5 // Created by Matt Parsons on 06/03/2019.
6 // Copyright © 2019 Matt Parsons. All rights reserved.
9 //Write Byte to Gayle Space 0xda9000 (0x0000c3)
10 //Read Byte From Gayle Space 0xda9000
11 //Read Byte From Gayle Space 0xdaa000
21 #define CLOCKBASE 0xDC0000
23 #define GSTATUS 0xda201c
24 #define GCLOW 0xda2010
29 //Write Byte to Gayle Space 0xda2018 (0x000000)
30 //Read Byte From Gayle Space 0xda2010
31 //Read Byte From Gayle Space 0xda201c
32 //Write Byte to Gayle Space 0xdaa000 (0x00002c)
33 //Write Byte to Gayle Space 0xda8000 (0x000000)
34 //Write Byte to Gayle Space 0xda2018 (0x000000)
35 //Write Byte to Gayle Space 0xda2010 (0x000012)
40 Write Byte to Gayle Space 0xda3018 (0x000000)
42 Read Byte from Gayle Ident 0xde1000 (0x000004)
43 Write ide_dev_head: 0x0000a0
44 Write Byte to Gayle Space 0xda2018 (0x0000a0)
45 Write ide_cyl_low: 0x000012
46 Write Byte to Gayle Space 0xda2010 (0x000012)
47 Write ide_cyl_low: 0x000034
48 Write Byte to Gayle Space 0xda2010 (0x000034)
49 Write Byte to Gayle Space 0xda3018 (0x000000)
50 Write ide_status_r: 0x000010
51 Write Byte to Gayle Space 0xda201c (0x000010)
56 static struct ide_controller *ide0;
60 ide0 = ide_allocate("cf");
61 fd = open("hd0.img", O_RDWR);
63 printf("HDD Image hd0.image failed open\n");
65 ide_attach(ide0, 0, fd);
66 ide_reset_begin(ide0);
67 printf("HDD Image hd0.image attached\n");
71 uint8_t CheckIrq(void){
74 irq = ide0->drive->intrq;
76 // printf("IDE IRQ: 0\n");
81 void writeGayleB(unsigned int address, unsigned int value){
84 if (address == GSTATUS) {
85 ide_write8(ide0, ide_status_r, value);
86 // printf("Write ide_status_r: 0x%06x IRQ:0x%06x\n",value, ide0->drive->intrq);
91 ide_write8(ide0, ide_dev_head, value);
92 // printf("Write ide_dev_head: 0x%06x\n",value);
96 if (address == GCLOW) {
97 ide_write8(ide0, ide_cyl_low, value);
98 // printf("Write ide_cyl_low: 0x%06x\n",value);
103 if (address == 0xDE1000){
105 // printf("Write Byte to Gayle Ident 0x%06x (0x%06x)\n",address,value);
109 if (address == 0xda9000){
113 if (address == 0xda8000){
117 if (address == 0xdaa000){
121 if (address == 0xdab000){
129 printf("Write Byte to Gayle Space 0x%06x (0x%06x)\n",address,value);
132 void writeGayle(unsigned int address, unsigned int value){
133 // printf("Write to Gayle Space 0x%06x (0x%06x)\n",address,value);
136 void writeGayleL(unsigned int address, unsigned int value){
137 // printf("Write Long to Gayle Space 0x%06x (0x%06x)\n",address,value);
140 uint8_t readGayleB(unsigned int address){
142 if (address == GSTATUS) {
143 // printf("Read ide_status_r\n");
144 return ide_read8(ide0, ide_status_r);
147 if (address == GCLOW) {
148 // printf("Read ide_cyl_low\n");
149 return ide_read8(ide0, ide_cyl_low);
152 if (address == GDH) {
153 // printf("Read ide_dev_head\n");
154 return ide_read8(ide0, ide_dev_head);
158 if (address == 0xDE1000){
160 // printf("Read Byte from Gayle Ident 0x%06x (0x%06x)\n",address,counter);
163 // printf("Gayle Ident cycle\n");
164 return 0xFF;//7F; to enable gayle
171 if (address == 0xda9000){
175 if (address == 0xdaa000){
179 printf("Read Byte From Gayle Space 0x%06x\n",address);
183 uint16_t readGayle(unsigned int address){
184 printf("Read From Gayle Space 0x%06x\n",address);
188 uint32_t readGayleL(unsigned int address){
189 printf("Read Long From Gayle Space 0x%06x\n",address);