1
0
mirror of https://github.com/DoctorWkt/pdp7-unix.git synced 2026-04-29 05:15:11 +00:00
This commit is contained in:
Warren Toomey
2016-03-03 19:48:03 +10:00
11 changed files with 169 additions and 142 deletions

View File

@@ -247,11 +247,11 @@ call:
isz 8 isz 8
-1 -1
tad sp tad sp
sad B sad 8
skp skp
jmp 1b jmp 1b
lac ap i lac ap i
img lmq
lac dp lac dp
dac ap i dac ap i
lac ap lac ap

View File

@@ -54,7 +54,7 @@ floop1:
tad d4 tad d4
dac name dac name
sys open; name; ..; 0 sys open; name: ..; 0
spa spa
jmp ferror jmp ferror
dac fi dac fi
@@ -189,7 +189,7 @@ ferror:
sys write; 1:..; 4 sys write; 1:..; 4
lac d1 lac d1
sys write; 1f; 1 sys write; 1f; 1
fmp floop1 jmp floop1
1: 077012 1: 077012
hangup: hangup:

View File

@@ -62,7 +62,7 @@ floop1:
tad d4 tad d4
dac name dac name
sys open; name; ..; 0 sys open; name: ..; 0
spa spa
jmp ferror jmp ferror
dac fi dac fi
@@ -72,7 +72,7 @@ ferror:
lac name lac name
dac 1f dac 1f
lac d1 lac d1
sys write; 1;..; 4 sys write; 1:..; 4
lac d1 lac d1
sys write; 1f; 1 sys write; 1f; 1
jmp floop1 jmp floop1
@@ -134,7 +134,7 @@ bksp:
jmp cloop jmp cloop
cret: cret:
czm col dzm col
jmp cloop jmp cloop
pass2: pass2:
@@ -278,6 +278,7 @@ hangup:
abort: abort:
lac d1 lac d1
sys write; m2; m2s sys write; m2; m2s
jmp stop
nofiles: nofiles:
lac d1 lac d1
@@ -342,7 +343,7 @@ gcard: 0
isz gcard isz gcard
sna sna
jmp gcard i jmp gcard i
irss 9 lrss 9
sad o45 sad o45
jmp 1f jmp 1f
jms putc jms putc

View File

@@ -59,7 +59,7 @@ trace: 0
jmp stop jmp stop
jmp trace i jmp trace i
itrace: 0 dtrace: 0
lac pc lac pc
dac 8 dac 8
lac 8 i lac 8 i

View File

@@ -8,7 +8,7 @@ start:
fetch: fetch:
lac pc i lac pc i
imq lmq
and o17777 and o17777
dac addr dac addr
ecla lls 4 ecla lls 4
@@ -79,7 +79,7 @@ bor:
jmp fetch jmp fetch
band: band:
lac t2 i lac t1 i
and t2 i and t2 i
dac t4 i dac t4 i
jmp fetch jmp fetch
@@ -185,7 +185,7 @@ consop:
tad d1 tad d1
dac sp i dac sp i
isz sp isz sp
iac addr lac addr
dac sp i dac sp i
isz sp isz sp
jmp fetch jmp fetch
@@ -206,13 +206,13 @@ mcall:
dac t2 dac t2
-1 -1
tad t2 i tad t2 i
imq lmq
lac dp lac dp
dac t1 i dac t1 i
lac t1 lac t1
dac dp dac dp
isz t1 isz t1
iac pc lac pc
dac t1 i dac t1 i
lacq lacq
dac pc dac pc
@@ -247,11 +247,11 @@ call:
isz 8 isz 8
-1 -1
tad sp tad sp
sad B sad 8
skp skp
jmp 1b jmp 1b
lac ap i lac ap i
img lmq
lac dp lac dp
dac ap i dac ap i
lac ap lac ap
@@ -364,24 +364,24 @@ unaop:
jmp . i jmp . i
uadr; umin; uind; unot uadr; umin; uind; unot
badr: uadr:
lac t1 lac t1
dac t3 i dac t3 i
jmp fetch jmp fetch
bmin: umin:
-1 -1
tad t1 i tad t1 i
cma cma
dac t3 i dac t3 i
jmp fetch jmp fetch
bind: uind:
lac t1 i lac t1 i
dac t2 i dac t2 i
jmp fetch jmp fetch
bnot: unot:
lac t1 i lac t1 i
sna cla sna cla
lac d1 lac d1
@@ -412,22 +412,22 @@ s = n+a
t = s+a t = s+a
u = t+a u = t+a
x = u+a x = u+a
f = x+a y = x+a
d1: 1 d1: 1
dm1: -1 dm1: -1
dm2: -2 dm2: -2
o17777: 017777 o17777: 017777
:1: 0 t1: 0
:2: 0 t2: 0
:3: 0 t3: 0
:4: 0 t4: 0
:ddr: 0 addr: 0
pc = 017 pc = 017
sp: stack sp: stack
dp: stack dp: stack
ip: stack ap: stack
stack: 0 stack: 0

