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]
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
Search a file in the provided PATH list
And return, if found, the full path to it.
@ -29,76 +115,7 @@ DstBuf = FilePath
DstStat = S.STAT
CS : not found
# GetDevByID.A
**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
# PutEnv
**In:**
Y,A = PTR to String NAME=VALUE (C-String)
**Out:**
@ -109,19 +126,19 @@ note: X Unmodified
PUSHW = PTR To Name (PSTR)
**Out:**
# GetEnv.YA
# GetEnv
**In:**
Y,A = PTR to NAME (PSTR)
**Out:**
CC : Y,A = PTR to VALUE (PSTR)
CS : not found
# UnsetEnv.YA
# UnsetEnv
**In:**
Y,A = PTR To Name (PSTR)
**Out:**
# LoadTxtFile.YA
# LoadTxtFile
Load TXT a file in memory (with ending 0)
**In:**
Y,A = File Path
@ -352,31 +369,31 @@ Load a file in AUX memory (Stock Objects)
Y,A = File Length
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:**
Y,A = PTR To Cmd Line
**Out:**
A = Child PSID
# GetMemStat.YA
# GetMemStat
**In:**
Y,A = Ptr to 24 bytes buffer
**Out:**
Buffer filled with memory stats
# GetPSStatus.A
# GetPSStatus
**In:**
A = PID
**Out:**
A = Status Byte
# GetPSStat.YA
# GetPSStat
**In:**
Y,A = Ptr to 24 bytes buffer
**Out:**
@ -389,7 +406,7 @@ Return information about a file
PUSHW = PTR to Filename (C-String)
**Out:**
# MKDir.YA
# MKDir
**In:**
Y,A = DIR name
**Out:**
@ -397,7 +414,8 @@ Return information about a file
CS : error
A = EC
# MkNod.YA
# MkNod
int mknod(const char *pathname, mode_t mode, dev_t dev);
return a hFile for a given Device Name
**In:**
Y,A=DevName
@ -406,6 +424,7 @@ return a hFile for a given Device Name
A = hFILE
# MKFIFO
int mkfifo(const char *pathname, mode_t mode);
return a hFILE to a new FIFO
**In:**
**Out:**
@ -587,7 +606,7 @@ Open a file
CC : A = hFILE
CS : A = EC
# FClose.A
# FClose
Close a file
**In:**
A = hFILE
@ -618,7 +637,7 @@ Write bytes to file
# Out:
Y,A = Bytes Written
# FFlush.A
# FFlush
**In:**
A = hFILE
@ -629,7 +648,7 @@ Set the file-position indicator for hFILE
PUSHB = From
PUSHB = hFILE
# FEOF.A
# FEOF
Test the end-of-file indicator for hFILE
**In:**
A = hFILE
@ -647,7 +666,7 @@ Return the current value of the file-position indicator
**Out:**
Offset = Offset
# Remove.YA
# Remove
# Rename
Rename a file

View File

@ -27,20 +27,32 @@ CS.START cld
.DA #1 DRV Layout Version 1
.DA 0
.DA CS.END-CS.START Code Length
.DA DEV.NODE-CS.START Device Node Offset
.DA DRV.CS.START-CS.START Driver Code Offset
.DA DRV.CS.END-DRV.CS.START Drv Code Length
.DA 0
.DA 0
.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
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
*--------------------------------------
Dev.Detect >LDYA L.MSG.DETECT
>SYSCALL printf
clc
rts
>LDYA L.INSDRV
>SYSCALL InsDrv
bcs .9
>STYA DEV.NODE+S.NODE.DEV.DRVPTR
>LDYA L.DEV.NODE
>SYSCALL MKNOD
.9 rts
CS.END
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 #91
*--------------------------------------
DRV.END
MAN
SAVE /A2OSX.SRC/DRV/CONSOLE.DRV.S
ASM

View File

@ -166,7 +166,7 @@ SYS.StrFTime .EQ $96
SYS.LoadLib .EQ $98
SYS.UnloadLib .EQ $9A
SYS.LoadDrv .EQ $9C
SYS.FileSearch .EQ $9E
SYS.InsDrv .EQ $9E
*--------------------------------------
SYS.ExecPSNewEnv .EQ $A0
SYS.ExecPS .EQ $A2
@ -180,7 +180,7 @@ SYS.GetPSStat .EQ $AE
* .EQ $B0
SYS.GetArg .EQ $B2
SYS.ExpandStr .EQ $B4
* .EQ $B6
SYS.FileSearch .EQ $B6
SYS.PutEnv .EQ $B8
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)
>SYSCALL GetArg.A
>SYSCALL LoadDrv.YA YA = PTR to ARG[1...n]
>SYSCALL LoadDrv YA = PTR to ARG[1...n]
bcs .99
lda #0 success, but....

View File

@ -94,14 +94,11 @@ K.LoadDrv >STYA .2+1 Save "BIN\0ARGS\0\0"
adc .2+1
tay
lda #0
adc .2+2
adc .2+2 Y,A = ARGS
jsr .88 call Dev.Detect
bcs .96
jsr BIN.InsDrv
bcs .96
jsr .96 Cleanup...
lda #0 Make sure RC = 0 if success
@ -131,113 +128,21 @@ BIN.FindDRV sec
.1 jsr K.GetEnv get value for Search Path
bcs .9
>PUSHYA
>PUSHW BIN.CmdLine
jsr K.FileSearch.I find LIB/DRV in Search
>STYA K.FileSearch.SearchPath
>LDYA BIN.CmdLine
jsr K.FileSearch.YA find LIB/DRV in Search
bcs .9
>LDYAI K.Buf256
clc
.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.LIB .AZ "LIB"
*--------------------------------------
* BIN.Load.YA
* BIN.Load
* in :
* Y,A = /BIN/PATH (CSTR)
* out :
@ -376,16 +281,17 @@ BIN.Load.1 >PUSHWI K.S.STAT
*--------------------------------------
BIN.CmdLine .BS 2
BIN.hMem .BS 1
*--------------------------------------
* BIN.InsDrv
* In:
* pDrv = .DRV File Loaded Address
*/--------------------------------------
* #K.InsDrv
* ##ASM
* **In:**
* Y,A = .DRV File Loaded Address
* Note:
* BIN.Load.YA called from K.LoadDrvYA
* BIN.Load called from K.LoadDrv
* Already setup correctly pDrv,
* BIN.R.Start,End
*--------------------------------------
BIN.InsDrv ldy #H.BIN.DRV.CODE.O
*\--------------------------------------
K.InsDrv ldy #H.BIN.DRV.CODE.O
lda (pDrv),y
clc
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
*/--------------------------------------
* # 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
* **In:**
* 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.UnloadLib
.DA K.LoadDrv
.DA K.FileSearch
.DA K.InsDrv
.DA K.ExecPSNewEnv $A0
.DA K.ExecPS
@ -110,7 +110,7 @@ K.SYSCALL.JMP .DA 0 $00
.DA 0 $B0
.DA K.GetArg
.DA K.ExpandStr
.DA 0
.DA K.FileSearch
.DA K.PutEnv
.DA K.SetEnv
.DA K.GetEnv

View File

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