System call sys_getchar () was improved; stdin is correspond with 0. fd and stdout...
[ZeXOS.git] / libc / include / x86.h
blobaaf8c5a38110688721de933508db0ce1c0ce176b
1 /*
2 * ZeX/OS
3 * Copyright (C) 2007 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com)
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef __X86_H
21 #define __X86_H
24 #define M_PIC 0x20 /* I/O for master PIC */
25 #define M_IMR 0x21 /* I/O for master IMR */
26 #define S_PIC 0xA0 /* I/O for slave PIC */
27 #define S_IMR 0xA1 /* I/O for slace IMR */
29 #define EOI 0x20 /* EOI command */
31 #define ICW1 0x11 /* Cascade, Edge triggered */
32 /* ICW2 is vector */
33 /* ICW3 is slave bitmap or number */
34 #define ICW4 0x01 /* 8088 mode */
36 #define M_VEC 0x68 /* Vector for master */
37 #define S_VEC 0x70 /* Vector for slave */
39 #define OCW3_IRR 0x0A /* Read IRR */
40 #define OCW3_ISR 0x0B /* Read ISR */
42 #define outb(value,port) \
43 __asm__ ("outb %%al,%%dx"::"a" (value),"d" (port))
46 #define inb(port) ({ \
47 unsigned char _v; \
48 __asm__ volatile ("inb %%dx,%%al":"=a" (_v):"d" (port)); \
49 _v; \
52 #define outb_p(value,port) \
53 __asm__ ("outb %%al,%%dx\n" \
54 "\tjmp 1f\n" \
55 "1:\tjmp 1f\n" \
56 "1:"::"a" (value),"d" (port))
58 #define inb_p(port) ({ \
59 unsigned char _v; \
60 __asm__ volatile ("inb %%dx,%%al\n" \
61 "\tjmp 1f\n" \
62 "1:\tjmp 1f\n" \
63 "1:":"=a" (_v):"d" (port)); \
64 _v; \
67 extern unsigned inportb (unsigned short port);
68 extern unsigned short inw (unsigned short port);
69 extern void outw_p (unsigned short v, unsigned short port);
70 extern void outportb (unsigned port, unsigned val);
73 extern unsigned disable (void);
74 extern void enable (void);
76 extern void enable_irq (unsigned short irq_num);
77 extern void disable_irq (unsigned short irq_num);
79 #endif