Subversion Repositories Kolibri OS

Rev

Rev 8818 | Rev 9094 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
9093 turbocat 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
 
8687 turbocat 19
#ifndef _KSYS_H_
20
#define _KSYS_H_
21
 
22
#include 
23
 
24
#define asm_inline __asm__ __volatile__
25
 
9093 turbocat 26
/*============== General structures ==============*/
8687 turbocat 27
 
9093 turbocat 28
#pragma pack(push,1)
8687 turbocat 29
 
30
typedef struct {
9093 turbocat 31
    uint8_t blue;
32
    uint8_t green;
33
    uint8_t red;
8687 turbocat 34
}rgb_t;
9093 turbocat 35
 
36
typedef union {
37
    uint32_t val;
38
    struct{
39
        uint8_t hour;
40
        uint8_t min;
41
        uint8_t sec;
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;
53
    };
54
}ksys_date_t;
55
 
8687 turbocat 56
typedef union{
9093 turbocat 57
    uint32_t val;
8687 turbocat 58
    struct{
9093 turbocat 59
        uint16_t  x;
60
        uint16_t  y;
8687 turbocat 61
    };
62
}ksys_pos_t;
63
 
64
typedef union ksys_oskey_t{
9093 turbocat 65
    uint32_t val;
8687 turbocat 66
    struct{
9093 turbocat 67
        uint8_t state;
68
        uint8_t code;
69
        uint8_t ctrl_key;
8687 turbocat 70
    };
71
}ksys_oskey_t;
72
 
73
typedef struct{
74
    void *data;
75
    size_t size;
76
}ksys_ufile_t;
77
 
78
 
79
typedef struct{
9093 turbocat 80
    uint32_t            p00;
8687 turbocat 81
    union{
82
        uint64_t        p04;
83
        struct {
9093 turbocat 84
            uint32_t    p04dw;
85
            uint32_t    p08dw;
8687 turbocat 86
        };
87
    };
9093 turbocat 88
    uint32_t            p12;
8687 turbocat 89
    union {
9093 turbocat 90
        uint32_t        p16;
8687 turbocat 91
        const char     *new_name;
92
        void           *bdfe;
93
        void           *buf16;
94
        const void     *cbuf16;
95
    };
96
    char                p20;
97
    const char         *p21;
98
}ksys70_t;
99
 
100
typedef struct {
9093 turbocat 101
    uint32_t attributes;
102
    uint32_t name_cp;
103
    ksys_time_t creation_time;
104
    ksys_date_t creation_date;
105
    ksys_time_t last_access_time;
106
    ksys_date_t last_access_date;
107
    ksys_time_t last_modification_time;
108
    ksys_date_t last_modification_date;
8687 turbocat 109
    unsigned long long size;
110
    char name[0];
111
}ksys_bdfe_t;
112
 
113
typedef struct {
114
  int cpu_usage;             //+0
115
  int window_pos_info;       //+4
116
  short int reserved1;       //+8
117
  char name[12];             //+10
118
  int memstart;              //+22
119
  int memused;               //+26
120
  int pid;                   //+30
121
  int winx_start;            //+34
122
  int winy_start;            //+38
123
  int winx_size;             //+42
124
  int winy_size;             //+46
125
  short int slot_info;       //+50
126
  short int reserved2;       //+52
127
  int clientx;               //+54
128
  int clienty;               //+58
129
  int clientwidth;           //+62
130
  int clientheight;          //+66
131
  unsigned char window_state;//+70
132
  char reserved3[1024-71];   //+71
9093 turbocat 133
}ksys_thread_t;
8687 turbocat 134
 
135
typedef unsigned int ksys_color_t;
136
 
137
typedef struct{
138
    ksys_color_t frame_area;
139
    ksys_color_t grab_bar;
140
    ksys_color_t grab_bar_button;
141
    ksys_color_t grab_button_text;
142
    ksys_color_t grab_text;
143
    ksys_color_t work_area;
144
    ksys_color_t work_button;
145
    ksys_color_t work_button_text;
146
    ksys_color_t work_text;
147
    ksys_color_t work_graph;
148
}ksys_colors_table_t;
149
 
150
typedef struct{
151
    unsigned pid;      // PID of sending thread
152
    unsigned datalen;  // data bytes
153
    char     *data;    // data begin
154
}ksys_ipc_msg;
155
 
156
typedef struct{
157
    unsigned lock;              // nonzero is locked
158
    unsigned used;              // used bytes in buffer
159
    ksys_ipc_msg *data;         // data begin
160
}ksys_ipc_buffer;
161
 
162
typedef struct {
163
    char* func_name;
164
    void* func_ptr;
9093 turbocat 165
}ksys_dll_t;
8687 turbocat 166
 
8702 turbocat 167
typedef unsigned ksys_drv_hand_t;
8699 turbocat 168
 
169
typedef struct{
170
    ksys_drv_hand_t handler;
171
    unsigned func_num;
172
    void* in_data_ptr;
173
    unsigned in_data_size;
174
    void* out_data_ptr;
175
    unsigned out_data_size;
8718 turbocat 176
}ksys_ioctl_t;
8699 turbocat 177
 
