Kernel 0.92

This commit is contained in:
Rémy GIBERT 2019-01-13 13:10:14 +00:00
parent ece4bd6c55
commit 8fa59957fe
13 changed files with 167 additions and 131 deletions

Binary file not shown.

View File

@ -77,23 +77,22 @@ DumpDev >LDYA L.MSG0
>LDA.G Table.Index >LDA.G Table.Index
.1 tax .1 tax
lda Dev.Table.hFD,x lda Dev.Table,x
beq .7 sta ZPFDPtr
lda Dev.Table+1,x
>STA.G DEV.FD sta ZPFDPtr+1
>SYSCALL GetMemPtr beq .8
>STYA ZPFDPtr S.FD
jsr DumpDevFD jsr DumpDevFD
bcs .9 bcs .9
>PUSHEA.G DEV.DIB >PUSHEA.G DEV.DIB
>LDA.G DEV.FD >LDA.G Table.Index
>SYSCALL GetDevStatus >SYSCALL GetDevStatus
bcc .6 bcc .6
>PUSHA >PUSHA
>PUSHBI 6 >PUSHBI 1
>LDYA L.MSG2.ERR >LDYA L.MSG2.ERR
>SYSCALL printf >SYSCALL printf
@ -103,10 +102,11 @@ DumpDev >LDYA L.MSG0
.6 jsr DumpDevDIB .6 jsr DumpDevDIB
.7 >INC.G Table.Index .7 >INC.G Table.Index
>INC.G Table.Index
cmp #K.DEV.MAX cmp #K.DEV.MAX
bne .1 bne .1
clc .8 clc
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
DumpDevFD ldy #S.FD.DEV.DRVPTR+1 DumpDevFD ldy #S.FD.DEV.DRVPTR+1
@ -115,10 +115,13 @@ DumpDevFD ldy #S.FD.DEV.DRVPTR+1
dey dey
>PUSHB (ZPFDPtr),y >PUSHB (ZPFDPtr),y
>LDA.G Table.Index lda ZPFDPtr
tax clc
lda Dev.Table.hPath,x adc #S.FD.DEV
>SYSCALL GetMemPtr tay
lda ZPFDPtr+1
adc /S.FD.DEV
>PUSHYA >PUSHYA
>PUSHB.G DEV.FD >PUSHB.G DEV.FD

View File

@ -3,8 +3,7 @@ PREFIX
AUTO 4,1 AUTO 4,1
.LIST OFF .LIST OFF
*-------------------------------------- *--------------------------------------
Dev.Table.hPath .EQ $1300 K.Dev.MAX Dev.Table .EQ $1300 K.Dev.MAX*2
Dev.Table.hFD .EQ $131C K.Dev.MAX
*-------------------------------------- *--------------------------------------
Flt.Table.hPath .EQ $1338 K.FLT.MAX Flt.Table.hPath .EQ $1338 K.FLT.MAX
Flt.Table.hLib .EQ $133C K.FLT.MAX Flt.Table.hLib .EQ $133C K.FLT.MAX

View File

