1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
;
; Copyright (c) 2006-2008 Advanced Micro Devices,Inc. ("AMD").
;
; This library is free software; you can redistribute it and/or modify
; it under the terms of the GNU Lesser General Public License as
; published by the Free Software Foundation; either version 2.1 of the
; License, or (at your option) any later version.
;
; This code is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
; Lesser General Public License for more details.
;
; You should have received a copy of the GNU Lesser General
; Public License along with this library; if not, write to the
; Free Software Foundation, Inc., 59 Temple Place, Suite 330,
; Boston, MA 02111-1307 USA
;
;* Function: *
;* This file contains generic VSM library functions.
.model tiny,c
.586p
.CODE
;***********************************************************************
; UCHAR in_8(USHORT io_port)
;***********************************************************************
in_8 proc pascal io_port:word
mov dx, io_port
in al, dx
ret
in_8 endp
;***********************************************************************
; void out_8(USHORT io_port, UCHAR io_data)
;***********************************************************************
out_8 proc pascal \
io_port:WORD, \
io_data:BYTE
mov dx, io_port
mov al, io_data
out dx, al
ret
out_8 endp
;***********************************************************************
; USHORT in_16(USHORT io_port)
;***********************************************************************
in_16 proc pascal, io_port:WORD
mov dx, io_port
in ax, dx
ret
in_16 endp
;***********************************************************************
; void out_16(USHORT io_port, USHORT io_data)
;***********************************************************************
out_16 proc pascal \
io_port:WORD, \
io_data:WORD
mov dx, io_port
mov ax, io_data
out dx, ax
ret
out_16 endp
;***********************************************************************
; ULONG in_32(USHORT io_port)
;***********************************************************************
in_32 proc pascal io_port: WORD
mov dx, io_port
in eax, dx
mov edx, eax
shr edx, 16
ret
in_32 endp
;***********************************************************************
;
; void out_32(USHORT io_port, ULONG io_data)
;***********************************************************************
out_32 proc pascal \
io_port:WORD, \
io_data:DWORD
mov dx, io_port
mov eax, io_data
out dx, eax
ret
out_32 endp
write_flat proc pascal \
Address: DWORD,\
Data: DWORD
mov ebx, [Address]
mov eax, [Data]
mov fs:[ebx], eax
ret
write_flat endp
read_flat proc pascal \
Address: DWORD
mov ebx, [Address]
mov eax, fs:[ebx]
mov edx, eax
shr edx, 16
ret
read_flat endp
write_flat_word proc pascal \
Address: DWORD,\
Data: WORD
mov ebx, [Address]
mov ax, [Data]
mov fs:[ebx], ax
ret
write_flat_word endp
read_flat_word proc pascal \
Address: DWORD
mov ebx, [Address]
mov ax, fs:[ebx]
ret
read_flat_word endp
write_flat_byte proc pascal \
Address: DWORD,\
Data: BYTE
mov ebx, [Address]
mov al, [Data]
mov fs:[ebx], al
ret
write_flat_byte endp
read_flat_byte proc pascal \
Address: DWORD
mov ebx, [Address]
mov al, fs:[ebx]
ret
read_flat_byte endp
read_timestamp proc
RDTSC
mov edx, eax
shr edx, 16
ret
read_timestamp endp
END
|