Added: new boot.S, serial out for Xeon Phi
[barrelfish] / hake / K1om.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 x86_mic.
10 --
11 -- This architecture is used to build for the Intel Xeon Phi architecture.
12 -- 
13 --------------------------------------------------------------------------
14
15 module K1om where
16
17 import HakeTypes
18 import Path
19 import qualified Config
20 import qualified ArchDefaults
21
22 -------------------------------------------------------------------------
23 --
24 -- Architecture specific definitions for X86_64-k1om
25 --
26 -------------------------------------------------------------------------
27
28 arch = "k1om"
29 archFamily = "k1om"
30
31 --compiler = "x86_64-k1om-barrelfish-gcc"
32 --objcopy  = "x86_64-k1om-barrelfish-objcopy"
33 --objdump  = "x86_64-k1om-barrelfish-objdump"
34 --ar       = "x86_64-k1om-barrelfish-ar"
35 --ranlib   = "x86_64-k1om-barrelfish-ranlib"
36 --cxxcompiler = "x86_64-k1om-barrelfish-g++"
37
38
39 compiler = "gcc"
40 objcopy  = "objcopy"
41 objdump  = "objdump"
42 ar       = "ar"
43 ranlib   = "ranlib"
44 cxxcompiler = "g++"
45
46
47 ourCommonFlags = [ Str "-m64",
48                    Str "-mno-red-zone",
49                   -- Str "-fPIE",
50                    Str "-fPIC",
51                    Str "-fno-stack-protector", 
52                    Str "-Wno-unused-but-set-variable",
53                    Str "-Wno-packed-bitfield-compat",
54 -- the intel mic architecture has no "normal" SIMD extensions
55                    Str "-fno-tree-vectorize",
56                    Str "-mno-mmx",
57                    Str "-mno-sse",
58                    Str "-mno-sse2",
59                    Str "-mno-sse3",
60                    Str "-mno-sse4.1",
61                    Str "-mno-sse4.2",
62                    Str "-mno-sse4",
63                    Str "-mno-sse4a",
64                    Str "-mno-3dnow", 
65 -- specific Xeon Phi architecture
66 --                   Str "-Wa,-march=k1om",
67 --                   Str "-Wa,-mtune=k1om",
68                    Str "-D__x86__",
69                    Str "-D__k1om__" ]
70
71
72 cFlags = ArchDefaults.commonCFlags
73                ++ ArchDefaults.commonFlags
74                ++ ourCommonFlags
75
76 cxxFlags = ArchDefaults.commonCxxFlags
77                  ++ ArchDefaults.commonFlags
78                  ++ ourCommonFlags
79
80 cDefines = ArchDefaults.cDefines options
81
82 -- TODO> -m elf_i386
83 ourLdFlags = [ Str "-Wl,-z,max-page-size=0x1000",
84 --               Str "-Wl,-b,elf64-k1om",
85 --               Str "-Wl,--oformat,elf64-k1om",
86                Str "-Wl,--build-id=none",
87                Str "-m64" ]
88
89
90 ldFlags = ArchDefaults.ldFlags arch ++ ourLdFlags
91 ldCxxFlags = ArchDefaults.ldCxxFlags arch ++ ourLdFlags
92
93 options = (ArchDefaults.options arch archFamily) { 
94             optFlags = cFlags,
95             optCxxFlags = cxxFlags,
96             optDefines = cDefines,
97             optLdFlags = ldFlags,
98             optLdCxxFlags = ldCxxFlags,
99             optInterconnectDrivers = ["lmp", "ump", "multihop"],
100             optFlounderBackends = ["lmp", "ump", "multihop"]
101           }
102
103 --
104 -- The kernel is "different"
105 --
106
107 kernelCFlags = [ Str s | s <- [ "-fno-builtin",
108                                 "-nostdinc",
109                                 "-std=c99",
110                                 "-m64",
111                                 "-mno-red-zone",
112                                -- "-fPIE",
113                                 "-fPIC",
114                                 "-e startup_64",
115                                 "-fno-stack-protector",
116                                 "-U__linux__",
117                                 "-D__k1om__",
118                                 "-Wall",
119                                 "-Wshadow",
120                                 "-Wstrict-prototypes",
121                                 "-Wold-style-definition",
122                                 "-Wmissing-prototypes",
123                                 "-Wmissing-declarations",
124                                 "-Wmissing-field-initializers",
125                                 "-Wredundant-decls",
126                                 "-Wno-packed-bitfield-compat",
127                                 "-Wno-unused-but-set-variable",
128                                 "-Werror",
129                                 "-imacros deputy/nodeputy.h",
130                                 "-fno-tree-vectorize",
131                                 "-mno-mmx",
132                                 "-mno-sse",
133                                 "-mno-sse2",
134                                 "-mno-sse3",
135                                 "-mno-sse4.1",
136                                 "-mno-sse4.2",
137                                 "-mno-sse4",
138                                 "-mno-sse4a",
139                                 "-mno-3dnow" ] ]
140         
141
142 kernelLdFlags = [ Str s | s <- [ "-Wl,-N",
143                                  --"-Wl,-b,elf64-k1om",
144                                 -- "-Wl,-A,k1om",
145                                  --"-Wl,--oformat,elf64-k1om",
146                                  -- "-pie",
147                                  "-fPIC",
148                                  "-fno-builtin",
149                                  "-nostdlib",
150                                  "-Wl,--fatal-warnings",
151                                  "-m64" ] ]
152
153
154 ------------------------------------------------------------------------
155 --
156 -- Now, commands to actually do something
157 --
158 ------------------------------------------------------------------------
159
160 --
161 -- Compilers
162 --
163 cCompiler = ArchDefaults.cCompiler arch compiler
164 cxxCompiler = ArchDefaults.cxxCompiler arch cxxcompiler
165 makeDepend = ArchDefaults.makeDepend arch compiler
166 makeCxxDepend  = ArchDefaults.makeCxxDepend arch cxxcompiler
167 cToAssembler = ArchDefaults.cToAssembler arch compiler
168 assembler = ArchDefaults.assembler arch compiler
169 archive = ArchDefaults.archive arch
170 linker = ArchDefaults.linker arch compiler
171 cxxlinker = ArchDefaults.cxxlinker arch cxxcompiler
172
173 --
174 -- Link the kernel (CPU Driver)
175 -- 
176 linkKernel :: Options -> [String] -> [String] -> String -> HRule
177 linkKernel opts objs libs kbin = 
178     let linkscript = "/kernel/linker.lds"
179     in
180       Rules [ Rule ([ Str compiler, Str Config.cOptFlags,
181                       NStr "-T", In BuildTree arch "/kernel/linker.lds",
182                       Str "-o", Out arch kbin 
183                     ]
184                     ++ (optLdFlags opts)
185                     ++
186                     [ In BuildTree arch o | o <- objs ]
187                     ++
188                     [ In BuildTree arch l | l <- libs ]
189                     ++ 
190                     [ NL, NStr "/bin/echo -e '\\0002' | dd of=",
191                       Out arch kbin, 
192                       Str "bs=1 seek=16 count=1 conv=notrunc status=noxfer"
193                     ]
194                    ),
195               Rule [ Str "cpp", 
196                      NStr "-I", NoDep SrcTree "src" "/kernel/include/",
197                      Str "-D__ASSEMBLER__", 
198                      Str "-P", In SrcTree "src" "/kernel/arch/k1om/linker.lds.in",
199                      Out arch linkscript 
200                    ]
201             ]