OurOS 0.1
Operating System built by McGill Students
 
Loading...
Searching...
No Matches
vmalloc.h
Go to the documentation of this file.
1#ifndef _KERNEL_MM_VMALLOC_H
2#define _KERNEL_MM_VMALLOC_H
3
4#include <stddef.h>
5
6/**
7 * @brief Maximum size of the virtual memory region for vmalloc.
8 */
9#define VMALLOC_SIZE (PAGE_SIZE * 512)
10
11/**
12 * @brief Alignment for each vmalloc allocation.
13 */
14#define VMALLOC_ALIGNMENT 16
15
16/**
17 * @brief Initializes the virtual memory allocator.
18 * This should be called after frame allocator and paging are initialized.
19 */
20void vmalloc_init(void);
21
22/**
23 * @brief Allocates `size` bytes of virtual memory and returns a pointer to it.
24 * The allocation is aligned to `VMALLOC_ALIGNMENT`. It panics if out of memory.
25 */
26void *vmalloc(size_t size);
27void *vmalloc(size_t size);
28
29/**
30 * @brief Frees the virtual memory allocated at `addr`.
31 * (TODO: stop using bump allocator)
32 */
33void vfree(void *addr);
34
35#endif // _KERNEL_MM_VMALLOC_H
void vfree(void *addr)
Frees the virtual memory allocated at addr. (TODO: stop using bump allocator)
Definition vmalloc.c:69
void * vmalloc(size_t size)
Allocates size bytes of virtual memory and returns a pointer to it. The allocation is aligned to VMAL...
Definition vmalloc.c:55
void vmalloc_init(void)
Initializes the virtual memory allocator. This should be called after frame allocator and paging are ...
Definition vmalloc.c:23