mirror of
https://gitlab.com/qemu-project/openbios.git
synced 2024-02-13 08:34:06 +08:00
Fix 8 byte alignment problems
git-svn-id: svn://coreboot.org/openbios/openbios-devel@171 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
#include "modules.h"
|
||||
|
||||
typedef struct {
|
||||
ducell mark;
|
||||
ucell mark_hi, mark_lo;
|
||||
xt_t read_xt;
|
||||
xt_t write_xt;
|
||||
|
||||
@@ -79,7 +79,8 @@ deblk_seek( deblk_info_t *di )
|
||||
/* -1 means seek to EOF (at least in our implementation) */
|
||||
if( (dcell)mark == -1 )
|
||||
RET(-1);
|
||||
di->mark = mark;
|
||||
di->mark_hi = pos_hi;
|
||||
di->mark_lo = pos_lo;
|
||||
|
||||
/* 0,1 == success, -1 == error */
|
||||
PUSH(0);
|
||||
@@ -89,7 +90,8 @@ deblk_seek( deblk_info_t *di )
|
||||
static void
|
||||
deblk_tell( deblk_info_t *di )
|
||||
{
|
||||
DPUSH( di->mark );
|
||||
PUSH( di->mark_lo );
|
||||
PUSH( di->mark_hi );
|
||||
}
|
||||
|
||||
|
||||
@@ -110,9 +112,10 @@ typedef struct {
|
||||
static void
|
||||
split( deblk_info_t *di, char *data, int len, work_t w[3] )
|
||||
{
|
||||
ducell mark = ((ducell)di->mark_hi << BITS) | di->mark_lo;
|
||||
memset( w, 0, sizeof(work_t[3]) );
|
||||
|
||||
w[0].offs = di->mark % di->blksize;
|
||||
w[0].offs = mark % di->blksize;
|
||||
w[0].blk_buf = di->buf;
|
||||
w[0].data = data;
|
||||
if( w[0].offs ) {
|
||||
@@ -141,13 +144,14 @@ do_readwrite( deblk_info_t *di, int is_write, xt_t xt )
|
||||
char *dest = (char*)POP();
|
||||
int last=0, retlen=0;
|
||||
work_t w[3];
|
||||
ducell mark = ((ducell)di->mark_hi << BITS) | di->mark_lo;
|
||||
|
||||
/* printk("read: %x %x\n", (int)dest, len ); */
|
||||
|
||||
if( !xt )
|
||||
return -1;
|
||||
|
||||
blk = di->mark / di->blksize;
|
||||
blk = mark / di->blksize;
|
||||
split( di, dest, len, w );
|
||||
|
||||
for( i=0; !last && i<3; i++ ) {
|
||||
@@ -174,8 +178,11 @@ do_readwrite( deblk_info_t *di, int is_write, xt_t xt )
|
||||
retlen += w[i].len;
|
||||
blk += n;
|
||||
}
|
||||
if( retlen > 0 )
|
||||
di->mark += retlen;
|
||||
if( retlen > 0 ) {
|
||||
mark += retlen;
|
||||
di->mark_hi = mark >> BITS;
|
||||
di->mark_lo = mark & (ucell) -1;
|
||||
}
|
||||
return retlen;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
typedef struct {
|
||||
int fd;
|
||||
|
||||
ducell offs;
|
||||
ducell size;
|
||||
ucell offs_hi, offs_lo;
|
||||
ucell size_hi, size_lo;
|
||||
int type; /* partition type or -1 */
|
||||
|
||||
ihandle_t part_ih;
|
||||
@@ -94,8 +94,10 @@ dlabel_open( dlabel_info_t *di )
|
||||
if( !(xt=find_ih_method("get-info", di->part_ih)) )
|
||||
goto out;
|
||||
call_package( xt , di->part_ih );
|
||||
di->size = DPOP();
|
||||
di->offs = DPOP();
|
||||
di->size_hi = POP();
|
||||
di->size_lo = POP();
|
||||
di->offs_hi = POP();
|
||||
di->offs_lo = POP();
|
||||
di->type = POP();
|
||||
}
|
||||
|
||||
@@ -139,12 +141,14 @@ dlabel_seek( dlabel_info_t *di )
|
||||
{
|
||||
llong pos = DPOP();
|
||||
int ret;
|
||||
ducell offs = ((ducell)di->offs_hi << BITS) | di->offs_lo;
|
||||
ducell size = ((ducell)di->size_hi << BITS) | di->size_lo;
|
||||
|
||||
if( pos != -1 )
|
||||
pos += di->offs;
|
||||
else if( di->size ) {
|
||||
pos += offs;
|
||||
else if( size ) {
|
||||
/* printk("Seek EOF\n"); */
|
||||
pos = di->offs + di->size;
|
||||
pos = offs + size;
|
||||
} else {
|
||||
/* let parent handle the EOF seek. */
|
||||
}
|
||||
@@ -159,8 +163,9 @@ static void
|
||||
dlabel_tell( dlabel_info_t *di )
|
||||
{
|
||||
llong pos = tell( di->fd );
|
||||
ducell offs = ((ducell)di->offs_hi << BITS) | di->offs_lo;
|
||||
if( pos != -1 )
|
||||
pos -= di->offs;
|
||||
pos -= offs;
|
||||
|
||||
DPUSH( pos );
|
||||
}
|
||||
@@ -179,7 +184,8 @@ static void
|
||||
dlabel_offset( dlabel_info_t *di )
|
||||
{
|
||||
ullong rel = DPOP();
|
||||
rel += di->offs;
|
||||
ducell offs = ((ducell)di->offs_hi << BITS) | di->offs_lo;
|
||||
rel += offs;
|
||||
DPUSH( rel );
|
||||
}
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
ullong offs;
|
||||
ullong size;
|
||||
ucell offs_hi, offs_lo;
|
||||
ucell size_hi, size_lo;
|
||||
int type;
|
||||
} sunparts_info_t;
|
||||
|
||||
@@ -95,6 +95,7 @@ sunparts_open( sunparts_info_t *di )
|
||||
unsigned char buf[512];
|
||||
struct sun_disklabel *p;
|
||||
unsigned int i, bs;
|
||||
ducell offs, size;
|
||||
|
||||
DPRINTF("sunparts_open '%s'\n", str );
|
||||
|
||||
@@ -136,12 +137,16 @@ sunparts_open( sunparts_info_t *di )
|
||||
parnum = 0;
|
||||
|
||||
DPRINTF("Selected partition %d\n", parnum);
|
||||
di->offs = (llong)__be32_to_cpu(p->partitions[parnum].start_cylinder) *
|
||||
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->offs_hi = offs >> BITS;
|
||||
di->offs_lo = offs & (ucell) -1;
|
||||
size = (llong)__be32_to_cpu(p->partitions[parnum].num_sectors) * bs;
|
||||
di->size_hi = size >> BITS;
|
||||
di->size_lo = size & (ucell) -1;
|
||||
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 %lld size %lld\n", offs, size);
|
||||
|
||||
RET( -1 );
|
||||
}
|
||||
@@ -161,8 +166,10 @@ sunparts_get_info( sunparts_info_t *di )
|
||||
{
|
||||
DPRINTF("Sun get_info\n");
|
||||
PUSH( di->type );
|
||||
DPUSH( di->offs );
|
||||
DPUSH( di->size );
|
||||
PUSH( di->offs_lo );
|
||||
PUSH( di->offs_hi );
|
||||
PUSH( di->size_lo );
|
||||
PUSH( di->size_hi );
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
Reference in New Issue
Block a user