Kernel 0.9.2

This commit is contained in:
Rémy GIBERT 2018-06-28 17:26:34 +02:00
parent 4d4fa6d241
commit cc7157abed
8 changed files with 244 additions and 205 deletions

View File

@ -10,6 +10,92 @@ CC : success
Y,A = PTR To Arg[A] Y,A = PTR To Arg[A]
CS : Out Of Bound CS : Out Of Bound
# LoadDrv
##ASM
**In:**
Y,A = PTR to "NAME.DRV [PARAM]" C-String
**Out:**
none
#K.InsDrv
##ASM
**In:**
Y,A = .DRV File Loaded Address
Note:
BIN.Load called from K.LoadDrv
Already setup correctly pDrv,
BIN.R.Start,End
# GetDevByID
**In:**
A = DevID
**Out:**
CC = OK, CS = ERROR
Y,A = DEVSLOT
# GetDevByName
**In:**
Y,A = Ptr to device name (C-String)
**Out:**
CC = OK, CS = ERROR
X = DEVID
Y,A = DEVSLOT
# GetDevStatus
**In:**
A = DevID
**Out:**
Y,A = S.DSTAT
# IOCTL
## C
`int ioctl ( short int id, short int op, void *param);`
## ASM
**In:**
`PUSHWI param`
`lda #op`
`ldy id`
`>SYSCALL IOCTL`
**Out:**
Y,A = ...
# OpenDir
**In:**
Y,A = PATH (C-String)
**Out:**
CC : success
A = hDIR
CS : error
A = EC
# ReadDir
**In:**
A = hDIR
**Out:**
CC : success
X = hDIRENT
Y,A = PTR to S.DIRENT
CS : error
A = EC
note : A = 0 means no more entry
# CloseDir
**In:**
A = hDIR
**Out:**
none, always succeed.
# ExpandStr
**In:**
Y,A = PTR to String to Expand (C-String)
**Out:**
X = hMem to Expanded String (C-String)
Y,A = PTR to Expanded String
# FileSearch # FileSearch
Search a file in the provided PATH list Search a file in the provided PATH list
And return, if found, the full path to it. And return, if found, the full path to it.
@ -29,76 +115,7 @@ DstBuf = FilePath
DstStat = S.STAT DstStat = S.STAT
CS : not found CS : not found
# GetDevByID.A # PutEnv
**In:**
A = DevID
**Out:**
CC = OK, CS = ERROR
Y,A = DEVSLOT
note: X Unmodified
# GetDevByName.YA
**In:**
Y,A = Ptr to device name (C-String)
**Out:**
CC = OK, CS = ERROR
X = DEVID
Y,A = DEVSLOT
# GetDevStatus.A
**In:**
A = DevID
**Out:**
Y,A = S.DSTAT
# IOCTL
## C
`int ioctl ( short int id, short int op, void *param);`
## ASM
**In:**
`PUSHWI param`
`lda #op`
`ldy id`
`>SYSCALL IOCTL`
**Out:**
Y,A = ...
# OpenDir.YA
**In:**
Y,A = PATH (C-String)
**Out:**
CC : success
A = hDIR
CS : error
A = EC
# ReadDir.A
**In:**
A = hDIR
**Out:**
CC : success
X = hDIRENT
Y,A = PTR to S.DIRENT
CS : error
A = EC
note : A = 0 means no more entry
# CloseDir.A
**In:**
A = hDIR
**Out:**
none, always succeed.
# ExpandStr
**In:**
Y,A = PTR to String to Expand (C-String)
**Out:**
X = hMem to Expanded String (C-String)
Y,A = PTR to Expanded String
# PutEnv.YA
**In:** **In:**
Y,A = PTR to String NAME=VALUE (C-String) Y,A = PTR to String NAME=VALUE (C-String)
**Out:** **Out:**
@ -109,19 +126,19 @@ note: X Unmodified
PUSHW = PTR To Name (PSTR) PUSHW = PTR To Name (PSTR)
**Out:** **Out:**
# GetEnv.YA # GetEnv
**In:** **In:**
Y,A = PTR to NAME (PSTR) Y,A = PTR to NAME (PSTR)
**Out:** **Out:**
CC : Y,A = PTR to VALUE (PSTR) CC : Y,A = PTR to VALUE (PSTR)
CS : not found CS : not found
# UnsetEnv.YA # UnsetEnv
**In:** **In:**
Y,A = PTR To Name (PSTR) Y,A = PTR To Name (PSTR)
**Out:** **Out:**
# LoadTxtFile.YA # LoadTxtFile
Load TXT a file in memory (with ending 0) Load TXT a file in memory (with ending 0)
**In:** **In:**
Y,A = File Path Y,A = File Path
@ -352,31 +369,31 @@ Load a file in AUX memory (Stock Objects)
Y,A = File Length Y,A = File Length
X = hMem of Loaded Object in AUX mem X = hMem of Loaded Object in AUX mem
# ExecPSNewEnv.YA # ExecPSNewEnv.
# ExecPS.YA (Blocking Parent PID) # ExecPS (Blocking Parent PID)
# CreatePSNewEnv.YA # CreatePSNewEnv
# CreatePS.YA (Non Blocking) # CreatePS (Non Blocking)
**In:** **In:**
Y,A = PTR To Cmd Line Y,A = PTR To Cmd Line
**Out:** **Out:**
A = Child PSID A = Child PSID
# GetMemStat.YA # GetMemStat
**In:** **In:**
Y,A = Ptr to 24 bytes buffer Y,A = Ptr to 24 bytes buffer
**Out:** **Out:**
Buffer filled with memory stats Buffer filled with memory stats
# GetPSStatus.A # GetPSStatus
**In:** **In:**
A = PID A = PID
**Out:** **Out:**
A = Status Byte A = Status Byte
# GetPSStat.YA # GetPSStat
**In:** **In:**
Y,A = Ptr to 24 bytes buffer Y,A = Ptr to 24 bytes buffer
**Out:** **Out:**
@ -389,7 +406,7 @@ Return information about a file
PUSHW = PTR to Filename (C-String) PUSHW = PTR to Filename (C-String)
**Out:** **Out:**
# MKDir.YA # MKDir
**In:** **In:**
Y,A = DIR name Y,A = DIR name
**Out:** **Out:**
@ -397,7 +414,8 @@ Return information about a file
CS : error CS : error
A = EC A = EC
# MkNod.YA # MkNod
int mknod(const char *pathname, mode_t mode, dev_t dev);
return a hFile for a given Device Name return a hFile for a given Device Name
**In:** **In:**
Y,A=DevName Y,A=DevName
@ -406,6 +424,7 @@ return a hFile for a given Device Name
A = hFILE A = hFILE
# MKFIFO # MKFIFO
int mkfifo(const char *pathname, mode_t mode);
return a hFILE to a new FIFO return a hFILE to a new FIFO
**In:** **In:**
**Out:** **Out:**
@ -587,7 +606,7 @@ Open a file
CC : A = hFILE CC : A = hFILE
CS : A = EC CS : A = EC
# FClose.A # FClose
Close a file Close a file
**In:** **In:**
A = hFILE A = hFILE
@ -618,7 +637,7 @@ Write bytes to file
# Out: # Out:
Y,A = Bytes Written Y,A = Bytes Written
# FFlush.A # FFlush
**In:** **In:**
A = hFILE A = hFILE
@ -629,7 +648,7 @@ Set the file-position indicator for hFILE
PUSHB = From PUSHB = From
PUSHB = hFILE PUSHB = hFILE
# FEOF.A # FEOF
Test the end-of-file indicator for hFILE Test the end-of-file indicator for hFILE
**In:** **In:**
A = hFILE A = hFILE
@ -647,7 +666,7 @@ Return the current value of the file-position indicator
**Out:** **Out:**
Offset = Offset Offset = Offset
# Remove.YA # Remove
# Rename # Rename
Rename a file Rename a file

