aboutsummaryrefslogtreecommitdiff
path: root/src/util.h
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2008-02-25 22:25:15 -0500
committerKevin O'Connor <kevin@koconnor.net>2008-02-25 22:25:15 -0500
commitf076a3eeb9a0185b06a2abbba8c798a7761b2bdf (patch)
treec4a56a0d43fc683678e91ab10a9fe561f9ef65ca /src/util.h
downloadseabios-hppa-rel-0.1.0.zip
seabios-hppa-rel-0.1.0.tar.gz
seabios-hppa-rel-0.1.0.tar.bz2
Initial checkin.rel-0.1.0
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/util.h b/src/util.h
new file mode 100644
index 0000000..0870ad5
--- /dev/null
+++ b/src/util.h
@@ -0,0 +1,55 @@
+// Basic x86 asm functions and function defs.
+//
+// Copyright (C) 2008 Kevin O'Connor <kevin@koconnor.net>
+//
+// This file may be distributed under the terms of the GNU GPLv3 license.
+
+#include "ioport.h" // outb
+
+static inline void irq_disable(void) {
+ asm volatile("cli": : :"memory");
+}
+
+static inline void irq_enable(void) {
+ asm volatile("sti": : :"memory");
+}
+
+static inline unsigned long irq_save(void)
+{
+ unsigned long flags;
+ asm volatile("pushfl ; popl %0" : "=g" (flags));
+ irq_disable();
+ return flags;
+}
+
+static inline void irq_restore(unsigned long flags)
+{
+ asm volatile("pushl %0 ; popfl" : : "g" (flags) : "memory", "cc");
+}
+
+#define DEBUGF(fmt, args...)
+#define BX_PANIC(fmt, args...)
+#define BX_INFO(fmt, args...)
+
+static inline void
+memset(void *s, int c, size_t n)
+{
+ while (n)
+ ((char *)s)[n--] = c;
+}
+
+// output.c
+void bprintf(u16 action, const char *fmt, ...)
+ __attribute__ ((format (printf, 2, 3)));
+struct bregs;
+void __debug_enter(const char *fname, struct bregs *regs);
+void __debug_exit(const char *fname, struct bregs *regs);
+#define debug_enter(regs) \
+ __debug_enter(__func__, regs)
+#define debug_exit(regs) \
+ __debug_exit(__func__, regs)
+#define printf(fmt, args...) \
+ bprintf(0, fmt , ##args )
+
+// kbd.c
+void handle_15c2(struct bregs *regs);