Skip to content

Commit 3daec26

Browse files
committed
timer as a baud rate generator
1 parent 96dbffc commit 3daec26

14 files changed

+265
-74
lines changed

.gitignore

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
.DS_Store
22
fp-info-cache
3-
*.d
4-
fw/reset
53
*.swp
64
*.bak
5+
6+
fw/*.d
7+
fw/*.gen
8+
fw/*.o
9+
fw/*.glob
10+
fw/reset
11+
fw/monitor
12+
13+
gal/*.chp
14+
gal/*.fus
15+
gal/*.pin

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "gal/GALasm"]
2+
path = gal/GALasm
3+
url = https://github.com/daveho/GALasm

Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
all:
2+
make -C fw
3+
4+
.PHONY: all

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
# 80188 single board computer
1+
# 80188 single board modular computer
22

3-
v.0.0.7
3+
v.0.0.11
44

55
## References
66
* [Tandy 2000 BIOS](https://www.retrotronics.org/svn/t2kbios/)
7+
* AMD 80C186/80C188 Preliminary
8+
* Intel 80C186EA/80C188EA Microprocessor User's Manual

fw/80188.inc

-8
This file was deleted.

fw/Makefile

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
1-
sources = reset.S
1+
sources = reset.S monitor.S
22

3-
# final build
4-
fw.bin: reset
5-
cp $< $@
3+
# firmware
4+
fw.bin: $(sources:.S=)
5+
dd if=reset of=$@.gen bs=1024 skip=255 seek=255
6+
dd if=monitor of=$@.gen bs=1024 conv=notrunc
7+
mv $@.gen $@
8+
9+
# exports symbols as constants
10+
reset.sym: reset
11+
nasm -DNOMAP -f elf reset.S
12+
objdump -t reset.o | awk '($$2 == "g"){print $$5}' > reset.glob
13+
grep -f reset.glob reset.map | \
14+
awk 'BEGIN{print ";; autogenerated"}{print $$3,"equ","0x"$$1}' > $@
615

716
# assembly
817
%: %.S
918
nasm $< -o $@
1019

1120
clean:
12-
rm -f fw.bin reset $(sources:.S=.d)
21+
rm -f fw.bin $(sources:.S=.d) $(sources:.S=)
1322

1423
# deps
1524
%.d: %.S

fw/amd80c188.inc

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
;; AMD 80C188
2+
;; partially compatible with Intel 80188
3+
4+
RELREG_REG equ 0xfffe
5+
RELREG_DEF equ 0x00ff
6+
7+
UMCS_REG equ 0xffa0
8+
LMCS_REG equ 0xffa2
9+
PACS_REG equ 0xffa4
10+
MMCS_REG equ 0xffa6
11+
MPCS_REG equ 0xffa8
12+
13+
UMCS_256K_W3 equ 0xc03f
14+
LMCS_128K_W3 equ 0x1fff
15+
16+
PACS_0x00000_W3 equ 0x3f
17+
MMCS_DEF equ 0x21ff
18+
MPCS_DEF equ 0xc0bf
19+
20+
TIMER0_MAXCNTA equ 0xff52
21+
TIMER0_CON equ 0xff56
22+
23+
TIMER1_MAXCNTA equ 0xff5a
24+
TIMER1_CON equ 0xff5e

fw/fw.bin

0 Bytes
Binary file not shown.

fw/monitor.S

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
CPU 186
2+
USE16
3+
4+
%include "amd80c188.inc"
5+
%include "platform.inc"
6+
%include "reset.sym"
7+
8+
segment .bss
9+
10+
segment .text start=0xc0000 align=256
11+
; 256k flash monitor entry point
12+
_mon:
13+
14+
say_what 0xc001
15+
say_what 0x5afe
16+
say_what 0xcafe
17+
18+
;; and now just loop here
19+
.nevermind:
20+
jmp .nevermind
21+
22+

fw/platform.inc

+26-27
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,46 @@
1-
UMCS_256K_W3 equ 0xc03f
2-
LMCS_128K_W3 equ 0x1fff
3-
4-
; base address will be be 0x0000
5-
; pcs0 0x0000
6-
; pcs1 0x0080
7-
; pcs2 0x0100
8-
; ...
9-
; hex(int('0000' + bin(0x00000)[2:].zfill(20)[4:10] + '111' + bin(0x7)[2:], 2))
10-
11-
;PACS_0x00000_W3_TANDY equ 0x003e
12-
PACS_0x00000_W3 equ 0x3f
13-
;MPCS_TANDY equ 0xc0be
14-
MMCS_DEF equ 0x21ff
15-
MPCS_DEF equ 0xc0bf
1+
LMCS_STACK equ 0x1fff
162

173
I8251_D equ 0x0000
184
I8251_C equ 0x0002
19-
I8251_8n1_1x equ 0x4d ; 01 00 11 01
20-
I8251_8e2_1x equ 0xfd
5+
I8251_8n1_1x equ 0x4d ; 01 00 11 01
6+
I8251_8n1_16x equ 0x4e ; 01 00 11 10
7+
8+
BAUD_9600_16x equ 13
219

2210
%macro say_what 1
2311
;; destroys AX, DX
24-
mov dx, 0x220
25-
mov ax, %1
26-
out dx, ax
12+
mov dx, 0x220
13+
mov ax, %1
14+
out dx, ax
15+
16+
%endmacro
2717

18+
%macro _baud_timer 1
19+
;; baud timer init
20+
;; destroys AX, DX
21+
mov ax, %1
22+
mov dx, TIMER0_MAXCNTA
23+
out dx, ax
24+
mov ax, 0xc001 ; 1100000000000001
25+
mov dx, TIMER0_CON
26+
out dx, ax
2827
%endmacro
2928

3029
%macro _serial_init 1
3130
;; serial init
3231
;; destroys AX, DX
33-
mov dx,I8251_C
34-
mov al,0xff ; dummy
35-
out dx,al
32+
mov dx, I8251_C
33+
mov al, 0xff ; dummy
34+
out dx, al
3635
nop
3736
nop
38-
mov al,0x40 ; reset
39-
out dx,al
37+
mov al, 0x40 ; reset
38+
out dx, al
4039
nop
4140
nop
4241

43-
mov al, %1; mode
44-
out dx,al
42+
mov al, %1 ; mode
43+
out dx, al
4544
%endmacro
4645

4746
%macro _serial_put_ch 1

fw/reset.S

+26-30
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,35 @@
11
CPU 186
22
USE16
3+
GLOBAL _restart
34

4-
%include "80188.inc"
5+
%ifndef NOMAP
6+
[map all reset.map]
7+
%endif
8+
9+
%include "amd80c188.inc"
510
%include "platform.inc"
611

712
; uncomment for the full ram image
813
; org 0x0
914

10-
11-
segment .bss
12-
1315
segment .text start=0xc0000 align=256
14-
; 256k flash monitor
15-
mon:
16-
17-
say_what 0xc001
18-
say_what 0x5afe
19-
say_what 0xcafe
20-
;; and now just loop here
21-
.nevermind:
22-
jmp .nevermind
23-
24-
16+
; 256k flash monitor stub
17+
_mon: jmp _mon
18+
2519

2620
segment .data start=0xffc00 align=256
27-
; platform constants in BIOS space
21+
; platform constants in ROM space
2822
; useful to read/change parameters
2923
UMCS: dw UMCS_256K_W3
3024
LMCS: dw LMCS_128K_W3
3125
PACS: dw PACS_0x00000_W3
32-
MMCS: dw MMCS_DEF
26+
MMCS: dw 0x0000 ; not handled yet
3327
MPCS: dw MPCS_DEF
3428

3529
segment .setup start=0xffe00 progbits
3630
; main setup code
3731

38-
setup:
32+
_setup:
3933
;; entry point
4034
say_what 0xb007
4135

@@ -89,16 +83,19 @@ _set_pcs:
8983
mov ax,[ds:MPCS]
9084
out dx,ax
9185

92-
;_set_sp:
93-
; mov ax, 0x0
94-
; mov ss, ax
95-
; mov sp, 0x1000
86+
_set_sp:
87+
mov ax, 0x0
88+
mov ss, ax
89+
mov sp, LMCS_STACK
9690

97-
_test_serial:
98-
_serial_init I8251_8n1_1x
91+
_init_serial:
92+
_baud_timer BAUD_9600_16x
93+
_serial_init I8251_8n1_16x
9994
nop
10095
nop
10196

97+
98+
_test_serial:
10299
_serial_put_ch 0xaa
103100

104101
mov cx,0xff
@@ -110,18 +107,17 @@ _finish:
110107
say_what 0x7331
111108

112109
jmp _test_serial
113-
;jmp 0xc000:mon
110+
;jmp 0xc000:_mon
114111

115112

116113
segment .restart start=0xffff0 progbits
117114
; 80188 entrypoint
118115
; CS = 0xffff
119116
; we have only 15 bytes here, so just
120117
; setting the cs and doing a "long jump"
121-
cli
122-
jmp 0xffe0:0
118+
_restart: cli
119+
jmp 0xffe0:0
123120
124121
; padding and version
125-
db 0x0,0x0
126-
db " V0.0.10"
127-
122+
db 0x0,0x0
123+
db " V0.0.11"

0 commit comments

Comments
 (0)