Kernel 0.92

This commit is contained in:
Rémy GIBERT 2018-12-21 15:32:45 +01:00
parent 0c79cdb036
commit 3c534a25fd
20 changed files with 210 additions and 197 deletions

Binary file not shown.

View File

@ -215,8 +215,17 @@ Remove an environment variable
# LoadTxtFile
Load TXT a file in memory (with ending 0)
## C
`int loadtxtfile ( const char * filename, short int flags, short int ftype, int auxtype );`
## ASM
**In:**
Y,A = File Path
`>PUSHW auxtype`
`>PUSHB ftype`
`>PUSHB flags`
`>LDYA filename`
`>SYSCALL loadtxtfile`
## RETURN VALUE
Y,A = File Length (without ending 0)
@ -224,11 +233,17 @@ Load TXT a file in memory (with ending 0)
# LoadFile
Load a file in memory
## C
`int loadfile ( const char * filename, short int flags, short int ftype, int auxtype );`
## ASM
**In:**
PUSHW = AUXTYPE (Handled by....
PUSHB = TYPE ...
PUSHB = MODE ...
LDYA = PATH ...FOpen)
`>PUSHW auxtype`
`>PUSHB ftype`
`>PUSHB flags`
`>LDYA filename`
`>SYSCALL loadfile`
## RETURN VALUE
Y,A = File Length

Binary file not shown.

View File

@ -8,6 +8,7 @@ AUTO 4,1
*--------------------------------------
.INB INC/MACROS.I
.INB INC/A2OSX.I
.INB INC/MLI.I
.INB INC/MLI.E.I
.INB INC/ETH.I
.INB INC/LIBTCPIP.I
@ -167,7 +168,12 @@ CS.RUN.HOSTOK >INC.G ArgIndex
>INC.G ArgIndex
>SYSCALL ArgV
bcs CS.RUN.RTS
pha
>PUSHWI 0 Aux type
>PUSHBI S.FI.T.TXT
>PUSHBI O.RDONLY
pla
>SYSCALL LoadTxtFile
bcs .9

View File

@ -132,5 +132,5 @@ DS.END
.ED
*--------------------------------------
MAN
SAVE USR/SRC/BIN/BIN/MEM.S
SAVE USR/SRC/BIN/MEM.S
ASM

View File

@ -181,6 +181,9 @@ CS.RUN jsr CMD.Init
lda (pPS),y
beq .1 no arg, continue starting interactive
>PUSHWI 0 Aux type
>PUSHBI S.FI.T.TXT
>PUSHBI O.RDONLY
lda #1
>SYSCALL ArgV
>SYSCALL LoadTxtFile
@ -381,6 +384,7 @@ CS.RUN.BATCH >SYSCALL GetChar
>PUSHBI 2
>LDYA L.MSG.TRACE
>SYSCALL printf
bcs .9
*--------------------------------------
CS.RUN.Exec jsr CL.Parse
@ -551,7 +555,7 @@ CS.END
*--------------------------------------
MSG.GREETINGS .AZ "\r\nA2osX-Shell %d.%d\r\n\r\n"
MSG.PROMPT .AZ "\e[7h$ "
MSG.TRACE .AS ">%s"
MSG.TRACE .AZ ">%s\r\n"
MSG.BATCHERR .AZ "^\r\nLine #%D:"
MSG.ERROR .AS "[$%h]:%S."
MSG.ECHOCRLF .AZ "\r\n"

View File

