A2osX/SBIN/INITD.S.txt
2020-08-18 10:00:26 +02:00

210 lines
3.8 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.

NEW
AUTO 3,1
.LIST OFF
.OP 65C02
.OR $2000
.TF sbin/initd
*---------------------------------------
INITDDBG .EQ 1
*--------------------------------------
.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
L.ETCINIT .DA ETCINIT
L.CMDS .DA BINSH
.DA BINMEM
.DA BINPS
.DA BINLSOF
.DA BINSHUTDOWN
.DA 0
*--------------------------------------
CS.INIT clc
rts
*--------------------------------------
CS.RUN 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 jsr CS.RUN.ETCINIT
bcs .99
.2 >SYSCALL getchar
bcs .99
cmp #C.CR Ctrl.M
bne .3
ldx #2
jsr CS.RUN.EXEC.X
bra .2
.3 cmp #16 Ctrl.P
bne .4
ldx #4
jsr CS.RUN.EXEC.X
bra .2
.4 cmp #12 Ctrl.L
bne .5
ldx #6
jsr CS.RUN.EXEC.X
.5 cmp #4 Ctrl.D
bne .2
ldx #8
jsr CS.RUN.EXEC.X
bcs .2
sec
rts
.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
bcs .90
sta hFile
.1 >PUSHWI 256
>PUSHW BufPtr
lda hFile
>SYSCALL fgets
bcs .80
lda (BufPtr)
cmp #'#'
beq .1
.DO INITDDBG=1
>LDYA BufPtr
>SYSCALL PutS
.FIN
>PUSHW BufPtr
>PUSHBI S.PS.F.NOHUP+S.PS.F.HOLD
>SYSCALL ExecL
>SLEEP
bra .1
.90 pha
jsr .81
pla
sec
rts
.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
*--------------------------------------
CS.DOEVENT sec
rts
*--------------------------------------
CS.QUIT lda #MLIQUIT
sta .1
jsr $BF00
.1 lda MLI.PARAMS
bcs *
rts
*--------------------------------------
CS.END
*--------------------------------------
MSG.CTRLR .AZ "INITD:Entering ROOT mode..."
ETCINIT .AZ "${ROOT}etc/init"
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"
*--------------------------------------
MLI.PARAMS .DA #4
.DA #0
.DA 0
.DA #0
.DA 0
*--------------------------------------
.DUMMY
.OR 0
DS.START
DS.END .ED
*--------------------------------------
MAN
SAVE usr/src/sbin/initd
ASM