Rev 2382 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2382 | Rev 2540 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
5 | ;; ;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 7... | Line 7... | ||
7 | 7 | ||
Line 8... | Line 8... | ||
8 | $Revision: 2382 $ |
8 | $Revision $ |
9 | 9 | ||
10 | 10 | ||
Line 53... | Line 53... | ||
53 | xor esi, esi; esi will hold total amount of memory |
53 | xor esi, esi; esi will hold total amount of memory |
54 | xor edx, edx; edx will hold maximum allocatable address |
54 | xor edx, edx; edx will hold maximum allocatable address |
55 | .calcmax: |
55 | .calcmax: |
56 | ; round all to pages |
56 | ; round all to pages |
57 | mov eax, [edi] |
57 | mov eax, [edi] |
- | 58 | cmp [edi+16], byte 1 |
|
- | 59 | jne .unusable |
|
- | 60 | ||
58 | test eax, 0xFFF |
61 | test eax, 0xFFF |
59 | jz @f |
62 | jz @f |
60 | neg eax |
63 | neg eax |
61 | and eax, 0xFFF |
64 | and eax, 0xFFF |
62 | add [edi], eax |
65 | add [edi], eax |
Line 85... | Line 88... | ||
85 | sub eax, [edi] |
88 | sub eax, [edi] |
86 | mov [edi+8], eax |
89 | mov [edi+8], eax |
87 | add esi, eax |
90 | add esi, eax |
88 | jmp .usable |
91 | jmp .usable |
89 | .unusable: |
92 | .unusable: |
90 | and dword [edi+8], 0 |
93 | ; and dword [edi+8], 0 |
91 | .usable: |
94 | .usable: |
92 | add edi, 20 |
95 | add edi, 20 |
93 | loop .calcmax |
96 | loop .calcmax |
94 | .calculated: |
97 | .calculated: |
95 | mov [MEM_AMOUNT-OS_BASE], esi |
98 | mov [MEM_AMOUNT-OS_BASE], esi |
Line 193... | Line 196... | ||
193 | 196 | ||
194 | ; scan through memory map and mark free areas as available |
197 | ; scan through memory map and mark free areas as available |
195 | mov ebx, BOOT_VAR-OS_BASE + 0x9104 |
198 | mov ebx, BOOT_VAR-OS_BASE + 0x9104 |
196 | mov edx, [ebx-4] |
199 | mov edx, [ebx-4] |
- | 200 | .scanmap: |
|
- | 201 | cmp [ebx+16], byte 1 |
|
- | 202 | jne .next |
|
197 | .scanmap: |
203 | |
198 | mov ecx, [ebx+8] |
204 | mov ecx, [ebx+8] |
199 | shr ecx, 12; ecx = number of pages |
205 | shr ecx, 12; ecx = number of pages |
200 | jz .next |
206 | jz .next |
201 | mov edi, [ebx] |
207 | mov edi, [ebx] |
Line 430... | Line 436... | ||
430 | shr eax, 8 |
436 | shr eax, 8 |
431 | and eax, 0x0f |
437 | and eax, 0x0f |
432 | ret |
438 | ret |
433 | endp |
439 | endp |
Line -... | Line 440... | ||
- | 440 | ||
- | 441 | iglobal |
|
- | 442 | align 4 |
|
- | 443 | acpi_lapic_base dd 0xfee00000 ; default local apic base |
|
- | 444 | endg |
|
434 | 445 | ||
435 | uglobal |
446 | uglobal |
436 | align 4 |
447 | align 4 |
437 | acpi_rsdp rd 1 |
448 | acpi_rsdp rd 1 |
438 | acpi_rsdt rd 1 |
449 | acpi_rsdt rd 1 |
Line 441... | Line 452... | ||
441 | acpi_dev_data rd 1 |
452 | acpi_dev_data rd 1 |
442 | acpi_dev_size rd 1 |
453 | acpi_dev_size rd 1 |
Line 443... | Line 454... | ||
443 | 454 | ||
444 | acpi_rsdt_base rd 1 |
455 | acpi_rsdt_base rd 1 |
445 | acpi_madt_base rd 1 |
- | |
446 | acpi_lapic_base rd 1 |
456 | acpi_madt_base rd 1 |
- | 457 | acpi_ioapic_base rd 1 |
|
- | 458 | ||
- | 459 | cpu_count rd 1 |
|
447 | acpi_ioapic_base rd 1 |
460 | smpt rd 16 |
Line 448... | Line 461... | ||
448 | endg |
461 | endg |
449 | 462 | ||
450 | ACPI_HI_RSDP_WINDOW_START equ 0x000E0000 |
463 | ACPI_HI_RSDP_WINDOW_START equ 0x000E0000 |
Line 491... | Line 504... | ||
491 | push esi |
504 | push esi |
Line 492... | Line 505... | ||
492 | 505 | ||
493 | lea ebx, [ecx+36] |
506 | lea ebx, [ecx+36] |
494 | mov esi, [ecx+4] |
507 | mov esi, [ecx+4] |
- | 508 | add esi, ecx |
|
495 | add esi, ecx |
509 | align 4 |
496 | .next: |
510 | .next: |
497 | mov eax, [ebx] |
511 | mov eax, [ebx] |
498 | cmp [eax], edx |
512 | cmp [eax], edx |
Line 511... | Line 525... | ||
511 | mov eax, [ebx] |
525 | mov eax, [ebx] |
512 | pop esi |
526 | pop esi |
513 | pop ebx |
527 | pop ebx |
514 | ret |
528 | ret |
Line 515... | Line -... | ||
515 | - | ||
516 | 529 | ||
517 | align 4 |
- | |
518 | 530 | align 4 |
|
Line 519... | Line 531... | ||
519 | check_acpi: |
531 | check_acpi: |
520 | 532 | ||
521 | call acpi_locate |
533 | call acpi_locate |
Line 531... | Line 543... | ||
531 | 543 | ||
532 | mov [acpi_madt_base-OS_BASE], eax |
544 | mov [acpi_madt_base-OS_BASE], eax |
533 | mov ecx, [eax+36] |
545 | mov ecx, [eax+36] |
Line -... | Line 546... | ||
- | 546 | mov [acpi_lapic_base-OS_BASE], ecx |
|
- | 547 | ||
- | 548 | mov edi, smpt-OS_BASE |
|
- | 549 | mov ebx, [ecx+0x20] |
|
- | 550 | shr ebx, 24 ; read APIC ID |
|
- | 551 | ||
- | 552 | mov [edi], ebx ; bootstrap always first |
|
- | 553 | inc [cpu_count-OS_BASE] |
|
534 | mov [acpi_lapic_base-OS_BASE], ecx |
554 | add edi, 4 |
535 | 555 | ||
536 | lea edx, [eax+44] |
556 | lea edx, [eax+44] |
537 | mov ecx, [eax+4] |
557 | mov ecx, [eax+4] |
538 | add ecx, eax |
558 | add ecx, eax |
539 | .check: |
559 | .check: |
540 | mov eax, [edx] |
560 | mov eax, [edx] |
- | 561 | cmp al, 0 |
|
- | 562 | jne .io_apic |
|
- | 563 | ||
- | 564 | shr eax, 24 ; get APIC ID |
|
- | 565 | cmp eax, ebx ; skip self |
|
- | 566 | je .next |
|
- | 567 | ||
- | 568 | test [edx+4], byte 1 ; is enabled ? |
|
- | 569 | jz .next |
|
- | 570 | ||
Line -... | Line 571... | ||
- | 571 | cmp [cpu_count-OS_BASE], 16 |
|
- | 572 | jae .next |
|
541 | cmp al, 1 |
573 | |
- | 574 | stosd ; store APIC ID |
|
542 | je .ioapic |
575 | inc [cpu_count-OS_BASE] |
543 | 576 | .next: |
|
544 | .next: |
577 | mov eax, [edx] |
545 | movzx eax, ah |
578 | movzx eax, ah |
546 | add edx, eax |
579 | add edx, eax |
547 | cmp edx, ecx |
580 | cmp edx, ecx |
- | 581 | jb .check |
|
548 | jb .check |
582 | .done: |
- | 583 | ret |
|
- | 584 | ||
- | 585 | .io_apic: |
|
549 | .done: |
586 | cmp al, 1 |
550 | ret |
587 | jne .next |
551 | .ioapic: |
588 |