mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
55fc1b7026
I've decided to do a rewrite on it due to some plans that would make refcounting physical pages nescessary among other things. now instead of a bitmap it uses a list of pages with each physical page having a page_t associated with it
50 lines
1007 B
C
50 lines
1007 B
C
#ifndef _PMM_H
|
|
#define _PMM_H
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
#define PMM_SECTION_COUNT 3
|
|
#define PMM_SECTION_1MB 0
|
|
#define PMM_SECTION_4GB 1
|
|
#define PMM_SECTION_DEFAULT 2
|
|
|
|
#define PAGE_FLAGS_FREE 1
|
|
|
|
typedef struct page_t {
|
|
struct vnode_t *backing;
|
|
uintmax_t offset;
|
|
struct page_t *hashnext;
|
|
struct page_t *hashprev;
|
|
struct page_t *vnodenext;
|
|
struct page_t *vnodeprev;
|
|
union {
|
|
struct {
|
|
struct page_t *freenext;
|
|
struct page_t *freeprev;
|
|
};
|
|
struct {
|
|
struct page_t *writenext;
|
|
struct page_t *writeprev;
|
|
};
|
|
};
|
|
uintmax_t refcount;
|
|
int flags;
|
|
} page_t;
|
|
|
|
void *pmm_allocpage(int section);
|
|
page_t *pmm_getpage(void *addr);
|
|
void pmm_hold(void *addr);
|
|
void pmm_release(void *addr);
|
|
void pmm_makefree(void *address, size_t count);
|
|
void *pmm_alloc(size_t size, int section);
|
|
void pmm_free(void *addr, size_t size);
|
|
void pmm_init();
|
|
|
|
extern uintptr_t hhdmbase;
|
|
|
|
#define MAKE_HHDM(x) (void *)((uintptr_t)x + hhdmbase)
|
|
#define FROM_HHDM(x) (void *)((uintptr_t)x - hhdmbase)
|
|
|
|
#endif
|