Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/sys/riscv/include/param.h
39535 views
1
/*-
2
* Copyright (c) 1990 The Regents of the University of California.
3
* All rights reserved.
4
*
5
* This code is derived from software contributed to Berkeley by
6
* William Jolitz.
7
*
8
* Redistribution and use in source and binary forms, with or without
9
* modification, are permitted provided that the following conditions
10
* are met:
11
* 1. Redistributions of source code must retain the above copyright
12
* notice, this list of conditions and the following disclaimer.
13
* 2. Redistributions in binary form must reproduce the above copyright
14
* notice, this list of conditions and the following disclaimer in the
15
* documentation and/or other materials provided with the distribution.
16
*
17
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
* SUCH DAMAGE.
28
*/
29
30
#ifndef _MACHINE_PARAM_H_
31
#define _MACHINE_PARAM_H_
32
33
/*
34
* Machine dependent constants for RISC-V.
35
*/
36
37
#include <machine/_align.h>
38
39
#define STACKALIGNBYTES (16 - 1)
40
#define STACKALIGN(p) ((uint64_t)(p) & ~STACKALIGNBYTES)
41
42
#ifndef MACHINE
43
#define MACHINE "riscv"
44
#endif
45
#ifndef MACHINE_ARCH
46
#define MACHINE_ARCH "riscv64"
47
#endif
48
49
#ifdef SMP
50
#ifndef MAXCPU
51
#define MAXCPU 16
52
#endif
53
#else
54
#define MAXCPU 1
55
#endif
56
57
#ifndef MAXMEMDOM
58
#define MAXMEMDOM 1
59
#endif
60
61
#define ALIGNBYTES _ALIGNBYTES
62
#define ALIGN(p) _ALIGN(p)
63
/*
64
* ALIGNED_POINTER is a boolean macro that checks whether an address
65
* is valid to fetch data elements of type t from on this architecture.
66
* This does not reflect the optimal alignment, just the possibility
67
* (within reasonable limits).
68
*/
69
#define ALIGNED_POINTER(p, t) ((((u_long)(p)) & (sizeof(t) - 1)) == 0)
70
71
/*
72
* CACHE_LINE_SIZE is the compile-time maximum cache line size for an
73
* architecture. It should be used with appropriate caution.
74
*/
75
#define CACHE_LINE_SHIFT 6
76
#define CACHE_LINE_SIZE (1 << CACHE_LINE_SHIFT)
77
78
#define PAGE_SHIFT 12
79
#define PAGE_SIZE (1 << PAGE_SHIFT) /* Page size */
80
#define PAGE_MASK (PAGE_SIZE - 1)
81
82
#define MAXPAGESIZES 3 /* maximum number of supported page sizes */
83
84
#ifndef KSTACK_PAGES
85
#define KSTACK_PAGES 4 /* pages of kernel stack (with pcb) */
86
#endif
87
88
#define KSTACK_GUARD_PAGES 1 /* pages of kstack guard; 0 disables */
89
#define PCPU_PAGES 1
90
91
/*
92
* Mach derived conversion macros
93
*/
94
#define riscv_btop(x) ((unsigned long)(x) >> PAGE_SHIFT)
95
#define riscv_ptob(x) ((unsigned long)(x) << PAGE_SHIFT)
96
97
#endif /* !_MACHINE_PARAM_H_ */
98
99