Subversion Repositories Kolibri OS

Rev

Rev 5552 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5552 Rev 5808
1
#ifndef __KOS_32_SYS_H__
1
#ifndef __KOS_32_SYS_H__
2
#define __KOS_32_SYS_H__
2
#define __KOS_32_SYS_H__
3
 
3
 
4
#include 
4
#include 
5
#include 
5
#include 
6
#include 
6
#include 
7
 
7
 
8
#ifdef __cplusplus
8
#ifdef __cplusplus
9
extern "C" {
9
extern "C" {
10
#endif
10
#endif
11
 
11
 
12
//#ifdef CONFIG_DEBUF
12
//#ifdef CONFIG_DEBUF
13
//  #define DBG(format,...) printf(format,##__VA_ARGS__)
13
//  #define DBG(format,...) printf(format,##__VA_ARGS__)
14
//#else
14
//#else
15
//  #define DBG(format,...)
15
//  #define DBG(format,...)
16
//#endif
16
//#endif
17
 
17
 
18
#define TYPE_3_BORDER_WIDTH  5
18
#define TYPE_3_BORDER_WIDTH  5
19
#define WIN_STATE_MINIMIZED  0x02
19
#define WIN_STATE_MINIMIZED  0x02
20
#define WIN_STATE_ROLLED     0x04
20
#define WIN_STATE_ROLLED     0x04
21
 
21
 
22
typedef  unsigned int color_t;
22
typedef  unsigned int color_t;
23
 
23
 
24
typedef union __attribute__((packed))
24
typedef union __attribute__((packed))
25
{
25
{
26
    uint32_t val;
26
    uint32_t val;
27
    struct
27
    struct
28
    {
28
    {
29
        short  x;
29
        short  x;
30
        short  y;
30
        short  y;
31
    };
31
    };
32
}pos_t;
32
}pos_t;
33
 
33
 
34
typedef union __attribute__((packed))
34
typedef union __attribute__((packed))
35
{
35
{
36
    uint32_t val;
36
    uint32_t val;
37
    struct
37
    struct
38
    {
38
    {
39
        uint8_t   state;
39
        uint8_t   state;
40
        uint8_t   code;
40
        uint8_t   code;
41
        uint16_t  ctrl_key;
41
        uint16_t  ctrl_key;
42
    };
42
    };
43
}oskey_t;
43
}oskey_t;
44
 
44
 
45
typedef struct
45
typedef struct
46
{
46
{
47
  unsigned      handle;
47
  unsigned      handle;
48
  unsigned      io_code;
48
  unsigned      io_code;
49
  void          *input;
49
  void          *input;
50
  int           inp_size;
50
  int           inp_size;
51
  void          *output;
51
  void          *output;
52
  int           out_size;
52
  int           out_size;
53
}ioctl_t;
53
}ioctl_t;
54
 
54
 
55
 
55
 
56
static inline
56
static inline
57
void define_button(uint32_t x_w, uint32_t y_h, uint32_t id, uint32_t color)
57
void define_button(uint32_t x_w, uint32_t y_h, uint32_t id, uint32_t color)
58
{
58
{
59
    __asm__ __volatile__(
59
    __asm__ __volatile__(
60
    "int $0x40"
60
    "int $0x40"
61
    ::"a"(8),
61
    ::"a"(8),
62
      "b"(x_w),
62
      "b"(x_w),
63
      "c"(y_h),
63
      "c"(y_h),
64
      "d"(id),
64
      "d"(id),
65
      "S"(color));
65
      "S"(color));
66
};
66
};
67
static inline void DefineButton(void) __attribute__ ((alias ("define_button")));
67
static inline void DefineButton(void) __attribute__ ((alias ("define_button")));
68
 
68
 
69
static inline
69
static inline
70
uint32_t get_skin_height(void)
70
uint32_t get_skin_height(void)
71
{
71
{
72
    uint32_t height;
72
    uint32_t height;
73
 
73
 
74
    __asm__ __volatile__(
74
    __asm__ __volatile__(
75
    "int $0x40 \n\t"
75
    "int $0x40 \n\t"
76
    :"=a"(height)
76
    :"=a"(height)
77
    :"a"(48),"b"(4));
77
    :"a"(48),"b"(4));
78
    return height;
78
    return height;
79
};
79
};
80
static inline uint32_t GetSkinHeight(void) __attribute__ ((alias ("get_skin_height")));
80
static inline uint32_t GetSkinHeight(void) __attribute__ ((alias ("get_skin_height")));
81
 
81
 
82
static inline
82
static inline
83
void BeginDraw(void)
83
void BeginDraw(void)
84
{
84
{
85
    __asm__ __volatile__(
85
    __asm__ __volatile__(
86
    "int $0x40" ::"a"(12),"b"(1));
86
    "int $0x40" ::"a"(12),"b"(1));
87
};
87
};
88
 
88
 
89
static inline
89
static inline
90
void EndDraw(void)
90
void EndDraw(void)
91
{
91
{
92
    __asm__ __volatile__(
92
    __asm__ __volatile__(
93
    "int $0x40" ::"a"(12),"b"(2));
93
    "int $0x40" ::"a"(12),"b"(2));
94
};
94
};
95
 
95
 
96
static inline void DrawWindow(int x, int y, int w, int h, const char *name,
96
static inline void DrawWindow(int x, int y, int w, int h, const char *name,
97
                       color_t workcolor, uint32_t style)
97
                       color_t workcolor, uint32_t style)
98
{
98
{
99
 
99
 
100
    __asm__ __volatile__(
100
    __asm__ __volatile__(
101
    "int $0x40"
101
    "int $0x40"
102
    ::"a"(0),
102
    ::"a"(0),
103
     "b"((x << 16) | ((w-1) & 0xFFFF)),
103
     "b"((x << 16) | ((w-1) & 0xFFFF)),
104
     "c"((y << 16) | ((h-1) & 0xFFFF)),
104
     "c"((y << 16) | ((h-1) & 0xFFFF)),
105
     "d"((style << 24) | (workcolor & 0xFFFFFF)),
105
     "d"((style << 24) | (workcolor & 0xFFFFFF)),
106
     "D"(name),
106
     "D"(name),
107
     "S"(0) : "memory");
107
     "S"(0) : "memory");
108
};
108
};
109
 
109
 
110
#define POS_SCREEN 0
110
#define POS_SCREEN 0
111
#define POS_WINDOW 1
111
#define POS_WINDOW 1
112
 
112
 
113
static inline
113
static inline
114
pos_t get_mouse_pos(int origin)
114
pos_t get_mouse_pos(int origin)
115
{
115
{
116
    pos_t val;
116
    pos_t val;
117
 
117
 
118
    __asm__ __volatile__(
118
    __asm__ __volatile__(
119
    "int $0x40 \n\t"
119
    "int $0x40 \n\t"
120
    "rol $16, %%eax"
120
    "rol $16, %%eax"
121
    :"=a"(val)
121
    :"=a"(val)
122
    :"a"(37),"b"(origin));
122
    :"a"(37),"b"(origin));
123
    return val;
123
    return val;
124
}
124
}
125
static inline pos_t GetMousePos(int origin) __attribute__ ((alias ("get_mouse_pos")));
125
static inline pos_t GetMousePos(int origin) __attribute__ ((alias ("get_mouse_pos")));
126
 
126
 
127
static inline
127
static inline
128
uint32_t get_mouse_buttons(void)
128
uint32_t get_mouse_buttons(void)
129
{
129
{
130
    uint32_t val;
130
    uint32_t val;
131
 
131
 
132
    __asm__ __volatile__(
132
    __asm__ __volatile__(
133
    "int $0x40"
133
    "int $0x40"
134
    :"=a"(val)
134
    :"=a"(val)
135
    :"a"(37),"b"(2));
135
    :"a"(37),"b"(2));
136
    return val;
136
    return val;
137
};
137
};
138
static inline uint32_t GetMouseButtons(void) __attribute__ ((alias ("get_mouse_buttons")));
138
static inline uint32_t GetMouseButtons(void) __attribute__ ((alias ("get_mouse_buttons")));
139
 
139
 
140
static inline
140
static inline
141
uint32_t get_mouse_wheels(void)
141
uint32_t get_mouse_wheels(void)
142
{
142
{
143
    uint32_t val;
143
    uint32_t val;
144
 
144
 
145
    __asm__ __volatile__(
145
    __asm__ __volatile__(
146
    "int $0x40 \n\t"
146
    "int $0x40 \n\t"
147
    :"=a"(val)
147
    :"=a"(val)
148
    :"a"(37),"b"(7));
148
    :"a"(37),"b"(7));
149
    return val;
149
    return val;
150
};
150
};
151
static inline uint32_t GetMouseWheels(void) __attribute__ ((alias ("get_mouse_wheels")));
151
static inline uint32_t GetMouseWheels(void) __attribute__ ((alias ("get_mouse_wheels")));
152
 
152
 
153
static inline
153
static inline
154
uint32_t wait_for_event(uint32_t time)
154
uint32_t wait_for_event(uint32_t time)
155
{
155
{
156
    uint32_t val;
156
    uint32_t val;
157
    __asm__ __volatile__(
157
    __asm__ __volatile__(
158
    "int $0x40"
158
    "int $0x40"
159
    :"=a"(val)
159
    :"=a"(val)
160
    :"a"(23), "b"(time));
160
    :"a"(23), "b"(time));
161
    return val;
161
    return val;
162
};
162
};
163
 
163
 
164
static inline uint32_t check_os_event()
164
static inline uint32_t check_os_event()
165
{
165
{
166
    uint32_t val;
166
    uint32_t val;
167
    __asm__ __volatile__(
167
    __asm__ __volatile__(
168
    "int $0x40"
168
    "int $0x40"
169
    :"=a"(val)
169
    :"=a"(val)
170
    :"a"(11));
170
    :"a"(11));
171
    return val;
171
    return val;
172
};
172
};
173
 
173
 
174
static inline uint32_t get_os_event()
174
static inline uint32_t get_os_event()
175
{
175
{
176
    uint32_t val;
176
    uint32_t val;
177
    __asm__ __volatile__(
177
    __asm__ __volatile__(
178
    "int $0x40"
178
    "int $0x40"
179
    :"=a"(val)
179
    :"=a"(val)
180
    :"a"(10));
180
    :"a"(10));
181
    return val;
181
    return val;
182
};
182
};
183
static inline uint32_t GetOsEvent(void) __attribute__ ((alias ("get_os_event")));
183
static inline uint32_t GetOsEvent(void) __attribute__ ((alias ("get_os_event")));
184
 
184
 
185
static inline
185
static inline
186
uint32_t get_tick_count(void)
186
uint32_t get_tick_count(void)
187
{
187
{
188
    uint32_t val;
188
    uint32_t val;
189
    __asm__ __volatile__(
189
    __asm__ __volatile__(
190
    "int $0x40"
190
    "int $0x40"
191
    :"=a"(val)
191
    :"=a"(val)
192
    :"a"(26),"b"(9));
192
    :"a"(26),"b"(9));
193
    return val;
193
    return val;
194
};
194
};
195
 
195
 
196
static inline
196
static inline
-
 
197
uint64_t get_ns_count(void)
-
 
198
{
-
 
199
    uint64_t val;
-
 
200
    __asm__ __volatile__(
-
 
201
    "int $0x40"
-
 
202
    :"=A"(val)
-
 
203
    :"a"(26), "b"(10));
-
 
204
    return val;
-
 
205
};
-
 
206
 
-
 
207
static inline
197
oskey_t get_key(void)
208
oskey_t get_key(void)
198
{
209
{
199
    oskey_t val;
210
    oskey_t val;
200
    __asm__ __volatile__(
211
    __asm__ __volatile__(
201
    "int $0x40"
212
    "int $0x40"
202
    :"=a"(val)
213
    :"=a"(val)
203
    :"a"(2));
214
    :"a"(2));
204
    return val;
215
    return val;
205
}
216
}
206
 
217
 
207
static inline
218
static inline
208
uint32_t get_os_button()
219
uint32_t get_os_button()
209
{
220
{
210
    uint32_t val;
221
    uint32_t val;
211
    __asm__ __volatile__(
222
    __asm__ __volatile__(
212
    "int $0x40"
223
    "int $0x40"
213
    :"=a"(val)
224
    :"=a"(val)
214
    :"a"(17));
225
    :"a"(17));
215
    return val>>8;
226
    return val>>8;
216
};
227
};
217
 
228
 
218
static inline uint32_t get_service(char *name)
229
static inline uint32_t get_service(char *name)
219
{
230
{
220
    uint32_t retval = 0;
231
    uint32_t retval = 0;
221
    __asm__ __volatile__(
232
    __asm__ __volatile__(
222
    "int $0x40"
233
    "int $0x40"
223
    :"=a"(retval)
234
    :"=a"(retval)
224
    :"a"(68),"b"(16),"c"(name)
235
    :"a"(68),"b"(16),"c"(name)
225
    :"memory");
236
    :"memory");
226
 
237
 
227
    return retval;
238
    return retval;
228
};
239
};
229
 
240
 
230
static inline int call_service(ioctl_t *io)
241
static inline int call_service(ioctl_t *io)
231
{
242
{
232
    int retval;
243
    int retval;
233
 
244
 
234
    __asm__ __volatile__(
245
    __asm__ __volatile__(
235
    "int $0x40"
246
    "int $0x40"
236
    :"=a"(retval)
247
    :"=a"(retval)
237
    :"a"(68),"b"(17),"c"(io)
248
    :"a"(68),"b"(17),"c"(io)
238
    :"memory","cc");
249
    :"memory","cc");
239
 
250
 
240
    return retval;
251
    return retval;
241
};
252
};
242
 
253
 
243
 
254
 
244
static inline
255
static inline
245
void draw_line(int xs, int ys, int xe, int ye, color_t color)
256
void draw_line(int xs, int ys, int xe, int ye, color_t color)
246
{
257
{
247
    __asm__ __volatile__(
258
    __asm__ __volatile__(
248
    "int $0x40"
259
    "int $0x40"
249
    ::"a"(38), "d"(color),
260
    ::"a"(38), "d"(color),
250
      "b"((xs << 16) | xe),
261
      "b"((xs << 16) | xe),
251
      "c"((ys << 16) | ye));
262
      "c"((ys << 16) | ye));
252
}
263
}
253
 
264
 
254
 
265
 
255
 
266
 
256
static inline
267
static inline
257
void draw_bar(int x, int y, int w, int h, color_t color)
268
void draw_bar(int x, int y, int w, int h, color_t color)
258
{
269
{
259
    __asm__ __volatile__(
270
    __asm__ __volatile__(
260
    "int $0x40"
271
    "int $0x40"
261
    ::"a"(13), "d"(color),
272
    ::"a"(13), "d"(color),
262
      "b"((x << 16) | w),
273
      "b"((x << 16) | w),
263
      "c"((y << 16) | h));
274
      "c"((y << 16) | h));
264
}
275
}
265
 
276
 
266
static inline
277
static inline
267
void draw_bitmap(void *bitmap, int x, int y, int w, int h)
278
void draw_bitmap(void *bitmap, int x, int y, int w, int h)
268
{
279
{
269
    __asm__ __volatile__(
280
    __asm__ __volatile__(
270
    "int $0x40"
281
    "int $0x40"
271
    ::"a"(7), "b"(bitmap),
282
    ::"a"(7), "b"(bitmap),
272
      "c"((w << 16) | h),
283
      "c"((w << 16) | h),
273
      "d"((x << 16) | y));
284
      "d"((x << 16) | y));
274
}
285
}
275
 
286
 
276
static inline
287
static inline
277
void draw_text_sys(const char *text, int x, int y, int len, color_t color)
288
void draw_text_sys(const char *text, int x, int y, int len, color_t color)
278
{
289
{
279
    __asm__ __volatile__(
290
    __asm__ __volatile__(
280
    "int $0x40"
291
    "int $0x40"
281
    ::"a"(4),"d"(text),
292
    ::"a"(4),"d"(text),
282
      "b"((x << 16) | y),
293
      "b"((x << 16) | y),
283
      "S"(len),"c"(color)
294
      "S"(len),"c"(color)
284
     :"memory");
295
     :"memory");
285
}
296
}
286
 
297
 
287
static inline void yield(void)
298
static inline void yield(void)
288
{
299
{
289
    __asm__ __volatile__(
300
    __asm__ __volatile__(
290
    "int $0x40"
301
    "int $0x40"
291
    ::"a"(68), "b"(1));
302
    ::"a"(68), "b"(1));
292
};
303
};
293
 
304
 
294
static inline void delay(uint32_t time)
305
static inline void delay(uint32_t time)
295
{
306
{
296
    __asm__ __volatile__(
307
    __asm__ __volatile__(
297
    "int $0x40"
308
    "int $0x40"
298
    ::"a"(5), "b"(time)
309
    ::"a"(5), "b"(time)
299
    :"memory");
310
    :"memory");
300
};
311
};
301
 
312
 
302
static inline
313
static inline
303
void *user_alloc(size_t size)
314
void *user_alloc(size_t size)
304
{
315
{
305
    void  *val;
316
    void  *val;
306
    __asm__ __volatile__(
317
    __asm__ __volatile__(
307
    "int $0x40"
318
    "int $0x40"
308
    :"=a"(val)
319
    :"=a"(val)
309
    :"a"(68),"b"(12),"c"(size));
320
    :"a"(68),"b"(12),"c"(size));
310
    return val;
321
    return val;
311
}
322
}
312
static inline void *UserAlloc(size_t size) __attribute__ ((alias ("user_alloc")));
323
static inline void *UserAlloc(size_t size) __attribute__ ((alias ("user_alloc")));
313
 
324
 
314
static inline
325
static inline
315
int user_free(void *mem)
326
int user_free(void *mem)
316
{
327
{
317
    int  val;
328
    int  val;
318
    __asm__ __volatile__(
329
    __asm__ __volatile__(
319
    "int $0x40"
330
    "int $0x40"
320
    :"=a"(val)
331
    :"=a"(val)
321
    :"a"(68),"b"(13),"c"(mem));
332
    :"a"(68),"b"(13),"c"(mem));
322
    return val;
333
    return val;
323
}
334
}
324
static inline int UserFree(void *mem) __attribute__ ((alias ("user_free")));
335
static inline int UserFree(void *mem) __attribute__ ((alias ("user_free")));
325
 
336
 
326
static inline
337
static inline
327
int *user_unmap(void *base, size_t offset, size_t size)
338
int *user_unmap(void *base, size_t offset, size_t size)
328
{
339
{
329
    int  *val;
340
    int  *val;
330
    __asm__ __volatile__(
341
    __asm__ __volatile__(
331
    "int $0x40"
342
    "int $0x40"
332
    :"=a"(val)
343
    :"=a"(val)
333
    :"a"(68),"b"(26),"c"(base),"d"(offset),"S"(size));
344
    :"a"(68),"b"(26),"c"(base),"d"(offset),"S"(size));
334
    return val;
345
    return val;
335
};
346
};
336
static inline int *UserUnmap(void *base, size_t offset, size_t size) __attribute__ ((alias ("user_unmap")));
347
static inline int *UserUnmap(void *base, size_t offset, size_t size) __attribute__ ((alias ("user_unmap")));
337
 
348
 
338
typedef union
349
typedef union
339
{
350
{
340
    struct
351
    struct
341
    {
352
    {
342
        void   *data;
353
        void   *data;
343
        size_t  size;
354
        size_t  size;
344
    };
355
    };
345
    unsigned long long raw;
356
    unsigned long long raw;
346
}ufile_t;
357
}ufile_t;
347
 
358
 
348
 
359
 
349
static inline ufile_t load_file(const char *path)
360
static inline ufile_t load_file(const char *path)
350
{
361
{
351
    ufile_t uf;
362
    ufile_t uf;
352
 
363
 
353
    __asm__ __volatile__ (
364
    __asm__ __volatile__ (
354
    "int $0x40"
365
    "int $0x40"
355
    :"=A"(uf.raw)
366
    :"=A"(uf.raw)
356
    :"a" (68), "b"(27),"c"(path));
367
    :"a" (68), "b"(27),"c"(path));
357
 
368
 
358
    return uf;
369
    return uf;
359
};
370
};
360
static inline ufile_t LoadFile(const char *path) __attribute__ ((alias ("load_file")));
371
static inline ufile_t LoadFile(const char *path) __attribute__ ((alias ("load_file")));
361
 
372
 
362
static inline int GetScreenSize()
373
static inline int GetScreenSize()
363
{
374
{
364
    int retval;
375
    int retval;
365
 
376
 
366
    __asm__ __volatile__(
377
    __asm__ __volatile__(
367
    "int $0x40"
378
    "int $0x40"
368
    :"=a"(retval)
379
    :"=a"(retval)
369
    :"a"(61), "b"(1));
380
    :"a"(61), "b"(1));
370
    return retval;
381
    return retval;
371
}
382
}
372
 
383
 
373
static inline
384
static inline
374
uint32_t  load_cursor(void *path, uint32_t flags)
385
uint32_t  load_cursor(void *path, uint32_t flags)
375
{
386
{
376
    uint32_t  val;
387
    uint32_t  val;
377
    __asm__ __volatile__(
388
    __asm__ __volatile__(
378
    "int $0x40"
389
    "int $0x40"
379
    :"=a"(val)
390
    :"=a"(val)
380
    :"a"(37), "b"(4), "c"(path), "d"(flags));
391
    :"a"(37), "b"(4), "c"(path), "d"(flags));
381
    return val;
392
    return val;
382
}
393
}
383
static inline
394
static inline
384
uint32_t  LoadCursor(void *path, uint32_t flags) __attribute__ ((alias ("load_cursor")));
395
uint32_t  LoadCursor(void *path, uint32_t flags) __attribute__ ((alias ("load_cursor")));
385
 
396
 
386
static inline
397
static inline
387
uint32_t  set_cursor(uint32_t  cursor)
398
uint32_t  set_cursor(uint32_t  cursor)
388
{
399
{
389
    uint32_t  old;
400
    uint32_t  old;
390
    __asm__ __volatile__(
401
    __asm__ __volatile__(
391
    "int $0x40"
402
    "int $0x40"
392
    :"=a"(old)
403
    :"=a"(old)
393
    :"a"(37), "b"(5), "c"(cursor));
404
    :"a"(37), "b"(5), "c"(cursor));
394
    return old;
405
    return old;
395
};
406
};
396
static inline uint32_t SetCursor(uint32_t  cursor) __attribute__ ((alias ("set_cursor")));
407
static inline uint32_t SetCursor(uint32_t  cursor) __attribute__ ((alias ("set_cursor")));
397
 
408
 
398
static inline
409
static inline
399
int destroy_cursor(uint32_t cursor)
410
int destroy_cursor(uint32_t cursor)
400
{
411
{
401
    int ret;
412
    int ret;
402
    __asm__ __volatile__(
413
    __asm__ __volatile__(
403
    "int $0x40"
414
    "int $0x40"
404
    :"=a"(ret)
415
    :"=a"(ret)
405
    :"a"(37), "b"(6), "c"(cursor)
416
    :"a"(37), "b"(6), "c"(cursor)
406
    :"memory");
417
    :"memory");
407
    return ret;
418
    return ret;
408
};
419
};
409
static inline int DestroyCursor(uint32_t cursor) __attribute__ ((alias ("destroy_cursor")));
420
static inline int DestroyCursor(uint32_t cursor) __attribute__ ((alias ("destroy_cursor")));
410
 
421
 
411
static inline void get_proc_info(char *info)
422
static inline void get_proc_info(char *info)
412
{
423
{
413
    __asm__ __volatile__(
424
    __asm__ __volatile__(
414
    "int $0x40"
425
    "int $0x40"
415
    :
426
    :
416
    :"a"(9), "b"(info), "c"(-1));
427
    :"a"(9), "b"(info), "c"(-1));
417
};
428
};
418
static inline void GetProcInfo(char *info) __attribute__ ((alias ("get_proc_info")));
429
static inline void GetProcInfo(char *info) __attribute__ ((alias ("get_proc_info")));
419
 
430
 
420
static inline
431
static inline
421
void* user_realloc(void *mem, size_t size)
432
void* user_realloc(void *mem, size_t size)
422
{
433
{
423
    void *val;
434
    void *val;
424
    __asm__ __volatile__(
435
    __asm__ __volatile__(
425
    "int $0x40"
436
    "int $0x40"
426
    :"=a"(val)
437
    :"=a"(val)
427
    :"a"(68),"b"(20),"c"(size),"d"(mem)
438
    :"a"(68),"b"(20),"c"(size),"d"(mem)
428
    :"memory");
439
    :"memory");
429
 
440
 
430
    return val;
441
    return val;
431
};
442
};
432
static inline void* UserRealloc(void *mem, size_t size) __attribute__ ((alias ("user_realloc")));
443
static inline void* UserRealloc(void *mem, size_t size) __attribute__ ((alias ("user_realloc")));
433
 
444
 
434
void *get_resource(void *data, uint32_t id);
445
void *get_resource(void *data, uint32_t id);
435
 
446
 
436
struct blit_call
447
struct blit_call
437
{
448
{
438
    int dstx;
449
    int dstx;
439
    int dsty;
450
    int dsty;
440
    int w;
451
    int w;
441
    int h;
452
    int h;
442
 
453
 
443
    int srcx;
454
    int srcx;
444
    int srcy;
455
    int srcy;
445
    int srcw;
456
    int srcw;
446
    int srch;
457
    int srch;
447
 
458
 
448
    void *bitmap;
459
    void *bitmap;
449
    int   stride;
460
    int   stride;
450
};
461
};
451
 
462
 
452
static inline void Blit(void *bitmap, int dst_x, int dst_y,
463
static inline void Blit(void *bitmap, int dst_x, int dst_y,
453
                        int src_x, int src_y, int w, int h,
464
                        int src_x, int src_y, int w, int h,
454
                        int src_w, int src_h, int stride)
465
                        int src_w, int src_h, int stride)
455
{
466
{
456
    volatile struct blit_call bc;
467
    volatile struct blit_call bc;
457
 
468
 
458
    bc.dstx = dst_x;
469
    bc.dstx = dst_x;
459
    bc.dsty = dst_y;
470
    bc.dsty = dst_y;
460
    bc.w    = w;
471
    bc.w    = w;
461
    bc.h    = h;
472
    bc.h    = h;
462
    bc.srcx = src_x;
473
    bc.srcx = src_x;
463
    bc.srcy = src_y;
474
    bc.srcy = src_y;
464
    bc.srcw = src_w;
475
    bc.srcw = src_w;
465
    bc.srch = src_h;
476
    bc.srch = src_h;
466
    bc.stride = stride;
477
    bc.stride = stride;
467
    bc.bitmap = bitmap;
478
    bc.bitmap = bitmap;
468
 
479
 
469
    __asm__ __volatile__(
480
    __asm__ __volatile__(
470
    "int $0x40"
481
    "int $0x40"
471
    ::"a"(73),"b"(0),"c"(&bc.dstx));
482
    ::"a"(73),"b"(0),"c"(&bc.dstx));
472
};
483
};
473
 
484
 
474
void* load_library(const char *name);
485
void* load_library(const char *name);
475
 
486
 
476
void* get_proc_address(void *handle, const char *proc_name);
487
void* get_proc_address(void *handle, const char *proc_name);
477
 
488
 
478
void enumerate_libraries(int (*callback)(void *handle, const char* name,
489
void enumerate_libraries(int (*callback)(void *handle, const char* name,
479
                                         uint32_t base, uint32_t size, void *user_data),
490
                                         uint32_t base, uint32_t size, void *user_data),
480
                         void *user_data);
491
                         void *user_data);
481
 
492
 
482
#ifdef __cplusplus
493
#ifdef __cplusplus
483
}
494
}
484
#endif
495
#endif
485
 
496
 
486
 
497
 
487
#endif
498
#endif