source: mainline/boot/arch/arm32/loader/pack@ 9b35499

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 9b35499 was 6b781c0, checked in by Jakub Jermar <jakub@…>, 18 years ago

Merge arm32 into trunk.

  • Property mode set to 100755
File size: 3.6 KB
Line 
1#! /bin/sh
2
3#
4# Copyright (C) 2007 Michal Kebrt
5# All rights reserved.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions
9# are met:
10#
11# - Redistributions of source code must retain the above copyright
12# notice, this list of conditions and the following disclaimer.
13# - Redistributions in binary form must reproduce the above copyright
14# notice, this list of conditions and the following disclaimer in the
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
17# derived from this software without specific prior written permission.
18#
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
21# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
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
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
28# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29#
30
31
32OBJCOPY="$1"
33LINK="_link.ld"
34HEADER="_components.h"
35
36shift 1
37
38echo "OUTPUT_FORMAT(\"elf32-littlearm\")
39
40ENTRY(start)
41
42SECTIONS {
43 .boot 0x0: AT (0) {
44 *(BOOTSTRAP);
45 *(.text);
46
47 *(.rodata);
48 *(.rodata.*);
49 *(.data); /* initialized data */
50 *(.sdata);
51 *(.sdata2);
52 *(.sbss);
53 *(.scommon);
54 *(.bss); /* uninitialized static variables */
55 *(COMMON); /* global variables */
56 *(.reginfo);
57
58 . = 0x4000;
59 *(PT); /* page table placed at 0x4000 */" > "$LINK"
60
61echo '
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
73#ifndef ___COMPONENTS_H__
74#define ___COMPONENTS_H__
75
76/** Holds information about components packed to one image (kernel + tasks). */
77typedef struct {
78 /** Name. */
79 char *name;
80 /** Start address. */
81 void *start;
82 /** End address. */
83 void *end;
84 /** Size (in bytes). */
85 unsigned int size;
86} component_t;
87
88/** @}
89*/
90
91' > "$HEADER"
92
93COUNT="0"
94DATA=""
95
96for TASK in "$@" ; do
97 BASENAME="`basename "$TASK" | sed 's/^\(.*\)\.[^.]*$/\1/'`"
98 OBJECT="${BASENAME}.o"
99 SYMBOL="`echo "_binary_$TASK" | tr "./" "__"`"
100 MACRO="`echo "$BASENAME" | tr [:lower:] [:upper:]`"
101 echo "$TASK -> $OBJECT"
102
103 echo "
104 . = ALIGN(4096);
105 *(.${BASENAME}_image);" >> "$LINK"
106
107 echo "
108extern int ${SYMBOL}_start;
109extern int ${SYMBOL}_end;
110
111#define ${MACRO}_START ((void *) &${SYMBOL}_start)
112#define ${MACRO}_END ((void *) &${SYMBOL}_end)
113#define ${MACRO}_SIZE ((unsigned int) ${MACRO}_END - (unsigned int) ${MACRO}_START)" >> "$HEADER"
114
115 "$OBJCOPY" -I binary -O elf32-littlearm -B arm --rename-section ".data=.${BASENAME}_image" "$TASK" "$OBJECT"
116
117 DATA="${DATA}
118 components[$COUNT].name = \"${BASENAME}\";
119 components[$COUNT].start = ${MACRO}_START;
120 components[$COUNT].end = ${MACRO}_END;
121 components[$COUNT].size = ${MACRO}_SIZE;";
122 COUNT="`expr "$COUNT" + 1`"
123done
124
125echo ' }
126}' >> "$LINK"
127
128echo "
129#define COMPONENTS $COUNT
130
131/** Initializes array of components. */
132static void init_components(component_t components[])
133{
134$DATA
135}
136
137#endif
138
139" >> "$HEADER"
Note: See TracBrowser for help on using the repository browser.