A2osX/SBIN/INITD.S.txt

210 lines
3.8 KiB
Plaintext
Raw Normal View History

2018-12-04 16:45:58 +00:00
NEW
2020-02-26 07:28:45 +00:00
AUTO 3,1
2018-12-04 16:45:58 +00:00
.LIST OFF
2020-02-26 07:28:45 +00:00
.OP 65C02
.OR $2000
2020-01-24 14:21:08 +00:00
.TF sbin/initd
2020-08-18 08:00:26 +00:00
*---------------------------------------
INITDDBG .EQ 1
2018-12-04 16:45:58 +00:00
*--------------------------------------
2020-07-27 15:19:35 +00:00
.INB inc/macros.i
.INB inc/a2osx.i
.INB inc/mli.i
2018-12-04 16:45:58 +00:00
*--------------------------------------
* Zero Page Segment, up to 32 bytes
*--------------------------------------
.DUMMY
.OR ZPBIN
ZS.START
2020-02-27 07:27:42 +00:00
BufPtr .BS 2
hBuf .BS 1
hFile .BS 1
2020-03-13 07:15:58 +00:00
ZS.END .ED
2018-12-04 16:45:58 +00:00
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
2018-12-05 15:12:10 +00:00
.DA #0 S.PS.F.EVENT
2018-12-04 16:45:58 +00:00
.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
2019-10-03 06:25:27 +00:00
*--------------------------------------
2018-12-04 16:45:58 +00:00
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
2020-02-27 07:27:42 +00:00
L.MSG.CTRLR .DA MSG.CTRLR
L.ETCINIT .DA ETCINIT
2020-07-30 11:14:37 +00:00
L.CMDS .DA BINSH
.DA BINMEM
.DA BINPS
.DA BINLSOF
.DA BINSHUTDOWN
2018-12-04 16:45:58 +00:00
.DA 0
*--------------------------------------
CS.INIT clc
rts
*--------------------------------------
CS.RUN ldy #S.PS.PID
lda (pPS),y
cmp #1
bne .9
2020-02-26 07:28:45 +00:00
2020-03-13 16:10:36 +00:00
ldy #S.PS.hStdIn
lda (pPS),y
>SYSCALL feof
bcs .99
tay
bne .1
>SYSCALL getchar
bcs .99
2020-02-26 07:28:45 +00:00
2020-03-13 16:10:36 +00:00
cmp #18 CTRL-R for Root mode
bne .1
2020-02-26 07:28:45 +00:00
2018-12-04 16:45:58 +00:00
>LDYA L.MSG.CTRLR
2020-02-28 07:21:46 +00:00
>SYSCALL PutS
2020-02-27 07:27:42 +00:00
2020-07-30 11:14:37 +00:00
ldx #0
jsr CS.RUN.EXEC.X
2020-03-13 16:10:36 +00:00
>SLEEP
2020-02-27 07:27:42 +00:00
.1 jsr CS.RUN.ETCINIT
bcs .99
.2 >SYSCALL getchar
bcs .99
cmp #C.CR Ctrl.M
bne .3
2020-07-30 11:14:37 +00:00
ldx #2
jsr CS.RUN.EXEC.X
2020-02-27 07:27:42 +00:00
bra .2
.3 cmp #16 Ctrl.P
bne .4
2020-07-30 11:14:37 +00:00
ldx #4
jsr CS.RUN.EXEC.X
2020-02-27 07:27:42 +00:00
bra .2
2020-07-30 11:14:37 +00:00
.4 cmp #12 Ctrl.L
bne .5
ldx #6
jsr CS.RUN.EXEC.X
.5 cmp #4 Ctrl.D
2020-02-27 07:27:42 +00:00
bne .2
2020-07-30 11:14:37 +00:00
ldx #8
jsr CS.RUN.EXEC.X
2020-02-27 07:27:42 +00:00
bcs .2
2018-12-04 16:45:58 +00:00
sec
rts
2020-02-27 07:27:42 +00:00
2018-12-04 16:45:58 +00:00
.9 lda #E.SYN
sec
2020-02-27 07:27:42 +00:00
.99 rts
*--------------------------------------
CS.RUN.ETCINIT >LDYAI 256
2020-02-28 07:21:46 +00:00
>SYSCALL GetMem
2020-02-27 07:27:42 +00:00
>STYA BufPtr
stx hBuf
>PUSHW L.ETCINIT
>PUSHBI O.RDONLY+O.TEXT
>PUSHBI S.FI.T.TXT
>PUSHWZ
2020-03-09 16:24:08 +00:00
>SYSCALL FOpen
2020-02-27 07:27:42 +00:00
bcs .90
sta hFile
.1 >PUSHWI 256
>PUSHW BufPtr
lda hFile
>SYSCALL fgets
bcs .80
lda (BufPtr)
cmp #'#'
beq .1
2020-08-18 08:00:26 +00:00
.DO INITDDBG=1
>LDYA BufPtr
>SYSCALL PutS
.FIN
2020-07-28 20:37:26 +00:00
>PUSHW BufPtr
2020-08-11 18:55:28 +00:00
>PUSHBI S.PS.F.NOHUP+S.PS.F.HOLD
2020-07-28 20:37:26 +00:00
>SYSCALL ExecL
>SLEEP
2020-02-27 07:27:42 +00:00
bra .1
.90 pha
jsr .81
pla
sec
rts
.80 lda hFile
2020-02-28 07:21:46 +00:00
>SYSCALL FClose
2020-02-27 07:27:42 +00:00
.81 lda hBuf
2020-02-28 07:21:46 +00:00
>SYSCALL FreeMem
2020-02-27 07:27:42 +00:00
2018-12-04 16:45:58 +00:00
rts
*--------------------------------------
2020-07-30 11:14:37 +00:00
CS.RUN.EXEC.X >PUSHW L.CMDS,x
2020-03-13 16:10:36 +00:00
>PUSHBI S.PS.F.HOLD
2020-02-27 07:27:42 +00:00
>SYSCALL ExecL
rts
2018-12-04 16:45:58 +00:00
*--------------------------------------
CS.DOEVENT sec
rts
*--------------------------------------
2020-07-30 11:14:37 +00:00
CS.QUIT lda #MLIQUIT
sta .1
jsr $BF00
.1 lda MLI.PARAMS
bcs *
2018-12-04 16:45:58 +00:00
rts
*--------------------------------------
CS.END
*--------------------------------------
2020-03-13 16:10:36 +00:00
MSG.CTRLR .AZ "INITD:Entering ROOT mode..."
2020-02-26 07:28:45 +00:00
ETCINIT .AZ "${ROOT}etc/init"
2020-07-30 11:14:37 +00:00
BINSH .AZ "${ROOT}bin/sh"
2020-02-27 07:27:42 +00:00
BINMEM .AZ "${ROOT}bin/mem"
BINPS .AZ "${ROOT}bin/ps"
2020-07-30 11:14:37 +00:00
BINLSOF .AZ "${ROOT}bin/lsof"
2020-02-27 07:27:42 +00:00
BINSHUTDOWN .AZ "${ROOT}bin/shutdown"
2020-07-30 11:14:37 +00:00
*--------------------------------------
MLI.PARAMS .DA #4
.DA #0
.DA 0
.DA #0
.DA 0
2018-12-04 16:45:58 +00:00
*--------------------------------------
.DUMMY
.OR 0
DS.START
2020-03-13 07:15:58 +00:00
DS.END .ED
2018-12-04 16:45:58 +00:00
*--------------------------------------
MAN
2020-07-27 15:19:35 +00:00
SAVE usr/src/sbin/initd
2018-12-04 16:45:58 +00:00
ASM