You can try to create a simple SATA device driver.
The process is kind of complex and it is way harder to explain than to
show, so i'll attach some code for you.
First, find the devices. You will need to obtain the RSDP. (i get it from limine services)
Having the RSDP, you will have to find the MCFG header, required for iterating PCI bus.
Related code for this is:
https://github.com/TretornESP/bloodmoon ... dev/acpi.c function
Code:
init_acpi
.
(get_rsdp_address() is a function that talks to limine, replace it with whatever
you like).
Then enumerate PCI devices
https://github.com/TretornESP/bloodmoon ... /dev/pci.c Code:
function enumerate_pci(
)
and search for class: 1, subclass: 6 and program interface: 1 wich are AHCI devices.
https://github.com/TretornESP/bloodmoon ... /devices.c function
Code:
register_devices()
For each one, initialice the ahci device.
https://github.com/TretornESP/bloodmoon ... dev/ahci.c function
Code:
init_ahci()
And store some reference to each available port categorizing it as SATA or ATAPI.
Now when you call your read function, you need to select the desired target device and use the function:
https://github.com/TretornESP/bloodmoon ... dev/ahci.c function
Code:
read_port()
I'm sorry but it is a really lenghty process and i don't really know how to explain it better. Hope this helps!
Have a nice day.