sam: further debugging work
authorAlan Cox <alan@linux.intel.com>
Sat, 18 Aug 2018 15:18:05 +0000 (16:18 +0100)
committerAlan Cox <alan@linux.intel.com>
Sat, 18 Aug 2018 15:18:05 +0000 (16:18 +0100)
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
Kernel/platform-sam/config.h
Kernel/platform-sam/discard.c
Kernel/platform-sam/kernel.def
Kernel/platform-sam/sam.s
Kernel/platform-sam/tricks.s

index 853e866..65e1be1 100644 (file)
@@ -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
index 0d1bf7a..af06b32 100644 (file)
@@ -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 */
index 92b3039..b65e674 100644 (file)
@@ -3,6 +3,7 @@
 #include <kdata.h>
 #include <printf.h>
 #include <devtty.h>
+#include <devide.h>
 
 void map_init(void)
 {
index 28a47e3..403e105 100644 (file)
@@ -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
index ef0db04..489968d 100644 (file)
@@ -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
 
index e32fa35..6da6a35 100644 (file)
@@ -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