@ -7,11 +7,11 @@ K.ENV.SIZE .EQ 256
K.PIPE.SIZE .EQ 256
*--------------------------------------
K.IRQDEV.MAX .EQ 4
K.DEV.MAX .EQ 32
K.DEV.MAX .EQ 28
K.FLT.MAX .EQ 4
K.NOD.MAX .EQ 32
K.PS.MAX .EQ 32
K.OF.MAX .EQ 32
K.FLT.MAX .EQ 4
K.EVT.MAX .EQ 4
K.SCR.MAX .EQ 6
K.TTY.MAX .EQ 4
@ -228,7 +228,7 @@ SYS.ExecV .EQ $A2
SYS.Kill .EQ $A6
* .EQ $A8
SYS.GetMemStat .EQ $AA
* .EQ $AA
* .EQ $AC
* .EQ $AE
@ -269,7 +269,7 @@ SYS.GetMemByID .EQ $E6
SYS.GetMem .EQ $E8
SYS.GetMem0 .EQ $EA
* .EQ $EC
SYS.GetMemStat .EQ $EC
SYS.SListAdd .EQ $EE
SYS.SListLookup .EQ $F0
@ -554,12 +554,6 @@ S.TIME.WDAY .EQ 7 1..7
*
S.TIME .EQ 8
*--------------------------------------
S.PFT.PATH .EQ 0 /dev, /mnt
S.PFT.HANDLER .EQ 16
S.PFT.DATA .EQ 24 8 bytes OPAQUE data for handler
*
S.PFT .EQ 32
*--------------------------------------
* S.STAT
*--------------------------------------
S.STAT.MODE .EQ 0

View File

@ -4,7 +4,10 @@ AUTO 4,1
.LIST OFF
*--------------------------------------
Dev.Table.hPath .EQ $1300 K.Dev.MAX
Dev.Table.hFD .EQ $1320 K.Dev.MAX
Dev.Table.hFD .EQ $131C K.Dev.MAX
*--------------------------------------
Flt.Table.hPath .EQ $1338 K.FLT.MAX
Flt.Table.hLib .EQ $133C K.FLT.MAX
*--------------------------------------
Nod.Table.hPath .EQ $1340 K.NOD.MAX
Nod.Table.hFD .EQ $1360 K.NOD.MAX
@ -17,11 +20,7 @@ PS.Table.Stats .EQ $13E0 K.PS.MAX
OF.Table.hPath .EQ $1400 K.OF.MAX
OF.Table.hFD .EQ $1420 K.OF.MAX
*--------------------------------------
Evt.Table .EQ $1440 K.EVT.MAX*S.EVT=4*8=32b
*--------------------------------------
Flt.Table .EQ $1460 K.FLT.MAX*S.FLT=4*32=128b
*--------------------------------------
A2osX.EndTables .EQ $1440
*--------------------------------------
MAN
SAVE INC/KERNEL.I

View File

@ -29,7 +29,7 @@ CS.START cld
.DA #0
.DA CS.END-CS.START Code Size (without Constants)
.DA DS.END-DS.START Data SegmentSize
.DA #32 Stack Size
.DA #16 Stack Size
.DA #ZS.END-ZS.START Zero Page Size
.DA 0
*--------------------------------------

View File

@ -84,7 +84,7 @@ A2osX.SaveSX .EQ $101 Aux
* Aux $3FE -> 3FF : IRQ Vector
*--------------------------------------
K.S.STAT .EQ $0300 S.STAT for internal kernel operations
*K.S.DIB .EQ $0340 S.DIB=25 or higher depends on dev type
Evt.Table .EQ $0340 K.EVT.MAX*S.EVT=4*8=32b
K.S.IOCTL .EQ $0360 9 bytes
K.MLI.PATH .EQ $0369 64+1
K.MLI.PARAMS .EQ $03AA Main, 18 bytes min for GetFileInfo (ATLK needs MORE!!!...32 max for now)
@ -163,11 +163,11 @@ S.DCB.TTY.bTITLE .EQ 10
S.DCB.TTY.OUTTAIL .EQ 14
S.DCB.TTY.OUTHEAD .EQ 15
S.DCB.TTY.INBUFFER .EQ 16
S.DCB.TTY.INBUFFER.MAX .EQ 40
S.DCB.TTY.OUTBUFFER .EQ 40
S.DCB.TTY.OUTBUFFER.MAX .EQ 64
S.DCB.TTY.INBUFFER.MAX .EQ 32
S.DCB.TTY.OUTBUFFER .EQ 32
S.DCB.TTY.OUTBUFFER.MAX .EQ 48
*
S.DCB.TTY .EQ 64
S.DCB.TTY .EQ 48
*--------------------------------------
MAN
SAVE USR/SRC/SYS/KERNEL.S.DEF

View File

@ -8,13 +8,12 @@ AUTO 4,1
*--------------------------------------
DRV.DiskII cld
cpx #IOCTL.FORMAT
bcs .9
bcs DRV.RamDrive.9
>STYA pIOCTL
jmp (.1,x)
.1 .DA DRV.DiskII.STATUS
.DA DRV.BLK READ
.DA DRV.BLK WRITE
.9 jmp A2osX.BadCall
*--------------------------------------
DRV.DiskII.STATUS
>LDYAI DRV.DiskII.DIB
@ -35,14 +34,14 @@ DRV.DiskII.DIB .DA #S.DIB.S.BLOCK+S.DIB.S.WRITE+S.DIB.S.READ
*--------------------------------------
DRV.RamDrive cld
cpx #IOCTL.CONTROL
bcs .9
bcs DRV.RamDrive.9
>STYA pIOCTL
jmp (.1,x)
.1 .DA DRV.RamDrive.STATUS
.DA DRV.BLK READ
.DA DRV.BLK WRITE
.DA DRV.BLK FORMAT
.9 jmp A2osX.BadCall
DRV.RamDrive.9 jmp A2osX.BadCall
*--------------------------------------
DRV.RamDrive.STATUS
jsr DRV.Blk
@ -69,14 +68,13 @@ DRV.RamDrive.DIB
*--------------------------------------
DRV.BlkDevice cld
cpx #IOCTL.CONTROL
bcs .9
bcs DRV.RamDrive.9
>STYA pIOCTL
jmp (.1,x)
.1 .DA DRV.BlkDevice.STATUS
.DA DRV.BLK READ
.DA DRV.BLK WRITE
.DA DRV.BLK FORMAT
.9 jmp A2osX.BadCall
*--------------------------------------
DRV.BlkDevice.STATUS
jsr DRV.Blk
@ -191,38 +189,32 @@ DRV.SmartPort.Cnt
*--------------------------------------
DRV.NULL cld
>STYA pIOCTL
jmp (.1,x)
txa
beq DRV.NULL.STATUS
jmp (.1-12,x)
*--------------------------------------
.1 .DA DRV.NULL.STATUS
.DA A2osX.BADCALL READBLOCK
.DA A2osX.BADCALL WRITEBLOCK
.DA A2osX.BADCALL FORMAT
.DA A2osX.BADCALL CONTROL
.DA A2osX.BADCALL INIT
.1
* .DA DRV.NULL.STATUS
* .DA A2osX.BADCALL READBLOCK
* .DA A2osX.BADCALL WRITEBLOCK
* .DA A2osX.BADCALL FORMAT
* .DA A2osX.BADCALL CONTROL
* .DA A2osX.BADCALL INIT
.DA DRV.NULL.OPEN
.DA DRV.NULL.CLOSE
.DA DRV.NULL.READ
.DA DRV.NULL.WRITE
*--------------------------------------
DRV.NULL.STATUS >LDYAI DRV.NULL.DIB
jmp DRV.STATUS.YA
DRV.NULL.READ ldx #C.EOF
jmp DRV.READ.X
DRV.NULL.OPEN
DRV.NULL.WRITE
DRV.NULL.CLOSE clc
rts
*--------------------------------------
DRV.NULL.DIB .DA #S.DIB.S.WRITE+S.DIB.S.READ+S.DIB.S.OPENED
.DA #0,#0,#0
>PSTR "NULL DEVICE"
>PSTR "NULL Device"
.BS 5
.DA #S.DIB.T.CHAR
.DA #0
.DA K.VER
*--------------------------------------
DRV.NULL.STATUS >LDYAI DRV.NULL.DIB
*--------------------------------------
DRV.STATUS.YA >STYA .2+1
ldy #S.IOCTL.STATCODE
@ -255,6 +247,8 @@ DRV.STATUS.YA >STYA .2+1
sec
rts
*--------------------------------------
DRV.NULL.READ ldx #C.EOF
*--------------------------------------
DRV.READ.X ldy #S.IOCTL.BYTECNT
lda #1
sta (pIOCTL),y
@ -270,7 +264,10 @@ DRV.READ.X ldy #S.IOCTL.BYTECNT
sta .1+2
.1 stx $ffff SELF MODIFIED
clc
*--------------------------------------
DRV.NULL.OPEN
DRV.NULL.WRITE
DRV.NULL.CLOSE clc
rts
*--------------------------------------
MAN

