15 #include <sys/types.h>
17 #include <sys/ioctl.h>
19 #include "gpio/gpio.h"
20 #include "platforms/amiga/gayle-ide/ide.h"
22 uint8_t garbege_datas[2 * 1024 * 1024];
30 void sigint_handler(int sig_num) {
32 //cpu_emulation_running = 0;
35 printf("Received sigint %d, exiting.\n", sig_num);
43 clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &f2);
44 srand((unsigned int)f2.tv_nsec);
46 signal(SIGINT, sigint_handler);
49 printf("Enable 200MHz GPCLK0 on GPIO4\n");
61 // printf("Status Reg%x\n",read_reg());
66 write8(0xbfe201, 0x0101); //CIA OVL
67 write8(0xbfe001, 0x0000); //CIA OVL LOW
69 printf("Writing garbege datas.\n");
70 for (uint32_t i = 0; i < 512 * 1024; i++) {
71 garbege_datas[i] = (uint8_t)(rand() % 0xFF);
72 write8(i, (uint32_t)garbege_datas[i]);
74 printf("Reading back garbege datas, read8()...\n");
75 for (uint32_t i = 0; i < 512 * 1024; i++) {
76 uint32_t c = read8(i);
77 if (c != garbege_datas[i]) {
79 printf("READ8: Garbege data mismatch at $%.6X: %.2X should be %.2X.\n", i, c, garbege_datas[i]);
83 printf("read8 errors total: %d.\n", errors);
86 printf("Reading back garbege datas, read16(), even addresses...\n");
87 for (uint32_t i = 0; i < (512 * 1024) - 2; i += 2) {
88 uint32_t c = be16toh(read16(i));
89 if (c != *((uint16_t *)&garbege_datas[i])) {
91 printf("READ16_EVEN: Garbege data mismatch at $%.6X: %.4X should be %.4X.\n", i, c, *((uint16_t *)&garbege_datas[i]));
95 printf("read16 even errors total: %d.\n", errors);
98 for (int x = 0; x < 20; x++) {
99 printf("Reading back garbege datas, read16(), odd addresses...\n");
100 for (uint32_t i = 1; i < (512 * 1024) - 2; i += 2) {
101 uint32_t c = be16toh((read8(i) << 8) | read8(i + 1));
102 if (c != *((uint16_t *)&garbege_datas[i])) {
104 printf("READ16_ODD: Garbege data mismatch at $%.6X: %.4X should be %.4X.\n", i, c, *((uint16_t *)&garbege_datas[i]));
108 printf("read16 odd loop %d errors total: %d.\n", x+1, errors);
112 printf("Reading back garbege datas, read32(), even addresses...\n");
113 for (uint32_t i = 0; i < (512 * 1024) - 4; i += 2) {
114 uint32_t c = be32toh(read32(i));
115 if (c != *((uint32_t *)&garbege_datas[i])) {
117 printf("READ32_EVEN: Garbege data mismatch at $%.6X: %.8X should be %.8X.\n", i, c, *((uint32_t *)&garbege_datas[i]));
121 printf("read32 even errors total: %d.\n", errors);
124 for (int x = 0; x < 20; x++) {
125 printf("Reading back garbege datas, read32(), odd addresses...\n");
126 for (uint32_t i = 1; i < (512 * 1024) - 4; i += 2) {
127 uint32_t c = be32toh(read32(i));
128 c = (c >> 8) | (read8(i + 3) << 24);
129 if (c != *((uint32_t *)&garbege_datas[i])) {
131 printf("READ32_ODD: Garbege data mismatch at $%.6X: %.8X should be %.8X.\n", i, c, *((uint32_t *)&garbege_datas[i]));
135 printf("read32 odd loop %d errors total: %d.\n", x+1, errors);
143 void m68k_set_irq(unsigned int level) {
146 struct ide_controller *get_ide(int index) {