9093 turbocat 178
typedef struct{
179
    char  key[64];
180
    char path[64];
181
}ksys_dir_key_t;
182
 
8687 turbocat 183
#pragma pack(pop)
184
 
9093 turbocat 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
200
};
201
 
8687 turbocat 202
enum KSYS_EVENTS {
203
    KSYS_EVENT_NONE = 0,     /* Event queue is empty */
204
    KSYS_EVENT_REDRAW = 1,   /* Window and window elements should be redrawn */
205
    KSYS_EVENT_KEY = 2,      /* A key on the keyboard was pressed */
206
    KSYS_EVENT_BUTTON = 3,   /* A button was clicked with the mouse */
207
    KSYS_EVENT_DESKTOP = 5,  /* Desktop redraw finished */
208
    KSYS_EVENT_MOUSE = 6,    /* Mouse activity (movement, button press) was detected */
209
    KSYS_EVENT_IPC = 7,      /* Interprocess communication notify */
210
    KSYS_EVENT_NETWORK = 8,  /* Network event */
211
    KSYS_EVENT_DEBUG = 9,    /* Debug subsystem event */
212
    KSYS_EVENT_IRQBEGIN = 16 /* 16..31 IRQ0..IRQ15 interrupt =IRQBEGIN+IRQn */
213
};
214
 
215
enum KSYS_FILE_ENCODING{
216
    KSYS_FILE_CP866 =1,
217
    KSYS_FILE_UTF16LE = 2,
218
    KSYS_FILE_UTF8 = 3
219
};
220
 
221
static inline
222
int _ksys_strcmp(const char * s1, const char * s2 )
223
{
224
    while ((*s1) && (*s1 == *s2)){ ++s1; ++s2; }
225
    return(*(unsigned char*)s1 - *(unsigned char *)s2);
226
}
227
 
9093 turbocat 228
/* ####################################################################### */
229
/* ############### ะก wrappers for system calls Kolibri OS ################ */
230
/* ####################################################################### */
8687 turbocat 231
 
232
 
9093 turbocat 233
/*=============== Function -1 - terminate thread/process ===============*/
234
 
235
static inline
236
void _ksys_exit(){
237
    asm_inline("int $0x40"::"a"(-1));
8687 turbocat 238
}
239
 
9093 turbocat 240
/*============== Function 0 - define and draw the window. ==============*/
241
 
8687 turbocat 242
static inline
9093 turbocat 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) {
8687 turbocat 244
    asm_inline(
245
        "int $0x40"
246
        ::"a"(0),
247
        "b"((x << 16) | ((w-1) & 0xFFFF)),
248
        "c"((y << 16) | ((h-1) & 0xFFFF)),
249
        "d"((style << 24) | (workcolor & 0xFFFFFF)),
250
        "D"(name),
251
        "S"(0)
252
        :"memory"
253
     );
254
};
255
 
9093 turbocat 256
/*================ Function 1 - put pixel in the window. ===============*/
257
 
258
static inline
259
void _ksys_draw_pixel(uint32_t x, uint32_t y, ksys_color_t color){
260
    asm_inline(
261
        "int $0x40"
262
        ::"a"(1), "b"(x), "c"(y), "d"(color)
263
    );
264
}
265
 
266
/*============ Function 2 - get the code of the pressed key. ===========*/
267
 
8687 turbocat 268
static inline
9093 turbocat 269
ksys_oskey_t _ksys_get_key(void){
270
    ksys_oskey_t val;
8687 turbocat 271
    asm_inline(
272
        "int $0x40"
9093 turbocat 273
        :"=a"(val)
274
        :"a"(2)
8687 turbocat 275
    );
9093 turbocat 276
    return val;
8687 turbocat 277
}
9093 turbocat 278
 
279
/*==================== Function 3 - get system time. ===================*/
280
 
8687 turbocat 281
static inline
9093 turbocat 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. ===================*/
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) {
8687 turbocat 297
   asm_inline(
298
        "int $0x40"
9093 turbocat 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)
313
        :"memory"
314
    );
315
}
316
 
317
/*=============== Function 8 - define/delete the button. ===============*/
318
 
319
static inline
320
void _ksys_define_button(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t id, ksys_color_t color) {
321
   asm_inline(
322
        "int $0x40"
8687 turbocat 323
        ::"a"(8),
324
        "b"((x<<16)+w),
325
        "c"((y<<16)+h),
326
        "d"(id),
327
        "S"(color)
328
    );
329
};
330
 
331
static inline
9093 turbocat 332
void _ksys_delete_button(uint32_t id){
8687 turbocat 333
    asm_inline(
334
        "int $0x40"
9093 turbocat 335
        ::"a"(8),"d"(id & 0x00FFFFFF | 0x80000000)
8687 turbocat 336
    );
9093 turbocat 337
}
338
 
339
/*============ Function 9 - information on execution thread. ===========*/
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;
8687 turbocat 351
}
352
 
9093 turbocat 353
/*==================== Function 10 - wait for event. ===================*/
354
 
8687 turbocat 355
static inline
9093 turbocat 356
uint32_t _ksys_wait_event(void){
357
    uint32_t val;
8687 turbocat 358
    asm_inline(
359
        "int $0x40"
9093 turbocat 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
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
 
393
static inline
394
void _ksys_draw_bar(uint32_t x, uint32_t y, uint32_t w, uint32_t h, ksys_color_t color){
395
    asm_inline(
396
        "int $0x40"
8687 turbocat 397
        ::"a"(13), "d"(color),
398
        "b"((x << 16) | w),
399
        "c"((y << 16) | h)
400
    );
401
}
402
 
9093 turbocat 403
/*=================== Function 14 - get screen size. ===================*/
404
 
8687 turbocat 405
static inline
9093 turbocat 406
ksys_pos_t _ksys_screen_size(){
407
	ksys_pos_t size;
408
    ksys_pos_t size_tmp;
409
    asm_inline(
410
        "int $0x40"
411
        :"=a"(size_tmp)
412
        :"a"(14)
413
    );
414
    size.x = size_tmp.y;
415
    size.y = size_tmp.x;
416
    return size;
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
}
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 =====================*/
476
/*======= Map background data to the address space of process. ==========*/
477
 
478
static inline
479
ksys_bitmap_t* _ksys_bg_get_map()
8687 turbocat 480
{
9093 turbocat 481
    ksys_bitmap_t *bitmap;
8687 turbocat 482
    asm_inline(
483
        "int $0x40"
9093 turbocat 484
        :"=a"(bitmap)
485
        :"a"(15), "b"(6)
8687 turbocat 486
    );
9093 turbocat 487
    return bitmap;
8687 turbocat 488
}
489
 
9093 turbocat 490
/*===== Function 15, subfunction 7 - close mapped background data. =====*/
491
 
8687 turbocat 492
static inline
9093 turbocat 493
int _ksys_bg_close_map(ksys_bitmap_t* bitmap)
494
{
495
    int status; // 1 - OK, 0 - ERROR
496
    asm_inline(
497
        "int $0x40"
498
        :"=a"(status)
499
        :"a"(15), "b"(7), "c"(bitmap)
500
    );
501
    return status;
502
}
503
 
504
/*===================== Function 15, subfunction 9 =====================*/
505
/*============= Redraws a rectangular part of the background ===========*/
506
 
507
static inline
508
void _ksys_bg_redraw_bar(ksys_pos_t angle1, ksys_pos_t angle2)
8687 turbocat 509
{
9093 turbocat 510
    asm_inline(
8687 turbocat 511
        "int $0x40"
9093 turbocat 512
        ::"a"(15), "b"(9),
513
        "c"(angle1.x*(1<<16)+angle2.x),
514
        "d"(angle1.y*(1<<16)+angle2.y)
8687 turbocat 515
    );
516
}
517
 
9093 turbocat 518
/*=============== Function 16 - save ramdisk on a floppy. ==============*/
519
 
8687 turbocat 520
static inline
9093 turbocat 521
int _ksys_save_ramdisk_fd(uint32_t floppy_id)
8687 turbocat 522
{
9093 turbocat 523
    int status; // 0 - OK, 1 - ERROR
8687 turbocat 524
    asm_inline(
525
        "int $0x40"
9093 turbocat 526
        :"=a"(status)
527
        :"a"(16), "b"(floppy_id)
8687 turbocat 528
    );
9093 turbocat 529
    return status;
8687 turbocat 530
}
531
 
9093 turbocat 532
/*======= Function 17 - get the identifier of the pressed button. ======*/
533
 
534
static inline
535
uint32_t _ksys_get_button()
536
{
537
    unsigned val;
538
    asm_inline(
539
        "int $0x40"
540
        :"=a"(val)
541
        :"a"(17)
542
    );
543
    return val>>8;
544
}
545
 
546
/*===================== Function 18, subfunction 1 =====================*/
547
/*============= Make deactive the window of the given thread. ==========*/
548
 
8687 turbocat 549
static inline
9093 turbocat 550
void _ksys_unfocus_window(int slot)
551
{
8687 turbocat 552
    asm_inline(
553
        "int $0x40"
9093 turbocat 554
        ::"a"(18), "b"(1), "c"(slot)
8687 turbocat 555
    );
556
}
9093 turbocat 557
 
558
/*= Function 18, subfunction 2 - terminate process/thread by the slot. =*/
559
 
8687 turbocat 560
static inline
9093 turbocat 561
void _ksys_kill_by_slot(int slot)
562
{
8687 turbocat 563
    asm_inline(
564
        "int $0x40"
9093 turbocat 565
        ::"a"(18), "b"(2), "c"(slot)
8687 turbocat 566
    );
567
}
568
 
9093 turbocat 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)
577
    );
578
}
579
 
580
/*===================== Function 18, subfunction 4 =====================*/
581
/*=========== Get counter of idle time units per one second. ===========*/
582
 
8687 turbocat 583
static inline
9093 turbocat 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"
633
        ::"a"(18), "b"(9), "c"(shd_param)
634
    );
635
}
636
 
637
/*========= Function 18, subfunction 16 - get size of free RAM. ========*/
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
 
650
/*======== Function 18, subfunction 17 - get full amount of RAM. =======*/
651
 
652
static inline
653
size_t _ksys_get_full_ram(void){
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)
8687 turbocat 668
{
669
    asm_inline(
9093 turbocat 670
        "int $0x40"
671
        ::"a"(18), "b"(18), "c"(PID)
8687 turbocat 672
    );
673
}
674
 
