Kernel version 0.9 : Change in API to conform with stdlib & stdio

This commit is contained in:
Rémy GIBERT 2017-08-22 17:03:34 +02:00
parent d0682caab7
commit 62ad3573b9
23 changed files with 130 additions and 1012 deletions

View File

@ -29,7 +29,7 @@ Print A (char) to File
## Out:
+ CC = success
# PutCA
# PutCharA
Print A (char) to StdOut
## In:
@ -38,21 +38,21 @@ Print A (char) to StdOut
## Out:
+ CC = success
# FGetCA
Get char from File
# GetChar
Get char from StdIn
## In:
+ A = hFILE
+ none.
## Out:
+ CC = success
+ A = char
# GetC
Get char from StdIn
# GetCA
Get char from File
## In:
+ none.
+ A = hFILE
## Out:
+ CC = success
@ -108,17 +108,17 @@ Scan a PStr (in progress)
## Out:
# PrintFYA/SPrintFYA/FPrintFYA
Prints Pascal/C-Style String
Prints C-Style String
## In:
+ PrintFYA :
PrintFYA :
+ Y,A = PTR to CStr
+ SPrintFYA :
SPrintFYA :
+ Y,A = PTR to CStr
+ PULLW = Ptr to Dst Buffer
+ FPrintFYA :
FPrintFYA :
+ Y,A = PTR to CStr
+ PULLB = hDev
+ PULLB = hNode
## Out:
+ CC : success

Binary file not shown.

Binary file not shown.

View File

@ -32,14 +32,14 @@ SRC.PrintLineErr ldx #0
.1 lda UsrBuf256,x
beq .2
phx
>SYSCALL PutCA
>SYSCALL PutCharA
plx
inx
bcc .1
rts
.2 lda #13
>SYSCALL PutCA
>SYSCALL PutCharA
bcs .9
ldx #0
@ -50,19 +50,19 @@ SRC.PrintLineErr ldx #0
beq .4
phx
lda #'-'
>SYSCALL PutCA
>SYSCALL PutCharA
plx
bcs .9
bra .3
.4 lda #'^'
phx
>SYSCALL PutCA
>SYSCALL PutCharA
plx
bcs .9
.5 lda #13
>SYSCALL PutCA
>SYSCALL PutCharA
.9 rts
*---------------------------------------
SRC.ParseLine ldx UsrBuf256
@ -326,12 +326,12 @@ SRC.ParseLine.OpCode
.21 inx
lda SRC.AM.StrBuf,x
phx
>SYSCALL PutCA
>SYSCALL PutCharA
plx
cpx SRC.AM.StrBuf
bne .21
lda #13
>SYSCALL PutCA
>SYSCALL PutCharA
.20 ldy #ASM.PC

View File

@ -110,7 +110,7 @@ SYM.Dump >LDYA L.MSG.SYMBOLS
rts
.5 lda #13
>SYSCALL PutCA
>SYSCALL PutCharA
ldy #SYM.DumpCount
lda (pData),y

View File

@ -241,11 +241,11 @@ CS.RUN.PRINT sty BytesRead Y,A = Bytes read
bra .7
.4 lda #13
>SYSCALL PutCA
>SYSCALL PutCharA
bcs .9
lda #10
.6 >SYSCALL PutCA
.6 >SYSCALL PutCharA
bcs .9
.7 inc ByteIndex

View File

@ -239,9 +239,9 @@ CS.RUN.CheckErr bcs .1
rts
.2 lda #13
>SYSCALL PutCA
>SYSCALL PutCharA
lda #10
>SYSCALL PutCA
>SYSCALL PutCharA
pla
sec
.9 rts

View File

@ -14,7 +14,7 @@ SCRN.Init ldy #ScreenH
>SYSCALL PrintFYA
bcs .9
lda #12
>SYSCALL PutCA
>SYSCALL PutCharA
bcs .9
lda #0
@ -162,7 +162,7 @@ SCRN.UpdateLineAtALenY
pla
bcs .11
>SYSCALL PutCA
>SYSCALL PutCharA
.11 ply
plx
bcs .9
@ -305,7 +305,7 @@ SCRN.ClearEOLA pha
pha
lda #' '
>SYSCALL PutCA
>SYSCALL PutCharA
bcc .1
plx
rts
@ -332,7 +332,7 @@ SCRN.InvLineA sta .2+1
.1 pha
lda #' '
>SYSCALL PutCA
>SYSCALL PutCharA
pla
bcs .9

View File

@ -162,7 +162,7 @@ CS.RUN.LINK >PUSHW L.MSG1.LINK.OK
.4 phx
lda #'0'
>SYSCALL PutCA
>SYSCALL PutCharA
plx
dex
bne .4

View File

@ -243,7 +243,7 @@ CS.RUN.DIR ldy #bAllmostAll
.1 lda #' '
phx
>SYSCALL PutCA
>SYSCALL PutCharA
plx
bcs .9
dex
@ -401,9 +401,9 @@ CS.RUN.NewLine ldy #ColCount
beq CS.RUN.NewLine.8
CS.RUN.NewLine.1
lda #13
>SYSCALL PutCA
>SYSCALL PutCharA
lda #10
>SYSCALL PutCA
>SYSCALL PutCharA
rts
CS.RUN.NewLine.8
clc

View File

@ -73,9 +73,9 @@ CS.RUN >LDYA L.MSG0
bcs .9
.6 lda #13
>SYSCALL PutCA
>SYSCALL PutCharA
lda #10
>SYSCALL PutCA
>SYSCALL PutCharA
.7 inc DEV.ID
lda DEV.ID

