sam: Further fixing and cleanups
authorAlan Cox <alan@linux.intel.com>
Sat, 25 Aug 2018 14:16:30 +0000 (15:16 +0100)
committerAlan Cox <alan@linux.intel.com>
Sat, 25 Aug 2018 14:16:30 +0000 (15:16 +0100)
We now start running init but blow up weirdly when opening the inittab

Kernel/platform-sam/README
Kernel/platform-sam/sam.s

index ab6effb..1b956e2 100644 (file)
@@ -11,7 +11,8 @@ Video
 
 0-5FFF         Frame buffer (mode 3)   bank 4/5
 6000-6FFF      Font
-7000-7FFF      Free
+7000-7EFF      Free
+7F00-7FFF      Copy of high page in case want video high for some cases
 8000-FFFF      Kernel in bank 0/1
 
 User Space
@@ -22,9 +23,6 @@ User Space
 FD00-FEFF      UDATA stash
 FF00-FFFF      Thunking code
 
-Probably will move the thunking code mostly into FFxx somewhere so we
-can do CP/M emulation still
-
 Extmem support would require extra work and separate high/low pools for
 the bank allocator
 
@@ -35,56 +33,44 @@ User Copies
 
 Forking
 
-0000-00FF      Parent low stubs
-0100-7FFF      Parent low bank
-8000-80FF      Child low stubs (not yet set)
-8100-FFFF      Child low bank
-
-then
-
-0000-7EFF      Parent high bank
-7F00-7FFF      Parent high stubs
-8000-FEFF      Child high bank
-FF00-FFFF      Child stubs (not yet set)
+Need to look at the TRS80m1 hack which might actually be faster than ldir
+and all the bank juggling tricks
 
 Stub code is in the low parts of the low banks and the top of the high banks
 so we have two copier routines one for each half.
 
+DONE   -       Move fonts to video bank after frame buffer
+       -       Floppy driver (at least for read)
+DONE   -       Get to init (but not much further)
+IP     -       Debug all the new banking code and stubs
+       -       Atom IDE driver
+DONE   -       Atom-lite IDE driver
+DONE   -       Look at how to preserve high colour bits
 
-To Do:
-
--      Keyboard map
--      Interrupt logic
--      Boot loader
-
-Then once we can get to the point of being able to see and type
-
--      Move fonts to video bank after frame buffer
--      Floppy driver (at least for read)
--      Get to init
--      Debug all the new banking code and stubs
--      Atom and Atom-lite IDE driver
--      Look at how to preserve high colour bits
+       -       RTC driver
+       -       Serial driver
+       -       Mouse/Joystick/Input
 
--      RTC driver
--      Serial driver
--      Mouse/Joystick/Input
+       -       Mode setting/graphics mode support
+       -       Video ioctls
+       -       UDG ioctls
+       -       Is there any way to do video mapping into user process sanely
+               (probably not)
 
--      Mode setting/graphics mode support
--      Video ioctls
--      UDG ioctls
--      Is there any way to do video mapping into user process sanely
-       (probably not)
+       -       Sound
 
--      Sound
+IP     -       MegaRAM (as RAMdisc)
 
--      MegaRAM
+       -       Maybe look at a 16K boundary aware allocator to get better
+               memory packing - but it's really hairy.
 
--      Maybe look at a 16K boundary aware allocator to get better memory
-       packing - but it's really hairy.
+       -       Less interrupt masking (but the banking logic makes it really
+               foul especially as we don't have proper IM2 support)
 
--      Less interrupt masking (but the banking logic makes it really foul
-       especially as we don't have proper IM2 support)
+       -       Maybe look at the modern add ons (SD card, network etc)
 
--      Maybe look at the modern add ons (SD card, network etc)
+Boot from the created floppy .mgt file
+Disable atomlite boot rom (need to fix that issue)
+Filesystem on Atomlite. If using simcoupe dd it 534 bytes into the image
+Select device 0 for boot to get atomlite (you can do partitions)
 
index dc55b94..f60bcab 100644 (file)
@@ -361,6 +361,9 @@ interrupt_high:
            ld (istack_switched_sp),sp
            ld sp,#istack_top
            call interrupt_handler
+           ; Restore stack pointer to user. This leaves us with an invalid
+           ; stack pointer if called from user but interrupts are off anyway
+           ld sp,(istack_switched_sp)
            ; On return HL = signal vector E= signal (if any) A = page for
            ; high
            or a
@@ -371,8 +374,7 @@ interrupt_high:
            and #0x60
            or d
            out (251),a
-           ; stack is invalid again now
-           ld sp,(istack_switched_sp)
+           ; User stack is now valid
            ; back on user stack
            xor a
            cp e
@@ -397,16 +399,19 @@ syscall_high:
            push ix
            ld ix,#0
            add ix,sp
+           push de             ; the syscall if must preserve de for now
+                               ; needs fixing when we change the syscall
+                               ; API for Z80 to something less sucky
            ld a,4(ix)
-           ld b,6(ix)
-           ld c,7(ix)
-           ld d,8(ix)
-           ld e,9(ix)
-           ld h,10(ix)
-           ld l,11(ix)
+           ld c,6(ix)
+           ld b,7(ix)
+           ld e,8(ix)
+           ld d,9(ix)
+           ld l,10(ix)
+           ld h,11(ix)
            push hl
-           ld h,12(ix)
-           ld l,13(ix)
+           ld l,12(ix)
+           ld h,13(ix)
            pop ix
            di
            ld (syscall_stash),a
@@ -417,6 +422,7 @@ syscall_high:
            ; Stack now invalid
            ld (U_DATA__U_SYSCALL_SP),sp
            ld sp,#kstack_top
+           ld a,(syscall_stash)
            call unix_syscall_entry
            ; FIXME check di rules
            push bc
@@ -425,9 +431,10 @@ syscall_high:
            and #0x60
            or b
            pop bc
-           out (251),a
-           ; stack now invalid
+           ; stack now invalid. Grab the new sp before we unbank the
+           ; memory holding it
            ld sp,(U_DATA__U_SYSCALL_SP)
+           out (251),a
            xor a
            cp h
            call nz, syscall_sigret
@@ -438,10 +445,12 @@ syscall_high:
            or l
            jr nz, error
            ex de,hl
+           pop de
            pop ix
            ei
            ret
 error:     scf
+           pop de
            pop ix
            ei
            ret