Subversion Repositories Kolibri OS

Rev

Rev 8206 | Rev 8284 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8206 Rev 8220
Line 423... Line 423...
423
 
423
 
424
        mov     eax, [esi+EFI_SYSTEM_TABLE.BootServices]
424
        mov     eax, [esi+EFI_SYSTEM_TABLE.BootServices]
425
        ccall   [eax+EFI_BOOT_SERVICES.AllocatePages], \
425
        ccall   [eax+EFI_BOOT_SERVICES.AllocatePages], \
426
                EFI_ALLOCATE_MAX_ADDRESS, EFI_RESERVED_MEMORY_TYPE, 1, \
426
                EFI_ALLOCATE_MAX_ADDRESS, EFI_RESERVED_MEMORY_TYPE, 1, \
427
                devicesdat_data
-
 
428
        test    eax, eax
427
                devicesdat_data
Line 429... Line 428...
429
        jnz     .error
428
        call    halt_on_error
430
 
429
 
431
        mov     eax, [esi+EFI_SYSTEM_TABLE.ConOut]
430
        mov     eax, [esi+EFI_SYSTEM_TABLE.ConOut]
Line 455... Line 454...
455
        call    num2hex
454
        call    num2hex
456
        mov     eax, [esi+EFI_SYSTEM_TABLE.ConOut]
455
        mov     eax, [esi+EFI_SYSTEM_TABLE.ConOut]
457
        ccall   [eax+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], eax, msg
456
        ccall   [eax+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], eax, msg
Line 458... Line 457...
458
 
457
 
459
        mov     eax, [status]
-
 
460
        test    eax, eax
-
 
461
        jz      @f
458
        mov     eax, [status]
462
        call    clearbuf
-
 
463
        mov     edi, msg
-
 
464
        call    num2hex
-
 
465
        mov     eax, [esi+EFI_SYSTEM_TABLE.ConOut]
-
 
466
        ccall   [eax+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], eax, msg_error
-
 
467
        mov     eax, [esi+EFI_SYSTEM_TABLE.ConOut]
-
 
468
        ccall   [eax+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], eax, msg
-
 
469
        jmp     $
-
 
Line 470... Line 459...
470
@@:
459
        call    halt_on_error
471
 
460
 
472
        mov     eax, [esi+EFI_SYSTEM_TABLE.ConOut]
461
        mov     eax, [esi+EFI_SYSTEM_TABLE.ConOut]
Line 504... Line 493...
504
 
493
 
505
        add     ebx, 4
494
        add     ebx, 4
506
        jmp     .next_gop_handle
495
        jmp     .next_gop_handle
Line 507... Line -...
507
@@:
-
 
508
 
-
 
509
        mov     eax, [esi+EFI_SYSTEM_TABLE.ConOut]
-
 
510
        ccall   [eax+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], eax, \
-
 
511
                msg_look_for_rsdp
-
 
512
 
-
 
513
        mov     ebx, [efi_table]
-
 
514
        mov     edi, [ebx+EFI_SYSTEM_TABLE.ConfigurationTable]
-
 
515
        mov     ecx, [ebx+EFI_SYSTEM_TABLE.NumberOfTableEntries]
-
 
516
.next_table:
-
 
517
        dec     ecx
-
 
518
        js      .all_tables_done
-
 
519
        ; EFI_ACPI_TABLE_GUID
-
 
520
        cmp     dword[edi+EFI_CONFIGURATION_TABLE.VendorGUID+0x0], 0x8868e871
-
 
521
        jnz     .not_acpi20
-
 
522
        cmp     dword[edi+EFI_CONFIGURATION_TABLE.VendorGUID+0x4], 0x11d3e4f1
-
 
523
        jnz     .not_acpi20
-
 
524
        cmp     dword[edi+EFI_CONFIGURATION_TABLE.VendorGUID+0x8], 0x800022bc
-
 
525
        jnz     .not_acpi20
-
 
526
        cmp     dword[edi+EFI_CONFIGURATION_TABLE.VendorGUID+0xc], 0x81883cc7
-
 
527
        jnz     .not_acpi20
-
 
528
        mov     eax, [edi+EFI_CONFIGURATION_TABLE.VendorTable]
-
 
529
        mov     edx, BOOT_LO.acpi_rsdp
