toaruos/kernel/devices/mbr.c
Kevin Lange 2eb953f1f1 Massive fixes to the EXT2 driver.
* Works with different block sizes
* Works with different inode sizes
* Tested on a real EXT2 file system made with mkfs.ext2

* MBR reading is available
* You can specify a partition with hdd=0 or hdd=1 etc.

* If you make a "real" disk image, you can get GRUB installed in
  its MBR, toss in a suitable config file, and boot right off the
  disk rather than having to use QEMU to boot the kernel or using
  some silly CDROM ramdisk nonsense.
2012-09-29 00:39:01 -07:00

30 lines
626 B
C

#include <system.h>
#include <logging.h>
#include <ata.h>
#define SECTORSIZE 512
#define DISK_PORT 0x1F0
mbr_t mbr;
int read_partition_map(int device) {
ide_read_sector(DISK_PORT, 0, 0, (uint8_t *)&mbr);
if (mbr.signature[0] == 0x55 && mbr.signature[1] == 0xAA) {
debug_print(INFO, "Partition table found.");
for (int i = 0; i < 4; ++i) {
if (mbr.partitions[i].status & 0x80) {
debug_print(NOTICE, "Partition #%d: @%d+%d", i+1, mbr.partitions[i].lba_first_sector, mbr.partitions[i].sector_count);
} else {
debug_print(NOTICE, "Partition #%d: inactive", i+1);
}
}
return 0;
}
return 1;
}