From f8e087767bb9fa82eac04b6819bb3cb78b2e8028 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sat, 6 May 2006 18:57:31 +0000 Subject: [PATCH] Allow access to variables in .text16 as well as .data16. Chained interrupt vectors, for example, will be easiest to handle if placed in .text16. --- src/arch/i386/include/libkir.h | 4 +++- src/arch/i386/include/librm.h | 11 ++++++++++- src/arch/i386/include/realmode.h | 3 +++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/arch/i386/include/libkir.h b/src/arch/i386/include/libkir.h index 44cb75e2..28db8308 100644 --- a/src/arch/i386/include/libkir.h +++ b/src/arch/i386/include/libkir.h @@ -10,9 +10,11 @@ * */ -/* Access to variables in .data16, in a way compatible with librm */ +/* Access to variables in .data16 and .text16 in a way compatible with librm */ #define __data16( variable ) variable +#define __text16( variable ) variable #define __use_data16( variable ) variable +#define __use_text16( variable ) variable /* Copy to/from base memory */ diff --git a/src/arch/i386/include/librm.h b/src/arch/i386/include/librm.h index b4970c02..3a5d9468 100644 --- a/src/arch/i386/include/librm.h +++ b/src/arch/i386/include/librm.h @@ -15,17 +15,26 @@ * */ -/* Access to variables in .data16 */ +/* Access to variables in .data16 and .text16 */ extern char *data16; +extern char *text16; #define __data16( variable ) \ _data16_ ## variable __asm__ ( #variable ) \ __attribute__ (( section ( ".data16" ) )) +#define __text16( variable ) \ + _text16_ ## variable __asm__ ( #variable ) \ + __attribute__ (( section ( ".text16" ) )) + #define __use_data16( variable ) \ ( * ( ( typeof ( _data16_ ## variable ) * ) \ & ( data16 [ ( size_t ) & ( _data16_ ## variable ) ] ) ) ) +#define __use_text16( variable ) \ + ( * ( ( typeof ( _text16_ ## variable ) * ) \ + & ( text16 [ ( size_t ) & ( _text16_ ## variable ) ] ) ) ) + /* Variables in librm.S, present in the normal data segment */ extern uint16_t rm_sp; extern uint16_t rm_ss; diff --git a/src/arch/i386/include/realmode.h b/src/arch/i386/include/realmode.h index b7f0dc9d..fa8c7863 100644 --- a/src/arch/i386/include/realmode.h +++ b/src/arch/i386/include/realmode.h @@ -80,6 +80,9 @@ typedef struct { * return foo; * } * + * Variables may also be placed in .text16 using __text16 and + * __use_text16. Some variables (e.g. chained interrupt vectors) fit + * most naturally in .text16; most should be in .data16. */ /*