Subversion Repositories Kolibri OS

Rev

Rev 9786 | Rev 9830 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9786 Rev 9829
Line -... Line 1...
-
 
1
#ifndef _KSYS_H_
-
 
2
#define _KSYS_H_
-
 
3
 
1
/* Copyright (C) KolibriOS team 2004-2021. All rights reserved. */
4
/* Copyright (C) KolibriOS team 2004-2021. All rights reserved. */
2
/* Distributed under terms of the GNU General Public License    */
5
/* Distributed under terms of the GNU General Public License    */
Line 3... Line 6...
3
 
6
 
4
/* This file contains basic wrappers over KolibriOS system calls. */
7
/* This file contains basic wrappers over KolibriOS system calls. */
Line 14... Line 17...
14
 
17
 
15
 * Warning! The end of the file is the old definitions of function/structure names.
18
 * Warning! The end of the file is the old definitions of function/structure names.
16
 * They are for compatibility... Better not to use them.
19
 * They are for compatibility... Better not to use them.
Line 17... Line -...
17
*/
-
 
18
 
-
 
19
#ifndef _KSYS_H_
-
 
20
#define _KSYS_H_
20
*/
21
 
21
 
Line 22... Line 22...
22
#include 
22
#include 
23
#include 
23
#include 
Line 191... Line 191...
191
typedef struct {
191
typedef struct {
192
    char key[64];
192
    char key[64];
193
    char path[64];
193
    char path[64];
194
} ksys_dir_key_t;
194
} ksys_dir_key_t;
Line -... Line 195...
-
 
195
 
-
 
196
typedef union {
-
 
197
    uint8_t raw_data[24];
-
 
198
    struct {
-
 
199
        uint32_t id;
-
 
200
        uint8_t data[20];
-
 
201
    };
-
 
202
} ksys_signal_info_t;
195
 
203
 
Line 196... Line 204...
196
#pragma pack(pop)
204
#pragma pack(pop)
Line 197... Line 205...
197
 
205
 
Line 235... Line 243...
235
    KSYS_TITLE_CP866 = 1,
243
    KSYS_TITLE_CP866 = 1,
236
    KSYS_TITLE_UTF16LE = 2,
244
    KSYS_TITLE_UTF16LE = 2,
237
    KSYS_TITLE_UTF8 = 3
245
    KSYS_TITLE_UTF8 = 3
238
};
246
};
Line -... Line 247...
-
 
247
 
-
 
