aboutsummaryrefslogtreecommitdiff
path: root/src/farptr.h
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2008-02-25 22:29:55 -0500
committerKevin O'Connor <kevin@koconnor.net>2008-02-25 22:29:55 -0500
commit4b60c000deee2002ba272b45a1121df7495c39f9 (patch)
tree15b897b77d26f30a52d13605c905e6fd42b3e83d /src/farptr.h
parentf076a3eeb9a0185b06a2abbba8c798a7761b2bdf (diff)
downloadseabios-hppa-4b60c000deee2002ba272b45a1121df7495c39f9.zip
seabios-hppa-4b60c000deee2002ba272b45a1121df7495c39f9.tar.gz
seabios-hppa-4b60c000deee2002ba272b45a1121df7495c39f9.tar.bz2
Version 0.1.1rel-0.1.1
Diffstat (limited to 'src/farptr.h')
-rw-r--r--src/farptr.h28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/farptr.h b/src/farptr.h
index 1c3044b..34c3ac2 100644
--- a/src/farptr.h
+++ b/src/farptr.h
@@ -29,7 +29,7 @@
__asm__ __volatile__("movl %0, %%" #SEG ":%1" \
: : "r"(value), "m"(var))
-#define GET_VAR(seg, var) ({ \
+#define __GET_VAR(seg, var) ({ \
typeof(var) __val; \
if (__builtin_types_compatible_p(typeof(__val), u8)) \
__val = READ8_SEG(seg, var); \
@@ -39,7 +39,7 @@
__val = READ32_SEG(seg, var); \
__val; })
-#define SET_VAR(seg, var, val) do { \
+#define __SET_VAR(seg, var, val) do { \
if (__builtin_types_compatible_p(typeof(var), u8)) \
WRITE8_SEG(seg, var, (val)); \
else if (__builtin_types_compatible_p(typeof(var), u16)) \
@@ -48,10 +48,30 @@
WRITE32_SEG(seg, var, (val)); \
} while (0)
-#define SET_SEG(SEG, value) \
+#define __SET_SEG(SEG, value) \
__asm__ __volatile__("movw %w0, %%" #SEG : : "r"(value))
-#define GET_SEG(SEG) ({ \
+#define __GET_SEG(SEG) ({ \
u16 __seg; \
__asm__ __volatile__("movw %%" #SEG ", %w0" : "=r"(__seg)); \
__seg;})
+#ifdef MODE16
+#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)
+#define GET_SEG(SEG) __GET_SEG(SEG)
+#else
+// In 32-bit mode there is no need to mess with the segments.
+#define GET_VAR(seg, var) (var)
+#define SET_VAR(seg, var, val) (var) = (val)
+#define SET_SEG(SEG, value) ((void)(value))
+#define GET_SEG(SEG) 0
+#endif
+
+#define GET_FARVAR(seg, var) ({ \
+ SET_SEG(ES, (seg)); \
+ GET_VAR(ES, (var)); })
+#define SET_FARVAR(seg, var, val) do { \
+ SET_SEG(ES, (seg)); \
+ SET_VAR(ES, (var), val); \
+ } while (0)