diff options
author | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2014-06-26 06:09:05 -0400 |
---|---|---|
committer | Matt Fleming <matt.fleming@intel.com> | 2014-07-07 15:12:53 -0400 |
commit | 022ee6c558fc933679e151f00f84332974147fa2 (patch) | |
tree | 1c9023d5cceddf7dd6c75508e4405f6bb316e93f /arch/x86 | |
parent | f49182ec8c685f4e89a50ba85ffe43b7f1e7b3e1 (diff) |
efi/x86: Move UEFI Runtime Services wrappers to generic code
In order for other archs (such as arm64) to be able to reuse the virtual
mode function call wrappers, move them to drivers/firmware/efi/runtime-wrappers.c.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/Kconfig | 1 | ||||
-rw-r--r-- | arch/x86/platform/efi/efi.c | 144 |
2 files changed, 3 insertions, 142 deletions
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index fcefdda5136d..801ed36c2e49 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig | |||
@@ -1522,6 +1522,7 @@ config EFI | |||
1522 | bool "EFI runtime service support" | 1522 | bool "EFI runtime service support" |
1523 | depends on ACPI | 1523 | depends on ACPI |
1524 | select UCS2_STRING | 1524 | select UCS2_STRING |
1525 | select EFI_RUNTIME_WRAPPERS | ||
1525 | ---help--- | 1526 | ---help--- |
1526 | This enables the kernel to use EFI runtime services that are | 1527 | This enables the kernel to use EFI runtime services that are |
1527 | available (such as the EFI variable services). | 1528 | available (such as the EFI variable services). |
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index f8524434bf65..135812b593cc 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c | |||
@@ -88,130 +88,6 @@ static int __init setup_add_efi_memmap(char *arg) | |||
88 | } | 88 | } |
89 | early_param("add_efi_memmap", setup_add_efi_memmap); | 89 | early_param("add_efi_memmap", setup_add_efi_memmap); |
90 | 90 | ||
91 | static efi_status_t virt_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc) | ||
92 | { | ||
93 | unsigned long flags; | ||
94 | efi_status_t status; | ||
95 | |||
96 | spin_lock_irqsave(&rtc_lock, flags); | ||
97 | status = efi_call_virt(get_time, tm, tc); | ||
98 | spin_unlock_irqrestore(&rtc_lock, flags); | ||
99 | return status; | ||
100 | } | ||
101 | |||
102 | static efi_status_t virt_efi_set_time(efi_time_t *tm) | ||
103 | { | ||
104 | unsigned long flags; | ||
105 | efi_status_t status; | ||
106 | |||
107 | spin_lock_irqsave(&rtc_lock, flags); | ||
108 | status = efi_call_virt(set_time, tm); | ||
109 | spin_unlock_irqrestore(&rtc_lock, flags); | ||
110 | return status; | ||
111 | } | ||
112 | |||
113 | static efi_status_t virt_efi_get_wakeup_time(efi_bool_t *enabled, | ||
114 | efi_bool_t *pending, | ||
115 | efi_time_t *tm) | ||
116 | { | ||
117 | unsigned long flags; | ||
118 | efi_status_t status; | ||
119 | |||
120 | spin_lock_irqsave(&rtc_lock, flags); | ||
121 | status = efi_call_virt(get_wakeup_time, enabled, pending, tm); | ||
122 | spin_unlock_irqrestore(&rtc_lock, flags); | ||
123 | return status; | ||
124 | } | ||
125 | |||
126 | static efi_status_t virt_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm) | ||
127 | { | ||
128 | unsigned long flags; | ||
129 | efi_status_t status; | ||
130 | |||
131 | spin_lock_irqsave(&rtc_lock, flags); | ||
132 | status = efi_call_virt(set_wakeup_time, enabled, tm); | ||
133 | spin_unlock_irqrestore(&rtc_lock, flags); | ||
134 | return status; | ||
135 | } | ||
136 | |||
137 | static efi_status_t virt_efi_get_variable(efi_char16_t *name, | ||
138 | efi_guid_t *vendor, | ||
139 | u32 *attr, | ||
140 | unsigned long *data_size, | ||
141 | void *data) | ||
142 | { | ||
143 | return efi_call_virt(get_variable, | ||
144 | name, vendor, attr, | ||
145 | data_size, data); | ||
146 | } | ||
147 | |||
148 | static efi_status_t virt_efi_get_next_variable(unsigned long *name_size, | ||
149 | efi_char16_t *name, | ||
150 | efi_guid_t *vendor) | ||
151 | { | ||
152 | return efi_call_virt(get_next_variable, | ||
153 | name_size, name, vendor); | ||
154 | } | ||
155 | |||
156 | static efi_status_t virt_efi_set_variable(efi_char16_t *name, | ||
157 | efi_guid_t *vendor, | ||
158 | u32 attr, | ||
159 | unsigned long data_size, | ||
160 | void *data) | ||
161 | { | ||
162 | return efi_call_virt(set_variable, | ||
163 | name, vendor, attr, | ||
164 | data_size, data); | ||
165 | } | ||
166 | |||
167 | static efi_status_t virt_efi_query_variable_info(u32 attr, | ||
168 | u64 *storage_space, | ||
169 | u64 *remaining_space, | ||
170 | u64 *max_variable_size) | ||
171 | { | ||
172 | if (efi.runtime_version < EFI_2_00_SYSTEM_TABLE_REVISION) | ||
173 | return EFI_UNSUPPORTED; | ||
174 | |||
175 | return efi_call_virt(query_variable_info, attr, storage_space, | ||
176 | remaining_space, max_variable_size); | ||
177 | } | ||
178 | |||
179 | static efi_status_t virt_efi_get_next_high_mono_count(u32 *count) | ||
180 | { | ||
181 | return efi_call_virt(get_next_high_mono_count, count); | ||
182 | } | ||
183 | |||
184 | static void virt_efi_reset_system(int reset_type, | ||
185 | efi_status_t status, | ||
186 | unsigned long data_size, | ||
187 | efi_char16_t *data) | ||
188 | { | ||
189 | __efi_call_virt(reset_system, reset_type, status, | ||
190 | data_size, data); | ||
191 | } | ||
192 | |||
193 | static efi_status_t virt_efi_update_capsule(efi_capsule_header_t **capsules, | ||
194 | unsigned long count, | ||
195 | unsigned long sg_list) | ||
196 | { | ||
197 | if (efi.runtime_version < EFI_2_00_SYSTEM_TABLE_REVISION) | ||
198 | return EFI_UNSUPPORTED; | ||
199 | |||
200 | return efi_call_virt(update_capsule, capsules, count, sg_list); | ||
201 | } | ||
202 | |||
203 | static efi_status_t virt_efi_query_capsule_caps(efi_capsule_header_t **capsules, | ||
204 | unsigned long count, | ||
205 | u64 *max_size, | ||
206 | int *reset_type) | ||
207 | { | ||
208 | if (efi.runtime_version < EFI_2_00_SYSTEM_TABLE_REVISION) | ||
209 | return EFI_UNSUPPORTED; | ||
210 | |||
211 | return efi_call_virt(query_capsule_caps, capsules, count, max_size, | ||
212 | reset_type); | ||
213 | } | ||
214 | |||
215 | static efi_status_t __init phys_efi_set_virtual_address_map( | 91 | static efi_status_t __init phys_efi_set_virtual_address_map( |
216 | unsigned long memory_map_size, | 92 | unsigned long memory_map_size, |
217 | unsigned long descriptor_size, | 93 | unsigned long descriptor_size, |
@@ -721,22 +597,6 @@ void __init old_map_region(efi_memory_desc_t *md) | |||
721 | (unsigned long long)md->phys_addr); | 597 | (unsigned long long)md->phys_addr); |
722 | } | 598 | } |
723 | 599 | ||
724 | static void native_runtime_setup(void) | ||
725 | { | ||
726 | efi.get_time = virt_efi_get_time; | ||
727 | efi.set_time = virt_efi_set_time; | ||
728 | efi.get_wakeup_time = virt_efi_get_wakeup_time; | ||
729 | efi.set_wakeup_time = virt_efi_set_wakeup_time; | ||
730 | efi.get_variable = virt_efi_get_variable; | ||
731 | efi.get_next_variable = virt_efi_get_next_variable; | ||
732 | efi.set_variable = virt_efi_set_variable; | ||
733 | efi.get_next_high_mono_count = virt_efi_get_next_high_mono_count; | ||
734 | efi.reset_system = virt_efi_reset_system; | ||
735 | efi.query_variable_info = virt_efi_query_variable_info; | ||
736 | efi.update_capsule = virt_efi_update_capsule; | ||
737 | efi.query_capsule_caps = virt_efi_query_capsule_caps; | ||
738 | } | ||
739 | |||
740 | /* Merge contiguous regions of the same type and attribute */ | 600 | /* Merge contiguous regions of the same type and attribute */ |
741 | static void __init efi_merge_regions(void) | 601 | static void __init efi_merge_regions(void) |
742 | { | 602 | { |
@@ -923,7 +783,7 @@ static void __init kexec_enter_virtual_mode(void) | |||
923 | */ | 783 | */ |
924 | efi.runtime_version = efi_systab.hdr.revision; | 784 | efi.runtime_version = efi_systab.hdr.revision; |
925 | 785 | ||
926 | native_runtime_setup(); | 786 | efi_native_runtime_setup(); |
927 | 787 | ||
928 | efi.set_virtual_address_map = NULL; | 788 | efi.set_virtual_address_map = NULL; |
929 | 789 | ||
@@ -1012,7 +872,7 @@ static void __init __efi_enter_virtual_mode(void) | |||
1012 | efi.runtime_version = efi_systab.hdr.revision; | 872 | efi.runtime_version = efi_systab.hdr.revision; |
1013 | 873 | ||
1014 | if (efi_is_native()) | 874 | if (efi_is_native()) |
1015 | native_runtime_setup(); | 875 | efi_native_runtime_setup(); |
1016 | else | 876 | else |
1017 | efi_thunk_runtime_setup(); | 877 | efi_thunk_runtime_setup(); |
1018 | 878 | ||