|
Voxia OS v0.0.1
Hobby Project Operating System Targeting x86-64
|
#include "libk/serial.h"#include "memory/memory_utils.h"#include "memory/phys_base_allocator.h"#include "memory/vm_manager.h"#include <autoconf.h>#include <hal/cpu/core.h>#include <hal/cpu/irq_lock.h>#include <hal/cpu/paging.h>#include <memory/kalloc.h>#include <spinlock.h>#include <str.h>#include <type.h>Go to the source code of this file.
Data Structures | |
| struct | freed_t |
| struct | kalloc_cpu_cache |
Macros | |
| #define | MAX_FREED_VADDRS 512 |
| #define | KALLOC_REFILL(BUCKET) |
| #define | KALLOC_SLAB_ALLOC(BUCKET) |
Functions | |
| struct kalloc_cpu_cache | __attribute__ ((aligned(64))) |
| static uintptr_t | lock_irqsave (spinlock_t *lk) |
| static void | unlock_irqrestore (spinlock_t *lk, uintptr_t flags) |
| static void | setup_redzone (void *ptr, size_t size) |
| static int | check_redzone (void *ptr, size_t size) |
| static uintptr_t | vaddr_alloc_locked (size_t page_count) |
| static void * | alloc_page_locked (void) |
| static void | refill_64 (struct kalloc_cpu_cache *cc, uintptr_t *gflags) |
| static void | refill_128 (struct kalloc_cpu_cache *cc, uintptr_t *gflags) |
| static void | refill_256 (struct kalloc_cpu_cache *cc, uintptr_t *gflags) |
| static void | refill_512 (struct kalloc_cpu_cache *cc, uintptr_t *gflags) |
| static void | refill_1024 (struct kalloc_cpu_cache *cc, uintptr_t *gflags) |
| static void | refill_2048 (struct kalloc_cpu_cache *cc, uintptr_t *gflags) |
| __attribute__ ((used, visibility("default"), section(".export"))) | |
| This function handles memory allocation for a new dentry using the slab allocator. | |
Variables | |
| void * | c_64 |
| void * | c_128 |
| void * | c_256 |
| void * | c_512 |
| void * | c_1024 |
| void * | c_2048 |
| size_t | c_64_count |
| size_t | c_128_count |
| size_t | c_256_count |
| size_t | c_512_count |
| size_t | c_1024_count |
| size_t | c_2048_count |
| spinlock_t | lock |
| uint8_t | _pad [64 -(sizeof(void *) *6+sizeof(size_t) *6+sizeof(spinlock_t)) % 64] |
| static struct kalloc_cpu_cache | cpu_caches [VOXIA_MAX_CORE] |
| static spinlock_t | kalloc_global_lock = {0} |
| static uintptr_t | kalloc_next_addr = KALLOC_BASE_ADDR |
| static freed_t | freed_vaddrs [512] |
| static size_t | freed_vaddr_count = 0 |
| #define KALLOC_REFILL | ( | BUCKET | ) |
Definition at line 108 of file kalloc.c.
Referenced by refill_1024(), refill_2048(), refill_256(), and refill_512().
| #define KALLOC_SLAB_ALLOC | ( | BUCKET | ) |
Definition at line 133 of file kalloc.c.
Referenced by __attribute__().
| #define MAX_FREED_VADDRS 512 |
Definition at line 14 of file kalloc.c.
Referenced by push_freed_vaddr().
| struct kalloc_cpu_cache __attribute__ | ( | (aligned(64)) | ) |
| __attribute__ | ( | (used, visibility("default"), section(".export")) | ) |
This function handles memory allocation for a new dentry using the slab allocator.
It also links the dentry to its corresponding VNode (if provided).
| name | The name of the file or directory. |
| vnode | Pointer to the associated VNode (inode data). Pass NULL if the VNode is not yet available. |
Definition at line 161 of file kalloc.c.
References ALIGN_UP, BLOCK_SIZE, data, get_kernel_vmm_page(), kalloc_global_lock, KALLOC_REDZONE_MAGIC, KALLOC_REDZONE_SIZE, KALLOC_SLAB_ALLOC, KERNEL_API, lock_irqsave(), kalloc_metadata_t::magic, NULL, PAGE_PRESENT, PAGE_USER, PAGE_WRITABLE, paging_get_highest_page_map(), phys_base_alloc(), setup_redzone(), kalloc_metadata_t::size, size, unlock_irqrestore(), vaddr_alloc_locked(), vma_register(), and vxMultipleMmap().
|
static |
Definition at line 99 of file kalloc.c.
References BLOCK_SIZE, get_kernel_vmm_page(), PAGE_PRESENT, PAGE_USER, PAGE_WRITABLE, paging_get_highest_page_map(), phys_base_alloc(), vaddr_alloc_locked(), vma_register(), and vxMmap().
|
static |
Definition at line 72 of file kalloc.c.
References KALLOC_REDZONE_MAGIC, ptr, and size.
|
inlinestatic |
Definition at line 55 of file kalloc.c.
References flags, irq_save(), and spin_acquire().
Referenced by __attribute__().
|
static |
Definition at line 130 of file kalloc.c.
References KALLOC_REFILL.
|
static |
|
static |
Definition at line 131 of file kalloc.c.
References KALLOC_REFILL.
|
static |
Definition at line 128 of file kalloc.c.
References KALLOC_REFILL.
|
static |
Definition at line 129 of file kalloc.c.
References KALLOC_REFILL.
|
static |
|
static |
Definition at line 66 of file kalloc.c.
References KALLOC_REDZONE_MAGIC, ptr, and size.
Referenced by __attribute__().
|
inlinestatic |
Definition at line 61 of file kalloc.c.
References flags, irq_restore(), and spin_release().
Referenced by __attribute__().
Definition at line 81 of file kalloc.c.
References BLOCK_SIZE, freed_vaddr_count, freed_vaddrs, kalloc_next_addr, and size.
Referenced by __attribute__(), and alloc_page_locked().
| uint8_t _pad[64 -(sizeof(void *) *6+sizeof(size_t) *6+ sizeof(spinlock_t)) % 64] |
Definition at line 19 of file kalloc.c.
Referenced by __attribute__().
|
static |
|
static |
Definition at line 53 of file kalloc.c.
Referenced by get_default_slab_addr(), push_freed_vaddr(), and vaddr_alloc_locked().
|
static |
Definition at line 52 of file kalloc.c.
Referenced by get_default_slab_addr(), push_freed_vaddr(), and vaddr_alloc_locked().
|
static |
Definition at line 48 of file kalloc.c.
Referenced by __attribute__().
|
static |
Definition at line 50 of file kalloc.c.
Referenced by vaddr_alloc_locked().
| spinlock_t lock |