1 --------------------------------------------------------------------------
2 -- Copyright (c) 2007-2010, ETH Zurich.
3 -- All rights reserved.
5 -- This file is distributed under the terms in the attached LICENSE file.
6 -- If you do not find this file, copies can be found by writing to:
7 -- ETH Zurich D-INFK, Universitaetstasse 6, CH-8092 Zurich. Attn: Systems Group.
9 -- Architectural definitions for Barrelfish on ARMv5 ISA.
11 -- The build target is the integratorcp board on QEMU with the default
14 --------------------------------------------------------------------------
19 import qualified Config
20 import qualified ArchDefaults
22 -------------------------------------------------------------------------
24 -- Architecture specific definitions for ARM
26 -------------------------------------------------------------------------
31 compiler = Config.arm_cc
32 objcopy = Config.arm_objcopy
33 objdump = Config.arm_objdump
35 ranlib = Config.arm_ranlib
36 cxxcompiler = Config.arm_cxx
38 ourCommonFlags = [ Str "-fno-unwind-tables",
39 Str "-Wno-packed-bitfield-compat",
41 Str "-fno-stack-protector",
42 Str "-mcpu=cortex-a9",
45 Str "-mabi=aapcs-linux",
46 Str "-mfloat-abi=hard",
48 Str "-msingle-pic-base",
49 Str "-mpic-register=r9",
50 Str "-DPIC_REGISTER=R9",
52 Str "-D__ARM_CORTEX__",
53 Str "-D__ARM_ARCH_7A__",
54 Str "-Wno-unused-but-set-variable",
55 Str "-Wno-suggest-attribute=noreturn",
59 cFlags = ArchDefaults.commonCFlags
60 ++ ArchDefaults.commonFlags
63 cxxFlags = ArchDefaults.commonCxxFlags
64 ++ ArchDefaults.commonFlags
67 cDefines = ArchDefaults.cDefines options
69 ourLdFlags = [ Str "-Wl,-section-start,.text=0x400000",
70 Str "-Wl,--build-id=none",
73 ldFlags = ArchDefaults.ldFlags arch ++ ourLdFlags
74 ldCxxFlags = ArchDefaults.ldCxxFlags arch ++ ourLdFlags
76 stdLibs = ArchDefaults.stdLibs arch
78 options = (ArchDefaults.options arch archFamily) {
80 optCxxFlags = cxxFlags,
81 optDefines = cDefines,
83 [ PreDep InstallTree arch "/include/trace_definitions/trace_defs.h",
84 PreDep InstallTree arch "/include/errors/errno.h",
85 PreDep InstallTree arch "/include/barrelfish_kpi/capbits.h",
86 PreDep InstallTree arch "/include/asmoffsets.h"
89 optLdCxxFlags = ldCxxFlags,
91 optInterconnectDrivers = ["lmp", "ump", "local"],
92 optFlounderBackends = ["lmp", "ump", "local"]
98 cCompiler = ArchDefaults.cCompiler arch compiler Config.cOptFlags
99 cxxCompiler = ArchDefaults.cxxCompiler arch cxxcompiler Config.cOptFlags
100 makeDepend = ArchDefaults.makeDepend arch compiler
101 makeCxxDepend = ArchDefaults.makeCxxDepend arch cxxcompiler
102 cToAssembler = ArchDefaults.cToAssembler arch compiler Config.cOptFlags
103 assembler = ArchDefaults.assembler arch compiler Config.cOptFlags
104 archive = ArchDefaults.archive arch
105 linker = ArchDefaults.linker arch compiler
106 strip = ArchDefaults.strip arch objcopy
107 debug = ArchDefaults.debug arch objcopy
108 cxxlinker = ArchDefaults.cxxlinker arch cxxcompiler
111 -- The kernel is "different"
114 kernelCFlags = [ Str s | s <- [ "-fno-builtin",
115 "-fno-unwind-tables",
129 "-Wstrict-prototypes",
130 "-Wold-style-definition",
131 "-Wmissing-prototypes",
132 "-Wmissing-declarations",
133 "-Wmissing-field-initializers",
136 "-imacros deputy/nodeputy.h",
139 "-fomit-frame-pointer",
141 "-Wmissing-noreturn",
142 "-mno-apcs-stack-check",
143 "-mno-apcs-reentrant",
145 "-mno-pic-data-is-text-relative",
150 "-Wno-unused-but-set-variable",
151 "-Wno-suggest-attribute=noreturn",
154 kernelLdFlags = [ Str "-Wl,-N",
158 Str "-Wl,--fatal-warnings",
159 Str "-Wl,--dynamic-list-data",
160 Str "-Wl,--export-dynamic"
165 -- Link the kernel (CPU Driver)
167 linkKernel :: Options -> [String] -> [String] -> String -> String -> HRule
168 linkKernel opts objs libs name driverType =
169 let linkscript = "/kernel/" ++ name ++ ".lds"
170 kernelmap = "/kernel/" ++ name ++ ".map"
171 kasmdump = "/kernel/" ++ name ++ ".asm"
172 kbinary = "/sbin/" ++ name
173 kbootable = kbinary ++ ".bin"
175 Rules [ Rule ([ Str compiler ] ++
176 map Str Config.cOptFlags ++
177 [ NStr "-T", In BuildTree arch linkscript,
178 Str "-o", Out arch kbinary,
179 NStr "-Wl,-Map,", Out arch kernelmap
183 [ In BuildTree arch o | o <- objs ]
185 [ In BuildTree arch l | l <- libs ]
187 (ArchDefaults.kernelLibs arch)
189 -- Generate kernel assembly dump
192 Str "-M reg-names-raw",
193 In BuildTree arch kbinary,
194 Str ">", Out arch kasmdump ],
196 NStr "-I", NoDep SrcTree "src" "/kernel/include/arch/armv7",
197 Str "-D__ASSEMBLER__",
200 ("/kernel/arch/armv7/"++driverType++".lds.in"),
203 -- Produce a stripped binary
206 In BuildTree arch kbinary,
207 Out arch (kbinary ++ ".stripped")