diff --git a/README.md b/README.md index b0ea687..b12f04a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,19 @@ # 80188 single board modular computer -v.0.1.0 +* testing and firmware development: r1 +* hardware development: r2 + +## Configuration + +* 8MHz 8086-compatible CPU +* 128KB low SRAM +* 256KB EEPROM (27C020) or Flash (SST39SF020) with in-system programming and software programming capabilities +* PC/104-compatible with 8-bit ISA bus + - 80188 Timer A is routed to OSC +* Dual channel 16550-compatible UART + - FTDI USB-Serial/6-pin connector on port A + - 5V 9pin connector on port B +* AT-compatible RTC ## References * [Tandy 2000 BIOS](https://www.retrotronics.org/svn/t2kbios/) @@ -9,11 +22,17 @@ v.0.1.0 ## Notes -### 0.1.0r1 +### r1 * minor: SYSBUS socket is too close to the CPU socket and can'tbe used with the wide connector * minor: 16V8 /OE and GND pin names were swapped * minor: UART1 labels are wrong * major: 74x573 OE should be /OE * major: 16V8 /RESET can't be used as input +* major: PLCC sockets are unreliable * unknown: 22V10 Verification failed at address 0x16C5: File=0x01, Device=0x00 +* feature: added in-system programming +* major: 39x flash doesn't work as /PGM is floating + +### r0 +* major: PCB socket is unreliable diff --git a/fw/8250.S b/fw/8250.S index 1b3c44d..98d0f6b 100644 --- a/fw/8250.S +++ b/fw/8250.S @@ -100,7 +100,7 @@ _serial_puts: %macro _serial_puts 1 mov bx, %1 %%loop: - mov al,[ds:bx] + mov al, [ds:bx] cmp al, 0 jz %%end mov cl, al diff --git a/fw/Makefile b/fw/Makefile index 4f9d7aa..3071dd4 100644 --- a/fw/Makefile +++ b/fw/Makefile @@ -1,4 +1,7 @@ sources = reset.S monitor.S +targets = fw.bin debug.txt + +all: $(targets) # firmware fw.bin: $(sources:.S=) @@ -14,16 +17,19 @@ reset.sym: reset grep -f reset.glob reset.map | \ awk 'BEGIN{print ";; autogenerated"}{print $$3,"equ","0x"$$1}' > $@ +debug.txt: reset + grep -e '^\s*say_what' -e '^[a-z_\.]*:$$' reset.S > $@ + # assembly %: %.S nasm $< -o $@ clean: - rm -f fw.bin $(sources:.S=.d) $(sources:.S=) reset.o reset.glob reset.map + rm -f $(targets) $(sources:.S=.d) $(sources:.S=) reset.o reset.glob reset.map # deps %.d: %.S nasm -M $^ > $@ include $(sources:.S=.d) -.PHONY: clean +.PHONY: all clean diff --git a/fw/debug.txt b/fw/debug.txt new file mode 100644 index 0000000..0e4ac25 --- /dev/null +++ b/fw/debug.txt @@ -0,0 +1,37 @@ +_mon: +_putch: +_getch: +_setup: + say_what 0xb007 ; jumped to the setup code + say_what 0xb105 +_soc_failure: + say_what 0xdead +_soc_passed: + say_what 0xc0de +_set_mem: +_set_pcs: +_test_setup_rom: +.loop: +.check: +.rom_failure: + say_what 0x0bad +.end: + say_what bx ; checksum + say_what 0x1337 ; rom check passed +_set_sp: + say_what ss ; 0x1000 + say_what sp ; 0xffff +_test_ram_words: + say_what si ; ram test address + say_what cx ; ram test value to write + say_what bx ; ram test value readback +.ram_failure: +.halt: + say_what 0x2bad +.end: + say_what 0xcafe ; memory test passed +_init_serial: +_print_version: +.loop: +_finish: +_restart: diff --git a/fw/fw.bin b/fw/fw.bin index 1639434..ca2713a 100644 Binary files a/fw/fw.bin and b/fw/fw.bin differ diff --git a/fw/monitor.S b/fw/monitor.S index 9e32741..947cbc8 100644 --- a/fw/monitor.S +++ b/fw/monitor.S @@ -9,9 +9,7 @@ segment .text start=0xc0000 align=256 ; 256k flash monitor entry point _mon: jmp _mon - _echo: call 0xf000:(_getch & 0xffff) - mov cx,ax call 0xf000:(_putch & 0xffff) jmp _echo diff --git a/fw/reset.S b/fw/reset.S index d68e4dd..21756a7 100644 --- a/fw/reset.S +++ b/fw/reset.S @@ -20,16 +20,33 @@ GLOBAL UMCS, LMCS, PACS, MMCS, MPCS, MAXRAM, _restart, _putch, _getch, _version %include "amd80c188.inc" %include "platform.inc" -; uncomment for the full ram image -; org 0x0 - -segment .text start=0xc0000 align=256 +segment .stub start=0xc0000 align=256 ; 256k flash monitor stub _mon: jmp _mon +segment .text start=0xf0000 align=256 +; BIOS functions +_putch: +;; write the content of BL over serial, blocking + push ax + push dx + + _serial_putch bx + + pop dx + pop ax + retf + +_getch: + push dx + pop dx + retf + + + segment .data start=0xffc00 align=256 ; platform constants in ROM space ; useful to read/change parameters @@ -41,12 +58,11 @@ MMCS: dw 0x0000 ; not handled yet MPCS: dw MPCS_DEF MAXRAM: dw 0x80 ; in KB + segment .setup start=0xffd00 progbits ; main setup code - _setup: - ;; entry point - say_what 0xb007 + say_what 0xb007 ; jumped to the setup code ;; proper init @@ -79,39 +95,22 @@ _soc_passed: say_what 0xc0de _set_mem: - mov ax,0xf000 - mov ds,ax - mov dx,UMCS_REG - mov ax,[ds:UMCS] - out dx,ax - mov dx,LMCS_REG - mov ax,[ds:LMCS] - out dx,ax + mov ax, 0xf000 + mov ds, ax + mov dx, UMCS_REG + mov ax, [ds:UMCS] + out dx, ax + mov dx, LMCS_REG + mov ax, [ds:LMCS] + out dx, ax _set_pcs: - mov dx,PACS_REG - mov ax,[ds:PACS] - out dx,ax - mov dx,MPCS_REG - mov ax,[ds:MPCS] - out dx,ax - -;_set_sp: -; ;; ss = (((0x80 - 1) >> 6) << 12) -; ;; sp = (0x80 << 10) - 1 -; mov ax, [ds:MAXRAM] -; dec ax -; shr ax, 6 -; shl ax, 12 -; mov ss, ax -; -; mov ax, [ds:MAXRAM] -; shl ax, 10 -; dec ax -; mov sp, ax -; -; say_what 0x1337 - + mov dx, PACS_REG + mov ax, [ds:PACS] + out dx, ax + mov dx, MPCS_REG + mov ax, [ds:MPCS] + out dx, ax _test_setup_rom: mov si, 0xfd00 @@ -123,7 +122,7 @@ _test_setup_rom: inc si loop .loop .check: - mov ax,[ds:SETUPSUM16] + mov ax, [ds:SETUPSUM16] cmp ax, bx jne .rom_failure jmp .end @@ -131,8 +130,25 @@ _test_setup_rom: say_what 0x0bad jmp .rom_failure .end: - say_what bx - say_what 0x1337 + say_what bx ; checksum + say_what 0x1337 ; rom check passed + + +_set_sp: + ;; ss = (((0x80 - 1) >> 6) << 12) + ;; sp = (0x80 << 10) - 1 + mov ax, [ds:MAXRAM] + dec ax + shr ax, 6 + shl ax, 12 + mov ss, ax + say_what ss ; 0x1000 + + mov ax, [ds:MAXRAM] + shl ax, 10 + dec ax + mov sp, ax + say_what sp ; 0xffff _test_ram_words: @@ -140,15 +156,13 @@ _test_ram_words: mov es, ax mov si, 0x1234 mov cx, 0xabcd - say_what si - say_what cx -;; went past here - mov [es:si],cx - mov [es:si],cx - mov bx,0x0 - mov bx,[es:si] + say_what si ; ram test address + say_what cx ; ram test value to write + mov [es:si], cx + mov bx, 0x0 + mov bx, [es:si] + say_what bx ; ram test value readback cmp bx, cx - say_what bx jne .ram_failure jmp .end @@ -157,7 +171,7 @@ _test_ram_words: say_what 0x2bad jmp .halt .end: - say_what 0xcafe + say_what 0xcafe ; memory test passed _init_serial: @@ -166,7 +180,7 @@ _print_version: mov dx, UART_THR mov bx, _version .loop: - mov al,[ds:bx] + mov al, [ds:bx] cmp al, 0 jz .end out dx, al @@ -178,44 +192,12 @@ _print_version: _finish: _serial_puts _ok + sti jmp 0xc000:_mon ; text constants _ok: db "OK",0x0a,0x0 -;_bad: db "failed",0x0a,0x0 - - -; BIOS functions -_putch: -; push ax -; push dx -; -; _serial_putch cx -; -; pop dx -; pop ax -; retf -; -_getch: -; push dx -; -; mov dx, I8251_C -; mov al, 0x34 ; RTS, Reset Error Flag, RX -; out dx, al -; -;.wait_ready: in al, dx -; and al, 0x02 ; RXRDY -; jz .wait_ready -; mov al, 0x10 ; Reset Error Flag -; out dx, al -; -; mov dx,I8251_D -; in al, dx -; -; xor ah, ah -; pop dx -; retf segment .restart start=0xffff0 progbits diff --git a/fw/reset.map b/fw/reset.map index af01235..4f9e2d6 100644 --- a/fw/reset.map +++ b/fw/reset.map @@ -11,15 +11,16 @@ Output file: reset -- Sections (summary) --------------------------------------------------------- Vstart Start Stop Length Class Name - C0000 C0000 C0002 00000002 progbits .text + C0000 C0000 C0002 00000002 progbits .stub + F0000 F0000 F0016 00000016 progbits .text FFC00 FFC00 FFC0E 0000000E progbits .data - FFD00 FFD00 FFE32 00000132 progbits .setup + FFD00 FFD00 FFE53 00000153 progbits .setup FFFF0 FFFF0 FFFF6 00000006 progbits .restart FFFF8 FFFF8 100000 00000008 progbits .version -- Sections (detailed) -------------------------------------------------------- ----- Section .text ------------------------------------------------------------ +---- Section .stub ------------------------------------------------------------ class: progbits length: 2 @@ -30,6 +31,17 @@ vstart: C0000 valign: not defined vfollows: not defined +---- Section .text ------------------------------------------------------------ + +class: progbits +length: 16 +start: F0000 +align: 100 +follows: not defined +vstart: F0000 +valign: not defined +vfollows: not defined + ---- Section .data ------------------------------------------------------------ class: progbits @@ -44,7 +56,7 @@ vfollows: not defined ---- Section .setup ----------------------------------------------------------- class: progbits -length: 132 +length: 153 start: FFD00 align: not defined follows: not defined @@ -133,14 +145,21 @@ Value Name 00000078 BAUD_9600 ----- Section .text ------------------------------------------------------------ +---- Section .stub ------------------------------------------------------------ Real Virtual Name - C0000 C0000 _8250_init - C0000 C0000 _serial_putch - C0000 C0000 _serial_puts C0000 C0000 _mon +---- Section .text ------------------------------------------------------------ + +Real Virtual Name + F0000 F0000 _8250_init + F0000 F0000 _serial_putch + F0000 F0000 _serial_puts + F0000 F0000 _putch + F0005 F0005 ..@5.wait_empty + F0013 F0013 _getch + ---- Section .data ------------------------------------------------------------ Real Virtual Name @@ -165,21 +184,20 @@ Real Virtual Name FFD6C FFD6C _test_setup_rom.check FFD76 FFD76 _test_setup_rom.rom_failure FFD7F FFD7F _test_setup_rom.end - FFD8C FFD8C _test_ram_words - FFDBB FFDBB _test_ram_words.ram_failure - FFDBB FFDBB _test_ram_words.halt - FFDC4 FFDC4 _test_ram_words.end - FFDCB FFDCB _init_serial - FFDF7 FFDF7 _print_version - FFDFD FFDFD _print_version.loop - FFE08 FFE08 _print_version.end - FFE0C FFE0C _finish - FFE0F FFE0F ..@19.loop - FFE1B FFE1B ..@20.wait_empty - FFE29 FFE29 ..@19.end - FFE2E FFE2E _ok - FFE32 FFE32 _putch - FFE32 FFE32 _getch + FFD8C FFD8C _set_sp + FFDAF FFDAF _test_ram_words + FFDDB FFDDB _test_ram_words.ram_failure + FFDDB FFDDB _test_ram_words.halt + FFDE4 FFDE4 _test_ram_words.end + FFDEB FFDEB _init_serial + FFE17 FFE17 _print_version + FFE1D FFE1D _print_version.loop + FFE28 FFE28 _print_version.end + FFE2C FFE2C _finish + FFE2F FFE2F ..@23.loop + FFE3B FFE3B ..@24.wait_empty + FFE49 FFE49 ..@23.end + FFE4F FFE4F _ok ---- Section .restart --------------------------------------------------------- diff --git a/fw/reset.sym b/fw/reset.sym index 6e1437f..4bb2e7e 100644 --- a/fw/reset.sym +++ b/fw/reset.sym @@ -1,11 +1,11 @@ ;; autogenerated +_putch equ 0xF0000 +_getch equ 0xF0013 UMCS equ 0xFFC02 LMCS equ 0xFFC04 PACS equ 0xFFC06 MMCS equ 0xFFC08 MPCS equ 0xFFC0A MAXRAM equ 0xFFC0C -_putch equ 0xFFE32 -_getch equ 0xFFE32 _restart equ 0xFFFF0 _version equ 0xFFFF8 diff --git a/gal/development.md b/gal/README.md similarity index 100% rename from gal/development.md rename to gal/README.md diff --git a/gal/cpu_card_16v8.jed b/gal/cpu_card_16v8.jed index 5cb69d0..1f2d34a 100644 --- a/gal/cpu_card_16v8.jed +++ b/gal/cpu_card_16v8.jed @@ -15,7 +15,6 @@ Device: GAL16V8 *L0576 11111111111111110111111111111111 *L0608 11111111111101111111111111111111 *L0640 11111111111111111111111111110111 -*L0672 11111111111111111111011101111111 *L0768 11111111111111111111111111111111 *L0800 11111111111111111111111111011111 *L0832 11111111111111110111111111111111 @@ -26,7 +25,6 @@ Device: GAL16V8 *L1088 11111111111111111011111111111111 *L1120 11111111111101111111111111111111 *L1152 11111111111111111111111111110111 -*L1184 11111111111111111111111101111111 *L1280 11111111111111111111111111111111 *L1312 11111111111111111111111111011111 *L1344 11111111111111111011111111111111 @@ -35,13 +33,15 @@ Device: GAL16V8 *L1536 11111111111111111111111111111111 *L1568 01111111111111111111111111111111 *L1792 11111111111111111111111111111111 -*L1824 11111111110111011111111111111111 +*L1824 11111111111111111111111111011111 +*L1856 11111111011101111111111111111111 +*L1888 11111111111111111111011101111111 *L2048 11111111 *L2056 0110011101101100011101010110010101011111011100100011000000110001 *L2120 11111111 *L2128 1111111111111111111111111111111111111111111111111111111111111111 *L2192 1 *L2193 1 -*C84e2 +*C8512 * -20df +20bc diff --git a/gal/cpu_card_16v8.pld b/gal/cpu_card_16v8.pld index 84e4626..fa90e48 100644 --- a/gal/cpu_card_16v8.pld +++ b/gal/cpu_card_16v8.pld @@ -8,12 +8,12 @@ Clock RESOUT A3 WR RD MIO SERIAL CARDSEL DEN GND RESET = RESOUT -IOR = RESET + MIO + RD + DEN + CARDSEL * SERIAL +IOR = RESET + MIO + RD + DEN IOW = RESET + MIO + WR + DEN -SMEMR = RESET + /MIO + RD + DEN + CARDSEL +SMEMR = RESET + /MIO + RD + DEN SMEMW = RESET + /MIO + WR + DEN -BEN = IOR * IOW +BEN = RESET + RD * WR + CARDSEL * SERIAL CSS1 = SERIAL + A3 diff --git a/gal/cpu_card_22v10.jed b/gal/cpu_card_22v10.jed index 7d50cd2..39f7fb4 100644 --- a/gal/cpu_card_22v10.jed +++ b/gal/cpu_card_22v10.jed @@ -7,14 +7,14 @@ Device: GAL22V10 *G0 *QF5892 *L0440 11111111111111111111111111111111111111111111 -*L0484 11111111111111111111111101111111111111111111 -*L0528 11111111011111111111111111111111111111111111 +*L0484 11111111111111111111111111011111111111111111 +*L0528 11111111111111111111111101111111111111111111 +*L0572 11111111011111111111111111111111111111111111 *L0924 11111111111111111111111111111111111111111111 *L0968 11111111111111111111111111011111111111111111 *L1012 11111111111111111111011111111111111111111111 *L1056 11111111111111110111111111111111111111111111 *L1100 11111111111111111111111111111111011111111111 -*L1144 11111111111111111111111101110111111111111111 *L1496 11111111111111111111111111111111111111111111 *L1540 11111111111111111111111111011111111111111111 *L1584 11111111111111111111011111111111111111111111 @@ -25,7 +25,6 @@ Device: GAL22V10 *L2244 11111111111111111111101111111111111111111111 *L2288 11111111111111110111111111111111111111111111 *L2332 11111111111111111111111111111111011111111111 -*L2376 11111111111111111111111111110111111111111111 *L2904 11111111111111111111111111111111111111111111 *L2948 11111111111111111111111111011111111111111111 *L2992 11111111111111111111101111111111111111111111 @@ -35,12 +34,17 @@ Device: GAL22V10 *L3696 11101111111111111111111111111111111111111111 *L3740 11110111111111111111111111111111111111111111 *L4312 11111111111111111111111111111111111111111111 -*L4356 11111111110111011111111111111111111111111111 +*L4356 11111111111111111111111111011111111111111111 +*L4400 11111111111101110111111111111111111111111111 +*L4444 11111111111111111111111101110111111111111111 +*L4884 11111111111111111111111111111111111111111111 +*L4928 11111111111111111111111111111111111110111111 *L5368 11111111111111111111111111111111111111111111 -*L5412 11111111111111111111111101111111111111111111 -*L5456 11111111101111111111111111111111111111111111 -*L5808 01111111111111110011 +*L5412 11111111111111111111111111011111111111111111 +*L5456 11111111111111111111111101111111111111111111 +*L5500 11111111101111111111111111111111111111111111 +*L5808 01111111111111111111 *L5828 0110011101101100011101010110010101011111011100100011000000110001 -*Cb950 +*Cd053 * -722d +999b diff --git a/gal/cpu_card_22v10.pld b/gal/cpu_card_22v10.pld index 482d897..fc4a427 100644 --- a/gal/cpu_card_22v10.pld +++ b/gal/cpu_card_22v10.pld @@ -8,15 +8,17 @@ Clock RESOUT A3 WR RD MIO SERIAL CARDSEL DEN DCD NC GND RESET = /NRESET + RESOUT -IOR = RESET + MIO + RD + DEN + CARDSEL * SERIAL +IOR = RESET + MIO + RD + DEN IOW = RESET + MIO + WR + DEN -SMEMR = RESET + /MIO + RD + DEN + CARDSEL +SMEMR = RESET + /MIO + RD + DEN SMEMW = RESET + /MIO + WR + DEN -BEN = IOR * IOW +BEN = RESET + RD * WR + CARDSEL * SERIAL -CSS1 = SERIAL + A3 -CSS2 = SERIAL + /A3 +CSS1 = RESET + SERIAL + A3 +CSS2 = RESET + SERIAL + /A3 + +USBRST = /DCD DESCRIPTION