View File

@@ -3,22 +3,22 @@
.. = 0 .. = 0
t = 0 t = 0
orig: orig:
hlt hlt " overwritten with interrupt return addr
jmp pibreak jmp pibreak " dispatch to interrupt processing
. = orig+7 . = orig+7
-1 -1 " only ever set (to -1): never read?!
. = orig+020 . = orig+020 " syscall (CAL) processing
1f 1f " addr for "CAL I": store return here on "CAL"
iof iof " interrupts off
dac u.ac dac u.ac " save user AC
lac 020 lac 020 " save user return addr
dac 1f dac 1f " save as if "CAL I"
lac 1f-1 lac 1f-1
dac 020 dac 020 " restore location 20
lac u.ac lac u.ac " restore user AC
jmp 1f+1 jmp 1f+1 " join "CAL I" processing
1f 1f
1: 0 1: 0
iof " interrupts off iof " interrupts off
@@ -49,7 +49,7 @@ orig:
jmp .. i " dispatch system call jmp .. i " dispatch system call
. = orig+0100 . = orig+0100
jmp coldentry jmp coldentry " here to start kernel
jms halt jms halt
okexit: okexit:
@@ -77,6 +77,7 @@ sysexit: " common system call exit code
lac u.ac " restore AC register lac u.ac " restore AC register
jmp u.rq+8 i " return to user jmp u.rq+8 i " return to user
" scheduler / idle loop
swap: 0 swap: 0
ion ion
1: 1:
@@ -84,49 +85,49 @@ swap: 0
jmp 1f jmp 1f
jms lookfor; 1 " in/ready jms lookfor; 1 " in/ready
skp skp
jmp 1b jmp 1b " loop until a process becomes ready
dzm maxquant dzm maxquant " here with in/ready (self?)
jmp 3f jmp 3f
1: 1: " here with out/ready process
dac 9f+t dac 9f+t " save process pointer (swapped out) in t0
jms lookfor; 2 " in/notready jms lookfor; 2 " in/notready " find a swapped in process to swap out?
jmp 1f jmp 1f
jms lookfor; 1 " in/ready jms lookfor; 1 " in/ready
jmp 1f jmp 1f
jmp 2f jmp 2f
1: 1:
lac swap lac swap
dac u.swapret dac u.swapret " return to scheduler when swapped back
iof iof
lac o200000 lac o200000 " change status to swapped out
tad u.ulistp i tad u.ulistp i
dac u.ulistp i dac u.ulistp i
ion ion
jms dskswap; 07000 jms dskswap; 07000 " swap process out
lac u.dspbuf lac u.dspbuf
sna sna
jmp 2f jmp 2f
law dspbuf law dspbuf
jms movdsp jms movdsp
2: 2:
iof iof " disable interrupts
lac o600000 lac o600000 " change status (1->7?)
tad 9f+t i tad 9f+t i
dac 9f+t i dac 9f+t i
ion ion " enable interrupts
jms dskswap; 06000 jms dskswap; 06000 " read process in?
lac u.swapret lac u.swapret " set our return addr
dac swap dac swap " to saved return addr
lac o20 lac o20 " reset maxquant to 16 ticks
dac maxquant dac maxquant
lac u.dspbuf lac u.dspbuf
sza sza " using display?
"** 01-s1.pdf page 4 "** 01-s1.pdf page 4
jms movdsp jms movdsp " yes.
3: 3:
dzm uquant dzm uquant " no. reset process tick count
iof iof
jmp swap i jmp swap i " return
t = t+1 t = t+1
swp: " system call dispatch table swp: " system call dispatch table

View File

