kernel: add header files
This commit is contained in:
81
include/kernel/pmap.h
Normal file
81
include/kernel/pmap.h
Normal file
@@ -0,0 +1,81 @@
|
||||
#ifndef KERNEL_PMAP_H_
|
||||
#define KERNEL_PMAP_H_
|
||||
|
||||
/* all the functions declared in this file are defined in arch/xyz/pmap.c */
|
||||
|
||||
#include <kernel/machine/pmap.h>
|
||||
#include <kernel/vm.h>
|
||||
#include <mango/status.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#define PMAP_INVALID ML_PMAP_INVALID
|
||||
#define PFN(x) ((x) >> VM_PAGE_SHIFT)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef ml_pmap_t pmap_t;
|
||||
typedef ml_pfn_t pfn_t;
|
||||
|
||||
enum pmap_fault_flags {
|
||||
/* if set, the faulting page is present, and the fault is
|
||||
* protection-related.
|
||||
* if clear, the faulting page is missing, and the
|
||||
* fault is due to the missing page.
|
||||
*/
|
||||
PMAP_FAULT_PRESENT = 0x01u,
|
||||
/* if set, the faulting page was accessed from user mode.
|
||||
* if clear, the faulting page was accessed from kernel mode.
|
||||
*/
|
||||
PMAP_FAULT_USER = 0x02u,
|
||||
/* if set, the fault was caused by a write operation.
|
||||
* if clear, the faulting page was caused by a read operation.
|
||||
*/
|
||||
PMAP_FAULT_WRITE = 0x04u,
|
||||
/* if set, the fault was caused while fetching an instruction from the
|
||||
* faulting page.
|
||||
*/
|
||||
PMAP_FAULT_IFETCH = 0x08u,
|
||||
/* if set, the fault was caused by misconfigured page tables */
|
||||
PMAP_FAULT_BADCFG = 0x10u,
|
||||
};
|
||||
|
||||
enum pmap_flags {
|
||||
PMAP_NORMAL = 0x00u,
|
||||
PMAP_HUGEPAGE = 0x01u,
|
||||
};
|
||||
|
||||
extern void pmap_bootstrap(void);
|
||||
extern pmap_t get_kernel_pmap(void);
|
||||
|
||||
extern pmap_t pmap_create(void);
|
||||
extern void pmap_destroy(pmap_t pmap);
|
||||
extern void pmap_switch(pmap_t pmap);
|
||||
|
||||
extern kern_status_t pmap_handle_fault(
|
||||
virt_addr_t fault_addr,
|
||||
enum pmap_fault_flags flags);
|
||||
|
||||
extern kern_status_t pmap_add(
|
||||
pmap_t pmap,
|
||||
virt_addr_t p,
|
||||
pfn_t pfn,
|
||||
vm_prot_t prot,
|
||||
enum pmap_flags flags);
|
||||
extern kern_status_t pmap_add_block(
|
||||
pmap_t pmap,
|
||||
virt_addr_t p,
|
||||
pfn_t pfn,
|
||||
size_t len,
|
||||
vm_prot_t prot,
|
||||
enum pmap_flags flags);
|
||||
|
||||
extern kern_status_t pmap_remove(pmap_t pmap, virt_addr_t p);
|
||||
extern kern_status_t pmap_remove_range(pmap_t pmap, virt_addr_t p, size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user