Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int ata_Identify(uint16_t bus, uint8_t ms) {
- outb(bus + DEVICE, ms);
- outb(bus + SEC_COUNT,0);
- outb(bus + LBA_L,0);
- outb(bus + LBA_M,0);
- outb(bus + LBA_H,0);
- outb(bus + COMMAND,0xEC);
- if(ata_Status(bus + COMMAND) == 0) {
- return -1;
- }
- // Retrieve Status until BSY clears
- while(ata_Status(bus + COMMAND) & BSY) {
- kprintf("Stuck\n");
- }
- // Check for lba mid and high
- if(inb(bus+LBA_M) != 0 || inb(bus+LBA_H) != 0) {
- return -1;
- }
- uint8_t status;
- while(((status = ata_Status(bus + COMMAND) & 0x9) == 0)) {
- kprintf("Stuck2\n");
- }
- if(status & ERR) {
- return -1;
- }
- uint16_t data[256];
- for(int i = 0; i < 256; i++) {
- data[i] = inb(bus);
- }
- kprintf("%x",((uint32_t)data[61] << 16 | data[60]));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment