summaryrefslogtreecommitdiff
path: root/sys/src/cmd/5e/dat.h
blob: d8356f07d26e1b8ee707c83453b44954668e5694 (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
typedef struct Process Process;
typedef struct Segment Segment;
typedef struct Fdtable Fdtable;
typedef struct Fd Fd;

enum {
	STACKTOP = 0x80000000UL,
	STACKSIZE = 0x10000,
	
	FDBLOCK = 16,
	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 {
	Segment* S[SEGNUM];
	u32int R[16];		/* general purpose registers / PC (R15) */
	u32int CPSR;		/* status register */
	char errbuf[ERRMAX];
	Fd *fd;
	int pid;
};

extern void **_privates;
extern int _nprivates;
#define P (*(Process**)_privates)

enum {
	SEGFLLOCK = 1,
};

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

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

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