Skip to content

Commit

Permalink
[kernel][driver][ahci] Make AHCI driver register controller with SATA…
Browse files Browse the repository at this point in the history
… driver
  • Loading branch information
JasonBrave committed Jul 28, 2022
1 parent 975a37f commit 253c2d4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions kernel/driver/ahci/ahci.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

#include <defs.h>
#include <driver/ata/ata.h>
#include <driver/pci/pci.h>
#include <memlayout.h>

Expand Down Expand Up @@ -138,6 +139,14 @@ void ahci_controller_init(struct PCIDevice* pci_dev) {
i++) {
ahci_init_port(ahci, i);
}
// register SATA controller
struct SATAController* sata_controller = kalloc();
memset(sata_controller, 0, sizeof(struct SATAController));
sata_controller->type = SATA_CONTROLLER_TYPE_AHCI;
sata_controller->num_ports
= ((ahci_read_reg32(ahci, AHCI_CAP) >> AHCI_CAP_NPORTS_SHIFT) & AHCI_CAP_NPORTS_MASK) + 1;
sata_controller->private = ahci;
sata_register_controller(sata_controller);
}

struct PCIDriver ahci_driver = {
Expand Down

0 comments on commit 253c2d4

Please sign in to comment.