e0dbd27b2864b5d7cafedc34e88e5b77ce70e951
[barrelfish] / kernel / Hakefile
1 --------------------------------------------------------------------------
2 -- Copyright (c) 2007-2012, 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
27
28 let
29   scheduler = case Config.scheduler of
30       Config.RR   -> "schedule_rr.c"
31       Config.RBED -> "schedule_rbed.c"
32   common_c = [ "gdb_stub.c", 
33                "capabilities.c", 
34                "dispatch.c",
35                scheduler, 
36                "memset.c", 
37                "memmove.c", 
38                "printf.c",
39                "startup.c", 
40                "stdlib.c", 
41                "string.c", 
42                "syscall.c",
43                "wakeup.c", 
44                "useraccess.c" ]
45              ++ (if Config.microbenchmarks then ["microbenchmarks.c"] else [])
46              ++ (if Config.oneshot_timer then ["timer.c"] else [])
47   common_libs = [ "getopt", "mdb_kernel" ]
48   
49   link_cpudriver arg = linkKernel opts name objs libs
50     where 
51       opts = (kernelOptions $ head $ Args.architectures arg)
52       suffix = if "cpu" == Args.target arg 
53              then "" 
54              else "_" ++ (Args.target arg)
55       name = "cpu" ++ suffix
56       objs = [ objectFilePath opts f 
57              | f <- (Args.assemblyFiles arg) ++ (Args.cFiles arg) ++ common_c ] 
58       libs = (Args.addLibraries arg) ++ common_libs
59     
60   cpudrivers arglist = 
61     let 
62       cafiles = List.nub $ concat [ [ [ arch, cfile ] 
63                                     | arch <- Args.architectures arg,
64                                       cfile <- common_c ++ (Args.cFiles arg) ]
65                                   | arg <- arglist ]
66       safiles = List.nub $ concat [ [ [ arch, sfile ]
67                                     | arch <- Args.architectures arg,
68                                       sfile <- Args.assemblyFiles arg ]
69                                   | arg <- arglist ]
70       mafiles = List.nub $ concat [ [ [ arch, mfile ]
71                                     | arch <- Args.architectures arg,
72                                       mfile <- Args.mackerelDevices arg ]
73                                   | arg <- arglist ]
74     in
75      ( [ compileCFile (kernelOptions a) f | [a,f] <- cafiles ]
76        ++
77        [ assembleSFile (kernelOptions a) f | [a,f] <- safiles ]
78        ++
79        [ mackerelDependencies (kernelOptions a) f [ c | [a,c] <- cafiles]  
80        | [a,f] <- mafiles ]
81        ++
82        [ link_cpudriver arg | arg <- arglist ]
83      )
84          
85   in cpudrivers [
86   --
87   -- Generic Intel/AMD amd64 64-bit x86 core
88   --
89   cpuDriver { 
90      architectures = [ "x86_64" ],
91      assemblyFiles = [ "arch/x86_64/boot.S", 
92                        "arch/x86_64/entry.S", 
93                        "arch/x86/init_ap_x86_64.S", 
94                        "arch/x86/init_ap_x86_32.S" ],
95      cFiles = [ "arch/x86_64/debug.c", 
96                 "arch/x86_64/gdb_arch.c", 
97                 "arch/x86_64/init.c", 
98                 "arch/x86_64/irq.c",
99                 "arch/x86_64/startup_arch.c", 
100                 "arch/x86_64/exec.c", 
101                 "arch/x86_64/syscall.c", 
102                 "arch/x86_64/paging.c",
103                 "arch/x86_64/vmkit.c" , 
104                 "arch/x86_64/page_mappings_arch.c",
105                 "arch/x86/apic.c", 
106                 "arch/x86/pic.c", 
107                 "arch/x86/start_aps.c", 
108                 "arch/x86/cmos.c", 
109                 "arch/x86/misc.c",
110                 "arch/x86/serial.c", 
111                 "arch/x86/multiboot.c", 
112                 "arch/x86/conio.c", 
113                 "arch/x86/syscall.c", 
114                 "arch/x86/debugregs.c",
115                 "arch/x86/perfmon.c", 
116                 "arch/x86/perfmon_intel.c", 
117                 "arch/x86/perfmon_amd.c", 
118                 "arch/x86/rtc.c", 
119                 "arch/x86/timing.c",
120                 "arch/x86/startup_x86.c", 
121                 "arch/x86/mcheck.c", 
122                 "arch/x86/ipi_notify.c"
123               ],
124      mackerelDevices = [ "lpc_pic", 
125                          "pc16550d", 
126                          "ia32", 
127                          "amd64", 
128                          "xapic", 
129                          "amd_vmcb", 
130                          "cpuid", 
131                          "lpc_rtc" ],
132      addLibraries = [ "elf_kernel" ]
133      },
134   --
135   -- Generic Intel ia32 32-bit x86 core
136   --
137   cpuDriver { 
138      architectures = [ "x86_32" ],
139      assemblyFiles = [ "arch/x86_32/boot.S", 
140                        "arch/x86_32/entry.S", 
141                        "arch/x86_32/pic.S",
142                        "arch/x86/init_ap_x86_64.S", 
143                        "arch/x86/init_ap_x86_32.S" ],
144      cFiles = [ "arch/x86_32/debug.c", 
145                 "arch/x86_32/gdb_arch.c", 
146                 "arch/x86_32/init.c", 
147                 "arch/x86_32/irq.c",
148                 "arch/x86_32/startup_arch.c", 
149                 "arch/x86_32/exec.c", 
150                 "arch/x86_32/syscall.c", 
151                 "arch/x86_32/paging.c",
152                 "arch/x86_32/page_mappings_arch.c",
153                 "arch/x86/apic.c", 
154                 "arch/x86/pic.c", 
155                 "arch/x86/start_aps.c", 
156                 "arch/x86/cmos.c", 
157                 "arch/x86/misc.c",
158                 "arch/x86/serial.c", 
159                 "arch/x86/multiboot.c", 
160                 "arch/x86/conio.c", 
161                 "arch/x86/syscall.c", 
162                 "arch/x86/debugregs.c",
163                 "arch/x86/perfmon.c", 
164                 "arch/x86/perfmon_intel.c", 
165                 "arch/x86/perfmon_amd.c", 
166                 "arch/x86/rtc.c", 
167                 "arch/x86/timing.c",
168                 "arch/x86/startup_x86.c", 
169                 "arch/x86/ipi_notify.c"
170               ],
171      mackerelDevices = [ "lpc_pic", 
172                          "pc16550d", 
173                          "ia32", 
174                          "amd64", 
175                          "xapic", 
176                          "cpuid", 
177                          "lpc_rtc" ],
178      addLibraries = [ "elf_kernel" ]
179      },
180   --
181   -- Intel Gauss Lake P54C core in the Rock Creek Single-Chip Cloud Computer
182   --
183   cpuDriver { 
184      architectures = [ "scc" ],
185      assemblyFiles = [ "arch/scc/boot.S",
186                        "arch/x86_32/entry.S", 
187                        "arch/x86_32/pic.S" ],
188      cFiles = [ "arch/scc/rck.c",
189                 "arch/x86_32/debug.c", 
190                 "arch/x86_32/gdb_arch.c", 
191                 "arch/x86_32/init.c", 
192                 "arch/x86_32/irq.c",
193                 "arch/x86_32/startup_arch.c", 
194                 "arch/x86_32/exec.c", 
195                 "arch/x86_32/syscall.c", 
196                 "arch/x86_32/paging.c",
197                 "arch/x86_32/page_mappings_arch.c",
198                 "arch/x86/apic.c", 
199                 "arch/x86/misc.c",
200                 "arch/x86/serial.c", 
201                 "arch/x86/multiboot.c", 
202                 "arch/x86/syscall.c", 
203                 "arch/x86/debugregs.c",
204                 "arch/x86/timing.c",
205                 "arch/x86/startup_x86.c"
206               ],
207      mackerelDevices = [ "pc16550d", 
208                          "ia32", 
209                          "xapic", 
210                          "rck", 
211                          "eMAC", 
212                          "cpuid", 
213                          "lpc_rtc" ],
214      addLibraries = [ "elf_kernel" ]
215      },
216   --
217   -- Generic ARMv5 core, unused?
218   --
219   cpuDriver {
220      architectures = [ "armv5" ],
221      assemblyFiles = [ "arch/armv5/boot.S", 
222                        "arch/armv5/exceptions.S" ],
223      cFiles = [ "arch/arm/exn.c", 
224                 "arch/arm/exec.c", 
225                 "arch/arm/misc.c", 
226                 "arch/arm/phys_mmap.c", 
227                 "arch/armv5/init.c", 
228                 "arch/armv5/integrator.c", 
229                 "arch/armv5/kludges.c", 
230                 "arch/armv5/kputchar.c", 
231                 "arch/armv5/pl011_uart.c", 
232                 "arch/armv5/cp15.c",
233                 "arch/armv5/paging.c", 
234                 "arch/armv5/startup_arch.c", 
235                 "arch/armv5/syscall.c" ],
236      mackerelDevices = [ "arm", 
237                          "arm_icp_pit", 
238                          "arm_icp_pic0", 
239                          "pl011_uart" ],
240      addLibraries = [ "elf", "cpio" ]
241      },
242   --
243   -- ARM11MP ARMv6 core, currently unsupported.
244   -- XXX: reorganize sources for ARMv6
245   --
246   cpuDriver {
247      architectures = [ "arm11mp" ],
248      assemblyFiles = [ "arch/armv5/boot.S", 
249                        "arch/armv5/exceptions.S", 
250                        "arch/paging_cp.S" ],
251      cFiles = [ "arch/arm/exn.c", 
252                 "arch/arm/exec.c", 
253                 "arch/arm/misc.c", 
254                 "arch/arm/phys_mmap.c", 
255                 "arch/armv5/init.c", 
256                 "arch/armv5/integrator.c", 
257                 "arch/armv5/kludges.c", 
258                 "arch/armv5/kputchar.c", 
259                 "arch/armv5/pl011_uart.c", 
260                 "arch/armv5/paging.c", 
261                 "arch/armv5/startup_arch.c", 
262                 "arch/armv5/syscall.c" ],
263      mackerelDevices = [ "arm", 
264                          "arm_icp_pit", 
265                          "arm_icp_pic0", 
266                          "pl011_uart" ],
267      addLibraries = [ "elf", "cpio" ]
268      },
269   --
270   -- ARM Gem5 Cortex-A series ARMv7 core
271   --
272   cpuDriver { 
273     target = "arm_gem5",
274     architectures = [ "armv7" ],
275     assemblyFiles = [ "arch/arm_gem5/boot.S",
276                       "arch/armv7/cp15.S",
277                       "arch/armv7/exceptions.S" ],
278     cFiles = [ "arch/arm/exec.c", 
279                "arch/arm/misc.c", 
280                "arch/arm/phys_mmap.c",
281                "arch/arm/exn.c", 
282                "arch/arm_gem5/init.c", 
283                "arch/arm_gem5/integrator.c", 
284                "arch/arm_gem5/paging.c", 
285                "arch/arm_gem5/gem5_serial.c", 
286                "arch/arm_gem5/pl011_uart.c", 
287                "arch/arm_gem5/startup_arch.c", 
288                "arch/armv7/syscall.c", 
289                "arch/armv7/kludges.c", 
290                "arch/armv7/multiboot.c", 
291                "arch/arm_gem5/start_aps.c", 
292                "arch/armv7/kputchar.c" ],
293     mackerelDevices = [ "arm", 
294                         "arm_icp_pit", 
295                         "pl011_uart", 
296                         "pl130_gic", 
297                         "sp804_pit", 
298                         "cortex_a9_pit", 
299                         "a9scu" ],
300     addLibraries = [ "elf", "cpio" ],
301     addCFlags = [ "-D__GEM5__" ]
302     },
303   --
304   -- Intel ixp2800 XScale core
305   --
306   cpuDriver {
307      target = "ixp2800",
308      architectures = [ "xscale" ],
309      assemblyFiles = [ "arch/xscale/boot.S", 
310                        "arch/armv5/exceptions.S"  ],
311      cFiles = [ "arch/arm/exn.c", 
312                 "arch/arm/exec.c", 
313                 "arch/arm/misc.c", 
314                 "arch/arm/phys_mmap.c", 
315                 "arch/armv5/init.c", 
316                 "arch/armv5/kludges.c", 
317                 "arch/armv5/startup_arch.c", 
318                 "arch/armv5/syscall.c", 
319                 "arch/xscale/ixp2800_integrator.c", 
320                 "arch/xscale/ixp2800_uart.c", 
321                 "arch/xscale/ixp2800_paging.c", 
322                 "arch/xscale/kputchar.c" ],
323      mackerelDevices = [ "arm", 
324                          "ixp2800_icp_pit", 
325                          "ixp2800_icp_pic0", 
326                          "ixp2800_uart" ],
327      addLibraries = [ "elf", "cpio" ]
328      },
329   --
330   -- Broadcom OMAP44xx-series dual-core Cortex-A9 SoC
331   --
332   cpuDriver {
333      target = "omap44xx",
334      architectures = [ "armv7" ],
335      assemblyFiles = [ "arch/omap44xx/boot.S",
336                        "arch/armv7/cp15.S",
337                        "arch/armv7/exceptions.S" ],
338      cFiles = [ "arch/arm/exec.c", 
339                 "arch/arm/misc.c", 
340                 "arch/arm/exn.c", 
341                 "arch/arm/phys_mmap.c",
342                 "arch/armv7/kludges.c", 
343                 "arch/armv7/multiboot.c", 
344                 "arch/armv7/syscall.c", 
345                 "arch/omap44xx/init.c", 
346                 "arch/omap44xx/omap.c", 
347                 "arch/omap44xx/paging.c", 
348                 "arch/omap44xx/startup_arch.c", 
349                 "arch/omap44xx/omap_uart.c", 
350                 "arch/omap44xx/start_aps.c", 
351                 "arch/armv7/kputchar.c" ],
352      mackerelDevices = [ "arm", 
353                          "arm_icp_pit", 
354                          "pl130_gic", 
355                          "sp804_pit", 
356                          "cortex_a9_pit", 
357                          "a9scu", 
358                          "omap/omap_uart", 
359                          "omap/omap44xx_id", 
360                          "omap/omap44xx_emif",
361                          "omap/omap44xx_gpio"],
362      addLibraries = [ "elf", "cpio" ]
363      }                            
364   
365   ]