Skip to content

Commit 074d37d

Browse files
committed
Add a Raspberry Pi 2 static loader
1 parent 13f561b commit 074d37d

File tree

8 files changed

+643
-0
lines changed

8 files changed

+643
-0
lines changed

sys/boot/arm/rpi/Makefile

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# $FreeBSD$
2+
3+
.include <src.opts.mk>
4+
5+
PROG= loader.sym
6+
INTERNALPROG=
7+
8+
NEWVERSWHAT= "Raspberry Pi loader" ${MACHINE_ARCH}
9+
BINDIR?= /boot
10+
INSTALLFLAGS= -b
11+
WARNS?= 1
12+
13+
# Architecture-specific loader code
14+
SRCS= start.S \
15+
main.c \
16+
reloc.c \
17+
conf.c \
18+
vers.c \
19+
pl011_console.c
20+
21+
# Always add MI sources
22+
.PATH: ${.CURDIR}/../../common
23+
#.include "${.CURDIR}/../../common/Makefile.inc"
24+
SRCS+= console.c \
25+
panic.c
26+
CFLAGS+= -I${.CURDIR}/../../common
27+
CFLAGS+= -I.
28+
CFLAGS+= -I${.CURDIR}/../../../contrib/libfdt
29+
30+
FILES= loader.bin
31+
FILESMODE_loader.bin= ${BINMODE}
32+
CLEANFILES+= vers.c loader.sym
33+
34+
CFLAGS+= -ffreestanding -msoft-float
35+
36+
LDFLAGS= -nostdlib
37+
LDFLAGS+= -Wl,-Bsymbolic -shared
38+
#LDFLAGS+= -static
39+
LDFLAGS+= -Wl,-T ${.CURDIR}/ldscript.${MACHINE_CPUARCH}
40+
41+
# where to get libstand from
42+
CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/
43+
44+
# clang doesn't understand %D as a specifier to printf
45+
NO_WERROR.clang=
46+
47+
#DPADD= ${LIBSTAND}
48+
DDADD= ${.OBJDIR}/../../../../lib/libstand/libstand.a
49+
#LDADD= -lstand
50+
LDADD= ${.OBJDIR}/../../../../lib/libstand/libstand.a
51+
52+
vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version
53+
sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT}
54+
55+
loader.sym: ${.CURDIR}/ldscript.${MACHINE_CPUARCH}
56+
57+
loader.bin: loader.sym
58+
${OBJCOPY} -S -O binary loader.sym ${.TARGET}
59+
60+
MAN=
61+
62+
.include <bsd.prog.mk>

sys/boot/arm/rpi/conf.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*-
2+
* Copyright (c) 2008 Semihalf, Rafal Jaworowski
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions
7+
* are met:
8+
* 1. Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
* 2. Redistributions in binary form must reproduce the above copyright
11+
* notice, this list of conditions and the following disclaimer in the
12+
* documentation and/or other materials provided with the distribution.
13+
*
14+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17+
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24+
* SUCH DAMAGE.
25+
*
26+
*/
27+
28+
#include <sys/cdefs.h>
29+
__FBSDID("$FreeBSD$");
30+
31+
#include <stand.h>
32+
#include "bootstrap.h"
33+
34+
extern struct console pl011_console;
35+
36+
struct console *consoles[] = {
37+
&pl011_console,
38+
NULL
39+
};

