2015-05-06 00:07:29 +02:00
|
|
|
/*
|
|
|
|
* This file is part of the coreboot project.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 Google, Inc.
|
2016-01-29 23:28:43 +01:00
|
|
|
* Copyright (C) 2015-2016 Intel Corp.
|
2015-05-06 00:07:29 +02:00
|
|
|
*
|
|
|
|
* 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,
|
2016-01-29 23:28:43 +01:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2015-05-06 00:07:29 +02:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <cbmem.h>
|
2019-08-04 18:54:32 +02:00
|
|
|
#include <cpu/x86/smm.h>
|
2015-05-06 00:07:29 +02:00
|
|
|
#include <soc/iosf.h>
|
|
|
|
|
2015-04-21 00:20:28 +02:00
|
|
|
static size_t smm_region_size(void)
|
2015-05-06 00:07:29 +02:00
|
|
|
{
|
2015-04-21 00:20:28 +02:00
|
|
|
u32 smm_size;
|
|
|
|
smm_size = iosf_bunit_read(BUNIT_SMRRH) & 0xFFFF;
|
|
|
|
smm_size -= iosf_bunit_read(BUNIT_SMRRL) & 0xFFFF;
|
|
|
|
smm_size = (smm_size + 1) << 20;
|
|
|
|
return smm_size;
|
|
|
|
}
|
|
|
|
|
2019-08-05 14:10:18 +02:00
|
|
|
void smm_region(uintptr_t *start, size_t *size)
|
2015-04-21 00:20:28 +02:00
|
|
|
{
|
2019-08-05 14:10:18 +02:00
|
|
|
*start = (iosf_bunit_read(BUNIT_SMRRL) & 0xFFFF) << 20;
|
2015-04-21 00:20:28 +02:00
|
|
|
*size = smm_region_size();
|
|
|
|
}
|
|
|
|
|
2015-05-06 00:07:29 +02:00
|
|
|
void *cbmem_top(void)
|
|
|
|
{
|
2019-08-05 14:10:18 +02:00
|
|
|
uintptr_t smm_base;
|
2015-04-21 00:20:28 +02:00
|
|
|
size_t smm_size;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* +-------------------------+ Top of RAM (aligned)
|
|
|
|
* | System Management Mode |
|
|
|
|
* | code and data | Length: CONFIG_TSEG_SIZE
|
|
|
|
* | (TSEG) |
|
|
|
|
* +-------------------------+ SMM base (aligned)
|
|
|
|
* | |
|
|
|
|
* | Chipset Reserved Memory | Length: Multiple of CONFIG_TSEG_SIZE
|
|
|
|
* | |
|
|
|
|
* +-------------------------+ top_of_ram (aligned)
|
|
|
|
* | |
|
|
|
|
* | CBMEM Root |
|
|
|
|
* | |
|
|
|
|
* +-------------------------+
|
|
|
|
* | |
|
|
|
|
* | FSP Reserved Memory |
|
|
|
|
* | |
|
|
|
|
* +-------------------------+
|
|
|
|
* | |
|
|
|
|
* | Various CBMEM Entries |
|
|
|
|
* | |
|
|
|
|
* +-------------------------+ top_of_stack (8 byte aligned)
|
|
|
|
* | |
|
|
|
|
* | stack (CBMEM Entry) |
|
|
|
|
* | |
|
|
|
|
* +-------------------------+
|
|
|
|
*/
|
|
|
|
|
2019-08-05 14:10:18 +02:00
|
|
|
smm_region(&smm_base, &smm_size);
|
2015-07-13 23:55:28 +02:00
|
|
|
return (void *)smm_base;
|
2015-05-06 00:07:29 +02:00
|
|
|
}
|