-
 
530
        mov     [edx], eax
-
 
531
        mov     eax, [esi+EFI_SYSTEM_TABLE.ConOut]
496
@@:
532
        ccall   [eax+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], eax, \
-
 
533
                msg_rsdp_found
-
 
534
        jmp     .all_tables_done
-
 
535
.not_acpi20:
-
 
536
        add     edi, sizeof.EFI_CONFIGURATION_TABLE
-
 
Line 537... Line 497...
537
        jmp     .next_table
497
 
538
.all_tables_done:
498
        call    find_rsdp
539
 
499
 
Line 573... Line 533...
573
@@:
533
@@:
Line 574... Line 534...
574
 
534
 
575
        movzx   ecx, [cfg_opt_value_vmode]
535
        movzx   ecx, [cfg_opt_value_vmode]
576
        mov     eax, [gop_interface]
536
        mov     eax, [gop_interface]
577
        ccall   [eax+EFI_GRAPHICS_OUTPUT_PROTOCOL.SetMode], eax, ecx
-
 
578
        test    eax, eax
-
 
579
        jz      @f
537
        ccall   [eax+EFI_GRAPHICS_OUTPUT_PROTOCOL.SetMode], eax, ecx
580
        call    clearbuf
-
 
581
        mov     edi, msg
-
 
582
        call    num2hex
-
 
583
        mov     eax, [esi+EFI_SYSTEM_TABLE.ConOut]
-
 
584
        ccall   [eax+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], eax, msg
-
 
585
        mov     eax, [esi+EFI_SYSTEM_TABLE.ConOut]
-
 
586
        ccall   [eax+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], eax, msg_error
-
 
587
        jmp     $
-
 
Line 588... Line 538...
588
@@:
538
        call    halt_on_error
589
 
539
 
590
        mov     ecx, [gop_interface]
540
        mov     ecx, [gop_interface]
591
        mov     edx, [ecx+EFI_GRAPHICS_OUTPUT_PROTOCOL.Mode]
541
        mov     edx, [ecx+EFI_GRAPHICS_OUTPUT_PROTOCOL.Mode]
Line 613... Line 563...
613
        mov     byte[edx+BOOT_LO.pci_data+1], 8    ; last bus, don't know how to count them
563
        mov     byte[edx+BOOT_LO.pci_data+1], 8    ; last bus, don't know how to count them
614
        mov     byte[edx+BOOT_LO.pci_data+2], 0x10 ; PCI version
564
        mov     byte[edx+BOOT_LO.pci_data+2], 0x10 ; PCI version
615
        mov     byte[edx+BOOT_LO.pci_data+3], 0x02
565
        mov     byte[edx+BOOT_LO.pci_data+3], 0x02
616
        mov     dword[edx+BOOT_LO.pci_data+4], 0xe3
566
        mov     dword[edx+BOOT_LO.pci_data+4], 0xe3
Line 617... Line -...
617
 
-
 
618
 
-
 
619
        mov     eax, [efi_table]
-
 
620
        mov     eax, [eax+EFI_SYSTEM_TABLE.BootServices]
-
 
621
        ccall   [eax+EFI_BOOT_SERVICES.AllocatePages], \
-
 
622
                EFI_ALLOCATE_ANY_PAGES, EFI_RESERVED_MEMORY_TYPE, \
-
 
623
                MEMORY_MAP_SIZE/0x1000, memory_map
-
 
624
        test    eax, eax
-
 
625
        jnz     .error
-
 
626
 
-
 
627
        mov     eax, [efi_table]
-
 
628
        mov     eax, [eax+EFI_SYSTEM_TABLE.BootServices]
-
 
629
        ccall   [eax+EFI_BOOT_SERVICES.GetMemoryMap], memory_map_size, \
-
 
630
                [memory_map], memory_map_key, descriptor_size, descriptor_ver
-
 
631
        test    eax, eax
-
 
632
        jnz     .error
-
 
633
 
-
 
634
        mov     edi, BOOT_LO.memmap_block_cnt
-
 
635
        mov     dword[edi], 0
-
 
636
        mov     edi, BOOT_LO.memmap_blocks
-
 
637
        mov     eax, [memory_map_size]
-
 
638
        xor     edx, edx
-
 
