Subversion Repositories Kolibri OS

Rev

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

Rev 1074 Rev 1085
Line 54... Line 54...
54
;;
54
;;
55
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
55
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 56... Line 56...
56
 
56
 
Line 57... Line 57...
57
include 'macros.inc'
57
include 'macros.inc'
Line 58... Line 58...
58
 
58
 
Line 59... Line 59...
59
$Revision: 1074 $
59
$Revision: 1085 $
Line 5456... Line 5456...
5456
 
5456
 
5457
           mov al, 0xFF
5457
           mov al, 0xFF
5458
           out 0x21, al
5458
           out 0x21, al
Line 5459... Line 5459...
5459
           out 0xA1, al
5459
           out 0xA1, al
5460
 
5460
 
5461
if 1
5461
if 0
Line 5462... Line 5462...
5462
           mov  word [OS_BASE+0x467+0],pr_mode_exit
5462
           mov  word [OS_BASE+0x467+0],pr_mode_exit
5463
           mov  word [OS_BASE+0x467+2],0x1000
5463
           mov  word [OS_BASE+0x467+2],0x1000
Line 5469... Line 5469...
5469
 
5469
 
5470
           mov  al,0xFE
5470
           mov  al,0xFE
Line 5471... Line 5471...
5471
           out  0x64,al
5471
           out  0x64,al
-
 
5472
 
Line 5472... Line 5473...
5472
 
5473
           hlt
5473
           hlt
5474
           jmp $-1
5474
 
5475
 
Line 5520... Line 5521...
5520
        jz      .fadt_found
5521
        jz      .fadt_found
5521
        loop    .scan_fadt
5522
        loop    .scan_fadt
5522
        jmp     no_acpi_power_off
5523
        jmp     no_acpi_power_off
5523
.fadt_found:
5524
.fadt_found:
5524
; ebx is linear address of FADT
5525
; ebx is linear address of FADT
-
 
5526
        mov     edi, [ebx+40] ; physical address of the DSDT
-
 
5527
        lea     eax, [ebp+4000h]
-
 
5528
        stdcall map_page, eax, edi, PG_MAP
-
 
5529
        lea     eax, [ebp+5000h]
-
 
5530
        lea     esi, [edi+0x1000]
-
 
5531
        stdcall map_page, eax, esi, PG_MAP
-
 
5532
        and     esi, 0xFFF
-
 
5533
        sub     edi, esi
-
 
5534
        cmp     dword [esi+ebp+4000h], 'DSDT'
-
 
5535
        jnz     no_acpi_power_off
-
 
5536
        mov     eax, [esi+ebp+4004h] ; DSDT length
-
 
5537
        sub     eax, 36+4
-
 
5538
        jbe     no_acpi_power_off
-
 
5539
        add     esi, 36
-
 
5540
.scan_dsdt:
-
 
5541
        cmp     dword [esi+ebp+4000h], '_S5_'
-
 
5542
        jnz     .scan_dsdt_cont
-
 
5543
        cmp     byte [esi+ebp+4000h+4], 12h ; DefPackage opcode
-
 
5544
        jnz     .scan_dsdt_cont
-
 
5545
        mov     dl, [esi+ebp+4000h+6]
-
 
5546
        cmp     dl, 4 ; _S5_ package must contain 4 bytes
-
 
5547
                      ; ...in theory; in practice, VirtualBox has 2 bytes
-
 
5548
        ja      .scan_dsdt_cont
-
 
5549
        cmp     dl, 1
-
 
5550
        jb      .scan_dsdt_cont
-
 
5551
        lea     esi, [esi+ebp+4000h+7]
-
 
5552
        xor     ecx, ecx
-
 
5553
        cmp     byte [esi], 0 ; 0 means zero byte, 0Ah xx means byte xx
-
 
5554
        jz      @f
-
 
5555
        cmp     byte [esi], 0xA
-
 
5556
        jnz     no_acpi_power_off
-
 
5557
        inc     esi
-
 
5558
        mov     cl, [esi]
-
 
5559
@@:
-
 
5560
        inc     esi
-
 
5561
        cmp     dl, 2
-
 
5562
        jb      @f
-
 
5563
        cmp     byte [esi], 0
-
 
5564
        jz      @f
-
 
5565
        cmp     byte [esi], 0xA
-
 
5566
        jnz     no_acpi_power_off
-
 
5567
        inc     esi
-
 
5568
        mov     ch, [esi]
-
 
5569
@@:
-
 
5570
        jmp     do_acpi_power_off
-
 
5571
.scan_dsdt_cont:
-
 
5572
        inc     esi
-
 
5573
        cmp     esi, 0x1000
-
 
5574
        jb      @f
-
 
5575
        sub     esi, 0x1000
-
 
5576
        add     edi, 0x1000
-
 
5577
        push    eax
-
 
5578
        lea     eax, [ebp+4000h]
-
 
5579
        stdcall map_page, eax, edi, PG_MAP
-
 
5580
        push    PG_MAP
-
 
5581
        lea     eax, [edi+1000h]
-
 
5582
        push    eax
-
 
5583
        lea     eax, [ebp+5000h]
-
 
5584
        push    eax
-
 
5585
        stdcall map_page
-
 
5586
        pop     eax
-
 
5587
@@:
-
 
5588
        dec     eax
-
 
5589
        jnz     .scan_dsdt
-
 
5590
        jmp     no_acpi_power_off
-
 
5591
do_acpi_power_off:
5525
        mov     edx, [ebx+48]
5592
        mov     edx, [ebx+48]
5526
        test    edx, edx
5593
        test    edx, edx
5527
        jz      .nosmi
5594
        jz      .nosmi
5528
        mov     al, [ebx+52]
5595
        mov     al, [ebx+52]
5529
        out     dx, al
5596
        out     dx, al
Line 5531... Line 5598...
5531
@@:
5598
@@:
5532
        in      ax, dx
5599
        in      ax, dx
5533
        test    al, 1
5600
        test    al, 1
5534
        jz      @b
5601
        jz      @b
5535
.nosmi:
5602
.nosmi:
-
 
5603
        and     cx, 0x0707
-
 
5604
        shl     cx, 2
-
 
5605
        or      cx, 0x2020
5536
        mov     edx, [ebx+64]
5606
        mov     edx, [ebx+64]
5537
        in      ax, dx
5607
        in      ax, dx
5538
        and     ax, 203h
5608
        and     ax, 203h
5539
        or      ax, 3C00h
5609
        or      ah, cl
5540
        out     dx, ax
5610
        out     dx, ax
5541
        mov     edx, [ebx+68]
5611
        mov     edx, [ebx+68]
5542
        test    edx, edx
5612
        test    edx, edx
5543
        jz      @f
5613
        jz      @f
5544
        in      ax, dx
5614
        in      ax, dx
5545
        and     ax, 203h
5615
        and     ax, 203h
5546
        or      ax, 3C00h
5616
        or      ah, ch
5547
        out     dx, ax
5617
        out     dx, ax
5548
@@:
5618
@@:
5549
        jmp     $
5619
        jmp     $
Line 5560... Line 5630...
5560
 
5630
 
5561
           mov  al,0xFE
5631
           mov  al,0xFE
Line 5562... Line 5632...
5562
           out  0x64,al
5632
           out  0x64,al
-
 
5633
 
Line 5563... Line 5634...
5563
 
5634
           hlt
5564
           hlt
5635
           jmp $-1
5565
 
5636
 
5566
scan_rsdp:
5637
scan_rsdp: