11 #define PAGE_SIZE 128 /* Size in words */
12 #define BUF_SIZE (PAGE_SIZE + PAGE_SIZE/2)
13 static unsigned buf[BUF_SIZE];
17 static void cleanup (void)
18 /* Remove the driver on exit */
25 static void fill (register unsigned* page, register unsigned char count, register unsigned num)
27 register unsigned char i;
28 for (i = 0; i < count; ++i, ++page) {
35 static void cmp (unsigned page, register const unsigned* buf,
36 register unsigned char count, register unsigned num)
38 register unsigned char i;
39 for (i = 0; i < count; ++i, ++buf) {
41 cprintf ("\r\nData mismatch in page $%04X at $%04X\r\n"
42 "Data is $%04X (should be $%04X)\r\n",
43 page, buf, *buf, num);
52 typedef struct emd_test_s {
58 static emd_test_t drivers[] = {
60 #if defined(__APPLE2__)
61 { '0', "Apple II auxiliary memory", "a2.auxmem.emd" },
64 #if defined(__APPLE2ENH__)
65 { '0', "Apple II auxiliary memory", "a2e.auxmem.emd" },
68 #if defined(__ATARI__)
69 { '0', "Atari 130XE memory", "atr130.emd" },
72 #if defined(__ATARIXL__)
73 { '0', "Atari 130XE memory", "atrx130.emd" },
77 { '0', "C16 RAM above $8000", "c16-ram.emd" },
81 { '0', "C64 RAM above $D000", "c64-ram.emd" },
82 { '1', "C64 256K", "c64-c256k.emd" },
83 { '2', "Double Quick Brown Box", "c64-dqbb.emd" },
84 { '3', "GEORAM", "c64-georam.emd" },
85 { '4', "Isepic", "c64-isepic.emd" },
86 { '5', "RamCart", "c64-ramcart.emd" },
87 { '6', "REU", "c64-reu.emd" },
88 { '7', "C128 VDC (in C64 mode)", "c64-vdc.emd" },
89 { '8', "C64DTV himem", "dtv-himem.emd" },
90 { '9', "65816 extra banks", "c64-65816.emd" },
94 { '0', "C128 RAM in bank 1", "c128-ram.emd" },
95 { '1', "C128 RAM in banks 1, 2 & 3", "c128-ram2.emd" },
96 { '2', "GEORAM", "c128-georam.emd" },
97 { '3', "RamCart", "c128-ramcart.emd" },
98 { '4', "REU", "c128-reu.emd" },
99 { '5', "VDC", "c128-vdc.emd" },
102 #if defined(__CBM510__)
103 { '0', "CBM5x0 RAM in bank 2", "cbm510-ram.emd" },
106 #if defined(__CBM610__)
107 { '0', "CBM6x0/7x0 RAM in bank 2", "cbm610-ram.emd" },
122 signed char valid_key = -1;
126 cputs ("Which RAM exp to test?\r\n\r\n");
127 for (index = 0; drivers[index].key; ++index) {
128 cprintf("%c: %s\r\n", drivers[index].key, drivers[index].displayname);
131 while (valid_key < 0) {
133 for (index = 0; drivers[index].key && valid_key < 0; ++index) {
134 if (key == drivers[index].key) {
141 Res = em_load_driver (drivers[valid_key].drivername);
142 if (Res != EM_ERR_OK) {
143 cprintf ("Error in em_load_driver: %u\r\n", Res);
144 cprintf ("os: %u, %s\r\n", _oserror, _stroserror (_oserror));
152 /* Get the number of available pages */
153 PageCount = em_pagecount ();
154 cprintf ("Loaded ok, page count = $%04X\r\n", PageCount);
156 /* TEST #1: em_map/em_use/em_commit */
157 cputs ("Testing em_map/em_use/em_commit");
160 cputs ("\r\n Filling ");
163 for (I = 0; I < PageCount; ++I) {
165 /* Fill the buffer and copy it to em */
166 fill (em_use (I), PAGE_SIZE, I);
169 /* Keep the user happy */
175 ((unsigned*) em_map (0x03))[0x73] = 0xFFFF;
179 /* Check all pages */
180 cputs ("\r\n Comparing ");
183 for (I = 0; I < PageCount; ++I) {
185 /* Get the buffer and compare it */
186 cmp (I, em_map (I), PAGE_SIZE, I);
188 /* Keep the user happy */
193 /* TEST #2: em_copyfrom/em_copyto. */
194 cputs ("\r\nTesting em_copyfrom/em_copyto");
196 /* We're filling now 384 bytes per run to test the copy routines with
199 PageCount = (PageCount * 2) / 3;
201 /* Setup the copy structure */
203 c.count = sizeof (buf);
205 /* Fill again all pages */
206 cputs ("\r\n Filling ");
211 for (I = 0; I < PageCount; ++I) {
213 /* Fill the buffer and copy it to em */
214 fill (buf, BUF_SIZE, I ^ 0xFFFF);
217 /* Adjust the em offset */
218 Offs = c.offs + sizeof (buf);
219 c.offs = (unsigned char) Offs;
220 c.page += (Offs >> 8);
222 /* Keep the user happy */
234 /* Check all pages */
235 cputs ("\r\n Comparing ");
240 for (I = 0; I < PageCount; ++I) {
242 /* Get the buffer and compare it */
244 cmp (I, buf, BUF_SIZE, I ^ 0xFFFF);
246 /* Adjust the em offset */
247 Offs = c.offs + sizeof (buf);
248 c.offs = (unsigned char) Offs;
249 c.page += (Offs >> 8);
251 /* Keep the user happy */
257 cprintf ("\r\nPassed!\r\n");