View File

@ -27,20 +27,32 @@ CS.START cld
.DA #1 DRV Layout Version 1 .DA #1 DRV Layout Version 1
.DA 0 .DA 0
.DA CS.END-CS.START Code Length .DA CS.END-CS.START Code Length
.DA DEV.NODE-CS.START Device Node Offset .DA 0
.DA DRV.CS.START-CS.START Driver Code Offset .DA 0
.DA DRV.CS.END-DRV.CS.START Drv Code Length .DA 0
*-------------------------------------- *--------------------------------------
* Relocation Table * Relocation Table
*-------------------------------------- *--------------------------------------
L.MSG.DETECT .DA MSG.DETECT L.MSG.DETECT .DA MSG.DETECT
L.INSDRV .DA DRV.CS.START
.DA DRV.CS.END
.DA DRV.END
L.DEV.NODE .DA DEV.NODE
.DA 0 End Of Reloc Table .DA 0 End Of Reloc Table
*-------------------------------------- *--------------------------------------
Dev.Detect >LDYA L.MSG.DETECT Dev.Detect >LDYA L.MSG.DETECT
>SYSCALL printf >SYSCALL printf
clc >LDYA L.INSDRV
rts >SYSCALL InsDrv
bcs .9
>STYA DEV.NODE+S.NODE.DEV.DRVPTR
>LDYA L.DEV.NODE
>SYSCALL MKNOD
.9 rts
CS.END CS.END
MSG.DETECT .AZ "Apple IIe/IIc 80 Col Driver.\r\n" MSG.DETECT .AZ "Apple IIe/IIc 80 Col Driver.\r\n"
*-------------------------------------- *--------------------------------------
@ -894,6 +906,7 @@ DEVSTAT .DA #S.DSTAT.S.WRITE+S.DSTAT.S.READ
.DA #0 .DA #0
.DA #91 .DA #91
*-------------------------------------- *--------------------------------------
DRV.END
MAN MAN
SAVE /A2OSX.SRC/DRV/CONSOLE.DRV.S SAVE /A2OSX.SRC/DRV/CONSOLE.DRV.S
ASM ASM