@ -349,7 +349,8 @@ CORE.GetPSByID tay
lda PS.TABLE.hPS,y lda PS.TABLE.hPS,y
jmp K.GetMemPtr jmp K.GetMemPtr
.8 >LDYAI CORE.S.PS0 Select PS0 .8 lda CORE.hPS0
jsr K.GetMemPtr
CORE.GetPSByID.8 CORE.GetPSByID.8
clc clc
CORE.GetPSByID.RTS CORE.GetPSByID.RTS
@ -367,7 +368,7 @@ CORE.GetPS ldy #0
.9 lda #E.NSP .9 lda #E.NSP
* sec * sec
rts CORE.GetPS.RTS rts
*-------------------------------------- *--------------------------------------
*CORE.DumpEvent ldy #S.EVT-1 *CORE.DumpEvent ldy #S.EVT-1
@ -383,20 +384,18 @@ CORE.GetPS ldy #0
CORE.ScrSel and #$0F CORE.ScrSel and #$0F
tax tax
lda A2osX.SCRNDEVS,x Get DevID lda A2osX.SCRNDEVS,x Get DevID
beq .8 No device claimed this screen beq CORE.GetPS.RTS No device claimed this screen
cmp A2osX.ASCREEN Same as active screen...nothing to do cmp A2osX.ASCREEN Same as active screen...nothing to do
beq .8 beq CORE.GetPS.RTS
tax pha
>PUSHWI 0 Param >PUSHWI 0 Param
>PUSHBI IOCTL.CONTROL request >PUSHBI IOCTL.CONTROL request
lda Dev.Table.hFD,x pla
jsr K.IOCTL jmp K.IOCTL
.8 rts
*-------------------------------------- *--------------------------------------
CORE.DestroyEvent CORE.DestroyEvent
lda (pEvent) lda (pEvent)
@ -423,7 +422,8 @@ CORE.DestroyEvent
dec CORE.EvtCount dec CORE.EvtCount
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
CORE.PSSelect0 >LDYAI CORE.S.PS0 Select PS0 CORE.PSSelect0 lda CORE.hPS0
jsr K.GetMemPtr
>STYA pPs >STYA pPs
>LDYAI K.STACKTOP >LDYAI K.STACKTOP
@ -531,23 +531,6 @@ DevMgr.Free .DA DevMgr.FreeMem
DevMgr.DevCnt .DA #0 DevMgr.DevCnt .DA #0
DevMgr.NodCnt .DA #0 DevMgr.NodCnt .DA #0
*-------------------------------------- *--------------------------------------
CORE.VBLState .BS 1
CORE.IRQMode .BS 1
CORE.TickPerSec .BS 1
CORE.TickPer10t .BS 1
CORE.TickSec .BS 1
CORE.Tick10t .BS 1
CORE.CPUStatCnt .DA #100
CORE.InKernelHits .BS 1
CORE.InKernelStats .BS 1
*--------------------------------------
CORE.EvtIndex .BS 1
CORE.EvtCount .BS 1
CORE.PSIndex .BS 1
CORE.PSCount .DA #0
CORE.LastPSID .DA #0
CORE.S.PS0 .BS S.PS.hStdErr+1
*--------------------------------------
MAN MAN
SAVE USR/SRC/SYS/KERNEL.S.CORE SAVE USR/SRC/SYS/KERNEL.S.CORE
LOAD USR/SRC/SYS/KERNEL.S LOAD USR/SRC/SYS/KERNEL.S

View File

