Restore call to apicinit.
[akaros.git] / kern / arch / x86 / mpacpi.c
1 #include <vfs.h>
2 #include <kfs.h>
3 #include <slab.h>
4 #include <kmalloc.h>
5 #include <kref.h>
6 #include <string.h>
7 #include <stdio.h>
8 #include <assert.h>
9 #include <error.h>
10 #include <cpio.h>
11 #include <pmap.h>
12 #include <smp.h>
13 #include <ip.h>
14 #include <acpi.h>
15 #include <arch/ioapic.h>
16 #include <arch/coreid.h>
17
18 extern  struct Madt     *apics;
19
20 int
21 mpacpi(int ncleft)
22 {
23         char *already;
24         int np, bp;
25         struct apic *apic;
26         struct Apicst *st;
27
28         if (apics == NULL)
29                 return ncleft;
30
31         printd("APIC lapic paddr %#.8llux, flags %#.8ux\n",
32                 apics->lapicpa, apics->pcat);
33         np = 0;
34         for(st = apics->st; st != NULL; st = st->next){
35                 already = "";
36                 switch(st->type){
37                 case ASlapic:
38                         /* this table is supposed to have all of them if it exists */
39                         if(st->lapic.id > MaxAPICNO)
40                                 break;
41                         apic = xlapic + st->lapic.id;
42                         bp = (np++ == 0);
43                         if(apic->useable){
44                                 already = "(mp)";
45                         }
46                         else if(ncleft != 0){
47                                 ncleft--;
48                                 printk("apicinit(%d, %p, %d);\n", st->lapic.id, apics->lapicpa, bp);
49                                 apicinit(st->lapic.id, apics->lapicpa, bp);
50                         } else
51                                 already = "(off)";
52
53                         printd("apic proc %d/%d apicid %d %s\n", np-1, apic->machno, st->lapic.id, already);
54                         break;
55                 case ASioapic:
56                         if(st->ioapic.id > Napic)
57                                 break;
58                         apic = xioapic + st->ioapic.id;
59                         if(apic->useable){
60                                 apic->ibase = st->ioapic.ibase; /* gnarly */
61                                 already = "(mp)";
62                                 goto pr1;
63                         }
64                         printk("ioapicinit(%d, %p, %p);\n", st->lapic.id, apics->lapicpa, st->ioapic.addr);
65                         ioapicinit(st->ioapic.id, st->ioapic.ibase, st->ioapic.addr);
66                 pr1:
67                         printd("ioapic %d ", st->ioapic.id);
68                         printd("addr %p base %d %s\n", apic->paddr, apic->ibase, already);
69                         break;
70                 }
71         }
72         return ncleft;
73 }