mirror of
https://github.com/DoctorWkt/unix-jun72.git
synced 2026-02-02 06:51:49 +00:00
- first three pages from Hellwig
This commit is contained in:
54
pages/e01-01
Normal file
54
pages/e01-01
Normal file
@@ -0,0 +1,54 @@
|
||||
/ u1 -- unix
|
||||
unkni: / used for all system calls
|
||||
sysent:
|
||||
incb sysflg / indicate a system routine is
|
||||
beq 1f / in progress
|
||||
jmp panic / called if trap inside system
|
||||
1:
|
||||
mov $s.syst+2,c1ockp
|
||||
mov r0,-(sp) / save user registers
|
||||
mov sp,u.r0 / pointer to bottom of users stack in u.r0
|
||||
mov r1,-(sp)
|
||||
mov r2,-(sp)
|
||||
mov r3,-(sp)
|
||||
mov r4,-(sp)
|
||||
mov r5,-(sp)
|
||||
mov ac,-(sp) / "accumulator" register for extended
|
||||
/ arithmetic unit
|
||||
mov mq,-(sp) / "multiplier quotient" register for the
|
||||
/ extended arithmetic unit
|
||||
mov sc,-(sp) / "step count" register for the extended
|
||||
/ arithmetic unit
|
||||
mov sp,u.sp / u.sp points to top of users stack
|
||||
mov 18.(sp),r0 / store pc in r0
|
||||
mov -(r0),r0 / sys inst in r0 10400xxx
|
||||
sub $sys,r0 / get xxx code
|
||||
asl r0 / multiply by 2 to jump indirect in bytes
|
||||
cmp r0,$2f—1f / limit of table (35) exceeded
|
||||
bhis badsys / yes, bad system call
|
||||
bic $341,20.(sp) / set users processor priority to 0 and clear
|
||||
/ carry bit
|
||||
jmp *1f(r0) / jump indirect thru table of addresses
|
||||
/ to proper system routine.
|
||||
1:
|
||||
sysrele / 0
|
||||
sysexit / 1
|
||||
sysfork / 2
|
||||
sysread / 3
|
||||
syswrite / 4
|
||||
sysopen / 5
|
||||
sysclose / 6
|
||||
syswait / 7
|
||||
syscreat / 8
|
||||
syslink / 9
|
||||
sysunlink / 10
|
||||
sysexec / 11
|
||||
syschdir / 12
|
||||
systime / 13
|
||||
sysmkdir / 14
|
||||
syschmod / 15
|
||||
syschown / 16
|
||||
sysbreak / 17
|
||||
sysstat / 18
|
||||
sysseek / 19
|
||||
systell / 20
|
||||
56
pages/e01-02
Normal file
56
pages/e01-02
Normal file
@@ -0,0 +1,56 @@
|
||||
sysmount / 21
|
||||
sysumount / 22
|
||||
syssetuid / 23
|
||||
sysgetuid / 24
|
||||
sysstime / 25
|
||||
sysquit / 26
|
||||
sysintr / 27
|
||||
sysfstat / 28
|
||||
sysemt / 29
|
||||
sysmdate / 30
|
||||
sysstty / 31
|
||||
sysgtty / 32
|
||||
sysilgins / 33
|
||||
2:
|
||||
|
||||
error:
|
||||
mov u.sp,r1
|
||||
bis $1,20.(r1) / set c bit in processor status word below
|
||||
/ users stack
|
||||
|
||||
sysret:
|
||||
tstb u.bsys / is a process about to be terminated because
|
||||
bne sysexit / of an error? yes, go to sysexit
|
||||
mov u.sp,sp / no point stack to users stack
|
||||
clr r1 / zero r1 to check last mentioned i-node
|
||||
jsr r0,iget / if last mentioned i—node has been modified
|
||||
/ it is written out
|
||||
tstb smod / has the super block been modified
|
||||
beq 1f / no, 1f
|
||||
clrb smod / yes, clear smod
|
||||
bis $1000,sb0 / set write bit in I/0 queue for super block
|
||||
/ output
|
||||
jsr r0,ppoke / write out modified super block to disk
|
||||
1:
|
||||
tstb mmod / has the super block for the dismountable file
|
||||
/ system
|
||||
beq 1f / been modified? no, 1f
|
||||
clrb mmod / yes, clear mmod
|
||||
movb mntd,sb1 / set the I/0 queue
|
||||
bis $1000,sb1 / set write bit in I/0 queue for detached sb
|
||||
jsr r0,ppoke / write it out to its device
|
||||
1:
|
||||
tstb uquant / is the time quantum 0?
|
||||
bne 1f / no, don't swap it out
|
||||
|
||||
sysrele:
|
||||
jsr r0,tswap / yes, swap it out
|
||||
1:
|
||||
mov (sp)+,sc / restore user registers
|
||||
mov (sp)+,mq
|
||||
mov (sp)+,ac
|
||||
mov (sp)+,r5
|
||||
mov (sp)+,r4
|
||||
mov (sp)+,r3
|
||||
mov (sp)+,r2
|
||||
mov (sp)+,r1
|
||||
56
pages/e01-03
Normal file
56
pages/e01-03
Normal file
@@ -0,0 +1,56 @@
|
||||
mov (sp)+,r0
|
||||
mov $s.chrgt+2,clockp
|
||||
decb sysflg / turn system flag off
|
||||
jsr r0,isintr / is there an interrupt from the user
|
||||
br intract / yes, output gets flushed, take interrupt
|
||||
/ action
|
||||
rti / no return from interrupt
|
||||
|
||||
badsys:
|
||||
incb u.bsys / turn on the user's bad system flag
|
||||
mov $3f,u.namep / point u.namep to "core\0\O"
|
||||
jsr r0,namei / get the i—number for the core image file
|
||||
br 1f / error
|
||||
neg r1 / negate the i-number to open the core image file
|
||||
/ for writing
|
||||
jsr r0,iopen / open the core image file
|
||||
jsr r0,itrunc / free all associated blocks
|
||||
br 2f
|
||||
1:
|
||||
mov $17,r1 / put i-node mode (17) in r1
|
||||
jsr r0,maknod / make an i-node
|
||||
mov u.dirbuf,r1 / put i-nodes number in r1
|
||||
2:
|
||||
mov $core,u.base / move address core to u.base
|
||||
mov $ecore-core,u.count / put the byte count in u.count
|
||||
mov $u.off,u.fofp / more user offset to u.fofp
|
||||
clr u.off / clear user offset
|
||||
jsr r0,writei / write out the core image to the user
|
||||
mov $user,u.base / pt. u.base to user
|
||||
mov $64.,u.count / u.count = 64
|
||||
jsr r0,writei / write out all the user parameters
|
||||
neg r1 / make i-number positive
|
||||
jsr r0,iclose / close the core image file
|
||||
br sysexit /
|
||||
3:
|
||||
<core\0\0>
|
||||
|
||||
sysexit: / terminate process
|
||||
clr u.intr / clear interrupt control word
|
||||
clr r1 / clear r1
|
||||
1: / r1 has file descriptor (index to u.fp list) Search the whole list
|
||||
jsr r0,fclose / close all files the process opened
|
||||
br .+2 / ignore error return
|
||||
inc r1 / increment file descriptor
|
||||
cmp r1,$10. / end of u.fp list?
|
||||
blt 1b / no, go back
|
||||
movb u.uno,r1 / yes, move dying process's number to r1
|
||||
clrb p.stat-1(r1) / free the process
|
||||
asl r1 / use r1 for index into the below tables
|
||||
mov p.pid—2(r1),r3 / move dying process's name to r3
|
||||
mov p.ppid-2(r1),r4 / move its parents name to r4
|
||||
clr r2
|
||||
clr r5 / initialize reg
|
||||
1: / find children of this dying process, if they are zombies, free them
|
||||
add $2,r2 / search parent process table for dying process's name
|
||||
cmp p.ppid-2(r2),r3 / found it?
|
||||
Reference in New Issue
Block a user