Skip to content

Commit 184e245

Browse files
author
deraadt
committed
refactor sys/param.h and machine/param.h. A lot of #ifdef _KERNEL is added
to keep definitions our of user space. The MD files now follow a consistant order -- all namespace intrusion is at the tail can be cleaned up independently. locore, bootblocks, and libkvm still see enough visibility to build. Checked on 90% of platforms...
1 parent 209ccf4 commit 184e245

File tree

52 files changed

+669
-992
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+669
-992
lines changed

sys/arch/alpha/include/param.h

Lines changed: 21 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
/* $OpenBSD: param.h,v 1.36 2012/06/26 01:59:47 deraadt Exp $ */
2-
/* $NetBSD: param.h,v 1.30 2000/06/09 16:03:04 thorpej Exp $ */
1+
/* $OpenBSD: param.h,v 1.37 2013/03/23 16:12:18 deraadt Exp $ */
32

43
/*
54
* Copyright (c) 1988 University of Utah.
@@ -33,15 +32,11 @@
3332
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3433
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3534
* SUCH DAMAGE.
36-
*
37-
* from: Utah $Hdr: machparam.h 1.11 89/08/14$
38-
*
39-
* @(#)param.h 8.1 (Berkeley) 6/10/93
4035
*/
4136

42-
/*
43-
* Machine dependent constants for the Alpha.
44-
*/
37+
#ifndef _MACHINE_PARAM_H_
38+
#define _MACHINE_PARAM_H_
39+
4540
#define _MACHINE alpha
4641
#define MACHINE "alpha"
4742
#define _MACHINE_ARCH alpha
@@ -56,53 +51,34 @@
5651
#define ALIGN(p) _ALIGN(p)
5752
#define ALIGNED_POINTER(p,t) _ALIGNED_POINTER(p,t)
5853

59-
#define NBPG (1 << 13) /* bytes/page */
60-
#define PGOFSET (NBPG-1) /* byte off. into pg */
61-
#define PGSHIFT 13 /* LOG2(NBPG) */
62-
63-
#define PAGE_SHIFT 13
64-
#define PAGE_SIZE (1 << PAGE_SHIFT)
65-
#define PAGE_MASK (PAGE_SIZE - 1)
54+
#define PAGE_SHIFT 13
55+
#define PAGE_SIZE (1 << PAGE_SHIFT)
56+
#define PAGE_MASK (PAGE_SIZE - 1)
57+
#define PGSHIFT PAGE_SHIFT /* LOG2(PAGE_SIZE) */
58+
#define PGOFSET PAGE_MASK /* byte offset into page */
6659

6760
#define KERNBASE 0xfffffc0000580000 /* start of kernel virtual */
6861

69-
#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
70-
#define DEV_BSIZE (1 << DEV_BSHIFT)
71-
#define BLKDEV_IOSIZE 2048
72-
#ifndef MAXPHYS
73-
#define MAXPHYS (64 * 1024) /* max raw I/O transfer size */
74-
#endif
62+
#ifdef _KERNEL
7563

76-
#define UPAGES 2 /* pages of u-area */
77-
#define USPACE (UPAGES * NBPG) /* total size of u-area */
78-
#define USPACE_ALIGN (0) /* u-area alignment 0-none */
64+
#define NBPG PAGE_SIZE /* bytes/page */
7965

80-
#ifndef MSGBUFSIZE
81-
#define MSGBUFSIZE NBPG /* default message buffer size */
82-
#endif
66+
#define UPAGES 2 /* pages of u-area */
67+
#define USPACE (UPAGES * PAGE_SIZE) /* total size of u-area */
68+
#define USPACE_ALIGN 0 /* u-area alignment 0-none */
8369

84-
/*
85-
* Constants related to network buffer management.
86-
*/
87-
#define NMBCLUSTERS 4096 /* map size, max cluster allocation */
70+
#define NMBCLUSTERS 4096 /* map size, max cluster allocation */
8871

72+
#ifndef MSGBUFSIZE
73+
#define MSGBUFSIZE (2 * PAGE_SIZE) /* default message buffer size */
74+
#endif
8975

9076
/*
91-
* Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized
77+
* Maximum size of the kernel malloc arena in PAGE_SIZE-sized
9278
* logical pages.
9379
*/
94-
#define NKMEMPAGES_MIN_DEFAULT ((8 * 1024 * 1024) >> PAGE_SHIFT)
9580
#define NKMEMPAGES_MAX_DEFAULT ((128 * 1024 * 1024) >> PAGE_SHIFT)
9681

