#include <alloc.h> #include <fileSystem.h> #include <hardDrive.h> #include <pci.h> #include <ports.h> #include <stdio.h> #define CONTENT(ptr) *((uint32_t *)(ptr)) extern void accessAHCIDrive(HardDrive *drive, uint64_t lba, void *buffer, uint16_t count, uint8_t direction); void scanHardDrives() { ListElement *drives = NULL; for (ListElement *current = *getPciDevices(); current; current = current->next) { PciDevice *pciDevice = current->data; if (pciDevice->class != 1) { continue; } switch (pciDevice->subclass) { case 1: initializeIdeController(pciDevice, &drives); break; case 6: initializeSataController(pciDevice, &drives); break; } } void *buffer = malloc(512); uint8_t i = 0; foreach (drives) { HardDrive *drive = current->data; drive->access(drive, 0, buffer, 1, 0); printf("drive %i start: %x end: %x\n", ++i, CONTENT(buffer), CONTENT(buffer + 508)); } printf("count: %i\n", listCount(drives)); mountDisk(listGet(&drives, 1)); }