kern
view src/asmops.h @ 86:379332fc1667
implementing ata read/write
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Wed, 07 Dec 2011 14:03:11 +0200 |
parents | 5f6c5751ae05 |
children |
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 push_regs() asm volatile("pusha");
17 #define pop_regs() asm volatile("popa");
19 #define inb(dest, port) asm volatile( \
20 "inb %1, %0\n\t" \
21 : "=a" ((unsigned char)(dest)) \
22 : "dN" ((unsigned short)(port)))
24 #define inw(dest, port) asm volatile( \
25 "inw %1, %0\n\t" \
26 : "=a" ((unsigned short)(dest)) \
27 : "dN" ((unsigned short)(port)))
29 #define inl(dest, port) asm volatile( \
30 "inl %1, %0\n\t" \
31 : "=a" ((unsigned long)(dest)) \
32 : "dN" ((unsigned short)(port)))
34 #define outb(src, port) asm volatile( \
35 "outb %0, %1\n\t" \
36 :: "a" ((unsigned char)(src)), "dN" ((unsigned short)(port)))
38 #define outw(src, port) asm volatile( \
39 "outw %0, %1\n\t" \
40 :: "a" ((unsigned short)(src)), "dN" ((unsigned short)(port)))
42 #define outl(src, port) asm volatile( \
43 "outl %0, %1\n\t" \
44 :: "a" ((unsigned long)(src)), "dN" ((unsigned short)(port)))
46 #define iodelay() outb(0, 0x80)
49 #endif /* ASMOPS_H_ */