示例#1
0
/*
 * Test if the given partition has an Amiga partition table/Rigid
 * Disk block
 */
static int part_test_amiga(struct blk_desc *dev_desc)
{
    struct rigid_disk_block *rdb;
    struct bootcode_block *bootcode;

    PRINTF("part_test_amiga: Testing for an Amiga RDB partition\n");

    rdb = get_rdisk(dev_desc);
    if (rdb)
    {
	bootcode = get_bootcode(dev_desc);
	if (bootcode)
	    PRINTF("part_test_amiga: bootable Amiga disk\n");
	else
	    PRINTF("part_test_amiga: non-bootable Amiga disk\n");

	return 0;
    }
    else
    {
	PRINTF("part_test_amiga: no RDB found\n");
	return -1;
    }

}
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");
    }
}
示例#3
0
/*
 * Find partition number partnum on the given drive.
 */
static struct partition_block *find_partition(struct blk_desc *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 = blk_dread(dev_desc, 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;
}