~kris/9p

9hist

ref: 7b1dbfc2de484d1aed8fd8681eb9f17052d89aba 9hist/alphapc/mem.h -rw-r--r-- 3.1 KiB
7b1dbfc2 — David du Colombier Plan 9 from Bell Labs 2002-04-23 24 years ago
                                                                                
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
 * Memory and machine-specific definitions.  Used in C and assembler.
 */

/*
 * Sizes
 */

#define	BI2BY		8			/* bits per byte */
#define	BI2WD		32			/* bits per word */
#define	BY2WD		4			/* bytes per word */
#define 	BY2V		8			/* bytes per vlong */
#define	BY2PG		8192		/* bytes per page */
#define	WD2PG		(BY2PG/BY2WD)	/* words per page */
#define	PGSHIFT		13			/* log(BY2PG) */
#define 	ROUND(s, sz)	(((s)+(sz-1))&~(sz-1))
#define 	PGROUND(s)	ROUND(s, BY2PG)
#define BLOCKALIGN	8

#define	BY2PTE		8			/* bytes per pte entry */
#define	PTE2PG		(BY2PG/BY2PTE)	/* pte entries per page */

#define	MAXMACH		1			/* max # cpus system can run */
#define	KSTACK		4096			/* Size of kernel stack */

/*
 * Time
 */
#define	HZ		100			/* clock frequency */
#define	MS2HZ	(1000/HZ)
#define	TK2SEC(t)	((t)/HZ)		/* ticks to seconds */

/*
 * Magic registers
 */

#define	MACH	15		/* R15 is m-> */
#define	USER		14		/* R14 is up-> */


/*
 * Fundamental addresses
 */
/* XXX MACHADDR, MACHP(n) */

/*
 * MMU
 *
 * A PTE is 64 bits, but a ulong is 32!  Hence we encode
 * the PTEs specially for fault.c, and decode them in putmmu().
 * This means that we can only map the first 2G of physical
 * space via putmmu() - ie only physical memory, not devices.
 */

#define	PTEVALID		0x3301
#define	PTEKVALID	0x1101
#define	PTEASM		0x0010
#define	PTEGH(s)		((s)<<5)
#define	PTEWRITE		0
#define	PTERONLY	0x4
#define	PTEUNCACHED	0
#define	PPN(n)		(((n)>>PGSHIFT)<<14)
#define	FIXPTE(x)		((((uvlong)(x)>>14)<<32)|((x) & 0x3fff))
#define	PTEPFN(pa)	(((uvlong)(pa)>>PGSHIFT)<<32)
#define	NCOLOR		1
#define	getpgcolor(a)	0

#define	PTEMAPMEM	(1024*1024)	
#define	PTEPERTAB	(PTEMAPMEM/BY2PG)
#define	SEGMAPSIZE	512
#define SSEGMAPSIZE	16

/*
 * Address spaces
 */

#define	UZERO	0			/* base of user address space */
#define	UTZERO	(UZERO+BY2PG)		/* first address in user text */
#define	USTKTOP	(TSTKTOP-TSTKSIZ*BY2PG)	/* byte just beyond user stack */
#define	TSTKTOP	KZERO	/* top of temporary stack */
#define	TSTKSIZ 100
#define	KZERO	0x80000000	/* base of kernel address space */
#define	KTZERO	(KZERO+0x400000)		/* first address in kernel text */
#define	USTKSIZE	(4*1024*1024)	/* size of user stack */

/*
 * Palcode instructions a la OSF/1
 */
#define	PALbpt		0x80
#define	PALbugchk	0x81
#define	PALcallsys	0x83
#define	PALimb		0x86
#define	PALgentrap	0xaa
#define	PALrdunique	0x9e
#define	PALwrunique	0x9f

#define	PALhalt		0x00
#define	PALdraina	0x02
#define	PALcserve	0x09
#define	PALrdps		0x36
#define	PALrdusp	0x3a
#define	PALrdval	0x32
#define	PALretsys	0x3d
#define	PALrti		0x3f
#define	PALswpctx	0x30
#define	PALswpipl	0x35
#define	PALtbi		0x33
#define	PALwhami	0x3c
#define	PALwrent	0x34
#define	PALwrfen	0x2b
#define	PALwrkgp	0x37
#define	PALwrusp	0x38
#define	PALwrval	0x31
#define	PALwrvptptr	0x2d

/*
 * Plus some useful VMS ones (needed at early boot time)
 */
#define	PALmfpr_pcbb	0x12
#define	PALmfpr_ptbr	0x15
#define	PALmfpr_vptb	0x29
#define	PALldqp		0x03
#define	PALstqp		0x04
#define	PALswppal	0x0a

/*
 * Processor Status (as returned by rdps)
 */
#define	UMODE	0x8
#define	IPL		0x7


#define isphys(x) (((ulong)x&KZERO)!=0)