remove unported includes and drivers
This commit is contained in:
parent
d1efa13e44
commit
d323c2e1d2
|
@ -1,47 +0,0 @@
|
|||
#
|
||||
# (C) Copyright 2000-2006
|
||||
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
#
|
||||
# See file CREDITS for list of people who contributed to this
|
||||
# project.
|
||||
#
|
||||
# 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
|
||||
#
|
||||
|
||||
include $(TOPDIR)/config.mk
|
||||
|
||||
#CFLAGS += -DET_DEBUG -DDEBUG
|
||||
|
||||
LIB = $(obj)libdisk.a
|
||||
|
||||
COBJS = part.o part_mac.o part_dos.o part_iso.o part_amiga.o
|
||||
|
||||
SRCS := $(COBJS:.o=.c)
|
||||
OBJS := $(addprefix $(obj),$(COBJS))
|
||||
|
||||
all: $(LIB)
|
||||
|
||||
$(LIB): $(obj).depend $(OBJS)
|
||||
$(AR) $(ARFLAGS) $@ $(OBJS)
|
||||
|
||||
#########################################################################
|
||||
|
||||
# defines $(obj).depend target
|
||||
include $(SRCTREE)/rules.mk
|
||||
|
||||
sinclude $(obj).depend
|
||||
|
||||
#########################################################################
|
277
disk/part.c
277
disk/part.c
|
@ -1,277 +0,0 @@
|
|||
/*
|
||||
* (C) Copyright 2001
|
||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <command.h>
|
||||
#include <ide.h>
|
||||
|
||||
#undef PART_DEBUG
|
||||
|
||||
#ifdef PART_DEBUG
|
||||
#define PRINTF(fmt,args...) printf (fmt ,##args)
|
||||
#else
|
||||
#define PRINTF(fmt,args...)
|
||||
#endif
|
||||
|
||||
#if ((CONFIG_COMMANDS & CFG_CMD_IDE) || \
|
||||
(CONFIG_COMMANDS & CFG_CMD_SCSI) || \
|
||||
(CONFIG_COMMANDS & CFG_CMD_USB) || \
|
||||
defined(CONFIG_MMC) || \
|
||||
defined(CONFIG_SYSTEMACE) )
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/*
|
||||
* reports device info to the user
|
||||
*/
|
||||
void dev_print (block_dev_desc_t *dev_desc)
|
||||
{
|
||||
#ifdef CONFIG_LBA48
|
||||
uint64_t lba512; /* number of blocks if 512bytes block size */
|
||||
#else
|
||||
lbaint_t lba512;
|
||||
#endif
|
||||
|
||||
if (dev_desc->type==DEV_TYPE_UNKNOWN) {
|
||||
puts ("not available\n");
|
||||
return;
|
||||
}
|
||||
if (dev_desc->if_type==IF_TYPE_SCSI) {
|
||||
printf ("(%d:%d) ", dev_desc->target,dev_desc->lun);
|
||||
}
|
||||
if (dev_desc->if_type==IF_TYPE_IDE) {
|
||||
printf ("Model: %s Firm: %s Ser#: %s\n",
|
||||
dev_desc->vendor,
|
||||
dev_desc->revision,
|
||||
dev_desc->product);
|
||||
} else {
|
||||
printf ("Vendor: %s Prod.: %s Rev: %s\n",
|
||||
dev_desc->vendor,
|
||||
dev_desc->product,
|
||||
dev_desc->revision);
|
||||
}
|
||||
puts (" Type: ");
|
||||
if (dev_desc->removable)
|
||||
puts ("Removable ");
|
||||
switch (dev_desc->type & 0x1F) {
|
||||
case DEV_TYPE_HARDDISK: puts ("Hard Disk");
|
||||
break;
|
||||
case DEV_TYPE_CDROM: puts ("CD ROM");
|
||||
break;
|
||||
case DEV_TYPE_OPDISK: puts ("Optical Device");
|
||||
break;
|
||||
case DEV_TYPE_TAPE: puts ("Tape");
|
||||
break;
|
||||
default: printf ("# %02X #", dev_desc->type & 0x1F);
|
||||
break;
|
||||
}
|
||||
puts ("\n");
|
||||
if ((dev_desc->lba * dev_desc->blksz)>0L) {
|
||||
ulong mb, mb_quot, mb_rem, gb, gb_quot, gb_rem;
|
||||
lbaint_t lba;
|
||||
|
||||
lba = dev_desc->lba;
|
||||
|
||||
lba512 = (lba * (dev_desc->blksz/512));
|
||||
mb = (10 * lba512) / 2048; /* 2048 = (1024 * 1024) / 512 MB */
|
||||
/* round to 1 digit */
|
||||
mb_quot = mb / 10;
|
||||
mb_rem = mb - (10 * mb_quot);
|
||||
|
||||
gb = mb / 1024;
|
||||
gb_quot = gb / 10;
|
||||
gb_rem = gb - (10 * gb_quot);
|
||||
#ifdef CONFIG_LBA48
|
||||
if (dev_desc->lba48)
|
||||
printf (" Supports 48-bit addressing\n");
|
||||
#endif
|
||||
#if defined(CFG_64BIT_LBA) && defined(CFG_64BIT_VSPRINTF)
|
||||
printf (" Capacity: %ld.%ld MB = %ld.%ld GB (%qd x %ld)\n",
|
||||
mb_quot, mb_rem,
|
||||
gb_quot, gb_rem,
|
||||
lba,
|
||||
dev_desc->blksz);
|
||||
#else
|
||||
printf (" Capacity: %ld.%ld MB = %ld.%ld GB (%ld x %ld)\n",
|
||||
mb_quot, mb_rem,
|
||||
gb_quot, gb_rem,
|
||||
(ulong)lba,
|
||||
dev_desc->blksz);
|
||||
#endif
|
||||
} else {
|
||||
puts (" Capacity: not available\n");
|
||||
}
|
||||
}
|
||||
#endif /* CFG_CMD_IDE || CFG_CMD_SCSI || CFG_CMD_USB || CONFIG_MMC */
|
||||
|
||||
#if ((CONFIG_COMMANDS & CFG_CMD_IDE) || \
|
||||
(CONFIG_COMMANDS & CFG_CMD_SCSI) || \
|
||||
(CONFIG_COMMANDS & CFG_CMD_USB) || \
|
||||
defined(CONFIG_SYSTEMACE) )
|
||||
|
||||
#if defined(CONFIG_MAC_PARTITION) || \
|
||||
defined(CONFIG_DOS_PARTITION) || \
|
||||
defined(CONFIG_ISO_PARTITION) || \
|
||||
defined(CONFIG_AMIGA_PARTITION)
|
||||
|
||||
void init_part (block_dev_desc_t * dev_desc)
|
||||
{
|
||||
#ifdef CONFIG_ISO_PARTITION
|
||||
if (test_part_iso(dev_desc) == 0) {
|
||||
dev_desc->part_type = PART_TYPE_ISO;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MAC_PARTITION
|
||||
if (test_part_mac(dev_desc) == 0) {
|
||||
dev_desc->part_type = PART_TYPE_MAC;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DOS_PARTITION
|
||||
if (test_part_dos(dev_desc) == 0) {
|
||||
dev_desc->part_type = PART_TYPE_DOS;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_AMIGA_PARTITION
|
||||
if (test_part_amiga(dev_desc) == 0) {
|
||||
dev_desc->part_type = PART_TYPE_AMIGA;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int get_partition_info (block_dev_desc_t *dev_desc, int part, disk_partition_t *info)
|
||||
{
|
||||
switch (dev_desc->part_type) {
|
||||
#ifdef CONFIG_MAC_PARTITION
|
||||
case PART_TYPE_MAC:
|
||||
if (get_partition_info_mac(dev_desc,part,info) == 0) {
|
||||
PRINTF ("## Valid MAC partition found ##\n");
|
||||
return (0);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DOS_PARTITION
|
||||
case PART_TYPE_DOS:
|
||||
if (get_partition_info_dos(dev_desc,part,info) == 0) {
|
||||
PRINTF ("## Valid DOS partition found ##\n");
|
||||
return (0);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ISO_PARTITION
|
||||
case PART_TYPE_ISO:
|
||||
if (get_partition_info_iso(dev_desc,part,info) == 0) {
|
||||
PRINTF ("## Valid ISO boot partition found ##\n");
|
||||
return (0);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_AMIGA_PARTITION
|
||||
case PART_TYPE_AMIGA:
|
||||
if (get_partition_info_amiga(dev_desc, part, info) == 0)
|
||||
{
|
||||
PRINTF ("## Valid Amiga partition found ##\n");
|
||||
return (0);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static void print_part_header (const char *type, block_dev_desc_t * dev_desc)
|
||||
{
|
||||
puts ("\nPartition Map for ");
|
||||
switch (dev_desc->if_type) {
|
||||
case IF_TYPE_IDE: puts ("IDE");
|
||||
break;
|
||||
case IF_TYPE_SCSI: puts ("SCSI");
|
||||
break;
|
||||
case IF_TYPE_ATAPI: puts ("ATAPI");
|
||||
break;
|
||||
case IF_TYPE_USB: puts ("USB");
|
||||
break;
|
||||
case IF_TYPE_DOC: puts ("DOC");
|
||||
break;
|
||||
default: puts ("UNKNOWN");
|
||||
break;
|
||||
}
|
||||
printf (" device %d -- Partition Type: %s\n\n",
|
||||
dev_desc->dev, type);
|
||||
}
|
||||
|
||||
void print_part (block_dev_desc_t * dev_desc)
|
||||
{
|
||||
|
||||
switch (dev_desc->part_type) {
|
||||
#ifdef CONFIG_MAC_PARTITION
|
||||
case PART_TYPE_MAC:
|
||||
PRINTF ("## Testing for valid MAC partition ##\n");
|
||||
print_part_header ("MAC", dev_desc);
|
||||
print_part_mac (dev_desc);
|
||||
return;
|
||||
#endif
|
||||
#ifdef CONFIG_DOS_PARTITION
|
||||
case PART_TYPE_DOS:
|
||||
PRINTF ("## Testing for valid DOS partition ##\n");
|
||||
print_part_header ("DOS", dev_desc);
|
||||
print_part_dos (dev_desc);
|
||||
return;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ISO_PARTITION
|
||||
case PART_TYPE_ISO:
|
||||
PRINTF ("## Testing for valid ISO Boot partition ##\n");
|
||||
print_part_header ("ISO", dev_desc);
|
||||
print_part_iso (dev_desc);
|
||||
return;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_AMIGA_PARTITION
|
||||
case PART_TYPE_AMIGA:
|
||||
PRINTF ("## Testing for a valid Amiga partition ##\n");
|
||||
print_part_header ("AMIGA", dev_desc);
|
||||
print_part_amiga (dev_desc);
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
puts ("## Unknown partition table\n");
|
||||
}
|
||||
|
||||
|
||||
#else /* neither MAC nor DOS nor ISO partition configured */
|
||||
# error neither CONFIG_MAC_PARTITION nor CONFIG_DOS_PARTITION nor CONFIG_ISO_PARTITION configured!
|
||||
#endif
|
||||
|
||||
#endif /* (CONFIG_COMMANDS & CFG_CMD_IDE) || CONFIG_COMMANDS & CFG_CMD_SCSI) */
|
|
@ -1,402 +0,0 @@
|
|||
/*
|
||||
* (C) Copyright 2001
|
||||
* Hans-Joerg Frieden, Hyperion Entertainment
|
||||
* Hans-JoergF@hyperion-entertainment.com
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
#include <common.h>
|
||||
#include <command.h>
|
||||
#include <ide.h>
|
||||
#include "part_amiga.h"
|
||||
|
||||
#if ((CONFIG_COMMANDS & CFG_CMD_IDE) || \
|
||||
(CONFIG_COMMANDS & CFG_CMD_SCSI) || \
|
||||
(CONFIG_COMMANDS & CFG_CMD_USB) || \
|
||||
defined(CONFIG_MMC) || \
|
||||
defined(CONFIG_SYSTEMACE) ) && defined(CONFIG_AMIGA_PARTITION)
|
||||
|
||||
#undef AMIGA_DEBUG
|
||||
|
||||
#ifdef AMIGA_DEBUG
|
||||
#define PRINTF(fmt, args...) printf(fmt ,##args)
|
||||
#else
|
||||
#define PRINTF(fmt, args...)
|
||||
#endif
|
||||
|
||||
struct block_header
|
||||
{
|
||||
u32 id;
|
||||
u32 summed_longs;
|
||||
s32 chk_sum;
|
||||
};
|
||||
|
||||
static unsigned char block_buffer[DEFAULT_SECTOR_SIZE];
|
||||
static struct rigid_disk_block rdb = {0};
|
||||
static struct bootcode_block bootcode = {0};
|
||||
|
||||
/*
|
||||
* Copy a bcpl to a c string
|
||||
*/
|
||||
static void bcpl_strcpy(char *to, char *from)
|
||||
{
|
||||
int len = *from++;
|
||||
|
||||
while (len)
|
||||
{
|
||||
*to++ = *from++;
|
||||
len--;
|
||||
}
|
||||
*to = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Print a BCPL String. BCPL strings start with a byte with the length
|
||||
* of the string, and don't contain a terminating nul character
|
||||
*/
|
||||
static void bstr_print(char *string)
|
||||
{
|
||||
int len = *string++;
|
||||
char buffer[256];
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (len)
|
||||
{
|
||||
buffer[i++] = *string++;
|
||||
len--;
|
||||
}
|
||||
|
||||
buffer[i] = 0;
|
||||
printf("%-10s", buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
* Sum a block. The checksum of a block must end up at zero
|
||||
* to be valid. The chk_sum field is selected so that adding
|
||||
* it yields zero.
|
||||
*/
|
||||
int sum_block(struct block_header *header)
|
||||
{
|
||||
s32 *block = (s32 *)header;
|
||||
u32 i;
|
||||
s32 sum = 0;
|
||||
|
||||
for (i = 0; i < header->summed_longs; i++)
|
||||
sum += *block++;
|
||||
|
||||
return (sum != 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Print an AmigaOS disk type. Disk types are a four-byte identifier
|
||||
* describing the file system. They are usually written as a three-letter
|
||||
* word followed by a backslash and a version number. For example,
|
||||
* DOS\0 would be the original file system. SFS\0 would be SmartFileSystem.
|
||||
* DOS\1 is FFS.
|
||||
*/
|
||||
static void print_disk_type(u32 disk_type)
|
||||
{
|
||||
char buffer[6];
|
||||
buffer[0] = (disk_type & 0xFF000000)>>24;
|
||||
buffer[1] = (disk_type & 0x00FF0000)>>16;
|
||||
buffer[2] = (disk_type & 0x0000FF00)>>8;
|
||||
buffer[3] = '\\';
|
||||
buffer[4] = (disk_type & 0x000000FF) + '0';
|
||||
buffer[5] = 0;
|
||||
printf("%s", buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
* Print the info contained within the given partition block
|
||||
*/
|
||||
static void print_part_info(struct partition_block *p)
|
||||
{
|
||||
struct amiga_part_geometry *g;
|
||||
|
||||
g = (struct amiga_part_geometry *)&(p->environment);
|
||||
|
||||
bstr_print(p->drive_name);
|
||||
printf("%6d\t%6d\t",
|
||||
g->low_cyl * g->block_per_track * g->surfaces ,
|
||||
(g->high_cyl - g->low_cyl + 1) * g->block_per_track * g->surfaces - 1);
|
||||
print_disk_type(g->dos_type);
|
||||
printf("\t%5d\n", g->boot_priority);
|
||||
}
|
||||
|
||||
/*
|
||||
* Search for the Rigid Disk Block. The rigid disk block is required
|
||||
* to be within the first 16 blocks of a drive, needs to have
|
||||
* the ID AMIGA_ID_RDISK ('RDSK') and needs to have a valid
|
||||
* sum-to-zero checksum
|
||||
*/
|
||||
struct rigid_disk_block *get_rdisk(block_dev_desc_t *dev_desc)
|
||||
{
|
||||
int i;
|
||||
int limit;
|
||||
char *s;
|
||||
|
||||
s = getenv("amiga_scanlimit");
|
||||
if (s)
|
||||
limit = atoi(s);
|
||||
else
|
||||
limit = AMIGA_BLOCK_LIMIT;
|
||||
|
||||
for (i=0; i<limit; i++)
|
||||
{
|
||||
ulong res = dev_desc->block_read(dev_desc->dev, i, 1,
|
||||
(ulong *)block_buffer);
|
||||
if (res == 1)
|
||||
{
|
||||
struct rigid_disk_block *trdb = (struct rigid_disk_block *)block_buffer;
|
||||
if (trdb->id == AMIGA_ID_RDISK)
|
||||
{
|
||||
PRINTF("Rigid disk block suspect at %d, checking checksum\n",i);
|
||||
if (sum_block((struct block_header *)block_buffer) == 0)
|
||||
{
|
||||
PRINTF("FOUND\n");
|
||||
memcpy(&rdb, trdb, sizeof(struct rigid_disk_block));
|
||||
return (struct rigid_disk_block *)&rdb;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
PRINTF("Done scanning, no RDB found\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Search for boot code
|
||||
* Again, the first boot block must be located somewhere in the first 16 blocks, or rooted in the
|
||||
* Ridgid disk block
|
||||
*/
|
||||
|
||||
struct bootcode_block *get_bootcode(block_dev_desc_t *dev_desc)
|
||||
{
|
||||
int i;
|
||||
int limit;
|
||||
char *s;
|
||||
|
||||
s = getenv("amiga_scanlimit");
|
||||
if (s)
|
||||
limit = atoi(s);
|
||||
else
|
||||
limit = AMIGA_BLOCK_LIMIT;
|
||||
|
||||
PRINTF("Scanning for BOOT from 0 to %d\n", limit);
|
||||
|
||||
for (i = 0; i < limit; i++)
|
||||
{
|
||||
ulong res = dev_desc->block_read(dev_desc->dev, i, 1, (ulong *)block_buffer);
|
||||
if (res == 1)
|
||||
{
|
||||
struct bootcode_block *boot = (struct bootcode_block *)block_buffer;
|
||||
if (boot->id == AMIGA_ID_BOOT)
|
||||
{
|
||||
PRINTF("BOOT block at %d, checking checksum\n", i);
|
||||
if (sum_block((struct block_header *)block_buffer) == 0)
|
||||
{
|
||||
PRINTF("Found valid bootcode block\n");
|
||||
memcpy(&bootcode, boot, sizeof(struct bootcode_block));
|
||||
return &bootcode;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PRINTF("No boot code found on disk\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Test if the given partition has an Amiga partition table/Rigid
|
||||
* Disk block
|
||||
*/
|
||||
int test_part_amiga(block_dev_desc_t *dev_desc)
|
||||
{
|
||||
struct rigid_disk_block *rdb;
|
||||
struct bootcode_block *bootcode;
|
||||
|
||||
PRINTF("test_part_amiga: Testing for an Amiga RDB partition\n");
|
||||
|
||||
rdb = get_rdisk(dev_desc);
|
||||
if (rdb)
|
||||
{
|
||||
bootcode = get_bootcode(dev_desc);
|
||||
if (bootcode)
|
||||
PRINTF("test_part_amiga: bootable Amiga disk\n");
|
||||
else
|
||||
PRINTF("test_part_amiga: non-bootable Amiga disk\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
PRINTF("test_part_amiga: no RDB found\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Find partition number partnum on the given drive.
|
||||
*/
|
||||
static struct partition_block *find_partition(block_dev_desc_t *dev_desc, int partnum)
|
||||
{
|
||||
struct rigid_disk_block *rdb;
|
||||
struct partition_block *p;
|
||||
u32 block;
|
||||
|
||||
PRINTF("Trying to find partition block %d\n", partnum);
|
||||
rdb = get_rdisk(dev_desc);
|
||||
if (!rdb)
|
||||
{
|
||||
PRINTF("find_partition: no rdb found\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PRINTF("find_partition: Scanning partition list\n");
|
||||
|
||||
block = rdb->partition_list;
|
||||
PRINTF("find_partition: partition list at 0x%x\n", block);
|
||||
|
||||
while (block != 0xFFFFFFFF)
|
||||
{
|
||||
ulong res = dev_desc->block_read(dev_desc->dev, block, 1,
|
||||
(ulong *)block_buffer);
|
||||
if (res == 1)
|
||||
{
|
||||
p = (struct partition_block *)block_buffer;
|
||||
if (p->id == AMIGA_ID_PART)
|
||||
{
|
||||
PRINTF("PART block suspect at 0x%x, checking checksum\n",block);
|
||||
if (sum_block((struct block_header *)p) == 0)
|
||||
{
|
||||
if (partnum == 0) break;
|
||||
else
|
||||
{
|
||||
partnum--;
|
||||
block = p->next;
|
||||
}
|
||||
}
|
||||
} else block = 0xFFFFFFFF;
|
||||
} else block = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
if (block == 0xFFFFFFFF)
|
||||
{
|
||||
PRINTF("PART block not found\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (struct partition_block *)block_buffer;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get info about a partition
|
||||
*/
|
||||
int get_partition_info_amiga (block_dev_desc_t *dev_desc, int part, disk_partition_t *info)
|
||||
{
|
||||
struct partition_block *p = find_partition(dev_desc, part-1);
|
||||
struct amiga_part_geometry *g;
|
||||
u32 disk_type;
|
||||
|
||||
if (!p) return -1;
|
||||
|
||||
g = (struct amiga_part_geometry *)&(p->environment);
|
||||
info->start = g->low_cyl * g->block_per_track * g->surfaces;
|
||||
info->size = (g->high_cyl - g->low_cyl + 1) * g->block_per_track * g->surfaces - 1;
|
||||
info->blksz = rdb.block_bytes;
|
||||
bcpl_strcpy(info->name, p->drive_name);
|
||||
|
||||
|
||||
disk_type = g->dos_type;
|
||||
|
||||
info->type[0] = (disk_type & 0xFF000000)>>24;
|
||||
info->type[1] = (disk_type & 0x00FF0000)>>16;
|
||||
info->type[2] = (disk_type & 0x0000FF00)>>8;
|
||||
info->type[3] = '\\';
|
||||
info->type[4] = (disk_type & 0x000000FF) + '0';
|
||||
info->type[5] = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void print_part_amiga (block_dev_desc_t *dev_desc)
|
||||
{
|
||||
struct rigid_disk_block *rdb;
|
||||
struct bootcode_block *boot;
|
||||
struct partition_block *p;
|
||||
u32 block;
|
||||
int i = 1;
|
||||
|
||||
rdb = get_rdisk(dev_desc);
|
||||
if (!rdb)
|
||||
{
|
||||
PRINTF("print_part_amiga: no rdb found\n");
|
||||
return;
|
||||
}
|
||||
|
||||
PRINTF("print_part_amiga: Scanning partition list\n");
|
||||
|
||||
block = rdb->partition_list;
|
||||
PRINTF("print_part_amiga: partition list at 0x%x\n", block);
|
||||
|
||||
printf("Summary: DiskBlockSize: %d\n"
|
||||
" Cylinders : %d\n"
|
||||
" Sectors/Track: %d\n"
|
||||
" Heads : %d\n\n",
|
||||
rdb->block_bytes, rdb->cylinders, rdb->sectors,
|
||||
rdb->heads);
|
||||
|
||||
printf(" First Num. \n"
|
||||
"Nr. Part. Name Block Block Type Boot Priority\n");
|
||||
|
||||
while (block != 0xFFFFFFFF)
|
||||
{
|
||||
ulong res;
|
||||
|
||||
PRINTF("Trying to load block #0x%X\n", block);
|
||||
|
||||
res = dev_desc->block_read(dev_desc->dev, block, 1,
|
||||
(ulong *)block_buffer);
|
||||
if (res == 1)
|
||||
{
|
||||
p = (struct partition_block *)block_buffer;
|
||||
if (p->id == AMIGA_ID_PART)
|
||||
{
|
||||
PRINTF("PART block suspect at 0x%x, checking checksum\n",block);
|
||||
if (sum_block((struct block_header *)p) == 0)
|
||||
{
|
||||
printf("%-4d ", i); i++;
|
||||
print_part_info(p);
|
||||
block = p->next;
|
||||
}
|
||||
} else block = 0xFFFFFFFF;
|
||||
} else block = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
boot = get_bootcode(dev_desc);
|
||||
if (boot)
|
||||
{
|
||||
printf("Disk is bootable\n");
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,157 +0,0 @@
|
|||
/*
|
||||
* (C) Copyright 2000
|
||||
* Hans-Joerg Frieden, Hyperion Entertainment
|
||||
* Hans-JoergF@hyperion-entertainment.com
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef _DISK_PART_AMIGA_H
|
||||
#define _DISK_PART_AMIGA_H
|
||||
#include <common.h>
|
||||
|
||||
#ifdef CONFIG_ISO_PARTITION
|
||||
/* Make the buffers bigger if ISO partition support is enabled -- CD-ROMS
|
||||
have 2048 byte blocks */
|
||||
#define DEFAULT_SECTOR_SIZE 2048
|
||||
#else
|
||||
#define DEFAULT_SECTOR_SIZE 512
|
||||
#endif
|
||||
|
||||
|
||||
#define AMIGA_BLOCK_LIMIT 16
|
||||
|
||||
/*
|
||||
* Amiga disks have a very open structure. The head for the partition table information
|
||||
* is stored somewhere within the first 16 blocks on disk, and is called the
|
||||
* "RigidDiskBlock".
|
||||
*/
|
||||
|
||||
struct rigid_disk_block
|
||||
{
|
||||
u32 id;
|
||||
u32 summed_longs;
|
||||
s32 chk_sum;
|
||||
u32 host_id;
|
||||
u32 block_bytes;
|
||||
u32 flags;
|
||||
u32 bad_block_list;
|
||||
u32 partition_list;
|
||||
u32 file_sys_header_list;
|
||||
u32 drive_init;
|
||||
u32 bootcode_block;
|
||||
u32 reserved_1[5];
|
||||
|
||||
/* Physical drive geometry */
|
||||
u32 cylinders;
|
||||
u32 sectors;
|
||||
u32 heads;
|
||||
u32 interleave;
|
||||
u32 park;
|
||||
u32 reserved_2[3];
|
||||
u32 write_pre_comp;
|
||||
u32 reduced_write;
|
||||
u32 step_rate;
|
||||
u32 reserved_3[5];
|
||||
|
||||
/* logical drive geometry */
|
||||
u32 rdb_blocks_lo;
|
||||
u32 rdb_blocks_hi;
|
||||
u32 lo_cylinder;
|
||||
u32 hi_cylinder;
|
||||
u32 cyl_blocks;
|
||||
u32 auto_park_seconds;
|
||||
u32 high_rdsk_block;
|
||||
u32 reserved_4;
|
||||
|
||||
char disk_vendor[8];
|
||||
char disk_product[16];
|
||||
char disk_revision[4];
|
||||
char controller_vendor[8];
|
||||
char controller_product[16];
|
||||
char controller_revision[4];
|
||||
|
||||
u32 reserved_5[10];
|
||||
};
|
||||
|
||||
/*
|
||||
* Each partition on this drive is defined by such a block
|
||||
*/
|
||||
|
||||
struct partition_block
|
||||
{
|
||||
u32 id;
|
||||
u32 summed_longs;
|
||||
s32 chk_sum;
|
||||
u32 host_id;
|
||||
u32 next;
|
||||
u32 flags;
|
||||
u32 reserved_1[2];
|
||||
u32 dev_flags;
|
||||
char drive_name[32];
|
||||
u32 reserved_2[15];
|
||||
u32 environment[17];
|
||||
u32 reserved_3[15];
|
||||
};
|
||||
|
||||
struct bootcode_block
|
||||
{
|
||||
u32 id;
|
||||
u32 summed_longs;
|
||||
s32 chk_sum;
|
||||
u32 host_id;
|
||||
u32 next;
|
||||
u32 load_data[123];
|
||||
};
|
||||
|
||||
|
||||
#define AMIGA_ID_RDISK 0x5244534B
|
||||
#define AMIGA_ID_PART 0x50415254
|
||||
#define AMIGA_ID_BOOT 0x424f4f54
|
||||
|
||||
/*
|
||||
* The environment array in the partition block
|
||||
* describes the partition
|
||||
*/
|
||||
|
||||
struct amiga_part_geometry
|
||||
{
|
||||
u32 table_size;
|
||||
u32 size_blocks;
|
||||
u32 unused1;
|
||||
u32 surfaces;
|
||||
u32 sector_per_block;
|
||||
u32 block_per_track;
|
||||
u32 reserved;
|
||||
u32 prealloc;
|
||||
u32 interleave;
|
||||
u32 low_cyl;
|
||||
u32 high_cyl;
|
||||
u32 num_buffers;
|
||||
u32 buf_mem_type;
|
||||
u32 max_transfer;
|
||||
u32 mask;
|
||||
s32 boot_priority;
|
||||
u32 dos_type;
|
||||
u32 baud;
|
||||
u32 control;
|
||||
u32 boot_blocks;
|
||||
};
|
||||
|
||||
#endif /* _DISK_PART_AMIGA_H_ */
|
251
disk/part_dos.c
251
disk/part_dos.c
|
@ -1,251 +0,0 @@
|
|||
/*
|
||||
* (C) Copyright 2001
|
||||
* Raymond Lo, lo@routefree.com
|
||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/*
|
||||
* Support for harddisk partitions.
|
||||
*
|
||||
* To be compatible with LinuxPPC and Apple we use the standard Apple
|
||||
* SCSI disk partitioning scheme. For more information see:
|
||||
* http://developer.apple.com/techpubs/mac/Devices/Devices-126.html#MARKER-14-92
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <command.h>
|
||||
#include <ide.h>
|
||||
#include "part_dos.h"
|
||||
|
||||
#if ((CONFIG_COMMANDS & CFG_CMD_IDE) || \
|
||||
(CONFIG_COMMANDS & CFG_CMD_SCSI) || \
|
||||
(CONFIG_COMMANDS & CFG_CMD_USB) || \
|
||||
defined(CONFIG_MMC) || \
|
||||
defined(CONFIG_SYSTEMACE) ) && defined(CONFIG_DOS_PARTITION)
|
||||
|
||||
/* Convert char[4] in little endian format to the host format integer
|
||||
*/
|
||||
static inline int le32_to_int(unsigned char *le32)
|
||||
{
|
||||
return ((le32[3] << 24) +
|
||||
(le32[2] << 16) +
|
||||
(le32[1] << 8) +
|
||||
le32[0]
|
||||
);
|
||||
}
|
||||
|
||||
static inline int is_extended(int part_type)
|
||||
{
|
||||
return (part_type == 0x5 ||
|
||||
part_type == 0xf ||
|
||||
part_type == 0x85);
|
||||
}
|
||||
|
||||
static void print_one_part (dos_partition_t *p, int ext_part_sector, int part_num)
|
||||
{
|
||||
int lba_start = ext_part_sector + le32_to_int (p->start4);
|
||||
int lba_size = le32_to_int (p->size4);
|
||||
|
||||
printf ("%5d\t\t%10d\t%10d\t%2x%s\n",
|
||||
part_num, lba_start, lba_size, p->sys_ind,
|
||||
(is_extended (p->sys_ind) ? " Extd" : ""));
|
||||
}
|
||||
|
||||
static int test_block_type(unsigned char *buffer)
|
||||
{
|
||||
if((buffer[DOS_PART_MAGIC_OFFSET + 0] != 0x55) ||
|
||||
(buffer[DOS_PART_MAGIC_OFFSET + 1] != 0xaa) ) {
|
||||
return (-1);
|
||||
} /* no DOS Signature at all */
|
||||
if(strncmp((char *)&buffer[DOS_PBR_FSTYPE_OFFSET],"FAT",3)==0)
|
||||
return DOS_PBR; /* is PBR */
|
||||
return DOS_MBR; /* Is MBR */
|
||||
}
|
||||
|
||||
|
||||
int test_part_dos (block_dev_desc_t *dev_desc)
|
||||
{
|
||||
unsigned char buffer[DEFAULT_SECTOR_SIZE];
|
||||
|
||||
if ((dev_desc->block_read(dev_desc->dev, 0, 1, (ulong *) buffer) != 1) ||
|
||||
(buffer[DOS_PART_MAGIC_OFFSET + 0] != 0x55) ||
|
||||
(buffer[DOS_PART_MAGIC_OFFSET + 1] != 0xaa) ) {
|
||||
return (-1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Print a partition that is relative to its Extended partition table
|
||||
*/
|
||||
static void print_partition_extended (block_dev_desc_t *dev_desc, int ext_part_sector, int relative,
|
||||
int part_num)
|
||||
{
|
||||
unsigned char buffer[DEFAULT_SECTOR_SIZE];
|
||||
dos_partition_t *pt;
|
||||
int i;
|
||||
|
||||
if (dev_desc->block_read(dev_desc->dev, ext_part_sector, 1, (ulong *) buffer) != 1) {
|
||||
printf ("** Can't read partition table on %d:%d **\n",
|
||||
dev_desc->dev, ext_part_sector);
|
||||
return;
|
||||
}
|
||||
i=test_block_type(buffer);
|
||||
if(i==-1) {
|
||||
printf ("bad MBR sector signature 0x%02x%02x\n",
|
||||
buffer[DOS_PART_MAGIC_OFFSET],
|
||||
buffer[DOS_PART_MAGIC_OFFSET + 1]);
|
||||
return;
|
||||
}
|
||||
if(i==DOS_PBR) {
|
||||
printf (" 1\t\t 0\t%10ld\t%2x\n",
|
||||
dev_desc->lba, buffer[DOS_PBR_MEDIA_TYPE_OFFSET]);
|
||||
return;
|
||||
}
|
||||
/* Print all primary/logical partitions */
|
||||
pt = (dos_partition_t *) (buffer + DOS_PART_TBL_OFFSET);
|
||||
for (i = 0; i < 4; i++, pt++) {
|
||||
/*
|
||||
* fdisk does not show the extended partitions that
|
||||
* are not in the MBR
|
||||
*/
|
||||
|
||||
if ((pt->sys_ind != 0) &&
|
||||
(ext_part_sector == 0 || !is_extended (pt->sys_ind)) ) {
|
||||
print_one_part (pt, ext_part_sector, part_num);
|
||||
}
|
||||
|
||||
/* Reverse engr the fdisk part# assignment rule! */
|
||||
if ((ext_part_sector == 0) ||
|
||||
(pt->sys_ind != 0 && !is_extended (pt->sys_ind)) ) {
|
||||
part_num++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Follows the extended partitions */
|
||||
pt = (dos_partition_t *) (buffer + DOS_PART_TBL_OFFSET);
|
||||
for (i = 0; i < 4; i++, pt++) {
|
||||
if (is_extended (pt->sys_ind)) {
|
||||
int lba_start = le32_to_int (pt->start4) + relative;
|
||||
|
||||
print_partition_extended (dev_desc, lba_start,
|
||||
ext_part_sector == 0 ? lba_start
|
||||
: relative,
|
||||
part_num);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Print a partition that is relative to its Extended partition table
|
||||
*/
|
||||
static int get_partition_info_extended (block_dev_desc_t *dev_desc, int ext_part_sector,
|
||||
int relative, int part_num,
|
||||
int which_part, disk_partition_t *info)
|
||||
{
|
||||
unsigned char buffer[DEFAULT_SECTOR_SIZE];
|
||||
dos_partition_t *pt;
|
||||
int i;
|
||||
|
||||
if (dev_desc->block_read (dev_desc->dev, ext_part_sector, 1, (ulong *) buffer) != 1) {
|
||||
printf ("** Can't read partition table on %d:%d **\n",
|
||||
dev_desc->dev, ext_part_sector);
|
||||
return -1;
|
||||
}
|
||||
if (buffer[DOS_PART_MAGIC_OFFSET] != 0x55 ||
|
||||
buffer[DOS_PART_MAGIC_OFFSET + 1] != 0xaa) {
|
||||
printf ("bad MBR sector signature 0x%02x%02x\n",
|
||||
buffer[DOS_PART_MAGIC_OFFSET],
|
||||
buffer[DOS_PART_MAGIC_OFFSET + 1]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Print all primary/logical partitions */
|
||||
pt = (dos_partition_t *) (buffer + DOS_PART_TBL_OFFSET);
|
||||
for (i = 0; i < 4; i++, pt++) {
|
||||
/*
|
||||
* fdisk does not show the extended partitions that
|
||||
* are not in the MBR
|
||||
*/
|
||||
if ((pt->sys_ind != 0) &&
|
||||
(part_num == which_part) &&
|
||||
(is_extended(pt->sys_ind) == 0)) {
|
||||
info->blksz = 512;
|
||||
info->start = ext_part_sector + le32_to_int (pt->start4);
|
||||
info->size = le32_to_int (pt->size4);
|
||||
switch(dev_desc->if_type) {
|
||||
case IF_TYPE_IDE:
|
||||
case IF_TYPE_ATAPI:
|
||||
sprintf ((char *)info->name, "hd%c%d\n", 'a' + dev_desc->dev, part_num);
|
||||
break;
|
||||
case IF_TYPE_SCSI:
|
||||
sprintf ((char *)info->name, "sd%c%d\n", 'a' + dev_desc->dev, part_num);
|
||||
break;
|
||||
case IF_TYPE_USB:
|
||||
sprintf ((char *)info->name, "usbd%c%d\n", 'a' + dev_desc->dev, part_num);
|
||||
break;
|
||||
case IF_TYPE_DOC:
|
||||
sprintf ((char *)info->name, "docd%c%d\n", 'a' + dev_desc->dev, part_num);
|
||||
break;
|
||||
default:
|
||||
sprintf ((char *)info->name, "xx%c%d\n", 'a' + dev_desc->dev, part_num);
|
||||
break;
|
||||
}
|
||||
/* sprintf(info->type, "%d, pt->sys_ind); */
|
||||
sprintf ((char *)info->type, "U-Boot");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Reverse engr the fdisk part# assignment rule! */
|
||||
if ((ext_part_sector == 0) ||
|
||||
(pt->sys_ind != 0 && !is_extended (pt->sys_ind)) ) {
|
||||
part_num++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Follows the extended partitions */
|
||||
pt = (dos_partition_t *) (buffer + DOS_PART_TBL_OFFSET);
|
||||
for (i = 0; i < 4; i++, pt++) {
|
||||
if (is_extended (pt->sys_ind)) {
|
||||
int lba_start = le32_to_int (pt->start4) + relative;
|
||||
|
||||
return get_partition_info_extended (dev_desc, lba_start,
|
||||
ext_part_sector == 0 ? lba_start : relative,
|
||||
part_num, which_part, info);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void print_part_dos (block_dev_desc_t *dev_desc)
|
||||
{
|
||||
printf ("Partition Start Sector Num Sectors Type\n");
|
||||
print_partition_extended (dev_desc, 0, 0, 1);
|
||||
}
|
||||
|
||||
int get_partition_info_dos (block_dev_desc_t *dev_desc, int part, disk_partition_t * info)
|
||||
{
|
||||
return get_partition_info_extended (dev_desc, 0, 0, 1, part, info);
|
||||
}
|
||||
|
||||
|
||||
#endif /* (CONFIG_COMMANDS & CFG_CMD_IDE) && CONFIG_DOS_PARTITION */
|
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
* (C) Copyright 2000
|
||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef _DISK_PART_DOS_H
|
||||
#define _DISK_PART_DOS_H
|
||||
|
||||
|
||||
#ifdef CONFIG_ISO_PARTITION
|
||||
/* Make the buffers bigger if ISO partition support is enabled -- CD-ROMS
|
||||
have 2048 byte blocks */
|
||||
#define DEFAULT_SECTOR_SIZE 2048
|
||||
#else
|
||||
#define DEFAULT_SECTOR_SIZE 512
|
||||
#endif
|
||||
#define DOS_PART_TBL_OFFSET 0x1be
|
||||
#define DOS_PART_MAGIC_OFFSET 0x1fe
|
||||
#define DOS_PBR_FSTYPE_OFFSET 0x36
|
||||
#define DOS_PBR_MEDIA_TYPE_OFFSET 0x15
|
||||
#define DOS_MBR 0
|
||||
#define DOS_PBR 1
|
||||
|
||||
typedef struct dos_partition {
|
||||
unsigned char boot_ind; /* 0x80 - active */
|
||||
unsigned char head; /* starting head */
|
||||
unsigned char sector; /* starting sector */
|
||||
unsigned char cyl; /* starting cylinder */
|
||||
unsigned char sys_ind; /* What partition type */
|
||||
unsigned char end_head; /* end head */
|
||||
unsigned char end_sector; /* end sector */
|
||||
unsigned char end_cyl; /* end cylinder */
|
||||
unsigned char start4[4]; /* starting sector counting from 0 */
|
||||
unsigned char size4[4]; /* nr of sectors in partition */
|
||||
} dos_partition_t;
|
||||
|
||||
#endif /* _DISK_PART_DOS_H */
|
260
disk/part_iso.c
260
disk/part_iso.c
|
@ -1,260 +0,0 @@
|
|||
/*
|
||||
* (C) Copyright 2001
|
||||
* Denis Peter, MPL AG Switzerland, d.peter@mpl.ch.
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <command.h>
|
||||
#include "part_iso.h"
|
||||
|
||||
#if ((CONFIG_COMMANDS & CFG_CMD_IDE) || \
|
||||
(CONFIG_COMMANDS & CFG_CMD_SCSI) || \
|
||||
(CONFIG_COMMANDS & CFG_CMD_USB) || \
|
||||
defined(CONFIG_MMC) || \
|
||||
defined(CONFIG_SYSTEMACE) ) && defined(CONFIG_ISO_PARTITION)
|
||||
|
||||
/* #define ISO_PART_DEBUG */
|
||||
|
||||
#ifdef ISO_PART_DEBUG
|
||||
#define PRINTF(fmt,args...) printf (fmt ,##args)
|
||||
#else
|
||||
#define PRINTF(fmt,args...)
|
||||
#endif
|
||||
|
||||
/* enable this if CDs are written with the PowerPC Platform ID */
|
||||
#undef CHECK_FOR_POWERPC_PLATTFORM
|
||||
#define CD_SECTSIZE 2048
|
||||
|
||||
static unsigned char tmpbuf[CD_SECTSIZE];
|
||||
|
||||
/* Convert char[4] in little endian format to the host format integer
|
||||
*/
|
||||
static inline unsigned long le32_to_int(unsigned char *le32)
|
||||
{
|
||||
return ((le32[3] << 24) +
|
||||
(le32[2] << 16) +
|
||||
(le32[1] << 8) +
|
||||
le32[0]
|
||||
);
|
||||
}
|
||||
/* Convert char[2] in little endian format to the host format integer
|
||||
*/
|
||||
static inline unsigned short le16_to_int(unsigned char *le16)
|
||||
{
|
||||
return ((le16[1] << 8) +
|
||||
le16[0]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/* only boot records will be listed as valid partitions */
|
||||
int get_partition_info_iso_verb(block_dev_desc_t * dev_desc, int part_num, disk_partition_t * info, int verb)
|
||||
{
|
||||
int i,offset,entry_num;
|
||||
unsigned short *chksumbuf;
|
||||
unsigned short chksum;
|
||||
unsigned long newblkaddr,blkaddr,lastsect,bootaddr;
|
||||
iso_boot_rec_t *pbr = (iso_boot_rec_t *)tmpbuf; /* boot record */
|
||||
iso_pri_rec_t *ppr = (iso_pri_rec_t *)tmpbuf; /* primary desc */
|
||||
iso_val_entry_t *pve = (iso_val_entry_t *)tmpbuf;
|
||||
iso_init_def_entry_t *pide;
|
||||
|
||||
/* the first sector (sector 0x10) must be a primary volume desc */
|
||||
blkaddr=PVD_OFFSET;
|
||||
if (dev_desc->block_read (dev_desc->dev, PVD_OFFSET, 1, (ulong *) tmpbuf) != 1)
|
||||
return (-1);
|
||||
if(ppr->desctype!=0x01) {
|
||||
if(verb)
|
||||
printf ("** First descriptor is NOT a primary desc on %d:%d **\n",
|
||||
dev_desc->dev, part_num);
|
||||
return (-1);
|
||||
}
|
||||
if(strncmp((char *)ppr->stand_ident,"CD001",5)!=0) {
|
||||
if(verb)
|
||||
printf ("** Wrong ISO Ident: %s on %d:%d **\n",
|
||||
ppr->stand_ident,dev_desc->dev, part_num);
|
||||
return (-1);
|
||||
}
|
||||
lastsect= ((ppr->firstsek_LEpathtab1_LE & 0x000000ff)<<24) +
|
||||
((ppr->firstsek_LEpathtab1_LE & 0x0000ff00)<< 8) +
|
||||
((ppr->firstsek_LEpathtab1_LE & 0x00ff0000)>> 8) +
|
||||
((ppr->firstsek_LEpathtab1_LE & 0xff000000)>>24) ;
|
||||
info->blksz=ppr->secsize_BE; /* assuming same block size for all entries */
|
||||
PRINTF(" Lastsect:%08lx\n",lastsect);
|
||||
for(i=blkaddr;i<lastsect;i++) {
|
||||
PRINTF("Reading block %d\n", i);
|
||||
if (dev_desc->block_read (dev_desc->dev, i, 1, (ulong *) tmpbuf) != 1)
|
||||
return (-1);
|
||||
if(ppr->desctype==0x00)
|
||||
break; /* boot entry found */
|
||||
if(ppr->desctype==0xff) {
|
||||
if(verb)
|
||||
printf ("** No valid boot catalog found on %d:%d **\n",
|
||||
dev_desc->dev, part_num);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
/* boot entry found */
|
||||
if(strncmp(pbr->ident_str,"EL TORITO SPECIFICATION",23)!=0) {
|
||||
if(verb)
|
||||
printf ("** Wrong El Torito ident: %s on %d:%d **\n",
|
||||
pbr->ident_str,dev_desc->dev, part_num);
|
||||
return (-1);
|
||||
}
|
||||
bootaddr=le32_to_int(pbr->pointer);
|
||||
PRINTF(" Boot Entry at: %08lX\n",bootaddr);
|
||||
if (dev_desc->block_read (dev_desc->dev, bootaddr, 1, (ulong *) tmpbuf) != 1) {
|
||||
if(verb)
|
||||
printf ("** Can't read Boot Entry at %lX on %d:%d **\n",
|
||||
bootaddr,dev_desc->dev, part_num);
|
||||
return (-1);
|
||||
}
|
||||
chksum=0;
|
||||
chksumbuf = (unsigned short *)tmpbuf;
|
||||
for(i=0;i<0x10;i++)
|
||||
chksum+=((chksumbuf[i] &0xff)<<8)+((chksumbuf[i] &0xff00)>>8);
|
||||
if(chksum!=0) {
|
||||
if(verb)
|
||||
printf ("** Checksum Error in booting catalog validation entry on %d:%d **\n",
|
||||
dev_desc->dev, part_num);
|
||||
return (-1);
|
||||
}
|
||||
if((pve->key[0]!=0x55)||(pve->key[1]!=0xAA)) {
|
||||
if(verb)
|
||||
printf ("** Key 0x55 0xAA error on %d:%d **\n",
|
||||
dev_desc->dev, part_num);
|
||||
return(-1);
|
||||
}
|
||||
#ifdef CHECK_FOR_POWERPC_PLATTFORM
|
||||
if(pve->platform!=0x01) {
|
||||
if(verb)
|
||||
printf ("** No PowerPC platform CD on %d:%d **\n",
|
||||
dev_desc->dev, part_num);
|
||||
return(-1);
|
||||
}
|
||||
#endif
|
||||
/* the validation entry seems to be ok, now search the "partition" */
|
||||
entry_num=0;
|
||||
offset=0x20;
|
||||
sprintf ((char *)info->type, "U-Boot");
|
||||
switch(dev_desc->if_type) {
|
||||
case IF_TYPE_IDE:
|
||||
case IF_TYPE_ATAPI:
|
||||
sprintf ((char *)info->name, "hd%c%d\n", 'a' + dev_desc->dev, part_num);
|
||||
break;
|
||||
case IF_TYPE_SCSI:
|
||||
sprintf ((char *)info->name, "sd%c%d\n", 'a' + dev_desc->dev, part_num);
|
||||
break;
|
||||
case IF_TYPE_USB:
|
||||
sprintf ((char *)info->name, "usbd%c%d\n", 'a' + dev_desc->dev, part_num);
|
||||
break;
|
||||
case IF_TYPE_DOC:
|
||||
sprintf ((char *)info->name, "docd%c%d\n", 'a' + dev_desc->dev, part_num);
|
||||
break;
|
||||
default:
|
||||
sprintf ((char *)info->name, "xx%c%d\n", 'a' + dev_desc->dev, part_num);
|
||||
break;
|
||||
}
|
||||
/* the bootcatalog (including validation Entry) is limited to 2048Bytes
|
||||
* (63 boot entries + validation entry) */
|
||||
while(offset<2048) {
|
||||
pide=(iso_init_def_entry_t *)&tmpbuf[offset];
|
||||
if ((pide->boot_ind==0x88) ||
|
||||
(pide->boot_ind==0x00)) { /* Header Id for default Sections Entries */
|
||||
if(entry_num==part_num) { /* part found */
|
||||
goto found;
|
||||
}
|
||||
entry_num++; /* count partitions Entries (boot and non bootables */
|
||||
offset+=0x20;
|
||||
continue;
|
||||
}
|
||||
if ((pide->boot_ind==0x90) || /* Section Header Entry */
|
||||
(pide->boot_ind==0x91) || /* Section Header Entry (last) */
|
||||
(pide->boot_ind==0x44)) { /* Extension Indicator */
|
||||
offset+=0x20; /* skip unused entries */
|
||||
}
|
||||
else {
|
||||
if(verb)
|
||||
printf ("** Partition %d not found on device %d **\n",
|
||||
part_num,dev_desc->dev);
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
/* if we reach this point entire sector has been
|
||||
* searched w/o succsess */
|
||||
if(verb)
|
||||
printf ("** Partition %d not found on device %d **\n",
|
||||
part_num,dev_desc->dev);
|
||||
return(-1);
|
||||
found:
|
||||
if(pide->boot_ind!=0x88) {
|
||||
if(verb)
|
||||
printf ("** Partition %d is not bootable on device %d **\n",
|
||||
part_num,dev_desc->dev);
|
||||
return (-1);
|
||||
}
|
||||
switch(pide->boot_media) {
|
||||
case 0x00: /* no emulation */
|
||||
info->size=le16_to_int(pide->sec_cnt)>>2;
|
||||
break;
|
||||
case 0x01: info->size=2400>>2; break; /* 1.2MByte Floppy */
|
||||
case 0x02: info->size=2880>>2; break; /* 1.44MByte Floppy */
|
||||
case 0x03: info->size=5760>>2; break; /* 2.88MByte Floppy */
|
||||
case 0x04: info->size=2880>>2; break; /* dummy (HD Emulation) */
|
||||
default: info->size=0; break;
|
||||
}
|
||||
newblkaddr=le32_to_int(pide->rel_block_addr);
|
||||
info->start=newblkaddr;
|
||||
PRINTF(" part %d found @ %lx size %lx\n",part_num,newblkaddr,info->size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_partition_info_iso(block_dev_desc_t * dev_desc, int part_num, disk_partition_t * info)
|
||||
{
|
||||
return(get_partition_info_iso_verb(dev_desc, part_num, info, 1));
|
||||
}
|
||||
|
||||
|
||||
void print_part_iso(block_dev_desc_t * dev_desc)
|
||||
{
|
||||
disk_partition_t info;
|
||||
int i;
|
||||
if(get_partition_info_iso_verb(dev_desc,0,&info,0)==-1) {
|
||||
printf("** No boot partition found on device %d **\n",dev_desc->dev);
|
||||
return;
|
||||
}
|
||||
printf("Part Start Sect x Size Type\n");
|
||||
i=0;
|
||||
do {
|
||||
printf (" %2d %8ld %8ld %6ld %.32s\n",
|
||||
i, info.start, info.size, info.blksz, info.type);
|
||||
i++;
|
||||
} while (get_partition_info_iso_verb(dev_desc,i,&info,0)!=-1);
|
||||
}
|
||||
|
||||
int test_part_iso (block_dev_desc_t *dev_desc)
|
||||
{
|
||||
disk_partition_t info;
|
||||
|
||||
return(get_partition_info_iso_verb(dev_desc,0,&info,0));
|
||||
}
|
||||
|
||||
#endif /* ((CONFIG_COMMANDS & CFG_CMD_IDE) || (CONFIG_COMMANDS & CFG_CMD_SCSI)) && defined(CONFIG_ISO_PARTITION) */
|
160
disk/part_iso.h
160
disk/part_iso.h
|
@ -1,160 +0,0 @@
|
|||
/*
|
||||
* (C) Copyright 2001
|
||||
* Denis Peter, MPL AG Switzerland, d.peter@mpl.ch.
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
#ifndef _PART_CD_H
|
||||
#define _PART_CD_H
|
||||
|
||||
#define BRVD 0x11
|
||||
#define PVD_OFFSET 0x10
|
||||
|
||||
|
||||
typedef struct iso_boot_rec {
|
||||
unsigned char desctype; /* type of Volume descriptor: 0 = boot record, 1 = primary, 2 = Supplement, 3 = volume part 0xff trminator */
|
||||
unsigned char stand_ident[5]; /* "CD001" */
|
||||
unsigned char vers; /* Version */
|
||||
char ident_str[0x20]; /* Ident String "EL TORITO SPECIFICATION" */
|
||||
unsigned char unused[0x20]; /* unused */
|
||||
unsigned char pointer[4]; /* absolute pointer to Boot Catalog */
|
||||
} iso_boot_rec_t;
|
||||
|
||||
|
||||
typedef struct iso_pri_rec {
|
||||
unsigned char desctype; /* type of Volume descriptor: 0 = boot record, 1 = primary, 2 = Supplement, 3 = volume part 0xff trminator */
|
||||
unsigned char stand_ident[5]; /* "CD001" */
|
||||
unsigned char vers; /* Version */
|
||||
unsigned char unused;
|
||||
char sysid[32]; /* system Identifier */
|
||||
char volid[32]; /* volume Identifier */
|
||||
unsigned char zeros1[8]; /* unused */
|
||||
unsigned long volsiz_LE; /* volume size Little Endian */
|
||||
unsigned long volsiz_BE; /* volume size Big Endian */
|
||||
unsigned char zeros2[32]; /* unused */
|
||||
unsigned short setsize_LE; /* volume set size LE */
|
||||
unsigned short setsize_BE; /* volume set size BE */
|
||||
unsigned short seqnum_LE; /* volume sequence number LE */
|
||||
unsigned short seqnum_BE; /* volume sequence number BE */
|
||||
unsigned short secsize_LE; /* sector size LE */
|
||||
unsigned short secsize_BE; /* sector size BE */
|
||||
unsigned long pathtablen_LE;/* Path Table size LE */
|
||||
unsigned long pathtablen_BE;/* Path Table size BE */
|
||||
unsigned long firstsek_LEpathtab1_LE; /* location of first occurrence of little endian type path table */
|
||||
unsigned long firstsek_LEpathtab2_LE; /* location of optional occurrence of little endian type path table */
|
||||
unsigned long firstsek_BEpathtab1_BE; /* location of first occurrence of big endian type path table */
|
||||
unsigned long firstsek_BEpathtab2_BE; /* location of optional occurrence of big endian type path table */
|
||||
unsigned char rootdir[34]; /* directory record for root dir */
|
||||
char volsetid[128];/* Volume set identifier */
|
||||
char pubid[128]; /* Publisher identifier */
|
||||
char dataprepid[128]; /* data preparer identifier */
|
||||
char appid[128]; /* application identifier */
|
||||
char copyr[37]; /* copyright string */
|
||||
char abstractfileid[37]; /* abstract file identifier */
|
||||
char bibliofileid[37]; /* bibliographic file identifier */
|
||||
unsigned char creationdate[17]; /* creation date */
|
||||
unsigned char modify[17]; /* modification date */
|
||||
unsigned char expire[17]; /* expiring date */
|
||||
unsigned char effective[17];/* effective date */
|
||||
unsigned char filestruc_ver; /* file structur version */
|
||||
} iso_pri_rec_t;
|
||||
|
||||
typedef struct iso_sup_rec {
|
||||
unsigned char desctype; /* type of Volume descriptor: 0 = boot record, 1 = primary, 2 = Supplement, 3 = volume part 0xff trminator */
|
||||
unsigned char stand_ident[5]; /* "CD001" */
|
||||
unsigned char vers; /* Version */
|
||||
unsigned char volumeflags; /* if bit 0 = 0 => all escape sequences are according ISO 2375 */
|
||||
char sysid[32]; /* system Identifier */
|
||||
char volid[32]; /* volume Identifier */
|
||||
unsigned char zeros1[8]; /* unused */
|
||||
unsigned long volsiz_LE; /* volume size Little Endian */
|
||||
unsigned long volsiz_BE; /* volume size Big Endian */
|
||||
unsigned char escapeseq[32];/* Escape sequences */
|
||||
unsigned short setsize_LE; /* volume set size LE */
|
||||
unsigned short setsize_BE; /* volume set size BE */
|
||||
unsigned short seqnum_LE; /* volume sequence number LE */
|
||||
unsigned short seqnum_BE; /* volume sequence number BE */
|
||||
unsigned short secsize_LE; /* sector size LE */
|
||||
unsigned short secsize_BE; /* sector size BE */
|
||||
unsigned long pathtablen_LE;/* Path Table size LE */
|
||||
unsigned long pathtablen_BE;/* Path Table size BE */
|
||||
unsigned long firstsek_LEpathtab1_LE; /* location of first occurrence of little endian type path table */
|
||||
unsigned long firstsek_LEpathtab2_LE; /* location of optional occurrence of little endian type path table */
|
||||
unsigned long firstsek_BEpathtab1_BE; /* location of first occurrence of big endian type path table */
|
||||
unsigned long firstsek_BEpathtab2_BE; /* location of optional occurrence of big endian type path table */
|
||||
unsigned char rootdir[34]; /* directory record for root dir */
|
||||
char volsetid[128];/* Volume set identifier */
|
||||
char pubid[128]; /* Publisher identifier */
|
||||
char dataprepid[128]; /* data preparer identifier */
|
||||
char appid[128]; /* application identifier */
|
||||
char copyr[37]; /* copyright string */
|
||||
char abstractfileid[37]; /* abstract file identifier */
|
||||
char bibliofileid[37]; /* bibliographic file identifier */
|
||||
unsigned char creationdate[17]; /* creation date */
|
||||
unsigned char modify[17]; /* modification date */
|
||||
unsigned char expire[17]; /* expiring date */
|
||||
unsigned char effective[17];/* effective date */
|
||||
unsigned char filestruc_ver; /* file structur version */
|
||||
}iso_sup_rec_t;
|
||||
|
||||
typedef struct iso_part_rec {
|
||||
unsigned char desctype; /* type of Volume descriptor: 0 = boot record, 1 = primary, 2 = Supplement, 3 = volume part 0xff trminator */
|
||||
unsigned char stand_ident[5]; /* "CD001" */
|
||||
unsigned char vers; /* Version */
|
||||
unsigned char unused;
|
||||
char sysid[32]; /* system Identifier */
|
||||
char volid[32]; /* volume partition Identifier */
|
||||
unsigned long partloc_LE; /* volume partition location LE */
|
||||
unsigned long partloc_BE; /* volume partition location BE */
|
||||
unsigned long partsiz_LE; /* volume partition size LE */
|
||||
unsigned long partsiz_BE; /* volume partition size BE */
|
||||
}iso_part_rec_t;
|
||||
|
||||
|
||||
typedef struct iso_val_entry {
|
||||
unsigned char header_id; /* Header ID must be 0x01 */
|
||||
unsigned char platform; /* Platform: 0=x86, 1=PowerPC, 2=MAC */
|
||||
unsigned char res[2]; /* reserved */
|
||||
char manu_str[0x18]; /* Ident String of manufacturer/developer */
|
||||
unsigned char chk_sum[2]; /* Check sum (all words must be zero) */
|
||||
unsigned char key[2]; /* key[0]=55, key[1]=0xAA */
|
||||
} iso_val_entry_t;
|
||||
|
||||
typedef struct iso_header_entry {
|
||||
unsigned char header_id; /* Header ID must be 0x90 or 0x91 */
|
||||
unsigned char platform; /* Platform: 0=x86, 1=PowerPC, 2=MAC */
|
||||
unsigned char numentry[2]; /* number of entries */
|
||||
char id_str[0x1C]; /* Ident String of sectionr */
|
||||
} iso_header_entry_t;
|
||||
|
||||
|
||||
typedef struct iso_init_def_entry {
|
||||
unsigned char boot_ind; /* Boot indicator 0x88=bootable 0=not bootable */
|
||||
unsigned char boot_media; /* boot Media Type: 0=no Emulation, 1=1.2MB floppy, 2=1.44MB floppy, 3=2.88MB floppy 4=hd (0x80) */
|
||||
unsigned char ld_seg[2]; /* Load segment (flat model=addr/10) */
|
||||
unsigned char systype; /* System Type copy of byte5 of part table */
|
||||
unsigned char res; /* reserved */
|
||||
unsigned char sec_cnt[2]; /* sector count in VIRTUAL Blocks (0x200) */
|
||||
unsigned char rel_block_addr[4]; /* relative Block address */
|
||||
} iso_init_def_entry_t;
|
||||
|
||||
|
||||
void print_partition_cd(int dev);
|
||||
|
||||
#endif /* _PART_CD_H */
|
250
disk/part_mac.c
250
disk/part_mac.c
|
@ -1,250 +0,0 @@
|
|||
/*
|
||||
* (C) Copyright 2000
|
||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/*
|
||||
* Support for harddisk partitions.
|
||||
*
|
||||
* To be compatible with LinuxPPC and Apple we use the standard Apple
|
||||
* SCSI disk partitioning scheme. For more information see:
|
||||
* http://developer.apple.com/techpubs/mac/Devices/Devices-126.html#MARKER-14-92
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <command.h>
|
||||
#include <ide.h>
|
||||
#include "part_mac.h"
|
||||
|
||||
#if ((CONFIG_COMMANDS & CFG_CMD_IDE) || \
|
||||
(CONFIG_COMMANDS & CFG_CMD_SCSI) || \
|
||||
(CONFIG_COMMANDS & CFG_CMD_USB) || \
|
||||
defined(CONFIG_MMC) || \
|
||||
defined(CONFIG_SYSTEMACE) ) && defined(CONFIG_MAC_PARTITION)
|
||||
|
||||
/* stdlib.h causes some compatibility problems; should fixe these! -- wd */
|
||||
#ifndef __ldiv_t_defined
|
||||
typedef struct {
|
||||
long int quot; /* Quotient */
|
||||
long int rem; /* Remainder */
|
||||
} ldiv_t;
|
||||
extern ldiv_t ldiv (long int __numer, long int __denom);
|
||||
# define __ldiv_t_defined 1
|
||||
#endif
|
||||
|
||||
|
||||
static int part_mac_read_ddb (block_dev_desc_t *dev_desc, mac_driver_desc_t *ddb_p);
|
||||
static int part_mac_read_pdb (block_dev_desc_t *dev_desc, int part, mac_partition_t *pdb_p);
|
||||
|
||||
/*
|
||||
* Test for a valid MAC partition
|
||||
*/
|
||||
int test_part_mac (block_dev_desc_t *dev_desc)
|
||||
{
|
||||
mac_driver_desc_t ddesc;
|
||||
mac_partition_t mpart;
|
||||
ulong i, n;
|
||||
|
||||
if (part_mac_read_ddb (dev_desc, &ddesc)) {
|
||||
/* error reading Driver Desriptor Block, or no valid Signature */
|
||||
return (-1);
|
||||
}
|
||||
|
||||
n = 1; /* assuming at least one partition */
|
||||
for (i=1; i<=n; ++i) {
|
||||
if ((dev_desc->block_read(dev_desc->dev, i, 1, (ulong *)&mpart) != 1) ||
|
||||
(mpart.signature != MAC_PARTITION_MAGIC) ) {
|
||||
return (-1);
|
||||
}
|
||||
/* update partition count */
|
||||
n = mpart.map_count;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
void print_part_mac (block_dev_desc_t *dev_desc)
|
||||
{
|
||||
ulong i, n;
|
||||
mac_driver_desc_t ddesc;
|
||||
mac_partition_t mpart;
|
||||
ldiv_t mb, gb;
|
||||
|
||||
if (part_mac_read_ddb (dev_desc, &ddesc)) {
|
||||
/* error reading Driver Desriptor Block, or no valid Signature */
|
||||
return;
|
||||
}
|
||||
|
||||
n = ddesc.blk_count;
|
||||
|
||||
mb = ldiv(n, ((1024 * 1024) / ddesc.blk_size)); /* MB */
|
||||
/* round to 1 digit */
|
||||
mb.rem *= 10 * ddesc.blk_size;
|
||||
mb.rem += 512 * 1024;
|
||||
mb.rem /= 1024 * 1024;
|
||||
|
||||
gb = ldiv(10 * mb.quot + mb.rem, 10240);
|
||||
gb.rem += 512;
|
||||
gb.rem /= 1024;
|
||||
|
||||
|
||||
printf ("Block Size=%d, Number of Blocks=%d, "
|
||||
"Total Capacity: %ld.%ld MB = %ld.%ld GB\n"
|
||||
"DeviceType=0x%x, DeviceId=0x%x\n\n"
|
||||
" #: type name"
|
||||
" length base (size)\n",
|
||||
ddesc.blk_size,
|
||||
ddesc.blk_count,
|
||||
mb.quot, mb.rem, gb.quot, gb.rem,
|
||||
ddesc.dev_type, ddesc.dev_id
|
||||
);
|
||||
|
||||
n = 1; /* assuming at least one partition */
|
||||
for (i=1; i<=n; ++i) {
|
||||
ulong bytes;
|
||||
char c;
|
||||
|
||||
printf ("%4ld: ", i);
|
||||
if (dev_desc->block_read (dev_desc->dev, i, 1, (ulong *)&mpart) != 1) {
|
||||
printf ("** Can't read Partition Map on %d:%ld **\n",
|
||||
dev_desc->dev, i);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mpart.signature != MAC_PARTITION_MAGIC) {
|
||||
printf ("** Bad Signature on %d:%ld - "
|
||||
"expected 0x%04x, got 0x%04x\n",
|
||||
dev_desc->dev, i, MAC_PARTITION_MAGIC, mpart.signature);
|
||||
return;
|
||||
}
|
||||
|
||||
/* update partition count */
|
||||
n = mpart.map_count;
|
||||
|
||||
c = 'k';
|
||||
bytes = mpart.block_count;
|
||||
bytes /= (1024 / ddesc.blk_size); /* kB; assumes blk_size == 512 */
|
||||
if (bytes >= 1024) {
|
||||
bytes >>= 10;
|
||||
c = 'M';
|
||||
}
|
||||
if (bytes >= 1024) {
|
||||
bytes >>= 10;
|
||||
c = 'G';
|
||||
}
|
||||
|
||||
printf ("%20.32s %-18.32s %10u @ %-10u (%3ld%c)\n",
|
||||
mpart.type,
|
||||
mpart.name,
|
||||
mpart.block_count,
|
||||
mpart.start_block,
|
||||
bytes, c
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Read Device Descriptor Block
|
||||
*/
|
||||
static int part_mac_read_ddb (block_dev_desc_t *dev_desc, mac_driver_desc_t *ddb_p)
|
||||
{
|
||||
if (dev_desc->block_read(dev_desc->dev, 0, 1, (ulong *)ddb_p) != 1) {
|
||||
printf ("** Can't read Driver Desriptor Block **\n");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (ddb_p->signature != MAC_DRIVER_MAGIC) {
|
||||
return (-1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read Partition Descriptor Block
|
||||
*/
|
||||
static int part_mac_read_pdb (block_dev_desc_t *dev_desc, int part, mac_partition_t *pdb_p)
|
||||
{
|
||||
int n = 1;
|
||||
|
||||
for (;;) {
|
||||
/*
|
||||
* We must always read the descritpor block for
|
||||
* partition 1 first since this is the only way to
|
||||
* know how many partitions we have.
|
||||
*/
|
||||
if (dev_desc->block_read (dev_desc->dev, n, 1, (ulong *)pdb_p) != 1) {
|
||||
printf ("** Can't read Partition Map on %d:%d **\n",
|
||||
dev_desc->dev, n);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (pdb_p->signature != MAC_PARTITION_MAGIC) {
|
||||
printf ("** Bad Signature on %d:%d: "
|
||||
"expected 0x%04x, got 0x%04x\n",
|
||||
dev_desc->dev, n, MAC_PARTITION_MAGIC, pdb_p->signature);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (n == part)
|
||||
return (0);
|
||||
|
||||
if ((part < 1) || (part > pdb_p->map_count)) {
|
||||
printf ("** Invalid partition %d:%d [%d:1...%d:%d only]\n",
|
||||
dev_desc->dev, part,
|
||||
dev_desc->dev,
|
||||
dev_desc->dev, pdb_p->map_count);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/* update partition count */
|
||||
n = part;
|
||||
}
|
||||
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
int get_partition_info_mac (block_dev_desc_t *dev_desc, int part, disk_partition_t *info)
|
||||
{
|
||||
mac_driver_desc_t ddesc;
|
||||
mac_partition_t mpart;
|
||||
|
||||
if (part_mac_read_ddb (dev_desc, &ddesc)) {
|
||||
return (-1);
|
||||
}
|
||||
|
||||
info->blksz = ddesc.blk_size;
|
||||
|
||||
if (part_mac_read_pdb (dev_desc, part, &mpart)) {
|
||||
return (-1);
|
||||
}
|
||||
|
||||
info->start = mpart.start_block;
|
||||
info->size = mpart.block_count;
|
||||
memcpy (info->type, mpart.type, sizeof(info->type));
|
||||
memcpy (info->name, mpart.name, sizeof(info->name));
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
#endif /* (CONFIG_COMMANDS & CFG_CMD_IDE) && CONFIG_MAC_PARTITION */
|
|
@ -1,99 +0,0 @@
|
|||
/*
|
||||
* (C) Copyright 2000
|
||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/*
|
||||
* See also Linux sources, fs/partitions/mac.h
|
||||
*
|
||||
* This file describes structures and values related to the standard
|
||||
* Apple SCSI disk partitioning scheme. For more information see:
|
||||
* http://developer.apple.com/techpubs/mac/Devices/Devices-126.html#MARKER-14-92
|
||||
*/
|
||||
|
||||
#ifndef _DISK_PART_MAC_H
|
||||
#define _DISK_PART_MAC_H
|
||||
|
||||
#define MAC_DRIVER_MAGIC 0x4552
|
||||
|
||||
/*
|
||||
* Driver Descriptor Structure, in block 0.
|
||||
* This block is (and shall remain) 512 bytes long.
|
||||
* Note that there is an alignment problem for the driver descriptor map!
|
||||
*/
|
||||
typedef struct mac_driver_desc {
|
||||
__u16 signature; /* expected to be MAC_DRIVER_MAGIC */
|
||||
__u16 blk_size; /* block size of device */
|
||||
__u32 blk_count; /* number of blocks on device */
|
||||
__u16 dev_type; /* device type */
|
||||
__u16 dev_id; /* device id */
|
||||
__u32 data; /* reserved */
|
||||
__u16 drvr_cnt; /* number of driver descriptor entries */
|
||||
__u16 drvr_map[247]; /* driver descriptor map */
|
||||
} mac_driver_desc_t;
|
||||
|
||||
/*
|
||||
* Device Driver Entry
|
||||
* (Cannot be included in mac_driver_desc because of alignment problems)
|
||||
*/
|
||||
typedef struct mac_driver_entry {
|
||||
__u32 block; /* block number of starting block */
|
||||
__u16 size; /* size of driver, in 512 byte blocks */
|
||||
__u16 type; /* OS Type */
|
||||
} mac_driver_entry_t;
|
||||
|
||||
|
||||
#define MAC_PARTITION_MAGIC 0x504d
|
||||
|
||||
/* type field value for A/UX or other Unix partitions */
|
||||
#define APPLE_AUX_TYPE "Apple_UNIX_SVR2"
|
||||
|
||||
/*
|
||||
* Each Partition Map entry (in blocks 1 ... N) has this format:
|
||||
*/
|
||||
typedef struct mac_partition {
|
||||
__u16 signature; /* expected to be MAC_PARTITION_MAGIC */
|
||||
__u16 sig_pad; /* reserved */
|
||||
__u32 map_count; /* # blocks in partition map */
|
||||
__u32 start_block; /* abs. starting block # of partition */
|
||||
__u32 block_count; /* number of blocks in partition */
|
||||
uchar name[32]; /* partition name */
|
||||
uchar type[32]; /* string type description */
|
||||
__u32 data_start; /* rel block # of first data block */
|
||||
__u32 data_count; /* number of data blocks */
|
||||
__u32 status; /* partition status bits */
|
||||
__u32 boot_start; /* first block of boot code */
|
||||
__u32 boot_size; /* size of boot code, in bytes */
|
||||
__u32 boot_load; /* boot code load address */
|
||||
__u32 boot_load2; /* reserved */
|
||||
__u32 boot_entry; /* boot code entry point */
|
||||
__u32 boot_entry2; /* reserved */
|
||||
__u32 boot_cksum; /* boot code checksum */
|
||||
uchar processor[16]; /* Type of Processor */
|
||||
__u16 part_pad[188]; /* reserved */
|
||||
#ifdef CONFIG_ISO_PARTITION
|
||||
uchar iso_dummy[2048];/* Reservere enough room for an ISO partition block to fit */
|
||||
#endif
|
||||
} mac_partition_t;
|
||||
|
||||
#define MAC_STATUS_BOOTABLE 8 /* partition is bootable */
|
||||
|
||||
#endif /* _DISK_PART_MAC_H */
|
Loading…
Reference in New Issue