aboutsummaryrefslogtreecommitdiff
path: root/kernel/include
diff options
context:
space:
mode:
authorAlex Auvolat <alex.auvolat@ens.fr>2014-12-05 15:06:17 +0100
committerAlex Auvolat <alex.auvolat@ens.fr>2014-12-05 15:06:17 +0100
commit274765f7daa3cc1094f9f26196fcf2b9a5289ee2 (patch)
tree974b59905b942ded566c5f9c2d512472646288fc /kernel/include
parent902eea7a56b38c20bbdca414e58fc6c3f4393025 (diff)
downloadmacroscope-274765f7daa3cc1094f9f26196fcf2b9a5289ee2.tar.gz
macroscope-274765f7daa3cc1094f9f26196fcf2b9a5289ee2.zip
Corrections :
- replace size_t by void* in many places - correct bug in region freeing code
Diffstat (limited to 'kernel/include')
-rw-r--r--kernel/include/paging.h8
-rw-r--r--kernel/include/region.h11
-rw-r--r--kernel/include/slab_alloc.h8
-rw-r--r--kernel/include/sys.h2
4 files changed, 15 insertions, 14 deletions
diff --git a/kernel/include/paging.h b/kernel/include/paging.h
index 2e1f844..720d6b3 100644
--- a/kernel/include/paging.h
+++ b/kernel/include/paging.h
@@ -1,6 +1,7 @@
#pragma once
#include <sys.h>
+#include <stdbool.h>
struct page_directory;
typedef struct page_directory pagedir_t;
@@ -14,10 +15,9 @@ pagedir_t *get_kernel_pagedir();
void switch_pagedir(pagedir_t *pd);
// these functions are always relative to the currently mapped page directory
-uint32_t pd_get_frame(size_t vaddr); // get physical frame for virtual address
-int pd_map_page(size_t vaddr, uint32_t frame_id,
- uint32_t rw); // returns nonzero on error
-void pd_unmap_page(size_t vaddr); // does nothing if page not mapped
+uint32_t pd_get_frame(void* vaddr); // get physical frame for virtual address
+int pd_map_page(void* vaddr, uint32_t frame_id, bool rw); // returns nonzero on error
+void pd_unmap_page(void* vaddr); // does nothing if page not mapped
pagedir_t *create_pagedir(); // returns zero on error
void delete_pagedir(pagedir_t *pd);
diff --git a/kernel/include/region.h b/kernel/include/region.h
index 1628370..bc26bfe 100644
--- a/kernel/include/region.h
+++ b/kernel/include/region.h
@@ -15,18 +15,19 @@
#define REGION_T_HW 0x00002000 // used for hardware access
struct region_info;
-typedef void (*page_fault_handler_t)(pagedir_t *pd, struct region_info *r, size_t addr);
+typedef void (*page_fault_handler_t)(pagedir_t *pd, struct region_info *r, void* addr);
typedef struct region_info {
- size_t addr, size;
+ void* addr;
+ size_t size;
uint32_t type;
page_fault_handler_t pf;
} region_info_t;
void region_allocator_init(void* kernel_data_end);
-size_t region_alloc(size_t size, uint32_t type, page_fault_handler_t pf); // returns 0 on error
-region_info_t *find_region(size_t addr);
-void region_free(size_t addr);
+void* region_alloc(size_t size, uint32_t type, page_fault_handler_t pf); // returns 0 on error
+region_info_t *find_region(void* addr);
+void region_free(void* addr);
void dbg_print_region_stats();
diff --git a/kernel/include/slab_alloc.h b/kernel/include/slab_alloc.h
index a3bd7de..5c575ba 100644
--- a/kernel/include/slab_alloc.h
+++ b/kernel/include/slab_alloc.h
@@ -22,13 +22,13 @@ typedef struct slab_type {
struct mem_allocator;
typedef struct mem_allocator mem_allocator_t;
-typedef void* (*page_alloc_fun_t)(const size_t bytes);
-typedef void (*page_free_fun_t)(const void* ptr);
+typedef void* (*page_alloc_fun_t)(size_t bytes);
+typedef void (*page_free_fun_t)(void* ptr);
mem_allocator_t* create_slab_allocator(const slab_type_t *types, page_alloc_fun_t af, page_free_fun_t ff);
void destroy_slab_allocator(mem_allocator_t*);
-void* slab_alloc(mem_allocator_t* a, const size_t sz);
-void slab_free(mem_allocator_t* a, const void* ptr);
+void* slab_alloc(mem_allocator_t* a, size_t sz);
+void slab_free(mem_allocator_t* a, void* ptr);
/* vim: set ts=4 sw=4 tw=0 noet :*/
diff --git a/kernel/include/sys.h b/kernel/include/sys.h
index ff98c60..c8721ec 100644
--- a/kernel/include/sys.h
+++ b/kernel/include/sys.h
@@ -22,7 +22,7 @@ static inline uint16_t inw(uint16_t port) {
return ret;
}
-static inline void invlpg(size_t addr) {
+static inline void invlpg(void* addr) {
asm volatile("invlpg (%0)" : : "r"(addr) : "memory");
}