v85: add discard segment
authorAlan Cox <alan@linux.intel.com>
Tue, 12 Mar 2019 22:01:10 +0000 (22:01 +0000)
committerAlan Cox <alan@linux.intel.com>
Tue, 12 Mar 2019 22:01:10 +0000 (22:01 +0000)
We don't yet reclaim it for buffers

Kernel/platform-v85/Makefile
Kernel/platform-v85/crt0.s
Kernel/platform-v85/discard.c [new file with mode: 0644]
Kernel/platform-v85/end.s
Kernel/platform-v85/main.c

index 2c466cd..77ba0cc 100644 (file)
@@ -2,9 +2,10 @@ LIBPATH=../../Library/libs
 LIBC=$(LIBPATH)/libc8080.a $(ACK_ROOT)/share/ack/cpm/libem.a
 
 CSRCS += devices.c main.c devtty.c msm5832.c devrd.c
+DISCARD_CSRCS = discard.c
 
-DISCARD_DSRCS = ../dev/devide_discard.c
-DSRCS = ../dev/devide.c ../dev/mbr.c ../dev/blkdev.c ../dev/devfdc765.c
+DISCARD_DSRCS = ../dev/devide_discard.c ../dev/mbr.c
+DSRCS = ../dev/devide.c ../dev/blkdev.c ../dev/devfdc765.c
 
 CROSS_CCOPTS += -I../dev/
 
@@ -12,10 +13,11 @@ ASRCS = crt0.s commonmem.s v85.s tricks.s end.s fdc765.s mdrive.s
 
 AOBJS = $(ASRCS:.s=.o)
 COBJS = $(CSRCS:.c=.o)
+DISCARD_COBJS = $(DISCARD_CSRCS:.c=.o)
 DISCARD_DOBJS = $(patsubst ../dev/%.c,%.o, $(DISCARD_DSRCS))
 DOBJS = $(patsubst ../dev/%.c,%.o, $(DSRCS))
 
-OBJS  = $(AOBJS) $(COBJS) $(DISCARD_DOBJS) $(DOBJS)
+OBJS  = $(AOBJS) $(COBJS) $(DISCARD_COBJS) $(DISCARD_DOBJS) $(DOBJS)
 
 JUNK = *.o *.lst *.asm *.sym *.rst
 
@@ -27,12 +29,15 @@ $(AOBJS): %.o: %.s
 $(COBJS): %.o: %.c
        $(CROSS_CC) $(CROSS_CCOPTS) $<
 
+$(DISCARD_COBJS): %.o: %.c
+       $(CROSS_CC) -Ras=../tools/discard85 $(CROSS_CCOPTS) $<
+
 $(DOBJS): %.o: ../dev/%.c
        $(CROSS_CC) $(CROSS_CCOPTS) $<
 
 # Need to make discard work yet
 $(DISCARD_DOBJS): %.o: ../dev/%.c
-       $(CROSS_CC) $(CROSS_CCOPTS) $<
+       $(CROSS_CC) -t -Ras=../tools/discard85 $(CROSS_CCOPTS) $<
 
 tricks.s: ../lib/8080fixedbank.s ../lib/8080fixedbank-core.s
 
@@ -40,8 +45,8 @@ clean:
        rm -f $(OBJS) $(JUNK)  core *~ bootblock.bin bootblock
 
 image: 
-       $(CROSS_LD) -b0:0x0100 -b4:0xE800 -o fuzix.bin crt0.o devices.o main.o \
-       commonmem.o tricks.o v85.o devtty.o \
+       $(CROSS_LD) -b0:0x0100 -b4:0xE800 -b5:0xD800 -o fuzix.bin crt0.o devices.o main.o \
+       discard.o commonmem.o tricks.o v85.o devtty.o \
        ../start.o ../version.o ../lowlevel-8085.o \
        ../bankfixed.o ../timer.o ../kdata.o  \
        ../devio.o ../filesys.o ../process.o ../inode.o ../syscall_fs.o \
index 0645517..a3ab15b 100644 (file)
@@ -8,6 +8,8 @@ datastart:
 bssstart:
 .sect .common
 commonstart:
+.sect .discard
+discardstart:
 
 .sect .text
 
@@ -21,6 +23,7 @@ init:
 
         call init_early
 
+       ! Common is packed in the BSS space
 
        lxi h,commonend
        lxi d,commonstart
@@ -28,7 +31,8 @@ init:
 
        lxi h,bssstart
        lxi d,commonstart
-       
+
+       ! Copy it high
 nextbyte:
        mov a,m
        stax d
@@ -39,9 +43,39 @@ nextbyte:
        ora c
        jnz nextbyte
 
