├── LICENSE ├── README ├── bin └── .gitignore ├── config ├── Makefile ├── lexer.l └── parser.y ├── contrib ├── README ├── distodt │ ├── README │ ├── h │ │ ├── bed.h │ │ ├── bedata.h │ │ ├── bmutils.h │ │ ├── downloadd.h │ │ ├── netutils.h │ │ ├── status.h │ │ ├── tokens.h │ │ └── utils.h │ ├── man │ │ ├── bed.1 │ │ ├── bed.doc │ │ ├── bedkill.1 │ │ ├── bedkill.doc │ │ ├── bedreboot.1 │ │ ├── bedreboot.doc │ │ ├── busers.1 │ │ ├── busers.doc │ │ ├── download.1 │ │ ├── download.doc │ │ ├── fusers.1 │ │ ├── fusers.doc │ │ ├── odt.1 │ │ ├── odt.doc │ │ ├── odtunlock.1 │ │ ├── odtunlock.doc │ │ ├── status.1 │ │ └── status.doc │ └── src │ │ ├── Makefile │ │ ├── bed.c │ │ ├── bedkill.c │ │ ├── bedreboot.c │ │ ├── bmutils.c │ │ ├── busers.c │ │ ├── download.c │ │ ├── downloadd.c │ │ ├── fusers.c │ │ ├── lib.a │ │ ├── lock.c │ │ ├── machines │ │ ├── netutils.c │ │ ├── obtainlock.c │ │ ├── obtainstatus.c │ │ ├── odt.c │ │ ├── odtd.c │ │ ├── odtunlock.c │ │ ├── parser.y │ │ ├── parsestatus.c │ │ ├── prstatus.c │ │ ├── releaselock.c │ │ ├── scanner.l │ │ ├── status.c │ │ ├── support.c │ │ ├── sysstat.c │ │ ├── utils.c │ │ ├── y.tab.c │ │ └── y.tab.h └── ether.monitor │ ├── README │ ├── etc │ ├── Makefile │ ├── Makefile.RAW │ ├── margparse.c │ ├── marp.c │ ├── mep.c │ ├── meread.c │ ├── mewrite.c │ ├── mhelp.c │ ├── micmp.c │ ├── minit.c │ ├── mip.c │ ├── monitor │ ├── mrarp.c │ ├── mshell.c │ ├── mtabinit.c │ ├── mtcp.c │ └── mudp.c │ ├── h │ ├── arp.h │ ├── conf.h │ ├── ctype.h │ ├── deqna.h │ ├── ether.h │ ├── icmp.h │ ├── ip.h │ ├── kernel.h │ ├── mark.h │ ├── micmp.h │ ├── monitor.h │ ├── mshell.h │ ├── mshellc.h │ ├── net.h │ ├── network.h │ ├── proc.h │ ├── sleep.h │ ├── slu.h │ ├── tcp.h │ ├── tty.h │ └── udp.h │ ├── man │ └── netmon.doc │ └── sys │ ├── Makefile │ ├── Makefile.RAW │ ├── addarg.c │ ├── argparse.c │ ├── arp.c │ ├── arpfind.c │ ├── arpinit.c │ ├── blkcopy.c │ ├── blkequ.c │ ├── clkinit.c │ ├── dtoIP.c │ ├── ep.c │ ├── eread.c │ ├── ethinit.c │ ├── ethrstrt.c │ ├── ethwstrt.c │ ├── ewrite.c │ ├── example │ ├── example.c │ ├── example1.c │ ├── getaddr.c │ ├── getbuf.c │ ├── getname.c │ ├── getnet.c │ ├── getpath.c │ ├── gettime.c │ ├── maddarg.c │ ├── maddrtab.c │ ├── margparse.c │ ├── mark.c │ ├── marp.c │ ├── marp2.c │ ├── mep.c │ ├── mep1.c │ ├── mep2.c │ ├── meread.c │ ├── mewrite.c │ ├── mexample.c │ ├── mgetpath.c │ ├── mhelp.c │ ├── micmp.c │ ├── micmp2.c │ ├── minit.c │ ├── mip.c │ ├── mip1.c │ ├── mip2.c │ ├── mkarp.c │ ├── mmargparse.c │ ├── mmep.c │ ├── mmip.c │ ├── mmshell │ ├── mmshell.c │ ├── mon1.c │ ├── monitor │ ├── monitor.h │ ├── mparse.c │ ├── mrarp.c │ ├── mrarp2.c │ ├── mshell │ ├── mshell.c │ ├── mshell.h │ ├── mshellc.h │ ├── mtabinit.c │ ├── mtcp.c │ ├── mtcp2.c │ ├── mudp.c │ ├── mudp2.c │ ├── netinit.c │ ├── netnum.c │ ├── netutil.s │ ├── nip.c │ ├── phelp.c │ ├── recvtim.c │ ├── route.c │ ├── setnok.c │ ├── shell │ ├── shell.c │ ├── sndrarp.c │ └── tcp.h ├── host └── cmd │ ├── Makeall │ ├── Makefile │ ├── README │ ├── download │ ├── Makefile │ ├── README │ ├── cmd │ │ ├── Makefile │ │ ├── download.c │ │ ├── lusers.c │ │ ├── odt.c │ │ ├── odtunlock.c │ │ └── upload.c │ ├── h │ │ ├── baud.h │ │ ├── dlpack.h │ │ ├── download.h │ │ ├── freedev.h │ │ ├── getdev.h │ │ ├── ulock.h │ │ └── upload.h │ ├── lib │ │ ├── Makefile │ │ ├── freedev.c │ │ ├── getdb.c │ │ ├── getdev.c │ │ ├── ulock.c │ │ └── usleep.c │ ├── lsi11 │ │ ├── Makefile │ │ ├── README │ │ ├── eload │ │ │ ├── Makefile │ │ │ ├── h │ │ │ │ ├── arp.h │ │ │ │ ├── baud.h │ │ │ │ ├── deqna.h │ │ │ │ ├── dlpack.h │ │ │ │ ├── download.h │ │ │ │ ├── eload.h │ │ │ │ ├── ethdown.h │ │ │ │ ├── ethdown.h.RAW │ │ │ │ ├── ether.h │ │ │ │ ├── freedev.h │ │ │ │ ├── getdev.h │ │ │ │ ├── ip.h │ │ │ │ ├── network.h │ │ │ │ ├── slu.h │ │ │ │ ├── udp.h │ │ │ │ ├── ulock.h │ │ │ │ └── upload.h │ │ │ ├── lib │ │ │ │ ├── Makefile │ │ │ │ ├── aldiv.s │ │ │ │ ├── almul.s │ │ │ │ ├── alrem.s │ │ │ │ ├── csv.s │ │ │ │ ├── ldiv.s │ │ │ │ ├── lmul.s │ │ │ │ ├── lrem.s │ │ │ │ └── printf.c │ │ │ └── src │ │ │ │ ├── .entry │ │ │ │ ├── .version │ │ │ │ ├── Makefile │ │ │ │ ├── Mknlist │ │ │ │ ├── av.sh │ │ │ │ ├── blkcopy.c │ │ │ │ ├── blkequ.c │ │ │ │ ├── cksum.s │ │ │ │ ├── edcmset.c │ │ │ │ ├── eload.c │ │ │ │ ├── en.sh │ │ │ │ ├── eread.c │ │ │ │ ├── erstart.c │ │ │ │ ├── estrt.c │ │ │ │ ├── ewrite.c │ │ │ │ ├── ewstart.c │ │ │ │ ├── getipaddr.c │ │ │ │ ├── netutil.s │ │ │ │ ├── startup.s │ │ │ │ └── udpipwr.c │ │ ├── h │ │ │ ├── a.out.h │ │ │ ├── baud.h │ │ │ ├── core11.h │ │ │ ├── dlpack.h │ │ │ ├── download.h │ │ │ ├── ethdown.h │ │ │ ├── ethdown.h.RAW │ │ │ ├── freedev.h │ │ │ ├── getdev.h │ │ │ ├── lsidl.h │ │ │ ├── lsidl.h.RAW │ │ │ ├── lsiul.h │ │ │ ├── lsiul.h.RAW │ │ │ ├── ulock.h │ │ │ └── upload.h │ │ └── src │ │ │ ├── Makefile │ │ │ ├── edl.c │ │ │ ├── eul.c │ │ │ ├── sdl.boot.s │ │ │ ├── sdl.c │ │ │ ├── sul.boot.s │ │ │ └── sul.c │ ├── machines.example │ └── vax │ │ ├── Makefile │ │ ├── README │ │ ├── eload │ │ ├── Makefile │ │ ├── h │ │ │ ├── arp.h │ │ │ ├── baud.h │ │ │ ├── deqna.h │ │ │ ├── dlpack.h │ │ │ ├── download.h │ │ │ ├── eload.h │ │ │ ├── ethdown.h │ │ │ ├── ether.h │ │ │ ├── freedev.h │ │ │ ├── getdev.h │ │ │ ├── ip.h │ │ │ ├── network.h │ │ │ ├── procreg.h │ │ │ ├── qbus.h │ │ │ ├── udp.h │ │ │ ├── ulock.h │ │ │ ├── upload.h │ │ │ └── vaxdl.h │ │ └── src │ │ │ ├── Makefile │ │ │ ├── autostart.s │ │ │ ├── av.sh │ │ │ ├── blkcopy.c │ │ │ ├── blkequ.c │ │ │ ├── cksum.s │ │ │ ├── edcmset.c │ │ │ ├── eload.c │ │ │ ├── eread.c │ │ │ ├── erstart.c │ │ │ ├── estrt.c │ │ │ ├── ewrite.c │ │ │ ├── ewstart.c │ │ │ ├── getipaddr.c │ │ │ ├── netutil.s │ │ │ ├── qmapinit.c │ │ │ ├── sizmem.s │ │ │ ├── startup.s │ │ │ └── udpipwr.c │ │ ├── h │ │ ├── baud.h │ │ ├── coreX.h │ │ ├── dlpack.h │ │ ├── download.h │ │ ├── ethdown.h │ │ ├── ethdown.h.RAW │ │ ├── freedev.h │ │ ├── getdev.h │ │ ├── procreg.h │ │ ├── ulock.h │ │ ├── upload.h │ │ ├── vaxdl.h │ │ ├── vaxdl.h.RAW │ │ ├── vaxul.h │ │ ├── vdownload.h │ │ └── vdownload.h.RAW │ │ └── src │ │ ├── Makefile │ │ ├── edl.c │ │ ├── eul.c │ │ ├── sdl.boot.s │ │ └── sdl.c │ └── fs │ ├── Close.c │ ├── Makefile │ ├── Open.c │ ├── Seek.c │ ├── Uncache.c │ ├── fgetargs.c │ ├── fgetreq.c │ ├── finit.c │ ├── fmode.c │ ├── fns.h │ ├── fs.c │ ├── fs.h │ ├── fsaccess.c │ ├── fsclose.c │ ├── fsd.c │ ├── fsmkdir.c │ ├── fsndrply.c │ ├── fsopen.c │ ├── fsread.c │ ├── fsrename.c │ ├── fsrmdir.c │ ├── fstrans.c │ ├── fsunlink.c │ ├── fswrite.c │ ├── openfile.c │ └── rmfile.c ├── include ├── a.out.h ├── arp.h ├── baud.h ├── bufpool.h ├── cmd.h ├── ctype.h ├── date.h ├── deqna.h ├── dgram.h ├── dir.h ├── disk.h ├── domain.h ├── dtc.h ├── ether.h ├── file.h ├── fns.h ├── fserver.h ├── hosts.h ├── iblock.h ├── icmp.h ├── io.h ├── ip.h ├── kernel.h ├── lfile.h ├── mark.h ├── math.h ├── mc68k │ ├── a.out.h │ ├── machine.h │ ├── pagsiz.h │ └── u.h ├── mem.h ├── name.h ├── net.h ├── network.h ├── ports.h ├── proc.h ├── q.h ├── rfile.h ├── rwho.h ├── sem.h ├── shell.h ├── sleep.h ├── slu.h ├── stdarg.h ├── stddef.h ├── string.h ├── tty.h ├── u.h ├── udp.h ├── unix-rwho.h └── xebec.h ├── lib ├── machines ├── standalone │ └── .gitignore ├── storage │ ├── README │ └── output │ │ ├── date │ │ ├── devs │ │ ├── dg │ │ ├── echo │ │ ├── help │ │ ├── mem │ │ ├── mount │ │ ├── netstat │ │ ├── ps │ │ ├── rf │ │ ├── routes │ │ ├── ruptime │ │ └── who ├── tmac.ad └── tmac.an ├── libxc ├── Makefile ├── abs.c ├── atoi.c ├── atol.c ├── ctype_.c ├── doprnt.c ├── doscan.c ├── fgets.c ├── fprintf.c ├── fputs.c ├── memchr.c ├── memcmp.c ├── memcpy.c ├── memmove.c ├── memset.c ├── printf.c ├── puts.c ├── qsort.c ├── rand.c ├── scanf.c ├── sprintf.c ├── strcat.c ├── strchr.c ├── strcmp.c ├── strcpy.c ├── strlcat.c ├── strlcpy.c ├── strlen.c ├── strncat.c ├── strncmp.c ├── strncpy.c ├── strrchr.c └── swab.c ├── man ├── Makefile ├── man0 │ ├── Makefile │ ├── Makefile.RAW │ ├── Notes.doc │ └── Notes.ms ├── man1 │ ├── Intro1.1 │ ├── Intro1.doc │ ├── Makefile │ ├── Makefile.RAW │ ├── as11.1 │ ├── as11.doc │ ├── cc11.1 │ ├── cc11.doc │ ├── cvt.1 │ ├── cvt.doc │ ├── dd58.1 │ ├── dd58.doc │ ├── download.1 │ ├── download.doc │ ├── fs.1 │ ├── fs.doc │ ├── ld11.1 │ ├── ld11.doc │ ├── lorder11.1 │ ├── lorder11.doc │ ├── lusers.1 │ ├── lusers.doc │ ├── nm11.1 │ ├── nm11.doc │ ├── odt.1 │ ├── odt.doc │ ├── odtunlock.1 │ ├── odtunlock.doc │ ├── pm.1 │ ├── pm.doc │ ├── ranlib11.1 │ ├── ranlib11.doc │ ├── size11.1 │ ├── size11.doc │ ├── strip11.1 │ ├── strip11.doc │ ├── subEIS.1 │ ├── subEIS.doc │ ├── tu58.1 │ ├── tu58.doc │ ├── upload.1 │ └── upload.doc ├── man2 │ ├── Intro2.2 │ ├── Intro2.doc │ ├── Makefile │ ├── Makefile.RAW │ ├── access.2 │ ├── access.doc │ ├── chprio.2 │ ├── chprio.doc │ ├── close.2 │ ├── close.doc │ ├── control.2 │ ├── control.doc │ ├── create.2 │ ├── create.doc │ ├── freebuf.2 │ ├── freebuf.doc │ ├── freemem.2 │ ├── freemem.doc │ ├── freestk.2 │ ├── freestk.doc │ ├── getaddr.2 │ ├── getaddr.doc │ ├── getbuf.2 │ ├── getbuf.doc │ ├── getc.2 │ ├── getc.doc │ ├── getmem.2 │ ├── getmem.doc │ ├── getname.2 │ ├── getname.doc │ ├── getnet.2 │ ├── getnet.doc │ ├── getpid.2 │ ├── getpid.doc │ ├── getprio.2 │ ├── getprio.doc │ ├── gettime.2 │ ├── gettime.doc │ ├── getutim.2 │ ├── getutim.doc │ ├── ip2name.2 │ ├── ip2name.doc │ ├── kill.2 │ ├── kill.doc │ ├── mark.2 │ ├── mark.doc │ ├── mkpool.2 │ ├── mkpool.doc │ ├── mount.2 │ ├── mount.doc │ ├── nammap.2 │ ├── nammap.doc │ ├── namrepl.2 │ ├── namrepl.doc │ ├── open.2 │ ├── open.doc │ ├── panic.2 │ ├── panic.doc │ ├── pcount.2 │ ├── pcount.doc │ ├── pcreate.2 │ ├── pcreate.doc │ ├── pdelete.2 │ ├── pdelete.doc │ ├── pinit.2 │ ├── pinit.doc │ ├── preceive.2 │ ├── preceive.doc │ ├── preset.2 │ ├── preset.doc │ ├── psend.2 │ ├── psend.doc │ ├── putc.2 │ ├── putc.doc │ ├── read.2 │ ├── read.doc │ ├── receive.2 │ ├── receive.doc │ ├── recvclr.2 │ ├── recvclr.doc │ ├── recvtim.2 │ ├── recvtim.doc │ ├── remove.2 │ ├── remove.doc │ ├── resume.2 │ ├── resume.doc │ ├── scount.2 │ ├── scount.doc │ ├── screate.2 │ ├── screate.doc │ ├── sdelete.2 │ ├── sdelete.doc │ ├── seek.2 │ ├── seek.doc │ ├── send.2 │ ├── send.doc │ ├── sendf.2 │ ├── sendf.doc │ ├── setdev.2 │ ├── setdev.doc │ ├── setnok.2 │ ├── setnok.doc │ ├── signal.2 │ ├── signal.doc │ ├── sleep.2 │ ├── sleep.doc │ ├── sreset.2 │ ├── sreset.doc │ ├── suspend.2 │ ├── suspend.doc │ ├── unmount.2 │ ├── unmount.doc │ ├── unsleep.2 │ ├── unsleep.doc │ ├── wait.2 │ ├── wait.doc │ ├── write.2 │ └── write.doc ├── man3 │ ├── Intro3.3 │ ├── Intro3.doc │ ├── Makefile │ ├── Makefile.RAW │ ├── TEMPL │ ├── blkcopy.3 │ ├── blkcopy.doc │ ├── blkequ.3 │ ├── blkequ.doc │ ├── ckmode.3 │ ├── ckmode.doc │ ├── ctype.3 │ ├── ctype.doc │ ├── disable.3 │ ├── disable.doc │ ├── dot2ip.3 │ ├── dot2ip.doc │ ├── eis.3 │ ├── eis.doc │ ├── fgetc.3 │ ├── fgetc.doc │ ├── fputc.3 │ ├── fputc.doc │ ├── gets.3 │ ├── gets.doc │ ├── halt.3 │ ├── halt.doc │ ├── netnum.3 │ ├── netnum.doc │ ├── netutil.3 │ ├── netutil.doc │ ├── printf.3 │ ├── printf.doc │ ├── puts.3 │ ├── puts.doc │ ├── qsort.3 │ ├── qsort.doc │ ├── queue.3 │ ├── queue.doc │ ├── rand.3 │ ├── rand.doc │ ├── scanf.3 │ ├── scanf.doc │ ├── string.3 │ ├── string.doc │ ├── swab.3 │ └── swab.doc └── man4 │ ├── Intro4.4 │ ├── Intro4.doc │ ├── Makefile │ ├── Makefile.RAW │ ├── TEMPL │ ├── ether.4 │ ├── ether.doc │ ├── internet.4 │ ├── internet.doc │ ├── namespace.4 │ ├── namespace.doc │ ├── rfilsys.4 │ ├── rfilsys.doc │ ├── tty.4 │ └── tty.doc └── xinu ├── Makefile ├── Mkdeps.sh ├── README ├── access.c ├── adump.c ├── arp_in.c ├── arpfind.c ├── arpinit.c ├── bpdump.c ├── bsvc.setup ├── chprio.c ├── ckmode.c ├── cksum.c ├── clkinit.c ├── clkint.s ├── close.c ├── control.c ├── create.c ├── ctxsw.s ├── devdump.c ├── dfalloc.c ├── dfdsearch.c ├── dgalloc.c ├── dgclose.c ├── dgcntl.c ├── dgdump.c ├── dginit.c ├── dgmcntl.c ├── dgmopen.c ├── dgparse.c ├── dgread.c ├── dgwrite.c ├── dot2ip.c ├── dscntl.c ├── dsinit.c ├── dsinter.c ├── dskbcpy.c ├── dskenq.c ├── dskqopt.c ├── dskstart.c ├── dsksync.c ├── dsopen.c ├── dsread.c ├── dsseek.c ├── dswrite.c ├── dudir.c ├── dumkfs.c ├── etherinit.c ├── etherinter.c ├── etherread.c ├── etherrstart.c ├── etherstart.c ├── etherwrite.c ├── etherwstart.c ├── freebuf.c ├── freemem.c ├── getaddr.c ├── getbuf.c ├── getc.c ├── getitem.c ├── getmem.c ├── getname.c ├── getnet.c ├── getpath.c ├── getpid.c ├── getprio.c ├── getstk.c ├── gettime.c ├── getutime.c ├── ibclear.c ├── ibfree.c ├── ibget.c ├── iblfree.c ├── ibnew.c ├── ibput.c ├── icmp_in.c ├── init.c ├── initialize.c ├── insert.c ├── insertd.c ├── intr.s ├── ioerr.c ├── ioinit.c ├── ioint.s ├── ionull.c ├── ip2name.c ├── ip_in.c ├── ipsend.c ├── kill.c ├── kprintf.c ├── lfclose.c ├── lfgetc.c ├── lfinit.c ├── lfputc.c ├── lfread.c ├── lfsdfree.c ├── lfseek.c ├── lfsetup.c ├── lfsflush.c ├── lfsnewd.c ├── lfwrite.c ├── mark.c ├── mdump.c ├── mkarp.c ├── mkpool.c ├── mount.c ├── nameinit.c ├── namemap.c ├── nameopen.c ├── namereplace.c ├── ndump.c ├── netdump.c ├── netin.c ├── netinit.c ├── netnum.c ├── netout.c ├── newqueue.c ├── nqalloc.c ├── open.c ├── panic.c ├── pause.s ├── pcount.c ├── pcreate.c ├── pdelete.c ├── pinit.c ├── poolinit.c ├── prdump.c ├── preceive.c ├── preset.c ├── psend.c ├── ptclear.c ├── putc.c ├── qdump.c ├── queue.c ├── rarp_in.c ├── read.c ├── ready.c ├── receive.c ├── recvclr.c ├── recvtime.c ├── remove.c ├── rename.c ├── resched.c ├── resume.c ├── rfalloc.c ├── rfclose.c ├── rfcntl.c ├── rfdump.c ├── rfgetc.c ├── rfinit.c ├── rfio.c ├── rfmkpac.c ├── rfopen.c ├── rfputc.c ├── rfread.c ├── rfseek.c ├── rfsend.c ├── rfwrite.c ├── route.c ├── rwho.c ├── rwhod.c ├── rwhoind.c ├── scount.c ├── screate.c ├── sdelete.c ├── seek.c ├── send.c ├── sendf.c ├── setclkr.s ├── setdev.c ├── setnok.c ├── shell ├── README ├── addarg.c ├── ascdate.c ├── cmd.h ├── lexan.c ├── login.c ├── shell.c ├── shell.h ├── x_bpool.c ├── x_cat.c ├── x_close.c ├── x_cp.c ├── x_create.c ├── x_date.c ├── x_devs.c ├── x_dg.c ├── x_echo.c ├── x_exit.c ├── x_help.c ├── x_kill.c ├── x_mem.c ├── x_mount.c ├── x_mv.c ├── x_net.c ├── x_ps.c ├── x_reboot.c ├── x_rf.c ├── x_rls.c ├── x_rm.c ├── x_routes.c ├── x_sleep.c ├── x_snap.c ├── x_unmou.c ├── x_uptime.c └── x_who.c ├── signal.c ├── signaln.c ├── sizmem.s ├── sleep.c ├── sleep10.c ├── sndrarp.c ├── sreset.c ├── ssclock.c ├── startup.s ├── suspend.c ├── tdump.c ├── test.c ├── ttycntl.c ├── ttygetc.c ├── ttyiin.c ├── ttyinit.c ├── ttyint.c ├── ttyoin.c ├── ttyopen.c ├── ttyputc.c ├── ttyread.c ├── ttywrite.c ├── udpecho.c ├── udpnxtp.c ├── udpsend.c ├── unmount.c ├── unsleep.c ├── userret.c ├── wait.c ├── wakeup.c ├── write.c ├── xdone.c └── xinu.conf /bin/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dancrossnyc/xinu68k/5e55d31122c01a394f2234dcd3be53b7030d34d3/bin/.gitignore -------------------------------------------------------------------------------- /config/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Make the Xinu configuration program 3 | # 4 | YFLAGS= -d 5 | CFLAGS= -O -Wall -ansi -pedantic -std=c11 6 | OBJ= parser.o 7 | SRCS= parser.y lexer.l 8 | PROG= config 9 | LIBS= -ly -ll 10 | RM= rm -f 11 | 12 | all: ${PROG} 13 | 14 | ${PROG}: ${OBJ} 15 | ${CC} -o ${PROG} ${OBJ} ${LIBS} 16 | ${RM} lexer.c 17 | 18 | install: ${PROG} 19 | cp ${PROG} ../xinu/config 20 | 21 | clean: 22 | ${RM} ${PROG} ${OBJ} parser.c lexer.c *.o y.tab.h 23 | 24 | parser.c: lexer.c 25 | -------------------------------------------------------------------------------- /contrib/README: -------------------------------------------------------------------------------- 1 | README 2 | ------ 3 | 4 | This is directory {Xinu-directory}/contrib. it contains software 5 | contributed by students and users at other sites. All the software 6 | is in the public domain (and probably unreliable). If you would 7 | like to have your software added to future tapes, contact Doug Comer 8 | at Purdue. 9 | -------------------------------------------------------------------------------- /contrib/distodt/h/bedata.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * bedata.h - Bed machines data base header file 4 | * 5 | * Author: Jim Griffioen 6 | * Dept. of Computer Sciences 7 | * Purdue University 8 | * Date: Thu May 26 23:01:36 1988 9 | * 10 | * Copyright (c) 1988 Jim Griffioen 11 | */ 12 | 13 | struct odtdata { 14 | char *sline, 15 | *bename, 16 | *dload, 17 | *betype, 18 | *dloadpath, 19 | *baud, 20 | *class, 21 | *odttype; 22 | }; 23 | 24 | extern struct odtdata **table, 25 | *entry; 26 | 27 | extern int size, cnt; 28 | 29 | extern struct odtdata **readodtdata(), *makeodt(); 30 | extern struct odtdata *getbeconfig(); 31 | 32 | -------------------------------------------------------------------------------- /contrib/distodt/h/bmutils.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * bmutils.h - Definitions for bm structure utilities 4 | * 5 | * Author: Shawn Oostermann/Jim Griffioen 6 | * Dept. of Computer Sciences 7 | * Purdue University 8 | * Date: Fri Jun 10 16:04:11 1988char 9 | * 10 | * Copyright (c) 1988char *CmdToSb (); Shawn Oostermann/Jim Griffioen 11 | */ 12 | 13 | char *UidToSb (); 14 | char *ServToSb (); 15 | char *DescToSb (); 16 | char *OmToSb (); 17 | char *BmToSb(); 18 | char *SbToBm(); 19 | 20 | #define BITMASK(n) (1<<(n)) 21 | 22 | -------------------------------------------------------------------------------- /contrib/distodt/h/netutils.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * netutils.h - Header file for network utilitie routines 4 | * 5 | * Author: Tim Korb/Shawn Oostermann/Jim Griffioen 6 | * Dept. of Computer Sciences 7 | * Purdue University 8 | * Date: Fri Jun 10 16:06:18 1988 9 | * 10 | * Copyright (c) 1988 Tim Korb/Shawn Oostermann/Jim Griffioen 11 | */ 12 | 13 | # define lsa (sizeof (struct sockaddr_in)) 14 | 15 | char *IaToSb (); 16 | char *GetHostName (); 17 | struct sockaddr_in *FdToRemoteSa (); 18 | struct sockaddr_in *FdToLocalSa (); 19 | -------------------------------------------------------------------------------- /contrib/distodt/h/tokens.h: -------------------------------------------------------------------------------- 1 | 2 | typedef union { 3 | char *sb; 4 | } YYSTYPE; 5 | extern YYSTYPE yylval; 6 | # define STRING 257 7 | # define NEWLINE 258 8 | -------------------------------------------------------------------------------- /contrib/distodt/h/utils.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * utils.h - Header file for bed utilities 4 | * 5 | * Author: Shawn Oostermann 6 | * Dept. of Computer Sciences 7 | * Purdue University 8 | * Date: Fri Jun 10 16:07:47 1988 9 | * 10 | * Copyright (c) 1988 Shawn Oostermann 11 | */ 12 | 13 | # define FALSE 0 14 | # define TRUE 1 15 | 16 | -------------------------------------------------------------------------------- /contrib/distodt/man/bedkill.1: -------------------------------------------------------------------------------- 1 | .TH BEDKILL 1 2 | .SH NAME 3 | bedkill \- kill all BED processes running on frontends 4 | .SH SYNOPSIS 5 | .B bedkill 6 | .SH DESCRIPTION 7 | .I Bedkill 8 | broadcasts a \f2kill\f1 message to all BED processes. It is useful for 9 | quickly stopping all BED processes. This is very helpful when debugging 10 | the distributed odt/download/upload software. 11 | .SH "SEE ALSO" 12 | bed(1), bedreboot(1) 13 | 14 | -------------------------------------------------------------------------------- /contrib/distodt/man/bedreboot.1: -------------------------------------------------------------------------------- 1 | .TH BEDREBOOT 1 2 | .SH NAME 3 | bedreboot \- reboot the BED on the specified frontend 4 | .SH SYNOPSIS 5 | .B bedreboot 6 | [ frontend\-machine ] ... 7 | .SH DESCRIPTION 8 | .I Bedreboot 9 | restarts the BED process on all frontends specified on the command line. This 10 | is useful if it appears that a particular BED is functioning incorrectly and 11 | needs to be restarted. 12 | .SH "SEE ALSO" 13 | bed(1), bedkill(1) 14 | 15 | -------------------------------------------------------------------------------- /contrib/distodt/man/fusers.1: -------------------------------------------------------------------------------- 1 | .TH FUSERS 1 2 | .SH NAME 3 | fusers \- list number of users and load averages on frontend machines 4 | .SH SYNOPSIS 5 | .B fusers 6 | .SH DESCRIPTION 7 | .I Fusers 8 | prints information about each frontend machine that is running a BED server. 9 | Each line lists the frontend machine name, the number of users 10 | logged in to the frontend, the load average, and the number of backends it 11 | serves. The load average printed lists the 1, 5, and 15 minute load 12 | averages on the frontend. 13 | .SH "SEE ALSO" 14 | busers(1), status(1) 15 | 16 | 17 | -------------------------------------------------------------------------------- /contrib/distodt/src/lib.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dancrossnyc/xinu68k/5e55d31122c01a394f2234dcd3be53b7030d34d3/contrib/distodt/src/lib.a -------------------------------------------------------------------------------- /contrib/distodt/src/scanner.l: -------------------------------------------------------------------------------- 1 | %{ 2 | /* 3 | * Scanner for machines database. 4 | * 5 | * Steve Chapin, 13 Apr 1988 6 | */ 7 | #include 8 | 9 | #include "../h/tokens.h" 10 | 11 | char *newsb(); 12 | %} 13 | C [^\n\t ] 14 | N [\n] 15 | W [\t ] 16 | %% 17 | {W} /* eat up white space */ ; 18 | "#"[^\n]*{N} /* eat up comment lines */ ; 19 | {N} { 20 | return(NEWLINE); 21 | } 22 | {C}+ { 23 | yylval.sb = newsb(yytext); 24 | return(STRING); 25 | } 26 | %% 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /contrib/distodt/src/y.tab.h: -------------------------------------------------------------------------------- 1 | 2 | typedef union { 3 | char *sb; 4 | } YYSTYPE; 5 | extern YYSTYPE yylval; 6 | # define STRING 257 7 | # define NEWLINE 258 8 | -------------------------------------------------------------------------------- /contrib/ether.monitor/README: -------------------------------------------------------------------------------- 1 | README 2 | ------ 3 | 4 | This software was built by: 5 | 6 | Chi-jiu Lin 7 | Guangzhou Institute of Electronic Technology 8 | Academic Sinica 9 | P.O. Box 176, Guangzhou 10 | People's Republic of China 11 | 12 | It allows one to monitor packets on an Ethernet, filtering 13 | out packets by protocol type, destination address, or source 14 | address. 15 | -------------------------------------------------------------------------------- /contrib/ether.monitor/etc/mhelp.c: -------------------------------------------------------------------------------- 1 | /* mhelp.c - mhelp */ 2 | 3 | #include 4 | #include 5 | #include "../h/mshell.h" 6 | #include "../h/mshellc.h" 7 | 8 | extern Bool found; 9 | 10 | /*------------------------------------------------------------------------ 11 | * mhelp - 'help' command for pseudo shell 12 | *------------------------------------------------------------------------ 13 | */ 14 | int mhelp(stdout) 15 | int stdout; 16 | { 17 | int i, j, inc; 18 | 19 | if ( (inc=(Msh.mncmds+3)/4) <= 0) 20 | inc = 1; 21 | fprintf(stdout, "Commands are:\n"); 22 | for(i=0 ; i=nmarks || marks[L[0]]!=L) 15 | #define marked(L) !unmarked(L) 16 | #endif 17 | -------------------------------------------------------------------------------- /contrib/ether.monitor/h/micmp.h: -------------------------------------------------------------------------------- 1 | #define ICMPS 0, "icrpech", "ICRPECH", \ 2 | 3, "icdestu", "ICDESTU", \ 3 | 4, "icsrcqn", "ICSRCQN", \ 4 | 5, "icredir", "ICREDIR", \ 5 | 8, "icrqech", "ICRQECH", \ 6 | 11, "ictimex", "ICTIMEX", \ 7 | 12, "icparmp", "ICPARMP", \ 8 | 13, "ictimst", "ICTIMST", \ 9 | 14, "ictimrp", "ICTIMRP", \ 10 | 15, "icrqinf", "ICRQINF", \ 11 | 16, "icrpinf", "ICRPINF", \ 12 | -1, 0, "UNKNOWN" 13 | -------------------------------------------------------------------------------- /contrib/ether.monitor/h/mshellc.h: -------------------------------------------------------------------------------- 1 | /* mshellc.h */ 2 | 3 | /* This file declares the set of commands for the pseudo shell */ 4 | 5 | struct mcmdent { /* entry in command table */ 6 | char *cmdnam; /* name of command */ 7 | int (*cproc)(); /* procedure that implements cmd*/ 8 | }; 9 | 10 | extern mhelp(), mep(), mip(), marp(), mrarp(), mudp(), mtcp(), micmp(); 11 | 12 | #define CMDS "help", mhelp, \ 13 | "udp", mudp, \ 14 | "tcp", mtcp, \ 15 | "icmp", micmp, \ 16 | "ip", mip, \ 17 | "arp", marp, \ 18 | "rarp", mrarp, \ 19 | "ep", mep 20 | extern struct mcmdent mcmds[]; 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /contrib/ether.monitor/h/network.h: -------------------------------------------------------------------------------- 1 | 2 | /* network.h */ 3 | 4 | /* Declarations data conversion and checksum routines */ 5 | 6 | extern short hs2net(); /* host to network short */ 7 | extern short net2hs(); /* network to host short */ 8 | extern long hl2net(); /* host-to-network long */ 9 | extern long net2hl(); /* network to host long */ 10 | extern long hl2vax(); /* pdp11-to-vax long */ 11 | extern long vax2hl(); /* vax-to-pdp11 long */ 12 | extern short cksum(); /* 1s comp of 16-bit 2s comp sum*/ 13 | -------------------------------------------------------------------------------- /contrib/ether.monitor/h/sleep.h: -------------------------------------------------------------------------------- 1 | /* sleep.h */ 2 | 3 | #define CVECTOR 0100 /* location of clock interrupt vector */ 4 | 5 | extern int clkruns; /* 1 iff clock exists; 0 otherwise */ 6 | /* Set at system startup. */ 7 | extern int clockq; /* q index of sleeping process list */ 8 | extern int count6; /* used to ignore 5 of 6 interrupts */ 9 | extern int count10; /* used to ignore 9 of 10 ticks */ 10 | extern long clktime; /* current time in secs since 1/1/70 */ 11 | extern int clmutex; /* mutual exclusion sem. for clock */ 12 | extern int *sltop; /* address of first key on clockq */ 13 | extern int slnempty; /* 1 iff clockq is nonempty */ 14 | 15 | extern int defclk; /* >0 iff clock interrupts are deferred */ 16 | extern int clkdiff; /* number of clock ticks deferred */ 17 | extern int clkint(); /* clock interrupt handler */ 18 | -------------------------------------------------------------------------------- /contrib/ether.monitor/h/slu.h: -------------------------------------------------------------------------------- 1 | /* slu.h */ 2 | 3 | /* standard serial line unit device constants */ 4 | 5 | #define SLUENABLE 0100 /* device interrupt enable bit */ 6 | #define SLUREADY 0200 /* device ready bit */ 7 | #define SLUDISABLE 0000 /* device interrupt disable mask*/ 8 | #define SLUTBREAK 0001 /* transmitter break-mode bit */ 9 | #define SLUERMASK 0170000 /* mask for error flags on input*/ 10 | #define SLUCHMASK 0377 /* mask for input character */ 11 | 12 | /* SLU device register layout and correspondence to vendor's names */ 13 | 14 | struct csr { 15 | int crstat; /* receiver control and status (RCSR) */ 16 | int crbuf; /* receiver data buffer (RBUF) */ 17 | int ctstat; /* transmitter control & status (XCSR) */ 18 | int ctbuf; /* transmitter data buffer (XBUF) */ 19 | }; 20 | -------------------------------------------------------------------------------- /contrib/ether.monitor/sys/blkcopy.c: -------------------------------------------------------------------------------- 1 | /* blkcopy.c - blkcopy */ 2 | 3 | #include 4 | 5 | /*------------------------------------------------------------------------ 6 | * blkcopy - copy a block of memory form one location to another 7 | *------------------------------------------------------------------------ 8 | */ 9 | blkcopy(to, from, nbytes) 10 | register char *to; 11 | register char *from; 12 | register int nbytes; 13 | { 14 | while (--nbytes >= 0) 15 | *to++ = *from++; 16 | return(OK); 17 | } 18 | -------------------------------------------------------------------------------- /contrib/ether.monitor/sys/blkequ.c: -------------------------------------------------------------------------------- 1 | /* blkequ.c - blkequ */ 2 | 3 | #include 4 | 5 | /*------------------------------------------------------------------------ 6 | * blkequ - return TRUE iff one block of memory is equal to another 7 | *------------------------------------------------------------------------ 8 | */ 9 | blkequ(first, second, nbytes) 10 | register char *first; 11 | register char *second; 12 | register int nbytes; 13 | { 14 | while (--nbytes >= 0) 15 | if (*first++ != *second++) 16 | return(FALSE); 17 | return(TRUE); 18 | } 19 | -------------------------------------------------------------------------------- /contrib/ether.monitor/sys/dtoIP.c: -------------------------------------------------------------------------------- 1 | /* dtoIP.c - dtoIP */ 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | /*------------------------------------------------------------------------ 8 | * dtoIP - convert network address in "decimal dot" notation to IP addr 9 | *------------------------------------------------------------------------ 10 | */ 11 | dtoIP(ip, nad1, nad2, nad3, nad4) 12 | char *ip; 13 | int nad1, nad2, nad3, nad4; 14 | { 15 | *ip++ = LOWBYTE & nad1; 16 | *ip++ = LOWBYTE & nad2; 17 | *ip++ = LOWBYTE & nad3; 18 | *ip++ = LOWBYTE & nad4; 19 | } 20 | -------------------------------------------------------------------------------- /contrib/ether.monitor/sys/example: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dancrossnyc/xinu68k/5e55d31122c01a394f2234dcd3be53b7030d34d3/contrib/ether.monitor/sys/example -------------------------------------------------------------------------------- /contrib/ether.monitor/sys/example.c: -------------------------------------------------------------------------------- 1 | #include "../h/conf.h" 2 | #include "../h/kernel.h" 3 | #include 4 | #include "../h/mshellc.h" 5 | 6 | 7 | 8 | int micmp(); 9 | struct mcmdent mcmds[] = { 10 | {"icmp",micmp}, 11 | {0,0} 12 | }; 13 | main() 14 | { 15 | int pid; 16 | 17 | if ((pid=newpid())==SYSERR){ 18 | printf("Slot is not free\n"); 19 | } 20 | printf("hello.\n"); 21 | micmp(); 22 | } 23 | newpid() 24 | { 25 | int pid; 26 | int i; 27 | 28 | for(i=0;i 4 | #include "../h/mshellc.h" 5 | 6 | 7 | 8 | int micmp(); 9 | struct mcmdent mcmds[] = { 10 | {"icmp",micmp}, 11 | {0,0} 12 | }; 13 | main() 14 | { 15 | int pid; 16 | 17 | if ((pid=newpid())==SYSERR){ 18 | printf("Slot is not free\n"); 19 | } 20 | printf("hello.\n"); 21 | micmp(); 22 | } 23 | newpid() 24 | { 25 | int pid; 26 | int i; 27 | 28 | for(i=0;i 4 | #include 5 | #include 6 | 7 | /*------------------------------------------------------------------------ 8 | * getaddr - obtain this system's complete address (IP address) 9 | *------------------------------------------------------------------------ 10 | */ 11 | SYSCALL getaddr(address) 12 | IPaddr address; 13 | { 14 | wait (Arp.rarpsem); 15 | if (!Net.mavalid) 16 | sndrarp(); 17 | signal(Arp.rarpsem); 18 | 19 | if (!Net.mavalid) 20 | return(SYSERR); 21 | blkcopy(address, Net.myaddr, IPLEN); 22 | return(OK); 23 | } 24 | -------------------------------------------------------------------------------- /contrib/ether.monitor/sys/getbuf.c: -------------------------------------------------------------------------------- 1 | /* getbuf.c - getbuf */ 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | /*------------------------------------------------------------------------ 9 | * getbuf -- get a buffer from a preestablished buffer pool 10 | *------------------------------------------------------------------------ 11 | */ 12 | SYSCALL *getbuf(poolid) 13 | int poolid; 14 | { 15 | char ps; 16 | int *buf; 17 | 18 | #ifdef MEMMARK 19 | if ( unmarked(bpmark) ) 20 | return((int *)SYSERR); 21 | #endif 22 | if (poolid<0 || poolid>=nbpools) 23 | return((int *)SYSERR); 24 | wait(bptab[poolid].bpsem); 25 | disable(ps); 26 | buf = bptab[poolid].bpnext; 27 | bptab[poolid].bpnext = *buf; 28 | restore(ps); 29 | *buf++ = poolid; 30 | return(buf); 31 | } 32 | -------------------------------------------------------------------------------- /contrib/ether.monitor/sys/getnet.c: -------------------------------------------------------------------------------- 1 | /* getnet.c - getnet */ 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | /*------------------------------------------------------------------------ 8 | * getnet - obtain the network portion of this system's IP address 9 | *------------------------------------------------------------------------ 10 | */ 11 | SYSCALL getnet(address) 12 | IPaddr address; 13 | { 14 | if (!Net.mavalid && getaddr(address) == SYSERR) 15 | return(SYSERR); 16 | blkcopy(address, Net.mynet, IPLEN); 17 | return(OK); 18 | } 19 | -------------------------------------------------------------------------------- /contrib/ether.monitor/sys/mhelp.c: -------------------------------------------------------------------------------- 1 | /* mhelp.c - mhelp */ 2 | 3 | #include 4 | #include 5 | #include "../h/mshell.h" 6 | #include "../h/mshellc.h" 7 | 8 | extern Bool found; 9 | 10 | /*------------------------------------------------------------------------ 11 | * mhelp - 'help' command for pseudo shell 12 | *------------------------------------------------------------------------ 13 | */ 14 | int mhelp(stdout) 15 | int stdout; 16 | { 17 | int i, j, inc; 18 | 19 | if ( (inc=(Msh.mncmds+3)/4) <= 0) 20 | inc = 1; 21 | fprintf(stdout, "Commands are:\n"); 22 | for(i=0 ; i 4 | #include 5 | #include 6 | 7 | /*------------------------------------------------------------------------ 8 | * netnum - obtain the network portion of a given IP address 9 | *------------------------------------------------------------------------ 10 | */ 11 | netnum(netpart, address) 12 | IPaddr netpart; 13 | IPaddr address; 14 | { 15 | blkcopy(netpart, address, IPLEN); 16 | switch (netpart[0] & IPTMASK) { 17 | case IPATYP: netpart[1] = '\0'; /* fall through */ 18 | case IPBTYP: netpart[2] = '\0'; /* fall through */ 19 | case IPCTYP: netpart[3] = '\0'; 20 | } 21 | return(OK); 22 | } 23 | -------------------------------------------------------------------------------- /contrib/ether.monitor/sys/phelp.c: -------------------------------------------------------------------------------- 1 | /* phelp.c - phelp */ 2 | 3 | #include 4 | #include 5 | #include "pshell.h" 6 | #include "pshellc.h" 7 | 8 | /*------------------------------------------------------------------------ 9 | * phelp - 'help' command for pseudo shell 10 | *------------------------------------------------------------------------ 11 | */ 12 | phelp(stdin, stdout, stderr, nargs, args) 13 | int stdin, stdout, stderr, nargs; 14 | char *args[]; 15 | { 16 | int i, j, inc; 17 | 18 | if ( (inc=(Psh.pncmds+3)/4) <= 0) 19 | inc = 1; 20 | fprintf(stdout, "Commands are:\n"); 21 | for(i=0 ; i 4 | #include 5 | #include 6 | 7 | /*------------------------------------------------------------------------ 8 | * setnok - set next-of-kin (notified at death) for a given process 9 | *------------------------------------------------------------------------ 10 | */ 11 | SYSCALL setnok(nok, pid) 12 | int nok; 13 | int pid; 14 | { 15 | char ps; 16 | struct pentry *pptr; 17 | 18 | disable(ps); 19 | if (isbadpid(pid)) { 20 | restore(ps); 21 | return(SYSERR); 22 | } 23 | pptr = &proctab[pid]; 24 | pptr->pnxtkin = nok; 25 | restore(ps); 26 | return(OK); 27 | } 28 | -------------------------------------------------------------------------------- /contrib/ether.monitor/sys/shell: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dancrossnyc/xinu68k/5e55d31122c01a394f2234dcd3be53b7030d34d3/contrib/ether.monitor/sys/shell -------------------------------------------------------------------------------- /host/cmd/Makeall: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Makeall -- make all of src/cmd for Xinu 4 | # 5 | 6 | echo 7 | echo '*** Making commands in {Xinu-directory}/src/cmd' 8 | 9 | make && make install 10 | for d in download fs 11 | do 12 | echo 13 | echo "*** Making commands in $XINU/src/cmd/$i" 14 | (cd $d && make && make install) 15 | done 16 | -------------------------------------------------------------------------------- /host/cmd/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | -------------------------------------------------------------------------------- /host/cmd/README: -------------------------------------------------------------------------------- 1 | This is README in {Xinu directory}/src/cmd. 2 | 3 | To make and install all commands, run 4 | 5 | Makeall 6 | 7 | To make particular programs (e.g., when you modify them), use 8 | 9 | make program-name 10 | make install 11 | -------------------------------------------------------------------------------- /host/cmd/download/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Xinu downloader 3 | # 4 | 5 | all: 6 | (cd lib ; make all) 7 | (cd cmd ; make all) 8 | (cd lsi11 ; make all) 9 | (cd vax ; make all) 10 | 11 | install: 12 | (cd lib ; make install) 13 | (cd cmd ; make install) 14 | (cd lsi11 ; make install) 15 | (cd vax ; make install) 16 | 17 | clean: 18 | (cd lib ; make clean) 19 | (cd cmd ; make clean) 20 | (cd lsi11 ; make clean) 21 | (cd vax ; make clean) 22 | -------------------------------------------------------------------------------- /host/cmd/download/h/baud.h: -------------------------------------------------------------------------------- 1 | struct baudent { 2 | char *name; 3 | int rate; 4 | } baudlist[] = { 5 | {"0", B0}, 6 | {"50", B50}, 7 | {"75", B75}, 8 | {"110", B110}, 9 | {"134", B134}, 10 | {"134.5", B134}, 11 | {"150", B150}, 12 | {"200", B200}, 13 | {"300", B300}, 14 | {"600", B600}, 15 | {"1200", B1200}, 16 | {"1800", B1800}, 17 | {"2400", B2400}, 18 | {"4800", B4800}, 19 | {"9600", B9600}, 20 | {"exta", EXTA}, 21 | {"19200", EXTA}, 22 | {"extb", EXTB}, 23 | {"38400", EXTB} 24 | }; 25 | 26 | #define NBAUD (sizeof(baudlist)/sizeof(struct baudent)) 27 | #define NOBAUD (-1) 28 | -------------------------------------------------------------------------------- /host/cmd/download/h/freedev.h: -------------------------------------------------------------------------------- 1 | #define FD_HOLD (1 << 0) /* hold dev--free others in class */ 2 | #define FD_FREE (1 << 1) /* free just this device */ 3 | #define FD_RELES (1 << 2) /* release other user's device */ 4 | #define FD_DBENTRY (1 << 3) /* class param is dev db entry */ 5 | #define FD_VERBOSE (1 << 5) /* verbose output when freeing */ 6 | 7 | #define FD_ANYDEV (-1) 8 | 9 | #define TRUE 1 10 | #define FALSE 0 11 | -------------------------------------------------------------------------------- /host/cmd/download/h/ulock.h: -------------------------------------------------------------------------------- 1 | #define SELF NULL 2 | 3 | extern char *get_ulock(); 4 | -------------------------------------------------------------------------------- /host/cmd/download/lsi11/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Lsi11-specific downloading routines 3 | # 4 | 5 | all: 6 | @echo Making Lsi-11 resident portion of up/downloaders 7 | (cd eload ; make all) 8 | @echo Making UNIX portion of Lsi-11 up/downloaders 9 | (cd src ; make all) 10 | 11 | install: 12 | @echo Making and installing Lsi-11 resident portion of up/downloaders 13 | (cd eload ; make install) 14 | @echo Making and installing UNIX portion of Lsi-11 up/downloaders 15 | (cd src ; make install) 16 | 17 | clean: 18 | @echo Cleaning LSI-11 resident portion up/downloader directory 19 | (cd eload ; make clean) 20 | @echo Cleaning LSI-11 UNIX portion up/downloader directory 21 | (cd src ; make clean) 22 | 23 | -------------------------------------------------------------------------------- /host/cmd/download/lsi11/README: -------------------------------------------------------------------------------- 1 | README 2 | ------ 3 | 4 | This directory contains all LSI-11 specific downloader code 5 | including the code that executes on the VAX when downloading 6 | an 11 as well as the code that executes on the 11 for bootstrap, 7 | serial line downloading, and ethernet downloading. 8 | 9 | The Makefile included here is to allow the Makefile in the parent 10 | directory to remake and install things without knowing the structure 11 | of lower-level directories. 12 | 13 | -------------------------------------------------------------------------------- /host/cmd/download/lsi11/eload/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Top-level Makefile for LSI 11 Ethernet downloader resident part 3 | # 4 | 5 | all: 6 | (cd src ; make all) 7 | 8 | install: 9 | (cd src ; make install) 10 | 11 | clean: 12 | (cd src ; make clean) 13 | 14 | -------------------------------------------------------------------------------- /host/cmd/download/lsi11/eload/h/baud.h: -------------------------------------------------------------------------------- 1 | struct baudent { 2 | char *name; 3 | int rate; 4 | } baudlist[] = { 5 | {"0", B0}, 6 | {"50", B50}, 7 | {"75", B75}, 8 | {"110", B110}, 9 | {"134", B134}, 10 | {"134.5", B134}, 11 | {"150", B150}, 12 | {"200", B200}, 13 | {"300", B300}, 14 | {"600", B600}, 15 | {"1200", B1200}, 16 | {"1800", B1800}, 17 | {"2400", B2400}, 18 | {"4800", B4800}, 19 | {"9600", B9600}, 20 | {"exta", EXTA}, 21 | {"19200", EXTA}, 22 | {"extb", EXTB}, 23 | {"38400", EXTB} 24 | }; 25 | 26 | #define NBAUD (sizeof(baudlist)/sizeof(struct baudent)) 27 | #define NOBAUD (-1) 28 | -------------------------------------------------------------------------------- /host/cmd/download/lsi11/eload/h/freedev.h: -------------------------------------------------------------------------------- 1 | #define FD_HOLD (1 << 0) /* hold dev--free others in class */ 2 | #define FD_FREE (1 << 1) /* free just this device */ 3 | #define FD_RELES (1 << 2) /* release other user's device */ 4 | #define FD_DBENTRY (1 << 3) /* class param is dev db entry */ 5 | #define FD_VERBOSE (1 << 5) /* verbose output when freeing */ 6 | 7 | #define FD_ANYDEV (-1) 8 | 9 | #define TRUE 1 10 | #define FALSE 0 11 | -------------------------------------------------------------------------------- /host/cmd/download/lsi11/eload/h/network.h: -------------------------------------------------------------------------------- 1 | /* network.h */ 2 | 3 | /* Declarations data conversion and checksum routines */ 4 | 5 | extern short hs2net(); /* host to network short */ 6 | extern short net2hs(); /* network to host short */ 7 | extern long hl2net(); /* host-to-network long */ 8 | extern long net2hl(); /* network to host long */ 9 | extern long hl2vax(); /* pdp11-to-vax long */ 10 | extern long vax2hl(); /* vax-to-pdp11 long */ 11 | extern short cksum(); /* 1s comp of 16-bit 2s comp sum*/ 12 | -------------------------------------------------------------------------------- /host/cmd/download/lsi11/eload/h/slu.h: -------------------------------------------------------------------------------- 1 | /* slu.h */ 2 | 3 | /* standard serial line unit device constants */ 4 | 5 | #define SLUENABLE 0100 /* device interrupt enable bit */ 6 | #define SLUREADY 0200 /* device ready bit */ 7 | #define SLUDISABLE 0000 /* device interrupt disable mask*/ 8 | #define SLUTBREAK 0001 /* transmitter break-mode bit */ 9 | #define SLUERMASK 0170000 /* mask for error flags on input*/ 10 | #define SLUCHMASK 0377 /* mask for input character */ 11 | 12 | /* SLU device register layout and correspondence to vendor's names */ 13 | 14 | struct csr { 15 | int crstat; /* receiver control and status (RCSR) */ 16 | int crbuf; /* receiver data buffer (RBUF) */ 17 | int ctstat; /* transmitter control & status (XCSR) */ 18 | int ctbuf; /* transmitter data buffer (XBUF) */ 19 | }; 20 | -------------------------------------------------------------------------------- /host/cmd/download/lsi11/eload/h/ulock.h: -------------------------------------------------------------------------------- 1 | #define SELF NULL 2 | 3 | extern char *get_ulock(); 4 | -------------------------------------------------------------------------------- /host/cmd/download/lsi11/eload/lib/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Make the run-time library for resident Ethernet downloader 3 | # 4 | 5 | AR = /bin/ar 6 | DIR = /usr/Xinu 7 | CC = $(DIR)/bin/cc11 8 | CFLAGS = -c -O 9 | LD = $(DIR)/bin/ld11 10 | LORDER = /usr/bin/lorder 11 | RANLIB = $(DIR)/bin/ranlib11 12 | 13 | .s.o: 14 | $(CC) $(CFLAGS) $< 15 | 16 | .c.o: 17 | $(CC) $(CFLAGS) $< 18 | 19 | SFILES = aldiv.s almul.s alrem.s csv.s ldiv.s lmul.s lrem.s 20 | 21 | CFILES = printf.c 22 | 23 | OFILES = aldiv.o almul.o alrem.o csv.o ldiv.o lmul.o lrem.o printf.o 24 | 25 | all: libsa.a 26 | 27 | install: all 28 | cp libsa.a ../src 29 | $(RANLIB) ../src/libsa.a 30 | 31 | clean: 32 | rm -rf *.o *.a a.out core .,* ,* 33 | 34 | libsa.a: $(OFILES) 35 | rm -rf libsa.a 36 | $(AR) cr libsa.a $(OFILES) 37 | $(RANLIB) libsa.a 38 | -------------------------------------------------------------------------------- /host/cmd/download/lsi11/eload/lib/almul.s: -------------------------------------------------------------------------------- 1 | / 2 | / 32-bit multiplication routine for fixed pt hardware. 3 | / Implements *= operator 4 | / Credit to an unknown author who slipped it under the door. 5 | .globl almul 6 | .globl csv, cret 7 | 8 | almul: 9 | jsr r5,csv 10 | mov 4(r5),r4 11 | mov 2(r4),r2 12 | sxt r1 13 | sub (r4),r1 14 | mov 8.(r5),r0 15 | sxt r3 16 | sub 6.(r5),r3 17 | mul r0,r1 18 | mul r2,r3 19 | add r1,r3 20 | mul r2,r0 21 | sub r3,r0 22 | mov r0,(r4)+ 23 | mov r1,(r4) 24 | jmp cret 25 | -------------------------------------------------------------------------------- /host/cmd/download/lsi11/eload/lib/csv.s: -------------------------------------------------------------------------------- 1 | / C register save and restore -- version 7/75 2 | 3 | .globl csv 4 | .globl cret 5 | 6 | csv: 7 | mov r5,r0 8 | mov sp,r5 9 | mov r4,-(sp) 10 | mov r3,-(sp) 11 | mov r2,-(sp) 12 | jsr pc,(r0) / jsr part is sub $2,sp 13 | 14 | cret: 15 | mov r5,r2 16 | mov -(r2),r4 17 | mov -(r2),r3 18 | mov -(r2),r2 19 | mov r5,sp 20 | mov (sp)+,r5 21 | rts pc 22 | -------------------------------------------------------------------------------- /host/cmd/download/lsi11/eload/lib/lmul.s: -------------------------------------------------------------------------------- 1 | / 2 | / 32-bit multiplication routine for fixed pt hardware. 3 | / Implements * operator 4 | / Credit to an unknown author who slipped it under the door. 5 | .globl lmul 6 | .globl csv, cret 7 | 8 | lmul: 9 | jsr r5,csv 10 | mov 6(r5),r2 11 | sxt r1 12 | sub 4(r5),r1 13 | mov 10.(r5),r0 14 | sxt r3 15 | sub 8.(r5),r3 16 | mul r0,r1 17 | mul r2,r3 18 | add r1,r3 19 | mul r2,r0 20 | sub r3,r0 21 | jmp cret 22 | -------------------------------------------------------------------------------- /host/cmd/download/lsi11/eload/src/.entry: -------------------------------------------------------------------------------- 1 | #define ETH_INITPC 000004 2 | -------------------------------------------------------------------------------- /host/cmd/download/lsi11/eload/src/.version: -------------------------------------------------------------------------------- 1 | #define VERSION 22 2 | #define ROMVERS 255 3 | -------------------------------------------------------------------------------- /host/cmd/download/lsi11/eload/src/Mknlist: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | PATH=/bin:/usr/bin 3 | DIR=/usr/Xinu 4 | OUTFILE=$1 5 | shift 6 | $DIR/bin/nm11 -n eload | egrep ' T | D | B ' > $OUTFILE 7 | -------------------------------------------------------------------------------- /host/cmd/download/lsi11/eload/src/av.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | : 'av - automatic version generator increments .version in current directory' 3 | : 4 | : 'Note: version 255 is reserved for ROM version (always accepted)' 5 | : 6 | VERSFILE=.version 7 | if test ! -f $VERSFILE -o ! -s $VERSFILE 8 | then echo "#define VERSION -1" > $VERSFILE 9 | fi 10 | awk ' \ 11 | /VERSION/ { \ 12 | print "#define VERSION " ($3 +1) % 255; \ 13 | print "#define ROMVERS 255" \ 14 | } \ 15 | ' < $VERSFILE > ,$VERSFILE 16 | /bin/mv ,$VERSFILE $VERSFILE 17 | 18 | -------------------------------------------------------------------------------- /host/cmd/download/lsi11/eload/src/blkcopy.c: -------------------------------------------------------------------------------- 1 | /* blkcopy.c - blkcopy */ 2 | 3 | #include "../h/eload.h" 4 | 5 | /*------------------------------------------------------------------------ 6 | * blkcopy - copy a block of memory form one location to another 7 | *------------------------------------------------------------------------ 8 | */ 9 | blkcopy(to, from, nbytes) 10 | register char *to; 11 | register char *from; 12 | register int nbytes; 13 | { 14 | while (--nbytes >= 0) 15 | *to++ = *from++; 16 | return(OK); 17 | } 18 | -------------------------------------------------------------------------------- /host/cmd/download/lsi11/eload/src/blkequ.c: -------------------------------------------------------------------------------- 1 | /* blkequ.c - blkequ */ 2 | 3 | #include "../h/eload.h" 4 | 5 | /*------------------------------------------------------------------------ 6 | * blkequ - return TRUE iff one block of memory is equal to another 7 | *------------------------------------------------------------------------ 8 | */ 9 | blkequ(first, second, nbytes) 10 | register char *first; 11 | register char *second; 12 | register int nbytes; 13 | { 14 | while (--nbytes >= 0) 15 | if (*first++ != *second++) 16 | return(FALSE); 17 | return(TRUE); 18 | } 19 | -------------------------------------------------------------------------------- /host/cmd/download/lsi11/eload/src/edcmset.c: -------------------------------------------------------------------------------- 1 | /* edcmset.c -- edcmset */ 2 | 3 | #include "../h/eload.h" 4 | #include "../h/deqna.h" 5 | 6 | /*------------------------------------------------------------------------ 7 | * edcmset -- initialize last command in deqna command list 8 | *------------------------------------------------------------------------ 9 | */ 10 | edcmset(dcmptr) 11 | struct dcmd *dcmptr; 12 | { 13 | dcmptr->dc_flag = DC_NUSED; 14 | dcmptr->dc_bufh = DC_ENDL; 15 | dcmptr->dc_buf = NULL; 16 | dcmptr->dc_st1 = dcmptr->dc_st2 = DC_INIT; 17 | } 18 | -------------------------------------------------------------------------------- /host/cmd/download/lsi11/eload/src/en.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | : 'en - defines eload entry point in .entry' 3 | : 4 | ENTRY=.entry 5 | /usr/Xinu/bin/nm11 eload | /bin/awk ' \ 6 | /estart/ { \ 7 | print "#define ETH_INITPC " $1 \ 8 | } \ 9 | ' > ,$ENTRY 10 | /bin/mv ,$ENTRY $ENTRY 11 | -------------------------------------------------------------------------------- /host/cmd/download/lsi11/eload/src/ewstart.c: -------------------------------------------------------------------------------- 1 | /* ewstart.c - ewstart */ 2 | 3 | #include "../h/eload.h" 4 | #include "../h/deqna.h" 5 | #include "../h/ether.h" 6 | 7 | ewstart(dcmptr, packet, len, setup) 8 | struct dcmd *dcmptr; 9 | struct epacket *packet; 10 | int len; 11 | int setup; 12 | { 13 | register struct dqregs *dqptr; 14 | 15 | dqptr = (struct dqregs *) EDEVICE; 16 | dcmptr->dc_bufh = DC_VALID | DC_ENDM | setup; 17 | if (isodd(len)) 18 | dcmptr->dc_bufh |= DC_LBIT; 19 | dcmptr->dc_buf = 0160000 | (unsigned)packet; 20 | dcmptr->dc_len = dqlen(len); 21 | dcmptr->dc_st1 = dcmptr->dc_st2 = DC_INIT; 22 | dcmptr->dc_flag = DC_NUSED; 23 | dqptr->d_wcmd = 0160000 | (unsigned)dcmptr; 24 | dqptr->d_wcmdh = NULL; 25 | } 26 | -------------------------------------------------------------------------------- /host/cmd/download/lsi11/eload/src/startup.s: -------------------------------------------------------------------------------- 1 | /* startup.s - start */ 2 | 3 | DISABLE = 340 / PS to disable interrupts 4 | 5 | /*---------------------------------------------------------------------- 6 | /* Etherload startup header -- branches to main program after disabling 7 | /*---------------------------------------------------------------------- 8 | .globl estart 9 | args: 10 | . = 4.^. / space for args 11 | estart: 12 | mtps $DISABLE / Disable interrupts 13 | jsr pc,_eload / start eload C program 14 | halt / halt if program returns 15 | jbr estart / rerun if user types P 16 | -------------------------------------------------------------------------------- /host/cmd/download/lsi11/h/baud.h: -------------------------------------------------------------------------------- 1 | struct baudent { 2 | char *name; 3 | int rate; 4 | } baudlist[] = { 5 | {"0", B0}, 6 | {"50", B50}, 7 | {"75", B75}, 8 | {"110", B110}, 9 | {"134", B134}, 10 | {"134.5", B134}, 11 | {"150", B150}, 12 | {"200", B200}, 13 | {"300", B300}, 14 | {"600", B600}, 15 | {"1200", B1200}, 16 | {"1800", B1800}, 17 | {"2400", B2400}, 18 | {"4800", B4800}, 19 | {"9600", B9600}, 20 | {"exta", EXTA}, 21 | {"19200", EXTA}, 22 | {"extb", EXTB}, 23 | {"38400", EXTB} 24 | }; 25 | 26 | #define NBAUD (sizeof(baudlist)/sizeof(struct baudent)) 27 | #define NOBAUD (-1) 28 | -------------------------------------------------------------------------------- /host/cmd/download/lsi11/h/core11.h: -------------------------------------------------------------------------------- 1 | /* 2 | * header for "core11" files 3 | */ 4 | #define REGISTERS 8 5 | #define NREGS REGISTERS+1 /* including PS */ 6 | #define COREMAGIC 0477 7 | struct core11 { 8 | short c_magic; 9 | short c_size; 10 | short c_zero1; 11 | short c_zero2; 12 | short c_regs[REGISTERS]; 13 | short c_psw; 14 | short c_zero3; 15 | short c_zero4; 16 | short c_zero5; 17 | }; 18 | #define R0 0 19 | #define R1 1 20 | #define R2 2 21 | #define R3 3 22 | #define R4 4 23 | #define R5 5 24 | #define R6 6 25 | #define R7 7 26 | -------------------------------------------------------------------------------- /host/cmd/download/lsi11/h/freedev.h: -------------------------------------------------------------------------------- 1 | #define FD_HOLD (1 << 0) /* hold dev--free others in class */ 2 | #define FD_FREE (1 << 1) /* free just this device */ 3 | #define FD_RELES (1 << 2) /* release other user's device */ 4 | #define FD_DBENTRY (1 << 3) /* class param is dev db entry */ 5 | #define FD_VERBOSE (1 << 5) /* verbose output when freeing */ 6 | 7 | #define FD_ANYDEV (-1) 8 | 9 | #define TRUE 1 10 | #define FALSE 0 11 | -------------------------------------------------------------------------------- /host/cmd/download/lsi11/h/lsiul.h: -------------------------------------------------------------------------------- 1 | /* lsiul.h -- definitions specific to PDP-11 uploader */ 2 | 3 | #define MAXADDR 0157777 4 | #define CSRBASE 0177560 5 | #define LOADSTART 0 6 | typedef unsigned short lsiword; 7 | 8 | #define LOADER "/usr/Xinu/lib/sul.boot.lsi" 9 | #define MAXSERPKT 526 10 | #define STACKLEN 20 11 | #define INTDISABLE 0340 12 | #define NOAUTOSTART -1 13 | #define DEFFILE "core11" 14 | #define ACKTIME 3 15 | 16 | struct spkt { 17 | lsiword len, base; 18 | lsiword buf[MAXSERPKT]; 19 | lsiword sum; 20 | }; 21 | -------------------------------------------------------------------------------- /host/cmd/download/lsi11/h/lsiul.h.RAW: -------------------------------------------------------------------------------- 1 | /* lsiul.h -- definitions specific to PDP-11 uploader */ 2 | 3 | #define MAXADDR 0157777 4 | #define CSRBASE 0177560 5 | #define LOADSTART 0 6 | typedef unsigned short lsiword; 7 | 8 | #define LOADER "{Xinu-directory}/lib/sul.boot.lsi" 9 | #define MAXSERPKT 526 10 | #define STACKLEN 20 11 | #define INTDISABLE 0340 12 | #define NOAUTOSTART -1 13 | #define DEFFILE "core11" 14 | #define ACKTIME 3 15 | 16 | struct spkt { 17 | lsiword len, base; 18 | lsiword buf[MAXSERPKT]; 19 | lsiword sum; 20 | }; 21 | -------------------------------------------------------------------------------- /host/cmd/download/lsi11/h/ulock.h: -------------------------------------------------------------------------------- 1 | #define SELF NULL 2 | 3 | extern char *get_ulock(); 4 | -------------------------------------------------------------------------------- /host/cmd/download/vax/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for VAX-specific downloading routines 3 | # 4 | 5 | all: 6 | @echo Making VAX-resident portion of up/downloaders 7 | (cd eload ; make all) 8 | @echo Making UNIX portion of VAX up/downloaders 9 | (cd src ; make all) 10 | 11 | install: 12 | @echo Making and installing VAX-resident portion of up/downloaders 13 | (cd eload ; make install) 14 | @echo Making and installing UNIX portion of VAX up/downloaders 15 | (cd src ; make install) 16 | 17 | clean: 18 | @echo Cleaning VAX-resident portion up/downloader directory 19 | (cd eload ; make clean) 20 | @echo Cleaning VAX UNIX portion up/downloader directory 21 | (cd src ; make clean) 22 | 23 | -------------------------------------------------------------------------------- /host/cmd/download/vax/README: -------------------------------------------------------------------------------- 1 | README 2 | ------ 3 | 4 | This directory contains all VAX specific downloader code 5 | including the code that executes on the UNIX machine VAX when 6 | downloading to a VAX as well as the code that executes on the 7 | VAX for bootstrap, serial line downloading, and ethernet 8 | downloading. 9 | 10 | The Makefile included here is to allow the Makefile in the parent 11 | directory to remake and install things without knowing the structure 12 | of lower-level directories. 13 | -------------------------------------------------------------------------------- /host/cmd/download/vax/eload/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for VAX Ethernet downloader 3 | # 4 | 5 | all: 6 | (cd src ; make all) 7 | 8 | install: 9 | (cd src ; make install) 10 | 11 | clean: 12 | (cd src ; make clean) 13 | -------------------------------------------------------------------------------- /host/cmd/download/vax/eload/h/baud.h: -------------------------------------------------------------------------------- 1 | struct baudent { 2 | char *name; 3 | int rate; 4 | } baudlist[] = { 5 | {"0", B0}, 6 | {"50", B50}, 7 | {"75", B75}, 8 | {"110", B110}, 9 | {"134", B134}, 10 | {"134.5", B134}, 11 | {"150", B150}, 12 | {"200", B200}, 13 | {"300", B300}, 14 | {"600", B600}, 15 | {"1200", B1200}, 16 | {"1800", B1800}, 17 | {"2400", B2400}, 18 | {"4800", B4800}, 19 | {"9600", B9600}, 20 | {"exta", EXTA}, 21 | {"19200", EXTA}, 22 | {"extb", EXTB}, 23 | {"38400", EXTB} 24 | }; 25 | 26 | #define NBAUD (sizeof(baudlist)/sizeof(struct baudent)) 27 | #define NOBAUD (-1) 28 | -------------------------------------------------------------------------------- /host/cmd/download/vax/eload/h/ethdown.h: -------------------------------------------------------------------------------- 1 | /* ethdown.h -- definitions for VAX ethernet down/up loader */ 2 | 3 | #define DLUDP 2001 /* UPD port for download */ 4 | #define MIN_UDPPORT 2030 5 | #define ELOAD "/usr/Xinu/lib/eload.vax" 6 | #define ETH_OK 1 /* ethernet download success */ 7 | #define ETH_FAILED -1 /* ethernet download failed */ 8 | #define ETH_INITSP 0xe7000 /* initial SP value for eload */ 9 | #define ETH_INITPC 0xce000 /* initial PC value for eload */ 10 | -------------------------------------------------------------------------------- /host/cmd/download/vax/eload/h/freedev.h: -------------------------------------------------------------------------------- 1 | #define FD_HOLD (1 << 0) /* hold dev--free others in class */ 2 | #define FD_FREE (1 << 1) /* free just this device */ 3 | #define FD_RELES (1 << 2) /* release other user's device */ 4 | #define FD_DBENTRY (1 << 3) /* class param is dev db entry */ 5 | #define FD_VERBOSE (1 << 5) /* verbose output when freeing */ 6 | 7 | #define FD_ANYDEV (-1) 8 | 9 | #define TRUE 1 10 | #define FALSE 0 11 | -------------------------------------------------------------------------------- /host/cmd/download/vax/eload/h/network.h: -------------------------------------------------------------------------------- 1 | /* network.h */ 2 | 3 | /* Declarations data conversion and checksum routines */ 4 | 5 | extern short hs2net(); /* host to network short */ 6 | extern short net2hs(); /* network to host short */ 7 | extern long hl2net(); /* host-to-network long */ 8 | extern long net2hl(); /* network to host long */ 9 | extern short cksum(); /* 1s comp of 16-bit 2s comp sum*/ 10 | -------------------------------------------------------------------------------- /host/cmd/download/vax/eload/h/ulock.h: -------------------------------------------------------------------------------- 1 | #define SELF NULL 2 | 3 | extern char *get_ulock(); 4 | -------------------------------------------------------------------------------- /host/cmd/download/vax/eload/src/av.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | : 'av - automatic version generator increments .version in current directory' 3 | : 4 | : 'Note: version 255 is reserved for ROM version (always accepted)' 5 | : 6 | VERSFILE=.version 7 | if test ! -f $VERSFILE -o ! -s $VERSFILE 8 | then echo "#define VERSION -1" > $VERSFILE 9 | fi 10 | awk ' \ 11 | /VERSION/ { \ 12 | print "#define VERSION " ($3 +1) % 255; \ 13 | print "#define ROMVERS 255" \ 14 | } \ 15 | ' < $VERSFILE > ,$VERSFILE 16 | /bin/mv ,$VERSFILE $VERSFILE 17 | 18 | -------------------------------------------------------------------------------- /host/cmd/download/vax/eload/src/blkcopy.c: -------------------------------------------------------------------------------- 1 | /* blkcopy.c - blkcopy */ 2 | 3 | /*------------------------------------------------------------------------ 4 | * blkcopy - copy a block of memory form one location to another 5 | *------------------------------------------------------------------------ 6 | */ 7 | blkcopy(to, from, nbytes) 8 | register char *to; 9 | register char *from; 10 | register int nbytes; 11 | { 12 | while (--nbytes >= 0) 13 | *to++ = *from++; 14 | } 15 | -------------------------------------------------------------------------------- /host/cmd/download/vax/eload/src/blkequ.c: -------------------------------------------------------------------------------- 1 | /* blkequ.c - blkequ */ 2 | 3 | #include 4 | 5 | /*------------------------------------------------------------------------ 6 | * blkequ - return TRUE iff one block of memory is equal to another 7 | *------------------------------------------------------------------------ 8 | */ 9 | blkequ(first, second, nbytes) 10 | register char *first; 11 | register char *second; 12 | register int nbytes; 13 | { 14 | while (--nbytes >= 0) 15 | if (*first++ != *second++) 16 | return(FALSE); 17 | return(TRUE); 18 | } 19 | -------------------------------------------------------------------------------- /host/cmd/download/vax/eload/src/edcmset.c: -------------------------------------------------------------------------------- 1 | /* edcmset.c -- edcmset */ 2 | 3 | #include "../h/eload.h" 4 | #include "../h/deqna.h" 5 | 6 | /*------------------------------------------------------------------------ 7 | * edcmset -- initialize last command in deqna command list 8 | *------------------------------------------------------------------------ 9 | */ 10 | edcmset(dcmptr) 11 | struct dcmd *dcmptr; 12 | { 13 | dcmptr->dc_flag = DC_NUSED; 14 | dcmptr->dc_bufh = DC_ENDL; 15 | dcmptr->dc_buf = (short) NULL; 16 | dcmptr->dc_st1 = dcmptr->dc_st2 = DC_INIT; 17 | } 18 | -------------------------------------------------------------------------------- /host/cmd/download/vax/eload/src/ewstart.c: -------------------------------------------------------------------------------- 1 | /* ewstart.c - ewstart */ 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | ewstart(dcmptr, packet, len, setup) 9 | struct dcmd *dcmptr; 10 | struct epacket *packet; 11 | int len; 12 | int setup; 13 | { 14 | register struct dqregs *dqptr; 15 | 16 | dqptr = (struct dqregs *) EDEVICE; 17 | dcmptr->dc_bufh = DC_VALID | DC_ENDM | setup | hiQ2low(packet); 18 | if (isodd(len)) 19 | dcmptr->dc_bufh |= DC_LBIT; 20 | dcmptr->dc_buf = (short) packet; 21 | dcmptr->dc_len = dqlen(len); 22 | dcmptr->dc_st1 = dcmptr->dc_st2 = DC_INIT; 23 | dcmptr->dc_flag = DC_NUSED; 24 | dqptr->d_wcmd = (short) dcmptr; 25 | dqptr->d_wcmdh = hiQ2low(dcmptr); 26 | } 27 | -------------------------------------------------------------------------------- /host/cmd/download/vax/eload/src/qmapinit.c: -------------------------------------------------------------------------------- 1 | /* qmapinit.c -- qmapinit */ 2 | 3 | #include 4 | 5 | /*------------------------------------------------------------------------ 6 | * qmapinit -- initialize Microvax II qbus mapping registers 7 | * called by eload only if running on UVAXII 8 | * warning: only 4 megs of memory are mapped for dma access 9 | *------------------------------------------------------------------------ 10 | */ 11 | 12 | qmapinit() 13 | { 14 | unsigned int *pqmapreg; 15 | unsigned int i; 16 | 17 | *QMMECSR = 1; /* enable parity error detection */ 18 | for (pqmapreg = QMAP, i = 0; i < QMNMREG; ) 19 | *pqmapreg++ = QMREGV | i++; 20 | *QMIPCR = QMENAB; /* enable bus mapping */ 21 | } 22 | -------------------------------------------------------------------------------- /host/cmd/download/vax/h/baud.h: -------------------------------------------------------------------------------- 1 | struct baudent { 2 | char *name; 3 | int rate; 4 | } baudlist[] = { 5 | {"0", B0}, 6 | {"50", B50}, 7 | {"75", B75}, 8 | {"110", B110}, 9 | {"134", B134}, 10 | {"134.5", B134}, 11 | {"150", B150}, 12 | {"200", B200}, 13 | {"300", B300}, 14 | {"600", B600}, 15 | {"1200", B1200}, 16 | {"1800", B1800}, 17 | {"2400", B2400}, 18 | {"4800", B4800}, 19 | {"9600", B9600}, 20 | {"exta", EXTA}, 21 | {"19200", EXTA}, 22 | {"extb", EXTB}, 23 | {"38400", EXTB} 24 | }; 25 | 26 | #define NBAUD (sizeof(baudlist)/sizeof(struct baudent)) 27 | #define NOBAUD (-1) 28 | -------------------------------------------------------------------------------- /host/cmd/download/vax/h/ethdown.h: -------------------------------------------------------------------------------- 1 | /* ethdown.h -- definitions for VAX ethernet down/up loader */ 2 | 3 | #define DLUDP 2001 /* UPD port for download */ 4 | #define MIN_UDPPORT 2030 5 | #define ELOAD "/usr/Xinu/lib/eload.vax" 6 | #define ETH_OK 1 /* ethernet download success */ 7 | #define ETH_FAILED -1 /* ethernet download failed */ 8 | #define ETH_INITSP 0xe7000 /* initial SP value for eload */ 9 | #define ETH_INITPC 0xce000 /* initial PC value for eload */ 10 | -------------------------------------------------------------------------------- /host/cmd/download/vax/h/ethdown.h.RAW: -------------------------------------------------------------------------------- 1 | /* ethdown.h -- definitions for VAX ethernet down/up loader */ 2 | 3 | #define DLUDP 2001 /* UPD port for download */ 4 | #define MIN_UDPPORT 2030 5 | #define ELOAD "{Xinu-directory}/lib/eload.vax" 6 | #define ETH_OK 1 /* ethernet download success */ 7 | #define ETH_FAILED -1 /* ethernet download failed */ 8 | #define ETH_INITSP 0xe7000 /* initial SP value for eload */ 9 | #define ETH_INITPC 0xce000 /* initial PC value for eload */ 10 | -------------------------------------------------------------------------------- /host/cmd/download/vax/h/freedev.h: -------------------------------------------------------------------------------- 1 | #define FD_HOLD (1 << 0) /* hold dev--free others in class */ 2 | #define FD_FREE (1 << 1) /* free just this device */ 3 | #define FD_RELES (1 << 2) /* release other user's device */ 4 | #define FD_DBENTRY (1 << 3) /* class param is dev db entry */ 5 | #define FD_VERBOSE (1 << 5) /* verbose output when freeing */ 6 | 7 | #define FD_ANYDEV (-1) 8 | 9 | #define TRUE 1 10 | #define FALSE 0 11 | -------------------------------------------------------------------------------- /host/cmd/download/vax/h/ulock.h: -------------------------------------------------------------------------------- 1 | #define SELF NULL 2 | 3 | extern char *get_ulock(); 4 | -------------------------------------------------------------------------------- /host/cmd/download/vax/h/vaxul.h: -------------------------------------------------------------------------------- 1 | /* vaxul.h -- definitions specific to VAX uploader */ 2 | 3 | #define DEFFILE "coreX" 4 | #define ACKTIME 3 5 | #define MAXADDR 0x20000000 6 | #define NOAUTOSTART (-1) 7 | #define LOW16 0xffff 8 | #define CONSKILL "\025" /* ^U */ 9 | #define CONSABRT "\003" /* ^C */ 10 | #define CONSINTR "\020" /* ^P */ 11 | #define CPUHALT "H\r" /* halts the cpu */ 12 | #define CPUNJAM "U\r" /* unjams the bus */ 13 | #define CPUINIT "I\r" /* initialize the cpu */ 14 | #define KSPREG -1001 /* " " for kernel stack ptr */ 15 | #define SPREG 0xe /* stack pointer register */ 16 | #define PCREG 0xf /* PC general register */ 17 | -------------------------------------------------------------------------------- /host/cmd/fs/Close.c: -------------------------------------------------------------------------------- 1 | // Close.c - Close 2 | 3 | #include "fs.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // Close - close a file given its index in the file cache table 7 | //------------------------------------------------------------------------ 8 | int 9 | Close(int rfd) 10 | { 11 | if (close(fcache[rfd].fd) < 0) 12 | return (SYSERR); 13 | fcache[rfd].name[0] = NULLCH; 14 | fcache[fcache[rfd].prev].next = fcache[rfd].next; 15 | fcache[fcache[rfd].next].prev = fcache[rfd].prev; 16 | fcache[rfd].prev = NOFILE; 17 | fcache[rfd].next = freelst; 18 | freelst = rfd; 19 | return (OK); 20 | } 21 | -------------------------------------------------------------------------------- /host/cmd/fs/Seek.c: -------------------------------------------------------------------------------- 1 | // Seek.c - Seek 2 | 3 | #include "fs.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // Seek - seek in a file given its index in the file cache table 7 | //------------------------------------------------------------------------ 8 | int 9 | Seek(int rfd, long newpos) 10 | { 11 | long lseek(); 12 | long pos; 13 | 14 | if ((pos = lseek(fcache[rfd].fd, newpos, 0)) < 0) 15 | return (SYSERR); 16 | fcache[rfd].currpos = pos; 17 | return (OK); 18 | } 19 | -------------------------------------------------------------------------------- /host/cmd/fs/Uncache.c: -------------------------------------------------------------------------------- 1 | // Uncache.c - Uncache 2 | 3 | #include "fs.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // Uncache - remove the cached entry for a file and close the file 7 | //------------------------------------------------------------------------ 8 | int 9 | Uncache(char *name) 10 | { 11 | int rfd; 12 | 13 | for (rfd = 0; rfd < MAXNFILES; rfd++) { 14 | if (strcmp(name, fcache[rfd].name) == 0) { 15 | Close(rfd); 16 | return (OK); 17 | } 18 | } 19 | return (SYSERR); 20 | } 21 | -------------------------------------------------------------------------------- /host/cmd/fs/fsaccess.c: -------------------------------------------------------------------------------- 1 | // fsaccess.c - fsaccess 2 | 3 | #include "fs.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // fsaccess - handle access request and prepare reply 7 | //------------------------------------------------------------------------ 8 | int 9 | fsaccess(struct fpacket *fpacptr, int flen) 10 | { 11 | struct fphdr *fptr; 12 | int rfd; 13 | 14 | fptr = &fpacptr->fp_h; 15 | fptr->f_op = FS_ERROR; 16 | return (FHDRLEN); 17 | } 18 | -------------------------------------------------------------------------------- /host/cmd/fs/fsclose.c: -------------------------------------------------------------------------------- 1 | // fsclose.c - fsclose 2 | 3 | #include "fs.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // fsclose - handle request to close a file 7 | //------------------------------------------------------------------------ 8 | int 9 | fsclose(struct fpacket *fpacptr, int flen) 10 | { 11 | struct fphdr *fptr; 12 | int rfd; 13 | 14 | fptr = &fpacptr->fp_h; 15 | if (Uncache(fptr->f_name) == SYSERR) 16 | fptr->f_op = FS_ERROR; 17 | return (FHDRLEN); 18 | } 19 | -------------------------------------------------------------------------------- /host/cmd/fs/fsmkdir.c: -------------------------------------------------------------------------------- 1 | // fsmkdir.c - fsmkdir 2 | 3 | #include "fs.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // fsmkdir - handle mkdir request and prepare reply 7 | //------------------------------------------------------------------------ 8 | int 9 | fsmkdir(struct fpacket *fpacptr, int flen) 10 | { 11 | struct fphdr *fptr; 12 | int rfd; 13 | 14 | if (mkdir(fptr->f_name, fptr->f_count) < 0) 15 | fptr->f_op = FS_ERROR; 16 | else 17 | Uncache(fptr->f_name); 18 | return (FHDRLEN); 19 | } 20 | -------------------------------------------------------------------------------- /host/cmd/fs/fsopen.c: -------------------------------------------------------------------------------- 1 | // fsopen.c - fsopen 2 | 3 | #include "fs.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // fsopen - handle open request and prepare reply 7 | //------------------------------------------------------------------------ 8 | int 9 | fsopen(struct fpacket *fpacptr, int flen) 10 | { 11 | struct stat stinfo; 12 | struct fphdr *fptr; 13 | int rfd; 14 | 15 | fptr = &fpacptr->fp_h; 16 | if ((rfd = Open(fptr->f_name, fptr->f_count)) < 0 || 17 | fstat(fcache[rfd].fd, &stinfo) < 0) 18 | fptr->f_op = FS_ERROR; 19 | else 20 | fptr->f_pos = stinfo.st_size; 21 | 22 | return FHDRLEN; 23 | } 24 | -------------------------------------------------------------------------------- /host/cmd/fs/fsread.c: -------------------------------------------------------------------------------- 1 | // fsread.c - fsread 2 | 3 | #include "fs.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // fsread - handle read request and prepare reply 7 | //------------------------------------------------------------------------ 8 | int 9 | fsread(struct fpacket *fpacptr, int flen) 10 | { 11 | struct fphdr *fptr; 12 | int rfd; 13 | int n; 14 | 15 | fptr = &fpacptr->fp_h; 16 | if ((rfd = Open(fptr->f_name, FLOLD | FLREAD)) < 0 17 | || Seek(rfd, fptr->f_pos) < 0 18 | || (n = read(fcache[rfd].fd, fpacptr->fpdata, 19 | fptr->f_count)) < 0) { 20 | fptr->f_op = FS_ERROR; 21 | return FHDRLEN; 22 | } 23 | fcache[rfd].currpos = fptr->f_pos += fptr->f_count = n; 24 | 25 | return n + FHDRLEN; 26 | } 27 | -------------------------------------------------------------------------------- /host/cmd/fs/fsrmdir.c: -------------------------------------------------------------------------------- 1 | // fsrmdir.c - fsrmdir 2 | 3 | #include "fs.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // fsrmdir - handle rmdir request and prepare reply 7 | //------------------------------------------------------------------------ 8 | int 9 | fsrmdir(struct fpacket *fpacptr, int flen) 10 | { 11 | struct fphdr *fptr; 12 | 13 | fptr = &fpacptr->fp_h; 14 | if (rmdir(fptr->f_name) < 0) 15 | fptr->f_op = FS_ERROR; 16 | else 17 | Uncache(fptr->f_name); 18 | 19 | return FHDRLEN; 20 | } 21 | -------------------------------------------------------------------------------- /host/cmd/fs/fstrans.c: -------------------------------------------------------------------------------- 1 | // fstrans.c - fstrans 2 | 3 | #include "fs.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // fstrans - handle transaction request and prepare reply 7 | //------------------------------------------------------------------------ 8 | int 9 | fstrans(struct fpacket *fpacptr, int flen) 10 | { 11 | struct fphdr *fptr; 12 | int rfd; 13 | 14 | fptr = &fpacptr->fp_h; 15 | fptr->f_op = FS_ERROR; // presently, no transactions 16 | 17 | return FHDRLEN; 18 | } 19 | -------------------------------------------------------------------------------- /host/cmd/fs/fsunlink.c: -------------------------------------------------------------------------------- 1 | // fsunlink.c - fsunlink 2 | 3 | #include "fs.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // fsunlink - handle unlink request and prepare reply 7 | //------------------------------------------------------------------------ 8 | int 9 | fsunlink(struct fpacket *fpacptr, int flen) 10 | { 11 | struct fphdr *fptr; 12 | int rfd; 13 | 14 | fptr = &fpacptr->fp_h; 15 | if (rmfile(fptr->f_name) < 0) { 16 | fptr->f_op = FS_ERROR; 17 | } else { 18 | Uncache(fptr->f_name); 19 | } 20 | 21 | return flen; 22 | } 23 | -------------------------------------------------------------------------------- /host/cmd/fs/fswrite.c: -------------------------------------------------------------------------------- 1 | // fswrite.c - fswrite 2 | 3 | #include "fs.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // fswrite - handle write request and prepare reply 7 | //------------------------------------------------------------------------ 8 | int 9 | fswrite(struct fpacket *fpacptr, int flen) 10 | { 11 | struct fphdr *fptr; 12 | int rfd; 13 | 14 | fptr = &fpacptr->fp_h; 15 | if ((rfd = Open(fptr->f_name, FLOLD | FLWRITE)) < 0 || 16 | Seek(rfd, fptr->f_pos) < 0 || 17 | (fptr->f_count = write(fcache[rfd].fd, 18 | fpacptr->fpdata, 19 | fptr->f_count)) < 0) { 20 | fptr->f_op = FS_ERROR; 21 | } else { 22 | fptr->f_pos += fptr->f_count; 23 | fcache[rfd].currpos = fptr->f_pos; 24 | } 25 | 26 | return FHDRLEN; 27 | } 28 | -------------------------------------------------------------------------------- /host/cmd/fs/rmfile.c: -------------------------------------------------------------------------------- 1 | // rmfile.c - rmfile 2 | 3 | #include "fs.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // rmfile - remove a file given its name and delete cache entry 7 | //------------------------------------------------------------------------ 8 | int 9 | rmfile(char *name) 10 | { 11 | char fname[RNAMLEN]; 12 | char *subdir; 13 | 14 | if (unlink(name) < 0) 15 | return SYSERR; 16 | strncpy(fname, name, sizeof(fname)); 17 | fname[sizeof(fname) - 1] = NULLCH; 18 | while ((subdir = rindex(fname, '/')) != NULL && subdir != fname) { 19 | *subdir = NULLCH; 20 | if (rmdir(fname) < 0) 21 | return OK; 22 | } 23 | 24 | return OK; 25 | } 26 | -------------------------------------------------------------------------------- /include/baud.h: -------------------------------------------------------------------------------- 1 | struct baudent { 2 | char *name; 3 | int rate; 4 | } baudlist[] = { 5 | {"0", B0}, 6 | {"50", B50}, 7 | {"75", B75}, 8 | {"110", B110}, 9 | {"134", B134}, 10 | {"150", B150}, 11 | {"200", B200}, 12 | {"300", B300}, 13 | {"600", B600}, 14 | {"1200", B1200}, 15 | {"1800", B1800}, 16 | {"2400", B2400}, 17 | {"4800", B4800}, 18 | {"9600", B9600}, 19 | {"exta", EXTA}, 20 | {"19200", EXTA}, 21 | {"extb", EXTB}, 22 | {"38400", EXTB} 23 | }; 24 | 25 | #define NBAUD (sizeof(baudlist)/sizeof(struct baudent)) 26 | #define NOBAUD (-1) 27 | -------------------------------------------------------------------------------- /include/bufpool.h: -------------------------------------------------------------------------------- 1 | #include "u.h" 2 | 3 | #ifndef NBPOOLS 4 | #define NBPOOLS 5 // Maximum number of pools 5 | #endif 6 | 7 | #ifndef BPMAXB 8 | #define BPMAXB 2048 // Maximum buffer length 9 | #endif 10 | 11 | #ifndef BPMINB 12 | #define BPMINB 2 // Minimum buffer length 13 | #endif 14 | 15 | #ifndef BPMAXN 16 | #define BPMAXN 100 // Maximum buffers in any pool 17 | #endif 18 | 19 | #ifdef MEMMARK 20 | extern MARKER bpmark; 21 | #endif 22 | 23 | struct bpool { // Description of a single pool 24 | size_t bpsize; // size of buffers in this pool 25 | void *bpnext; // pointer to next free buffer 26 | int bpsem; // semaphore that counts buffers 27 | }; // currently in THIS pool 28 | 29 | extern struct bpool bptab[]; // Buffer pool table 30 | extern size_t nbpools; // current number of pools 31 | -------------------------------------------------------------------------------- /include/dir.h: -------------------------------------------------------------------------------- 1 | #include "u.h" 2 | 3 | #define FDNLEN 10 // length of file name + 1 4 | #define NFDES 28 // number of files per directory 5 | 6 | struct fdes { // description of each file 7 | size_t fdlen; // length in bytes 8 | IBADDR fdiba; // first index block 9 | char fdname[FDNLEN]; // zero-terminated file name 10 | }; 11 | 12 | struct dir { // directory layout 13 | int d_iblks; // i-blocks on this disk 14 | DBADDR d_fblst; // pointer to list of free blks 15 | IBADDR d_filst; // pointer to list of free iblks 16 | int d_id; // disk identification integer 17 | int d_nfiles; // current number of files 18 | struct fdes d_files[NFDES]; // descriptions of the files 19 | }; 20 | 21 | struct freeblk { // shape of block on free list 22 | DBADDR fbnext; // address of next free block 23 | }; 24 | -------------------------------------------------------------------------------- /include/dtc.h: -------------------------------------------------------------------------------- 1 | // Data Technology Corp. DTC-11-1 disk controller host interface 2 | struct dtc { // controller interface regs. 3 | int dt_ccsr; // command completion status 4 | int dt_csr; // control and status register 5 | void *dt_dar; // data address register 6 | struct xbdcb *dt_car; // command address register 7 | int dt_xdar; // extension of dar (not used) 8 | int dt_xcar; // extension of car (not used) 9 | }; 10 | 11 | // bits in the dtc csr register 12 | #define DTGO 0000001 // "go" bit - start interface 13 | #define DTRESET 0000002 // "force reset" bit 14 | #define DTINTR 0000100 // enable interface interrupt 15 | #define DTDONE 0000200 // command done 16 | #define DTERROR 0100000 // some error occurred 17 | -------------------------------------------------------------------------------- /include/file.h: -------------------------------------------------------------------------------- 1 | #define FLREAD 0x01 // file mode bit for "read" 2 | #define FLWRITE 0x02 // file mode bit for "write" 3 | #define FLRW 0x03 // file mode bits for read+write 4 | #define FLNEW 0x08 // file mode bit for "new file" 5 | #define FLOLD 0x10 // file mode bit for "old file" 6 | 7 | // Definition of characters in the mode argument to open 8 | #define FLOMODE 'o' // Old => file exists 9 | #define FLNMODE 'n' // New => file does not exist 10 | #define FLRMODE 'r' // Read => open read-only 11 | #define FLWMODE 'w' // Write=> open for writing 12 | 13 | // Universal file control functions (additional args in parentheses) 14 | #define FLREMOVE 3001 // remove file (name) 15 | #define FLACCESS 3002 // test access (name, mode) 16 | #define FLRENAME 3003 // change file name (old, new) 17 | -------------------------------------------------------------------------------- /include/hosts.h: -------------------------------------------------------------------------------- 1 | // Symbolic names and IP addresses for local hosts at Purdue 2 | // This file is useful for writing test programs, but not 3 | // strictly necessary. 4 | 5 | #define MERLIN 128,10,2,3 // vax780 - Where the magic happens 6 | #define ARTHUR 128,10,2,1 // vax8600 - The King at Purdue CS 7 | #define MORDRED 128,10,2,2 // vax780 - Another mainstay in CS dept 8 | #define GWEN 128,10,2,8 // vax785 - The Xinu project VAX 9 | #define LUCAS 128,10,2,20 // sun170 - The TILDE file server 10 | #define LANCELOT 128,10,2,23 // sun160C - Comer's office machine 11 | #define XINU 128,10,2,30 // lsi11/23- Xinu test machine 12 | #define KNIGHT1 128,10,2,31 // lsi11/23- Student Xinu machine 13 | -------------------------------------------------------------------------------- /include/iblock.h: -------------------------------------------------------------------------------- 1 | #ifndef IBLOCK_H__ 2 | #define IBLOCK_H__ 3 | 4 | typedef int IBADDR; // iblocks addressed 0,1,2,... 5 | 6 | #define IBLEN 29 // # d-block ptrs in an i-block 7 | #define IBNULL -1 // null pointer in i-block list 8 | #define IBAREA 1 // start if iblocks on disk 9 | #define IBWDIR TRUE // ibnew: write directory 10 | #define IBNWDIR FALSE // ibnew: don't write directory 11 | 12 | struct iblk { // index block layout 13 | long ib_byte; // first data byte indexed by 14 | // this index block 15 | IBADDR ib_next; // address of next i-block 16 | DBADDR ib_dba[IBLEN]; // ptrs to data blocks indexed 17 | }; 18 | 19 | #define ibtodb(ib) (((ib)>>3)+IBAREA) // iblock to disk block addr. 20 | #define ibdisp(ib) (((ib)&07)*sizeof(struct iblk)) 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /include/io.h: -------------------------------------------------------------------------------- 1 | #ifdef NDEVS 2 | #define isbaddev(f) ((f) < 0 || (f) >= NDEVS) 3 | #endif 4 | #define BADDEV -1 5 | 6 | // In-line I/O procedures 7 | #define getchar() getc(CONSOLE) 8 | #define putchar(ch) putc(CONSOLE, (ch)) 9 | #define fgetc(unit) getc((unit)) 10 | #define fputc(unit, ch) putc((unit), (ch)) 11 | 12 | extern void *intrargs[]; 13 | -------------------------------------------------------------------------------- /include/kernel.h: -------------------------------------------------------------------------------- 1 | #include "u.h" 2 | 3 | extern int rdyhead, rdytail; 4 | extern volatile int preempt; 5 | 6 | #include "fns.h" 7 | 8 | int atoi(const char *s); 9 | int fprintf(int dev, const char *fmt, ...); 10 | int printf(const char *fmt, ...); 11 | int write(int descrp, const void *buff, int count); 12 | -------------------------------------------------------------------------------- /include/mark.h: -------------------------------------------------------------------------------- 1 | #ifndef MAXMARK 2 | #define MAXMARK 20 // maximum number of marked locations 3 | #endif 4 | 5 | extern int *(marks[]); 6 | extern int nmarks; 7 | extern int mkmutex; 8 | 9 | // by declaring it to be an array, the 10 | // name provides an address so forgotten 11 | // &'s don't become a problem 12 | typedef int MARKER[1]; 13 | 14 | #define unmarked(L) (L[0]<0 || L[0]>=nmarks || marks[L[0]]!=L) 15 | #define marked(L) !unmarked(L) 16 | -------------------------------------------------------------------------------- /include/math.h: -------------------------------------------------------------------------------- 1 | extern double fabs(), floor(), ceil(), fmod(), ldexp(), 2 | sqrt(), hypot(), atof(), 3 | sin(), cos(), tan(), asin(), acos(), atan(), atan2(), 4 | exp(), log(), log10(), pow(), 5 | sinh(), cosh(), tanh(), gamma(), j0(), j1(), jn(), y0(), y1(), yn(); 6 | 7 | #define HUGE 1.701411733192644270e38 8 | #define LOGHUGE 39 9 | -------------------------------------------------------------------------------- /include/mc68k/machine.h: -------------------------------------------------------------------------------- 1 | #define NVECTORS 256 2 | #define VECTORS 0 3 | -------------------------------------------------------------------------------- /include/mc68k/pagsiz.h: -------------------------------------------------------------------------------- 1 | #define NBPG 512 2 | #define PGOFSET 511 3 | #define CLSIZE 2 4 | #define CLOFSET 1023 5 | #define BSIZE 1024 6 | #define BMASK 1023 7 | #define BSHIFT 10 8 | #define PAGSIZ (NBPG*CLSIZE) 9 | #define PAGRND ((PAGSIZ)-1) 10 | -------------------------------------------------------------------------------- /include/mc68k/u.h: -------------------------------------------------------------------------------- 1 | // MC68000-specific types. 2 | typedef unsigned short uword; 3 | typedef short int16; 4 | typedef unsigned short uint16; 5 | -------------------------------------------------------------------------------- /include/network.h: -------------------------------------------------------------------------------- 1 | // All includes needed for the network 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | // Declarations data conversion and checksum routines 16 | #define hs2net(X) (X) 17 | #define net2hs(X) (X) 18 | #define hl2net(X) (X) 19 | #define net2hl(X) (X) 20 | extern uint16 cksum(void *p, size_t nwords); // 1s comp of 16-bit 2s comp sum 21 | -------------------------------------------------------------------------------- /include/q.h: -------------------------------------------------------------------------------- 1 | // q structure declarations, constants, and inline procedures 2 | #ifndef NQENT 3 | #define NQENT NPROC + NSEM + NSEM + 4 // for ready & sleep 4 | #endif 5 | 6 | // One for each process plus two for each list. 7 | struct qent { 8 | int qkey; // key on which the queue is ordered 9 | int qnext; // pointer to next process or tail 10 | int qprev; // pointer to previous process or head 11 | }; 12 | 13 | extern struct qent q[]; 14 | extern int nextqueue; 15 | 16 | // inline list manipulation procedures 17 | #define isempty(list) (q[(list)].qnext >= NPROC) 18 | #define nonempty(list) (q[(list)].qnext < NPROC) 19 | #define firstkey(list) (q[q[(list)].qnext].qkey) 20 | #define lastkey(tail) (q[q[(tail)].qprev].qkey) 21 | #define firstid(list) (q[(list)].qnext) 22 | 23 | #define EMPTY -1 // equivalent of null pointer 24 | -------------------------------------------------------------------------------- /include/sem.h: -------------------------------------------------------------------------------- 1 | #ifndef NSEM 2 | #define NSEM 35 // number of semaphores, if not defined 3 | #endif 4 | 5 | #define SFREE '\01' // this semaphore is free 6 | #define SUSED '\02' // this semaphore is used 7 | 8 | struct sentry { // semaphore table entry 9 | char sstate; // the state SFREE or SUSED 10 | short semcnt; // count for this semaphore 11 | short sqhead; // q index of head of list 12 | short sqtail; // q index of tail of list 13 | }; 14 | extern struct sentry semaph[]; 15 | extern int nextsem; 16 | 17 | #define isbadsem(s) (s<0 || s>=NSEM) 18 | -------------------------------------------------------------------------------- /include/sleep.h: -------------------------------------------------------------------------------- 1 | #define CVECTOR 0x100 // location of clock interrupt vector 2 | 3 | extern volatile int hasclock; // 1 iff clock exists; 0 otherwise 4 | // Set at system startup. 5 | extern volatile int clockq; // q index of sleeping process list 6 | extern volatile int count6; // used to ignore 5 of 6 interrupts 7 | extern volatile int count10; // used to ignore 9 of 10 ticks 8 | extern volatile long clktime; // current time in secs since 1/1/70 9 | extern volatile int clmutex; // mutual exclusion sem. for clock 10 | extern volatile int *sltop; // address of first key on clockq 11 | extern volatile int slnempty; // 1 iff clockq is nonempty 12 | 13 | extern volatile int deferclock; // >0 iff clock interrupts are deferred 14 | extern volatile int clkdiff; // number of clock ticks deferred 15 | -------------------------------------------------------------------------------- /include/stdarg.h: -------------------------------------------------------------------------------- 1 | typedef char *va_list; 2 | #define va_start(list, start) \ 3 | (list) = (char *) \ 4 | ((sizeof(start) < sizeof(int)) \ 5 | ? ((const int *)&(start) + 1) \ 6 | : (const int *)(&(start) + 1)) 7 | #define va_arg(list, typ) \ 8 | (sizeof(typ) < sizeof(int) \ 9 | ? ((list) += sizeof(int), (typ)((const int *)(list))[-1]) \ 10 | : ((list) += sizeof(typ), (typ)((const typ *)(list))[-1])) 11 | #define va_end(list) ((list) += 0) 12 | -------------------------------------------------------------------------------- /include/stddef.h: -------------------------------------------------------------------------------- 1 | #ifndef STDDEF_H__ 2 | #define STDDEF_H__ 3 | 4 | typedef unsigned long size_t; 5 | typedef int intptr_t; 6 | typedef unsigned int uintptr_t; 7 | 8 | #define NULL 0 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /include/string.h: -------------------------------------------------------------------------------- 1 | void *memchr(const void *p, int v, size_t size); 2 | int memcmp(const void *a, const void *b, size_t size); 3 | void *memcpy(void *dst, const void *src, size_t size); 4 | void *memset(void *dst, int c, size_t size); 5 | void *memmove(void *dst, const void *src, size_t size); 6 | int sprintf(char *dst, const char *fmt, ...); 7 | char *strcat(char *dst, const char *src); 8 | int strcmp(const char *s1, const char *s2); 9 | char *strcpy(char *dst, const char *src); 10 | size_t strlcat(char *dst, const char *src, size_t size); 11 | size_t strlen(const char *s); 12 | size_t strlcpy(char *dst, const char *src, size_t size); 13 | char *strncat(char *s1, const char *s2, size_t size); 14 | int strncmp(const char *s1, const char *s2, size_t size); 15 | char *strncpy(char *s1, const char *s2, size_t size); 16 | -------------------------------------------------------------------------------- /lib/standalone/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dancrossnyc/xinu68k/5e55d31122c01a394f2234dcd3be53b7030d34d3/lib/standalone/.gitignore -------------------------------------------------------------------------------- /lib/storage/README: -------------------------------------------------------------------------------- 1 | This is the Xinu working directory. Sample output from commands is 2 | found in subdirectory "output". 3 | 4 | --DEC 5 | -------------------------------------------------------------------------------- /lib/storage/output/date: -------------------------------------------------------------------------------- 1 | Jul 9 1986 14:24:16 2 | -------------------------------------------------------------------------------- /lib/storage/output/dg: -------------------------------------------------------------------------------- 1 | Dev= 3: lport= 513, fport= 0, mode=002, xport=29 addr=192.5.48.3 2 | Dev= 4: lport= 7, fport= 0, mode=001, xport=28 addr=0.0.0.0 3 | Dev= 5: lport=2051, fport=2001, mode=042, xport=27 addr=192.5.48.3 4 | -------------------------------------------------------------------------------- /lib/storage/output/echo: -------------------------------------------------------------------------------- 1 | a bbb c 2 | -------------------------------------------------------------------------------- /lib/storage/output/help: -------------------------------------------------------------------------------- 1 | Commands are: 2 | bpool echo netstat sleep 3 | cat exit ps snap 4 | close help reboot time 5 | cp kill rf unmount 6 | create logout rls uptime 7 | date mem rm who 8 | devs mount routes ? 9 | dg mv ruptime 10 | -------------------------------------------------------------------------------- /lib/storage/output/mem: -------------------------------------------------------------------------------- 1 | Memory: 57343 bytes real memory, 36082 text, 4738 data, 5944 bss 2 | initially: 10579 avail 3 | presently: 1052 avail, 2684 stack, 6843 heap 4 | free list: 5 | block at 150070, length 1052 (02034) 6 | -------------------------------------------------------------------------------- /lib/storage/output/mount: -------------------------------------------------------------------------------- 1 | "Xinu/" -> (RFILSYS ) "/usr/Xinu/" 2 | "h/" -> (NAMESPACE) "Xinu/src/sys/h/" 3 | "kernel/" -> (NAMESPACE) "Xinu/src/sys/sys/" 4 | "core11" -> (NAMESPACE) "kernel/core11" 5 | "a.out" -> (NAMESPACE) "kernel/a.out" 6 | "/dev/console" -> (CONSOLE ) "" 7 | "/dev/null" -> (RFILSYS ) "/dev/null" 8 | "/dev/" -> (SYSERR ) "" 9 | "/" -> (RFILSYS ) "/" 10 | "~/" -> (NAMESPACE) "Xinu/" 11 | "" -> (NAMESPACE) "Xinu/storage/" 12 | -------------------------------------------------------------------------------- /lib/storage/output/netstat: -------------------------------------------------------------------------------- 1 | bpool=0, mutex/cnt=27/1, nxt prt=2052, addr valid 2 | Packets: recvd=694, tossed=30 (0 for overrun) 3 | 0. uport= 513, pid= -1, xprt=29, size=-1 4 | 1. uport= 7, pid= -1, xprt=28, size=-1 5 | 2. uport=2051, pid= -1, xprt=27, size= 0 6 | -------------------------------------------------------------------------------- /lib/storage/output/ps: -------------------------------------------------------------------------------- 1 | pid name state prio stack range stack length sem message 2 | --- -------- ----- ---- ------------- ------------ --- ------- 3 | 0 prnull ready 0 157320-157777 62 / 304 - - 4 | 3 ps curr 20 152124-153027 308 / 452 - - 5 | 4 UDPecho wait 30 153030-153623 118 / 380 10 - 6 | 5 rwhod sleep 20 153624-154277 80 / 300 - - 7 | 6 rwho-in wait 20 154300-154753 130 / 300 14 - 8 | 7 netout wait 99 154754-155573 80 / 400 5 - 9 | 8 netin susp 100 155574-156333 90 / 352 - - 10 | 9 main recv 20 156334-157317 96 / 500 - - 11 | -------------------------------------------------------------------------------- /lib/storage/output/rf: -------------------------------------------------------------------------------- 1 | Remote files: server on dev=4, server mutex=22 2 | 8. name=/dev/null , pos= 0, mode=021, sem=23 3 | 9. name=/usr/Xinu/storage/output/rf, pos= 108, mode=002, sem=21 4 | -------------------------------------------------------------------------------- /lib/storage/output/routes: -------------------------------------------------------------------------------- 1 | Routing cache: size=6, next=5 2 | 0. Route=D, Dev= 1 IPaddr=128.010.002.075, Ether addr=0800.1100.834a 3 | 1. Route=D, Dev= 1 IPaddr=128.010.002.009, Ether addr=aa00.0301.1483 4 | 2. Route=D, Dev= 1 IPaddr=128.010.002.003, Ether addr=0800.2b02.2618 5 | 3. Route=D, Dev= 1 IPaddr=128.010.002.002, Ether addr=0207.0100.27ba 6 | 4. Route=D, Dev= 1 IPaddr=128.010.002.007, Ether addr=aa00.0301.27c0 7 | 5. Route=D, Dev= 1 IPaddr=128.010.002.071, Ether addr=0800.1100.82fa 8 | -------------------------------------------------------------------------------- /lib/storage/output/ruptime: -------------------------------------------------------------------------------- 1 | xinu up 3:13 1 users, load 0.00, 0.00, 0.00 2 | cypress1 up 8:23 2 users, load 0.10, 0.09, 0.08 3 | gareth down 1:00 4 | gawain up 1 + 10:09 3 users, load 0.13, 0.00, 0.00 5 | merlin up 9 + 0:58 10 users, load 0.37, 0.78, 0.94 6 | lucas up 20 + 15:27 1 users, load 0.00, 0.08, 0.00 7 | bedivere up 7 + 19:20 8 users, load 0.26, 0.12, 0.01 8 | blays up 4 + 7:24 5 users, load 4.12, 4.85, 5.26 9 | mordred up 16 + 11:10 29 users, load 2.17, 2.30, 1.92 10 | arthur up 4 + 6:08 28 users, load 1.32, 1.41, 1.42 11 | gwen up 12 + 11:11 10 users, load 1.73, 1.58, 1.59 12 | lancelot up 14 + 5:23 4 users, load 1.54, 1.32, 1.28 13 | -------------------------------------------------------------------------------- /lib/storage/output/who: -------------------------------------------------------------------------------- 1 | xinu!dec Console : Jul 9 1986 13:41:47 2 | -------------------------------------------------------------------------------- /libxc/abs.c: -------------------------------------------------------------------------------- 1 | int 2 | abs(int arg) 3 | { 4 | 5 | if (arg < 0) 6 | arg = -arg; 7 | return (arg); 8 | } 9 | -------------------------------------------------------------------------------- /libxc/atoi.c: -------------------------------------------------------------------------------- 1 | int 2 | atoi(char *p) 3 | { 4 | int n; 5 | int f; 6 | 7 | n = 0; 8 | f = 0; 9 | for (;; p++) { 10 | switch (*p) { 11 | case ' ': 12 | case '\t': 13 | continue; 14 | case '-': 15 | f++; 16 | case '+': 17 | p++; 18 | } 19 | break; 20 | } 21 | while (*p >= '0' && *p <= '9') 22 | n = n * 10 + *p++ - '0'; 23 | return (f ? -n : n); 24 | } 25 | -------------------------------------------------------------------------------- /libxc/atol.c: -------------------------------------------------------------------------------- 1 | long 2 | atol(char *p) 3 | { 4 | long n; 5 | int f; 6 | 7 | n = 0; 8 | f = 0; 9 | for (;; p++) { 10 | switch (*p) { 11 | case ' ': 12 | case '\t': 13 | continue; 14 | case '-': 15 | f++; 16 | case '+': 17 | p++; 18 | } 19 | break; 20 | } 21 | while (*p >= '0' && *p <= '9') 22 | n = n * 10 + *p++ - '0'; 23 | return (f ? -n : n); 24 | } 25 | -------------------------------------------------------------------------------- /libxc/ctype_.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | char _ctype_[] = { 4 | 0, 5 | _C, _C, _C, _C, _C, _C, _C, _C, 6 | _C, _S, _S, _S, _S, _S, _C, _C, 7 | _C, _C, _C, _C, _C, _C, _C, _C, 8 | _C, _C, _C, _C, _C, _C, _C, _C, 9 | _S, _P, _P, _P, _P, _P, _P, _P, 10 | _P, _P, _P, _P, _P, _P, _P, _P, 11 | _N, _N, _N, _N, _N, _N, _N, _N, 12 | _N, _N, _P, _P, _P, _P, _P, _P, 13 | _P, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U, 14 | _U, _U, _U, _U, _U, _U, _U, _U, 15 | _U, _U, _U, _U, _U, _U, _U, _U, 16 | _U, _U, _U, _P, _P, _P, _P, _P, 17 | _P, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L, 18 | _L, _L, _L, _L, _L, _L, _L, _L, 19 | _L, _L, _L, _L, _L, _L, _L, _L, 20 | _L, _L, _L, _P, _P, _P, _P, _C 21 | }; 22 | -------------------------------------------------------------------------------- /libxc/fgets.c: -------------------------------------------------------------------------------- 1 | // fgets.c - fgets 2 | 3 | #define NULL 0 4 | 5 | //------------------------------------------------------------------------ 6 | // fgets -- read a newline-terminated string from device (file) dev 7 | //------------------------------------------------------------------------ 8 | char * 9 | fgets(int dev, char *s, int n) 10 | { 11 | int c; 12 | char *cs; 13 | int getc(int); 14 | 15 | cs = s; 16 | c = -1; 17 | while (--n > 0 && (c = getc(dev)) >= 0) { 18 | *cs++ = c; 19 | if (c == '\n') 20 | break; 21 | } 22 | if (c < 0 && cs == s) 23 | return (NULL); 24 | *cs++ = '\0'; 25 | 26 | return (s); 27 | } 28 | -------------------------------------------------------------------------------- /libxc/fprintf.c: -------------------------------------------------------------------------------- 1 | // fprintf.c - fprintf 2 | 3 | #include 4 | 5 | extern void _doprnt(const char *fmt, va_list args, int (*func)(int, int), int farg); 6 | extern int putc(int, int); 7 | 8 | #define OK 1 9 | 10 | //------------------------------------------------------------------------ 11 | // fprintf -- print a formatted message on specified device (file) 12 | //------------------------------------------------------------------------ 13 | int 14 | fprintf(int dev, const char *fmt, ...) 15 | { 16 | va_list args; 17 | 18 | va_start(args, fmt); 19 | _doprnt(fmt, args, putc, dev); 20 | va_end(args); 21 | 22 | return OK; 23 | } 24 | -------------------------------------------------------------------------------- /libxc/fputs.c: -------------------------------------------------------------------------------- 1 | // fputs.c - fputs 2 | 3 | //------------------------------------------------------------------------ 4 | // fputs -- write a null-terminated string to a device (file) 5 | //------------------------------------------------------------------------ 6 | int 7 | fputs(int dev, char *s) 8 | { 9 | int r; 10 | int c; 11 | int putc(int, int); 12 | 13 | r = 0; 14 | while ((c = *s++) != '\0') 15 | r = putc(dev, c); 16 | 17 | return r; 18 | } 19 | -------------------------------------------------------------------------------- /libxc/memchr.c: -------------------------------------------------------------------------------- 1 | // ISO C. 2 | 3 | #include 4 | #include 5 | 6 | void * 7 | memchr(const void *p, int v, size_t len) 8 | { 9 | const char *b = (const char *)p; 10 | 11 | while (len > 0) { 12 | if (*b == v) { 13 | return (void *)b; 14 | } 15 | len--; 16 | b++; 17 | } 18 | 19 | return NULL; 20 | } 21 | -------------------------------------------------------------------------------- /libxc/memcmp.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int 5 | memcmp(const void *a, const void *b, size_t len) 6 | { 7 | const char *aa = (const char *)a; 8 | const char *bb = (const char *)b; 9 | 10 | while (len-- > 0) { 11 | if (*aa < *bb) 12 | return -1; 13 | if (*aa > *bb) 14 | return 1; 15 | aa++; 16 | bb++; 17 | } 18 | 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /libxc/memcpy.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void * 5 | memcpy(void *dst, const void *src, size_t len) 6 | { 7 | return memmove(dst, src, len); 8 | } 9 | -------------------------------------------------------------------------------- /libxc/memmove.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void * 5 | memmove(void *dst, const void *src, size_t len) 6 | { 7 | char *d, *s; 8 | 9 | d = (char *)dst; 10 | s = (char *)src; 11 | if (d < s) 12 | while (len-- > 0) 13 | *d++ = *s++; 14 | else { 15 | d += len; 16 | s += len; 17 | while (len-- > 0) 18 | *--d = *--s; 19 | } 20 | 21 | return dst; 22 | } 23 | -------------------------------------------------------------------------------- /libxc/memset.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void * 5 | memset(void *dst, int c, size_t len) 6 | { 7 | unsigned char *p = (unsigned char *)p; 8 | unsigned char v = c; 9 | 10 | while (len-- > 0) { 11 | *p++ = v; 12 | } 13 | 14 | return dst; 15 | } 16 | -------------------------------------------------------------------------------- /libxc/printf.c: -------------------------------------------------------------------------------- 1 | // printf.c - printf 2 | 3 | #include 4 | 5 | extern void _doprnt(const char *fmt, va_list args, int (*func)(int, int), int farg); 6 | extern int putc(int, int); 7 | 8 | #define OK 1 9 | #define CONSOLE 0 10 | 11 | //------------------------------------------------------------------------ 12 | // printf -- write formatted output on CONSOLE 13 | //------------------------------------------------------------------------ 14 | int 15 | printf(const char *fmt, ...) 16 | { 17 | va_list args; 18 | 19 | va_start(args, fmt); 20 | _doprnt(fmt, args, putc, CONSOLE); 21 | va_end(args); 22 | 23 | return OK; 24 | } 25 | -------------------------------------------------------------------------------- /libxc/puts.c: -------------------------------------------------------------------------------- 1 | // puts.c - puts 2 | 3 | #define CONSOLE 0 4 | 5 | //------------------------------------------------------------------------ 6 | // puts -- write a null-terminated string to the console 7 | //------------------------------------------------------------------------ 8 | int 9 | puts(char *s) 10 | { 11 | int c; 12 | int putc(int, int); 13 | 14 | while ((c = *s++) != '\0') 15 | putc(CONSOLE, c); 16 | 17 | return putc(CONSOLE, '\n'); 18 | } 19 | -------------------------------------------------------------------------------- /libxc/rand.c: -------------------------------------------------------------------------------- 1 | static long randx = 1; 2 | 3 | void 4 | srand(unsigned x) 5 | { 6 | randx = x; 7 | } 8 | 9 | int 10 | rand(void) 11 | { 12 | return (((randx = randx * 1103515245 + 12345) >> 16) & 0x7FFF); 13 | } 14 | -------------------------------------------------------------------------------- /libxc/strcat.c: -------------------------------------------------------------------------------- 1 | // Concatenate s2 on the end of s1. S1's space must be large enough. 2 | // Return s1. 3 | 4 | #include 5 | #include 6 | 7 | char * 8 | strcat(char *s1, const char *s2) 9 | { 10 | char *os1; 11 | 12 | os1 = s1; 13 | while ((*s1++) != '\0') 14 | ; 15 | --s1; 16 | while ((*s1++ = *s2++) != '\0') 17 | ; 18 | 19 | return os1; 20 | } 21 | -------------------------------------------------------------------------------- /libxc/strchr.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | char * 5 | strchr(const char *s, int c) 6 | { 7 | 8 | char *p = (char *)s; 9 | 10 | do { 11 | if (*p == c) 12 | return p; 13 | } while (*p++ != '\0'); 14 | 15 | return NULL; 16 | } 17 | -------------------------------------------------------------------------------- /libxc/strcmp.c: -------------------------------------------------------------------------------- 1 | // Compare strings: s1>s2: >0 s1==s2: 0 s1 4 | #include 5 | 6 | int 7 | strcmp(const char *s1, const char *s2) 8 | { 9 | 10 | while (*s1 == *s2++) 11 | if (*s1++ == '\0') 12 | return 0; 13 | return (*s1 < *--s2) ? -1 : 1; 14 | } 15 | -------------------------------------------------------------------------------- /libxc/strcpy.c: -------------------------------------------------------------------------------- 1 | // Copy string s2 to s1. s1 must be large enough. 2 | // return s1 3 | 4 | #include 5 | #include 6 | 7 | char * 8 | strcpy(char *s1, const char *s2) 9 | { 10 | char *os1; 11 | 12 | os1 = s1; 13 | while ((*s1++ = *s2++) != '\0') 14 | ; 15 | 16 | return os1; 17 | } 18 | -------------------------------------------------------------------------------- /libxc/strlcat.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Inspired by the version in several other variants of Unix. 3 | */ 4 | #include 5 | #include 6 | 7 | size_t 8 | strlcat(char *dst, const char *src, size_t size) 9 | { 10 | char *p; 11 | size_t len; 12 | 13 | p = memchr(dst, '\0', size); 14 | if (p == NULL) 15 | p = dst + size; 16 | len = p - dst; 17 | return(len + strlcpy(p, src, size - len)); 18 | } 19 | -------------------------------------------------------------------------------- /libxc/strlcpy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Inspired by Todd what's his name's version in OpenBSD. 3 | */ 4 | #include 5 | #include 6 | 7 | size_t 8 | strlcpy(char *dst, const char *src, size_t size) 9 | { 10 | size_t len, srclen; 11 | 12 | /* 13 | * Get the length of the source first, test for the 14 | * pathological case, then cat as much as we can. 15 | */ 16 | srclen = strlen(src); 17 | if (size-- <= 0) 18 | return(srclen); 19 | len = (size < srclen) ? size : srclen; 20 | memmove(dst, src, len); 21 | dst[len] = '\0'; 22 | 23 | return(srclen); 24 | } 25 | -------------------------------------------------------------------------------- /libxc/strlen.c: -------------------------------------------------------------------------------- 1 | // Returns the number of 2 | // non-NULL bytes in string argument. 3 | 4 | #include 5 | #include 6 | 7 | size_t 8 | strlen(const char *s) 9 | { 10 | size_t n; 11 | 12 | n = 0; 13 | while (*s++) 14 | n++; 15 | 16 | return n; 17 | } 18 | -------------------------------------------------------------------------------- /libxc/strncat.c: -------------------------------------------------------------------------------- 1 | // Concatenate s2 on the end of s1. S1's space must be large enough. 2 | // At most n characters are moved. 3 | // Return s1. 4 | 5 | #include 6 | #include 7 | 8 | char * 9 | strncat(char *s1, const char *s2, size_t n) 10 | { 11 | char *os1; 12 | 13 | os1 = s1; 14 | while ((*s1++) != '\0') 15 | ; 16 | --s1; 17 | while ((*s1++ = *s2++) != '\0') 18 | if (n-- == 0) { 19 | *--s1 = '\0'; 20 | break; 21 | } 22 | 23 | return os1; 24 | } 25 | -------------------------------------------------------------------------------- /libxc/strncmp.c: -------------------------------------------------------------------------------- 1 | // Compare strings (at most n bytes): s1>s2: >0 s1==s2: 0 s1 4 | #include 5 | 6 | int 7 | strncmp(const char *s1, const char *s2, size_t n) 8 | { 9 | 10 | while (n-- > 0 && *s1 == *s2++) 11 | if (*s1++ == '\0') 12 | return (0); 13 | return (n == 0) ? 0 : (*s1 < *--s2 ? -1 : 1); 14 | } 15 | -------------------------------------------------------------------------------- /libxc/strncpy.c: -------------------------------------------------------------------------------- 1 | // Copy s2 to s1, truncating or null-padding to always copy n bytes 2 | // return s1 3 | 4 | #include 5 | #include 6 | 7 | char * 8 | strncpy(char *s1, const char *s2, size_t n) 9 | { 10 | size_t i; 11 | char *os1; 12 | 13 | os1 = s1; 14 | for (i = 0; i < n; i++) 15 | if ((*s1++ = *s2++) == '\0') { 16 | while (++i < n) 17 | *s1++ = '\0'; 18 | return os1; 19 | } 20 | 21 | return os1; 22 | } 23 | -------------------------------------------------------------------------------- /libxc/strrchr.c: -------------------------------------------------------------------------------- 1 | // Return the ptr in sp at which the character c last 2 | // appears; NULL if not found 3 | 4 | #define NULL 0 5 | 6 | char * 7 | rindex(char *sp, int c) 8 | { 9 | char *r; 10 | 11 | r = NULL; 12 | do { 13 | if (*sp == c) 14 | r = sp; 15 | } while (*sp++); 16 | return (r); 17 | } 18 | -------------------------------------------------------------------------------- /libxc/swab.c: -------------------------------------------------------------------------------- 1 | // Swap bytes in 16-bit [half-]words 2 | // for going between the 11 and the interdata 3 | 4 | void 5 | swab(short *pf, short *pt, int n) 6 | { 7 | 8 | n /= 2; 9 | while (--n >= 0) { 10 | *pt++ = (*pf << 8) + ((*pf >> 8) & 0xFF); 11 | pf++; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /man/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Make All Xinu Manual Pages 3 | # 4 | 5 | all: 6 | @echo making all manual pages in man[01234] 7 | cd man0;make;cd .. 8 | cd man1;make;cd .. 9 | cd man2;make;cd .. 10 | cd man3;make;cd .. 11 | cd man4;make;cd .. 12 | 13 | install: 14 | @echo type "\`make print'" to make and print the entire manual 15 | 16 | clean: 17 | rm -rf *.doc core ,* 18 | cd man0;make clean;cd .. 19 | cd man1;make clean;cd .. 20 | cd man2;make clean;cd .. 21 | cd man3;make clean;cd .. 22 | cd man4;make clean;cd .. 23 | 24 | print: manual 25 | 26 | listings: manual 27 | 28 | manual: all 29 | cat man0/*.doc man1/*.doc man2/*.doc \ 30 | man3/*.doc man4/*.doc \ 31 | sed '1,2d;s/^/ /' | lpr 32 | -------------------------------------------------------------------------------- /man/man1/Intro1.1: -------------------------------------------------------------------------------- 1 | .ds Sh "Cross-Development Commands 2 | .ds Sa "Section 1 3 | .bp 4 | .tm ==== .Sc "" "\*(Sh" \n% 5 | .ds Sn "INTRO(\|1\|) 6 | .ds Sf "Xinu Programmer's Manual 7 | .in 0i 8 | .sp 8 9 | .ps +4 10 | .B 11 | .ce 12 | Section 1: Cross-Development Commands 13 | .IX commands "cross-development" 14 | .sp 3 15 | .ps 10 16 | .PP 17 | This section of the manual describes the program 18 | development commands that run on the host computer. 19 | They are used to prepare programs for execution 20 | under Xinu, transfer the memory image into the 21 | micro, and monitor execution. 22 | None of these programs (e.g., the C compiler) executes 23 | on the micro itself. 24 | -------------------------------------------------------------------------------- /man/man1/lusers.1: -------------------------------------------------------------------------------- 1 | .TH LUSERS 1 2 | .SH NAME 3 | lusers \- list users holding odt lock reservations 4 | .SH SYNOPSIS 5 | .B lusers 6 | .SH DESCRIPTION 7 | .I Lusers 8 | lists the users who hold reservations on tty lines. 9 | Each line of output contains the machine name and number, the user 10 | who holds it, and the idle time, rounded to the nearest minute. 11 | Reservations are made by \f2odt\f1(1), \f2download\f1(1), 12 | and \f2upload\f1(1). 13 | .SH FILES 14 | /tmp/LSI-* Lock files. 15 | .SH "SEE ALSO" 16 | odtunlock(1), odt(1) 17 | .SH BUGS 18 | \f2Lusers\f1 lists reservations and idle time based on lock 19 | file times which may not be quite accurate. 20 | Machines with more than 10 minutes of idle time are listed even though 21 | the reservation software considers the reservation to have 22 | expired. 23 | -------------------------------------------------------------------------------- /man/man1/size11.1: -------------------------------------------------------------------------------- 1 | .TH SIZE11 1 2 | .SH NAME 3 | size11 \- size of an 11 object file 4 | .SH SYNOPSIS 5 | .B size11 6 | [ objectfile ... ] 7 | .SH DESCRIPTION 8 | .I Size11 9 | prints the (decimal) number of bytes 10 | required by the 11 | text, data, and bss 12 | portions, and their sum in hex and decimal, 13 | of each object-file argument. 14 | If no file is specified, 15 | .B a.out 16 | is used. 17 | .SH "SEE ALSO" 18 | ld11(1) 19 | -------------------------------------------------------------------------------- /man/man1/strip11.1: -------------------------------------------------------------------------------- 1 | .TH STRIP11 1 2 | .SH NAME 3 | strip11 \- remove symbols and relocation bits from 11 object file 4 | .SH SYNOPSIS 5 | .B strip11 6 | name ... 7 | .SH DESCRIPTION 8 | .I Strip11 9 | removes the symbol 10 | table and relocation bits ordinarily attached to the output 11 | of the assembler and loader. 12 | This is useful to save space after a program has been 13 | debugged. 14 | .PP 15 | The effect of 16 | .I strip11 17 | is the same as use of the 18 | .B \-s 19 | option 20 | of 21 | .IR ld11 . 22 | .SH FILES 23 | /tmp/stm? temporary file 24 | .SH "SEE ALSO" 25 | ld11(1) 26 | -------------------------------------------------------------------------------- /man/man2/access.2: -------------------------------------------------------------------------------- 1 | .TH ACCESS 2 2 | .SH NAME 3 | access \- determine whether a file is accessible 4 | .SH SYNOPSIS 5 | .B int access(filename, mode) 6 | .br 7 | .B char *filename; 8 | .br 9 | .B char *mode; 10 | .fi 11 | .SH DESCRIPTION 12 | .I Access 13 | examines file with name \f2filename\f1 to determine if it is 14 | accessible according to the modes specified in the mode string 15 | \f2mode\f1. 16 | Valid characters in the mode string are \f3r\f1 (check for read access) 17 | \f3w\f1 (check for write access), \f3n\f1 (check to see if a new file can 18 | be created), and \f3o\f1 (check to see if file exists). 19 | If neither \f3r\f1 nor \f3w\f1 is specified, both are assumed. 20 | .SH SEE ALSO 21 | open(2), ckmode(3) 22 | -------------------------------------------------------------------------------- /man/man2/close.2: -------------------------------------------------------------------------------- 1 | .TH CLOSE 2 2 | .SH NAME 3 | close \- device independent close routine 4 | .SH SYNOPSIS 5 | .B int 6 | .B close(dev) 7 | .nf 8 | .B int dev; 9 | .fi 10 | .SH DESCRIPTION 11 | .I Close 12 | will disconnect I/O from the device given by 13 | .I dev. 14 | It returns SYSERR if 15 | .I dev 16 | is incorrect, or is not opened for I/O. 17 | Otherwise, 18 | .I close 19 | returns OK. 20 | .PP 21 | Normally tty devices like the console do not have to be opened and 22 | closed. 23 | .SH SEE ALSO 24 | control(2), getc(2), open(2), putc(2), read(2), seek(2), write(2) 25 | -------------------------------------------------------------------------------- /man/man2/freebuf.2: -------------------------------------------------------------------------------- 1 | .TH FREEBUF 2 2 | .SH NAME 3 | freebuf \- free a buffer by returning it to its buffer pool 4 | .SH SYNOPSIS 5 | .nf 6 | .B int freebuf(buf) 7 | .B char *buf; 8 | .fi 9 | .SH DESCRIPTION 10 | .I Freebuf 11 | returns a previously allocated buffer to its buffer pool, making it 12 | available for other processes to use. 13 | .I Freebuf 14 | returns SYSERR if the buffer address is invalid or if the pool 15 | id has been corrupted (this version stores pool ids in the integer 16 | preceding the buffer address). 17 | .SH SEE ALSO 18 | getbuf(2), mkpool(2), getmem(2), freemem(2) 19 | -------------------------------------------------------------------------------- /man/man2/getaddr.2: -------------------------------------------------------------------------------- 1 | .TH GETADDR 2 2 | .SH NAME 3 | getaddr \- obtain the local machine's Internet (IP) address 4 | .SH SYNOPSIS 5 | .nf 6 | .B int getaddr(ip) 7 | .B IPaddr ip; 8 | .fi 9 | .SH DESCRIPTION 10 | .I Getaddr 11 | obtains the local machine's primary Internet (IP) address and places 12 | it in the 4-byte array specified by argument \f2ip\f1. 13 | Calling \f2getaddr\f1 may trigger a Reverse Address Resolution Protocol 14 | (RARP) broadcast to find the address. 15 | If RARP succeeds, the address is kept locally for successive lookup 16 | requests. 17 | If RARP fails, \f2getaddr\f1 calls \f2panic\f1 to halt processing. 18 | .SH SEE ALSO 19 | getname(2), getnet(2) 20 | .SH BUGS 21 | There is no provision to obtain multiple addresses for machines that 22 | connect to multiple networks. 23 | -------------------------------------------------------------------------------- /man/man2/getbuf.2: -------------------------------------------------------------------------------- 1 | .TH BUFFER 3 2 | .SH NAME 3 | getbuf \- obtain a buffer from a buffer pool 4 | .SH SYNOPSIS 5 | .nf 6 | .B char *getbuf(poolid) 7 | .B int poolid; 8 | .fi 9 | .SH DESCRIPTION 10 | .I Getbuf 11 | obtains a free buffer from the pool given by argument 12 | .I poolid, 13 | and returns a pointer to the first word of the buffer. 14 | If all buffers in the specified pool are in use, the 15 | calling process will be blocked until a buffer becomes 16 | available. 17 | If the argument 18 | .I poolid 19 | does not specify a valid pool, 20 | getbuf returns SYSERR. 21 | .SH SEE ALSO 22 | freebuf(2), getmem(2), getstk(2), freemem(2), freestk(2) 23 | -------------------------------------------------------------------------------- /man/man2/getc.2: -------------------------------------------------------------------------------- 1 | .TH GETC 2 2 | .SH NAME 3 | getc \- device independent character input routine 4 | .SH SYNOPSIS 5 | .B int 6 | .B getc(dev) 7 | .nf 8 | .B int dev; 9 | .fi 10 | .SH DESCRIPTION 11 | .I Getc 12 | will read the next character from the I/O device given by 13 | .I dev. 14 | It returns SYSERR if 15 | .I dev 16 | is incorrect. 17 | A successful call may return a 18 | character (widened to an integer) or the value EOF to denote end of 19 | file, depending on the device driver. 20 | .SH SEE ALSO 21 | close(2), control(2), open(2), putc(2), read(2), seek(2), write(2) 22 | .SH BUGS 23 | Not all devices report the end-of-file condition. 24 | -------------------------------------------------------------------------------- /man/man2/getnet.2: -------------------------------------------------------------------------------- 1 | .TH GETNET 2 2 | .SH NAME 3 | getnet \- obtain the Internet (IP) address of local machine's network 4 | .SH SYNOPSIS 5 | .nf 6 | .B int getnet(ip) 7 | .B IPaddr ip; 8 | .fi 9 | .SH DESCRIPTION 10 | .I Getnet 11 | obtains the Internet (IP) address of the local machine's 12 | primary network, and stores 13 | it in the 4-byte array specified by argument \f2ip\f1. 14 | Calling \f2getnet\f1 may trigger a Reverse Address Resolution Protocol 15 | (RARP) broadcast to find the address. 16 | If RARP succeeds, the address is kept locally for successive lookup 17 | requests. 18 | If RARP fails, \f2getnet\f1 calls \f2panic\f1 to halt processing. 19 | .SH SEE ALSO 20 | getaddr(2), getname(2), getnet(2) 21 | .SH BUGS 22 | There is no provision to obtain multiple addresses for machines that 23 | connect to multiple networks. 24 | -------------------------------------------------------------------------------- /man/man2/getpid.2: -------------------------------------------------------------------------------- 1 | .TH GETPID 2 2 | .SH NAME 3 | getpid \- return the process id of the currently running process 4 | .SH SYNOPSIS 5 | .B int 6 | .B getpid() 7 | .fi 8 | .SH DESCRIPTION 9 | .I Getpid 10 | returns the process id of the currently executing process. 11 | It is necessary to be able to identify one's self in order to 12 | perform some operations (e.g., change one's scheduling priority). 13 | -------------------------------------------------------------------------------- /man/man2/getprio.2: -------------------------------------------------------------------------------- 1 | .TH GETPRIO 2 2 | .SH NAME 3 | getprio \- return the scheduling priority of a given process 4 | .SH SYNOPSIS 5 | .B int 6 | .B getprio(pid) 7 | .nf 8 | .B int pid; 9 | .fi 10 | .SH DESCRIPTION 11 | .I Getprio 12 | returns the scheduling priority of process 13 | .I pid. 14 | If pid is invalid, 15 | .I getprio 16 | returns SYSERR. 17 | -------------------------------------------------------------------------------- /man/man2/getprio.doc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | GETPRIO(2) Xinu Programmer's Manual GETPRIO(2) 5 | 6 | 7 | 8 | NAME 9 | getprio - return the scheduling priority of a given process 10 | 11 | SYNOPSIS 12 | int getprio(pid) 13 | int pid; 14 | 15 | DESCRIPTION 16 | _G_e_t_p_r_i_o returns the scheduling priority of process _p_i_d. If 17 | pid is invalid, _g_e_t_p_r_i_o returns SYSERR. 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | Version 6b Printed 1/12/87 1 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /man/man2/mkpool.2: -------------------------------------------------------------------------------- 1 | .TH MKPOOL 2 2 | .SH NAME 3 | mkpool \- create a buffer pool 4 | .SH SYNOPSIS 5 | .nf 6 | .B int mkpool(bufsiz, numbufs) 7 | .B int bufsiz; 8 | .B int numbufs; 9 | .fi 10 | .SH DESCRIPTION 11 | .I Mkpool 12 | creates a pool of 13 | .I numbufs 14 | buffers, each of size 15 | .I bufsiz, 16 | and returns an integer identifying the pool. 17 | If no more pools can be created, or if the arguments are incorrect, 18 | .I mkpool 19 | returns SYSERR. 20 | .SH SEE ALSO 21 | getbuf(2), freebuf(2), poolinit(2) 22 | .SH BUGS 23 | At present there is no way to reclaim space from buffer pools once 24 | they are no longer needed. 25 | -------------------------------------------------------------------------------- /man/man2/pcreate.2: -------------------------------------------------------------------------------- 1 | .TH PCREATE 2 2 | .SH NAME 3 | pcreate \- create a new port 4 | .SH SYNOPSIS 5 | .B int 6 | .B pcreate(count) 7 | .br 8 | .B int count; 9 | .SH DESCRIPTION 10 | .I Pcreate 11 | creates a port with 12 | .I count 13 | locations for storing message pointers. 14 | .PP 15 | .I Pcreate 16 | returns an integer identifying the port if 17 | successful. If no more ports can be allocated, 18 | or if 19 | .I count 20 | is nonpositive, 21 | .I pcreate 22 | returns 23 | SYSERR. 24 | .PP 25 | Ports are manipulated with 26 | PSEND(2) and PRECEIVE(2). 27 | Receiving from a port returns a pointer to a message that was previously 28 | sent to the port. 29 | .SH SEE ALSO 30 | pcount(2), pdelete(2), preceive(2), preset(2), psend(2) 31 | -------------------------------------------------------------------------------- /man/man2/pinit.2: -------------------------------------------------------------------------------- 1 | .TH PINIT 2 2 | .SH NAME 3 | pinit \- initialize the ports table at system startup 4 | .SH SYNOPSIS 5 | .nf 6 | .B int pinit(maxmsgs) 7 | .B int maxmsgs; 8 | .fi 9 | .SH DESCRIPTION 10 | .I Pinit 11 | initializes the ports mechanism by clearing the ports table and 12 | allocating memory for messages. 13 | It should be called only once (usually at system startup). 14 | Argument \f2maxmsgs\f1 specifies an upper bound on the number 15 | of simultaneously outstanding messages at all ports. 16 | .SH SEE ALSO 17 | pcreate(2), pdelete(2), psend(2), preceive(2) 18 | -------------------------------------------------------------------------------- /man/man2/psend.2: -------------------------------------------------------------------------------- 1 | .TH PSEND 2 2 | .SH NAME 3 | psend \- send a message to a port 4 | .SH SYNOPSIS 5 | .nf 6 | .B int psend(portid, message) 7 | .B int portid; 8 | .B char *message; 9 | .fi 10 | .SH DESCRIPTION 11 | .I Psend 12 | adds the pointer 13 | .I message 14 | to the port 15 | .I portid. 16 | If successful, 17 | .I psend 18 | returns OK; it returns SYSERR if 19 | .I portid 20 | is invalid. 21 | Note that only a pointer, not the entire message, is enqueued, 22 | and that psend may return to the caller before the receiver 23 | has consumed the message. 24 | .PP 25 | If the port is full at the time of the call, the sending process will be 26 | blocked until space is available in the port for the message. 27 | .SH SEE ALSO 28 | pcount(2), pcreate(2), pdelete(2), preceive(2), preset(2) 29 | -------------------------------------------------------------------------------- /man/man2/putc.2: -------------------------------------------------------------------------------- 1 | .TH PUTC 2 2 | .SH NAME 3 | putc \- device independent character output routine 4 | .SH SYNOPSIS 5 | .nf 6 | .B int putc(dev, ch) 7 | .B int dev; 8 | .B char ch; 9 | .fi 10 | .SH DESCRIPTION 11 | .I Putc 12 | will write the character 13 | .I ch 14 | on the I/O device given by 15 | .I dev. 16 | It returns SYSERR if 17 | .I dev 18 | is incorrect, OK otherwise. 19 | .PP 20 | By convention, 21 | .I printf 22 | calls 23 | .I putc 24 | on device CONSOLE to write formatted output. 25 | Usually CONSOLE is device zero. 26 | .SH SEE ALSO 27 | close(2), control(2), getc(2), open(2), read(2), seek(2), write(2) 28 | -------------------------------------------------------------------------------- /man/man2/read.2: -------------------------------------------------------------------------------- 1 | .TH READ 2 2 | .SH NAME 3 | read \- device independent input routine 4 | .SH SYNOPSIS 5 | .nf 6 | .B int read(dev, buffer, numchars) 7 | .B int dev; 8 | .B char *buffer; 9 | .B int numchars; 10 | .fi 11 | .SH DESCRIPTION 12 | .I Read 13 | will read up to 14 | .I numchars 15 | bytes from the I/O device given by 16 | .I dev. 17 | It returns SYSERR if 18 | .I dev 19 | is incorrect. 20 | It returns the number of characters read if successful. 21 | The number of bytes actually returned depends on the device. 22 | For example, when reading from a device of type "tty", each read 23 | normally returns one line. 24 | For a disk, however, each read returns one block and the argument 25 | \f2numchars\f1 is taken to be the index of the disk block desired. 26 | .SH SEE ALSO 27 | close(2), control(2), getc(2), open(2), putc(2), seek(2), write(2) 28 | -------------------------------------------------------------------------------- /man/man2/receive.2: -------------------------------------------------------------------------------- 1 | .TH RECEIVE 2 2 | .SH NAME 3 | receive \- receive a (one-word) message 4 | .SH SYNOPSIS 5 | .nf 6 | .B int receive() 7 | .fi 8 | .SH DESCRIPTION 9 | .I Receive 10 | returns the one-word 11 | message sent to a process using SEND(2). 12 | If no messages are waiting, 13 | .I receive 14 | blocks until one appears. 15 | .SH SEE ALSO 16 | preceive(2), psend(2), receive(2) 17 | -------------------------------------------------------------------------------- /man/man2/receive.doc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | RECEIVE(2) Xinu Programmer's Manual RECEIVE(2) 5 | 6 | 7 | 8 | NAME 9 | receive - receive a (one-word) message 10 | 11 | SYNOPSIS 12 | int receive() 13 | 14 | DESCRIPTION 15 | _R_e_c_e_i_v_e returns the one-word message sent to a process using 16 | SEND(2). If no messages are waiting, _r_e_c_e_i_v_e blocks until 17 | one appears. 18 | 19 | SEE ALSO 20 | preceive(2), psend(2), receive(2) 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | Version 6b Printed 1/12/87 1 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /man/man2/recvclr.2: -------------------------------------------------------------------------------- 1 | .TH RECVCLR 2 2 | .SH NAME 3 | recvclr \- clear incoming message buffer asynchronously 4 | .SH SYNOPSIS 5 | .nf 6 | .B int recvclr() 7 | .fi 8 | .SH DESCRIPTION 9 | A process executes \f2recvclr\f1 to clear its message buffer of 10 | any waiting message in preparation for receiving messages. 11 | If a message is waiting, \f2recvclr\f1 returns it to the caller. 12 | If no messages are waiting, 13 | .I recvclr 14 | returns OK. 15 | .SH SEE ALSO 16 | receive(2), send(2), preceive(2), psend(2) 17 | -------------------------------------------------------------------------------- /man/man2/resume.2: -------------------------------------------------------------------------------- 1 | .TH RESUME 2 2 | .SH NAME 3 | resume \- resume a suspended process 4 | .SH SYNOPSIS 5 | .nf 6 | .B int resume(pid) 7 | .B int pid; 8 | .fi 9 | .SH DESCRIPTION 10 | .I Resume 11 | takes process 12 | .I pid 13 | out of hibernation and allows it to resume execution. 14 | If 15 | .I pid 16 | is invalid or process 17 | .I pid 18 | is not suspended, 19 | .I resume 20 | returns SYSERR; otherwise it returns the priority at which 21 | the process resumed execution. 22 | Only suspended processes may be resumed. 23 | .SH SEE ALSO 24 | sleep(2), suspend(2), send(2), receive(2) 25 | -------------------------------------------------------------------------------- /man/man2/scount.2: -------------------------------------------------------------------------------- 1 | .TH SCOUNT 2 2 | .SH NAME 3 | scount \- return the count associated with a semaphore 4 | .SH SYNOPSIS 5 | .nf 6 | .B int scount(sem) 7 | .B int sem; 8 | .fi 9 | .SH DESCRIPTION 10 | .I Scount 11 | returns the current count associated with semaphore 12 | .I sem. 13 | A count of negative p means that there are p processes waiting 14 | on the semaphore; a count of positive p means that at most p more 15 | calls to WAIT(2) can occur before a process will be blocked (assuming 16 | no intervening sends occur). 17 | .SH SEE ALSO 18 | screate(2), sdelete(2), signal(2), sreset(2), wait(2) 19 | .SH BUGS 20 | In this version, there is no way to distinguish SYSERR 21 | from a legal semaphore count of \-1. 22 | -------------------------------------------------------------------------------- /man/man2/sdelete.2: -------------------------------------------------------------------------------- 1 | .TH SDELETE 2 2 | .SH NAME 3 | sdelete \- delete a semaphore 4 | .SH SYNOPSIS 5 | .nf 6 | .B int sdelete(sem) 7 | .B int sem; 8 | .fi 9 | .SH DESCRIPTION 10 | .I Sdelete 11 | removes semaphore 12 | .I sem 13 | from the system and returns processes that were waiting for it 14 | to the ready state. 15 | The call returns SYSERR if 16 | .I sem 17 | is not a legal semaphore; 18 | it returns OK if the deletion was successful. 19 | .SH SEE ALSO 20 | scount(2), screate(2), signal(2), sreset(2), wait(2) 21 | -------------------------------------------------------------------------------- /man/man2/seek.2: -------------------------------------------------------------------------------- 1 | .TH SEEK 2 2 | .SH NAME 3 | seek \- device independent position seeking routine 4 | .SH SYNOPSIS 5 | .nf 6 | .B int seek(dev, position) 7 | .B int dev; 8 | .B char *buffer; 9 | .B long position; 10 | .fi 11 | .SH DESCRIPTION 12 | .I Seek 13 | will position the device given by 14 | .I dev 15 | after the 16 | .I position 17 | byte. 18 | It returns SYSERR if 19 | .I dev 20 | is incorrect, or if it is not possible to position 21 | .I dev 22 | as specified. 23 | .PP 24 | .I Seek 25 | cannot be used with devices connected to terminals. 26 | .PP 27 | Note that the position argument is declared 28 | .I long 29 | rather than 30 | .I int. 31 | .SH SEE ALSO 32 | close(2), control(2), getc(2), open(2), putc(2), read(2), write(2) 33 | -------------------------------------------------------------------------------- /man/man2/send.2: -------------------------------------------------------------------------------- 1 | .TH SEND 2 2 | .SH NAME 3 | send \- send a (one-word) message to a process 4 | .SH SYNOPSIS 5 | .nf 6 | .B int send(pid, msg) 7 | .B int pid; 8 | .B int msg; 9 | .fi 10 | .SH DESCRIPTION 11 | .I Send 12 | sends the one-word message 13 | .I msg 14 | to the process with id 15 | .I pid. 16 | A process may have at most one outstanding message that has 17 | not been received. 18 | .PP 19 | .I Send 20 | returns SYSERR if 21 | .I pid 22 | is invalid or if the process already has a message waiting 23 | that has not been received. 24 | Otherwise, it sends the message and returns OK. 25 | .SH SEE ALSO 26 | receive(2), sendf(2), preceive(2), psend(2) 27 | -------------------------------------------------------------------------------- /man/man2/sendf.2: -------------------------------------------------------------------------------- 1 | .TH SENDF 2 2 | .SH NAME 3 | sendf \- send a (one-word) message to a process, forcing delivery 4 | .SH SYNOPSIS 5 | .nf 6 | .B int sendf(pid, msg) 7 | .B int pid; 8 | .B int msg; 9 | .fi 10 | .SH DESCRIPTION 11 | .I Sendf 12 | sends the one-word message 13 | .I msg 14 | to the process with id 15 | .I pid. 16 | A process may have at most one outstanding message that has 17 | not been received. 18 | .I Sendf 19 | returns SYSERR if process id \f2pid\f1 is 20 | invalid. 21 | Otherwise, it returns OK. 22 | .SH SEE ALSO 23 | receive(2), recvtim(2), recvclr(2), preceive(2), psend(2) 24 | -------------------------------------------------------------------------------- /man/man2/setdev.2: -------------------------------------------------------------------------------- 1 | .TH SETDEV 2 2 | .SH NAME 3 | setdev \- set the standard input and output device ids for a process 4 | .SH SYNOPSIS 5 | .nf 6 | .B int setdev(pid, dev1, dev2) 7 | .B int pid; 8 | .B int dev1; 9 | .B int dev2; 10 | .fi 11 | .SH DESCRIPTION 12 | .I Setdev 13 | records the device ids \f2dev1\f1 and \f2dev2\f1 in the process table 14 | entry for process \f2pid\f1 so the system will 15 | automatically close the devices when the process exits. 16 | It is used primarily by the shell to record the process' standard 17 | input and standard output device ids. 18 | .SH SEE ALSO 19 | close(2), kill(2) 20 | .SH BUGS 21 | The limit of two device ids per process is fixed, and 22 | both must be set in a single call. 23 | -------------------------------------------------------------------------------- /man/man2/signal.2: -------------------------------------------------------------------------------- 1 | .TH SIGNAL 2 2 | .SH NAME 3 | signal, signaln \- signal a semaphore 4 | .SH SYNOPSIS 5 | .nf 6 | .B int signal(sem) 7 | .B int signaln(sem, count) 8 | .B int sem; 9 | .B int count; 10 | .fi 11 | .SH DESCRIPTION 12 | In either form, 13 | .I signal 14 | signals semaphore 15 | .I sem 16 | and returns SYSERR if the semaphore does not exist, OK otherwise. 17 | The form 18 | .I signal 19 | increments the count of 20 | .I sem 21 | by 1 and frees the next process if any 22 | are waiting. 23 | The form 24 | .I signaln 25 | increments the semaphore by 26 | .I count 27 | and frees up to 28 | .I count 29 | processes if that many are waiting. 30 | Note that \f2signaln\f1(sem, x) is equivalent to 31 | executing \f2signal\f1(sem) x times. 32 | .SH SEE ALSO 33 | scount(2), screate(2), sdelete(2), sreset(2), wait(2) 34 | -------------------------------------------------------------------------------- /man/man2/sreset.2: -------------------------------------------------------------------------------- 1 | .TH SRESET 2 2 | .SH NAME 3 | sreset \- reset semaphore count 4 | .SH SYNOPSIS 5 | .nf 6 | .B int sreset(sem,count) 7 | .B int sem; 8 | .B int count; 9 | .fi 10 | .SH DESCRIPTION 11 | .I Sreset 12 | frees processes in the queue for semaphore 13 | .I sem, 14 | and resets its count to 15 | .I count. 16 | This corresponds to the operations of sdelete(sem) and 17 | sem=screate(count), except that it guarantees that the 18 | semaphore id 19 | .I sem 20 | does not change. 21 | .I Sreset 22 | returns SYSERR if 23 | .I sem 24 | is not a valid semaphore id. 25 | The current count in a semaphore does not affect 26 | resetting it. 27 | .SH SEE ALSO 28 | scount(2), screate(2), sdelete(2), signal(2), wait(2) 29 | -------------------------------------------------------------------------------- /man/man2/unmount.2: -------------------------------------------------------------------------------- 1 | .TH UNMOUNT 2 2 | .SH NAME 3 | unmount \- remove an entry from the syntactic namespace mapping table 4 | .SH SYNOPSIS 5 | .nf 6 | .B int unmount(prefix) 7 | .B char *prefix; 8 | .fi 9 | .SH DESCRIPTION 10 | .I Unmount 11 | searches the syntactic namespace mapping table and removes 12 | the mapping which has a prefix equal to the null-terminated 13 | string \f2prefix\f1. 14 | If no such entry exists, \f2unmount\f1 returns SYSERR. 15 | Otherwise, it returns OK. 16 | .SH SEE ALSO 17 | mount(2), namespace(4) 18 | -------------------------------------------------------------------------------- /man/man2/unsleep.2: -------------------------------------------------------------------------------- 1 | .TH UNSLEEP 2 2 | .SH NAME 3 | unsleep \- remove a sleeping process from the clock queue prematurely 4 | .SH SYNOPSIS 5 | .nf 6 | .B int unsleep(pid) 7 | .B int pid; 8 | .fi 9 | .SH DESCRIPTION 10 | .I Unsleep 11 | allow one process to take another out of the sleeping state before 12 | the time limit has expired. 13 | usually, only system routines like RECVTIM(2) and KILL(2) call 14 | \f2unsleep\f1. 15 | User-level processes can avoid using \f2unsleep\f1 by arranging 16 | processes to cooperate using message passing primitives. 17 | .SH SEE ALSO 18 | sleep(2), kill(2), recvtim(2) 19 | -------------------------------------------------------------------------------- /man/man2/wait.2: -------------------------------------------------------------------------------- 1 | .TH WAIT 2 2 | .SH NAME 3 | wait \- block and wait until semaphore signalled 4 | .SH SYNOPSIS 5 | .nf 6 | .B int wait(sem) 7 | .B int sem; 8 | .fi 9 | .SH DESCRIPTION 10 | .I Wait 11 | decrements the count of semaphore 12 | .I sem, 13 | blocking the calling process if the count goes negative 14 | by enqueuing it in the queue for 15 | .I sem. 16 | The only ways to get free from a semaphore queue are for 17 | some other process to signal the semaphore, or 18 | for some other process to delete or reset the semaphore. 19 | .I Wait 20 | and SIGNAL(2) are the two basic synchronization primitives in 21 | the system. 22 | .PP 23 | .I Wait 24 | returns SYSERR if 25 | .I sem 26 | is invalid. 27 | Otherwise, it returns OK once freed from the queue. 28 | .SH SEE ALSO 29 | scount(2), screate(2), sdelete(2), signal(2), sreset(2) 30 | -------------------------------------------------------------------------------- /man/man3/Intro3.3: -------------------------------------------------------------------------------- 1 | .ds Sh "Library Procedures 2 | .ds Sa "Section 3 3 | .bp 4 | .tm ==== .Sc "" "\*(Sh" \n% 5 | .ds Sn "INTRO(\|3\|) 6 | .ds Sf "Xinu Programmer's Manual 7 | .in 0i 8 | .sp 8 9 | .ps +4 10 | .B 11 | .ce 12 | Section 3: Library Procedures 13 | .SX "Xinu" "library" 14 | .IX "system library" 15 | .IX "library" 16 | .sp 3 17 | .ps 10 18 | .PP 19 | This section of the manual describes the procedure 20 | (functions) available to programs from the standard 21 | libraries. 22 | C programmers will recognize some of the C-library functions 23 | (esp., those that manipulate strings). 24 | Be careful: not all procedure arguments are like those in UNIX. 25 | -------------------------------------------------------------------------------- /man/man3/TEMPL: -------------------------------------------------------------------------------- 1 | .TH XXX 3 2 | .SH NAME 3 | xxx \- descr. of xxx 4 | .SH SYNOPSIS 5 | .B #include 6 | .PP 7 | .B int xxx(x,y) 8 | .br 9 | .B int x; 10 | .B int y; 11 | .br 12 | .SH DESCRIPTION 13 | .I Xxx 14 | does neat things. 15 | .SH "SEE ALSO" 16 | zzz(2) 17 | .SH SEE ALSO 18 | .SH DIAGNOSTICS 19 | -------------------------------------------------------------------------------- /man/man3/blkcopy.3: -------------------------------------------------------------------------------- 1 | .TH BLKCOPY 3 2 | .SH NAME 3 | blkcopy \- copy a contiguous block of bytes 4 | .SH SYNOPSIS 5 | .nf 6 | .B int blkcopy(to, from, nbytes) 7 | .B char *to; 8 | .B char *from; 9 | .B int nbytes; 10 | .SH DESCRIPTION 11 | .I Blkcopy 12 | copies a block of \f2nbytes\f1 contiguous bytes starting at 13 | location \f2from\f1 into the area starting at location \f2to\f1. 14 | \f2Blkcopy\f1 returns \f2OK\f1 to the caller. 15 | \f2Blkcopy\f1 will copy any byte value including the null character (zero). 16 | .SH "SEE ALSO" 17 | blkequ(3), string(3) 18 | .SH BUGS 19 | \f2Blkcopy\f1 does not check for valid memory addresses. 20 | -------------------------------------------------------------------------------- /man/man3/blkequ.3: -------------------------------------------------------------------------------- 1 | .TH BLKEQU 3 2 | .SH NAME 3 | blkequ \- compare two contiguous blocks of memory for equality 4 | .SH SYNOPSIS 5 | .B Bool blkequ(first, second, nbytes) 6 | .br 7 | .B char *first; 8 | .br 9 | .B char *second; 10 | .br 11 | .B int nbytes; 12 | .br 13 | .SH DESCRIPTION 14 | .I Blkequ 15 | compares two blocks of memory for equality. 16 | Each block contains exactly \f2nbytes\f1 bytes. 17 | \f2Blkequ\f1 returns FALSE if the two blocks differ, and 18 | TRUE if the blocks are equal. 19 | \f2Blkequ\f1 compares all byte values including null (zero). 20 | .SH "SEE ALSO" 21 | blkcopy(3), string(3) 22 | .SH BUGS 23 | \f2Blkequ\f1 does not check for valid memory addresses. 24 | -------------------------------------------------------------------------------- /man/man3/disable.3: -------------------------------------------------------------------------------- 1 | .TH DISABLE 3 2 | .SH NAME 3 | disable, enable, restore \- change and restore processor interrupt status 4 | .SH SYNOPSIS 5 | .B disable(ps); 6 | .br 7 | .B enable(ps); 8 | .br 9 | .B restore(ps); 10 | .PP 11 | .B char ps; 12 | .br 13 | .SH DESCRIPTION 14 | These routines change the processor interrupt status mode. 15 | Normally, procedures use 16 | .I disable 17 | and 18 | .I restore 19 | to save the interrupt status, mask interrupts off, and then restore 20 | the saved status. 21 | \f2Enable\f1 explicitly enables interrupts; it is used only at system 22 | startup. 23 | .SH SEE ALSO 24 | cvt(1) 25 | .SH BUGS 26 | In this implementation, \f2disable\f1 and \f2restore\f1 are macros 27 | that must have local variable \f2ps\f1 as an argument, and must use 28 | CVT(1) to convert the assembler code they produce to legal assembler. 29 | -------------------------------------------------------------------------------- /man/man3/dot2ip.3: -------------------------------------------------------------------------------- 1 | .TH DOT2IP 3 2 | .SH NAME 3 | dot2ip \- convert dotted decimal notation to an IP address 4 | .SH SYNOPSIS 5 | .nf 6 | .B int dot2ip(ip, b1, b2, b3, b4) 7 | .B IPaddr ip; 8 | .B int b1; 9 | .B int b2; 10 | .B int b3; 11 | .B int b4; 12 | .br 13 | .SH DESCRIPTION 14 | Procedure 15 | .I dot2ip 16 | converts an Internet (IP) address from dotted decimal notation 17 | to its 32-bit integer form and stores it in argument \f2ip\f1. 18 | Each of the arguments \f2b1\f1, \f2b2\f1, \f2b3\f1, 19 | and \f2b4\f1, gives the value of one byte of the internet 20 | address. 21 | -------------------------------------------------------------------------------- /man/man3/fgetc.3: -------------------------------------------------------------------------------- 1 | .TH FGETC 3 2 | .SH NAME 3 | fgetc, getchar \- get character from a device 4 | .SH SYNOPSIS 5 | .B #include 6 | .PP 7 | .B int fgetc(dev) 8 | .br 9 | .B int 10 | .B dev; 11 | .PP 12 | .B int getchar() 13 | .SH DESCRIPTION 14 | These procedures are included for compatibility with \s-2UNIX\s0. 15 | .I Fgetc 16 | returns the next character from the named input 17 | .IR device . 18 | .PP 19 | .I Getchar() 20 | is identical to 21 | .IR getc(CONSOLE) . 22 | .PP 23 | Note that 24 | .I fgetc 25 | is exactly equivalent to 26 | .I getc. 27 | .SH "SEE ALSO" 28 | getc(2), putc(2), gets(3), scanf(3), 29 | .SH DIAGNOSTICS 30 | These functions return SYSERR to indicate an illegal device 31 | or read error. 32 | -------------------------------------------------------------------------------- /man/man3/fputc.3: -------------------------------------------------------------------------------- 1 | .TH FPUTC 3 2 | .SH NAME 3 | fputc, putchar \- put character to a device 4 | .SH SYNOPSIS 5 | .B #include 6 | .PP 7 | .B int fputc(device, c) 8 | .br 9 | .B int device; 10 | .br 11 | .B char c; 12 | .br 13 | .B putchar(c) 14 | .SH DESCRIPTION 15 | These procedures are included for compatibility with \s-2UNIX\s0. 16 | .I Fputc 17 | appends the character 18 | .I c 19 | to the named output 20 | .IR device , 21 | and returns SYSERR if device is invalid; it is defined to be 22 | .I "putc(device, c)." 23 | .PP 24 | .I Putchar(c) 25 | is also defined to be 26 | .I "putc(CONSOLE, c)." 27 | .SH "SEE ALSO" 28 | putc(2), puts(3), printf(3) 29 | -------------------------------------------------------------------------------- /man/man3/netnum.3: -------------------------------------------------------------------------------- 1 | .TH NETNUM 3 2 | .SH NAME 3 | netnum \- compute the network portion of a given Internet (IP) address 4 | .SH SYNOPSIS 5 | .B #include 6 | .PP 7 | .B int netnum(netpart, address) 8 | .br 9 | .B IPaddr netpart; 10 | .br 11 | .B IPaddr address; 12 | .br 13 | .SH DESCRIPTION 14 | .I Netnum 15 | extracts the network portion of the Internet address specified by 16 | argument \f2address\f1, and places the result in argument \f2netpart\f1. 17 | It operates by using the IP class of argument \f2address\f1 18 | to determine whether the 19 | network part of the address occupies 1, 2, or 3 bytes, and it zeros the 20 | remaining bytes. 21 | \f2Netnum\f1 always returns OK. 22 | .SH "SEE ALSO" 23 | getaddr(2), getnet(2) 24 | .SH BUGS 25 | .I Netnum 26 | does not understand subnets or subnet masks. 27 | -------------------------------------------------------------------------------- /man/man3/puts.3: -------------------------------------------------------------------------------- 1 | .TH PUTS 3 2 | .SH NAME 3 | puts, fputs \- write a string to a device 4 | .SH SYNOPSIS 5 | .B puts(s) 6 | .br 7 | .B char *s; 8 | .PP 9 | .B fputs(dev, s) 10 | .br 11 | .B int dev; 12 | .br 13 | .B char *s; 14 | .SH DESCRIPTION 15 | .I Puts 16 | writes the null-terminated string 17 | .I s 18 | on the output device CONSOLE and appends a newline character. 19 | .PP 20 | .I Fputs 21 | writes the null-terminated string 22 | .I s 23 | on device 24 | .IR dev . 25 | .PP 26 | Neither routine writes the terminal null character. 27 | They return SYSERR if \f2dev\f1 is invalid. 28 | .SH "SEE ALSO" 29 | gets(3), putc(3), printf(3), read(2), write(2) 30 | .SH BUGS 31 | .I Puts 32 | appends a newline, 33 | .I fputs 34 | does not; there is no good reason for this. 35 | -------------------------------------------------------------------------------- /man/man3/qsort.3: -------------------------------------------------------------------------------- 1 | .TH QSORT 3 2 | .SH NAME 3 | qsort \- quicker sort 4 | .SH SYNOPSIS 5 | .nf 6 | .B qsort(base, nel, width, compar) 7 | .B char *base; 8 | .B int (*compar)(); 9 | .fi 10 | .SH DESCRIPTION 11 | .I Qsort 12 | is an implementation 13 | of the quicker-sort algorithm. 14 | The first argument is a pointer to the base of the data; 15 | the second is the number of elements; 16 | the third is the width of an element 17 | in bytes; 18 | the last is the name of the comparison routine 19 | to be called with two arguments which are pointers 20 | to the elements being compared. 21 | The routine must return 22 | an integer less than, equal to, or greater than 0 23 | according as the first argument is to be considered 24 | less than, equal to, or greater than the second. 25 | -------------------------------------------------------------------------------- /man/man3/rand.3: -------------------------------------------------------------------------------- 1 | .TH RAND 3 2 | .SH NAME 3 | rand, srand \- random number generator 4 | .SH SYNOPSIS 5 | .nf 6 | .B srand(seed) 7 | .B int seed; 8 | .PP 9 | .B rand() 10 | .fi 11 | .SH DESCRIPTION 12 | .I Rand 13 | uses a multiplicative congruential 14 | random number generator 15 | with period 2\u\s732\s0\d 16 | to return successive pseudo-random 17 | numbers in the range from 0 to 2\u\s731\s10\d\-1. 18 | .PP 19 | The generator is reinitialized by calling 20 | .I srand 21 | with 1 as argument. 22 | It can be set to a random starting point by calling 23 | .I srand 24 | with whatever you like as argument. 25 | .SH BUGS 26 | \f2Rand\f1 does not provide mutual exclusion among calling 27 | processes. 28 | Thus, there is a small chance that two concurrent 29 | processes will receive the same value. 30 | -------------------------------------------------------------------------------- /man/man3/swab.3: -------------------------------------------------------------------------------- 1 | .TH SWAB 3 2 | .SH NAME 3 | swab \- swap bytes 4 | .SH SYNOPSIS 5 | .nf 6 | .B swab(from, to, nbytes) 7 | .B char *from, *to; 8 | .fi 9 | .SH DESCRIPTION 10 | .I Swab 11 | copies 12 | .I nbytes 13 | bytes pointed to by 14 | .I from 15 | to the position pointed to by 16 | .I to, 17 | exchanging adjacent even and odd bytes. 18 | It is useful for carrying binary data between 19 | LSI 11's and other machines. 20 | .I Nbytes 21 | should be even. 22 | .SH SEE ALSO 23 | hs2net(3) hl2net(3), net2hl(3), net2hs(3) 24 | -------------------------------------------------------------------------------- /man/man4/TEMPL: -------------------------------------------------------------------------------- 1 | .TH XXX 4 2 | .SH NAME 3 | xxx \- device driver for x 4 | .SH SYNOPSIS 5 | .nf 6 | .B #include 7 | .sp 8 | .B read(device buffer, length) 9 | .B write(device, buffer, length) 10 | .B open(device, name) 11 | .B close(device) 12 | .B control(device, function, arg1, arg2) 13 | .B init(device) 14 | .B seek(device,offset) 15 | .br 16 | .SH DESCRIPTION 17 | .PP 18 | .TP 19 | .B read(device buffer, length) 20 | .sp 21 | 22 | .TP 23 | .B write(device, buffer, length) 24 | .sp 25 | 26 | .TP 27 | .B open(device, name) 28 | .sp 29 | 30 | .TP 31 | .B close(device) 32 | .sp 33 | 34 | .TP 35 | .B control(device, function, arg1, arg2) 36 | .sp 37 | 38 | .TP 39 | .B init(device) 40 | .sp 41 | 42 | .TP 43 | .B seek(device,offset) 44 | .sp 45 | 46 | .SH NOTES 47 | -------------------------------------------------------------------------------- /xinu/Mkdeps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | CC="${CC:-gcc}" 3 | dir=$1 4 | shift 5 | if [ "$dir" != "" ] 6 | then 7 | dir="$dir/" 8 | fi 9 | $CC -MM -MG "$@" | sed -e "s@\(.*\).o:@$dir\1.o $dir\1.d:@" 10 | -------------------------------------------------------------------------------- /xinu/access.c: -------------------------------------------------------------------------------- 1 | #include "kernel.h" 2 | #include "conf.h" 3 | #include "file.h" 4 | #include "name.h" 5 | 6 | //------------------------------------------------------------------------ 7 | // access - determine accessability given file name and desired mode 8 | //------------------------------------------------------------------------ 9 | SYSCALL 10 | access(char *name, int mode) 11 | { 12 | struct devsw *dp; 13 | int dev; 14 | char fullname[NAMLEN]; 15 | 16 | dev = namemap(name, fullname); 17 | if (dev == SYSERR) 18 | return SYSERR; 19 | dp = &devtab[dev]; 20 | 21 | return (*dp->ctl)(dp, FLACCESS, fullname, mode); 22 | } 23 | -------------------------------------------------------------------------------- /xinu/arpinit.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "proc.h" 4 | #include "network.h" 5 | #include "string.h" 6 | 7 | struct arpcache Arp; 8 | 9 | //------------------------------------------------------------------------ 10 | // arpinit - initialize data structures for ARP processing 11 | //------------------------------------------------------------------------ 12 | void 13 | arpinit(void) 14 | { 15 | 16 | memset(&Arp, 0, sizeof(Arp)); 17 | Arp.atabsiz = 0; 18 | Arp.atabnxt = 0; 19 | Arp.arpsem = screate(1); 20 | Arp.rarpsem = screate(1); 21 | Arp.arppid = Arp.rarppid = BADPID; 22 | for (int k = 0; k < AR_TAB; k++) { 23 | Arp.arptab[k].dev = -1; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /xinu/bpdump.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "mark.h" 4 | #include "bufpool.h" 5 | 6 | //------------------------------------------------------------------------ 7 | // bpdump - dump the buffer pool table 8 | //------------------------------------------------------------------------ 9 | int 10 | bpdump(void) 11 | { 12 | 13 | for (int k = 0; k < NBPOOLS; k++) { 14 | struct bpool *bp = &bptab[k]; 15 | kprintf("Buffer Pool %2d: buf size=%4d, " 16 | "sem=%2d, count=%d\n", 17 | k, bp->bpsize, bp->bpsem, 18 | scount(bp->bpsem)); 19 | } 20 | 21 | return OK; 22 | } 23 | -------------------------------------------------------------------------------- /xinu/bsvc.setup: -------------------------------------------------------------------------------- 1 | BSVC Simulator Setup File 2 | 3 | UI_VERSION {2.0} 4 | SIMULATOR {sim68000} 5 | COMMAND {AttachDevice 0 RAM {BaseAddress = 0 Size = 100000}} 6 | COMMAND {AttachDevice 0 M68681 {BaseAddress = 100010 OffsetToFirstRegister = 0 OffsetBetweenRegisters = 1 InterruptLevel = 5 PortAStandardInputOutputFlag = 0 PortBStandardInputOutputFlag = 0 PortACommand = xterm -T "TERMINAL A" -e xtermpipe PortBCommand = }} 7 | COMMAND {AttachDevice 0 Timer {BaseAddress = 100040 IRQ = 6}} 8 | -------------------------------------------------------------------------------- /xinu/cksum.c: -------------------------------------------------------------------------------- 1 | #include "u.h" 2 | 3 | uint16 4 | cksum(unsigned short *p, size_t words) 5 | { 6 | uint32 sum; 7 | 8 | sum = 0; 9 | for (int k = 0; k < words; k++) 10 | sum += *p++; 11 | while ((sum >> 16) != 0) 12 | sum = (sum >> 16) + (sum & 0xFFFF); 13 | 14 | return (~sum) & 0xFFFF; 15 | } 16 | -------------------------------------------------------------------------------- /xinu/close.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "io.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // close - close a device 7 | //------------------------------------------------------------------------ 8 | SYSCALL 9 | close(int descrp) 10 | { 11 | struct devsw *devptr; 12 | 13 | if (isbaddev(descrp)) 14 | return SYSERR; 15 | devptr = &devtab[descrp]; 16 | 17 | return (*devptr->close)(devptr); 18 | } 19 | -------------------------------------------------------------------------------- /xinu/control.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "io.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // control - control a device (e.g., set the mode) 7 | //------------------------------------------------------------------------ 8 | SYSCALL 9 | control(int descrp, int func, int addr) 10 | { 11 | struct devsw *dp; 12 | 13 | if (isbaddev(descrp)) 14 | return SYSERR; 15 | dp = &devtab[descrp]; 16 | 17 | return (*dp->ctl)(dp, func, addr, NULL); 18 | } 19 | -------------------------------------------------------------------------------- /xinu/devdump.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | 4 | //------------------------------------------------------------------------ 5 | // devdump - dump device names from the device switch table 6 | //------------------------------------------------------------------------ 7 | void 8 | devdump(void) 9 | { 10 | 11 | kprintf("Num Device minor CSR i-vector o-vector I/O buffer\n"); 12 | kprintf("--- -------- ----- -------- -------- -------- ----------\n"); 13 | for (int k = 0; k < NDEVS; k++) { 14 | struct devsw *dp = &devtab[k]; 15 | kprintf("%2d. %-9s %3d %08x %08x %08x\n", 16 | k, dp->name, dp->minor, 17 | dp->csr, dp->ivec, dp->iobuf); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /xinu/dfalloc.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "disk.h" 4 | #include "lfile.h" 5 | 6 | //------------------------------------------------------------------------ 7 | // dfalloc -- allocate a device table entry for a disk file; return id 8 | //------------------------------------------------------------------------ 9 | int 10 | dfalloc(void) 11 | { // assume exclusion for dir. provided by caller 12 | 13 | for (int k = 0; k < Ndf; k++) { 14 | if (fltab[k].fl_pid == 0) { 15 | fltab[k].fl_pid = getpid(); 16 | return k; 17 | } 18 | } 19 | 20 | return SYSERR; 21 | } 22 | -------------------------------------------------------------------------------- /xinu/dgalloc.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "network.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // dgalloc - allocate a datagram psuedo device and return descriptor 7 | //------------------------------------------------------------------------ 8 | int 9 | dgalloc(void) 10 | { 11 | int ps = disable(); 12 | 13 | for (int k = 0; k < Ndg; k++) { 14 | struct dgblk *dgptr = &dgtab[k]; 15 | if (dgptr->dg_state == DG_FREE) { 16 | dgptr->dg_state = DG_USED; 17 | restore(ps); 18 | return k; 19 | } 20 | } 21 | restore(ps); 22 | 23 | return SYSERR; 24 | } 25 | -------------------------------------------------------------------------------- /xinu/dgclose.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "proc.h" 4 | #include "network.h" 5 | 6 | //------------------------------------------------------------------------ 7 | // dgclose - close a datagram pseudo device, making it available again 8 | //------------------------------------------------------------------------ 9 | int 10 | dgclose(struct devsw *devptr) 11 | { 12 | int ps; 13 | struct dgblk *dgptr; 14 | struct netq *nqptr; 15 | int nq; 16 | 17 | dgptr = (struct dgblk *)devptr->iobuf; 18 | ps = disable(); 19 | nq = dgptr->dg_netq; 20 | nqptr = &Net.netqs[nq]; 21 | nqptr->valid = FALSE; 22 | nqptr->uport = -1; 23 | nqptr->pid = BADPID; 24 | dgptr->dg_state = DG_FREE; 25 | restore(ps); 26 | 27 | return OK; 28 | } 29 | -------------------------------------------------------------------------------- /xinu/dgcntl.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "network.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // dgcntl - control function for datagram pseudo-devices 7 | //------------------------------------------------------------------------ 8 | int 9 | dgcntl(struct devsw *devptr, int func, int arg) 10 | { 11 | int ps = disable(); 12 | struct dgblk *dgptr = (struct dgblk *)devptr->iobuf; 13 | 14 | switch (func) { 15 | case DG_SETMODE: // set mode bits 16 | dgptr->dg_mode = arg; 17 | break; 18 | case DG_CLEAR: // clear queued packets 19 | preset(dgptr->dg_xport, freebuf); 20 | break; 21 | default: 22 | restore(ps); 23 | return SYSERR; 24 | } 25 | restore(ps); 26 | 27 | return OK; 28 | } 29 | -------------------------------------------------------------------------------- /xinu/dginit.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "network.h" 4 | 5 | struct dgblk dgtab[Ndg]; // dg device control blocks 6 | 7 | //------------------------------------------------------------------------ 8 | // dginit - initialize datagram protocol pseudo device marking it free 9 | //------------------------------------------------------------------------ 10 | void 11 | dginit(struct devsw *devptr) 12 | { 13 | struct dgblk *dgptr; 14 | 15 | devptr->iobuf = (char *)(dgptr = &dgtab[devptr->minor]); 16 | dgptr->dg_dnum = devptr->num; 17 | dgptr->dg_state = DG_FREE; 18 | } 19 | -------------------------------------------------------------------------------- /xinu/dgmcntl.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "network.h" 4 | #include "string.h" 5 | 6 | //------------------------------------------------------------------------ 7 | // dgmcntl - control the network and datagram interface pseudo devices 8 | //------------------------------------------------------------------------ 9 | int 10 | dgmcntl(struct devsw *devptr, int func, char *addr) 11 | { 12 | 13 | switch (func) { 14 | #ifdef NETDAEMON 15 | case NC_SETGW: 16 | memmove(Net.gateway, addr, IPLEN); 17 | return OK; 18 | #endif 19 | default: 20 | break; 21 | } 22 | 23 | return SYSERR; 24 | } 25 | -------------------------------------------------------------------------------- /xinu/dot2ip.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "network.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // dot2ip - convert network address from "decimal dot" form to IPaddr 7 | //------------------------------------------------------------------------ 8 | void 9 | dot2ip(char *ip, int nad1, int nad2, int nad3, int nad4) 10 | { 11 | *ip++ = LOWBYTE & nad1; 12 | *ip++ = LOWBYTE & nad2; 13 | *ip++ = LOWBYTE & nad3; 14 | *ip++ = LOWBYTE & nad4; 15 | } 16 | -------------------------------------------------------------------------------- /xinu/dscntl.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "proc.h" 4 | #include "disk.h" 5 | 6 | //------------------------------------------------------------------------ 7 | // dscntl -- control disk driver/device 8 | //------------------------------------------------------------------------ 9 | int 10 | dscntl(struct devsw *devptr, int func) 11 | { 12 | int stat; 13 | int ps; 14 | 15 | ps = disable(); 16 | switch (func) { 17 | 18 | case DSKSYNC: 19 | stat = dsksync(devptr); 20 | break; 21 | 22 | default: 23 | stat = SYSERR; 24 | break; 25 | } 26 | restore(ps); 27 | return stat; 28 | } 29 | -------------------------------------------------------------------------------- /xinu/dskbcpy.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "disk.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // dskbcpy -- copy data into a new disk buffer and return its address 7 | //------------------------------------------------------------------------ 8 | char * 9 | dskbcpy(void *oldbuf) 10 | { 11 | int i; 12 | char *newbuf, *to, *from; 13 | 14 | from = (char *)oldbuf; 15 | newbuf = to = getbuf(dskdbp); 16 | for (i = 0; i < DBUFSIZ; i++) 17 | *to++ = *from++; 18 | return newbuf; 19 | } 20 | -------------------------------------------------------------------------------- /xinu/dsread.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "proc.h" 4 | #include "disk.h" 5 | 6 | //------------------------------------------------------------------------ 7 | // dsread -- read a block from a disk device 8 | //------------------------------------------------------------------------ 9 | int 10 | dsread(struct devsw *devptr, void *buff, DBADDR block) 11 | { 12 | struct dreq *drptr; 13 | int stat; 14 | int ps; 15 | 16 | ps = disable(); 17 | drptr = (struct dreq *)getbuf(dskrbp); 18 | drptr->drdba = block; 19 | drptr->drpid = currpid; 20 | drptr->drbuff = buff; 21 | drptr->drop = DREAD; 22 | if ((stat = dskenq(drptr, (struct dsblk *)devptr->iobuf)) == DONQ) { 23 | suspend(currpid); 24 | stat = drptr->drstat; 25 | } 26 | freebuf(drptr); 27 | restore(ps); 28 | return stat; 29 | } 30 | -------------------------------------------------------------------------------- /xinu/dsseek.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "proc.h" 4 | #include "disk.h" 5 | 6 | //------------------------------------------------------------------------ 7 | // dsseek -- schedule a request to move the disk arm 8 | //------------------------------------------------------------------------ 9 | int 10 | dsseek(struct devsw *devptr, DBADDR block) 11 | { 12 | struct dreq *drptr; 13 | int ps; 14 | 15 | ps = disable(); 16 | drptr = (struct dreq *)getbuf(dskrbp); 17 | drptr->drdba = block; 18 | drptr->drpid = currpid; 19 | drptr->drbuff = NULL; 20 | drptr->drop = DSEEK; 21 | 22 | // enqueued with normal policy like other read/write requests 23 | dskenq(drptr, (struct dsblk *)devptr->iobuf); 24 | restore(ps); 25 | return OK; 26 | } 27 | -------------------------------------------------------------------------------- /xinu/dswrite.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "proc.h" 4 | #include "disk.h" 5 | 6 | //------------------------------------------------------------------------ 7 | // dswrite -- write a block (system buffer) onto a disk device 8 | //------------------------------------------------------------------------ 9 | int 10 | dswrite(struct devsw *devptr, void *buff, DBADDR block) 11 | { 12 | struct dreq *drptr; 13 | int ps; 14 | 15 | ps = disable(); 16 | drptr = (struct dreq *)getbuf(dskrbp); 17 | drptr->drbuff = buff; 18 | drptr->drdba = block; 19 | drptr->drpid = currpid; 20 | drptr->drop = DWRITE; 21 | dskenq(drptr, (struct dsblk *)devptr->iobuf); 22 | restore(ps); 23 | return OK; 24 | } 25 | -------------------------------------------------------------------------------- /xinu/etherrstart.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "network.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // ethrstrt - start an ethernet read operation on the DEQNA 7 | //------------------------------------------------------------------------ 8 | 9 | int 10 | ethrstrt(struct etblk *etptr, char *buf, int len) 11 | { 12 | struct dcmd *dcmptr; 13 | struct dqregs *dqptr; 14 | 15 | dcmptr = etptr->ercmd; 16 | dcmptr->dc_bufh = DC_VALID; 17 | dcmptr->dc_buf = buf; 18 | dcmptr->dc_len = dqlen(len); 19 | dcmptr->dc_st1 = dcmptr->dc_st2 = DC_INIT; 20 | dcmptr->dc_flag = DC_NUSED; 21 | dqptr = etptr->eioaddr; 22 | dqptr->d_rcmd = (char *)dcmptr; 23 | dqptr->d_rcmdh = NULL; 24 | return OK; 25 | } 26 | -------------------------------------------------------------------------------- /xinu/etherwrite.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "proc.h" 4 | #include "network.h" 5 | #include "string.h" 6 | 7 | //------------------------------------------------------------------------ 8 | // ethwrite - write a single packet to the ethernet 9 | //------------------------------------------------------------------------ 10 | 11 | int 12 | ethwrite(struct devsw *devptr, char *buff, int len) 13 | { 14 | struct etblk *etptr; 15 | int ps; 16 | 17 | if (len > EMAXPAK) 18 | return SYSERR; 19 | if (len < EMINPAK) 20 | len = EMINPAK; 21 | etptr = (struct etblk *)devptr->iobuf; 22 | memmove(((struct eheader *)buff)->e_src, etptr->etpaddr, EPADLEN); 23 | ps = disable(); 24 | wait(etptr->etwsem); 25 | ethwstrt(etptr, buff, etptr->etlen = len, DC_NORM); 26 | restore(ps); 27 | return OK; 28 | } 29 | -------------------------------------------------------------------------------- /xinu/freebuf.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "mark.h" 4 | #include "bufpool.h" 5 | 6 | //------------------------------------------------------------------------ 7 | // freebuf -- free a buffer that was allocated from a pool by getbuf 8 | //------------------------------------------------------------------------ 9 | SYSCALL 10 | freebuf(void *buf) 11 | { 12 | int ps; 13 | int pool; 14 | int *bp; 15 | 16 | if (unmarked(bpmark)) 17 | return SYSERR; 18 | bp = (int *)buf; 19 | pool = *(--bp); 20 | if (pool < 0 || pool >= nbpools) 21 | return SYSERR; 22 | ps = disable(); 23 | *bp = (int)bptab[pool].bpnext; 24 | bptab[pool].bpnext = (void *)buf; 25 | restore(ps); 26 | signal(bptab[pool].bpsem); 27 | 28 | return OK; 29 | } 30 | -------------------------------------------------------------------------------- /xinu/getaddr.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "network.h" 4 | #include "string.h" 5 | 6 | //------------------------------------------------------------------------ 7 | // getaddr - obtain this system's complete address (IP address) 8 | //------------------------------------------------------------------------ 9 | SYSCALL 10 | getaddr(IPaddr address) 11 | { 12 | wait(Arp.rarpsem); 13 | if (!Net.mavalid) 14 | sndrarp(); 15 | signal(Arp.rarpsem); 16 | 17 | if (!Net.mavalid) 18 | return SYSERR; 19 | memmove(address, Net.myaddr, IPLEN); 20 | return OK; 21 | } 22 | -------------------------------------------------------------------------------- /xinu/getbuf.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "mark.h" 4 | #include "bufpool.h" 5 | 6 | //------------------------------------------------------------------------ 7 | // getbuf -- get a buffer from a preestablished buffer pool 8 | //------------------------------------------------------------------------ 9 | void * 10 | getbuf(int poolid) 11 | { 12 | int ps; 13 | int *buf; 14 | 15 | if (unmarked(bpmark)) 16 | return (void *)SYSERR; 17 | if (poolid < 0 || poolid >= nbpools) 18 | return (void *)SYSERR; 19 | wait(bptab[poolid].bpsem); 20 | ps = disable(); 21 | buf = (int *)bptab[poolid].bpnext; 22 | bptab[poolid].bpnext = (char *)(*buf); 23 | restore(ps); 24 | *buf++ = poolid; 25 | 26 | return (void *)buf; 27 | } 28 | -------------------------------------------------------------------------------- /xinu/getc.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "io.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // getc - get one character from a device 7 | //------------------------------------------------------------------------ 8 | SYSCALL 9 | getc(int descrp) 10 | { 11 | struct devsw *devptr; 12 | 13 | if (isbaddev(descrp)) 14 | return SYSERR; 15 | devptr = &devtab[descrp]; 16 | 17 | return (*devptr->getc)(devptr); 18 | } 19 | -------------------------------------------------------------------------------- /xinu/getname.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "conf.h" 5 | #include "kernel.h" 6 | #include "network.h" 7 | 8 | //------------------------------------------------------------------------ 9 | // getname - get name of this host and place it where specified 10 | //------------------------------------------------------------------------ 11 | SYSCALL 12 | getname(char *name, size_t size) 13 | { 14 | strlcpy(name, "krem68k", size); 15 | /* 16 | IPaddr myaddr; 17 | char *p; 18 | 19 | *name = NULLCH; 20 | if (!Net.mnvalid) { 21 | getaddr(myaddr); 22 | if (ip2name(myaddr, Net.myname) == SYSERR) 23 | return SYSERR; 24 | Net.mnvalid = TRUE; 25 | } 26 | for (p = Net.myname; *p != NULLCH && *p != '.';) 27 | *name++ = *p++; 28 | *name = NULLCH; 29 | */ 30 | return OK; 31 | } 32 | -------------------------------------------------------------------------------- /xinu/getnet.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "network.h" 4 | #include "string.h" 5 | 6 | //------------------------------------------------------------------------ 7 | // getnet - obtain the network portion of this system's IP address 8 | //------------------------------------------------------------------------ 9 | SYSCALL 10 | getnet(IPaddr address) 11 | { 12 | if (!Net.mavalid && getaddr(address) == SYSERR) 13 | return SYSERR; 14 | memmove(address, Net.mynet, IPLEN); 15 | return OK; 16 | } 17 | -------------------------------------------------------------------------------- /xinu/getpid.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "proc.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // getpid -- get the process id of currently executing process 7 | //------------------------------------------------------------------------ 8 | SYSCALL 9 | getpid(void) 10 | { 11 | return currpid; 12 | } 13 | -------------------------------------------------------------------------------- /xinu/getprio.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "proc.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // getprio -- return the scheduling priority of a given process 7 | //------------------------------------------------------------------------ 8 | SYSCALL 9 | getprio(int pid) 10 | { 11 | struct pentry *pptr; 12 | int ps; 13 | 14 | ps = disable(); 15 | if (isbadpid(pid) || (pptr = &proctab[pid])->pstate == PRFREE) { 16 | restore(ps); 17 | return SYSERR; 18 | } 19 | restore(ps); 20 | return pptr->pprio; 21 | } 22 | -------------------------------------------------------------------------------- /xinu/gettime.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "date.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // gettime - get local time in seconds past Jan 1, 1970 7 | //------------------------------------------------------------------------ 8 | SYSCALL 9 | gettime(long *timvar) 10 | { 11 | long now; 12 | 13 | if (getutime(&now) == SYSERR) 14 | return SYSERR; 15 | *timvar = ut2ltime(now); // adjust for timezone 16 | return OK; 17 | } 18 | -------------------------------------------------------------------------------- /xinu/ibclear.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "disk.h" 4 | #include "lfile.h" 5 | #include "dir.h" 6 | 7 | //------------------------------------------------------------------------ 8 | // ibclear -- clear in-core copy of an iblock 9 | //------------------------------------------------------------------------ 10 | void 11 | ibclear(struct iblk *ibptr, long ibbyte) 12 | { 13 | int i; 14 | 15 | ibptr->ib_byte = ibbyte; 16 | for (i = 0; i < IBLEN; i++) 17 | ibptr->ib_dba[i] = DBNULL; 18 | ibptr->ib_next = IBNULL; 19 | } 20 | -------------------------------------------------------------------------------- /xinu/ibget.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "disk.h" 4 | #include "lfile.h" 5 | #include "dir.h" 6 | 7 | //------------------------------------------------------------------------ 8 | // ibget -- get an iblock from disk given its number 9 | //------------------------------------------------------------------------ 10 | void 11 | ibget(int diskdev, IBADDR inum, struct iblk *loc) 12 | { 13 | char *from, *to; 14 | int i; 15 | char *buff; 16 | 17 | buff = getbuf(dskdbp); 18 | read(diskdev, buff, ibtodb(inum)); 19 | from = buff + ibdisp(inum); 20 | to = (char *)loc; 21 | for (i = 0; i < sizeof(struct iblk); i++) 22 | *to++ = *from++; 23 | freebuf(buff); 24 | } 25 | -------------------------------------------------------------------------------- /xinu/init.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "io.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // init - initialize a device 7 | //------------------------------------------------------------------------ 8 | int 9 | init(int descrp) 10 | { 11 | struct devsw *devptr; 12 | 13 | if (isbaddev(descrp)) 14 | return SYSERR; 15 | devptr = &devtab[descrp]; 16 | (*devptr->init)(devptr); 17 | return OK; 18 | } 19 | -------------------------------------------------------------------------------- /xinu/insert.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "q.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // insert.c -- insert an process into a q list in key order 7 | // proc: process to insert 8 | // head: q index of head of list 9 | // key: key to use for this process 10 | //------------------------------------------------------------------------ 11 | int 12 | insert(int proc, int head, int key) 13 | { 14 | int next; // runs through list 15 | int prev; 16 | 17 | next = q[head].qnext; 18 | while (q[next].qkey < key) // tail has MAXINT as key 19 | next = q[next].qnext; 20 | q[proc].qnext = next; 21 | q[proc].qprev = prev = q[next].qprev; 22 | q[proc].qkey = key; 23 | q[prev].qnext = proc; 24 | q[next].qprev = proc; 25 | 26 | return OK; 27 | } 28 | -------------------------------------------------------------------------------- /xinu/insertd.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "q.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // insertd -- insert process pid in delta list "head", given its key 7 | //------------------------------------------------------------------------ 8 | int 9 | insertd(int pid, int head, int key) 10 | { 11 | int next; // runs through list 12 | int prev; // follows next through list 13 | 14 | for (prev = head, next = q[head].qnext; 15 | q[next].qkey < key; 16 | prev = next, next = q[next].qnext) 17 | key -= q[next].qkey; 18 | q[pid].qnext = next; 19 | q[pid].qprev = prev; 20 | q[pid].qkey = key; 21 | q[prev].qnext = pid; 22 | q[next].qprev = pid; 23 | if (next < NPROC) 24 | q[next].qkey -= key; 25 | 26 | return OK; 27 | } 28 | -------------------------------------------------------------------------------- /xinu/intr.s: -------------------------------------------------------------------------------- 1 | | Disable interrupts. 2 | .text 3 | .globl disable 4 | disable: 5 | move.w %sr,%d0 6 | move.w #0x2700,%sr 7 | rts 8 | 9 | | Restore interrupt status from the given argument. 10 | .globl restore 11 | restore: 12 | move.w 6(%sp),%sr 13 | rts 14 | 15 | | Unconditionally enable interrupts. 16 | .global enable 17 | enable: 18 | move.w #0x2000,%sr 19 | rts 20 | -------------------------------------------------------------------------------- /xinu/ioerr.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | 4 | //------------------------------------------------------------------------ 5 | // ioerr - return an error (used for "error" entries in devtab) 6 | //------------------------------------------------------------------------ 7 | int 8 | ioerr(void) 9 | { 10 | return SYSERR; 11 | } 12 | 13 | INTPROC 14 | interr(void) 15 | { 16 | } 17 | -------------------------------------------------------------------------------- /xinu/ioinit.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "mc68k/machine.h" 4 | #include "io.h" 5 | 6 | //------------------------------------------------------------------------ 7 | // iosetvec -- fill in interrupt vectors and dispatch table entries 8 | //------------------------------------------------------------------------ 9 | int 10 | iosetvec(int dev, void (*handler)(void), void *arg) 11 | { 12 | struct devsw *devptr; 13 | void (**vptr)(void) = (void (**)(void))VECTORS; 14 | 15 | if (isbaddev(dev)) 16 | return SYSERR; 17 | devptr = &devtab[dev]; 18 | if (devptr->ivec == 0) // No interrupt support. 19 | return OK; 20 | vptr[devptr->ivec] = handler; // fill in input interrupt 21 | intrargs[devptr->ivec] = arg; // fill in handler argument 22 | return OK; 23 | } 24 | -------------------------------------------------------------------------------- /xinu/ioint.s: -------------------------------------------------------------------------------- 1 | | I/O interrupts trap here. Original PC and PS are on top of the 2 | | stack when one of these is called. Interrupts are disabled. 3 | 4 | | C functionst that are called from interrupt routines. 5 | .globl ttyint 6 | 7 | | intrargs is an array of pointers that are arguments passed to C. 8 | .globl intrargs 9 | 10 | | Exception vector entry for DUART, IVR 65. 11 | .globl vecduart 12 | vecduart: 13 | move.w #0x2700,%sr 14 | movem.l %d0-%d1/%a0-%a1,-(%sp) | Will call C; save registers 15 | lea intrargs,%a0 | Load argument pointer into A0 16 | move.l 65*4(%a0),-(%sp) | handler argument to C ttyint 17 | jsr ttyint | Call C 18 | addq.l #4,%sp | Pop handler argument 19 | movem.l (%sp)+,%d0-%d1/%a0-%a1 | Restore registers 20 | rte | Return from exception 21 | -------------------------------------------------------------------------------- /xinu/ionull.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | 4 | //------------------------------------------------------------------------ 5 | // ionull - do nothing (used for "don't care" entries in devtab) 6 | //------------------------------------------------------------------------ 7 | int 8 | ionull(void) 9 | { 10 | return OK; 11 | } 12 | 13 | void 14 | initnull(void) 15 | { 16 | } 17 | -------------------------------------------------------------------------------- /xinu/lfinit.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "disk.h" 4 | #include "lfile.h" 5 | 6 | struct flblk fltab[Ndf]; 7 | 8 | //------------------------------------------------------------------------ 9 | // lfinit -- mark disk file 'device' available at system startup 10 | //------------------------------------------------------------------------ 11 | void 12 | lfinit(struct devsw *devptr) 13 | { 14 | struct flblk *flptr; 15 | 16 | flptr = &fltab[devptr->minor]; 17 | devptr->iobuf = (void *)flptr; 18 | flptr->fl_pid = 0; 19 | flptr->fl_id = devptr->num; 20 | } 21 | -------------------------------------------------------------------------------- /xinu/lfread.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "disk.h" 4 | #include "lfile.h" 5 | #include "dir.h" 6 | 7 | //------------------------------------------------------------------------ 8 | // lfread -- read from a previously opened disk file 9 | //------------------------------------------------------------------------ 10 | int 11 | lfread(struct devsw *devptr, char *buff, int count) 12 | { 13 | int done; 14 | int ichar; 15 | 16 | if (count < 0) 17 | return SYSERR; 18 | for (done = 0; done < count; done++) 19 | if ((ichar = lfgetc(devptr)) == SYSERR) 20 | return SYSERR; 21 | else if (ichar == EOF) { // EOF before finished 22 | if (done == 0) 23 | return EOF; 24 | else 25 | return done; 26 | } else 27 | *buff++ = (char) ichar; 28 | return done; 29 | } 30 | -------------------------------------------------------------------------------- /xinu/lfsdfree.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "disk.h" 4 | #include "lfile.h" 5 | #include "dir.h" 6 | 7 | //------------------------------------------------------------------------ 8 | // lfsdfree -- free a data block given its address 9 | //------------------------------------------------------------------------ 10 | int 11 | lfsdfree(int diskdev, DBADDR dba) 12 | { 13 | struct dir *dirptr; 14 | int dirsem; 15 | struct freeblk *buf; 16 | 17 | dirptr = (struct dir *)dsdirec(diskdev); 18 | dirsem = ((struct dsblk *)devtab[diskdev].iobuf)->dflsem; 19 | buf = (struct freeblk *)getbuf(dskdbp); 20 | wait(dirsem); 21 | buf->fbnext = dirptr->d_fblst; 22 | dirptr->d_fblst = dba; 23 | write(diskdev, buf, dba); 24 | write(diskdev, dskbcpy(dirptr), DIRBLK); 25 | signal(dirsem); 26 | return OK; 27 | } 28 | -------------------------------------------------------------------------------- /xinu/lfseek.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "disk.h" 4 | #include "lfile.h" 5 | #include "dir.h" 6 | 7 | //------------------------------------------------------------------------ 8 | // lfseek -- seek to a specified position of a file 9 | //------------------------------------------------------------------------ 10 | int 11 | lfseek(struct devsw *devptr, long offset) 12 | { 13 | struct flblk *flptr; 14 | int ps; 15 | 16 | ps = disable(); 17 | flptr = (struct flblk *)devptr->iobuf; 18 | if (flptr->fl_mode & FLWRITE) { 19 | if (flptr->fl_dch) 20 | lfsflush(flptr); 21 | } else if (offset > (flptr->fl_dent)->fdlen) { 22 | restore(ps); 23 | return SYSERR; 24 | } 25 | flptr->fl_pos = offset; 26 | lfsetup(flptr->fl_dev, flptr); 27 | restore(ps); 28 | return OK; 29 | } 30 | -------------------------------------------------------------------------------- /xinu/lfsflush.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "disk.h" 4 | #include "lfile.h" 5 | #include "dir.h" 6 | 7 | //------------------------------------------------------------------------ 8 | // lfsflush -- flush data and i-block for a file 9 | //------------------------------------------------------------------------ 10 | int 11 | lfsflush(struct flblk *flptr) 12 | { 13 | DBADDR dba; 14 | 15 | if (!flptr->fl_dch) 16 | return SYSERR; 17 | dba = flptr->fl_iblk.ib_dba[flptr->fl_ipnum]; 18 | write(flptr->fl_dev, dskbcpy(flptr->fl_buff), dba); 19 | flptr->fl_dch = FALSE; 20 | return OK; 21 | } 22 | -------------------------------------------------------------------------------- /xinu/lfwrite.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | 4 | //------------------------------------------------------------------------ 5 | // lfwrite -- write 'count' bytes onto a local disk file 6 | //------------------------------------------------------------------------ 7 | int 8 | lfwrite(struct devsw *devptr, char *buff, int count) 9 | { 10 | int i; 11 | 12 | if (count < 0) 13 | return SYSERR; 14 | for (i = count; i > 0; i--) 15 | if (lfputc(devptr, *buff++) == SYSERR) 16 | return SYSERR; 17 | return count; 18 | } 19 | -------------------------------------------------------------------------------- /xinu/namemap.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "conf.h" 5 | #include "kernel.h" 6 | #include "name.h" 7 | 8 | //------------------------------------------------------------------------ 9 | // namemap - using namespace, iteratively map name onto (newname,device) 10 | //------------------------------------------------------------------------ 11 | SYSCALL 12 | namemap(char *name, char *newname) 13 | { 14 | size_t size = 80; 15 | int ps; 16 | int dev; 17 | char tmpnam[NAMLEN]; 18 | 19 | ps = disable(); 20 | dev = namereplace(name, newname, size); 21 | while (dev == NAMESPACE) { 22 | strlcpy(tmpnam, newname, NAMLEN); 23 | dev = namereplace(tmpnam, newname, size); 24 | } 25 | restore(ps); 26 | 27 | return dev; 28 | } 29 | -------------------------------------------------------------------------------- /xinu/nameopen.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "name.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // nameopen - open an object (e.g., remote file) based on the name 7 | //------------------------------------------------------------------------ 8 | int 9 | nameopen(struct devsw *devptr, char *filename, char *mode) 10 | { 11 | int dev; 12 | char newname[NAMLEN]; 13 | 14 | dev = namemap(filename, newname); 15 | if (dev == SYSERR) 16 | return SYSERR; 17 | 18 | return open(dev, newname, mode); 19 | } 20 | -------------------------------------------------------------------------------- /xinu/ndump.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "conf.h" 5 | #include "kernel.h" 6 | #include "io.h" 7 | #include "name.h" 8 | 9 | #define PADTO 24 10 | 11 | //------------------------------------------------------------------------ 12 | // ndump - dump current mappings in object naming system 13 | //------------------------------------------------------------------------ 14 | void 15 | ndump(void) 16 | { 17 | 18 | for (int i = 0; i < Nam.nnames; i++) { 19 | struct nament *nptr = &Nam.nametab[i]; 20 | int dev = nptr->ndev; 21 | char *p = "SYSERR"; 22 | 23 | kprintf("\"%-s\"", nptr->npre); 24 | for (int len = strlen(nptr->npre); len < PADTO; len++) 25 | kprintf(" "); 26 | if (!isbaddev(dev)) 27 | p = devtab[dev].name; 28 | kprintf(" -> (%-8s) \"%s\"\n", p, nptr->nrepl); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /xinu/netnum.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "network.h" 4 | #include "string.h" 5 | 6 | //------------------------------------------------------------------------ 7 | // netnum - obtain the network portion of a given IP address 8 | //------------------------------------------------------------------------ 9 | int 10 | netnum(IPaddr netpart, IPaddr address) 11 | { 12 | 13 | memmove(netpart, address, IPLEN); 14 | switch (netpart[0] & IPTMASK) { 15 | case IPATYP: 16 | netpart[1] = '\0'; // fall through 17 | case IPBTYP: 18 | netpart[2] = '\0'; // fall through 19 | case IPCTYP: 20 | netpart[3] = '\0'; 21 | } 22 | 23 | return OK; 24 | } 25 | -------------------------------------------------------------------------------- /xinu/newqueue.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "q.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // newqueue -- initialize a new list in the q structure 7 | //------------------------------------------------------------------------ 8 | int 9 | newqueue(void) 10 | { 11 | struct qent *hptr; // address of new list head 12 | struct qent *tptr; // address of new list tail 13 | int hindex, tindex; // head and tail indexes 14 | 15 | hptr = &q[hindex = nextqueue++]; // nextqueue is global variable 16 | tptr = &q[tindex = nextqueue++]; // giving next used q pos. 17 | hptr->qnext = tindex; 18 | hptr->qprev = EMPTY; 19 | hptr->qkey = MININT; 20 | tptr->qnext = EMPTY; 21 | tptr->qprev = hindex; 22 | tptr->qkey = MAXINT; 23 | return hindex; 24 | } 25 | -------------------------------------------------------------------------------- /xinu/nqalloc.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "proc.h" 4 | #include "network.h" 5 | 6 | //------------------------------------------------------------------------ 7 | // nqalloc - allocate a network demultiplexing queue 8 | //------------------------------------------------------------------------ 9 | int 10 | nqalloc(void) 11 | { 12 | int ps; 13 | 14 | ps = disable(); 15 | for (int i = 0; i < NETQS; i++) { 16 | struct netq *nqptr = &Net.netqs[i]; 17 | if (!nqptr->valid) { 18 | nqptr->valid = TRUE; 19 | nqptr->uport = -1; 20 | nqptr->pid = BADPID; 21 | restore(ps); 22 | return i; 23 | } 24 | } 25 | restore(ps); 26 | 27 | return SYSERR; 28 | } 29 | -------------------------------------------------------------------------------- /xinu/open.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "io.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // open - open a connection to a device/file (parms 2 &3 are optional) 7 | //------------------------------------------------------------------------ 8 | SYSCALL 9 | open(int descrp, char *nam, char *mode) 10 | { 11 | struct devsw *devptr; 12 | 13 | if (isbaddev(descrp)) 14 | return SYSERR; 15 | devptr = &devtab[descrp]; 16 | 17 | return (*devptr->open)(devptr, nam, mode); 18 | } 19 | -------------------------------------------------------------------------------- /xinu/pause.s: -------------------------------------------------------------------------------- 1 | | Pause the processor until we get an interrupt. 2 | .text 3 | .globl pause, halt 4 | halt: 5 | pause: 6 | STOP #0x2000 7 | RTS 8 | 9 | .text 10 | .globl stop 11 | stop: 12 | STOP #0x2700 13 | RTS 14 | -------------------------------------------------------------------------------- /xinu/pcount.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "mark.h" 4 | #include "ports.h" 5 | 6 | //------------------------------------------------------------------------ 7 | // pcount -- return the count of current messages in a port 8 | //------------------------------------------------------------------------ 9 | SYSCALL 10 | pcount(int portid) 11 | { 12 | int scnt; 13 | int count; 14 | int ps; 15 | struct pt *ptptr; 16 | 17 | ps = disable(); 18 | if (isbadport(portid) || 19 | unmarked(ptmark) || 20 | (ptptr = &ports[portid])->ptstate != PTALLOC) { 21 | restore(ps); 22 | return SYSERR; 23 | } 24 | count = scount(ptptr->ptrsem); 25 | if ((scnt = scount(ptptr->ptssem)) < 0) 26 | count -= scnt; // add number waiting 27 | restore(ps); 28 | 29 | return count; 30 | } 31 | -------------------------------------------------------------------------------- /xinu/pdelete.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "mark.h" 4 | #include "ports.h" 5 | 6 | //------------------------------------------------------------------------ 7 | // pdelete -- delete a port, freeing waiting processes and messages 8 | //------------------------------------------------------------------------ 9 | SYSCALL 10 | pdelete(int portid, int (*dispose)(void *)) 11 | { 12 | int ps; 13 | struct pt *ptptr; 14 | 15 | ps = disable(); 16 | if (isbadport(portid) || 17 | unmarked(ptmark) || 18 | (ptptr = &ports[portid])->ptstate != PTALLOC) { 19 | restore(ps); 20 | return SYSERR; 21 | } 22 | _ptclear(ptptr, PTFREE, dispose); 23 | restore(ps); 24 | 25 | return OK; 26 | } 27 | -------------------------------------------------------------------------------- /xinu/poolinit.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "mark.h" 4 | #include "bufpool.h" 5 | 6 | struct bpool bptab[NBPOOLS]; 7 | size_t nbpools; 8 | MARKER bpmark; // self initializing mark 9 | 10 | //------------------------------------------------------------------------ 11 | // poolinit -- initialize the buffer pool routines 12 | //------------------------------------------------------------------------ 13 | int 14 | poolinit(void) 15 | { 16 | int status; 17 | int ps; 18 | 19 | ps = disable(); 20 | status = mark(bpmark); 21 | if (status == OK) { 22 | nbpools = 0; 23 | } 24 | restore(ps); 25 | 26 | return (status == OK) ? OK : SYSERR; 27 | } 28 | -------------------------------------------------------------------------------- /xinu/preset.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "mark.h" 4 | #include "ports.h" 5 | 6 | //------------------------------------------------------------------------ 7 | // preset -- reset a port, freeing waiting processes and messages 8 | //------------------------------------------------------------------------ 9 | SYSCALL 10 | preset(int portid, int (*dispose)(void *)) 11 | { 12 | int ps; 13 | struct pt *ptptr; 14 | 15 | ps = disable(); 16 | if (isbadport(portid) || 17 | unmarked(ptmark) || 18 | (ptptr = &ports[portid])->ptstate != PTALLOC) { 19 | restore(ps); 20 | return SYSERR; 21 | } 22 | _ptclear(ptptr, PTALLOC, dispose); 23 | restore(ps); 24 | return OK; 25 | } 26 | -------------------------------------------------------------------------------- /xinu/putc.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "io.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // putc - write a single character to a device 7 | //------------------------------------------------------------------------ 8 | SYSCALL 9 | putc(int descrp, int ch) 10 | { 11 | struct devsw *devptr; 12 | 13 | if (isbaddev(descrp)) 14 | return SYSERR; 15 | devptr = &devtab[descrp]; 16 | 17 | return (*devptr->putc)(devptr, ch); 18 | } 19 | -------------------------------------------------------------------------------- /xinu/read.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "io.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // read - read one or more bytes from a device 7 | //------------------------------------------------------------------------ 8 | SYSCALL 9 | read(int descrp, void *buff, int count) 10 | { 11 | struct devsw *devptr; 12 | 13 | if (isbaddev(descrp)) 14 | return SYSERR; 15 | devptr = &devtab[descrp]; 16 | 17 | return (*devptr->read)(devptr, buff, count); 18 | } 19 | -------------------------------------------------------------------------------- /xinu/ready.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "proc.h" 4 | #include "q.h" 5 | 6 | //------------------------------------------------------------------------ 7 | // ready -- make a process eligible for CPU service 8 | // 9 | // pid: id of process to make ready 10 | // resch: reschedule afterward? 11 | //------------------------------------------------------------------------ 12 | int 13 | ready(int pid) 14 | { 15 | struct pentry *pptr; 16 | 17 | if (isbadpid(pid)) 18 | return SYSERR; 19 | pptr = &proctab[pid]; 20 | pptr->pstate = PRREADY; 21 | insert(pid, rdyhead, pptr->pprio); 22 | 23 | return OK; 24 | } 25 | 26 | int 27 | readysched(int pid) 28 | { 29 | if (ready(pid) != OK) 30 | return SYSERR; 31 | resched(); 32 | 33 | return OK; 34 | } 35 | -------------------------------------------------------------------------------- /xinu/receive.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "proc.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // receive - wait for a message and return it 7 | //------------------------------------------------------------------------ 8 | SYSCALL 9 | receive(void) 10 | { 11 | struct pentry *pptr; 12 | int msg; 13 | int ps; 14 | 15 | ps = disable(); 16 | pptr = &proctab[currpid]; 17 | if (!pptr->phasmsg) { // if no message, wait for one 18 | pptr->pstate = PRRECV; 19 | resched(); 20 | } 21 | msg = pptr->pmsg; // retrieve message 22 | pptr->phasmsg = FALSE; 23 | restore(ps); 24 | return msg; 25 | } 26 | -------------------------------------------------------------------------------- /xinu/recvclr.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "proc.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // recvclr -- clear messages, returning waiting message (if any) 7 | //------------------------------------------------------------------------ 8 | SYSCALL 9 | recvclr(void) 10 | { 11 | int ps; 12 | int msg = OK; 13 | 14 | ps = disable(); 15 | if (proctab[currpid].phasmsg) { // existing message? 16 | proctab[currpid].phasmsg = FALSE; 17 | msg = proctab[currpid].pmsg; 18 | } 19 | restore(ps); 20 | 21 | return msg; 22 | } 23 | -------------------------------------------------------------------------------- /xinu/remove.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "file.h" 4 | #include "name.h" 5 | 6 | //------------------------------------------------------------------------ 7 | // remove - remove a file given its name (key is optional) 8 | //------------------------------------------------------------------------ 9 | SYSCALL 10 | remove(char *name, int key) 11 | { 12 | struct devsw *dp; 13 | int dev; 14 | char fullname[NAMLEN]; 15 | 16 | dev = namemap(name, fullname); 17 | if (dev == SYSERR) 18 | return SYSERR; 19 | dp = &devtab[dev]; 20 | 21 | return (*dp->ctl)(dp, FLREMOVE, fullname, key); 22 | } 23 | -------------------------------------------------------------------------------- /xinu/rename.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "file.h" 4 | #include "name.h" 5 | 6 | //------------------------------------------------------------------------ 7 | // rename - rename a file (key is optional) 8 | //------------------------------------------------------------------------ 9 | SYSCALL 10 | rename(char *old, char *new) 11 | { 12 | struct devsw *dp; 13 | int dev, dev2; 14 | char fullold[NAMLEN]; 15 | char fullnew[NAMLEN]; 16 | 17 | // map names through namespace and restrict to single device 18 | if ((dev = namemap(old, fullold)) == SYSERR || 19 | (dev2 = namemap(new, fullnew)) == SYSERR || 20 | dev != dev2) 21 | return SYSERR; 22 | dp = &devtab[dev]; 23 | 24 | return (*dp->ctl)(dp, FLRENAME, fullold, fullnew); 25 | } 26 | -------------------------------------------------------------------------------- /xinu/resume.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "proc.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // resume -- unsuspend a process, making it ready; return the priority 7 | //------------------------------------------------------------------------ 8 | SYSCALL 9 | resume(int pid) 10 | { 11 | int ps; // saved processor status 12 | struct pentry *pptr; // pointer to proc. tab. entry 13 | int prio; // priority to return 14 | 15 | ps = disable(); 16 | if (isbadpid(pid) || (pptr = &proctab[pid])->pstate != PRSUSP) { 17 | restore(ps); 18 | return SYSERR; 19 | } 20 | prio = pptr->pprio; 21 | readysched(pid); 22 | restore(ps); 23 | 24 | return prio; 25 | } 26 | -------------------------------------------------------------------------------- /xinu/rfalloc.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "fserver.h" 4 | #include "rfile.h" 5 | 6 | //------------------------------------------------------------------------ 7 | // rfalloc -- allocate pseudo device for a remote file; return id 8 | //------------------------------------------------------------------------ 9 | int 10 | rfalloc(void) 11 | { 12 | int ps = disable(); 13 | 14 | for (int i = 0; i < Nrf; i++) 15 | if (Rf.rftab[i].rf_state == RFREE) { 16 | Rf.rftab[i].rf_state = RUSED; 17 | restore(ps); 18 | return i; 19 | } 20 | restore(ps); 21 | 22 | return SYSERR; 23 | } 24 | -------------------------------------------------------------------------------- /xinu/rfclose.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "network.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // rfclose -- close a remote file by deallocating pseudo device 7 | //------------------------------------------------------------------------ 8 | int 9 | rfclose(struct devsw *devptr) 10 | { 11 | struct rfblk *rfptr; 12 | long junk; // argument to rfmkpac; not really used 13 | 14 | rfptr = (struct rfblk *)devptr->iobuf; 15 | if (rfptr->rf_state == RFREE) 16 | return SYSERR; 17 | wait(rfptr->rf_mutex); 18 | junk = 0L; // 0L is long zero constant 19 | rfmkpac(FS_CLOSE, rfptr->rf_name, &junk, (char *)&junk, 0); 20 | rfptr->rf_state = RFREE; 21 | signal(rfptr->rf_mutex); 22 | 23 | return OK; 24 | } 25 | -------------------------------------------------------------------------------- /xinu/rfdump.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "fserver.h" 4 | #include "rfile.h" 5 | 6 | //------------------------------------------------------------------------ 7 | // rfdump -- dump the contents of the remote file device blocks 8 | //------------------------------------------------------------------------ 9 | void 10 | rfdump(void) 11 | { 12 | 13 | kprintf("Remote files: server on dev=%d, server mutex=%d\n", 14 | Rf.device, Rf.rmutex); 15 | for (int i = 0; i < Nrf; i++) { 16 | struct rfblk *rfptr = &Rf.rftab[i]; 17 | if (rfptr->rf_state == RFREE) 18 | continue; 19 | kprintf(" %2d. ", rfptr->rf_dnum); 20 | kprintf("mode=%03o, sem=%2d, pos=%6d, file name=%s\n", 21 | rfptr->rf_mode, rfptr->rf_mutex, 22 | rfptr->rf_pos, rfptr->rf_name); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /xinu/rfgetc.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "network.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // rfgetc -- get a character from a remote file 7 | //------------------------------------------------------------------------ 8 | int 9 | rfgetc(struct devsw *devptr) 10 | { 11 | char ch; 12 | int retcode; 13 | 14 | if ((retcode = read(devptr->num, &ch, 1)) == 1) 15 | return ch; 16 | if (retcode == 0) 17 | return EOF; 18 | 19 | return SYSERR; 20 | } 21 | -------------------------------------------------------------------------------- /xinu/rfinit.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "fserver.h" 4 | #include "rfile.h" 5 | 6 | struct rfinfo Rf; 7 | 8 | //------------------------------------------------------------------------ 9 | // rfinit -- initialize remote file pseudo devices 10 | //------------------------------------------------------------------------ 11 | void 12 | rfinit(struct devsw *devptr) 13 | { 14 | struct rfblk *rfptr; 15 | 16 | devptr->iobuf = (char *)(rfptr = &Rf.rftab[devptr->minor]); 17 | rfptr->rf_dnum = devptr->num; 18 | rfptr->rf_name[0] = NULLCH; 19 | rfptr->rf_state = RFREE; 20 | rfptr->rf_mutex = screate(1); 21 | rfptr->rf_pos = 0L; 22 | if (devptr->minor == 0) { // done just once 23 | Rf.device = RCLOSED; 24 | Rf.rmutex = screate(1); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /xinu/rfio.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "network.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // rfio -- perform input or output using remote file server 7 | //------------------------------------------------------------------------ 8 | int 9 | rfio(struct devsw *devptr, int rop, char *buff, int len) 10 | { 11 | struct rfblk *rfptr; 12 | int retcode; 13 | 14 | rfptr = (struct rfblk *)devptr->iobuf; 15 | wait(rfptr->rf_mutex); 16 | if (len < 0 || rfptr->rf_state == RFREE) { 17 | signal(rfptr->rf_mutex); 18 | return SYSERR; 19 | } 20 | retcode = rfmkpac(rop, rfptr->rf_name, &rfptr->rf_pos, buff, len); 21 | signal(rfptr->rf_mutex); 22 | 23 | return retcode; 24 | } 25 | -------------------------------------------------------------------------------- /xinu/rfputc.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "network.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // rfputc -- put a single character into a remote file 7 | //------------------------------------------------------------------------ 8 | int 9 | rfputc(struct devsw *devptr, int ch) 10 | { 11 | char outch; 12 | 13 | outch = ch; 14 | if (write(devptr->num, &outch, 1) != 1) 15 | return SYSERR; 16 | 17 | return OK; 18 | } 19 | -------------------------------------------------------------------------------- /xinu/rfread.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "network.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // rfread -- read one or more bytes from a remote file 7 | //------------------------------------------------------------------------ 8 | int 9 | rfread(struct devsw *devptr, char *buff, int len) 10 | { 11 | return rfio(devptr, FS_READ, buff, min(len, RDATLEN)); 12 | } 13 | -------------------------------------------------------------------------------- /xinu/rfseek.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "fserver.h" 4 | #include "rfile.h" 5 | 6 | //------------------------------------------------------------------------ 7 | // rfseek -- seek to a specified position of a remote file 8 | //------------------------------------------------------------------------ 9 | int 10 | rfseek(struct devsw *devptr, long offset) 11 | { 12 | struct rfblk *rfptr; 13 | 14 | rfptr = (struct rfblk *)devptr->iobuf; 15 | wait(rfptr->rf_mutex); 16 | rfptr->rf_pos = offset; 17 | signal(rfptr->rf_mutex); 18 | 19 | return OK; 20 | } 21 | -------------------------------------------------------------------------------- /xinu/rfwrite.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "network.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // rfwrite -- write one or more bytes to a remote file 7 | //------------------------------------------------------------------------ 8 | int 9 | rfwrite(struct devsw *devptr, char *buff, int len) 10 | { 11 | 12 | if (len < 0) 13 | return SYSERR; 14 | for (int i = len; i > 0; i -= RDATLEN, buff += RDATLEN) 15 | if (rfio(devptr, FS_WRITE, buff, min(i, RDATLEN)) == SYSERR) 16 | return SYSERR; 17 | 18 | return len; 19 | } 20 | -------------------------------------------------------------------------------- /xinu/rwho.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "network.h" 4 | #include "rwho.h" 5 | 6 | struct rwinfo Rwho; // all globals used by rwho subsystem 7 | 8 | //------------------------------------------------------------------------ 9 | // rwho - Initialize rwho subsystem and start daemon processes 10 | //------------------------------------------------------------------------ 11 | void 12 | rwho(void) 13 | { 14 | resume(create(RWIN, RWISTK, RWIPRIO, RWINAM, RWIARGS)); 15 | resume(create(RWOUT, RWOSTK, RWOPRIO, RWONAM, RWOARGS)); 16 | } 17 | -------------------------------------------------------------------------------- /xinu/scount.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "sem.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // scount -- return a semaphore count 7 | //------------------------------------------------------------------------ 8 | SYSCALL 9 | scount(int sem) 10 | { 11 | 12 | if (isbadsem(sem) || semaph[sem].sstate == SFREE) 13 | return SYSERR; 14 | 15 | return semaph[sem].semcnt; 16 | } 17 | -------------------------------------------------------------------------------- /xinu/seek.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "io.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // seek -- position a device (very common special case of control) 7 | //------------------------------------------------------------------------ 8 | SYSCALL 9 | seek(int descrp, long pos) 10 | { 11 | struct devsw *devptr; 12 | 13 | if (isbaddev(descrp)) 14 | return SYSERR; 15 | devptr = &devtab[descrp]; 16 | 17 | return (*devptr->seek)(devptr, pos); 18 | } 19 | -------------------------------------------------------------------------------- /xinu/sendf.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "proc.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // sendf -- sendf a message to another process, forcing delivery 7 | //------------------------------------------------------------------------ 8 | SYSCALL 9 | sendf(int pid, int msg) 10 | { 11 | struct pentry *pptr; 12 | int ps; 13 | 14 | ps = disable(); 15 | if (isbadpid(pid) || ((pptr = &proctab[pid])->pstate == PRFREE)) { 16 | restore(ps); 17 | return SYSERR; 18 | } 19 | pptr->pmsg = msg; 20 | pptr->phasmsg = TRUE; 21 | if (pptr->pstate == PRRECV) 22 | readysched(pid); 23 | else if (pptr->pstate == PRTRECV) { 24 | unsleep(pid); 25 | readysched(pid); 26 | } 27 | restore(ps); 28 | 29 | return OK; 30 | } 31 | -------------------------------------------------------------------------------- /xinu/setclkr.s: -------------------------------------------------------------------------------- 1 | |------------------------------------------------------------------------ 2 | | setclkr -- set cklruns to 1 iff real-time clock exists, 0 otherwise 3 | |------------------------------------------------------------------------ 4 | .globl setclkr 5 | setclkr: 6 | move.l #1,hasclock 7 | rts 8 | -------------------------------------------------------------------------------- /xinu/setdev.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "proc.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // setdev - set the two device entries in the process table entry 7 | // 8 | // pid: process to change 9 | // dev1, dev2: device descriptors to set 10 | //------------------------------------------------------------------------ 11 | SYSCALL 12 | setdev(int pid, int dev1, int dev2) 13 | { 14 | int *nxtdev; 15 | 16 | if (isbadpid(pid)) 17 | return SYSERR; 18 | nxtdev = (int *)proctab[pid].pdevs; 19 | *nxtdev++ = dev1; 20 | *nxtdev = dev2; 21 | 22 | return OK; 23 | } 24 | -------------------------------------------------------------------------------- /xinu/setnok.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "proc.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // setnok - set next-of-kin (notified at death) for a given process 7 | //------------------------------------------------------------------------ 8 | SYSCALL 9 | setnok(int nok, int pid) 10 | { 11 | int ps; 12 | struct pentry *pptr; 13 | 14 | ps = disable(); 15 | if (isbadpid(pid)) { 16 | restore(ps); 17 | return SYSERR; 18 | } 19 | pptr = &proctab[pid]; 20 | pptr->pnxtkin = nok; 21 | restore(ps); 22 | 23 | return OK; 24 | } 25 | -------------------------------------------------------------------------------- /xinu/shell/cmd.h: -------------------------------------------------------------------------------- 1 | // Declarations for all commands known by the shell 2 | struct cmdent { // entry in command table 3 | char *cmdnam; // name of command 4 | Bool cbuiltin; // Is this a builtin command? 5 | int (*cproc)(int, int, int, int, char *[]); // procedure that implements cmd 6 | }; 7 | 8 | extern int 9 | x_bpool(), x_cat(), x_close(), x_cp(), 10 | x_creat(), x_date(), x_devs(), x_dg(), 11 | x_echo(), x_exit(), x_help(), x_kill(), 12 | x_mem(), x_mount(), x_mv(), x_net(), 13 | x_ps(), x_reboot(), x_rf(), x_rls(), 14 | x_rm(), x_routes(), x_sleep(), x_snap(), 15 | x_unmou(), x_uptime(), x_who(); 16 | 17 | extern struct cmdent cmds[]; 18 | -------------------------------------------------------------------------------- /xinu/shell/x_bpool.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "conf.h" 5 | #include "kernel.h" 6 | #include "mark.h" 7 | #include "bufpool.h" 8 | 9 | //------------------------------------------------------------------------ 10 | // x_bpool - (command bpool) format and print buffer pool information 11 | //------------------------------------------------------------------------ 12 | COMMAND 13 | x_bpool(int stdin, int stdout, int stderr, int nargs, char *args[]) 14 | { 15 | 16 | for (int i = 0; i < nbpools; i++) { 17 | struct bpool *bpptr = &bptab[i]; 18 | char str[80]; 19 | sprintf(str, "pool=%2d. bsize=%4d, sem=%2d, count=%d\n", 20 | i, bpptr->bpsize, bpptr->bpsem, 21 | scount(bpptr->bpsem)); 22 | write(stdout, str, strlen(str)); 23 | } 24 | 25 | return OK; 26 | } 27 | -------------------------------------------------------------------------------- /xinu/shell/x_close.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "conf.h" 5 | #include "kernel.h" 6 | 7 | //------------------------------------------------------------------------ 8 | // x_close - (command close) close a device given its id 9 | //------------------------------------------------------------------------ 10 | COMMAND 11 | x_close(int stdin, int stdout, int stderr, int nargs, char *args[]) 12 | { 13 | if (nargs != 2) { 14 | fprintf(stderr, "use: close device-number\n"); 15 | return SYSERR; 16 | } 17 | return close(atoi(args[1])); 18 | } 19 | -------------------------------------------------------------------------------- /xinu/shell/x_date.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "conf.h" 5 | #include "kernel.h" 6 | #include "sleep.h" 7 | #include "date.h" 8 | 9 | //------------------------------------------------------------------------ 10 | // x_date - (command date) print the date and time 11 | //------------------------------------------------------------------------ 12 | COMMAND 13 | x_date(int stdin, int stdout, int stderr, int nargs, char *args[]) 14 | { 15 | long now; 16 | char str[80]; 17 | 18 | if (nargs == 2) 19 | clktime = 0L; 20 | gettime(&now); 21 | ascdate(now, str); 22 | strlcat(str, "\n", sizeof(str)); 23 | write(stdout, str, strlen(str)); 24 | 25 | return OK; 26 | } 27 | -------------------------------------------------------------------------------- /xinu/shell/x_echo.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "conf.h" 5 | #include "kernel.h" 6 | 7 | //------------------------------------------------------------------------ 8 | // x_echo - (command echo) echo arguments separated by blanks 9 | //------------------------------------------------------------------------ 10 | COMMAND 11 | x_echo(int stdin, int stdout, int stderr, int nargs, char *args[]) 12 | { 13 | char str[80]; 14 | 15 | str[0] = '\0'; 16 | if (nargs != 1) { 17 | strlcpy(str, args[1], sizeof(str)); 18 | for (int i = 2; i < nargs; i++) { 19 | strlcat(str, " ", sizeof(str)); 20 | strlcat(str, args[i], sizeof(str)); 21 | } 22 | } 23 | strlcat(str, "\n", sizeof(str)); 24 | write(stdout, str, strlen(str)); 25 | 26 | return OK; 27 | } 28 | -------------------------------------------------------------------------------- /xinu/shell/x_exit.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "shell.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // x_exit - (builtin command exit) exit from the shell 7 | //------------------------------------------------------------------------ 8 | BUILTIN 9 | x_exit(int stdin, int stdout, int stderr, int nargs, char *args[]) 10 | { 11 | return SHEXIT; 12 | } 13 | -------------------------------------------------------------------------------- /xinu/shell/x_kill.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "shell.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // x_kill - (command kill) terminate a process 7 | //------------------------------------------------------------------------ 8 | BUILTIN 9 | x_kill(int stdin, int stdout, int stderr, int nargs, char *args[]) 10 | { 11 | int pid; 12 | 13 | if (nargs != 2) { 14 | fprintf(stderr, "use: kill process-id\n"); 15 | return SYSERR; 16 | } 17 | if ((pid = atoi(args[1])) == getpid()) 18 | fprintf(stderr, "Shell killed\n"); 19 | return kill(pid); 20 | } 21 | -------------------------------------------------------------------------------- /xinu/shell/x_mv.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "file.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // x_mv - (command mv) move (rename) a file 7 | //------------------------------------------------------------------------ 8 | COMMAND 9 | x_mv(int stdin, int stdout, int stderr, int nargs, char *args[]) 10 | { 11 | if (nargs != 3) { 12 | fprintf(stderr, "usage: mv file tofile\n"); 13 | return SYSERR; 14 | } 15 | if (rename(args[1], args[2]) == SYSERR) { 16 | fprintf(stderr, "Cannot move %s\n", args[1]); 17 | return SYSERR; 18 | } 19 | return OK; 20 | } 21 | -------------------------------------------------------------------------------- /xinu/shell/x_reboot.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | 4 | //------------------------------------------------------------------------ 5 | // x_reboot - (builtin command reboot) restart the system from scratch 6 | //------------------------------------------------------------------------ 7 | BUILTIN 8 | x_reboot(int stdin, int stdout, int stderr, int nargs, char *args[]) 9 | { 10 | restart(); // warning! This terminates everything. 11 | return OK; 12 | } 13 | -------------------------------------------------------------------------------- /xinu/shell/x_rm.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "file.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // x_rm - (command rm) remove a file given its name 7 | //------------------------------------------------------------------------ 8 | COMMAND 9 | x_rm(int stdin, int stdout, int stderr, int nargs, char *args[]) 10 | { 11 | if (nargs != 2) { 12 | fprintf(stderr, "usage: rm file\n"); 13 | return SYSERR; 14 | } 15 | if (remove(args[1], 0) == SYSERR) { 16 | fprintf(stderr, "Cannot remove %s\n", args[1]); 17 | return SYSERR; 18 | } 19 | return OK; 20 | } 21 | -------------------------------------------------------------------------------- /xinu/shell/x_sleep.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | 4 | //------------------------------------------------------------------------ 5 | // x_sleep - (command sleep) delay for a given number of seconds 6 | //------------------------------------------------------------------------ 7 | COMMAND 8 | x_sleep(int stdin, int stdout, int stderr, int nargs, char *args[]) 9 | { 10 | 11 | if (nargs != 2) { 12 | fprintf(stderr, "usage: sleep delay\n"); 13 | return SYSERR; 14 | } 15 | 16 | return sleep(atoi(args[1])); 17 | } 18 | -------------------------------------------------------------------------------- /xinu/shell/x_unmou.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "io.h" 4 | #include "name.h" 5 | 6 | //------------------------------------------------------------------------ 7 | // x_unmou - (command unmount) remove a prefix from the namespace table 8 | //------------------------------------------------------------------------ 9 | COMMAND 10 | x_unmou(int stdin, int stdout, int stderr, int nargs, char *args[]) 11 | { 12 | if (nargs != 2) { 13 | fprintf(stderr, "use: unmount prefix\n"); 14 | return SYSERR; 15 | } 16 | if (unmount(args[1]) == SYSERR) { 17 | fprintf(stderr, "unmount fails.\n"); 18 | return SYSERR; 19 | } 20 | return OK; 21 | } 22 | -------------------------------------------------------------------------------- /xinu/signal.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "proc.h" 4 | #include "q.h" 5 | #include "sem.h" 6 | 7 | //------------------------------------------------------------------------ 8 | // signal -- signal a semaphore, releasing one waiting process 9 | //------------------------------------------------------------------------ 10 | SYSCALL 11 | signal(int sem) 12 | { 13 | struct sentry *sptr; 14 | int ps; 15 | 16 | ps = disable(); 17 | if (isbadsem(sem) || (sptr = &semaph[sem])->sstate == SFREE) { 18 | restore(ps); 19 | return SYSERR; 20 | } 21 | if ((sptr->semcnt++) < 0) 22 | readysched(getfirst(sptr->sqhead)); 23 | restore(ps); 24 | 25 | return OK; 26 | } 27 | -------------------------------------------------------------------------------- /xinu/signaln.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "proc.h" 4 | #include "q.h" 5 | #include "sem.h" 6 | 7 | //------------------------------------------------------------------------ 8 | // signaln -- signal a semaphore n times 9 | //------------------------------------------------------------------------ 10 | SYSCALL 11 | signaln(int sem, int count) 12 | { 13 | struct sentry *sptr; 14 | int ps; 15 | 16 | ps = disable(); 17 | if (isbadsem(sem) || semaph[sem].sstate == SFREE || count <= 0) { 18 | restore(ps); 19 | return SYSERR; 20 | } 21 | sptr = &semaph[sem]; 22 | for (; count > 0; count--) 23 | if ((sptr->semcnt++) < 0) 24 | ready(getfirst(sptr->sqhead)); 25 | resched(); 26 | restore(ps); 27 | 28 | return OK; 29 | } 30 | -------------------------------------------------------------------------------- /xinu/sizmem.s: -------------------------------------------------------------------------------- 1 | |------------------------------------------------------------------------ 2 | | sizmem -- size memory, placing highest valid address in _maxaddr 3 | |------------------------------------------------------------------------ 4 | .globl sizmem,maxaddr 5 | sizmem: 6 | move.l #0x00100000,%d0 7 | sub.l #4,%d0 8 | move.l %d0,maxaddr 9 | rts 10 | -------------------------------------------------------------------------------- /xinu/sleep.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "proc.h" 4 | #include "q.h" 5 | #include "sleep.h" 6 | 7 | //------------------------------------------------------------------------ 8 | // sleep -- delay the calling process n seconds 9 | //------------------------------------------------------------------------ 10 | SYSCALL 11 | sleep(int n) 12 | { 13 | int ps; 14 | 15 | if (n < 0 || !hasclock) 16 | return SYSERR; 17 | if (n == 0) { 18 | ps = disable(); 19 | resched(); 20 | restore(ps); 21 | return OK; 22 | } 23 | while (n >= 1000) { 24 | sleep10(10000); 25 | n -= 1000; 26 | } 27 | if (n > 0) 28 | sleep10(10 * n); 29 | 30 | return OK; 31 | } 32 | -------------------------------------------------------------------------------- /xinu/sleep10.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "proc.h" 4 | #include "q.h" 5 | #include "sleep.h" 6 | 7 | //------------------------------------------------------------------------ 8 | // sleep10 -- delay the caller for a time specified in tenths of seconds 9 | //------------------------------------------------------------------------ 10 | SYSCALL 11 | sleep10(int n) 12 | { 13 | int ps; 14 | 15 | if (n < 0 || !hasclock) 16 | return SYSERR; 17 | ps = disable(); 18 | if (n > 0) { // sleep10(0) -> end time slice 19 | insertd(currpid, clockq, n); 20 | slnempty = TRUE; 21 | sltop = (int *)&q[q[clockq].qnext].qkey; 22 | proctab[currpid].pstate = PRSLEEP; 23 | } 24 | resched(); 25 | restore(ps); 26 | 27 | return OK; 28 | } 29 | -------------------------------------------------------------------------------- /xinu/sreset.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "proc.h" 4 | #include "q.h" 5 | #include "sem.h" 6 | 7 | //------------------------------------------------------------------------ 8 | // sreset -- reset the count and queue of a semaphore 9 | //------------------------------------------------------------------------ 10 | SYSCALL 11 | sreset(int sem, int count) 12 | { 13 | struct sentry *sptr; 14 | int ps; 15 | int pid; 16 | int slist; 17 | 18 | ps = disable(); 19 | if (isbadsem(sem) || count < 0 || semaph[sem].sstate == SFREE) { 20 | restore(ps); 21 | return SYSERR; 22 | } 23 | sptr = &semaph[sem]; 24 | slist = sptr->sqhead; 25 | while ((pid = getfirst(slist)) != EMPTY) 26 | ready(pid); 27 | sptr->semcnt = count; 28 | resched(); 29 | restore(ps); 30 | 31 | return OK; 32 | } 33 | -------------------------------------------------------------------------------- /xinu/test.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "network.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // main -- start UDP echo server and then run Xinu pseudo-shell 7 | //------------------------------------------------------------------------ 8 | int 9 | main(void) 10 | { 11 | int udpecho(); 12 | 13 | // start rwho daemon and input processes 14 | //rwho(); 15 | 16 | // start UDP echo server 17 | //resume(create(udpecho, 380, 30, "UDPecho", 0)); 18 | 19 | while (TRUE) { 20 | login(CONSOLE); 21 | shell(CONSOLE); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /xinu/ttygetc.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "tty.h" 4 | #include "io.h" 5 | 6 | //------------------------------------------------------------------------ 7 | // ttygetc - read one character from a tty device 8 | //------------------------------------------------------------------------ 9 | int 10 | ttygetc(struct devsw *devptr) 11 | { 12 | int ps; 13 | int ch; 14 | struct tty *iptr; 15 | 16 | ps = disable(); 17 | iptr = &tty[devptr->minor]; 18 | wait(iptr->isem); // wait for a character in buff 19 | ch = LOWBYTE & iptr->ibuff[iptr->itail++]; 20 | if (iptr->itail >= IBUFLEN) 21 | iptr->itail = 0; 22 | if (iptr->ieof && (iptr->ieofc == ch)) 23 | ch = EOF; 24 | restore(ps); 25 | 26 | return ch; 27 | } 28 | -------------------------------------------------------------------------------- /xinu/ttyint.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "tty.h" 4 | #include "io.h" 5 | #include "slu.h" 6 | 7 | INTPROC 8 | ttyint(void *arg) 9 | { 10 | struct tty *tty = (struct tty *)arg; 11 | struct csr *csr = tty->ioaddr; 12 | volatile byte isr = csr->isr; 13 | 14 | if (isr & DUART_TxINTABLE) { 15 | ttyoin(tty); 16 | } 17 | if (isr & DUART_RxINTABLE) { 18 | ttyiin(tty); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /xinu/ttyopen.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | 4 | //------------------------------------------------------------------------ 5 | // ttyopen - open tty device and return descriptor (for namespace) 6 | //------------------------------------------------------------------------ 7 | int 8 | ttyopen(struct devsw *devptr, char *nam, char *mode) 9 | { 10 | 11 | // This routine is not usually used to open tty devices, 12 | // but is provided so that automatic calls to open do not 13 | // fail. It returns SYSERR unless called with a null name 14 | if (*nam != '\0') 15 | return SYSERR; 16 | 17 | return devptr->num; 18 | } 19 | -------------------------------------------------------------------------------- /xinu/ttyputc.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "tty.h" 4 | #include "io.h" 5 | #include "slu.h" 6 | 7 | //------------------------------------------------------------------------ 8 | // ttyputc - write one character to a tty device 9 | //------------------------------------------------------------------------ 10 | int 11 | ttyputc(struct devsw *devptr, int ch) 12 | { 13 | struct tty *iptr; 14 | int ps; 15 | 16 | iptr = &tty[devptr->minor]; 17 | if (ch == NEWLINE && iptr->ocrlf) 18 | ttyputc(devptr, RETURN); 19 | ps = disable(); 20 | wait(iptr->osem); // wait for space in queue 21 | iptr->obuff[iptr->ohead++] = ch; 22 | if (iptr->ohead >= OBUFLEN) 23 | iptr->ohead = 0; 24 | iptr->imr |= DUART_TxINTABLE; 25 | (iptr->ioaddr)->imr = iptr->imr; 26 | restore(ps); 27 | 28 | return OK; 29 | } 30 | -------------------------------------------------------------------------------- /xinu/udpecho.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "network.h" 4 | 5 | #define MAXECHO 600 // maximum size of echoed datagram 6 | static char buff[MAXECHO]; // here because the stack may be small 7 | 8 | //------------------------------------------------------------------------ 9 | // udpecho - UDP echo server process (runs forever in background) 10 | //------------------------------------------------------------------------ 11 | PROCESS 12 | udpecho(void) 13 | { 14 | int dev, len; 15 | 16 | if ((dev = open(INTERNET, ANYFPORT, (void *)UECHO)) == SYSERR) { 17 | kprintf("udpecho: open fails\n"); 18 | return SYSERR; 19 | } 20 | while (TRUE) { 21 | len = read(dev, buff, MAXECHO); 22 | write(dev, buff, len); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /xinu/udpnxtp.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "network.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // udpnxtp - return the next available UDP local "port" number 7 | //------------------------------------------------------------------------ 8 | int 9 | udpnxtp(void) 10 | { 11 | int i; 12 | int try; 13 | Bool inuse; 14 | struct netq *nqptr; 15 | int ps; 16 | 17 | ps = disable(); 18 | for (inuse = TRUE; inuse;) { 19 | inuse = FALSE; 20 | try = Net.nxtprt++; 21 | for (i = 0; i < NETQS; i++) 22 | if ((nqptr = &Net.netqs[i])->valid && 23 | nqptr->uport == try) { 24 | inuse = TRUE; 25 | break; 26 | } 27 | } 28 | restore(ps); 29 | 30 | return try; 31 | } 32 | -------------------------------------------------------------------------------- /xinu/userret.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | 4 | //------------------------------------------------------------------------ 5 | // userret -- entered when a process exits by return 6 | //------------------------------------------------------------------------ 7 | void 8 | userret(void) 9 | { 10 | kill(getpid()); 11 | } 12 | -------------------------------------------------------------------------------- /xinu/wait.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "proc.h" 4 | #include "q.h" 5 | #include "sem.h" 6 | 7 | //------------------------------------------------------------------------ 8 | // wait -- make current process wait on a semaphore 9 | //------------------------------------------------------------------------ 10 | SYSCALL 11 | wait(int sem) 12 | { 13 | int ps; 14 | struct sentry *sptr; 15 | struct pentry *pptr; 16 | 17 | ps = disable(); 18 | if (isbadsem(sem) || (sptr = &semaph[sem])->sstate == SFREE) { 19 | restore(ps); 20 | return SYSERR; 21 | } 22 | if (--(sptr->semcnt) < 0) { 23 | (pptr = &proctab[currpid])->pstate = PRWAIT; 24 | pptr->psem = sem; 25 | enqueue(currpid, sptr->sqtail); 26 | resched(); 27 | } 28 | restore(ps); 29 | 30 | return OK; 31 | } 32 | -------------------------------------------------------------------------------- /xinu/wakeup.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "proc.h" 4 | #include "q.h" 5 | #include "sleep.h" 6 | 7 | //------------------------------------------------------------------------ 8 | // wakeup -- called by clock interrupt dispatcher to awaken processes 9 | //------------------------------------------------------------------------ 10 | INTPROC 11 | wakeup(void) 12 | { 13 | while (nonempty(clockq) && firstkey(clockq) <= 0) 14 | ready(getfirst(clockq)); 15 | if ((slnempty = nonempty(clockq)) != 0) 16 | sltop = (int *)&q[q[clockq].qnext].qkey; 17 | resched(); 18 | } 19 | -------------------------------------------------------------------------------- /xinu/write.c: -------------------------------------------------------------------------------- 1 | #include "conf.h" 2 | #include "kernel.h" 3 | #include "io.h" 4 | 5 | //------------------------------------------------------------------------ 6 | // write - write 1 or more bytes to a device 7 | //------------------------------------------------------------------------ 8 | SYSCALL 9 | write(int descrp, const void *buff, int count) 10 | { 11 | struct devsw *devptr; 12 | 13 | if (isbaddev(descrp)) 14 | return SYSERR; 15 | devptr = &devtab[descrp]; 16 | 17 | return (*devptr->write)(devptr, buff, count); 18 | } 19 | -------------------------------------------------------------------------------- /xinu/xdone.c: -------------------------------------------------------------------------------- 1 | #include "kernel.h" 2 | 3 | //------------------------------------------------------------------------ 4 | // xdone -- print system completion message as last process exits 5 | //------------------------------------------------------------------------ 6 | void 7 | xdone(void) 8 | { 9 | kprintf("\n\nAll user processes have completed.\n\n"); 10 | } 11 | --------------------------------------------------------------------------------