Subversion Repositories Kolibri OS

Rev

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

Rev 9074 Rev 9130
Line 25... Line 25...
25
bit_AHCI_HBA_PxCMD_ST    = 0
25
bit_AHCI_HBA_PxCMD_ST    = 0
26
bit_AHCI_HBA_PxCMD_FRE   = 4
26
bit_AHCI_HBA_PxCMD_FRE   = 4
27
bit_AHCI_HBA_PxCMD_FR    = 14
27
bit_AHCI_HBA_PxCMD_FR    = 14
28
bit_AHCI_HBA_PxCMD_CR    = 15
28
bit_AHCI_HBA_PxCMD_CR    = 15
Line -... Line 29...
-
 
29
 
-
 
30
AHCI_HBA_PxCMD_ST    = 1 shl 0
-
 
31
AHCI_HBA_PxCMD_FRE   = 1 shl 4
-
 
32
AHCI_HBA_PxCMD_FR    = 1 shl 14
-
 
33
AHCI_HBA_PxCMD_CR    = 1 shl 15
29
 
34
 
Line 30... Line 35...
30
bit_AHCI_H2D_FLAG_CMD    = 7
35
bit_AHCI_H2D_FLAG_CMD    = 7
31
 
36
 
32
AHCI_HBA_PxSSTS_DET         = 0xF
37
AHCI_HBA_PxSSTS_DET         = 0xF
Line 415... Line 420...
415
        imul    edi, sizeof.HBA_PORT
420
        imul    edi, sizeof.HBA_PORT
416
        add     edi, HBA_MEM.ports
421
        add     edi, HBA_MEM.ports
417
        add     edi, esi
422
        add     edi, esi
418
        ; now edi - base of HBA_MEM.ports[ebx]
423
        ; now edi - base of HBA_MEM.ports[ebx]
Line 419... Line 424...
419
 
424
 
-
 
425
        DEBUGF  1, "K: AHCI: port %d, cmd = %x, ssts = %x\n", ebx, [edi + HBA_PORT.command], [edi + HBA_PORT.sata_status]
-
 
426
 
-
 
427
        ; If port is not idle force it to be idle
-
 
428
        mov     eax, [edi + HBA_PORT.command]
-
 
429
        and     eax, (AHCI_HBA_PxCMD_ST or AHCI_HBA_PxCMD_CR or AHCI_HBA_PxCMD_FRE or AHCI_HBA_PxCMD_FR)
-
 
430
        test    eax, eax
-
 
431
        jz      @f
-
 
432
 
-
 
433
        mov     eax, edi
-
 
434
        DEBUGF  1, "ahci_stop_cmd..\n"
-
 
435
        call    ahci_stop_cmd
-
 
436
@@:
-
 
437
        ; TODO: what is purpose of this block of code ?
-
 
438
        ; Reset port, disable slumber and partial state
-
 
439
        ; mov     [edi + HBA_PORT.sata_control], 0x301
-
 
440
        ; push    ebx
-
 
441
        ; mov     ebx, 5 ; wait 50 ms
-
 
442
        ; call    delay_hs
-
 
443
        ; pop     ebx
-
 
444
        ; mov     [edi + HBA_PORT.sata_control], 0x300
-
 
445
 
-
 
446
        ; if(abar->cap & HBA_MEM_CAP_SSS)
-
 
447
        ; {
-
 
448
        ; abar->ports[i].cmd |= (HBA_PxCMD_SUD | HBA_PxCMD_POD | HBA_PxCMD_ICC);
-
 
449
        ; Sleep(10);
-
 
450
        ; }
-
 
451
        ; rewritten to:
-
 
452
        bt      [esi + HBA_MEM.cap], 27 ; check Supports Staggered Spin-up bit in capabilities
-
 
453
        jnc     @f
-
 
454
        DEBUGF  1, "Supports Staggered Spin-up\n"
-
 
455
        or      [edi + HBA_PORT.command], (0x0002 or 0x0004 or 0x10000000)
-
 
456
        push    ebx
-
 
457
        mov     ebx, 1 ; wait 10 ms
-
 
458
        call    delay_hs
-
 
459
        pop     ebx
-
 
460
@@:
-
 
461
        ; Clear interrupt status and error status
-
 
462
        mov     [edi + HBA_PORT.sata_error], 0xFFFFFFFF
-
 
463
        mov     [edi + HBA_PORT.interrupt_status], 0xFFFFFFFF
-
 
464
 
Line 420... Line 465...
420
        DEBUGF  1, "K: AHCI: port %d, ssts = %x\n", ebx, [edi + HBA_PORT.sata_status]