View File

@ -166,7 +166,7 @@ SYS.StrFTime .EQ $96
SYS.LoadLib .EQ $98 SYS.LoadLib .EQ $98
SYS.UnloadLib .EQ $9A SYS.UnloadLib .EQ $9A
SYS.LoadDrv .EQ $9C SYS.LoadDrv .EQ $9C
SYS.FileSearch .EQ $9E SYS.InsDrv .EQ $9E
*-------------------------------------- *--------------------------------------
SYS.ExecPSNewEnv .EQ $A0 SYS.ExecPSNewEnv .EQ $A0
SYS.ExecPS .EQ $A2 SYS.ExecPS .EQ $A2
@ -180,7 +180,7 @@ SYS.GetPSStat .EQ $AE
* .EQ $B0 * .EQ $B0
SYS.GetArg .EQ $B2 SYS.GetArg .EQ $B2
SYS.ExpandStr .EQ $B4 SYS.ExpandStr .EQ $B4
* .EQ $B6 SYS.FileSearch .EQ $B6
SYS.PutEnv .EQ $B8 SYS.PutEnv .EQ $B8
SYS.SetEnv .EQ $BA SYS.SetEnv .EQ $BA

View File

@ -53,7 +53,7 @@ CS.INIT ldy #S.PS.ARGC
lda #1 get PTR to ARG[1] (Driver name) lda #1 get PTR to ARG[1] (Driver name)
>SYSCALL GetArg.A >SYSCALL GetArg.A
>SYSCALL LoadDrv.YA YA = PTR to ARG[1...n] >SYSCALL LoadDrv YA = PTR to ARG[1...n]
bcs .99 bcs .99
lda #0 success, but.... lda #0 success, but....

View File

