diff --git a/XTMax/Code/XTMax/XTMax.ino b/XTMax/Code/XTMax/XTMax.ino index 600479d..2bb8b56 100644 --- a/XTMax/Code/XTMax/XTMax.ino +++ b/XTMax/Code/XTMax/XTMax.ino @@ -197,7 +197,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[5] = {0, 0, 0, 0, 0}; uint8_t XTMax_MEM_Response_Array[16]; @@ -681,10 +681,12 @@ inline void IO_Read_Cycle() { 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+4: isa_data_out = sd_scratch_register[0]; break; - case SD_BASE+5: isa_data_out = sd_scratch_register[1]; break; - case SD_BASE+6: isa_data_out = sd_scratch_register[2]; break; - case SD_BASE+7: isa_data_out = sd_scratch_register[3]; break; + case SD_BASE+2: break; // Write only + 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+7: isa_data_out = sd_scratch_register[4]; break; } GPIO7_DR = GPIO7_DATA_OUT_UNSCRAMBLE + MUX_ADDR_n_LOW + CHRDY_OUT_LOW + trigger_out; @@ -745,10 +747,11 @@ inline void IO_Write_Cycle() { 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+4: sd_scratch_register[0] = data_in; break; - case SD_BASE+5: sd_scratch_register[1] = data_in; break; - case SD_BASE+6: sd_scratch_register[2] = data_in; break; - case SD_BASE+7: sd_scratch_register[3] = data_in; 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+7: sd_scratch_register[4] = data_in; break; } //gpio9_int = GPIO9_DR; diff --git a/XTMax/Code/XTMax/bootrom.h b/XTMax/Code/XTMax/bootrom.h index 473c04a..a71c06b 100644 --- a/XTMax/Code/XTMax/bootrom.h +++ b/XTMax/Code/XTMax/bootrom.h @@ -1,97 +1,105 @@ #define BOOTROM_ADDR 0xCE000 unsigned char BOOTROM[] = { - 85, 170, 4, 6, 80, 82, 250, 184, 200, 228, 232, 54, 4, 232, 57, 3, - 115, 3, 233, 130, 0, 184, 10, 229, 232, 40, 4, 49, 192, 142, 192, 38, - 161, 78, 0, 186, 132, 2, 239, 232, 55, 4, 184, 181, 229, 232, 19, 4, - 38, 161, 76, 0, 186, 134, 2, 239, 232, 38, 4, 184, 185, 229, 232, 2, - 4, 184, 31, 229, 232, 252, 3, 184, 0, 192, 38, 163, 78, 0, 232, 16, - 4, 184, 181, 229, 232, 236, 3, 184, 156, 224, 38, 163, 76, 0, 232, 0, - 4, 184, 185, 229, 232, 220, 3, 184, 52, 229, 232, 214, 3, 184, 0, 192, - 38, 163, 6, 1, 232, 234, 3, 184, 181, 229, 232, 198, 3, 184, 81, 225, - 38, 163, 4, 1, 232, 218, 3, 184, 185, 229, 232, 182, 3, 184, 64, 0, - 142, 192, 38, 254, 6, 117, 0, 251, 90, 88, 7, 203, 85, 86, 128, 250, - 128, 116, 28, 137, 197, 137, 214, 156, 14, 184, 189, 224, 80, 156, 186, 132, - 2, 237, 80, 186, 134, 2, 237, 80, 137, 232, 137, 242, 207, 235, 56, 128, - 252, 21, 126, 5, 232, 112, 0, 235, 34, 128, 252, 1, 116, 10, 128, 252, - 21, 116, 5, 190, 235, 224, 235, 3, 190, 247, 224, 86, 83, 136, 227, 48, - 255, 208, 227, 137, 222, 91, 46, 255, 164, 11, 225, 6, 190, 64, 0, 142, - 198, 38, 136, 38, 116, 0, 7, 137, 229, 139, 118, 8, 156, 131, 230, 254, - 157, 131, 214, 0, 86, 157, 94, 93, 202, 2, 0, 221, 226, 97, 225, 117, - 225, 248, 225, 156, 226, 55, 225, 55, 225, 55, 225, 183, 226, 221, 226, 55, - 225, 55, 225, 207, 226, 221, 226, 55, 225, 55, 225, 221, 226, 221, 226, 55, - 225, 55, 225, 221, 226, 223, 226, 80, 184, 152, 229, 232, 5, 3, 88, 80, - 136, 224, 48, 228, 232, 26, 3, 184, 185, 229, 232, 246, 2, 88, 233, 155, - 1, 0, 4, 16, 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, 112, 1, 80, 48, 228, 137, - 198, 83, 232, 115, 1, 137, 197, 1, 240, 137, 222, 131, 211, 0, 232, 154, - 1, 91, 88, 115, 3, 233, 88, 1, 83, 81, 82, 87, 80, 137, 193, 48, - 237, 137, 223, 186, 130, 2, 176, 0, 238, 81, 137, 232, 137, 243, 177, 81, - 232, 90, 2, 114, 50, 186, 128, 2, 185, 232, 3, 235, 3, 232, 117, 2, - 236, 60, 254, 224, 248, 117, 32, 185, 0, 1, 252, 237, 171, 226, 252, 237, - 131, 197, 1, 131, 214, 0, 89, 226, 208, 186, 130, 2, 176, 1, 238, 88, - 95, 90, 89, 91, 233, 13, 1, 186, 130, 2, 176, 1, 238, 89, 88, 40, - 200, 95, 90, 89, 91, 233, 240, 0, 132, 192, 117, 3, 233, 237, 0, 80, - 48, 228, 137, 198, 83, 232, 240, 0, 137, 197, 1, 240, 137, 222, 131, 211, - 0, 232, 23, 1, 91, 88, 115, 3, 233, 213, 0, 30, 83, 81, 82, 87, - 80, 137, 193, 48, 237, 137, 223, 140, 192, 142, 216, 186, 130, 2, 176, 0, - 238, 81, 137, 232, 137, 243, 177, 88, 232, 210, 1, 114, 78, 186, 128, 2, - 176, 254, 238, 185, 0, 1, 135, 247, 252, 173, 239, 226, 252, 135, 254, 186, - 128, 2, 185, 196, 9, 235, 3, 232, 219, 1, 236, 60, 255, 225, 248, 36, - 31, 60, 5, 117, 38, 185, 196, 9, 235, 3, 232, 200, 1, 236, 132, 192, - 225, 248, 116, 23, 131, 197, 1, 131, 214, 0, 89, 226, 180, 186, 130, 2, - 176, 1, 238, 88, 95, 90, 89, 91, 31, 235, 105, 186, 130, 2, 176, 1, - 238, 89, 88, 40, 200, 95, 90, 89, 91, 31, 235, 76, 132, 192, 116, 76, - 80, 48, 228, 137, 197, 83, 232, 79, 0, 1, 232, 131, 211, 0, 232, 122, - 0, 91, 88, 114, 59, 235, 61, 182, 15, 6, 184, 64, 0, 142, 192, 38, - 138, 22, 117, 0, 7, 254, 194, 181, 254, 177, 255, 49, 192, 248, 195, 80, - 83, 232, 36, 0, 232, 84, 0, 91, 88, 114, 21, 235, 23, 235, 21, 180, - 3, 232, 94, 0, 135, 209, 248, 195, 180, 170, 249, 195, 180, 1, 249, 195, - 180, 4, 249, 195, 48, 228, 248, 195, 49, 192, 49, 219, 82, 81, 82, 136, - 200, 36, 192, 209, 224, 209, 224, 136, 232, 185, 16, 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, 15, 0, 185, 16, 188, 195, 80, 30, 83, 81, 82, 86, 184, - 0, 192, 142, 216, 186, 130, 2, 176, 1, 238, 49, 201, 186, 232, 3, 180, - 134, 205, 21, 186, 128, 2, 176, 255, 185, 80, 0, 238, 226, 253, 186, 130, - 2, 176, 0, 238, 190, 245, 227, 185, 1, 0, 180, 1, 232, 79, 0, 114, - 54, 190, 251, 227, 185, 5, 0, 180, 1, 232, 66, 0, 114, 41, 187, 100, - 0, 190, 1, 228, 185, 1, 0, 180, 1, 232, 50, 0, 190, 7, 228, 185, - 1, 0, 180, 0, 232, 39, 0, 115, 14, 156, 49, 201, 186, 232, 3, 180, - 134, 205, 21, 157, 75, 117, 218, 94, 90, 89, 91, 31, 114, 8, 184, 86, - 229, 232, 127, 0, 88, 195, 184, 121, 229, 232, 119, 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, 81, 82, 49, 201, 186, 100, 0, 180, 134, 205, 21, - 90, 89, 195, 156, 30, 83, 86, 137, 198, 184, 0, 192, 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, 192, 142, 216, 49, 219, - 252, 137, 214, 177, 12, 211, 238, 131, 230, 15, 138, 132, 184, 228, 180, 14, - 205, 16, 137, 214, 177, 8, 211, 238, 131, 230, 15, 138, 132, 184, 228, 180, - 14, 205, 16, 137, 214, 177, 4, 211, 238, 131, 230, 15, 138, 132, 184, 228, - 180, 14, 205, 16, 137, 214, 131, 230, 15, 138, 132, 184, 228, 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, 61, 32, 0, 78, - 101, 119, 32, 73, 78, 84, 49, 51, 104, 32, 86, 101, 99, 116, 111, 114, - 32, 61, 32, 0, 78, 101, 119, 32, 70, 105, 120, 101, 100, 32, 68, 105, - 115, 107, 32, 80, 97, 114, 97, 109, 101, 116, 101, 114, 32, 84, 97, 98, - 108, 101, 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, 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, 58, 0, 32, 0, 13, 10, 0, 0, 0, 0, 0, + 85, 170, 4, 6, 80, 82, 250, 184, 27, 229, 232, 137, 4, 232, 140, 3, + 115, 3, 233, 188, 0, 84, 88, 57, 224, 116, 39, 62, 161, 255, 255, 62, + 199, 6, 255, 255, 170, 170, 62, 128, 62, 0, 0, 170, 62, 163, 255, 255, + 116, 2, 235, 14, 80, 48, 192, 176, 64, 246, 224, 88, 116, 4, 48, 210, + 235, 8, 178, 1, 184, 93, 229, 232, 76, 4, 184, 131, 2, 146, 238, 184, + 130, 229, 232, 65, 4, 49, 192, 142, 192, 38, 161, 78, 0, 186, 132, 2, + 239, 232, 80, 4, 184, 45, 230, 232, 44, 4, 38, 161, 76, 0, 186, 134, + 2, 239, 232, 63, 4, 184, 49, 230, 232, 27, 4, 184, 151, 229, 232, 21, + 4, 184, 0, 192, 38, 163, 78, 0, 232, 41, 4, 184, 45, 230, 232, 5, + 4, 184, 214, 224, 38, 163, 76, 0, 232, 25, 4, 184, 49, 230, 232, 245, + 3, 184, 172, 229, 232, 239, 3, 184, 0, 192, 38, 163, 6, 1, 232, 3, + 4, 184, 45, 230, 232, 223, 3, 184, 139, 225, 38, 163, 4, 1, 232, 243, + 3, 184, 49, 230, 232, 207, 3, 184, 64, 0, 142, 192, 38, 254, 6, 117, + 0, 251, 90, 88, 7, 203, 85, 86, 128, 250, 128, 116, 28, 137, 197, 137, + 214, 156, 14, 184, 247, 224, 80, 156, 186, 132, 2, 237, 80, 186, 134, 2, + 237, 80, 137, 232, 137, 242, 207, 235, 56, 128, 252, 21, 126, 5, 232, 112, + 0, 235, 34, 128, 252, 1, 116, 10, 128, 252, 21, 116, 5, 190, 37, 225, + 235, 3, 190, 49, 225, 86, 83, 136, 227, 48, 255, 208, 227, 137, 222, 91, + 46, 255, 164, 69, 225, 6, 190, 64, 0, 142, 198, 38, 136, 38, 116, 0, + 7, 137, 229, 139, 118, 8, 156, 131, 230, 254, 157, 131, 214, 0, 86, 157, + 94, 93, 202, 2, 0, 48, 227, 155, 225, 175, 225, 64, 226, 239, 226, 113, + 225, 113, 225, 113, 225, 10, 227, 48, 227, 113, 225, 113, 225, 34, 227, 48, + 227, 113, 225, 113, 225, 48, 227, 48, 227, 113, 225, 113, 225, 48, 227, 50, + 227, 80, 184, 16, 230, 232, 30, 3, 88, 80, 136, 224, 48, 228, 232, 51, + 3, 184, 49, 230, 232, 15, 3, 88, 233, 180, 1, 0, 4, 16, 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, 137, 1, 80, 48, 228, 137, 198, 83, 232, 140, 1, 137, + 197, 1, 240, 137, 222, 131, 211, 0, 232, 179, 1, 91, 88, 115, 3, 233, + 113, 1, 83, 81, 82, 87, 80, 137, 193, 48, 237, 137, 223, 186, 130, 2, + 176, 0, 238, 81, 137, 232, 137, 243, 177, 81, 232, 115, 2, 114, 64, 186, + 128, 2, 185, 232, 3, 235, 3, 232, 142, 2, 236, 60, 254, 224, 248, 117, + 46, 185, 0, 1, 82, 186, 131, 2, 236, 90, 132, 192, 252, 116, 4, 243, + 109, 235, 4, 237, 171, 226, 252, 237, 131, 197, 1, 131, 214, 0, 89, 226, + 194, 186, 130, 2, 176, 1, 238, 88, 95, 90, 89, 91, 233, 24, 1, 186, + 130, 2, 176, 1, 238, 89, 88, 40, 200, 95, 90, 89, 91, 233, 251, 0, + 132, 192, 117, 3, 233, 248, 0, 80, 48, 228, 137, 198, 83, 232, 251, 0, + 137, 197, 1, 240, 137, 222, 131, 211, 0, 232, 34, 1, 91, 88, 115, 3, + 233, 224, 0, 30, 83, 81, 82, 87, 80, 137, 193, 48, 237, 137, 223, 140, + 192, 142, 216, 186, 130, 2, 176, 0, 238, 81, 137, 232, 137, 243, 177, 88, + 232, 221, 1, 114, 89, 186, 128, 2, 176, 254, 238, 185, 0, 1, 135, 247, + 82, 186, 131, 2, 236, 90, 132, 192, 252, 116, 4, 243, 111, 235, 4, 173, + 239, 226, 252, 135, 254, 185, 196, 9, 235, 3, 232, 219, 1, 236, 60, 255, + 225, 248, 36, 31, 60, 5, 117, 38, 185, 196, 9, 235, 3, 232, 200, 1, + 236, 132, 192, 225, 248, 116, 23, 131, 197, 1, 131, 214, 0, 89, 226, 169, + 186, 130, 2, 176, 1, 238, 88, 95, 90, 89, 91, 31, 235, 105, 186, 130, + 2, 176, 1, 238, 89, 88, 40, 200, 95, 90, 89, 91, 31, 235, 76, 132, + 192, 116, 76, 80, 48, 228, 137, 197, 83, 232, 79, 0, 1, 232, 131, 211, + 0, 232, 122, 0, 91, 88, 114, 59, 235, 61, 182, 15, 6, 184, 64, 0, + 142, 192, 38, 138, 22, 117, 0, 7, 254, 194, 181, 254, 177, 255, 49, 192, + 248, 195, 80, 83, 232, 36, 0, 232, 84, 0, 91, 88, 114, 21, 235, 23, + 235, 21, 180, 3, 232, 94, 0, 135, 209, 248, 195, 180, 170, 249, 195, 180, + 1, 249, 195, 180, 4, 249, 195, 48, 228, 248, 195, 49, 192, 49, 219, 82, + 81, 82, 136, 200, 36, 192, 209, 224, 209, 224, 136, 232, 185, 16, 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, 15, 0, 185, 16, 188, 195, 80, 30, 83, 81, + 82, 86, 184, 0, 192, 142, 216, 186, 130, 2, 176, 1, 238, 49, 201, 186, + 232, 3, 180, 134, 205, 21, 186, 128, 2, 176, 255, 185, 80, 0, 238, 226, + 253, 186, 130, 2, 176, 0, 238, 190, 72, 228, 185, 1, 0, 180, 1, 232, + 79, 0, 114, 54, 190, 78, 228, 185, 5, 0, 180, 1, 232, 66, 0, 114, + 41, 187, 100, 0, 190, 84, 228, 185, 1, 0, 180, 1, 232, 50, 0, 190, + 90, 228, 185, 1, 0, 180, 0, 232, 39, 0, 115, 14, 156, 49, 201, 186, + 232, 3, 180, 134, 205, 21, 157, 75, 117, 218, 94, 90, 89, 91, 31, 114, + 8, 184, 206, 229, 232, 127, 0, 88, 195, 184, 241, 229, 232, 119, 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, 81, 82, 49, 201, 186, 100, 0, 180, + 134, 205, 21, 90, 89, 195, 156, 30, 83, 86, 137, 198, 184, 0, 192, 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, 192, 142, + 216, 49, 219, 252, 137, 214, 177, 12, 211, 238, 131, 230, 15, 138, 132, 11, + 229, 180, 14, 205, 16, 137, 214, 177, 8, 211, 238, 131, 230, 15, 138, 132, + 11, 229, 180, 14, 205, 16, 137, 214, 177, 4, 211, 238, 131, 230, 15, 138, + 132, 11, 229, 180, 14, 205, 16, 137, 214, 131, 230, 15, 138, 132, 11, 229, + 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, 67, 80, 85, + 32, 115, 117, 112, 112, 111, 114, 116, 115, 32, 73, 78, 83, 47, 79, 85, + 84, 83, 32, 105, 110, 115, 116, 114, 117, 99, 116, 105, 111, 110, 115, 13, + 10, 0, 79, 108, 100, 32, 73, 78, 84, 49, 51, 104, 32, 86, 101, 99, + 116, 111, 114, 32, 61, 32, 0, 78, 101, 119, 32, 73, 78, 84, 49, 51, + 104, 32, 86, 101, 99, 116, 111, 114, 32, 61, 32, 0, 78, 101, 119, 32, + 70, 105, 120, 101, 100, 32, 68, 105, 115, 107, 32, 80, 97, 114, 97, 109, + 101, 116, 101, 114, 32, 84, 97, 98, 108, 101, 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, + 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, 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, 0, 0, 0, 0, @@ -119,12 +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, 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, 0, 216}; \ No newline at end of file + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 157}; \ No newline at end of file diff --git a/XTMax/Drivers/BootROM/bootrom.asm b/XTMax/Drivers/BootROM/bootrom.asm index 695bd37..effa8d3 100644 --- a/XTMax/Drivers/BootROM/bootrom.asm +++ b/XTMax/Drivers/BootROM/bootrom.asm @@ -83,10 +83,48 @@ entry: mov ax, welcome_msg call print_string +; +; Initialize the SD Card. +; call init_sd - %ifndef AS_COM_PROGRAM jc .skip +%endif + +; +; Detecting 80186-compatible so we can use REP INSW/OUTSW. +; Based on https://www.rcollins.org/ftp/source/cpuid/cpuid.asm +; +.cpuid: + push sp + pop ax + cmp ax, sp ; if below 80286, these values will differ + jz .support_string_io ; nope, 80286 or higher + mov ax, ds:[0xffff] ; get original data + mov word ds:[0xffff], 0xaaaa ; write signature at test location + cmp byte ds:[0], 0xaa ; 8086 will write the 2nd byte at offset 0 + mov ds:[0xffff], ax + je .test_v20 + jmp .support_string_io ; we have an 80186/80188 +.test_v20: + push ax ; save results + xor al, al ; force ZF + mov al, 0x40 ; multiplicand + mul al ; V20 doesn't affect ZF + pop ax ; restore results + jz .support_string_io ; we have an V20 + xor dl, dl + jmp .store_string_io +.support_string_io: + mov dl, 1 + mov ax, string_io_msg + call print_string +.store_string_io: + mov ax, 0x283 ; scratch register 0 + xchg ax, dx + out dx, al ; save capability + +%ifndef AS_COM_PROGRAM ; ; Install our BIOS INT13h hook into the interrupt vector table. ; @@ -98,13 +136,13 @@ entry: mov es, ax mov ax, es:[0x13*4+2] - mov dx, 0x284 ; scratch register 0 + mov dx, 0x284 ; scratch register 1-2 out dx, ax ; save segment call print_hex mov ax, colon call print_string mov ax, es:[0x13*4] - mov dx, 0x286 ; scratch register 2 + mov dx, 0x286 ; scratch register 3-4 out dx, ax ; save offset call print_hex mov ax, newline @@ -245,14 +283,14 @@ int13h_entry: ; Simulate INT 13h with the original vector. ; pushf ; setup for iret below - mov dx, 0x284 ; scratch register 0 + mov dx, 0x284 ; scratch register 1-2 %ifndef AS_COM_PROGRAM in ax, dx %else mov ax, cs %endif push ax ; setup for iret below - mov dx, 0x286 ; scratch register 2 + mov dx, 0x286 ; scratch register 3-4 %ifndef AS_COM_PROGRAM in ax, dx %else @@ -502,11 +540,23 @@ func_02_read_sector: call print_string %endif mov cx, 256 ; block size (in words) + push dx + mov dx, 0x283 ; scratch register 0 + in al, dx + pop dx + test al, al ; supports insw? cld + jz .receive_block +.receive_block_fast: +cpu 186 + rep insw +cpu 8086 + jmp .receive_crc .receive_block: in ax, dx stosw loop .receive_block +.receive_crc: in ax, dx ; discard CRC add TEMP_LO, 1 ; next block adc TEMP_HI, 0 ; carry @@ -605,17 +655,28 @@ func_03_write_sector: out dx, al mov cx, 256 ; block size (in words) xchg di, si ; save si (aka TEMP1) + push dx + mov dx, 0x283 ; scratch register 0 + in al, dx + pop dx + test al, al ; supports outsw? cld + jz .send_block +.send_block_fast: +cpu 186 + rep outsw +cpu 8086 + jmp .end_send_block .send_block: lodsw out dx, ax loop .send_block +.end_send_block: xchg si, di ; restore si (aka TEMP1) %ifdef DEBUG_IO mov ax, wait_msg call print_string %endif - mov dx, 0x280 ; data port mov cx, 2500 ; timeout jmp .receive_status_no_delay .receive_status: @@ -1205,6 +1266,7 @@ debug_handler: welcome_msg db 'BootROM for XTMax v1.0', 0xD, 0xA db 'Copyright (c) 2025 Matthieu Bucchianeri', 0xD, 0xA, 0 +string_io_msg db 'CPU supports INS/OUTS instructions', 0xD, 0xA, 0 old_13h_msg db 'Old INT13h Vector = ', 0 new_13h_msg db 'New INT13h Vector = ', 0 new_fdpt_msg db 'New Fixed Disk Parameter Table = ', 0