Patrick Georgi | 02363b5 | 2020-05-05 20:48:50 +0200 | [diff] [blame] | 1 | /* This file is part of the coreboot project. */ |
Patrick Georgi | ac95903 | 2020-05-05 22:49:26 +0200 | [diff] [blame^] | 2 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Aaron Durbin | 595688a | 2016-03-31 11:38:13 -0500 | [diff] [blame] | 3 | |
Furquan Shaikh | 0b6ff78 | 2016-04-21 08:10:02 -0700 | [diff] [blame] | 4 | #include <assert.h> |
Barnali Sarkar | 66fe0c4 | 2017-05-23 18:17:14 +0530 | [diff] [blame] | 5 | #include <cpu/x86/msr.h> |
| 6 | #include <intelblocks/msr.h> |
Aaron Durbin | 595688a | 2016-03-31 11:38:13 -0500 | [diff] [blame] | 7 | #include <program_loading.h> |
Naresh G Solanki | 4764be3 | 2018-04-05 11:22:12 +0530 | [diff] [blame] | 8 | #include <soc/cpu.h> |
Aaron Durbin | 595688a | 2016-03-31 11:38:13 -0500 | [diff] [blame] | 9 | |
| 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 Shaikh | 0b6ff78 | 2016-04-21 08:10:02 -0700 | [diff] [blame] | 15 | static 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 Durbin | faa74b0 | 2016-03-31 14:00:47 -0500 | [diff] [blame] | 21 | void platform_segment_loaded(uintptr_t start, size_t size, int flags) |
Aaron Durbin | 595688a | 2016-03-31 11:38:13 -0500 | [diff] [blame] | 22 | { |
Furquan Shaikh | 0b6ff78 | 2016-04-21 08:10:02 -0700 | [diff] [blame] | 23 | /* Bail out if this is not the final segment. */ |
| 24 | if (!(flags & SEG_FINAL)) |
| 25 | return; |
Aaron Durbin | faa74b0 | 2016-03-31 14:00:47 -0500 | [diff] [blame] | 26 | |
Furquan Shaikh | 0b6ff78 | 2016-04-21 08:10:02 -0700 | [diff] [blame] | 27 | 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 Leahy | d8fb362 | 2017-03-09 10:10:25 -0800 | [diff] [blame] | 35 | assert(start_car_check && end_car_check); |
Furquan Shaikh | 0b6ff78 | 2016-04-21 08:10:02 -0700 | [diff] [blame] | 36 | |
| 37 | flush_l1d_to_l2(); |
Aaron Durbin | 595688a | 2016-03-31 11:38:13 -0500 | [diff] [blame] | 38 | } |