Rev 5068 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5068 | Rev 5081 | ||
---|---|---|---|
1 | #ifndef __KOS_32_SYS_H__ |
1 | #ifndef __KOS_32_SYS_H__ |
2 | #define __KOS_32_SYS_H__ |
2 | #define __KOS_32_SYS_H__ |
3 | 3 | ||
4 | #include |
4 | #include |
5 | #include |
5 | #include |
6 | #include |
6 | #include |
7 | 7 | ||
8 | //#ifdef CONFIG_DEBUF |
8 | //#ifdef CONFIG_DEBUF |
9 | // #define DBG(format,...) printf(format,##__VA_ARGS__) |
9 | // #define DBG(format,...) printf(format,##__VA_ARGS__) |
10 | //#else |
10 | //#else |
11 | // #define DBG(format,...) |
11 | // #define DBG(format,...) |
12 | //#endif |
12 | //#endif |
13 | 13 | ||
14 | #define TYPE_3_BORDER_WIDTH 5 |
14 | #define TYPE_3_BORDER_WIDTH 5 |
15 | 15 | ||
16 | typedef unsigned int color_t; |
16 | typedef unsigned int color_t; |
17 | 17 | ||
18 | typedef union __attribute__((packed)) |
18 | typedef union __attribute__((packed)) |
19 | { |
19 | { |
20 | uint32_t val; |
20 | uint32_t val; |
21 | struct |
21 | struct |
22 | { |
22 | { |
23 | short x; |
23 | short x; |
24 | short y; |
24 | short y; |
25 | }; |
25 | }; |
26 | }pos_t; |
26 | }pos_t; |
27 | 27 | ||
28 | typedef union __attribute__((packed)) |
28 | typedef union __attribute__((packed)) |
29 | { |
29 | { |
30 | uint32_t val; |
30 | uint32_t val; |
31 | struct |
31 | struct |
32 | { |
32 | { |
33 | uint8_t state; |
33 | uint8_t state; |
34 | uint8_t code; |
34 | uint8_t code; |
35 | uint16_t ctrl_key; |
35 | uint16_t ctrl_key; |
36 | }; |
36 | }; |
37 | }oskey_t; |
37 | }oskey_t; |
38 | 38 | ||
39 | typedef struct |
39 | typedef struct |
40 | { |
40 | { |
41 | unsigned handle; |
41 | unsigned handle; |
42 | unsigned io_code; |
42 | unsigned io_code; |
43 | void *input; |
43 | void *input; |
44 | int inp_size; |
44 | int inp_size; |
45 | void *output; |
45 | void *output; |
46 | int out_size; |
46 | int out_size; |
47 | }ioctl_t; |
47 | }ioctl_t; |
48 | 48 | ||
49 | 49 | ||
50 | static inline |
50 | static inline |
51 | void DefineButton(uint32_t x_w, uint32_t y_h, uint32_t id, uint32_t color) |
51 | void DefineButton(uint32_t x_w, uint32_t y_h, uint32_t id, uint32_t color) |
52 | { |
52 | { |
53 | __asm__ __volatile__( |
53 | __asm__ __volatile__( |
54 | "int $0x40" |
54 | "int $0x40" |
55 | ::"a"(8), |
55 | ::"a"(8), |
56 | "b"(x_w), |
56 | "b"(x_w), |
57 | "c"(y_h), |
57 | "c"(y_h), |
58 | "d"(id), |
58 | "d"(id), |
59 | "S"(color)); |
59 | "S"(color)); |
60 | 60 | ||
61 | 61 | ||
62 | }; |
62 | }; |
63 | 63 | ||
64 | static inline |
64 | static inline |
65 | uint32_t get_skin_height(void) |
65 | uint32_t get_skin_height(void) |
66 | { |
66 | { |
67 | uint32_t height; |
67 | uint32_t height; |
68 | 68 | ||
69 | __asm__ __volatile__( |
69 | __asm__ __volatile__( |
70 | "int $0x40 \n\t" |
70 | "int $0x40 \n\t" |
71 | :"=a"(height) |
71 | :"=a"(height) |
72 | :"a"(48),"b"(4)); |
72 | :"a"(48),"b"(4)); |
73 | return height; |
73 | return height; |
74 | }; |
74 | }; |
75 | static inline uint32_t GetSkinHeight(void) __attribute__ ((alias ("get_skin_height"))); |
75 | static inline uint32_t GetSkinHeight(void) __attribute__ ((alias ("get_skin_height"))); |
76 | 76 | ||
77 | static inline |
77 | static inline |
78 | void BeginDraw(void) |
78 | void BeginDraw(void) |
79 | { |
79 | { |
80 | __asm__ __volatile__( |
80 | __asm__ __volatile__( |
81 | "int $0x40" ::"a"(12),"b"(1)); |
81 | "int $0x40" ::"a"(12),"b"(1)); |
82 | }; |
82 | }; |
83 | 83 | ||
84 | static inline |
84 | static inline |
85 | void EndDraw(void) |
85 | void EndDraw(void) |
86 | { |
86 | { |
87 | __asm__ __volatile__( |
87 | __asm__ __volatile__( |
88 | "int $0x40" ::"a"(12),"b"(2)); |
88 | "int $0x40" ::"a"(12),"b"(2)); |
89 | }; |
89 | }; |
90 | 90 | ||
91 | static inline void DrawWindow(int x, int y, int w, int h, const char *name, |
91 | static inline void DrawWindow(int x, int y, int w, int h, const char *name, |
92 | color_t workcolor, uint32_t style) |
92 | color_t workcolor, uint32_t style) |
93 | { |
93 | { |
94 | 94 | ||
95 | __asm__ __volatile__( |
95 | __asm__ __volatile__( |
96 | "int $0x40" |
96 | "int $0x40" |
97 | ::"a"(0), |
97 | ::"a"(0), |
98 | "b"((x << 16) | ((w-1) & 0xFFFF)), |
98 | "b"((x << 16) | ((w-1) & 0xFFFF)), |
99 | "c"((y << 16) | ((h-1) & 0xFFFF)), |
99 | "c"((y << 16) | ((h-1) & 0xFFFF)), |
100 | "d"((style << 24) | (workcolor & 0xFFFFFF)), |
100 | "d"((style << 24) | (workcolor & 0xFFFFFF)), |
101 | "D"(name), |
101 | "D"(name), |
102 | "S"(0)); |
102 | "S"(0)); |
103 | }; |
103 | }; |
104 | 104 | ||
105 | #define POS_SCREEN 0 |
105 | #define POS_SCREEN 0 |
106 | #define POS_WINDOW 1 |
106 | #define POS_WINDOW 1 |
107 | 107 | ||
108 | static inline |
108 | static inline |
109 | pos_t get_mouse_pos(int origin) |
109 | pos_t get_mouse_pos(int origin) |
110 | { |
110 | { |
111 | pos_t val; |
111 | pos_t val; |
112 | 112 | ||
113 | __asm__ __volatile__( |
113 | __asm__ __volatile__( |
114 | "int $0x40 \n\t" |
114 | "int $0x40 \n\t" |
115 | "rol $16, %%eax" |
115 | "rol $16, %%eax" |
116 | :"=a"(val) |
116 | :"=a"(val) |
117 | :"a"(37),"b"(origin)); |
117 | :"a"(37),"b"(origin)); |
118 | return val; |
118 | return val; |
119 | } |
119 | } |
120 | static inline pos_t GetMousePos(int origin) __attribute__ ((alias ("get_mouse_pos"))); |
120 | static inline pos_t GetMousePos(int origin) __attribute__ ((alias ("get_mouse_pos"))); |
121 | 121 | ||
122 | static inline |
122 | static inline |
123 | uint32_t get_mouse_buttons(void) |
123 | uint32_t get_mouse_buttons(void) |
124 | { |
124 | { |
125 | uint32_t val; |
125 | uint32_t val; |
126 | 126 | ||
127 | __asm__ __volatile__( |
127 | __asm__ __volatile__( |
128 | "int $0x40" |
128 | "int $0x40" |
129 | :"=a"(val) |
129 | :"=a"(val) |
130 | :"a"(37),"b"(2)); |
130 | :"a"(37),"b"(2)); |
131 | return val; |
131 | return val; |
132 | }; |
132 | }; |
133 | static inline uint32_t GetMouseButtons(void) __attribute__ ((alias ("get_mouse_buttons"))); |
133 | static inline uint32_t GetMouseButtons(void) __attribute__ ((alias ("get_mouse_buttons"))); |
134 | 134 | ||
135 | static inline |
135 | static inline |
136 | uint32_t get_mouse_wheels(void) |
136 | uint32_t get_mouse_wheels(void) |
137 | { |
137 | { |
138 | uint32_t val; |
138 | uint32_t val; |
139 | 139 | ||
140 | __asm__ __volatile__( |
140 | __asm__ __volatile__( |
141 | "int $0x40 \n\t" |
141 | "int $0x40 \n\t" |
142 | :"=a"(val) |
142 | :"=a"(val) |
143 | :"a"(37),"b"(7)); |
143 | :"a"(37),"b"(7)); |
144 | return val; |
144 | return val; |
145 | }; |
145 | }; |
146 | static inline uint32_t GetMouseWheels(void) __attribute__ ((alias ("get_mouse_wheels"))); |
146 | static inline uint32_t GetMouseWheels(void) __attribute__ ((alias ("get_mouse_wheels"))); |
147 | 147 | ||
148 | static inline |
148 | static inline |
149 | uint32_t wait_for_event(uint32_t time) |
149 | uint32_t wait_for_event(uint32_t time) |
150 | { |
150 | { |
151 | uint32_t val; |
151 | uint32_t val; |
152 | __asm__ __volatile__( |
152 | __asm__ __volatile__( |
153 | "int $0x40" |
153 | "int $0x40" |
154 | :"=a"(val) |
154 | :"=a"(val) |
155 | :"a"(23), "b"(time)); |
155 | :"a"(23), "b"(time)); |
156 | return val; |
156 | return val; |
157 | }; |
157 | }; |
158 | 158 | ||
159 | static inline uint32_t check_os_event() |
159 | static inline uint32_t check_os_event() |
160 | { |
160 | { |
161 | uint32_t val; |
161 | uint32_t val; |
162 | __asm__ __volatile__( |
162 | __asm__ __volatile__( |
163 | "int $0x40" |
163 | "int $0x40" |
164 | :"=a"(val) |
164 | :"=a"(val) |
165 | :"a"(11)); |
165 | :"a"(11)); |
166 | return val; |
166 | return val; |
167 | }; |
167 | }; |
168 | 168 | ||
169 | static inline uint32_t get_os_event() |
169 | static inline uint32_t get_os_event() |
170 | { |
170 | { |
171 | uint32_t val; |
171 | uint32_t val; |
172 | __asm__ __volatile__( |
172 | __asm__ __volatile__( |
173 | "int $0x40" |
173 | "int $0x40" |
174 | :"=a"(val) |
174 | :"=a"(val) |
175 | :"a"(10)); |
175 | :"a"(10)); |
176 | return val; |
176 | return val; |
177 | }; |
177 | }; |
178 | static inline uint32_t GetOsEvent(void) __attribute__ ((alias ("get_os_event"))); |
178 | static inline uint32_t GetOsEvent(void) __attribute__ ((alias ("get_os_event"))); |
179 | 179 | ||
180 | static inline |
180 | static inline |
181 | uint32_t get_tick_count(void) |
181 | uint32_t get_tick_count(void) |
182 | { |
182 | { |
183 | uint32_t val; |
183 | uint32_t val; |
184 | __asm__ __volatile__( |
184 | __asm__ __volatile__( |
185 | "int $0x40" |
185 | "int $0x40" |
186 | :"=a"(val) |
186 | :"=a"(val) |
187 | :"a"(26),"b"(9)); |
187 | :"a"(26),"b"(9)); |
188 | return val; |
188 | return val; |
189 | }; |
189 | }; |
190 | 190 | ||
191 | static inline |
191 | static inline |
192 | oskey_t get_key(void) |
192 | oskey_t get_key(void) |
193 | { |
193 | { |
194 | oskey_t val; |
194 | oskey_t val; |
195 | __asm__ __volatile__( |
195 | __asm__ __volatile__( |
196 | "int $0x40" |
196 | "int $0x40" |
197 | :"=a"(val) |
197 | :"=a"(val) |
198 | :"a"(2)); |
198 | :"a"(2)); |
199 | return val; |
199 | return val; |
200 | } |
200 | } |
201 | 201 | ||
202 | static inline |
202 | static inline |
203 | uint32_t get_os_button() |
203 | uint32_t get_os_button() |
204 | { |
204 | { |
205 | uint32_t val; |
205 | uint32_t val; |
206 | __asm__ __volatile__( |
206 | __asm__ __volatile__( |
207 | "int $0x40" |
207 | "int $0x40" |
208 | :"=a"(val) |
208 | :"=a"(val) |
209 | :"a"(17)); |
209 | :"a"(17)); |
210 | return val>>8; |
210 | return val>>8; |
211 | }; |
211 | }; |
212 | 212 | ||
213 | static inline uint32_t get_service(char *name) |
213 | static inline uint32_t get_service(char *name) |
214 | { |
214 | { |
215 | uint32_t retval = 0; |
215 | uint32_t retval = 0; |
- | 216 | __asm__ __volatile__( |
|
216 | asm volatile ("int $0x40" |
217 | "int $0x40" |
217 | :"=a"(retval) |
218 | :"=a"(retval) |
218 | :"a"(68),"b"(16),"c"(name) |
219 | :"a"(68),"b"(16),"c"(name) |
219 | :"memory"); |
220 | :"memory"); |
220 | 221 | ||
221 | return retval; |
222 | return retval; |
222 | }; |
223 | }; |
223 | 224 | ||
224 | static inline int call_service(ioctl_t *io) |
225 | static inline int call_service(ioctl_t *io) |
225 | { |
226 | { |
226 | int retval; |
227 | int retval; |
- | 228 | ||
227 | 229 | __asm__ __volatile__( |
|
228 | asm volatile("int $0x40" |
230 | "int $0x40" |
229 | :"=a"(retval) |
231 | :"=a"(retval) |
230 | :"a"(68),"b"(17),"c"(io) |
232 | :"a"(68),"b"(17),"c"(io) |
231 | :"memory","cc"); |
233 | :"memory","cc"); |
232 | 234 | ||
233 | return retval; |
235 | return retval; |
234 | }; |
236 | }; |
235 | 237 | ||
236 | 238 | ||
237 | static inline |
239 | static inline |
238 | void draw_line(int xs, int ys, int xe, int ye, color_t color) |
240 | void draw_line(int xs, int ys, int xe, int ye, color_t color) |
239 | { |
241 | { |
240 | __asm__ __volatile__( |
242 | __asm__ __volatile__( |
241 | "int $0x40" |
243 | "int $0x40" |
242 | ::"a"(38), "d"(color), |
244 | ::"a"(38), "d"(color), |
243 | "b"((xs << 16) | xe), |
245 | "b"((xs << 16) | xe), |
244 | "c"((ys << 16) | ye)); |
246 | "c"((ys << 16) | ye)); |
245 | } |
247 | } |
246 | 248 | ||
247 | 249 | ||
248 | 250 | ||
249 | static inline |
251 | static inline |
250 | void draw_bar(int x, int y, int w, int h, color_t color) |
252 | void draw_bar(int x, int y, int w, int h, color_t color) |
251 | { |
253 | { |
252 | __asm__ __volatile__( |
254 | __asm__ __volatile__( |
253 | "int $0x40" |
255 | "int $0x40" |
254 | ::"a"(13), "d"(color), |
256 | ::"a"(13), "d"(color), |
255 | "b"((x << 16) | w), |
257 | "b"((x << 16) | w), |
256 | "c"((y << 16) | h)); |
258 | "c"((y << 16) | h)); |
257 | } |
259 | } |
258 | 260 | ||
259 | static inline |
261 | static inline |
260 | void draw_bitmap(void *bitmap, int x, int y, int w, int h) |
262 | void draw_bitmap(void *bitmap, int x, int y, int w, int h) |
261 | { |
263 | { |
262 | __asm__ __volatile__( |
264 | __asm__ __volatile__( |
263 | "int $0x40" |
265 | "int $0x40" |
264 | ::"a"(7), "b"(bitmap), |
266 | ::"a"(7), "b"(bitmap), |
265 | "c"((w << 16) | h), |
267 | "c"((w << 16) | h), |
266 | "d"((x << 16) | y)); |
268 | "d"((x << 16) | y)); |
267 | } |
269 | } |
268 | 270 | ||
269 | static inline |
271 | static inline |
270 | void draw_text_sys(const char *text, int x, int y, int len, color_t color) |
272 | void draw_text_sys(const char *text, int x, int y, int len, color_t color) |
271 | { |
273 | { |
272 | __asm__ __volatile__( |
274 | __asm__ __volatile__( |
273 | "int $0x40" |
275 | "int $0x40" |
274 | ::"a"(4),"d"(text), |
276 | ::"a"(4),"d"(text), |
275 | "b"((x << 16) | y), |
277 | "b"((x << 16) | y), |
276 | "S"(len),"c"(color)); |
278 | "S"(len),"c"(color)); |
277 | } |
279 | } |
278 | 280 | ||
279 | static inline void yield(void) |
281 | static inline void yield(void) |
280 | { |
282 | { |
281 | __asm__ __volatile__( |
283 | __asm__ __volatile__( |
282 | "int $0x40" |
284 | "int $0x40" |
283 | ::"a"(68), "b"(1)); |
285 | ::"a"(68), "b"(1)); |
284 | }; |
286 | }; |
285 | 287 | ||
286 | static inline void delay(uint32_t time) |
288 | static inline void delay(uint32_t time) |
287 | { |
289 | { |
288 | __asm__ __volatile__( |
290 | __asm__ __volatile__( |
289 | "int $0x40" |
291 | "int $0x40" |
290 | ::"a"(5), "b"(time) |
292 | ::"a"(5), "b"(time) |
291 | :"memory"); |
293 | :"memory"); |
292 | }; |
294 | }; |
293 | 295 | ||
294 | static inline |
296 | static inline |
295 | void *user_alloc(size_t size) |
297 | void *user_alloc(size_t size) |
296 | { |
298 | { |
297 | void *val; |
299 | void *val; |
298 | __asm__ __volatile__( |
300 | __asm__ __volatile__( |
299 | "int $0x40" |
301 | "int $0x40" |
300 | :"=a"(val) |
302 | :"=a"(val) |
301 | :"a"(68),"b"(12),"c"(size)); |
303 | :"a"(68),"b"(12),"c"(size)); |
302 | return val; |
304 | return val; |
303 | } |
305 | } |
304 | static inline void *UserAlloc(size_t size) __attribute__ ((alias ("user_alloc"))); |
306 | static inline void *UserAlloc(size_t size) __attribute__ ((alias ("user_alloc"))); |
305 | 307 | ||
306 | static inline |
308 | static inline |
307 | int user_free(void *mem) |
309 | int user_free(void *mem) |
308 | { |
310 | { |
309 | int val; |
311 | int val; |
310 | __asm__ __volatile__( |
312 | __asm__ __volatile__( |
311 | "int $0x40" |
313 | "int $0x40" |
312 | :"=a"(val) |
314 | :"=a"(val) |
313 | :"a"(68),"b"(13),"c"(mem)); |
315 | :"a"(68),"b"(13),"c"(mem)); |
314 | return val; |
316 | return val; |
315 | } |
317 | } |
316 | static inline int UserFree(void *mem) __attribute__ ((alias ("user_free"))); |
318 | static inline int UserFree(void *mem) __attribute__ ((alias ("user_free"))); |
317 | 319 | ||
318 | static inline |
320 | static inline |
319 | int *user_unmap(void *base, size_t offset, size_t size) |
321 | int *user_unmap(void *base, size_t offset, size_t size) |
320 | { |
322 | { |
321 | int *val; |
323 | int *val; |
322 | __asm__ __volatile__( |
324 | __asm__ __volatile__( |
323 | "int $0x40" |
325 | "int $0x40" |
324 | :"=a"(val) |
326 | :"=a"(val) |
325 | :"a"(68),"b"(26),"c"(base),"d"(offset),"S"(size)); |
327 | :"a"(68),"b"(26),"c"(base),"d"(offset),"S"(size)); |
326 | return val; |
328 | return val; |
327 | }; |
329 | }; |
328 | static inline int *UserUnmap(void *base, size_t offset, size_t size) __attribute__ ((alias ("user_unmap"))); |
330 | static inline int *UserUnmap(void *base, size_t offset, size_t size) __attribute__ ((alias ("user_unmap"))); |
329 | 331 | ||
330 | typedef union |
332 | typedef union |
331 | { |
333 | { |
332 | struct |
334 | struct |
333 | { |
335 | { |
334 | void *data; |
336 | void *data; |
335 | size_t size; |
337 | size_t size; |
336 | }; |
338 | }; |
337 | unsigned long long raw; |
339 | unsigned long long raw; |
338 | }ufile_t; |
340 | }ufile_t; |
339 | 341 | ||
340 | 342 | ||
341 | static inline ufile_t load_file(const char *path) |
343 | static inline ufile_t load_file(const char *path) |
342 | { |
344 | { |
343 | ufile_t uf; |
345 | ufile_t uf; |
344 | 346 | ||
345 | __asm__ __volatile__ ( |
347 | __asm__ __volatile__ ( |
346 | "int $0x40" |
348 | "int $0x40" |
347 | :"=A"(uf.raw) |
349 | :"=A"(uf.raw) |
348 | :"a" (68), "b"(27),"c"(path)); |
350 | :"a" (68), "b"(27),"c"(path)); |
349 | 351 | ||
350 | return uf; |
352 | return uf; |
351 | }; |
353 | }; |
352 | static inline ufile_t LoadFile(const char *path) __attribute__ ((alias ("load_file"))); |
354 | static inline ufile_t LoadFile(const char *path) __attribute__ ((alias ("load_file"))); |
353 | 355 | ||
354 | static inline int GetScreenSize() |
356 | static inline int GetScreenSize() |
355 | { |
357 | { |
356 | int retval; |
358 | int retval; |
357 | 359 | ||
358 | __asm__ __volatile__( |
360 | __asm__ __volatile__( |
359 | "int $0x40" |
361 | "int $0x40" |
360 | :"=a"(retval) |
362 | :"=a"(retval) |
361 | :"a"(61), "b"(1)); |
363 | :"a"(61), "b"(1)); |
362 | return retval; |
364 | return retval; |
363 | } |
365 | } |
364 | 366 | ||
365 | static inline |
367 | static inline |
366 | uint32_t load_cursor(void *path, uint32_t flags) |
368 | uint32_t load_cursor(void *path, uint32_t flags) |
367 | { |
369 | { |
368 | uint32_t val; |
370 | uint32_t val; |
369 | __asm__ __volatile__( |
371 | __asm__ __volatile__( |
370 | "int $0x40" |
372 | "int $0x40" |
371 | :"=a"(val) |
373 | :"=a"(val) |
372 | :"a"(37), "b"(4), "c"(path), "d"(flags)); |
374 | :"a"(37), "b"(4), "c"(path), "d"(flags)); |
373 | return val; |
375 | return val; |
374 | } |
376 | } |
375 | static inline |
377 | static inline |
376 | uint32_t LoadCursor(void *path, uint32_t flags) __attribute__ ((alias ("load_cursor"))); |
378 | uint32_t LoadCursor(void *path, uint32_t flags) __attribute__ ((alias ("load_cursor"))); |
377 | 379 | ||
378 | static inline |
380 | static inline |
379 | uint32_t set_cursor(uint32_t cursor) |
381 | uint32_t set_cursor(uint32_t cursor) |
380 | { |
382 | { |
381 | uint32_t old; |
383 | uint32_t old; |
382 | __asm__ __volatile__( |
384 | __asm__ __volatile__( |
383 | "int $0x40" |
385 | "int $0x40" |
384 | :"=a"(old) |
386 | :"=a"(old) |
385 | :"a"(37), "b"(5), "c"(cursor)); |
387 | :"a"(37), "b"(5), "c"(cursor)); |
386 | return old; |
388 | return old; |
387 | }; |
389 | }; |
388 | static inline uint32_t SetCursor(uint32_t cursor) __attribute__ ((alias ("set_cursor"))); |
390 | static inline uint32_t SetCursor(uint32_t cursor) __attribute__ ((alias ("set_cursor"))); |
389 | 391 | ||
390 | static inline |
392 | static inline |
391 | int destroy_cursor(uint32_t cursor) |
393 | int destroy_cursor(uint32_t cursor) |
392 | { |
394 | { |
393 | int ret; |
395 | int ret; |
394 | __asm__ __volatile__( |
396 | __asm__ __volatile__( |
395 | "int $0x40" |
397 | "int $0x40" |
396 | :"=a"(ret) |
398 | :"=a"(ret) |
397 | :"a"(37), "b"(6), "c"(cursor) |
399 | :"a"(37), "b"(6), "c"(cursor) |
398 | :"memory"); |
400 | :"memory"); |
399 | return ret; |
401 | return ret; |
400 | }; |
402 | }; |
401 | static inline int DestroyCursor(uint32_t cursor) __attribute__ ((alias ("destroy_cursor"))); |
403 | static inline int DestroyCursor(uint32_t cursor) __attribute__ ((alias ("destroy_cursor"))); |
402 | 404 | ||
403 | static inline void get_proc_info(char *info) |
405 | static inline void get_proc_info(char *info) |
404 | { |
406 | { |
405 | __asm__ __volatile__( |
407 | __asm__ __volatile__( |
406 | "int $0x40" |
408 | "int $0x40" |
407 | : |
409 | : |
408 | :"a"(9), "b"(info), "c"(-1)); |
410 | :"a"(9), "b"(info), "c"(-1)); |
409 | }; |
411 | }; |
410 | static inline void GetProcInfo(char *info) __attribute__ ((alias ("get_proc_info"))); |
412 | static inline void GetProcInfo(char *info) __attribute__ ((alias ("get_proc_info"))); |
411 | 413 | ||
412 | static inline |
414 | static inline |
413 | void* user_realloc(void *mem, size_t size) |
415 | void* user_realloc(void *mem, size_t size) |
414 | { |
416 | { |
415 | void *val; |
417 | void *val; |
416 | __asm__ __volatile__( |
418 | __asm__ __volatile__( |
417 | "int $0x40" |
419 | "int $0x40" |
418 | :"=a"(val) |
420 | :"=a"(val) |
419 | :"a"(68),"b"(20),"c"(size),"d"(mem) |
421 | :"a"(68),"b"(20),"c"(size),"d"(mem) |
420 | :"memory"); |
422 | :"memory"); |
421 | 423 | ||
422 | return val; |
424 | return val; |
423 | }; |
425 | }; |
424 | static inline void* UserRrealloc(void *mem, size_t size) __attribute__ ((alias ("user_realloc"))); |
426 | static inline void* UserRrealloc(void *mem, size_t size) __attribute__ ((alias ("user_realloc"))); |
425 | 427 | ||
426 | void *get_resource(void *data, uint32_t id); |
428 | void *get_resource(void *data, uint32_t id); |
427 | 429 | ||
428 | struct blit_call |
430 | struct blit_call |
429 | { |
431 | { |
430 | int dstx; |
432 | int dstx; |
431 | int dsty; |
433 | int dsty; |
432 | int w; |
434 | int w; |
433 | int h; |
435 | int h; |
434 | 436 | ||
435 | int srcx; |
437 | int srcx; |
436 | int srcy; |
438 | int srcy; |
437 | int srcw; |
439 | int srcw; |
438 | int srch; |
440 | int srch; |
439 | 441 | ||
440 | unsigned char *bitmap; |
442 | unsigned char *bitmap; |
441 | int stride; |
443 | int stride; |
442 | }; |
444 | }; |
443 | 445 | ||
444 | static inline void Blit(void *bitmap, int dst_x, int dst_y, |
446 | static inline void Blit(void *bitmap, int dst_x, int dst_y, |
445 | int src_x, int src_y, int w, int h, |
447 | int src_x, int src_y, int w, int h, |
446 | int src_w, int src_h, int stride) |
448 | int src_w, int src_h, int stride) |
447 | { |
449 | { |
448 | volatile struct blit_call bc; |
450 | volatile struct blit_call bc; |
449 | 451 | ||
450 | bc.dstx = dst_x; |
452 | bc.dstx = dst_x; |
451 | bc.dsty = dst_y; |
453 | bc.dsty = dst_y; |
452 | bc.w = w; |
454 | bc.w = w; |
453 | bc.h = h; |
455 | bc.h = h; |
454 | bc.srcx = src_x; |
456 | bc.srcx = src_x; |
455 | bc.srcy = src_y; |
457 | bc.srcy = src_y; |
456 | bc.srcw = src_w; |
458 | bc.srcw = src_w; |
457 | bc.srch = src_h; |
459 | bc.srch = src_h; |
458 | bc.stride = stride; |
460 | bc.stride = stride; |
459 | bc.bitmap = bitmap; |
461 | bc.bitmap = bitmap; |
460 | 462 | ||
461 | __asm__ __volatile__( |
463 | __asm__ __volatile__( |
462 | "int $0x40" |
464 | "int $0x40" |
463 | ::"a"(73),"b"(0),"c"(&bc.dstx)); |
465 | ::"a"(73),"b"(0),"c"(&bc.dstx)); |
464 | - | ||
465 | }; |
466 | }; |
466 | 467 | ||
467 | #endif><>><>><>><>><>><>><>><>><>><> |
468 | #endif><>><>><>><>><>><>><>><>><>><> |