From: Alan Cox Date: Sat, 31 Jan 2015 21:03:24 +0000 (+0000) Subject: socz80: boot to a shell prompt, achievement unlocked X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=bc634851c57664ad0e8d7aaf80ad441d935a6404;p=FUZIX.git socz80: boot to a shell prompt, achievement unlocked The tty code still needs prodding and debugging to get the interrupt handling fixed. It would also be better to use custom usermem functions that used the MMU page 17, but the old uzi180 style ones need modifying somewhat to handle bank boundaries. No swap (seriously you've got 2MB RAM), sd card as "floppy" device. --- diff --git a/Kernel/platform-socz80/README b/Kernel/platform-socz80/README index 2ee31070..e24da522 100644 --- a/Kernel/platform-socz80/README +++ b/Kernel/platform-socz80/README @@ -5,7 +5,7 @@ At this point in time it supports the following components - timer - ramdiscs - SD card -- two serial ports (USB virtual and native) +- two serial ports (USB virtual and native) (currently not quite working) It does not support - speed setting on the uarts with the newer FPGA firmware @@ -21,3 +21,13 @@ array in HL. This port is heavily based upon (and mostly consists of) code by Will Sowerbutts. + + +MMU +--- + +The MMU has 4K pages, but we use them in 16K blocks. It also supports both +read-only pages and an MMU bypass for copying memory. The read-only bit +isn't yet used but ought to be used to protect kernel space. The bypass mode +is used and any code using it *MUST* not use it from an IRQ or if it does +must save/restore it properly. diff --git a/Kernel/platform-socz80/config.h b/Kernel/platform-socz80/config.h index e7cac40a..c80e571a 100644 --- a/Kernel/platform-socz80/config.h +++ b/Kernel/platform-socz80/config.h @@ -18,7 +18,7 @@ #define TICKSPERSEC 100 /* Ticks per second */ #define PROGBASE 0x0000 #define PROGLOAD 0x0100 /* also data base */ -#define PROGTOP 0xF700 /* Top of program, base of U_DATA */ +#define PROGTOP 0xF800 /* Top of program, base of U_DATA */ #define BOOT_TTY (512 + 1)/* Set this to default device for stdio, stderr */ /* In this case, the default is the first TTY device */ diff --git a/Kernel/platform-socz80/fuzix.lnk b/Kernel/platform-socz80/fuzix.lnk index 50fa2df6..2244a9d5 100644 --- a/Kernel/platform-socz80/fuzix.lnk +++ b/Kernel/platform-socz80/fuzix.lnk @@ -1,7 +1,7 @@ -mwxuy -i fuzix.ihx -b _CODE=0x0088 --b _COMMONMEM=0xF700 +-b _COMMONMEM=0xF800 -b _DISCARD=0xE000 -l z80 platform-socz80/crt0.rel diff --git a/Kernel/platform-socz80/kernel.def b/Kernel/platform-socz80/kernel.def index e4860e30..bf28fa4f 100644 --- a/Kernel/platform-socz80/kernel.def +++ b/Kernel/platform-socz80/kernel.def @@ -1,6 +1,6 @@ ; UZI mnemonics for memory addresses etc -U_DATA .equ 0xf700 ; (this is struct u_data from kernel.h) +U_DATA .equ 0xf800 ; (this is struct u_data from kernel.h) U_DATA__TOTALSIZE .equ 0x300 ; 256+256+256 bytes. Z80_TYPE .equ 0 ; Actually a T80 diff --git a/Kernel/platform-socz80/tricks.s b/Kernel/platform-socz80/tricks.s index 7fc5e4b0..b7717e2e 100644 --- a/Kernel/platform-socz80/tricks.s +++ b/Kernel/platform-socz80/tricks.s @@ -1,4 +1,5 @@ ; 2013-12-21 William R Sowerbutts +; 2015-01-30 Alan Cox .module tricks @@ -24,7 +25,14 @@ .include "../kernel.def" .include "kernel.def" - .area _COMMONMEM +; +; These do not need to be in common memory as we don't have to +; pull udata remapping tricks on a 16K banked system. In the case of +; SocZ80 they *MUST NOT* be in common as they reload the MMU page for +; 0xF000. That takes multiple instructions and the code will vanish +; midstream if it is in common space! +; + .area _CODE2 ; Switchout switches out the current process, finds another that is READY, ; possibly the same process, and switches it in. When a process is @@ -193,11 +201,14 @@ _dofork: ; load into MMU ld a, #0x0F out (MMU_SELECT), a - ld a, d + ld a, h out (MMU_FRAMEHI), a - ld a, e + ld a, l out (MMU_FRAMELO), a + ld a,#'!' + call outchar + ; now the copy operation is complete we can get rid of the stuff ; _switchin will be expecting from our copy of the stack. pop bc @@ -267,9 +278,6 @@ bank_copy: ; save the parent mapping ld b, a - call outcharhex - ld a, c - call outcharhex ; store the old MMU mapping ld a, #0x0E out (MMU_SELECT), a @@ -290,8 +298,8 @@ bank_copy: ; child base page is in c parent in b ld d,#0 - ld l,d - ld c,a + ld l, d + ld a, c sla a rl d sla a @@ -308,6 +316,7 @@ bank_copy: rl d sla a rl d ; de now holds the src pointer + ld e, a ld b, #4 ; we're going to copy 16K copynextpage: @@ -329,6 +338,8 @@ copynextpage: push hl push de push bc + call outde + call outhl ld hl, #0xe000 ld de, #0xd000