1292407Sbr/*- 2292407Sbr * Copyright (c) 1990 The Regents of the University of California. 3292407Sbr * All rights reserved. 4292407Sbr * 5292407Sbr * This code is derived from software contributed to Berkeley by 6292407Sbr * William Jolitz. 7292407Sbr * 8292407Sbr * Redistribution and use in source and binary forms, with or without 9292407Sbr * modification, are permitted provided that the following conditions 10292407Sbr * are met: 11292407Sbr * 1. Redistributions of source code must retain the above copyright 12292407Sbr * notice, this list of conditions and the following disclaimer. 13292407Sbr * 2. Redistributions in binary form must reproduce the above copyright 14292407Sbr * notice, this list of conditions and the following disclaimer in the 15292407Sbr * documentation and/or other materials provided with the distribution. 16292407Sbr * 17292407Sbr * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18292407Sbr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19292407Sbr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20292407Sbr * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21292407Sbr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22292407Sbr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23292407Sbr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24292407Sbr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25292407Sbr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26292407Sbr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27292407Sbr * SUCH DAMAGE. 28292407Sbr * 29292407Sbr * from: @(#)param.h 5.8 (Berkeley) 6/28/91 30292407Sbr * $FreeBSD$ 31292407Sbr */ 32292407Sbr 33292407Sbr#ifndef _MACHINE_PARAM_H_ 34292407Sbr#define _MACHINE_PARAM_H_ 35292407Sbr 36292407Sbr/* 37292407Sbr * Machine dependent constants for RISC-V. 38292407Sbr */ 39292407Sbr 40292407Sbr#include <machine/_align.h> 41292407Sbr 42292407Sbr#define STACKALIGNBYTES (16 - 1) 43292407Sbr#define STACKALIGN(p) ((uint64_t)(p) & ~STACKALIGNBYTES) 44292407Sbr 45292407Sbr#ifndef MACHINE 46292407Sbr#define MACHINE "riscv" 47292407Sbr#endif 48292407Sbr#ifndef MACHINE_ARCH 49292407Sbr#define MACHINE_ARCH "riscv64" 50292407Sbr#endif 51292407Sbr 52292407Sbr#if defined(SMP) || defined(KLD_MODULE) 53292407Sbr#ifndef MAXCPU 54295972Sbr#define MAXCPU 16 55292407Sbr#endif 56292407Sbr#else 57292407Sbr#define MAXCPU 1 58292407Sbr#endif /* SMP || KLD_MODULE */ 59292407Sbr 60292407Sbr#ifndef MAXMEMDOM 61292407Sbr#define MAXMEMDOM 1 62292407Sbr#endif 63292407Sbr 64292407Sbr#define ALIGNBYTES _ALIGNBYTES 65292407Sbr#define ALIGN(p) _ALIGN(p) 66292407Sbr/* 67292407Sbr * ALIGNED_POINTER is a boolean macro that checks whether an address 68292407Sbr * is valid to fetch data elements of type t from on this architecture. 69292407Sbr * This does not reflect the optimal alignment, just the possibility 70292407Sbr * (within reasonable limits). 71292407Sbr */ 72292407Sbr#define ALIGNED_POINTER(p, t) ((((u_long)(p)) & (sizeof(t) - 1)) == 0) 73292407Sbr 74292407Sbr/* 75292407Sbr * CACHE_LINE_SIZE is the compile-time maximum cache line size for an 76292407Sbr * architecture. It should be used with appropriate caution. 77292407Sbr */ 78292407Sbr#define CACHE_LINE_SHIFT 6 79292407Sbr#define CACHE_LINE_SIZE (1 << CACHE_LINE_SHIFT) 80292407Sbr 81292407Sbr#define PAGE_SHIFT 12 82292407Sbr#define PAGE_SIZE (1 << PAGE_SHIFT) /* Page size */ 83292407Sbr#define PAGE_MASK (PAGE_SIZE - 1) 84292407Sbr 85292407Sbr#define MAXPAGESIZES 1 /* maximum number of supported page sizes */ 86292407Sbr 87292407Sbr#ifndef KSTACK_PAGES 88292407Sbr#define KSTACK_PAGES 4 /* pages of kernel stack (with pcb) */ 89292407Sbr#endif 90292407Sbr 91292407Sbr#define KSTACK_GUARD_PAGES 1 /* pages of kstack guard; 0 disables */ 92292407Sbr#define PCPU_PAGES 1 93292407Sbr 94292407Sbr/* 95292407Sbr * Mach derived conversion macros 96292407Sbr */ 97292407Sbr#define round_page(x) (((unsigned long)(x) + PAGE_MASK) & ~PAGE_MASK) 98292407Sbr#define trunc_page(x) ((unsigned long)(x) & ~PAGE_MASK) 99292407Sbr 100292407Sbr#define atop(x) ((unsigned long)(x) >> PAGE_SHIFT) 101292407Sbr#define ptoa(x) ((unsigned long)(x) << PAGE_SHIFT) 102292407Sbr 103292407Sbr#define riscv_btop(x) ((unsigned long)(x) >> PAGE_SHIFT) 104292407Sbr#define riscv_ptob(x) ((unsigned long)(x) << PAGE_SHIFT) 105292407Sbr 106292407Sbr#define pgtok(x) ((unsigned long)(x) * (PAGE_SIZE / 1024)) 107292407Sbr 108292407Sbr#endif /* !_MACHINE_PARAM_H_ */ 109