1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <commonlib/helpers.h>
5 #include <console/console.h>
6 #include <cpu/x86/smm.h>
7 #include <stage_cache.h>
12 * Subregions within SMM
13 * +-------------------------+
14 * | IED | IED_REGION_SIZE
15 * +-------------------------+
16 * | External Stage Cache | SMM_RESERVED_SIZE
17 * +-------------------------+
20 * +-------------------------+ TSEG
22 int smm_subregion(int sub
, uintptr_t *start
, size_t *size
)
26 const size_t ied_size
= CONFIG_IED_REGION_SIZE
;
27 const size_t cache_size
= CONFIG_SMM_RESERVED_SIZE
;
30 smm_region(&sub_base
, &sub_size
);
31 else if (CONFIG(SMM_ASEG
))
32 aseg_region(&sub_base
, &sub_size
);
36 ASSERT(IS_ALIGNED(sub_base
, sub_size
));
37 ASSERT(sub_size
> (cache_size
+ ied_size
));
40 case SMM_SUBREGION_HANDLER
:
41 /* Handler starts at the base of TSEG. */
43 sub_size
-= cache_size
;
45 case SMM_SUBREGION_CACHE
:
46 /* External cache is in the middle of TSEG. */
47 sub_base
+= sub_size
- (ied_size
+ cache_size
);
48 sub_size
= cache_size
;
50 case SMM_SUBREGION_CHIPSET
:
51 /* IED is at the top. */
52 sub_base
+= sub_size
- ied_size
;
64 void stage_cache_external_region(void **base
, size_t *size
)
68 if (smm_subregion(SMM_SUBREGION_CACHE
, (uintptr_t *)base
, size
))
69 printk(BIOS_ERR
, "No cache SMM subregion.\n");
72 void smm_list_regions(void)
78 smm_region(&base
, &size
);
82 printk(BIOS_DEBUG
, "SMM Memory Map\n");
83 printk(BIOS_DEBUG
, "SMRAM : 0x%" PRIxPTR
" 0x%zx\n", base
, size
);
85 for (i
= 0; i
< SMM_SUBREGION_NUM
; i
++) {
86 if (smm_subregion(i
, &base
, &size
))
88 printk(BIOS_DEBUG
, " Subregion %d: 0x%" PRIxPTR
" 0x%zx\n", i
, base
, size
);