Rev 8818 | Rev 9094 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8818 | Rev 9093 | ||
---|---|---|---|
Line -... | Line 1... | ||
- | 1 | /* Copyright (C) KolibriOS team 2004-2021. All rights reserved. */ |
|
- | 2 | /* Distributed under terms of the GNU General Public License */ |
|
- | 3 | ||
- | 4 | /* This file contains basic wrappers over KolibriOS system calls. */ |
|
- | 5 | /* See sysfuncs.txt file for details. */ |
|
- | 6 | ||
- | 7 | /* |
|
- | 8 | * This file was created with you in mind. Lest you reinvent the wheel. |
|
- | 9 | * If for some reason there is not enough wrapper add! I ask you to stick to the same style: snake_case. |
|
- | 10 | * Structure names must start with "ksys_" and end with "_t". |
|
- | 11 | * All wrappers must start with the "_ksys_" prefix. |
|
- | 12 | * I consider it mandatory to place the wrappers in the correct order in the official documentation. |
|
- | 13 | * Enjoy writing your code :) |
|
- | 14 | */ |
|
- | 15 | ||
- | 16 | // Warning! The end of the file is the old definitions of function/structure names. |
|
- | 17 | // They are for compatibility... Better not to use them. */ |
|
- | 18 | ||
1 | #ifndef _KSYS_H_ |
19 | #ifndef _KSYS_H_ |
2 | #define _KSYS_H_ |
20 | #define _KSYS_H_ |
Line 3... | Line -... | ||
3 | - | ||
4 | #ifdef __cplusplus |
- | |
5 | extern "C" { |
- | |
6 | #endif |
- | |
7 | 21 | ||
Line 8... | Line 22... | ||
8 | #include |
22 | #include |
Line 9... | Line -... | ||
9 | - | ||
10 | #define asm_inline __asm__ __volatile__ |
- | |
11 | - | ||
12 | #define KSYS_FS_ERR_SUCCESS 0 // Success |
- | |
13 | #define KSYS_FS_ERR_1 1 // Base and/or partition of a hard disk is not defined (fn21.7 & fn21.8) |
- | |
14 | #define KSYS_FS_ERR_2 2 // Function is not supported for the given file system |
- | |
15 | #define KSYS_FS_ERR_3 3 // Unknown file system |
23 | |
16 | #define KSYS_FS_ERR_4 4 // Reserved, is never returned in the current implementation |
- | |
17 | #define KSYS_FS_ERR_5 5 // File not found |
- | |
18 | #define KSYS_FS_ERR_EOF 6 // End of file, EOF |
- | |
19 | #define KSYS_FS_ERR_7 7 // Pointer lies outside of application memory |
- | |
20 | #define KSYS_FS_ERR_8 8 // Disk is full |
- | |
Line 21... | Line 24... | ||
21 | #define KSYS_FS_ERR_9 9 // FAT table is destroyed |
24 | #define asm_inline __asm__ __volatile__ |
Line 22... | Line 25... | ||
22 | #define KSYS_FS_ERR_10 10 // Access denied |
25 | |
23 | #define KSYS_FS_ERR_11 11 // Device error |
26 | /*============== General structures ==============*/ |
24 | 27 | ||
25 | typedef void ksys_panic(char *func_name); |
28 | #pragma pack(push,1) |
26 | 29 | ||
Line 27... | Line -... | ||
27 | typedef struct { |
- | |
28 | unsigned char blue; |
30 | typedef struct { |
29 | unsigned char green; |
31 | uint8_t blue; |
- | 32 | uint8_t green; |
|
- | 33 | uint8_t red; |
|
- | 34 | }rgb_t; |
|
- | 35 | ||
- | 36 | typedef union { |
|
- | 37 | uint32_t val; |
|
- | 38 | struct{ |
|
- | 39 | uint8_t hour; |
|
- | 40 | uint8_t min; |
|
- | 41 | uint8_t sec; |
|
30 | unsigned char red; |
42 | uint8_t _zero; |
- | 43 | }; |
|
- | 44 | }ksys_time_t; |
|
- | 45 | ||
- | 46 | typedef union { |
|
- | 47 | uint32_t val; |
|
- | 48 | struct{ |
|
- | 49 | uint8_t year; |
|
- | 50 | uint8_t month; |
|
- | 51 | uint8_t day; |
|
- | 52 | uint8_t _zero; |
|
31 | }rgb_t; |
53 | }; |
32 | 54 | }ksys_date_t; |
|
33 | #pragma pack(push,1) |
55 | |
34 | typedef union{ |
56 | typedef union{ |
Line 35... | Line 57... | ||
35 | unsigned val; |
57 | uint32_t val; |
36 | struct{ |
58 | struct{ |
37 | short x; |
59 | uint16_t x; |
38 | short y; |
60 | uint16_t y; |
39 | }; |
61 | }; |
40 | }ksys_pos_t; |
62 | }ksys_pos_t; |
41 | 63 | ||
42 | typedef union ksys_oskey_t{ |
64 | typedef union ksys_oskey_t{ |
Line 43... | Line 65... | ||
43 | unsigned val; |
65 | uint32_t val; |
44 | struct{ |
66 | struct{ |
45 | unsigned char state; |
67 | uint8_t state; |
46 | unsigned char code; |
68 | uint8_t code; |
Line 47... | Line 69... | ||
47 | unsigned char ctrl_key; |
69 | uint8_t ctrl_key; |
48 | }; |
70 | }; |
49 | }ksys_oskey_t; |
71 | }ksys_oskey_t; |
50 | 72 | ||
51 | typedef struct{ |
73 | typedef struct{ |
52 | void *data; |
74 | void *data; |
53 | size_t size; |
75 | size_t size; |
54 | }ksys_ufile_t; |
76 | }ksys_ufile_t; |
55 | 77 | ||
56 | 78 | ||
57 | typedef struct{ |
79 | typedef struct{ |
58 | unsigned p00; |
80 | uint32_t p00; |
59 | union{ |
81 | union{ |
60 | uint64_t p04; |
82 | uint64_t p04; |
61 | struct { |
83 | struct { |
62 | unsigned p04dw; |
84 | uint32_t p04dw; |
63 | unsigned p08dw; |
85 | uint32_t p08dw; |
64 | }; |
86 | }; |
65 | }; |
87 | }; |
66 | unsigned p12; |
88 | uint32_t p12; |
Line 67... | Line -... | ||
67 | union { |
- | |
68 | unsigned p16; |
89 | union { |
69 | const char *new_name; |
90 | uint32_t p16; |
70 | void *bdfe; |
91 | const char *new_name; |
71 | void *buf16; |
92 | void *bdfe; |
72 | const void *cbuf16; |
93 | void *buf16; |
73 | }; |
94 | const void *cbuf16; |
74 | char p20; |
95 | }; |
75 | const char *p21; |
96 | char p20; |
76 | }ksys70_t; |
97 | const char *p21; |
77 | 98 | }ksys70_t; |
|
78 | 99 | ||
79 | typedef struct { |
100 | typedef struct { |
Line 80... | Line 101... | ||
80 | unsigned attributes; |
101 | uint32_t attributes; |
Line 107... | Line 128... | ||
107 | int clienty; //+58 |
128 | int clienty; //+58 |
108 | int clientwidth; //+62 |
129 | int clientwidth; //+62 |
109 | int clientheight; //+66 |
130 | int clientheight; //+66 |
110 | unsigned char window_state;//+70 |
131 | unsigned char window_state;//+70 |
111 | char reserved3[1024-71]; //+71 |
132 | char reserved3[1024-71]; //+71 |
112 | }ksys_proc_table_t; |
133 | }ksys_thread_t; |
Line 113... | Line 134... | ||
113 | 134 | ||
Line 114... | Line 135... | ||
114 | typedef unsigned int ksys_color_t; |
135 | typedef unsigned int ksys_color_t; |
115 | 136 | ||
Line 139... | Line 160... | ||
139 | }ksys_ipc_buffer; |
160 | }ksys_ipc_buffer; |
Line 140... | Line 161... | ||
140 | 161 | ||
141 | typedef struct { |
162 | typedef struct { |
142 | char* func_name; |
163 | char* func_name; |
143 | void* func_ptr; |
164 | void* func_ptr; |
Line 144... | Line 165... | ||
144 | }ksys_coff_etable_t; |
165 | }ksys_dll_t; |
Line 145... | Line 166... | ||
145 | 166 | ||
146 | typedef unsigned ksys_drv_hand_t; |
167 | typedef unsigned ksys_drv_hand_t; |
Line 152... | Line 173... | ||
152 | unsigned in_data_size; |
173 | unsigned in_data_size; |
153 | void* out_data_ptr; |
174 | void* out_data_ptr; |
154 | unsigned out_data_size; |
175 | unsigned out_data_size; |
155 | }ksys_ioctl_t; |
176 | }ksys_ioctl_t; |
Line -... | Line 177... | ||
- | 177 | ||
- | 178 | typedef struct{ |
|
- | 179 | char key[64]; |
|
- | 180 | char path[64]; |
|
- | 181 | }ksys_dir_key_t; |
|
156 | 182 | ||
Line -... | Line 183... | ||
- | 183 | #pragma pack(pop) |
|
- | 184 | ||
- | 185 | typedef rgb_t ksys_bitmap_t; |
|
- | 186 | ||
- | 187 | enum KSYS_FS_ERRORS { |
|
- | 188 | KSYS_FS_ERR_SUCCESS = 0, // Success |
|
- | 189 | KSYS_FS_ERR_1 = 1, // Base and/or partition of a hard disk is not defined (fn21.7 & fn21.8) |
|
- | 190 | KSYS_FS_ERR_2 = 2, // Function is not supported for the given file system |
|
- | 191 | KSYS_FS_ERR_3 = 3, // Unknown file system |
|
- | 192 | KSYS_FS_ERR_4 = 4, // Reserved, is never returned in the current implementation |
|
- | 193 | KSYS_FS_ERR_5 = 5, // File not found |
|
- | 194 | KSYS_FS_ERR_EOF = 6, // End of file, EOF |
|
- | 195 | KSYS_FS_ERR_7 = 7, // Pointer lies outside of application memory |
|
- | 196 | KSYS_FS_ERR_8 = 8, // Disk is full |
|
- | 197 | KSYS_FS_ERR_9 = 9, // FAT table is destroyed |
|
- | 198 | KSYS_FS_ERR_10 = 10, // Access denied |
|
- | 199 | KSYS_FS_ERR_11 = 11 // Device error |
|
157 | #pragma pack(pop) |
200 | }; |
158 | 201 | ||
159 | enum KSYS_EVENTS { |
202 | enum KSYS_EVENTS { |
160 | KSYS_EVENT_NONE = 0, /* Event queue is empty */ |
203 | KSYS_EVENT_NONE = 0, /* Event queue is empty */ |
161 | KSYS_EVENT_REDRAW = 1, /* Window and window elements should be redrawn */ |
204 | KSYS_EVENT_REDRAW = 1, /* Window and window elements should be redrawn */ |
Line 173... | Line 216... | ||
173 | KSYS_FILE_CP866 =1, |
216 | KSYS_FILE_CP866 =1, |
174 | KSYS_FILE_UTF16LE = 2, |
217 | KSYS_FILE_UTF16LE = 2, |
175 | KSYS_FILE_UTF8 = 3 |
218 | KSYS_FILE_UTF8 = 3 |
176 | }; |
219 | }; |
Line 177... | Line -... | ||
177 | - | ||
178 | enum KSYS_CLIP_ENCODING{ |
- | |
179 | KSYS_CLIP_UTF8 = 0, |
- | |
180 | KSYS_CLIP_CP866 = 1, |
- | |
181 | KSYS_CLIP_CP1251 = 2 |
- | |
182 | }; |
- | |
183 | - | ||
184 | enum KSYS_CLIP_TYPES{ |
- | |
185 | KSYS_CLIP_TEXT = 0, |
- | |
186 | KSYS_CLIP_IMAGE = 1, |
- | |
187 | KSYS_CLIP_RAW = 2 |
- | |
188 | }; |
- | |
189 | - | ||
190 | enum KSYS_MOUSE_POS{ |
- | |
191 | KSYS_MOUSE_SCREEN_POS = 0, |
- | |
192 | KSYS_MOUSE_WINDOW_POS = 1 |
- | |
193 | }; |
- | |
194 | - | ||
195 | enum KSYS_SHM_MODE{ |
- | |
196 | KSYS_SHM_OPEN = 0x00, |
- | |
197 | KSYS_SHM_OPEN_ALWAYS = 0x04, |
- | |
198 | KSYS_SHM_CREATE = 0x08, |
- | |
199 | KSYS_SHM_READ = 0x00, |
- | |
200 | KSYS_SHM_WRITE = 0x01, |
- | |
201 | }; |
- | |
202 | - | ||
203 | enum KSYS_EVENT_MASK{ |
- | |
204 | KSYS_EVM_REDRAW = 1, |
- | |
205 | KSYS_EVM_KEY = 2, |
- | |
206 | KSYS_EVM_BUTTON = 4, |
- | |
207 | KSYS_EVM_EXIT = 8, |
- | |
208 | KSYS_EVM_BACKGROUND = 16, |
- | |
209 | KSYS_EVM_MOUSE = 32, |
- | |
210 | KSYS_EVM_IPC = 64, |
- | |
211 | KSYS_EVM_STACK = 128, |
- | |
212 | KSYS_EVM_DEBUG = 256, |
- | |
213 | KSYS_EVM_STACK2 = 512, |
- | |
214 | KSYS_EVM_MOUSE_FILTER = 0x80000000, |
- | |
215 | KSYS_EVM_CURSOR_FILTER = 0x40000000, |
- | |
216 | }; |
- | |
217 | 220 | ||
218 | static inline |
221 | static inline |
219 | int _ksys_strcmp(const char * s1, const char * s2 ) |
222 | int _ksys_strcmp(const char * s1, const char * s2 ) |
220 | { |
223 | { |
221 | while ((*s1) && (*s1 == *s2)){ ++s1; ++s2; } |
224 | while ((*s1) && (*s1 == *s2)){ ++s1; ++s2; } |
222 | return(*(unsigned char*)s1 - *(unsigned char *)s2); |
225 | return(*(unsigned char*)s1 - *(unsigned char *)s2); |
Line -... | Line 226... | ||
- | 226 | } |
|
223 | } |
227 | |
- | 228 | /* ####################################################################### */ |
|
Line 224... | Line -... | ||
224 | - | ||
225 | // Functions for working with the graphical interface |
- | |
226 | 229 | /* ############### С wrappers for system calls Kolibri OS ################ */ |
|
227 | static inline |
230 | /* ####################################################################### */ |
228 | void _ksys_start_draw() |
- | |
Line 229... | Line 231... | ||
229 | { |
231 | |
230 | asm_inline("int $0x40"::"a"(12),"b"(1)); |
232 | |
231 | } |
- | |
232 | 233 | /*=============== Function -1 - terminate thread/process ===============*/ |
|
233 | static inline |
234 | |
Line -... | Line 235... | ||
- | 235 | static inline |
|
- | 236 | void _ksys_exit(){ |
|
234 | void _ksys_end_draw() |
237 | asm_inline("int $0x40"::"a"(-1)); |
235 | { |
238 | } |
236 | asm_inline("int $0x40" ::"a"(12),"b"(2)); |
- | |
237 | } |
239 | |
238 | 240 | /*============== Function 0 - define and draw the window. ==============*/ |
|
239 | static inline |
241 | |
240 | void _ksys_create_window(int x, int y, int w, int h, const char *name, ksys_color_t workcolor, unsigned style) |
242 | static inline |
241 | { |
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) { |
Line 249... | Line 251... | ||
249 | "S"(0) |
251 | "S"(0) |
250 | :"memory" |
252 | :"memory" |
251 | ); |
253 | ); |
252 | }; |
254 | }; |
Line -... | Line 255... | ||
- | 255 | ||
- | 256 | /*================ Function 1 - put pixel in the window. ===============*/ |
|
253 | 257 | ||
254 | static inline |
258 | static inline |
255 | void _ksys_change_window(int new_x, int new_y, int new_w, int new_h) |
- | |
256 | { |
259 | void _ksys_draw_pixel(uint32_t x, uint32_t y, ksys_color_t color){ |
257 | asm_inline( |
260 | asm_inline( |
258 | "int $0x40" |
261 | "int $0x40" |
259 | ::"a"(67), "b"(new_x), "c"(new_y), "d"(new_w),"S"(new_h) |
262 | ::"a"(1), "b"(x), "c"(y), "d"(color) |
260 | ); |
263 | ); |
Line -... | Line 264... | ||
- | 264 | } |
|
- | 265 | ||
261 | } |
266 | /*============ Function 2 - get the code of the pressed key. ===========*/ |
- | 267 | ||
- | 268 | static inline |
|
- | 269 | ksys_oskey_t _ksys_get_key(void){ |
|
- | 270 | ksys_oskey_t val; |
|
- | 271 | asm_inline( |
|
- | 272 | "int $0x40" |
|
- | 273 | :"=a"(val) |
|
- | 274 | :"a"(2) |
|
- | 275 | ); |
|
- | 276 | return val; |
|
- | 277 | } |
|
- | 278 | ||
- | 279 | /*==================== Function 3 - get system time. ===================*/ |
|
- | 280 | ||
- | 281 | static inline |
|
- | 282 | ksys_time_t _ksys_get_time(){ |
|
- | 283 | ksys_time_t c_time; |
|
- | 284 | asm_inline( |
|
- | 285 | "int $0x40" |
|
- | 286 | :"=a"(c_time) |
|
- | 287 | :"a"(3) |
|
- | 288 | :"memory" |
|
- | 289 | ); |
|
- | 290 | return c_time; |
|
- | 291 | } |
|
- | 292 | ||
- | 293 | /*=================== Function 4 - draw text string. ===================*/ |
|
262 | 294 | ||
- | 295 | static inline |
|
- | 296 | void _ksys_draw_text(const char *text, uint32_t x, uint32_t y, uint32_t len, ksys_color_t color) { |
|
- | 297 | asm_inline( |
|
- | 298 | "int $0x40" |
|
- | 299 | ::"a"(4),"d"(text), |
|
- | 300 | "b"((x << 16) | y), |
|
- | 301 | "S"(len),"c"(color) |
|
- | 302 | :"memory" |
|
- | 303 | ); |
|
- | 304 | } |
|
- | 305 | ||
- | 306 | /*========================= Function 5 - delay. ========================*/ |
|
- | 307 | ||
- | 308 | static inline |
|
- | 309 | void _ksys_delay(uint32_t time){ |
|
- | 310 | asm_inline( |
|
- | 311 | "int $0x40" |
|
- | 312 | ::"a"(5), "b"(time) |
|
263 | static inline |
313 | :"memory" |
- | 314 | ); |
|
- | 315 | } |
|
- | 316 | ||
- | 317 | /*=============== Function 8 - define/delete the button. ===============*/ |
|
- | 318 | ||
264 | void _ksys_define_button(unsigned x, unsigned y, unsigned w, unsigned h, unsigned id, ksys_color_t color) |
319 | static inline |
265 | { |
320 | void _ksys_define_button(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t id, ksys_color_t color) { |
266 | asm_inline( |
321 | asm_inline( |
267 | "int $0x40" |
322 | "int $0x40" |
268 | ::"a"(8), |
323 | ::"a"(8), |
Line 272... | Line 327... | ||
272 | "S"(color) |
327 | "S"(color) |
273 | ); |
328 | ); |
274 | }; |
329 | }; |
Line 275... | Line 330... | ||
275 | 330 | ||
276 | static inline |
331 | static inline |
277 | void _ksys_draw_line(int xs, int ys, int xe, int ye, ksys_color_t color) |
- | |
278 | { |
332 | void _ksys_delete_button(uint32_t id){ |
279 | asm_inline( |
333 | asm_inline( |
280 | "int $0x40" |
334 | "int $0x40" |
281 | ::"a"(38), "d"(color), |
- | |
282 | "b"((xs << 16) | xe), |
- | |
283 | "c"((ys << 16) | ye) |
335 | ::"a"(8),"d"(id & 0x00FFFFFF | 0x80000000) |
284 | ); |
336 | ); |
Line -... | Line 337... | ||
- | 337 | } |
|
- | 338 | ||
285 | } |
339 | /*============ Function 9 - information on execution thread. ===========*/ |
286 | 340 | ||
- | 341 | static inline |
|
- | 342 | int _ksys_thread_info(ksys_thread_t* table, int slot){ |
|
- | 343 | int val; |
|
- | 344 | asm_inline( |
|
- | 345 | "int $0x40" |
|
- | 346 | :"=a"(val) |
|
- | 347 | :"a"(9), "b"(table), "c"(slot) |
|
- | 348 | :"memory" |
|
- | 349 | ); |
|
- | 350 | return val; |
|
- | 351 | } |
|
- | 352 | ||
- | 353 | /*==================== Function 10 - wait for event. ===================*/ |
|
- | 354 | ||
- | 355 | static inline |
|
- | 356 | uint32_t _ksys_wait_event(void){ |
|
- | 357 | uint32_t val; |
|
- | 358 | asm_inline( |
|
- | 359 | "int $0x40" |
|
- | 360 | :"=a"(val) |
|
- | 361 | :"a"(10) |
|
- | 362 | ); |
|
- | 363 | return val; |
|
- | 364 | } |
|
- | 365 | ||
- | 366 | /*=============== Function 11 - check for event, no wait. ==============*/ |
|
- | 367 | ||
- | 368 | static inline |
|
- | 369 | uint32_t _ksys_check_event(void){ |
|
- | 370 | uint32_t val; |
|
- | 371 | asm_inline( |
|
- | 372 | "int $0x40" |
|
- | 373 | :"=a"(val) |
|
- | 374 | :"a"(11) |
|
- | 375 | ); |
|
- | 376 | return val; |
|
- | 377 | } |
|
- | 378 | ||
- | 379 | /*=============== Function 12 - begin/end window redraw. ===============*/ |
|
- | 380 | ||
- | 381 | static inline |
|
- | 382 | void _ksys_start_draw(){ |
|
- | 383 | asm_inline("int $0x40"::"a"(12),"b"(1)); |
|
- | 384 | } |
|
- | 385 | ||
- | 386 | static inline |
|
287 | static inline |
387 | void _ksys_end_draw(){ |
- | 388 | asm_inline("int $0x40" ::"a"(12),"b"(2)); |
|
- | 389 | } |
|
- | 390 | ||
- | 391 | /*============ Function 13 - draw a rectangle in the window. ===========*/ |
|
- | 392 | ||
288 | void _ksys_draw_bar(int x, int y, int w, int h, ksys_color_t color) |
393 | static inline |
289 | { |
394 | void _ksys_draw_bar(uint32_t x, uint32_t y, uint32_t w, uint32_t h, ksys_color_t color){ |
290 | asm_inline( |
395 | asm_inline( |
291 | "int $0x40" |
396 | "int $0x40" |
292 | ::"a"(13), "d"(color), |
397 | ::"a"(13), "d"(color), |
293 | "b"((x << 16) | w), |
398 | "b"((x << 16) | w), |
294 | "c"((y << 16) | h) |
399 | "c"((y << 16) | h) |
Line -... | Line 400... | ||
- | 400 | ); |
|
- | 401 | } |
|
295 | ); |
402 | |
296 | } |
403 | /*=================== Function 14 - get screen size. ===================*/ |
297 | 404 | ||
- | 405 | static inline |
|
298 | static inline |
406 | ksys_pos_t _ksys_screen_size(){ |
299 | void _ksys_draw_bitmap(void *bitmap, int x, int y, int w, int h) |
407 | ksys_pos_t size; |
300 | { |
408 | ksys_pos_t size_tmp; |
301 | asm_inline( |
- | |
302 | "int $0x40" |
- | |
303 | ::"a"(7), "b"(bitmap), |
409 | asm_inline( |
304 | "c"((w << 16) | h), |
410 | "int $0x40" |
- | 411 | :"=a"(size_tmp) |
|
- | 412 | :"a"(14) |
|
- | 413 | ); |
|
305 | "d"((x << 16) | y) |
414 | size.x = size_tmp.y; |
Line -... | Line 415... | ||
- | 415 | size.y = size_tmp.x; |
|
- | 416 | return size; |
|
306 | :"memory" |
417 | } |
- | 418 | ||
- | 419 | /*== Function 15, subfunction 1 - set a size of the background image. ==*/ |
|
- | 420 | ||
- | 421 | static inline |
|
- | 422 | void _ksys_bg_set_size(uint32_t w, uint32_t h){ |
|
- | 423 | asm_inline( |
|
- | 424 | "int $0x40" |
|
- | 425 | ::"a"(15), "b"(1), "c"(w), "d"(h) |
|
- | 426 | ); |
|
- | 427 | } |
|
307 | ); |
428 | |
- | 429 | /*=== Function 15, subfunction 2 - put pixel on the background image. ==*/ |
|
- | 430 | ||
- | 431 | static inline |
|
- | 432 | void _ksys_bg_put_pixel(uint32_t x, uint32_t y, uint32_t w, ksys_color_t color){ |
|
- | 433 | asm_inline( |
|
- | 434 | "int $0x40" |
|
- | 435 | ::"a"(15), "b"(2), "c"((x+y*w)*3), "d"(color) |
|
- | 436 | ); |
|
- | 437 | } |
|
- | 438 | ||
- | 439 | /*=========== Function 15, subfunction 3 - redraw background. ==========*/ |
|
- | 440 | ||
- | 441 | static inline |
|
- | 442 | void _ksys_bg_redraw(void){ |
|
- | 443 | asm_inline( |
|
- | 444 | "int $0x40" |
|
- | 445 | ::"a"(15), "b"(3) |
|
- | 446 | ); |
|
- | 447 | } |
|
- | 448 | ||
- | 449 | /*== Function 15, subfunction 4 - set drawing mode for the background. =*/ |
|
- | 450 | ||
- | 451 | enum KSYS_BG_MODES{ |
|
- | 452 | KSYS_BG_MODE_PAVE=1, |
|
- | 453 | KSYS_BG_MODE_STRETCH=2 |
|
- | 454 | }; |
|
- | 455 | ||
- | 456 | static inline |
|
- | 457 | void _ksys_bg_set_mode(uint32_t mode){ |
|
- | 458 | asm_inline( |
|
- | 459 | "int $0x40" |
|
- | 460 | ::"a"(15), "b"(4), "c"(mode) |
|
- | 461 | ); |
|
- | 462 | } |
|
- | 463 | ||
- | 464 | /*===================== Function 15, subfunction 5 =====================*/ |
|
- | 465 | /*============ Put block of pixels on the background image. ============*/ |
|
- | 466 | ||
- | 467 | static inline |
|
- | 468 | void _ksys_bg_put_bitmap(ksys_bitmap_t* bitmap, size_t bitmap_size, uint32_t x, uint32_t y, uint32_t w){ |
|
- | 469 | asm_inline( |
|
- | 470 | "int $0x40" |
|
- | 471 | ::"a"(15), "b"(5), "c"(bitmap), "d"((x+y*w)*3), "S"(bitmap_size) |
|
- | 472 | ); |
|
- | 473 | } |
|
- | 474 | ||
- | 475 | /*===================== Function 15, subfunction 6 =====================*/ |
|
308 | } |
476 | /*======= Map background data to the address space of process. ==========*/ |
- | 477 | ||
309 | 478 | static inline |
|
310 | static inline |
479 | ksys_bitmap_t* _ksys_bg_get_map() |
311 | void _ksys_draw_text(const char *text, int x, int y, int len, ksys_color_t color) |
480 | { |
312 | { |
- | |
313 | asm_inline( |
481 | ksys_bitmap_t *bitmap; |
314 | "int $0x40" |
- | |
315 | ::"a"(4),"d"(text), |
482 | asm_inline( |
- | 483 | "int $0x40" |
|
316 | "b"((x << 16) | y), |
484 | :"=a"(bitmap) |
Line -... | Line 485... | ||
- | 485 | :"a"(15), "b"(6) |
|
- | 486 | ); |
|
317 | "S"(len),"c"(color) |
487 | return bitmap; |
318 | :"memory" |
488 | } |
319 | ); |
489 | |
- | 490 | /*===== Function 15, subfunction 7 - close mapped background data. =====*/ |
|
320 | } |
491 | |
321 | 492 | static inline |
|
322 | static inline |
493 | int _ksys_bg_close_map(ksys_bitmap_t* bitmap) |
323 | void _ksys_draw_text_bg(const char *text, int x, int y, int len, ksys_color_t color, ksys_color_t bg) |
- | |
324 | { |
494 | { |
325 | asm_inline( |
- | |
326 | "int $0x40" |
495 | int status; // 1 - OK, 0 - ERROR |
- | 496 | asm_inline( |
|
327 | ::"a"(4),"d"(text), |
497 | "int $0x40" |
Line -... | Line 498... | ||
- | 498 | :"=a"(status) |
|
- | 499 | :"a"(15), "b"(7), "c"(bitmap) |
|
- | 500 | ); |
|
328 | "b"((x << 16) | y), |
501 | return status; |
329 | "S"(len),"c"(color), "D"(bg) |
502 | } |
330 | :"memory" |
503 | |
331 | ); |
- | |
332 | } |
504 | /*===================== Function 15, subfunction 9 =====================*/ |
333 | 505 | /*============= Redraws a rectangular part of the background ===========*/ |
|
- | 506 | ||
- | 507 | static inline |
|
334 | static inline |
508 | void _ksys_bg_redraw_bar(ksys_pos_t angle1, ksys_pos_t angle2) |
335 | void _ksys_draw_number(int number, int x, int y, int len, ksys_color_t color){ |
509 | { |
336 | unsigned fmt; |
510 | asm_inline( |
Line -... | Line 511... | ||
- | 511 | "int $0x40" |
|
- | 512 | ::"a"(15), "b"(9), |
|
337 | fmt = len << 16 | 0x80000000; // no leading zeros + width |
513 | "c"(angle1.x*(1<<16)+angle2.x), |
338 | asm_inline( |
514 | "d"(angle1.y*(1<<16)+angle2.y) |
339 | "int $0x40" |
515 | ); |
340 | ::"a"(47), "b"(fmt), "c"(number), "d"((x << 16) | y), "S"(color) |
516 | } |
341 | ); |
517 | |
342 | } |
518 | /*=============== Function 16 - save ramdisk on a floppy. ==============*/ |
- | 519 | ||
343 | 520 | static inline |
|
344 | static inline |
521 | int _ksys_save_ramdisk_fd(uint32_t floppy_id) |
- | 522 | { |
|
345 | void _ksys_draw_number_bg(unsigned number, int x, int y, int len, ksys_color_t color, ksys_color_t bg){ |
523 | int status; // 0 - OK, 1 - ERROR |
Line -... | Line 524... | ||
- | 524 | asm_inline( |
|
- | 525 | "int $0x40" |
|
346 | unsigned fmt; |
526 | :"=a"(status) |
347 | fmt = len << 16 | 0x80000000; // no leading zeros + width |
527 | :"a"(16), "b"(floppy_id) |
348 | asm_inline( |
528 | ); |
349 | "int $0x40" |
529 | return status; |
350 | ::"a"(47), "b"(fmt), "c"(number), "d"((x << 16) | y), "S"(color), "D"(bg) |
530 | } |
351 | ); |
531 | |
352 | } |
532 | /*======= Function 17 - get the identifier of the pressed button. ======*/ |
353 | 533 | ||
354 | static inline |
534 | static inline |
355 | unsigned _ksys_get_skin_height() |
535 | uint32_t _ksys_get_button() |
356 | { |
536 | { |
Line -... | Line 537... | ||
- | 537 | unsigned val; |
|
- | 538 | asm_inline( |
|
- | 539 | "int $0x40" |
|
357 | unsigned height; |
540 | :"=a"(val) |
358 | asm_inline( |
541 | :"a"(17) |
359 | "int $0x40 \n\t" |
542 | ); |
360 | :"=a"(height) |
543 | return val>>8; |
361 | :"a"(48),"b"(4) |
544 | } |
362 | ); |
545 | |
363 | return height; |
546 | /*===================== Function 18, subfunction 1 =====================*/ |
364 | } |
547 | /*============= Make deactive the window of the given thread. ==========*/ |
Line 365... | Line 548... | ||
365 | 548 | ||
Line 366... | Line 549... | ||
366 | static inline |
549 | static inline |
367 | void _ksys_get_system_colors(ksys_colors_table_t *color_table) |
550 | void _ksys_unfocus_window(int slot) |
368 | { |
551 | { |
369 | asm_inline( |
- | |
370 | "int $0x40" |
- | |
371 | ::"a"(48),"b"(3),"c"(color_table),"d"(40) |
552 | asm_inline( |
372 | ); |
553 | "int $0x40" |
- | 554 | ::"a"(18), "b"(1), "c"(slot) |
|
- | 555 | ); |
|
- | 556 | } |
|
- | 557 | ||
- | 558 | /*= Function 18, subfunction 2 - terminate process/thread by the slot. =*/ |
|
- | 559 | ||
- | 560 | static inline |
|
- | 561 | void _ksys_kill_by_slot(int slot) |
|
- | 562 | { |
|
- | 563 | asm_inline( |
|
- | 564 | "int $0x40" |
|
- | 565 | ::"a"(18), "b"(2), "c"(slot) |
|
- | 566 | ); |
|
- | 567 | } |
|
- | 568 | ||
- | 569 | /*===================== Function 18, subfunction 3 =====================*/ |
|
- | 570 | /*============= Make active the window of the given thread. ============*/ |
|
- | 571 | ||
- | 572 | static inline |
|
- | 573 | void _ksys_focus_window(int slot){ |
|
- | 574 | asm_inline( |
|
- | 575 | "int $0x40" |
|
- | 576 | ::"a"(18), "b"(3), "c"(slot) |
|
373 | } |
577 | ); |
- | 578 | } |
|
- | 579 | ||
- | 580 | /*===================== Function 18, subfunction 4 =====================*/ |
|
- | 581 | /*=========== Get counter of idle time units per one second. ===========*/ |
|
- | 582 | ||
- | 583 | static inline |
|
- | 584 | uint32_t _ksys_get_idle(void){ |
|
- | 585 | uint32_t sec; |
|
- | 586 | asm_inline( |
|
- | 587 | "int $0x40" |
|
- | 588 | :"=a"(sec) |
|
- | 589 | :"a"(18), "b"(4) |
|
- | 590 | ); |
|
- | 591 | return sec; |
|
- | 592 | } |
|
- | 593 | ||
- | 594 | /*========== Function 18, subfunction 5 - get CPU clock rate. ==========*/ |
|
- | 595 | /*================ modulo 2^32 clock ticks = 4GHz ======================*/ |
|
- | 596 | ||
- | 597 | static inline |
|
- | 598 | uint32_t _ksys_get_cpu_clock(void){ |
|
- | 599 | uint32_t clock; |
|
- | 600 | asm_inline( |
|
- | 601 | "int $0x40" |
|
- | 602 | :"=a"(clock) |
|
- | 603 | :"a"(18), "b"(5) |
|
- | 604 | ); |
|
- | 605 | return clock; |
|
- | 606 | } |
|
- | 607 | ||
- | 608 | /* Function 18, subfunction 6 - save ramdisk to the file on hard drive. */ |
|
- | 609 | ||
- | 610 | static inline |
|
- | 611 | uint32_t _ksys_save_ramdisk_hd(const char* ramdisk_path){ |
|
- | 612 | uint32_t fs_err; |
|
- | 613 | asm_inline( |
|
- | 614 | "int $0x40" |
|
- | 615 | :"=a"(fs_err) |
|
- | 616 | :"a"(18), "b"(6), "c"(ramdisk_path) |
|
- | 617 | ); |
|
- | 618 | return fs_err; |
|
- | 619 | } |
|
- | 620 | ||
- | 621 | /* Function 18, subfunction 9 - system shutdown with the parameter. */ |
|
- | 622 | ||
- | 623 | enum KSYS_SHD_PARAM { |
|
- | 624 | KSYS_SHD_POWEROFF = 2, |
|
- | 625 | KSYS_SHD_REBOOT = 3, |
|
- | 626 | KSYS_SHD_RESTART_KRN = 4 |
|
- | 627 | }; |
|
- | 628 | ||
- | 629 | static inline |
|
- | 630 | void _ksys_shutdown(uint32_t shd_param){ |
|
- | 631 | asm_inline( |
|
- | 632 | "int $0x40" |
|
374 | 633 | ::"a"(18), "b"(9), "c"(shd_param) |
|
- | 634 | ); |
|
375 | /* Functions for working with a screen. */ |
635 | } |
376 | - | ||
377 | static inline |
- | |
378 | ksys_pos_t _ksys_screen_size() |
636 | |
379 | { |
637 | /*========= Function 18, subfunction 16 - get size of free RAM. ========*/ |
Line -... | Line 638... | ||
- | 638 | ||
- | 639 | static inline |
|
- | 640 | size_t _ksys_get_ram_size(void){ |
|
- | 641 | size_t size; |
|
- | 642 | asm_inline( |
|
- | 643 | "int $0x40" |
|
- | 644 | :"=a"(size) |
|
- | 645 | :"a"(18), "b"(16) |
|
- | 646 | ); |
|
- | 647 | return size; |
|
- | 648 | } |
|
- | 649 | ||
Line 380... | Line 650... | ||
380 | ksys_pos_t size; |
650 | /*======== Function 18, subfunction 17 - get full amount of RAM. =======*/ |
- | 651 | ||
Line 381... | Line 652... | ||
381 | ksys_pos_t size_tmp; |
652 | static inline |
382 | asm_inline( |
653 | size_t _ksys_get_full_ram(void){ |
383 | "int $0x40" |
654 | size_t size; |
- | 655 | asm_inline( |
|
- | 656 | "int $0x40" |
|
- | 657 | :"=a"(size) |
|
- | 658 | :"a"(18), "b"(17) |
|
- | 659 | ); |
|
- | 660 | return size; |
|
- | 661 | } |
|
- | 662 | ||
- | 663 | /*===================== Function 18, subfunction 18 ====================*/ |
|
- | 664 | /*============= Terminate process/thread by the identifier. ============*/ |
|
- | 665 | ||
- | 666 | static inline |
|
- | 667 | void _ksys_kill_by_pid(uint32_t PID) |
|
- | 668 | { |
|
- | 669 | asm_inline( |
|
- | 670 | "int $0x40" |
|
- | 671 | ::"a"(18), "b"(18), "c"(PID) |
|
- | 672 | ); |
|
- | 673 | } |
|
- | 674 | ||
- | 675 | ||
- | 676 | static inline |
|
- | 677 | int _ksys_get_thread_slot(int PID){ |
|
- | 678 | int val; |
|
- | 679 | asm_inline( |
|
- | 680 | "int $0x40" |
|
- | 681 | :"=a"(val) |
|
- | 682 | :"a"(18), "b"(21), "c"(PID) |
|
- | 683 | ); |
|
- | 684 | return val; |
|
- | 685 | } |
|
- | 686 | ||
- | 687 | /*============= Function 23 - wait for event with timeout. =============*/ |
|
- | 688 | ||
- | 689 | static inline |
|
- | 690 | uint32_t _ksys_wait_event_timeout(uint32_t timeout){ |
|
- | 691 | unsigned val; |
|
- | 692 | asm_inline( |
|
- | 693 | "int $0x40" |
|
- | 694 | :"=a"(val) |
|
- | 695 | :"a"(23), "b"(timeout) |
|
- | 696 | ); |
|
- | 697 | return val; |
|
- | 698 | } |
|
- | 699 | ||
- | 700 | /*=== Function 26, subfunction 9 - get the value of the time counter. ==*/ |
|
- | 701 | ||
- | 702 | static inline |
|
- | 703 | uint32_t _ksys_get_tick_count(){ |
|
- | 704 | unsigned val; |
|
- | 705 | asm_inline( |
|
- | 706 | "int $0x40" |
|
- | 707 | :"=a"(val) |
|
- | 708 | :"a"(26),"b"(9) |
|
- | 709 | ); |
|
- | 710 | return val; |
|
- | 711 | } |
|
- | 712 | ||
- | 713 | /*===================== Function 26, subfunction 10 ====================*/ |
|
- | 714 | /*========== Get the value of the high precision time counter. =========*/ |
|
- | 715 | ||
- | 716 | static inline |
|
- | 717 | uint64_t _ksys_get_ns_count(){ |
|
- | 718 | uint64_t val; |
|
- | 719 | asm_inline( |
|
- | 720 | "int $0x40" |
|
- | 721 | :"=A"(val) |
|
- | 722 | :"a"(26), "b"(10) |
|
- | 723 | ); |
|
- | 724 | return val; |
|
- | 725 | } |
|
- | 726 | ||
- | 727 | /*=================== Function 29 - get system date. ===================*/ |
|
- | 728 | ||
- | 729 | static inline |
|
- | 730 | ksys_date_t _ksys_get_date(){ |
|
- | 731 | ksys_date_t val; |
|
- | 732 | asm_inline("int $0x40":"=a"(val):"a"(29)); |
|
- | 733 | return val; |
|
- | 734 | } |
|
- | 735 | ||
- | 736 | /*===========+ Function 30 - work with the current folder.==============*/ |
|
- | 737 | /*--------- Subfunction 1 - set current folder for the thread. ---------*/ |
|
- | 738 | ||
- | 739 | static inline |
|
- | 740 | void _ksys_setcwd(char* dir){ |
|
- | 741 | asm_inline( |
|
- | 742 | "int $0x40" |
|
- | 743 | ::"a"(30), "b"(1), "c"(dir) |
|
- | 744 | ); |
|
- | 745 | } |
|
- | 746 | ||
- | 747 | /*--------- Subfunction 2 - get current folder for the thread. ---------*/ |
|
- | 748 | ||
- | 749 | static inline |
|
- | 750 | int _ksys_getcwd(char* buf, int bufsize){ |
|
- | 751 | register int val; |
|
- | 752 | asm_inline( |
|
- | 753 | "int $0x40" |
|
- | 754 | :"=a"(val):"a"(30), "b"(2), "c"(buf), "d"(bufsize) |
|
- | 755 | ); |
|
- | 756 | return val; |
|
- | 757 | } |
|
- | 758 | ||
- | 759 | /* ---- Subfunction 3 - install the add.system directory for the kernel ------*/ |
|
- | 760 | ||
- | 761 | static inline |
|
- | 762 | int _ksys_set_kernel_dir(ksys_dir_key_t *table){ |
|
- | 763 | register int val; |
|
- | 764 | asm_inline( |
|
- | 765 | "int $0x40" |
|
- | 766 | :"=a"(val) |
|
- | 767 | :"a"(30), "b"(3), "c"(table) |
|
384 | :"=a"(size_tmp) |
768 | :"memory" |
385 | :"a"(14) |
769 | ); |
386 | ); |
770 | return val; |
387 | size.x = size_tmp.y; |
771 | } |
388 | size.y = size_tmp.x; |
772 | |
Line 404... | Line 788... | ||
404 | ); |
788 | ); |
405 | return pos; |
789 | return pos; |
406 | } |
790 | } |
Line 407... | Line 791... | ||
407 | 791 | ||
408 | static inline |
792 | static inline |
409 | unsigned _ksys_get_mouse_buttons() |
- | |
410 | { |
793 | uint32_t _ksys_get_mouse_buttons(void){ // subfunction 2 - states of the mouse buttons |
411 | unsigned val; |
794 | uint32_t val; |
412 | asm_inline( |
795 | asm_inline( |
413 | "int $0x40" |
796 | "int $0x40" |
414 | :"=a"(val) |
797 | :"=a"(val) |
415 | :"a"(37),"b"(2) |
798 | :"a"(37),"b"(2) |
416 | ); |
799 | ); |
417 | return val; |
800 | return val; |
Line 418... | Line 801... | ||
418 | } |
801 | } |
419 | 802 | ||
420 | static inline |
- | |
421 | unsigned _ksys_get_mouse_wheels() |
803 | static inline |
422 | { |
804 | uint32_t _ksys_get_mouse_eventstate(void){ // subfunction 3 - states and events of the mouse buttons |
423 | unsigned val; |
805 | uint32_t val; |
424 | asm_inline( |
806 | asm_inline( |
425 | "int $0x40 \n\t" |
807 | "int $0x40" |
426 | :"=a"(val) |
808 | :"=a"(val) |
427 | :"a"(37),"b"(7) |
809 | :"a"(37),"b"(3) |
428 | ); |
810 | ); |
Line 429... | Line 811... | ||
429 | return val; |
811 | return val; |
430 | } |
812 | } |
431 | - | ||
432 | static inline |
813 | |
433 | unsigned _ksys_load_cursor(void *path, unsigned flags) |
814 | static inline |
434 | { |
815 | uint32_t _ksys_load_cursor(void *path, uint32_t flags) { // subfunction 4 - load cursor |
435 | unsigned val; |
816 | uint32_t val; |
436 | asm_inline( |
817 | asm_inline( |
437 | "int $0x40" |
818 | "int $0x40" |
438 | :"=a"(val) |
819 | :"=a"(val) |
439 | :"a"(37), "b"(4), "c"(path), "d"(flags) |
820 | :"a"(37), "b"(4), "c"(path), "d"(flags) |
440 | :"memory" |
821 | :"memory" |
Line 441... | Line 822... | ||
441 | ); |
822 | ); |
442 | return val; |
823 | return val; |
443 | } |
- | |
444 | 824 | } |
|
445 | static inline |
825 | |
446 | unsigned _ksys_set_cursor(unsigned cursor) |
826 | static inline |
447 | { |
827 | uint32_t _ksys_set_cursor(uint32_t cursor){ // subfunction 5 - set curso |
448 | unsigned old; |
828 | uint32_t old; |
449 | asm_inline( |
829 | asm_inline( |
450 | "int $0x40" |
830 | "int $0x40" |
451 | :"=a"(old) |
831 | :"=a"(old) |
Line 452... | Line 832... | ||
452 | :"a"(37), "b"(5), "c"(cursor) |
832 | :"a"(37), "b"(5), "c"(cursor) |
453 | ); |
833 | ); |
454 | return old; |
- | |
455 | } |
834 | return old; |
456 | 835 | } |
|
457 | static inline |
836 | |
458 | int _ksys_destroy_cursor(unsigned cursor) |
837 | static inline |
459 | { |
838 | int _ksys_delete_cursor(uint32_t cursor){ // subfunction 6 - delete curso |
Line 466... | Line 845... | ||
466 | ); |
845 | ); |
467 | return ret; |
846 | return ret; |
468 | } |
847 | } |
Line 469... | Line 848... | ||
469 | 848 | ||
470 | static inline |
849 | static inline |
471 | unsigned _ksys_get_mouse_eventstate() |
850 | uint32_t _ksys_get_mouse_wheels(void) // subfunction 7 - get scroll data |
472 | { |
851 | { |
473 | unsigned val; |
852 | uint32_t val; |
474 | asm_inline( |
853 | asm_inline( |
475 | "int $0x40" |
854 | "int $0x40" |
476 | :"=a"(val) |
855 | :"=a"(val) |
477 | :"a"(37),"b"(3) |
856 | :"a"(37),"b"(7) |
478 | ); |
857 | ); |
479 | return val; |
858 | return val; |
Line -... | Line 859... | ||
- | 859 | } |
|
Line -... | Line 860... | ||
- | 860 | ||
- | 861 | /*=========== Function 40 - set the mask for expected events. ==========*/ |
|
- | 862 | ||
- | 863 | enum KSYS_EVENT_MASK{ |
|
- | 864 | KSYS_EVM_REDRAW = 1, |
|
- | 865 | KSYS_EVM_KEY = 2, |
|
- | 866 | KSYS_EVM_BUTTON = 4, |
|
- | 867 | KSYS_EVM_EXIT = 8, |
|
- | 868 | KSYS_EVM_BACKGROUND = 16, |
|
- | 869 | KSYS_EVM_MOUSE = 32, |
|
- | 870 | KSYS_EVM_IPC = 64, |
|
- | 871 | KSYS_EVM_STACK = 128, |
|
480 | } |
872 | KSYS_EVM_DEBUG = 256, |
- | 873 | KSYS_EVM_STACK2 = 512, |
|
Line 481... | Line 874... | ||
481 | 874 | KSYS_EVM_MOUSE_FILTER = 0x80000000, |
|
482 | 875 | KSYS_EVM_CURSOR_FILTER = 0x40000000, |
|
483 | /* Functions for working with events and buttons. */ |
- | |
484 | 876 | }; |
|
485 | static inline |
877 | |
486 | unsigned _ksys_set_event_mask(unsigned mask) |
878 | static inline |
487 | { |
879 | uint32_t _ksys_set_event_mask(uint32_t mask){ |
488 | unsigned val; |
880 | unsigned val; |
489 | asm_inline( |
881 | asm_inline( |
490 | "int $0x40" |
882 | "int $0x40" |
491 | :"=a"(val) |
883 | :"=a"(val) |
Line -... | Line 884... | ||
- | 884 | :"a"(40), "b"(mask) |
|
- | 885 | ); |
|
492 | :"a"(40), "b"(mask) |
886 | return val; |
493 | ); |
887 | } |
494 | return val; |
888 | |
495 | } |
- | |
496 | 889 | /*====================== Function 38 - draw line. ======================*/ |
|
497 | static inline |
890 | |
498 | unsigned _ksys_wait_event(unsigned time) |
891 | static inline |
- | 892 | void _ksys_draw_line(int xs, int ys, int xe, int ye, ksys_color_t color) |
|
499 | { |
893 | { |
500 | unsigned val; |
894 | asm_inline( |
501 | asm_inline( |
- | |
502 | "int $0x40" |
895 | "int $0x40" |
Line -... | Line 896... | ||
- | 896 | ::"a"(38), "d"(color), |
|
- | 897 | "b"((xs << 16) | xe), |
|
503 | :"=a"(val) |
898 | "c"((ys << 16) | ye) |
504 | :"a"(23), "b"(time) |
899 | ); |
505 | ); |
- | |
506 | return val; |
900 | } |
- | 901 | ||
507 | } |
902 | /*============= Function 47 - draw a number in the window. =============*/ |
508 | 903 | ||
509 | static inline |
904 | static inline |
510 | unsigned _ksys_check_event() |
- | |
511 | { |
905 | void _ksys_draw_number(int number, int x, int y, int len, ksys_color_t color){ |
512 | unsigned val; |
- | |
513 | asm_inline( |
906 | unsigned fmt; |
Line 514... | Line 907... | ||
514 | "int $0x40" |
907 | fmt = len << 16 | 0x80000000; // no leading zeros + width |
515 | :"=a"(val) |
908 | asm_inline( |
516 | :"a"(11) |
- | |
517 | ); |
909 | "int $0x40" |
- | 910 | ::"a"(47), "b"(fmt), "c"(number), "d"((x << 16) | y), "S"(color) |
|
518 | return val; |
911 | ); |
519 | } |
912 | } |
520 | 913 | ||
521 | static inline |
- | |
522 | unsigned _ksys_get_event() |
914 | static inline |
523 | { |
- | |
524 | unsigned val; |
915 | void _ksys_draw_number_bg(unsigned number, int x, int y, int len, ksys_color_t color, ksys_color_t bg){ |
Line -... | Line 916... | ||
- | 916 | unsigned fmt; |
|
- | 917 | fmt = len << 16 | 0x80000000; // no leading zeros + width |
|
525 | asm_inline( |
918 | asm_inline( |
526 | "int $0x40" |
919 | "int $0x40" |
527 | :"=a"(val) |
920 | ::"a"(47), "b"(fmt), "c"(number), "d"((x << 16) | y), "S"(color), "D"(bg) |
528 | :"a"(10) |
- | |
529 | ); |
921 | ); |
530 | return val; |
922 | } |
531 | } |
923 | |
532 | - | ||
533 | static inline |
924 | /*====== Function 48, subfunction 3 - get standard window colors. ======*/ |
534 | unsigned _ksys_get_button() |
- | |
535 | { |
925 | |
Line -... | Line 926... | ||
- | 926 | static inline |
|
- | 927 | void _ksys_get_system_colors(ksys_colors_table_t *color_table) |
|
536 | unsigned val; |
928 | { |
537 | asm_inline( |
929 | asm_inline( |
- | 930 | "int $0x40" |
|
- | 931 | ::"a"(48),"b"(3),"c"(color_table),"d"(40) |
|
- | 932 | ); |
|
- | 933 | } |
|
- | 934 | ||
- | 935 | /*============ Function 48, subfunction 4 - get skin height. ===========*/ |
|
- | 936 | ||
538 | "int $0x40" |
937 | static inline |
- | 938 | uint32_t _ksys_get_skin_height(){ |
|
- | 939 | unsigned height; |
|
- | 940 | asm_inline( |
|
- | 941 | "int $0x40" |
|
- | 942 | :"=a"(height) |
|
539 | :"=a"(val) |
943 | :"a"(48),"b"(4) |
540 | :"a"(17) |
944 | ); |
541 | ); |
945 | return height; |
542 | return val>>8; |
946 | } |
543 | } |
947 | |
544 | 948 | /*==================== Function 51 - create thread. ====================*/ |
|
545 | static inline |
949 | |
546 | ksys_oskey_t _ksys_get_key(void) |
950 | static inline |
Line -... | Line 951... | ||
- | 951 | int _ksys_start_thread(void* thread_entry, void* stack_top){ |
|
- | 952 | int val; |
|
547 | { |
953 | asm_inline( |
- | 954 | "int $0x40" |
|
- | 955 | :"=a"(val) |
|
- | 956 | :"a"(51), "b"(1), "c"(thread_entry), "d"(stack_top) |
|
- | 957 | ); |
|
- | 958 | return val; |
|
- | 959 | } |
|
- | 960 | ||
- | 961 | ||
- | 962 | /*==================== Function 54, subfunction 0 ======================*/ |
|
- | 963 | /*============== Get the number of slots in the clipboard. =============*/ |
|
- | 964 | ||
- | 965 | enum KSYS_CLIP_ENCODING{ |
|
Line 548... | Line 966... | ||
548 | ksys_oskey_t val; |
966 | KSYS_CLIP_UTF8 = 0, |
549 | asm_inline( |
967 | KSYS_CLIP_CP866 = 1, |
550 | "int $0x40" |
- | |
551 | :"=a"(val) |
968 | KSYS_CLIP_CP1251 = 2 |
552 | :"a"(2) |
969 | }; |
553 | ); |
970 | |
554 | return val; |
971 | enum KSYS_CLIP_TYPES{ |
555 | } |
972 | KSYS_CLIP_TEXT = 0, |
556 | 973 | KSYS_CLIP_IMAGE = 1, |
|
557 | /* Functions for working with the clipboard */ |
974 | KSYS_CLIP_RAW = 2 |
558 | 975 | }; |
|
Line -... | Line 976... | ||
- | 976 | ||
- | 977 | static inline |
|
- | 978 | int _ksys_clip_num(){ |
|
559 | static inline |
979 | unsigned val; |
560 | int _ksys_clip_num() |
980 | asm_inline( |
561 | { |
- | |
562 | unsigned val; |
981 | "int $0x40" |
563 | asm_inline( |
982 | :"=a"(val) |
564 | "int $0x40" |
983 | :"a"(54), "b"(0) |
565 | :"=a"(val) |
984 | ); |
566 | :"a"(54), "b"(0) |
985 | return val; |
567 | ); |
986 | } |
568 | return val; |
987 | |
569 | } |
988 | /*==================== Function 54, subfunction 1 ======================*/ |
Line -... | Line 989... | ||
- | 989 | /*================= Read the data from the clipboard. ==================-*/ |
|
- | 990 | ||
- | 991 | static inline |
|
570 | 992 | char* _ksys_clip_get(int n) { // returned buffer must be freed by _ksys_free() |
|
571 | static inline |
993 | char* val; |
572 | char* _ksys_clip_get(int n) // returned buffer must be freed by _ksys_free() |
- | |
573 | { |
994 | asm_inline( |
574 | char* val; |
995 | "int $0x40" |
575 | asm_inline( |
996 | :"=a"(val) |
576 | "int $0x40" |
997 | :"a"(54), "b"(1), "c"(n) |
577 | :"=a"(val) |
998 | ); |
578 | :"a"(54), "b"(1), "c"(n) |
999 | return val; |
579 | ); |
1000 | } |
580 | return val; |
1001 | |
581 | } |
1002 | /*==================== Function 54, subfunction 2 ======================*/ |
Line -... | Line 1003... | ||
- | 1003 | /*================= Write the data to the clipboard. ===================*/ |
|
- | 1004 | ||
- | 1005 | static inline |
|
582 | 1006 | int _ksys_clip_set(int n, char *buffer){ |
|
583 | static inline |
1007 | unsigned val; |
584 | int _ksys_clip_set(int n, char *buffer) |
- | |
585 | { |
1008 | asm_inline( |
586 | unsigned val; |
1009 | "int $0x40" |
587 | asm_inline( |
1010 | :"=a"(val) |
588 | "int $0x40" |
1011 | :"a"(54), "b"(2), "c"(n), "d"(buffer) |
589 | :"=a"(val) |
1012 | :"memory" |
590 | :"a"(54), "b"(2), "c"(n), "d"(buffer) |
1013 | ); |
591 | :"memory" |
1014 | return val; |
592 | ); |
1015 | } |
Line -... | Line 1016... | ||
- | 1016 | ||
- | 1017 | /*===================== Function 54, subfunction 3 =====================*/ |
|
- | 1018 | /*================ Delete the last slot in the clipboard ===============*/ |
|
593 | return val; |
1019 | |
594 | } |
1020 | static inline |
595 | - | ||
596 | static inline |
1021 | int _ksys_clip_pop(){ |
597 | int _ksys_clip_pop() |
1022 | unsigned val; |
598 | { |
1023 | asm_inline ( |
599 | unsigned val; |
1024 | "int $0x40" |
600 | asm_inline ( |
1025 | :"=a"(val) |
601 | "int $0x40" |
1026 | :"a"(54), "b"(3) |
602 | :"=a"(val) |
1027 | ); |
603 | :"a"(54), "b"(3) |
1028 | return val; |
Line 604... | Line -... | ||
604 | ); |
- | |
605 | return val; |
1029 | } |
Line 606... | Line 1030... | ||
606 | } |
1030 | |
607 | 1031 | /*===================== Function 54, subfunction 4 =====================*/ |
|
608 | static inline |
- | |
609 | int _ksys_clip_unlock() |
- | |
610 | { |
- | |
611 | unsigned val; |
- | |
612 | asm_inline( |
- | |
613 | "int $0x40" |
1032 | /*===================== Alarm reset the lock buffer ====================*/ |
614 | :"=a"(val) |
- | |
615 | :"a"(54), "b"(4) |
- | |
616 | ); |
1033 | |
Line 617... | Line 1034... | ||
617 | return val; |
1034 | static inline |
618 | } |
1035 | int _ksys_clip_unlock(){ |
619 | - | ||
620 | 1036 | unsigned val; |
|
621 | /* Working with time */ |
1037 | asm_inline( |
622 | 1038 | "int $0x40" |
|
623 | static inline |
1039 | :"=a"(val) |
624 | unsigned _ksys_get_tick_count() |
- | |
625 | { |
1040 | :"a"(54), "b"(4) |
626 | unsigned val; |
- | |
627 | asm_inline( |
1041 | ); |
Line -... | Line 1042... | ||
- | 1042 | return val; |
|
- | 1043 | } |
|
628 | "int $0x40" |
1044 | |
629 | :"=a"(val) |
1045 | /*============== Function 63 - work with the debug board. ==============*/ |
630 | :"a"(26),"b"(9) |
- | |
631 | ); |
1046 | |
632 | return val; |
1047 | static inline |
633 | } |
1048 | void _ksys_debug_putc(char c){ |
634 | - | ||
635 | static inline |
1049 | asm_inline("int $0x40"::"a"(63), "b"(1), "c"(c)); |
636 | uint64_t _ksys_get_ns_count() |
1050 | } |
Line 637... | Line -... | ||
637 | { |
- | |
638 | uint64_t val; |
- | |
639 | asm_inline( |
- | |
640 | "int $0x40" |
- | |
641 | :"=A"(val) |
- | |
642 | :"a"(26), "b"(10) |
- | |
643 | ); |
- | |
644 | return val; |
- | |
645 | } |
- | |
646 | - | ||
647 | static inline |
- | |
648 | void _ksys_delay(unsigned time) |
- | |
649 | { |
- | |
650 | asm_inline( |
- | |
651 | "int $0x40" |
- | |
652 | ::"a"(5), "b"(time) |
- | |
653 | :"memory" |
- | |
654 | ); |
1051 | |
Line 655... | Line 1052... | ||
655 | } |
1052 | static inline |
656 | 1053 | void _ksys_debug_puts(char *s){ |
|
657 | static inline |
1054 | unsigned i=0; |
658 | unsigned _ksys_get_date() |
1055 | while (*(s+i)){ |
Line 682... | Line 1079... | ||
682 | :"a"(68),"b"(12),"c"(size) |
1079 | :"a"(68),"b"(12),"c"(size) |
683 | ); |
1080 | ); |
684 | return val; |
1081 | return val; |
685 | } |
1082 | } |
Line -... | Line 1083... | ||
- | 1083 | ||
- | 1084 | /*========== Function 68, subfunction 13 - free memory block. ==========*/ |
|
686 | 1085 | ||
687 | static inline |
1086 | static inline |
688 | int _ksys_free(void *mem) |
- | |
689 | { |
1087 | int _ksys_free(void *mem){ |
690 | int val; |
1088 | int val; |
691 | asm_inline( |
1089 | asm_inline( |
692 | "int $0x40" |
1090 | "int $0x40" |
693 | :"=a"(val) |
1091 | :"=a"(val) |
694 | :"a"(68),"b"(13),"c"(mem) |
1092 | :"a"(68),"b"(13),"c"(mem) |
695 | ); |
1093 | ); |
696 | return val; |
1094 | return val; |
Line -... | Line 1095... | ||
- | 1095 | } |
|
- | 1096 | ||
697 | } |
1097 | /*============= Function 68, subfunction 16 - load driver. =============*/ |
698 | 1098 | ||
699 | static inline |
1099 | static inline |
700 | void* _ksys_realloc(void *mem, size_t size) |
1100 | ksys_drv_hand_t _ksys_load_driver(char *driver_name) |
701 | { |
1101 | { |
702 | void *val; |
1102 | ksys_drv_hand_t driver_h; |
703 | asm_inline( |
1103 | asm_inline( |
704 | "int $0x40" |
1104 | "int $0x40" |
705 | :"=a"(val) |
- | |
706 | :"a"(68),"b"(20),"c"(size),"d"(mem) |
1105 | :"=a"(driver_h) |
707 | :"memory" |
1106 | :"a"(68), "b"(16), "c"(driver_name) |
708 | ); |
1107 | ); |
Line -... | Line 1108... | ||
- | 1108 | return driver_h; |
|
- | 1109 | } |
|
709 | return val; |
1110 | |
710 | } |
1111 | /*============ Function 68, subfunction 17 - driver control. ===========*/ |
711 | 1112 | ||
712 | static inline |
1113 | static inline |
713 | int* _ksys_unmap(void *base, size_t offset, size_t size) |
1114 | unsigned _ksys_driver_control(ksys_ioctl_t *ioctl) |
714 | { |
1115 | { |
715 | int *val; |
1116 | unsigned status; |
716 | asm_inline( |
1117 | asm_inline( |
- | 1118 | "int $0x40" |
|
717 | "int $0x40" |
1119 | :"=a"(status) |
718 | :"=a"(val) |
1120 | :"a"(68), "b"(17), "c"(ioctl) |
719 | :"a"(68),"b"(26),"c"(base),"d"(offset),"S"(size) |
1121 | :"memory" |
Line 720... | Line -... | ||
720 | ); |
- | |
721 | return val; |
1122 | ); |
Line 722... | Line 1123... | ||
722 | } |
1123 | return status; |
723 | 1124 | } |
|
724 | - | ||
725 | /* Loading the dynamic coff library */ |
1125 | |
726 | 1126 | /*== Function 68, subfunction 18 - subfunction 19 - load DLL (MS COFF) ==*/ |
|
727 | static inline |
1127 | |
728 | ksys_coff_etable_t* _ksys_load_coff(const char* path) |
1128 | static inline |
729 | { |
1129 | ksys_dll_t* _ksys_dlopen(const char* path){ |
730 | ksys_coff_etable_t *table; |
1130 | ksys_dll_t *table; |
731 | asm_inline( |
1131 | asm_inline( |
732 | "int $0x40" |
1132 | "int $0x40" |
733 | :"=a"(table) |
1133 | :"=a"(table) |
Line -... | Line 1134... | ||
- | 1134 | :"a"(68),"b"(19), "c"(path) |
|
- | 1135 | :"memory" |
|
734 | :"a"(68),"b"(19), "c"(path) |
1136 | ); |
735 | :"memory" |
1137 | return table; |
736 | ); |
- | |
737 | return table; |
1138 | } |
738 | } |
1139 | |
739 | 1140 | /* It is not a system call, it serves as an auxiliary tool*/ |
|
740 | static inline |
1141 | |
741 | void* _ksys_get_coff_func(ksys_coff_etable_t *table, const char* fun_name, ksys_panic* panic) |
1142 | static inline |
742 | { |
1143 | void* _ksys_dlsym(ksys_dll_t *table, const char* fun_name){ |
743 | unsigned i=0; |
1144 | unsigned i=0; |
744 | while (1){ |
1145 | while (1){ |
745 | if (NULL == (table+i)->func_name){ |
1146 | if (!(table+i)->func_name){ |
746 | break; |
1147 | break; |
747 | }else{ |
1148 | }else{ |
748 | if (!_ksys_strcmp(fun_name, (table+i)->func_name)){ |
- | |
749 | return (table+i)->func_ptr; |
1149 | if (!_ksys_strcmp(fun_name, (table+i)->func_name)){ |
750 | } |
1150 | return (table+i)->func_ptr; |
Line 751... | Line -... | ||
751 | } |
- | |
752 | i++; |
- | |
753 | } |
- | |
754 | panic((char*)fun_name); |
- | |
755 | return NULL; |
- | |
756 | } |
- | |
757 | - | ||
758 | - | ||
759 | /* Debug board functions */ |
- | |
760 | - | ||
761 | static inline |
- | |
762 | void _ksys_debug_putc(char c) |
- | |
763 | { |
- | |
764 | asm_inline("int $0x40"::"a"(63), "b"(1), "c"(c)); |
- | |
765 | } |
- | |
766 | - | ||
767 | static inline |
- | |
768 | void _ksys_debug_puts(char *s) |
- | |
769 | { |
- | |
770 | unsigned i=0; |
- | |
771 | while (*(s+i)){ |
1151 | } |
Line 772... | Line 1152... | ||
772 | asm_inline ("int $0x40"::"a"(63), "b"(1), "c"(*(s+i))); |
1152 | } |
773 | i++; |
1153 | i++; |
774 | } |
- | |
775 | } |
1154 | } |
776 | 1155 | return NULL; |
|
777 | 1156 | } |
|
778 | /* Working with threads and process */ |
1157 | |
779 | 1158 | /* Function 68, subfunction 20 - reallocate memory block.*/ |
|
- | 1159 | ||
780 | static inline |
1160 | static inline |
781 | int _ksys_start_thread(void* proc, char* stack_top) |
1161 | void* _ksys_realloc(void *mem, size_t size){ |
782 | { |
1162 | void *val; |
Line 783... | Line -... | ||
783 | int val; |
- | |
784 | asm_inline( |
1163 | asm_inline( |
785 | "int $0x40" |
- | |
786 | :"=a"(val) |
- | |
787 | :"a"(51), "b"(1), "c"(proc), "d"(stack_top) |
- | |
788 | ); |
- | |
789 | return val; |
- | |
Line 790... | Line 1164... | ||
790 | } |
1164 | "int $0x40" |
791 | 1165 | :"=a"(val) |
|
- | 1166 | :"a"(68),"b"(20),"c"(size),"d"(mem) |
|
792 | static inline |
1167 | :"memory" |
793 | void _ksys_focus_window(int slot){ |
1168 | ); |
794 | asm_inline( |
1169 | return val; |
795 | "int $0x40" |
1170 | } |
796 | ::"a"(18), "b"(3), "c"(slot) |
1171 | |
797 | ); |
1172 | /* Function 68, subfunction 21 - load driver by full name. */ |
798 | } |
1173 | |
799 | 1174 | static inline |
|
Line -... | Line 1175... | ||
- | 1175 | ksys_drv_hand_t _ksys_load_driver_opt(char *driver_path, char *cmd_line) |
|
- | 1176 | { |
|
- | 1177 | ksys_drv_hand_t driver_h; |
|
- | 1178 | asm_inline( |
|
- | 1179 | "int $0x40" |
|
- | 1180 | :"=a"(driver_h) |
|
- | 1181 | :"a"(68), "b"(21), "c"(driver_path), "d"(cmd_line) |
|
- | 1182 | ); |
|
- | 1183 | return driver_h; |
|
- | 1184 | } |
|
800 | static inline |
1185 | |
801 | int _ksys_get_thread_slot(int tid){ |
1186 | /*======== Function 68, subfunction 22 - open named memory area. =======*/ |
802 | int val; |
1187 | |
803 | asm_inline( |
1188 | enum KSYS_SHM_MODE{ |
804 | "int $0x40" |
1189 | KSYS_SHM_OPEN = 0x00, |
805 | :"=a"(val) |
1190 | KSYS_SHM_OPEN_ALWAYS = 0x04, |
806 | :"a"(18), "b"(21), "c"(tid) |
1191 | KSYS_SHM_CREATE = 0x08, |
807 | ); |
1192 | KSYS_SHM_READ = 0x00, |
808 | return val; |
- | |
809 | } |
1193 | KSYS_SHM_WRITE = 0x01, |
810 | 1194 | }; |
|
811 | static inline |
- | |
812 | int _ksys_process_info(ksys_proc_table_t* table, int pid) |
- | |
813 | { |
- | |
814 | int val; |
- | |
815 | asm_inline( |
- | |
816 | "int $0x40" |
- | |
817 | :"=a"(val) |
1195 | |
Line 818... | Line -... | ||
818 | :"a"(9), "b"(table), "c"(pid) |
- | |
819 | :"memory" |
1196 | static inline |
Line 820... | Line 1197... | ||
820 | ); |
1197 | int _ksys_shm_open(char *name, int mode, int size, char **new_shm) |
821 | return val; |
1198 | { |
- | 1199 | int error; |
|
822 | } |
1200 | asm_inline( |
823 | 1201 | "int $0x40" |
|
824 | static inline |
1202 | :"=a"(*new_shm), "=d"(error) |
825 | void _ksys_exit() |
1203 | :"a"(68), "b"(22), "c"(name), "d"(size), "S"(mode) |
826 | { |
1204 | ); |
Line -... | Line 1205... | ||
- | 1205 | return error; |
|
- | 1206 | } |
|
827 | asm_inline("int $0x40"::"a"(-1)); |
1207 | |
828 | } |
1208 | /*======= Function 68, subfunction 23 - close named memory area. =======*/ |
829 | 1209 | ||
830 | 1210 | static inline |
|
831 | /* Working with files and directories */ |
1211 | void _ksys_shm_close(char *shm_name) |
- | 1212 | { |
|
832 | 1213 | asm_inline( |
|
833 | static inline |
1214 | "int $0x40": |
834 | void _ksys_setcwd(char* dir){ |
1215 | :"a"(68), "b"(23), "c"(shm_name) |
835 | asm_inline( |
1216 | ); |
Line -... | Line 1217... | ||
- | 1217 | } |
|
- | 1218 | ||
836 | "int $0x40" |
1219 | /*====== Function 68, subfunction 26 - release memory pages ============*/ |
837 | ::"a"(30), "b"(1), "c"(dir) |
1220 | |
838 | ); |
1221 | static inline |
839 | } |
1222 | int* _ksys_unmap(void *base, size_t offset, size_t size){ |
840 | 1223 | int *val; |
|
Line 859... | Line 1242... | ||
859 | :"memory" |
1242 | :"memory" |
860 | ); |
1243 | ); |
861 | return uf; |
1244 | return uf; |
862 | } |
1245 | } |
Line -... | Line 1246... | ||
- | 1246 | ||
- | 1247 | /*==== Function 68, subfunction 28 - load file, specifying the encoding ===*/ |
|
863 | 1248 | ||
864 | static inline |
1249 | static inline |
865 | ksys_ufile_t _ksys_load_file_enc(const char *path, unsigned file_encoding) |
1250 | ksys_ufile_t _ksys_load_file_enc(const char *path, unsigned file_encoding) |
866 | { |
1251 | { |
867 | ksys_ufile_t uf; |
1252 | ksys_ufile_t uf; |
Line 872... | Line 1257... | ||
872 | :"memory" |
1257 | :"memory" |
873 | ); |
1258 | ); |
874 | return uf; |
1259 | return uf; |
875 | } |
1260 | } |
Line -... | Line 1261... | ||
- | 1261 | ||
- | 1262 | /*==== Function 70 - work with file system with long names support. ====*/ |
|
876 | 1263 | ||
877 | static inline |
1264 | static inline |
878 | int _ksys_work_files(const ksys70_t *k) |
1265 | int _ksys_work_files(const ksys70_t *k) |
879 | { |
1266 | { |
880 | int status; |
1267 | int status; |
Line 885... | Line 1272... | ||
885 | :"memory" |
1272 | :"memory" |
886 | ); |
1273 | ); |
887 | return status; |
1274 | return status; |
888 | } |
1275 | } |
Line -... | Line 1276... | ||
- | 1276 | ||
- | 1277 | /*====== Function 70, subfunction 0 - read file with long names support. ======*/ |
|
889 | 1278 | ||
890 | static inline |
1279 | static inline |
891 | int _ksys_file_read_file(const char *name, unsigned long long offset, unsigned size, void *buf, unsigned *bytes_read) |
1280 | int _ksys_file_read_file(const char *name, unsigned long long offset, unsigned size, void *buf, unsigned *bytes_read) |
892 | { |
1281 | { |
893 | ksys70_t k; |
1282 | ksys70_t k; |
Line 909... | Line 1298... | ||
909 | *bytes_read = bytes_read_v; |
1298 | *bytes_read = bytes_read_v; |
910 | } |
1299 | } |
911 | return status; |
1300 | return status; |
912 | } |
1301 | } |
Line -... | Line 1302... | ||
- | 1302 | ||
- | 1303 | /*===================== Function 70, subfunction 2 =====================*/ |
|
- | 1304 | /*============ Create/rewrite file with long names support. ============*/ |
|
- | 1305 | ||
- | 1306 | static inline |
|
- | 1307 | int _ksys_file_create(const char* name){ |
|
- | 1308 | ksys70_t k; |
|
- | 1309 | k.p00 = 2; |
|
- | 1310 | k.p12 = 0; |
|
- | 1311 | k.p21 = name; |
|
- | 1312 | return _ksys_work_files(&k); |
|
- | 1313 | } |
|
- | 1314 | ||
- | 1315 | /*===================== Function 70, subfunction 3 =====================*/ |
|
- | 1316 | /*=========== Write to existing file with long names support. ==========*/ |
|
913 | 1317 | ||
914 | static inline |
1318 | static inline |
915 | int _ksys_file_write_file(const char *name, unsigned long long offset, unsigned size, const void *buf, unsigned *bytes_written) |
1319 | int _ksys_file_write_file(const char *name, unsigned long long offset, unsigned size, const void *buf, unsigned *bytes_written) |
916 | { |
1320 | { |
917 | ksys70_t k; |
1321 | ksys70_t k; |
Line 933... | Line 1337... | ||
933 | *bytes_written = bytes_written_v; |
1337 | *bytes_written = bytes_written_v; |
934 | } |
1338 | } |
935 | return status; |
1339 | return status; |
936 | } |
1340 | } |
Line 937... | Line -... | ||
937 | - | ||
938 | static inline |
1341 | |
939 | int _ksys_file_create(const char* name){ |
- | |
940 | ksys70_t k; |
- | |
941 | k.p00 = 2; |
- | |
942 | k.p12 = 0; |
- | |
943 | k.p21 = name; |
- | |
944 | return _ksys_work_files(&k); |
- | |
Line 945... | Line 1342... | ||
945 | } |
1342 | /*========== Function 70, subfunction 5 - get information on file/folder. =====*/ |
946 | 1343 | ||
947 | static inline |
1344 | static inline |
948 | int _ksys_file_get_info(const char *name, ksys_bdfe_t *bdfe) |
1345 | int _ksys_file_get_info(const char *name, ksys_bdfe_t *bdfe) |
Line 953... | Line 1350... | ||
953 | k.p20 = 0; |
1350 | k.p20 = 0; |
954 | k.p21 = name; |
1351 | k.p21 = name; |
955 | return _ksys_work_files(&k); |
1352 | return _ksys_work_files(&k); |
956 | } |
1353 | } |
Line 957... | Line -... | ||
957 | - | ||
958 | static inline |
- | |
959 | int _ksys_file_delete(const char *name) |
- | |
960 | { |
- | |
961 | ksys70_t k; |
- | |
962 | k.p00 = 8; |
- | |
963 | k.p20 = 0; |
- | |
964 | k.p21 = name; |
- | |
965 | return _ksys_work_files(&k); |
- | |
966 | } |
- | |
967 | - | ||
968 | static inline |
1354 | |
969 | int _ksys_file_rename(const char *name, const char *new_name) |
- | |
970 | { |
- | |
971 | ksys70_t k; |
- | |
972 | k.p00 = 10; |
- | |
973 | k.new_name = new_name; |
- | |
974 | k.p20 = 0; |
- | |
975 | k.p21 = name; |
- | |
976 | return _ksys_work_files(&k); |
- | |
977 | } |
- | |
Line 978... | Line 1355... | ||
978 | 1355 | /*=========== Function 70, subfunction 7 - start application. ===========*/ |
|
979 | 1356 | ||
980 | static inline |
1357 | static inline |
981 | int _ksys_exec(char *app_name, char *args) |
1358 | int _ksys_exec(char *app_name, char *args) |
Line 986... | Line 1363... | ||
986 | file_opt.p08dw = (unsigned)args; |
1363 | file_opt.p08dw = (unsigned)args; |
987 | file_opt.p21 = app_name; |
1364 | file_opt.p21 = app_name; |
988 | return _ksys_work_files(&file_opt); |
1365 | return _ksys_work_files(&file_opt); |
989 | } |
1366 | } |
Line 990... | Line -... | ||
990 | - | ||
991 | static inline |
- | |
992 | int _ksys_mkdir(const char *path) |
- | |
993 | { |
- | |
994 | ksys70_t dir_opt; |
- | |
995 | dir_opt.p00 = 9; |
- | |
996 | dir_opt.p21 = path; |
- | |
997 | return _ksys_work_files(&dir_opt); |
- | |
998 | } |
- | |
999 | 1367 | ||
Line 1000... | Line 1368... | ||
1000 | /* Working with a named shared memory area. */ |
1368 | /*========== Function 70, subfunction 8 - delete file/folder. ==========*/ |
1001 | 1369 | ||
1002 | static inline |
1370 | static inline |
1003 | int _ksys_shm_open(char *name, int mode, int size, char **new_shm) |
1371 | int _ksys_file_delete(const char *name) |
1004 | { |
1372 | { |
1005 | int error; |
1373 | ksys70_t k; |
1006 | asm_inline( |
- | |
1007 | "int $0x40" |
- | |
1008 | :"=a"(*new_shm), "=d"(error) |
1374 | k.p00 = 8; |
1009 | :"a"(68), "b"(22), "c"(name), "d"(size), "S"(mode) |
1375 | k.p20 = 0; |
1010 | ); |
1376 | k.p21 = name; |
Line -... | Line 1377... | ||
- | 1377 | return _ksys_work_files(&k); |
|
Line 1011... | Line 1378... | ||
1011 | return error; |
1378 | } |
1012 | } |
1379 | |
1013 | 1380 | /*============= Function 70, subfunction 9 - create folder. ============*/ |
|
1014 | 1381 | ||
1015 | static inline |
1382 | static inline |
1016 | void _ksys_shm_close(char *shm_name) |
1383 | int _ksys_mkdir(const char *path) |
1017 | { |
1384 | { |
1018 | asm_inline( |
1385 | ksys70_t dir_opt; |
Line 1019... | Line 1386... | ||
1019 | "int $0x40": |
1386 | dir_opt.p00 = 9; |
Line 1020... | Line 1387... | ||
1020 | :"a"(68), "b"(23), "c"(shm_name) |
1387 | dir_opt.p21 = path; |
1021 | ); |
1388 | return _ksys_work_files(&dir_opt); |
1022 | } |
1389 | } |
1023 | 1390 | ||
1024 | /* Driver functions */ |
1391 | /*============= Function 70, subfunction 10 - rename/move. =============*/ |
1025 | 1392 | ||
1026 | static inline |
1393 | static inline |
1027 | ksys_drv_hand_t _ksys_load_driver(char *driver_name) |
- | |
1028 | { |
1394 | int _ksys_file_rename(const char *name, const char *new_name) |
1029 | ksys_drv_hand_t driver_h; |
1395 | { |
1030 | asm_inline( |
1396 | ksys70_t k; |
Line 1031... | Line -... | ||
1031 | "int $0x40" |
- | |
1032 | :"=a"(driver_h) |
- | |
1033 | :"a"(68), "b"(16), "c"(driver_name) |
- | |
1034 | ); |
- | |
1035 | return driver_h; |
- | |
1036 | } |
- | |
1037 | - | ||
1038 | static inline |
- | |
1039 | ksys_drv_hand_t _ksys_load_pe_driver(char *driver_path, char *cmd_line) |
- | |
1040 | { |
- | |
1041 | ksys_drv_hand_t driver_h; |
- | |
Line 1042... | Line -... | ||
1042 | asm_inline( |
- | |
1043 | "int $0x40" |
1397 | k.p00 = 10; |
1044 | :"=a"(driver_h) |
- | |
1045 | :"a"(68), "b"(21), "c"(driver_path), "d"(cmd_line) |
- | |
1046 | ); |
- | |
1047 | return driver_h; |
- | |
1048 | } |
- | |
1049 | - | ||
1050 | static inline |
- | |
1051 | unsigned _ksys_work_driver(ksys_ioctl_t *ioctl) |
- | |
1052 | { |
- | |
1053 | unsigned status; |
- | |
Line 1054... | Line 1398... | ||
1054 | asm_inline( |
1398 | k.new_name = new_name; |
1055 | "int $0x40" |
- | |
1056 | :"=a"(status) |
1399 | k.p20 = 0; |
- | 1400 | k.p21 = name; |
|
Line 1057... | Line 1401... | ||
1057 | :"a"(68), "b"(17), "c"(ioctl) |
1401 | return _ksys_work_files(&k); |