Subversion Repositories Kolibri OS

Rev

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

Rev 6439 Rev 6441
Line 25... Line 25...
25
//#endif
25
//#endif
Line 26... Line 26...
26
 
26
 
27
#define TYPE_3_BORDER_WIDTH  5
27
#define TYPE_3_BORDER_WIDTH  5
28
#define WIN_STATE_MINIMIZED  0x02
28
#define WIN_STATE_MINIMIZED  0x02
-
 
29
#define WIN_STATE_ROLLED     0x04
-
 
30
#define POS_SCREEN 0
-
 
31
#define POS_WINDOW 1
-
 
32
 
-
 
33
#define IPC_NOBUFFER 1
-
 
34
#define IPC_LOCKED 2
-
 
35
#define IPC_OVERFLOW 3
-
 
36
#define IPC_NOPID 4
-
 
37
 
-
 
38
#define SHM_OPEN        0x00
-
 
39
#define SHM_OPEN_ALWAYS 0x04
-
 
40
#define SHM_CREATE      0x08
-
 
41
#define SHM_READ        0x00
-
 
42
#define SHM_WRITE       0x01
-
 
43
 
Line 29... Line 44...
29
#define WIN_STATE_ROLLED     0x04
44
 
Line 30... Line 45...
30
 
45
 
Line 61... Line 76...
61
  int           inp_size;
76
  int           inp_size;
62
  void          *output;
77
  void          *output;
63
  int           out_size;
78
  int           out_size;
64
}ioctl_t;
79
}ioctl_t;
Line -... Line 80...
-
 
80
 
-
 
81
typedef union
-
 
82
{
-
 
83
    struct
-
 
84
    {
-
 
85
        void   *data;
-
 
86
        size_t  size;
-
 
87
    } x;
-
 
88
    unsigned long long raw;
-
 
89
}ufile_t;
-
 
90
 
-
 
91
struct kolibri_system_colors {
-
 
92
  color_t frame_area;
-
 
93
  color_t grab_bar;
-
 
94
  color_t grab_bar_button;
-
 
95
  color_t grab_button_text;
-
 
96
  color_t grab_text;
-
 
97
  color_t work_area;
-
 
98
  color_t work_button;
-
 
99
  color_t work_button_text;
-
 
100
  color_t work_text;
-
 
101
  color_t work_graph;
-
 
102
};
-
 
103
 
-
 
104
 
-
 
105
struct blit_call
-
 
106
{
-
 
107
    int dstx;
-
 
108
    int dsty;
-
 
109
    int w;
-
 
110
    int h;
-
 
111
 
-
 
112
    int srcx;
-
 
113
    int srcy;
-
 
114
    int srcw;
-
 
115
    int srch;
-
 
116
 
-
 
117
    void *bitmap;
-
 
118
    int   stride;
-
 
119
};
-
 
120
 
-
 
121
struct ipc_message
-
 
122
{
-
 
123
    uint32_t    pid;        // PID of sending thread
-
 
124
    uint32_t    datalen;    // data bytes
-
 
125
    char        data[0];    // data begin
-
 
126
};
-
 
127
 
-
 
128
struct ipc_buffer
-
 
129
{
-
 
130
    uint32_t    lock;   // nonzero is locked
-
 
131
    uint32_t    used;   // used bytes in buffer
-
 
132
    struct ipc_message  data[0];    // data begin
-
 
133
};
65
 
134
 
66
static inline void begin_draw(void)
135
static inline void begin_draw(void)
67
{
136
{
68
    __asm__ __volatile__(
137
    __asm__ __volatile__(
69
    "int $0x40" ::"a"(12),"b"(1));
138
    "int $0x40" ::"a"(12),"b"(1));
Line 153... Line 222...
153
    :"=a"(height)
222
    :"=a"(height)
154
    :"a"(48),"b"(4));
223
    :"a"(48),"b"(4));
155
    return height;
224
    return height;
156
};
225
};
Line 157... Line -...
157
 
-
 
158
/*
-
 
159
// TinyC dont support aliasing of static inline funcs
-
 
160
static inline void BeginDraw(void) __attribute__ ((alias ("begin_draw")));
-
 
161
static inline void EndDraw(void) __attribute__ ((alias ("end_draw")));
-
 
162
static inline void DrawWindow(int x, int y, int w, int h, const char *name,
-
 
163
                              color_t workcolor, uint32_t style)
-
 
164
                              __attribute__ ((alias ("sys_create_window")));
-
 
165
static inline void DefineButton(void) __attribute__ ((alias ("define_button")));
-
 
166
static inline void DrawLine(int xs, int ys, int xe, int ye, color_t color)
-
 
167
                            __attribute__ ((alias ("draw_line")));
-
 
168
static inline void DrawBar(int x, int y, int w, int h, color_t color)
-
 
169
                           __attribute__ ((alias ("draw_bar")));
-
 
170
static inline void DrawBitmap(void *bitmap, int x, int y, int w, int h)
-
 
171
                              __attribute__ ((alias ("draw_bitmap")));
-
 
172
static inline uint32_t GetSkinHeight(void) __attribute__ ((alias ("get_skin_height")));
-
 
173
*/
-
 
