Rev 2198 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2198 | Rev 2349 | ||
---|---|---|---|
1 | #! /bin/sh |
1 | #! /bin/sh |
2 | 2 | ||
3 | # |
3 | # |
4 | # Copyright (C) 2006 Martin Decky |
4 | # Copyright (C) 2006 Martin Decky |
5 | # All rights reserved. |
5 | # All rights reserved. |
6 | # |
6 | # |
7 | # Redistribution and use in source and binary forms, with or without |
7 | # Redistribution and use in source and binary forms, with or without |
8 | # modification, are permitted provided that the following conditions |
8 | # modification, are permitted provided that the following conditions |
9 | # are met: |
9 | # are met: |
10 | # |
10 | # |
11 | # - Redistributions of source code must retain the above copyright |
11 | # - Redistributions of source code must retain the above copyright |
12 | # notice, this list of conditions and the following disclaimer. |
12 | # notice, this list of conditions and the following disclaimer. |
13 | # - Redistributions in binary form must reproduce the above copyright |
13 | # - Redistributions in binary form must reproduce the above copyright |
14 | # notice, this list of conditions and the following disclaimer in the |
14 | # notice, this list of conditions and the following disclaimer in the |
15 | # documentation and/or other materials provided with the distribution. |
15 | # documentation and/or other materials provided with the distribution. |
16 | # - The name of the author may not be used to endorse or promote products |
16 | # - The name of the author may not be used to endorse or promote products |
17 | # derived from this software without specific prior written permission. |
17 | # derived from this software without specific prior written permission. |
18 | # |
18 | # |
19 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
19 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
20 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
20 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
21 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
21 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
22 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
22 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
23 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
23 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
24 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
24 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
25 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
26 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
27 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
28 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | # |
29 | # |
30 | 30 | ||
31 | 31 | ||
32 | OBJCOPY="$1" |
32 | OBJCOPY="$1" |
33 | LINK="_link.ld" |
33 | LINK="_link.ld" |
34 | HEADER="_components.h" |
34 | HEADER="_components.h" |
35 | 35 | ||
36 | shift 1 |
36 | shift 1 |
37 | 37 | ||
38 | echo "OUTPUT_FORMAT(\"elf32-littlearm\") |
38 | echo "OUTPUT_FORMAT(\"elf32-littlearm\") |
39 | 39 | ||
40 | ENTRY(start) |
40 | ENTRY(start) |
41 | 41 | ||
42 | SECTIONS { |
42 | SECTIONS { |
43 | .boot 0x0: AT (0) { |
43 | .boot 0x0: AT (0) { |
44 | *(BOOTSTRAP); |
44 | *(BOOTSTRAP); |
45 | *(.text); |
45 | *(.text); |
46 | 46 | ||
47 | *(.rodata); |
47 | *(.rodata); |
48 | *(.rodata.*); |
48 | *(.rodata.*); |
49 | *(.data); /* initialized data */ |
49 | *(.data); /* initialized data */ |
50 | *(.sdata); |
50 | *(.sdata); |
51 | *(.sdata2); |
51 | *(.sdata2); |
52 | *(.sbss); |
52 | *(.sbss); |
53 | *(.scommon); |
53 | *(.scommon); |
54 | *(.bss); /* uninitialized static variables */ |
54 | *(.bss); /* uninitialized static variables */ |
55 | *(COMMON); /* global variables */ |
55 | *(COMMON); /* global variables */ |
56 | *(.reginfo); |
56 | *(.reginfo); |
57 | 57 | ||
58 | . = ALIGN(16384); |
58 | . = ALIGN(16384); |
59 | *(PT); /* page table */" > "$LINK" |
59 | *(PT); /* page table */" > "$LINK" |
60 | 60 | ||
- | 61 | echo ' |
|
- | 62 | /** @addtogroup arm32boot |
|
- | 63 | * @{ |
|
- | 64 | */ |
|
- | 65 | /** @file |
|
- | 66 | * @brief Components (kernel + tasks) related declarations. |
|
- | 67 | * |
|
- | 68 | * Generated by the <code>pack</code> script. This script packs all the |
|
- | 69 | * components (kernel + tasks) into one image (image.boot) and generates |
|
- | 70 | * a code that initializes an array of #component_t structs. |
|
- | 71 | */ |
|
- | 72 | ||
61 | echo '#ifndef ___COMPONENTS_H__ |
73 | #ifndef ___COMPONENTS_H__ |
62 | #define ___COMPONENTS_H__ |
74 | #define ___COMPONENTS_H__ |
63 | 75 | ||
- | 76 | /** Holds information about components packed to one image (kernel + tasks). */ |
|
64 | typedef struct { |
77 | typedef struct { |
- | 78 | /** Name. */ |
|
65 | char *name; |
79 | char *name; |
66 | 80 | /** Start address. */ |
|
67 | void *start; |
81 | void *start; |
- | 82 | /** End address. */ |
|
68 | void *end; |
83 | void *end; |
- | 84 | /** Size (in bytes). */ |
|
69 | unsigned int size; |
85 | unsigned int size; |
70 | } component_t;' > "$HEADER" |
86 | } component_t; |
- | 87 | ||
- | 88 | /** @} |
|
- | 89 | */ |
|
- | 90 | ||
- | 91 | ' > "$HEADER" |
|
71 | 92 | ||
72 | COUNT="0" |
93 | COUNT="0" |
73 | DATA="" |
94 | DATA="" |
74 | 95 | ||
75 | for TASK in "$@" ; do |
96 | for TASK in "$@" ; do |
76 | BASENAME="`basename "$TASK" | sed 's/^\(.*\)\.[^.]*$/\1/'`" |
97 | BASENAME="`basename "$TASK" | sed 's/^\(.*\)\.[^.]*$/\1/'`" |
77 | OBJECT="${BASENAME}.o" |
98 | OBJECT="${BASENAME}.o" |
78 | SYMBOL="`echo "_binary_$TASK" | tr "./" "__"`" |
99 | SYMBOL="`echo "_binary_$TASK" | tr "./" "__"`" |
79 | MACRO="`echo "$BASENAME" | tr [:lower:] [:upper:]`" |
100 | MACRO="`echo "$BASENAME" | tr [:lower:] [:upper:]`" |
80 | echo "$TASK -> $OBJECT" |
101 | echo "$TASK -> $OBJECT" |
81 | 102 | ||
82 | echo " |
103 | echo " |
83 | . = ALIGN(4096); |
104 | . = ALIGN(4096); |
84 | *(.${BASENAME}_image);" >> "$LINK" |
105 | *(.${BASENAME}_image);" >> "$LINK" |
85 | 106 | ||
86 | echo " |
107 | echo " |
87 | extern int ${SYMBOL}_start; |
108 | extern int ${SYMBOL}_start; |
88 | extern int ${SYMBOL}_end; |
109 | extern int ${SYMBOL}_end; |
89 | 110 | ||
90 | #define ${MACRO}_START ((void *) &${SYMBOL}_start) |
111 | #define ${MACRO}_START ((void *) &${SYMBOL}_start) |
91 | #define ${MACRO}_END ((void *) &${SYMBOL}_end) |
112 | #define ${MACRO}_END ((void *) &${SYMBOL}_end) |
92 | #define ${MACRO}_SIZE ((unsigned int) ${MACRO}_END - (unsigned int) ${MACRO}_START)" >> "$HEADER" |
113 | #define ${MACRO}_SIZE ((unsigned int) ${MACRO}_END - (unsigned int) ${MACRO}_START)" >> "$HEADER" |
93 | 114 | ||
94 | "$OBJCOPY" -I binary -O elf32-littlearm -B arm --rename-section ".data=.${BASENAME}_image" "$TASK" "$OBJECT" |
115 | "$OBJCOPY" -I binary -O elf32-littlearm -B arm --rename-section ".data=.${BASENAME}_image" "$TASK" "$OBJECT" |
95 | 116 | ||
96 | DATA="${DATA} |
117 | DATA="${DATA} |
97 | components[$COUNT].name = \"${BASENAME}\"; |
118 | components[$COUNT].name = \"${BASENAME}\"; |
98 | components[$COUNT].start = ${MACRO}_START; |
119 | components[$COUNT].start = ${MACRO}_START; |
99 | components[$COUNT].end = ${MACRO}_END; |
120 | components[$COUNT].end = ${MACRO}_END; |
100 | components[$COUNT].size = ${MACRO}_SIZE;"; |
121 | components[$COUNT].size = ${MACRO}_SIZE;"; |
101 | COUNT="`expr "$COUNT" + 1`" |
122 | COUNT="`expr "$COUNT" + 1`" |
102 | done |
123 | done |
103 | 124 | ||
104 | echo ' } |
125 | echo ' } |
105 | }' >> "$LINK" |
126 | }' >> "$LINK" |
106 | 127 | ||
107 | echo " |
128 | echo " |
108 | #define COMPONENTS $COUNT |
129 | #define COMPONENTS $COUNT |
109 | 130 | ||
110 | static void init_components(component_t components[]) |
131 | static void init_components(component_t components[]) |
111 | { |
132 | { |
112 | $DATA |
133 | $DATA |
113 | } |
134 | } |
114 | 135 | ||
115 | #endif |
136 | #endif |
- | 137 | ||
116 | " >> "$HEADER" |
138 | " >> "$HEADER" |
117 | 139 |