97-
/* pages ("clicks") to disk blocks */
98-
#define ctod(x) ((x) << (PGSHIFT - DEV_BSHIFT))
99-
#define dtoc(x) ((x) >> (PGSHIFT - DEV_BSHIFT))
100-
101-
/* bytes to disk blocks */
102-
#define btodb(x) ((x) >> DEV_BSHIFT)
103-
#define dbtob(x) ((x) << DEV_BSHIFT)
104-
105-
#ifdef _KERNEL
10682
#ifndef _LOCORE
10783

10884
#include <machine/intr.h>
@@ -120,3 +96,5 @@ paddr_t alpha_XXX_dmamap(vaddr_t);
12096

12197
#endif
12298
#endif /* !_KERNEL */
99+
100+
#endif /* _MACHINE_PARAM_H_ */

sys/arch/alpha/include/vmparam.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: vmparam.h,v 1.21 2011/05/30 22:25:20 oga Exp $ */
1+
/* $OpenBSD: vmparam.h,v 1.22 2013/03/23 16:12:18 deraadt Exp $ */
22
/* $NetBSD: vmparam.h,v 1.18 2000/05/22 17:13:54 thorpej Exp $ */
33

44
/*
@@ -57,7 +57,7 @@
5757
* consider doing that at some point, but it might require changes
5858
* to the exec code.
5959
*/
60-
#define USRTEXT NBPG
60+
#define USRTEXT PAGE_SIZE
6161
#define USRSTACK ((vaddr_t)0x0000000200000000) /* 8G */
6262

6363
/*
@@ -116,7 +116,7 @@
116116
#define VM_PIE_MAX_ADDR 0x80000000
117117

118118
/* virtual sizes (bytes) for various kernel submaps */
119-
#define VM_PHYS_SIZE (USRIOSIZE*NBPG)
119+
#define VM_PHYS_SIZE (USRIOSIZE * PAGE_SIZE)
120120

121121
/* some Alpha-specific constants */
122122
#define VPTBASE ((vaddr_t)0xfffffffc00000000) /* Virt. pg table */

sys/arch/amd64/include/biosvar.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* XXX - DSR */
2-
/* $OpenBSD: biosvar.h,v 1.17 2012/10/09 12:58:07 jsing Exp $ */
2+
/* $OpenBSD: biosvar.h,v 1.18 2013/03/23 16:12:20 deraadt Exp $ */
33

44
/*
55
* Copyright (c) 1997-1999 Michael Shalayeff
@@ -33,8 +33,8 @@
3333
#define _MACHINE_BIOSVAR_H_
3434

3535
/* some boxes put apm data seg in the 2nd page */
36-
#define BOOTARG_OFF (NBPG*2)
37-
#define BOOTARG_LEN (NBPG*1)
36+
#define BOOTARG_OFF (PAGE_SIZE * 2)
37+
#define BOOTARG_LEN (PAGE_SIZE * 1)
3838
#define BOOTBIOS_ADDR (0x7c00)
3939
#define BOOTBIOS_MAXSEC ((1 << 28) - 1)
4040

sys/arch/amd64/include/param.h

Lines changed: 27 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: param.h,v 1.19 2013/03/21 15:50:28 deraadt Exp $ */
1+
/* $OpenBSD: param.h,v 1.20 2013/03/23 16:12:20 deraadt Exp $ */
22

33
/*-
44
* Copyright (c) 1990 The Regents of the University of California.
@@ -30,10 +30,11 @@
3030
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3232
* SUCH DAMAGE.
33-
*
34-
* @(#)param.h 5.8 (Berkeley) 6/28/91
3533
*/
3634

35+
#ifndef _MACHINE_PARAM_H_
36+
#define _MACHINE_PARAM_H_
37+
3738
#ifdef _KERNEL
3839
#ifdef _LOCORE
3940
#include <machine/psl.h>
@@ -46,69 +47,47 @@
4647
#define MACHINE "amd64"
4748
#define _MACHINE_ARCH amd64
4849
#define MACHINE_ARCH "amd64"
49-
#define MID_MACHINE MID_AMD64
50+
#define MID_MACHINE MID_AMD64
5051

5152
#define ALIGNBYTES _ALIGNBYTES
5253
#define ALIGN(p) _ALIGN(p)
5354
#define ALIGNED_POINTER(p,t) _ALIGNED_POINTER(p,t)
5455

55-
#define PGSHIFT 12 /* LOG2(NBPG) */
56-
#define NBPG (1 << PGSHIFT) /* bytes/page */
57-
#define PGOFSET (NBPG-1) /* byte offset into page */
56+
#define PAGE_SHIFT 12
57+
#define PAGE_SIZE (1 << PAGE_SHIFT)
58+
#define PAGE_MASK (PAGE_SIZE - 1)
59+
#define PGSHIFT PAGE_SHIFT /* LOG2(PAGE_SIZE) */
60+
#define PGOFSET PAGE_MASK /* byte offset into page */
5861

