diff --git a/.Floppies/A2OSX.BUILD.po b/.Floppies/A2OSX.BUILD.po index 374152e6..00722017 100644 Binary files a/.Floppies/A2OSX.BUILD.po and b/.Floppies/A2OSX.BUILD.po differ diff --git a/BIN/SHUTDOWN.S.txt b/BIN/SHUTDOWN.S.txt index 009aae01..9a9a1d3f 100644 --- a/BIN/SHUTDOWN.S.txt +++ b/BIN/SHUTDOWN.S.txt @@ -8,13 +8,20 @@ NEW .INB inc/macros.i .INB inc/a2osx.i .INB inc/kernel.i +*-------------------------------------- +DEFAULT.TIMEOUT .EQ 60 *-------------------------------------- .DUMMY .OR ZPBIN ZS.START ZPPtr1 .BS 2 +ArgPtr .BS 2 Count .BS 1 Index .BS 1 +Timeout .BS 4 +bSec .BS 1 +bTimeout .BS 1 +bRestart .BS 1 ZS.END .ED *-------------------------------------- * File Header (16 Bytes) @@ -23,7 +30,7 @@ CS.START cld jmp (.1,x) .DA #$61 6502,Level 1 (65c02) .DA #1 BIN Layout Version 1 - .DA #0 S.PS.F.EVENT + .DA #S.PS.F.EVENT .DA #0 .DA CS.END-CS.START Code Size (without Constants) .DA DS.END-DS.START Data SegmentSize @@ -35,9 +42,10 @@ CS.START cld *-------------------------------------- .1 .DA CS.INIT .DA CS.RUN - .DA CS.DOEVENT + .DA CS.DOEVENT .DA CS.QUIT L.MSG.USAGE .DA MSG.USAGE +L.MSG.CRLF .DA MSG.CRLF L.MSG.SHUTDOWN .DA MSG.SHUTDOWN L.MSG.PS .DA MSG.PS L.MSG.DEV .DA MSG.DEV @@ -46,63 +54,151 @@ L.MSG.DEV .DA MSG.DEV CS.INIT clc rts *-------------------------------------- -CS.RUN >LDYA L.MSG.SHUTDOWN - >SYSCALL PutS +CS.RUN lda #DEFAULT.TIMEOUT + sta Timeout + +.1 inc Index + lda Index + >SYSCALL ArgV + bcs .8 + + >STYA ZPPtr1 + >DEBUG + lda (ZPPtr1) + cmp #'-' + beq .2 + + lda ArgPtr+1 + bne .9 + + >LDYA ZPPtr1 + >STYA ArgPtr + bra .1 + +.2 ldy #2 + lda (ZPPtr1),y + bne .9 + + dey + lda (ZPPtr1),y + + cmp #'a' + bcc .3 + + cmp #'z'+1 + bcs .3 + + eor #$20 + +.3 cmp #'T' + bne .4 + + inc Index + lda Index + >SYSCALL ArgV + bcs .9 + + >SYSCALL atol + bcs .9 + + >PULLL Timeout + + bra .1 + +.4 cmp #'R' + bne .9 + + sec + ror bRestart + bra .1 + +.8 jsr CS.RUN.WAIT + bcs .99 jsr CS.RUN.PS jsr CS.RUN.DEV - + >PUSHBI 1 - - >PUSHBI 1 INITD + +* lda #1 INITD >SYSCALL Kill lda #0 sec +.99 rts +*-------------------------------------- +.9 >PUSHW L.MSG.USAGE + >PUSHBI 0 + >SYSCALL PrintF + + lda #E.SYN + sec + rts +*-------------------------------------- +CS.RUN.WAIT >PUSHW L.MSG.SHUTDOWN + >PUSHL Timeout + >PUSHBI 4 + >SYSCALL PrintF + +.1 >SLEEP + + lda bSec + bpl .1 + + stz bSec + + lda bTimeout + bpl CS.RUN.WAIT + + >PUSHW L.MSG.CRLF + >PUSHBI 0 + >SYSCALL PrintF + + clc rts *-------------------------------------- CS.RUN.PS stz Count ldx #0 stx Index - + .1 lda PS.Table.hPS,x beq .7 >SYSCALL GetMemPtr >STYA ZPPtr1 - + .2 lda (ZPPtr1) bpl .4 HOLD ? - + ldy #S.PS.CPID lda (ZPPtr1),y .3 jsr CS.GetPSByID bra .2 - + .4 ldy #S.PS.S lda (ZPPtr1),y cmp #S.PS.S.QUIT beq .6 - + ldy #S.PS.PID lda (ZPPtr1),y beq .7 don't kill PS0 - + cmp #1 beq .7 don't kill INITD - + cmp (pPS),y don't kill myself beq .7 - + jsr CS.RUN.KILL - + .5 ldy #S.PS.PPID lda (ZPPtr1),y bne .3 go kill parent if not 0 - + .6 inc Count .7 >SLEEP @@ -111,10 +207,10 @@ CS.RUN.PS stz Count ldx Index cpx #K.PS.MAX bne .1 - + lda Count bne CS.RUN.PS - + sec rts *-------------------------------------- @@ -122,17 +218,17 @@ CS.RUN.KILL >PUSHW L.MSG.PS ldy #S.PS.PID lda (ZPPtr1),y >PUSHA - + ldy #S.PS.hARGV lda (ZPPtr1),y >SYSCALL GetMemPtr >PUSHYA - + >PUSHBI 3 >SYSCALL PrintF - + >PUSHBI 1 - + ldy #S.PS.PID lda (ZPPtr1),y >SYSCALL Kill @@ -140,7 +236,7 @@ CS.RUN.KILL >PUSHW L.MSG.PS *-------------------------------------- CS.RUN.DEV ldx #1 stx Index - + .1 lda Dev.Table-1,x sta ZPPtr1 lda Dev.Table,x @@ -149,7 +245,7 @@ CS.RUN.DEV ldx #1 >PUSHW L.MSG.DEV >PUSHB Index - + lda ZPPtr1 clc adc #S.FD.DEV @@ -157,18 +253,18 @@ CS.RUN.DEV ldx #1 lda ZPPtr1+1 adc /S.FD.DEV >PUSHYA - + >PUSHBI 3 >SYSCALL PrintF - - + + .7 inc Index inc Index ldx Index cpx #K.DEV.MAX*2+1 - bne .1 - + bne .1 + rts *-------------------------------------- CS.GetPSByID ldx #0 @@ -183,34 +279,59 @@ CS.GetPSByID ldx #0 >SYSCALL GetMemPtr >STYA ZPPtr1 plx - + pla - + ldy #S.PS.PID cmp (ZPPtr1),y beq .8 - + .7 inx cpx #K.PS.MAX bne .1 -* sec +* sec rts - + .8 clc rts *-------------------------------------- -CS.DOEVENT sec +CS.DOEVENT lda (pEvent) + bpl .9 + asl + bpl .9 + + sta bSec + + ldx #4 + ldy #0 + + clc + +.1 lda Timeout,y + sbc #0 + sta Timeout,y + iny + dex + bne .1 + + ror + eor #$80 + sta bTimeout + +.9 sec rts *-------------------------------------- CS.QUIT clc rts *-------------------------------------- -CS.END +CS.END MSG.USAGE .AS "Usage : SHUTDOWN \r\n" - .AZ " -T : \r\n" -MSG.SHUTDOWN .AZ "SHUTDOWN:System..." + .AS " -R : Restart System\r\n" + .AS " -T : default to 60" +MSG.CRLF .AZ "\r\n" +MSG.SHUTDOWN .AZ "\r\e[KSHUTDOWN:System will stop in %u seconds..." MSG.PS .AZ "SHUTDOWN:Killing process %3d, %s\r\n" MSG.DEV .AZ "SHUTDOWN:Closing device %3d, %s\r\n" *-------------------------------------- diff --git a/SYS/KERNEL.S.CORE.txt b/SYS/KERNEL.S.CORE.txt index 8fbbf75d..65fede5e 100644 --- a/SYS/KERNEL.S.CORE.txt +++ b/SYS/KERNEL.S.CORE.txt @@ -1,15 +1,9 @@ NEW AUTO 3,1 *-------------------------------------- -CORE.Quit ldx #5 +CORE.Run ldx #1 -.1 stz K.MLI.PARAMS,x - dex - bpl .1 - - >MLICALL MLIQUIT -*-------------------------------------- -CORE.Run ldx #1 Skip PS0 + bra .80 Skip PS0 .1 stx CORE.PSIndex @@ -64,8 +58,10 @@ CORE.Run ldx #1 Skip PS0 >PUSHBI 2 ldy #S.PS.PID lda (pPS),y -* cmp #1 INITD ? -* beq CORE.Quit + cmp #1 INITD ? + bne .6 + + jmp CORE.Quit .6 >SYSCALL2 Kill bra .8 @@ -74,7 +70,7 @@ CORE.Run ldx #1 Skip PS0 .8 ldx CORE.PSIndex inx - cpx CORE.PSCount +.80 cpx CORE.PSCount bne .1 *-------------------------------------- CORE.Events jsr CORE.GetEvents @@ -132,6 +128,23 @@ CORE.Events jsr CORE.GetEvents >SYSCALL2 IOCTL .8 jmp CORE.Run *-------------------------------------- +CORE.Quit jsr CORE.IRQ.None.Off + + lda IRQ.INTNUM + sta K.MLI.PARAMS+1 + + >MLICALL MLIDEALLOCIRQ + + ldx #5 + +.1 stz K.MLI.PARAMS+1,x + dex + bpl .1 + + lda #4 + ldx #MLIQUIT + jmp GP.MLICall +*-------------------------------------- CORE.UpdateParentPS tax save RC From INIT or RUN @@ -243,7 +256,8 @@ CORE.GetEvents lda #Evt.Table * CC: Event Cleared *-------------------------------------- CORE.Dispatch ldx #1 skip PS0 - + bra .80 + .1 stx CORE.PSIndex lda PS.Table.hPS,x @@ -296,9 +310,11 @@ CORE.Dispatch ldx #1 skip PS0 .5 ldx CORE.PSIndex inx - cpx CORE.PSCount +.80 cpx CORE.PSCount bne .1 + * sec + rts *-------------------------------------- * X unmodified @@ -474,40 +490,43 @@ CORE.EvtIndex .BS 1 CORE.EvtCount .BS 1 *-------------------------------------- * Called by : -* - Kernel K.IrqHAuxLC +* - Kernel IRQ Manager (AuxLC) * - ProDOS IRQ Manager (GP) *-------------------------------------- -K.IrqH.IIGS lda IO.IIGS.INTFLAG +CORE.IRQ.IIGS lda IO.IIGS.INTFLAG and #$08 - beq K.IrqH.DEV + beq CORE.IRQ.DEV stz IO.IIGS.CLRVBLINT - bra K.IrqH.Switch + bra CORE.IRQ.Switch *-------------------------------------- -K.IrqH.TCLOCK ldy IRQ.VBL.n0 +CORE.IRQ.TCLOCK ldy IRQ.VBL.n0 lda $c080,y and #$20 - beq K.IrqH.DEV + beq CORE.IRQ.DEV lda $c088,y lda $c080,y - bra K.IrqH.Switch + bra CORE.IRQ.Switch *-------------------------------------- -K.IrqH.VBL -K.IrqH.VBL.MSM jsr $FFFF SELF MODIFIED,SERVEMOUSE - bcs K.IrqH.DEV Not From Mouse +CORE.IRQ.MOUSE jsr $FFFF SELF MODIFIED,SERVEMOUSE + bcs CORE.IRQ.DEV Not From Mouse + ldx IRQ.VBL.0n lda MOUSESTSx,x and #MOUSESTSx.INTVBL IRQ was caused by VBL ? - beq K.IrqH.DEV - ldx K.IrqH.VBL.MRM+2 $Cn + beq CORE.IRQ.DEV + + ldx CORE.IRQ.MOUSE.2+2 $Cn ldy IRQ.VBL.n0 -K.IrqH.VBL.MRM jsr $FFFF SELF MODIFIED,READMOUSE + +CORE.IRQ.MOUSE.2 + jsr $FFFF SELF MODIFIED,READMOUSE *-------------------------------------- -K.IrqH.Switch inc IRQ.Tick +CORE.IRQ.Switch inc IRQ.Tick dec CORE.CPUStatCnt bne .2 @@ -547,7 +566,7 @@ K.IrqH.Switch inc IRQ.Tick .8 clc exit with V flag set rts *-------------------------------------- -K.IrqH.DEV ldx #0 +CORE.IRQ.DEV ldx #0 .1 lda IRQ.Vectors+1,x beq .9 sta .10+2 @@ -565,6 +584,30 @@ K.IrqH.DEV ldx #0 .8 clv clear V (no task switching) rts *-------------------------------------- +CORE.IRQ.IIGS.Off + lda #$08 + trb IO.IIGS.INTEN + + rts +CORE.IRQ.TCLOCK.Off + ldx IRQ.VBL.n0 + stz $c080,x + + ldx IRQ.VBL.0n + sta CLRPAGE2 + stz $478,x + stz $7f8,x + + rts +CORE.IRQ.MOUSE.Off + ldy CORE.IRQ.MOUSE.Off.1+2 Cn + ldy IRQ.VBL.n0 + lda #0 +CORE.IRQ.MOUSE.Off.1 + jmp $ffff SELF MODIFIED +CORE.IRQ.None.Off + rts +*-------------------------------------- IRQ.InKernel .BS 1 IRQ.InLib .BS 1 IRQ.SkipA2osX .BS 1 diff --git a/SYS/KERNEL.S.GP.txt b/SYS/KERNEL.S.GP.txt index 8a9eda5a..aa15d10d 100644 --- a/SYS/KERNEL.S.GP.txt +++ b/SYS/KERNEL.S.GP.txt @@ -373,17 +373,17 @@ GO.EXIT.JMP jmp $FFFF SELF MODIFIED * must exit with RTS * - CC if IRQ cleared, CS if NOT *-------------------------------------- -GP.IrqH cld +GP.IRQ cld bit IRQ.SkipA2osX After A2osX IRQ.H ? - bmi GP.IrqH.Exit + bmi GP.IRQ.Exit sta SETALTZP switch to aux LC tsx stx A2osX.SaveSM ldx A2osX.SaveSX txs -GP.IrqH.JSR jsr K.IrqH.DEV SELF MODIFIED +GP.IRQ.JSR jsr CORE.IRQ.DEV SELF MODIFIED tsx go back to Main stx A2osX.SaveSX ldx A2osX.SaveSM @@ -391,7 +391,7 @@ GP.IrqH.JSR jsr K.IrqH.DEV SELF MODIFIED sta CLRALTZP rts -GP.IrqH.Exit stz IRQ.SkipA2osX reset flag +GP.IRQ.Exit stz IRQ.SkipA2osX reset flag sec rts *-------------------------------------- diff --git a/SYS/KERNEL.S.INIT.txt b/SYS/KERNEL.S.INIT.txt index 8a5884ca..13f0a732 100644 --- a/SYS/KERNEL.S.INIT.txt +++ b/SYS/KERNEL.S.INIT.txt @@ -22,7 +22,7 @@ Kernel.Init2 sei >LDYA PAKME.MAIN >STYA ZPInBufPtr - >LDYAI CORE.Run + >LDYAI A2osX.EndTables jsr A2osX.Unpak >LDYA PAKME.AUX @@ -595,6 +595,7 @@ CPU.Init.Z80 >PUSHWI MSG.Z80 >PUSHBI 1 >SYSCALL2 printf rts + .9 >LDYAI MSG.Z80.KO >SYSCALL2 puts rts @@ -793,7 +794,7 @@ DevMgrInit.AddBDev >PUSHWI FD.BDEV >PUSHWI FD.BDEV.NAME >SYSCALL2 MKDev -DevMgrInit.AddBDev.RTS + rts *-------------------------------------- * Setup AuxLC $FFFE->Kernel IRQ Handler @@ -805,11 +806,11 @@ IrqMgrInit >LDYAI MSG.IRQ php sei >LDYA $FFFE - >STYA K.IrqHAuxLC.JMP+1 - >LDYAI K.IrqHAuxLC + >STYA IRQ.JMP+1 + >LDYAI IRQ.Handler >STYA $FFFE - >LDYAI GP.IrqH + >LDYAI GP.IRQ >STYA K.MLI.PARAMS+2 >MLICALL MLIALLOCIRQ @@ -831,12 +832,19 @@ IrqMgrInit >LDYAI MSG.IRQ jsr IrqMgrInit.HZ2Tick - >LDYAI K.IrqH.IIGS + >LDYAI CORE.IRQ.IIGS jsr IrqMgrInit.SetV + >LDYAI CORE.IRQ.IIGS.Off + >STYA CORE.Quit+1 + >LDYAI MSG.IRQ.IIGS bra .8 +.9 plp + sec + rts + .1 cmp #A2osX.HWType.IIc beq .2 @@ -845,9 +853,12 @@ IrqMgrInit >LDYAI MSG.IRQ lda #"C" sta IRQ.Mode - >LDYAI K.IrqH.TCLOCK + >LDYAI CORE.IRQ.TCLOCK jsr IrqMgrInit.SetV - + + >LDYAI CORE.IRQ.TCLOCK.Off + >STYA CORE.Quit+1 + >LDYAI MSG.IRQ.CLOCK bra .8 @@ -856,10 +867,13 @@ IrqMgrInit >LDYAI MSG.IRQ lda #"V" sta IRQ.Mode - >LDYAI K.IrqH.VBL + >LDYAI CORE.IRQ.MOUSE jsr IrqMgrInit.SetV - >LDYAI MSG.IRQ.VBL + >LDYAI CORE.IRQ.MOUSE.Off + >STYA CORE.Quit+1 + + >LDYAI MSG.IRQ.MOUSE bra .8 .3 jsr IrqMgrInit.HZ2Tick @@ -871,13 +885,9 @@ IrqMgrInit >LDYAI MSG.IRQ .8 >SYSCALL2 puts clc rts - -.9 plp - sec - rts *-------------------------------------- -IrqMgrInit.SetV >STYA K.IrqHAuxLC.JSR+1 - >STYA GP.IrqH.JSR+1 +IrqMgrInit.SetV >STYA IRQ.JSR+1 + >STYA GP.IRQ.JSR+1 rts *-------------------------------------- IrqMgrInit.TClock @@ -915,12 +925,15 @@ IrqMgrInit.TClock sty IRQ.VBL.n0 lda #A2osX.S.CLK sta A2osX.S,x + php sei lda #$40+$20 Enable interrupt + 64Hz sta $c080,y - lda #$40 + sta CLRPAGE2 + + lda #$40 sta $478,x sta $7f8,x @@ -959,8 +972,9 @@ IrqMgrInit.Mouse .4 lda ZPPtr1+1 sta .11+2 - sta K.IrqH.VBL.MSM+2 - sta K.IrqH.VBL.MRM+2 + sta CORE.IRQ.MOUSE.Off.1+2 + sta CORE.IRQ.MOUSE+2 + sta CORE.IRQ.MOUSE.2+2 and #$0f sta IRQ.VBL.0n asl @@ -975,7 +989,10 @@ IrqMgrInit.Mouse bit RROMBNK2 Renable ROM to allow MOUSE II firmware works properly ldy #INITMOUSE jsr .10 + ldy #SETMOUSE + lda (ZPPtr1),y + sta CORE.IRQ.MOUSE.Off.1+1 lda #MOUSEMODx.INTVBL+MOUSEMODx.ACTIVE jsr .10 @@ -983,17 +1000,19 @@ IrqMgrInit.Mouse bit RRAMWRAMBNK1 ldy #SERVEMOUSE lda (ZPPtr1),y - sta K.IrqH.VBL.MSM+1 + sta CORE.IRQ.MOUSE+1 ldy #READMOUSE lda (ZPPtr1),y - sta K.IrqH.VBL.MRM+1 + sta CORE.IRQ.MOUSE.2+1 jsr IrqMgrInit.HZ2Tick dec CORE.IRQMode + plp clc rts + .9 plp sec rts @@ -1196,7 +1215,7 @@ DRV.BLKDEV .DA DRV.RamDrive *-------------------------------------- MSG.IRQ .AZ "Interrupt Manager..." MSG.IRQ.IIGS .AZ " Apple IIgs VBL IRQ Activated." -MSG.IRQ.VBL .AZ " Mouse Card VBL IRQ Activated." +MSG.IRQ.MOUSE .AZ " Mouse Card VBL IRQ Activated." MSG.IRQ.CLOCK .AZ " Clock Card IRQ Activated." MSG.IRQ.POLL .AZ " Polling Mode." MSG.EVT .AZ "Event Manager..." diff --git a/SYS/KERNEL.S.IRQ.txt b/SYS/KERNEL.S.IRQ.txt index 37e4cc62..5eee17b2 100644 --- a/SYS/KERNEL.S.IRQ.txt +++ b/SYS/KERNEL.S.IRQ.txt @@ -12,19 +12,19 @@ NEW *-------------------------------------- MSLOT .EQ $7f8 *-------------------------------------- -K.IrqHAuxLC.BRK jmp K.IrqHAuxLC.6 +*IRQ.BRK jmp IRQ.6 *-------------------------------------- -K.IrqHAuxLC cld +IRQ.Handler cld - sta K.IrqHAuxLC.6+1 + sta IRQ.6+1 pla pha and #$10 BRK? -* bne K.IrqHAuxLC.BRK +* bne IRQ.BRK bne * - stx K.IrqHAuxLC.5+1 - sty K.IrqHAuxLC.4+1 + stx IRQ.5+1 + sty IRQ.4+1 lda RDPAGE2 pha @@ -43,7 +43,7 @@ K.IrqHAuxLC cld pha sta CLRCXROM Enable access to slot C800 space -K.IrqHAuxLC.JSR jsr K.IrqH.DEV SELF MODIFIED +IRQ.JSR jsr CORE.IRQ.DEV SELF MODIFIED ldx #CLRCXROM @@ -56,17 +56,17 @@ K.IrqHAuxLC.JSR jsr K.IrqH.DEV SELF MODIFIED pla Get back MSLOT sta MSLOT - sta K.IrqHAuxLC.2+2 + sta IRQ.2+2 and #$F0 eor #$C0 ....mmm...not looking like Cn.... - bne K.IrqHAuxLC.3 + bne IRQ.3 sta $CFFF Release $C800 -K.IrqHAuxLC.2 lda $ff00 SELF MODIFIED +IRQ.2 lda $ff00 SELF MODIFIED -K.IrqHAuxLC.3 pla Must keep Carry +IRQ.3 pla Must keep Carry bpl .1 sta SETWRITEAUX @@ -88,7 +88,7 @@ K.IrqHAuxLC.3 pla Must keep Carry sta SETPAGE2 -.30 bvc K.IrqHAuxLC.4 if not V, skip task switching +.30 bvc IRQ.4 if not V, skip task switching tsx Check Stack if before "dec IRQ.InKernel" cpx #$fc $1ff-PChi-PClo-P = $1fc @@ -123,15 +123,15 @@ K.IrqHAuxLC.3 pla Must keep Carry .8 clc -K.IrqHAuxLC.4 ldy #$ff Self Modified -K.IrqHAuxLC.5 ldx #$ff Self Modified -K.IrqHAuxLC.6 lda #$ff Self Modified - bcc K.IrqHAuxLC.8 +IRQ.4 ldy #$ff Self Modified +IRQ.5 ldx #$ff Self Modified +IRQ.6 lda #$ff Self Modified + bcc IRQ.8 dec IRQ.SkipA2osX Make regular ProDOS IRQ manager skip A2osX -K.IrqHAuxLC.JMP jmp $FFFF SELF MODIFIED Not handled, pass to ProDOS +IRQ.JMP jmp $FFFF SELF MODIFIED Not handled, pass to ProDOS -K.IrqHAuxLC.8 rti +IRQ.8 rti *-------------------------------------- MAN SAVE USR/SRC/SYS/KERNEL.S.IRQ