@ -94,14 +94,11 @@ K.LoadDrv >STYA .2+1 Save "BIN\0ARGS\0\0"
adc .2+1 adc .2+1
tay tay
lda #0 lda #0
adc .2+2 adc .2+2 Y,A = ARGS
jsr .88 call Dev.Detect jsr .88 call Dev.Detect
bcs .96 bcs .96
jsr BIN.InsDrv
bcs .96
jsr .96 Cleanup... jsr .96 Cleanup...
lda #0 Make sure RC = 0 if success lda #0 Make sure RC = 0 if success
@ -131,113 +128,21 @@ BIN.FindDRV sec
.1 jsr K.GetEnv get value for Search Path .1 jsr K.GetEnv get value for Search Path
bcs .9 bcs .9
>PUSHYA >STYA K.FileSearch.SearchPath
>PUSHW BIN.CmdLine
jsr K.FileSearch.I find LIB/DRV in Search >LDYA BIN.CmdLine
jsr K.FileSearch.YA find LIB/DRV in Search
bcs .9 bcs .9
>LDYAI K.Buf256 >LDYAI K.Buf256
clc clc
.9 rts .9 rts
*/--------------------------------------
* # FileSearch
* Search a file in the provided PATH list
* And return, if found, the full path to it.
* ## C
* `int filesearch ( char * filename, char * searchpath, char * fullpath, stat * filestat);`
* ## ASM
* **In:**
* `>PUSHWI filestat`
* `>PUSHWI fullpath`
* `>PUSHWI searchpath`
* `>LDYAI filename`
* **Out:**
* CC : success
* DstBuf = FilePath
* DstStat = S.STAT
* CS : not found
*\--------------------------------------
K.FileSearch >PULLW .4+1 DstStat
>PULLW .2+1 DstBuf
jsr K.FileSearch.I
bcs .9
ldx #$ff
.1 inx
lda K.Buf256,x
.2 sta $ffff,x Self Modified
bne .1
ldx #S.STAT-1
.3 lda K.S.STAT,x
.4 sta $ffff,x Self Modified
dex
bpl .3
.9 rts
K.FileSearch.I >PULLW .4+1 Filename
>PULLYA Get Search list
jsr K.ExpandStr Expand it
bcs .99
stx .98+1
>STYA .2+1 expanded search list ;
stz .1+1
.1 ldy #$0 Self Modified Index in Search list string
ldx #$0
.2 lda $ffff,y Self Modified, Search list string
beq .3 end of string, try it....
iny
cmp #';'
beq .3
sta K.Buf256,x
inx
bra .2
.3 txa
beq .98 String is empty....nothing to try
sty .1+1 save current index
ldy #$0
.4 lda $ffff,y Self Modified, Append Filename...
sta K.Buf256,x
beq .5
iny
inx
bra .4
.5 >PUSHWI K.S.STAT
>PUSHWI K.Buf256
>SYSCALL STAT -> BNK1
bcs .1 Failed...retry next path...
lda K.S.STAT+S.STAT.P.TYPE
cmp #S.FI.T.DIR Dir ?
beq .1
jsr .98 Discard Expanded hSrch list
clc
.99 rts
.98 lda #$ff SELF MODIFIED : Discard Expanded hSrch list
jsr K.FreeMem
lda #MLI.E.FNOTFND
sec
rts
*-------------------------------------- *--------------------------------------
BIN.Find.ENV.DRV .AZ "DRV" BIN.Find.ENV.DRV .AZ "DRV"
BIN.Find.ENV.LIB .AZ "LIB" BIN.Find.ENV.LIB .AZ "LIB"
*-------------------------------------- *--------------------------------------
* BIN.Load.YA * BIN.Load
* in : * in :
* Y,A = /BIN/PATH (CSTR) * Y,A = /BIN/PATH (CSTR)
* out : * out :
@ -376,16 +281,17 @@ BIN.Load.1 >PUSHWI K.S.STAT
*-------------------------------------- *--------------------------------------
BIN.CmdLine .BS 2 BIN.CmdLine .BS 2
BIN.hMem .BS 1 BIN.hMem .BS 1
*-------------------------------------- */--------------------------------------
* BIN.InsDrv * #K.InsDrv
* In: * ##ASM
* pDrv = .DRV File Loaded Address * **In:**
* Y,A = .DRV File Loaded Address
* Note: * Note:
* BIN.Load.YA called from K.LoadDrvYA * BIN.Load called from K.LoadDrv
* Already setup correctly pDrv, * Already setup correctly pDrv,
* BIN.R.Start,End * BIN.R.Start,End
*-------------------------------------- *\--------------------------------------
BIN.InsDrv ldy #H.BIN.DRV.CODE.O K.InsDrv ldy #H.BIN.DRV.CODE.O
lda (pDrv),y lda (pDrv),y
clc clc
adc BIN.R.Start Advance start From AUXTYPE to AUXTYPE+DRV code offset adc BIN.R.Start Advance start From AUXTYPE to AUXTYPE+DRV code offset

View File

