From b6a2f32fe12eb1c075b17b00bd997054caa1f7ff Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sat, 18 Aug 2018 16:18:05 +0100 Subject: [PATCH] sam: further debugging work We now get to the bootdev prompt with interrupts running. No keyboard input yet but that's next to investigate. Note that there's a stop after loading so if you are using simcoupe you need to hit shift-F10, ctrl-downarrow escape to set it loose (or set up debugger stuff first as needed) --- Kernel/platform-sam/atom.s | 16 +++++++++++----- Kernel/platform-sam/config.h | 2 +- Kernel/platform-sam/discard.c | 1 + Kernel/platform-sam/kernel.def | 4 ++-- Kernel/platform-sam/sam.s | 12 ++++++------ Kernel/platform-sam/tricks.s | 16 ++++++++-------- 6 files changed, 29 insertions(+), 22 deletions(-) diff --git a/Kernel/platform-sam/atom.s b/Kernel/platform-sam/atom.s index 853e8669..65e1be14 100644 --- a/Kernel/platform-sam/atom.s +++ b/Kernel/platform-sam/atom.s @@ -49,34 +49,39 @@ _devide_read_data: ; ld a, (blk_op + BLKPARAM_SWAP_PAGE) ; call map_for_swap atomlite_read: - call atomlite_reader + call atomlite_reader_fast jp map_kernel_low atomlite_read_user: + push ix ; HL is the user buffer, BC length + ld ix,#U_DATA__U_PAGE call user_mapping jr z,ide_r2 call atomlite_reader exx call user_mapping ide_r2: - call atomlite_reader + call atomlite_reader + pop ix jp map_kernel_low _devide_write_data: ld a, (_blk_op + BLKPARAM_IS_USER_OFFSET) ld hl, (_blk_op + BLKPARAM_ADDR_OFFSET) or a - jr z, atomlite_read + jr z, atomlite_write dec a - jr z, atomlite_read_user + jr z, atomlite_write_user ; SWAP to enable yet ; ld a, (blk_op + BLKPARAM_SWAP_PAGE) ; call map_for_swap atomlite_write: - call atomlite_writer + call atomlite_writer_fast jp map_kernel_low atomlite_write_user: + push ix ; HL is the user buffer, BC length + ld ix,#U_DATA__U_PAGE call user_mapping jr z,ide_w2 call atomlite_writer @@ -84,6 +89,7 @@ atomlite_write_user: call user_mapping ide_w2: call atomlite_writer + pop ix jp map_kernel_low ; ; This needs optimizing to use as we know C = 0 - but think about diff --git a/Kernel/platform-sam/config.h b/Kernel/platform-sam/config.h index 0d1bf7ae..af06b322 100644 --- a/Kernel/platform-sam/config.h +++ b/Kernel/platform-sam/config.h @@ -33,7 +33,7 @@ #define PROGBASE 0x0000 /* Base of user */ #define PROGLOAD 0x0100 /* Load and run here */ #define PROGTOP 0xFD00 /* Top of program, base of U_DATA stash */ -#define PROC_SIZE 64 /* Memory needed per process */ +#define PROC_SIZE 32 /* Mimumum memory needed per process */ #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-sam/discard.c b/Kernel/platform-sam/discard.c index 92b30397..b65e6749 100644 --- a/Kernel/platform-sam/discard.c +++ b/Kernel/platform-sam/discard.c @@ -3,6 +3,7 @@ #include #include #include +#include void map_init(void) { diff --git a/Kernel/platform-sam/kernel.def b/Kernel/platform-sam/kernel.def index 28a47e3f..403e1051 100644 --- a/Kernel/platform-sam/kernel.def +++ b/Kernel/platform-sam/kernel.def @@ -1,6 +1,6 @@ -; UZI mnemonics for memory addresses etc +; Fuzix mnemonics for memory addresses etc -U_DATA .equ 0x010 ; (this is struct u_data from kernel.h) +U_DATA .equ 0xF800 ; (this is struct u_data from kernel.h) U_DATA__TOTALSIZE .equ 0x200 ; 512 bytes. U_DATA_STASH .equ 0xFD00 ; FD00-FEFF diff --git a/Kernel/platform-sam/sam.s b/Kernel/platform-sam/sam.s index ef0db04e..489968d5 100644 --- a/Kernel/platform-sam/sam.s +++ b/Kernel/platform-sam/sam.s @@ -45,7 +45,7 @@ .include "kernel.def" .include "../kernel.def" -KERNEL_LOW .equ 0 ; 0/1 low 2/3 high +KERNEL_LOW .equ 0x20 ; 0/1 low 2/3 high (ROM off) KERNEL_HIGH .equ 2 VIDEO_LOW .equ 4 ; 4/5 video and font @@ -92,7 +92,7 @@ init_hardware: ; set system RAM size (FIXME - check for 512/1M) ld hl, #256 ld (_ramsize), hl - ld hl, #(256-64) ; 64K for kernel + ld hl, #(256-96) ; 64K for kernel, 32K for video/font/etc ld (_procmem), hl im 1 ; set CPU interrupt mode @@ -168,7 +168,6 @@ _program_vectors: ; And then the high stubs from the kernel inc hl - inc hl ld a,(hl) call map_page_low ld hl,#stubs_high @@ -247,17 +246,18 @@ _platform_doexec: ei jp (hl) nop -rst20: nop nop nop nop +rst20: ret + nop nop nop nop nop -rst28: nop nop nop +rst28: ret nop nop nop @@ -280,7 +280,7 @@ rst38: jp interrupt_high ; Interrupt handling stub nop nop nop - .ds 0x27 + .ds 0x26 nmi_handler: ; Should be at 0x66 retn diff --git a/Kernel/platform-sam/tricks.s b/Kernel/platform-sam/tricks.s index e32fa358..6da6a35f 100644 --- a/Kernel/platform-sam/tricks.s +++ b/Kernel/platform-sam/tricks.s @@ -41,8 +41,9 @@ _platform_switchout: push iy ld (U_DATA__U_SP), sp - ; Map the to - ld a,(U_DATA__U_PAGE2) + ; The U_DATA stash lives in th top of the user process. Map that + ; low with interrupts off so we can ldir between the two + ld a,(U_DATA__U_PAGE + 1) call map_page_low ld hl,#U_DATA ld de,#U_DATA_STASH-0x8000 @@ -61,7 +62,7 @@ _switchin: pop bc ; return address (we never do) pop de ; new process pointer - ld hl,#P_TAB__P_PAGE2_OFFSET + ld hl,#P_TAB__P_PAGE_OFFSET + 1 add hl,de ld a,(hl) ; our high page @@ -98,8 +99,8 @@ skip_copyback: ld P_TAB__P_STATUS_OFFSET(ix), #P_RUNNING ld a, P_TAB__P_PAGE_OFFSET(ix) ld (U_DATA__U_PAGE),a - ld a, P_TAB__P_PAGE2_OFFSET(ix) - ld (U_DATA__U_PAGE2),a + ld a, P_TAB__P_PAGE_OFFSET+1(ix) + ld (U_DATA__U_PAGE + 1),a ld hl,#0 ld (_runticks), hl ; Recover IX and IY, return value @@ -219,7 +220,7 @@ _dofork: ; We also have no sane stack for these so we use ix as the return. ; copy_process: - ld de,#P_TAB__P_PAGE2_OFFSET + ld de,#P_TAB__P_PAGE_OFFSET+1 add hl,de ld a,(U_DATA__U_PAGE) call map_page_low @@ -228,8 +229,7 @@ copy_process: jp _platform_copier_l cp1ret: inc hl - inc hl - ld a,(U_DATA__U_PAGE2) + ld a,(U_DATA__U_PAGE+1) call map_page_low call setup_platform_copier ld ix,#cp2ret -- 2.34.1