mirror of
https://gitlab.com/qemu-project/openbios.git
synced 2024-02-13 08:34:06 +08:00
Added handling of alphabetic partition ids as used in Sparc. Fixed sizes
reported. git-svn-id: svn://coreboot.org/openbios/openbios-devel@30 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
@@ -63,7 +63,9 @@ dlabel_open( dlabel_info_t *di )
|
|||||||
s = parstr;
|
s = parstr;
|
||||||
filename = NULL;
|
filename = NULL;
|
||||||
if( s ) {
|
if( s ) {
|
||||||
if( *s == '-' || isdigit(*s) ) {
|
if( *s == '-' || isdigit(*s) ||
|
||||||
|
(*s >= 'a' && *s < ('a' + 8)
|
||||||
|
&& (*(s + 1) == ',' || *(s + 1) == '\0'))) {
|
||||||
if( (s=strpbrk(parstr,",")) ) {
|
if( (s=strpbrk(parstr,",")) ) {
|
||||||
filename = s+1;
|
filename = s+1;
|
||||||
*s = 0;
|
*s = 0;
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
ullong offs;
|
ullong offs;
|
||||||
ullong size;
|
ullong size;
|
||||||
|
int type;
|
||||||
} sunparts_info_t;
|
} sunparts_info_t;
|
||||||
|
|
||||||
DECLARE_NODE( sunparts, INSTALL_OPEN, sizeof(sunparts_info_t), "+/packages/sun-parts" );
|
DECLARE_NODE( sunparts, INSTALL_OPEN, sizeof(sunparts_info_t), "+/packages/sun-parts" );
|
||||||
@@ -93,15 +94,19 @@ sunparts_open( sunparts_info_t *di )
|
|||||||
int parnum = -1;
|
int parnum = -1;
|
||||||
unsigned char buf[512];
|
unsigned char buf[512];
|
||||||
struct sun_disklabel *p;
|
struct sun_disklabel *p;
|
||||||
unsigned int i;
|
unsigned int i, bs;
|
||||||
|
|
||||||
DPRINTF("sunparts_open '%s'\n", str );
|
DPRINTF("sunparts_open '%s'\n", str );
|
||||||
|
|
||||||
if( str ) {
|
if( str ) {
|
||||||
parnum = atol(str);
|
if( !strlen(str) )
|
||||||
if( !strlen(str) )
|
parnum = -1;
|
||||||
parnum = -1;
|
else if (str[0] >= 'a' && str[0] < ('a' + 8))
|
||||||
free( str );
|
parnum = str[0] - 'a';
|
||||||
|
else
|
||||||
|
parnum = atol(str);
|
||||||
|
|
||||||
|
free( str );
|
||||||
}
|
}
|
||||||
|
|
||||||
SEEK( 0 );
|
SEEK( 0 );
|
||||||
@@ -110,10 +115,11 @@ sunparts_open( sunparts_info_t *di )
|
|||||||
|
|
||||||
/* Check Magic */
|
/* Check Magic */
|
||||||
if (!has_sun_part_magic(buf)) {
|
if (!has_sun_part_magic(buf)) {
|
||||||
DPRINTF("sun partition magic not found.\n");
|
DPRINTF("Sun partition magic not found.\n");
|
||||||
RET(0);
|
RET(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bs = 512; // XXX get real block size?
|
||||||
/* get partition data */
|
/* get partition data */
|
||||||
p = (struct sun_disklabel *)buf;
|
p = (struct sun_disklabel *)buf;
|
||||||
|
|
||||||
@@ -125,10 +131,16 @@ sunparts_open( sunparts_info_t *di )
|
|||||||
parnum = i;
|
parnum = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
di->offs = (llong)__be32_to_cpu(p->partitions[parnum].start_cylinder) *
|
|
||||||
__be16_to_cpu(p->ntrks) * __be16_to_cpu(p->nsect);
|
|
||||||
|
|
||||||
di->size = (llong)__be32_to_cpu(p->partitions[parnum].num_sectors) ;
|
if (parnum < 0)
|
||||||
|
parnum = 0;
|
||||||
|
|
||||||
|
DPRINTF("Selected partition %d\n", parnum);
|
||||||
|
di->offs = (llong)__be32_to_cpu(p->partitions[parnum].start_cylinder) *
|
||||||
|
__be16_to_cpu(p->ntrks) * __be16_to_cpu(p->nsect) * bs;
|
||||||
|
|
||||||
|
di->size = (llong)__be32_to_cpu(p->partitions[parnum].num_sectors) * bs;
|
||||||
|
di->type = __be32_to_cpu(p->infos[parnum].id);
|
||||||
DPRINTF("Found Sun partition table, offs %d size %d\n", (int)di->offs, (int)di->size);
|
DPRINTF("Found Sun partition table, offs %d size %d\n", (int)di->offs, (int)di->size);
|
||||||
|
|
||||||
RET( -1 );
|
RET( -1 );
|
||||||
@@ -147,7 +159,8 @@ sunparts_probe( __attribute__((unused))sunparts_info_t *dummy )
|
|||||||
static void
|
static void
|
||||||
sunparts_get_info( sunparts_info_t *di )
|
sunparts_get_info( sunparts_info_t *di )
|
||||||
{
|
{
|
||||||
PUSH( -1 ); /* no type */
|
DPRINTF("Sun get_info\n");
|
||||||
|
PUSH( di->type );
|
||||||
DPUSH( di->offs );
|
DPUSH( di->offs );
|
||||||
DPUSH( di->size );
|
DPUSH( di->size );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user