Kernel 0.93

This commit is contained in:
Rémy GIBERT 2019-04-09 16:47:33 +01:00
parent 4613e2e20c
commit dc1fbce88f
13 changed files with 577 additions and 99 deletions

View File

@ -1,100 +1,97 @@
NEW
PREFIX
AUTO 4,1 Enable MASM3 auto line num
.LIST OFF
.OP 65C02 Target CPU, must = CPU header level
.OR $2000 usualy $2000, any value > $100 ok
.TF <PATH TO BINARY> e.g. BIN/MYPROG
*--------------------------------------
.INB INC/MACROS.I
.INB INC/A2OSX.I
*--------------------------------------
* Zero Page Segment, up to 32 bytes
*--------------------------------------
.DUMMY
.OR ZPBIN
AUTO 3,1 Enable MASM3 auto line num
.LIST OFF
.OP 65C02 Target CPU, must = CPU header level
.OR $2000 usualy $2000, any value > $100 ok
.TF <PATH TO BINARY> e.g. BIN/MYPROG
*---------------------------------------
.INB INC/MACROS.I
.INB INC/A2OSX.I
*---------------------------------------
* Zero Page Segment, up to 32 bytes (0 filled before INIT)
*---------------------------------------
.DUMMY
.OR ZPBIN
ZS.START
* MyPtr .BS 2
ZS.END .ED
*--------------------------------------
*---------------------------------------
* File Header (16 Bytes)
*--------------------------------------
*---------------------------------------
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 #0
.DA CS.END-CS.START Code Size (without Constants)
.DA DS.END-DS.START Data SegmentSize
.DA #16 Stack Size
.DA #ZS.END-ZS.START Zero Page Size
.DA 0
*--------------------------------------
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
.DA #0 S.PS.F.EVENT
.DA #0
.DA CS.END-CS.START Code Size (without Constants)
.DA DS.END-DS.START Data SegmentSize
.DA #16 Stack Size
.DA #ZS.END-ZS.START Zero Page Size
.DA 0
*---------------------------------------
* Relocation Table
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
*---------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
* Add any address you want be relocated by loader
* Usefull if you have to pass EFFECTIVE address to an API call...
* L.MSG.Test .DA Msg.Test
.DA 0
*--------------------------------------
.DA 0
*---------------------------------------
* Called once at process creation
* Put code for loading LIB here
*--------------------------------------
*---------------------------------------
CS.INIT clc
rts
*--------------------------------------
rts
*---------------------------------------
* Called until exit with CS
* if RUN exits with CC, RN entered again
*--------------------------------------
*---------------------------------------
CS.RUN
* Put your code here
* >LDYA L.MSG.Test Load EFFECTIVE address
* >SYSCALL puts Call API to print a string
* >LDYA L.MSG.Test Load EFFECTIVE address
* >SYSCALL puts Call API to print a string
.8 lda #0 Exit Code = Succes
sec QUIT Process
rts
.8 lda #0 Exit Code = Succes
sec QUIT Process
rts
.9 lda #E.SYN Exit Code = Succes
sec QUIT Process
rts
*--------------------------------------
.9 lda #E.SYN Exit Code = Succes
sec QUIT Process
rts
*---------------------------------------
* Called if option S.PS.F.EVENT enabled in Header
* Timer Event : every 10th seconds
*--------------------------------------
*---------------------------------------
CS.DOEVENT sec
rts
*--------------------------------------
rts
*---------------------------------------
* Called once, when RUN exited with CS
* Put code for unloading LIB here
*--------------------------------------
*---------------------------------------
CS.QUIT clc
rts
*--------------------------------------
rts
*---------------------------------------
CS.END
*--------------------------------------
*---------------------------------------
* Initialized DATA
*--------------------------------------
*---------------------------------------
* Put your constant here :
* MSG.TEST .AZ "Test Message"
*--------------------------------------
* Per Process DATA segement (0 filled before INIT)
*--------------------------------------
.DUMMY
.OR 0
*---------------------------------------
* Per Process DATA segement (0 filled before INIT)
*---------------------------------------
.DUMMY
.OR 0
DS.START
DS.END
.ED
*--------------------------------------
.ED
*---------------------------------------
MAN
SAVE USR/SRC/BIN<MYPROG.S> Save this source file
SAVE USR/SRC/BIN<MYPROG.S> Save this source file
ASM

Binary file not shown.

BIN
A2osX.logo.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

