Rev 877 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
877 | serge | 1 | |
2 | |||
3 | |||
4 | { |
||
5 | u32_t handle; |
||
6 | u32_t io_code; |
||
7 | void *input; |
||
8 | int inp_size; |
||
9 | void *output; |
||
10 | int out_size; |
||
11 | }ioctl_t; |
||
12 | |||
13 | |||
14 | |||
15 | |||
16 | #define ERR_PARAM -1 |
||
17 | |||
18 | |||
19 | |||
20 | |||
21 | |||
22 | |||
23 | |||
24 | #define IMPORT __attribute__ ((dllimport)) |
||
25 | |||
26 | |||
27 | |||
28 | |||
29 | #define PciApi __PciApi |
||
30 | //#define RegService __RegService |
||
31 | #define CreateObject __CreateObject |
||
32 | #define DestroyObject __DestroyObject |
||
33 | |||
34 | |||
35 | |||
36 | |||
37 | #define PG_NOCACHE 0x018 |
||
38 | |||
39 | |||
40 | void* STDCALL KernelAlloc(size_t size)__asm__("KernelAlloc"); |
||
41 | void* STDCALL KernelFree(void *mem)__asm__("KernelFree"); |
||
42 | void* STDCALL UserAlloc(size_t size)__asm__("UserAlloc"); |
||
43 | int STDCALL UserFree(void *mem)__asm__("UserFree"); |
||
44 | |||
45 | |||
46 | |||
47 | |||
48 | |||
49 | |||
50 | //void *DestroyObject(void *obj); |
||
51 | |||
52 | |||
53 | |||
54 | |||
55 | |||
56 | |||
57 | |||
58 | |||
59 | u16_t STDCALL PciRead16(u32_t bus, u32_t devfn, u32_t reg)__asm__("PciRead16"); |
||
60 | u32_t STDCALL PciRead32(u32_t bus, u32_t devfn, u32_t reg)__asm__("PciRead32"); |
||
61 | |||
62 | |||
63 | u32_t STDCALL PciWrite16(u32_t bus, u32_t devfn, u32_t reg,u16_t val)__asm__("PciWrite16"); |
||
64 | u32_t STDCALL PciWrite32(u32_t bus, u32_t devfn, u32_t reg,u32_t val)__asm__("PciWrite32"); |
||
65 | |||
66 | |||
67 | |||
68 | |||
69 | int dbgprintf(const char* format, ...); |
||
70 | |||
71 | |||
72 | |||
73 | |||
878 | serge | 74 | { |
75 | int retval; |
||
76 | |||
77 | |||
78 | :"=a"(retval) |
||
79 | :"a"(61), "b"(1)); |
||
80 | return retval; |
||
81 | } |
||
82 | |||
83 | |||
84 | { |
||
85 | int retval; |
||
86 | |||
87 | |||
88 | :"=a"(retval) |
||
89 | :"a"(61), "b"(2)); |
||
90 | return retval; |
||
91 | } |
||
92 | |||
93 | |||
94 | { |
||
95 | int retval; |
||
96 | |||
97 | |||
98 | :"=a"(retval) |
||
99 | :"a"(61), "b"(3)); |
||
100 | return retval; |
||
101 | } |
||
102 | |||
103 | |||
877 | serge | 104 | { |
105 | u32_t retval; |
||
106 | |||
107 | |||
108 | "call *__imp__GetPgAddr \n\t" |
||
109 | :"=eax" (retval) |
||
110 | :"a" (mem) ); |
||
111 | return retval; |
||
112 | }; |
||
113 | |||
114 | |||
115 | { |
||
116 | size = (size+4095) & ~4095; |
||
117 | __asm__ __volatile__ ( |
||
118 | "call *__imp__CommitPages" |
||
119 | ::"a" (page), "b"(mem),"c"(size>>12) |
||
120 | :"edx" ); |
||
121 | __asm__ __volatile__ ("":::"eax","ebx","ecx"); |
||
122 | }; |
||
123 | |||
124 | |||
125 | { |
||
126 | size = (size+4095) & ~4095; |
||
127 | __asm__ __volatile__ ( |
||
128 | "call *__imp__UnmapPages" |
||
129 | ::"a" (mem), "c"(size>>12) |
||
130 | :"edx"); |
||
131 | __asm__ __volatile__ ("":::"eax","ecx"); |
||
132 | }; |
||
133 | |||
134 | |||
135 | { |
||
136 | if( !delay ) |
||
137 | delay++; |
||
138 | delay*=2000; |
||
139 | |||
140 | |||
141 | "1:\n\t" |
||
142 | "xorl %%eax, %%eax \n\t" |
||
143 | "cpuid \n\t" |
||
144 | "decl %%edi \n\t" |
||
145 | "jnz 1b" |
||
146 | : |
||
147 | :"D"(delay) |
||
148 | :"eax","ebx","ecx","edx"); |
||
149 | }; |
||
150 | |||
151 | |||
152 | { |
||
153 | u32_t retval; |
||
154 | |||
155 | |||
156 | "call *__imp__PciApi" |
||
157 | :"=a" (retval) |
||
158 | :"a" (cmd) |
||
159 | :"memory"); |
||
160 | return retval; |
||
161 | }; |
||
162 | |||
163 | |||
164 | { |
||
165 | void *retval; |
||
166 | |||
167 | |||
168 | "call *__imp__CreateObject \n\t" |
||
169 | :"=a" (retval) |
||
170 | :"a" (size),"b"(pid) |
||
171 | :"esi","edi", "memory"); |
||
172 | return retval; |
||
173 | } |
||
174 | |||
175 | |||
176 | { |
||
177 | __asm__ __volatile__ ( |
||
178 | "call *__imp__DestroyObject" |
||
179 | : |
||
180 | :"a" (obj) |
||
181 | :"ebx","edx","esi","edi", "memory"); |
||
182 | } |
||
183 | |||
184 | |||
185 | |||
186 | u32 __RegService(char *name, srv_proc_t proc) |
||
187 | { |
||
188 | u32 retval; |
||
189 | |||
190 | |||
191 | ( |
||
192 | "pushl %%eax \n\t" |
||
193 | "pushl %%ebx \n\t" |
||
194 | "call *__imp__RegService \n\t" |
||
195 | :"=eax" (retval) |
||
196 | :"a" (proc), "b" (name) |
||
197 | :"memory" |
||
198 | ); |
||
199 | return retval; |
||
200 | }; |
||
201 | */ |
||
202 | |||
203 | |||
204 | { |
||
205 | u32_t ifl; |
||
206 | __asm__ __volatile__ ( |
||
207 | "pushf\n\t" |
||
208 | "popl %0\n\t" |
||
209 | "cli\n" |
||
210 | : "=r" (ifl)); |
||
211 | return ifl; |
||
212 | } |
||
213 | |||
214 | |||
215 | { |
||
216 | __asm__ __volatile__ ( |
||
217 | "pushl %0\n\t" |
||
218 | "popf\n" |
||
219 | : : "r" (ifl) |
||
220 | ); |
||
221 | } |
||
222 | |||
223 | |||
224 | { |
||
225 | u32_t tmp; |
||
226 | __asm__ __volatile__ ( |
||
227 | // "xorl %%eax, %%eax \n\t" |
||
228 | "cld \n\t" |
||
229 | "rep stosb \n" |
||
230 | :"=c"(tmp),"=D"(tmp) |
||
231 | :"a"(0),"c"(len),"D"(dst)); |
||
232 | __asm__ __volatile__ ("":::"ecx","edi"); |
||
233 | }; |
||
234 |