OSDN Git Service

appened flash programming testrun
[unagi/old-svn-converted.git] / client / trunk / anago / reader_dummy.c
1 #include <stdbool.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include "reader_master.h"
5 #include "reader_dummy.h"
6
7 static void dummy_init(void)
8 {
9 }
10 static int dummy_open_close(enum reader_control oc)
11 {
12         return OK;
13 }
14 //---- cpu ----
15 static void dummy_cpu_read(long address, long length, uint8_t *data)
16 {
17         printf("%s %06x %04x\n", __FUNCTION__, (int) address, (int) length);
18         memset(data, 0x55, length);
19 }
20 static void dummy_cpu_write_6502(long address, long length, const uint8_t *data)
21 {
22         printf("%s %04x %04x %02x\n", __FUNCTION__, (int) address, (int) length, (int) *data);
23 }
24 static void dummy_cpu_flash_config(long c000x, long c2aaa, long c5555, long unit)
25 {
26         printf("%s %04x %04x %04x %04x\n", __FUNCTION__, (int) c000x, (int) c2aaa, (int) c5555, (int) unit);
27 }
28 static long dummy_cpu_flash_program(long address, long length, const u8 *data, bool dowait)
29 {
30         int i = 0x10;
31         printf("%s %06x\n", __FUNCTION__, (int) address);
32         if(0){
33                 while(i != 0){
34                         printf("%02x ", *data);
35                         data++;
36                         i--;
37                 }
38                 printf("\n");
39         }
40         return 0x100;
41 }
42
43 static void dummy_cpu_flash_erase(long address, bool dowait)
44 {
45         printf("%s %04x\n", __FUNCTION__, (int) address);
46 }
47
48 //---- ppu ----
49 static void dummy_ppu_read(long address, long length, u8 *data)
50 {
51         printf("%s %06x %04x\n", __FUNCTION__, (int) address, (int) length);
52         memset(data, 0x55, length);
53 }
54 static void dummy_ppu_write(long address, long length, const uint8_t *data)
55 {
56         printf("%s %04x %04x %02x\n", __FUNCTION__, (int) address, (int) length, (int) *data);
57 }
58 static void dummy_ppu_flash_config(long c000x, long c2aaa, long c5555, long unit)
59 {
60         printf("%s %04x %04x %04x %04x\n", __FUNCTION__, (int) c000x, (int) c2aaa, (int) c5555, (int) unit);
61 }
62 static long dummy_ppu_flash_program(long address, long length, const u8 *data, bool dowait)
63 {
64         int i = 0x10;
65         printf("%s %06x\n", __FUNCTION__, (int) address);
66         if(0){
67                 while(i != 0){
68                         printf("%02x ", *data);
69                         data++;
70                         i--;
71                 }
72                 printf("\n");
73         }
74         return 0x100;
75 }
76
77 static void dummy_ppu_flash_erase(long address, bool dowait)
78 {
79         printf("%s %04x\n", __FUNCTION__, (int) address);
80 }
81
82 static void dummy_flash_status(uint8_t s[2])
83 {
84         s[0] = 0;
85         s[1] = 0;
86 }
87 static void dummy_flash_device_get(uint8_t s[2])
88 {
89         s[0] = 0x01;
90         s[1] = 0xa4;
91 }
92 static uint8_t dummy_vram_connection(void)
93 {
94         return 0x05;
95 }
96 const struct reader_driver DRIVER_DUMMY = {
97         .name = "tester",
98         .open_or_close = dummy_open_close,
99         .init = dummy_init,
100         .cpu_read = dummy_cpu_read, .ppu_read = dummy_ppu_read,
101         .cpu_write_6502 = dummy_cpu_write_6502,
102         .flash_support = true,
103         .ppu_write = dummy_ppu_write,
104         .cpu_flash_config = dummy_cpu_flash_config,
105         .cpu_flash_erase = dummy_cpu_flash_erase,
106         .cpu_flash_program = dummy_cpu_flash_program,
107         .cpu_flash_device_get = dummy_flash_device_get,
108         .ppu_flash_config = dummy_ppu_flash_config,
109         .ppu_flash_erase = dummy_ppu_flash_erase,
110         .ppu_flash_program = dummy_ppu_flash_program,
111         .ppu_flash_device_get = dummy_flash_device_get,
112         .flash_status = dummy_flash_status,
113         .vram_connection = dummy_vram_connection
114 };