Kernel 0.93+

This commit is contained in:
Rémy GIBERT 2019-10-11 15:06:33 +02:00
parent 85cee73031
commit 9db2372429
11 changed files with 242 additions and 138 deletions

Binary file not shown.

View File

@ -106,6 +106,10 @@ CS.RUN >LDYAI S.PW
>LDYA pData
>SYSCALL putpw
bcs .99
>SYSCALL FlushEtcPasswd
bcs .99
lda #0
sec
rts
@ -153,9 +157,14 @@ CS.RUN.ROOT ldy #0
>LEA.G PW+S.PW.PASSWD
>SYSCALL strcmp
bcs .99
>LDYA pData
>SYSCALL putpw
bcs .9
>SYSCALL FlushEtcPasswd
bcs .9
lda #0
sec
.9 rts

View File

@ -79,6 +79,9 @@ CS.RUN >LDYAI S.PW
>SYSCALL putpw
bcs .99
>SYSCALL FlushEtcPasswd
bcs .99
jsr CS.RUN.RmDir
bcs .99

View File

@ -287,6 +287,9 @@ CS.RUN.DIR .DO X.COPY.TO.DEST=1
bcs .1
cmp #3
beq .99 abort
jsr CS.RUN.ToUpper
cmp #'N'
bne .2
jmp CS.RUN.CR.NEXT no overwrite, nothing to do, no recurse
@ -336,6 +339,9 @@ CS.RUN.FILE jsr CS.RUN.FILE.MSG
bcs .1
cmp #3
beq .99 abort
jsr CS.RUN.ToUpper
cmp #'N'
bne .11
jmp CS.RUN.CR.NEXT no overwrite exit
@ -619,6 +625,13 @@ CS.RUN.GetPathY lda (pData),y
CS.RUN.IncCount >INCW.G Count
rts
*--------------------------------------
CS.RUN.ToUpper cmp #'a'
bcc .8
cmp #'z'+1
bcs .8
eor #$20
.8 rts
*--------------------------------------
CS.DOEVENT sec
rts
*--------------------------------------

View File

@ -284,7 +284,7 @@ SYS.UnsetEnv .EQ $BE
SYS.GetPWUID .EQ $D0
SYS.GetPWName .EQ $D2
SYS.PutPW .EQ $D4
* .EQ $D6
SYS.FlushEtcPasswd .EQ $D6
* .EQ $D8
* .EQ $DA

View File

@ -2,23 +2,29 @@ NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
BYTE8.MAX .EQ 1+15
REP.MAX .EQ 1+7
REP.MAX .EQ 1+1254
BL.MIN .EQ 3
BL.MAX .EQ 3+63
STR.MIN .EQ 127 DISABLED
STR.MAX .EQ 3+15
*--------------------------------------
PAK.B.BYTE8 .EQ %0.0000
PAK.B.BYTE8.W .EQ 5
PAK.B.TOP8 .EQ %10.000
PAK.B.BYTE8.W .EQ 1
PAK.B.BYTE8 .EQ %0
PAK.B.TOP8.W .EQ 5
PAK.B.TOP16 .EQ %110.000
PAK.B.TOP8 .EQ %10.000
PAK.B.TOP16.W .EQ 6
PAK.B.TOP24 .EQ %1110.000
PAK.B.TOP16 .EQ %110.000
PAK.B.TOP24.W .EQ 7
PAK.B.REPn .EQ %11110.000
PAK.B.REPn.W .EQ 8
PAK.B.BL .EQ %11111
PAK.B.TOP24 .EQ %1110.000
PAK.B.REP.W .EQ 5
PAK.B.REP .EQ %11110
PAK.B.BL.W .EQ 5
PAK.B.BL .EQ %11111
PAK.B.STR.W .EQ 6 DISABLED
PAK.B.STR .EQ %01.0000
*--------------------------------------
* Shunk Header :
* WORD : Target UNCompressed Length
@ -38,10 +44,11 @@ S.PAKSTAT.TOP8 .EQ 4
S.PAKSTAT.TOP16 .EQ 6
S.PAKSTAT.TOP24 .EQ 8
S.PAKSTAT.BYTE8 .EQ 10
S.PAKSTAT.REPN .EQ 12
S.PAKSTAT.BL .EQ 14
S.PAKSTAT.STR .EQ 12
S.PAKSTAT.REPN .EQ 14
S.PAKSTAT.BL .EQ 16
*
S.PAKSTAT .EQ 16
S.PAKSTAT .EQ 18
*--------------------------------------
LIBPAK.Pak .EQ 4
*--------------------------------------

