aboutsummaryrefslogtreecommitdiff
path: root/src/soc/intel/fsp_broadwell_de/memmap.c
blob: cbd3cf7788fd3ba86b99002fe5d811423061dfce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
 * This file is part of the coreboot project.
 *
 * Copyright (C) 2013 Google, Inc.
 * Copyright (C) 2015-2016 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; 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.
 */

#define __SIMPLE_DEVICE__

#include <cbmem.h>
#include <cpu/x86/smm.h>
#include <drivers/intel/fsp1_0/fsp_util.h>
#include <soc/broadwell_de.h>
#include <soc/pci_devs.h>
#include <device/pci_ops.h>

void *cbmem_top(void)
{
	return find_fsp_reserved_mem(*(void **)CBMEM_FSP_HOB_PTR);
}

/*
 * Get TSEG base.
 */
uintptr_t sa_get_tseg_base(void)
{
	const pci_devfn_t dev = PCI_DEV(BUS0, VTD_DEV, VTD_FUNC);

	/* All regions concerned for have 1 MiB alignment. */
	return ALIGN_DOWN(pci_read_config32(dev, TSEG_BASE), 1 * MiB);
}

size_t sa_get_tseg_size(void)
{
	const pci_devfn_t dev = PCI_DEV(BUS0, VTD_DEV, VTD_FUNC);

	/* All regions concerned for have 1 MiB alignment. */
	size_t ret = ALIGN_DOWN(pci_read_config32(dev, TSEG_LIMIT), 1 * MiB);

	/* Lower 20bit of TSEG_LIMIT are don't care, need to add 1MiB */
	ret += 1 * MiB;

	/* Subtract base to get the size */
	return ret - sa_get_tseg_base();
}

void smm_region(uintptr_t *start, size_t *size)
{
	*start = sa_get_tseg_base();
	*size = sa_get_tseg_size();
}