예제 #1
0
Klib::MemoryMap::MemoryMap(int *fd_, uint32_t dev_addr, uint32_t size_)
{
    size = size_;
    fd = fd_;

    if(dev_addr != 0x0) {
        mapped_base = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, *fd, 
                           dev_addr & ~MAP_MASK(size) );

        if(mapped_base == (void *) -1) {
            fprintf(stderr, "Can't map the memory to user space.\n");
            close(*fd);
            status = MEMMAP_FAILURE;
            return;
        }

        status = MEMMAP_OPENED;

        // Device base address
        mapped_dev_base = (intptr_t)mapped_base + (dev_addr & MAP_MASK(size));
    } else {
        status = MEMMAP_CLOSED;
        mapped_base = NULL;
        mapped_dev_base = 0;
    }
}
예제 #2
0
/**Function*************************************************************

  Synopsis    [Sets up the mask.]

  Description []

  SideEffects []

  SeeAlso     []

***********************************************************************/
void Map_MappingSetupMask( unsigned uMask[], int nVarsMax )
{
    if ( nVarsMax == 6 )
        uMask[0] = uMask[1] = MAP_FULL;
    else
    {
        uMask[0] = MAP_MASK(1 << nVarsMax);
        uMask[1] = 0;
    }
}
예제 #3
0
/**Function*************************************************************

  Synopsis    [Expand the truth table]

  Description []

  SideEffects []

  SeeAlso     []

***********************************************************************/
void Map_MappingExpandTruth( unsigned uTruth[2], int nVars )
{
    assert( nVars < 7 );
    if ( nVars == 6 )
        return;
    if ( nVars < 5 )
    {
        uTruth[0] &= MAP_MASK( (1<<nVars) );
        uTruth[0]  = Map_MappingExpandTruth_rec( uTruth[0], nVars );
    }
    uTruth[1] = uTruth[0];
}