Rev 9253 | Rev 9958 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 9253 | Rev 9286 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2020-2021. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2020-2021. All rights reserved. ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; Version 2, or (at your option) any later version. ;; |
5 | ;; Version 2, or (at your option) any later version. ;; |
6 | ;; ;; |
6 | ;; ;; |
7 | ;; Written by Ivan Baravy ;; |
7 | ;; Written by Ivan Baravy ;; |
8 | ;; ;; |
8 | ;; ;; |
9 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
9 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
10 | 10 | ||
11 | format pe64 efi |
11 | format pe64 efi |
12 | entry main |
12 | entry main |
13 | 13 | ||
14 | section '.text' code executable readable |
14 | section '.text' code executable readable |
15 | 15 | ||
16 | include '../../struct.inc' |
16 | include '../../struct.inc' |
17 | include '../../macros.inc' |
17 | include '../../macros.inc' |
18 | include '../../kglobals.inc' |
18 | include '../../kglobals.inc' |
19 | fastcall fix fstcall |
19 | fastcall fix fstcall |
20 | include 'proc64.inc' |
20 | include 'proc64.inc' |
21 | include '../../const.inc' |
21 | include '../../const.inc' |
22 | 22 | ||
23 | purge DQ |
23 | purge DQ |
24 | include 'uefi64.inc' |
24 | include 'uefi64.inc' |
25 | 25 | ||
26 | MEMORY_MAP_SIZE = 0x10000 |
26 | MEMORY_MAP_SIZE = 0x10000 |
27 | PROTOCOL_HANDLERS_BUFFER_SIZE = 0x100 |
27 | PROTOCOL_HANDLERS_BUFFER_SIZE = 0x100 |
28 | FILE_BUFFER_SIZE = 0x1000 |
28 | FILE_BUFFER_SIZE = 0x1000 |
29 | 29 | ||
30 | KERNEL_TRAMPOLINE = 0x8f80 ; just before BOOT_LO |
30 | KERNEL_TRAMPOLINE = 0x8f80 ; just before BOOT_LO |
31 | KERNEL_BASE = 0x10000 |
31 | KERNEL_BASE = 0x10000 |
32 | RAMDISK_BASE = 0x100000 |
32 | RAMDISK_BASE = 0x100000 |
33 | MAX_FILE_SIZE = 0x10000000 |
33 | MAX_FILE_SIZE = 0x10000000 |
34 | 34 | ||
35 | CODE_32_SELECTOR = 8 |
35 | CODE_32_SELECTOR = 8 |
36 | DATA_32_SELECTOR = 16 |
36 | DATA_32_SELECTOR = 16 |
37 | CODE_64_SELECTOR = 24 |
37 | CODE_64_SELECTOR = 24 |
38 | 38 | ||
39 | ; linux/arch/x86/include/uapi/asm/e820.h |
39 | ; linux/arch/x86/include/uapi/asm/e820.h |
40 | E820_RAM = 1 |
40 | E820_RAM = 1 |
41 | E820_RESERVED = 2 |
41 | E820_RESERVED = 2 |
42 | E820_ACPI = 3 |
42 | E820_ACPI = 3 |
43 | E820_NVS = 4 |
43 | E820_NVS = 4 |
44 | E820_UNUSABLE = 5 |
44 | E820_UNUSABLE = 5 |
45 | E820_PMEM = 7 |
45 | E820_PMEM = 7 |
46 | 46 | ||
47 | proc load_file _root, _name, _buffer, _size, _fatal |
47 | proc load_file _root, _name, _buffer, _size, _fatal |
48 | locals |
- | |
49 | .status dq ? |
- | |
50 | endl |
- | |
51 | mov [_root], rcx |
48 | mov [_root], rcx |
52 | mov [_name], rdx |
49 | mov [_name], rdx |
53 | mov [_buffer], r8 |
50 | mov [_buffer], r8 |
54 | mov [_size], r9 |
51 | mov [_size], r9 |
55 | mov r10, [_root] |
52 | mov r10, [_root] |
56 | mov r11, [_name] |
53 | mov r11, [_name] |
57 | fstcall [r10+EFI_FILE_PROTOCOL.Open], r10, file_handle, \ |
54 | fstcall [r10+EFI_FILE_PROTOCOL.Open], r10, file_handle, \ |
58 | r11, EFI_FILE_MODE_READ, 0 |
55 | r11, EFI_FILE_MODE_READ, 0 |
59 | test eax, eax |
56 | test eax, eax |
60 | jz @f |
57 | jz @f |
61 | xor eax, eax |
58 | mov [_size], 0 |
62 | cmp [_fatal], 1 |
59 | cmp [_fatal], 1 |
63 | jnz .done |
60 | jnz .done |
64 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
61 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
65 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
62 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
66 | msg_error_open_file |
63 | msg_error_open_file |
67 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
64 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
68 | mov rdx, [_name] |
65 | mov rdx, [_name] |
69 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, [_name] |
66 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, [_name] |
70 | jmp $ |
67 | jmp $ |
71 | @@: |
68 | @@: |
72 | - | ||
73 | lea rdx, [_size] |
69 | lea rdx, [_size] |
74 | mov r8, [_buffer] |
70 | mov r8, [_buffer] |
75 | mov r10, [file_handle] |
71 | mov r10, [file_handle] |
76 | fstcall [r10+EFI_FILE_PROTOCOL.Read], [file_handle], rdx, r8 |
72 | fstcall [r10+EFI_FILE_PROTOCOL.Read], [file_handle], rdx, r8 |
77 | mov r10, [file_handle] |
73 | mov r10, [file_handle] |
78 | fstcall [r10+EFI_FILE_PROTOCOL.Close], [file_handle] |
74 | fstcall [r10+EFI_FILE_PROTOCOL.Close], [file_handle] |
79 | mov rax, [_size] |
- | |
80 | .done: |
75 | .done: |
81 | mov [.status], rax |
- | |
82 | call clearbuf |
76 | call clearbuf |
- | 77 | mov rax, [_size] |
|
83 | mov rdi, msg |
78 | mov rdi, msg |
84 | call num2dec |
79 | call num2dec |
85 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
80 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
86 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
81 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
87 | msg_file_size |
82 | msg_file_size |
88 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
83 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
89 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, msg |
84 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, msg |
90 | mov rax, [.status] |
85 | mov rax, [_size] |
91 | ret |
86 | ret |
92 | endp |
87 | endp |
93 | 88 | ||
94 | skip_whitespace: |
89 | skip_whitespace: |
95 | .next_char: |
90 | .next_char: |
96 | cmp byte[rsi], 0 |
91 | cmp byte[rsi], 0 |
97 | jz .done |
92 | jz .done |
98 | cmp byte[rsi], 0x20 ; ' ' |
93 | cmp byte[rsi], 0x20 ; ' ' |
99 | jz .whitespace |
94 | jz .whitespace |
100 | cmp byte[rsi], 9 ; '\t' |
95 | cmp byte[rsi], 9 ; '\t' |
101 | jz .whitespace |
96 | jz .whitespace |
102 | jmp .done |
97 | jmp .done |
103 | .whitespace: |
98 | .whitespace: |
104 | inc rsi |
99 | inc rsi |
105 | jmp .next_char |
100 | jmp .next_char |
106 | .done: |
101 | .done: |
107 | ret |
102 | ret |
108 | 103 | ||
109 | skip_until_newline: |
104 | skip_until_newline: |
110 | .next_char: |
105 | .next_char: |
111 | cmp byte[rsi], 0 |
106 | cmp byte[rsi], 0 |
112 | jz .done |
107 | jz .done |
113 | cmp byte[rsi], 0xd ; '\r' |
108 | cmp byte[rsi], 0xd ; '\r' |
114 | jz .done |
109 | jz .done |
115 | cmp byte[rsi], 0xa ; '\n' |
110 | cmp byte[rsi], 0xa ; '\n' |
116 | jz .done |
111 | jz .done |
117 | inc rsi |
112 | inc rsi |
118 | jmp .next_char |
113 | jmp .next_char |
119 | .done: |
114 | .done: |
120 | ret |
115 | ret |
121 | 116 | ||
122 | skip_newline: |
117 | skip_newline: |
123 | .next_char: |
118 | .next_char: |
124 | cmp byte[rsi], 0xd ; '\r' |
119 | cmp byte[rsi], 0xd ; '\r' |
125 | jz .newline |
120 | jz .newline |
126 | cmp byte[rsi], 0xa ; '\n' |
121 | cmp byte[rsi], 0xa ; '\n' |
127 | jz .newline |
122 | jz .newline |
128 | jmp .done |
123 | jmp .done |
129 | .newline: |
124 | .newline: |
130 | inc rsi |
125 | inc rsi |
131 | jmp .next_char |
126 | jmp .next_char |
132 | .done: |
127 | .done: |
133 | ret |
128 | ret |
134 | 129 | ||
135 | skip_line: |
130 | skip_line: |
136 | call skip_until_newline |
131 | call skip_until_newline |
137 | call skip_newline |
132 | call skip_newline |
138 | ret |
133 | ret |
139 | 134 | ||
140 | dec2bin: |
135 | dec2bin: |
141 | mov edx, 0 |
136 | mov edx, 0 |
142 | .next_char: |
137 | .next_char: |
143 | movzx eax, byte[rsi] |
138 | movzx eax, byte[rsi] |
144 | test eax, eax |
139 | test eax, eax |
145 | jz .done |
140 | jz .done |
146 | sub eax, '0' |
141 | sub eax, '0' |
147 | jb .done |
142 | jb .done |
148 | cmp eax, 9 |
143 | cmp eax, 9 |
149 | ja .done |
144 | ja .done |
150 | inc rsi |
145 | inc rsi |
151 | imul edx, 10 |
146 | imul edx, 10 |
152 | add edx, eax |
147 | add edx, eax |
153 | jmp .next_char |
148 | jmp .next_char |
154 | .done: |
149 | .done: |
155 | mov eax, edx |
150 | mov eax, edx |
156 | ret |
151 | ret |
157 | 152 | ||
158 | parse_option: |
153 | parse_option: |
159 | mov rbx, config_options-3*8 |
154 | mov rbx, config_options-3*8 |
160 | .try_next_option: |
155 | .try_next_option: |
161 | add rbx, 3*8 |
156 | add rbx, 3*8 |
162 | mov rdi, rsi |
157 | mov rdi, rsi |
163 | mov rdx, [rbx] ; option name |
158 | mov rdx, [rbx] ; option name |
164 | test rdx, rdx |
159 | test rdx, rdx |
165 | jz .done |
160 | jz .done |
166 | .next_char: |
161 | .next_char: |
167 | cmp byte[rdx], 0 |
162 | cmp byte[rdx], 0 |
168 | jnz @f |
163 | jnz @f |
169 | cmp byte[rdi], '=' |
164 | cmp byte[rdi], '=' |
170 | jz .opt_name_ok |
165 | jz .opt_name_ok |
171 | @@: |
166 | @@: |
172 | cmp byte[rdi], 0 |
167 | cmp byte[rdi], 0 |
173 | jz .done |
168 | jz .done |
174 | movzx eax, byte[rdi] |
169 | movzx eax, byte[rdi] |
175 | cmp [rdx], al |
170 | cmp [rdx], al |
176 | jnz .try_next_option |
171 | jnz .try_next_option |
177 | inc rdi |
172 | inc rdi |
178 | inc rdx |
173 | inc rdx |
179 | jmp .next_char |
174 | jmp .next_char |
180 | .opt_name_ok: |
175 | .opt_name_ok: |
181 | inc rdi |
176 | inc rdi |
182 | mov rsi, rdi |
177 | mov rsi, rdi |
183 | call qword[rbx+8] |
178 | call qword[rbx+8] |
184 | .done: |
179 | .done: |
185 | ret |
180 | ret |
186 | 181 | ||
187 | parse_line: |
182 | parse_line: |
188 | .next_line: |
183 | .next_line: |
189 | cmp byte[rsi], 0 |
184 | cmp byte[rsi], 0 |
190 | jz .done |
185 | jz .done |
191 | cmp byte[rsi], 0xd ; '\r' |
186 | cmp byte[rsi], 0xd ; '\r' |
192 | jz .skip |
187 | jz .skip |
193 | cmp byte[rsi], 0xa ; '\n' |
188 | cmp byte[rsi], 0xa ; '\n' |
194 | jz .skip |
189 | jz .skip |
195 | cmp byte[rsi], '#' |
190 | cmp byte[rsi], '#' |
196 | jz .skip |
191 | jz .skip |
197 | call parse_option |
192 | call parse_option |
198 | call skip_line |
193 | call skip_line |
199 | jmp .next_line |
194 | jmp .next_line |
200 | .skip: |
195 | .skip: |
201 | call skip_line |
196 | call skip_line |
202 | jmp .next_line |
197 | jmp .next_line |
203 | .done: |
198 | .done: |
204 | ret |
199 | ret |
205 | 200 | ||
206 | cfg_opt_func_resolution: |
201 | cfg_opt_func_resolution: |
207 | call dec2bin |
202 | call dec2bin |
208 | xor edx, edx |
203 | xor edx, edx |
209 | mov [rdx+BOOT_LO.x_res], ax |
204 | mov [rdx+BOOT_LO.x_res], ax |
210 | cmp byte[rsi], 'x' |
205 | cmp byte[rsi], 'x' |
211 | jz @f |
206 | jz @f |
212 | cmp byte[rsi], '*' |
207 | cmp byte[rsi], '*' |
213 | jz @f |
208 | jz @f |
214 | jmp .done |
209 | jmp .done |
215 | @@: |
210 | @@: |
216 | inc rsi |
211 | inc rsi |
217 | call dec2bin |
212 | call dec2bin |
218 | xor edx, edx |
213 | xor edx, edx |
219 | mov [rdx+BOOT_LO.y_res], ax |
214 | mov [rdx+BOOT_LO.y_res], ax |
220 | mov [cfg_opt_used_resolution], 1 |
215 | mov [cfg_opt_used_resolution], 1 |
221 | .done: |
216 | .done: |
222 | ret |
217 | ret |
223 | 218 | ||
224 | cfg_opt_func_acpi: |
219 | cfg_opt_func_acpi: |
225 | call dec2bin |
220 | call dec2bin |
226 | mov [cfg_opt_used_acpi], 1 |
221 | mov [cfg_opt_used_acpi], 1 |
227 | mov [cfg_opt_value_acpi], al |
222 | mov [cfg_opt_value_acpi], al |
228 | ret |
223 | ret |
229 | 224 | ||
230 | cfg_opt_func_debug_print: |
225 | cfg_opt_func_debug_print: |
231 | call dec2bin |
226 | call dec2bin |
232 | mov [cfg_opt_used_debug_print], 1 |
227 | mov [cfg_opt_used_debug_print], 1 |
233 | mov [cfg_opt_value_debug_print], al |
228 | mov [cfg_opt_value_debug_print], al |
234 | ret |
229 | ret |
235 | 230 | ||
236 | cfg_opt_func_launcher_start: |
231 | cfg_opt_func_launcher_start: |
237 | call dec2bin |
232 | call dec2bin |
238 | mov [cfg_opt_used_launcher_start], 1 |
233 | mov [cfg_opt_used_launcher_start], 1 |
239 | mov [cfg_opt_value_launcher_start], al |
234 | mov [cfg_opt_value_launcher_start], al |
240 | ret |
235 | ret |
241 | 236 | ||
242 | cfg_opt_func_mtrr: |
237 | cfg_opt_func_mtrr: |
243 | call dec2bin |
238 | call dec2bin |
244 | mov [cfg_opt_used_mtrr], 1 |
239 | mov [cfg_opt_used_mtrr], 1 |
245 | mov [cfg_opt_value_mtrr], al |
240 | mov [cfg_opt_value_mtrr], al |
246 | ret |
241 | ret |
247 | 242 | ||
248 | cfg_opt_func_ask_params: |
243 | cfg_opt_func_ask_params: |
249 | call dec2bin |
244 | call dec2bin |
250 | mov [cfg_opt_used_ask_params], 1 |
245 | mov [cfg_opt_used_ask_params], 1 |
251 | mov [cfg_opt_value_ask_params], al |
246 | mov [cfg_opt_value_ask_params], al |
252 | ret |
247 | ret |
253 | 248 | ||
254 | cfg_opt_func_imgfrom: |
249 | cfg_opt_func_imgfrom: |
255 | call dec2bin |
250 | call dec2bin |
256 | mov [cfg_opt_used_imgfrom], 1 |
251 | mov [cfg_opt_used_imgfrom], 1 |
257 | mov [cfg_opt_value_imgfrom], al |
252 | mov [cfg_opt_value_imgfrom], al |
258 | ret |
253 | ret |
259 | 254 | ||
260 | cfg_opt_func_syspath: |
255 | cfg_opt_func_syspath: |
261 | mov rdi, cfg_opt_value_syspath |
256 | mov rdi, cfg_opt_value_syspath |
262 | .next_char: |
257 | .next_char: |
263 | movzx eax, byte[rsi] |
258 | movzx eax, byte[rsi] |
264 | cmp al, 0xd ; \r |
259 | cmp al, 0xd ; \r |
265 | jz .done |
260 | jz .done |
266 | cmp al, 0xa ; \n |
261 | cmp al, 0xa ; \n |
267 | jz .done |
262 | jz .done |
268 | inc rsi |
263 | inc rsi |
269 | stosb |
264 | stosb |
270 | jmp .next_char |
265 | jmp .next_char |
271 | .done: |
266 | .done: |
272 | mov byte[rdi], 0 |
267 | mov byte[rdi], 0 |
273 | ret |
268 | ret |
274 | 269 | ||
275 | proc parse_config uses rbx rsi rdi, _buffer |
270 | proc parse_config uses rbx rsi rdi, _buffer |
276 | mov rsi, rcx |
271 | mov rsi, rcx |
277 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
272 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
278 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
273 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
279 | msg_parsing_config |
274 | msg_parsing_config |
280 | .next_line: |
275 | .next_line: |
281 | call parse_line |
276 | call parse_line |
282 | cmp byte[rsi], 0 |
277 | cmp byte[rsi], 0 |
283 | jnz .next_line |
278 | jnz .next_line |
284 | ret |
279 | ret |
285 | endp |
280 | endp |
286 | 281 | ||
287 | proc read_options_from_config |
282 | proc read_options_from_config |
288 | mov r10, [rbx+EFI_SYSTEM_TABLE.BootServices] |
283 | mov r10, [rbx+EFI_SYSTEM_TABLE.BootServices] |
289 | fstcall [r10+EFI_BOOT_SERVICES.HandleProtocol], [efi_handle], \ |
284 | fstcall [r10+EFI_BOOT_SERVICES.HandleProtocol], [efi_handle], \ |
290 | lip_guid, lip_interface |
285 | lip_guid, lip_interface |
291 | test eax, eax |
286 | test eax, eax |
292 | jz @f |
287 | jz @f |
293 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
288 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
294 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
289 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
295 | msg_error_efi_lip_handle |
290 | msg_error_efi_lip_handle |
296 | jmp $ |
291 | jmp $ |
297 | @@: |
292 | @@: |
298 | mov r11, [lip_interface] |
293 | mov r11, [lip_interface] |
299 | mov r10, [rbx+EFI_SYSTEM_TABLE.BootServices] |
294 | mov r10, [rbx+EFI_SYSTEM_TABLE.BootServices] |
300 | fstcall [r10+EFI_BOOT_SERVICES.HandleProtocol], \ |
295 | fstcall [r10+EFI_BOOT_SERVICES.HandleProtocol], \ |
301 | [r11+EFI_LOADED_IMAGE_PROTOCOL.DeviceHandle], sfsp_guid, \ |
296 | [r11+EFI_LOADED_IMAGE_PROTOCOL.DeviceHandle], sfsp_guid, \ |
302 | sfsp_interface |
297 | sfsp_interface |
303 | test eax, eax |
298 | test eax, eax |
304 | jz @f |
299 | jz @f |
305 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
300 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
306 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
301 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
307 | msg_error_lip_dev_sfsp |
302 | msg_error_lip_dev_sfsp |
308 | jmp $ |
303 | jmp $ |
309 | @@: |
304 | @@: |
310 | mov r10, [sfsp_interface] |
305 | mov r10, [sfsp_interface] |
311 | fstcall [r10+EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.OpenVolume], \ |
306 | fstcall [r10+EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.OpenVolume], \ |
312 | [sfsp_interface], esp_root |
307 | [sfsp_interface], esp_root |
313 | test eax, eax |
308 | test eax, eax |
314 | jz @f |
309 | jz @f |
315 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
310 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
316 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
311 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
317 | msg_error_sfsp_openvolume |
312 | msg_error_sfsp_openvolume |
318 | jmp $ |
313 | jmp $ |
319 | @@: |
314 | @@: |
320 | fstcall load_file, [esp_root], file_name, KERNEL_BASE, \ |
315 | fstcall load_file, [esp_root], file_name, KERNEL_BASE, \ |
321 | FILE_BUFFER_SIZE, 0 ; not fatal |
316 | FILE_BUFFER_SIZE, 0 ; not fatal |
322 | 317 | ||
323 | test eax, eax |
318 | test eax, eax |
324 | jz @f |
319 | jz @f |
325 | fstcall parse_config, KERNEL_BASE |
320 | fstcall parse_config, KERNEL_BASE |
326 | @@: |
321 | @@: |
327 | 322 | ||
328 | .error: |
323 | .error: |
329 | ret |
324 | ret |
330 | endp |
325 | endp |
331 | 326 | ||
332 | proc print_vmode uses rax rbx rcx rdx rsi rdi |
327 | proc print_vmode uses rax rbx rcx rdx rsi rdi |
333 | mov r10, rcx |
328 | mov r10, rcx |
334 | call clearbuf |
329 | call clearbuf |
335 | mov eax, [r10+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.HorizontalResolution] |
330 | mov eax, [r10+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.HorizontalResolution] |
336 | mov rdi, msg |
331 | mov rdi, msg |
337 | call num2dec |
332 | call num2dec |
338 | mov eax, [r10+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.VerticalResolution] |
333 | mov eax, [r10+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.VerticalResolution] |
339 | mov rdi, msg+8*2 |
334 | mov rdi, msg+8*2 |
340 | call num2dec |
335 | call num2dec |
341 | 336 | ||
342 | mov eax, [r10+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.PixelFormat] |
337 | mov eax, [r10+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.PixelFormat] |
343 | mov rdi, msg+16*2 |
338 | mov rdi, msg+16*2 |
344 | call num2dec |
339 | call num2dec |
345 | 340 | ||
346 | mov eax, [r10+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.PixelsPerScanLine] |
341 | mov eax, [r10+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.PixelsPerScanLine] |
347 | mov rdi, msg+24*2 |
342 | mov rdi, msg+24*2 |
348 | call num2dec |
343 | call num2dec |
349 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
344 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
350 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, msg |
345 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, msg |
351 | ret |
346 | ret |
352 | endp |
347 | endp |
353 | 348 | ||
354 | proc find_vmode_index_by_resolution |
349 | proc find_vmode_index_by_resolution |
355 | mov [cfg_opt_used_resolution], 1 |
350 | mov [cfg_opt_used_resolution], 1 |
356 | mov [cfg_opt_value_vmode], 0 |
351 | mov [cfg_opt_value_vmode], 0 |
357 | .next_mode: |
352 | .next_mode: |
358 | movzx edx, [cfg_opt_value_vmode] |
353 | movzx edx, [cfg_opt_value_vmode] |
359 | mov r10, [gop_interface] |
354 | mov r10, [gop_interface] |
360 | fstcall [r10+EFI_GRAPHICS_OUTPUT_PROTOCOL.QueryMode], [gop_interface], \ |
355 | fstcall [r10+EFI_GRAPHICS_OUTPUT_PROTOCOL.QueryMode], [gop_interface], \ |
361 | rdx, gop_info_size, gop_info |
356 | rdx, gop_info_size, gop_info |
362 | cmp rax, EFI_SUCCESS |
357 | cmp rax, EFI_SUCCESS |
363 | jnz .error |
358 | jnz .error |
364 | mov rcx, [gop_info] |
359 | mov rcx, [gop_info] |
365 | fstcall print_vmode |
360 | fstcall print_vmode |
366 | ; PixelBlueGreenRedReserved8BitPerColor |
361 | ; PixelBlueGreenRedReserved8BitPerColor |
367 | cmp [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.PixelFormat], 1 |
362 | cmp [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.PixelFormat], 1 |
368 | jnz .skip_mode |
363 | jnz .skip_mode |
369 | xor edx, edx |
364 | xor edx, edx |
370 | mov eax, [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.HorizontalResolution] |
365 | mov eax, [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.HorizontalResolution] |
371 | cmp ax, [rdx+BOOT_LO.x_res] |
366 | cmp ax, [rdx+BOOT_LO.x_res] |
372 | jnz .skip_mode |
367 | jnz .skip_mode |
373 | mov eax, [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.VerticalResolution] |
368 | mov eax, [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.VerticalResolution] |
374 | cmp ax, [rdx+BOOT_LO.y_res] |
369 | cmp ax, [rdx+BOOT_LO.y_res] |
375 | jnz .skip_mode |
370 | jnz .skip_mode |
376 | jmp .done |
371 | jmp .done |
377 | .skip_mode: |
372 | .skip_mode: |
378 | inc [cfg_opt_value_vmode] |
373 | inc [cfg_opt_value_vmode] |
379 | movzx eax, [cfg_opt_value_vmode] |
374 | movzx eax, [cfg_opt_value_vmode] |
380 | mov rcx, [gop_interface] |
375 | mov rcx, [gop_interface] |
381 | mov rdx, [rcx+EFI_GRAPHICS_OUTPUT_PROTOCOL.Mode] |
376 | mov rdx, [rcx+EFI_GRAPHICS_OUTPUT_PROTOCOL.Mode] |
382 | cmp eax, [rdx+EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE.MaxMode] |
377 | cmp eax, [rdx+EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE.MaxMode] |
383 | jnz .next_mode |
378 | jnz .next_mode |
384 | mov [cfg_opt_used_resolution], 0 |
379 | mov [cfg_opt_used_resolution], 0 |
385 | mov [cfg_opt_value_ask_params], 1 |
380 | mov [cfg_opt_value_ask_params], 1 |
386 | 381 | ||
387 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
382 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
388 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
383 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
389 | msg_error_no_such_vmode |
384 | msg_error_no_such_vmode |
390 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
385 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
391 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
386 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
392 | msg_error |
387 | msg_error |
393 | jmp $ |
388 | jmp $ |
394 | .error: |
389 | .error: |
395 | .done: |
390 | .done: |
396 | ret |
391 | ret |
397 | endp |
392 | endp |
398 | 393 | ||
399 | ask_for_params: |
394 | ask_for_params: |
400 | jmp $ |
395 | jmp $ |
401 | 396 | ||
402 | proc detect_pci_config |
397 | proc detect_pci_config |
403 | fstcall get_protocol_interface, pcirbiop_guid |
398 | fstcall get_protocol_interface, pcirbiop_guid |
404 | mov [pcirbiop_interface], rax |
399 | mov [pcirbiop_interface], rax |
405 | mov r10, rax |
400 | mov r10, rax |
406 | fstcall [r10+EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.Configuration], r10, \ |
401 | fstcall [r10+EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.Configuration], r10, \ |
407 | pcirbiop_resources |
402 | pcirbiop_resources |
408 | ; fstcall dump_pci_resources |
403 | ; fstcall dump_pci_resources |
409 | fstcall get_last_pci_bus |
404 | fstcall get_last_pci_bus |
410 | call clearbuf |
405 | call clearbuf |
411 | movzx eax, [pci_last_bus] |
406 | movzx eax, [pci_last_bus] |
412 | mov rdi, msg |
407 | mov rdi, msg |
413 | call num2hex |
408 | call num2hex |
414 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
409 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
415 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
410 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
416 | msg_pci_last_bus |
411 | msg_pci_last_bus |
417 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
412 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
418 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, msg |
413 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, msg |
419 | ret |
414 | ret |
420 | endp |
415 | endp |
421 | 416 | ||
422 | proc get_last_pci_bus |
417 | proc get_last_pci_bus |
423 | mov rsi, [pcirbiop_resources] |
418 | mov rsi, [pcirbiop_resources] |
424 | .next_resource: |
419 | .next_resource: |
425 | cmp [rsi+EFI_QWORD_ADDRESS_SPACE_DESCRIPTOR.Type], \ |
420 | cmp [rsi+EFI_QWORD_ADDRESS_SPACE_DESCRIPTOR.Type], \ |
426 | EFI_RESOURCE_DESCRIPTOR_TYPE.END_TAG |
421 | EFI_RESOURCE_DESCRIPTOR_TYPE.END_TAG |
427 | jz .not_found |
422 | jz .not_found |
428 | mov rax, [rsi+EFI_QWORD_ADDRESS_SPACE_DESCRIPTOR.RangeMaximum] |
423 | mov rax, [rsi+EFI_QWORD_ADDRESS_SPACE_DESCRIPTOR.RangeMaximum] |
429 | cmp [rsi+EFI_QWORD_ADDRESS_SPACE_DESCRIPTOR.ResourceType], \ |
424 | cmp [rsi+EFI_QWORD_ADDRESS_SPACE_DESCRIPTOR.ResourceType], \ |
430 | EFI_RESOURCE_TYPE.BUS |
425 | EFI_RESOURCE_TYPE.BUS |
431 | jz .found |
426 | jz .found |
432 | movzx eax, [rsi+EFI_QWORD_ADDRESS_SPACE_DESCRIPTOR.Length] |
427 | movzx eax, [rsi+EFI_QWORD_ADDRESS_SPACE_DESCRIPTOR.Length] |
433 | lea rsi, [rsi+rax+3] |
428 | lea rsi, [rsi+rax+3] |
434 | jmp .next_resource |
429 | jmp .next_resource |
435 | .found: |
430 | .found: |
436 | mov [pci_last_bus], al |
431 | mov [pci_last_bus], al |
437 | .not_found: |
432 | .not_found: |
438 | ret |
433 | ret |
439 | endp |
434 | endp |
440 | 435 | ||
441 | proc main _efi_handle, _efi_table |
436 | proc main _efi_handle, _efi_table |
442 | mov [efi_handle], rcx |
437 | mov [efi_handle], rcx |
443 | mov [efi_table], rdx |
438 | mov [efi_table], rdx |
444 | mov rbx, rdx |
439 | mov rbx, rdx |
445 | 440 | ||
446 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
441 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
447 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.Reset], rcx, 1 |
442 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.Reset], rcx, 1 |
448 | test eax, eax |
443 | test eax, eax |
449 | jnz $ ; what can I do here? |
444 | jnz $ ; what can I do here? |
450 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
445 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
451 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
446 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
452 | msg_u4k_loaded |
447 | msg_u4k_loaded |
453 | 448 | ||
454 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
449 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
455 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
450 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
456 | msg_detect_pci_config |
451 | msg_detect_pci_config |
457 | fstcall detect_pci_config |
452 | fstcall detect_pci_config |
458 | 453 | ||
459 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
454 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
460 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
455 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
461 | msg_read_options |
456 | msg_read_options |
462 | fstcall read_options_from_config |
457 | fstcall read_options_from_config |
463 | 458 | ||
464 | ; read kernel file |
459 | ; read kernel file |
465 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
460 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
466 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
461 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
467 | msg_load_kernel |
462 | msg_load_kernel |
468 | fstcall load_file, [esp_root], kernel_name, KERNEL_BASE, \ |
463 | fstcall load_file, [esp_root], kernel_name, KERNEL_BASE, \ |
469 | MAX_FILE_SIZE, 1 ; fatal |
464 | MAX_FILE_SIZE, 1 ; fatal |
470 | 465 | ||
471 | ; read ramdisk image |
466 | ; read ramdisk image |
472 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
467 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
473 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
468 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
474 | msg_load_ramdisk |
469 | msg_load_ramdisk |
475 | fstcall load_file, [esp_root], ramdisk_name, RAMDISK_BASE, \ |
470 | fstcall load_file, [esp_root], ramdisk_name, RAMDISK_BASE, \ |
476 | MAX_FILE_SIZE, 1 ; fatal |
471 | MAX_FILE_SIZE, 1 ; fatal |
477 | 472 | ||
478 | ; alloc buffer for devices.dat |
473 | ; alloc buffer for devices.dat |
479 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
474 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
480 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
475 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
481 | msg_alloc_devicesdat |
476 | msg_alloc_devicesdat |
482 | mov r10, [rbx+EFI_SYSTEM_TABLE.BootServices] |
477 | mov r10, [rbx+EFI_SYSTEM_TABLE.BootServices] |
483 | fstcall [r10+EFI_BOOT_SERVICES.AllocatePages], \ |
478 | fstcall [r10+EFI_BOOT_SERVICES.AllocatePages], \ |
484 | EFI_ALLOCATE_MAX_ADDRESS, EFI_RESERVED_MEMORY_TYPE, 1, \ |
479 | EFI_ALLOCATE_MAX_ADDRESS, EFI_RESERVED_MEMORY_TYPE, 1, \ |
485 | devicesdat_data |
480 | devicesdat_data |
486 | cmp eax, EFI_SUCCESS |
481 | cmp eax, EFI_SUCCESS |
487 | jnz .error |
482 | jnz .error |
488 | 483 | ||
489 | ; read devices.dat |
484 | ; read devices.dat |
490 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
485 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
491 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
486 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
492 | msg_load_devicesdat |
487 | msg_load_devicesdat |
493 | 488 | ||
494 | fstcall load_file, [esp_root], devicesdat_name, [devicesdat_data], \ |
489 | fstcall load_file, [esp_root], devicesdat_name, [devicesdat_data], \ |
495 | [devicesdat_size], 0 ; not fatal |
490 | [devicesdat_size], 0 ; not fatal |
496 | mov [devicesdat_size], rax |
491 | mov [devicesdat_size], rax |
497 | 492 | ||
498 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
493 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
499 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
494 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
500 | msg_locate_gop_interface |
495 | msg_locate_gop_interface |
501 | 496 | ||
502 | fstcall get_protocol_interface, gop_guid |
497 | fstcall get_protocol_interface, gop_guid |
503 | mov [gop_interface], rax |
498 | mov [gop_interface], rax |
504 | 499 | ||
505 | fstcall find_rsdp |
500 | fstcall find_rsdp |
506 | 501 | ||
507 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
502 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
508 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
503 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
509 | msg_acpi_tables_done |
504 | msg_acpi_tables_done |
510 | 505 | ||
511 | cmp [cfg_opt_used_resolution], 0 |
506 | cmp [cfg_opt_used_resolution], 0 |
512 | jz .not_used_resolution |
507 | jz .not_used_resolution |
513 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
508 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
514 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
509 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
515 | msg_opt_resolution |
510 | msg_opt_resolution |
516 | call clearbuf |
511 | call clearbuf |
517 | xor edx, edx |
512 | xor edx, edx |
518 | movzx eax, [rdx+BOOT_LO.x_res] |
513 | movzx eax, [rdx+BOOT_LO.x_res] |
519 | mov rdi, msg |
514 | mov rdi, msg |
520 | call num2dec |
515 | call num2dec |
521 | xor edx, edx |
516 | xor edx, edx |
522 | movzx eax, [rdx+BOOT_LO.y_res] |
517 | movzx eax, [rdx+BOOT_LO.y_res] |
523 | mov rdi, msg+8*2 |
518 | mov rdi, msg+8*2 |
524 | call num2dec |
519 | call num2dec |
525 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
520 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
526 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, msg |
521 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, msg |
527 | fstcall find_vmode_index_by_resolution |
522 | fstcall find_vmode_index_by_resolution |
528 | .not_used_resolution: |
523 | .not_used_resolution: |
529 | cmp [cfg_opt_used_debug_print], 0 |
524 | cmp [cfg_opt_used_debug_print], 0 |
530 | jz .not_used_debug_print |
525 | jz .not_used_debug_print |
531 | movzx eax, [cfg_opt_value_debug_print] |
526 | movzx eax, [cfg_opt_value_debug_print] |
532 | xor edx, edx |
527 | xor edx, edx |
533 | mov [rdx+BOOT_LO.debug_print], al |
528 | mov [rdx+BOOT_LO.debug_print], al |
534 | .not_used_debug_print: |
529 | .not_used_debug_print: |
535 | 530 | ||
536 | cmp [cfg_opt_value_ask_params], 0 |
531 | cmp [cfg_opt_value_ask_params], 0 |
537 | jz @f |
532 | jz @f |
538 | call ask_for_params |
533 | call ask_for_params |
539 | @@: |
534 | @@: |
540 | 535 | ||
541 | movzx edx, [cfg_opt_value_vmode] |
536 | movzx edx, [cfg_opt_value_vmode] |
542 | mov r10, [gop_interface] |
537 | mov r10, [gop_interface] |
543 | fstcall [r10+EFI_GRAPHICS_OUTPUT_PROTOCOL.SetMode], [gop_interface], rdx |
538 | fstcall [r10+EFI_GRAPHICS_OUTPUT_PROTOCOL.SetMode], [gop_interface], rdx |
544 | test eax, eax |
539 | test eax, eax |
545 | jz @f |
540 | jz @f |
546 | call clearbuf |
541 | call clearbuf |
547 | mov rdi, msg |
542 | mov rdi, msg |
548 | call num2hex |
543 | call num2hex |
549 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
544 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
550 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, msg |
545 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, msg |
551 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
546 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
552 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
547 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
553 | msg_error |
548 | msg_error |
554 | jmp $ |
549 | jmp $ |
555 | @@: |
550 | @@: |
556 | 551 | ||
557 | mov rcx, [gop_interface] |
552 | mov rcx, [gop_interface] |
558 | mov rdx, [rcx+EFI_GRAPHICS_OUTPUT_PROTOCOL.Mode] |
553 | mov rdx, [rcx+EFI_GRAPHICS_OUTPUT_PROTOCOL.Mode] |
559 | mov rdi, [rdx+EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE.FrameBufferBase] |
554 | mov rdi, [rdx+EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE.FrameBufferBase] |
560 | mov [fb_base], rdi |
555 | mov [fb_base], rdi |
561 | 556 | ||
562 | mov edx, [rdx+EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE.Mode] |
557 | mov edx, [rdx+EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE.Mode] |
563 | mov r10, [gop_interface] |
558 | mov r10, [gop_interface] |
564 | fstcall [r10+EFI_GRAPHICS_OUTPUT_PROTOCOL.QueryMode], [gop_interface], \ |
559 | fstcall [r10+EFI_GRAPHICS_OUTPUT_PROTOCOL.QueryMode], [gop_interface], \ |
565 | rdx, gop_info_size, gop_info |
560 | rdx, gop_info_size, gop_info |
566 | test eax, eax |
561 | test eax, eax |
567 | jz @f |
562 | jz @f |
568 | jmp .error |
563 | jmp .error |
569 | @@: |
564 | @@: |
570 | mov rcx, [gop_info] |
565 | mov rcx, [gop_info] |
571 | mov eax, [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.HorizontalResolution] |
566 | mov eax, [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.HorizontalResolution] |
572 | xor rdx, rdx |
567 | xor rdx, rdx |
573 | mov [rdx+BOOT_LO.x_res], ax |
568 | mov [rdx+BOOT_LO.x_res], ax |
574 | mov eax, [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.VerticalResolution] |
569 | mov eax, [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.VerticalResolution] |
575 | mov [rdx+BOOT_LO.y_res], ax |
570 | mov [rdx+BOOT_LO.y_res], ax |
576 | mov eax, [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.PixelsPerScanLine] |
571 | mov eax, [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.PixelsPerScanLine] |
577 | shl eax, 2 |
572 | shl eax, 2 |
578 | mov [rdx+BOOT_LO.pitch], ax |
573 | mov [rdx+BOOT_LO.pitch], ax |
579 | 574 | ||
580 | mov [rdx+BOOT_LO.pci_data.access_mechanism], 1 |
575 | mov [rdx+BOOT_LO.pci_data.access_mechanism], 1 |
581 | movzx eax, [pci_last_bus] |
576 | movzx eax, [pci_last_bus] |
582 | mov [rdx+BOOT_LO.pci_data.last_bus], al |
577 | mov [rdx+BOOT_LO.pci_data.last_bus], al |
583 | mov [rdx+BOOT_LO.pci_data.version], 0x0300 ; PCI 3.0 |
578 | mov [rdx+BOOT_LO.pci_data.version], 0x0300 ; PCI 3.0 |
584 | mov [rdx+BOOT_LO.pci_data.pm_entry], 0 |
579 | mov [rdx+BOOT_LO.pci_data.pm_entry], 0 |
585 | 580 | ||
586 | ; kernel |
581 | ; kernel |
587 | ; fstcall BootServices, AllocatePages, EFI_RESERVED_MEMORY_TYPE, \ |
582 | ; fstcall BootServices, AllocatePages, EFI_RESERVED_MEMORY_TYPE, \ |
588 | ; 450000/0x1000, EFI_ALLOCATE_ADDRESS |
583 | ; 450000/0x1000, EFI_ALLOCATE_ADDRESS |
589 | 584 | ||
590 | ; ramdisk |
585 | ; ramdisk |
591 | ; fstcall BootServices, AllocatePages, EFI_RESERVED_MEMORY_TYPE, \ |
586 | ; fstcall BootServices, AllocatePages, EFI_RESERVED_MEMORY_TYPE, \ |
592 | ; 2880*512/0x1000, EFI_ALLOCATE_ADDRESS |
587 | ; 2880*512/0x1000, EFI_ALLOCATE_ADDRESS |
593 | 588 | ||
594 | fstcall calc_memmap |
589 | fstcall calc_memmap |
595 | ; fstcall dump_memmap |
590 | ; fstcall dump_memmap |
596 | 591 | ||
597 | mov r10, [rbx+EFI_SYSTEM_TABLE.BootServices] |
592 | mov r10, [rbx+EFI_SYSTEM_TABLE.BootServices] |
598 | fstcall [r10+EFI_BOOT_SERVICES.ExitBootServices], [efi_handle], \ |
593 | fstcall [r10+EFI_BOOT_SERVICES.ExitBootServices], [efi_handle], \ |
599 | [memory_map_key] |
594 | [memory_map_key] |
600 | fstcall halt_on_error |
595 | fstcall halt_on_error |
601 | 596 | ||
602 | cli |
597 | cli |
603 | 598 | ||
604 | xor edx, edx |
599 | xor edx, edx |
605 | xor esi, esi |
600 | xor esi, esi |
606 | mov [rsi+BOOT_LO.bpp], 32 |
601 | mov [rsi+BOOT_LO.bpp], 32 |
607 | mov [rsi+BOOT_LO.vesa_mode], dx |
602 | mov [rsi+BOOT_LO.vesa_mode], dx |
608 | mov [rsi+BOOT_LO.bank_switch], edx |
603 | mov [rsi+BOOT_LO.bank_switch], edx |
609 | mov rdi, [fb_base] |
604 | mov rdi, [fb_base] |
610 | mov [rsi+BOOT_LO.lfb], edi |
605 | mov [rsi+BOOT_LO.lfb], edi |
611 | 606 | ||
612 | movzx eax, [cfg_opt_value_mtrr] |
607 | movzx eax, [cfg_opt_value_mtrr] |
613 | mov [rsi+BOOT_LO.mtrr], al |
608 | mov [rsi+BOOT_LO.mtrr], al |
614 | 609 | ||
615 | movzx eax, [cfg_opt_value_launcher_start] |
610 | movzx eax, [cfg_opt_value_launcher_start] |
616 | mov [rsi+BOOT_LO.launcher_start], al |
611 | mov [rsi+BOOT_LO.launcher_start], al |
617 | 612 | ||
618 | movzx eax, [cfg_opt_value_debug_print] |
613 | movzx eax, [cfg_opt_value_debug_print] |
619 | mov [rsi+BOOT_LO.debug_print], al |
614 | mov [rsi+BOOT_LO.debug_print], al |
620 | 615 | ||
621 | mov [rsi+BOOT_LO.dma], dl |
616 | mov [rsi+BOOT_LO.dma], dl |
622 | mov [rsi+BOOT_LO.apm_entry], edx |
617 | mov [rsi+BOOT_LO.apm_entry], edx |
623 | mov [rsi+BOOT_LO.apm_version], dx |
618 | mov [rsi+BOOT_LO.apm_version], dx |
624 | mov [rsi+BOOT_LO.apm_flags], dx |
619 | mov [rsi+BOOT_LO.apm_flags], dx |
625 | mov [rsi+BOOT_LO.apm_code_32], dx |
620 | mov [rsi+BOOT_LO.apm_code_32], dx |
626 | mov [rsi+BOOT_LO.apm_code_16], dx |
621 | mov [rsi+BOOT_LO.apm_code_16], dx |
627 | mov [rsi+BOOT_LO.apm_data_16], dx |
622 | mov [rsi+BOOT_LO.apm_data_16], dx |
628 | mov [rsi+BOOT_LO.bios_hd_cnt], dl |
623 | mov [rsi+BOOT_LO.bios_hd_cnt], dl |
629 | 624 | ||
630 | movzx eax, [cfg_opt_value_imgfrom] |
625 | movzx eax, [cfg_opt_value_imgfrom] |
631 | mov [rsi+BOOT_LO.rd_load_from], al |
626 | mov [rsi+BOOT_LO.rd_load_from], al |
632 | 627 | ||
633 | mov eax, dword[devicesdat_size] |
628 | mov eax, dword[devicesdat_size] |
634 | mov [rdx+BOOT_LO.devicesdat_size], eax |
629 | mov [rdx+BOOT_LO.devicesdat_size], eax |
635 | mov eax, dword[devicesdat_data] |
630 | mov eax, dword[devicesdat_data] |
636 | mov [rdx+BOOT_LO.devicesdat_data], eax |
631 | mov [rdx+BOOT_LO.devicesdat_data], eax |
637 | 632 | ||
638 | mov rsi, cfg_opt_value_syspath |
633 | mov rsi, cfg_opt_value_syspath |
639 | mov rdi, BOOT_LO.syspath |
634 | mov rdi, BOOT_LO.syspath |
640 | mov ecx, 0x17 |
635 | mov ecx, 0x17 |
641 | rep movsb |
636 | rep movsb |
642 | 637 | ||
643 | ; kernel trampoline |
638 | ; kernel trampoline |
644 | mov rsi, kernel_trampoline |
639 | mov rsi, kernel_trampoline |
645 | mov rdi, KERNEL_TRAMPOLINE |
640 | mov rdi, KERNEL_TRAMPOLINE |
646 | mov ecx, kernel_trampoline.size |
641 | mov ecx, kernel_trampoline.size |
647 | rep movsb |
642 | rep movsb |
648 | 643 | ||
649 | mov rax, GDTR |
644 | mov rax, GDTR |
650 | lgdt [cs:rax] |
645 | lgdt [cs:rax] |
651 | 646 | ||
652 | mov ax, DATA_32_SELECTOR |
647 | mov ax, DATA_32_SELECTOR |
653 | mov ds, ax |
648 | mov ds, ax |
654 | mov es, ax |
649 | mov es, ax |
655 | mov fs, ax |
650 | mov fs, ax |
656 | mov gs, ax |
651 | mov gs, ax |
657 | mov ss, ax |
652 | mov ss, ax |
658 | 653 | ||
659 | push CODE_32_SELECTOR |
654 | push CODE_32_SELECTOR |
660 | mov rax, KERNEL_TRAMPOLINE |
655 | mov rax, KERNEL_TRAMPOLINE |
661 | push rax |
656 | push rax |
662 | retf |
657 | retf |
663 | 658 | ||
664 | .error: |
659 | .error: |
665 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
660 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
666 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
661 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
667 | msg_error |
662 | msg_error |
668 | jmp $ |
663 | jmp $ |
669 | endp |
664 | endp |
670 | 665 | ||
671 | proc halt_on_error |
666 | proc halt_on_error |
672 | test eax, eax |
667 | test eax, eax |
673 | jz @f |
668 | jz @f |
674 | call clearbuf |
669 | call clearbuf |
675 | mov rdi, msg |
670 | mov rdi, msg |
676 | call num2hex |
671 | call num2hex |
677 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
672 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
678 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
673 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
679 | msg_error |
674 | msg_error |
680 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
675 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
681 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, msg |
676 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, msg |
682 | jmp $ |
677 | jmp $ |
683 | @@: |
678 | @@: |
684 | ret |
679 | ret |
685 | endp |
680 | endp |
686 | 681 | ||
687 | proc get_protocol_interface uses rsi rdi, _guid |
682 | proc get_protocol_interface uses rsi rdi, _guid |
688 | locals |
683 | locals |
689 | .status dq ? |
684 | .status dq ? |
690 | endl |
685 | endl |
691 | mov [_guid], rcx |
686 | mov [_guid], rcx |
692 | mov [prot_handlers_buffer_size], PROTOCOL_HANDLERS_BUFFER_SIZE |
687 | mov [prot_handlers_buffer_size], PROTOCOL_HANDLERS_BUFFER_SIZE |
693 | mov r10, [rbx+EFI_SYSTEM_TABLE.BootServices] |
688 | mov r10, [rbx+EFI_SYSTEM_TABLE.BootServices] |
694 | fstcall [r10+EFI_BOOT_SERVICES.LocateHandle], \ |
689 | fstcall [r10+EFI_BOOT_SERVICES.LocateHandle], \ |
695 | EFI_LOCATE_SEARCH_TYPE.ByProtocol, [_guid], 0, \ |
690 | EFI_LOCATE_SEARCH_TYPE.ByProtocol, [_guid], 0, \ |
696 | prot_handlers_buffer_size, prot_handlers_buffer |
691 | prot_handlers_buffer_size, prot_handlers_buffer |
697 | mov [.status], rax |
692 | mov [.status], rax |
698 | 693 | ||
699 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
694 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
700 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
695 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
701 | msg_protocol_buffer_size |
696 | msg_protocol_buffer_size |
702 | call clearbuf |
697 | call clearbuf |
703 | mov rax, [prot_handlers_buffer_size] |
698 | mov rax, [prot_handlers_buffer_size] |
704 | mov rdi, msg |
699 | mov rdi, msg |
705 | call num2hex |
700 | call num2hex |
706 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
701 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
707 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, msg |
702 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, msg |
708 | 703 | ||
709 | mov rax, [.status] |
704 | mov rax, [.status] |
710 | test eax, eax |
705 | test eax, eax |
711 | jz @f |
706 | jz @f |
712 | call clearbuf |
707 | call clearbuf |
713 | mov rdi, msg |
708 | mov rdi, msg |
714 | call num2hex |
709 | call num2hex |
715 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
710 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
716 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
711 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
717 | msg_error |
712 | msg_error |
718 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
713 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
719 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, msg |
714 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, msg |
720 | jmp $ |
715 | jmp $ |
721 | @@: |
716 | @@: |
722 | 717 | ||
723 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
718 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
724 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
719 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
725 | msg_look_for_handler |
720 | msg_look_for_handler |
726 | 721 | ||
727 | mov rsi, prot_handlers_buffer |
722 | mov rsi, prot_handlers_buffer |
728 | .try_next_handle: |
723 | .try_next_handle: |
729 | mov rax, rsi |
724 | mov rax, rsi |
730 | mov rcx, prot_handlers_buffer |
725 | mov rcx, prot_handlers_buffer |
731 | sub rax, rcx |
726 | sub rax, rcx |
732 | cmp rax, [prot_handlers_buffer_size] |
727 | cmp rax, [prot_handlers_buffer_size] |
733 | jb @f |
728 | jb @f |
734 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
729 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
735 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
730 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
736 | msg_error_out_of_handlers |
731 | msg_error_out_of_handlers |
737 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
732 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
738 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
733 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
739 | msg_error |
734 | msg_error |
740 | jmp $ |
735 | jmp $ |
741 | @@: |
736 | @@: |
742 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
737 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
743 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
738 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
744 | msg_query_handler |
739 | msg_query_handler |
745 | 740 | ||
746 | mov r10, [rbx+EFI_SYSTEM_TABLE.BootServices] |
741 | mov r10, [rbx+EFI_SYSTEM_TABLE.BootServices] |
747 | fstcall [r10+EFI_BOOT_SERVICES.HandleProtocol], qword[rsi], [_guid], \ |
742 | fstcall [r10+EFI_BOOT_SERVICES.HandleProtocol], qword[rsi], [_guid], \ |
748 | prot_interface |
743 | prot_interface |
749 | ;mov rax, 0x8000_0000_0000_0003 |
744 | ;mov rax, 0x8000_0000_0000_0003 |
750 | test eax, eax |
745 | test eax, eax |
751 | jz @f |
746 | jz @f |
752 | call clearbuf |
747 | call clearbuf |
753 | mov rdi, msg |
748 | mov rdi, msg |
754 | call num2hex |
749 | call num2hex |
755 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
750 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
756 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, msg |
751 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, msg |
757 | 752 | ||
758 | add rsi, 8 |
753 | add rsi, 8 |
759 | jmp .try_next_handle |
754 | jmp .try_next_handle |
760 | @@: |
755 | @@: |
761 | mov rax, [prot_interface] |
756 | mov rax, [prot_interface] |
762 | ret |
757 | ret |
763 | endp |
758 | endp |
764 | 759 | ||
765 | 760 | ||
766 | proc find_rsdp uses rsi rdi |
761 | proc find_rsdp uses rsi rdi |
767 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
762 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
768 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
763 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
769 | msg_look_for_rsdp |
764 | msg_look_for_rsdp |
770 | 765 | ||
771 | mov rdi, [rbx+EFI_SYSTEM_TABLE.ConfigurationTable] |
766 | mov rdi, [rbx+EFI_SYSTEM_TABLE.ConfigurationTable] |
772 | mov rcx, [rbx+EFI_SYSTEM_TABLE.NumberOfTableEntries] |
767 | mov rcx, [rbx+EFI_SYSTEM_TABLE.NumberOfTableEntries] |
773 | mov rax, 0x11d3e4f18868e871 |
768 | mov rax, 0x11d3e4f18868e871 |
774 | mov rdx, 0x81883cc7800022bc |
769 | mov rdx, 0x81883cc7800022bc |
775 | .next_table: |
770 | .next_table: |
776 | dec ecx |
771 | dec ecx |
777 | js .all_tables_done |
772 | js .all_tables_done |
778 | cmp [rdi+0], rax |
773 | cmp [rdi+0], rax |
779 | jnz .not_acpi20 |
774 | jnz .not_acpi20 |
780 | cmp [rdi+8], rdx |
775 | cmp [rdi+8], rdx |
781 | jnz .not_acpi20 |
776 | jnz .not_acpi20 |
782 | mov rax, [rdi+16] |
777 | mov rax, [rdi+16] |
783 | mov rdx, BOOT_LO.acpi_rsdp |
778 | mov rdx, BOOT_LO.acpi_rsdp |
784 | mov [rdx], eax |
779 | mov [rdx], eax |
785 | jmp .all_tables_done |
780 | jmp .all_tables_done |
786 | .not_acpi20: |
781 | .not_acpi20: |
787 | add rdi, 24 |
782 | add rdi, 24 |
788 | jmp .next_table |
783 | jmp .next_table |
789 | .all_tables_done: |
784 | .all_tables_done: |
790 | ret |
785 | ret |
791 | endp |
786 | endp |
792 | 787 | ||
793 | proc dump_pci_resources uses rsi rdi |
788 | proc dump_pci_resources uses rsi rdi |
794 | xor eax, eax |
789 | xor eax, eax |
795 | mov rsi, [pcirbiop_resources] |
790 | mov rsi, [pcirbiop_resources] |
796 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
791 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
797 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
792 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
798 | msg_dump_pci_resources |
793 | msg_dump_pci_resources |
799 | .next_resource: |
794 | .next_resource: |
800 | call clearbuf |
795 | call clearbuf |
801 | movzx eax, [rsi+EFI_QWORD_ADDRESS_SPACE_DESCRIPTOR.Type] |
796 | movzx eax, [rsi+EFI_QWORD_ADDRESS_SPACE_DESCRIPTOR.Type] |
802 | cmp eax, EFI_RESOURCE_DESCRIPTOR_TYPE.END_TAG |
797 | cmp eax, EFI_RESOURCE_DESCRIPTOR_TYPE.END_TAG |
803 | jz .done |
798 | jz .done |
804 | mov rdi, msg |
799 | mov rdi, msg |
805 | call num2hex |
800 | call num2hex |
806 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
801 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
807 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, msg |
802 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, msg |
808 | call clearbuf |
803 | call clearbuf |
809 | movzx eax, [rsi+EFI_QWORD_ADDRESS_SPACE_DESCRIPTOR.ResourceType] |
804 | movzx eax, [rsi+EFI_QWORD_ADDRESS_SPACE_DESCRIPTOR.ResourceType] |
810 | mov rdi, msg |
805 | mov rdi, msg |
811 | call num2dec |
806 | call num2dec |
812 | mov rax, [rsi+EFI_QWORD_ADDRESS_SPACE_DESCRIPTOR.RangeMinimum] |
807 | mov rax, [rsi+EFI_QWORD_ADDRESS_SPACE_DESCRIPTOR.RangeMinimum] |
813 | mov rdi, msg+2*2 |
808 | mov rdi, msg+2*2 |
814 | call num2hex |
809 | call num2hex |
815 | mov rax, [rsi+EFI_QWORD_ADDRESS_SPACE_DESCRIPTOR.RangeMaximum] |
810 | mov rax, [rsi+EFI_QWORD_ADDRESS_SPACE_DESCRIPTOR.RangeMaximum] |
816 | mov rdi, msg+19*2 |
811 | mov rdi, msg+19*2 |
817 | call num2hex |
812 | call num2hex |
818 | mov rax, [rsi+EFI_QWORD_ADDRESS_SPACE_DESCRIPTOR.TranslationOffset] |
813 | mov rax, [rsi+EFI_QWORD_ADDRESS_SPACE_DESCRIPTOR.TranslationOffset] |
819 | mov rdi, msg+36*2 |
814 | mov rdi, msg+36*2 |
820 | call num2hex |
815 | call num2hex |
821 | mov rax, [rsi+EFI_QWORD_ADDRESS_SPACE_DESCRIPTOR.AddressLength] |
816 | mov rax, [rsi+EFI_QWORD_ADDRESS_SPACE_DESCRIPTOR.AddressLength] |
822 | mov rdi, msg+53*2 |
817 | mov rdi, msg+53*2 |
823 | call num2hex |
818 | call num2hex |
824 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
819 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
825 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, msg |
820 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, msg |
826 | movzx eax, [rsi+EFI_QWORD_ADDRESS_SPACE_DESCRIPTOR.Length] |
821 | movzx eax, [rsi+EFI_QWORD_ADDRESS_SPACE_DESCRIPTOR.Length] |
827 | add eax, 3 |
822 | add eax, 3 |
828 | add rsi, rax |
823 | add rsi, rax |
829 | jmp .next_resource |
824 | jmp .next_resource |
830 | .done: |
825 | .done: |
831 | ret |
826 | ret |
832 | endp |
827 | endp |
833 | 828 | ||
834 | proc calc_memmap uses rsi rdi |
829 | proc calc_memmap uses rsi rdi |
835 | mov r10, [rbx+EFI_SYSTEM_TABLE.BootServices] |
830 | mov r10, [rbx+EFI_SYSTEM_TABLE.BootServices] |
836 | fstcall [r10+EFI_BOOT_SERVICES.AllocatePages], EFI_ALLOCATE_ANY_PAGES, \ |
831 | fstcall [r10+EFI_BOOT_SERVICES.AllocatePages], EFI_ALLOCATE_ANY_PAGES, \ |
837 | EFI_RESERVED_MEMORY_TYPE, MEMORY_MAP_SIZE/0x1000, memory_map |
832 | EFI_RESERVED_MEMORY_TYPE, MEMORY_MAP_SIZE/0x1000, memory_map |
838 | call halt_on_error |
833 | call halt_on_error |
839 | 834 | ||
840 | mov r10, [rbx+EFI_SYSTEM_TABLE.BootServices] |
835 | mov r10, [rbx+EFI_SYSTEM_TABLE.BootServices] |
841 | fstcall [r10+EFI_BOOT_SERVICES.GetMemoryMap], memory_map_size, \ |
836 | fstcall [r10+EFI_BOOT_SERVICES.GetMemoryMap], memory_map_size, \ |
842 | [memory_map], memory_map_key, descriptor_size, descriptor_ver |
837 | [memory_map], memory_map_key, descriptor_size, descriptor_ver |
843 | call halt_on_error |
838 | call halt_on_error |
844 | 839 | ||
845 | mov rdi, BOOT_LO.memmap_blocks |
840 | mov rdi, BOOT_LO.memmap_blocks |
846 | mov dword[rdi-4], 0 ; memmap_block_cnt |
841 | mov dword[rdi-4], 0 ; memmap_block_cnt |
847 | mov rsi, [memory_map] |
842 | mov rsi, [memory_map] |
848 | mov r10, rsi |
843 | mov r10, rsi |
849 | add r10, [memory_map_size] |
844 | add r10, [memory_map_size] |
850 | .next_descr: |
845 | .next_descr: |
851 | fstcall add_uefi_memmap |
846 | fstcall add_uefi_memmap |
852 | add rsi, [descriptor_size] |
847 | add rsi, [descriptor_size] |
853 | cmp rsi, r10 |
848 | cmp rsi, r10 |
854 | jb .next_descr |
849 | jb .next_descr |
855 | ret |
850 | ret |
856 | endp |
851 | endp |
857 | 852 | ||
858 | proc dump_memmap uses rsi rdi |
853 | proc dump_memmap uses rsi rdi |
859 | xor eax, eax |
854 | xor eax, eax |
860 | mov rsi, BOOT_LO.memmap_blocks |
855 | mov rsi, BOOT_LO.memmap_blocks |
861 | mov r12, [rax+BOOT_LO.memmap_block_cnt] |
856 | mov r12, [rax+BOOT_LO.memmap_block_cnt] |
862 | 857 | ||
863 | call clearbuf |
858 | call clearbuf |
864 | mov eax, ebx |
859 | mov eax, ebx |
865 | mov rdi, msg |
860 | mov rdi, msg |
866 | call num2dec |
861 | call num2dec |
867 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
862 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
868 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
863 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, \ |
869 | msg_memmap |
864 | msg_memmap |
870 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
865 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
871 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, msg |
866 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, msg |
872 | call clearbuf |
867 | call clearbuf |
873 | .next_mapping: |
868 | .next_mapping: |
874 | dec r12d |
869 | dec r12d |
875 | js .done |
870 | js .done |
876 | mov rax, rsi |
871 | mov rax, rsi |
877 | mov rcx, BOOT_LO.memmap_blocks |
872 | mov rcx, BOOT_LO.memmap_blocks |
878 | sub rax, rcx |
873 | sub rax, rcx |
879 | mov ecx, sizeof.e820entry |
874 | mov ecx, sizeof.e820entry |
880 | xor edx, edx |
875 | xor edx, edx |
881 | div ecx |
876 | div ecx |
882 | mov rdi, msg |
877 | mov rdi, msg |
883 | call num2dec |
878 | call num2dec |
884 | mov rax, [rsi+e820entry.addr] |
879 | mov rax, [rsi+e820entry.addr] |
885 | mov rdi, msg+4*2 |
880 | mov rdi, msg+4*2 |
886 | call num2hex |
881 | call num2hex |
887 | mov rax, [rsi+e820entry.size] |
882 | mov rax, [rsi+e820entry.size] |
888 | mov rdi, msg+24*2 |
883 | mov rdi, msg+24*2 |
889 | call num2hex |
884 | call num2hex |
890 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
885 | mov rcx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
891 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, msg |
886 | fstcall [rcx+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], rcx, msg |
892 | add rsi, sizeof.e820entry |
887 | add rsi, sizeof.e820entry |
893 | jmp .next_mapping |
888 | jmp .next_mapping |
894 | .done: |
889 | .done: |
895 | ret |
890 | ret |
896 | endp |
891 | endp |
897 | 892 | ||
898 | ; linux/arch/x86/platform/efi/efi.c |
893 | ; linux/arch/x86/platform/efi/efi.c |
899 | ; do_add_efi_memmap |
894 | ; do_add_efi_memmap |
900 | proc add_uefi_memmap |
895 | proc add_uefi_memmap |
901 | xor eax, eax |
896 | xor eax, eax |
902 | cmp [rax+BOOT_LO.memmap_block_cnt], MAX_MEMMAP_BLOCKS |
897 | cmp [rax+BOOT_LO.memmap_block_cnt], MAX_MEMMAP_BLOCKS |
903 | jz .done |
898 | jz .done |
904 | 899 | ||
905 | mov rax, [rsi+EFI_MEMORY_DESCRIPTOR.PhysicalStart] |
900 | mov rax, [rsi+EFI_MEMORY_DESCRIPTOR.PhysicalStart] |
906 | mov [rdi+e820entry.addr], rax |
901 | mov [rdi+e820entry.addr], rax |
907 | 902 | ||
908 | mov rax, [rsi+EFI_MEMORY_DESCRIPTOR.NumberOfPages] |
903 | mov rax, [rsi+EFI_MEMORY_DESCRIPTOR.NumberOfPages] |
909 | shl rax, 12 |
904 | shl rax, 12 |
910 | mov [rdi+e820entry.size], rax |
905 | mov [rdi+e820entry.size], rax |
911 | 906 | ||
912 | mov ecx, [rsi+EFI_MEMORY_DESCRIPTOR.Type] |
907 | mov ecx, [rsi+EFI_MEMORY_DESCRIPTOR.Type] |
913 | cmp ecx, EFI_LOADER_CODE |
908 | cmp ecx, EFI_LOADER_CODE |
914 | jz .mem_ram_if_wb |
909 | jz .mem_ram_if_wb |
915 | cmp ecx, EFI_LOADER_DATA |
910 | cmp ecx, EFI_LOADER_DATA |
916 | jz .mem_ram_if_wb |
911 | jz .mem_ram_if_wb |
917 | cmp ecx, EFI_BOOT_SERVICES_CODE |
912 | cmp ecx, EFI_BOOT_SERVICES_CODE |
918 | jz .mem_ram_if_wb |
913 | jz .mem_ram_if_wb |
919 | cmp ecx, EFI_BOOT_SERVICES_DATA |
914 | cmp ecx, EFI_BOOT_SERVICES_DATA |
920 | jz .mem_ram_if_wb |
915 | jz .mem_ram_if_wb |
921 | cmp ecx, EFI_CONVENTIONAL_MEMORY |
916 | cmp ecx, EFI_CONVENTIONAL_MEMORY |
922 | jz .mem_ram_if_wb |
917 | jz .mem_ram_if_wb |
923 | cmp ecx, EFI_ACPI_RECLAIM_MEMORY |
918 | cmp ecx, EFI_ACPI_RECLAIM_MEMORY |
924 | mov eax, E820_ACPI |
919 | mov eax, E820_ACPI |
925 | jz .type_done |
920 | jz .type_done |
926 | cmp ecx, EFI_ACPI_MEMORY_NVS |
921 | cmp ecx, EFI_ACPI_MEMORY_NVS |
927 | mov eax, E820_NVS |
922 | mov eax, E820_NVS |
928 | jz .type_done |
923 | jz .type_done |
929 | cmp ecx, EFI_UNUSABLE_MEMORY |
924 | cmp ecx, EFI_UNUSABLE_MEMORY |
930 | mov eax, E820_UNUSABLE |
925 | mov eax, E820_UNUSABLE |
931 | jz .type_done |
926 | jz .type_done |
932 | cmp ecx, EFI_PERSISTENT_MEMORY |
927 | cmp ecx, EFI_PERSISTENT_MEMORY |
933 | mov eax, E820_PMEM |
928 | mov eax, E820_PMEM |
934 | jz .type_done |
929 | jz .type_done |
935 | jmp .reserved |
930 | jmp .reserved |
936 | .mem_ram_if_wb: |
931 | .mem_ram_if_wb: |
937 | test [rsi+EFI_MEMORY_DESCRIPTOR.Attribute], dword EFI_MEMORY_WB |
932 | test [rsi+EFI_MEMORY_DESCRIPTOR.Attribute], dword EFI_MEMORY_WB |
938 | mov eax, E820_RAM |
933 | mov eax, E820_RAM |
939 | jnz .type_done |
934 | jnz .type_done |
940 | .reserved: |
935 | .reserved: |
941 | mov eax, E820_RESERVED |
936 | mov eax, E820_RESERVED |
942 | .type_done: |
937 | .type_done: |
943 | mov [rdi+e820entry.type], eax |
938 | mov [rdi+e820entry.type], eax |
944 | cmp eax, E820_RAM |
939 | cmp eax, E820_RAM |
945 | jnz @f |
940 | jnz @f |
946 | xor eax, eax |
941 | xor eax, eax |
947 | inc [rax+BOOT_LO.memmap_block_cnt] |
942 | inc [rax+BOOT_LO.memmap_block_cnt] |
948 | add rdi, sizeof.e820entry |
943 | add rdi, sizeof.e820entry |
949 | @@: |
944 | @@: |
950 | .done: |
945 | .done: |
951 | ret |
946 | ret |
952 | endp |
947 | endp |
953 | 948 | ||
954 | num2dec: |
949 | num2dec: |
955 | push rbx rcx rdx rdi |
950 | push rbx rcx rdx rdi |
956 | 951 | ||
957 | xor ecx, ecx |
952 | xor ecx, ecx |
958 | mov ebx, 10 |
953 | mov ebx, 10 |
959 | .next_digit: |
954 | .next_digit: |
960 | xor edx, edx |
955 | xor edx, edx |
961 | div ebx |
956 | div ebx |
962 | push rdx |
957 | push rdx |
963 | inc ecx |
958 | inc ecx |
964 | test eax, eax |
959 | test eax, eax |
965 | jnz .next_digit |
960 | jnz .next_digit |
966 | 961 | ||
967 | .next_char: |
962 | .next_char: |
968 | pop rax |
963 | pop rax |
969 | add eax, '0' |
964 | add eax, '0' |
970 | stosw |
965 | stosw |
971 | loop .next_char |
966 | loop .next_char |
972 | 967 | ||
973 | pop rdi rdx rcx rbx |
968 | pop rdi rdx rcx rbx |
974 | ret |
969 | ret |
975 | 970 | ||
976 | 971 | ||
977 | num2hex: |
972 | num2hex: |
978 | push rbx rcx rdx rdi |
973 | push rbx rcx rdx rdi |
979 | 974 | ||
980 | xchg rdx, rax |
975 | xchg rdx, rax |
981 | mov ecx, 16 |
976 | mov ecx, 16 |
982 | .next_tetra: |
977 | .next_tetra: |
983 | rol rdx, 4 |
978 | rol rdx, 4 |
984 | movzx eax, dl |
979 | movzx eax, dl |
985 | and eax, 0x0f |
980 | and eax, 0x0f |
986 | movzx eax, byte[hex_abc+eax] |
981 | movzx eax, byte[hex_abc+eax] |
987 | stosw |
982 | stosw |
988 | loop .next_tetra |
983 | loop .next_tetra |
989 | 984 | ||
990 | pop rdi rdx rcx rbx |
985 | pop rdi rdx rcx rbx |
991 | ret |
986 | ret |
992 | 987 | ||
993 | clearbuf: |
988 | clearbuf: |
994 | push rcx rdi |
989 | push rcx rdi |
995 | mov eax, ' ' |
990 | mov eax, ' ' |
996 | mov ecx, 79 |
991 | mov ecx, 79 |
997 | mov rdi, msg |
992 | mov rdi, msg |
998 | rep stosw |
993 | rep stosw |
999 | pop rdi rcx |
994 | pop rdi rcx |
1000 | ret |
995 | ret |
1001 | 996 | ||
1002 | use32 |
997 | use32 |
1003 | kernel_trampoline: |
998 | kernel_trampoline: |
1004 | org KERNEL_TRAMPOLINE |
999 | org KERNEL_TRAMPOLINE |
1005 | mov eax, cr0 |
1000 | mov eax, cr0 |
1006 | and eax, not CR0_PG |
1001 | and eax, not CR0_PG |
1007 | mov cr0, eax |
1002 | mov cr0, eax |
1008 | 1003 | ||
1009 | mov ecx, MSR_AMD_EFER |
1004 | mov ecx, MSR_AMD_EFER |
1010 | rdmsr |
1005 | rdmsr |
1011 | btr eax, 8 ; LME |
1006 | btr eax, 8 ; LME |
1012 | wrmsr |
1007 | wrmsr |
1013 | 1008 | ||
1014 | mov eax, cr4 |
1009 | mov eax, cr4 |
1015 | and eax, not CR4_PAE |
1010 | and eax, not CR4_PAE |
1016 | mov cr4, eax |
1011 | mov cr4, eax |
1017 | 1012 | ||
1018 | push KERNEL_BASE |
1013 | push KERNEL_BASE |
1019 | retn |
1014 | retn |
1020 | 1015 | ||
1021 | align 16 |
1016 | align 16 |
1022 | GDTR: |
1017 | GDTR: |
1023 | dw 4*8-1 |
1018 | dw 4*8-1 |
1024 | dq GDT |
1019 | dq GDT |
1025 | align 16 |
1020 | align 16 |
1026 | GDT: |
1021 | GDT: |
1027 | dw 0, 0, 0, 0 |
1022 | dw 0, 0, 0, 0 |
1028 | dw 0FFFFh,0,9A00h,0CFh ; 32-bit code |
1023 | dw 0FFFFh,0,9A00h,0CFh ; 32-bit code |
1029 | dw 0FFFFh,0,9200h,0CFh ; flat data |
1024 | dw 0FFFFh,0,9200h,0CFh ; flat data |
1030 | dw 0FFFFh,0,9A00h,0AFh ; 64-bit code |
1025 | dw 0FFFFh,0,9A00h,0AFh ; 64-bit code |
1031 | assert $ < BOOT_LO |
1026 | assert $ < BOOT_LO |
1032 | kernel_trampoline.size = $ - KERNEL_TRAMPOLINE |
1027 | kernel_trampoline.size = $ - KERNEL_TRAMPOLINE |
1033 | 1028 | ||
1034 | section '.rodata' data readable |
1029 | section '.rodata' data readable |
1035 | gop_guid db EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID |
1030 | gop_guid db EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID |
1036 | lip_guid db EFI_LOADED_IMAGE_PROTOCOL_GUID |
1031 | lip_guid db EFI_LOADED_IMAGE_PROTOCOL_GUID |
1037 | sfsp_guid db EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID |
1032 | sfsp_guid db EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID |
1038 | pcirbiop_guid db EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GUID |
1033 | pcirbiop_guid db EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GUID |
1039 | 1034 | ||
1040 | file_name du '\EFI\KOLIBRIOS\KOLIBRI.INI',0 |
1035 | file_name du '\EFI\KOLIBRIOS\KOLIBRI.INI',0 |
1041 | kernel_name du '\EFI\KOLIBRIOS\KOLIBRI.KRN',0 |
1036 | kernel_name du '\EFI\KOLIBRIOS\KOLIBRI.KRN',0 |
1042 | ramdisk_name du '\EFI\KOLIBRIOS\KOLIBRI.IMG',0 |
1037 | ramdisk_name du '\EFI\KOLIBRIOS\KOLIBRI.IMG',0 |
1043 | devicesdat_name du '\EFI\KOLIBRIOS\DEVICES.DAT',0 |
1038 | devicesdat_name du '\EFI\KOLIBRIOS\DEVICES.DAT',0 |
1044 | 1039 | ||
1045 | config_options dq cfg_opt_name_resolution, cfg_opt_func_resolution, \ |
1040 | config_options dq cfg_opt_name_resolution, cfg_opt_func_resolution, \ |
1046 | cfg_opt_cmnt_resolution, \ |
1041 | cfg_opt_cmnt_resolution, \ |
1047 | cfg_opt_name_acpi, cfg_opt_func_acpi, cfg_opt_cmnt_acpi, \ |
1042 | cfg_opt_name_acpi, cfg_opt_func_acpi, cfg_opt_cmnt_acpi, \ |
1048 | cfg_opt_name_debug_print, cfg_opt_func_debug_print, \ |
1043 | cfg_opt_name_debug_print, cfg_opt_func_debug_print, \ |
1049 | cfg_opt_cmnt_debug_print, \ |
1044 | cfg_opt_cmnt_debug_print, \ |
1050 | cfg_opt_name_launcher_start, cfg_opt_func_launcher_start, \ |
1045 | cfg_opt_name_launcher_start, cfg_opt_func_launcher_start, \ |
1051 | cfg_opt_cmnt_launcher_start, \ |
1046 | cfg_opt_cmnt_launcher_start, \ |
1052 | cfg_opt_name_mtrr, cfg_opt_func_mtrr, cfg_opt_cmnt_mtrr, \ |
1047 | cfg_opt_name_mtrr, cfg_opt_func_mtrr, cfg_opt_cmnt_mtrr, \ |
1053 | cfg_opt_name_ask_params, cfg_opt_func_ask_params, \ |
1048 | cfg_opt_name_ask_params, cfg_opt_func_ask_params, \ |
1054 | cfg_opt_cmnt_ask_params, \ |
1049 | cfg_opt_cmnt_ask_params, \ |
1055 | cfg_opt_name_imgfrom, cfg_opt_func_imgfrom, \ |
1050 | cfg_opt_name_imgfrom, cfg_opt_func_imgfrom, \ |
1056 | cfg_opt_cmnt_imgfrom, \ |
1051 | cfg_opt_cmnt_imgfrom, \ |
1057 | cfg_opt_name_syspath, cfg_opt_func_syspath, \ |
1052 | cfg_opt_name_syspath, cfg_opt_func_syspath, \ |
1058 | cfg_opt_cmnt_syspath, \ |
1053 | cfg_opt_cmnt_syspath, \ |
1059 | 0 |
1054 | 0 |
1060 | 1055 | ||
1061 | cfg_opt_name_resolution db "resolution",0 |
1056 | cfg_opt_name_resolution db "resolution",0 |
1062 | cfg_opt_name_acpi db "acpi",0 |
1057 | cfg_opt_name_acpi db "acpi",0 |
1063 | cfg_opt_name_debug_print db "debug_print",0 |
1058 | cfg_opt_name_debug_print db "debug_print",0 |
1064 | cfg_opt_name_launcher_start db "launcher_start",0 |
1059 | cfg_opt_name_launcher_start db "launcher_start",0 |
1065 | cfg_opt_name_mtrr db "mtrr",0 |
1060 | cfg_opt_name_mtrr db "mtrr",0 |
1066 | cfg_opt_name_ask_params db "ask_params",0 |
1061 | cfg_opt_name_ask_params db "ask_params",0 |
1067 | cfg_opt_name_imgfrom db "imgfrom",0 |
1062 | cfg_opt_name_imgfrom db "imgfrom",0 |
1068 | cfg_opt_name_syspath db "syspath",0 |
1063 | cfg_opt_name_syspath db "syspath",0 |
1069 | 1064 | ||
1070 | cfg_opt_cmnt_resolution db "# Graphic mode",0 |
1065 | cfg_opt_cmnt_resolution db "# Graphic mode",0 |
1071 | cfg_opt_cmnt_acpi db "# ACPI settings",0xa, \ |
1066 | cfg_opt_cmnt_acpi db "# ACPI settings",0xa, \ |
1072 | "# 0: don't use",0xa, \ |
1067 | "# 0: don't use",0xa, \ |
1073 | "# 1: parse ACPI tables",0xa, \ |
1068 | "# 1: parse ACPI tables",0xa, \ |
1074 | "# 2: + call _PIC method",0xa, \ |
1069 | "# 2: + call _PIC method",0xa, \ |
1075 | "# 3: + get APIC interrupts",0xa,0 |
1070 | "# 3: + get APIC interrupts",0xa,0 |
1076 | cfg_opt_cmnt_debug_print db "# Duplicate debug output to the screen",0 |
1071 | cfg_opt_cmnt_debug_print db "# Duplicate debug output to the screen",0 |
1077 | cfg_opt_cmnt_launcher_start db "# Start LAUNCHER app after kernel is loaded",0 |
1072 | cfg_opt_cmnt_launcher_start db "# Start LAUNCHER app after kernel is loaded",0 |
1078 | cfg_opt_cmnt_mtrr db "# Configure MTRR's",0 |
1073 | cfg_opt_cmnt_mtrr db "# Configure MTRR's",0 |
1079 | cfg_opt_cmnt_ask_params db "# Interrupt booting to ask the user for boot", \ |
1074 | cfg_opt_cmnt_ask_params db "# Interrupt booting to ask the user for boot", \ |
1080 | " params",0 |
1075 | " params",0 |
1081 | cfg_opt_cmnt_imgfrom db "# Where to load ramdisk image from",0 |
1076 | cfg_opt_cmnt_imgfrom db "# Where to load ramdisk image from",0 |
1082 | cfg_opt_cmnt_syspath db "# Path to /sys directory",0 |
1077 | cfg_opt_cmnt_syspath db "# Path to /sys directory",0 |
1083 | 1078 | ||
1084 | msg_u4k_loaded du "uefi64kos loaded",13,10,0 |
1079 | msg_u4k_loaded du "uefi64kos loaded",13,10,0 |
1085 | msg_detect_pci_config du "Detect PCI configuration",13,10,0 |
1080 | msg_detect_pci_config du "Detect PCI configuration",13,10,0 |
1086 | msg_dump_pci_resources du "Dump PCI resources",13,10,0 |
1081 | msg_dump_pci_resources du "Dump PCI resources",13,10,0 |
1087 | msg_pci_last_bus du "Last PCI bus",13,10,0 |
1082 | msg_pci_last_bus du "Last PCI bus",13,10,0 |
1088 | msg_read_options du "Read options from config file",13,10,0 |
1083 | msg_read_options du "Read options from config file",13,10,0 |
1089 | msg_file_size du "File size:",13,10,0 |
1084 | msg_file_size du "File size:",13,10,0 |
1090 | msg_parsing_config du "Parsing config file",13,10,0 |
1085 | msg_parsing_config du "Parsing config file",13,10,0 |
1091 | msg_load_kernel du "Load kernel",13,10,0 |
1086 | msg_load_kernel du "Load kernel",13,10,0 |
1092 | msg_load_ramdisk du "Load ramdisk",13,10,0 |
1087 | msg_load_ramdisk du "Load ramdisk",13,10,0 |
1093 | msg_load_devicesdat du "Load DEVICES.DAT",13,10,0 |
1088 | msg_load_devicesdat du "Load DEVICES.DAT",13,10,0 |
1094 | msg_alloc_devicesdat du "Allocate memory for DEVICES.DAT",13,10,0 |
1089 | msg_alloc_devicesdat du "Allocate memory for DEVICES.DAT",13,10,0 |
1095 | msg_locate_gop_interface du "Locate GOP interface",13,10,0 |
1090 | msg_locate_gop_interface du "Locate GOP interface",13,10,0 |
1096 | msg_look_for_handler du "Look for protocol handler",13,10,0 |
1091 | msg_look_for_handler du "Look for protocol handler",13,10,0 |
1097 | msg_query_handler du "Query handler",13,10,0 |
1092 | msg_query_handler du "Query handler",13,10,0 |
1098 | msg_query_vmode du "Query vmode",13,10,0 |
1093 | msg_query_vmode du "Query vmode",13,10,0 |
1099 | msg_vmode_found du "Video mode found",13,10,0 |
1094 | msg_vmode_found du "Video mode found",13,10,0 |
1100 | msg_look_for_rsdp du "Look for RSDP",13,10,0 |
1095 | msg_look_for_rsdp du "Look for RSDP",13,10,0 |
1101 | msg_rsdp_found du "RSDP found",13,10,0 |
1096 | msg_rsdp_found du "RSDP found",13,10,0 |
1102 | msg_acpi_tables_done du "ACPI tables done",13,10,0 |
1097 | msg_acpi_tables_done du "ACPI tables done",13,10,0 |
1103 | msg_ask_for_params du "Ask for params",13,10,0 |
1098 | msg_ask_for_params du "Ask for params",13,10,0 |
1104 | msg_set_graphic_mode du "Set graphic mode",13,10,0 |
1099 | msg_set_graphic_mode du "Set graphic mode",13,10,0 |
1105 | msg_success du "Success!",13,10,0 |
1100 | msg_success du "Success!",13,10,0 |
1106 | msg_protocol_buffer_size du "Protocol buffer size",13,10,0 |
1101 | msg_protocol_buffer_size du "Protocol buffer size",13,10,0 |
1107 | msg_opt_resolution du "Option resolution: ",0 |
1102 | msg_opt_resolution du "Option resolution: ",0 |
1108 | msg_memmap du "Memmap",13,10,0 |
1103 | msg_memmap du "Memmap",13,10,0 |
1109 | msg_error du "Error!",13,10,0 |
1104 | msg_error du "Error!",13,10,0 |
1110 | msg_error_efi_lip_handle du "efi_handle can't handle LIP",13,10,0 |
1105 | msg_error_efi_lip_handle du "efi_handle can't handle LIP",13,10,0 |
1111 | msg_error_lip_dev_sfsp du "LIP device handle can't handle SFSP",13,10,0 |
1106 | msg_error_lip_dev_sfsp du "LIP device handle can't handle SFSP",13,10,0 |
1112 | msg_error_sfsp_openvolume du "SFSP OpenVolume failed",13,10,0 |
1107 | msg_error_sfsp_openvolume du "SFSP OpenVolume failed",13,10,0 |
1113 | msg_error_no_such_vmode du "No such vmode",13,10,0 |
1108 | msg_error_no_such_vmode du "No such vmode",13,10,0 |
1114 | msg_error_out_of_handlers du "Out of handlers",13,10,0 |
1109 | msg_error_out_of_handlers du "Out of handlers",13,10,0 |
1115 | msg_error_open_file du "Error: can't open file ",0 |
1110 | msg_error_open_file du "Error: can't open file ",0 |
1116 | msg_error_exit_boot_services du "Error: Exit boot services",13,10,0 |
1111 | msg_error_exit_boot_services du "Error: Exit boot services",13,10,0 |
1117 | msg du 79 dup " ",13,10,0 |
1112 | msg du 79 dup " ",13,10,0 |
1118 | msg_debug du "Debug ",13,10,0 |
1113 | msg_debug du "Debug ",13,10,0 |
1119 | 1114 | ||
1120 | section '.data' data readable writeable |
1115 | section '.data' data readable writeable |
1121 | efi_handle dq 0 |
1116 | efi_handle dq 0 |
1122 | efi_table dq 0 |
1117 | efi_table dq 0 |
1123 | 1118 | ||
1124 | fb_base dq 0 |
1119 | fb_base dq 0 |
1125 | 1120 | ||
1126 | gop_interface dq 0 |
1121 | gop_interface dq 0 |
1127 | gop_info_size dq 0 |
1122 | gop_info_size dq 0 |
1128 | gop_info dq 0 |
1123 | gop_info dq 0 |
1129 | 1124 | ||
1130 | lip_interface dq 0 |
1125 | lip_interface dq 0 |
1131 | 1126 | ||
1132 | sfsp_interface dq 0 |
1127 | sfsp_interface dq 0 |
1133 | 1128 | ||
1134 | pci_last_bus db 254 |
1129 | pci_last_bus db 254 |
1135 | 1130 | ||
1136 | cfg_opt_used_resolution db 0 |
1131 | cfg_opt_used_resolution db 0 |
1137 | cfg_opt_used_acpi db 0 |
1132 | cfg_opt_used_acpi db 0 |
1138 | cfg_opt_used_debug_print db 0 |
1133 | cfg_opt_used_debug_print db 0 |
1139 | cfg_opt_used_launcher_start db 0 |
1134 | cfg_opt_used_launcher_start db 0 |
1140 | cfg_opt_used_mtrr db 0 |
1135 | cfg_opt_used_mtrr db 0 |
1141 | cfg_opt_used_ask_params db 0 |
1136 | cfg_opt_used_ask_params db 0 |
1142 | cfg_opt_used_imgfrom db 0 |
1137 | cfg_opt_used_imgfrom db 0 |
1143 | cfg_opt_used_syspath db 0 |
1138 | cfg_opt_used_syspath db 0 |
1144 | 1139 | ||
1145 | cfg_opt_value_vmode db 0 |
1140 | cfg_opt_value_vmode db 0 |
1146 | cfg_opt_value_acpi db 0 |
1141 | cfg_opt_value_acpi db 0 |
1147 | cfg_opt_value_debug_print db 0 |
1142 | cfg_opt_value_debug_print db 0 |
1148 | cfg_opt_value_launcher_start db 1 |
1143 | cfg_opt_value_launcher_start db 1 |
1149 | cfg_opt_value_mtrr db 0 |
1144 | cfg_opt_value_mtrr db 0 |
1150 | cfg_opt_value_ask_params db 0 |
1145 | cfg_opt_value_ask_params db 0 |
1151 | cfg_opt_value_imgfrom db RD_LOAD_FROM_MEMORY |
1146 | cfg_opt_value_imgfrom db RD_LOAD_FROM_MEMORY |
1152 | cfg_opt_value_syspath db "/RD/1",0 |
1147 | cfg_opt_value_syspath db "/RD/1",0 |
1153 | rb 20 |
1148 | rb 20 |
1154 | 1149 | ||
1155 | memory_map_key dq 0 |
1150 | memory_map_key dq 0 |
1156 | descriptor_size dq 0 |
1151 | descriptor_size dq 0 |
1157 | descriptor_ver dq 0 |
1152 | descriptor_ver dq 0 |
1158 | memory_map_size dq MEMORY_MAP_SIZE |
1153 | memory_map_size dq MEMORY_MAP_SIZE |
1159 | 1154 | ||
1160 | efi_fs_info_id db EFI_FILE_SYSTEM_INFO_ID |
1155 | efi_fs_info_id db EFI_FILE_SYSTEM_INFO_ID |
1161 | efi_fs_info_size dq sizeof.EFI_FILE_SYSTEM_INFO |
1156 | efi_fs_info_size dq sizeof.EFI_FILE_SYSTEM_INFO |
1162 | 1157 | ||
1163 | devicesdat_data dq 0xffffffff |
1158 | devicesdat_data dq 0xffffffff |
1164 | devicesdat_size dq 0x1000 |
1159 | devicesdat_size dq 0x1000 |
1165 | 1160 | ||
1166 | hex_abc db '0123456789ABCDEF' |
1161 | hex_abc db '0123456789ABCDEF' |
1167 | 1162 | ||
1168 | section '.bss' data readable writeable discardable |
1163 | section '.bss' data readable writeable discardable |
1169 | prot_handlers_buffer_size dq ? |
1164 | prot_handlers_buffer_size dq ? |
1170 | prot_interface dq ? |
1165 | prot_interface dq ? |
1171 | esp_root dq ? |
1166 | esp_root dq ? |
1172 | file_handle dq ? |
1167 | file_handle dq ? |
1173 | pcirbiop_interface dq ? |
1168 | pcirbiop_interface dq ? |
1174 | pcirbiop_resources dq ? |
1169 | pcirbiop_resources dq ? |
1175 | efi_fs_info EFI_FILE_SYSTEM_INFO |
1170 | efi_fs_info EFI_FILE_SYSTEM_INFO |
1176 | memory_map dq ? |
1171 | memory_map dq ? |
1177 | prot_handlers_buffer rq PROTOCOL_HANDLERS_BUFFER_SIZE/8 |
1172 | prot_handlers_buffer rq PROTOCOL_HANDLERS_BUFFER_SIZE/8 |
1178 | pcirbio_buffer rq PROTOCOL_HANDLERS_BUFFER_SIZE/8 |
1173 | pcirbio_buffer rq PROTOCOL_HANDLERS_BUFFER_SIZE/8 |
1179 | 1174 | ||
1180 | section '.reloc' fixups data discardable> |
1175 | section '.reloc' fixups data discardable> |