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