Kernel 0.94

This commit is contained in:
Rémy GIBERT 2020-09-24 17:31:48 +02:00
parent b5a45c1101
commit 020bfcdcbf
6 changed files with 294 additions and 111 deletions

Binary file not shown.

View File

@ -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
@ -38,6 +45,7 @@ CS.START cld
.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,8 +54,66 @@ 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
@ -55,11 +121,41 @@ CS.RUN >LDYA L.MSG.SHUTDOWN
>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
@ -201,7 +297,30 @@ CS.GetPSByID ldx #0
.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
@ -209,8 +328,10 @@ CS.QUIT clc
*--------------------------------------
CS.END
MSG.USAGE .AS "Usage : SHUTDOWN <NEXT.STSTEM>\r\n"
.AZ " -T <seconds> : \r\n"
MSG.SHUTDOWN .AZ "SHUTDOWN:System..."
.AS " -R : Restart System\r\n"
.AS " -T <seconds> : 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"
*--------------------------------------

View File

@ -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,6 +256,7 @@ CORE.GetEvents lda #Evt.Table
* CC: Event Cleared
*--------------------------------------
CORE.Dispatch ldx #1 skip PS0
bra .80
.1 stx CORE.PSIndex
@ -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

View File

@ -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
*--------------------------------------

View File

@ -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..."

View File

@ -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