X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/01a605198da7bc5883a3dfa96b38f4f7c04f67f9..09a115a4c07e26b3a978c693c0d6d17abea80479:/lunaix-os/hal/ahci/utils.c diff --git a/lunaix-os/hal/ahci/utils.c b/lunaix-os/hal/ahci/utils.c index 279cd50..9af9cfe 100644 --- a/lunaix-os/hal/ahci/utils.c +++ b/lunaix-os/hal/ahci/utils.c @@ -1,3 +1,4 @@ +#include #include #include @@ -8,13 +9,14 @@ #define IDDEV_MODELNUM_OFFSET 27 void -ahci_parse_dev_info(struct ahci_device_info* dev_info, uint16_t* data) +ahci_parse_dev_info(struct hba_device* dev_info, uint16_t* data) { dev_info->max_lba = *((uint32_t*)(data + IDDEV_MAXLBA_OFFSET)); - dev_info->sector_size = *((uint32_t*)(data + IDDEV_LSECSIZE_OFFSET)); + dev_info->block_size = *((uint32_t*)(data + IDDEV_LSECSIZE_OFFSET)); + dev_info->cbd_size = (*data & 0x3) ? 12 : 16; memcpy(&dev_info->wwn, (uint8_t*)(data + IDDEV_WWN_OFFSET), 8); - if (!dev_info->sector_size) { - dev_info->sector_size = 512; + if (!dev_info->block_size) { + dev_info->block_size = 512; } ahci_parsestr(&dev_info->serial_num, data + IDDEV_SERIALNUM_OFFSET, 10); ahci_parsestr(&dev_info->model, data + IDDEV_MODELNUM_OFFSET, 20); @@ -23,9 +25,11 @@ ahci_parse_dev_info(struct ahci_device_info* dev_info, uint16_t* data) void ahci_parsestr(char* str, uint16_t* reg_start, int size_word) { - for (int i = 0, j = 0; i < size_word; i++, j += 2) { + int j = 0; + for (int i = 0; i < size_word; i++, j += 2) { uint16_t reg = *(reg_start + i); str[j] = (char)(reg >> 8); str[j + 1] = (char)(reg & 0xff); } + str[j - 1] = '\0'; } \ No newline at end of file