|
|
DataMuseum.dkPresents historical artifacts from the history of: Bogika Butler |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Bogika Butler Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 35328 (0x8a00)
Types: TextFile
Names: »OLDCALLS.SS«
└─⟦909f4eb2b⟧ Bits:30009789/_.ft.Ibm2.50006622.imd Mogens Pelles Zilog 80,000 / EOS projekt
└─⟦this⟧ »OLDCALLS.SS«
└─⟦ddcd65152⟧ Bits:30009789/_.ft.Ibm2.50006617.imd Mogens Pelles Zilog 80,000 / EOS projekt
└─⟦this⟧ »OLDCALLS.SS«
ø eos version of unix system calls page 1 vir 83/06/20
ø written by Vilhelm Rosenqvist -- june 1983
ø
ø the function names exported below are sorted by their
ø 'UNIX system call number'
ø the labels appear in the systable at the end of this text
ø
.globl __exit,_fork,_read,_write,_open ø 01-05
.globl _close,_wait,_creat,_link,_unlink ø 06-10
.globl _exec,_chdir,_time,_mknod,_chmod ø 11-15
.globl _chown,_brk,_stat,_lseek,_getpid ø 16-20
.globl _mount,_umount,_setuid,_getuid,_stime ø 21-25
.globl _ptrace,_alarm,_fstat,_pause,_utime ø 26-30
.globl _access,_nice,_ftime ø 31-35
.globl _sync,_kill ø 36-40
.globl _dup,_pipe,_times,_profil,_locking ø 41-45
.globl _setgid,_getgid,_signal ø 46-50
.globl _acct,_phys,_lock,_ioctl ø 51-55
.globl _mpxchan, _execve,_umask ø 56-60
.globl _chroot ø 61-65
.globl _outline,_inpline,_putl,_getl,_gethc ø 66-70 these numbers are
.globl _get1b,_put1b,_macsbug ø 71-75 assigned
.globl _sbrk,_dup2 ø 76-80 by eos
.globl _setmem ø 64+17=81, 17=break
ø
ø run time variables in the .data section follows
ø
.data
ø constants containing error codes:
eperm=1
enoent=2
esrch=3
eintr=4
eio=5
enxio=6
e2big=7
enoexec=8
ebadf=9
echild=10
eagain=11
enomem=12
eacces=13
efault=14
enotblk=15
ebusy=16
eexist=17
exdev=18
enodev=19
enotdir=20
eisdir=21
einval=22
enfile=23
emfile=24
enotty=25
etxtbsy=26
efbig=27
enospc=28
espipe=29
erofs=30
emlink=31
epipe=32
edom=33
erange=34
edeadlock=35
ø
ø page 2 vir 83/06/20
ø various constants used in the run time system:
eos=7
obj_call=0
obj_return=1
dealloc=7
hexop=0x00020028 ø print memory in hex
zero_act=22 ø size of obj call arg list with zero actuals
one_act=36 ø ------------------------------- one actual
dealarg=22 ø --------dealloc ---------------zero actuals
pagemask=0777 ø pagesize:= 512 (= 9 bits)
orgsys=0x000C0000 ø unix C-runtime system
appl=0x0700 ø application family
univers=0 ø universal family
entry_ill=univers-2
data_ill=univers-7
give_up=univers+18
no_resources=univers+22
get_ref=2
assign=1
readseq=1
writeseq=2
seek=5
datasize=13
neworold=0
oldfile=1
ø
ø a unix context consists of the following pointers
fml=0
temp=0x4000
local=0x8000
stack=temp+1
gate=temp+2 ø not present in demo version
fs_ref=temp+3 ø return pointer from get_ref, points to a file system
ff_env=0x00010001 ø Æf,1,fildesÅ
local_1=local+1
objdir=local+4
legal_items=0x1C ø ...111.. a one indicates a legal return pointer kind
ø page 3 vir 83/06/20
.globl _etext,_edata,_end ø import symbol values from linker
.globl _environ,_errno,erreos ø global variables
.globl f_stk,f_data,top_text,top_bss ø used by cexappl
_environ: .long 0
_errno: .long 0
erreos: .long 0,0 ø holds d6/d7 after error calls
_eoscrtt: .long 0 ø test mask for the runtime system.
ø first byte : bit0=1: print stack before severe error return (prireturn)
ø bit1=1: print stack when unimplemented syscalls are called
ø bit2=1: print input/output buffers
ø bit3=1: print calls to the kernel
ø
ø the following three _top_ values should (also) be present in the text
ø section when text and data segments are separate (reentrant programs)
ø because the values are needed to map the data segment.
top_text: .long _etext ø top of program = first of data
top_data: .long _edata ø top of initialised data = first of bss
top_bss: .long _end ø top of bss, grows when _brk/_sbrk is called
ø
f_stk: .long 0 ø points to the first byte of the stack segment
f_data: .long 0 ø points to the first byte of the data segment
bsmax: .long 0 ø points to the top byte of the local data segment
ø _top_bss cannot grow beyond this value. at present
ø bsmax is fixed by the load format converter
ø program and communicated via
ø long(5) in the text header (sym_size in ld)
used_fildes: .long 0xE0000000 ø keeps track of pointers in the file envelope:
ø pointer Æfml,1,xÅ is free if bit 32-x equals zero
ø and Æfml,1,xÅ = nil pointer. in the demo version
ø the bit mask allone is trusted and the initial
ø value reserves input,output,error_output
dum_time: .long 0 ø time starts a jan 1 1970, time 100 sec past midn.
ft_msec=4 ø offset to millisec used in ftime
ft_zs=6 ø offset to zone and daylight saving flag
ø
sd=1 ø should be changed when to correct value of sig_dfl is known
ø table with entry points to signal catching rutines, initialized to default.
sigfunc: .long sd,sd,sd,sd,sd,sd,sd,sd,sd,sd,sd,sd,sd,sd,sd ø 15 entries
topfunc:
lenfunc=topfunc-sigfunc ø length of function table
ø
ø page 4 vir 83/06/20
ø entry address to program equals zero
ø d0= entry number: 0 (exception), 1 (run), and 2 (fork) are handled
ø
.text
start:
ø=========================
ø called entry: d3.w= #formals, a5= f_stk, a6= t_stk, a7= f_val
cmpw #1,d0 ø if func <1 , =1 , >1 then
beqs run_entry ø on =1 goto run
bgt fork_entry ø on >1 goto fork_entry
ø exception entry: ø on <1
ø================================
ø return give_up to the caller of this program
ø
btst #0,_eoscrtt
beqs 17$
moveml #0xFFFF,a7@- ø save regs for print out
17$:
swap d3
addl #give_up,d3
movl d6,a4 ø future d6 holds ill addr?
movl d3,a5 ø future d7 holds cause + give_up
ø continue in prireturn below
prireturn:
ø===========
ø a4/a5 holds obj_result
ø print stack and return to obj_caller
btst #0,_eoscrtt
beqs 17$
movl a4,a7@-
movl a5,a7@- ø put result on stack, may cause a trap if a7 is spoiled
movl #127,d2
movl a7,d4
movl #hexop,d5
trap #eos
17$:
movl a4,d6
movl a5,d7
moveq #1,d5
trap #eos
ø page 5 vir 83/06/20
run_entry: ø set up arg vector and env vector and call _main
ø==============
trap #9 ø to be removed
movl a5,f_stk ø f_stk:= a5;
movl 16,bsmax ø bsmax:= value stored by eosload in header.sym_size;
moveq #0,d0
moveq #0,d1 ø nargs:=0; state:= scan args;
cmpl a7,a6 ø when no val data
beq 9$ ø goto run_call_error
1$: ø next val:
movw a6@-,d7 ø d7:= length of val
blt 9$ ø when length < 0 goto run_call_error;
clrw a6@ ø ensure that terminating NULL is present
btst #0,d7 ø test for odd length
beqs 6$ ø skip if even
addqw #1,d7 ø round up length
clrb a6@(-1) ø clear unused byte
6$:
subw d7,a6 ø a6:= val address
cmpl a7,a6 ø ccr:= a6-a7 ( >= req.0)
blts 9$ ø when val < lowval goto run_call_error;
cmpl #0x2a2a2a2a,a6@ ø when text = '****'
beqs 2$ ø goto end of args
movl a6,a5@+ ø push pointer to val
3$: ø scan_envs:
addqw #1,d1 ø nargs/nenvs := nargs/nenvs + 1;
cmpl a7,a6 ø if more values
bnes 1$ ø goto next val;
tstl d1 ø if state= scan args
bges 5$ ø goto end of args, no env present;
ø d1.w= nenvs , d0.l=nargs; move vectors to stach top
clrl a7@- ø zero after env vector
movl a7,a1 ø a1:= top env vector:= nenvs*4;
lslw #2,d1 ø d1:= length of env vector:= nenvs*4;
subw d1,a1 ø a1:= first of env vector ;
4$: ø copy next:
movl a5@-,a7@- ø copy one vector element
cmpl f_stk,a5 ø if last element not copied
bnes 4$ ø goto copy next;
movl a7,a0 ø a0:= first of arg vector
movl a1,_environ ø environment:= pointer to env vector
movl a1,a7@- ø env vector
movl a0,a7@- ø arg vector
movl d0,a7@- ø nargs
moveq #0,d0 ø test mask := no test output := 0
movl a0@,a0 ø a0 points to first arg (=program name)
cmpl #0x74657374,a0@
bnes 7$
movl a0@(4),d0 ø when progname starts with 'test' testmask:= next long
7$:
movl d0,_eoscrtt
jsr _main ø main(nargs,arg vector,env vector):
jsr _exit ø clean up files
ø at return d0 = result of whole program= result of _main;
bra main_exit
5$: ø end of args, no env present:
subql #4,a6 ø room for dummy zero to terminate env
movl a6,a7 ø a7 must still be equal to a6
2$: ø end of args:
tstl d1 ø if no args (d1=0) or more than one '****' text (d1<0)
bles 9$ ø then goto run_call_error;
clrl a5@+ ø push zero after arg vector
clrl a6@ ø long zero after env texts
movl d1,d0 ø d0.l:= nargs
moveq #-1,d1 ø nenvs:= -1, state:= scan env;
bra 3$ ø goto scan env, which increases nenvs to zero
9$: ø run_call_error:
movl #data_ill,d7
movl #orgsys,d6
movw d0,d6
addw d1,d6 ø d6:= orgsys+text_index;
moveq #1,d5
trap #eos
ø page 6 vir 83/06/20
fork_entry:
ø==============
movl #entry_ill,d7
movl #orgsys,d6
moveq #1,d5
trap #eos
small_stk:
ø==========
movl #no_resources,a5 ø future d7
movl a7,a4 ø future d6:= stacktop
bra prireturn
popsys:
movl a7@+,a0 ø return addr
movl a7@+,d0 ø syscall label
subl #systable,d0
lsrl #2,d0
addl #0xEE0000,d0
movl a0,a7@- ø return addr
btst #1,_eoscrtt
beqs 17$
movl d0,a7@- ø syscall index
moveq #126,d0
movl d0,a7@-
movl a7,a7@-
bsr _prthex
addql #8,a7
movl a7@+,d0 ø d0:= index
17$:
rts
negative:
bsrs popsys
movl d0,_errno ø _errno:= syscall index + not implemented
moveq #-1,d0 ø d0:= -1 ; "not ok"
rts
ppositive:
bsrs popsys
moveq #0,d0 ø d0:= 0 ; "ok"
rts
.globl _trap9
_trap9: ø called by c test programs
ø===================================
movl a7@(4),d0
movl _errno,d1
trap #9
rts
trp7: ø print arg and result of kernel call
btst #2,_eoscrtt
bnes 17$
trap #eos
rts
17$:
movl d5,a7@-
movl d4,a7@-
movl d2,a7@-
movl #hexop,d5
addql #1,d2
trap #eos ø print args
movl a7@,d2
movl a7@(4),d4
movl a7@(8),d5
trap #eos ø call operation
movl d7,a7@-
movl d6,a7@-
movl f_stk,d4
movl #32,d2
movl #hexop,d5
trap #eos ø print return value data
movl a7,d4
moveq #20,d2 ø print regs
movl #hexop,d5
trap #eos ø print registers
movl a6@,d4
moveq #127,d2
movl #hexop,d5
trap #eos ø print stack below system call
movl a7@+,d6
movl a7@+,d7 ø restore original result of op
addl #12,a7 ø pop regs
rts
ø trp7: ø testversion of trap #eos
movl a7,d7 ø save stack pointer
movl f_stk,a7 ø stack pointer:= first of stack;
ø movl #6,a7@ ø return value in get_ref,read and write
ø movl #3,a7@(6) ø return value in get_ref
trap #9 ø print regs and stack segm
movl d7,a7 ø restore stack pointer
ø moveq #0,d7 ø simulate
ø moveq #0,d6 ø simulate
trap #eos
rts
.globl _prttxt,_prthex
_prttxt:
moveq #1,d0
bra dollar1
_prthex:
moveq #2,d0
dollar1:
movl a7@(4),a0 ø a0:= address
movl a7@(8),d1 ø d1:= length
link a6,#-56
moveml #0x3FFF,a7@ ø save regs
movl a0,d4 ø d4:= address
movl d1,d2 ø d2:= length
addql #1,d2 ø compensate for odd addresses rounded down by the kernel
moveq #40,d5
swap d5
movw d0,d5
swap d5
trap #eos
tstw d7
beq 2$
moveq #-1,d7
bras 3$
2$: moveq #0,d7
3$: movl d7,a7@ ø saved d0:= result ( 0 or -1)
moveml a7@,#0x3FFF ø restor regs
unlk a6
rts
ø page 7 vir 83/06/20
ø procedures shared between syscalls
ø
assfao: ø d0=fildes, d1=create_mode d2=unix_io_mode, a4=name
ø========ø a5:= end_of_name, da:=??? saved d0 is on stack at call time.
ø
subql #2,d2 ø if unix_io_mode <0 or > 2
bgts 9$ ø then goto error
addql #3,d2 ø d2:= eos_io_rights:= unix_io_mode + 1;
bles 9$
link a6,#-one_act ø a6:= top_arg, a7:= low_arg;
movl f_stk,a1 ø a1:= valdata:= f_stk;
movl a1,d5 ø d5:= valdata;
moveq #4,d3 ø d3:= length of integer:= 4;
movl d1,a1@+ ø push create mode in valdata
movw d3,a1@+ ø length of integer
movl d2,a1@+ ø push io_rights in valdata
movw d3,a1@+ ø length of integer
movl a7,d6
subql #4,d6 ø d6:= max destination; "protect the stack"
bsr mov_txt ø mov_txt(a1/a4/d6=!,a1/a5/d7:=!);
blt small_stk ø when destination to small goto stack to small
movw d7,a1@+ ø length of name in valdata
subl d5,a1 ø a1 := length of valdata:= valdata-top of valdata
movl a6,a3 ø a3:= top_arg
movl #fs_ref,a3@- ø fs_ref
movl #assign,a3@- ø .assign
movl #stack,a3@- ø valdata in stack
movw #7,a3@-
clrl a3@-
movl a1,a3@- ø length of valdata
addl #ff_env,d0 ø d0:= pointer address into file_env;
movl d0,a3@- ø 1. actual := pointer addr
movw #2,a3@- ø return pointer
clrl a7@ ø actual type := pointer
moveq #one_act,d2 ø d2:= arg_length
movl a7,d4 ø d4:= low_arg
moveq #0,d5 ø d5:= obj_call
bsr trp7 ø call kernel
unlk a6 ø pop call
tstw d7
beqs 1$
bra obj_call_error ø if result <> ok then goto obj_call_error;
1$: rts
9$: ø error:
moveq #einval,d0 ø_errno:= invalid argument
movl d0,_errno
bra neg_d0
obj_call_error: ø d6/d7=result, one 'rts' and saved d0 is on the stack
ø=============
ø
movw #1,_errno ø _errno:= hex 10000
movw d7,_errno+2 ø + family/cause
moveml #0x00C0,erreos ø _erreos:= result in d6/d7
neg_d0: ø
ø========ø
moveq #-1,d0 ø d0:= saved d0:= -1
movl d0,a7@(4) ø ccr:= lt ;
rts ø return
ø page 8 vir 83/06/20
mov_txt: ø a1=destination, d6=max destination, a4= source
ø=========ø a1:= rounded dest., a5:= end_source, d7:= #chars moved excl. null
ø
ø copy chars from a4 to a1 while a1 is increased. copying stops normally
ø if a null_char is reached, or abnormally if d6 is reached.
ø normal termination : d7 >= 0, ccr = ge
øabnormal termination : d7 < 0, ccr = lt
ø
movl a1,d7 ø d7:= old destination
movl a4,a5 ø a5:= old source
1$: ø next two chars:
cmpl a1,d6 ø when destination >= max_destination then
bles 9$ ø goto error
movb a5@+,a1@+ ø copy char, update a5/a1
beqs 2$ ø if null char goto normal termination
movb a5@+,a1@+ ø copy char, update a5/a1
bnes 1$ ø if not null char goto next two chars;
2$: ø normal termination:
subql #1,a1 ø a1:= address of copied null char; "the top dest addr"
subl a1,d7 ø d7:= - #chars:= (top_destination - destination);
addql #1,a1
exg a1,d7 ø d7:=:a1
bclr #0,d7 ø destnation has been rounded
exg d7,a1 ø a1:=:d7
negl d7 ø d7:= #chars, ccr:= ge ;
rts
9$: ø abnormal:
moveq #-1,d7 ø d7:= -1, ccr:= lt ;
rts
ø page 9 vir 83/06/20
get_fs_ref: ø call objdir to get ref to file system
ø====================================================
ø a4=f_txt, saved d0 is assumed to be on top of stack
ø return: ccr<>lt : ok return: a3=pos_txt,a4=f_txt,a5=top_txt,other=undef
ø ccr=lt: error return (no item/no objdir etc)
link a6,#-one_act ø a6:=top_arg; a7:=low_arg;
movl a7,d4 ø d4:=lowarg
movl f_stk,a1 ø d5:=a1:= first byte of stack
movl a1,d5
moveq #4,d7 ø d7:= length of integer
addql #4,a1 ø room for return integer: item_kind
movw d7,a1@+ ø length of int
addql #4,a1 ø room for return integer: used chars
movw d7,a1@+ ø length of int
movl a7,d6
subql #4,d6 ø d6:= max_destination
bsr mov_txt ø mov_txt(a1=destin"updated",d6=max_destin,
ø a4=f_txt,a5:=end_txt,d7:=length );
blts 9$ ø if stack to small goto error
movw d7,a1@+ ø length of name in val data
subl d5,a1 ø a1:= length of val data seg
movl a6,a3 ø a3:= top_arg
movl #objdir,a3@- ø call objdir
movl #get_ref,a3@- ø .getref
movl #stack,a3@- ø val data in stack
movw #3,a3@-
clrl a3@-
movl a1,a3@- ø push length of val data seg
movl #fs_ref,a3@- ø pointer address of pointer, to receive pointer to fs
movw #2,a3@- ø return pointer
clrl a7@ ø actual type=pointer actual
moveq #one_act,d2
movl a7,d4
moveq #0,d5
bsr trp7
unlk a6
tstw d7
bnes 9$ ø if result of call <> ok then goto error
movl f_stk,a1
movl a1@,d6 ø d6:= returned item kind , ccr:= ge (if objdir is ok)
moveq #legal_items,d7 ø d7:= ones for legal kinds;
btst d6,d7
beqs 9$ ø when illegal item kind then goto error
addql #6,a1
movl a1@,a3 ø a3:= returned used chars
addl a4,a3 ø a3:= pos address
rts ø return with ccr <> lt
9$:
moveml #0x00C0,erreos ø save d6,d7
movl #enoent,_errno
moveq #-1,d0 ø d0:= saved d0:= -1
movl d0,a7@(4)
rts ø return with ccr=lt
ø page 10 vir 83/06/20
check_nil: ø d0=fildes, d7:=result, d0/d1/a4/a5/a6 survives
ø============================================================
ø d7=0 : Æf,1,d0+1Å is a nil pointer
ø d7=1 : fildes specifies a nonexsisting pointer
ø d7=4 : Æf,1,d0+1Å is not a nil pointer
ø
ø until ref_equal has been implemented by the kernal, the demo version
ø below will be used. the demo version assumes that used_fildes is
ø a correct reflection of the pointer situation.
ø
cmpl #19,d0
bhis 1$ ø when fildes < 0 or > 19 then goto error_1
movl used_fildes,d7
moveq #31,d6
subw d0,d6 ø d6:= bit# fildes := 31-fildes;
btst d6,d7
bnes 4$ ø when bit# fildes is set in used_fildes then goto error_4
moveq #0,d7 ø result = ok
rts
4$:
moveq #4,d7 ø result := fildes is not free
rts
1$:
moveq #1,d7 ø result := fildes is illegal
rts
ø page 11 vir 83/06/20
find_fildes: ø compute unused fildes integer
ø============================================
ø returns -1 (_errno=emfile) or
ø free fildes >=0 in d0
ø spoiles all registers except a4/a5/a6/a7
moveq #0,d0 ø d0:=fildes:=0
movl used_fildes,d1 ø d1:= help mask
1$: ø next sign bit
blts 2$ ø when sign bit is on goto pointer in use
bsr check_nil ø check_nil(d0=index,d7:=result,d1=same);
subqb #1,d7 ø d7=0 ok
beqs 9$ ø d7=1 pointer index too big, goto error
bgts 3$ ø d7=4 pointer not nil, try next
ø pointer is free:
rts ø return with index in d0
3$: ø pointer was not nil
bsr resv_fildes ø update bit in mask
2$: ø bit was on, pointer in use:
addql #1,d0 ø d0:= next index
lsll #1,d1 ø next bit in mask
bras 1$ ø goto next sign bit
9$: ø no free pointers
moveq #emfile,d0 ø errno:= emfile
movl d0,_errno
moveq #-1,d0 ø do:=no free:=-1
rts
resv_fildes: ø d0=fildes,d6/d7:=????
ø=============================================
bsr check_fildes ø returns only if fildes is ok
bset d7,d6 ø set the bit
movl d6,used_fildes
rts
check_fildes: ø dirty return is made below
moveq #31,d7
cmpl d7,d0
bhis 1$ ø when fildes <0 or > 31 goto dirty
subl d0,d7 ø d7:= bit# := 31-fildes
movl used_fildes,d6
rts ø normal return
1$: ø dirty
addql #4,a7 ø pop return
rts ø dirty return
free_fildes: ø d0=fildes, d6/d7:=????
ø=============================================
bsr check_fildes ø returns only if fildes ok
bclr d7,d6 ø clear the bit
movl d6,used_fildes
rts
ø page 12 vir 83/06/20
ø eos implementations of unix system calls
ø in alfabetic order
eos_brk:
ø====================
moveq #0,d1
movl d1,a1 ø a1:= ok_result:= zero;
movl a7@(4),d1 ø d1:= new _top_bss := first argument;
bras set_break
eos_sbrk:
ø===================
movl top_bss,a1 ø a1:= ok_result:= old top_bss;
movl a7@(4),d1 ø d1:= new top_bss:= increment (=first argument)
addl a1,d1 ø + old top_bss;
set_break: ø d1= new top_bss, a1= ok_result (zero or old top_bss)
ø=================================================
ø round up d1
movl #pagemask,d0 ø d0:= 000...111 ;
addl d0,d1 ø d1:= d1 + (pagesize-1);
notl d0 ø d0:= 111...000 ;
andl d0,d1 ø d1:= d1 div pagesize * pagesize;
cmpl bsmax,d1 ø ccr:= d1-bsmax (<= req.)
bhis 9$ ø when d1 > bsmax goto error
ø cmpl top_data,d1 ø ccr:= d1-top_data ( > req.)
ø blss 9$ ø when d1 <= top_data goto error
movl d1,top_bss ø top_bss:= new top_bss;
movl a1,d0 ø d0:= ok_result;
rts
9$: ø error:
moveq #enomem,d0 ø
movl d0,_errno ø ø _errno:= no memmory;
moveq #-1,d0 ø d0:= not ok;
rts
ø page 13 vir 83/06/20
eos_close: ø (fildes)
ø======================
close_frm=56
link a6,#-close_frm
moveml #0x3FFF,a7@ ø save regs
moveq #0,d0
movw a6@(10),d0 ø d0:= positive fildes
bsr free_fildes ø d0=fildes d6/d7:=??
link a6,#-dealarg
movl a6,a3 ø a3:= top_arg
addl #ff_env,d0 ø d0:= pointer address
movl d0,a3@- ø 1. arg to dealloc
movl d0,a3@- ø 2. arg to dealloc
clrw a3@- ø void value arg
moveq #dealarg,d2 ø d2:= arg_length;
movl a7,d4 ø d4:= low_arg
moveq #dealloc,d5 ø d5:= func
bsr trp7 ø call kernel
unlk a6
clrl a7@ ø save d0:= result:= ok; "always ok"
moveml a7@,#0x3FFF
unlk a6
rts
eos_create:
ø=================
moveq #neworold,d1 ø d1:= eos_create_mode; "this is a create call"
moveq #2,d0 ø a0:= unix io_mode:= write;
movl d0,a0
bra open_create
eos__exit:
ø===============
movl a7@(4),d0 ø d6:= exit status
main_exit:
ø=========
movl #orgsys,d6
movb d0,d6 ø d6:= orgsys, exit status;
lslw #8,d6 ø shift 8
moveq #0,d7 ø d7:= return due to exit:= ok
moveq #1,d5 ø d5:= obj_return;
trap #eos ø call kernel
eos_getpid:
ø======================================
movl _environ,d0
beqs 1$ ø if no environ vector then processid:=0
movl d0,a0 ø else
movl a0@,a0 ø a0:= first env_text;
moveq #0,d0
movb a0@,d0 ø d0:=processid:= first letter of first env_text;
1$: ø end ;
rts ø return processid;
ø page 14 vir 83/06/20
eos_lseek:
ø=====================
lseek_frm=56
link a6,#-lseek_frm
moveml #0x3FFF,a7@
movl a6,a5 ø a5:= arg base;
link a6,#-zero_act ø a6:=a3:= top_arg, a7:= low_arg;
movl a6,a3
movl #ff_env,d0
addw a5@(10),d0 ø d0:= Æf,1,fildes+1Å
movl d0,a3@- ø push fao address
moveq #seek,d0
movl d0,a3@- ø push function = seek
movl #stack,a3@- ø stack
movw #3,a3@- ø holds
clrl a3@- ø val data
moveq #18,d0 ø length of val data
movl d0,a3@- ø := 18 = 3 * 6 (3 integers)
movl f_stk,a0 ø a0:= low stack
moveq #4,d7 ø d7:= length of integer
addql #4,a0 ø room for returned position
movw d7,a0@+ ø integer
movl a5@(12),a0@+ ø push offset bytes
movw d7,a0@+ ø integer
movl a5@(16),a0@+ ø push base mode
movw d7,a0@+ ø integer
cmpl a7,a0 ø ccr:= a0-a7 ( <=0 req.)
bgt small_stk ø when a0 > a7 goto small_stack
moveq #zero_act,d2
movl a7,d4
moveq #obj_call,d5
bsr trp7
unlk a6
tstw d7
beqs 1$
bsr obj_call_error ø when result <> ok then call obj_call_error;
bras 2$
1$: movl f_stk,a0
movl a0@,a7@ ø saved d0:= returned position
2$: moveml a7@,#0x3FFF ø restore regs
unlk a6
rts
ø page 15 vir 83/06/20
eos_open:
ø================
moveq #oldfile,d1 ø d1:= eos_create_mode; "this is an open call"
movl a7@(8),a0 ø a0:= unix io_mode:= 2.arg
ø continue in open create
open_create: ø d1=eos_create_mode, a0=unix io_mode
opcr_frm=56
link a6,#-opcr_frm
moveml #0x3FFF,a7@ ø save regs including d1,a0 with argument values
bsr find_fildes ø d0:= fildes;
movl d0,a7@ ø saved d0:= fildes;
blts 1$ ø when error goto return
movl a6@(8),a4 ø a4:= name:= 1.arg
bsr get_fs_ref ø get_fs_ref(a4=name,a3:=rest_name);
blts 1$ ø when error goto return
movl a7@,d0 ø d0:= fildes;
movl a7@(4),d1 ø d1:= saved d1:=eos_create_mode;
movl a7@(32),d2 ø d2:= save a0:= unix io_mode;
movl a3,a4 ø a4:= file_name:= rest_name;
bsr assfao ø fs_ref.assign(d0/d1/d2/a4=!)
bnes 1$ ø when errror goto return
movl a7@,d0 ø d0:= fildes
bsr resv_fildes ø reserve fildes (d0=fildes,d6/d7:=?)
movl a7@(4),d1 ø d1:=eos_create_mode;
cmpl #oldfile,d1 ø test if oldfile was used as create mode
beqs 1$ ø if open was called (oldfile was used) goto return
bsr cut_file ø cut_file to zero bytes (create was called)
1$: ø return:
moveml a7@,#0x3FFF
unlk a6
rts
cut_file: ø d0=fildes
link a6,#-zero_act ø a6:= top_arg; a7:= lowarg;
movl a6,a3 ø
movl d0,a3@-
addl #ff_env,a3@ ø push pointer to fao
moveq #datasize,d1
movl d1,a3@- ø push function code
movl #stack,a3@- ø value data
movw #7,a3@- ø argument
clrl a3@-
moveq #6,d1
movl d1,a3@- ø in first 6 bytes of stack segment
movl f_stk,a0 ø room is present because assfao could be called
clrl a0@+ ø data size of file:= 0;
movw #4,a0@+ ø integer
movl a7,d4 ø low_arg
moveq #zero_act,d2 ø length of arg
moveq #0,d5 ø obj_call
bsr trp7 ø call kernel
unlk a6
rts
ø page 16 vir 83/06/20
eos_read:
ø====================
moveq #readseq,d0
movl d0,a1 ø a1:=function code := readseq;
øcontinue in read_write below
read_write: ø a1= function = read or write
rw_frm=56
movl a7@(4),d0 ø d0:= fildes
movl a7@(8),a0 ø a0:= buf
movl a7@(12),d1 ø d1:= nbytes
link a6,#-rw_frm
moveml #0x3FFF,a7@ ø save regs
link a6,#-one_act ø room for kernel call
movl f_stk,a2 ø a2:= f_stk
cmpl a2,a0 ø ccr:= a0-a2
bges 1$ ø if a0<a2 (i.e. buf < f_stk) then
movl #local_1,d2 ø buf is placed in data segment, a0=offset
bras 2$ ø
1$: ø else
movl #stack,d2 ø buf is placed in stack (temp_1)
subl a2,a0 ø a0:= offset:= buf address - f_stk;
2$: ø ;
moveq #4,d7 ø d7:= integer type:= 4;
moveq #1,d6 ø mode:= unix-i/o := 1;
movl d6,a2@+ ø mode is a call value;
movw d7,a2@+ ø mode is an integer;
addql #4,a2 ø room for return integer: nbytes
movw d7,a2@+ ø integer
cmpl a7,a2 ø ccr:= a2-a7 ( <= req.)
bgt small_stk ø when a2 > a7 then goto small_stack;
movl a6,a3 ; a3:= top of arg
addl #ff_env,d0 ; d0:= pointer addres to fao
movl d0,a3@- ø push pointer addr
movl a1,a3@- ø push function (read_seq or write_seq)
movl #stack,a3@- ø value data in stack
movw #7,a3@-
clrl a3@-
moveq #12,d7
movl d7,a3@- ø 12 bytes valuedata
movl d2,a3@- ø create sub seg argument for buf
movw #3,a3@- ø read+write allowed
movl a0,a3@- ø offset to buf
movl d1,a3@- ø length of buf
moveq #one_act,d2 ø d2:= length of arg
movl a7,d4 ø d4:= low_arg
moveq #0,d5 ø d5:= obj_call
bsr trp7
unlk a6 ø pop call
tstb d7 ø mik mak
beqs 3$
bsr obj_call_error ø if result <> ok then pack result and saved d0
bra 4$ ø else
3$: movl f_stk,a0 ø a0:= val data
movl a0@(6),a7@ ø saved d0:= returned byte count;
btst #3,_eoscrtt
beqs 17$
movl a7@(32),a0 ø length is already on stack
movl a0,a7@- ø push buf address
bsr _prthex ø print io buffer
addql #4,a7 ø pop address
17$:
4$: moveml a7@,#0x3FFF
unlk a6
rts
ø page 17 vir 83/06/20
eos_signal:
ø====================
movl a7@(4),d0 ø d0:= signal#
lslw #2,d0 ø d0.w := signal entry offset;
blts 9$ ø when offset < 0 goto error
cmpw #lenfunc,d0 ø ccr:= d0-lenfunc ( < req.)
blts 1$ ø when offset inside table goto ok
9$: ø error:
moveq #einval,d0 ø
movl d0,_errno ø _errno:= ill argument;
moveq #-1,d0 ø d0:= not ok;
rts ø return;
1$: ø ok:
lea sigfunc,a0 ø a0:= signal entry :=signal table
addw d0,a0 ø + signal entry offset;
movl a0@,d0 ø d0:=old signal function = content of signal entry;
movl a7@(8),a0@ ø signal entry:= new signal function:= second argument;
rts ø return
eos_time:
ø=======================
moveq #100,d0 ø simulate that 100 seconds has elapsed
addl dum_time,d0 ø
movl d0,dum_time ø
movl a7@(4),a0 ø a0:= address of return value
movl a0,d1 ø test a0 in d1
beqs 1$ ø when address = 0 goto skip
movl d0,a0@ ø return dummy time value
1$: rts
eos_ftime:
ø=======================
movl a7@(4),a0 ø a0:= address of return record structure;
clrw a0@(ft_msec) ø millisec:=0;
moveq #-1,d0
movw d0,a0@(ft_zs) ø zone:= se-cp := -1; summer := yes;
bras eos_time ø set dummy time via call to eos_time;
eos_write:
ø===============
moveq #writeseq,d0
movl d0,a1 ø a1:= function:= write
bra read_write
ø page 19 vir 83/06/20
ø below follows the systable. all calls to syscalls jumps via this table
ø
systable:
__exit: bra eos__exit ø 01 terminate a process
_fork: bsr negative ø 02 fork a new process
_read: bra eos_read ø 03 read from a file
_write: bra eos_write ø 04 write to a file
_open: bra eos_open ø 05 open a file for read or write
_close: bra eos_close ø 06 close a file
_wait: bsr negative ø 07 wait for a process to terminate
_creat: bra eos_create ø 08 create a new file
_link: bsr ppositive ø 09 link to a file
_unlink: bsr ppositive ø 10 remove a directory entry
_exec: bsr negative ø 11 execute a file (obsolete?)
_chdir: bsr negative ø 12 change current working directory
_time: bra eos_time ø 13 get date and time
_mknod: bsr negative ø 14 make a directory or a special file
_chmod: bsr negative ø 15 change mode of a file
_chown: bsr negative ø 16 change owner and group of a file
_brk: bra eos_brk ø 17 extend heep segment
_stat: bsr negative ø 18 get status of a file
_lseek: bra eos_lseek ø 19 position in a file
_getpid: bra eos_getpid ø 20 get process id
_mount: bsr negative ø 21 mount a file system
_umount: bsr negative ø 22 unmount a file system
_setuid: bsr ppositive ø 23 set user id
_getuid: bsr ppositive ø 24 get user id
_stime: bsr ppositive ø 25 set time
_ptrace: bsr negative ø 26 process trace
_alarm: bsr negative ø 27 schedule signal after specified time
_fstat: bsr negative ø 28 get file status
_pause: bsr negative ø 29 stop until signal
_utime: bsr ppositive ø 30 set file times
bsr negative ø 31 stty is obsolete
bsr negative ø 32 gtty is obsolete
_access: bsr ppositive ø 33 determine accessibility of a file
_nice: bsr ppositive ø 34 set program priority
_ftime: bra eos_ftime ø 35 get date and time
_sync: bsr ppositive ø 36 update the super block
_kill: bsr negative ø 37 send signal to kill a process
bsr negative ø 38 not assigned
bsr negative ø 39 not assigned
bsr negative ø 40 tell is obsolete
ø page 20 vir 83/06/20
_dup: bsr negative ø 41 duplicate an open file descriptor
_pipe: bsr negative ø 42 create an interprocess channel
_times: bsr ppositive ø 43 get process times
_profil: bsr negative ø 44 make execution time profile
_locking: bsr negative ø 45 file concurrency control
_setgid: bsr ppositive ø 46 set group id
_getgid: bsr ppositive ø 47 get group id
_signal: bra eos_signal ø 48 catch or ignore signals
bsr negative ø 49 not assigned
bsr negative ø 50 not assigned
_acct: bsr negative ø 51 turn accounting on or off
_phys: bsr negative ø 52 map user virtual address to physical memory
_lock: bsr ppositive ø 53 lock a process in primary memory
_ioctl: bsr ppositive ø 54 control device
bsr negative ø 55 not assigned
_mpxchan: bsr negative ø 56 ??
bsr negative ø 57 not assigned
bsr negative ø 58 not assigned
_execve: bsr negative ø 59 execute a file
_umask: bsr ppositive ø 60 set file creation mode mask
_chroot: bsr negative ø 61 change root directory
bsr negative ø 62 not assigned
bsr negative ø 63 not assigned
bsr negative ø 64 not assigned
bsr negative ø 65 not assigned
_outline: bsr negative ø 66 mio?
_inpline: bsr negative ø 67 mio?
_putl: bsr negative ø 68 mio?
_getl: bsr negative ø 69 mio?
_gethc: bsr negative ø 70 mio?
_get1b: bsr negative ø 71 mio?
_put1b: bsr negative ø 72 mio?
_macsbug: bsr negative ø 73 mio?
bsr negative ø 74 not assigned
bsr negative ø 75 not assigned
_sbrk: bra eos_sbrk ø 76 extend heep segment
_dup2: bsr negative ø 77 duplicate filedescriptor
bsr negative ø 78 not assigned
bsr negative ø 79 not assigned
bsr negative ø 80 not assigned
_setmem: bsr negative ø 81 ?? 81=64+17, 17=_brk
bsr negative ø transmission problem ?
ø end of eos syscalls
«eof»