Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. #ifndef __GLIBC__MENUET_OS_H
  2. #define __GLIBC__MENUET_OS_H
  3.  
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7.  
  8. typedef unsigned char       __u8;
  9. typedef unsigned short      __u16;
  10. typedef unsigned long       __u32;
  11.  
  12. #pragma pack(push,1)
  13.  
  14. void __menuet__define_window(__u16 x1,__u16 y1,__u16 xsize,__u16 ysize,
  15.      __u32 body_color,__u32 grab_color,__u32 frame_color);
  16. void __menuet__window_redraw(int status);
  17. void __menuet__putpixel(__u32 x,__u32 y,__u32 color);
  18. int __menuet__getkey(void);
  19. __u32 __menuet__getsystemclock(void);
  20. void __menuet__write_text(__u16 x,__u16 y,__u32 color,char * text,int len);
  21. void __menuet__delay100(int m);
  22. __u32 __menuet__open(char * name,char * data);
  23. void __menuet__save(char * name,char * data,__u32 count);
  24. void __menuet__putimage(__u16 x1,__u16 y1,__u16 xsize,__u16 ysize,char * image);
  25. void __menuet__make_button(__u16 x1,__u16 y1,__u16 xsize,__u16 ysize, int id,__u32 color);
  26. int __menuet__get_button_id(void);
  27. int __menuet__wait_for_event(void);
  28. int __menuet__check_for_event(void);
  29. void __menuet__bar(__u16 x1,__u16 y1,__u16 xsize,__u16 ysize,__u32 color);
  30. void __menuet__sys_exit(void);
  31. void * __menuet__exec_thread(void (* func_ptr)(void),__u32 stack_size,int * retp);
  32. void __menuet__idle(void);
  33.  
  34. void __menuet__exec_ramdisk(char * filename,char * args,...);
  35. void __menuet__exec_hd(char * filename,char * args,...);
  36.  
  37. struct process_table_entry
  38. {
  39.  __u32 cpu_usage;
  40.  __u16 pos_in_windowing_stack;
  41.  __u16 win_stack_val_at_ecx;
  42.  __u16 reserved1;
  43.  char name[12];
  44.  __u32 memstart;
  45.  __u32 memused;
  46.  __u32 pid;
  47.  __u32 winx_start,winy_start;
  48.  __u32 winx_size,winy_size;
  49.  __u16 thread_state;
  50.  __u16 reserved2;
  51.  __u32 client_left,client_top,client_width,client_height;
  52.  __u8 window_state;
  53.  __u8 reserved3[1024-71];
  54. };
  55.  
  56. #define PID_WHOAMI              (-1)
  57.  
  58. int __menuet__get_process_table(struct process_table_entry * proctab,int pid);
  59. void __menuet__get_screen_max(__u16 * x,__u16 * y);
  60.  
  61. #define BTYPE_TILE                  1
  62. #define BTYPE_STRETCH               2
  63.  
  64. void __menuet__set_background_size(__u32 xsz,__u32 ysz);
  65. void __menuet__write_background_mem(__u32 pos,__u32 color);
  66. void __menuet__draw_background(void);
  67. void __menuet__set_background_draw_type(int type);
  68. void __menuet__background_blockmove(char * src_ptr,__u32 bgr_dst,__u32 count);
  69.  
  70. void __menuet__reset_mpu401(void);
  71. void __menuet__write_mpu401(__u8 d);
  72.  
  73. __u32 __menuet__get_date(void);
  74.  
  75. void __menuet__line(__u16 x1,__u16 y1,__u16 x2,__u16 y2,__u32 color);
  76.  
  77. void __menuet__set_bitfield_for_wanted_events(__u16 ev);
  78.  
  79. #define EVENT_REDRAW              0x00000001
  80. #define EVENT_KEY                 0x00000002
  81. #define EVENT_BUTTON              0x00000004
  82. #define EVENT_END_REQUEST         0x00000008
  83. #define EVENT_DESKTOP_BACK_DRAW   0x00000010
  84. #define EVENT_MOUSE_CHANGE        0x00000020
  85. #define EVENT_IPC                 0x00000040
  86. #define EVENT_GET_IRQS_MASK       0xFFFF0000
  87. #define EVENT_GET_IRQ(e)          (((e)>>16)&0xFFFF)
  88.  
  89. __u32 __menuet__get_irq_owner(__u32 irq);
  90. int __menuet__get_data_read_by_irq(__u32 irq,__u32 * num_bytes_in_buf,__u8 * data);
  91. int __menuet__send_data_to_device(__u16 port,__u8 val);
  92. void __menuet__program_irq(void * intr_table,__u32 irq_num);
  93. int __menuet__reserve_irq(int irqno);
  94. int __menuet__free_irq(int irqno);
  95. int __menuet__reserve_port_area(__u32 start,__u32 end);
  96. int __menuet__free_port_area(__u32 start,__u32 end);
  97.  
  98.  
  99. #define NAME_LEN                   512
  100.  
  101. #define STC_READ                  0
  102. #define STC_WRITE                 1
  103. #define STC_APPEND                2
  104.  
  105. struct systree_info
  106. {
  107.         __u32 command;
  108.         __u32 file_offset_low;
  109.         __u32 file_offset_high;
  110.         __u32 size;
  111.         __u32 data_pointer;
  112.         char _zero;
  113.         const char* nameptr;
  114. };
  115.  
  116. struct systree_info2
  117. {
  118.         __u32 command;
  119.         __u32 file_offset_low;
  120.         __u32 file_offset_high;
  121.         __u32 size;
  122.         __u32 data_pointer;
  123.         char name[NAME_LEN];
  124. };
  125.  
  126. struct bdfe_time
  127. {
  128.         __u8 seconds;
  129.         __u8 minutes;
  130.         __u8 hours;
  131.         __u8 reserved;
  132. };
  133. struct bdfe_date
  134. {
  135.         __u8 day;
  136.         __u8 month;
  137.         __u16 year;
  138. };
  139. struct bdfe_item
  140. {
  141.         __u32 attr;
  142.         __u8 nametype;
  143.         __u8 reserved[3];
  144.         struct bdfe_time ctime;
  145.         struct bdfe_date cdate;
  146.         struct bdfe_time atime;
  147.         struct bdfe_date adate;
  148.         struct bdfe_time mtime;
  149.         struct bdfe_date mdate;
  150.         __u32 filesize_low;
  151.         __u32 filesize_high;
  152. };
  153.  
  154. int __kolibri__system_tree_access(struct systree_info * info);
  155. int __kolibri__system_tree_access2(struct systree_info2 * info);
  156.  
  157. int __fslayer_open(char * name,int flags);
  158. int __fslayer_close(int fd);
  159. int __fslayer_lseek(int fd,int pos,int seek_type);
  160. int __fslayer_tell(int fd);
  161. int __fslayer_read(int fd,void * buffer,__u32 count);
  162. int __fslayer_write(int fd,void * buffer,__u32 count);
  163.  
  164. typedef struct
  165. {
  166.  __u8 lock;
  167.  __u8 resvd[3];
  168.  __u32 ptr_to_fmsg_pos;
  169.  /* Below is for message */
  170.  __u32 sender_pid;
  171.  __u32 msg_length;
  172. } msgrcva_t /*__attribute__((packed))*/;
  173.  
  174. void send_message(int pid,void * msg_ptr,int message_size);
  175. void define_receive_area(msgrcva_t * rcva_ptr,int size);
  176.  
  177. void __menuet__sound_load_block(char * blockptr);
  178. void __menuet__sound_play_block(void);
  179.  
  180. void __menuet__dga_get_caps(int * xres,int * yres,int * bpp,int * bpscan);
  181.  
  182. void get_pci_version(__u8 * major,__u8 * minor);
  183. void pci_get_last_bus(__u8 * last_bus);
  184. void get_pci_access_mechanism(__u8 * mechanism);
  185.  
  186. void pci_write_config_byte(__u8 bus,__u8 dev,__u8 fn,__u8 reg,__u8 val);
  187. void pci_write_config_word(__u8 bus,__u8 dev,__u8 fn,__u8 reg,__u16 val);
  188. void pci_write_config_dword(__u8 bus,__u8 dev,__u8 fn,__u8 reg,__u32 val);
  189. __u8 pci_read_config_byte(__u8 bus,__u8 dev,__u8 fn,__u8 reg);
  190. __u16 pci_read_config_word(__u8 bus,__u8 dev,__u8 fn,__u8 reg);
  191. __u32 pci_read_config_dword(__u8 bus,__u8 dev,__u8 fn,__u8 reg);
  192.  
  193. typedef struct{
  194.         char* name;
  195.         void* pointer;
  196. } IMP_ENTRY;
  197. typedef const IMP_ENTRY* IMP_TABLE;
  198. IMP_TABLE __kolibri__cofflib_load(const char*);
  199. __u32 __kolibri__cofflib_getproc(IMP_TABLE, const char*);
  200.  
  201.  
  202. static __inline__ void __menuet__debug_out_byte(const char ch){
  203.     __asm__ __volatile__ ("int $0x40"::"a"(63L),"b"(1L),"c"((__u8)ch));
  204. }
  205.  
  206. static __inline__ __u32 __menuet__wtf(void){
  207.  __u32 __ret;
  208.  __asm__ __volatile__("int $0x40":"=a"(__ret):"0"(26),"b"(9));
  209.  return __ret;
  210.    }
  211.  
  212. void __menuet__debug_out(const char* str);
  213.  
  214. #define TIME_GETH(x)    ((x)&0x000000FF)
  215. #define TIME_GETM(x)    ((((x)&0x00FF00)>>8)&0xFF)
  216. #define TIME_GETS(x)    ((((x)&0xFF0000)>>16)&0xFF)
  217.  
  218. #pragma pack(pop)
  219.  
  220. #ifdef __cplusplus
  221. }
  222. #endif
  223.  
  224. #endif
  225.