248
enum KSYS_SCANCODES {
-
 
249
    KSYS_SCANCODE_ANY = 0,
-
 
250
    KSYS_SCANCODE_ESC = 1,
-
 
251
    KSYS_SCANCODE_1 = 2,
-
 
252
    KSYS_SCANCODE_2 = 3,
-
 
253
    KSYS_SCANCODE_3 = 4,
-
 
254
    KSYS_SCANCODE_4 = 5,
-
 
255
    KSYS_SCANCODE_5 = 6,
-
 
256
    KSYS_SCANCODE_6 = 7,
-
 
257
    KSYS_SCANCODE_7 = 8,
-
 
258
    KSYS_SCANCODE_8 = 9,
-
 
259
    KSYS_SCANCODE_9 = 10,
-
 
260
    KSYS_SCANCODE_0 = 11,
-
 
261
    KSYS_SCANCODE_MINUS = 12,
-
 
262
    KSYS_SCANCODE_EQUAL = 13,
-
 
263
    KSYS_SCANCODE_BACKSPACE = 14,
-
 
264
    KSYS_SCANCODE_TAB = 15,
-
 
265
    KSYS_SCANCODE_Q = 16,
-
 
266
    KSYS_SCANCODE_W = 17,
-
 
267
    KSYS_SCANCODE_E = 18,
-
 
268
    KSYS_SCANCODE_R = 19,
-
 
269
    KSYS_SCANCODE_T = 20,
-
 
270
    KSYS_SCANCODE_Y = 21,
-
 
271
    KSYS_SCANCODE_U = 22,
-
 
272
    KSYS_SCANCODE_I = 23,
-
 
273
    KSYS_SCANCODE_O = 24,
-
 
274
    KSYS_SCANCODE_P = 25,
-
 
275
    KSYS_SCANCODE_LBRACE = 26,
-
 
276
    KSYS_SCANCODE_RBRACE = 27,
-
 
277
    KSYS_SCANCODE_ENTER = 28,
-
 
278
     KSYS_SCANCODE_EXT_NUMPAD_ENTER = 28,
-
 
279
    KSYS_SCANCODE_LCTRL = 29,
-
 
280
     KSYS_SCANCODE_EXT_RCTRL = 29,
-
 
281
    KSYS_SCANCODE_A = 30,
-
 
282
    KSYS_SCANCODE_S = 31,
-
 
283
    KSYS_SCANCODE_D = 32,
-
 
284
    KSYS_SCANCODE_F = 33,
-
 
285
    KSYS_SCANCODE_G = 34,
-
 
286
    KSYS_SCANCODE_H = 35,
-
 
287
    KSYS_SCANCODE_J = 36,
-
 
288
    KSYS_SCANCODE_K = 37,
-
 
289
    KSYS_SCANCODE_L = 38,
-
 
290
    KSYS_SCANCODE_SEMICOLON = 39,
-
 
291
    KSYS_SCANCODE_SQUOTE = 40,
-
 
292
    KSYS_SCANCODE_BQUOTE = 41,
-
 
293
    KSYS_SCANCODE_LSHIFT = 42,
-
 
294
    KSYS_SCANCODE_BACKSLASH = 43,
-
 
295
    KSYS_SCANCODE_Z = 44,
-
 
296
    KSYS_SCANCODE_X = 45,
-
 
297
    KSYS_SCANCODE_C = 46,
-
 
298
    KSYS_SCANCODE_V = 47,
-
 
299
    KSYS_SCANCODE_B = 48,
-
 
300
    KSYS_SCANCODE_N = 49,
-
 
301
    KSYS_SCANCODE_M = 50,
-
 
302
    KSYS_SCANCODE_COMMA = 51,
-
 
303
    KSYS_SCANCODE_POINT = 52,
-
 
304
    KSYS_SCANCODE_SLASH = 53,
-
 
305
     KSYS_SCANCODE_EXT_NUMPAD_DIV = 53,
-
 
306
    KSYS_SCANCODE_RSHIFT = 54,
-
 
307
    KSYS_SCANCODE_NUMPAD_MULT = 55,
-
 
308
     KSYS_SCANCODE_EXT_PRTSCR = 55,
-
 
309
    KSYS_SCANCODE_LALT = 56,
-
 
310
     KSYS_SCANCODE_EXT_RALT = 56,
-
 
311
    KSYS_SCANCODE_SPACE = 57,
-
 
312
    KSYS_SCANCODE_CAPSLOCK = 58,
-
 
313
    KSYS_SCANCODE_F1 = 59,
-
 
314
    KSYS_SCANCODE_F2 = 60,
-
 
315
    KSYS_SCANCODE_F3 = 61,
-
 
316
    KSYS_SCANCODE_F4 = 62,
-
 
317
    KSYS_SCANCODE_F5 = 63,
-
 
318
    KSYS_SCANCODE_F6 = 64,
-
 
319
    KSYS_SCANCODE_F7 = 65,
-
 
320
    KSYS_SCANCODE_F8 = 66,
-
 
321
    KSYS_SCANCODE_F9 = 67,
-
 
322
    KSYS_SCANCODE_F10 = 68,
-
 
323
    KSYS_SCANCODE_NUMLOCK = 69,
-
 
324
    KSYS_SCANCODE_SCRLOCK = 70,
-
 
325
    KSYS_SCANCODE_NUMPAD_7 = 71,
-
 
326
     KSYS_SCANCODE_EXT_HOME = 71,
-
 
327
    KSYS_SCANCODE_NUMPAD_8 = 72,
-
 
328
     KSYS_SCANCODE_EXT_UP = 72,
-
 
329
    KSYS_SCANCODE_NUMPAD_9 = 73,
-
 
330
     KSYS_SCANCODE_EXT_PGUP = 73,
-
 
331
    KSYS_SCANCODE_NUMPAD_MINUS = 74,
-
 
332
    KSYS_SCANCODE_NUMPAD_4 = 75,
-
 
333
     KSYS_SCANCODE_EXT_LEFT = 75,
-
 
334
    KSYS_SCANCODE_NUMPAD_5 = 76,
-
 
335
    KSYS_SCANCODE_NUMPAD_6 = 77,
-
 
336
     KSYS_SCANCODE_EXT_RIGHT = 77,
-
 
337
    KSYS_SCANCODE_NUMPAD_PLUS = 78,
-
 
338
    KSYS_SCANCODE_NUMPAD_1 = 79,
-
 
339
     KSYS_SCANCODE_EXT_END = 79,
-
 
340
    KSYS_SCANCODE_NUMPAD_2 = 80,
-
 
341
     KSYS_SCANCODE_EXT_DOWN = 80,
-
 
342
    KSYS_SCANCODE_NUMPAD_3 = 81,
-
 
343
     KSYS_SCANCODE_EXT_PGDOWN = 81,
-
 
344
    KSYS_SCANCODE_NUMPAD_0 = 82,
-
 
345
     KSYS_SCANCODE_EXT_INSERT = 82,
-
 
346
    KSYS_SCANCODE_NUMPAD_COMMA = 83,
-
 
347
     KSYS_SCANCODE_EXT_DELETE = 83,
-
 
348
    //84-86 doesn't exist
-
 
349
    KSYS_SCANCODE_F11 = 87,
-
 
350
    KSYS_SCANCODE_F12 = 88,
-
 
351
    //89,90 doesn't exist
-
 
352
    KSYS_SCANCODE_EXT_LWIN = 91,
-
 
353
    KSYS_SCANCODE_EXT_RWIN = 92,
-
 
354
    KSYS_SCANCODE_EXT_MENU = 93,
-
 
355
	KSYS_SCANCODE_EXT = 0xE0,
-
 
356
 
-
 
357
    KSYS_SCANCODE_UNK_M_UP = 250 // Is it needed?
-
 
358
};
239
 
