intel/apollolake: Add API for get_bios_size and use it

get_bios_size returns the value of bios_size. Use this function to
calculate bios_size for caching in bootblock.

BUG=chrome-os-partner:54563

Change-Id: I2e592b1c52138bd4623ad2acd05c744224a8e50b
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://review.coreboot.org/15292
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Tested-by: build bot (Jenkins)
This commit is contained in:
Furquan Shaikh 2016-06-21 12:50:13 -07:00
parent 14b2a4d574
commit 8065bd4ce1
3 changed files with 34 additions and 7 deletions

View File

@ -22,6 +22,7 @@
#include <soc/iomap.h>
#include <soc/cpu.h>
#include <soc/gpio.h>
#include <soc/mmap_boot.h>
#include <soc/northbridge.h>
#include <soc/pci_devs.h>
#include <soc/uart.h>
@ -87,7 +88,8 @@ void asmlinkage bootblock_c_entry(uint64_t base_timestamp)
static void cache_bios_region(void)
{
int mtrr;
uint32_t rom_size, alignment;
size_t rom_size;
uint32_t alignment;
mtrr = get_free_var_mtrr();
@ -95,7 +97,8 @@ static void cache_bios_region(void)
return;
/* Only the IFD BIOS region is memory mapped (at top of 4G) */
rom_size = CONFIG_IFD_BIOS_END - CONFIG_IFD_BIOS_START;
rom_size = get_bios_size();
/* Round to power of two */
alignment = 1 << (log2_ceil(rom_size));
rom_size = ALIGN_UP(rom_size, alignment);

View File

@ -0,0 +1,22 @@
/*
* This file is part of the coreboot project.
*
* Copyright (C) 2016 Google Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef __SOC_APOLLOLAKE_MMAP_BOOT_H__
#define __SOC_APOLLOLAKE_MMAP_BOOT_H__
size_t get_bios_size(void);
#endif /* __SOC_APOLLOLAKE_MMAP_BOOT_H__ */

View File

@ -23,6 +23,7 @@
#include <console/console.h>
#include <fmap.h>
#include <soc/intel/common/nvm.h>
#include <soc/mmap_boot.h>
#include <soc/spi.h>
/*
@ -87,11 +88,6 @@ static void bios_mmap_init(void)
SPIBAR_BFPREG_PRL_SHIFT) + 1) * 4 * KiB;
size = bios_end - start;
printk(BIOS_INFO, "IFD BIOS region info loaded from FLREG%d\n",
(val & SPIBAR_BFPREG_SBRS) ? 6 : 1);
printk(BIOS_INFO, "IFD BIOS Start: 0x%zx\n", start);
printk(BIOS_INFO, "IFD BIOS End : 0x%zx\n", bios_end);
/* BIOS region is mapped right below 4G. */
base = 4ULL * GiB - size;
@ -167,3 +163,9 @@ uint32_t nvm_mmio_to_flash_offset(void *p)
*/
return (uintptr_t)p - (4ULL * GiB - size) + start;
}
size_t get_bios_size(void)
{
bios_mmap_init();
return car_get_var(bios_size);
}