View File

@ -76,7 +76,7 @@ Pak >PULLW Pak.SrcPtr
jsr Pak.Run
bcs .9
jsr Pak.ComputeBLBits
jsr Pak.ComputeLenBits
jsr Pak.BuildTOPTable
jsr Pak.PrintStats
@ -109,7 +109,7 @@ Pak >PULLW Pak.SrcPtr
Pak.Run >LDYA Pak.SrcPtr
>STYA ZPSrcPtr
stz Pak.Byte8.Longest
stz Pak.Str.Longest
stz Pak.Rep.Longest
@ -130,7 +130,7 @@ Pak.Run >LDYA Pak.SrcPtr
stz Pak.RepCnt
stz Pak.LastByte
stz Pak.Out.ByteCnt
stz Pak.Out.StrLen
ldx #S.PAKSTAT.PASS1
bit Pak.bPass2
@ -150,23 +150,23 @@ Pak.Run.1 inc Pak.SrcCnt
inc Pak.SrcCnt+1
beq .8 0 byte left...
.1 jsr Pak.ScanBL
.1 jsr Pak.ScanRep
bcs .2
jsr Pak.PutBL
bcs .9
ldy Pak.BestBLLen
bra .6
.2 jsr Pak.ScanRep
bcs .20
jsr Pak.PutRep
bcs .9
ldy Pak.RepCnt
stz Pak.RepCnt
bra .6
.2 jsr Pak.ScanBL
bcs .20
jsr Pak.PutBL
bcs .9
ldy Pak.BestBLLen
.6 tya
clc
@ -302,7 +302,19 @@ Pak.ScanBL >LDYA Pak.SrcPtr Start at beginning of Src buf
rts
*--------------------------------------
Pak.ComputeBLBits
Pak.ComputeLenBits
ldx #8
lda Pak.Rep.Longest
dec
.14 asl
bcs .15
dex
bra .14
.15 stx Pak.Rep.LenBits
ldx #8
lda Pak.BL.Longest
@ -420,11 +432,14 @@ Pak.PutRep ldx #S.PAKSTAT.REPN
Pak.PutRep.2 jsr Pak.Out.Flush
bcs .9
ldy #PAK.B.REP.W
lda #PAK.B.REP
jsr Pak.Out.PutYBits
bcs .9
lda Pak.RepCnt
dec remap 1-8 to 0-7 range
ldy #PAK.B.REPn.W
ora #PAK.B.REPn
ldy Pak.Rep.LenBits
jmp Pak.Out.PutYBits
@ -518,13 +533,10 @@ Pak.PutByte8.2 ldy Pak.Shnk+S.PAKSHNK.TOPCNT
dey
bne .1
ldx #S.PAKSTAT.BYTE8
jsr Pak.UpdateStats
inc Pak.Out.ByteCnt
ldy Pak.Out.ByteCnt
sta Pak.Out.ByteBuf,y
cpy #BYTE8.MAX
inc Pak.Out.StrLen
ldy Pak.Out.StrLen
sta Pak.Out.StrBuf,y
cpy #STR.MAX
bcc .9
jmp Pak.Out.Flush
@ -579,7 +591,7 @@ Pak.Out.Init lda Pak.Shnk+S.PAKSHNK.BLBITS
sta Pak.Out.Mask
stz Pak.Out.Byte
stz Pak.Out.ByteCnt
stz Pak.Out.StrLen
clc
.9 rts
@ -591,34 +603,65 @@ Pak.Out.Close bit Pak.Out.Mask
.8 clc
rts
*--------------------------------------
Pak.Out.Flush lda Pak.Out.ByteCnt
Pak.Out.Flush lda Pak.Out.StrLen
beq .8
dec
ora #PAK.B.BYTE8
cmp #STR.MIN
bcs .2
ldy #PAK.B.BYTE8.W
ldx #0
.1 ldy #PAK.B.BYTE8.W
lda PAK.B.BYTE8
jsr Pak.Out.PutYBits
bcs .9
inc Pak.Stat+S.PAKSTAT.BYTE8
bne .10
inc Pak.Stat+S.PAKSTAT.BYTE8+1
.10 inx
lda Pak.Out.StrBuf,x
ldy #8
jsr Pak.Out.PutYBits
bcs .9
cpx Pak.Out.StrLen
bne .1
bra .7
.2 dec
dec
dec
ora #PAK.B.STR
ldy #PAK.B.STR.W
jsr Pak.Out.PutYBits
bcs .9
ldx #0
.1 inx
lda Pak.Out.ByteBuf,x
.3 inx
lda Pak.Out.StrBuf,x
ldy #8
jsr Pak.Out.PutYBits
bcs .9
cpx Pak.Out.ByteCnt
bne .1
cpx Pak.Out.StrLen
bne .3
cpx Pak.Byte8.Longest
bcc .2
cpx Pak.Str.Longest
bcc .7
stx Pak.Byte8.Longest
stx Pak.Str.Longest
.2 stz Pak.Out.ByteCnt
ldx #S.PAKSTAT.STR
jsr Pak.UpdateStats
.7 stz Pak.Out.StrLen
.8 clc
.9 rts
@ -699,20 +742,21 @@ Pak.PrintStats lda Pak.BL.OfsBitsL
>PUSHB Pak.BL.Longest
>PUSHW Pak.Stat+S.PAKSTAT.BL
>PUSHB Pak.REP.LenBits
>PUSHB Pak.REP.Longest
>PUSHW Pak.Stat+S.PAKSTAT.REPN
>PUSHB Pak.Byte8.Longest
>PUSHW Pak.Stat+S.PAKSTAT.BYTE8
>PUSHB Pak.Str.Longest
>PUSHW Pak.Stat+S.PAKSTAT.STR
ldx #S.PAKSTAT.TOP24
ldx #S.PAKSTAT.BYTE8
.1 >PUSHW Pak.Stat,x
dex
dex
bpl .1
>PUSHBI 23
>PUSHBI 26
>LDYA L.MSG.Stats
>SYSCALL printf
@ -765,9 +809,10 @@ MSG.Stats .AS "\r\nPass 1 : %5D\r\n"
.AS "Top 8 : %5D\r\n"
.AS "Top 16 : %5D\r\n"
.AS "Top 24 : %5D\r\n"
.AS "Byte 8 : %5D, Longest : %d\r\n"
.AS "Rep N : %5D, Longest : %d\r\n"
.AZ "BLNK : %5D, Longest : %d (%d bits), Farest : %D (%d bits)\r\n"
.AS "Byte 8 : %5D\r\n"
.AS "String : %5D, Longest : %d\r\n"
.AS "Rep : %5D, Longest : %d (%d bits)\r\n"
.AZ "BL : %5D, Longest : %d (%d bits), Farest : %D (%d bits)\r\n"
MSG.Top24 .AZ "Top : %5d, %h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h%h\r\n"
TOP.Bits .DA #PAK.B.TOP8,PAK.B.TOP16,PAK.B.TOP24
TOP.BitCnt .DA #PAK.B.TOP8.W,#PAK.B.TOP16.W,#PAK.B.TOP24.W
@ -794,17 +839,19 @@ Pak.BestBL .BS 2
Pak.Cnt .BS 2
Pak.bStop .BS 1
Pak.Byte8.Longest .BS 1
Pak.Str.Longest .BS 1
Pak.Rep.Longest .BS 1
Pak.Rep.LenBits .BS 1
Pak.RepCnt .BS 1
Pak.LastByte .BS 1
Pak.Out.Byte .BS 1
Pak.Out.Mask .BS 1
Pak.Out.ByteCnt .BS 1
Pak.Out.ByteBuf .BS BYTE8.MAX
Pak.Out.StrLen .BS 1
Pak.Out.StrBuf .BS STR.MAX
*--------------------------------------
Pak.CntL .BS 256
Pak.CntH .BS 256