174
 
-
 
175
#define POS_SCREEN 0
-
 
176
#define POS_WINDOW 1
-
 
177
 
226
 
178
static inline
227
static inline
179
pos_t get_mouse_pos(int origin)
228
pos_t get_mouse_pos(int origin)
180
{
229
{
Line 241... Line 290...
241
    :"a"(37), "b"(6), "c"(cursor)
290
    :"a"(37), "b"(6), "c"(cursor)
242
    :"memory");
291
    :"memory");
243
    return ret;
292
    return ret;
244
};
293
};
Line 245... Line -...
245
 
-
 
246
/*
-
 
247
static inline pos_t GetMousePos(int origin) __attribute__ ((alias ("get_mouse_pos")));
-
 
248
static inline uint32_t GetMouseButtons(void) __attribute__ ((alias ("get_mouse_buttons")));
-
 
249
static inline uint32_t GetMouseWheels(void) __attribute__ ((alias ("get_mouse_wheels")));
-
 
250
 
-
 
251
static inline uint32_t  LoadCursor(void *path, uint32_t flags) __attribute__ ((alias ("load_cursor")));
-
 
252
static inline uint32_t SetCursor(uint32_t  cursor) __attribute__ ((alias ("set_cursor")));
-
 
253
static inline int DestroyCursor(uint32_t cursor) __attribute__ ((alias ("destroy_cursor")));
-
 
Line 254... Line 294...
254
*/
294
 
255
 
295
 
256
static inline
296
static inline
257
uint32_t wait_for_event(uint32_t time)
297
uint32_t wait_for_event(uint32_t time)
Line 281... Line 321...
281
    "int $0x40"
321
    "int $0x40"
282
    :"=a"(val)
322
    :"=a"(val)
283
    :"a"(10));
323
    :"a"(10));
284
    return val;
324
    return val;
285
};
325
};
286
//static inline uint32_t GetOsEvent(void) __attribute__ ((alias ("get_os_event")));
-
 
Line 287... Line 326...
287
 
326
 
288
static inline
327
static inline
289
uint32_t get_tick_count(void)
328
uint32_t get_tick_count(void)
290
{
329
{
Line 414... Line 453...
414
    :"=a"(val)
453
    :"=a"(val)
415
    :"a"(68),"b"(26),"c"(base),"d"(offset),"S"(size));
454
    :"a"(68),"b"(26),"c"(base),"d"(offset),"S"(size));
416
    return val;
455
    return val;
417
};
456
};
Line 418... Line -...
418
 
-
 
419
/*
-
 
420
static inline void *UserAlloc(size_t size) __attribute__ ((alias ("user_alloc")));
-
 
421
static inline int UserFree(void *mem) __attribute__ ((alias ("user_free")));
-
 
422
static inline void* UserRealloc(void *mem, size_t size) __attribute__ ((alias ("user_realloc")));
-
 
423
static inline int *UserUnmap(void *base, size_t offset, size_t size) __attribute__ ((alias ("user_unmap")));
-
 
424
*/
-
 
425
 
-
 
426
typedef union
-
 
427
{
-
 
428
    struct
-
 
429
    {
-
 
430
        void   *data;
-
 
431
        size_t  size;
-
 
432
    } x;
-
 
433
    unsigned long long raw;
-
 
434
}ufile_t;
-
 
435
 
457
 
436
static inline ufile_t load_file(const char *path)
458
static inline ufile_t load_file(const char *path)
437
{
459
{
Line 438... Line 460...
438
    ufile_t uf;
460
    ufile_t uf;
Line 442... Line 464...
442
    :"=A"(uf.raw)
464
    :"=A"(uf.raw)
443
    :"a" (68), "b"(27),"c"(path));
465
    :"a" (68), "b"(27),"c"(path));
Line 444... Line 466...
444
 
466
 
445
    return uf;
467
    return uf;
446
};
-
 
Line 447... Line 468...
447
//static inline ufile_t LoadFile(const char *path) __attribute__ ((alias ("load_file")));
468
};
448
 
469
 
449
static inline int GetScreenSize()
470
static inline int GetScreenSize()
Line 464... Line 485...
464
    "int $0x40"
485
    "int $0x40"
465
    :
486
    :
466
    :"a"(9), "b"(info), "c"(-1)
487
    :"a"(9), "b"(info), "c"(-1)
467
    :"memory");
488
    :"memory");
468
};
489
};
469
//static inline void GetProcInfo(char *info) __attribute__ ((alias ("get_proc_info")));
-
 
