summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2017-01-13 00:16:09 +0100
committerRichard Braun <rbraun@sceen.net>2017-01-13 00:16:09 +0100
commitcf59c5fa63b4639777fbe28fba79cfbd63fa6d4e (patch)
tree6cd4b64fc94f7cc9c2c1f75ba298169a88248657
parent27e9a04a0a07707d7a85dc65198b4ab8f32888f6 (diff)
Replace unsigned long with uintptr_t for integer/pointer conversions
This is mostly done for the machine-independent part.
-rw-r--r--arch/x86/machine/acpimp.c8
-rw-r--r--arch/x86/machine/boot.c20
-rw-r--r--arch/x86/machine/cpu.c2
-rw-r--r--arch/x86/machine/pmap.c73
-rw-r--r--arch/x86/machine/pmap.h8
-rw-r--r--arch/x86/machine/strace.c14
-rw-r--r--kern/kmem.c30
-rw-r--r--kern/percpu.c7
-rw-r--r--kern/percpu.h5
-rw-r--r--kern/rbtree.c7
-rw-r--r--kern/rbtree.h15
-rw-r--r--kern/rbtree_i.h21
-rw-r--r--kern/sprintf.c2
-rw-r--r--kern/sref.c12
-rw-r--r--kern/stdint.h4
-rw-r--r--test/test_vm_page_fill.c5
-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
22 files changed, 180 insertions, 162 deletions
diff --git a/arch/x86/machine/acpimp.c b/arch/x86/machine/acpimp.c
index b294da92..e88e7650 100644
--- a/arch/x86/machine/acpimp.c
+++ b/arch/x86/machine/acpimp.c
@@ -252,7 +252,7 @@ static int __init
acpimp_get_rsdp(phys_addr_t start, size_t size, struct acpimp_rsdp *rsdp)
{
const struct acpimp_rsdp *src;
- unsigned long addr, end, map_addr;
+ uintptr_t addr, end, map_addr;
size_t map_size;
int error;
@@ -263,7 +263,7 @@ acpimp_get_rsdp(phys_addr_t start, size_t size, struct acpimp_rsdp *rsdp)
return -1;
}
- addr = (unsigned long)vm_kmem_map_pa(start, size, &map_addr, &map_size);
+ addr = (uintptr_t)vm_kmem_map_pa(start, size, &map_addr, &map_size);
if (addr == 0) {
panic("acpimp: unable to map bios memory in kernel map");
@@ -295,7 +295,7 @@ static int __init
acpimp_find_rsdp(struct acpimp_rsdp *rsdp)
{
const uint16_t *ptr;
- unsigned long base, map_addr;
+ uintptr_t base, map_addr;
size_t map_size;
int error;
@@ -344,7 +344,7 @@ acpimp_copy_table(uint32_t addr)
{
const struct acpimp_sdth *table;
struct acpimp_sdth *copy;
- unsigned long map_addr;
+ uintptr_t map_addr;
size_t size, map_size;
unsigned int checksum;
diff --git a/arch/x86/machine/boot.c b/arch/x86/machine/boot.c
index d5359755..d26e3dc4 100644
--- a/arch/x86/machine/boot.c
+++ b/arch/x86/machine/boot.c
@@ -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
@@ -188,17 +188,17 @@ boot_save_cmdline_sizes(struct multiboot_raw_info *mbi)
uint32_t i;
if (mbi->flags & MULTIBOOT_LOADER_CMDLINE) {
- mbi->unused0 = boot_strlen((char *)(unsigned long)mbi->cmdline) + 1;
+ mbi->unused0 = boot_strlen((char *)(uintptr_t)mbi->cmdline) + 1;
}
if (mbi->flags & MULTIBOOT_LOADER_MODULES) {
- unsigned long addr;
+ uintptr_t addr;
addr = mbi->mods_addr;
for (i = 0; i < mbi->mods_count; i++) {
mod = (struct multiboot_raw_module *)addr + i;
- mod->reserved = boot_strlen((char *)(unsigned long)mod->string) + 1;
+ mod->reserved = boot_strlen((char *)(uintptr_t)mod->string) + 1;
}
}
}
@@ -208,11 +208,11 @@ boot_register_data(const struct multiboot_raw_info *mbi)
{
struct multiboot_raw_module *mod;
struct elf_shdr *shdr;
- unsigned long tmp;
+ uintptr_t tmp;
unsigned int i;
- biosmem_register_boot_data((unsigned long)&_boot,
- BOOT_VTOP((unsigned long)&_end), false);
+ biosmem_register_boot_data((uintptr_t)&_boot,
+ BOOT_VTOP((uintptr_t)&_end), false);
if ((mbi->flags & MULTIBOOT_LOADER_CMDLINE) && (mbi->cmdline != 0)) {
biosmem_register_boot_data(mbi->cmdline, mbi->cmdline + mbi->unused0, true);
@@ -298,7 +298,7 @@ boot_show_version(void)
static void * __init
boot_save_memory(uint32_t addr, size_t size)
{
- unsigned long map_addr;
+ uintptr_t map_addr;
size_t map_size;
const void *src;
void *copy;
@@ -329,7 +329,7 @@ static void __init
boot_save_mod(struct multiboot_module *dest_mod,
const struct multiboot_raw_module *src_mod)
{
- unsigned long map_addr;
+ uintptr_t map_addr;
size_t size, map_size;
const void *src;
void *copy;
@@ -365,7 +365,7 @@ boot_save_mods(void)
{
const struct multiboot_raw_module *src;
struct multiboot_module *dest;
- unsigned long map_addr;
+ uintptr_t map_addr;
size_t size, map_size;
uint32_t i;
diff --git a/arch/x86/machine/cpu.c b/arch/x86/machine/cpu.c
index 0f9ad343..5fc21315 100644
--- a/arch/x86/machine/cpu.c
+++ b/arch/x86/machine/cpu.c
@@ -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
diff --git a/arch/x86/machine/pmap.c b/arch/x86/machine/pmap.c
index 975c61b3..0031f7c1 100644
--- a/arch/x86/machine/pmap.c
+++ b/arch/x86/machine/pmap.c
@@ -139,20 +139,20 @@ static pmap_pte_t pmap_prot_table[VM_PROT_ALL + 1] __read_mostly;
#define PMAP_UPDATE_OP_PROTECT 3
struct pmap_update_enter_args {
- unsigned long va;
+ uintptr_t va;
phys_addr_t pa;
int prot;
int flags;
};
struct pmap_update_remove_args {
- unsigned long start;
- unsigned long end;
+ uintptr_t start;
+ uintptr_t end;
};
struct pmap_update_protect_args {
- unsigned long start;
- unsigned long end;
+ uintptr_t start;
+ uintptr_t end;
int prot;
};
@@ -283,13 +283,13 @@ static char pmap_panic_directmap_msg[] __bootdata
= "pmap: invalid direct physical mapping";
static __always_inline unsigned long
-pmap_pte_index(unsigned long va, const struct pmap_pt_level *pt_level)
+pmap_pte_index(uintptr_t va, const struct pmap_pt_level *pt_level)
{
return ((va >> pt_level->skip) & ((1UL << pt_level->bits) - 1));
}
static void __boot
-pmap_boot_enter(pmap_pte_t *root_ptp, unsigned long va, phys_addr_t pa,
+pmap_boot_enter(pmap_pte_t *root_ptp, uintptr_t va, phys_addr_t pa,
unsigned long pgsize)
{
const struct pmap_pt_level *pt_level, *pt_levels;
@@ -316,7 +316,7 @@ pmap_boot_enter(pmap_pte_t *root_ptp, unsigned long va, phys_addr_t pa,
last_level = 0;
}
- pt_levels = (void *)BOOT_VTOP((unsigned long)pmap_pt_levels);
+ pt_levels = (void *)BOOT_VTOP((uintptr_t)pmap_pt_levels);
pt = root_ptp;
for (level = PMAP_NR_LEVELS - 1; level != last_level; level--) {
@@ -324,10 +324,10 @@ pmap_boot_enter(pmap_pte_t *root_ptp, unsigned long va, phys_addr_t pa,
pte = &pt[pmap_pte_index(va, pt_level)];
if (*pte != 0) {
- ptp = (void *)(unsigned long)(*pte & PMAP_PA_MASK);
+ ptp = (void *)(uintptr_t)(*pte & PMAP_PA_MASK);
} else {
ptp = biosmem_bootalloc(1);
- *pte = ((unsigned long)ptp | PMAP_PTE_RW | PMAP_PTE_P)
+ *pte = ((uintptr_t)ptp | PMAP_PTE_RW | PMAP_PTE_P)
& pt_level->mask;
}
@@ -417,8 +417,9 @@ pmap_setup_paging(void)
{
struct pmap_cpu_table *cpu_table;
phys_addr_t pa, directmap_end;
- unsigned long i, va, size, pgsize;
+ unsigned long i, size, pgsize;
pmap_pte_t *root_ptp;
+ uintptr_t va;
/* Use large pages for the direct physical mapping when possible */
pgsize = pmap_boot_get_pgsize();
@@ -431,14 +432,14 @@ pmap_setup_paging(void)
*/
#ifdef X86_PAE
- root_ptp = (void *)BOOT_VTOP((unsigned long)pmap_cpu_kpdpts[0]);
+ root_ptp = (void *)BOOT_VTOP((uintptr_t)pmap_cpu_kpdpts[0]);
#else /* X86_PAE */
root_ptp = biosmem_bootalloc(1);
#endif /* X86_PAE */
- va = vm_page_trunc((unsigned long)&_boot);
+ va = vm_page_trunc((uintptr_t)&_boot);
pa = va;
- size = vm_page_round((unsigned long)&_eboot) - va;
+ size = vm_page_round((uintptr_t)&_eboot) - va;
for (i = 0; i < size; i += PAGE_SIZE) {
pmap_boot_enter(root_ptp, va, pa, PAGE_SIZE);
@@ -467,9 +468,9 @@ pmap_setup_paging(void)
* in the direct mapping, which requires the creation of an additional
* mapping for it. See param.h for more details.
*/
- va = P2ALIGN((unsigned long)&_init, pgsize);
+ va = P2ALIGN((uintptr_t)&_init, pgsize);
pa = BOOT_VTOP(va);
- size = vm_page_round((unsigned long)&_end) - va;
+ size = vm_page_round((uintptr_t)&_end) - va;
for (i = 0; i < size; i += pgsize) {
pmap_boot_enter(root_ptp, va, pa, pgsize);
@@ -478,8 +479,8 @@ pmap_setup_paging(void)
}
#endif /* __LP64__ */
- cpu_table = (void *)BOOT_VTOP((unsigned long)&kernel_pmap_cpu_tables[0]);
- cpu_table->root_ptp_pa = (unsigned long)root_ptp;
+ cpu_table = (void *)BOOT_VTOP((uintptr_t)&kernel_pmap_cpu_tables[0]);
+ cpu_table->root_ptp_pa = (uintptr_t)root_ptp;
return root_ptp;
}
@@ -494,8 +495,8 @@ pmap_ap_setup_paging(void)
pgsize = pmap_boot_get_pgsize();
pmap_boot_enable_pgext(pgsize);
- pmap = (void *)BOOT_VTOP((unsigned long)&kernel_pmap_store);
- cpu_table = (void *)BOOT_VTOP((unsigned long)pmap->cpu_tables[boot_ap_id]);
+ pmap = (void *)BOOT_VTOP((uintptr_t)&kernel_pmap_store);
+ cpu_table = (void *)BOOT_VTOP((uintptr_t)pmap->cpu_tables[boot_ap_id]);
#ifdef X86_PAE
return (void *)(uint32_t)cpu_table->root_ptp_pa;
@@ -523,7 +524,7 @@ MACRO_END
static inline pmap_pte_t *
pmap_ptp_from_pa(phys_addr_t pa)
{
- unsigned long va;
+ uintptr_t va;
va = vm_page_direct_va(pa);
return (pmap_pte_t *)va;
@@ -572,13 +573,13 @@ pmap_pte_next(pmap_pte_t pte)
* page properties.
*/
static void __init
-pmap_walk_vas(unsigned long start, unsigned long end, pmap_walk_fn_t walk_fn)
+pmap_walk_vas(uintptr_t start, uintptr_t end, pmap_walk_fn_t walk_fn)
{
const struct pmap_pt_level *pt_level;
phys_addr_t root_ptp_pa, ptp_pa;
pmap_pte_t *ptp, *pte;
unsigned int index, level;
- unsigned long va;
+ uintptr_t va;
assert(vm_page_aligned(start));
assert(start < end);
@@ -931,13 +932,13 @@ pmap_copy_cpu_table_page(const pmap_pte_t *sptp, unsigned int level,
static void __init
pmap_copy_cpu_table_recursive(const pmap_pte_t *sptp, unsigned int level,
- pmap_pte_t *dptp, unsigned long start_va)
+ pmap_pte_t *dptp, uintptr_t start_va)
{
const struct pmap_pt_level *pt_level;
struct vm_page *page;
phys_addr_t pa;
- unsigned long va;
unsigned int i;
+ uintptr_t va;
assert(level != 0);
@@ -994,7 +995,7 @@ pmap_copy_cpu_table(unsigned int cpu)
sptp = pmap_ptp_from_pa(kernel_pmap->cpu_tables[cpu_id()]->root_ptp_pa);
#ifdef X86_PAE
- cpu_table->root_ptp_pa = BOOT_VTOP((unsigned long)pmap_cpu_kpdpts[cpu]);
+ cpu_table->root_ptp_pa = BOOT_VTOP((uintptr_t)pmap_cpu_kpdpts[cpu]);
dptp = pmap_ptp_from_pa(cpu_table->root_ptp_pa);
#else /* X86_PAE */
struct vm_page *page;
@@ -1081,7 +1082,7 @@ pmap_thread_init(struct thread *thread)
}
int
-pmap_kextract(unsigned long va, phys_addr_t *pap)
+pmap_kextract(uintptr_t va, phys_addr_t *pap)
{
const struct pmap_pt_level *pt_level;
pmap_pte_t *ptp, *pte;
@@ -1131,7 +1132,7 @@ pmap_create(struct pmap **pmapp)
}
static int
-pmap_enter_local(struct pmap *pmap, unsigned long va, phys_addr_t pa,
+pmap_enter_local(struct pmap *pmap, uintptr_t va, phys_addr_t pa,
int prot, int flags)
{
const struct pmap_pt_level *pt_level;
@@ -1186,7 +1187,7 @@ pmap_enter_local(struct pmap *pmap, unsigned long va, phys_addr_t pa,
}
int
-pmap_enter(struct pmap *pmap, unsigned long va, phys_addr_t pa,
+pmap_enter(struct pmap *pmap, uintptr_t va, phys_addr_t pa,
int prot, int flags)
{
struct pmap_update_oplist *oplist;
@@ -1223,7 +1224,7 @@ pmap_enter(struct pmap *pmap, unsigned long va, phys_addr_t pa,
}
static void
-pmap_remove_local_single(struct pmap *pmap, unsigned long va)
+pmap_remove_local_single(struct pmap *pmap, uintptr_t va)
{
const struct pmap_pt_level *pt_level;
pmap_pte_t *ptp, *pte;
@@ -1252,7 +1253,7 @@ pmap_remove_local_single(struct pmap *pmap, unsigned long va)
}
static void
-pmap_remove_local(struct pmap *pmap, unsigned long start, unsigned long end)
+pmap_remove_local(struct pmap *pmap, uintptr_t start, uintptr_t end)
{
while (start < end) {
pmap_remove_local_single(pmap, start);
@@ -1261,7 +1262,7 @@ pmap_remove_local(struct pmap *pmap, unsigned long start, unsigned long end)
}
int
-pmap_remove(struct pmap *pmap, unsigned long va, const struct cpumap *cpumap)
+pmap_remove(struct pmap *pmap, uintptr_t va, const struct cpumap *cpumap)
{
struct pmap_update_oplist *oplist;
struct pmap_update_op *op;
@@ -1298,8 +1299,8 @@ pmap_remove(struct pmap *pmap, unsigned long va, const struct cpumap *cpumap)
}
static void
-pmap_protect_local(struct pmap *pmap, unsigned long start,
- unsigned long end, int prot)
+pmap_protect_local(struct pmap *pmap, uintptr_t start,
+ uintptr_t end, int prot)
{
(void)pmap;
(void)start;
@@ -1311,7 +1312,7 @@ pmap_protect_local(struct pmap *pmap, unsigned long start,
}
int
-pmap_protect(struct pmap *pmap, unsigned long va, int prot,
+pmap_protect(struct pmap *pmap, uintptr_t va, int prot,
const struct cpumap *cpumap)
{
struct pmap_update_oplist *oplist;
@@ -1351,7 +1352,7 @@ pmap_protect(struct pmap *pmap, unsigned long va, int prot,
}
static void
-pmap_flush_tlb(struct pmap *pmap, unsigned long start, unsigned long end)
+pmap_flush_tlb(struct pmap *pmap, uintptr_t start, uintptr_t end)
{
if ((pmap != pmap_current()) && (pmap != kernel_pmap)) {
return;
diff --git a/arch/x86/machine/pmap.h b/arch/x86/machine/pmap.h
index a0565d69..a344d5ee 100644
--- a/arch/x86/machine/pmap.h
+++ b/arch/x86/machine/pmap.h
@@ -177,7 +177,7 @@ int pmap_thread_init(struct thread *thread);
* This function walks the page tables to retrieve the physical address
* mapped at the given virtual address.
*/
-int pmap_kextract(unsigned long va, phys_addr_t *pap);
+int pmap_kextract(uintptr_t va, phys_addr_t *pap);
/*
* Create a pmap for a user task.
@@ -196,7 +196,7 @@ int pmap_create(struct pmap **pmapp);
*
* This function may trigger an implicit update.
*/
-int pmap_enter(struct pmap *pmap, unsigned long va, phys_addr_t pa,
+int pmap_enter(struct pmap *pmap, uintptr_t va, phys_addr_t pa,
int prot, int flags);
/*
@@ -206,7 +206,7 @@ int pmap_enter(struct pmap *pmap, unsigned long va, phys_addr_t pa,
*
* This function may trigger an implicit update.
*/
-int pmap_remove(struct pmap *pmap, unsigned long va,
+int pmap_remove(struct pmap *pmap, uintptr_t va,
const struct cpumap *cpumap);
/*
@@ -214,7 +214,7 @@ int pmap_remove(struct pmap *pmap, unsigned long va,
*
* This function may trigger an implicit update.
*/
-int pmap_protect(struct pmap *pmap, unsigned long va, int prot,
+int pmap_protect(struct pmap *pmap, uintptr_t va, int prot,
const struct cpumap *cpumap);
/*
diff --git a/arch/x86/machine/strace.c b/arch/x86/machine/strace.c
index 42af6b20..7906cb0d 100644
--- a/arch/x86/machine/strace.c
+++ b/arch/x86/machine/strace.c
@@ -39,7 +39,7 @@ static struct elf_sym *strace_symtab_end __read_mostly;
static char *strace_strtab __read_mostly;
static const char *
-strace_lookup(unsigned long addr, unsigned long *offset, unsigned long *size)
+strace_lookup(uintptr_t addr, uintptr_t *offset, uintptr_t *size)
{
struct elf_sym *sym;
@@ -67,7 +67,7 @@ strace_lookup(unsigned long addr, unsigned long *offset, unsigned long *size)
static void
strace_show_one(unsigned int index, unsigned long ip)
{
- unsigned long offset, size;
+ uintptr_t offset, size;
const char *name;
name = strace_lookup(ip, &offset, &size);
@@ -76,7 +76,7 @@ strace_show_one(unsigned int index, unsigned long ip)
printk("strace: #%u [" STRACE_ADDR_FORMAT "]\n", index, ip);
} else
printk("strace: #%u [" STRACE_ADDR_FORMAT "] %s+%#lx/%#lx\n",
- index, ip, name, offset, size);
+ index, ip, name, (unsigned long)offset, (unsigned long)size);
}
void
@@ -98,7 +98,7 @@ strace_show(unsigned long ip, unsigned long bp)
break;
}
- error = pmap_kextract((unsigned long)&frame[1], &pa);
+ error = pmap_kextract((uintptr_t)&frame[1], &pa);
if (error) {
printk("strace: unmapped return address at %p\n", &frame[1]);
@@ -106,7 +106,7 @@ strace_show(unsigned long ip, unsigned long bp)
}
strace_show_one(i, (unsigned long)frame[1]);
- error = pmap_kextract((unsigned long)frame, &pa);
+ error = pmap_kextract((uintptr_t)frame, &pa);
if (error) {
printk("strace: unmapped frame address at %p\n", frame);
@@ -123,7 +123,7 @@ strace_show(unsigned long ip, unsigned long bp)
static void * __init
strace_copy_section(const struct elf_shdr *shdr)
{
- unsigned long map_addr;
+ uintptr_t map_addr;
size_t map_size;
const void *src;
void *copy;
@@ -176,7 +176,7 @@ void __init
strace_setup(const struct multiboot_raw_info *mbi)
{
const struct elf_shdr *shstrtab_hdr, *symtab_hdr, *strtab_hdr;
- unsigned long map_addr, shstrtab_map_addr;
+ uintptr_t map_addr, shstrtab_map_addr;
size_t size, map_size, shstrtab_map_size;
const char *shstrtab;
const void *table;
diff --git a/kern/kmem.c b/kern/kmem.c
index 0f3b4962..8d3ce49a 100644
--- a/kern/kmem.c
+++ b/kern/kmem.c
@@ -181,7 +181,7 @@ kmem_buf_fill(void *buf, uint64_t pattern, size_t size)
{
uint64_t *ptr, *end;
- assert(P2ALIGNED((unsigned long)buf, sizeof(uint64_t)));
+ assert(P2ALIGNED((uintptr_t)buf, sizeof(uint64_t)));
assert(P2ALIGNED(size, sizeof(uint64_t)));
end = buf + size;
@@ -196,7 +196,7 @@ kmem_buf_verify_fill(void *buf, uint64_t old, uint64_t new, size_t size)
{
uint64_t *ptr, *end;
- assert(P2ALIGNED((unsigned long)buf, sizeof(uint64_t)));
+ assert(P2ALIGNED((uintptr_t)buf, sizeof(uint64_t)));
assert(P2ALIGNED(size, sizeof(uint64_t)));
end = buf + size;
@@ -263,7 +263,7 @@ kmem_pagefree(void *ptr, size_t size)
} else {
struct vm_page *page;
- page = vm_page_lookup(vm_page_direct_pa((unsigned long)ptr));
+ page = vm_page_lookup(vm_page_direct_pa((uintptr_t)ptr));
assert(page != NULL);
vm_page_free(page, vm_page_order(size));
}
@@ -341,10 +341,10 @@ kmem_slab_create(struct kmem_cache *cache, size_t color)
return slab;
}
-static inline unsigned long
+static inline uintptr_t
kmem_slab_buf(const struct kmem_slab *slab)
{
- return P2ALIGN((unsigned long)slab->addr, PAGE_SIZE);
+ return P2ALIGN((uintptr_t)slab->addr, PAGE_SIZE);
}
static void
@@ -628,7 +628,7 @@ kmem_cache_buf_to_slab(const struct kmem_cache *cache, void *buf)
return NULL;
}
- return (struct kmem_slab *)vm_page_end((unsigned long)buf) - 1;
+ return (struct kmem_slab *)vm_page_end((uintptr_t)buf) - 1;
}
static inline bool
@@ -643,7 +643,7 @@ static void
kmem_cache_register(struct kmem_cache *cache, struct kmem_slab *slab)
{
struct vm_page *page;
- unsigned long va, end;
+ uintptr_t va, end;
phys_addr_t pa;
bool virtual;
int error;
@@ -677,7 +677,7 @@ kmem_cache_lookup(struct kmem_cache *cache, void *buf)
{
struct kmem_slab *slab;
struct vm_page *page;
- unsigned long va;
+ uintptr_t va;
phys_addr_t pa;
bool virtual;
int error;
@@ -685,7 +685,7 @@ kmem_cache_lookup(struct kmem_cache *cache, void *buf)
assert(kmem_cache_registration_required(cache));
virtual = kmem_pagealloc_virtual(cache->slab_size);
- va = (unsigned long)buf;
+ va = (uintptr_t)buf;
if (virtual) {
error = pmap_kextract(va, &pa);
@@ -709,8 +709,8 @@ kmem_cache_lookup(struct kmem_cache *cache, void *buf)
}
slab = vm_page_get_priv(page);
- assert((unsigned long)buf >= kmem_slab_buf(slab));
- assert((unsigned long)buf < (kmem_slab_buf(slab) + cache->slab_size));
+ assert((uintptr_t)buf >= kmem_slab_buf(slab));
+ assert((uintptr_t)buf < (kmem_slab_buf(slab) + cache->slab_size));
return slab;
}
@@ -965,7 +965,7 @@ kmem_cache_free_verify(struct kmem_cache *cache, void *buf)
struct kmem_slab *slab;
union kmem_bufctl *bufctl;
unsigned char *redzone_byte;
- unsigned long slabend;
+ uintptr_t slabend;
slab = kmem_cache_lookup(cache, buf);
@@ -973,13 +973,13 @@ kmem_cache_free_verify(struct kmem_cache *cache, void *buf)
kmem_cache_error(cache, buf, KMEM_ERR_INVALID, NULL);
}
- slabend = P2ALIGN((unsigned long)slab->addr + cache->slab_size, PAGE_SIZE);
+ slabend = P2ALIGN((uintptr_t)slab->addr + cache->slab_size, PAGE_SIZE);
- if ((unsigned long)buf >= slabend) {
+ if ((uintptr_t)buf >= slabend) {
kmem_cache_error(cache, buf, KMEM_ERR_INVALID, NULL);
}
- if ((((unsigned long)buf - (unsigned long)slab->addr) % cache->buf_size)
+ if ((((uintptr_t)buf - (uintptr_t)slab->addr) % cache->buf_size)
!= 0) {
kmem_cache_error(cache, buf, KMEM_ERR_INVALID, NULL);
}
diff --git a/kern/percpu.c b/kern/percpu.c
index 5b9690cc..ab7b4fb6 100644
--- a/kern/percpu.c
+++ b/kern/percpu.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014 Richard Braun.
+ * Copyright (c) 2014-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
@@ -24,6 +24,7 @@
#include <kern/percpu.h>
#include <kern/printk.h>
#include <kern/stddef.h>
+#include <kern/stdint.h>
#include <kern/string.h>
#include <machine/cpu.h>
#include <vm/vm_kmem.h>
@@ -111,9 +112,9 @@ void
percpu_cleanup(void)
{
struct vm_page *page;
- unsigned long va;
+ uintptr_t va;
- va = (unsigned long)percpu_area_content;
+ va = (uintptr_t)percpu_area_content;
page = vm_page_lookup(vm_page_direct_pa(va));
vm_page_free(page, vm_page_order(percpu_area_size));
}
diff --git a/kern/percpu.h b/kern/percpu.h
index 820fed63..a9d1eb3b 100644
--- a/kern/percpu.h
+++ b/kern/percpu.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014 Richard Braun.
+ * Copyright (c) 2014-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
@@ -55,6 +55,7 @@
#include <kern/assert.h>
#include <kern/macros.h>
+#include <kern/stdint.h>
#define PERCPU_SECTION .percpu
#define __percpu __section(QUOTE(PERCPU_SECTION))
@@ -72,7 +73,7 @@ extern char _epercpu;
* Expands to the address of a percpu variable.
*/
#define percpu_ptr(var, cpu) \
- ((typeof(var) *)(percpu_area(cpu) + ((unsigned long)(&(var)))))
+ ((typeof(var) *)(percpu_area(cpu) + ((uintptr_t)(&(var)))))
/*
* Expands to the lvalue of a percpu variable.
diff --git a/kern/rbtree.c b/kern/rbtree.c
index 49cb097f..0d0a844c 100644
--- a/kern/rbtree.c
+++ b/kern/rbtree.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2012 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
@@ -20,6 +20,7 @@
#include <kern/rbtree.h>
#include <kern/rbtree_i.h>
#include <kern/stddef.h>
+#include <kern/stdint.h>
/*
* Return the index of a node in the children array of its parent.
@@ -79,7 +80,7 @@ rbtree_node_set_parent(struct rbtree_node *node, struct rbtree_node *parent)
assert(rbtree_node_check_alignment(node));
assert(rbtree_node_check_alignment(parent));
- node->parent = (unsigned long)parent | (node->parent & RBTREE_COLOR_MASK);
+ node->parent = (uintptr_t)parent | (node->parent & RBTREE_COLOR_MASK);
}
/*
@@ -179,7 +180,7 @@ rbtree_insert_rebalance(struct rbtree *tree, struct rbtree_node *parent,
assert(rbtree_node_check_alignment(parent));
assert(rbtree_node_check_alignment(node));
- node->parent = (unsigned long)parent | RBTREE_COLOR_RED;
+ node->parent = (uintptr_t)parent | RBTREE_COLOR_RED;
node->children[RBTREE_LEFT] = NULL;
node->children[RBTREE_RIGHT] = NULL;
diff --git a/kern/rbtree.h b/kern/rbtree.h
index 0e552b44..dd17e956 100644
--- a/kern/rbtree.h
+++ b/kern/rbtree.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2011, 2012 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
@@ -24,6 +24,7 @@
#include <kern/assert.h>
#include <kern/macros.h>
#include <kern/stddef.h>
+#include <kern/stdint.h>
/*
* Indexes of the left and right nodes in the children array of a node.
@@ -41,6 +42,11 @@ struct rbtree_node;
*/
struct rbtree;
+/*
+ * Insertion point identifier.
+ */
+typedef uintptr_t rbtree_slot_t;
+
#include <kern/rbtree_i.h>
/*
@@ -62,7 +68,7 @@ rbtree_node_init(struct rbtree_node *node)
{
assert(rbtree_node_check_alignment(node));
- node->parent = (unsigned long)node | RBTREE_COLOR_RED;
+ node->parent = (uintptr_t)node | RBTREE_COLOR_RED;
node->children[RBTREE_LEFT] = NULL;
node->children[RBTREE_RIGHT] = NULL;
}
@@ -200,8 +206,7 @@ MACRO_END
* This macro essentially acts as rbtree_lookup() but in addition to a node,
* it also returns a slot, which identifies an insertion point in the tree.
* If the returned node is null, the slot can be used by rbtree_insert_slot()
- * to insert without the overhead of an additional lookup. The slot is a
- * simple unsigned long integer.
+ * to insert without the overhead of an additional lookup.
*
* The constraints that apply to the key parameter are the same as for
* rbtree_lookup().
@@ -240,7 +245,7 @@ MACRO_END
* must denote a null node).
*/
static inline void
-rbtree_insert_slot(struct rbtree *tree, unsigned long slot,
+rbtree_insert_slot(struct rbtree *tree, rbtree_slot_t slot,
struct rbtree_node *node)
{
struct rbtree_node *parent;
diff --git a/kern/rbtree_i.h b/kern/rbtree_i.h
index 7f9650e7..f788e830 100644
--- a/kern/rbtree_i.h
+++ b/kern/rbtree_i.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2011, 2012 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
@@ -21,6 +21,7 @@
#include <kern/assert.h>
#include <kern/macros.h>
#include <kern/stddef.h>
+#include <kern/stdint.h>
/*
* Red-black node structure.
@@ -37,7 +38,7 @@
* special alignment constraints such as member packing.
*/
struct rbtree_node {
- unsigned long parent;
+ uintptr_t parent;
struct rbtree_node *children[2];
};
@@ -52,8 +53,8 @@ struct rbtree {
* Masks applied on the parent member of a node to obtain either the
* color or the parent address.
*/
-#define RBTREE_COLOR_MASK 0x1UL
-#define RBTREE_PARENT_MASK (~0x3UL)
+#define RBTREE_COLOR_MASK ((uintptr_t)1)
+#define RBTREE_PARENT_MASK (~(uintptr_t)0x3)
/*
* Node colors.
@@ -65,7 +66,7 @@ struct rbtree {
* Masks applied on slots to obtain either the child index or the parent
* address.
*/
-#define RBTREE_SLOT_INDEX_MASK 0x1UL
+#define RBTREE_SLOT_INDEX_MASK ((uintptr_t)0x1)
#define RBTREE_SLOT_PARENT_MASK (~RBTREE_SLOT_INDEX_MASK)
/*
@@ -95,7 +96,7 @@ rbtree_d2i(int diff)
static inline int
rbtree_node_check_alignment(const struct rbtree_node *node)
{
- return ((unsigned long)node & (~RBTREE_PARENT_MASK)) == 0;
+ return ((uintptr_t)node & (~RBTREE_PARENT_MASK)) == 0;
}
/*
@@ -110,19 +111,19 @@ rbtree_node_parent(const struct rbtree_node *node)
/*
* Translate an insertion point into a slot.
*/
-static inline unsigned long
+static inline rbtree_slot_t
rbtree_slot(struct rbtree_node *parent, int index)
{
assert(rbtree_node_check_alignment(parent));
assert(rbtree_check_index(index));
- return (unsigned long)parent | index;
+ return (rbtree_slot_t)parent | index;
}
/*
* Extract the parent address from a slot.
*/
static inline struct rbtree_node *
-rbtree_slot_parent(unsigned long slot)
+rbtree_slot_parent(rbtree_slot_t slot)
{
return (struct rbtree_node *)(slot & RBTREE_SLOT_PARENT_MASK);
}
@@ -131,7 +132,7 @@ rbtree_slot_parent(unsigned long slot)
* Extract the index from a slot.
*/
static inline int
-rbtree_slot_index(unsigned long slot)
+rbtree_slot_index(rbtree_slot_t slot)
{
return slot & RBTREE_SLOT_INDEX_MASK;
}
diff --git a/kern/sprintf.c b/kern/sprintf.c
index 7117dbed..386d9d3c 100644
--- a/kern/sprintf.c
+++ b/kern/sprintf.c
@@ -340,7 +340,7 @@ integer:
}
break;
case SPRINTF_MODIFIER_PTR:
- n = (unsigned long)va_arg(ap, void *);
+ n = (uintptr_t)va_arg(ap, void *);
break;
case SPRINTF_MODIFIER_SIZE:
if (flags & SPRINTF_FORMAT_CONV_SIGNED) {
diff --git a/kern/sref.c b/kern/sref.c
index 528eb226..a9253dc7 100644
--- a/kern/sref.c
+++ b/kern/sref.c
@@ -240,18 +240,18 @@ sref_queue_concat(struct sref_queue *queue1, struct sref_queue *queue2)
queue1->size += queue2->size;
}
-static inline unsigned long
+static inline uintptr_t
sref_counter_hash(const struct sref_counter *counter)
{
- unsigned long va;
+ uintptr_t va;
- va = (unsigned long)counter;
+ va = (uintptr_t)counter;
assert(P2ALIGNED(va, 1UL << SREF_HASH_SHIFT));
return (va >> SREF_HASH_SHIFT);
}
-static inline unsigned long
+static inline uintptr_t
sref_counter_index(const struct sref_counter *counter)
{
return (sref_counter_hash(counter) & (SREF_MAX_DELTAS - 1));
@@ -430,7 +430,7 @@ sref_end_epoch(struct sref_queue *queue)
}
static inline struct sref_delta *
-sref_cache_delta(struct sref_cache *cache, unsigned int i)
+sref_cache_delta(struct sref_cache *cache, unsigned long i)
{
assert(i < ARRAY_SIZE(cache->deltas));
return &cache->deltas[i];
@@ -441,7 +441,7 @@ sref_cache_init(struct sref_cache *cache, unsigned int cpu)
{
char name[EVCNT_NAME_SIZE];
struct sref_delta *delta;
- unsigned int i;
+ unsigned long i;
mutex_init(&cache->lock);
diff --git a/kern/stdint.h b/kern/stdint.h
index d6794c4e..7aac9170 100644
--- a/kern/stdint.h
+++ b/kern/stdint.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2011 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
@@ -18,6 +18,8 @@
#ifndef _KERN_STDINT_H
#define _KERN_STDINT_H
+typedef unsigned long uintptr_t;
+
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
diff --git a/test/test_vm_page_fill.c b/test/test_vm_page_fill.c
index dc25ba8a..d20fd8ae 100644
--- a/test/test_vm_page_fill.c
+++ b/test/test_vm_page_fill.c
@@ -26,6 +26,7 @@
#include <kern/error.h>
#include <kern/list.h>
#include <kern/stddef.h>
+#include <kern/stdint.h>
#include <kern/thread.h>
#include <machine/pmap.h>
#include <test/test.h>
@@ -42,8 +43,8 @@ static void
test_write_pages(void)
{
struct vm_page *page;
- unsigned long va;
int error, flags;
+ uintptr_t va;
for (;;) {
page = vm_page_alloc(0, VM_PAGE_SEL_HIGHMEM, VM_PAGE_KERNEL);
@@ -77,8 +78,8 @@ static void
test_reset_pages(void)
{
struct vm_page *page;
- unsigned long va;
int error, flags;
+ uintptr_t va;
while (!list_empty(&test_pages)) {
page = list_first_entry(&test_pages, struct vm_page, node);
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);