| 1 | #ifndef INCLUDE_sQt5fY5eUJn5tKV0IBTDxK0zqQutTqTp |
| 2 | #define INCLUDE_sQt5fY5eUJn5tKV0IBTDxK0zqQutTqTp 1 |
| 3 | |
| 4 | #include "llibc.h" |
| 5 | |
| 6 | #define PFX "ginge: " |
| 7 | #define err(f, ...) g_fprintf(2, PFX f, ##__VA_ARGS__) |
| 8 | #define log(f, ...) g_fprintf(1, PFX f, ##__VA_ARGS__) |
| 9 | #ifdef DBG |
| 10 | #define dbg log |
| 11 | #define dbg_c printf |
| 12 | #else |
| 13 | #define dbg(...) |
| 14 | #define dbg_c(...) |
| 15 | #endif |
| 16 | |
| 17 | void do_entry(unsigned long entry, void *stack_frame, int stack_frame_cnt, void *exitf); |
| 18 | |
| 19 | struct dev_fd_t { |
| 20 | const char *name; |
| 21 | int fd; |
| 22 | void (*open_cb)(int fd); |
| 23 | }; |
| 24 | extern struct dev_fd_t emu_interesting_fds[]; |
| 25 | enum { |
| 26 | IFD_SOUND = 0, |
| 27 | }; |
| 28 | |
| 29 | // note: __FD_SETSIZE is 1024, fd_set stuff will crash if made larger |
| 30 | enum { |
| 31 | FAKEDEV_MEM = 1001, |
| 32 | FAKEDEV_GPIO, |
| 33 | FAKEDEV_FB0, |
| 34 | FAKEDEV_FB1, |
| 35 | FAKEDEV_MMUHACK, // 1005 |
| 36 | FAKEDEV_WM97XX, |
| 37 | FAKEDEV_WM97XX_P, |
| 38 | FAKEDEV_TTY, // 1008 |
| 39 | FAKEDEV_TTY0, |
| 40 | FAKEDEV_FD_BOUNDARY, |
| 41 | }; |
| 42 | |
| 43 | void do_patches(void *ptr, unsigned int size); |
| 44 | |
| 45 | struct op_context; |
| 46 | |
| 47 | void emu_init(void *map_bottom[2], int is_dl); |
| 48 | void emu_call_handle_op(struct op_context *op_ctx); |
| 49 | long emu_do_mmap(unsigned int length, int prot, int flags, int fd, unsigned int offset); |
| 50 | long emu_do_munmap(void *addr, unsigned int length); |
| 51 | long emu_do_ioctl(int fd, int request, void *argp); |
| 52 | long emu_do_read(int fd, void *buf, int count); |
| 53 | void *emu_do_fopen(const char *path, const char *mode); |
| 54 | int emu_do_system(const char *command); |
| 55 | long emu_do_execve(const char *filename, char *const argv[], char *const envp[]); |
| 56 | const char *emu_wrap_path(const char *path); |
| 57 | void emu_wrap_path_free(const char *w_path, const char *old_path); |
| 58 | |
| 59 | int host_init(void); |
| 60 | int host_read_btns(void); |
| 61 | int host_read_ts(int *pressed, int *x1024, int *y1024); |
| 62 | void host_forced_exit(int status); |
| 63 | |
| 64 | enum { GP2X_UP = 0, GP2X_LEFT = 2, GP2X_DOWN = 4, GP2X_RIGHT = 6, |
| 65 | GP2X_START = 8, GP2X_SELECT = 9, GP2X_L = 10, GP2X_R = 11, |
| 66 | GP2X_A = 12, GP2X_B = 13, GP2X_X = 14, GP2X_Y = 15, |
| 67 | GP2X_VOL_UP = 16, GP2X_VOL_DOWN = 17, GP2X_PUSH = 18 }; |
| 68 | |
| 69 | extern char *bin_path; |
| 70 | extern char **g_argv; |
| 71 | |
| 72 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) |
| 73 | |
| 74 | #endif /* INCLUDE_sQt5fY5eUJn5tKV0IBTDxK0zqQutTqTp */ |