blob: b43c97233d5f831f8209d87c9527d606a637cea1 [file] [log] [blame]
Stefan Reinauer3b314022009-10-26 17:04:28 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2009 coresystems GmbH
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.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
18 */
19
20#ifndef _CBMEM_H_
21#define _CBMEM_H_
22
Stefan Reinauer294edb22011-08-14 13:52:03 -070023/* Reserve 128k for ACPI and other tables */
Vadim Bendeburyf2f93862011-10-04 10:44:16 -070024#if CONFIG_CONSOLE_CBMEM
25#define HIGH_MEMORY_DEF_SIZE ( 256 * 1024 )
26#else
Stefan Reinauer294edb22011-08-14 13:52:03 -070027#define HIGH_MEMORY_DEF_SIZE ( 128 * 1024 )
Vadim Bendeburyf2f93862011-10-04 10:44:16 -070028#endif
29
Stefan Reinauer3b314022009-10-26 17:04:28 +000030#if CONFIG_HAVE_ACPI_RESUME
zbaof7223732012-04-13 13:42:15 +080031#define HIGH_MEMORY_SAVE (CONFIG_RAMTOP - CONFIG_RAMBASE)
32#define HIGH_MEMORY_SIZE (HIGH_MEMORY_SAVE + CONFIG_HIGH_SCRATCH_MEMORY_SIZE + HIGH_MEMORY_DEF_SIZE)
Stefan Reinauer61f4a742012-04-03 16:21:04 -070033
34/* Delegation of resume backup memory so we don't have to
35 * (slowly) handle backing up OS memory in romstage.c
36 */
37#define CBMEM_BOOT_MODE 0x610
38#define CBMEM_RESUME_BACKUP 0x614
zbaof7223732012-04-13 13:42:15 +080039
40#else /* CONFIG_HAVE_ACPI_RESUME */
Rudolf Marek97be27e2010-12-13 19:50:25 +000041#define HIGH_MEMORY_SIZE HIGH_MEMORY_DEF_SIZE
zbaof7223732012-04-13 13:42:15 +080042#endif /* CONFIG_HAVE_ACPI_RESUME */
Stefan Reinauer3b314022009-10-26 17:04:28 +000043
44#define CBMEM_ID_FREESPACE 0x46524545
45#define CBMEM_ID_GDT 0x4c474454
46#define CBMEM_ID_ACPI 0x41435049
47#define CBMEM_ID_CBTABLE 0x43425442
48#define CBMEM_ID_PIRQ 0x49525154
49#define CBMEM_ID_MPTABLE 0x534d5054
50#define CBMEM_ID_RESUME 0x5245534d
zbaof7223732012-04-13 13:42:15 +080051#define CBMEM_ID_RESUME_SCRATCH 0x52455343
Sven Schnelle164bcfd2011-08-14 20:56:34 +020052#define CBMEM_ID_SMBIOS 0x534d4254
Vadim Bendebury6f72d692011-09-21 16:12:39 -070053#define CBMEM_ID_TIMESTAMP 0x54494d45
Stefan Reinauer61f4a742012-04-03 16:21:04 -070054#define CBMEM_ID_MRCDATA 0x4d524344
Vadim Bendeburybe25a4d2011-09-30 11:13:06 -070055#define CBMEM_ID_CONSOLE 0x434f4e53
Duncan Laurie215f27852012-10-10 14:34:49 -070056#define CBMEM_ID_ELOG 0x454c4f47
Stefan Reinauer3b314022009-10-26 17:04:28 +000057#define CBMEM_ID_NONE 0x00000000
58
Stefan Reinauer61f4a742012-04-03 16:21:04 -070059#ifndef __ASSEMBLER__
60#ifndef __PRE_RAM__
61extern uint64_t high_tables_base, high_tables_size;
62#endif
63
Vadim Bendeburye1860602011-09-20 17:07:14 -070064int cbmem_initialize(void);
Stefan Reinauer3b314022009-10-26 17:04:28 +000065
66void cbmem_init(u64 baseaddr, u64 size);
67int cbmem_reinit(u64 baseaddr);
68void *cbmem_add(u32 id, u64 size);
69void *cbmem_find(u32 id);
Maciej Pijankaea921852009-10-27 14:29:29 +000070void cbmem_list(void);
71void cbmem_arch_init(void);
Stefan Reinauer3b314022009-10-26 17:04:28 +000072
Rudolf Marek475916d2010-12-13 20:02:23 +000073extern struct cbmem_entry *get_cbmem_toc(void);
74
Rudolf Marek33109342010-12-11 22:26:10 +000075#ifndef __PRE_RAM__
Rudolf Marekbcaea142010-11-22 22:00:52 +000076void set_cbmem_toc(struct cbmem_entry *);
Stefan Reinauerbb11e602012-05-10 12:15:18 -070077void __attribute__((weak)) cbmem_post_handling(void);
Stefan Reinauer3b314022009-10-26 17:04:28 +000078#endif
Rudolf Marek33109342010-12-11 22:26:10 +000079#endif
Stefan Reinauer61f4a742012-04-03 16:21:04 -070080#endif