From aba6c280b6602d616960a9fadbd32c63c288ce0e Mon Sep 17 00:00:00 2001 From: Lephe Date: Sat, 17 Aug 2024 18:04:16 +0200 Subject: [PATCH] hh2: provide metadata macros and a non-metadata marker by default If none of the HH2_*() macros are used, the binary will show up as its own filename instead of random garbage. If HH2_NAME() is used the metadata will be read, and the binary format requires that all fields by specified. Using only a subset of the macros is invalid, but not reported. --- fxcp_hh2.ld.c | 5 ++++- include/gint/config.h.in | 22 ++++++++++++++++++++++ src/kernel/start.S | 8 ++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/fxcp_hh2.ld.c b/fxcp_hh2.ld.c index 46b0713..5036a1b 100644 --- a/fxcp_hh2.ld.c +++ b/fxcp_hh2.ld.c @@ -43,7 +43,10 @@ SECTIONS - All text from .text and .text.* (including user code) */ .hh2 : { KEEP(*(.hh2.header)) - KEEP(*(.hh2.info)) + KEEP(*(.hh2.info.name)) + KEEP(*(.hh2.info.description)) + KEEP(*(.hh2.info.author)) + KEEP(*(.hh2.info.version)) KEEP(*(.hh2.stage2)) . = ALIGN(16); } > eram AT> bin diff --git a/include/gint/config.h.in b/include/gint/config.h.in index 0f5af29..55845be 100644 --- a/include/gint/config.h.in +++ b/include/gint/config.h.in @@ -80,4 +80,26 @@ #define GINT_RENDER_MONO (GINT_HW_FX || GINT_FX9860G_G3A) #define GINT_RENDER_RGB ((GINT_HW_CG || GINT_HW_CP) && !GINT_FX9860G_G3A) +/* Macros for specifying HH2 binary metadata fields. Here because this header + is guaranteed to be included with every gint header. */ +#if GINT_HW_CP +#define HH2_NAME(STR) \ + GSECTION(".hh2.info.name") GVISIBLE \ + char _hh2info_name[] = (STR); +#define HH2_DESCRIPTION(STR) \ + GSECTION(".hh2.info.description") GVISIBLE \ + char _hh2info_description[] = (STR); +#define HH2_AUTHOR(STR) \ + GSECTION(".hh2.info.author") GVISIBLE \ + char _hh2info_author[] = (STR); +#define HH2_VERSION(STR) \ + GSECTION(".hh2.info.version") GVISIBLE \ + char _hh2info_version[] = (STR); +#else +#define HH2_NAME(STR) +#define HH2_DESCRIPTION(STR) +#define HH2_AUTHOR(STR) +#define HH2_VERSION(STR) +#endif + #endif /* GINT_CONFIG */ diff --git a/src/kernel/start.S b/src/kernel/start.S index 7a5e4d3..2da9385 100644 --- a/src/kernel/start.S +++ b/src/kernel/start.S @@ -122,4 +122,12 @@ _stage2: it's overriding the correct location. */ .long 1, 2, 3, 4, 5, 6, 7, 8 +/* Also provide default values for metadata fields. */ + +.section .hh2.info.name +.global __hh2info_name +.weak __hh2info_name +/* Zero byte will skip specifiying any of the data */ +__hh2info_name: .byte 0x00 + #endif /* GINT_OS_CP */