359
 
240
KOSAPI int __strcmp(const char* s1, const char* s2)
360
KOSAPI int __strcmp(const char* s1, const char* s2)
241
{
361
{
242
    while ((*s1) && (*s1 == *s2)) {
362
    while ((*s1) && (*s1 == *s2)) {
243
        ++s1;
363
        ++s1;
Line 352... Line 472...
352
        "int $0x40" ::"a"(8), "d"(id & 0x00FFFFFF | 0x80000000));
472
        "int $0x40" ::"a"(8), "d"(id & 0x00FFFFFF | 0x80000000));
353
}
473
}
Line 354... Line 474...
354
 
474
 
Line -... Line 475...
-
 
475
/*============ Function 9 - information on execution thread. ===========*/
-
 
476
 
-
 
477
#define KSYS_THIS_SLOT -1
-
 
478
 
-
 
479
enum KSYS_SLOT_STATES {
-
 
480
    KSYS_SLOT_STATE_RUNNING = 0,
-
 
481
    KSYS_SLOT_STATE_SUSPENDED = 1,
-
 
482
    KSYS_SLOT_STATE_SUSPENDED_WAIT_EVENT = 2,
-
 
483
    KSYS_SLOT_STATE_NORMAL_TERM = 3,
-
 
484
    KSYS_SLOT_STATE_EXCEPT_TERM = 4,
-
 
485
    KSYS_SLOT_STATE_WAIT_EVENT = 5,
-
 
486
    KSYS_SLOT_STATE_FREE = 6
355
/*============ Function 9 - information on execution thread. ===========*/
487
};
356
 
488
 
