blob: d0f0c9a5cc1244d6c75f54256f7c35ecfb0e1c99 [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
Aaron Durbin8e4a3552013-02-08 17:28:04 -060031#if CONFIG_RELOCATABLE_RAMSTAGE
32#define HIGH_MEMORY_SAVE 0
33#else
zbaof7223732012-04-13 13:42:15 +080034#define HIGH_MEMORY_SAVE (CONFIG_RAMTOP - CONFIG_RAMBASE)
Aaron Durbin8e4a3552013-02-08 17:28:04 -060035#endif
36
zbaof7223732012-04-13 13:42:15 +080037#define HIGH_MEMORY_SIZE (HIGH_MEMORY_SAVE + CONFIG_HIGH_SCRATCH_MEMORY_SIZE + HIGH_MEMORY_DEF_SIZE)
Stefan Reinauer61f4a742012-04-03 16:21:04 -070038
39/* Delegation of resume backup memory so we don't have to
40 * (slowly) handle backing up OS memory in romstage.c
41 */
42#define CBMEM_BOOT_MODE 0x610
43#define CBMEM_RESUME_BACKUP 0x614
zbaof7223732012-04-13 13:42:15 +080044
45#else /* CONFIG_HAVE_ACPI_RESUME */
Rudolf Marek97be27e2010-12-13 19:50:25 +000046#define HIGH_MEMORY_SIZE HIGH_MEMORY_DEF_SIZE
zbaof7223732012-04-13 13:42:15 +080047#endif /* CONFIG_HAVE_ACPI_RESUME */
Stefan Reinauer3b314022009-10-26 17:04:28 +000048
49#define CBMEM_ID_FREESPACE 0x46524545
50#define CBMEM_ID_GDT 0x4c474454
51#define CBMEM_ID_ACPI 0x41435049
Duncan Laurie11290c42012-10-03 19:07:05 -070052#define CBMEM_ID_ACPI_GNVS 0x474e5653
Stefan Reinauer3b314022009-10-26 17:04:28 +000053#define CBMEM_ID_CBTABLE 0x43425442
54#define CBMEM_ID_PIRQ 0x49525154
55#define CBMEM_ID_MPTABLE 0x534d5054
56#define CBMEM_ID_RESUME 0x5245534d
zbaof7223732012-04-13 13:42:15 +080057#define CBMEM_ID_RESUME_SCRATCH 0x52455343
Sven Schnelle164bcfd2011-08-14 20:56:34 +020058#define CBMEM_ID_SMBIOS 0x534d4254
Vadim Bendebury6f72d692011-09-21 16:12:39 -070059#define CBMEM_ID_TIMESTAMP 0x54494d45
Stefan Reinauer61f4a742012-04-03 16:21:04 -070060#define CBMEM_ID_MRCDATA 0x4d524344
Vadim Bendeburybe25a4d2011-09-30 11:13:06 -070061#define CBMEM_ID_CONSOLE 0x434f4e53
Duncan Laurie215f27852012-10-10 14:34:49 -070062#define CBMEM_ID_ELOG 0x454c4f47
Stefan Reinauerd37ab452012-12-18 16:23:28 -080063#define CBMEM_ID_COVERAGE 0x47434f56
Aaron Durbina1db81b42013-02-08 17:11:28 -060064#define CBMEM_ID_ROMSTAGE_INFO 0x47545352
Stefan Reinauer3b314022009-10-26 17:04:28 +000065#define CBMEM_ID_NONE 0x00000000
66
Stefan Reinauer61f4a742012-04-03 16:21:04 -070067#ifndef __ASSEMBLER__
68#ifndef __PRE_RAM__
69extern uint64_t high_tables_base, high_tables_size;
70#endif
71
Vadim Bendeburye1860602011-09-20 17:07:14 -070072int cbmem_initialize(void);
Stefan Reinauer3b314022009-10-26 17:04:28 +000073
74void cbmem_init(u64 baseaddr, u64 size);
75int cbmem_reinit(u64 baseaddr);
76void *cbmem_add(u32 id, u64 size);
77void *cbmem_find(u32 id);
Maciej Pijankaea921852009-10-27 14:29:29 +000078void cbmem_list(void);
79void cbmem_arch_init(void);
Stefan Reinauer3b314022009-10-26 17:04:28 +000080
Rudolf Marek475916d2010-12-13 20:02:23 +000081extern struct cbmem_entry *get_cbmem_toc(void);
82
Rudolf Marek33109342010-12-11 22:26:10 +000083#ifndef __PRE_RAM__
Rudolf Marekbcaea142010-11-22 22:00:52 +000084void set_cbmem_toc(struct cbmem_entry *);
Stefan Reinauerbb11e602012-05-10 12:15:18 -070085void __attribute__((weak)) cbmem_post_handling(void);
Stefan Reinauer3b314022009-10-26 17:04:28 +000086#endif
Rudolf Marek33109342010-12-11 22:26:10 +000087#endif
Stefan Reinauer61f4a742012-04-03 16:21:04 -070088#endif