summaryrefslogtreecommitdiff
path: root/i386/x15/param.h
blob: f8f9c33990725b83b3ae3f81ebb03640a466e58c (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
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/*
 * Copyright (c) 2010-2014 Richard Braun.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *
 * This file is a top header in the inclusion hierarchy, and shouldn't include
 * other headers that may cause circular dependencies.
 */

#ifndef _X86_PARAM_H
#define _X86_PARAM_H

#include <kern/macros.h>

#define __LITTLE_ENDIAN__

/*
 * L1 cache line size.
 *
 * XXX Use this value until processor selection is available.
 */
#define CPU_L1_SIZE 64

/*
 * Code/data alignment.
 */
#define TEXT_ALIGN  16

#ifdef __LP64__
#define DATA_ALIGN  8
#else /* __LP64__ */
#define DATA_ALIGN  4
#endif /* __LP64__ */

/*
 * Attributes for variables that are mostly read and seldom changed.
 */
#define __read_mostly __section(".data.read_mostly")

/*
 * Provide architecture-specific string functions.
 */
#define ARCH_STRING_MEMCPY
#define ARCH_STRING_MEMMOVE
#define ARCH_STRING_MEMSET
#define ARCH_STRING_MEMCMP
#define ARCH_STRING_STRLEN
#define ARCH_STRING_STRCPY
#define ARCH_STRING_STRCMP

/*
 * System timer frequency.
 *
 * The selected value of 200 translates to a period of 5ms, small enough to
 * provide low latency, and is practical as both a dividend and divisor.
 */
#define HZ 200

/*
 * 4 KiB pages.
 */
#define PAGE_SHIFT  12
#define PAGE_SIZE   (1 << PAGE_SHIFT)
#define PAGE_MASK   (PAGE_SIZE - 1)

/*
 * Kernel stack size for threads and interrupt handlers.
 */
#define STACK_SIZE PAGE_SIZE

/*
 * Virtual memory properties.
 */

/*
 * User space boundaries.
 */
#define VM_MIN_ADDRESS              DECL_CONST(0, UL)

#ifdef __LP64__
#define VM_MAX_ADDRESS              DECL_CONST(0x800000000000, UL)
#else /* __LP64__ */
#define VM_MAX_ADDRESS              DECL_CONST(0xc0000000, UL)
#endif/* __LP64__ */

/*
 * Kernel space boundaries.
 */
#ifdef __LP64__
#define VM_MIN_KERNEL_ADDRESS       DECL_CONST(0xffff800000000000, UL)
#define VM_MAX_KERNEL_ADDRESS       DECL_CONST(0xfffffffffffff000, UL)
#else /* __LP64__ */
#define VM_MIN_KERNEL_ADDRESS       VM_MAX_ADDRESS
#define VM_MAX_KERNEL_ADDRESS       DECL_CONST(0xfffff000, UL)
#endif /* __LP64__ */

/*
 * Direct physical mapping boundaries.
 */
#ifdef __LP64__
#define VM_MIN_DIRECTMAP_ADDRESS    VM_MIN_KERNEL_ADDRESS
#define VM_MAX_DIRECTMAP_ADDRESS    DECL_CONST(0xffffc00000000000, UL)
#else /* __LP64__ */
#define VM_MIN_DIRECTMAP_ADDRESS    VM_MAX_ADDRESS
#define VM_MAX_DIRECTMAP_ADDRESS    DECL_CONST(0xf8000000, UL)
#endif /* __LP64__ */

/*
 * Kernel mapping offset.
 *
 * On 32-bits systems, the kernel is linked at addresses included in the
 * direct physical mapping, whereas on 64-bits systems, it is linked at
 * -2 GiB because the "kernel" memory model is used when compiling (see
 * the -mcmodel=kernel gcc option).
 */
#ifdef __LP64__
#define VM_KERNEL_OFFSET            DECL_CONST(0xffffffff80000000, UL)
#else /* __LP64__ */
#define VM_KERNEL_OFFSET            VM_MIN_DIRECTMAP_ADDRESS
#endif /* __LP64__ */

/*
 * Kernel virtual space boundaries.
 *
 * In addition to the direct physical mapping, the kernel has its own virtual
 * memory space.
 */
#define VM_MIN_KMEM_ADDRESS         VM_MAX_DIRECTMAP_ADDRESS

#ifdef __LP64__
#define VM_MAX_KMEM_ADDRESS         VM_KERNEL_OFFSET
#else /* __LP64__ */
#define VM_MAX_KMEM_ADDRESS         DECL_CONST(0xfffff000, UL)
#endif /* __LP64__ */

/*
 * Physical memory properties.
 */

#define VM_PAGE_DMA_LIMIT       DECL_CONST(0x1000000, UL)

#ifdef __LP64__
#define VM_PAGE_MAX_SEGS 4
#define VM_PAGE_DMA32_LIMIT     DECL_CONST(0x100000000, UL)
#define VM_PAGE_DIRECTMAP_LIMIT DECL_CONST(0x400000000000, UL)
#define VM_PAGE_HIGHMEM_LIMIT   DECL_CONST(0x10000000000000, UL)
#else /* __LP64__ */
#define VM_PAGE_DIRECTMAP_LIMIT DECL_CONST(0x38000000, ULL)
#ifdef X86_PAE
#define VM_PAGE_MAX_SEGS 3
#define VM_PAGE_HIGHMEM_LIMIT   DECL_CONST(0x10000000000000, ULL)
#else /* X86_PAE */
#define VM_PAGE_MAX_SEGS 3
#define VM_PAGE_HIGHMEM_LIMIT   DECL_CONST(0xfffff000, UL)
#endif /* X86_PAE */
#endif /* __LP64__ */

/*
 * Physical segment indexes.
 */
#define VM_PAGE_SEG_DMA         0

#ifdef __LP64__
#define VM_PAGE_SEG_DMA32       1
#define VM_PAGE_SEG_DIRECTMAP   2
#define VM_PAGE_SEG_HIGHMEM     3
#else /* __LP64__ */
#define VM_PAGE_SEG_DMA32       1   /* Alias for the DIRECTMAP segment */
#define VM_PAGE_SEG_DIRECTMAP   1
#define VM_PAGE_SEG_HIGHMEM     2
#endif /* __LP64__ */

#endif /* _X86_PARAM_H */