470
 
-
 
471
 
-
 
472
struct blit_call
-
 
473
{
-
 
474
    int dstx;
-
 
475
    int dsty;
-
 
476
    int w;
-
 
477
    int h;
-
 
478
 
-
 
479
    int srcx;
-
 
480
    int srcy;
-
 
481
    int srcw;
-
 
482
    int srch;
-
 
483
 
-
 
484
    void *bitmap;
-
 
485
    int   stride;
-
 
486
};
-
 
Line 487... Line 490...
487
 
490
 
488
static inline void Blit(void *bitmap, int dst_x, int dst_y,
491
static inline void Blit(void *bitmap, int dst_x, int dst_y,
489
                        int src_x, int src_y, int w, int h,
492
                        int src_x, int src_y, int w, int h,
490
                        int src_w, int src_h, int stride)
493
                        int src_w, int src_h, int stride)
Line 505... Line 508...
505
    __asm__ __volatile__(
508
    __asm__ __volatile__(
506
    "int $0x40"
509
    "int $0x40"
507
    ::"a"(73),"b"(0),"c"(&bc.dstx));
510
    ::"a"(73),"b"(0),"c"(&bc.dstx));
508
};
511
};
Line -... Line 512...
-
 
512
 
-
 
513
 
-
 
514
// newlib exclusive
509
 
515
#ifndef __TINYC__
Line 510... Line 516...
510
int create_thread(int (*proc)(void *param), void *param, int stack_size);
516
int create_thread(int (*proc)(void *param), void *param, int stack_size);
Line 511... Line 517...
511
 
517
 
Line 512... Line 518...
512
void* load_library(const char *name);
518
void* load_library(const char *name);
513
 
519
 
514
void* get_proc_address(void *handle, const char *proc_name);
520
void* get_proc_address(void *handle, const char *proc_name);
515
 
521
 
Line 516... Line 522...
516
void enumerate_libraries(int (*callback)(void *handle, const char* name,
522
void enumerate_libraries(int (*callback)(void *handle, const char* name,
Line 517... Line 523...
517
                                         uint32_t base, uint32_t size, void *user_data),
523
                                         uint32_t base, uint32_t size, void *user_data),
518
                         void *user_data);
524
                         void *user_data);
Line 575... Line 581...
575
    register uint32_t val;
581
    register uint32_t val;
576
    asm volatile ("int $0x40":"=a"(val):"a"(54), "b"(4));
582
    asm volatile ("int $0x40":"=a"(val):"a"(54), "b"(4));
577
    return val;
583
    return val;
578
}
584
}
Line 579... Line -...
579
 
-
 
580
struct kolibri_system_colors {
-
 
581
  color_t frame_area;
-
 
582
  color_t grab_bar;
-
 
583
  color_t grab_bar_button;
-
 
584
  color_t grab_button_text;
-
 
585
  color_t grab_text;
-
 
586
  color_t work_area;
-
 
587
  color_t work_button;
-
 
588
  color_t work_button_text;
-
 
589
  color_t work_text;
-
 
590
  color_t work_graph;
-
 
591
};
-
 
592
 
585
 
