2022-02-06 19:40:26 +00:00
|
|
|
#ifndef SPEC_H
|
|
|
|
#define SPEC_H
|
2021-11-30 23:29:09 +00:00
|
|
|
|
2022-02-06 19:40:26 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
typedef enum {
|
2021-11-30 23:29:09 +00:00
|
|
|
STMT_address,
|
|
|
|
STMT_after,
|
|
|
|
STMT_align,
|
|
|
|
STMT_beginseg,
|
2024-01-24 18:00:10 +00:00
|
|
|
STMT_compress,
|
2021-11-30 23:29:09 +00:00
|
|
|
STMT_endseg,
|
|
|
|
STMT_entry,
|
|
|
|
STMT_flags,
|
|
|
|
STMT_include,
|
2024-06-10 14:07:51 +00:00
|
|
|
STMT_include_data_only_within_rodata,
|
|
|
|
STMT_include_no_data,
|
2021-11-30 23:29:09 +00:00
|
|
|
STMT_name,
|
|
|
|
STMT_number,
|
|
|
|
STMT_romalign,
|
|
|
|
STMT_stack,
|
|
|
|
STMT_increment,
|
|
|
|
STMT_pad_text,
|
2022-02-06 19:40:26 +00:00
|
|
|
} STMTId;
|
2021-11-30 23:29:09 +00:00
|
|
|
|
2022-02-06 19:40:26 +00:00
|
|
|
enum {
|
2021-11-30 23:29:09 +00:00
|
|
|
FLAG_BOOT = (1 << 0),
|
|
|
|
FLAG_OBJECT = (1 << 1),
|
|
|
|
FLAG_RAW = (1 << 2),
|
2024-02-03 22:59:19 +00:00
|
|
|
FLAG_NOLOAD = (1 << 3),
|
2024-02-13 01:10:20 +00:00
|
|
|
FLAG_SYMS = (1 << 4)
|
2021-11-30 23:29:09 +00:00
|
|
|
};
|
|
|
|
|
2022-02-06 19:40:26 +00:00
|
|
|
struct Include {
|
|
|
|
char* fpath;
|
2021-11-30 23:29:09 +00:00
|
|
|
int linkerPadding;
|
2024-06-10 14:07:51 +00:00
|
|
|
bool dataOnlyWithinRodata;
|
|
|
|
bool noData;
|
2021-11-30 23:29:09 +00:00
|
|
|
};
|
|
|
|
|
2022-02-06 19:40:26 +00:00
|
|
|
typedef struct Segment {
|
2021-11-30 23:29:09 +00:00
|
|
|
uint32_t fields;
|
2022-02-06 19:40:26 +00:00
|
|
|
char* name;
|
|
|
|
char* after;
|
2021-11-30 23:29:09 +00:00
|
|
|
uint32_t flags;
|
|
|
|
uint32_t address;
|
|
|
|
uint32_t stack;
|
|
|
|
uint32_t align;
|
|
|
|
uint32_t romalign;
|
|
|
|
uint32_t increment;
|
|
|
|
uint32_t entry;
|
|
|
|
uint32_t number;
|
2022-02-06 19:40:26 +00:00
|
|
|
struct Include* includes;
|
2021-11-30 23:29:09 +00:00
|
|
|
int includesCount;
|
2024-01-24 18:00:10 +00:00
|
|
|
bool compress;
|
2022-02-06 19:40:26 +00:00
|
|
|
} Segment;
|
|
|
|
|
|
|
|
void parse_rom_spec(char* spec, struct Segment** segments, int* segment_count);
|
|
|
|
|
|
|
|
bool get_single_segment_by_name(struct Segment* dstSegment, char *spec, const char *segmentName);
|
2021-11-30 23:29:09 +00:00
|
|
|
|
2022-02-06 19:40:26 +00:00
|
|
|
void free_single_segment_elements(struct Segment *segment);
|
2021-11-30 23:29:09 +00:00
|
|
|
|
2022-02-06 19:40:26 +00:00
|
|
|
void free_rom_spec(struct Segment* segments, int segment_count);
|
2021-11-30 23:29:09 +00:00
|
|
|
|
|
|
|
#endif
|