]> git.ozlabs.org Git - yaboot.git/commitdiff
amiga partition table support.
authorEthan Benson <erbenson@alaska.net>
Fri, 20 May 2005 03:10:03 +0000 (03:10 +0000)
committerEthan Benson <erbenson@alaska.net>
Fri, 20 May 2005 03:10:03 +0000 (03:10 +0000)
* Support for amiga partition tables.  (Sven Luther)
git-archimport-id: erbenson@alaska.net--public/yaboot--devel--1.3--patch-80

0arch-timestamps0
ChangeLog
include/amiga-part.h [new file with mode: 0644]
second/partition.c

index b264f19aae1f3d3650bb23114e9b863128b90805..3cb519f9d3dc10fcab6ae1188aeacb1fd43979dd 100644 (file)
@@ -1,7 +1,7 @@
-./0arch-timestamps0    1109049412      1116476790
+./0arch-timestamps0    1116476796      1116558595
 ./BUGS 1109049412      1000991730
 ./COPYING      1109049412      1000991730
-./ChangeLog    1116476729      1116476779
+./ChangeLog    1116558534      1116558571
 ./Config       1109049412      1002101497
 ./INSTALL      1109049412      1000991730
 ./Makefile     1109049412      1089576723
 ./doc/examples/simpleboot.chrp 1109049412      1068017750
 ./doc/examples/yaboot.conf.multi-boot  1109049412      1006348765
 ./doc/examples/yaboot.conf.rs6000      1109049412      1006348765
-./doc/examples 1116476789      1068017750
+./doc/examples 1116558575      1068017750
 ./doc/yaboot-howto.de.sgml     1109049413      1096186109
 ./doc/yaboot-howto.sgml        1109049413      1096186082
-./doc  1116476789      1096186109
+./doc  1116558575      1096186109
 ./etc/yaboot.conf      1109049413      1006348765
-./etc  1116476789      1007269243
+./etc  1116558575      1007269243
 ./first/ofboot 1109049413      1065311880
-./first        1116476789      1071492158
+./first        1116558575      1071492158
 ./include/asm/elf.h    1109049413      1000991730
 ./include/asm/ppc_asm.tmpl     1109049413      1000991730
 ./include/asm/processor.h      1109049413      1000991730
-./include/asm  1116476789      1007269243
+./include/asm  1116558575      1007269243
 ./include/bootinfo.h   1109049413      1007200690
 ./include/byteorder.h  1109049413      1000991730
 ./include/cfg.h        1109049413      1007200690
 ./include/debug.h      1109049413      1007200690
 ./include/errors.h     1109049413      1007200690
 ./include/et/com_err.h 1109049413      1000991731
-./include/et   1116476790      1007269243
+./include/et   1116558575      1007269243
 ./include/ext2fs/bitops.h      1109049413      1003927524
 ./include/ext2fs/ext2_err.h    1109049413      1003927524
 ./include/ext2fs/ext2_io.h     1109049413      1003927524
 ./include/ext2fs/ext2fs.h      1109049413      1003927524
-./include/ext2fs       1116476790      1007269243
+./include/ext2fs       1116558575      1007269243
 ./include/fdisk-part.h 1109049413      1007200690
 ./include/file.h       1109049413      1007200690
 ./include/fs.h 1109049413      1007200690
 ./include/linux/iso_fs.h       1109049413      1000991731
 ./include/linux/stat.h 1109049413      1000991731
 ./include/linux/types.h        1109049413      1000991731
-./include/linux        1116476790      1007269243
+./include/linux        1116558575      1007269243
 ./include/mac-part.h   1109049413      1007200690
 ./include/md5.h        1109049413      1000991730
 ./include/partition.h  1109049413      1007200690
 ./include/prom.h       1109049413      1007200690
 ./include/reiserfs/reiserfs.h  1109049413      1025684115
-./include/reiserfs     1116476790      1025684115
+./include/reiserfs     1116558575      1025684115
 ./include/setjm2.h     1109049413      1000991730
 ./include/setjmp.h     1109049413      1000991730
 ./include/stdlib.h     1109049413      1000991730
 ./include/swab.h       1109049413      1000991730
 ./include/types.h      1109049413      1000991730
 ./include/xfs/xfs.h    1109049413      1002101334
-./include/xfs  1116476790      1007269244
+./include/xfs  1116558575      1007269244
 ./include/yaboot.h     1109049413      1007200690
-./include      1116476789      1007269244
+./include/amiga-part.h 1116558586      1116558522
+./include      1116558575      1116558522
 ./lib/ctype.c  1109049413      1000991731
 ./lib/libext2fs.a      1109049413      1003927524
 ./lib/malloc.c 1109049413      1007200690
@@ -80,8 +81,8 @@
 ./lib/string.S 1109049413      1007200690
 ./lib/strtol.c 1109049413      1000991731
 ./lib/vsprintf.c       1109049413      1000991731
-./lib/strstr.c 1116476589      1116476589
-./lib  1116476790      1116476589
+./lib/strstr.c 1116476796      1116476589
+./lib  1116558575      1116476589
 ./man/bootstrap.8      1109049413      1000991731
 ./man/mkofboot.8       1109049413      1006348765
 ./man/ofpath.8 1109049413      1000991731
@@ -89,7 +90,7 @@
 ./man/yabootconfig.8   1109049413      1027929577
 ./man/ybin.8   1109049413      1006348765
 ./man/yaboot.8 1116476644      1090699543
-./man  1116476680      1116476667
+./man  1116558575      1116476667
 ./man.patch    1109049413      1006348761
 ./second/cache.S       1109049413      1007200690
 ./second/cfg.c 1109049413      1007200690
 ./second/fs_xfs.c      1109049413      1032059541
 ./second/iso_util.c    1109049413      1003656415
 ./second/md5.c 1109049413      1032059532
-./second/partition.c   1109049413      1032059525
 ./second/prom.c        1109049413      1067937197
 ./second/setjmp.S      1109049413      1000991732
 ./second/yaboot.c      1113696387      1032059504
-./second       1116476790      1089575693
+./second/partition.c   1116558522      1116558522
+./second       1116558575      1116558522
 ./util/elfextract.c    1109049413      1007303237
 ./util/addnote.c       1109049413      1107321884
-./util 1116476790      1107321884
-./ybin/mkofboot        1116476790      1073219938
+./util 1116558575      1107321884
+./ybin/mkofboot        1116558575      1073219938
 ./ybin/ofpath  1109049414      1089576762
 ./ybin/ybin    1109049414      1089576732
 ./ybin/yabootconfig    1109049414      1089576743
-./ybin 1116476790      1089576762
-.      1116476789      1116476779
+./ybin 1116558575      1089576762
+.      1116558575      1116558571
index 97531ddc1dbde6db29f71ca3039acc971ac00d52..aab19558240a977f66d333259530d9ce5b470091 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,22 @@
 # arch-tag: automatic-ChangeLog--erbenson@alaska.net--public/yaboot--devel--1.3
 #
 
+2005-05-20 03:10:03 GMT        Ethan Benson <erbenson@alaska.net>      patch-80
+
+    Summary:
+      amiga partition table support.
+    Revision:
+      yaboot--devel--1.3--patch-80
+
+    * Support for amiga partition tables.  (Sven Luther)
+
+    new files:
+     include/.arch-ids/amiga-part.h.id include/amiga-part.h
+
+    modified files:
+     0arch-timestamps0 ChangeLog second/partition.c
+
+
 2005-05-19 04:26:37 GMT        Ethan Benson <erbenson@alaska.net>      patch-79
 
     Summary:
