blob: 920580d0a1337d16bcc1f2134c369ba0af413471 [file] [log] [blame]
Aaron Durbin595688a2016-03-31 11:38:13 -05001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2016 Intel Corp.
5 * Copyright 2016 Google Inc.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
Martin Rothebabfad2016-04-10 11:09:16 -060011 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
Aaron Durbin595688a2016-03-31 11:38:13 -050016 */
17
18#include <arch/cpu.h>
Furquan Shaikh0b6ff782016-04-21 08:10:02 -070019#include <assert.h>
Barnali Sarkar66fe0c42017-05-23 18:17:14 +053020#include <cpu/x86/msr.h>
21#include <intelblocks/msr.h>
Aaron Durbin595688a2016-03-31 11:38:13 -050022#include <program_loading.h>
Naresh G Solanki4764be32018-04-05 11:22:12 +053023#include <soc/cpu.h>
Aaron Durbin595688a2016-03-31 11:38:13 -050024
25/*
26 * This file supports the necessary hoops one needs to jump through since
27 * early FSP component and early stages are running from cache-as-ram.
28 */
29
Furquan Shaikh0b6ff782016-04-21 08:10:02 -070030static inline int is_car_addr(uintptr_t addr)
31{
32 return ((addr >= CONFIG_DCACHE_RAM_BASE) &&
33 (addr < (CONFIG_DCACHE_RAM_BASE + CONFIG_DCACHE_RAM_SIZE)));
34}
35
Aaron Durbinfaa74b02016-03-31 14:00:47 -050036void platform_segment_loaded(uintptr_t start, size_t size, int flags)
Aaron Durbin595688a2016-03-31 11:38:13 -050037{
Furquan Shaikh0b6ff782016-04-21 08:10:02 -070038 /* Bail out if this is not the final segment. */
39 if (!(flags & SEG_FINAL))
40 return;
Aaron Durbinfaa74b02016-03-31 14:00:47 -050041
Furquan Shaikh0b6ff782016-04-21 08:10:02 -070042 char start_car_check = is_car_addr(start);
43 char end_car_check = is_car_addr(start + size - 1);
44
45 /* Bail out if loaded program segment does not lie in CAR region. */
46 if (!start_car_check && !end_car_check)
47 return;
48
49 /* Loaded program segment should lie entirely within CAR region. */
Lee Leahyd8fb3622017-03-09 10:10:25 -080050 assert(start_car_check && end_car_check);
Furquan Shaikh0b6ff782016-04-21 08:10:02 -070051
52 flush_l1d_to_l2();
Aaron Durbin595688a2016-03-31 11:38:13 -050053}