/*-1* Copyright (c) 1990 The Regents of the University of California.2* All rights reserved.3*4* This code is derived from software contributed to Berkeley by5* William Jolitz.6*7* Redistribution and use in source and binary forms, with or without8* modification, are permitted provided that the following conditions9* are met:10* 1. Redistributions of source code must retain the above copyright11* notice, this list of conditions and the following disclaimer.12* 2. Redistributions in binary form must reproduce the above copyright13* notice, this list of conditions and the following disclaimer in the14* documentation and/or other materials provided with the distribution.15*16* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND17* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE18* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE19* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE20* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL21* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS22* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)23* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT24* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF26* SUCH DAMAGE.27*/2829#ifndef _MACHINE_PARAM_H_30#define _MACHINE_PARAM_H_3132/*33* Machine dependent constants for RISC-V.34*/3536#include <machine/_align.h>3738#define STACKALIGNBYTES (16 - 1)39#define STACKALIGN(p) ((uint64_t)(p) & ~STACKALIGNBYTES)4041#ifndef MACHINE42#define MACHINE "riscv"43#endif44#ifndef MACHINE_ARCH45#define MACHINE_ARCH "riscv64"46#endif4748#ifdef SMP49#ifndef MAXCPU50#define MAXCPU 1651#endif52#else53#define MAXCPU 154#endif5556#ifndef MAXMEMDOM57#define MAXMEMDOM 158#endif5960#define ALIGNBYTES _ALIGNBYTES61#define ALIGN(p) _ALIGN(p)62/*63* ALIGNED_POINTER is a boolean macro that checks whether an address64* is valid to fetch data elements of type t from on this architecture.65* This does not reflect the optimal alignment, just the possibility66* (within reasonable limits).67*/68#define ALIGNED_POINTER(p, t) ((((u_long)(p)) & (sizeof(t) - 1)) == 0)6970/*71* CACHE_LINE_SIZE is the compile-time maximum cache line size for an72* architecture. It should be used with appropriate caution.73*/74#define CACHE_LINE_SHIFT 675#define CACHE_LINE_SIZE (1 << CACHE_LINE_SHIFT)7677#define PAGE_SHIFT 1278#define PAGE_SIZE (1 << PAGE_SHIFT) /* Page size */79#define PAGE_MASK (PAGE_SIZE - 1)8081#define MAXPAGESIZES 3 /* maximum number of supported page sizes */8283#ifndef KSTACK_PAGES84#define KSTACK_PAGES 4 /* pages of kernel stack (with pcb) */85#endif8687#define KSTACK_GUARD_PAGES 1 /* pages of kstack guard; 0 disables */88#define PCPU_PAGES 18990/*91* Mach derived conversion macros92*/93#define riscv_btop(x) ((unsigned long)(x) >> PAGE_SHIFT)94#define riscv_ptob(x) ((unsigned long)(x) << PAGE_SHIFT)9596#endif /* !_MACHINE_PARAM_H_ */979899