blob: fc6691b0fb20d005204c4b21a1884b80ad6dc594 [file] [log] [blame]
Patrick Georgiac959032020-05-05 22:49:26 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Aaron Durbin595688a2016-03-31 11:38:13 -05002
Furquan Shaikh0b6ff782016-04-21 08:10:02 -07003#include <assert.h>
Barnali Sarkar66fe0c42017-05-23 18:17:14 +05304#include <intelblocks/msr.h>
Aaron Durbin595688a2016-03-31 11:38:13 -05005#include <program_loading.h>
Naresh G Solanki4764be32018-04-05 11:22:12 +05306#include <soc/cpu.h>
Aaron Durbin595688a2016-03-31 11:38:13 -05007
8/*
9 * This file supports the necessary hoops one needs to jump through since
10 * early FSP component and early stages are running from cache-as-ram.
11 */
12
Furquan Shaikh0b6ff782016-04-21 08:10:02 -070013static inline int is_car_addr(uintptr_t addr)
14{
15 return ((addr >= CONFIG_DCACHE_RAM_BASE) &&
16 (addr < (CONFIG_DCACHE_RAM_BASE + CONFIG_DCACHE_RAM_SIZE)));
17}
18
Aaron Durbinfaa74b02016-03-31 14:00:47 -050019void platform_segment_loaded(uintptr_t start, size_t size, int flags)
Aaron Durbin595688a2016-03-31 11:38:13 -050020{
Furquan Shaikh0b6ff782016-04-21 08:10:02 -070021 /* Bail out if this is not the final segment. */
22 if (!(flags & SEG_FINAL))
23 return;
Aaron Durbinfaa74b02016-03-31 14:00:47 -050024
Furquan Shaikh0b6ff782016-04-21 08:10:02 -070025 char start_car_check = is_car_addr(start);
26 char end_car_check = is_car_addr(start + size - 1);
27
28 /* Bail out if loaded program segment does not lie in CAR region. */
29 if (!start_car_check && !end_car_check)
30 return;
31
32 /* Loaded program segment should lie entirely within CAR region. */
Lee Leahyd8fb3622017-03-09 10:10:25 -080033 assert(start_car_check && end_car_check);
Furquan Shaikh0b6ff782016-04-21 08:10:02 -070034
35 flush_l1d_to_l2();
Aaron Durbin595688a2016-03-31 11:38:13 -050036}