├── .gitignore ├── Caldera-license.pdf ├── LICENSE.txt ├── Makefile ├── README.asciidoc ├── ancient-src ├── bsd211 │ ├── GENERIC │ │ └── ram.h │ ├── h │ │ ├── buf.h │ │ ├── conf.h │ │ ├── dir.h │ │ ├── disk.h │ │ ├── disklabel.h │ │ ├── dk.h │ │ ├── errno.h │ │ ├── exec.h │ │ ├── file.h │ │ ├── fs.h │ │ ├── inode.h │ │ ├── ioctl.h │ │ ├── kernel.h │ │ ├── localopts.h │ │ ├── mount.h │ │ ├── namei.h │ │ ├── param.h │ │ ├── proc.h │ │ ├── resource.h │ │ ├── select.h │ │ ├── signal.h │ │ ├── signalvar.h │ │ ├── stat.h │ │ ├── stddef.h │ │ ├── syslog.h │ │ ├── systm.h │ │ ├── text.h │ │ ├── time.h │ │ ├── trace.h │ │ ├── ttychars.h │ │ ├── ttydev.h │ │ ├── types.h │ │ ├── uio.h │ │ └── user.h │ ├── include │ │ └── fcntl.h │ ├── machine │ │ ├── fperr.h │ │ ├── machparam.h │ │ ├── net_mac.h │ │ └── seg.h │ └── sys │ │ ├── kern_descrip.c │ │ ├── sys_generic.c │ │ ├── sys_inode.c │ │ ├── ufs_alloc.c │ │ ├── ufs_bio.c │ │ ├── ufs_bmap.c │ │ ├── ufs_disksubr.c │ │ ├── ufs_dsort.c │ │ ├── ufs_fio.c │ │ ├── ufs_inode.c │ │ ├── ufs_mount.c │ │ ├── ufs_namei.c │ │ ├── ufs_subr.c │ │ ├── ufs_syscalls.c │ │ ├── ufs_syscalls2.c │ │ └── vfs_vnops.c ├── bsd29 │ ├── dev │ │ └── bio.c │ ├── include │ │ ├── errno.h │ │ ├── sys │ │ │ ├── buf.h │ │ │ ├── conf.h │ │ │ ├── dir.h │ │ │ ├── fblk.h │ │ │ ├── file.h │ │ │ ├── filsys.h │ │ │ ├── fperr.h │ │ │ ├── inline.h │ │ │ ├── ino.h │ │ │ ├── inode.h │ │ │ ├── localopts.h │ │ │ ├── mount.h │ │ │ ├── param.h │ │ │ ├── reg.h │ │ │ ├── stat.h │ │ │ ├── systm.h │ │ │ ├── types.h │ │ │ └── user.h │ │ └── whoami.h │ └── sys │ │ ├── alloc.c │ │ ├── fio.c │ │ ├── iget.c │ │ ├── main.c │ │ ├── nami.c │ │ ├── pipe.c │ │ ├── prf.c │ │ ├── rdwri.c │ │ ├── subr.c │ │ ├── sys2.c │ │ ├── sys3.c │ │ └── sys4.c ├── v6 │ ├── buf.h │ ├── conf.h │ ├── conf │ │ ├── data.s │ │ ├── m40.s │ │ ├── m45.s │ │ ├── mkconf.c │ │ └── sysfix.c │ ├── dmr │ │ ├── bio.c │ │ ├── cat.c │ │ ├── dc.c │ │ ├── dh.c │ │ ├── dhdm.c │ │ ├── dhfdm.c │ │ ├── dn.c │ │ ├── dp.c │ │ ├── hp.c │ │ ├── hs.c │ │ ├── ht.c │ │ ├── kl.c │ │ ├── lp.c │ │ ├── mem.c │ │ ├── partab.c │ │ ├── pc.c │ │ ├── rf.c │ │ ├── rk.c │ │ ├── rp.c │ │ ├── sys.c │ │ ├── tc.c │ │ ├── tm.c │ │ ├── tty.c │ │ ├── vs.c │ │ └── vt.c │ ├── file.h │ ├── filsys.h │ ├── ino.h │ ├── inode.h │ ├── ken │ │ ├── alloc.c │ │ ├── clock.c │ │ ├── fio.c │ │ ├── iget.c │ │ ├── main.c │ │ ├── malloc.c │ │ ├── nami.c │ │ ├── pipe.c │ │ ├── prf.c │ │ ├── rdwri.c │ │ ├── sig.c │ │ ├── slp.c │ │ ├── subr.c │ │ ├── sys1.c │ │ ├── sys2.c │ │ ├── sys3.c │ │ ├── sys4.c │ │ ├── sysent.c │ │ ├── text.c │ │ └── trap.c │ ├── param.h │ ├── proc.h │ ├── reg.h │ ├── seg.h │ ├── systm.h │ ├── text.h │ ├── tty.h │ └── user.h └── v7 │ ├── conf │ ├── c.c │ ├── hphtconf │ ├── hptmconf │ ├── l.s │ ├── makefile │ ├── mch.s │ ├── mch0.s │ ├── mkconf │ ├── mkconf.c │ ├── rkhtconf │ ├── rktmconf │ ├── rp1conf │ ├── rphtconf │ ├── rptmconf │ └── tconf │ ├── dev │ ├── bio.c │ ├── cat.c │ ├── dc.c │ ├── dh.c │ ├── dhdm.c │ ├── dhfdm.c │ ├── dkleave.c │ ├── dn.c │ ├── dsort.c │ ├── du.c │ ├── dz.c │ ├── hp.c │ ├── ht.c │ ├── kl.c │ ├── mem.c │ ├── mklib │ ├── mx1.c │ ├── mx2.c │ ├── partab.c │ ├── pk0.c │ ├── pk1.c │ ├── pk2.c │ ├── pk3.c │ ├── rf.c │ ├── rk.c │ ├── rl.c │ ├── rp.c │ ├── sys.c │ ├── tc.c │ ├── tm.c │ ├── tty.c │ ├── vp.c │ └── vs.c │ ├── h │ ├── acct.h │ ├── buf.h │ ├── callo.h │ ├── conf.h │ ├── dir.h │ ├── fblk.h │ ├── file.h │ ├── filsys.h │ ├── ino.h │ ├── inode.h │ ├── map.h │ ├── mount.h │ ├── mpx.h │ ├── mx.h │ ├── pack.h │ ├── param.h │ ├── pk.h │ ├── pk.p │ ├── prim.h │ ├── proc.h │ ├── pwd.h │ ├── reg.h │ ├── seg.h │ ├── smallparam.h │ ├── stat.h │ ├── systm.h │ ├── text.h │ ├── timeb.h │ ├── tty.h │ ├── types.h │ └── user.h │ └── sys │ ├── acct.c │ ├── alloc.c │ ├── clock.c │ ├── fakemx.c │ ├── fio.c │ ├── iget.c │ ├── machdep.c │ ├── main.c │ ├── malloc.c │ ├── mklib │ ├── nami.c │ ├── pipe.c │ ├── prf.c │ ├── prim.c │ ├── rdwri.c │ ├── sig.c │ ├── slp.c │ ├── subr.c │ ├── sys1.c │ ├── sys2.c │ ├── sys3.c │ ├── sys4.c │ ├── sysent.c │ ├── text.c │ ├── trap.c │ └── ureg.c ├── doc ├── retro-fuse-architecture.drawio └── retro-fuse-architecture.png ├── src ├── bsd211adapt.c ├── bsd211adapt.h ├── bsd211fs.c ├── bsd211fs.h ├── bsd211fuse.c ├── bsd211unadapt.h ├── bsd29adapt.c ├── bsd29adapt.h ├── bsd29fs.c ├── bsd29fs.h ├── bsd29fuse.c ├── bsd29unadapt.h ├── dskio.c ├── dskio.h ├── fusecommon.c ├── fusecommon.h ├── idmap.c ├── idmap.h ├── v6adapt.c ├── v6adapt.h ├── v6fs.c ├── v6fs.h ├── v6fuse.c ├── v6unadapt.h ├── v7adapt.c ├── v7adapt.h ├── v7fs.c ├── v7fs.h ├── v7fuse.c └── v7unadapt.h └── test ├── BSD211Tests.py ├── BSD29Tests.py ├── FileIOTests.py ├── FileList.py ├── RetroFuseTestBase.py ├── ShadowedFile.py ├── SimhDrivers.py ├── TestUtils.py ├── V6Tests.py ├── V7Tests.py ├── ancient-cksum ├── cksum-bsd211 ├── cksum-bsd29 ├── cksum-v6 ├── cksum-v6.c ├── cksum-v7 └── cksum-v7.c ├── cksum.py ├── retro-fuse-test.py └── system-images ├── bsd211-test-system-mscp.dsk.gz ├── bsd29-test-system-rl02.dsk.gz ├── v6-test-system-rk05.dsk.gz └── v7-test-system-rp04.dsk.gz /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.d 3 | v[67]fs 4 | bsd2*fs 5 | *.map 6 | *.dsk 7 | .vscode/ 8 | *.code-workspace 9 | __pycache__ -------------------------------------------------------------------------------- /Caldera-license.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaylogue/retro-fuse/3269f8d83bc4957d77d61a5f80049045dd826350/Caldera-license.pdf -------------------------------------------------------------------------------- /ancient-src/bsd211/GENERIC/ram.h: -------------------------------------------------------------------------------- 1 | #define NRAM 0 2 | -------------------------------------------------------------------------------- /ancient-src/bsd211/h/conf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1986 Regents of the University of California. 3 | * All rights reserved. The Berkeley software License Agreement 4 | * specifies the terms and conditions for redistribution. 5 | * 6 | * @(#)conf.h 1.3 (2.11BSD Berkeley) 12/23/92 7 | */ 8 | 9 | /* 10 | * Declaration of block device 11 | * switch. Each entry (row) is 12 | * the only link between the 13 | * main unix code and the driver. 14 | * The initialization of the 15 | * device switches is in the 16 | * file conf.c. 17 | */ 18 | struct bdevsw 19 | { 20 | int16_t (*d_open)(dev_t dev, int16_t flag, int16_t mode); 21 | int16_t (*d_close)(dev_t dev, int16_t flag, int16_t mode); 22 | int16_t (*d_strategy)(struct buf *bp); 23 | int16_t (*d_root)(caddr_t addr); /* XXX root attach routine */ 24 | daddr_t (*d_psize)(dev_t dev); 25 | int16_t d_flags; 26 | }; 27 | 28 | #if defined(KERNEL) && !defined(SUPERVISOR) 29 | extern struct bdevsw bdevsw[]; 30 | #endif 31 | 32 | /* 33 | * Character device switch. 34 | */ 35 | struct cdevsw 36 | { 37 | int16_t (*d_open)(); 38 | int16_t (*d_close)(); 39 | int16_t (*d_read)(); 40 | int16_t (*d_write)(); 41 | int16_t (*d_ioctl)(); 42 | int16_t (*d_stop)(); 43 | struct tty *d_ttys; 44 | int16_t (*d_select)(); 45 | int16_t (*d_strategy)(); 46 | }; 47 | #if defined(KERNEL) && !defined(SUPERVISOR) 48 | extern struct cdevsw cdevsw[]; 49 | #endif 50 | 51 | /* 52 | * tty line control switch. 53 | */ 54 | struct linesw 55 | { 56 | int16_t (*l_open)(); 57 | int16_t (*l_close)(); 58 | int16_t (*l_read)(); 59 | int16_t (*l_write)(); 60 | int16_t (*l_ioctl)(); 61 | int16_t (*l_rint)(); 62 | int16_t (*l_rend)(); 63 | int16_t (*l_meta)(); 64 | int16_t (*l_start)(); 65 | int16_t (*l_modem)(); 66 | }; 67 | #if defined(KERNEL) && !defined(SUPERVISOR) 68 | extern struct linesw linesw[]; 69 | #endif 70 | -------------------------------------------------------------------------------- /ancient-src/bsd211/h/dk.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1982, 1986 Regents of the University of California. 3 | * All rights reserved. The Berkeley software License Agreement 4 | * specifies the terms and conditions for redistribution. 5 | * 6 | * @(#)dk.h 7.1 (Berkeley) 6/4/86 7 | */ 8 | 9 | /* 10 | * Instrumentation 11 | */ 12 | #define CPUSTATES 4 13 | 14 | #define CP_USER 0 15 | #define CP_NICE 1 16 | #define CP_SYS 2 17 | #define CP_IDLE 3 18 | 19 | #define DK_NDRIVE 10 20 | 21 | #if defined(KERNEL) && defined(UCB_METER) && !defined(SUPERVISOR) 22 | long cp_time[CPUSTATES]; /* number of ticks spent in each cpu state */ 23 | int dk_ndrive; /* number of drives being monitored */ 24 | int dk_busy; /* bit array of drive busy flags */ 25 | long dk_time[DK_NDRIVE]; /* ticks spent with drive busy */ 26 | long dk_seek[DK_NDRIVE]; /* number of seeks */ 27 | long dk_xfer[DK_NDRIVE]; /* number of transfers */ 28 | long dk_wds[DK_NDRIVE]; /* number of clicks transfered */ 29 | long dk_wps[DK_NDRIVE]; /* words per second */ 30 | char *dk_name[DK_NDRIVE]; /* names of monitored drives */ 31 | int dk_unit[DK_NDRIVE]; /* unit numbers of monitored drives */ 32 | int dk_n; /* number of dk numbers assigned so far */ 33 | 34 | long tk_nin; /* number of tty characters input */ 35 | long tk_nout; /* number of tty characters output */ 36 | #endif 37 | -------------------------------------------------------------------------------- /ancient-src/bsd211/h/exec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1986 Regents of the University of California. 3 | * All rights reserved. The Berkeley software License Agreement 4 | * specifies the terms and conditions for redistribution. 5 | * 6 | * @(#)exec.h 1.2 (2.11BSD GTE) 10/31/93 7 | */ 8 | 9 | #ifndef _EXEC_ 10 | #define _EXEC_ 11 | /* 12 | * Header prepended to each a.out file. 13 | */ 14 | struct exec { 15 | int a_magic; /* magic number */ 16 | unsigned int a_text; /* size of text segment */ 17 | unsigned int a_data; /* size of initialized data */ 18 | unsigned int a_bss; /* size of uninitialized data */ 19 | unsigned int a_syms; /* size of symbol table */ 20 | unsigned int a_entry; /* entry point */ 21 | unsigned int a_unused; /* not used */ 22 | unsigned int a_flag; /* relocation info stripped */ 23 | }; 24 | 25 | #define NOVL 15 /* number of overlays */ 26 | struct ovlhdr { 27 | int max_ovl; /* maximum overlay size */ 28 | unsigned int ov_siz[NOVL]; /* size of i'th overlay */ 29 | }; 30 | 31 | /* 32 | * eXtended header definition for use with the new macros in a.out.h 33 | */ 34 | struct xexec { 35 | struct exec e; 36 | struct ovlhdr o; 37 | }; 38 | 39 | #define A_MAGIC1 0407 /* normal */ 40 | #define A_MAGIC2 0410 /* read-only text */ 41 | #define A_MAGIC3 0411 /* separated I&D */ 42 | #define A_MAGIC4 0405 /* overlay */ 43 | #define A_MAGIC5 0430 /* auto-overlay (nonseparate) */ 44 | #define A_MAGIC6 0431 /* auto-overlay (separate) */ 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /ancient-src/bsd211/h/file.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1986 Regents of the University of California. 3 | * All rights reserved. The Berkeley software License Agreement 4 | * specifies the terms and conditions for redistribution. 5 | * 6 | * @(#)file.h 1.3 (2.11BSD GTE) 1/19/95 7 | */ 8 | 9 | #include 10 | 11 | #ifndef _SYS_FILE_H_ 12 | #define _SYS_FILE_H_ 13 | 14 | /* 15 | * Descriptor table entry. 16 | * One for each kernel object. 17 | */ 18 | struct file { 19 | int16_t f_flag; /* see below */ 20 | char f_type; /* descriptor type */ 21 | u_char f_count; /* reference count */ 22 | int16_t f_msgcount; /* references from message queue */ 23 | union { 24 | caddr_t f_Data; 25 | struct socket *f_Socket; 26 | } f_un; 27 | off_t f_offset; 28 | }; 29 | 30 | #ifdef KERNEL 31 | struct fileops { 32 | int16_t (*fo_rw)(); 33 | int16_t (*fo_ioctl)(); 34 | int16_t (*fo_select)(); 35 | int16_t (*fo_close)(); 36 | }; 37 | 38 | #define f_data f_un.f_Data 39 | #define f_socket f_un.f_Socket 40 | 41 | #ifndef SUPERVISOR 42 | extern struct file file[], *fileNFILE; 43 | extern int16_t nfile; 44 | #endif 45 | 46 | /* UNUSED: struct file *getf(); */ 47 | /* UNUSED: struct file *falloc(); */ 48 | #endif 49 | 50 | /* 51 | * Access call. 52 | */ 53 | #define F_OK 0 /* does file exist */ 54 | #define X_OK 1 /* is it executable by caller */ 55 | #define W_OK 2 /* writable by caller */ 56 | #define R_OK 4 /* readable by caller */ 57 | 58 | /* 59 | * Lseek call. 60 | */ 61 | #define L_SET 0 /* absolute offset */ 62 | #define L_INCR 1 /* relative to current offset */ 63 | #define L_XTND 2 /* relative to end of file */ 64 | 65 | #ifdef KERNEL 66 | #define GETF(fp, fd) { \ 67 | if ((unsigned)(fd) >= NOFILE || ((fp) = u.u_ofile[fd]) == NULL) { \ 68 | u.u_error = EBADF; \ 69 | return; \ 70 | } \ 71 | } 72 | #define DTYPE_INODE 1 /* file */ 73 | #define DTYPE_SOCKET 2 /* communications endpoint */ 74 | #define DTYPE_PIPE 3 /* I don't want to hear it, okay? */ 75 | #endif 76 | #endif /* _SYS_FILE_H_ */ 77 | -------------------------------------------------------------------------------- /ancient-src/bsd211/h/kernel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1986 Regents of the University of California. 3 | * All rights reserved. The Berkeley software License Agreement 4 | * specifies the terms and conditions for redistribution. 5 | * 6 | * @(#)kernel.h 1.3 (2.11BSD GTE) 1997/2/14 7 | */ 8 | 9 | /* 10 | * Global variables for the kernel 11 | */ 12 | 13 | #ifdef SUPERVISOR 14 | /* UNUSED: long startnet; /* start of network data space */ 15 | #else 16 | memaddr malloc(); 17 | 18 | /* 1.1 */ 19 | /* UNUSED: long hostid; */ 20 | /* UNUSED: char hostname[MAXHOSTNAMELEN]; */ 21 | /* UNUSED: int hostnamelen; */ 22 | 23 | /* 1.2 */ 24 | #include 25 | 26 | /* UNUSED: struct timeval boottime; */ 27 | extern struct timeval time; 28 | /* UNUSED: struct timezone tz; /* XXX */ 29 | /* UNUSED: int adjdelta; */ 30 | /* UNUSED: int hz; */ 31 | /* UNUSED: int mshz; /* # milliseconds per hz */ 32 | /* UNUSED: int lbolt; /* awoken once a second */ 33 | /* UNUSED: int realitexpire(); */ 34 | 35 | /* UNUSED: short avenrun[3]; */ 36 | #endif 37 | -------------------------------------------------------------------------------- /ancient-src/bsd211/h/localopts.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by the configuration script sys/conf/config. 3 | * 4 | * It contains a list the kernel options not prepended to the Makefile 5 | * as -Dxxxx commands to the compiler. MAXMEM was moved to param.h leaving 6 | * only EXTERNALITIMES to be placed in localopts.h 7 | */ 8 | 9 | /* UNUSED: #define EXTERNALITIMES 1 */ 10 | -------------------------------------------------------------------------------- /ancient-src/bsd211/h/namei.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1986 Regents of the University of California. 3 | * All rights reserved. The Berkeley software License Agreement 4 | * specifies the terms and conditions for redistribution. 5 | * 6 | * @(#)namei.h 1.3 (2.11BSD) 1997/1/18 7 | */ 8 | 9 | #ifndef _NAMEI_ 10 | #define _NAMEI_ 11 | 12 | #ifdef KERNEL 13 | #include "uio.h" 14 | #else 15 | #include 16 | #endif 17 | 18 | /* 19 | * Encapsulation of namei parameters. 20 | * One of these is located in the u. area to 21 | * minimize space allocated on the kernel stack. 22 | */ 23 | struct nameidata { 24 | caddr_t ni_dirp; /* pathname pointer */ 25 | short ni_nameiop; /* see below */ 26 | short ni_error; /* error return if any */ 27 | off_t ni_endoff; /* end of useful stuff in directory */ 28 | struct inode *ni_pdir; /* inode of parent directory of dirp */ 29 | struct inode *ni_ip; /* inode of dirp */ 30 | enum uio_seg ni_segflg; /* segment flag */ 31 | off_t ni_offset; /* offset in directory */ 32 | u_short ni_count; /* offset of open slot (off_t?) */ 33 | struct direct ni_dent; /* current directory entry */ 34 | }; 35 | 36 | /* 37 | * namei operations and modifiers 38 | */ 39 | #define LOOKUP 0 /* perform name lookup only */ 40 | #define CREATE 1 /* setup for file creation */ 41 | #define DELETE 2 /* setup for file deletion */ 42 | #define LOCKPARENT 0x10 /* see the top of namei */ 43 | #define NOCACHE 0x20 /* name must not be left in cache */ 44 | #define FOLLOW 0x40 /* follow symbolic links */ 45 | #define NOFOLLOW 0x0 /* don't follow symbolic links (pseudo) */ 46 | 47 | #define NDINIT(ndp,op,flags,segflg,namep) {\ 48 | (ndp)->ni_nameiop = op | flags; \ 49 | (ndp)->ni_segflg = segflg; \ 50 | (ndp)->ni_dirp = namep; \ 51 | } 52 | 53 | /* 54 | * This structure describes the elements in the cache of recent 55 | * names looked up by namei. 56 | */ 57 | struct namecache { 58 | struct namecache *nc_forw; /* hash chain, MUST BE FIRST */ 59 | struct namecache *nc_back; /* hash chain, MUST BE FIRST */ 60 | struct namecache *nc_nxt; /* LRU chain */ 61 | struct namecache **nc_prev; /* LRU chain */ 62 | struct inode *nc_ip; /* inode the name refers to */ 63 | ino_t nc_ino; /* ino of parent of name */ 64 | dev_t nc_dev; /* dev of parent of name */ 65 | dev_t nc_idev; /* dev of the name ref'd */ 66 | u_short nc_id; /* referenced inode's id */ 67 | char nc_nlen; /* length of name */ 68 | #define NCHNAMLEN 15 /* maximum name segment length we bother with */ 69 | char nc_name[NCHNAMLEN]; /* segment name */ 70 | }; 71 | #if defined(KERNEL) && !defined(SUPERVISOR) 72 | extern struct namecache *namecache; 73 | extern int16_t nchsize; 74 | #include 75 | extern segm nmidesc; 76 | #endif 77 | 78 | /* 79 | * Stats on usefulness of namei caches. 80 | */ 81 | struct nchstats { 82 | int32_t ncs_goodhits; /* hits that we can reall use */ 83 | int32_t ncs_badhits; /* hits we must drop */ 84 | int32_t ncs_falsehits; /* hits with id mismatch */ 85 | int32_t ncs_miss; /* misses */ 86 | int32_t ncs_long; /* int32_t names that ignore cache */ 87 | int32_t ncs_pass2; /* names found with passes == 2 */ 88 | int32_t ncs_2passes; /* number of times we attempt it */ 89 | }; 90 | #endif 91 | -------------------------------------------------------------------------------- /ancient-src/bsd211/h/resource.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1986 Regents of the University of California. 3 | * All rights reserved. The Berkeley software License Agreement 4 | * specifies the terms and conditions for redistribution. 5 | * 6 | * @(#)resource.h 1.3 (2.11BSD GTE) 1997/2/14 7 | */ 8 | 9 | #ifndef _SYS_RESOURCE_H_ 10 | #define _SYS_RESOURCE_H_ 11 | 12 | /* 13 | * Process priority specifications to get/setpriority. 14 | */ 15 | #define PRIO_MIN -20 16 | #define PRIO_MAX 20 17 | 18 | #define PRIO_PROCESS 0 19 | #define PRIO_PGRP 1 20 | #define PRIO_USER 2 21 | 22 | /* 23 | * Resource utilization information. 24 | */ 25 | 26 | #define RUSAGE_SELF 0 27 | #define RUSAGE_CHILDREN -1 28 | 29 | struct rusage { 30 | struct timeval ru_utime; /* user time used */ 31 | struct timeval ru_stime; /* system time used */ 32 | long ru_maxrss; 33 | #define ru_first ru_ixrss 34 | long ru_ixrss; /* integral shared memory size */ 35 | long ru_idrss; /* integral unshared data " */ 36 | long ru_isrss; /* integral unshared stack " */ 37 | long ru_minflt; /* page reclaims */ 38 | long ru_majflt; /* page faults */ 39 | long ru_ovly; /* overlay changes */ 40 | long ru_nswap; /* swaps */ 41 | long ru_inblock; /* block input operations */ 42 | long ru_oublock; /* block output operations */ 43 | long ru_msgsnd; /* messages sent */ 44 | long ru_msgrcv; /* messages received */ 45 | long ru_nsignals; /* signals received */ 46 | long ru_nvcsw; /* voluntary context switches */ 47 | long ru_nivcsw; /* involuntary " */ 48 | #define ru_last ru_nivcsw 49 | }; 50 | 51 | struct k_rusage { /* KERNEL RUSAGE STRUCTURE */ 52 | #define k_ru_first ru_utime 53 | long ru_utime; /* user time used ('hz' ticks) */ 54 | long ru_stime; /* system time used ('hz' ticks) */ 55 | long ru_ovly; /* overlay changes */ 56 | long ru_nswap; /* swaps */ 57 | long ru_inblock; /* block input operations */ 58 | long ru_oublock; /* block output operations */ 59 | long ru_msgsnd; /* messages sent */ 60 | long ru_msgrcv; /* messages received */ 61 | long ru_nsignals; /* signals received */ 62 | long ru_nvcsw; /* voluntary context switches */ 63 | long ru_nivcsw; /* involuntary " */ 64 | #define k_ru_last ru_nivcsw 65 | }; 66 | 67 | /* 68 | * Resource limits 69 | */ 70 | #define RLIMIT_CPU 0 /* cpu time in milliseconds */ 71 | #define RLIMIT_FSIZE 1 /* maximum file size */ 72 | #define RLIMIT_DATA 2 /* data size */ 73 | #define RLIMIT_STACK 3 /* stack size */ 74 | #define RLIMIT_CORE 4 /* core file size */ 75 | #define RLIMIT_RSS 5 /* resident set size */ 76 | 77 | #define RLIM_NLIMITS 6 /* number of resource limits */ 78 | 79 | #define RLIM_INFINITY 0x7fffffff 80 | 81 | struct rlimit { 82 | long rlim_cur; /* current (soft) limit */ 83 | long rlim_max; /* maximum value for rlim_cur */ 84 | }; 85 | 86 | /* Load average structure. */ 87 | struct loadavg { 88 | short ldavg[3]; 89 | int fscale; 90 | }; 91 | #endif /* !_SYS_RESOURCE_H_ */ 92 | -------------------------------------------------------------------------------- /ancient-src/bsd211/h/select.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1992, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the University of 16 | * California, Berkeley and its contributors. 17 | * 4. Neither the name of the University nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | * 33 | * @(#)select.h 8.2.1 (2.11BSD) 2000/2/28 34 | */ 35 | 36 | #ifndef _SYS_SELECT_H_ 37 | #define _SYS_SELECT_H_ 38 | 39 | #include 40 | 41 | /* 42 | * Select uses bit masks of file descriptors in longs. 43 | * These macros manipulate such bit fields (the filesystem macros use chars). 44 | * FD_SETSIZE may be defined by the user, but the default here 45 | * should be >= NOFILE (param.h). 46 | */ 47 | #ifndef FD_SETSIZE 48 | #define FD_SETSIZE 32 49 | #endif 50 | 51 | typedef long fd_mask; 52 | #define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */ 53 | 54 | typedef struct fd_set { 55 | fd_mask fds_bits[1]; 56 | } fd_set; 57 | 58 | #define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS))) 59 | #define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS))) 60 | #define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS))) 61 | #define FD_ZERO(p) bzero((char *)(p), sizeof(*(p))) 62 | 63 | #ifndef KERNEL 64 | int select(); 65 | int pselect(); 66 | #endif /* !KERNEL */ 67 | 68 | #endif /* !_SYS_SELECT_H_ */ 69 | -------------------------------------------------------------------------------- /ancient-src/bsd211/h/stat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1982, 1986 Regents of the University of California. 3 | * All rights reserved. The Berkeley software License Agreement 4 | * specifies the terms and conditions for redistribution. 5 | * 6 | * @(#)stat.h 7.1.5 (2.11BSD) 1996/09/20 7 | */ 8 | 9 | #ifndef _STAT_H_ 10 | #define _STAT_H_ 11 | 12 | struct stat 13 | { 14 | dev_t st_dev; 15 | ino_t st_ino; 16 | uint16_t st_mode; 17 | int16_t st_nlink; 18 | uid_t st_uid; 19 | gid_t st_gid; 20 | dev_t st_rdev; 21 | off_t st_size; 22 | time_t st_atime; 23 | int16_t st_spare1; 24 | time_t st_mtime; 25 | int16_t st_spare2; 26 | time_t st_ctime; 27 | int16_t st_spare3; 28 | int32_t st_blksize; 29 | int32_t st_blocks; 30 | u_short st_flags; 31 | u_short st_spare4[3]; 32 | }; 33 | 34 | #define S_IFMT 0170000 /* type of file */ 35 | #define S_IFDIR 0040000 /* directory */ 36 | #define S_IFCHR 0020000 /* character special */ 37 | #define S_IFBLK 0060000 /* block special */ 38 | #define S_IFREG 0100000 /* regular */ 39 | #define S_IFLNK 0120000 /* symbolic link */ 40 | #define S_IFSOCK 0140000/* socket */ 41 | #define S_ISUID 0004000 /* set user id on execution */ 42 | #define S_ISGID 0002000 /* set group id on execution */ 43 | #define S_ISVTX 0001000 /* save swapped text even after use */ 44 | #define S_IREAD 0000400 /* read permission, owner */ 45 | #define S_IWRITE 0000200 /* write permission, owner */ 46 | #define S_IEXEC 0000100 /* execute/search permission, owner */ 47 | 48 | /* 49 | * Definitions of flags in mode that are 4.4 compatible. 50 | */ 51 | 52 | #define S_IFIFO 0010000 /* named pipe (fifo) - Not used by 2.11BSD */ 53 | 54 | #define S_IRWXU 0000700 /* RWX mask for owner */ 55 | #define S_IRUSR 0000400 /* R for owner */ 56 | #define S_IWUSR 0000200 /* W for owner */ 57 | #define S_IXUSR 0000100 /* X for owner */ 58 | 59 | #define S_IRWXG 0000070 /* RWX mask for group */ 60 | #define S_IRGRP 0000040 /* R for group */ 61 | #define S_IWGRP 0000020 /* W for group */ 62 | #define S_IXGRP 0000010 /* X for group */ 63 | 64 | #define S_IRWXO 0000007 /* RWX mask for other */ 65 | #define S_IROTH 0000004 /* R for other */ 66 | #define S_IWOTH 0000002 /* W for other */ 67 | #define S_IXOTH 0000001 /* X for other */ 68 | 69 | #define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */ 70 | #define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */ 71 | #define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */ 72 | #define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */ 73 | 74 | /* 75 | * Definitions of flags stored in file flags word. Different from 4.4 because 76 | * 2.11BSD only could afford a u_short for the flags. It is not a great 77 | * inconvenience since there are still 5 bits in each byte available for 78 | * future use. 79 | * 80 | * Super-user and owner changeable flags. 81 | */ 82 | #define UF_SETTABLE 0x00ff /* mask of owner changeable flags */ 83 | #define UF_NODUMP 0x0001 /* do not dump file */ 84 | #define UF_IMMUTABLE 0x0002 /* file may not be changed */ 85 | #define UF_APPEND 0x0004 /* writes to file may only append */ 86 | /* 87 | * Super-user changeable flags. 88 | */ 89 | #define SF_SETTABLE 0xff00 /* mask of superuser changeable flags */ 90 | #define SF_ARCHIVED 0x0100 /* file is archived */ 91 | #define SF_IMMUTABLE 0x0200 /* file may not be changed */ 92 | #define SF_APPEND 0x0400 /* writes to file may only append */ 93 | 94 | #ifdef KERNEL 95 | /* 96 | * Shorthand abbreviations of above. 97 | */ 98 | #define APPEND (UF_APPEND | SF_APPEND) 99 | #define IMMUTABLE (UF_IMMUTABLE | SF_IMMUTABLE) 100 | #endif 101 | 102 | #endif /* !_STAT_H_ */ 103 | -------------------------------------------------------------------------------- /ancient-src/bsd211/h/stddef.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1990, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the University of 16 | * California, Berkeley and its contributors. 17 | * 4. Neither the name of the University nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | * 33 | * @(#)stddef.h 8.1 (Berkeley) 6/2/93 34 | */ 35 | 36 | #ifndef _STDDEF_H_ 37 | #define _STDDEF_H_ 38 | 39 | /* #include */ 40 | 41 | #define offsetof(type, member) ((size_t)((char *)&((type *)0)->member - (char *)0)) 42 | 43 | #endif /* _STDDEF_H_ */ 44 | -------------------------------------------------------------------------------- /ancient-src/bsd211/h/text.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1986 Regents of the University of California. 3 | * All rights reserved. The Berkeley software License Agreement 4 | * specifies the terms and conditions for redistribution. 5 | * 6 | * @(#)text.h 1.2 (2.11BSD GTE) 1/19/95 7 | */ 8 | 9 | #ifndef _SYS_TEXT_H_ 10 | #define _SYS_TEXT_H_ 11 | 12 | /* 13 | * Text structure. XXX REF COUNT should be short 14 | * One allocated per pure 15 | * procedure on swap device. 16 | * Manipulated by text.c 17 | */ 18 | struct text 19 | { 20 | struct text *x_forw; /* forward link in free list */ 21 | struct text **x_back; /* backward link in free list */ 22 | short x_daddr; /* segment's disk address */ 23 | short x_caddr; /* core address, if loaded */ 24 | size_t x_size; /* size (clicks) */ 25 | struct inode *x_iptr; /* inode of prototype */ 26 | u_char x_count; /* reference count */ 27 | u_char x_ccount; /* number of loaded references */ 28 | u_char x_flag; /* traced, written flags */ 29 | char dummy; /* room for one more */ 30 | }; 31 | 32 | #if defined(KERNEL) && !defined(SUPERVISOR) 33 | extern struct text text[], *textNTEXT; 34 | int ntext; 35 | #endif 36 | 37 | #define XTRC 0x01 /* Text may be written, exclusive use */ 38 | #define XWRIT 0x02 /* Text written into, must swap out */ 39 | #define XLOAD 0x04 /* Currently being read from file */ 40 | #define XLOCK 0x08 /* Being swapped in or out */ 41 | #define XWANT 0x10 /* Wanted for swapping */ 42 | #define XPAGI 0x20 /* Page in on demand from inode */ 43 | #define XUNUSED 0x40 /* unused since swapped out for cache */ 44 | 45 | /* arguments to xswap: */ 46 | #define X_OLDSIZE (-1) /* the old size is the same as current */ 47 | #define X_DONTFREE 0 /* save core image (for parent in newproc) */ 48 | #define X_FREECORE 1 /* free core space after swap */ 49 | 50 | /* 51 | * Text table statistics 52 | */ 53 | struct xstats { 54 | u_long alloc; /* calls to xalloc */ 55 | u_long alloc_inuse; /* found in use/sticky */ 56 | u_long alloc_cachehit; /* found in cache */ 57 | u_long alloc_cacheflush; /* flushed cached text */ 58 | u_long alloc_unused; /* flushed unused cached text */ 59 | u_long free; /* calls to xfree */ 60 | u_long free_inuse; /* still in use/sticky */ 61 | u_long free_cache; /* placed in cache */ 62 | u_long free_cacheswap; /* swapped out to place in cache */ 63 | }; 64 | #endif /* _SYS_TEXT_H_ */ 65 | -------------------------------------------------------------------------------- /ancient-src/bsd211/h/time.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1986 Regents of the University of California. 3 | * All rights reserved. The Berkeley software License Agreement 4 | * specifies the terms and conditions for redistribution. 5 | * 6 | * @(#)time.h 1.3 (2.11BSD) 2000/4/21 7 | */ 8 | 9 | #ifndef _SYS_TIME_H_ 10 | #define _SYS_TIME_H_ 11 | 12 | #include 13 | 14 | /* 15 | * Structure returned by gettimeofday(2) system call, 16 | * and used in other calls. 17 | */ 18 | struct timeval { 19 | int32_t tv_sec; /* seconds */ 20 | int32_t tv_usec; /* and microseconds */ 21 | }; 22 | 23 | /* 24 | * Structure defined by POSIX.4 to be like a timeval but with nanoseconds 25 | * instead of microseconds. Silly on a PDP-11 but keeping the names the 26 | * same makes life simpler than changing the names. 27 | */ 28 | struct timespec { 29 | time_t tv_sec; /* seconds */ 30 | int32_t tv_nsec; /* and nanoseconds */ 31 | }; 32 | 33 | struct timezone { 34 | int16_t tz_minuteswest; /* minutes west of Greenwich */ 35 | int16_t tz_dsttime; /* type of dst correction */ 36 | }; 37 | #define DST_NONE 0 /* not on dst */ 38 | #define DST_USA 1 /* USA style dst */ 39 | #define DST_AUST 2 /* Australian style dst */ 40 | #define DST_WET 3 /* Western European dst */ 41 | #define DST_MET 4 /* Middle European dst */ 42 | #define DST_EET 5 /* Eastern European dst */ 43 | #define DST_CAN 6 /* Canada */ 44 | 45 | /* 46 | * Operations on timevals. 47 | * 48 | * NB: timercmp does not work for >= or <=. 49 | */ 50 | #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) 51 | #define timercmp(tvp, uvp, cmp) \ 52 | ((tvp)->tv_sec cmp (uvp)->tv_sec || \ 53 | (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec) 54 | #define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0 55 | 56 | /* 57 | * Names of the interval timers, and structure 58 | * defining a timer setting. 59 | */ 60 | #define ITIMER_REAL 0 61 | #define ITIMER_VIRTUAL 1 62 | #define ITIMER_PROF 2 63 | 64 | struct k_itimerval { 65 | int32_t it_interval; /* timer interval */ 66 | int32_t it_value; /* current value */ 67 | }; 68 | 69 | struct itimerval { 70 | struct timeval it_interval; /* timer interval */ 71 | struct timeval it_value; /* current value */ 72 | }; 73 | 74 | #ifndef KERNEL 75 | #include 76 | #endif 77 | 78 | /* 79 | * Getkerninfo clock information structure 80 | */ 81 | struct clockinfo { 82 | int16_t hz; /* clock frequency */ 83 | int16_t tick; /* micro-seconds per hz tick */ 84 | int16_t stathz; /* statistics clock frequency */ 85 | int16_t profhz; /* profiling clock frequency */ 86 | }; 87 | #endif /* !_SYS_TIME_H_ */ 88 | -------------------------------------------------------------------------------- /ancient-src/bsd211/h/trace.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1982, 1986 Regents of the University of California. 3 | * All rights reserved. The Berkeley software License Agreement 4 | * specifies the terms and conditions for redistribution. 5 | * 6 | * @(#)trace.h 7.1 (Berkeley) 6/4/86 7 | */ 8 | 9 | /* 10 | * File system buffer tracing points; all trace 11 | * 12 | * Slipped into 2.10 in about 15 minutes. Bears only a casual 13 | * relationship to the 4.X code, we just used the same names so 14 | * someone could do it right if they felt like it. Note that 15 | * the #defines aren't even sequentially numbered. 16 | */ 17 | #define TR_BREADHIT 0 /* buffer read found in cache */ 18 | #define TR_BREADMISS 1 /* buffer read not in cache */ 19 | #define TR_BWRITE 2 /* buffer written */ 20 | #define TR_BREADHITRA 3 /* buffer read-ahead found in cache */ 21 | #define TR_BREADMISSRA 4 /* buffer read-ahead not in cache */ 22 | #define TR_BRELSE 5 /* brelse */ 23 | #define TR_SWAPIO 6 /* swap i/o request arrives */ 24 | #define TR_NUM_210 7 /* size of array for 2.10BSD 25 | 26 | #define TR_XFODMISS 5 /* exe fod read */ 27 | #define TR_XFODHIT 6 /* exe fod read */ 28 | #define TR_BREALLOC 8 /* expand/contract a buffer */ 29 | 30 | /* 31 | * Memory allocator trace points; all trace the amount of memory involved 32 | */ 33 | #define TR_MALL 10 /* memory allocated */ 34 | 35 | /* 36 | * Paging trace points: all are 37 | */ 38 | #define TR_INTRANS 20 /* page intransit block */ 39 | #define TR_EINTRANS 21 /* page intransit wait done */ 40 | #define TR_FRECLAIM 22 /* reclaim from free list */ 41 | #define TR_RECLAIM 23 /* reclaim from loop */ 42 | #define TR_XSFREC 24 /* reclaim from free list instead of drum */ 43 | #define TR_XIFREC 25 /* reclaim from free list instead of fsys */ 44 | #define TR_WAITMEM 26 /* wait for memory in pagein */ 45 | #define TR_EWAITMEM 27 /* end memory wait in pagein */ 46 | #define TR_ZFOD 28 /* zfod page fault */ 47 | #define TR_EXFOD 29 /* exec fod page fault */ 48 | #define TR_VRFOD 30 /* vread fod page fault */ 49 | #define TR_CACHEFOD 31 /* fod in file system cache */ 50 | #define TR_SWAPIN 32 /* drum page fault */ 51 | #define TR_PGINDONE 33 /* page in done */ 52 | 53 | /* 54 | * System call trace points. 55 | */ 56 | #define TR_VADVISE 40 /* vadvise occurred with */ 57 | 58 | /* 59 | * Miscellaneous 60 | */ 61 | #define TR_STAMP 45 /* user said vtrace(VTR_STAMP, value); */ 62 | 63 | /* 64 | * This defines the size of the trace flags array. 65 | */ 66 | #define TR_NFLAGS 100 /* generous */ 67 | 68 | #define TRCSIZ 4096 69 | 70 | /* 71 | * Specifications of the vtrace() system call, which takes one argument. 72 | */ 73 | #define VTRACE 64+51 74 | 75 | #define VTR_DISABLE 0 /* set a trace flag to 0 */ 76 | #define VTR_ENABLE 1 /* set a trace flag to 1 */ 77 | #define VTR_VALUE 2 /* return value of a trace flag */ 78 | #define VTR_UALARM 3 /* set alarm to go off (sig 16) */ 79 | /* in specified number of hz */ 80 | #define VTR_STAMP 4 /* user specified stamp */ 81 | 82 | #if defined(KERNEL) && defined(UCB_METER) && !defined(SUPERVISOR) 83 | u_long tracebuf[TR_NUM_210]; 84 | #define trace(a) tracebuf[a]++; 85 | #else 86 | #define trace(a) ; 87 | #endif 88 | -------------------------------------------------------------------------------- /ancient-src/bsd211/h/ttychars.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1982, 1986 Regents of the University of California. 3 | * All rights reserved. The Berkeley software License Agreement 4 | * specifies the terms and conditions for redistribution. 5 | * 6 | * @(#)ttychars.h 7.3 (2.11BSD) 2020/1/7 7 | */ 8 | 9 | /* 10 | * User visible structures and constants 11 | * related to terminal handling. 12 | */ 13 | #ifndef _TTYCHARS_ 14 | #define _TTYCHARS_ 15 | struct ttychars { 16 | char tc_erase; /* erase last character */ 17 | char tc_kill; /* erase entire line */ 18 | char tc_intrc; /* interrupt */ 19 | char tc_quitc; /* quit */ 20 | char tc_startc; /* start output */ 21 | char tc_stopc; /* stop output */ 22 | char tc_eofc; /* end-of-file */ 23 | char tc_brkc; /* input delimiter (like nl) */ 24 | char tc_suspc; /* stop process signal */ 25 | char tc_dsuspc; /* delayed stop process signal */ 26 | char tc_rprntc; /* reprint line */ 27 | char tc_flushc; /* flush output (toggles) */ 28 | char tc_werasc; /* word erase */ 29 | char tc_lnextc; /* literal next character */ 30 | }; 31 | 32 | #define CTRL(c) (c&037) 33 | #define _POSIX_VDISABLE ((unsigned char)'\377') 34 | #define CCEQ(val,c) (c == val ? val != _POSIX_VDISABLE : 0) 35 | 36 | /* default special characters */ 37 | #define CERASE 0177 38 | #define CKILL CTRL('u') 39 | #define CINTR CTRL('c') 40 | #define CQUIT 034 /* FS, ^\ */ 41 | #define CSTART CTRL('q') 42 | #define CSTOP CTRL('s') 43 | #define CEOF CTRL('d') 44 | #define CEOT CEOF 45 | #define CBRK _POSIX_VDISABLE 46 | #define CSUSP CTRL('z') 47 | #define CDSUSP CTRL('y') 48 | #define CRPRNT CTRL('r') 49 | #define CFLUSH CTRL('o') 50 | #define CWERASE CTRL('w') 51 | #define CLNEXT CTRL('v') 52 | #endif /* _TTYCHARS_ */ 53 | -------------------------------------------------------------------------------- /ancient-src/bsd211/h/ttydev.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1982, 1986 Regents of the University of California. 3 | * All rights reserved. The Berkeley software License Agreement 4 | * specifies the terms and conditions for redistribution. 5 | * 6 | * @(#)ttydev.h 7.1 (Berkeley) 6/4/86 7 | */ 8 | 9 | /* 10 | * Terminal definitions related to underlying hardware. 11 | */ 12 | #ifndef _TTYDEV_ 13 | #define _TTYDEV_ 14 | 15 | /* 16 | * Speeds 17 | */ 18 | #define B0 0 19 | #define B50 1 20 | #define B75 2 21 | #define B110 3 22 | #define B134 4 23 | #define B150 5 24 | #define B200 6 25 | #define B300 7 26 | #define B600 8 27 | #define B1200 9 28 | #define B1800 10 29 | #define B2400 11 30 | #define B4800 12 31 | #define B9600 13 32 | #define EXTA 14 33 | #define EXTB 15 34 | 35 | #ifdef KERNEL 36 | /* 37 | * Hardware bits. 38 | * SHOULD NOT BE HERE. 39 | */ 40 | #define DONE 0200 41 | #define IENABLE 0100 42 | 43 | /* 44 | * Modem control commands. 45 | */ 46 | #define DMSET 0 47 | #define DMBIS 1 48 | #define DMBIC 2 49 | #define DMGET 3 50 | #endif 51 | #endif 52 | -------------------------------------------------------------------------------- /ancient-src/bsd211/h/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1986 Regents of the University of California. 3 | * All rights reserved. The Berkeley software License Agreement 4 | * specifies the terms and conditions for redistribution. 5 | * 6 | * @(#)types.h 1.4.1 (2.11BSD) 2000/2/28 7 | */ 8 | 9 | #ifndef _TYPES_ 10 | #define _TYPES_ 11 | 12 | /* 13 | * Basic system types and major/minor device constructing/busting macros. 14 | */ 15 | 16 | /* major part of a device */ 17 | #define major(x) ((int16_t)(((int16_t)(x)>>8)&0377)) 18 | 19 | /* minor part of a device */ 20 | #define minor(x) ((int16_t)((x)&0377)) 21 | 22 | /* make a device number */ 23 | #define makedev(x,y) ((dev_t)(((x)<<8) | (y))) 24 | 25 | typedef unsigned char u_char; 26 | typedef uint16_t u_short; 27 | typedef uint16_t u_int; 28 | typedef uint32_t u_long; /* see this! unsigned longs at last! */ 29 | typedef uint16_t ushort; /* sys III compat */ 30 | 31 | #ifdef pdp11 32 | typedef struct _physadr { short r[1]; } *physadr; 33 | typedef struct label_t { 34 | int16_t val[8]; /* regs 2-7, __ovno and super SP */ 35 | } label_t; 36 | #endif 37 | typedef struct _quad { int32_t val[2]; } quad; 38 | typedef int32_t daddr_t; 39 | typedef void * caddr_t; 40 | typedef u_short ino_t; 41 | typedef int32_t swblk_t; 42 | typedef u_int size_t; 43 | typedef int16_t ssize_t; 44 | typedef int32_t time_t; 45 | typedef int16_t dev_t; 46 | typedef int32_t off_t; 47 | typedef u_short uid_t; 48 | typedef u_short gid_t; 49 | typedef int16_t pid_t; 50 | typedef u_short mode_t; 51 | 52 | #define NBBY 8 /* number of bits in a byte */ 53 | 54 | #ifndef howmany 55 | #define howmany(x, y) (((x)+((y)-1))/(y)) 56 | #endif 57 | 58 | #include 59 | 60 | typedef char bool_t; /* boolean */ 61 | typedef u_int memaddr; /* core or swap address */ 62 | typedef int32_t ubadr_t; /* unibus address */ 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /ancient-src/bsd211/h/uio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1982, 1986, 1993, 1994 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the University of 16 | * California, Berkeley and its contributors. 17 | * 4. Neither the name of the University nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | * 33 | * @(#)uio.h 8.5.2 (2.11BSD GTE) 12/20/94 34 | * 35 | * Copied from 4.4-Lite and modified for 2.11BSD. Modifications were removal 36 | * of prototypes, limits for dynamic allocation of iovec structs and changing 37 | * uio_resid to u_short from int. 38 | */ 39 | 40 | #ifndef _SYS_UIO_H_ 41 | #define _SYS_UIO_H_ 42 | 43 | /* 44 | * XXX 45 | * iov_base should be a void *. 46 | */ 47 | struct iovec { 48 | char *iov_base; /* Base address. */ 49 | size_t iov_len; /* Length. */ 50 | }; 51 | 52 | enum uio_rw { UIO_READ, UIO_WRITE }; 53 | 54 | /* Segment flag values. */ 55 | enum uio_seg { 56 | UIO_USERSPACE, /* from user data space */ 57 | UIO_SYSSPACE, /* from system space */ 58 | UIO_USERISPACE /* from user I space */ 59 | }; 60 | 61 | struct uio { 62 | struct iovec *uio_iov; 63 | int uio_iovcnt; 64 | off_t uio_offset; 65 | u_short uio_resid; 66 | enum uio_seg uio_segflg; 67 | enum uio_rw uio_rw; 68 | }; 69 | #endif /* !_SYS_UIO_H_ */ 70 | -------------------------------------------------------------------------------- /ancient-src/bsd211/machine/fperr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1986 Regents of the University of California. 3 | * All rights reserved. The Berkeley software License Agreement 4 | * specifies the terms and conditions for redistribution. 5 | * 6 | * @(#)fperr.h 1.2 (2.11BSD) 1997/8/28 7 | */ 8 | 9 | /* 10 | * Structure of the floating point error register save/return 11 | */ 12 | struct fperr { 13 | short f_fec; 14 | caddr_t f_fea; 15 | }; 16 | 17 | /* 18 | * These are not used any where and are present here merely for reference. 19 | * All the of the VAX oriented FP codes were removed from signal.h and the 20 | * kernel. The kernel now passes the unaltered contents of the FEC register to 21 | * the application. The values below were taken from the PDP-11/70 processor 22 | * handbook. 23 | */ 24 | 25 | #ifdef notnow 26 | #define FPE_OPCODE_TRAP 0x2 /* Bad FP opcode */ 27 | #define FPE_FLTDIV_TRAP 0x4 /* FP divide by zero */ 28 | #define FPE_INTOVF_TRAP 0x6 /* FP to INT overflow */ 29 | #define FPE_FLTOVF_TRAP 0x8 /* FP overflow */ 30 | #define FPE_FLTUND_TRAP 0xa /* FP underflow */ 31 | #define FPE_UNDEF_TRAP 0xc /* FP Undefined variable */ 32 | #define FPE_MAINT_TRAP 0xe /* FP Maint trap */ 33 | #endif /* notnow */ 34 | -------------------------------------------------------------------------------- /ancient-src/bsd211/sys/ufs_dsort.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1986 Regents of the University of California. 3 | * All rights reserved. The Berkeley software License Agreement 4 | * specifies the terms and conditions for redistribution. 5 | * 6 | * @(#)ufs_dsort.c 1.1 (2.10BSD Berkeley) 12/1/86 7 | */ 8 | 9 | /* 10 | * generalized seek sort for disk 11 | */ 12 | 13 | #include "param.h" 14 | #include "systm.h" 15 | #include "buf.h" 16 | #include "dk.h" 17 | 18 | disksort(dp, bp) 19 | register struct buf *dp, *bp; 20 | { 21 | register struct buf *ap; 22 | struct buf *tp; 23 | 24 | ap = dp->b_actf; 25 | if (ap == NULL) { 26 | dp->b_actf = bp; 27 | dp->b_actl = bp; 28 | bp->av_forw = NULL; 29 | return; 30 | } 31 | tp = NULL; 32 | for (; ap != NULL; ap = ap->av_forw) { 33 | if ((bp->b_flags&B_READ) && (ap->b_flags&B_READ) == 0) { 34 | if (tp == NULL) 35 | tp = ap; 36 | break; 37 | } 38 | if ((bp->b_flags&B_READ) == 0 && (ap->b_flags&B_READ)) 39 | continue; 40 | if (ap->b_cylin <= bp->b_cylin) 41 | if (tp == NULL || ap->b_cylin >= tp->b_cylin) 42 | tp = ap; 43 | } 44 | if (tp == NULL) 45 | tp = dp->b_actl; 46 | bp->av_forw = tp->av_forw; 47 | tp->av_forw = bp; 48 | if (tp == dp->b_actl) 49 | dp->b_actl = bp; 50 | } 51 | 52 | #ifdef UCB_METER 53 | /* 54 | * Allocate iostat disk monitoring slots for a driver. If slots already 55 | * allocated (*dkn >= 0) or not enough slots left to satisfy request simply 56 | * ignore it. 57 | */ 58 | dk_alloc(dkn, slots, name, wps) 59 | int *dkn; /* pointer to number for iostat */ 60 | int slots; /* number of iostat slots requested */ 61 | char *name; /* name of device */ 62 | long wps; /* words per second transfer rate */ 63 | { 64 | int i; 65 | register char **np; 66 | register int *up; 67 | register long *wp; 68 | 69 | if (*dkn < 0 && dk_n + slots <= DK_NDRIVE) { 70 | /* 71 | * Allocate and initialize the slots 72 | */ 73 | *dkn = dk_n; 74 | np = &dk_name[dk_n]; 75 | up = &dk_unit[dk_n]; 76 | wp = &dk_wps[dk_n]; 77 | dk_n += slots; 78 | 79 | for (i = 0; i < slots; i++) { 80 | *np++ = name; 81 | *up++ = i; 82 | *wp++ = wps; 83 | } 84 | } 85 | } 86 | #endif /* UCB_METER */ 87 | -------------------------------------------------------------------------------- /ancient-src/bsd29/include/sys/buf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Each buffer in the pool is usually doubly linked into 2 lists: 3 | * the device with which it is currently associated (always) 4 | * and also on a list of blocks available for allocation 5 | * for other use (usually). 6 | * The latter list is kept in last-used order, and the two 7 | * lists are doubly linked to make it easy to remove 8 | * a buffer from one list when it was found by 9 | * looking through the other. 10 | * A buffer is on the available list, and is liable 11 | * to be reassigned to another disk block, if and only 12 | * if it is not marked BUSY. When a buffer is busy, the 13 | * available-list pointers can be used for other purposes. 14 | * Most drivers use the forward ptr as a link in their I/O 15 | * active queue. 16 | * A buffer header contains all the information required 17 | * to perform I/O. 18 | * Most of the routines which manipulate these things 19 | * are in bio.c. 20 | */ 21 | struct buf 22 | { 23 | int16_t b_flags; /* see defines below */ 24 | struct buf *b_forw; /* headed by d_tab of conf.c */ 25 | struct buf *b_back; /* " */ 26 | struct buf *av_forw; /* position on free list, */ 27 | struct buf *av_back; /* if not BUSY*/ 28 | dev_t b_dev; /* major+minor device name */ 29 | uint16_t b_bcount; /* transfer count */ 30 | union { 31 | caddr_t b_addr; /* low order core address */ 32 | int16_t *b_words; /* words for clearing */ 33 | struct filsys *b_filsys; /* superblocks */ 34 | struct dinode *b_dino;/* ilist */ 35 | daddr_t *b_daddr; /* indirect block */ 36 | } b_un; 37 | daddr_t b_blkno; /* block # on device */ 38 | char b_xmem; /* high order core address */ 39 | char b_error; /* returned after I/O */ 40 | #ifdef UCB_BHASH 41 | struct buf *b_link; /* hash links for buffer cache */ 42 | #endif 43 | uint16_t b_resid; /* words not transferred after error */ 44 | }; 45 | 46 | #ifdef KERNEL 47 | extern struct buf buf[]; /* The buffer pool itself */ 48 | extern struct buf bfreelist; /* head of available list */ 49 | #endif 50 | 51 | /* 52 | * These flags are kept in b_flags. 53 | */ 54 | #define B_WRITE 0000000 /* non-read pseudo-flag */ 55 | #define B_READ 0000001 /* read when I/O occurs */ 56 | #define B_DONE 0000002 /* transaction finished */ 57 | #define B_ERROR 0000004 /* transaction aborted */ 58 | #define B_BUSY 0000010 /* not on av_forw/back list */ 59 | #define B_PHYS 0000020 /* Physical IO potentially using UNIBUS map */ 60 | #define B_MAP 0000040 /* This block has the UNIBUS map allocated */ 61 | #define B_WANTED 0000100 /* issue wakeup when BUSY goes off */ 62 | #define B_AGE 0000200 /* place at head of free list when freed */ 63 | #define B_ASYNC 0000400 /* don't wait for I/O completion */ 64 | #define B_DELWRI 0001000 /* don't write till block leaves free list */ 65 | #define B_TAPE 0002000 /* this is a magtape (no bdwrite) */ 66 | #define B_RH70 0004000 /* this device is talking to an RH70 */ 67 | #define B_UBAREMAP 0010000 /* buf's addr is UNIBUS virtual, not physical */ 68 | #define B_BAD 0020000 /* diverted to replacement for bad sector */ 69 | 70 | /* 71 | * special redeclarations for 72 | * the head of the queue per 73 | * device driver. 74 | */ 75 | #define b_actf av_forw 76 | #define b_actl av_back 77 | #define b_active b_bcount 78 | #define b_errcnt b_resid 79 | 80 | /* 81 | * redeclaration used by disksort() 82 | */ 83 | #define b_cylin b_resid 84 | 85 | /* arguments to chkphys */ 86 | #define WORD 2 /* doing I/O by word */ 87 | #define BYTE 1 /* doing I/O by byte */ 88 | -------------------------------------------------------------------------------- /ancient-src/bsd29/include/sys/conf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Declaration of block device 3 | * switch. Each entry (row) is 4 | * the only link between the 5 | * main unix code and the driver. 6 | * The initialization of the 7 | * device switches is in the 8 | * file conf.c. 9 | */ 10 | struct bdevsw { 11 | int16_t (*d_open)(dev_t dev, int16_t flag); 12 | int16_t (*d_close)(dev_t dev, int16_t flag); 13 | int16_t (*d_strategy)(struct buf *bp); 14 | void (*d_root)(); /* root attach routine */ 15 | struct buf *d_tab; 16 | }; 17 | #ifdef KERNEL 18 | extern struct bdevsw bdevsw[]; 19 | #endif 20 | 21 | /* 22 | * Character device switch. 23 | */ 24 | struct cdevsw { 25 | int (*d_open)(); 26 | int (*d_close)(); 27 | int (*d_read)(); 28 | int (*d_write)(); 29 | int (*d_ioctl)(); 30 | int (*d_stop)(); 31 | struct tty *d_ttys; 32 | #ifdef UCB_NET 33 | int (*d_select)(); 34 | #endif 35 | }; 36 | #ifdef KERNEL 37 | extern struct cdevsw cdevsw[]; 38 | #endif 39 | 40 | /* 41 | * tty line control switch. 42 | */ 43 | struct linesw { 44 | int (*l_open)(); /* entry to discipline */ 45 | int (*l_close)(); /* exit from discipline */ 46 | int (*l_read)(); /* read routine */ 47 | char *(*l_write)(); /* write routine */ 48 | int (*l_ioctl)(); /* ioctl interface to driver */ 49 | int (*l_input)(); /* received character input */ 50 | int (*l_output)(); /* character output */ 51 | int (*l_modem)(); /* modem control notification */ 52 | }; 53 | #ifdef KERNEL 54 | extern struct linesw linesw[]; 55 | #endif 56 | -------------------------------------------------------------------------------- /ancient-src/bsd29/include/sys/dir.h: -------------------------------------------------------------------------------- 1 | #ifndef DIRSIZ 2 | #define DIRSIZ 14 3 | #endif 4 | struct direct 5 | { 6 | ino_t d_ino; 7 | char d_name[DIRSIZ]; 8 | }; 9 | -------------------------------------------------------------------------------- /ancient-src/bsd29/include/sys/fblk.h: -------------------------------------------------------------------------------- 1 | struct fblk 2 | { 3 | int16_t df_nfree; 4 | daddr_t df_free[NICFREE]; 5 | } __attribute__((packed)); 6 | -------------------------------------------------------------------------------- /ancient-src/bsd29/include/sys/file.h: -------------------------------------------------------------------------------- 1 | /* 2 | * One file structure is allocated 3 | * for each open/creat/pipe call. 4 | * Main use is to hold the read/write 5 | * pointer associated with each open 6 | * file. 7 | */ 8 | struct file 9 | { 10 | char f_flag; 11 | char f_count; /* reference count */ 12 | struct inode *f_inode; /* pointer to inode structure */ 13 | union { 14 | off_t f_offset; /* read/write character pointer */ 15 | struct chan *f_chan; /* mpx channel pointer */ 16 | #ifdef UCB_NET 17 | struct socket *f_Socket; 18 | #endif 19 | } f_un; 20 | }; 21 | #ifdef UCB_NET 22 | #define f_socket f_un.f_Socket 23 | #endif 24 | 25 | #ifdef KERNEL 26 | extern struct file file[]; /* The file table itself */ 27 | #endif 28 | 29 | /* flags */ 30 | #define FREAD 01 31 | #define FWRITE 02 32 | #define FPIPE 04 33 | #ifdef MPX_FILS 34 | #define FMPX 010 35 | #define FMPY 020 36 | #define FMP 030 37 | #endif 38 | #ifdef UCB_NET 39 | #define FSOCKET 040 /* descriptor of a socket */ 40 | #endif 41 | 42 | /* flags supplied to access call */ 43 | #define FACCESS_EXISTS 0x0 /* does file exist? */ 44 | #define FACCESS_EXECUTE 0x1 /* is it executable by caller? */ 45 | #define FACCESS_WRITE 0x2 /* is it writable by caller? */ 46 | #define FACCESS_READ 0x4 /* is it readable by caller? */ 47 | #define F_OK FACCESS_EXISTS 48 | #define X_OK FACCESS_EXECUTE 49 | #define W_OK FACCESS_WRITE 50 | #define R_OK FACCESS_READ 51 | 52 | /* flags supplies to lseek call */ 53 | #define FSEEK_ABSOLUTE 0x0 /* absolute offset */ 54 | #define FSEEK_RELATIVE 0x1 /* relative to current offset */ 55 | #define FSEEK_EOF 0x2 /* relative to end of file */ 56 | #define L_SET FSEEK_ABSOLUTE 57 | #define L_INCR FSEEK_RELATIVE 58 | #define L_XTND FSEEK_EOF 59 | 60 | /* flags supplied to open call */ 61 | #define FATT_RDONLY 0x0 /* open for reading only */ 62 | #define FATT_WRONLY 0x1 /* open for writing only */ 63 | #define FATT_RDWR 0x2 /* open for reading and writing */ 64 | #define O_RDONLY FATT_RDONLY 65 | #define O_WRONLY FATT_WRONLY 66 | #define O_RDWR FATT_RDWR 67 | -------------------------------------------------------------------------------- /ancient-src/bsd29/include/sys/filsys.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Structure of the super-block 3 | */ 4 | struct filsys 5 | { 6 | uint16_t s_isize; /* size in blocks of i-list */ 7 | daddr_t s_fsize; /* size in blocks of entire volume */ 8 | int16_t s_nfree; /* number of addresses in s_free */ 9 | daddr_t s_free[NICFREE]; /* free block list */ 10 | int16_t s_ninode; /* number of i-nodes in s_inode */ 11 | ino_t s_inode[NICINOD]; /* free i-node list */ 12 | char s_flock; /* lock during free list manipulation */ 13 | char s_ilock; /* lock during i-list manipulation */ 14 | char s_fmod; /* super block modified flag */ 15 | char s_ronly; /* mounted read-only flag */ 16 | time_t s_time; /* last super block update */ 17 | daddr_t s_tfree; /* total free blocks*/ 18 | ino_t s_tinode; /* total free inodes */ 19 | int16_t s_dinfo[2]; /* interleave stuff */ 20 | #define s_m s_dinfo[0] 21 | #define s_n s_dinfo[1] 22 | char s_fsmnt[12]; /* ordinary file mounted on */ 23 | ino_t s_lasti; /* start place for circular search */ 24 | ino_t s_nbehind; /* est # free inodes before s_lasti */ 25 | } __attribute__((packed)); 26 | 27 | #ifdef KERNEL 28 | extern struct filsys *getfs(dev_t dev); 29 | #endif 30 | -------------------------------------------------------------------------------- /ancient-src/bsd29/include/sys/fperr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Structure of the floating point error register save/return 3 | */ 4 | 5 | struct fperr 6 | { 7 | short f_fec; 8 | caddr_t f_fea; 9 | }; 10 | 11 | /* 12 | * Bits in the floating point status register 13 | */ 14 | #define FPS_FER 0100000 /* floating error */ 15 | #define FPS_FID 0040000 /* interrupt disable */ 16 | /* bit 13-12 are unused */ 17 | #define FPS_FIUV 0004000 /* interrupt on undefined variable */ 18 | #define FPS_FIU 0002000 /* interrupt on underflow */ 19 | #define FPS_FIV 0001000 /* interrupt on overflow */ 20 | #define FPS_FIC 0000400 /* interrupt on integer conversion error */ 21 | #define FPS_FD 0000200 /* floating double precision mode */ 22 | #define FPS_FL 0000100 /* floating long integer mode */ 23 | #define FPS_FT 0000040 /* floating truncate mode */ 24 | #define FPS_FMM 0000020 /* floating maintenance mode */ 25 | #define FPS_FN 0000010 /* floating negative */ 26 | #define FPS_FZ 0000004 /* floating zero */ 27 | #define FPS_FV 0000002 /* floating overflow */ 28 | #define FPS_FC 0000001 /* floating carry */ 29 | 30 | #define FPS_BITS \ 31 | "\10\20FER\17FID\14FIUV\13FIU\12FIV\11FIC\10FD\7FL\6FT\5FMM\4FN\3FZ\2FV\1FC" 32 | 33 | /* 34 | * Floating point error register codes 35 | */ 36 | #define FEC_FMMT 0000016 /* maintenance mode trap */ 37 | #define FEC_FUV 0000014 /* floating undefined variable */ 38 | #define FEC_FU 0000012 /* floating underflow */ 39 | #define FEC_FV 0000010 /* floating overflow */ 40 | #define FEC_FC 0000006 /* floating integer conversion error */ 41 | #define FEC_FDZ 0000004 /* floating divide by zero */ 42 | #define FEC_FOPER 0000002 /* floating op code error */ 43 | -------------------------------------------------------------------------------- /ancient-src/bsd29/include/sys/inline.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Definitions of inline expansions used for speed, 3 | * and replacements for them if UNFAST is defined. 4 | */ 5 | 6 | #ifndef UNFAST 7 | 8 | #define plock(ip) \ 9 | { \ 10 | while ((ip)->i_flag & ILOCK) { \ 11 | (ip)->i_flag |= IWANT; \ 12 | sleep((caddr_t)(ip), PINOD); \ 13 | } \ 14 | (ip)->i_flag |= ILOCK; \ 15 | } 16 | 17 | #define prele(ip) \ 18 | { \ 19 | (ip)->i_flag &= ~ILOCK; \ 20 | if ((ip)->i_flag&IWANT) { \ 21 | (ip)->i_flag &= ~IWANT; \ 22 | wakeup((caddr_t)(ip)); \ 23 | } \ 24 | } 25 | 26 | /* 27 | * The GETF macro is used in a conditional, e.g. 28 | * if (GETF(fp,fd)) { 29 | * u.u_error = EBADF; 30 | * return; 31 | * } 32 | */ 33 | #define GETF(fp, fd) \ 34 | ((unsigned)(fd) >= NOFILE || ((fp) = u.u_ofile[fd]) == NULL) 35 | 36 | #ifdef UCB_FSFIX 37 | #define IUPDAT(ip, t1, t2, waitfor) { \ 38 | if (ip->i_flag&(IUPD|IACC|ICHG)) \ 39 | iupdat(ip, t1, t2, waitfor); \ 40 | } 41 | #else 42 | #define IUPDAT(ip, t1, t2) { \ 43 | if (ip->i_flag&(IUPD|IACC|ICHG)) \ 44 | iupdat(ip, t1, t2); \ 45 | } 46 | #endif UCB_FSFIX 47 | 48 | #ifndef MENLO_JCL 49 | #define ISSIG(p) ((p)->p_sig && issig()) 50 | #endif MENLO_JCL 51 | 52 | #else UNFAST 53 | 54 | #ifdef UCB_FSFIX 55 | #define IUPDAT(ip, t1, t2, waitfor) iupdat(ip, t1, t2, waitfor) 56 | #else 57 | #define IUPDAT(ip, t1, t2) iupdat(ip, t1, t2) 58 | #endif UCB_FSFIX 59 | 60 | #ifndef MENLO_JCL 61 | #define ISSIG(p) issig(p) 62 | #endif 63 | 64 | #endif UNFAST 65 | 66 | /* 67 | * Other macros that are always used, or replace null routines. 68 | */ 69 | 70 | #ifdef MENLO_JCL 71 | #define ISSIG(p) ((p)->p_sig && \ 72 | ((p)->p_flag&STRC || ((p)->p_sig & ~(p)->p_ignsig)) && issig()) 73 | #endif 74 | 75 | #ifndef INTRLVE 76 | #define dkblock(bp) ((bp)->b_blkno) 77 | #define dkunit(bp) ((minor((bp)->b_dev) >> 3) & 07) 78 | #endif INTRLVE 79 | -------------------------------------------------------------------------------- /ancient-src/bsd29/include/sys/ino.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Inode structure as it appears on 3 | * a disk block. 4 | */ 5 | struct dinode 6 | { 7 | uint16_t di_mode; /* mode and type of file */ 8 | int16_t di_nlink; /* number of links to file */ 9 | int16_t di_uid; /* owner's user id */ 10 | int16_t di_gid; /* owner's group id */ 11 | off_t di_size; /* number of bytes in file */ 12 | char di_addr[40]; /* disk block addresses */ 13 | time_t di_atime; /* time last accessed */ 14 | time_t di_mtime; /* time last modified */ 15 | time_t di_ctime; /* time created */ 16 | } __attribute__((packed)); 17 | 18 | #ifndef UCB_NKB 19 | #define INOPB 8 /* 8 inodes per block */ 20 | /* 21 | * 39 of the address bytes are used; 22 | * 13 addresses of 3 bytes each. 23 | */ 24 | #endif 25 | 26 | #if UCB_NKB == 1 27 | #define INOPB 16 /* 16 inodes per BSIZE block */ 28 | /* 29 | * 21 of the address bytes are used; 30 | * 7 addresses of 3 bytes each. 31 | */ 32 | #endif 33 | -------------------------------------------------------------------------------- /ancient-src/bsd29/include/sys/mount.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mount structure. 3 | * One allocated on every mount. 4 | * Used to hold the super block. 5 | */ 6 | struct mount 7 | { 8 | dev_t m_dev; /* device mounted */ 9 | struct inode *m_inodp; /* pointer to mounted on inode */ 10 | struct filsys m_filsys; /* superblock data */ 11 | }; 12 | 13 | # ifdef KERNEL 14 | extern struct mount mount[]; 15 | # endif 16 | -------------------------------------------------------------------------------- /ancient-src/bsd29/include/sys/reg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Location of the users' stored 3 | * registers relative to R0. 4 | * Usage is u.u_ar0[XX]. 5 | */ 6 | #ifdef MENLO_KOV 7 | #define R0 (0) 8 | #define R1 (-3) 9 | #define R2 (-11) 10 | #define R3 (-10) 11 | #define R4 (-9) 12 | #define R5 (-7) 13 | #define R6 (-4) 14 | #else 15 | #define R0 (0) 16 | #define R1 (-2) 17 | #define R2 (-9) 18 | #define R3 (-8) 19 | #define R4 (-7) 20 | #define R5 (-6) 21 | #define R6 (-3) 22 | #endif 23 | #define R7 (1) 24 | #define PC (1) 25 | #define RPS (2) 26 | -------------------------------------------------------------------------------- /ancient-src/bsd29/include/sys/stat.h: -------------------------------------------------------------------------------- 1 | struct stat 2 | { 3 | dev_t st_dev; 4 | ino_t st_ino; 5 | uint16_t st_mode; 6 | int16_t st_nlink; 7 | int16_t st_uid; 8 | int16_t st_gid; 9 | dev_t st_rdev; 10 | off_t st_size; 11 | time_t st_atime; 12 | time_t st_mtime; 13 | time_t st_ctime; 14 | }; 15 | 16 | #define S_IFMT 0170000 /* type of file */ 17 | #define S_IFCHR 0020000 /* character special */ 18 | #define S_IFMPC 0030000 /* multiplexed char special */ 19 | #define S_IFDIR 0040000 /* directory */ 20 | #define S_IFBLK 0060000 /* block special */ 21 | #define S_IFMPB 0070000 /* multiplexed block special */ 22 | #define S_IFREG 0100000 /* regular */ 23 | #define S_IFLNK 0120000 /* symbolic link */ 24 | #define S_IFQUOT 0140000 /* quota */ 25 | 26 | #define S_ISUID 0004000 /* set user id on execution */ 27 | #define S_ISGID 0002000 /* set group id on execution */ 28 | #define S_ISVTX 0001000 /* save swapped text even after use */ 29 | #define S_IREAD 0000400 /* read permission, owner */ 30 | #define S_IWRITE 0000200 /* write permission, owner */ 31 | #define S_IEXEC 0000100 /* execute/search permission, owner */ 32 | -------------------------------------------------------------------------------- /ancient-src/bsd29/include/sys/types.h: -------------------------------------------------------------------------------- 1 | typedef char bool_t; /* Boolean */ 2 | typedef char * caddr_t; /* virtual core address */ 3 | typedef uint16_t comp_t; /* "floating pt": 3 bits base 8 exp, 13 bits fraction */ 4 | typedef int32_t daddr_t; /* disk address */ 5 | typedef int16_t dev_t; /* device code */ 6 | typedef uint16_t ino_t; /* i-node number */ 7 | #ifdef MENLO_KOV 8 | typedef short label_t[7]; /* regs 2-7 and __ovno */ 9 | #else 10 | typedef int16_t label_t[6]; /* program status */ 11 | #endif 12 | typedef uint16_t memaddr; /* core or swap address */ 13 | typedef int32_t off_t; /* offset in file */ 14 | typedef struct {int16_t r[1];}* physadr; 15 | typedef uint16_t size_t; /* size of process segments */ 16 | typedef int32_t time_t; /* a time */ 17 | typedef int32_t ubadr_t; /* UNIBUS address */ 18 | typedef uint16_t u_short; 19 | /* UNUSED typedef int16_t void; /* Embarassing crock for Ritchie C compiler */ 20 | #ifdef UCB_NET 21 | typedef unsigned short u_int; 22 | typedef long u_long; /* watch out! */ 23 | typedef char u_char; /* watch out! */ 24 | typedef struct fd_set { long fds_bits[1]; } fd_set; 25 | #endif 26 | 27 | /* selectors and constructor for device code */ 28 | #define major(x) (int16_t)(((uint16_t)(x)>>8)) 29 | #define minor(x) (int16_t)((x)&0377) 30 | #define makedev(x,y) (dev_t)((x)<<8|(y)) 31 | -------------------------------------------------------------------------------- /ancient-src/bsd29/include/whoami.h: -------------------------------------------------------------------------------- 1 | #define _WHOAMI /* so param.h won't include us again */ 2 | 3 | #define UNKNOWN 4 | #define PDP11 GENERIC 5 | /* #define NONFP /* if no floating point unit */ 6 | /* #define ENABLE34 /* support the ENABLE/34 board */ 7 | 8 | #ifdef KERNEL 9 | # include "sys/localopts.h" 10 | #else 11 | # include 12 | #endif 13 | -------------------------------------------------------------------------------- /ancient-src/v6/buf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Each buffer in the pool is usually doubly linked into 2 lists: 3 | * the device with which it is currently associated (always) 4 | * and also on a list of blocks available for allocation 5 | * for other use (usually). 6 | * The latter list is kept in last-used order, and the two 7 | * lists are doubly linked to make it easy to remove 8 | * a buffer from one list when it was found by 9 | * looking through the other. 10 | * A buffer is on the available list, and is liable 11 | * to be reassigned to another disk block, if and only 12 | * if it is not marked BUSY. When a buffer is busy, the 13 | * available-list pointers can be used for other purposes. 14 | * Most drivers use the forward ptr as a link in their I/O 15 | * active queue. 16 | * A buffer header contains all the information required 17 | * to perform I/O. 18 | * Most of the routines which manipulate these things 19 | * are in bio.c. 20 | */ 21 | extern struct buf 22 | { 23 | int16_t b_flags; /* see defines below */ 24 | struct buf *b_forw; /* headed by devtab of b_dev */ 25 | struct buf *b_back; /* " */ 26 | struct buf *av_forw; /* position on free list, */ 27 | struct buf *av_back; /* if not BUSY*/ 28 | int16_t b_dev; /* major+minor device name */ 29 | int16_t b_wcount; /* transfer count (usu. words) */ 30 | char *b_addr; /* low order core address */ 31 | char *b_xmem; /* high order core address */ 32 | uint16_t b_blkno; /* block # on device */ 33 | char b_error; /* returned after I/O */ 34 | uint16_t b_resid; /* words not transferred after error */ 35 | } buf[NBUF]; 36 | 37 | /* 38 | * Each block device has a devtab, which contains private state stuff 39 | * and 2 list heads: the b_forw/b_back list, which is doubly linked 40 | * and has all the buffers currently associated with that major 41 | * device; and the d_actf/d_actl list, which is private to the 42 | * device but in fact is always used for the head and tail 43 | * of the I/O queue for the device. 44 | * Various routines in bio.c look at b_forw/b_back 45 | * (notice they are the same as in the buf structure) 46 | * but the rest is private to each device driver. 47 | */ 48 | struct devtab 49 | { 50 | char d_active; /* busy flag */ 51 | char d_errcnt; /* error count (for recovery) */ 52 | struct buf *b_forw; /* first buffer for this dev */ 53 | struct buf *b_back; /* last buffer for this dev */ 54 | struct buf *d_actf; /* head of I/O queue */ 55 | struct buf *d_actl; /* tail of I/O queue */ 56 | }; 57 | 58 | /* 59 | * This is the head of the queue of available 60 | * buffers-- all unused except for the 2 list heads. 61 | */ 62 | extern struct buf bfreelist; 63 | 64 | /* 65 | * These flags are kept in b_flags. 66 | */ 67 | #define B_WRITE 0 /* non-read pseudo-flag */ 68 | #define B_READ 01 /* read when I/O occurs */ 69 | #define B_DONE 02 /* transaction finished */ 70 | #define B_ERROR 04 /* transaction aborted */ 71 | #define B_BUSY 010 /* not on av_forw/back list */ 72 | #define B_PHYS 020 /* Physical IO potentially using UNIBUS map */ 73 | #define B_MAP 040 /* This block has the UNIBUS map allocated */ 74 | #define B_WANTED 0100 /* issue wakeup when BUSY goes off */ 75 | #define B_RELOC 0200 /* no longer used */ 76 | #define B_ASYNC 0400 /* don't wait for I/O completion */ 77 | #define B_DELWRI 01000 /* don't write till block leaves available list */ 78 | -------------------------------------------------------------------------------- /ancient-src/v6/conf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Used to dissect integer device code 3 | * into major (driver designation) and 4 | * minor (driver parameter) parts. 5 | */ 6 | struct devst 7 | { 8 | int8_t d_minor; 9 | int8_t d_major; 10 | }; 11 | 12 | /* 13 | * Declaration of block device 14 | * switch. Each entry (row) is 15 | * the only link between the 16 | * main unix code and the driver. 17 | * The initialization of the 18 | * device switches is in the 19 | * file conf.c. 20 | */ 21 | extern struct bdevsw 22 | { 23 | void (*d_open)(int16_t dev, int16_t flag); 24 | void (*d_close)(int16_t dev, int16_t flag); 25 | void (*d_strategy)(struct buf *bp); 26 | struct devtab *d_tab; 27 | } bdevsw[]; 28 | 29 | /* 30 | * Nblkdev is the number of entries 31 | * (rows) in the block switch. It is 32 | * set in binit/bio.c by making 33 | * a pass over the switch. 34 | * Used in bounds checking on major 35 | * device numbers. 36 | */ 37 | extern int16_t nblkdev; 38 | 39 | /* 40 | * Character device switch. 41 | */ 42 | extern struct cdevsw 43 | { 44 | int16_t (*d_open)(); 45 | int16_t (*d_close)(); 46 | int16_t (*d_read)(); 47 | int16_t (*d_write)(); 48 | int16_t (*d_sgtty)(); 49 | } cdevsw[]; 50 | 51 | /* 52 | * Number of character switch entries. 53 | * Set by cinit/tty.c 54 | */ 55 | extern int16_t nchrdev; 56 | -------------------------------------------------------------------------------- /ancient-src/v6/conf/data.s: -------------------------------------------------------------------------------- 1 | / l45.o needs to be in data space 2 | / to get l45.o; as data.s l.s 3 | .data 4 | -------------------------------------------------------------------------------- /ancient-src/v6/conf/sysfix.c: -------------------------------------------------------------------------------- 1 | /* 2 | * fix system image for I/D space 3 | * Move data down to 0; move text to 4K. 4 | * Also put the data at the start of the 5 | * file and the text after it. 6 | */ 7 | 8 | int tbuf[259]; 9 | int rbuf[259]; 10 | int obuf[259]; 11 | int txtsiz; 12 | int datsiz; 13 | int bsssiz; 14 | int symsiz; 15 | 16 | int txtrel 8192; 17 | int datrel; 18 | 19 | 20 | main(argc, argv) 21 | char **argv; 22 | { 23 | register word, rel, s; 24 | 25 | if (argc<3) { 26 | printf("Arg count\n"); 27 | exit(1); 28 | } 29 | if ((tbuf[0] = open(argv[1], 0)) < 0) { 30 | printf("Input file\n"); 31 | exit(1); 32 | } 33 | rbuf[0] = open(argv[1], 0); 34 | if ((fcreat(argv[2], obuf)) < 0) { 35 | printf("Output file\n"); 36 | exit(1); 37 | } 38 | if (getw(tbuf) != 0407) { 39 | printf("Bad input format\n"); 40 | exit(1); 41 | } 42 | putw(0407, obuf); 43 | txtsiz = getw(tbuf); 44 | datsiz = getw(tbuf); 45 | bsssiz = getw(tbuf); 46 | symsiz = getw(tbuf); 47 | getw(tbuf); 48 | getw(tbuf); 49 | if (getw(tbuf) != 0) { 50 | printf("No relocation bits\n"); 51 | exit(1); 52 | } 53 | putw(txtsiz, obuf); 54 | putw(datsiz, obuf); 55 | putw(bsssiz, obuf); 56 | putw(symsiz, obuf); 57 | putw(0, obuf); 58 | putw(0, obuf); 59 | putw(1, obuf); 60 | datrel = -txtsiz; 61 | /* 62 | * Copy out data first 63 | */ 64 | tbuf[1] = 0; 65 | seek(tbuf[0], 020+txtsiz, 0); 66 | seek(rbuf[0], 020+txtsiz, 0); 67 | seek(rbuf[0], txtsiz, 1); 68 | seek(rbuf[0], datsiz, 1); 69 | s = datsiz >> 1; 70 | while (s--) { 71 | word = getw(tbuf); 72 | rel = getw(rbuf); 73 | if (rel&01) 74 | word =- datrel; 75 | word =+ getrel(rel); 76 | putw(word, obuf); 77 | } 78 | /* 79 | * Now to the text. 80 | */ 81 | rbuf[1] = 0; 82 | tbuf[1] = 0; 83 | seek(rbuf[0], 020+txtsiz, 0); 84 | seek(rbuf[0], datsiz, 1); 85 | seek(tbuf[0], 020, 0); 86 | s = txtsiz >> 1; 87 | while(s--) { 88 | rel = getw(rbuf); 89 | word = getw(tbuf); 90 | if (rel&01) 91 | word =- txtrel; 92 | word =+ getrel(rel); 93 | putw(word, obuf); 94 | } 95 | /* 96 | * The symbol table. 97 | */ 98 | tbuf[1] = 0; 99 | seek(tbuf[0], 020+txtsiz, 0); 100 | seek(tbuf[0], txtsiz, 1); 101 | seek(tbuf[0], datsiz, 1); 102 | seek(tbuf[0], datsiz, 1); 103 | s = symsiz; 104 | while ((s =- 12) >= 0) { 105 | putw(getw(tbuf), obuf); 106 | putw(getw(tbuf), obuf); 107 | putw(getw(tbuf), obuf); 108 | putw(getw(tbuf), obuf); 109 | rel = getw(tbuf); 110 | putw(rel, obuf); 111 | word = getw(tbuf); 112 | switch(rel&07) { 113 | case 2: 114 | word =+ txtrel; 115 | break; 116 | 117 | case 3: 118 | case 4: 119 | word =+ datrel; 120 | } 121 | putw(word, obuf); 122 | } 123 | fflush(obuf); 124 | close(obuf[0]); 125 | exit(0); 126 | } 127 | 128 | getrel(r) 129 | { 130 | switch (r&016) { 131 | 132 | case 02: /* ref to text */ 133 | return(txtrel); 134 | 135 | case 04: /* ref to data */ 136 | case 06: /* ref to bss */ 137 | return(datrel); 138 | 139 | case 0: 140 | return(0); 141 | 142 | default: 143 | printf("Bad relocation %o\n", r); 144 | return(0); 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /ancient-src/v6/dmr/cat.c: -------------------------------------------------------------------------------- 1 | # 2 | /* 3 | */ 4 | 5 | /* 6 | * GP DR11C driver used for C/A/T 7 | */ 8 | 9 | #include "../param.h" 10 | #include "../user.h" 11 | #include "../tty.h" 12 | 13 | #define CATADDR 0167750 14 | #define PCAT 9 15 | #define CATHIWAT 60 16 | #define CATLOWAT 15 17 | 18 | struct { 19 | int catlock; 20 | struct clist oq; 21 | } cat; 22 | 23 | struct { 24 | int catcsr; 25 | int catbuf; 26 | }; 27 | 28 | ctopen(dev) 29 | { 30 | if (cat.catlock==0) { 31 | cat.catlock++; 32 | CATADDR->catcsr =| IENABLE; 33 | } else 34 | u.u_error = ENXIO; 35 | } 36 | 37 | ctclose() 38 | { 39 | cat.catlock = 0; 40 | } 41 | 42 | ctwrite(dev) 43 | { 44 | register c; 45 | extern lbolt; 46 | 47 | while ((c=cpass()) >= 0) { 48 | spl5(); 49 | while (cat.oq.c_cc > CATHIWAT) 50 | sleep(&cat.oq, PCAT); 51 | while (putc(c, &cat.oq) < 0) 52 | sleep(&lbolt, PCAT); 53 | catintr(); 54 | spl0(); 55 | } 56 | } 57 | 58 | catintr() 59 | { 60 | register int c; 61 | 62 | if (CATADDR->catcsr&DONE && (c=getc(&cat.oq))>=0) { 63 | CATADDR->catbuf = c; 64 | if (cat.oq.c_cc==0 || cat.oq.c_cc==CATLOWAT) 65 | wakeup(&cat.oq); 66 | } else { 67 | if (cat.catlock==0) 68 | CATADDR->catcsr = 0; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /ancient-src/v6/dmr/dhdm.c: -------------------------------------------------------------------------------- 1 | # 2 | /* 3 | */ 4 | 5 | /* 6 | * DM-BB driver 7 | */ 8 | #include "../param.h" 9 | #include "../tty.h" 10 | #include "../conf.h" 11 | 12 | #define DMADDR 0170500 13 | 14 | struct tty dh11[]; 15 | int ndh11; /* Set by dh.c to number of lines */ 16 | 17 | #define DONE 0200 18 | #define SCENABL 040 19 | #define CLSCAN 01000 20 | #define TURNON 07 /* RQ send, CD lead, line enable */ 21 | #define TURNOFF 1 /* line enable only */ 22 | #define CARRIER 0100 23 | 24 | struct dmregs { 25 | int dmcsr; 26 | int dmlstat; 27 | }; 28 | 29 | /* 30 | * Turn on the line associated with the (DH) device dev. 31 | */ 32 | dmopen(dev) 33 | { 34 | register struct tty *tp; 35 | 36 | tp = &dh11[dev.d_minor]; 37 | DMADDR->dmcsr = dev.d_minor; 38 | DMADDR->dmlstat = TURNON; 39 | if (DMADDR->dmlstat&CARRIER) 40 | tp->t_state =| CARR_ON; 41 | DMADDR->dmcsr = IENABLE|SCENABL; 42 | spl5(); 43 | while ((tp->t_state&CARR_ON)==0) 44 | sleep(&tp->t_rawq, TTIPRI); 45 | spl0(); 46 | } 47 | 48 | /* 49 | * If a DH line has the HUPCL mode, 50 | * turn off carrier when it is closed. 51 | */ 52 | dmclose(dev) 53 | { 54 | register struct tty *tp; 55 | 56 | tp = &dh11[dev.d_minor]; 57 | if (tp->t_flags&HUPCL) { 58 | DMADDR->dmcsr = dev.d_minor; 59 | DMADDR->dmlstat = TURNOFF; 60 | DMADDR->dmcsr = IENABLE|SCENABL; 61 | } 62 | } 63 | 64 | /* 65 | * DM11 interrupt. 66 | * Mainly, deal with carrier transitions. 67 | */ 68 | dmint() 69 | { 70 | register struct tty *tp; 71 | 72 | if (DMADDR->dmcsr&DONE) { 73 | tp = &dh11[DMADDR->dmcsr&017]; 74 | if (tp < &dh11[ndh11]) { 75 | wakeup(tp); 76 | if ((DMADDR->dmlstat&CARRIER)==0) { 77 | if ((tp->t_state&WOPEN)==0) { 78 | signal(tp, SIGHUP); 79 | DMADDR->dmlstat = 0; 80 | flushtty(tp); 81 | } 82 | tp->t_state =& ~CARR_ON; 83 | } else 84 | tp->t_state =| CARR_ON; 85 | } 86 | DMADDR->dmcsr = IENABLE|SCENABL; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /ancient-src/v6/dmr/dhfdm.c: -------------------------------------------------------------------------------- 1 | # 2 | /* 3 | */ 4 | 5 | /* 6 | * DM-BB fake driver 7 | */ 8 | #include "../tty.h" 9 | #include "../conf.h" 10 | 11 | struct tty dh11[]; 12 | 13 | dmopen(dev) 14 | { 15 | register struct tty *tp; 16 | 17 | tp = &dh11[dev.d_minor]; 18 | tp->t_state =| CARR_ON; 19 | } 20 | 21 | dmclose(dev) 22 | { 23 | } 24 | -------------------------------------------------------------------------------- /ancient-src/v6/dmr/dn.c: -------------------------------------------------------------------------------- 1 | # 2 | /* 3 | */ 4 | 5 | /* 6 | * DN-11 ACU interface 7 | */ 8 | 9 | #include "../param.h" 10 | #include "../conf.h" 11 | #include "../user.h" 12 | 13 | struct dn { 14 | struct { 15 | char dn_stat; 16 | char dn_reg; 17 | } dn11[3]; 18 | } 19 | 20 | #define DNADDR 0175200 21 | 22 | #define PWI 00200 23 | #define ACR 00100 24 | #define DLO 0020 25 | #define DONE 0200 26 | #define IENABLE 0100 27 | #define DSS 040 28 | #define PND 020 29 | #define MENABLE 04 30 | #define DPR 02 31 | #define CRQ 01 32 | 33 | #define DNPRI 5 34 | 35 | dnopen(dev, flag) 36 | { 37 | register struct dn *dp; 38 | register int rdev; 39 | 40 | rdev = dev.d_minor; 41 | dp = &DNADDR->dn11[rdev]; 42 | if (dp->dn_reg&(PWI|DLO)) 43 | u.u_error = ENXIO; 44 | else { 45 | DNADDR->dn11[0].dn_stat =| MENABLE; 46 | dp->dn_stat = IENABLE|MENABLE|CRQ; 47 | } 48 | } 49 | 50 | dnclose(dev) 51 | { 52 | DNADDR->dn11[dev.d_minor].dn_stat =& MENABLE; 53 | } 54 | 55 | dnwrite(dev) 56 | { 57 | register struct dn *dp; 58 | register c; 59 | extern lbolt; 60 | 61 | dp = &DNADDR->dn11[dev.d_minor]; 62 | for(;;) { 63 | while ((dp->dn_stat&DONE)==0) 64 | sleep(DNADDR, DNPRI); 65 | dp->dn_stat =& ~DONE; 66 | contin: 67 | if (dp->dn_reg&(PWI|ACR)) { 68 | u.u_error = EIO; 69 | return; 70 | } 71 | if (dp->dn_stat&DSS) 72 | return; 73 | c = 0; 74 | if (u.u_count==0 || (dp->dn_stat&PND)==0 || (c=cpass())<0) 75 | continue; 76 | if (c=='-') { 77 | sleep(&lbolt, DNPRI); 78 | sleep(&lbolt, DNPRI); 79 | goto contin; 80 | } 81 | dp->dn_reg = c-'0'; 82 | dp->dn_stat =| DPR; 83 | } 84 | } 85 | 86 | dnint(dev) 87 | { 88 | wakeup(DNADDR); 89 | } 90 | -------------------------------------------------------------------------------- /ancient-src/v6/dmr/hs.c: -------------------------------------------------------------------------------- 1 | # 2 | /* 3 | */ 4 | 5 | /* 6 | * RS03/04 disk driver 7 | */ 8 | 9 | #include "../param.h" 10 | #include "../buf.h" 11 | #include "../conf.h" 12 | #include "../user.h" 13 | 14 | 15 | struct { 16 | int hscs1; /* Control and Status register 1 */ 17 | int hswc; /* Word count register */ 18 | int hsba; /* UNIBUS address register */ 19 | int hsda; /* Desired address register */ 20 | int hscs2; /* Control and Status register 2 */ 21 | int hsds; /* Drive Status */ 22 | int hser; /* Error register */ 23 | int hsas; /* not used */ 24 | int hsla; /* not used */ 25 | int hsdb; /* not used */ 26 | int hsmr; /* not used */ 27 | int hsdt; /* not used */ 28 | int hsbae; /* 11/70 bus extension */ 29 | }; 30 | 31 | struct devtab hstab; 32 | struct buf rhsbuf; 33 | 34 | #define HSADDR 0172040 35 | 36 | #define ERR 040000 /* hscs1 - composite error */ 37 | 38 | #define GO 01 39 | #define RCLR 010 40 | #define DRY 0200 /* hsds - Drive Ready */ 41 | 42 | hsstrategy(abp) 43 | struct buf *abp; 44 | { 45 | register struct buf *bp; 46 | register mblks; 47 | 48 | bp = abp; 49 | mblks = 1024; /* RJS03 */ 50 | if(bp->b_dev.d_minor >= 8) 51 | mblks = 2048; /* RJS04 */ 52 | if(bp->b_blkno >= mblks) { 53 | bp->b_flags =| B_ERROR; 54 | iodone(bp); 55 | return; 56 | } 57 | bp->av_forw = 0; 58 | spl5(); 59 | if (hstab.d_actf==0) 60 | hstab.d_actf = bp; else 61 | hstab.d_actl->av_forw = bp; 62 | hstab.d_actl = bp; 63 | if (hstab.d_active==0) 64 | hsstart(); 65 | spl0(); 66 | } 67 | 68 | hsstart() 69 | { 70 | register struct buf *bp; 71 | register addr; 72 | 73 | if ((bp = hstab.d_actf) == 0) 74 | return; 75 | hstab.d_active++; 76 | addr = bp->b_blkno; 77 | if(bp->b_dev.d_minor < 8) 78 | addr =<< 1; /* RJS03 */ 79 | HSADDR->hscs2 = bp->b_dev.d_minor & 07; 80 | rhstart(bp, &HSADDR->hsda, addr<<1, &HSADDR->hsbae); 81 | } 82 | 83 | hsintr() 84 | { 85 | register struct buf *bp; 86 | 87 | if (hstab.d_active == 0) 88 | return; 89 | bp = hstab.d_actf; 90 | hstab.d_active = 0; 91 | if(HSADDR->hscs1 & ERR){ /* error bit */ 92 | deverror(bp, HSADDR->hscs2, 0); 93 | HSADDR->hscs1 = RCLR|GO; 94 | if (++hstab.d_errcnt <= 10) { 95 | hsstart(); 96 | return; 97 | } 98 | bp->b_flags =| B_ERROR; 99 | } 100 | hstab.d_errcnt = 0; 101 | hstab.d_actf = bp->av_forw; 102 | iodone(bp); 103 | hsstart(); 104 | } 105 | 106 | hsread(dev) 107 | { 108 | 109 | physio(hsstrategy, &rhsbuf, dev, B_READ); 110 | } 111 | 112 | hswrite(dev) 113 | { 114 | 115 | physio(hsstrategy, &rhsbuf, dev, B_WRITE); 116 | } 117 | -------------------------------------------------------------------------------- /ancient-src/v6/dmr/kl.c: -------------------------------------------------------------------------------- 1 | # 2 | /* 3 | */ 4 | 5 | /* 6 | * KL/DL-11 driver 7 | */ 8 | #include "../param.h" 9 | #include "../conf.h" 10 | #include "../user.h" 11 | #include "../tty.h" 12 | #include "../proc.h" 13 | 14 | /* base address */ 15 | #define KLADDR 0177560 /* console */ 16 | #define KLBASE 0176500 /* kl and dl11-a */ 17 | #define DLBASE 0175610 /* dl-e */ 18 | #define NKL11 1 19 | #define NDL11 0 20 | #define DSRDY 02 21 | #define RDRENB 01 22 | 23 | struct tty kl11[NKL11+NDL11]; 24 | 25 | struct klregs { 26 | int klrcsr; 27 | int klrbuf; 28 | int kltcsr; 29 | int kltbuf; 30 | } 31 | 32 | klopen(dev, flag) 33 | { 34 | register char *addr; 35 | register struct tty *tp; 36 | 37 | if(dev.d_minor >= NKL11+NDL11) { 38 | u.u_error = ENXIO; 39 | return; 40 | } 41 | tp = &kl11[dev.d_minor]; 42 | if (u.u_procp->p_ttyp == 0) { 43 | u.u_procp->p_ttyp = tp; 44 | tp->t_dev = dev; 45 | } 46 | /* 47 | * set up minor 0 to address KLADDR 48 | * set up minor 1 thru NKL11-1 to address from KLBASE 49 | * set up minor NKL11 on to address from DLBASE 50 | */ 51 | addr = KLADDR + 8*dev.d_minor; 52 | if(dev.d_minor) 53 | addr =+ KLBASE-KLADDR-8; 54 | if(dev.d_minor >= NKL11) 55 | addr =+ DLBASE-KLBASE-8*NKL11+8; 56 | tp->t_addr = addr; 57 | if ((tp->t_state&ISOPEN) == 0) { 58 | tp->t_state = ISOPEN|CARR_ON; 59 | tp->t_flags = XTABS|LCASE|ECHO|CRMOD; 60 | tp->t_erase = CERASE; 61 | tp->t_kill = CKILL; 62 | } 63 | addr->klrcsr =| IENABLE|DSRDY|RDRENB; 64 | addr->kltcsr =| IENABLE; 65 | } 66 | 67 | klclose(dev) 68 | { 69 | register struct tty *tp; 70 | 71 | tp = &kl11[dev.d_minor]; 72 | wflushtty(tp); 73 | tp->t_state = 0; 74 | } 75 | 76 | klread(dev) 77 | { 78 | ttread(&kl11[dev.d_minor]); 79 | } 80 | 81 | klwrite(dev) 82 | { 83 | ttwrite(&kl11[dev.d_minor]); 84 | } 85 | 86 | klxint(dev) 87 | { 88 | register struct tty *tp; 89 | 90 | tp = &kl11[dev.d_minor]; 91 | ttstart(tp); 92 | if (tp->t_outq.c_cc == 0 || tp->t_outq.c_cc == TTLOWAT) 93 | wakeup(&tp->t_outq); 94 | } 95 | 96 | klrint(dev) 97 | { 98 | register int c, *addr; 99 | register struct tty *tp; 100 | 101 | tp = &kl11[dev.d_minor]; 102 | addr = tp->t_addr; 103 | c = addr->klrbuf; 104 | addr->klrcsr =| RDRENB; 105 | if ((c&0177)==0) 106 | addr->kltbuf = c; /* hardware botch */ 107 | ttyinput(c, tp); 108 | } 109 | 110 | klsgtty(dev, v) 111 | int *v; 112 | { 113 | register struct tty *tp; 114 | 115 | tp = &kl11[dev.d_minor]; 116 | ttystty(tp, v); 117 | } 118 | -------------------------------------------------------------------------------- /ancient-src/v6/dmr/lp.c: -------------------------------------------------------------------------------- 1 | # 2 | /* 3 | */ 4 | 5 | /* 6 | * LP-11 Line printer driver 7 | */ 8 | 9 | #include "../param.h" 10 | #include "../conf.h" 11 | #include "../user.h" 12 | 13 | #define LPADDR 0177514 14 | 15 | #define IENABLE 0100 16 | #define DONE 0200 17 | 18 | #define LPPRI 10 19 | #define LPLWAT 50 20 | #define LPHWAT 100 21 | #define EJLINE 60 22 | #define MAXCOL 80 23 | 24 | struct { 25 | int lpsr; 26 | int lpbuf; 27 | }; 28 | 29 | struct { 30 | int cc; 31 | int cf; 32 | int cl; 33 | int flag; 34 | int mcc; 35 | int ccc; 36 | int mlc; 37 | } lp11; 38 | 39 | #define CAP 01 /* Set to 0 for 96-char printer, else to 01 */ 40 | #define EJECT 02 41 | #define OPEN 04 42 | #define IND 010 /* Set to 0 for no indent, else to 010 */ 43 | 44 | #define FORM 014 45 | 46 | lpopen(dev, flag) 47 | { 48 | 49 | if(lp11.flag & OPEN || LPADDR->lpsr < 0) { 50 | u.u_error = EIO; 51 | return; 52 | } 53 | lp11.flag =| (IND|EJECT|OPEN); 54 | LPADDR->lpsr =| IENABLE; 55 | lpcanon(FORM); 56 | } 57 | 58 | lpclose(dev, flag) 59 | { 60 | lpcanon(FORM); 61 | lp11.flag = 0; 62 | } 63 | 64 | lpwrite() 65 | { 66 | register int c; 67 | 68 | while ((c=cpass())>=0) 69 | lpcanon(c); 70 | } 71 | 72 | lpcanon(c) 73 | { 74 | register c1, c2; 75 | 76 | c1 = c; 77 | if(lp11.flag&CAP) { 78 | if(c1>='a' && c1<='z') 79 | c1 =+ 'A'-'a'; else 80 | switch(c1) { 81 | 82 | case '{': 83 | c2 = '('; 84 | goto esc; 85 | 86 | case '}': 87 | c2 = ')'; 88 | goto esc; 89 | 90 | case '`': 91 | c2 = '\''; 92 | goto esc; 93 | 94 | case '|': 95 | c2 = '!'; 96 | goto esc; 97 | 98 | case '~': 99 | c2 = '^'; 100 | 101 | esc: 102 | lpcanon(c2); 103 | lp11.ccc--; 104 | c1 = '-'; 105 | } 106 | } 107 | 108 | switch(c1) { 109 | 110 | case '\t': 111 | lp11.ccc = (lp11.ccc+8) & ~7; 112 | return; 113 | 114 | case FORM: 115 | case '\n': 116 | if((lp11.flag&EJECT) == 0 || 117 | lp11.mcc!=0 || lp11.mlc!=0) { 118 | lp11.mcc = 0; 119 | lp11.mlc++; 120 | if(lp11.mlc >= EJLINE && lp11.flag&EJECT) 121 | c1 = FORM; 122 | lpoutput(c1); 123 | if(c1 == FORM) 124 | lp11.mlc = 0; 125 | } 126 | 127 | case '\r': 128 | lp11.ccc = 0; 129 | if(lp11.flag&IND) 130 | lp11.ccc = 8; 131 | return; 132 | 133 | case 010: 134 | if(lp11.ccc > 0) 135 | lp11.ccc--; 136 | return; 137 | 138 | case ' ': 139 | lp11.ccc++; 140 | return; 141 | 142 | default: 143 | if(lp11.ccc < lp11.mcc) { 144 | lpoutput('\r'); 145 | lp11.mcc = 0; 146 | } 147 | if(lp11.ccc < MAXCOL) { 148 | while(lp11.ccc > lp11.mcc) { 149 | lpoutput(' '); 150 | lp11.mcc++; 151 | } 152 | lpoutput(c1); 153 | lp11.mcc++; 154 | } 155 | lp11.ccc++; 156 | } 157 | } 158 | 159 | lpstart() 160 | { 161 | register int c; 162 | 163 | while (LPADDR->lpsr&DONE && (c = getc(&lp11)) >= 0) 164 | LPADDR->lpbuf = c; 165 | } 166 | 167 | lpint() 168 | { 169 | register int c; 170 | 171 | lpstart(); 172 | if (lp11.cc == LPLWAT || lp11.cc == 0) 173 | wakeup(&lp11); 174 | } 175 | 176 | lpoutput(c) 177 | { 178 | if (lp11.cc >= LPHWAT) 179 | sleep(&lp11, LPPRI); 180 | putc(c, &lp11); 181 | spl4(); 182 | lpstart(); 183 | spl0(); 184 | } 185 | -------------------------------------------------------------------------------- /ancient-src/v6/dmr/mem.c: -------------------------------------------------------------------------------- 1 | # 2 | /* 3 | */ 4 | 5 | /* 6 | * Memory special file 7 | * minor device 0 is physical memory 8 | * minor device 1 is kernel memory 9 | * minor device 2 is EOF/RATHOLE 10 | */ 11 | 12 | #include "../param.h" 13 | #include "../user.h" 14 | #include "../conf.h" 15 | #include "../seg.h" 16 | 17 | mmread(dev) 18 | { 19 | register c, bn, on; 20 | int a, d; 21 | 22 | if(dev.d_minor == 2) 23 | return; 24 | do { 25 | bn = lshift(u.u_offset, -6); 26 | on = u.u_offset[1] & 077; 27 | a = UISA->r[0]; 28 | d = UISD->r[0]; 29 | spl7(); 30 | UISA->r[0] = bn; 31 | UISD->r[0] = 077406; 32 | if(dev.d_minor == 1) 33 | UISA->r[0] = (ka6-6)->r[(bn>>7)&07] + (bn & 0177); 34 | c = fuibyte(on); 35 | UISA->r[0] = a; 36 | UISD->r[0] = d; 37 | spl0(); 38 | } while(u.u_error==0 && passc(c)>=0); 39 | } 40 | 41 | mmwrite(dev) 42 | { 43 | register c, bn, on; 44 | int a, d; 45 | 46 | if(dev.d_minor == 2) { 47 | c = u.u_count; 48 | u.u_count = 0; 49 | u.u_base =+ c; 50 | dpadd(u.u_offset, c); 51 | return; 52 | } 53 | for(;;) { 54 | bn = lshift(u.u_offset, -6); 55 | on = u.u_offset[1] & 077; 56 | if ((c=cpass())<0 || u.u_error!=0) 57 | break; 58 | a = UISA->r[0]; 59 | d = UISD->r[0]; 60 | spl7(); 61 | UISA->r[0] = bn; 62 | UISD->r[0] = 077406; 63 | if(dev.d_minor == 1) 64 | UISA->r[0] = (ka6-6)->r[(bn>>7)&07] + (bn & 0177); 65 | suibyte(on, c); 66 | UISA->r[0] = a; 67 | UISD->r[0] = d; 68 | spl0(); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /ancient-src/v6/dmr/partab.c: -------------------------------------------------------------------------------- 1 | /* 2 | */ 3 | 4 | char partab[] { 5 | 0001,0201,0201,0001,0201,0001,0001,0201, 6 | 0202,0004,0003,0205,0005,0206,0201,0001, 7 | 0201,0001,0001,0201,0001,0201,0201,0001, 8 | 0001,0201,0201,0001,0201,0001,0001,0201, 9 | 0200,0000,0000,0200,0000,0200,0200,0000, 10 | 0000,0200,0200,0000,0200,0000,0000,0200, 11 | 0000,0200,0200,0000,0200,0000,0000,0200, 12 | 0200,0000,0000,0200,0000,0200,0200,0000, 13 | 0200,0000,0000,0200,0000,0200,0200,0000, 14 | 0000,0200,0200,0000,0200,0000,0000,0200, 15 | 0000,0200,0200,0000,0200,0000,0000,0200, 16 | 0200,0000,0000,0200,0000,0200,0200,0000, 17 | 0000,0200,0200,0000,0200,0000,0000,0200, 18 | 0200,0000,0000,0200,0000,0200,0200,0000, 19 | 0200,0000,0000,0200,0000,0200,0200,0000, 20 | 0000,0200,0200,0000,0200,0000,0000,0201 21 | }; 22 | -------------------------------------------------------------------------------- /ancient-src/v6/dmr/pc.c: -------------------------------------------------------------------------------- 1 | # 2 | /* 3 | */ 4 | 5 | /* 6 | * PC-11 Paper tape reader/punch driver 7 | */ 8 | 9 | #include "../param.h" 10 | #include "../conf.h" 11 | #include "../user.h" 12 | 13 | #define PCADDR 0177550 14 | 15 | #define CLOSED 0 16 | #define WAITING 1 17 | #define READING 2 18 | #define EOF 3 19 | 20 | #define RDRENB 01 21 | #define IENABLE 0100 22 | #define DONE 0200 23 | #define BUSY 04000 24 | #define ERROR 0100000 25 | 26 | #define PCIPRI 30 27 | #define PCOPRI 40 28 | #define PCOLWAT 50 29 | #define PCOHWAT 100 30 | #define PCIHWAT 250 31 | 32 | struct { 33 | int pcrcsr; 34 | int pcrbuf; 35 | int pcpcsr; 36 | int pcpbuf; 37 | }; 38 | 39 | struct clist { 40 | int cc; 41 | int cf; 42 | int cl; 43 | }; 44 | 45 | struct pc11 { 46 | int pcstate; 47 | struct clist pcin; 48 | struct clist pcout; 49 | } pc11; 50 | 51 | pcopen(dev, flag) 52 | { 53 | extern lbolt; 54 | 55 | if (flag==0) { 56 | if (pc11.pcstate!=CLOSED) { 57 | u.u_error = ENXIO; 58 | return; 59 | } 60 | pc11.pcstate = WAITING; 61 | while(pc11.pcstate==WAITING) { 62 | PCADDR->pcrcsr = IENABLE|RDRENB; 63 | sleep(&lbolt, PCIPRI); 64 | } 65 | } else { 66 | PCADDR->pcpcsr =| IENABLE; 67 | pcleader(); 68 | } 69 | } 70 | 71 | pcclose(dev, flag) 72 | { 73 | if (flag==0) { 74 | spl4(); 75 | while (getc(&pc11.pcin) >= 0); 76 | PCADDR->pcrcsr = 0; 77 | pc11.pcstate = CLOSED; 78 | spl0(); 79 | } else 80 | pcleader(); 81 | } 82 | 83 | pcread() 84 | { 85 | register int c; 86 | 87 | spl4(); 88 | do { 89 | while ((c = getc(&pc11.pcin)) < 0) { 90 | if (pc11.pcstate==EOF) 91 | goto out; 92 | if ((PCADDR->pcrcsr&(ERROR|BUSY|DONE))==0) 93 | PCADDR->pcrcsr =| IENABLE|RDRENB; 94 | sleep(&pc11.pcin, PCIPRI); 95 | } 96 | } while (passc(c)>=0); 97 | out: 98 | spl0(); 99 | } 100 | 101 | pcwrite() 102 | { 103 | register int c; 104 | 105 | while ((c=cpass())>=0) 106 | pcoutput(c); 107 | } 108 | 109 | pcstart() 110 | { 111 | register int c; 112 | 113 | if (PCADDR->pcpcsr&DONE && (c = getc(&pc11.pcout)) >= 0) 114 | PCADDR->pcpbuf = c; 115 | } 116 | 117 | pcrint() 118 | { 119 | if (pc11.pcstate==WAITING) { 120 | if (PCADDR->pcrcsr&ERROR) 121 | return; 122 | pc11.pcstate = READING; 123 | } 124 | if (pc11.pcstate==READING) { 125 | if (PCADDR->pcrcsr&ERROR) 126 | pc11.pcstate = EOF; 127 | else { 128 | putc(PCADDR->pcrbuf, &pc11.pcin); 129 | if (pc11.pcin.cc < PCIHWAT) 130 | PCADDR->pcrcsr =| IENABLE|RDRENB; 131 | } 132 | wakeup(&pc11.pcin); 133 | } 134 | } 135 | 136 | pcpint() 137 | { 138 | 139 | pcstart(); 140 | if (pc11.pcout.cc <= PCOLWAT) 141 | wakeup(&pc11.pcout); 142 | } 143 | 144 | pcoutput(c) 145 | { 146 | if (PCADDR->pcpcsr&ERROR) { 147 | u.u_error = EIO; 148 | return; 149 | } 150 | if (pc11.pcout.cc >= PCOHWAT) 151 | sleep(&pc11.pcout, PCOPRI); 152 | putc(c, &pc11.pcout); 153 | spl4(); 154 | pcstart(); 155 | spl0(); 156 | } 157 | 158 | pcleader() 159 | { 160 | register int i; 161 | 162 | i = 100; 163 | do 164 | pcoutput(0); 165 | while (--i); 166 | } 167 | -------------------------------------------------------------------------------- /ancient-src/v6/dmr/rf.c: -------------------------------------------------------------------------------- 1 | # 2 | /* 3 | */ 4 | 5 | /* 6 | * RF disk driver 7 | */ 8 | 9 | #include "../param.h" 10 | #include "../buf.h" 11 | #include "../conf.h" 12 | #include "../user.h" 13 | 14 | struct { 15 | int rfcs; 16 | int rfwc; 17 | int rfba; 18 | int rfda; 19 | int rfdae; 20 | }; 21 | 22 | struct devtab rftab; 23 | struct buf rrfbuf; 24 | 25 | #define NRFBLK 1024 26 | #define RFADDR 0177460 27 | 28 | #define GO 01 29 | #define RCOM 02 30 | #define WCOM 04 31 | #define CTLCLR 0400 32 | #define IENABLE 0100 33 | 34 | rfstrategy(abp) 35 | struct buf *abp; 36 | { 37 | register struct buf *bp; 38 | 39 | bp = abp; 40 | if(bp->b_flags&B_PHYS) 41 | mapalloc(bp); 42 | if (bp->b_blkno >= NRFBLK*(bp->b_dev.d_minor+1)) { 43 | bp->b_flags =| B_ERROR; 44 | iodone(bp); 45 | return; 46 | } 47 | bp->av_forw = 0; 48 | spl5(); 49 | if (rftab.d_actf==0) 50 | rftab.d_actf = bp; 51 | else 52 | rftab.d_actl->av_forw = bp; 53 | rftab.d_actl = bp; 54 | if (rftab.d_active==0) 55 | rfstart(); 56 | spl0(); 57 | } 58 | 59 | rfstart() 60 | { 61 | register struct buf *bp; 62 | 63 | if ((bp = rftab.d_actf) == 0) 64 | return; 65 | rftab.d_active++; 66 | RFADDR->rfdae = bp->b_blkno.hibyte; 67 | devstart(bp, &RFADDR->rfda, bp->b_blkno<<8, 0); 68 | } 69 | 70 | rfintr() 71 | { 72 | register struct buf *bp; 73 | 74 | if (rftab.d_active == 0) 75 | return; 76 | bp = rftab.d_actf; 77 | rftab.d_active = 0; 78 | if (RFADDR->rfcs < 0) { /* error bit */ 79 | deverror(bp, RFADDR->rfcs, RFADDR->rfdae); 80 | RFADDR->rfcs = CTLCLR; 81 | if (++rftab.d_errcnt <= 10) { 82 | rfstart(); 83 | return; 84 | } 85 | bp->b_flags =| B_ERROR; 86 | } 87 | rftab.d_errcnt = 0; 88 | rftab.d_actf = bp->av_forw; 89 | iodone(bp); 90 | rfstart(); 91 | } 92 | 93 | rfread(dev) 94 | { 95 | 96 | physio(rfstrategy, &rrfbuf, dev, B_READ); 97 | } 98 | 99 | rfwrite(dev) 100 | { 101 | 102 | physio(rfstrategy, &rrfbuf, dev, B_WRITE); 103 | } 104 | -------------------------------------------------------------------------------- /ancient-src/v6/dmr/rk.c: -------------------------------------------------------------------------------- 1 | # 2 | /* 3 | */ 4 | 5 | /* 6 | * RK disk driver 7 | */ 8 | 9 | #include "../param.h" 10 | #include "../buf.h" 11 | #include "../conf.h" 12 | #include "../user.h" 13 | 14 | #define RKADDR 0177400 15 | #define NRK 4 16 | #define NRKBLK 4872 17 | 18 | #define RESET 0 19 | #define GO 01 20 | #define DRESET 014 21 | #define IENABLE 0100 22 | #define DRY 0200 23 | #define ARDY 0100 24 | #define WLO 020000 25 | #define CTLRDY 0200 26 | 27 | struct { 28 | int rkds; 29 | int rker; 30 | int rkcs; 31 | int rkwc; 32 | int rkba; 33 | int rkda; 34 | }; 35 | 36 | struct devtab rktab; 37 | struct buf rrkbuf; 38 | 39 | rkstrategy(abp) 40 | struct buf *abp; 41 | { 42 | register struct buf *bp; 43 | register *qc, *ql; 44 | int d; 45 | 46 | bp = abp; 47 | if(bp->b_flags&B_PHYS) 48 | mapalloc(bp); 49 | d = bp->b_dev.d_minor-7; 50 | if(d <= 0) 51 | d = 1; 52 | if (bp->b_blkno >= NRKBLK*d) { 53 | bp->b_flags =| B_ERROR; 54 | iodone(bp); 55 | return; 56 | } 57 | bp->av_forw = 0; 58 | spl5(); 59 | if (rktab.d_actf==0) 60 | rktab.d_actf = bp; 61 | else 62 | rktab.d_actl->av_forw = bp; 63 | rktab.d_actl = bp; 64 | if (rktab.d_active==0) 65 | rkstart(); 66 | spl0(); 67 | } 68 | 69 | rkaddr(bp) 70 | struct buf *bp; 71 | { 72 | register struct buf *p; 73 | register int b; 74 | int d, m; 75 | 76 | p = bp; 77 | b = p->b_blkno; 78 | m = p->b_dev.d_minor - 7; 79 | if(m <= 0) 80 | d = p->b_dev.d_minor; 81 | else { 82 | d = lrem(b, m); 83 | b = ldiv(b, m); 84 | } 85 | return(d<<13 | (b/12)<<4 | b%12); 86 | } 87 | 88 | rkstart() 89 | { 90 | register struct buf *bp; 91 | 92 | if ((bp = rktab.d_actf) == 0) 93 | return; 94 | rktab.d_active++; 95 | devstart(bp, &RKADDR->rkda, rkaddr(bp), 0); 96 | } 97 | 98 | rkintr() 99 | { 100 | register struct buf *bp; 101 | 102 | if (rktab.d_active == 0) 103 | return; 104 | bp = rktab.d_actf; 105 | rktab.d_active = 0; 106 | if (RKADDR->rkcs < 0) { /* error bit */ 107 | deverror(bp, RKADDR->rker, RKADDR->rkds); 108 | RKADDR->rkcs = RESET|GO; 109 | while((RKADDR->rkcs&CTLRDY) == 0) ; 110 | if (++rktab.d_errcnt <= 10) { 111 | rkstart(); 112 | return; 113 | } 114 | bp->b_flags =| B_ERROR; 115 | } 116 | rktab.d_errcnt = 0; 117 | rktab.d_actf = bp->av_forw; 118 | iodone(bp); 119 | rkstart(); 120 | } 121 | 122 | rkread(dev) 123 | { 124 | 125 | physio(rkstrategy, &rrkbuf, dev, B_READ); 126 | } 127 | 128 | rkwrite(dev) 129 | { 130 | 131 | physio(rkstrategy, &rrkbuf, dev, B_WRITE); 132 | } 133 | -------------------------------------------------------------------------------- /ancient-src/v6/dmr/sys.c: -------------------------------------------------------------------------------- 1 | # 2 | /* 3 | */ 4 | 5 | /* 6 | * indirect driver for controlling tty. 7 | */ 8 | #include "../param.h" 9 | #include "../conf.h" 10 | #include "../user.h" 11 | #include "../tty.h" 12 | #include "../proc.h" 13 | 14 | syopen(dev, flag) 15 | { 16 | register *tp; 17 | 18 | if(tp = syttyp()) 19 | (*cdevsw[tp->t_dev.d_major].d_open)(tp->t_dev, flag); 20 | } 21 | 22 | syread(dev) 23 | { 24 | register *tp; 25 | 26 | if(tp = syttyp()) 27 | (*cdevsw[tp->t_dev.d_major].d_read)(tp->t_dev); 28 | } 29 | 30 | sywrite(dev) 31 | { 32 | register *tp; 33 | 34 | if(tp = syttyp()) 35 | (*cdevsw[tp->t_dev.d_major].d_write)(tp->t_dev); 36 | } 37 | 38 | sysgtty(dev, flag) 39 | { 40 | register *tp; 41 | 42 | if(tp = syttyp()) 43 | (*cdevsw[tp->t_dev.d_major].d_sgtty)(tp->t_dev, flag); 44 | } 45 | 46 | syttyp() 47 | { 48 | register tp; 49 | 50 | tp = u.u_procp->p_ttyp; 51 | if(tp == NULL) 52 | u.u_error = ENXIO; 53 | return(tp); 54 | } 55 | -------------------------------------------------------------------------------- /ancient-src/v6/dmr/tc.c: -------------------------------------------------------------------------------- 1 | # 2 | /* 3 | */ 4 | 5 | /* 6 | * TC-11 DECtape driver 7 | */ 8 | 9 | #include "../param.h" 10 | #include "../conf.h" 11 | #include "../buf.h" 12 | #include "../user.h" 13 | 14 | struct { 15 | int tccsr; 16 | int tccm; 17 | int tcwc; 18 | int tcba; 19 | int tcdt; 20 | }; 21 | 22 | struct devtab tctab; 23 | char tcper[8]; 24 | 25 | #define TCADDR 0177340 26 | #define NTCBLK 578 27 | 28 | #define TAPERR 0100000 29 | #define TREV 04000 30 | #define READY 0200 31 | #define IENABLE 0100 32 | #define UPS 0200 33 | #define ENDZ 0100000 34 | #define BLKM 02000 35 | #define ILGOP 010000 36 | #define SELERR 04000 37 | 38 | #define SAT 0 39 | #define RNUM 02 40 | #define RDATA 04 41 | #define SST 010 42 | #define WDATA 014 43 | #define GO 01 44 | 45 | #define SFORW 1 46 | #define SREV 2 47 | #define SIO 3 48 | 49 | tcclose(dev) 50 | { 51 | bflush(dev); 52 | tcper[dev&07] = 0; 53 | } 54 | 55 | tcstrategy(abp) 56 | struct buf *abp; 57 | { 58 | register struct buf *bp; 59 | 60 | bp = abp; 61 | if(bp->b_flags&B_PHYS) 62 | mapalloc(bp); 63 | if(bp->b_blkno >= NTCBLK || tcper[bp->b_dev&07]) { 64 | bp->b_flags =| B_ERROR; 65 | iodone(bp); 66 | return; 67 | } 68 | bp->av_forw = 0; 69 | spl6(); 70 | if (tctab.d_actf==0) 71 | tctab.d_actf = bp; 72 | else 73 | tctab.d_actl->av_forw = bp; 74 | tctab.d_actl = bp; 75 | if (tctab.d_active==0) 76 | tcstart(); 77 | spl0(); 78 | } 79 | 80 | tcstart() 81 | { 82 | register struct buf *bp; 83 | register int *tccmp, com; 84 | 85 | loop: 86 | tccmp = &TCADDR->tccm; 87 | if ((bp = tctab.d_actf) == 0) 88 | return; 89 | if(tcper[bp->b_dev&07]) { 90 | if((tctab.d_actf = bp->av_forw) == 0) 91 | (*tccmp).lobyte = SAT|GO; 92 | bp->b_flags =| B_ERROR; 93 | iodone(bp); 94 | goto loop; 95 | } 96 | if (((*tccmp).hibyte&07) != bp->b_dev.d_minor) 97 | (*tccmp).lobyte = SAT|GO; 98 | tctab.d_errcnt = 20; 99 | tctab.d_active = SFORW; 100 | com = (bp->b_dev.d_minor<<8) | IENABLE|RNUM|GO; 101 | if ((TCADDR->tccsr & UPS) == 0) { 102 | com =| TREV; 103 | tctab.d_active = SREV; 104 | } 105 | *tccmp = com; 106 | } 107 | 108 | tcintr() 109 | { 110 | register struct buf *bp; 111 | register int *tccmp; 112 | register int *tcdtp; 113 | 114 | tccmp = &TCADDR->tccm; 115 | tcdtp = &TCADDR->tccsr; 116 | bp = tctab.d_actf; 117 | if (*tccmp&TAPERR) { 118 | if((*tcdtp&(ENDZ|BLKM)) == 0) 119 | deverror(bp, *tcdtp, 0); 120 | if(*tcdtp & (ILGOP|SELERR)) { 121 | tcper[bp->b_dev&07]++; 122 | tctab.d_errcnt = 0; 123 | } 124 | *tccmp =& ~TAPERR; 125 | if (--tctab.d_errcnt <= 0) { 126 | bp->b_flags =| B_ERROR; 127 | goto done; 128 | } 129 | if (*tccmp&TREV) { 130 | setforw: 131 | tctab.d_active = SFORW; 132 | *tccmp =& ~TREV; 133 | } else { 134 | setback: 135 | tctab.d_active = SREV; 136 | *tccmp =| TREV; 137 | } 138 | (*tccmp).lobyte = IENABLE|RNUM|GO; 139 | return; 140 | } 141 | tcdtp = &TCADDR->tcdt; 142 | switch (tctab.d_active) { 143 | 144 | case SIO: 145 | done: 146 | tctab.d_active = 0; 147 | if (tctab.d_actf = bp->av_forw) 148 | tcstart(); 149 | else 150 | TCADDR->tccm.lobyte = SAT|GO; 151 | iodone(bp); 152 | return; 153 | 154 | case SFORW: 155 | if (*tcdtp > bp->b_blkno) 156 | goto setback; 157 | if (*tcdtp < bp->b_blkno) 158 | goto setforw; 159 | *--tcdtp = bp->b_addr; /* core address */ 160 | *--tcdtp = bp->b_wcount; 161 | tccmp->lobyte = ((bp->b_xmem & 03) << 4) | IENABLE|GO 162 | | (bp->b_flags&B_READ?RDATA:WDATA); 163 | tctab.d_active = SIO; 164 | return; 165 | 166 | case SREV: 167 | if (*tcdtp+3 > bp->b_blkno) 168 | goto setback; 169 | goto setforw; 170 | } 171 | } 172 | -------------------------------------------------------------------------------- /ancient-src/v6/dmr/vs.c: -------------------------------------------------------------------------------- 1 | # 2 | /* 3 | */ 4 | 5 | /* 6 | * Screw Works interface via DC-11 7 | */ 8 | 9 | #include "../tty.h" 10 | 11 | #define VSADDR 0174150 12 | #define CDLEAD 01 13 | #define B1200 030 14 | #define STOP1 0400 15 | #define CLSEND 02 16 | #define RQSEND 01 17 | 18 | #define MAGIC_MAP 0377 19 | 20 | struct { 21 | int vsrcsr; 22 | int vsrbuf; 23 | int vsxcsr; 24 | int vsxbuf; 25 | }; 26 | 27 | struct { 28 | struct clist iq; 29 | struct clist oq; 30 | } vs; 31 | 32 | vsopen(dev) 33 | { 34 | VSADDR->vsrcsr = IENABLE|B1200|CDLEAD; 35 | VSADDR->vsxcsr = STOP1|IENABLE|B1200; 36 | vschar(0); 37 | } 38 | 39 | vsclose(dev) 40 | { 41 | vschar(0); 42 | VSADDR->vsrcsr =& ~IENABLE; 43 | while (getc(&vs.iq) >= 0); 44 | } 45 | 46 | vswrite(dev) 47 | { 48 | register int count, c; 49 | 50 | count = 0; 51 | while ((c=cpass()) >= 0) { 52 | if (--count <= 0) { 53 | count = 60; 54 | vschar(0); 55 | } 56 | vschar(c); 57 | } 58 | vschar(0); 59 | } 60 | 61 | vschar(c) 62 | { 63 | 64 | c =^ MAGIC_MAP; 65 | spl5(); 66 | while (vs.oq.c_cc > 60) { 67 | vsxintr(); 68 | sleep(&vs.oq, TTIPRI); 69 | } 70 | putc(c, &vs.oq); 71 | vsxintr(); 72 | spl0(); 73 | } 74 | 75 | vsxintr() 76 | { 77 | static lchar; 78 | register c; 79 | register int *xcsr; 80 | 81 | xcsr = &VSADDR->vsxcsr; 82 | if (*xcsr&DONE) { 83 | if (lchar==MAGIC_MAP) { 84 | *xcsr =& ~RQSEND; 85 | lchar = 0; 86 | if (vs.oq.c_cc==0) 87 | goto wake; 88 | } 89 | if ((*xcsr&CLSEND) == 0) { 90 | *xcsr =& ~RQSEND; 91 | *xcsr =| RQSEND; 92 | if ((*xcsr&CLSEND) == 0) 93 | goto wake; 94 | } 95 | if ((c = getc(&vs.oq)) >= 0) 96 | VSADDR->vsxbuf = lchar = c; 97 | if (vs.oq.c_cc <= 15) 98 | wake: 99 | wakeup(&vs.oq); 100 | } 101 | } 102 | 103 | vsread(dev) 104 | { 105 | register int c; 106 | 107 | spl5(); 108 | while ((c = getc(&vs.iq)) < 0) 109 | sleep(&vs.iq, TTIPRI); 110 | spl0(); 111 | passc("?0*#?546?213?879?"[c&017]); 112 | } 113 | 114 | vsrintr() 115 | { 116 | register int c; 117 | 118 | c = VSADDR->vsrbuf; 119 | if (vs.iq.c_cc<=10) 120 | putc(c, &vs.iq); 121 | wakeup(&vs.iq); 122 | } 123 | -------------------------------------------------------------------------------- /ancient-src/v6/dmr/vt.c: -------------------------------------------------------------------------------- 1 | # 2 | /* 3 | */ 4 | 5 | /* 6 | * VT01 driver via DR11C to 11/20 7 | */ 8 | 9 | #include "../param.h" 10 | #include "../user.h" 11 | 12 | int vtflag; 13 | 14 | struct vtreg { 15 | int csr; 16 | int buf; 17 | }; 18 | 19 | #define VTADDR 0167770 20 | #define RQINT 01 21 | #define BIENABL 040 22 | #define SEOF 0100000 23 | #define VTPRI 8 24 | 25 | vtopen(dev, flag) 26 | { 27 | if (!flag) 28 | u.u_error = ENXIO; 29 | else 30 | VTADDR->csr = BIENABL; 31 | } 32 | 33 | vtclose() 34 | { 35 | VTADDR->buf = SEOF; 36 | VTADDR->csr =| RQINT; 37 | } 38 | 39 | vtwrite() 40 | { 41 | register int c; 42 | int register count; 43 | 44 | while ((c=cpass()) >= 0) { 45 | retry: 46 | for (count=0; count<10; count++) 47 | if ((VTADDR->csr&RQINT)==0) { 48 | VTADDR->buf = c&0377; 49 | VTADDR->csr =| RQINT; 50 | goto contin; 51 | } 52 | spl5(); 53 | if (VTADDR->csr&RQINT) { 54 | vtflag++; 55 | sleep(VTADDR, VTPRI); 56 | } 57 | spl0(); 58 | goto retry; 59 | contin:; 60 | } 61 | } 62 | 63 | vtintr() 64 | { 65 | VTADDR->csr =& ~RQINT; 66 | if (vtflag) { 67 | vtflag = 0; 68 | wakeup(VTADDR); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /ancient-src/v6/file.h: -------------------------------------------------------------------------------- 1 | /* 2 | * One file structure is allocated 3 | * for each open/creat/pipe call. 4 | * Main use is to hold the read/write 5 | * pointer associated with each open 6 | * file. 7 | */ 8 | extern struct file 9 | { 10 | char f_flag; 11 | char f_count; /* reference count */ 12 | struct inode *f_inode; /* pointer to inode structure */ 13 | uint16_t f_offset[2]; /* read/write character pointer */ 14 | } file[NFILE]; 15 | 16 | /* flags */ 17 | #define FREAD 01 18 | #define FWRITE 02 19 | #define FPIPE 04 20 | -------------------------------------------------------------------------------- /ancient-src/v6/filsys.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Definition of the unix super block. 3 | * The root super block is allocated and 4 | * read in iinit/alloc.c. Subsequently 5 | * a super block is allocated and read 6 | * with each mount (smount/sys3.c) and 7 | * released with unmount (sumount/sys3.c). 8 | * A disk block is ripped off for storage. 9 | * See alloc.c for general alloc/free 10 | * routines for free list and I list. 11 | */ 12 | struct filsys 13 | { 14 | int16_t s_isize; /* size in blocks of I list */ 15 | int16_t s_fsize; /* size in blocks of entire volume */ 16 | int16_t s_nfree; /* number of in core free blocks (0-100) */ 17 | int16_t s_free[100]; /* in core free blocks */ 18 | int16_t s_ninode; /* number of in core I nodes (0-100) */ 19 | int16_t s_inode[100]; /* in core free I nodes */ 20 | char s_flock; /* lock during free list manipulation */ 21 | char s_ilock; /* lock during I list manipulation */ 22 | char s_fmod; /* super block modified flag */ 23 | char s_ronly; /* mounted read-only flag */ 24 | int16_t s_time[2]; /* current date of last update */ 25 | int16_t pad[50]; 26 | }; 27 | -------------------------------------------------------------------------------- /ancient-src/v6/ino.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Inode structure as it appears on 3 | * the disk. Not used by the system, 4 | * but by things like check, df, dump. 5 | */ 6 | struct inode 7 | { 8 | int i_mode; 9 | char i_nlink; 10 | char i_uid; 11 | char i_gid; 12 | char i_size0; 13 | char *i_size1; 14 | int i_addr[8]; 15 | int i_atime[2]; 16 | int i_mtime[2]; 17 | }; 18 | 19 | /* modes */ 20 | #define IALLOC 0100000 21 | #define IFMT 060000 22 | #define IFDIR 040000 23 | #define IFCHR 020000 24 | #define IFBLK 060000 25 | #define ILARG 010000 26 | #define ISUID 04000 27 | #define ISGID 02000 28 | #define ISVTX 01000 29 | #define IREAD 0400 30 | #define IWRITE 0200 31 | #define IEXEC 0100 32 | -------------------------------------------------------------------------------- /ancient-src/v6/inode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The I node is the focus of all 3 | * file activity in unix. There is a unique 4 | * inode allocated for each active file, 5 | * each current directory, each mounted-on 6 | * file, text file, and the root. An inode is 'named' 7 | * by its dev/inumber pair. (iget/iget.c) 8 | * Data, from mode on, is read in 9 | * from permanent inode on volume. 10 | */ 11 | extern struct inode 12 | { 13 | char i_flag; 14 | char i_count; /* reference count */ 15 | int16_t i_dev; /* device where inode resides */ 16 | int16_t i_number; /* i number, 1-to-1 with device address */ 17 | int16_t i_mode; 18 | char i_nlink; /* directory entries */ 19 | char i_uid; /* owner */ 20 | char i_gid; /* group of owner */ 21 | char i_size0; /* most significant of size */ 22 | uint16_t i_size1; /* least sig */ 23 | int16_t i_addr[8]; /* device addresses constituting file */ 24 | int16_t i_lastr; /* last logical block read (for read-ahead) */ 25 | } inode[NINODE]; 26 | 27 | /* flags */ 28 | #define ILOCK 01 /* inode is locked */ 29 | #define IUPD 02 /* inode has been modified */ 30 | #define IACC 04 /* inode access time to be updated */ 31 | #define IMOUNT 010 /* inode is mounted on */ 32 | #define IWANT 020 /* some process waiting on lock */ 33 | #define ITEXT 040 /* inode is pure text prototype */ 34 | 35 | /* modes */ 36 | #define IALLOC 0100000 /* file is used */ 37 | #define IFMT 060000 /* type of file */ 38 | #define IFDIR 040000 /* directory */ 39 | #define IFCHR 020000 /* character special */ 40 | #define IFBLK 060000 /* block special, 0 is regular */ 41 | #define ILARG 010000 /* large addressing algorithm */ 42 | #define ISUID 04000 /* set user id on execution */ 43 | #define ISGID 02000 /* set group id on execution */ 44 | #define ISVTX 01000 /* save swapped text even after use */ 45 | #define IREAD 0400 /* read, write, execute permissions */ 46 | #define IWRITE 0200 47 | #define IEXEC 0100 48 | -------------------------------------------------------------------------------- /ancient-src/v6/ken/malloc.c: -------------------------------------------------------------------------------- 1 | # 2 | /* 3 | */ 4 | 5 | /* 6 | * Structure of the coremap and swapmap 7 | * arrays. Consists of non-zero count 8 | * and base address of that many 9 | * contiguous units. 10 | * (The coremap unit is 64 bytes, 11 | * the swapmap unit is 512 bytes) 12 | * The addresses are increasing and 13 | * the list is terminated with the 14 | * first zero count. 15 | */ 16 | struct map 17 | { 18 | char *m_size; 19 | char *m_addr; 20 | }; 21 | 22 | /* 23 | * Allocate size units from the given 24 | * map. Return the base of the allocated 25 | * space. 26 | * Algorithm is first fit. 27 | */ 28 | malloc(mp, size) 29 | struct map *mp; 30 | { 31 | register int a; 32 | register struct map *bp; 33 | 34 | for (bp = mp; bp->m_size; bp++) { 35 | if (bp->m_size >= size) { 36 | a = bp->m_addr; 37 | bp->m_addr =+ size; 38 | if ((bp->m_size =- size) == 0) 39 | do { 40 | bp++; 41 | (bp-1)->m_addr = bp->m_addr; 42 | } while ((bp-1)->m_size = bp->m_size); 43 | return(a); 44 | } 45 | } 46 | return(0); 47 | } 48 | 49 | /* 50 | * Free the previously allocated space aa 51 | * of size units into the specified map. 52 | * Sort aa into map and combine on 53 | * one or both ends if possible. 54 | */ 55 | mfree(mp, size, aa) 56 | struct map *mp; 57 | { 58 | register struct map *bp; 59 | register int t; 60 | register int a; 61 | 62 | a = aa; 63 | for (bp = mp; bp->m_addr<=a && bp->m_size!=0; bp++); 64 | if (bp>mp && (bp-1)->m_addr+(bp-1)->m_size == a) { 65 | (bp-1)->m_size =+ size; 66 | if (a+size == bp->m_addr) { 67 | (bp-1)->m_size =+ bp->m_size; 68 | while (bp->m_size) { 69 | bp++; 70 | (bp-1)->m_addr = bp->m_addr; 71 | (bp-1)->m_size = bp->m_size; 72 | } 73 | } 74 | } else { 75 | if (a+size == bp->m_addr && bp->m_size) { 76 | bp->m_addr =- size; 77 | bp->m_size =+ size; 78 | } else if (size) do { 79 | t = bp->m_addr; 80 | bp->m_addr = a; 81 | a = t; 82 | t = bp->m_size; 83 | bp->m_size = size; 84 | bp++; 85 | } while (size = t); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /ancient-src/v6/ken/prf.c: -------------------------------------------------------------------------------- 1 | # 2 | /* 3 | */ 4 | 5 | #include "../param.h" 6 | #include "../seg.h" 7 | #include "../buf.h" 8 | #include "../conf.h" 9 | 10 | /* 11 | * Address and structure of the 12 | * KL-11 console device registers. 13 | */ 14 | struct 15 | { 16 | int rsr; 17 | int rbr; 18 | int xsr; 19 | int xbr; 20 | }; 21 | 22 | /* 23 | * In case console is off, 24 | * panicstr contains argument to last 25 | * call to panic. 26 | */ 27 | 28 | char *panicstr; 29 | 30 | /* 31 | * Scaled down version of C Library printf. 32 | * Only %s %l %d (==%l) %o are recognized. 33 | * Used to print diagnostic information 34 | * directly on console tty. 35 | * Since it is not interrupt driven, 36 | * all system activities are pretty much 37 | * suspended. 38 | * Printf should not be used for chit-chat. 39 | */ 40 | printf(fmt,x1,x2,x3,x4,x5,x6,x7,x8,x9,xa,xb,xc) 41 | char fmt[]; 42 | { 43 | register char *s; 44 | register *adx, c; 45 | 46 | adx = &x1; 47 | loop: 48 | while((c = *fmt++) != '%') { 49 | if(c == '\0') 50 | return; 51 | putchar(c); 52 | } 53 | c = *fmt++; 54 | if(c == 'd' || c == 'l' || c == 'o') 55 | printn(*adx, c=='o'? 8: 10); 56 | if(c == 's') { 57 | s = *adx; 58 | while(c = *s++) 59 | putchar(c); 60 | } 61 | adx++; 62 | goto loop; 63 | } 64 | 65 | /* 66 | * Print an unsigned integer in base b. 67 | */ 68 | printn(n, b) 69 | { 70 | register a; 71 | 72 | if(a = ldiv(n, b)) 73 | printn(a, b); 74 | putchar(lrem(n, b) + '0'); 75 | } 76 | 77 | /* 78 | * Print a character on console. 79 | * Attempts to save and restore device 80 | * status. 81 | * If the switches are 0, all 82 | * printing is inhibited. 83 | */ 84 | putchar(c) 85 | { 86 | register rc, s; 87 | 88 | rc = c; 89 | if(SW->integ == 0) 90 | return; 91 | while((KL->xsr&0200) == 0) 92 | ; 93 | if(rc == 0) 94 | return; 95 | s = KL->xsr; 96 | KL->xsr = 0; 97 | KL->xbr = rc; 98 | if(rc == '\n') { 99 | putchar('\r'); 100 | putchar(0177); 101 | putchar(0177); 102 | } 103 | putchar(0); 104 | KL->xsr = s; 105 | } 106 | 107 | /* 108 | * Panic is called on unresolvable 109 | * fatal errors. 110 | * It syncs, prints "panic: mesg" and 111 | * then loops. 112 | */ 113 | panic(s) 114 | char *s; 115 | { 116 | panicstr = s; 117 | update(); 118 | printf("panic: %s\n", s); 119 | for(;;) 120 | idle(); 121 | } 122 | 123 | /* 124 | * prdev prints a warning message of the 125 | * form "mesg on dev x/y". 126 | * x and y are the major and minor parts of 127 | * the device argument. 128 | */ 129 | prdev(str, dev) 130 | { 131 | 132 | printf("%s on dev %l/%l\n", str, dev.d_major, dev.d_minor); 133 | } 134 | 135 | /* 136 | * deverr prints a diagnostic from 137 | * a device driver. 138 | * It prints the device, block number, 139 | * and an octal word (usually some error 140 | * status register) passed as argument. 141 | */ 142 | deverror(bp, o1, o2) 143 | int *bp; 144 | { 145 | register *rbp; 146 | 147 | rbp = bp; 148 | prdev("err", rbp->b_dev); 149 | printf("bn%l er%o %o\n", rbp->b_blkno, o1, o2); 150 | } 151 | -------------------------------------------------------------------------------- /ancient-src/v6/ken/sysent.c: -------------------------------------------------------------------------------- 1 | # 2 | /* 3 | */ 4 | 5 | /* 6 | * This table is the switch used to transfer 7 | * to the appropriate routine for processing a system call. 8 | * Each row contains the number of arguments expected 9 | * and a pointer to the routine. 10 | */ 11 | int sysent[] 12 | { 13 | 0, &nullsys, /* 0 = indir */ 14 | 0, &rexit, /* 1 = exit */ 15 | 0, &fork, /* 2 = fork */ 16 | 2, &read, /* 3 = read */ 17 | 2, &write, /* 4 = write */ 18 | 2, &open, /* 5 = open */ 19 | 0, &close, /* 6 = close */ 20 | 0, &wait, /* 7 = wait */ 21 | 2, &creat, /* 8 = creat */ 22 | 2, &link, /* 9 = link */ 23 | 1, &unlink, /* 10 = unlink */ 24 | 2, &exec, /* 11 = exec */ 25 | 1, &chdir, /* 12 = chdir */ 26 | 0, >ime, /* 13 = time */ 27 | 3, &mknod, /* 14 = mknod */ 28 | 2, &chmod, /* 15 = chmod */ 29 | 2, &chown, /* 16 = chown */ 30 | 1, &sbreak, /* 17 = break */ 31 | 2, &stat, /* 18 = stat */ 32 | 2, &seek, /* 19 = seek */ 33 | 0, &getpid, /* 20 = getpid */ 34 | 3, &smount, /* 21 = mount */ 35 | 1, &sumount, /* 22 = umount */ 36 | 0, &setuid, /* 23 = setuid */ 37 | 0, &getuid, /* 24 = getuid */ 38 | 0, &stime, /* 25 = stime */ 39 | 3, &ptrace, /* 26 = ptrace */ 40 | 0, &nosys, /* 27 = x */ 41 | 1, &fstat, /* 28 = fstat */ 42 | 0, &nosys, /* 29 = x */ 43 | 1, &nullsys, /* 30 = smdate; inoperative */ 44 | 1, &stty, /* 31 = stty */ 45 | 1, >ty, /* 32 = gtty */ 46 | 0, &nosys, /* 33 = x */ 47 | 0, &nice, /* 34 = nice */ 48 | 0, &sslep, /* 35 = sleep */ 49 | 0, &sync, /* 36 = sync */ 50 | 1, &kill, /* 37 = kill */ 51 | 0, &getswit, /* 38 = switch */ 52 | 0, &nosys, /* 39 = x */ 53 | 0, &nosys, /* 40 = x */ 54 | 0, &dup, /* 41 = dup */ 55 | 0, &pipe, /* 42 = pipe */ 56 | 1, ×, /* 43 = times */ 57 | 4, &profil, /* 44 = prof */ 58 | 0, &nosys, /* 45 = tiu */ 59 | 0, &setgid, /* 46 = setgid */ 60 | 0, &getgid, /* 47 = getgid */ 61 | 2, &ssig, /* 48 = sig */ 62 | 0, &nosys, /* 49 = x */ 63 | 0, &nosys, /* 50 = x */ 64 | 0, &nosys, /* 51 = x */ 65 | 0, &nosys, /* 52 = x */ 66 | 0, &nosys, /* 53 = x */ 67 | 0, &nosys, /* 54 = x */ 68 | 0, &nosys, /* 55 = x */ 69 | 0, &nosys, /* 56 = x */ 70 | 0, &nosys, /* 57 = x */ 71 | 0, &nosys, /* 58 = x */ 72 | 0, &nosys, /* 59 = x */ 73 | 0, &nosys, /* 60 = x */ 74 | 0, &nosys, /* 61 = x */ 75 | 0, &nosys, /* 62 = x */ 76 | 0, &nosys /* 63 = x */ 77 | }; 78 | -------------------------------------------------------------------------------- /ancient-src/v6/param.h: -------------------------------------------------------------------------------- 1 | /* 2 | * tunable variables 3 | */ 4 | 5 | #define NBUF 15 /* size of buffer cache */ 6 | #define NINODE 100 /* number of in core inodes */ 7 | #define NFILE 100 /* number of in core file structures */ 8 | #define NMOUNT 5 /* number of mountable file systems */ 9 | #define NEXEC 3 /* number of simultaneous exec's */ 10 | #define MAXMEM (64*32) /* max core per process - first # is Kw */ 11 | #define SSIZE 20 /* initial stack size (*64 bytes) */ 12 | #define SINCR 20 /* increment of stack (*64 bytes) */ 13 | #define NOFILE 15 /* max open files per process */ 14 | #define CANBSIZ 256 /* max size of typewriter line */ 15 | #define CMAPSIZ 100 /* size of core allocation area */ 16 | #define SMAPSIZ 100 /* size of swap allocation area */ 17 | #define NCALL 20 /* max simultaneous time callouts */ 18 | #define NPROC 50 /* max number of processes */ 19 | #define NTEXT 40 /* max number of pure texts */ 20 | #define NCLIST 100 /* max total clist size */ 21 | #define HZ 60 /* Ticks/second of the clock */ 22 | 23 | /* 24 | * priorities 25 | * probably should not be 26 | * altered too much 27 | */ 28 | 29 | #define PSWP -100 30 | #define PINOD -90 31 | #define PRIBIO -50 32 | #define PPIPE 1 33 | #define PWAIT 40 34 | #define PSLEP 90 35 | #define PUSER 100 36 | 37 | /* 38 | * signals 39 | * dont change 40 | */ 41 | 42 | #define NSIG 20 43 | #define SIGHUP 1 /* hangup */ 44 | #define SIGINT 2 /* interrupt (rubout) */ 45 | #define SIGQIT 3 /* quit (FS) */ 46 | #define SIGINS 4 /* illegal instruction */ 47 | #define SIGTRC 5 /* trace or breakpoint */ 48 | #define SIGIOT 6 /* iot */ 49 | #define SIGEMT 7 /* emt */ 50 | #define SIGFPT 8 /* floating exception */ 51 | #define SIGKIL 9 /* kill */ 52 | #define SIGBUS 10 /* bus error */ 53 | #define SIGSEG 11 /* segmentation violation */ 54 | #define SIGSYS 12 /* sys */ 55 | #define SIGPIPE 13 /* end of pipe */ 56 | 57 | /* 58 | * fundamental constants 59 | * cannot be changed 60 | */ 61 | 62 | #define USIZE 16 /* size of user block (*64) */ 63 | #define NULL 0 64 | #define NODEV (-1) 65 | #define ROOTINO 1 /* i number of all roots */ 66 | #define DIRSIZ 14 /* max characters per directory */ 67 | 68 | /* 69 | * structure to access an 70 | * integer in bytes 71 | */ 72 | struct hilo 73 | { 74 | char lobyte; 75 | char hibyte; 76 | }; 77 | 78 | /* 79 | * structure to access an integer 80 | */ 81 | struct integ 82 | { 83 | int16_t integ; 84 | }; 85 | 86 | /* 87 | * Certain processor registers 88 | */ 89 | /* UNUSED #define PS 0177776 */ 90 | /* UNUSED #define KL 0177560 */ 91 | /* UNUSED #define SW 0177570 */ 92 | -------------------------------------------------------------------------------- /ancient-src/v6/proc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * One structure allocated per active 3 | * process. It contains all data needed 4 | * about the process while the 5 | * process may be swapped out. 6 | * Other per process data (user.h) 7 | * is swapped with the process. 8 | */ 9 | struct proc 10 | { 11 | char p_stat; 12 | char p_flag; 13 | char p_pri; /* priority, negative is high */ 14 | char p_sig; /* signal number sent to this process */ 15 | char p_uid; /* user id, used to direct tty signals */ 16 | char p_time; /* resident time for scheduling */ 17 | char p_cpu; /* cpu usage for scheduling */ 18 | char p_nice; /* nice for scheduling */ 19 | int p_ttyp; /* controlling tty */ 20 | int p_pid; /* unique process id */ 21 | int p_ppid; /* process id of parent */ 22 | int p_addr; /* address of swappable image */ 23 | int p_size; /* size of swappable image (*64 bytes) */ 24 | int p_wchan; /* event process is awaiting */ 25 | int *p_textp; /* pointer to text structure */ 26 | } proc[NPROC]; 27 | 28 | /* stat codes */ 29 | #define SSLEEP 1 /* sleeping on high priority */ 30 | #define SWAIT 2 /* sleeping on low priority */ 31 | #define SRUN 3 /* running */ 32 | #define SIDL 4 /* intermediate state in process creation */ 33 | #define SZOMB 5 /* intermediate state in process termination */ 34 | #define SSTOP 6 /* process being traced */ 35 | 36 | /* flag codes */ 37 | #define SLOAD 01 /* in core */ 38 | #define SSYS 02 /* scheduling process */ 39 | #define SLOCK 04 /* process cannot be swapped */ 40 | #define SSWAP 010 /* process is being swapped out */ 41 | #define STRC 020 /* process is being traced */ 42 | #define SWTED 040 /* another tracing flag */ 43 | -------------------------------------------------------------------------------- /ancient-src/v6/reg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Location of the users' stored 3 | * registers relative to R0. 4 | * Usage is u.u_ar0[XX]. 5 | */ 6 | #define R0 (0) 7 | #define R1 (-2) 8 | #define R2 (-9) 9 | #define R3 (-8) 10 | #define R4 (-7) 11 | #define R5 (-6) 12 | #define R6 (-3) 13 | #define R7 (1) 14 | #define RPS (2) 15 | 16 | #define TBIT 020 /* PS trace bit */ 17 | -------------------------------------------------------------------------------- /ancient-src/v6/seg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * KT-11 addresses and bits. 3 | */ 4 | 5 | #define UISD 0177600 /* first user I-space descriptor register */ 6 | #define UISA 0177640 /* first user I-space address register */ 7 | #define UDSA 0177660 /* first user D-space address register */ 8 | #define RO 02 /* access abilities */ 9 | #define WO 04 10 | #define RW 06 11 | #define ED 010 /* extend direction */ 12 | 13 | /* 14 | * structure used to address 15 | * a sequence of integers. 16 | */ 17 | struct 18 | { 19 | int r[]; 20 | }; 21 | int *ka6; /* 11/40 KISA6; 11/45 KDSA6 */ 22 | 23 | /* 24 | * address to access 11/70 UNIBUS map 25 | */ 26 | #define UBMAP 0170200 27 | -------------------------------------------------------------------------------- /ancient-src/v6/systm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Random set of variables 3 | * used by more than one 4 | * routine. 5 | */ 6 | extern char canonb[CANBSIZ]; /* buffer for erase and kill (#@) */ 7 | extern int16_t coremap[CMAPSIZ]; /* space for core allocation */ 8 | extern int16_t swapmap[SMAPSIZ]; /* space for swap allocation */ 9 | extern struct inode *rootdir; /* pointer to inode of root directory */ 10 | extern int16_t cputype; /* type of cpu =40, 45, or 70 */ 11 | extern int16_t execnt; /* number of processes in exec */ 12 | extern int16_t lbolt; /* time of day in 60th not in time */ 13 | extern int16_t time[2]; /* time in sec from 1970 */ 14 | extern int16_t tout[2]; /* time of day of next sleep */ 15 | /* 16 | * The callout structure is for 17 | * a routine arranging 18 | * to be called by the clock interrupt 19 | * (clock.c) with a specified argument, 20 | * in a specified amount of time. 21 | * Used, for example, to time tab 22 | * delays on teletypes. 23 | */ 24 | extern struct callo 25 | { 26 | int16_t c_time; /* incremental time */ 27 | int16_t c_arg; /* argument to routine */ 28 | int16_t (*c_func)(); /* routine */ 29 | } callout[NCALL]; 30 | /* 31 | * Mount structure. 32 | * One allocated on every mount. 33 | * Used to find the super block. 34 | */ 35 | extern struct mount 36 | { 37 | int16_t m_dev; /* device mounted */ 38 | struct buf *m_bufp; /* pointer to superblock */ 39 | struct inode *m_inodp; /* pointer to mounted on inode */ 40 | } mount[NMOUNT]; 41 | extern int16_t mpid; /* generic for unique process id's */ 42 | extern char runin; /* scheduling flag */ 43 | extern char runout; /* scheduling flag */ 44 | extern char runrun; /* scheduling flag */ 45 | extern char curpri; /* more scheduling */ 46 | extern int16_t maxmem; /* actual max memory per process */ 47 | extern int16_t *lks; /* pointer to clock device */ 48 | extern int16_t rootdev; /* dev of root see conf.c */ 49 | extern int16_t swapdev; /* dev of swap see conf.c */ 50 | extern int16_t swplo; /* block number of swap space */ 51 | extern int16_t nswap; /* size of swap space */ 52 | extern int16_t updlock; /* lock for sync */ 53 | extern int16_t rablock; /* block to be read ahead */ 54 | extern char regloc[]; /* locs. of saved user registers (trap.c) */ 55 | -------------------------------------------------------------------------------- /ancient-src/v6/text.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Text structure. 3 | * One allocated per pure 4 | * procedure on swap device. 5 | * Manipulated by text.c 6 | */ 7 | struct text 8 | { 9 | int x_daddr; /* disk address of segment */ 10 | int x_caddr; /* core address, if loaded */ 11 | int x_size; /* size (*64) */ 12 | int *x_iptr; /* inode of prototype */ 13 | char x_count; /* reference count */ 14 | char x_ccount; /* number of loaded references */ 15 | } text[NTEXT]; 16 | -------------------------------------------------------------------------------- /ancient-src/v6/tty.h: -------------------------------------------------------------------------------- 1 | /* 2 | * A clist structure is the head 3 | * of a linked list queue of characters. 4 | * The characters are stored in 4-word 5 | * blocks containing a link and 6 characters. 6 | * The routines getc and putc (m45.s or m40.s) 7 | * manipulate these structures. 8 | */ 9 | struct clist 10 | { 11 | int c_cc; /* character count */ 12 | int c_cf; /* pointer to first block */ 13 | int c_cl; /* pointer to last block */ 14 | }; 15 | 16 | /* 17 | * A tty structure is needed for 18 | * each UNIX character device that 19 | * is used for normal terminal IO. 20 | * The routines in tty.c handle the 21 | * common code associated with 22 | * these structures. 23 | * The definition and device dependent 24 | * code is in each driver. (kl.c dc.c dh.c) 25 | */ 26 | struct tty 27 | { 28 | struct clist t_rawq; /* input chars right off device */ 29 | struct clist t_canq; /* input chars after erase and kill */ 30 | struct clist t_outq; /* output list to device */ 31 | int t_flags; /* mode, settable by stty call */ 32 | int *t_addr; /* device address (register or startup fcn) */ 33 | char t_delct; /* number of delimiters in raw q */ 34 | char t_col; /* printing column of device */ 35 | char t_erase; /* erase character */ 36 | char t_kill; /* kill character */ 37 | char t_state; /* internal state, not visible externally */ 38 | char t_char; /* character temporary */ 39 | int t_speeds; /* output+input line speed */ 40 | int t_dev; /* device name */ 41 | }; 42 | 43 | char partab[]; /* ASCII table: parity, character class */ 44 | 45 | #define TTIPRI 10 46 | #define TTOPRI 20 47 | 48 | #define CERASE '#' /* default special characters */ 49 | #define CEOT 004 50 | #define CKILL '@' 51 | #define CQUIT 034 /* FS, cntl shift L */ 52 | #define CINTR 0177 /* DEL */ 53 | 54 | /* limits */ 55 | #define TTHIWAT 50 56 | #define TTLOWAT 30 57 | #define TTYHOG 256 58 | 59 | /* modes */ 60 | #define HUPCL 01 61 | #define XTABS 02 62 | #define LCASE 04 63 | #define ECHO 010 64 | #define CRMOD 020 65 | #define RAW 040 66 | #define ODDP 0100 67 | #define EVENP 0200 68 | #define NLDELAY 001400 69 | #define TBDELAY 006000 70 | #define CRDELAY 030000 71 | #define VTDELAY 040000 72 | 73 | /* Hardware bits */ 74 | #define DONE 0200 75 | #define IENABLE 0100 76 | 77 | /* Internal state bits */ 78 | #define TIMEOUT 01 /* Delay timeout in progress */ 79 | #define WOPEN 02 /* Waiting for open to complete */ 80 | #define ISOPEN 04 /* Device is open */ 81 | #define SSTART 010 /* Has special start routine at addr */ 82 | #define CARR_ON 020 /* Software copy of carrier-present */ 83 | #define BUSY 040 /* Output in progress */ 84 | #define ASLEEP 0100 /* Wakeup when output done */ 85 | -------------------------------------------------------------------------------- /ancient-src/v6/user.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The user structure. 3 | * One allocated per process. 4 | * Contains all per process data 5 | * that doesn't need to be referenced 6 | * while the process is swapped. 7 | * The user block is USIZE*64 bytes 8 | * long; resides at virtual kernel 9 | * loc 140000; contains the system 10 | * stack per user; is cross referenced 11 | * with the proc structure for the 12 | * same process. 13 | */ 14 | extern struct user 15 | { 16 | int16_t u_rsav[2]; /* save r5,r6 when exchanging stacks */ 17 | int16_t u_fsav[25]; /* save fp registers */ 18 | /* rsav and fsav must be first in structure */ 19 | char u_segflg; /* flag for IO; user or kernel space */ 20 | char u_error; /* return error code */ 21 | char u_uid; /* effective user id */ 22 | char u_gid; /* effective group id */ 23 | char u_ruid; /* real user id */ 24 | char u_rgid; /* real group id */ 25 | int16_t u_procp; /* pointer to proc structure */ 26 | char *u_base; /* base address for IO */ 27 | uint16_t u_count; /* bytes remaining for IO */ 28 | uint16_t u_offset[2]; /* offset in file for IO */ 29 | struct inode *u_cdir; /* pointer to inode of current directory */ 30 | char u_dbuf[DIRSIZ]; /* current pathname component */ 31 | char *u_dirp; /* current pointer to inode */ 32 | struct { /* current directory entry */ 33 | int16_t u_ino; 34 | char u_name[DIRSIZ]; 35 | } u_dent; 36 | struct inode *u_pdir; /* inode of parent directory of dirp */ 37 | int16_t u_uisa[16]; /* prototype of segmentation addresses */ 38 | int16_t u_uisd[16]; /* prototype of segmentation descriptors */ 39 | struct file *u_ofile[NOFILE]; /* pointers to file structures of open files */ 40 | intptr_t u_arg[5]; /* arguments to current system call */ 41 | int16_t u_tsize; /* text size (*64) */ 42 | int16_t u_dsize; /* data size (*64) */ 43 | int16_t u_ssize; /* stack size (*64) */ 44 | int16_t u_sep; /* flag for I and D separation */ 45 | int16_t u_qsav[2]; /* label variable for quits and interrupts */ 46 | int16_t u_ssav[2]; /* label variable for swapping */ 47 | int16_t u_signal[NSIG]; /* disposition of signals */ 48 | int16_t u_utime; /* this process user time */ 49 | int16_t u_stime; /* this process system time */ 50 | int16_t u_cutime[2]; /* sum of childs' utimes */ 51 | int16_t u_cstime[2]; /* sum of childs' stimes */ 52 | int16_t *u_ar0; /* address of users saved R0 */ 53 | int16_t u_prof[4]; /* profile arguments */ 54 | char u_intflg; /* catch intr from sys */ 55 | /* kernel stack per user 56 | * extends from u + USIZE*64 57 | * backward not to reach here 58 | */ 59 | } u; 60 | 61 | /* u_error codes */ 62 | /* UNUSED #define EFAULT 106 */ 63 | #define EPERM 1 64 | #define ENOENT 2 65 | #define ESRCH 3 66 | #define EINTR 4 67 | #define EIO 5 68 | #define ENXIO 6 69 | #define E2BIG 7 70 | #define ENOEXEC 8 71 | #define EBADF 9 72 | #define ECHILD 10 73 | #define EAGAIN 11 74 | #define ENOMEM 12 75 | #define EACCES 13 76 | #define ENOTBLK 15 77 | #define EBUSY 16 78 | #define EEXIST 17 79 | #define EXDEV 18 80 | #define ENODEV 19 81 | #define ENOTDIR 20 82 | #define EISDIR 21 83 | #define EINVAL 22 84 | #define ENFILE 23 85 | #define EMFILE 24 86 | #define ENOTTY 25 87 | #define ETXTBSY 26 88 | #define EFBIG 27 89 | #define ENOSPC 28 90 | #define ESPIPE 29 91 | #define EROFS 30 92 | #define EMLINK 31 93 | #define EPIPE 32 94 | -------------------------------------------------------------------------------- /ancient-src/v7/conf/c.c: -------------------------------------------------------------------------------- 1 | #include "../h/param.h" 2 | #include "../h/systm.h" 3 | #include "../h/buf.h" 4 | #include "../h/tty.h" 5 | #include "../h/conf.h" 6 | #include "../h/proc.h" 7 | #include "../h/text.h" 8 | #include "../h/dir.h" 9 | #include "../h/user.h" 10 | #include "../h/file.h" 11 | #include "../h/inode.h" 12 | #include "../h/acct.h" 13 | 14 | int nulldev(); 15 | int nodev(); 16 | int rkstrategy(); 17 | struct buf rktab; 18 | int htopen(), htclose(), htstrategy(); 19 | struct buf httab; 20 | struct bdevsw bdevsw[] = 21 | { 22 | nulldev, nulldev, rkstrategy, &rktab, /* rk = 0 */ 23 | nodev, nodev, nodev, 0, /* rp = 1 */ 24 | nodev, nodev, nodev, 0, /* rf = 2 */ 25 | nodev, nodev, nodev, 0, /* tm = 3 */ 26 | nodev, nodev, nodev, 0, /* tc = 4 */ 27 | nodev, nodev, nodev, 0, /* hs = 5 */ 28 | nodev, nodev, nodev, 0, /* hp = 6 */ 29 | htopen, htclose, htstrategy, &httab, /* ht = 7 */ 30 | nodev, nodev, nodev, 0, /* rl = 8 */ 31 | 0 32 | }; 33 | 34 | int klopen(), klclose(), klread(), klwrite(), klioctl(); 35 | int mmread(), mmwrite(); 36 | int rkread(), rkwrite(); 37 | int htread(), htwrite(); 38 | int syopen(), syread(), sywrite(), sysioctl(); 39 | 40 | struct cdevsw cdevsw[] = 41 | { 42 | klopen, klclose, klread, klwrite, klioctl, nulldev, 0, /* console = 0 */ 43 | nodev, nodev, nodev, nodev, nodev, nulldev, 0, /* pc = 1 */ 44 | nodev, nodev, nodev, nodev, nodev, nulldev, 0, /* lp = 2 */ 45 | nodev, nodev, nodev, nodev, nodev, nulldev, 0, /* dc = 3 */ 46 | nodev, nodev, nodev, nodev, nodev, nulldev, 0, /* dh = 4 */ 47 | nodev, nodev, nodev, nodev, nodev, nulldev, 0, /* dp = 5 */ 48 | nodev, nodev, nodev, nodev, nodev, nulldev, 0, /* dj = 6 */ 49 | nodev, nodev, nodev, nodev, nodev, nulldev, 0, /* dn = 7 */ 50 | nulldev, nulldev, mmread, mmwrite, nodev, nulldev, 0, /* mem = 8 */ 51 | nulldev, nulldev, rkread, rkwrite, nodev, nulldev, 0, /* rk = 9 */ 52 | nodev, nodev, nodev, nodev, nodev, nulldev, 0, /* rf = 10 */ 53 | nodev, nodev, nodev, nodev, nodev, nulldev, 0, /* rp = 11 */ 54 | nodev, nodev, nodev, nodev, nodev, nulldev, 0, /* tm = 12 */ 55 | nodev, nodev, nodev, nodev, nodev, nulldev, 0, /* hs = 13 */ 56 | nodev, nodev, nodev, nodev, nodev, nulldev, 0, /* hp = 14 */ 57 | htopen, htclose, htread, htwrite, nodev, nulldev, 0, /* ht = 15 */ 58 | nodev, nodev, nodev, nodev, nodev, nulldev, 0, /* du = 16 */ 59 | syopen, nulldev, syread, sywrite, sysioctl, nulldev, 0, /* tty = 17 */ 60 | nodev, nodev, nodev, nodev, nodev, nulldev, 0, /* rl = 18 */ 61 | 0 62 | }; 63 | 64 | int ttyopen(), ttyclose(), ttread(), ttwrite(), ttyinput(), ttstart(); 65 | struct linesw linesw[] = 66 | { 67 | ttyopen, nulldev, ttread, ttwrite, nodev, ttyinput, ttstart, /* 0 */ 68 | 0 69 | }; 70 | int rootdev = makedev(0, 0); 71 | int swapdev = makedev(0, 0); 72 | int pipedev = makedev(0, 0); 73 | int nldisp = 1; 74 | daddr_t swplo = 4000; 75 | int nswap = 872; 76 | 77 | struct buf buf[NBUF]; 78 | struct file file[NFILE]; 79 | struct inode inode[NINODE]; 80 | int mpxchan(); 81 | int (*ldmpx)() = mpxchan; 82 | struct proc proc[NPROC]; 83 | struct text text[NTEXT]; 84 | struct buf bfreelist; 85 | struct acct acctbuf; 86 | struct inode *acctp; 87 | -------------------------------------------------------------------------------- /ancient-src/v7/conf/hphtconf: -------------------------------------------------------------------------------- 1 | hp 2 | root hp 0 3 | swap hp 1 4 | swplo 0 5 | nswap 8778 6 | ht 7 | -------------------------------------------------------------------------------- /ancient-src/v7/conf/hptmconf: -------------------------------------------------------------------------------- 1 | hp 2 | root hp 0 3 | swap hp 1 4 | swplo 0 5 | nswap 8778 6 | tm 7 | -------------------------------------------------------------------------------- /ancient-src/v7/conf/l.s: -------------------------------------------------------------------------------- 1 | / low core 2 | 3 | .data 4 | ZERO: 5 | 6 | br4 = 200 7 | br5 = 240 8 | br6 = 300 9 | br7 = 340 10 | 11 | . = ZERO+0 12 | br 1f 13 | 4 14 | 15 | / trap vectors 16 | trap; br7+0. / bus error 17 | trap; br7+1. / illegal instruction 18 | trap; br7+2. / bpt-trace trap 19 | trap; br7+3. / iot trap 20 | trap; br7+4. / power fail 21 | trap; br7+5. / emulator trap 22 | start;br7+6. / system (overlaid by 'trap') 23 | 24 | . = ZERO+40 25 | .globl start, dump 26 | 1: jmp start 27 | jmp dump 28 | 29 | 30 | . = ZERO+60 31 | klin; br4 32 | klou; br4 33 | 34 | . = ZERO+100 35 | kwlp; br6 36 | kwlp; br6 37 | 38 | . = ZERO+114 39 | trap; br7+7. / 11/70 parity 40 | 41 | . = ZERO+220 42 | rkio; br5 43 | 44 | . = ZERO+224 45 | htio; br5 46 | 47 | . = ZERO+240 48 | trap; br7+7. / programmed interrupt 49 | trap; br7+8. / floating point 50 | trap; br7+9. / segmentation violation 51 | 52 | ////////////////////////////////////////////////////// 53 | / interface code to C 54 | ////////////////////////////////////////////////////// 55 | 56 | .text 57 | .globl call, trap 58 | 59 | .globl _klrint 60 | klin: jsr r0,call; jmp _klrint 61 | .globl _klxint 62 | klou: jsr r0,call; jmp _klxint 63 | 64 | .globl _clock 65 | kwlp: jsr r0,call; jmp _clock 66 | 67 | 68 | .globl _rkintr 69 | rkio: jsr r0,call; jmp _rkintr 70 | 71 | .globl _htintr 72 | htio: jsr r0,call; jmp _htintr 73 | -------------------------------------------------------------------------------- /ancient-src/v7/conf/makefile: -------------------------------------------------------------------------------- 1 | unix: l.o mch.o c.o ../sys/LIB1 ../dev/LIB2 2 | ld -o unix -X -i l.o mch.o c.o ../sys/LIB1 ../dev/LIB2 3 | 4 | all: 5 | cd ../sys; cc -c -O *.c; mklib; rm *.o 6 | cd ../dev; cc -c -O *.c; mklib; rm *.o 7 | 8 | mch.o: mch0.s mch.s 9 | as -o mch.o mch0.s mch.s 10 | 11 | allsystems: 12 | mkconf catcsr |= IENABLE; 34 | } else 35 | u.u_error = ENXIO; 36 | } 37 | 38 | ctclose() 39 | { 40 | cat.catlock = 0; 41 | catintr(); 42 | } 43 | 44 | ctwrite(dev) 45 | { 46 | register c; 47 | extern lbolt; 48 | 49 | while ((c=cpass()) >= 0) { 50 | spl5(); 51 | while (cat.oq.c_cc > CATHIWAT) 52 | sleep((caddr_t)&cat.oq, PCAT); 53 | while (putc(c, &cat.oq) < 0) 54 | sleep((caddr_t)&lbolt, PCAT); 55 | catintr(); 56 | spl0(); 57 | } 58 | } 59 | 60 | catintr() 61 | { 62 | register int c; 63 | 64 | if (CATADDR->catcsr&DONE) { 65 | if ((c = getc(&cat.oq)) >= 0) { 66 | CATADDR->catbuf = c; 67 | if (cat.oq.c_cc==0 || cat.oq.c_cc==CATLOWAT) 68 | wakeup((caddr_t)&cat.oq); 69 | } else { 70 | if (cat.catlock==0) 71 | CATADDR->catcsr = 0; 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /ancient-src/v7/dev/dhdm.c: -------------------------------------------------------------------------------- 1 | /* 2 | * DM-BB driver 3 | */ 4 | #include "../h/param.h" 5 | #include "../h/tty.h" 6 | #include "../h/conf.h" 7 | 8 | #define DMADDR ((struct device *)0170500) 9 | 10 | struct tty dh11[]; 11 | int ndh11; /* Set by dh.c to number of lines */ 12 | 13 | #define DONE 0200 14 | #define SCENABL 040 15 | #define CLSCAN 01000 16 | #define TURNON 03 /* CD lead, line enable */ 17 | #define SECX 010 /* secondary xmit */ 18 | #define RQS 04 /* request to send */ 19 | #define TURNOFF 1 /* line enable only */ 20 | #define CARRIER 0100 21 | #define CLS 040 /* clear to send */ 22 | #define SECR 020 /* secondary receive */ 23 | 24 | struct device 25 | { 26 | int dmcsr; 27 | int dmlstat; 28 | int junk[2]; 29 | }; 30 | 31 | #define B1200 9 32 | #define B300 7 33 | 34 | /* 35 | * Turn on the line associated with the (DH) device dev. 36 | */ 37 | dmopen(dev) 38 | { 39 | register struct tty *tp; 40 | register struct device *addr; 41 | register d; 42 | 43 | d = minor(dev); 44 | tp = &dh11[d]; 45 | addr = DMADDR; 46 | addr += d>>4; 47 | spl5(); 48 | addr->dmcsr = d&017; 49 | addr->dmlstat = TURNON; 50 | if (addr->dmlstat&CARRIER) { 51 | tp->t_state |= CARR_ON; 52 | } 53 | addr->dmcsr = IENABLE|SCENABL; 54 | while ((tp->t_state&CARR_ON)==0) 55 | sleep((caddr_t)&tp->t_rawq, TTIPRI); 56 | addr->dmcsr = d&017; 57 | if (addr->dmlstat&SECR) { 58 | tp->t_ispeed = B1200; 59 | tp->t_ospeed = B1200; 60 | dhparam(dev); 61 | } 62 | addr->dmcsr = IENABLE|SCENABL; 63 | spl0(); 64 | } 65 | 66 | /* 67 | * Dump control bits into the DM registers. 68 | */ 69 | dmctl(dev, bits) 70 | { 71 | register struct device *addr; 72 | register d, s; 73 | 74 | d = minor(dev); 75 | addr = DMADDR; 76 | addr += d>>4; 77 | s = spl5(); 78 | addr->dmcsr = d&017; 79 | addr->dmlstat = bits; 80 | addr->dmcsr = IENABLE|SCENABL; 81 | splx(s); 82 | } 83 | 84 | /* 85 | * DM11 interrupt. 86 | * Mainly, deal with carrier transitions. 87 | */ 88 | dmint(dev) 89 | { 90 | register struct tty *tp; 91 | register struct device *addr; 92 | register d; 93 | 94 | d = minor(dev); 95 | addr = DMADDR; 96 | addr += d; 97 | if (addr->dmcsr&DONE) { 98 | tp = &dh11[(d<<4)+(addr->dmcsr&017)]; 99 | if (tp < &dh11[ndh11]) { 100 | wakeup((caddr_t)&tp->t_rawq); 101 | if ((addr->dmlstat&CARRIER)==0) { 102 | if ((tp->t_state&WOPEN)==0) { 103 | signal(tp->t_pgrp, SIGHUP); 104 | addr->dmlstat = 0; 105 | flushtty(tp); 106 | } 107 | tp->t_state &= ~CARR_ON; 108 | } else { 109 | tp->t_state |= CARR_ON; 110 | } 111 | } 112 | addr->dmcsr = IENABLE|SCENABL; 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /ancient-src/v7/dev/dhfdm.c: -------------------------------------------------------------------------------- 1 | /* 2 | * DM-BB fake driver 3 | */ 4 | #include "../h/param.h" 5 | #include "../h/tty.h" 6 | #include "../h/conf.h" 7 | 8 | struct tty dh11[]; 9 | 10 | dmopen(dev) 11 | { 12 | register struct tty *tp; 13 | 14 | tp = &dh11[minor(dev)]; 15 | tp->t_state |= CARR_ON; 16 | } 17 | 18 | dmctl(dev, bits) 19 | { 20 | } 21 | -------------------------------------------------------------------------------- /ancient-src/v7/dev/dkleave.c: -------------------------------------------------------------------------------- 1 | #include "../h/param.h" 2 | #include "../h/buf.h" 3 | 4 | daddr_t 5 | dkblock(bp) 6 | register struct buf *bp; 7 | { 8 | register int dminor; 9 | 10 | if (((dminor=minor(bp->b_dev))&0100) == 0) 11 | return(bp->b_blkno); 12 | dminor >>= 3; 13 | dminor &= 07; 14 | dminor++; 15 | return(bp->b_blkno/dminor); 16 | } 17 | 18 | dkunit(bp) 19 | register struct buf *bp; 20 | { 21 | register int dminor; 22 | 23 | dminor = minor(bp->b_dev) >> 3; 24 | if ((dminor&010) == 0) 25 | return(dminor); 26 | dminor &= 07; 27 | dminor++; 28 | return(bp->b_blkno%dminor); 29 | } 30 | -------------------------------------------------------------------------------- /ancient-src/v7/dev/dn.c: -------------------------------------------------------------------------------- 1 | /* 2 | * DN-11 ACU interface 3 | */ 4 | 5 | #include "../h/param.h" 6 | #include "../h/dir.h" 7 | #include "../h/user.h" 8 | 9 | struct device { 10 | int dn_reg[4]; 11 | }; 12 | 13 | struct device *dn_addr[] = { (struct device *)0175200 }; 14 | #define NDN 4 15 | 16 | #define PWI 0100000 17 | #define ACR 040000 18 | #define DLO 010000 19 | #define DONE 0200 20 | #define IENABLE 0100 21 | #define DSS 040 22 | #define PND 020 23 | #define MENABLE 04 24 | #define DPR 02 25 | #define CRQ 01 26 | 27 | #define DNPRI (PZERO+5) 28 | 29 | dnopen(dev) 30 | register dev; 31 | { 32 | register struct device *dp; 33 | 34 | dev = minor(dev); 35 | if (dev >= NDN || 36 | (dp = dn_addr[dev>>2])->dn_reg[dev&03]&(PWI|DLO|CRQ)) 37 | u.u_error = ENXIO; 38 | else { 39 | dp->dn_reg[0] |= MENABLE; 40 | dp->dn_reg[dev&03] = IENABLE|MENABLE|CRQ; 41 | } 42 | } 43 | 44 | dnclose(dev) 45 | { 46 | dev = minor(dev); 47 | dn_addr[dev>>2]->dn_reg[dev&03] = MENABLE; 48 | } 49 | 50 | dnwrite(dev) 51 | { 52 | register c; 53 | register *dp; 54 | extern lbolt; 55 | 56 | dev = minor(dev); 57 | dp = &(dn_addr[dev>>2]->dn_reg[dev&03]); 58 | while ((*dp & (PWI|ACR|DSS)) == 0) { 59 | spl4(); 60 | if ((*dp&PND) == 0 || u.u_count == 0 || (c=cpass()) < 0) 61 | sleep((caddr_t)dp, DNPRI); 62 | else if (c == '-') { 63 | sleep((caddr_t)&lbolt, DNPRI); 64 | sleep((caddr_t)&lbolt, DNPRI); 65 | } else { 66 | *dp = (c<<8)|IENABLE|MENABLE|DPR|CRQ; 67 | sleep((caddr_t)dp, DNPRI); 68 | } 69 | spl0(); 70 | } 71 | if (*dp&(PWI|ACR)) 72 | u.u_error = EIO; 73 | } 74 | 75 | /* 76 | * interrupt-- "dev" applies to 77 | * system unit number, not minor device 78 | */ 79 | dnint(dev) 80 | { 81 | register *dp,*ep; 82 | 83 | dp = &(dn_addr[dev]->dn_reg[0]); 84 | *dp &= ~MENABLE; 85 | for (ep=dp; epb_actf; 18 | if(ap == NULL) { 19 | dp->b_actf = bp; 20 | dp->b_actl = bp; 21 | bp->av_forw = NULL; 22 | return; 23 | } 24 | tp = NULL; 25 | for(; ap != NULL; ap = ap->av_forw) { 26 | if ((bp->b_flags&B_READ) && (ap->b_flags&B_READ) == 0) { 27 | if (tp == NULL) 28 | tp = ap; 29 | break; 30 | } 31 | if ((bp->b_flags&B_READ) == 0 && (ap->b_flags&B_READ)) 32 | continue; 33 | if(ap->b_cylin <= bp->b_cylin) 34 | if(tp == NULL || ap->b_cylin >= tp->b_cylin) 35 | tp = ap; 36 | } 37 | if(tp == NULL) 38 | tp = dp->b_actl; 39 | bp->av_forw = tp->av_forw; 40 | tp->av_forw = bp; 41 | if(tp == dp->b_actl) 42 | dp->b_actl = bp; 43 | } 44 | -------------------------------------------------------------------------------- /ancient-src/v7/dev/mem.c: -------------------------------------------------------------------------------- 1 | # 2 | /* 3 | */ 4 | 5 | /* 6 | * Memory special file 7 | * minor device 0 is physical memory 8 | * minor device 1 is kernel memory 9 | * minor device 2 is EOF/RATHOLE 10 | */ 11 | 12 | #include "../h/param.h" 13 | #include "../h/dir.h" 14 | #include "../h/user.h" 15 | #include "../h/conf.h" 16 | #include "../h/seg.h" 17 | 18 | mmread(dev) 19 | { 20 | register c, bn, on; 21 | int a, d; 22 | 23 | if(minor(dev) == 2) 24 | return; 25 | do { 26 | bn = u.u_offset >> 6; 27 | on = u.u_offset & 077; 28 | a = UISA->r[0]; 29 | d = UISD->r[0]; 30 | spl7(); 31 | UISA->r[0] = bn; 32 | UISD->r[0] = 077406; 33 | if(minor(dev) == 1) 34 | UISA->r[0] = (ka6-6)->r[(bn>>7)&07] + (bn & 0177); 35 | if ((c = fuibyte((caddr_t)on)) < 0) 36 | u.u_error = ENXIO; 37 | UISA->r[0] = a; 38 | UISD->r[0] = d; 39 | spl0(); 40 | } while(u.u_error==0 && passc(c)>=0); 41 | } 42 | 43 | mmwrite(dev) 44 | { 45 | register c, bn, on; 46 | int a, d; 47 | 48 | if(minor(dev) == 2) { 49 | u.u_count = 0; 50 | return; 51 | } 52 | for(;;) { 53 | bn = u.u_offset >> 6; 54 | on = u.u_offset & 077; 55 | if ((c=cpass())<0 || u.u_error!=0) 56 | break; 57 | a = UISA->r[0]; 58 | d = UISD->r[0]; 59 | spl7(); 60 | UISA->r[0] = bn; 61 | UISD->r[0] = 077406; 62 | if(minor(dev) == 1) 63 | UISA->r[0] = (ka6-6)->r[(bn>>7)&07] + (bn & 0177); 64 | if (suibyte((caddr_t)on, c) < 0) 65 | u.u_error = ENXIO; 66 | UISA->r[0] = a; 67 | UISD->r[0] = d; 68 | spl0(); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /ancient-src/v7/dev/mklib: -------------------------------------------------------------------------------- 1 | ar rc LIB2 \ 2 | bio.o \ 3 | cat.o \ 4 | dhdm.o \ 5 | dh.o \ 6 | dhfdm.o \ 7 | dn.o \ 8 | du.o \ 9 | hp.o \ 10 | ht.o \ 11 | kl.o \ 12 | mem.o \ 13 | mx1.o \ 14 | mx2.o \ 15 | partab.o \ 16 | rf.o \ 17 | rk.o \ 18 | sys.o \ 19 | tc.o \ 20 | tm.o \ 21 | tty.o \ 22 | vp.o \ 23 | vs.o \ 24 | dsort.o \ 25 | dkleave.o \ 26 | pk0.o \ 27 | pk1.o \ 28 | pk2.o \ 29 | pk3.o \ 30 | dc.o \ 31 | dz.o \ 32 | rl.o \ 33 | rp.o 34 | -------------------------------------------------------------------------------- /ancient-src/v7/dev/partab.c: -------------------------------------------------------------------------------- 1 | /* 2 | */ 3 | 4 | char partab[] = { 5 | 0001,0201,0201,0001,0201,0001,0001,0201, 6 | 0202,0004,0003,0201,0005,0206,0201,0001, 7 | 0201,0001,0001,0201,0001,0201,0201,0001, 8 | 0001,0201,0201,0001,0201,0001,0001,0201, 9 | 0200,0000,0000,0200,0000,0200,0200,0000, 10 | 0000,0200,0200,0000,0200,0000,0000,0200, 11 | 0000,0200,0200,0000,0200,0000,0000,0200, 12 | 0200,0000,0000,0200,0000,0200,0200,0000, 13 | 0200,0000,0000,0200,0000,0200,0200,0000, 14 | 0000,0200,0200,0000,0200,0000,0000,0200, 15 | 0000,0200,0200,0000,0200,0000,0000,0200, 16 | 0200,0000,0000,0200,0000,0200,0200,0000, 17 | 0000,0200,0200,0000,0200,0000,0000,0200, 18 | 0200,0000,0000,0200,0000,0200,0200,0000, 19 | 0200,0000,0000,0200,0000,0200,0200,0000, 20 | 0000,0200,0200,0000,0200,0000,0000,0201 21 | }; 22 | -------------------------------------------------------------------------------- /ancient-src/v7/dev/pk3.c: -------------------------------------------------------------------------------- 1 | #include "../h/param.h" 2 | #include "../h/systm.h" 3 | #include "../h/conf.h" 4 | #include "../h/buf.h" 5 | 6 | #define XPRI 30 7 | #define NBLOCKS 10 8 | 9 | int bwaiting, wcount; 10 | struct buf *bufps[NBLOCKS]; 11 | char *nbase[NBLOCKS]; /* normal allocations */ 12 | short nmap[NBLOCKS]; /* 1 bit == 32 bytes */ 13 | 14 | char log[] ={0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4}; 15 | #define FULL -1 16 | #define LOCK s = spl6() 17 | #define UNLOCK splx(s) 18 | 19 | /* 20 | * getepack: get empty packet 21 | * with size specified by bitmask. 22 | */ 23 | char * 24 | getepack(bits) 25 | { 26 | register i; 27 | int s, savbits; 28 | char **base; 29 | short *map; 30 | 31 | base = nbase; map = nmap; 32 | savbits = bits; 33 | 34 | /* 35 | * search for space 36 | */ 37 | LOCK; 38 | for(;;) { 39 | 40 | if (bits == FULL) 41 | goto force; 42 | 43 | for(i=0; i 16; n >>= 4) 56 | offset += 4; 57 | offset += log[n]; 58 | } else { 59 | bits = savbits; 60 | for(n=17; --n; bits <<= 1) 61 | if ((m&bits)==0) 62 | goto found; 63 | continue; 64 | found: 65 | offset = 16-n; 66 | m |= bits; 67 | } 68 | map[i] = m; 69 | UNLOCK; 70 | return(base[i] + 32*offset); 71 | } 72 | /* 73 | * grab another block from the system 74 | */ 75 | force: 76 | for(i=0;ib_flags |= B_PACK; 83 | bp->b_flags |= B_PBUSY; 84 | map[i] = bits; 85 | base[i] = bp->b_un.b_addr; 86 | UNLOCK; 87 | return(bp->b_un.b_addr); 88 | } 89 | /* 90 | * sleep until something is released 91 | */ 92 | bwaiting++; 93 | wcount++; 94 | sleep((caddr_t)&bwaiting, XPRI); 95 | bwaiting--; 96 | } 97 | } 98 | 99 | /* 100 | * freepack: release space beginning 101 | * at address p with length specified 102 | * by bits. 103 | */ 104 | freepack(p, bits) 105 | char *p; 106 | { 107 | register i, d, s; 108 | char **base; 109 | short *map; 110 | 111 | if (p==NULL) 112 | return; 113 | LOCK; 114 | base = nbase; map = nmap; 115 | 116 | for(i=0;i=0 && d<=512) 119 | goto found; 120 | } 121 | goto out; 122 | found: 123 | d >>= 5; 124 | d = (bits<b_flags &= ~B_PBUSY; 131 | base[i] = NULL; 132 | bufps[i] = NULL; 133 | brelse(bp); 134 | } 135 | if (bwaiting) 136 | wakeup((caddr_t)&bwaiting); 137 | out: 138 | splx(s); 139 | } 140 | 141 | 142 | 143 | /* 144 | * integer to bitmap conversion 145 | */ 146 | dtom(d) 147 | register d; 148 | { 149 | register m; 150 | 151 | m = 1; 152 | while (d>32) { 153 | d -= 32; 154 | m |= m+1; 155 | } 156 | return(m); 157 | } 158 | 159 | #define NRECS 160 160 | int reclist[NRECS]; 161 | int recbits[NRECS]; 162 | 163 | -------------------------------------------------------------------------------- /ancient-src/v7/dev/rf.c: -------------------------------------------------------------------------------- 1 | # 2 | /* 3 | * RF disk driver 4 | */ 5 | 6 | #include "../h/param.h" 7 | #include "../h/systm.h" 8 | #include "../h/buf.h" 9 | #include "../h/conf.h" 10 | #include "../h/dir.h" 11 | #include "../h/user.h" 12 | 13 | struct device { 14 | int rfcs; 15 | int rfwc; 16 | char *rfba; 17 | int rfda; 18 | int rfdae; 19 | }; 20 | 21 | struct buf rftab; 22 | struct buf rrfbuf; 23 | 24 | #define NRFBLK 1024 25 | #define RFADDR ((struct device *)0177460) 26 | 27 | #define GO 01 28 | #define RCOM 04 29 | #define WCOM 02 30 | #define CTLCLR 0400 31 | #define IENABLE 0100 32 | 33 | /* 34 | * Monitoring device number 35 | */ 36 | #define DK_N 0 37 | 38 | rfstrategy(bp) 39 | register struct buf *bp; 40 | { 41 | if(bp->b_flags&B_PHYS) 42 | mapalloc(bp); 43 | if (bp->b_blkno >= NRFBLK*(minor(bp->b_dev)+1)) { 44 | bp->b_flags |= B_ERROR; 45 | iodone(bp); 46 | return; 47 | } 48 | bp->av_forw = 0; 49 | spl5(); 50 | if (rftab.b_actf == NULL) 51 | rftab.b_actf = bp; 52 | else 53 | rftab.b_actl->av_forw = bp; 54 | rftab.b_actl = bp; 55 | if (rftab.b_active == NULL) 56 | rfstart(); 57 | spl0(); 58 | } 59 | 60 | rfstart() 61 | { 62 | register struct buf *bp; 63 | register int com; 64 | 65 | if ((bp = rftab.b_actf) == NULL) 66 | return; 67 | rftab.b_active++; 68 | RFADDR->rfda = (int)(bp->b_blkno<<8)&0177777; 69 | RFADDR->rfdae = (int)(bp->b_blkno>>8)&037; 70 | RFADDR->rfba = bp->b_un.b_addr; 71 | RFADDR->rfwc = -(bp->b_bcount>>1); 72 | com = (bp->b_xmem&3) << 4; 73 | com |= (bp->b_flags & B_READ) ? RCOM+GO+IENABLE : WCOM+GO+IENABLE; 74 | RFADDR->rfcs = com; 75 | dk_busy |= 1<b_bcount>>5) & 03777; 78 | dk_wds[DK_N] += com; 79 | } 80 | 81 | rfintr() 82 | { 83 | register struct buf *bp; 84 | 85 | if (rftab.b_active == NULL) 86 | return; 87 | dk_busy &= ~(1<rfcs < 0) { /* error bit */ 91 | deverror(bp, RFADDR->rfcs, RFADDR->rfdae); 92 | RFADDR->rfcs = CTLCLR; 93 | if (++rftab.b_errcnt <= 10) { 94 | rfstart(); 95 | return; 96 | } 97 | bp->b_flags |= B_ERROR; 98 | } 99 | rftab.b_errcnt = 0; 100 | rftab.b_actf = bp->av_forw; 101 | bp->b_resid = 0; 102 | iodone(bp); 103 | rfstart(); 104 | } 105 | 106 | rfread(dev) 107 | { 108 | 109 | physio(rfstrategy, &rrfbuf, dev, B_READ); 110 | } 111 | 112 | rfwrite(dev) 113 | { 114 | 115 | physio(rfstrategy, &rrfbuf, dev, B_WRITE); 116 | } 117 | -------------------------------------------------------------------------------- /ancient-src/v7/dev/rk.c: -------------------------------------------------------------------------------- 1 | /* 2 | * RK disk driver 3 | */ 4 | 5 | #include "../h/param.h" 6 | #include "../h/systm.h" 7 | #include "../h/buf.h" 8 | #include "../h/conf.h" 9 | #include "../h/dir.h" 10 | #include "../h/user.h" 11 | 12 | #define RKADDR ((struct device *)0177400) 13 | #define NRK 4 14 | #define NRKBLK 4872 15 | 16 | #define RESET 0 17 | #define WCOM 2 18 | #define RCOM 4 19 | #define GO 01 20 | #define DRESET 014 21 | #define IENABLE 0100 22 | #define DRY 0200 23 | #define ARDY 0100 24 | #define WLO 020000 25 | #define CTLRDY 0200 26 | 27 | /* 28 | * Monitoring device bit 29 | */ 30 | #define DK_N 1 31 | 32 | struct device 33 | { 34 | int rkds; 35 | int rker; 36 | int rkcs; 37 | int rkwc; 38 | caddr_t rkba; 39 | int rkda; 40 | }; 41 | 42 | struct buf rktab; 43 | struct buf rrkbuf; 44 | 45 | rkstrategy(bp) 46 | register struct buf *bp; 47 | { 48 | 49 | if(bp->b_flags&B_PHYS) 50 | mapalloc(bp); 51 | if (bp->b_blkno >= NRKBLK) { 52 | bp->b_flags |= B_ERROR; 53 | iodone(bp); 54 | return; 55 | } 56 | bp->av_forw = (struct buf *)NULL; 57 | spl5(); 58 | if(rktab.b_actf == NULL) 59 | rktab.b_actf = bp; 60 | else 61 | rktab.b_actl->av_forw = bp; 62 | rktab.b_actl = bp; 63 | if(rktab.b_active == NULL) 64 | rkstart(); 65 | spl0(); 66 | } 67 | 68 | rkstart() 69 | { 70 | register struct buf *bp; 71 | register com; 72 | daddr_t bn; 73 | int dn, cn, sn; 74 | 75 | if ((bp = rktab.b_actf) == NULL) 76 | return; 77 | rktab.b_active++; 78 | bn = bp->b_blkno; 79 | dn = minor(bp->b_dev); 80 | cn = bn/12; 81 | sn = bn%12; 82 | RKADDR->rkda = (dn<<13) | (cn<<4) | sn; 83 | RKADDR->rkba = bp->b_un.b_addr; 84 | RKADDR->rkwc = -(bp->b_bcount>>1); 85 | com = ((bp->b_xmem&3) << 4) | IENABLE | GO; 86 | if(bp->b_flags & B_READ) 87 | com |= RCOM; else 88 | com |= WCOM; 89 | RKADDR->rkcs = com; 90 | dk_busy |= 1<b_bcount>>6; 93 | dk_wds[DK_N] += com; 94 | } 95 | 96 | rkintr() 97 | { 98 | register struct buf *bp; 99 | 100 | if (rktab.b_active == NULL) 101 | return; 102 | dk_busy &= ~(1<rkcs < 0) { /* error bit */ 106 | deverror(bp, RKADDR->rker, RKADDR->rkds); 107 | RKADDR->rkcs = RESET|GO; 108 | while((RKADDR->rkcs&CTLRDY) == 0) 109 | ; 110 | if (++rktab.b_errcnt <= 10) { 111 | rkstart(); 112 | return; 113 | } 114 | bp->b_flags |= B_ERROR; 115 | } 116 | rktab.b_errcnt = 0; 117 | rktab.b_actf = bp->av_forw; 118 | bp->b_resid = 0; 119 | iodone(bp); 120 | rkstart(); 121 | } 122 | 123 | rkread(dev) 124 | dev_t dev; 125 | { 126 | 127 | physio(rkstrategy, &rrkbuf, dev, B_READ); 128 | } 129 | 130 | rkwrite(dev) 131 | dev_t dev; 132 | { 133 | 134 | physio(rkstrategy, &rrkbuf, dev, B_WRITE); 135 | } 136 | -------------------------------------------------------------------------------- /ancient-src/v7/dev/sys.c: -------------------------------------------------------------------------------- 1 | /* 2 | * indirect driver for controlling tty. 3 | */ 4 | #include "../h/param.h" 5 | #include "../h/conf.h" 6 | #include "../h/dir.h" 7 | #include "../h/user.h" 8 | #include "../h/tty.h" 9 | #include "../h/proc.h" 10 | 11 | syopen(dev, flag) 12 | { 13 | 14 | if(u.u_ttyp == NULL) { 15 | u.u_error = ENXIO; 16 | return; 17 | } 18 | (*cdevsw[major(u.u_ttyd)].d_open)(u.u_ttyd, flag); 19 | } 20 | 21 | syread(dev) 22 | { 23 | 24 | (*cdevsw[major(u.u_ttyd)].d_read)(u.u_ttyd); 25 | } 26 | 27 | sywrite(dev) 28 | { 29 | 30 | (*cdevsw[major(u.u_ttyd)].d_write)(u.u_ttyd); 31 | } 32 | 33 | sysioctl(dev, cmd, addr, flag) 34 | caddr_t addr; 35 | { 36 | 37 | (*cdevsw[major(u.u_ttyd)].d_ioctl)(u.u_ttyd, cmd, addr, flag); 38 | } 39 | -------------------------------------------------------------------------------- /ancient-src/v7/dev/vs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Screw Works interface via DC-11 3 | */ 4 | 5 | #include "../h/types.h" 6 | #include "../h/tty.h" 7 | 8 | #define VSADDR ((struct device *)0174140) 9 | #define CDLEAD 01 10 | #define B1200 030 11 | #define STOP1 0400 12 | #define CLSEND 02 13 | #define RQSEND 01 14 | 15 | #define GO 026 16 | #define COUNT 120 17 | 18 | struct device { 19 | int vsrcsr; 20 | int vsrbuf; 21 | int vsxcsr; 22 | int vsxbuf; 23 | }; 24 | 25 | struct { 26 | struct clist iq; 27 | int vtime; 28 | struct clist oq; 29 | } vs; 30 | 31 | 32 | vsopen(dev) 33 | { 34 | register c; 35 | 36 | c = VSADDR->vsrcsr; /* touch register */ 37 | VSADDR->vsrcsr = IENABLE|B1200|CDLEAD; 38 | VSADDR->vsxcsr = STOP1|IENABLE|B1200; 39 | vschar(GO); 40 | } 41 | 42 | vsclose(dev) 43 | { 44 | vschar(GO); 45 | VSADDR->vsrcsr &= ~IENABLE; 46 | while (getc(&vs.iq) >= 0); 47 | } 48 | 49 | vswrite(dev) 50 | { 51 | register int count, c; 52 | 53 | count = 0; 54 | while ((c=cpass()) >= 0) { 55 | if (--count <= 0) { 56 | count = COUNT; 57 | vschar(GO); 58 | } 59 | vschar(c); 60 | } 61 | vschar(GO); 62 | } 63 | 64 | vschar(c) 65 | { 66 | 67 | spl5(); 68 | while (vs.oq.c_cc > 120) { 69 | vsxintr(); 70 | sleep((caddr_t)&vs.oq, TTIPRI); 71 | } 72 | putc(c, &vs.oq); 73 | vsxintr(); 74 | spl0(); 75 | } 76 | 77 | vstimo() 78 | { 79 | vs.vtime = 0; 80 | vsxintr(); 81 | } 82 | 83 | vsxintr() 84 | { 85 | static lchar; 86 | register c; 87 | register int *xcsr; 88 | 89 | xcsr = &VSADDR->vsxcsr; 90 | if (*xcsr&DONE) { 91 | if (lchar==GO) { 92 | *xcsr &= ~RQSEND; 93 | lchar = -1; 94 | if (vs.oq.c_cc==0) { 95 | wakeup((caddr_t)&vs.oq); 96 | return; 97 | } 98 | } 99 | if ((*xcsr&CLSEND) == 0) { 100 | *xcsr |= RQSEND; 101 | if ((*xcsr&CLSEND) == 0) { 102 | if (vs.vtime==0) { 103 | vs.vtime++; 104 | timeout(vstimo, (caddr_t)0, 60); 105 | } 106 | return; 107 | } 108 | } 109 | if ((c = getc(&vs.oq)) >= 0) 110 | VSADDR->vsxbuf = lchar = c; 111 | else 112 | *xcsr &= ~RQSEND; 113 | if (vs.oq.c_cc <= 15) 114 | wakeup((caddr_t)&vs.oq); 115 | } 116 | } 117 | 118 | vsread(dev) 119 | { 120 | register int c; 121 | 122 | spl5(); 123 | while ((c = getc(&vs.iq)) < 0) 124 | sleep((caddr_t)&vs.iq, TTIPRI); 125 | spl0(); 126 | passc("?0*#?546?213?879?"[c&017]); 127 | } 128 | 129 | vsrintr() 130 | { 131 | register int c; 132 | 133 | c = VSADDR->vsrbuf; /* Register must be read (?) */ 134 | c = VSADDR->vsrbuf; 135 | if (vs.iq.c_cc<=10) 136 | putc(c, &vs.iq); 137 | wakeup((caddr_t)&vs.iq); 138 | } 139 | -------------------------------------------------------------------------------- /ancient-src/v7/h/acct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Accounting structures 3 | */ 4 | 5 | typedef unsigned short comp_t; /* "floating pt": 3 bits base 8 exp, 13 bits fraction */ 6 | struct acct 7 | { 8 | char ac_comm[10]; /* Accounting command name */ 9 | comp_t ac_utime; /* Accounting user time */ 10 | comp_t ac_stime; /* Accounting system time */ 11 | comp_t ac_etime; /* Accounting elapsed time */ 12 | time_t ac_btime; /* Beginning time */ 13 | short ac_uid; /* Accounting user ID */ 14 | short ac_gid; /* Accounting group ID */ 15 | short ac_mem; /* average memory usage */ 16 | comp_t ac_io; /* number of disk IO blocks */ 17 | dev_t ac_tty; /* control typewriter */ 18 | char ac_flag; /* Accounting flag */ 19 | }; 20 | 21 | extern struct acct acctbuf; 22 | extern struct inode *acctp; /* inode of accounting file */ 23 | 24 | #define AFORK 01 /* has executed fork, but no exec */ 25 | #define ASU 02 /* used super-user privileges */ 26 | -------------------------------------------------------------------------------- /ancient-src/v7/h/buf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Each buffer in the pool is usually doubly linked into 2 lists: 3 | * the device with which it is currently associated (always) 4 | * and also on a list of blocks available for allocation 5 | * for other use (usually). 6 | * The latter list is kept in last-used order, and the two 7 | * lists are doubly linked to make it easy to remove 8 | * a buffer from one list when it was found by 9 | * looking through the other. 10 | * A buffer is on the available list, and is liable 11 | * to be reassigned to another disk block, if and only 12 | * if it is not marked BUSY. When a buffer is busy, the 13 | * available-list pointers can be used for other purposes. 14 | * Most drivers use the forward ptr as a link in their I/O 15 | * active queue. 16 | * A buffer header contains all the information required 17 | * to perform I/O. 18 | * Most of the routines which manipulate these things 19 | * are in bio.c. 20 | */ 21 | struct buf 22 | { 23 | int b_flags; /* see defines below */ 24 | struct buf *b_forw; /* headed by d_tab of conf.c */ 25 | struct buf *b_back; /* " */ 26 | struct buf *av_forw; /* position on free list, */ 27 | struct buf *av_back; /* if not BUSY*/ 28 | dev_t b_dev; /* major+minor device name */ 29 | unsigned b_bcount; /* transfer count */ 30 | union { 31 | caddr_t b_addr; /* low order core address */ 32 | int16_t *b_words; /* words for clearing */ 33 | struct filsys *b_filsys; /* superblocks */ 34 | struct dinode *b_dino; /* ilist */ 35 | daddr_t *b_daddr; /* indirect block */ 36 | } b_un; 37 | daddr_t b_blkno; /* block # on device */ 38 | char b_xmem; /* high order core address */ 39 | char b_error; /* returned after I/O */ 40 | unsigned int b_resid; /* words not transferred after error */ 41 | }; 42 | 43 | extern struct buf buf[]; /* The buffer pool itself */ 44 | extern struct buf bfreelist; /* head of available list */ 45 | 46 | /* 47 | * These flags are kept in b_flags. 48 | */ 49 | #define B_WRITE 0 /* non-read pseudo-flag */ 50 | #define B_READ 01 /* read when I/O occurs */ 51 | #define B_DONE 02 /* transaction finished */ 52 | #define B_ERROR 04 /* transaction aborted */ 53 | #define B_BUSY 010 /* not on av_forw/back list */ 54 | #define B_PHYS 020 /* Physical IO potentially using UNIBUS map */ 55 | #define B_MAP 040 /* This block has the UNIBUS map allocated */ 56 | #define B_WANTED 0100 /* issue wakeup when BUSY goes off */ 57 | #define B_AGE 0200 /* delayed write for correct aging */ 58 | #define B_ASYNC 0400 /* don't wait for I/O completion */ 59 | #define B_DELWRI 01000 /* don't write till block leaves available list */ 60 | #define B_TAPE 02000 /* this is a magtape (no bdwrite) */ 61 | #define B_PBUSY 04000 62 | #define B_PACK 010000 63 | 64 | /* 65 | * special redeclarations for 66 | * the head of the queue per 67 | * device driver. 68 | */ 69 | #define b_actf av_forw 70 | #define b_actl av_back 71 | #define b_active b_bcount 72 | #define b_errcnt b_resid 73 | -------------------------------------------------------------------------------- /ancient-src/v7/h/callo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The callout structure is for 3 | * a routine arranging 4 | * to be called by the clock interrupt 5 | * (clock.c) with a specified argument, 6 | * in a specified amount of time. 7 | * Used, for example, to time tab 8 | * delays on typewriters. 9 | */ 10 | 11 | struct callo 12 | { 13 | int c_time; /* incremental time */ 14 | caddr_t c_arg; /* argument to routine */ 15 | int (*c_func)(); /* routine */ 16 | }; 17 | struct callo callout[NCALL]; 18 | -------------------------------------------------------------------------------- /ancient-src/v7/h/conf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Declaration of block device 3 | * switch. Each entry (row) is 4 | * the only link between the 5 | * main unix code and the driver. 6 | * The initialization of the 7 | * device switches is in the 8 | * file conf.c. 9 | */ 10 | extern struct bdevsw 11 | { 12 | int16_t (*d_open)(dev_t dev, int16_t flag); 13 | int16_t (*d_close)(dev_t dev, int16_t flag); 14 | int16_t (*d_strategy)(struct buf *bp); 15 | struct buf *d_tab; 16 | } bdevsw[]; 17 | 18 | /* 19 | * Character device switch. 20 | */ 21 | extern struct cdevsw 22 | { 23 | int16_t (*d_open)(); 24 | int16_t (*d_close)(); 25 | int16_t (*d_read)(); 26 | int16_t (*d_write)(); 27 | int16_t (*d_ioctl)(); 28 | int16_t (*d_stop)(); 29 | struct tty *d_ttys; 30 | } cdevsw[]; 31 | 32 | /* 33 | * tty line control switch. 34 | */ 35 | extern struct linesw 36 | { 37 | int16_t (*l_open)(); 38 | int16_t (*l_close)(); 39 | int16_t (*l_read)(); 40 | char *(*l_write)(); 41 | int16_t (*l_ioctl)(); 42 | int16_t (*l_rint)(); 43 | int16_t (*l_rend)(); 44 | int16_t (*l_meta)(); 45 | int16_t (*l_start)(); 46 | int16_t (*l_modem)(); 47 | } linesw[]; 48 | -------------------------------------------------------------------------------- /ancient-src/v7/h/dir.h: -------------------------------------------------------------------------------- 1 | #ifndef DIRSIZ 2 | #define DIRSIZ 14 3 | #endif 4 | struct direct 5 | { 6 | ino_t d_ino; 7 | char d_name[DIRSIZ]; 8 | }; 9 | -------------------------------------------------------------------------------- /ancient-src/v7/h/fblk.h: -------------------------------------------------------------------------------- 1 | struct fblk 2 | { 3 | int16_t df_nfree; 4 | daddr_t df_free[NICFREE]; 5 | } __attribute__((packed)); 6 | -------------------------------------------------------------------------------- /ancient-src/v7/h/file.h: -------------------------------------------------------------------------------- 1 | /* 2 | * One file structure is allocated 3 | * for each open/creat/pipe call. 4 | * Main use is to hold the read/write 5 | * pointer associated with each open 6 | * file. 7 | */ 8 | struct file 9 | { 10 | char f_flag; 11 | char f_count; /* reference count */ 12 | struct inode *f_inode; /* pointer to inode structure */ 13 | union { 14 | off_t f_offset; /* read/write character pointer */ 15 | struct chan *f_chan; /* mpx channel pointer */ 16 | } f_un; 17 | }; 18 | 19 | extern struct file file[]; /* The file table itself */ 20 | 21 | /* flags */ 22 | #define FREAD 01 23 | #define FWRITE 02 24 | #define FPIPE 04 25 | #define FMPX 010 26 | #define FMPY 020 27 | #define FMP 030 28 | #define FKERNEL 040 29 | -------------------------------------------------------------------------------- /ancient-src/v7/h/filsys.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Structure of the super-block 3 | */ 4 | struct filsys { 5 | uint16_t s_isize; /* size in blocks of i-list */ 6 | daddr_t s_fsize; /* size in blocks of entire volume */ 7 | short s_nfree; /* number of addresses in s_free */ 8 | daddr_t s_free[NICFREE];/* free block list */ 9 | int16_t s_ninode; /* number of i-nodes in s_inode */ 10 | ino_t s_inode[NICINOD];/* free i-node list */ 11 | char s_flock; /* lock during free list manipulation */ 12 | char s_ilock; /* lock during i-list manipulation */ 13 | char s_fmod; /* super block modified flag */ 14 | char s_ronly; /* mounted read-only flag */ 15 | time_t s_time; /* last super block update */ 16 | /* remainder not maintained by this version of the system */ 17 | daddr_t s_tfree; /* total free blocks*/ 18 | ino_t s_tinode; /* total free inodes */ 19 | int16_t s_m; /* interleave factor */ 20 | int16_t s_n; /* " " */ 21 | char s_fname[6]; /* file system name */ 22 | char s_fpack[6]; /* file system pack name */ 23 | } __attribute__((packed)); 24 | -------------------------------------------------------------------------------- /ancient-src/v7/h/ino.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Inode structure as it appears on 3 | * a disk block. 4 | */ 5 | struct dinode 6 | { 7 | unsigned short di_mode; /* mode and type of file */ 8 | short di_nlink; /* number of links to file */ 9 | short di_uid; /* owner's user id */ 10 | short di_gid; /* owner's group id */ 11 | off_t di_size; /* number of bytes in file */ 12 | char di_addr[40]; /* disk block addresses */ 13 | time_t di_atime; /* time last accessed */ 14 | time_t di_mtime; /* time last modified */ 15 | time_t di_ctime; /* time created */ 16 | }; 17 | #define INOPB 8 /* 8 inodes per block */ 18 | /* 19 | * the 40 address bytes: 20 | * 39 used; 13 addresses 21 | * of 3 bytes each. 22 | */ 23 | -------------------------------------------------------------------------------- /ancient-src/v7/h/inode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The I node is the focus of all 3 | * file activity in unix. There is a unique 4 | * inode allocated for each active file, 5 | * each current directory, each mounted-on 6 | * file, text file, and the root. An inode is 'named' 7 | * by its dev/inumber pair. (iget/iget.c) 8 | * Data, from mode on, is read in 9 | * from permanent inode on volume. 10 | */ 11 | 12 | #define NADDR 13 13 | #define NINDEX 15 14 | 15 | struct group { 16 | short g_state; 17 | char g_index; 18 | char g_rot; 19 | struct group *g_group; 20 | struct inode *g_inode; 21 | struct file *g_file; 22 | short g_rotmask; 23 | short g_datq; 24 | struct chan *g_chans[NINDEX]; 25 | }; 26 | struct inode 27 | { 28 | char i_flag; 29 | char i_count; /* reference count */ 30 | dev_t i_dev; /* device where inode resides */ 31 | ino_t i_number; /* i number, 1-to-1 with device address */ 32 | uint16_t i_mode; 33 | int16_t i_nlink; /* directory entries */ 34 | int16_t i_uid; /* owner */ 35 | int16_t i_gid; /* group of owner */ 36 | off_t i_size; /* size of file */ 37 | union { 38 | struct { 39 | daddr_t i_addr[NADDR]; /* if normal file/directory */ 40 | daddr_t i_lastr; /* last logical block read (for read-ahead) */ 41 | }; 42 | struct { 43 | daddr_t i_rdev; /* i_addr[0] */ 44 | struct group i_group; /* multiplexor group file */ 45 | }; 46 | } i_un; 47 | }; 48 | 49 | 50 | extern struct inode inode[]; /* The inode table itself */ 51 | extern struct inode *mpxip; /* mpx virtual inode */ 52 | 53 | /* flags */ 54 | #define ILOCK 01 /* inode is locked */ 55 | #define IUPD 02 /* file has been modified */ 56 | #define IACC 04 /* inode access time to be updated */ 57 | #define IMOUNT 010 /* inode is mounted on */ 58 | #define IWANT 020 /* some process waiting on lock */ 59 | #define ITEXT 040 /* inode is pure text prototype */ 60 | #define ICHG 0100 /* inode has been changed */ 61 | 62 | /* modes */ 63 | #define IFMT 0170000 /* type of file */ 64 | #define IFDIR 0040000 /* directory */ 65 | #define IFCHR 0020000 /* character special */ 66 | #define IFBLK 0060000 /* block special */ 67 | #define IFREG 0100000 /* regular */ 68 | #define IFMPC 0030000 /* multiplexed char special */ 69 | #define IFMPB 0070000 /* multiplexed block special */ 70 | #define ISUID 04000 /* set user id on execution */ 71 | #define ISGID 02000 /* set group id on execution */ 72 | #define ISVTX 01000 /* save swapped text even after use */ 73 | #define IREAD 0400 /* read, write, execute permissions */ 74 | #define IWRITE 0200 75 | #define IEXEC 0100 76 | -------------------------------------------------------------------------------- /ancient-src/v7/h/map.h: -------------------------------------------------------------------------------- 1 | struct map 2 | { 3 | short m_size; 4 | unsigned short m_addr; 5 | }; 6 | 7 | struct map coremap[CMAPSIZ]; /* space for core allocation */ 8 | struct map swapmap[SMAPSIZ]; /* space for swap allocation */ 9 | -------------------------------------------------------------------------------- /ancient-src/v7/h/mount.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mount structure. 3 | * One allocated on every mount. 4 | * Used to find the super block. 5 | */ 6 | struct mount 7 | { 8 | dev_t m_dev; /* device mounted */ 9 | struct buf *m_bufp; /* pointer to superblock */ 10 | struct inode *m_inodp; /* pointer to mounted on inode */ 11 | }; 12 | extern struct mount mount[NMOUNT]; 13 | -------------------------------------------------------------------------------- /ancient-src/v7/h/mpx.h: -------------------------------------------------------------------------------- 1 | #define M 3 2 | #define C 100 3 | 4 | /* 5 | * character Q structure 6 | */ 7 | struct clist 8 | { 9 | int c_cc; 10 | int c_cf; 11 | int c_cl; 12 | }; 13 | 14 | struct chan 15 | { 16 | char cflag; 17 | char m, c; 18 | struct chan *dest; 19 | struct clist ioq; 20 | }; 21 | 22 | /* c flags */ 23 | #define BLOCK 01 24 | 25 | struct line 26 | { 27 | char xbuf[24+2]; 28 | char rbuf[100+2]; 29 | char rseq; 30 | char xseq; 31 | char ackf; 32 | char xflag; 33 | char state; 34 | char time; 35 | int sum; 36 | char *ip; 37 | char *ep; 38 | }; 39 | #define WWAIT 02 40 | #define CRUN 04 41 | #define RWAIT 010 42 | #define ALLOC 020 43 | #define DIS 040 44 | #define DLY 0100 45 | 46 | /* 47 | * machine structure 48 | */ 49 | struct mach 50 | { 51 | char mflag; 52 | char rchan; 53 | char rcount; 54 | char xchan; 55 | char xcount; 56 | struct clist ackq; 57 | struct clist datq; 58 | struct clist disq; 59 | struct chan *chanp[128]; 60 | }; 61 | 62 | /* m flags */ 63 | #define RNEXT 01 64 | #define MRUN 04 65 | #define XNEXT 010 66 | 67 | /* 68 | * trace buffer 69 | */ 70 | #define TBSIZ 100 71 | -------------------------------------------------------------------------------- /ancient-src/v7/h/mx.h: -------------------------------------------------------------------------------- 1 | #define NGROUPS 10 /* number of mpx files permitted at one time */ 2 | #define NCHANS 20 /* number of channel structures */ 3 | #define NPORTS 30 /* number of channels to i/o ports */ 4 | #define CNTLSIZ 10 5 | #define NLEVELS 4 6 | #define NMSIZE 50 /* max size of mxlstn file name */ 7 | 8 | /* 9 | * header returned on read of mpx 10 | */ 11 | struct rh { 12 | short index; 13 | short count; 14 | short ccount; 15 | }; 16 | 17 | /* 18 | * head expected on write of mpx 19 | */ 20 | struct wh { 21 | short index; 22 | short count; 23 | short ccount; 24 | char *data; 25 | }; 26 | 27 | struct mx_args { 28 | char *m_name; 29 | int m_cmd; 30 | int m_arg[3]; 31 | }; 32 | 33 | 34 | #ifdef KERNEL 35 | /* 36 | * internal structure for channel 37 | */ 38 | 39 | struct chan { 40 | short c_flags; 41 | char c_index; 42 | char c_line; 43 | struct group *c_group; 44 | struct file *c_fy; 45 | struct tty *c_ttyp; 46 | struct clist c_ctlx; 47 | int c_pgrp; 48 | struct tty *c_ottyp; 49 | char c_oline; 50 | union { 51 | struct clist datq; 52 | } cx; 53 | union { 54 | struct clist datq; 55 | struct chan *c_chan; 56 | } cy; 57 | struct clist c_ctly; 58 | }; 59 | 60 | struct schan { 61 | short c_flags; 62 | char c_index; 63 | char c_line; 64 | struct group *c_group; 65 | struct file *c_fy; 66 | struct tty *c_ttyp; 67 | struct clist c_ctlx; 68 | int c_pgrp; 69 | }; 70 | 71 | 72 | /* 73 | * flags 74 | */ 75 | #define INUSE 01 76 | #define COPEN 02 77 | #define XGRP 04 78 | #define YGRP 010 79 | #define WCLOSE 020 80 | #define ISGRP 0100 81 | #define BLOCK 0200 82 | #define EOTMARK 0400 83 | #define SIGBLK 01000 84 | #define BLKMSG 01000 85 | #define ENAMSG 02000 86 | #define WFLUSH 04000 87 | #define NMBUF 010000 88 | #define PORT 020000 89 | #define ALT 040000 90 | 91 | #endif 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | /* 102 | * mpxchan command codes 103 | */ 104 | #define MPX 5 105 | #define MPXN 6 106 | #define CHAN 1 107 | #define JOIN 2 108 | #define EXTR 3 109 | #define ATTACH 4 110 | #define CONNECT 7 111 | #define DETACH 8 112 | #define DISCON 9 113 | #define DEBUG 10 114 | #define NPGRP 11 115 | #define CSIG 12 116 | #define PACK 13 117 | 118 | #define NDEBUGS 30 119 | /* 120 | * control channel message codes 121 | */ 122 | #define M_WATCH 1 123 | #define M_CLOSE 2 124 | #define M_EOT 3 125 | #define M_OPEN 4 126 | #define M_BLK 5 127 | #define M_UBLK 6 128 | #define DO_BLK 7 129 | #define DO_UBLK 8 130 | #define M_IOCTL 12 131 | #define M_SIG 14 132 | 133 | 134 | /* 135 | * debug codes other than mpxchan cmds 136 | */ 137 | #define MCCLOSE 29 138 | #define MCOPEN 28 139 | #define ALL 27 140 | #define SCON 26 141 | #define MSREAD 25 142 | #define SDATA 24 143 | #define MCREAD 23 144 | #define MCWRITE 22 145 | 146 | -------------------------------------------------------------------------------- /ancient-src/v7/h/pack.h: -------------------------------------------------------------------------------- 1 | struct header { 2 | char sync; 3 | char ksize; 4 | short sum; 5 | char cntl; 6 | char ccntl; 7 | }; 8 | #define HDRSIZ 6 9 | 10 | struct pack { 11 | short p_state; /* line state */ 12 | short p_bits; /* mask for getepack */ 13 | short p_rsize; /* input packet size */ 14 | short p_xsize; /* output packet size */ 15 | struct header p_ihbuf; /* input header */ 16 | struct header p_ohbuf; /* output header */ 17 | char *p_rptr; 18 | char p_mode; 19 | char **p_ipool; 20 | char p_xcount; /* # active output buffers */ 21 | char p_rcount; 22 | char p_nout,p_tout; 23 | char p_lpsize; /* log(psize/32) */ 24 | char p_timer; 25 | char p_obusy; 26 | char p_srxmit; 27 | char p_rwindow; /* window size */ 28 | char p_swindow; 29 | char p_msg; /* control msg */ 30 | char p_rmsg; /* repeated control msg */ 31 | char p_ps,p_pr; /* last packet sent, recv'd */ 32 | char p_rpr; 33 | char p_nxtps; /* next output seq number */ 34 | char p_imap; /* bit map of input buffers */ 35 | char p_pscopy; /* newest output packet */ 36 | char *p_ob[8]; /* output buffers */ 37 | char *p_ib[8]; /* input buffers */ 38 | char p_os[8]; /* output buffer status */ 39 | char p_is[8]; /* input buffer status */ 40 | short p_osum[8]; /* output checksums */ 41 | short p_isum[8]; /* input checksums */ 42 | DSYSTEM; 43 | }; 44 | #define CHECK 0125252 45 | #define SYN 020 46 | #define MOD8 7 47 | #define ISCNTL(a) ((a & 0300)==0) 48 | #define MIN(a,b) ((at_linep) 7 | #define TURNOFF pkturnoff(tp) 8 | #define UCOUNT u.u_count 9 | #define S tp 10 | #define P pk->p_ttyp 11 | #define SDEF struct tty *tp 12 | #define FS , tp 13 | 14 | #define SIGNAL signal(pk->p_ttyp->t_pgrp, SIGPIPE) 15 | #define TERROR pk->p_istate == R_ERROR 16 | #define SETERROR u.u_error = EIO 17 | #define OBUSY tp->t_state&BUSY 18 | #define ODEAD ((tp->t_state&CARR_ON)==0) 19 | char *getepack(); 20 | #define GETEPACK getepack(pk->p_bits) 21 | #define FREEPACK(a,b) freepack(a, b) 22 | 23 | 24 | #define q1 tp->t_rawq 25 | #define q2 tp->t_canq 26 | #define q3 tp->t_outq 27 | 28 | #define LOCK s = spl6() 29 | #define UNLOCK splx(s) 30 | #define DSYSTEM struct tty *p_ttyp 31 | #define ISYSTEM tp = pk->p_ttyp 32 | #define SLEEP(a, b) sleep((caddr_t)a, b) 33 | #define SLEEPNO (tp->t_chan!=NULL) 34 | #define WAKEUP(a) wakeup((caddr_t)a) 35 | #define IOMOVE(p, c, f) iomove(p, c, f) 36 | #define PKGETPKT(p) 37 | #define DTOM(a) dtom(a) 38 | #include "../h/param.h" 39 | #include "../h/dir.h" 40 | #include "../h/user.h" 41 | #include "../h/pk.h" 42 | #include "../h/tty.h" 43 | #include "../h/buf.h" 44 | #include "../h/proc.h" 45 | 46 | #endif 47 | /* 48 | * user level 49 | */ 50 | #ifdef USER 51 | #define SLEEP(a, b) 52 | #define SIGNAL 53 | #define WAKEUP(a) 54 | #define DSYSTEM int p_ifn, p_ofn 55 | #define ISYSTEM 56 | #define GETEPACK malloc(pk->p_xsize) 57 | #define FREEPACK(a, b) free(a) 58 | #define OBUSY 0 59 | #define PKGETPKT(p) pkgetpack(p); 60 | #define DTOM(a) 1; 61 | #define S ipk, ibuf, icount 62 | #define SDEF int icount; char *ibuf; struct pack *ipk 63 | #define UCOUNT icount 64 | #define IOMOVE(p, c, f) pkmove(p, ibuf, c, f) ; ibuf += c; UCOUNT -= c 65 | #define PADDR ipk 66 | #define TURNOFF 67 | #define LOCK 68 | #define UNLOCK 69 | #define SETERROR 70 | #define GENERROR(p, s) 71 | #define PACKSIZE 64 72 | #define WINDOWS 3 73 | #define PKDEBUG(l, f, s) { extern Debug; if (Debug >= l) fprintf(stderr, f, s);} 74 | #define PKASSERT(e, f, v) if (!(e)) {\ 75 | fprintf(stderr, "AERROR - (%s) ", "e");\ 76 | fprintf(stderr, f, v);\ 77 | pkfail();}; 78 | #endif 79 | -------------------------------------------------------------------------------- /ancient-src/v7/h/prim.h: -------------------------------------------------------------------------------- 1 | #define NOSLEEP 0400 2 | #define FORCE 01000 3 | #define NORM 02000 4 | #define KEEP 04000 5 | #define CLR 010000 6 | 7 | int bwaiting,wcount; 8 | 9 | char *getepack(); 10 | -------------------------------------------------------------------------------- /ancient-src/v7/h/proc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * One structure allocated per active 3 | * process. It contains all data needed 4 | * about the process while the 5 | * process may be swapped out. 6 | * Other per process data (user.h) 7 | * is swapped with the process. 8 | */ 9 | struct proc { 10 | char p_stat; 11 | char p_flag; 12 | char p_pri; /* priority, negative is high */ 13 | char p_time; /* resident time for scheduling */ 14 | char p_cpu; /* cpu usage for scheduling */ 15 | char p_nice; /* nice for cpu usage */ 16 | short p_sig; /* signals pending to this process */ 17 | short p_uid; /* user id, used to direct tty signals */ 18 | short p_pgrp; /* name of process group leader */ 19 | short p_pid; /* unique process id */ 20 | short p_ppid; /* process id of parent */ 21 | short p_addr; /* address of swappable image */ 22 | short p_size; /* size of swappable image (clicks) */ 23 | caddr_t p_wchan; /* event process is awaiting */ 24 | struct text *p_textp; /* pointer to text structure */ 25 | struct proc *p_link; /* linked list of running processes */ 26 | int p_clktim; /* time to alarm clock signal */ 27 | }; 28 | 29 | extern struct proc proc[]; /* the proc table itself */ 30 | 31 | /* stat codes */ 32 | #define SSLEEP 1 /* awaiting an event */ 33 | #define SWAIT 2 /* (abandoned state) */ 34 | #define SRUN 3 /* running */ 35 | #define SIDL 4 /* intermediate state in process creation */ 36 | #define SZOMB 5 /* intermediate state in process termination */ 37 | #define SSTOP 6 /* process being traced */ 38 | 39 | /* flag codes */ 40 | #define SLOAD 01 /* in core */ 41 | #define SSYS 02 /* scheduling process */ 42 | #define SLOCK 04 /* process cannot be swapped */ 43 | #define SSWAP 010 /* process is being swapped out */ 44 | #define STRC 020 /* process is being traced */ 45 | #define SWTED 040 /* another tracing flag */ 46 | #define SULOCK 0100 /* user settable lock in core */ 47 | 48 | /* 49 | * parallel proc structure 50 | * to replace part with times 51 | * to be passed to parent process 52 | * in ZOMBIE state. 53 | */ 54 | struct xproc { 55 | char xp_stat; 56 | char xp_flag; 57 | char xp_pri; /* priority, negative is high */ 58 | char xp_time; /* resident time for scheduling */ 59 | char xp_cpu; /* cpu usage for scheduling */ 60 | char xp_nice; /* nice for cpu usage */ 61 | short xp_sig; /* signals pending to this process */ 62 | short xp_uid; /* user id, used to direct tty signals */ 63 | short xp_pgrp; /* name of process group leader */ 64 | short xp_pid; /* unique process id */ 65 | short xp_ppid; /* process id of parent */ 66 | short xp_xstat; /* Exit status for wait */ 67 | time_t xp_utime; /* user time, this proc */ 68 | time_t xp_stime; /* system time, this proc */ 69 | }; 70 | -------------------------------------------------------------------------------- /ancient-src/v7/h/pwd.h: -------------------------------------------------------------------------------- 1 | struct passwd 2 | { 3 | char *pw_name; 4 | char *pw_passwd; 5 | int pw_uid; 6 | int pw_gid; 7 | int pw_quota; 8 | char *pw_comment; 9 | char *pw_gecos; 10 | char *pw_dir; 11 | char *pw_shell; 12 | }; 13 | -------------------------------------------------------------------------------- /ancient-src/v7/h/reg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Location of the users' stored 3 | * registers relative to R0. 4 | * Usage is u.u_ar0[XX]. 5 | */ 6 | #define R0 (0) 7 | #define R1 (-2) 8 | #define R2 (-9) 9 | #define R3 (-8) 10 | #define R4 (-7) 11 | #define R5 (-6) 12 | #define R6 (-3) 13 | #define R7 (1) 14 | #define PC (1) 15 | #define RPS (2) 16 | 17 | #define TBIT 020 /* PS trace bit */ 18 | -------------------------------------------------------------------------------- /ancient-src/v7/h/seg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * KT-11 addresses and bits. 3 | */ 4 | 5 | #define UISD ((physadr)0177600) /* first user I-space descriptor register */ 6 | #define UISA ((physadr)0177640) /* first user I-space address register */ 7 | #define UDSA ((physadr)0177660) /* first user D-space address register */ 8 | #define RO 02 /* access abilities */ 9 | #define RW 06 10 | #define ED 010 /* extend direction */ 11 | #define TX 020 /* Software: text segment */ 12 | #define ABS 040 /* Software: absolute address */ 13 | 14 | /* 15 | * structure used to address 16 | * a sequence of integers. 17 | */ 18 | extern physadr ka6; /* 11/40 KISA6; 11/45 KDSA6 */ 19 | 20 | /* 21 | * address to access 11/70 UNIBUS map 22 | */ 23 | #define UBMAP ((physadr)0170200) 24 | -------------------------------------------------------------------------------- /ancient-src/v7/h/stat.h: -------------------------------------------------------------------------------- 1 | struct stat 2 | { 3 | dev_t st_dev; 4 | ino_t st_ino; 5 | uint16_t st_mode; 6 | int16_t st_nlink; 7 | int16_t st_uid; 8 | int16_t st_gid; 9 | dev_t st_rdev; 10 | off_t st_size; 11 | time_t st_atime; 12 | time_t st_mtime; 13 | time_t st_ctime; 14 | }; 15 | 16 | #define S_IFMT 0170000 /* type of file */ 17 | #define S_IFDIR 0040000 /* directory */ 18 | #define S_IFCHR 0020000 /* character special */ 19 | #define S_IFBLK 0060000 /* block special */ 20 | #define S_IFREG 0100000 /* regular */ 21 | #define S_IFMPC 0030000 /* multiplexed char special */ 22 | #define S_IFMPB 0070000 /* multiplexed block special */ 23 | #define S_ISUID 0004000 /* set user id on execution */ 24 | #define S_ISGID 0002000 /* set group id on execution */ 25 | #define S_ISVTX 0001000 /* save swapped text even after use */ 26 | #define S_IREAD 0000400 /* read permission, owner */ 27 | #define S_IWRITE 0000200 /* write permission, owner */ 28 | #define S_IEXEC 0000100 /* execute/search permission, owner */ 29 | -------------------------------------------------------------------------------- /ancient-src/v7/h/systm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Random set of variables 3 | * used by more than one 4 | * routine. 5 | */ 6 | extern char canonb[CANBSIZ]; /* buffer for erase and kill (#@) */ 7 | extern struct inode *rootdir; /* pointer to inode of root directory */ 8 | extern struct proc *runq; /* head of linked list of running processes */ 9 | extern int16_t cputype; /* type of cpu =40, 45, or 70 */ 10 | extern int16_t lbolt; /* time of day in 60th not in time */ 11 | extern time_t time; /* time in sec from 1970 */ 12 | 13 | /* 14 | * Nblkdev is the number of entries 15 | * (rows) in the block switch. It is 16 | * set in binit/bio.c by making 17 | * a pass over the switch. 18 | * Used in bounds checking on major 19 | * device numbers. 20 | */ 21 | extern int16_t nblkdev; 22 | 23 | /* 24 | * Number of character switch entries. 25 | * Set by cinit/tty.c 26 | */ 27 | extern int16_t nchrdev; 28 | 29 | extern int16_t mpid; /* generic for unique process id's */ 30 | extern char runin; /* scheduling flag */ 31 | extern char runout; /* scheduling flag */ 32 | extern char runrun; /* scheduling flag */ 33 | extern char curpri; /* more scheduling */ 34 | extern int16_t maxmem; /* actual max memory per process */ 35 | extern physadr lks; /* pointer to clock device */ 36 | extern daddr_t swplo; /* block number of swap space */ 37 | extern int16_t nswap; /* size of swap space */ 38 | extern int16_t updlock; /* lock for sync */ 39 | extern daddr_t rablock; /* block to be read ahead */ 40 | extern char regloc[]; /* locs. of saved user registers (trap.c) */ 41 | extern char msgbuf[MSGBUFS]; /* saved "printf" characters */ 42 | extern dev_t rootdev; /* device of the root */ 43 | extern dev_t swapdev; /* swapping device */ 44 | extern dev_t pipedev; /* pipe device */ 45 | extern int16_t icode[]; /* user init code */ 46 | extern int16_t szicode; /* its size */ 47 | 48 | extern dev_t getmdev(); 49 | extern daddr_t bmap(struct inode *ip, daddr_t bn, int16_t rwflg); 50 | extern struct inode *ialloc(dev_t dev); 51 | extern struct inode *iget(dev_t dev, ino_t ino); 52 | extern struct inode *owner(); 53 | extern struct inode *maknode(int16_t mode); 54 | extern struct inode *namei(int16_t (*func)(), int16_t flag); 55 | extern struct buf *alloc(dev_t dev); 56 | extern struct buf *getblk(dev_t dev, daddr_t blkno); 57 | extern struct buf *geteblk(); 58 | extern struct buf *bread(dev_t dev, daddr_t blkno); 59 | extern struct buf *breada(dev_t dev, daddr_t blkno, daddr_t rablkno); 60 | extern struct filsys *getfs(dev_t dev); 61 | extern struct file *getf(int16_t f); 62 | extern struct file *falloc(); 63 | extern int16_t uchar(); 64 | /* 65 | * Instrumentation 66 | */ 67 | extern int16_t dk_busy; 68 | extern int32_t dk_time[32]; 69 | extern int32_t dk_numb[3]; 70 | extern int32_t dk_wds[3]; 71 | extern int32_t tk_nin; 72 | extern int32_t tk_nout; 73 | 74 | /* 75 | * Structure of the system-entry table 76 | */ 77 | extern struct sysent { 78 | char sy_narg; /* total number of arguments */ 79 | char sy_nrarg; /* number of args in registers */ 80 | int16_t (*sy_call)(); /* handler */ 81 | } sysent[]; 82 | -------------------------------------------------------------------------------- /ancient-src/v7/h/text.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Text structure. 3 | * One allocated per pure 4 | * procedure on swap device. 5 | * Manipulated by text.c 6 | */ 7 | struct text 8 | { 9 | short x_daddr; /* disk address of segment (relative to swplo) */ 10 | short x_caddr; /* core address, if loaded */ 11 | short x_size; /* size (clicks) */ 12 | struct inode *x_iptr; /* inode of prototype */ 13 | char x_count; /* reference count */ 14 | char x_ccount; /* number of loaded references */ 15 | char x_flag; /* traced, written flags */ 16 | }; 17 | 18 | extern struct text text[]; 19 | 20 | #define XTRC 01 /* Text may be written, exclusive use */ 21 | #define XWRIT 02 /* Text written into, must swap out */ 22 | #define XLOAD 04 /* Currently being read from file */ 23 | #define XLOCK 010 /* Being swapped in or out */ 24 | #define XWANT 020 /* Wanted for swapping */ 25 | -------------------------------------------------------------------------------- /ancient-src/v7/h/timeb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Structure returned by ftime system call 3 | */ 4 | struct timeb { 5 | time_t time; 6 | unsigned short millitm; 7 | short timezone; 8 | short dstflag; 9 | }; 10 | -------------------------------------------------------------------------------- /ancient-src/v7/h/types.h: -------------------------------------------------------------------------------- 1 | typedef long daddr_t; /* disk address */ 2 | typedef char * caddr_t; /* core address */ 3 | typedef unsigned int ino_t; /* i-node number */ 4 | typedef long time_t; /* a time */ 5 | typedef int label_t[6]; /* program status */ 6 | typedef int dev_t; /* device code */ 7 | typedef long off_t; /* offset in file */ 8 | /* selectors and constructor for device code */ 9 | #define major(x) (int)(((unsigned)x>>8)) 10 | #define minor(x) (int)(x&0377) 11 | #define makedev(x,y) (dev_t)((x)<<8|(y)) 12 | -------------------------------------------------------------------------------- /ancient-src/v7/sys/acct.c: -------------------------------------------------------------------------------- 1 | #include "../h/param.h" 2 | #include "../h/systm.h" 3 | #include "../h/acct.h" 4 | #include "../h/dir.h" 5 | #include "../h/user.h" 6 | #include "../h/inode.h" 7 | #include "../h/proc.h" 8 | #include "../h/seg.h" 9 | 10 | /* 11 | * Perform process accounting functions. 12 | */ 13 | 14 | sysacct() 15 | { 16 | register struct inode *ip; 17 | register struct a { 18 | char *fname; 19 | } *uap; 20 | 21 | uap = (struct a *)u.u_ap; 22 | if (suser()) { 23 | if (uap->fname==NULL) { 24 | if (acctp) { 25 | plock(acctp); 26 | iput(acctp); 27 | acctp = NULL; 28 | } 29 | return; 30 | } 31 | if (acctp) { 32 | u.u_error = EBUSY; 33 | return; 34 | } 35 | ip = namei(uchar, 0); 36 | if(ip == NULL) 37 | return; 38 | if((ip->i_mode & IFMT) != IFREG) { 39 | u.u_error = EACCES; 40 | iput(ip); 41 | return; 42 | } 43 | acctp = ip; 44 | prele(ip); 45 | } 46 | } 47 | 48 | /* 49 | * On exit, write a record on the accounting file. 50 | */ 51 | acct() 52 | { 53 | register i; 54 | register struct inode *ip; 55 | off_t siz; 56 | 57 | if ((ip=acctp)==NULL) 58 | return; 59 | plock(ip); 60 | for (i=0; ii_size; 73 | u.u_offset = siz; 74 | u.u_base = (caddr_t)&acctbuf; 75 | u.u_count = sizeof(acctbuf); 76 | u.u_segflg = 1; 77 | u.u_error = 0; 78 | writei(ip); 79 | if(u.u_error) 80 | ip->i_size = siz; 81 | prele(ip); 82 | } 83 | 84 | /* 85 | * Produce a pseudo-floating point representation 86 | * with 3 bits base-8 exponent, 13 bits fraction. 87 | */ 88 | compress(t) 89 | register time_t t; 90 | { 91 | register exp = 0, round = 0; 92 | 93 | while (t >= 8192) { 94 | exp++; 95 | round = t&04; 96 | t >>= 3; 97 | } 98 | if (round) { 99 | t++; 100 | if (t >= 8192) { 101 | t >>= 3; 102 | exp++; 103 | } 104 | } 105 | return((exp<<13) + t); 106 | } 107 | 108 | /* 109 | * lock user into core as much 110 | * as possible. swapping may still 111 | * occur if core grows. 112 | */ 113 | syslock() 114 | { 115 | register struct proc *p; 116 | register struct a { 117 | int flag; 118 | } *uap; 119 | 120 | uap = (struct a *)u.u_ap; 121 | if(suser()) { 122 | p = u.u_procp; 123 | p->p_flag &= ~SULOCK; 124 | if(uap->flag) 125 | p->p_flag |= SULOCK; 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /ancient-src/v7/sys/fakemx.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Fake multiplexor routines to satisfy references 3 | * if you don't want it. 4 | */ 5 | 6 | #include "../h/param.h" 7 | #include "../h/dir.h" 8 | #include "../h/user.h" 9 | #include "../h/tty.h" 10 | #include "../h/inode.h" 11 | #include "../h/mx.h" 12 | 13 | sdata(cp) 14 | struct chan *cp; 15 | { 16 | } 17 | 18 | mcttstart(tp) 19 | struct tty *tp; 20 | { 21 | } 22 | 23 | mpxchan() 24 | { 25 | u.u_error = EINVAL; 26 | } 27 | 28 | mcstart(p, q) 29 | struct chan *p; 30 | caddr_t q; 31 | { 32 | } 33 | 34 | scontrol(chan, s, c) 35 | struct chan *chan; 36 | { 37 | } 38 | -------------------------------------------------------------------------------- /ancient-src/v7/sys/malloc.c: -------------------------------------------------------------------------------- 1 | #include "../h/param.h" 2 | #include "../h/systm.h" 3 | #include "../h/map.h" 4 | 5 | /* 6 | * Allocate 'size' units from the given 7 | * map. Return the base of the allocated 8 | * space. 9 | * In a map, the addresses are increasing and the 10 | * list is terminated by a 0 size. 11 | * The core map unit is 64 bytes; the swap map unit 12 | * is 512 bytes. 13 | * Algorithm is first-fit. 14 | */ 15 | malloc(mp, size) 16 | struct map *mp; 17 | { 18 | register unsigned int a; 19 | register struct map *bp; 20 | 21 | for (bp=mp; bp->m_size; bp++) { 22 | if (bp->m_size >= size) { 23 | a = bp->m_addr; 24 | bp->m_addr += size; 25 | if ((bp->m_size -= size) == 0) { 26 | do { 27 | bp++; 28 | (bp-1)->m_addr = bp->m_addr; 29 | } while ((bp-1)->m_size = bp->m_size); 30 | } 31 | return(a); 32 | } 33 | } 34 | return(0); 35 | } 36 | 37 | /* 38 | * Free the previously allocated space aa 39 | * of size units into the specified map. 40 | * Sort aa into map and combine on 41 | * one or both ends if possible. 42 | */ 43 | mfree(mp, size, a) 44 | struct map *mp; 45 | register int a; 46 | { 47 | register struct map *bp; 48 | register unsigned int t; 49 | 50 | if ((bp = mp)==coremap && runin) { 51 | runin = 0; 52 | wakeup((caddr_t)&runin); /* Wake scheduler when freeing core */ 53 | } 54 | for (; bp->m_addr<=a && bp->m_size!=0; bp++); 55 | if (bp>mp && (bp-1)->m_addr+(bp-1)->m_size == a) { 56 | (bp-1)->m_size += size; 57 | if (a+size == bp->m_addr) { 58 | (bp-1)->m_size += bp->m_size; 59 | while (bp->m_size) { 60 | bp++; 61 | (bp-1)->m_addr = bp->m_addr; 62 | (bp-1)->m_size = bp->m_size; 63 | } 64 | } 65 | } else { 66 | if (a+size == bp->m_addr && bp->m_size) { 67 | bp->m_addr -= size; 68 | bp->m_size += size; 69 | } else if (size) { 70 | do { 71 | t = bp->m_addr; 72 | bp->m_addr = a; 73 | a = t; 74 | t = bp->m_size; 75 | bp->m_size = size; 76 | bp++; 77 | } while (size = t); 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /ancient-src/v7/sys/mklib: -------------------------------------------------------------------------------- 1 | ar cr LIB1 \ 2 | main.o \ 3 | trap.o \ 4 | sig.o \ 5 | iget.o \ 6 | prf.o \ 7 | slp.o \ 8 | subr.o \ 9 | rdwri.o \ 10 | clock.o \ 11 | fio.o \ 12 | malloc.o \ 13 | alloc.o \ 14 | machdep.o \ 15 | nami.o \ 16 | pipe.o \ 17 | prim.o \ 18 | fakemx.o \ 19 | sysent.o \ 20 | sys3.o \ 21 | sys1.o \ 22 | sys4.o \ 23 | sys2.o \ 24 | acct.o \ 25 | text.o \ 26 | ureg.o 27 | -------------------------------------------------------------------------------- /ancient-src/v7/sys/prf.c: -------------------------------------------------------------------------------- 1 | #include "../h/param.h" 2 | #include "../h/systm.h" 3 | #include "../h/seg.h" 4 | #include "../h/buf.h" 5 | #include "../h/conf.h" 6 | 7 | /* 8 | * In case console is off, 9 | * panicstr contains argument to last 10 | * call to panic. 11 | */ 12 | 13 | char *panicstr; 14 | 15 | /* 16 | * Scaled down version of C Library printf. 17 | * Only %s %u %d (==%u) %o %x %D are recognized. 18 | * Used to print diagnostic information 19 | * directly on console tty. 20 | * Since it is not interrupt driven, 21 | * all system activities are pretty much 22 | * suspended. 23 | * Printf should not be used for chit-chat. 24 | */ 25 | /* VARARGS 1 */ 26 | printf(fmt, x1) 27 | register char *fmt; 28 | unsigned x1; 29 | { 30 | register c; 31 | register unsigned int *adx; 32 | char *s; 33 | 34 | adx = &x1; 35 | loop: 36 | while((c = *fmt++) != '%') { 37 | if(c == '\0') 38 | return; 39 | putchar(c); 40 | } 41 | c = *fmt++; 42 | if(c == 'd' || c == 'u' || c == 'o' || c == 'x') 43 | printn((long)*adx, c=='o'? 8: (c=='x'? 16:10)); 44 | else if(c == 's') { 45 | s = (char *)*adx; 46 | while(c = *s++) 47 | putchar(c); 48 | } else if (c == 'D') { 49 | printn(*(long *)adx, 10); 50 | adx += (sizeof(long) / sizeof(int)) - 1; 51 | } 52 | adx++; 53 | goto loop; 54 | } 55 | 56 | /* 57 | * Print an unsigned integer in base b. 58 | */ 59 | printn(n, b) 60 | long n; 61 | { 62 | register long a; 63 | 64 | if (n<0) { /* shouldn't happen */ 65 | putchar('-'); 66 | n = -n; 67 | } 68 | if(a = n/b) 69 | printn(a, b); 70 | putchar("0123456789ABCDEF"[(int)(n%b)]); 71 | } 72 | 73 | /* 74 | * Panic is called on unresolvable 75 | * fatal errors. 76 | * It syncs, prints "panic: mesg" and 77 | * then loops. 78 | */ 79 | panic(s) 80 | char *s; 81 | { 82 | panicstr = s; 83 | update(); 84 | printf("panic: %s\n", s); 85 | for(;;) 86 | idle(); 87 | } 88 | 89 | /* 90 | * prdev prints a warning message of the 91 | * form "mesg on dev x/y". 92 | * x and y are the major and minor parts of 93 | * the device argument. 94 | */ 95 | prdev(str, dev) 96 | char *str; 97 | dev_t dev; 98 | { 99 | 100 | printf("%s on dev %u/%u\n", str, major(dev), minor(dev)); 101 | } 102 | 103 | /* 104 | * deverr prints a diagnostic from 105 | * a device driver. 106 | * It prints the device, block number, 107 | * and an octal word (usually some error 108 | * status register) passed as argument. 109 | */ 110 | deverror(bp, o1, o2) 111 | register struct buf *bp; 112 | { 113 | 114 | prdev("err", bp->b_dev); 115 | printf("bn=%D er=%o,%o\n", bp->b_blkno, o1, o2); 116 | } 117 | -------------------------------------------------------------------------------- /ancient-src/v7/sys/ureg.c: -------------------------------------------------------------------------------- 1 | #include "../h/param.h" 2 | #include "../h/systm.h" 3 | #include "../h/dir.h" 4 | #include "../h/user.h" 5 | #include "../h/proc.h" 6 | #include "../h/text.h" 7 | #include "../h/seg.h" 8 | 9 | /* 10 | * Load the user hardware segmentation 11 | * registers from the software prototype. 12 | * The software registers must have 13 | * been setup prior by estabur. 14 | */ 15 | sureg() 16 | { 17 | register *udp, *uap, *rdp; 18 | int *rap, *limudp; 19 | int taddr, daddr; 20 | struct text *tp; 21 | 22 | taddr = daddr = u.u_procp->p_addr; 23 | if ((tp=u.u_procp->p_textp) != NULL) 24 | taddr = tp->x_caddr; 25 | limudp = &u.u_uisd[16]; 26 | if (cputype==40) 27 | limudp = &u.u_uisd[8]; 28 | rap = (int *)UISA; 29 | rdp = (int *)UISD; 30 | uap = &u.u_uisa[0]; 31 | for (udp = &u.u_uisd[0]; udp < limudp;) { 32 | *rap++ = *uap++ + (*udp&TX? taddr: (*udp&ABS? 0: daddr)); 33 | *rdp++ = *udp++; 34 | } 35 | } 36 | 37 | /* 38 | * Set up software prototype segmentation 39 | * registers to implement the 3 pseudo 40 | * text,data,stack segment sizes passed 41 | * as arguments. 42 | * The argument sep specifies if the 43 | * text and data+stack segments are to 44 | * be separated. 45 | * The last argument determines whether the text 46 | * segment is read-write or read-only. 47 | */ 48 | estabur(nt, nd, ns, sep, xrw) 49 | unsigned nt, nd, ns; 50 | { 51 | register a, *ap, *dp; 52 | 53 | if(sep) { 54 | if(cputype == 40) 55 | goto err; 56 | if(ctos(nt) > 8 || ctos(nd)+ctos(ns) > 8) 57 | goto err; 58 | } else 59 | if(ctos(nt)+ctos(nd)+ctos(ns) > 8) 60 | goto err; 61 | if(nt+nd+ns+USIZE > maxmem) 62 | goto err; 63 | a = 0; 64 | ap = &u.u_uisa[0]; 65 | dp = &u.u_uisd[0]; 66 | while(nt >= 128) { 67 | *dp++ = (127<<8) | xrw|TX; 68 | *ap++ = a; 69 | a += 128; 70 | nt -= 128; 71 | } 72 | if(nt) { 73 | *dp++ = ((nt-1)<<8) | xrw|TX; 74 | *ap++ = a; 75 | } 76 | if(sep) 77 | while(ap < &u.u_uisa[8]) { 78 | *ap++ = 0; 79 | *dp++ = 0; 80 | } 81 | a = USIZE; 82 | while(nd >= 128) { 83 | *dp++ = (127<<8) | RW; 84 | *ap++ = a; 85 | a += 128; 86 | nd -= 128; 87 | } 88 | if(nd) { 89 | *dp++ = ((nd-1)<<8) | RW; 90 | *ap++ = a; 91 | a += nd; 92 | } 93 | while(ap < &u.u_uisa[8]) { 94 | if(*dp &ABS) { 95 | dp++; 96 | ap++; 97 | continue; 98 | } 99 | *dp++ = 0; 100 | *ap++ = 0; 101 | } 102 | if(sep) 103 | while(ap < &u.u_uisa[16]) { 104 | if(*dp & ABS) { 105 | dp++; 106 | ap++; 107 | continue; 108 | } 109 | *dp++ = 0; 110 | *ap++ = 0; 111 | } 112 | a += ns; 113 | while(ns >= 128) { 114 | a -= 128; 115 | ns -= 128; 116 | *--dp = (127<<8) | RW; 117 | *--ap = a; 118 | } 119 | if(ns) { 120 | *--dp = ((128-ns)<<8) | RW | ED; 121 | *--ap = a-128; 122 | } 123 | if(!sep) { 124 | ap = &u.u_uisa[0]; 125 | dp = &u.u_uisa[8]; 126 | while(ap < &u.u_uisa[8]) 127 | *dp++ = *ap++; 128 | ap = &u.u_uisd[0]; 129 | dp = &u.u_uisd[8]; 130 | while(ap < &u.u_uisd[8]) 131 | *dp++ = *ap++; 132 | } 133 | sureg(); 134 | return(0); 135 | 136 | err: 137 | u.u_error = ENOMEM; 138 | return(-1); 139 | } 140 | -------------------------------------------------------------------------------- /doc/retro-fuse-architecture.drawio: -------------------------------------------------------------------------------- 1 | 3Zpbd9o4EIB/DY/JsS1fHxPStD097cme7G53901YMqgxliuLAPvrV7IlfBOXBDthCw/Yo5uZb2Y0I5iA6XLzkcF88ZUinE4cC20m4G7iOLZtR+JDSraVxLfCSjBnBKlOteCR/IuV0FLSFUG4aHXklKac5Eqo+sU0y3DMWx0hY3TdHpvQtL1qDue4J3iMYdqXfieILypp6Fm1/BMm84Ve2bZUyxLqzkpQLCCi64YIfJiAKaOUV1fLzRSnUnlaL9W4+z2tuwdjOOOnDPi6+OfH1v/95/flOrv97fOf3+6y/MoB1TTPMF2pb6yelm+1ChhdZQjLWawJuF0vCMePOYxl61pAF7IFX6bizhaXCc34PVySVPKe0hUjmInpvuG1alSI7VDdT2lKWbkQ8MuXkMOUzDMhY5VibwvO6BNu9LwvX6KlrwSll2fMON40REopHzFdYs62ootqDRWfbft2XdP2NO1Fg7SrhVBZ2Hw3cw1BXCgOL2FivYSJPSATyTchaao1ndEMm9QfBXdWEEhQLFZj/WFgOF6bhu32cexiQxOHCCwj4bANNPxUmuVMXMzlRbIqsFw6z3WTWGnXeqZDNXgI1SMPh8g1QQmdGSi9Z84gIrjlWVGAKmBHTcHkjkNwDTpcI6fH1Q4MXMFYWE2Br4uVpLjYFhwvRcebh8/DwzWgCjD0cdcRJXiIwyQ2gffjEM+SC4IrguhpcEfzWXfgXc3ACXkBiFCfE/aRhcxRM/Lt0DvGaQwekfvOPLzjzgYRzLnUw8gBNEkSJzb6EfJnvucf42MwhSRBke+P62PAajMFwMDUNW2MYzH1e0xhFkvNCOEfGdmIjyfMMlkPdPCJr8zbjNosVNphyER0YhiLZQQTcCsVSES2fqMalgQhuYzRKNpmUyY+6qFOypLGip6dBBRYBrKmDHQ0ssFxb0XF05vshrPybfBiT76Nu6FGcym7IfD7Kezbpjq2KYXtgMIZupHlcu1rLykgTKqsyOiiGRxktVftGLXK877Sm2WaQadaxnAKOXluF/UmRasVHigpA5km7jnXXouqawftSQqhlhircc0yvDOV5wXHpuKQzTHvTVWy3331M8zB2evfiDy3zML/uaJcMb4qykrvRnSI8k3dpn1/ltJYBAWR/DyTWJZDRDwd3UUOVseIXdwolxtkj3+NgSJYLHYldHs3GGC/9ttRwDUUsuGbBoF+wSPrm5rTJem/fywxQmB+fySmMqXhiK3DBZ1LmZ2nN2pJ0UrS/T963yj07Yuj3y+KUjKraI9G46jW3+r8x/PfOynq1y+HkqI4hUVBqroRMt4Xv/q8dY/S8YbwvyTxa0/d/a34y+u7TfNmq28yoZlqkJhJC+Q4+9qyXC2oB5d3rdEPmBGhYFlc3R30vCrfOWHDqbKZAx2Di0r1gNPJzroWeGqiB6yoNRGIOhONneaZyrhfxsCbxq1mOGDaZ1ixe6IV63B+IWZsd04VXOuVZryLwNqMu7977TFjYUBw2+iWyw7F/gfe/aqjd4jA7nhFNeOwPhL9yj4y/iZwIcYOoug6DDthuxa91OTd7lnrG0dup39ew8SU9EqVAjmjMS6KnqWef66qf3A/81j1JLs/lHEOXY13z1htp5/826HTN9DRzlh1oNl7CKOR1Act6tC7d/DyiRb89ELvdWt8OVh9Dm6HQ53vn/1PlKEN0Q072aWhCh3oVxxxW/+5qApN9V+0wIf/AA== -------------------------------------------------------------------------------- /doc/retro-fuse-architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaylogue/retro-fuse/3269f8d83bc4957d77d61a5f80049045dd826350/doc/retro-fuse-architecture.png -------------------------------------------------------------------------------- /src/dskio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Jay Logue 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * @file Functions for accessing the underlying device/image file. 19 | */ 20 | 21 | #ifndef __DSKIO_H__ 22 | #define __DSKIO_H__ 23 | 24 | enum { 25 | DSK_BLKSIZE = 512 26 | }; 27 | 28 | extern int dsk_open(const char *filename, off_t size, off_t offset, int create, int overwrite, int ro); 29 | extern int dsk_close(); 30 | extern int dsk_read(off_t blkno, void * buf, int byteCount); 31 | extern int dsk_write(off_t blkno, void * buf, int byteCount); 32 | extern int dsk_flush(); 33 | extern off_t dsk_getsize(); 34 | extern void dsk_setsize(off_t size); 35 | 36 | #endif /* __DSKIO_H__ */ -------------------------------------------------------------------------------- /src/fusecommon.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Jay Logue 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * @file Common FUSE filesystem definitions. 19 | */ 20 | 21 | #ifndef __FUSECOMMON_H__ 22 | #define __FUSECOMMON_H__ 23 | 24 | #include 25 | #include 26 | 27 | #define RETROFUSE_VERSION 8 28 | 29 | /** retro-fuse configuration parameters. 30 | */ 31 | struct retrofuse_config { 32 | const char *dskfilename; 33 | uint32_t fssize; 34 | uint32_t fsoffset; 35 | const char *mountpoint; 36 | int overwrite; 37 | int readonly; 38 | int foreground; 39 | int debug; 40 | int showversion; 41 | int showhelp; 42 | int initfs; 43 | /* Note that this is a combination of init parameters used by 44 | * all filesystem types. For each individual filesystem, some 45 | * fields may not be used. */ 46 | struct { 47 | uint32_t isize; 48 | uint32_t iratio; 49 | uint16_t m; 50 | uint16_t n; 51 | } initfsparams; 52 | }; 53 | 54 | extern const char *retrofuse_cmdname; 55 | extern const struct fuse_operations retrofuse_ops; 56 | extern const uint32_t retrofuse_maxuidgid; 57 | 58 | extern int retrofuse_parseinitfsopt(struct retrofuse_config *cfg, const char *arg); 59 | extern int retrofuse_adduidmap(uid_t hostid, uint32_t fsid); 60 | extern int retrofuse_addgidmap(gid_t hostid, uint32_t fsid); 61 | extern int retrofuse_checkinitfsconfig(const struct retrofuse_config * cfg); 62 | extern int retrofuse_initfs(const struct retrofuse_config * cfg); 63 | extern int retrofuse_mount(const struct retrofuse_config * cfg); 64 | extern void retrofuse_showhelp(); 65 | extern off_t retrofuse_fsblktodskblk(off_t fsblk); 66 | extern off_t retrofuse_dskblktofsblk(off_t fskblk); 67 | 68 | #endif /* __FUSECOMMON_H__ */ -------------------------------------------------------------------------------- /src/idmap.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Jay Logue 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * @file UID/GID mapping table implementation 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #include "idmap.h" 26 | 27 | enum { 28 | MAP_SIZE_INC = 128 29 | }; 30 | 31 | /** Add an entry to a UID/GID mapping table. 32 | */ 33 | int idmap_addidmap(struct idmap * map, uint32_t hostid, uint32_t fsid) 34 | { 35 | if (fsid > map->maxfsid) 36 | return -EINVAL; 37 | if (map->entries == NULL || (map->entrycount % MAP_SIZE_INC) == 0) { 38 | map->entries = (struct idmap_entry *)realloc(map->entries, 39 | sizeof(struct idmap_entry) * (map->entrycount + MAP_SIZE_INC)); 40 | if (map->entries == NULL) 41 | return -ENOMEM; 42 | } 43 | map->entries[map->entrycount].hostid = hostid; 44 | map->entries[map->entrycount].fsid = fsid; 45 | map->entrycount++; 46 | return 0; 47 | } 48 | 49 | /** Map a filesystem UID/GID to a correspondign host id. 50 | */ 51 | uint32_t idmap_tohostid(struct idmap * map, uint32_t fsid) 52 | { 53 | for (size_t i = 0; i < map->entrycount; i++) 54 | if (map->entries[i].fsid == fsid) 55 | return map->entries[i].hostid; 56 | if (fsid == map->defaultfsid) 57 | return map->defaulthostid; 58 | if (fsid > map->maxfsid) 59 | return map->defaulthostid; 60 | return fsid; 61 | } 62 | 63 | /** Map a host UID/GID to a correspondign filesystem id. 64 | */ 65 | uint32_t idmap_tofsid(struct idmap * map, uint32_t hostid) 66 | { 67 | for (size_t i = 0; i < map->entrycount; i++) 68 | if (map->entries[i].hostid == hostid) 69 | return map->entries[i].fsid; 70 | if (hostid == map->defaulthostid) 71 | return map->defaultfsid; 72 | if (hostid > map->maxfsid) 73 | return map->defaultfsid; 74 | return hostid; 75 | } 76 | -------------------------------------------------------------------------------- /src/idmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Jay Logue 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * @file UID/GID mapping table 19 | */ 20 | 21 | #ifndef __IDMAP_H__ 22 | #define __IDMAP_H__ 23 | 24 | #include 25 | #include 26 | 27 | struct idmap_entry { 28 | uint32_t hostid; 29 | uint32_t fsid; 30 | }; 31 | 32 | /** Map relating host UID/GID values to corresponding filesystem ids 33 | */ 34 | struct idmap { 35 | struct idmap_entry * entries; 36 | size_t entrycount; 37 | uint32_t maxfsid; 38 | uint32_t defaulthostid; 39 | uint32_t defaultfsid; 40 | }; 41 | 42 | extern int idmap_addidmap(struct idmap * map, uint32_t hostid, uint32_t fsid); 43 | extern uint32_t idmap_tohostid(struct idmap * map, uint32_t fsid); 44 | extern uint32_t idmap_tofsid(struct idmap * map, uint32_t hostid); 45 | 46 | #endif /* __IDMAP_H__ */ -------------------------------------------------------------------------------- /src/v6unadapt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Jay Logue 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * @file Undo adaptations defined in v7adapt.h, restoring access to 19 | * modern constructs, while still prevering access to select 20 | * definitions from v7 code. 21 | */ 22 | 23 | #ifndef __V6UNADAPT_H__ 24 | #define __V6UNADAPT_H__ 25 | 26 | 27 | /* Undefine name mapping macros 28 | */ 29 | #undef access 30 | #undef alloc 31 | #undef badblock 32 | #undef bawrite 33 | #undef bcopy 34 | #undef bdevsw 35 | #undef bdwrite 36 | #undef bflush 37 | #undef bfreelist 38 | #undef binit 39 | #undef bmap 40 | #undef bread 41 | #undef breada 42 | #undef brelse 43 | #undef buf 44 | #undef buffers 45 | #undef bwrite 46 | #undef callo 47 | #undef callout 48 | #undef cdevsw 49 | #undef chmod 50 | #undef chown 51 | #undef close 52 | #undef closef 53 | #undef closei 54 | #undef clrbuf 55 | #undef devtab 56 | #undef dpadd 57 | #undef dpcmp 58 | #undef falloc 59 | #undef file 60 | #undef file 61 | #undef filsys 62 | #undef free 63 | #undef getblk 64 | #undef geterror 65 | #undef getf 66 | #undef getfs 67 | #undef hilo 68 | #undef httab 69 | #undef ialloc 70 | #undef ifree 71 | #undef iget 72 | #undef iinit 73 | #undef incore 74 | #undef inode 75 | #undef integ 76 | #undef iodone 77 | #undef iomove 78 | #undef iowait 79 | #undef iput 80 | #undef itrunc 81 | #undef iupdat 82 | #undef ldiv 83 | #undef link 84 | #undef lrem 85 | #undef lshift 86 | #undef maknode 87 | #undef mapfree 88 | #undef max 89 | #undef min 90 | #undef mknod 91 | #undef mount 92 | #undef namei 93 | #undef nblkdev 94 | #undef nchrdev 95 | #undef notavail 96 | #undef open1 97 | #undef openi 98 | #undef owner 99 | #undef panic 100 | #undef prdev 101 | #undef prele 102 | #undef printf 103 | #undef rablock 104 | #undef rdwr 105 | #undef readi 106 | #undef readp 107 | #undef rootdev 108 | #undef rootdir 109 | #undef schar 110 | #undef sleep 111 | #undef spl0 112 | #undef spl6 113 | #undef stat1 114 | #undef suser 115 | #undef suword 116 | #undef swbuf 117 | #undef time 118 | #undef tmtab 119 | #undef u 120 | #undef uchar 121 | #undef ufalloc 122 | #undef unlink 123 | #undef update 124 | #undef updlock 125 | #undef user 126 | #undef wakeup 127 | #undef wdir 128 | #undef writei 129 | #undef writep 130 | 131 | #ifdef FREAD 132 | enum { 133 | V6_FREAD = FREAD, 134 | V6_FWRITE = FWRITE 135 | }; 136 | #endif /* FREAD */ 137 | 138 | /* Restore modern definitions of macros that collide with v7 code. 139 | */ 140 | #pragma pop_macro("NULL") 141 | #pragma pop_macro("NSIG") 142 | #pragma pop_macro("SIGIOT") 143 | #pragma pop_macro("SIGABRT") 144 | #pragma pop_macro("EAGAIN") 145 | #pragma pop_macro("FREAD") 146 | #pragma pop_macro("FWRITE") 147 | 148 | #endif /* __V6UNADAPT_H__ */ -------------------------------------------------------------------------------- /test/TestUtils.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # 4 | # Copyright 2021 Jay Logue 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | # 20 | # @file Utility code used in retro-fuse tests. 21 | # 22 | 23 | class obj: 24 | '''Convert a dictionary into an object with corresponding property names''' 25 | def __init__(self, d): 26 | for key, val in d.items(): 27 | if isinstance(val, dict): 28 | self.__dict__.update({key: obj(val)}) 29 | elif isinstance(val, list): 30 | objList = [] 31 | for elem in val: 32 | if isinstance(elem, dict): 33 | objList.append(obj(elem)) 34 | else: 35 | objList.append(elem) 36 | self.__dict__.update({key: objList}) 37 | else: 38 | self.__dict__.update({key: val}) 39 | -------------------------------------------------------------------------------- /test/ancient-cksum/cksum-bsd211: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaylogue/retro-fuse/3269f8d83bc4957d77d61a5f80049045dd826350/test/ancient-cksum/cksum-bsd211 -------------------------------------------------------------------------------- /test/ancient-cksum/cksum-bsd29: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaylogue/retro-fuse/3269f8d83bc4957d77d61a5f80049045dd826350/test/ancient-cksum/cksum-bsd29 -------------------------------------------------------------------------------- /test/ancient-cksum/cksum-v6: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaylogue/retro-fuse/3269f8d83bc4957d77d61a5f80049045dd826350/test/ancient-cksum/cksum-v6 -------------------------------------------------------------------------------- /test/ancient-cksum/cksum-v7: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaylogue/retro-fuse/3269f8d83bc4957d77d61a5f80049045dd826350/test/ancient-cksum/cksum-v7 -------------------------------------------------------------------------------- /test/system-images/bsd211-test-system-mscp.dsk.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaylogue/retro-fuse/3269f8d83bc4957d77d61a5f80049045dd826350/test/system-images/bsd211-test-system-mscp.dsk.gz -------------------------------------------------------------------------------- /test/system-images/bsd29-test-system-rl02.dsk.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaylogue/retro-fuse/3269f8d83bc4957d77d61a5f80049045dd826350/test/system-images/bsd29-test-system-rl02.dsk.gz -------------------------------------------------------------------------------- /test/system-images/v6-test-system-rk05.dsk.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaylogue/retro-fuse/3269f8d83bc4957d77d61a5f80049045dd826350/test/system-images/v6-test-system-rk05.dsk.gz -------------------------------------------------------------------------------- /test/system-images/v7-test-system-rp04.dsk.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaylogue/retro-fuse/3269f8d83bc4957d77d61a5f80049045dd826350/test/system-images/v7-test-system-rp04.dsk.gz --------------------------------------------------------------------------------