summaryrefslogtreecommitdiff
path: root/tools/spec.h
blob: 8c48910430a7aa9cb87d2c6f6fb6ae3ae7d891c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef SPEC_H
#define SPEC_H

#include <stdint.h>
#include <stdbool.h>

typedef enum {
    STMT_address,
    STMT_after,
    STMT_align,
    STMT_beginseg,
    STMT_compress,
    STMT_endseg,
    STMT_entry,
    STMT_flags,
    STMT_include,
    STMT_name,
    STMT_number,
    STMT_romalign,
    STMT_stack,
    STMT_increment,
    STMT_pad_text,
} STMTId;

enum {
    FLAG_BOOT = (1 << 0),
    FLAG_OBJECT = (1 << 1),
    FLAG_RAW = (1 << 2),
    FLAG_NOLOAD = (1 << 3),
    FLAG_SYMS = (1 << 4),
    FLAG_OVL = (1 << 5)
};

struct Include {
    char* fpath;
    int linkerPadding;
};

typedef struct Segment {
    uint32_t fields;
    char* name;
    char* after;
    uint32_t flags;
    uint32_t address;
    uint32_t stack;
    uint32_t align;
    uint32_t romalign;
    uint32_t increment;
    uint32_t entry;
    uint32_t number;
    struct Include* includes;
    int includesCount;
    bool compress;
} 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);

void free_single_segment_elements(struct Segment *segment);

void free_rom_spec(struct Segment* segments, int segment_count);

#endif