Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Trying to set the Endianness of a page on PPC 8548E: (1 Item)
   
Trying to set the Endianness of a page on PPC 8548E  
 

 

 

Hi

 

Im running 6.4.1 on a PPC8548E. 

 

Im trying to use the function shm_ctl_special  to change the endianness
of a page in memory from Big to Little Endian.

 

I've tried some test code (see code that follows)  which is mostly based
on the sample code for the similar function shm_ctl.  

 

The call to shm_ctl_special seems to have no effect.  I tried the
shm_ctl_special call with and without the parameter  "PPC_SPECIAL_E".  

 

After the call to shm_ctl_special, I read a 32 bit value from the
selected address (ptr) to the variable 'dataRead' and whether I set the
PPC_SPECIAL_E  bit or not the value of 'dataRead' does not change.

 

Ive also tried it with different physical addresses.  0xd0000000 is a
PCIe address space on our board.  Ive also tried it with 0xff0000000
which is our flash area. 

 

 

Any help would be greatly appreciated. 

 

Brian

 

 

 

 

 

#define PPC_SPECIAL_E         0x0001

#define PPC_SPECIAL_G         0x0002

#define PPC_SPECIAL_M         0x0004

#define PPC_SPECIAL_I         0x0008

#define PPC_SPECIAL_W         0x0010

 

 

 

void testEndianBit ()

{

 

    int         fd, memsize;

    char        *ptr, *name;

    uint64_t    physaddr;

    int         dataRead;

 

 

 

 

 

    name = "/wally";

    physaddr = 0xd0000000;

 

    memsize = sysconf( _SC_PAGE_SIZE );

 

 

    /* map in the physical memory */

 

    ptr = mmap_device_memory( NULL, memsize, PROT_READ|PROT_NOCACHE, 0,
physaddr );

    if ( ptr == MAP_FAILED ) {

        printf( "%s: mmap_device_memory for physical address %llx
failed: %s\n",

            progname, physaddr, strerror(errno) );

        exit( EXIT_FAILURE );

    }

 

    /* open the shared memory object, create it if it doesn't exist */

 

    fd = shm_open( name, O_RDWR | O_CREAT, 0 );

    if ( fd == -1 ) {

        printf( "%s: error creating the shared memory object '%s':
%s\n",

                progname, name, strerror(errno) );

        exit( EXIT_FAILURE );

    }

 

 

    if ( shm_ctl_special( fd, SHMCTL_PHYS  , physaddr, memsize,
PPC_SPECIAL_E | PPC_SPECIAL_I | PPC_SPECIAL_W) == -1 )

      {

        printf( "%s: shm_ctl spec failed: %s\n", progname,
strerror(errno) );

        close( fd );

        munmap( ptr, memsize );

        shm_unlink( name );

        exit( EXIT_FAILURE );

      }

    else

        printf ("special passed\n");

 

    dataRead = * ((int *)ptr);

 

 

    /*

     * The memory object remains in

     * the system after the close

     */

    close( fd );

 

    /*

     * To remove a memory object

     * you must unlink it like a file.

     *

     * This may be done by another process.

     */

    shm_unlink( name );

    munmap( ptr, memsize );

 

    return EXIT_SUCCESS;

 

}