View File

@ -292,11 +292,11 @@ NSC.Dump ldx #1
lda DS1216E.DATA+2
jsr PrintBCD
lda #'/'
>SYSCALL PutCA
>SYSCALL PutCharA
lda DS1216E.DATA+1
jsr PrintBCD
lda #'/'
>SYSCALL PutCA
>SYSCALL PutCharA
lda DS1216E.DATA
jsr PrintBCD
@ -309,15 +309,15 @@ NSC.Dump ldx #1
.4 and #$3F
jsr PrintBCD
lda #':'
>SYSCALL PutCA
>SYSCALL PutCharA
lda DS1216E.DATA+5
jsr PrintBCD
lda #':'
>SYSCALL PutCA
>SYSCALL PutCharA
lda DS1216E.DATA+6
jsr PrintBCD
lda #'.'
>SYSCALL PutCA
>SYSCALL PutCharA
lda DS1216E.DATA+7
jsr PrintBCD
rts
@ -328,12 +328,12 @@ PrintBCD pha
lsr
lsr
ora #$30
>SYSCALL PutCA
>SYSCALL PutCharA
bcs .9
pla
and #$0f
ora #$30
>SYSCALL PutCA
>SYSCALL PutCharA
.9 rts
*--------------------------------------
GetBCD lda (ZPPtr1),y

View File

@ -533,10 +533,10 @@ CS.RUN.OVERWRITE.KEY
.FIN
*--------------------------------------
CS.RUN.CR lda #13
>SYSCALL PutCA
>SYSCALL PutCharA
bcs .9
lda #10
>SYSCALL PutCA
>SYSCALL PutCharA
.9 rts
*--------------------------------------
.DO X.COPY.TO.DEST=1
@ -653,7 +653,7 @@ CS.RUN.Copy stz .90+1
bmi .8
lda #'.'
>SYSCALL PutCA
>SYSCALL PutCharA
rts
.8 clc

View File

@ -677,7 +677,7 @@ SetCharAtXY cmp #$40
sta CLRWRITEAUX
plp
clc
rts
*--------------------------------------
GetCharAtXY php

View File

@ -269,9 +269,9 @@ SYS.FreeStkObjA .EQ $AC
* .EQ $AE
*--------------------------------------
SYS.FPutCAY .EQ $B0
SYS.PutCA .EQ $B2
SYS.FGetCA .EQ $B4
SYS.GetC .EQ $B6
SYS.PutCharA .EQ $B2
SYS.GetCA .EQ $B4
SYS.GetChar .EQ $B6
SYS.FPutS .EQ $B8
SYS.PutSYA .EQ $BA
SYS.FGetS .EQ $BC

View File

@ -79,10 +79,10 @@ CS.RUN lda #0
bcc .2
lda #13
>SYSCALL PutCA
>SYSCALL PutCharA
bcs .9
lda #10
>SYSCALL PutCA
>SYSCALL PutCharA
bcs .9
>LDYA L.SHELL
@ -153,7 +153,7 @@ INPUT.CHARIN tax save char...
lda (pData),y
bne .1
txa
.1 >SYSCALL PutCA
.1 >SYSCALL PutCharA
rts
.2 cpx #13 CR

View File

@ -489,11 +489,11 @@ Cmd.Exec.ECHO lda ARGS
Cmd.Exec.ECHO.CR
lda #13
>SYSCALL PutCA
>SYSCALL PutCharA
bcs Cmd.Exec.ECHO.RTS
lda #10
>SYSCALL PutCA
>SYSCALL PutCharA
Cmd.Exec.ECHO.RTS
rts
@ -562,7 +562,7 @@ Cmd.Exec.READ lda ARGS
cmp #'"'
beq .1
phx
>SYSCALL PutCA
>SYSCALL PutCharA
plx
bcs .99
bra .3

View File

@ -159,7 +159,7 @@ CS.RUN ldy #VarBuffer READ Command ?
lda (pData),y
bpl .13
>SYSCALL GetC
>SYSCALL GetChar
bcs .8
.13 jsr CheckSleep
@ -181,7 +181,7 @@ CS.RUN ldy #VarBuffer READ Command ?
bcs CS.RUN.EXIT.RTS
.1 >SYSCALL Sleep
>SYSCALL GetC
>SYSCALL GetChar
bcs .1 no char
jsr CS.CHARIN
@ -219,7 +219,7 @@ CS.RUN.READ lda #0
sta (pData)
.1 >SYSCALL Sleep
>SYSCALL GetC
>SYSCALL GetChar
bcs .1 no char
jsr CS.CHARIN
@ -289,13 +289,13 @@ CS.RUN.BATCH jsr CSH.Run
.90 jsr CSH.GetChar
bcs .92
>SYSCALL PutCA
>SYSCALL PutCharA
.91 jsr CSH.GetNextChar
bcs .92
cmp #13
beq .92
>SYSCALL PutCA
>SYSCALL PutCharA
bra .91
.92 pla
@ -409,7 +409,7 @@ CS.CHARIN tax
bne .8
txa
>SYSCALL PutCA
>SYSCALL PutCharA
.8 clc
rts
@ -417,9 +417,9 @@ CS.CHARIN tax
CS.CHARIN.CTRL cpx #13 CR
bne .10
txa
>SYSCALL PutCA
>SYSCALL PutCharA
lda #10
>SYSCALL PutCA
>SYSCALL PutCharA
lda (pData) CmdBuffer
ora #$80
@ -513,14 +513,27 @@ PrintPrompt >LDYA L.ENV.PS1
plp
.9 rts
*--------------------------------------
CmdLine.CLR jsr CmdLine.DEL
bne CmdLine.CLR
rts
CmdLine.CLR lda (pData)
beq .9
tay
lda #8
.1 sta (pData),y
dey
bne .1
jsr CmdLine.SET
lda #0
sta (pData)
.9 rts
*--------------------------------------
CmdLine.DEL lda (pData)
beq .9
lda #8
>SYSCALL PutCA
>SYSCALL PutCharA
lda (pData)
dec
sta (pData)

View File

@ -16,27 +16,27 @@ K.FPutCAY sta K.PutC.Char
sty K.PutC.Node
tya
phy
bne K.PutCA.1
K.PutCA.8 ply
bne K.PutCharA.1
K.PutCharA.8 ply
clc
rts
*/--------------------------------------
* # PutCA
* # PutCharA
* Print A (char) to StdOut
* ## In:
* A : char to print
* ## Out:
* CC = success
*\--------------------------------------
K.PutCA sta K.PutC.Char
K.PutCharA sta K.PutC.Char
phy
ldy #S.PS.hStdOut
lda (pPs),y
beq K.PutCA.8 NUL
beq K.PutCharA.8 NUL
phx
K.PutCA.1 sta K.PutC.Node
K.PutCharA.1 sta K.PutC.Node
jsr K.GetMemPtrA
>STYA pDev
@ -44,27 +44,27 @@ K.PutCA.1 sta K.PutC.Node
lda (pDev),y
asl
tax
jsr K.PutCA.Jmp
jsr K.PutCharA.Jmp
plx
ply
rts
*--------------------------------------
K.PutCA.Jmp jmp (.1,x)
.1 .DA K.PutCA.REG
K.PutCharA.Jmp jmp (.1,x)
.1 .DA K.PutCharA.REG
.DA K.CHR.IOERR DIR
.DA K.PutCA.CDEV
.DA K.PutCharA.CDEV
.DA K.CHR.IOERR BDEV
.DA K.CHR.IOERR LNK
.DA K.CHR.IOERR DSOCK
.DA K.PutCA.SSOCK
.DA K.PutCA.FIFO
.DA K.PutCharA.SSOCK
.DA K.PutCharA.FIFO
*--------------------------------------
K.PutCA.REG lda K.PutC.Node
K.PutCharA.REG lda K.PutC.Node
ldy K.PutC.Char
jmp K.FWriteAY
*--------------------------------------
K.PutCA.CDEV ldy #S.NODE.DEV.JMP
K.PutCharA.CDEV ldy #S.NODE.DEV.JMP
lda (pDev),y
sta .1+1
iny
@ -74,7 +74,8 @@ K.PutCA.CDEV ldy #S.NODE.DEV.JMP
ldx #DEVMGR.WRITE
.1 jmp $ffff
*--------------------------------------
K.PutCA.SSOCK lda (pDev) #S.NODE.HANDLER
K.PutCharA.SSOCK
lda (pDev) #S.NODE.HANDLER
jsr K.GetMemPtrA
>STYA .1
@ -87,7 +88,7 @@ K.PutCA.SSOCK lda (pDev) #S.NODE.HANDLER
tax Function Offset for write
.1 jmp $ffff
*--------------------------------------
K.PutCA.FIFO ldy #S.NODE.FIFO.S
K.PutCharA.FIFO ldy #S.NODE.FIFO.S
lda (pDev),y
beq .9 Remote PS did not opened yet the pipe
cmp #S.NODE.FIFO.S.Closed
@ -123,16 +124,7 @@ K.PutCA.FIFO ldy #S.NODE.FIFO.S
K.PutC.Char .BS 1
K.PutC.Node .BS 1
*/--------------------------------------
* # FGetCA
* Get char from File
* ## In:
* A = hFILE
* ## Out:
* CC = success
* A = char
*\--------------------------------------
*/--------------------------------------
* # GetC
* # GetChar
* Get char from StdIn
* ## In:
* none.
@ -140,10 +132,18 @@ K.PutC.Node .BS 1
* CC = success
* A = char
*\--------------------------------------
K.GetC ldy #S.PS.hStdIn
lda (pPs),y
K.FGetCA sta K.PutC.Node
K.GetChar ldy #S.PS.hStdIn
lda (pPs),y
*/--------------------------------------
* # GetCA
* Get char from File
* ## In:
* A = hFILE
* ## Out:
* CC = success
* A = char
*\--------------------------------------
K.GetCA sta K.PutC.Node
jsr K.GetMemPtrA
>STYA pDev

View File