View File

@ -4,38 +4,44 @@ AUTO 4,1
*/--------------------------------------
* # LoadTxtFile
* Load TXT a file in memory (with ending 0)
* ## C
* `int loadtxtfile ( const char * filename, short int flags, short int ftype, int auxtype );`
* ## ASM
* **In:**
* Y,A = File Path
* `>PUSHW auxtype`
* `>PUSHB ftype`
* `>PUSHB flags`
* `>LDYA filename`
* `>SYSCALL loadtxtfile`
* ## RETURN VALUE
* Y,A = File Length (without ending 0)
* X = hMem of Loaded File
*\--------------------------------------
K.LoadTxtFile pha
>PUSHWI 0 Aux type
>PUSHBI S.FI.T.TXT
>PUSHBI O.RDONLY
pla
sec
K.LoadTxtFile sec
.HS 90 BCC
*/--------------------------------------
* # LoadFile
* Load a file in memory
* ## C
* `int loadfile ( const char * filename, short int flags, short int ftype, int auxtype );`
* ## ASM
* **In:**
* PUSHW = AUXTYPE (Handled by....
* PUSHB = TYPE ...
* PUSHB = MODE ...
* LDYA = PATH ...FOpen)
* `>PUSHW auxtype`
* `>PUSHB ftype`
* `>PUSHB flags`
* `>LDYA filename`
* `>SYSCALL loadfile`
* ## RETURN VALUE
* Y,A = File Length
* X = hMem of Loaded File
*\--------------------------------------
K.LoadFile clc
ror FIO.bTXT
jsr K.FOpen
bcc .12
rts
bcs .9
.12 sta FIO.hFile
.12 sta .99+2 hFILE
pha
>PUSHWI K.S.Stat
@ -66,48 +72,51 @@ K.LoadFile clc
>PUSHW K.S.Stat+S.STAT.SIZE
>PUSHW FIO.Mem
lda FIO.hFile
lda .99+2
jsr K.FRead
bcs .98
bcc .2
pha
lda .8+1
jsr K.FreeMem
pla
.99 pha
lda #$ff SELF MODIFIED
jsr K.FClose
pla
sec
.9 rts
sty .6+1
.2 sty .6+1
sta .7+1 Save Bytes read
jsr .99 close file
bit FIO.bTXT
bpl .6
bpl .5
pha set ending 0
tya
* clc
clc set ending 0
lda .6+1
adc FIO.Mem
sta .5+1
lda .7+1
sta .4+1
pla
adc FIO.Mem+1
sta .5+2
.5 stz $ffff Self Modified
sta .4+2
.4 stz $ffff Self Modified
.5 jsr .99 close file
.6 ldy #$ff Self Modified
.7 lda #$ff Self Modified
.8 ldx #$ff Self Modified
clc
.9 rts
.98 pha
lda .8+1
jsr K.FreeMem
pla
.99 pha
lda FIO.hFile
jsr K.FClose
pla
sec
rts
*--------------------------------------
FIO.bTXT .BS 1
FIO.hFile .BS 1
FIO.Mem .BS 2
*/--------------------------------------
* # ChTyp

View File

@ -270,6 +270,12 @@ MemMgrInit >LDYAI Mem.MHiMem
dex
bpl .1
ldx #K.FLT.MAX*2-1
.11 stz Flt.Table.hPath,x
dex
bpl .11
ldx #K.NOD.MAX*2-1
.2 stz Nod.Table.hPath,x
@ -294,8 +300,6 @@ MemMgrInit >LDYAI Mem.MHiMem
dex
bpl .5
stz Flt.Table
rts
*--------------------------------------
SysScrInit >LDYAI Mem.XHiMem

