kern

view src/asmops.h @ 47:f65b348780e3

continuing with the process implementation. not done yet, panics.
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 28 Jul 2011 05:43:04 +0300
parents e6de3c6015cb
children 4eaecb14fe31
line source
1 #ifndef ASMOPS_H_
2 #define ASMOPS_H_
4 #include <inttypes.h>
6 /* general purpose registers as they are pushed by pusha */
7 struct registers {
8 uint32_t edi, esi, ebp, esp;
9 uint32_t ebx, edx, ecx, eax;
10 } __attribute__ ((packed));
12 #define enable_intr() asm volatile("sti")
13 #define disable_intr() asm volatile("cli")
14 #define halt_cpu() asm volatile("hlt")
16 #define inb(dest, port) asm volatile( \
17 "inb %1, %0\n\t" \
18 : "=a" ((unsigned char)(dest)) \
19 : "dN" ((unsigned short)(port)))
21 #define inw(dest, port) asm volatile( \
22 "inw %1, %0\n\t" \
23 : "=a" ((unsigned short)(dest)) \
24 : "dN" ((unsigned short)(port)))
26 #define inl(dest, port) asm volatile( \
27 "inl %1, %0\n\t" \
28 : "=a" ((unsigned long)(dest)) \
29 : "dN" ((unsigned short)(port)))
31 #define outb(src, port) asm volatile( \
32 "outb %0, %1\n\t" \
33 :: "a" ((unsigned char)(src)), "dN" ((unsigned short)(port)))
35 #define outw(src, port) asm volatile( \
36 "outw %0, %1\n\t" \
37 :: "a" ((unsigned short)(src)), "dN" ((unsigned short)(port)))
39 #define outl(src, port) asm volatile( \
40 "outl %0, %1\n\t" \
41 :: "a" ((unsigned long)(src)), "dN" ((unsigned short)(port)))
43 #define iodelay() outb(0, 0x80)
45 #endif /* ASMOPS_H_ */