95 lines
1.7 KiB
C
95 lines
1.7 KiB
C
//Functions.c
|
|
//05/07/03 Josh Holtrop
|
|
//for HOS
|
|
|
|
|
|
inline void outportb(unsigned int port, unsigned char value) // Output a byte to a port
|
|
{
|
|
asm volatile ("outb %%al,%%dx"::"d" (port), "a" (value));
|
|
};
|
|
|
|
inline void outportw(unsigned int port, unsigned int value) // Output a word to a port
|
|
{
|
|
asm volatile ("outw %%ax,%%dx"::"d" (port), "a" (value));
|
|
};
|
|
|
|
inline byte inportb(unsigned short port)
|
|
{
|
|
unsigned char ret_val;
|
|
|
|
asm volatile("inb %w1,%b0"
|
|
: "=a"(ret_val)
|
|
: "d"(port));
|
|
return ret_val;
|
|
};
|
|
|
|
void enable_ints()
|
|
{
|
|
asm("sti");
|
|
};
|
|
|
|
void disable_ints()
|
|
{
|
|
asm("cli");
|
|
};
|
|
|
|
void remap_pics(int pic1, int pic2)
|
|
{
|
|
byte a1, a2;
|
|
|
|
a1 = inportb(PIC1_DATA); //0x21
|
|
a2 = inportb(PIC2_DATA); //0xA1
|
|
|
|
outportb(PIC1_COMMAND, ICW1_INIT+ICW1_ICW4); //0x20, 0x10+0x01 00010001b
|
|
outportb(PIC2_COMMAND, ICW1_INIT+ICW1_ICW4); //0xA0, 0x10+0x01 00010001b
|
|
outportb(PIC1_DATA, pic1); //0x21, pic1
|
|
outportb(PIC2_DATA, pic2); //0xA1, pic2
|
|
outportb(PIC1_DATA, 4); //0x21, 0x04 00000100b
|
|
outportb(PIC2_DATA, 2); //0xA1, 0x02 00000010b
|
|
outportb(PIC1_DATA, ICW4_8086); //0x21, 0x01 00000001b
|
|
outportb(PIC2_DATA, ICW4_8086); //0xA1, 0x01 00000001b
|
|
|
|
outportb(PIC1_DATA, a1); //0x21
|
|
outportb(PIC2_DATA, a2); //0xA1
|
|
}
|
|
|
|
inline void pic1_mask(byte mask)
|
|
{
|
|
outportb(PIC1_DATA, mask); //0x21, maskfield *OCW1*
|
|
}
|
|
|
|
inline void pic2_mask(byte mask)
|
|
{
|
|
outportb(PIC2_DATA, mask); //0xA1, maskfield *OCW1*
|
|
}
|
|
|
|
inline void restart()
|
|
{
|
|
outportb (0x64, 0xfe);
|
|
for (;;)
|
|
{
|
|
}
|
|
}
|
|
|
|
inline void eoi()
|
|
{
|
|
outportb(0x20, 0x20); //EOI
|
|
}
|
|
|
|
inline void eoi2()
|
|
{
|
|
outportb(0xA0, 0x20);
|
|
outportb(0x20, 0x20);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|