/* Available in: irq, thread. */ TT_MSG_QUEUE_T *tt_msg_queue_init (void *msg_buffer, size_t msg_buffer_size) { TT_MSG_QUEUE_T *msg_queue; if (msg_buffer == NULL) return NULL; if (msg_buffer_size <= sizeof (TT_MSG_QUEUE_T)) return NULL; msg_queue = (TT_MSG_QUEUE_T *) msg_buffer; msg_buffer = (void *)((char *) msg_buffer + sizeof (TT_MSG_QUEUE_T)); msg_buffer_size -= sizeof (TT_MSG_QUEUE_T); msg_queue->msg_free = memInit (msg_buffer, msg_buffer_size, TT_MSG_T); if (msg_queue->msg_free == NULL) return NULL; msg_queue->max_msg_limit = listLength (msg_queue->msg_free); if (msg_queue->max_msg_limit <= 0) return NULL; msg_queue->msg_buffer = msg_buffer; msg_queue->msg_buffer_size = msg_buffer_size; listInit (&msg_queue->msg_used); tt_pc_init (&msg_queue->pc_semaphore, msg_queue->max_msg_limit); return msg_queue; }
/**************************************************************************//** \brief Performs memory initialization. \param[in] descriptor - pointer to hsmci descriptor. \return status of initialization procedure. ******************************************************************************/ MemoryStatus_t absMemInit(HAL_HsmciDescriptor_t *descriptor) { if (memSuccess != memInit(descriptor)) return memoryErrorStatus; return memorySuccessStatus; }
FieldData::FieldData(const GridInfo& gInfo, string category, int nElem, int nDoublesPerElem, bool onGpu) : nElem(nElem), scale(1.), gInfo(gInfo), isReal(nDoublesPerElem==1) { int nDoubles = nElem * nDoublesPerElem; int nComplex = ceildiv(nDoubles,2); memInit(category, nComplex, onGpu); }
void memCheckState() { if (!mInfo) memInit(); if (mInfo->state != MEM_STATE_OK){ fprintf (stderr,"\rMemory not initialized :p\n"); exit (0); } }
wrath_gluNewTess( void ) #endif { wrath_GLUtesselator *tess; /* Only initialize fields which can be changed by the api. Other fields * are initialized where they are used. */ if (memInit( MAX_FAST_ALLOC ) == 0) { return 0; /* out of memory */ } tess = (wrath_GLUtesselator *)memAlloc( sizeof( wrath_GLUtesselator )); if (tess == NULL) { return 0; /* out of memory */ } #if defined(WRATH_MALLOC_DEBUG) or defined(WRATH_NEW_DEBUG) { WRATHAutoLockMutex(tracker().m_mutex); tracker()[tess]=file_list_str(file, line); } #endif tess->state = T_DORMANT; tess->normal[0] = 0; tess->normal[1] = 0; tess->normal[2] = 0; tess->relTolerance = WRATH_GLU_TESS_DEFAULT_TOLERANCE; //tess->windingRule = WRATH_GLU_TESS_WINDING_ODD; tess->flagBoundary = FALSE; tess->boundaryOnly = FALSE; tess->callBegin = &noBegin; tess->callEdgeFlag = &noEdgeFlag; tess->callVertex = &noVertex; tess->callEnd = &noEnd; tess->callError = &noError; tess->callCombine = &noCombine; tess->callMesh = &noMesh; tess->callWinding= &noWinding; tess->callBeginData= &glu_wrath_gl_noBeginData; tess->callEdgeFlagData= &glu_wrath_gl_noEdgeFlagData; tess->callVertexData= &glu_wrath_gl_noVertexData; tess->callEndData= &glu_wrath_gl_noEndData; tess->callErrorData= &glu_wrath_gl_noErrorData; tess->callCombineData= &glu_wrath_gl_noCombineData; tess->callWindingData= &glu_wrath_gl_noWindingData; tess->polygonData= NULL; return tess; }
//Initialization void matrix::init(int nrows, int ncols, bool onGpu) { nr = nrows; nc = ncols; if(nr*nc>0) memInit("matrix", nr*nc, onGpu); }
// Construct from a complex diagonal matrix: matrix::matrix(const matrix3<>& m) { nr = 3; nc = 3; memInit("matrix", nr*nc); for(int j=0; j<3; j++) for(int i=0; i<3; i++) set(i,j, m(i,j)); }
// Construct from a complex diagonal matrix: matrix::matrix(const std::vector<complex>& d) { nr = d.size(); nc = d.size(); if(d.size()) { memInit("matrix", nr*nc); zero(); complex* thisData = data(); for(int i=0; i<nRows(); i++) thisData[index(i,i)] = d[i]; } }
USBHALHost::USBHALHost() { instHost = this; memInit(); memset((void*)usb_hcca, 0, HCCA_SIZE); for (int i = 0; i < MAX_ENDPOINT; i++) { edBufAlloc[i] = false; } for (int i = 0; i < MAX_TD; i++) { tdBufAlloc[i] = false; } }
void wsInit(const char* filename) { // Init memory emulation memInit(filename); // Init GPU gpuInit(); // Init I/O emulation ioInit(); // And reset everything wsReset(); }
// Called by other constructors to do the work void ColumnBundle::init(int nc, size_t len, const Basis *b, const QuantumNumber* q, bool onGpu) { ncols = nc; col_length = len; basis = b; qnum = q; if(nCols() == 0) { memFree(); return; } //must be default constructor or assignment to empty ColumnBundle myassert(colLength() != 0); memInit("ColumnBundle", nCols()*colLength(), onGpu); //in base class ManagedMemory }
GLU_API GLUtesselator* GLU_APIENTRY gluNewTess(void) { GLUtesselator* tess; /* Only initialize fields which can be changed by the api. Other fields * are initialized where they are used. */ if (memInit(MAX_FAST_ALLOC)==0) { return 0; /* out of memory */ } tess=(GLUtesselator*)memAlloc(sizeof(GLUtesselator)); if (tess==NULL) { return 0; /* out of memory */ } tess->state=T_DORMANT; tess->normal[0]=0; tess->normal[1]=0; tess->normal[2]=0; tess->relTolerance=GLU_TESS_DEFAULT_TOLERANCE; tess->windingRule=GLU_TESS_WINDING_ODD; tess->flagBoundary=FALSE; tess->boundaryOnly=FALSE; tess->callBegin=&noBegin; tess->callEdgeFlag=&noEdgeFlag; tess->callVertex=&noVertex; tess->callEnd=&noEnd; tess->callError=&noError; tess->callCombine=&noCombine; tess->callMesh=&noMesh; tess->callBeginData=&__gl_noBeginData; tess->callEdgeFlagData=&__gl_noEdgeFlagData; tess->callVertexData=&__gl_noVertexData; tess->callEndData=&__gl_noEndData; tess->callErrorData=&__gl_noErrorData; tess->callCombineData=&__gl_noCombineData; tess->polygonData=NULL; return tess; }
void usrRoot (char *pMemPoolStart, unsigned memPoolSize) { usrKernelCoreInit (); /* core kernel facilities */ cpuPwrFrameWorkInit ( CPU_PWR_TASK_P_STATE, CPU_PWR_ISR_P_STATE, CPU_PWR_UTIL_PERIOD1, CPU_PWR_UTIL_PERIOD2, CPU_PWR_HIGH_THRESHOLD, CPU_PWR_LOW_THRESHOLD ); /* CPU Power management framework Component */ cpuPwrLightMgrInit(); /* CPU Power Light utilization manager Component */ poolLibInit(); /* memory pools of fixed size items */ memInit (pMemPoolStart, memPoolSize, MEM_PART_DEFAULT_OPTIONS); /* full featured memory allocator */ memPartLibInit (pMemPoolStart, memPoolSize); /* core memory partition manager */ memInfoInit (); /* memory allocator info routines */ rtpHookLibInit (RTP_HOOK_TBL_SIZE); /* Add hook routines to be called on RTP operations. */ usrSysctlInit(); /* System control function */ usrHwSysctlInit(); /* System control hardware info registration */ rtpLibInit (RTP_HOOK_TBL_SIZE, SYSCALL_HOOK_TBL_SIZE, RTP_SIGNAL_QUEUE_SIZE, TASK_USER_EXC_STACK_OVERFLOW_SIZE, TASK_USER_EXEC_STACK_OVERFLOW_SIZE, TASK_USER_EXEC_STACK_UNDERFLOW_SIZE, RTP_FD_NUM_MAX); /* Real Time Process. */ sdLibInit (SD_HOOK_TBL_SIZE); /* provide data sharing between RTPs or kernel */ shlLibInit (); /* provide sharing of code between RTPs */ pgPoolLibInit(); /* Generic Page Pool Allocator */ pgPoolVirtLibInit(); /* Page Pool Allocator for Virtual Space */ pgPoolPhysLibInit(); /* Page Pool Allocator for Physical Space */ /* basic MMU component */ usrMmuInit ((VIRT_ADDR) pMemPoolStart, memPoolSize); /* MMU global map support */ usrTextProtect (); /* write-protect program text */ usrPmInit (); /* reboot-safe protected memory region manager */ usrEdrInit (); /* reboot-safe protected error log */ edrSystemDebugModeInit (); /* a flag indicating the system is in 'debug' mode */ pgMgrLibInit(); /* Page Manager Library */ usrKernelIntStkProtect(); /* insert underflow and overflow guard pages on interrupt stack */ taskStackGuardPageEnable(); /* insert underflow and overflow guard pages to kernel task stacks */ taskStackNoExecEnable(); /* enable non-executable kernel task stacks */ sysClkInit (); /* System clock component */ vxIpiLibInit (); /* Inter Processor Interrupts for SMP and AMP */ edrStubInit (); /* protected error log stub initialization */ /* Modified definitions for generalized coprocessor */ setLibInit (); /* sets of unspecified item types */ usrIosCoreInit (); /* core I/O system */ usrKernelExtraInit (); /* extended kernel facilities */ usrIosExtraInit (); /* extended I/O system */ sockLibInit (); /* Socket API */ usrNetworkInit (); /* Initialize the network subsystem */ selTaskDeleteHookAdd (); /* selectInit, part 2, install task delete hook */ cplusCtorsLink (); /* run compiler generated initialization functions at system startup */ usrCplusLibInit (); /* Basic support for C++ applications */ cplusDemanglerInit (); /* Support library for kernel shell and loader: provides human readable forms of C++ identifiers */ usrScInit (); /* The system call initialization sequence */ usrToolsInit (); /* software development tools */ usrAppInit (); /* call usrAppInit() (in your usrAppInit.c project file) after startup. */ usrRtpAppInitBootline (); /* Launch RTP from a string-encoded list in the boot parameters. */ }
fastuidraw_GLUtesselator * REGALFASTUIDRAW_GLU_CALL fastuidraw_gluNewTess_release( void ) { fastuidraw_GLUtesselator *tess; /* Only initialize fields which can be changed by the api. Other fields * are initialized where they are used. */ if (memInit( MAX_FAST_ALLOC ) == 0) { return 0; /* out of memory */ } tess = (fastuidraw_GLUtesselator *)memAlloc( sizeof( fastuidraw_GLUtesselator )); if (tess == NULL) { return 0; /* out of memory */ } tess->state = T_DORMANT; tess->relTolerance = FASTUIDRAW_GLU_TESS_DEFAULT_TOLERANCE; tess->boundaryOnly = FALSE; tess->callBegin = &noBegin; tess->callVertex = &noVertex; tess->callEnd = &noEnd; tess->callError = &noError; tess->callCombine = &noCombine; tess->callMesh = &noMesh; tess->callWinding= &noWinding; tess->callBeginData= &glu_fastuidraw_gl_noBeginData; tess->callVertexData= &glu_fastuidraw_gl_noVertexData; tess->callEndData= &glu_fastuidraw_gl_noEndData; tess->callErrorData= &glu_fastuidraw_gl_noErrorData; tess->callCombineData= &glu_fastuidraw_gl_noCombineData; tess->callWindingData= &glu_fastuidraw_gl_noWindingData; tess->polygonData= NULL; tess->fastuidraw_alloc_tracker = NULL; return tess; }
/*----------------------------------------------------------------------------- Name : llSystemsStartup Description : Start up systems required by program Inputs : Outputs : Return : ----------------------------------------------------------------------------*/ char *llSystemsStartup(void) { //memory utyMemoryHeap = (void *)GlobalAlloc(GPTR, MemoryHeapSize + sizeof(memcookie) * 4); if (utyMemoryHeap == NULL) { sprintf(errorString, "Error allocating heap of size %d", MemoryHeapSize); return(errorString); } if (memInit(utyMemoryHeap, MemoryHeapSize) != OKAY) { sprintf(errorString, "Error starting memory manager with heap size %d at 0x%x", MemoryHeapSize, errorString); return(errorString); } //allocate a blank element list return(NULL); }
int vmInit() { if((vm = (VM*)malloc(sizeof(VM))) == NULL) return 1; if((vm->cpu = (CPU*)malloc(cpuSizeof())) == NULL) { free(vm); return 1; } if((vm->mem = (Mem*)malloc(memSizeof())) == NULL) { free(vm); free(vm->cpu); return 1; } if(cpuInit(vm->cpu) != 0) { free(vm); free(vm->cpu); free(vm->mem); return 1; } if(memInit(vm->mem) != 0) { free(vm); free(vm->cpu); free(vm->mem); return 1; } return 0; }
void systemTask(void *arg) { bool pass = true; ledInit(); ledSet(CHG_LED, 1); uartInit(); //Init the high-levels modules systemInit(); #ifndef USE_RADIOLINK_CRTP #ifdef UART_OUTPUT_TRACE_DATA //debugInitTrace(); #endif #ifdef ENABLE_UART // uartInit(); #endif #endif //ndef USE_RADIOLINK_CRTP commInit(); DEBUG_PRINT("----------------------------\n"); DEBUG_PRINT("Crazyflie is up and running!\n"); DEBUG_PRINT("Build %s:%s (%s) %s\n", V_SLOCAL_REVISION, V_SREVISION, V_STAG, (V_MODIFIED)?"MODIFIED":"CLEAN"); DEBUG_PRINT("I am 0x%X%X%X and I have %dKB of flash!\n", *((int*)(MCU_ID_ADDRESS+8)), *((int*)(MCU_ID_ADDRESS+4)), *((int*)(MCU_ID_ADDRESS+0)), *((short*)(MCU_FLASH_SIZE_ADDRESS))); commanderInit(); stabilizerInit(); expbrdInit(); memInit(); //Test the modules pass &= systemTest(); pass &= configblockTest(); pass &= commTest(); pass &= commanderTest(); pass &= stabilizerTest(); pass &= expbrdTest(); pass &= memTest(); //Start the firmware if(pass) { selftestPassed = 1; systemStart(); ledseqRun(SYS_LED, seq_alive); ledseqRun(LINK_LED, seq_testPassed); } else { selftestPassed = 0; if (systemTest()) { while(1) { ledseqRun(SYS_LED, seq_testPassed); //Red passed == not passed! vTaskDelay(M2T(2000)); // System can be forced to start by setting the param to 1 from the cfclient if (selftestPassed) { DEBUG_PRINT("Start forced.\n"); systemStart(); break; } } } else { ledInit(); ledSet(SYS_LED, true); } } DEBUG_PRINT("Free heap: %d bytes\n", xPortGetFreeHeapSize()); workerLoop(); //Should never reach this point! while(1) vTaskDelay(portMAX_DELAY); }
void systemTask(void *arg) { bool pass = true; ledInit(); ledSet(CHG_LED, 1); #ifdef DEBUG_QUEUE_MONITOR queueMonitorInit(); #endif uartInit(); #ifdef ENABLE_UART1 uart1Init(); #endif #ifdef ENABLE_UART2 uart2Init(); #endif //Init the high-levels modules systemInit(); #ifndef USE_RADIOLINK_CRTP #ifdef UART_OUTPUT_TRACE_DATA //debugInitTrace(); #endif #ifdef ENABLE_UART // uartInit(); #endif #endif //ndef USE_RADIOLINK_CRTP commInit(); commanderAdvancedInit(); stabilizerInit(); #ifdef PLATFORM_CF2 deckInit(); #endif soundInit(); memInit(); #ifdef PROXIMITY_ENABLED proximityInit(); #endif //Test the modules pass &= systemTest(); pass &= configblockTest(); pass &= commTest(); pass &= commanderAdvancedTest(); pass &= stabilizerTest(); #ifdef PLATFORM_CF2 pass &= deckTest(); #endif pass &= soundTest(); pass &= memTest(); pass &= watchdogNormalStartTest(); //Start the firmware if(pass) { selftestPassed = 1; systemStart(); soundSetEffect(SND_STARTUP); ledseqRun(SYS_LED, seq_alive); ledseqRun(LINK_LED, seq_testPassed); } else { selftestPassed = 0; if (systemTest()) { while(1) { ledseqRun(SYS_LED, seq_testPassed); //Red passed == not passed! vTaskDelay(M2T(2000)); // System can be forced to start by setting the param to 1 from the cfclient if (selftestPassed) { DEBUG_PRINT("Start forced.\n"); systemStart(); break; } } } else { ledInit(); ledSet(SYS_LED, true); } } DEBUG_PRINT("Free heap: %d bytes\n", xPortGetFreeHeapSize()); workerLoop(); //Should never reach this point! while(1) vTaskDelay(portMAX_DELAY); }
void systemTask(void *arg) { bool pass = true; ledInit(); ledSet(CHG_LED, 1); #ifdef DEBUG_QUEUE_MONITOR queueMonitorInit(); #endif #ifdef ENABLE_UART1 uart1Init(); #endif #ifdef ENABLE_UART2 uart2Init(); #endif //Init the high-levels modules systemInit(); commInit(); commanderInit(); StateEstimatorType estimator = anyEstimator; deckInit(); estimator = deckGetRequiredEstimator(); stabilizerInit(estimator); if (deckGetRequiredLowInterferenceRadioMode()) { platformSetLowInterferenceRadioMode(); } soundInit(); memInit(); #ifdef PROXIMITY_ENABLED proximityInit(); #endif //Test the modules pass &= systemTest(); pass &= configblockTest(); pass &= commTest(); pass &= commanderTest(); pass &= stabilizerTest(); pass &= deckTest(); pass &= soundTest(); pass &= memTest(); pass &= watchdogNormalStartTest(); //Start the firmware if(pass) { selftestPassed = 1; systemStart(); soundSetEffect(SND_STARTUP); ledseqRun(SYS_LED, seq_alive); ledseqRun(LINK_LED, seq_testPassed); } else { selftestPassed = 0; if (systemTest()) { while(1) { ledseqRun(SYS_LED, seq_testPassed); //Red passed == not passed! vTaskDelay(M2T(2000)); // System can be forced to start by setting the param to 1 from the cfclient if (selftestPassed) { DEBUG_PRINT("Start forced.\n"); systemStart(); break; } } } else { ledInit(); ledSet(SYS_LED, true); } } DEBUG_PRINT("Free heap: %d bytes\n", xPortGetFreeHeapSize()); workerLoop(); //Should never reach this point! while(1) vTaskDelay(portMAX_DELAY); }
int init(int argc, char **argv, char **env) { #ifdef _ITEM_QUITPARTY FILE *f; int i; char line[256]; #endif srand(getpid()); print("This Program is compiled at %s %s by gcc %s\n", __DATE__, __TIME__, __VERSION__); defaultConfig(argv[0]); signalset(); GOTORETURNFALSEIFFALSE(parseCommandLine(argc, argv)); GOTORETURNFALSEIFFALSE(parseEnvironment(env)); { Char aho; debug(sizeof(aho), d); debug(sizeof(aho.data), d); debug(sizeof(aho.string), d); debug(sizeof(aho.flg), d); debug(sizeof(aho.indexOfExistItems), d); debug(sizeof(aho.haveSkill), d); debug(sizeof(aho.indexOfHaveTitle), d); debug(sizeof(aho.addressBook), d); debug(sizeof(aho.workint), d); debug(sizeof(aho.workchar), d); } print("配置文件: %s\n", getConfigfilename()); GOTORETURNFALSEIFFALSE(readconfigfile(getConfigfilename())); nice(getrunlevel()); { int iWork = setAcWBSize(); if(iWork == 0) { printf("----------------------------------------\n"); printf("-------------[AC缓冲] 无法设置 %s\n", getConfigfilename()); printf("----------------------------------------\n"); exit(1); } else { printf("AC缓冲 = %d\n", iWork); } } if(getDebuglevel() >= 1) { print("调试等级: %d\n", getDebuglevel()); print("运行等级: %d\n", getrunlevel()); print("接收缓冲: %d\n", getrecvbuffer() * 1024); print("发送缓冲: %d\n", getsendbuffer() * 1024); print("接收缓冲下限: %d\n", getrecvlowatbuffer()); print("内存单元大小: %d\n", getMemoryunit()); print("内存单元数量: %d\n", getMemoryunitnum()); print("账号服务器地址: %s\n", getAccountservername()); print("账号服务器端口: %d\n", getAccountserverport()); print("登陆服务器名称: %s\n", getGameservername()); print("登陆服务器密码: %s\n", getAccountserverpasswd()); print("等待连接端口: %d\n", getPortnumber()); print("服务端序列号: %d\n", getServernumber()); print("重复地址使用: %d\n", getReuseaddr()); print("最大在线人数: %d\n", getFdnum()); print("最大在线宠数: %d\n", getPetcharnum()); print("最大其他数目: %d\n", getOtherscharnum()); print("最大对象数目: %d\n", getObjnum()); print("最大物品数目: %d\n", getItemnum()); print("最大战斗数目: %d\n", getBattlenum()); print("顶层文件目录: %s\n", getTopdir()); print("地图文件目录: %s\n", getMapdir()); print("地图标识文件: %s\n", getMaptilefile()); print("物品配置文件: %s\n", getItemfile()); print("不可战斗文件: %s\n", getInvfile()); print("显示位置文件: %s\n", getAppearfile()); print("头衔名称文件: %s\n", getTitleNamefile()); print("头衔配置文件: %s\n", getTitleConfigfile()); print("遇敌坐标文件: %s\n", getEncountfile()); print("遇敌组群文件: %s\n", getGroupfile()); print("宠物基本文件: %s\n", getEnemyBasefile()); print("创建宠物文件: %s\n", getEnemyfile()); print("精灵魔法文件: %s\n", getMagicfile()); #ifdef _ATTACK_MAGIC print("攻击魔法文件: %s\n", getAttMagicfileName()); #endif print("宠物技能文件: %s\n", getPetskillfile()); print("物品成份文件: %s\n", getItematomfile()); print("猜迷问题文件: %s\n", getQuizfile()); #ifdef _GMRELOAD print("G M 配置文件: %s\n", getGMSetfile()); #endif print("日志记录文件: %s\n", getLsgenlogfilename()); print("还原资料目录: %s\n", getStoredir()); print("NPC 配置目录: %s\n", getNpcdir()); print("日志记载文件: %s\n", getLogdir()); print("日志配置文件: %s\n", getLogconffile()); print("GM的指命密码: %s\n", getChatMagicPasswd()); print("使用GM的权限: %d\n", getChatMagicCDKeyCheck()); print("NPC 模板数目: %d\n", getNpctemplatenum()); print("NPC 最大数目: %d\n", getNpccreatenum()); print("走路时间间隔: %d\n", getWalksendinterval()); print("清除所有间隔: %d\n", getCAsendinterval_ms()); print("清除目标间隔: %d\n", getCDsendinterval_ms()); print("执行一次时间: %d\n", getOnelooptime_ms()); print("宠物清除时间: %d\n", getPetdeletetime()); print("道具清除时间: %d\n", getItemdeletetime()); #ifdef _DEL_DROP_GOLD print("石器清除时间: %d\n", getGolddeletetime()); #endif print("数据保存间隔: %d\n", getCharSavesendinterval()); print("名片最大数目: %d\n", getAddressbookoffmsgnum()); print("读取频率协议: %d\n", getProtocolreadfrequency()); print("连接错误上限: %d\n", getAllowerrornum()); #ifdef _GET_BATTLE_EXP print("战斗经验倍数: %d倍\n", getBattleexp() ); #endif #ifdef _NEW_PLAYER_CF print("出生人物转数: %d转\n", getNewplayertrans()); print("出生人物等级: %d级\n", getNewplayerlv()); print("出生人物金钱: %d S\n", getNewplayergivegold()); print("出生宠物等级: %d级\n", getNewplayerpetlv()); #ifdef _VIP_SERVER print("出生拥有点数: %d点\n", getNewplayergivevip()); #endif print("出生能骑等级: %d\n", getRidePetLevel()); #ifdef _NEW_PLAYER_RIDE print("出生配套骑宠: %s\n", getPlayerRide()); #endif print("出生拥有宠物: NO1:%d NO2:%d NO3:%d NO4:%d NO5:%d\n", getNewplayergivepet(0), getNewplayergivepet(1), getNewplayergivepet(2), getNewplayergivepet(3), getNewplayergivepet(4)); print("出生拥有物品: ITEM1:%d ITEM2:%d ITEM3:%d ITEM4:%d ITEM5:%d\n" " ITEM1:%d ITEM2:%d ITEM3:%d ITEM4:%d ITEM5:%d\n" " ITEM1:%d ITEM2:%d ITEM3:%d ITEM4:%d ITEM5:%d\n", getNewplayergiveitem(0), getNewplayergiveitem(1), getNewplayergiveitem(2), getNewplayergiveitem(3), getNewplayergiveitem(4), getNewplayergiveitem(5), getNewplayergiveitem(6), getNewplayergiveitem(7), getNewplayergiveitem(8), getNewplayergiveitem(9), getNewplayergiveitem(10), getNewplayergiveitem(11), getNewplayergiveitem(12), getNewplayergiveitem(13), getNewplayergiveitem(14)); #endif #ifdef _UNREG_NEMA print("禁止人物名称: 名字1:%s 名字2:%s 名字3:%s 名字4:%s 名字5:%s\n", getUnregname(0), getUnregname(1), getUnregname(2), getUnregname(3), getUnregname(4)); #endif #ifdef _UNLAW_WARP_FLOOR print("禁止传送地图: 地图1:%d 地图2:%d 地图3:%d 地图4:%d 地图5:%d\n" " 地图1:%d 地图2:%d 地图3:%d 地图4:%d 地图5:%d\n", getUnlawwarpfloor(0), getUnlawwarpfloor(1), getUnlawwarpfloor(2), getUnlawwarpfloor(3), getUnlawwarpfloor(4), getUnlawwarpfloor(5), getUnlawwarpfloor(6), getUnlawwarpfloor(7), getUnlawwarpfloor(8), getUnlawwarpfloor(9)); #endif #ifdef _WATCH_FLOOR print("是否全图观战: %s\n",getWatchFloorCF()); if(strcmp(getWatchFloorCF(),"是")) print("允许观战地图: 地图1:%d 地图2:%d 地图3:%d 地图4:%d 地图5:%d\n",getWatchFloor(1), getWatchFloor(2), getWatchFloor(3), getWatchFloor(4), getWatchFloor(5)); #endif #ifdef _BATTLE_FLOOR print("是否强制战斗: %s\n",getBattleFloorCF()); if(strcmp(getBattleFloorCF(),"是")) print("强制战斗地图: 地图1:%d 地图2:%d 地图3:%d 地图4:%d 地图5:%d\n",getBattleFloor(1), getBattleFloor(2), getBattleFloor(3), getBattleFloor(4), getBattleFloor(5)); #endif #ifdef _TRANS_LEVEL_CF print("人物等级转数: %d级\n", getChartrans()); print("宠物等级转数: %d级\n", getPettrans()); #endif #ifdef _POINT print("禁止点数上限: %s\n", getPoint()); if(strcmp(getPoint(), "是")) print("每转点数上限: 0转:%d 1转:%d 2转:%d 3转:%d 4转:%d 5转:%d 6转:%d\n", getTransPoint(0), getTransPoint(1), getTransPoint(2), getTransPoint(3), getTransPoint(4), getTransPoint(5), getTransPoint(6)); #endif #ifdef _PET_UP print("宠物能否捡获: %s\n", getPetup()); #endif #ifdef _LOOP_ANNOUNCE print("循环公告路径: %s\n",getLoopAnnouncePath()); print("循环时间间隔: %d分钟\n",getLoopAnnounceTime()); #endif #ifdef _SKILLUPPOINT_CF print("每级升级点数: %d\n",getSkup()); #endif #ifdef _RIDELEVEL print("骑宠等级相差: %d级\n",getRideLevel()); #endif #ifdef _REVLEVEL print("还原上限等级: %s级\n",getRevLevel()); #endif #ifdef _TRANS_LEVEL_CF print("一般等级上限: %d级\n", getYBLevel()); print("最高等级上限: %d级\n", getMaxLevel()); #endif #ifdef _FIX_CHARLOOPS print("恶魔时间倍数: %d倍\n", getCharloops()); #endif #ifdef _PLAYER_ANNOUNCE if(getPAnnounce() == -1) print("喇叭消耗点数: 关闭使用\n"); else print("喇叭消耗点数: %d点\n", getPAnnounce()); #endif #ifdef _PLAYER_MOVE if(getPMove() == -1) print("顺移消耗点数: 关闭使用\n"); else print("顺移消耗点数: %d点\n", getPMove()); #endif #ifdef _BATTLE_GOLD print("战斗获得金钱: %d%\n", getBattleGold()); #endif #ifdef _ANGEL_TIME print("精灵召唤时间: (%d人/在线人数)分\n", getAngelPlayerTime()); print("精灵召唤人数: %d人\n", getAngelPlayerMun()); #endif #ifdef _RIDEMODE_20 print("2.0 骑宠模式: %d\n", getRideMode()); #endif #ifdef _FM_POINT_PK print("庄园互抢模式: %s\n", getFmPointPK()); #endif } { //andy_add 2003/05/05 check GameServer Name char *GameServerName; GameServerName = getGameserverID(); if(GameServerName == NULL || strlen(GameServerName) <= 0) return FALSE; print("\n游戏服务器ID: %s\n", GameServerName); } print("开始初始化\n"); //#define DEBUG1( arg... ) if( getDebuglevel()>1 ){##arg} print("建立内存空间..."); GOTORETURNFALSEIFFALSE(configmem(getMemoryunit(), getMemoryunitnum())); GOTORETURNFALSEIFFALSE(memInit()); print("完成\n"); print("始终化连接空间..."); if(!initConnect(getFdnum())) goto MEMEND; print("完成\n"); while(1) { print("尝试绑定本地端口 %d... ", getPortnumber()); bindedfd = bindlocalhost(getPortnumber()); if(bindedfd == -1) sleep(10); else break; } print("完成\n"); print("建立对象..."); if(!initObjectArray(getObjnum())) goto CLOSEBIND; print("完成\n"); print("建立人物..."); if(!CHAR_initCharArray(getFdnum(), getPetcharnum(), getOtherscharnum())) goto CLOSEBIND; print("完成\n"); print("建立物品..."); if(!ITEM_readItemConfFile(getItemfile())) goto CLOSEBIND; if(!ITEM_initExistItemsArray(getItemnum())) goto CLOSEBIND; print("完成\n"); print("建立战斗..."); if(!BATTLE_initBattleArray(getBattlenum())) goto CLOSEBIND; print("完成\n"); print("建立功能模块..."); if(!initFunctionTable()) goto CLOSEBIND; print("完成\n"); print("初始化邮件..."); if(!PETMAIL_initOffmsgBuffer(getAddressbookoffmsgnum())) goto CLOSEBIND; print("完成\n"); print("读取不可战斗文件..."); if(!CHAR_initInvinciblePlace(getInvfile())) goto CLOSEBIND; print("完成\n"); print("读取显示位置文件..."); if(!CHAR_initAppearPosition(getAppearfile())) goto CLOSEBIND; print("完成\n"); print("读取头衔名称文件..."); if(!TITLE_initTitleName(getTitleNamefile())) goto CLOSEBIND; print("完成\n"); print("读取头衔配置文件..."); if(!TITLE_initTitleConfig(getTitleConfigfile())) goto CLOSEBIND; print("完成\n"); print("读取遇敌坐标文件..."); if(!ENCOUNT_initEncount(getEncountfile())) goto CLOSEBIND; print("完成\n"); print("读取宠物基本文件..."); if(!ENEMYTEMP_initEnemy(getEnemyBasefile())) goto CLOSEBIND; print("完成\n"); print("读取创建宠物文件..."); if(!ENEMY_initEnemy(getEnemyfile())) goto CLOSEBIND; print("完成\n"); print("读取遇敌组群文件..."); if(!GROUP_initGroup(getGroupfile())) goto CLOSEBIND; print("完成\n"); print("读取魔法文件..."); if(!MAGIC_initMagic(getMagicfile())) goto CLOSEBIND; print("完成\n"); #ifdef _ATTACK_MAGIC print("读取魔法攻击文件..."); if(!ATTMAGIC_initMagic(getAttMagicfileName())) // if( !ATTMAGIC_initMagic( getMagicfile() ) ) goto CLOSEBIND; print("魔法攻击文件 -->%s...", getAttMagicfileName()); print("完成\n"); #endif print("读取宠物技能文件..."); if(!PETSKILL_initPetskill(getPetskillfile())) goto CLOSEBIND; print("完成\n"); print("读取物品成份文件..."); if(!ITEM_initItemAtom(getItematomfile())) goto CLOSEBIND; print("完成\n"); print("初始化料理合成物品..."); if(!ITEM_initItemIngCache()) goto CLOSEBIND; print("完成\n"); print("初始料理合成随机设定..."); if(!ITEM_initRandTable()) goto CLOSEBIND; print("完成\n"); print("读取猜迷问题文件..."); if(!QUIZ_initQuiz(getQuizfile())) goto CLOSEBIND; print("完成\n"); #ifdef _GMRELOAD print("读取GM配置文件..."); if(!LoadGMSet(getGMSetfile())) goto CLOSEBIND; print("完成\n"); #endif #ifdef _USER_EXP_CF print( "读取经验配置文件..." ); if ( !LoadEXP( getEXPfile() ) ) goto CLOSEBIND; print("最高等级: %d...",getMaxLevel()); print("一般等级: %d...",getYBLevel()); print( "完成\n" ); #endif #ifdef _LOOP_ANNOUNCE print("读取循环公告文件..."); if(!loadLoopAnnounce()) print("...失败\n"); else print("完成\n"); #endif #ifdef _RIDE_CF print("读取自定义骑宠文件..."); if(!CHAR_Ride_CF_init()) print("...失败\n"); print("完成\n"); #endif #ifdef _FM_LEADER_RIDE print("读取庄园族长专用骑宠文件..."); if(!CHAR_FmLeaderRide_init()) print("...失败\n"); print("完成\n"); #endif #ifdef _NEED_ITEM_ENEMY print("读取融合宠配置文件..."); if(!need_item_eneny_init()) print("...失败\n"); print("完成\n"); #endif print("建立地图..."); if(!MAP_initReadMap(getMaptilefile(), getMapdir())) goto CLOSEBIND; print("完成\n"); print("读取NPC文件..."); if(!NPC_readNPCSettingFiles(getNpcdir(), getNpctemplatenum(), getNpccreatenum())) goto CLOSEBIND; print("完成\n"); print("初始化 NPC 服务器... "); if(lssproto_InitServer(lsrpcClientWriteFunc, LSGENWORKINGBUFFER) < 0) goto CLOSEBIND; print("完成\n"); print("尝试连接账号服务器... "); acfd = connectHost(getAccountservername(), getAccountserverport()); if(acfd == -1) goto CLOSEBIND; print("完成\n"); initConnectOne(acfd, NULL, 0); if(!CONNECT_acfdInitRB(acfd)) goto CLOSEAC; if(!CONNECT_acfdInitWB(acfd)) goto CLOSEAC; CONNECT_setCtype(acfd, AC); print("初始化 NPC 客户端 ... "); if(saacproto_InitClient(lsrpcClientWriteFunc, LSGENWORKINGBUFFER, acfd) < 0) goto CLOSEAC; print("完成\n"); print("向账号服务器发送登陆请求... "); saacproto_ACServerLogin_send(acfd, getGameservername(), getAccountserverpasswd()); print("完成\n"); if(isExistFile(getLsgenlogfilename())) { lssproto_SetServerLogFiles(getLsgenlogfilename(), getLsgenlogfilename()); saacproto_SetClientLogFiles(getLsgenlogfilename(), getLsgenlogfilename()); } print("初始化已完成\n"); print("开始记始日志\n"); { if(!initLog(getLogconffile())) goto CLOSEAC; } #ifdef _ITEM_QUITPARTY print("读取队伍解散物品消失文件..."); //读取档案 f = fopen(getitemquitparty(), "r"); if(f != NULL) { while(fgets(line, sizeof(line), f)) { if(line[0] == '#')continue; if(line[0] == '\n')continue; chomp(line); itemquitparty_num++; } if(fseek(f, 0, SEEK_SET) == -1) { print("物品录找错误\n"); fclose(f); goto CLOSEAC; } //配记忆体 Disappear_Item = allocateMemory(sizeof(struct tagDisappearItem) * itemquitparty_num); if(Disappear_Item == NULL) { print("无法分配内存 %d\n", sizeof(struct tagDisappearItem) * itemquitparty_num); fclose(f); goto CLOSEAC; } i = 0; //将道具编号存入 Disappear_Item.string while(fgets(line, sizeof(line), f)) { if(line[0] == '#')continue; if(line[0] == '\n')continue; chomp(line); sprintf(Disappear_Item[i].string, "%s", line); print("\n道具编号:%s", Disappear_Item[i].string); i++; } fclose(f); } #endif DEBUG_ADJUSTTIME = 0; return TRUE; CLOSEAC: close(acfd); CLOSEBIND: close(bindedfd); endConnect(); MEMEND: memEnd(); RETURNFALSE: return FALSE; }
int my_usrRoot(char* pMemPoolStart, unsigned int memPoolSize) { eventLibInit(); semBLibInit(); semMLibInit(); semCLibInit(); semQLibInit(); wdLibInit(); taskHookInit(); memInit(pMemPoolStart, memPoolSize); memPartLibInit(pMemPoolStart, memPoolSize); if (proc_sysMmuLibInit == 0) goto usrRoot_failed; int (*_sysMmuLibInit)() = (void*) proc_sysMmuLibInit; if (_sysMmuLibInit(0x1000) != 0) goto usrRoot_failed; if (vmMpuLibInit(0x1000) != 0) goto usrRoot_failed; if (vmBaseGlobalMapInit(&MemDescArray, MemDescArrayCount, 1) == 0) goto usrRoot_failed; sysClockConnect(usrClock, 0); sysClockRateSet(60); sysClockEnable(); selectInit(50); usrBootLineParse(0x1000); iosInit(20, 50, "/null"); ttyDrv(); usrSerialInit(); hashLibInit(); envLibInit(1); sigInit(); excInit(); logInit(fdConsole, 50); stdioInit(); fioLibInit(); selTaskDeleteHookAdd(); sub_FFB5F728(); my_taskcreate_Startup(); return 0; usrRoot_failed: printExc("usrRoot: MMU configuration failed, errno = %#x", *(long*) (GetErrorNumAddr()), 0, 0, 0, 0); reboot(1); return 0; }
void usrRoot ( char * pMemPoolStart, /* start of system memory partition */ unsigned memPoolSize /* initial size of mem pool */ ) { char tyName [20]; int ix; /* Initialize the memory pool before initializing any other package. * The memory associated with the root task will be reclaimed at the * completion of its activities. */ #ifdef INCLUDE_MEM_MGR_FULL memInit (pMemPoolStart, memPoolSize); /* initialize memory pool */ #else memPartLibInit (pMemPoolStart, memPoolSize);/* initialize memory pool */ #endif /* INCLUDE_MEM_MGR_FULL */ #ifdef INCLUDE_SHOW_ROUTINES memShowInit (); /* initialize memShow routine */ #endif /* INCLUDE_SHOW_ROUTINES */ #if defined(INCLUDE_MMU_BASIC) || defined(INCLUDE_MMU_FULL) || \ defined(INCLUDE_MMU_MPU) usrMmuInit (); /* initialize the mmu */ #endif /* defined(INCLUDE_MMU_BASIC, INCLUDE_MMU_FULL, INCLUDE_MMU_MPU) */ /* set up system timer */ sysClkConnect ((FUNCPTR) usrClock, 0); /* connect clock ISR */ sysClkRateSet (SYS_CLK_RATE); /* set system clock rate */ sysClkEnable (); /* start it */ #ifdef INCLUDE_FAST_DRAM /* * make use of data cache as fast DRAM, * establish parameters in config.h, MMU * must be initialed before data cache is * initialized as data ram... */ cacheCreateInternalDataRAM((UINT32 *)FD_ORIGIN, FD_NUMLINES); #endif /* * The select library needs to be initialized before the tyLib module * since the _func_selWakeupListInit FUNCPTR is required (SPR #3314). * The installation of the select task delete hooks is performed * later in usrRoot() after NFS and RPC have been initialized. */ #ifdef INCLUDE_SELECT selectInit (NUM_FILES); #endif /* INCLUDE_SELECT */ /* initialize I/O system */ #ifdef INCLUDE_IO_SYSTEM iosInit (NUM_DRIVERS, NUM_FILES, "/null"); consoleFd = NONE; /* assume no console device */ #ifdef INCLUDE_TYCODRV_5_2 #ifdef INCLUDE_TTY_DEV if (NUM_TTY > 0) { tyCoDrv (); /* install console driver */ for (ix = 0; ix < NUM_TTY; ix++) /* create serial devices */ { sprintf (tyName, "%s%d", "/tyCo/", ix); (void) tyCoDevCreate (tyName, ix, 512, 512); if (ix == CONSOLE_TTY) strcpy (consoleName, tyName); /* store console name */ } consoleFd = open (consoleName, O_RDWR, 0); /* set baud rate */ (void) ioctl (consoleFd, FIOBAUDRATE, CONSOLE_BAUD_RATE); (void) ioctl (consoleFd, FIOSETOPTIONS, OPT_TERMINAL); } #endif /* INCLUDE_TTY_DEV */ #else /* !INCLUDE_TYCODRV_5_2 */ #ifdef INCLUDE_TTY_DEV if (NUM_TTY > 0) { ttyDrv(); /* install console driver */ for (ix = 0; ix < NUM_TTY; ix++) /* create serial devices */ { #if (defined(INCLUDE_WDB) && (WDB_COMM_TYPE == WDB_COMM_SERIAL)) if (ix == WDB_TTY_CHANNEL) /* don't use WDBs channel */ continue; #endif sprintf (tyName, "%s%d", "/tyCo/", ix); (void) ttyDevCreate (tyName, sysSerialChanGet(ix), 512, 512); if (ix == CONSOLE_TTY) /* init the tty console */ { strcpy (consoleName, tyName); consoleFd = open (consoleName, O_RDWR, 0); (void) ioctl (consoleFd, FIOBAUDRATE, CONSOLE_BAUD_RATE); (void) ioctl (consoleFd, FIOSETOPTIONS, OPT_TERMINAL); } } } #endif /* INCLUDE_TTY_DEV */ #ifdef INCLUDE_PC_CONSOLE pcConDrv (); for (ix = 0; ix < N_VIRTUAL_CONSOLES; ix++) { sprintf (tyName, "%s%d", "/pcConsole/", ix); (void) pcConDevCreate (tyName,ix, 512, 512); if (ix == PC_CONSOLE) /* init the console device */ { strcpy (consoleName, tyName); consoleFd = open (consoleName, O_RDWR, 0); (void) ioctl (consoleFd, FIOBAUDRATE, CONSOLE_BAUD_RATE); (void) ioctl (consoleFd, FIOSETOPTIONS, OPT_TERMINAL); } } #endif /* INCLUDE_PC_CONSOLE */ #endif /* !INCLUDE_TYCODRV_5_2 */ ioGlobalStdSet (STD_IN, consoleFd); ioGlobalStdSet (STD_OUT, consoleFd); ioGlobalStdSet (STD_ERR, consoleFd); #endif /* INCLUDE_IO_SYSTEM */ /* initialize symbol table facilities */ #ifdef INCLUDE_SYM_TBL hashLibInit (); /* initialize hash table package */ symLibInit (); /* initialize symbol table package */ #ifdef INCLUDE_SHOW_ROUTINES symShowInit (); /* initialize symbol table show */ #endif /* INCLUDE_SHOW_ROUTINES */ #endif /* INCLUDE_SYM_TBL */ /* initialize exception handling */ #if defined(INCLUDE_EXC_HANDLING) && defined(INCLUDE_EXC_TASK) #ifdef INCLUDE_EXC_SHOW excShowInit (); #endif excInit (); /* initialize exception handling */ #endif /* defined(INCLUDE_EXC_HANDLING) && defined(INCLUDE_EXC_TASK) */ #ifdef INCLUDE_LSTLIB lstLibInit (); #endif #ifdef INCLUDE_LOGGING logInit (consoleFd, MAX_LOG_MSGS); /* initialize logging */ # ifdef INCLUDE_LOG_STARTUP logMsg ("logging started to %s [%d], queue size %d\n", consoleName, consoleFd, MAX_LOG_MSGS, 4,5,6); taskDelay (2); /* allow time for message to be displayed */ # endif /* INCLUDE_LOG_STARTUP */ #endif /* INCLUDE_LOGGING */ #ifdef INCLUDE_SIGNALS sigInit (); /* initialize signals */ #endif /* INCLUDE_SIGNALS */ /* initialize debugging */ #ifdef INCLUDE_DEBUG dbgInit (); /* initialize debugging */ #endif /* INCLUDE_DEBUG */ /* initialize pipe driver */ #ifdef INCLUDE_PIPES pipeDrv (); /* install pipe driver */ #endif /* INCLUDE_PIPES */ /* initialize standard I/O package */ #ifdef INCLUDE_STDIO stdioInit (); /* initialize standard I/O library */ #ifdef INCLUDE_SHOW_ROUTINES stdioShowInit (); #endif /* INCLUDE_SHOW_ROUTINES */ #endif /* INCLUDE_STDIO */ /* initialize POSIX queued signals */ #if defined(INCLUDE_POSIX_SIGNALS) && defined(INCLUDE_SIGNALS) sigqueueInit (NUM_SIGNAL_QUEUES); /* initialize queued signals */ #endif /* initialize POSIX semaphores */ #ifdef INCLUDE_POSIX_SEM semPxLibInit (); #ifdef INCLUDE_SHOW_ROUTINES semPxShowInit (); #endif /* INCLUDE_SHOW_POUTINES */ #endif /* INCLUDE_POSIX_SEM */ /* initialize POSIX threads */ #ifdef INCLUDE_POSIX_PTHREADS pthreadLibInit (); #endif /* INCLUDE_POSIX_PTHREADS */ /* initialize POSIX message queues */ #ifdef INCLUDE_POSIX_MQ mqPxLibInit (MQ_HASH_SIZE); #ifdef INCLUDE_SHOW_ROUTINES mqPxShowInit (); #endif /* INCLUDE_SHOW_ROUTINES */ #endif /* INCLUDE_POSIX_MQ */ /* initialize POSIX async I/O support */ #ifdef INCLUDE_POSIX_AIO aioPxLibInit (MAX_LIO_CALLS); #ifdef INCLUDE_POSIX_AIO_SYSDRV aioSysInit (MAX_AIO_SYS_TASKS, AIO_TASK_PRIORITY, AIO_TASK_STACK_SIZE); #endif /* INCLUDE_POSIX_AIO_SYSDRV */ #endif /* INCLUDE_POSIX_AIO */ #ifdef INCLUDE_CBIO /* init main CBIO module, cbioLib() */ cbioLibInit(); #endif INCLUDE_CBIO /* initialize filesystems and disk drivers */ #ifdef INCLUDE_DOSFS_MAIN /* dosFs2 file system initialization */ hashLibInit (); /* initialize hash table package */ /* First initialize the main dosFs module */ dosFsLibInit( 0 ); /* Initialize sub-modules */ /* ensure that at least one directory handler is defined */ # if ((!defined INCLUDE_DOSFS_DIR_VFAT) && \ (!defined INCLUDE_DOSFS_DIR_FIXED)) # define INCLUDE_DOSFS_DIR_VFAT # endif /* init VFAT (MS long file names) module */ # ifdef INCLUDE_DOSFS_DIR_VFAT /* Sub-module: VFAT Directory Handler */ dosVDirLibInit(); # endif /* INCLUDE_DOSFS_DIR_VFAT */ /* init strict 8.3 and vxLongNames handler */ # ifdef INCLUDE_DOSFS_DIR_FIXED /* Sub-module: Vintage 8.3 and VxLong Directory Handler */ dosDirOldLibInit(); # endif /* INCLUDE_DOSFS_DIR_FIXED */ /* Sub-module: FAT12/FAT16/FAT32 FAT Handler */ dosFsFatInit(); # ifdef INCLUDE_DOSFS_CHKDSK /* Sub-module: Consistency check handler */ dosChkLibInit(); # endif /* INCLUDE_DOSFS_CHKDSK */ # ifdef INCLUDE_DOSFS_FMT /* Sub-module: Formatter */ dosFsFmtLibInit(); /* init dosFs scalable formatter */ # endif /* INCLUDE_DOSFS_FMT */ #endif /* INCLUDE_DOSFS_MAIN */ /* dosFs1 legacy code, dosFsInit(), usrDosFsOld.c */ #ifdef INCLUDE_DOSFS hashLibInit (); /* initialize hash table package */ dosFsInit (NUM_DOSFS_FILES); /* init dosFs filesystem */ #endif /* INCLUDE_DOSFS */ #ifdef INCLUDE_RAWFS rawFsInit (NUM_RAWFS_FILES); /* init rawFs filesystem */ #endif /* INCLUDE_RAWFS */ #ifdef INCLUDE_RT11FS rt11FsInit (NUM_RT11FS_FILES); /* init rt11Fs filesystem */ #endif /* INCLUDE_RT11FS */ #ifdef INCLUDE_RAMDRV ramDrv (); /* initialize ram disk driver */ #endif /* INCLUDE_RAMDRV */ /* initialize USB components */ #ifdef INCLUDE_USB_INIT usbInit (); /* USB Host Stack Initialization */ #endif #ifdef INCLUDE_UHCI_INIT usrUsbHcdUhciAttach (); /* UHCI Initialization */ #endif #ifdef INCLUDE_OHCI_INIT usrUsbHcdOhciAttach (); /* OHCI Initialization */ #endif #ifdef INCLUDE_USB_MOUSE_INIT usrUsbMseInit (); /* Mouse Driver Initialization */ #endif #ifdef INCLUDE_USB_KEYBOARD_INIT usrUsbKbdInit (); /* Keyboard Driver Initialization */ #endif #ifdef INCLUDE_USB_PRINTER_INIT usrUsbPrnInit (); /* Printer Driver Initialization */ #endif #ifdef INCLUDE_USB_SPEAKER_INIT usrUsbSpkrInit (); /* Speaker Driver Initialization */ #endif #ifdef INCDLUE_USB_AUDIO_DEMO usrUsbAudioDemo (); /* USB Audio Demo */ #endif #ifdef INCLUDE_USB_MS_BULKONLY_INIT usrUsbBulkDevInit(); /* Bulk Driver Initialization */ #endif #ifdef INCLUDE_USB_MS_CBI_INIT usrUsbCbiUfiDevInit (); /* CBI Driver Initialization */ #endif #ifdef INCLUDE_USB_PEGASUS_END_INIT usrUsbPegasusEndInit (); /* Pegasus Driver Initialization */ #endif #ifdef INCLUDE_SCSI /* * initialize either the SCSI1 or SCSI2 interface; initialize SCSI2 when * the SCSI2 interface is available. */ #ifndef INCLUDE_SCSI2 scsi1IfInit (); #else scsi2IfInit (); #endif /* initialize SCSI controller */ if (sysScsiInit () == OK) { usrScsiConfig (); /* configure SCSI peripherals */ } else { #ifdef INCLUDE_STDIO printf ("sysScsiInit() Failed, SCSI system not initialized\n"); #endif /* INCLUDE_STDIO */ } #endif /* INCLUDE_SCSI */ #ifdef INCLUDE_FD /* initialize floppy disk driver */ if ((fdDrv (FD_INT_VEC, FD_INT_LVL)) == ERROR) { #ifdef INCLUDE_STDIO printf ("fdDrv returned ERROR from usrRoot.\n"); #endif /* INCLUDE_STDIO */ } #endif /* INCLUDE_FD */ #ifdef INCLUDE_IDE /* init IDE disk driver */ if ((ideDrv (IDE_INT_VEC, IDE_INT_LVL, IDE_CONFIG)) == ERROR) { #ifdef INCLUDE_STDIO printf ("ideDrv returned ERROR from usrRoot.\n"); #endif /* INCLUDE_STDIO */ } #endif /* INCLUDE_IDE */ #ifdef INCLUDE_MMC d /* init IDE disk driver */ if ((mmcDrv (AT91C_ID_MCI, AT91C_VEC_MCI, IDE_CONFIG)) == ERROR) { #ifdef INCLUDE_STDIO printf ("ideDrv returned ERROR from usrRoot.\n"); #endif /* INCLUDE_STDIO */ } #endif /* INCLUDE_MMC */ #ifdef INCLUDE_ATA { /* initialize hard disk driver */ IMPORT ATA_RESOURCE ataResources[]; ATA_RESOURCE *pAtaResource; for (ix = 0; ix < ATA_MAX_CTRLS; ix++) { pAtaResource = &ataResources[ix]; if (pAtaResource->ctrlType == IDE_LOCAL) if ((ataDrv (ix, pAtaResource->drives, pAtaResource->intVector, pAtaResource->intLevel, pAtaResource->configType, pAtaResource->semTimeout, pAtaResource->wdgTimeout)) == ERROR) { #ifdef INCLUDE_STDIO printf ("ataDrv returned ERROR from usrRoot.\n"); #endif /* INCLUDE_STDIO */ } } } #ifdef INCLUDE_SHOW_ROUTINES ataShowInit (); /* install ATA/IDE show routine */ #endif /* INCLUDE_SHOW_ROUTINES */ #endif /* INCLUDE_ATA */ #ifdef INCLUDE_LPT { IMPORT LPT_RESOURCE lptResources[]; lptDrv (LPT_CHANNELS, &lptResources[0]); /* init LPT parallel driver */ } #endif /* INCLUDE_LPT */ #ifdef INCLUDE_PCMCIA #ifdef INCLUDE_SHOW_ROUTINES pcmciaShowInit (); /* install PCMCIA show routines */ #endif /* INCLUDE_SHOW_ROUTINES */ pcmciaInit (); /* init PCMCIA Lib */ #endif /* INCLUDE_PCMCIA */ #ifdef INCLUDE_TFFS tffsDrv (); /* it should be after pcmciaInit() */ #endif /* INCLUDE_TFFS */ #ifdef INCLUDE_FORMATTED_IO fioLibInit (); /* initialize formatted I/O */ #endif /* INCLUDE_FORMATTED_IO */ /* initialize floating point facilities */ #ifdef INCLUDE_FLOATING_POINT floatInit (); /* initialize floating point I/O */ #endif /* INCLUDE_FLOATING_POINT */ /* install software floating point emulation (if applicable) */ #ifdef INCLUDE_SW_FP mathSoftInit (); /* use software emulation for fp math */ #endif /* INCLUDE_SW_FP */ /* install hardware floating point support (if applicable) */ #ifdef INCLUDE_HW_FP mathHardInit (); /* do fppInit() & install hw fp math */ #ifdef INCLUDE_SHOW_ROUTINES fppShowInit (); /* install hardware fp show routine */ #endif /* INCLUDE_SHOW_ROUTINES */ #endif /* INCLUDE_HW_FP */ /* install dsp support (if applicable) */ #ifdef INCLUDE_DSP usrDspInit (); /* do dspInit() */ #endif /* INCLUDE_DSP */ /* initialize AltiVec library (if applicable) */ #ifdef INCLUDE_ALTIVEC usrAltivecInit (); #endif /* INCLUDE_ALTIVEC */ /* initialize performance monitoring tools */ #ifdef INCLUDE_SPY spyLibInit (); /* install task cpu utilization tool */ #endif /* INCLUDE_SPY */ #ifdef INCLUDE_TIMEX timexInit (); /* install function timing tool */ #endif /* INCLUDE_TIMEX */ #ifdef INCLUDE_ENV_VARS envLibInit (ENV_VAR_USE_HOOKS); /* initialize environment variable */ #endif /* INCLUDE_ENV_VARS */ #ifdef INCLUDE_NTPASSFS { IMPORT int ntPassFsInit(); IMPORT void * ntPassFsDevInit(); IMPORT char fullExePath[]; char passName [MAX_FILENAME_LENGTH]; char * defPathEnd; if (ntPassFsInit(1) == OK) { if (ntPassFsDevInit("host:") == NULL) { #ifdef INCLUDE_STDIO printf ("ntPassFsDevInit failed for host: \n"); #endif /* INCLUDE_STDIO */ } else { sprintf (passName, "host:%s", fullExePath); /* Remove bootFile name at the end of the string */ defPathEnd = strrchr (passName, '\\'); if (defPathEnd != NULL) *defPathEnd = '\0'; ioDefPathSet (passName); } } else { #ifdef INCLUDE_STDIO printf ("ntPassFsInit failed\n"); #endif /* INCLUDE_STDIO */ } } #endif /* INCLUDE_NTPASSFS */ /* initialize object module loader */ #ifdef INCLUDE_LOADER moduleLibInit (); /* initialize module manager */ #if defined(INCLUDE_AOUT) loadAoutInit (); /* use a.out format */ #else /* coff or ecoff */ #if defined(INCLUDE_ECOFF) loadEcoffInit (); /* use ecoff format */ #else /* ecoff */ #if defined(INCLUDE_COFF) loadCoffInit (); /* use coff format */ #else /* coff */ #if defined(INCLUDE_ELF) loadElfInit (); /* use elf format */ #else #if defined(INCLUDE_SOM_COFF) loadSomCoffInit (); #else #if defined(INCLUDE_PECOFF) { extern int loadPecoffInit(); loadPecoffInit (); } #endif #endif #endif #endif #endif #endif #endif /* INCLUDE_LOADER */ /* initialize wtx client to synchronize host and target symbol tables */ #ifdef INCLUDE_SYM_TBL_SYNC symSyncLibInit (); #endif /* INCLUDE_SYM_TBL_SYNC */ /* initialize network */ #ifdef INCLUDE_NET_INIT usrBootLineInit (sysStartType); /* crack the bootline */ # if defined(INCLUDE_LOGGING) && defined(INCLUDE_LOG_STARTUP) logMsg ("before usrNetInit()\n", 1,2,3,4,5,6); taskDelay (2); /* allow time for message to be displayed */ # endif /* INCLUDE_LOGGING && INCLUDE_LOG_STARTUP */ usrNetInit (BOOT_LINE_ADRS); /* initialize network support */ # if defined(INCLUDE_LOGGING) && defined(INCLUDE_LOG_STARTUP) logMsg ("after usrNetInit()\n", 1,2,3,4,5,6); taskDelay (2); /* allow time for message to be displayed */ # endif /* INCLUDE_LOGGING && INCLUDE_LOG_STARTUP */ #endif /* INCLUDE_NET_INIT */ #ifdef INCLUDE_PASSFS { extern STATUS passFsInit (); extern void *passFsDevInit (); char passName [256]; if (passFsInit (1) == OK) { extern char vxsim_hostname[]; extern char vxsim_cwd[]; sprintf (passName, "%s:", vxsim_hostname); if (passFsDevInit (passName) == NULL) { #ifdef INCLUDE_STDIO printf ("passFsDevInit failed for <%s>\n", passName); #endif /* INCLUDE_STDIO */ } else { sprintf (passName, "%s:%s", vxsim_hostname, vxsim_cwd); ioDefPathSet (passName); } } else #ifdef INCLUDE_STDIO printf ("passFsInit failed\n"); #endif /* INCLUDE_STDIO */ } #endif /* INCLUDE_PASSFS */ #ifdef INCLUDE_DOS_DISK { char unixName [80]; extern void unixDrv (); extern void unixDiskInit (); extern char *u_progname; /* home of executable */ char *pLastSlash; unixDrv (); pLastSlash = strrchr (u_progname, '/'); pLastSlash = (pLastSlash == NULL) ? u_progname : (pLastSlash + 1); sprintf (unixName, "/tmp/%s%d.dos", pLastSlash, sysProcNumGet()); unixDiskInit (unixName, "A:", 0); } #endif /* INCLUDE_DOS_DISK */ /* initialize shared memory objects */ #ifdef INCLUDE_SM_OBJ /* unbundled shared memory objects */ usrSmObjInit (BOOT_LINE_ADRS); #endif /* INCLUDE_SM_OBJ */ /* initialize WindMP */ #ifdef INCLUDE_VXFUSION /* unbundled VxFusion (distributed objects) */ usrVxFusionInit (BOOT_LINE_ADRS); #ifdef INCLUDE_SHOW_ROUTINES { extern void msgQDistShowInit(); extern void distNameShowInit (); extern void distIfShowInit (); extern void msgQDistGrpShowInit (); msgQDistShowInit(); distNameShowInit (); distIfShowInit (); msgQDistGrpShowInit (); } #endif /* INCLUDE_SHOW_ROUTINES */ #endif /* INCLUDE_WINDMP */ /* write protect text segment & vector table only after bpattach () */ #ifdef INCLUDE_MMU_FULL /* unbundled mmu product */ #ifdef INCLUDE_PROTECT_TEXT if (vmTextProtect () != OK) printf ("\nError protecting text segment. errno = %x\n", errno); #endif /* INCLUDE_PROTECT_TEXT */ #ifdef INCLUDE_PROTECT_VEC_TABLE if (intVecTableWriteProtect () != OK) printf ("\nError protecting vector table. errno = %x\n", errno); #endif /* INCLUDE_PROTECT_VEC_TABLE */ #endif /* INCLUDE_MMU_FULL */ /* install select hook only after NFS/RPC for proper delete hook order */ #ifdef INCLUDE_SELECT selTaskDeleteHookAdd (); #endif /* INCLUDE_SELECT */ /* create system and status symbol tables */ #ifdef INCLUDE_STANDALONE_SYM_TBL # if defined(INCLUDE_LOGGING) && defined(INCLUDE_LOG_STARTUP) logMsg ("before symTblCreate()\n", 1,2,3,4,5,6); taskDelay (2); /* allow time for message to be displayed */ # endif /* INCLUDE_LOGGING && INCLUDE_LOG_STARTUP */ sysSymTbl = symTblCreate (SYM_TBL_HASH_SIZE_LOG2, TRUE, memSysPartId); #ifdef INCLUDE_SYM_TBL_SYNC /* create a module (group 1) that is not synchronized (SPR# 20301) */ moduleCreate ("vxWorks.sym", #if (defined INCLUDE_AOUT) MODULE_A_OUT, #elif ((defined INCLUDE_COFF) || (defined INCLUDE_ECOFF) || \ (defined INCLUDE_SOMCOFF)) MODULE_ECOFF, #elif (defined INCLUDE_ELF) MODULE_ELF, #endif /* INCLUDE_AOUT */ HIDDEN_MODULE|LOAD_NO_SYMBOLS); #endif /* INCLUDE_SYM_TBL_SYNC */ printf ("\nAdding %ld symbols for standalone.\n", standTblSize); /* fill in from built in table*/ for (ix = 0; (ULONG) ix < standTblSize; ix++) #if ((CPU_FAMILY == ARM) && ARM_THUMB) thumbSymTblAdd (sysSymTbl, &(standTbl[ix])); #else symTblAdd (sysSymTbl, &(standTbl[ix])); #endif /* CPU_FAMILY == ARM */ # if defined(INCLUDE_LOGGING) && defined(INCLUDE_LOG_STARTUP) logMsg ("sysSymTbl complete.\n", 1,2,3,4,5,6); taskDelay (2); /* allow time for message to be displayed */ # endif /* INCLUDE_LOGGING && INCLUDE_LOG_STARTUP */ #endif /* INCLUDE_STANDALONE_SYM_TBL */ #ifdef INCLUDE_NET_SYM_TBL sysSymTbl = symTblCreate (SYM_TBL_HASH_SIZE_LOG2, TRUE, memSysPartId); netLoadSymTbl (); /* fill in table from host */ #endif /* INCLUDE_NET_SYM_TBL */ #ifdef INCLUDE_STAT_SYM_TBL statSymTbl = symTblCreate (STAT_TBL_HASH_SIZE_LOG2, FALSE, memSysPartId); for (ix = 0; (ULONG)ix < statTblSize; ix ++) /* fill in from builtin table*/ symTblAdd (statSymTbl, &(statTbl [ix])); #endif /* INCLUDE_STAT_SYM_TBL */ /* initialize C++ support library */ #if defined (INCLUDE_CPLUS) && defined (INCLUDE_CPLUS_MIN) #error Define only one of INCLUDE_CPLUS or INCLUDE_CPLUS_MIN, not both #endif #if defined (INCLUDE_CPLUS) || defined (INCLUDE_CPLUS_MIN) #ifndef INCLUDE_CTORS_DTORS #define INCLUDE_CTORS_DTORS #endif #endif #ifdef INCLUDE_CTORS_DTORS /* * call compiler generated init functions (usually - but not necessarily - * C++ related) */ cplusCtorsLink (); #endif #ifdef INCLUDE_CPLUS /* all standard C++ runtime support */ cplusLibInit (); #endif #ifdef INCLUDE_CPLUS_MIN /* minimal C++ runtime support */ cplusLibMinInit (); #endif #ifdef INCLUDE_CPLUS_DEMANGLER cplusDemanglerInit (); #endif /* initialize COM/DCOM runtime support */ #ifdef INCLUDE_COM comLibInit (); #endif #ifdef INCLUDE_DCOM dcomLibInit (); #endif /* initialize Wind Web Server */ #ifdef INCLUDE_HTTP httpd (); #endif /* INCLUDE_HTTP */ #ifdef INCLUDE_RBUFF /* install rBuff support */ rBuffLibInit(); #ifdef INCLUDE_SHOW_ROUTINES rBuffShowInit (); /* install rBuff show routine */ #endif /* INCLUDE_SHOW_ROUTINES */ #endif /* INCLUDE_RBUFF */ #ifdef INCLUDE_WINDVIEW windviewConfig (); #endif /* INCLUDE_WINDVIEW */ /* initialize the WDB debug agent */ #ifdef INCLUDE_WDB # if defined(INCLUDE_LOGGING) && defined(INCLUDE_LOG_STARTUP) logMsg ("before wdbConfig()\n", 1,2,3,4,5,6); taskDelay (2); /* allow time for message to be displayed */ # endif /* INCLUDE_LOGGING && INCLUDE_LOG_STARTUP */ wdbConfig(); # if defined(INCLUDE_LOGGING) && defined(INCLUDE_LOG_STARTUP) logMsg ("after wdbConfig()\n", 1,2,3,4,5,6); taskDelay (2); /* allow time for message to be displayed */ # endif /* INCLUDE_LOGGING && INCLUDE_LOG_STARTUP */ #ifdef INCLUDE_WDB_BANNER #if (WDB_COMM_TYPE == WDB_COMM_NETWORK) #define WDB_COMM_TYPE_STR "WDB_COMM_NETWORK" #endif /* WDB_COMM_TYPE == WDB_COMM_NETWORK */ #if (WDB_COMM_TYPE == WDB_COMM_SERIAL) #define WDB_COMM_TYPE_STR "WDB_COMM_SERIAL" #endif /* WDB_COMM_TYPE == WDB_COMM_SERIAL */ #if (WDB_COMM_TYPE == WDB_COMM_TYCODRV_5_2) #define WDB_COMM_TYPE_STR "WDB_COMM_TYCODRV_5_2" #endif /* WDB_COMM_TYPE == WDB_COMM_TYCODRV_5_2 */ #if (WDB_COMM_TYPE == WDB_COMM_NETROM) #define WDB_COMM_TYPE_STR "WDB_COMM_NETROM" #endif /* WDB_COMM_TYPE == WDB_COMM_NETROM */ #if (WDB_COMM_TYPE == WDB_COMM_VTMD) #define WDB_COMM_TYPE_STR "WDB_COMM_VTMD" #endif /* WDB_COMM_TYPE == WDB_COMM_VTMD */ #if (WDB_COMM_TYPE == WDB_COMM_END) #define WDB_COMM_TYPE_STR "WDB_COMM_END" #endif /* WDB_COMM_TYPE == WDB_COMM_END */ #if (WDB_COMM_TYPE == WDB_COMM_CUSTOM) #define WDB_COMM_TYPE_STR "WDB_COMM_CUSTOM" #endif /* WDB_COMM_TYPE == WDB_COMM_CUSTOM */ #if (WDB_COMM_TYPE == WDB_COMM_PIPE) #define WDB_COMM_TYPE_STR "WDB_COMM_PIPE" #endif /* WDB_COMM_TYPE == WDB_COMM_PIPE */ #ifndef WDB_COMM_TYPE_STR #define WDB_COMM_TYPE_STR "Unknown" #endif /* WDB_COMM_TYPE_STR */ #ifndef INCLUDE_SHELL /* WDB banner same as printed by usrWdbBanner */ printf ("\n\n"); printf ("%23s\n\n", runtimeName); printf ("Copyright 1984-2002 Wind River Systems, Inc.\n\n"); printf (" CPU: %s\n", sysModel ()); printf (" Runtime Name: %s\n", runtimeName); printf ("Runtime Version: %s\n", runtimeVersion); printf (" BSP version: " BSP_VERSION BSP_REV "\n"); printf (" Created: %s\n", creationDate); printf (" WDB Comm Type: %s\n", WDB_COMM_TYPE_STR); printf (" WDB: %s.\n\n", ((wdbRunsExternal () || wdbRunsTasking ()) ? "Ready" : "Agent configuration failed") ); printf("\n@@@@@line:%d, function:%s, file:%s",__LINE__,__FUNCTION__,__FILE__); #endif /*INCLUDE_SHELL*/ #endif /*INCLUDE_WDB_BANNER*/ #endif /* INCLUDE_WDB */ /* initialize interactive shell */ #ifdef INCLUDE_SHELL #ifdef INCLUDE_SECURITY /* include shell security */ printf("\n@@@@@line:%d, function:%s, file:%s",__LINE__,__FUNCTION__,__FILE__); if ((sysFlags & SYSFLG_NO_SECURITY) == 0) { printf("\n@@@@@line:%d, function:%s, file:%s",__LINE__,__FUNCTION__,__FILE__); loginInit (); /* initialize login table */ printf("\n@@@@@line:%d, function:%s, file:%s",__LINE__,__FUNCTION__,__FILE__); shellLoginInstall (loginPrompt, NULL); /* install security program */ printf("\n@@@@@line:%d, function:%s, file:%s",__LINE__,__FUNCTION__,__FILE__); /* add additional users here as required */ loginUserAdd (LOGIN_USER_NAME, LOGIN_PASSWORD); } #endif /* INCLUDE_SECURITY */ printf("\n@@@@@line:%d, function:%s, file:%s",__LINE__,__FUNCTION__,__FILE__); printLogo (); /* print out the banner page */ printf (" "); printf ("CPU: %s. Processor #%d.\n", sysModel (), sysProcNumGet ()); printf (" "); #ifdef HITACHI_SH_KERNEL_ON_SDRAM printf ("Memory Size: 0x%x.", (UINT)(sysMemTop () - (char *)FREE_RAM_ADRS)); #else /* HITACHI_SH_KERNEL_ON_SDRAM */ printf ("Memory Size: 0x%x.", (UINT)(sysMemTop () - (char *)LOCAL_MEM_LOCAL_ADRS)); #endif /* HITACHI_SH_KERNEL_ON_SDRAM */ printf (" BSP version " BSP_VERSION BSP_REV "."); #if defined(INCLUDE_WDB) && defined(INCLUDE_WDB_BANNER) printf ("\n "); printf ("WDB Comm Type: %s", WDB_COMM_TYPE_STR); printf ("\n "); printf ("WDB: %s.", ((wdbRunsExternal () || wdbRunsTasking ()) ? "Ready" : "Agent configuration failed") ); printf("\n@@@@@line:%d, function:%s, file:%s",__LINE__,__FUNCTION__,__FILE__); #endif /*INCLUDE_WDB && INCLUDE_WDB_BANNER*/ printf ("\n\n"); #ifdef INCLUDE_STARTUP_SCRIPT /* run a startup script */ if (sysBootParams.startupScript [0] != EOS) usrStartupScript (sysBootParams.startupScript); #endif /* INCLUDE_STARTUP_SCRIPT */ shellInit (SHELL_STACK_SIZE, TRUE); /* create the shell */ /* only include the simple demo if the shell is NOT included */ #else #if defined(INCLUDE_DEMO) /* create demo w/o shell */ taskSpawn ("demo", 20, 0, 2000, (FUNCPTR)usrDemo, 0,0,0,0,0,0,0,0,0,0); #endif /* mips cpp no elif */ #endif /* INCLUDE_SHELL */ #ifdef INCLUDE_WINDML usrWindMlInit (); #endif /* INCLUDE_WINDML */ #if defined (INCLUDE_SOUND) && defined(INCLUDE_SB16) sb16Drv (); /* install sound driver SB16 */ sb16DevCreate ("/sound", 0x220, 5, 1, 5); #endif /* INCLUDE_SOUND && INCLUDE_SB16 */ #if defined (INCLUDE_SOUND_CODEC) sndDac3550Drv (); /* install sound driver Dac3550a */ sndDac3550DevCreate ("/sound", 0x220, 5, 1, 5); #endif #if defined(INCLUDE_JAVA) javaConfig (); #endif /* INCLUDE_JAVA */ #ifdef INCLUDE_HTML usrHtmlInit (); #endif /* INCLUDE_HTML */ #if CPU==SIMNT win_ReleaseMutex(simUpMutex); #endif #ifdef INCLUDE_USER_APPL /* Startup the user's application */ USER_APPL_INIT; /* must be a valid C statement or block */ #endif }
//************************************************************************************** //*** //*** //*** //************************************************************************************** void main() { uchar cmd; schar j; uchar fname[14]; unsigned i; long swtrig = 0; picInit(); memInit(); serSendString("\r\nxPIClog\r\n"); serSendString("=======\r\n"); serUsage(); serSendString("\r\n\r\nCOLD START\r\n"); serSendString("CHECK TIME AND DATE!\r\n\r\n"); SDPOW(1); // SD card power on pinInitSD(); // other SD card pins filReadConfig("poweron"); pinExitSD(); // prepare card shutdown SDPOW(0); // SD card power on // a little ugly... for(;;) { // MENU LOOP for(;;) { // check serial commands cmd = cmdCheck(EXEC); // check pushbutton if( !SWITCH ) { LED(1); if( swtrig++ > 120000 ) cmd = CMD_OFF; } else { LED(1); // new v0.8a -> dim LED light during menu operation if( ( swtrig < 120000)&&(swtrig > 1000) ) cmd = CMD_START; swtrig = 0; LED(0); } if( cmd == CMD_START ) break; // power off? if( cmd == CMD_OFF ) { serSendString("\r\n\r\nGOING TO SLEEP\r\n\r\n"); LED(0); swtrig = 0; for(i=0;i<2000;i++) LED(1); LED(0); POWOUT(0); pinExitSD(); // prepare card shutdown SDPOW(0); // SD card power off BANDGAP(0); // voltage reference off sleep(); nop(); nop(); while( !SWITCH ) LED(1); LED(0); serSendString("\r\n\r\nWOKE UP\r\n\r\n"); cmd = CMD_LOAD; // ;-) } // read config file? if( cmd == CMD_LOAD ) { SDPOW(1); // SD card power on pinInitSD(); // other SD card pins filReadConfig((uchar *)&sCfg.crdFName); pinExitSD(); // prepare card shutdown SDPOW(0); // SD card power on }// END CMD load // read config file? if( cmd == CMD_SAVE ) { SDPOW(1); // SD card power on pinInitSD(); // other SD card pins filSaveConfig((uchar *)&sCfg.crdFName); pinExitSD(); // prepare card shutdown SDPOW(0); // SD card power on }// END CMD load }// END for menu loop // PREPARE ACQUISITION for(j=0;j<10;j++) { for(i=0;i<20000;i++) LED(1); for(i=0;i<20000;i++) LED(0); } serSendString("\r\nSTART\r\n"); measStorInit(); // new v0.8a; might be advantageous to clear the buffer first... rtcSetAlarm(sCfg.rtcSUnit,sCfg.rtcSRate); rtcEnableAlarm(); // ACQUISITION LOOP for(;;) { if( sCfg.rtcActive == NO ) break; if( sCfg.rtcSleep ) { sleep(); nop(); nop(); } } rtcDisableAlarm(); SDPOW(1); // SD card power on pinInitSD(); // other SD card pins LED(1); // just in case we left because of a serial transmission... serRXBufFlushIn(); serRXBufInit(); serSendString("\r\nWRITE PENDING DATA: "); strcpy((uchar *)&fname,(uchar*)&sCfg.crdFName); strcat((uchar *)&fname,".log"); // TODO if( (j=filOpenAppendClose((uchar *)&fname)) < 0) { // flush buffer while( measStorReadVMeas() > 0 ) {;} serSendString("ERROR\r\n"); } else { sCfg.crdSamplesWritten+=(uchar)j; serSendString("OK\r\n"); } pinExitSD(); // prepare card shutdown SDPOW(0); // SD card power off serSendString("\r\nSTOP\r\n"); // long->ulong might overflow (in years ;-) serSendStringDebug("SAMPLES WRITTEN: ",(long)sCfg.crdSamplesWritten,"\r\n"); while( !SWITCH ) {;} LED(0); }// END main for loop }