Seperated the tool prefix from the tool name for ARMv8.
[barrelfish] / hake / ARMv8.hs
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, Haldeneggsteig 4, 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
16 module ARMv8 where
17
18 import HakeTypes
19 import Path
20 import qualified Config
21 import qualified ArchDefaults
22
23 -------------------------------------------------------------------------
24 --
25 -- Architecture specific definitions for ARM
26 --
27 -------------------------------------------------------------------------
28
29 arch = "armv8"
30 archFamily = "aarch64"
31
32 toolprefix = "aarch64-none-elf-"
33
34 compiler = toolprefix ++ "gcc"
35 objcopy  = toolprefix ++ "objcopy"
36 objdump  = toolprefix ++ "objdump"
37 ar       = toolprefix ++ "ar"
38 ranlib   = toolprefix ++ "ranlib"
39 cxxcompiler = toolprefix ++ "g++"
40
41 ourCommonFlags = [ Str "-fno-unwind-tables",
42                    Str "-Wno-packed-bitfield-compat",
43                    Str "-fno-stack-protector",
44                    Str "-mcpu=cortex-a57",
45                    Str "-march=armv8-a",
46                    Str "-mabi=lp64",
47                    Str "-DPIC_REGISTER=X10",
48                    Str "-fPIE",
49                    Str "-ffixed-r9",
50                    Str "-DTHREAD_REGISTER=X9",
51                    Str "-D__ARM_CORTEX__",
52                    Str "-D__ARM_ARCH_8A__",
53                    Str "-Wno-unused-but-set-variable",
54                    Str "-Wno-format"
55  ]
56
57 cFlags = ArchDefaults.commonCFlags 
58          ++ ArchDefaults.commonFlags
59          ++ ourCommonFlags
60
61 cxxFlags = ArchDefaults.commonCxxFlags
62            ++ ArchDefaults.commonFlags
63            ++ ourCommonFlags
64
65 cDefines = ArchDefaults.cDefines options
66
67 ourLdFlags = [ Str "-Wl,-section-start,.text=0x400000",
68                Str "-Wl,-section-start,.data=0x600000",
69                Str "-Wl,--build-id=none" ]
70
71 ldFlags = ArchDefaults.ldFlags arch ++ ourLdFlags
72 ldCxxFlags = ArchDefaults.ldCxxFlags arch ++ ourLdFlags
73
74 stdLibs = ArchDefaults.stdLibs arch ++ [ Str "-lgcc" ]
75
76 options = (ArchDefaults.options arch archFamily) { 
77             optFlags = cFlags,
78             optCxxFlags = cxxFlags,
79             optDefines = cDefines,
80             optDependencies = 
81                 [ PreDep InstallTree arch "/include/trace_definitions/trace_defs.h",
82                   PreDep InstallTree arch "/include/errors/errno.h",
83                   PreDep InstallTree arch "/include/barrelfish_kpi/capbits.h",
84                   PreDep InstallTree arch "/include/asmoffsets.h"
85                    ],
86             optLdFlags = ldFlags,
87             optLdCxxFlags = ldCxxFlags,
88             optLibs = stdLibs,
89             optInterconnectDrivers = ["lmp", "ump"],
90             optFlounderBackends = ["lmp", "ump"]
91           }
92
93 --
94 -- Compilers
95 --
96 cCompiler = ArchDefaults.cCompiler arch compiler
97 cxxCompiler = ArchDefaults.cxxCompiler arch cxxcompiler
98 makeDepend = ArchDefaults.makeDepend arch compiler
99 makeCxxDepend  = ArchDefaults.makeCxxDepend arch cxxcompiler
100 cToAssembler = ArchDefaults.cToAssembler arch compiler
101 assembler = ArchDefaults.assembler arch compiler
102 archive = ArchDefaults.archive arch
103 linker = ArchDefaults.linker arch compiler
104 cxxlinker = ArchDefaults.cxxlinker arch cxxcompiler
105
106
107 --
108 -- The kernel is "different"
109 --
110
111 kernelCFlags = [ Str s | s <- [ "-fno-builtin",
112                                 "-fno-unwind-tables",
113                                 "-nostdinc",
114                                 "-std=c99",
115                                 "-mcpu=cortex-a57",
116                                 "-march=armv8-a",
117                                 "-mabi=lp64",
118                                 "-fPIE",
119                                 "-U__linux__",
120                                 "-Wall",
121                                 "-Wshadow",
122                                 "-Wstrict-prototypes",
123                                 "-Wold-style-definition",
124                                 "-Wmissing-prototypes",
125                                 "-Wmissing-declarations",
126                                 "-Wmissing-field-initializers",
127                                 "-Wredundant-decls",
128                                 "-Werror",
129                                 "-imacros deputy/nodeputy.h",
130                                 "-fno-stack-check",
131                                 "-ffreestanding",
132                                 "-fomit-frame-pointer",
133                                 "-Wmissing-noreturn",
134                                 "-ffixed-r9",
135                                 "-DTHREAD_REGISTER=X9",
136                                 "-D__ARM_CORTEX__",
137                                 "-D__ARM_ARCH_8A__",
138                                 "-Wno-unused-but-set-variable",
139                                 "-Wno-format"
140                               ]]
141
142 kernelLdFlags = [ Str "-Wl,-N",
143                   Str "-fno-builtin",
144                   Str "-nostdlib",
145                   Str "-pie",
146                   Str "-Wl,--fatal-warnings"
147                 ]
148
149
150 --
151 -- Link the kernel (CPU Driver)
152 --
153 linkKernel :: Options -> [String] -> [String] -> String -> HRule
154 linkKernel opts objs libs name =
155     let linkscript = "/kernel/" ++ name ++ ".lds"
156         kernelmap  = "/kernel/" ++ name ++ ".map"
157         kasmdump   = "/kernel/" ++ name ++ ".asm"
158         kbinary    = "/sbin/" ++ name
159         kbootable  = kbinary ++ ".bin"
160     in
161         Rules [ Rule ([ Str compiler, Str Config.cOptFlags,
162                       NStr "-T", In BuildTree arch linkscript,
163                       Str "-o", Out arch kbinary,
164                       NStr "-Wl,-Map,", Out arch kernelmap
165                     ]
166                     ++ (optLdFlags opts)
167                     ++
168                     [ In BuildTree arch o | o <- objs ]
169                     ++
170                     [ In BuildTree arch l | l <- libs ]
171                     ++
172                     [ Str "-lgcc" ]
173                    ),
174               -- Generate kernel assembly dump
175               Rule [ Str objdump, 
176                      Str "-d", 
177                      Str "-M reg-names-raw",
178                      In BuildTree arch kbinary, 
179                      Str ">", Out arch kasmdump ],
180               Rule [ Str "cpp",
181                      NStr "-I", NoDep SrcTree "src" "/kernel/include/arch/armv8",
182                      Str "-D__ASSEMBLER__",
183                      Str "-P", In SrcTree "src" "/kernel/arch/armv8/linker.lds.in",
184                      Out arch linkscript
185                    ]
186             ]