Rev 5238 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5232 | raandoom | 1 | #include "config.h" |
2 | |||
3 | #pragma pack(push,1) |
||
4 | |||
5 | typedef struct { |
||
6 | __u32 func; |
||
7 | __u32 l_off; |
||
8 | __u32 h_off_flags; |
||
9 | __u32 size; |
||
10 | char* data; |
||
11 | char null; |
||
12 | char* name; |
||
13 | } fs_info; |
||
14 | |||
15 | #pragma pack(pop) |
||
16 | |||
17 | char path[] = "/sys/games/2048.dat"; |
||
18 | |||
5248 | raandoom | 19 | __u8 config_load(config_state* st) |
5232 | raandoom | 20 | { |
21 | fs_info cfg = {0}; |
||
22 | cfg.func = 0; |
||
5248 | raandoom | 23 | cfg.size = sizeof(config_state); |
24 | cfg.data = (char*)st; |
||
5232 | raandoom | 25 | cfg.name = path; |
26 | |||
27 | __u32 ret = 0; |
||
28 | __u32 rnum = 0; |
||
29 | |||
30 | __asm__ __volatile__("int $0x40":"=a"(ret),"=b"(rnum): |
||
31 | "a"(70), |
||
5238 | raandoom | 32 | "b"((__u32)(&cfg)): |
33 | "memory"); |
||
5232 | raandoom | 34 | |
5248 | raandoom | 35 | return !ret || (rnum == cfg.size); |
5232 | raandoom | 36 | } |
37 | |||
5248 | raandoom | 38 | __u8 config_save(config_state* st) |
5232 | raandoom | 39 | { |
40 | fs_info cfg = {0}; |
||
41 | cfg.func = 2; |
||
5248 | raandoom | 42 | cfg.size = sizeof(config_state); |
43 | cfg.data = (char*)st; |
||
5232 | raandoom | 44 | cfg.name = path; |
45 | |||
46 | __u32 ret = 0; |
||
47 | __u32 wnum = 0; |
||
48 | |||
49 | __asm__ __volatile__("int $0x40":"=a"(ret),"=b"(wnum): |
||
50 | "a"(70), |
||
5238 | raandoom | 51 | "b"((__u32)(&cfg)): |
52 | "memory"); |
||
5248 | raandoom | 53 | |
54 | return !ret || (wnum == cfg.size); |
||
5232 | raandoom | 55 | } |