cbmem: Extend hooks to ramstage, fix timestamp synching
Commit 7dd5bbd71 (cbmem: Unify random on-CBMEM-init tasks under common
CBMEM_INIT_HOOK() API) inadvertently broke ramstage timestamps since
timestamp_sync() was no longer called there. Oops.
This patch fixes the issue by extending the CBMEM_INIT_HOOK() mechanism
to the cbmem_initialize() call in ramstage. The macro is split into
explicit ROMSTAGE_/RAMSTAGE_ versions to make the behavior as clear as
possible and prevent surprises (although just using a single macro and
relying on the Makefiles to link an object into all appropriate stages
would also work).
This allows us to get rid of the explicit cbmemc_reinit() in ramstage
(which I somehow accounted for in the last patch without realizing that
timestamps work exactly the same way...), and replace the older and less
flexible cbmem_arch_init() mechanism.
Also added a size assertion for the pre-RAM CBMEM console to memlayout
that could prevent a very unlikely buffer overflow I just noticed.
BRANCH=None
BUG=None
TEST=Booted on Pinky and Falco, confirmed that ramstage timestamps once
again show up. Compile-tested for Rambi and Samus.
Change-Id: If907266c3f20dc3d599b5c968ea5b39fe5c00e9c
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/233533
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
parent
9c57d6a842
commit
18fdeb7d32
15 changed files with 32 additions and 41 deletions
|
|
@ -204,19 +204,24 @@ void *cbmem_add(u32 id, u64 size);
|
|||
void *cbmem_find(u32 id);
|
||||
|
||||
typedef void (* const cbmem_init_hook_t)(void);
|
||||
#define CBMEM_INIT_HOOK(init_fn_) static cbmem_init_hook_t init_fn_ ## _ptr \
|
||||
__attribute__((used, section(".rodata.cbmem_init_hooks"))) = init_fn_;
|
||||
void cbmem_run_init_hooks(void);
|
||||
|
||||
#ifndef __PRE_RAM__
|
||||
/* Ramstage only functions. */
|
||||
void cbmem_list(void);
|
||||
void cbmem_arch_init(void);
|
||||
void cbmem_print_entry(int n, u32 id, u64 start, u64 size);
|
||||
static inline void cbmem_run_init_hooks(void) {}
|
||||
#else
|
||||
static inline void cbmem_arch_init(void) {}
|
||||
void cbmem_run_init_hooks(void);
|
||||
#endif /* __PRE_RAM__ */
|
||||
#define ROMSTAGE_CBMEM_INIT_HOOK(init_fn_) static cbmem_init_hook_t \
|
||||
init_fn_ ## _unused_ __attribute__((unused)) = init_fn_;
|
||||
#define RAMSTAGE_CBMEM_INIT_HOOK(init_fn_) \
|
||||
static cbmem_init_hook_t init_fn_ ## _ptr_ __attribute__((used, \
|
||||
section(".rodata.cbmem_init_hooks"))) = init_fn_;
|
||||
#else /* __PRE_RAM__ */
|
||||
#define ROMSTAGE_CBMEM_INIT_HOOK(init_fn_) \
|
||||
static cbmem_init_hook_t init_fn_ ## _ptr_ __attribute__((used, \
|
||||
section(".rodata.cbmem_init_hooks"))) = init_fn_;
|
||||
#define RAMSTAGE_CBMEM_INIT_HOOK(init_fn_) static cbmem_init_hook_t \
|
||||
init_fn_ ## _unused_ __attribute__((unused)) = init_fn_;
|
||||
#endif /* !__PRE_RAM__ */
|
||||
|
||||
#endif /* __ASSEMBLER__ */
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,9 @@
|
|||
REGION(timestamp, addr, size, 8)
|
||||
|
||||
#define PRERAM_CBMEM_CONSOLE(addr, size) \
|
||||
REGION(preram_cbmem_console, addr, size, 4)
|
||||
REGION(preram_cbmem_console, addr, size, 4) \
|
||||
_ = ASSERT(size <= CONFIG_CONSOLE_CBMEM_BUFFER_SIZE, \
|
||||
"pre-RAM CBMEM console size must not be larger than post-RAM!");
|
||||
|
||||
/* Use either CBFS_CACHE (unified) or both (PRERAM|POSTRAM)_CBFS_CACHE */
|
||||
#define CBFS_CACHE(addr, size) REGION(cbfs_cache, addr, size, 4)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue