kern

view src/asmops.h @ 42:e6de3c6015cb

started implementing processes
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 24 Jul 2011 18:29:24 +0300
parents e70b1ab9613e
children 5f6c5751ae05
line source
1 #ifndef ASMOPS_H_
2 #define ASMOPS_H_
4 /* general purpose registers as they are pushed by pusha */
5 struct registers {
6 uint32_t edi, esi, ebp, esp;
7 uint32_t ebx, edx, ecx, eax;
8 } __attribute__ ((packed));
10 #define enable_intr() asm volatile("sti")
11 #define disable_intr() asm volatile("cli")
12 #define halt_cpu() asm volatile("hlt")
14 #define inb(dest, port) asm volatile( \
15 "inb %1, %0\n\t" \
16 : "=a" ((unsigned char)(dest)) \
17 : "dN" ((unsigned short)(port)))
19 #define inw(dest, port) asm volatile( \
20 "inw %1, %0\n\t" \
21 : "=a" ((unsigned short)(dest)) \
22 : "dN" ((unsigned short)(port)))
24 #define inl(dest, port) asm volatile( \
25 "inl %1, %0\n\t" \
26 : "=a" ((unsigned long)(dest)) \
27 : "dN" ((unsigned short)(port)))
29 #define outb(src, port) asm volatile( \
30 "outb %0, %1\n\t" \
31 :: "a" ((unsigned char)(src)), "dN" ((unsigned short)(port)))
33 #define outw(src, port) asm volatile( \
34 "outw %0, %1\n\t" \
35 :: "a" ((unsigned short)(src)), "dN" ((unsigned short)(port)))
37 #define outl(src, port) asm volatile( \
38 "outl %0, %1\n\t" \
39 :: "a" ((unsigned long)(src)), "dN" ((unsigned short)(port)))
41 #define iodelay() outb(0, 0x80)
43 #endif /* ASMOPS_H_ */