Introduce Overlay Header and LBAs
This commit is contained in:
parent
8a54e5f1ea
commit
5320eab44d
|
@ -0,0 +1,13 @@
|
|||
#ifndef __JABYENGINE_OVERLAY__H__
|
||||
#define __JABYENGINE_OVERLAY__H__
|
||||
#include "../../stdint.h"
|
||||
|
||||
typedef struct __attribute__((packed)) {
|
||||
void (*execute)();
|
||||
} OverlayHeader;
|
||||
|
||||
typedef struct __attribute__((packed)) {
|
||||
uint16_t lba;
|
||||
uint16_t size;
|
||||
} OverlayLBA;
|
||||
#endif //!__JABYENGINE_OVERLAY__H__
|
|
@ -0,0 +1,16 @@
|
|||
#ifndef __JABYENGINE_OVERLAY_DECLARATION__H__
|
||||
#define __JABYENGINE_OVERLAY_DECLARATION__H__
|
||||
|
||||
// No include here because this header should be included in a namespace and we don't want multiple namespace definitions of OverlayHeader and OverlayLBA
|
||||
|
||||
extern const OverlayHeader overlay_header;
|
||||
extern const OverlayLBA overlay_lba[];
|
||||
|
||||
#define __declare_overlay_header(function) \
|
||||
[[gnu::used]] \
|
||||
const OverlayHeader __section(".header") overlay_header = {.execute = &function};
|
||||
|
||||
#define __declare_overlay_lbas(...) \
|
||||
[[gnu::used]] \
|
||||
const OverlayLBA __section(".header.lbas") overlay_lba[] = {__VA_ARGS__};
|
||||
#endif //!__JABYENGINE_OVERLAY_DECLARATION__H__
|
|
@ -38,6 +38,8 @@ pub fn write(output: &mut Output, overlay_desc: &Vec<OverlaySlot>) -> Result<(),
|
|||
writeln!(output, "\t\t.{} {{", section.name)?;
|
||||
writeln!(output, "\t\t\t__{}_start = .;", section.name)?;
|
||||
section.file_pattern.iter().try_for_each(|patr| writeln!(output, "\t\t\tKEEP({}(.header))", patr))?;
|
||||
writeln!(output, "\t\t\t__{}_lbas = .;", section.name)?;
|
||||
section.file_pattern.iter().try_for_each(|patr| writeln!(output, "\t\t\tKEEP({}(.header.lbas))", patr))?;
|
||||
writeln!(output, "\t\t\t__{}_ctor = .;", section.name)?;
|
||||
|
||||
for section_type in [".text.startup._GLOBAL__*", ".ctors", ".text.*", ".rodata*", ".sdata*", ".data*", ".sbss*", ".bss*"] {
|
||||
|
|
Loading…
Reference in New Issue