Kernel 0.9.2

This commit is contained in:
Rémy GIBERT 2018-10-03 17:25:03 +02:00
parent 2db77dc027
commit e9e8508c2e
7 changed files with 160 additions and 115 deletions

Binary file not shown.

Binary file not shown.

View File

@ -253,6 +253,7 @@ SYS.GuiOSD.JMP .EQ $E200
*--------------------------------------
K.E.OOM .EQ $FF Out Of Memory Error
K.E.OOH .EQ $FE Out Of Handle Error
K.E.INVH .EQ $FD Invalid Handle
*--------------------------------------
K.E.NSP .EQ $DD No Such Process Error
*--------------------------------------

View File

@ -113,8 +113,9 @@ Kernel.Init3 sta SETALTZP
jsr PS0.Init
>PUSHBI 0
>LDYAI MSG.Init3
>SYSCALL puts
>SYSCALL printf
jsr CPU.Init.6502
jsr CPU.Init.Z80
@ -1004,7 +1005,8 @@ MSG.KCREAD.KO .AZ "\nError While Reading Kernel Config File, Using Default.\n"
MSG.Init2.OK .AZ "A2osX[Stage2]:Complete.\n"
*--------------------------------------
SYSSCREEN.TOP .AZ "A2osX 0.92 System Screen"
MSG.Init3 .AZ "A2osX[Stage3]:Init\r\nPress Ctrl-D for Mantenance Mode."
MSG.Init3 .AS "A2osX[Stage3]:Init "
.AZ "*** Press Ctrl-D for Mantenance Mode ***\r\n"
MSG.DEV .AZ "Device Manager..."
MSG.BLKDEV .AZ " Adding : /DEV/%s\r\n"
MSG.IRQ .AZ "Interrupt Manager..."
@ -1029,9 +1031,9 @@ MSG.6502 .AZ "6502."
MSG.65C02 .AZ "65C02."
MSG.65R02 .AZ "65R02."
MSG.65816 .AZ "65816."
MSG.CPU.SPEED .AZ "Detecting CPU Speed..."
MSG.CPU.SPEED .AZ "Checking CPU Speed..."
MSG.CPU.SPEEDOK .AZ "%d.%02d Mhz.\r\n"
MSG.Z80 .AZ "Detecting Z80 CPU..."
MSG.Z80 .AZ "Checking Z80 CPU..."
MSG.Z80.OK .AZ "Detected In Slot %d.\r\n"
MSG.Z80.KO .AZ "Not Detected."
*--------------------------------------

View File

