MBR.c 749 B

1234567891011121314151617181920
  1. #include "MBR.h"
  2. #include <common/kprint.h>
  3. #include <driver/disk/ahci/ahci.h>
  4. struct MBR_disk_partition_table_t MBR_partition_tables[MBR_MAX_AHCI_CTRL_NUM][MBR_MAX_AHCI_PORT_NUM] = {0};
  5. /**
  6. * @brief 读取磁盘的分区表
  7. *
  8. * @param ahci_ctrl_num ahci控制器编号
  9. * @param ahci_port_num ahci端口编号
  10. */
  11. struct MBR_disk_partition_table_t *MBR_read_partition_table(uint8_t ahci_ctrl_num, uint8_t ahci_port_num)
  12. {
  13. unsigned char buf[512];
  14. memset(buf, 0, 512);
  15. ahci_operation.transfer(ATA_CMD_READ_DMA_EXT, 0, 1, (uint64_t)&buf, ahci_ctrl_num, ahci_port_num);
  16. MBR_partition_tables[ahci_ctrl_num][ahci_port_num] = *(struct MBR_disk_partition_table_t *)buf;
  17. return &MBR_partition_tables[ahci_ctrl_num][ahci_port_num];
  18. }