36 lines
1.2 KiB
C
36 lines
1.2 KiB
C
/*
|
|
* Copyright (c) 2020 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU)
|
|
* OS-Lab-2020 (i.e., ChCore) is licensed under the Mulan PSL v1.
|
|
* You can use this software according to the terms and conditions of the Mulan PSL v1.
|
|
* You may obtain a copy of Mulan PSL v1 at:
|
|
* http://license.coscl.org.cn/MulanPSL
|
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
|
* PURPOSE.
|
|
* See the Mulan PSL v1 for more details.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <common/types.h>
|
|
typedef u64 vmr_prop_t;
|
|
#define VMR_READ (1 << 0)
|
|
#define VMR_WRITE (1 << 1)
|
|
#define VMR_EXEC (1 << 2)
|
|
#define KERNEL_PT (1 << 3)
|
|
/* functions */
|
|
int map_range_in_pgtbl(vaddr_t * pgtbl, vaddr_t va, paddr_t pa,
|
|
size_t len, vmr_prop_t flags);
|
|
int unmap_range_in_pgtbl(vaddr_t * pgtbl, vaddr_t va, size_t len);
|
|
|
|
#ifndef KBASE
|
|
#define KBASE 0xFFFFFF0000000000
|
|
#endif
|
|
|
|
#ifdef CHCORE
|
|
|
|
#define phys_to_virt(x) ((vaddr_t)((paddr_t)(x) + KBASE))
|
|
#define virt_to_phys(x) ((paddr_t)((vaddr_t)(x) - KBASE))
|
|
|
|
#endif
|