+       ! The discard follows the common
+
+       push h
+
+       lxi h,discardend
+       lxi d,discardstart
+       call calcsize
+
+       pop h
+       dad b
+       dcx h
+       xchg
+       dad b
+       dcx h
+       xchg
+
+!
+!      We copy discard from the top because it will probably overlap
+!      on an 8080/8085 type system due to the larger code sizes.
+!
+nextbyted:
+       mov a,m
+       stax d
+       dcx h
+       dcx d
+       dcx b
+       mov a,b
+       ora c
+       jnz nextbyted
+
 !      lxi h,bssend            ! We should really do this but bssend
                                ! isnt appearing at the end so plan b
-       lxi h,commonstart       ! Wipe all the free space
+       lxi h,discardstart      ! Wipe all the free space
        lxi d,bssstart
        call calcsize
 
diff --git a/Kernel/platform-v85/discard.c b/Kernel/platform-v85/discard.c
new file mode 100644 (file)
index 0000000..bff4ac1
--- /dev/null
@@ -0,0 +1,64 @@
+#include <kernel.h>
+#include <timer.h>
+#include <kdata.h>
+#include <printf.h>
+#include <devtty.h>
+#include <blkdev.h>
+#include <devfdc765.h>
+
+void pagemap_init(void)
+{
+ uint8_t i;
+ uint8_t m = 2;
+ for (i = 1; i < 8; i++) {
+  if (probe_bank(m) == 0) {
+       pagemap_add(m);
+       ramsize += 48;
+       procmem += 48;
+  }
+  m <<= 1;
+ }
+ if (procmem < 96)
+       panic("insufficient memory");
+}
+
+/* Nothing to do for the map of init */
+void map_init(void)
+{
+}
+
+uint8_t platform_param(char *p)
+{
+ used(p);
+ return 0;
+}
+
+/*
+ *     This function is called for partitioned devices if a partition is found
+ *     and marked as swap type. The first one found will be used as swap. We
+ *     only support one swap device.
+ */
+void platform_swap_found(uint8_t letter, uint8_t m)
+{
+       blkdev_t *blk = blk_op.blkdev;
+       uint16_t n;
+       if (swap_dev != 0xFFFF)
+               return;
+       letter -= 'a';
+       kputs("(swap) ");
+       swap_dev = letter << 4 | m;
+       
+       if (blk->lba_count[m - 1] > 0xFFFF)
+               n = 0xFFFF;
+       else
+               n = (uint16_t)blk->lba_count[m-1];
+       n /= SWAP_SIZE;
+       if (n > MAX_SWAPS)
+               n = MAX_SWAPS;
+#ifdef SWAPDEV
+       while (n)
+               swapmap_init(n--);
+#endif
+}
+
index ae8ac45..1c1485c 100644 (file)
@@ -10,3 +10,8 @@ commonend:
 .define bssend
 
 bssend:
+
+.sect .discard
+.define discardend
+
+discardend:
index a26e41a..408550d 100644 (file)
@@ -11,22 +11,6 @@ uint16_t swap_dev = 0xFFFF;
 
 extern uint16_t probe_bank(uint16_t);
 
-void pagemap_init(void)
-{
- uint8_t i;
- uint8_t m = 2;
- for (i = 1; i < 8; i++) {
-  if (probe_bank(m) == 0) {
-       pagemap_add(m);
-       ramsize += 48;
-       procmem += 48;
-  }
-  m <<= 1;
- }
- if (procmem < 96)
-       panic("insufficient memory");
-}
 
 /* On idle we spin checking for the terminals. Gives us more responsiveness
    for the polled ports */
@@ -45,42 +29,3 @@ void platform_interrupt(void)
  devfd_spindown();
 }
 
-/* Nothing to do for the map of init */
-void map_init(void)
-{
-}
-
-uint8_t platform_param(char *p)
-{
- used(p);
- return 0;
-}
-
-/*
- *     This function is called for partitioned devices if a partition is found
- *     and marked as swap type. The first one found will be used as swap. We
- *     only support one swap device.
- */
-void platform_swap_found(uint8_t letter, uint8_t m)
-{
-       blkdev_t *blk = blk_op.blkdev;
-       uint16_t n;
-       if (swap_dev != 0xFFFF)
-               return;
-       letter -= 'a';
-       kputs("(swap) ");
-       swap_dev = letter << 4 | m;
-       
-       if (blk->lba_count[m - 1] > 0xFFFF)
-               n = 0xFFFF;
-       else
-               n = (uint16_t)blk->lba_count[m-1];
-       n /= SWAP_SIZE;
-       if (n > MAX_SWAPS)
-               n = MAX_SWAPS;
-#ifdef SWAPDEV
-       while (n)
-               swapmap_init(n--);
-#endif
-}
-