Rev 8664 | Rev 9097 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8664 | Rev 8695 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #include |
1 | #include |
2 | #include |
2 | #include |
3 | #include "../../kolibri-libc/source/include/ksys.h" |
- | |
4 | #include |
3 | #include |
Line -... | Line 4... | ||
- | 4 | ||
- | 5 | #define asm_inline __asm__ __volatile__ |
|
- | 6 | ||
- | 7 | #pragma pack(push,1) |
|
- | 8 | typedef union{ |
|
- | 9 | unsigned val; |
|
- | 10 | struct{ |
|
- | 11 | short x; |
|
- | 12 | short y; |
|
- | 13 | }; |
|
- | 14 | }ksys_pos_t; |
|
- | 15 | ||
- | 16 | typedef union ksys_oskey_t{ |
|
- | 17 | unsigned val; |
|
- | 18 | struct{ |
|
- | 19 | unsigned char state; |
|
- | 20 | unsigned char code; |
|
- | 21 | unsigned char ctrl_key; |
|
- | 22 | }; |
|
- | 23 | }ksys_oskey_t; |
|
- | 24 | ||
- | 25 | typedef struct{ |
|
- | 26 | unsigned handle; |
|
- | 27 | unsigned io_code; |
|
- | 28 | unsigned *input; |
|
- | 29 | int inp_size; |
|
- | 30 | void *output; |
|
- | 31 | int out_size; |
|
- | 32 | }ksys_ioctl_t; |
|
- | 33 | ||
- | 34 | typedef struct{ |
|
- | 35 | void *data; |
|
- | 36 | size_t size; |
|
- | 37 | }ksys_ufile_t; |
|
- | 38 | ||
- | 39 | ||
- | 40 | typedef struct{ |
|
- | 41 | unsigned p00; |
|
- | 42 | union{ |
|
- | 43 | uint64_t p04; |
|
- | 44 | struct { |
|
- | 45 | unsigned p04dw; |
|
- | 46 | unsigned p08dw; |
|
- | 47 | }; |
|
- | 48 | }; |
|
- | 49 | unsigned p12; |
|
- | 50 | union { |
|
- | 51 | unsigned p16; |
|
- | 52 | const char *new_name; |
|
- | 53 | void *bdfe; |
|
- | 54 | void *buf16; |
|
- | 55 | const void *cbuf16; |
|
- | 56 | }; |
|
- | 57 | char p20; |
|
- | 58 | const char *p21; |
|
- | 59 | }ksys70_t; |
|
- | 60 | ||
- | 61 | typedef struct { |
|
- | 62 | int cpu_usage; //+0 |
|
- | 63 | int window_pos_info; //+4 |
|
- | 64 | short int reserved1; //+8 |
|
- | 65 | char name[12]; //+10 |
|
- | 66 | int memstart; //+22 |
|
- | 67 | int memused; //+26 |
|
- | 68 | int pid; //+30 |
|
- | 69 | int winx_start; //+34 |
|
- | 70 | int winy_start; //+38 |
|
- | 71 | int winx_size; //+42 |
|
- | 72 | int winy_size; //+46 |
|
- | 73 | short int slot_info; //+50 |
|
- | 74 | short int reserved2; //+52 |
|
- | 75 | int clientx; //+54 |
|
- | 76 | int clienty; //+58 |
|
- | 77 | int clientwidth; //+62 |
|
- | 78 | int clientheight; //+66 |
|
- | 79 | unsigned char window_state;//+70 |
|
- | 80 | char reserved3[1024-71]; //+71 |
|
- | 81 | }ksys_proc_table_t; |
|
- | 82 | ||
- | 83 | #pragma pack(pop) |
|
- | 84 | ||
- | 85 | static inline |
|
- | 86 | int _ksys_process_info(ksys_proc_table_t* table, int pid) |
|
- | 87 | { |
|
- | 88 | int val; |
|
- | 89 | asm_inline( |
|
- | 90 | "int $0x40" |
|
- | 91 | :"=a"(val) |
|
- | 92 | :"a"(9), "b"(table), "c"(pid) |
|
- | 93 | :"memory" |
|
- | 94 | ); |
|
- | 95 | return val; |
|
- | 96 | } |
|
- | 97 | ||
- | 98 | static inline |
|
- | 99 | void _ksys_change_window(int new_x, int new_y, int new_w, int new_h) |
|
- | 100 | { |
|
- | 101 | asm_inline( |
|
- | 102 | "int $0x40" |
|
- | 103 | ::"a"(67), "b"(new_x), "c"(new_y), "d"(new_w),"S"(new_h) |
|
- | 104 | ); |
|
- | 105 | } |
|
- | 106 | ||
- | 107 | static inline |
|
- | 108 | ksys_pos_t _ksys_screen_size() |
|
- | 109 | { |
|
- | 110 | ksys_pos_t size; |
|
- | 111 | ksys_pos_t size_tmp; |
|
- | 112 | asm_inline( |
|
- | 113 | "int $0x40" |
|
- | 114 | :"=a"(size_tmp) |
|
- | 115 | :"a"(14) |
|
- | 116 | ); |
|
- | 117 | size.x = size_tmp.y; |
|
- | 118 | size.y = size_tmp.x; |
|
- | 119 | return size; |
|
- | 120 | } |
|
5 | 121 | ||
6 | void *memrchr(const void *m, int c, size_t n) |
122 | void *memrchr(const void *m, int c, size_t n) |
7 | { |
123 | { |
8 | const unsigned char *s = (const unsigned char*)m; |
124 | const unsigned char *s = (const unsigned char*)m; |
9 | c = (unsigned char)c; |
125 | c = (unsigned char)c; |
Line 21... | Line 137... | ||
21 | int new_y = screen_size.y/2-info->winy_size/2; |
137 | int new_y = screen_size.y/2-info->winy_size/2; |
22 | _ksys_change_window(new_x, new_y, -1, -1); |
138 | _ksys_change_window(new_x, new_y, -1, -1); |
23 | free(info); |
139 | free(info); |
24 | } |
140 | } |
Line 25... | Line 141... | ||
25 | 141 | ||
26 | int mkdir(const char * path, unsigned) |
142 | int mkdir(const char *path, unsigned v) |
- | 143 | { |
|
- | 144 | int status; |
|
- | 145 | ksys70_t dir_opt; |
|
- | 146 | dir_opt.p00 = 9; |
|
- | 147 | dir_opt.p21 = path; |
|
- | 148 | asm_inline( |
|
- | 149 | "int $0x40" |
|
- | 150 | :"=a"(status) |
|
- | 151 | :"a"(70), "b"(&dir_opt) |
|
- | 152 | :"memory" |
|
27 | { |
153 | ); |
28 | return _ksys_mkdir(path); |
154 | return status; |
Line 29... | Line 155... | ||
29 | } |
155 | } |
30 | 156 | ||
31 | char *dirname (char *path) |
157 | char *dirname (char *path) |
Line 75... | Line 201... | ||
75 | path = (char *) dot; |
201 | path = (char *) dot; |
76 | return path; |
202 | return path; |
77 | } |
203 | } |
Line 78... | Line 204... | ||
78 | 204 | ||
79 | void setcwd(char* path){ |
205 | void setcwd(char* path){ |
- | 206 | asm_inline( |
|
- | 207 | "int $0x40" |
|
- | 208 | ::"a"(30), "b"(1), "c"(path) |
|
80 | _ksys_setcwd(path); |
209 | ); |