639
        mov     ecx, [descriptor_size]
-
 
640
        div     ecx
-
 
641
        mov     ecx, eax
-
 
642
        cmp     ecx, MAX_MEMMAP_BLOCKS
-
 
643
        jbe     @f
-
 
644
        mov     ecx, MAX_MEMMAP_BLOCKS
-
 
645
@@:
-
 
646
        xor     eax, eax
-
 
647
        mov     [eax+BOOT_LO.memmap_block_cnt], 0
-
 
648
        mov     esi, [memory_map]
-
 
649
.next_descr:
-
 
650
        call    add_uefi_memmap
-
 
651
        add     esi, [descriptor_size]
-
 
652
        add     edi, sizeof.e820entry
-
 
653
        dec     ecx
-
 
654
        jnz     .next_descr
-
 
655
 
567
 
656
        ; kernel
568
        ; kernel
657
;        eficall BootServices, AllocatePages, EFI_RESERVED_MEMORY_TYPE, \
569
;        eficall BootServices, AllocatePages, EFI_RESERVED_MEMORY_TYPE, \
Line 658... Line 570...
658
;                450000/0x1000, EFI_ALLOCATE_ADDRESS
570
;                450000/0x1000, EFI_ALLOCATE_ADDRESS
659
 
571
 
660
        ; ramdisk
572
        ; ramdisk
Line -... Line 573...
-
 
573
;        eficall BootServices, AllocatePages, EFI_RESERVED_MEMORY_TYPE, \
-
 
574
;                2880*512/0x1000, EFI_ALLOCATE_ADDRESS
-
 
575
 
661
;        eficall BootServices, AllocatePages, EFI_RESERVED_MEMORY_TYPE, \
576
        call    calc_memmap
662
;                2880*512/0x1000, EFI_ALLOCATE_ADDRESS
577
;        call    dump_memmap
663
 
578
 
664
        mov     eax, [efi_table]
579
        mov     eax, [efi_table]
665
        mov     eax, [eax+EFI_SYSTEM_TABLE.BootServices]
-
 
666
        ccall   [eax+EFI_BOOT_SERVICES.ExitBootServices], [efi_handle], \
580
        mov     eax, [eax+EFI_SYSTEM_TABLE.BootServices]
667
                [memory_map_key]
-
 
Line 668... Line 581...
668
        test    eax, eax
581
        ccall   [eax+EFI_BOOT_SERVICES.ExitBootServices], [efi_handle], \
Line 669... Line 582...
669
        jnz     .error
582
                [memory_map_key]
670
 
583
        call    halt_on_error
Line 742... Line 655...
742
        mov     eax, [esi+EFI_SYSTEM_TABLE.ConOut]
655
        mov     eax, [esi+EFI_SYSTEM_TABLE.ConOut]
743
        ccall   [eax+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], eax, \
656
        ccall   [eax+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], eax, \
744
                msg_error
657
                msg_error
745
        jmp     $
658
        jmp     $
Line -... Line 659...
-
 
659
 
746
 
660
halt_on_error:
747
; linux/arch/x86/platform/efi/efi.c
661
        test    eax, eax
-
 
662
        jz      @f
748
; do_add_efi_memmap
663
        call    clearbuf
749
proc add_uefi_memmap
664
        mov     edi, msg
-
 
665
        call    num2hex
-
 
666
        mov     eax, [esi+EFI_SYSTEM_TABLE.ConOut]
-
 
667
        ccall   [eax+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], eax, \
-
 
668
                msg_error
-
 
669
        mov     eax, [esi+EFI_SYSTEM_TABLE.ConOut]
750
locals
670
        ccall   [eax+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], eax, msg
751
  pew dd ?
671
        jmp     $
752
endl
672
@@:
Line -... Line 673...
-
 
673
        ret
753
        pushad
674
 
-
 
675
proc find_rsdp
-
 
676
        mov     eax, [esi+EFI_SYSTEM_TABLE.ConOut]
Line 754... Line 677...
754
 
677
        ccall   [eax+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], eax, \
-
 
678
                msg_look_for_rsdp
-
 
679
 
-
 
680
        mov     edi, [esi+EFI_SYSTEM_TABLE.ConfigurationTable]
-
 
