Cleanup in elf.c with .bss section clean; adm command mounts cdrom instead of floppy...
[ZeXOS.git] / kernel / arch / x86_64 / include / io.h
blob5c1ff49ff42dc06db46468956ad48ed21ede9627
1 /*
2 * ZeX/OS
3 * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org)
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_64_H
21 #define _X86_64_H
23 #include <system.h>
24 #include <build.h>
26 #ifdef ARCH_x86_64
28 #define outb(value,port) \
29 __asm__ ("outb %%al,%%dx"::"a" (value),"d" (port))
31 #define outw(value,port) \
32 __asm__ ("outw %%ax,%%dx"::"a" (value),"d" (port))
34 #define outl(value,port) \
35 __asm__ ("outl %%eax,%%dx"::"a" (value),"d" (port))
37 #define inb(port) ({ \
38 unsigned char _v; \
39 __asm__ volatile ("inb %%dx,%%al":"=a" (_v):"d" (port)); \
40 _v; \
43 #define inw(port) ({ \
44 unsigned short _v; \
45 __asm__ volatile ("inw %%dx,%%ax":"=a" (_v):"d" (port)); \
46 _v; \
49 #define inl(port) ({ \
50 unsigned int _v; \
51 __asm__ volatile ("inl %%dx,%%eax":"=a" (_v):"d" (port)); \
52 _v; \
55 #define outb_p(value,port) \
56 __asm__ ("outb %%al,%%dx\n" \
57 "\tjmp 1f\n" \
58 "1:\tjmp 1f\n" \
59 "1:"::"a" (value),"d" (port))
61 #define inb_p(port) ({ \
62 unsigned char _v; \
63 __asm__ volatile ("inb %%dx,%%al\n" \
64 "\tjmp 1f\n" \
65 "1:\tjmp 1f\n" \
66 "1:":"=a" (_v):"d" (port)); \
67 _v; \
70 #define outw_p(value,port) \
71 __asm__ ("outw %%ax,%%dx\n" \
72 "\tjmp 1f\n" \
73 "1:\tjmp 1f\n" \
74 "1:"::"a" (value),"dN" (port))
77 struct regs {
78 unsigned long gs;
79 unsigned long fs;
80 unsigned long es;
81 unsigned long ds;
82 unsigned long r15;
83 unsigned long r14;
84 unsigned long r13;
85 unsigned long r12;
86 unsigned long r11;
87 unsigned long r10;
88 unsigned long r9;
89 unsigned long r8;
90 unsigned long rdi;
91 unsigned long rsi;
92 unsigned long rbp;
93 unsigned long rsp;
94 unsigned long rbx;
95 unsigned long rdx;
96 unsigned long rcx;
97 unsigned long rax;
98 unsigned long int_no;
99 unsigned long err_code;
100 unsigned long rip;
101 unsigned long cs;
102 unsigned long eflags;
103 unsigned long useresp;
104 unsigned long ss;
107 #define _set_gate(gate_addr, type, dpl, addr) \
108 __asm__ ("movw %%dx,%%ax\n\t" \
109 "movw %0,%%dx\n\t" \
110 "movl %%eax,%1\n\t" \
111 "movl %%edx,%2" \
113 : "i" ((short) (0x8000+(dpl<<13)+(type<<8))), \
114 "o" (*((char *) (gate_addr))), \
115 "o" (*(4+(char *) (gate_addr))), \
116 "d" ((char *) (addr)),"a" (0x00080000))
118 #endif
120 #endif