357
KOSAPI int _ksys_thread_info(ksys_thread_t* table, int slot)
489
KOSAPI int _ksys_thread_info(ksys_thread_t* table, int slot)
358
{
490
{
359
    int val;
491
    int val;
Line 1070... Line 1202...
1070
        : "=a"(key_state)
1202
        : "=a"(key_state)
1071
        : "a"(66), "b"(3));
1203
        : "a"(66), "b"(3));
1072
    return key_state;
1204
    return key_state;
1073
}
1205
}
Line -... Line 1206...
-
 
1206
 
-
 
1207
/*========= Function 66, subfunction 4 - set system-wide hotkey. ========*/
-
 
1208
 
-
 
1209
enum KSYS_SYS_HOTKEY_CONTROL_KEY_STATES {
-
 
1210
    KSYS_SYS_HOTKEY_SHIFT_NONE = 0x0,
-
 
1211
    KSYS_SYS_HOTKEY_SHIFT_ONE = 0x1,
-
 
1212
    KSYS_SYS_HOTKEY_SHIFT_BOTH = 0x2,
-
 
1213
    KSYS_SYS_HOTKEY_SHIFT_LEFTONLY = 0x3,
-
 
1214
    KSYS_SYS_HOTKEY_SHIFT_RIGHTONLY = 0x4,
-
 
1215
 
-
 
1216
    KSYS_SYS_HOTKEY_CTRL_NONE = 0x00,
-
 
1217
    KSYS_SYS_HOTKEY_CTRL_ONE = 0x10,
-
 
1218
    KSYS_SYS_HOTKEY_CTRL_BOTH = 0x20,
-
 
1219
    KSYS_SYS_HOTKEY_CTRL_LEFTONLY = 0x30,
-
 
1220
    KSYS_SYS_HOTKEY_CTRL_RIGHTONLY = 0x40,
-
 
1221
 
-
 
1222
    KSYS_SYS_HOTKEY_ALT_NONE = 0x000,
-
 
1223
    KSYS_SYS_HOTKEY_ALT_ONE = 0x100,
-
 
1224
    KSYS_SYS_HOTKEY_ALT_BOTH = 0x200,
-
 
1225
    KSYS_SYS_HOTKEY_ALT_LEFTONLY = 0x300,
-
 
1226
    KSYS_SYS_HOTKEY_ALT_RIGHTONLY = 0x400,
-
 
1227
};
-
 
1228
 
-
 
1229
KOSAPI int _ksys_set_sys_hotkey(uint8_t scancode, uint16_t control_key_states) {
-
 
1230
    int res;
-
 
1231
    asm_inline(
-
 
1232
        "int $0x40"
-
 
1233
        : "=a"(res)
-
 
1234
        : "a"(66), "b"(4), "c"(scancode), "d"(control_key_states)
-
 
1235
        : "memory");
-
 
1236
    return res;
-
 
1237
}
-
 
1238
 
-
 
1239
/*========= Function 66, subfunction 5 - delete installed hotkey. ========*/
-
 
1240
 
-
 
1241
KOSAPI int _ksys_del_sys_hotkey(uint8_t scancode, uint16_t control_key_states) {
-
 
1242
    int res;
-
 
1243
    asm_inline(
-
 
1244
        "int $0x40"
-
 
1245
        : "=a"(res)
-
 
1246
        : "a"(66), "b"(5), "c"(scancode), "d"(control_key_states)
-
 
1247
        : "memory");
-
 
1248
    return res;
-
 
1249
}
1074
 
1250
 
Line 1075... Line 1251...
1075
/*========= Function 67 - change position/sizes of the window. =========*/
1251
/*========= Function 67 - change position/sizes of the window. =========*/
1076
 
1252
 