@ -9,30 +9,39 @@ AUTO 4,1
* Y,A = FD * Y,A = FD
* X = DevID * X = DevID
*\-------------------------------------- *\--------------------------------------
K.GetDevByName >STYA ZPPtr1 K.GetDevByName >STYA ZPPtr1 requested dev name
ldx #0 ldx #0
.1 lda Dev.Table.hPath,x .1 lda Dev.Table,x
beq K.GetDev.NODEV sta .3+1
jsr K.GetMemPtr clc
adc #S.FD.DEV
sta ZPPtr2
>STYA ZPPtr2 lda Dev.Table+1,x
beq K.GetDev.NODEV
sta .4+1
adc /S.FD.DEV
sta ZPPtr2+1
ldy #$ff ldy #$ff
.2 iny .2 iny
lda (ZPPtr1),y lda (ZPPtr1),y
cmp (ZPPtr2),y cmp (ZPPtr2),y
bne .4 bne .7
ora (ZPPtr2),y Both char are 0 ? ora (ZPPtr2),y Both char are 0 ?
bne .2 no....loop bne .2 no....loop
lda Dev.Table.hFD,x .3 ldy #$ff SELF MODIFIED
jmp K.GetMemPtr .4 lda #$ff SELF MODIFIED
clc
rts
.4 inx .7 inx
inx
cpx DevMgr.DevCnt cpx DevMgr.DevCnt
bne .1 bne .1
@ -42,18 +51,21 @@ K.GetDev.9 rts
*/-------------------------------------- */--------------------------------------
* # GetDevStatus * # GetDevStatus
* ## C * ## C
* `int getdevstatus(short int hFD, S.DIB* dstat);` * `int getdevstatus(short int hDEV, S.DIB* dstat);`
* ## ASM * ## ASM
* `>PUSHWI S.DIB` * `>PUSHWI S.DIB`
* `lda DevID` * `lda DevID`
* `>SYSCALL GetDevStatus` * `>SYSCALL GetDevStatus`
* ## RETURN VALUE * ## RETURN VALUE
*\-------------------------------------- *\--------------------------------------
K.GetDevStatus jsr K.GetMemPtr K.GetDevStatus tax
>STYA pFD
>PULLW K.S.IOCTL+S.IOCTL.BUFPTR >PULLW K.S.IOCTL+S.IOCTL.BUFPTR
lda Dev.Table+1,x
beq K.GetDev.NODEV
ldy Dev.Table,x
>STYA pFD
lda #S.IOCTL.STATCODE.GETDIB lda #S.IOCTL.STATCODE.GETDIB
K.GetDevStatus.I K.GetDevStatus.I
sta K.S.IOCTL+S.IOCTL.STATCODE sta K.S.IOCTL+S.IOCTL.STATCODE
@ -82,22 +94,43 @@ K.MKDev jsr MEM.SPtr1PPtr2 ptr1=fd, ptr2=name
cpx #K.DEV.MAX cpx #K.DEV.MAX
beq .9 beq .9
>LDYAI S.FD.DEV ldy #$ff
ldx #S.MEM.F.FD ldx #S.FD.DEV
jsr MEM.GetMem.YAX
.1 iny Get DEV name length
inx compute FD+NAME+\0 in X
lda (ZPPtr2),y
bne .1
txa
tay
lda #0
jsr MEM.GetKrnlBuf
bcs .99 bcs .99
>STYA pFD >STYA pFD
txa >STYA .4+1
ldx DevMgr.DevCnt ldx DevMgr.DevCnt
sta Dev.Table.hFD,x sta Dev.Table+1,x
tya
sta Dev.Table,x
ldy #S.FD.DEV-1 ldy #S.FD.DEV-1
.1 lda (ZPPtr1),y .2 lda (ZPPtr1),y
sta (pFD),y sta (pFD),y
dey dey
bpl .1 bpl .2
ldy #$ff
ldx #S.FD.DEV-1
.3 iny
inx
lda (ZPPtr2),y
.4 sta $ffff,x
bne .3
>LDYAI K.IOBuf >LDYAI K.IOBuf
>STYA K.S.IOCTL+S.IOCTL.BUFPTR >STYA K.S.IOCTL+S.IOCTL.BUFPTR
@ -113,13 +146,13 @@ K.MKDev jsr MEM.SPtr1PPtr2 ptr1=fd, ptr2=name
ldx #0 ldx #0
.3 lda IRQ.Vectors+1,x .5 lda IRQ.Vectors+1,x
beq .7 beq .7
inx inx
inx inx
cpx #K.IRQDEV.MAX*2 cpx #K.IRQDEV.MAX*2
bne .3 bne .5
.9 lda #E.OOH .9 lda #E.OOH
* sec * sec
@ -130,16 +163,8 @@ K.MKDev jsr MEM.SPtr1PPtr2 ptr1=fd, ptr2=name
lda pFD+1 lda pFD+1
sta IRQ.Vectors+1,x sta IRQ.Vectors+1,x
.8 >LDYA ZPPtr2 .8 lda DevMgr.DevCnt
>SYSCALL StrDup inc DevMgr.DevCnt
bcs .99
txa
ldx DevMgr.DevCnt
sta Dev.Table.hPath,x
txa
inc DevMgr.DevCnt inc DevMgr.DevCnt
* clc * clc
rts rts