View File

@ -122,7 +122,7 @@ K.SYSCALL .DA 0 $00
.DA K.GetPWUID $D0
.DA K.GetPWName
.DA K.PutPW
.DA 0
.DA K.FlushEtcPasswd
.DA 0
.DA 0
.DA 0
@ -373,13 +373,13 @@ K.SYSCALL.BANK .DA #RRAMWRAMBNK1 $00
.DA #RRAMWRAMBNK2
.DA #$80
.DA #$C0 $D0 : PWD
.DA #$C0 $D0 : PWDX
.DA #$80
.DA #$C0 PWD
.DA #$C0 PWDX
.DA #$80
.DA #$C0 PWD
.DA #$C0 PWDX
.DA #$80
.DA #RRAMWRAMBNK2
.DA #0 PWD
.DA #$80
.DA #RRAMWRAMBNK2
.DA #$80

72
SYS/KERNEL.S.PWD.txt Normal file
View File

@ -0,0 +1,72 @@
NEW
AUTO 3,1
*--------------------------------------
K.FlushEtcPasswd
lda PWD.DBPtr
sta A1L
clc
adc PWD.DBSize
sta A2L
lda PWD.DBPtr+1
sta A1L+1
adc PWD.DBSize+1
sta A2L+1
>LDYA PWD.DBSize
>SYSCALL2 GetMem
bcs .9
stx .8+1
>STYA A4L Save Destination Address in MAIN
clc Aux To Main
jsr AuxMove
>PUSHWZ Aux type
>PUSHBI S.FI.T.TXT
>PUSHBI O.WRONLY+O.CREATE
>LDYAI PWD.FILE
ldx #SYS.FOpen
jsr K.SYSCALL2
bcc .1
pha
jsr .8
pla
sec
.9 rts
.1 sta .7+1
>PUSHW PWD.DBSize
lda .8+1
jsr K.getmemptr
>PUSHYA
lda .7+1
ldx #SYS.FWrite
jsr K.SYSCALL2
bcc .7
pha
jsr .7
pla
sec
rts
.7 lda #$ff SELF MODIFIED
ldx #SYS.fclose
jsr K.SYSCALL2
.8 lda #$ff
jmp K.freemem SELF MODIFIED
*--------------------------------------
PWD.hDB .BS 1
PWD.DBPtr .BS 2
PWD.DBSize .BS 2
PWD.FILE .AZ "${ROOT}ETC/PASSWD"
*--------------------------------------
MAN
SAVE USR/SRC/SYS/KERNEL.S.PWD
LOAD USR/SRC/SYS/KERNEL.S
ASM

