Skip to content

Commit

Permalink
code-mismatch: fix various kernel code discrepancies which break TURB…
Browse files Browse the repository at this point in the history
…O C build

main issue is missing ASM attributes that C and asm code uses different names
correct long constant by standard suffix 'L' or 'UL'
  • Loading branch information
jmalak authored and PerditionC committed Jul 10, 2024
1 parent c928849 commit 4ca2825
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion kernel/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ STATIC struct MenuSelector MenuStruct[MENULINESMAX] BSS_INIT({0});

int nMenuLine BSS_INIT(0);
int MenuColor = -1;
extern char kernel_command_line[256];
extern char ASM kernel_command_line[256];
extern int kernel_command_line_length;

STATIC void WriteMenuLine(struct MenuSelector *menu)
Expand Down
4 changes: 2 additions & 2 deletions kernel/dosfns.c
Original file line number Diff line number Diff line change
Expand Up @@ -921,12 +921,12 @@ COUNT DosGetExtFree(BYTE FAR * DriveString, struct xfreespace FAR * xfsp)
total = (((UDWORD)rg[0] << 16UL) | rg[1]);
avail = (((UDWORD)rg[2] << 16UL) | rg[3]);

while (total > 0x00ffffff && spc < 128) {
while (total > 0x00ffffffUL && spc < 128) {
spc *= 2;
avail /= 2;
total /= 2;
}
while (total > 0x00ffffff && bps < 32768) {
while (total > 0x00ffffffUL && bps < 32768UL) {
bps *= 2;
avail /= 2;
total /= 2;
Expand Down
2 changes: 1 addition & 1 deletion kernel/init-mod.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#define BSS_INIT(x)
#endif

extern struct _KernelConfig InitKernelConfig;
extern struct _KernelConfig ASM InitKernelConfig;

/*
* Functions in `INIT_TEXT' may need to call functions in `_TEXT'. The entry
Expand Down
2 changes: 1 addition & 1 deletion kernel/initdisk.c
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ STATIC int LBA_Get_Drive_Parameters(int drive, struct DriveParamS *driveParam, i
else
{
if (firstPass) printf("Drive %02x is too large to handle, restricted to 2TB\n", drive);
driveParam->total_sectors = 0xffffffffu;
driveParam->total_sectors = 0xffffffffUL;
}

/* if we arrive here, mark drive as LBA capable */
Expand Down
4 changes: 2 additions & 2 deletions kernel/inthndlr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1916,7 +1916,7 @@ struct int2f12regs {
UWORD callerARG1; /* used if called from INT2F/12 */
};

extern intvec BIOSInt13, UserInt13, BIOSInt19;
extern intvec ASM BIOSInt13, ASM UserInt13, ASM BIOSInt19;


/* WARNING: modifications in `r' are used outside of int2F_12_handler()
Expand Down Expand Up @@ -2405,7 +2405,7 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs FAR *pr)
if (cdsp->cdsFlags)
{
TempCDS.cdsDpb = cdsp->cdsDpb;
TempCDS.cdsFlags = CDSPHYSDRV; // don't inherit CDS flags
TempCDS.cdsFlags = CDSPHYSDRV; /* don't inherit CDS flags */
}
else
{
Expand Down
6 changes: 3 additions & 3 deletions kernel/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ __segment DosTextSeg = 0;

struct lol FAR *LoL = &DATASTART;

struct _KernelConfig InitKernelConfig = { -1 };
char kernel_command_line[256] = { 0, -1 }; /* special none value */
struct _KernelConfig ASM InitKernelConfig = { -1 };
char ASM kernel_command_line[256] = { 0, -1 }; /* special none value */
int kernel_command_line_length BSS_INIT(0);
UBYTE debugger_present = 0xFF; /* initialised in kernel.asm
UBYTE ASM debugger_present = 0xFF; /* initialised in kernel.asm
do NOT set 0 here or compiler may
move it into bss that we zero out */

Expand Down
2 changes: 1 addition & 1 deletion sys/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,7 @@ void put_boot(SYSOptions *opts)
clusters = dataSectors / (((bs32->bsSecPerClust - 1) & 0xFF) + 1);

if (bs32->bsFATsecs == 0) {
if (clusters >= 0xFFFfff5) { /* FAT32 has 28 significant bits */
if (clusters >= 0xFFFfff5UL) { /* FAT32 has 28 significant bits */
printf("Too many clusters (%lXh) for FAT32 file system!\n", clusters);
exit(1);
}
Expand Down

0 comments on commit 4ca2825

Please sign in to comment.