summaryrefslogtreecommitdiff
path: root/sys/src/cmd/5e/dat.h
blob: 153b99ee3b51fafe9f944eb5ed216c5fecd21dcf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
typedef struct Process Process;
typedef struct Segment Segment;
typedef struct Fdtable Fdtable;
typedef struct Fd Fd;

enum {
	STACKSIZE = 0x100000,
	NAMEMAX = 27,
	NNOTE = 5,
	SEGNUM = 8,

	flN = 1<<31,
	flZ = 1<<30,
	flC = 1<<29,
	flV = 1<<28,
	FLAGS = flN | flZ | flC | flV,
};

enum {
	SEGTEXT,
	SEGDATA,
	SEGBSS,
	SEGSTACK,
};

struct Process {
	Process *prev, *next;	/* linked list (for fs) */
	int pid;
	char name[NAMEMAX+1];	/* name for status file */
	Ref *path;		/* Ref + string data */

	Segment *S[SEGNUM];	/* memory */
	u32int R[16];		/* general purpose registers / PC (R15) */
	u32int CPSR;		/* status register */

	char errbuf[ERRMAX];
	Fd *fd;			/* bitmap of OCEXEC files */
	
	/* note handling */
	u32int notehandler;
	int innote;
	jmp_buf notejmp;
	char notes[ERRMAX][NNOTE];
	long notein, noteout;
};

extern void **_privates;
extern int _nprivates;
#define P (*(Process**)_privates)
extern Ref nproc;
extern Process plist;
extern Lock plistlock;

enum {
	SEGFLLOCK = 1,
};

struct Segment {
	Ref;
	int flags;
	RWLock rw; /* lock for SEGFLLOCK segments */
	Lock lock; /* atomic accesses */
	u32int start, size;
	void *data;
	Ref *dref;
};

struct Fd {
	RWLock;
	Ref;
	u8int *fds;
	int nfds;
};

#define fulltrace 0
#define havesymbols 0
#define ultraverbose 0
#define systrace 0