Skip to content

Commit

Permalink
cleanup and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
yottatsa committed Aug 4, 2022
1 parent 6448c4a commit 220ecc5
Show file tree
Hide file tree
Showing 14 changed files with 205 additions and 139 deletions.
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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/)
Expand All @@ -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
2 changes: 1 addition & 1 deletion fw/8250.S
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions fw/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
sources = reset.S monitor.S
targets = fw.bin debug.txt

all: $(targets)

# firmware
fw.bin: $(sources:.S=)
Expand All @@ -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
37 changes: 37 additions & 0 deletions fw/debug.txt
Original file line number Diff line number Diff line change
@@ -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:
Binary file modified fw/fw.bin
Binary file not shown.
2 changes: 0 additions & 2 deletions fw/monitor.S
Original file line number Diff line number Diff line change
Expand Up @@ -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
150 changes: 66 additions & 84 deletions fw/reset.S
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -123,32 +122,47 @@ _test_setup_rom:
inc si
loop .loop
.check:
mov ax,[ds:SETUPSUM16]
mov ax, [ds:SETUPSUM16]
cmp ax, bx
jne .rom_failure
jmp .end
.rom_failure:
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:
mov ax, 0x0
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

Expand All @@ -157,7 +171,7 @@ _test_ram_words:
say_what 0x2bad
jmp .halt
.end:
say_what 0xcafe
say_what 0xcafe ; memory test passed


_init_serial:
Expand All @@ -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
Expand All @@ -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
Expand Down
Loading

0 comments on commit 220ecc5

Please sign in to comment.