1-------------------------------------------------------------------------- 2-- Copyright (c) 2007-2010, ETH Zurich. 3-- All rights reserved. 4-- 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. 8-- 9-- Architectural definitions for Barrelfish on ARMv5 ISA. 10-- 11-- The build target is the integratorcp board on QEMU with the default 12-- ARM926EJ-S cpu. 13-- 14-------------------------------------------------------------------------- 15 16module ARMv7 where 17 18import HakeTypes 19import qualified Config 20import qualified ArchDefaults 21 22------------------------------------------------------------------------- 23-- 24-- Architecture specific definitions for ARM 25-- 26------------------------------------------------------------------------- 27 28arch = "armv7" 29archFamily = "arm" 30 31compiler = Config.arm_cc 32objcopy = Config.arm_objcopy 33objdump = Config.arm_objdump 34ar = Config.arm_ar 35ranlib = Config.arm_ranlib 36cxxcompiler = Config.arm_cxx 37 38ourCommonFlags = [ Str "-fno-unwind-tables", 39 Str "-Wno-packed-bitfield-compat", 40 Str "-marm", 41 Str "-fno-stack-protector", 42 Str "-mcpu=cortex-a9", 43 Str "-march=armv7-a", 44 Str "-mapcs", 45 Str "-mabi=aapcs-linux", 46 Str "-mfloat-abi=hard", 47 Str "-mfpu=vfpv3", 48 Str "-msingle-pic-base", 49 Str "-mpic-register=r9", 50 Str "-DPIC_REGISTER=R9", 51 Str "-fPIE", 52 Str "-D__ARM_CORTEX__", 53 Str "-D__ARM_ARCH_7A__", 54 Str "-Wno-unused-but-set-variable", 55 Str "-Wno-suggest-attribute=noreturn", 56 Str "-Wno-format" 57 ] 58 59cFlags = ArchDefaults.commonCFlags 60 ++ ArchDefaults.commonFlags 61 ++ ourCommonFlags 62 63cxxFlags = ArchDefaults.commonCxxFlags 64 ++ ArchDefaults.commonFlags 65 ++ ourCommonFlags 66 67cDefines = ArchDefaults.cDefines options 68 69ourLdFlags = [ Str "-Wl,-section-start,.text=0x400000", 70 Str "-Wl,--build-id=none", 71 Str "-static" ] 72 73ldFlags = ArchDefaults.ldFlags arch ++ ourLdFlags 74ldCxxFlags = ArchDefaults.ldCxxFlags arch ++ ourLdFlags 75 76stdLibs = ArchDefaults.stdLibs arch 77 78options = (ArchDefaults.options arch archFamily) { 79 optFlags = cFlags, 80 optCxxFlags = cxxFlags, 81 optDefines = cDefines, 82 optDependencies = 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" 87 ], 88 optLdFlags = ldFlags, 89 optLdCxxFlags = ldCxxFlags, 90 optLibs = stdLibs, 91 optInterconnectDrivers = ["lmp", "ump", "local"], 92 optFlounderBackends = ["lmp", "ump", "local"] 93 } 94 95-- 96-- Compilers 97-- 98cCompiler = ArchDefaults.cCompiler arch compiler Config.cOptFlags 99cxxCompiler = ArchDefaults.cxxCompiler arch cxxcompiler Config.cOptFlags 100makeDepend = ArchDefaults.makeDepend arch compiler 101makeCxxDepend = ArchDefaults.makeCxxDepend arch cxxcompiler 102cToAssembler = ArchDefaults.cToAssembler arch compiler Config.cOptFlags 103assembler = ArchDefaults.assembler arch compiler Config.cOptFlags 104archive = ArchDefaults.archive arch 105linker = ArchDefaults.linker arch compiler 106strip = ArchDefaults.strip arch objcopy 107debug = ArchDefaults.debug arch objcopy 108cxxlinker = ArchDefaults.cxxlinker arch cxxcompiler 109 110-- 111-- The kernel is "different" 112-- 113 114kernelCFlags = [ Str s | s <- [ "-fno-builtin", 115 "-fno-unwind-tables", 116 "-nostdinc", 117 "-std=c99", 118 "-marm", 119 "-mcpu=cortex-a9", 120 "-march=armv7-a", 121 "-mfpu=vfpv3", 122 "-mapcs", 123 "-mabi=aapcs-linux", 124 "-mfloat-abi=hard", 125 "-fPIE", 126 "-U__linux__", 127 "-Wall", 128 "-Wshadow", 129 "-Wstrict-prototypes", 130 "-Wold-style-definition", 131 "-Wmissing-prototypes", 132 "-Wmissing-declarations", 133 "-Wmissing-field-initializers", 134 "-Wredundant-decls", 135 "-Werror", 136 "-imacros deputy/nodeputy.h", 137 "-fno-stack-check", 138 "-ffreestanding", 139 "-fomit-frame-pointer", 140 "-mno-long-calls", 141 "-Wmissing-noreturn", 142 "-mno-apcs-stack-check", 143 "-mno-apcs-reentrant", 144 "-msingle-pic-base", 145 "-mno-pic-data-is-text-relative", 146 "-mpic-register=r9", 147 "-DPIC_REGISTER=R9", 148 "-D__ARM_CORTEX__", 149 "-D__ARM_ARCH_7A__", 150 "-Wno-unused-but-set-variable", 151 "-Wno-suggest-attribute=noreturn", 152 "-Wno-format" ]] 153 154kernelLdFlags = [ Str "-Wl,-N", 155 Str "-fno-builtin", 156 Str "-nostdlib", 157 Str "-pie", 158 Str "-Wl,--fatal-warnings", 159 Str "-Wl,--dynamic-list-data", 160 Str "-Wl,--export-dynamic" 161 ] 162 163 164-- 165-- Link the kernel (CPU Driver) 166-- 167linkKernel :: Options -> [String] -> [String] -> String -> String -> HRule 168linkKernel 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" 174 in 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 180 ] 181 ++ (optLdFlags opts) 182 ++ 183 [ In BuildTree arch o | o <- objs ] 184 ++ 185 [ In BuildTree arch l | l <- libs ] 186 ++ 187 (ArchDefaults.kernelLibs arch) 188 ), 189 -- Generate kernel assembly dump 190 Rule [ Str objdump, 191 Str "-d", 192 Str "-M reg-names-raw", 193 In BuildTree arch kbinary, 194 Str ">", Out arch kasmdump ], 195 Rule [ Str "cpp", 196 NStr "-I", NoDep SrcTree "src" "/kernel/include/arch/armv7", 197 Str "-D__ASSEMBLER__", 198 Str "-P", 199 In SrcTree "src" 200 ("/kernel/arch/armv7/"++driverType++".lds.in"), 201 Out arch linkscript 202 ], 203 -- Produce a stripped binary 204 Rule [ Str objcopy, 205 Str "-g", 206 In BuildTree arch kbinary, 207 Out arch (kbinary ++ ".stripped") 208 ] 209 ] 210