593
static inline void get_system_colors(struct kolibri_system_colors *color_table)
586
static inline void get_system_colors(struct kolibri_system_colors *color_table)
594
{
587
{
595
  __asm__ volatile ("int $0x40"
588
  __asm__ volatile ("int $0x40"
596
		    :
589
		    :
Line 672... Line 665...
672
    register int val;
665
    register int val;
673
    asm volatile ("int $0x40":"=a"(val):"a"(30), "b"(2), "c"(buf), "d"(bufsize));
666
    asm volatile ("int $0x40":"=a"(val):"a"(30), "b"(2), "c"(buf), "d"(bufsize));
674
    return val;
667
    return val;
675
}
668
}
Line -... Line 669...
-
 
669
 
-
 
670
static inline
-
 
671
void ipc_set_area(void* buf, int bufsize){
-
 
672
    asm volatile ("int $0x40"::"a"(60), "b"(1), "c"(buf), "d"(bufsize));
-
 
673
}
-
 
674
 
-
 
675
static inline
-
 
676
int ipc_send_message(int pid_reciever, void *data, int datalen) {
-
 
677
    register int val;
-
 
678
    asm volatile ("int $0x40":"=a"(val):"a"(60), "b"(2), "c"(pid_reciever), "d"(data), "S"(datalen));
-
 
679
    return val;
-
 
680
}
-
 
681
 
-
 
682
static inline
-
 
683
void* shm_open(char *shm_name, int msize, int flags, int *retsz){
-
 
684
    register int val, cod;
-
 
685
    asm volatile ("int $0x40":"=a"(val),"=d"(cod):"a"(68), "b"(22), "c"(shm_name), "d"(msize), "S"(flags));
-
 
686
 
-
 
687
    if(retsz) *retsz = cod;  // errcode if NULL or memsize when open
-
 
688
    return (void*)val;
-
 
689
}
-
 
690
 
-
 
691
static inline
-
 
692
void shm_close(char *shm_name){
-
 
693
    asm volatile ("int $0x40"::"a"(68), "b"(23), "c"(shm_name));
-
 
694
}
-
 
695
 
-
 
696
static inline
-
 
697
int start_app(char *app_name, char *args){
-
 
698
    struct file_op_t
-
 
699
    {
-
 
700
        uint32_t    fn;
-
 
701
        uint32_t    flags;
-
 
702
        char*       args;
-
 
703
        uint32_t    res1, res2;
-
 
704
        char        zero;
-
 
705
        char*       app_name  __attribute__((packed));
-
 
706
    } file_op;
-
 
707
    memset(&file_op, 0, sizeof(file_op));
-
 
708
    file_op.fn = 7;
-
 
709
    file_op.args = args;
-
 
710
    file_op.app_name = app_name;
-
 
711
 
-
 
712
    register int val;
-
 
713
    asm volatile ("int $0x40":"=a"(val):"a"(70), "b"(&file_op));
-
 
714
 
-
 
715
    return val;
-
 
716
}
-
 
717
 
676
 
718
 
677
/*
719
/*
678
static inline char *getcwd(char *buf, size_t size)
720
static inline char *getcwd(char *buf, size_t size)
679
{
721
{
680
	int rc = get_current_folder(buf, size);
722
	int rc = get_current_folder(buf, size);
Line 711... Line 753...
711
        va_end(ap);
753
        va_end(ap);
712
        debug_board_write_str(log_board);
754
        debug_board_write_str(log_board);
713
}
755
}
714
*/
756
*/
Line -... Line 757...
-
 
757
 
-
 
758
 
-
 
759
 
-
 
760
// TinyC don't support aliasing of static inline funcs
-
 
761
#ifndef __TINYC__
-
 
762
static inline void BeginDraw(void) __attribute__ ((alias ("begin_draw")));
-
 
763
static inline void EndDraw(void) __attribute__ ((alias ("end_draw")));
-
 
764
static inline void DrawWindow(int x, int y, int w, int h, const char *name,
-
 
765
                              color_t workcolor, uint32_t style)
-
 
766
                              __attribute__ ((alias ("sys_create_window")));
-
 
767
static inline void DefineButton(void) __attribute__ ((alias ("define_button")));
-
 
768
static inline void DrawLine(int xs, int ys, int xe, int ye, color_t color)
-
 
769
                            __attribute__ ((alias ("draw_line")));
-
 
770
static inline void DrawBar(int x, int y, int w, int h, color_t color)
-
 
771
                           __attribute__ ((alias ("draw_bar")));
-
 
772
static inline void DrawBitmap(void *bitmap, int x, int y, int w, int h)
-
 
773
                              __attribute__ ((alias ("draw_bitmap")));
-
 
774
static inline uint32_t GetSkinHeight(void) __attribute__ ((alias ("get_skin_height")));
-
 
775
static inline pos_t GetMousePos(int origin) __attribute__ ((alias ("get_mouse_pos")));
-
 
776
static inline uint32_t GetMouseButtons(void) __attribute__ ((alias ("get_mouse_buttons")));
-
 
777
static inline uint32_t GetMouseWheels(void) __attribute__ ((alias ("get_mouse_wheels")));
-
 
778
static inline uint32_t  LoadCursor(void *path, uint32_t flags) __attribute__ ((alias ("load_cursor")));
-
 
779
static inline uint32_t SetCursor(uint32_t  cursor) __attribute__ ((alias ("set_cursor")));
-
 
780
static inline int DestroyCursor(uint32_t cursor) __attribute__ ((alias ("destroy_cursor")));
-
 
781
static inline uint32_t GetOsEvent(void) __attribute__ ((alias ("get_os_event")));
-
 
782
static inline void *UserAlloc(size_t size) __attribute__ ((alias ("user_alloc")));
-
 
783
static inline int UserFree(void *mem) __attribute__ ((alias ("user_free")));
-
 
784
static inline void* UserRealloc(void *mem, size_t size) __attribute__ ((alias ("user_realloc")));
-
 
785
static inline int *UserUnmap(void *base, size_t offset, size_t size) __attribute__ ((alias ("user_unmap")));
-
 
786
static inline ufile_t LoadFile(const char *path) __attribute__ ((alias ("load_file")));
-
 
787
static inline void GetProcInfo(char *info) __attribute__ ((alias ("get_proc_info")));
-
 
788
#endif
715
 
789
 
716
#ifdef __cplusplus
790
#ifdef __cplusplus
717
}
791
}