update ksys.h #355

Open
Egor00f wants to merge 4 commits from Egor00f/kolibrios:update-ksys.h into main
2 changed files with 587 additions and 14 deletions

View File

@@ -159,7 +159,7 @@ typedef struct {
typedef union {
struct {
uint32_t cpu_usage; // CPU usage (cycles per secondgoes)
uint32_t cpu_usage; // CPU usage (cycles per secondes)
uint16_t pos_in_window_stack; // position of the thread window in the window stack
uint16_t slot_num_window_stack; // slot number in window stack
uint16_t __reserved1; // reserved
@@ -240,6 +240,30 @@ typedef union {
};
} ksys_signal_info_t;
typedef struct {
uint8_t a, b, c, d;
uint8_t debug_label;
uint8_t ABI_low;
uint8_t ABI_high;
uint32_t commit_id;
uint16_t reserved;
uint16_t commit_count;
} ksys_kernel_version_t;
typedef struct
{
uint32_t total_ram_pages;
uint32_t free_ram_pages;
uint32_t page_faults;
uint32_t kernel_heap_size;
uint32_t kernel_heap_free;
uint32_t kernel_heap_total_blocks;
uint32_t kernel_heap_free_blocks;
uint32_t kernel_heap_largest_free_block;
uint32_t kernel_heap_largest_alloc_block;
} ksys_memory_info_t;
#pragma pack(pop)
typedef rgb_t ksys_bitmap_t;
@@ -785,6 +809,40 @@ KOSAPI void _ksys_shutdown(uint32_t shd_param)
asm_inline("int $0x40" ::"a"(18), "b"(9), "c"(shd_param));
}
/*====== Function 18, subfunction 10 - minimize current window. ========*/
KOSAPI void _ksys_minimize_current_windows()
{
asm_inline(
"int $0x40" ::"a"(18), "b"(10));
}
/*========== Function 18, subfunction 13 - get kernel version. =========*/
KOSAPI int _ksys_get_kernel_version(ksys_kernel_version_t* info)
{
int err;
asm_inline(
"int $0x40"
: "=a"(err)
: "a"(18), "b"(13), "c"(info)
: "memory");
return err;
}
/*========= Function 18, subfunction 15 - move mouse to center. ========*/
KOSAPI int _ksys_center_mouse()
{
int a;
asm_inline(
"int $0x40"
: "=a"(a)
: "a"(18), "b"(15));
return a;
}
/*========= Function 18, subfunction 16 - get size of free RAM. ========*/
KOSAPI size_t _ksys_get_ram_size(void)
@@ -843,6 +901,19 @@ KOSAPI uint32_t _ksys_set_mouse_settings(ksys_mouse_settings_t settings, uint32_
#define _ksys_set_mouse_pos(X, Y) _ksys_set_mouse_settings(KSYS_MOUSE_SET_POS, X * 65536 + Y)
/*===================== Function 18, subfunction 20 ====================*/
KOSAPI int _ksys_get_memory_info(ksys_memory_info_t* info)
{
int total;
asm_inline(
"int $0x40"
: "=a"(total)
: "a"(18), "b"(20), "c"(info)
: "memory");
return total;
}
/*===================== Function 18, subfunction 21 ====================*/
/*=====Get the slot number of the process / thread by identifier.. =====*/
@@ -856,6 +927,216 @@ KOSAPI int _ksys_get_thread_slot(int PID)
return val;
}
/*===================== Function 18, subfunction 22 ====================*/
typedef enum KSYS_WIN_REMOTE_CONTROL {
WIN_MINIMIZE_BY_SLOT = 0,
WIN_MINIMIZE_BY_PID = 1,
WIN_RESTORE_BY_SLOT = 2,
WIN_RESTORE_BY_PID = 3
} ksys_win_remote_control_t;
KOSAPI int _ksys_window_remote_control(ksys_win_remote_control_t type, uint32_t param)
{
int result;
asm_inline(
"int $0x40"
: "=a"(result)
: "a"(18), "b"(22), "c"(type), "d"(param));
return result;
}
/*===================== Function 18, subfunction 23 ====================*/
KOSAPI int _ksys_minimize_all_windows()
{
int count;
asm_inline(
"int $0x40"
: "=a"(count)
: "a"(18), "b"(23));
return count;
}
/*===================== Function 18, subfunction 24 ====================*/
KOSAPI void _ksys_set_draw_limits(unsigned int x, unsigned int y)
{
asm_inline(
"int $0x40" ::"a"(18), "b"(24), "c"(x), "d"(y));
}
/*===================== Function 18, subfunction 25 ====================*/
typedef enum KSYS_ZPOS {
KSYS_ZPOS_DESKTOP = -2,
KSYS_ZPOS_ALWAYS_BACK = -1,
KSYS_ZPOS_NORMAL = 0,
KSYS_ZPOS_ALWAYS_TOP = 1
} ksys_zpos_t;
/*=========== Function 18, subfunction 25, subsubfunction 1 ============*/
KOSAPI ksys_zpos_t _ksys_get_window_zposition(int32_t pid)
{
ksys_zpos_t result_eax;
asm_inline(
"int $0x40"
: "=a"(result_eax)
: "a"(18), "b"(25), "c"(1), "d"(pid));
return result_eax;
}
/*=========== Function 18, subfunction 25, subsubfunction 2 ============*/
KOSAPI int _ksys_set_window_zposition(int32_t pid, ksys_zpos_t position)
{
int err;
asm_inline(
"int $0x40"
: "=a"(err)
: "a"(18), "b"(25), "c"(2), "d"(pid), "S"(position));
return err;
}
/*==================== Function 21, subfunction 2 =====================*/
typedef enum KSYS_KEYBOARD_LAYOUT {
KSYS_KEYBOARD_LAYOUT_NORMAL = 1,
KSYS_KEYBOARD_LAYOUT_SHIFT = 2,
KSYS_KEYBOARD_LAYOUT_ALT = 3
} ksys_keyboard_layout_t;
KOSAPI int _ksys_set_keyboard_layout(ksys_keyboard_layout_t mode, char* table)
{
int err;
asm_inline(
"int $0x40"
: "=a"(err)
: "a"(21), "b"(2), "c"(mode), "d"(table));
return err;
}
typedef enum KSYS_LANG {
KSYS_LANG_ENG = 1,
KSYS_LANG_FI = 2,
KSYS_LANG_GER = 3,
KSYS_LANG_RU = 4
} ksys_lang_t;
KOSAPI int _ksys_set_keyboard_lang(ksys_lang_t lang)
{
int err;
asm_inline(
"int $0x40"
: "=a"(err)
: "a"(21), "b"(2), "c"(9), "d"(lang));
return err;
}
/*==================== Function 21, subfunction 5 =====================*/
KOSAPI int _ksys_set_lang(ksys_lang_t lang)
{
int err;
asm_inline(
"int $0x40"
: "=a"(err)
: "a"(21), "b"(5), "c"(lang));
return err;
}
/*==================== Function 21, subfunction 11 =====================*/
KOSAPI int _ksys_allow_HD(int param)
{
int err;
asm_inline(
"int $0x40"
: "=a"(err)
: "a"(21), "b"(11), "c"(param));
return err;
}
/*==================== Function 21, subfunction 12 =====================*/
KOSAPI int _ksys_allow_PCI(int param)
{
int err;
asm_inline(
"int $0x40"
: "=a"(err)
: "a"(21), "b"(12), "c"(param));
return err;
}
typedef enum KSYS_SET_TIME_ERR {
KSYS_SET_TIME_OK = 0,
KSYS_SET_TIME_WRONG_PARAM = 1,
KSYS_SET_TIME_CMOS = 2
} ksys_set_time_err;
/*============================ Function 22 ============================*/
KOSAPI ksys_set_time_err _ksys_set_time(ksys_time_bcd_t time)
{
ksys_set_time_err err;
asm_inline(
"int $0x40"
: "=a"(err)
: "a"(22), "b"(0), "c"(time));
}
KOSAPI ksys_set_time_err _ksys_set_date(ksys_date_bcd_t date)
{
ksys_set_time_err err;
asm_inline(
"int $0x40"
: "=a"(err)
: "a"(22), "b"(1), "c"(date));
}
/*========= Function 26, subfunction 2 - get keyboard layout. ==========*/
KOSAPI uint32_t _ksys_keyboard_layout(ksys_keyboard_layout_t layout, unsigned char* buf)
{
asm_inline("int $0x40" ::"a"(26), "b"(2), "c"(layout), "d"(buf) : "memory");
}
KOSAPI ksys_lang_t _ksys_get_keyboard_lang()
{
ksys_lang_t lang;
asm_inline(
"int $0x40"
: "=a"(lang)
: "a"(26), "b"(2), "c"(9));
return lang;
}
/*======= Function 26, subfunction 5 - get the system language. ========*/
KOSAPI ksys_lang_t _ksys_get_lang()
{
ksys_lang_t lang;
asm_inline(
"int $0x40"
: "=a"(lang)
: "a"(26), "b"(5));
return lang;
}
/*============= Function 23 - wait for event with timeout. =============*/
KOSAPI uint32_t _ksys_wait_event_timeout(uint32_t timeout)

View File

@@ -120,7 +120,7 @@ typedef struct {
typedef union {
struct {
uint32_t cpu_usage; // CPU usage (cycles per secondgoes)
uint32_t cpu_usage; // CPU usage (cycles per secondes)
uint16_t pos_in_window_stack; // position of the thread window in the window stack
uint16_t slot_num_window_stack; // slot number in window stack
uint16_t __reserved1; // reserved
@@ -214,6 +214,30 @@ typedef struct {
uint32_t pitch;
} ksys_blitter_params_t;
typedef struct {
uint8_t a, b, c, d;
uint8_t debug_label;
uint8_t ABI_low;
uint8_t ABI_high;
uint32_t commit_id;
uint16_t reserved;
uint16_t commit_count;
} ksys_kernel_version_t;
typedef struct
{
uint32_t total_ram_pages;
uint32_t free_ram_pages;
uint32_t page_faults;
uint32_t kernel_heap_size;
uint32_t kernel_heap_free;
uint32_t kernel_heap_total_blocks;
uint32_t kernel_heap_free_blocks;
uint32_t kernel_heap_largest_free_block;
uint32_t kernel_heap_largest_alloc_block;
} ksys_memory_info_t;
#pragma pack(pop)
typedef rgb_t ksys_bitmap_t;
@@ -759,6 +783,40 @@ KOSAPI void _ksys_shutdown(uint32_t shd_param)
asm_inline("int $0x40" ::"a"(18), "b"(9), "c"(shd_param));
}
/*====== Function 18, subfunction 10 - minimize current window. ========*/
KOSAPI void _ksys_minimize_current_windows()
{
asm_inline(
"int $0x40" ::"a"(18), "b"(10));
}
/*========== Function 18, subfunction 13 - get kernel version. =========*/
KOSAPI int _ksys_get_kernel_version(ksys_kernel_version_t* info)
{
int err;
asm_inline(
"int $0x40"
: "=a"(err)
: "a"(18), "b"(13), "c"(info)
: "memory");
return err;
}
/*========= Function 18, subfunction 15 - move mouse to center. ========*/
KOSAPI int _ksys_center_mouse()
{
int a;
asm_inline(
"int $0x40"
: "=a"(a)
: "a"(18), "b"(15));
return a;
}
/*========= Function 18, subfunction 16 - get size of free RAM. ========*/
KOSAPI size_t _ksys_get_ram_size(void)
@@ -817,6 +875,19 @@ KOSAPI uint32_t _ksys_set_mouse_settings(ksys_mouse_settings_t settings, uint32_
#define _ksys_set_mouse_pos(X, Y) _ksys_set_mouse_settings(KSYS_MOUSE_SET_POS, X * 65536 + Y)
/*===================== Function 18, subfunction 20 ====================*/
KOSAPI int _ksys_get_memory_info(ksys_memory_info_t* info)
{
int total;
asm_inline(
"int $0x40"
: "=a"(total)
: "a"(18), "b"(20), "c"(info)
: "memory");
return total;
}
/*===================== Function 18, subfunction 21 ====================*/
/*=====Get the slot number of the process / thread by identifier.. =====*/
@@ -830,6 +901,185 @@ KOSAPI int _ksys_get_thread_slot(int PID)
return val;
}
/*===================== Function 18, subfunction 22 ====================*/
typedef enum KSYS_WIN_REMOTE_CONTROL {
WIN_MINIMIZE_BY_SLOT = 0,
WIN_MINIMIZE_BY_PID = 1,
WIN_RESTORE_BY_SLOT = 2,
WIN_RESTORE_BY_PID = 3
} ksys_win_remote_control_t;
KOSAPI int _ksys_window_remote_control(ksys_win_remote_control_t type, uint32_t param)
{
int result;
asm_inline(
"int $0x40"
: "=a"(result)
: "a"(18), "b"(22), "c"(type), "d"(param));
return result;
}
/*===================== Function 18, subfunction 23 ====================*/
KOSAPI int _ksys_minimize_all_windows()
{
int count;
asm_inline(
"int $0x40"
: "=a"(count)
: "a"(18), "b"(23));
return count;
}
/*===================== Function 18, subfunction 24 ====================*/
KOSAPI void _ksys_set_draw_limits(unsigned int x, unsigned int y)
{
asm_inline(
"int $0x40" ::"a"(18), "b"(24), "c"(x), "d"(y));
}
/*===================== Function 18, subfunction 25 ====================*/
typedef enum KSYS_ZPOS {
KSYS_ZPOS_DESKTOP = -2,
KSYS_ZPOS_ALWAYS_BACK = -1,
KSYS_ZPOS_NORMAL = 0,
KSYS_ZPOS_ALWAYS_TOP = 1
} ksys_zpos_t;
/*=========== Function 18, subfunction 25, subsubfunction 1 ============*/
KOSAPI ksys_zpos_t _ksys_get_window_zposition(int32_t pid)
{
ksys_zpos_t result_eax;
asm_inline(
"int $0x40"
: "=a"(result_eax)
: "a"(18), "b"(25), "c"(1), "d"(pid));
return result_eax;
}
/*=========== Function 18, subfunction 25, subsubfunction 2 ============*/
KOSAPI int _ksys_set_window_zposition(int32_t pid, ksys_zpos_t position)
{
int err;
asm_inline(
"int $0x40"
: "=a"(err)
: "a"(18), "b"(25), "c"(2), "d"(pid), "S"(position));
return err;
}
/*==================== Function 21, subfunction 2 =====================*/
typedef enum KSYS_KEYBOARD_LAYOUT {
KSYS_KEYBOARD_LAYOUT_NORMAL = 1,
KSYS_KEYBOARD_LAYOUT_SHIFT = 2,
KSYS_KEYBOARD_LAYOUT_ALT = 3
} ksys_keyboard_layout_t;
KOSAPI int _ksys_set_keyboard_layout(ksys_keyboard_layout_t mode, char* table)
{
int err;
asm_inline(
"int $0x40"
: "=a"(err)
: "a"(21), "b"(2), "c"(mode), "d"(table));
return err;
}
typedef enum KSYS_LANG {
KSYS_LANG_ENG = 1,
KSYS_LANG_FI = 2,
KSYS_LANG_GER = 3,
KSYS_LANG_RU = 4
} ksys_lang_t;
KOSAPI int _ksys_set_keyboard_lang(ksys_lang_t lang)
{
int err;
asm_inline(
"int $0x40"
: "=a"(err)
: "a"(21), "b"(2), "c"(9), "d"(lang));
return err;
}
/*==================== Function 21, subfunction 5 =====================*/
KOSAPI int _ksys_set_lang(ksys_lang_t lang)
{
int err;
asm_inline(
"int $0x40"
: "=a"(err)
: "a"(21), "b"(5), "c"(lang));
return err;
}
/*==================== Function 21, subfunction 11 =====================*/
KOSAPI int _ksys_allow_HD(int param)
{
int err;
asm_inline(
"int $0x40"
: "=a"(err)
: "a"(21), "b"(11), "c"(param));
return err;
}
/*==================== Function 21, subfunction 12 =====================*/
KOSAPI int _ksys_allow_PCI(int param)
{
int err;
asm_inline(
"int $0x40"
: "=a"(err)
: "a"(21), "b"(12), "c"(param));
return err;
}
typedef enum KSYS_SET_TIME_ERR {
KSYS_SET_TIME_OK = 0,
KSYS_SET_TIME_WRONG_PARAM = 1,
KSYS_SET_TIME_CMOS = 2
} ksys_set_time_err;
/*============================ Function 22 ============================*/
KOSAPI ksys_set_time_err _ksys_set_time(ksys_time_t time)
{
ksys_set_time_err err;
asm_inline(
"int $0x40"
: "=a"(err)
: "a"(22), "b"(0), "c"(time));
}
KOSAPI ksys_set_time_err _ksys_set_date(ksys_date_t date)
{
ksys_set_time_err err;
asm_inline(
"int $0x40"
: "=a"(err)
: "a"(22), "b"(1), "c"(date));
}
/*============= Function 23 - wait for event with timeout. =============*/
KOSAPI uint32_t _ksys_wait_event_timeout(uint32_t timeout)
@@ -842,19 +1092,37 @@ KOSAPI uint32_t _ksys_wait_event_timeout(uint32_t timeout)
return val;
}
/*=== Function 26, subfunction 2 - get keynoard layout. ==*/
typedef enum KSYS_KEYBOARD_LAYOUT {
KSYS_KEYBOARD_LAYOUT_NORMAL = 1,
KSYS_KEYBOARD_LAYOUT_SHIFT = 2,
KSYS_KEYBOARD_LAYOUT_ALT = 3
} ksys_keyboard_layout_t;
/*========= Function 26, subfunction 2 - get keyboard layout. ==========*/
KOSAPI uint32_t _ksys_keyboard_layout(ksys_keyboard_layout_t layout, unsigned char* buf)
{
asm_inline("int $0x40" ::"a"(26), "b"(2), "c"(layout), "d"(buf) : "memory");
}
KOSAPI ksys_lang_t _ksys_get_keyboard_lang()
{
ksys_lang_t lang;
asm_inline(
"int $0x40"
: "=a"(lang)
: "a"(26), "b"(2), "c"(9));
return lang;
}
/*======= Function 26, subfunction 5 - get the system language. ========*/
KOSAPI ksys_lang_t _ksys_get_lang()
{
ksys_lang_t lang;
asm_inline(
"int $0x40"
: "=a"(lang)
: "a"(26), "b"(5));
return lang;
}
/*=== Function 26, subfunction 9 - get the value of the time counter. ==*/
KOSAPI uint32_t _ksys_get_tick_count(void)
@@ -880,6 +1148,30 @@ KOSAPI uint64_t _ksys_get_ns_count(void)
return val;
}
/*===================== Function 26, subfunction 11 ====================*/
KOSAPI int _ksys_get_HD()
{
int val;
asm_inline(
"int $0x40"
: "=a"(val)
: "a"(26), "b"(11));
return val;
}
/*===================== Function 26, subfunction 12 ====================*/
KOSAPI int _ksys_get_PCI()
{
int val;
asm_inline(
"int $0x40"
: "=a"(val)
: "a"(26), "b"(12));
return val;
}
/*=================== Function 29 - get system date. ===================*/
KOSAPI ksys_date_t _ksys_get_date(void)
@@ -1210,7 +1502,7 @@ KOSAPI void _ksys_debug_puts(const char* s)
KOSAPI void ksys_draw_bitmap_palette(void* bitmap, int x, int y, int w, int h, int bpp, void* palette, int offset)
{
asm_inline(
"pushl %%ebp,\n\t" // save EBP register
"pushl %%ebp\n\t" // save EBP register
"movl 0x24(%%ebp), %%ebp\n\t" // 0x24 - "offset" param
"int $0x40\n\t"
"popl %%ebp" // restore EBP register