From d695626cfeb28b8aeb2d6c42b0b6a7bed9e48923 Mon Sep 17 00:00:00 2001 From: Pawel Wieczorkiewicz Date: Mon, 16 Aug 2021 17:24:42 +0200 Subject: [PATCH] mm/regions: add in_free_region() helper function The functions returns true iff specified physical address does not belong to kernel, user nor init sections. Signed-off-by: Pawel Wieczorkiewicz --- include/mm/regions.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/mm/regions.h b/include/mm/regions.h index 5dad496d..3111927d 100644 --- a/include/mm/regions.h +++ b/include/mm/regions.h @@ -125,6 +125,12 @@ static inline bool in_kernel_section(const void *addr) { (addr >= _ptr(__start_symbols) && addr < _ptr(__end_symbols)); } +static inline bool in_free_region(paddr_t pa) { + return !in_kernel_section(paddr_to_virt_kern(pa)) && + !in_user_section(paddr_to_virt_user(pa)) && + !in_init_section(paddr_to_virt(pa)); +} + static inline uint32_t get_bios_ebda_addr(void) { return (*(uint16_t *) paddr_to_virt_kern(EBDA_ADDR_ENTRY)) << 4; }