From: Minep Date: Tue, 9 Aug 2022 14:29:17 +0000 (+0100) Subject: Merge branch 'master' into vfs-dev X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/commitdiff_plain/0e1309c02f0703c050df09b71346dab60fc6df87?hp=6a279840b778869d8a80b6ef179d0114de12d0d4 Merge branch 'master' into vfs-dev --- diff --git a/lunaix-os/hal/ahci/ahci.c b/lunaix-os/hal/ahci/ahci.c index 53981a0..39e511c 100644 --- a/lunaix-os/hal/ahci/ahci.c +++ b/lunaix-os/hal/ahci/ahci.c @@ -161,7 +161,7 @@ ahci_init() // 需要通过全部置位去清空这些寄存器(相当的奇怪……) port_regs[HBA_RPxSERR] = -1; - port_regs[HBA_RPxIE] |= (HBA_PxINTR_D2HR); + port_regs[HBA_RPxIE] |= (HBA_PxINTR_DPS); hba.ports[i] = port; @@ -293,7 +293,7 @@ hba_prepare_cmd(struct hba_port* port, cmd_header->prdt_len = 1; cmd_table->entries[0] = (struct hba_prdte){ .data_base = vmm_v2p(buffer), - .byte_count = size - 1 }; + .byte_count = (size - 1) | (0x80000000) }; } *cmdh = cmd_header; diff --git a/lunaix-os/hal/pci.c b/lunaix-os/hal/pci.c index 50fe80d..d626768 100644 --- a/lunaix-os/hal/pci.c +++ b/lunaix-os/hal/pci.c @@ -181,10 +181,19 @@ pci_setup_msi(struct pci_device* device, int vector) pci_write_cspace( device->cspace_base, PCI_MSI_ADDR(device->msi_loc), msi_addr); - pci_write_cspace( - device->cspace_base, PCI_MSI_DATA(device->msi_loc), msi_data & 0xffff); pci_reg_t reg1 = pci_read_cspace(device->cspace_base, device->msi_loc); + pci_reg_t msg_ctl = reg1 >> 16; + + int offset = !!(msg_ctl & MSI_CAP_64BIT) * 4; + pci_write_cspace(device->cspace_base, + PCI_MSI_DATA(device->msi_loc, offset), + msi_data & 0xffff); + + if ((msg_ctl & MSI_CAP_MASK)) { + pci_write_cspace( + device->cspace_base, PCI_MSI_MASK(device->msi_loc, offset), 0); + } // manipulate the MSI_CTRL to allow device using MSI to request service. reg1 = (reg1 & 0xff8fffff) | 0x10000; diff --git a/lunaix-os/includes/hal/ahci/hba.h b/lunaix-os/includes/hal/ahci/hba.h index 91ecfed..334acd5 100644 --- a/lunaix-os/includes/hal/ahci/hba.h +++ b/lunaix-os/includes/hal/ahci/hba.h @@ -32,7 +32,7 @@ #define HBA_PxCMD_ST (1) #define HBA_PxINTR_DMA (1 << 2) #define HBA_PxINTR_D2HR (1) -#define HBA_PxINTR_DPE (1 << 5) +#define HBA_PxINTR_DPS (1 << 5) #define HBA_PxTFD_ERR (1) #define HBA_PxTFD_BSY (1 << 7) #define HBA_PxTFD_DRQ (1 << 3) diff --git a/lunaix-os/includes/hal/pci.h b/lunaix-os/includes/hal/pci.h index b31352b..d622acb 100644 --- a/lunaix-os/includes/hal/pci.h +++ b/lunaix-os/includes/hal/pci.h @@ -34,7 +34,12 @@ #define PCI_BAR_ADDR_IO(x) ((x) & ~0x3) #define PCI_MSI_ADDR(msi_base) ((msi_base) + 4) -#define PCI_MSI_DATA(msi_base) ((msi_base) + 8) +#define PCI_MSI_DATA(msi_base, offset) ((msi_base) + 8 + offset) +#define PCI_MSI_MASK(msi_base, offset) ((msi_base) + 0xc + offset) + +#define MSI_CAP_64BIT 0x80 +#define MSI_CAP_MASK 0x100 +#define MSI_CAP_ENABLE 0x1 #define PCI_RCMD_DISABLE_INTR (1 << 10) #define PCI_RCMD_FAST_B2B (1 << 9)