@ -103,16 +103,16 @@ K.SScanF.IsDigit
rts
*/--------------------------------------
* # PrintFYA/SPrintFYA/FPrintFYA
* Prints Pascal/C-Style String
* Prints C-Style String
* ## In:
* PrintFYA :
* PrintFYA :
* Y,A = PTR to CStr
* SPrintFYA :
* SPrintFYA :
* Y,A = PTR to CStr
* PULLW = Ptr to Dst Buffer
* FPrintFYA :
* FPrintFYA :
* Y,A = PTR to CStr
* PULLB = hDev
* PULLB = hNode
* ## Out:
* CC : success
* CS : error code from Output
@ -154,16 +154,13 @@ K.SPrintFYA >STYA ZPPtr1
K.FPrintFYA >STYA ZPPtr1
K.PPrintFYA ldx #$01 PSTR
.HS 2C bit abs
K.PrintFYA ldx #$00 CSTR
>STYA ZPPtr1
stx Printf.GetCharAtPtr1Y+1
K.PrintFYA >STYA ZPPtr1
ldy #0
.1 jsr Printf.GetCharAtPtr1Y
beq .99
.1 lda (ZPPtr1),y
beq .99
iny
cmp #'%'
bne .10
@ -171,9 +168,10 @@ K.PrintFYA ldx #$00 CSTR
lda #' '
sta PADCHAR
.2 ldx #PrintFTBL1.END-PrintFTBL1-1
jsr Printf.GetCharAtPtr1Y
.2 ldx #PrintFTBL2-PrintFTBL1-1
lda (ZPPtr1),y
beq .99
iny
.3 cmp PrintFTBL1,x do we have a %x command?
beq .8 yes, jmp to it!
@ -220,9 +218,11 @@ K.PrintFYA ldx #$00 CSTR
.10 cmp #'\'
bne .20
ldx #PrintFTBL2.END-PrintFTBL2-1
jsr Printf.GetCharAtPtr1Y
ldx #PrintFTBL2.OUT-PrintFTBL2-1
lda (ZPPtr1),y
beq .99
iny
.12 cmp PrintFTBL2,x
beq .13
dex
@ -238,9 +238,7 @@ K.PrintFYA ldx #$00 CSTR
PrintFESC jmp (PrintFJMP,x)
*--------------------------------------
PrintFTBL1 .AS "abBdDuefhHiILnNsS"
PrintFTBL1.END
PrintFTBL2 .AS "befnr\%"
PrintFTBL2.END
PrintFTBL2.OUT .HS 08.1B.0C.0A.0D \b\e\f\n\r
.DA #'\' \\
.DA #'%' \%
@ -499,28 +497,7 @@ PrintF.SS ldy #$00 PSTR
.8 clc
.9 rts
*--------------------------------------
Printf.GetCharAtPtr1Y
lda #$ff Self Modified PSTR/CSTR
bne .1
lda (ZPPtr1),y CSTR
beq .9
iny advance to next char...
bne .9
inc ZPPtr1+1 Allow >256 CStrings
rts
.1 tya PSTR
cmp (ZPPtr1)
beq .9
iny
lda (ZPPtr1),y NZ
.9 clc no error, but end of string
rts
*--------------------------------------
Printf.Cout jmp K.PutCA
Printf.Cout jmp K.PutCharA
Printf.Cout.Ptr sta $ffff Self modified

View File

@ -1,357 +0,0 @@
PR#3
PREFIX /A2OSX.BUILD
LOMEM $A00
INC 1
AUTO 6
*--------------------------------------
Kernel.Init2 sei
>LDAXI MSG.Init2
jsr PrintFAX
>LDYAI A2osX.GP
>STYA ZPPtr1
>LDYAI A2osX.SYSCALL
>STYA ZPPtr2
>LDYAI A2osX.D1-A2osX.GP^$FFFF
>STYA ZPPtr3
jsr Kernel.Move
sta CLRALTZP
>LDAXI MSG.D2
jsr PrintFAX
sta SETALTZP
lda RRAMWRAMBNK2
lda RRAMWRAMBNK2
>LDYAI A2osX.D2
>STYA ZPPtr1
>LDYAI $D000
>STYA ZPPtr2
>LDYAI A2osX.E0-A2osX.D2^$FFFF
>STYA ZPPtr3
jsr Kernel.Move
sta CLRALTZP
>LDAXI MSG.D1
jsr PrintFAX
sta SETALTZP
lda RRAMWRAMBNK1
lda RRAMWRAMBNK1
>LDYAI A2osX.D1
>STYA ZPPtr1
>LDYAI $D000
>STYA ZPPtr2
>LDYAI A2osX.D2-A2osX.D1^$FFFF
>STYA ZPPtr3
jsr Kernel.Move
sta CLRALTZP
>LDAXI MSG.E0
jsr PrintFAX
sta SETALTZP
lda RRAMWRAMBNK1
lda RRAMWRAMBNK1
>LDYAI A2osX.E0
>STYA ZPPtr1
>LDYAI $E000
>STYA ZPPtr2
>LDYAI A2osX.E0.E-A2osX.E0^$FFFF
>STYA ZPPtr3
jsr Kernel.Move
>LDYAI D.STACK.TOP
>STYA pStack init Soft Stack
sta CLRALTZP Make MAIN ZP is enabled for X.PRINT.F
cli
jsr KConfigLoad
lda A2osX.HZ
pha push HZ
>LDAXI MSG.HZ
jsr PrintFAX
jsr CPU.Init
>LDAXI MSG.Init2.OK
jsr PrintFAX
rts Do NOT replace this JSR/RTS with a JMP
*--------------------------------------
Kernel.Move ldy #0
.1 inc ZPPtr3
bne .2
inc ZPPtr3+1
beq .9
.2 lda (ZPPtr1),y
sta (ZPPtr2),y
iny
bne .1
inc ZPPtr1+1
inc ZPPtr2+1
bne .1
.9 rts
*--------------------------------------
CPU.Init >LDAXI MSG.CPU
jsr PrintFAX
jsr Detect6502 A = CPU type
sta A2osX.CPUTYPE
ldx MSG.CPUTYPEH,y
lda MSG.CPUTYPEL,y
jsr PrintFAX
lda MACHID
and #MACHID.TYPE
cmp #MACHID.TYPE.IIc
beq CPU.Init.Z80
>LDAXI MSG.CPU.SPEED
jsr PrintFAX
stz A2osX.RANDOM16
stz A2osX.RANDOM16+1
php
sei
.1 bit VBL
bpl .2
.2 bit VBL
bmi .2
ldx #0 Count LO
lda #0 Count HI
.3 ldy #3 (2)
.4 nop (2)
dey (2)
bne .4 (2*)
inc A2osX.RANDOM16 (6)
bne .5 (2*)
inc A2osX.RANDOM16+1 (6)
bit VBL (4)
bpl .3 (2*)
bmi .6
.5 nop (2)
nop (2)
nop (2)
bit VBL (4)
bpl .3 (2*)
.6 plp
stz A2osX.CPUSPEED
.7 sec
lda A2osX.RANDOM16
sbc #100
tax
lda A2osX.RANDOM16+1
sbc /100
bcc .8
stx A2osX.RANDOM16
sta A2osX.RANDOM16+1
inc A2osX.CPUSPEED
bra .7
.8 lda A2osX.RANDOM16
sta A2osX.CPUSPEED+1
pha push CPU speed LO
lda A2osX.CPUSPEED
pha push CPU speed HI
>LDAXI MSG.CPU.SPEEDOK
jsr PrintFAX
CPU.Init.Z80 >LDAXI MSG.Z80
jsr PrintFAX
jsr DetectZ80
bcs .9
sta A2osX.Z80SLOT
pha Push Z80Slot
tax
lda #A2osX.SLOTS.Z80
sta A2osX.SLOTS,x
>LDAXI MSG.Z80.OK
jsr PrintFAX
rts
.9 >LDAXI MSG.Z80.KO
jsr PrintFAX
rts
*--------------------------------------
* Out:
* A = $60, 6502
* A = $61, 65C02
* A = $62, 65R02
* A = $63, 65816
*--------------------------------------
Detect6502 ldy #0 Test 6502 BCD bug
sed
lda #$99
clc
adc #$01
cld
bmi .9 BUG!, we have 6502
ldy #3 test 65C816 TYX Instruction
ldx #0
.OP 65816
tyx TYX: if 65C816, x becomes non-zero
.OP 65C02
bne .9 worked! 65C816
dey y=2 -> R65C02
ldx $EA save zp $EA
stz $EA store 0 in $EA
* .OP 65R02
.HS F7EA For compatibility with A2osX.ASM
* smb 7,$EA if not Rockwell, assemble as nop nop
* .OP 65C02
asl $EA cs if Rockwell
stx $EA restore zp $EA
bcs .9
dey y=1 -> 65C02
.9 tya
ora #$60
rts
*--------------------------------------
* Out:
* A = Z80 Slot
*--------------------------------------
DetectZ80 ldx #Z80Code.Size
.1 lda Z80Code.Start-1,x
sta $1000-1,x 00000H for Z80
dex
bne .1
stz ZPPtr1
lda #$C1
sta ZPPtr1+1
.2 sta (ZPPtr1)
lda $100D
bmi .8
inc ZPPtr1+1
lda ZPPtr1+1
cmp #$C8
beq .9 CS
clc
adc #$20
sta $100A
bra .2
.8 lda ZPPtr1+1
and #$0F
clc
.9 rts
*--------------------------------------
KConfigLoad >LDAXI MSG.KCREAD
jsr PrintFAX
jsr MLI
.DA #MLIOPEN
.DA MLIOPEN00
bcs .9
lda MLIOPEN00+5
sta MLIREAD00+1
sta MLICLOSE00+1
jsr MLI
.DA #MLIREAD
.DA MLIREAD00
php
pha
jsr MLI
.DA #MLICLOSE
.DA MLICLOSE00
pla
plp
bcs .9
>LDAXI MSG.KCREAD.OK
jsr PrintFAX
rts
.9 >LDAXI MSG.KCREAD.KO
jsr PrintFAX
rts
*--------------------------------------
Z80Code.Start .HS 31FFFF START: LD SP,0FFFFH Init Stack
.HS 3EFF LD A,0FFH Set Flag
.HS 320D00 LD (FLAG),A
.HS 3200E1 LD (0E100H),A Back to 6502
.HS 18F3 JR START Loop
.HS 00 FLAG: .DB 0
Z80Code.Size .EQ *-Z80Code.Start
*--------------------------------------
MSG.Init2 >CSTR "A2osX[Stage2]:Init\nInstalling KERNEL...\n - $BE00 Global Page...\n"
MSG.D1 >CSTR " - $D000 Bank1...\n"
MSG.D2 >CSTR " - $D000 Bank2...\n"
MSG.E0 >CSTR " - $E000...\n"
MSG.HZ >CSTR "Kernel SYS Timer Set For %d0 hz Machine.\n"
MSG.Init2.OK >CSTR "A2osX[Stage2]:Complete.\n"
*--------------------------------------
MSG.CPU >CSTR "Checking CPU..."
MSG.CPU.SPEED >CSTR "Detecting CPU Speed..."
MSG.CPUTYPEL .DA #MSG.6502
.DA #MSG.65C02
.DA #MSG.65R02
.DA #MSG.65816
MSG.CPUTYPEH .DA /MSG.6502
.DA /MSG.65C02
.DA /MSG.65R02
.DA /MSG.65816
MSG.6502 >CSTR "6502.\n"
MSG.65C02 >CSTR "65C02.\n"
MSG.65R02 >CSTR "65R02.\n"
MSG.65816 >CSTR "65816.\n"
MSG.CPU.SPEEDOK >CSTR "%d.%02d Mhz.\n"
MSG.Z80 >CSTR "Detecting Z80 CPU..."
MSG.Z80.OK >CSTR "Detected In Slot %d.\n"
MSG.Z80.KO >CSTR "Not Detected.\n"
MSG.KCREAD >CSTR "Reading Kernel Config File..."
MSG.KCREAD.OK >CSTR "OK\n"
MSG.KCREAD.KO >CSTR "\nError While Reading Kernel Config File, Using Default.\n"
A2OSXCONF >PSTR "A2osX.KCONFIG"
*--------------------------------------
MLIOPEN00 .DA #3
.DA A2OSXCONF
.DA $1000
.BS 1
*--------------------------------------
MLIREAD00 .DA #4
.BS 1
.DA A2osX.HZ
.DA 16
.BS 2
*--------------------------------------
MLICLOSE00 .DA #1
.BS 1
*--------------------------------------
MAN
SAVE /A2OSX.SRC/SYS/KERNEL.S.INIT2
LOAD /A2OSX.SRC/SYS/KERNEL.S
ASM