@@ -1,15 +1,18 @@
"** 01-s1.pdf page 14 "** 01-s1.pdf page 14
" s3 " s3
" call:
" jms searchu; addr
searchu: 0 searchu: 0
lac searchu i lac searchu i " fetch argument
dac 9f+t+1 dac 9f+t+1 " in t1
-mnproc -mnproc " loop counter
dac 9f+t dac 9f+t " in t0
law ulist-1 law ulist-1 " ulist ptr
dac 8 dac 8 " in index 8
1: 1:
lac 8 i lac 8 i " copy ulist entry to lu
dac lu dac lu
lac 8 i lac 8 i
dac lu+1 dac lu+1
@@ -17,65 +20,69 @@ searchu: 0
dac lu+2 dac lu+2
lac 8 i lac 8 i
dac lu+3 dac lu+3
jms 9f+t+1 i jms 9f+t+1 i " call argument as subroutine
isz 9f+t isz 9f+t " returned: loop done?
jmp 1b jmp 1b " no, do it again
isz searchu isz searchu " skip argument
jmp searchu i jmp searchu i
t = t+2 t = t+2
" look for process:
" jms lookfor; status
" found: ulist ptr in AC
" not found
lookfor: 0 lookfor: 0
jms searchu; 1f jms searchu; 1f
isz lookfor isz lookfor " skip argument
isz lookfor isz lookfor " give skip return
jmp lookfor i jmp lookfor i
1: 0 1: 0 " worker called by searchu
lac lu lac lu
rtl; rtl; and o7 rtl; rtl; and o7 " bits 0:2 of lu
sad lookfor i sad lookfor i " match argument?
skp skp " yes
jmp 1b i jmp 1b i " no, return, keep going
-3 -3
tad 8 tad 8 " roll index 8 back to this entry
and o17777 and o17777
isz lookfor isz lookfor " skip argument
jmp lookfor i jmp lookfor i " non-skip return
.fork: .fork:
jms lookfor; 0 " not-used jms lookfor; 0 " not-used " find an unused process slot
skp skp
jms error jms error " none found- return error
dac 9f+t dac 9f+t " save ulist ptr in t0
isz uniqpid isz uniqpid " generate new pid
lac uniqpid lac uniqpid
dac u.ac dac u.ac " return in AC
law sysexit law sysexit
dac u.swapret dac u.swapret " return from system call when swapped back in
lac o200000 lac o200000 " change process status to out/ready
tad u.ulistp i tad u.ulistp i
dac u.ulistp i dac u.ulistp i
jms dskswap; 07000 jms dskswap; 07000 " swap parent out
lac 9f+t lac 9f+t " get unused ulist slot back
dac u.ulistp dac u.ulistp " set ulist pointer
lac o100000 lac o100000 " mark child in/ready
xor u.ulistp i xor u.ulistp i
dac u.ulistp i dac u.ulistp i
lac u.pid lac u.pid
"** 01-s1.pdf page 15 "** 01-s1.pdf page 15
dac u.ac dac u.ac " return parent pid in AC?
lac uniqpid lac uniqpid
dac u.pid dac u.pid " set child pid
isz 9f+t isz 9f+t
dac 9f+t i dac 9f+t i " set pid in process table
isz u.rq+8 isz u.rq+8 " increment return address from sys call
dzm u.intflg dzm u.intflg " clear int flag
jmp sysexit jmp sysexit " return in child process
t= t+1 t= t+1
badcal: badcal: " bad (unimplemented) system call
clon clon " clear any pending clock interrupt?
-1 -1
dac 7 dac 7 " set location 7 to -1
.save: .save:
lac d1 lac d1
jms iget jms iget
@@ -86,16 +93,16 @@ badcal:
.exit: .exit:
lac u.dspbuf lac u.dspbuf
sna sna " process using display?
jmp .+3 jmp .+3 " no
law dspbuf law dspbuf " yes
jms movdsp jms movdsp
jms awake jms awake
lac u.ulistp i lac u.ulistp i
and o77777 and o77777 " mark process table entry free
dac u.ulistp i dac u.ulistp i
isz u.ulistp isz u.ulistp
dzm u.ulistp i dzm u.ulistp i " clear pid in process table
jms swap jms swap
.rmes: .rmes:

View File