9093 turbocat 675
 
8687 turbocat 676
static inline
9093 turbocat 677
int _ksys_get_thread_slot(int PID){
678
    int val;
8687 turbocat 679
    asm_inline(
9093 turbocat 680
        "int $0x40"
681
        :"=a"(val)
682
        :"a"(18), "b"(21), "c"(PID)
8687 turbocat 683
    );
9093 turbocat 684
    return val;
8687 turbocat 685
}
686
 
9093 turbocat 687
/*============= Function 23 - wait for event with timeout. =============*/
8687 turbocat 688
 
689
static inline
9093 turbocat 690
uint32_t _ksys_wait_event_timeout(uint32_t timeout){
691
    unsigned val;
8687 turbocat 692
    asm_inline(
693
        "int $0x40"
9093 turbocat 694
        :"=a"(val)
695
        :"a"(23), "b"(timeout)
8687 turbocat 696
    );
9093 turbocat 697
    return val;
8687 turbocat 698
}
699
 
9093 turbocat 700
/*=== Function 26, subfunction 9 - get the value of the time counter. ==*/
8687 turbocat 701
 
9093 turbocat 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
}
8687 turbocat 712
 
9093 turbocat 713
/*===================== Function 26, subfunction 10 ====================*/
714
/*========== Get the value of the high precision time counter. =========*/
715
 
8687 turbocat 716
static inline
9093 turbocat 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)
768
        :"memory"
769
    );
770
    return val;
771
}
772
 
773
/*=================== Function 37 - work with mouse. ===================*/
774
 
775
enum KSYS_MOUSE_POS{
776
    KSYS_MOUSE_SCREEN_POS = 0,
777
    KSYS_MOUSE_WINDOW_POS = 1
778
};
779
 
780
static inline
781
ksys_pos_t _ksys_get_mouse_pos(int origin){
8687 turbocat 782
    ksys_pos_t pos;
783
    asm_inline(
784
        "int $0x40 \n\t"
785
        "rol $16, %%eax"
786
        :"=a"(pos)
787
        :"a"(37),"b"(origin)
788
    );
789
    return pos;
790
}
9093 turbocat 791
 
8687 turbocat 792
static inline
9093 turbocat 793
uint32_t _ksys_get_mouse_buttons(void){ // subfunction 2 - states of the mouse buttons
794
    uint32_t val;
8687 turbocat 795
    asm_inline(
796
        "int $0x40"
797
        :"=a"(val)
798
        :"a"(37),"b"(2)
799
    );
800
    return val;
801
}
9093 turbocat 802
 
8687 turbocat 803
static inline
9093 turbocat 804
uint32_t _ksys_get_mouse_eventstate(void){   // subfunction 3 - states and events of the mouse buttons
805
    uint32_t val;
8687 turbocat 806
    asm_inline(
9093 turbocat 807
        "int $0x40"
8687 turbocat 808
        :"=a"(val)
9093 turbocat 809
        :"a"(37),"b"(3)
8687 turbocat 810
    );
811
    return val;
812
}
9093 turbocat 813
 
814
static inline
815
uint32_t _ksys_load_cursor(void *path, uint32_t flags) { // subfunction 4 - load cursor
816
    uint32_t val;
8687 turbocat 817
    asm_inline(
818
        "int $0x40"
819
        :"=a"(val)
820
        :"a"(37), "b"(4), "c"(path), "d"(flags)
821
        :"memory"
822
    );
823
    return val;
9093 turbocat 824
}
825
 
8687 turbocat 826
static inline
9093 turbocat 827
uint32_t _ksys_set_cursor(uint32_t cursor){ // subfunction 5 - set curso
828
    uint32_t old;
8687 turbocat 829
    asm_inline(
830
        "int $0x40"
831
        :"=a"(old)
832
        :"a"(37), "b"(5), "c"(cursor)
833
    );
834
    return old;
835
}
9093 turbocat 836
 
837
static inline
838
int _ksys_delete_cursor(uint32_t cursor){ // subfunction 6 - delete curso
8687 turbocat 839
    int ret;
840
    asm_inline(
841
        "int $0x40"
842
        :"=a"(ret)
843
        :"a"(37), "b"(6), "c"(cursor)
844
        :"memory"
845
    );
846
    return ret;
847
}
848
 
849
static inline
9093 turbocat 850
uint32_t _ksys_get_mouse_wheels(void)  // subfunction 7 - get scroll data
8687 turbocat 851
{
9093 turbocat 852
    uint32_t val;
8687 turbocat 853
    asm_inline(
854
        "int $0x40"
855
        :"=a"(val)
9093 turbocat 856
        :"a"(37),"b"(7)
8687 turbocat 857
    );
858
    return val;
859
}
860
 
9093 turbocat 861
/*=========== Function 40 - set the mask for expected events. ==========*/
8687 turbocat 862
 
9093 turbocat 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,
872
    KSYS_EVM_DEBUG      = 256,
873
    KSYS_EVM_STACK2     = 512,
874
    KSYS_EVM_MOUSE_FILTER  = 0x80000000,
