2007-04-02 14:52:01 +02:00
|
|
|
|
#include "types.h"
|
2007-04-02 15:11:17 +02:00
|
|
|
|
|
2007-04-02 15:30:47 +02:00
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
#define sti() asm("sti"::)
|
|
|
|
|
|
|
|
|
|
#define cli() asm("cli"::)
|
|
|
|
|
|
|
|
|
|
#define nop() asm("nop"::)
|
|
|
|
|
|
2018-08-17 11:17:24 +02:00
|
|
|
|
#define pushad() asm("pushal"::)
|
|
|
|
|
|
|
|
|
|
#define popad() asm("popal"::)
|
|
|
|
|
|
|
|
|
|
#define pushf() asm("pushf"::)
|
|
|
|
|
|
|
|
|
|
#define popf() asm("popf"::)
|
|
|
|
|
|
|
|
|
|
#define iret() asm("iret"::)
|
2007-04-02 15:30:47 +02:00
|
|
|
|
|
|
|
|
|
#define irqendmaster() asm("movb $0x20,%al; \
|
|
|
|
|
outb %al,$0x20;")
|
|
|
|
|
|
|
|
|
|
#define irqendslave() asm("movb $0x20,%al; \
|
|
|
|
|
outb %al,$0xA0;")
|
|
|
|
|
|
2018-08-31 02:48:03 +02:00
|
|
|
|
#define lidt(idtr) asm ("lidtl %0"::"m" (*idtr))
|
|
|
|
|
|
|
|
|
|
#define lgdt(gdtr) asm ("lgdtl %0"::"m" (*gdtr))
|
|
|
|
|
|
|
|
|
|
#define sidt(idtr) asm ("sidtl %0"::"m" (*idtr))
|
|
|
|
|
|
|
|
|
|
#define sgdt(gdtr) asm ("sgdtl %0"::"m" (*gdtr))
|
2007-04-02 15:30:47 +02:00
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
2007-04-02 14:52:01 +02:00
|
|
|
|
|
|
|
|
|
#define outb(port,value) \
|
|
|
|
|
asm volatile ("outb %%al,%%dx"::"d" (port), "a" (value));
|
|
|
|
|
|
|
|
|
|
#define outw(port,value) \
|
2007-04-02 14:55:34 +02:00
|
|
|
|
asm volatile ("outw %%ax,%%dx"::"d" (port), "a" (value));
|
2007-04-02 14:52:01 +02:00
|
|
|
|
|
2007-04-02 15:11:17 +02:00
|
|
|
|
#define outd(port,value) \
|
2007-04-02 15:30:47 +02:00
|
|
|
|
asm volatile ("outl %%eax,%%dx"::"d" (port), "a" (value));
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
2007-04-02 15:11:17 +02:00
|
|
|
|
|
2007-04-02 14:52:01 +02:00
|
|
|
|
#define inb(port) ({ \
|
|
|
|
|
u8 _v; \
|
|
|
|
|
asm volatile ("inb %%dx,%%al" : "=a" (_v) : "d" (port)); \
|
|
|
|
|
_v; \
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
#define inw(port) ({ \
|
|
|
|
|
u16 _v; \
|
|
|
|
|
asm volatile ("inw %%dx,%%ax" : "=a" (_v) : "d"(port)); \
|
|
|
|
|
_v; \
|
2007-04-02 15:11:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
2007-04-02 15:30:47 +02:00
|
|
|
|
|
2007-04-02 15:11:17 +02:00
|
|
|
|
#define ind(port) ({ \
|
|
|
|
|
u32 _v; \
|
2007-04-02 15:30:47 +02:00
|
|
|
|
asm volatile ("inl %%dx,%%eax" : "=a" (_v) : "d"(port)); \
|
2007-04-02 15:11:17 +02:00
|
|
|
|
_v; \
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-02 15:30:47 +02:00
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
/* pas termin<69> */
|
|
|
|
|
|
2007-04-02 15:11:17 +02:00
|
|
|
|
#define rolb(input,rotate) ({ \
|
|
|
|
|
u32 _v; \
|
|
|
|
|
asm volatile ("roll %1,%0" : "=g" (_v) : "cI" (rotate), "0" (input)); \
|
|
|
|
|
_v; \
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-02 15:30:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|