wip, thread support and timer
[ginge.git] / loader / header.h
1 #ifndef INCLUDE_sQt5fY5eUJn5tKV0IBTDxK0zqQutTqTp
2 #define INCLUDE_sQt5fY5eUJn5tKV0IBTDxK0zqQutTqTp 1
3
4 #define PFX "ginge: "
5 #define err(f, ...) fprintf(stderr, PFX f, ##__VA_ARGS__)
6 #define log(f, ...) fprintf(stdout, PFX f, ##__VA_ARGS__)
7 #ifdef DBG
8 #define dbg log
9 #define dbg_c printf
10 #else
11 #define dbg(...)
12 #define dbg_c(...)
13 #endif
14
15 void do_entry(unsigned long entry, void *stack_frame, int stack_frame_cnt, void *exitf);
16
17 struct dev_fd_t {
18   const char *name;
19   int fd;
20 };
21 extern struct dev_fd_t emu_interesting_fds[];
22 enum {
23         IFD_SOUND = 0,
24 };
25
26 // note: __FD_SETSIZE is 1024, fd_set stuff will crash if made larger
27 enum {
28   FAKEDEV_MEM = 1001,
29   FAKEDEV_GPIO,
30   FAKEDEV_FB0,
31   FAKEDEV_FB1,
32   FAKEDEV_MMUHACK,
33   FAKEDEV_TTY0,
34   FAKEDEV_FD_BOUNDARY,
35 };
36
37 void do_patches(void *ptr, unsigned int size);
38
39 struct op_context;
40
41 void  emu_init(void *map_bottom);
42 void  emu_call_handle_op(struct op_context *op_ctx);
43 void *emu_do_mmap(unsigned int length, int prot, int flags, int fd, unsigned int offset);
44 int   emu_do_ioctl(int fd, int request, void *argp);
45 int   emu_read_gpiodev(void *buf, int count);
46 void *emu_do_fopen(const char *path, const char *mode);
47 int   emu_do_system(const char *command);
48
49 int   host_read_btns(void);
50
51 enum  { GP2X_UP = 0,      GP2X_LEFT = 2,      GP2X_DOWN = 4,  GP2X_RIGHT = 6,
52         GP2X_START = 8,   GP2X_SELECT = 9,    GP2X_L = 10,    GP2X_R = 11,
53         GP2X_A = 12,      GP2X_B = 13,        GP2X_X = 14,    GP2X_Y = 15,
54         GP2X_VOL_UP = 16, GP2X_VOL_DOWN = 17, GP2X_PUSH = 18 };
55
56 #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
57
58 #endif /* INCLUDE_sQt5fY5eUJn5tKV0IBTDxK0zqQutTqTp */