2013-12-15 09:09:20 +01:00
|
|
|
#ifndef __KOS_32_SYS_H__
|
|
|
|
#define __KOS_32_SYS_H__
|
|
|
|
|
|
|
|
#include <newlib.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stddef.h>
|
2020-12-19 18:58:43 +01:00
|
|
|
#include <string.h>
|
2013-12-15 09:09:20 +01:00
|
|
|
|
2014-09-24 12:20:09 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2013-12-15 09:09:20 +01:00
|
|
|
//#ifdef CONFIG_DEBUF
|
|
|
|
// #define DBG(format,...) printf(format,##__VA_ARGS__)
|
|
|
|
//#else
|
|
|
|
// #define DBG(format,...)
|
|
|
|
//#endif
|
|
|
|
|
2015-01-15 03:45:05 +01:00
|
|
|
#define TYPE_3_BORDER_WIDTH 5
|
|
|
|
#define WIN_STATE_MINIMIZED 0x02
|
|
|
|
#define WIN_STATE_ROLLED 0x04
|
2014-01-21 15:12:35 +01:00
|
|
|
|
2013-12-15 09:09:20 +01:00
|
|
|
typedef unsigned int color_t;
|
|
|
|
|
|
|
|
typedef union __attribute__((packed))
|
|
|
|
{
|
|
|
|
uint32_t val;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
short x;
|
|
|
|
short y;
|
|
|
|
};
|
|
|
|
}pos_t;
|
|
|
|
|
|
|
|
typedef union __attribute__((packed))
|
|
|
|
{
|
|
|
|
uint32_t val;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
uint8_t state;
|
|
|
|
uint8_t code;
|
|
|
|
uint16_t ctrl_key;
|
|
|
|
};
|
|
|
|
}oskey_t;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
unsigned handle;
|
|
|
|
unsigned io_code;
|
|
|
|
void *input;
|
|
|
|
int inp_size;
|
|
|
|
void *output;
|
|
|
|
int out_size;
|
|
|
|
}ioctl_t;
|
|
|
|
|
2020-12-18 09:46:40 +01:00
|
|
|
#pragma pack(push, 1)
|
|
|
|
struct proc_info
|
|
|
|
{
|
|
|
|
unsigned long cpu_usage;
|
|
|
|
unsigned short pos_in_stack;
|
|
|
|
unsigned short slot;
|
|
|
|
unsigned short reserved2;
|
|
|
|
char name[12];
|
|
|
|
unsigned long address;
|
|
|
|
unsigned long memory_usage;
|
|
|
|
unsigned long ID;
|
|
|
|
unsigned long left,top;
|
|
|
|
unsigned long width,height;
|
|
|
|
unsigned short thread_state;
|
|
|
|
unsigned short reserved3;
|
|
|
|
unsigned long cleft, ctop, cwidth, cheight;
|
|
|
|
unsigned char window_state;
|
|
|
|
unsigned char reserved4[1024-71];
|
|
|
|
};
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
struct kolibri_system_colors {
|
|
|
|
color_t frame_area;
|
|
|
|
color_t grab_bar;
|
|
|
|
color_t grab_bar_button;
|
|
|
|
color_t grab_button_text;
|
|
|
|
color_t grab_text;
|
|
|
|
color_t work_area;
|
|
|
|
color_t work_button;
|
|
|
|
color_t work_button_text;
|
|
|
|
color_t work_text;
|
|
|
|
color_t work_graph;
|
|
|
|
};
|
|
|
|
|
2016-01-26 03:29:46 +01:00
|
|
|
static inline void begin_draw(void)
|
|
|
|
{
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40" ::"a"(12),"b"(1));
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline
|
|
|
|
void end_draw(void)
|
|
|
|
{
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40" ::"a"(12),"b"(2));
|
|
|
|
};
|
|
|
|
|
2016-09-27 22:37:49 +02:00
|
|
|
static inline void
|
2016-03-16 12:39:28 +01:00
|
|
|
put_image(uint16_t x_coord, uint16_t y_coord,
|
|
|
|
uint16_t size_x, uint16_t size_y, void *img)
|
|
|
|
{
|
2016-09-27 22:37:49 +02:00
|
|
|
__asm__ __volatile__("int $0x40"
|
2016-03-16 12:39:28 +01:00
|
|
|
::"a"(25),
|
|
|
|
"b"(img),
|
|
|
|
"c"(size_x<<16 | size_y),
|
|
|
|
"d"(x_coord<<16 | y_coord));
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-01-26 03:29:46 +01:00
|
|
|
static inline
|
|
|
|
void sys_create_window(int x, int y, int w, int h, const char *name,
|
|
|
|
color_t workcolor, uint32_t style)
|
|
|
|
{
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40"
|
|
|
|
::"a"(0),
|
|
|
|
"b"((x << 16) | ((w-1) & 0xFFFF)),
|
|
|
|
"c"((y << 16) | ((h-1) & 0xFFFF)),
|
|
|
|
"d"((style << 24) | (workcolor & 0xFFFFFF)),
|
|
|
|
"D"(name),
|
|
|
|
"S"(0) : "memory");
|
|
|
|
};
|
2013-12-15 09:09:20 +01:00
|
|
|
|
2020-12-19 18:58:43 +01:00
|
|
|
#define OLD -1
|
|
|
|
static inline
|
|
|
|
void sys_change_window(int new_x, int new_y, int new_w, int new_h)
|
|
|
|
{
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40"
|
|
|
|
::"a"(67), "b"(new_x), "c"(new_y), "d"(new_w),"S"(new_h)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2013-12-15 09:09:20 +01:00
|
|
|
static inline
|
2015-04-20 21:00:00 +02:00
|
|
|
void define_button(uint32_t x_w, uint32_t y_h, uint32_t id, uint32_t color)
|
2013-12-15 09:09:20 +01:00
|
|
|
{
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40"
|
|
|
|
::"a"(8),
|
|
|
|
"b"(x_w),
|
|
|
|
"c"(y_h),
|
|
|
|
"d"(id),
|
|
|
|
"S"(color));
|
|
|
|
};
|
|
|
|
|
2014-01-21 15:12:35 +01:00
|
|
|
static inline
|
2016-01-26 03:29:46 +01:00
|
|
|
void draw_line(int xs, int ys, int xe, int ye, color_t color)
|
2014-01-21 15:12:35 +01:00
|
|
|
{
|
2016-01-26 03:29:46 +01:00
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40"
|
|
|
|
::"a"(38), "d"(color),
|
|
|
|
"b"((xs << 16) | xe),
|
|
|
|
"c"((ys << 16) | ye));
|
|
|
|
}
|
2014-01-21 15:12:35 +01:00
|
|
|
|
2016-01-26 03:29:46 +01:00
|
|
|
static inline
|
|
|
|
void draw_bar(int x, int y, int w, int h, color_t color)
|
|
|
|
{
|
2014-01-21 15:12:35 +01:00
|
|
|
__asm__ __volatile__(
|
2016-01-26 03:29:46 +01:00
|
|
|
"int $0x40"
|
|
|
|
::"a"(13), "d"(color),
|
|
|
|
"b"((x << 16) | w),
|
|
|
|
"c"((y << 16) | h));
|
|
|
|
}
|
2014-01-21 15:12:35 +01:00
|
|
|
|
2013-12-15 09:09:20 +01:00
|
|
|
static inline
|
2016-01-26 03:29:46 +01:00
|
|
|
void draw_bitmap(void *bitmap, int x, int y, int w, int h)
|
2013-12-15 09:09:20 +01:00
|
|
|
{
|
|
|
|
__asm__ __volatile__(
|
2016-01-26 03:29:46 +01:00
|
|
|
"int $0x40"
|
|
|
|
::"a"(7), "b"(bitmap),
|
|
|
|
"c"((w << 16) | h),
|
|
|
|
"d"((x << 16) | y));
|
|
|
|
}
|
2013-12-15 09:09:20 +01:00
|
|
|
|
|
|
|
static inline
|
2016-01-26 03:29:46 +01:00
|
|
|
void draw_text_sys(const char *text, int x, int y, int len, color_t color)
|
2013-12-15 09:09:20 +01:00
|
|
|
{
|
|
|
|
__asm__ __volatile__(
|
2016-01-26 03:29:46 +01:00
|
|
|
"int $0x40"
|
|
|
|
::"a"(4),"d"(text),
|
|
|
|
"b"((x << 16) | y),
|
|
|
|
"S"(len),"c"(color)
|
|
|
|
:"memory");
|
|
|
|
}
|
2013-12-15 09:09:20 +01:00
|
|
|
|
2020-12-19 18:58:43 +01:00
|
|
|
/*
|
|
|
|
void define_button_text(int x, int y, int w, int h, uint32_t id, uint32_t color, char* text)
|
|
|
|
{
|
|
|
|
define_button(x * 65536 + w, y * 65536 + h, id, color);
|
|
|
|
|
|
|
|
int tx = ((((-strlen(text))*8)+w)/2)+x;
|
|
|
|
int ty = h/2-7+y;
|
|
|
|
|
|
|
|
draw_text_sys(text, tx, ty, strlen(text), 0x90000000);
|
|
|
|
};
|
|
|
|
*/
|
|
|
|
|
2016-01-26 03:29:46 +01:00
|
|
|
static inline
|
|
|
|
uint32_t get_skin_height(void)
|
2013-12-15 09:09:20 +01:00
|
|
|
{
|
2016-01-26 03:29:46 +01:00
|
|
|
uint32_t height;
|
2013-12-15 09:09:20 +01:00
|
|
|
|
|
|
|
__asm__ __volatile__(
|
2016-01-26 03:29:46 +01:00
|
|
|
"int $0x40 \n\t"
|
|
|
|
:"=a"(height)
|
|
|
|
:"a"(48),"b"(4));
|
|
|
|
return height;
|
2013-12-15 09:09:20 +01:00
|
|
|
};
|
|
|
|
|
2016-01-26 03:29:46 +01:00
|
|
|
static inline void BeginDraw(void) __attribute__ ((alias ("begin_draw")));
|
|
|
|
static inline void EndDraw(void) __attribute__ ((alias ("end_draw")));
|
|
|
|
static inline void DrawWindow(int x, int y, int w, int h, const char *name,
|
|
|
|
color_t workcolor, uint32_t style)
|
|
|
|
__attribute__ ((alias ("sys_create_window")));
|
|
|
|
static inline void DefineButton(void) __attribute__ ((alias ("define_button")));
|
|
|
|
static inline void DrawLine(int xs, int ys, int xe, int ye, color_t color)
|
|
|
|
__attribute__ ((alias ("draw_line")));
|
|
|
|
static inline void DrawBar(int x, int y, int w, int h, color_t color)
|
|
|
|
__attribute__ ((alias ("draw_bar")));
|
|
|
|
static inline void DrawBitmap(void *bitmap, int x, int y, int w, int h)
|
|
|
|
__attribute__ ((alias ("draw_bitmap")));
|
|
|
|
static inline uint32_t GetSkinHeight(void) __attribute__ ((alias ("get_skin_height")));
|
|
|
|
|
|
|
|
|
2014-08-26 16:10:17 +02:00
|
|
|
#define POS_SCREEN 0
|
|
|
|
#define POS_WINDOW 1
|
2013-12-15 09:09:20 +01:00
|
|
|
|
|
|
|
static inline
|
2014-08-26 16:10:17 +02:00
|
|
|
pos_t get_mouse_pos(int origin)
|
2013-12-15 09:09:20 +01:00
|
|
|
{
|
|
|
|
pos_t val;
|
|
|
|
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40 \n\t"
|
|
|
|
"rol $16, %%eax"
|
|
|
|
:"=a"(val)
|
2014-08-26 16:10:17 +02:00
|
|
|
:"a"(37),"b"(origin));
|
2013-12-15 09:09:20 +01:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline
|
|
|
|
uint32_t get_mouse_buttons(void)
|
|
|
|
{
|
|
|
|
uint32_t val;
|
|
|
|
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40"
|
|
|
|
:"=a"(val)
|
|
|
|
:"a"(37),"b"(2));
|
|
|
|
return val;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline
|
|
|
|
uint32_t get_mouse_wheels(void)
|
|
|
|
{
|
|
|
|
uint32_t val;
|
|
|
|
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40 \n\t"
|
|
|
|
:"=a"(val)
|
|
|
|
:"a"(37),"b"(7));
|
|
|
|
return val;
|
|
|
|
};
|
2016-01-26 03:29:46 +01:00
|
|
|
|
|
|
|
static inline uint32_t load_cursor(void *path, uint32_t flags)
|
|
|
|
{
|
|
|
|
uint32_t val;
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40"
|
|
|
|
:"=a"(val)
|
|
|
|
:"a"(37), "b"(4), "c"(path), "d"(flags));
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint32_t set_cursor(uint32_t cursor)
|
|
|
|
{
|
|
|
|
uint32_t old;
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40"
|
|
|
|
:"=a"(old)
|
|
|
|
:"a"(37), "b"(5), "c"(cursor));
|
|
|
|
return old;
|
|
|
|
};
|
|
|
|
|
2020-12-19 18:58:43 +01:00
|
|
|
|
|
|
|
#define EVM_REDRAW 1
|
|
|
|
#define EVM_KEY 2
|
|
|
|
#define EVM_BUTTON 4
|
|
|
|
#define EVM_EXIT 8
|
|
|
|
#define EVM_BACKGROUND 16
|
|
|
|
#define EVM_MOUSE 32
|
|
|
|
#define EVM_IPC 64
|
|
|
|
#define EVM_STACK 128
|
|
|
|
#define EVM_DEBUG 256
|
|
|
|
#define EVM_STACK2 512
|
|
|
|
#define EVM_MOUSE_FILTER 0x80000000
|
|
|
|
#define EVM_CURSOR_FILTER 0x40000000
|
|
|
|
|
2016-03-16 12:39:28 +01:00
|
|
|
static inline uint32_t set_wanted_events_mask(uint32_t event_mask)
|
|
|
|
{
|
|
|
|
uint32_t old_event_mask;
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40"
|
|
|
|
:"=a"(old_event_mask)
|
2016-09-27 22:37:49 +02:00
|
|
|
:"a"(40),"b"(event_mask));
|
2016-03-16 12:39:28 +01:00
|
|
|
|
|
|
|
return old_event_mask;
|
|
|
|
};
|
|
|
|
|
2016-01-26 03:29:46 +01:00
|
|
|
static inline int destroy_cursor(uint32_t cursor)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40"
|
|
|
|
:"=a"(ret)
|
|
|
|
:"a"(37), "b"(6), "c"(cursor)
|
|
|
|
:"memory");
|
|
|
|
return ret;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline pos_t GetMousePos(int origin) __attribute__ ((alias ("get_mouse_pos")));
|
|
|
|
static inline uint32_t GetMouseButtons(void) __attribute__ ((alias ("get_mouse_buttons")));
|
2014-08-26 16:10:17 +02:00
|
|
|
static inline uint32_t GetMouseWheels(void) __attribute__ ((alias ("get_mouse_wheels")));
|
2013-12-15 09:09:20 +01:00
|
|
|
|
2016-01-26 03:29:46 +01:00
|
|
|
static inline uint32_t LoadCursor(void *path, uint32_t flags) __attribute__ ((alias ("load_cursor")));
|
|
|
|
static inline uint32_t SetCursor(uint32_t cursor) __attribute__ ((alias ("set_cursor")));
|
|
|
|
static inline int DestroyCursor(uint32_t cursor) __attribute__ ((alias ("destroy_cursor")));
|
|
|
|
|
|
|
|
|
2013-12-15 09:09:20 +01:00
|
|
|
static inline
|
|
|
|
uint32_t wait_for_event(uint32_t time)
|
|
|
|
{
|
|
|
|
uint32_t val;
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40"
|
|
|
|
:"=a"(val)
|
|
|
|
:"a"(23), "b"(time));
|
|
|
|
return val;
|
|
|
|
};
|
|
|
|
|
2016-09-27 22:37:49 +02:00
|
|
|
static inline uint32_t check_os_event(void)
|
2013-12-15 09:09:20 +01:00
|
|
|
{
|
|
|
|
uint32_t val;
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40"
|
|
|
|
:"=a"(val)
|
|
|
|
:"a"(11));
|
|
|
|
return val;
|
|
|
|
};
|
|
|
|
|
2016-09-27 22:37:49 +02:00
|
|
|
static inline uint32_t get_os_event(void)
|
2014-01-21 15:12:35 +01:00
|
|
|
{
|
|
|
|
uint32_t val;
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40"
|
|
|
|
:"=a"(val)
|
|
|
|
:"a"(10));
|
|
|
|
return val;
|
|
|
|
};
|
2014-08-26 16:10:17 +02:00
|
|
|
static inline uint32_t GetOsEvent(void) __attribute__ ((alias ("get_os_event")));
|
2014-01-21 15:12:35 +01:00
|
|
|
|
2013-12-15 09:09:20 +01:00
|
|
|
static inline
|
|
|
|
uint32_t get_tick_count(void)
|
|
|
|
{
|
|
|
|
uint32_t val;
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40"
|
|
|
|
:"=a"(val)
|
|
|
|
:"a"(26),"b"(9));
|
|
|
|
return val;
|
|
|
|
};
|
|
|
|
|
2015-09-06 10:56:26 +02:00
|
|
|
static inline
|
|
|
|
uint64_t get_ns_count(void)
|
|
|
|
{
|
|
|
|
uint64_t val;
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40"
|
|
|
|
:"=A"(val)
|
|
|
|
:"a"(26), "b"(10));
|
|
|
|
return val;
|
|
|
|
};
|
|
|
|
|
2013-12-15 09:09:20 +01:00
|
|
|
static inline
|
|
|
|
oskey_t get_key(void)
|
|
|
|
{
|
|
|
|
oskey_t val;
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40"
|
|
|
|
:"=a"(val)
|
|
|
|
:"a"(2));
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline
|
2016-09-27 22:37:49 +02:00
|
|
|
uint32_t get_os_button(void)
|
2013-12-15 09:09:20 +01:00
|
|
|
{
|
|
|
|
uint32_t val;
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40"
|
|
|
|
:"=a"(val)
|
|
|
|
:"a"(17));
|
|
|
|
return val>>8;
|
|
|
|
};
|
|
|
|
|
2017-05-15 22:30:49 +02:00
|
|
|
static inline uint32_t
|
|
|
|
heap_init(void)
|
|
|
|
{
|
|
|
|
uint32_t heapsize;
|
|
|
|
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40"
|
|
|
|
:"=a"(heapsize)
|
|
|
|
:"a"(68),"b"(11)
|
|
|
|
);
|
|
|
|
|
|
|
|
return heapsize;
|
|
|
|
}
|
|
|
|
|
2013-12-15 09:09:20 +01:00
|
|
|
static inline uint32_t get_service(char *name)
|
|
|
|
{
|
2014-09-01 22:27:45 +02:00
|
|
|
uint32_t retval = 0;
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40"
|
|
|
|
:"=a"(retval)
|
|
|
|
:"a"(68),"b"(16),"c"(name)
|
|
|
|
:"memory");
|
2013-12-15 09:09:20 +01:00
|
|
|
|
2014-09-01 22:27:45 +02:00
|
|
|
return retval;
|
2013-12-15 09:09:20 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline int call_service(ioctl_t *io)
|
|
|
|
{
|
2014-09-01 22:27:45 +02:00
|
|
|
int retval;
|
2013-12-15 09:09:20 +01:00
|
|
|
|
2014-09-01 22:27:45 +02:00
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40"
|
|
|
|
:"=a"(retval)
|
|
|
|
:"a"(68),"b"(17),"c"(io)
|
|
|
|
:"memory","cc");
|
2013-12-15 09:09:20 +01:00
|
|
|
|
2014-09-01 22:27:45 +02:00
|
|
|
return retval;
|
2013-12-15 09:09:20 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static inline void yield(void)
|
|
|
|
{
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40"
|
|
|
|
::"a"(68), "b"(1));
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline void delay(uint32_t time)
|
|
|
|
{
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40"
|
|
|
|
::"a"(5), "b"(time)
|
|
|
|
:"memory");
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline
|
|
|
|
void *user_alloc(size_t size)
|
|
|
|
{
|
|
|
|
void *val;
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40"
|
|
|
|
:"=a"(val)
|
|
|
|
:"a"(68),"b"(12),"c"(size));
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline
|
|
|
|
int user_free(void *mem)
|
|
|
|
{
|
|
|
|
int val;
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40"
|
|
|
|
:"=a"(val)
|
2014-01-16 19:50:44 +01:00
|
|
|
:"a"(68),"b"(13),"c"(mem));
|
2013-12-15 09:09:20 +01:00
|
|
|
return val;
|
|
|
|
}
|
2016-01-26 03:29:46 +01:00
|
|
|
|
|
|
|
static inline
|
|
|
|
void* user_realloc(void *mem, size_t size)
|
|
|
|
{
|
|
|
|
void *val;
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40"
|
|
|
|
:"=a"(val)
|
|
|
|
:"a"(68),"b"(20),"c"(size),"d"(mem)
|
|
|
|
:"memory");
|
|
|
|
|
|
|
|
return val;
|
|
|
|
};
|
2013-12-15 09:09:20 +01:00
|
|
|
|
|
|
|
static inline
|
|
|
|
int *user_unmap(void *base, size_t offset, size_t size)
|
|
|
|
{
|
2014-04-04 23:41:12 +02:00
|
|
|
int *val;
|
2013-12-15 09:09:20 +01:00
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40"
|
|
|
|
:"=a"(val)
|
|
|
|
:"a"(68),"b"(26),"c"(base),"d"(offset),"S"(size));
|
|
|
|
return val;
|
2014-08-26 16:10:17 +02:00
|
|
|
};
|
2016-01-26 03:29:46 +01:00
|
|
|
|
|
|
|
static inline void *UserAlloc(size_t size) __attribute__ ((alias ("user_alloc")));
|
|
|
|
static inline int UserFree(void *mem) __attribute__ ((alias ("user_free")));
|
|
|
|
static inline void* UserRealloc(void *mem, size_t size) __attribute__ ((alias ("user_realloc")));
|
2014-08-26 16:10:17 +02:00
|
|
|
static inline int *UserUnmap(void *base, size_t offset, size_t size) __attribute__ ((alias ("user_unmap")));
|
2013-12-15 09:09:20 +01:00
|
|
|
|
|
|
|
typedef union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
void *data;
|
|
|
|
size_t size;
|
|
|
|
};
|
|
|
|
unsigned long long raw;
|
|
|
|
}ufile_t;
|
|
|
|
|
|
|
|
static inline ufile_t load_file(const char *path)
|
|
|
|
{
|
2014-09-01 22:27:45 +02:00
|
|
|
ufile_t uf;
|
2013-12-15 09:09:20 +01:00
|
|
|
|
2014-09-01 22:27:45 +02:00
|
|
|
__asm__ __volatile__ (
|
|
|
|
"int $0x40"
|
|
|
|
:"=A"(uf.raw)
|
|
|
|
:"a" (68), "b"(27),"c"(path));
|
2013-12-15 09:09:20 +01:00
|
|
|
|
2014-09-01 22:27:45 +02:00
|
|
|
return uf;
|
2013-12-15 09:09:20 +01:00
|
|
|
};
|
2014-08-26 16:10:17 +02:00
|
|
|
static inline ufile_t LoadFile(const char *path) __attribute__ ((alias ("load_file")));
|
2013-12-15 09:09:20 +01:00
|
|
|
|
2016-09-27 22:37:49 +02:00
|
|
|
static inline int GetScreenSize(void)
|
2013-12-15 09:09:20 +01:00
|
|
|
{
|
2014-09-01 22:27:45 +02:00
|
|
|
int retval;
|
2013-12-15 09:09:20 +01:00
|
|
|
|
2014-09-01 22:27:45 +02:00
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40"
|
|
|
|
:"=a"(retval)
|
|
|
|
:"a"(61), "b"(1));
|
|
|
|
return retval;
|
2013-12-15 09:09:20 +01:00
|
|
|
}
|
|
|
|
|
2020-12-19 18:58:43 +01:00
|
|
|
static inline
|
|
|
|
pos_t max_screen_size()
|
|
|
|
{
|
|
|
|
pos_t size;
|
2021-02-16 20:31:15 +01:00
|
|
|
pos_t size_tmp;
|
2020-12-19 18:58:43 +01:00
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40"
|
2021-02-16 20:31:15 +01:00
|
|
|
:"=a"(size_tmp)
|
2020-12-19 18:58:43 +01:00
|
|
|
:"a"(14));
|
2021-02-16 20:31:15 +01:00
|
|
|
size.x = size_tmp.y;
|
|
|
|
size.y = size_tmp.x;
|
|
|
|
return size;
|
2020-12-19 18:58:43 +01:00
|
|
|
};
|
|
|
|
|
2020-12-18 09:46:40 +01:00
|
|
|
static inline void get_system_colors(struct kolibri_system_colors *color_table)
|
|
|
|
{
|
|
|
|
__asm__ volatile ("int $0x40"
|
|
|
|
:
|
|
|
|
:"a"(48),"b"(3),"c"(color_table),"d"(40)
|
|
|
|
);
|
|
|
|
}
|
2013-12-15 09:09:20 +01:00
|
|
|
|
|
|
|
static inline void get_proc_info(char *info)
|
|
|
|
{
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40"
|
|
|
|
:
|
2015-12-14 18:41:20 +01:00
|
|
|
:"a"(9), "b"(info), "c"(-1)
|
|
|
|
:"memory");
|
2014-08-26 16:10:17 +02:00
|
|
|
};
|
|
|
|
static inline void GetProcInfo(char *info) __attribute__ ((alias ("get_proc_info")));
|
2013-12-15 09:09:20 +01:00
|
|
|
|
|
|
|
|
|
|
|
struct blit_call
|
|
|
|
{
|
|
|
|
int dstx;
|
|
|
|
int dsty;
|
|
|
|
int w;
|
|
|
|
int h;
|
|
|
|
|
|
|
|
int srcx;
|
|
|
|
int srcy;
|
|
|
|
int srcw;
|
|
|
|
int srch;
|
|
|
|
|
2014-09-24 12:20:09 +02:00
|
|
|
void *bitmap;
|
2013-12-15 09:09:20 +01:00
|
|
|
int stride;
|
|
|
|
};
|
|
|
|
|
2014-08-29 17:38:30 +02:00
|
|
|
static inline void Blit(void *bitmap, int dst_x, int dst_y,
|
2013-12-15 09:09:20 +01:00
|
|
|
int src_x, int src_y, int w, int h,
|
2014-08-29 17:38:30 +02:00
|
|
|
int src_w, int src_h, int stride)
|
|
|
|
{
|
|
|
|
volatile struct blit_call bc;
|
|
|
|
|
|
|
|
bc.dstx = dst_x;
|
|
|
|
bc.dsty = dst_y;
|
|
|
|
bc.w = w;
|
|
|
|
bc.h = h;
|
|
|
|
bc.srcx = src_x;
|
|
|
|
bc.srcy = src_y;
|
|
|
|
bc.srcw = src_w;
|
|
|
|
bc.srch = src_h;
|
|
|
|
bc.stride = stride;
|
|
|
|
bc.bitmap = bitmap;
|
|
|
|
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40"
|
|
|
|
::"a"(73),"b"(0),"c"(&bc.dstx));
|
|
|
|
};
|
2013-12-15 09:09:20 +01:00
|
|
|
|
2016-09-27 22:37:49 +02:00
|
|
|
#define TLS_KEY_PID 0
|
|
|
|
#define TLS_KEY_TID 4
|
|
|
|
#define TLS_KEY_LOW_STACK 8
|
|
|
|
#define TLS_KEY_HIGH_STACK 12
|
|
|
|
#define TLS_KEY_LIBC 16
|
|
|
|
|
|
|
|
unsigned int tls_alloc(void);
|
|
|
|
int tls_free(unsigned int key);
|
|
|
|
|
|
|
|
static inline int tls_set(unsigned int key, void *val)
|
|
|
|
{
|
|
|
|
int ret = -1;
|
|
|
|
if(key < 4096)
|
|
|
|
{
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"movl %0, %%fs:(%1)"
|
|
|
|
::"r"(val),"r"(key));
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline void *tls_get(unsigned int key)
|
|
|
|
{
|
|
|
|
void *val = (void*)-1;
|
|
|
|
if(key < 4096)
|
|
|
|
{
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"movl %%fs:(%1), %0"
|
|
|
|
:"=r"(val)
|
|
|
|
:"r"(key));
|
|
|
|
};
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-01-26 03:29:46 +01:00
|
|
|
int create_thread(int (*proc)(void *param), void *param, int stack_size);
|
|
|
|
|
2014-11-27 02:02:55 +01:00
|
|
|
void* load_library(const char *name);
|
|
|
|
|
|
|
|
void* get_proc_address(void *handle, const char *proc_name);
|
|
|
|
|
|
|
|
void enumerate_libraries(int (*callback)(void *handle, const char* name,
|
|
|
|
uint32_t base, uint32_t size, void *user_data),
|
|
|
|
void *user_data);
|
|
|
|
|
2014-09-24 12:20:09 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2013-12-15 09:09:20 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|