- int retries = 0;
-
- while (retries < MAX_RETRY) {
- port->regs[HBA_RPxCI] = bitmask;
-
- wait_until(!(port->regs[HBA_RPxCI] & bitmask));
-
- if ((port->regs[HBA_RPxTFD] & HBA_PxTFD_ERR)) {
- // 有错误
- sata_read_error(port);
- retries++;
- } else {
- vfree_dma(table);
- return 1;
- }
- }
-
-fail:
- vfree_dma(table);
- return 0;
-}
-
-int
-sata_read_buffer(struct hba_device* dev,
- uint64_t lba,
- void* buffer,
- uint32_t size)
-{
- return __sata_buffer_io(dev, lba, buffer, size, 0);
-}
-
-int
-sata_write_buffer(struct hba_device* dev,
- uint64_t lba,
- void* buffer,
- uint32_t size)
-{
- return __sata_buffer_io(dev, lba, buffer, size, 1);
-}
+ // The async way...
+ struct hba_cmd_state* cmds = valloc(sizeof(struct hba_cmd_state));
+ *cmds = (struct hba_cmd_state){ .cmd_table = table, .state_ctx = io_req };
+ ahci_post(port, cmds, slot);
+}
\ No newline at end of file