e20176c23f66c26e40c9f65ae4bb543f233d7d35
[barrelfish] / hake / XScale.hs
1 --------------------------------------------------------------------------
2 -- Copyright (c) 2007-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, Universit√§tstasse 6, CH-8092 Zurich. Attn: Systems Group.
8 --
9 -- Architectural definitions for Barrelfish on ARMv5 ISA.
10 --
11 -- The build target is the XScale with XScale cpu.
12 --
13 --------------------------------------------------------------------------
14
15 module XScale where
16
17 import HakeTypes
18 import qualified Config
19 import qualified ArchDefaults
20
21 -------------------------------------------------------------------------
22 --
23 -- Architecture specific definitions for ARM
24 --
25 -------------------------------------------------------------------------
26
27 arch = "xscale"
28 archFamily = "arm"
29
30 compiler    = Config.arm_cc
31 objcopy     = Config.arm_objcopy
32 objdump     = Config.arm_objdump
33 ar          = Config.arm_ar
34 ranlib      = Config.arm_ranlib
35 cxxcompiler = Config.arm_cxx
36
37 ourCommonFlags = [ Str "-Wno-packed-bitfield-compat",
38                    Str "-fno-unwind-tables",
39                    Str "-fshort-enums",
40                    Str "-mcpu=xscale",
41                    Str "-mbig-endian",
42                    Str "-mapcs",
43                    Str "-mabi=aapcs-linux",
44                    Str "-msingle-pic-base",
45                    Str "-mpic-register=r10",
46                    Str "-DPIC_REGISTER=R10",
47                    Str "-fpic",
48                    Str "-ffixed-r9",
49                    Str "-DTHREAD_REGISTER=R9",
50                    Str "-D__ARM_ARCH_5__" ]
51
52 cFlags = ArchDefaults.commonCFlags 
53          ++ ArchDefaults.commonFlags
54          ++ ourCommonFlags
55
56 cxxFlags = ArchDefaults.commonCxxFlags
57            ++ ArchDefaults.commonFlags
58            ++ ourCommonFlags
59
60 cDefines = ArchDefaults.cDefines options
61
62 ourLdFlags = [ Str "-Wl,-section-start,.text=0x400000",
63                Str "-Wl,-section-start,.data=0x600000",
64                Str "-mcpu=xscale",
65                Str "-mbig-endian" ]
66
67 ldFlags = ArchDefaults.ldFlags arch ++ ourLdFlags
68 ldCxxFlags = ArchDefaults.ldCxxFlags arch ++ ourLdFlags
69
70 stdLibs = ArchDefaults.stdLibs arch ++ [ Str "-lgcc" ]
71
72 options = (ArchDefaults.options arch archFamily) { 
73             optFlags = cFlags,
74             optCxxFlags = cxxFlags,
75             optDefines = cDefines,
76             optDependencies = 
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" ],
81             optLdFlags = ldFlags,
82             optLdCxxFlags = ldCxxFlags,
83             optLibs = stdLibs,
84             optInterconnectDrivers = ["lmp"],
85             optFlounderBackends = ["lmp"]
86           }
87
88
89 --
90 -- Compilers
91 --
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
101
102 --
103 -- The kernel is "different"
104 --
105
106 kernelCFlags = [ Str s | s <- [ "-fno-builtin",
107                                 "-fno-unwind-tables",
108                                 "-fshort-enums",
109                                 "-nostdinc",
110                                 "-std=c99",
111                                 "-mcpu=xscale",
112                                 "-mbig-endian",
113                                 "-mapcs",
114                                 "-mabi=aapcs-linux",
115                                 "-fPIE",
116                                 "-U__linux__",
117                                 "-Wall",
118                                 "-Wshadow",
119                                 "-Wstrict-prototypes",
120                                 "-Wold-style-definition",
121                                 "-Wmissing-prototypes",
122                                 "-Wmissing-declarations",
123                                 "-Wmissing-field-initializers",
124                                 "-Wno-implicit-function-declaration",
125                                 "-Wredundant-decls",
126                                 "-Werror",
127                                 "-imacros deputy/nodeputy.h",
128                                 "-fpie",
129                                 "-fno-stack-check",
130                                 "-ffreestanding",
131                                 "-fomit-frame-pointer",
132                                 "-mno-long-calls",
133                                 "-Wmissing-noreturn",
134                                 "-mno-apcs-stack-check",
135                                 "-mno-apcs-reentrant",
136                                 "-msingle-pic-base",
137                                 "-mpic-register=r10",
138                                 "-DPIC_REGISTER=R10",
139                                 "-ffixed-r9",
140                                 "-DTHREAD_REGISTER=R9",
141                                 "-D__ARM_ARCH_5__" ]]
142
143 kernelLdFlags = [ Str "-Wl,-N",
144                   NStr "-Wl,-Map,", Out arch "kernel.map",
145                   Str "-fno-builtin",
146                   Str "-nostdlib",
147                   Str "-Wl,--fatal-warnings",
148                   Str "-mcpu=xscale",
149                   Str "-mbig-endian"
150                 ]
151
152
153 --
154 -- Link the kernel (CPU Driver)
155 --
156 linkKernel :: Options -> [String] -> [String] -> String -> HRule
157 linkKernel opts objs libs kbin =
158     let linkscript = "/kernel/linker.lds"
159         kbootable  = kbin ++ ".bin"
160     in
161         Rules [ Rule ([ Str compiler, Str Config.cOptFlags,
162                       NStr "-T", In BuildTree arch linkscript,
163                       Str "-o", Out arch kbin
164                     ]
165                     ++ (optLdFlags opts)
166                     ++
167                     [ In BuildTree arch o | o <- objs ]
168                     ++
169                     [ In BuildTree arch l | l <- libs ]
170                     ++
171                     [ Str "-lgcc" ]
172                    ),
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")],
179               Rule [ Str "cpp",
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",
183                      Out arch linkscript
184                    ]
185             ]