@@ -254,8 +254,8 @@ extern u8 _datalow_seg, _datalow_base[];
#define SEG_LOW ((u32)&_datalow_seg)
#if MODESEGMENT
-#define GET_LOW(var) GET_FARVAR(SEG_LOW, (var))
-#define SET_LOW(var, val) SET_FARVAR(SEG_LOW, (var), (val))
+#define GET_LOW(var) __GET_FARVAR("addr32 ", SEG_LOW, (var))
+#define SET_LOW(var, val) __SET_FARVAR("addr32 ", SEG_LOW, (var), (val))
#define LOWFLAT2LOW(var) ((typeof(var))((void*)(var) - (u32)_datalow_base))
#else
#define GET_LOW(var) (var)
@@ -106,13 +106,13 @@ DECL_SEGFUNCS(SS)
// Macros for accessing a variable in another segment. (They
// automatically update the %es segment and then make the appropriate
// access.)
-#define __GET_FARVAR(seg, var) ({ \
+#define __GET_FARVAR(prefix, seg, var) ({ \
SET_SEG(ES, (seg)); \
- GET_VAR(ES, (var)); })
-#define __SET_FARVAR(seg, var, val) do { \
- typeof(var) __sfv_val = (val); \
- SET_SEG(ES, (seg)); \
- SET_VAR(ES, (var), __sfv_val); \
+ __GET_VAR(prefix, ES, (var)); })
+#define __SET_FARVAR(prefix, seg, var, val) do { \
+ typeof(var) __sfv_val = (val); \
+ SET_SEG(ES, (seg)); \
+ __SET_VAR(prefix, ES, (var), __sfv_val); \
} while (0)
// Macros for accesssing a 32bit flat mode pointer from 16bit real
@@ -139,8 +139,8 @@ DECL_SEGFUNCS(SS)
#if MODESEGMENT == 1
// Definitions when using segmented mode.
-#define GET_FARVAR(seg, var) __GET_FARVAR((seg), (var))
-#define SET_FARVAR(seg, var, val) __SET_FARVAR((seg), (var), (val))
+#define GET_FARVAR(seg, var) __GET_FARVAR("", (seg), (var))
+#define SET_FARVAR(seg, var, val) __SET_FARVAR("", (seg), (var), (val))
#define GET_VAR(seg, var) __GET_VAR("", seg, (var))
#define SET_VAR(seg, var, val) __SET_VAR("", seg, (var), (val))
#define SET_SEG(SEG, value) __SET_SEG(SEG, (value))
@@ -398,7 +398,7 @@ irqentry_extrastack:
pushl %eax
movl $_datalow_seg, %eax
movl %eax, %ds
- movl StackPos, %eax
+ addr32 movl StackPos, %eax
subl $24, %eax
popl 0(%eax) // Backup %eax, %ds, %es, %ecx, %edx
popw 4(%eax)
@@ -40,7 +40,7 @@ stack_hop(u32 eax, u32 edx, void *func)
// Copy stack seg to %ds/%ss and set %esp
"movw %w6, %%ds\n"
"movw %w6, %%ss\n"
- "movl %5, %%esp\n"
+ "addr32 movl %5, %%esp\n"
"pushl %3\n"
"pushl %4\n"
// Call func
@@ -68,9 +68,9 @@ stack_hop_back(u32 eax, u32 edx, void *func)
u32 bkup_stack_pos, temp;
asm volatile(
// Backup stack_pos and current %ss/%esp
- "movl %6, %4\n"
+ "addr32 movl %6, %4\n"
"movw %%ss, %w3\n"
- "movl %%esp, %6\n"
+ "addr32 movl %%esp, %6\n"
// Restore original callers' %ss/%esp
"movl -4(%4), %5\n"
"movl %5, %%ss\n"
@@ -81,8 +81,8 @@ stack_hop_back(u32 eax, u32 edx, void *func)
// Restore %ss/%esp and stack_pos
"movw %w3, %%ds\n"
"movw %w3, %%ss\n"
- "movl %6, %%esp\n"
- "movl %4, %6"
+ "addr32 movl %6, %%esp\n"
+ "addr32 movl %4, %6"
: "+a" (eax), "+d" (edx), "+c" (func), "=&r" (bkup_ss)
, "=&r" (bkup_stack_pos), "=&r" (temp), "+m" (StackPos)
:
@@ -48,8 +48,6 @@ def setSectionsStart(sections, endaddr, minalign=1, segoffset=0):
totspace = alignpos(totspace, section.align) + section.size
startaddr = (endaddr - totspace) / minalign * minalign
curaddr = startaddr
- # out = [(addr, sectioninfo), ...]
- out = []
for section in sections:
curaddr = alignpos(curaddr, section.align)
section.finalloc = curaddr
@@ -261,7 +259,8 @@ def outXRefs(sections, useseg=0):
loc = symbol.section.finalloc
if useseg:
loc = symbol.section.finalsegloc
- out += "%s = 0x%x ;\n" % (reloc.symbolname, loc + symbol.offset)
+ out += "%s = 0x%x ;\n" % (
+ reloc.symbolname, (loc + symbol.offset) & 0xffffffff)
return out
# Write LD script includes for the given sections using relative offsets