#include "drivers/atapi/ata.h" #include "lib/print.h" #include uint8_t selected_drive_primary = 0; uint8_t selected_drive_secondary = 0; uint8_t primary_master_info_buffer[512]; uint8_t primary_slave_info_buffer[512]; uint8_t secondary_master_info_buffer[512]; uint8_t secondary_slave_info_buffer[512]; ide_device_t ide_devices[4]; void fix_ata_string(char* buf, size_t sz) { if ((sz % 2) != 0) return; for (size_t i = 0; i < sz; i += 2) { char tmp = buf[i]; buf[i] = buf[i + 1]; buf[i + 1] = tmp; } buf[sz-1] = '\0'; } void scan_drives() { uint8_t type = ident_device(IDE_SECONDARY_IO_BASE, IDE_DRIVE_MASTER, secondary_master_info_buffer); if (type == 2) { ide_devices[0].bus = IDE_SECONDARY_IO_BASE; ide_devices[0].device = IDE_DRIVE_MASTER; ide_devices->type = type; atapi_identify_data_t* ident_result = (atapi_identify_data_t*)secondary_master_info_buffer; ide_devices->ident_info_struct = (void*)ident_result; kprintf("Detected ATAPI master device on secondary bus\n"); fix_ata_string(ident_result->model_num, 40); kprintf("Model Number: %s\n", ident_result->model_num); } }