ASIM_APE_CLASS::ASIM_APE_CLASS ( const char *n) : ASIM_SYSTEM_CLASS(n), statCycles(0), statRetired(0), sysBreak(false) { for (UINT32 i=0;i<NUM_HWCS_PER_CPU;i++) { my_tpu[i] = NULL; } my_driver = new DRIVER_CLASS(this,"DRIVER"); // // Initialize the system and driver // InitModule(); my_driver->InitModule(); /* allow as many cpu instructions as we can possibly buffer */ ASIM_INST_CLASS::SetMaxObjs(MAX_INST_BUF_SZ * NUM_HWCS_PER_CPU); // instantiate ASIM configuration config = new ASIM_CONFIG_CLASS(this); config->RegisterSimulatorConfiguration(); }
//Implementation of Initialize routine. static BOOL ModMgrInit(__MODULE_MGR* lpThis) { int i = 0; CHAR Buffer[128]; BOOL bResult = FALSE; if(NULL == lpThis) { return FALSE; } //Initialize static kernel module(s). while(TRUE) { if(0 == KernelModule[i].dwLoadAddress) { break; } bResult = InitModule(KernelModule[i].InitRoutine); if(!bResult) { sprintf(Buffer," The module with start address 0x%08X can not be initialized.", KernelModule[i].dwLoadAddress); PrintLine(Buffer); } i += 1; } return TRUE; }
bool rApplication::Init(){ int sdlInit = SDL_Init(SDL_INIT_VIDEO); if (sdlInit < 0){ rLog::Error("Error Initializing SDL: %i", sdlInit); return false; } if (SDL_SetVideoMode(m_displaySize.x, m_displaySize.y, 0, SDL_OPENGL) == 0){ rLog::Error("Error Setting SDL OpenGL Video Mode"); return false; } m_graphicsDevice = new rSDLGraphicsDevice(); m_contentManager = new rOpenGLContentManager(m_graphicsDevice); m_inputManager = new rSDLInputManager(); InitEngine(m_graphicsDevice, m_contentManager, m_inputManager); InitModule(); return true; }
//------------------------------------------------------------------------ bool bundleEntry (CFBundleRef ref) { if (ref) { bundleRefCounter++; CFRetain (ref); // hold all bundle refs until plug-in is fully uninitialized gBundleRefs.push_back (ref); if (!moduleHandle) { ghInst = ref; moduleHandle = ref; // optain the bundle path CFURLRef tempURL = CFBundleCopyBundleURL (ref); CFURLGetFileSystemRepresentation (tempURL, true, (UInt8*)gPath, MAX_PATH); CFRelease (tempURL); } } return InitModule (); }
int main(int argc, char* argv[]) { int i; HRESULT hr; IFCSessions* pISessions = NULL; bool bOk = false; FC_CString jot; FC_CStrList deleteFileList; CMDL_INPUT cmdl; if(DumpLogoAndHelp(argc, argv)) return 0; if(!ParseCmdLine(argc, argv, &cmdl)) return 1; //need COINIT_MULTITHREADED, otherwise IFCSession object won't work: hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); if(FAILED(hr)) { _tprintf("4dl: fatal error: CoInitialize failed: hr=%x\n" , hr); goto error; } // This provides a NULL DACL which will allow access to everyone. hr = ::CoInitializeSecurity(NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_NONE, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL); if(FAILED(hr)) { _tprintf("4dl: fatal error: CoInitializeSecurity failed: hr=%x\n" , hr); goto error; } InitModule(); //create the sessions interface hr = CoCreateInstance(CLSID_FCSessions, NULL, CLSCTX_ALL, IID_IFCSessions, (void**)&pISessions); if(FAILED(hr)) { _tprintf("4dl: fatal error: CoCreateInstance for CLSID_FCSessions failed: hr=%x\n", hr); goto error; } SetConsoleCtrlHandler(HandlerRoutine, TRUE); if(cmdl.bMergeOnly && cmdl.destDirMerged.isEmpty()) cmdl.destDirMerged.load(_T(".")); //HACK otherwise .merged gets deleted.. if(cmdl.safe4PL.getUsed()>0) { const TCHAR* pszTrgName = cmdl.trgNames.get(0); const TCHAR* pszTrgAddr = cmdl.connectStr.get(0); const TCHAR* psz4PL; CConnection cnt(pISessions, pszTrgName, pszTrgAddr, cmdl.pszPassWord); if(cmdl.nVerbose>=1) _tprintf(_T("4dl: safe parameter: stop resource\n")); long lKey; IControlMgt* pCtrlMgt = cnt.getCtrlMgt(&lKey); if(!pCtrlMgt) goto error; hr = pCtrlMgt->PauseResource(lKey); if(FAILED(hr)) { _tprintf(_T("4dl: error: stop resource failed: hr=0x%x\n"), hr); goto error; } for(i=0; i<cmdl.safe4PL.getUsed();i++) { if(g_bForceShutdown) goto error; psz4PL = cmdl.safe4PL.get(i); if(cmdl.uploadDestDir.isEmpty()) jot.load(psz4PL)<<_T(".tmp"); else jot.load(cmdl.uploadDestDir)<<_T("\\")<<psz4PL; int iret = UploadParameter(&cnt, psz4PL, jot, cmdl.nVerbose, cmdl.nMaxGS); if(iret>0) { cmdl.download4PL.add(jot); if(cmdl.uploadDestDir.isEmpty()) deleteFileList.add(jot); } else if(iret==0) { _tprintf(_T("4dl: warning safe '%s': no such parameters in running control\n"), psz4PL); } else { goto error; } } } if(!cmdl.upload4PL.isEmpty()) { const TCHAR* pszTrgName = cmdl.trgNames.get(0); const TCHAR* pszTrgAddr = cmdl.connectStr.get(0); long lKey = 0; IControlMgt* pCtrlMgt = NULL; CConnection cnt(pISessions, pszTrgName, pszTrgAddr, cmdl.pszPassWord); if(cmdl.uploadDestDir.isEmpty()) jot.load(cmdl.upload4PL); else jot.load(cmdl.uploadDestDir)<<_T("\\")<<cmdl.upload4PL; if(g_bForceShutdown) goto error; if(cmdl.bStopTasksForUpload) { if(cmdl.nVerbose>=1) _tprintf(_T("4dl: upload parameter: stop all tasks\n")); pCtrlMgt = cnt.getCtrlMgt(&lKey); if(!pCtrlMgt) goto error; hr = pCtrlMgt->StopAllTasksOnResource(lKey); if(FAILED(hr)) { _tprintf(_T("4dl: error: stop all tasks failed: hr=0x%x\n"), hr); goto error; } } int iret = UploadParameter(&cnt, cmdl.upload4PL, jot, cmdl.nVerbose, cmdl.nMaxGS); if(cmdl.bStopTasksForUpload && pCtrlMgt) { if(cmdl.nVerbose>=1) _tprintf(_T("4dl: upload parameter: start all tasks\n")); hr = pCtrlMgt->StartAllTasksOnResource(lKey); if(FAILED(hr)) { _tprintf(_T("4dl: error: start all tasks failed: hr=0x%x\n"), hr); goto error; } } if(iret<1) { if(iret==0) { _tprintf(_T("4dl: error: upload '%s': no such parameters in running control\n"), cmdl.upload4PL.psz()); } goto error; } } if(cmdl.bDownload) { for(i=0;i<cmdl.trgNames.getUsed();i++) { FC_CStrList paramFilesMerged; const TCHAR* pszTrgName = cmdl.trgNames.get(i); if(g_bForceShutdown) goto error; if(!MergeTargetParameterFiles(pszTrgName, cmdl.loaderLists.get(i), &cmdl.download4PL, ¶mFilesMerged, cmdl.bMergeWarn, cmdl.nVerbose, cmdl.destDirMerged, &deleteFileList)) goto error; if(cmdl.bMergeOnly) continue; CConnection cnt(pISessions, pszTrgName, cmdl.connectStr.get(i), cmdl.pszPassWord); if(!cnt.openCommissioningSession()) goto error; if(!DownloadControl(&cnt, &cmdl, ¶mFilesMerged, cmdl.nVerbose, cmdl.nMaxGS)) goto error; if(cmdl.safe4PL.getUsed()>0) { if(cmdl.nVerbose>=1) _tprintf(_T("4dl: safe parameter: start resource\n")); long lKey; IControlMgt* pCtrlMgt = cnt.getCtrlMgt(&lKey); if(!pCtrlMgt) goto error; hr = pCtrlMgt->ContinueResource(lKey); if(FAILED(hr)) { _tprintf(_T("4dl: error: start resource failed: hr=0x%x\n"), hr); goto error; } } } if(cmdl.bMergeOnly)//HACK _tprintf(_T("4dl: merge completed successfully\n")); else _tprintf(_T("4dl: download completed successfully\n")); } bOk = true; error: if (pISessions) { pISessions->Shutdown_Gracefully(); pISessions->Release(); } CoUninitialize(); for(i=0; i<deleteFileList.getUsed(); i++) { if(!FC_Exist(deleteFileList.get(i))) continue; if(cmdl.nVerbose>=1) _tprintf(_T("4dl: delete file '%s'\n"), deleteFileList.get(i)); unlink(deleteFileList.get(i)); } return bOk ? 0 : 1; }
bool DllExport InitDll () ///< must be called from host right after loading dll { return InitModule (); }
/* * Initialize kernel and create/start initial task */ EXPORT void knl_t_kernel_main( T_CTSK *inittask ) { DISABLE_INTERRUPT; /* * Target-dependent initialization */ InitModule(cpu); InitModule(tkdev); /* * Each module initialization */ InitModule(task); #if CFN_MAX_SEMID > 0 #ifdef USE_FUNC_SEMAPHORE_INITIALIZE InitModule(semaphore); #endif #endif #if CFN_MAX_FLGID > 0 #ifdef USE_FUNC_EVENTFLAG_INITIALIZE InitModule(eventflag); #endif #endif #if CFN_MAX_MBXID > 0 #ifdef USE_FUNC_MAILBOX_INITIALIZE InitModule(mailbox); #endif #endif #if CFN_MAX_MBFID > 0 #ifdef USE_FUNC_MESSAGEBUFFER_INITIALIZE InitModule(messagebuffer); #endif #endif #if CFN_MAX_PORID > 0 #ifdef USE_FUNC_RENDEZVOUS_INITIALIZE InitModule(rendezvous); #endif #endif #if CFN_MAX_MTXID > 0 #ifdef USE_FUNC_MUTEX_INITIALIZE InitModule(mutex); #endif #endif #if CFN_MAX_MPLID > 0 #ifdef USE_FUNC_MEMORYPOOL_INITIALIZE InitModule(memorypool); #endif #endif #if CFN_MAX_MPFID > 0 #ifdef USE_FUNC_FIX_MEMORYPOOL_INITIALIZE InitModule(fix_memorypool); #endif #endif #if CFN_MAX_CYCID > 0 #ifdef USE_FUNC_CYCLICHANDLER_INITIALIZE InitModule(cyclichandler); #endif #endif #if CFN_MAX_ALMID > 0 #ifdef USE_FUNC_ALARMHANDLER_INITIALIZE InitModule(alarmhandler); #endif #endif #if CFN_MAX_SSYID > 0 #ifdef USE_FUNC_SUBSYSTEM_INITIALIZE InitModule(subsystem); #endif #endif InitModule(timer); /* * Create/start initial task */ knl_init_task_startup(inittask); knl_force_dispatch(); /* No return */ }