mirror of
https://github.com/A2osX/A2osX.git
synced 2024-08-16 11:29:21 +00:00
407 lines
8.1 KiB
Plaintext
407 lines
8.1 KiB
Plaintext
PR#3
|
||
PREFIX /A2OSX.SRC
|
||
LOMEM $A00
|
||
INC 1
|
||
AUTO 6
|
||
.LIST OFF
|
||
*--------------------------------------
|
||
Kernel.Init3 jsr MemMgrInit
|
||
jsr PS0Init
|
||
bcs *
|
||
|
||
>LDYAI MSG.Init3
|
||
>SYSCALL CPrintFYA
|
||
|
||
>LDYAI MSG.IRQ
|
||
>SYSCALL CPrintFYA
|
||
jsr IrqMgrInit
|
||
bcs *
|
||
|
||
>LDYAI MSG.DEV
|
||
>SYSCALL CPrintFYA
|
||
jsr DevMgrInit
|
||
bcs *
|
||
|
||
>LDYAI MSG.EVT
|
||
>SYSCALL CPrintFYA
|
||
jsr EvtMgrInit
|
||
bcs *
|
||
|
||
>LDYAI MSG.FLT
|
||
>SYSCALL CPrintFYA
|
||
jsr FltMgrInit
|
||
bcs *
|
||
|
||
>LDYAI MSG.TSK
|
||
>SYSCALL CPrintFYA
|
||
jsr TskMgrInit
|
||
bcs *
|
||
|
||
ldy #S.PS.hPREFIX
|
||
lda (pPs),y
|
||
>SYSCALL GetMemPtrA
|
||
|
||
>PUSHYA
|
||
>LDYAI MSG.Prefix
|
||
>SYSCALL CPrintFYA
|
||
|
||
>PUSHWI STARTUP.CMDLINE
|
||
>LDYAI MSG.Startup
|
||
>SYSCALL CPrintFYA
|
||
|
||
>LDYAI STARTUP.CMDLINE
|
||
>SYSCALL ExpandPStrYA
|
||
phx Save Expanded CMDLINE for discard
|
||
>SYSCALL CreateProcessYA
|
||
bcs .9
|
||
pla
|
||
>SYSCALL FreeMemA ...discard...
|
||
|
||
>LDYAI MSG.Init3.OK
|
||
>SYSCALL CPrintFYA
|
||
|
||
>LDYAI TskMgr.Table
|
||
>STYA pPs
|
||
|
||
>DEBUGOA
|
||
|
||
bit RRAMWRAMBNK2
|
||
bit RRAMWRAMBNK2
|
||
jmp K.KernelRun
|
||
|
||
.9 >PUSHA
|
||
>LDYAI MSG.StartupErr
|
||
>SYSCALL CPrintFYA
|
||
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 .DA DevMgr.NUL.Code
|
||
.DA #S.DEV.S.WRITE+S.DEV.S.READ+S.DEV.S.OPENED
|
||
.DA #3
|
||
.AS "NUL" NAME
|
||
.HS 00 NAME must Be 4 bytes long
|
||
*--------------------------------------
|
||
DevMgr.SYS .DA DevMgr.SYS.Code
|
||
.DA #S.DEV.S.WRITE+S.DEV.S.READ+3
|
||
.DA #3
|
||
.AS "SYS" NAME
|
||
.HS 00 NAME must Be 4 bytes long
|
||
*--------------------------------------
|
||
* Setup AuxLC $FFFE->Kernel IRQ Handler
|
||
* if irq not handled, jmp (S.IrqMgrOldFFFE)
|
||
*--------------------------------------
|
||
IrqMgrInit php
|
||
sei
|
||
>LDYA $FFFE
|
||
>STYA K.IrqMgrOldFFFE
|
||
>LDYAI K.IrqHandlerAuxLC
|
||
>STYA $FFFE
|
||
plp
|
||
|
||
>LDYAI IrqHandler
|
||
>STYA MLICALL.PARAMS+2
|
||
>MLICALL MLIALLOCIRQ
|
||
bcs .9
|
||
|
||
lda MLICALL.PARAMS+1
|
||
sta ProDOS.INTNUM
|
||
|
||
.9 rts
|
||
*--------------------------------------
|
||
DevMgrInit stz ZPPtr1
|
||
lda #$C1
|
||
sta ZPPtr1+1
|
||
lda #'1'
|
||
sta SP.DEV+5 S1Dy
|
||
|
||
.1 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 .3 not a smartport...
|
||
dex
|
||
bpl .2
|
||
*SmartPort!!!
|
||
jsr DevMgrInit.SP
|
||
ldy #A2osX.SLOTS.SP
|
||
bra .7
|
||
* Disk II, or Block device ?
|
||
.3 dex if x=0, only first SIG byte failed
|
||
bpl .8
|
||
|
||
ldy #$ff
|
||
lda (ZPPtr1),y
|
||
bne .4 $0, Disk II, 16sect
|
||
|
||
jsr DevMgrInit.DII
|
||
ldy #A2osX.SLOTS.DII
|
||
bra .7
|
||
|
||
.4 inc
|
||
beq .7 $ff, Disk II, 13sect, ignore
|
||
dec
|
||
* Block device
|
||
jsr DevMgrInit.BLK
|
||
ldy #A2osX.SLOTS.BLK
|
||
|
||
.7 lda ZPPtr1+1
|
||
and #$0f
|
||
tax
|
||
tya
|
||
sta A2osX.SLOTS,x
|
||
|
||
.8 inc SP.DEV+5
|
||
inc ZPPtr1+1
|
||
lda ZPPtr1+1
|
||
cmp #$C8
|
||
bne .1
|
||
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
DevMgrInit.SP ldy #$ff
|
||
lda (ZPPtr1),y
|
||
clc
|
||
adc #3 Compute smartport entry point
|
||
sta .1+1
|
||
sta .3+1
|
||
sta SP.DEV+S.DEV.JMP
|
||
lda ZPPtr1+1
|
||
sta .1+2
|
||
sta .3+2
|
||
sta SP.DEV+S.DEV.JMP+1
|
||
|
||
.1 jsr $ffff Self Modified
|
||
.DA #0 Status
|
||
.DA SP.CTRL.STATUS
|
||
bcs .9
|
||
lda SP.STATUS1
|
||
beq .9 no device
|
||
|
||
.2 lda #1
|
||
sta SP.DEV.STATUS+1
|
||
lda #'1'
|
||
sta SP.DEV+7 SxD1
|
||
|
||
.3 jsr $ffff Self Modified
|
||
.DA #0 Status
|
||
.DA SP.DEV.STATUS
|
||
bcs .7
|
||
lda SP.STATUS2+S.DEVSTAT.S
|
||
sta SP.DEV+S.DEV.S
|
||
|
||
|
||
|
||
|
||
|
||
|
||
.7 inc SP.DEV+7
|
||
dec SP.STATUS1
|
||
bne .3
|
||
|
||
.9 rts
|
||
*--------------------------------------
|
||
DevMgrInit.DII
|
||
rts
|
||
*--------------------------------------
|
||
DevMgrInit.BLK
|
||
rts
|
||
*--------------------------------------
|
||
DevMgrInit.AddDev
|
||
lda DevMgr.Count
|
||
inc DevMgr.Count
|
||
jsr K.GetDevByIDA
|
||
>STYA ZPPtr1
|
||
rts
|
||
*--------------------------------------
|
||
SmartPort.OFS .HS 07010305
|
||
SmartPort.SIG .HS 00200003
|
||
*--------------------------------------
|
||
SP.CTRL.STATUS .DA #3
|
||
.DA #0
|
||
.DA SP.STATUS1
|
||
.DA #0 return S only
|
||
SP.DEV.STATUS .DA #3
|
||
.BS 1
|
||
.DA SP.STATUS2
|
||
.DA #3 return DIB
|
||
SP.STATUS1 .BS 4
|
||
SP.STATUS2 .BS S.DEVSTAT
|
||
*--------------------------------------
|
||
SP.DEV .BS 2 JMP
|
||
.BS 1 S
|
||
>PSTR "S1D1" 5 bytes
|
||
*--------------------------------------
|
||
SP.DRV cld
|
||
ldy #7
|
||
lda (pDev),y
|
||
and #$f
|
||
sta PRTCALL.PARAMS+1 dev
|
||
SP.DRV.lo ldy #$ff
|
||
SP.DRV.hi lda #$ff
|
||
jmp A2osX.PRTCALL
|
||
*--------------------------------------
|
||
BLK.DRV
|
||
*--------------------------------------
|
||
EvtMgrInit
|
||
* lda #10
|
||
* sta EVTMGR.10TH.CNT WARNING!!!! WRONG BANK!!!
|
||
|
||
* lda A2osX.HZ
|
||
* sta EVTMGR.HZ.CNT
|
||
|
||
lda MACHID
|
||
and #MACHID.TYPE
|
||
cmp #MACHID.TYPE.IIc
|
||
bne .8
|
||
|
||
* sta CLRIOUDIS
|
||
* sta ENBVBLIIC
|
||
|
||
.8 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
|
||
|
||
>PUSHWI K.ENV.SIZE get a buffer for ENV
|
||
>PUSHBI S.MEM.F.INIT0 make sure blank
|
||
>SYSCALL GetMem create it...
|
||
bcs .9
|
||
|
||
txa
|
||
ldy #S.PS.hENV
|
||
sta (pPs),y
|
||
|
||
>LDYAI UsrBuf256
|
||
>STYA MLICALL.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\n"
|
||
MSG.IRQ >CSTR "-Interrupt Manager...\n"
|
||
MSG.DEV >CSTR "-Device Manager...\n"
|
||
MSG.EVT >CSTR "-Event Manager...\n"
|
||
MSG.FLT >CSTR "-Path Filter...\n"
|
||
MSG.TSK >CSTR "-Task Manager...\n"
|
||
MSG.Prefix >CSTR "Prefix:%S\n"
|
||
MSG.Startup >CSTR "Executing Kernel Startup Script...\nCmd:%S\n"
|
||
MSG.StartupErr >CSTR "Failed : [$%h]\n"
|
||
MSG.Init3.OK >CSTR "A2osX[Stage3]:Complete.\n"
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE SYS/KERNEL.S.INIT3
|
||
LOAD SYS/KERNEL.S
|
||
ASM
|