@ -122,6 +122,105 @@ K.ExpandStr stz .88+1 Reset Intermediate string...
.9 rts .9 rts
*/-------------------------------------- */--------------------------------------
* # FileSearch
* Search a file in the provided PATH list
* And return, if found, the full path to it.
* ## C
* `int filesearch ( char * filename, char * searchpath, char * fullpath, stat * filestat);`
* ## ASM
* **In:**
* `>PUSHWI filestat`
* `>PUSHWI fullpath`
* `>PUSHWI searchpath`
* `>LDYAI filename`
* **Out:**
* CC : success
* DstBuf = FilePath
* DstStat = S.STAT
* CS : not found
*\--------------------------------------
K.FileSearch pha
>PULLW K.FileSearch.SearchPath
>PULLW .2+1 DstBuf
>PULLW .4+1 DstStat
pla Y,A = filename
jsr K.FileSearch.YA
bcs .9
ldx #$ff
.1 inx
lda K.Buf256,x
.2 sta $ffff,x Self Modified
bne .1
ldx #S.STAT-1
.3 lda K.S.STAT,x
.4 sta $ffff,x Self Modified
dex
bpl .3
.9 rts
K.FileSearch.YA jsr K.ExpandStr Y,A = Search Path, Expand it
bcs .99
stx .98+1
>STYA .2+1 expanded search list ;
stz .1+1
.1 ldy #$0 Self Modified Index in Search list string
ldx #$0
.2 lda $ffff,y Self Modified, Search list string
beq .3 end of string, try it....
iny
cmp #';'
beq .3
sta K.Buf256,x
inx
bra .2
.3 txa
beq .98 String is empty....nothing to try
sty .1+1 save current index
ldy #$0
.4 lda $ffff,y Self Modified, Append Filename...
sta K.Buf256,x
beq .5
iny
inx
bra .4
.5 >PUSHWI K.S.STAT
>PUSHWI K.Buf256
>SYSCALL STAT -> BNK1
bcs .1 Failed...retry next path...
lda K.S.STAT+S.STAT.P.TYPE
cmp #S.FI.T.DIR Dir ?
beq .1
jsr .98 Discard Expanded hSrch list
clc
.99 rts
.98 lda #$ff SELF MODIFIED : Discard Expanded hSrch list
jsr K.FreeMem
lda #MLI.E.FNOTFND
sec
rts
*--------------------------------------
K.FileSearch.SearchPath .BS 2
*/--------------------------------------
* # PutEnv * # PutEnv
* **In:** * **In:**
* Y,A = PTR to String NAME=VALUE (C-String) * Y,A = PTR to String NAME=VALUE (C-String)

View File

@ -96,7 +96,7 @@ K.SYSCALL.JMP .DA 0 $00
.DA K.LoadLib .DA K.LoadLib
.DA K.UnloadLib .DA K.UnloadLib
.DA K.LoadDrv .DA K.LoadDrv
.DA K.FileSearch .DA K.InsDrv
.DA K.ExecPSNewEnv $A0 .DA K.ExecPSNewEnv $A0
.DA K.ExecPS .DA K.ExecPS
@ -110,7 +110,7 @@ K.SYSCALL.JMP .DA 0 $00
.DA 0 $B0 .DA 0 $B0
.DA K.GetArg .DA K.GetArg
.DA K.ExpandStr .DA K.ExpandStr
.DA 0 .DA K.FileSearch
.DA K.PutEnv .DA K.PutEnv
.DA K.SetEnv .DA K.SetEnv
.DA K.GetEnv .DA K.GetEnv

View File

@ -113,6 +113,7 @@ K.MKDir jsr PFT.CheckPathYA
rts rts
*/-------------------------------------- */--------------------------------------
* # MkNod * # MkNod
* int mknod(const char *pathname, mode_t mode, dev_t dev);
* return a hFile for a given Device Name * return a hFile for a given Device Name
* **In:** * **In:**
* Y,A=DevName * Y,A=DevName
@ -166,6 +167,7 @@ K.MkNod jsr K.GetDevByName Ptr1=NAME
rts rts
*/-------------------------------------- */--------------------------------------
* # MKFIFO * # MKFIFO
* int mkfifo(const char *pathname, mode_t mode);
* return a hFILE to a new FIFO * return a hFILE to a new FIFO
* **In:** * **In:**
* **Out:** * **Out:**