Kernel 0.9.2

This commit is contained in:
Rémy GIBERT 2018-07-17 17:45:59 +02:00
parent 545cd148d0
commit a2d0b52982
13 changed files with 199 additions and 154 deletions

View File

@ -18,15 +18,19 @@ CS : Out Of Bound
**Out:**
none
#K.InsDrv
#InsDrv
##C
`void * insdrv (void * src, void * crvcsstart, void * drvcsend, void * drvend);`
##ASM
**In:**
Y,A = .DRV File Loaded Address
Note:
BIN.Load called from K.LoadDrv
Already setup correctly pDrv,
BIN.R.Start,End
>PUSHW DRV.END
>PUSHW DRV.CS.END
>PUSHW DRV.CS.START
>LDYA L.SRC
**Out:**
Y,A = Ptr to installed driver
# GetDevByID
**In:**
@ -41,7 +45,7 @@ Y,A = DEVSLOT
**Out:**
CC = OK, CS = ERROR
X = DEVID
Y,A = DEVSLOT
Y,A = FD
# GetDevStatus
**In:**
@ -49,19 +53,11 @@ Y,A = DEVSLOT
**Out:**
Y,A = S.DSTAT
# IOCTL
## C
`int ioctl ( short int id, short int op, void *param);`
## ASM
# MKDev
**In:**
`PUSHWI param`
`lda #op`
`ldy id`
`>SYSCALL IOCTL`
Y,A = Ptr to FD.DEV
**Out:**
Y,A = ...
A = DEVID
# OpenDir
**In:**
@ -177,6 +173,42 @@ Load a file in memory
PUSHW = GID
PUSHW = PATH
# open
## C
`int open(const char *pathname, int flags);`
## ASM
**In:**
`>PUSHB flags`
`>LDYA pathname`
`>SYSCALL open`
**Out:**
A = hFD
note : if file is created on ProDOS : T=TXT,X=$0000
# IOCTL
## C
`int ioctl(int fd, unsigned long request, void * param );`
## ASM
**In:**
`PUSHWI param`
`lda #request`
`ldy fd`
`>SYSCALL IOCTL`
**Out:**
Y,A = ...
# pipe
## C
`int pipe(int pipefd[2]);`
## ASM
**In:**
# FAdd,FSub,FMult,FDiv,FPwr
Return X+Y, X-Y, X*Y, X/Y, X^Y
@ -601,6 +633,15 @@ Open a file
+ SYS.FOpen.A : Append
+ SYS.FOpen.T : Open/Append in Text mode
+ SYS.FOpen.X : Create if not exists
http://man7.org/linux/man-pages/man3/fopen.3.html
r = O_RDONLY
w = O_WRONLY | O_CREAT | O_TRUNC
a = O_WRONLY | O_CREAT | O_APPEND
r+ = O_RDWR
w+ = O_RDWR | O_CREAT | O_TRUNC
a+ = O_RDWR | O_CREAT | O_APPEND
*
TODO: mode="w+t=TYP,x=AUXTYPE"
`>LDYAI filename`
**Out:**
CC : A = hFILE
@ -608,6 +649,11 @@ Open a file
# FClose
Close a file
## C
int fclose ( FILE * stream );
## ASM
**In:**
A = hFILE
**Out:**

Binary file not shown.

Binary file not shown.

View File

@ -26,31 +26,30 @@ CS.START cld
* Relocation Table
*--------------------------------------
L.MSG.DETECT .DA MSG.DETECT
L.INSDRV .DA DRV.CS.START
.DA DRV.CS.END
.DA DRV.END
L.NODE .DA NODE
L.DRV.CS.START .DA DRV.CS.START
L.FD.DEV .DA FD.DEV
.DA 0 End Of Reloc Table
*--------------------------------------
Dev.Detect >LDYA L.MSG.DETECT
>SYSCALL printf
>PUSHW L.INSDRV+4
>PUSHW L.INSDRV+2
>LDYA L.INSDRV
>PUSHWI DRV.END
>PUSHWI DRV.CS.END
>PUSHWI DRV.CS.START
>LDYA L.DRV.CS.START
>SYSCALL InsDrv
bcs .9
>STYA NODE+S.FD.DEV.DRVPTR
>STYA FD.DEV+S.FD.DEV.DRVPTR
>LDYA L.NODE
>SYSCALL MKNOD
>LDYA L.FD.DEV
>SYSCALL MKDEV
.9 rts
CS.END
MSG.DETECT .AZ "Apple IIe/IIc 80 Col Driver.\r\n"
*--------------------------------------
NODE .DA #S.FD.T.CDEV
FD.DEV .DA #S.FD.T.CDEV
.DA #0 HANDLER
.DA #0 BUSID
.DA #0 DEVID

