Angel Pons | 0612b27 | 2020-04-05 15:46:56 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Michael Niewöhner | e0ad1fa | 2019-10-28 18:55:14 +0100 | [diff] [blame] | 2 | |
| 3 | #include <arch/romstage.h> |
| 4 | #include <cbmem.h> |
| 5 | #include <console/console.h> |
| 6 | #include <cpu/x86/mtrr.h> |
| 7 | #include <cpu/x86/smm.h> |
Srinidhi N Kaushik | 4eb489f | 2020-11-25 02:21:57 -0800 | [diff] [blame] | 8 | #include <intelblocks/fast_spi.h> |
Michael Niewöhner | e0ad1fa | 2019-10-28 18:55:14 +0100 | [diff] [blame] | 9 | #include <intelblocks/systemagent.h> |
Angel Pons | 3dea2b6 | 2020-10-01 22:50:12 +0200 | [diff] [blame] | 10 | #include <types.h> |
Michael Niewöhner | e0ad1fa | 2019-10-28 18:55:14 +0100 | [diff] [blame] | 11 | |
Michael Niewöhner | e75a64f | 2019-10-19 15:17:06 +0200 | [diff] [blame] | 12 | /* |
| 13 | * Expected Host Memory Map (we don't know 100% and not all regions are present on all SoCs): |
| 14 | * |
| 15 | * +---------------------------+ TOUUD |
| 16 | * | | |
| 17 | * +---------------------------+ TOM (if mem > 4GB) |
| 18 | * | CSME UMA (if mem > 4 GiB) | |
| 19 | * +---------------------------+ TOUUD |
| 20 | * | | |
| 21 | * +---------------------------+ 4GiB |
| 22 | * | PCI Address Space | |
| 23 | * +---------------------------+ TOM (if mem < 4GB) |
| 24 | * | CSME UMA (if mem < 4 GiB) | |
| 25 | * +---------------------------+ TOLUD (also maps into MC address space) |
| 26 | * | iGD / DSM | |
| 27 | * +---------------------------+ BDSM |
| 28 | * | GTT / GSM | |
| 29 | * +---------------------------+ TOLM |
| 30 | * | TSEG | |
| 31 | * +---------------------------+ TSEGMB |
| 32 | * | DMA Protected Region | |
| 33 | * +---------------------------+ DPR |
| 34 | * | PRM (C6DRAM/SGX) | |
| 35 | * +---------------------------+ PRMRR |
| 36 | * | Probeless Trace | |
| 37 | * +---------------------------+ ME Stolen |
| 38 | * | PTT | |
| 39 | * +---------------------------+ TOLUM / top_of_ram / cbmem_top |
| 40 | * | CBMEM Root | |
| 41 | * +---------------------------+ |
| 42 | * | FSP Reserved Memory | |
| 43 | * +---------------------------+ |
| 44 | * | various CBMEM entries | |
| 45 | * +---------------------------+ top_of_stack (8 byte aligned) |
| 46 | * | stack (CBMEM entry) | |
| 47 | * +---------------------------+ FSP TOLUM |
| 48 | * | | |
| 49 | * +---------------------------+ 0 |
| 50 | */ |
| 51 | |
Michael Niewöhner | e0ad1fa | 2019-10-28 18:55:14 +0100 | [diff] [blame] | 52 | void smm_region(uintptr_t *start, size_t *size) |
| 53 | { |
| 54 | *start = sa_get_tseg_base(); |
| 55 | *size = sa_get_tseg_size(); |
| 56 | } |
| 57 | |
Michael Niewöhner | e0ad1fa | 2019-10-28 18:55:14 +0100 | [diff] [blame] | 58 | void fill_postcar_frame(struct postcar_frame *pcf) |
| 59 | { |
Angel Pons | 3dea2b6 | 2020-10-01 22:50:12 +0200 | [diff] [blame] | 60 | /* FSP does not seem to bother w.r.t. alignment when asked to place cbmem_top() */ |
| 61 | uintptr_t top_of_ram = ALIGN_UP((uintptr_t)cbmem_top(), 8 * MiB); |
Michael Niewöhner | e0ad1fa | 2019-10-28 18:55:14 +0100 | [diff] [blame] | 62 | |
| 63 | /* |
| 64 | * We need to make sure ramstage will be run cached. At this |
| 65 | * point exact location of ramstage in cbmem is not known. |
Angel Pons | 3dea2b6 | 2020-10-01 22:50:12 +0200 | [diff] [blame] | 66 | * Instruct postcar to cache 16 megs below cbmem top which is |
Michael Niewöhner | e0ad1fa | 2019-10-28 18:55:14 +0100 | [diff] [blame] | 67 | * a safe bet to cover ramstage. |
| 68 | */ |
Michael Niewöhner | e0ad1fa | 2019-10-28 18:55:14 +0100 | [diff] [blame] | 69 | printk(BIOS_DEBUG, "top_of_ram = 0x%lx\n", top_of_ram); |
Angel Pons | 3dea2b6 | 2020-10-01 22:50:12 +0200 | [diff] [blame] | 70 | |
| 71 | postcar_frame_add_mtrr(pcf, top_of_ram - 16 * MiB, 16 * MiB, MTRR_TYPE_WRBACK); |
Michael Niewöhner | e0ad1fa | 2019-10-28 18:55:14 +0100 | [diff] [blame] | 72 | |
| 73 | /* Cache the TSEG region */ |
| 74 | postcar_enable_tseg_cache(pcf); |
Srinidhi N Kaushik | 4eb489f | 2020-11-25 02:21:57 -0800 | [diff] [blame] | 75 | |
| 76 | /* Cache the extended BIOS region if it is supported */ |
| 77 | fast_spi_cache_ext_bios_postcar(pcf); |
Michael Niewöhner | e0ad1fa | 2019-10-28 18:55:14 +0100 | [diff] [blame] | 78 | } |