View File

@ -103,7 +103,7 @@ K.SYSCALL.JMP .DA 0 $00
.DA 0
.DA K.Kill
.DA 0
.DA K.GetMemStat
.DA 0
.DA 0
.DA 0
@ -142,7 +142,7 @@ K.SYSCALL.JMP .DA 0 $00
.DA K.GetMemByID
.DA K.GetMem
.DA K.GetMem0
.DA 0
.DA K.GetMemStat
.DA K.SListAdd
*--------------------------------------
.DA K.SListLookup $F0

View File

@ -6,9 +6,7 @@ AUTO 4,1
* In :
* Out :
*--------------------------------------
K.PFTAdd
clc
rts
K.PFTAdd
*--------------------------------------
* K.PFTRemove
* In :
@ -16,59 +14,52 @@ K.PFTAdd
*--------------------------------------
K.PFTRemove
clc
rts
K.PFTRemove.RTS rts
*--------------------------------------
* PFT.CheckPathYA
* In :
* Y,A = PATH (C-String)
* Out :
*--------------------------------------
PFT.CheckPathYA stx .71+1 Save SYSCALL #
PFT.CheckPathYA stx .6+1 Save SYSCALL #
jsr K.realpath.I realpath in K.Buf256
bcs .9
bcs K.PFTRemove.RTS
>LDYAI Flt.Table
ldx #0
.1 lda Flt.Table.hPath,x
beq .8
jsr K.GetMemPtr
>STYA ZPPtr1
.1 lda (ZPPtr1) Get Filter char....
beq .80
ldy #$ff
ldy #0
.2 lda (ZPPtr1),y
.2 iny
lda (ZPPtr1),y "/FILTER\0"
beq .3 end of filter string....
lda K.Buf256,y
beq .8
cmp (ZPPtr1),y
bne .8
iny
bne .2
cmp K.Buf256,y can be \0
beq .2
bra .8
.3 lda K.Buf256,y
.3 lda K.Buf256,y path is "/FILTER/..." ?
cmp #'/'
bne .8
ldy #S.PFT.HANDLER
lda (ZPPtr1),y get hLib
lda Flt.Table.hLib,x get hLib
jsr K.GetMemPtr
>STYA .72+1
>STYA .7+1
pla discard JSR return @
pla
>LDYAI K.Buf256 pass full path to handler
.71 ldx #$ff SELF MODIFIED SYSCALL #
.72 jmp $ffff SELF MODIFIED
.6 ldx #$ff SELF MODIFIED SYSCALL #
.7 jmp $ffff SELF MODIFIED
.9 rts
.8 lda ZPPtr1
clc
adc (ZPPtr1) Add STR len
adc #S.PFT
sta ZPPtr1
bcc .1
.8 inx
cpx #K.FLT.MAX
bne .1
.80 >LDYAI K.Buf256
*--------------------------------------

View File

@ -193,12 +193,10 @@ K.PrintF.1 stz PrintF.Cnt
stz PrintF.Cnt+1
stz PrintF.GetByte+1
ldy #0
.1 lda (ZPPtr1),y
.1 jsr MEM.GetCharPtr1
beq .8 end of format..
iny
cmp #'%'
bne .10
@ -207,9 +205,8 @@ K.PrintF.1 stz PrintF.Cnt
sta K.PrintF.PadC
.2 ldx #PrintFTBL2-PrintFTBL1-1
lda (ZPPtr1),y
jsr MEM.GetCharPtr1
beq .99
iny
.3 cmp PrintFTBL1,x do we have a %x command?
beq .6 yes, jmp to it!
@ -243,12 +240,10 @@ K.PrintF.1 stz PrintF.Cnt
sta K.PrintF.PadL
bra .2 go get next char...
.6 phy
txa
.6 txa
asl
tax
jsr PrintF.ESC
ply
bcc .1
bcs .99
@ -262,9 +257,8 @@ K.PrintF.1 stz PrintF.Cnt
bne .20
ldx #PrintFTBL2.OUT-PrintFTBL2-1
lda (ZPPtr1),y
jsr MEM.GetCharPtr1
beq .99
iny
.12 cmp PrintFTBL2,x
beq .13

View File

@ -84,7 +84,7 @@ K.StrToUL clc Unsigned
bcs K.StrToUL.rts
* clc
K.StrToUL.Exit adc ZPPtr2
adc ZPPtr2
sta (ZPPtr1)
lda #0
adc ZPPtr2+1

View File

@ -1207,6 +1207,58 @@ RESET.VALUES .DA #0 S.DCB.TTY.MODE
.DA #S.DCB.TTY.OUTBUFFER S.DCB.TTY.OUTHEAD
.DA #S.DCB.TTY.INBUFFER S.DCB.TTY.INBUFFER
*--------------------------------------
SCR.BASEL .HS 00.80.00.80.00.80.00.80.28.A8.28.A8.28.A8.28.A8.50.D0.50.D0.50.D0.50.D0
SCR.BASEH .HS 04.04.05.05.06.06.07.07.04.04.05.05.06.06.07.07.04.04.05.05.06.06.07.07
*--------------------------------------
BUF.BASEL .DA #0
.DA #80
.DA #160
.DA #240
.DA #320
.DA #400
.DA #480
.DA #560
.DA #640
.DA #720
.DA #800
.DA #880
.DA #960
.DA #1040
.DA #1120
.DA #1200
.DA #1280
.DA #1360
.DA #1440
.DA #1520
.DA #1600
.DA #1680
.DA #1760
.DA #1840
BUF.BASEH .DA /0
.DA /80
.DA /160
.DA /240
.DA /320
.DA /400
.DA /480
.DA /560
.DA /640
.DA /720
.DA /800
.DA /880
.DA /960
.DA /1040
.DA /1120
.DA /1200
.DA /1280
.DA /1360
.DA /1440
.DA /1520
.DA /1600
.DA /1680
.DA /1760
.DA /1840
*--------------------------------------
CtrlChars .HS 05080A0C0D151B
CtrlChars.Cnt .EQ *-CtrlChars
*--------------------------------------

View File

@ -2,58 +2,6 @@ NEW
PREFIX
AUTO 4,1
*--------------------------------------
SCR.BASEL .HS 00.80.00.80.00.80.00.80.28.A8.28.A8.28.A8.28.A8.50.D0.50.D0.50.D0.50.D0
SCR.BASEH .HS 04.04.05.05.06.06.07.07.04.04.05.05.06.06.07.07.04.04.05.05.06.06.07.07
*--------------------------------------
BUF.BASEL .DA #0
.DA #80
.DA #160
.DA #240
.DA #320
.DA #400
.DA #480
.DA #560
.DA #640
.DA #720
.DA #800
.DA #880
.DA #960
.DA #1040
.DA #1120
.DA #1200
.DA #1280
.DA #1360
.DA #1440
.DA #1520
.DA #1600
.DA #1680
.DA #1760
.DA #1840
BUF.BASEH .DA /0
.DA /80
.DA /160
.DA /240
.DA /320
.DA /400
.DA /480
.DA /560
.DA /640
.DA /720
.DA /800
.DA /880
.DA /960
.DA /1040
.DA /1120
.DA /1200
.DA /1280
.DA /1360
.DA /1440
.DA /1520
.DA /1600
.DA /1680
.DA /1760
.DA /1840
*--------------------------------------
DRV.TERM.CLRSCR ldx #23
sta SET80STORE

View File

@ -21,7 +21,7 @@ AUTO 4,1
.INB USR/SRC/SYS/KERNEL.S.INIT
.INB USR/SRC/X.PRINTF.S
A2osX.MAIN .PH $1480
A2osX.MAIN .PH A2osX.EndTables
.INB USR/SRC/SYS/KERNEL.S.CORE
.INB USR/SRC/SYS/KERNEL.S.DRV
.INB USR/SRC/SYS/KERNEL.S.TERM