1 --------------------------------------------------------------------------
2 -- Copyright (c) 2007-2015, 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, Universitätstasse 6, CH-8092 Zurich. Attn: Systems Group.
9 -- Architectural definitions for Barrelfish on ARMv5 ISA.
11 -- The build target is the XScale with XScale cpu.
13 --------------------------------------------------------------------------
18 import qualified Config
19 import qualified ArchDefaults
21 -------------------------------------------------------------------------
23 -- Architecture specific definitions for ARM
25 -------------------------------------------------------------------------
30 compiler = Config.arm_cc
31 objcopy = Config.arm_objcopy
32 objdump = Config.arm_objdump
34 ranlib = Config.arm_ranlib
35 cxxcompiler = Config.arm_cxx
37 ourCommonFlags = [ Str "-Wno-packed-bitfield-compat",
39 Str "-fno-unwind-tables",
44 Str "-mabi=aapcs-linux",
45 Str "-msingle-pic-base",
46 Str "-mpic-register=r10",
47 Str "-DPIC_REGISTER=R10",
50 Str "-DTHREAD_REGISTER=R9",
51 Str "-D__ARM_ARCH_5__" ]
53 cFlags = ArchDefaults.commonCFlags
54 ++ ArchDefaults.commonFlags
57 cxxFlags = ArchDefaults.commonCxxFlags
58 ++ ArchDefaults.commonFlags
61 cDefines = ArchDefaults.cDefines options
63 ourLdFlags = [ Str "-Wl,-section-start,.text=0x400000",
64 Str "-Wl,-section-start,.data=0x600000",
68 ldFlags = ArchDefaults.ldFlags arch ++ ourLdFlags
69 ldCxxFlags = ArchDefaults.ldCxxFlags arch ++ ourLdFlags
71 stdLibs = ArchDefaults.stdLibs arch ++ [ Str "-lgcc" ]
73 options = (ArchDefaults.options arch archFamily) {
75 optCxxFlags = cxxFlags,
76 optDefines = cDefines,
78 [ PreDep InstallTree arch "/include/errors/errno.h",
79 PreDep InstallTree arch "/include/barrelfish_kpi/capbits.h",
80 PreDep InstallTree arch "/include/asmoffsets.h",
81 PreDep InstallTree arch "/include/romfs_size.h" ],
83 optLdCxxFlags = ldCxxFlags,
85 optInterconnectDrivers = ["lmp"],
86 optFlounderBackends = ["lmp"]
93 cCompiler = ArchDefaults.cCompiler arch compiler Config.cOptFlags
94 cxxCompiler = ArchDefaults.cxxCompiler arch cxxcompiler Config.cOptFlags
95 makeDepend = ArchDefaults.makeDepend arch compiler
96 makeCxxDepend = ArchDefaults.makeCxxDepend arch cxxcompiler
97 cToAssembler = ArchDefaults.cToAssembler arch compiler Config.cOptFlags
98 assembler = ArchDefaults.assembler arch compiler Config.cOptFlags
99 archive = ArchDefaults.archive arch
100 linker = ArchDefaults.linker arch compiler
101 cxxlinker = ArchDefaults.cxxlinker arch cxxcompiler
104 -- The kernel is "different"
107 kernelCFlags = [ Str s | s <- [ "-fno-builtin",
108 "-fno-unwind-tables",
120 "-Wstrict-prototypes",
121 "-Wold-style-definition",
122 "-Wmissing-prototypes",
123 "-Wmissing-declarations",
124 "-Wmissing-field-initializers",
125 "-Wno-implicit-function-declaration",
128 "-imacros deputy/nodeputy.h",
132 "-fomit-frame-pointer",
134 "-Wno-missing-noreturn",
136 "-mno-apcs-stack-check",
137 "-mno-apcs-reentrant",
139 "-mpic-register=r10",
140 "-DPIC_REGISTER=R10",
142 "-DTHREAD_REGISTER=R9",
143 "-D__ARM_ARCH_5__" ]]
145 kernelLdFlags = [ Str "-Wl,-N",
146 NStr "-Wl,-Map,", Out arch "kernel.map",
149 Str "-Wl,--fatal-warnings",
156 -- Link the kernel (CPU Driver)
158 linkKernel :: Options -> [String] -> [String] -> String -> HRule
159 linkKernel opts objs libs kbin =
160 let linkscript = "/kernel/linker.lds"
161 kbootable = kbin ++ ".bin"
163 Rules [ Rule ([ Str compiler ] ++
164 map Str Config.cOptFlags ++
165 [ NStr "-T", In BuildTree arch linkscript,
166 Str "-o", Out arch kbin
170 [ In BuildTree arch o | o <- objs ]
172 [ In BuildTree arch l | l <- libs ]
176 -- Edit ELF header so qemu-system-arm will treat it as a Linux kernel
177 Rule [ In SrcTree "src" "/tools/arm-mkbootelf.sh",
178 Str objdump, In BuildTree arch kbin, Out arch (kbootable)],
179 -- Generate kernel assembly dump
180 Rule [ Str (objdump ++ " -d -M reg-names-raw"),
181 In SrcTree arch kbin, Str ">", Out arch (kbin ++ ".asm")],
183 NStr "-I", NoDep SrcTree "src" "/kernel/include/arch/xscale",
184 Str "-D__ASSEMBLER__",
185 Str "-P", In SrcTree "src" "/kernel/arch/xscale/linker.lds.in",