1 | /*****************************************************************************/ |
2 | /* */ |
3 | /* config.h */ |
4 | /* */ |
5 | /* Target configuration file for the ld65 linker */ |
6 | /* */ |
7 | /* */ |
8 | /* */ |
9 | /* (C) 1998-2012, Ullrich von Bassewitz */ |
10 | /* Roemerstrasse 52 */ |
11 | /* D-70794 Filderstadt */ |
12 | /* EMail: uz@cc65.org */ |
13 | /* */ |
14 | /* */ |
15 | /* This software is provided 'as-is', without any expressed or implied */ |
16 | /* warranty. In no event will the authors be held liable for any damages */ |
17 | /* arising from the use of this software. */ |
18 | /* */ |
19 | /* Permission is granted to anyone to use this software for any purpose, */ |
20 | /* including commercial applications, and to alter it and redistribute it */ |
21 | /* freely, subject to the following restrictions: */ |
22 | /* */ |
23 | /* 1. The origin of this software must not be misrepresented; you must not */ |
24 | /* claim that you wrote the original software. If you use this software */ |
25 | /* in a product, an acknowledgment in the product documentation would be */ |
26 | /* appreciated but is not required. */ |
27 | /* 2. Altered source versions must be plainly marked as such, and must not */ |
28 | /* be misrepresented as being the original software. */ |
29 | /* 3. This notice may not be removed or altered from any source */ |
30 | /* distribution. */ |
31 | /* */ |
32 | /*****************************************************************************/ |
33 | |
34 | |
35 | |
36 | #ifndef CONFIG_H |
37 | #define CONFIG_H |
38 | |
39 | |
40 | |
41 | /* common */ |
42 | #include "coll.h" |
43 | #include "filepos.h" |
44 | |
45 | /* ld65 */ |
46 | #include "lineinfo.h" |
47 | #include "segments.h" |
48 | |
49 | |
50 | |
51 | /*****************************************************************************/ |
52 | /* Data */ |
53 | /*****************************************************************************/ |
54 | |
55 | |
56 | |
57 | /* Forward for struct MemoryArea */ |
58 | struct MemoryArea; |
59 | |
60 | /* File list entry */ |
61 | typedef struct File File; |
62 | struct File { |
63 | unsigned Name; /* Name index of the file */ |
64 | unsigned Flags; |
65 | unsigned Format; /* Output format */ |
66 | unsigned long Size; /* Size of the generated file */ |
67 | Collection MemoryAreas; /* List of memory areas in this file */ |
68 | }; |
69 | |
70 | /* Segment descriptor entry */ |
71 | typedef struct SegDesc SegDesc; |
72 | struct SegDesc { |
73 | unsigned Name; /* Index of the name */ |
74 | LineInfo* LI; /* Position of definition */ |
75 | Segment* Seg; /* Pointer to segment structure */ |
76 | unsigned Attr; /* Attributes for segment */ |
77 | unsigned Flags; /* Set of bitmapped flags */ |
78 | unsigned char FillVal; /* Fill value for this segment */ |
79 | struct MemoryArea* Load; /* Load memory section */ |
80 | struct MemoryArea* Run; /* Run memory section */ |
81 | unsigned long Addr; /* Start address or offset into segment */ |
82 | unsigned long RunAlignment; /* Run area alignment if given */ |
83 | unsigned long LoadAlignment; /* Load area alignment if given */ |
84 | }; |
85 | |
86 | /* Segment flags */ |
87 | #define SF_RO 0x0001 /* Read only segment */ |
88 | #define SF_BSS 0x0002 /* Segment is BSS style segment */ |
89 | #define SF_ZP 0x0004 /* Zeropage segment (o65 only) */ |
90 | #define SF_DEFINE 0x0008 /* Define start and size */ |
91 | #define SF_ALIGN 0x0010 /* Align segment in run area */ |
92 | #define SF_ALIGN_LOAD 0x0020 /* Align segment in load area */ |
93 | #define SF_OFFSET 0x0040 /* Segment has offset in memory */ |
94 | #define SF_START 0x0080 /* Segment has fixed start address */ |
95 | #define SF_OPTIONAL 0x0100 /* Segment is optional (must not exist) */ |
96 | #define SF_RUN_DEF 0x0200 /* RUN symbols already defined */ |
97 | #define SF_LOAD_DEF 0x0400 /* LOAD symbols already defined */ |
98 | #define SF_FILLVAL 0x0800 /* Segment has separate fill value */ |
99 | #define SF_OVERWRITE 0x1000 /* Segment can overwrite (part of) another one */ |
100 | |
101 | |
102 | |
103 | /*****************************************************************************/ |
104 | /* Code */ |
105 | /*****************************************************************************/ |
106 | |
107 | |
108 | |
109 | void CfgRead (void); |
110 | /* Read the configuration */ |
111 | |
112 | unsigned CfgProcess (void); |
113 | /* Process the config file after reading in object files and libraries. This |
114 | ** includes postprocessing of the config file data but also assigning segments |
115 | ** and defining segment/memory area related symbols. The function will return |
116 | ** the number of memory area overflows (so zero means anything went ok). |
117 | ** In case of overflows, a short mapfile can be generated later, to ease the |
118 | ** task of rearranging segments for the user. |
119 | */ |
120 | |
121 | void CfgWriteTarget (void); |
122 | /* Write the target file(s) */ |
123 | |
124 | |
125 | |
126 | /* End of config.h */ |
127 | |
128 | #endif |
129 | |