blob: 24fbb64b97b0d29ac1e8dc26a9beff4550af0346 [file] [log] [blame]
Kyösti Mälkkicb08e162013-10-15 17:19:41 +03001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2011 Google Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Kyösti Mälkkicb08e162013-10-15 17:19:41 +030014 */
15
16// Use simple device model for this file even in ramstage
17#define __SIMPLE_DEVICE__
18
19#include <arch/io.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020020#include <device/pci_ops.h>
Kyösti Mälkkicb08e162013-10-15 17:19:41 +030021#include <cbmem.h>
22#include "haswell.h"
23
Kyösti Mälkkif1e3c762014-12-22 12:28:07 +020024static uintptr_t smm_region_start(void)
Kyösti Mälkkicb08e162013-10-15 17:19:41 +030025{
26 /*
27 * Base of TSEG is top of usable DRAM below 4GiB. The register has
Martin Roth128c1042016-11-18 09:29:03 -070028 * 1 MiB alignment.
Kyösti Mälkkicb08e162013-10-15 17:19:41 +030029 */
Kyösti Mälkkif1e3c762014-12-22 12:28:07 +020030 uintptr_t tom = pci_read_config32(PCI_DEV(0,0,0), TSEG);
31 return tom & ~((1 << 20) - 1);
32}
33
34void *cbmem_top(void)
35{
36 return (void *)smm_region_start();
Kyösti Mälkkicb08e162013-10-15 17:19:41 +030037}