aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-01-11 23:06:04 -0500
committerIan Moffett <ian@osmora.org>2024-01-12 00:04:50 -0500
commit213679c7c1ee8c5a482f35fbcd62a48758f6cf12 (patch)
treecb2ad0f12286deed79105fbe2960b26fce9bb649 /sys
parent089405dd59157c3a652fcc5d1b28141bb0546eb9 (diff)
kernel: vm: Make vm_get_bsp_ctx() return pointer
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys')
-rw-r--r--sys/include/vm/vm.h2
-rw-r--r--sys/vm/vm_dynalloc.c24
-rw-r--r--sys/vm/vm_init.c6
3 files changed, 16 insertions, 16 deletions
diff --git a/sys/include/vm/vm.h b/sys/include/vm/vm.h
index 1bbe500..4ea6d22 100644
--- a/sys/include/vm/vm.h
+++ b/sys/include/vm/vm.h
@@ -60,6 +60,6 @@ vm_get_page_size(void)
}
void vm_init(void);
-struct vm_ctx vm_get_bsp_ctx(void);
+struct vm_ctx *vm_get_bsp_ctx(void);
#endif /* !_VM_H_ */
diff --git a/sys/vm/vm_dynalloc.c b/sys/vm/vm_dynalloc.c
index 861efe4..e1b61c7 100644
--- a/sys/vm/vm_dynalloc.c
+++ b/sys/vm/vm_dynalloc.c
@@ -39,12 +39,12 @@ void *
dynalloc(size_t sz)
{
/* TODO: Per CPU */
- struct vm_ctx vm_ctx = vm_get_bsp_ctx();
+ struct vm_ctx *vm_ctx = vm_get_bsp_ctx();
void *tmp;
- spinlock_acquire(&vm_ctx.dynalloc_lock);
- tmp = tlsf_malloc(vm_ctx.tlsf_ctx, sz);
- spinlock_release(&vm_ctx.dynalloc_lock);
+ spinlock_acquire(&vm_ctx->dynalloc_lock);
+ tmp = tlsf_malloc(vm_ctx->tlsf_ctx, sz);
+ spinlock_release(&vm_ctx->dynalloc_lock);
return tmp;
}
@@ -58,12 +58,12 @@ void *
dynrealloc(void *old_ptr, size_t newsize)
{
/* TODO: Per CPU */
- struct vm_ctx vm_ctx = vm_get_bsp_ctx();
+ struct vm_ctx *vm_ctx = vm_get_bsp_ctx();
void *tmp;
- spinlock_acquire(&vm_ctx.dynalloc_lock);
- tmp = tlsf_realloc(vm_ctx.tlsf_ctx, old_ptr, newsize);
- spinlock_release(&vm_ctx.dynalloc_lock);
+ spinlock_acquire(&vm_ctx->dynalloc_lock);
+ tmp = tlsf_realloc(vm_ctx->tlsf_ctx, old_ptr, newsize);
+ spinlock_release(&vm_ctx->dynalloc_lock);
return tmp;
}
@@ -76,9 +76,9 @@ void
dynfree(void *ptr)
{
/* TODO: Per CPU */
- struct vm_ctx vm_ctx = vm_get_bsp_ctx();
+ struct vm_ctx *vm_ctx = vm_get_bsp_ctx();
- spinlock_acquire(&vm_ctx.dynalloc_lock);
- tlsf_free(vm_ctx.tlsf_ctx, ptr);
- spinlock_release(&vm_ctx.dynalloc_lock);
+ spinlock_acquire(&vm_ctx->dynalloc_lock);
+ tlsf_free(vm_ctx->tlsf_ctx, ptr);
+ spinlock_release(&vm_ctx->dynalloc_lock);
}
diff --git a/sys/vm/vm_init.c b/sys/vm/vm_init.c
index e755119..2a704fe 100644
--- a/sys/vm/vm_init.c
+++ b/sys/vm/vm_init.c
@@ -46,17 +46,17 @@ static volatile struct vas kernel_vas;
* TODO: Move this to a per CPU structure, this kinda sucks
* how it is right now...
*/
-static volatile struct vm_ctx bsp_vm_ctx = {0};
+static struct vm_ctx bsp_vm_ctx = {0};
volatile struct limine_hhdm_request g_hhdm_request = {
.id = LIMINE_HHDM_REQUEST,
.revision = 0
};
-struct vm_ctx
+struct vm_ctx *
vm_get_bsp_ctx(void)
{
- return bsp_vm_ctx;
+ return &bsp_vm_ctx;
}
void