RDB partition tables in AROS
Hello,
I'm participating in the AROS project which is an Amiga like system but on PC (some other machines also).
To allow AROS be installed beside Linux and others, we needed to embed the RDB tables into the PC MBR, and this is the only way for AROS to boot from a PC BIOS.
I've made some changes to GRUB2 to allow this. Can I have access to your source code repository ?
Thanks,
Alain Greppin
Alain Greppin <[email protected]> writes:
Hi,
Quoted 9 lines
I'm participating in the AROS project which is an Amiga like system but on PC (some other machines also).
To allow AROS be installed beside Linux and others, we needed to embed the RDB tables into the PC MBR, and this is the only way for AROS to boot from a PC BIOS.
I've made some changes to GRUB2 to allow this. Can I have access to your source code repository ?
Please send in a patch(+ChangeLog entry). How can we accept a patch of which we do not know if it is good enough?
--
Marco
Hello,
Here is a diff againt our svn repository. We have grub2 version 1.96 here.
The changes log:
- recognize RDB partion tables inside MBR, this is needed for AROS to boot on a PC
- fix AFFS filesystem for AROS
- minor bug fix in SFS: count of nodes in extent-btree is written as big endian on disk
- fixed gensymlist.sh to let us build with a compiler command having arguments
Regards,
Alain Greppin
affs.c (working copy) renamed from affs.c (revision 27991) +0 -0
@@ -25,6 +25,9 @@
#include <grub/dl.h>
#include <grub/types.h>
#include <grub/fshelp.h>
+#ifdef __AROS__
+#include <grub/partition.h>
+#endif
/* The affs bootblock. */
struct grub_affs_bblock
@@ -209,8 +212,22 @@
rblock = (struct grub_affs_rblock *) rootblock;
/* Read the rootblock. */
+#ifdef __AROS__
+ grub_uint64_t reservedblocks = 2; + grub_uint64_t countblocks; + if (disk->partition)
+ countblocks = disk->partition->len;
+ else
+ countblocks = disk->total_sectors;
+
+ grub_disk_addr_t rblknum = (countblocks - 1 + reservedblocks) / 2; +
+ grub_disk_read (disk, rblknum, 0,
+ GRUB_DISK_SECTOR_SIZE * 16, (char *) rootblock);
+#else
grub_disk_read (disk, (disk->total_sectors >> 1) + blocksize, 0,
GRUB_DISK_SECTOR_SIZE * 16, (char *) rootblock);
+#endif
if (grub_errno)
goto fail;@@ -241,7 +258,11 @@
data->disk = disk;
data->htsize = grub_be_to_cpu32 (rblock->htsize); data->diropen.data = data;
+#ifdef __AROS__
+ data->diropen.block = rblknum;
+#else
data->diropen.block = (disk->total_sectors >> 1);
+#endif
grub_free (rootblock);
sfs.c (working copy) renamed from sfs.c (revision 27991) +2 -1
@@ -172,7 +172,8 @@ return grub_errno; } - for (i = 0; i < tree->nodes; i++) + grub_uint16_t nodescount = grub_be_to_cpu16(tree->nodes); + for (i = 0; i < nodescount; i++) {
#define EXTNODE(tree, index) \
@@ -189,7 +190,7 @@
/* In case the last node is reached just use that one, it is
the right match. */
- if (i + 1 == tree->nodes && !tree->leaf)
+ if (i + 1 == nodescount && !tree->leaf)
{
next = grub_be_to_cpu32 (EXTNODE (tree, i)->data);
break;gensymlist.sh.in (working copy) renamed from gensymlist.sh.in (revision 27991) +0 -0
@@ -14,7 +14,7 @@
### The configure script will replace these variables.
srcdir=@srcdir@
-CC=@CC@
+CC="@CC@"
cat <<EOF
grub/pc_partition.h (working copy) renamed from grub/pc_partition.h (revision 27991) +0 -0
@@ -206,4 +206,10 @@ || type == GRUB_PC_PARTITION_TYPE_NETBSD);
}
+static inline int
+grub_pc_partition_is_rdb(int type)
+{
+ return (type == 0x30);
+}
+
#endif /* ! GRUB_PC_PARTITION_HEADER */
amiga.c (working copy) renamed from amiga.c (revision 27991) +3 -0
@@ -87,7 +87,10 @@ /* Enforce raw disk access. */ raw = *disk; +#ifndef __AROS__ raw.partition = 0; +#endif + part.data = NULL; /* The RDSK block is one of the first 15 blocks. */ for (pos = 0; pos < 15; pos++)
@@ -210,7 +213,13 @@
GRUB_MOD_INIT(amiga_partition_map)
{
+#ifdef __AROS__
+ extern struct grub_partition_map *grub_rdb_partition_map;
+ grub_rdb_partition_map = &grub_amiga_partition_map; +#endif
+
grub_partition_map_register (&grub_amiga_partition_map);
+
#ifndef GRUB_UTIL
my_mod = mod;
#endif
pc.c (working copy) renamed from pc.c (revision 27991) +0 -0
@@ -24,6 +24,9 @@
#include <grub/misc.h>
#include <grub/dl.h>
+/* RDB partition tables for AROS */
+struct grub_partition_map *grub_rdb_partition_map = NULL; +
static struct grub_partition_map grub_pc_partition_map;
#ifndef GRUB_UTIL
@@ -149,8 +152,42 @@
&& ! grub_pc_partition_is_extended (e->type))
{
pcdata.dos_part++;-
- if (hook (disk, &p))
+
+ /* Check if this is a RDB partition table. */
+ if (grub_rdb_partition_map &&grub_pc_partition_is_rdb(e->type))
+ {
+ struct grub_partition p2; + struct grub_disk raw2; + int ok = 0;
+
+ auto int rdb_hook(grub_disk_t disk, constgrub_partition_t p);
+
+ int rdb_hook(grub_disk_t disk __attribute__((unused)),
+ const grub_partition_t part)
+ {
+ p2 = *part;
+ pcdata.bsd_part = part->index;
+
+ p2.start += p.start; + p2.offset += p.offset; + p2.data = &pcdata; + p2.partmap = &grub_pc_partition_map;
+
+ grub_dprintf("partition", "RDB part %c start=%ld\n",
+ (char)('a' + part->index),
(long)p2.start);
+
+ ok = hook(disk, &p2);
+ return ok;
+ }
+
+ raw2 = raw;
+ raw2.partition = &p;
+
+ grub_rdb_partition_map->iterate(&raw2, rdb_hook);
+ if (ok)
+ goto finish;
+ }
+ else if (hook (disk, &p))
goto finish;
/* Check if this is a BSD partition. */pc.c (working copy) line 25
Quoted 7 lines · Alain Greppin
Index:
partmap/pc.c
===================================================================pc.c (working copy) renamed from pc.c (revision 27991) +0
-0@@ -24,6 +24,9 @@ #include <grub/misc.h> #include <grub/dl.h>
I think it's a bad idea to increase pc.mod code size this way. This module is usually part of the "stage1" step, where size is already quite constrained.
Quoted 63 lines
pc.c (working copy) renamed from pc.c (revision 27991) +39
-2+/* RDB partition tables for AROS */ +struct grub_partition_map *grub_rdb_partition_map = NULL; + static struct grub_partition_map grub_pc_partition_map; #ifndef GRUB_UTIL@@ -149,8 +152,42 @@ && ! grub_pc_partition_is_extended (e->type)) { pcdata.dos_part++; - - if (hook (disk, &p)) + + /* Check if this is a RDB partition table. */ + if (grub_rdb_partition_map && grub_pc_partition_is_rdb(e->type)) + { + struct grub_partition p2; + struct grub_disk raw2; + int ok = 0; + + auto int rdb_hook(grub_disk_t disk, const grub_partition_t p); + + int rdb_hook(grub_disk_t disk __attribute__((unused)), + const grub_partition_t part) + { + p2 = *part; + pcdata.bsd_part = part->index; + + p2.start += p.start; + p2.offset += p.offset; + p2.data = &pcdata; + p2.partmap = &grub_pc_partition_map; + + grub_dprintf("partition", "RDB part %c start=%ld\n", + (char)('a' + part->index), (long)p2.start); + + ok = hook(disk, &p2); + return ok; + } + + raw2 = raw; + raw2.partition = &p; + + grub_rdb_partition_map->iterate(&raw2, rdb_hook); + if (ok) + goto finish; + } + else if (hook (disk, &p))goto finish; /* Check if this is a BSD partition. */_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 5 lines
Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What use is a phone call… if you are unable to speak? (as seen on /.)