Author: blueswirl Date: 2009-07-31 13:10:38 +0200 (Fri, 31 Jul 2009) New Revision: 513
Modified: trunk/openbios-devel/arch/ppc/qemu/methods.c trunk/openbios-devel/arch/ppc/qemu/ofmem.c trunk/openbios-devel/include/ofmem.h Log: Use ucell type to pass ofmem arguments (Igor Kovalenko)
Modified: trunk/openbios-devel/arch/ppc/qemu/methods.c =================================================================== --- trunk/openbios-devel/arch/ppc/qemu/methods.c 2009-07-20 06:52:23 UTC (rev 512) +++ trunk/openbios-devel/arch/ppc/qemu/methods.c 2009-07-31 11:10:38 UTC (rev 513) @@ -241,9 +241,9 @@ static void mmu_translate( void ) { - int mode; - int virt = POP(); - int phys = ofmem_translate( virt, &mode ); + ucell mode; + ucell virt = POP(); + ucell phys = ofmem_translate( virt, &mode );
if( phys == -1 ) { PUSH( 0 );
Modified: trunk/openbios-devel/arch/ppc/qemu/ofmem.c =================================================================== --- trunk/openbios-devel/arch/ppc/qemu/ofmem.c 2009-07-20 06:52:23 UTC (rev 512) +++ trunk/openbios-devel/arch/ppc/qemu/ofmem.c 2009-07-31 11:10:38 UTC (rev 513) @@ -37,21 +37,21 @@
typedef struct alloc_desc { struct alloc_desc *next; - int size; /* size (including) this struct */ + ucell size; /* size (including) this struct */ } alloc_desc_t;
typedef struct mem_range { struct mem_range *next; - ulong start; - ulong size; + ucell start; + ucell size; } range_t;
typedef struct trans { struct trans *next; - ulong virt; /* chain is sorted by virt */ - ulong size; - ulong phys; - int mode; + ucell virt; /* chain is sorted by virt */ + ucell size; + ucell phys; + ucell mode; } translation_t;
typedef struct { @@ -236,8 +236,8 @@ /************************************************************************/
extern char _start[], _end[]; -static inline int -def_memmode( ulong phys ) +static inline ucell +def_memmode( ucell phys ) { /* XXX: Guard bit not set as it should! */ if( phys < IO_BASE ) @@ -251,7 +251,7 @@ /************************************************************************/
static int -is_free( ulong ea, ulong size, range_t *r ) +is_free( ucell ea, ucell size, range_t *r ) { if( size == 0 ) return 1; @@ -265,7 +265,7 @@ }
static void -add_entry_( ulong ea, ulong size, range_t **r ) +add_entry_( ucell ea, ucell size, range_t **r ) { range_t *nr;
@@ -279,7 +279,7 @@ }
static int -add_entry( ulong ea, ulong size, range_t **r ) +add_entry( ucell ea, ucell size, range_t **r ) { if( !is_free( ea, size, *r ) ) { printk("add_entry: range not free!\n"); @@ -310,20 +310,20 @@ }
static void -fill_range( ulong ea, int size, range_t **rr ) +fill_range( ulong ea, ucell size, range_t **rr ) { add_entry_( ea, size, rr ); join_ranges( rr ); }
-static ulong -find_area( ulong align, ulong size, range_t *r, ulong min, ulong max, int reverse ) +static ucell +find_area( ucell align, ucell size, range_t *r, ucell min, ucell max, int reverse ) { - ulong base = min; + ucell base = min; range_t *r2;
if( (align & (align-1)) ) { - printk("bad alignment %ld\n", align); + printk("bad alignment %d\n", align); align = 0x1000; } if( !align ) @@ -362,11 +362,11 @@ base = r2->start - size; } } - return (ulong)-1; + return (ucell)-1; }
-static ulong -ofmem_claim_phys_( ulong phys, ulong size, ulong align, int min, int max, int reverse ) +static ucell +ofmem_claim_phys_( ucell phys, ucell size, ucell align, ucell min, ucell max, int reverse ) { ofmem_t *ofmem = OFMEM; if( !align ) { @@ -387,15 +387,15 @@ }
/* if align != 0, phys is ignored. Returns -1 on error */ -ulong -ofmem_claim_phys( ulong phys, ulong size, ulong align ) +ucell +ofmem_claim_phys( ucell phys, ucell size, ucell align ) { /* printk("+ ofmem_claim phys %08lx %lx %ld\n", phys, size, align ); */ return ofmem_claim_phys_( phys, size, align, 0, get_ram_size(), 0 ); }
-static ulong -ofmem_claim_virt_( ulong virt, ulong size, ulong align, int min, int max, int reverse ) +static ucell +ofmem_claim_virt_( ucell virt, ucell size, ucell align, ucell min, ucell max, int reverse ) { ofmem_t *ofmem = OFMEM; if( !align ) { @@ -416,8 +416,8 @@ return virt; }
-ulong -ofmem_claim_virt( ulong virt, ulong size, ulong align ) +ucell +ofmem_claim_virt( ucell virt, ucell size, ucell align ) { /* printk("+ ofmem_claim virt %08lx %lx %ld\n", virt, size, align ); */ return ofmem_claim_virt_( virt, size, align, get_ram_size() , IO_BASE, 0 ); @@ -425,12 +425,12 @@
/* allocate both physical and virtual space and add a translation */ -ulong -ofmem_claim( ulong addr, ulong size, ulong align ) +ucell +ofmem_claim( ucell addr, ucell size, ucell align ) { ofmem_t *ofmem = OFMEM; - ulong virt, phys; - ulong offs = addr & 0xfff; + ucell virt, phys; + ucell offs = addr & 0xfff;
/* printk("+ ofmem_claim %08lx %lx %ld\n", addr, size, align ); */ virt = phys = 0; @@ -496,7 +496,7 @@ }
static int -map_page_range( ulong virt, ulong phys, ulong size, int mode ) +map_page_range( ucell virt, ucell phys, ucell size, ucell mode ) { ofmem_t *ofmem = OFMEM; translation_t *t, **tt; @@ -508,7 +508,7 @@ for( t=ofmem->trans; t; ) { if( virt == t->virt || (virt < t->virt && virt + size > t->virt )) { if( t->phys + virt - t->virt != phys ) { - printk("mapping altered (ea %08lx)\n", t->virt ); + printk("mapping altered (ea %08x)\n", t->virt ); } else if( t->mode != mode ){ printk("mapping mode altered\n"); } @@ -538,7 +538,7 @@ }
int -ofmem_map( ulong phys, ulong virt, ulong size, int mode ) +ofmem_map( ucell phys, ucell virt, ucell size, ucell mode ) { ofmem_t *ofmem = OFMEM; /* printk("+ofmem_map: %08lX --> %08lX (size %08lX, mode 0x%02X)\n", @@ -563,14 +563,14 @@ }
/* virtual -> physical. */ -ulong -ofmem_translate( ulong virt, int *mode ) +ucell +ofmem_translate( ucell virt, ucell *mode ) { ofmem_t *ofmem = OFMEM; translation_t *t;
for( t=ofmem->trans; t && t->virt <= virt ; t=t->next ) { - ulong offs; + ucell offs; if( t->virt + t->size - 1 < virt ) continue; offs = virt - t->virt; @@ -585,7 +585,7 @@
/* release memory allocated by ofmem_claim */ void -ofmem_release( ulong virt, ulong size ) +ofmem_release( ucell virt, ucell size ) { /* printk("ofmem_release unimplemented (%08lx, %08lx)\n", virt, size ); */ } @@ -595,10 +595,10 @@ /* page fault handler */ /************************************************************************/
-static ulong -ea_to_phys( ulong ea, int *mode ) +static ucell +ea_to_phys( ucell ea, ucell *mode ) { - ulong phys; + ucell phys;
if (ea >= 0xfff00000UL) { /* ROM into RAM */ @@ -621,7 +621,7 @@ }
static void -hash_page_64( ulong ea, ulong phys, int mode ) +hash_page_64( ucell ea, ucell phys, ucell mode ) { static int next_grab_slot=0; uint64_t vsid_mask, page_mask, pgidx, hash; @@ -687,7 +687,7 @@ }
static void -hash_page_32( ulong ea, ulong phys, int mode ) +hash_page_32( ucell ea, ucell phys, ucell mode ) { static int next_grab_slot=0; ulong *upte, cmp, hash1; @@ -734,7 +734,7 @@ return ((pvr >= 0x330000) && (pvr < 0x70330000)); }
-static void hash_page( ulong ea, ulong phys, int mode ) +static void hash_page( ulong ea, ulong phys, ucell mode ) { if ( is_ppc64() ) hash_page_64(ea, phys, mode); @@ -746,8 +746,8 @@ dsi_exception( void ) { ulong dar, dsisr; - int mode; - ulong phys; + ucell mode; + ucell phys;
asm volatile("mfdar %0" : "=r" (dar) : ); asm volatile("mfdsisr %0" : "=r" (dsisr) : ); @@ -760,8 +760,8 @@ isi_exception( void ) { ulong nip, srr1; - int mode; - ulong phys; + ucell mode; + ucell phys;
asm volatile("mfsrr0 %0" : "=r" (nip) : ); asm volatile("mfsrr1 %0" : "=r" (srr1) : );
Modified: trunk/openbios-devel/include/ofmem.h =================================================================== --- trunk/openbios-devel/include/ofmem.h 2009-07-20 06:52:23 UTC (rev 512) +++ trunk/openbios-devel/include/ofmem.h 2009-07-31 11:10:38 UTC (rev 513) @@ -20,14 +20,14 @@ extern void ofmem_cleanup( void ); extern void ofmem_init( void );
-extern ulong ofmem_claim( ulong addr, ulong size, ulong align ); -extern ulong ofmem_claim_phys( ulong mphys, ulong size, ulong align ); -extern ulong ofmem_claim_virt( ulong mvirt, ulong size, ulong align ); +extern ucell ofmem_claim( ucell addr, ucell size, ucell align ); +extern ucell ofmem_claim_phys( ucell mphys, ucell size, ucell align ); +extern ucell ofmem_claim_virt( ucell mvirt, ucell size, ucell align );
-extern int ofmem_map( ulong phys, ulong virt, ulong size, int mode ); +extern int ofmem_map( ucell phys, ucell virt, ucell size, ucell mode );
-extern void ofmem_release( ulong virt, ulong size ); -extern ulong ofmem_translate( ulong virt, int *ret_mode ); +extern void ofmem_release( ucell virt, ucell size ); +extern ucell ofmem_translate( ucell virt, ucell *ret_mode );
#ifdef CONFIG_PPC #define PAGE_SHIFT 12