Merge branch 'arrakis'
[barrelfish] / kernel / Hakefile
1 --------------------------------------------------------------------------
2 -- Copyright (c) 2007-2013, 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, Universitaetstr. 6, CH-8092 Zurich.
8 -- Attn: Systems Group.
9 --
10 -- Hakefile for Barrelfish CPU drivers
11 --
12 --------------------------------------------------------------------------
13
14 --
15 -- Missing from this new Hakefile is the rule to build kernel debug
16 -- symbols, since this requires some thinking about naming
17 -- conventions.  Here is the rule we need:
18 --
19 --                Rule ( [ Str "OBJDUMP=objdump",
20 --                         In SrcTree "src" "/tools/gen-gdbscript.sh",
21 --                         In SrcTree "src" "/tools/debug.gdb.in",
22 --                         In BuildTree arch "../sbin/cpu",
23 --                         Str ">", Out arch "/debug.gdb"
24 --                        ] )
25
26 let
27   scheduler = case Config.scheduler of
28       Config.RR   -> "schedule_rr.c"
29       Config.RBED -> "schedule_rbed.c"
30   common_c = [ "gdb_stub.c", 
31                "capabilities.c", 
32                "cap_delete.c",
33                "dispatch.c",
34                scheduler, 
35                "kcb.c",
36                "memset.c", 
37                "memmove.c", 
38                "monitor.c",
39                "paging_generic.c",
40                "printf.c",
41                "startup.c",
42                "stdlib.c",
43                "string.c",
44                "sys_debug.c",
45                "syscall.c",
46                "wakeup.c",
47                "useraccess.c",
48                "coreboot.c" ]
49              ++ (if Config.microbenchmarks then ["microbenchmarks.c"] else [])
50              ++ (if Config.oneshot_timer then ["timer.c"] else [])
51   common_libs = [ "getopt", "mdb_kernel" ]
52
53   link_cpudriver arg = linkKernel opts name objs libs
54     where
55       opts = kernelOptions $ head $ Args.architectures arg
56       suffix = if "cpu" == Args.target arg
57              then ""
58              else "_" ++ (Args.target arg)
59       name = "cpu" ++ suffix
60       objs = [ objectFilePath opts f
61              | f <- (Args.assemblyFiles arg) ++ (Args.cFiles arg) ++ common_c ]
62       libs = (Args.addLibraries arg) ++ common_libs
63
64   cpudrivers arglist =
65     let
66       cafiles = Data.List.nub $ concat [ [ [ arch, cfile ]
67                                          | arch <- Args.architectures arg,
68                                            cfile <- common_c ++ (Args.cFiles arg) ]
69                                        | arg <- arglist ]
70       safiles = Data.List.nub $ concat [ [ [ arch, sfile ]
71                                          | arch <- Args.architectures arg,
72                                            sfile <- Args.assemblyFiles arg ]
73                                        | arg <- arglist ]
74       mafiles = Data.List.nub $ concat [ [ [ arch, mfile ]
75                                          | arch <- Args.architectures arg,
76                                            mfile <- Args.mackerelDevices arg ]
77                                        | arg <- arglist ]
78     in
79      ( [ compileCFile (kernelOptions a) f | [a,f] <- cafiles ]
80        ++
81        [ assembleSFile (kernelOptions a) f | [a,f] <- safiles ]
82        ++
83        [ mackerelDependencies (kernelOptions a) f [ c | [a,c] <- cafiles]
84        | [a,f] <- mafiles ]
85        ++
86        [ link_cpudriver arg | arg <- arglist ]
87      )
88
89   in cpudrivers [
90   --
91   -- Generic Intel/AMD amd64 64-bit x86 core
92   --
93   cpuDriver {
94      architectures = [ "x86_64" ],
95      assemblyFiles = [ "arch/x86_64/boot.S",
96                        "arch/x86_64/entry.S",
97                        "../usr/drivers/cpuboot/init_ap_x86_64.S",
98                        "../usr/drivers/cpuboot/init_ap_x86_32.S" ],
99      cFiles = [ "arch/x86_64/debug.c",
100                 "arch/x86_64/gdb_arch.c",
101                 "arch/x86_64/init.c",
102                 "arch/x86_64/irq.c",
103                 "arch/x86_64/startup_arch.c",
104                 "arch/x86_64/exec.c",
105                 "arch/x86_64/syscall.c",
106                 "arch/x86_64/paging.c",
107                 "arch/x86_64/vmkit.c" ,
108                 "arch/x86_64/vmx_checks.c",
109                 "arch/x86_64/vmx_vmkit.c",
110                 "arch/x86_64/svm_vmkit.c",
111                 "arch/x86_64/page_mappings_arch.c",
112                 "arch/x86/apic.c",
113                 "arch/x86/pic.c",
114                 "arch/x86/cmos.c",
115                 "arch/x86/misc.c",
116                 "arch/x86/serial.c",
117                 "arch/x86/multiboot.c",
118                 "arch/x86/conio.c",
119                 "arch/x86/syscall.c",
120                 "arch/x86/debugregs.c",
121                 "arch/x86/perfmon.c",
122                 "arch/x86/perfmon_intel.c",
123                 "arch/x86/perfmon_amd.c",
124                 "arch/x86/rtc.c",
125                 "arch/x86/timing.c",
126                 "arch/x86/startup_x86.c",
127                 "arch/x86/mcheck.c",
128                 "arch/x86/ipi_notify.c"
129               ] ++ (if Config.microbenchmarks then ["arch/x86_64/microbenchmarks.c"] else []),
130      mackerelDevices = [ "lpc_pic",
131                          "pc16550d",
132                          "ia32",
133                          "amd64",
134                          "xapic",
135                          "amd_vmcb",
136                          "cpuid",
137                          "lpc_rtc" ],
138      addLibraries = [ "elf_kernel" ]
139      },
140   --
141   -- Intel Xeon Phi (K1OM)
142   --
143   cpuDriver { 
144      architectures = [ "k1om" ],
145      assemblyFiles = [ "arch/x86_64/boot.S",
146                        "arch/x86_64/entry.S", 
147                        "../usr/drivers/cpuboot/init_ap_x86_64.S", 
148                        "../usr/drivers/cpuboot/init_ap_x86_32.S" ],
149      cFiles = [ "arch/x86/apic.c", 
150     --          "arch/x86/pic.c", 
151                 "arch/x86/misc.c",
152                 "arch/x86/multiboot.c", 
153                 "arch/x86/syscall.c", 
154                 "arch/x86/debugregs.c",
155                 "arch/x86/perfmon.c", 
156                 "arch/x86/perfmon_intel.c", 
157                 "arch/x86/perfmon_amd.c", 
158 --              "arch/x86/rtc.c", 
159                 "arch/x86/timing.c",
160                 "arch/x86/startup_x86.c", 
161                 "arch/x86/ipi_notify.c",
162                 "arch/x86_64/syscall.c",
163                 "arch/x86_64/debug.c", 
164                 "arch/x86_64/exec.c", 
165                 "arch/x86_64/irq.c",
166                 "arch/x86_64/paging.c",
167                 "arch/x86_64/page_mappings_arch.c",
168                 "arch/x86_64/gdb_arch.c", 
169                 "arch/k1om/init.c", 
170                 "arch/k1om/startup_arch.c", 
171                 "arch/k1om/mcheck.c", 
172                 "arch/k1om/serial.c",
173                 "arch/k1om/xeon_phi.c"
174
175               ] ++ (if Config.microbenchmarks then ["arch/x86_64/microbenchmarks.c"] else []),
176      mackerelDevices = [ "lpc_pic", 
177                          "ia32", 
178                          "amd64", 
179                          "xapic", 
180                          "cpuid", 
181                          "xeon_phi/xeon_phi_serial" ],
182      addLibraries = [ "elf_kernel" ] 
183      },
184
185   --
186   -- Generic Intel ia32 32-bit x86 core
187   --
188   cpuDriver {
189      architectures = [ "x86_32" ],
190      assemblyFiles = [ "arch/x86_32/boot.S",
191                        "arch/x86_32/entry.S",
192                        "arch/x86_32/pic.S",
193                        "../usr/drivers/cpuboot/init_ap_x86_32.S" ],
194      cFiles = [ "arch/x86_32/debug.c",
195                 "arch/x86_32/gdb_arch.c",
196                 "arch/x86_32/init.c",
197                 "arch/x86_32/irq.c",
198                 "arch/x86_32/startup_arch.c",
199                 "arch/x86_32/exec.c",
200                 "arch/x86_32/syscall.c",
201                 "arch/x86_32/paging.c",
202                 "arch/x86_32/page_mappings_arch.c",
203                 "arch/x86/apic.c",
204                 "arch/x86/pic.c",
205                 "arch/x86/cmos.c",
206                 "arch/x86/misc.c",
207                 "arch/x86/serial.c",
208                 "arch/x86/multiboot.c",
209                 "arch/x86/conio.c",
210                 "arch/x86/syscall.c",
211                 "arch/x86/debugregs.c",
212                 "arch/x86/perfmon.c",
213                 "arch/x86/perfmon_intel.c",
214                 "arch/x86/perfmon_amd.c",
215                 "arch/x86/rtc.c",
216                 "arch/x86/timing.c",
217                 "arch/x86/startup_x86.c",
218                 "arch/x86/ipi_notify.c"
219               ],
220      mackerelDevices = [ "lpc_pic",
221                          "pc16550d",
222                          "ia32",
223                          "amd64",
224                          "xapic",
225                          "cpuid",
226                          "lpc_rtc" ],
227      addLibraries = [ "elf_kernel" ]
228      },
229   --
230   -- Intel Gauss Lake P54C core in the Rock Creek Single-Chip Cloud Computer
231   --
232   cpuDriver {
233      architectures = [ "scc" ],
234      assemblyFiles = [ "arch/scc/boot.S",
235                        "arch/x86_32/entry.S",
236                        "arch/x86_32/pic.S" ],
237      cFiles = [ "arch/scc/rck.c",
238                 "arch/x86_32/debug.c",
239                 "arch/x86_32/gdb_arch.c",
240                 "arch/x86_32/init.c",
241                 "arch/x86_32/irq.c",
242                 "arch/x86_32/startup_arch.c",
243                 "arch/x86_32/exec.c",
244                 "arch/x86_32/syscall.c",
245                 "arch/x86_32/paging.c",
246                 "arch/x86_32/page_mappings_arch.c",
247                 "arch/x86/apic.c",
248                 "arch/x86/misc.c",
249                 "arch/x86/serial.c",
250                 "arch/x86/multiboot.c",
251                 "arch/x86/syscall.c",
252                 "arch/x86/debugregs.c",
253                 "arch/x86/timing.c",
254                 "arch/x86/startup_x86.c"
255               ],
256      mackerelDevices = [ "pc16550d",
257                          "ia32",
258                          "xapic",
259                          "rck",
260                          "eMAC",
261                          "cpuid",
262                          "lpc_rtc" ],
263      addLibraries = [ "elf_kernel" ]
264      },
265   --
266   -- Generic ARMv5 core, unused?
267   --
268   cpuDriver {
269      architectures = [ "armv5" ],
270      assemblyFiles = [ "arch/armv5/boot.S",
271                        "arch/armv5/exceptions.S" ],
272      cFiles = [ "arch/arm/exn.c", 
273                 "arch/arm/exec.c", 
274                 "arch/arm/misc.c", 
275                 "arch/arm/phys_mmap.c", 
276                 "arch/arm/syscall.c",
277                 "arch/armv5/init.c", 
278                 "arch/armv5/integrator.c", 
279                 "arch/armv5/kludges.c", 
280                 "arch/armv5/kputchar.c", 
281                 "arch/armv5/pl011_uart.c", 
282                 "arch/armv5/cp15.c",
283                 "arch/armv5/paging.c", 
284                 "arch/armv5/startup_arch.c" ], 
285      mackerelDevices = [ "arm", 
286                          "arm_icp_pit", 
287                          "arm_icp_pic0", 
288                          "pl011_uart" ],
289      addLibraries = [ "elf", "cpio" ]
290      },
291   --
292   -- ARM11MP ARMv6 core, currently unsupported.
293   -- XXX: reorganize sources for ARMv6
294   --
295   cpuDriver {
296      architectures = [ "arm11mp" ],
297      assemblyFiles = [ "arch/armv5/boot.S",
298                        "arch/armv5/exceptions.S",
299                        "arch/paging_cp.S" ],
300      cFiles = [ "arch/arm/exn.c", 
301                 "arch/arm/exec.c", 
302                 "arch/arm/misc.c", 
303                 "arch/arm/phys_mmap.c", 
304                 "arch/arm/syscall.c",
305                 "arch/armv5/init.c", 
306                 "arch/armv5/integrator.c", 
307                 "arch/armv5/kludges.c", 
308                 "arch/armv5/kputchar.c", 
309                 "arch/armv5/pl011_uart.c", 
310                 "arch/armv5/paging.c", 
311                 "arch/armv5/startup_arch.c" ], 
312      mackerelDevices = [ "arm", 
313                          "arm_icp_pit", 
314                          "arm_icp_pic0", 
315                          "pl011_uart" ],
316      addLibraries = [ "elf", "cpio" ]
317      },
318   --
319   -- ARM Gem5 Cortex-A series ARMv7 core
320   --
321   cpuDriver {
322     target = "arm_gem5",
323     architectures = [ "armv7" ],
324     assemblyFiles = [ "arch/arm_gem5/boot.S",
325                       "arch/armv7/cp15.S",
326                       "arch/armv7/exceptions.S" ],
327     cFiles = [ "arch/arm/exec.c", 
328                "arch/arm/misc.c", 
329                "arch/arm/phys_mmap.c",
330                "arch/arm/exn.c", 
331                "arch/arm/syscall.c",
332                "arch/arm_gem5/init.c", 
333                "arch/arm_gem5/integrator.c", 
334                "arch/arm_gem5/paging.c", 
335                "arch/arm_gem5/gem5_serial.c", 
336                "arch/arm_gem5/pl011_uart.c", 
337                "arch/arm_gem5/startup_arch.c", 
338                "arch/armv7/gic.c",
339                "arch/armv7/kludges.c", 
340                "arch/armv7/multiboot.c", 
341                "arch/armv7/paging.c",
342                "arch/armv7/irq.c", 
343                "arch/arm_gem5/start_aps.c", 
344                "arch/armv7/kputchar.c" ],
345     mackerelDevices = [ "arm", 
346                         "arm_icp_pit", 
347                         "pl011_uart", 
348                         "pl130_gic", 
349                         "sp804_pit", 
350                         "cortex_a9_pit", 
351                         "a9scu" ],
352     addLibraries = [ "elf", "cpio" ]
353     },
354   --
355   -- Intel ixp2800 XScale core
356   --
357   cpuDriver {
358      target = "ixp2800",
359      architectures = [ "xscale" ],
360      assemblyFiles = [ "arch/xscale/boot.S",
361                        "arch/armv5/exceptions.S"  ],
362      cFiles = [ "arch/arm/exn.c", 
363                 "arch/arm/exec.c", 
364                 "arch/arm/misc.c", 
365                 "arch/arm/phys_mmap.c", 
366                 "arch/arm/syscall.c", 
367                 -- according to the Xscale documentation, the MMU is a
368                 -- standard ARMv5 design, so we should be able to use
369                 -- the armv5 cp15 code. -SG, 8/1/13
370                 "arch/armv5/cp15.c",
371                 "arch/armv5/init.c", 
372                 "arch/armv5/kludges.c", 
373                 "arch/armv5/startup_arch.c", 
374                 "arch/xscale/ixp2800_integrator.c", 
375                 "arch/xscale/ixp2800_uart.c", 
376                 "arch/xscale/ixp2800_paging.c", 
377                 "arch/xscale/kputchar.c" ],
378      mackerelDevices = [ "arm",
379                          "ixp2800_icp_pit",
380                          "ixp2800_icp_pic0",
381                          "ixp2800_uart" ],
382      addLibraries = [ "elf", "cpio" ]
383      },
384   --
385   -- Broadcom OMAP44xx-series dual-core Cortex-A9 SoC
386   --
387   cpuDriver {
388      target = "omap44xx",
389      architectures = [ "armv7" ],
390      assemblyFiles = [ "arch/omap44xx/boot.S",
391                        "arch/armv7/cp15.S",
392                        "arch/armv7/exceptions.S" ],
393      cFiles = [ "arch/arm/exec.c", 
394                 "arch/arm/misc.c", 
395                 "arch/arm/exn.c", 
396                 "arch/arm/syscall.c",
397                 "arch/arm/phys_mmap.c",
398                 "arch/armv7/gic.c",
399                 "arch/armv7/kludges.c",
400                 "arch/armv7/multiboot.c",
401                 "arch/armv7/paging.c",
402                 "arch/armv7/irq.c",
403                 "arch/omap44xx/init.c",
404                 "arch/omap44xx/omap.c",
405                 "arch/omap44xx/paging.c",
406                 "arch/omap44xx/startup_arch.c",
407                 "arch/omap44xx/omap_uart.c",
408                 "arch/omap44xx/start_aps.c",
409                 "arch/omap44xx/spinlock.c",
410                 "arch/omap44xx/cortexm3_heteropanda.c", --will be empty if heteropanda = False
411                 "arch/armv7/kputchar.c"],
412      mackerelDevices = [ "arm",
413                          "arm_icp_pit",
414                          "pl130_gic",
415                          "sp804_pit",
416                          "cortex_a9_pit",
417                          "cortex_a9_gt",
418                          "a9scu",
419                          "omap/omap_uart",
420                          "omap/omap44xx_id",
421                          "omap/omap44xx_emif",
422                          "omap/omap44xx_gpio",
423                          "omap/omap44xx_sysctrl_padconf_core",
424                          "omap/omap44xx_sysctrl_padconf_wkup",
425                          "omap/omap44xx_hsusbhost",
426                          "omap/omap44xx_usbtllhs_config",
427                          "omap/omap44xx_scrm",
428                          "omap/omap44xx_ehci",
429                          "omap/omap44xx_ckgen_prm",
430                          "omap/omap44xx_l4per_cm2",
431                          "omap/omap44xx_l3init_cm2",
432                          "omap/omap44xx_spinlock",
433                          "omap/omap44xx_mmu",
434                          "omap/omap44xx_gpio"],
435      addLibraries = [ "elf", "cpio" ]
436      },
437   --
438   -- Broadcom OMAP44xx-series dual-core Cortex-M3 Coprocessor,
439   -- used to run a heterogenous system on the pandaboard
440   --
441
442   cpuDriver {
443      target = "omap44xx",
444      architectures = [ "armv7-m" ],
445      assemblyFiles = [ "arch/armv7-m/boot.S",
446                        "arch/armv7-m/exceptions.S" ],
447      cFiles = [ 
448                 "arch/arm/misc.c", 
449                 "arch/arm/phys_mmap.c",
450                 "arch/arm/syscall.c", 
451                 "arch/armv7/kludges.c", 
452                 "arch/armv7/multiboot.c", 
453                 "arch/armv7-m/exec.c", 
454                 "arch/armv7-m/exn.c", 
455                 "arch/armv7-m/init.c", 
456                 "arch/armv7-m/omap.c", 
457                 "arch/armv7-m/paging.c", 
458                 "arch/omap44xx/startup_arch.c", 
459                 "arch/omap44xx/omap_uart.c", 
460 --                "arch/omap44xx/start_aps.c", 
461                 "arch/armv7/kputchar.c", 
462                 "arch/omap44xx/spinlock.c"
463                 ],
464      mackerelDevices = [ "arm",
465                          "omap/omap44xx_cortex_m3_nvic",
466                          "omap/omap_uart",
467                          "omap/omap44xx_id",
468                          "omap/omap44xx_emif",
469                          "omap/omap44xx_gpio",
470                          "omap/omap44xx_mmu",
471                          "omap/omap44xx_spinlock"],
472      addLibraries = [ "elf", "cpio" ]
473      },
474   --
475   -- Applied Micro APM88xxxx series SoC,
476   -- used to run a heterogenous system on the pandaboard
477   --
478
479   cpuDriver {
480      target = "apm88xxxx",
481      architectures = [ "armv8" ],
482      assemblyFiles = [ "arch/apm88xxxx/boot.S",
483                        "arch/armv8/exceptions.S"
484                      ],
485      cFiles = [ "arch/armv8/exec.c",
486                 "arch/armv8/exn.c",
487                 "arch/armv8/irq.c",
488                 "arch/armv8/kludges.c",
489                 "arch/armv8/kputchar.c",
490                 "arch/armv8/misc.c",
491                 "arch/apm88xxxx/init.c",
492                 "arch/apm88xxxx/paging.c",
493                 "arch/apm88xxxx/uart.c" ],
494      mackerelDevices = [ "arm",
495                          "apm88xxxx/apm88xxxx_pc16550"
496                        ],
497      addLibraries = [ "elf", "cpio" ]
498      }
499   ]