Mercurial > hg > Members > kono > nitros9-code
changeset 1239:90bad6d8388c
Major changes to bring kernel closer to L2 port
author | boisy |
---|---|
date | Tue, 05 Aug 2003 13:46:17 +0000 |
parents | 481618f41f1d |
children | cd2122359eb9 |
files | level2/modules/kernel/fallbit.asm level2/modules/kernel/fallprc.asm level2/modules/kernel/falltsk.asm level2/modules/kernel/fchain.asm level2/modules/kernel/ffind64.asm level2/modules/kernel/ffork.asm level2/modules/kernel/ffreehb.asm level2/modules/kernel/fld.asm level2/modules/kernel/fmem.asm level2/modules/kernel/fmove.asm level2/modules/kernel/fnproc.asm level2/modules/kernel/fsleep.asm level2/modules/kernel/fsrqmem.asm level2/modules/kernel/fssvc.asm level2/modules/kernel/fvmodul.asm level2/modules/kernel/krn.asm level2/modules/kernel/krnp2.asm |
diffstat | 17 files changed, 122 insertions(+), 86 deletions(-) [+] |
line wrap: on
line diff
--- a/level2/modules/kernel/fallbit.asm Sun Aug 03 00:30:20 2003 +0000 +++ b/level2/modules/kernel/fallbit.asm Tue Aug 05 13:46:17 2003 +0000 @@ -272,12 +272,11 @@ IFNE H6309 tfr w,d Dupe current bit # into D subr y,d Calculate size we have free so far - cmpd R$Y,u As big as user requested? ELSE tfr y,d subd 7,s - cmpd R$Y,u ENDC + cmpd R$Y,u As big as user requested? bhs WereDone Yes, we are done cmpd $03,s As big as the largest one we have found so far? bls MoveBit No, move to next bit and keep going
--- a/level2/modules/kernel/fallprc.asm Sun Aug 03 00:30:20 2003 +0000 +++ b/level2/modules/kernel/fallprc.asm Tue Aug 05 13:46:17 2003 +0000 @@ -38,6 +38,7 @@ tfm y,x+ ELSE clra + clrb leax P$PID,u ldy #$80 LChinese std ,x++
--- a/level2/modules/kernel/falltsk.asm Sun Aug 03 00:30:20 2003 +0000 +++ b/level2/modules/kernel/falltsk.asm Tue Aug 05 13:46:17 2003 +0000 @@ -34,9 +34,11 @@ IFNE H6309 aim #^ImgChg,P$State,x flag DAT image change in process descriptor ELSE + pshs a lda P$State,x anda #^ImgChg sta P$State,x + puls a ENDC clr <D.Task1N task 1 DAT image has changed andcc #^Carry clear carry
--- a/level2/modules/kernel/fchain.asm Sun Aug 03 00:30:20 2003 +0000 +++ b/level2/modules/kernel/fchain.asm Tue Aug 05 13:46:17 2003 +0000 @@ -27,10 +27,10 @@ ldw #$00fc get size (P$SP+$FC) tfm x+,u+ move it ELSE - ldy #$007E + ldy #$00FC L03C3 ldd ,x++ copy bytes std ,u++ - leay -1,y + leay -2,y bne L03C3 ENDC L03CB ldu 2,s get new descriptor pointer @@ -103,8 +103,8 @@ IFNE H6309 cmpr x,u check From/To addresses ELSE - pshs u src ptr - cmpx ,s++ dest ptr + pshs x src ptr + cmpu ,s++ dest ptr ENDC puls y size bhi L0471 To < From: do F$Move @@ -122,8 +122,8 @@ pshs d,x tfr y,d leax d,x - pshs u - cmpx ,s++ + pshs x + cmpu ,s++ puls d,x ENDC bls L0471 end of FROM <= start of TO: do F$Move @@ -136,7 +136,7 @@ ELSE tfr y,d leax d,x - leau d,y + leau d,u ENDC * This all appears to be doing a copy where destination <= source,
--- a/level2/modules/kernel/ffind64.asm Sun Aug 03 00:30:20 2003 +0000 +++ b/level2/modules/kernel/ffind64.asm Tue Aug 05 13:46:17 2003 +0000 @@ -142,20 +142,17 @@ IFNE H6309 lsld ???Calculate 256 byte page #? lsld + tfr y,u U=Ptr to start of new page + ldw #$3f Clear out the 64 byte block we are using + leax TFMNull,pc + tfm x,u+ ELSE aslb rola aslb rola - ENDC - tfr y,u U=Ptr to start of new page - IFNE H6309 - ldw #$3f Clear out the 64 byte block we are using - leax TFMNull,pc - tfm x,u+ - ELSE ldb #$3f -ClrIt clr ,u+ +ClrIt clr b,y decb bne ClrIt ENDC
--- a/level2/modules/kernel/ffork.asm Sun Aug 03 00:30:20 2003 +0000 +++ b/level2/modules/kernel/ffork.asm Tue Aug 05 13:46:17 2003 +0000 @@ -31,11 +31,10 @@ std P$User,u lda P$Prior,x sta P$Prior,u - pshs x,u ENDC * Copy network I/O pointers to new descriptor IFEQ Network-1 - pshs x,u preserve pointers to descriptors + pshs x,u leax >P$NIO,x point to current NIO pointers leau >P$NIO,u point to buffer for new ones IFNE H6309
--- a/level2/modules/kernel/ffreehb.asm Sun Aug 03 00:30:20 2003 +0000 +++ b/level2/modules/kernel/ffreehb.asm Tue Aug 05 13:46:17 2003 +0000 @@ -75,7 +75,7 @@ stx ,y++ decb bne L0ALoop - ldx 2,s get proc desc ptr + ldx 2,s lda P$State,x ora #ImgChg sta P$State,x
--- a/level2/modules/kernel/fld.asm Sun Aug 03 00:30:20 2003 +0000 +++ b/level2/modules/kernel/fld.asm Tue Aug 05 13:46:17 2003 +0000 @@ -15,7 +15,7 @@ brn L0AC8 lda ,x Get byte stb >$FFA0 Map block 0 into $0000-$1FFF - fdb $21ED + fdb $21ED LBRN ??? puls pc,cc Get interrupt status/(or turn on) & return * Get 1st byte of LDDDXY - also used by many other routines
--- a/level2/modules/kernel/fmem.asm Sun Aug 03 00:30:20 2003 +0000 +++ b/level2/modules/kernel/fmem.asm Tue Aug 05 13:46:17 2003 +0000 @@ -48,8 +48,8 @@ IFNE H6309 subr a,b same count? ELSE - pshs b - suba ,s+ + pshs a + subb ,s+ ENDC beq L0634 yes, save it bcs L062C overflow, delete the ram we just got @@ -63,8 +63,8 @@ IFNE H6309 addr b,a ELSE - pshs a - addb ,s+ + pshs b + adda ,s+ ENDC negb os9 F$DelImg
--- a/level2/modules/kernel/fmove.asm Sun Aug 03 00:30:20 2003 +0000 +++ b/level2/modules/kernel/fmove.asm Tue Aug 05 13:46:17 2003 +0000 @@ -97,6 +97,18 @@ L0BF2 clrb clear errors puls d,x,y,u,pc return ELSE +* Main move loop +* Stack: 0,s=distance to end of source block +* 2,s=distance to end of destination block +* 4,s=pointer to destination +* 6,s=pointer to destination DAT image +* 8,s=pointer to source +* 10,s=pointer to source DAT image +* 12,s=task # of source +* 13,s=task # of destination +* 14,s=total byte count of move +* Registers: X=Source pointer +* U=Destination pointer L0BXA pshs cc ldd [<$07,s] pshs b @@ -189,8 +201,9 @@ ELSE pshs d tfr x,d - subd ,s++ + subd ,s tfr d,x + puls d ENDC lsra Calculate offset into DAT image to get proper lsra 8K bank (remember that each entry in a DAT image
--- a/level2/modules/kernel/fnproc.asm Sun Aug 03 00:30:20 2003 +0000 +++ b/level2/modules/kernel/fnproc.asm Tue Aug 05 13:46:17 2003 +0000 @@ -99,4 +99,4 @@ clr <P$Signal,x Clear out the one in process dsc. os9 F$Exit Exit with signal # being error code -L0E45 jmp [>D.Poll] Call IOMAN for IRQ polling +S.SvcIRQ jmp [>D.Poll] Call IOMAN for IRQ polling
--- a/level2/modules/kernel/fsleep.asm Sun Aug 03 00:30:20 2003 +0000 +++ b/level2/modules/kernel/fsleep.asm Tue Aug 05 13:46:17 2003 +0000 @@ -26,15 +26,19 @@ IFNE H6309 aim #^Suspend,P$State,x ELSE + lda P$State,x + anda #^Suspend + sta P$State,x ENDC L071B puls cc os9 F$AProc activate the process bra L0780 L0722 ldd R$X,u get callers X (contains sleep tick count) beq L076D done, wake it up - IFNE H6309 + IFNE H6309 decd subtract 1 from tick count ELSE + subd #$0001 ENDC std R$X,u save it back beq L071B zero, wake up process @@ -47,6 +51,8 @@ IFNE H6309 tim #TimSleep,P$State,x ELSE + lda P$State,x + bita #TimSleep ENDC beq L074F ldy P$SP,x get process stack pointer @@ -64,6 +70,9 @@ IFNE H6309 oim #TimSleep,P$State,x ELSE + lda P$State,x + ora #TimSleep + sta P$State,x ENDC ldd P$Queue,y stx P$Queue,y @@ -75,6 +84,9 @@ IFNE H6309 aim #^TimSleep,P$State,x ELSE + lda P$State,x + anda #^TimSleep + sta P$State,x ENDC SkpSleep puls cc,pc
--- a/level2/modules/kernel/fsrqmem.asm Sun Aug 03 00:30:20 2003 +0000 +++ b/level2/modules/kernel/fsrqmem.asm Tue Aug 05 13:46:17 2003 +0000 @@ -53,16 +53,15 @@ ldx <D.SysMem Get start of table ptr ldb #$20 skip block 0: it's always full abx same size, but faster than leax $20,x -* leay -17,y Skip Kernal, Vector RAM & I/O (Can't be free) +* leay -17,y Skip Kernel, Vector RAM & I/O (Can't be free) L0857 ldb R$A,u Get # 256 byte pages requested * Loop (from end of system mem map) to look for # continuous pages requested L0859 equ * IFNE H6309 -* TODO: Verify order of comparison cmpr x,y We still have any system RAM left to try? ELSE - pshs y - cmpx ,s++ + pshs x + cmpy ,s++ ENDC bhi L0863 Yes, continue comb Exit with No System RAM Error @@ -73,7 +72,7 @@ bne L0857 Used, try next lower page decb Found 1 page, dec # pages we need to allocate bne L0859 Still more pages needed, check if we can get more - sty ,s Found free contigous pages, save SMAP entry ptr + 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 @@ -141,7 +140,7 @@ * Scan DAT image to find memory blocks to free up ldx <D.SysDAT get pointer to system DAT image IFNE H6309 - lde #8 get # blocks to check + lde #DAT.BlCt get # blocks to check ELSE ldy #DAT.BlCt ENDC
--- a/level2/modules/kernel/fssvc.asm Sun Aug 03 00:30:20 2003 +0000 +++ b/level2/modules/kernel/fssvc.asm Tue Aug 05 13:46:17 2003 +0000 @@ -10,7 +10,7 @@ * Error: CC = C bit set; B = error code * FSSvc ldy R$Y,u get pointer to table - bra L037F start moving + bra SysSvc start moving * Main move loop L036D clra clear MSB of table offset lslb multiply function # by 2 to get offset into table @@ -19,10 +19,10 @@ leax d,y offset X from current Y ldd <D.SysDis get system dispatch table pointer stx d,u save vector into place - bcs L037F it was a privliged call, skip ahead + bcs SysSvc it was a privliged call, skip ahead ldd <D.UsrDis get user displat table pointer stx d,u save vector into place -L037F ldb ,y+ get callcode +SysSvc ldb ,y+ get callcode cmpb #$80 done? bne L036D no, keep going rts return
--- a/level2/modules/kernel/fvmodul.asm Sun Aug 03 00:30:20 2003 +0000 +++ b/level2/modules/kernel/fvmodul.asm Tue Aug 05 13:46:17 2003 +0000 @@ -101,8 +101,8 @@ oim #ModBlock,d,x dece ELSE - pshs a,x save block size, blkmap -L04DE ldd ,y++ D = image block # +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 @@ -185,21 +185,18 @@ L054E ldx <D.ModDAT leax d,x cmpx <D.ModEnd - bcs L0583 + bcs S.Poll ldu 7,s bne L056E - IFEQ H6309 - pshs x - ENDC ldy <D.ModEnd leay MD$ESize,y IFNE H6309 -* TODO: Verify order of comparison cmpr x,y ELSE + pshs x cmpy ,s++ ENDC - bhi L0583 + bhi S.Poll sty <D.ModEnd leay -MD$ESize,y sty $07,s @@ -226,7 +223,7 @@ rts * Default interrupt handling routine on first booting OS9p1 -L0583 orcc #Carry +S.Poll orcc #Carry rts * Check module ID & calculate module header parity & CRC @@ -256,8 +253,7 @@ ince valid parity? ELSE leas -1,s make var - ldb #$07 seven bytes - lda #$4A header crc + 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
--- a/level2/modules/kernel/krn.asm Sun Aug 03 00:30:20 2003 +0000 +++ b/level2/modules/kernel/krn.asm Tue Aug 05 13:46:17 2003 +0000 @@ -33,7 +33,7 @@ fcc /0123456789ABCDEF/ fcc /01234567/ ELSE - fcc /012345/ + fcc /12345123/ ENDC * Might as well have this here as just past the end of OS9p1... @@ -71,7 +71,7 @@ SubSiz equ *-SubStrt * Don't add any code here: See L0065, below. * Interrupt service routine -L0271 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 OS9P1 equ * @@ -79,20 +79,20 @@ ldq #$01001f00 Start address to clear & # bytes to clear leay <OS9P1+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 #8192-$100 + ldy #$2000-$100 clra clrb L001C std ,x++ leay -2,y bne L001C - inca - inca + stx <D.CCStk Set pointer to top of global memory to $2000 + inca D = $0100 ENDC * Setup system direct page variables - std <D.CCStk Set pointer to top of global memory to $2000 - lda #$01 set task user table to $0100 std <D.Tasks addb #$20 set Task image table to $0120 std <D.TskIPt @@ -122,7 +122,7 @@ 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 beggining of global memory 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 @@ -156,9 +156,9 @@ bne Loop2 ENDC -* leau <L0271,pc point to vector +* 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 L0271 for now +L0065 stu ,x++ Set all IRQ vectors to go to Vectors for now cmpx #D.NMI bls L0065 @@ -167,30 +167,36 @@ 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 >L0316,pc Setup System service routine entry vector + + leax >SysCall,pc Setup System service routine entry vector stx <D.SysSvc stx <D.XSWI2 - leax >L0E12,pc Setup system IRQ service vector + + leax >S.SysIRQ,pc Setup system IRQ service vector stx <D.SysIRQ stx <D.XIRQ - leax >L0E45,pc Setup in system IRQ service vector + + leax >S.SvcIRQ,pc Setup in system IRQ service vector stx <D.SvcIRQ - leax >L0583,pc Setup interrupt polling vector + leax >S.Poll,pc Setup interrupt polling vector stx <D.Poll ORCC #$01;RTS - leax >L0E44,pc Setup alternate IRQ vector: pts to an RTS + leax >S.AltIRQ,pc Setup alternate IRQ vector: pts to an RTS stx <D.AltIRQ lda #'1 --- in OS9p1 jsr <D.BtBug --- - leax >L0E7D,pc Setup change to task 1 vector + leax >S.Flip1,pc Setup change to task 1 vector stx <D.Flip1 + * Setup System calls - leay >L0200,pc - lbsr L037F + leay >SysCalls,pc + lbsr SysSvc + * Initialize system process descriptor 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 @@ -218,16 +224,21 @@ 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 + * Setup system memory map ldx <D.SysMem Get system memory map pointer ldb <D.CCStk Get MSB of top of CC memory @@ -250,17 +261,16 @@ std <D.BlkMap+2 save block map end pointer ELSE ldd #$0008 -L0111 rolb - lsla +L0111 aslb + rola stb >$FFA5 pshs a lda #$01 sta >-$6000,x cmpa ,x - beq L0112 puls a - bra L0111 -L0112 stb <D.MemSz + bne L0111 + stb <D.MemSz pshs x addd ,s++ std <D.BlkMap+2 @@ -289,6 +299,7 @@ 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 @@ -312,6 +323,7 @@ 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 os9p2 + * Mark kernel in system memory map as used memory (256 byte blocks) L01D2 ldx <D.SysMem Get system mem ptr ldd #NotRAM*256+$ED $ED00 is the start of the boot @@ -324,7 +336,7 @@ 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 -L0E44 rts return +S.AltIRQ rts return * Link module pointed to by X link lda #Systm Attempt to link system module @@ -335,7 +347,7 @@ os9p2 fcs 'OS9p2' * Service vector call pointers -L0200 fcb F$Link +SysCalls fcb F$Link fdb FLink-*-2 fcb F$PrsNam fdb FPrsNam-*-2 @@ -439,7 +451,7 @@ IFNE H6309 oim #SysState,P$State,x mark process as in system state ELSE - pshs d +***** pshs d lda P$State,x ora #SysState sta P$State,x @@ -459,7 +471,7 @@ sta ,u- decb bne Loop3 - puls d +***** puls d ENDC andcc #^IntMasks leau ,s needed because the TFM is u-, not -u (post, not pre) @@ -473,9 +485,9 @@ 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 + ldb R$CC,u + andb #^IntMasks + stb R$CC,u ENDC ldx <D.Proc get current process ptr IFNE H6309 @@ -501,7 +513,7 @@ AllClr inc <D.QCnt IFNE H6309 aim #$1F,<D.QCnt - beq DoFull ever 32 system calls, do the full check + 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 @@ -566,7 +578,7 @@ * Process software interupts from system state * Entry: U=Register stack pointer -L0316 leau ,s get pointer to register stack +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 @@ -717,7 +729,7 @@ * they have to always be in the vector RAM page ($FE00-$FEFF) * Default routine for D.SysIRQ -L0E12 lda <D.SSTskN Get current task's GIME task # (0 or 1) +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) @@ -773,6 +785,7 @@ 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 @@ -796,7 +809,7 @@ * 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 -L0E7D ldb #2 get Task image entry numberx2 for Grfdrv (task 1) +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 @@ -935,10 +948,11 @@ eom equ * *SWIStack fcc /REGISTER STACK/ R$Size data bytes -SWIStack fcb $88,$03,$00,$45,$72,$00,$cd,$00,$12,$00,$00,$00 +SWIStack fcb $88,$03,$00 IFNE H6309 - fcb $e5,$7f + fcb $45,$72 ENDC + fcb $00,$cd,$00,$12,$00,$00,$00,$e5,$7f fcb $55 D.ErrRst
--- a/level2/modules/kernel/krnp2.asm Sun Aug 03 00:30:20 2003 +0000 +++ b/level2/modules/kernel/krnp2.asm Tue Aug 05 13:46:17 2003 +0000 @@ -18,7 +18,7 @@ * 18.4 92/12/15 - Cut initial memory allocation routine - unnecessary * 18.5 93/01/18 - Fixed bug in F$Sleep (LCB) * - Optimized F$All64 to use tfm (BN) -* NitrOS9 V1.09 - Move & optomized F$CpyMem to OS9P1 +* NitrOS9 V1.09 - Move & optimized F$CpyMem to OS9P1 * V1.10 93/05/23 - Slight opt to UnLink * V1.11 93/07/26 - Slight opt in F$Icpt * - Slight opt in F$Wait alarm clearing @@ -38,7 +38,7 @@ * instead of CLR for clearing DAT block #'s (F$UnLink) * 93/12/17 - Moved F$CRCMod code here to give some room in OS9P1 * 94/05/15 - Attempted opts in Unlink: Changed usage of W to D @ L0185 -* and L0198 and L01B5, also optomized L017C to eliminate a +* and L0198 and L01B5, also optimized L017C to eliminate a * branch (speeds up module dir search by 3 cycles/module * checked) * - Changed BRA L032F @ L02EC (AllProc error) to RTS @@ -117,6 +117,9 @@ IFNE H6309 oim #SysState,P$State,x mark process as system state ELSE + ldb P$State,x + orb #SysState + stb P$State,x ENDC * copy register stack to process descriptor sts P$SP,x save stack pointer @@ -185,6 +188,7 @@ lda #(EXEC.+READ.) get file mode os9 I$ChgDir change to it bcc L004F went ok, go on + jmp <D.Crash os9 F$Boot try & load boot file bcc L003A go try again L004F ldu <D.Init get pointer to init