aboutsummaryrefslogtreecommitdiff
path: root/src/bregs.h
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2008-07-04 13:04:29 -0400
committerKevin O'Connor <kevin@koconnor.net>2008-07-04 13:04:29 -0400
commit9521e26a164eb4689b34d82a5de0d998bdd4c4dc (patch)
treed3ba8e12b31213defe5fa794e4d0bcec711c871f /src/bregs.h
parent0525d29af0803bdfca40f9bb8b1f8cf5b9a84c05 (diff)
downloadseabios-hppa-9521e26a164eb4689b34d82a5de0d998bdd4c4dc.zip
seabios-hppa-9521e26a164eb4689b34d82a5de0d998bdd4c4dc.tar.gz
seabios-hppa-9521e26a164eb4689b34d82a5de0d998bdd4c4dc.tar.bz2
Extract 'struct bregs' out of biosvar.h; clean up header includes.
Diffstat (limited to 'src/bregs.h')
-rw-r--r--src/bregs.h90
1 files changed, 90 insertions, 0 deletions
diff --git a/src/bregs.h b/src/bregs.h
new file mode 100644
index 0000000..8da6c52
--- /dev/null
+++ b/src/bregs.h
@@ -0,0 +1,90 @@
+// Structure layout of cpu registers the the bios uses.
+//
+// Copyright (C) 2008 Kevin O'Connor <kevin@koconnor.net>
+//
+// This file may be distributed under the terms of the GNU GPLv3 license.
+
+#ifndef __BREGS_H
+#define __BREGS_H
+
+
+/****************************************************************
+ * Registers saved/restored in romlayout.S
+ ****************************************************************/
+
+#define UREG(ER, R, RH, RL) union { u32 ER; struct { u16 R; u16 R ## _hi; }; struct { u8 RL; u8 RH; u8 R ## _hilo; u8 R ## _hihi; }; }
+
+// Layout of registers passed in to irq handlers. Note that this
+// layout corresponds to code in romlayout.S - don't change it here
+// without also updating the assembler code.
+struct bregs {
+ u16 ds;
+ u16 es;
+ UREG(edi, di, di_hi, di_lo);
+ UREG(esi, si, si_hi, si_lo);
+ UREG(ebx, bx, bh, bl);
+ UREG(edx, dx, dh, dl);
+ UREG(ecx, cx, ch, cl);
+ UREG(eax, ax, ah, al);
+ u16 ip;
+ u16 cs;
+ u16 flags;
+} PACKED;
+
+
+/****************************************************************
+ * Helper functions
+ ****************************************************************/
+
+// bregs flags bitdefs
+#define F_ZF (1<<6)
+#define F_CF (1<<0)
+
+static inline void
+set_cf(struct bregs *regs, int cond)
+{
+ if (cond)
+ regs->flags |= F_CF;
+ else
+ regs->flags &= ~F_CF;
+}
+
+// Frequently used return codes
+#define RET_EUNSUPPORTED 0x86
+
+static inline void
+set_success(struct bregs *regs)
+{
+ set_cf(regs, 0);
+}
+
+static inline void
+set_code_success(struct bregs *regs)
+{
+ regs->ah = 0;
+ set_cf(regs, 0);
+}
+
+static inline void
+set_fail_silent(struct bregs *regs)
+{
+ set_cf(regs, 1);
+}
+
+static inline void
+set_code_fail_silent(struct bregs *regs, u8 code)
+{
+ regs->ah = code;
+ set_cf(regs, 1);
+}
+
+#define set_fail(regs) \
+ __set_fail(__func__, (regs))
+#define set_code_fail(regs, code) \
+ __set_code_fail(__func__, (regs), (code))
+
+// util.c
+void __set_fail(const char *fname, struct bregs *regs);
+void __set_code_fail(const char *fname, struct bregs *regs, u8 code);
+
+#endif // bregs.h