micropack: turn into a level 0 test bed
authorAlan Cox <alan@linux.intel.com>
Wed, 14 Jun 2017 20:25:46 +0000 (21:25 +0100)
committerAlan Cox <alan@linux.intel.com>
Wed, 14 Jun 2017 20:25:46 +0000 (21:25 +0100)
Kernel/platform-micropack/Makefile
Kernel/platform-micropack/README
Kernel/platform-micropack/bootblock.s
Kernel/platform-micropack/config.h
Kernel/platform-micropack/crt0.s
Kernel/platform-micropack/fuzix.lnk
Kernel/platform-micropack/main.c
Kernel/platform-micropack/syscall_bank.c [deleted file]
Kernel/platform-micropack/z80pack.s

index f79403a..e4100b5 100644 (file)
@@ -1,17 +1,15 @@
 
 DSRCS = ../dev/z80pack/devlpr.c ../dev/z80pack/devfd.c
 CSRCS = devices.c main.c devtty.c
-CBSRCS = syscall_bank.c
 
 ASRCS = crt0.s z80pack.s
 ASRCS += tricks.s commonmem.s
 
 AOBJS = $(ASRCS:.s=.rel)
 COBJS = $(CSRCS:.c=.rel)
-CBOBJS = $(CBSRCS:.c=.rel)
 DOBJS = $(patsubst ../dev/z80pack/%.c,%.rel, $(DSRCS))
 
-OBJS  = $(AOBJS) $(COBJS) $(DOBJS) $(CBOBJS)
+OBJS  = $(AOBJS) $(COBJS) $(DOBJS)
 
 CROSS_CCOPTS += -I../dev/z80pack/
 
@@ -19,20 +17,12 @@ JUNK = *.rel *.lst *.asm *.sym *.rst
 
 all:   $(OBJS)
 
-syscall_bank.h: ../include/syscall_name.h ../syscall_fs.c ../syscall_fs2.c ../syscall_fs3.c ../syscall_other.c ../syscall_exec16.c
-       ../tools/map_syscall ../syscall_fs.c ../syscall_fs2.c ../syscall_fs3.c ../syscall_other.c ../syscall_exec16.c >syscall_bank.h
-
-syscall_bank.c: syscall_bank.h
-
 $(AOBJS): %.rel: %.s
        $(CROSS_AS) $(ASOPTS) $<
 
 $(COBJS): %.rel: %.c
        $(CROSS_CC) $(CROSS_CCOPTS) -c $<
 
-$(CBOBJS): %.rel: %.c
-       $(CROSS_CC) $(CROSS_CCOPTS) --constseg DATAAL -c $<
-
 $(DOBJS): %.rel: ../dev/z80pack/%.c
        $(CROSS_CC) $(CROSS_CCOPTS) -c $<
 
index 880c583..52ec95c 100644 (file)
@@ -1,33 +1,35 @@
 A FUZIX target for z80pack.
 
 Test environment for a very squashed build to see what we can achieve in
-64K + disk banking and explore ROM banking ideas
+64K
 
-Not a useful target, but memory testing stuff
+We build a kernel from 0x8000-0xFFFF and everything needs to either fit in
+that space, or we will need some kind of overlay for obscure syscalls. We
+can't however swap the overlays over userspace because there may be pointers
+to userspace addresses in the syscalls. One option might be to mark binaries
+by required level and have level 1 binaries given less room but loaded with
+the overlay. That would work well since it's only a few obscure calls we need
+to boot out.
 
-File system code is paged with the banks being 4K spaced 0xE00 length copies
-of the bank and any fixed data that dribbles over the end.
+The obvious calls to bank out are
 
-TODO: 
-Turn memory images into a loadable binary and a block for the disk
-Preload the exec syscall bank into the main binary so startup works
+rename (526 bytes)
+mkdir (481 bytes)
+rmdir (356 bytes)
 
+It may also be possible to bank out some of execve if we don't allow the
+code/data of a binary to be the full space so we have room for it.
 
-Savings:
+Other options include just having an overlay zone of about 1.5K which would
+hold either
 