1077
KOSAPI void _ksys_change_window(int new_x, int new_y, int new_w, int new_h)
1253
KOSAPI void _ksys_change_window(int new_x, int new_y, int new_w, int new_h)
1078
{
1254
{
1079
    asm_inline(
1255
    asm_inline(
Line -... Line 1256...
-
 
1256
        "int $0x40" ::"a"(67), "b"(new_x), "c"(new_y), "d"(new_w), "S"(new_h));
-
 
1257
}
-
 
1258
 
-
 
1259
/*===== Function 68, subfunction 1 - switch to the next thread of execution ====*/
-
 
1260
 
-
 
1261
KOSAPI void _ksys_thread_yield(void) 
-
 
1262
{
1080
        "int $0x40" ::"a"(67), "b"(new_x), "c"(new_y), "d"(new_w), "S"(new_h));
1263
    asm_inline("int $0x40" :: "a"(68),"b"(1));
Line 1081... Line 1264...
1081
}
1264
}
1082
 
1265
 
1083
/*======== Function 68, subfunction 12 - allocate memory block. ========*/
1266
/*======== Function 68, subfunction 12 - allocate memory block. ========*/
Line 1102... Line 1285...
1102
        : "=a"(val)
1285
        : "=a"(val)
1103
        : "a"(68), "b"(13), "c"(mem));
1286
        : "a"(68), "b"(13), "c"(mem));
1104
    return val;
1287
    return val;
1105
}
1288
}
Line -... Line 1289...
-
 
1289
 
-
 
1290
/*====== Function 68, subfunction 14 - Wait signal from other applications/drivers. =====*/
-
 
1291
 
-
 
1292
KOSAPI void _ksys_wait_signal(ksys_signal_info_t* signal)
-
 
1293
{
-
 
1294
    asm_inline("int $0x40" :: "a"(68),"b"(14),"c"(signal) : "memory");
-
 
1295
}
1106
 
1296
 
Line 1107... Line 1297...
1107
/*============= Function 68, subfunction 16 - load driver. =============*/
1297
/*============= Function 68, subfunction 16 - load driver. =============*/
1108
 
1298
 
1109
KOSAPI ksys_drv_hand_t _ksys_load_driver(char* driver_name)
1299
KOSAPI ksys_drv_hand_t _ksys_load_driver(char* driver_name)
Line 1352... Line 1542...
1352
    k.p20 = 0;
1542
    k.p20 = 0;
1353
    k.p21 = name;
1543
    k.p21 = name;
1354
    return _ksys70(&k).status;
1544
    return _ksys70(&k).status;
1355
}
1545
}
Line 1356... Line 1546...
1356
 
1546
 
Line 1357... Line 1547...
1357
/*============= Function 70, subfunction 9 - create folder. ============*/
1547
/*============= Function 70, subfunction 9 - create folder. =============*/
1358
 
1548
 
1359
KOSAPI int _ksys_mkdir(const char* path)
1549
KOSAPI int _ksys_mkdir(const char* path)
1360
{
1550
{
Line 1376... Line 1566...
1376
    return _ksys70(&k).status;
1566
    return _ksys70(&k).status;
1377
}
1567
}
Line 1378... Line 1568...
1378
 
1568
 
Line 1379... Line 1569...
1379
#define _ksys_dir_rename _ksys_file_rename
1569
#define _ksys_dir_rename _ksys_file_rename
Line 1380... Line 1570...
1380
 
1570
 
1381
/*============  Function 71, subfunction 1 - set window title ============= */
1571
/*============= Function 71, subfunction 1 - set window title =============*/
1382
 
1572
 
