blob: 0870ad5ddf7f63dd5e43de1f14b598e907e258c4 [file] [log] [blame]
Kevin O'Connorf076a3e2008-02-25 22:25:15 -05001// Basic x86 asm functions and function defs.
2//
3// Copyright (C) 2008 Kevin O'Connor <kevin@koconnor.net>
4//
5// This file may be distributed under the terms of the GNU GPLv3 license.
6
7#include "ioport.h" // outb
8
9static inline void irq_disable(void) {
10 asm volatile("cli": : :"memory");
11}
12
13static inline void irq_enable(void) {
14 asm volatile("sti": : :"memory");
15}
16
17static inline unsigned long irq_save(void)
18{
19 unsigned long flags;
20 asm volatile("pushfl ; popl %0" : "=g" (flags));
21 irq_disable();
22 return flags;
23}
24
25static inline void irq_restore(unsigned long flags)
26{
27 asm volatile("pushl %0 ; popfl" : : "g" (flags) : "memory", "cc");
28}
29
30#define DEBUGF(fmt, args...)
31#define BX_PANIC(fmt, args...)
32#define BX_INFO(fmt, args...)
33
34static inline void
35memset(void *s, int c, size_t n)
36{
37 while (n)
38 ((char *)s)[n--] = c;
39}
40
41// output.c
42void bprintf(u16 action, const char *fmt, ...)
43 __attribute__ ((format (printf, 2, 3)));
44struct bregs;
45void __debug_enter(const char *fname, struct bregs *regs);
46void __debug_exit(const char *fname, struct bregs *regs);
47#define debug_enter(regs) \
48 __debug_enter(__func__, regs)
49#define debug_exit(regs) \
50 __debug_exit(__func__, regs)
51#define printf(fmt, args...) \
52 bprintf(0, fmt , ##args )
53
54// kbd.c
55void handle_15c2(struct bregs *regs);