ahci: add block operations

Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
Michael Shaw 2026-07-13 00:02:22 -04:00
commit fc0720b118
5 changed files with 60 additions and 9 deletions

View file

@ -1,4 +1,4 @@
# SPDX-License-Identifier: GPL-2.0-only
obj-y += acpi/
obj-y += pci/
#obj-y += ahci.o
obj-y += ahci.o

View file

@ -5,10 +5,13 @@
#include <drivers/pci.h>
#include <drivers/ahci.h>
#include <kernel/block.h>
#include <lib/string.h>
#include <lib/stdio.h>
#include <fs/devfs.h>
static uint8_t sata_device_count = 0;
static struct sata_device sata_devices[32] = {0};
@ -212,8 +215,18 @@ int ahci_access_sectors(struct sata_device *dev, paddr_t lba, uint16_t count, pa
return true;
}
void ahci_init_device(struct pci_device *device)
static ssize_t ahci_block_read(struct block_device *dev, char *buf, size_t off, size_t n_blocks)
{
}
static int ahci_init_device(struct pci_device *device, size_t ahci_dev_no)
{
struct block_device *bdev = kzalloc(sizeof(struct block_device), ALLOC_KERN);
if (!bdev)
return -ENOMEM;
return 0;
}
void ahci_init()
@ -224,11 +237,16 @@ void ahci_init()
size_t n = pci_find_device(0x0001, 0x0006, &dev_list);
list_item_t *item = dev_list.head;
size_t i = 0;
while (item) {
ahci_init_device(item->ptr);
int res = ahci_init_device(item->ptr, i++);
if (res < 0)
kerr("ahci_init_device: %s\n", strerror(-res));
item = item->next;
}
krdy("AHCI ready\n");
krdy("AHCI ready\n");
}
DRIVER_ENTRY_PRIORITY(ahci_init, 3);