View File

@ -124,7 +124,7 @@ SYS.Rename .EQ $42
SYS.GetDevByID .EQ $48
SYS.GetDevByName .EQ $4A
SYS.GetDevStatus .EQ $4C
* .EQ $4E
SYS.MKDev .EQ $4E
* .EQ $50
SYS.SScanF .EQ $52

View File

@ -167,7 +167,7 @@ H.BIN.ZP.SIZE .EQ 13
*
H.BIN.EXE.REL.TABLE .EQ 16
*
H.BIN.DRV.REL.TABLE .EQ 4
H.BIN.DRV.REL.TABLE .EQ 2 Including main jmp
*--------------------------------------
MAN
SAVE /A2OSX.BUILD/INC/KERNEL.I

View File

@ -42,10 +42,12 @@ CS.INIT ldy #S.PS.ARGC
cmp #2
bne .90
lda #1
>SYSCALL GetArg
>PUSHBI 0
>SYSCALL MkNod
lda #1
>SYSCALL GetArg get /dev/xxx
>SYSCALL open
bcs .9
ldy #S.PS.hStdIn
@ -55,7 +57,7 @@ CS.INIT ldy #S.PS.ARGC
iny #S.PS.hStdErr
sta (pPs),y
>STA.G hNode
>STA.G hDEV
lda #2
>SYSCALL GetArg
@ -220,7 +222,7 @@ CS.QUIT >LDA.G hBinName
beq .1
>SYSCALL FreeMem
.1 >LDA.G hNode
.1 >LDA.G hDEV
beq .8
>PUSHA
@ -267,7 +269,7 @@ IAC.SB.DATA .BS 64
IAC.VERB .BS 1
IAC.OPT .BS 1
IAC.SB .BS 1
hNode .BS 1
hDEV .BS 1
hBinName .BS 1
TimeOut .BS 1
DS.END .ED

View File

