01ce601bdb
Convert all DEBUG_SMBUS, DEBUG_SMI, and DEBUG_RAM_SETUP custom and local #defines into globally configurable kconfig options (and Options.lb options for as long as newconfig still exists) which can be enabled by the user in the "Debugging" menu. The respective menu items only appear if a board is selected where the chipset code actually provides such additional DEBUG output. All three variables default to 0 / off for now. Also, drop a small chunk of dead/useless code in the src/northbridge/via/cn700/raminit.c file, which would otherwise break compilation. Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de> Reworked to still apply to trunk, added X86EMU_DEBUG (and make the x86emu/yabel code only work printf instead of a redefined version of printk and Acked-by: Stefan Reinauer <stepan@coresystems.de> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@5185 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
156 lines
3.6 KiB
C
156 lines
3.6 KiB
C
/*
|
|
* This file is part of the coreboot project.
|
|
*
|
|
* Copyright (C) 2008-2009 coresystems GmbH
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License as
|
|
* published by the Free Software Foundation; version 2 of
|
|
* the License.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
|
* MA 02110-1301 USA
|
|
*/
|
|
|
|
#include <arch/io.h>
|
|
#include <arch/romcc_io.h>
|
|
#include <console/console.h>
|
|
#include <cpu/x86/cache.h>
|
|
#include <cpu/x86/smm.h>
|
|
|
|
void southbridge_smi_set_eos(void);
|
|
|
|
typedef enum { SMI_LOCKED, SMI_UNLOCKED } smi_semaphore;
|
|
|
|
/* SMI multiprocessing semaphore */
|
|
static volatile smi_semaphore smi_handler_status = SMI_UNLOCKED;
|
|
|
|
static int smi_obtain_lock(void)
|
|
{
|
|
u8 ret = SMI_LOCKED;
|
|
|
|
asm volatile (
|
|
"movb %2, %%al\n"
|
|
"xchgb %%al, %1\n"
|
|
"movb %%al, %0\n"
|
|
: "=g" (ret), "=m" (smi_handler_status)
|
|
: "g" (SMI_LOCKED)
|
|
: "eax"
|
|
);
|
|
|
|
return (ret == SMI_UNLOCKED);
|
|
}
|
|
|
|
static void smi_release_lock(void)
|
|
{
|
|
asm volatile (
|
|
"movb %1, %%al\n"
|
|
"xchgb %%al, %0\n"
|
|
: "=m" (smi_handler_status)
|
|
: "g" (SMI_UNLOCKED)
|
|
: "eax"
|
|
);
|
|
}
|
|
|
|
#define LAPIC_ID 0xfee00020
|
|
static inline __attribute__((always_inline)) unsigned long nodeid(void)
|
|
{
|
|
return (*((volatile unsigned long *)(LAPIC_ID)) >> 24);
|
|
}
|
|
|
|
void io_trap_handler(int smif)
|
|
{
|
|
/* If a handler function handled a given IO trap, it
|
|
* shall return a non-zero value
|
|
*/
|
|
printk_debug("SMI function trap 0x%x: ", smif);
|
|
|
|
if (southbridge_io_trap_handler(smif))
|
|
return;
|
|
|
|
if (mainboard_io_trap_handler(smif))
|
|
return;
|
|
|
|
printk_debug("Unknown function\n");
|
|
}
|
|
|
|
/**
|
|
* @brief Set the EOS bit
|
|
*/
|
|
static void smi_set_eos(void)
|
|
{
|
|
southbridge_smi_set_eos();
|
|
}
|
|
|
|
/**
|
|
* @brief Interrupt handler for SMI#
|
|
*
|
|
* @param smm_revision revision of the smm state save map
|
|
*/
|
|
|
|
void smi_handler(u32 smm_revision)
|
|
{
|
|
unsigned int node;
|
|
smm_state_save_area_t state_save;
|
|
|
|
/* Are we ok to execute the handler? */
|
|
if (!smi_obtain_lock()) {
|
|
/* For security reasons we don't release the other CPUs
|
|
* until the CPU with the lock is actually done
|
|
*/
|
|
while (smi_handler_status == SMI_LOCKED) /* wait */ ;
|
|
return;
|
|
}
|
|
|
|
node=nodeid();
|
|
|
|
console_init();
|
|
|
|
printk_spew("\nSMI# #%d\n", node);
|
|
|
|
switch (smm_revision) {
|
|
case 0x00030002:
|
|
case 0x00030007:
|
|
state_save.type = LEGACY;
|
|
state_save.legacy_state_save = (legacy_smm_state_save_area_t *)
|
|
(0xa8000 + 0x7e00 - (node * 0x400));
|
|
break;
|
|
case 0x00030100:
|
|
state_save.type = EM64T;
|
|
state_save.em64t_state_save = (em64t_smm_state_save_area_t *)
|
|
(0xa8000 + 0x7d00 - (node * 0x400));
|
|
break;
|
|
case 0x00030064:
|
|
state_save.type = AMD64;
|
|
state_save.amd64_state_save = (amd64_smm_state_save_area_t *)
|
|
(0xa8000 + 0x7e00 - (node * 0x400));
|
|
break;
|
|
default:
|
|
printk_debug("smm_revision: 0x%08x\n", smm_revision);
|
|
printk_debug("SMI# not supported on your CPU\n");
|
|
/* Don't release lock, so no further SMI will happen,
|
|
* if we don't handle it anyways.
|
|
*/
|
|
return;
|
|
}
|
|
|
|
/* Call chipset specific SMI handlers. */
|
|
if (cpu_smi_handler)
|
|
cpu_smi_handler(node, &state_save);
|
|
if (northbridge_smi_handler)
|
|
northbridge_smi_handler(node, &state_save);
|
|
if (southbridge_smi_handler)
|
|
southbridge_smi_handler(node, &state_save);
|
|
|
|
smi_release_lock();
|
|
|
|
/* De-assert SMI# signal to allow another SMI */
|
|
smi_set_eos();
|
|
}
|