A2osX/SYS/KERNEL.S.txt
2015-10-20 10:31:11 +02:00

351 lines
7.3 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
.LIST OFF
.OP 65C02
.OR $D000
.TF /A2OSX.BOOT/SYS/KERNEL
*--------------------------------------
.INB INC/MACROS.I
.INB INC/KERNEL.I
.INB INC/A2OSX.I
.INB INC/A2OSX.API.I
.INB INC/IO.I
.INB INC/PRODOS.I
*--------------------------------------
KERNEL jmp S.KernelInit KERNEL.COLDBOOT
*--------------------------------------
jmp (.1,x) KERNEL.SYSCALL
*--------------------------------------
.1 .DA S.GetMem $00
.DA S.FreeMemA
.DA S.GetMemPtrA
.DA S.GetMemByIDA
.DA S.GetMemByNameA
.DA S.GetMemByNameYA
.DA 0
.DA 0
*--------------------------------------
.DA S.NewPStrYA $10
.DA S.PStrCpyA
.DA S.PStrCat
.DA S.PStrCmp
.DA S.PStrGetTkn
.DA 0
.DA 0
.DA 0
*--------------------------------------
.DA S.LoadBinA $20
.DA S.LoadLibYA
.DA S.UnloadLibA
.DA S.LoadDrvA
.DA 0
.DA 0
.DA 0
.DA 0
*--------------------------------------
.DA S.ExpandPStrA $30
.DA S.ExpandPStrYA
.DA S.GetEnvVarH
.DA S.GetEnvVarP
.DA S.SetEnvVarH
.DA S.SetEnvVarP
.DA 0
.DA 0
*--------------------------------------
.DA S.MLICreateFile $40
.DA S.MLICreateDirA
.DA S.MLICreateDirYA
.DA S.MLIDestroyA
.DA S.MLIDestroyYA
.DA S.MLIRename
.DA S.MLISetFileInfo
.DA S.MLIGetFileInfoA
.DA S.MLIGetFileInfoYA $50
.DA S.MLIOnline
.DA S.MLISetPrefixA
.DA S.MLISetPrefixYA
.DA S.MLIGetPrefixA
.DA S.MLIGetPrefixYA
.DA S.MLIOpenA
.DA S.MLIOpenYA
.DA S.MLINewLine $60
.DA S.MLIRead
.DA S.MLIWrite
.DA S.MLICloseA
.DA S.MLIFlushA
.DA S.MLISetMark
.DA S.MLIGetMarkA
.DA S.MLISetEOF
.DA S.MLIGetEOFA $70
.DA S.MLISetBuf
.DA S.MLIGetBuf
.DA S.MLIGetTime
.DA S.MLIAllocIRQ
.DA S.MLIDeallocIRQA
.DA S.MLIReadBlock
.DA S.MLIWriteBlock
*--------------------------------------
.DA S.GetDevByIDA $80
.DA S.GetDevByNameA
.DA S.GetDevByNameYA
.DA 0
.DA S.GetKeyboardEvent
.DA 0
.DA 0
.DA 0
*--------------------------------------
.DA S.ExecProcessNewEnvA $90
.DA S.ExecProcessA
.DA S.CreateProcessNewEnvA
.DA S.CreateProcessA
.DA S.GetPSByIDA
.DA 0
.DA 0
.DA 0
*--------------------------------------
.DA S.CheckPrefixA $A0
.DA S.FileSearch
.DA S.LoadFileA
.DA S.LoadFileYA
.DA S.ListDirInitA
.DA S.ListDirNextA
.DA S.ListDirCloseA
.DA 0
*--------------------------------------
.DA S.AddNetCfg $B0
.DA S.SetNetCfg
.DA S.GetNetCfgA
.DA S.ClrNetCfgA
.DA 0
.DA 0
.DA 0
.DA 0
*--------------------------------------
.DA S.ScreenSelectA $C0
.DA 0
.DA S.SysScrPPSTRA
.DA S.SysScrPPSTRYA
*--------------------------------------
S.KernelInit sei
ldx #$FF init 6502 stack to highest
txs
stx A2osX.SaveSM
stx A2osX.SaveSX
cli
>LDYAI D.STACK.TOP
>STYA pStack init Soft Stack
stz A2osX.SCREENS
stz A2osX.ASCREEN
stz A2osX.CSCREEN.DEV
stz A2osX.GSCREEN.DEV
jsr S.SysScrInit
>LDYAI MSG.Init
jsr S.SysScrPPSTRYA
>LDYAI MSG.Init.MemMgr
jsr S.SysScrPPSTRYA
jsr S.MemMgrInit
jsr S.SysScrPRCode
bcs .1
>LDYAI MSG.Init.TskMgr
jsr S.SysScrPPSTRYA
jsr S.TskMgrInit
jsr S.SysScrPRCode
.1 bcs .2
>LDYAI MSG.Init.DevMgr
jsr S.SysScrPPSTRYA
jsr S.DevMgrInit
jsr S.SysScrPRCode
.2 bcs .3
>LDYAI MSG.Init.EvtMgr
jsr S.SysScrPPSTRYA
jsr S.EvtMgrInit
jsr S.SysScrPRCode
.3 bcs .99
>LDYAI MSG.Init.Startup
jsr S.SysScrPPSTRYA
>LDYAI STARTUP.FILE Build A2osX.STARTUP full path...
jsr S.NewPStrYA
pha save for discard
>PUSHA
>PUSHWI ENV.A2osX get KRNL root path
ldy #S.PS.hENV
lda TskMgr.Table,y
>PUSHA
jsr S.GetEnvVarP
pha save for discard
>PUSHA
jsr S.PStrCat
pha save for discard
jsr S.ExecFileA
jsr S.SysScrPRCode
bcs *
pla
jsr S.FreeMemA
pla
jsr S.FreeMemA
pla
jsr S.FreeMemA
>LDYAI MSG.Init.SysEnv
jsr S.SysScrPPSTRYA
jsr S.PrintSysEnv
.99 bcs *
>LDYAI MSG.Init.OK
jsr S.SysScrPPSTRYA
*--------------------------------------
S.KernelRun jsr S.TskMgrRun
bcs .98
jsr S.SysScrCPULoad
jsr S.GetEvent
bcs S.KernelRun CS=no event
jsr S.DispatchEvent
bcc S.KernelRun CC=Event Dispatched
lda (pEvent)
and #S.EVT.F.TIMER Discard any TIMER event
beq .1
jsr S.DestroyEvent
bra S.KernelRun
.1 lda (pEvent)
and #S.EVT.F.KEY any special key?
beq .99
ldy #S.EVT.DATAHI Open-Apple?
lda (pEvent),y
bpl .99
ldy #S.EVT.DATALO
lda (pEvent),y
cmp #$31
bne .2
lda #A2osX.SCREENS.S
jsr S.ScreenSelectA
bra .8
.2 cmp #$32
bne .3
lda #A2osX.SCREENS.C
jsr S.ScreenSelectA
bra .8
.3 cmp #$33
bne .8
lda #A2osX.SCREENS.G
jsr S.ScreenSelectA
.8 jsr S.DestroyEvent
bra S.KernelRun
.98 lda #A2osX.SCREENS.S
jsr S.ScreenSelectA
>LDYAI MSG.KRNLPANIC
jsr S.SysScrPPSTRYA
bra *
.99 >LDYAI MSG.EVNTPANIC
jsr S.SysScrPPSTRYA
jsr S.DumpEvent
jsr S.DestroyEvent
jmp S.KernelRun
*--------------------------------------
S.PrintSysEnv ldy #S.PS.hENV
lda TskMgr.Table,y Get PS #0 ENV
jsr S.GetMemPtrA
>STYA R.AX
.1 lda (R.AX)
beq .8 Ending 0 ?
>LDYA R.AX
jsr S.SysScrPPSTRYA
jsr S.SysScrCROUT
lda R.AL
sec
adc (R.AX) Add len+1 to PTR
sta R.AL
bcc .1
inc R.AH
bra .1
.8 rts
*--------------------------------------
pDevJmp jmp (pDev)
pCodeJmp jmp (pCode)
pLibJmp jmp (pLib)
*--------------------------------------
MSG.Init >PSTRING "A2osX[Stage2]:Init\n"
MSG.Init.MemMgr >PSTRING "->MemMgr Init"
MSG.Init.TskMgr >PSTRING "->TskMgr Init"
MSG.Init.DevMgr >PSTRING "->DevMgr Init"
MSG.Init.EvtMgr >PSTRING "->EvtMgr Init"
MSG.Init.Startup >PSTRING "EXEC A2osX.Startup...\n"
MSG.Init.SysEnv >PSTRING "SYS ENV:\n"
MSG.Init.OK >PSTRING "A2osX[Stage2]:Complete."
MSG.EVNTPANIC >PSTRING "\nEVT:F/hDev/DATA/W1/W2="
MSG.KRNLPANIC >PSTRING "\n\n!!!Kernel Panic!!!"
*--------------------------------------
STARTUP.FILE >PSTRING "A2osX.STARTUP"
*--------------------------------------
ENV.A2osX >PSTRING "A2OSX"
ENV.PATH >PSTRING "PATH"
ENV.LIB >PSTRING "LIB"
*--------------------------------------
.INB SYS/KERNEL.S.MEM
.INB SYS/KERNEL.S.SCR
.INB SYS/KERNEL.S.STR
.INB SYS/KERNEL.S.FS
.INB SYS/KERNEL.S.MLI
.INB SYS/KERNEL.S.BIN
.INB SYS/KERNEL.S.DRV
.INB SYS/KERNEL.S.LIB
.INB SYS/KERNEL.S.NET
.INB SYS/KERNEL.S.RDR
.INB SYS/KERNEL.S.ENV
.INB SYS/KERNEL.S.TSK
.INB SYS/KERNEL.S.EVT
.INB SYS/KERNEL.S.EXE
*--------------------------------------
.INB SYS/KERNEL.S.DEV
*--------------------------------------
MAN
SAVE SYS/KERNEL.S
ASM