OSDN Git Service

support exception
[unagi/old-svn-converted.git] / client / trunk / reader_master.h
1 #ifndef _READER_MASTER_H_
2 #define _READER_MASTER_H_
3 #include "type.h"
4 #ifdef WIN32
5  #include <windows.h>
6 #else
7  #include <unistd.h>
8 #endif
9
10 struct textcontrol;
11 struct gauge;
12 struct reader_handle;
13
14 struct reader_memory_access{
15         void (*memory_read)(const struct reader_handle *h, const struct gauge *g, long address, long length, uint8_t *data);
16         void (*memory_write)(const struct reader_handle *h, long address, long length, const uint8_t *data);
17         void (*flash_config)(const struct reader_handle *h, long c000x, long c2aaa, long c5555, long unit, bool retry);
18         void (*flash_erase)(const struct reader_handle *h, long address, bool wait);
19         long (*flash_program)(const struct reader_handle *h, const struct gauge *g, long address, long length, const uint8_t *data, bool wait, bool skip);
20         void (*flash_device_get)(const struct reader_handle *h, uint8_t s[2]);
21 };
22 struct reader_control{
23         const char *name;
24         const struct reader_handle *(*open)(void (*except)(const char *str));
25         void (*close)(const struct reader_handle *h);
26         void (*init)(const struct reader_handle *h);
27         void (*flash_status)(const struct reader_handle *h, uint8_t s[2]);
28         uint8_t (*vram_connection)(const struct reader_handle *h);
29 };
30 struct reader_driver{
31         const struct reader_control control;
32         const struct reader_memory_access cpu, ppu;
33 };
34
35 static inline void wait(long msec)
36 {
37         if(msec == 0){
38                 return;
39         }
40 #ifdef WIN32
41         Sleep(msec);
42 #else
43         usleep(msec * 1000);
44 #endif
45 }
46 #endif