1-------------------------------------------------------------------------- 2-- Copyright (c) 2015, 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, CAB F.78, Universitaetstrasse 6, CH-8092 Zurich. 8-- Attn: Systems Group. 9-- 10-- Architectural definitions for Barrelfish on ARMv8. 11-- 12-------------------------------------------------------------------------- 13 14module ARMv8 where 15 16import HakeTypes 17import qualified Config 18import qualified ArchDefaults 19import Data.Char 20 21------------------------------------------------------------------------- 22-- 23-- Architecture specific definitions for ARM 24-- 25------------------------------------------------------------------------- 26 27arch = "armv8" 28archFamily = "aarch64" 29 30compiler = Config.aarch64_cc 31objcopy = Config.aarch64_objcopy 32objdump = Config.aarch64_objdump 33ar = Config.aarch64_ar 34ranlib = Config.aarch64_ranlib 35cxxcompiler = Config.aarch64_cxx 36 37ourCommonFlags = [ Str "-fno-unwind-tables", 38 Str "-Wno-packed-bitfield-compat", 39 Str "-fno-stack-protector", 40 Str "-mcpu=cortex-a57", 41 Str "-march=armv8-a", 42 Str "-mabi=lp64", 43 Str "-mstrict-align", 44 Str "-fPIE", 45 -- The dispatcher needs a scratch register on ARMv8. 46 -- We use r18, which is reserved as the 'platform register' 47 -- by the ARM-64 ABI. 48 Str "-ffixed-x18", 49 Str "-D__ARM_CORTEX__", 50 Str "-D__ARM_ARCH_8A__", 51 -- Str "-DPREFER_SIZE_OVER_SPEED", 52 Str "-Wno-unused-but-set-variable", 53 Str "-Wno-format" 54 ] 55 56cFlags = ArchDefaults.commonCFlags 57 ++ ArchDefaults.commonFlags 58 ++ ourCommonFlags 59 60cxxFlags = ArchDefaults.commonCxxFlags 61 ++ ArchDefaults.commonFlags 62 ++ ourCommonFlags 63 ++ [Str "-std=gnu++11"] 64 65cDefines = ArchDefaults.cDefines options 66 67ourLdFlags = [ Str "-Wl,--build-id=none", Str "-static" ] 68 69ldFlags = ArchDefaults.ldFlags arch ++ ourLdFlags 70ldCxxFlags = ArchDefaults.ldCxxFlags arch ++ ourLdFlags 71 72stdLibs = ArchDefaults.stdLibs arch 73 74options = (ArchDefaults.options arch archFamily) { 75 optFlags = cFlags, 76 optCxxFlags = cxxFlags, 77 optDefines = cDefines, 78 optDependencies = 79 [ PreDep InstallTree arch "/include/trace_definitions/trace_defs.h", 80 PreDep InstallTree arch "/include/errors/errno.h", 81 PreDep InstallTree arch "/include/barrelfish_kpi/capbits.h", 82 PreDep InstallTree arch "/include/asmoffsets.h" 83 ], 84 optLdFlags = ldFlags, 85 optLdCxxFlags = ldCxxFlags, 86 optLibs = stdLibs, 87 optInterconnectDrivers = ["lmp", "ump", "multihop", "local"], 88 optFlounderBackends = ["lmp", "ump", "multihop", "local"] 89 } 90 91-- 92-- Compilers 93-- 94cCompiler = ArchDefaults.cCompiler arch compiler Config.cOptFlags 95cxxCompiler = ArchDefaults.cxxCompiler arch cxxcompiler Config.cOptFlags 96makeDepend = ArchDefaults.makeDepend arch compiler 97makeCxxDepend = ArchDefaults.makeCxxDepend arch cxxcompiler 98cToAssembler = ArchDefaults.cToAssembler arch compiler Config.cOptFlags 99assembler = ArchDefaults.assembler arch compiler Config.cOptFlags 100archive = ArchDefaults.archive arch 101linker = ArchDefaults.linker arch compiler 102ldtLinker = ArchDefaults.ldtLinker arch compiler 103strip = ArchDefaults.strip arch objcopy 104debug = ArchDefaults.debug arch objcopy 105cxxlinker = ArchDefaults.cxxlinker arch cxxcompiler 106ldtCxxlinker = ArchDefaults.ldtCxxlinker arch cxxcompiler 107 108 109-- 110-- The kernel needs different flags 111-- 112 113kernelCFlags = [ Str s | s <- [ "-fno-builtin", 114 "-fno-unwind-tables", 115 "-nostdinc", 116 "-std=c99", 117 "-mcpu=cortex-a57", 118 "-march=armv8-a+nofp", 119 "-mgeneral-regs-only", 120 "-mabi=lp64", 121 "-mstrict-align", 122 "-U__linux__", 123 "-Wall", 124 "-Wshadow", 125 "-Wstrict-prototypes", 126 "-Wold-style-definition", 127 "-Wmissing-prototypes", 128 "-Wmissing-declarations", 129 "-Wmissing-field-initializers", 130 "-Wredundant-decls", 131 "-Werror", 132 "-imacros deputy/nodeputy.h", 133 "-fno-stack-check", 134 "-ffreestanding", 135 "-fomit-frame-pointer", 136 "-Wmissing-noreturn", 137 "-D__ARM_CORTEX__", 138 "-D__ARM_ARCH_8A__", 139 "-DPREFER_SIZE_OVER_SPEED", 140 "-Wno-unused-but-set-variable", 141 "-Wno-format" 142 ]] 143 144kernelLdFlags = [ Str "-Wl,-N", 145 Str "-pie", 146 Str "-fno-builtin", 147 Str "-nostdlib", 148 Str "-Wl,--fatal-warnings", 149 Str "-Wl,--build-id=none" 150 ] 151 152 153-- 154-- Link the kernel (CPU Driver) 155-- 156linkKernel :: Options -> [String] -> [String] -> String -> String -> HRule 157linkKernel opts objs libs name driverType= 158 let linkscript = "/kernel/" ++ name ++ ".lds" 159 kernelmap = "/kernel/" ++ name ++ ".map" 160 kasmdump = "/kernel/" ++ name ++ ".asm" 161 kbinary = "/sbin/" ++ name 162 kdebug = kbinary ++ ".debug" 163 kfull = kbinary ++ ".full" 164 in 165 Rules ([ Rule ([ Str compiler ] ++ 166 map Str Config.cOptFlags ++ 167 [ NStr "-T", In BuildTree arch linkscript, 168 Str "-o", 169 Out arch kfull, 170 NStr "-Wl,-Map,", Out arch kernelmap 171 ] 172 ++ (optLdFlags opts) 173 ++ 174 [ In BuildTree arch o | o <- objs ] 175 ++ 176 [ In BuildTree arch l | l <- libs ] 177 ++ 178 (ArchDefaults.kernelLibs arch) 179 ++ 180 [ NL, NStr "bash -c \"echo -e '\\0002'\" | dd of=", 181 Out arch kfull, 182 Str "bs=1 seek=16 count=1 conv=notrunc status=noxfer" 183 ] 184 ), 185 Rule $ strip opts kfull kdebug kbinary, 186 Rule $ debug opts kfull kdebug, 187 -- Generate kernel assembly dump 188 Rule [ Str objdump, 189 Str "-d", 190 Str "-M reg-names-raw", 191 In BuildTree arch kbinary, 192 Str ">", 193 Out arch kasmdump ], 194 Rule [ Str "cpp", 195 NStr "-I", NoDep SrcTree "src" "/kernel/include/arch/armv8", 196 NStr "-I", NoDep SrcTree "src" "/kernel/include", 197 Str "-D__ASSEMBLER__", 198 Str "-P", In SrcTree "src" 199 ("/kernel/arch/armv8/"++driverType++".lds.in"), 200 Out arch linkscript 201 ] 202 ] ++ [ Phony ((map toUpper arch) ++ "_All") False 203 [ Dep BuildTree arch kbinary]]) 204