This repository has been archived by the owner on Aug 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Abstract details about memory layout.
Details of the loaded image come from the linker. Abstracting these details hides the linker specifics and gives more flexibility for overriding in a test in future. Change-Id: I70fd71bd117a99fae461530c95b8f8f6260fdc3e
- Loading branch information
1 parent
3a94257
commit 5991ec9
Showing
5 changed files
with
101 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#pragma once | ||
|
||
#include "hf/addr.h" | ||
|
||
/** | ||
* Get the address the .text section begins at. | ||
*/ | ||
static inline paddr_t layout_text_begin(void) | ||
{ | ||
extern uint8_t text_begin[]; | ||
return pa_init((uintpaddr_t)text_begin); | ||
} | ||
|
||
/** | ||
* Get the address the .text section ends at. | ||
*/ | ||
static inline paddr_t layout_text_end(void) | ||
{ | ||
extern uint8_t text_end[]; | ||
return pa_init((uintpaddr_t)text_end); | ||
} | ||
|
||
/** | ||
* Get the address the .rodata section begins at. | ||
*/ | ||
static inline paddr_t layout_rodata_begin(void) | ||
{ | ||
extern uint8_t rodata_begin[]; | ||
return pa_init((uintpaddr_t)rodata_begin); | ||
} | ||
|
||
/** | ||
* Get the address the .rodata section ends at. | ||
*/ | ||
static inline paddr_t layout_rodata_end(void) | ||
{ | ||
extern uint8_t rodata_end[]; | ||
return pa_init((uintpaddr_t)rodata_end); | ||
} | ||
|
||
/** | ||
* Get the address the .data section begins at. | ||
*/ | ||
static inline paddr_t layout_data_begin(void) | ||
{ | ||
extern uint8_t data_begin[]; | ||
return pa_init((uintpaddr_t)data_begin); | ||
} | ||
|
||
/** | ||
* Get the address the .data section ends at. | ||
*/ | ||
static inline paddr_t layout_data_end(void) | ||
{ | ||
extern uint8_t data_end[]; | ||
return pa_init((uintpaddr_t)data_end); | ||
} | ||
|
||
/** | ||
* Get the address the loaded image ends at. | ||
*/ | ||
static inline paddr_t layout_bin_end(void) | ||
{ | ||
extern uint8_t bin_end[]; | ||
return pa_init((uintpaddr_t)bin_end); | ||
} | ||
|
||
/** | ||
* Get the address to load the primary VM at. | ||
* | ||
* This is placed just after the image. | ||
*/ | ||
static inline paddr_t layout_primary_begin(void) | ||
{ | ||
/* TODO: This is a hack. We must read the alignment from the binary. */ | ||
paddr_t bin_end = layout_bin_end(); | ||
return pa_init((pa_addr(bin_end) + 0x80000 - 1) & ~(0x80000 - 1)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters