Skip to contentSkip to conversation

Some minor powerpc fixes, addons

PATCH In review Marcin Kurek 2 participants 2 messages Oct 15, 2007 – Oct 16, 2007 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Some minor powerpc fixes, addons

Hell[o]

Attached rest of my grub changes.

affs: As mentioned on grub_ofdisk_open() the total_sectors value is hosed on ieee1275 then we can not use it here. Anyway the code is still a bit broken :( I will try to fix it in a free time in future.

Read: Fixed grub_ofdisk_read() for old versions of OF and fixed a read error check. Not tested, but should be fine I hope.

ofboot: Added ofboot commands to boot using interface from firmware. This allows us to boot MorphOS for example. As a addon I introduced a command to execute a forth script before real boot which can be used for example on efika to execute a device-tree fixup before boot linux.

A small example:

menuentry "MorphOS (Normal)" {
ofboot $mos_img $mos_3d ramdebug logserver
}

menuentry "Gentoo (2.6.22-gentoo-r8)" {
        set       root=(ide0,11)
        ofrun    efika.forth
        linux     /vmlinuz-2.6.22-gentoo-r8 video=radeonfb root=/dev/sda7
        initrd    /initrd-2.6.22-gentoo-r8.img
}
Signature · 1 line
--- Marcin 'Morgoth' Kurek ---
fs/affs.c +14 -9
diff -urN grub2.org/fs/affs.c grub2/fs/affs.c
@@ -25,6 +25,7 @@
 #include <grub/dl.h>
 #include <grub/types.h>
 #include <grub/fshelp.h>
+#include <grub/partition.h>
 
 /* The affs bootblock.  */
 struct grub_affs_bblock
@@ -97,6 +98,9 @@
   struct grub_fshelp_node diropen;
   grub_disk_t disk;
 
+  /* Size in sectors */
+  grub_uint64_t len;
+
   /* Blocksize in sectors.  */
   int blocksize;
 
@@ -170,10 +174,17 @@
   int checksumr = 0;
   int blocksize = 0;
 
+
   data = grub_malloc (sizeof (struct grub_affs_data));
   if (!data)
     return 0;
 
+  /* total_sectors are not valid on ieee1275 */
+  if(disk->partition)
+    data->len = grub_partition_get_len (disk->partition);
+  else
+    data->len = disk->total_sectors;
+
   /* Read the bootblock.  */
   grub_disk_read (disk, 0, 0, sizeof (struct grub_affs_bblock),
 		  (char *) &data->bblock);
@@ -194,12 +205,6 @@
       goto fail;
     }
 
-  /* Read the bootblock.  */
-  grub_disk_read (disk, 0, 0, sizeof (struct grub_affs_bblock),
-		  (char *) &data->bblock);
-  if (grub_errno)
-    goto fail;
-
   /* No sane person uses more than 8KB for a block.  At least I hope
      for that person because in that case this won't work.  */
   rootblock = grub_malloc (GRUB_DISK_SECTOR_SIZE * 16);
@@ -209,7 +214,7 @@
   rblock = (struct grub_affs_rblock *) rootblock;
 
   /* Read the rootblock.  */
-  grub_disk_read (disk, (disk->total_sectors >> 1) + blocksize, 0,
+  grub_disk_read (disk, (data->len >> 1) + blocksize, 0,
 		  GRUB_DISK_SECTOR_SIZE * 16, (char *) rootblock);
   if (grub_errno)
     goto fail;
@@ -241,7 +246,7 @@
   data->disk = disk;
   data->htsize = grub_be_to_cpu32 (rblock->htsize);
   data->diropen.data = data;
-  data->diropen.block = (disk->total_sectors >> 1);
+  data->diropen.block = (data->len >> 1);
 
   grub_free (rootblock);
 
@@ -522,7 +527,7 @@
     {
       /* The rootblock maps quite well on a file header block, it's
 	 something we can use here.  */
-      grub_disk_read (data->disk, disk->total_sectors >> 1,
+      grub_disk_read (data->disk, data->len >> 1,
 		      data->blocksize * (GRUB_DISK_SECTOR_SIZE
 					 - GRUB_AFFS_FILE_LOCATION),
 		      sizeof (file), (char *) &file);
disk/ieee1275/ofdisk.c +4 -3
diff -urN grub2.org/disk/ieee1275/ofdisk.c grub2/disk/ieee1275/ofdisk.c
@@ -124,7 +124,7 @@
 grub_ofdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
 		  grub_size_t size, char *buf)
 {
-  grub_ssize_t status, actual;
+  grub_ssize_t status = 0, actual = 0;
   unsigned long long pos;
 
   grub_dprintf ("disk",
@@ -139,9 +139,10 @@
     return grub_error (GRUB_ERR_READ_ERROR,
 		       "Seek error, can't seek block %llu",
 		       sector);
+  size *= 512UL;
   grub_ieee1275_read ((grub_ieee1275_ihandle_t) disk->data, buf,
-		      size * 512UL, &actual);
-  if (actual != actual)
+		      size, &actual);
+  if (actual != size)
     return grub_error (GRUB_ERR_READ_ERROR, "Read error on block: %llu",
 		       sector);
     
conf/powerpc-ieee1275.rmk +12 -0
diff -urN grub2.org/conf/powerpc-ieee1275.rmk grub2/conf/powerpc-ieee1275.rmk
@@ -101,6 +101,8 @@
 
 # Modules.
 pkgdata_MODULES = halt.mod \
+	_ofboot.mod \
+	ofboot.mod \
 	_linux.mod \
 	linux.mod \
 	normal.mod \
@@ -109,6 +111,16 @@
         _multiboot.mod \
         multiboot.mod
 
+# For _ofboot.mod.
+_ofboot_mod_SOURCES = loader/powerpc/ieee1275/ofboot.c
+_ofboot_mod_CFLAGS = $(COMMON_CFLAGS)
+_ofboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
+# For ofboot.mod.
+ofboot_mod_SOURCES = loader/powerpc/ieee1275/ofboot_normal.c
+ofboot_mod_CFLAGS = $(COMMON_CFLAGS)
+ofboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
 # For _linux.mod.
 _linux_mod_SOURCES = loader/powerpc/ieee1275/linux.c
 _linux_mod_CFLAGS = $(COMMON_CFLAGS)
include/grub/powerpc/ieee1275/loader.h +6 -0
diff -urN grub2.org/include/grub/powerpc/ieee1275/loader.h grub2/include/grub/powerpc/ieee1275/loader.h
@@ -23,10 +23,16 @@
    loader.  */
 void grub_rescue_cmd_linux (int argc, char *argv[]);
 void grub_rescue_cmd_initrd (int argc, char *argv[]);
+void grub_rescue_cmd_ofboot (int argc, char *argv[]);
+void grub_rescue_cmd_ofrun (int argc, char *argv[]);
 
 void grub_linux_init (void);
 void grub_linux_fini (void);
+void grub_ofboot_init (void);
+void grub_ofboot_fini (void);
 void grub_linux_normal_init (void);
 void grub_linux_normal_fini (void);
+void grub_ofboot_normal_init (void);
+void grub_ofboot_normal_fini (void);
 
 #endif /* ! GRUB_LOADER_MACHINE_HEADER */
loader/powerpc/ieee1275/ofboot.c +140 -0

140 lines not on this page · raw message

loader/powerpc/ieee1275/ofboot_normal.c +60 -0

60 lines not on this page · raw message

#1 lore raw

"Marcin Kurek" <[email protected]> writes:

Hi,

Quoted 1 line

Attached rest of my grub changes.

Great! I will review them soon. Can you send in ChangeLog entries? That will make reviewing easier for me. Besides that, we need them before committing.

Thanks,
Marco