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" },
100 { '6', "Internal Function RAM", "c128-ifnram.emd" },
101 { '7', "External Function RAM", "c128-efnram.emd" },
104 #if defined(__CBM510__)
105 { '0', "CBM5x0 RAM in bank 2", "cbm510-ram.emd" },
108 #if defined(__CBM610__)
109 { '0', "CBM6x0/7x0 RAM in bank 2", "cbm610-ram.emd" },
124 signed char valid_key = -1;
128 cputs ("Which RAM exp to test?\r\n\r\n");
129 for (index = 0; drivers[index].key; ++index) {
130 cprintf("%c: %s\r\n", drivers[index].key, drivers[index].displayname);
133 while (valid_key < 0) {
135 for (index = 0; drivers[index].key && valid_key < 0; ++index) {
136 if (key == drivers[index].key) {
143 Res = em_load_driver (drivers[valid_key].drivername);
144 if (Res != EM_ERR_OK) {
145 cprintf ("Error in em_load_driver: %u\r\n", Res);
146 cprintf ("os: %u, %s\r\n", _oserror, _stroserror (_oserror));
154 /* Get the number of available pages */
155 PageCount = em_pagecount ();
156 cprintf ("Loaded ok, page count = $%04X\r\n", PageCount);
158 /* TEST #1: em_map/em_use/em_commit */
159 cputs ("Testing em_map/em_use/em_commit");
162 cputs ("\r\n Filling ");
165 for (I = 0; I < PageCount; ++I) {
167 /* Fill the buffer and copy it to em */
168 fill (em_use (I), PAGE_SIZE, I);
171 /* Keep the user happy */
177 ((unsigned*) em_map (0x03))[0x73] = 0xFFFF;
181 /* Check all pages */
182 cputs ("\r\n Comparing ");
185 for (I = 0; I < PageCount; ++I) {
187 /* Get the buffer and compare it */
188 cmp (I, em_map (I), PAGE_SIZE, I);
190 /* Keep the user happy */
195 /* TEST #2: em_copyfrom/em_copyto. */
196 cputs ("\r\nTesting em_copyfrom/em_copyto");
198 /* We're filling now 384 bytes per run to test the copy routines with
201 PageCount = (PageCount * 2) / 3;
203 /* Setup the copy structure */
205 c.count = sizeof (buf);
207 /* Fill again all pages */
208 cputs ("\r\n Filling ");
213 for (I = 0; I < PageCount; ++I) {
215 /* Fill the buffer and copy it to em */
216 fill (buf, BUF_SIZE, I ^ 0xFFFF);
219 /* Adjust the em offset */
220 Offs = c.offs + sizeof (buf);
221 c.offs = (unsigned char) Offs;
222 c.page += (Offs >> 8);
224 /* Keep the user happy */
236 /* Check all pages */
237 cputs ("\r\n Comparing ");
242 for (I = 0; I < PageCount; ++I) {
244 /* Get the buffer and compare it */
246 cmp (I, buf, BUF_SIZE, I ^ 0xFFFF);
248 /* Adjust the em offset */
249 Offs = c.offs + sizeof (buf);
250 c.offs = (unsigned char) Offs;
251 c.page += (Offs >> 8);
253 /* Keep the user happy */
259 cprintf ("\r\nPassed!\r\n");