-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
minim8: A mini11 derived 68HC11 machine
- Loading branch information
1 parent
1a34add
commit ae5874e
Showing
20 changed files
with
2,601 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
|
||
CSRCS = devtty.c | ||
CSRCS += devices.c main.c | ||
|
||
ASRCS = m8.S crt0.S sci.S | ||
ASRCS += tricks.S commonmem.S | ||
|
||
CDSRCS = discard.c | ||
|
||
DSRCS = ../../dev/tinydisk.c ../../dev/tinysd.c | ||
DNSRCS = ../../dev/net/net_w5x00.c | ||
DISCARD_DSRCS = ../../dev/tinydisk_discard.c ../../dev/tinysd_discard.c | ||
|
||
COBJS = $(CSRCS:.c=$(BINEXT)) | ||
CDOBJS = $(CDSRCS:.c=$(BINEXT)) | ||
AOBJS = $(ASRCS:.S=$(BINEXT)) | ||
A68OBJS = $(patsubst ../../dev/68hc11/%.S,%.o, $(A68SRCS)) | ||
DOBJS = $(patsubst ../../dev/%.c,%.o, $(DSRCS)) | ||
DNOBJS = $(patsubst ../../dev/net/%.c,%.o, $(DNSRCS)) | ||
DAOBJS = $(DASRCS:.S=$(BINEXT)) | ||
DISCARD_DOBJS = $(patsubst ../../dev/%.c,%.o, $(DISCARD_DSRCS)) | ||
|
||
OBJS = $(COBJS) $(CDOBJS) $(AOBJS) $(A68OBJS) $(DOBJS) $(DAOBJS) $(DISCARD_DOBJS) $(DNOBJS) | ||
|
||
CROSS_CCOPTS += -I../../dev/ -I../../dev/68hc11/ -I../../dev/net/ | ||
|
||
all: $(OBJS) | ||
|
||
$(COBJS): %$(BINEXT): %.c | ||
$(CROSS_CC) $(CROSS_CCOPTS) $(CROSS_CC_SEG1) $< | ||
|
||
$(CDOBJS): %$(BINEXT): %.c | ||
$(CROSS_CC) $(CROSS_CCOPTS) $(CROSS_CC_SEGDISC) $< | ||
|
||
$(AOBJS): %$(BINEXT): %.S | ||
cpp -E $< >$*.s | ||
$(CROSS_AS) $(ASOPTS) $*.s -o $*.o | ||
|
||
$(DOBJS): %$(BINEXT): ../../dev/%.c | ||
$(CROSS_CC) $(CROSS_CCOPTS) $(CROSS_CC_SEG1) -c $< | ||
|
||
$(DNOBJS): %$(BINEXT): ../../dev/net/%.c | ||
$(CROSS_CC) $(CROSS_CCOPTS) $(CROSS_CC_SEG1) -c $< | ||
|
||
$(DAOBJS): %$(BINEXT): ../../dev/%.S | ||
$(CROSS_CC) $(CROSS_CCOPTS) $(CROSS_CC_SEG1) -c $< | ||
|
||
$(DISCARD_DOBJS): %$(BINEXT): ../../dev/%.c | ||
$(CROSS_CC) $(CROSS_CCOPTS) $(CROSS_CC_SEGDISC) -c $< | ||
|
||
clean: | ||
rm -f $(DOBJS) $(DAOBJS) $(OBJS) *.o *.s core *~ fuzix.bin fuzix.tmpmap | ||
rm -f loadsd.elf loadsd | ||
|
||
image: loadsd | ||
$(CROSS_LD) -M -T memory.x -relax -o ../../fuzix.elf crt0.o commonmem.o \ | ||
m8.o ../../start.o ../../version.o ../../cpu-68hc11/lowlevel-68hc11-flat.o \ | ||
tricks.o main.o discard.o ../../timer.o ../../kdata.o devices.o \ | ||
tinydisk.o tinydisk_discard.o tinysd.o tinysd_discard.o \ | ||
sci.o ../../syscall_net.o ../../network.o net_w5x00.o \ | ||
../../devio.o ../../filesys.o ../../process.o ../../inode.o ../../syscall_fs.o \ | ||
../../syscall_proc.o ../../syscall_other.o ../../mm.o ../../swap.o ../../bankfixed.o \ | ||
../../tty.o ../../devsys.o ../../syscall_fs2.o ../../syscall_fs3.o \ | ||
../../syscall_exec.o ../../syscall_exec16.o ../../blk512.o ../../memalloc_none.o \ | ||
../../usermem.o ../../cpu-68hc11/usermem_std-68hc11-flat.o devtty.o >../../fuzix.map | ||
$(CROSS_OBJCOPY) ../../fuzix.elf -O binary ../../fuzix.bin | ||
|
||
loadsd: loadsd.S loadsd.x | ||
$(CROSS_CC) -c loadsd.S | ||
$(CROSS_LD) -M -T loadsd.x -relax -o loadsd.elf loadsd.o >loadsd.map | ||
$(CROSS_OBJCOPY) loadsd.elf -O binary loadsd | ||
|
||
IMAGES = $(FUZIX_ROOT)/Images/$(TARGET) | ||
|
||
diskimage: loadsd | ||
# Make a blank disk image with partition | ||
dd if=$(FUZIX_ROOT)/Standalone/filesystem-src/parttab.40M of=$(IMAGES)/sd.img bs=40017920 conv=sync | ||
# Add the bootstrap loader | ||
dd if=loadsd of=$(IMAGES)/sd.img conv=notrunc | ||
# Add the file system | ||
dd if=$(IMAGES)/filesys.img of=$(IMAGES)/sd.img bs=512 seek=2048 conv=notrunc | ||
# Add the kernel | ||
dd if=../../fuzix.bin of=$(IMAGES)/sd.img bs=512 seek=1 conv=notrunc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
Fuzix for the Mini11/M8 derived from the Mini11 | ||
|
||
This is a 68HC11, 2K of ROM at F800-FFFF (fixed) and 512K of RAM with a latch | ||
allowing the lower and upper 32K to be banked individually. | ||
|
||
The normal setup is an SD card on the SPI and the onboard serial at 9600 baud | ||
with a 7.3728MHz clock. | ||
|
||
Memory mapping | ||
|
||
Kernel (bank 0) | ||
0x0000-0x00FF Direct page (kernel) | ||
0x0100-0x01FF Loader space for now (can be reclaimed later) | ||
0x0200-0xDFFF Kernel | ||
0xE200-0xEDFF Common | ||
0xEE00-0xEEFF SCI serial buffers (set in m8.S) | ||
0xEF00-0xEFFF Vectors and firmware glue | ||
0xF000-0xF03F Internal I/O (only I/O) | ||
0xF040-0xF1FF Internal common RAM (but only 256 bytes on 68HC11Ax) | ||
0xF200-0xF3FF Gap | ||
0xF400-0xF7FF External I/O (not yet used) | ||
0xF800-0xFFFF ROM / memory latch | ||
|
||
In user space | ||
|
||
0x0000-0x00FF Direct page (user) | ||
0x0100-0xDDFF User space | ||
0xDE00-0xDFFF Udata stash | ||
0xE000-0xEFFF Common | ||
0xF000-0xF03F Internal I/O | ||
0xF040-0xF1FF Internal RAM (unbankable) | ||
|
||
This requires a thunked 68HC11 model. We pack helper data in the common | ||
memory and as we have so little we copy common code into each bank to | ||
have the same effect. | ||
|
||
There is a fair bit of space in the kernel and common maps and some holes that | ||
could also be tidied up if needed. | ||
|
||
TODO | ||
|
||
Would it make sense to compact the DP usage and overlap the udata at | ||
0x0080 in the kernel map with kernel DP at 0x00 ? This would turn a lot | ||
of accesses into DP mode | ||
|
||
Optimize fork and other copiers. Several could be a chunk faster with | ||
more self modifying code and also by using the upper/lower split for the bits | ||
that can be accessed via both windows. | ||
|
||
Add SPI mux support and WizNet 5500 for internet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
; | ||
; Common space for stacks and user data | ||
; | ||
; exported symbols | ||
.globl ub | ||
.globl udata | ||
.globl kstack_top | ||
.globl istack_top | ||
.globl istack_switched_sp | ||
|
||
.section .data | ||
|
||
; | ||
; The stacks are a bit odd. The stack pointer points to the next byte | ||
; that will be written on a push so we want the top to be the last | ||
; byte inclusive, not exclusive as on most processors. | ||
; | ||
; .ds is in words for this assembler ???? | ||
; | ||
ub: ; first 512 bytes: starts with struct u_block, with the kernel stack working down from above | ||
udata: | ||
kstack_base: | ||
.ds 255,0 | ||
.byte 0 | ||
kstack_top: | ||
.byte 0 | ||
|
||
istack_base: | ||
.ds 126,0 | ||
.byte 0 | ||
istack_top: | ||
.byte 0 | ||
istack_switched_sp: .word 0 | ||
|
||
; | ||
; We have a tiny writable common area in the internal ram | ||
; | ||
.section .commondata | ||
|
||
.globl shared_sp | ||
.globl shared_syscall | ||
.globl shared_map | ||
.globl shared_mlatch | ||
.globl shared_argn | ||
.globl shared_argn1 | ||
.globl shared_argn2 | ||
.globl shared_argn3 | ||
.globl shared_retval | ||
.globl shared_error | ||
.globl shared_signal | ||
.globl shared_sigvec | ||
.globl shared_preempt | ||
.globl int_stack | ||
.globl syscall_stack | ||
.globl sci_stack | ||
|
||
shared_sp: | ||
.word 0 | ||
shared_syscall: | ||
.byte 0 | ||
shared_map: | ||
.byte 0 | ||
shared_mlatch: | ||
.byte 0 | ||
shared_argn: | ||
.word 0 | ||
shared_argn1: | ||
.word 0 | ||
shared_argn2: | ||
.word 0 | ||
shared_argn3: | ||
.word 0 | ||
shared_retval: | ||
.word 0 | ||
shared_error: | ||
.word 0 | ||
shared_signal: | ||
.byte 0 | ||
shared_sigvec: | ||
.word 0 | ||
shared_preempt: | ||
.byte 0 | ||
.ds 16 ; words | ||
int_stack: | ||
.byte 0 | ||
|
||
.ds 16 | ||
|
||
syscall_stack: | ||
.byte 0 | ||
|
||
.ds 16 ; Stack for serial interrupt | ||
sci_stack: | ||
.byte 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* Enable to make ^Z dump the inode table for debug */ | ||
#undef CONFIG_IDUMP | ||
/* Enable to make ^A drop back into the monitor */ | ||
#undef CONFIG_MONITOR | ||
/* Profil syscall support (not yet complete) */ | ||
#undef CONFIG_PROFIL | ||
/* Acct syscall support */ | ||
#undef CONFIG_ACCT | ||
/* Multiple processes in memory at once */ | ||
#define CONFIG_MULTI | ||
|
||
#define CONFIG_BANK_FIXED | ||
#define MAX_MAPS 7 | ||
#define MAP_SIZE 0xE000 | ||
#define CONFIG_BANKS 1 | ||
|
||
/* Permit large I/O requests to bypass cache and go direct to userspace */ | ||
#define CONFIG_LARGE_IO_DIRECT(x) 1 | ||
|
||
/* Arguments are tricky. The 680x binaries stack one way the 68HC11 the other. | ||
We deal with that in the syscall stubs and in crt0 */ | ||
#define CONFIG_CALL_R2L | ||
|
||
#define TICKSPERSEC 10 /* Ticks per second */ | ||
|
||
#define MAPBASE 0x0000 /* We map from 0 */ | ||
#define PROGBASE 0x0000 /* also data base */ | ||
#define PROGLOAD 0x0100 | ||
#define PROGTOP 0xDE00 /* udata stash at DE-DF */ | ||
|
||
#define SWAPDEV (swap_dev) /* A variable for dynamic, or a device major/minor */ | ||
extern uint16_t swap_dev; | ||
/* We swap a range including the internal I/O window. This is safe because we | ||
map the memory into the swap window not directly */ | ||
#define SWAP_SIZE 0x70 /* 56K in blocks (prog + udata) */ | ||
#define SWAPBASE 0x0000 /* start at the base of user mem */ | ||
#define SWAPTOP 0xE000 /* Swap out udata and program */ | ||
#define MAX_SWAPS 16 /* We will size if from the partition */ | ||
/* Swap will be set up when a suitably labelled partition is seen */ | ||
#define CONFIG_DYNAMIC_SWAP | ||
/* | ||
* When the kernel swaps something it needs to map the right page into | ||
* memory using map_for_swap and then turn the user address into a | ||
* physical address. We use the second 16K window. | ||
*/ | ||
#define swap_map(x) ((uint8_t *)(x)) | ||
|
||
#define CONFIG_TD_NUM 1 | ||
#define CONFIG_TD_SD | ||
#define TD_SD_NUM 1 | ||
|
||
#define BOOT_TTY 513 /* Set this to default device for stdio, stderr */ | ||
|
||
/* We need a tidier way to do this from the loader */ | ||
#define CMDLINE NULL /* Location of root dev name */ | ||
|
||
/* Device parameters */ | ||
#define NUM_DEV_TTY 1 | ||
#define TTYDEV BOOT_TTY /* Device used by kernel for messages, panics */ | ||
#define NBUFS 5 /* Number of block buffers */ | ||
#define NMOUNTS 2 /* Number of mounts at a time */ | ||
|
||
#define CONFIG_NET | ||
#define CONFIG_NET_WIZNET | ||
#define CONFIG_NET_W5500 | ||
|
||
#define plt_discard() | ||
#define plt_copyright() | ||
|
||
#define BOOTDEVICENAMES "hd#" | ||
|
||
/* 68HC11 specific stuff */ | ||
#define IOBASE 0xF000 | ||
|
||
#define DP_BASE 0x0000 | ||
#define DP_SIZE 0x00C0 /* C0-FF is for the kernel */ | ||
|
||
#define TTY_INIT_BAUD B9600 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
; | ||
; So we end up first in the image | ||
; | ||
|
||
.section .text | ||
|
||
entry: | ||
sei ; interrupts off | ||
lds #kstack_top ; C stack | ||
|
||
; Clear the udata (probably not needed as we did the move | ||
ldx #udata | ||
wipeud: | ||
clr 0,x | ||
inx | ||
cpx #istack_switched_sp | ||
bne wipeud | ||
|
||
ldx #__bss_start | ||
ldd #__bss_size | ||
bss_wipe: clr ,x | ||
inx | ||
subd #1 | ||
bne bss_wipe | ||
|
||
gogogo: | ||
jsr init_early | ||
jsr init_hardware | ||
jsr fuzix_main ; Should never return | ||
sei ; Spin | ||
stop: jmp stop | ||
|
||
|
||
; | ||
; Force our custom sections to be allocated so they appear in the | ||
; final binary. That was fun to find.... | ||
; | ||
.section .discard,"a" | ||
.section .common,"a" | ||
.section .commondata,"a" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include <kernel.h> | ||
#include <version.h> | ||
#include <kdata.h> | ||
#include <devsys.h> | ||
#include <tinydisk.h> | ||
#include <tty.h> | ||
#include <devtty.h> | ||
|
||
struct devsw dev_tab[] = /* The device driver switch table */ | ||
{ | ||
// minor open close read write ioctl | ||
// ----------------------------------------------------------------- | ||
/* 0: /dev/hd - block device interface */ | ||
{ td_open, no_close, td_read, td_write, td_ioctl}, | ||
/* 1: /dev/fd - Floppy disk block devices */ | ||
{ no_open, no_close, no_rdwr, no_rdwr, no_ioctl}, | ||
/* 2: /dev/tty TTY devices */ | ||
{ tty_open, tty_close, tty_read, tty_write, tty_ioctl }, | ||
/* 3: /dev/lpr Printer devices */ | ||
{ no_open, no_close, no_rdwr, no_rdwr, no_ioctl }, | ||
/* 4: /dev/mem etc System devices (one offs) */ | ||
{ no_open, no_close, sys_read, sys_write, sys_ioctl }, | ||
/* Pack to 7 with nxio if adding private devices and start at 8 */ | ||
}; | ||
|
||
bool validdev(uint16_t dev) | ||
{ | ||
/* This is a bit uglier than needed but the right hand side is | ||
a constant this way */ | ||
if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) - 1) | ||
return false; | ||
else | ||
return true; | ||
} | ||
|
Oops, something went wrong.