arch/x86: document CAR symbols and expose them in symbols.h
Attempt to better document the symbol usage in car.ld for cache-as-ram usage. Additionally, add _car_region_[start|end] that completely covers the entire cache-as-ram region. The _car_data_[start|end] symbols were renamed to _car_relocatable_data_[start|end] in the hopes of making it clearer that objects within there move. Lastly, all these symbols were added to arch/symbols.h. Change-Id: I1f1af4983804dc8521d0427f43381bde6d23a060 Signed-off-by: Andrey Petrov <andrey.petrov@intel.com> Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://review.coreboot.org/13804 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth <martinroth@google.com> Reviewed-by: Furquan Shaikh <furquan@google.com>
This commit is contained in:
parent
b1bca88a04
commit
dd56de974d
|
@ -18,6 +18,7 @@
|
|||
/* This file is included inside a SECTIONS block */
|
||||
. = CONFIG_DCACHE_RAM_BASE;
|
||||
.car.data . (NOLOAD) : {
|
||||
_car_region_start = . ;
|
||||
/* Vboot work buffer is completely volatile outside of verstage and
|
||||
* romstage. Appropriate code needs to handle the transition. */
|
||||
#if IS_ENABLED(CONFIG_SEPARATE_VERSTAGE)
|
||||
|
@ -36,12 +37,12 @@
|
|||
* so that multiple stages (romstage and verstage) have a consistent
|
||||
* link address of these shared objects. */
|
||||
PRERAM_CBMEM_CONSOLE(., (CONFIG_LATE_CBMEM_INIT ? 0 : 0xc00))
|
||||
_car_data_start = .;
|
||||
_car_relocatable_data_start = .;
|
||||
/* The timestamp implementation relies on this storage to be around
|
||||
* after migration. One of the fields indicates not to use it as the
|
||||
* backing store once cbmem comes online. Therefore, this data needs
|
||||
* to reside in the migrated area (between _car_data_start and
|
||||
* _car_data_end). */
|
||||
* to reside in the migrated area (between _car_relocatable_data_start
|
||||
* and _car_relocatable_data_end). */
|
||||
TIMESTAMP(., 0x100)
|
||||
/* _car_global_start and _car_global_end provide symbols to per-stage
|
||||
* variables that are not shared like the timestamp and the pre-ram
|
||||
|
@ -51,7 +52,9 @@
|
|||
*(.car.global_data);
|
||||
. = ALIGN(ARCH_POINTER_ALIGN_SIZE);
|
||||
_car_global_end = .;
|
||||
_car_data_end = .;
|
||||
_car_relocatable_data_end = .;
|
||||
|
||||
_car_region_end = . + CONFIG_DCACHE_RAM_SIZE - (. - _car_region_start);
|
||||
}
|
||||
|
||||
/* Global variables are not allowed in romstage
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#ifndef ARCH_EARLY_VARIABLES_H
|
||||
#define ARCH_EARLY_VARIABLES_H
|
||||
|
||||
#include <arch/symbols.h>
|
||||
#include <stdlib.h>
|
||||
#include <rules.h>
|
||||
|
||||
|
@ -59,18 +60,15 @@ void *car_sync_var_ptr(void *var);
|
|||
#define car_set_var(var, val) \
|
||||
do { car_get_var(var) = (val); } while(0)
|
||||
|
||||
extern char _car_data_start[];
|
||||
extern char _car_data_end[];
|
||||
|
||||
static inline size_t car_data_size(void)
|
||||
{
|
||||
size_t car_size = &_car_data_end[0] - &_car_data_start[0];
|
||||
size_t car_size = _car_relocatable_data_size;
|
||||
return ALIGN(car_size, 64);
|
||||
}
|
||||
|
||||
static inline size_t car_object_offset(void *ptr)
|
||||
{
|
||||
return (char *)ptr - &_car_data_start[0];
|
||||
return (char *)ptr - &_car_relocatable_data_start[0];
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* This file is part of the coreboot project.
|
||||
*
|
||||
* Copyright (C) 2016 Intel Corp.
|
||||
* Copyright 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; version 2 of the License.
|
||||
*
|
||||
* 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 __ARCH_SYMBOLS_H
|
||||
#define __ARCH_SYMBOLS_H
|
||||
|
||||
/*
|
||||
* The _car_region_[start|end] covers the entirety of the cache as ram
|
||||
* region. All other symbols with the _car prefix a subsets of this
|
||||
* larger region.
|
||||
*/
|
||||
extern char _car_region_start[];
|
||||
extern char _car_region_end[];
|
||||
#define _car_region_size (_car_region_end - _car_region_start)
|
||||
|
||||
/*
|
||||
* This is the stack used under CONFIG_C_ENVIRONMENT_BOOTBLOCK for
|
||||
* all stages that execute when cache-as-ram is up.
|
||||
*/
|
||||
extern char _car_stack_start[];
|
||||
extern char _car_stack_end[];
|
||||
#define _car_stack_size (_car_stack_end - _car_stack_start)
|
||||
|
||||
/*
|
||||
* The _car_relocatable_data_[start|end] symbols cover CAR data which is
|
||||
* relocatable once memory comes online. Variables with CAR_GLOBAL decoration
|
||||
* reside within this region. The _car_global_[start|end] is a subset of the
|
||||
* relocatable region which excludes the timestamp region because of
|
||||
* intricacies in the timestamp code.
|
||||
*/
|
||||
extern char _car_relocatable_data_start[];
|
||||
extern char _car_relocatable_data_end[];
|
||||
#define _car_relocatable_data_size \
|
||||
(_car_relocatable_data_end - _car_relocatable_data_start)
|
||||
extern char _car_global_start[];
|
||||
extern char _car_global_end[];
|
||||
#define _car_global_size (_car_global_end - _car_global_start)
|
||||
|
||||
#endif
|
|
@ -150,11 +150,11 @@ void post_cache_as_ram(void)
|
|||
void *migrated_car = (void *)(CONFIG_RAMTOP - car_size);
|
||||
|
||||
print_car_debug("Copying data from cache to RAM...");
|
||||
memcpy_(migrated_car, &_car_data_start[0], car_size);
|
||||
memcpy_(migrated_car, _car_relocatable_data_start, car_size);
|
||||
print_car_debug(" Done\n");
|
||||
|
||||
print_car_debug("Verifying data integrity in RAM...");
|
||||
if (memcmp_(migrated_car, &_car_data_start[0], car_size) == 0)
|
||||
if (memcmp_(migrated_car, _car_relocatable_data_start, car_size) == 0)
|
||||
print_car_debug(" Done\n");
|
||||
else
|
||||
print_car_debug(" FAILED\n");
|
||||
|
|
|
@ -46,8 +46,8 @@ void *car_get_var_ptr(void *var)
|
|||
{
|
||||
char *migrated_base = NULL;
|
||||
int offset;
|
||||
void * _car_start = &_car_data_start;
|
||||
void * _car_end = &_car_data_end;
|
||||
void * _car_start = _car_relocatable_data_start;
|
||||
void * _car_end = _car_relocatable_data_end;
|
||||
|
||||
/* If the cache-as-ram has not been migrated return the pointer
|
||||
* passed in. */
|
||||
|
@ -84,8 +84,8 @@ void *car_get_var_ptr(void *var)
|
|||
void *car_sync_var_ptr(void *var)
|
||||
{
|
||||
void ** mig_var = car_get_var_ptr(var);
|
||||
void * _car_start = &_car_data_start;
|
||||
void * _car_end = &_car_data_end;
|
||||
void * _car_start = _car_relocatable_data_start;
|
||||
void * _car_end = _car_relocatable_data_end;
|
||||
|
||||
/* Not moved or migrated yet. */
|
||||
if (mig_var == var)
|
||||
|
@ -129,7 +129,7 @@ static void do_car_migrate_variables(void)
|
|||
return;
|
||||
}
|
||||
|
||||
memcpy(migrated_base, &_car_data_start[0], car_size);
|
||||
memcpy(migrated_base, _car_relocatable_data_start, car_size);
|
||||
|
||||
/* Mark that the data has been moved. */
|
||||
car_migrated = ~0;
|
||||
|
|
Loading…
Reference in New Issue