Rev 8092 | Rev 8206 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8092 | Rev 8150 | ||
---|---|---|---|
Line -... | Line 1... | ||
- | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|
- | 2 | ;; ;; |
|
- | 3 | ;; Copyright (C) KolibriOS team 2020. All rights reserved. ;; |
|
- | 4 | ;; Distributed under terms of the GNU General Public License ;; |
|
- | 5 | ;; Version 2, or (at your option) any later version. ;; |
|
- | 6 | ;; ;; |
|
- | 7 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|
- | 8 | ||
1 | format pe64 dll efi |
9 | format pe64 efi |
2 | entry main |
10 | entry main |
Line 3... | Line 11... | ||
3 | 11 | ||
Line 4... | Line 12... | ||
4 | section '.text' code executable readable |
12 | section '.text' code executable readable |
5 | 13 | ||
6 | include '../../struct.inc' |
14 | include '../../struct.inc' |
- | 15 | include '../../macros.inc' |
|
- | 16 | include '../../const.inc' |
|
7 | include '../../macros.inc' |
17 | |
Line 8... | Line 18... | ||
8 | include '../../const.inc' |
18 | purge DQ |
9 | include 'uefi.inc' |
19 | include 'uefi64.inc' |
10 | 20 | ||
11 | MEMORY_MAP_SIZE = 0x4000 |
21 | MEMORY_MAP_SIZE = 0x4000 |
Line 42... | Line 52... | ||
42 | cmp rax, EFI_SUCCESS |
52 | cmp rax, EFI_SUCCESS |
43 | jz @f |
53 | jz @f |
44 | xor eax, eax |
54 | xor eax, eax |
45 | cmp [.fatal], 1 |
55 | cmp [.fatal], 1 |
46 | jnz .done |
56 | jnz .done |
- | 57 | mov rbx, [efi_table] |
|
- | 58 | mov rbx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
|
- | 59 | eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \ |
|
47 | eficall ConOut, OutputString, ConOut, msg_error_open_file |
60 | msg_error_open_file |
- | 61 | mov rbx, [efi_table] |
|
48 | eficall ConOut, OutputString, ConOut, [.name] |
62 | mov rbx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
- | 63 | eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \ |
|
- | 64 | [.name] |
|
49 | jmp $ |
65 | jmp $ |
50 | @@: |
66 | @@: |
Line 51... | Line 67... | ||
51 | 67 | ||
52 | lea rax, [.size] |
68 | lea rax, [.size] |
Line 99... | Line 115... | ||
99 | ret |
115 | ret |
Line 100... | Line 116... | ||
100 | 116 | ||
101 | skip_line: |
117 | skip_line: |
102 | call skip_until_newline |
118 | call skip_until_newline |
103 | call skip_newline |
- | |
104 | .done: |
119 | call skip_newline |
Line 105... | Line 120... | ||
105 | ret |
120 | ret |
106 | 121 | ||
107 | dec2bin: |
122 | dec2bin: |
Line 250... | Line 265... | ||
250 | cmp byte[rsi], 0 |
265 | cmp byte[rsi], 0 |
251 | jnz .next_line |
266 | jnz .next_line |
252 | ret 1*8 |
267 | ret 1*8 |
Line 253... | Line 268... | ||
253 | 268 | ||
- | 269 | read_options_from_config: |
|
- | 270 | mov rbx, [efi_table] |
|
254 | read_options_from_config: |
271 | mov rbx, [rbx+EFI_SYSTEM_TABLE.BootServices] |
255 | eficall BootServices, HandleProtocol, qword[efi_handler], lipuuid, \ |
272 | eficall rbx, EFI_BOOT_SERVICES.HandleProtocol, [efi_handle], lipuuid, \ |
256 | lip_interface |
273 | lip_interface |
257 | cmp eax, EFI_SUCCESS |
274 | cmp eax, EFI_SUCCESS |
258 | jnz .error |
275 | jnz .error |
Line -... | Line 276... | ||
- | 276 | mov rax, [lip_interface] |
|
- | 277 | ||
259 | mov rax, [lip_interface] |
278 | mov rbx, [efi_table] |
260 | 279 | mov rbx, [rbx+EFI_SYSTEM_TABLE.BootServices] |
|
261 | eficall BootServices, HandleProtocol, \ |
280 | eficall rbx, EFI_BOOT_SERVICES.HandleProtocol, \ |
262 | [rax+EFI_LOADED_IMAGE_PROTOCOL.DeviceHandle], sfspguid, \ |
281 | [rax+EFI_LOADED_IMAGE_PROTOCOL.DeviceHandle], sfspguid, \ |
263 | sfsp_interface |
282 | sfsp_interface |
Line 283... | Line 302... | ||
283 | @@: |
302 | @@: |
Line 284... | Line 303... | ||
284 | 303 | ||
285 | .error: |
304 | .error: |
Line -... | Line 305... | ||
- | 305 | ret |
|
- | 306 | ||
- | 307 | print_vmode: |
|
- | 308 | push rax rbx rcx rdx rsi rdi |
|
- | 309 | mov rbx, rcx |
|
- | 310 | call clearbuf |
|
- | 311 | mov eax, [rbx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.HorizontalResolution] |
|
- | 312 | mov rdi, msg |
|
- | 313 | call num2dec |
|
- | 314 | mov eax, [rbx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.VerticalResolution] |
|
- | 315 | mov rdi, msg+8*2 |
|
- | 316 | call num2dec |
|
- | 317 | ||
- | 318 | mov eax, [rbx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.PixelFormat] |
|
- | 319 | mov rdi, msg+16*2 |
|
- | 320 | call num2dec |
|
- | 321 | ||
- | 322 | mov eax, [rbx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.PixelsPerScanLine] |
|
- | 323 | mov rdi, msg+24*2 |
|
- | 324 | call num2dec |
|
- | 325 | mov rbx, [efi_table] |
|
- | 326 | mov rbx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
|
- | 327 | eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, msg |
|
- | 328 | pop rdi rsi rdx rcx rbx rax |
|
286 | ret |
329 | ret |
287 | 330 | ||
288 | find_vmode_index_by_resolution: |
331 | find_vmode_index_by_resolution: |
289 | mov [cfg_opt_used_resolution], 1 |
332 | mov [cfg_opt_used_resolution], 1 |
290 | mov [cfg_opt_value_vmode], 0 |
333 | mov [cfg_opt_value_vmode], 0 |
291 | .next_mode: |
334 | .next_mode: |
292 | movzx eax, [cfg_opt_value_vmode] |
335 | movzx eax, [cfg_opt_value_vmode] |
293 | eficall [gop_interface], EFI_GRAPHICS_OUTPUT_PROTOCOL.QueryMode, \ |
336 | eficall [gop_interface], EFI_GRAPHICS_OUTPUT_PROTOCOL.QueryMode, \ |
294 | [gop_interface], rax, gop_info_size, gop_info |
337 | [gop_interface], rax, gop_info_size, gop_info |
295 | cmp rax, EFI_SUCCESS |
338 | cmp rax, EFI_SUCCESS |
- | 339 | jnz .error |
|
296 | jnz .error |
340 | mov rcx, [gop_info] |
297 | mov rcx, [gop_info] |
341 | call print_vmode |
298 | ; PixelBlueGreenRedReserved8BitPerColor |
342 | ; PixelBlueGreenRedReserved8BitPerColor |
299 | cmp [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.PixelFormat], 1 |
343 | cmp [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.PixelFormat], 1 |
300 | jnz .skip_mode |
344 | jnz .skip_mode |
Line 309... | Line 353... | ||
309 | .skip_mode: |
353 | .skip_mode: |
310 | inc [cfg_opt_value_vmode] |
354 | inc [cfg_opt_value_vmode] |
311 | movzx eax, [cfg_opt_value_vmode] |
355 | movzx eax, [cfg_opt_value_vmode] |
312 | mov rcx, [gop_interface] |
356 | mov rcx, [gop_interface] |
313 | mov rdx, [rcx+EFI_GRAPHICS_OUTPUT_PROTOCOL.Mode] |
357 | mov rdx, [rcx+EFI_GRAPHICS_OUTPUT_PROTOCOL.Mode] |
314 | cmp eax, [rdx+EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE.MaxMode] |
358 | cmp eax, 8;[rdx+EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE.MaxMode] |
315 | jnz .next_mode |
359 | jnz .next_mode |
316 | mov [cfg_opt_used_resolution], 0 |
360 | mov [cfg_opt_used_resolution], 0 |
317 | mov [cfg_opt_value_ask_params], 1 |
361 | mov [cfg_opt_value_ask_params], 1 |
- | 362 | ||
- | 363 | mov rbx, [efi_table] |
|
- | 364 | mov rbx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
|
- | 365 | eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \ |
|
- | 366 | msg_error_no_such_vmode |
|
- | 367 | mov rbx, [efi_table] |
|
- | 368 | mov rbx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
|
- | 369 | eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, msg_error |
|
- | 370 | jmp $ |
|
318 | .error: |
371 | .error: |
319 | .done: |
372 | .done: |
320 | ret |
373 | ret |
Line 321... | Line 374... | ||
321 | 374 | ||
- | 375 | ask_for_params: |
|
- | 376 | ret |
|
- | 377 | mov rbx, [efi_table] |
|
- | 378 | mov rbx, [rbx+EFI_SYSTEM_TABLE.BootServices] |
|
- | 379 | eficall rbx, EFI_BOOT_SERVICES.HandleProtocol, [rax], gopuuid, \ |
|
- | 380 | msg_ask_for_params |
|
- | 381 | jmp $ |
|
322 | ask_for_params: |
382 | |
323 | xor ebx, ebx |
383 | xor ebx, ebx |
324 | .next_mode: |
384 | .next_mode: |
325 | call clearbuf |
385 | call clearbuf |
326 | mov eax, ebx |
386 | mov eax, ebx |
Line 344... | Line 404... | ||
344 | call num2dec |
404 | call num2dec |
345 | ; mov eax, [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.PixelsPerScanLine] |
405 | ; mov eax, [rcx+EFI_GRAPHICS_OUTPUT_MODE_INFORMATION.PixelsPerScanLine] |
346 | ; lea rdi, [msg+14*2] |
406 | ; lea rdi, [msg+14*2] |
347 | ; call num2dec |
407 | ; call num2dec |
348 | .skip: |
408 | .skip: |
- | 409 | mov rbx, [efi_table] |
|
- | 410 | mov rbx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
|
349 | eficall ConOut, OutputString, ConOut, msg |
411 | eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, msg |
350 | cmp rax, EFI_SUCCESS |
412 | cmp rax, EFI_SUCCESS |
351 | jnz .error |
413 | jnz .error |
Line 352... | Line 414... | ||
352 | 414 | ||
353 | pop rbx |
415 | pop rbx |
Line 356... | Line 418... | ||
356 | mov rdx, [rcx+EFI_GRAPHICS_OUTPUT_PROTOCOL.Mode] |
418 | mov rdx, [rcx+EFI_GRAPHICS_OUTPUT_PROTOCOL.Mode] |
357 | cmp ebx, [rdx+EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE.MaxMode] |
419 | cmp ebx, [rdx+EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE.MaxMode] |
358 | jnz .next_mode |
420 | jnz .next_mode |
Line -... | Line 421... | ||
- | 421 | ||
- | 422 | ||
359 | 423 | mov rbx, [efi_table] |
|
360 | 424 | mov rbx, [rbx+EFI_SYSTEM_TABLE.ConIn] |
|
361 | eficall ConIn, Reset, ConIn, 1 |
425 | eficall rbx, SIMPLE_INPUT_INTERFACE.Reset, rbx, 1 |
362 | cmp rax, EFI_SUCCESS |
426 | cmp rax, EFI_SUCCESS |
363 | jnz .error |
427 | jnz .error |
364 | xor ecx, ecx |
428 | xor ecx, ecx |
- | 429 | @@: |
|
- | 430 | push rcx |
|
365 | @@: |
431 | mov rbx, [efi_table] |
366 | push rcx |
432 | mov rbx, [rbx+EFI_SYSTEM_TABLE.ConIn] |
367 | eficall ConIn, ReadKeyStroke, ConIn, msg |
433 | eficall rbx, SIMPLE_INPUT_INTERFACE.ReadKeyStroke, rbx, msg |
368 | pop rcx |
434 | pop rcx |
369 | mov rdx, EFI_DEVICE_ERROR |
435 | mov rdx, EFI_DEVICE_ERROR |
370 | cmp rax, rdx |
436 | cmp rax, rdx |
Line 386... | Line 452... | ||
386 | .error: |
452 | .error: |
387 | .done: |
453 | .done: |
388 | ret |
454 | ret |
Line 389... | Line 455... | ||
389 | 455 | ||
390 | main: |
- | |
391 | sub rsp, 0x38 |
- | |
392 | - | ||
393 | ; initialize UEFI library |
- | |
394 | InitializeLib |
- | |
395 | jc .error |
- | |
396 | - | ||
397 | ; eficall ConOut, Reset, ConOut, 1 |
456 | main: |
398 | ; cmp rax, EFI_SUCCESS |
- | |
399 | ; jnz .error |
- | |
400 | - | ||
401 | eficall ConOut, ClearScreen, ConOut |
457 | mov [efi_handle], rcx |
402 | cmp rax, EFI_SUCCESS |
- | |
Line -... | Line 458... | ||
- | 458 | mov [efi_table], rdx |
|
- | 459 | ||
- | 460 | mov rbx, [efi_table] |
|
- | 461 | mov rbx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
|
- | 462 | eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.Reset, rbx, 1 |
|
- | 463 | test eax, eax |
|
- | 464 | jz @f |
|
- | 465 | jmp $ ; what can I do here? |
|
- | 466 | @@: |
|
- | 467 | mov rbx, [efi_table] |
|
- | 468 | mov rbx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
|
- | 469 | eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \ |
|
- | 470 | msg_u4k_loaded |
|
- | 471 | ||
- | 472 | mov rbx, [efi_table] |
|
- | 473 | mov rbx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
|
403 | jnz .error |
474 | eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \ |
Line 404... | Line 475... | ||
404 | 475 | msg_read_options |
|
- | 476 | call read_options_from_config |
|
- | 477 | ||
- | 478 | ; read kernel file |
|
- | 479 | mov rbx, [efi_table] |
|
405 | call read_options_from_config |
480 | mov rbx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
406 | 481 | eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \ |
|
407 | ; read kernel file |
482 | msg_load_kernel |
408 | push 1 |
483 | push 1 |
409 | push -1 |
484 | push -1 |
410 | push KERNEL_BASE |
485 | push KERNEL_BASE |
Line 411... | Line 486... | ||
411 | push kernel_name |
486 | push kernel_name |
- | 487 | push [esp_root] |
|
- | 488 | call load_file |
|
- | 489 | ||
- | 490 | ; read ramdisk image |
|
412 | push [esp_root] |
491 | mov rbx, [efi_table] |
413 | call load_file |
492 | mov rbx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
414 | 493 | eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \ |
|
415 | ; read ramdisk image |
494 | msg_load_ramdisk |
416 | push 1 |
495 | push 1 |
417 | push -1 |
496 | push -1 |
Line 418... | Line 497... | ||
418 | push RAMDISK_BASE |
497 | push RAMDISK_BASE |
- | 498 | push ramdisk_name |
|
- | 499 | push [esp_root] |
|
419 | push ramdisk_name |
500 | call load_file |
- | 501 | ||
- | 502 | ; alloc buffer for devices.dat |
|
- | 503 | mov rbx, [efi_table] |
|
- | 504 | mov rbx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
|
420 | push [esp_root] |
505 | eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \ |
- | 506 | msg_alloc_devicesdat |
|
421 | call load_file |
507 | mov rbx, [efi_table] |
422 | 508 | mov rbx, [rbx+EFI_SYSTEM_TABLE.BootServices] |
|
Line 423... | Line 509... | ||
423 | ; alloc buffer for devices.dat |
509 | eficall rbx, EFI_BOOT_SERVICES.AllocatePages, \ |
- | 510 | EFI_ALLOCATE_MAX_ADDRESS, EFI_RESERVED_MEMORY_TYPE, 1, \ |
|
- | 511 | devicesdat_data |
|
- | 512 | cmp eax, EFI_SUCCESS |
|
- | 513 | jnz .error |
|
- | 514 | ||
424 | eficall BootServices, AllocatePages, EFI_ALLOCATE_MAX_ADDRESS, \ |
515 | ; read devices.dat |
425 | EFI_RESERVED_MEMORY_TYPE, 1, devicesdat_data |
516 | mov rbx, [efi_table] |
426 | cmp eax, EFI_SUCCESS |
517 | mov rbx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
427 | jnz .error |
518 | eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \ |
428 | 519 | msg_load_devicesdat |
|
429 | ; read devices.dat |
520 | |
430 | push 0 ; not fatal |
521 | push 0 ; not fatal |
Line -... | Line 522... | ||
- | 522 | push [devicesdat_size] |
|
- | 523 | push [devicesdat_data] |
|
431 | push [devicesdat_size] |
524 | push devicesdat_name |
- | 525 | push [esp_root] |
|
- | 526 | call load_file |
|
- | 527 | mov [devicesdat_size], rax |
|
- | 528 | ||
- | 529 | mov rbx, [efi_table] |
|
- | 530 | mov rbx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
|
- | 531 | eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \ |
|
- | 532 | msg_locate_gop_handlers |
|
- | 533 | ||
- | 534 | mov rbx, [efi_table] |
|
- | 535 | mov rbx, [rbx+EFI_SYSTEM_TABLE.BootServices] |
|
- | 536 | eficall rbx, EFI_BOOT_SERVICES.LocateHandle, \ |
|
432 | push [devicesdat_data] |
537 | EFI_LOCATE_SEARCH_TYPE.ByProtocol, gopuuid, 0, \ |
- | 538 | gop_buffer_size, gop_buffer |
|
- | 539 | mov [status], rax |
|
- | 540 | ||
- | 541 | mov rbx, [efi_table] |
|
- | 542 | mov rbx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
|
- | 543 | eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \ |
|
- | 544 | msg_gop_buffer_size |
|
- | 545 | call clearbuf |
|
433 | push devicesdat_name |
546 | mov rax, [gop_buffer_size] |
- | 547 | mov rdi, msg |
|
434 | push [esp_root] |
548 | call num2hex |
- | 549 | mov rbx, [efi_table] |
|
- | 550 | mov rbx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
|
- | 551 | eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, msg |
|
- | 552 | ||
- | 553 | mov rax, [status] |
|
- | 554 | test eax, eax |
|
- | 555 | jz @f |
|
- | 556 | call clearbuf |
|
- | 557 | mov rdi, msg |
|
- | 558 | call num2hex |
|
- | 559 | mov rbx, [efi_table] |
|
- | 560 | mov rbx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
|
- | 561 | eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, msg_error |
|
- | 562 | mov rbx, [efi_table] |
|
- | 563 | mov rbx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
|
- | 564 | eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, msg |
|
- | 565 | jmp $ |
|
435 | call load_file |
566 | @@: |
- | 567 | ||
- | 568 | mov rbx, [efi_table] |
|
- | 569 | mov rbx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
|
- | 570 | eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \ |
|
- | 571 | msg_look_for_gop_handler |
|
- | 572 | ||
- | 573 | mov rbx, gop_buffer |
|
- | 574 | .next_gop_handle: |
|
- | 575 | mov rax, rbx |
|
- | 576 | sub rax, gop_buffer |
|
- | 577 | cmp rax, [gop_buffer_size] |
|
- | 578 | jb @f |
|
- | 579 | push rbx |
|
- | 580 | mov rbx, [efi_table] |
|
- | 581 | mov rbx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
|
- | 582 | eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \ |
|
436 | mov [devicesdat_size], rax |
583 | msg_error_out_of_handlers |
- | 584 | pop rbx |
|
- | 585 | push rbx |
|
- | 586 | mov rbx, [efi_table] |
|
- | 587 | mov rbx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
|
- | 588 | eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, msg_error |
|
- | 589 | pop rbx |
|
- | 590 | jmp $ |
|
- | 591 | @@: |
|
437 | 592 | push rbx |
|
- | 593 | mov rbx, [efi_table] |
|
- | 594 | mov rbx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
|
- | 595 | eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \ |
|
438 | eficall BootServices, LocateHandle, 2, gopuuid, 0, gop_buffer_size, \ |
596 | msg_query_handler |
439 | gop_buffer |
597 | pop rbx |
- | 598 | ||
- | 599 | mov rax, rbx |
|
440 | cmp eax, EFI_SUCCESS |
600 | push rbx |
441 | jnz .error |
601 | mov rbx, [efi_table] |
- | 602 | mov rbx, [rbx+EFI_SYSTEM_TABLE.BootServices] |
|
- | 603 | eficall rbx, EFI_BOOT_SERVICES.HandleProtocol, [rax], gopuuid, \ |
|
- | 604 | gop_interface |
|
- | 605 | pop rbx |
|
- | 606 | ;mov rax, 0x8000_0000_0000_0003 |
|
- | 607 | test eax, eax |
|
- | 608 | jz @f |
|
- | 609 | call clearbuf |
|
- | 610 | mov rdi, msg |
|
- | 611 | call num2hex |
|
- | 612 | push rbx |
|
- | 613 | mov rbx, [efi_table] |
|
Line -... | Line 614... | ||
- | 614 | mov rbx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
|
442 | mov rsi, gop_buffer |
615 | eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, msg |
- | 616 | pop rbx |
|
- | 617 | ||
- | 618 | add rbx, 8 |
|
- | 619 | jmp .next_gop_handle |
|
- | 620 | @@: |
|
- | 621 | ||
443 | lodsq |
622 | push rbx |
444 | mov [gop_handle], rax |
623 | mov rbx, [efi_table] |
445 | eficall BootServices, HandleProtocol, qword[gop_handle], gopuuid, \ |
624 | mov rbx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
446 | gop_interface |
625 | eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \ |
447 | cmp eax, EFI_SUCCESS |
626 | msg_look_for_rsdp |
Line 466... | Line 645... | ||
466 | .not_acpi20: |
645 | .not_acpi20: |
467 | add rdi, 24 |
646 | add rdi, 24 |
468 | jmp .next_table |
647 | jmp .next_table |
469 | .all_tables_done: |
648 | .all_tables_done: |
Line -... | Line 649... | ||
- | 649 | ||
- | 650 | mov rbx, [efi_table] |
|
- | 651 | mov rbx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
|
- | 652 | eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \ |
|
- | 653 | msg_acpi_tables_done |
|
470 | 654 | ||
471 | cmp [cfg_opt_used_resolution], 0 |
655 | cmp [cfg_opt_used_resolution], 0 |
- | 656 | jz .not_used_resolution |
|
- | 657 | mov rbx, [efi_table] |
|
- | 658 | mov rbx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
|
- | 659 | eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \ |
|
- | 660 | msg_opt_resolution |
|
- | 661 | call clearbuf |
|
- | 662 | xor edx, edx |
|
- | 663 | movzx eax, [rdx+BOOT_LO.x_res] |
|
- | 664 | mov rdi, msg |
|
- | 665 | call num2dec |
|
- | 666 | xor edx, edx |
|
- | 667 | movzx eax, [rdx+BOOT_LO.y_res] |
|
- | 668 | mov rdi, msg+8*2 |
|
- | 669 | call num2dec |
|
- | 670 | mov rbx, [efi_table] |
|
- | 671 | mov rbx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
|
472 | jz .not_used_resolution |
672 | eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, msg |
473 | call find_vmode_index_by_resolution |
673 | call find_vmode_index_by_resolution |
474 | .not_used_resolution: |
674 | .not_used_resolution: |
475 | cmp [cfg_opt_used_debug_print], 0 |
675 | cmp [cfg_opt_used_debug_print], 0 |
476 | jz .not_used_debug_print |
676 | jz .not_used_debug_print |
Line 485... | Line 685... | ||
485 | @@: |
685 | @@: |
Line 486... | Line 686... | ||
486 | 686 | ||
487 | movzx ecx, [cfg_opt_value_vmode] |
687 | movzx ecx, [cfg_opt_value_vmode] |
488 | eficall [gop_interface], EFI_GRAPHICS_OUTPUT_PROTOCOL.SetMode, \ |
688 | eficall [gop_interface], EFI_GRAPHICS_OUTPUT_PROTOCOL.SetMode, \ |
489 | [gop_interface], rcx |
689 | [gop_interface], rcx |
490 | cmp eax, EFI_SUCCESS |
690 | test eax, eax |
- | 691 | jz @f |
|
- | 692 | call clearbuf |
|
- | 693 | mov rdi, msg |
|
- | 694 | call num2hex |
|
- | 695 | mov rbx, [efi_table] |
|
- | 696 | mov rbx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
|
- | 697 | eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, msg |
|
- | 698 | mov rbx, [efi_table] |
|
- | 699 | mov rbx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
|
- | 700 | eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, msg_error |
|
- | 701 | jmp $ |
|
Line 491... | Line 702... | ||
491 | jnz .error |
702 | @@: |
492 | 703 | ||
493 | mov rcx, [gop_interface] |
704 | mov rcx, [gop_interface] |
494 | mov rdx, [rcx+EFI_GRAPHICS_OUTPUT_PROTOCOL.Mode] |
705 | mov rdx, [rcx+EFI_GRAPHICS_OUTPUT_PROTOCOL.Mode] |
Line 516... | Line 727... | ||
516 | mov byte[rdx+BOOT_LO.pci_data+2], 0x10 ; PCI version |
727 | mov byte[rdx+BOOT_LO.pci_data+2], 0x10 ; PCI version |
517 | mov byte[rdx+BOOT_LO.pci_data+3], 0x02 |
728 | mov byte[rdx+BOOT_LO.pci_data+3], 0x02 |
518 | mov dword[rdx+BOOT_LO.pci_data+4], 0xe3 |
729 | mov dword[rdx+BOOT_LO.pci_data+4], 0xe3 |
Line -... | Line 730... | ||
- | 730 | ||
- | 731 | ||
519 | 732 | mov rbx, [efi_table] |
|
520 | 733 | mov rbx, [rbx+EFI_SYSTEM_TABLE.BootServices] |
|
521 | eficall BootServices, AllocatePages, EFI_ALLOCATE_ANY_PAGES, \ |
734 | eficall rbx, EFI_BOOT_SERVICES.AllocatePages, EFI_ALLOCATE_ANY_PAGES, \ |
522 | EFI_RESERVED_MEMORY_TYPE, MEMORY_MAP_SIZE/0x1000, memory_map |
735 | EFI_RESERVED_MEMORY_TYPE, MEMORY_MAP_SIZE/0x1000, memory_map |
Line -... | Line 736... | ||
- | 736 | cmp eax, EFI_SUCCESS |
|
- | 737 | jnz .error |
|
523 | cmp eax, EFI_SUCCESS |
738 | |
524 | jnz .error |
739 | mov rbx, [efi_table] |
525 | 740 | mov rbx, [rbx+EFI_SYSTEM_TABLE.BootServices] |
|
526 | eficall BootServices, GetMemoryMap, memory_map_size, [memory_map], \ |
741 | eficall rbx, EFI_BOOT_SERVICES.GetMemoryMap, memory_map_size, \ |
Line 527... | Line 742... | ||
527 | memory_map_key, descriptor_size, descriptor_ver |
742 | [memory_map], memory_map_key, descriptor_size, descriptor_ver |
528 | cmp eax, EFI_SUCCESS |
743 | cmp eax, EFI_SUCCESS |
Line 551... | Line 766... | ||
551 | 766 | ||
552 | ; ramdisk |
767 | ; ramdisk |
553 | ; eficall BootServices, AllocatePages, EFI_RESERVED_MEMORY_TYPE, \ |
768 | ; eficall BootServices, AllocatePages, EFI_RESERVED_MEMORY_TYPE, \ |
Line -... | Line 769... | ||
- | 769 | ; 2880*512/0x1000, EFI_ALLOCATE_ADDRESS |
|
- | 770 | ||
554 | ; 2880*512/0x1000, EFI_ALLOCATE_ADDRESS |
771 | mov rbx, [efi_table] |
- | 772 | mov rbx, [rbx+EFI_SYSTEM_TABLE.BootServices] |
|
555 | 773 | eficall rbx, EFI_BOOT_SERVICES.ExitBootServices, [efi_handle], \ |
|
556 | eficall BootServices, ExitBootServices, [efi_handler], [memory_map_key] |
774 | [memory_map_key] |
Line 557... | Line 775... | ||
557 | cmp eax, EFI_SUCCESS |
775 | cmp eax, EFI_SUCCESS |
Line 610... | Line 828... | ||
610 | mov ss, ax |
828 | mov ss, ax |
Line 611... | Line 829... | ||
611 | 829 | ||
612 | push CODE_32_SELECTOR |
830 | push CODE_32_SELECTOR |
613 | lea rax, [.next] |
831 | lea rax, [.next] |
614 | push rax |
- | |
615 | ; push .next |
832 | push rax |
616 | retf |
833 | retf |
617 | use32 |
834 | use32 |
618 | align 16 |
835 | align 16 |
619 | .next: |
836 | .next: |
Line 633... | Line 850... | ||
633 | push KERNEL_BASE |
850 | push KERNEL_BASE |
634 | retn |
851 | retn |
Line 635... | Line 852... | ||
635 | 852 | ||
636 | use64 |
853 | use64 |
637 | .error: |
854 | .error: |
638 | eficall ConOut, OutputString, ConOut, msg_error |
855 | mov rbx, [efi_table] |
639 | jmp .quit |
- | |
- | 856 | mov rbx, [rbx+EFI_SYSTEM_TABLE.ConOut] |
|
640 | .quit: |
857 | eficall rbx, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString, rbx, \ |
641 | mov rcx, -1 |
858 | msg_error |
Line 642... | Line 859... | ||
642 | loop $ |
859 | jmp $ |
643 | 860 | ||
644 | 861 | ||
645 | ; linux/arch/x86/platform/efi/efi.c |
862 | ; linux/arch/x86/platform/efi/efi.c |
Line 646... | Line 863... | ||
646 | ; do_add_efi_memmap |
863 | ; do_add_efi_memmap |
647 | add_uefi_memmap: |
864 | add_uefi_memmap: |
648 | push rax rbx rcx rdx rsi rdi |
- | |
649 | 865 | push rax rbx rcx rdx rsi rdi |
|
650 | mov r10d, [rsi+0] |
866 | |
Line 651... | Line 867... | ||
651 | mov r11, [rsi+8] |
867 | mov r10d, [rsi+EFI_MEMORY_DESCRIPTOR.Type] |
652 | ; mov r12, [rsi+16] |
868 | mov r11, [rsi+EFI_MEMORY_DESCRIPTOR.PhysicalStart] |
653 | mov r13, [rsi+24] |
869 | mov r13, [rsi+EFI_MEMORY_DESCRIPTOR.NumberOfPages] |
654 | mov r14, [rsi+32] |
870 | mov r14, [rsi+EFI_MEMORY_DESCRIPTOR.Attribute] |
Line 762... | Line 978... | ||
762 | rep stosw |
978 | rep stosw |
763 | pop rdi rsi rdx rcx rbx rax |
979 | pop rdi rsi rdx rcx rbx rax |
764 | ret |
980 | ret |
Line 765... | Line 981... | ||
765 | 981 | ||
- | 982 | section '.data' data readable writeable |
|
- | 983 | efi_handle dq 0 |
|
- | 984 | efi_table dq 0 |
|
Line 766... | Line 985... | ||
766 | section '.data' data readable writeable |
985 | uefi_rsptmp dq 0 |
767 | 986 | ||
768 | GDTR: |
987 | GDTR: |
769 | dw 4*8-1 |
988 | dw 4*8-1 |
Line 792... | Line 1011... | ||
792 | sfspguid db EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID |
1011 | sfspguid db EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID |
793 | sfsp_interface dq 0 |
1012 | sfsp_interface dq 0 |
Line 794... | Line 1013... | ||
794 | 1013 | ||
795 | esp_root dq ? |
1014 | esp_root dq ? |
796 | file_handle dq ? |
1015 | file_handle dq ? |
797 | file_name du '\EFI\BOOT\KOLIBRI.INI',0 |
1016 | file_name du '\EFI\KOLIBRIOS\KOLIBRI.INI',0 |
798 | kernel_name du '\EFI\BOOT\KOLIBRI.KRN',0 |
1017 | kernel_name du '\EFI\KOLIBRIOS\KOLIBRI.KRN',0 |
799 | ramdisk_name du '\EFI\BOOT\KOLIBRI.IMG',0 |
1018 | ramdisk_name du '\EFI\KOLIBRIOS\KOLIBRI.IMG',0 |
800 | devicesdat_name du '\EFI\BOOT\DEVICES.DAT',0 |
1019 | devicesdat_name du '\EFI\KOLIBRIOS\DEVICES.DAT',0 |
Line 801... | Line 1020... | ||
801 | file_buffer_size dq FILE_BUFFER_SIZE-1 ; leave the last byte for \0 |
1020 | file_buffer_size dq FILE_BUFFER_SIZE-1 ; leave the last byte for \0 |
802 | 1021 | ||
803 | config_options dq cfg_opt_name_resolution, cfg_opt_func_resolution, \ |
1022 | config_options dq cfg_opt_name_resolution, cfg_opt_func_resolution, \ |
Line 814... | Line 1033... | ||
814 | cfg_opt_cmnt_imgfrom, \ |
1033 | cfg_opt_cmnt_imgfrom, \ |
815 | cfg_opt_name_syspath, cfg_opt_func_syspath, \ |
1034 | cfg_opt_name_syspath, cfg_opt_func_syspath, \ |
816 | cfg_opt_cmnt_syspath, \ |
1035 | cfg_opt_cmnt_syspath, \ |
817 | 0 |
1036 | 0 |
Line 818... | Line 1037... | ||
818 | 1037 | ||
819 | cfg_opt_name_resolution db 'resolution',0 |
1038 | cfg_opt_name_resolution db "resolution",0 |
820 | cfg_opt_name_acpi db 'acpi',0 |
1039 | cfg_opt_name_acpi db "acpi",0 |
821 | cfg_opt_name_debug_print db 'debug_print',0 |
1040 | cfg_opt_name_debug_print db "debug_print",0 |
822 | cfg_opt_name_launcher_start db 'launcher_start',0 |
1041 | cfg_opt_name_launcher_start db "launcher_start",0 |
823 | cfg_opt_name_mtrr db 'mtrr',0 |
1042 | cfg_opt_name_mtrr db "mtrr",0 |
824 | cfg_opt_name_ask_params db 'ask_params',0 |
1043 | cfg_opt_name_ask_params db "ask_params",0 |
825 | cfg_opt_name_imgfrom db 'imgfrom',0 |
1044 | cfg_opt_name_imgfrom db "imgfrom",0 |
Line 826... | Line 1045... | ||
826 | cfg_opt_name_syspath db 'syspath',0 |
1045 | cfg_opt_name_syspath db "syspath",0 |
827 | 1046 | ||
828 | cfg_opt_cmnt_resolution db "# Graphic mode",0 |
1047 | cfg_opt_cmnt_resolution db "# Graphic mode",0 |
829 | cfg_opt_cmnt_acpi db "# ACPI settings",0xa, \ |
1048 | cfg_opt_cmnt_acpi db "# ACPI settings",0xa, \ |
830 | "# 0: don't use",0xa, \ |
1049 | "# 0: don't use",0xa, \ |
831 | "# 1: parse ACPI tables",0xa, \ |
1050 | "# 1: parse ACPI tables",0xa, \ |
832 | "# 2: + call _PIC method",0xa, \ |
1051 | "# 2: + call _PIC method",0xa, \ |
833 | "# 3: + get APIC interrupts",0xa,0 |
1052 | "# 3: + get APIC interrupts",0xa,0 |
834 | cfg_opt_cmnt_debug_print db "# Duplicate debug output to the screen",0 |
1053 | cfg_opt_cmnt_debug_print db "# Duplicate debug output to the screen",0 |
835 | cfg_opt_cmnt_launcher_start db "# Start LAUNCHER app after kernel is loaded",0 |
1054 | cfg_opt_cmnt_launcher_start db "# Start LAUNCHER app after kernel is loaded",0 |
- | 1055 | cfg_opt_cmnt_mtrr db "# Configure MTRR's",0 |
|
836 | cfg_opt_cmnt_mtrr db "# Configure MTRR's",0 |
1056 | cfg_opt_cmnt_ask_params db "# Interrupt booting to ask the user for boot", \ |
837 | cfg_opt_cmnt_ask_params db "# Interrupt booting to ask the user for boot params",0 |
1057 | " params",0 |
Line 838... | Line 1058... | ||
838 | cfg_opt_cmnt_imgfrom db "# Where to load ramdisk image from",0 |
1058 | cfg_opt_cmnt_imgfrom db "# Where to load ramdisk image from",0 |
839 | cfg_opt_cmnt_syspath db "# Path to /sys directory",0 |
1059 | cfg_opt_cmnt_syspath db "# Path to /sys directory",0 |
Line 850... | Line 1070... | ||
850 | cfg_opt_value_vmode db 0 |
1070 | cfg_opt_value_vmode db 0 |
851 | cfg_opt_value_acpi db 0 |
1071 | cfg_opt_value_acpi db 0 |
852 | cfg_opt_value_debug_print db 0 |
1072 | cfg_opt_value_debug_print db 0 |
853 | cfg_opt_value_launcher_start db 1 |
1073 | cfg_opt_value_launcher_start db 1 |
854 | cfg_opt_value_mtrr db 0 |
1074 | cfg_opt_value_mtrr db 0 |
855 | cfg_opt_value_ask_params db 1 |
1075 | cfg_opt_value_ask_params db 0 |
856 | cfg_opt_value_imgfrom db RD_LOAD_FROM_MEMORY |
1076 | cfg_opt_value_imgfrom db RD_LOAD_FROM_MEMORY |
857 | cfg_opt_value_syspath db '/RD/1',0 |
1077 | cfg_opt_value_syspath db "/RD/1",0 |
858 | rb 20 |
1078 | rb 20 |
Line 859... | Line 1079... | ||
859 | 1079 | ||
860 | memory_map_key dq 0 |
1080 | memory_map_key dq 0 |
861 | descriptor_size dq 0 |
1081 | descriptor_size dq 0 |
862 | descriptor_ver dq 0 |
1082 | descriptor_ver dq 0 |
Line -... | Line 1083... | ||
- | 1083 | memory_map_size dq MEMORY_MAP_SIZE |
|
- | 1084 | ||
- | 1085 | msg_u4k_loaded du "uefi64kos loaded",13,10,0 |
|
- | 1086 | msg_read_options du "Read options from config file",13,10,0 |
|
- | 1087 | msg_load_kernel du "Load kernel",13,10,0 |
|
- | 1088 | msg_load_ramdisk du "Load ramdisk",13,10,0 |
|
- | 1089 | msg_load_devicesdat du "Load DEVICES.DAT",13,10,0 |
|
- | 1090 | msg_alloc_devicesdat du "Allocate memory for DEVICES.DAT",13,10,0 |
|
- | 1091 | msg_locate_gop_handlers du "Locate GOP handlers",13,10,0 |
|
- | 1092 | msg_look_for_gop_handler du "Look for GOP handler",13,10,0 |
|
- | 1093 | msg_query_handler du "Query handler",13,10,0 |
|
- | 1094 | msg_query_vmode du "Query vmode",13,10,0 |
|
- | 1095 | msg_vmode_found du "Video mode found",13,10,0 |
|
- | 1096 | msg_look_for_rsdp du "Look for RSDP",13,10,0 |
|
- | 1097 | msg_rsdp_found du "RSDP found",13,10,0 |
|
- | 1098 | msg_acpi_tables_done du "ACPI tables done",13,10,0 |
|
863 | memory_map_size dq MEMORY_MAP_SIZE |
1099 | msg_ask_for_params du "Ask for params",13,10,0 |
- | 1100 | msg_set_graphic_mode du "Set graphic mode",13,10,0 |
|
- | 1101 | msg_success du "Success!",13,10,0 |
|
864 | 1102 | msg_gop_buffer_size du "GOP buffer size",13,10,0 |
|
865 | msg_success du 'Success!',13,10,0 |
1103 | msg_opt_resolution du "option resolution: ",0 |
- | 1104 | msg_error du "Error!",13,10,0 |
|
866 | msg_error du 'Error!',13,10,0 |
1105 | msg_error_no_such_vmode du "No such vmode",13,10,0 |
- | 1106 | msg_error_out_of_handlers du "Out of handlers",13,10,0 |
|
Line 867... | Line 1107... | ||
867 | msg du 79 dup ' ',13,10,0 |
1107 | msg_error_open_file du "Error: can't open file ",0 |
868 | msg_error_open_file du "Error: can't open file ",0 |
1108 | msg du 79 dup " ",13,10,0 |
869 | 1109 | ||
Line 870... | Line -... | ||
870 | efi_fs_info_id db EFI_FILE_SYSTEM_INFO_ID |
- | |
871 | efi_fs_info_size dq sizeof.EFI_FILE_SYSTEM_INFO |
- | |
872 | efi_fs_info EFI_FILE_SYSTEM_INFO |
1110 | efi_fs_info_id db EFI_FILE_SYSTEM_INFO_ID |
873 | 1111 | efi_fs_info_size dq sizeof.EFI_FILE_SYSTEM_INFO |
|
874 | ;section '.bss' data readable writeable |
- | |
875 | 1112 | efi_fs_info EFI_FILE_SYSTEM_INFO |
|
876 | memory_map dq ? |
1113 | |
- | 1114 | memory_map dq ? |
|
Line 877... | Line 1115... | ||
877 | gop_buffer rb GOP_BUFFER_SIZE |
1115 | gop_buffer rq GOP_BUFFER_SIZE/8 |