Support for Intel Core Duo and Core 2 Duo (tm) CPUs.
[coreboot.git] / src / cpu / intel / model_6ex / model_6ex_init.c
1 #include <console/console.h>
2 #include <device/device.h>
3 #include <device/pci.h>
4 #include <string.h>
5 #include <cpu/cpu.h>
6 #include <cpu/x86/mtrr.h>
7 #include <cpu/x86/msr.h>
8 #include <cpu/x86/lapic.h>
9 #include <cpu/intel/microcode.h>
10 #include <cpu/intel/hyperthreading.h>
11 #include <cpu/x86/cache.h>
12 #include <cpu/x86/mtrr.h>
13
14 static const uint32_t microcode_updates[] = {
15         #include "microcode_m206e839.h"
16         /*  Dummy terminator  */
17         0x0, 0x0, 0x0, 0x0,
18         0x0, 0x0, 0x0, 0x0,
19         0x0, 0x0, 0x0, 0x0,
20         0x0, 0x0, 0x0, 0x0,
21 };
22
23 static inline void strcpy(char *dst, char *src) 
24 {
25         while (*src) *dst++ = *src++;
26 }
27
28 static void fill_processor_name(char *processor_name)
29 {
30         struct cpuid_result regs;
31         char temp_processor_name[49];
32         char *processor_name_start;
33         unsigned int *name_as_ints = (unsigned int *)temp_processor_name;
34         int i;
35
36         for (i=0; i<3; i++) {
37                 regs = cpuid(0x80000002 + i);
38                 name_as_ints[i*4 + 0] = regs.eax;
39                 name_as_ints[i*4 + 1] = regs.ebx;
40                 name_as_ints[i*4 + 2] = regs.ecx;
41                 name_as_ints[i*4 + 3] = regs.edx;
42         }
43
44         temp_processor_name[48] = 0;
45
46         /* Skip leading spaces */
47         processor_name_start = temp_processor_name;
48         while (*processor_name_start == ' ') 
49                 processor_name_start++;
50
51         memset(processor_name, 0, 49);
52         strcpy(processor_name, processor_name_start);
53 }
54
55 static void model_6ex_init(device_t cpu)
56 {
57         char processor_name[49];
58
59         /* Turn on caching if we haven't already */
60         x86_enable_cache();
61
62         /* Update the microcode */
63         intel_update_microcode(microcode_updates);
64
65         /* Print processor name */
66         fill_processor_name(processor_name);
67         printk_info("CPU: %s.\n", processor_name);
68
69         /* Setup MTRRs */
70         x86_setup_mtrrs(36);
71         x86_mtrr_check();
72         
73         /* Enable the local cpu apics */
74         setup_lapic();
75
76         /* Start up my cpu siblings */
77         intel_sibling_init(cpu);
78 }
79
80 static struct device_operations cpu_dev_ops = {
81         .init     = model_6ex_init,
82 };
83
84 static struct cpu_device_id cpu_table[] = {
85         { X86_VENDOR_INTEL, 0x06e0 }, /* Intel Core Solo/Core Duo */
86         { X86_VENDOR_INTEL, 0x06e8 }, /* Intel Core Solo/Core Duo */
87         { 0, 0 },
88 };
89
90 static const struct cpu_driver driver __cpu_driver = {
91         .ops      = &cpu_dev_ops,
92         .id_table = cpu_table,
93 };
94