From a6c177b58958d55ffb8d14ac4996a3b7620c4c11 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sun, 1 Jul 2018 21:15:10 +0100 Subject: [PATCH] coco2: memory usage Rearrange memory Remove drivewire Pack things into some of the spaces Use the LEVEL_0 option At this point we have 28.5K user space Still really a demo of how small we can go, and for shrinking work. --- Kernel/platform-coco2/Makefile | 11 +++++----- Kernel/platform-coco2/README | 36 ++++++-------------------------- Kernel/platform-coco2/config.h | 10 +++++---- Kernel/platform-coco2/devices.c | 2 -- Kernel/platform-coco2/fuzix.link | 3 ++- 5 files changed, 20 insertions(+), 42 deletions(-) diff --git a/Kernel/platform-coco2/Makefile b/Kernel/platform-coco2/Makefile index 5fc6af5d..11914c3c 100644 --- a/Kernel/platform-coco2/Makefile +++ b/Kernel/platform-coco2/Makefile @@ -1,14 +1,14 @@ -CSRCS = devices.c main.c mini_ide.c +CSRCS = devices.c main.c mini_ide.c devtty.c -C3SRCS = libc.c devtty.c +C3SRCS = libc.c CDSRCS = discard.c mini_ide_discard.c DSRCS = ../dev/devdw.c ASRCS = crt0.s coco2.s ide.s -ASRCS += tricks.s commonmem.s drivewire.s +ASRCS += tricks.s commonmem.s COBJS = $(CSRCS:.c=$(BINEXT)) C3OBJS = $(C3SRCS:.c=$(BINEXT)) @@ -22,12 +22,13 @@ CROSS_CCOPTS += -I../dev/ all: $(OBJS) export CROSS_CC_SEGD=-mcode-section=.text3 -mfar-code-page=2 +export CROSS_CC_SEGI=-mcode-section=.page1 -mfar-code-page=2 $(COBJS): %$(BINEXT): %.c $(CROSS_CC) $(CROSS_CCOPTS) $(CROSS_CC_SEG2) -c $< $(C3OBJS): %$(BINEXT): %.c - $(CROSS_CC) $(CROSS_CCOPTS) $(CROSS_CC_SEGD) -c $< + $(CROSS_CC) $(CROSS_CCOPTS) $(CROSS_CC_SEGI) -c $< $(CDOBJS): %$(BINEXT): %.c $(CROSS_CC) $(CROSS_CCOPTS) $(CROSS_CC_SEGDISC) -c $< @@ -50,7 +51,7 @@ image: bootfuz.bin coco2.o discard.o ../simple.o \ ../start.o ../version.o ../lowlevel-6809.o \ tricks.o main.o ../timer.o ../kdata.o devices.o \ - drivewire.o devdw.o mini_ide.o mini_ide_discard.o \ + mini_ide.o mini_ide_discard.o \ ../devio.o ../filesys.o ../process.o ../inode.o ../syscall_fs.o \ ../syscall_proc.o ../syscall_other.o ../mm.o ../swap.o \ ../tty.o ../devsys.o ../usermem.o ../syscall_fs2.o ../syscall_exec16.o \ diff --git a/Kernel/platform-coco2/README b/Kernel/platform-coco2/README index ed531b63..d0ff48e0 100644 --- a/Kernel/platform-coco2/README +++ b/Kernel/platform-coco2/README @@ -1,7 +1,7 @@ COCO2 ===== -COCO or Dragon 64 with an IDE port, cartridge and 64K of RAM +COCO or Dragon 64 with an IDE port 64K of RAM Supported hardware: IDE (Glenside or compatible) @@ -9,13 +9,13 @@ Supported hardware: Memory Map ========== 0000-00FF Interrupt stack -0100-01FF Vectors (then wasted - could hide libc.o in there ?) +0100-01FF Vectors and then libc 0200-03FF Display 0400-7FFF Code/Data for kernel (take care to keep this below 8000 and shuffle stuff if needed to make it fit) -8000-EFFF User space -EC00-FBFF More kernel bits -FC00-FEFF udata +8000-F1FF User space (28.5K) +F200-FBFF More kernel bits +FD00-FEFF udata FF00-FFFF I/O etc @@ -38,28 +38,4 @@ actually be doable! MPI switching -Could we do a cartridge version -- Re-order so common is in low memory -- Support map_kernel/map_process flipping -- Add asm helpers for user mode copying (trivial - and since we never copy - into kernel ROM we can optimise them a lot - one map switch only) -- Fix IDE to support the map flip on transfers (needs little asm code - adding) -- How to do discard, can we just take the hit or do we need to copy the - entire cartridge into high RAM, run in high RAM with discard at say - 0xA000 and then in platform_discard switch on map_kernel cartridge - selection so we can let userspace blow away the upper 32K of the RAM - mapping. - -16K Cartridge version would give us space for -- Proper video (costs us about 8K) -- Nice loader (just 'EXEC $C000' and go) < 1K -- Probably all of sound/joysticks/printer/floppy and a few more buffers -- Full size user memory bank (so can run full v7 shell) 4K - - -Write a loader into the cartridge start so it bootstraps off disk and runs -nicely - -6847T1 lower case ? - +See platform-coco2cart for the actual resulting cartridge based implementation diff --git a/Kernel/platform-coco2/config.h b/Kernel/platform-coco2/config.h index 602a9e71..64c29682 100644 --- a/Kernel/platform-coco2/config.h +++ b/Kernel/platform-coco2/config.h @@ -14,12 +14,14 @@ #define UDATA_BLKS 1 #define CONFIG_USERMEM_DIRECT +#define CONFIG_LEVEL_0 /* Minimal system */ + #define CONFIG_BANKS 1 /* And swapping */ #define SWAPDEV 0x0 /* Uses part of IDE slice 0 */ -#define SWAP_SIZE 0x40 /* 32K in 512 byte blocks */ +#define SWAP_SIZE 0x39 /* 512 byte blocks */ #define SWAPBASE 0x8000 /* We swap the lot, including stashed uarea */ -#define SWAPTOP 0xEC00 /* so it's a round number of 512 byte sectors */ +#define SWAPTOP 0xF200 /* so it's a round number of 512 byte sectors */ #define UDATA_SIZE 0x0200 /* one block */ #define MAX_SWAPS 32 @@ -48,7 +50,7 @@ extern unsigned char vt_mangle_6847(unsigned char c); #define TICKSPERSEC 50 /* Ticks per second */ #define PROGBASE 0x8000 /* also data base */ #define PROGLOAD 0x8000 /* also data base */ -#define PROGTOP 0xEC00 /* Top of program */ +#define PROGTOP 0xF200 /* Top of program */ /* We need a tidier way to do this from the loader */ #define CMDLINE NULL /* Location of root dev name */ @@ -58,7 +60,7 @@ extern unsigned char vt_mangle_6847(unsigned char c); #define NDEVS 2 /* Devices 0..NDEVS-1 are capable of being mounted */ /* (add new mountable devices to beginning area.) */ #define TTYDEV 513 /* Device used by kernel for messages, panics */ -#define NBUFS 6 /* Number of block buffers */ +#define NBUFS 5 /* Number of block buffers */ #define NMOUNTS 2 /* Number of mounts at a time */ #define swap_map(x) ((uint8_t *)(x)) diff --git a/Kernel/platform-coco2/devices.c b/Kernel/platform-coco2/devices.c index f62ec4a4..11fd8bbb 100644 --- a/Kernel/platform-coco2/devices.c +++ b/Kernel/platform-coco2/devices.c @@ -29,8 +29,6 @@ struct devsw dev_tab[] = /* The device driver switch table */ { nxio_open, no_close, no_rdwr, no_rdwr, no_ioctl }, { nxio_open, no_close, no_rdwr, no_rdwr, no_ioctl }, { nxio_open, no_close, no_rdwr, no_rdwr, no_ioctl }, - /* 8: /dev/dw DriveWire remote disk images */ - { dw_open, no_close, dw_read, dw_write, no_ioctl }, }; bool validdev(uint16_t dev) diff --git a/Kernel/platform-coco2/fuzix.link b/Kernel/platform-coco2/fuzix.link index 46404c17..a1622336 100644 --- a/Kernel/platform-coco2/fuzix.link +++ b/Kernel/platform-coco2/fuzix.link @@ -2,11 +2,12 @@ define basesympat __sectionbase_%s__ define lensympat __sectionlen_%s__ section .istack load 0x0000 section .vectors load 0x0100 +section .page1 section .start load 0x0400 section .text section .text2 section .bss -section .video load 0xEC00 +section .video load 0xF200 section .data section .videodata section .common -- 2.34.1