38 lines
884 B
C
38 lines
884 B
C
#pragma once
|
|
|
|
#include <stddef.h>
|
|
#include <dtb.h>
|
|
|
|
#define MMAN_NO_PAGE 0xffffffffffffffff
|
|
#define PAGE_SIZE (1 << 12)
|
|
|
|
// PAGE_FREE => available
|
|
// PAGE_ALLOCATED => this range is allocated explicitly
|
|
// PAGE_DIVIDED => this range is divided into smaller range
|
|
// PAGE_RESERVED => this range is reserved explicitly
|
|
typedef enum :uint8_t {
|
|
PAGE_FREE = 0,
|
|
PAGE_ALLOCATED = 1,
|
|
PAGE_DIVIDED = 2,
|
|
PAGE_RESERVED = 3,
|
|
} page_state_t;
|
|
|
|
typedef struct {
|
|
page_state_t state;
|
|
uint64_t maxsz;
|
|
} page_header_t;
|
|
|
|
void mman_init();
|
|
|
|
void *allocate_page(size_t page_cnt);
|
|
void free_page(void *ptr);
|
|
void reserve_page(void *begin, void *end);
|
|
|
|
void mman_fdt_memory_cb_func(const vector_t *props);
|
|
|
|
extern fdt_callback_t mman_dtb_memory_cb;
|
|
extern void *mman_memory_start;
|
|
extern void *mman_memory_end;
|
|
extern size_t mman_page_cnt;
|
|
extern page_header_t *mman_frame_array;
|