Aaron Durbin | 595688a | 2016-03-31 11:38:13 -0500 | [diff] [blame] | 1 | /* |
| 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 Roth | ebabfad | 2016-04-10 11:09:16 -0600 | [diff] [blame] | 11 | * |
| 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 Durbin | 595688a | 2016-03-31 11:38:13 -0500 | [diff] [blame] | 16 | */ |
| 17 | |
| 18 | #include <arch/cpu.h> |
Furquan Shaikh | 0b6ff78 | 2016-04-21 08:10:02 -0700 | [diff] [blame] | 19 | #include <assert.h> |
Barnali Sarkar | 66fe0c4 | 2017-05-23 18:17:14 +0530 | [diff] [blame] | 20 | #include <cpu/x86/msr.h> |
| 21 | #include <intelblocks/msr.h> |
Aaron Durbin | 595688a | 2016-03-31 11:38:13 -0500 | [diff] [blame] | 22 | #include <program_loading.h> |
Naresh G Solanki | 4764be3 | 2018-04-05 11:22:12 +0530 | [diff] [blame^] | 23 | #include <soc/cpu.h> |
Aaron Durbin | 595688a | 2016-03-31 11:38:13 -0500 | [diff] [blame] | 24 | |
| 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 Shaikh | 0b6ff78 | 2016-04-21 08:10:02 -0700 | [diff] [blame] | 30 | static 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 Durbin | faa74b0 | 2016-03-31 14:00:47 -0500 | [diff] [blame] | 36 | void platform_segment_loaded(uintptr_t start, size_t size, int flags) |
Aaron Durbin | 595688a | 2016-03-31 11:38:13 -0500 | [diff] [blame] | 37 | { |
Furquan Shaikh | 0b6ff78 | 2016-04-21 08:10:02 -0700 | [diff] [blame] | 38 | /* Bail out if this is not the final segment. */ |
| 39 | if (!(flags & SEG_FINAL)) |
| 40 | return; |
Aaron Durbin | faa74b0 | 2016-03-31 14:00:47 -0500 | [diff] [blame] | 41 | |
Furquan Shaikh | 0b6ff78 | 2016-04-21 08:10:02 -0700 | [diff] [blame] | 42 | 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 Leahy | d8fb362 | 2017-03-09 10:10:25 -0800 | [diff] [blame] | 50 | assert(start_car_check && end_car_check); |
Furquan Shaikh | 0b6ff78 | 2016-04-21 08:10:02 -0700 | [diff] [blame] | 51 | |
| 52 | flush_l1d_to_l2(); |
Aaron Durbin | 595688a | 2016-03-31 11:38:13 -0500 | [diff] [blame] | 53 | } |