Compare commits

...

15 Commits

Author SHA1 Message Date
f9e2afcc5d archive notice 2025-10-07 15:45:13 -04:00
0845370c43 Adjusted code/boot/makefile to remove map.txt when make clean is run 2025-09-02 13:36:24 -04:00
347b6fa236 Merge pull request 'Migration to LWTOOLS' (#2) from gfaraday/chibi-pc09:main into main 2025-09-02 13:32:31 -04:00
677b3cb02d feat: modularized with lwtools build system 2025-08-31 14:42:14 -05:00
c67176e99a feat\!: migrate to LWTOOLS build system 2025-08-31 13:44:00 -05:00
9c668967d5 Merge pull request 'Merge memory test and serial output routines' (#1) from gfaraday/chibi-pc09:main into main
Reviewed-on: #1
2025-08-22 11:36:24 -04:00
5bd4c7ae15 Merge pull request 'Integrate port of ROBIT-2' (#2) from memtest into main
Reviewed-on: gfaraday/chibi-pc09#2
2025-08-20 18:39:21 -04:00
9a4f9fb6dd Merge branch 'memtest' of https://gitea.ambersplace.net/gfaraday/chibi-pc09 into memtest 2025-08-20 17:36:18 -05:00
3835594548 refactor(memtest): refactored the port of ROBIT-2 2025-08-20 17:30:35 -05:00
f6642860a5 feat: ported ROBIT-2 for MIKBUG to CHIBI PC-09 2025-08-20 17:30:35 -05:00
9dc46c16ee Merge pull request 'serial' (#1) from serial into main
Reviewed-on: gfaraday/chibi-pc09#1
2025-08-20 18:29:54 -04:00
d2c5118ba2 refactor(memtest): refactored the port of ROBIT-2 2024-12-11 06:49:44 -06:00
a642e05c2c feat: ported ROBIT-2 for MIKBUG to CHIBI PC-09 2024-12-11 06:35:11 -06:00
9edc255412 style: caps in comment fix 2024-12-11 05:30:33 -06:00
971dc1d719 feat: new serial functions 2024-12-07 10:30:15 -06:00
11 changed files with 215 additions and 77 deletions

View File

@@ -1,5 +1,13 @@
# chibi pc-09 # chibi pc-09
## Archived!
This repo has been archived, and the different parts have been migrated to other repos.
The PCB for prototype 1 has been moved to https://gitea.ambersplace.net/chibi/pc09-prototype-1
The firmware has been moved to https://gitea.ambersplace.net/chibi/chibi-firmware
![Gitea last commit](https://img.shields.io/gitea/last-commit/amberisvibin/chibi-pc09?gitea_url=https%3A%2F%2Fgitea.ambersplace.net&style=for-the-badge&label=Last%20Gitea%20Commit) ![Gitea last commit](https://img.shields.io/gitea/last-commit/amberisvibin/chibi-pc09?gitea_url=https%3A%2F%2Fgitea.ambersplace.net&style=for-the-badge&label=Last%20Gitea%20Commit)
![GitHub last commit](https://img.shields.io/github/last-commit/amberisvibin/chibi-pc09?style=for-the-badge&label=Last%20Github%20Commit) ![GitHub last commit](https://img.shields.io/github/last-commit/amberisvibin/chibi-pc09?style=for-the-badge&label=Last%20Github%20Commit)

5
code/boot/linkscript Normal file
View File

@@ -0,0 +1,5 @@
section RESET load 8000
section SERIAL
section MEMTEST
section VECTORS high 100000

View File

@@ -8,26 +8,45 @@
# Project Defaults & Folders # Project Defaults & Folders
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
TARGET := boot.bin TARGET := boot
TARGROM := $(TARGET).bin
SRCDIR := src/ SRCDIR := src/
MAINSRC := $(SRCDIR)boot.s BUILDDIR := build/
SRCS := $(wildcard $(SRCDIR)*.s) SRCS := $(wildcard $(SRCDIR)*.s)
OBJS := $(patsubst $(SRCDIR)%.s,$(BUILDDIR)%.o,$(SRCS))
INCS := $(wildcard $(SRCDIR)*.inc) INCS := $(wildcard $(SRCDIR)*.inc)
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Toolchain Definitions # Toolchain Definitions
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
AS := asm6809 AS := lwasm
LD := lwlink
FIX := mot2bin
ASFLAGS := -f obj
LDFLAGS := -f srec -m map.txt -s linkscript
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Rules and Phony Targets # Rules and Phony Targets
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
all: $(TARGET) all: $(TARGROM)
$(TARGET): $(SRCS) $(INCS) # Fix srec into flashable bin file
$(AS) -o $(TARGET) $(MAINSRC) $(TARGROM): $(TARGET).s19
$(FIX) -out $@ $<
# Link objects
$(TARGET).s19: $(OBJS)
$(LD) $(LDFLAGS) -o $@ $^
# Assemble objects
$(OBJS): $(BUILDDIR)%.o : $(SRCDIR)%.s
-@mkdir -p $(BUILDDIR)
$(AS) $(ASFLAGS) -o $@ $<
.IGNORE: clean
clean: clean:
rm -v $(TARGET) @echo 'Cleaning up intermediary files...'
@rm -rv $(TARGROM) $(TARGET).s19 map.txt $(BUILDDIR)

View File

@@ -1,55 +0,0 @@
; CHIBI PC-09 Prototype #1 Boot ROM -- Hardware Initialization and Reset Vecs
; Copyright (c) 2024 Amber Zeller, Gale Faraday
; Licensed under MIT
INCLUDE "src/hardware.inc"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Hardware Initialization Routines
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ORG ROM_BASE
RESET
; 8n1 Serial Enable DLAB
lda #(UARTF_LCR_WLS | UARTF_LCR_DLAB)
sta UART_LCR
; REVIEW: Potential endianness hiccough here
ldd #$0C00 ; Set divisor to 12 (9600 baud)
sta UART_DLM
stb UART_DLL
lda #(UARTF_LCR_WLS) ; 8n1 serial, disable DLAB
sta UART_LCR
lda #(UARTF_MCR_RTS) ; Enable Request-to-Send
sta UART_MCR
lda 'H ; send 'H'
sta UART_BUFR
WAIT
sync ; Wait for interrupts
nop
bra WAIT
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Interrupt and Reset Vectors
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ORG VECS_BASE
VECTORS
fdb $0000 ; Reserved
fdb $0000 ; SWI3
fdb $0000 ; SWI2
fdb $0000 ; FIRQ
fdb $0000 ; IRQ
fdb $0000 ; SWI
fdb $0000 ; NMI
fdb RESET ; Reset

View File

@@ -1,7 +1,9 @@
; CHIBI PC-09 Hardware Definitions ; CHIBI PC-09 Hardware Definitions
; Copyright (c) 2024 Amber Zeller, Gale Faraday ; Copyright (c) 2024-2025 Amber Zeller, Gale Faraday
; Licensed under MIT ; Licensed under MIT
; vim: ft=asm
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Hardware Base Addresses ;; Hardware Base Addresses
@@ -20,23 +22,23 @@ VECS_BASE EQU $FFF0 ; Vectors Base Address
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; When UARTF_LCR_DLAB = 0: ; When UARTF_LCR_DLAB = 0:
UART_BUFR EQU UART_BASE ; TX/RX Buffer (Read for RX, Write for TX) UART_BUFR EQU UART_BASE ; TX/RX Buffer (Read for RX, Write for TX)
UART_RBR EQU UART_BASE ; RX Buffer Register UART_RBR EQU UART_BASE ; RX Buffer Register
UART_THR EQU UART_BASE ; TX Holding Register UART_THR EQU UART_BASE ; TX Holding Register
UART_IER EQU UART_BASE + 1 ; Interrupt Enable Register UART_IER EQU UART_BASE+1 ; Interrupt Enable Register
; When UARTF_LCR_DLAB = 1: ; When UARTF_LCR_DLAB = 1:
UART_DLL EQU UART_BASE ; Divisor Latch (LSB) UART_DLL EQU UART_BASE ; Divisor Latch (LSB)
UART_DLM EQU UART_BASE + 1 ; Divisor Latch (MSB) UART_DLM EQU UART_BASE+1 ; Divisor Latch (MSB)
; Independent of DLAB: ; Independent of DLAB:
UART_IIR EQU UART_BASE + 2 ; Interrupt Ident Register (Upon Read) UART_IIR EQU UART_BASE+2 ; Interrupt Ident Register (Upon Read)
UART_FCR EQU UART_BASE + 2 ; FIFO Control Register (Upon Write) UART_FCR EQU UART_BASE+2 ; FIFO Control Register (Upon Write)
UART_LCR EQU UART_BASE + 3 ; Line Control Register UART_LCR EQU UART_BASE+3 ; Line Control Register
UART_MCR EQU UART_BASE + 4 ; MODEM Control Register UART_MCR EQU UART_BASE+4 ; MODEM Control Register
UART_LSR EQU UART_BASE + 5 ; Line Status Register UART_LSR EQU UART_BASE+5 ; Line Status Register
UART_MSR EQU UART_BASE + 6 ; MODEM Status Register UART_MSR EQU UART_BASE+6 ; MODEM Status Register
UART_SCR EQU UART_BASE + 7 ; Scratch Register (Not for control just spare RAM) UART_SCR EQU UART_BASE+7 ; Scratch Register (Not for control just spare RAM)
; UART Flags for Interrupt Enable Register: ; UART Flags for Interrupt Enable Register:
UARTF_IER_ERBFI EQU %10000000 ; Enable Received Data Available Interrupt UARTF_IER_ERBFI EQU %10000000 ; Enable Received Data Available Interrupt
@@ -93,4 +95,3 @@ UARTF_MSR_DSR EQU %00000100 ; Data Set Ready
UARTF_MSR_RI EQU %00000010 ; Ring Indicator UARTF_MSR_RI EQU %00000010 ; Ring Indicator
UARTF_MSR_DCD EQU %00000001 ; Data Carrier Detect UARTF_MSR_DCD EQU %00000001 ; Data Carrier Detect
; vim: ft=asm

42
code/boot/src/memtest.s Normal file
View File

@@ -0,0 +1,42 @@
; CHIBI PC-09 Prototype #1 Boot ROM -- Memory Testing Routines
; Copyright (c) 2024-2025 Amber Zeller, Gale Faraday
; Licensed under MIT
INCLUDE "hardware.inc"
INCLUDE "serial.inc"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Memory Testing Routines
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SECTION MEMTEST
; RAM testing routine. Ported to 6809 from 6800, based on source for ROBIT-2 for
; MIKBUG.
RAMTEST
ldx #SRAM_BASE
AGAIN@ ; Store 1 in memory
lda #1 ; Set [X] to 1
sta 0,x
cmpa 0,x ; If failed print out an error indicator
bne ERR@
NEXT@ ; Loop point for next address
asla ; Shift A and [X] left
asl 0,x
cmpa 0,x ; Compare A and [X]
bne ERR@
cmpa #$80 ; Only test up to $80
bne NEXT@ ; Loop if not $80
cmpx #$60FF ; Compare X to end of RAM
beq PASS@ ; Finish if we're at the end
leax 1,x ; Increment X
bra AGAIN@
ERR@ ; Write out error indicator
ldb #'X
jsr OUTCHAR
PASS@ ; Pass test
ldb #'P
jsr OUTCHAR
rts

7
code/boot/src/reset.inc Normal file
View File

@@ -0,0 +1,7 @@
; CHIBI PC-09 Prototype #1 -- Reset Handler Header
; Copyright (c) 2025 Amber Zeller, Gale Faraday
; Licensed under MIT
; vim: ft=asm
RESET IMPORT

35
code/boot/src/reset.s Normal file
View File

@@ -0,0 +1,35 @@
; CHIBI PC-09 Prototype #1 Boot ROM -- Reset Handler
; Copyright (c) 2024-2025 Amber Zeller, Gale Faraday
; Licensed under MIT
INCLUDE "hardware.inc"
INCLUDE "serial.inc"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Hardware Initialization Routines
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SECTION RESET
EXPORT RESET
RESET
; 8n1 Serial Enable DLAB
lda #UARTF_LCR_WLS | UARTF_LCR_DLAB
sta UART_LCR
; REVIEW: Potential endianness hiccough here
ldd #$0C00 ; Set divisor to 12 (9600 baud)
sta UART_DLM
stb UART_DLL
lda #(UARTF_LCR_WLS) ; 8n1 serial, disable DLAB
sta UART_LCR
lda #(UARTF_MCR_RTS) ; Enable Request-to-Send
sta UART_MCR
lda #'H ; send 'H'
sta UART_BUFR
WAIT@
sync ; Wait for interrupts
nop
bra WAIT@

8
code/boot/src/serial.inc Normal file
View File

@@ -0,0 +1,8 @@
; CHIBI PC-09 Prototype #1 -- Serial Driver Header
; Copyright (c) 2025 Amber Zeller, Gale Faraday
; Licensed under MIT
; vim: ft=asm
OUTCHAR IMPORT
OUTSTR IMPORT

45
code/boot/src/serial.s Normal file
View File

@@ -0,0 +1,45 @@
; CHIBI PC-09 Prototype #1 Boot ROM -- Serial Driver
; Copyright (c) 2024-2025 Amber Zeller, Gale Faraday
; Licensed under MIT
INCLUDE "hardware.inc"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Serial UART Driver
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SECTION SERIAL
EXPORT OUTCHAR
EXPORT OUTSTR
; Writes a char to the UART in non FIFO mode, preserves A.
; @param b: char to write
OUTCHAR
pshs a ; Preserve A
NOTREADY@
lda UART_LSR ; if LSR.THRE == 1 then write
anda UARTF_LSR_THRE
bne NOTREADY@ ; Loop if UART not ready yet
stb UART_BUFR ; Write char
puls a ; Restore A
rts
; Writes a null terminated string to the UART in non FIFO mode, clobbers A and
; B.
; @param x: null terminated string start address.
OUTSTR
ldb 0,x ; Get the next value from X
cmpb #$00 ; Make sure that we aren't at a terminator
beq END@
leax 1,x ; Increment X for our next char
NOTREADY@ ; Loop point for UART waiting
lda UART_LSR ; Wait for UART to be ready
anda UARTF_LSR_THRE
bne NOTREADY@
stb UART_BUFR ; Actually do our write
bra OUTSTR ; Reset for the next char
END@ ; Jump point for end of routine
rts

23
code/boot/src/vecs.s Normal file
View File

@@ -0,0 +1,23 @@
; CHIBI PC-09 Prototype #1 Boot ROM -- Interrupt and Reset Vectors
; Copyright (c) 2024-2025 Amber Zeller, Gale Faraday
; Licensed under MIT
INCLUDE "reset.inc"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Interrupt and Reset Vectors
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SECTION VECTORS
VECTORS
fdb $0000 ; Reserved
fdb $0000 ; SWI3
fdb $0000 ; SWI2
fdb $0000 ; FIRQ
fdb $0000 ; IRQ
fdb $0000 ; SWI
fdb $0000 ; NMI
fdb RESET ; Reset