31 lines
733 B
C
31 lines
733 B
C
// physical memory allocator
|
|
|
|
#ifndef KARLOS_RAM_H
|
|
#define KARLOS_RAM_H
|
|
|
|
#include <stddef.h>
|
|
#include <stdbool.h>
|
|
#include <address.h>
|
|
|
|
enum frame_size {
|
|
RAM_PAGE_NORMAL = 0,
|
|
RAM_PAGE_LARGE = 1,
|
|
RAM_PAGE_HUGE = 2,
|
|
};
|
|
|
|
size_t frame_size_to_num_bytes(enum frame_size size);
|
|
|
|
struct ram_buffer_requirements {
|
|
uint64_t size;
|
|
uint64_t align;
|
|
bool limit4gb;
|
|
};
|
|
|
|
void ram_init(void);
|
|
bool ram_alloc_frame(struct ppn *ppn_out, enum frame_size size);
|
|
bool ram_alloc_frame_zeroed(struct ppn *ppn_out, enum frame_size size);
|
|
bool ram_alloc_buffer(struct ppn *ppn_out, struct ram_buffer_requirements req);
|
|
bool ram_alloc_buffer_zeroed(struct ppn *ppn_out, struct ram_buffer_requirements req);
|
|
void ram_free(struct ppn ppn);
|
|
|
|
#endif
|