blob: 05325cceb9b54af329611b9f2fbc962de7599bb6 [file] [log] [blame]
Varadarajan Narayanana6935c22016-03-02 16:57:10 +05301/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright 2014 Google Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <cbmem.h>
17#include <soc/soc_services.h>
18
Varadarajan Narayanan8ce14a72016-03-29 12:30:38 +053019static int cbmem_backing_store_ready;
20
21void ipq_cbmem_backing_store_ready(void)
22{
23 cbmem_backing_store_ready = 1;
24}
25
Varadarajan Narayanana6935c22016-03-02 16:57:10 +053026void *cbmem_top(void)
27{
Varadarajan Narayanan8ce14a72016-03-29 12:30:38 +053028 /*
29 * In romstage, make sure that cbmem backing store is ready before
30 * returning pointer to cbmem top. Otherwise, it could lead to issues
31 * with components that utilize cbmem in romstage (e.g. vboot_locator
32 * for loading ipq blobs before DRAM is initialized).
33 */
34 if (ENV_ROMSTAGE && (cbmem_backing_store_ready == 0))
35 return NULL;
36
Varadarajan Narayanana6935c22016-03-02 16:57:10 +053037 return _memlayout_cbmem_top;
38}