kern

annotate src/asmops.h @ 87:178d5a95e6de

implementing ata read
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 07 Dec 2011 17:10:37 +0200
parents 5f6c5751ae05
children
rev   line source
nuclear@1 1 #ifndef ASMOPS_H_
nuclear@1 2 #define ASMOPS_H_
nuclear@1 3
nuclear@43 4 #include <inttypes.h>
nuclear@43 5
nuclear@42 6 /* general purpose registers as they are pushed by pusha */
nuclear@42 7 struct registers {
nuclear@42 8 uint32_t edi, esi, ebp, esp;
nuclear@42 9 uint32_t ebx, edx, ecx, eax;
nuclear@42 10 } __attribute__ ((packed));
nuclear@42 11
nuclear@10 12 #define enable_intr() asm volatile("sti")
nuclear@10 13 #define disable_intr() asm volatile("cli")
nuclear@10 14 #define halt_cpu() asm volatile("hlt")
nuclear@10 15
nuclear@54 16 #define push_regs() asm volatile("pusha");
nuclear@54 17 #define pop_regs() asm volatile("popa");
nuclear@54 18
nuclear@1 19 #define inb(dest, port) asm volatile( \
nuclear@1 20 "inb %1, %0\n\t" \
nuclear@2 21 : "=a" ((unsigned char)(dest)) \
nuclear@2 22 : "dN" ((unsigned short)(port)))
nuclear@1 23
nuclear@10 24 #define inw(dest, port) asm volatile( \
nuclear@10 25 "inw %1, %0\n\t" \
nuclear@2 26 : "=a" ((unsigned short)(dest)) \
nuclear@2 27 : "dN" ((unsigned short)(port)))
nuclear@1 28
nuclear@1 29 #define inl(dest, port) asm volatile( \
nuclear@1 30 "inl %1, %0\n\t" \
nuclear@2 31 : "=a" ((unsigned long)(dest)) \
nuclear@2 32 : "dN" ((unsigned short)(port)))
nuclear@1 33
nuclear@1 34 #define outb(src, port) asm volatile( \
nuclear@1 35 "outb %0, %1\n\t" \
nuclear@2 36 :: "a" ((unsigned char)(src)), "dN" ((unsigned short)(port)))
nuclear@1 37
nuclear@10 38 #define outw(src, port) asm volatile( \
nuclear@10 39 "outw %0, %1\n\t" \
nuclear@2 40 :: "a" ((unsigned short)(src)), "dN" ((unsigned short)(port)))
nuclear@1 41
nuclear@1 42 #define outl(src, port) asm volatile( \
nuclear@1 43 "outl %0, %1\n\t" \
nuclear@2 44 :: "a" ((unsigned long)(src)), "dN" ((unsigned short)(port)))
nuclear@1 45
nuclear@36 46 #define iodelay() outb(0, 0x80)
nuclear@36 47
nuclear@54 48
nuclear@1 49 #endif /* ASMOPS_H_ */