View File

@ -50,9 +50,8 @@ K.OpenDir jsr PFT.CheckPathYA
ldy #S.FD.DIR.REF ldy #S.FD.DIR.REF
sta (pFD),y sta (pFD),y
.8 ldx #$ff Self Modified .8 lda #$ff Self Modified
>LDYAI K.Buf256 jsr STDIO.NewHFile
jsr STDIO.NewHFileYAX
bcc .99 bcc .99

View File

@ -343,6 +343,23 @@ GP.IrqH.Exit stz IRQ.SkipA2osX reset flag
sec sec
rts rts
*-------------------------------------- *--------------------------------------
CORE.VBLState .BS 1
CORE.IRQMode .BS 1
CORE.TickPerSec .BS 1
CORE.TickPer10t .BS 1
CORE.TickSec .BS 1
CORE.Tick10t .BS 1
CORE.CPUStatCnt .DA #100
CORE.InKernelHits .BS 1
CORE.InKernelStats .BS 1
*--------------------------------------
CORE.EvtIndex .BS 1
CORE.EvtCount .BS 1
CORE.PSIndex .BS 1
CORE.PSCount .DA #0
CORE.LastPSID .DA #0
CORE.hPS0 .BS 1
*--------------------------------------
IRQ.Mode .BS 1 IRQ.Mode .BS 1
IRQ.SkipA2osX .BS 1 IRQ.SkipA2osX .BS 1
IRQ.Tick .BS 1 IRQ.Tick .BS 1

View File

@ -112,8 +112,10 @@ Kernel.Init3 sta SETALTZP
jsr MemMgrInit jsr MemMgrInit
>LDYAI CORE.S.PS0 Select Process 0 (Kernel) >LDYAI S.PS Select Process 0 (Kernel)
jsr K.GetMem0
>STYA pPs >STYA pPs
stx CORE.hPS0
>LDYAI K.STACKTOP >LDYAI K.STACKTOP
>STYA pStack >STYA pStack
@ -131,13 +133,25 @@ Kernel.Init3 sta SETALTZP
lda #"P" lda #"P"
sta SYS.BASL0+38 sta SYS.BASL0+38
jsr PS0.Init >PUSHWI 0 Aux type
>PUSHBI S.FI.T.TXT
>PUSHBI O.RDWR
>LDYAI DEV.CONSOLE
>SYSCALL fopen
bcs * bcs *
ldy #S.PS.hStdIn
sta (pPs),y
iny #S.PS.hStdOut
sta (pPs),y
iny #S.PS.hStdErr
sta (pPs),y
lda #"I" lda #"I"
sta SYS.BASL0+38 sta SYS.BASL0+38
*-------------------------------------- *--------------------------------------
>LDYAI MSG.Init3 Kernel.Init3C >LDYAI MSG.Init3
>SYSCALL puts >SYSCALL puts
jsr CPU.Init.6502 jsr CPU.Init.6502
@ -279,7 +293,7 @@ MemMgrInit >LDYAI Mem.MHiMem
ldx #K.DEV.MAX*2-1 ldx #K.DEV.MAX*2-1
.1 stz Dev.Table.hPath,x .1 stz Dev.Table,x
dex dex
bpl .1 bpl .1
@ -392,27 +406,6 @@ SysScrInit.TTYPtrs
rts rts
*-------------------------------------- *--------------------------------------
PS0.Init >PUSHWI 0 Aux type
>PUSHBI S.FI.T.TXT
>PUSHBI O.RDWR
>LDYAI DEV.CONSOLE
>SYSCALL fopen
bcs .9
ldy #S.PS.hStdIn
sta (pPs),y
sta CORE.S.PS0+S.PS.hStdIn
iny #S.PS.hStdOut
sta (pPs),y
sta CORE.S.PS0+S.PS.hStdOut
iny #S.PS.hStdErr
sta (pPs),y
sta CORE.S.PS0+S.PS.hStdErr
* clc
.9 rts
*--------------------------------------
CPU.Init.6502 >PUSHBI 0 CPU.Init.6502 >PUSHBI 0
>LDYAI MSG.CPU >LDYAI MSG.CPU
>SYSCALL printf >SYSCALL printf

