2016-03-03 00:09:27 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the coreboot project.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2015 Intel Corp.
|
|
|
|
* (Written by Andrey Petrov <andrey.petrov@intel.com> for Intel Corp.)
|
|
|
|
*
|
|
|
|
* 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; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
2016-04-10 19:09:16 +02:00
|
|
|
*
|
|
|
|
* 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.
|
2016-03-03 00:09:27 +01:00
|
|
|
*/
|
|
|
|
|
2016-09-30 22:57:12 +02:00
|
|
|
#include <assert.h>
|
2016-03-03 00:09:27 +01:00
|
|
|
#include <cbmem.h>
|
2019-04-05 18:11:19 +02:00
|
|
|
#include <console/console.h>
|
2016-03-03 00:09:27 +01:00
|
|
|
#include <device/pci.h>
|
2017-06-09 02:32:02 +02:00
|
|
|
#include <fsp/memmap.h>
|
2017-08-30 13:23:20 +02:00
|
|
|
#include <intelblocks/smm.h>
|
2017-03-14 13:56:27 +01:00
|
|
|
#include <soc/systemagent.h>
|
2016-03-03 00:09:27 +01:00
|
|
|
#include <soc/pci_devs.h>
|
|
|
|
|
2019-04-05 18:11:19 +02:00
|
|
|
#include "chip.h"
|
|
|
|
|
2016-03-03 00:09:27 +01:00
|
|
|
void *cbmem_top(void)
|
|
|
|
{
|
2017-08-29 23:11:16 +02:00
|
|
|
const struct device *dev;
|
|
|
|
const config_t *config;
|
|
|
|
void *tolum = (void *)sa_get_tseg_base();
|
|
|
|
|
2019-03-06 01:53:33 +01:00
|
|
|
if (!CONFIG(SOC_INTEL_GLK))
|
2017-08-29 23:11:16 +02:00
|
|
|
return tolum;
|
|
|
|
|
2019-07-03 06:25:59 +02:00
|
|
|
dev = pcidev_path_on_root(PCH_DEVFN_LPC);
|
2017-08-29 23:11:16 +02:00
|
|
|
assert(dev != NULL);
|
|
|
|
config = dev->chip_info;
|
|
|
|
|
|
|
|
if (!config)
|
2019-05-09 19:40:34 +02:00
|
|
|
die_with_post_code(POST_HW_INIT_FAILURE,
|
|
|
|
"Failed to get chip_info\n");
|
2017-08-29 23:11:16 +02:00
|
|
|
|
|
|
|
/* FSP allocates 2x PRMRR Size Memory for alignment */
|
|
|
|
if (config->sgx_enable)
|
|
|
|
tolum -= config->PrmrrSize * 2;
|
|
|
|
|
|
|
|
return tolum;
|
2016-05-13 09:47:14 +02:00
|
|
|
}
|
2016-09-30 22:57:12 +02:00
|
|
|
|
|
|
|
int smm_subregion(int sub, void **start, size_t *size)
|
|
|
|
{
|
|
|
|
uintptr_t sub_base;
|
|
|
|
size_t sub_size;
|
2017-08-30 13:23:20 +02:00
|
|
|
void *smm_base;
|
2016-09-30 22:57:12 +02:00
|
|
|
const size_t cache_size = CONFIG_SMM_RESERVED_SIZE;
|
|
|
|
|
2017-08-30 13:23:20 +02:00
|
|
|
smm_region_info(&smm_base, &sub_size);
|
|
|
|
sub_base = (uintptr_t)smm_base;
|
2016-09-30 22:57:12 +02:00
|
|
|
|
|
|
|
assert(sub_size > CONFIG_SMM_RESERVED_SIZE);
|
|
|
|
|
|
|
|
switch (sub) {
|
|
|
|
case SMM_SUBREGION_HANDLER:
|
|
|
|
/* Handler starts at the base of TSEG. */
|
|
|
|
sub_size -= cache_size;
|
|
|
|
break;
|
|
|
|
case SMM_SUBREGION_CACHE:
|
|
|
|
/* External cache is in the middle of TSEG. */
|
|
|
|
sub_base += sub_size - cache_size;
|
|
|
|
sub_size = cache_size;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
*start = (void *)sub_base;
|
|
|
|
*size = sub_size;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|