diff --git a/include/amiga-part.h b/include/amiga-part.h
new file mode 100644 (file)
index 0000000..ad9a139
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ *  amiga-part.h - Structure of amiga partition table
+ *
+ *  Copyright (C) 2004 Sven Luther <luther@debian.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#define AMIGA_RDB_MAX  16
+#define AMIGA_ID_RDB   0x5244534B      /* 'RDSK' */
+#define AMIGA_ID_PART  0x50415254      /* 'PART' */
+#define AMIGA_END      0xffffffff
+
+#define AMIGA_ID               0
+#define AMIGA_LENGTH           1
+#define AMIGA_PARTITIONS       7
+#define AMIGA_CYL              16
+#define AMIGA_SECT             17
+#define AMIGA_HEADS            18
+#define AMIGA_RDBLIMIT         33
+
+
+#define AMIGA_PART_NEXT                4
+#define AMIGA_PART_FLAGS       8
+#define AMIGA_PART_LOWCYL      41
+#define AMIGA_PART_HIGHCYL     42
+#define AMIGA_PART_DOSTYPE     48
+
+#define        AMIGA_PART_BOOTABLE     0x1
+#define        AMIGA_PART_NOMOUNT      0x2
index c8663497927b04dc851a190fb5c3ae518be0a3b9..e3ab4c58855d7adfbfc48fe17366dc063fbe667f 100644 (file)
@@ -1,6 +1,8 @@
 /*
  *  partition.c - partition table support
  *
+ *  Copyright (C) 2004 Sven Luther
+ *
  *  Copyright (C) 2001, 2002 Ethan Benson
  *
  *  Copyright (C) 1999 Benjamin Herrenschmidt
@@ -31,6 +33,7 @@
 #include "stdlib.h"
 #include "mac-part.h"
 #include "fdisk-part.h"
+#include "amiga-part.h"
 #include "partition.h"
 #include "prom.h"
 #include "string.h"
@@ -213,6 +216,110 @@ identify_iso_fs(ihandle device, unsigned int *iso_root_block)
      return 0;
 }
 
+/* 
+ * Detects and read amiga partition tables.
+ */
+
+static int
+_amiga_checksum (unsigned int blk_size)
+{
+       unsigned int sum;
+       int i, end;
+       unsigned int *amiga_block = (unsigned int *) block_buffer;
+
+       sum = amiga_block[0];
+       end = amiga_block[AMIGA_LENGTH];
+
+       if (end > blk_size) end = blk_size;
+
+       for (i = 1; i < end; i++) sum += amiga_block[i];
+
+       return sum;
+}
+
+static int
+_amiga_find_rdb (const char *dev_name, prom_handle disk, unsigned int prom_blksize)
+{
+       int i;
+       unsigned int *amiga_block = (unsigned int *) block_buffer;
+
+       for (i = 0; i<AMIGA_RDB_MAX; i++) {
+               if (i != 0) {
+                       if (prom_readblocks(disk, i, 1, block_buffer) != 1) {
+                               prom_printf("Can't read boot block %d\n", i);
+                               break;
+                       }       
+               }
+               if ((amiga_block[AMIGA_ID] == AMIGA_ID_RDB) && (_amiga_checksum (prom_blksize) == 0))
+                       return 1;
+       }
+       /* Amiga partition table not found, let's reread block 0 */
+       if (prom_readblocks(disk, 0, 1, block_buffer) != 1) {
+               prom_printf("Can't read boot blocks\n");
+               return 0; /* TODO: something bad happened, should fail more verbosely */
+       }       
+       return 0;
+}
+
+static void
+partition_amiga_lookup( const char *dev_name, prom_handle disk,
+                        unsigned int prom_blksize, struct partition_t** list )
+{
+       int partition, part;
+       unsigned int blockspercyl;
+       unsigned int *amiga_block = (unsigned int *) block_buffer;
+       unsigned int *used = NULL;
+       unsigned int possible;
+       int checksum;
+       int i;
+
+       blockspercyl = amiga_block[AMIGA_SECT] * amiga_block[AMIGA_HEADS];
+       possible = amiga_block[AMIGA_RDBLIMIT]/32 +1;
+
+       used = (unsigned int *) malloc (sizeof (unsigned int) * (possible + 1));
+
+       for (i=0; i < possible; i++) used[i] = 0;
+
+
+       for (part = amiga_block[AMIGA_PARTITIONS], partition = 0;
+               part != AMIGA_END;
+               part = amiga_block[AMIGA_PART_NEXT], partition++)
+       {
+               if (prom_readblocks(disk, part, 1, block_buffer) != 1) {
+                       prom_printf("Can't read partition block %d\n", part);
+                       break;
+               }       
+               checksum = _amiga_checksum (prom_blksize);
+               if ((amiga_block[AMIGA_ID] == AMIGA_ID_PART) &&
+                       (checksum == 0) &&
+                       ((used[part/32] & (0x1 << (part % 32))) == 0))
+               {
+                       used[part/32] |= (0x1 << (part % 32));
+               } else {
+                       prom_printf("Amiga partition table corrupted at block %d\n", part);
+                       if (amiga_block[AMIGA_ID] != AMIGA_ID_PART)
+                               prom_printf ("block type is not partition but %08x\n", amiga_block[AMIGA_ID]);
+                       if (checksum != 0)
+                               prom_printf ("block checsum is bad : %d\n", checksum);
+                       if ((used[part/32] & (0x1 << (part % 32))) != 0)
+                               prom_printf ("partition table is looping, block %d already traveled\n", part);
+                       break;
+               }
+
+              /* We use the partition block size from the partition table.
+               * The filesystem implmentations are responsible for mapping
+               * to their own fs blocksize */
+              add_new_partition(
+                   list, /* partition list */
+                   partition, /* partition number */
+                   "Linux", /* type */
+                   '\0', /* name */
+                   blockspercyl * amiga_block[AMIGA_PART_LOWCYL], /* start */
+                   blockspercyl * (amiga_block[AMIGA_PART_HIGHCYL] - amiga_block[AMIGA_PART_LOWCYL] + 1), /* size */
+                   prom_blksize );
+       }
+}
+
 struct partition_t*
 partitions_lookup(const char *device)
 {
@@ -260,6 +367,9 @@ partitions_lookup(const char *device)
                            0,
                            prom_blksize);
          prom_printf("ISO9660 disk\n");
+     } else if (_amiga_find_rdb(device, disk, prom_blksize) != -1) {
+         /* amiga partition format */
+         partition_amiga_lookup(device, disk, prom_blksize, &list);
      } else {
          prom_printf("No supported partition table detected\n");
          goto bail;