blob: e57ed53d743980379cd25360fc500f9a4414887c [file] [log] [blame]
Andrey Petrov491c0162016-03-02 15:09:27 -08001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2015 Intel Corp.
5 * (Written by Andrey Petrov <andrey.petrov@intel.com> for Intel Corp.)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
Martin Rothebabfad2016-04-10 11:09:16 -060011 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
Andrey Petrov491c0162016-03-02 15:09:27 -080016 */
17
18#include <arch/io.h>
19#include <cbmem.h>
20#include <device/pci.h>
21#include <soc/northbridge.h>
22#include <soc/pci_devs.h>
Hannah Williamsd9c84ca2016-05-13 00:47:14 -070023#include <soc/smm.h>
Andrey Petrov491c0162016-03-02 15:09:27 -080024
25static uintptr_t smm_region_start(void)
26{
27 return ALIGN_DOWN(pci_read_config32(NB_DEV_ROOT, TSEG), 1*MiB);
28}
29
Hannah Williamsd9c84ca2016-05-13 00:47:14 -070030static size_t smm_region_size(void)
31{
32 uintptr_t smm_end =
33 ALIGN_DOWN(pci_read_config32(NB_DEV_ROOT, BGSM), 1*MiB);
34 return smm_end - smm_region_start();
35}
36
Andrey Petrov491c0162016-03-02 15:09:27 -080037void *cbmem_top(void)
38{
39 return (void *)smm_region_start();
40}
Hannah Williamsd9c84ca2016-05-13 00:47:14 -070041
42void smm_region(void **start, size_t *size)
43{
44 *start = (void *)smm_region_start();
45 *size = smm_region_size();
46}