summaryrefslogtreecommitdiff
path: root/src/security/intel/stm/SmmStm.h
blob: c12b0347af4aa4fbe56ce73627e455e953c4ec5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/* SPDX-License-Identifier: BSD-2-Clause */

#ifndef _SMM_STM_H_
#define _SMM_STM_H_

#include <cpu/x86/msr.h>
#include "StmApi.h"

/*
 *  Load STM image.
 *
 *  @retval SUCCESS           STM is loaded to MSEG
 *  @retval BUFFER_TOO_SMALL  MSEG is too small
 *  @retval UNSUPPORTED       MSEG is not enabled
 */
int load_stm_image(uintptr_t mseg);

void stm_setup(
	uintptr_t mseg, int cpu, uintptr_t smbase,
	uintptr_t smbase_base, uint32_t offset32);

/*
 *  Add resources in list to database. Allocate new memory areas as needed.
 *
 *  @param resource_list  A pointer to resource list to be added
 *  @param num_entries    Optional number of entries.
 *			  If 0, list must be terminated by END_OF_RESOURCES.
 *
 *  @retval SUCCESS            If resources are added
 *  @retval INVALID_PARAMETER  If nested procedure detected resource failure
 *  @retval OUT_OF_RESOURCES    If nested procedure returned it and we cannot
 *				allocate more areas.
 */
int add_pi_resource(STM_RSC *resource_list, uint32_t num_entries);

/*
 *  Delete resources in list to database.
 *
 *  @param resource_list  A pointer to resource list to be deleted
 *			  NULL means delete all resources.
 *  @param num_entries    Optional number of entries.
 *			  If 0, list must be terminated by END_OF_RESOURCES.
 *
 *  @retval SUCCESS           If resources are deleted
 *  @retval NVALID_PARAMETER  If nested procedure detected resource fail
 */
int delete_pi_resource(STM_RSC *resource_list, uint32_t num_entries);

/*
 *  Get BIOS resources.
 *
 *  @param resource_list  A pointer to resource list to be filled
 *  @param resource_size  On input it means size of resource list input.
 *			 On output it means size of resource list filled,
 *			 or the size of resource list to be filled if
 *			 size is too small.
 *
 *  @retval SUCCESS            If resources are returned.
 *  @retval BUFFER_TOO_SMALL   If resource list buffer is too small to
 *				hold the whole resources.
 */
int get_pi_resource(STM_RSC *resource_list, uint32_t *resource_size);

/*
 *  This function notifies the STM of a resource change.
 *
 *  @param stm_resource BIOS STM resource
 */
void notify_stm_resource_change(void *stm_resource);

/*
 *  This function returns the pointer to the STM BIOS resource list.
 *
 *  @return BIOS STM resource
 */
void *get_stm_resource(void);

void setup_smm_descriptor(void *smbase, void *base_smbase, int32_t apic_id,
				int32_t entry32_off);

/*
 *  Check STM image size.
 *
 *  @param stm_image      STM image
 *  @param stm_image_size  STM image size
 *
 *  @retval true  check pass
 *  @retval false check fail
 */
bool stm_check_stm_image(void *stm_image, uint32_t stm_image_size);

/*
 * Create 4G page table for STM.
 * 4M Non-PAE page table in IA32 version.
 *
 *  @param page_table_base        The page table base in MSEG
 */
void stm_gen_4g_pagetable_ia32(uint32_t pagetable_base);

/*
 *  Create 4G page table for STM.
 *  2M PAE page table in X64 version.
 *
 *  @param pagetable_base        The page table base in MSEG
 */
void stm_gen_4g_pagetable_x64(uint32_t pagetable_base);

#endif