View File

@ -1,515 +0,0 @@
PR#3
PREFIX /A2OSX.BUILD
LOMEM $A00
INC 1
AUTO 6
*--------------------------------------
Kernel.Init3 sta SETALTZP
bit RRAMWRAMBNK1
bit RRAMWRAMBNK1
jsr MemMgrInit
jsr PS0Init
bcs *
>LDYAI MSG.Init3
>SYSCALL PrintFYA
>LDYAI MSG.DEV
>SYSCALL PrintFYA
jsr DevMgrInit
bcs *
>LDYAI MSG.IRQ
>SYSCALL PrintFYA
jsr IrqMgrInit
bcs *
>LDYAI MSG.EVT
>SYSCALL PrintFYA
jsr EvtMgrInit
bcs *
>LDYAI MSG.FLT
>SYSCALL PrintFYA
jsr FltMgrInit
bcs *
>LDYAI MSG.TSK
>SYSCALL PrintFYA
jsr TskMgrInit
bcs *
ldy #S.PS.hPREFIX
lda (pPs),y
>SYSCALL GetMemPtrA
>PUSHYA
>LDYAI MSG.Prefix
>SYSCALL PrintFYA
>PUSHWI STARTUP.CMDLINE
>LDYAI MSG.Startup
>SYSCALL PrintFYA
>LDYAI STARTUP.CMDLINE
>SYSCALL ExpandPStrYA
phx Save Expanded CMDLINE for discard
>SYSCALL CreateProcessYA
bcs .9
pla
>SYSCALL FreeMemA ...discard...
>LDYAI MSG.Init3.OK
>SYSCALL PrintFYA
>LDYAI TskMgr.Table
>STYA pPs
>DEBUGOA
bit RRAMWRAMBNK2
bit RRAMWRAMBNK2
jmp K.KernelRun
.9 >PUSHA
>LDYAI MSG.StartupErr
>SYSCALL PrintFYA
bra * No need to discard Expanded CMDLINE
*--------------------------------------
MemMgrInit >LDYAI MemMgr.MHiMem
>STYA MemMgr.HiMem
>STYA MemMgr.Free
>LDYAI MemMgr.MLoMem
>STYA MemMgr.LoMem
stz MemMgr.LastSlot Reserve Slot #0
sta SETWRITEAUX
>LDYAI MemMgr.XHiMem
>STYA MemMgr.HiMem
>STYA MemMgr.Free
>LDYAI MemMgr.XLoMem
>STYA MemMgr.LoMem
stz MemMgr.LastSlot Reserve Slot #0
sta CLRWRITEAUX
rts
*--------------------------------------
PS0Init ldx #S.DEV*2 NUL,SYS
.1 lda DevMgr.NUL-1,x
sta DevMgr.Table-1,x
dex
bne .1
lda #2
sta DevMgr.Count
>LDYAI TskMgr.Table Select Process 0 (Kernel)
>STYA pPs
ldy #S.PS-1
lda #0
.2 sta (pPs),y Blank PS0
dey
bpl .2
>LDYAI DEV.SYS
>SYSCALL MkNodYA
bcs .9
ldy #S.PS.hStdIn
sta (pPs),y
ldy #S.PS.hStdOut
sta (pPs),y
ldy #S.PS.hStdErr
sta (pPs),y
clc
.9 rts
*--------------------------------------
DevMgr.NUL cld
jmp (DevMgr.NUL.Code,x)
.DA #S.DEV.S.WRITE+S.DEV.S.READ+S.DEV.S.OPENED
.BS 6
>PSTR "NUL" NAME
.HS 00 NAME must Be 4 bytes long
*--------------------------------------
DevMgr.SYS cld
jmp (DevMgr.SYS.Code,x)
.DA #S.DEV.S.WRITE+S.DEV.S.READ
.BS 6
>PSTR "SYS" NAME
.HS 00 NAME must Be 4 bytes long
*--------------------------------------
* Setup AuxLC $FFFE->Kernel IRQ Handler
* if irq not handled, jmp (S.IrqMgrOldFFFE)
*--------------------------------------
SETMOUSE .EQ $12 Sets mouse mode
SERVEMOUSE .EQ $13 Services mouse interrupt
READMOUSE .EQ $14 Reads mouse position
*--------------------------------------
IrqMgrInit php
sei
>LDYA $FFFE
>STYA K.IrqMgrOldFFFE
>LDYAI K.IrqHandlerAuxLC
>STYA $FFFE
>LDYAI IrqHandler
>STYA K.MLI.PARAMS+2
>MLICALL MLIALLOCIRQ
bcs .9
lda K.MLI.PARAMS+1
sta ProDOS.INTNUM
stz ZPPtr1 Try finding a Mouse Card...
lda #$C1
sta ZPPtr1+1
.1 ldx #Mouse.SIG-Mouse.OFS-1
.2 ldy Mouse.OFS,x
lda (ZPPtr1),y
cmp Mouse.SIG,x
bne .3
dex
bpl .2
bra .4
.3 inc ZPPtr1+1 no match, try next slot....
lda ZPPtr1+1
cmp #$C8
bne .1
plp
clc
rts
.9 plp
sec
rts
.4 lda ZPPtr1+1
sta K.IrqMgrVBL.MSM+2
sta K.IrqMgrVBL.MRM+2
and #$0f
sta K.IrqMgrVBL.0n
asl
asl
asl
asl
sta K.IrqMgrVBL.n0
ldy #SERVEMOUSE
lda (ZPPtr1),y
sta K.IrqMgrVBL.MSM+1
ldy #READMOUSE
lda (ZPPtr1),y
sta K.IrqMgrVBL.MRM+1
bit RROMBNK2 Renable ROM to allow MOUSE II firmware works properly
ldy #SETMOUSE
lda (ZPPtr1),y
sta .7+1
lda #9 #MOUSEMODx.INTVBL+MOUSEMODx.ACTIVE
ldx ZPPtr1+1 DEVSLOTCn
stx .7+2
ldy K.IrqMgrVBL.n0
.7 jsr $ffff self Modified, CALL SETMOUSE
bcs *
bit RRAMWRAMBNK1 Back To LC Ram
bit RRAMWRAMBNK1
inc K.IrkMgr.VBL set=1 awaiting IrqMgr confirmation
plp
clc
rts
*--------------------------------------
Mouse.OFS .HS 05070B0CFB
Mouse.SIG .HS 38180120D6
*--------------------------------------
DevMgrInit stz ZPPtr1
lda #$C1
sta ZPPtr1+1
lda #1
sta DEV.HEADER+S.DEV.BUSID
.1 lda #1
sta DEV.HEADER+S.DEV.DEVID
ldx #SmartPort.SIG-SmartPort.OFS-1
.2 ldy SmartPort.OFS,x Check if there is a smartport firmware
lda (ZPPtr1),y
cmp SmartPort.SIG,x
bne .8 not a Disk Controller...
dex
bpl .2
ldy #$ff
lda (ZPPtr1),y
bne .3 $0, Disk II, 16sect
jsr DevMgrInit.DII
ldy #A2osX.SLOTS.DII
bra .7
.3 inc
beq .7 $ff, Disk II 13 Sect, ignore
ldy #7
lda (ZPPtr1),y
bne .4 $Cn07=00 : SmartPort
jsr DevMgrInit.SP
ldy #A2osX.SLOTS.SP
bra .7
.4 jsr DevMgrInit.BLK
ldy #A2osX.SLOTS.BLK
.7 lda ZPPtr1+1
and #$0f
tax
tya
sta A2osX.SLOTS,x
.8 inc DEV.HEADER+S.DEV.BUSID
inc ZPPtr1+1
lda ZPPtr1+1
cmp #$C8
bne .1
clc
rts
*--------------------------------------
DevMgrInit.DII >LDYAI A2osX.DIIDrv
>STYA DEV.HEADER+S.DEV.DRV.JMP
jsr DevMgrInit.AddDev
inc DEV.HEADER+S.DEV.DEVID
jsr DevMgrInit.AddDev
rts
*--------------------------------------
DevMgrInit.BLK ldy #$ff
lda (ZPPtr1),y
sta DEV.HEADER+S.DEV.ROM.JMP
lda ZPPtr1+1
sta DEV.HEADER+S.DEV.ROM.JMP+1
>LDYAI A2osX.BlkDrv
>STYA DEV.HEADER+S.DEV.DRV.JMP
jsr DevMgrInit.AddDev
inc DEV.HEADER+S.DEV.DEVID
jsr DevMgrInit.AddDev
rts
*--------------------------------------
DevMgrInit.SP ldy #$ff
lda (ZPPtr1),y
clc
adc #3 Compute smartport entry point
sta .1+1
sta .3+1
sta DEV.HEADER+S.DEV.ROM.JMP
lda ZPPtr1+1
sta .1+2
sta .3+2
sta DEV.HEADER+S.DEV.ROM.JMP+1
>LDYAI A2osX.PrtDrv
>STYA DEV.HEADER+S.DEV.DRV.JMP
.1 jsr $ffff Self Modified
.DA #0 Status
.DA SP.CTRL.STATUS
bcs .9
lda SP.CTRL.STATUS.DATA
beq .9 no device
.2 lda #1
sta SP.DEV.STATUS.DEVID
.3 jsr $ffff Self Modified
.DA #0 Status
.DA SP.DEV.STATUS
bcs .7
lda SP.DEV.STATUS.DATA+S.DEVSTAT.S
sta DEV.HEADER+S.DEV.S
jsr DevMgrInit.AddDev
.7 inc SP.DEV.STATUS.DEVID
inc DEV.HEADER+S.DEV.DEVID
dec SP.CTRL.STATUS.DATA
bne .3
.9 rts
*--------------------------------------
DevMgrInit.AddDev
lda DevMgr.Count
cmp #K.DEV.MAX
beq .9
inc DevMgr.Count
>SYSCALL GetDevByIDA
>STYA ZPPtr2
lda DEV.HEADER+S.DEV.BUSID
ora #$30
sta DEV.HEADER+S.DEV.NAME+2 SnDy
lda DEV.HEADER+S.DEV.DEVID
ora #$30
sta DEV.HEADER+S.DEV.NAME+4 SxDn
ldy #S.DEV-1
.1 lda DEV.HEADER,y
sta (ZPPtr2),y
dey
bpl .1
clc
rts
.9 lda #DEVMGR.ERROOH
sec
rts
*--------------------------------------
DEV.HEADER clc
jmp ($ffff,x)
.DA #S.DEV.S.BLOCK S
.BS 1 F
.BS 1 BUS.ID
.BS 1 DEV.ID
.BS 2 ROM.JMP
.BS 1
>PSTR "S1D1" 5 bytes
*--------------------------------------
SmartPort.OFS .HS 010305
SmartPort.SIG .HS 200003
*--------------------------------------
SP.CTRL.STATUS .DA #3
.DA #0
.DA SP.CTRL.STATUS.DATA
.DA #0
SP.CTRL.STATUS.DATA
.BS 8 DevCnt
SP.DEV.STATUS .DA #3
SP.DEV.STATUS.DEVID
.BS 1
.DA SP.DEV.STATUS.DATA
.DA #3 return DIB
SP.DEV.STATUS.DATA
.BS S.DEVSTAT
*--------------------------------------
EvtMgrInit lda #$A5
sta A2osX.TIMER16
lda #$9B
sta A2osX.TIMER16+1
lda /EvtMgr.Table
sta pEvent+1
clc
rts
*--------------------------------------
FltMgrInit stz FltMgr.Table
clc
rts
*--------------------------------------
TskMgrInit >LDYAI TskMgr.Table+S.PS Clear whole process table except PS0
>STYA .2+1
ldx #K.PS.MAX-1
.1 lda #0
ldy #S.PS-1
.2 sta $ffff,y Self Modified
dey
bpl .2
lda .2+1
clc
adc #S.PS
sta .2+1
bcc .3
inc .2+2
.3 dex
bne .1
>LDYAI K.ENV.SIZE get a buffer for ENV
>SYSCALL GetMem0YA make sure blank!!
bcs .9
txa
ldy #S.PS.hENV
sta (pPs),y
>LDYAI UsrBuf256
>STYA K.MLI.PARAMS+1
>MLICALL MLIGETPREFIX
bcs .9
>LDYAI UsrBuf256
>SYSCALL NewPStrYA
bcs .9
txa
ldy #S.PS.hPREFIX
sta (pPs),y
>PUSHWI UsrBuf256 push ENV value
>PUSHWI I.ENV.A2osX push ENV name
>SYSCALL SetEnv
bcs .9
>LDYAI I.ENV.PATH
>SYSCALL PutEnvYA
bcs .9
>LDYAI I.ENV.LIB
>SYSCALL PutEnvYA
bcs .9
>LDYAI I.ENV.DRV
>SYSCALL PutEnvYA
.9 rts
*--------------------------------------
DEV.SYS >PSTR "SYS"
I.ENV.A2osX >PSTR "A2OSX"
I.ENV.PATH >PSTR "PATH=${A2OSX}SBIN/;${A2OSX}BIN/"
I.ENV.LIB >PSTR "LIB=${A2OSX}LIB/"
I.ENV.DRV >PSTR "DRV=${A2OSX}DRV/"
STARTUP.CMDLINE >PSTR "${A2OSX}SBIN/SHELL ${A2OSX}A2osX.STARTUP"
*--------------------------------------
MSG.Init3 >CSTR "A2osX[Stage3]:Init\r\n"
MSG.DEV >CSTR "-Device Manager...\r\n"
MSG.IRQ >CSTR "-Interrupt Manager...\r\n"
MSG.EVT >CSTR "-Event Manager...\r\n"
MSG.FLT >CSTR "-Path Filter...\r\n"
MSG.TSK >CSTR "-Task Manager...\r\n"
MSG.Prefix >CSTR "Prefix:%S\r\n"
MSG.Startup >CSTR "Executing Kernel Startup Script...\r\nCmd:%S\r\n"
MSG.StartupErr >CSTR "Failed : [$%h]\r\n"
MSG.Init3.OK >CSTR "A2osX[Stage3]:Complete.\r\n"
*--------------------------------------
MAN
SAVE /A2OSX.SRC/SYS/KERNEL.S.INIT3
LOAD /A2OSX.SRC/SYS/KERNEL.S
ASM

View File

@ -112,9 +112,9 @@ K.SYSCALL.JMP .DA K.FileSearch $00
.DA 0
*--------------------------------------
.DA K.FPutCAY $B0
.DA K.PutCA
.DA K.FGetCA
.DA K.GetC
.DA K.PutCharA
.DA K.GetCA
.DA K.GetChar
.DA K.FPutS
.DA K.PutSYA
.DA K.FGetS