View File

@ -0,0 +1,206 @@
NEW
AUTO 3,1
.LIST OFF
.OP 65C02
.OR $2000
.TF BIN/USERADD
*--------------------------------------
.INB INC/MACROS.I
.INB INC/A2OSX.I
*--------------------------------------
* Zero Page Segment, up to 32 bytes
*--------------------------------------
.DUMMY
.OR ZPBIN
ZS.START
ZPPWPtr .BS 2
ZPhPW .BS 1
ZPStrPtr .BS 2
ZPhStr .BS 1
ZPbStrSecret .BS 1
ZPStrLen .BS 1
ZPStrMax .BS 1
ZS.END .ED
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
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 #0
.DA CS.END-CS.START Code Size (without Constants)
.DA DS.END-DS.START Data SegmentSize
.DA #16 Stack Size
.DA #ZS.END-ZS.START Zero Page Size
.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
L.LIBCRYPT .DA LIBCRYPT
L.MSG.USAGE .DA MSG.USAGE
L.MSG.ROOTPWD1 .DA MSG.ROOTPWD1
L.MSG.ROOTPWD2 .DA MSG.ROOTPWD2
L.MSG.BS .DA MSG.BS
.DA 0
*--------------------------------------
* Called once at process creation
* Put code for loading LIB here
*--------------------------------------
CS.INIT >LDYA L.LIBCRYPT
>SYSCALL LoadLib
bcs .9
sta hLIBCRYPT
.9 rts
*--------------------------------------
* Called until exit with CS
* if RUN exits with CC, RN entered again
*--------------------------------------
CS.RUN >LDYAI S.PW
>SYSCALL getmem
bcs .99
>STYA ZPPWPtr
stx ZPhPW
>LDYAI 256
>SYSCALL getmem
bcs .99
>STYA ZPStrPtr
stx ZPhStr
>PUSHW ZPPWPtr
lda #0
>SYSCALL GetPWUID
bcc .1
jmp CS.RUN.ROOT
.1
.8 lda #0
sec
rts
.9 lda #E.SYN
sec
.99 rts
*--------------------------------------
CS.RUN.ROOT sec
ror ZPbStrSecret
lda #127
sta ZPStrMax
>PUSHBI 0
>LDYA L.MSG.ROOTPWD1
>SYSCALL printf
bcs .9
jsr CS.RUN.GetStr
clc
.9 rts
*--------------------------------------
CS.RUN.GetStr stz ZPStrLen
.1 >SYSCALL getchar
bcs .9
cmp #C.SPACE
bcc .2
ldy ZPStrLen
cpy ZPStrMax
beq .1
sta (ZPStrPtr),y
iny
sty ZPStrLen
bit ZPbStrSecret
bmi .1
>SYSCALL putchar
bra .1
.2 cmp #3
beq .9
cmp #C.CR
beq .8
cmp #C.BS
bne .1
ldy ZPStrLen
beq .1
dec ZPStrLen
bit ZPbStrSecret
bmi .1
>PUSHBI 0
>LDYA L.MSG.BS
>SYSCALL printf
bra .1
.8 clc
.9 rts
*--------------------------------------
* Called if option S.PS.F.EVENT enabled in Header
* Timer Event : every 10th seconds
*--------------------------------------
CS.DOEVENT sec
rts
*--------------------------------------
* Called once, when RUN exited with CS
* Put code for unloading LIB here
*--------------------------------------
CS.QUIT lda ZPhStr
beq .1
>SYSCALL freemem
.1 lda ZPhPW
beq .2
>SYSCALL freemem
.2 lda hLIBCRYPT
beq .8
>SYSCALL UnloadLib
.8 clc
rts
*--------------------------------------
CS.END
*--------------------------------------
* Initialized DATA
*--------------------------------------
MSG.USAGE .AZ "Usage : USERADD username\r\n"
MSG.ROOTPWD1 .AZ "Please enter ROOT password : "
MSG.ROOTPWD2 .AZ "Please retype ROOT password : "
MSG.BS .DA #C.BS,#C.SPACE,#C.BS,#0
*--------------------------------------
LIBCRYPT .AZ "libcrypt"
hLIBCRYPT .BS 1
*--------------------------------------
* Per Process DATA segment
*--------------------------------------
.DUMMY
.OR 0
DS.START
PW .DA S.PW
DS.END
.ED
*--------------------------------------
MAN
SAVE USR/SRC/BIN/USERADD.S
ASM

