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",
38 Str "-fno-unwind-tables",
43 Str "-mabi=aapcs-linux",
44 Str "-msingle-pic-base",
45 Str "-mpic-register=r10",
46 Str "-DPIC_REGISTER=R10",
49 Str "-DTHREAD_REGISTER=R9",
50 Str "-D__ARM_ARCH_5__" ]
52 cFlags = ArchDefaults.commonCFlags
53 ++ ArchDefaults.commonFlags
56 cxxFlags = ArchDefaults.commonCxxFlags
57 ++ ArchDefaults.commonFlags
60 cDefines = ArchDefaults.cDefines options
62 ourLdFlags = [ Str "-Wl,-section-start,.text=0x400000",
63 Str "-Wl,-section-start,.data=0x600000",
67 ldFlags = ArchDefaults.ldFlags arch ++ ourLdFlags
68 ldCxxFlags = ArchDefaults.ldCxxFlags arch ++ ourLdFlags
70 stdLibs = ArchDefaults.stdLibs arch ++ [ Str "-lgcc" ]
72 options = (ArchDefaults.options arch archFamily) {
74 optCxxFlags = cxxFlags,
75 optDefines = cDefines,
77 [ PreDep InstallTree arch "/include/errors/errno.h",
78 PreDep InstallTree arch "/include/barrelfish_kpi/capbits.h",
79 PreDep InstallTree arch "/include/asmoffsets.h",
80 PreDep InstallTree arch "/include/romfs_size.h" ],
82 optLdCxxFlags = ldCxxFlags,
84 optInterconnectDrivers = ["lmp"],
85 optFlounderBackends = ["lmp"]
92 cCompiler = ArchDefaults.cCompiler arch compiler
93 cxxCompiler = ArchDefaults.cxxCompiler arch cxxcompiler
94 makeDepend = ArchDefaults.makeDepend arch compiler
95 makeCxxDepend = ArchDefaults.makeCxxDepend arch cxxcompiler
96 cToAssembler = ArchDefaults.cToAssembler arch compiler
97 assembler = ArchDefaults.assembler arch compiler
98 archive = ArchDefaults.archive arch
99 linker = ArchDefaults.linker arch compiler
100 cxxlinker = ArchDefaults.cxxlinker arch cxxcompiler
103 -- The kernel is "different"
106 kernelCFlags = [ Str s | s <- [ "-fno-builtin",
107 "-fno-unwind-tables",
119 "-Wstrict-prototypes",
120 "-Wold-style-definition",
121 "-Wmissing-prototypes",
122 "-Wmissing-declarations",
123 "-Wmissing-field-initializers",
124 "-Wno-implicit-function-declaration",
127 "-imacros deputy/nodeputy.h",
131 "-fomit-frame-pointer",
133 "-Wmissing-noreturn",
134 "-mno-apcs-stack-check",
135 "-mno-apcs-reentrant",
137 "-mpic-register=r10",
138 "-DPIC_REGISTER=R10",
140 "-DTHREAD_REGISTER=R9",
141 "-D__ARM_ARCH_5__" ]]
143 kernelLdFlags = [ Str "-Wl,-N",
144 NStr "-Wl,-Map,", Out arch "kernel.map",
147 Str "-Wl,--fatal-warnings",
154 -- Link the kernel (CPU Driver)
156 linkKernel :: Options -> [String] -> [String] -> String -> HRule
157 linkKernel opts objs libs kbin =
158 let linkscript = "/kernel/linker.lds"
159 kbootable = kbin ++ ".bin"
161 Rules [ Rule ([ Str compiler, Str Config.cOptFlags,
162 NStr "-T", In BuildTree arch linkscript,
163 Str "-o", Out arch kbin
167 [ In BuildTree arch o | o <- objs ]
169 [ In BuildTree arch l | l <- libs ]
173 -- Edit ELF header so qemu-system-arm will treat it as a Linux kernel
174 Rule [ In SrcTree "src" "/tools/arm-mkbootelf.sh",
175 Str objdump, In BuildTree arch kbin, Out arch (kbootable)],
176 -- Generate kernel assembly dump
177 Rule [ Str (objdump ++ " -d -M reg-names-raw"),
178 In SrcTree arch kbin, Str ">", Out arch (kbin ++ ".asm")],
180 NStr "-I", NoDep SrcTree "src" "/kernel/include/arch/xscale",
181 Str "-D__ASSEMBLER__",
182 Str "-P", In SrcTree "src" "/kernel/arch/xscale/linker.lds.in",