A2osX/SBIN/INITD.S.txt
burniouf 09923489fd LIBCRYPT:Bufixes and MD5 removal (duplicated in KERNEL)
ACOS:bugfixes in GET
KERNEL:fixes for //c loobing bug
2021-07-27 18:21:58 +02:00

249 lines
4.4 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 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
* bra .55
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
.55 >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
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
bra .2
.5 cmp #4 Ctrl.D
bne .2
ldx #8
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 .AZ " [%h]\r\n"
MSG.ETCINIT .AS "INITD:Executing "
.FIN
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"
*--------------------------------------
.DUMMY
.OR 0
DS.START
DS.END .ED
*--------------------------------------
MAN
SAVE usr/src/sbin/initd.s
ASM