From: Will Sowerbutts Date: Sat, 27 Dec 2014 11:22:22 +0000 (+0000) Subject: Kernel: Tidy up p112 and n8vem-mark4 targets, remove redundant code and merge memory... X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=261e0ea2192714df6933578b8773c6cb13bca78d;p=FUZIX.git Kernel: Tidy up p112 and n8vem-mark4 targets, remove redundant code and merge memory mapping functions into common Z180 code. --- diff --git a/Kernel/cpu-z180/z180.s b/Kernel/cpu-z180/z180.s index 10bbd20d..48cc4fef 100644 --- a/Kernel/cpu-z180/z180.s +++ b/Kernel/cpu-z180/z180.s @@ -26,6 +26,9 @@ .globl _switchout .globl _dofork .globl map_kernel + .globl map_process_always + .globl map_save + .globl map_restore .globl unix_syscall_entry .globl null_handler .globl nmi_handler @@ -720,3 +723,53 @@ switchinfail: ld hl, #badswitchmsg call outstring jp _trap_monitor + +map_kernel: ; map the kernel into the low 60K, leaves common memory unchanged + push af +.if DEBUGBANK + ld a, #'K' + call outchar +.endif + ld a, #(OS_BANK + FIRST_RAM_BANK) + out0 (MMU_BBR), a + pop af + ret + +map_process_always: ; map the process into the low 60K based on current common mem (which is unchanged) + push af +.if DEBUGBANK + ld a, #'=' + call outchar +.endif + ld a, (U_DATA__U_PAGE) + out0 (MMU_BBR), a +.if DEBUGBANK + call outcharhex +.endif + ; MMU_CBR is left unchanged + pop af + ret + +map_save: ; save the current process/kernel mapping + push af + in0 a, (MMU_BBR) + ld (map_store), a + pop af + ret + +map_restore: ; restore the saved process/kernel mapping + push af +.if DEBUGBANK + ld a, #'-' + call outchar +.endif + ld a, (map_store) + out0 (MMU_BBR), a +.if DEBUGBANK + call outcharhex +.endif + pop af + ret + +map_store: ; storage for map_save/map_restore + .db 0 diff --git a/Kernel/platform-n8vem-mark4/README b/Kernel/platform-n8vem-mark4/README index 914c5a6f..50248e13 100644 --- a/Kernel/platform-n8vem-mark4/README +++ b/Kernel/platform-n8vem-mark4/README @@ -1,4 +1,4 @@ -This is UZI for the N8VEM Mark IV SBC +This is Fuzix for the N8VEM Mark IV SBC By Will Sowerbutts Assumes an N8VEM Mark IV SBC fitted with 512KB RAM, with the RS232 port as diff --git a/Kernel/platform-n8vem-mark4/cpmload.s b/Kernel/platform-n8vem-mark4/cpmload.s deleted file mode 100644 index 7d1dfa28..00000000 --- a/Kernel/platform-n8vem-mark4/cpmload.s +++ /dev/null @@ -1,36 +0,0 @@ -.module cpmload -.area _LOADER (ABS) - - ; CP/M will load us at 0x0100 - ; We want to relocate our payload (the kernel) and jump into it. - ; We put a small stub at the very bottom of memory, copy the kernel into - ; place above us, then jump into it. - - .org 0x100 - di - ; copy ourselves to the very bottom of memory -- 0x00 upwards - ld de, #0 - ld hl, #(doload) ; start of loader code - ld bc, #(endloader-doload) ; length of our loader - ldir ; copy copy copy! - ld hl, (load_address) - ld sp, hl ; stash copy of entry vector in SP for now - ex de, hl ; load_address to de - ld hl, #payload_start - ld bc, (load_length) - jp 0 ; jump and perform copy in low memory - - ; this code gets copied to .org 0 -doload: - ldir ; copy image into correct place - ld hl, #0 - add hl, sp ; recover entry vector - jp (hl) ; run image -endloader: ; end of code to copy - - ; the data is in a trailer, with a 6-byte header: -load_address: - .ds 2 -load_length: - .ds 2 -payload_start: diff --git a/Kernel/platform-n8vem-mark4/mark4.s b/Kernel/platform-n8vem-mark4/mark4.s index 8d9bdcc8..f10b51ef 100644 --- a/Kernel/platform-n8vem-mark4/mark4.s +++ b/Kernel/platform-n8vem-mark4/mark4.s @@ -12,12 +12,6 @@ .globl platform_interrupt_all .globl _trap_monitor - .globl map_kernel - .globl map_process_always - .globl map_save - .globl map_restore - ;.globl map_process_only - ; imported symbols .globl z180_init_hardware .globl z180_init_early @@ -84,75 +78,6 @@ ocloop: in0 a, (ASCI_STAT0) platform_interrupt_all: ret -map_kernel: ; map the kernel into the low 60K, leaves common memory unchanged - push af -.if DEBUGBANK - ld a, #'K' - call outchar -.endif - ld a, #(OS_BANK + FIRST_RAM_BANK) - out0 (MMU_BBR), a - pop af - ret - -; this "map_process" business makes no sense on mark4 since we'd switch stacks -; and the RET would thus lose its return address. oh damn. I suppose we could -; pop the stack address into hl, then jp (hl) or whatever. let's try and get by -; without it. -; -; map_process: ; if HL=0 call map_kernel, else map the full 64K in bank pointed to by HL -; ld a, h -; or l -; jr z, map_kernel -; ld a, (hl) -; out0 (MMU_BBR), a -; out0 (MMU_CBR), a -; ret - -; map_process_only: ; as map_process, but does not modify common memory -; ld a, h -; or l -; jr z, map_kernel -; ld a, (hl) -; out0 (MMU_BBR), a -; ret - -map_process_always: ; map the process into the low 60K based on current common mem (which is unchanged) - push af -.if DEBUGBANK - ld a, #'=' - call outchar -.endif - ld a, (U_DATA__U_PAGE) - out0 (MMU_BBR), a -.if DEBUGBANK - call outcharhex -.endif - ; MMU_CBR is left unchanged - pop af - ret - -map_save: ; save the current process/kernel mapping - push af - in0 a, (MMU_BBR) - ld (map_store), a - pop af - ret - -map_restore: ; restore the saved process/kernel mapping - push af -.if DEBUGBANK - ld a, #'-' - call outchar -.endif - ld a, (map_store) - out0 (MMU_BBR), a -.if DEBUGBANK - call outcharhex -.endif - pop af - ret - _trap_monitor: di call outnewline @@ -173,6 +98,3 @@ _trap_monitor: call outnewline halt jr _trap_monitor - -map_store: ; storage for map_save/map_restore - .db 0 diff --git a/Kernel/platform-p112/README b/Kernel/platform-p112/README index 2b4b9109..e38cf047 100644 --- a/Kernel/platform-p112/README +++ b/Kernel/platform-p112/README @@ -1,4 +1,4 @@ -This is UZI for the DX-Designs P112 +This is Fuzix for the DX-Designs P112 By Will Sowerbutts Assumes a P112 fitted with 1024KB RAM and G-IDE diff --git a/Kernel/platform-p112/main.c b/Kernel/platform-p112/main.c index baf4da28..361457ea 100644 --- a/Kernel/platform-p112/main.c +++ b/Kernel/platform-p112/main.c @@ -24,7 +24,7 @@ void pagemap_init(void) { int i; - /* N8VEM SBC Mark IV has RAM in the top 512K of physical memory. + /* P112 has RAM across the full physical 1MB address space * First 64K is used by the kernel. * Each process gets the full 64K for now. * Page size is 4KB. */ @@ -36,7 +36,7 @@ void pagemap_init(void) void platform_idle(void) { /* Let's go to sleep while we wait for something to interrupt us; - * Makes the Mark IV's run LED go red, which amuses me greatly. */ + * sadly no fun LED to change colour */ __asm halt __endasm; diff --git a/Kernel/platform-p112/p112.s b/Kernel/platform-p112/p112.s index 0f9579c7..3af2fe6c 100644 --- a/Kernel/platform-p112/p112.s +++ b/Kernel/platform-p112/p112.s @@ -13,12 +13,6 @@ .globl platform_interrupt_all .globl _trap_monitor - .globl map_kernel - .globl map_process_always - .globl map_save - .globl map_restore - ;.globl map_process_only - ; imported symbols .globl z180_init_hardware .globl z180_init_early @@ -108,75 +102,6 @@ ocloop: in0 a, (ESCC_CTRL_A) platform_interrupt_all: ret -map_kernel: ; map the kernel into the low 60K, leaves common memory unchanged - push af -.if DEBUGBANK - ld a, #'K' - call outchar -.endif - ld a, #(OS_BANK + FIRST_RAM_BANK) - out0 (MMU_BBR), a - pop af - ret - -; this "map_process" business makes no sense on mark4 since we'd switch stacks -; and the RET would thus lose its return address. oh damn. I suppose we could -; pop the stack address into hl, then jp (hl) or whatever. let's try and get by -; without it. -; -; map_process: ; if HL=0 call map_kernel, else map the full 64K in bank pointed to by HL -; ld a, h -; or l -; jr z, map_kernel -; ld a, (hl) -; out0 (MMU_BBR), a -; out0 (MMU_CBR), a -; ret - -; map_process_only: ; as map_process, but does not modify common memory -; ld a, h -; or l -; jr z, map_kernel -; ld a, (hl) -; out0 (MMU_BBR), a -; ret - -map_process_always: ; map the process into the low 60K based on current common mem (which is unchanged) - push af -.if DEBUGBANK - ld a, #'=' - call outchar -.endif - ld a, (U_DATA__U_PAGE) - out0 (MMU_BBR), a -.if DEBUGBANK - call outcharhex -.endif - ; MMU_CBR is left unchanged - pop af - ret - -map_save: ; save the current process/kernel mapping - push af - in0 a, (MMU_BBR) - ld (map_store), a - pop af - ret - -map_restore: ; restore the saved process/kernel mapping - push af -.if DEBUGBANK - ld a, #'-' - call outchar -.endif - ld a, (map_store) - out0 (MMU_BBR), a -.if DEBUGBANK - call outcharhex -.endif - pop af - ret - _trap_monitor: di call outnewline @@ -197,6 +122,3 @@ _trap_monitor: call outnewline halt jr _trap_monitor - -map_store: ; storage for map_save/map_restore - .db 0