Add support for a FUNCFSEG macro that will force a "32bit flat" C function to be located in the f-segment. This is useful for 32bit code with inline assembler that thunks to 16bit mode.
Signed-off-by: Kevin O'Connor kevin@koconnor.net --- scripts/layoutrom.py | 16 +++++++++++----- src/types.h | 4 ++++ 2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/scripts/layoutrom.py b/scripts/layoutrom.py index 2454920..dd770fe 100755 --- a/scripts/layoutrom.py +++ b/scripts/layoutrom.py @@ -197,11 +197,14 @@ def doLayout(sections, config, genreloc): textsections + rodatasections + datasections, sec16_start , segoffset=BUILD_BIOS_ADDR)
- # Determine "fseg memory" data positions - sections32fseg = getSectionsCategory(sections, '32fseg') + # Determine 32bit "fseg memory" data positions + sections32textfseg = getSectionsCategory(sections, '32textfseg') + sec32textfseg_start, sec32textfseg_align = setSectionsStart( + sections32textfseg, sec32seg_start, 16)
+ sections32fseg = getSectionsCategory(sections, '32fseg') sec32fseg_start, sec32fseg_align = setSectionsStart( - sections32fseg, sec32seg_start, 16 + sections32fseg, sec32textfseg_start, 16 , segoffset=BUILD_BIOS_ADDR)
# Determine 32flat runtime positions @@ -274,13 +277,14 @@ def doLayout(sections, config, genreloc): # Print statistics size16 = BUILD_BIOS_ADDR + BUILD_BIOS_SIZE - sec16_start size32seg = sec16_start - sec32seg_start - size32fseg = sec32seg_start - sec32fseg_start + size32textfseg = sec32seg_start - sec32textfseg_start + size32fseg = sec32textfseg_start - sec32fseg_start size32flat = sec32fseg_start - sec32flat_start size32init = sec32flat_start - sec32init_start sizelow = li.sec32low_end - li.sec32low_start print("16bit size: %d" % size16) print("32bit segmented size: %d" % size32seg) - print("32bit flat size: %d" % size32flat) + print("32bit flat size: %d" % (size32flat + size32textfseg)) print("32bit flat init size: %d" % size32init) print("Lowmem size: %d" % sizelow) print("f-segment var size: %d" % size32fseg) @@ -659,6 +663,8 @@ def main(): section.category = '32low' elif section.name.startswith('.data.varfseg.'): section.category = '32fseg' + elif section.name.startswith('.text.32fseg.'): + section.category = '32textfseg' elif section.name.startswith('.fixedaddr.'): section.category = 'fixed' elif section.fileid == '32flat' and section not in runtimesections: diff --git a/src/types.h b/src/types.h index 097372c..6dd8c43 100644 --- a/src/types.h +++ b/src/types.h @@ -70,6 +70,8 @@ extern void __force_link_error__only_in_16bit(void) __noreturn; # define VARFSEG __section(".discard.varfseg." UNIQSEC) __VISIBLE __weak // Designate a variable at a specific address in the f-segment. # define VARFSEGFIXED(addr) __section(".discard.varfixed." UNIQSEC) __VISIBLE __weak +// Notes a 32bit flat function that must reside in the f-segment. +# define FUNCFSEG __section(".discard.32fseg." UNIQSEC) __VISIBLE __weak // Verify a variable is only accessable via 32bit "init" functions # define VARVERIFY32INIT __section(".discard.varinit." UNIQSEC) // Designate top-level assembler as 16bit only. @@ -90,6 +92,7 @@ extern void __force_link_error__only_in_16bit(void) __noreturn; # define VARLOW __section(".discard.varlow." UNIQSEC) __VISIBLE __weak # define VARFSEG __section(".discard.varfseg." UNIQSEC) __VISIBLE __weak # define VARFSEGFIXED(addr) __section(".discard.varfixed." UNIQSEC) __VISIBLE __weak +# define FUNCFSEG __section(".discard.32fseg." UNIQSEC) __VISIBLE __weak # define VARVERIFY32INIT __section(".discard.varinit." UNIQSEC) # define ASM16(code) # define ASM32FLAT(code) @@ -106,6 +109,7 @@ extern void __force_link_error__only_in_16bit(void) __noreturn; # define VARLOW __section(".data.varlow." UNIQSEC) __VISIBLE __weak # define VARFSEG __section(".data.varfseg." UNIQSEC) __VISIBLE # define VARFSEGFIXED(addr) __section(".fixedaddr." __stringify(addr)) __VISIBLE __aligned(1) +# define FUNCFSEG __section(".text.32fseg." UNIQSEC) __VISIBLE # define VARVERIFY32INIT __section(".data.varinit." UNIQSEC) # define ASM16(code) # define ASM32FLAT(code) __ASM(code)