465
        ; ------------------------------------------
421
 
466
 
422
        mov     ecx, [edi + HBA_PORT.sata_status]
467
        mov     ecx, [edi + HBA_PORT.sata_status]
423
        shr     ecx, 8
468
        shr     ecx, 8
Line 428... Line 473...
428
        mov     ecx, [edi + HBA_PORT.sata_status]
473
        mov     ecx, [edi + HBA_PORT.sata_status]
429
        and     ecx, AHCI_HBA_PxSSTS_DET
474
        and     ecx, AHCI_HBA_PxSSTS_DET
430
        cmp     ecx, AHCI_HBA_PxSSTS_DET_PRESENT
475
        cmp     ecx, AHCI_HBA_PxSSTS_DET_PRESENT
431
        jne     .continue_detect_drives
476
        jne     .continue_detect_drives
Line 432... Line 477...
432
 
477
 
Line 433... Line 478...
433
        DEBUGF  1, "K: AHCI: found drive at port %d, signature = %x\n", ebx, [edi + HBA_PORT.signature]  
478
        DEBUGF  1, "K: AHCI: found drive at port %d, cmd = 0x%x, ssts = 0x%x, signature = 0x%x\n", ebx, [edi + HBA_PORT.command], [edi + HBA_PORT.sata_status], [edi + HBA_PORT.signature]  
434
 
479
 
435
        mov     ecx, ebx
480
        mov     ecx, ebx
436
        imul    ecx, sizeof.PORT_DATA
481
        imul    ecx, sizeof.PORT_DATA
Line 522... Line 567...
522
 
567
 
523
        ; TODO AHCIPortCmdWait(bd->port_num, cmd_slot);
568
        ; TODO AHCIPortCmdWait(bd->port_num, cmd_slot);
524
        mov     ebx, 20 ;;;
569
        mov     ebx, 20 ;;;
Line -... Line 570...
-
 
570
        call    delay_hs ;;;
-
 
571
 
-
 
572
        DEBUGF  1, "sata_error register = 0x%x\n", [edi + HBA_PORT.sata_error]
-
 
573
 
-
 
574
        mov     ecx, ecx
-
 
575
        mov     esi, [buf_virt]
-
 
576
.print_ident:
-
 
577
        cmp     ecx, 512 - 1 ; why -1 ?
-
 
578
        jae     .end_print_ident
-
 
579
 
-
 
580
        mov     al, byte [esi + ecx]
-
 
581
        mov     byte [modelstr], al
-
 
582
        mov     byte [modelstr + 1], 0
-
 
583
        DEBUGF  1, "(%s) ", modelstr
-
 
584
 
-
 
585
        inc     ecx
-
 
586
        jmp     .print_ident
525
        call    delay_hs ;;;
587
.end_print_ident:
526
 
588
 
527
        mov     esi, [buf_virt]
589
        mov     esi, [buf_virt]
528
        add     esi, 27*2
590
        add     esi, 27*2
529
        mov     edi, modelstr
591
        mov     edi, modelstr
Line 541... Line 603...
541
        mov     byte [modelstr + ecx], dl
603
        mov     byte [modelstr + ecx], dl
542
        mov     byte [modelstr + ecx + 1], bl
604
        mov     byte [modelstr + ecx + 1], bl
543
        add     ecx, 2
605
        add     ecx, 2
544
        jmp     .reverse1
606
        jmp     .reverse1
545
.reverse1_end:
607
.reverse1_end:
546
        DEBUGF  1, "Ident data of port: model = %s\n", modelstr
608
        DEBUGF  1, "Ident data of port: model = %s ", modelstr
-
 
609
 
-
 
610
        ; mov    esi, [buf_virt]
-
 
611
        ; mov    eax, [esi + 12] ; lower dword of sector count has 12 bytes offset
-
 
612
        ; mov    edx, [esi + 12 + 4] ; higher dword of sector count
-
 
613
        ; DEBUGF 1, "sector_count = 0x%x:%x ", edx, eax
-
 
614
 
-
 
615
        ; mov    eax, [esi + 200]
-
 
616
        ; mov    edx, [esi + 200 + 4]
-
 
617
        ; mov    ecx, 1024*1024
-
 
618
        ; div    ecx
-
 
619
        ; shl    eax, 9 ; *= 512, 512 - block size
-
 
620
        ; DEBUGF 1, "disk capacity = %u MiB\n", eax
-
 
621
 
Line 547... Line 622...
547
 
622
 
548
.ret:
623
.ret:
549
        popad
624
        popad
550
        ret
625
        ret