Hello, This is my first patch for GRUB, and I haven't found any coding styles/formatting, nor developer documentation, so, if there's something wrong, please, forgive me and point me to the right direction.
Current implementation of the chainloading code does not work, cause it reads the partition table from the first sector of the root device, and the root device does not contain partition information. I've changed the way partition table are loaded, keeping a copy of the partition entry in grub_partition_t structs data field, and just loading this information in the correct address when chainloading. I've also changed the logical partitions start address to point to the actual disk sector, instead of pointing to the sector relative to the beginning of the extended partition, so we can now boot into logical partitions (for example, syslinux doesn't boot if the partition table doesn't map to the correct disk sector). Any comments are appreciated. -- Lucas
diff -ru grub2.org/include/grub/pc_partition.h grub2/include/grub/pc_partition.h --- grub2.org/include/grub/pc_partition.h 2007-07-21 20:32:22.000000000 -0300 +++ grub2/include/grub/pc_partition.h 2008-06-29 22:13:38.000000000 -0300 @@ -182,6 +182,9 @@ /* The offset of the extended partition. */ unsigned long ext_offset; + + /* Partition entry. */ + struct grub_pc_partition_entry e; }; static inline int diff -ru grub2.org/loader/i386/pc/chainloader.c grub2/loader/i386/pc/chainloader.c --- grub2.org/loader/i386/pc/chainloader.c 2007-09-03 17:10:19.000000000 -0300 +++ grub2/loader/i386/pc/chainloader.c 2008-06-29 22:50:50.000000000 -0300 @@ -31,6 +31,7 @@ #include <grub/machine/memory.h> #include <grub/rescue.h> #include <grub/dl.h> +#include <grub/pc_partition.h> static grub_dl_t my_mod; static int boot_drive; @@ -103,10 +104,11 @@ if (p) { - grub_disk_read (disk, p->offset, 446, 64, - (char *) GRUB_MEMORY_MACHINE_PART_TABLE_ADDR); - part_addr = (void *) (GRUB_MEMORY_MACHINE_PART_TABLE_ADDR - + (p->index << 4)); + struct grub_pc_partition *pcdata = p->data; + grub_memcpy((void *) GRUB_MEMORY_MACHINE_PART_TABLE_ADDR, + (void *) &pcdata->e, + sizeof(struct grub_pc_partition_entry)); + part_addr = (void *) (GRUB_MEMORY_MACHINE_PART_TABLE_ADDR); } } diff -ru grub2.org/partmap/pc.c grub2/partmap/pc.c --- grub2.org/partmap/pc.c 2007-07-21 20:32:30.000000000 -0300 +++ grub2/partmap/pc.c 2008-06-29 22:55:50.000000000 -0300 @@ -135,6 +135,8 @@ pcdata.bsd_part = -1; pcdata.dos_type = e->type; pcdata.bsd_type = -1; + grub_memcpy(&pcdata.e, e, sizeof(struct grub_pc_partition_entry)); + pcdata.e.start = grub_cpu_to_le32(p.offset + grub_le_to_cpu32 (e->start)); grub_dprintf ("partition", "partition %d: flag 0x%x, type 0x%x, start 0x%llx, len 0x%llx\n",
_______________________________________________ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel