2 * This file is part of the coreboot project.
4 * Copyright (C) 2007 Advanced Micro Devices, Inc.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include <console/console.h>
25 #include <cpu/x86/msr.h>
26 #include <cpu/amd/microcode.h>
27 #include <cpu/x86/cache.h>
39 u32 m_patch_data_cksum;
57 u8 x86_code_entry[191];
60 static int need_apply_patch(struct microcode *m, u32 equivalent_processor_rev_id)
63 if (m->processor_rev_id != equivalent_processor_rev_id) {
64 printk_err("microcode: rev id (%x) does not match this patch.\n", m->processor_rev_id);
65 printk_err("microcode: Not updated! Fix microcode_updates[] \n");
69 //look at the device id, if not found return;
70 //if(m->nb_rev_id != installed_nb_rev_id) return 0;
73 if (m->ht_io_hub_dev_id) {
74 //look at the device id, if not found return;
75 //if(m->ht_io_hub_rev_id != installed_ht_io_bub_rev_id) return 0;
78 if (m->x86_code_present) {
79 //if(!x86_code_execute()) return 0;
86 void amd_update_microcode(void *microcode_updates, u32 equivalent_processor_rev_id)
88 u32 patch_id, new_patch_id;
96 printk_debug("microcode: equivalent rev id = 0x%04x, current patch id = 0x%08x\n", equivalent_processor_rev_id, patch_id);
98 m = microcode_updates;
100 for(c = microcode_updates; m->date_code; m = (struct microcode *)c) {
102 if( need_apply_patch(m, equivalent_processor_rev_id) ) {
108 wrmsr(0xc0010020, msr);
110 printk_debug("microcode: patch id to apply = 0x%08x\n", m->patch_id);
112 //read the patch_id again
114 new_patch_id = msr.lo;
116 printk_debug("microcode: updated to patch id = 0x%08x %s\n", new_patch_id , (new_patch_id == m->patch_id)?" success\n":" fail\n" );