xref: /freebsd/sys/riscv/include/param.h (revision 5884fab46153dee52bda660bcabca95c3cc97f44)
18d7e7a98SRuslan Bukin /*-
28d7e7a98SRuslan Bukin  * Copyright (c) 1990 The Regents of the University of California.
38d7e7a98SRuslan Bukin  * All rights reserved.
48d7e7a98SRuslan Bukin  *
58d7e7a98SRuslan Bukin  * This code is derived from software contributed to Berkeley by
68d7e7a98SRuslan Bukin  * William Jolitz.
78d7e7a98SRuslan Bukin  *
88d7e7a98SRuslan Bukin  * Redistribution and use in source and binary forms, with or without
98d7e7a98SRuslan Bukin  * modification, are permitted provided that the following conditions
108d7e7a98SRuslan Bukin  * are met:
118d7e7a98SRuslan Bukin  * 1. Redistributions of source code must retain the above copyright
128d7e7a98SRuslan Bukin  *    notice, this list of conditions and the following disclaimer.
138d7e7a98SRuslan Bukin  * 2. Redistributions in binary form must reproduce the above copyright
148d7e7a98SRuslan Bukin  *    notice, this list of conditions and the following disclaimer in the
158d7e7a98SRuslan Bukin  *    documentation and/or other materials provided with the distribution.
168d7e7a98SRuslan Bukin  *
178d7e7a98SRuslan Bukin  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
188d7e7a98SRuslan Bukin  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
198d7e7a98SRuslan Bukin  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
208d7e7a98SRuslan Bukin  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
218d7e7a98SRuslan Bukin  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
228d7e7a98SRuslan Bukin  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
238d7e7a98SRuslan Bukin  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
248d7e7a98SRuslan Bukin  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
258d7e7a98SRuslan Bukin  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
268d7e7a98SRuslan Bukin  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
278d7e7a98SRuslan Bukin  * SUCH DAMAGE.
288d7e7a98SRuslan Bukin  */
298d7e7a98SRuslan Bukin 
308d7e7a98SRuslan Bukin #ifndef _MACHINE_PARAM_H_
318d7e7a98SRuslan Bukin #define	_MACHINE_PARAM_H_
328d7e7a98SRuslan Bukin 
338d7e7a98SRuslan Bukin /*
348d7e7a98SRuslan Bukin  * Machine dependent constants for RISC-V.
358d7e7a98SRuslan Bukin  */
368d7e7a98SRuslan Bukin 
378d7e7a98SRuslan Bukin #include <machine/_align.h>
388d7e7a98SRuslan Bukin 
398d7e7a98SRuslan Bukin #define	STACKALIGNBYTES	(16 - 1)
408d7e7a98SRuslan Bukin #define	STACKALIGN(p)	((uint64_t)(p) & ~STACKALIGNBYTES)
418d7e7a98SRuslan Bukin 
428d7e7a98SRuslan Bukin #ifndef MACHINE
438d7e7a98SRuslan Bukin #define	MACHINE		"riscv"
448d7e7a98SRuslan Bukin #endif
458d7e7a98SRuslan Bukin #ifndef MACHINE_ARCH
46*61bbe53cSJohn Baldwin #define	MACHINE_ARCH	"riscv64"
478d7e7a98SRuslan Bukin #endif
488d7e7a98SRuslan Bukin 
49c3d326fdSMark Johnston #ifdef SMP
508d7e7a98SRuslan Bukin #ifndef MAXCPU
5117696c12SRuslan Bukin #define	MAXCPU		16
528d7e7a98SRuslan Bukin #endif
538d7e7a98SRuslan Bukin #else
548d7e7a98SRuslan Bukin #define	MAXCPU		1
55c3d326fdSMark Johnston #endif
568d7e7a98SRuslan Bukin 
578d7e7a98SRuslan Bukin #ifndef MAXMEMDOM
588d7e7a98SRuslan Bukin #define	MAXMEMDOM	1
598d7e7a98SRuslan Bukin #endif
608d7e7a98SRuslan Bukin 
618d7e7a98SRuslan Bukin #define	ALIGNBYTES	_ALIGNBYTES
628d7e7a98SRuslan Bukin #define	ALIGN(p)	_ALIGN(p)
638d7e7a98SRuslan Bukin /*
648d7e7a98SRuslan Bukin  * ALIGNED_POINTER is a boolean macro that checks whether an address
658d7e7a98SRuslan Bukin  * is valid to fetch data elements of type t from on this architecture.
668d7e7a98SRuslan Bukin  * This does not reflect the optimal alignment, just the possibility
678d7e7a98SRuslan Bukin  * (within reasonable limits).
688d7e7a98SRuslan Bukin  */
698d7e7a98SRuslan Bukin #define	ALIGNED_POINTER(p, t)	((((u_long)(p)) & (sizeof(t) - 1)) == 0)
708d7e7a98SRuslan Bukin 
718d7e7a98SRuslan Bukin /*
728d7e7a98SRuslan Bukin  * CACHE_LINE_SIZE is the compile-time maximum cache line size for an
738d7e7a98SRuslan Bukin  * architecture.  It should be used with appropriate caution.
748d7e7a98SRuslan Bukin  */
758d7e7a98SRuslan Bukin #define	CACHE_LINE_SHIFT	6
768d7e7a98SRuslan Bukin #define	CACHE_LINE_SIZE		(1 << CACHE_LINE_SHIFT)
778d7e7a98SRuslan Bukin 
788d7e7a98SRuslan Bukin #define	PAGE_SHIFT	12
798d7e7a98SRuslan Bukin #define	PAGE_SIZE	(1 << PAGE_SHIFT)	/* Page size */
808d7e7a98SRuslan Bukin #define	PAGE_MASK	(PAGE_SIZE - 1)
818d7e7a98SRuslan Bukin 
82f6893f09SMark Johnston #define	MAXPAGESIZES	3	/* maximum number of supported page sizes */
838d7e7a98SRuslan Bukin 
848d7e7a98SRuslan Bukin #ifndef KSTACK_PAGES
858d7e7a98SRuslan Bukin #define	KSTACK_PAGES	4	/* pages of kernel stack (with pcb) */
868d7e7a98SRuslan Bukin #endif
878d7e7a98SRuslan Bukin 
888d7e7a98SRuslan Bukin #define	KSTACK_GUARD_PAGES	1	/* pages of kstack guard; 0 disables */
898d7e7a98SRuslan Bukin #define	PCPU_PAGES		1
908d7e7a98SRuslan Bukin 
918d7e7a98SRuslan Bukin /*
928d7e7a98SRuslan Bukin  * Mach derived conversion macros
938d7e7a98SRuslan Bukin  */
948d7e7a98SRuslan Bukin #define	riscv_btop(x)		((unsigned long)(x) >> PAGE_SHIFT)
958d7e7a98SRuslan Bukin #define	riscv_ptob(x)		((unsigned long)(x) << PAGE_SHIFT)
968d7e7a98SRuslan Bukin 
978d7e7a98SRuslan Bukin #endif /* !_MACHINE_PARAM_H_ */
98