Since some people disapprove of white space cleanups mixed in regular commits
[coreboot.git] / src / cpu / amd / model_fxx / model_fxx_update_microcode.c
1 /* Copyright 2005 AMD
2  * 2005.08 yhlu add microcode support
3  */
4 /*============================================================================
5 Copyright 2005 ADVANCED MICRO DEVICES, INC. All Rights Reserved.
6 This software and any related documentation (the "Materials") are the
7 confidential proprietary information of AMD. Unless otherwise provided in a
8 software agreement specifically licensing the Materials, the Materials are
9 provided in confidence and may not be distributed, modified, or reproduced in
10 whole or in part by any means.
11 LIMITATION OF LIABILITY: THE MATERIALS ARE PROVIDED "AS IS" WITHOUT ANY
12 EXPRESS OR IMPLIED WARRANTY OF ANY KIND, INCLUDING BUT NOT LIMITED TO
13 WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, TITLE, FITNESS FOR ANY
14 PARTICULAR PURPOSE, OR WARRANTIES ARISING FROM CONDUCT, COURSE OF DEALING, OR
15 USAGE OF TRADE. IN NO EVENT SHALL AMD OR ITS LICENSORS BE LIABLE FOR ANY
16 DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS,
17 BUSINESS INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT OF THE USE OF OR
18 INABILITY TO USE THE MATERIALS, EVEN IF AMD HAS BEEN ADVISED OF THE
19 POSSIBILITY OF SUCH DAMAGES. BECAUSE SOME JURISDICTIONS PROHIBIT THE EXCLUSION
20 OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE ABOVE
21 LIMITATION MAY NOT APPLY TO YOU.
22 AMD does not assume any responsibility for any errors which may appear in the
23 Materials nor any responsibility to support or update the Materials. AMD
24 retains the right to modify the Materials at any time, without notice, and is
25 not obligated to provide such modified Materials to you.
26 NO SUPPORT OBLIGATION: AMD is not obligated to furnish, support, or make any
27 further information, software, technical information, know-how, or show-how
28 available to you.
29 U.S. GOVERNMENT RESTRICTED RIGHTS: The Materials are provided with "RESTRICTED
30 RIGHTS." Use, duplication, or disclosure by the Government is subject to the
31 restrictions as set forth in FAR 52.227-14 and DFAR 252.227-7013, et seq., or
32 its successor. Use of the Materials by the Government constitutes
33 acknowledgement of AMD's proprietary rights in them.
34 ============================================================================*/
35 //@DOC
36 // in model_fxx_update_microcode.c
37 /*
38 $1.0$
39 */
40 // Description: microcode patch support for k8
41 // by yhlu
42 //
43 //============================================================================
44
45
46 #include <console/console.h>
47 #include <device/device.h>
48 #include <device/pci.h>
49 #include <string.h>
50
51 #include <cpu/amd/microcode.h>
52
53 static uint8_t microcode_updates[] __attribute__ ((aligned(16))) = {
54
55 #if CONFIG_K8_REV_F_SUPPORT == 0
56         #include "microcode_rev_c.h"
57         #include "microcode_rev_d.h"
58         #include "microcode_rev_e.h"
59 #endif
60
61 #if CONFIG_K8_REV_F_SUPPORT == 1
62 //      #include "microcode_rev_f.h"
63 #endif
64         /*  Dummy terminator  */
65         0x0, 0x0, 0x0, 0x0,
66         0x0, 0x0, 0x0, 0x0,
67         0x0, 0x0, 0x0, 0x0,
68         0x0, 0x0, 0x0, 0x0,
69 };
70
71 static unsigned get_equivalent_processor_rev_id(unsigned orig_id) {
72         static unsigned id_mapping_table[] = {
73         #if CONFIG_K8_REV_F_SUPPORT == 0
74                 0x0f48, 0x0048,
75                 0x0f58, 0x0048,
76
77                 0x0f4a, 0x004a,
78                 0x0f5a, 0x004a,
79                 0x0f7a, 0x004a,
80                 0x0f82, 0x004a,
81                 0x0fc0, 0x004a,
82                 0x0ff0, 0x004a,
83
84                 0x10f50, 0x0150,
85                 0x10f70, 0x0150,
86                 0x10f80, 0x0150,
87                 0x10fc0, 0x0150,
88                 0x10ff0, 0x0150,
89
90                 0x20f10, 0x0210,
91                 0x20f12, 0x0210,
92                 0x20f32, 0x0210,
93                 0x20fb1, 0x0210,
94         #endif
95
96         #if CONFIG_K8_REV_F_SUPPORT == 1
97
98         #endif
99
100         };
101
102
103         unsigned new_id;
104         int i;
105
106         new_id = 0;
107
108         for(i=0; i<sizeof(id_mapping_table); i+=2 ) {
109                 if(id_mapping_table[i]==orig_id) {
110                         new_id = id_mapping_table[i+1];
111                         break;
112                 }
113         }
114
115         return new_id;
116
117 }
118
119 void model_fxx_update_microcode(unsigned cpu_deviceid)
120 {
121         unsigned equivalent_processor_rev_id;
122
123         /* Update the microcode */
124         equivalent_processor_rev_id = get_equivalent_processor_rev_id(cpu_deviceid );
125         if(equivalent_processor_rev_id != 0)
126                 amd_update_microcode(microcode_updates, equivalent_processor_rev_id);
127
128 }
129