libpayload: Allow using CBFS functions on images in RAM
Two new functions allow switching the CBFS functions from using RAM or ROM, with ROM as default. Change-Id: I04d67ad622d25c5728ae9a63f5b8a3dc9bbacce6 Signed-off-by: Patrick Georgi <patrick.georgi@secunet.com> Reviewed-on: http://review.coreboot.org/550 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
parent
e8689ed974
commit
409d17dee7
|
@ -1,2 +1,4 @@
|
||||||
#include <arch/types.h>
|
#include <arch/types.h>
|
||||||
#include "cbfs_core.h"
|
#include "cbfs_core.h"
|
||||||
|
void setup_cbfs_from_ram(void* start, uint32_t size);
|
||||||
|
void setup_cbfs_from_flash(void);
|
||||||
|
|
|
@ -40,18 +40,18 @@
|
||||||
#define ERROR(x...) printf(x)
|
#define ERROR(x...) printf(x)
|
||||||
#define LOG(x...)
|
#define LOG(x...)
|
||||||
|
|
||||||
uint32_t host_virt_to_phys(void *addr);
|
static uint32_t host_virt_to_phys(void *addr);
|
||||||
void *host_phys_to_virt(uint32_t addr);
|
static void *host_phys_to_virt(uint32_t addr);
|
||||||
|
|
||||||
uint32_t romstart(void);
|
uint32_t romstart(void);
|
||||||
uint32_t romend(void);
|
uint32_t romend(void);
|
||||||
|
|
||||||
#include <arch/virtual.h>
|
#include <arch/virtual.h>
|
||||||
uint32_t host_virt_to_phys(void *addr) {
|
static uint32_t host_virt_to_phys(void *addr) {
|
||||||
return virt_to_phys(addr);
|
return virt_to_phys(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *host_phys_to_virt(uint32_t addr) {
|
static void *host_phys_to_virt(uint32_t addr) {
|
||||||
return phys_to_virt(addr);
|
return phys_to_virt(addr);
|
||||||
}
|
}
|
||||||
#undef virt_to_phys
|
#undef virt_to_phys
|
||||||
|
@ -76,3 +76,26 @@ uint32_t romend(void)
|
||||||
|
|
||||||
#include "cbfs_core.c"
|
#include "cbfs_core.c"
|
||||||
|
|
||||||
|
static uint32_t ram_cbfs_offset;
|
||||||
|
|
||||||
|
static uint32_t ram_virt_to_phys(void *addr) {
|
||||||
|
return (uint32_t)addr - ram_cbfs_offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *ram_phys_to_virt(uint32_t addr) {
|
||||||
|
return (void*)addr + ram_cbfs_offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup_cbfs_from_ram(void* start, uint32_t size)
|
||||||
|
{
|
||||||
|
/* assumes rollover */
|
||||||
|
ram_cbfs_offset = (uint32_t)start + size;
|
||||||
|
virt_to_phys = ram_virt_to_phys;
|
||||||
|
phys_to_virt = ram_phys_to_virt;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup_cbfs_from_flash()
|
||||||
|
{
|
||||||
|
virt_to_phys = host_virt_to_phys;
|
||||||
|
phys_to_virt = host_phys_to_virt;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue