CBMEM: Fix allocation for static CBMEM
CBMEM console buffer size is adjustable in menuconfig, but this would not correctly adjust the overall allocation made for CBMEM. HIGH_MEMORY_SIZE is aligned to 64kB and definitions are moved down in the header file as HIGH_MEMORY_SIZE is not used with DYNAMIC_CBMEM. Try to continue boot even if CBMEM cannot be created. This error would only occur during development of new ports anyways and more log output is better. Change-Id: I4ee2df601b12ab6532ffcae8897775ecaa2fc05f Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: http://review.coreboot.org/4621 Reviewed-by: Aaron Durbin <adurbin@google.com> Tested-by: build bot (Jenkins)
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <console/console.h>
|
#include <console/console.h>
|
||||||
#include <cbmem.h>
|
#include <cbmem.h>
|
||||||
#include <arch/acpi.h>
|
#include <arch/acpi.h>
|
||||||
|
@@ -21,13 +21,6 @@
|
|||||||
#ifndef _CBMEM_H_
|
#ifndef _CBMEM_H_
|
||||||
#define _CBMEM_H_
|
#define _CBMEM_H_
|
||||||
|
|
||||||
/* Reserve 128k for ACPI and other tables */
|
|
||||||
#if CONFIG_CONSOLE_CBMEM
|
|
||||||
#define HIGH_MEMORY_DEF_SIZE ( 256 * 1024 )
|
|
||||||
#else
|
|
||||||
#define HIGH_MEMORY_DEF_SIZE ( 128 * 1024 )
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if CONFIG_HAVE_ACPI_RESUME
|
#if CONFIG_HAVE_ACPI_RESUME
|
||||||
#if CONFIG_RELOCATABLE_RAMSTAGE
|
#if CONFIG_RELOCATABLE_RAMSTAGE
|
||||||
#define HIGH_MEMORY_SAVE 0
|
#define HIGH_MEMORY_SAVE 0
|
||||||
@@ -35,16 +28,11 @@
|
|||||||
#define HIGH_MEMORY_SAVE (CONFIG_RAMTOP - CONFIG_RAMBASE)
|
#define HIGH_MEMORY_SAVE (CONFIG_RAMTOP - CONFIG_RAMBASE)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define HIGH_MEMORY_SIZE (HIGH_MEMORY_SAVE + CONFIG_HIGH_SCRATCH_MEMORY_SIZE + HIGH_MEMORY_DEF_SIZE)
|
|
||||||
|
|
||||||
/* Delegation of resume backup memory so we don't have to
|
/* Delegation of resume backup memory so we don't have to
|
||||||
* (slowly) handle backing up OS memory in romstage.c
|
* (slowly) handle backing up OS memory in romstage.c
|
||||||
*/
|
*/
|
||||||
#define CBMEM_BOOT_MODE 0x610
|
#define CBMEM_BOOT_MODE 0x610
|
||||||
#define CBMEM_RESUME_BACKUP 0x614
|
#define CBMEM_RESUME_BACKUP 0x614
|
||||||
|
|
||||||
#else /* CONFIG_HAVE_ACPI_RESUME */
|
|
||||||
#define HIGH_MEMORY_SIZE HIGH_MEMORY_DEF_SIZE
|
|
||||||
#endif /* CONFIG_HAVE_ACPI_RESUME */
|
#endif /* CONFIG_HAVE_ACPI_RESUME */
|
||||||
|
|
||||||
#define CBMEM_ID_FREESPACE 0x46524545
|
#define CBMEM_ID_FREESPACE 0x46524545
|
||||||
@@ -130,6 +118,24 @@ u64 cbmem_entry_size(const struct cbmem_entry *entry);
|
|||||||
|
|
||||||
#else /* !CONFIG_DYNAMIC_CBMEM */
|
#else /* !CONFIG_DYNAMIC_CBMEM */
|
||||||
|
|
||||||
|
/* Allocation with static CBMEM is resolved at build time. We start
|
||||||
|
* with 128kB and conditionally add some of the most greedy CBMEM
|
||||||
|
* table entries.
|
||||||
|
*/
|
||||||
|
#define _CBMEM_SZ_MINIMAL ( 128 * 1024 )
|
||||||
|
|
||||||
|
#if CONFIG_HAVE_ACPI_RESUME
|
||||||
|
#define _CBMEM_SZ_RESUME (HIGH_MEMORY_SAVE + CONFIG_HIGH_SCRATCH_MEMORY_SIZE)
|
||||||
|
#else
|
||||||
|
#define _CBMEM_SZ_RESUME 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define _CBMEM_SZ_TOTAL \
|
||||||
|
(_CBMEM_SZ_MINIMAL + _CBMEM_SZ_RESUME + CONFIG_CONSOLE_CBMEM_BUFFER_SIZE)
|
||||||
|
|
||||||
|
#define HIGH_MEMORY_SIZE ALIGN_UP(_CBMEM_SZ_TOTAL, 0x10000)
|
||||||
|
|
||||||
|
|
||||||
#ifndef __PRE_RAM__
|
#ifndef __PRE_RAM__
|
||||||
void set_top_of_ram(uint64_t ramtop);
|
void set_top_of_ram(uint64_t ramtop);
|
||||||
void backup_top_of_ram(uint64_t ramtop);
|
void backup_top_of_ram(uint64_t ramtop);
|
||||||
|
@@ -104,13 +104,12 @@ static void cbmem_init(void)
|
|||||||
cbmem_locate_table(&baseaddr, &size);
|
cbmem_locate_table(&baseaddr, &size);
|
||||||
cbmem_trace_location(baseaddr, size, __FUNCTION__);
|
cbmem_trace_location(baseaddr, size, __FUNCTION__);
|
||||||
|
|
||||||
cbmem_toc = (struct cbmem_entry *)(unsigned long)baseaddr;
|
if (!(baseaddr && size)) {
|
||||||
|
printk(BIOS_CRIT, "Unable to set location for CBMEM.\n");
|
||||||
if (size < (64 * 1024)) {
|
return;
|
||||||
printk(BIOS_DEBUG, "Increase CBMEM size!\n");
|
|
||||||
for (;;) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cbmem_toc = (struct cbmem_entry *)(unsigned long)baseaddr;
|
||||||
memset(cbmem_toc, 0, CBMEM_TOC_RESERVED);
|
memset(cbmem_toc, 0, CBMEM_TOC_RESERVED);
|
||||||
|
|
||||||
cbmem_toc[0] = (struct cbmem_entry) {
|
cbmem_toc[0] = (struct cbmem_entry) {
|
||||||
|
Reference in New Issue
Block a user