tgl6502: fix various basic things such as __fastcall__ for memcpy
authorAlan Cox <alan@linux.intel.com>
Sat, 10 Jan 2015 22:28:26 +0000 (22:28 +0000)
committerAlan Cox <alan@linux.intel.com>
Sat, 10 Jan 2015 22:28:26 +0000 (22:28 +0000)
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
Kernel/platform-tgl6502/config.h
Kernel/platform-tgl6502/crt0.s
Kernel/platform-tgl6502/libc.c [deleted file]
Kernel/platform-tgl6502/tgl6502.s

index b415860..98d60a3 100644 (file)
@@ -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
index a2a93e3..cabfc8c 100644 (file)
 /* 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 */
 
index 0b5f8c4..82d15b8 100644 (file)
@@ -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 (file)
index 8a97283..0000000
+++ /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;
-}
-
index f9e56e5..6d028e3 100644 (file)
@@ -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
            sta 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
            ldx #>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