slab: add umalloc
This commit is contained in:
parent
a28088aea6
commit
b496366469
8 changed files with 238 additions and 12 deletions
|
|
@ -36,6 +36,7 @@ void panic();
|
|||
void cli();
|
||||
void sti();
|
||||
void _save_context();
|
||||
void reboot();
|
||||
void load_stack_and_jump(uintptr_t rsp, uintptr_t rbp, void *func, void *arg);
|
||||
|
||||
typedef uintptr_t paddr_t;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <kernel/lock.h>
|
||||
#include <kernel/rbtree.h>
|
||||
#include <kernel/slab.h>
|
||||
|
||||
#include <lib/sem.h>
|
||||
|
||||
|
|
@ -24,6 +25,12 @@
|
|||
#define STDOUT_FILENO 1
|
||||
#define STDERR_FILENO 2
|
||||
|
||||
#define USER_STACK_BASE 0x00007FFFF0000000
|
||||
#define USER_HEAP_BASE 0x0000000100000000 /* 4GB */
|
||||
|
||||
#define PM_BUD 0
|
||||
#define PM_SLB 1
|
||||
|
||||
typedef int64_t pid_t;
|
||||
|
||||
struct proc_mmap_entry {
|
||||
|
|
@ -60,6 +67,22 @@ struct procregs {
|
|||
|
||||
} PACKED;
|
||||
|
||||
struct proc_mapping {
|
||||
uintptr_t vaddr;
|
||||
paddr_t paddr;
|
||||
size_t len;
|
||||
uint64_t attr;
|
||||
uint64_t type;
|
||||
slab_t *slab;
|
||||
struct proc_mapping *next;
|
||||
};
|
||||
|
||||
struct proc_allocation {
|
||||
struct proc_mapping *mappings;
|
||||
struct proc_mapping *last;
|
||||
size_t num_mappings;
|
||||
};
|
||||
|
||||
struct proc {
|
||||
struct procregs regs;
|
||||
uint8_t state;
|
||||
|
|
@ -83,6 +106,10 @@ struct proc {
|
|||
|
||||
uintptr_t stack_start;
|
||||
uintptr_t stack_size;
|
||||
|
||||
uintptr_t heap_start;
|
||||
|
||||
struct rbtree umalloc_tree;
|
||||
};
|
||||
|
||||
struct procregs *proc_current_regs();
|
||||
|
|
|
|||
|
|
@ -12,6 +12,14 @@
|
|||
#define ALLOC_KERN 0x01
|
||||
#define ALLOC_DMA 0x02
|
||||
|
||||
#define UA_SLAB 0x1
|
||||
#define UA_BUD 0x2
|
||||
|
||||
#define ALLOC_USER 0x0
|
||||
#define ALLOC_USER_STACK 0x1
|
||||
#define ALLOC_USER_RDONLY 0x2
|
||||
#define ALLOC_USER_EXEC 0x4
|
||||
|
||||
#define ATTEMPT_FREE(_x) \
|
||||
if (_x) { \
|
||||
kfree(_x); \
|
||||
|
|
|
|||
Loading…
Reference in a new issue