diff --git a/XTMax/Code/XTMax/bootrom.h b/XTMax/Code/XTMax/bootrom.h index 060f3d0..2b4ba01 100644 --- a/XTMax/Code/XTMax/bootrom.h +++ b/XTMax/Code/XTMax/bootrom.h @@ -1,14 +1,14 @@ #define BOOTROM_ADDR 0xce000 unsigned char BOOTROM[] = { - 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, + 85, 170, 4, 6, 80, 81, 82, 86, 250, 184, 157, 5, 232, 2, 5, 232, + 2, 4, 115, 3, 233, 168, 0, 184, 223, 5, 232, 244, 4, 49, 192, 142, + 192, 38, 161, 78, 0, 186, 131, 2, 239, 232, 3, 5, 184, 150, 5, 232, + 223, 4, 38, 161, 76, 0, 186, 133, 2, 239, 232, 242, 4, 184, 154, 5, 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, + 0, 184, 60, 6, 232, 186, 4, 184, 64, 0, 142, 192, 38, 160, 117, 0, + 4, 128, 186, 130, 2, 238, 80, 232, 197, 4, 184, 154, 5, 232, 161, 4, + 184, 87, 6, 232, 155, 4, 38, 254, 6, 117, 0, 38, 160, 117, 0, 48, + 228, 232, 171, 4, 184, 154, 5, 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, @@ -25,8 +25,8 @@ unsigned char BOOTROM[] = { 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, + 80, 184, 114, 6, 232, 122, 3, 88, 80, 136, 224, 48, 228, 232, 143, 3, + 184, 154, 5, 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, @@ -58,8 +58,8 @@ unsigned char BOOTROM[] = { 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, + 205, 19, 129, 62, 254, 125, 85, 170, 117, 15, 184, 143, 6, 232, 97, 1, + 49, 192, 142, 192, 234, 0, 124, 0, 0, 184, 169, 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, @@ -73,8 +73,8 @@ unsigned char BOOTROM[] = { 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, + 116, 224, 249, 94, 90, 89, 91, 31, 114, 8, 184, 250, 5, 232, 113, 0, + 88, 195, 184, 29, 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, @@ -89,25 +89,25 @@ unsigned char BOOTROM[] = { 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, + 65, 66, 67, 68, 69, 70, 58, 0, 32, 0, 13, 10, 0, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -127,4 +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, 80}; \ 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 89f70c9..55cdfd4 100644 --- a/XTMax/Drivers/BootROM/bootrom.asm +++ b/XTMax/Drivers/BootROM/bootrom.asm @@ -1320,9 +1320,6 @@ unsupported_msg db 'Unsupported INT13h Function ', 0 boot_msg db 'Booting from SD Card...', 0xD, 0xA, 0 no_boot_msg db 'Not bootable', 0xD, 0xA, 0 %endif -colon db ':', 0 -space db ' ', 0 -newline db 0xD, 0xA, 0 %ifdef DEBUG handler_msg db 'INT13h Function ', 0 diff --git a/XTMax/Drivers/BootROM/build.cmd b/XTMax/Drivers/BootROM/build.cmd index a4087f1..de5f553 100644 --- a/XTMax/Drivers/BootROM/build.cmd +++ b/XTMax/Drivers/BootROM/build.cmd @@ -1,2 +1,3 @@ ..\Driver_Build_Tools\NASM\nasm.exe -f bin -o bootrom.com -DAS_COM_PROGRAM .\bootrom.asm ..\Driver_Build_Tools\NASM\nasm.exe -f bin -o bootrom .\bootrom.asm & python checksum.py & python generate_header.py +..\Driver_Build_Tools\NASM\nasm.exe -f bin -o xtmdiags.com .\diags.asm diff --git a/XTMax/Drivers/BootROM/diags.asm b/XTMax/Drivers/BootROM/diags.asm new file mode 100644 index 0000000..d7c4cb9 --- /dev/null +++ b/XTMax/Drivers/BootROM/diags.asm @@ -0,0 +1,354 @@ +org 0x100 + +; +; The base I/O port for the XTMAX SD Card. +; +%define XTMAX_IO_BASE (0x280) +%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 + +entry: + mov ax, welcome_msg + call print_string + +; +; Inspect the INT13h and the HDNUM +; + mov ax, current_13h_msg + call print_string + xor ax, ax ; INT vector segment + mov es, ax + mov ax, es:[0x13*4+2] + call print_hex + mov ax, colon + call print_string + mov ax, es:[0x13*4] + call print_hex + mov ax, newline + call print_string + + mov ax, saved_13h_msg + call print_string + mov dx, REG_SCRATCH_1 + in ax, dx + call print_hex + mov ax, colon + call print_string + mov dx, REG_SCRATCH_3 + in ax, dx + call print_hex + mov ax, newline + call print_string + + mov ax, hdnum_msg + call print_string + mov ax, 0x40 ; BIOS data area + mov es, ax + mov al, es:[0x75] ; HDNUM + call print_hex_byte + mov ax, newline + call print_string + + mov ax, disk_id_msg + call print_string + mov dx, REG_SCRATCH_0 + in al, dx + xor ah, ah + call print_hex_byte + mov ax, newline + call print_string + mov ax, newline + call print_string + +; +; Inspect the Fixed Disk Parameters Tables +; + mov ax, disk80_fdpt_msg + call print_string + xor ax, ax ; INT vector segment + mov es, ax + mov ax, es:[0x41*4+2] + mov bx, ax + call print_hex + mov ax, colon + call print_string + mov ax, es:[0x41*4] + mov si, ax + call print_hex + mov ax, newline + call print_string + + mov ax, space + call print_string + mov ax, space + call print_string + mov es, bx + mov cx, 18 +.dump_disk80_fdpt: + mov al, es:[si] + inc si + call print_hex_byte + mov ax, space + call print_string + loop .dump_disk80_fdpt + mov ax, newline + call print_string + + mov ax, disk81_fdpt_msg + call print_string + xor ax, ax ; INT vector segment + mov es, ax + mov ax, es:[0x46*4+2] + mov bx, ax + call print_hex + mov ax, colon + call print_string + mov ax, es:[0x46*4] + mov si, ax + call print_hex + mov ax, newline + call print_string + + mov ax, space + call print_string + mov ax, space + call print_string + mov es, bx + mov cx, 18 +.dump_disk81_fdpt: + mov al, es:[si] + inc si + call print_hex_byte + mov ax, space + call print_string + loop .dump_disk81_fdpt + mov ax, newline + call print_string + mov ax, newline + call print_string + +; +; Invoke Read Parameters on the fixed disks. +; + mov ax, parm_disk80_msg + call print_string + xor ax, ax + xor bx, bx + xor cx, cx + xor dx, dx + xor si, si + xor di, di + xor bp, bp + mov dl, 0x80 + mov ah, 0x08 + call dump_regs + int 0x13 + call dump_regs + mov ax, newline + + call print_string + mov ax, parm_disk81_msg + call print_string + xor ax, ax + xor bx, bx + xor cx, cx + xor dx, dx + xor si, si + xor di, di + xor bp, bp + mov dl, 0x81 + mov ah, 0x08 + call dump_regs + int 0x13 + call dump_regs + + ; wait for kbd + mov ah, 0x01 + int 0x21 + mov ax, newline + call print_string + +; +; Read First Sector on the fixed disks. +; + xor ax, ax + mov cx, 256 + mov di, buf_read + rep stosw + mov ax, read_disk80_msg + call print_string + xor ax, ax + xor bx, bx + xor cx, cx + xor dx, dx + xor si, si + xor di, di + xor bp, bp + mov dl, 0x80 + mov ah, 0x02 + mov bx, ds + mov es, bx + mov bx, buf_read + mov ch, 0 + mov cl, 1 + mov dh, 0 + mov al, 1 + call dump_regs + int 0x13 + call dump_regs + mov ax, newline + call print_string + + mov cx, 16 + mov si, buf_read +.dump_disk80_sector_1: + lodsb + call print_hex_byte + mov ax, space + call print_string + loop .dump_disk80_sector_1 + mov ax, newline + call print_string + mov ax, dotdotdot + call print_string + mov cx, 16 + add si, 512-16-16 +.dump_disk80_sector_2: + lodsb + call print_hex_byte + mov ax, space + call print_string + loop .dump_disk80_sector_2 + mov ax, newline + call print_string + mov ax, newline + call print_string + + xor ax, ax + mov cx, 256 + mov di, buf_read + rep stosw + mov ax, read_disk81_msg + call print_string + xor ax, ax + xor bx, bx + xor cx, cx + xor dx, dx + xor si, si + xor di, di + xor bp, bp + mov dl, 0x81 + mov ah, 0x02 + mov bx, ds + mov es, bx + mov bx, buf_read + mov ch, 0 + mov cl, 1 + mov dh, 0 + mov al, 1 + call dump_regs + int 0x13 + call dump_regs + mov ax, newline + call print_string + + mov cx, 16 + mov si, buf_read +.dump_disk81_sector_1: + lodsb + call print_hex_byte + mov ax, space + call print_string + loop .dump_disk81_sector_1 + mov ax, newline + call print_string + mov ax, dotdotdot + call print_string + mov cx, 16 + add si, 512-16-16 +.dump_disk81_sector_2: + lodsb + call print_hex_byte + mov ax, space + call print_string + loop .dump_disk81_sector_2 + mov ax, newline + call print_string + +; +; DOS exit program. +; + mov ah, 0x4c + xor al, al + int 0x21 + +buf_read times 512 db 0 + +; +; General utilities +; + +%define AS_COM_PROGRAM +%include "utils.inc" + +; +; Display an 8-bit value in hex. +; in: AL = value +; out: AX = +; +print_hex_byte: + pushf + push ds + push bx + push cx + push dx + push si + mov dl, al + xor ah, ah +%ifndef AS_COM_PROGRAM + mov ax, ROM_SEGMENT + mov ds, ax +%endif + xor bx, bx + cld +.nibble1: + mov si, dx + mov cl, 4 + shr si, cl + and si, 0xf + mov al, [hex_map+si] + mov ah, 0xe + int 0x10 +.nibble2: + mov si, dx + and si, 0xf + mov al, [hex_map+si] + mov ah, 0xe + int 0x10 + pop si + pop dx + pop cx + pop bx + pop ds + popf + ret + +; +; Strings +; + +welcome_msg db 'XTMax BootROM diagnostics', 0xD, 0xA, 0xD, 0xA, 0 +current_13h_msg db 'Current INT13h Vector = ', 0 +saved_13h_msg db 'Saved INT13h Vector = ', 0 +hdnum_msg db 'BIOS Data Area HDNUM = ', 0 +disk_id_msg db 'XTMax Fixed Disk ID = ', 0 +disk80_fdpt_msg db 'Fixed Disk 80h Parameters Table = ', 0 +disk81_fdpt_msg db 'Fixed Disk 81h Parameters Table = ', 0 +parm_disk80_msg db 'Call Fixed Disk 80h Read Parameters', 0xD, 0xA, 0 +parm_disk81_msg db 'Call Fixed Disk 81h Read Parameters', 0xD, 0xA, 0 +read_disk80_msg db 'Read First Sector on Fixed Disk 80h', 0xD, 0xA, 0 +read_disk81_msg db 'Read First Sector on Fixed Disk 81h', 0xD, 0xA, 0 +dotdotdot db '[...]', 0xD, 0xA, 0 \ No newline at end of file diff --git a/XTMax/Drivers/BootROM/utils.inc b/XTMax/Drivers/BootROM/utils.inc index c3541b0..38c4868 100644 --- a/XTMax/Drivers/BootROM/utils.inc +++ b/XTMax/Drivers/BootROM/utils.inc @@ -142,3 +142,7 @@ dump_regs: registers_msg db ' AX BX CX DX DS SI ES DI BP FLAGS', 0xD, 0xA, 0 %endif + +colon db ':', 0 +space db ' ', 0 +newline db 0xD, 0xA, 0