blob: 8fa81c715abe97a65e6e59932292a3708293569c [file] [log] [blame]
Marc Jones1587dc82017-05-15 18:55:11 -06001/*
2 * This file is part of the coreboot project.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
14#define __SIMPLE_DEVICE__
15
16#include <stdint.h>
17#include <arch/io.h>
18#include <cbmem.h>
19
20#define CBMEM_TOP_SCRATCHPAD 0x78
21
22void backup_top_of_low_cacheable(uintptr_t ramtop)
23{
24 uint16_t top_cache = ramtop >> 16;
25 pci_write_config16(PCI_DEV(0,0,0), CBMEM_TOP_SCRATCHPAD, top_cache);
26}
27
28uintptr_t restore_top_of_low_cacheable(void)
29{
30 uint16_t top_cache;
31 top_cache = pci_read_config16(PCI_DEV(0,0,0), CBMEM_TOP_SCRATCHPAD);
32 return (top_cache << 16);
33}