-Other candidates for the bot which are big are waitpid at 380 bytes and
-signal + sigdisp at 621 bytes the pair. signal/sigdisp normally occur only
-at startup and signal handling so would be acceptable-ish, waitpid always
-involves a task switch anyway. Neither are ideal but they might work.
+rename
+mkdir
+rmdir
 
-Some inline tricks with tty might also save a tiny bit of RAM
-Put the swap stack at 0x80-0xFF as we can't realistically run CP/M
-emulation.
+execve (and helpers)
+
+waitpid
+flock
 
-Other thoughts. When working with small app have a version of some of the
-overlays that can be loaded in the top of app space - how to do relocations
-and patches ?
 
-Do we want to keep the overlays in the swap space gapped between each
-swapped app. Disk swap is usually cheap spacewise and it would speed up
-their fetching.
index 118aede..926128e 100644 (file)
@@ -24,7 +24,7 @@ progress:     .db '/', '-', '\', '|'
 
 diskload:      di
                ld sp, #stack
-               ld hl, #0x88
+               ld hl, #0x6000
                exx
                xor a
                ld h, a
index 7b52f5c..69892eb 100644 (file)
@@ -14,8 +14,8 @@
 #undef CONFIG_BANK_FIXED
 /* Swap only */
 #define CONFIG_SWAP_ONLY
-/* Simple user copies */
-#define CONFIG_USERMEM_DIRECT
+/* Mini platform */
+#define CONFIG_LEVEL_0
 
 /* Banks as reported to user space */
 #define CONFIG_BANKS   1
index e48761a..6e7a767 100644 (file)
@@ -2,7 +2,6 @@
         ; WRS: Note we list all our segments here, even though
         ; we don't use them all, because their ordering is set
         ; when they are first seen.
-       .area _CODE6            ; overlaid by 3 4 5 (which are smaller)
         .area _CODE
         .area _CODE2
         .area _CONST
index 80babec..caee95d 100644 (file)
@@ -1,15 +1,9 @@
 -mwxuy
 -r
 -i fuzix.ihx
--b _DATAAL=0xC000
--b _CODE=0xC040
--b _DISCARD=0x5000
+-b _DISCARD=0x6000
 -b _UDATA=0x7E00
--b _CODE6=0x8000
--b _CODE3=0x8000
--b _CODE4=0x8000
--b _CODE5=0x8000
--b _CODE7=0x8000
+-b _CODE=0x8000
 -l z80
 platform-micropack/crt0.rel
 platform-micropack/commonmem.rel
@@ -41,5 +35,4 @@ swap.rel
 devsys.rel
 platform-micropack/devlpr.rel
 platform-micropack/devtty.rel
-platform-micropack/syscall_bank.rel
 -e
index 3a60423..97de86c 100644 (file)
@@ -32,3 +32,12 @@ uint8_t platform_param(char *p)
  used(p);
  return 0;
 }
+
+size_t strlcpy(char *dst, const char *src, size_t dstsize)
+{
+  size_t len = strlen(src);
+  size_t cp = len >= dstsize ? dstsize - 1 : len;
+  memcpy(dst, src, cp);
+  dst[cp] = 0;
+  return len;
+}
diff --git a/Kernel/platform-micropack/syscall_bank.c b/Kernel/platform-micropack/syscall_bank.c
deleted file mode 100644 (file)
index 034bf2f..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#include "cpu.h"
-const uint8_t syscall_bank[] = {
-#include "syscall_bank.h"
-};
-
index 1202097..42bbadd 100644 (file)
@@ -78,7 +78,7 @@ init_hardware:
             ; set system RAM size
             ld hl, #64
             ld (_ramsize), hl
-            ld hl, #32                 ; 64K for kernel
+            ld hl, #32                 ; 32K for kernel
             ld (_procmem), hl
 
            ld a, #1
@@ -159,6 +159,9 @@ outchar:
            out (0x01), a
             ret
 
+;
+;      Not used yet - will be needed if we do the 3 overlays
+;
 overlay_syscall_entry:
        ld hl, #18
        add hl, sp
@@ -207,3 +210,5 @@ _need_resched:
        .db 0
 _curbank:
        .db 0
+_syscall_bank:
+       .db 0