sp1: mm: Add helpers to convert PMA-to-vma, etc

Signed-off-by: Ian Moffett <ian@mirocom.org>
This commit is contained in:
2026-04-18 21:05:06 -04:00
parent c95dad2a6b
commit 9dfb6d9e2b
2 changed files with 43 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2026, Mirocom Laboratories
* All rights reserved.
*
* The following sources are CONFIDENTIAL and PROPRIETARY
* property of Mirocom Laboratories. Unauthorized copying,
* use, distribution or modification of this file, in whole
* and in part, is strictly prohibited without the prior written
* consent from Mirocom Laboratories.
*/
#ifndef _MM_VM_H_
#define _MM_VM_H_ 1
#include <sys/param.h>
#include <os/bpt.h>
/*
* Macros used to convert physical to virtual addresses
* and vice versa.
*/
#define pma_to_vma(pma) \
PTR_OFFSET((void *)pma, bpt_kload_base())
#define vma_to_pma(vma) \
(uintptr_t)PTR_NOFFSET(vma, bpt_kload_base())
#endif /* !_MM_VM_H_ */
+16
View File
@@ -12,6 +12,7 @@
#ifndef _OS_BPT_H_
#define _OS_BPT_H_ 1
#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/status.h>
@@ -83,4 +84,19 @@ status_t bpt_init(void);
/* Boot protocol specific init funcs */
status_t bpt_init_limine(struct bpt_ops *ops);
/*
* Obtain the kernel load base from the bootloader
*/
__always_inline static inline uintptr_t
bpt_kload_base(void)
{
struct bpt_protovar pv;
if (bpt_get_protovar(&pv) != STATUS_SUCCESS) {
return 0;
}
return pv.kload_base;
}
#endif /* !_OS_BPT_H_ */