DSRCS = ../dev/devdw.c ../dev/blkdev.c ../dev/devide.c
NSRCS = ../dev/net/net_native.c
-ASRCS = coco3.s crt0.s ../platform-dragon-nx32/ide.s
+ASRCS = coco3.s crt0.s ide.s
ASRCS += tricks.s commonmem.s usermem_gime.s drivewire.s sdc.s videoll.s
COBJS = $(CSRCS:.c=$(BINEXT))
coco3.o ../start.o ../version.o ../lowlevel-6809.o \
tricks.o main.o ../timer.o ../kdata.o devices.o \
drivewire.o devdw.o ttydw.o blkdev.o mbr.o devide.o devide_discard.o \
- ../platform-dragon-nx32/ide.o devsdc.o sdc.o \
+ ide.o devsdc.o sdc.o \
../devio.o ../filesys.o ../process.o ../inode.o ../syscall_fs.o \
../syscall_proc.o ../syscall_other.o ../mm.o ../bank16k.o ../swap.o \
../tty.o ../devsys.o ../usermem.o ../syscall_fs2.o ../syscall_exec16.o \
.globl _hz
.globl _bufpool
.globl _discard_size
+ .globl _copy_common
+ .globl blkdev_rawflg
+ .globl blkdev_unrawflg
; exported debugging tools
.globl _trap_monitor
sta 0xffa9
rts
+;;; Copy existing common area to page
+;;; takes: B = destination page
+;;; returns: nothing
+_copy_common
+ pshs u
+ incb
+ stb 0xffa8
+ ldx #0xe200
+ ldu #0xe200&0x1fff
+a@ ldd ,x++
+ std ,u++
+ cmpx #0xff00
+ bne a@
+ clr 0xffa8
+ puls u,pc
+
+;;; Helper for blkdev drivers to setup memory based on rawflag
+blkdev_rawflg
+ ldx #_blk_op ; X = blkdev operations
+ ldb 0xffa8 ; get mmu setting
+ stb ret+1 ; save in stash
+ ldb 2,x ; get raw mode
+ decb ; compare to 1
+ bmi out@ ; less than or equal: 0, or 1 don't do map
+ beq proc@ ; is direct to process
+ ;; is swap so map page into kernel memory at 0x0000
+ ldb 3,x ; get page no
+ stb 0xffa8 ; task 1, kernel task regs.
+ incb ; inc page no... next block no.
+ stb 0xffa9 ; store it in mmu
+ rts
+proc@ jsr map_process_always
+ ; get parameters from C, X points to cmd packet
+out@ rts
+
+;;; Helper for blkdev drivers to clean up memory after blkdev_rawflg
+blkdev_unrawflg
+ret ldb #0
+ stb 0xffa8
+ incb
+ stb 0xffa9
+ jsr map_kernel
+ rts
#define MAX_MAPS 128-3
#define MAPBASE 0x0000
/* And swapping */
-/* #define SWAPDEV 2051 */
-#define SWAP_SIZE 0x62
+extern unsigned int swapdev;
+#define SWAPDEV swapdev
+#define SWAP_SIZE 0x71
/* FIXME */
#define SWAPBASE 0x0000 /* We swap the lot in one, include the */
-#define SWAPTOP 0xC300 /* uarea so its a round number of sectors */
+#define SWAPTOP 0xe200 /* uarea so its a round number of sectors */
#define UDATA_BLOCKS 0 /* We swap the uarea in the data */
#define UDATA_SWAPSIZE 0
#define MAX_SWAPS 32
--- /dev/null
+;
+; Glennside style IDE block transfer logic
+;
+
+ .module dragonide
+
+ .globl _devide_read_data
+ .globl _devide_write_data
+
+ .globl _blk_op
+
+ include "kernel.def"
+ include "../kernel09.def"
+
+ .area .common
+
+;
+; Standad mapping for Glennside style IDE
+;
+_devide_read_data:
+ pshs y,dp
+ lda #0xFF
+ tfr a,dp
+ jsr blkdev_rawflg
+ ldx _blk_op
+ leay 512,x
+ sty endp
+readword:
+ lda <IDEDATA
+ ldb <IDEDATA_L ; latched
+ std ,x++
+ cmpx endp
+ bne readword
+ jsr blkdev_unrawflg
+ puls y,dp,pc
+
+_devide_write_data:
+ pshs y,dp
+ lda #0xFF
+ tfr a,dp
+ jsr blkdev_rawflg
+ ldx _blk_op
+ leay 512,x
+ sty endp
+writeword:
+ ldd ,x++
+ stb <IDEDATA_L
+ sta <IDEDATA
+ cmpx endp
+ bne writeword
+ jsr blkdev_unrawflg
+ puls y,dp,pc
+
+endp: .dw 0
#include "cpu.h"
int strcmp( char *a, char *b ){
+ return strncmp(a, b, strlen(a));
+}
+
+int strncmp( char *a, char *b, int n){
int ret;
- while (1){
+ while (n--){
ret = *a - *b++;
if( ! *a || ret )
return ret;
a++;
}
+ return 0;
}
size_t strlen(const char *p)
#define DISC __attribute__((section(".discard")))
-
+unsigned int swapdev = 0;
struct blkbuf *bufpool_end = bufpool + NBUFS;
pagemap_add(i);
/* add common page last so init gets it */
pagemap_add(6);
+ /* initialize swap pages */
+ for (i = 0; i<MAX_SWAPS; i++)
+ swapmap_add(i);
}
DISC
DISC
uint8_t platform_param(char *p)
{
- if( !strcmp(p,"NODW") ){
+ if (!strcmp(p,"NODW") ){
dwtype = DWTYPE_NOTFOUND;
return -1;
}
+ if (!strncmp(p,"SWAP=",5)){
+ swapdev = bootdevice(p+5);
+ kprintf("swap: %d\n",swapdev);
+ return -1;
+ }
return 0;
}
pshs y,u
ldy #PREG2 ; set Y to point at data reg a
ldd #64*256+4 ; A = chunk count (64), B = bytes per chunk (4)
- tst _blk_op+2 ; test user/kernel xfer
- beq wrChnk ; if zero then stay in kernel space
- jsr map_process_always ; else flip in user space
+ jsr blkdev_rawflg ; map memory based on blkopt flag
wrChnk ldu ,x ; get 2 data bytes from source
stu ,y ; send data to controller
ldu 2,x ; two more bytes..
abx ; increment X by chunk size (4)
deca ; decrement loop counter
bne wrChnk ; loop until all chunks written
- jsr map_kernel ; reset to kernel space
+ jsr blkdev_unrawflg ; reset memory
puls y,u,pc ; return
;;; Reads 256 bytes from SDC
pshs y,u
ldy #PREG2 ; set Y to point to data reg a
ldd #32*256+8 ; A = chunk count (32), B = bytes per chunk (8)
- tst _blk_op+2 ; test usr/kernel xfer
- beq rdChnk ; if zero then stay in kernel space
- jsr map_process_always ; else flip to user space
+ jsr blkdev_rawflg ; map memory based on blkopt flag
rdChnk ldu ,y ; read 1st pair of bytes for the chunk
stu ,x ; store to buffer
ldu ,y ; bytes 3 and 4 of..
abx ; increment X by chunk size (8)
deca ; decrement loop counter
bne rdChnk ; loop if more chunks to read
- jsr map_kernel ; reset to kernel space
+ jsr blkdev_unrawflg ; reset memory
puls y,u,pc ; return
.globl _chksigs
.globl _getproc
.globl _trap_monitor
+ .globl _get_common
+ .globl _swap_finish
;; exported
.globl _switchout
_ramtop:
.dw 0
-_swapstack
- .dw 0
- .dw 0
+swapstack
+ zmb 256
+swapstacktop
fork_proc_ptr:
.dw 0 ; (C type is struct p_tab *) -- address of child process p_tab entry
_switchin:
orcc #0x10 ; irq off
- stx _swapstack ; save passed page table *
+ stx swapstack ; save passed page table *
+
+ lda P_TAB__P_PAGE_OFFSET+1,x ; LSB of 16 page
+ bne notswapped ; clear
+ ;; Our choosen process is swapped out
+ jsr _get_common ; realloc dead's common page
+ ;; B is now our hand-picked common page
+
+ ; save the above as we are going to switch bank so they will
+ ; cease to be accessible if in common (we could put then in
+ ; kernel space and probably should)
+ lds #swapstacktop ; switch to swap stack
+ tfr b,a
+ inca
+ sta 0xffa7 ; transfer to new common
+ sta 0xffaf ; *poof* we now run from new common
+ ;; save our stashed page no, as pagemap will detroy it
+ ldx swapstack
+ jsr _swap_finish ; need to call swapper with
+ ;; fix up udata's copy of the page tables
+ ;; and fix up the mmu's also
+ ldx swapstack
+ ldd P_TAB__P_PAGE_OFFSET+0,x
+ std U_DATA__U_PAGE
+ sta 0xffa0
+ inca
+ sta 0xffa1
+ stb 0xffa2
+ incb
+ stb 0xffa3
+ ldd P_TAB__P_PAGE_OFFSET+2,x
+ std U_DATA__U_PAGE2
+ sta 0xffa4
+ inca
+ sta 0xffa5
+ stb 0xffa6
+ stx swapstack ; save passed page table *
;; flip in the newly choosen task's common page
+notswapped
lda P_TAB__P_PAGE_OFFSET+3,x
inca
sta 0xffa7
;; --------- No Stack ! --------------
; check u_data->u_ptab matches what we wanted
- ldx _swapstack
+ ldx swapstack
cmpx U_DATA__U_PTAB
bne switchinfail