diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2009-12-30 12:14:53 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2009-12-30 12:14:53 -0500 |
commit | 871e0a0c142f7b2fcaa93600c5958d4ae4fa1394 (patch) | |
tree | 9b439bc44c321d659cd56c2cae71c917684b67d5 /src/biosvar.h | |
parent | eda2c83bfa9d54a6f751e31ea555e53966f60272 (diff) | |
download | seabios-871e0a0c142f7b2fcaa93600c5958d4ae4fa1394.tar.gz |
Add support for 32bit PCI BIOS entry.
Create a new code blob (code32seg) with support for 32bit functions
that need to utilize explicit segment accesses.
This code blob uses global variables relative to %gs and with a
dynamic code offset (determined by get_global_offset()).
Add BIOS32 structure and code.
Add code for 32bit PCI BIOS code.
Diffstat (limited to 'src/biosvar.h')
-rw-r--r-- | src/biosvar.h | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/biosvar.h b/src/biosvar.h index 6a789e41..db6783e0 100644 --- a/src/biosvar.h +++ b/src/biosvar.h @@ -260,12 +260,31 @@ get_ebda_ptr() * Global variables ****************************************************************/ +#if MODE16 == 0 && MODESEGMENT == 1 +// In 32bit segmented mode %cs may not be readable and the code may be +// relocated. The entry code sets up %gs with a readable segment and +// the code offset can be determined by get_global_offset(). +#define GLOBAL_SEGREG GS +static inline u32 __attribute_const get_global_offset(void) { + u32 ret; + asm(" calll 1f\n" + "1:popl %0\n" + " subl $1b, %0" + : "=r"(ret)); + return ret; +} +#else #define GLOBAL_SEGREG CS +static inline u32 __attribute_const get_global_offset(void) { + return 0; +} +#endif static inline u16 get_global_seg() { return GET_SEG(GLOBAL_SEGREG); } -#define GET_GLOBAL(var) \ - GET_VAR(GLOBAL_SEGREG, (var)) +#define GET_GLOBAL(var) \ + GET_VAR(GLOBAL_SEGREG, *(typeof(&(var)))((void*)&(var) \ + + get_global_offset())) #define SET_GLOBAL(var, val) do { \ ASSERT32FLAT(); \ (var) = (val); \ |