875
    KSYS_EVM_CURSOR_FILTER = 0x40000000,
876
};
8687 turbocat 877
 
878
static inline
9093 turbocat 879
uint32_t _ksys_set_event_mask(uint32_t mask){
8687 turbocat 880
    unsigned val;
881
    asm_inline(
882
        "int $0x40"
883
        :"=a"(val)
884
        :"a"(40), "b"(mask)
885
    );
886
    return val;
887
}
888
 
9093 turbocat 889
/*====================== Function 38 - draw line. ======================*/
890
 
8687 turbocat 891
static inline
9093 turbocat 892
void _ksys_draw_line(int xs, int ys, int xe, int ye, ksys_color_t color)
8687 turbocat 893
{
894
    asm_inline(
895
        "int $0x40"
9093 turbocat 896
        ::"a"(38), "d"(color),
897
        "b"((xs << 16) | xe),
898
        "c"((ys << 16) | ye)
8687 turbocat 899
    );
900
}
9093 turbocat 901
 
902
/*============= Function 47 - draw a number in the window. =============*/
903
 
8687 turbocat 904
static inline
9093 turbocat 905
void _ksys_draw_number(int number, int x, int y, int len, ksys_color_t color){
906
    unsigned fmt;
907
    fmt = len << 16 | 0x80000000; // no leading zeros + width
8687 turbocat 908
    asm_inline(
909
        "int $0x40"
9093 turbocat 910
        ::"a"(47), "b"(fmt), "c"(number), "d"((x << 16) | y), "S"(color)
8687 turbocat 911
    );
912
}
9093 turbocat 913
 
8687 turbocat 914
static inline
9093 turbocat 915
void _ksys_draw_number_bg(unsigned number, int x, int y, int len, ksys_color_t color, ksys_color_t bg){
916
    unsigned fmt;
917
    fmt = len << 16 | 0x80000000; // no leading zeros + width
8687 turbocat 918
    asm_inline(
919
        "int $0x40"
9093 turbocat 920
        ::"a"(47), "b"(fmt), "c"(number), "d"((x << 16) | y), "S"(color), "D"(bg)
8687 turbocat 921
    );
922
}
923
 
9093 turbocat 924
/*====== Function 48, subfunction 3 - get standard window colors. ======*/
925
 
