1b840ff379f6e8b410c507a54cb8a4df19732a10
[coreboot.git] / src / arch / i386 / boot / tables.c
1 #include <console/console.h>
2 #include <mem.h>
3 #include <cpu/cpu.h>
4 #include <boot/tables.h>
5 #include <boot/linuxbios_tables.h>
6 #include <arch/pirq_routing.h>
7 #include <arch/smp/mpspec.h>
8 #include "linuxbios_table.h"
9
10 #if CONFIG_SMP && CONFIG_MAX_PHYSICAL_CPUS && (CONFIG_MAX_PHYSICAL_CPUS < CONFIG_MAX_CPUS)
11 static void remove_logical_cpus(unsigned long *processor_map)
12 {
13         /* To turn off hyperthreading just remove the logical
14          * cpus from the processor map.
15          */
16         int disable_logical_cpus = !CONFIG_LOGICAL_CPUS;
17         if (get_option(&disable_logical_cpus,"hyper_threading")) {
18                 disable_logical_cpus = !CONFIG_LOGICAL_CPUS;
19         }
20         if (disable_logical_cpus) {
21                 /* disable logical cpus */
22                 int cnt;
23                 for(cnt=MAX_PHYSICAL_CPUS;cnt<MAX_CPUS;cnt++)
24                         processor_map[cnt]=0;
25                 printk_debug("logical cpus disabled\n");
26         }
27 }
28 #else
29
30 #define remove_logical_cpus(processor_map) do {} while(0) 
31
32 #endif /* CONFIG_SMP && CONFIG_MAX_PHYSICAL_CPUS */
33
34 struct lb_memory *write_tables(struct mem_range *mem, unsigned long *processor_map)
35 {
36         unsigned long low_table_start, low_table_end;
37         unsigned long rom_table_start, rom_table_end;
38
39         rom_table_start = 0xf0000;
40         rom_table_end =   0xf0000;
41         /* Start low addr at 16 bytes instead of 0 because of a buglet
42          * in the generic linux unzip code, as it tests for the a20 line.
43          */
44         low_table_start = 0;
45         low_table_end = 16;
46
47         post_code(0x9a);
48         check_pirq_routing_table();
49         /* This table must be betweeen 0xf0000 & 0x100000 */
50         rom_table_end = copy_pirq_routing_table(rom_table_end);
51         rom_table_end = (rom_table_end + 1023) & ~1023;
52
53         /* copy the smp block to address 0 */
54         post_code(0x96);
55
56         /* The smp table must be in 0-1K, 639K-640K, or 960K-1M */
57         remove_logical_cpus(processor_map);
58         low_table_end = write_smp_table(low_table_end, processor_map);
59
60         /* Don't write anything in the traditional x86 BIOS data segment */
61         if (low_table_end < 0x500) {
62                 low_table_end = 0x500;
63         }
64         /* The linuxbios table must be in 0-4K or 960K-1M */
65         write_linuxbios_table(processor_map, mem,
66                               low_table_start, low_table_end,
67                               rom_table_start >> 10, rom_table_end >> 10);
68
69         return get_lb_mem();
70 }