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:
Blue Swirl
2007-10-16 20:59:36 +00:00
parent 11b1459885
commit a62aba86c6
3 changed files with 43 additions and 23 deletions

View File

@@ -20,7 +20,7 @@
#include "modules.h" #include "modules.h"
typedef struct { typedef struct {
ducell mark; ucell mark_hi, mark_lo;
xt_t read_xt; xt_t read_xt;
xt_t write_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) */ /* -1 means seek to EOF (at least in our implementation) */
if( (dcell)mark == -1 ) if( (dcell)mark == -1 )
RET(-1); RET(-1);
di->mark = mark; di->mark_hi = pos_hi;
di->mark_lo = pos_lo;
/* 0,1 == success, -1 == error */ /* 0,1 == success, -1 == error */
PUSH(0); PUSH(0);
@@ -89,7 +90,8 @@ deblk_seek( deblk_info_t *di )
static void static void
deblk_tell( deblk_info_t *di ) 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 static void
split( deblk_info_t *di, char *data, int len, work_t w[3] ) 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]) ); 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].blk_buf = di->buf;
w[0].data = data; w[0].data = data;
if( w[0].offs ) { if( w[0].offs ) {
@@ -141,13 +144,14 @@ do_readwrite( deblk_info_t *di, int is_write, xt_t xt )
char *dest = (char*)POP(); char *dest = (char*)POP();
int last=0, retlen=0; int last=0, retlen=0;
work_t w[3]; work_t w[3];
ducell mark = ((ducell)di->mark_hi << BITS) | di->mark_lo;
/* printk("read: %x %x\n", (int)dest, len ); */ /* printk("read: %x %x\n", (int)dest, len ); */
if( !xt ) if( !xt )
return -1; return -1;
blk = di->mark / di->blksize; blk = mark / di->blksize;
split( di, dest, len, w ); split( di, dest, len, w );
for( i=0; !last && i<3; i++ ) { 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; retlen += w[i].len;
blk += n; blk += n;
} }
if( retlen > 0 ) if( retlen > 0 ) {
di->mark += retlen; mark += retlen;
di->mark_hi = mark >> BITS;
di->mark_lo = mark & (ucell) -1;
}
return retlen; return retlen;
} }

View File

@@ -22,8 +22,8 @@
typedef struct { typedef struct {
int fd; int fd;
ducell offs; ucell offs_hi, offs_lo;
ducell size; ucell size_hi, size_lo;
int type; /* partition type or -1 */ int type; /* partition type or -1 */
ihandle_t part_ih; ihandle_t part_ih;
@@ -94,8 +94,10 @@ dlabel_open( dlabel_info_t *di )
if( !(xt=find_ih_method("get-info", di->part_ih)) ) if( !(xt=find_ih_method("get-info", di->part_ih)) )
goto out; goto out;
call_package( xt , di->part_ih ); call_package( xt , di->part_ih );
di->size = DPOP(); di->size_hi = POP();
di->offs = DPOP(); di->size_lo = POP();
di->offs_hi = POP();
di->offs_lo = POP();
di->type = POP(); di->type = POP();
} }
@@ -139,12 +141,14 @@ dlabel_seek( dlabel_info_t *di )
{ {
llong pos = DPOP(); llong pos = DPOP();
int ret; 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 ) if( pos != -1 )
pos += di->offs; pos += offs;
else if( di->size ) { else if( size ) {
/* printk("Seek EOF\n"); */ /* printk("Seek EOF\n"); */
pos = di->offs + di->size; pos = offs + size;
} else { } else {
/* let parent handle the EOF seek. */ /* let parent handle the EOF seek. */
} }
@@ -159,8 +163,9 @@ static void
dlabel_tell( dlabel_info_t *di ) dlabel_tell( dlabel_info_t *di )
{ {
llong pos = tell( di->fd ); llong pos = tell( di->fd );
ducell offs = ((ducell)di->offs_hi << BITS) | di->offs_lo;
if( pos != -1 ) if( pos != -1 )
pos -= di->offs; pos -= offs;
DPUSH( pos ); DPUSH( pos );
} }
@@ -179,7 +184,8 @@ static void
dlabel_offset( dlabel_info_t *di ) dlabel_offset( dlabel_info_t *di )
{ {
ullong rel = DPOP(); ullong rel = DPOP();
rel += di->offs; ducell offs = ((ducell)di->offs_hi << BITS) | di->offs_lo;
rel += offs;
DPUSH( rel ); DPUSH( rel );
} }

View File

@@ -25,8 +25,8 @@
#endif #endif
typedef struct { typedef struct {
ullong offs; ucell offs_hi, offs_lo;
ullong size; ucell size_hi, size_lo;
int type; int type;
} sunparts_info_t; } sunparts_info_t;
@@ -95,6 +95,7 @@ sunparts_open( sunparts_info_t *di )
unsigned char buf[512]; unsigned char buf[512];
struct sun_disklabel *p; struct sun_disklabel *p;
unsigned int i, bs; unsigned int i, bs;
ducell offs, size;
DPRINTF("sunparts_open '%s'\n", str ); DPRINTF("sunparts_open '%s'\n", str );
@@ -136,12 +137,16 @@ sunparts_open( sunparts_info_t *di )
parnum = 0; parnum = 0;
DPRINTF("Selected partition %d\n", parnum); 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; __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); 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 ); RET( -1 );
} }
@@ -161,8 +166,10 @@ sunparts_get_info( sunparts_info_t *di )
{ {
DPRINTF("Sun get_info\n"); DPRINTF("Sun get_info\n");
PUSH( di->type ); PUSH( di->type );
DPUSH( di->offs ); PUSH( di->offs_lo );
DPUSH( di->size ); PUSH( di->offs_hi );
PUSH( di->size_lo );
PUSH( di->size_hi );
} }
static void static void