Rev 9764 | Rev 9767 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 9764 | Rev 9766 | ||
---|---|---|---|
Line 18... | Line 18... | ||
18 | 18 | ||
19 | #ifndef _KSYS_H_ |
19 | #ifndef _KSYS_H_ |
Line 20... | Line 20... | ||
20 | #define _KSYS_H_ |
20 | #define _KSYS_H_ |
- | 21 | ||
Line -... | Line 22... | ||
- | 22 | #include |
|
21 | 23 | #include |
|
Line 22... | Line 24... | ||
22 | #include |
24 | |
Line 23... | Line 25... | ||
23 | 25 | #define KOSAPI static inline |
|
Line 73... | Line 75... | ||
73 | typedef struct{ |
75 | typedef struct { |
74 | void *data; |
76 | void* data; |
75 | size_t size; |
77 | size_t size; |
76 | }ksys_ufile_t; |
78 | } ksys_ufile_t; |
Line 77... | Line -... | ||
77 | - | ||
78 | 79 | ||
79 | typedef struct{ |
80 | typedef struct { |
80 | uint32_t p00; |
81 | uint32_t p00; |
81 | union{ |
82 | union { |
82 | uint64_t p04; |
83 | uint64_t p04; |
Line 96... | Line 97... | ||
96 | char p20; |
97 | char p20; |
97 | const char *p21; |
98 | const char* p21; |
98 | }ksys70_t; |
99 | } ksys70_t; |
Line 99... | Line 100... | ||
99 | 100 | ||
- | 101 | typedef struct { |
|
- | 102 | uint32_t status; |
|
- | 103 | uint32_t rw_bytes; |
|
- | 104 | } ksys70_status_t; |
|
- | 105 | ||
100 | typedef struct { |
106 | typedef struct { |
101 | uint32_t attributes; |
107 | uint32_t attributes; |
102 | uint32_t name_cp; |
108 | uint32_t name_cp; |
103 | ksys_time_t creation_time; |
109 | ksys_time_t creation_time; |
104 | ksys_date_t creation_date; |
110 | ksys_date_t creation_date; |
105 | ksys_time_t last_access_time; |
111 | ksys_time_t last_access_time; |
106 | ksys_date_t last_access_date; |
112 | ksys_date_t last_access_date; |
107 | ksys_time_t last_modification_time; |
113 | ksys_time_t last_modification_time; |
108 | ksys_date_t last_modification_date; |
114 | ksys_date_t last_modification_date; |
109 | unsigned long long size; |
115 | uint64_t size; |
110 | char name[0]; |
116 | char name[0]; |
Line 111... | Line 117... | ||
111 | }ksys_bdfe_t; |
117 | } ksys_bdfe_t; |
112 | 118 | ||
113 | typedef struct { |
119 | typedef struct { |
114 | int cpu_usage; //+0 |
120 | int cpu_usage; //+0 |
115 | int window_pos_info; //+4 |
121 | int window_pos_info; //+4 |
116 | short int reserved1; //+8 |
122 | uint16_t reserved1; //+8 |
117 | char name[12]; //+10 |
123 | char name[12]; //+10 |
118 | int memstart; //+22 |
124 | int memstart; //+22 |
119 | int memused; //+26 |
125 | int memused; //+26 |
120 | int pid; //+30 |
126 | int pid; //+30 |
121 | int winx_start; //+34 |
127 | int winx_start; //+34 |
122 | int winy_start; //+38 |
128 | int winy_start; //+38 |
123 | int winx_size; //+42 |
129 | int winx_size; //+42 |
124 | int winy_size; //+46 |
130 | int winy_size; //+46 |
125 | short int slot_info; //+50 |
131 | uint16_t slot_info; //+50 |
126 | short int reserved2; //+52 |
132 | uint16_t reserved2; //+52 |
127 | int clientx; //+54 |
133 | int clientx; //+54 |
128 | int clienty; //+58 |
134 | int clienty; //+58 |
129 | int clientwidth; //+62 |
135 | int clientwidth; //+62 |
130 | int clientheight; //+66 |
136 | int clientheight; //+66 |
131 | unsigned char window_state;//+70 |
137 | uint8_t window_state; //+70 |
Line 132... | Line 138... | ||
132 | char reserved3[1024-71]; //+71 |
138 | uint8_t reserved3[1024 - 71]; //+71 |
Line 133... | Line 139... | ||
133 | }ksys_thread_t; |
139 | } ksys_thread_t; |
Line 216... | Line 222... | ||
216 | KSYS_FILE_CP866 =1, |
222 | KSYS_FILE_CP866 = 1, |
217 | KSYS_FILE_UTF16LE = 2, |
223 | KSYS_FILE_UTF16LE = 2, |
218 | KSYS_FILE_UTF8 = 3 |
224 | KSYS_FILE_UTF8 = 3 |
219 | }; |
225 | }; |
Line 220... | Line -... | ||
220 | - | ||
221 | static inline |
226 | |
222 | int __strcmp(const char * s1, const char * s2 ) |
227 | KOSAPI int __strcmp(const char* s1, const char* s2) |
223 | { |
228 | { |
- | 229 | while ((*s1) && (*s1 == *s2)) { |
|
- | 230 | ++s1; |
|
- | 231 | ++s2; |
|
224 | while ((*s1) && (*s1 == *s2)){ ++s1; ++s2; } |
232 | } |
225 | return(*(unsigned char*)s1 - *(unsigned char *)s2); |
233 | return (*(unsigned char*)s1 - *(unsigned char*)s2); |
Line 226... | Line 234... | ||
226 | } |
234 | } |
227 | 235 | ||
228 | /* ####################################################################### */ |
236 | /* ####################################################################### */ |
Line 229... | Line -... | ||
229 | /* ############### С wrappers for system calls Kolibri OS ################ */ |
- | |
230 | /* ####################################################################### */ |
237 | /* ############### С wrappers for system calls Kolibri OS ################ */ |
Line 231... | Line -... | ||
231 | - | ||
232 | 238 | /* ####################################################################### */ |
|
- | 239 | ||
233 | /*=============== Function -1 - terminate thread/process ===============*/ |
240 | /*=============== Function -1 - terminate thread/process ===============*/ |
234 | 241 | ||
Line 235... | Line 242... | ||
235 | static inline |
242 | KOSAPI void _ksys_exit(void) |
Line 236... | Line -... | ||
236 | void _ksys_exit(){ |
- | |
237 | asm_inline("int $0x40"::"a"(-1)); |
243 | { |
- | 244 | asm_inline("int $0x40" ::"a"(-1)); |
|
238 | } |
245 | } |
239 | 246 | ||
240 | /*============== Function 0 - define and draw the window. ==============*/ |
- | |
241 | 247 | /*============== Function 0 - define and draw the window. ==============*/ |
|
242 | static inline |
248 | |
243 | void _ksys_create_window(uint32_t x, uint32_t y, uint32_t w, uint32_t h, const char *name, ksys_color_t workcolor, uint32_t style) { |
249 | KOSAPI void _ksys_create_window(uint32_t x, uint32_t y, uint32_t w, uint32_t h, const char* name, ksys_color_t workcolor, uint32_t style) |
244 | asm_inline( |
250 | { |
245 | "int $0x40" |
251 | asm_inline( |
246 | ::"a"(0), |
252 | "int $0x40" ::"a"(0), |
247 | "b"((x << 16) | ((w-1) & 0xFFFF)), |
- | |
248 | "c"((y << 16) | ((h-1) & 0xFFFF)), |
253 | "b"((x << 16) | ((w - 1) & 0xFFFF)), |
Line 249... | Line 254... | ||
249 | "d"((style << 24) | (workcolor & 0xFFFFFF)), |
254 | "c"((y << 16) | ((h - 1) & 0xFFFF)), |
Line 250... | Line -... | ||
250 | "D"(name), |
- | |
251 | "S"(0) |
255 | "d"((style << 24) | (workcolor & 0xFFFFFF)), |
- | 256 | "D"(name), |
|
252 | :"memory" |
257 | "S"(0) |
253 | ); |
- | |
254 | }; |
258 | : "memory"); |
255 | - | ||
256 | /*================ Function 1 - put pixel in the window. ===============*/ |
259 | }; |
Line 257... | Line 260... | ||
257 | 260 | ||
Line 258... | Line -... | ||
258 | static inline |
- | |
259 | void _ksys_draw_pixel(uint32_t x, uint32_t y, ksys_color_t color){ |
261 | /*================ Function 1 - put pixel in the window. ===============*/ |
- | 262 | ||
260 | asm_inline( |
263 | KOSAPI void _ksys_draw_pixel(uint32_t x, uint32_t y, ksys_color_t color) |
261 | "int $0x40" |
264 | { |
262 | ::"a"(1), "b"(x), "c"(y), "d"(color) |
265 | asm_inline( |
263 | ); |
266 | "int $0x40" ::"a"(1), "b"(x), "c"(y), "d"(color)); |
264 | } |
267 | } |
265 | - | ||
266 | /*============ Function 2 - get the code of the pressed key. ===========*/ |
268 | |
267 | 269 | /*============ Function 2 - get the code of the pressed key. ===========*/ |
|
Line 268... | Line 270... | ||
268 | static inline |
270 | |
Line 269... | Line -... | ||
269 | ksys_oskey_t _ksys_get_key(void){ |
- | |
270 | ksys_oskey_t val; |
271 | KOSAPI ksys_oskey_t _ksys_get_key(void) |
- | 272 | { |
|
271 | asm_inline( |
273 | ksys_oskey_t val; |
272 | "int $0x40" |
274 | asm_inline( |
273 | :"=a"(val) |
275 | "int $0x40" |
274 | :"a"(2) |
276 | : "=a"(val) |
275 | ); |
277 | : "a"(2)); |
276 | return val; |
278 | return val; |
277 | } |
- | |
278 | 279 | } |
|
279 | /*==================== Function 3 - get system time. ===================*/ |
280 | |
Line 280... | Line 281... | ||
280 | 281 | /*==================== Function 3 - get system time. ===================*/ |
|
281 | static inline |
- | |
282 | ksys_time_t _ksys_get_time(){ |
- | |
283 | ksys_time_t c_time; |
282 | |
- | 283 | KOSAPI ksys_time_t _ksys_get_time(void) |
|
284 | asm_inline( |
284 | { |
285 | "int $0x40" |
- | |
286 | :"=a"(c_time) |
285 | ksys_time_t c_time; |
287 | :"a"(3) |
286 | asm_inline( |
288 | :"memory" |
287 | "int $0x40" |
289 | ); |
288 | : "=a"(c_time) |
290 | return c_time; |
- | |
291 | } |
289 | : "a"(3) |
Line 292... | Line 290... | ||
292 | 290 | : "memory"); |
|
Line 293... | Line -... | ||
293 | /*=================== Function 4 - draw text string. ===================*/ |
- | |
294 | 291 | return c_time; |
|
- | 292 | } |
|
295 | static inline |
293 | |
296 | void _ksys_draw_text(const char *text, uint32_t x, uint32_t y, uint32_t len, ksys_color_t color) { |
- | |
297 | asm_inline( |
294 | /*=================== Function 4 - draw text string. ===================*/ |
298 | "int $0x40" |
295 | KOSAPI void _ksys_draw_text(const char* text, uint32_t x, uint32_t y, uint32_t len, ksys_color_t color) |
299 | ::"a"(4),"d"(text), |
- | |
300 | "b"((x << 16) | y), |
296 | { |
Line 301... | Line 297... | ||
301 | "S"(len),"c"(color) |
297 | asm_inline( |
Line 302... | Line -... | ||
302 | :"memory" |
- | |
303 | ); |
298 | "int $0x40" ::"a"(4), "d"(text), |
304 | } |
299 | "b"((x << 16) | y), |
305 | 300 | "S"(len), "c"(color) |
|
306 | /*========================= Function 5 - delay. ========================*/ |
- | |
307 | 301 | : "memory"); |
|
308 | static inline |
302 | } |
309 | void _ksys_delay(uint32_t time){ |
303 | |
310 | asm_inline( |
304 | /*========================= Function 5 - delay. ========================*/ |
311 | "int $0x40" |
- | |
312 | ::"a"(5), "b"(time) |
305 | |
Line 313... | Line 306... | ||
313 | :"memory" |
306 | KOSAPI void _ksys_delay(uint32_t time) |
Line 314... | Line -... | ||
314 | ); |
- | |
315 | } |
307 | { |
- | 308 | asm_inline( |
|
316 | 309 | "int $0x40" ::"a"(5), "b"(time) |
|
317 | /*=============== Function 7 - draw image in the window. ===============*/ |
310 | : "memory"); |
318 | - | ||
319 | static inline |
311 | } |
320 | void _ksys_draw_bitmap(void *bitmap, int x, int y, int w, int h) |
312 | |
321 | { |
313 | /*=============== Function 7 - draw image in the window. ===============*/ |
322 | asm_inline( |
314 | |
323 | "int $0x40" |
- | |
324 | ::"a"(7), "b"(bitmap), |
315 | KOSAPI void _ksys_draw_bitmap(void* bitmap, int x, int y, int w, int h) |
Line 325... | Line -... | ||
325 | "c"((w << 16) | h), |
- | |
326 | "d"((x << 16) | y) |
316 | { |
- | 317 | asm_inline( |
|
327 | :"memory" |
318 | "int $0x40" ::"a"(7), "b"(bitmap), |
328 | ); |
- | |
329 | } |
319 | "c"((w << 16) | h), |
330 | - | ||
331 | /*=============== Function 8 - define/delete the button. ===============*/ |
320 | "d"((x << 16) | y) |
Line 332... | Line 321... | ||
332 | 321 | : "memory"); |
|
Line 333... | Line -... | ||
333 | static inline |
- | |
334 | void _ksys_define_button(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t id, ksys_color_t color) { |
322 | } |
- | 323 | ||
335 | asm_inline( |
324 | /*=============== Function 8 - define/delete the button. ===============*/ |
336 | "int $0x40" |
325 | |
337 | ::"a"(8), |
326 | KOSAPI void _ksys_define_button(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t id, ksys_color_t color) |
338 | "b"((x<<16)+w), |
327 | { |
339 | "c"((y<<16)+h), |
328 | asm_inline( |
340 | "d"(id), |
329 | "int $0x40" ::"a"(8), |
341 | "S"(color) |
- | |
342 | ); |
330 | "b"((x << 16) + w), |
343 | }; |
331 | "c"((y << 16) + h), |
Line 344... | Line 332... | ||
344 | 332 | "d"(id), |
|
Line 345... | Line -... | ||
345 | static inline |
- | |
346 | void _ksys_delete_button(uint32_t id){ |
333 | "S"(color)); |
- | 334 | }; |
|
347 | asm_inline( |
335 | |
348 | "int $0x40" |
336 | KOSAPI void _ksys_delete_button(uint32_t id) |
349 | ::"a"(8),"d"(id & 0x00FFFFFF | 0x80000000) |
337 | { |
350 | ); |
338 | asm_inline( |
351 | } |
339 | "int $0x40" ::"a"(8), "d"(id & 0x00FFFFFF | 0x80000000)); |
352 | - | ||
353 | /*============ Function 9 - information on execution thread. ===========*/ |
340 | } |
354 | 341 | ||
Line 355... | Line 342... | ||
355 | static inline |
342 | /*============ Function 9 - information on execution thread. ===========*/ |
Line 356... | Line -... | ||
356 | int _ksys_thread_info(ksys_thread_t* table, int slot){ |
- | |
357 | int val; |
343 | |
- | 344 | KOSAPI int _ksys_thread_info(ksys_thread_t* table, int slot) |
|
358 | asm_inline( |
345 | { |
359 | "int $0x40" |
346 | int val; |
360 | :"=a"(val) |
347 | asm_inline( |
361 | :"a"(9), "b"(table), "c"(slot) |
348 | "int $0x40" |
362 | :"memory" |
349 | : "=a"(val) |
363 | ); |
- | |
364 | return val; |
350 | : "a"(9), "b"(table), "c"(slot) |
365 | } |
351 | : "memory"); |
Line 366... | Line 352... | ||
366 | 352 | return val; |
|
Line 367... | Line -... | ||
367 | /*==================== Function 10 - wait for event. ===================*/ |
- | |
368 | 353 | } |
|
- | 354 | ||
369 | static inline |
355 | /*==================== Function 10 - wait for event. ===================*/ |
370 | uint32_t _ksys_wait_event(void){ |
356 | |
Line 371... | Line -... | ||
371 | uint32_t val; |
- | |
372 | asm_inline( |
357 | KOSAPI uint32_t _ksys_wait_event(void) |
- | 358 | { |
|
373 | "int $0x40" |
359 | uint32_t val; |
374 | :"=a"(val) |
360 | asm_inline( |
Line 375... | Line 361... | ||
375 | :"a"(10) |
361 | "int $0x40" |
Line 376... | Line -... | ||
376 | ); |
- | |
377 | return val; |
362 | : "=a"(val) |
- | 363 | : "a"(10)); |
|
378 | } |
364 | return val; |
379 | - | ||
380 | /*=============== Function 11 - check for event, no wait. ==============*/ |
365 | } |
381 | 366 | ||
382 | static inline |
367 | /*=============== Function 11 - check for event, no wait. ==============*/ |
383 | uint32_t _ksys_check_event(void){ |
- | |
384 | uint32_t val; |
368 | |
Line 385... | Line 369... | ||
385 | asm_inline( |
369 | KOSAPI uint32_t _ksys_check_event(void) |
Line 386... | Line -... | ||
386 | "int $0x40" |
- | |
387 | :"=a"(val) |
370 | { |
- | 371 | uint32_t val; |
|
388 | :"a"(11) |
372 | asm_inline( |
389 | ); |
373 | "int $0x40" |
390 | return val; |
374 | : "=a"(val) |
391 | } |
375 | : "a"(11)); |
392 | 376 | return val; |
|
393 | /*=============== Function 12 - begin/end window redraw. ===============*/ |
377 | } |
394 | - | ||
395 | static inline |
378 | |
396 | void _ksys_start_draw(){ |
379 | /*=============== Function 12 - begin/end window redraw. ===============*/ |
397 | asm_inline("int $0x40"::"a"(12),"b"(1)); |
380 | |
398 | } |
381 | KOSAPI void _ksys_start_draw(void) |
Line 399... | Line 382... | ||
399 | 382 | { |
|
Line 400... | Line -... | ||
400 | static inline |
- | |
401 | void _ksys_end_draw(){ |
383 | asm_inline("int $0x40" ::"a"(12), "b"(1)); |
- | 384 | } |
|
402 | asm_inline("int $0x40" ::"a"(12),"b"(2)); |
385 | |
403 | } |
- | |
404 | 386 | KOSAPI void _ksys_end_draw(void) |
|
405 | /*============ Function 13 - draw a rectangle in the window. ===========*/ |
- | |
406 | 387 | { |
|
Line 407... | Line 388... | ||
407 | static inline |
388 | asm_inline("int $0x40" ::"a"(12), "b"(2)); |
Line 408... | Line -... | ||
408 | void _ksys_draw_bar(uint32_t x, uint32_t y, uint32_t w, uint32_t h, ksys_color_t color){ |
- | |
409 | asm_inline( |
389 | } |
- | 390 | ||
410 | "int $0x40" |
391 | /*============ Function 13 - draw a rectangle in the window. ===========*/ |
411 | ::"a"(13), "d"(color), |
- | |
412 | "b"((x << 16) | w), |
392 | |
413 | "c"((y << 16) | h) |
- | |
414 | ); |
393 | KOSAPI void _ksys_draw_bar(uint32_t x, uint32_t y, uint32_t w, uint32_t h, ksys_color_t color) |
Line 415... | Line 394... | ||
415 | } |
394 | { |
Line 416... | Line -... | ||
416 | - | ||
417 | /*=================== Function 14 - get screen size. ===================*/ |
395 | asm_inline( |
- | 396 | "int $0x40" ::"a"(13), "d"(color), |
|
418 | 397 | "b"((x << 16) | w), |
|
419 | static inline |
- | |
420 | ksys_pos_t _ksys_screen_size(){ |
398 | "c"((y << 16) | h)); |
421 | ksys_pos_t size; |
- | |
422 | ksys_pos_t size_tmp; |
399 | } |
Line 423... | Line 400... | ||
423 | asm_inline( |
400 | |
Line 424... | Line 401... | ||
424 | "int $0x40" |
401 | /*=================== Function 14 - get screen size. ===================*/ |
425 | :"=a"(size_tmp) |
402 | |
426 | :"a"(14) |
403 | KOSAPI ksys_pos_t _ksys_screen_size(void) |
427 | ); |
404 | { |
Line 428... | Line -... | ||
428 | size.x = size_tmp.y; |
- | |
429 | size.y = size_tmp.x; |
405 | ksys_pos_t size; |
- | 406 | ksys_pos_t size_tmp; |
|
430 | return size; |
407 | asm_inline( |
431 | } |
- | |
432 | 408 | "int $0x40" |
|
433 | /*== Function 15, subfunction 1 - set a size of the background image. ==*/ |
- | |
434 | 409 | : "=a"(size_tmp) |
|
Line 435... | Line 410... | ||
435 | static inline |
410 | : "a"(14)); |
436 | void _ksys_bg_set_size(uint32_t w, uint32_t h){ |
411 | size.x = size_tmp.y; |
Line 437... | Line -... | ||
437 | asm_inline( |
- | |
438 | "int $0x40" |
412 | size.y = size_tmp.x; |
- | 413 | return size; |
|
439 | ::"a"(15), "b"(1), "c"(w), "d"(h) |
414 | } |
440 | ); |
- | |
441 | } |
415 | |
442 | - | ||
443 | /*=== Function 15, subfunction 2 - put pixel on the background image. ==*/ |
416 | /*== Function 15, subfunction 1 - set a size of the background image. ==*/ |
Line 444... | Line 417... | ||
444 | 417 | ||
445 | static inline |
418 | KOSAPI void _ksys_bg_set_size(uint32_t w, uint32_t h) |
Line 446... | Line -... | ||
446 | void _ksys_bg_put_pixel(uint32_t x, uint32_t y, uint32_t w, ksys_color_t color){ |
- | |
447 | asm_inline( |
419 | { |
448 | "int $0x40" |
420 | asm_inline( |
449 | ::"a"(15), "b"(2), "c"((x+y*w)*3), "d"(color) |
421 | "int $0x40" ::"a"(15), "b"(1), "c"(w), "d"(h)); |
450 | ); |
422 | } |
451 | } |
423 | |
452 | 424 | /*=== Function 15, subfunction 2 - put pixel on the background image. ==*/ |
|
453 | /*=========== Function 15, subfunction 3 - redraw background. ==========*/ |
425 | |
454 | - | ||
455 | static inline |
426 | KOSAPI void _ksys_bg_put_pixel(uint32_t x, uint32_t y, uint32_t w, ksys_color_t color) |
456 | void _ksys_bg_redraw(void){ |
427 | { |
Line 457... | Line 428... | ||
457 | asm_inline( |
428 | asm_inline( |
Line 458... | Line -... | ||
458 | "int $0x40" |
- | |
459 | ::"a"(15), "b"(3) |
429 | "int $0x40" ::"a"(15), "b"(2), "c"((x + y * w) * 3), "d"(color)); |
460 | ); |
430 | } |
461 | } |
431 | |
462 | 432 | /*=========== Function 15, subfunction 3 - redraw background. ==========*/ |
|
463 | /*== Function 15, subfunction 4 - set drawing mode for the background. =*/ |
433 | |
464 | 434 | KOSAPI void _ksys_bg_redraw(void) |
|
465 | enum KSYS_BG_MODES{ |
435 | { |
466 | KSYS_BG_MODE_PAVE=1, |
- | |
467 | KSYS_BG_MODE_STRETCH=2 |
436 | asm_inline( |
468 | }; |
437 | "int $0x40" ::"a"(15), "b"(3)); |
Line 469... | Line 438... | ||
469 | 438 | } |
|
470 | static inline |
439 | |
Line 471... | Line -... | ||
471 | void _ksys_bg_set_mode(uint32_t mode){ |
- | |
472 | asm_inline( |
440 | /*== Function 15, subfunction 4 - set drawing mode for the background. =*/ |
473 | "int $0x40" |
441 | |
474 | ::"a"(15), "b"(4), "c"(mode) |
442 | enum KSYS_BG_MODES { |
475 | ); |
- | |
476 | } |
443 | KSYS_BG_MODE_PAVE = 1, |
477 | 444 | KSYS_BG_MODE_STRETCH = 2 |
|
478 | /*===================== Function 15, subfunction 5 =====================*/ |
445 | }; |
479 | /*============ Put block of pixels on the background image. ============*/ |
- | |
480 | 446 | ||
Line 481... | Line 447... | ||
481 | static inline |
447 | KOSAPI void _ksys_bg_set_mode(uint32_t mode) |
Line 482... | Line -... | ||
482 | void _ksys_bg_put_bitmap(ksys_bitmap_t* bitmap, size_t bitmap_size, uint32_t x, uint32_t y, uint32_t w){ |
- | |
483 | asm_inline( |
448 | { |
484 | "int $0x40" |
449 | asm_inline( |
485 | ::"a"(15), "b"(5), "c"(bitmap), "d"((x+y*w)*3), "S"(bitmap_size) |
450 | "int $0x40" ::"a"(15), "b"(4), "c"(mode)); |
486 | ); |
451 | } |
487 | } |
452 | |
488 | 453 | /*===================== Function 15, subfunction 5 =====================*/ |
|
489 | /*===================== Function 15, subfunction 6 =====================*/ |
454 | /*============ Put block of pixels on the background image. ============*/ |
490 | /*======= Map background data to the address space of process. ==========*/ |
- | |
491 | 455 | ||
492 | static inline |
456 | KOSAPI void _ksys_bg_put_bitmap(ksys_bitmap_t* bitmap, size_t bitmap_size, uint32_t x, uint32_t y, uint32_t w) |
Line 493... | Line 457... | ||
493 | ksys_bitmap_t* _ksys_bg_get_map() |
457 | { |
Line 494... | Line -... | ||
494 | { |
- | |
495 | ksys_bitmap_t *bitmap; |
458 | asm_inline( |
496 | asm_inline( |
459 | "int $0x40" ::"a"(15), "b"(5), "c"(bitmap), "d"((x + y * w) * 3), "S"(bitmap_size)); |
497 | "int $0x40" |
460 | } |
498 | :"=a"(bitmap) |
461 | |
499 | :"a"(15), "b"(6) |
462 | /*===================== Function 15, subfunction 6 =====================*/ |
500 | ); |
463 | /*======= Map background data to the address space of process. ==========*/ |
501 | return bitmap; |
464 | |
502 | } |
- | |
503 | 465 | KOSAPI ksys_bitmap_t* _ksys_bg_get_map(void) |
|
504 | /*===== Function 15, subfunction 7 - close mapped background data. =====*/ |
466 | { |
Line 505... | Line 467... | ||
505 | 467 | ksys_bitmap_t* bitmap; |
|
506 | static inline |
468 | asm_inline( |
Line 507... | Line -... | ||
507 | int _ksys_bg_close_map(ksys_bitmap_t* bitmap) |
- | |
508 | { |
469 | "int $0x40" |
509 | int status; // 1 - OK, 0 - ERROR |
470 | : "=a"(bitmap) |
510 | asm_inline( |
471 | : "a"(15), "b"(6)); |
511 | "int $0x40" |
- | |
512 | :"=a"(status) |
472 | return bitmap; |
513 | :"a"(15), "b"(7), "c"(bitmap) |
- | |
514 | ); |
473 | } |
Line 515... | Line 474... | ||
515 | return status; |
474 | |
Line 516... | Line -... | ||
516 | } |
- | |
517 | 475 | /*===== Function 15, subfunction 7 - close mapped background data. =====*/ |
|
518 | /*===================== Function 15, subfunction 9 =====================*/ |
476 | |
519 | /*============= Redraws a rectangular part of the background ===========*/ |
477 | KOSAPI int _ksys_bg_close_map(ksys_bitmap_t* bitmap) |
520 | - | ||
521 | static inline |
478 | { |
522 | void _ksys_bg_redraw_bar(ksys_pos_t angle1, ksys_pos_t angle2) |
- | |
523 | { |
479 | int status; // 1 - OK, 0 - ERROR |
Line 524... | Line 480... | ||
524 | asm_inline( |
480 | asm_inline( |
525 | "int $0x40" |
481 | "int $0x40" |
Line 526... | Line -... | ||
526 | ::"a"(15), "b"(9), |
- | |
527 | "c"(angle1.x*(1<<16)+angle2.x), |
482 | : "=a"(status) |
- | 483 | : "a"(15), "b"(7), "c"(bitmap)); |
|
528 | "d"(angle1.y*(1<<16)+angle2.y) |
484 | return status; |
529 | ); |
- | |
530 | } |
485 | } |
531 | - | ||
532 | /*=============== Function 16 - save ramdisk on a floppy. ==============*/ |
486 | |
Line 533... | Line 487... | ||
533 | 487 | /*===================== Function 15, subfunction 9 =====================*/ |
|
534 | static inline |
488 | /*============= Redraws a rectangular part of the background ===========*/ |
Line 535... | Line -... | ||
535 | int _ksys_save_ramdisk_fd(uint32_t floppy_id) |
- | |
536 | { |
489 | |
- | 490 | KOSAPI void _ksys_bg_redraw_bar(ksys_pos_t angle1, ksys_pos_t angle2) |
|
537 | int status; // 0 - OK, 1 - ERROR |
491 | { |
538 | asm_inline( |
492 | asm_inline( |
539 | "int $0x40" |
493 | "int $0x40" ::"a"(15), "b"(9), |
540 | :"=a"(status) |
494 | "c"(angle1.x * (1 << 16) + angle2.x), |
541 | :"a"(16), "b"(floppy_id) |
495 | "d"(angle1.y * (1 << 16) + angle2.y)); |
542 | ); |
- | |
543 | return status; |
496 | } |
544 | } |
497 | |
Line 545... | Line 498... | ||
545 | 498 | /*=============== Function 16 - save ramdisk on a floppy. ==============*/ |
|
546 | /*======= Function 17 - get the identifier of the pressed button. ======*/ |
499 | |
Line 547... | Line -... | ||
547 | - | ||
548 | static inline |
500 | KOSAPI int _ksys_save_ramdisk_fd(uint32_t floppy_id) |
- | 501 | { |
|
549 | uint32_t _ksys_get_button() |
502 | int status; // 0 - OK, 1 - ERROR |
550 | { |
503 | asm_inline( |
551 | unsigned val; |
504 | "int $0x40" |
552 | asm_inline( |
505 | : "=a"(status) |
553 | "int $0x40" |
506 | : "a"(16), "b"(floppy_id)); |
554 | :"=a"(val) |
- | |
555 | :"a"(17) |
507 | return status; |
556 | ); |
508 | } |
Line 557... | Line 509... | ||
557 | return val>>8; |
509 | |
Line 558... | Line -... | ||
558 | } |
- | |
559 | 510 | /*======= Function 17 - get the identifier of the pressed button. ======*/ |
|
- | 511 | ||
560 | /*===================== Function 18, subfunction 1 =====================*/ |
512 | KOSAPI uint32_t _ksys_get_button(void) |
561 | /*============= Make deactive the window of the given thread. ==========*/ |
513 | { |
562 | 514 | unsigned val; |
|
563 | static inline |
515 | asm_inline( |
564 | void _ksys_unfocus_window(int slot) |
516 | "int $0x40" |
565 | { |
- | |
566 | asm_inline( |
517 | : "=a"(val) |
567 | "int $0x40" |
518 | : "a"(17)); |
Line 568... | Line 519... | ||
568 | ::"a"(18), "b"(1), "c"(slot) |
519 | return val >> 8; |
Line 638... | Line 589... | ||
638 | KSYS_SHD_POWEROFF = 2, |
589 | KSYS_SHD_POWEROFF = 2, |
639 | KSYS_SHD_REBOOT = 3, |
590 | KSYS_SHD_REBOOT = 3, |
640 | KSYS_SHD_RESTART_KRN = 4 |
591 | KSYS_SHD_RESTART_KRN = 4 |
641 | }; |
592 | }; |
Line 642... | Line -... | ||
642 | - | ||
643 | static inline |
593 | |
- | 594 | KOSAPI void _ksys_shutdown(uint32_t shd_param) |
|
644 | void _ksys_shutdown(uint32_t shd_param){ |
595 | { |
645 | asm_inline( |
- | |
646 | "int $0x40" |
596 | asm_inline( |
647 | ::"a"(18), "b"(9), "c"(shd_param) |
- | |
648 | ); |
597 | "int $0x40" ::"a"(18), "b"(9), "c"(shd_param)); |
Line 649... | Line 598... | ||
649 | } |
598 | } |
Line 650... | Line -... | ||
650 | - | ||
651 | /*========= Function 18, subfunction 16 - get size of free RAM. ========*/ |
599 | |
- | 600 | /*========= Function 18, subfunction 16 - get size of free RAM. ========*/ |
|
652 | 601 | ||
653 | static inline |
602 | KOSAPI size_t _ksys_get_ram_size(void) |
654 | size_t _ksys_get_ram_size(void){ |
603 | { |
655 | size_t size; |
604 | size_t size; |
656 | asm_inline( |
605 | asm_inline( |
657 | "int $0x40" |
- | |
658 | :"=a"(size) |
606 | "int $0x40" |
659 | :"a"(18), "b"(16) |
607 | : "=a"(size) |
Line 660... | Line 608... | ||
660 | ); |
608 | : "a"(18), "b"(16)); |
Line 661... | Line -... | ||
661 | return size; |
- | |
662 | } |
609 | return size; |
- | 610 | } |
|
663 | 611 | ||
664 | /*======== Function 18, subfunction 17 - get full amount of RAM. =======*/ |
612 | /*======== Function 18, subfunction 17 - get full amount of RAM. =======*/ |
665 | 613 | ||
666 | static inline |
614 | KOSAPI size_t _ksys_get_full_ram(void) |
667 | size_t _ksys_get_full_ram(void){ |
615 | { |
668 | size_t size; |
- | |
669 | asm_inline( |
616 | size_t size; |
670 | "int $0x40" |
617 | asm_inline( |
Line 671... | Line 618... | ||
671 | :"=a"(size) |
618 | "int $0x40" |
672 | :"a"(18), "b"(17) |
619 | : "=a"(size) |
Line 673... | Line -... | ||
673 | ); |
- | |
674 | return size; |
620 | : "a"(18), "b"(17)); |
675 | } |
621 | return size; |
676 | 622 | } |
|
677 | /*===================== Function 18, subfunction 18 ====================*/ |
- | |
678 | /*============= Terminate process/thread by the identifier. ============*/ |
623 | |
679 | - | ||
680 | static inline |
624 | /*===================== Function 18, subfunction 18 ====================*/ |
Line 681... | Line 625... | ||
681 | void _ksys_kill_by_pid(uint32_t PID) |
625 | /*============= Terminate process/thread by the identifier. ============*/ |
682 | { |
626 | |
Line 683... | Line -... | ||
683 | asm_inline( |
- | |
684 | "int $0x40" |
627 | KOSAPI void _ksys_kill_by_pid(uint32_t PID) |
- | 628 | { |
|
685 | ::"a"(18), "b"(18), "c"(PID) |
629 | asm_inline( |
686 | ); |
630 | "int $0x40" ::"a"(18), "b"(18), "c"(PID)); |
687 | } |
631 | } |
688 | 632 | ||
689 | /*===================== Function 18, subfunction 21 ====================*/ |
633 | /*===================== Function 18, subfunction 21 ====================*/ |
690 | /*=====Get the slot number of the process / thread by identifier.. =====*/ |
- | |
691 | 634 | /*=====Get the slot number of the process / thread by identifier.. =====*/ |
|
692 | static inline |
635 | |
Line 693... | Line 636... | ||
693 | int _ksys_get_thread_slot(int PID){ |
636 | KOSAPI int _ksys_get_thread_slot(int PID) |
Line 694... | Line -... | ||
694 | int val; |
- | |
695 | asm_inline( |
637 | { |
- | 638 | int val; |
|
696 | "int $0x40" |
639 | asm_inline( |
697 | :"=a"(val) |
640 | "int $0x40" |
698 | :"a"(18), "b"(21), "c"(PID) |
641 | : "=a"(val) |
699 | ); |
642 | : "a"(18), "b"(21), "c"(PID)); |
700 | return val; |
643 | return val; |
701 | } |
- | |
702 | 644 | } |
|
703 | /*============= Function 23 - wait for event with timeout. =============*/ |
645 | |
Line 704... | Line 646... | ||
704 | 646 | /*============= Function 23 - wait for event with timeout. =============*/ |
|
Line 705... | Line -... | ||
705 | static inline |
- | |
706 | uint32_t _ksys_wait_event_timeout(uint32_t timeout){ |
647 | |
- | 648 | KOSAPI uint32_t _ksys_wait_event_timeout(uint32_t timeout) |
|
707 | unsigned val; |
649 | { |
708 | asm_inline( |
650 | unsigned val; |
709 | "int $0x40" |
651 | asm_inline( |
710 | :"=a"(val) |
652 | "int $0x40" |
711 | :"a"(23), "b"(timeout) |
653 | : "=a"(val) |
712 | ); |
- | |
713 | return val; |
654 | : "a"(23), "b"(timeout)); |
714 | } |
655 | return val; |
Line 715... | Line 656... | ||
715 | 656 | } |
|
716 | /*=== Function 26, subfunction 9 - get the value of the time counter. ==*/ |
657 | |
Line 717... | Line -... | ||
717 | - | ||
718 | static inline |
658 | /*=== Function 26, subfunction 9 - get the value of the time counter. ==*/ |
- | 659 | ||
719 | uint32_t _ksys_get_tick_count(){ |
660 | KOSAPI uint32_t _ksys_get_tick_count(void) |
720 | unsigned val; |
661 | { |
721 | asm_inline( |
662 | unsigned val; |
722 | "int $0x40" |
663 | asm_inline( |
723 | :"=a"(val) |
664 | "int $0x40" |
724 | :"a"(26),"b"(9) |
- | |
725 | ); |
665 | : "=a"(val) |
726 | return val; |
666 | : "a"(26), "b"(9)); |
Line 727... | Line 667... | ||
727 | } |
667 | return val; |
Line 728... | Line -... | ||
728 | - | ||
729 | /*===================== Function 26, subfunction 10 ====================*/ |
668 | } |
- | 669 | ||
730 | /*========== Get the value of the high precision time counter. =========*/ |
670 | /*===================== Function 26, subfunction 10 ====================*/ |
731 | 671 | /*========== Get the value of the high precision time counter. =========*/ |
|
- | 672 | ||
- | 673 | KOSAPI uint64_t _ksys_get_ns_count(void) |
|
732 | static inline |
674 | { |
733 | uint64_t _ksys_get_ns_count(){ |
675 | uint64_t val; |
Line 734... | Line 676... | ||
734 | uint64_t val; |
676 | asm_inline( |
735 | asm_inline( |
677 | "int $0x40" |
Line 736... | Line -... | ||
736 | "int $0x40" |
- | |
737 | :"=A"(val) |
678 | : "=A"(val) |
- | 679 | : "a"(26), "b"(10)); |
|
738 | :"a"(26), "b"(10) |
680 | return val; |
739 | ); |
- | |
740 | return val; |
681 | } |
741 | } |
- | |
742 | 682 | ||
Line 743... | Line 683... | ||
743 | /*=================== Function 29 - get system date. ===================*/ |
683 | /*=================== Function 29 - get system date. ===================*/ |
Line 744... | Line -... | ||
744 | - | ||
745 | static inline |
684 | |
- | 685 | KOSAPI ksys_date_t _ksys_get_date(void) |
|
746 | ksys_date_t _ksys_get_date(){ |
686 | { |
747 | ksys_date_t val; |
687 | ksys_date_t val; |
748 | asm_inline("int $0x40":"=a"(val):"a"(29)); |
688 | asm_inline("int $0x40" |
- | 689 | : "=a"(val) |
|
749 | return val; |
690 | : "a"(29)); |
750 | } |
- | |
751 | 691 | return val; |
|
752 | /*===========+ Function 30 - work with the current folder.==============*/ |
692 | } |
Line 753... | Line 693... | ||
753 | /*--------- Subfunction 1 - set current folder for the thread. ---------*/ |
693 | |
Line 754... | Line -... | ||
754 | - | ||
755 | static inline |
694 | /*===========+ Function 30 - work with the current folder.==============*/ |
- | 695 | /*--------- Subfunction 1 - set current folder for the thread. ---------*/ |
|
756 | void _ksys_setcwd(char* dir){ |
696 | |
757 | asm_inline( |
697 | KOSAPI void _ksys_setcwd(char* dir) |
758 | "int $0x40" |
698 | { |
759 | ::"a"(30), "b"(1), "c"(dir) |
699 | asm_inline( |
760 | ); |
700 | "int $0x40" ::"a"(30), "b"(1), "c"(dir)); |
761 | } |
701 | } |
762 | - | ||
763 | /*--------- Subfunction 2 - get current folder for the thread. ---------*/ |
702 | |
764 | 703 | /*--------- Subfunction 2 - get current folder for the thread. ---------*/ |
|
Line 765... | Line 704... | ||
765 | static inline |
704 | |
Line 766... | Line 705... | ||
766 | int _ksys_getcwd(char* buf, int bufsize){ |
705 | KOSAPI int _ksys_getcwd(char* buf, int bufsize) |
767 | register int val; |
706 | { |
768 | asm_inline( |
707 | register int val; |
769 | "int $0x40" |
708 | asm_inline( |
Line 770... | Line -... | ||
770 | :"=a"(val):"a"(30), "b"(2), "c"(buf), "d"(bufsize) |
- | |
771 | ); |
709 | "int $0x40" |
- | 710 | : "=a"(val) |
|
772 | return val; |
711 | : "a"(30), "b"(2), "c"(buf), "d"(bufsize)); |
773 | } |
712 | return val; |
774 | 713 | } |
|
775 | /* ---- Subfunction 3 - install the add.system directory for the kernel ------*/ |
714 | |
776 | 715 | /* ---- Subfunction 3 - install the add.system directory for the kernel ------*/ |
|
777 | static inline |
716 | |
778 | int _ksys_set_kernel_dir(ksys_dir_key_t *table){ |
- | |
779 | register int val; |
717 | KOSAPI int _ksys_set_kernel_dir(ksys_dir_key_t* table) |
780 | asm_inline( |
718 | { |
Line 781... | Line -... | ||
781 | "int $0x40" |
- | |
782 | :"=a"(val) |
719 | register int val; |
- | 720 | asm_inline( |
|
783 | :"a"(30), "b"(3), "c"(table) |
721 | "int $0x40" |
784 | :"memory" |
722 | : "=a"(val) |
785 | ); |
723 | : "a"(30), "b"(3), "c"(table) |
786 | return val; |
724 | : "memory"); |
787 | } |
725 | return val; |
788 | - | ||
789 | /*=================== Function 37 - work with mouse. ===================*/ |
726 | } |
790 | 727 | ||
Line 791... | Line -... | ||
791 | enum KSYS_MOUSE_POS{ |
- | |
792 | KSYS_MOUSE_SCREEN_POS = 0, |
728 | /*=================== Function 37 - work with mouse. ===================*/ |
- | 729 | ||
793 | KSYS_MOUSE_WINDOW_POS = 1 |
730 | enum KSYS_MOUSE_POS { |
794 | }; |
731 | KSYS_MOUSE_SCREEN_POS = 0, |
795 | 732 | KSYS_MOUSE_WINDOW_POS = 1 |
|
796 | static inline |
733 | }; |
797 | ksys_pos_t _ksys_get_mouse_pos(int origin){ |
734 | |
798 | ksys_pos_t pos; |
- | |
799 | asm_inline( |
735 | KOSAPI ksys_pos_t _ksys_get_mouse_pos(int origin) |
800 | "int $0x40 \n\t" |
736 | { |
Line 801... | Line -... | ||
801 | "rol $16, %%eax" |
- | |
802 | :"=a"(pos) |
737 | ksys_pos_t pos; |
- | 738 | asm_inline( |
|
803 | :"a"(37),"b"(origin) |
739 | "int $0x40 \n\t" |
804 | ); |
740 | "rol $16, %%eax" |
805 | return pos; |
741 | : "=a"(pos) |
806 | } |
742 | : "a"(37), "b"(origin)); |
807 | 743 | return pos; |
|
808 | static inline |
744 | } |
809 | uint32_t _ksys_get_mouse_buttons(void){ // subfunction 2 - states of the mouse buttons |
- | |
810 | uint32_t val; |
745 | |
811 | asm_inline( |
746 | KOSAPI uint32_t _ksys_get_mouse_buttons(void) // subfunction 2 - states of the mouse buttons |
Line 812... | Line -... | ||
812 | "int $0x40" |
- | |
813 | :"=a"(val) |
747 | { |
- | 748 | uint32_t val; |
|
814 | :"a"(37),"b"(2) |
749 | asm_inline( |
815 | ); |
750 | "int $0x40" |
816 | return val; |
751 | : "=a"(val) |
817 | } |
752 | : "a"(37), "b"(2)); |
818 | 753 | return val; |
|
819 | static inline |
- | |
820 | uint32_t _ksys_get_mouse_eventstate(void){ // subfunction 3 - states and events of the mouse buttons |
754 | } |
821 | uint32_t val; |
755 | |
Line 822... | Line -... | ||
822 | asm_inline( |
- | |
823 | "int $0x40" |
756 | KOSAPI uint32_t _ksys_get_mouse_eventstate(void) // subfunction 3 - states and events of the mouse buttons |
- | 757 | { |
|
824 | :"=a"(val) |
758 | uint32_t val; |
825 | :"a"(37),"b"(3) |
759 | asm_inline( |
826 | ); |
760 | "int $0x40" |
827 | return val; |
761 | : "=a"(val) |
828 | } |
762 | : "a"(37), "b"(3)); |
829 | 763 | return val; |
|
830 | static inline |
- | |
831 | uint32_t _ksys_load_cursor(void *path, uint32_t flags) { // subfunction 4 - load cursor |
764 | } |
832 | uint32_t val; |
765 | |
Line 833... | Line -... | ||
833 | asm_inline( |
- | |
834 | "int $0x40" |
766 | KOSAPI uint32_t _ksys_load_cursor(void* path, uint32_t flags) // subfunction 4 - load cursor |
835 | :"=a"(val) |
767 | { |
836 | :"a"(37), "b"(4), "c"(path), "d"(flags) |
768 | uint32_t val; |
837 | :"memory" |
769 | asm_inline( |
838 | ); |
770 | "int $0x40" |
839 | return val; |
771 | : "=a"(val) |
840 | } |
772 | : "a"(37), "b"(4), "c"(path), "d"(flags) |
841 | - | ||
842 | static inline |
773 | : "memory"); |
843 | uint32_t _ksys_set_cursor(uint32_t cursor){ // subfunction 5 - set curso |
774 | return val; |
Line 844... | Line 775... | ||
844 | uint32_t old; |
775 | } |
Line 889... | Line 820... | ||
889 | KSYS_EVM_STACK2 = 512, |
820 | KSYS_EVM_STACK2 = 512, |
890 | KSYS_EVM_MOUSE_FILTER = 0x80000000, |
821 | KSYS_EVM_MOUSE_FILTER = 0x80000000, |
891 | KSYS_EVM_CURSOR_FILTER = 0x40000000, |
822 | KSYS_EVM_CURSOR_FILTER = 0x40000000, |
892 | }; |
823 | }; |
Line 893... | Line -... | ||
893 | - | ||
894 | static inline |
824 | |
- | 825 | KOSAPI uint32_t _ksys_set_event_mask(uint32_t mask) |
|
895 | uint32_t _ksys_set_event_mask(uint32_t mask){ |
826 | { |
896 | unsigned val; |
827 | unsigned val; |
897 | asm_inline( |
828 | asm_inline( |
898 | "int $0x40" |
829 | "int $0x40" |
899 | :"=a"(val) |
830 | : "=a"(val) |
900 | :"a"(40), "b"(mask) |
- | |
901 | ); |
831 | : "a"(40), "b"(mask)); |
902 | return val; |
832 | return val; |
Line 903... | Line 833... | ||
903 | } |
833 | } |
Line 904... | Line -... | ||
904 | - | ||
905 | /*====================== Function 38 - draw line. ======================*/ |
834 | |
906 | 835 | /*====================== Function 38 - draw line. ======================*/ |
|
907 | static inline |
836 | |
908 | void _ksys_draw_line(int xs, int ys, int xe, int ye, ksys_color_t color) |
- | |
909 | { |
837 | KOSAPI void _ksys_draw_line(int xs, int ys, int xe, int ye, ksys_color_t color) |
910 | asm_inline( |
838 | { |
911 | "int $0x40" |
839 | asm_inline( |
912 | ::"a"(38), "d"(color), |
- | |
913 | "b"((xs << 16) | xe), |
840 | "int $0x40" ::"a"(38), "d"(color), |
Line 914... | Line 841... | ||
914 | "c"((ys << 16) | ye) |
841 | "b"((xs << 16) | xe), |
Line 915... | Line -... | ||
915 | ); |
- | |
916 | } |
842 | "c"((ys << 16) | ye)); |
- | 843 | } |
|
917 | 844 | ||
918 | /*============= Function 47 - draw a number in the window. =============*/ |
845 | /*============= Function 47 - draw a number in the window. =============*/ |
919 | 846 | ||
920 | static inline |
- | |
921 | void _ksys_draw_number(int number, int x, int y, int len, ksys_color_t color){ |
847 | KOSAPI void _ksys_draw_number(int number, int x, int y, int len, ksys_color_t color) |
922 | unsigned fmt; |
- | |
923 | fmt = len << 16 | 0x80000000; // no leading zeros + width |
848 | { |
Line 924... | Line -... | ||
924 | asm_inline( |
- | |
925 | "int $0x40" |
849 | unsigned fmt; |
- | 850 | fmt = len << 16 | 0x80000000; // no leading zeros + width |
|
926 | ::"a"(47), "b"(fmt), "c"(number), "d"((x << 16) | y), "S"(color) |
851 | asm_inline( |
927 | ); |
852 | "int $0x40" ::"a"(47), "b"(fmt), "c"(number), "d"((x << 16) | y), "S"(color)); |
928 | } |
853 | } |
929 | - | ||
930 | static inline |
854 | |
931 | void _ksys_draw_number_bg(unsigned number, int x, int y, int len, ksys_color_t color, ksys_color_t bg){ |
- | |
932 | unsigned fmt; |
855 | KOSAPI void _ksys_draw_number_bg(unsigned number, int x, int y, int len, ksys_color_t color, ksys_color_t bg) |
Line 933... | Line 856... | ||
933 | fmt = len << 16 | 0x80000000; // no leading zeros + width |
856 | { |
Line 934... | Line -... | ||
934 | asm_inline( |
- | |
935 | "int $0x40" |
857 | unsigned fmt; |
936 | ::"a"(47), "b"(fmt), "c"(number), "d"((x << 16) | y), "S"(color), "D"(bg) |
858 | fmt = len << 16 | 0x80000000; // no leading zeros + width |
937 | ); |
859 | asm_inline( |
938 | } |
- | |
939 | 860 | "int $0x40" ::"a"(47), "b"(fmt), "c"(number), "d"((x << 16) | y), "S"(color), "D"(bg)); |
|
940 | /*====== Function 48, subfunction 3 - get standard window colors. ======*/ |
- | |
941 | 861 | } |
|
Line 942... | Line 862... | ||
942 | static inline |
862 | |
Line 943... | Line -... | ||
943 | void _ksys_get_system_colors(ksys_colors_table_t *color_table) |
- | |
944 | { |
863 | /*====== Function 48, subfunction 3 - get standard window colors. ======*/ |
- | 864 | ||
945 | asm_inline( |
865 | KOSAPI void _ksys_get_system_colors(ksys_colors_table_t* color_table) |
946 | "int $0x40" |
866 | { |
947 | ::"a"(48),"b"(3),"c"(color_table),"d"(40) |
867 | asm_inline( |
948 | ); |
868 | "int $0x40" ::"a"(48), "b"(3), "c"(color_table), "d"(40)); |
949 | } |
869 | } |
950 | - | ||
951 | /*============ Function 48, subfunction 4 - get skin height. ===========*/ |
870 | |
952 | 871 | /*============ Function 48, subfunction 4 - get skin height. ===========*/ |
|
Line 953... | Line 872... | ||
953 | static inline |
872 | |
Line 954... | Line -... | ||
954 | uint32_t _ksys_get_skin_height(){ |
- | |
955 | unsigned height; |
873 | KOSAPI uint32_t _ksys_get_skin_height() |
- | 874 | { |
|
956 | asm_inline( |
875 | unsigned height; |
957 | "int $0x40" |
876 | asm_inline( |
958 | :"=a"(height) |
877 | "int $0x40" |
959 | :"a"(48),"b"(4) |
878 | : "=a"(height) |
960 | ); |
879 | : "a"(48), "b"(4)); |
961 | return height; |
880 | return height; |
962 | } |
- | |
963 | 881 | } |
|
964 | /*==================== Function 51 - create thread. ====================*/ |
882 | |
Line 965... | Line -... | ||
965 | - | ||
966 | static inline |
883 | /*==================== Function 51 - create thread. ====================*/ |
967 | int _ksys_create_thread(void* thread_entry, void* stack_top){ |
884 | |
Line 968... | Line 885... | ||
968 | int val; |
885 | KOSAPI int _ksys_create_thread(void* thread_entry, void* stack_top) |
969 | asm_inline( |
886 | { |
Line 989... | Line 906... | ||
989 | KSYS_CLIP_TEXT = 0, |
906 | KSYS_CLIP_TEXT = 0, |
990 | KSYS_CLIP_IMAGE = 1, |
907 | KSYS_CLIP_IMAGE = 1, |
991 | KSYS_CLIP_RAW = 2 |
908 | KSYS_CLIP_RAW = 2 |
992 | }; |
909 | }; |
Line 993... | Line -... | ||
993 | - | ||
994 | static inline |
910 | |
- | 911 | KOSAPI int _ksys_clip_num(void) |
|
995 | int _ksys_clip_num(){ |
912 | { |
996 | unsigned val; |
913 | unsigned val; |
997 | asm_inline( |
914 | asm_inline( |
998 | "int $0x40" |
915 | "int $0x40" |
999 | :"=a"(val) |
916 | : "=a"(val) |
1000 | :"a"(54), "b"(0) |
- | |
1001 | ); |
917 | : "a"(54), "b"(0)); |
1002 | return val; |
918 | return val; |
Line 1003... | Line 919... | ||
1003 | } |
919 | } |
1004 | 920 | ||
Line 1005... | Line -... | ||
1005 | /*==================== Function 54, subfunction 1 ======================*/ |
- | |
1006 | /*================= Read the data from the clipboard. ==================-*/ |
921 | /*==================== Function 54, subfunction 1 ======================*/ |
- | 922 | /*================= Read the data from the clipboard. ==================-*/ |
|
1007 | 923 | ||
1008 | static inline |
924 | KOSAPI char* _ksys_clip_get(int n) // returned buffer must be freed by _ksys_free() |
1009 | char* _ksys_clip_get(int n) { // returned buffer must be freed by _ksys_free() |
925 | { |
1010 | char* val; |
926 | char* val; |
1011 | asm_inline( |
927 | asm_inline( |
1012 | "int $0x40" |
- | |
1013 | :"=a"(val) |
928 | "int $0x40" |
1014 | :"a"(54), "b"(1), "c"(n) |
929 | : "=a"(val) |
Line 1015... | Line 930... | ||
1015 | ); |
930 | : "a"(54), "b"(1), "c"(n)); |
1016 | return val; |
931 | return val; |
Line 1017... | Line -... | ||
1017 | } |
- | |
1018 | 932 | } |
|
- | 933 | ||
1019 | /*==================== Function 54, subfunction 2 ======================*/ |
934 | /*==================== Function 54, subfunction 2 ======================*/ |
1020 | /*================= Write the data to the clipboard. ===================*/ |
935 | /*================= Write the data to the clipboard. ===================*/ |
1021 | 936 | ||
1022 | static inline |
937 | KOSAPI int _ksys_clip_set(int n, char* buffer) |
1023 | int _ksys_clip_set(int n, char *buffer){ |
938 | { |
1024 | unsigned val; |
939 | unsigned val; |
1025 | asm_inline( |
- | |
1026 | "int $0x40" |
940 | asm_inline( |
1027 | :"=a"(val) |
941 | "int $0x40" |
Line 1028... | Line 942... | ||
1028 | :"a"(54), "b"(2), "c"(n), "d"(buffer) |
942 | : "=a"(val) |
1029 | :"memory" |
943 | : "a"(54), "b"(2), "c"(n), "d"(buffer) |
Line 1030... | Line -... | ||
1030 | ); |
- | |
1031 | return val; |
944 | : "memory"); |
- | 945 | return val; |
|
1032 | } |
946 | } |
1033 | 947 | ||
1034 | /*===================== Function 54, subfunction 3 =====================*/ |
948 | /*===================== Function 54, subfunction 3 =====================*/ |
1035 | /*================ Delete the last slot in the clipboard ===============*/ |
949 | /*================ Delete the last slot in the clipboard ===============*/ |
1036 | 950 | ||
1037 | static inline |
- | |
1038 | int _ksys_clip_pop(){ |
951 | KOSAPI int _ksys_clip_pop() |
1039 | unsigned val; |
952 | { |
Line 1040... | Line 953... | ||
1040 | asm_inline ( |
953 | unsigned val; |
1041 | "int $0x40" |
954 | asm_inline( |
Line 1042... | Line -... | ||
1042 | :"=a"(val) |
- | |
1043 | :"a"(54), "b"(3) |
955 | "int $0x40" |
- | 956 | : "=a"(val) |
|
1044 | ); |
957 | : "a"(54), "b"(3)); |
1045 | return val; |
958 | return val; |
1046 | } |
959 | } |
1047 | 960 | ||
1048 | /*===================== Function 54, subfunction 4 =====================*/ |
961 | /*===================== Function 54, subfunction 4 =====================*/ |
1049 | /*===================== Alarm reset the lock buffer ====================*/ |
- | |
1050 | 962 | /*===================== Alarm reset the lock buffer ====================*/ |
|
1051 | static inline |
963 | |
Line 1052... | Line 964... | ||
1052 | int _ksys_clip_unlock(){ |
964 | KOSAPI int _ksys_clip_unlock() |
Line 1053... | Line -... | ||
1053 | unsigned val; |
- | |
1054 | asm_inline( |
965 | { |
- | 966 | unsigned val; |
|
1055 | "int $0x40" |
967 | asm_inline( |
1056 | :"=a"(val) |
968 | "int $0x40" |
Line 1057... | Line -... | ||
1057 | :"a"(54), "b"(4) |
- | |
1058 | ); |
969 | : "=a"(val) |
- | 970 | : "a"(54), "b"(4)); |
|
1059 | return val; |
971 | return val; |
1060 | } |
972 | } |
1061 | 973 | ||
1062 | /*============== Function 63 - work with the debug board. ==============*/ |
974 | /*============== Function 63 - work with the debug board. ==============*/ |
1063 | 975 | ||
Line 1080... | Line 992... | ||
1080 | typedef enum KSYS_KEY_INPUT_MODE { |
992 | typedef enum KSYS_KEY_INPUT_MODE { |
1081 | KSYS_KEY_INPUT_MODE_ASCII = 0, |
993 | KSYS_KEY_INPUT_MODE_ASCII = 0, |
1082 | KSYS_KEY_INPUT_MODE_SCANC = 1, |
994 | KSYS_KEY_INPUT_MODE_SCANC = 1, |
1083 | } ksys_key_input_mode_t; |
995 | } ksys_key_input_mode_t; |
Line 1084... | Line -... | ||
1084 | - | ||
1085 | static inline |
996 | |
- | 997 | KOSAPI void _ksys_set_key_input_mode(ksys_key_input_mode_t mode) |
|
1086 | void _ksys_set_key_input_mode(ksys_key_input_mode_t mode){ |
998 | { |
1087 | asm_inline( |
- | |
1088 | "int $0x40" |
999 | asm_inline( |
1089 | ::"a"(66),"b"(1),"c"(mode) |
- | |
1090 | ); |
1000 | "int $0x40" ::"a"(66), "b"(1), "c"(mode)); |
Line 1091... | Line 1001... | ||
1091 | } |
1001 | } |
Line 1092... | Line -... | ||
1092 | - | ||
1093 | /*========= Function 67 - change position/sizes of the window. =========*/ |
1002 | |
- | 1003 | /*========= Function 67 - change position/sizes of the window. =========*/ |
|
1094 | 1004 | ||
1095 | static inline |
- | |
1096 | void _ksys_change_window(int new_x, int new_y, int new_w, int new_h){ |
1005 | KOSAPI void _ksys_change_window(int new_x, int new_y, int new_w, int new_h) |
1097 | asm_inline( |
- | |
1098 | "int $0x40" |
1006 | { |
Line 1099... | Line 1007... | ||
1099 | ::"a"(67), "b"(new_x), "c"(new_y), "d"(new_w),"S"(new_h) |
1007 | asm_inline( |
Line 1100... | Line -... | ||
1100 | ); |
- | |
1101 | } |
1008 | "int $0x40" ::"a"(67), "b"(new_x), "c"(new_y), "d"(new_w), "S"(new_h)); |
- | 1009 | } |
|
1102 | 1010 | ||
1103 | /*======== Function 68, subfunction 12 - allocate memory block. ========*/ |
1011 | /*======== Function 68, subfunction 12 - allocate memory block. ========*/ |
1104 | 1012 | ||
1105 | static inline |
1013 | KOSAPI void* _ksys_alloc(size_t size) |
1106 | void* _ksys_alloc(size_t size){ |
1014 | { |
1107 | void *val; |
- | |
1108 | asm_inline( |
1015 | void* val; |
1109 | "int $0x40" |
1016 | asm_inline( |
Line 1110... | Line 1017... | ||
1110 | :"=a"(val) |
1017 | "int $0x40" |
Line 1111... | Line -... | ||
1111 | :"a"(68),"b"(12),"c"(size) |
- | |
1112 | ); |
1018 | : "=a"(val) |
- | 1019 | : "a"(68), "b"(12), "c"(size)); |
|
1113 | return val; |
1020 | return val; |
1114 | } |
1021 | } |
1115 | 1022 | ||
1116 | /*========== Function 68, subfunction 13 - free memory block. ==========*/ |
1023 | /*========== Function 68, subfunction 13 - free memory block. ==========*/ |
1117 | 1024 | ||
1118 | static inline |
- | |
1119 | int _ksys_free(void *mem){ |
1025 | KOSAPI int _ksys_free(void* mem) |
1120 | int val; |
1026 | { |
Line 1121... | Line 1027... | ||
1121 | asm_inline( |
1027 | int val; |
Line 1122... | Line -... | ||
1122 | "int $0x40" |
- | |
1123 | :"=a"(val) |
1028 | asm_inline( |
1124 | :"a"(68),"b"(13),"c"(mem) |
1029 | "int $0x40" |
1125 | ); |
1030 | : "=a"(val) |
1126 | return val; |
1031 | : "a"(68), "b"(13), "c"(mem)); |
1127 | } |
1032 | return val; |
1128 | 1033 | } |
|
1129 | /*============= Function 68, subfunction 16 - load driver. =============*/ |
1034 | |
1130 | - | ||
1131 | static inline |
1035 | /*============= Function 68, subfunction 16 - load driver. =============*/ |
1132 | ksys_drv_hand_t _ksys_load_driver(char *driver_name) |
1036 | |
Line 1133... | Line 1037... | ||
1133 | { |
1037 | KOSAPI ksys_drv_hand_t _ksys_load_driver(char* driver_name) |
Line 1134... | Line -... | ||
1134 | ksys_drv_hand_t driver_h; |
- | |
1135 | asm_inline( |
1038 | { |
1136 | "int $0x40" |
1039 | ksys_drv_hand_t driver_h; |
1137 | :"=a"(driver_h) |
1040 | asm_inline( |
1138 | :"a"(68), "b"(16), "c"(driver_name) |
1041 | "int $0x40" |
1139 | ); |
1042 | : "=a"(driver_h) |
1140 | return driver_h; |
1043 | : "a"(68), "b"(16), "c"(driver_name)); |
1141 | } |
1044 | return driver_h; |
1142 | 1045 | } |
|
1143 | /*============ Function 68, subfunction 17 - driver control. ===========*/ |
- | |
1144 | 1046 | ||
1145 | static inline |
1047 | /*============ Function 68, subfunction 17 - driver control. ===========*/ |
Line 1146... | Line 1048... | ||
1146 | unsigned _ksys_driver_control(ksys_ioctl_t *ioctl) |
1048 | |
Line 1147... | Line -... | ||
1147 | { |
- | |
1148 | unsigned status; |
1049 | KOSAPI int _ksys_driver_control(ksys_ioctl_t* ioctl) |
- | 1050 | { |
|
1149 | asm_inline( |
1051 | int status; |
1150 | "int $0x40" |
1052 | asm_inline( |
1151 | :"=a"(status) |
1053 | "int $0x40" |
1152 | :"a"(68), "b"(17), "c"(ioctl) |
1054 | : "=a"(status) |
1153 | :"memory" |
1055 | : "a"(68), "b"(17), "c"(ioctl) |
1154 | ); |
1056 | : "memory"); |
1155 | return status; |
- | |
1156 | } |
1057 | return status; |
1157 | 1058 | } |
|
Line 1158... | Line 1059... | ||
1158 | /*== Function 68, subfunction 18 - subfunction 19 - load DLL (MS COFF) ==*/ |
1059 | |
Line 1159... | Line -... | ||
1159 | - | ||
1160 | static inline |
1060 | /*== Function 68, subfunction 18 - subfunction 19 - load DLL (MS COFF) ==*/ |
- | 1061 | ||
1161 | ksys_dll_t* _ksys_dlopen(const char* path){ |
1062 | KOSAPI ksys_dll_t* _ksys_dlopen(const char* path) |
1162 | ksys_dll_t *table; |
1063 | { |
1163 | asm_inline( |
1064 | ksys_dll_t* table; |
1164 | "int $0x40" |
1065 | asm_inline( |
1165 | :"=a"(table) |
1066 | "int $0x40" |
Line 1187... | Line 1088... | ||
1187 | return NULL; |
1088 | return NULL; |
1188 | } |
1089 | } |
Line 1189... | Line 1090... | ||
1189 | 1090 | ||
Line 1190... | Line -... | ||
1190 | /* Function 68, subfunction 20 - reallocate memory block.*/ |
- | |
1191 | 1091 | /* Function 68, subfunction 20 - reallocate memory block.*/ |
|
- | 1092 | ||
1192 | static inline |
1093 | KOSAPI void* _ksys_realloc(void* mem, size_t size) |
1193 | void* _ksys_realloc(void *mem, size_t size){ |
1094 | { |
1194 | void *val; |
1095 | void* val; |
1195 | asm_inline( |
1096 | asm_inline( |
1196 | "int $0x40" |
1097 | "int $0x40" |
1197 | :"=a"(val) |
1098 | : "=a"(val) |
1198 | :"a"(68),"b"(20),"c"(size),"d"(mem) |
- | |
1199 | :"memory" |
1099 | : "a"(68), "b"(20), "c"(size), "d"(mem) |
1200 | ); |
1100 | : "memory"); |
Line 1201... | Line 1101... | ||
1201 | return val; |
1101 | return val; |
Line 1202... | Line -... | ||
1202 | } |
- | |
1203 | 1102 | } |
|
1204 | /* Function 68, subfunction 21 - load driver by full name. */ |
1103 | |
1205 | 1104 | /* Function 68, subfunction 21 - load driver by full name. */ |
|
1206 | static inline |
1105 | |
1207 | ksys_drv_hand_t _ksys_load_driver_opt(char *driver_path, char *cmd_line) |
1106 | KOSAPI ksys_drv_hand_t _ksys_load_driver_opt(char* driver_path, char* cmd_line) |
1208 | { |
1107 | { |
1209 | ksys_drv_hand_t driver_h; |
1108 | ksys_drv_hand_t driver_h; |
1210 | asm_inline( |
- | |
1211 | "int $0x40" |
1109 | asm_inline( |
1212 | :"=a"(driver_h) |
1110 | "int $0x40" |
Line 1213... | Line 1111... | ||
1213 | :"a"(68), "b"(21), "c"(driver_path), "d"(cmd_line) |
1111 | : "=a"(driver_h) |
Line 1223... | Line 1121... | ||
1223 | KSYS_SHM_CREATE = 0x08, |
1121 | KSYS_SHM_CREATE = 0x08, |
1224 | KSYS_SHM_READ = 0x00, |
1122 | KSYS_SHM_READ = 0x00, |
1225 | KSYS_SHM_WRITE = 0x01, |
1123 | KSYS_SHM_WRITE = 0x01, |
1226 | }; |
1124 | }; |
Line 1227... | Line -... | ||
1227 | - | ||
1228 | static inline |
1125 | |
1229 | int _ksys_shm_open(char *name, int mode, int size, char **new_shm) |
1126 | KOSAPI int _ksys_shm_open(char* name, int mode, int size, char** new_shm) |
1230 | { |
1127 | { |
1231 | int error; |
1128 | int error; |
1232 | asm_inline( |
1129 | asm_inline( |
1233 | "int $0x40" |
1130 | "int $0x40" |
1234 | :"=a"(*new_shm), "=d"(error) |
1131 | : "=a"(*new_shm), "=d"(error) |
1235 | :"a"(68), "b"(22), "c"(name), "d"(size), "S"(mode) |
- | |
1236 | ); |
1132 | : "a"(68), "b"(22), "c"(name), "d"(size), "S"(mode)); |
1237 | return error; |
1133 | return error; |
Line 1238... | Line 1134... | ||
1238 | } |
1134 | } |
Line 1239... | Line -... | ||
1239 | - | ||
1240 | /*======= Function 68, subfunction 23 - close named memory area. =======*/ |
1135 | |
1241 | 1136 | /*======= Function 68, subfunction 23 - close named memory area. =======*/ |
|
1242 | static inline |
1137 | |
1243 | void _ksys_shm_close(char *shm_name) |
1138 | KOSAPI void _ksys_shm_close(char* shm_name) |
- | 1139 | { |
|
1244 | { |
1140 | asm_inline( |
1245 | asm_inline( |
- | |
1246 | "int $0x40": |
1141 | "int $0x40" |
Line 1247... | Line 1142... | ||
1247 | :"a"(68), "b"(23), "c"(shm_name) |
1142 | : |
Line 1248... | Line -... | ||
1248 | ); |
- | |
1249 | } |
1143 | : "a"(68), "b"(23), "c"(shm_name)); |
- | 1144 | } |
|
1250 | 1145 | ||
1251 | /*====== Function 68, subfunction 26 - release memory pages ============*/ |
1146 | /*====== Function 68, subfunction 26 - release memory pages ============*/ |
1252 | 1147 | ||
1253 | static inline |
1148 | KOSAPI int* _ksys_unmap(void* base, size_t offset, size_t size) |
1254 | int* _ksys_unmap(void *base, size_t offset, size_t size){ |
1149 | { |
1255 | int *val; |
- | |
1256 | asm_inline( |
1150 | int* val; |
1257 | "int $0x40" |
1151 | asm_inline( |
Line 1258... | Line 1152... | ||
1258 | :"=a"(val) |
1152 | "int $0x40" |
Line 1259... | Line -... | ||
1259 | :"a"(68),"b"(26),"c"(base),"d"(offset),"S"(size) |
- | |
1260 | ); |
1153 | : "=a"(val) |
1261 | return val; |
1154 | : "a"(68), "b"(26), "c"(base), "d"(offset), "S"(size)); |
1262 | } |
1155 | return val; |
1263 | 1156 | } |
|
1264 | /*========== Function 68, subfunction 27 - load file ===================*/ |
1157 | |
1265 | 1158 | /*========== Function 68, subfunction 27 - load file ===================*/ |
|
1266 | static inline |
1159 | |
1267 | ksys_ufile_t _ksys_load_file(const char *path) |
1160 | KOSAPI ksys_ufile_t _ksys_load_file(const char* path) |
1268 | { |
- | |
1269 | ksys_ufile_t uf; |
1161 | { |
1270 | asm_inline( |
1162 | ksys_ufile_t uf; |
Line 1271... | Line 1163... | ||
1271 | "int $0x40" |
1163 | asm_inline( |
Line 1272... | Line -... | ||
1272 | :"=a"(uf.data), "=d"(uf.size) |
- | |
1273 | :"a"(68), "b"(27),"c"(path) |
1164 | "int $0x40" |
1274 | :"memory" |
1165 | : "=a"(uf.data), "=d"(uf.size) |
1275 | ); |
1166 | : "a"(68), "b"(27), "c"(path) |
1276 | return uf; |
1167 | : "memory"); |
1277 | } |
1168 | return uf; |
1278 | 1169 | } |
|
1279 | /*==== Function 68, subfunction 28 - load file, specifying the encoding ===*/ |
1170 | |
1280 | 1171 | /*==== Function 68, subfunction 28 - load file, specifying the encoding ===*/ |
|
1281 | static inline |
- | |
1282 | ksys_ufile_t _ksys_load_file_enc(const char *path, unsigned file_encoding) |
1172 | |
1283 | { |
1173 | KOSAPI ksys_ufile_t _ksys_load_file_enc(const char* path, unsigned file_encoding) |
Line 1284... | Line 1174... | ||
1284 | ksys_ufile_t uf; |
1174 | { |
Line 1285... | Line -... | ||
1285 | asm_inline( |
- | |
1286 | "int $0x40" |
1175 | ksys_ufile_t uf; |
1287 | :"=a"(uf.data), "=d"(uf.size) |
1176 | asm_inline( |
1288 | :"a"(68), "b"(28),"c"(path), "d"(file_encoding) |
1177 | "int $0x40" |
1289 | :"memory" |
1178 | : "=a"(uf.data), "=d"(uf.size) |
1290 | ); |
1179 | : "a"(68), "b"(28), "c"(path), "d"(file_encoding) |
1291 | return uf; |
1180 | : "memory"); |
1292 | } |
1181 | return uf; |
1293 | 1182 | } |
|
1294 | /*==== Function 70 - work with file system with long names support. ====*/ |
- | |
1295 | 1183 | ||
1296 | static inline |
1184 | /*==== Function 70 - work with file system with long names support. ====*/ |
Line 1297... | Line 1185... | ||
1297 | int _ksys_work_files(const ksys70_t *k) |
1185 | |
Line 1298... | Line -... | ||
1298 | { |
- | |
1299 | int status; |
1186 | KOSAPI ksys70_status_t _ksys70(const ksys70_t* k) |
1300 | asm_inline( |
1187 | { |
1301 | "int $0x40" |
1188 | ksys70_status_t status; |
1302 | :"=a"(status) |
1189 | asm_inline( |
1303 | :"a"(70), "b"(k) |
1190 | "int $0x40" |
1304 | :"memory" |
1191 | : "=a"(status.status), "=b"(status.rw_bytes) |
1305 | ); |
1192 | : "a"(70), "b"(k) |
1306 | return status; |
1193 | : "memory"); |
1307 | } |
1194 | return status; |
1308 | - | ||
1309 | /*====== Function 70, subfunction 0 - read file with long names support. ======*/ |
- | |
1310 | - | ||
1311 | static inline |
- | |
1312 | int _ksys_file_read_file(const char *name, unsigned long long offset, unsigned size, void *buf, unsigned *bytes_read) |
- | |
1313 | { |
- | |
1314 | ksys70_t k; |
- | |
1315 | k.p00 = 0; |
1195 | } |
1316 | k.p04 = offset; |
1196 | |
Line 1317... | Line 1197... | ||
1317 | k.p12 = size; |
1197 | /*====== Function 70, subfunction 0 - read file with long names support. ======*/ |
1318 | k.buf16 = buf; |
1198 | |
Line 1319... | Line -... | ||
1319 | k.p20 = 0; |
- | |
1320 | k.p21 = name; |
1199 | KOSAPI ksys70_status_t _ksys_file_read(const char* name, uint64_t offset, uint32_t size, void* buf) |
- | 1200 | { |
|
1321 | int status; |
1201 | ksys70_t k; |
1322 | asm_inline( |
1202 | k.p00 = 0; |
1323 | "int $0x40" |
1203 | k.p04 = offset; |
1324 | :"=a"(status), "=b"(*bytes_read) |
1204 | k.p12 = size; |
1325 | :"a"(70), "b"(&k) |
1205 | k.buf16 = buf; |
1326 | :"memory" |
1206 | k.p20 = 0; |
1327 | ); |
1207 | k.p21 = name; |
1328 | return status; |
1208 | return _ksys70(&k); |
Line 1329... | Line 1209... | ||
1329 | } |
1209 | } |
1330 | 1210 | ||
Line 1331... | Line -... | ||
1331 | /*===================== Function 70, subfunction 2 =====================*/ |
- | |
1332 | /*============ Create/rewrite file with long names support. ============*/ |
1211 | /*===================== Function 70, subfunction 2 =====================*/ |
1333 | 1212 | /*============ Create/rewrite file with long names support. ============*/ |
|
1334 | static inline |
1213 | |
1335 | int _ksys_file_create(const char* name){ |
1214 | KOSAPI int _ksys_file_create(const char* name) |
1336 | ksys70_t k; |
1215 | { |
1337 | k.p00 = 2; |
1216 | ksys70_t k; |
1338 | k.p04dw = 0; |
1217 | k.p00 = 2; |
1339 | k.p08dw = 0; |
1218 | k.p04dw = 0; |
1340 | k.p12 = 0; |
1219 | k.p08dw = 0; |
1341 | k.p21 = name; |
- | |
1342 | return _ksys_work_files(&k); |
- | |
1343 | } |
- | |
1344 | - | ||
1345 | /*===================== Function 70, subfunction 3 =====================*/ |
- | |
1346 | /*=========== Write to existing file with long names support. ==========*/ |
- | |
1347 | - | ||
1348 | static inline |
1220 | k.p12 = 0; |
1349 | int _ksys_file_write_file(const char *name, unsigned long long offset, unsigned size, const void *buf, unsigned *bytes_written) |
1221 | k.p21 = name; |
Line 1350... | Line 1222... | ||
1350 | { |
1222 | return _ksys70(&k).status; |
Line 1351... | Line -... | ||
1351 | ksys70_t k; |
- | |
1352 | k.p00 = 3; |
1223 | } |
1353 | k.p04 = offset; |
1224 | |
1354 | k.p12 = size; |
1225 | /*===================== Function 70, subfunction 3 =====================*/ |
1355 | k.cbuf16 = buf; |
1226 | /*=========== Write to existing file with long names support. ==========*/ |
1356 | k.p20 = 0; |
1227 | |
1357 | k.p21 = name; |
1228 | KOSAPI ksys70_status_t _ksys_file_write(const char* name, uint64_t offset, uint32_t size, const void* buf) |
1358 | int status; |
1229 | { |
1359 | asm_inline( |
1230 | ksys70_t k; |
1360 | "int $0x40" |
1231 | k.p00 = 3; |
1361 | :"=a"(status), "=b"(*bytes_written) |
1232 | k.p04 = offset; |
1362 | :"a"(70), "b"(&k) |
1233 | k.p12 = size; |
1363 | :"memory" |
1234 | k.cbuf16 = buf; |
Line -... | Line 1235... | ||
- | 1235 | k.p20 = 0; |
|
- | 1236 | k.p21 = name; |
|
1364 | ); |
1237 | return _ksys70(&k); |
Line 1365... | Line -... | ||
1365 | return status; |
- | |
1366 | } |
1238 | } |
1367 | 1239 | ||
1368 | /*========== Function 70, subfunction 5 - get information on file/folder. =====*/ |
1240 | /*========== Function 70, subfunction 5 - get information on file/folder. =====*/ |
1369 | 1241 | ||
1370 | static inline |
1242 | KOSAPI int _ksys_file_info(const char* name, ksys_bdfe_t* bdfe) |
1371 | int _ksys_file_get_info(const char *name, ksys_bdfe_t *bdfe) |
1243 | { |
Line 1372... | Line 1244... | ||
1372 | { |
1244 | ksys70_t k; |
1373 | ksys70_t k; |
1245 | k.p00 = 5; |
1374 | k.p00 = 5; |
1246 | k.p04dw = 0; |
Line 1375... | Line 1247... | ||
1375 | k.p04dw = 0; |
1247 | k.p08dw = 0; |
1376 | k.p08dw = 0; |
1248 | k.p12 = 0; |
1377 | k.p12 = 0; |
1249 | k.bdfe = bdfe; |
Line 1378... | Line 1250... | ||
1378 | k.bdfe = bdfe; |
1250 | k.p20 = 0; |
Line 1379... | Line -... | ||
1379 | k.p20 = 0; |
- | |
1380 | k.p21 = name; |
1251 | k.p21 = name; |
1381 | return _ksys_work_files(&k); |
1252 | return _ksys70(&k).status; |
1382 | } |
1253 | } |
1383 | 1254 | ||
1384 | /*=========== Function 70, subfunction 7 - start application. ===========*/ |
1255 | #define _ksys_dir_info _ksys_file_info |
1385 | 1256 | ||
1386 | static inline |
1257 | /*=========== Function 70, subfunction 7 - start application. ===========*/ |
1387 | int _ksys_exec(char *app_name, char *args) |
1258 | |
Line 1388... | Line 1259... | ||
1388 | { |
1259 | KOSAPI int _ksys_exec(const char* app_name, char* args) |
Line 1389... | Line -... | ||
1389 | ksys70_t file_opt; |
- | |
1390 | file_opt.p00 = 7; |
1260 | { |
1391 | file_opt.p04dw = 0; |
1261 | ksys70_t file_opt; |
1392 | file_opt.p08dw = (unsigned)args; |
1262 | file_opt.p00 = 7; |
1393 | 1263 | file_opt.p04dw = 0; |
|
1394 | file_opt.p12 = 0; |
1264 | file_opt.p08dw = (uint32_t)args; |
1395 | file_opt.p16 = 0; |
1265 | |
1396 | file_opt.p20 = 0; |
1266 | file_opt.p12 = 0; |
Line 1397... | Line 1267... | ||
1397 | 1267 | file_opt.p16 = 0; |
|
Line 1398... | Line -... | ||
1398 | file_opt.p21 = app_name; |
- | |
1399 | return _ksys_work_files(&file_opt); |
1268 | file_opt.p20 = 0; |
1400 | } |
1269 | |
1401 | 1270 | file_opt.p21 = app_name; |
|
1402 | /*========== Function 70, subfunction 8 - delete file/folder. ==========*/ |
1271 | return _ksys70(&file_opt).status; |
1403 | 1272 | } |
|
1404 | static inline |
1273 | |
1405 | int _ksys_file_delete(const char *name) |
1274 | /*========== Function 70, subfunction 8 - delete file/folder. ==========*/ |
1406 | { |
1275 | |
1407 | ksys70_t k; |
1276 | KOSAPI int _ksys_file_delete(const char* name) |
Line -... | Line 1277... | ||
- | 1277 | { |
|
- | 1278 | ksys70_t k; |
|
1408 | k.p00 = 8; |
1279 | k.p00 = 8; |
Line 1409... | Line -... | ||
1409 | k.p20 = 0; |
- | |
1410 | k.p21 = name; |
1280 | k.p20 = 0; |
1411 | return _ksys_work_files(&k); |
1281 | k.p21 = name; |
1412 | } |
1282 | return _ksys70(&k).status; |
1413 | 1283 | } |
|
1414 | /*============= Function 70, subfunction 9 - create folder. ============*/ |
1284 | |
1415 | 1285 | /*============= Function 70, subfunction 9 - create folder. ============*/ |
|
1416 | static inline |
1286 | |
1417 | int _ksys_mkdir(const char *path) |
1287 | KOSAPI int _ksys_mkdir(const char* path) |
1418 | { |
- | |
1419 | ksys70_t dir_opt; |
1288 | { |
1420 | dir_opt.p00 = 9; |
1289 | ksys70_t dir_opt; |
Line 1421... | Line -... | ||
1421 | dir_opt.p21 = path; |
- | |
1422 | return _ksys_work_files(&dir_opt); |
1290 | dir_opt.p00 = 9; |
1423 | } |
1291 | dir_opt.p21 = path; |
1424 | 1292 | return _ksys70(&dir_opt).status; |
|
1425 | /*============= Function 70, subfunction 10 - rename/move. =============*/ |
1293 | } |
1426 | 1294 | ||
1427 | static inline |
1295 | /*============= Function 70, subfunction 10 - rename/move. =============*/ |
1428 | int _ksys_file_rename(const char *name, const char *new_name) |
1296 | |
1429 | { |
1297 | KOSAPI int _ksys_file_rename(const char* name, const char* new_name) |
1430 | ksys70_t k; |
- | |
1431 | k.p00 = 10; |
1298 | { |
1432 | k.new_name = new_name; |
1299 | ksys70_t k; |
Line 1433... | Line -... | ||
1433 | k.p20 = 0; |
- | |
1434 | k.p21 = name; |
1300 | k.p00 = 10; |
1435 | return _ksys_work_files(&k); |
1301 | k.new_name = new_name; |
1436 | } |
1302 | k.p20 = 0; |
1437 | 1303 | k.p21 = name; |
|
1438 | /*============= Function 77 - implements the POSIX subsystem. =============*/ |
1304 | return _ksys70(&k).status; |
1439 | 1305 | } |
|
1440 | static inline |
1306 | |
1441 | int _ksys_posix_read(int pipefd, void* buff, int n) |
1307 | #define _ksys_dir_rename _ksys_file_rename |
1442 | { |
- | |
1443 | int count; |
1308 | |
1444 | asm_inline( |
1309 | /*============= Function 77 - implements the POSIX subsystem. =============*/ |
Line 1445... | Line 1310... | ||
1445 | "int $0x40" |
1310 | |
Line 1446... | Line 1311... | ||
1446 | :"=a"(count) |
1311 | KOSAPI int _ksys_posix_read(int pipefd, void* buff, int n) |
- | 1312 | { |
|
- | 1313 | int count; |
|
- | 1314 | asm_inline( |
|
- | 1315 | "int $0x40" |
|
- | 1316 | : "=a"(count) |
|
- | 1317 | : "a"(77), "b"(10), "c"(pipefd), "d"(buff), "S"(n) |
|
- | 1318 | : "memory"); |
|
- | 1319 | return count; |
|
- | 1320 | } |
|
- | 1321 | ||
- | 1322 | KOSAPI int _ksys_posix_write(int pipefd, void* buff, int n) |
|
- | 1323 | { |
|
- | 1324 | int count; |
|
- | 1325 | asm_inline( |
|
- | 1326 | "int $0x40" |
|
Line 1447... | Line 1327... | ||
1447 | :"a"(77), "b"(10),"c"(pipefd), "d"(buff), "S"(n) |
1327 | : "=a"(count) |