View File

@ -83,7 +83,7 @@ IO.Open.I ldx #5 $/DEV/
.8 .DA STDIO.IOERR REG .8 .DA STDIO.IOERR REG
.DA STDIO.IOERR DIR .DA STDIO.IOERR DIR
.DA IO.OPEN.CDEV .DA IO.OPEN.CDEV
.DA STDIO.IOERR BDEV .DA IO.OPEN.BDEV
.DA STDIO.IOERR LNK .DA STDIO.IOERR LNK
.DA IO.OPEN.DSOCK .DA IO.OPEN.DSOCK
.DA IO.OPEN.SSOCK .DA IO.OPEN.SSOCK
@ -173,7 +173,8 @@ IO.OPEN.REG.E >LDYAI S.FD.REG
sec sec
rts rts
*-------------------------------------- *--------------------------------------
IO.OPEN.CDEV sta .1+1 A=DEVID IO.OPEN.CDEV
IO.OPEN.BDEV sta .1+1 A=DEVID
pha pha
jsr K.IOCTL.GetPDrv jsr K.IOCTL.GetPDrv
@ -182,8 +183,8 @@ IO.OPEN.CDEV sta .1+1 A=DEVID
jsr K.IOCTL.pDrvJmp jsr K.IOCTL.pDrvJmp
bcs .9 bcs .9
.1 ldx #$ff SELF MODIFIED .1 lda #$ff SELF MODIFIED
lda Dev.Table.hFD,x
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
IO.OPEN.DSOCK IO.OPEN.DSOCK
@ -431,19 +432,22 @@ IO.WRITE.PIPE >PULLW K.S.IOCTL+S.IOCTL.BUFPTR
*/-------------------------------------- */--------------------------------------
* # IOCTL * # IOCTL
* ## C * ## C
* `int ioctl(short int hFD, int request, void * param );` * `int ioctl(short int DevID, int request, void * param );`
* ## ASM * ## ASM
* `PUSHWI param` * `PUSHWI param`
* `PUSHBI request` * `PUSHBI request`
* `lda hFD` * `lda hDEV`
* `>SYSCALL IOCTL` * `>SYSCALL IOCTL`
* ## RETURN VALUE * ## RETURN VALUE
* Y,A = ... * Y,A = ...
*\-------------------------------------- *\--------------------------------------
K.IOCTL jsr K.GetMemPtr K.IOCTL tax
bcs K.IOCTL.9 lda Dev.Table+1,x
beq K.IOCTL.9
>STYA pFD sta pFD+1
lda Dev.Table,x
sta pFD
jsr K.IOCTL.GetPDrv jsr K.IOCTL.GetPDrv
@ -454,7 +458,8 @@ K.IOCTL jsr K.GetMemPtr
K.IOCTL.pDrvJmp jmp (pDrv) K.IOCTL.pDrvJmp jmp (pDrv)
K.IOCTL.9 lda #MLI.E.NODEV K.IOCTL.9 sec
lda #MLI.E.NODEV
>RET 3 >RET 3
*-------------------------------------- *--------------------------------------
K.IOCTL.GetPDrv ldy #S.FD.DEV.DRVPTR K.IOCTL.GetPDrv ldy #S.FD.DEV.DRVPTR

View File

