A2osX/BIN/WHO.S.txt
2020-07-08 17:26:23 +02:00

175 lines
3.3 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 bin/who
*--------------------------------------
.INB inc/macros.i
.INB inc/io.i
.INB inc/mli.i
.INB inc/a2osx.i
.INB inc/kernel.i
*--------------------------------------
.DUMMY
.OR ZPBIN
ZS.START
SessionID .BS 1
ZPSessionPtr .BS 2
ZPCODE .BS 9
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
.DA CS.END-CS.START Code Size (without Constants)
.DA DS.END-DS.START Data SegmentSize
.DA #64 Stack Size
.DA #ZS.END-ZS.START Zero Page Size
.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.EVENT
.DA CS.QUIT
L.MSG0 .DA MSG0
L.MSG1 .DA MSG1
.DA 0
*--------------------------------------
CS.INIT clc
rts
*--------------------------------------
CS.RUN ldy #8
.10 lda ZPCODE.START,y
sta ZPCODE,y
dey
bpl .10
>LDYA L.MSG0
>SYSCALL PutS
ldx #1
stx SessionID
.1 lda S.Table.hSID-1,x
beq .7
jsr CS.RUN.GetSession
>PUSHW L.MSG1 format
>PUSHB SessionID 1 byte SID
ldx SessionID
lda S.Table.hSID-1,x
>PUSHA 1 byte hSession
>PUSHB (pData) 1 byte PRIVILEGE
ldy #S.SESSION.UID
>PUSHB (pData),y 1 byte UID
iny #S.SESSION.UID
>PUSHB (pData),y 1 byte GID
lda pData
clc
adc #S.SESSION.NAME
tay
lda pData+1
adc /S.SESSION.NAME
>PUSHYA 2 bytes NAME
ldx SessionID
lda S.Table.hFile-1,x
tax
jsr CS.RUN.GetDevName
>PUSHYA 2 bytes DEV
>PUSHBI 9 total = 9 ... bytes
>SYSCALL PrintF
bcs .9
.7 inc SessionID
ldx SessionID
cpx #K.USR.MAX+1
bne .1
.8 lda #0 tell TSKMGR that all done ok, but
sec we do not want to stay in memory
.9 rts
*--------------------------------------
CS.RUN.GetSession
>SYSCALL GetStkObjPtr
>STYA ZPSessionPtr
ldy #0
.1 jsr ZPCODE
sta (pData),y
iny
cpy #S.SESSION.NAME
bne .1
.2 jsr ZPCODE
sta (pData),y
iny
tax
bne .2
rts
*--------------------------------------
CS.RUN.GetDevName
lda OF.Table.hPath-1,x
bne .1
lda OF.Table.hFD-1,x
tax
lda Dev.Table-1,x
clc
adc #S.FD.DEV
tay
lda Dev.Table,x
adc /S.FD.DEV
* clc
rts
.1 >SYSCALL GetMemPtr
rts
*--------------------------------------
CS.EVENT sec
rts
*--------------------------------------
CS.QUIT clc
rts
*--------------------------------------
CS.END
ZPCODE.START sta SETREADAUX
lda (ZPSessionPtr),y
sta CLRREADAUX
rts
MSG0 .AZ "SID hSD Privilege UID GID Name Dev"
MSG1 .AZ "%3d $%0h %b %3d %3d %16s %s\r\n"
*--------------------------------------
.DUMMY
.OR 0
DS.START
BUF .BS 240
DS.END
.ED
*--------------------------------------
MAN
SAVE usr/src/bin/who.s
ASM