@ -72,11 +72,11 @@ K.Close jsr K.GetMemPtr
jmp (.1,x)
.1 .DA IO.CLOSE.REG
.DA STDIO.IOERR DIR
.DA IO.CLOSE.DIR
.DA IO.CLOSE.CDEV
.DA STDIO.IOERR BDEV
.DA STDIO.IOERR LNK
.DA STDIO.IOERR DSOCK
.DA IO.CLOSE.DSOCK
.DA IO.CLOSE.SSOCK
.DA IO.CLOSE.PIPE
@ -85,9 +85,25 @@ K.Close jsr K.GetMemPtr
rts
*--------------------------------------
IO.CLOSE.REG
IO.CLOSE.DIR
ldy #S.FD.REG.REF
lda (pFD),y
beq .1
sta K.MLI.PARAMS+1
>MLICALL MLICLOSE
.1 ldy #S.FD.REG.IOBUF
lda (pFD),y
beq .8
jmp K.FreeMem
.8 clc
rts
*--------------------------------------
IO.CLOSE.CDEV
*--------------------------------------
IO.CLOSE.DSOCK
IO.CLOSE.SSOCK
*--------------------------------------
IO.CLOSE.PIPE clc
@ -107,8 +123,6 @@ IO.CLOSE.PIPE clc
* CS: A = EC
*\--------------------------------------
K.Read jsr K.GetMemPtr
bcs K.Write.9
>STYA pFD
>PULLW K.S.IOCTL+S.IOCTL.BUFPTR
@ -141,13 +155,8 @@ IO.Read.I lda (pFD) #S.FD.T
* CS: A = EC
*\--------------------------------------
K.Write jsr K.GetMemPtr
bcs K.Write.9
>STYA pFD
>PULLW K.S.IOCTL+S.IOCTL.BUFPTR
>PULLW K.S.IOCTL+S.IOCTL.BYTECNT
IO.Write.I lda (pFD) #S.FD.T
tax
jmp (.1,x)
@ -171,10 +180,8 @@ IO.WRITE.REG ldx #MLIWRITE
ldy #S.FD.REG.REF
lda (pFD),y
sta K.MLI.PARAMS+1
>LDYA K.S.IOCTL+S.IOCTL.BUFPTR
>STYA K.MLI.PARAMS+2
>LDYA K.S.IOCTL+S.IOCTL.BYTECNT
>STYA K.MLI.PARAMS+4
>PULLW K.MLI.PARAMS+2
>PULLW K.MLI.PARAMS+4
lda #4 Param Count = 4 for MLIREAD & MLIWRITE
jsr GP.MLICall
@ -186,6 +193,9 @@ IO.READ.CDEV ldx #IOCTL.READ
*--------------------------------------
IO.WRITE.CDEV ldx #IOCTL.WRITE
>PULLW K.S.IOCTL+S.IOCTL.BUFPTR
>PULLW K.S.IOCTL+S.IOCTL.BYTECNT
jsr K.IOCTL.GetPDRV
>LDYAI K.S.IOCTL
@ -207,15 +217,15 @@ IO.READ.SSOCK ldy #S.FD.SOCK.READ
jsr K.GetMemPtr
>STYA .1
>PUSHW K.S.IOCTL+S.IOCTL.BYTECNT
>PUSHW K.S.IOCTL+S.IOCTL.BUFPTR
ldy #S.FD.SOCK.HSKT
lda (pFD),y
.1 jmp $ffff
*--------------------------------------
IO.READ.PIPE ldy #S.FD.PIPE.S
IO.READ.PIPE >PULLW K.S.IOCTL+S.IOCTL.BUFPTR
>PULLW K.S.IOCTL+S.IOCTL.BYTECNT
ldy #S.FD.PIPE.S
lda (pFD),y
bit #S.FD.PIPE.S.WOpened
beq .9 Remote PS did not opened yet the pipe
@ -236,7 +246,10 @@ IO.READ.PIPE ldy #S.FD.PIPE.S
sec
rts
*--------------------------------------
IO.WRITE.PIPE ldy #S.FD.PIPE.S
IO.WRITE.PIPE >PULLW K.S.IOCTL+S.IOCTL.BUFPTR
>PULLW K.S.IOCTL+S.IOCTL.BYTECNT
ldy #S.FD.PIPE.S
lda (pFD),y
bit #S.FD.PIPE.S.ROpened
beq .9 Remote PS did not opened yet the pipe

View File

@ -155,13 +155,13 @@ K.MKDir jsr PFT.CheckPathYA
bpl .1
>MLICALL MLICREATE
rts
K.MKDir.RTS rts
*/--------------------------------------
* # MkNod
* Create a special or ordinary file.
* (CDEV, BDEV, DSOCKS, SSOCK, PIPE)
* ## C
* `int mknod(const char *pathname, int mode, hFD fd);`
* `hFILE mknod(const char *pathname, int mode, hFD fd);`
* ## ASM
* **In:**
* `>PUSHB fd`
@ -178,31 +178,14 @@ K.MkNod >STYA ZPPtr1 pathname
>PULLB K.S.STAT+S.STAT.DEV
jsr K.GetMemPtr
bcs .99
bcs K.MKDir.RTS
>STYA pFD
ldx #0
.1 lda Nod.Table.hFD,x
beq .2
inx
cpx #K.NOD.MAX
beq .98
.2 lda K.S.STAT+S.STAT.DEV
sta Nod.Table.hFD,x
stx .3+1
>LDYA ZPPtr1
jsr K.NewStr
bcs .99
txa
.3 ldx #$ff SELF MODIFIED
sta Nod.Table.hPath,x
ldx K.S.STAT+S.STAT.DEV
jsr STDIO.NewHFileYAX
bcs K.MKDir.RTS
lda (pFD) #S.FD.T
@ -217,10 +200,6 @@ K.MkNod >STYA ZPPtr1 pathname
.DA STAT.MKNOD.DSOCK
.DA STAT.MKNOD.SSOCK
.DA STAT.MKNOD.PIPE
.98 lda #K.E.OOH
sec
.99 rts
*--------------------------------------
STAT.MKNOD.CDEV
STAT.MKNOD.BDEV

