+++ /dev/null
-
-CSRCS = devlpr.c devtty.c devrd.c
-CSRCS += devices.c main.c libc.c
-
-ASRCS = p6809.s crt0.s
-ASRCS += tricks.s commonmem.s
-
-COBJS = $(CSRCS:.c=$(BINEXT))
-AOBJS = $(ASRCS:.s=$(BINEXT))
-OBJS = $(COBJS) $(AOBJS)
-
-JUNK = $(CSRCS:.c=.o) $(ASRCS:.s=.o)
-
-all: $(OBJS)
-
-$(COBJS): %$(BINEXT): %.c
- $(CROSS_CC) $(CROSS_CCOPTS) -c $<
-
-$(AOBJS): %$(BINEXT): %.s
- $(CROSS_AS) $(ASOPTS) $< -o $*.o
-
-clean:
- rm -f $(OBJS) $(JUNK) core *~
-
-image:
- $(CROSS_LD) --raw -o ../fuzix.bin --map=../fuzix.map --script=fuzix.link \
- crt0.o commonmem.o \
- p6809.o ../start.o ../version.o ../lowlevel-6809.o \
- tricks.o main.o ../timer.o ../kdata.o devrd.o devices.o \
- ../devio.o ../filesys.o ../process.o ../inode.o ../syscall_fs.o \
- ../syscall_proc.o ../syscall_other.o ../mm.o ../swap.o ../bank16k.o \
- ../tty.o ../devsys.o ../usermem.o ../syscall_fs2.o ../syscall_exec16.o \
- ../usermem_std-6809.o devlpr.o devtty.o libc.o
+++ /dev/null
-;
-; Put the udata at the start of common. We have four 16K banks so we
-; keep the non .common kernel elements below C000 and then keep bank 3 as a
-; true common bank
-;
- .module commonmem
-
- ; exported symbols
- .globl _ub
- .globl _udata
- .globl kstack_top
- .globl istack_top
- .globl istack_switched_sp
-
- .area .udata
-
-_ub: ; first 512 bytes: starts with struct u_block, with the kernel stack working down from above
-_udata:
-kstack_base:
- zmb 512
-kstack_top:
-
- ; next 256 bytes: 254 byte interrupt stack, then 2 byte saved stack pointer
-istack_base:
- zmb 254
-istack_top:
-istack_switched_sp: .dw 0
+++ /dev/null
-/* Enable to make ^Z dump the inode table for debug */
-#undef CONFIG_IDUMP
-/* Enable to make ^A drop back into the monitor */
-#undef CONFIG_MONITOR
-/* Profil syscall support (not yet complete) */
-#define CONFIG_PROFIL
-/* Multiple processes in memory at once */
-#define CONFIG_MULTI
-/* Single tasking - for now while we get it booting */
-#undef CONFIG_SINGLETASK
-/* Use C helpers for usermem */
-#define CONFIG_USERMEM_C
-#define BANK_PROCESS *((volatile uint8_t *)0xff91) &= ~1
-#define BANK_KERNEL *((volatile uint8_t *)0xff91) |= 1
-/* We use flexible 16K banks so use the helper */
-#define CONFIG_BANK16
-#define CONFIG_BANKS 4
-#define MAX_MAPS 16
-/* And swapping */
-#define SWAPDEV 6 /* FIXME */
-#define SWAP_SIZE 0x80 /* 64K blocks */
-/* FIXME */
-#define SWAPBASE 0x0000 /* We swap the lot in one, include the */
-#define SWAPTOP 0x8000 /* 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
-
-/* Video terminal, not a serial tty */
-#define CONFIG_VT
-/* Vt definitions */
-#define VT_WIDTH 64
-#define VT_HEIGHT 24
-#define VT_RIGHT 63
-#define VT_BOTTOM 23
-
-#define TICKSPERSEC 100 /* Ticks per second */
-#define PROGBASE 0x0100 /* also data base */
-#define PROGLOAD 0x0800 /* also data base */
-#define PROGTOP 0x7000 /* Top of program, base of U_DATA */
-
-#define BOOT_TTY (512 + 1) /* Set this to default device for stdio, stderr */
- /* In this case, the default is the first TTY device */
- /* Temp FIXME set to serial port for debug ease */
-
-/* We need a tidier way to do this from the loader */
-#define CMDLINE NULL /* Location of root dev name */
-
-/* Device parameters */
-#define NUM_DEV_TTY 2
-#define NDEVS 1 /* Devices 0..NDEVS-1 are capable of being mounted */
- /* (add new mountable devices to beginning area.) */
-#define TTYDEV BOOT_TTY /* Device used by kernel for messages, panics */
-#define NBUFS 7 /* Number of block buffers */
-#define NMOUNTS 2 /* Number of mounts at a time - nothing mountable! */
-
-#define swap_map(x) ((uint8_t *)(x))
+++ /dev/null
- ; Ordering of segments for the linker.
- ; WRS: Note we list all our segments here, even though
- ; we don't use them all, because their ordering is set
- ; when they are first seen.
-
- ; imported symbols
- .globl _fuzix_main
- .globl init_early
- .globl init_hardware
- .globl kstack_top
-
- ; startup code @0
- .area .start
- jmp start
-
- .area .text
-
-start: orcc #0x10 ; interrupts definitely off
- lds #kstack_top
- ; move the common memory where it belongs
- ; we do this dowards, not out of any concern about
- ; about overlap (although its correct for this) but because
- ; it deals with linker reloc limits nicely
-; ldd #s__INITIALIZER
-; addd #l__COMMONMEM
-; tfr d,x
-; ldd #s__COMMONMEM
-; addd #l__COMMONMEM
-; tfr d,y
-
-;copier: lda ,-x
-; sta ,-y
-; cmpy #s__COMMONMEM
-; bgt copier
-
-;wiper: ldx #s__DATA
-; ldd #l__DATA
-; clr ,x+
-; subd #1
-; bne wiper
-
- jsr init_early
- jsr init_hardware
- jsr _fuzix_main
- orcc #0x10
-stop: bra stop
-
+++ /dev/null
-#ifndef __DEVICE_DOT_H__
-#define __DEVICE_DOT_H__
-
-extern void mod_control(uint8_t set, uint8_t clr);
-
-#endif /* __DEVICE_DOT_H__ */
+++ /dev/null
-#include <kernel.h>
-#include <version.h>
-#include <kdata.h>
-#include <devrd.h>
-#include <devsys.h>
-#include <devlpr.h>
-#include <tty.h>
-#include <devtty.h>
-
-struct devsw dev_tab[] = /* The device driver switch table */
-{
-// minor open close read write ioctl
-// -----------------------------------------------------------------
- /* 0: /dev/fd Floppy disc block devices */
- { rd_open, no_close, rd_read, rd_write, no_ioctl },
- /* 1: /dev/hd Hard disc block devices (absent) */
- { nxio_open, no_close, no_rdwr, no_rdwr, no_ioctl },
- /* 2: /dev/tty TTY devices */
- { tty_open, tty_close, tty_read, tty_write, tty_ioctl },
- /* 3: /dev/lpr Printer devices */
- { lpr_open, lpr_close, no_rdwr, lpr_write, no_ioctl },
- /* 4: /dev/mem etc System devices (one offs) */
- { no_open, no_close, sys_read, sys_write, sys_ioctl },
- /* Pack to 7 with nxio if adding private devices and start at 8 */
-};
-
-bool validdev(uint16_t dev)
-{
- /* This is a bit uglier than needed but the right hand side is
- a constant this way */
- if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) + 255)
- return false;
- else
- return true;
-}
-void device_init(void)
-{
-}
-
+++ /dev/null
-#include <kernel.h>
-#include <version.h>
-#include <kdata.h>
-#include <device.h>
-#include <devlpr.h>
-
-/* random test places */
-uint8_t *lpstat = (uint8_t *)0xFF00;
-uint8_t *lpdata = (uint8_t *)0xFF01;
-
-int lpr_open(uint8_t minor, uint16_t flag)
-{
- minor;
- flag; // shut up compiler
- return 0;
-}
-
-int lpr_close(uint8_t minor)
-{
- minor; // shut up compiler
- return 0;
-}
-
-int lpr_write(uint8_t minor, uint8_t rawflag, uint8_t flag)
-{
- int c = udata.u_count;
- char *p = udata.u_base;
- uint16_t ct;
-
- minor;
- rawflag;
- flag; // shut up compiler
-
- while (c-- > 0) {
- ct = 0;
-
- /* Try and balance polling and sleeping */
- while (*lpstat & 2) {
- ct++;
- if (ct == 10000) {
- udata.u_ptab->p_timeout = 3;
- if (psleep_flags(NULL, flag)) {
- if (udata.u_count)
- udata.u_error = 0;
- return udata.u_count;
- }
- ct = 0;
- }
- }
- /* Data */
- *lpdata = ugetc(p++);
- }
- return udata.u_count;
-}
+++ /dev/null
-#ifndef __DEVLPR_DOT_H__
-#define __DEVLPR_DOT_H__
-
-int lpr_open(uint8_t minor, uint16_t flag);
-int lpr_close(uint8_t minor);
-int lpr_write(uint8_t minor, uint8_t rawflag, uint8_t flag);
-
-#endif
+++ /dev/null
-/*
- * NC100 RD PCMCIA driver
- *
- */
-
-#include <kernel.h>
-#include <kdata.h>
-#include <printf.h>
-#include <devrd.h>
-
-static int rd_transfer(bool is_read, uint8_t rawflag)
-{
- blkno_t block;
- int block_xfer;
- uint16_t dptr;
- int dlen;
- int ct = 0;
- int map;
-
- /* FIXME: raw is broken unless nicely aligned */
- if(rawflag) {
- dlen = udata.u_count;
- dptr = (uint16_t)udata.u_base;
- if (((uint16_t)dptr | dlen) & BLKMASK) {
- udata.u_error = EIO;
- return -1;
- }
- block = udata.u_offset >> 9;
- block_xfer = dlen >> 9;
- map = 1;
- } else { /* rawflag == 0 */
- dlen = 512;
- dptr = (uint16_t)udata.u_buf->bf_data;
- block = udata.u_buf->bf_blk;
- block_xfer = 1;
- map = 0;
- }
- block += 2*320; /* ramdisc starts at 320K in */
-
- while (ct < block_xfer) {
-/* rd_memcpy(is_read, map, dptr, block); */
- block++;
- ct++;
- }
- return ct;
-}
-
-int rd_open(uint8_t minor, uint16_t flag)
-{
- flag;
- if(minor != 0) {
- udata.u_error = ENODEV;
- return -1;
- }
- return 0;
-}
-
-int rd_read(uint8_t minor, uint8_t rawflag, uint8_t flag)
-{
- flag;minor;
- return rd_transfer(true, rawflag);
-}
-
-int rd_write(uint8_t minor, uint8_t rawflag, uint8_t flag)
-{
- flag;minor;
- return rd_transfer(false, rawflag);
-}
-
+++ /dev/null
-#ifndef __DEVRD_DOT_H__
-#define __DEVRD_DOT_H__
-
-/* public interface */
-int rd_read(uint8_t minor, uint8_t rawflag, uint8_t flag);
-int rd_write(uint8_t minor, uint8_t rawflag, uint8_t flag);
-int rd_open(uint8_t minor, uint16_t flag);
-
-/* asm banking helper */
-void rd_memcpy(uint8_t isread, uint8_t map, uint16_t dptr, uint16_t block);
-
-#endif /* __DEVRD_DOT_H__ */
-
+++ /dev/null
-#include <kernel.h>
-#include <kdata.h>
-#include <printf.h>
-#include <stdbool.h>
-#include <devtty.h>
-#include <device.h>
-#include <vt.h>
-#include <tty.h>
-
-#undef DEBUG /* UNdefine to delete debug code sequences */
-
-uint8_t *uarta = (uint8_t *)0xFF04;
-uint8_t *uartb = (uint8_t *)0xFF05;
-
-char tbuf1[TTYSIZ];
-char tbuf2[TTYSIZ];
-
-struct s_queue ttyinq[NUM_DEV_TTY + 1] = { /* ttyinq[0] is never used */
- {NULL, NULL, NULL, 0, 0, 0},
- {tbuf1, tbuf1, tbuf1, TTYSIZ, 0, TTYSIZ / 2},
- {tbuf2, tbuf2, tbuf2, TTYSIZ, 0, TTYSIZ / 2}
-};
-
-static void nap(void)
-{
-}
-
-/* tty1 is the screen tty2 is the serial port */
-
-/* Output for the system console (kprintf etc) */
-void kputchar(char c)
-{
- if (c == '\n')
- tty_putc(1, '\r');
- tty_putc(1, c);
-}
-
-ttyready_t tty_writeready(uint8_t minor)
-{
- uint8_t c;
- if (minor == 1)
- return TTY_READY_NOW;
- c = *uartb;
- return (c & 1) ? TTY_READY_NOW : TTY_READY_SOON;
-}
-
-void tty_putc(uint8_t minor, unsigned char c)
-{
- minor;
-#if 0
- if (minor == 1) {
- vtoutput(&c, 1);
- return;
- }
-#endif
- *uarta = c;
-}
-
-void tty_sleeping(uint8_t minor)
-{
- used(minor);
-}
-
-void tty_setup(uint8_t minor)
-{
- minor;
-}
-
-/* For the moment */
-int tty_carrier(uint8_t minor)
-{
- minor;
- return 1;
-}
-
-void platform_interrupt(void)
-{
- timer_interrupt();
-}
-
-/* This is used by the vt asm code, but needs to live at the top of the kernel */
-uint16_t cursorpos;
+++ /dev/null
-#ifndef __DEVTTY_DOT_H__
-#define __DEVTTY_DOT_H__
-
-extern int nc100_tty_open(uint8_t minor, uint16_t flag);
-extern int nc100_tty_close(uint8_t minor);
-extern void nc100_tty_init(void);
-#endif
+++ /dev/null
-; UZI mnemonics for memory addresses etc
-
-U_DATA equ 0xF000 ; (this is struct u_data from kernel.h)
-U_DATA__TOTALSIZE equ 0x300 ; 256+256+256 bytes.
-
-SAM_USER macro
- endm
-
-SAM_KERNEL macro
- endm
-
-SAM_SAVE macro
- endm
-
-SAM_RESTORE macro
- endm
-
+++ /dev/null
-#include "cpu.h"
-
-void *memcpy(void *d, const void *s, size_t sz)
-{
- unsigned char *dp, *sp;
- while(sz--)
- *dp++=*sp++;
- return d;
-}
-
-void *memset(void *d, int c, size_t sz)
-{
- unsigned char *p = d;
- while(sz--)
- *p++ = c;
- return d;
-}
-
-size_t strlen(const char *p)
-{
- const char *e = p;
- while(*e++);
- return e-p-1;
-}
-
+++ /dev/null
-#include <kernel.h>
-#include <timer.h>
-#include <kdata.h>
-#include <printf.h>
-#include <devtty.h>
-
-void platform_idle(void)
-{
-}
-
-void do_beep(void)
-{
-}
-
-/*
- * Map handling: We have flexible paging. Each map table consists of a set of pages
- * with the last page repeated to fill any holes.
- */
-
-void pagemap_init(void)
-{
- int i;
- /* 0/1/2 image, 3/4/5 kernel 6-19 apps */
- /* Don't add page 6 yet - it's the initial common at boot */
- for (i = 0x80 + 7; i < 0x80 + 20; i++)
- pagemap_add(i);
- /*
- * The kernel boots with 0x86 as the common, list it last here so it also
- * gets given to init as the kernel kicks off the init stub. init will then
- * exec preserving this common and all forks will be copies from it.
- */
- pagemap_add(0x86);
-}
-
-void map_init(void)
-{
-}
+++ /dev/null
-;
-; 6809 Simulation Platform
-;
-
- .module p6809
-
- ; exported symbols
- .globl init_early
- .globl init_hardware
- .globl interrupt_handler
- .globl _program_vectors
- .globl map_kernel
- .globl map_process
- .globl map_process_always
- .globl map_save
- .globl map_restore
- .globl _kernel_flag
-
- ; exported debugging tools
- .globl _trap_monitor
- .globl outchar
- .globl _di
- .globl _ei
- .globl _irqrestore
-
- ; imported symbols
- .globl _ramsize
- .globl _procmem
- .globl unix_syscall_entry
- .globl nmi_handler
-
- include "kernel.def"
- include "../kernel09.def"
-
-; -----------------------------------------------------------------------------
-; COMMON MEMORY BANK (0xF000 upwards)
-; -----------------------------------------------------------------------------
- .area .common
-
-trapmsg: .ascii "Trapdoor: SP="
- .db 0
-trapmsg2: .ascii ", PC="
- .db 0
-tm_user_sp: .dw 0
-
-_trap_monitor:
- orcc #0x10
- bra _trap_monitor
-
-_trap_reboot:
- lda 0xff90
- anda #0xfc ; map in the ROM
- jmp 0
-
-_di:
- tfr cc,b ; return the old irq state
- orcc #0x10
- rts
-_ei:
- andcc #0xef
- rts
-
-_irqrestore: ; B holds the data
- tfr b,cc
- rts
-
-; -----------------------------------------------------------------------------
-; KERNEL MEMORY BANK (below 0xF000, only accessible when the kernel is mapped)
-; -----------------------------------------------------------------------------
- .area .text
-
-init_early:
- rts
-
-init_hardware:
- ; set system RAM size
- ldd #256
- std _ramsize
- ldd #192
- std _procmem
-
- ; Our vectors are in high memory unlike Z80 but we still
- ; need vectors
- ldx #0
- jsr _program_vectors
-
- rts
-
-
-;------------------------------------------------------------------------------
-; COMMON MEMORY PROCEDURES FOLLOW
-
- .area .common
-
-_program_vectors:
- ;
- ; Note: we must install an NMI handler on the NC100 FIXME
- ;
-
- ; we are called, with interrupts disabled, by both newproc() and crt0
- ; will exit with interrupts off
- orcc #0x10 ; di just to be sure
-
- jsr map_process
-
- ldx #0xFFF2
- ldd #badswi_handler
- std ,y++
- std ,y++ ; SWI2 and 3 both bad SWI
- ldd #firq_handler
- std ,y++
- ldd #interrupt_handler
- std ,y++
- ldd #unix_syscall_entry
- stx ,y++
- ldd #nmi_handler
- stx ,y
- jsr map_kernel
- rts
-
-;
-; FIXME:
-;
-firq_handler:
-badswi_handler:
- rti
-
-;
-; Userspace mapping pages 7+ kernel mapping pages 3-5, first common 6
-;
-;
-; All registers preserved
-;
-map_process_always:
- pshs y,u
- ldx #U_DATA__U_PAGE
- jsr map_process_2
- puls y,u,pc
-;
-; HL is the page table to use, A is eaten, HL is eaten
-;
-map_process:
- cmpx #0
- bne map_process_2
-;
-; Map in the kernel below the current common, all registers preserved
-;
-map_kernel:
-;
-; Two MMU mappings is pure luxury
-;
-; Kernel map was set up by boot loader, just flip to it
-;
- lda 0xff91 ; INIT1, use 0xFFA8 maps
- ora #0x01
- sta 0xff91
- rts
-;
-; User is in the FFA0 map with the top 8K as common
-;
-; As the core code currently does 16K happily but not 8 we just pair
-; up pages
-;
-map_process_2:
- pshs x,y,a
- ldy #0xffa0 ; MMU user map. We can fiddle with
- lda ,x+ ; this to our hearts content
- sta ,y+ ; as it's not live yet
- inca
- sta ,y+
- lda ,x+
- sta ,y+
- inca
- sta ,y+
- lda ,x+
- sta ,y+
- inca
- sta ,y+
- lda ,x+
- sta ,y+
- inca
- sta ,y
- lda 0xff91
- anda #0xfe
- sta 0xff91 ; new mapping goes live here
- puls x,y,a,pc ; so had better include common!
-;
-; Restore a saved mapping. We are guaranteed that we won't switch
-; common copy between save and restore. Preserve all registers
-;
-; We cheat somewhat. We have two mapping sets, so just remember
-; which space we were in. Note: we could be in kernel in either
-; space while doing user copies
-;
-map_restore:
- pshs a
- lda 0xff91
- ora saved_map
- sta 0xff91
- puls a,pc
-
-;
-; Save the current mapping.
-;
-map_save:
- pshs a
- lda 0xff91
- anda #1
- sta saved_map
- puls a,pc
-
-saved_map: .db 0
-
-
-; outchar: Wait for UART TX idle, then print the char in a
-
-outchar:
- pshs b
-outcharw:
- ldb 0xffa0
- bitb #0x02
- beq outcharw
- sta 0xffa1
- puls b,pc
-
- .area .data
-_kernel_flag: .db 1
+++ /dev/null
-;
-; 6809 version
-;
- .module tricks
-
- .globl _newproc
- .globl _chksigs
- .globl _getproc
- .globl _trap_monitor
- .globl _inint
- .globl _switchout
- .globl _switchin
- .globl _dofork
- .globl _ramtop
-
-
- include "kernel.def"
- include "../kernel09.def"
-
- .area .common
-
-; ramtop must be in common for single process swapping cases
-; and its a constant for the others from before init forks so it'll be fine
-; here
-_ramtop:
- .dw 0
-
-; Switchout switches out the current process, finds another that is READY,
-; possibly the same process, and switches it in. When a process is
-; restarted after calling switchout, it thinks it has just returned
-; from switchout().
-;
-; FIXME: make sure we optimise the switch to self case higher up the stack!
-;
-; This function can have no arguments or auto variables.
-_switchout:
- orcc #0x10 ; irq off
- jsr _chksigs
-
- ; save machine state
- ldd #0 ; return code set here is ignored, but _switchin can
- ; return from either _switchout OR _dofork, so they must both write
- ; U_DATA__U_SP with the following on the stack:
- pshs d
- sts U_DATA__U_SP
-
- ; set inint to false
- lda #0
- sta _inint
-
- ; find another process to run (may select this one again) returns it
- ; in X
- jsr _getproc
- jsr _switchin
- ; we should never get here
- jsr _trap_monitor
-
-badswitchmsg: .ascii "_switchin: FAIL"
- .db 13
- .db 10
- .db 0
-
-; new process pointer is in X
-_switchin:
- orcc #0x10 ; irq off
-
- ldy P_TAB__P_PAGE_OFFSET+3,x
- ; FIXME: can we skip the usermaps here ?
- stx 0xffa6 ; map the process uarea we want
- adda #1
- stx 0xffa7
- stx 0xffaf ; and include the kernel mapping
-
- ; ------- No stack -------
- ; check u_data->u_ptab matches what we wanted
- cmpx U_DATA__U_PTAB
- bne switchinfail
-
- ; wants optimising up a bit
- lda #P_RUNNING
- sta P_TAB__P_STATUS_OFFSET,x
-
- lda #0
- sta _runticks
-
- ; restore machine state -- note we may be returning from either
- ; _switchout or _dofork
- lds U_DATA__U_SP
-
- puls x ; return code
-
- ; enable interrupts, if the ISR isn't already running
- lda _inint
- beq swtchdone ; in ISR, leave interrupts off
- andcc #0xef
-swtchdone:
- rts
-
-switchinfail:
- jsr outx
- ldx #badswitchmsg
- jsr outstring
- ; something went wrong and we didn't switch in what we asked for
- jmp _trap_monitor
-
-fork_proc_ptr: .dw 0 ; (C type is struct p_tab *) -- address of child process p_tab entry
-
-;
-; Called from _fork. We are in a syscall, the uarea is live as the
-; parent uarea. The kernel is the mapped object.
-;
-_dofork:
- ; always disconnect the vehicle battery before performing maintenance
- orcc #0x10 ; should already be the case ... belt and braces.
-
- ; new process in X, get parent pid into y
-
- stx fork_proc_ptr
- ldy P_TAB__P_PID_OFFSET,x
-
- ; Save the stack pointer and critical registers.
- ; When this process (the parent) is switched back in, it will be as if
- ; it returns with the value of the child's pid.
- pshs y ; y has p->p_pid from above, the return value in the parent
-
- ; save kernel stack pointer -- when it comes back in the parent we'll be in
- ; _switchin which will immediately return (appearing to be _dofork()
- ; returning) and with HL (ie return code) containing the child PID.
- ; Hurray.
- sts U_DATA__U_SP
-
- ; now we're in a safe state for _switchin to return in the parent
- ; process.
-
- ; --------- we switch stack copies in this call -----------
- jsr fork_copy ; copy 0x000 to udata.u_top and the
- ; uarea and return on the childs
- ; common
- ; We are now in the kernel child context
-
- ; now the copy operation is complete we can get rid of the stuff
- ; _switchin will be expecting from our copy of the stack.
- puls y
-
- ldx fork_proc_ptr
- jsr _newproc
-
- ; any calls to map process will now map the childs memory
-
- ; runticks = 0;
- clr _runticks
- ; in the child process, fork() returns zero.
- ;
- ; And we exit, with the kernel mapped, the child now being deemed
- ; to be the live uarea. The parent is frozen in time and space as
- ; if it had done a switchout().
- rts
-
-fork_copy:
- ldd U_DATA__U_TOP
- addd #0x0fff ; + 0x1000 (-1 for the rounding to follow)
- lsra
- lsra
- lsra
- lsra
- lsra ; bits 2/1 for 8K pages
- anda #6 ; lose bit 0
- adda #2 ; and round up to the next bank (but in 8K terms)
-
- ldx fork_proc_ptr
- ldy P_TAB__P_PAGE_OFFSET,x
- ; y now points to the child page pointers
- ldx U_DATA__U_PAGE
- ; and x to the parent
-fork_next:
-; ld a,(hl)
-; out (0x11), a ; 0x4000 map the child
-; ld c, a
-; inc hl
-; ld a, (de)
-; out (0x12), a ; 0x8000 maps the parent
-; inc de
-; exx
-; ld hl, #0x8000 ; copy the bank
-; ld de, #0x4000
-; ld bc, #0x4000 ; we copy the whole bank, we could optimise
-; ; further
-; ldir
-; exx
-; call map_kernel ; put the maps back so we can look in p_tab
-; FIXME: can't map_kernel here - we've been playing with the maps, fix
-; directly
- suba #1
- bne fork_next
-
-; ld a, c
-; out (0x13), a ; our last bank repeats up to common
- ; --- we are now on the stack copy, parent stack is locked away ---
- rts ; this stack is copied so safe to return on
-
-