blob: 384b441635c4d5bf84980e8ac480f778dd0cf5bf [file] [log] [blame]
Patrick Georgi02363b52020-05-05 20:48:50 +02001/* This file is part of the coreboot project. */
Patrick Georgiac959032020-05-05 22:49:26 +02002/* SPDX-License-Identifier: GPL-2.0-or-later */
Aaron Durbin595688a2016-03-31 11:38:13 -05003
Furquan Shaikh0b6ff782016-04-21 08:10:02 -07004#include <assert.h>
Barnali Sarkar66fe0c42017-05-23 18:17:14 +05305#include <cpu/x86/msr.h>
6#include <intelblocks/msr.h>
Aaron Durbin595688a2016-03-31 11:38:13 -05007#include <program_loading.h>
Naresh G Solanki4764be32018-04-05 11:22:12 +05308#include <soc/cpu.h>
Aaron Durbin595688a2016-03-31 11:38:13 -05009
10/*
11 * This file supports the necessary hoops one needs to jump through since
12 * early FSP component and early stages are running from cache-as-ram.
13 */
14
Furquan Shaikh0b6ff782016-04-21 08:10:02 -070015static inline int is_car_addr(uintptr_t addr)
16{
17 return ((addr >= CONFIG_DCACHE_RAM_BASE) &&
18 (addr < (CONFIG_DCACHE_RAM_BASE + CONFIG_DCACHE_RAM_SIZE)));
19}
20
Aaron Durbinfaa74b02016-03-31 14:00:47 -050021void platform_segment_loaded(uintptr_t start, size_t size, int flags)
Aaron Durbin595688a2016-03-31 11:38:13 -050022{
Furquan Shaikh0b6ff782016-04-21 08:10:02 -070023 /* Bail out if this is not the final segment. */
24 if (!(flags & SEG_FINAL))
25 return;
Aaron Durbinfaa74b02016-03-31 14:00:47 -050026
Furquan Shaikh0b6ff782016-04-21 08:10:02 -070027 char start_car_check = is_car_addr(start);
28 char end_car_check = is_car_addr(start + size - 1);
29
30 /* Bail out if loaded program segment does not lie in CAR region. */
31 if (!start_car_check && !end_car_check)
32 return;
33
34 /* Loaded program segment should lie entirely within CAR region. */
Lee Leahyd8fb3622017-03-09 10:10:25 -080035 assert(start_car_check && end_car_check);
Furquan Shaikh0b6ff782016-04-21 08:10:02 -070036
37 flush_l1d_to_l2();
Aaron Durbin595688a2016-03-31 11:38:13 -050038}