@ -97,9 +97,16 @@ PFT.CheckNodeA stx .80+1 Save SYSCALL #
beq .9 beq .9
sta IO.hFD sta IO.hFD
ldy OF.Table.hPath,x if 0, its a hDEV
bne .10
jsr K.GetMemPtr tax
>STYA pFD lda Dev.Table+1,x
ldy Dev.Table,x
bra .11
.10 jsr K.GetMemPtr
.11 >STYA pFD
ldy #S.FD.HANDLER ldy #S.FD.HANDLER
lda (pFD),y lda (pFD),y

View File

@ -982,13 +982,9 @@ K.FOpen jsr PFT.CheckPathYA
jsr IO.Open.I jsr IO.Open.I
bcs .9 bcs .9
tax sta .1+1 save hFD
stx .1+1 save hFD jsr STDIO.NewHFile
>LDYAI K.Buf256
jsr STDIO.NewHFileYAX
bcc .9 bcc .9
pha save MLI error pha save MLI error
@ -1275,12 +1271,10 @@ K.Rename jsr PFT.CheckPathYA
.9 >RET 2 .9 >RET 2
*-------------------------------------- *--------------------------------------
* Y,A = filepath * K.Buf256 = filepath
* X = hFD * X = hFD
*-------------------------------------- *--------------------------------------
STDIO.NewHFileYAX STDIO.NewHFile sta .4+1 Store hFD
pha
stx .4+1 Store hFD
ldx #0 ldx #0
@ -1291,14 +1285,20 @@ STDIO.NewHFileYAX
cpx #K.OF.MAX cpx #K.OF.MAX
bne .1 bne .1
pla
lda #E.OOH lda #E.OOH
* sec * sec
rts rts
.2 stx .3+1 Store hFILE .2 lda (pFD)
cmp #S.FD.T.CDEV
bcc .21 REG or DIR....store path
pla stz OF.Table.hPath,x STZ path for SPECIAL files
bra .4
.21 stx .3+1 Store hFILE
>LDYAI K.buf256
>SYSCALL strdup >SYSCALL strdup
bcs .9 bcs .9
txa txa

View File

@ -1134,8 +1134,13 @@ DRV.TERM.Title.ON
ldy #S.DCB.TTY.DEVID ldy #S.DCB.TTY.DEVID
lda (ZPDCBPtr),y lda (ZPDCBPtr),y
tax tax
lda Dev.Table.hPath,x lda Dev.Table,x
jsr K.GetMemPtr clc
adc #S.FD.DEV
tay
lda Dev.Table+1,x
adc /S.FD.DEV
>STYA ZPTmpWord >STYA ZPTmpWord
ldx #0 ldx #0

View File

@ -47,7 +47,6 @@ A2osX.D1 .PH $D000
.INB USR/SRC/SYS/KERNEL.S.STDLIB .INB USR/SRC/SYS/KERNEL.S.STDLIB
.INB USR/SRC/SYS/KERNEL.S.DEV .INB USR/SRC/SYS/KERNEL.S.DEV
.INB USR/SRC/SYS/KERNEL.S.FIO .INB USR/SRC/SYS/KERNEL.S.FIO
.INB USR/SRC/SYS/KERNEL.S.PFT
.EP .EP
A2osX.D2 .PH $D000 A2osX.D2 .PH $D000
.DA #RRAMWRAMBNK2 .DA #RRAMWRAMBNK2
@ -66,6 +65,7 @@ A2osX.E0 .PH $E000
.INB USR/SRC/SYS/KERNEL.S.TERMLC .INB USR/SRC/SYS/KERNEL.S.TERMLC
********* TMP ***** go to A2osX.D1 ********* TMP ***** go to A2osX.D1
.INB USR/SRC/SYS/KERNEL.S.IO .INB USR/SRC/SYS/KERNEL.S.IO
.INB USR/SRC/SYS/KERNEL.S.PFT
********* TMP ***** go to A2osX.D2 ********* TMP ***** go to A2osX.D2
.LIST ON .LIST ON
DevMgr.FreeMem .EQ * DevMgr.FreeMem .EQ *