View File

@ -666,6 +666,9 @@ DEBUG.PLOT php
sta CLRPAGE2
bcs .1 CS = main
sta SETPAGE2
plx
lda PALETTE.AUX,x
pha
.1 lda ZPCntY
cmp #40
@ -766,6 +769,8 @@ PALETTE.BGR .HS 00000000 BLACK
.HS 8dddd000 YELLOW
.HS d0ff7200 AQUA
.HS ffffff00 WHITE
*--------------------------------------
PALETTE.AUX .HS 00080109020A030B040C050D060E070F
*--------------------------------------
.DUMMY
.OR 0

View File

@ -89,28 +89,30 @@ A2osX.S.CLK .EQ $E3
A2osX.S.DISABLE .EQ $FF
*--------------------------------------
* ProDOS ERROR CODES : $00->$5F
* Kernel ERROR CODES : $60->$7F
* Lib ERROR CODES : $80->$BF
* Kernel ERROR CODES : $F0->$FF
*--------------------------------------
E.OOM .EQ $FF Out Of Memory Error
E.OOH .EQ $FE Out Of Handle Error
E.INVH .EQ $FD Invalid Handle
E.BUF .EQ $FC Buffer Overflow
E.BADPATH .EQ $FB
E.BADARG .EQ $FA
E.NSP .EQ $F9 No Such Process Error
E.SYN .EQ $F8 Syntax Error
E.ENVF .EQ $F7 Env is Full
E.IBIN .EQ $F6 Invalid BIN format
E.FTB .EQ $F5 File Too Big Error
E.OOB .EQ $F4 Out Of Bound
E.INUM .EQ $F3 Invalid Numerical
E.IUSR .EQ $F2 Invalid User
E.OOM .EQ $7F Out Of Memory Error
E.OOH .EQ $7E Out Of Handle Error
E.INVH .EQ $7D Invalid Handle
E.BUF .EQ $7C Buffer Overflow
E.BADPATH .EQ $7B
E.BADARG .EQ $7A
E.NSP .EQ $79 No Such Process Error
E.SYN .EQ $78 Syntax Error
E.ENVF .EQ $77 Env is Full
E.IBIN .EQ $76 Invalid BIN format
E.FTB .EQ $75 File Too Big Error
E.OOB .EQ $74 Out Of Bound
E.INUM .EQ $73 Invalid Numerical
E.NOKEY .EQ $EF Undefined Key
E.DUPKEY .EQ $EE Duplicate Key
E.NODATA .EQ $ED No Data
E.DATALEN .EQ $EC Data Length Mismatch
E.NOKEY .EQ $6F Undefined Key
E.DUPKEY .EQ $6E Duplicate Key
E.NODATA .EQ $6D No Data
E.DATALEN .EQ $6C Data Length Mismatch
E.IPWDDB .EQ $68 Invalid PWD database
E.IUSR .EQ $67 Invalid User
*--------------------------------------
* A2osX.SYSCALL Constants
*--------------------------------------
@ -624,11 +626,11 @@ S.PW.NAME .EQ 0 16+1
S.PW.PASSWD .EQ 17 32+1
S.PW.UID .EQ 50
S.PW.GID .EQ 51
S.PW.GECOS .EQ 52 32+1
S.PW.DIR .EQ 85 64+1
S.PW.SHELL .EQ 150 64+1
S.PW.GECOS .EQ 52 64+1
S.PW.DIR .EQ 115 64+1
S.PW.SHELL .EQ 182 64+1
*
S.PW .EQ 215
S.PW .EQ 247
*--------------------------------------
MAN
SAVE INC/A2OSX.I

View File

