X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/c4d08ac5260bb26db10bcfd9dc6fd2db60efebe9..e6416905c4afb34e61276cdc07c44813a3ebc5e7:/lunaix-os/hal/ahci/utils.c diff --git a/lunaix-os/hal/ahci/utils.c b/lunaix-os/hal/ahci/utils.c index 96d163b..f11ffb4 100644 --- a/lunaix-os/hal/ahci/utils.c +++ b/lunaix-os/hal/ahci/utils.c @@ -85,4 +85,19 @@ ahci_try_send(struct hba_port* port, int slot) hba_clear_reg(port->regs[HBA_RPxIS]); return retries < MAX_RETRY; +} + +void +ahci_post(struct hba_port* port, struct hba_cmd_state* state, int slot) +{ + int bitmask = 1 << slot; + + // 确保端口是空闲的 + wait_until(!(port->regs[HBA_RPxTFD] & (HBA_PxTFD_BSY | HBA_PxTFD_DRQ))); + + hba_clear_reg(port->regs[HBA_RPxIS]); + + port->cmdctx.issued[slot] = state; + port->cmdctx.tracked_ci |= bitmask; + port->regs[HBA_RPxCI] |= bitmask; } \ No newline at end of file