nckernel  0.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
port.c
Go to the documentation of this file.
1 #include <sys/io.h>
2 #include <errno.h>
3 
4 void outdw(unsigned short port, unsigned long dword)
5 {
6  asm __volatile__ (
7  "out %%eax, %%dx"
8  : /* Output */
9  : "d"(port), "a"(dword) /* Input */
10  /* : Clobber list */
11  );
12 }
13 
14 void outw(unsigned short port, unsigned short word)
15 {
16  asm __volatile__ (
17  "out %%ax, %%dx"
18  : /* Output */
19  : "d"(port), "a"(word) /* Input */
20  /* : Clobber list */
21  );
22 }
23 
24 void outb(unsigned short port, unsigned char byte)
25 {
26  asm __volatile__ (
27  "out %%al, %%dx"
28  : /* Output */
29  : "d"(port), "a"(byte) /* Input */
30  /* : Clobber list */
31  );
32 }
33 
34 unsigned long indw(unsigned short port)
35 {
36  unsigned long dword;
37  asm __volatile__ (
38  "in %%dx, %%eax"
39  : "=a"(dword) /* Output */
40  : "d"(port) /* Input */
41  /* : Clobber list */
42  );
43 
44  return dword;
45 }
46 
47 unsigned short inw(unsigned short port)
48 {
49  unsigned short word;
50  asm __volatile__ (
51  "in %%dx, %%ax"
52  : "=a"(word) /* Output */
53  : "d"(port) /* Input */
54  /* : Clobber list */
55  );
56 
57  return word;
58 }
59 
60 unsigned char inb(unsigned short port)
61 {
62  unsigned char byte;
63  asm __volatile__ (
64  "in %%dx, %%al"
65  : "=a"(byte) /* Output */
66  : "d"(port) /* Input */
67  /* : Clobber list */
68  );
69 
70  return byte;
71 }
72 
73 int ioperm(unsigned long from, unsigned long num, int turn_on)
74 {
75  return -EFAULT;
76 }
77 
78 int iopl(int level)
79 {
80  return -EFAULT;
81 }
82 
83 /* End of a file */