59-
#define PAGE_SHIFT 12
60-
#define PAGE_SIZE (1 << PAGE_SHIFT)
61-
#define PAGE_MASK (PAGE_SIZE - 1)
62+
#define KERNBASE 0xffffffff80000000 /* start of kernel virtual space */
6263

63-
#define NPTEPG (NBPG/(sizeof (pt_entry_t)))
64+
#ifdef _KERNEL
6465

65-
#define KERNBASE 0xffffffff80000000 /* start of kernel virtual space */
66-
#define KERNTEXTOFF (KERNBASE+0x1000000) /* start of kernel text */
66+
#define KERNTEXTOFF (KERNBASE+0x1000000) /* start of kernel text */
67+
#define KERNTEXTOFF_HI 0xffffffff
68+
#define KERNTEXTOFF_LO 0x81000000
6769

68-
#define KERNTEXTOFF_HI 0xffffffff
69-
#define KERNTEXTOFF_LO 0x81000000
70+
#define KERNBASE_HI 0xffffffff
71+
#define KERNBASE_LO 0x80000000
7072

71-
#define KERNBASE_HI 0xffffffff
72-
#define KERNBASE_LO 0x80000000
73+
#define NBPG PAGE_SIZE /* bytes/page */
7374

74-
#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
75-
#define DEV_BSIZE (1 << DEV_BSHIFT)
76-
#define BLKDEV_IOSIZE 2048
77-
#ifndef MAXPHYS
78-
#define MAXPHYS (64 * 1024) /* max raw I/O transfer size */
79-
#endif
75+
#define UPAGES 5 /* pages of u-area */
76+
#define USPACE (UPAGES * PAGE_SIZE) /* total size of u-area */
77+
#define USPACE_ALIGN 0 /* u-area alignment 0-none */
8078

81-
#define UPAGES 5 /* pages of u-area */
82-
#define USPACE (UPAGES * NBPG) /* total size of u-area */
83-
#define USPACE_ALIGN (0) /* u-area alignment 0-none */
79+
#define NMBCLUSTERS 6144 /* map size, max cluster allocation */
8480

85-
#ifndef MSGBUFSIZE
86-
#define MSGBUFSIZE 16*NBPG /* default message buffer size */
81+
#ifndef MSGBUFSIZE
82+
#define MSGBUFSIZE (16 * PAGE_SIZE) /* default message buffer size */
8783
#endif
8884

8985
/*
90-
* Constants related to network buffer management.
91-
*/
92-
#define NMBCLUSTERS 6144 /* map size, max cluster allocation */
93-
94-
/*
95-
* Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized
86+
* Maximum size of the kernel malloc arena in PAGE_SIZE-sized
9687
* logical pages.
9788
*/
98-
#define NKMEMPAGES_MIN_DEFAULT ((8 * 1024 * 1024) >> PAGE_SHIFT)
9989
#define NKMEMPAGES_MAX_DEFAULT ((128 * 1024 * 1024) >> PAGE_SHIFT)
10090

101-
/* pages ("clicks") to disk blocks */
102-
#define ctod(x) ((x) << (PGSHIFT - DEV_BSHIFT))
103-
#define dtoc(x) ((x) >> (PGSHIFT - DEV_BSHIFT))
104-
105-
/* bytes to disk blocks */
106-
#define dbtob(x) ((x) << DEV_BSHIFT)
107-
#define btodb(x) ((x) >> DEV_BSHIFT)
91+
#endif /* _KERNEL */
10892

109-
/*
110-
* Mach derived conversion macros
111-
*/
112-
#define x86_round_pdr(x) \
113-
((((unsigned long)(x)) + (NBPD_L2 - 1)) & ~(NBPD_L2 - 1))
114-
#define x86_trunc_pdr(x) ((unsigned long)(x) & ~(NBPD_L2 - 1))
93+
#endif /* _MACHINE_PARAM_H_ */

sys/arch/amd64/include/pte.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: pte.h,v 1.8 2011/03/23 16:54:34 pirofti Exp $ */
1+
/* $OpenBSD: pte.h,v 1.9 2013/03/23 16:12:20 deraadt Exp $ */
22
/* $NetBSD: pte.h,v 1.1 2003/04/26 18:39:47 fvdl Exp $ */
33

44
/*
@@ -97,6 +97,9 @@ typedef u_int64_t pt_entry_t; /* PTE */
9797
#define L2_FRAME (L3_FRAME|L2_MASK)
9898
#define L1_FRAME (L2_FRAME|L1_MASK)
9999

100+
#define x86_round_pdr(x) \
101+
((((unsigned long)(x)) + (NBPD_L2 - 1)) & ~(NBPD_L2 - 1))
102+
100103
/*
101104
* PDE/PTE bits. These are no different from their i386 counterparts.
102105
*/

0 commit comments

Comments
 (0)