public static void RemoveCursor() { C.outb(0x3D4, 14); C.outb(0x3D5, 0x07); C.outb(0x3D4, 15); C.outb(0x3D5, 0xD0); }
public static void UpdateCursor(int X, int Y) { int tmp = GetOffset(X, Y); C.outb(0x3D4, 14); C.outb(0x3D5, (byte)(tmp >> 8)); C.outb(0x3D4, 15); C.outb(0x3D5, (byte)tmp); }
/* Use the ATAPI protocol to read a single sector from the given * * bus/drive into the buffer using logical block address lba. */ internal static unsafe int atapi_drive_read_sector(UInt32 bus, UInt32 drive, UInt32 lba, byte *buffer) { // 0xA8 is READ SECTORS command byte ushort[] read_cmd = new ushort[12] { 0xA8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; byte status; int size; // Tell the scheduler that this process is using the ATA subsystem // ata_grab(); // WHAT DA HELL IS ATA_GRAB() // Select drive (only the slave-bit is set) portnum = (byte)bus; ushort thePort = (ushort)(drive & (1 << 4)); C.outb(thePort, ATA_DRIVE_SELECT); ATA_SELECT_DELAY((byte)bus); // 400ns delay C.outb(0x0, ATA_FEATURES); // PIO mode C.outb(ATAPI_SECTOR_SIZE & 0xFF, ATA_ADDRESS2); C.outb(ATAPI_SECTOR_SIZE >> 8, ATA_ADDRESS3); C.outb(0xA0, ATA_COMMAND); // ATA PACKET command // while ((status = inb (ATA_COMMAND (bus))) & 0x80) while (((status = C.inb(ATA_COMMAND)) & 0x80) == 0) { ; } // while (!((status = inb (ATA_COMMAND (bus))) & 0x8) && !(status & 0x1)) while (((status = C.inb(ATA_COMMAND)) & 0x8) != 0 && (status & 0x01) != 0) { ; } // DRQ or ERROR set if ((byte)(status & 0x1) == 0) { size = -1; goto cleanup; } read_cmd[9] = 1; // 1 sector read_cmd[2] = (byte)((lba >> 0x18) & 0xFF); // most sig. byte of LBA read_cmd[3] = (byte)((lba >> 0x10) & 0xFF); read_cmd[4] = (byte)((lba >> 0x08) & 0xFF); read_cmd[5] = (byte)((lba >> 0x00) & 0xFF); // least sig. byte of LBA // Send ATAPI/SCSI command //outw(ATA_DATA, read_cmd); // WTF? read_cmd is an array! foreach (ushort ush in read_cmd) { C.outw(ATA_DATA, ush); } // Wait for IRQ that says the data is ready //schedule(); // ??? // Read actual size size = (((int)C.inb(ATA_ADDRESS3)) >> 8) | (int)(C.inb(ATA_ADDRESS2)); /* This code only supports the case where the data transfer * of one sector is done in one step. */ // WHAT DA HELL IS ASSERT //ASSERT (size == ATAPI_SECTOR_SIZE); // Read data // inw((ushort)ATA_DATA, (ushort*)buffer, (ushort)(size / 2)); /* The controller will send another IRQ even though we've read all * the data we want. Wait for it -- so it doesn't interfere with * subsequent operations: */ //////////////////////////////////////////////////////////////// // schedule(); // HAS SOMETHING TO DO WITH IRQ.. xD //////////// //////////////////////////////////////////////////////////////// /* Wait for BSY and DRQ to clear, indicating Command Finished */ // while ((status = inb (ATA_COMMAND (bus))) & 0x88) while (((status = C.inb(ATA_COMMAND)) & 0x88) == 0) { ; } cleanup: /* Exit the ATA subsystem */ // ata_release(); // ATA RELEASE? WTF!! return(size); }