CS350 COS
COS
Loading...
Searching...
No Matches
ioport.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2006-2018 Ali Mashtizadeh
3 * All rights reserved.
4 */
5
6#include <stdint.h>
7
8static __inline__ unsigned char inb(unsigned short port)
9{
10 unsigned char retval;
11 __asm__ __volatile__ ("inb %w1, %0\n\t"
12 : "=a" (retval)
13 : "d" (port));
14 return retval;
15}
16
17static __inline__ unsigned short inw(unsigned short port)
18{
19 unsigned short retval;
20 __asm__ __volatile__ ("inw %w1, %0\n\t"
21 : "=a" (retval)
22 : "d" (port));
23 return retval;
24}
25
26static __inline__ unsigned int inl(int port)
27{
28 unsigned int retval;
29 __asm__ __volatile__ ("inl %w1, %0\n\t"
30 : "=a" (retval)
31 : "d" (port));
32 return retval;
33}
34
35static __inline__ void outb(int port, unsigned char val)
36{
37 __asm__ __volatile__ ("outb %0, %w1\n\t"
38 :
39 : "a" (val),
40 "d" (port));
41}
42
43static __inline__ void outw(int port, unsigned short val)
44{
45 __asm__ __volatile__ ("outw %0, %w1\n\t"
46 :
47 : "a" (val),
48 "d" (port));
49}
50
51static __inline__ void outl(int port, unsigned int val)
52{
53 __asm__ __volatile__ ("outl %0, %w1\n\t"
54 :
55 : "a" (val),
56 "d" (port));
57}
58
59static __inline__ void insb(int port,void *buf,int cnt)
60{
61 __asm__ __volatile__ ("cld\n\trepne\n\tinsb\n\t"
62 : "=D" (buf), "=c" (cnt)
63 : "d" (port), "0" (buf), "1" (cnt) : "memory", "cc");
64}
65
66static __inline__ void insw(int port,void *buf,int cnt)
67{
68 __asm__ __volatile__ ("cld\n\trepne\n\tinsw\n\t"
69 : "=D" (buf), "=c" (cnt)
70 : "d" (port), "0" (buf), "1" (cnt) : "memory", "cc");
71}
72
73static __inline__ void insl(int port,void *buf,int cnt)
74{
75 __asm__ __volatile__ ("cld\n\trepne\n\tinsl\n\t"
76 : "=D" (buf), "=c" (cnt)
77 : "d" (port), "0" (buf), "1" (cnt) : "memory", "cc");
78}
79
80static __inline__ void outsb(int port,const void *buf,int cnt)
81{
82 __asm__ __volatile__ ("cld\n\trepne\n\toutsb\n\t"
83 : "=S" (buf), "=c" (cnt)
84 : "d" (port), "0" (buf), "1" (cnt) : "cc");
85}
86
87static __inline__ void outsw(int port,const void *buf,int cnt)
88{
89 __asm__ __volatile__ ("cld\n\trepne\n\toutsw\n\t"
90 : "=S" (buf), "=c" (cnt)
91 : "d" (port), "0" (buf), "1" (cnt) : "cc");
92}
93
94static __inline__ void outsl(int port,const void *buf,int cnt)
95{
96 __asm__ __volatile__ ("cld\n\trepne\n\toutsl\n\t"
97 : "=S" (buf), "=c" (cnt)
98 : "d" (port), "0" (buf), "1" (cnt) : "cc");
99}
static char buf[4096]
Definition: ethdump.c:10
static __inline__ void outsw(int port, const void *buf, int cnt)
Definition: ioport.h:87
static __inline__ void outw(int port, unsigned short val)
Definition: ioport.h:43
static __inline__ unsigned int inl(int port)
Definition: ioport.h:26
static __inline__ void outb(int port, unsigned char val)
Definition: ioport.h:35
static __inline__ void outsl(int port, const void *buf, int cnt)
Definition: ioport.h:94
static __inline__ void insb(int port, void *buf, int cnt)
Definition: ioport.h:59
static __inline__ void outl(int port, unsigned int val)
Definition: ioport.h:51
static __inline__ unsigned char inb(unsigned short port)
Definition: ioport.h:8
static __inline__ unsigned short inw(unsigned short port)
Definition: ioport.h:17
static __inline__ void insl(int port, void *buf, int cnt)
Definition: ioport.h:73
static __inline__ void outsb(int port, const void *buf, int cnt)
Definition: ioport.h:80
static __inline__ void insw(int port, void *buf, int cnt)
Definition: ioport.h:66