681
        mov     ecx, [esi+EFI_SYSTEM_TABLE.NumberOfTableEntries]
-
 
682
.next_table:
-
 
683
        dec     ecx
-
 
684
        js      .all_tables_done
-
 
685
        ; EFI_ACPI_TABLE_GUID
-
 
686
        cmp     dword[edi+EFI_CONFIGURATION_TABLE.VendorGUID+0x0], 0x8868e871
-
 
687
        jnz     .not_acpi20
-
 
688
        cmp     dword[edi+EFI_CONFIGURATION_TABLE.VendorGUID+0x4], 0x11d3e4f1
-
 
689
        jnz     .not_acpi20
-
 
690
        cmp     dword[edi+EFI_CONFIGURATION_TABLE.VendorGUID+0x8], 0x800022bc
-
 
691
        jnz     .not_acpi20
-
 
692
        cmp     dword[edi+EFI_CONFIGURATION_TABLE.VendorGUID+0xc], 0x81883cc7
755
        mov     edx, [esi+EFI_MEMORY_DESCRIPTOR.Type]
693
        jnz     .not_acpi20
-
 
694
        mov     eax, [edi+EFI_CONFIGURATION_TABLE.VendorTable]
-
 
695
        mov     edx, BOOT_LO.acpi_rsdp
-
 
696
        mov     [edx], eax
-
 
697
        mov     eax, [esi+EFI_SYSTEM_TABLE.ConOut]
-
 
698
        ccall   [eax+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString], eax, \
-
 
699
                msg_rsdp_found
-
 
700
        jmp     .all_tables_done
-
 
701
.not_acpi20:
-
 
702
        add     edi, sizeof.EFI_CONFIGURATION_TABLE
-
 
703
        jmp     .next_table
Line -... Line 704...
-
 
704
.all_tables_done:
756
 
705
        ret
-
 
706
endp
757
        mov     eax, [esi+EFI_MEMORY_DESCRIPTOR.PhysicalStart.lo] ; FIXME hi
707
 
758
        mov     [edi+e820entry.addr], eax
708
proc calc_memmap
Line -... Line 709...
-
 
709
        mov     eax, [esi+EFI_SYSTEM_TABLE.BootServices]
-
 
710
        ccall   [eax+EFI_BOOT_SERVICES.AllocatePages], EFI_ALLOCATE_ANY_PAGES, \
-
 
711
                EFI_RESERVED_MEMORY_TYPE, MEMORY_MAP_SIZE/0x1000, memory_map
-
 
712
        call    halt_on_error
Line 759... Line -...
759
 
-
 
760
        mov     eax, [esi+EFI_MEMORY_DESCRIPTOR.NumberOfPages]
713
 
761
        shl     eax, 12
714
        mov     eax, [esi+EFI_SYSTEM_TABLE.BootServices]
762
        mov     [edi+e820entry.size], eax
-
 
763
 
715
        ccall   [eax+EFI_BOOT_SERVICES.GetMemoryMap], memory_map_size, \
764
 
716
                [memory_map], memory_map_key, descriptor_size, descriptor_ver
765
        cmp     edx, EFI_LOADER_CODE
-
 
766
        jz      .case0
717
        call    halt_on_error
767
        cmp     edx, EFI_LOADER_DATA
718
 
768
        jz      .case0
719
        push    esi
769
        cmp     edx, EFI_BOOT_SERVICES_CODE
-
 
770
        jz      .case0
720
        mov     edi, BOOT_LO.memmap_blocks
771
        cmp     edx, EFI_BOOT_SERVICES_DATA
721
        mov     dword[edi-4], 0 ; memmap_block_cnt
772
        jz      .case0
722
        mov     esi, [memory_map]
773
        cmp     edx, EFI_CONVENTIONAL_MEMORY
-
 
774
        jz      .case0
723
        mov     ebx, esi
775
        cmp     edx, EFI_ACPI_RECLAIM_MEMORY
-
 
776
        jz      .case1
724
        add     ebx, [memory_map_size]
777
        cmp     edx, EFI_ACPI_MEMORY_NVS
725
.next_descr:
-
 
726
        call    add_uefi_memmap
Line -... Line 727...
-
 
727
        add     esi, [descriptor_size]
-
 
728
        cmp     esi, ebx
778
        jz      .case2
729
        jb      .next_descr
779
        cmp     edx, EFI_UNUSABLE_MEMORY
730
        pop     esi
780
        jz      .case3
731
        ret
-
 
732
endp
-
 
733
 
-
 
734
; linux/arch/x86/platform/efi/efi.c
-
 
735
; do_add_efi_memmap
-
 
736
proc add_uefi_memmap
-
 
737
        cmp     [BOOT_LO.memmap_block_cnt], MAX_MEMMAP_BLOCKS
-
 
738
        jz      .done
-
 
739
 
781
        cmp     edx, EFI_PERSISTENT_MEMORY
740
        mov     eax, [esi+EFI_MEMORY_DESCRIPTOR.PhysicalStart.lo]
782
        jz      .case4
741
        mov     edx, [esi+EFI_MEMORY_DESCRIPTOR.PhysicalStart.hi]
-
 
742
        mov     [edi+e820entry.addr.lo], eax
-
 
743
        mov     [edi+e820entry.addr.hi], edx
783
        jmp     .default
744
 
-
 
745
        mov     eax, [esi+EFI_MEMORY_DESCRIPTOR.NumberOfPages.lo]
784
 
746
        mov     edx, [esi+EFI_MEMORY_DESCRIPTOR.NumberOfPages.hi]
-
 
747
        shld    edx, eax, 12
-
 
748
        shl     eax, 12
-
 
749
        mov     [edi+e820entry.size.lo], eax
-
 
750
        mov     [edi+e820entry.size.hi], edx
-
 
751
 
-
 
752
        mov     ecx, [esi+EFI_MEMORY_DESCRIPTOR.Type]
785
.case0:
753
        cmp     ecx, EFI_LOADER_CODE
-
 
754
        jz      .mem_ram_if_wb
786
        test    [esi+EFI_MEMORY_DESCRIPTOR.Attribute.lo], EFI_MEMORY_WB
755
        cmp     ecx, EFI_LOADER_DATA
-
 
756
        jz      .mem_ram_if_wb
787
        jz      @f
757
        cmp     ecx, EFI_BOOT_SERVICES_CODE
788
        mov     eax, E820_RAM
758
        jz      .mem_ram_if_wb
789
        jmp     .done
759
        cmp     ecx, EFI_BOOT_SERVICES_DATA
790
    @@:
760
        jz      .mem_ram_if_wb
791
        mov     eax, E820_RESERVED
761
        cmp     ecx, EFI_CONVENTIONAL_MEMORY
792
        jmp     .done
762
        jz      .mem_ram_if_wb
793
.case1:
763
        cmp     ecx, EFI_ACPI_RECLAIM_MEMORY
794
        mov     eax, E820_ACPI
764
        mov     eax, E820_ACPI
795
        jmp     .done
765
        jz      .type_done
796
.case2:
766
        cmp     ecx, EFI_ACPI_MEMORY_NVS
797
        mov     eax, E820_NVS
767
        mov     eax, E820_NVS
-
 
768
        jz      .type_done
-
 
769
        cmp     ecx, EFI_UNUSABLE_MEMORY
-
 
770
        mov     eax, E820_UNUSABLE
-
 
771
        jz      .type_done
-
 
772
        cmp     ecx, EFI_PERSISTENT_MEMORY
798
        jmp     .done
773
        mov     eax, E820_PMEM
799
.case3:
774
        jz      .type_done
800
        mov     eax, E820_UNUSABLE
-
 
801
        jmp     .done
-
 
802
.case4:
775
        jmp     .reserved
803
        mov     eax, E820_PMEM
776
.mem_ram_if_wb:
804
        jmp     .done
-
 
-
 
777
        test    [esi+EFI_MEMORY_DESCRIPTOR.Attribute.lo], EFI_MEMORY_WB
-
 
778
        mov     eax, E820_RAM
805
.default:
779
        jnz     .type_done
806
        mov     eax, E820_RESERVED
780
.reserved:
807
        jmp     .done
781
        mov     eax, E820_RESERVED
808
 
782
.type_done:
809
.done:
783
        mov     [edi+e820entry.type], eax
810
        mov     [edi+e820entry.type], eax
784
        cmp     eax, E820_RAM
Line 811... Line 785...
811
 
785
        jnz     @f