"Intel64 mode"
};
-static int _pg_dir_add_region(pg_dir_t*, void*, u32_t, region_type_t, u32_t, region_opts_t);
+static int _pg_dir_add_region(pg_dir_t*, void*, u32_t, region_type_t, page_attrs_t, region_opts_t);
int _pg_dir_vpxlate(pg_dir_t*, u32_t, u32_t*);
int _pg_dir_pagesize(pg_dir_t*, u32_t, u32_t*);
int _pg_dir_xfer(pg_dir_t*, void*, pg_dir_t*, void*, u32_t);
for(mmap = (struct memory_map*)info->mmap_addr;
(void*)mmap < (void*)(info->mmap_addr + info->mmap_length);
mmap = (struct memory_map*)((void*)mmap + mmap->size + sizeof(mmap->size))) {
- u32_t attrs;
+ page_attrs_t attrs;
u64_t addr;
#if FEATURE(DEBUG)
frame = pg_frame_alloc_end();
if(ret_val) {
- u32_t attrs;
+ page_attrs_t attrs;
void* vaddr;
vaddr = CONFIG_KERNEL_STACK_BASE;
frame = pg_frame_alloc_end();
if(ret_val) {
- u32_t attrs;
+ page_attrs_t attrs;
void* vaddr;
vaddr = (void*)((u32_t)CONFIG_KERNEL_STACK_BASE - PAGE_SIZE);
/* we found a place to allocate the heap segment */
if(heap_start) {
- u32_t attrs;
+ page_attrs_t attrs;
/* the heap shouldn't be executable, right? */
attrs = PAGE_ATTR_PRESENT | PAGE_ATTR_WRITABLE |
}
static int _pg_dir_add_region(pg_dir_t *pd, void *base, u32_t size,
- region_type_t type, u32_t attrs, region_opts_t opts)
+ region_type_t type, page_attrs_t attrs, region_opts_t opts)
{
struct region *reg;
int ret_val;
/* round up to the page size */
nbytes = ALIGN(increment, heap->reg_pgsize);
- err = pg_dir_map(pd, 0, heap->reg_base + heap->reg_size, nbytes, heap->reg_attrs);
+ err = pg_dir_map(pd, 0, heap->reg_base + heap->reg_size,
+ nbytes, heap->reg_attrs);
if(!err) {
/* successfully mapped pages - keep track of the increased heap size */
/* value may be zero, e.g. if the caller wants to free less than a page */
if(nbytes) {
/* remove nbytes of space at the end of the region */
- err = pg_dir_unmap(pd, heap->reg_base + heap->reg_size - nbytes, nbytes);
+ err = pg_dir_unmap(pd, heap->reg_base + heap->reg_size - nbytes,
+ nbytes);
if(!err) {
heap->reg_size -= nbytes;
pid_t t_pid;
} __attribute__((packed));
+#define ALIGNED(_v, _a) (!((_v) & (((_a) - 1))))
+#define ALIGN(_v, _a) (ALIGNED((_v), (_a)) ? (_v) : (((_v) & ~((_a) - 1)) + (_a)))
+
+#if FEATURE(SMP) && FEATURE(APIC)
+#define CPU_ID cpu_get_id()
+#else /* !(FEATURE(SMP) && FEATURE(APIC)) */
+#define CPU_ID 0
+#endif /* !(FEATURE(SMP) && FEATURE(APIC)) */
+
+#define PDPT_ALIGN 32
+#define PAGE_ALIGN 0x1000
+#define ARCH_ALIGN sizeof(void*)
+
+#define PAGE_SIZE 0x1000
+#define PAGE_SIZE_BIG 0x200000
+#define PAGE_SIZE_LARGE 0x400000
+#define PAGE_SIZE_HUGE 0x40000000
+
+typedef enum {
+ PAGE_ATTR_PRESENT = (1 << 0),
+ PAGE_ATTR_WRITABLE = (1 << 1),
+ PAGE_ATTR_USER = (1 << 2),
+ PAGE_ATTR_WRITE_THRU = (1 << 3),
+ PAGE_ATTR_CACHE_DISABLE = (1 << 4),
+ PAGE_ATTR_ACCESSED = (1 << 5),
+ PAGE_ATTR_DIRTY = (1 << 6),
+ PAGE_ATTR_SIZE = (1 << 7),
+ PAGE_ATTR_GLOBAL = (1 << 8),
+#if FEATURE(PAGING_NX)
+ PAGE_ATTR_NO_EXEC = (1 << 63)
+#else /* !FEATURE(PAGING_NX) */
+ PAGE_ATTR_NO_EXEC = 0
+#endif /* !FEATURE(PAGING_NX) */
+} page_attrs_t;
+
typedef enum {
REGION_TYPE_TEXT = 0,
REGION_TYPE_BSS,
typedef struct region region_t;
struct region {
- void *reg_base;
+ void *reg_base;
region_type_t reg_type;
- u32_t reg_size;
- u32_t reg_pgsize;
- u32_t reg_attrs; /* page attributes */
+ u32_t reg_size;
+ u32_t reg_pgsize;
+ page_attrs_t reg_attrs;
region_opts_t reg_opts;
- u32_t reg_refs;
+ u32_t reg_refs;
};
-#if FEATURE(SMP) && FEATURE(APIC)
-#define CPU_ID cpu_get_id()
-#else /* !(FEATURE(SMP) && FEATURE(APIC)) */
-#define CPU_ID 0
-#endif /* !(FEATURE(SMP) && FEATURE(APIC)) */
+typedef struct pagedir pg_dir_t;
int cpu_get_id(void);
u64_t cpu_get_capabilities(void);
void task_lock(task_t*);
int task_unlock(task_t*);
-/*
- * Definitions, types, and prototypes related to paging
- */
-
-#define ALIGNED(_v, _a) (!((_v) & (((_a) - 1))))
-#define ALIGN(_v, _a) (ALIGNED((_v), (_a)) ? (_v) : (((_v) & ~((_a) - 1)) + (_a)))
-
-#define PDPT_ALIGN 32
-#define PAGE_ALIGN 0x1000
-#define ARCH_ALIGN sizeof(void*)
-
-#define PAGE_SIZE 0x1000
-#define PAGE_SIZE_BIG 0x200000
-#define PAGE_SIZE_LARGE 0x400000
-#define PAGE_SIZE_HUGE 0x40000000
-
-#define PAGE_ATTR_PRESENT (1 << 0)
-#define PAGE_ATTR_WRITABLE (1 << 1)
-#define PAGE_ATTR_USER (1 << 2)
-#define PAGE_ATTR_WRITE_THRU (1 << 3)
-#define PAGE_ATTR_CACHE_DISABLE (1 << 4)
-#define PAGE_ATTR_ACCESSED (1 << 5)
-#define PAGE_ATTR_DIRTY (1 << 6)
-#define PAGE_ATTR_SIZE (1 << 7)
-#define PAGE_ATTR_GLOBAL (1 << 8)
-#define PAGE_ATTR_NO_EXEC 0 /* (1 << 63) */
-
-typedef struct pagedir pg_dir_t;
-
int pg_dir_create(pg_dir_t**);
/*
*
* SYNOPSIS
* int pg_dir_map(pg_dir_t* pd, const void *paddr, const void *vaddr,
- * const u32_t bytes, const u32_t attrs);
+ * const u32_t bytes, const page_attrs_t);
*
* DESCRIPTION
* The pg_dir_map() function attempts to map page frames (physical pages) into
* -ENOSYS The function is not implemented for this paging mode
* -EFAULT Could not determine the paging mode used by the page directory
*/
-int pg_dir_map(pg_dir_t*, const void*, const void*, const u32_t, const u32_t);
+int pg_dir_map(pg_dir_t*, const void*, const void*, const u32_t, const page_attrs_t);
int pg_dir_map_region(pg_dir_t*, pg_dir_t*, region_t*);
int pg_dir_clone_region(pg_dir_t*, pg_dir_t*, region_t*);
int pg_dir_unmap(pg_dir_t*, const void*, const u32_t);