Справочник Пользователя для UTStarcom MSG2000

Скачать
Страница из 278
  
Page
 
2-35
CC06786-11B
Confidential and Proprietary
Technical Overview
1
4
AB
AB
Preliminary
To access the PSRAM from user level in Linux, use the mmap system call as shown 
in the following code segment.
1.
The start physical address and size of PSRAM on per XLR
Note, for PSRAM, the start address is 0x19000000, the size is 16384KB.
2.
Call system API "mmap" to transform physical address to virtual address. For 
example:
3.
Then you can access PSRAM as same as accessing system memory.
PP50-1 $ iobus
IOBus Devices:
BaseAddr        Size(KB)        ChipSel Device
=============================================================================
0xbc000000       16384            0     cfiflash_0
0xb8000000       16384            3     cfiflash_1
0x19000000       16384            4     psram
0x1d000000        8192            6     pcmcia
0x1d840000          64            1     cpld
volatile u16 *psram_mmap(u32 addr, u32 size)
{
    int fd=-1;
    volatile u16 *mAddr=NULL;
    if (0 > (fd = open("/dev/mem", O_RDWR|O_SYNC)))
    {
       if(debug)
       {
           printf("Open /dev/mem error!\n");
       }
       return NULL;
    }
    if (MAP_FAILED == (mAddr = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_SHARED, 
fd, addr)))
    {
        if(debug)
        {
            printf("mmap /dev/mem error!\n");
        }
        close(fd);
        return NULL;
    }
    close(fd);
    return mAddr;
}