zxdiv: Fix various things
authorAlan Cox <alan@linux.intel.com>
Thu, 22 Nov 2018 00:19:16 +0000 (00:19 +0000)
committerAlan Cox <alan@linux.intel.com>
Thu, 22 Nov 2018 00:19:16 +0000 (00:19 +0000)
Map the code low
Mark code as code1 so it banks right
Fix the writable code references
Sort out the udata mapping
Fix the __memcpy calls to call our bank code not invalid sdcc lib code
Remove strlcpy we don't use
Fix minor fork bugs

With this we get to the point of init running and forking. No further but
we really need swap on to make any real progress.

Kernel/platform-zxdiv/Makefile
Kernel/platform-zxdiv/README
Kernel/platform-zxdiv/config.h
Kernel/platform-zxdiv/crt0.s
Kernel/platform-zxdiv/fuzix.lnk
Kernel/platform-zxdiv/kernel.def
Kernel/platform-zxdiv/main.c
Kernel/platform-zxdiv/rules.mk
Kernel/platform-zxdiv/tricks.s
Kernel/platform-zxdiv/zx128.s

index 2d79c7a..0bbb573 100644 (file)
@@ -38,6 +38,9 @@ clean:
 
 # Re-order the image and snapshop it
 image:
+       # Merge the first code bank into common
+       dd if=../bank1.bin bs=16384 skip=3 seek=3 count=1 \
+               of=../common.bin conv=notrunc
        # The bootstrap to con Fatware
        dd if=../common.bin of=BOOT.BIN bs=8192 count=1
        # Rest of the base image, starts at 0x2200, pad it
index 578db85..3e792be 100644 (file)
@@ -40,7 +40,9 @@ We run with the following mapping
 
 4000-7FFF      Kernel data continued (lots of space) 
 
-8000-BFFF      _DISCARD area - blown away when we exec init
+8000-83FF      Needed to create the exec of init
+8400-BFFF      _DISCARD area - blown away when we exec init
+               (tons of room in this space)
 
 C000-FFFF
        0:      Kernel CODE (fairly full)
@@ -61,11 +63,8 @@ around we exchange it with bank 6 as we go.
 
 To Do:
 
--      Get the DivIDE interface working
--      Review DivIDE writes - is the port aliasing safe with a full
-       otir or do we need to avoid port aliasing ?
 -      Check the swap hooks are ok
--      See what we can get below 0x2000
+-      Turn on swap so we can make progress
 -      Set video space in CODE3 bank to 0 not 0xFF for neatness
 -      Look at what is needed for other suitable interfaces. DIVMMC would
        in particular be good to support but that means another harder
@@ -155,3 +154,10 @@ hassle.
 Could we jump up and down on it enough to get user to be a bit bigger than 32K
 and if so where and how do we handle the extra
 
+
+
+DONE   -       Get the DivIDE interface working
+DONE   -       See what we can get below 0x2000
+DONE   -       Review DivIDE writes - is the port aliasing safe with a full
+       otir or do we need to avoid port aliasing ? - safe
+DONE   -       Crash when we fork() or switch ?
index dd050ee..6b059a1 100644 (file)
@@ -1,5 +1,3 @@
-#define CONFIG_LEVEL_0
-
 #define CONFIG_IDE
 #define CONFIG_SD
 #define SD_DRIVE_COUNT 1               /* For the moment */
@@ -42,7 +40,7 @@
 #define TICKSPERSEC 50   /* Ticks per second */
 #define PROGBASE    0x8000  /* also data base */
 #define PROGLOAD    0x8000  /* also data base */
-#define PROGTOP     0xFC00  /* Top of program, base of U_DATA copy */
+#define PROGTOP     0xFE00  /* Top of program, base of U_DATA copy */
 #define PROC_SIZE   32   /* Memory needed per process */
 
 #define BOOT_TTY (513)  /* Set this to default device for stdio, stderr */
index 77f2d98..0b9d036 100644 (file)
@@ -2,6 +2,7 @@
        ;
        ;       Our common lives low
        ;
+       .area _CODE
         .area _COMMONMEM
        .area _STUBS
         .area _CONST
@@ -28,7 +29,7 @@
        ;
        ;       All our code is banked at 0xC000
        ;
-        .area _CODE
+        .area _CODE1
        .area _CODE2
        ;
        ; Code3 sits above the display area along with the font and video
@@ -69,7 +70,7 @@
        ; the kernel image for us from blocks 1+ and all is good.
        ;
 
-        .area _CODE
+        .area _CODE1
 
        .globl _go
 
@@ -109,7 +110,7 @@ stop:   halt
 
        ; Boot marker at 0x2200
 
-       .area _COMMONMEM
+       .area _COMMONDATA
        .globl _marker
 _marker:
        .byte 'Z'               ; marker
