2020-09-20 13:03:44 +03:00
|
|
|
#ifndef __MM__PMM_H__
|
|
|
|
#define __MM__PMM_H__
|
2020-06-05 18:51:33 +03:00
|
|
|
|
|
|
|
#include <stdint.h>
|
2021-01-02 23:44:27 +03:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdbool.h>
|
2022-08-13 20:54:49 +03:00
|
|
|
|
|
|
|
struct memmap_entry {
|
|
|
|
uint64_t base;
|
|
|
|
uint64_t length;
|
|
|
|
uint32_t type;
|
|
|
|
uint32_t unused;
|
|
|
|
};
|
2020-06-05 18:51:33 +03:00
|
|
|
|
2020-09-19 16:29:19 +03:00
|
|
|
#define MEMMAP_USABLE 1
|
|
|
|
#define MEMMAP_RESERVED 2
|
|
|
|
#define MEMMAP_ACPI_RECLAIMABLE 3
|
|
|
|
#define MEMMAP_ACPI_NVS 4
|
|
|
|
#define MEMMAP_BAD_MEMORY 5
|
|
|
|
#define MEMMAP_BOOTLOADER_RECLAIMABLE 0x1000
|
|
|
|
#define MEMMAP_KERNEL_AND_MODULES 0x1001
|
2021-04-07 03:10:28 +03:00
|
|
|
#define MEMMAP_FRAMEBUFFER 0x1002
|
2021-03-05 08:10:58 +03:00
|
|
|
#define MEMMAP_EFI_RECLAIMABLE 0x2000
|
2020-09-19 16:29:19 +03:00
|
|
|
|
2021-10-07 05:04:41 +03:00
|
|
|
struct meminfo {
|
|
|
|
size_t uppermem;
|
|
|
|
size_t lowermem;
|
|
|
|
};
|
|
|
|
|
2022-08-13 20:54:49 +03:00
|
|
|
struct meminfo mmap_get_info(size_t mmap_count, struct memmap_entry *mmap);
|
2021-10-07 05:04:41 +03:00
|
|
|
|
2022-09-02 03:29:12 +03:00
|
|
|
#if defined (BIOS)
|
2022-08-13 20:54:49 +03:00
|
|
|
extern struct memmap_entry memmap[];
|
2020-12-10 10:47:37 +03:00
|
|
|
extern size_t memmap_entries;
|
2021-09-03 04:10:23 +03:00
|
|
|
#endif
|
2020-12-10 10:47:37 +03:00
|
|
|
|
2022-09-02 03:29:12 +03:00
|
|
|
#if defined (UEFI)
|
2022-08-13 20:54:49 +03:00
|
|
|
extern struct memmap_entry *memmap;
|
2021-09-03 04:10:23 +03:00
|
|
|
extern size_t memmap_entries;
|
2022-09-24 04:57:55 +03:00
|
|
|
|
|
|
|
extern struct memmap_entry *untouched_memmap;
|
|
|
|
extern size_t untouched_memmap_entries;
|
2021-07-06 23:45:16 +03:00
|
|
|
#endif
|
|
|
|
|
2021-12-14 08:47:28 +03:00
|
|
|
extern bool allocations_disallowed;
|
|
|
|
|
2020-06-05 18:51:33 +03:00
|
|
|
void init_memmap(void);
|
2022-08-13 20:54:49 +03:00
|
|
|
struct memmap_entry *get_memmap(size_t *entries);
|
|
|
|
struct memmap_entry *get_raw_memmap(size_t *entry_count);
|
|
|
|
void print_memmap(struct memmap_entry *mm, size_t size);
|
2022-09-25 21:37:17 +03:00
|
|
|
bool memmap_alloc_range_in(struct memmap_entry *m, size_t *_count,
|
|
|
|
uint64_t base, uint64_t length, uint32_t type, uint32_t overlay_type, bool do_panic, bool simulation, bool new_entry);
|
2022-06-27 11:48:03 +03:00
|
|
|
bool memmap_alloc_range(uint64_t base, uint64_t length, uint32_t type, uint32_t overlay_type, bool panic, bool simulation, bool new_entry);
|
2021-07-09 15:40:44 +03:00
|
|
|
void pmm_randomise_memory(void);
|
2020-09-20 13:03:44 +03:00
|
|
|
|
|
|
|
void *ext_mem_alloc(size_t count);
|
|
|
|
void *ext_mem_alloc_type(size_t count, uint32_t type);
|
2021-10-29 02:15:11 +03:00
|
|
|
void *ext_mem_alloc_type_aligned(size_t count, uint32_t type, size_t alignment);
|
2020-09-20 13:03:44 +03:00
|
|
|
|
|
|
|
void *conv_mem_alloc(size_t count);
|
2020-06-05 18:51:33 +03:00
|
|
|
|
2021-10-21 02:27:05 +03:00
|
|
|
void pmm_free(void *ptr, size_t length);
|
|
|
|
|
2022-09-02 03:29:12 +03:00
|
|
|
#if defined (UEFI)
|
2021-05-06 05:31:05 +03:00
|
|
|
void pmm_release_uefi_mem(void);
|
2021-03-10 03:23:44 +03:00
|
|
|
#endif
|
|
|
|
|
2020-06-05 18:51:33 +03:00
|
|
|
#endif
|