When in 32bit mode - just define it to 0.
COMMONCFLAGS += $(call cc-option,$(CC),-fno-stack-protector,)
COMMONCFLAGS += $(call cc-option,$(CC),-fno-stack-protector-all,)
-CFLAGS = $(COMMONCFLAGS) -g
-CFLAGS16INC = $(COMMONCFLAGS) -DMODE16 -fno-jump-tables -fno-defer-pop \
+CFLAGS = $(COMMONCFLAGS) -g -DMODE16=0
+CFLAGS16INC = $(COMMONCFLAGS) -DMODE16=1 -fno-jump-tables -fno-defer-pop \
$(call cc-option,$(CC),--param large-stack-frame=8,)
CFLAGS16 = $(CFLAGS16INC) -g
int
usleep(u32 count)
{
-#ifdef MODE16
- // In 16bit mode, use the rtc to wait for the specified time.
- u8 statusflag = 0;
- int ret = set_usertimer(count, GET_SEG(SS), (u32)&statusflag);
- if (ret)
- return -1;
- irq_enable();
- while (!statusflag)
- cpu_relax();
- irq_disable();
- return 0;
-#else
- // In 32bit mode, we need to call into 16bit mode to sleep.
- struct bregs br;
- memset(&br, 0, sizeof(br));
- br.ah = 0x86;
- br.cx = count >> 16;
- br.dx = count;
- call16_int(0x15, &br);
- if (br.flags & F_CF)
- return -1;
- return 0;
-#endif
+ if (MODE16) {
+ // In 16bit mode, use the rtc to wait for the specified time.
+ u8 statusflag = 0;
+ int ret = set_usertimer(count, GET_SEG(SS), (u32)&statusflag);
+ if (ret)
+ return -1;
+ irq_enable();
+ while (!statusflag)
+ cpu_relax();
+ irq_disable();
+ return 0;
+ } else {
+ // In 32bit mode, we need to call into 16bit mode to sleep.
+ struct bregs br;
+ memset(&br, 0, sizeof(br));
+ br.ah = 0x86;
+ br.cx = count >> 16;
+ br.dx = count;
+ call16_int(0x15, &br);
+ if (br.flags & F_CF)
+ return -1;
+ return 0;
+ }
}
#define RET_ECLOCKINUSE 0x83
#define MAKE_FARPTR(seg,off) ((void*)(((seg)<<4)+(off)))
-#ifdef MODE16
+#if MODE16 == 1
// Definitions when in 16 bit mode.
#define GET_FARVAR(seg, var) __GET_FARVAR((seg), (var))
};
#define __VISIBLE __attribute__((externally_visible))
-#ifdef MODE16
+#if MODE16 == 1
// Notes a function as externally visible in the 16bit code chunk.
#define VISIBLE16 __VISIBLE
// Notes a function as externally visible in the 32bit code chunk.
call16(struct bregs *callregs)
{
asm volatile(
-#ifdef MODE16
+#if MODE16 == 1
"calll __call16\n"
#else
"calll __call16_from32\n"