Mercurial > hg > Members > kono > nitros9-code
changeset 3123:039ddb7c8ad7
l2 kernel: Remove tabs and trailing whitespace, align comments
No functional change (no change to generated binaries).
line wrap: on
line diff
--- a/level2/modules/kernel/ccbfnproc.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/ccbfnproc.asm Mon Nov 28 08:31:26 2016 +0000 @@ -7,7 +7,7 @@ * * Output: Control does not return to the caller * -FNProc +FNProc IFGT Level-1 ldx <D.SysPrc get system process descriptor stx <D.Proc save it as current @@ -18,7 +18,7 @@ clrb std <D.Proc ENDC - fcb $8C skip the next 2 bytes + fcb $8C skip the next 2 bytes L0D91 cwai #^IntMasks re-enable IRQ's and wait for one L0D93 orcc #IntMasks Shut off interrupts again @@ -83,13 +83,13 @@ ldu <D.UsrIRQ Get IRQ entry point for user state stu <D.XIRQ Save as IRQ service routine ptr - ldb P$Task,x get task number - lslb 2 bytes per entry in D.TskIpt - ldy P$SP,x get stack pointer - lbsr L0E8D re-map the DAT image, if necessary + ldb P$Task,x get task number + lslb 2 bytes per entry in D.TskIpt + ldy P$SP,x get stack pointer + lbsr L0E8D re-map the DAT image, if necessary - ldb <D.Quick get quick return flag - lbra L0E4C Go switch GIME over to new process & run + ldb <D.Quick get quick return flag + lbra L0E4C Go switch GIME over to new process & run * Process a signal (process had no signal trap) L0DFD equ * @@ -100,10 +100,10 @@ orb #SysState stb P$State,x ENDC - leas >P$Stack,x Point SP to process' stack - andcc #^IntMasks Turn interrupts on - ldb <P$Signal,x Get signal that process received - clr <P$Signal,x Clear out the one in process dsc. - os9 F$Exit Exit with signal # being error code + leas >P$Stack,x Point SP to process' stack + andcc #^IntMasks Turn interrupts on + ldb <P$Signal,x Get signal that process received + clr <P$Signal,x Clear out the one in process dsc. + os9 F$Exit Exit with signal # being error code -S.SvcIRQ jmp [>D.Poll] Call IOMAN for IRQ polling +S.SvcIRQ jmp [>D.Poll] Call IOMAN for IRQ polling
--- a/level2/modules/kernel/ccbfsrqmem.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/ccbfsrqmem.asm Mon Nov 28 08:31:26 2016 +0000 @@ -26,7 +26,7 @@ addd #$00FF round it up to nearest 256 byte page (e.g. $1FF = $2FE) clrb just keep # of pages (and start 8K block #, e.g. $2FE = $200) std R$D,u save rounded version back to user -* leay Bt.Start/256,y +* leay Bt.Start/256,y * leay $20,y skip Block 0 (always reserved for system) * Change to pshs a,b:use 1,s for block # to check, and ,s for TFM spot * incb skip block 0 (always reserved for system) @@ -61,8 +61,8 @@ ldw #$0020 Get size of 8K block in pages tfm s,y+ Mark entire block's worth of pages with A ELSE -L0848 ldb #32 count = 32 pages -L084A sta ,y+ mark the RAM +L0848 ldb #32 count = 32 pages +L084A sta ,y+ mark the RAM decb bne L084A ENDC @@ -79,10 +79,10 @@ * (Already permanently marked @ L01D2) * At the start, Y is pointing to the end of the SMAP table+1 ldx <D.SysMem Get start of table ptr - * CCB change - start scanning from f000 down, rather than ec00 + * CCB change - start scanning from f000 down, rather than ec00 * leay Bt.Start/256,x - leay $ff00/256,x - * end of CCB change + leay $ff00/256,x + * end of CCB change ldb #32 skip block 0: it's always full abx same size, but faster than leax $20,x * leay -(256-(Bt.Start>>8)),y skip Kernel, Vector RAM & I/O (Can't be free) @@ -107,18 +107,18 @@ sty ,s Found free contiguous pages, save SMAP entry ptr lda 1,s Get LSB of ptr lsra Divide by 32 (Calculate start 8K block #) - lsra - lsra - lsra - lsra + lsra + lsra + lsra + lsra ldb 1,s Get LSB of ptr again andb #%00011111 Keep only within 8K block offset addb R$A,u Add # pages requested addb #$1F Round up to nearest 8K block lsrb Divide by 32 (Calculate end 8K block #) - lsrb - lsrb - lsrb + lsrb + lsrb + lsrb lsrb ldx <D.SysPrc Get ptr to system proc. dsc. lbsr L09BE Allocate an image with our start/end block #'s @@ -168,7 +168,7 @@ andb #^RAMinUse stb ,x+ ENDC - deca + deca bne L08AD * Scan DAT image to find memory blocks to free up ldx <D.SysDAT get pointer to system DAT image @@ -186,10 +186,10 @@ bne L08EC no, move to next block tfr x,d subd <D.SysDAT - lslb - lslb - lslb - lslb + lslb + lslb + lslb + lslb ldu <D.SysMem get pointer to system map IFNE H6309 addr d,u @@ -242,11 +242,11 @@ * Error: CC = C bit set; B = error code * FBoot - ** CCB change: just panic + ** CCB change: just panic lda #'t tried to boot jsr <D.BtBug - jmp <D.Crash - ** + jmp <D.Crash + ** coma Set boot flag lda <D.Boot we booted once before? bne L08F3 Yes, return @@ -263,34 +263,34 @@ L0908 leax <boot,pcr * Link to module and execute L090C lda #Systm+Objct - os9 F$Link + os9 F$Link bcs L08F3 - lda #'b calling boot + lda #'b calling boot jsr <D.BtBug jsr ,y load boot file bcs L08F3 std <D.BtSz save boot file size stx <D.BtPtr save start pointer of bootfile - lda #'b boot returns OK + lda #'b boot returns OK jsr <D.BtBug * added for IOMan system memory extentions IFNE H6309 - ldd M$Name,x grab the name offset - ldd d,x find the first 2 bytes of the first module - cmpd #$4E69 'Ni' ? (NitrOS9 module?) - bne not.ext no, not system memory extensions - ldd M$Exec,x grab the execution ptr - jmp d,x and go execute the system memory extension module + ldd M$Name,x grab the name offset + ldd d,x find the first 2 bytes of the first module + cmpd #$4E69 'Ni' ? (NitrOS9 module?) + bne not.ext no, not system memory extensions + ldd M$Exec,x grab the execution ptr + jmp d,x and go execute the system memory extension module ENDC not.ext ldd <D.BtSz - bsr I.VBlock internal verify block routine + bsr I.VBlock internal verify block routine ldx <D.SysDAT get system DAT pointer - ldb $0D,x get highest allocated block number - incb allocate block 0, too - ldx <D.BlkMap point to the memory block map - lbra L01DF and go mark the blocks as used. + ldb $0D,x get highest allocated block number + incb allocate block 0, too + ldx <D.BlkMap point to the memory block map + lbra L01DF and go mark the blocks as used. ************************************************** @@ -303,39 +303,39 @@ * * Output: None * -* Error: CC = C bit set; B = error code +* Error: CC = C bit set; B = error code * -FVBlock ldd R$D,u size of block to verify - ldx R$X,u start address to verify +FVBlock ldd R$D,u size of block to verify + ldx R$X,u start address to verify -I.VBlock leau d,x point to end of bootfile - tfr x,d transfer start of block to D - anda #$E0 - clrb D is now block number - pshs d,u save starting block and end of block - lsra - lsra - lsra - lsra A is now logical block * 2 - ldy <D.SysDAT get pointer to system DAT - leay a,y y is pointer of sys block map of start of block -L092D ldd M$ID,x get module ID - cmpd #M$ID12 legal ID? - bne L0954 no, keep looking +I.VBlock leau d,x point to end of bootfile + tfr x,d transfer start of block to D + anda #$E0 + clrb D is now block number + pshs d,u save starting block and end of block + lsra + lsra + lsra + lsra A is now logical block * 2 + ldy <D.SysDAT get pointer to system DAT + leay a,y y is pointer of sys block map of start of block +L092D ldd M$ID,x get module ID + cmpd #M$ID12 legal ID? + bne L0954 no, keep looking - ldd M$Name,x find name offset pointer + ldd M$Name,x find name offset pointer pshs x leax d,x -name.prt lda ,x+ get first character of the name - jsr <D.BtBug print it out +name.prt lda ,x+ get first character of the name + jsr <D.BtBug print it out bpl name.prt - lda #C$SPAC a space + lda #C$SPAC a space jsr <D.BtBug puls x IFNE H6309 - ldd ,s offset into block - subr d,x make X=offset into block + ldd ,s offset into block + subr d,x make X=offset into block ELSE tfr x,d subd ,s @@ -357,7 +357,7 @@ bne L0954 L094E ldd M$Size,x leax d,x - fcb $8C skip 2 bytes + fcb $8C skip 2 bytes L0954 leax 1,x move to next byte L0956 cmpx 2,s gone thru whole bootfile?
--- a/level2/modules/kernel/ccbkrn.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/ccbkrn.asm Mon Nov 28 08:31:26 2016 +0000 @@ -21,1019 +21,1019 @@ * 19r9 2004/07/12 Boisy G. Pitre * F$SRqMem now properly scans the DAT images of the system to update * the D.SysMem map. - - nam krn - ttl NitrOS-9 Level 2 Kernel - - use defsfile - + + nam krn + ttl NitrOS-9 Level 2 Kernel + + use defsfile + * defines for customizations -Revision set 9 module revision -Edition set 19 module Edition -Where equ $F000 absolute address of where Kernel starts in memory - - mod eom,MName,Systm,ReEnt+Revision,entry,0 +Revision set 9 module revision +Edition set 19 module Edition +Where equ $F000 absolute address of where Kernel starts in memory + + mod eom,MName,Systm,ReEnt+Revision,entry,0 + + * CCB Change: module name changes to CCBKrn +MName fcs /CCBKrn/ + fcb Edition - * CCB Change: module name changes to CCBKrn -MName fcs /CCBKrn/ - fcb Edition - - * CCB Change: added a automagic "fill" directive - * between the end of the kernel module, proper, and the fe page code - * see way down. Manually refilling the empty space after each - * code change was a pain and error prone. BG - + * CCB Change: added a automagic "fill" directive + * between the end of the kernel module, proper, and the fe page code + * see way down. Manually refilling the empty space after each + * code change was a pain and error prone. BG + * FILL - all unused bytes are now here -* fcc /www.nitros9.org / -* fcc /www.nitros9.org / -* fcc /www.ni/ -* fcc /w/ -* fcc /w/ -* fcc /w/ -* IFNE H6309 -* fcc /www.nitros9.org / -* fcc /www.nitros9.org / -* fcc /www/ -* ELSE -* fcc /www.nit/ -* ENDC - +* fcc /www.nitros9.org / +* fcc /www.nitros9.org / +* fcc /www.ni/ +* fcc /w/ +* fcc /w/ +* fcc /w/ +* IFNE H6309 +* fcc /www.nitros9.org / +* fcc /www.nitros9.org / +* fcc /www/ +* ELSE +* fcc /www.nit/ +* ENDC + * Might as well have this here as just past the end of Kernel... DisTable - fdb L0CD2+Where D.Clock absolute address at the start - fdb XSWI3+Where D.XSWI3 - fdb XSWI2+Where D.XSWI2 - fdb D.Crash D.XFIRQ crash on an FIRQ - fdb XIRQ+Where D.XIRQ - fdb XSWI+Where D.XSWI - fdb D.Crash D.XNMI crash on an NMI - fdb $0055 D.ErrRst ??? Not used as far as I can tell - fdb Sys.Vec+Where Initial Kernel system call vector -DisSize equ *-DisTable + fdb L0CD2+Where D.Clock absolute address at the start + fdb XSWI3+Where D.XSWI3 + fdb XSWI2+Where D.XSWI2 + fdb D.Crash D.XFIRQ crash on an FIRQ + fdb XIRQ+Where D.XIRQ + fdb XSWI+Where D.XSWI + fdb D.Crash D.XNMI crash on an NMI + fdb $0055 D.ErrRst ??? Not used as far as I can tell + fdb Sys.Vec+Where Initial Kernel system call vector +DisSize equ *-DisTable * DO NOT ADD ANYTHING BETWEEN THESE 2 TABLES: see code using 'SubSiz', below -LowSub equ $0160 start of low memory subroutines -SubStrt equ * +LowSub equ $0160 start of low memory subroutines +SubStrt equ * * D.Flip0 - switch to system task 0 -R.Flip0 equ * - IFNE H6309 - aim #$FE,<D.TINIT map type 0 - lde <D.TINIT another 2 bytes saved if GRFDRV does: tfr cc,e - ste >DAT.Task and we can use A here, instead of E - ELSE - pshs a - lda <D.TINIT - anda #$FE - sta <D.TINIT - sta >DAT.Task - puls a - ENDC - clr <D.SSTskN - tfr x,s - tfr a,cc - rts -SubSiz equ *-SubStrt +R.Flip0 equ * + IFNE H6309 + aim #$FE,<D.TINIT map type 0 + lde <D.TINIT another 2 bytes saved if GRFDRV does: tfr cc,e + ste >DAT.Task and we can use A here, instead of E + ELSE + pshs a + lda <D.TINIT + anda #$FE force TR=0 + sta <D.TINIT + sta >DAT.Task + puls a + ENDC + clr <D.SSTskN + tfr x,s + tfr a,cc + rts +SubSiz equ *-SubStrt * Don't add any code here: See L0065, below. * Interrupt service routine -Vectors jmp [<-(D.SWI3-D.XSWI3),x] (-$10) (Jmp to 2ndary vector) - +Vectors jmp [<-(D.SWI3-D.XSWI3),x] (-$10) (Jmp to 2ndary vector) + * Let's start by initializing system page -entry equ * - * CCB Addition - save stacked OS9Boot size and make a dummy kernel printer - pulu d pull boot file size from CoCoBoot and - std <D.BtSz save to direct page for later use - inc <D.Boot mark boot attempted flag - inc <D.Speed mark high speed - lds #$1fff reset system stack (s/b 0x2000 ?!?!) - lda #$7e put code in DP so rest of kernel can - sta <D.BtBug call kernel printing routine - leax BtDebug,pc - stx <D.BtBug+1 - sta <D.Crash and do the same with the kernel crash - leax Crash,pc code - stx <D.Crash+1 - bra CCBEND jump over new kprint & crash routines +entry equ * + * CCB Addition - save stacked OS9Boot size and make a dummy kernel printer + pulu d pull boot file size from CoCoBoot and + std <D.BtSz save to direct page for later use + inc <D.Boot mark boot attempted flag + inc <D.Speed mark high speed + lds #$1fff reset system stack (s/b 0x2000 ?!?!) + lda #$7e put code in DP so rest of kernel can + sta <D.BtBug call kernel printing routine + leax BtDebug,pc + stx <D.BtBug+1 + sta <D.Crash and do the same with the kernel crash + leax Crash,pc code + stx <D.Crash+1 + bra CCBEND jump over new kprint & crash routines - * This is a kernel print routine - * This is added to replace the same routine found in "rel.asm" - * so we get debug output. - * Takes A - charactor to print - * modifies - nothing -BtDebug pshs cc,d,x save the register - orcc #IntMasks turn IRQ's off - ldb #$3b block to map in - stb >$FFA0 map the boot screen into block 0 - ldx >$0002 where to put the bytes - sta ,x+ put the character on-screen - stx >$0002 save updated address - clr >$FFA0 map block 0 in again - puls cc,d,x,pc restore and return - * This routine just prints "!" and loops forever -Crash lda #'! print a "!" - jsr <D.BtBug -e bra e loop forever + * This is a kernel print routine + * This is added to replace the same routine found in "rel.asm" + * so we get debug output. + * Takes A - charactor to print + * modifies - nothing +BtDebug pshs cc,d,x save the register + orcc #IntMasks turn IRQ's off + ldb #$3b block to map in + stb >$FFA0 map the boot screen into block 0 + ldx >$0002 where to put the bytes + sta ,x+ put the character on-screen + stx >$0002 save updated address + clr >$FFA0 map block 0 in again + puls cc,d,x,pc restore and return + * This routine just prints "!" and loops forever +Crash lda #'! print a "!" + jsr <D.BtBug +e bra e loop forever CCBEND - * end of CCB Addition + * end of CCB Addition - * This code clears the rest of the low block - * rel.asm/cocoboot has cleared the DP already. - IFNE H6309 - ldq #$01001f00 start address to clear & # bytes to clear - leay <entry+2,pc point to a 0 - tfm y,d+ - std <D.CCStk set pointer to top of global memory to $2000 - lda #$01 set task user table to $0100 - ELSE - ldx #$100 - ldy #$2000-$100 - clra - clrb -L001C std ,x++ - leay -2,y - bne L001C - stx <D.CCStk Set pointer to top of global memory to $2000 - inca D = $0100 - ENDC - + * This code clears the rest of the low block + * rel.asm/cocoboot has cleared the DP already. + IFNE H6309 + ldq #$01001f00 start address to clear & # bytes to clear + leay <entry+2,pc point to a 0 + tfm y,d+ + std <D.CCStk set pointer to top of global memory to $2000 + lda #$01 set task user table to $0100 + ELSE + ldx #$100 + ldy #$2000-$100 + clra + clrb +L001C std ,x++ + leay -2,y + bne L001C + stx <D.CCStk Set pointer to top of global memory to $2000 + inca D = $0100 + ENDC + * Setup system direct page variables - std <D.Tasks set Task Structure pointer to 0x100 - addb #$20 set Task image table pointer to $0120 - std <D.TskIPt - clrb set memory block map pointer to $0200 - inca - std <D.BlkMap - addb #$40 set second block map pointer to $0240 - std <D.BlkMap+2 - clrb set system service dispatch table - inca pointer to 0x300 - std <D.SysDis - inca set user dispatch table pointer to $0400 - std <D.UsrDis - inca set process descriptor block pointer to $0500 - std <D.PrcDBT - inca set system process descriptor pointer to $0600 - std <D.SysPrc - std <D.Proc set user process descriptor pointer to $0600 - adda #$02 set stack pointer to $0800 - tfr d,s - inca set system stack base pointer to $0900 - std <D.SysStk - std <D.SysMem set system memory map ptr $0900 - inca set module directory start ptr to $0a00 - std <D.ModDir - std <D.ModEnd set module directory end ptr to $0a00 - adda #$06 set secondary module directory start to $1000 - std <D.ModDir+2 - std <D.ModDAT set module directory DAT pointer to $1000 - std <D.CCMem set pointer to beginning of global memory to $1000 + std <D.Tasks set Task Structure pointer to 0x100 + addb #$20 set Task image table pointer to $0120 + std <D.TskIPt + clrb set memory block map pointer to $0200 + inca + std <D.BlkMap + addb #$40 set second block map pointer to $0240 + std <D.BlkMap+2 + clrb set system service dispatch table + inca pointer to 0x300 + std <D.SysDis + inca set user dispatch table pointer to $0400 + std <D.UsrDis + inca set process descriptor block pointer to $0500 + std <D.PrcDBT + inca set system process descriptor pointer to $0600 + std <D.SysPrc + std <D.Proc set user process descriptor pointer to $0600 + adda #$02 set stack pointer to $0800 + tfr d,s + inca set system stack base pointer to $0900 + std <D.SysStk + std <D.SysMem set system memory map ptr $0900 + inca set module directory start ptr to $0a00 + std <D.ModDir + std <D.ModEnd set module directory end ptr to $0a00 + adda #$06 set secondary module directory start to $1000 + std <D.ModDir+2 + std <D.ModDAT set module directory DAT pointer to $1000 + std <D.CCMem set pointer to beginning of global memory to $1000 * In following line, CRC=ON if it is STA <D.CRC, CRC=OFF if it is a STB <D.CRC - stb <D.CRC set CRC checking flag to off - + stb <D.CRC set CRC checking flag to off + * Initialize interrupt vector tables, move pointer data down to DP * CCB Change: * this line was an error? -* leay <DisTable,pcr - leay DisTable,pcr point to table of absolute vector addresses +* leay <DisTable,pcr + leay DisTable,pcr point to table of absolute vector addresses * * - ldx #D.Clock where to put it in memory - IFNE H6309 - ldf #DisSize size of the table - E=0 from TFM, above - tfm y+,x+ move it over - ELSE - ldb #DisSize + ldx #D.Clock where to put it in memory + IFNE H6309 + ldf #DisSize size of the table - E=0 from TFM, above + tfm y+,x+ move it over + ELSE + ldb #DisSize l@ - lda ,y+ load a byte from source - sta ,x+ store a byte to dest - decb bump counter - bne l@ loop if we're not done - ENDC - + lda ,y+ load a byte from source + sta ,x+ store a byte to dest + decb bump counter + bne l@ loop if we're not done + ENDC + * initialize D.Flip0 routine in low memory, move funtion down to low * memory. * Y=ptr to R.Flip0 already * leay >R.Flip0,pc - ldu #LowSub move to 0x160 - stu <D.Flip0 store fuction pointer to DP area - IFNE H6309 - ldf #SubSiz size of it - tfm y+,u+ copy it over - ELSE - ldb #SubSiz -Loop2 lda ,y+ load a byte from source - sta ,u+ and save to destination - decb bump counter - bne Loop2 loop if not done - ENDC - + ldu #LowSub move to 0x160 + stu <D.Flip0 store fuction pointer to DP area + IFNE H6309 + ldf #SubSiz size of it + tfm y+,u+ copy it over + ELSE + ldb #SubSiz +Loop2 lda ,y+ load a byte from source + sta ,u+ and save to destination + decb bump counter + bne Loop2 loop if not done + ENDC + * leau <Vectors,pc point to vector -* fill in the secondard interrupt vectors to all point to - tfr y,u move the pointer to a faster register -L0065 stu ,x++ Set all IRQ vectors to go to Vectors for now - cmpx #D.NMI - bls L0065 - +* fill in the secondard interrupt vectors to all point to + tfr y,u move the pointer to a faster register +L0065 stu ,x++ Set all IRQ vectors to go to Vectors for now + cmpx #D.NMI + bls L0065 + * Initialize user interupt vectors - ldx <D.XSWI2 Get SWI2 (os9 command) service routine pointer - stx <D.UsrSvc Save it as user service routine pointer - ldx <D.XIRQ Get IRQ service routine pointer - stx <D.UsrIRQ Save it as user IRQ routine pointer - - leax >SysCall,pc Setup System service routine entry vector - stx <D.SysSvc - stx <D.XSWI2 - - leax >S.SysIRQ,pc Setup system IRQ service vector - stx <D.SysIRQ - stx <D.XIRQ - - leax >S.SvcIRQ,pc Setup in system IRQ service vector - stx <D.SvcIRQ - leax >S.Poll,pc Setup interrupt polling vector - stx <D.Poll ORCC #$01;RTS - leax >S.AltIRQ,pc Setup alternate IRQ vector: pts to an RTS - stx <D.AltIRQ - - lda #'K --- in Kernel - jsr <D.BtBug --- - - leax >S.Flip1,pc Setup change to task 1 vector - stx <D.Flip1 - + ldx <D.XSWI2 Get SWI2 (os9 command) service routine pointer + stx <D.UsrSvc Save it as user service routine pointer + ldx <D.XIRQ Get IRQ service routine pointer + stx <D.UsrIRQ Save it as user IRQ routine pointer + + leax >SysCall,pc Setup System service routine entry vector + stx <D.SysSvc + stx <D.XSWI2 + + leax >S.SysIRQ,pc Setup system IRQ service vector + stx <D.SysIRQ + stx <D.XIRQ + + leax >S.SvcIRQ,pc Setup in system IRQ service vector + stx <D.SvcIRQ + leax >S.Poll,pc Setup interrupt polling vector + stx <D.Poll ORCC #$01;RTS + leax >S.AltIRQ,pc Setup alternate IRQ vector: pts to an RTS + stx <D.AltIRQ + + lda #'K --- in Kernel + jsr <D.BtBug --- + + leax >S.Flip1,pc Setup change to task 1 vector + stx <D.Flip1 + * Setup System calls - leay >SysCalls,pc load y with address of table, below - lbsr SysSvc copy table below into dispatch table - + leay >SysCalls,pc load y with address of table, below + lbsr SysSvc copy table below into dispatch table + * Initialize system process descriptor - ldu <D.PrcDBT get process table pointer - ldx <D.SysPrc get system process pointer + ldu <D.PrcDBT get process table pointer + ldx <D.SysPrc get system process pointer * These overlap because it is quicker than trying to strip hi byte from X - stx ,u save it as first process in table - stx 1,u save it as the second as well - IFNE H6309 - oim #$01,P$ID,x Set process ID to 1 (inited to 0) - oim #SysState,P$State,x Set to system state (inited to 0) - ELSE - ldd #$01*256+SysState - sta P$ID,x set PID to 1 - stb P$State,x set state to system (*NOT* zero ) - ENDC - clra set System task as task #0 - sta <D.SysTsk - sta P$Task,x - coma Setup its priority & age ($FF) - sta P$Prior,x - sta P$Age,x - leax <P$DATImg,x point to DAT image - stx <D.SysDAT save it as a pointer in DP + stx ,u save it as first process in table + stx 1,u save it as the second as well + IFNE H6309 + oim #$01,P$ID,x Set process ID to 1 (inited to 0) + oim #SysState,P$State,x Set to system state (inited to 0) + ELSE + ldd #$01*256+SysState + sta P$ID,x set PID to 1 + stb P$State,x set state to system (*NOT* zero ) + ENDC + clra set System task as task #0 + sta <D.SysTsk + sta P$Task,x + coma Setup its priority & age ($FF) + sta P$Prior,x + sta P$Age,x + leax <P$DATImg,x point to DAT image + stx <D.SysDAT save it as a pointer in DP * actually, since block 0 is tfm'd to be zero, we can skip the next 2 lines - IFNE H6309 - clrd - ELSE - clra - clrb - ENDC - std ,x++ initialize 1st block to 0 (for this DP) - + IFNE H6309 + clrd + ELSE + clra + clrb + ENDC + std ,x++ initialize 1st block to 0 (for this DP) + * Dat.BlCt-ROMCount-RAMCount - lda #$06 initialize the rest of the blocks to be free - ldu #DAT.Free -L00EF stu ,x++ store free "flag" - deca bump counter - bne L00EF loop if not done - - ldu #$003F Block $3F is in use, at the top of system DAT image - stu ,x - - ldx <D.Tasks Point to task user table - inc ,x mark first 2 in use (system & GrfDrv) - inc 1,x - + lda #$06 initialize the rest of the blocks to be free + ldu #DAT.Free +L00EF stu ,x++ store free "flag" + deca bump counter + bne L00EF loop if not done + + ldu #$003F Block $3F is in use, at the top of system DAT image + stu ,x + + ldx <D.Tasks Point to task user table + inc ,x mark first 2 in use (system & GrfDrv) + inc 1,x + * Setup system memory map - ldx <D.SysMem Get system memory map pointer - ldb <D.CCStk Get MSB of top of CC memory -L0104 inc ,x+ Mark it as used - decb Done? - bne L0104 No, go back till done + ldx <D.SysMem Get system memory map pointer + ldb <D.CCStk Get MSB of top of CC memory +L0104 inc ,x+ Mark it as used + decb Done? + bne L0104 No, go back till done * Calculate memory size - * CCB Comment: - * This code only modifies 2 bytes in the x0 blocks (x=doesn't cares) - * which at worst will be our DP. Should not effect CCB's prior load of - * OS9Boot it can only be loaded into block x1 through x6 and 3f so - * we should be safe. - ldx <D.BlkMap get ptr to 8k block map - inc <$3F,x mark block $3F as used (kernel) - IFNE H6309 - ldq #$00080100 e=Marker, D=Block # to check -L0111 asld get next block # - stb >$FFA5 Map block into block 6 of my task - ste >-$6000,x save marker to that block - cmpe ,x did it ghost to block 0? - bne L0111 No, keep going till ghost is found - stb <D.MemSz Save # 8k mem blocks that exist - addr x,d add number of blocks to block map start - ELSE - ldd #$0008 -L0111 aslb - rola - stb >$FFA5 - pshs a - lda #$01 - sta >-$6000,x - cmpa ,x - puls a - bne L0111 - stb <D.MemSz - pshs x - addd ,s++ - ENDC - std <D.BlkMap+2 save block map end pointer - + * CCB Comment: + * This code only modifies 2 bytes in the x0 blocks (x=doesn't cares) + * which at worst will be our DP. Should not effect CCB's prior load of + * OS9Boot it can only be loaded into block x1 through x6 and 3f so + * we should be safe. + ldx <D.BlkMap get ptr to 8k block map + inc <$3F,x mark block $3F as used (kernel) + IFNE H6309 + ldq #$00080100 e=Marker, D=Block # to check +L0111 asld get next block # + stb >$FFA5 Map block into block 6 of my task + ste >-$6000,x save marker to that block + cmpe ,x did it ghost to block 0? + bne L0111 No, keep going till ghost is found + stb <D.MemSz Save # 8k mem blocks that exist + addr x,d add number of blocks to block map start + ELSE + ldd #$0008 +L0111 aslb + rola + stb >$FFA5 + pshs a + lda #$01 + sta >-$6000,x + cmpa ,x + puls a + bne L0111 + stb <D.MemSz + pshs x + addd ,s++ + ENDC + std <D.BlkMap+2 save block map end pointer + * [D] at this point will contain 1 of the following: * $0210 - 128k * $0220 - 256k * $0240 - 512k * $0280 - 1024k * $0300 - 2048k - bitb #%00110000 block above 128K-256K? - beq L0170 yes, no need to mark block map - tstb 2 meg? - beq L0170 yes, skip this + bitb #%00110000 block above 128K-256K? + beq L0170 yes, no need to mark block map + tstb 2 meg? + beq L0170 yes, skip this * Mark blocks from 128k-256K to block $3F as NOT RAM - abx add maximum block number to block map start - leax -1,x Skip good blocks that are RAM - lda #NotRAM Not RAM flag - subb #$3F Calculate # blocks to mark as not RAM -L0127 sta ,x+ Mark them all - decb - bne L0127 - + abx add maximum block number to block map start + leax -1,x Skip good blocks that are RAM + lda #NotRAM Not RAM flag + subb #$3F Calculate # blocks to mark as not RAM +L0127 sta ,x+ Mark them all + decb + bne L0127 + L0170 * CCB - Commented out next two line. we don't have REL or BOOT, so the verify will be only -* for the memory taken by KRN itself... f000 to ff00 -* ldx #Bt.Start start address of the boot track in memory -* lda #$12 size of the boot track: B=$00 from L0127 loop, above -* CCB Addtion - change 2 lines above to: -* ldx #Where start address of KRN in memory -* ldd #$f00 size of KRN: B is already 0, A = F, Size=15 sectors (max) +* for the memory taken by KRN itself... f000 to ff00 +* ldx #Bt.Start start address of the boot track in memory +* lda #$12 size of the boot track: B=$00 from L0127 loop, above +* CCB Addtion - change 2 lines above to: +* ldx #Where start address of KRN in memory +* ldd #$f00 size of KRN: B is already 0, A = F, Size=15 sectors (max) * end of CCB Addtion -* lbsr I.VBlock go verify it -* bsr L01D2 go mark system map +* lbsr I.VBlock go verify it +* bsr L01D2 go mark system map * CCB Change - I'm commenting out this whole section, and replacing it - IFEQ 1 + IFEQ 1 * See if init module is in memory already -L01B0 leax <init,pc point to 'Init' module name - bsr link try & link it - bcc L01BF no error, go on -L01B8 os9 F$Boot error linking init, try & load boot file - bcc L01B0 got it, try init again - bra L01CE error, re-booting do D.Crash -L01BF stu <D.Init Save init module pointer - lda Feature1,u Get feature byte #1 from init module - bita #CRCOn CRC feature on? - beq ShowI if not, continue - inc <D.CRC else inc. CRC flag -ShowI lda #'i found init module - jsr <D.BtBug +L01B0 leax <init,pc point to 'Init' module name + bsr link try & link it + bcc L01BF no error, go on +L01B8 os9 F$Boot error linking init, try & load boot file + bcc L01B0 got it, try init again + bra L01CE error, re-booting do D.Crash +L01BF stu <D.Init Save init module pointer + lda Feature1,u Get feature byte #1 from init module + bita #CRCOn CRC feature on? + beq ShowI if not, continue + inc <D.CRC else inc. CRC flag +ShowI lda #'i found init module + jsr <D.BtBug -L01C1 leax <krnp2,pc Point to it's name - bsr link Try to link it - bcc L01D0 It worked, execute it - os9 F$Boot It doesn't exist try re-booting - bcc L01C1 No error's, let's try to link it again -L01CE jmp <D.Crash obviously can't do it, crash machine -L01D0 jmp ,y execute krnp2 - ENDC +L01C1 leax <krnp2,pc Point to it's name + bsr link Try to link it + bcc L01D0 It worked, execute it + os9 F$Boot It doesn't exist try re-booting + bcc L01C1 No error's, let's try to link it again +L01CE jmp <D.Crash obviously can't do it, crash machine +L01D0 jmp ,y execute krnp2 + ENDC * CCB we'll replace above with this: - ldd <D.BtSz get the size of OS9Boot file - addd #$fff add size of krn and round to higher size - clrb - pshs d save on stack - os9 F$SRqMem get memory - U is our starting address - stu <D.BtPtr save this just incase something uses it - tfr u,x setup x for vblock - puls d setup d for vblock with stacked size - lbsr I.VBlock verify OS9Boot - * this was copied from f$boot - * I dont know why we need to do this. Wouldn't - * f$srqmem do this for us?!?! But the system won't boot without. - ldx <D.SysDAT get system DAT pointer - ldb $0D,x get highest allocated block number - incb allocate block 0, too - ldx <D.BlkMap point to the memory block map - bsr L01DF and go mark the blocks as used - * end of copy from f$boot - leax <init,pc point to 'Init' module name - bsr link try & link it -L01BF stu <D.Init Save init module pointer - lda Feature1,u Get feature byte #1 from init module - bita #CRCOn CRC feature on? -* beq ShowI if not, continue - inc <D.CRC else inc. CRC flag -ShowI lda #'i found init module - jsr <D.BtBug -L01C1 leax <krnp2,pc Point to it's name - bsr link Try to link it -*e bra e -L01D0 jmp ,y execute krnp2 - + ldd <D.BtSz get the size of OS9Boot file + addd #$fff add size of krn and round to higher size + clrb + pshs d save on stack + os9 F$SRqMem get memory - U is our starting address + stu <D.BtPtr save this just incase something uses it + tfr u,x setup x for vblock + puls d setup d for vblock with stacked size + lbsr I.VBlock verify OS9Boot + * this was copied from f$boot + * I dont know why we need to do this. Wouldn't + * f$srqmem do this for us?!?! But the system won't boot without. + ldx <D.SysDAT get system DAT pointer + ldb $0D,x get highest allocated block number + incb allocate block 0, too + ldx <D.BlkMap point to the memory block map + bsr L01DF and go mark the blocks as used + * end of copy from f$boot + leax <init,pc point to 'Init' module name + bsr link try & link it +L01BF stu <D.Init Save init module pointer + lda Feature1,u Get feature byte #1 from init module + bita #CRCOn CRC feature on? +* beq ShowI if not, continue + inc <D.CRC else inc. CRC flag +ShowI lda #'i found init module + jsr <D.BtBug +L01C1 leax <krnp2,pc Point to it's name + bsr link Try to link it +*e bra e +L01D0 jmp ,y execute krnp2 + * CCB - End of change - - + + * Mark kernel in system memory map as used memory (256 byte blocks) -* L01D2 ldx <D.SysMem Get system mem ptr -* * CCB Change - only mark KRN as used (BOOT and REL don't exist) -* ldd #NotRAM*256+(Bt.Start/256) B = MSB of start of the boot -* ldd #NotRam*256+(Where/256) B = MSB of start of REL - * CCB Change end -* abx point to Bt.Start - start of boot track -* comb we have $FF-$ED pages to mark as used -* sta b,x Mark I/O as not RAM +* L01D2 ldx <D.SysMem Get system mem ptr +* * CCB Change - only mark KRN as used (BOOT and REL don't exist) +* ldd #NotRAM*256+(Bt.Start/256) B = MSB of start of the boot +* ldd #NotRam*256+(Where/256) B = MSB of start of REL + * CCB Change end +* abx point to Bt.Start - start of boot track +* comb we have $FF-$ED pages to mark as used +* sta b,x Mark I/O as not RAM * Mark kernel and boot file in system memory as used - there is no * reason this is a routine anymore - only one place calls it, but -* some speghetti is here... one of the IRQ routines "borrows" this rts. -L01DF lda #RAMinUse get in use flag -L01E1 sta ,x+ save it - decb done? - bne L01E1 no, keep going - ldx <D.BlkMap get pointer to start of block map - sta <$3f,x mark kernel block as RAMinUse, instead of ModInBlk -S.AltIRQ rts return - +* some speghetti is here... one of the IRQ routines "borrows" this rts. +L01DF lda #RAMinUse get in use flag +L01E1 sta ,x+ save it + decb done? + bne L01E1 no, keep going + ldx <D.BlkMap get pointer to start of block map + sta <$3f,x mark kernel block as RAMinUse, instead of ModInBlk +S.AltIRQ rts return + * Link module pointed to by X -link lda #Systm Attempt to link system module - os9 F$Link - rts - -init fcs 'Init' -krnp2 fcs 'krnp2' - +link lda #Systm Attempt to link system module + os9 F$Link + rts + +init fcs 'Init' +krnp2 fcs 'krnp2' + * Service vector call pointers -SysCalls fcb F$Link - fdb FLink-*-2 - fcb F$PrsNam - fdb FPrsNam-*-2 - fcb F$CmpNam - fdb FCmpNam-*-2 - fcb F$CmpNam+SysState - fdb FSCmpNam-*-2 - fcb F$CRC - fdb FCRC-*-2 - fcb F$SRqMem+SysState - fdb FSRqMem-*-2 - fcb F$SRtMem+SysState - fdb FSRtMem-*-2 - fcb F$AProc+SysState - fdb FAProc-*-2 - fcb F$NProc+SysState - fdb FNProc-*-2 - fcb F$VModul+SysState - fdb FVModul-*-2 - fcb F$SSvc+SysState - fdb FSSvc-*-2 - fcb F$SLink+SysState - fdb FSLink-*-2 - fcb F$Boot+SysState - fdb FBoot-*-2 - fcb F$BtMem+SysState - fdb FSRqMem-*-2 - IFNE H6309 - fcb F$CpyMem - fdb FCpyMem-*-2 - ENDC - fcb F$Move+SysState - fdb FMove-*-2 - fcb F$AllImg+SysState - fdb FAllImg-*-2 - fcb F$SetImg+SysState - fdb FFreeLB-*-2 - fcb F$FreeLB+SysState - fdb FSFreeLB-*-2 - fcb F$FreeHB+SysState - fdb FFreeHB-*-2 - fcb F$AllTsk+SysState - fdb FAllTsk-*-2 - fcb F$DelTsk+SysState - fdb FDelTsk-*-2 - fcb F$SetTsk+SysState - fdb FSetTsk-*-2 - fcb F$ResTsk+SysState - fdb FResTsk-*-2 - fcb F$RelTsk+SysState - fdb FRelTsk-*-2 - fcb F$DATLog+SysState - fdb FDATLog-*-2 - fcb F$LDAXY+SysState - fdb FLDAXY-*-2 - fcb F$LDDDXY+SysState - fdb FLDDDXY-*-2 - fcb F$LDABX+SysState - fdb FLDABX-*-2 - fcb F$STABX+SysState - fdb FSTABX-*-2 - fcb F$ELink+SysState - fdb FELink-*-2 - fcb F$FModul+SysState - fdb FFModul-*-2 - fcb F$VBlock+SysState - fdb FVBlock-*-2 - IFNE H6309 - fcb F$DelRAM - fdb FDelRAM-*-2 - ENDC - fcb $80 - +SysCalls fcb F$Link + fdb FLink-*-2 + fcb F$PrsNam + fdb FPrsNam-*-2 + fcb F$CmpNam + fdb FCmpNam-*-2 + fcb F$CmpNam+SysState + fdb FSCmpNam-*-2 + fcb F$CRC + fdb FCRC-*-2 + fcb F$SRqMem+SysState + fdb FSRqMem-*-2 + fcb F$SRtMem+SysState + fdb FSRtMem-*-2 + fcb F$AProc+SysState + fdb FAProc-*-2 + fcb F$NProc+SysState + fdb FNProc-*-2 + fcb F$VModul+SysState + fdb FVModul-*-2 + fcb F$SSvc+SysState + fdb FSSvc-*-2 + fcb F$SLink+SysState + fdb FSLink-*-2 + fcb F$Boot+SysState + fdb FBoot-*-2 + fcb F$BtMem+SysState + fdb FSRqMem-*-2 + IFNE H6309 + fcb F$CpyMem + fdb FCpyMem-*-2 + ENDC + fcb F$Move+SysState + fdb FMove-*-2 + fcb F$AllImg+SysState + fdb FAllImg-*-2 + fcb F$SetImg+SysState + fdb FFreeLB-*-2 + fcb F$FreeLB+SysState + fdb FSFreeLB-*-2 + fcb F$FreeHB+SysState + fdb FFreeHB-*-2 + fcb F$AllTsk+SysState + fdb FAllTsk-*-2 + fcb F$DelTsk+SysState + fdb FDelTsk-*-2 + fcb F$SetTsk+SysState + fdb FSetTsk-*-2 + fcb F$ResTsk+SysState + fdb FResTsk-*-2 + fcb F$RelTsk+SysState + fdb FRelTsk-*-2 + fcb F$DATLog+SysState + fdb FDATLog-*-2 + fcb F$LDAXY+SysState + fdb FLDAXY-*-2 + fcb F$LDDDXY+SysState + fdb FLDDDXY-*-2 + fcb F$LDABX+SysState + fdb FLDABX-*-2 + fcb F$STABX+SysState + fdb FSTABX-*-2 + fcb F$ELink+SysState + fdb FELink-*-2 + fcb F$FModul+SysState + fdb FFModul-*-2 + fcb F$VBlock+SysState + fdb FVBlock-*-2 + IFNE H6309 + fcb F$DelRAM + fdb FDelRAM-*-2 + ENDC + fcb $80 + * SWI3 vector entry -XSWI3 lda #P$SWI3 point to SWI3 vector - fcb $8C skip 2 bytes - +XSWI3 lda #P$SWI3 point to SWI3 vector + fcb $8C skip 2 bytes + * SWI vector entry -XSWI lda #P$SWI point to SWI vector - ldx <D.Proc get process pointer - ldu a,x user defined SWI[x]? - beq L028E no, go get option byte -GoUser lbra L0E5E Yes, go call users's routine - +XSWI lda #P$SWI point to SWI vector + ldx <D.Proc get process pointer + ldu a,x user defined SWI[x]? + beq L028E no, go get option byte +GoUser lbra L0E5E Yes, go call users's routine + * SWI2 vector entry -XSWI2 ldx <D.Proc get current process descriptor - ldu P$SWI2,x any SWI vector? - bne GoUser yes, go execute it - +XSWI2 ldx <D.Proc get current process descriptor + ldu P$SWI2,x any SWI vector? + bne GoUser yes, go execute it + * Process software interupts from a user state * Entry: X=Process descriptor pointer of process that made system call * U=Register stack pointer -L028E ldu <D.SysSvc set system call processor to system side - stu <D.XSWI2 - ldu <D.SysIRQ do the same thing for IRQ's - stu <D.XIRQ - IFNE H6309 - oim #SysState,P$State,x mark process as in system state - ELSE - lda P$State,x - ora #SysState - sta P$State,x - ENDC +L028E ldu <D.SysSvc set system call processor to system side + stu <D.XSWI2 + ldu <D.SysIRQ do the same thing for IRQ's + stu <D.XIRQ + IFNE H6309 + oim #SysState,P$State,x mark process as in system state + ELSE + lda P$State,x + ora #SysState + sta P$State,x + ENDC * copy register stack to process descriptor - sts P$SP,x save stack pointer - leas (P$Stack-R$Size),x point S to register stack destination - - IFNE H6309 - leau R$Size-1,s point to last byte of destination register stack - leay -1,y point to caller's register stack in $FEE1 - ldw #R$Size size of the register stack - tfm y-,u- - leau ,s needed because the TFM is u-, not -u (post, not pre) - ELSE + sts P$SP,x save stack pointer + leas (P$Stack-R$Size),x point S to register stack destination + + IFNE H6309 + leau R$Size-1,s point to last byte of destination register stack + leay -1,y point to caller's register stack in $FEE1 + ldw #R$Size size of the register stack + tfm y-,u- + leau ,s needed because the TFM is u-, not -u (post, not pre) + ELSE * Note! R$Size MUST BE an EVEN number of bytes for this to work! - leau R$Size,s point to last byte of destination register stack - lda #R$Size/2 -Loop3 ldx ,--y - stx ,--u - deca - bne Loop3 - ENDC - andcc #^IntMasks + leau R$Size,s point to last byte of destination register stack + lda #R$Size/2 +Loop3 ldx ,--y + stx ,--u + deca + bne Loop3 + ENDC + andcc #^IntMasks * B=function code already from calling process: DON'T USE IT! - ldx R$PC,u get where PC was from process - leax 1,x move PC past option - stx R$PC,u save updated PC to process + ldx R$PC,u get where PC was from process + leax 1,x move PC past option + stx R$PC,u save updated PC to process * execute function call - ldy <D.UsrDis get user dispatch table pointer - lbsr L033B go execute option - IFNE H6309 - aim #^IntMasks,R$CC,u Clear interrupt flags in caller's CC - ELSE - lda R$CC,u - anda #^IntMasks - sta R$CC,u - ENDC - ldx <D.Proc get current process ptr - IFNE H6309 - aim #^(SysState+TimOut),P$State,x Clear system & timeout flags - ELSE - lda P$State,x - anda #^(SysState+TimOut) - sta P$State,x - ENDC - + ldy <D.UsrDis get user dispatch table pointer + lbsr L033B go execute option + IFNE H6309 + aim #^IntMasks,R$CC,u Clear interrupt flags in caller's CC + ELSE + lda R$CC,u + anda #^IntMasks + sta R$CC,u + ENDC + ldx <D.Proc get current process ptr + IFNE H6309 + aim #^(SysState+TimOut),P$State,x Clear system & timeout flags + ELSE + lda P$State,x + anda #^(SysState+TimOut) + sta P$State,x + ENDC + * Check for image change now, which lets stuff like F$MapBlk and F$ClrBlk * do the short-circuit thing, too. Adds about 20 cycles to each system call. - lbsr TstImg it doesn't hurt to call this twice - lda P$State,x get current state of the process - ora <P$Signal,x is there a pending signal? - sta <D.Quick save quick return flag - beq AllClr if nothing's have changed, do full checks - -DoFull bsr L02DA move the stack frame back to user state - lbra L0D80 go back to the process - + lbsr TstImg it doesn't hurt to call this twice + lda P$State,x get current state of the process + ora <P$Signal,x is there a pending signal? + sta <D.Quick save quick return flag + beq AllClr if nothing's have changed, do full checks + +DoFull bsr L02DA move the stack frame back to user state + lbra L0D80 go back to the process + * add ldu P$SP,x, etc... -AllClr equ * - IFNE H6309 - inc <D.QCnt - aim #$1F,<D.QCnt - beq DoFull every 32 system calls, do the full check - ldw #R$Size --- size of the register stack - ldy #Where+SWIStack --- to stack at top of memory - orcc #IntMasks - tfm u+,y+ --- move the stack to the top of memory - ELSE - lda <D.QCnt - inca - anda #$1F - sta <D.QCnt - beq DoFull - ldb #R$Size - ldy #Where+SWIStack - orcc #IntMasks -Loop4 lda ,u+ - sta ,y+ - decb - bne Loop4 - ENDC - lbra BackTo1 otherwise simply return to the user - +AllClr equ * + IFNE H6309 + inc <D.QCnt + aim #$1F,<D.QCnt + beq DoFull every 32 system calls, do the full check + ldw #R$Size --- size of the register stack + ldy #Where+SWIStack --- to stack at top of memory + orcc #IntMasks + tfm u+,y+ --- move the stack to the top of memory + ELSE + lda <D.QCnt + inca + anda #$1F + sta <D.QCnt + beq DoFull + ldb #R$Size + ldy #Where+SWIStack + orcc #IntMasks +Loop4 lda ,u+ + sta ,y+ + decb + bne Loop4 + ENDC + lbra BackTo1 otherwise simply return to the user + * Copy register stack from user to system * Entry: U=Ptr to Register stack in process dsc -L02CB pshs cc,x,y,u preserve registers - ldb P$Task,x get task # - ldx P$SP,x get stack pointer - lbsr L0BF3 calculate block offset (only affects A&X) - leax -$6000,x adjust pointer to where memory map will be - bra L02E9 go copy it - +L02CB pshs cc,x,y,u preserve registers + ldb P$Task,x get task # + ldx P$SP,x get stack pointer + lbsr L0BF3 calculate block offset (only affects A&X) + leax -$6000,x adjust pointer to where memory map will be + bra L02E9 go copy it + * Copy register stack from system to user * Entry: U=Ptr to Register stack in process dsc -L02DA pshs cc,x,y,u preserve registers - ldb P$Task,x get task # of destination - ldx P$SP,x get stack pointer - lbsr L0BF3 calculate block offset (only affects A&X) - leax -$6000,x adjust pointer to where memory map will be - exg x,y swap pointers & copy +L02DA pshs cc,x,y,u preserve registers + ldb P$Task,x get task # of destination + ldx P$SP,x get stack pointer + lbsr L0BF3 calculate block offset (only affects A&X) + leax -$6000,x adjust pointer to where memory map will be + exg x,y swap pointers & copy * Copy a register stack * Entry: X=Source * Y=Destination * A=Offset into DAT image of stack * B=Task # -L02E9 leau a,u point to block # of where stack is - lda 1,u get first block - ldb 3,u get a second just in case of overlap - orcc #IntMasks shutdown interupts while we do this - std >$FFA5 map blocks in - IFNE H6309 - ldw #R$Size get size of register stack - tfm x+,y+ copy it - ELSE - ldb #R$Size -Loop5 lda ,x+ - sta ,y+ - decb - bne Loop5 - ENDC - ldx <D.SysDAT remap the blocks we took out - lda $0B,x - ldb $0D,x - std >$FFA5 - puls cc,x,y,u,pc restore & return - +L02E9 leau a,u point to block # of where stack is + lda 1,u get first block + ldb 3,u get a second just in case of overlap + orcc #IntMasks shutdown interupts while we do this + std >$FFA5 map blocks in + IFNE H6309 + ldw #R$Size get size of register stack + tfm x+,y+ copy it + ELSE + ldb #R$Size +Loop5 lda ,x+ + sta ,y+ + decb + bne Loop5 + ENDC + ldx <D.SysDAT remap the blocks we took out + lda $0B,x + ldb $0D,x + std >$FFA5 + puls cc,x,y,u,pc restore & return + * Process software interupts from system state * Entry: U=Register stack pointer -SysCall leau ,s get pointer to register stack - lda <D.SSTskN Get system task # (0=SYSTEM, 1=GRFDRV) - clr <D.SSTskN Force to System Process - pshs a Save the system task number - lda ,u Restore callers CC register (R$CC=$00) - tfr a,cc make it current - ldx R$PC,u Get my caller's PC register - leax 1,x move PC to next position - stx R$PC,u Save my caller's updated PC register - ldy <D.SysDis get system dispatch table pointer - bsr L033B execute system call - puls a restore system state task number - lbra L0E2B return to process - +SysCall leau ,s get pointer to register stack + lda <D.SSTskN Get system task # (0=SYSTEM, 1=GRFDRV) + clr <D.SSTskN Force to System Process + pshs a Save the system task number + lda ,u Restore callers CC register (R$CC=$00) + tfr a,cc make it current + ldx R$PC,u Get my caller's PC register + leax 1,x move PC to next position + stx R$PC,u Save my caller's updated PC register + ldy <D.SysDis get system dispatch table pointer + bsr L033B execute system call + puls a restore system state task number + lbra L0E2B return to process + * Entry: X = system call vector to jump to -Sys.Vec jmp ,x execute service call - +Sys.Vec jmp ,x execute service call + * Execute system call * Entry: B=Function call # * Y=Function dispatch table pointer (D.SysDis or D.UsrDis) -L033B - lslb is it a I/O call? (Also multiplys by 2 for offset) - bcc L0345 no, go get normal vector +L033B + lslb is it a I/O call? (Also multiplys by 2 for offset) + bcc L0345 no, go get normal vector * Execute I/O system calls - ldx IOEntry,y get IOMan vector + ldx IOEntry,y get IOMan vector * Execute the system call -L034F pshs u preserve register stack pointer - jsr [D.SysVec] perform a vectored system call - puls u restore pointer -L0355 tfr cc,a move CC to A for stack update - bcc L035B go update it if no error from call - stb R$B,u save error code to caller's B -L035B ldb R$CC,u get callers CC, R$CC=$00 - IFNE H6309 - andd #$2FD0 [A]=H,N,Z,V,C [B]=E,F,I - orr b,a merge them together - ELSE - anda #$2F [A]=H,N,Z,V,C - andb #$D0 [B]=E,F,I - pshs b - ora ,s+ - ENDC - sta R$CC,u return it to caller, R$CC=$00 - rts - +L034F pshs u preserve register stack pointer + jsr [D.SysVec] perform a vectored system call + puls u restore pointer +L0355 tfr cc,a move CC to A for stack update + bcc L035B go update it if no error from call + stb R$B,u save error code to caller's B +L035B ldb R$CC,u get callers CC, R$CC=$00 + IFNE H6309 + andd #$2FD0 [A]=H,N,Z,V,C [B]=E,F,I + orr b,a merge them together + ELSE + anda #$2F [A]=H,N,Z,V,C + andb #$D0 [B]=E,F,I + pshs b + ora ,s+ + ENDC + sta R$CC,u return it to caller, R$CC=$00 + rts + * Execute regular system calls -L0345 - clra clear MSB of offset - ldx d,y get vector to call - bne L034F it's initialized, go execute it - comb set carry for error - ldb #E$UnkSvc get error code - bra L0355 return with it - - use fssvc.asm - - use flink.asm - - use fvmodul.asm - - use ffmodul.asm - - use fprsnam.asm - - use fcmpnam.asm - - use ccbfsrqmem.asm - +L0345 + clra clear MSB of offset + ldx d,y get vector to call + bne L034F it's initialized, go execute it + comb set carry for error + ldb #E$UnkSvc get error code + bra L0355 return with it + + use fssvc.asm + + use flink.asm + + use fvmodul.asm + + use ffmodul.asm + + use fprsnam.asm + + use fcmpnam.asm + + use ccbfsrqmem.asm + * use fallram.asm - - - IFNE H6309 - use fdelram.asm - ENDC - - use fallimg.asm - - use ffreehb.asm - - use fdatlog.asm - - use fld.asm - - IFNE H6309 - use fcpymem.asm - ENDC - - use fmove.asm - - use fldabx.asm - - use falltsk.asm - - use faproc.asm - + + + IFNE H6309 + use fdelram.asm + ENDC + + use fallimg.asm + + use ffreehb.asm + + use fdatlog.asm + + use fld.asm + + IFNE H6309 + use fcpymem.asm + ENDC + + use fmove.asm + + use fldabx.asm + + use falltsk.asm + + use faproc.asm + * System IRQ service routine -XIRQ ldx <D.Proc get current process pointer - sts P$SP,x save the stack pointer - lds <D.SysStk get system stack pointer - ldd <D.SysSvc set system service routine to current - std <D.XSWI2 - ldd <D.SysIRQ set system IRQ routine to current - std <D.XIRQ - jsr [>D.SvcIRQ] execute irq service - bcc L0D5B - - ldx <D.Proc get current process pointer - ldb P$Task,x - ldx P$SP,x get it's stack pointer - - pshs u,d,cc save some registers - leau ,s point to a 'caller register stack' - lbsr L0C40 do a LDB 0,X in task B - puls u,d,cc and now A ( R$A,U ) = the CC we want - - ora #IntMasks disable it's IRQ's - lbsr L0C28 save it back -L0D5B orcc #IntMasks shut down IRQ's - ldx <D.Proc get current process pointer - tst <D.QIRQ was it a clock IRQ? - lbne L0DF7 if not, do a quick return - - lda P$State,x Get it's state - bita #TimOut Is it timed out? - bne L0D7C yes, wake it up +XIRQ ldx <D.Proc get current process pointer + sts P$SP,x save the stack pointer + lds <D.SysStk get system stack pointer + ldd <D.SysSvc set system service routine to current + std <D.XSWI2 + ldd <D.SysIRQ set system IRQ routine to current + std <D.XIRQ + jsr [>D.SvcIRQ] execute irq service + bcc L0D5B + + ldx <D.Proc get current process pointer + ldb P$Task,x + ldx P$SP,x get it's stack pointer + + pshs u,d,cc save some registers + leau ,s point to a 'caller register stack' + lbsr L0C40 do a LDB 0,X in task B + puls u,d,cc and now A ( R$A,U ) = the CC we want + + ora #IntMasks disable it's IRQ's + lbsr L0C28 save it back +L0D5B orcc #IntMasks shut down IRQ's + ldx <D.Proc get current process pointer + tst <D.QIRQ was it a clock IRQ? + lbne L0DF7 if not, do a quick return + + lda P$State,x Get it's state + bita #TimOut Is it timed out? + bne L0D7C yes, wake it up * Update active process queue - ldu #(D.AProcQ-P$Queue) point to active process queue - ldb #Suspend get suspend flag -L0D6A ldu P$Queue,u get a active process pointer - beq L0D78 - bitb P$State,u is it suspended? - bne L0D6A yes, go to next one in chain - ldb P$Prior,x get current process priority - cmpb P$Prior,u do we bump this one? - blo L0D7C - -L0D78 ldu P$SP,x - bra L0DB9 - -L0D7C anda #^TimOut - sta P$State,x - -L0D80 equ * -L0D83 bsr L0D11 activate next process - - use ccbfnproc.asm - + ldu #(D.AProcQ-P$Queue) point to active process queue + ldb #Suspend get suspend flag +L0D6A ldu P$Queue,u get a active process pointer + beq L0D78 + bitb P$State,u is it suspended? + bne L0D6A yes, go to next one in chain + ldb P$Prior,x get current process priority + cmpb P$Prior,u do we bump this one? + blo L0D7C + +L0D78 ldu P$SP,x + bra L0DB9 + +L0D7C anda #^TimOut + sta P$State,x + +L0D80 equ * +L0D83 bsr L0D11 activate next process + + use ccbfnproc.asm + * The following routines must appear no earlier than $E00 when assembled, as * they have to always be in the vector RAM page ($FE00-$FEFF) - + * CCB: this code (after pad) start assembling *before* 0xfe00, it's too big to * fit into the memory as stated above!!!! -PAD fill $00,($0df1-*) fill memory to ensure the above happens +PAD fill $00,($0df1-*) fill memory to ensure the above happens * Default routine for D.SysIRQ S.SysIRQ - lda <D.SSTskN Get current task's GIME task # (0 or 1) - beq FastIRQ Use super-fast version for system state - clr <D.SSTskN Clear out memory copy (task 0) - jsr [>D.SvcIRQ] (Normally routine in Clock calling D.Poll) - inc <D.SSTskN Save task # for system state - lda #1 Task 1 - ora <D.TINIT Merge task bit's into Shadow version - sta <D.TINIT Update shadow - sta >DAT.Task Save to GIME as well & return - bra DoneIRQ Check for error and exit - -FastIRQ jsr [>D.SvcIRQ] (Normally routine in Clock calling D.Poll) -DoneIRQ bcc L0E28 No error on IRQ, exit - IFNE H6309 - oim #IntMasks,0,s Setup RTI to shut interrupts off again - ELSE - lda ,s - ora #IntMasks - sta ,s - ENDC -L0E28 rti - + lda <D.SSTskN Get current task's GIME task # (0 or 1) + beq FastIRQ Use super-fast version for system state + clr <D.SSTskN Clear out memory copy (task 0) + jsr [>D.SvcIRQ] (Normally routine in Clock calling D.Poll) + inc <D.SSTskN Save task # for system state + lda #1 Task 1 + ora <D.TINIT Merge task bit's into Shadow version + sta <D.TINIT Update shadow + sta >DAT.Task Save to GIME as well & return + bra DoneIRQ Check for error and exit + +FastIRQ jsr [>D.SvcIRQ] (Normally routine in Clock calling D.Poll) +DoneIRQ bcc L0E28 No error on IRQ, exit + IFNE H6309 + oim #IntMasks,0,s Setup RTI to shut interrupts off again + ELSE + lda ,s + ora #IntMasks + sta ,s + ENDC +L0E28 rti + * return from a system call -L0E29 clra Force System task # to 0 (non-GRDRV) -L0E2B ldx <D.SysPrc Get system process dsc. ptr - lbsr TstImg check image, and F$SetTsk (PRESERVES A) - orcc #IntMasks Shut interrupts off - sta <D.SSTskN Save task # for system state - beq Fst2 If task 0, skip subroutine - ora <D.TINIT Merge task bit's into Shadow version - sta <D.TINIT Update shadow - sta >DAT.Task Save to GIME as well & return -Fst2 leas ,u Stack ptr=U & return - rti - +L0E29 clra Force System task # to 0 (non-GRDRV) +L0E2B ldx <D.SysPrc Get system process dsc. ptr + lbsr TstImg check image, and F$SetTsk (PRESERVES A) + orcc #IntMasks Shut interrupts off + sta <D.SSTskN Save task # for system state + beq Fst2 If task 0, skip subroutine + ora <D.TINIT Merge task bit's into Shadow version + sta <D.TINIT Update shadow + sta >DAT.Task Save to GIME as well & return +Fst2 leas ,u Stack ptr=U & return + rti + * Switch to new process, X=Process descriptor pointer, U=Stack pointer -L0E4C equ * - IFNE H6309 - oim #$01,<D.TINIT switch GIME shadow to user state - lda <D.TINIT - ELSE - lda <D.TINIT - ora #$01 - sta <D.TINIT - ENDC - sta >DAT.Task save it to GIME - leas ,y point to new stack - tstb is the stack at SWISTACK? - bne MyRTI no, we're doing a system-state rti - - IFNE H6309 - ldf #R$Size E=0 from call to L0E8D before - ldu #Where+SWIStack point to the stack - tfm u+,y+ move the stack from top of memory to user memory - ELSE - ldb #R$Size - ldu #Where+SWIStack point to the stack -RtiLoop lda ,u+ - sta ,y+ - decb - bne RtiLoop - ENDC -MyRTI rti return from IRQ - - +L0E4C equ * + IFNE H6309 + oim #$01,<D.TINIT switch GIME shadow to user state + lda <D.TINIT + ELSE + lda <D.TINIT + ora #$01 + sta <D.TINIT + ENDC + sta >DAT.Task save it to GIME + leas ,y point to new stack + tstb is the stack at SWISTACK? + bne MyRTI no, we're doing a system-state rti + + IFNE H6309 + ldf #R$Size E=0 from call to L0E8D before + ldu #Where+SWIStack point to the stack + tfm u+,y+ move the stack from top of memory to user memory + ELSE + ldb #R$Size + ldu #Where+SWIStack point to the stack +RtiLoop lda ,u+ + sta ,y+ + decb + bne RtiLoop + ENDC +MyRTI rti return from IRQ + + * Execute routine in task 1 pointed to by U * comes from user requested SWI vectors -L0E5E equ * - IFNE H6309 - oim #$01,<D.TINIT switch GIME shadow to user state - ldb <D.TINIT - ELSE - ldb <D.TINIT - orb #$01 - stb <D.TINIT - ENDC - stb >DAT.Task - jmp ,u - -* Flip to task 1 (used by GRF/WINDInt to switch to GRFDRV) (pointed to +L0E5E equ * + IFNE H6309 + oim #$01,<D.TINIT switch GIME shadow to user state + ldb <D.TINIT + ELSE + ldb <D.TINIT + orb #$01 + stb <D.TINIT + ENDC + stb >DAT.Task + jmp ,u + +* Flip to task 1 (used by GRF/WINDInt to switch to GRFDRV) (pointed to * by <D.Flip1). All regs are already preserved on stack for the RTI -S.Flip1 ldb #2 get Task image entry numberx2 for Grfdrv (task 1) - bsr L0E8D copy over the DAT image - IFNE H6309 - oim #$01,<D.TINIT - lda <D.TINIT get copy of GIME Task side - ELSE - lda <D.TINIT - ora #$01 - sta <D.TINIT - ENDC - sta >DAT.Task save it to GIME register - inc <D.SSTskN increment system state task number - rti return - +S.Flip1 ldb #2 get Task image entry numberx2 for Grfdrv (task 1) + bsr L0E8D copy over the DAT image + IFNE H6309 + oim #$01,<D.TINIT + lda <D.TINIT get copy of GIME Task side + ELSE + lda <D.TINIT + ora #$01 + sta <D.TINIT + ENDC + sta >DAT.Task save it to GIME register + inc <D.SSTskN increment system state task number + rti return + * Setup MMU in task 1, B=Task # to swap to, shifted left 1 bit -L0E8D cmpb <D.Task1N are we going back to the same task - beq L0EA3 without the DAT image changing? - stb <D.Task1N nope, save current task in map type 1 - ldx #$FFA8 get MMU start register for process's - ldu <D.TskIPt get task image pointer table - ldu b,u get address of DAT image -L0E93 leau 1,u point to actual MMU block - IFNE H6309 - lde #4 get # banks/2 for task - ELSE - lda #4 - pshs a - ENDC -L0E9B lda ,u++ get a bank - ldb ,u++ and next one - std ,x++ Save it to MMU - IFNE H6309 - dece done? - ELSE - dec ,s - ENDC - bne L0E9B no, keep going - IFEQ H6309 - leas 1,s - ENDC -L0EA3 rts return - +L0E8D cmpb <D.Task1N are we going back to the same task + beq L0EA3 without the DAT image changing? + stb <D.Task1N nope, save current task in map type 1 + ldx #$FFA8 get MMU start register for process's + ldu <D.TskIPt get task image pointer table + ldu b,u get address of DAT image +L0E93 leau 1,u point to actual MMU block + IFNE H6309 + lde #4 get # banks/2 for task + ELSE + lda #4 + pshs a + ENDC +L0E9B lda ,u++ get a bank + ldb ,u++ and next one + std ,x++ Save it to MMU + IFNE H6309 + dece done? + ELSE + dec ,s + ENDC + bne L0E9B no, keep going + IFEQ H6309 + leas 1,s + ENDC +L0EA3 rts return + * Execute FIRQ vector (called from $FEF4) -FIRQVCT ldx #D.FIRQ get DP offset of vector - bra L0EB8 go execute it - +FIRQVCT ldx #D.FIRQ get DP offset of vector + bra L0EB8 go execute it + * Execute IRQ vector (called from $FEF7) -IRQVCT orcc #IntMasks disasble IRQ's - ldx #D.IRQ get DP offset of vector +IRQVCT orcc #IntMasks disasble IRQ's + ldx #D.IRQ get DP offset of vector * Execute interrupt vector, B=DP Vector offset -L0EB8 clra (faster than CLR >$xxxx) - sta >DAT.Task Force to Task 0 (system state) - IFNE H6309 - tfr 0,dp setup DP - ELSE - tfr a,dp - ENDC -MapGrf equ * - IFNE H6309 - aim #$FE,<D.TINIT switch GIME shadow to system state - lda <D.TINIT set GIME again just in case timer is used - ELSE - lda <D.TINIT - anda #$FE - sta <D.TINIT - ENDC -MapT0 sta >DAT.Task - jmp [,x] execute it - +L0EB8 clra (faster than CLR >$xxxx) + sta >DAT.Task Force to Task 0 (system state) + IFNE H6309 + tfr 0,dp setup DP + ELSE + tfr a,dp + ENDC +MapGrf equ * + IFNE H6309 + aim #$FE,<D.TINIT switch GIME shadow to system state + lda <D.TINIT set GIME again just in case timer is used + ELSE + lda <D.TINIT + anda #$FE + sta <D.TINIT + ENDC +MapT0 sta >DAT.Task + jmp [,x] execute it + * Execute SWI3 vector (called from $FEEE) -SWI3VCT orcc #IntMasks disable IRQ's - ldx #D.SWI3 get DP offset of vector - bra SWICall go execute it - +SWI3VCT orcc #IntMasks disable IRQ's + ldx #D.SWI3 get DP offset of vector + bra SWICall go execute it + * Execute SWI2 vector (called from $FEF1) -SWI2VCT orcc #IntMasks disasble IRQ's - ldx #D.SWI2 get DP offset of vector - +SWI2VCT orcc #IntMasks disasble IRQ's + ldx #D.SWI2 get DP offset of vector + * This routine is called from an SWI, SWI2, or SWI3 * saves 1 cycle on system-system calls * saves about 200 cycles (calls to I.LDABX and L029E) on grfdrv-system, * or user-system calls. -SWICall ldb [R$PC,s] get callcode of the system call +SWICall ldb [R$PC,s] get callcode of the system call * NOTE: Alan DeKok claims that this is BAD. It crashed Colin McKay's * CoCo 3. Instead, we should do a clra/sta >DAT.Task. -* clr >DAT.Task go to map type 1 - clra - sta >DAT.Task +* clr >DAT.Task go to map type 1 + clra + sta >DAT.Task * set DP to zero - IFNE H6309 - tfr 0,dp - ELSE - tfr a,dp - ENDC - + IFNE H6309 + tfr 0,dp + ELSE + tfr a,dp + ENDC + * These lines add a total of 81 addition cycles to each SWI(2,3) call, * and 36 bytes+12 for R$Size in the constant page at $FExx * It takes no more time for a SWI(2,3) from system state than previously, @@ -1041,77 +1041,77 @@ * For processes that re-vector SWI, SWI3, it adds 81 cycles. BUT SWI(3) * CANNOT be vectored to L0EBF cause the user SWI service routine has been * changed - lda <D.TINIT get map type flag - bita #$01 check it without changing it - + lda <D.TINIT get map type flag + bita #$01 check it without changing it + * Change to LBEQ R.SysSvc to avoid JMP [,X] * and add R.SysSvc STA >DAT.Task ??? - beq MapT0 in map 0: restore hardware and do system service - tst <D.SSTskN get system state 0,1 - bne MapGrf if in grfdrv, go to map 0 and do system service - + beq MapT0 in map 0: restore hardware and do system service + tst <D.SSTskN get system state 0,1 + bne MapGrf if in grfdrv, go to map 0 and do system service + * the preceding few lines are necessary, as all SWI's still pass thru * here before being vectored to the system service routine... which * doesn't copy the stack from user state. - sta >DAT.Task go to map type X again to get user's stack + sta >DAT.Task go to map type X again to get user's stack * a byte less, a cycle more than ldy #$FEED-R$Size, or ldy #$F000+SWIStack - leay <SWIStack,pc where to put the register stack: to $FEDF - tfr s,u get a copy of where the stack is - IFNE H6309 - ldw #R$Size get the size of the stack - tfm u+,y+ move the stack to the top of memory - ELSE - pshs b - ldb #R$Size -Looper lda ,u+ - sta ,y+ - decb - bne Looper - puls b - ENDC - bra L0EB8 and go from map type 1 to map type 0 - + leay <SWIStack,pc where to put the register stack: to $FEDF + tfr s,u get a copy of where the stack is + IFNE H6309 + ldw #R$Size get the size of the stack + tfm u+,y+ move the stack to the top of memory + ELSE + pshs b + ldb #R$Size +Looper lda ,u+ + sta ,y+ + decb + bne Looper + puls b + ENDC + bra L0EB8 and go from map type 1 to map type 0 + * Execute SWI vector (called from $FEFA) -SWIVCT ldx #D.SWI get DP offset of vector - bra SWICall go execute it - +SWIVCT ldx #D.SWI get DP offset of vector + bra SWICall go execute it + * Execute NMI vector (called from $FEFD) -NMIVCT ldx #D.NMI get DP offset of vector - bra L0EB8 go execute it - +NMIVCT ldx #D.NMI get DP offset of vector + bra L0EB8 go execute it + * The end of the kernel module is here - emod -eom equ * - + emod +eom equ * + * What follows after the kernel module is the register stack, starting * at $FEDD (6309) or $FEDF (6809). This register stack area is used by * the kernel to save the caller's registers in the $FEXX area of memory * because it doesn't* get "switched out" no matter the contents of the * MMU registers. -SWIStack - fcc /REGISTER STACK/ same # bytes as R$Size for 6809 - IFNE H6309 - fcc /63/ if 6309, add two more spaces - ENDC - - fcb $55 D.ErrRst - +SWIStack + fcc /REGISTER STACK/ same # bytes as R$Size for 6809 + IFNE H6309 + fcc /63/ if 6309, add two more spaces + ENDC + + fcb $55 D.ErrRst + * This list of addresses ends up at $FEEE after the kernel track is loaded * into memory. All interrupts come through the 6809 vectors at $FFF0-$FFFE * and get directed to here. From here, the BRA takes CPU control to the * various handlers in the kernel. - bra SWI3VCT SWI3 vector comes here - nop - bra SWI2VCT SWI2 vector comes here - nop - bra FIRQVCT FIRQ vector comes here - nop - bra IRQVCT IRQ vector comes here - nop - bra SWIVCT SWI vector comes here - nop - bra NMIVCT NMI vector comes here - nop + bra SWI3VCT SWI3 vector comes here + nop + bra SWI2VCT SWI2 vector comes here + nop + bra FIRQVCT FIRQ vector comes here + nop + bra IRQVCT IRQ vector comes here + nop + bra SWIVCT SWI vector comes here + nop + bra NMIVCT NMI vector comes here + nop - - end + + end
--- a/level2/modules/kernel/fallbit.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/fallbit.asm Mon Nov 28 08:31:26 2016 +0000 @@ -37,7 +37,7 @@ sta ,-s preserve current mask bmi SkpBit If high bit set, skip ahead IFGT Level-1 - os9 F$LDABX go get original value from bit map + os9 F$LDABX go get original value from bit map ELSE lda ,x ENDC @@ -100,7 +100,7 @@ ENDC leas 1,s eat the working copy of the mask BitEx clrb no error & return - rts + rts * Calculate address of first byte we want, and which bit in that byte, from * a bit allocation map given the address of the map & the bit # we want to @@ -233,7 +233,7 @@ ENDC leas 1,s eat working copy of mask L08E0 clrb eat error & return - rts + rts ************************************************** @@ -364,4 +364,4 @@ ELSE leas $09,s ENDC - rts + rts
--- a/level2/modules/kernel/fallimg.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/fallimg.asm Mon Nov 28 08:31:26 2016 +0000 @@ -17,11 +17,11 @@ * * 6309 NOTE: IF W IS USED HERE, TRY TO PRESERVE IT AS F$SRQMEM WILL * PROBABLY END UP USING IT -L09BE pshs d,x,y,u - lsla +L09BE pshs d,x,y,u + lsla leay P$DATImg,x leay a,y - clra + clra tfr d,x ldu <D.BlkMap pshs d,x,y,u @@ -51,7 +51,7 @@ L09F7 ldb #E$MemFul leas 6,s stb 1,s - comb + comb puls d,x,y,u,pc L0A00 puls x,y,u @@ -74,5 +74,5 @@ ora #ImgChg sta P$State,x ENDC - clrb + clrb puls d,x,y,u,pc
--- a/level2/modules/kernel/fallprc.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/fallprc.asm Mon Nov 28 08:31:26 2016 +0000 @@ -57,12 +57,12 @@ *************************************************************************** * OS-9 L2 Upgrade Enhancement: Stamp current date/time for start of process -* ldy <D.Proc get current process descriptor -* ldx <D.SysProc get system process descriptor -* stx <D.Proc make system process current -* leax P$DatBeg,u new proc desc creation date/time stamp -* os9 F$Time ignore any error... -* sty <D.Proc restore current proc desc address +* ldy <D.Proc get current process descriptor +* ldx <D.SysProc get system process descriptor +* stx <D.Proc make system process current +* leax P$DatBeg,u new proc desc creation date/time stamp +* os9 F$Time ignore any error... +* sty <D.Proc restore current proc desc address *************************************************************************** lda #SysState set process to system state @@ -89,8 +89,8 @@ * * Error: CC = C bit set; B = error code * -FDelPrc lda R$A,u get process # - bra L0386 delete it +FDelPrc lda R$A,u get process # + bra L0386 delete it ************************************************** @@ -147,7 +147,7 @@ L0368 comb Exit with No Children error ldb #E$NoChld - rts + rts * Child has died * Entry: Y=Ptr to child process that died
--- a/level2/modules/kernel/fallram.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/fallram.asm Mon Nov 28 08:31:26 2016 +0000 @@ -25,7 +25,7 @@ * don't need to calc A L0983 tfr y,d Copy start of requested block mem ptr to D (B) lda ,s Get # blocks requested - stb ,s Save start block # + stb ,s Save start block # L098D inc ,y+ Flag blocks as used deca (for all blocks allocated) bne L098D Do until done
--- a/level2/modules/kernel/falltsk.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/falltsk.asm Mon Nov 28 08:31:26 2016 +0000 @@ -32,10 +32,10 @@ * Error: CC = C bit set; B = error code * FDelTsk ldx R$X,u -L0C68 ldb P$Task,x grab the current task number - beq L0C64 if system (or released), exit - clr P$Task,x force the task number to be zero - bra L0CC3 do a F$RelTsk +L0C68 ldb P$Task,x grab the current task number + beq L0C64 if system (or released), exit + clr P$Task,x force the task number to be zero + bra L0CC3 do a F$RelTsk TstImg equ * IFNE H6309 @@ -46,8 +46,8 @@ bitb #ImgChg * puls b ENDC - beq L0C65 if not, exit now: don't clear carry, it's not needed - fcb $8C skip LDX, below + beq L0C65 if not, exit now: don't clear carry, it's not needed + fcb $8C skip LDX, below ************************************************** @@ -83,7 +83,7 @@ cmpb #2 is it either system or GrfDrv? bhi L0C9F no, return ldx #DAT.Regs update system DAT image - lbsr L0E93 go bash the hardware + lbsr L0E93 go bash the hardware L0C9F puls cc,d,x,u,pc @@ -100,7 +100,7 @@ * FResTsk bsr L0CA6 stb R$B,u -L0CA5 rts +L0CA5 rts * Find a free task in task map @@ -154,45 +154,45 @@ * Possible, move ALL software-clock code into OS9p2, and therefore * have it auto-initialize? All hardware clocks would then be called * just once a minute. -L0CD2 ldx <D.SProcQ Get sleeping process Queue ptr - beq L0CFD None (no one sleeping), so exit +L0CD2 ldx <D.SProcQ Get sleeping process Queue ptr + beq L0CFD None (no one sleeping), so exit IFNE H6309 tim #TimSleep,P$State,x Is it a timed sleep? ELSE ldb P$State,x bitb #TimSleep ENDC - beq L0CFD No, exit: waiting for signal/interrupt - ldu P$SP,x Yes, get his stack pointer - ldd R$X,u Get his sleep tick count + beq L0CFD No, exit: waiting for signal/interrupt + ldu P$SP,x Yes, get his stack pointer + ldd R$X,u Get his sleep tick count IFNE H6309 - decd decrement sleep count + decd decrement sleep count ELSE subd #$0001 ENDC - std R$X,u Save it back - bne L0CFD Still more ticks to go, so exit + std R$X,u Save it back + bne L0CFD Still more ticks to go, so exit * Process needs to wake up, update queue pointers -L0CE7 ldu P$Queue,x Get next process in Queue - bsr L0D11 activate it - leax ,u point to new process - beq L0CFB don't exist, go on +L0CE7 ldu P$Queue,x Get next process in Queue + bsr L0D11 activate it + leax ,u point to new process + beq L0CFB don't exist, go on IFNE H6309 tim #TimSleep,P$State,x is it in a timed sleep? ELSE ldb P$State,x bitb #TimSleep ENDC - beq L0CFB no, go update process table - ldu P$SP,x get it's stack pointer - ldd R$X,u any sleep time left? - beq L0CE7 no, go activate next process in queue -L0CFB stx <D.SProcQ Store new sleeping process pointer -L0CFD dec <D.Slice Any time remaining on process? - bne L0D0D Yes, exit - inc <D.Slice reset slice count - ldx <D.Proc Get current process pointer - beq L0D0D none, return + beq L0CFB no, go update process table + ldu P$SP,x get it's stack pointer + ldd R$X,u any sleep time left? + beq L0CE7 no, go activate next process in queue +L0CFB stx <D.SProcQ Store new sleeping process pointer +L0CFD dec <D.Slice Any time remaining on process? + bne L0D0D Yes, exit + inc <D.Slice reset slice count + ldx <D.Proc Get current process pointer + beq L0D0D none, return IFNE H6309 oim #TimOut,P$State,x put him in a timeout state ELSE @@ -200,5 +200,5 @@ orb #TimOut stb P$State,x ENDC -L0D0D clrb - rts +L0D0D clrb + rts
--- a/level2/modules/kernel/faproc.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/faproc.asm Mon Nov 28 08:31:26 2016 +0000 @@ -10,7 +10,7 @@ * Error: CC = C bit set; B = error code * FAProc ldx R$X,u Get ptr to process to activate -L0D11 clrb +L0D11 clrb pshs cc,b,x,y,u lda P$Prior,x Get process priority sta P$Age,x Save it as age (How long it's been around) @@ -28,7 +28,7 @@ L0D29 leay ,u point Y to current process L0D2B ldu P$Queue,u get pointer to next process in chain bne L0D1F Still more in chain, keep going - ldd P$Queue,y + ldd P$Queue,y stx P$Queue,y save new process to chain std P$Queue,x puls cc,b,x,y,u,pc
--- a/level2/modules/kernel/fchain.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/fchain.asm Mon Nov 28 08:31:26 2016 +0000 @@ -28,7 +28,7 @@ tfm x+,u+ move it ELSE ldy #$00FC -L03C3 ldd ,x++ copy bytes +L03C3 ldd ,x++ copy bytes std ,u++ leay -2,y bne L03C3 @@ -59,12 +59,12 @@ os9 F$UnLink unlink from the primary module ldb P$PagCnt,x grab the page count addb #$1F round up to the nearest block - lsrb - lsrb - lsrb - lsrb + lsrb + lsrb + lsrb + lsrb lsrb get number of blocks used - lda #$08 + lda #$08 IFNE H6309 subr b,a A=number of blocks unused ELSE @@ -72,11 +72,11 @@ suba ,s+ ENDC leay <P$DATImg,x set up the initial DAT image - lslb + lslb leay b,y go to the offset ldu #DAT.Free mark the blocks as free L040C stu ,y++ do all of them - deca + deca bne L040C ldu 2,s get new process descriptor pointer stu <D.Proc make it the new process @@ -94,21 +94,21 @@ * as the old process, not that it matters... IFNE H6309 - fcb $24,$00 TODO: Identify this! + fcb $24,$00 TODO: Identify this! ENDC ldu <D.Proc get nre process lda P$Task,u new task number ldb P$Task,x old task number leau >(P$Stack-R$Size),x set up the stack for the new process - leax ,y + leax ,y ldu R$X,u where to copy from IFNE H6309 cmpr x,u check From/To addresses ELSE - pshs x src ptr - cmpu ,s++ dest ptr + pshs x src ptr + cmpu ,s++ dest ptr ENDC - puls y size + puls y size bhi L0471 To < From: do F$Move beq L0474 To == From, skip F$Move @@ -133,8 +133,8 @@ * The areas to copy overlap: do special move routine pshs d,x,y,u save regs IFNE H6309 - addr y,x go to the END of the area to copy FROM - addr y,u end of area to copy TO + addr y,x go to the END of the area to copy FROM + addr y,u end of area to copy TO ELSE tfr y,d leax d,x @@ -145,11 +145,11 @@ * in the same address space. L0457 ldb ,s grab ?? leax -1,x back up one - os9 F$LDABX + os9 F$LDABX exg x,u ldb 1,s leax -1,x back up another one - os9 F$STABX + os9 F$STABX exg x,u leay -1,y bne L0457 @@ -208,7 +208,7 @@ bcc L04D7 no error, keep going leas 4,s purge stack puls x,y,u,pc restore & return -* +* L04D7 stu 2,s save pointer to module pshs a,y save module type & entry point ldu $0B,s restore register stack pointer @@ -262,12 +262,11 @@ std 6,s lda #Entire sta R$CC,y save condition code - clra + clra sta R$DP,y save direct page - clrb + clrb std R$U,y save data area start stx R$PC,y save program entry point L053E puls d restore process pointer std <D.Proc save it as current puls d,x,y,u,pc -
--- a/level2/modules/kernel/fclrblk.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/fclrblk.asm Mon Nov 28 08:31:26 2016 +0000 @@ -13,7 +13,7 @@ FClrBlk ldb R$B,u beq L0BE9 ldd R$U,u - tstb + tstb bne L0BAA bita #$1F bne L0BAA @@ -22,14 +22,14 @@ anda #$E0 suba R$U,u bcs L0BCE - lsra - lsra - lsra - lsra - lsra + lsra + lsra + lsra + lsra + lsra cmpa R$B,u bcs L0BAA -L0BCE +L0BCE IFNE H6309 oim #ImgChg,P$State,x ELSE @@ -38,16 +38,16 @@ sta P$State,x ENDC lda R$U,u - lsra - lsra - lsra - lsra + lsra + lsra + lsra + lsra leay P$DATImg,x leay a,y ldb R$B,u ldx #DAT.Free L0BE4 stx ,y++ - decb + decb bne L0BE4 -L0BE9 clrb - rts +L0BE9 clrb + rts
--- a/level2/modules/kernel/fcpymem.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/fcpymem.asm Mon Nov 28 08:31:26 2016 +0000 @@ -71,7 +71,7 @@ rts L0A01 clrb No error & exit - rts + rts ELSE @@ -133,4 +133,3 @@ rts end. ENDC -
--- a/level2/modules/kernel/fcrcmod.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/fcrcmod.asm Mon Nov 28 08:31:26 2016 +0000 @@ -18,5 +18,5 @@ sta <D.CRC turn CRC checking on CRCRep lda <D.CRC get current CRC flag for return CRCRep2 sta R$A,u save it to their register stack - clrb no error + clrb no error rts and exit
--- a/level2/modules/kernel/fdatlog.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/fdatlog.asm Mon Nov 28 08:31:26 2016 +0000 @@ -15,17 +15,17 @@ bsr CmpLBlk Go modify X to be Logical address stx R$X,u Save in callers X register clrb No error & return - rts + rts * Compute logical address given B=Logical Block # & X=offset into block * Exits with B being logical block & X=logical address CmpLBlk pshs b Preserve logical block # tfr b,a Move log. block # to A lsla Multiply logical block by 32 - lsla - lsla - lsla - lsla + lsla + lsla + lsla + lsla clrb D=8k offset value IFNE H6309 addr d,x X=logical address in 64k workspace
--- a/level2/modules/kernel/fdebug.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/fdebug.asm Mon Nov 28 08:31:26 2016 +0000 @@ -1,64 +1,63 @@ -****************************************************** -* F$Debug entry point -* +****************************************************** +* F$Debug entry point +* * Enter the debugger (or reboot) * -* Input: A = Function code -* +* Input: A = Function code +* FDebug equ * * Determine if this is a system process or super user * Only they have permission to reboot lda R$A,u - cmpa #255 reboot request - bne leave nope + cmpa #255 reboot request + bne leave nope ldx <D.Proc - ldd P$User,x get user ID + ldd P$User,x get user ID beq REBOOT comb ldb #E$UnkSvc -leave rts +leave rts * NOTE: HIGHLY MACHINE DEPENDENT CODE! * THIS CODE IS SPECIFIC TO THE COCO 3! REBOOT orcc #IntMasks turn off IRQ's clrb - stb >$FFA0 map in block 0 - stb >$0071 cold reboot - lda #$38 bottom of DECB block mapping - sta >$FFA0 map in block zero - stb >$0071 and cold reboot here, too - ldu #$0000 force code to go at offset $0000 + stb >$FFA0 map in block 0 + stb >$0071 cold reboot + lda #$38 bottom of DECB block mapping + sta >$FFA0 map in block zero + stb >$0071 and cold reboot here, too + ldu #$0000 force code to go at offset $0000 leax ReBootLoc,pc reboot code ldy #CodeSize cit.loop lda ,x+ sta ,u+ leay -1,y bne cit.loop - clr >$FEED cold reboot - clr >$FFD8 go to low speed - jmp >$0000 jump to the reset code + clr >$FEED cold reboot + clr >$FFD8 go to low speed + jmp >$0000 jump to the reset code ReBootLoc - ldd #$3808 block $38, 8 times - ldx #$FFA0 where to put it -Lp sta 8,x put into map 1 - sta ,x+ and into map 0 + ldd #$3808 block $38, 8 times + ldx #$FFA0 where to put it +Lp sta 8,x put into map 1 + sta ,x+ and into map 0 inca - decb count down + decb count down bne Lp - lda #$4C standard DECB mapping + lda #$4C standard DECB mapping sta >$FF90 - clr >$FF91 go to map type 0 - clr >$FFDE and to all-ROM mode + clr >$FF91 go to map type 0 + clr >$FFDE and to all-ROM mode ldd #$FFFF -* clrd executes as CLRA on a 6809 +* clrd executes as CLRA on a 6809 fdb $104F - tstb is it a 6809? - bne Reset yup, skip ahead -* ldmd #$00 go to 6809 mode! + tstb is it a 6809? + bne Reset yup, skip ahead +* ldmd #$00 go to 6809 mode! fcb $11,$3D,$00 Reset jmp [$FFFE] do a reset CodeSize equ *-ReBootLoc -
--- a/level2/modules/kernel/fdelimg.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/fdelimg.asm Mon Nov 28 08:31:26 2016 +0000 @@ -17,7 +17,7 @@ lsla 2 bytes per block entry leau a,u Point U to block entry * Block count in B -L0B55 +L0B55 IFNE H6309 ldw ,u Get block # addw <D.BlkMap Add it to map ptr @@ -47,6 +47,5 @@ ora #ImgChg sta P$State,x ENDC - clrb - rts - + clrb + rts
--- a/level2/modules/kernel/fdelram.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/fdelram.asm Mon Nov 28 08:31:26 2016 +0000 @@ -36,4 +36,4 @@ decb count down a block bne DelRAM.1 continue DelRAM.2 clrb and exit - rts + rts
--- a/level2/modules/kernel/fexit.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/fexit.asm Mon Nov 28 08:31:26 2016 +0000 @@ -9,62 +9,62 @@ * * Error: CC = C bit set; B = error code * -FExit ldx <D.Proc get current process pointer - bsr L05A5 close all the paths - ldb R$B,u get exit signal - stb <P$Signal,x and save in proc desc +FExit ldx <D.Proc get current process pointer + bsr L05A5 close all the paths + ldb R$B,u get exit signal + stb <P$Signal,x and save in proc desc leay P$PID,x - bra L0563 go find kids... + bra L0563 go find kids... -L0551 clr P$SID,y clear child ID - lbsr L0B2E find its proc desc - clr 1,y clear sibling ID +L0551 clr P$SID,y clear child ID + lbsr L0B2E find its proc desc + clr 1,y clear sibling ID IFNE H6309 tim #Dead,P$State,y ELSE - lda P$State,y get child's state - bita #Dead is it dead? + lda P$State,y get child's state + bita #Dead is it dead? ENDC - beq L0563 ...no - lda P$ID,y else get its ID - lbsr L0386 and destroy its proc desc -L0563 lda P$SID,y get child ID - bne L0551 ...yes, loop + beq L0563 ...no + lda P$ID,y else get its ID + lbsr L0386 and destroy its proc desc +L0563 lda P$SID,y get child ID + bne L0551 ...yes, loop - leay ,x kid's proc desc + leay ,x kid's proc desc ldx #D.WProcQ-P$Queue - lds <D.SysStk use system stack - pshs cc save CC - orcc #IntMasks halt interrupts - lda P$PID,y get our parent ID - bne L0584 and wake him up + lds <D.SysStk use system stack + pshs cc save CC + orcc #IntMasks halt interrupts + lda P$PID,y get our parent ID + bne L0584 and wake him up - puls cc restore CC - lda P$ID,y get our ID - lbsr L0386 give up our proc desc - bra L05A2 and start next active process + puls cc restore CC + lda P$ID,y get our ID + lbsr L0386 give up our proc desc + bra L05A2 and start next active process * Search for Waiting Parent -L0580 cmpa P$ID,x is proc desc our parent's? - beq L0592 ...yes! +L0580 cmpa P$ID,x is proc desc our parent's? + beq L0592 ...yes! -L0584 leau ,x U is base desc - ldx P$Queue,x X is next waiter - bne L0580 see if parent - puls cc restore CC - lda #(SysState!Dead) set us to system state - sta P$State,y and mark us as dead - bra L05A2 so F$Wait will find us; next proc +L0584 leau ,x U is base desc + ldx P$Queue,x X is next waiter + bne L0580 see if parent + puls cc restore CC + lda #(SysState!Dead) set us to system state + sta P$State,y and mark us as dead + bra L05A2 so F$Wait will find us; next proc * Found Parent (X) -L0592 ldd P$Queue,x take parent out of wait queue +L0592 ldd P$Queue,x take parent out of wait queue std P$Queue,u - puls cc restore CC - ldu P$SP,x get parent's stack register + puls cc restore CC + ldu P$SP,x get parent's stack register ldu R$U,u - lbsr L036C get child's death signal to parent - os9 F$AProc move parent to active queue -L05A2 os9 F$NProc start next proc in active queue + lbsr L036C get child's death signal to parent + os9 F$AProc move parent to active queue +L05A2 os9 F$NProc start next proc in active queue * Close Proc I/O Paths & Unlink Mem * Entry: U=Register stack pointer @@ -94,10 +94,10 @@ * Unlink the module L05CB ldd <D.Proc pshs d - stx <D.Proc set bad proc - ldu P$PModul,x program pointer - os9 F$UnLink unlink aborted program + stx <D.Proc set bad proc + ldu P$PModul,x program pointer + os9 F$UnLink unlink aborted program puls u,b,a - std <D.Proc reset parent proc - os9 F$DelTsk release X's task # - rts + std <D.Proc reset parent proc + os9 F$DelTsk release X's task # + rts
--- a/level2/modules/kernel/ffind64.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/ffind64.asm Mon Nov 28 08:31:26 2016 +0000 @@ -108,7 +108,7 @@ * Index entry has a totally unused 256 byte page L0AB4 orcc #Carry Set flag (didn't find one) -L0AB6 leay d,y +L0AB6 leay d,y puls a Get which index entry we were checking bcc L0AE1 If we found a blank entry, go allocate it inca Didn't, move to next index entry @@ -177,8 +177,8 @@ FRet64 lda R$A,u ldx R$X,u pshs u,y,x,d - clrb - tsta + clrb + tsta beq L0B22 IFNE H6309 lsrd (Divide by 4) @@ -194,15 +194,15 @@ beq L0B20 tfr d,y clr ,y - clrb + clrb tfr d,u - clra + clra L0B10 tst d,u bne L0B20 addb #$40 bne L0B10 - inca - os9 F$SRtMem + inca + os9 F$SRtMem lda ,s clr a,x L0B20 clr ,s+
--- a/level2/modules/kernel/ffmodul.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/ffmodul.asm Mon Nov 28 08:31:26 2016 +0000 @@ -104,11 +104,11 @@ anda #LangMask bne L06FE L06ED puls y,x,d - abx - clrb + abx + clrb ldb 1,s leas 4,s - rts + rts L06F6 leas 4,s purge stack ldd 8,s do we have a directory pointer? @@ -119,10 +119,10 @@ cmpu <D.ModDir at the beginning? bhs L06A1 no, check entry ldb #E$MNF get error code (module not found) - fcb $8C skip 2 bytes + fcb $8C skip 2 bytes L070B ldb #E$BNam get error code - coma set carry for error + coma set carry for error L070E stb 1,s save error code for caller puls d,u,pc return @@ -143,5 +143,5 @@ tfr y,d copy DAT pointer to D subd 3,s calculate DAT image offset asrb divide it by 2 - lbsr CmpLBlk convert X to logical address in 64k map + lbsr CmpLBlk convert X to logical address in 64k map puls cc,d,y,pc restore & return
--- a/level2/modules/kernel/ffork.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/ffork.asm Mon Nov 28 08:31:26 2016 +0000 @@ -34,7 +34,7 @@ ENDC * Copy network I/O pointers to new descriptor IFEQ Network-1 - pshs x,u + pshs x,u leax >P$NIO,x point to current NIO pointers leau >P$NIO,u point to buffer for new ones IFNE H6309 @@ -50,7 +50,7 @@ puls x,u restore pointers to descriptors ENDC * Copy I/O pointers to new descriptor - leax P$DIO,x + leax P$DIO,x leau P$DIO,u IFNE H6309 ldw #DefIOSiz @@ -92,7 +92,7 @@ * Copy parameters to new process lda P$PagCnt,x get memory page count - clrb + clrb subd ,s calculate destination tfr d,u set parameter destination pointer ldb P$Task,x get source task # @@ -110,7 +110,7 @@ ldy #R$Size get size of register stack os9 F$Move move the register stack over puls u,x - os9 F$DelTsk + os9 F$DelTsk ldy <D.Proc lda P$ID,x sta R$A,u @@ -126,18 +126,18 @@ sta P$State,x ENDC * Put date & time of creation into descriptor -* pshs x preserve process pointer -* leax P$DatBeg,x point to time buffer -* os9 F$Time put date/time into it -* puls x restore pointer +* pshs x preserve process pointer +* leax P$DatBeg,x point to time buffer +* os9 F$Time put date/time into it +* puls x restore pointer os9 F$AProc and start the process rts return * Fork error goes here L02CF puls x - pshs b save error - lbsr L05A5 close paths & unlink mem - lda P$ID,x get bad ID - lbsr L0386 delete proc desc & task # - comb set carry - puls pc,u,b pull error code & u & return + pshs b save error + lbsr L05A5 close paths & unlink mem + lda P$ID,x get bad ID + lbsr L0386 delete proc desc & task # + comb set carry + puls pc,u,b pull error code & u & return
--- a/level2/modules/kernel/ffreehb.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/ffreehb.asm Mon Nov 28 08:31:26 2016 +0000 @@ -22,7 +22,7 @@ L0A31 tfr b,a Copy # blocks requested to A * This gets called directly from within F$Link L0A33 suba #$09 Invert within 8 - nega + nega pshs x,d Save X, block # & block count ldd #$FFFF -1' L0A56 pshs d @@ -61,12 +61,12 @@ ldy R$Y,u Get ptr to DAT Image bsr L0A4B Go find block #'s bra L0A2C Do error checking & exit (since never called, -* not worried about speed) +* not worried about speed) L0A4B lda #$FF Value to start loop at block 0 pshs x,d Preserve X,flag & block count * lda #$01 # to add to go to next block (positive here) - nega -(-1)=+1 + nega -(-1)=+1 subb #9 Drop block count to -8 to -1 (invert within 8) negb Negate so it is a positive # again bra L0A56 Go into main find loop @@ -89,7 +89,7 @@ ldu R$U,u L0A8C pshs d,x,y,u leay <P$DATImg,x - lsla + lsla leay a,y IFNE H6309 clra @@ -107,5 +107,5 @@ ora #ImgChg sta P$State,x ENDC - clrb + clrb puls d,x,y,u,pc
--- a/level2/modules/kernel/fgblkmp.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/fgblkmp.asm Mon Nov 28 08:31:26 2016 +0000 @@ -1,7 +1,7 @@ ************************************************** * System Call: F$GBlkMp * -* Function: +* Function: * * Input: X = 1024 byte buffer pointer * @@ -23,4 +23,4 @@ ldx <D.BlkMap Get start ptr of system block map L0978 ldu R$X,u Get addr to put it that caller requested os9 F$Move Move it into caller's space - rts + rts
--- a/level2/modules/kernel/fgcmdir.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/fgcmdir.asm Mon Nov 28 08:31:26 2016 +0000 @@ -98,10 +98,10 @@ L0C95 pshs u ldu <D.ModDir bra L0CA4 -L0C9B cmpy MD$MPDAT,u same DAT ptrs? - bne L0CA2 no, skip - stx MD$MPDAT,u else update ptrs -L0CA2 leau MD$ESize,u next entry -L0CA4 cmpu <D.ModEnd last entry? - bne L0C9B no - puls u,pc else yes... return +L0C9B cmpy MD$MPDAT,u same DAT ptrs? + bne L0CA2 no, skip + stx MD$MPDAT,u else update ptrs +L0CA2 leau MD$ESize,u next entry +L0CA4 cmpu <D.ModEnd last entry? + bne L0C9B no + puls u,pc else yes... return
--- a/level2/modules/kernel/fgmoddr.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/fgmoddr.asm Mon Nov 28 08:31:26 2016 +0000 @@ -31,4 +31,4 @@ bra L0978 --- saves 4 bytes, adds 3 cycles *** ldu R$X,u Get caller's buffer ptr *** os9 F$Move Copy module directory in caller's buffer -*** rts +*** rts
--- a/level2/modules/kernel/fgprdsc.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/fgprdsc.asm Mon Nov 28 08:31:26 2016 +0000 @@ -20,4 +20,4 @@ ldy #P$Size Y=Size of process descriptor (512 bytes) ldu R$X,u Get requested place to put copy of process dsc. os9 F$Move Move it into caller's space -L0962 rts +L0962 rts
--- a/level2/modules/kernel/fgprocp.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/fgprocp.asm Mon Nov 28 08:31:26 2016 +0000 @@ -32,4 +32,4 @@ L0B40 puls d,x Get regs back comb Exit with Bad process ID error ldb #E$BPrcID - rts + rts
--- a/level2/modules/kernel/ficpt.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/ficpt.asm Mon Nov 28 08:31:26 2016 +0000 @@ -2,7 +2,7 @@ * System Call: F$Icpt * * Function: Sets the function to be called when a signal arrives. -* +* * * Input: X = Address of intercept routine * U = Address of intercept routine data area
--- a/level2/modules/kernel/fld.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/fld.asm Mon Nov 28 08:31:26 2016 +0000 @@ -14,7 +14,7 @@ ldy R$Y,u Get ptr to DAT block entry bsr L0AC8 Go get byte sta R$A,u Save in caller's A reg. - rts + rts * Entry: X=offset ($0000-$1fff) to get from block pointed to by Y (DAT entry * format) @@ -47,7 +47,7 @@ puls b,cc bra AdjBlk0 -L0AEA leax >-DAT.BlSz,x Bump offset ptr to start of block again +L0AEA leax >-DAT.BlSz,x Bump offset ptr to start of block again leay 2,y Bump source MMU block up to next on in DAT Image AdjBlk0 cmpx #DAT.BlSz Going to wrap out of our block? bhs L0AEA Yes, go adjust @@ -73,7 +73,7 @@ bsr L0B02 Go get 2 bytes std -(R$X+3),u Save into caller's X clrb No error & return - rts + rts * Get 2 bytes for LDDDXY (also called by other routines) * Should simply map in 2 blocks, and do a LDD (don't have to worry about wrap) L0B02 pshs u,y,x Preserve regs @@ -85,9 +85,9 @@ bsr AdjBlk0 Wrap address around for 1 block ldu <D.SysDAT Get sys DAT Image ptr * lda 1,u Get MMU block #0 - clra system block 0 =0 always + clra system block 0 =0 always ldb 3,u Get MMU block #1 - tfr d,u make U=blocks to re-map in once done + tfr d,u make U=blocks to re-map in once done lda 1,y Get MMU block #0 ldb 3,y Get MMU block #1 pshs cc Preserve int. status @@ -95,5 +95,4 @@ std >DAT.Regs Map in both blocks ldd ,x Get 2 bytes stu >DAT.Regs Map original blocks in -* tfr y,w Restore W puls pc,u,y,x,cc Restore regs & return
--- a/level2/modules/kernel/fldabx.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/fldabx.asm Mon Nov 28 08:31:26 2016 +0000 @@ -27,8 +27,8 @@ puls cc,a,x,u stb R$A,u Save into caller's A & return - clrb set to no errors - rts + clrb set to no errors + rts * Get pointer to task DAT image * Entry: B=Task #
--- a/level2/modules/kernel/flink.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/flink.asm Mon Nov 28 08:31:26 2016 +0000 @@ -90,7 +90,7 @@ lsrb * adda #$02 lsra - inca instead of adda #2, above + inca instead of adda #2, above lsra lsra lsra @@ -138,18 +138,18 @@ addd R$U,u add it to start of module std R$Y,u set execution entry point clrb No error & return - rts + rts LinkErr orcc #Carry Error & return puls u,pc L0422 ldx <D.Proc get pointer to current process leay P$DATImg,x point to process DAT image - clra + clra pshs d,x,y subb #DAT.BlCt - negb - lslb + negb + lslb leay b,y IFNE H6309 L0430 ldw ,s Get counter @@ -168,9 +168,9 @@ bne L0434 If not done, keep going puls d,u subd 4,s - lsrb + lsrb stb ,s - clrb + clrb puls d,x,y,pc Restore regs & return L0449 puls u,y
--- a/level2/modules/kernel/fmapblk.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/fmapblk.asm Mon Nov 28 08:31:26 2016 +0000 @@ -39,11 +39,11 @@ pshs d ENDC lsla Multiply start block # by 32 - lsla - lsla - lsla - lsla - clrb + lsla + lsla + lsla + lsla + clrb std R$U,u save address of first block IFNE H6309 tfr w,d Restore offset @@ -53,8 +53,8 @@ leau ,s move DAT image into process descriptor os9 F$SetImg Change process dsc to reflect new blocks L0BA6 leas <$10,s Eat DAT image copy & return - rts + rts L0BAA comb Illegal Block address error ldb #E$IBA - rts + rts
--- a/level2/modules/kernel/fmem.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/fmem.asm Mon Nov 28 08:31:26 2016 +0000 @@ -66,8 +66,8 @@ pshs b adda ,s+ ENDC - negb - os9 F$DelImg + negb + os9 F$DelImg L0634 puls a restore requested page count sta P$PagCnt,x save it into process descriptor L0638 lda P$PagCnt,x get page count
--- a/level2/modules/kernel/fmove.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/fmove.asm Mon Nov 28 08:31:26 2016 +0000 @@ -128,11 +128,11 @@ * 14,s=total byte count of move * Registers: X=Source pointer * U=Destination pointer -L0BXA pshs cc - ldd [<$07,s] - pshs b - ldd [<$0C,s] - pshs b +L0BXA pshs cc + ldd [<$07,s] + pshs b + ldd [<$0C,s] + pshs b ldd <$11,s cmpd $03,s bls L0B82 @@ -149,13 +149,13 @@ lda $0E,s +++ sty >$FFA5 ***** NO STACK USE BETWEEN HERE..... - tfr d,y +++ + tfr d,y +++ andb #$07 beq L0B99 L0B92 lda ,x+ sta ,u+ - decb - bne L0B92 + decb + bne L0B92 L0B99 tfr y,d +++ * ldb $0E,s --- @@ -166,8 +166,8 @@ lsra +++ lsra +++ beq L0BBC -* pshs b --- - exg x,u +* pshs b --- + exg x,u L0BA4 * pulu y,b,a --- * std ,x --- @@ -179,64 +179,64 @@ * dec ,s --- * bne L0BA4 --- * leas $01,s --- - pulu y +++ - sty ,x++ +++ - pulu y +++ - sty ,x++ +++ - pulu y +++ - sty ,x++ +++ - pulu y +++ - sty ,x++ +++ - deca +++ - bne L0BA4 +++ + pulu y +++ + sty ,x++ +++ + pulu y +++ + sty ,x++ +++ + pulu y +++ + sty ,x++ +++ + pulu y +++ + sty ,x++ +++ + deca +++ + bne L0BA4 +++ exg x,u L0BBC ldy <D.SysDAT lda $0B,y - ldb $0D,y + ldb $0D,y std >$FFA5 ***** AND HERE........... - puls cc - ldd $0E,s + puls cc + ldd $0E,s subd $0C,s - beq L0BEF + beq L0BEF std $0E,s - ldd ,s + ldd ,s subd $0C,s - bne L0BD7 + bne L0BD7 ldd #DAT.BlSz leax >-DAT.BlSz,x inc $0B,s inc $0B,s -L0BD7 std ,s - ldd $02,s +L0BD7 std ,s + ldd $02,s subd $0C,s bne L0BEA ldd #DAT.BlSz leau >-DAT.BlSz,u inc $07,s - inc $07,s -L0BEA std $02,s + inc $07,s +L0BEA std $02,s lbra L0BXA L0BEF leas <$10,s -L0BF2 clrb +L0BF2 clrb puls pc,u,y,x,b,a ENDC -L0BF3 tfr u,y save a copy of U for later +L0BF3 tfr u,y save a copy of U for later * Calculate offset within DAT image * Entry: B=Task # * X=Pointer to data * Exit : A=Offset into DAT image * X=Offset within block from original pointer * Possible bug: No one ever checks if the DAT image, in fact, exists. -L0BF5 ldu <D.TskIPt get task image ptr table +L0BF5 ldu <D.TskIPt get task image ptr table lslb - ldu b,u get ptr to this task's DAT image + ldu b,u get ptr to this task's DAT image tfr x,d copy logical address to D anda #%11100000 Keep only which 8K bank it's in beq L0C07 Bank 0, no further calcs needed - clrb force it to start on an 8K boundary + clrb force it to start on an 8K boundary IFNE H6309 - subr d,x now X=offset into the block + subr d,x now X=offset into the block ELSE pshs d tfr x,d @@ -249,4 +249,3 @@ lsra is 2 bytes) lsra L0C07 rts -
--- a/level2/modules/kernel/fnproc.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/fnproc.asm Mon Nov 28 08:31:26 2016 +0000 @@ -7,7 +7,7 @@ * * Output: Control does not return to the caller * -FNProc +FNProc IFGT Level-1 ldx <D.SysPrc get system process descriptor stx <D.Proc save it as current @@ -18,7 +18,7 @@ clrb std <D.Proc ENDC - fcb $8C skip the next 2 bytes + fcb $8C skip the next 2 bytes L0D91 cwai #^IntMasks re-enable IRQ's and wait for one L0D93 orcc #IntMasks Shut off interrupts again @@ -83,12 +83,12 @@ ldu <D.UsrIRQ Get IRQ entry point for user state stu <D.XIRQ Save as IRQ service routine ptr - ldb P$Task,x get task number - lslb 2 bytes per entry in D.TskIpt - ldy P$SP,x get stack pointer - lbsr L0E8D re-map the DAT image, if necessary + ldb P$Task,x get task number + lslb 2 bytes per entry in D.TskIpt + ldy P$SP,x get stack pointer + lbsr L0E8D re-map the DAT image, if necessary - ldb <D.Quick get quick return flag + ldb <D.Quick get quick return flag bra L0E4C Go switch GIME over to new process & run * Process a signal (process had no signal trap) @@ -100,10 +100,10 @@ orb #SysState stb P$State,x ENDC - leas >P$Stack,x Point SP to process' stack - andcc #^IntMasks Turn interrupts on - ldb <P$Signal,x Get signal that process received - clr <P$Signal,x Clear out the one in process dsc. - os9 F$Exit Exit with signal # being error code + leas >P$Stack,x Point SP to process' stack + andcc #^IntMasks Turn interrupts on + ldb <P$Signal,x Get signal that process received + clr <P$Signal,x Clear out the one in process dsc. + os9 F$Exit Exit with signal # being error code -S.SvcIRQ jmp [>D.Poll] Call IOMAN for IRQ polling +S.SvcIRQ jmp [>D.Poll] Call IOMAN for IRQ polling
--- a/level2/modules/kernel/fsend.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/fsend.asm Mon Nov 28 08:31:26 2016 +0000 @@ -124,11 +124,10 @@ L06E0 ldd P$Queue,x std P$Queue,y lda P$Signal,x - deca + deca bne L06F1 sta P$Signal,x lda ,s tfr a,cc L06F1 os9 F$AProc activate the process L06F4 puls cc,a,y,u,pc restore & return -
--- a/level2/modules/kernel/fsleep.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/fsleep.asm Mon Nov 28 08:31:26 2016 +0000 @@ -22,7 +22,7 @@ deca wakeup signal? bne L0715 no, skip ahead sta P$Signal,x clear pending signal so we can wake up process -L0715 +L0715 IFNE H6309 aim #^Suspend,P$State,x ELSE @@ -96,8 +96,8 @@ ldx P$Queue,x bne L0770 ldx <D.Proc - clra - clrb + clra + clrb stx P$Queue,y std P$Queue,x puls cc @@ -116,10 +116,10 @@ ENDC pshs cc,d sts P$SP,x - os9 F$NProc + os9 F$NProc L079C pshs x ldx <D.Proc std P$SP,x - clrb + clrb puls x,pc
--- a/level2/modules/kernel/fsprior.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/fsprior.asm Mon Nov 28 08:31:26 2016 +0000 @@ -24,5 +24,4 @@ rts return L07BD comb set carry for error ldb #E$BPrcID -L07C0 rts - +L07C0 rts
--- a/level2/modules/kernel/fsrqmem.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/fsrqmem.asm Mon Nov 28 08:31:26 2016 +0000 @@ -26,7 +26,7 @@ addd #$00FF round it up to nearest 256 byte page (e.g. $1FF = $2FE) clrb just keep # of pages (and start 8K block #, e.g. $2FE = $200) std R$D,u save rounded version back to user -* leay Bt.Start/256,y +* leay Bt.Start/256,y * leay $20,y skip Block 0 (always reserved for system) * Change to pshs a,b:use 1,s for block # to check, and ,s for TFM spot * incb skip block 0 (always reserved for system) @@ -61,8 +61,8 @@ ldw #$0020 Get size of 8K block in pages tfm s,y+ Mark entire block's worth of pages with A ELSE -L0848 ldb #32 count = 32 pages -L084A sta ,y+ mark the RAM +L0848 ldb #32 count = 32 pages +L084A sta ,y+ mark the RAM decb bne L084A ENDC @@ -104,18 +104,18 @@ sty ,s Found free contiguous pages, save SMAP entry ptr lda 1,s Get LSB of ptr lsra Divide by 32 (Calculate start 8K block #) - lsra - lsra - lsra - lsra + lsra + lsra + lsra + lsra ldb 1,s Get LSB of ptr again andb #%00011111 Keep only within 8K block offset addb R$A,u Add # pages requested addb #$1F Round up to nearest 8K block lsrb Divide by 32 (Calculate end 8K block #) - lsrb - lsrb - lsrb + lsrb + lsrb + lsrb lsrb ldx <D.SysPrc Get ptr to system proc. dsc. lbsr L09BE Allocate an image with our start/end block #'s @@ -165,7 +165,7 @@ andb #^RAMinUse stb ,x+ ENDC - deca + deca bne L08AD * Scan DAT image to find memory blocks to free up ldx <D.SysDAT get pointer to system DAT image @@ -183,10 +183,10 @@ bne L08EC no, move to next block tfr x,d subd <D.SysDAT - lslb - lslb - lslb - lslb + lslb + lslb + lslb + lslb ldu <D.SysMem get pointer to system map IFNE H6309 addr d,u @@ -239,7 +239,7 @@ * Error: CC = C bit set; B = error code * FBoot - lda #'t tried to boot + lda #'t tried to boot jsr <D.BtBug coma Set boot flag lda <D.Boot we booted once before? @@ -257,34 +257,34 @@ L0908 leax <boot,pcr * Link to module and execute L090C lda #Systm+Objct - os9 F$Link + os9 F$Link bcs L08F3 - lda #'b calling boot + lda #'b calling boot jsr <D.BtBug jsr ,y load boot file bcs L08F3 std <D.BtSz save boot file size stx <D.BtPtr save start pointer of bootfile - lda #'b boot returns OK + lda #'b boot returns OK jsr <D.BtBug * added for IOMan system memory extentions IFNE H6309 - ldd M$Name,x grab the name offset - ldd d,x find the first 2 bytes of the first module - cmpd #$4E69 'Ni' ? (NitrOS9 module?) - bne not.ext no, not system memory extensions - ldd M$Exec,x grab the execution ptr - jmp d,x and go execute the system memory extension module + ldd M$Name,x grab the name offset + ldd d,x find the first 2 bytes of the first module + cmpd #$4E69 'Ni' ? (NitrOS9 module?) + bne not.ext no, not system memory extensions + ldd M$Exec,x grab the execution ptr + jmp d,x and go execute the system memory extension module ENDC not.ext ldd <D.BtSz - bsr I.VBlock internal verify block routine + bsr I.VBlock internal verify block routine ldx <D.SysDAT get system DAT pointer - ldb $0D,x get highest allocated block number - incb allocate block 0, too - ldx <D.BlkMap point to the memory block map - lbra L01DF and go mark the blocks as used. + ldb $0D,x get highest allocated block number + incb allocate block 0, too + ldx <D.BlkMap point to the memory block map + lbra L01DF and go mark the blocks as used. ************************************************** @@ -297,46 +297,46 @@ * * Output: None * -* Error: CC = C bit set; B = error code +* Error: CC = C bit set; B = error code * -FVBlock ldd R$D,u size of block to verify - ldx R$X,u start address to verify +FVBlock ldd R$D,u size of block to verify + ldx R$X,u start address to verify I.VBlock leau d,x point to end of bootfile tfr x,d anda #$E0 - clrb + clrb pshs d,u - lsra - lsra - lsra - lsra + lsra + lsra + lsra + lsra ldy <D.SysDAT get pointer to system DAT leay a,y offset to bootfile L092D ldd M$ID,x get module ID cmpd #M$ID12 legal ID? bne L0954 no, keep looking - ldd M$Name,x find name offset pointer + ldd M$Name,x find name offset pointer pshs x leax d,x -name.prt lda ,x+ get first character of the name - jsr <D.BtBug print it out +name.prt lda ,x+ get first character of the name + jsr <D.BtBug print it out bpl name.prt - lda #C$SPAC a space + lda #C$SPAC a space jsr <D.BtBug puls x IFNE H6309 - ldd ,s offset into block - subr d,x make X=offset into block + ldd ,s offset into block + subr d,x make X=offset into block ELSE tfr x,d subd ,s tfr d,x ENDC tfr y,d - os9 F$VModul + os9 F$VModul IFNE H6309 ldw ,s leax w,x @@ -351,7 +351,7 @@ bne L0954 L094E ldd M$Size,x leax d,x - fcb $8C skip 2 bytes + fcb $8C skip 2 bytes L0954 leax 1,x move to next byte L0956 cmpx 2,s gone thru whole bootfile?
--- a/level2/modules/kernel/fstime.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/fstime.asm Mon Nov 28 08:31:26 2016 +0000 @@ -32,12 +32,11 @@ stx <D.Proc Save as current process lda #Systm+Objct Link to Clock module leax ClockNam,pc - os9 F$Link + os9 F$Link puls x Get back ptr to user's process stx <D.Proc Make it the active process again - bcs ex@ If error in Link, exit with error code + bcs ex@ If error in Link, exit with error code jmp ,y Jump into Clock -ex@ rts +ex@ rts ClockNam fcs /Clock/ -
--- a/level2/modules/kernel/fsuser.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/fsuser.asm Mon Nov 28 08:31:26 2016 +0000 @@ -7,7 +7,7 @@ * * Output: None * -* Error: CC = C bit set; B = error code +* Error: CC = C bit set; B = error code * FSUser ldx <D.Proc get current process dsc ptr ldd R$Y,u get requested user number
--- a/level2/modules/kernel/funlink.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/funlink.asm Mon Nov 28 08:31:26 2016 +0000 @@ -42,12 +42,12 @@ beq L015D already zero, get next one lda ,s get block offset lsla find offset into 64k map by multiplying by 32 - lsla - lsla - lsla - lsla - clrb - nega + lsla + lsla + lsla + lsla + clrb + nega IFNE H6309 addr d,x ELSE @@ -154,19 +154,19 @@ bne L01FB puls u Restore module ptr ELSE - pshs y save y - ldy MD$MPDAT,u module image ptr -L01FB pshs a,x save #blocks, ptr - ldd ,y get block number - clr ,y+ clear the image + pshs y save y + ldy MD$MPDAT,u module image ptr +L01FB pshs a,x save #blocks, ptr + ldd ,y get block number + clr ,y+ clear the image clr ,y+ - leax d,x point to blkmap entry + leax d,x point to blkmap entry ldb ,x andb #^(RAMinUse+ModBlock) free block stb ,x puls a,x - deca last block done? - bne L01FB ..no, loop + deca last block done? + bne L01FB ..no, loop puls y ENDC ldx <D.ModDir get module directory pointer @@ -182,9 +182,8 @@ L0226 addd #$1FFF round up to nearest block lsra calculate block # within 64k workspace - lsra - lsra - lsra - lsra - rts - + lsra + lsra + lsra + lsra + rts
--- a/level2/modules/kernel/funload.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/funload.asm Mon Nov 28 08:31:26 2016 +0000 @@ -8,7 +8,7 @@ * * Output: None * -* Error: CC = C bit set; B = error code +* Error: CC = C bit set; B = error code * FUnLoad pshs u preserve register stack pointer lda R$A,u get module type @@ -25,9 +25,9 @@ decw subtract 1 stw MD$Link,u save it back ELSE - ldx MD$Link,u get module link count - beq L0A21 branch if zero - leax -1,x else decrement + ldx MD$Link,u get module link count + beq L0A21 branch if zero + leax -1,x else decrement stx MD$Link,u ENDC bne L0A4E not zero, don't remove from memory, return @@ -38,7 +38,7 @@ * Special handling for I/O module deletion clra - ldx [MD$MPDAT,u] get 1st 2 blocks in DAT image of module + ldx [MD$MPDAT,u] get 1st 2 blocks in DAT image of module ldy <D.SysDAT get pointer to system DAT image L0A2B adda #2 cmpa #DAT.ImSz done entire DAT? @@ -46,10 +46,10 @@ cmpx a,y find block? bne L0A2B no, keep looking lsla multiply by 16 to calculate the offset - lsla - lsla - lsla - clrb + lsla + lsla + lsla + clrb addd MD$MPtr,u add in the pointer tfr d,x copy it to X os9 F$IODel delete the device from memory
--- a/level2/modules/kernel/fvmodul.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/fvmodul.asm Mon Nov 28 08:31:26 2016 +0000 @@ -9,28 +9,28 @@ * * Error: CC = C bit set; B = error code * -FVModul pshs u preserve register stack pointer - ldx R$X,u get block offset - ldy R$D,u get DAT image pointer - bsr L0463 validate it - ldx ,s get register stack pointer - stu R$U,x save address of module directory entry - puls u,pc restore & return +FVModul pshs u preserve register stack pointer + ldx R$X,u get block offset + ldy R$D,u get DAT image pointer + bsr L0463 validate it + ldx ,s get register stack pointer + stu R$U,x save address of module directory entry + puls u,pc restore & return * Validate module - shortcut for calls within OS9p1 go here (ex. OS9Boot) * Entry: X=Module block offset * Y=Module DAT image pointer -L0463 pshs x,y save block offset & DAT Image ptr - lbsr L0586 Go check module ID & header parity - bcs L0495 Error, exit - ldd #M$Type Get offset to module type - lbsr L0B02 get it - andb #LangMask Just keep language mask - pshs d Preserve ??? & language - ldd #M$Name get offset to module name +L0463 pshs x,y save block offset & DAT Image ptr + lbsr L0586 Go check module ID & header parity + bcs L0495 Error, exit + ldd #M$Type Get offset to module type + lbsr L0B02 get it + andb #LangMask Just keep language mask + pshs d Preserve ??? & language + ldd #M$Name get offset to module name lbsr L0B02 - leax d,x Point X to module name - puls a Restore type/language + leax d,x Point X to module name + puls a Restore type/language lbsr L068D puls a bcs L0497 @@ -41,9 +41,9 @@ pshs a subb ,s+ ENDC - blo L0497 If wrapped, skip ahead + blo L0497 If wrapped, skip ahead ldb #E$KwnMod - fcb $8C skip 2 bytes + fcb $8C skip 2 bytes L0491 ldb #E$DirFul L0493 orcc #Carry L0495 puls x,y,pc @@ -60,32 +60,32 @@ clrb ENDC std MD$Link,u - ldd #M$Size Get offset to size of module + ldd #M$Size Get offset to size of module lbsr L0B02 IFNE H6309 - addr x,d Add it to module ptr + addr x,d Add it to module ptr ELSE pshs x addd ,s++ ENDC std MD$MBSiz,u ldy [MD$MPDAT,u] get pointer to module DAT - ldx <D.ModDir get module directory pointer - pshs u save module pointer - fcb $8C skip 2 bytes + ldx <D.ModDir get module directory pointer + pshs u save module pointer + fcb $8C skip 2 bytes -L04BC leax MD$ESize,x move to next entry +L04BC leax MD$ESize,x move to next entry L04BE cmpx <D.ModEnd bcc L04CD - cmpx ,s match? - beq L04BC no, keep looking + cmpx ,s match? + beq L04BC no, keep looking cmpy [MD$MPDAT,x] DAT match? - bne L04BC no, keep looking + bne L04BC no, keep looking bsr L04F2 L04CD puls u ldx <D.BlkMap Get ptr to block map - ldd MD$MBSiz,u Get size of module + ldd MD$MBSiz,u Get size of module addd #$1FFF Round up to nearest 8K block lsra Divide by 32 lsra @@ -100,14 +100,14 @@ oim #ModBlock,d,x dece ELSE -L04DE pshs a,x save block size, blkmap - ldd ,y++ D = image block # - leax d,x X = blkmap ptr - ldb ,x get block marker - orb #ModBlock set module in block - stb ,x marker +L04DE pshs a,x save block size, blkmap + ldd ,y++ D = image block # + leax d,x X = blkmap ptr + ldb ,x get block marker + orb #ModBlock set module in block + stb ,x marker puls x,a - deca count-- + deca count-- ENDC bne L04DE no, keep going @@ -127,12 +127,12 @@ L0503 ldy 2,s ELSE pshs x - clra D=0000 + clra D=0000 clrb -L04FA ldy ,x last entry? - beq L0503 ..yes - std ,x++ no, clear - bra L04FA and loop +L04FA ldy ,x last entry? + beq L0503 ..yes + std ,x++ no, clear + bra L04FA and loop L0503 puls x ldy 2,s ENDC @@ -165,7 +165,7 @@ tfr a,b pshs b * incb - comb one byte shorter than incb;lslg;negb + comb one byte shorter than incb;lslg;negb lslb * negb sex @@ -201,29 +201,29 @@ sty $07,s L056E stx <D.ModDAT IFNE H6309 - ldd $05,s Get source ptr + ldd $05,s Get source ptr stx $05,s ldf 2,s clre rolw tfm d+,x+ - stw ,x Save 0 + stw ,x Save 0 ELSE ldy 5,s - ldb 2,s B=block count - stx 5,s return dir datimg ptr -L0577 ldu ,y++ copy images - stu ,x++ to new mod dat entry + ldb 2,s B=block count + stx 5,s return dir datimg ptr +L0577 ldu ,y++ copy images + stu ,x++ to new mod dat entry decb bne L0577 - clr ,x zero flag + clr ,x zero flag clr 1,x ENDC rts * Default interrupt handling routine on first booting OS9p1 S.Poll orcc #Carry - rts + rts * Check module ID & calculate module header parity & CRC * Entry: X=Block offset of module @@ -251,15 +251,15 @@ bne L05A2 no, keep going ince valid parity? ELSE - leas -1,s make var + leas -1,s make var ldd #($4A*256+M$Revs) Get initial value & count (7 bytes of header) -L05A2 sta ,s save crc - lbsr LDAXY get next byte - eora ,s do crc - decb more? - bne L05A2 ..loop - leas 1,s drop var - inca $FF+1 = 00 +L05A2 sta ,s save crc + lbsr LDAXY get next byte + eora ,s do crc + decb more? + bne L05A2 ..loop + leas 1,s drop var + inca $FF+1 = 00 ENDC beq L05B5 yes, skip ahead ldb #E$BMHP get module header parity error @@ -301,7 +301,7 @@ bne L05D8 no, keep going pshs x give up some time to system ldx #1 - os9 F$Sleep + os9 F$Sleep puls x restore module pointer L05D8 lbsr LDAXY get a byte from module into A bsr CRCCalc add it to running CRC @@ -336,7 +336,7 @@ pshs a ldd 1,u std ,u - clra + clra ldb ,s IFNE H6309 lsld @@ -346,7 +346,7 @@ ENDC eora 1,u std 1,u - clrb + clrb lda ,s IFNE H6309 lsrd @@ -362,17 +362,17 @@ ENDC std 1,u lda ,s - lsla + lsla eora ,s sta ,s - lsla - lsla + lsla + lsla eora ,s sta ,s - lsla - lsla - lsla - lsla + lsla + lsla + lsla + lsla eora ,s+ bpl L0635 IFNE H6309 @@ -385,7 +385,7 @@ eorb 2,u stb 2,u ENDC -L0635 rts +L0635 rts ************************************************** @@ -408,9 +408,9 @@ leas -3,s allocate a 3 byte buffer ldx <D.Proc point to current process descriptor lda P$Task,x get its task number - ldb <D.SysTsk get the system task number + ldb <D.SysTsk get the system task number ldx R$U,u point to user's 24 bit CRC accumulator - ldy #3 number of bytes to move + ldy #3 number of bytes to move leau ,s point to our temp buffer pshs d,x,y save [D]=task #'s,[X]=Buff,[Y]=3 lbsr L0B2C move CRC accumulator to temp buffer @@ -432,9 +432,9 @@ ENDC bne L065D no, keep going puls d,x,y restore pointers - exg a,b swap around the task numbers + exg a,b swap around the task numbers exg x,u and the pointers lbsr L0B2C move accumulator back to user leas 7,s clean up stack L0677 clrb no error - rts + rts
--- a/level2/modules/kernel/krn.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/krn.asm Mon Nov 28 08:31:26 2016 +0000 @@ -21,911 +21,911 @@ * 19r9 2004/07/12 Boisy G. Pitre * F$SRqMem now properly scans the DAT images of the system to update * the D.SysMem map. - - nam krn - ttl NitrOS-9 Level 2 Kernel - - IFP1 - use defsfile - ENDC - + + nam krn + ttl NitrOS-9 Level 2 Kernel + + IFP1 + use defsfile + ENDC + * defines for customizations -Revision set 9 module revision -Edition set 19 module Edition -Where equ $F000 absolute address of where Kernel starts in memory - - mod eom,MName,Systm,ReEnt+Revision,entry,0 - -MName fcs /Krn/ - fcb Edition - +Revision set 9 module revision +Edition set 19 module Edition +Where equ $F000 absolute address of where Kernel starts in memory + + mod eom,MName,Systm,ReEnt+Revision,entry,0 + +MName fcs /Krn/ + fcb Edition + * FILL - all unused bytes are now here - fcc /www.nitros9.org / - fcc /www.nitros9.org / - fcc /www.nitros9.org / - fcc /www.nitros9.org / - fcc /www.nitros9.org / - fcc /www.nitros9.org / - IFNE H6309 - fcc /www.nitros9.org / - fcc /www.nitros9.org / - fcc /www.nit/ - ELSE - fcc /www.nit/ - ENDC - + fcc /www.nitros9.org / + fcc /www.nitros9.org / + fcc /www.nitros9.org / + fcc /www.nitros9.org / + fcc /www.nitros9.org / + fcc /www.nitros9.org / + IFNE H6309 + fcc /www.nitros9.org / + fcc /www.nitros9.org / + fcc /www.nit/ + ELSE + fcc /www.nit/ + ENDC + * Might as well have this here as just past the end of Kernel... DisTable - fdb L0CD2+Where D.Clock absolute address at the start - fdb XSWI3+Where D.XSWI3 - fdb XSWI2+Where D.XSWI2 - fdb D.Crash D.XFIRQ crash on an FIRQ - fdb XIRQ+Where D.XIRQ - fdb XSWI+Where D.XSWI - fdb D.Crash D.XNMI crash on an NMI - fdb $0055 D.ErrRst ??? Not used as far as I can tell - fdb Sys.Vec+Where Initial Kernel system call vector -DisSize equ *-DisTable + fdb L0CD2+Where D.Clock absolute address at the start + fdb XSWI3+Where D.XSWI3 + fdb XSWI2+Where D.XSWI2 + fdb D.Crash D.XFIRQ crash on an FIRQ + fdb XIRQ+Where D.XIRQ + fdb XSWI+Where D.XSWI + fdb D.Crash D.XNMI crash on an NMI + fdb $0055 D.ErrRst ??? Not used as far as I can tell + fdb Sys.Vec+Where Initial Kernel system call vector +DisSize equ *-DisTable * DO NOT ADD ANYTHING BETWEEN THESE 2 TABLES: see code using 'SubSiz', below -LowSub equ $0160 start of low memory subroutines -SubStrt equ * +LowSub equ $0160 start of low memory subroutines +SubStrt equ * * D.Flip0 - switch to system task 0 -R.Flip0 equ * - IFNE H6309 - aim #$FE,<D.TINIT map type 0 - lde <D.TINIT another 2 bytes saved if GRFDRV does: tfr cc,e - ste >DAT.Task and we can use A here, instead of E - ELSE - pshs a - lda <D.TINIT - anda #$FE - sta <D.TINIT - sta >DAT.Task - puls a - ENDC - clr <D.SSTskN - tfr x,s - tfr a,cc - rts -SubSiz equ *-SubStrt +R.Flip0 equ * + IFNE H6309 + aim #$FE,<D.TINIT map type 0 + lde <D.TINIT another 2 bytes saved if GRFDRV does: tfr cc,e + ste >DAT.Task and we can use A here, instead of E + ELSE + pshs a + lda <D.TINIT + anda #$FE + sta <D.TINIT + sta >DAT.Task + puls a + ENDC + clr <D.SSTskN + tfr x,s + tfr a,cc + rts +SubSiz equ *-SubStrt * Don't add any code here: See L0065, below. * Interrupt service routine -Vectors jmp [<-(D.SWI3-D.XSWI3),x] (-$10) (Jmp to 2ndary vector) - +Vectors jmp [<-(D.SWI3-D.XSWI3),x] (-$10) (Jmp to 2ndary vector) + * Let's start by initializing system page -entry equ * - IFNE H6309 - ldq #$01001f00 start address to clear & # bytes to clear - leay <entry+2,pc point to a 0 - tfm y,d+ - std <D.CCStk set pointer to top of global memory to $2000 - lda #$01 set task user table to $0100 - ELSE - ldx #$100 - ldy #$2000-$100 - clra - clrb -L001C std ,x++ - leay -2,y - bne L001C - stx <D.CCStk Set pointer to top of global memory to $2000 - inca D = $0100 - ENDC - +entry equ * + IFNE H6309 + ldq #$01001f00 start address to clear & # bytes to clear + leay <entry+2,pc point to a 0 + tfm y,d+ + std <D.CCStk set pointer to top of global memory to $2000 + lda #$01 set task user table to $0100 + ELSE + ldx #$100 + ldy #$2000-$100 + clra + clrb +L001C std ,x++ + leay -2,y + bne L001C + stx <D.CCStk Set pointer to top of global memory to $2000 + inca D = $0100 + ENDC + * Setup system direct page variables - std <D.Tasks - addb #$20 set Task image table to $0120 - std <D.TskIPt - clrb set memory block map to $0200 - inca - std <D.BlkMap - addb #$40 set second block map to $0240 - std <D.BlkMap+2 - clrb set system service dispatch table to $0300 - inca - std <D.SysDis - inca set user dispatch table to $0400 - std <D.UsrDis - inca set process descriptor block to $0500 - std <D.PrcDBT - inca set system process descriptor to $0600 - std <D.SysPrc - std <D.Proc set user process descriptor to $0600 - adda #$02 set stack pointer to $0800 - tfr d,s - inca set system stack to $0900 - std <D.SysStk - std <D.SysMem set system memory map ptr $0900 - inca set module directory start to $0a00 - std <D.ModDir - std <D.ModEnd set module directory end to $0a00 - adda #$06 set secondary module directory start to $1000 - std <D.ModDir+2 - std <D.ModDAT set module directory DAT pointer to $1000 - std <D.CCMem set pointer to beginning of global memory to $1000 + std <D.Tasks + addb #$20 set Task image table to $0120 + std <D.TskIPt + clrb set memory block map to $0200 + inca + std <D.BlkMap + addb #$40 set second block map to $0240 + std <D.BlkMap+2 + clrb set system service dispatch table to $0300 + inca + std <D.SysDis + inca set user dispatch table to $0400 + std <D.UsrDis + inca set process descriptor block to $0500 + std <D.PrcDBT + inca set system process descriptor to $0600 + std <D.SysPrc + std <D.Proc set user process descriptor to $0600 + adda #$02 set stack pointer to $0800 + tfr d,s + inca set system stack to $0900 + std <D.SysStk + std <D.SysMem set system memory map ptr $0900 + inca set module directory start to $0a00 + std <D.ModDir + std <D.ModEnd set module directory end to $0a00 + adda #$06 set secondary module directory start to $1000 + std <D.ModDir+2 + std <D.ModDAT set module directory DAT pointer to $1000 + std <D.CCMem set pointer to beginning of global memory to $1000 * In following line, CRC=ON if it is STA <D.CRC, CRC=OFF if it is a STB <D.CRC - stb <D.CRC set CRC checking flag to off - + stb <D.CRC set CRC checking flag to off + * Initialize interrupt vector tables - leay <DisTable,pcr point to table of absolute vector addresses - ldx #D.Clock where to put it in memory - IFNE H6309 - ldf #DisSize size of the table - E=0 from TFM, above - tfm y+,x+ move it over - ELSE - ldb #DisSize + leay <DisTable,pcr point to table of absolute vector addresses + ldx #D.Clock where to put it in memory + IFNE H6309 + ldf #DisSize size of the table - E=0 from TFM, above + tfm y+,x+ move it over + ELSE + ldb #DisSize l@ - lda ,y+ - sta ,x+ - decb - bne l@ - ENDC - + lda ,y+ + sta ,x+ + decb + bne l@ + ENDC + * initialize D.Flip0 routine in low memory * Y=ptr to R.Flip0 already * leay >R.Flip0,pc - ldu #LowSub somewhere in block 0 that's never modified - stu <D.Flip0 switch to system task 0 - IFNE H6309 - ldf #SubSiz size of it - tfm y+,u+ copy it over - ELSE - ldb #SubSiz -Loop2 lda ,y+ - sta ,u+ - decb - bne Loop2 - ENDC - + ldu #LowSub somewhere in block 0 that's never modified + stu <D.Flip0 switch to system task 0 + IFNE H6309 + ldf #SubSiz size of it + tfm y+,u+ copy it over + ELSE + ldb #SubSiz +Loop2 lda ,y+ + sta ,u+ + decb + bne Loop2 + ENDC + * leau <Vectors,pc point to vector - tfr y,u move the pointer to a faster register -L0065 stu ,x++ Set all IRQ vectors to go to Vectors for now - cmpx #D.NMI - bls L0065 - + tfr y,u move the pointer to a faster register +L0065 stu ,x++ Set all IRQ vectors to go to Vectors for now + cmpx #D.NMI + bls L0065 + * Initialize user interupt vectors - ldx <D.XSWI2 Get SWI2 (os9 command) service routine pointer - stx <D.UsrSvc Save it as user service routine pointer - ldx <D.XIRQ Get IRQ service routine pointer - stx <D.UsrIRQ Save it as user IRQ routine pointer - - leax >SysCall,pc Setup System service routine entry vector - stx <D.SysSvc - stx <D.XSWI2 - - leax >S.SysIRQ,pc Setup system IRQ service vector - stx <D.SysIRQ - stx <D.XIRQ - - leax >S.SvcIRQ,pc Setup in system IRQ service vector - stx <D.SvcIRQ - leax >S.Poll,pc Setup interrupt polling vector - stx <D.Poll ORCC #$01;RTS - leax >S.AltIRQ,pc Setup alternate IRQ vector: pts to an RTS - stx <D.AltIRQ - - lda #'K --- in Kernel - jsr <D.BtBug --- - - leax >S.Flip1,pc Setup change to task 1 vector - stx <D.Flip1 - + ldx <D.XSWI2 Get SWI2 (os9 command) service routine pointer + stx <D.UsrSvc Save it as user service routine pointer + ldx <D.XIRQ Get IRQ service routine pointer + stx <D.UsrIRQ Save it as user IRQ routine pointer + + leax >SysCall,pc Setup System service routine entry vector + stx <D.SysSvc + stx <D.XSWI2 + + leax >S.SysIRQ,pc Setup system IRQ service vector + stx <D.SysIRQ + stx <D.XIRQ + + leax >S.SvcIRQ,pc Setup in system IRQ service vector + stx <D.SvcIRQ + leax >S.Poll,pc Setup interrupt polling vector + stx <D.Poll ORCC #$01;RTS + leax >S.AltIRQ,pc Setup alternate IRQ vector: pts to an RTS + stx <D.AltIRQ + + lda #'K --- in Kernel + jsr <D.BtBug --- + + leax >S.Flip1,pc Setup change to task 1 vector + stx <D.Flip1 + * Setup System calls - leay >SysCalls,pc - lbsr SysSvc - + leay >SysCalls,pc + lbsr SysSvc + * Initialize system process descriptor - ldu <D.PrcDBT get process table pointer - ldx <D.SysPrc get system process pointer - + ldu <D.PrcDBT get process table pointer + ldx <D.SysPrc get system process pointer + * These overlap because it is quicker than trying to strip hi byte from X - stx ,u save it as first process in table - stx 1,u save it as the second as well - IFNE H6309 - oim #$01,P$ID,x Set process ID to 1 (inited to 0) - oim #SysState,P$State,x Set to system state (inited to 0) - ELSE - ldd #$01*256+SysState - sta P$ID,x - stb P$State,x - ENDC - clra System task is task #0 - sta <D.SysTsk - sta P$Task,x - coma Setup its priority & age ($FF) - sta P$Prior,x - sta P$Age,x - leax <P$DATImg,x point to DAT image - stx <D.SysDAT save it as a pointer in DP + stx ,u save it as first process in table + stx 1,u save it as the second as well + IFNE H6309 + oim #$01,P$ID,x Set process ID to 1 (inited to 0) + oim #SysState,P$State,x Set to system state (inited to 0) + ELSE + ldd #$01*256+SysState + sta P$ID,x + stb P$State,x + ENDC + clra System task is task #0 + sta <D.SysTsk + sta P$Task,x + coma Setup its priority & age ($FF) + sta P$Prior,x + sta P$Age,x + leax <P$DATImg,x point to DAT image + stx <D.SysDAT save it as a pointer in DP * actually, since block 0 is tfm'd to be zero, we can skip the next 2 lines - IFNE H6309 - clrd - ELSE - clra - clrb - ENDC - std ,x++ initialize 1st block to 0 (for this DP) - + IFNE H6309 + clrd + ELSE + clra + clrb + ENDC + std ,x++ initialize 1st block to 0 (for this DP) + * Dat.BlCt-ROMCount-RAMCount - lda #$06 initialize the rest of the blocks to be free - ldu #DAT.Free -L00EF stu ,x++ - deca - bne L00EF - - ldu #$003F Block $3F is in use, at the top of system DAT image - stu ,x - - ldx <D.Tasks Point to task user table - inc ,x mark first 2 in use (system & GrfDrv) - inc 1,x - + lda #$06 initialize the rest of the blocks to be free + ldu #DAT.Free +L00EF stu ,x++ + deca + bne L00EF + + ldu #$003F Block $3F is in use, at the top of system DAT image + stu ,x + + ldx <D.Tasks Point to task user table + inc ,x mark first 2 in use (system & GrfDrv) + inc 1,x + * Setup system memory map - ldx <D.SysMem Get system memory map pointer - ldb <D.CCStk Get MSB of top of CC memory -L0104 inc ,x+ Mark it as used - decb Done? - bne L0104 No, go back till done - + ldx <D.SysMem Get system memory map pointer + ldb <D.CCStk Get MSB of top of CC memory +L0104 inc ,x+ Mark it as used + decb Done? + bne L0104 No, go back till done + * Calculate memory size - ldx <D.BlkMap get ptr to 8k block map - inc <$3F,x mark block $3F as used (kernel) - IFNE H6309 - ldq #$00080100 e=Marker, D=Block # to check -L0111 asld get next block # - stb >$FFA5 Map block into block 6 of my task - ste >-$6000,x save marker to that block - cmpe ,x did it ghost to block 0? - bne L0111 No, keep going till ghost is found - stb <D.MemSz Save # 8k mem blocks that exist - addr x,d add number of blocks to block map start - ELSE - ldd #$0008 -L0111 aslb - rola - stb >$FFA5 - pshs a - lda #$01 - sta >-$6000,x - cmpa ,x - puls a - bne L0111 - stb <D.MemSz - pshs x - addd ,s++ - ENDC - std <D.BlkMap+2 save block map end pointer - + ldx <D.BlkMap get ptr to 8k block map + inc <$3F,x mark block $3F as used (kernel) + IFNE H6309 + ldq #$00080100 e=Marker, D=Block # to check +L0111 asld get next block # + stb >$FFA5 Map block into block 6 of my task + ste >-$6000,x save marker to that block + cmpe ,x did it ghost to block 0? + bne L0111 No, keep going till ghost is found + stb <D.MemSz Save # 8k mem blocks that exist + addr x,d add number of blocks to block map start + ELSE + ldd #$0008 +L0111 aslb + rola + stb >$FFA5 + pshs a + lda #$01 + sta >-$6000,x + cmpa ,x + puls a + bne L0111 + stb <D.MemSz + pshs x + addd ,s++ + ENDC + std <D.BlkMap+2 save block map end pointer + * [D] at this point will contain 1 of the following: * $0210 - 128k * $0220 - 256k * $0240 - 512k * $0280 - 1024k * $0300 - 2048k - bitb #%00110000 block above 128K-256K? - beq L0170 yes, no need to mark block map - tstb 2 meg? - beq L0170 yes, skip this + bitb #%00110000 block above 128K-256K? + beq L0170 yes, no need to mark block map + tstb 2 meg? + beq L0170 yes, skip this * Mark blocks from 128k-256K to block $3F as NOT RAM - abx add maximum block number to block map start - leax -1,x Skip good blocks that are RAM - lda #NotRAM Not RAM flag - subb #$3F Calculate # blocks to mark as not RAM -L0127 sta ,x+ Mark them all - decb - bne L0127 - -L0170 ldx #Bt.Start start address of the boot track in memory - lda #18 size of the boot track: B=$00 from L0127 loop, above - lbsr I.VBlock go verify it - - bsr L01D2 go mark system map - + abx add maximum block number to block map start + leax -1,x Skip good blocks that are RAM + lda #NotRAM Not RAM flag + subb #$3F Calculate # blocks to mark as not RAM +L0127 sta ,x+ Mark them all + decb + bne L0127 + +L0170 ldx #Bt.Start start address of the boot track in memory + lda #18 size of the boot track: B=$00 from L0127 loop, above + lbsr I.VBlock go verify it + + bsr L01D2 go mark system map + * See if init module is in memory already -L01B0 leax <init,pc point to 'Init' module name - bsr link try & link it - bcc L01BF no error, go on -L01B8 os9 F$Boot error linking init, try & load boot file - bcc L01B0 got it, try init again - bra L01CE error, re-booting do D.Crash +L01B0 leax <init,pc point to 'Init' module name + bsr link try & link it + bcc L01BF no error, go on +L01B8 os9 F$Boot error linking init, try & load boot file + bcc L01B0 got it, try init again + bra L01CE error, re-booting do D.Crash * Save pointer to init module and execute krnp2 -L01BF stu <D.Init Save init module pointer - lda Feature1,u Get feature byte #1 from init module - bita #CRCOn CRC feature on? - beq ShowI if not, continue - inc <D.CRC else inc. CRC flag -ShowI lda #'i found init module - jsr <D.BtBug - -L01C1 leax <krnp2,pc Point to it's name - bsr link Try to link it - bcc L01D0 It worked, execute it - os9 F$Boot It doesn't exist try re-booting - bcc L01C1 No error's, let's try to link it again -L01CE jmp <D.Crash obviously can't do it, crash machine -L01D0 jmp ,y execute krnp2 - +L01BF stu <D.Init Save init module pointer + lda Feature1,u Get feature byte #1 from init module + bita #CRCOn CRC feature on? + beq ShowI if not, continue + inc <D.CRC else inc. CRC flag +ShowI lda #'i found init module + jsr <D.BtBug + +L01C1 leax <krnp2,pc Point to it's name + bsr link Try to link it + bcc L01D0 It worked, execute it + os9 F$Boot It doesn't exist try re-booting + bcc L01C1 No error's, let's try to link it again +L01CE jmp <D.Crash obviously can't do it, crash machine +L01D0 jmp ,y execute krnp2 + * Mark kernel in system memory map as used memory (256 byte blocks) -L01D2 ldx <D.SysMem Get system mem ptr - ldd #NotRAM*256+(Bt.Start/256) B = MSB of start of the boot - abx point to Bt.Start - start of boot track - comb we have $FF-$ED pages to mark as used - sta b,x Mark I/O as not RAM -L01DF lda #RAMinUse get in use flag -L01E1 sta ,x+ save it - decb done? - bne L01E1 no, keep going - ldx <D.BlkMap get pointer to start of block map - sta <$3f,x mark kernel block as RAMinUse, instead of ModInBlk -S.AltIRQ rts return - +L01D2 ldx <D.SysMem Get system mem ptr + ldd #NotRAM*256+(Bt.Start/256) B = MSB of start of the boot + abx point to Bt.Start - start of boot track + comb we have $FF-$ED pages to mark as used + sta b,x Mark I/O as not RAM +L01DF lda #RAMinUse get in use flag +L01E1 sta ,x+ save it + decb done? + bne L01E1 no, keep going + ldx <D.BlkMap get pointer to start of block map + sta <$3f,x mark kernel block as RAMinUse, instead of ModInBlk +S.AltIRQ rts return + * Link module pointed to by X -link lda #Systm Attempt to link system module - os9 F$Link - rts - -init fcs 'Init' -krnp2 fcs 'krnp2' - +link lda #Systm Attempt to link system module + os9 F$Link + rts + +init fcs 'Init' +krnp2 fcs 'krnp2' + * Service vector call pointers -SysCalls fcb F$Link - fdb FLink-*-2 - fcb F$PrsNam - fdb FPrsNam-*-2 - fcb F$CmpNam - fdb FCmpNam-*-2 - fcb F$CmpNam+SysState - fdb FSCmpNam-*-2 - fcb F$CRC - fdb FCRC-*-2 - fcb F$SRqMem+SysState - fdb FSRqMem-*-2 - fcb F$SRtMem+SysState - fdb FSRtMem-*-2 - fcb F$AProc+SysState - fdb FAProc-*-2 - fcb F$NProc+SysState - fdb FNProc-*-2 - fcb F$VModul+SysState - fdb FVModul-*-2 - fcb F$SSvc+SysState - fdb FSSvc-*-2 - fcb F$SLink+SysState - fdb FSLink-*-2 - fcb F$Boot+SysState - fdb FBoot-*-2 - fcb F$BtMem+SysState - fdb FSRqMem-*-2 - IFNE H6309 - fcb F$CpyMem - fdb FCpyMem-*-2 - ENDC - fcb F$Move+SysState - fdb FMove-*-2 - fcb F$AllImg+SysState - fdb FAllImg-*-2 - fcb F$SetImg+SysState - fdb FFreeLB-*-2 - fcb F$FreeLB+SysState - fdb FSFreeLB-*-2 - fcb F$FreeHB+SysState - fdb FFreeHB-*-2 - fcb F$AllTsk+SysState - fdb FAllTsk-*-2 - fcb F$DelTsk+SysState - fdb FDelTsk-*-2 - fcb F$SetTsk+SysState - fdb FSetTsk-*-2 - fcb F$ResTsk+SysState - fdb FResTsk-*-2 - fcb F$RelTsk+SysState - fdb FRelTsk-*-2 - fcb F$DATLog+SysState - fdb FDATLog-*-2 - fcb F$LDAXY+SysState - fdb FLDAXY-*-2 - fcb F$LDDDXY+SysState - fdb FLDDDXY-*-2 - fcb F$LDABX+SysState - fdb FLDABX-*-2 - fcb F$STABX+SysState - fdb FSTABX-*-2 - fcb F$ELink+SysState - fdb FELink-*-2 - fcb F$FModul+SysState - fdb FFModul-*-2 - fcb F$VBlock+SysState - fdb FVBlock-*-2 - IFNE H6309 - fcb F$DelRAM - fdb FDelRAM-*-2 - ENDC - fcb $80 - +SysCalls fcb F$Link + fdb FLink-*-2 + fcb F$PrsNam + fdb FPrsNam-*-2 + fcb F$CmpNam + fdb FCmpNam-*-2 + fcb F$CmpNam+SysState + fdb FSCmpNam-*-2 + fcb F$CRC + fdb FCRC-*-2 + fcb F$SRqMem+SysState + fdb FSRqMem-*-2 + fcb F$SRtMem+SysState + fdb FSRtMem-*-2 + fcb F$AProc+SysState + fdb FAProc-*-2 + fcb F$NProc+SysState + fdb FNProc-*-2 + fcb F$VModul+SysState + fdb FVModul-*-2 + fcb F$SSvc+SysState + fdb FSSvc-*-2 + fcb F$SLink+SysState + fdb FSLink-*-2 + fcb F$Boot+SysState + fdb FBoot-*-2 + fcb F$BtMem+SysState + fdb FSRqMem-*-2 + IFNE H6309 + fcb F$CpyMem + fdb FCpyMem-*-2 + ENDC + fcb F$Move+SysState + fdb FMove-*-2 + fcb F$AllImg+SysState + fdb FAllImg-*-2 + fcb F$SetImg+SysState + fdb FFreeLB-*-2 + fcb F$FreeLB+SysState + fdb FSFreeLB-*-2 + fcb F$FreeHB+SysState + fdb FFreeHB-*-2 + fcb F$AllTsk+SysState + fdb FAllTsk-*-2 + fcb F$DelTsk+SysState + fdb FDelTsk-*-2 + fcb F$SetTsk+SysState + fdb FSetTsk-*-2 + fcb F$ResTsk+SysState + fdb FResTsk-*-2 + fcb F$RelTsk+SysState + fdb FRelTsk-*-2 + fcb F$DATLog+SysState + fdb FDATLog-*-2 + fcb F$LDAXY+SysState + fdb FLDAXY-*-2 + fcb F$LDDDXY+SysState + fdb FLDDDXY-*-2 + fcb F$LDABX+SysState + fdb FLDABX-*-2 + fcb F$STABX+SysState + fdb FSTABX-*-2 + fcb F$ELink+SysState + fdb FELink-*-2 + fcb F$FModul+SysState + fdb FFModul-*-2 + fcb F$VBlock+SysState + fdb FVBlock-*-2 + IFNE H6309 + fcb F$DelRAM + fdb FDelRAM-*-2 + ENDC + fcb $80 + * SWI3 vector entry -XSWI3 lda #P$SWI3 point to SWI3 vector - fcb $8C skip 2 bytes - +XSWI3 lda #P$SWI3 point to SWI3 vector + fcb $8C skip 2 bytes + * SWI vector entry -XSWI lda #P$SWI point to SWI vector - ldx <D.Proc get process pointer - ldu a,x user defined SWI[x]? - beq L028E no, go get option byte -GoUser lbra L0E5E Yes, go call users's routine - +XSWI lda #P$SWI point to SWI vector + ldx <D.Proc get process pointer + ldu a,x user defined SWI[x]? + beq L028E no, go get option byte +GoUser lbra L0E5E Yes, go call users's routine + * SWI2 vector entry -XSWI2 ldx <D.Proc get current process descriptor - ldu P$SWI2,x any SWI vector? - bne GoUser yes, go execute it - +XSWI2 ldx <D.Proc get current process descriptor + ldu P$SWI2,x any SWI vector? + bne GoUser yes, go execute it + * Process software interupts from a user state * Entry: X=Process descriptor pointer of process that made system call * U=Register stack pointer -L028E ldu <D.SysSvc set system call processor to system side - stu <D.XSWI2 - ldu <D.SysIRQ do the same thing for IRQ's - stu <D.XIRQ - IFNE H6309 - oim #SysState,P$State,x mark process as in system state - ELSE - lda P$State,x - ora #SysState - sta P$State,x - ENDC +L028E ldu <D.SysSvc set system call processor to system side + stu <D.XSWI2 + ldu <D.SysIRQ do the same thing for IRQ's + stu <D.XIRQ + IFNE H6309 + oim #SysState,P$State,x mark process as in system state + ELSE + lda P$State,x + ora #SysState + sta P$State,x + ENDC * copy register stack to process descriptor - sts P$SP,x save stack pointer - leas (P$Stack-R$Size),x point S to register stack destination - - IFNE H6309 - leau R$Size-1,s point to last byte of destination register stack - leay -1,y point to caller's register stack in $FEE1 - ldw #R$Size size of the register stack - tfm y-,u- - leau ,s needed because the TFM is u-, not -u (post, not pre) - ELSE + sts P$SP,x save stack pointer + leas (P$Stack-R$Size),x point S to register stack destination + + IFNE H6309 + leau R$Size-1,s point to last byte of destination register stack + leay -1,y point to caller's register stack in $FEE1 + ldw #R$Size size of the register stack + tfm y-,u- + leau ,s needed because the TFM is u-, not -u (post, not pre) + ELSE * Note! R$Size MUST BE an EVEN number of bytes for this to work! - leau R$Size,s point to last byte of destination register stack - lda #R$Size/2 -Loop3 ldx ,--y - stx ,--u - deca - bne Loop3 - ENDC - andcc #^IntMasks + leau R$Size,s point to last byte of destination register stack + lda #R$Size/2 +Loop3 ldx ,--y + stx ,--u + deca + bne Loop3 + ENDC + andcc #^IntMasks * B=function code already from calling process: DON'T USE IT! - ldx R$PC,u get where PC was from process - leax 1,x move PC past option - stx R$PC,u save updated PC to process + ldx R$PC,u get where PC was from process + leax 1,x move PC past option + stx R$PC,u save updated PC to process * execute function call - ldy <D.UsrDis get user dispatch table pointer - lbsr L033B go execute option - IFNE H6309 - aim #^IntMasks,R$CC,u Clear interrupt flags in caller's CC - ELSE - lda R$CC,u - anda #^IntMasks - sta R$CC,u - ENDC - ldx <D.Proc get current process ptr - IFNE H6309 - aim #^(SysState+TimOut),P$State,x Clear system & timeout flags - ELSE - lda P$State,x - anda #^(SysState+TimOut) - sta P$State,x - ENDC - + ldy <D.UsrDis get user dispatch table pointer + lbsr L033B go execute option + IFNE H6309 + aim #^IntMasks,R$CC,u Clear interrupt flags in caller's CC + ELSE + lda R$CC,u + anda #^IntMasks + sta R$CC,u + ENDC + ldx <D.Proc get current process ptr + IFNE H6309 + aim #^(SysState+TimOut),P$State,x Clear system & timeout flags + ELSE + lda P$State,x + anda #^(SysState+TimOut) + sta P$State,x + ENDC + * Check for image change now, which lets stuff like F$MapBlk and F$ClrBlk * do the short-circuit thing, too. Adds about 20 cycles to each system call. - lbsr TstImg it doesn't hurt to call this twice - lda P$State,x get current state of the process - ora <P$Signal,x is there a pending signal? - sta <D.Quick save quick return flag - beq AllClr if nothing's have changed, do full checks - -DoFull bsr L02DA move the stack frame back to user state - lbra L0D80 go back to the process - + lbsr TstImg it doesn't hurt to call this twice + lda P$State,x get current state of the process + ora <P$Signal,x is there a pending signal? + sta <D.Quick save quick return flag + beq AllClr if nothing's have changed, do full checks + +DoFull bsr L02DA move the stack frame back to user state + lbra L0D80 go back to the process + * add ldu P$SP,x, etc... -AllClr equ * - IFNE H6309 - inc <D.QCnt - aim #$1F,<D.QCnt - beq DoFull every 32 system calls, do the full check - ldw #R$Size --- size of the register stack - ldy #Where+SWIStack --- to stack at top of memory - orcc #IntMasks - tfm u+,y+ --- move the stack to the top of memory - ELSE - lda <D.QCnt - inca - anda #$1F - sta <D.QCnt - beq DoFull - ldb #R$Size - ldy #Where+SWIStack - orcc #IntMasks -Loop4 lda ,u+ - sta ,y+ - decb - bne Loop4 - ENDC - lbra BackTo1 otherwise simply return to the user - +AllClr equ * + IFNE H6309 + inc <D.QCnt + aim #$1F,<D.QCnt + beq DoFull every 32 system calls, do the full check + ldw #R$Size --- size of the register stack + ldy #Where+SWIStack --- to stack at top of memory + orcc #IntMasks + tfm u+,y+ --- move the stack to the top of memory + ELSE + lda <D.QCnt + inca + anda #$1F + sta <D.QCnt + beq DoFull + ldb #R$Size + ldy #Where+SWIStack + orcc #IntMasks +Loop4 lda ,u+ + sta ,y+ + decb + bne Loop4 + ENDC + lbra BackTo1 otherwise simply return to the user + * Copy register stack from user to system * Entry: U=Ptr to Register stack in process dsc -L02CB pshs cc,x,y,u preserve registers - ldb P$Task,x get task # - ldx P$SP,x get stack pointer - lbsr L0BF3 calculate block offset (only affects A&X) - leax -$6000,x adjust pointer to where memory map will be - bra L02E9 go copy it - +L02CB pshs cc,x,y,u preserve registers + ldb P$Task,x get task # + ldx P$SP,x get stack pointer + lbsr L0BF3 calculate block offset (only affects A&X) + leax -$6000,x adjust pointer to where memory map will be + bra L02E9 go copy it + * Copy register stack from system to user * Entry: U=Ptr to Register stack in process dsc -L02DA pshs cc,x,y,u preserve registers - ldb P$Task,x get task # of destination - ldx P$SP,x get stack pointer - lbsr L0BF3 calculate block offset (only affects A&X) - leax -$6000,x adjust pointer to where memory map will be - exg x,y swap pointers & copy +L02DA pshs cc,x,y,u preserve registers + ldb P$Task,x get task # of destination + ldx P$SP,x get stack pointer + lbsr L0BF3 calculate block offset (only affects A&X) + leax -$6000,x adjust pointer to where memory map will be + exg x,y swap pointers & copy * Copy a register stack * Entry: X=Source * Y=Destination * A=Offset into DAT image of stack * B=Task # -L02E9 leau a,u point to block # of where stack is - lda 1,u get first block - ldb 3,u get a second just in case of overlap - orcc #IntMasks shutdown interupts while we do this - std >$FFA5 map blocks in - IFNE H6309 - ldw #R$Size get size of register stack - tfm x+,y+ copy it - ELSE - ldb #R$Size -Loop5 lda ,x+ - sta ,y+ - decb - bne Loop5 - ENDC - ldx <D.SysDAT remap the blocks we took out - lda $0B,x - ldb $0D,x - std >$FFA5 - puls cc,x,y,u,pc restore & return - +L02E9 leau a,u point to block # of where stack is + lda 1,u get first block + ldb 3,u get a second just in case of overlap + orcc #IntMasks shutdown interupts while we do this + std >$FFA5 map blocks in + IFNE H6309 + ldw #R$Size get size of register stack + tfm x+,y+ copy it + ELSE + ldb #R$Size +Loop5 lda ,x+ + sta ,y+ + decb + bne Loop5 + ENDC + ldx <D.SysDAT remap the blocks we took out + lda $0B,x + ldb $0D,x + std >$FFA5 + puls cc,x,y,u,pc restore & return + * Process software interupts from system state * Entry: U=Register stack pointer -SysCall leau ,s get pointer to register stack - lda <D.SSTskN Get system task # (0=SYSTEM, 1=GRFDRV) - clr <D.SSTskN Force to System Process - pshs a Save the system task number - lda ,u Restore callers CC register (R$CC=$00) - tfr a,cc make it current - ldx R$PC,u Get my caller's PC register - leax 1,x move PC to next position - stx R$PC,u Save my caller's updated PC register - ldy <D.SysDis get system dispatch table pointer - bsr L033B execute system call - puls a restore system state task number - lbra L0E2B return to process - +SysCall leau ,s get pointer to register stack + lda <D.SSTskN Get system task # (0=SYSTEM, 1=GRFDRV) + clr <D.SSTskN Force to System Process + pshs a Save the system task number + lda ,u Restore callers CC register (R$CC=$00) + tfr a,cc make it current + ldx R$PC,u Get my caller's PC register + leax 1,x move PC to next position + stx R$PC,u Save my caller's updated PC register + ldy <D.SysDis get system dispatch table pointer + bsr L033B execute system call + puls a restore system state task number + lbra L0E2B return to process + * Entry: X = system call vector to jump to -Sys.Vec jmp ,x execute service call - +Sys.Vec jmp ,x execute service call + * Execute system call * Entry: B=Function call # * Y=Function dispatch table pointer (D.SysDis or D.UsrDis) -L033B - lslb is it a I/O call? (Also multiplys by 2 for offset) - bcc L0345 no, go get normal vector +L033B + lslb is it a I/O call? (Also multiplys by 2 for offset) + bcc L0345 no, go get normal vector * Execute I/O system calls - ldx IOEntry,y get IOMan vector + ldx IOEntry,y get IOMan vector * Execute the system call -L034F pshs u preserve register stack pointer - jsr [D.SysVec] perform a vectored system call - puls u restore pointer -L0355 tfr cc,a move CC to A for stack update - bcc L035B go update it if no error from call - stb R$B,u save error code to caller's B -L035B ldb R$CC,u get callers CC, R$CC=$00 - IFNE H6309 - andd #$2FD0 [A]=H,N,Z,V,C [B]=E,F,I - orr b,a merge them together - ELSE - anda #$2F [A]=H,N,Z,V,C - andb #$D0 [B]=E,F,I - pshs b - ora ,s+ - ENDC - sta R$CC,u return it to caller, R$CC=$00 - rts - +L034F pshs u preserve register stack pointer + jsr [D.SysVec] perform a vectored system call + puls u restore pointer +L0355 tfr cc,a move CC to A for stack update + bcc L035B go update it if no error from call + stb R$B,u save error code to caller's B +L035B ldb R$CC,u get callers CC, R$CC=$00 + IFNE H6309 + andd #$2FD0 [A]=H,N,Z,V,C [B]=E,F,I + orr b,a merge them together + ELSE + anda #$2F [A]=H,N,Z,V,C + andb #$D0 [B]=E,F,I + pshs b + ora ,s+ + ENDC + sta R$CC,u return it to caller, R$CC=$00 + rts + * Execute regular system calls -L0345 - clra clear MSB of offset - ldx d,y get vector to call - bne L034F it's initialized, go execute it - comb set carry for error - ldb #E$UnkSvc get error code - bra L0355 return with it - - use fssvc.asm - - use flink.asm - - use fvmodul.asm - - use ffmodul.asm - - use fprsnam.asm - - use fcmpnam.asm - - use fsrqmem.asm - +L0345 + clra clear MSB of offset + ldx d,y get vector to call + bne L034F it's initialized, go execute it + comb set carry for error + ldb #E$UnkSvc get error code + bra L0355 return with it + + use fssvc.asm + + use flink.asm + + use fvmodul.asm + + use ffmodul.asm + + use fprsnam.asm + + use fcmpnam.asm + + use fsrqmem.asm + * use fallram.asm - - - IFNE H6309 - use fdelram.asm - ENDC - - use fallimg.asm - - use ffreehb.asm - - use fdatlog.asm - - use fld.asm - - IFNE H6309 - use fcpymem.asm - ENDC - - use fmove.asm - - use fldabx.asm - - use falltsk.asm - - use faproc.asm - + + + IFNE H6309 + use fdelram.asm + ENDC + + use fallimg.asm + + use ffreehb.asm + + use fdatlog.asm + + use fld.asm + + IFNE H6309 + use fcpymem.asm + ENDC + + use fmove.asm + + use fldabx.asm + + use falltsk.asm + + use faproc.asm + * System IRQ service routine -XIRQ ldx <D.Proc get current process pointer - sts P$SP,x save the stack pointer - lds <D.SysStk get system stack pointer - ldd <D.SysSvc set system service routine to current - std <D.XSWI2 - ldd <D.SysIRQ set system IRQ routine to current - std <D.XIRQ - jsr [>D.SvcIRQ] execute irq service - bcc L0D5B - - ldx <D.Proc get current process pointer - ldb P$Task,x - ldx P$SP,x get it's stack pointer - - pshs u,d,cc save some registers - leau ,s point to a 'caller register stack' - lbsr L0C40 do a LDB 0,X in task B - puls u,d,cc and now A ( R$A,U ) = the CC we want - - ora #IntMasks disable it's IRQ's - lbsr L0C28 save it back -L0D5B orcc #IntMasks shut down IRQ's - ldx <D.Proc get current process pointer - tst <D.QIRQ was it a clock IRQ? - lbne L0DF7 if not, do a quick return - - lda P$State,x Get it's state - bita #TimOut Is it timed out? - bne L0D7C yes, wake it up +XIRQ ldx <D.Proc get current process pointer + sts P$SP,x save the stack pointer + lds <D.SysStk get system stack pointer + ldd <D.SysSvc set system service routine to current + std <D.XSWI2 + ldd <D.SysIRQ set system IRQ routine to current + std <D.XIRQ + jsr [>D.SvcIRQ] execute irq service + bcc L0D5B + + ldx <D.Proc get current process pointer + ldb P$Task,x + ldx P$SP,x get it's stack pointer + + pshs u,d,cc save some registers + leau ,s point to a 'caller register stack' + lbsr L0C40 do a LDB 0,X in task B + puls u,d,cc and now A ( R$A,U ) = the CC we want + + ora #IntMasks disable it's IRQ's + lbsr L0C28 save it back +L0D5B orcc #IntMasks shut down IRQ's + ldx <D.Proc get current process pointer + tst <D.QIRQ was it a clock IRQ? + lbne L0DF7 if not, do a quick return + + lda P$State,x Get it's state + bita #TimOut Is it timed out? + bne L0D7C yes, wake it up * Update active process queue - ldu #(D.AProcQ-P$Queue) point to active process queue - ldb #Suspend get suspend flag -L0D6A ldu P$Queue,u get a active process pointer - beq L0D78 - bitb P$State,u is it suspended? - bne L0D6A yes, go to next one in chain - ldb P$Prior,x get current process priority - cmpb P$Prior,u do we bump this one? - blo L0D7C - -L0D78 ldu P$SP,x - bra L0DB9 - -L0D7C anda #^TimOut - sta P$State,x - -L0D80 equ * -L0D83 bsr L0D11 activate next process - - use fnproc.asm - + ldu #(D.AProcQ-P$Queue) point to active process queue + ldb #Suspend get suspend flag +L0D6A ldu P$Queue,u get a active process pointer + beq L0D78 + bitb P$State,u is it suspended? + bne L0D6A yes, go to next one in chain + ldb P$Prior,x get current process priority + cmpb P$Prior,u do we bump this one? + blo L0D7C + +L0D78 ldu P$SP,x + bra L0DB9 + +L0D7C anda #^TimOut + sta P$State,x + +L0D80 equ * +L0D83 bsr L0D11 activate next process + + use fnproc.asm + * The following routines must appear no earlier than $E00 when assembled, as * they have to always be in the vector RAM page ($FE00-$FEFF) - + * Default routine for D.SysIRQ S.SysIRQ - lda <D.SSTskN Get current task's GIME task # (0 or 1) - beq FastIRQ Use super-fast version for system state - clr <D.SSTskN Clear out memory copy (task 0) - jsr [>D.SvcIRQ] (Normally routine in Clock calling D.Poll) - inc <D.SSTskN Save task # for system state - lda #1 Task 1 - ora <D.TINIT Merge task bit's into Shadow version - sta <D.TINIT Update shadow - sta >DAT.Task Save to GIME as well & return - bra DoneIRQ Check for error and exit - -FastIRQ jsr [>D.SvcIRQ] (Normally routine in Clock calling D.Poll) -DoneIRQ bcc L0E28 No error on IRQ, exit - IFNE H6309 - oim #IntMasks,0,s Setup RTI to shut interrupts off again - ELSE - lda ,s - ora #IntMasks - sta ,s - ENDC -L0E28 rti - + lda <D.SSTskN Get current task's GIME task # (0 or 1) + beq FastIRQ Use super-fast version for system state + clr <D.SSTskN Clear out memory copy (task 0) + jsr [>D.SvcIRQ] (Normally routine in Clock calling D.Poll) + inc <D.SSTskN Save task # for system state + lda #1 Task 1 + ora <D.TINIT Merge task bit's into Shadow version + sta <D.TINIT Update shadow + sta >DAT.Task Save to GIME as well & return + bra DoneIRQ Check for error and exit + +FastIRQ jsr [>D.SvcIRQ] (Normally routine in Clock calling D.Poll) +DoneIRQ bcc L0E28 No error on IRQ, exit + IFNE H6309 + oim #IntMasks,0,s Setup RTI to shut interrupts off again + ELSE + lda ,s + ora #IntMasks + sta ,s + ENDC +L0E28 rti + * return from a system call -L0E29 clra Force System task # to 0 (non-GRDRV) -L0E2B ldx <D.SysPrc Get system process dsc. ptr - lbsr TstImg check image, and F$SetTsk (PRESERVES A) - orcc #IntMasks Shut interrupts off - sta <D.SSTskN Save task # for system state - beq Fst2 If task 0, skip subroutine - ora <D.TINIT Merge task bit's into Shadow version - sta <D.TINIT Update shadow - sta >DAT.Task Save to GIME as well & return -Fst2 leas ,u Stack ptr=U & return - rti - +L0E29 clra Force System task # to 0 (non-GRDRV) +L0E2B ldx <D.SysPrc Get system process dsc. ptr + lbsr TstImg check image, and F$SetTsk (PRESERVES A) + orcc #IntMasks Shut interrupts off + sta <D.SSTskN Save task # for system state + beq Fst2 If task 0, skip subroutine + ora <D.TINIT Merge task bit's into Shadow version + sta <D.TINIT Update shadow + sta >DAT.Task Save to GIME as well & return +Fst2 leas ,u Stack ptr=U & return + rti + * Switch to new process, X=Process descriptor pointer, U=Stack pointer -L0E4C equ * - IFNE H6309 - oim #$01,<D.TINIT switch GIME shadow to user state - lda <D.TINIT - ELSE - lda <D.TINIT - ora #$01 - sta <D.TINIT - ENDC - sta >DAT.Task save it to GIME - leas ,y point to new stack - tstb is the stack at SWISTACK? - bne MyRTI no, we're doing a system-state rti - - IFNE H6309 - ldf #R$Size E=0 from call to L0E8D before - ldu #Where+SWIStack point to the stack - tfm u+,y+ move the stack from top of memory to user memory - ELSE - ldb #R$Size - ldu #Where+SWIStack point to the stack -RtiLoop lda ,u+ - sta ,y+ - decb - bne RtiLoop - ENDC -MyRTI rti return from IRQ - - +L0E4C equ * + IFNE H6309 + oim #$01,<D.TINIT switch GIME shadow to user state + lda <D.TINIT + ELSE + lda <D.TINIT + ora #$01 + sta <D.TINIT + ENDC + sta >DAT.Task save it to GIME + leas ,y point to new stack + tstb is the stack at SWISTACK? + bne MyRTI no, we're doing a system-state rti + + IFNE H6309 + ldf #R$Size E=0 from call to L0E8D before + ldu #Where+SWIStack point to the stack + tfm u+,y+ move the stack from top of memory to user memory + ELSE + ldb #R$Size + ldu #Where+SWIStack point to the stack +RtiLoop lda ,u+ + sta ,y+ + decb + bne RtiLoop + ENDC +MyRTI rti return from IRQ + + * Execute routine in task 1 pointed to by U * comes from user requested SWI vectors -L0E5E equ * - IFNE H6309 - oim #$01,<D.TINIT switch GIME shadow to user state - ldb <D.TINIT - ELSE - ldb <D.TINIT - orb #$01 - stb <D.TINIT - ENDC - stb >DAT.Task - jmp ,u - -* Flip to task 1 (used by GRF/WINDInt to switch to GRFDRV) (pointed to +L0E5E equ * + IFNE H6309 + oim #$01,<D.TINIT switch GIME shadow to user state + ldb <D.TINIT + ELSE + ldb <D.TINIT + orb #$01 + stb <D.TINIT + ENDC + stb >DAT.Task + jmp ,u + +* Flip to task 1 (used by GRF/WINDInt to switch to GRFDRV) (pointed to * by <D.Flip1). All regs are already preserved on stack for the RTI -S.Flip1 ldb #2 get Task image entry numberx2 for Grfdrv (task 1) - bsr L0E8D copy over the DAT image - IFNE H6309 - oim #$01,<D.TINIT - lda <D.TINIT get copy of GIME Task side - ELSE - lda <D.TINIT - ora #$01 - sta <D.TINIT - ENDC - sta >DAT.Task save it to GIME register - inc <D.SSTskN increment system state task number - rti return - +S.Flip1 ldb #2 get Task image entry numberx2 for Grfdrv (task 1) + bsr L0E8D copy over the DAT image + IFNE H6309 + oim #$01,<D.TINIT + lda <D.TINIT get copy of GIME Task side + ELSE + lda <D.TINIT + ora #$01 + sta <D.TINIT + ENDC + sta >DAT.Task save it to GIME register + inc <D.SSTskN increment system state task number + rti return + * Setup MMU in task 1, B=Task # to swap to, shifted left 1 bit -L0E8D cmpb <D.Task1N are we going back to the same task - beq L0EA3 without the DAT image changing? - stb <D.Task1N nope, save current task in map type 1 - ldx #$FFA8 get MMU start register for process's - ldu <D.TskIPt get task image pointer table - ldu b,u get address of DAT image -L0E93 leau 1,u point to actual MMU block - IFNE H6309 - lde #4 get # banks/2 for task - ELSE - lda #4 - pshs a - ENDC -L0E9B lda ,u++ get a bank - ldb ,u++ and next one - std ,x++ Save it to MMU - IFNE H6309 - dece done? - ELSE - dec ,s - ENDC - bne L0E9B no, keep going - IFEQ H6309 - leas 1,s - ENDC -L0EA3 rts return - +L0E8D cmpb <D.Task1N are we going back to the same task + beq L0EA3 without the DAT image changing? + stb <D.Task1N nope, save current task in map type 1 + ldx #$FFA8 get MMU start register for process's + ldu <D.TskIPt get task image pointer table + ldu b,u get address of DAT image +L0E93 leau 1,u point to actual MMU block + IFNE H6309 + lde #4 get # banks/2 for task + ELSE + lda #4 + pshs a + ENDC +L0E9B lda ,u++ get a bank + ldb ,u++ and next one + std ,x++ Save it to MMU + IFNE H6309 + dece done? + ELSE + dec ,s + ENDC + bne L0E9B no, keep going + IFEQ H6309 + leas 1,s + ENDC +L0EA3 rts return + * Execute FIRQ vector (called from $FEF4) -FIRQVCT ldx #D.FIRQ get DP offset of vector - bra L0EB8 go execute it - +FIRQVCT ldx #D.FIRQ get DP offset of vector + bra L0EB8 go execute it + * Execute IRQ vector (called from $FEF7) -IRQVCT orcc #IntMasks disasble IRQ's - ldx #D.IRQ get DP offset of vector +IRQVCT orcc #IntMasks disasble IRQ's + ldx #D.IRQ get DP offset of vector * Execute interrupt vector, B=DP Vector offset -L0EB8 clra (faster than CLR >$xxxx) - sta >DAT.Task Force to Task 0 (system state) - IFNE H6309 - tfr 0,dp setup DP - ELSE - tfr a,dp - ENDC -MapGrf equ * - IFNE H6309 - aim #$FE,<D.TINIT switch GIME shadow to system state - lda <D.TINIT set GIME again just in case timer is used - ELSE - lda <D.TINIT - anda #$FE - sta <D.TINIT - ENDC -MapT0 sta >DAT.Task - jmp [,x] execute it - +L0EB8 clra (faster than CLR >$xxxx) + sta >DAT.Task Force to Task 0 (system state) + IFNE H6309 + tfr 0,dp setup DP + ELSE + tfr a,dp + ENDC +MapGrf equ * + IFNE H6309 + aim #$FE,<D.TINIT switch GIME shadow to system state + lda <D.TINIT set GIME again just in case timer is used + ELSE + lda <D.TINIT + anda #$FE + sta <D.TINIT + ENDC +MapT0 sta >DAT.Task + jmp [,x] execute it + * Execute SWI3 vector (called from $FEEE) -SWI3VCT orcc #IntMasks disable IRQ's - ldx #D.SWI3 get DP offset of vector - bra SWICall go execute it - +SWI3VCT orcc #IntMasks disable IRQ's + ldx #D.SWI3 get DP offset of vector + bra SWICall go execute it + * Execute SWI2 vector (called from $FEF1) -SWI2VCT orcc #IntMasks disasble IRQ's - ldx #D.SWI2 get DP offset of vector - +SWI2VCT orcc #IntMasks disasble IRQ's + ldx #D.SWI2 get DP offset of vector + * This routine is called from an SWI, SWI2, or SWI3 * saves 1 cycle on system-system calls * saves about 200 cycles (calls to I.LDABX and L029E) on grfdrv-system, * or user-system calls. -SWICall ldb [R$PC,s] get callcode of the system call +SWICall ldb [R$PC,s] get callcode of the system call * NOTE: Alan DeKok claims that this is BAD. It crashed Colin McKay's * CoCo 3. Instead, we should do a clra/sta >DAT.Task. -* clr >DAT.Task go to map type 1 - clra - sta >DAT.Task +* clr >DAT.Task go to map type 1 + clra + sta >DAT.Task * set DP to zero - IFNE H6309 - tfr 0,dp - ELSE - tfr a,dp - ENDC - + IFNE H6309 + tfr 0,dp + ELSE + tfr a,dp + ENDC + * These lines add a total of 81 addition cycles to each SWI(2,3) call, * and 36 bytes+12 for R$Size in the constant page at $FExx * It takes no more time for a SWI(2,3) from system state than previously, @@ -933,76 +933,76 @@ * For processes that re-vector SWI, SWI3, it adds 81 cycles. BUT SWI(3) * CANNOT be vectored to L0EBF cause the user SWI service routine has been * changed - lda <D.TINIT get map type flag - bita #$01 check it without changing it - + lda <D.TINIT get map type flag + bita #$01 check it without changing it + * Change to LBEQ R.SysSvc to avoid JMP [,X] * and add R.SysSvc STA >DAT.Task ??? - beq MapT0 in map 0: restore hardware and do system service - tst <D.SSTskN get system state 0,1 - bne MapGrf if in grfdrv, go to map 0 and do system service - + beq MapT0 in map 0: restore hardware and do system service + tst <D.SSTskN get system state 0,1 + bne MapGrf if in grfdrv, go to map 0 and do system service + * the preceding few lines are necessary, as all SWI's still pass thru * here before being vectored to the system service routine... which * doesn't copy the stack from user state. - sta >DAT.Task go to map type X again to get user's stack + sta >DAT.Task go to map type X again to get user's stack * a byte less, a cycle more than ldy #$FEED-R$Size, or ldy #$F000+SWIStack - leay <SWIStack,pc where to put the register stack: to $FEDF - tfr s,u get a copy of where the stack is - IFNE H6309 - ldw #R$Size get the size of the stack - tfm u+,y+ move the stack to the top of memory - ELSE - pshs b - ldb #R$Size -Looper lda ,u+ - sta ,y+ - decb - bne Looper - puls b - ENDC - bra L0EB8 and go from map type 1 to map type 0 - + leay <SWIStack,pc where to put the register stack: to $FEDF + tfr s,u get a copy of where the stack is + IFNE H6309 + ldw #R$Size get the size of the stack + tfm u+,y+ move the stack to the top of memory + ELSE + pshs b + ldb #R$Size +Looper lda ,u+ + sta ,y+ + decb + bne Looper + puls b + ENDC + bra L0EB8 and go from map type 1 to map type 0 + * Execute SWI vector (called from $FEFA) -SWIVCT ldx #D.SWI get DP offset of vector - bra SWICall go execute it - +SWIVCT ldx #D.SWI get DP offset of vector + bra SWICall go execute it + * Execute NMI vector (called from $FEFD) -NMIVCT ldx #D.NMI get DP offset of vector - bra L0EB8 go execute it - +NMIVCT ldx #D.NMI get DP offset of vector + bra L0EB8 go execute it + * The end of the kernel module is here - emod -eom equ * - + emod +eom equ * + * What follows after the kernel module is the register stack, starting * at $FEDD (6309) or $FEDF (6809). This register stack area is used by * the kernel to save the caller's registers in the $FEXX area of memory * because it doesn't* get "switched out" no matter the contents of the * MMU registers. -SWIStack - fcc /REGISTER STACK/ same # bytes as R$Size for 6809 - IFNE H6309 - fcc /63/ if 6309, add two more spaces - ENDC - - fcb $55 D.ErrRst - +SWIStack + fcc /REGISTER STACK/ same # bytes as R$Size for 6809 + IFNE H6309 + fcc /63/ if 6309, add two more spaces + ENDC + + fcb $55 D.ErrRst + * This list of addresses ends up at $FEEE after the kernel track is loaded * into memory. All interrupts come through the 6809 vectors at $FFF0-$FFFE * and get directed to here. From here, the BRA takes CPU control to the * various handlers in the kernel. - bra SWI3VCT SWI3 vector comes here - nop - bra SWI2VCT SWI2 vector comes here - nop - bra FIRQVCT FIRQ vector comes here - nop - bra IRQVCT IRQ vector comes here - nop - bra SWIVCT SWI vector comes here - nop - bra NMIVCT NMI vector comes here - nop - - end + bra SWI3VCT SWI3 vector comes here + nop + bra SWI2VCT SWI2 vector comes here + nop + bra FIRQVCT FIRQ vector comes here + nop + bra IRQVCT IRQ vector comes here + nop + bra SWIVCT SWI vector comes here + nop + bra NMIVCT NMI vector comes here + nop + + end
--- a/level2/modules/kernel/krnp2.asm Tue Jan 05 21:55:34 2016 +0000 +++ b/level2/modules/kernel/krnp2.asm Mon Nov 28 08:31:26 2016 +0000 @@ -175,7 +175,7 @@ puls cc,u,pc restore IRQ's, register stack pointer & return ENDC -krnp2 lda #'2 into krnp2 +krnp2 lda #'2 into krnp2 jsr <D.BtBug leay SvcTab,pc install system calls @@ -190,7 +190,7 @@ beq L004F don't exist, open std device leax d,u point to name - lda #'x tried chd'ing + lda #'x tried chd'ing jsr <D.BtBug lda #(EXEC.+READ.) get file mode @@ -233,7 +233,7 @@ ldd InitStr,u get offset to name of first module leax d,u point to it - lda #'C tried to to CC3Go + lda #'C tried to to CC3Go jsr <D.BtBug lda #Objct get module type @@ -335,7 +335,7 @@ fdb FCRCMod-*-2 fcb $7f fdb GetIOMan-*-2 - fcb $80 + fcb $80 use fcrcmod.asm @@ -365,7 +365,7 @@ os9 F$Link link it rts return -IOMan fcs /IOMan/ +IOMan fcs /IOMan/ use funlink.asm