示例#1
0
void Static::InitStaticVars() {
  sizemap_.Init();
  span_allocator_.Init();
  span_allocator_.New(); // Reduce cache conflicts
  span_allocator_.New(); // Reduce cache conflicts
  stacktrace_allocator_.Init();
  // Do a bit of sanitizing: make sure central_cache is aligned properly
  CHECK_CONDITION((sizeof(central_cache_[0]) % 64) == 0);
  for (int i = 0; i < kNumClasses; ++i) {
    central_cache_[i].Init(i);
  }
  new ((void*)pageheap_memory_) PageHeap;
  DLL_Init(&sampled_objects_);
}
示例#2
0
void InitDevice(void)
{
    IntDisableAll();
    WDT_INIT();
    Digitals_Init();  
    ItcInit();
    NVM_FlashInit();
    CRM_Init();  
    TMR_Init();
    ASM_Init();
    UART1_Init();
    UART2_Init();
    SPI_Init();
    MACA_Init(); 
    
///    DMAP_ResetStack(0);
  // WirelessHART Stack Initialisation
    NVM_ReadRecords(); // persistent data reading
    APP_Init();
    DLL_Init();   // reset the modem inside
    TL_Init();
    NET_Init();
    HART_DLL_Init(HART_ROLE_DECIDED);
  
  #if ( SHT1X_MODE != 0 )
    SHT1x_INIT();
  #endif
 
  #if ( (BOARD_TYPE == BOARD_TYPE_HART_DEV_KIT) )
    #if (!defined (IS_VN220))
      ADC_Extern_Init();
    #endif
  #endif
    
    IntEnableAll(); 
}    
示例#3
0
int main(int argc, char **argv)
{
	struct MsgPort *myport;
	char *PortName;
	dll_tMessage *msg;
	int expunge = FALSE;
	int opencount = 0;

	/*
	* If an argument was passed, use it as the port name,
	* otherwise use the program name
	*/
	if (argc > 1)
	{
		PortName = argv[1];
	}
	else
	{
		PortName = argv[0];
	}

	/*
	* Process symbol import table
	*/
	if (!dllImportSymbols())
	{
		D(bug("[DLL] %s: dllImportSymbols failed\n", PortName));
		//exit(0);
		return 0;
	}

	/*
	* Call DLL specific constructor
	*/
	if (!DLL_Init())
	{
		D(bug("[DLL] %s: DLL_Init failed\n", PortName));
		//exit(0);
		return 0;
	}

	/*
	* Create a (public) message port
	*/
	if (!(myport = CreatePort(PortName, 0)))
	{
		D(bug("[DLL] %s: can't create message port\n", PortName));
		//exit(0);
		return 0;
	}

	/*
	** Loop until DLL expunges (that is if a CloseMessage leads to opencount==0)
	** and no pending Messages are left
	*/
	while ((msg = (dll_tMessage *)GetMsg(myport)) || (!expunge))
	{
		if (msg)
		{
			switch (msg->dllMessageType)
			{
				case DLLMTYPE_Open:
					D(bug("[DLL] %s: received DLLMTYPE_Open\n", PortName));
					if (msg->dllMessageData.dllOpen.StackType != DLLSTACK_DEFAULT)
					{
						msg->dllMessageData.dllOpen.ErrorCode = DLLERR_StackNotSupported;
						if (opencount <= 0)
						{
							D(bug("[DLL] %s: unsupported stack type %d, expunging\n",
								PortName, msg->dllMessageData.dllOpen.StackType));
							expunge = TRUE;
						}
						break;
					}
					opencount++;
					D(bug("[DLL] %s: increased open count to %d\n", PortName, opencount));
					if (opencount > 0)
					{
						expunge = FALSE;
					}
					msg->dllMessageData.dllOpen.ErrorCode = DLLERR_NoError;
					break;

				case DLLMTYPE_Close:
					D(bug("[DLL] %s: received DLLMTYPE_Close\n", PortName));
					opencount--;
					D(bug("[DLL] %s: descreased open count to %d\n", PortName, opencount));
					if (opencount <= 0)
					{
						D(bug("[DLL] %s: open count is 0, expunging\n", PortName));
						expunge = TRUE;
					}
					break;

				case DLLMTYPE_SymbolQuery:
					D(bug("[DLL] %s: received DLLMTYPE_SymbolQuery\n", PortName));
					dllExportSymbol(&msg->dllMessageData.dllSymbolQuery);
					D(bug("[DLL] %s: result of symbol query for '%s': %p\n",
						PortName, msg->dllMessageData.dllSymbolQuery.SymbolName,
						*msg->dllMessageData.dllSymbolQuery.SymbolPointer));
					break;

				case DLLMTYPE_Kill:
					D(bug("[DLL] %s: received DLLMTYPE_Kill\n", PortName));
					expunge = TRUE;
					break;
			}

			/*
			* Send the message back
			*/
			D(bug("[DLL] %s: replying message\n", PortName));
			ReplyMsg((struct Message *)msg);
		}

		/*
		* Wait for messages to pop up
		* Note that if the DLL is expunged it doesn't wait anymore,
		* but it still processes all pending messages (including open messages
		* which can disable the expunge flag).
		* FIXME: Is this multithread safe ??
		*/
		if (!expunge)
		{
			D(bug("[DLL] %s: Waiting for message...\n", PortName));
			WaitPort(myport);
		}
	}

	/*
	* Delete public port
	*/
	DeletePort(myport);

	/*
	* Call DLL specific destructor
	*/
	DLL_DeInit();

	return 0;
}
示例#4
0
int main(int argc, char **argv)
{
    struct MsgPort *myport;
    char PortName[255];
    dll_tMessage *msg;
    int expunge=0L;
    int opencount=0L;

    bug("[DynFile] %s('%s')\n", __PRETTY_FUNCTION__, argv[0]);

    /*
     * If an argument was passed, use it as the port name,
     * otherwise use the program name
     */
    if (argc>1)
    {
        char *argPort = argv[1];

        if (argPort[0] == '"')
            strncpy(PortName, &argPort[1], strlen(argPort) - 2);
        else
            strcpy(PortName, argPort);
    }
    else
    {
        strcpy(PortName, argv[0]);
    }

    bug("[DynFile] %s: Portname '%s'\n", __PRETTY_FUNCTION__, PortName);
    /*
     * Process symbol import table
     */
    if(!dllImportSymbols())
        exit(0L);

    bug("[DynFile] %s: symbols imported\n", __PRETTY_FUNCTION__);

    /*
     * Call DLL specific constructor
     */
    if(!DLL_Init())
        exit(0L);

    bug("[DynFile] %s: initialised\n", __PRETTY_FUNCTION__);

    /*
     * Create a (public) message port
     */
    myport = CreatePort(PortName,0);
    if (!myport)
        exit(0l);

    bug("[DynFile] %s: port @ 0x%p\n", __PRETTY_FUNCTION__, myport);

    /*
    ** Loop until DLL expunges (that is if a CloseMessage leads to opencount==0)
    ** and no pending Messages are left
    */
    while((msg=(dll_tMessage *)GetMsg(myport))||(!expunge))
    {
        if (msg)
        {
            switch(msg->dllMessageType)
            {
            case DLLMTYPE_Open:
                    bug("[DynFile] %s: DLLMTYPE_Open\n", __PRETTY_FUNCTION__);
                    /*
                     * Stack type checking should go here. Might be ommited for strictly
                     * private DLLs, or when stack frame compatibility can be 100% assured.
                     * FIXME: Not handled for now
                     */
                    opencount++;
                    if(opencount>0)
                            expunge=0L;
                    msg->dllMessageData.dllOpen.ErrorCode=DLLERR_NoError;
                    break;

            case DLLMTYPE_Close:
                    bug("[DynFile] %s: DLLMTYPE_Close\n", __PRETTY_FUNCTION__);
                    opencount--;
                    if(opencount<=0L)    // <0 ????
                            expunge=1L;
                    break;

            case DLLMTYPE_SymbolQuery:
                    bug("[DynFile] %s: DLLMTYPE_SymbolQuery\n", __PRETTY_FUNCTION__);
                    dllExportSymbol(&msg->dllMessageData.dllSymbolQuery);
                    //printf("Symbol Query for %s : %p\n",msg->dllMessageData.dllSymbolQuery.SymbolName,
                    //                                    *msg->dllMessageData.dllSymbolQuery.SymbolPointer);
                    break;

            case DLLMTYPE_Kill:
                    bug("[DynFile] %s: DLLMTYPE_Kill\n", __PRETTY_FUNCTION__);
                    expunge=1L;
                    break;
            }

            /*
             * Send the message back
             */
            ReplyMsg((struct Message *)msg);
        }

        /*
         * Wait for messages to pop up
         * Note that if the DLL is expunged it doesn't wait anymore,
         * but it still processes all pending messages (including open messages
         * which can disable the expunge flag).
         * FIXME: Is this multithread safe ??
         */
        if(!expunge)
            WaitPort(myport);
    }

    /*
     * Delete public port
     */
    DeletePort(myport);

    /*
     * Call DLL specific destructor
     */
    DLL_DeInit();

    return 0L;
}