@ -102,11 +102,12 @@ Kernel.Init3 sta SETALTZP
sta IRQ.InKernel
stz IRQ.InLib
sta SETALTCHAR
sta CLRMIXED
sta CLRHIRES
sta SET80STORE
sta CLRPAGE2
sta SETALTCHAR
sta SETDHIRES
lda #"M"
sta SYS.BASL0+38
@ -172,6 +173,8 @@ Kernel.Init3C >LDYAI MSG.Init3
jsr TskMgrInit
bcs *
jsr PwdMgrInit
ldy #S.PS.hPREFIX
lda (pPs),y
jsr K.GetMemPtr
@ -1064,6 +1067,19 @@ TskMgrInit >LDYAI MSG.TSK
>SYSCALL PutEnv
.9 rts
*--------------------------------------
PwdMgrInit >LDYAI MSG.PWD
>SYSCALL puts
>PUSHWI 0 Aux type
>PUSHBI S.FI.T.TXT
>PUSHBI O.RDONLY
>LDYAI ETCPASSWD
>SYSCALL LoadStkObj
bcs .9
sta PWD.hDB
.9 rts
*--------------------------------------
* Modified CHARGET/CHARGOT for ROM CALL
* CHRGET .EQ $B1 - C8
*--------------------------------------
@ -1117,8 +1133,10 @@ MSG.IRQ.CLOCK .AZ " Clock Card IRQ Activated."
MSG.IRQ.POLL .AZ " Polling Mode."
MSG.EVT .AZ "Event Manager..."
MSG.TSK .AZ "Task Manager..."
MSG.PWD .AZ "Password Manager..."
MSG.Prefix .AZ "Root:%s\r\n"
MSG.CTRLR .AZ "Ctrl-R Pressed, entering ROOT mode..."
MSG.PWDINIT .AZ "Loading ETC/PASSWD file..."
MSG.ETCINIT .AZ "Executing %s..."
MSG.StartupErr .AZ "Failed : [$%h]\r\n"
MSG.Init3.OK .AZ "OK\r\nA2osX[Stage3]:Complete.\r\n"
@ -1144,6 +1162,7 @@ I.ENV.PATH .AZ "PATH=${ROOT}SBIN/:${ROOT}BIN/"
I.ENV.LIB .AZ "LIB=${ROOT}LIB/"
I.ENV.DRV .AZ "DRV=${ROOT}DRV/"
CTRLR.SHELL .AZ "${ROOT}BIN/SH"
ETCPASSWD .AZ "${ROOT}ETC/PASSWD"
ETCINIT.CMDLINE .AZ "${ROOT}ETC/INIT"
*--------------------------------------
MLIOPEN00 .DA #3

View File

@ -23,8 +23,8 @@ K.GetPWUID
* ## RETURN VALUE
*\--------------------------------------
K.GetPWName jsr MEM.SPtr1PPtr2
sec
rts
bra K.PutPW.1
*/--------------------------------------
* # PutPW
* ## C
@ -34,10 +34,19 @@ K.GetPWName jsr MEM.SPtr1PPtr2
* `>SYSCALL putpw`
* ## RETURN VALUE
*\--------------------------------------
K.PutPW >PULLW ZPPtr1
sec
K.PutPW >STYA ZPPtr1
K.PutPW.1 sta SETREADAUX
sta SETWRITEAUX
jsr X.PWD
sta CLRREADAUX
sta CLRWRITEAUX
rts
*--------------------------------------
PWD.hDB .BS 1
*--------------------------------------
MAN
SAVE USR/SRC/SYS/KERNEL.S.PWD
LOAD USR/SRC/SYS/KERNEL.S

27
SYS/KERNEL.S.PWDX.txt Normal file
View File

@ -0,0 +1,27 @@
NEW
AUTO 3,1
*--------------------------------------
X.PWD jmp (.1-SYS.GetPWUID,x)
.1 .DA PWD.GetPWUID
.DA PWD.GetPWName
.DA PWD.PutPW
*--------------------------------------
* USERNAME:PASSWORD:UID:GID:GECOS:HOME:SHELL
*--------------------------------------
PWD.GetPWUID
*--------------------------------------
PWD.GetPWName
*--------------------------------------
PWD.PutPW lda PWD.hDB
beq .9
.9 lda #E.IPWDDB
sec
rts
*--------------------------------------
PWD.FindByID
*--------------------------------------
MAN
SAVE USR/SRC/SYS/KERNEL.S.PWDX
LOAD USR/SRC/SYS/KERNEL.S
ASM

View File

@ -252,8 +252,7 @@ SLIST.NewKey jsr SLIST.Search
clc
rts
.99 >DEBUG
lda #E.DUPKEY
.99 lda #E.DUPKEY
sec
.9 rts
*--------------------------------------

View File

@ -32,6 +32,7 @@ Mem.MLoMem .EQ *
A2osX.AUX .PH $1000
.INB USR/SRC/SYS/KERNEL.S.OSD
.INB USR/SRC/SYS/KERNEL.S.SLIST
.INB USR/SRC/SYS/KERNEL.S.PWDX
.LIST ON
Mem.XLoMem .EQ *
.LIST OFF

