arch_kernel.h revision 05dda88d
1/*
2 * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
3 * Distributed under the terms of the NewOS License.
4 */
5#ifndef _KERNEL_ARCH_RISCV64_KERNEL_H
6#define _KERNEL_ARCH_RISCV64_KERNEL_H
7
8#include <arch/cpu.h>
9
10#warning Review arch_kernel.h
11
12// memory layout
13#define KERNEL_LOAD_BASE        0x80000000
14#define KERNEL_LOAD_BASE_64_BIT 0xffffffff80000000ll
15
16
17#if defined(__riscv64__)
18
19// Base of the kernel address space.
20#define KERNEL_BASE             0xffffff0000000000
21#define KERNEL_SIZE             0x10000000000
22#define KERNEL_TOP              (KERNEL_BASE + (KERNEL_SIZE - 1))
23#define KERNEL_LOAD_BASE        0xffffffff80000000
24
25// Kernel physical memory map area.
26#define KERNEL_PMAP_BASE        0xffffff0000000000
27#define KERNEL_PMAP_SIZE        0x8000000000
28
29// Userspace address space layout.
30// There is a 2MB hole just before the end of the bottom half of the address
31// space. This means that if userland passes in a buffer that crosses into the
32// uncanonical address region, it will be caught through a page fault.
33#define USER_BASE               0x100000
34#define USER_BASE_ANY           USER_BASE
35#define USER_SIZE               (0x800000000000 - (0x200000 + 0x100000))
36#define USER_TOP                (USER_BASE + (USER_SIZE - 1))
37
38#define KERNEL_USER_DATA_BASE   0x7f0000000000
39#define USER_STACK_REGION       0x7f0000000000
40#define USER_STACK_REGION_SIZE  ((USER_TOP - USER_STACK_REGION) + 1)
41
42#else /* ! __riscv64__ */
43	#warning Unknown RISC-V Architecture!
44#endif
45
46#endif	/* _KERNEL_ARCH_RISCV64_KERNEL_H */
47