index d379a3b..26efb81 100644 (file)
@@ -1,11 +1,13 @@
 -mwxuy
 -r
 -i fuzix.ihx
--b _COMMONMEM=0x2200
--b _CODE=0xC000
+-b _CODE=0x0200
+-b _COMMONMEM=0x400
+-b _COMMONDATA=0x2200
+-b _CODE1=0xC000
 -b _CODE2=0xC000
 -b _CODE3=0xDB00
--b _DISCARD=0x8000
+-b _DISCARD=0x8400
 -b BOOT1FEC=0x1FEC
 -b BOOT1FF7=0x1FF7
 -b BOOT1FFE=0x1FFE
index 24abedc..2a1125f 100644 (file)
@@ -1,10 +1,10 @@
 ; UZI mnemonics for memory addresses etc
 
-; FIXME: THIS IS WRONG - NEED TO SORT OUT MAPPINGS AND DEAL WITH THIS
-U_DATA                      .equ 0x4000       ; (this is struct u_data from kernel.h)
-U_DATA__TOTALSIZE           .equ 0x300        ; 256+256+256 bytes.
+; We stick it straight after the tag
+U_DATA                      .equ 0x2204       ; (this is struct u_data from kernel.h)
+U_DATA__TOTALSIZE           .equ 0x200        ; 256+256+256 bytes.
 
-U_DATA_STASH               .equ 0xFC00       ; FC00-FEFF
+U_DATA_STASH               .equ 0xFE00       ; FE00-FFFF
 
 Z80_TYPE                   .equ 1
 
index afdacd9..762df54 100644 (file)
@@ -22,12 +22,16 @@ void platform_interrupt(void)
  timer_interrupt();
 }
 
-size_t strlcpy(char *dst, const char *src, size_t dstsize)
+/*
+ *     So that we don't suck in a library routine we can't use from
+ *     the runtime
+ */
+
+int strlen(const char *p)
 {
-  size_t len = strlen(src);
-  size_t cp = len >= dstsize ? dstsize - 1 : len;
-  memcpy(dst, src, cp);
-  dst[cp] = 0;
+  int len = 0;
+  while(*p++)
+    len++;
   return len;
 }
 
index a6a6115..9266fa4 100644 (file)
@@ -8,11 +8,12 @@ CROSS_CCOPTS += --external-banker
 export BANKED=-banked
 #
 export CROSS_CC_SEG1=--codeseg CODE2
-export CROSS_CC_SEG3=--codeseg CODE
-export CROSS_CC_SYS1=--codeseg CODE
-export CROSS_CC_SYS2=--codeseg CODE
-export CROSS_CC_SYS3=--codeseg CODE
-export CROSS_CC_SYS4=--codeseg CODE
+export CROSS_CC_SEG3=--codeseg CODE1
+export CROSS_CC_SEG4=--codeseg CODE1
+export CROSS_CC_SYS1=--codeseg CODE1
+export CROSS_CC_SYS2=--codeseg CODE1
+export CROSS_CC_SYS3=--codeseg CODE1
+export CROSS_CC_SYS4=--codeseg CODE3
 export CROSS_CC_SYS5=--codeseg CODE3
 # The banking default is to put fonts in bank3. We don't want this so build
 # our font as CONST so it lands where we want it
index dc8b380..eafffc6 100644 (file)
@@ -261,7 +261,6 @@ _dup_low_page:
        out (c), a
        ret
 
-fork_proc_ptr: .dw 0 ; (C type is struct p_tab *) -- address of child process p_tab entry
 
 ;
 ;      Called from _fork. We are in a syscall, the uarea is live as the
@@ -397,7 +396,7 @@ _dofork:
 ;
 bankfork:
        or #0x18                ; ROM bits for the bank
-       ld b, #0x3C             ; 40 x 256 minus 4 sets for the uarea stash/irqs
+       ld b, #0x3E             ; 64 x 256 minus 2 sets for the uarea stash/irqs
        ld hl, #0xC000          ; base of memory to fork (vectors included)
 bankfork_1:
        push bc                 ; Save our counter and also child offset
@@ -440,3 +439,5 @@ _swapstack:
 _low_bank:
        .dw _ptab                       ; Init starts owning this
 
+fork_proc_ptr:
+       .dw 0 ; (C type is struct p_tab *) -- address of child process p_tab entry
index dd58cf3..11e2b02 100644 (file)
@@ -104,7 +104,7 @@ _int_disabled:
 ; -----------------------------------------------------------------------------
 ; KERNEL MEMORY BANK (above 0xC000, only accessible when the kernel is mapped)
 ; -----------------------------------------------------------------------------
-        .area _CODE
+        .area _CODE1
 
 ;
 ;      The memory banker will deal with the map setting