Beispiel #1
0
EMBX_ERROR STb5525_RegisterTransport(const char *name, EMBX_FACTORY *phFactory)
{
	void *physicalSharedAddr = (void *) 0x84200000;
	void *virtualSharedAddr = mmap_translate_virtual(physicalSharedAddr);
	void *uncachedSharedAddr = mmap_translate_uncached(virtualSharedAddr);

	EMBXSHM_GenericConfig_t config = {
		"shm",		/* name */
		0,			/* cpuID */
		{ 1, 1, 0, 0 },		/* participants */
		0,			/* pointerWarp */
		(void *) 0,		/* sharedAddr */
		2 * 1024 * 1024,	/* sharedSize */
		STb5525_NotifyFunction, /* interrupt knocking function */
		&STb5525_Context,	/* data structure used by above */
		0,			/* maxPorts */
		0,			/* maxObjects */
		0			/* freeListSize */
	};

	strcpy(config.name, name);
	config.sharedAddr = uncachedSharedAddr;

	if (IS_HOST()) {
		config.maxObjects = 64;
		config.freeListSize = 64;
	} else {
		config.cpuID = 1;

		STb5525_ReserveSharedMemory(physicalSharedAddr,
					    config.sharedSize);
	}
	
	return EMBX_RegisterTransport(EMBXSHM_generic_factory,
				      &config, sizeof(config), phFactory);
	
}
Beispiel #2
0
EMBX_VOID *EMBX_OS_PhysMemMap(EMBX_UINT pMem, int size, int cached)
{
    EMBX_VOID *vaddr = NULL;

    EMBX_Info(EMBX_INFO_OS, (">>>>PhysMemMap(0x%08x, %d)\n", (unsigned int) pMem, size));

    /* Test the weak symbol for being non NULL, if true we are linked against a vmem capable OS21 */
    if (vmem_create)
    {
      unsigned mode;

      mode = VMEM_CREATE_READ|VMEM_CREATE_WRITE;

      if (cached)
	  mode |= VMEM_CREATE_CACHED;
      else
	  mode |= VMEM_CREATE_UNCACHED | VMEM_CREATE_NO_WRITE_BUFFER;
      
      vaddr = vmem_create((EMBX_VOID *)pMem, size, NULL, mode);

    }
    else
    {
#if defined __ST231__
	  /* This assumes that pMem is a true physical address */
	  vaddr = mmap_translate_virtual((EMBX_VOID *)pMem);
	  vaddr = (cached ? mmap_translate_cached(vaddr) : mmap_translate_uncached(vaddr));
	  
	  if (!vaddr)
	  {
	      /* Failed to find a current translation, so create our own */

	      EMBX_UINT page_size = 0x10000000; /* Map 256MB pages unconditionally */
	      EMBX_UINT pMem_base = pMem & ~(page_size-1);
	      EMBX_UINT pMem_size = (size + (page_size-1)) & ~(page_size-1);

	      vaddr = mmap_create((void *)pMem_base, 
				  pMem_size,
				  mmap_protect_rwx, 
				  (cached ? mmap_cached : mmap_uncached),
				  page_size);
	      
	      /* Adjust the returned vaddr accordingly */
	      if (vaddr)
		  vaddr = (void *) ((EMBX_UINT) vaddr + (pMem - pMem_base));
	  }

#elif defined __sh__

      if (cached)
	  vaddr = ST40_P1_ADDR(pMem);
      else
	  vaddr = ST40_P2_ADDR(pMem);

#endif /* defined __ST231__ */
      
      if (NULL == vaddr) {
	  EMBX_DebugMessage(("PhysMemMap: pMem %p size %d cached %d failed\n", pMem, size, cached));
      }
    }

    EMBX_Info(EMBX_INFO_OS, ("PhysMemMap: *vMem = %p\n", vaddr));
    
    EMBX_Info(EMBX_INFO_OS, ("<<<<PhysMemMap\n"));
    
    return vaddr;
}