655 changes: 655 additions & 0 deletions src/cpu/x86/smm/smm_module_loaderv2.c

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions src/include/cpu/x86/smm.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ static inline bool smm_points_to_smram(const void *ptr, const size_t len)
* into this field so the code doing the loading can manipulate the
* runtime's assumptions. e.g. updating the APIC id to CPU map to
* handle sparse APIC id space.
* The following parameters are only used when X86_SMM_LOADER_VERSION2 is enabled.
* - smm_entry - entry address of first CPU thread, all others will be tiled
* below this address.
* - smm_main_entry_offset - default entry offset (e.g 0x8000)
* - smram_start - smaram starting address
* - smram_end - smram ending address
*/
struct smm_loader_params {
void *stack_top;
Expand All @@ -141,12 +147,24 @@ struct smm_loader_params {
void *handler_arg;

struct smm_runtime *runtime;

/* The following are only used by X86_SMM_LOADER_VERSION2 */
#if CONFIG(X86_SMM_LOADER_VERSION2)
unsigned int smm_entry;
unsigned int smm_main_entry_offset;
unsigned int smram_start;
unsigned int smram_end;
#endif
};

/* Both of these return 0 on success, < 0 on failure. */
int smm_setup_relocation_handler(struct smm_loader_params *params);
int smm_load_module(void *smram, size_t size, struct smm_loader_params *params);

#if CONFIG(X86_SMM_LOADER_VERSION2)
u32 smm_get_cpu_smbase(unsigned int cpu_num);
#endif

/* Backup and restore default SMM region. */
void *backup_default_smm_area(void);
void restore_default_smm_area(void *smm_save_area);
Expand Down