home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
UNIFLEX
/
UNIFLEX
/
UniFLEX_Std.Utils1.tar.Z
/
UniFLEX_Std.Utils1.tar
/
utils1
/
uinit
< prev
next >
Wrap
Text File
|
1984-11-16
|
9KB
|
475 lines
opt pag,nol
ttl UniFLEX init task (task 1)
pag
lib sysdef
lib sysstat
lib sysints
opt lis
pag
info UniFLEX init system
info Version 1.05, Released December 3, 1984
info Copyright, (C) 1984, by
info Technical Systems Consultants, Inc.
info All rights reserved.
*
* This task is executed after system initialization.
* Task 0 is the scheduler, and 'init' is task 1. Its
* main purpose is to read the ttylist file and start
* the login task for each terminal listed in the file.
*
*
* constants
*
DFALT equ 0 default interrupt mode
IGNORE equ 1 ignore interrupt for 'cpint'
UTPRM equ FACUR+FACUW+FACOR utmp file permissions for create
READ equ 0 read mode for open
RW equ 2 read/write mode for open
UNFILS equ 16 number of possible task files
TTYS equ 32 max number of terminals
TTPRM equ FACUR+FACUW+FACOR perms for tty open
CR equ $d carriage return
RBUFS equ 512 read line buffer size
*
* structure definitions
*
* struct ttab
org 0
trmnm rmb 2 2 character terminal name
tstyp rmb 1 ttyset parameter
ttid rmb 2 task id started with this tty
TIBSIZ equ * structure size
* struct linbuf
org 0
lacpt rmb 1 accept flag (should be '1)
lstyp rmb 1 ttyset parameter
ltnam rmb 2 terminal name
lterm rmb 1 line terminator ($D)
LINSIZ equ * structure size
pag
*
* Program entry here
*
org 0
init sys cpint,HANGI,IGNORE ignore hangup interrupt
sys cpint,ALRMI,aupdt set for auto update
ldd #30
sys alarm
ldd #"bt setup 'bt' for boot
lbsr uphf update history file
init0 ldd #-1 kill all tasks
sys spint,KILLI
ldx #ttab point to terminal table
init1 clr 0,x+ zero it out
cmpx #ttend end of table?
bne init1 loop til done
clr bdflag set bring down flag
sys sacct,0 turn off accounting
init2 ldd #"su setup 'su'
lbsr uphf update history file
lbsr single execute single user mode
tst bdflag bring system down?
bne down
ldd #"mu setup 'mu' for multi-user mode
lbsr uphf update history file
sys fork fork a new task
bra runst new guy branch ahead
pshs d save task id
init4 sys wait wait for new task
bes init4
cmpd 0,s is this the one?
bne init4 if not, wait again
puls d reset stack
bra iloop go to main loop
*
* runst
*
* Run the system startup file thru the shell.
*
runst sys cpint,ALRMI,DFALT
sys open,root,READ open the root
ldd #0 set file desc 0
sys dup dup file
ldd #0
sys dup
sys exec,shell,starg exec the shell with startup file
sys term if here, error!
*
* down
*
* Bring system down.
*
down sys cpint,ALRMI,DFALT
lbsr kilal kill all jobs
ldd #"st set up 'st' for stop
lbsr uphf update history file
ldd #-1 kill all tasks
sys spint,KILLI
sys sacct,0 turn off accounting
sys update update disks
bra * halt!
pag
*
* iloop
*
* This is the main processing loop of init.
*
iloop sys cpint,HANGI,reset
sys cpint,EMTI,reset0
ldd #0 prepare to close all files
pshs d save count
iloop2 sys close close a file
ldd 0,s get count
addd #1 bump to next file
std 0,s save new
cmpd #UNFILS last file?
bne iloop2
puls d get count
sys open,ttyf,READ open ttys file
std ttfd save descriptor
ldd #rdbuf init read line ptrs
std rbfbeg
std rbfend
ldx #ttab point to tty table
iloop4 pshs x save entry
lbsr rdline read a tty file line
puls x
beq iloop6 finished?
lda linbuf+lacpt an accepted line?
cmpa #'+ is it not '+'?
bne iloop4 if so, skip it
ldd linbuf+ltnam get tty name
std trmnm,x save in table
lda linbuf+lstyp get ttyset parameter
sta tstyp,x save in table
leax TIBSIZ,x bump to next entry
bra iloop4 repeat
iloop6 ldd ttfd get file descriptor
sys close close the tty file
ldx #ttab point to terminal table just built
iloo65 ldd trmnm,x get tty name
beq iloop7 is it null?
lbsr mkjob go create task
iloop7 leax TIBSIZ,x bump to next entry
cmpx #ttend end of table?
bne iloo65 repeat?
iloop8 sys wait wait for a task to terminate
bes iloop8
pshs x
ldx #ttab point to terminal table
iloo85 cmpd ttid,x look for task id
beq iloop9 does it match?
leax TIBSIZ,x move to next entry
cmpx #ttend end of list?
bne iloo85 if not, repeat
puls x
bra iloop8 if so, go wait again
iloop9 lbsr kiljb kill off the tasks tty
puls d
cmpd #8
beq iloop8
lbsr mkjob go make new tty task
bra iloop8 go wait again
*
* rdline
*
* Read a line from the 'ttylist' file and enter
* the data in the tty table.
*
rdline ldx #linbuf point to line buffer
ldb #LINSIZ set size count
rdlin2 jsr rlgetc get a character
beq rdlin4 error?
sta 0,x+ save in buffer
decb dec the count
bne rdlin2 repeat?
cmpa #CR is it cr term?
beq rdlin3
cmpa #': is it ':' term?
bne rdlin4 if not - error
rdli25 jsr rlgetc get character
beq rdlin4 error?
cmpa #CR look for cr
bne rdli25
rdlin3 clz set ok status
rts return
rdlin4 sez set error status
rts return
*
* single
*
* Run a single user shell (initial system is single
* usr only).
*
single lbsr kilal kill all other jobs
sys fork fork a task
bra singl4 ne jump ahead
pshs d save new task id
singl2 sys wait wait for job
bes singl2
cmpd 0,s right one term'd?
bne singl2
tfr x,d get status
cmpa #KILLI was it killed?
bne singl3
inc bdflag set down flag
singl3 puls d,pc return
singl4 sys cpint,ALRMI,DFALT
sys cpint,EMTI,DFALT
sys cpint,HANGI,DFALT
sys open,ctty,RW open console term
ldd #0 duplicate the file
sys dup
ldd #0
sys dup
sys create,utmp,UTPRM create user file
sys close close the file
sys exec,shell,sharg execute the shell
sys term term if error
pag
*
* mkjob
*
* Make a new task for the terminal name specified
* in the table entry pointed at by X.
*
mkjob ldd trmnm,x get term name
std mttnm set in device name
sys fork fork a new task
bra mkjob2 if new guy, jump ahead
std ttid,x save task id
rts return
mkjob2 sys cpint,HANGI,DFALT reset hangs interrupt
sys cpint,ALRMI,DFALT
sys cpint,EMTI,DFALT
sys chown,mktty,0 change owner to 0
bes mkjob8
sys chprm,mktty,TTPRM set perms for tty
bes mkjob8
sys open,mktty,RW open terminal
bes mkjob8
ldd #0 duplicate the open term
sys dup
sys exec,login,lgarg execute the login program
mkjob8 sys term if error
*
* kiljb
*
* Terminate the job whose entry is pointed at by X.
*
kiljb pshs x save pointer
ldd ttid,x get task id
beq kiljb4 if null, already killed!
lbsr upduf update login file
ldx 0,s get table entry
ldd trmnm,x get terminal name
lbsr uphf update history file
ldx 0,s point to entry
ldd ttid,x get id
sys spint,KILLI kill job
kiljb4 puls x reset entry pointer
ldd #0 set null word
std ttid,x zero task id
rts return
*
* kilal
*
* Kill all active jobs.
*
kilal ldx #ttab point to term table
kilal2 bsr kiljb kill this job
leax TIBSIZ,x bump to next entry
cmpx #ttend end ot table?
bne kilal2 if not, repeat
rts return
pag
*
* Get a character for read line
*
rlgetc pshs x,b save regs
ldx rbfbeg get start ptr
cmpx rbfend empty list?
bne rlget4
ldd ttfd get file desc
sys read,rdbuf,RBUFS fill buffer
bes rlget6 error?
cmpd #0 end of file?
beq rlget6
ldx #rdbuf reset pointers
stx rbfbeg
leax d,x find end of buffer
stx rbfend mark it
ldx #rdbuf point to 1st char
rlget4 lda 0,x+ get a character
stx rbfbeg set new start
puls x,b,pc return
rlget6 sez set error status
puls x,b,pc return
*
* upduf
*
* Update the act/utmp file with this user
*
upduf pshs x save entry ptr
sys open,utmp,1 open the file
bes upduf6 if error, skip
pshs d save file desc
ldx 2,s get entry ptr
ldd trmnm,x get term name
anda #$f mask low 4 bits
andb #$f of each char
asla hi byte times 10
pshs a
asla
asla
adda 0,s result now x10
sta 0,s save result
addb 0,s+ add in low byte
clra clear hi byte
aslb now x16
rola
aslb
rola
aslb
rola
aslb
rola
std isk2 save in seek call
ldd 0,s get file desc
sys ind,isk seek in file
ldd 0,s get file desc
sys write,nulls,16 zero out entry
puls d get file desc
sys close close the file
upduf6 puls x,pc return
*
* reset
*
* Reset system
*
reset ldd #-1 hangup all tasks
sys spint,HANGI
ldd #15 sleep for 15 seconds
sys alarm
sys stop
reset0 ldd #init0 reset the pc
std 10,s on stack
rti do it!
* do auto update
aupdt sys update do update
sys cpint,ALRMI,aupdt
ldd #30
sys alarm
rti return
pag
*
* uphf
*
* Update the history file (/act/history).
*
uphf std uphbuf save name
sys open,hisf,1 open file for write
bes uphf4 if error - exit
pshs d save file desc
sys time,uphtim get time
ldd 0,s get file desc
sys seek,0,0,2 seek to eof
ldd 0,s get file desc
sys write,uphbuf,16 write out entry
puls d get file desc
sys close close the file
uphf4 rts return
pag
*
* data constants
*
root fcc '/',0
utmp fcc '/act/utmp',0
hisf fcc '/act/history',0
shell fcc '/bin/shell',0
startup fcc '/etc/startup',0
ctty fcc '/dev/tty00',0
sharg fdb shnm,0
shnm fcc 'shell',0
login fcc '/etc/login',0
lgarg fdb lgnm,0
lgnm fcc 'login',0
mktty fcc '/dev/tty'
mttnm fdb 0,0
starg fdb shnm2,strnm,0
shnm2 fcc 'shell',0
strnm fcc '/etc/startup',0
ttyf fcc '/etc/ttylist',0
nulls fdb 0,0,0,0,0,0,0,0 null entry
uphbuf fdb 0,0,0,0,0,0 buffer for history updates
uphtim fdb 0,0,0,0 time for history
*
* data section
*
isk fcb seek ind seek call
fdb 0
isk2 fdb 0,0
bdflag fcb 0 bring down flag
rbfbeg rmb 2 buffer ptr
rbfend rmb 2
ttfd rmb 2 open file descriptor
linbuf rmb LINSIZ line buffer
ttab rmb TTYS*TIBSIZ terminal table
ttend equ * end of table
rdbuf rmb RBUFS read line buffer
end