View File

@ -965,24 +965,26 @@ K.SScanF.Fwd tya Y=char count parsed
* `>PUSHBI mode`
* + O.RDONLY : if R and !exists -> ERROR
* + O.WRONLY : if W and !exists -> CREATE
* + O.TRUNC : Reset Size To 0
* + O.APPEND : Append
* + O.TEXT : Open/Append in Text mode
* + O.CREATE : 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"
* TODO: mode="w+,t=TYP,x=AUXTYPE"
* + r = O_RDONLY
* + r+ = O_RDWR
* + w = O_WRONLY | O_CREAT | O_TRUNC
* + w+ = O_RDWR | O_CREAT | O_TRUNC
* + a = O_WRONLY | O_CREAT | O_APPEND
* + a+ = O_RDWR | O_CREAT | O_APPEND
* + ,t=123 or t=$ff or t=TXT
* + ,x=12345 or x=$ffff
* `>LDYAI filename`
* **Out:**
* CC : A = hFILE
* CS : A = EC
*\--------------------------------------
K.FOpen jsr PFT.CheckPathYA
>STYA K.FOpen.PATH
jsr STDIO.SetMLIPathYA
>PULLB K.FOpen.MODE
>PULLB K.FOpen.TYPE
@ -1014,11 +1016,7 @@ K.FOpen.I >MLICALL MLIGETFILEINFO
bcc K.FOpen.10
K.FOpen.9 rts
K.FOpen.10 lda #S.FD.REG
sec
adc K.MLI.PATH
tay
lda #0
K.FOpen.10 >LDYAI S.FD.REG
ldx #S.MEM.F.INIT0+S.MEM.F.FD
jsr MEM.GetMem.YAX
bcs K.FOpen.9
@ -1026,19 +1024,6 @@ K.FOpen.10 lda #S.FD.REG
>STYA pFD
stx .8+1
ldx #0
ldy #S.FD.REG
.1 inx
lda K.MLI.PATH,x
sta (pFD),y
iny
cpx K.MLI.PATH
bne .1
lda #0
sta (pFD),y
* ldy #S.FD.T Done by GetMem0
* lda #S.FD.T.REG
* sta (pFD),y
@ -1076,7 +1061,7 @@ K.FOpen.10 lda #S.FD.REG
.20 lda K.FOpen.MODE
and #O.TEXT Text Mode ?
beq .8
beq .22
lda #$FF
sta K.MLI.PARAMS+2
@ -1084,17 +1069,21 @@ K.FOpen.10 lda #S.FD.REG
sta K.MLI.PARAMS+3
>MLICALL MLINEWLINE
.8 lda #$ff Self Modified, hFD
clc
rts CC
.22 >LDYA K.FOpen.PATH
.8 ldx #$ff Self Modified, hFD
jsr STDIO.NewHFileYAX
bcc .80
.98 pha save MLI error
lda .8+1
jsr K.FClose
jsr K.Close
pla get back MLI error
sec
rts
.80 rts
*--------------------------------------
K.FOpen.PATH .BS 2
K.FOpen.MODE .BS 1
K.FOpen.TYPE .BS 1
K.FOpen.AUXTYPE .BS 2
@ -1109,25 +1098,27 @@ K.FOpen.AUXTYPE .BS 2
* **Out:**
*\--------------------------------------
K.FClose jsr PFT.CheckNodeA
sta .8+1
jsr K.GetMemPtr
>STYA pFD
sta .8+1 save hFILE
tax
ldy #S.FD.REG.REF
lda (pFD),y
beq .1
sta K.MLI.PARAMS+1
>MLICALL MLICLOSE
lda Nod.Table.hPath,x
beq .9
.1 ldy #S.FD.REG.IOBUF
lda (pFD),y
beq .8
stz Nod.Table.hPath,x
jsr K.FreeMem discard filename
jsr K.FreeMem
.1 lda Nod.Table.hFD,x
jsr K.Close
.8 lda #$ff Self Modified
jmp K.FreeMem
.9 rts
.8 ldx #$ff SELF MODIFIED
lda Nod.Table.hFD,x
stz Nod.Table.hFD,x
jmp K.FreeMem discard filename
.9 lda #K.E.INVH
sec
rts
*/--------------------------------------
* # FRead
* int fread (hFILE stream, void * ptr, int count );
@ -1141,8 +1132,12 @@ K.FClose jsr PFT.CheckNodeA
* Y,A = Bytes Read
*\--------------------------------------
K.FRead jsr PFT.CheckNodeA
ldx #MLIREAD
bra K.FReadWrite.1
jsr STDIO.GetHFile
bcs .9
jmp K.Read
.9
*/--------------------------------------
* # FWrite
* Write bytes to file
@ -1159,7 +1154,9 @@ K.FRead jsr PFT.CheckNodeA
*\--------------------------------------
K.FWrite jsr PFT.CheckNodeA
ldx #MLIWRITE
K.FReadWrite.1 jsr STDIO.GetRefNum
K.FReadWrite.1 jsr STDIO.GetHFile
bcs .9
>PULLW K.MLI.PARAMS+2
>PULLW K.MLI.PARAMS+4
@ -1177,7 +1174,7 @@ K.FReadWrite.1 jsr STDIO.GetRefNum
* A = hFILE
*\--------------------------------------
K.FFlush jsr PFT.CheckNodeA
jsr STDIO.GetRefNum
jsr STDIO.GetHFile
>MLICALL MLIFLUSH
rts
*/-------------------------------------
@ -1193,7 +1190,7 @@ K.FFlush jsr PFT.CheckNodeA
* `>SYSCALL fseek`
*\-------------------------------------
K.FSeek jsr PFT.CheckNodeA
jsr STDIO.GetRefNum
jsr STDIO.GetHFileREG
>PULLA FROM
tax
>PULLW ZPPtr1 offset LW
@ -1262,7 +1259,7 @@ K.FSeek jsr PFT.CheckNodeA
* CS :
*\--------------------------------------
K.FEOF jsr PFT.CheckNodeA
jsr STDIO.GetRefNum
jsr STDIO.GetHFileREG
>MLICALL MLIGETMARK
bcs .9
@ -1302,7 +1299,7 @@ K.FEOF.MARK .BS 3
* On stack (long)
*\--------------------------------------
K.FTell jsr PFT.CheckNodeA
jsr STDIO.GetRefNum
jsr STDIO.GetHFileREG
>MLICALL MLIGETMARK
bcs .9
@ -1356,6 +1353,66 @@ K.Rename jsr PFT.CheckPathYA
>MLICALL MLIRENAME
rts
*--------------------------------------
* Y,A = filepath
* X = hFD
*--------------------------------------
STDIO.NewHFileYAX
pha
stx .4+1 Store hFD
ldx #0
.1 lda Nod.Table.hFD,x
beq .2
inx
cpx #K.NOD.MAX
bne .1
pla
lda #K.E.OOH
* sec
rts
.2 stx .3+1 Store hFILE
pla
jsr K.NewStr
bcs .9
txa
.3 ldx #$ff SELF MODIFIED
sta Nod.Table.hPath,x
.4 lda #$ff SELF MODIFIED
sta Nod.Table.hFD,x
txa hFILE
clc
.9 rts
*--------------------------------------
STDIO.GetHFile tay
lda Dev.Table.hFD,y
beq .9
STDIO.GetHFileREG
tay
lda Dev.Table.hFD,y
beq STDIO.GetHFile.9
jsr K.GetMemPtr
>STYA pFD
ldy #S.FD.REG.REF
lda (pFD),y
sta K.MLI.PARAMS+1
rts
STDIO.GetHFile.9
lda #K.E.INVH
sec
rts
*--------------------------------------
STDIO.SetMLIPathYA
>STYA .1+1
@ -1387,13 +1444,6 @@ STDIO.SetIOBUF >LDYAI 1024 get a ProDOS IOBUF
sta (pFD),y
.9 rts
*--------------------------------------
STDIO.GetRefNum jsr K.GetMemPtr
>STYA pFD
ldy #S.FD.REG.REF
lda (pFD),y
sta K.MLI.PARAMS+1
rts
*--------------------------------------
STDIO.IOERR lda #MLI.E.IO
sec
rts