Revision 1fddfba1

b/hw/ide/ahci.c
884 884
        }
885 885

  
886 886
        if (ide_state->drive_kind != IDE_CD) {
887
            ide_set_sector(ide_state, (cmd_fis[6] << 16) | (cmd_fis[5] << 8) |
888
                           cmd_fis[4]);
887
            /*
888
             * We set the sector depending on the sector defined in the FIS.
889
             * Unfortunately, the spec isn't exactly obvious on this one.
890
             *
891
             * Apparently LBA48 commands set fis bytes 10,9,8,6,5,4 to the
892
             * 48 bit sector number. ATA_CMD_READ_DMA_EXT is an example for
893
             * such a command.
894
             *
895
             * Non-LBA48 commands however use 7[lower 4 bits],6,5,4 to define a
896
             * 28-bit sector number. ATA_CMD_READ_DMA is an example for such
897
             * a command.
898
             *
899
             * Since the spec doesn't explicitly state what each field should
900
             * do, I simply assume non-used fields as reserved and OR everything
901
             * together, independent of the command.
902
             */
903
            ide_set_sector(ide_state, ((uint64_t)cmd_fis[10] << 40)
904
                                    | ((uint64_t)cmd_fis[9] << 32)
905
                                    /* This is used for LBA48 commands */
906
                                    | ((uint64_t)cmd_fis[8] << 24)
907
                                    /* This is used for non-LBA48 commands */
908
                                    | ((uint64_t)(cmd_fis[7] & 0xf) << 24)
909
                                    | ((uint64_t)cmd_fis[6] << 16)
910
                                    | ((uint64_t)cmd_fis[5] << 8)
911
                                    | cmd_fis[4]);
889 912
        }
890 913

  
891 914
        /* Copy the ACMD field (ATAPI packet, if any) from the AHCI command

Also available in: Unified diff