2020-04-05 15:46:45 +02:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2015-05-06 00:07:29 +02:00
|
|
|
|
|
|
|
#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;
|
2020-03-19 00:31:58 +01:00
|
|
|
smm_size = iosf_bunit_read(BUNIT_SMRRH) & 0xFFFF;
|
2015-04-21 00:20:28 +02:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2019-10-23 17:25:58 +02:00
|
|
|
void *cbmem_top_chipset(void)
|
2015-05-06 00:07:29 +02:00
|
|
|
{
|
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 |
|
2020-11-09 21:13:27 +01:00
|
|
|
* | code and data | Length: CONFIG_SMM_TSEG_SIZE
|
2015-04-21 00:20:28 +02:00
|
|
|
* | (TSEG) |
|
|
|
|
* +-------------------------+ SMM base (aligned)
|
|
|
|
* | |
|
2020-11-09 21:13:27 +01:00
|
|
|
* | Chipset Reserved Memory | Length: Multiple of CONFIG_SMM_TSEG_SIZE
|
2015-04-21 00:20:28 +02:00
|
|
|
* | |
|
|
|
|
* +-------------------------+ 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
|
|
|
}
|