1383
KOSAPI void _ksys_set_window_title(const char* title)
1573
KOSAPI void _ksys_set_window_title(const char* title)
1384
{
1574
{
Line 1385... Line 1575...
1385
    asm_inline("int $0x40" ::"a"(71), "b"(1), "c"(title)
1575
    asm_inline("int $0x40" ::"a"(71), "b"(1), "c"(title)
Line -... Line 1576...
-
 
1576
               : "memory");
-
 
1577
}
-
 
1578
 
-
 
1579
#define _ksys_clear_window_title() _ksys_set_window_title(NULL)
-
 
1580
 
-
 
1581
/*============= Function 77, subfunction 0 - create futex object =============*/
-
 
1582
 
-
 
1583
KOSAPI void* _ksys_futex_create(void* futexControlAddr) {
-
 
1584
    void* futexDesc;
-
 
1585
    asm_inline(
-
 
1586
        "int $0x40"
-
 
1587
        : "=a"(futexDesc)
-
 
1588
        : "a"(77), "b"(0), "c"(futexControlAddr)
-
 
1589
        : "memory");
-
 
1590
    return futexDesc;
-
 
1591
}
-
 
1592
 
-
 
1593
/*============= Function 77, subfunction 1 - destroy futex object =============*/
-
 
1594
 
-
 
1595
KOSAPI int _ksys_futex_destroy(void* futexDesc) {
-
 
1596
    int res;
-
 
1597
    asm_inline(
-
 
1598
        "int $0x40"
-
 
1599
        : "=a"(res)
-
 
1600
        : "a"(77), "b"(1), "c"(futexDesc)
-
 
1601
        : "memory");
-
 
1602
    return res;
-
 
1603
}
-
 
1604
 
-
 
1605
/*============= Function 77, subfunction 2 - futex wait =============*/
-
 
1606
 
-
 
1607
KOSAPI int _ksys_futex_wait(void* futexDesc, int controlVal, int timeout) {
-
 
1608
    int res;
-
 
1609
    asm_inline(
-
 
1610
        "int $0x40"
-
 
1611
        : "=a"(res)
1386
               : "memory");
1612
        : "a"(77), "b"(2), "c"(futexDesc), "d"(controlVal), "S"(timeout)
-
 
1613
        : "memory");
-
 
1614
    return res;
-
 
1615
}
-
 
1616
 
-
 
1617
/*============= Function 77, subfunction 3 - futex wake =============*/
-
 
1618
 
-
 
1619
KOSAPI int _ksys_futex_wake(void* futexDesc, int maxWakeCount) {
-
 
1620
    int count;
-
 
1621
    asm_inline(
-
 
1622
        "int $0x40"
-
 
1623
        : "=a"(count)
-
 
1624
        : "a"(77), "b"(3), "c"(futexDesc), "d"(maxWakeCount)
Line 1387... Line 1625...
1387
}
1625
        : "memory");
1388
 
1626
    return count;
1389
#define _ksys_clear_window_title() _ksys_set_window_title(NULL)
1627
}
1390
 
1628
 
Line 1399... Line 1637...
1399
        : "a"(77), "b"(10), "c"(pipefd), "d"(buff), "S"(n)
1637
        : "a"(77), "b"(10), "c"(pipefd), "d"(buff), "S"(n)
1400
        : "memory");
1638
        : "memory");
1401
    return count;
1639
    return count;
1402
}
1640
}
Line -... Line 1641...
-
 
1641
 
-
 
1642
/*============= Function 77, subfunction 11 - write from buffer to file =============*/
1403
 
1643
 
1404
KOSAPI int _ksys_posix_write(int pipefd, void* buff, int n)
1644
KOSAPI int _ksys_posix_write(int pipefd, void* buff, int n)
1405
{
1645
{
1406
    int count;
1646
    int count;
1407
    asm_inline(
1647
    asm_inline(
Line 1410... Line 1650...
1410
        : "a"(77), "b"(11), "c"(pipefd), "d"(buff), "S"(n)
1650
        : "a"(77), "b"(11), "c"(pipefd), "d"(buff), "S"(n)
1411
        : "memory");
1651
        : "memory");
1412
    return count;
1652
    return count;
1413
}
1653
}
Line -... Line 1654...
-
 
1654
 
-
 
1655
/*============= Function 77, subfunction 13 - create new pipe =============*/
1414
 
1656
 
1415
KOSAPI int _ksys_posix_pipe2(int pipefd[2], int flags)
1657
KOSAPI int _ksys_posix_pipe2(int pipefd[2], int flags)
1416
{
1658
{
1417
    int err;
1659
    int err;
1418
    asm_inline(
1660
    asm_inline(