mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-24 14:31:05 +00:00
239 lines
4.3 KiB
Plaintext
239 lines
4.3 KiB
Plaintext
NEW
|
||
AUTO 3,1
|
||
.LIST OFF
|
||
.OP 65C02
|
||
.OR $2000
|
||
.TF sbin/initd
|
||
*--------------------------------------
|
||
INITDDBG .EQ 0
|
||
*--------------------------------------
|
||
.INB inc/macros.i
|
||
.INB inc/a2osx.i
|
||
.INB inc/mli.i
|
||
*--------------------------------------
|
||
* Zero Page Segment, up to 32 bytes
|
||
*--------------------------------------
|
||
.DUMMY
|
||
.OR ZPBIN
|
||
ZS.START
|
||
BufPtr .BS 2
|
||
hBuf .BS 1
|
||
hFile .BS 1
|
||
ZS.END .ED
|
||
*--------------------------------------
|
||
* File Header (16 Bytes)
|
||
*--------------------------------------
|
||
CS.START cld
|
||
jmp (.1,x)
|
||
.DA #$61 6502,Level 1 (65c02)
|
||
.DA #1 BIN Layout Version 1
|
||
.DA #0 S.PS.F.EVENT
|
||
.DA #0
|
||
.DA CS.END-CS.START Code Size (without Constants)
|
||
.DA DS.END-DS.START Data SegmentSize
|
||
.DA #16 Stack Size
|
||
.DA #ZS.END-ZS.START Zero Page Size
|
||
.DA 0
|
||
*--------------------------------------
|
||
* Relocation Table
|
||
*--------------------------------------
|
||
.1 .DA CS.INIT
|
||
.DA CS.RUN
|
||
.DA CS.DOEVENT
|
||
.DA CS.QUIT
|
||
L.MSG.CTRLR .DA MSG.CTRLR
|
||
.DO INITDDBG=1
|
||
L.MSG.ETCINIT .DA MSG.ETCINIT
|
||
L.MSG.START .DA MSG.START
|
||
L.MSG.OK .DA MSG.OK
|
||
L.MSG.KO .DA MSG.KO
|
||
.FIN
|
||
L.ETCINIT .DA ETCINIT
|
||
L.CMDS .DA BINSH
|
||
.DA BINMEM
|
||
.DA BINPS
|
||
.DA BINLSOF
|
||
.DA BINSHUTDOWN
|
||
.DA 0
|
||
*--------------------------------------
|
||
CS.INIT
|
||
*--------------------------------------
|
||
CS.QUIT clc
|
||
rts
|
||
*--------------------------------------
|
||
CS.RUN .DO INITDDBG=1
|
||
>LDYA L.MSG.START
|
||
>SYSCALL PutS
|
||
.FIN
|
||
|
||
ldy #S.PS.PID
|
||
lda (pPS),y
|
||
cmp #1
|
||
bne .9
|
||
|
||
ldy #S.PS.hStdIn
|
||
lda (pPS),y
|
||
>SYSCALL FEOF
|
||
bcs .99
|
||
|
||
tay
|
||
bne .1
|
||
|
||
>SYSCALL GetChar
|
||
bcs .99
|
||
|
||
cmp #18 CTRL-R for Root mode
|
||
bne .1
|
||
|
||
>LDYA L.MSG.CTRLR
|
||
>SYSCALL PutS
|
||
|
||
ldx #0
|
||
jsr CS.RUN.EXEC.X
|
||
|
||
>SLEEP
|
||
*--------------------------------------
|
||
.1 .DO INITDDBG=1
|
||
>LDYA L.MSG.ETCINIT
|
||
>SYSCALL PutS
|
||
.FIN
|
||
|
||
jsr CS.RUN.ETCINIT
|
||
bcs .99
|
||
*--------------------------------------
|
||
.2 >SYSCALL GetChar
|
||
bcs .99
|
||
|
||
ldy #4
|
||
|
||
.3 cmp CTRLCHARS,y
|
||
beq .7
|
||
|
||
dey
|
||
bpl .3
|
||
|
||
bra .2
|
||
|
||
.7 tya
|
||
asl
|
||
tax
|
||
jsr CS.RUN.EXEC.X
|
||
bra .2
|
||
|
||
.9 lda #E.SYN
|
||
sec
|
||
.99 rts
|
||
*--------------------------------------
|
||
CS.RUN.ETCINIT >LDYAI 256
|
||
>SYSCALL GetMem
|
||
>STYA BufPtr
|
||
stx hBuf
|
||
|
||
>PUSHW L.ETCINIT
|
||
>PUSHBI O.RDONLY+O.TEXT
|
||
>PUSHBI S.FI.T.TXT
|
||
>PUSHWZ
|
||
>SYSCALL FOpen
|
||
bcc .10
|
||
|
||
pha
|
||
.DO INITDDBG=1
|
||
jsr CS.RUN.ERRMSG
|
||
.FIN
|
||
jsr .81
|
||
|
||
pla
|
||
sec
|
||
rts
|
||
|
||
.10 sta hFile
|
||
|
||
.1 >PUSHB hFile
|
||
>PUSHW BufPtr
|
||
>PUSHWI 256
|
||
>SYSCALL FGetS
|
||
bcs .80
|
||
|
||
lda (BufPtr)
|
||
cmp #'#'
|
||
beq .1
|
||
|
||
.DO INITDDBG=1
|
||
>PUSHW BufPtr
|
||
>PUSHBI 0
|
||
>SYSCALL PrintF
|
||
.FIN
|
||
|
||
>PUSHW BufPtr
|
||
>PUSHBI S.PS.F.NOHUP+S.PS.F.HOLD
|
||
>SYSCALL ExecL
|
||
|
||
.DO INITDDBG=1
|
||
bcs .2
|
||
|
||
>LDYA L.MSG.OK
|
||
>SYSCALL PutS
|
||
|
||
.FIN
|
||
>SLEEP
|
||
bra .1
|
||
|
||
.DO INITDDBG=1
|
||
.2 jsr CS.RUN.ERRMSG
|
||
bra .1
|
||
.FIN
|
||
|
||
.80 lda hFile
|
||
>SYSCALL FClose
|
||
|
||
.81 lda hBuf
|
||
>SYSCALL FreeMem
|
||
|
||
rts
|
||
*--------------------------------------
|
||
CS.RUN.EXEC.X >PUSHW L.CMDS,x
|
||
>PUSHBI S.PS.F.HOLD
|
||
>SYSCALL ExecL
|
||
rts
|
||
*--------------------------------------
|
||
.DO INITDDBG=1
|
||
CS.RUN.ERRMSG tax
|
||
>PUSHW L.MSG.KO
|
||
txa
|
||
>PUSHA
|
||
>PUSHBI 1
|
||
>SYSCALL PrintF
|
||
rts
|
||
.FIN
|
||
*--------------------------------------
|
||
CS.DOEVENT sec
|
||
rts
|
||
*--------------------------------------
|
||
CS.END
|
||
*--------------------------------------
|
||
MSG.CTRLR .AZ "INITD:Entering ROOT mode..."
|
||
.DO INITDDBG=1
|
||
MSG.START .AZ "INITD:Starting..."
|
||
MSG.OK .AZ " [OK]"
|
||
MSG.KO .CZ " [%h]\r\n"
|
||
MSG.ETCINIT .AS "INITD:Executing "
|
||
.FIN
|
||
ETCINIT .AZ "${ROOT}etc/init"
|
||
*--------------------------------------
|
||
CTRLCHARS .DA #19,#13,#16,#12,#4
|
||
*--------------------------------------
|
||
BINSH .AZ "${ROOT}bin/sh"
|
||
BINMEM .AZ "${ROOT}bin/mem"
|
||
BINPS .AZ "${ROOT}bin/ps"
|
||
BINLSOF .AZ "${ROOT}bin/lsof"
|
||
BINSHUTDOWN .AZ "${ROOT}bin/shutdown"
|
||
*--------------------------------------
|
||
.DUMMY
|
||
.OR 0
|
||
DS.START
|
||
DS.END .ED
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE usr/src/sbin/initd.s
|
||
ASM
|