A2osX/SBIN/INITD.S.txt
2020-02-28 08:21:46 +01:00

182 lines
3.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
*--------------------------------------
.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.BINSH .DA BINSH
L.ETCINIT .DA ETCINIT
L.BINMEM .DA BINMEM
L.BINPS .DA BINPS
L.BINSHUTDOWN .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
>LDYA L.BINSH
jsr CS.RUN.EXEC.YA
.1 jsr CS.RUN.ETCINIT
bcs .99
.2 >SYSCALL getchar
bcs .99
cmp #C.CR Ctrl.M
bne .3
>LDYA L.BINMEM
jsr CS.RUN.EXEC.YA
bra .2
.3 cmp #16 Ctrl.P
bne .4
>LDYA L.BINPS
jsr CS.RUN.EXEC.YA
bra .2
.4 cmp #4 Ctrl.D
bne .2
>LDYA L.BINSHUTDOWN
jsr CS.RUN.EXEC.YA
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
>LDYA BufPtr
jsr CS.RUN.EXEC.YA
bra .1
.90 pha
jsr .81
pla
sec
rts
.80 lda hFile
>SYSCALL FClose
.81 lda hBuf
>SYSCALL FreeMem
rts
*--------------------------------------
CS.RUN.EXEC.YA >PUSHYA
>PUSHBI S.PS.F.HOLD+S.PS.F.SLEEP+S.PS.F.NOHUP
>SYSCALL ExecL
rts
*--------------------------------------
CS.DOEVENT sec
rts
*--------------------------------------
CS.QUIT clc
rts
*--------------------------------------
CS.END
*--------------------------------------
MSG.CTRLR .AZ "INITD:Ctrl-R Pressed, entering ROOT mode..."
BINSH .AZ "${ROOT}bin/sh"
ETCINIT .AZ "${ROOT}etc/init"
BINMEM .AZ "${ROOT}bin/mem"
BINPS .AZ "${ROOT}bin/ps"
BINSHUTDOWN .AZ "${ROOT}bin/shutdown"
*--------------------------------------
.DUMMY
.OR 0
DS.START
DS.END
.ED
*--------------------------------------
MAN
SAVE USR/SRC/SBIN/INITD
ASM