More code reorg and auto-detecting second drive.
This commit is contained in:
parent
9535b0f878
commit
923bbd548e
@ -173,7 +173,7 @@
|
||||
#define EMS_TOTAL_SIZE (16*1024*1024)
|
||||
|
||||
#define SD_BASE 0x280 // Must be a multiple of 8.
|
||||
#define SD_FIXED_DISK_ID 0x80 // or 0x81 for 2nd disk.
|
||||
#define SD_CONFIG_BYTE 0
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------
|
||||
@ -198,7 +198,7 @@ uint8_t spi_shift_out =0;
|
||||
uint8_t sd_spi_datain =0;
|
||||
uint32_t sd_spi_cs_n = 0x0;
|
||||
uint32_t sd_spi_dataout =0;
|
||||
uint8_t sd_scratch_register[4] = {0, 0, 0, 0};
|
||||
uint8_t sd_scratch_register[6] = {0, 0, 0, 0, 0, 0};
|
||||
uint16_t sd_requested_timeout = 0;
|
||||
elapsedMillis sd_timeout;
|
||||
|
||||
@ -592,11 +592,11 @@ inline void Mem_Read_Cycle() {
|
||||
|
||||
GPIO8_DR = sd_pin_outputs + MUX_DATA_n_HIGH + CHRDY_OE_n_HIGH + DATA_OE_n_HIGH;
|
||||
}
|
||||
else if (isa_address>=BOOTROM_ADDR+sizeof(BOOTROM) && isa_address<BOOTROM_ADDR+sizeof(BOOTROM)+512) { // SD Card virtual buffer
|
||||
else if (isa_address>=BOOTROM_ADDR+sizeof(BOOTROM) && isa_address<BOOTROM_ADDR+sizeof(BOOTROM)+512+2) { // SD Card virtual buffer, include 2 bytes for CRC
|
||||
GPIO7_DR = MUX_ADDR_n_LOW + CHRDY_OUT_LOW + trigger_out;
|
||||
GPIO8_DR = sd_pin_outputs + MUX_DATA_n_HIGH + CHRDY_OE_n_LOW + DATA_OE_n_LOW ; // Assert CHRDY_n=0 to begin wait states
|
||||
|
||||
// Alias to IO port SD_BASE
|
||||
// Receive a byte to the SD Card
|
||||
sd_spi_dataout = 0xff; SD_SPI_Cycle(); isa_data_out = sd_spi_datain;
|
||||
GPIO7_DR = GPIO7_DATA_OUT_UNSCRAMBLE + MUX_ADDR_n_LOW + CHRDY_OUT_LOW + trigger_out; // Output data
|
||||
GPIO8_DR = sd_pin_outputs + MUX_DATA_n_HIGH + CHRDY_OE_n_HIGH + DATA_OE_n_LOW; // De-assert CHRDY
|
||||
@ -668,7 +668,7 @@ inline void Mem_Write_Cycle() {
|
||||
gpio6_int = GPIO6_DR;
|
||||
data_in = 0xFF & ADDRESS_DATA_GPIO6_UNSCRAMBLE;
|
||||
|
||||
// Alias to IO port SD_BASE
|
||||
// Send a byte to the SD Card
|
||||
sd_spi_dataout = data_in; SD_SPI_Cycle();
|
||||
GPIO8_DR = sd_pin_outputs + MUX_DATA_n_LOW + CHRDY_OE_n_HIGH + DATA_OE_n_HIGH; // De-assert CHRDY
|
||||
|
||||
@ -716,13 +716,13 @@ inline void IO_Read_Cycle() {
|
||||
else if ((isa_address&0x0FF8)==SD_BASE ) { // Location of SD Card registers
|
||||
|
||||
switch (isa_address) {
|
||||
case SD_BASE: // First two registers serve the same function (to allow use of Word I/O)
|
||||
case SD_BASE+1: sd_spi_dataout = 0xff; SD_SPI_Cycle(); isa_data_out = sd_spi_datain; break;
|
||||
case SD_BASE+2: isa_data_out = SD_FIXED_DISK_ID; break;
|
||||
case SD_BASE+3: isa_data_out = sd_scratch_register[0]; break;
|
||||
case SD_BASE+4: isa_data_out = sd_scratch_register[1]; break;
|
||||
case SD_BASE+5: isa_data_out = sd_scratch_register[2]; break;
|
||||
case SD_BASE+6: isa_data_out = sd_scratch_register[3]; break;
|
||||
case SD_BASE+0: sd_spi_dataout = 0xff; SD_SPI_Cycle(); isa_data_out = sd_spi_datain; break;
|
||||
case SD_BASE+1: isa_data_out = SD_CONFIG_BYTE; break;
|
||||
case SD_BASE+2: isa_data_out = sd_scratch_register[0]; break;
|
||||
case SD_BASE+3: isa_data_out = sd_scratch_register[1]; break;
|
||||
case SD_BASE+4: isa_data_out = sd_scratch_register[2]; break;
|
||||
case SD_BASE+5: isa_data_out = sd_scratch_register[3]; break;
|
||||
case SD_BASE+6: isa_data_out = sd_scratch_register[4]; break;
|
||||
case SD_BASE+7: isa_data_out = sd_timeout >= sd_requested_timeout; break;
|
||||
default: isa_data_out = 0xff; break;
|
||||
}
|
||||
@ -782,21 +782,21 @@ inline void IO_Write_Cycle() {
|
||||
data_in = 0xFF & ADDRESS_DATA_GPIO6_UNSCRAMBLE;
|
||||
|
||||
switch (isa_address) {
|
||||
case SD_BASE: // First two registers serve the same function (to allow use of Word I/O)
|
||||
case SD_BASE+1: sd_spi_dataout = data_in; SD_SPI_Cycle(); break;
|
||||
case SD_BASE+2: sd_spi_cs_n = data_in&0x1; break;
|
||||
case SD_BASE+3: sd_scratch_register[0] = data_in; break;
|
||||
case SD_BASE+4: sd_scratch_register[1] = data_in; break;
|
||||
case SD_BASE+5: sd_scratch_register[2] = data_in; break;
|
||||
case SD_BASE+6: sd_scratch_register[3] = data_in; break;
|
||||
case SD_BASE+0: sd_spi_dataout = data_in; SD_SPI_Cycle(); break;
|
||||
case SD_BASE+1: sd_spi_cs_n = data_in&0x1; break;
|
||||
case SD_BASE+2: sd_scratch_register[0] = data_in; break;
|
||||
case SD_BASE+3: sd_scratch_register[1] = data_in; break;
|
||||
case SD_BASE+4: sd_scratch_register[2] = data_in; break;
|
||||
case SD_BASE+5: sd_scratch_register[3] = data_in; break;
|
||||
case SD_BASE+6: sd_scratch_register[4] = data_in; break;
|
||||
case SD_BASE+7: sd_timeout = 0; sd_requested_timeout = data_in * 10; break;
|
||||
}
|
||||
|
||||
|
||||
//gpio9_int = GPIO9_DR;
|
||||
while ( (gpio9_int&0xF0) != 0xF0 ) { // Wait here until cycle is complete
|
||||
gpio6_int = GPIO6_DR;
|
||||
gpio6_int = GPIO6_DR;
|
||||
gpio9_int = GPIO9_DR;
|
||||
}
|
||||
}
|
||||
|
||||
sd_pin_outputs = (sd_spi_cs_n<<17); // SD_CS_n - SD_CLK - SD_MOSI
|
||||
|
||||
|
||||
@ -1,111 +1,113 @@
|
||||
#define BOOTROM_ADDR 0xce000
|
||||
unsigned char BOOTROM[] = {
|
||||
85, 170, 4, 6, 80, 81, 82, 86, 250, 184, 124, 5, 232, 232, 4, 232,
|
||||
237, 3, 115, 3, 233, 158, 0, 184, 190, 5, 232, 218, 4, 49, 192, 142,
|
||||
192, 38, 161, 78, 0, 186, 131, 2, 239, 232, 233, 4, 184, 151, 6, 232,
|
||||
197, 4, 38, 161, 76, 0, 186, 133, 2, 239, 232, 216, 4, 184, 155, 6,
|
||||
232, 180, 4, 184, 0, 206, 38, 163, 78, 0, 184, 188, 0, 38, 163, 76,
|
||||
0, 184, 27, 6, 232, 160, 4, 186, 130, 2, 236, 48, 228, 80, 232, 180,
|
||||
4, 184, 155, 6, 232, 144, 4, 88, 60, 128, 117, 16, 184, 0, 206, 38,
|
||||
163, 6, 1, 184, 151, 1, 38, 163, 4, 1, 235, 14, 184, 0, 206, 38,
|
||||
163, 26, 1, 184, 151, 1, 38, 163, 24, 1, 184, 0, 206, 38, 163, 98,
|
||||
0, 184, 110, 3, 38, 163, 96, 0, 184, 54, 6, 232, 89, 4, 184, 64,
|
||||
0, 142, 192, 38, 254, 6, 117, 0, 38, 160, 117, 0, 232, 102, 4, 184,
|
||||
155, 6, 232, 66, 4, 251, 94, 90, 89, 88, 7, 203, 251, 85, 86, 80,
|
||||
82, 186, 130, 2, 236, 90, 56, 194, 88, 116, 57, 137, 197, 137, 214, 156,
|
||||
14, 184, 229, 0, 80, 156, 186, 131, 2, 237, 80, 186, 133, 2, 237, 80,
|
||||
137, 232, 137, 242, 207, 156, 80, 137, 240, 60, 128, 114, 19, 137, 232, 128,
|
||||
252, 8, 117, 12, 6, 184, 64, 0, 142, 192, 38, 138, 22, 117, 0, 7,
|
||||
88, 157, 235, 58, 128, 252, 21, 126, 5, 232, 113, 0, 235, 34, 128, 252,
|
||||
1, 116, 10, 128, 252, 21, 116, 5, 190, 48, 1, 235, 3, 190, 62, 1,
|
||||
86, 137, 222, 136, 227, 48, 255, 208, 227, 135, 222, 46, 255, 164, 81, 1,
|
||||
140, 197, 190, 64, 0, 142, 198, 38, 136, 38, 116, 0, 142, 197, 137, 229,
|
||||
139, 118, 8, 86, 115, 4, 157, 249, 235, 2, 157, 248, 94, 93, 202, 2,
|
||||
0, 83, 3, 167, 1, 187, 1, 79, 2, 20, 3, 125, 1, 125, 1, 125,
|
||||
1, 47, 3, 83, 3, 125, 1, 125, 1, 69, 3, 83, 3, 125, 1, 125,
|
||||
1, 83, 3, 83, 3, 125, 1, 125, 1, 83, 3, 85, 3, 80, 184, 81,
|
||||
6, 232, 115, 3, 88, 80, 136, 224, 48, 228, 232, 136, 3, 184, 155, 6,
|
||||
232, 100, 3, 88, 233, 203, 1, 0, 4, 255, 0, 0, 255, 255, 0, 200,
|
||||
0, 0, 0, 0, 0, 63, 0, 6, 189, 64, 0, 142, 197, 48, 228, 38,
|
||||
134, 38, 116, 0, 132, 228, 116, 1, 249, 7, 195, 132, 192, 117, 3, 233,
|
||||
160, 1, 80, 48, 228, 137, 198, 83, 232, 227, 1, 137, 197, 1, 240, 137,
|
||||
222, 131, 211, 0, 232, 10, 2, 91, 88, 115, 3, 233, 136, 1, 30, 83,
|
||||
81, 82, 87, 80, 137, 193, 48, 237, 184, 0, 206, 142, 216, 137, 223, 186,
|
||||
130, 2, 176, 0, 238, 81, 137, 232, 137, 243, 177, 81, 232, 213, 2, 114,
|
||||
60, 186, 135, 2, 176, 10, 238, 186, 128, 2, 236, 60, 254, 116, 10, 186,
|
||||
135, 2, 236, 132, 192, 117, 38, 235, 238, 185, 0, 1, 86, 190, 0, 8,
|
||||
252, 243, 165, 94, 237, 131, 197, 1, 131, 214, 0, 89, 226, 199, 186, 130,
|
||||
2, 176, 1, 238, 88, 95, 90, 89, 91, 31, 233, 45, 1, 186, 130, 2,
|
||||
176, 1, 238, 89, 88, 40, 200, 95, 90, 89, 91, 31, 233, 15, 1, 132,
|
||||
192, 117, 3, 233, 12, 1, 80, 48, 228, 137, 198, 83, 232, 79, 1, 137,
|
||||
197, 1, 240, 137, 222, 131, 211, 0, 232, 118, 1, 91, 88, 115, 3, 233,
|
||||
244, 0, 30, 83, 81, 82, 87, 80, 137, 193, 48, 237, 137, 223, 140, 192,
|
||||
142, 216, 184, 0, 206, 142, 192, 186, 130, 2, 176, 0, 238, 81, 137, 232,
|
||||
137, 243, 177, 88, 232, 61, 2, 114, 102, 186, 128, 2, 176, 254, 238, 185,
|
||||
0, 1, 86, 137, 254, 191, 0, 8, 252, 243, 165, 137, 247, 94, 186, 135,
|
||||
2, 176, 25, 238, 186, 128, 2, 236, 60, 255, 117, 10, 186, 135, 2, 236,
|
||||
132, 192, 117, 59, 235, 238, 36, 31, 60, 5, 117, 51, 186, 135, 2, 176,
|
||||
25, 238, 186, 128, 2, 236, 132, 192, 117, 10, 186, 135, 2, 236, 132, 192,
|
||||
117, 29, 235, 238, 131, 197, 1, 131, 214, 0, 89, 226, 160, 186, 130, 2,
|
||||
176, 1, 238, 140, 216, 142, 192, 88, 95, 90, 89, 91, 31, 235, 107, 186,
|
||||
130, 2, 176, 1, 238, 89, 140, 216, 142, 192, 88, 40, 200, 95, 90, 89,
|
||||
91, 31, 235, 74, 132, 192, 116, 74, 80, 48, 228, 137, 197, 83, 232, 141,
|
||||
0, 1, 232, 131, 211, 0, 232, 184, 0, 91, 88, 114, 57, 235, 59, 182,
|
||||
254, 6, 184, 64, 0, 142, 192, 38, 138, 22, 117, 0, 7, 181, 254, 177,
|
||||
255, 49, 192, 248, 195, 80, 83, 232, 100, 0, 232, 148, 0, 91, 88, 114,
|
||||
21, 235, 23, 235, 21, 180, 3, 232, 158, 0, 135, 209, 248, 195, 180, 170,
|
||||
249, 195, 180, 1, 249, 195, 180, 4, 249, 195, 48, 228, 248, 195, 49, 192,
|
||||
142, 216, 142, 192, 185, 0, 1, 191, 0, 124, 243, 171, 186, 130, 2, 236,
|
||||
136, 194, 184, 1, 2, 185, 1, 0, 187, 0, 124, 205, 19, 129, 62, 254,
|
||||
125, 85, 170, 117, 15, 184, 110, 6, 232, 92, 1, 49, 192, 142, 192, 234,
|
||||
0, 124, 0, 0, 184, 136, 6, 232, 77, 1, 251, 244, 235, 253, 49, 192,
|
||||
49, 219, 82, 81, 82, 136, 200, 36, 192, 209, 224, 209, 224, 136, 232, 185,
|
||||
255, 0, 247, 225, 90, 136, 241, 48, 237, 1, 200, 177, 63, 247, 225, 89,
|
||||
81, 48, 237, 128, 225, 63, 73, 1, 200, 131, 210, 0, 137, 211, 89, 90,
|
||||
195, 81, 82, 232, 18, 0, 57, 211, 114, 10, 119, 4, 57, 200, 114, 4,
|
||||
249, 90, 89, 195, 248, 90, 89, 195, 186, 250, 0, 185, 63, 197, 195, 80,
|
||||
30, 83, 81, 82, 86, 184, 0, 206, 142, 216, 186, 130, 2, 176, 1, 238,
|
||||
185, 1, 0, 186, 160, 134, 180, 134, 205, 21, 186, 128, 2, 176, 255, 185,
|
||||
10, 0, 238, 226, 253, 186, 130, 2, 176, 0, 238, 187, 10, 0, 190, 188,
|
||||
4, 185, 1, 0, 180, 1, 232, 92, 0, 115, 15, 49, 201, 186, 32, 78,
|
||||
180, 134, 205, 21, 75, 117, 231, 249, 235, 52, 190, 194, 4, 185, 5, 0,
|
||||
180, 1, 232, 64, 0, 114, 39, 186, 135, 2, 176, 250, 238, 190, 200, 4,
|
||||
185, 1, 0, 180, 1, 232, 45, 0, 190, 206, 4, 185, 1, 0, 180, 0,
|
||||
232, 34, 0, 115, 9, 186, 135, 2, 236, 132, 192, 116, 224, 249, 94, 90,
|
||||
89, 91, 31, 114, 8, 184, 217, 5, 232, 108, 0, 88, 195, 184, 252, 5,
|
||||
232, 100, 0, 88, 195, 186, 128, 2, 176, 255, 238, 81, 185, 6, 0, 252,
|
||||
172, 238, 226, 252, 185, 8, 0, 236, 60, 255, 225, 251, 89, 56, 224, 118,
|
||||
3, 249, 235, 4, 248, 236, 226, 253, 176, 255, 238, 195, 64, 0, 0, 0,
|
||||
0, 149, 72, 0, 0, 1, 170, 135, 119, 0, 0, 0, 0, 1, 105, 64,
|
||||
0, 0, 0, 1, 186, 128, 2, 80, 176, 255, 238, 136, 200, 136, 252, 239,
|
||||
88, 134, 216, 239, 134, 216, 180, 1, 239, 185, 8, 0, 236, 60, 255, 225,
|
||||
251, 132, 192, 116, 1, 249, 195, 156, 30, 83, 86, 137, 198, 184, 0, 206,
|
||||
142, 216, 180, 14, 49, 219, 252, 172, 8, 192, 116, 4, 205, 16, 235, 247,
|
||||
94, 91, 31, 157, 195, 156, 30, 83, 81, 82, 86, 137, 194, 184, 0, 206,
|
||||
142, 216, 49, 219, 252, 137, 214, 177, 12, 211, 238, 131, 230, 15, 138, 132,
|
||||
108, 5, 180, 14, 205, 16, 137, 214, 177, 8, 211, 238, 131, 230, 15, 138,
|
||||
132, 108, 5, 180, 14, 205, 16, 137, 214, 177, 4, 211, 238, 131, 230, 15,
|
||||
138, 132, 108, 5, 180, 14, 205, 16, 137, 214, 131, 230, 15, 138, 132, 108,
|
||||
5, 180, 14, 205, 16, 94, 90, 89, 91, 31, 157, 195, 48, 49, 50, 51,
|
||||
52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 66, 111, 111, 116,
|
||||
82, 79, 77, 32, 102, 111, 114, 32, 88, 84, 77, 97, 120, 32, 118, 49,
|
||||
46, 48, 13, 10, 67, 111, 112, 121, 114, 105, 103, 104, 116, 32, 40, 99,
|
||||
41, 32, 50, 48, 50, 53, 32, 77, 97, 116, 116, 104, 105, 101, 117, 32,
|
||||
66, 117, 99, 99, 104, 105, 97, 110, 101, 114, 105, 13, 10, 0, 79, 108,
|
||||
100, 32, 73, 78, 84, 49, 51, 104, 32, 86, 101, 99, 116, 111, 114, 32,
|
||||
32, 32, 32, 32, 32, 32, 61, 32, 0, 83, 68, 32, 67, 97, 114, 100,
|
||||
32, 105, 110, 105, 116, 105, 97, 108, 105, 122, 101, 100, 32, 115, 117, 99,
|
||||
99, 101, 115, 115, 102, 117, 108, 108, 121, 13, 10, 0, 83, 68, 32, 67,
|
||||
97, 114, 100, 32, 102, 97, 105, 108, 101, 100, 32, 116, 111, 32, 105, 110,
|
||||
105, 116, 105, 97, 108, 105, 122, 101, 13, 10, 0, 70, 105, 120, 101, 100,
|
||||
32, 68, 105, 115, 107, 32, 73, 68, 32, 32, 32, 32, 32, 32, 32, 32,
|
||||
32, 32, 32, 61, 32, 0, 84, 111, 116, 97, 108, 32, 70, 105, 120, 101,
|
||||
100, 32, 68, 105, 115, 107, 32, 68, 114, 105, 118, 101, 115, 32, 61, 32,
|
||||
0, 85, 110, 115, 117, 112, 112, 111, 114, 116, 101, 100, 32, 73, 78, 84,
|
||||
49, 51, 104, 32, 70, 117, 110, 99, 116, 105, 111, 110, 32, 0, 66, 111,
|
||||
111, 116, 105, 110, 103, 32, 102, 114, 111, 109, 32, 83, 68, 32, 67, 97,
|
||||
114, 100, 46, 46, 46, 13, 10, 0, 78, 111, 116, 32, 98, 111, 111, 116,
|
||||
97, 98, 108, 101, 13, 10, 0, 58, 0, 32, 0, 13, 10, 0, 0, 0,
|
||||
85, 170, 4, 6, 80, 81, 82, 86, 250, 184, 150, 5, 232, 2, 5, 232,
|
||||
2, 4, 115, 3, 233, 168, 0, 184, 216, 5, 232, 244, 4, 49, 192, 142,
|
||||
192, 38, 161, 78, 0, 186, 131, 2, 239, 232, 3, 5, 184, 177, 6, 232,
|
||||
223, 4, 38, 161, 76, 0, 186, 133, 2, 239, 232, 242, 4, 184, 181, 6,
|
||||
232, 206, 4, 184, 0, 206, 38, 163, 78, 0, 184, 198, 0, 38, 163, 76,
|
||||
0, 184, 53, 6, 232, 186, 4, 184, 64, 0, 142, 192, 38, 160, 117, 0,
|
||||
4, 128, 186, 130, 2, 238, 80, 232, 197, 4, 184, 181, 6, 232, 161, 4,
|
||||
184, 80, 6, 232, 155, 4, 38, 254, 6, 117, 0, 38, 160, 117, 0, 48,
|
||||
228, 232, 171, 4, 184, 181, 6, 232, 135, 4, 88, 49, 201, 142, 193, 60,
|
||||
128, 117, 16, 184, 0, 206, 38, 163, 6, 1, 184, 170, 1, 38, 163, 4,
|
||||
1, 235, 14, 184, 0, 206, 38, 163, 26, 1, 184, 170, 1, 38, 163, 24,
|
||||
1, 184, 0, 206, 38, 163, 98, 0, 184, 129, 3, 38, 163, 96, 0, 251,
|
||||
94, 90, 89, 88, 7, 203, 251, 85, 86, 80, 82, 186, 130, 2, 236, 90,
|
||||
56, 194, 88, 116, 58, 137, 197, 137, 214, 156, 14, 184, 239, 0, 80, 186,
|
||||
131, 2, 237, 80, 186, 133, 2, 237, 80, 137, 232, 137, 242, 250, 203, 251,
|
||||
156, 80, 137, 240, 60, 128, 114, 19, 137, 232, 128, 252, 8, 117, 12, 6,
|
||||
184, 64, 0, 142, 192, 38, 138, 22, 117, 0, 7, 88, 157, 235, 58, 128,
|
||||
252, 25, 126, 5, 232, 121, 0, 235, 34, 128, 252, 1, 116, 10, 128, 252,
|
||||
21, 116, 5, 190, 59, 1, 235, 3, 190, 73, 1, 86, 137, 222, 136, 227,
|
||||
48, 255, 208, 227, 135, 222, 46, 255, 164, 92, 1, 140, 197, 190, 64, 0,
|
||||
142, 198, 38, 136, 38, 116, 0, 142, 197, 137, 229, 139, 118, 8, 86, 115,
|
||||
4, 157, 249, 235, 2, 157, 248, 94, 93, 202, 2, 0, 102, 3, 186, 1,
|
||||
206, 1, 98, 2, 39, 3, 144, 1, 144, 1, 144, 1, 66, 3, 102, 3,
|
||||
144, 1, 144, 1, 88, 3, 102, 3, 144, 1, 144, 1, 102, 3, 102, 3,
|
||||
144, 1, 144, 1, 102, 3, 104, 3, 144, 1, 144, 1, 144, 1, 102, 3,
|
||||
80, 184, 107, 6, 232, 122, 3, 88, 80, 136, 224, 48, 228, 232, 143, 3,
|
||||
184, 181, 6, 232, 107, 3, 88, 233, 203, 1, 0, 4, 255, 0, 0, 255,
|
||||
255, 0, 200, 0, 0, 0, 0, 0, 63, 0, 6, 189, 64, 0, 142, 197,
|
||||
48, 228, 38, 134, 38, 116, 0, 132, 228, 116, 1, 249, 7, 195, 132, 192,
|
||||
117, 3, 233, 160, 1, 80, 48, 228, 137, 198, 83, 232, 229, 1, 137, 197,
|
||||
1, 240, 137, 222, 131, 211, 0, 232, 12, 2, 91, 88, 115, 3, 233, 136,
|
||||
1, 30, 83, 81, 82, 87, 80, 137, 193, 48, 237, 184, 0, 206, 142, 216,
|
||||
137, 223, 186, 129, 2, 176, 0, 238, 81, 137, 232, 137, 243, 177, 81, 232,
|
||||
215, 2, 114, 60, 186, 135, 2, 176, 10, 238, 186, 128, 2, 236, 60, 254,
|
||||
116, 10, 186, 135, 2, 236, 132, 192, 117, 38, 235, 238, 185, 0, 1, 86,
|
||||
190, 0, 8, 252, 243, 165, 173, 94, 131, 197, 1, 131, 214, 0, 89, 226,
|
||||
199, 186, 129, 2, 176, 1, 238, 88, 95, 90, 89, 91, 31, 233, 45, 1,
|
||||
186, 129, 2, 176, 1, 238, 89, 88, 40, 200, 95, 90, 89, 91, 31, 233,
|
||||
15, 1, 132, 192, 117, 3, 233, 12, 1, 80, 48, 228, 137, 198, 83, 232,
|
||||
81, 1, 137, 197, 1, 240, 137, 222, 131, 211, 0, 232, 120, 1, 91, 88,
|
||||
115, 3, 233, 244, 0, 30, 83, 81, 82, 87, 80, 137, 193, 48, 237, 137,
|
||||
223, 140, 192, 142, 216, 184, 0, 206, 142, 192, 186, 129, 2, 176, 0, 238,
|
||||
81, 137, 232, 137, 243, 177, 88, 232, 63, 2, 114, 102, 186, 128, 2, 176,
|
||||
254, 238, 185, 0, 1, 86, 137, 254, 191, 0, 8, 252, 243, 165, 137, 247,
|
||||
94, 186, 135, 2, 176, 25, 238, 186, 128, 2, 236, 60, 255, 117, 10, 186,
|
||||
135, 2, 236, 132, 192, 117, 59, 235, 238, 36, 31, 60, 5, 117, 51, 186,
|
||||
135, 2, 176, 25, 238, 186, 128, 2, 236, 132, 192, 117, 10, 186, 135, 2,
|
||||
236, 132, 192, 117, 29, 235, 238, 131, 197, 1, 131, 214, 0, 89, 226, 160,
|
||||
186, 129, 2, 176, 1, 238, 140, 216, 142, 192, 88, 95, 90, 89, 91, 31,
|
||||
235, 107, 186, 129, 2, 176, 1, 238, 89, 140, 216, 142, 192, 88, 40, 200,
|
||||
95, 90, 89, 91, 31, 235, 74, 132, 192, 116, 74, 80, 48, 228, 137, 197,
|
||||
83, 232, 143, 0, 1, 232, 131, 211, 0, 232, 186, 0, 91, 88, 114, 57,
|
||||
235, 59, 182, 254, 6, 184, 64, 0, 142, 192, 38, 138, 22, 117, 0, 7,
|
||||
181, 254, 177, 255, 49, 192, 248, 195, 80, 83, 232, 102, 0, 232, 150, 0,
|
||||
91, 88, 114, 21, 235, 23, 235, 21, 180, 3, 232, 160, 0, 135, 209, 248,
|
||||
195, 180, 170, 249, 195, 180, 1, 249, 195, 180, 4, 249, 195, 48, 228, 248,
|
||||
195, 49, 192, 142, 216, 142, 192, 185, 0, 1, 191, 0, 124, 243, 171, 186,
|
||||
130, 2, 236, 136, 194, 48, 246, 184, 1, 2, 185, 1, 0, 187, 0, 124,
|
||||
205, 19, 129, 62, 254, 125, 85, 170, 117, 15, 184, 136, 6, 232, 97, 1,
|
||||
49, 192, 142, 192, 234, 0, 124, 0, 0, 184, 162, 6, 232, 82, 1, 251,
|
||||
244, 235, 253, 49, 192, 49, 219, 82, 81, 82, 136, 200, 36, 192, 209, 224,
|
||||
209, 224, 136, 232, 185, 255, 0, 247, 225, 90, 136, 241, 48, 237, 1, 200,
|
||||
177, 63, 247, 225, 89, 81, 48, 237, 128, 225, 63, 73, 1, 200, 131, 210,
|
||||
0, 137, 211, 89, 90, 195, 81, 82, 232, 18, 0, 57, 211, 114, 10, 119,
|
||||
4, 57, 200, 114, 4, 249, 90, 89, 195, 248, 90, 89, 195, 186, 250, 0,
|
||||
185, 63, 197, 195, 80, 30, 83, 81, 82, 86, 184, 0, 206, 142, 216, 186,
|
||||
129, 2, 176, 1, 238, 185, 1, 0, 186, 160, 134, 180, 134, 205, 21, 186,
|
||||
128, 2, 176, 255, 185, 10, 0, 238, 226, 253, 186, 129, 2, 176, 0, 238,
|
||||
187, 10, 0, 190, 209, 4, 185, 1, 0, 180, 1, 232, 92, 0, 115, 15,
|
||||
49, 201, 186, 32, 78, 180, 134, 205, 21, 75, 117, 231, 249, 235, 52, 190,
|
||||
215, 4, 185, 5, 0, 180, 1, 232, 64, 0, 114, 39, 186, 135, 2, 176,
|
||||
250, 238, 190, 221, 4, 185, 1, 0, 180, 1, 232, 45, 0, 190, 227, 4,
|
||||
185, 1, 0, 180, 0, 232, 34, 0, 115, 9, 186, 135, 2, 236, 132, 192,
|
||||
116, 224, 249, 94, 90, 89, 91, 31, 114, 8, 184, 243, 5, 232, 113, 0,
|
||||
88, 195, 184, 22, 6, 232, 105, 0, 88, 195, 186, 128, 2, 176, 255, 238,
|
||||
81, 185, 6, 0, 252, 172, 238, 226, 252, 185, 8, 0, 236, 60, 255, 225,
|
||||
251, 89, 56, 224, 118, 3, 249, 235, 4, 248, 236, 226, 253, 176, 255, 238,
|
||||
195, 64, 0, 0, 0, 0, 149, 72, 0, 0, 1, 170, 135, 119, 0, 0,
|
||||
0, 0, 1, 105, 64, 0, 0, 0, 1, 186, 128, 2, 80, 176, 255, 238,
|
||||
136, 200, 238, 136, 248, 238, 136, 216, 238, 88, 134, 224, 238, 134, 224, 238,
|
||||
176, 1, 238, 185, 8, 0, 236, 60, 255, 225, 251, 132, 192, 116, 1, 249,
|
||||
195, 156, 30, 83, 86, 137, 198, 184, 0, 206, 142, 216, 180, 14, 49, 219,
|
||||
252, 172, 8, 192, 116, 4, 205, 16, 235, 247, 94, 91, 31, 157, 195, 156,
|
||||
30, 83, 81, 82, 86, 137, 194, 184, 0, 206, 142, 216, 49, 219, 252, 137,
|
||||
214, 177, 12, 211, 238, 131, 230, 15, 138, 132, 134, 5, 180, 14, 205, 16,
|
||||
137, 214, 177, 8, 211, 238, 131, 230, 15, 138, 132, 134, 5, 180, 14, 205,
|
||||
16, 137, 214, 177, 4, 211, 238, 131, 230, 15, 138, 132, 134, 5, 180, 14,
|
||||
205, 16, 137, 214, 131, 230, 15, 138, 132, 134, 5, 180, 14, 205, 16, 94,
|
||||
90, 89, 91, 31, 157, 195, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
|
||||
65, 66, 67, 68, 69, 70, 66, 111, 111, 116, 82, 79, 77, 32, 102, 111,
|
||||
114, 32, 88, 84, 77, 97, 120, 32, 118, 49, 46, 48, 13, 10, 67, 111,
|
||||
112, 121, 114, 105, 103, 104, 116, 32, 40, 99, 41, 32, 50, 48, 50, 53,
|
||||
32, 77, 97, 116, 116, 104, 105, 101, 117, 32, 66, 117, 99, 99, 104, 105,
|
||||
97, 110, 101, 114, 105, 13, 10, 0, 79, 108, 100, 32, 73, 78, 84, 49,
|
||||
51, 104, 32, 86, 101, 99, 116, 111, 114, 32, 32, 32, 32, 32, 32, 32,
|
||||
61, 32, 0, 83, 68, 32, 67, 97, 114, 100, 32, 105, 110, 105, 116, 105,
|
||||
97, 108, 105, 122, 101, 100, 32, 115, 117, 99, 99, 101, 115, 115, 102, 117,
|
||||
108, 108, 121, 13, 10, 0, 83, 68, 32, 67, 97, 114, 100, 32, 102, 97,
|
||||
105, 108, 101, 100, 32, 116, 111, 32, 105, 110, 105, 116, 105, 97, 108, 105,
|
||||
122, 101, 13, 10, 0, 70, 105, 120, 101, 100, 32, 68, 105, 115, 107, 32,
|
||||
73, 68, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 61, 32, 0,
|
||||
84, 111, 116, 97, 108, 32, 70, 105, 120, 101, 100, 32, 68, 105, 115, 107,
|
||||
32, 68, 114, 105, 118, 101, 115, 32, 61, 32, 0, 85, 110, 115, 117, 112,
|
||||
112, 111, 114, 116, 101, 100, 32, 73, 78, 84, 49, 51, 104, 32, 70, 117,
|
||||
110, 99, 116, 105, 111, 110, 32, 0, 66, 111, 111, 116, 105, 110, 103, 32,
|
||||
102, 114, 111, 109, 32, 83, 68, 32, 67, 97, 114, 100, 46, 46, 46, 13,
|
||||
10, 0, 78, 111, 116, 32, 98, 111, 111, 116, 97, 98, 108, 101, 13, 10,
|
||||
0, 58, 0, 32, 0, 13, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
@ -125,6 +127,4 @@ unsigned char BOOTROM[] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 35};
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80};
|
||||
@ -15,12 +15,15 @@ cpu 8086 ; ensure we remain compatible with 8086
|
||||
; The base I/O port for the XTMAX SD Card.
|
||||
;
|
||||
%define XTMAX_IO_BASE (0x280)
|
||||
|
||||
;
|
||||
; Whether we are going to rename the BIOS's 1st disk to be the second disk.
|
||||
; This is useful to allow booting from the second disk.
|
||||
;
|
||||
;%define TAKE_OVER_FIXED_DISK_0
|
||||
%define REG_DATA (XTMAX_IO_BASE+0)
|
||||
%define REG_CS (XTMAX_IO_BASE+1) ; write-only
|
||||
%define REG_CONFIG (XTMAX_IO_BASE+1) ; read-only
|
||||
%define REG_SCRATCH_0 (XTMAX_IO_BASE+2) ; fixed disk id
|
||||
%define REG_SCRATCH_1 (XTMAX_IO_BASE+3) ; BIOS INT13h segment
|
||||
%define REG_SCRATCH_2 (XTMAX_IO_BASE+4) ; BIOS INT13h segment
|
||||
%define REG_SCRATCH_3 (XTMAX_IO_BASE+5) ; BIOS INT13h offset
|
||||
%define REG_SCRATCH_4 (XTMAX_IO_BASE+6) ; BIOS INT13h offset
|
||||
%define REG_TIMEOUT (XTMAX_IO_BASE+7)
|
||||
|
||||
;
|
||||
; Whether we will try/force using our own bootstrap code instead of falling back to BASIC.
|
||||
@ -28,6 +31,12 @@ cpu 8086 ; ensure we remain compatible with 8086
|
||||
%define USE_BOOTSTRAP
|
||||
;%define FORCE_OWN_BOOTSTRAP
|
||||
|
||||
;
|
||||
; Whether we are going to rename the BIOS's 1st disk to be the second disk.
|
||||
; This is useful to allow booting from the second disk.
|
||||
;
|
||||
;%define TAKE_OVER_FIXED_DISK_0
|
||||
|
||||
;
|
||||
; The properties of our emulated disk.
|
||||
;
|
||||
@ -38,13 +47,16 @@ cpu 8086 ; ensure we remain compatible with 8086
|
||||
%define NUM_SECTORS (NUM_HEADS * (NUM_CYLINDERS - 1) * SECTORS_PER_TRACK)
|
||||
|
||||
%if NUM_HEADS > 255
|
||||
%error NUM_HEADS is too large
|
||||
%error NUM_HEADS_ is too large
|
||||
%endif
|
||||
%if NUM_HEADS > 16
|
||||
%warning NUM_HEADS_ above 16 can cause compatibility issues
|
||||
%endif
|
||||
%if SECTORS_PER_TRACK > 63
|
||||
%error SECTORS_PER_TRACK is too large
|
||||
%error SECTORS_PER_TRACK_ is too large
|
||||
%endif
|
||||
%if NUM_CYLINDERS > 1024
|
||||
%error NUM_CYLINDERS is too large
|
||||
%error NUM_CYLINDERS_ is too large
|
||||
%endif
|
||||
|
||||
%ifndef AS_COM_PROGRAM
|
||||
@ -93,23 +105,20 @@ entry:
|
||||
.install_13h_vector:
|
||||
mov ax, old_13h_msg
|
||||
call print_string
|
||||
|
||||
xor ax, ax ; INT vector segment
|
||||
mov es, ax
|
||||
|
||||
mov ax, es:[0x13*4+2]
|
||||
mov dx, XTMAX_IO_BASE+3 ; scratch register 0-1
|
||||
mov dx, REG_SCRATCH_1
|
||||
out dx, ax ; save segment
|
||||
call print_hex
|
||||
mov ax, colon
|
||||
call print_string
|
||||
mov ax, es:[0x13*4]
|
||||
mov dx, XTMAX_IO_BASE+5 ; scratch register 2-3
|
||||
mov dx, REG_SCRATCH_3
|
||||
out dx, ax ; save offset
|
||||
call print_hex
|
||||
mov ax, newline
|
||||
call print_string
|
||||
|
||||
mov ax, ROM_SEGMENT
|
||||
mov es:[0x13*4+2], ax ; store segment
|
||||
mov ax, int13h_entry
|
||||
@ -122,22 +131,50 @@ entry:
|
||||
call swap_fixed_disk_parameters_tables
|
||||
%endif
|
||||
|
||||
;
|
||||
; Determine our fixed disk ID.
|
||||
;
|
||||
.identify_fixed_disk:
|
||||
mov ax, disk_id_msg
|
||||
call print_string
|
||||
mov ax, 0x40 ; BIOS data area
|
||||
mov es, ax
|
||||
%ifndef TAKE_OVER_FIXED_DISK_0
|
||||
mov al, es:[0x75] ; HDNUM
|
||||
add al, 0x80
|
||||
%else
|
||||
mov al, 0x80
|
||||
%endif
|
||||
mov dx, REG_SCRATCH_0 ; save fixed disk id
|
||||
out dx, al
|
||||
push ax
|
||||
call print_hex
|
||||
mov ax, newline
|
||||
call print_string
|
||||
%if !(%isdef(USE_BOOTSTRAP) && %isdef(FORCE_OWN_BOOTSTRAP))
|
||||
.update_bda:
|
||||
;
|
||||
; Increment the number of fixed disks in the BIOS Data Area.
|
||||
;
|
||||
mov ax, num_drives_msg
|
||||
call print_string
|
||||
inc byte es:[0x75] ; HDNUM
|
||||
mov al, es:[0x75]
|
||||
xor ah, ah
|
||||
call print_hex
|
||||
mov ax, newline
|
||||
call print_string
|
||||
%endif
|
||||
pop ax
|
||||
|
||||
;
|
||||
; Install our fixed disk parameter table.
|
||||
; For the 1st disk, it is stored in the interrupt vector table, at vector 41h.
|
||||
; For the 2nd disk, it is stored in the interrupt vector table, at vector 46h.
|
||||
;
|
||||
.install_fixed_disk_parameters_table:
|
||||
mov ax, disk_id_msg
|
||||
call print_string
|
||||
mov dx, XTMAX_IO_BASE+2 ; fixed disk id
|
||||
in al, dx
|
||||
xor ah, ah
|
||||
push ax
|
||||
call print_hex
|
||||
mov ax, newline
|
||||
call print_string
|
||||
pop ax
|
||||
xor cx, cx ; INT vector segment
|
||||
mov es, cx
|
||||
cmp al, 0x80
|
||||
jne .second_disk
|
||||
mov ax, ROM_SEGMENT
|
||||
@ -153,7 +190,6 @@ entry:
|
||||
.end_fdpt:
|
||||
|
||||
%ifdef USE_BOOTSTRAP
|
||||
.update_bda:
|
||||
;
|
||||
; Install our BIOS INT18h hook into the interrupt vector table.
|
||||
;
|
||||
@ -164,21 +200,6 @@ entry:
|
||||
mov es:[0x18*4], ax ; store offset
|
||||
%endif
|
||||
|
||||
%if !(%isdef(USE_BOOTSTRAP) && %isdef(FORCE_OWN_BOOTSTRAP))
|
||||
;
|
||||
; Increment the number of fixed disks in the BIOS Data Area.
|
||||
;
|
||||
mov ax, num_drives_msg
|
||||
call print_string
|
||||
mov ax, 0x40 ; BIOS data area
|
||||
mov es, ax
|
||||
inc byte es:[0x75] ; HDNUM
|
||||
mov al, es:[0x75]
|
||||
call print_hex
|
||||
mov ax, newline
|
||||
call print_string
|
||||
%endif
|
||||
|
||||
.skip:
|
||||
sti
|
||||
pop si
|
||||
@ -216,15 +237,21 @@ entry:
|
||||
; INT 13h entry point.
|
||||
;
|
||||
int13h_entry:
|
||||
sti
|
||||
%ifdef EXTRA_DEBUG
|
||||
push TEMP0
|
||||
mov TEMP0, sp
|
||||
mov TEMP0, [TEMP0+6] ; grab the flags for iret
|
||||
push TEMP0
|
||||
popf
|
||||
pop TEMP0
|
||||
call dump_regs
|
||||
%endif
|
||||
sti
|
||||
push TEMP0
|
||||
push TEMP1
|
||||
push ax
|
||||
push dx
|
||||
mov dx, XTMAX_IO_BASE+2 ; fixed disk id
|
||||
mov dx, REG_SCRATCH_0
|
||||
in al, dx
|
||||
pop dx
|
||||
cmp dl, al ; is this our drive?
|
||||
@ -236,9 +263,9 @@ int13h_entry:
|
||||
;
|
||||
.forward_to_bios:
|
||||
%ifdef TAKE_OVER_FIXED_DISK_0
|
||||
cmp dl, 0x80+FIXED_DISK_1 ; is this the other fixed drive?
|
||||
cmp dl, 0x81 ; is this the other fixed drive?
|
||||
jne .no_fixed_disk_take_over
|
||||
mov dl, 0x80+FIXED_DISK_0
|
||||
mov dl, 0x80
|
||||
call swap_fixed_disk_parameters_tables
|
||||
.no_fixed_disk_take_over:
|
||||
%endif
|
||||
@ -252,32 +279,33 @@ int13h_entry:
|
||||
;
|
||||
; Simulate INT 13h with the original vector.
|
||||
;
|
||||
pushf ; setup for iret below
|
||||
mov dx, XTMAX_IO_BASE+3 ; scratch register 0-1
|
||||
mov dx, REG_SCRATCH_1
|
||||
%ifndef AS_COM_PROGRAM
|
||||
in ax, dx
|
||||
%else
|
||||
mov ax, cs
|
||||
%endif
|
||||
push ax ; setup for iret below
|
||||
mov dx, XTMAX_IO_BASE+5 ; scratch register 2-3
|
||||
push ax ; setup for retf below
|
||||
mov dx, REG_SCRATCH_3
|
||||
%ifndef AS_COM_PROGRAM
|
||||
in ax, dx
|
||||
%else
|
||||
mov ax, fake_int13h_entry
|
||||
%endif
|
||||
push ax ; setup for iret below
|
||||
push ax ; setup for retf below
|
||||
mov ax, TEMP0 ; restore ax
|
||||
mov dx, TEMP1 ; restore dx
|
||||
iret ; call the INT 13h handler
|
||||
cli ; INT inhibits interrupts
|
||||
retf ; call the INT 13h handler
|
||||
.return_from_int13h:
|
||||
sti ; just in case
|
||||
pushf
|
||||
push ax
|
||||
mov ax, TEMP1 ; original dx
|
||||
cmp al, 0x80 ; is fixed fixed?
|
||||
jb .skip_update_hdnum
|
||||
%ifdef TAKE_OVER_FIXED_DISK_0
|
||||
mov dl, 0x80+FIXED_DISK_1
|
||||
mov dl, 0x81
|
||||
call swap_fixed_disk_parameters_tables
|
||||
%endif
|
||||
mov ax, TEMP0 ; original ax
|
||||
@ -297,7 +325,7 @@ int13h_entry:
|
||||
; This is an operation for the SD Card. Use our own INT 13h logic.
|
||||
;
|
||||
.check_function:
|
||||
cmp ah, 0x15 ; is valid function?
|
||||
cmp ah, 0x19 ; is valid function?
|
||||
jle .prepare_call
|
||||
call func_unsupported
|
||||
jmp .update_bda
|
||||
@ -392,6 +420,10 @@ func_table:
|
||||
dw func_unsupported ; diagnostics
|
||||
dw func_10_is_ready ; diagnostics
|
||||
dw func_15_read_size
|
||||
dw func_unsupported ; detect_change
|
||||
dw func_unsupported ; set_media_type
|
||||
dw func_unsupported ; set_media_type
|
||||
dw func_10_is_ready ; park_heads
|
||||
|
||||
func_unsupported:
|
||||
%ifdef DEBUG
|
||||
@ -496,7 +528,7 @@ func_02_read_sector:
|
||||
%endif
|
||||
mov di, bx ; setup use of movsw
|
||||
.assert_cs:
|
||||
mov dx, XTMAX_IO_BASE+2 ; chip select port
|
||||
mov dx, REG_CS
|
||||
mov al, 0 ; assert chip select
|
||||
out dx, al
|
||||
.cmd17:
|
||||
@ -515,15 +547,15 @@ func_02_read_sector:
|
||||
mov ax, wait_msg
|
||||
call print_string
|
||||
%endif
|
||||
mov dx, XTMAX_IO_BASE+7 ; timeout port
|
||||
mov dx, REG_TIMEOUT
|
||||
mov al, 10 ; 100 ms
|
||||
out dx, al
|
||||
.receive_token:
|
||||
mov dx, XTMAX_IO_BASE+0 ; data port
|
||||
mov dx, REG_DATA
|
||||
in al, dx
|
||||
cmp al, 0xfe
|
||||
je .got_token
|
||||
mov dx, XTMAX_IO_BASE+7 ; timeout port
|
||||
mov dx, REG_TIMEOUT
|
||||
in al, dx
|
||||
test al, al
|
||||
jnz .error
|
||||
@ -539,16 +571,16 @@ func_02_read_sector:
|
||||
cld
|
||||
.receive_block:
|
||||
rep movsw
|
||||
pop si
|
||||
.receive_crc:
|
||||
in ax, dx ; discard CRC
|
||||
lodsw ; discard CRC
|
||||
pop si
|
||||
add TEMP_LO, 1 ; next block
|
||||
adc TEMP_HI, 0 ; carry
|
||||
pop cx ; number of sectors left to read
|
||||
loop .cmd17
|
||||
.success:
|
||||
.deassert_cs1:
|
||||
mov dx, XTMAX_IO_BASE+2 ; chip select port
|
||||
mov dx, REG_CS
|
||||
mov al, 1 ; deassert chip select
|
||||
out dx, al
|
||||
.return1:
|
||||
@ -561,7 +593,7 @@ func_02_read_sector:
|
||||
jmp succeeded
|
||||
.error:
|
||||
.deassert_cs2:
|
||||
mov dx, XTMAX_IO_BASE+2 ; chip select port
|
||||
mov dx, REG_CS
|
||||
mov al, 1 ; deassert chip select
|
||||
out dx, al
|
||||
.return2:
|
||||
@ -625,7 +657,7 @@ func_03_write_sector:
|
||||
mov es, ax
|
||||
%endif
|
||||
.assert_cs:
|
||||
mov dx, XTMAX_IO_BASE+2 ; chip select port
|
||||
mov dx, REG_CS
|
||||
mov al, 0 ; assert chip select
|
||||
out dx, al
|
||||
.cmd24:
|
||||
@ -640,7 +672,7 @@ func_03_write_sector:
|
||||
mov cl, 0x58 ; CMD24
|
||||
call send_sd_read_write_cmd
|
||||
jc .error
|
||||
mov dx, XTMAX_IO_BASE+0 ; data port
|
||||
mov dx, REG_DATA
|
||||
mov al, 0xfe ; send token
|
||||
out dx, al
|
||||
mov cx, 256 ; block size (in words)
|
||||
@ -656,15 +688,15 @@ func_03_write_sector:
|
||||
mov ax, wait_msg
|
||||
call print_string
|
||||
%endif
|
||||
mov dx, XTMAX_IO_BASE+7 ; timeout port
|
||||
mov dx, REG_TIMEOUT
|
||||
mov al, 25 ; 250 ms
|
||||
out dx, al
|
||||
.receive_status:
|
||||
mov dx, XTMAX_IO_BASE+0 ; data port
|
||||
mov dx, REG_DATA
|
||||
in al, dx
|
||||
cmp al, 0xff
|
||||
jne .got_status
|
||||
mov dx, XTMAX_IO_BASE+7 ; timeout port
|
||||
mov dx, REG_TIMEOUT
|
||||
in al, dx
|
||||
test al, al
|
||||
jnz .error
|
||||
@ -689,15 +721,15 @@ func_03_write_sector:
|
||||
mov ax, wait_msg
|
||||
call print_string
|
||||
%endif
|
||||
mov dx, XTMAX_IO_BASE+7 ; timeout port
|
||||
mov dx, REG_TIMEOUT
|
||||
mov al, 25 ; 250 ms
|
||||
out dx, al
|
||||
.receive_finish:
|
||||
mov dx, XTMAX_IO_BASE+0 ; data port
|
||||
mov dx, REG_DATA
|
||||
in al, dx
|
||||
test al, al
|
||||
jnz .got_finish
|
||||
mov dx, XTMAX_IO_BASE+7 ; timeout port
|
||||
mov dx, REG_TIMEOUT
|
||||
in al, dx
|
||||
test al, al
|
||||
jnz .error
|
||||
@ -718,7 +750,7 @@ func_03_write_sector:
|
||||
%endif
|
||||
.success:
|
||||
.deassert_cs1:
|
||||
mov dx, XTMAX_IO_BASE+2 ; chip select port
|
||||
mov dx, REG_CS
|
||||
mov al, 1 ; deassert chip select
|
||||
out dx, al
|
||||
.return1:
|
||||
@ -733,7 +765,7 @@ func_03_write_sector:
|
||||
jmp succeeded
|
||||
.error:
|
||||
.deassert_cs2:
|
||||
mov dx, XTMAX_IO_BASE+2 ; chip select port
|
||||
mov dx, REG_CS
|
||||
mov al, 1 ; deassert chip select
|
||||
out dx, al
|
||||
.return2:
|
||||
@ -906,9 +938,10 @@ int18h_entry:
|
||||
mov di, 0x7c00
|
||||
rep stosw
|
||||
.read_boot_sector:
|
||||
mov dx, XTMAX_IO_BASE+2 ; fixed disk id
|
||||
mov dx, REG_SCRATCH_0
|
||||
in al, dx
|
||||
mov dl, al
|
||||
xor dh, dh
|
||||
mov ax, 0x201 ; read 1 sector
|
||||
mov cx, 1 ; sector 1
|
||||
mov bx, 0x7c00
|
||||
@ -955,14 +988,14 @@ swap_fixed_disk_parameters_tables:
|
||||
push es
|
||||
push ax
|
||||
push bx
|
||||
xor ax, ax
|
||||
xor ax, ax ; INT vector segment
|
||||
mov es, ax
|
||||
mov ax, es:[(0x41+FIXED_DISK_0*5)*4+2]
|
||||
xchg es:[(0x41+FIXED_DISK_1*5)*4+2], ax
|
||||
mov es:[(0x41+FIXED_DISK_0*5)*4+2], ax
|
||||
mov ax, es:[(0x41+FIXED_DISK_0*5)*4]
|
||||
xchg es:[(0x41+FIXED_DISK_1*5)*4], ax
|
||||
mov es:[(0x41+FIXED_DISK_0*5)*4], ax
|
||||
mov ax, es:[0x41*4+2]
|
||||
xchg es:[0x46*4+2], ax
|
||||
mov es:[0x41*4+2], ax
|
||||
mov ax, es:[0x41*4+0]
|
||||
xchg es:[0x46*4+0], ax
|
||||
mov es:[0x41*4+0], ax
|
||||
pop bx
|
||||
pop ax
|
||||
pop es
|
||||
@ -1064,7 +1097,7 @@ init_sd:
|
||||
mov ax, ROM_SEGMENT
|
||||
mov ds, ax
|
||||
%endif
|
||||
mov dx, XTMAX_IO_BASE+2 ; chip select port
|
||||
mov dx, REG_CS
|
||||
mov al, 1 ; deassert chip select
|
||||
.power_up_delay:
|
||||
out dx, al
|
||||
@ -1073,14 +1106,14 @@ init_sd:
|
||||
mov ah, 0x86 ; wait
|
||||
int 0x15
|
||||
.dummy_cycles:
|
||||
mov dx, XTMAX_IO_BASE+0 ; data port
|
||||
mov dx, REG_DATA
|
||||
mov al, 0xff
|
||||
mov cx, 10 ; send 80 clock cycles
|
||||
.synchronize:
|
||||
out dx, al
|
||||
loop .synchronize
|
||||
.assert_cs:
|
||||
mov dx, XTMAX_IO_BASE+2 ; chip select port
|
||||
mov dx, REG_CS
|
||||
mov al, 0 ; assert chip select
|
||||
out dx, al
|
||||
.cmd0:
|
||||
@ -1115,7 +1148,7 @@ init_sd:
|
||||
call send_sd_init_cmd
|
||||
jc .exit
|
||||
.acmd41:
|
||||
mov dx, XTMAX_IO_BASE+7 ; timeout port
|
||||
mov dx, REG_TIMEOUT
|
||||
mov al, 250 ; 2.5 s
|
||||
out dx, al
|
||||
.retry_acmd41:
|
||||
@ -1133,7 +1166,7 @@ init_sd:
|
||||
mov ah, 0 ; expect ready state
|
||||
call send_sd_init_cmd
|
||||
jnc .exit
|
||||
mov dx, XTMAX_IO_BASE+7 ; timeout port
|
||||
mov dx, REG_TIMEOUT
|
||||
in al, dx
|
||||
test al, al
|
||||
jz .retry_acmd41
|
||||
@ -1170,7 +1203,7 @@ init_sd:
|
||||
; FL = <TRASH>
|
||||
;
|
||||
send_sd_init_cmd:
|
||||
mov dx, XTMAX_IO_BASE+0 ; data port
|
||||
mov dx, REG_DATA
|
||||
.settle_before:
|
||||
mov al, 0xff
|
||||
out dx, al
|
||||
@ -1226,14 +1259,18 @@ send_sd_read_write_cmd:
|
||||
out dx, al
|
||||
.send_cmd:
|
||||
mov al, cl ; command byte
|
||||
mov ah, bh ; address byte 1
|
||||
out dx, ax
|
||||
pop ax ; address byte 3
|
||||
xchg al, bl ; address byte 2
|
||||
out dx, ax
|
||||
xchg al, bl ; address byte 4
|
||||
mov ah, 0x1 ; crc (dummy)
|
||||
out dx, ax
|
||||
out dx, al
|
||||
mov al, bh ; address byte 1
|
||||
out dx, al
|
||||
mov al, bl ; address byte 2
|
||||
out dx, al
|
||||
pop ax
|
||||
xchg al, ah ; address byte 3
|
||||
out dx, al
|
||||
xchg al, ah ; address byte 4
|
||||
out dx, al
|
||||
mov al, 0x1 ; crc (dummy)
|
||||
out dx, al
|
||||
mov cx, 8 ; retries
|
||||
.receive_r1:
|
||||
in al, dx
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user