@@ -1,31 +1,34 @@
"** 01-s1.pdf page 28 "** 01-s1.pdf page 28
" s5 " s5
" read/write a process from/to swap space
" call:
" AC/ first word of process table
" jms dskswap; DSLD bits
dskswap: 0 dskswap: 0
cll; als 3 cll; als 3 " get process disk address
dac 9f+t dac 9f+t " save in t0
jms dsktrans; -64; userdata; 9f+t; dskswap jms dsktrans; -64; userdata; 9f+t; dskswap " read/write user area
lac 9f+t lac 9f+t " get swap addr back
tad o20 tad o20 " advance by 16??
dac 9f+t dac 9f+t " save
jms dsktrans; -4096; 4096; 9f+t; dskswap jms dsktrans; -4096; 4096; 9f+t; dskswap " read/write user memory
isz dskswap isz dskswap " skip bits
jmp dskswap i jmp dskswap i " return
t = t+1 t = t+1
access: 0 access: 0
lac i.flags lac i.flags
lmq lmq " save in MQ
lac u.uid lac u.uid " get user id
spa spa " negative?
jmp access i jmp access i " yes: super user, return
sad i.uid sad i.uid " compare to file owner
lrs 2 lrs 2 " same: shift flags down two
lacq lacq " get flags back
and mode " mode from system call and mode " mode from system call
sza sza " access allowed?
jmp access i jmp access i " yes: return
jms error jms error " no: return error from system call
fassign: 0 fassign: 0
-10 -10

View File

@@ -255,29 +255,29 @@ pget: 0
t = t+3 t = t+3
iwrite: 0 iwrite: 0
dac 9f+t dac 9f+t " save arg in t0
lac iwrite lac iwrite " load return address
"** 01-s1.pdf page 38 "** 01-s1.pdf page 38
dac iread dac iread " save as iread return addr
lac cskp lac cskp
dac iwrite dac iwrite " set our return addr to "cskp"
jmp 1f jmp 1f
iread: 0 iread: 0
dac 9f+t dac 9f+t
lac cnop lac cnop " set iwrite return to "cnop"
dac iwrite dac iwrite
1: 1:
-1 -1
tad iread i tad iread i " get word before return addr
dac 10 dac 10 " store in index 8 & 9
dac 11 dac 11
isz iread isz iread " increment return addr
lac iread i lac iread i " load word
dac 9f+t+1 dac 9f+t+1 " save in t1
isz iread isz iread " increment return addr
lac o70000 lac o70000
xct iwrite xct iwrite
lac i.size lac i.size

View File

@@ -36,11 +36,13 @@ pibreak: " priority interrupt processing "chain"
isz uquant " increment user quantum counter isz uquant " increment user quantum counter
"** written: ttydelay -> ttyd1 "** written: ttydelay -> ttyd1
"** written: ttyrestart -> ttyres1 "** written: ttyrestart -> ttyres1
" referenced in iread:
cnop: cnop:
nop nop
-1 -1
dac 7 dac 7 " set location 7 to -1
clon clon " enable clock interrupts, reset flag
lac ttydelay lac ttydelay
spa spa
isz ttydelay isz ttydelay

View File

@@ -164,6 +164,16 @@ sysdata:
s.fblks: .=.+10 " free block numbers s.fblks: .=.+10 " free block numbers
s.uniq: .=.+1 " next unique value s.uniq: .=.+1 " next unique value
s.tim: .=.+2 " (up)time(?) in 60Hz ticks (low, high) s.tim: .=.+2 " (up)time(?) in 60Hz ticks (low, high)
" process table
" first word
" bits 0:2 -- status
" 0: free slot
" 1: in/ready
" 2: in/notready
" 3: out/ready
" 4: out/notready??
" bits 3:17 -- disk swap address/8
" second word: pid
ulist: ulist:
0131000;1;0;0 0131000;1;0;0
0031040;0;0;0 0031040;0;0;0
@@ -182,7 +192,7 @@ userdata:
u.uid: -1 " user id u.uid: -1 " user id
u.pid: 1 " process id u.pid: 1 " process id
u.cdir: 3 " connected directory (inode number?) u.cdir: 3 " connected directory (inode number?)
u.ulistp: ulist u.ulistp: ulist " pointer to process table entry
u.swapret: 0 u.swapret: 0
u.base: 0 u.base: 0
u.count: 0 u.count: 0
@@ -197,9 +207,12 @@ inode:
i.flags: .=.+1 " inode flags i.flags: .=.+1 " inode flags
" 400000 free?? (checked/toggled by icreat) " 400000 free?? (checked/toggled by icreat)
" 200000 large file " 200000 large file
" 000040 special? (checked by read/write) " 000040 special device (indicated by inum)?
" 000020 directory " 000020 directory
" 000017 can be changed by chmod. " 000010 owner read
" 000004 owner write
" 000002 world read
" 000001 world write
i.dskps: .=.+7 " disk block pointers (indirect if "large file") i.dskps: .=.+7 " disk block pointers (indirect if "large file")
i.uid: .=.+1 " owner i.uid: .=.+1 " owner
i.nlks: .=.+1 " link count i.nlks: .=.+1 " link count