summaryrefslogtreecommitdiff
path: root/vm
diff options
context:
space:
mode:
Diffstat (limited to 'vm')
-rw-r--r--vm/vm_kmem.c29
-rw-r--r--vm/vm_kmem.h7
-rw-r--r--vm/vm_map.c43
-rw-r--r--vm/vm_map.h16
-rw-r--r--vm/vm_page.c7
-rw-r--r--vm/vm_page.h7
6 files changed, 57 insertions, 52 deletions
diff --git a/vm/vm_kmem.c b/vm/vm_kmem.c
index 5c4e6a73..7de04bd8 100644
--- a/vm/vm_kmem.c
+++ b/vm/vm_kmem.c
@@ -24,6 +24,7 @@
#include <kern/panic.h>
#include <kern/param.h>
#include <kern/stddef.h>
+#include <kern/stdint.h>
#include <kern/types.h>
#include <machine/pmap.h>
#include <vm/vm_adv.h>
@@ -51,7 +52,7 @@ vm_kmem_alloc_check(size_t size)
}
static int
-vm_kmem_free_check(unsigned long va, size_t size)
+vm_kmem_free_check(uintptr_t va, size_t size)
{
if (!vm_page_aligned(va)) {
return -1;
@@ -63,8 +64,8 @@ vm_kmem_free_check(unsigned long va, size_t size)
void *
vm_kmem_alloc_va(size_t size)
{
- unsigned long va;
int error, flags;
+ uintptr_t va;
assert(vm_kmem_alloc_check(size) == 0);
@@ -83,9 +84,9 @@ vm_kmem_alloc_va(size_t size)
void
vm_kmem_free_va(void *addr, size_t size)
{
- unsigned long va;
+ uintptr_t va;
- va = (unsigned long)addr;
+ va = (uintptr_t)addr;
assert(vm_kmem_free_check(va, size) == 0);
vm_map_remove(kernel_map, va, va + vm_page_round(size));
}
@@ -94,10 +95,10 @@ void *
vm_kmem_alloc(size_t size)
{
struct vm_page *page;
- unsigned long va, start, end;
+ uintptr_t va, start, end;
size = vm_page_round(size);
- va = (unsigned long)vm_kmem_alloc_va(size);
+ va = (uintptr_t)vm_kmem_alloc_va(size);
if (va == 0) {
return 0;
@@ -139,11 +140,11 @@ vm_kmem_free(void *addr, size_t size)
{
const struct cpumap *cpumap;
struct vm_page *page;
- unsigned long va, end;
+ uintptr_t va, end;
phys_addr_t pa;
int error;
- va = (unsigned long)addr;
+ va = (uintptr_t)addr;
size = vm_page_round(size);
end = va + size;
cpumap = cpumap_all();
@@ -164,15 +165,15 @@ vm_kmem_free(void *addr, size_t size)
void *
vm_kmem_map_pa(phys_addr_t pa, size_t size,
- unsigned long *map_vap, size_t *map_sizep)
+ uintptr_t *map_vap, size_t *map_sizep)
{
- unsigned long offset, map_va;
+ uintptr_t offset, map_va;
size_t map_size;
phys_addr_t start;
start = vm_page_trunc(pa);
map_size = vm_page_round(pa + size) - start;
- map_va = (unsigned long)vm_kmem_alloc_va(map_size);
+ map_va = (uintptr_t)vm_kmem_alloc_va(map_size);
if (map_va == 0) {
return NULL;
@@ -192,14 +193,14 @@ vm_kmem_map_pa(phys_addr_t pa, size_t size,
*map_sizep = map_size;
}
- return (void *)(map_va + (unsigned long)(pa & PAGE_MASK));
+ return (void *)(map_va + (uintptr_t)(pa & PAGE_MASK));
}
void
-vm_kmem_unmap_pa(unsigned long map_va, size_t map_size)
+vm_kmem_unmap_pa(uintptr_t map_va, size_t map_size)
{
const struct cpumap *cpumap;
- unsigned long va, end;
+ uintptr_t va, end;
cpumap = cpumap_all();
end = map_va + map_size;
diff --git a/vm/vm_kmem.h b/vm/vm_kmem.h
index 771a5d9d..a5e5e6d0 100644
--- a/vm/vm_kmem.h
+++ b/vm/vm_kmem.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2014 Richard Braun
+ * Copyright (c) 2010-2017 Richard Braun
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,6 +19,7 @@
#define _VM_VM_KMEM_H
#include <kern/types.h>
+#include <kern/stdint.h>
/*
* The kernel space is required not to start at address 0, which is used to
@@ -79,11 +80,11 @@ void vm_kmem_free(void *addr, size_t size);
* caching on the mapping.
*/
void * vm_kmem_map_pa(phys_addr_t pa, size_t size,
- unsigned long *map_vap, size_t *map_sizep);
+ uintptr_t *map_vap, size_t *map_sizep);
/*
* Unmap physical memory from the kernel map.
*/
-void vm_kmem_unmap_pa(unsigned long map_va, size_t map_size);
+void vm_kmem_unmap_pa(uintptr_t map_va, size_t map_size);
#endif /* _VM_VM_KMEM_H */
diff --git a/vm/vm_map.c b/vm/vm_map.c
index 78ff2cc3..8cfc5502 100644
--- a/vm/vm_map.c
+++ b/vm/vm_map.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011-2014 Richard Braun.
+ * Copyright (c) 2011-2017 Richard Braun.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -53,7 +53,7 @@
* by the mapping functions.
*/
struct vm_map_request {
- unsigned long start;
+ uintptr_t start;
size_t size;
size_t align;
int flags;
@@ -62,7 +62,7 @@ struct vm_map_request {
struct vm_map_entry *next;
};
-static int vm_map_prepare(struct vm_map *map, unsigned long start,
+static int vm_map_prepare(struct vm_map *map, uintptr_t start,
size_t size, size_t align, int flags,
struct vm_object *object, uint64_t offset,
struct vm_map_request *request);
@@ -95,7 +95,7 @@ vm_map_entry_destroy(struct vm_map_entry *entry)
}
static inline int
-vm_map_entry_cmp_lookup(unsigned long addr, const struct rbtree_node *node)
+vm_map_entry_cmp_lookup(uintptr_t addr, const struct rbtree_node *node)
{
struct vm_map_entry *entry;
@@ -153,7 +153,7 @@ vm_map_request_assert_valid(const struct vm_map_request *request)
* address), or NULL if there is no such entry.
*/
static struct vm_map_entry *
-vm_map_lookup_nearest(struct vm_map *map, unsigned long addr)
+vm_map_lookup_nearest(struct vm_map *map, uintptr_t addr)
{
struct vm_map_entry *entry;
struct rbtree_node *node;
@@ -190,7 +190,7 @@ static int
vm_map_find_fixed(struct vm_map *map, struct vm_map_request *request)
{
struct vm_map_entry *next;
- unsigned long start;
+ uintptr_t start;
size_t size;
start = request->start;
@@ -224,7 +224,7 @@ vm_map_find_avail(struct vm_map *map, struct vm_map_request *request)
{
struct vm_map_entry *next;
struct list *node;
- unsigned long base, start;
+ uintptr_t base, start;
size_t size, align, space;
int error;
@@ -374,7 +374,7 @@ vm_map_unlink(struct vm_map *map, struct vm_map_entry *entry)
* prepare the mapping request for that region.
*/
static int
-vm_map_prepare(struct vm_map *map, unsigned long start,
+vm_map_prepare(struct vm_map *map, uintptr_t start,
size_t size, size_t align, int flags,
struct vm_object *object, uint64_t offset,
struct vm_map_request *request)
@@ -446,7 +446,7 @@ vm_map_try_merge_next(struct vm_map *map, const struct vm_map_request *request,
struct vm_map_entry *entry)
{
struct vm_map_entry *prev, *next;
- unsigned long end;
+ uintptr_t end;
assert(entry != NULL);
@@ -566,7 +566,7 @@ out:
}
int
-vm_map_enter(struct vm_map *map, unsigned long *startp,
+vm_map_enter(struct vm_map *map, uintptr_t *startp,
size_t size, size_t align, int flags,
struct vm_object *object, uint64_t offset)
{
@@ -601,9 +601,9 @@ error_enter:
static void
vm_map_split_entries(struct vm_map_entry *prev, struct vm_map_entry *next,
- unsigned long split_addr)
+ uintptr_t split_addr)
{
- unsigned long delta;
+ uintptr_t delta;
delta = split_addr - prev->start;
prev->end = split_addr;
@@ -616,7 +616,7 @@ vm_map_split_entries(struct vm_map_entry *prev, struct vm_map_entry *next,
static void
vm_map_clip_start(struct vm_map *map, struct vm_map_entry *entry,
- unsigned long start)
+ uintptr_t start)
{
struct vm_map_entry *new_entry, *next;
@@ -634,8 +634,7 @@ vm_map_clip_start(struct vm_map *map, struct vm_map_entry *entry,
}
static void
-vm_map_clip_end(struct vm_map *map, struct vm_map_entry *entry,
- unsigned long end)
+vm_map_clip_end(struct vm_map *map, struct vm_map_entry *entry, uintptr_t end)
{
struct vm_map_entry *new_entry, *prev;
@@ -653,7 +652,7 @@ vm_map_clip_end(struct vm_map *map, struct vm_map_entry *entry,
}
void
-vm_map_remove(struct vm_map *map, unsigned long start, unsigned long end)
+vm_map_remove(struct vm_map *map, uintptr_t start, uintptr_t end)
{
struct vm_map_entry *entry;
struct list *node;
@@ -696,7 +695,7 @@ out:
static void
vm_map_init(struct vm_map *map, struct pmap *pmap,
- unsigned long start, unsigned long end)
+ uintptr_t start, uintptr_t end)
{
assert(vm_page_aligned(start));
assert(vm_page_aligned(end));
@@ -772,7 +771,8 @@ vm_map_info(struct vm_map *map)
printk("vm_map: %s: %016lx-%016lx\n"
"vm_map: start end "
- "size offset flags type\n", name, map->start, map->end);
+ "size offset flags type\n", name,
+ (unsigned long)map->start, (unsigned long)map->end);
list_for_each_entry(&map->entry_list, entry, list_node) {
if (entry->object == NULL) {
@@ -781,9 +781,10 @@ vm_map_info(struct vm_map *map)
type = "object";
}
- printk("vm_map: %016lx %016lx %8luk %08llx %08x %s\n", entry->start,
- entry->end, (entry->end - entry->start) >> 10, entry->offset,
- entry->flags, type);
+ printk("vm_map: %016lx %016lx %8luk %08llx %08x %s\n",
+ (unsigned long)entry->start, (unsigned long)entry->end,
+ (unsigned long)(entry->end - entry->start) >> 10,
+ entry->offset, entry->flags, type);
}
printk("vm_map: total: %zuk\n", map->size >> 10);
diff --git a/vm/vm_map.h b/vm/vm_map.h
index 02667bd5..e4d47301 100644
--- a/vm/vm_map.h
+++ b/vm/vm_map.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011-2014 Richard Braun.
+ * Copyright (c) 2011-2017 Richard Braun.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -66,8 +66,8 @@
struct vm_map_entry {
struct list list_node;
struct rbtree_node tree_node;
- unsigned long start;
- unsigned long end;
+ uintptr_t start;
+ uintptr_t end;
struct vm_object *object;
uint64_t offset;
int flags;
@@ -81,11 +81,11 @@ struct vm_map {
struct list entry_list;
struct rbtree entry_tree;
unsigned int nr_entries;
- unsigned long start;
- unsigned long end;
+ uintptr_t start;
+ uintptr_t end;
size_t size;
struct vm_map_entry *lookup_cache;
- unsigned long find_cache;
+ uintptr_t find_cache;
size_t find_cache_threshold;
struct pmap *pmap;
};
@@ -93,14 +93,14 @@ struct vm_map {
/*
* Create a virtual mapping.
*/
-int vm_map_enter(struct vm_map *map, unsigned long *startp,
+int vm_map_enter(struct vm_map *map, uintptr_t *startp,
size_t size, size_t align, int flags,
struct vm_object *object, uint64_t offset);
/*
* Remove mappings from start to end.
*/
-void vm_map_remove(struct vm_map *map, unsigned long start, unsigned long end);
+void vm_map_remove(struct vm_map *map, uintptr_t start, uintptr_t end);
/*
* Set up the vm_map module.
diff --git a/vm/vm_page.c b/vm/vm_page.c
index 19f74a40..d1d6349c 100644
--- a/vm/vm_page.c
+++ b/vm/vm_page.c
@@ -41,6 +41,7 @@
#include <kern/printk.h>
#include <kern/sprintf.h>
#include <kern/stddef.h>
+#include <kern/stdint.h>
#include <kern/string.h>
#include <kern/thread.h>
#include <kern/types.h>
@@ -647,7 +648,7 @@ vm_page_setup(void)
struct vm_page_zone *zone;
struct vm_page *table, *page, *end;
size_t nr_pages, table_size;
- unsigned long va;
+ uintptr_t va;
unsigned int i;
phys_addr_t pa;
@@ -666,7 +667,7 @@ vm_page_setup(void)
printk("vm_page: page table size: %zu entries (%zuk)\n", nr_pages,
table_size >> 10);
table = vm_page_bootalloc(table_size);
- va = (unsigned long)table;
+ va = (uintptr_t)table;
/*
* Initialize the zones, associating them to the page table. When
@@ -691,7 +692,7 @@ vm_page_setup(void)
table += vm_page_atop(vm_page_zone_size(zone));
}
- while (va < (unsigned long)table) {
+ while (va < (uintptr_t)table) {
pa = vm_page_direct_pa(va);
page = vm_page_lookup(pa);
assert((page != NULL) && (page->type == VM_PAGE_RESERVED));
diff --git a/vm/vm_page.h b/vm/vm_page.h
index f2011b40..71fb43a1 100644
--- a/vm/vm_page.h
+++ b/vm/vm_page.h
@@ -27,6 +27,7 @@
#include <kern/macros.h>
#include <kern/param.h>
#include <kern/stddef.h>
+#include <kern/stdint.h>
#include <kern/types.h>
#include <machine/pmap.h>
@@ -100,15 +101,15 @@ vm_page_to_pa(const struct vm_page *page)
return page->phys_addr;
}
-static inline unsigned long
+static inline uintptr_t
vm_page_direct_va(phys_addr_t pa)
{
assert(pa < VM_PAGE_DIRECTMAP_LIMIT);
- return ((unsigned long)pa + VM_MIN_DIRECTMAP_ADDRESS);
+ return ((uintptr_t)pa + VM_MIN_DIRECTMAP_ADDRESS);
}
static inline phys_addr_t
-vm_page_direct_pa(unsigned long va)
+vm_page_direct_pa(uintptr_t va)
{
assert(va >= VM_MIN_DIRECTMAP_ADDRESS);
assert(va < VM_MAX_DIRECTMAP_ADDRESS);