plan 9 kernel history: overview | file list | diff list

1991/0705/port/portdat.h (diff list | history)

1991/0614/sys/src/9/port/portdat.h:5,141991/0705/sys/src/9/port/portdat.h:5,17 (short | long | prev | next)
Add Egrp, Fgrp, Image, Palloc, Pte, Segment, Swapalloc. Remove PTE, Seg, Orig.
Add Stopped state and devproc ctl requests.
In Proc: change seg to pointer list, add egrp, fgrp, newtlb, procctl.
Add LSEG1, LSEG2.
Foramt edits.
rsc Fri Mar 4 12:44:25 2005
1991/0428    
typedef struct Chan	Chan; 
typedef struct Dev	Dev; 
typedef struct Dirtab	Dirtab; 
1991/0705    
typedef struct Egrp	Egrp; 
1991/0428    
typedef struct Env	Env; 
typedef struct Envp	Envp; 
typedef struct Envval	Envval; 
typedef struct Etherpkt	Etherpkt; 
1991/0705    
typedef struct Fgrp	Fgrp; 
typedef struct Image	Image; 
1991/0607    
typedef struct IOQ	IOQ; 
typedef struct KIOQ	KIOQ; 
1991/0428    
typedef struct List	List; 
1991/0614/sys/src/9/port/portdat.h:15,311991/0705/sys/src/9/port/portdat.h:18,34
1991/0428    
typedef struct Mount	Mount; 
typedef struct Mtab	Mtab; 
typedef struct Note	Note; 
typedef struct Orig	Orig; 
typedef struct PTE	PTE; 
typedef struct Page	Page; 
1991/0705    
typedef struct Palloc	Palloc; 
1991/0428    
typedef struct Pgrp	Pgrp; 
typedef struct Proc	Proc; 
1991/0705    
typedef struct Pte	Pte; 
1991/0428    
typedef struct Qinfo	Qinfo; 
typedef struct QLock	QLock; 
typedef struct Queue	Queue; 
typedef struct Ref	Ref; 
typedef struct Rendez	Rendez; 
typedef struct Seg	Seg; 
1991/0705    
typedef struct Segment	Segment; 
1991/0428    
typedef struct Stream	Stream; 
 
typedef int Devgen(Chan*, Dirtab*, int, int, Dir*); 
1991/0614/sys/src/9/port/portdat.h:177,1831991/0705/sys/src/9/port/portdat.h:180,186
1991/0428    
	Lock; 
	Envval	*val; 
	char	name[NAMELEN]; 
	Env	*next;			/* in chain of Envs for a pgrp */ 
1991/0705    
	Env	*next;			/* in chain of Envs for a egrp */ 
1991/0428    
	int	pgref;			/* # pgrps pointing here */ 
}; 
 
1991/0614/sys/src/9/port/portdat.h:259,3151991/0705/sys/src/9/port/portdat.h:262,407
1991/0428    
	int	flag;			/* whether system posted it */ 
}; 
 
#define	OWRPERM	0x01	/* write permission */ 
#define	OPURE	0x02	/* original data mustn't be written */ 
#define	OCACHED	0x04	/* cached; don't discard on exit */ 
1991/0607    
#define OISMEM	0x08	/* origin contains real memory */ 
#define OSHARED	0x10	/* origin does not copy on ref/wr */ 
1991/0705    
/* Fields for cache control of pages */ 
#define	PG_NOFLUSH	0 
#define PG_TXTFLUSH	1 
#define PG_DATFLUSH	2 
/* Simulated modified and referenced bits */ 
#define PG_MOD		0x01 
#define PG_REF		0x02 
1991/0428    
 
struct Orig 
1991/0705    
struct Page 
1991/0428    
{ 
	Lock; 
	Orig	*next;			/* for allocation */ 
	ushort	nproc;			/* processes using it */ 
	ushort	npage;			/* sum of refs of pages in it */ 
	ushort	flag; 
	ulong	va;			/* va of 0th pte */ 
	ulong	npte;			/* #pte's in list */ 
	PTE	*pte; 
	Chan	*chan;			/* channel deriving segment (if open) */ 
	ushort	type;			/* of channel (which could be non-open) */ 
	Qid	qid; 
	Chan	*mchan; 
1991/0705    
	ulong	pa;			/* Physical address in memory */ 
	ulong	va;			/* Virtual address for user */ 
	ulong	daddr;			/* Disc address on swap */ 
	ushort	ref;			/* Reference count */ 
	char	lock;			/* Software lock */ 
	char	modref;			/* Simulated modify/reference bits */ 
	char	cachectl[MAXMACH];	/* Cache flushing control for putmmu */ 
	Image	*image;			/* Associated text or swap image */ 
	Page	*next;			/* Lru free list */ 
	Page	*prev; 
	Page	*hash;			/* Image hash chains */ 
}; 
 