@ -280,34 +280,39 @@ BIN.Load.1 >PUSHWI K.S.STAT
BIN.CmdLine .BS 2
BIN.hMem .BS 1
*/--------------------------------------
* #K.InsDrv
* #InsDrv
* ##C
* `void * insdrv (void * src, void * crvcsstart, void * drvcsend, void * drvend);`
* ##ASM
* **In:**
* PUSHW = DRV.END
* PUSHW = DRV.CS.END
* Y,A = DRV.CS.START
* >PUSHW DRV.END
* >PUSHW DRV.CS.END
* >PUSHW DRV.CS.START
* >LDYA L.SRC
* **Out:**
* Y,A = Ptr to installed driver
*\--------------------------------------
K.InsDrv >STYA BIN.R.CS.Start
K.InsDrv >STYA ZPPtr1
>PULLW BIN.R.CS.Start
>PULLW BIN.R.CS.End
>PULLW BIN.R.End
lda BIN.R.End Compute DRVLen=End-start
sec
sbc BIN.R.CS.Start
sta BIN.R.Len
sta BIN.Move.Len
lda BIN.R.End+1
sbc BIN.R.CS.Start+1
sta BIN.R.Len+1
sta BIN.Move.Len+1
lda DevMgr.Free Compute new DevMgr.Free
clc
adc BIN.R.Len
sta BIN.R.End
adc BIN.Move.Len
tay Save DRVEnd LO
lda DevMgr.Free+1
adc BIN.R.Len+1 A = DRVEnd HI
sta BIN.R.End+1
adc BIN.Move.Len+1 A = DRVEnd HI
bcs .9 we crossed $FFFF, out of mem
@ -315,67 +320,48 @@ K.InsDrv >STYA BIN.R.CS.Start
sbc /DevMgr.HiMem
bcs .9 No More Room to load Driver....
lda DevMgr.DevCnt
cmp #K.DEV.MAX
bne .10 No Device Handle Left
>LDYA DevMgr.Free
jsr BIN.MoveToYA
lda #K.E.OOH
sec
rts
.9 lda #K.E.OOM
sec
rts
.10 lda DevMgr.Free Offset = Target DRV address-Src Address
lda DevMgr.Free
sta ZPPtr1
sec
sbc BIN.R.CS.Start
sta BIN.R.Offset
lda DevMgr.Free+1
sta ZPPtr1+1
sbc BIN.R.CS.Start+1
sta BIN.R.Offset+1
jsr BIN.Move
>LDYA BIN.R.CS.Start
>STYA ZPPtr1
jsr BIN.RelDrv
>LDYA BIN.R.End
>STYA DevMgr.Free
ldx DevMgr.DevCnt
lda DevMgr.Free
sta FD.Table.PTRLO,x
inx
tay
clc
adc BIN.Move.Len
sta DevMgr.Free
lda DevMgr.Free+1
sta FD.Table.PTRHI,x
inx
stx DevMgr.DevCnt
pha
adc BIN.Move.Len+1
sta DevMgr.Free+1
pla
clc
rts
*--------------------------------------
BIN.Move lda BIN.R.CS.Start
clc
sta ZPPtr1
adc BIN.R.Offset
sta BIN.R.CS.Start
sta ZPPtr2
lda BIN.R.CS.Start+1
sta ZPPtr1+1
adc BIN.R.Offset+1
sta BIN.R.CS.Start+1
sta ZPPtr2+1
lda BIN.R.Len+1
.9 lda #K.E.OOM
sec
rts
*--------------------------------------
BIN.Move.Len .BS 2
*--------------------------------------
BIN.MoveToYA >STYA ZPPtr2
lda BIN.Move.Len+1
eor #$ff
pha
lda BIN.R.Len
lda BIN.Move.Len
eor #$ff
tax
@ -397,24 +383,7 @@ BIN.Move lda BIN.R.CS.Start
inc ZPPtr2+1
bra .1
.3 lda BIN.R.CS.End
clc
adc BIN.R.Offset
sta BIN.R.CS.End
lda BIN.R.CS.End+1
adc BIN.R.Offset+1
sta BIN.R.CS.End+1
lda BIN.R.End
clc
adc BIN.R.Offset
sta BIN.R.End
lda BIN.R.End+1
adc BIN.R.Offset+1
sta BIN.R.End+1
rts
.3 rts
*--------------------------------------
* BIN.Rel___ :
*--------------------------------------
@ -423,8 +392,6 @@ BIN.R.CS.End .BS 2
BIN.R.End .BS 2
BIN.R.Offset .BS 2
*--------------------------------------
BIN.R.Len .BS 2
*--------------------------------------
BIN.RelExe ldy #H.BIN.T+1
lda (ZPPtr1),y
cmp /H.BIN.T.BIN65
@ -452,7 +419,7 @@ BIN.RelExe ldy #H.BIN.T+1
.HS 2C bit abs
*--------------------------------------
BIN.RelDrv ldy #H.BIN.DRV.REL.TABLE
.1 lda (ZPPtr1),y Start Relocate JMP table
tax LO in X
iny
@ -501,31 +468,31 @@ BIN.RelDrv ldy #H.BIN.DRV.REL.TABLE
pha
ldy #1
lda (ZPPtr1),y Get LO
lda (ZPPtr1),y Get LO
tax save LO in X
iny make Y point to HI
lda (ZPPtr1),y Get HI
cpx BIN.R.CS.Start
lda (ZPPtr1),y Get HI
sbc BIN.R.CS.Start+1
bcc .5 addr < BIN.R.CS.Start, out of range
txa Get back LO
cpx BIN.R.End
lda (ZPPtr1),y Get HI
lda (ZPPtr1),y Get HI
sbc BIN.R.End+1
bcs .5 addr > BIN.R.End, out of range
txa Get back LO
* clc CC from bcs .6
adc BIN.R.Offset add Offset to abs address
adc BIN.R.Offset add Offset to abs address
dey
sta (ZPPtr1),y store relocated addr LO
sta (ZPPtr1),y store relocated addr LO
iny
lda (ZPPtr1),y Get HI
lda (ZPPtr1),y Get HI
adc BIN.R.Offset+1
sta (ZPPtr1),y store relocated addr HI
sta (ZPPtr1),y store relocated addr HI
.5 pla get back Opcode length...

View File

@ -385,6 +385,8 @@ CORE.ScrSel and #$0F
lda A2osX.SCRNDEVS-1,x
beq .8 No device claimed this screen
>DEBUG
jsr K.GetDevByID x unmodified.....
bcs .8 ???

View File

@ -83,6 +83,46 @@ K.GetDevStatus ldx #IOCTL.STATUS
>STYA pFD
jmp (pFD)
*/--------------------------------------
* # MKDev
* **In:**
* Y,A = Ptr to FD.DEV
* **Out:**
* A = DEVID
*\--------------------------------------
K.MKDev >STYA .1+1
ldx DevMgr.DevCnt
cmp #K.DEV.MAX
beq .9
>LDYAI S.FD.DEV
jsr K.GetMem
>STYA .2+1
phx
ldx DevMgr.DevCnt
sta FD.Table.PTRHI,x
tya
sta FD.Table.PTRLO,x
pla
sta FD.Table.hMem,x
.10 lda #$ff SELF MODIFIED
sta FD.Table.F,x
ldx #S.FD.DEV-1
.1 lda $ffff,x SELF MODIFIED
.2 sta $ffff,x SELF MODIFIED
dex
bpl .1
inc DevMgr.DevCnt
rts
.9 lda #K.E.OOH
* sec
rts
*--------------------------------------
MAN
SAVE /A2OSX.SRC/SYS/KERNEL.S.DEV

View File

@ -106,10 +106,10 @@ Kernel.Init3 sta SETALTZP
jsr MemMgrInit
>LDYAI FD.NULL
jsr DevMgrInit.AddCDev
>SYSCALL MKDev
>LDYAI FD.SYS
jsr DevMgrInit.AddCDev
>SYSCALL MKDev
jsr PS0.Init
@ -138,12 +138,24 @@ Kernel.Init3 sta SETALTZP
>LDYAI MSG.Prefix
>SYSCALL printf
>PUSHWI STARTUP.CMDLINE
lda KBD
bpl .1
sta KBDSTROBE
cmp #$84 CTRL-D for Maintenace mode
bne .1
>LDYAI MSG.MMode
>SYSCALL printf
>LDYAI STARTUP.SHELL
bra .8
.1 >PUSHWI STARTUP.CMDLINE
>LDYAI MSG.Startup
>SYSCALL printf
>LDYAI STARTUP.CMDLINE
>SYSCALL ExpandStr
.8 >SYSCALL ExpandStr
phx Save Expanded CMDLINE for discard
>SYSCALL CreatePS
@ -862,33 +874,7 @@ DevMgrInit.AddBDev
>LDYAI FD.BDEV
DevMgrInit.AddCDev
>STYA .1+1
stx .10+1
>LDYAI S.FD.DEV
jsr K.GetMem
>STYA .2+1
phx
ldx DevMgr.DevCnt
sta FD.Table.PTRHI,x
tya
sta FD.Table.PTRLO,x
pla
sta FD.Table.hMem,x
.10 lda #$ff SELF MODIFIED
sta FD.Table.F,x
ldx #S.FD.DEV-1
.1 lda $ffff,x SELF MODIFIED
.2 sta $ffff,x SELF MODIFIED
dex
bpl .1
inc DevMgr.DevCnt
>SYSCALL MKDev
rts
*--------------------------------------
EvtMgrInit >LDYAI MSG.EVT
@ -1006,7 +992,7 @@ MSG.KCREAD.OK .AZ "OK\n"
MSG.KCREAD.KO .AZ "\nError While Reading Kernel Config File, Using Default.\n"
MSG.Init2.OK .AZ "A2osX[Stage2]:Complete.\n"
*--------------------------------------
MSG.Init3 .AZ "A2osX[Stage3]:Init\r\n"
MSG.Init3 .AZ "A2osX[Stage3]:Init\r\nPress Ctrl-D for Mantenance Mode."
MSG.DEV .AZ "-Device Manager...\r\n"
MSG.BLKDEV .AZ " /DEV/%s\r\n"
MSG.IRQ .AZ "-Interrupt Manager..."
@ -1017,6 +1003,7 @@ MSG.EVT .AZ "-Event Manager...\r\n"
MSG.FLT .AZ "-Path Filter...\r\n"
MSG.TSK .AZ "-Task Manager...\r\n"
MSG.Prefix .AZ "Prefix:%s\r\n"
MSG.MMode .AZ "Ctrl-D Pressed, entering Maintenance mode...\r\n"
MSG.Startup .AZ "Executing Kernel Startup Script...\r\nCmd:%s\r\n"
MSG.StartupErr .AZ "Failed : [$%h]\r\n"
MSG.Init3.OK .AZ "A2osX[Stage3]:Complete.\r\n"
@ -1041,6 +1028,7 @@ I.ENV.A2osX .AZ "A2OSX"
I.ENV.PATH .AZ "PATH=${A2OSX}SBIN/;${A2OSX}BIN/"
I.ENV.LIB .AZ "LIB=${A2OSX}LIB/"
I.ENV.DRV .AZ "DRV=${A2OSX}DRV/"
STARTUP.SHELL .AZ "${A2OSX}SBIN/SHELL"
STARTUP.CMDLINE .AZ "${A2OSX}SBIN/SHELL ${A2OSX}A2osX.STARTUP"
*--------------------------------------
MLIOPEN00 .DA #3

View File

@ -45,6 +45,7 @@ K.Open.DEV ldy #K.MLI.PATH+6 skip L/DEV/
sta .1+2
>PULLA get flags
lda .8+1 pass A=DEVID To Driver
ldx #IOCTL.OPEN
.1 jsr $ffff SELF MODIFIED
bcs .99

View File

@ -49,7 +49,7 @@ K.SYSCALL.JMP .DA 0 $00
.DA K.GetDevByID
.DA K.GetDevByName
.DA K.GetDevStatus
.DA K.IOCTL
.DA K.MKDev
.DA 0 $50
.DA K.SScanF