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

View File

@ -3,8 +3,7 @@ PREFIX
AUTO 4,1
.LIST OFF
*--------------------------------------
Dev.Table.hPath .EQ $1300 K.Dev.MAX
Dev.Table.hFD .EQ $131C K.Dev.MAX
Dev.Table .EQ $1300 K.Dev.MAX*2
*--------------------------------------
Flt.Table.hPath .EQ $1338 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
jmp K.GetMemPtr
.8 >LDYAI CORE.S.PS0 Select PS0
.8 lda CORE.hPS0
jsr K.GetMemPtr
CORE.GetPSByID.8
clc
CORE.GetPSByID.RTS
@ -367,7 +368,7 @@ CORE.GetPS ldy #0
.9 lda #E.NSP
* sec
rts
CORE.GetPS.RTS rts
*--------------------------------------
*CORE.DumpEvent ldy #S.EVT-1
@ -383,20 +384,18 @@ CORE.GetPS ldy #0
CORE.ScrSel and #$0F
tax
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
beq .8
beq CORE.GetPS.RTS
tax
pha
>PUSHWI 0 Param
>PUSHBI IOCTL.CONTROL request
lda Dev.Table.hFD,x
pla
jsr K.IOCTL
.8 rts
jmp K.IOCTL
*--------------------------------------
CORE.DestroyEvent
lda (pEvent)
@ -423,7 +422,8 @@ CORE.DestroyEvent
dec CORE.EvtCount
.9 rts
*--------------------------------------
CORE.PSSelect0 >LDYAI CORE.S.PS0 Select PS0
CORE.PSSelect0 lda CORE.hPS0
jsr K.GetMemPtr
>STYA pPs
>LDYAI K.STACKTOP
@ -531,23 +531,6 @@ DevMgr.Free .DA DevMgr.FreeMem
DevMgr.DevCnt .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
SAVE USR/SRC/SYS/KERNEL.S.CORE
LOAD USR/SRC/SYS/KERNEL.S

View File

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

View File

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

View File

@ -343,6 +343,23 @@ GP.IrqH.Exit stz IRQ.SkipA2osX reset flag
sec
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.SkipA2osX .BS 1
IRQ.Tick .BS 1

View File

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

View File

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

View File

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

View File

@ -982,13 +982,9 @@ K.FOpen jsr PFT.CheckPathYA
jsr IO.Open.I
bcs .9
tax
sta .1+1 save hFD
stx .1+1 save hFD
>LDYAI K.Buf256
jsr STDIO.NewHFileYAX
jsr STDIO.NewHFile
bcc .9
pha save MLI error
@ -1275,12 +1271,10 @@ K.Rename jsr PFT.CheckPathYA
.9 >RET 2
*--------------------------------------
* Y,A = filepath
* K.Buf256 = filepath
* X = hFD
*--------------------------------------
STDIO.NewHFileYAX
pha
stx .4+1 Store hFD
STDIO.NewHFile sta .4+1 Store hFD
ldx #0
@ -1291,14 +1285,20 @@ STDIO.NewHFileYAX
cpx #K.OF.MAX
bne .1
pla
lda #E.OOH
* sec
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
bcs .9
txa

View File

@ -1134,8 +1134,13 @@ DRV.TERM.Title.ON
ldy #S.DCB.TTY.DEVID
lda (ZPDCBPtr),y
tax
lda Dev.Table.hPath,x
jsr K.GetMemPtr
lda Dev.Table,x
clc
adc #S.FD.DEV
tay
lda Dev.Table+1,x
adc /S.FD.DEV
>STYA ZPTmpWord
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.DEV
.INB USR/SRC/SYS/KERNEL.S.FIO
.INB USR/SRC/SYS/KERNEL.S.PFT
.EP
A2osX.D2 .PH $D000
.DA #RRAMWRAMBNK2
@ -66,6 +65,7 @@ A2osX.E0 .PH $E000
.INB USR/SRC/SYS/KERNEL.S.TERMLC
********* TMP ***** go to A2osX.D1
.INB USR/SRC/SYS/KERNEL.S.IO
.INB USR/SRC/SYS/KERNEL.S.PFT
********* TMP ***** go to A2osX.D2
.LIST ON
DevMgr.FreeMem .EQ *