static int do_boot(void *arg) { thread_sleep(250); /* sniff it to see if it's a bootimage or a raw image */ bootimage_t *bi; if (bootimage_open(lkb_iobuffer, lkb_iobuffer_size, &bi) >= 0) { void *ptr; size_t len; /* it's a bootimage */ TRACEF("detected bootimage\n"); /* find the lk image */ if (bootimage_get_file_section(bi, TYPE_LK, &ptr, &len) >= 0) { TRACEF("found lk section at %p\n", ptr); arch_chain_load(ptr, 5, 6, 7, 8); } } else { /* raw image, just chain load it directly */ TRACEF("raw image, chainloading\n"); arch_chain_load(lkb_iobuffer, 1, 2, 3, 4); } return 0; }
void SSD_Ddm::Reply_With_Status(Message *p_message, STATUS status) { TRACEF(TRACE_L5, ("\nReply_With_Status: req_code = %X, status = %X", p_message->reqCode, status)); // Set the status of the reply. p_message->DetailedStatusCode = status; // Get pointer to block storage request payload. BSA_RW_PAYLOAD *p_BSA = (BSA_RW_PAYLOAD *)p_message->GetPPayload(); // Clear the reply payload. BSA_REPLY_PAYLOAD reply_payload; memset(&reply_payload, 0, sizeof(BSA_REPLY_PAYLOAD)); // Set zero transfer byte count in reply. reply_payload.TransferCount = 0; // Save logical block address in context for reply. reply_payload.LogicalBlockAddress = p_BSA->LogicalBlockAddress; // Add the payload to the reply message. p_message->AddReplyPayload(&reply_payload, sizeof(BSA_REPLY_PAYLOAD)); // Reply to caller Reply(p_message); Decrement_Requests_Outstanding(); TRACEF(TRACE_L5, ("\nReply_With_Status: Return from reply, requests outstanding = %d", m_num_requests_outstanding)); } // SSD_Ddm::Reply_With_Status
static int chargen_server(void *arg) { status_t err; tcp_socket_t *listen_socket; err = tcp_open_listen(&listen_socket, 19); if (err < 0) { TRACEF("error opening chargen listen socket\n"); return -1; } for (;;) { tcp_socket_t *accept_socket; err = tcp_accept(listen_socket, &accept_socket); TRACEF("tcp_accept returns returns %d, handle %p\n", err, accept_socket); if (err < 0) { TRACEF("error accepting socket, retrying\n"); continue; } TRACEF("starting chargen worker\n"); thread_detach_and_resume(thread_create("chargen_worker", &chargen_worker, accept_socket, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE)); } }
void FF_Controller::Mark_Unit_Not_Busy(Flash_Address flash_address) { // Check to see if the unit_index is busy. // For the HBC, only one device can be accessed at one time. U32 unit_index = flash_address.Unit_Index(); CT_ASSERT(unit_index < Flash_Address::Num_Units(), FF_Controller::Mark_Unit_Not_Busy); CT_ASSERT(FF_Controller::m_p_controller_context[unit_index], FF_Controller::Mark_Unit_Not_Busy); // Set callback context for this unit_index to null because it is // no longer busy. m_p_controller_context[unit_index] = 0; if (m_can_units_overlap) { // See if another context is waiting for this unit_index. if (!LIST_IS_EMPTY(&m_context_list_wait_unit[unit_index])) { m_p_flash->m_stats.Dec_Num_Waits_Unit(unit_index); FF_Controller_Context *p_controller_context; p_controller_context = (FF_Controller_Context *)LIST_REMOVE_HEAD( &m_context_list_wait_unit[unit_index]); TRACEF(TRACE_L5, (EOL "Mark_Unit_Not_Busy Making context ready for unit_index = %d", p_controller_context->m_flash_address.Unit_Index())); // Queue context back on ready list for execution. p_controller_context->Make_Ready(); } } // m_can_units_overlap else { // See if another context is waiting for any unit. U32 num_units = Flash_Address::Num_Units(); for (U32 any_unit_index = 0; any_unit_index < num_units; any_unit_index++) { if (!LIST_IS_EMPTY(&m_context_list_wait_unit[any_unit_index])) { m_p_flash->m_stats.Dec_Num_Waits_Unit(any_unit_index); FF_Controller_Context *p_controller_context; p_controller_context = (FF_Controller_Context *)LIST_REMOVE_HEAD( &m_context_list_wait_unit[any_unit_index]); TRACEF(TRACE_L5, (EOL "Mark_Unit_Not_Busy Making context ready for unit_index = %d", p_controller_context->m_flash_address.Unit_Index())); // Queue context back on ready list for execution. p_controller_context->Make_Ready(); return; } } } // NOT m_can_units_overlap } // FF_Controller::Mark_Unit_Not_Busy
static void usbtest_entry(const struct app_descriptor *app, void *args) { LTRACE_ENTRY; TRACEF("starting usb stack\n"); usb_start(); // XXX get callback from stack thread_sleep(2000); TRACEF("queuing transfers\n"); queue_rx_transfer(); queue_tx_transfer(); while (event_wait(&testevent) == NO_ERROR) { if (!rxqueued) { /* dump the state of the transfer */ LTRACEF("rx transfer completed\n"); usbc_dump_transfer(&rx); hexdump8(rx.buf, MIN(128, rx.bufpos)); queue_rx_transfer(); } if (!txqueued) { /* dump the state of the transfer */ LTRACEF("tx transfer completed\n"); usbc_dump_transfer(&tx); queue_tx_transfer(); } } LTRACE_EXIT; }
}END_TEST START_TEST( test_PopFromCharRingBuffer) { int nRc = -1; size_t nItemsLeft = 999; size_t nPopBufferSize = 14; size_t nItemsRead = 0; char szBuffer1[] = "LiveMem1"; char szBuffer2[] = "LiveMem2"; char szPopBuffer[14] = ""; struct RingBuffer *pStruct = InitCharRingBuffer(); TRACEF(7,(" test_PopFromCharRingBuffer()\n")); if (pStruct != NULL) { nItemsLeft = PushToCharRingBuffer(pStruct, szBuffer1, strlen( szBuffer1)); DumpCharRingBufferInfo(pStruct); nItemsLeft = PushToCharRingBuffer(pStruct, szBuffer2, strlen( szBuffer2)); DumpCharRingBufferInfo(pStruct); TRACEF(7,(" Items read: %Zi writen: '%s' read: '%s'\n", nItemsRead, szBuffer1, szPopBuffer )); nItemsRead = PopFromCharRingBuffer(pStruct, szPopBuffer, 8); DumpCharRingBufferInfo(pStruct); szPopBuffer[nItemsRead]; } TRACEF(7,(" Items read: %Zi writen: '%s' read: '%s'\n", nItemsRead, szBuffer1, szPopBuffer )); fail_unless(strcmp(szBuffer1, szPopBuffer) == 0, "PopFromCharRingBuffer() not all data read."); nRc = DestroyRingBuffer(pStruct); }END_TEST
void DriveMonitorIsm::DM_Create_Bsa_Device(void *p, DM_DEVICE_STATE *pDMState, pDMCallback_t Callback) { DM_CR_CONTEXT *pCC = new DM_CR_CONTEXT; STATUS status; TRACE_ENTRY(DM_Create_Bsa_Device); pCC->p = p; pCC->pDMState = pDMState; pCC->Callback = Callback; pCC->flags = 0; if (DM_Find_Bsa_Device(pDMState)) { TRACEF(TRACE_L3, ("\n\rDM: Bsa Vdn %d found", pDMState->pPD->vdnDdm)); // found a pre-configured device for this device, call end DM_Create_Bsa_End(pCC, 0); return; } TRACEF(TRACE_L3, ("\n\rDM: Bsa Create Started")); // create a virtual device status = DM_Create_InsertBSACfg(pCC, OK); } // DM_Create_Bsa_Device
int StoreStorageData(FILE *LogFileHandle, struct StorageInformationStructure *pInfoStruct) { int nStatus = 0; TRACEF(7,(" StoreStorageData(%p,%p)\n", LogFileHandle, pInfoStruct)); int nStorageIndex = 0; for (nStorageIndex = 0; nStorageIndex < pInfoStruct->nNumberOfDisksSupported; nStorageIndex++) { struct StorageStatistics *pStruct = pInfoStruct->arStorageStatisticsPointerArray[nStorageIndex]; TRACEF(7,(" StorageStatistics[%d] %p\n", nStorageIndex, pStruct)); fprintf(LogFileHandle, " <cpu Name=\"dsk%d\">", nStorageIndex); fprintf(LogFileHandle, " <nrd>%lu</nrd>", pStruct->nrd); fprintf(LogFileHandle, " <nwr>%lu</nwr>", pStruct->nwr); fprintf(LogFileHandle, " <rd>%lu</rd>", pStruct->rd); fprintf(LogFileHandle, " <wr>%lu</wr>", pStruct->wr); //fprintf(LogFileHandle, " <wcnt>%lu</wcnt>", pStruct->wcnt); //fprintf(LogFileHandle, " <rcnt>%lu</rcnt>", pStruct->rcnt); fprintf(LogFileHandle, " <wtime>%lu</wtime>", pStruct->wtime); fprintf(LogFileHandle, " <rtime>%lu</rtime>", pStruct->rtime); fprintf(LogFileHandle, " <ioinprogress>%lu</ioinprogress>", pStruct->ioinprogress); fprintf(LogFileHandle, " <iotime>%lu</iotime>", pStruct->iotime); fprintf(LogFileHandle, " <weightediotime>%lu</weightediotime>", pStruct->weightediotime); fprintf(LogFileHandle, " </cpu>\n"); } // next nStorageIndex. return (nStatus); } // end StoreStorageData.
}END_TEST START_TEST( test_PopFromCharRingBuffer_read_beyond_buffer) { int nRc = -1; size_t nItemsLeft = 999; size_t nPopBufferSize = 14; size_t nItemsRead = 0; char szBuffer[] = "LiveMem"; char szPopBuffer[14] = ""; TRACEF(7,(" test_PopFromCharRingBuffer_read_beyond_buffer()\n")); struct RingBuffer *pStruct = InitCharRingBuffer(); if (pStruct != NULL) { nItemsLeft = PushToCharRingBuffer(pStruct, szBuffer, strlen( szBuffer)); nItemsRead = PopFromCharRingBuffer(pStruct, szPopBuffer, nPopBufferSize - 1); szPopBuffer[nItemsRead]; TRACEF(7,(" Items read: %Zi writen: '%s' read: '%s'\n", nItemsRead, szBuffer, szPopBuffer )); nItemsRead = PopFromCharRingBuffer(pStruct, szPopBuffer, nPopBufferSize - 1); } fail_unless(nItemsRead == 0, "PopFromCharRingBuffer() There was data available read."); nRc = DestroyRingBuffer(pStruct); }END_TEST
static int encode_int(struct microjs_sdt * microjs, int32_t x) { #if MICROJS_OPTIMIZATION_ENABLED microjs->spc = microjs->pc; /* save code pointer */ #endif TRACEF("%04x\t", microjs->pc); if (x >= 0) { if (x < 32768) { if (x < 128) { if (x < 8) { TRACEF("I4 %d\n", x); microjs->code[microjs->pc++] = OPC_I4 + x; } else { TRACEF("I8 %d\n", x); microjs->code[microjs->pc++] = OPC_I8; microjs->code[microjs->pc++] = x; } } else { TRACEF("I16 %d\n", x); microjs->code[microjs->pc++] = OPC_I16; microjs->code[microjs->pc++] = x; microjs->code[microjs->pc++] = x >> 8; } } else { TRACEF("I32 %d\n", x); microjs->code[microjs->pc++] = OPC_I32; microjs->code[microjs->pc++] = x; microjs->code[microjs->pc++] = x >> 8; microjs->code[microjs->pc++] = x >> 16; microjs->code[microjs->pc++] = x >> 24; } } else {
DynamicLib* rvmOpenDynamicLib(Env* env, const char* file, char** errorMsg) { *errorMsg = NULL; DynamicLib* dlib = NULL; void* handle = dlopen(file, RTLD_LOCAL | RTLD_LAZY); if (!handle) { *errorMsg = dlerror(); TRACEF("Failed to load dynamic library '%s': %s", file, *errorMsg); return NULL; } if (file) { TRACEF("Opening dynamic library '%s'", file); } dlib = rvmAllocateMemoryAtomicUncollectable(env, sizeof(DynamicLib)); if (!dlib) { dlclose(handle); return NULL; } dlib->handle = handle; if (file) { strncpy(dlib->path, file, sizeof(dlib->path) - 1); } else { strncpy(dlib->path, env->vm->options->imagePath, sizeof(dlib->path) - 1); } return dlib; }
void smc91c96_init(void) { int i; TRACE; // try to detect it if ((*SMC_REG16(SMC_BSR) & 0xff00) != 0x3300) { TRACEF("didn't see smc91c96 chip at 0x%x\n", (unsigned int)smc91c96_base); } // read revision smc_bank(3); TRACEF("detected, revision 0x%x\n", *SMC_REG16(SMC_REV)); // read in the mac address smc_bank(1); for (i = 0; i < 6; i++) { mac_addr[i] = *SMC_REG8(SMC_IAR0 + i); } TRACEF("mac address %02x:%02x:%02x:%02x:%02x:%02x\n", mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]); smc_bank(0); }
int FF_Controller::Is_Unit_Busy( FF_Controller_Context *p_controller_context) { // Check to see if the unit_index is busy. // For the HBC, only one device can be accessed at one time. U32 unit_index = p_controller_context->m_flash_address.Unit_Index(); if (m_can_units_overlap) { // Check this unit to see if it's busy. if (m_p_controller_context[unit_index] != 0) { TRACEF(TRACE_L5, (EOL "Unit is busy, unit_index = %d", p_controller_context->m_flash_address.Unit_Index())); // It is busy, so the context must wait. m_p_flash->m_stats.Inc_Num_Waits_Unit(unit_index); // Put this context on the wait list for the unit_index. LIST_INSERT_TAIL(&m_context_list_wait_unit[unit_index], &p_controller_context->m_list); return 1; } // unit_index is busy } else { // Check to see if any unit is busy. U32 num_units = Flash_Address::Num_Units(); for (U32 any_unit_index = 0; any_unit_index < num_units; any_unit_index++) { if (m_p_controller_context[any_unit_index] != 0) { TRACEF(TRACE_L5, (EOL "Unit is busy, any_unit_index = %d", p_controller_context->m_flash_address.Unit_Index())); // A unit is busy, so the context must wait. m_p_flash->m_stats.Inc_Num_Waits_Unit(unit_index); // Put this context on the wait list for the unit_index. LIST_INSERT_TAIL(&m_context_list_wait_unit[unit_index], &p_controller_context->m_list); return 1; } // unit_index is busy } // Continue if no unit is busy. } // Unit is not busy. // Save the pointer to the callback context that will be run // when the command finished. // The caller will start the command. m_p_controller_context[unit_index] = p_controller_context; return 0; } // Is_Unit_Busy
}END_TEST START_TEST( test_GetCharRecord) { int nRc = -1; size_t nItemsLeft = 999; size_t nPopBufferSize = 14; size_t nItemsRead = 0; char szBuffer[] = "LiveMem1\nLiveMem2\n"; char szPopBuffer[14] = ""; struct RingBuffer *pStruct = InitCharRingBuffer(); TRACEF(7,(" test_GetCharRecord()\n")); if (pStruct != NULL) { nItemsLeft = PushToCharRingBuffer(pStruct, szBuffer, strlen( szBuffer)); nItemsRead = GetCharRecord(pStruct, '\n', szPopBuffer, nPopBufferSize - 1); DumpCharRingBufferData(pStruct); TRACEF(7,(" GetCharRecord returned: %Zi writen: '%s' read: '%s'\n", nItemsRead, szBuffer, szPopBuffer )); // TRACEF(7,(" GetCharRecord returned: pStruct->pRingHead: '%s'\n", pStruct->pRingHead )); nItemsRead = GetCharRecord(pStruct, '\n', szPopBuffer, nPopBufferSize - 1); DumpCharRingBufferData(pStruct); TRACEF(7,(" GetCharRecord returned: %Zi writen: '%s' read: '%s'\n", nItemsRead, szBuffer, szPopBuffer )); } fail_unless(nItemsRead == 0, "GetCharRecord() Record not found."); nRc = DestroyRingBuffer(pStruct); }END_TEST
static ssize_t stm32_flash_bdev_erase(struct bdev *bdev, off_t offset, size_t len) { LTRACEF("dev %p, offset 0x%llx, len 0x%zx\n", bdev, offset, len); ssize_t total_erased = 0; HAL_FLASH_Unlock(); while (len > 0) { uint32_t sector = 0; off_t sector_offset = 0; off_t next_offset = 0; if (offset_to_sector(offset, §or, §or_offset, &next_offset) < 0) return ERR_INVALID_ARGS; FLASH_EraseInitTypeDef erase; erase.TypeErase = FLASH_TYPEERASE_SECTORS; erase.Sector = sector; erase.NbSectors = 1; erase.VoltageRange = FLASH_VOLTAGE_RANGE_3; // XXX LTRACEF("erase params: sector %u, num_sectors %u, next_offset 0x%llx\n", erase.Sector, erase.NbSectors, next_offset); if (1) { uint32_t sector_error; HAL_StatusTypeDef err = HAL_FLASHEx_Erase(&erase, §or_error); if (err != HAL_OK) { TRACEF("error starting erase operation, sector error %u\n", sector_error); total_erased = ERR_IO; break; } err = FLASH_WaitForLastOperation(HAL_MAX_DELAY); if (err != HAL_OK) { TRACEF("error waiting for erase operation to end, hal error %u\n", HAL_FLASH_GetError()); total_erased = ERR_IO; break; } // invalidate the cache on this region arch_invalidate_cache_range(FLASHAXI_BASE + sector_offset, next_offset - sector_offset); } // move to the next erase boundary total_erased += next_offset - sector_offset; off_t erased_bytes = next_offset - offset; if (erased_bytes >= len) break; len -= erased_bytes; offset = next_offset; } HAL_FLASH_Lock(); return total_erased; }
void print_stubs(vita_elf_stub_t *stubs, int num_stubs) { int i; for (i = 0; i < num_stubs; i++) { TRACEF(VERBOSE, " 0x%06x (%s):\n", stubs[i].addr, stubs[i].symbol ? stubs[i].symbol->name : "unreferenced stub"); TRACEF(VERBOSE, " Library: %u (%s)\n", stubs[i].library_nid, stubs[i].library ? stubs[i].library->name : "not found"); TRACEF(VERBOSE, " Module : %u (%s)\n", stubs[i].module_nid, stubs[i].module ? stubs[i].module->name : "not found"); TRACEF(VERBOSE, " NID : %u (%s)\n", stubs[i].target_nid, stubs[i].target ? stubs[i].target->name : "not found"); } }
//************************************************************************ // RaidDdmCommandCompletionReply // This method is called whenever we receive a status for any cmd we // submitted to the Raid DDM. // We check if the cmd completed successfully or not. If cmd completed // successfully, then we report the status of the cmd to the Cmd Sender // for the RMSTR cmd. Also we need to check if any events need to be // generated for the cmd completion e.g change priority etc // //************************************************************************ void DdmRAIDMstr ::RaidDdmCommandCompletionReply( STATUS completionCode, void *pStatusData, void *pCmdData, void *_pRmstrCmdContext) { CONTEXT *pRmstrCmdContext = (CONTEXT *)_pRmstrCmdContext; RaidRequest *pRaidRequest = (RaidRequest *)pCmdData; TRACEF(TRACE_L2,("\tRaidDdmCmdCompletionReply: Enter\n")); switch(completionCode){ case RMSTR_SUCCESS: break; default: // Resolve: // Log that the cmd failed to start TRACEF(TRACE_L1, ("\tRaidDdmCmdCompletionReply: ERROR CODE = 0x%x\n", completionCode)); m_pCmdServer->csrvReportCmdStatus( pRmstrCmdContext->cmdHandle, // handle completionCode, // completion code NULL, // result Data (void *)pRmstrCmdContext->pData);// Orig cmd info delete pRmstrCmdContext; return; } if (pRmstrCmdContext->cmdHandle) { // Report the status to cmdSender, that cmd // was submitted // Event will be reported when the RAID DDM reports back TRACEF(TRACE_L2,("\tRaidDdmCmdCompletionReply: Reporting status back to cmd sender\n")); m_pCmdServer->csrvReportCmdStatus( pRmstrCmdContext->cmdHandle, // handle RMSTR_SUCCESS, // completion code NULL, // result Data (void *)pRmstrCmdContext->pData);// Orig cmd info // check if we need to generate any special events // e.g for change priority CheckForEventsToBeGeneratedOnCmdCompletion( pRmstrCmdContext); StopCommandProcessing( true, pRmstrCmdContext->cmdHandle); } else { assert(pRmstrCmdContext->cmdHandle != NULL); } if (pRmstrCmdContext) { delete pRmstrCmdContext; pRmstrCmdContext = NULL; } }
//************************************************************************ // RaidDdmEventHandler // This method is called whenever the Raid DDM generates an event. // submitted to the Raid DDM. // We process UTILITY events, ARRAY offline events etc // //************************************************************************ void DdmRAIDMstr ::RaidDdmEventHandler( STATUS eventCode, void *pStatusData) { TRACEF_NF(TRACE_RMSTR,("\tRaidDdmEventHandler Enter:\n")); RaidEvent *pRaidEvent = NULL; RaidMemberDownEvent *pRaidMemberDownEvent = NULL; RaidOfflineEvent *pRaidOfflineEvent = NULL; TRACEF(TRACE_L2,("\tRaidDdmEventHandler: Enter\n")); switch(eventCode){ case RAID_EVT_UTIL_STARTED: case RAID_EVT_UTIL_STOPPED: case RAID_EVT_UTIL_PERCENT_COMPLETE: ProcessUtilityEvents(eventCode,pStatusData); break; case RAID_EVT_MEMBER_DOWN: pRaidEvent = (RaidEvent *)pStatusData; pRaidMemberDownEvent = &pRaidEvent->Event.MemberDown; TRACEF(TRACE_L2,("\tRaidDdmEventHandler: Member down event recvd\n")); StartInternalProcessMemberDownEvent( &pRaidMemberDownEvent->ArrayRowID, &pRaidMemberDownEvent->MemberRowID, pRaidMemberDownEvent->Reason); break; case RAID_EVT_ARRAY_OFFLINE: pRaidEvent = (RaidEvent *)pStatusData; pRaidOfflineEvent = &pRaidEvent->Event.RaidOffline; TRACEF(TRACE_L2,("\tRaidDdmEventHandler: Array offline event recvd\n")); StartInternalProcessArrayOfflineEvent( &pRaidOfflineEvent->ArrayRowID, &pRaidOfflineEvent->MemberRowID, pRaidOfflineEvent->Reason); break; #ifdef RMSTR_RAID_DDM_TEST case RAID_EVT_ENABLED: // This is temporary. Raid DDM lets us know that it is enabled and that it // has populated the ADT, MDT tables, so we can read them InitializeRmstrData(); break; #endif default: break; } return; }
}END_TEST START_TEST( test_GetNumberOfNics_Eth1Only) { int nRc = -2; char szNetDevFileName[] = "net_dev"; struct NicInformation stNicInformation; FILE *pFileHandle = fopen(szNetDevFileName, "w"); TRACEF(3,(" test_GetNumberOfNics_Eth1Only()\n")); if (pFileHandle != NULL) { fprintf(pFileHandle, "\n"); fprintf( pFileHandle, "Inter-| Receive | Transmit\n"); fprintf( pFileHandle, " face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed\n"); fprintf( pFileHandle, " lo:736517538 525971 0 0 0 0 0 0 736517538 525971 0 0 0 0 0 0\n"); fprintf( pFileHandle, " eth1:4022315145 4180846 0 0 0 0 0 31792 725452986 2341643 0 0 0 0 0 0\n"); fclose(pFileHandle); nRc = GetNumberOfNics(szNetDevFileName, &stNicInformation); unlink(szNetDevFileName); } fail_unless( ( (nRc != 0) && (stNicInformation.nBridge == 0) && (stNicInformation.nEth == 0)), "test_GetNumberOfNics_Eth1Only() couldn't identify 1 NIC"); }END_TEST
/* * usbrecords_find * check if we can recover device based on recovery queue * @param[t_token] recovery token to compare against * @ret -1 unable to recover, 0 success (token->user_data has handle) */ int usbrecords_find(transport_recovery_token_t *t_token) { int rc = -1; recovery_entry_t *item; recovery_entry_t *tmp_item; platform_mutex_lock(&recovery_lock); /* check all entries */ for (item = TAILQ_FIRST(&t_recovery_queue); item != NULL; item = tmp_item) { transport_recovery_token_t *token = item->t_token; tmp_item = TAILQ_NEXT(item, entries); if (token->len == t_token->len) { if( 0 == memcmp(token->token, t_token->token, token->len) ) { TRACEF("Matches, nduid(%s)\n", token->nduid); /* Remove the item from queue. */ TAILQ_REMOVE(&t_recovery_queue, item, entries); /* restore handle */ t_token->user_data = token->user_data; /* Free the item as we don't need it anymore. */ platform_free(item->t_token); platform_free(item); /* success */ rc = 0; break; } } } platform_mutex_unlock(&recovery_lock); return rc; }
/* * usbrecords_remove * @param[nduid] device nduid * @ret 0 - success, -1 error */ int usbrecords_remove(char *nduid) { recovery_entry_t *item; recovery_entry_t *tmp_item; LTRACEF("Update records\n"); platform_mutex_lock(&recovery_lock); /* check all entries */ for (item = TAILQ_FIRST(&t_recovery_queue); item != NULL; item = tmp_item) { tmp_item = TAILQ_NEXT(item, entries); if(0 == strncmp(item->t_token->nduid, nduid, sizeof(item->t_token->nduid)) ) { TRACEF("explicit remove::nduid(%s)\n", nduid); /* destroy handle */ novacom_usbll_destroy((novacom_usbll_handle_t)item->t_token->user_data); /* Remove the item from queue. */ TAILQ_REMOVE(&t_recovery_queue, item, entries); /* Free the item as we don't need it anymore. */ platform_free(item->t_token); platform_free(item); } } platform_mutex_unlock(&recovery_lock); return 0; }
/* * usbrecords_update * @param[elapsed] elapsed time * @ret 0 - success, -1 error */ int usbrecords_update(int elapsed) { recovery_entry_t *item; recovery_entry_t *tmp_item; LTRACEF("Update records\n"); platform_mutex_lock(&recovery_lock); /* check all entries */ for (item = TAILQ_FIRST(&t_recovery_queue); item != NULL; item = tmp_item) { tmp_item = TAILQ_NEXT(item, entries); /* update remaining recovery time */ item->timeout -= elapsed; PTRACEF(USB_RECOVERY, "Check entry(%p): timeout %d\n", item, item->timeout); /* expired? */ if(item->timeout < 0) { TRACEF("expired timeout::destroy record\n"); /* destroy handle */ novacom_usbll_destroy((novacom_usbll_handle_t)item->t_token->user_data); /* Remove the item from queue. */ TAILQ_REMOVE(&t_recovery_queue, item, entries); /* Free the item as we don't need it anymore. */ platform_free(item->t_token); platform_free(item); } } platform_mutex_unlock(&recovery_lock); return 0; }
void platform_init(void) { uart_init(); /* detect any virtio devices */ const uint virtio_irqs[] = { VIRTIO0_INT, VIRTIO1_INT, VIRTIO2_INT, VIRTIO3_INT }; virtio_mmio_detect((void *)VIRTIO_BASE, 4, virtio_irqs); #if WITH_LIB_MINIP if (virtio_net_found() > 0) { uint8_t mac_addr[6]; virtio_net_get_mac_addr(mac_addr); TRACEF("found virtio networking interface\n"); /* start minip */ minip_set_macaddr(mac_addr); __UNUSED uint32_t ip_addr = IPV4(192, 168, 0, 99); __UNUSED uint32_t ip_mask = IPV4(255, 255, 255, 0); __UNUSED uint32_t ip_gateway = IPV4_NONE; //minip_init(virtio_net_send_minip_pkt, NULL, ip_addr, ip_mask, ip_gateway); minip_init_dhcp(virtio_net_send_minip_pkt, NULL); virtio_net_start(); } #endif }
DdmConsoleTest::DdmConsoleTest(DID did) : Ddm(did) { TRACEF(TRACE_L8, ("EXEC DdmConsoleTest::DdmConsoleTest\n")); pDdmConsoleTest = this; }
static int atomic_tester(void *arg) { int add = (intptr_t)arg; int i; TRACEF("add %d\n", add); for (i=0; i < 1000000; i++) { atomic_add(&atomic, add); } int old = atomic_add(&atomic_count, -1); TRACEF("exiting, old count %d\n", old); return 0; }
static EvalResult _search_filter(const char *filename, void *user_data) { EvalResult result = EVAL_RESULT_TRUE; assert(filename != NULL); assert(user_data != NULL); FilterArgs *args = (FilterArgs *)user_data; if(args->result->root->filter_exprs) { TRACEF("search", "Filtering file: %s", filename); if(args->extensions) { result = evaluate(args->extensions, args->result->root->filter_exprs, filename); if(result == EVAL_RESULT_ABORTED) { fprintf(stderr, _("Evaluation aborted.\n")); } } else { fprintf(stderr, _("Couldn't evaluate expression, no extensions loaded.\n")); result = EVAL_RESULT_ABORTED; } } return result; }
STATUS DriveMonitorIsm::DM_Create_Bsa_End(void *pClientContext, STATUS status) { DM_CR_CONTEXT *pCC = (DM_CR_CONTEXT *)pClientContext; DM_DEVICE_STATE *pDMState = pCC->pDMState; pDMCallback_t Callback = pCC->Callback; TRACE_ENTRY(DM_Create_Bsa_End); if (status != ercOK) { TRACE_HEX(TRACE_L8, "\n\rDM_Create_Bsa_End: status = ", status); } else { TRACEF(TRACE_L3, ("\n\rDM: Created BSA Vdn %d ", pDMState->pPD->vdnDdm)); } // Do a callback if there is one if (Callback) (this->*Callback)((void *)pCC->p, status); delete pCC; return ercOK; } // DM_Create_Bsa_End
static int discard_worker(void *socket) { uint64_t count = 0; uint32_t crc = 0; tcp_socket_t *s = socket; lk_time_t t = current_time(); for (;;) { uint8_t buf[1024]; ssize_t ret = tcp_read(s, buf, sizeof(buf)); if (ret <= 0) break; crc = crc32(crc, buf, ret); count += ret; } t = current_time() - t; TRACEF("discard worker exiting, read %llu bytes in %u msecs (%llu bytes/sec), crc32 0x%x\n", count, (uint32_t)t, count * 1000 / t, crc); tcp_close(s); return 0; }
void arm_generic_timer_init(int irq, uint32_t freq_override) { uint32_t cntfrq; if (freq_override == 0) { cntfrq = read_cntfrq(); if (!cntfrq) { TRACEF("Failed to initialize timer, frequency is 0\n"); return; } } else { cntfrq = freq_override; } #if LOCAL_TRACE LTRACEF("Test min cntfrq\n"); arm_generic_timer_init_conversion_factors(1); test_time_conversions(1); LTRACEF("Test max cntfrq\n"); arm_generic_timer_init_conversion_factors(~0); test_time_conversions(~0); LTRACEF("Set actual cntfrq\n"); #endif arm_generic_timer_init_conversion_factors(cntfrq); test_time_conversions(cntfrq); LTRACEF("register irq %d on cpu %d\n", irq, arch_curr_cpu_num()); register_int_handler(irq, &platform_tick, NULL); unmask_interrupt(irq); timer_irq = irq; }
static LRESULT CALLBACK DelayedNotificationWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) // // This is the wndproc for the notification window // // it's here to dispatch the notifications to the client // { if( message == UWM_DELAYED_DIRECTORY_NOTIFICATION ) { CDirChangeNotification * pNotification = reinterpret_cast<CDirChangeNotification*>(lParam); ASSERT( pNotification ); if( pNotification ) { DWORD dwEx(0); __try { pNotification->DispatchNotificationFunction(); } __except(dwEx = GetExceptionCode(), EXCEPTION_EXECUTE_HANDLER) { //An exception was raised: // // Likely cause: there was a problem creating the CDelayedDirectoryChangeHandler::m_hWatchStoppedDispatchedEvent object // and the change handler object was deleted before the notification could be dispatched to this function. // // or perhaps, somebody's implementation of an overridden function caused an exception TRACEF(_T("Following exception occurred: %d -- File: %s Line: %d\n"), dwEx, _T(__FILE__), __LINE__); } }