sys/boot/arm/rpi/ldscript.arm

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
/* $FreeBSD$ */
2+
3+
OUTPUT_ARCH(arm)
4+
ENTRY(_start)
5+
SECTIONS
6+
{
7+
/* Read-only sections, merged into text segment: */
8+
. = 0; /*SIZEOF_HEADERS;*/
9+
ImageBase = .;
10+
.text :
11+
{
12+
*(.text)
13+
/* .gnu.warning sections are handled specially by elf32.em. */
14+
*(.gnu.warning)
15+
*(.gnu.linkonce.t*)
16+
} =0
17+
_etext = .;
18+
PROVIDE (etext = .);
19+
.interp : { *(.interp) }
20+
.hash : { *(.hash) }
21+
.dynsym : { *(.dynsym) }
22+
.dynstr : { *(.dynstr) }
23+
.gnu.version : { *(.gnu.version) }
24+
.gnu.version_d : { *(.gnu.version_d) }
25+
.gnu.version_r : { *(.gnu.version_r) }
26+
.rela.text :
27+
{ *(.rela.text) *(.rela.gnu.linkonce.t*) }
28+
.rela.data :
29+
{ *(.rela.data) *(.rela.gnu.linkonce.d*) }
30+
.rela.rodata :
31+
{ *(.rela.rodata) *(.rela.gnu.linkonce.r*) }
32+
.rela.got : { *(.rela.got) }
33+
.rela.got1 : { *(.rela.got1) }
34+
.rela.got2 : { *(.rela.got2) }
35+
.rela.ctors : { *(.rela.ctors) }
36+
.rela.dtors : { *(.rela.dtors) }
37+
.rela.init : { *(.rela.init) }
38+
.rela.fini : { *(.rela.fini) }
39+
.rela.bss : { *(.rela.bss) }
40+
.rela.plt : { *(.rela.plt) }
41+
.rela.sdata : { *(.rela.sdata) }
42+
.rela.sbss : { *(.rela.sbss) }
43+
.rela.sdata2 : { *(.rela.sdata2) }
44+
.rela.sbss2 : { *(.rela.sbss2) }
45+
.init : { *(.init) } =0
46+
.fini : { *(.fini) } =0
47+
.rodata : { *(.rodata) *(.gnu.linkonce.r*) }
48+
.rodata1 : { *(.rodata1) }
49+
.sdata2 : { *(.sdata2) }
50+
.sbss2 : { *(.sbss2) }
51+
/* Adjust the address for the data segment to the next page up. */
52+
. = ((. + 0x1000) & ~(0x1000 - 1));
53+
.data :
54+
{
55+
*(.data)
56+
*(.gnu.linkonce.d*)
57+
CONSTRUCTORS
58+
}
59+
.data1 : { *(.data1) }
60+
.got1 : { *(.got1) }
61+
.dynamic : { *(.dynamic) }
62+
/* Put .ctors and .dtors next to the .got2 section, so that the pointers
63+
get relocated with -mrelocatable. Also put in the .fixup pointers.
64+
The current compiler no longer needs this, but keep it around for 2.7.2 */
65+
PROVIDE (_GOT2_START_ = .);
66+
.got2 : { *(.got2) }
67+
PROVIDE (__CTOR_LIST__ = .);
68+
.ctors : { *(.ctors) }
69+
PROVIDE (__CTOR_END__ = .);
70+
PROVIDE (__DTOR_LIST__ = .);
71+
.dtors : { *(.dtors) }
72+
PROVIDE (__DTOR_END__ = .);
73+
PROVIDE (_FIXUP_START_ = .);
74+
.fixup : { *(.fixup) }
75+
PROVIDE (_FIXUP_END_ = .);
76+
PROVIDE (_GOT2_END_ = .);
77+
PROVIDE (_GOT_START_ = .);
78+
.got : { *(.got) }
79+
.got.plt : { *(.got.plt) }
80+
PROVIDE (_GOT_END_ = .);
81+
/* We want the small data sections together, so single-instruction offsets
82+
can access them all, and initialized data all before uninitialized, so
83+
we can shorten the on-disk segment size. */
84+
.sdata : { *(.sdata) }
85+
_edata = .;
86+
PROVIDE (edata = .);
87+
.plt : { *(.plt) }
88+
__bss_start = .;
89+
.sbss :
90+
{
91+
*(.sbss)
92+
*(.scommon)
93+
*(.dynsbss)
94+
}
95+
.bss :
96+
{
97+
*(.dynbss)
98+
*(.bss)
99+
*(COMMON)
100+
}
101+
_end = . ;
102+
/* Stabs debugging sections. */
103+
.stab 0 : { *(.stab) }
104+
.stabstr 0 : { *(.stabstr) }
105+
/* DWARF debug sections.
106+
Symbols in the DWARF debugging sections are relative to the beginning
107+
of the section so we begin them at 0. */
108+
/* DWARF 1 */
109+
.debug 0 : { *(.debug) }
110+
.line 0 : { *(.line) }
111+
/* GNU DWARF 1 extensions */
112+
.debug_srcinfo 0 : { *(.debug_srcinfo) }
113+
.debug_sfnames 0 : { *(.debug_sfnames) }
114+
/* DWARF 1.1 and DWARF 2 */
115+
.debug_aranges 0 : { *(.debug_aranges) }
116+
.debug_pubnames 0 : { *(.debug_pubnames) }
117+
/* DWARF 2 */
118+
.debug_info 0 : { *(.debug_info) }
119+
.debug_abbrev 0 : { *(.debug_abbrev) }
120+
.debug_line 0 : { *(.debug_line) }
121+
.debug_frame 0 : { *(.debug_frame) }
122+
.debug_str 0 : { *(.debug_str) }
123+
.debug_loc 0 : { *(.debug_loc) }
124+
.debug_macinfo 0 : { *(.debug_macinfo) }
125+
/* SGI/MIPS DWARF 2 extensions */
126+
.debug_weaknames 0 : { *(.debug_weaknames) }
127+
.debug_funcnames 0 : { *(.debug_funcnames) }
128+
.debug_typenames 0 : { *(.debug_typenames) }
129+
.debug_varnames 0 : { *(.debug_varnames) }
130+
/* These must appear regardless of . */
131+
}

0 commit comments

Comments
 (0)