xref: /netbsd-src/sys/arch/riscv/include/param.h (revision 75b842b84762e0251223b719bf77fbef2e651bf6)
1*75b842b8Sskrll /* $NetBSD: param.h,v 1.8 2023/05/07 12:41:48 skrll Exp $ */
26cf6fe02Smatt 
36cf6fe02Smatt /*-
46cf6fe02Smatt  * Copyright (c) 2014 The NetBSD Foundation, Inc.
56cf6fe02Smatt  * All rights reserved.
66cf6fe02Smatt  *
76cf6fe02Smatt  * This code is derived from software contributed to The NetBSD Foundation
86cf6fe02Smatt  * by Matt Thomas of 3am Software Foundry.
96cf6fe02Smatt  *
106cf6fe02Smatt  * Redistribution and use in source and binary forms, with or without
116cf6fe02Smatt  * modification, are permitted provided that the following conditions
126cf6fe02Smatt  * are met:
136cf6fe02Smatt  * 1. Redistributions of source code must retain the above copyright
146cf6fe02Smatt  *    notice, this list of conditions and the following disclaimer.
156cf6fe02Smatt  * 2. Redistributions in binary form must reproduce the above copyright
166cf6fe02Smatt  *    notice, this list of conditions and the following disclaimer in the
176cf6fe02Smatt  *    documentation and/or other materials provided with the distribution.
186cf6fe02Smatt  *
196cf6fe02Smatt  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
206cf6fe02Smatt  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
216cf6fe02Smatt  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
226cf6fe02Smatt  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
236cf6fe02Smatt  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
246cf6fe02Smatt  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
256cf6fe02Smatt  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
266cf6fe02Smatt  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
276cf6fe02Smatt  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
286cf6fe02Smatt  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
296cf6fe02Smatt  * POSSIBILITY OF SUCH DAMAGE.
306cf6fe02Smatt  */
316cf6fe02Smatt 
326cf6fe02Smatt #ifndef	_RISCV_PARAM_H_
336cf6fe02Smatt #define	_RISCV_PARAM_H_
346cf6fe02Smatt 
35b1b36fc1Ssimonb #ifdef _KERNEL_OPT
36b1b36fc1Ssimonb #include "opt_param.h"
37b1b36fc1Ssimonb #endif
38b1b36fc1Ssimonb 
396cf6fe02Smatt /*
406cf6fe02Smatt  * Machine dependent constants for all OpenRISC processors
416cf6fe02Smatt  */
426cf6fe02Smatt 
436cf6fe02Smatt /*
446cf6fe02Smatt  * For KERNEL code:
456cf6fe02Smatt  *	MACHINE must be defined by the individual port.  This is so that
466cf6fe02Smatt  *	uname returns the correct thing, etc.
476cf6fe02Smatt  *
486cf6fe02Smatt  * For non-KERNEL code:
496cf6fe02Smatt  *	If ELF, MACHINE and MACHINE_ARCH are forced to "or1k/or1k".
506cf6fe02Smatt  */
516cf6fe02Smatt 
526cf6fe02Smatt #ifdef _LP64
536cf6fe02Smatt #define	_MACHINE_ARCH		riscv64
546cf6fe02Smatt #define	MACHINE_ARCH		"riscv64"
556cf6fe02Smatt #define	_MACHINE_ARCH32		riscv32
566cf6fe02Smatt #define	MACHINE_ARCH32		"riscv32"
576cf6fe02Smatt #else
586cf6fe02Smatt #define	_MACHINE_ARCH		riscv32
596cf6fe02Smatt #define	MACHINE_ARCH		"riscv32"
606cf6fe02Smatt #endif
616cf6fe02Smatt #define	_MACHINE		riscv
626cf6fe02Smatt #define	MACHINE			"riscv"
636cf6fe02Smatt 
646cf6fe02Smatt #define	MID_MACHINE		MID_RISCV
656cf6fe02Smatt 
66*75b842b8Sskrll /* RISC-V specific macro to align a stack pointer (downwards). */
67*75b842b8Sskrll #define STACK_ALIGNBYTES	(16UL - 1)
686cf6fe02Smatt #define	ALIGNBYTES32		__BIGGEST_ALIGNMENT__
696cf6fe02Smatt 
70aa62b115Ssimonb #define NKMEMPAGES_MIN_DEFAULT		((128UL * 1024 * 1024) >> PAGE_SHIFT)
71aa62b115Ssimonb #define NKMEMPAGES_MAX_UNLIMITED	1
726cf6fe02Smatt 
736cf6fe02Smatt #define PGSHIFT			12
746cf6fe02Smatt #define	NBPG			(1 << PGSHIFT)
756cf6fe02Smatt #define PGOFSET			(NBPG - 1)
766cf6fe02Smatt 
776cf6fe02Smatt #define UPAGES			2
786cf6fe02Smatt #define	USPACE			(UPAGES << PGSHIFT)
796cf6fe02Smatt #define USPACE_ALIGN		NBPG
806cf6fe02Smatt 
816cf6fe02Smatt /*
826cf6fe02Smatt  * Constants related to network buffer management.
836cf6fe02Smatt  * MCLBYTES must be no larger than NBPG (the software page size), and
846cf6fe02Smatt  * NBPG % MCLBYTES must be zero.
856cf6fe02Smatt  */
866cf6fe02Smatt #define	MSIZE			512		/* size of an mbuf */
876cf6fe02Smatt 
886cf6fe02Smatt #ifndef MCLSHIFT
896cf6fe02Smatt #define	MCLSHIFT		11		/* convert bytes to m_buf clusters */
906cf6fe02Smatt 						/* 2K cluster can hold Ether frame */
916cf6fe02Smatt #endif	/* MCLSHIFT */
926cf6fe02Smatt 
936cf6fe02Smatt #define	MCLBYTES		(1 << MCLSHIFT)	/* size of a m_buf cluster */
946cf6fe02Smatt 
95fa49a3b5Sskrll #ifndef MSGBUFSIZE
96fa49a3b5Sskrll #define MSGBUFSIZE		65536		/* default message buffer size */
97fa49a3b5Sskrll #endif
98fa49a3b5Sskrll 
99fa49a3b5Sskrll #define MAXCPUS			32
100fa49a3b5Sskrll 
1016cf6fe02Smatt #ifdef _KERNEL
1026cf6fe02Smatt void delay(unsigned long);
1036cf6fe02Smatt #define	DELAY(x)		delay(x)
1046cf6fe02Smatt #endif
1056cf6fe02Smatt 
106*75b842b8Sskrll #define riscv_btop(x)		((unsigned long)(x) >> PGSHIFT)
107*75b842b8Sskrll #define riscv_ptob(x)		((unsigned long)(x) << PGSHIFT)
108*75b842b8Sskrll 
109*75b842b8Sskrll 
1106cf6fe02Smatt #endif /* _RISCV_PARAM_H_ */
111