struct Swapalloc 
{ 
	Lock;			/* Free map lock */ 
	int	free;		/* Number of currently free swap pages */ 
	char	*swmap;		/* Base of swap map in memory */ 
	char	*alloc;		/* Round robin allocator */ 
	char	*top;		/* Top of swap map */ 
	Rendez	r;		/* Pager kproc idle sleep */ 
}swapalloc; 
 
struct Image 
{ 
	Ref; 
	Chan	*c;			/* Channel associated with running image */ 
	Qid 	qid;			/* Qid for page cache coherence checks */ 
1991/0428    
	Qid	mqid; 
	ulong	minca;			/* base of region in chan */ 
	ulong	maxca;			/* end of region in chan */ 
1991/0607    
	void	(*freepg)(Page*, int);	/* how to free pages for this origin */ 
	Page	(*allocpg)(int, Orig*, ulong); 
1991/0705    
	Chan	*mchan; 
	ushort	type;			/* Device type of owning channel */ 
	Segment *s;			/* TEXT segment for image if running, may be null */ 
	Image	*hash;			/* Qid hash chains */ 
	Image	*next;			/* Free list */ 
1991/0428    
}; 
 
struct Page 
1991/0705    
struct Pte 
1991/0428    
{ 
	Orig	*o;			/* origin of segment owning page */ 
	ulong	va;			/* virtual address */ 
	ulong	pa;			/* physical address */ 
	ushort	ref; 
	Page	*next; 
	Page	*prev; 
1991/0705    
	union { 
		Pte	*next;			/* Free list */ 
		Page	*pages[PTEPERTAB];	/* Page map for this chunk of pte */ 
	}; 
1991/0428    
}; 
 
1991/0705    
/* Segment types */ 
#define SG_TYPE		007		/* Mask type of segment */ 
#define SG_TEXT		000 
#define SG_DATA		001 
#define SG_BSS		002 
#define SG_STACK	003 
#define SG_SHARED	004 
#define SG_PHYSICAL	005 
/* Segment flags */ 
#define SG_RONLY	040		/* Segment is read only */ 
 
#define HIGHWATER	((conf.npage*5)/100) 
#define MAXHEADROOM	HIGHWATER*2	/* Silly but OK for debug */ 
#define PG_ONSWAP	1 
#define pagedout(s)	(((ulong)s)==0 || (((ulong)s)&PG_ONSWAP)) 
#define swapaddr(s)	(((ulong)s)&~PG_ONSWAP) 
#define onswap(s)	(((ulong)s)&PG_ONSWAP) 
 
#define SEGMAXSIZE	(SEGMAPSIZE*PTEMAPMEM) 
 
struct Segment 
{ 
	Ref; 
	QLock	lk; 
	ushort	steal;			/* Page stealer lock */ 
	Segment	*next;			/* free list pointers */ 
	ushort	type;			/* segment type */ 
	ulong	base;			/* virtual base */ 
	ulong	top;			/* virtual top */ 
	ulong	size;			/* size in pages */ 
	ulong	fstart;			/* start address in file for demand load */ 
	ulong	flen;			/* length of segment in file */ 
	Image	*image;			/* image in file system attached to this segment */ 
	Page	*(*pgalloc)(ulong addr);/* SG_PHYSICAL page allocator */ 
	void	(*pgfree)(Page *);	/* SG_PHYSICAL page free */ 
	Pte	*map[SEGMAPSIZE];	/* segment pte map */ 
}; 
 
1991/0428    
struct Pgrp 
{ 
	Ref;				/* also used as a lock when mounting */ 
	Pgrp	*next; 
1991/0705    
	Pgrp	*next;			/* free list */ 
1991/0428    
	int	index;			/* index in pgrp table */ 
	ulong	pgrpid; 
	char	user[NAMELEN]; 
	int	nmtab;			/* highest active mount table entry, +1 */ 
	int	nenv;			/* highest active env table entry, +1 */ 
	QLock	debug;			/* single access via devproc.c */ 
	Mtab	*mtab; 
1991/0705    
}; 
 
struct Egrp 
{ 
	Ref; 
	Egrp	*next; 
	int	nenv;			/* highest active env table entry, +1 */ 
1991/0428    
	Envp	*etab; 
}; 
 
1991/0705    
#define	NFD	100 
struct Fgrp 
{ 
	Ref; 
	Fgrp	*next; 
	Chan	*fd[NFD]; 
	int	maxfd;			/* highest fd in use */ 
}; 
 
#define PGHSIZE	512 
struct Palloc 
{ 
	Lock; 
	ulong	addr; 
	int	active; 
	Page	*page;		/* base of Page structures, indexed by phys page number */ 
	ulong	minppn;		/* index of first usable page */ 
	Page	*head;		/* most recently used */ 
	Page	*tail;		/* least recently used */ 
	ulong	freecount;	/* how many pages on free list now */ 
	ulong	user;		/* how many user pages */ 
	Page	*hash[PGHSIZE]; 
	Lock	hashlock; 
	Rendez	r;		/* Sleep for free mem */ 
	QLock	pwait;		/* Queue of procs waiting for memory */ 
	int	wanted;		/* Do the wakeup at free */ 
}; 
 
