sp1: mm: Add helpers to convert PMA-to-vma, etc
Signed-off-by: Ian Moffett <ian@mirocom.org>
This commit is contained in:
@@ -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_ */
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
#ifndef _OS_BPT_H_
|
#ifndef _OS_BPT_H_
|
||||||
#define _OS_BPT_H_ 1
|
#define _OS_BPT_H_ 1
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/status.h>
|
#include <sys/status.h>
|
||||||
|
|
||||||
@@ -83,4 +84,19 @@ status_t bpt_init(void);
|
|||||||
/* Boot protocol specific init funcs */
|
/* Boot protocol specific init funcs */
|
||||||
status_t bpt_init_limine(struct bpt_ops *ops);
|
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_ */
|
#endif /* !_OS_BPT_H_ */
|
||||||
|
|||||||
Reference in New Issue
Block a user