926
static inline
927
void _ksys_get_system_colors(ksys_colors_table_t *color_table)
8687 turbocat 928
{
929
    asm_inline(
9093 turbocat 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
 
937
static inline
938
uint32_t _ksys_get_skin_height(){
939
    unsigned height;
940
    asm_inline(
8687 turbocat 941
        "int $0x40"
9093 turbocat 942
        :"=a"(height)
943
        :"a"(48),"b"(4)
8687 turbocat 944
    );
9093 turbocat 945
    return height;
8687 turbocat 946
}
9093 turbocat 947
 
948
/*==================== Function 51 - create thread. ====================*/
949
 
950
static inline
951
int _ksys_start_thread(void* thread_entry, void* stack_top){
952
    int val;
8687 turbocat 953
    asm_inline(
954
        "int $0x40"
955
        :"=a"(val)
9093 turbocat 956
        :"a"(51), "b"(1), "c"(thread_entry), "d"(stack_top)
8687 turbocat 957
    );
958
    return val;
959
}
960
 
961
 
9093 turbocat 962
/*==================== Function 54, subfunction 0 ======================*/
963
/*============== Get the number of slots in the clipboard. =============*/
964
 
965
enum KSYS_CLIP_ENCODING{
966
    KSYS_CLIP_UTF8 = 0,
967
    KSYS_CLIP_CP866 = 1,
968
    KSYS_CLIP_CP1251 = 2
969
};
970
 
971
enum KSYS_CLIP_TYPES{
972
    KSYS_CLIP_TEXT = 0,
973
    KSYS_CLIP_IMAGE = 1,
974
    KSYS_CLIP_RAW = 2
975
};
976
 
8687 turbocat 977
static inline
9093 turbocat 978
int _ksys_clip_num(){
8687 turbocat 979
    unsigned val;
980
    asm_inline(
981
        "int $0x40"
982
        :"=a"(val)
983
        :"a"(54), "b"(0)
984
    );
985
    return val;
986
}
987
 
9093 turbocat 988
/*==================== Function 54, subfunction 1 ======================*/
989
/*================= Read the data from the clipboard. ==================-*/
990
 
8687 turbocat 991
static inline
9093 turbocat 992
char* _ksys_clip_get(int n) {  // returned buffer must be freed by _ksys_free()
8687 turbocat 993
    char* val;
994
    asm_inline(
995
        "int $0x40"
996
        :"=a"(val)
997
        :"a"(54), "b"(1), "c"(n)
998
    );
999
    return val;
1000
}
1001
 
9093 turbocat 1002
/*==================== Function 54, subfunction 2 ======================*/
1003
/*================= Write the data to the clipboard. ===================*/
1004
 
8687 turbocat 1005
static inline
9093 turbocat 1006
int _ksys_clip_set(int n, char *buffer){
8687 turbocat 1007
    unsigned val;
1008
    asm_inline(
1009
        "int $0x40"
1010
        :"=a"(val)
1011
        :"a"(54), "b"(2), "c"(n), "d"(buffer)
1012
        :"memory"
1013
    );
1014
    return val;
1015
}
1016
 
9093 turbocat 1017
/*===================== Function 54, subfunction 3 =====================*/
1018
/*================ Delete the last slot in the clipboard ===============*/
1019
 
8687 turbocat 1020
static inline
9093 turbocat 1021
int _ksys_clip_pop(){
8687 turbocat 1022
    unsigned val;
1023
    asm_inline (
1024
        "int $0x40"
1025
        :"=a"(val)
1026
        :"a"(54), "b"(3)
1027
    );
1028
    return val;
1029
}
1030
 
9093 turbocat 1031
/*===================== Function 54, subfunction 4 =====================*/
1032
/*===================== Alarm reset the lock buffer ====================*/
1033
 
8687 turbocat 1034
static inline
9093 turbocat 1035
int _ksys_clip_unlock(){
8687 turbocat 1036
    unsigned val;
1037
    asm_inline(
1038
        "int $0x40"
1039
        :"=a"(val)
1040
        :"a"(54), "b"(4)
1041
    );
1042
    return val;
1043
}
1044
 
9093 turbocat 1045
/*============== Function 63 - work with the debug board. ==============*/
8687 turbocat 1046
 
1047
static inline
9093 turbocat 1048
void _ksys_debug_putc(char c){
1049
    asm_inline("int $0x40"::"a"(63), "b"(1), "c"(c));
8687 turbocat 1050
}
1051
 
1052
static inline
9093 turbocat 1053
void _ksys_debug_puts(char *s){
1054
    unsigned i=0;
1055
    while (*(s+i)){
1056
        asm_inline ("int $0x40"::"a"(63), "b"(1), "c"(*(s+i)));
1057
        i++;
1058
    }
8687 turbocat 1059
}
1060
 
9093 turbocat 1061
/*========= Function 67 - change position/sizes of the window. =========*/
1062
 
8687 turbocat 1063
static inline
9093 turbocat 1064
void _ksys_change_window(int new_x, int new_y, int new_w, int new_h){
8687 turbocat 1065
    asm_inline(
1066
        "int $0x40"
9093 turbocat 1067
        ::"a"(67), "b"(new_x), "c"(new_y), "d"(new_w),"S"(new_h)
8687 turbocat 1068
    );
1069
}
1070
 
9093 turbocat 1071
/*======== Function 68, subfunction 12 - allocate memory block. ========*/
8687 turbocat 1072
 
1073
static inline
1074
void* _ksys_alloc(size_t size){
1075
    void  *val;
1076
    asm_inline(
1077
        "int $0x40"
1078
        :"=a"(val)
1079
        :"a"(68),"b"(12),"c"(size)
1080
    );
1081
    return val;
1082
}
9093 turbocat 1083
 
1084
/*========== Function 68, subfunction 13 - free memory block. ==========*/
1085
 
8687 turbocat 1086
static inline
9093 turbocat 1087
int _ksys_free(void *mem){
8687 turbocat 1088
    int val;
1089
    asm_inline(
1090
        "int $0x40"
1091
        :"=a"(val)
1092
        :"a"(68),"b"(13),"c"(mem)
1093
    );
1094
    return val;
1095
}
1096
 
9093 turbocat 1097
/*============= Function 68, subfunction 16 - load driver. =============*/
1098
 
8687 turbocat 1099
static inline
9093 turbocat 1100
ksys_drv_hand_t _ksys_load_driver(char *driver_name)
8687 turbocat 1101
{
9093 turbocat 1102
    ksys_drv_hand_t driver_h;
8687 turbocat 1103
    asm_inline(
1104
        "int $0x40"
9093 turbocat 1105
        :"=a"(driver_h)
1106
        :"a"(68), "b"(16), "c"(driver_name)
8687 turbocat 1107
    );
9093 turbocat 1108
    return driver_h;
8687 turbocat 1109
}
9093 turbocat 1110
 
1111
/*============ Function 68, subfunction 17 - driver control. ===========*/
1112
 
8687 turbocat 1113
static inline
9093 turbocat 1114
unsigned _ksys_driver_control(ksys_ioctl_t *ioctl)
8687 turbocat 1115
{
9093 turbocat 1116
    unsigned status;
8687 turbocat 1117
    asm_inline(
1118
        "int $0x40"
9093 turbocat 1119
        :"=a"(status)
1120
        :"a"(68), "b"(17), "c"(ioctl)
1121
        :"memory"
8687 turbocat 1122
    );
9093 turbocat 1123
    return status;
8687 turbocat 1124
}
1125
 
9093 turbocat 1126
/*== Function 68, subfunction 18 - subfunction 19 - load DLL (MS COFF) ==*/
8687 turbocat 1127
 
1128
static inline
9093 turbocat 1129
ksys_dll_t* _ksys_dlopen(const char* path){
1130
    ksys_dll_t *table;
8687 turbocat 1131
    asm_inline(
1132
        "int $0x40"
1133
        :"=a"(table)
1134
        :"a"(68),"b"(19), "c"(path)
1135
        :"memory"
1136
    );
1137
    return table;
1138
}
1139
 
9093 turbocat 1140
/* It is not a system call, it serves as an auxiliary tool*/
1141
 
8687 turbocat 1142
static inline
9093 turbocat 1143
void* _ksys_dlsym(ksys_dll_t *table, const char* fun_name){
8687 turbocat 1144
    unsigned i=0;
1145
    while (1){
9093 turbocat 1146
        if (!(table+i)->func_name){
8687 turbocat 1147
            break;
1148
        }else{
1149
            if (!_ksys_strcmp(fun_name, (table+i)->func_name)){
1150
                return (table+i)->func_ptr;
1151
            }
1152
        }
1153
        i++;
1154
    }
1155
    return NULL;
1156
}
1157
 
9093 turbocat 1158
/* Function 68, subfunction 20 - reallocate memory block.*/
8687 turbocat 1159
 
1160
static inline
9093 turbocat 1161
void* _ksys_realloc(void *mem, size_t size){
1162
    void *val;
8687 turbocat 1163
    asm_inline(
1164
        "int $0x40"
1165
        :"=a"(val)
9093 turbocat 1166
        :"a"(68),"b"(20),"c"(size),"d"(mem)
1167
        :"memory"
8687 turbocat 1168
    );
1169
    return val;
1170
}
9093 turbocat 1171
 
1172
/* Function 68, subfunction 21 - load driver by full name. */
1173
 
1174
static inline
1175
ksys_drv_hand_t _ksys_load_driver_opt(char *driver_path, char *cmd_line)
1176
{
1177
    ksys_drv_hand_t driver_h;
8687 turbocat 1178
    asm_inline(
1179
        "int $0x40"
9093 turbocat 1180
        :"=a"(driver_h)
1181
        :"a"(68), "b"(21), "c"(driver_path), "d"(cmd_line)
8687 turbocat 1182
    );
9093 turbocat 1183
    return driver_h;
8687 turbocat 1184
}
1185
 
9093 turbocat 1186
/*======== Function 68, subfunction 22 - open named memory area. =======*/
1187
 
1188
enum KSYS_SHM_MODE{
1189
    KSYS_SHM_OPEN = 0x00,
1190
    KSYS_SHM_OPEN_ALWAYS = 0x04,
1191
    KSYS_SHM_CREATE = 0x08,
1192
    KSYS_SHM_READ = 0x00,
1193
    KSYS_SHM_WRITE = 0x01,
1194
};
1195
 
1196
static inline
1197
int _ksys_shm_open(char *name, int mode, int size, char **new_shm)
8687 turbocat 1198
{
9093 turbocat 1199
    int error;
8687 turbocat 1200
    asm_inline(
1201
        "int $0x40"
9093 turbocat 1202
        :"=a"(*new_shm), "=d"(error)
1203
        :"a"(68), "b"(22), "c"(name), "d"(size), "S"(mode)
8687 turbocat 1204
    );
9093 turbocat 1205
    return error;
8687 turbocat 1206
}
1207
 
9093 turbocat 1208
/*======= Function 68, subfunction 23 - close named memory area. =======*/
1209
 
8687 turbocat 1210
static inline
9093 turbocat 1211
void _ksys_shm_close(char *shm_name)
8687 turbocat 1212
{
9093 turbocat 1213
    asm_inline(
1214
        "int $0x40":
1215
        :"a"(68), "b"(23), "c"(shm_name)
1216
    );
8687 turbocat 1217
}
1218
 
9093 turbocat 1219
/*====== Function 68, subfunction 26 - release memory pages ============*/
8687 turbocat 1220
 
9093 turbocat 1221
static inline
1222
int* _ksys_unmap(void *base, size_t offset, size_t size){
1223
    int  *val;
8687 turbocat 1224
    asm_inline(
1225
        "int $0x40"
9093 turbocat 1226
        :"=a"(val)
1227
        :"a"(68),"b"(26),"c"(base),"d"(offset),"S"(size)
8687 turbocat 1228
    );
1229
    return val;
1230
}
1231
 
9093 turbocat 1232
/*========== Function 68, subfunction 27 - load file ===================*/
1233
 
8687 turbocat 1234
static inline
1235
ksys_ufile_t _ksys_load_file(const char *path)
1236
{
1237
    ksys_ufile_t uf;
1238
    asm_inline(
1239
        "int $0x40"
1240
        :"=a"(uf.data), "=d"(uf.size)
1241
        :"a"(68), "b"(27),"c"(path)
1242
        :"memory"
1243
    );
1244
    return uf;
1245
}
1246
 
9093 turbocat 1247
/*==== Function 68, subfunction 28 - load file, specifying the encoding ===*/
1248
 
8687 turbocat 1249
static inline
1250
ksys_ufile_t _ksys_load_file_enc(const char *path, unsigned file_encoding)
1251
{
1252
    ksys_ufile_t uf;
1253
    asm_inline(
1254
        "int $0x40"
1255
        :"=a"(uf.data), "=d"(uf.size)
1256
        :"a"(68), "b"(28),"c"(path), "d"(file_encoding)
1257
        :"memory"
1258
    );
1259
    return uf;
1260
}
1261
 
9093 turbocat 1262
/*==== Function 70 - work with file system with long names support. ====*/
1263
 
8687 turbocat 1264
static inline
1265
int _ksys_work_files(const ksys70_t *k)
1266
{
1267
    int status;
1268
    asm_inline(
1269
        "int $0x40"
1270
        :"=a"(status)
1271
        :"a"(70), "b"(k)
1272
        :"memory"
1273
    );
1274
    return status;
1275
}
1276
 
9093 turbocat 1277
/*====== Function 70, subfunction 0 - read file with long names support. ======*/
1278
 
8687 turbocat 1279
static inline
1280
int _ksys_file_read_file(const char *name, unsigned long long offset, unsigned size, void *buf, unsigned *bytes_read)
1281
{
1282
    ksys70_t k;
1283
    k.p00 = 0;
1284
    k.p04 = offset;
1285
    k.p12 = size;
1286
    k.buf16 = buf;
1287
    k.p20 = 0;
1288
    k.p21 = name;
1289
    int status;
1290
    unsigned bytes_read_v;
8730 turbocat 1291
    asm_inline(
1292
        "int $0x40"
1293
        :"=a"(status), "=b"(bytes_read_v)
1294
        :"a"(70), "b"(&k)
1295
        :"memory"
1296
    );
8687 turbocat 1297
    if (!status) {
1298
        *bytes_read = bytes_read_v;
1299
    }
1300
    return status;
1301
}
1302
 
9093 turbocat 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. ==========*/
1317
 
8687 turbocat 1318
static inline
1319
int _ksys_file_write_file(const char *name, unsigned long long offset, unsigned size, const void *buf, unsigned *bytes_written)
1320
{
1321
    ksys70_t k;
1322
    k.p00 = 3;
1323
    k.p04 = offset;
1324
    k.p12 = size;
1325
    k.cbuf16 = buf;
1326
    k.p20 = 0;
1327
    k.p21 = name;
1328
    int status;
1329
    unsigned bytes_written_v;
1330
    asm_inline(
1331
        "int $0x40"
1332
        :"=a"(status), "=b"(bytes_written_v)
1333
        :"a"(70), "b"(&k)
1334
        :"memory"
1335
    );
1336
    if (!status) {
1337
        *bytes_written = bytes_written_v;
1338
    }
1339
    return status;
1340
}
1341
 
9093 turbocat 1342
/*========== Function 70, subfunction 5 - get information on file/folder. =====*/
8687 turbocat 1343
 
1344
static inline
1345
int _ksys_file_get_info(const char *name, ksys_bdfe_t *bdfe)
1346
{
1347
    ksys70_t k;
1348
    k.p00 = 5;
1349
    k.bdfe = bdfe;
1350
    k.p20 = 0;
1351
    k.p21 = name;
1352
    return _ksys_work_files(&k);
1353
}
1354
 
9093 turbocat 1355
/*=========== Function 70, subfunction 7 - start application. ===========*/
1356
 
8687 turbocat 1357
static inline
9093 turbocat 1358
int _ksys_exec(char *app_name, char *args)
8687 turbocat 1359
{
9093 turbocat 1360
    ksys70_t file_opt;
1361
    file_opt.p00 = 7;
1362
    file_opt.p04dw = 0;
1363
    file_opt.p08dw = (unsigned)args;
1364
    file_opt.p21 = app_name;
1365
    return _ksys_work_files(&file_opt);
8687 turbocat 1366
}
1367
 
9093 turbocat 1368
/*========== Function 70, subfunction 8 - delete file/folder. ==========*/
1369
 
8687 turbocat 1370
static inline
9093 turbocat 1371
int _ksys_file_delete(const char *name)
8687 turbocat 1372
{
1373
    ksys70_t k;
9093 turbocat 1374
    k.p00 = 8;
8687 turbocat 1375
    k.p20 = 0;
1376
    k.p21 = name;
1377
    return _ksys_work_files(&k);
1378
}
1379
 
9093 turbocat 1380
/*============= Function 70, subfunction 9 - create folder. ============*/
8687 turbocat 1381
 
1382
static inline
1383
int _ksys_mkdir(const char *path)
1384
{
1385
    ksys70_t dir_opt;
1386
    dir_opt.p00 = 9;
1387
    dir_opt.p21 = path;
1388
    return _ksys_work_files(&dir_opt);
1389
}
1390
 
9093 turbocat 1391
/*============= Function 70, subfunction 10 - rename/move. =============*/
8687 turbocat 1392
 
1393
static inline
9093 turbocat 1394
int _ksys_file_rename(const char *name, const char *new_name)
8687 turbocat 1395
{
9093 turbocat 1396
    ksys70_t k;
1397
    k.p00 = 10;
1398
    k.new_name = new_name;
1399
    k.p20 = 0;
1400
    k.p21 = name;
1401
    return _ksys_work_files(&k);
8687 turbocat 1402
}
1403
 
1404
 
9093 turbocat 1405
/* ######### Old names of functions and structures. Do not use again! ##########*/
8699 turbocat 1406
 
9093 turbocat 1407
#define ksys_coff_etable_t ksys_dll_t
1408
#define ksys_proc_table_t  ksys_thread_t
1409
#define _ksys_get_event    _ksys_wait_event
8699 turbocat 1410
 
8687 turbocat 1411
#endif // _KSYS_H_