View File

@ -8,10 +8,6 @@ AUTO 4,1
* M32.ARG .BS 4
* M32.TMP .BS 4
*--------------------------------------
* TODO : Make it SIGNED 32 bits
* http://6502.org/source/integers/32muldiv.htm
* http://nparker.llx.com/a2/mult.html
*--------------------------------------
M32.Add ldx #4
ldy #0

217
X.M32S.S.txt Normal file
View File

@ -0,0 +1,217 @@
NEW
PREFIX
AUTO 4,1
.LIST OFF
*--------------------------------------
* Uses: 12 ZP
* M32.ACC .BS 4
* M32.ARG .BS 4
* M32.TMP .BS 4
*--------------------------------------
* TODO : Make it SIGNED 32 bits, with OVERVLOW detection
* http://6502.org/source/integers/32muldiv.htm
* http://nparker.llx.com/a2/mult.html
*--------------------------------------
M32.Add ldx #4
ldy #0
clc ARG+ACC->ACC
.1 lda M32.ARG,y
adc M32.ACC,y
sta M32.ACC,y
iny
dex
bne .1
clc
rts if CS, Overflow
*---------------------------------------
M32.Sub ldx #4
ldy #0
sec ARG-ACC->ACC
.1 lda M32.ARG,y
sbc M32.ACC,y
sta M32.ACC,y
iny
dex
bne .1
clc
rts
bcs .8 if CC, Overflow
sec
rts
.8 clc
rts
*--------------------------------------
M32.Mul ldx #3 ARG*ACC->ACC
.1 lda M32.ACC,x
sta M32.TMP,x
stz M32.ACC,x
dex
bpl .1
ldx #32
.2 lsr M32.TMP+3
ror M32.TMP+2
ror M32.TMP+1
ror M32.TMP
bcc .3
clc
lda M32.ARG
adc M32.ACC
sta M32.ACC
lda M32.ARG+1
adc M32.ACC+1
sta M32.ACC+1
lda M32.ARG+2
adc M32.ACC+2
sta M32.ACC+2
lda M32.ARG+3
adc M32.ACC+3
sta M32.ACC+3
.3 asl M32.ARG
rol M32.ARG+1
rol M32.ARG+2
rol M32.ARG+3
dex
bne .2
clc
rts
*--------------------------------------
M32.Mod sec
.HS 90 BCC
*--------------------------------------
M32.Div clc
php
stz M32.TMP ARG/ACC->ACC
stz M32.TMP+1
stz M32.TMP+2
stz M32.TMP+3
ldx #32
.1 asl M32.ARG
rol M32.ARG+1
rol M32.ARG+2
rol M32.ARG+3
rol M32.TMP
rol M32.TMP+1
rol M32.TMP+2
rol M32.TMP+3
sec
lda M32.TMP
sbc M32.ACC
pha
lda M32.TMP+1
sbc M32.ACC+1
pha
lda M32.TMP+2
sbc M32.ACC+2
pha
lda M32.TMP+3
sbc M32.ACC+3
bcs .2
pla
pla
pla
dex
bne .1
bra .3
.2 sta M32.TMP+3
pla
sta M32.TMP+2
pla
sta M32.TMP+1
pla
sta M32.TMP
inc M32.ARG bit0 always 0 because of .1 asl
dex
bne .1
.3 plp
ldx #3
ldy #M32.ARG+3
bcc .4
ldy #M32.TMP+3
clc
.4 lda $0,y
sta M32.ACC,x
dey
dex
bpl .4
rts
*--------------------------------------
M32.ACC2ARG ldx #3 ACC->ARG
.1 lda M32.ACC,x
sta M32.ARG,x
dex
bpl .1
rts
*--------------------------------------
M32.Cmp ldx #4
ldy #0
sec
.1 lda M32.ARG,y
sbc M32.ACC,y
sta M32.ACC,y
iny
dex
bne .1
bcc .5 CC if ACC < ARG
lda M32.ACC
ora M32.ACC+1
ora M32.ACC+2
ora M32.ACC+3 Z if ACC = ARG
bne .4
lda #%010 010 ACC = ARG
rts
.4 lda #%100 100 ACC > ARG
rts
.5 lda #%001 001 ACC < ARG
rts
*--------------------------------------
MAN
SAVE USR/SRC/X.M32S.S
LOAD USR/SRC/BIN/SH.S
ASM