Move variables from assembler to C code.
[seabios.git] / src / types.h
index 8dd1a3b1c0d03fcc1d945ceb5e081e0d13188754..52e508bca4a8128f4d984ac40e3ed73bc5b2a716 100644 (file)
@@ -2,7 +2,7 @@
 //
 // Copyright (C) 2008  Kevin O'Connor <kevin@koconnor.net>
 //
-// This file may be distributed under the terms of the GNU GPLv3 license.
+// This file may be distributed under the terms of the GNU LGPLv3 license.
 #ifndef __TYPES_H
 #define __TYPES_H
 
@@ -22,14 +22,27 @@ union u64_u32_u {
 };
 
 #define __VISIBLE __attribute__((externally_visible))
+
 #if MODE16 == 1
 // Notes a function as externally visible in the 16bit code chunk.
-#define VISIBLE16 __VISIBLE
+# define VISIBLE16 __VISIBLE
 // Notes a function as externally visible in the 32bit code chunk.
-#define VISIBLE32
+# define VISIBLE32
+// Designate a variable as (only) visible to 16bit code.
+# define VAR16 __attribute__((section(".data16." __FILE__ "." __stringify(__LINE__))))
+// Designate a variable as visible to both 32bit and 16bit code.
+# define VAR16_32 VAR16 __VISIBLE
+// Designate a variable at a specific 16bit address
+# define VAR16FIXED(addr) __aligned(1) __VISIBLE  __attribute__((section(".fixedaddr." __stringify(addr))))
+// Designate top-level assembler as 16bit only.
+# define ASM16(code) asm(".section .text.asm." __FILE__ "." __stringify(__LINE__) "\n\t" code)
 #else
-#define VISIBLE16
-#define VISIBLE32 __VISIBLE
+# define VISIBLE16
+# define VISIBLE32 __VISIBLE
+# define VAR16 __attribute__((section(".discard.var16")))
+# define VAR16_32 VAR16 __VISIBLE __attribute__((weak))
+# define VAR16FIXED(addr) VAR16_32
+# define ASM16(code)
 #endif
 
 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)