View File

@ -38,16 +38,19 @@ K.GetPWUID sta ZPPtr1+1
jsr PWD.GetByte get UID
cmp ZPPtr1+1
beq PWD.GetPW.8
jsr PWD.NextLine
bra .1
PWD.GetPW.8 ldx ZPPtr2+1
beq .8 Dry run, no output
jmp PWD.Record2PW
.8 clc a = UID
rts
PWD.GetPW.9 lda #E.IPWDDB
sec
rts
.HS 2C BIT ABS
PWD.GetPW.99 lda #E.IUSR
sec
@ -83,16 +86,22 @@ K.GetPWName >STYA TXTPTR
.2 iny
jsr SHARED.TXTPTR.GetY
beq .4
cmp (ZPPtr3),y
beq .2
.3 jsr PWD.NextLine
bra .1
.4 lda (ZPPtr3),y
cmp #':'
bne .3
ldx ZPPtr2+1
beq .8
jmp PWD.Record2PW
.8 iny
jsr PWD.NextString skip PASSWORD
jmp PWD.GetByte get UID
@ -113,9 +122,11 @@ K.PutPW >STYA ZPPtr2
*--------------------------------------
lda PWD.hDB
bne .1
ldy #S.PW.UID
jsr SHARED.TXTPTR.GetY
bne PWD.GetPW.RTS Must be ROOT user
jsr PWD.GetRecordLen
tay
lda #0
@ -127,15 +138,19 @@ K.PutPW >STYA ZPPtr2
>STYA PWD.DBPtr
stx PWD.hDB
jmp .8
.1 jsr K.GetmemPtr
>STYA PWD.DBPtr
ldy #S.PW.PASSWD
jsr SHARED.TXTPTR.GetY
bne .12
jsr PWD.DeleteRecord
bcc .80
rts
.12 jsr PWD.DeleteRecord
bcc .11 user exits..
jsr PWD.GetUID new user, get UID
@ -180,71 +195,14 @@ K.PutPW >STYA ZPPtr2
jsr K.Freemem
.8 jsr PWD.StoreRecord
.80 inc PWD.bDirty
clc
.80 clc
.99 rts
.9 lda #E.IPWDDB
sec
rts
*--------------------------------------
PWD.Save lda PWD.bDirty
beq .9
lda PWD.DBPtr
sta A1L
clc
adc PWD.DBSize
sta A2L
lda PWD.DBPtr+1
sta A1L+1
adc PWD.DBSize+1
sta A2L+1
>LDYA PWD.DBSize
>SYSCALL2 GetMem
bcs .9
stx .8+1
>STYA A4L Save Destination Address in MAIN
clc Aux To Main
jsr AuxMove
>PUSHWZ Aux type
>PUSHBI S.FI.T.TXT
>PUSHBI O.WRONLY+O.CREATE
>LDYAI PWD.FILE
ldx #SYS.FOpen
jsr K.SYSCALL2
bcc .1
pha
jsr .8
pla
sec
.9 rts
.1 sta .7+1
>PUSHW PWD.DBSize
lda .8+1
jsr K.getmemptr
>PUSHYA
lda .7+1
ldx #SYS.FWrite
jsr K.SYSCALL2
bcc .2
pha
jsr .7
pla
sec
rts
.2 stz PWD.bDirty
.7 lda #$ff SELF MODIFIED
ldx #SYS.fclose
jsr K.SYSCALL2
.8 lda #$ff
jmp K.freemem SELF MODIFIED
*--------------------------------------
* PRIVATE
*--------------------------------------
PWD.GetUID >LDYA PWD.DBPtr

View File

@ -69,17 +69,12 @@ A2osX.E0 .PH $E000
.INB USR/SRC/SYS/KERNEL.S.TERMLC
.INB USR/SRC/SYS/KERNEL.S.SHARED
.INB USR/SRC/SYS/KERNEL.S.STDIO2
.INB USR/SRC/SYS/KERNEL.S.PWD
********* TMP ***** go to A2osX.D1
.INB USR/SRC/SYS/KERNEL.S.IO
.INB USR/SRC/SYS/KERNEL.S.PIPE
********* TMP ***** go to A2osX.D2
*--------------------------------------
PWD.bDirty .BS 1
PWD.hDB .BS 1
PWD.DBPtr .BS 2
PWD.DBSize .BS 2
PWD.FILE .AZ "${ROOT}ETC/PASSWD"
*--------------------------------------
DevMgr.Stat .DA DevMgr.FreeMem
DevMgr.Free .DA DevMgr.FreeMem
.DA DevMgr.HiMem