slab: upgrade kmalloc to allow DMA regions
these DMA regions are only meant to comply with certain AHCI requirements, and are not yet general purpose
This commit is contained in:
parent
20d19ed994
commit
8544efe1ab
7 changed files with 89 additions and 36 deletions
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#define ALIGN(_a) __attribute__((aligned(_a)))
|
||||
|
||||
|
||||
struct page { /* I would rather refer to this as a struct */
|
||||
union {
|
||||
struct {
|
||||
|
|
@ -81,6 +82,7 @@ extern size_t max_regions;
|
|||
|
||||
extern struct page *pml4;
|
||||
extern paddr_t kcr3;
|
||||
extern struct page kdefault_attrs;
|
||||
|
||||
uint64_t cr3_read();
|
||||
void cr3_write(uint64_t cr3);
|
||||
|
|
|
|||
|
|
@ -6,9 +6,14 @@
|
|||
#include <kernel/mem.h>
|
||||
|
||||
#define SLAB_PAGE_ALIGN 0x01
|
||||
#define SLAB_DMA_64K 0x02
|
||||
|
||||
#define ALLOC_KERN 0x01
|
||||
#define ALLOC_DMA 0x02
|
||||
|
||||
struct slab {
|
||||
size_t size; /* size of each object */
|
||||
size_t tsize; /* total size of this slab */
|
||||
size_t num; /* number of objects in this slab */
|
||||
size_t free; /* number of free objects */
|
||||
uint64_t flags;
|
||||
|
|
@ -30,8 +35,8 @@ void *slab_alloc(struct slab *slab);
|
|||
void slab_free(struct slab *slab, void *ptr);
|
||||
|
||||
void kmalloc_init();
|
||||
void *kmalloc(size_t size);
|
||||
void *kzalloc(size_t size);
|
||||
void *kmalloc(size_t size, uint64_t flags);
|
||||
void *kzalloc(size_t size, uint64_t flags);
|
||||
void kfree(void *ptr);
|
||||
|
||||
#endif /* _SLAB_H_ */
|
||||
|
|
|
|||
Loading…
Reference in a new issue