1991/0514    
enum					/* Argument to forkpgrp call */ 
{ 
	FPall 	  = 0,			/* Concession to back portablility */ 
1991/0614/sys/src/9/port/portdat.h:324,3421991/0705/sys/src/9/port/portdat.h:416,424
1991/0428    
 */ 
1991/0605    
enum 
{ 
	SSEG, TSEG, DSEG, BSEG, ESEG, LSEG, NSEG 
1991/0705    
	SSEG, TSEG, DSEG, BSEG, ESEG, LSEG, SEG1, SEG2, NSEG 
1991/0605    
}; 
1991/0428    
 
struct Seg 
{ 
	Proc	*proc;			/* process owning this segment */ 
	Orig	*o;			/* root list of pte's */ 
	ulong	minva;			/* va of 0th pte (not necessarily Seg->o->va) */ 
	ulong	maxva;			/* va of last pte */ 
	PTE	*mod;			/* list of modified pte's */ 
1991/0606    
	ulong	endseg;			/* segments end */ 
1991/0428    
}; 
                 
/* 
 * Process states 
 */ 
1991/0614/sys/src/9/port/portdat.h:354,3621991/0705/sys/src/9/port/portdat.h:436,454
1991/0428    
	Inwait, 
	Wakeme, 
	Broken, 
1991/0705    
	Stopped, 
1991/0428    
}; 
 
/* 
1991/0705    
 * devproc requests 
 */ 
enum 
{ 
	Proc_stopme = 1, 
	Proc_exitme = 2, 
}; 
 
/* 
1991/0428    
 * Proc.time 
 */ 
enum 
1991/0614/sys/src/9/port/portdat.h:379,3851991/0705/sys/src/9/port/portdat.h:471,477
1991/0428    
	QLock	*qlock;			/* address of qlock being queued for DEBUG */ 
	int	state; 
	Page	*upage;			/* BUG: should be unlinked from page list */ 
	Seg	seg[NSEG]; 
1991/0705    
	Segment	*seg[NSEG]; 
1991/0428    
	ulong	pid; 
	int	nchild; 
	QLock	wait;			/* exiting children to be waited for */ 
1991/0614/sys/src/9/port/portdat.h:386,3921991/0705/sys/src/9/port/portdat.h:478,488
1991/0428    
	Waitmsg	waitmsg;		/* this is large but must be addressable */ 
	Proc	*child; 
	Proc	*parent; 
	Pgrp	*pgrp; 
1991/0705    
 
	Pgrp	*pgrp;			/* Process group for notes and namespace */ 
	Egrp 	*egrp;			/* Environment group */ 
	Fgrp	*fgrp;			/* File descriptor group */ 
 
1991/0428    
	ulong	parentpid; 
	ulong	time[6];		/* User, Sys, Real; child U, S, R */ 
	short	exiting; 
1991/0614/sys/src/9/port/portdat.h:400,4071991/0705/sys/src/9/port/portdat.h:496,504
1991/0428    
	int	kp;			/* true if a kernel process */ 
1991/0513    
	Proc	*palarm;		/* Next alarm time */ 
	ulong	alarm;			/* Time of call */ 
1991/0614    
	int	hasspin; 
1991/0513    
                 
1991/0705    
	int 	hasspin;		/* I hold a spin lock */ 
	int	newtlb;			/* Pager has touched my tables so I must flush */ 
	int	procctl;		/* Control for /proc debugging */ 
1991/0504    
	/* 
1991/0507    
	 *  machine specific MMU goo 
1991/0504    
	 */ 
1991/0614/sys/src/9/port/portdat.h:408,4211991/0705/sys/src/9/port/portdat.h:505,510
1991/0507    
	PMMU; 
1991/0428    
}; 
 
struct PTE 
{ 
	Proc	*proc;			/* process owning this PTE (0 in Orig) */ 
	PTE	*nextmod;		/* next at this va */ 
	PTE	*nextva;		/* next in this proc at higher va */ 
	Page	*page; 
}; 
                 
/* 
 *  operations available to a queue 
 */ 
1991/0614/sys/src/9/port/portdat.h:504,5131991/0705/sys/src/9/port/portdat.h:593,604
1991/0428    
extern	char	user[NAMELEN]; 
extern	char	*errstrtab[]; 
extern	char	*statename[]; 
1991/0705    
extern	Palloc 	palloc; 
extern  Image	swapimage; 
1991/0428    
 
#define	CHDIR	0x80000000L 
#define	CHAPPEND 0x40000000L 
#define	CHEXCL	0x20000000L 
1991/0705    
#define	CHDIR		0x80000000L 
#define	CHAPPEND 	0x40000000L 
#define	CHEXCL		0x20000000L 
1991/0428    
 
 
 


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)