1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 3 #ifndef _SMM_STM_H_ 4 #define _SMM_STM_H_ 5 6 #include "StmApi.h" 7 #include <stdbool.h> 8 9 /* 10 * Load STM image. 11 * 12 * @retval SUCCESS STM is loaded to MSEG 13 * @retval BUFFER_TOO_SMALL MSEG is too small 14 * @retval UNSUPPORTED MSEG is not enabled 15 */ 16 int load_stm_image(uintptr_t mseg); 17 18 void stm_setup( 19 uintptr_t mseg, int cpu, uintptr_t smbase, 20 uintptr_t smbase_base, uint32_t offset32); 21 22 /* 23 * Add resources in list to database. Allocate new memory areas as needed. 24 * 25 * @param resource_list A pointer to resource list to be added 26 * @param num_entries Optional number of entries. 27 * If 0, list must be terminated by END_OF_RESOURCES. 28 * 29 * @retval SUCCESS If resources are added 30 * @retval INVALID_PARAMETER If nested procedure detected resource failure 31 * @retval OUT_OF_RESOURCES If nested procedure returned it and we cannot 32 * allocate more areas. 33 */ 34 int add_pi_resource(STM_RSC *resource_list, uint32_t num_entries); 35 36 /* 37 * Delete resources in list to database. 38 * 39 * @param resource_list A pointer to resource list to be deleted 40 * NULL means delete all resources. 41 * @param num_entries Optional number of entries. 42 * If 0, list must be terminated by END_OF_RESOURCES. 43 * 44 * @retval SUCCESS If resources are deleted 45 * @retval NVALID_PARAMETER If nested procedure detected resource fail 46 */ 47 int delete_pi_resource(STM_RSC *resource_list, uint32_t num_entries); 48 49 /* 50 * Get BIOS resources. 51 * 52 * @param resource_list A pointer to resource list to be filled 53 * @param resource_size On input it means size of resource list input. 54 * On output it means size of resource list filled, 55 * or the size of resource list to be filled if 56 * size is too small. 57 * 58 * @retval SUCCESS If resources are returned. 59 * @retval BUFFER_TOO_SMALL If resource list buffer is too small to 60 * hold the whole resources. 61 */ 62 int get_pi_resource(STM_RSC *resource_list, uint32_t *resource_size); 63 64 /* 65 * This function notifies the STM of a resource change. 66 * 67 * @param stm_resource BIOS STM resource 68 */ 69 void notify_stm_resource_change(void *stm_resource); 70 71 /* 72 * This function returns the pointer to the STM BIOS resource list. 73 * 74 * @return BIOS STM resource 75 */ 76 void *get_stm_resource(void); 77 78 void setup_smm_descriptor(void *smbase, int32_t apic_id, 79 int32_t entry32_off); 80 81 /* 82 * Check STM image size. 83 * 84 * @param stm_image STM image 85 * @param stm_image_size STM image size 86 * 87 * @retval true check pass 88 * @retval false check fail 89 */ 90 bool stm_check_stm_image(void *stm_image, uint32_t stm_image_size); 91 92 /* 93 * Create 4G page table for STM. 94 * 4M Non-PAE page table in IA32 version. 95 * 96 * @param page_table_base The page table base in MSEG 97 */ 98 void stm_gen_4g_pagetable_ia32(uint32_t pagetable_base); 99 100 /* 101 * Create 4G page table for STM. 102 * 2M PAE page table in X64 version. 103 * 104 * @param pagetable_base The page table base in MSEG 105 */ 106 void stm_gen_4g_pagetable_x64(uint32_t pagetable_base); 107 108 #endif 109