int DeviceInit() { ClassInit(); BusInit(); InputInit(); return StorageInit(); }
static void XBitsTestSetup(void) { StorageInit(); HostBitInitCtx(); IPPairBitInitCtx(); StorageFinalize(); HostInitConfig(TRUE); IPPairInitConfig(TRUE); }
/************************************************* Function: LogicInit Description: Input: Output: Return: Others: *************************************************/ void LogicInit(void) { HarewareInit(); StorageInit(); GuiInit(); SetBeepIndex(_HW_BEEP_OK_); TimerStart(); LogicSetMasterCtl(FRAME_ADDR_PC); }
/************************************************* Function: LogicInit Description: Input: Output: Return: Others: *************************************************/ void LogicInit(void) { HarewareInit(); StorageInit(); PasswordInit(); OtherInit(); SendCommandAck(RFID_POWER_SYNC, NULL, 0); SetBeepIndex(_HW_BEEP_OK_); }
static int FlowStorageTest02(void) { Flow *f = NULL; StorageInit(); int id1 = FlowStorageRegister("test", sizeof(void *), NULL, StorageTestFree); if (id1 < 0) goto error; if (StorageFinalize() < 0) goto error; FlowInitConfig(FLOW_QUIET); f = FlowAlloc(); if (f == NULL) { goto error; } void *ptr = FlowGetStorageById(f, id1); if (ptr != NULL) { goto error; } void *ptr1a = SCMalloc(128); if (ptr1a == NULL) { goto error; } FlowSetStorageById(f, id1, ptr1a); void *ptr1b = FlowGetStorageById(f, id1); if (ptr1a != ptr1b) { goto error; } FlowClearMemory(f, 0); FlowFree(f); FlowShutdown(); StorageCleanup(); return 1; error: if (f != NULL) { FlowClearMemory(f, 0); FlowFree(f); } FlowShutdown(); StorageCleanup(); return 0; }
/********************************************************************************************************* ** 函数名称: InitAllIRQ ** 函数功能: 对所有需要的中断进行初始化 ** 入口参数: 无 ** 出口参数: 无 ** 函数说明: *********************************************************************************************************/ void InitAllIRQ(void) { /******************************** * 在此处添加中断初始化调用 *********************************/ // uint8 status; Time0Init(); //定时器 I2C1Init(I2C_CLK_100K); //I2C,默认速度100 I2C2Init(I2C_CLK_100K); //I2C,默认速度100 #ifndef __UCOS PCF8563Init(); //UCOS下在时间任务中初始化 // KeyboardInit(); //键盘任务中初始化 #endif StorageInit(); LCDInit(); DS18B20Init(); }
static int StorageTest01(void) { StorageInit(); int id = StorageRegister(STORAGE_HOST, "test", 8, StorageTestAlloc, StorageTestFree); if (id < 0) goto error; id = StorageRegister(STORAGE_HOST, "variable", 24, StorageTestAlloc, StorageTestFree); if (id < 0) goto error; id = StorageRegister(STORAGE_FLOW, "store", sizeof(void *), StorageTestAlloc, StorageTestFree); if (id < 0) goto error; if (StorageFinalize() < 0) goto error; StorageCleanup(); return 1; error: StorageCleanup(); return 0; }
static int FlowStorageTest01(void) { Flow *f = NULL; StorageInit(); int id1 = FlowStorageRegister("test", 8, StorageTestAlloc, StorageTestFree); if (id1 < 0) goto error; int id2 = FlowStorageRegister("variable", 24, StorageTestAlloc, StorageTestFree); if (id2 < 0) goto error; int id3 = FlowStorageRegister("store", sizeof(void *), StorageTestAlloc, StorageTestFree); if (id3 < 0) goto error; if (StorageFinalize() < 0) goto error; FlowInitConfig(FLOW_QUIET); f = FlowAlloc(); if (f == NULL) { goto error; } void *ptr = FlowGetStorageById(f, id1); if (ptr != NULL) { goto error; } ptr = FlowGetStorageById(f, id2); if (ptr != NULL) { goto error; } ptr = FlowGetStorageById(f, id3); if (ptr != NULL) { goto error; } void *ptr1a = FlowAllocStorageById(f, id1); if (ptr1a == NULL) { goto error; } void *ptr2a = FlowAllocStorageById(f, id2); if (ptr2a == NULL) { goto error; } void *ptr3a = FlowAllocStorageById(f, id3); if (ptr3a == NULL) { goto error; } void *ptr1b = FlowGetStorageById(f, id1); if (ptr1a != ptr1b) { goto error; } void *ptr2b = FlowGetStorageById(f, id2); if (ptr2a != ptr2b) { goto error; } void *ptr3b = FlowGetStorageById(f, id3); if (ptr3a != ptr3b) { goto error; } FlowClearMemory(f, 0); FlowFree(f); FlowShutdown(); StorageCleanup(); return 1; error: if (f != NULL) { FlowClearMemory(f, 0); FlowFree(f); } FlowShutdown(); StorageCleanup(); return 0; }
static int StorageTest03(void) { StorageInit(); int id = StorageRegister(STORAGE_HOST, "test", 8, StorageTestAlloc, StorageTestFree); if (id < 0) goto error; id = StorageRegister(STORAGE_HOST, "test", 8, StorageTestAlloc, StorageTestFree); if (id != -1) { printf("duplicate registration should have failed: "); goto error; } id = StorageRegister(STORAGE_HOST, "test1", 6, NULL, StorageTestFree); if (id != -1) { printf("duplicate registration should have failed (2): "); goto error; } id = StorageRegister(STORAGE_HOST, "test2", 8, StorageTestAlloc, NULL); if (id != -1) { printf("duplicate registration should have failed (3): "); goto error; } id = StorageRegister(STORAGE_HOST, "test3", 0, StorageTestAlloc, StorageTestFree); if (id != -1) { printf("duplicate registration should have failed (4): "); goto error; } id = StorageRegister(STORAGE_HOST, "", 8, StorageTestAlloc, StorageTestFree); if (id != -1) { printf("duplicate registration should have failed (5): "); goto error; } id = StorageRegister(STORAGE_HOST, NULL, 8, StorageTestAlloc, StorageTestFree); if (id != -1) { printf("duplicate registration should have failed (6): "); goto error; } id = StorageRegister(STORAGE_MAX, "test4", 8, StorageTestAlloc, StorageTestFree); if (id != -1) { printf("duplicate registration should have failed (7): "); goto error; } id = StorageRegister(38, "test5", 8, StorageTestAlloc, StorageTestFree); if (id != -1) { printf("duplicate registration should have failed (8): "); goto error; } id = StorageRegister(-1, "test6", 8, StorageTestAlloc, StorageTestFree); if (id != -1) { printf("duplicate registration should have failed (9): "); goto error; } StorageCleanup(); return 1; error: StorageCleanup(); return 0; }
static int StorageTest02(void) { struct StorageTest02Data *test = NULL; StorageInit(); int id1 = StorageRegister(STORAGE_HOST, "test", 4, StorageTest02Init, StorageTestFree); if (id1 < 0) { printf("StorageRegister failed (2): "); goto error; } int id2 = StorageRegister(STORAGE_HOST, "test2", 4, StorageTest02Init, StorageTestFree); if (id2 < 0) { printf("StorageRegister failed (2): "); goto error; } if (StorageFinalize() < 0) { printf("StorageFinalize failed: "); goto error; } Storage *storage = NULL; void *data = StorageAllocById(&storage, STORAGE_HOST, id1); if (data == NULL) { printf("StorageAllocById failed, data == NULL, storage %p: ", storage); goto error; } test = (struct StorageTest02Data *)data; if (test->abc != 1234) { printf("setup failed, test->abc != 1234, but %d (1):", test->abc); goto error; } test->abc = 4321; data = StorageAllocById(&storage, STORAGE_HOST, id2); if (data == NULL) { printf("StorageAllocById failed, data == NULL, storage %p: ", storage); goto error; } test = (struct StorageTest02Data *)data; if (test->abc != 1234) { printf("setup failed, test->abc != 1234, but %d (2):", test->abc); goto error; } data = StorageGetById(storage, STORAGE_HOST, id1); if (data == NULL) { printf("StorageAllocById failed, data == NULL, storage %p: ", storage); goto error; } test = (struct StorageTest02Data *)data; if (test->abc != 4321) { printf("setup failed, test->abc != 4321, but %d (3):", test->abc); goto error; } //StorageFreeById(storage, STORAGE_HOST, id1); //StorageFreeById(storage, STORAGE_HOST, id2); StorageFree(&storage, STORAGE_HOST); StorageCleanup(); return 1; error: StorageCleanup(); return 0; }
int main( void ) { volatile unsigned long ul; // Initialize address and notify host pCurrent = (u08*)vStart; u32 kopycounter=0; prvSetupHardware( ); // Version Controll debug_msg( "NowBoot V1.2; Compiled at: "__DATE__" "__TIME__"\r"); wait_ms(1000); debug_msg("NowBoot: Running drives and filesystem."); StorageInit(); wait_ms(100); debug_msg("NowBoot: Checking for new firmware..."); //f_rename ( "1:fmw/fmw_n.old", "fmw/fmw_n.bin" ); //For tests only res = f_open(&firmwarefile, "1:fmw/fmw_n.bin", FA_OPEN_EXISTING | FA_READ); if(res != FR_OK){ f_close(&firmwarefile); debug_msg("NowBoot: Can`t find new firmware."); debug_msg("NowBoot: Checking for in-flash firmware"); if((*((u08*)vStart+4)==0xFF)&&(*((u08*)(vStart+5))==0xff)){ debug_msg("NowBoot: Flash is empty!"); debug_msg("NowBoot: Opening default firmware!"); res = f_open(&firmwarefile, "1:fmw/fmw_0.bin", FA_OPEN_EXISTING | FA_READ); if(res != FR_OK){ f_close(&firmwarefile); debug_msg("NowBoot: Can`t find any firmware file... Nothing to do."); for(;;)AT91C_BASE_SYS->WDTC_WDCR = 0xA5000001; //endless loop } goto fmw_prog; } else{ debug_msg("NowBoot: Flash contain firmware."); goto app_now; } }else{ debug_msg("NowBoot: Found new firmware."); fmw_prog: debug_msg("NowBoot: Start programming..."); wait_ms(300); debug_txt("\rCopying page: "); for (;;) { debug_txt("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bKopiuje strone: "); debug32_tdec(kopycounter++); res = f_read(&firmwarefile, page, sizeof(page), &br); /* Read a chunk of src file */ if (res || br == 0) { wait_ms(100); debug_msg("NowBoot: Copying finshed."); break; /* error or eof */ } //memset(page,0xff,sizeof(page)); //for tests only flash_write(pCurrent , (void *) page ); pCurrent+= MEMORY_PAGE_SIZE; } } f_close(&firmwarefile); /* TO DO: MD5 verification */ wait_ms(300); debug_msg("NowBoot: Firmware upgrade successful."); debug_msg("NowBoot: Removing firmware file."); f_unlink ( "1:fmw/fmw_n.old" ); //removeing old firmware f_rename ( "1:fmw/fmw_n.bin", "fmw/fmw_n.old" ); app_now: wait_ms(100); debug_msg("NowBoot: End of Boot."); spiInit(); wait_ms(1000); AT91C_BASE_SYS->WDTC_WDCR = 0xA5000001; //WDT restart asm volatile( "LDR pc, =0x00108000" //Jump to firmware start ); debug_msg("NowBoot: Something bad happened! I should never be here."); wait_ms(100); vPortSoftReset(); return 0; }
void RunUnittests(int list_unittests, char *regex_arg) { #ifdef UNITTESTS /* Initializations for global vars, queues, etc (memsets, mutex init..) */ GlobalInits(); TimeInit(); SupportFastPatternForSigMatchTypes(); default_packet_size = DEFAULT_PACKET_SIZE; #ifdef __SC_CUDA_SUPPORT__ /* Init the CUDA environment */ SCCudaInitCudaEnvironment(); CudaBufferInit(); #endif /* load the pattern matchers */ MpmTableSetup(); #ifdef __SC_CUDA_SUPPORT__ MpmCudaEnvironmentSetup(); #endif SpmTableSetup(); AppLayerSetup(); /* hardcoded initialization code */ SigTableSetup(); /* load the rule keywords */ TmqhSetup(); StorageInit(); CIDRInit(); SigParsePrepare(); #ifdef DBG_MEM_ALLOC SCLogInfo("Memory used at startup: %"PRIdMAX, (intmax_t)global_mem); #endif SCReputationInitCtx(); SCProtoNameInit(); TagInitCtx(); SCReferenceConfInit(); SCClassConfInit(); UtInitialize(); RegisterAllModules(); HostBitInitCtx(); StorageFinalize(); /* test and initialize the unittesting subsystem */ if(regex_arg == NULL){ regex_arg = ".*"; UtRunSelftest(regex_arg); /* inits and cleans up again */ } AppLayerHtpEnableRequestBodyCallback(); AppLayerHtpNeedFileInspection(); UTHRegisterTests(); StreamTcpRegisterTests(); SigRegisterTests(); SCReputationRegisterTests(); TmModuleRegisterTests(); SigTableRegisterTests(); HashTableRegisterTests(); HashListTableRegisterTests(); BloomFilterRegisterTests(); BloomFilterCountingRegisterTests(); PoolRegisterTests(); ByteRegisterTests(); MpmRegisterTests(); FlowBitRegisterTests(); HostBitRegisterTests(); IPPairBitRegisterTests(); StatsRegisterTests(); DecodePPPRegisterTests(); DecodeVLANRegisterTests(); DecodeRawRegisterTests(); DecodePPPOERegisterTests(); DecodeICMPV4RegisterTests(); DecodeICMPV6RegisterTests(); DecodeIPV4RegisterTests(); DecodeIPV6RegisterTests(); DecodeTCPRegisterTests(); DecodeUDPV4RegisterTests(); DecodeGRERegisterTests(); DecodeAsn1RegisterTests(); DecodeMPLSRegisterTests(); AppLayerProtoDetectUnittestsRegister(); ConfRegisterTests(); ConfYamlRegisterTests(); TmqhFlowRegisterTests(); FlowRegisterTests(); HostRegisterUnittests(); IPPairRegisterUnittests(); SCSigRegisterSignatureOrderingTests(); SCRadixRegisterTests(); DefragRegisterTests(); SigGroupHeadRegisterTests(); SCHInfoRegisterTests(); SCRuleVarsRegisterTests(); AppLayerParserRegisterUnittests(); ThreadMacrosRegisterTests(); UtilSpmSearchRegistertests(); UtilActionRegisterTests(); SCClassConfRegisterTests(); SCThresholdConfRegisterTests(); SCRConfRegisterTests(); #ifdef __SC_CUDA_SUPPORT__ SCCudaRegisterTests(); #endif PayloadRegisterTests(); DcePayloadRegisterTests(); UriRegisterTests(); #ifdef PROFILING SCProfilingRegisterTests(); #endif DeStateRegisterTests(); DetectRingBufferRegisterTests(); MemcmpRegisterTests(); DetectEngineHttpClientBodyRegisterTests(); DetectEngineHttpServerBodyRegisterTests(); DetectEngineHttpHeaderRegisterTests(); DetectEngineHttpRawHeaderRegisterTests(); DetectEngineHttpMethodRegisterTests(); DetectEngineHttpCookieRegisterTests(); DetectEngineHttpRawUriRegisterTests(); DetectEngineHttpStatMsgRegisterTests(); DetectEngineHttpStatCodeRegisterTests(); DetectEngineHttpUARegisterTests(); DetectEngineHttpHHRegisterTests(); DetectEngineHttpHRHRegisterTests(); DetectEngineInspectModbusRegisterTests(); DetectEngineRegisterTests(); DetectEngineSMTPFiledataRegisterTests(); SCLogRegisterTests(); MagicRegisterTests(); UtilMiscRegisterTests(); DetectAddressTests(); DetectProtoTests(); DetectPortTests(); SCAtomicRegisterTests(); MemrchrRegisterTests(); #ifdef __SC_CUDA_SUPPORT__ CudaBufferRegisterUnittests(); #endif AppLayerUnittestsRegister(); MimeDecRegisterTests(); StreamingBufferRegisterTests(); if (list_unittests) { UtListTests(regex_arg); } else { /* global packet pool */ extern intmax_t max_pending_packets; max_pending_packets = 128; PacketPoolInit(); uint32_t failed = UtRunTests(regex_arg); PacketPoolDestroy(); UtCleanup(); #ifdef BUILD_HYPERSCAN MpmHSGlobalCleanup(); #endif #ifdef __SC_CUDA_SUPPORT__ if (PatternMatchDefaultMatcher() == MPM_AC_CUDA) MpmCudaBufferDeSetup(); CudaHandlerFreeProfiles(); #endif if (failed) { exit(EXIT_FAILURE); } } #ifdef DBG_MEM_ALLOC SCLogInfo("Total memory used (without SCFree()): %"PRIdMAX, (intmax_t)global_mem); #endif exit(EXIT_SUCCESS); #else SCLogError(SC_ERR_NOT_SUPPORTED, "Unittests are not build-in"); exit(EXIT_FAILURE); #endif /* UNITTESTS */ }