From 0f296159a3ece30ff5d815b2e1bffee3a2a476c2 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sat, 10 Jan 2015 22:28:26 +0000 Subject: [PATCH] tgl6502: fix various basic things such as __fastcall__ for memcpy Now things look a bit saner and we get to the point of sitting on our butt waiting for a keyboard input. --- Kernel/platform-tgl6502/Makefile | 4 ++-- Kernel/platform-tgl6502/config.h | 12 ++++++------ Kernel/platform-tgl6502/crt0.s | 4 ++-- Kernel/platform-tgl6502/libc.c | 17 ----------------- Kernel/platform-tgl6502/tgl6502.s | 19 ++++++++++++++----- 5 files changed, 24 insertions(+), 32 deletions(-) delete mode 100644 Kernel/platform-tgl6502/libc.c diff --git a/Kernel/platform-tgl6502/Makefile b/Kernel/platform-tgl6502/Makefile index b415860a..98d60a33 100644 --- a/Kernel/platform-tgl6502/Makefile +++ b/Kernel/platform-tgl6502/Makefile @@ -1,6 +1,6 @@ CSRCS = devtty.c devrd.c -CSRCS += devices.c main.c libc.c +CSRCS += devices.c main.c ASRCS = tgl6502.s crt0.s ASRCS += tricks.s commonmem.s @@ -29,4 +29,4 @@ image: ../devio.o ../filesys.o ../process.o ../inode.o ../syscall_fs.o \ ../syscall_proc.o ../syscall_other.o ../mm.o ../swap.o ../bankfixed.o \ ../tty.o ../devsys.o ../syscall_fs2.o ../syscall_exec.o \ - ../usermem.o ../usermem_std-6502.o devtty.o libc.o + ../usermem.o ../usermem_std-6502.o devtty.o diff --git a/Kernel/platform-tgl6502/config.h b/Kernel/platform-tgl6502/config.h index a2a93e30..cabfc8c3 100644 --- a/Kernel/platform-tgl6502/config.h +++ b/Kernel/platform-tgl6502/config.h @@ -15,20 +15,20 @@ /* For now used BANK_FIXED as we don't yet have sane swap with 16K maps */ #define CONFIG_BANK_FIXED #define MAX_MAPS 2 -#define MAP_SIZE 0xC000 +#define MAP_SIZE 0xE000 /* And swapping */ #define SWAPDEV 257 /* FIXME */ -#define SWAP_SIZE 0x60 /* 48K in blocks */ +#define SWAP_SIZE 0x70 /* 56K in blocks */ #define SWAPBASE 0x0000 /* We swap the lot in one, include the */ -#define SWAPTOP 0xC000 /* vectors so its a round number of sectors */ +#define SWAPTOP 0xE000 /* vectors so its a round number of sectors */ /* FIXME: we need to swap the udata separately */ #define MAX_SWAPS 32 #define TICKSPERSEC 10 /* Ticks per second */ -#define PROGBASE 0x0200 /* also data base */ -#define PROGLOAD 0x0200 -#define PROGTOP 0xC000 /* Top of program */ +#define PROGBASE 0x2000 /* also data base */ +#define PROGLOAD 0x2000 +#define PROGTOP 0xE000 /* Top of program */ #define BOOT_TTY 513 /* Set this to default device for stdio, stderr */ diff --git a/Kernel/platform-tgl6502/crt0.s b/Kernel/platform-tgl6502/crt0.s index 0b5f8c46..82d15b86 100644 --- a/Kernel/platform-tgl6502/crt0.s +++ b/Kernel/platform-tgl6502/crt0.s @@ -65,12 +65,12 @@ start: ; Map ROM at 0x4000-0xFFFF sta ptr1 lda #>__BSS_RUN__ sta ptr1+1 - lda #0 - tay lda #'z' sta $FF03 + lda #0 + tay ldx #>__BSS_SIZE__ beq bss_wipe_tail bss_wiper_1: sta (ptr1),y diff --git a/Kernel/platform-tgl6502/libc.c b/Kernel/platform-tgl6502/libc.c deleted file mode 100644 index 8a972835..00000000 --- a/Kernel/platform-tgl6502/libc.c +++ /dev/null @@ -1,17 +0,0 @@ -#include "cpu.h" - -void *memcpy(void *d, void *s, size_t sz) -{ - unsigned char *dp, *sp; - while(sz--) - *dp++=*sp++; - return d; -} - -size_t strlen(const char *p) -{ - const char *e = p; - while(*e++); - return e-p-1; -} - diff --git a/Kernel/platform-tgl6502/tgl6502.s b/Kernel/platform-tgl6502/tgl6502.s index f9e56e55..6d028e32 100644 --- a/Kernel/platform-tgl6502/tgl6502.s +++ b/Kernel/platform-tgl6502/tgl6502.s @@ -92,7 +92,6 @@ init_hardware: sta _ramsize lda #120 sta _procmem - jsr program_vectors_k rts @@ -125,7 +124,7 @@ program_vectors_k: sta $FFFB ; However tempting it may be to use BRK for system calls we ; can't do this on an NMOS 6502 because the chip has brain - ; dead IRQ handling buts that could simply "lose" the syscall! + ; dead IRQ handling bits that could simply "lose" the syscall! lda #syscall_entry @@ -159,11 +158,15 @@ program_vectors_k: ; banking/mappings without having to leave interrupts off all the time ; map_process_always: + pha + txa pha lda #U_DATA__U_PAGE jsr map_process_2 pla + tax + pla rts ; ; X,A points to the map table of this process @@ -181,6 +184,8 @@ map_process: ; common area just to balance out memory usages). ; map_kernel: + pha + txa pha ; Common is left untouched as is ZP and S lda #$01 ; Kernel RAM at 0x2000-0x3FFF @@ -199,6 +204,8 @@ map_kernel: inx stx $FF91 pla + tax + pla rts ; X,A holds the map table of this process @@ -206,9 +213,10 @@ map_process_2: sta ptr1 tya pha - sty ptr1+1 + stx ptr1+1 ldy #0 lda (ptr1),y ; 4 bytes if needed + tax jsr restore_bits pla tay @@ -252,12 +260,13 @@ restore_bits: ; we go to proper banking rts -; Save the current mapping. ; -; FIXME: need to copy the 8 byte area +; Save the current mapping. +; May not be sufficient if we want IRQs on while doing page tricks ; map_save: pha + lda U_DATA__U_PAGE sta saved_map pla rts -- 2.34.1