docstring
stringlengths
22
576
signature
stringlengths
9
317
prompt
stringlengths
57
886
code
stringlengths
20
1.36k
repository
stringclasses
49 values
language
stringclasses
2 values
license
stringclasses
9 values
stars
int64
15
21.3k
/* This is the entry point for the bootloader application and is called by the reset interrupt vector after the C-startup routines executed. */
int main(void)
/* This is the entry point for the bootloader application and is called by the reset interrupt vector after the C-startup routines executed. */ int main(void)
{ Init(); BootComInit(); while (1) { LedToggle(); BootComCheckActivationRequest(); } return 0; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Removes an interrupt handler for the specified PWM generator block. */
void PWMGenIntUnregister(unsigned long ulBase, unsigned long ulGen)
/* Removes an interrupt handler for the specified PWM generator block. */ void PWMGenIntUnregister(unsigned long ulBase, unsigned long ulGen)
{ unsigned long ulInt; ASSERT(ulBase == PWM_BASE); ASSERT(PWMGenValid(ulGen)); if(ulGen == PWM_GEN_3) { ulInt = INT_PWM3; } else { ulInt = INT_PWM0 + (ulGen >> 6) - 1; } IntDisable(ulInt); IntUnregister(ulInt); }
watterott/WebRadio
C++
null
71
/* Provide an error response when an HCI command send failed. */
static void error_response(int error)
/* Provide an error response when an HCI command send failed. */ static void error_response(int error)
{ uint16_t response = sys_cpu_to_le16(waiting_response); int le_error = sys_cpu_to_le32(error); uint16_t size = sys_cpu_to_le16(sizeof(le_error)); edtt_write((uint8_t *)&response, sizeof(response), EDTTT_BLOCK); edtt_write((uint8_t *)&size, sizeof(size), EDTTT_BLOCK); edtt_write((uint8_t *)&le_error, sizeof(le_error), EDTTT_BLOCK); waiting_response = CMD_NOTHING; waiting_opcode = 0; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Variance of the elements of a floating-point vector. */
void arm_var_f64(const float64_t *pSrc, uint32_t blockSize, float64_t *pResult)
/* Variance of the elements of a floating-point vector. */ void arm_var_f64(const float64_t *pSrc, uint32_t blockSize, float64_t *pResult)
{ uint32_t blkCnt; float64_t sum = 0.; float64_t fSum = 0.; float64_t fMean, fValue; const float64_t * pInput = pSrc; if (blockSize <= 1U) { *pResult = 0; return; } blkCnt = blockSize; while (blkCnt > 0U) { sum += *pInput++; blkCnt--; } fMean = sum / (float64_t) blockSize; pInput = pSrc; blkCnt = blockSize; while (blkCnt > 0U) { fValue = *pInput++ - fMean; fSum += fValue * fValue; blkCnt--; } *pResult = fSum / (float64_t)(blockSize - 1.); }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Release all memory associated with X.25 routing structures. */
void __exit x25_route_free(void)
/* Release all memory associated with X.25 routing structures. */ void __exit x25_route_free(void)
{ struct x25_route *rt; struct list_head *entry, *tmp; write_lock_bh(&x25_route_list_lock); list_for_each_safe(entry, tmp, &x25_route_list) { rt = list_entry(entry, struct x25_route, node); __x25_remove_route(rt); } write_unlock_bh(&x25_route_list_lock); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Dumps the first declaration of the declaration list to a file. */
void cr_declaration_dump_one(CRDeclaration *a_this, FILE *a_fp, glong a_indent)
/* Dumps the first declaration of the declaration list to a file. */ void cr_declaration_dump_one(CRDeclaration *a_this, FILE *a_fp, glong a_indent)
{ g_return_if_fail (a_this); dump (a_this, a_fp, a_indent); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Get FCM state, get FCM overflow, complete, error flag. */
en_flag_status_t FCM_GetStatus(uint32_t u32Flag)
/* Get FCM state, get FCM overflow, complete, error flag. */ en_flag_status_t FCM_GetStatus(uint32_t u32Flag)
{ DDL_ASSERT(IS_FCM_FLAG(u32Flag)); return ((READ_REG32_BIT(CM_FCM->SR, u32Flag) != 0UL) ? SET : RESET); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* 6.. FMS Terminate Upload Sequence (Confirmed Service Id = 14) 6..1. Request Message Parameters */
static void dissect_ff_msg_fms_terminate_upload_seq_req(tvbuff_t *tvb, gint offset, guint32 length, packet_info *pinfo, proto_tree *tree)
/* 6.. FMS Terminate Upload Sequence (Confirmed Service Id = 14) 6..1. Request Message Parameters */ static void dissect_ff_msg_fms_terminate_upload_seq_req(tvbuff_t *tvb, gint offset, guint32 length, packet_info *pinfo, proto_tree *tree)
{ proto_tree *sub_tree; col_set_str(pinfo->cinfo, COL_INFO, "FMS Terminate Upload Sequence Request"); if (!tree) { return; } sub_tree = proto_tree_add_subtree(tree, tvb, offset, length, ett_ff_fms_terminate_upload_seq_req, NULL, "FMS Terminate Upload Sequence Request"); proto_tree_add_item(sub_tree, hf_ff_fms_terminate_upload_seq_req_idx, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; length -= 4; if (length) { proto_tree_add_item(sub_tree, hf_ff_unknown_data, tvb, offset, length, ENC_NA); } }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Set the type of exception to access the protected IP. */
void MPU_IP_SetExceptionType(uint32_t u32Type)
/* Set the type of exception to access the protected IP. */ void MPU_IP_SetExceptionType(uint32_t u32Type)
{ DDL_ASSERT(IS_MPU_UNLOCK()); DDL_ASSERT(IS_MPU_IP_EXP_TYPE(u32Type)); WRITE_REG32(bCM_MPU->IPPR_b.BUSERRE, (u32Type >> MPU_IPPR_BUSERRE_POS)); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* The function finds chipid from specific list according to ul_id. */
static bool chipid_find(const chipidtype_t *p_cid_types, uint32_t ul_size, uint32_t ul_id, chipidtype_t *p_cid_type)
/* The function finds chipid from specific list according to ul_id. */ static bool chipid_find(const chipidtype_t *p_cid_types, uint32_t ul_size, uint32_t ul_id, chipidtype_t *p_cid_type)
{ uint32_t ul_counter; for (ul_counter = 0; ul_counter < ul_size; ul_counter++) { if (p_cid_types[ul_counter].num == ul_id) { memcpy(p_cid_type, &p_cid_types[ul_counter], sizeof(chipidtype_t)); return true; } } return false; }
remotemcu/remcu-chip-sdks
C++
null
436
/* This function removes the first hbq buffer on an hbq list and returns a pointer to that buffer. If it finds no buffers on the list it returns NULL. */
static struct hbq_dmabuf* lpfc_sli_hbqbuf_get(struct list_head *rb_list)
/* This function removes the first hbq buffer on an hbq list and returns a pointer to that buffer. If it finds no buffers on the list it returns NULL. */ static struct hbq_dmabuf* lpfc_sli_hbqbuf_get(struct list_head *rb_list)
{ struct lpfc_dmabuf *d_buf; list_remove_head(rb_list, d_buf, struct lpfc_dmabuf, list); if (!d_buf) return NULL; return container_of(d_buf, struct hbq_dmabuf, dbuf); }
robutest/uclinux
C++
GPL-2.0
60
/* If the conversion results in an overflow or an underflow condition, then Result is set to INT64_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeUintnToInt64(IN UINTN Operand, OUT INT64 *Result)
/* If the conversion results in an overflow or an underflow condition, then Result is set to INT64_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */ RETURN_STATUS EFIAPI SafeUintnToInt64(IN UINTN Operand, OUT INT64 *Result)
{ if (Result == NULL) { return RETURN_INVALID_PARAMETER; } *Result = (INT64)Operand; return RETURN_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Note: @ops->func and all the functions it calls must be labeled with "notrace", otherwise it will go into a recursive loop. */
int register_ftrace_function(struct ftrace_ops *ops)
/* Note: @ops->func and all the functions it calls must be labeled with "notrace", otherwise it will go into a recursive loop. */ int register_ftrace_function(struct ftrace_ops *ops)
{ int ret; if (unlikely(ftrace_disabled)) return -1; mutex_lock(&ftrace_lock); ret = __register_ftrace_function(ops); ftrace_startup(0); mutex_unlock(&ftrace_lock); return ret; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Enable a DAC channel. Enables the selected DAC channel. */
void dac_chan_enable(struct dac_module *const module_inst, enum dac_channel channel)
/* Enable a DAC channel. Enables the selected DAC channel. */ void dac_chan_enable(struct dac_module *const module_inst, enum dac_channel channel)
{ Assert(module_inst); Assert(module_inst->hw); Dac *const dac_module = module_inst->hw; dac_module->DACCTRL[channel].reg |= DAC_DACCTRL_ENABLE; }
memfault/zero-to-main
C++
null
200
/* USBH_InterruptSendData Sends the data on Interrupt OUT Endpoint. */
USBH_StatusTypeDef USBH_InterruptSendData(USBH_HandleTypeDef *phost, uint8_t *buff, uint8_t length, uint8_t pipe_num)
/* USBH_InterruptSendData Sends the data on Interrupt OUT Endpoint. */ USBH_StatusTypeDef USBH_InterruptSendData(USBH_HandleTypeDef *phost, uint8_t *buff, uint8_t length, uint8_t pipe_num)
{ (void)USBH_LL_SubmitURB(phost, pipe_num, 0U, USBH_EP_INTERRUPT, USBH_PID_DATA, buff, (uint16_t)length, 0U); return USBH_OK; }
ua1arn/hftrx
C++
null
69
/* Find the most appropriate selector matching a given selector name */
static const struct mapping_selector* selector_find(const char *string, size_t slen, int linenum)
/* Find the most appropriate selector matching a given selector name */ static const struct mapping_selector* selector_find(const char *string, size_t slen, int linenum)
{ const struct mapping_selector * found = NULL; int ambig = 0; int i; for(i = 0; selector_list[i].name != NULL; ++i) { if(strncasecmp(selector_list[i].name, string, slen) != 0) continue; if(slen == strlen(selector_list[i].name)) return &selector_list[i]; if(found == NULL) found = &selector_list[i]; else if (selector_list[i].add_fn != found->add_fn) ambig = 1; } if(found == NULL) { fprintf(stderr, "Error: Unknown selector `%.*s' at line %d.\n", (int) slen, string, linenum); return NULL; } if(ambig) { fprintf(stderr, "Selector `%.*s'at line %d is ambiguous.\n", (int) slen, string, linenum); return NULL; } return found; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Returns a multiple of the size of a "struct signalfd_siginfo", or a negative error code. The "count" parameter must be at least the size of a "struct signalfd_siginfo". */
static ssize_t signalfd_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
/* Returns a multiple of the size of a "struct signalfd_siginfo", or a negative error code. The "count" parameter must be at least the size of a "struct signalfd_siginfo". */ static ssize_t signalfd_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
{ struct signalfd_ctx *ctx = file->private_data; struct signalfd_siginfo __user *siginfo; int nonblock = file->f_flags & O_NONBLOCK; ssize_t ret, total = 0; siginfo_t info; count /= sizeof(struct signalfd_siginfo); if (!count) return -EINVAL; siginfo = (struct signalfd_siginfo __user *) buf; do { ret = signalfd_dequeue(ctx, &info, nonblock); if (unlikely(ret <= 0)) break; ret = signalfd_copyinfo(siginfo, &info); if (ret < 0) break; siginfo++; total += ret; nonblock = 1; } while (--count); return total ? total: ret; }
robutest/uclinux
C++
GPL-2.0
60
/* Enable or disable reload and continue counting when overflow/underflow. */
void TMRA_CountReloadCmd(CM_TMRA_TypeDef *TMRAx, en_functional_state_t enNewState)
/* Enable or disable reload and continue counting when overflow/underflow. */ void TMRA_CountReloadCmd(CM_TMRA_TypeDef *TMRAx, en_functional_state_t enNewState)
{ DDL_ASSERT(IS_TMRA_UNIT(TMRAx)); DDL_ASSERT(IS_FUNCTIONAL_STATE(enNewState)); if (enNewState == ENABLE) { CLR_REG8_BIT(TMRAx->BCSTRH, TMRA_BCSTRH_OVSTP); } else { SET_REG8_BIT(TMRAx->BCSTRH, TMRA_BCSTRH_OVSTP); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Put the complete text file into a text page. */
static void text_page_set_text(GtkWidget *page, const char *absolute_path)
/* Put the complete text file into a text page. */ static void text_page_set_text(GtkWidget *page, const char *absolute_path)
{ FILE *text_file; char line[4096+1]; text_file = ws_fopen(absolute_path, "r"); if (text_file != NULL) { while (fgets(line, sizeof line, text_file) != NULL) { text_page_insert(page, line, (int) strlen(line)); } if(ferror(text_file)) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Error reading file \"%s\": %s", absolute_path, g_strerror(errno)); } fclose(text_file); } else { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Could not open file \"%s\": %s", absolute_path, g_strerror(errno)); } }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Fills each sci2cConfig member with its default value. */
void SCI2C_ConfigStructInit(SCI2C_Config_T *sci2cConfig)
/* Fills each sci2cConfig member with its default value. */ void SCI2C_ConfigStructInit(SCI2C_Config_T *sci2cConfig)
{ sci2cConfig->addrMode = SCI2C_ADDR_MODE_7BIT; sci2cConfig->slaveAddr = 0x55; sci2cConfig->clkHighPeriod = 0x3C; sci2cConfig->clkLowPeriod = 0x82; sci2cConfig->mode = SCI2C_MODE_MASTER; sci2cConfig->restart = SCI2C_RESTART_ENABLE; sci2cConfig->rxFifoThreshold = 0; sci2cConfig->txFifoThreshold = 0; sci2cConfig->speed = SCI2C_SPEED_FAST; }
pikasTech/PikaPython
C++
MIT License
1,403
/* This task should be signaled when a receive packet is ready to be read from the interface. */
static void ethernetif_input(void const *argument)
/* This task should be signaled when a receive packet is ready to be read from the interface. */ static void ethernetif_input(void const *argument)
{ struct pbuf *p = NULL; struct netif *netif = (struct netif *) argument; for( ;; ) { if (osSemaphoreWait( RxPktSemaphore, TIME_WAITING_FOR_INPUT)==osOK) { do { p = low_level_input( netif ); if (p != NULL) { if (netif->input( p, netif) != ERR_OK ) { pbuf_free(p); } } }while(p!=NULL); } } }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Gets the interrupt status for a PWM module. */
uint32_t PWMIntStatus(uint32_t ui32Base, bool bMasked)
/* Gets the interrupt status for a PWM module. */ uint32_t PWMIntStatus(uint32_t ui32Base, bool bMasked)
{ ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE)); if(bMasked == true) { return(HWREG(ui32Base + PWM_O_ISC)); } else { return(HWREG(ui32Base + PWM_O_RIS)); } }
feaser/openblt
C++
GNU General Public License v3.0
601
/* This function gets the base address of the second half of the channel control table that holds the alternate control structures for each channel. */
void* uDMAControlAlternateBaseGet(void)
/* This function gets the base address of the second half of the channel control table that holds the alternate control structures for each channel. */ void* uDMAControlAlternateBaseGet(void)
{ return((void *)HWREG(UDMA_ALTBASE)); }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Utility function: convert any string type to UTF8, returns number of bytes in output string or a negative error code */
int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in)
/* Utility function: convert any string type to UTF8, returns number of bytes in output string or a negative error code */ int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in)
{ ASN1_STRING stmp, *str = &stmp; int mbflag, type, ret; if (!in) return -1; type = in->type; if ((type < 0) || (type > 30)) return -1; mbflag = tag2nbyte[type]; if (mbflag == -1) return -1; mbflag |= MBSTRING_FLAG; stmp.data = NULL; stmp.length = 0; stmp.flags = 0; ret = ASN1_mbstring_copy(&str, in->data, in->length, mbflag, B_ASN1_UTF8STRING); if (ret < 0) return ret; *out = stmp.data; return stmp.length; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Limit must be within speedstep_low_freq and speedstep_high_freq, with at least one border included. */
static int speedstep_verify(struct cpufreq_policy *policy)
/* Limit must be within speedstep_low_freq and speedstep_high_freq, with at least one border included. */ static int speedstep_verify(struct cpufreq_policy *policy)
{ return cpufreq_frequency_table_verify(policy, &speedstep_freqs[0]); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Read SPI flash data. Data region doesn't need to be page aligned. */
static bool IRAM read_data(sdk_flashchip_t *flashchip, uint32_t addr, uint8_t *dst, uint32_t size)
/* Read SPI flash data. Data region doesn't need to be page aligned. */ static bool IRAM read_data(sdk_flashchip_t *flashchip, uint32_t addr, uint8_t *dst, uint32_t size)
{ if (size < 1) { return true; } if ((addr + size) > flashchip->chip_size) { return false; } while (size >= SPI_READ_MAX_SIZE) { read_block(flashchip, addr, dst, SPI_READ_MAX_SIZE); dst += SPI_READ_MAX_SIZE; size -= SPI_READ_MAX_SIZE; addr += SPI_READ_MAX_SIZE; } if (size > 0) { read_block(flashchip, addr, dst, size); } return true; }
RavenSystem/esp-homekit-devices
C++
Other
2,577
/* set power down sleep VDDCORE gpio interrupt config */
BL_Err_Type PDS_Set_Vddcore_GPIO_IntCfg(PDS_VDDCORE_GPIO_SRC_Type src, PDS_AON_GPIO_INT_Trigger_Type mode)
/* set power down sleep VDDCORE gpio interrupt config */ BL_Err_Type PDS_Set_Vddcore_GPIO_IntCfg(PDS_VDDCORE_GPIO_SRC_Type src, PDS_AON_GPIO_INT_Trigger_Type mode)
{ uint32_t tmpVal = 0; CHECK_PARAM(IS_PDS_VDDCORE_GPIO_SRC_TYPE(src)); CHECK_PARAM(IS_PDS_AON_GPIO_INT_Trigger_TYPE(mode)); tmpVal = BL_RD_REG(PDS_BASE, PDS_GPIO_INT); tmpVal = BL_SET_REG_BITS_VAL(tmpVal, PDS_GPIO_INT_SELECT, src); tmpVal = BL_SET_REG_BITS_VAL(tmpVal, PDS_GPIO_INT_MODE, mode); BL_WR_REG(PDS_BASE, PDS_GPIO_INT, tmpVal); return SUCCESS; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* The constructor function initializes the Performance Measurement Enable flag */
EFI_STATUS EFIAPI SmmPerformanceLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
/* The constructor function initializes the Performance Measurement Enable flag */ EFI_STATUS EFIAPI SmmPerformanceLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
{ EFI_STATUS Status; mPerformanceMeasurementEnabled = (BOOLEAN)((PcdGet8 (PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0); Status = gSmst->SmmRegisterProtocolNotify ( &gEdkiiSmmExitBootServicesProtocolGuid, SmmPerformanceLibExitBootServicesCallback, &mPerformanceLibExitBootServicesRegistration ); ASSERT_EFI_ERROR (Status); return Status; }
tianocore/edk2
C++
Other
4,240
/* Get the target bus timing to set on the link. This function will try to select highest bus timing supported by card, controller and the driver. */
SD_MMC_BUS_MODE EmmcGetTargetBusTiming(IN SD_MMC_HC_PRIVATE_DATA *Private, IN UINT8 SlotIndex, IN EMMC_EXT_CSD *ExtCsd)
/* Get the target bus timing to set on the link. This function will try to select highest bus timing supported by card, controller and the driver. */ SD_MMC_BUS_MODE EmmcGetTargetBusTiming(IN SD_MMC_HC_PRIVATE_DATA *Private, IN UINT8 SlotIndex, IN EMMC_EXT_CSD *ExtCsd)
{ SD_MMC_BUS_MODE BusTiming; BusTiming = SdMmcMmcHs400; while (BusTiming > SdMmcMmcLegacy) { if (EmmcIsBusTimingSupported (Private, SlotIndex, ExtCsd, BusTiming)) { break; } BusTiming--; } return BusTiming; }
tianocore/edk2
C++
Other
4,240
/* If BufferSize is 0, then no output buffer is produced and 0 is returned. */
UINTN EFIAPI AsciiVSPrint(OUT CHAR8 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR8 *FormatString, IN VA_LIST Marker)
/* If BufferSize is 0, then no output buffer is produced and 0 is returned. */ UINTN EFIAPI AsciiVSPrint(OUT CHAR8 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR8 *FormatString, IN VA_LIST Marker)
{ return BasePrintLibSPrintMarker (StartOfBuffer, BufferSize, 0, FormatString, Marker, NULL); }
tianocore/edk2
C++
Other
4,240
/* Determine whether the platform is operating in Custom Secure Boot mode. */
BOOLEAN InCustomMode(VOID)
/* Determine whether the platform is operating in Custom Secure Boot mode. */ BOOLEAN InCustomMode(VOID)
{ EFI_STATUS Status; VOID *Data; UINTN DataSize; Status = AuthServiceInternalFindVariable (EFI_CUSTOM_MODE_NAME, &gEfiCustomModeEnableGuid, &Data, &DataSize); if (!EFI_ERROR (Status) && (*(UINT8 *)Data == CUSTOM_SECURE_BOOT_MODE)) { return TRUE; } return FALSE; }
tianocore/edk2
C++
Other
4,240
/* If this is called while a probe() or remove() is in progress it will return -EAGAIN and not perform the reset. */
int umc_controller_reset(struct umc_dev *umc)
/* If this is called while a probe() or remove() is in progress it will return -EAGAIN and not perform the reset. */ int umc_controller_reset(struct umc_dev *umc)
{ struct device *parent = umc->dev.parent; int ret = 0; if(down_trylock(&parent->sem)) return -EAGAIN; ret = device_for_each_child(parent, parent, umc_bus_pre_reset_helper); if (ret >= 0) ret = device_for_each_child(parent, parent, umc_bus_post_reset_helper); up(&parent->sem); return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* USB Device Connect Function Called by the User to Connect/Disconnect USB Device Parameters: con: Connect/Disconnect Return Value: None */
void USBD_Connect(BOOL con)
/* USB Device Connect Function Called by the User to Connect/Disconnect USB Device Parameters: con: Connect/Disconnect Return Value: None */ void USBD_Connect(BOOL con)
{ if (con) { LPC_USBx->USBCMD_D |= 1; } else { LPC_USBx->USBCMD_D &= ~1; } }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* If the end of the buffer has been reached, return -EAGAIN, if not, return the offset within the buffer of the next entry to be read. */
static int find_dirent_index(nfs_readdir_descriptor_t *desc)
/* If the end of the buffer has been reached, return -EAGAIN, if not, return the offset within the buffer of the next entry to be read. */ static int find_dirent_index(nfs_readdir_descriptor_t *desc)
{ struct nfs_entry *entry = desc->entry; int loop_count = 0, status; for(;;) { status = dir_decode(desc); if (status) break; dfprintk(DIRCACHE, "NFS: found cookie %Lu at index %Ld\n", (unsigned long long)entry->cookie, desc->current_index); if (desc->file->f_pos == desc->current_index) { *desc->dir_cookie = entry->cookie; break; } desc->current_index++; if (loop_count++ > 200) { loop_count = 0; schedule(); } } return status; }
robutest/uclinux
C++
GPL-2.0
60
/* Writers of suspendable-input applications must note that skip_input_data is not granted the right to give a suspension return. If the skip extends beyond the data currently in the buffer, the buffer can be marked empty so that the next read will cause a fill_input_buffer call that can suspend. Arranging for additional bytes to be discarded before reloading the input buffer is the application writer's problem. */
skip_input_data(j_decompress_ptr cinfo, long num_bytes)
/* Writers of suspendable-input applications must note that skip_input_data is not granted the right to give a suspension return. If the skip extends beyond the data currently in the buffer, the buffer can be marked empty so that the next read will cause a fill_input_buffer call that can suspend. Arranging for additional bytes to be discarded before reloading the input buffer is the application writer's problem. */ skip_input_data(j_decompress_ptr cinfo, long num_bytes)
{ struct jpeg_source_mgr * src = cinfo->src; size_t nbytes; if (num_bytes > 0) { nbytes = (size_t) num_bytes; while (nbytes > src->bytes_in_buffer) { nbytes -= src->bytes_in_buffer; (void) (*src->fill_input_buffer) (cinfo); } src->next_input_byte += nbytes; src->bytes_in_buffer -= nbytes; } }
xboot/xboot
C++
MIT License
779
/* RETURN VALUES: 0 - success -EIO - i/o error */
int dbUnmount(struct inode *ipbmap, int mounterror)
/* RETURN VALUES: 0 - success -EIO - i/o error */ int dbUnmount(struct inode *ipbmap, int mounterror)
{ struct bmap *bmp = JFS_SBI(ipbmap->i_sb)->bmap; if (!(mounterror || isReadOnly(ipbmap))) dbSync(ipbmap); truncate_inode_pages(ipbmap->i_mapping, 0); kfree(bmp); return (0); }
robutest/uclinux
C++
GPL-2.0
60
/* Convert provided flags to status code, and clear any errors if present. */
static status_t LPI2C_SlaveCheckAndClearError(LPI2C_Type *base, uint32_t flags)
/* Convert provided flags to status code, and clear any errors if present. */ static status_t LPI2C_SlaveCheckAndClearError(LPI2C_Type *base, uint32_t flags)
{ status_t result = kStatus_Success; flags &= (uint32_t)kSlaveErrorFlags; if (0U != flags) { if (0U != (flags & (uint32_t)kLPI2C_SlaveBitErrFlag)) { result = kStatus_LPI2C_BitError; } else if (0U != (flags & (uint32_t)kLPI2C_SlaveFifoErrFlag)) { result = kStatus_LPI2C_FifoError; } else { ; } LPI2C_SlaveClearStatusFlags(base, flags); } else { ; } return result; }
eclipse-threadx/getting-started
C++
Other
310
/* Alternate Data TLB Fault @ Alternate Data TLB vector Refer to SDM Vol2 Table 5-6 & 8-1 */
void alt_dtlb(struct kvm_vcpu *vcpu, u64 vadr)
/* Alternate Data TLB Fault @ Alternate Data TLB vector Refer to SDM Vol2 Table 5-6 & 8-1 */ void alt_dtlb(struct kvm_vcpu *vcpu, u64 vadr)
{ set_ifa_itir_iha(vcpu, vadr, 1, 1, 0); inject_guest_interruption(vcpu, IA64_ALT_DATA_TLB_VECTOR); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This is like of_node_to_nid_single() for memory represented in the ibm,dynamic-reconfiguration-memory node. */
static int of_drconf_to_nid_single(struct of_drconf_cell *drmem, struct assoc_arrays *aa)
/* This is like of_node_to_nid_single() for memory represented in the ibm,dynamic-reconfiguration-memory node. */ static int of_drconf_to_nid_single(struct of_drconf_cell *drmem, struct assoc_arrays *aa)
{ int default_nid = 0; int nid = default_nid; int index; if (min_common_depth > 0 && min_common_depth <= aa->array_sz && !(drmem->flags & DRCONF_MEM_AI_INVALID) && drmem->aa_index < aa->n_arrays) { index = drmem->aa_index * aa->array_sz + min_common_depth - 1; nid = aa->arrays[index]; if (nid == 0xffff || nid >= MAX_NUMNODES) nid = default_nid; } return nid; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Returns: The wanted page on success, else a NULL pointer. */
struct page* vxfs_get_page(struct address_space *mapping, u_long n)
/* Returns: The wanted page on success, else a NULL pointer. */ struct page* vxfs_get_page(struct address_space *mapping, u_long n)
{ struct page * pp; pp = read_mapping_page(mapping, n, NULL); if (!IS_ERR(pp)) { kmap(pp); if (PageError(pp)) goto fail; } return (pp); fail: vxfs_put_page(pp); return ERR_PTR(-EIO); }
robutest/uclinux
C++
GPL-2.0
60
/* Returns seconds, approximately. We don't need nanosecond resolution, and we don't need to waste time with a big divide when 2^30ns == 1.074s. */
static unsigned long get_timestamp(int this_cpu)
/* Returns seconds, approximately. We don't need nanosecond resolution, and we don't need to waste time with a big divide when 2^30ns == 1.074s. */ static unsigned long get_timestamp(int this_cpu)
{ return cpu_clock(this_cpu) >> 30LL; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* initialize TIMER channel input parameter struct with a default value */
void timer_channel_input_struct_para_init(timer_ic_parameter_struct *icpara)
/* initialize TIMER channel input parameter struct with a default value */ void timer_channel_input_struct_para_init(timer_ic_parameter_struct *icpara)
{ icpara->icpolarity = TIMER_IC_POLARITY_RISING; icpara->icselection = TIMER_IC_SELECTION_DIRECTTI; icpara->icprescaler = TIMER_IC_PSC_DIV1; icpara->icfilter = 0U; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Walk one dissector table's hash table calling a user supplied function on each entry. */
void dissector_table_foreach(const char *table_name, DATFunc func, gpointer user_data)
/* Walk one dissector table's hash table calling a user supplied function on each entry. */ void dissector_table_foreach(const char *table_name, DATFunc func, gpointer user_data)
{ dissector_foreach_info_t info; dissector_table_t sub_dissectors = find_dissector_table(table_name); info.table_name = table_name; info.selector_type = sub_dissectors->type; info.caller_func = func; info.caller_data = user_data; g_hash_table_foreach(sub_dissectors->hash_table, dissector_table_foreach_func, &info); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Returns: a newly allocated string containing the name of the character set. This string must be freed with g_free(). */
gchar* g_get_codeset(void)
/* Returns: a newly allocated string containing the name of the character set. This string must be freed with g_free(). */ gchar* g_get_codeset(void)
{ const gchar *charset; g_get_charset (&charset); return g_strdup (charset); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This file is part of the Simba project. Ignore one line. */
static char* ignore_line(char *buf_p)
/* This file is part of the Simba project. Ignore one line. */ static char* ignore_line(char *buf_p)
{ while (*buf_p != '\n') { if (*buf_p == '\0') { return (NULL); } buf_p++; } return (buf_p); }
eerimoq/simba
C++
Other
337
/* Rebuild the preset table. This is like a hash table in that it allows quick access to the zone information. For each preset there are zone structures linked by next_instr and by next_zone. Former is the whole link for this preset, and latter is the link for zone (i.e. instrument/ bank/key combination). */
static void rebuild_presets(struct snd_sf_list *sflist)
/* Rebuild the preset table. This is like a hash table in that it allows quick access to the zone information. For each preset there are zone structures linked by next_instr and by next_zone. Former is the whole link for this preset, and latter is the link for zone (i.e. instrument/ bank/key combination). */ static void rebuild_presets(struct snd_sf_list *sflist)
{ struct snd_soundfont *sf; struct snd_sf_zone *cur; memset(sflist->presets, 0, sizeof(sflist->presets)); for (sf = sflist->fonts; sf; sf = sf->next) { for (cur = sf->zones; cur; cur = cur->next) { if (! cur->mapped && cur->sample == NULL) { cur->sample = set_sample(sf, &cur->v); if (cur->sample == NULL) continue; } add_preset(sflist, cur); } } }
robutest/uclinux
C++
GPL-2.0
60
/* This file is part of the Simba project. */
int mock_write_eeprom_soft_module_init(int res)
/* This file is part of the Simba project. */ int mock_write_eeprom_soft_module_init(int res)
{ harness_mock_write("eeprom_soft_module_init()", NULL, 0); harness_mock_write("eeprom_soft_module_init(): return (res)", &res, sizeof(res)); return (0); }
eerimoq/simba
C++
Other
337
/* Populates the .heading fields in the sensors_vec_t struct with the right angular data (0-359°) Heading increases when measuring clockwise */
void magGetOrientation(sensors_axis_t axis, sensors_event_t *event, sensors_vec_t *orientation)
/* Populates the .heading fields in the sensors_vec_t struct with the right angular data (0-359°) Heading increases when measuring clockwise */ void magGetOrientation(sensors_axis_t axis, sensors_event_t *event, sensors_vec_t *orientation)
{ float const PI = 3.14159265F; switch (axis) { case SENSOR_AXIS_X: orientation->heading = (float)atan2(event->magnetic.z, event->magnetic.y) * 180 / PI; break; case SENSOR_AXIS_Y: orientation->heading = (float)atan2(event->magnetic.x, event->magnetic.z) * 180 / PI; break; case SENSOR_AXIS_Z: default: orientation->heading = (float)atan2(event->magnetic.y, event->magnetic.x) * 180 / PI; break; } if (orientation->heading < 0) { orientation->heading = 360 + orientation->heading; } }
microbuilder/LPC11U_LPC13U_CodeBase
C++
Other
54
/* Find a connected NET/ROM socket given their circuit IDs. */
static struct sock* nr_find_peer(unsigned char index, unsigned char id, ax25_address *dest)
/* Find a connected NET/ROM socket given their circuit IDs. */ static struct sock* nr_find_peer(unsigned char index, unsigned char id, ax25_address *dest)
{ struct sock *s; struct hlist_node *node; spin_lock_bh(&nr_list_lock); sk_for_each(s, node, &nr_list) { struct nr_sock *nr = nr_sk(s); if (nr->your_index == index && nr->your_id == id && !ax25cmp(&nr->dest_addr, dest)) { bh_lock_sock(s); goto found; } } s = NULL; found: spin_unlock_bh(&nr_list_lock); return s; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* The STATUS_REG register is read by the primary interface.. */
int32_t lps22hh_status_reg_get(stmdev_ctx_t *ctx, lps22hh_status_t *val)
/* The STATUS_REG register is read by the primary interface.. */ int32_t lps22hh_status_reg_get(stmdev_ctx_t *ctx, lps22hh_status_t *val)
{ int32_t ret; ret = lps22hh_read_reg(ctx, LPS22HH_STATUS, (uint8_t *) val, 1); return ret; }
eclipse-threadx/getting-started
C++
Other
310
/* Immediately put all linked substreams into SETUP state. */
static int snd_pcm_drop(struct snd_pcm_substream *substream)
/* Immediately put all linked substreams into SETUP state. */ static int snd_pcm_drop(struct snd_pcm_substream *substream)
{ struct snd_pcm_runtime *runtime; struct snd_card *card; int result = 0; if (PCM_RUNTIME_CHECK(substream)) return -ENXIO; runtime = substream->runtime; card = substream->pcm->card; if (runtime->status->state == SNDRV_PCM_STATE_OPEN || runtime->status->state == SNDRV_PCM_STATE_DISCONNECTED || runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) return -EBADFD; snd_pcm_stream_lock_irq(substream); if (runtime->status->state == SNDRV_PCM_STATE_PAUSED) snd_pcm_pause(substream, 0); snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); snd_pcm_stream_unlock_irq(substream); return result; }
robutest/uclinux
C++
GPL-2.0
60
/* If the conversion results in an overflow or an underflow condition, then Result is set to INT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeUint32ToInt8(IN UINT32 Operand, OUT INT8 *Result)
/* If the conversion results in an overflow or an underflow condition, then Result is set to INT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */ RETURN_STATUS EFIAPI SafeUint32ToInt8(IN UINT32 Operand, OUT INT8 *Result)
{ RETURN_STATUS Status; if (Result == NULL) { return RETURN_INVALID_PARAMETER; } if (Operand <= MAX_INT8) { *Result = (INT8)Operand; Status = RETURN_SUCCESS; } else { *Result = INT8_ERROR; Status = RETURN_BUFFER_TOO_SMALL; } return Status; }
tianocore/edk2
C++
Other
4,240
/* This file is part of the uIP TCP/IP stack */
unsigned char uiplib_ipaddrconv(char *addrstr, unsigned char *ipaddr)
/* This file is part of the uIP TCP/IP stack */ unsigned char uiplib_ipaddrconv(char *addrstr, unsigned char *ipaddr)
{ unsigned char tmp; char c; unsigned char i, j; tmp = 0; for(i = 0; i < 4; ++i) { j = 0; do { c = *addrstr; ++j; if(j > 4) { return 0; } if(c == '.' || c == 0) { *ipaddr = tmp; ++ipaddr; tmp = 0; } else if(c >= '0' && c <= '9') { tmp = (tmp * 10) + (c - '0'); } else { return 0; } ++addrstr; } while(c != '.' && c != 0); } return 1; }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Converts a 2 digit decimal to BCD format. */
static uint8_t RTC_ByteToBcd2(uint8_t Value)
/* Converts a 2 digit decimal to BCD format. */ static uint8_t RTC_ByteToBcd2(uint8_t Value)
{ uint8_t bcdhigh = 0; while (Value >= 10) { bcdhigh++; Value -= 10; } return ((uint8_t)(bcdhigh << 4) | Value); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This buffer is required to safely transfer AP from real address mode to protected mode or long mode, due to the fact that the buffer returned by */
UINTN AllocateCodeBuffer(IN UINTN BufferSize)
/* This buffer is required to safely transfer AP from real address mode to protected mode or long mode, due to the fact that the buffer returned by */ UINTN AllocateCodeBuffer(IN UINTN BufferSize)
{ EFI_STATUS Status; EFI_PHYSICAL_ADDRESS StartAddress; StartAddress = BASE_4GB - 1; Status = gBS->AllocatePages ( AllocateMaxAddress, EfiBootServicesCode, EFI_SIZE_TO_PAGES (BufferSize), &StartAddress ); if (EFI_ERROR (Status)) { StartAddress = 0; } return (UINTN)StartAddress; }
tianocore/edk2
C++
Other
4,240
/* sai get tx enabled interrupt status. Set the master clock divider. */
static bool SAI_TxGetEnabledInterruptStatus(I2S_Type *base, uint32_t enableFlag, uint32_t statusFlag)
/* sai get tx enabled interrupt status. Set the master clock divider. */ static bool SAI_TxGetEnabledInterruptStatus(I2S_Type *base, uint32_t enableFlag, uint32_t statusFlag)
{ uint32_t tcsr = base->TCSR; return IS_SAI_FLAG_SET(tcsr, enableFlag) && IS_SAI_FLAG_SET(tcsr, statusFlag); }
eclipse-threadx/getting-started
C++
Other
310
/* The caller of this routine ensures that the specified adapter has been shut down and that this operation has been completed. Thus, there are no pending erp_actions which would need to be handled here. */
void zfcp_erp_thread_kill(struct zfcp_adapter *adapter)
/* The caller of this routine ensures that the specified adapter has been shut down and that this operation has been completed. Thus, there are no pending erp_actions which would need to be handled here. */ void zfcp_erp_thread_kill(struct zfcp_adapter *adapter)
{ kthread_stop(adapter->erp_thread); adapter->erp_thread = NULL; WARN_ON(!list_empty(&adapter->erp_ready_head)); WARN_ON(!list_empty(&adapter->erp_running_head)); }
robutest/uclinux
C++
GPL-2.0
60
/* "Ethernet@Wirespeed" needs to be enabled to achieve link in certain circumstances. eg a gigabit TSEC connected to a gigabit switch with a 4-wire ethernet cable. Both ends advertise gigabit, but can't link. "Ethernet@Wirespeed" reduces advertised speed until link can be achieved. */
static uint mii_BCM54xx_wirespeed(uint mii_reg, struct tsec_private *priv)
/* "Ethernet@Wirespeed" needs to be enabled to achieve link in certain circumstances. eg a gigabit TSEC connected to a gigabit switch with a 4-wire ethernet cable. Both ends advertise gigabit, but can't link. "Ethernet@Wirespeed" reduces advertised speed until link can be achieved. */ static uint mii_BCM54xx_wirespeed(uint mii_reg, struct tsec_private *priv)
{ return (read_phy_reg(priv, mii_reg) & 0x8FFF) | 0x8010; }
EmcraftSystems/u-boot
C++
Other
181
/* Select given device on the SPI bus. Set device specific setting and calls board chip select. */
void spi_select_device(volatile void *spi, struct spi_device *device)
/* Select given device on the SPI bus. Set device specific setting and calls board chip select. */ void spi_select_device(volatile void *spi, struct spi_device *device)
{ ioport_set_pin_low(device->id); }
memfault/zero-to-main
C++
null
200
/* RETURN: MV_BAD_PARAM if parameters to function invalid, MV_OK otherwise. */
void mv_xor_hal_init(u32 xor_chan_num)
/* RETURN: MV_BAD_PARAM if parameters to function invalid, MV_OK otherwise. */ void mv_xor_hal_init(u32 xor_chan_num)
{ u32 i; for (i = 0; i < xor_chan_num; i++) { mv_xor_command_set(i, MV_STOP); mv_xor_ctrl_set(i, (1 << XEXCR_REG_ACC_PROTECT_OFFS) | (4 << XEXCR_DST_BURST_LIMIT_OFFS) | (4 << XEXCR_SRC_BURST_LIMIT_OFFS)); } }
4ms/stm32mp1-baremetal
C++
Other
137
/* Change Logs: Date Author Notes iysheng first version idk500 suit for Vango V85xx ZhuXW add delay function System Clock Configuration */
void SystemClock_Config(void)
/* Change Logs: Date Author Notes iysheng first version idk500 suit for Vango V85xx ZhuXW add delay function System Clock Configuration */ void SystemClock_Config(void)
{ NVIC_SetPriority(SysTick_IRQn, 0); CLK_InitTypeDef CLK_Struct; CLK_Struct.ClockType = CLK_TYPE_AHBSRC \ |CLK_TYPE_PLLL \ |CLK_TYPE_HCLK \ |CLK_TYPE_PCLK; CLK_Struct.AHBSource = CLK_AHBSEL_LSPLL; CLK_Struct.PLLL.Frequency = CLK_PLLL_26_2144MHz; CLK_Struct.PLLL.Source = CLK_PLLLSRC_XTALL; CLK_Struct.PLLL.State = CLK_PLLL_ON; CLK_Struct.HCLK.Divider = 1; CLK_Struct.PCLK.Divider = 2; CLK_ClockConfig(&CLK_Struct); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Set Timer 1 Input to XOR of Three Channels. The first timer capture input is formed from the XOR of the first three timer input channels 1, 2, 3. */
void timer_set_ti1_ch123_xor(uint32_t timer_peripheral)
/* Set Timer 1 Input to XOR of Three Channels. The first timer capture input is formed from the XOR of the first three timer input channels 1, 2, 3. */ void timer_set_ti1_ch123_xor(uint32_t timer_peripheral)
{ TIM_CR2(timer_peripheral) |= TIM_CR2_TI1S; }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* Enables or disables the transmitter of an USART peripheral. */
void USART_SetTransmitterEnabled(AT91S_USART *usart, unsigned char enabled)
/* Enables or disables the transmitter of an USART peripheral. */ void USART_SetTransmitterEnabled(AT91S_USART *usart, unsigned char enabled)
{ if (enabled) { usart->US_CR = AT91C_US_TXEN; } else { usart->US_CR = AT91C_US_TXDIS; } }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* This service is a wrapper for the PEI Service RegisterForShadow(), except the pointer to the PEI Services Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface Specification for details. */
EFI_STATUS EFIAPI PeiServicesRegisterForShadow(IN EFI_PEI_FILE_HANDLE FileHandle)
/* This service is a wrapper for the PEI Service RegisterForShadow(), except the pointer to the PEI Services Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface Specification for details. */ EFI_STATUS EFIAPI PeiServicesRegisterForShadow(IN EFI_PEI_FILE_HANDLE FileHandle)
{ ASSERT (FALSE); return EFI_OUT_OF_RESOURCES; }
tianocore/edk2
C++
Other
4,240
/* vx_read_one_cbit - read one bit from UER config @index: the bit index returns 0 or 1. */
static int vx_read_one_cbit(struct vx_core *chip, int index)
/* vx_read_one_cbit - read one bit from UER config @index: the bit index returns 0 or 1. */ static int vx_read_one_cbit(struct vx_core *chip, int index)
{ unsigned long flags; int val; spin_lock_irqsave(&chip->lock, flags); if (chip->type >= VX_TYPE_VXPOCKET) { vx_outb(chip, CSUER, 1); vx_outb(chip, RUER, index & XX_UER_CBITS_OFFSET_MASK); val = (vx_inb(chip, RUER) >> 7) & 0x01; } else { vx_outl(chip, CSUER, 1); vx_outl(chip, RUER, index & XX_UER_CBITS_OFFSET_MASK); val = (vx_inl(chip, RUER) >> 7) & 0x01; } spin_unlock_irqrestore(&chip->lock, flags); return val; }
robutest/uclinux
C++
GPL-2.0
60
/* The input SdtHeader information is copied to the tree RootNode. The table Length field is automatically updated. The checksum field is only updated when serializing the tree. */
EFI_STATUS EFIAPI AmlUpdateRootNode(IN AML_ROOT_NODE *RootNode, IN CONST EFI_ACPI_DESCRIPTION_HEADER *SdtHeader)
/* The input SdtHeader information is copied to the tree RootNode. The table Length field is automatically updated. The checksum field is only updated when serializing the tree. */ EFI_STATUS EFIAPI AmlUpdateRootNode(IN AML_ROOT_NODE *RootNode, IN CONST EFI_ACPI_DESCRIPTION_HEADER *SdtHeader)
{ EFI_STATUS Status; UINT32 Length; if (!IS_AML_ROOT_NODE (RootNode) || (SdtHeader == NULL) || ((SdtHeader->Signature != EFI_ACPI_6_3_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE) && (SdtHeader->Signature != EFI_ACPI_6_3_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE))) { ASSERT (0); return EFI_INVALID_PARAMETER; } CopyMem ( RootNode->SdtHeader, SdtHeader, sizeof (EFI_ACPI_DESCRIPTION_HEADER) ); Status = AmlComputeSize ((AML_NODE_HEADER *)RootNode, &Length); if (EFI_ERROR (Status)) { ASSERT (0); return Status; } RootNode->SdtHeader->Length = Length + (UINT32)sizeof (EFI_ACPI_DESCRIPTION_HEADER); return Status; }
tianocore/edk2
C++
Other
4,240
/* Normally, the VFS handles the d_move() for the file system, after the ->rename() callback. OCFS2 wants to handle this internally, so the new lock can be created atomically with respect to the cluster. */
void ocfs2_dentry_move(struct dentry *dentry, struct dentry *target, struct inode *old_dir, struct inode *new_dir)
/* Normally, the VFS handles the d_move() for the file system, after the ->rename() callback. OCFS2 wants to handle this internally, so the new lock can be created atomically with respect to the cluster. */ void ocfs2_dentry_move(struct dentry *dentry, struct dentry *target, struct inode *old_dir, struct inode *new_dir)
{ int ret; struct ocfs2_super *osb = OCFS2_SB(old_dir->i_sb); struct inode *inode = dentry->d_inode; if (old_dir == new_dir) goto out_move; ocfs2_dentry_lock_put(osb, dentry->d_fsdata); dentry->d_fsdata = NULL; ret = ocfs2_dentry_attach_lock(dentry, inode, OCFS2_I(new_dir)->ip_blkno); if (ret) mlog_errno(ret); out_move: d_move(dentry, target); }
robutest/uclinux
C++
GPL-2.0
60
/* Reads an unsigned 8 bit value over I2C. */
err_t lsm303magRead8(uint8_t addr, uint8_t reg, uint8_t *value)
/* Reads an unsigned 8 bit value over I2C. */ err_t lsm303magRead8(uint8_t addr, uint8_t reg, uint8_t *value)
{ I2CWriteLength = 2; I2CReadLength = 0; I2CMasterBuffer[0] = addr; I2CMasterBuffer[1] = reg; i2cEngine(); I2CWriteLength = 0; I2CReadLength = 1; I2CMasterBuffer[0] = addr | 0x01; ASSERT_I2C_STATUS(i2cEngine()); *value = I2CSlaveBuffer[0]; return ERROR_NONE; }
microbuilder/LPC11U_LPC13U_CodeBase
C++
Other
54
/* Read a single color from the graphical memory. Use this function to read a color from the graphical memory of the controller. Limits have to be set prior to calling this function, e.g.: */
hx8347a_color_t hx8347a_read_gram(void)
/* Read a single color from the graphical memory. Use this function to read a color from the graphical memory of the controller. Limits have to be set prior to calling this function, e.g.: */ hx8347a_color_t hx8347a_read_gram(void)
{ uint8_t red; uint8_t green; uint8_t blue; hx8347a_select_register(HX8347A_SRAMWRITE); hx8347a_select_chip(); hx8347a_send_byte(HX8347A_START_READREG); red = hx8347a_read_byte(); red = hx8347a_read_byte(); green = hx8347a_read_byte(); blue = hx8347a_read_byte(); hx8347a_deselect_chip(); return HX8347A_COLOR(red, green, blue); }
remotemcu/remcu-chip-sdks
C++
null
436
/* Dissects Attribute ID field. This could be done with the */
static void dissect_zcl_attr_id(tvbuff_t *tvb, proto_tree *tree, guint *offset, guint16 cluster_id)
/* Dissects Attribute ID field. This could be done with the */ static void dissect_zcl_attr_id(tvbuff_t *tvb, proto_tree *tree, guint *offset, guint16 cluster_id)
{ zbee_zcl_cluster_desc *desc; int hf_attr_id = hf_zbee_zcl_attr_id; desc = zbee_zcl_get_cluster_desc(cluster_id); if (desc && (desc->hf_attr_id >= 0)) hf_attr_id = desc->hf_attr_id; proto_tree_add_item(tree, hf_attr_id, tvb, *offset, 2, ENC_LITTLE_ENDIAN); *offset += 2; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* The index of Processor specified by mPackageFirstThreadIndex will do the package-scope register programming. */
BOOLEAN IsPackageFirstThread(IN UINTN CpuIndex)
/* The index of Processor specified by mPackageFirstThreadIndex will do the package-scope register programming. */ BOOLEAN IsPackageFirstThread(IN UINTN CpuIndex)
{ UINT32 PackageIndex; PackageIndex = gSmmCpuPrivate->ProcessorInfo[CpuIndex].Location.Package; ASSERT (mPackageFirstThreadIndex != NULL); if (mPackageFirstThreadIndex[PackageIndex] == (UINT32)-1) { mPackageFirstThreadIndex[PackageIndex] = (UINT32)CpuIndex; } return (BOOLEAN)(mPackageFirstThreadIndex[PackageIndex] == CpuIndex); }
tianocore/edk2
C++
Other
4,240
/* param tcd A pointer to the TCD structure. param srcModulo A source modulo value. param destModulo A destination modulo value. */
void EDMA_TcdSetModulo(edma_tcd_t *tcd, edma_modulo_t srcModulo, edma_modulo_t destModulo)
/* param tcd A pointer to the TCD structure. param srcModulo A source modulo value. param destModulo A destination modulo value. */ void EDMA_TcdSetModulo(edma_tcd_t *tcd, edma_modulo_t srcModulo, edma_modulo_t destModulo)
{ assert(tcd != NULL); assert(((uint32_t)tcd & 0x1FU) == 0U); uint16_t tmpreg; tmpreg = tcd->ATTR & (~(uint16_t)(DMA_ATTR_SMOD_MASK | DMA_ATTR_DMOD_MASK)); tcd->ATTR = tmpreg | DMA_ATTR_DMOD(destModulo) | DMA_ATTR_SMOD(srcModulo); }
eclipse-threadx/getting-started
C++
Other
310
/* IDL typedef struct { IDL long flags; IDL long pdc_connection_status; IDL } NETLOGON_INFO_1; */
static int netlogon_dissect_NETLOGON_INFO_1(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep)
/* IDL typedef struct { IDL long flags; IDL long pdc_connection_status; IDL } NETLOGON_INFO_1; */ static int netlogon_dissect_NETLOGON_INFO_1(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep)
{ offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, di, drep, hf_netlogon_flags, NULL); offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, di, drep, hf_netlogon_pdc_connection_status, NULL); return offset; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* SC_Itf_XferBlock function from the host. This is user implementable. */
uint8_t SC_Itf_XferBlock(uint8_t *ptrBlock, uint32_t blockLen, uint16_t expectedLen, USBD_CCID_BulkIn_DataTypeDef *CCID_BulkIn_Data)
/* SC_Itf_XferBlock function from the host. This is user implementable. */ uint8_t SC_Itf_XferBlock(uint8_t *ptrBlock, uint32_t blockLen, uint16_t expectedLen, USBD_CCID_BulkIn_DataTypeDef *CCID_BulkIn_Data)
{ uint8_t ErrorCode = SLOT_NO_ERROR; UNUSED(CCID_BulkIn_Data); UNUSED(expectedLen); UNUSED(blockLen); UNUSED(ptrBlock); if (ProtocolNUM_OUT == 0x00U) { } if (ProtocolNUM_OUT == 0x01U) { } if (ErrorCode != SLOT_NO_ERROR) { return ErrorCode; } return ErrorCode; }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* This function must not be called if the LIDD interface is currently configured to expect DMA transactions. If DMA was previously used to write to the panel, */
uint16_t LCDIDDDataRead(uint32_t ui32Base, uint32_t ui32CS)
/* This function must not be called if the LIDD interface is currently configured to expect DMA transactions. If DMA was previously used to write to the panel, */ uint16_t LCDIDDDataRead(uint32_t ui32Base, uint32_t ui32CS)
{ uint32_t ui32Reg; ASSERT(ui32Base == LCD0_BASE); ASSERT((ui32CS == 0) || (ui32CS == 1)); ui32Reg = ui32CS ? LCD_O_LIDDCS1DATA : LCD_O_LIDDCS0DATA; return ((uint16_t)HWREG(ui32Base + ui32Reg)); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* @rc: UWB Radio Controller @_addr: Pointer to address to write . @type: Type of address to set (UWB_ADDR_DEV or UWB_ADDR_MAC). */
static int uwb_rc_addr_set(struct uwb_rc *rc, const void *_addr, enum uwb_addr_type type)
/* @rc: UWB Radio Controller @_addr: Pointer to address to write . @type: Type of address to set (UWB_ADDR_DEV or UWB_ADDR_MAC). */ static int uwb_rc_addr_set(struct uwb_rc *rc, const void *_addr, enum uwb_addr_type type)
{ int result; u8 bmOperationType = 0x1; const struct uwb_dev_addr *dev_addr = _addr; const struct uwb_mac_addr *mac_addr = _addr; struct uwb_rc_evt_dev_addr_mgmt reply; const u8 *baAddr; result = -EINVAL; switch (type) { case UWB_ADDR_DEV: baAddr = dev_addr->data; break; case UWB_ADDR_MAC: baAddr = mac_addr->data; bmOperationType |= 0x2; break; default: return result; } return uwb_rc_dev_addr_mgmt(rc, bmOperationType, baAddr, &reply); }
robutest/uclinux
C++
GPL-2.0
60
/* Parameters: channel UART channel to send to ch character to send */
void uart_putchar(UART_MemMapPtr channel, char ch)
/* Parameters: channel UART channel to send to ch character to send */ void uart_putchar(UART_MemMapPtr channel, char ch)
{ while(!(UART_S1_REG(channel) & UART_S1_TDRE_MASK)); UART_D_REG(channel) = (uint8)ch; }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* @client: the i2c client @dim: either LP3944_DIM0 or LP3944_DIM1 @duty_cycle: percentage of a period during which a led is ON */
static int lp3944_dim_set_dutycycle(struct i2c_client *client, u8 dim, u8 duty_cycle)
/* @client: the i2c client @dim: either LP3944_DIM0 or LP3944_DIM1 @duty_cycle: percentage of a period during which a led is ON */ static int lp3944_dim_set_dutycycle(struct i2c_client *client, u8 dim, u8 duty_cycle)
{ u8 pwm_reg; u8 pwm_value; int err; if (dim == LP3944_DIM0) pwm_reg = LP3944_REG_PWM0; else if (dim == LP3944_DIM1) pwm_reg = LP3944_REG_PWM1; else return -EINVAL; if (duty_cycle > LP3944_DUTY_CYCLE_MAX) return -EINVAL; pwm_value = (duty_cycle * 255) / LP3944_DUTY_CYCLE_MAX; err = lp3944_reg_write(client, pwm_reg, pwm_value); return err; }
robutest/uclinux
C++
GPL-2.0
60
/* LOCKING: the frame_rcvd_lock needs to be held since this parses the frame buffer. */
static void pm8001_get_attached_sas_addr(struct pm8001_phy *phy, u8 *sas_addr)
/* LOCKING: the frame_rcvd_lock needs to be held since this parses the frame buffer. */ static void pm8001_get_attached_sas_addr(struct pm8001_phy *phy, u8 *sas_addr)
{ if (phy->sas_phy.frame_rcvd[0] == 0x34 && phy->sas_phy.oob_mode == SATA_OOB_MODE) { struct pm8001_hba_info *pm8001_ha = phy->sas_phy.ha->lldd_ha; u64 addr = be64_to_cpu(*(__be64 *)pm8001_ha->sas_addr); addr += phy->sas_phy.id; *(__be64 *)sas_addr = cpu_to_be64(addr); } else { struct sas_identify_frame *idframe = (void *) phy->sas_phy.frame_rcvd; memcpy(sas_addr, idframe->sas_addr, SAS_ADDR_SIZE); } }
robutest/uclinux
C++
GPL-2.0
60
/* Handle incoming reply to any other type of command */
static int iscsi_tcp_data_recv_done(struct iscsi_tcp_conn *tcp_conn, struct iscsi_segment *segment)
/* Handle incoming reply to any other type of command */ static int iscsi_tcp_data_recv_done(struct iscsi_tcp_conn *tcp_conn, struct iscsi_segment *segment)
{ struct iscsi_conn *conn = tcp_conn->iscsi_conn; int rc = 0; if (!iscsi_tcp_dgst_verify(tcp_conn, segment)) return ISCSI_ERR_DATA_DGST; rc = iscsi_complete_pdu(conn, tcp_conn->in.hdr, conn->data, tcp_conn->in.datalen); if (rc) return rc; iscsi_tcp_hdr_recv_prep(tcp_conn); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Sets the value of the real time clock (RTC) counter. */
void HibernateRTCSet(uint32_t ui32RTCValue)
/* Sets the value of the real time clock (RTC) counter. */ void HibernateRTCSet(uint32_t ui32RTCValue)
{ HWREG(HIB_RTCLD) = ui32RTCValue; _HibernateWriteComplete(); }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Computes the 32-bit CRC of a given buffer of data word(32-bit) */
uint32_t CRC_CalculateBlockCRC(uint32_t pBuffer[], uint32_t bufferLength)
/* Computes the 32-bit CRC of a given buffer of data word(32-bit) */ uint32_t CRC_CalculateBlockCRC(uint32_t pBuffer[], uint32_t bufferLength)
{ uint32_t index = 0; for (index = 0; index < bufferLength; index++) { CRC->DATA = pBuffer[index]; } return (CRC->DATA); }
pikasTech/PikaPython
C++
MIT License
1,403
/* Clocks for each of the 3 SPI controllers supported by the Kinetis K70 MCUs. Enable the USB-HS/FS module clock */
static void usb_clk_enable(struct clk *clk)
/* Clocks for each of the 3 SPI controllers supported by the Kinetis K70 MCUs. Enable the USB-HS/FS module clock */ static void usb_clk_enable(struct clk *clk)
{ local_clk_enable(clk); mdelay(10); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Returns true if executing @program supresses domain transition, false otherwise. */
static bool tomoyo_is_domain_keeper(const struct tomoyo_path_info *domainname, const struct tomoyo_path_info *program, const struct tomoyo_path_info *last_name)
/* Returns true if executing @program supresses domain transition, false otherwise. */ static bool tomoyo_is_domain_keeper(const struct tomoyo_path_info *domainname, const struct tomoyo_path_info *program, const struct tomoyo_path_info *last_name)
{ struct tomoyo_domain_keeper_entry *ptr; bool flag = false; down_read(&tomoyo_domain_keeper_list_lock); list_for_each_entry(ptr, &tomoyo_domain_keeper_list, list) { if (ptr->is_deleted) continue; if (!ptr->is_last_name) { if (ptr->domainname != domainname) continue; } else { if (tomoyo_pathcmp(ptr->domainname, last_name)) continue; } if (ptr->program && tomoyo_pathcmp(ptr->program, program)) continue; if (ptr->is_not) { flag = false; break; } flag = true; } up_read(&tomoyo_domain_keeper_list_lock); return flag; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* lpIndex is the partition index of the target partition. needed only for VirtualIo, VirtualLan and SessionMgr. Zero indicates to use our partition index - for the other types. */
int HvLpEvent_openPath(HvLpEvent_Type eventType, HvLpIndex lpIndex)
/* lpIndex is the partition index of the target partition. needed only for VirtualIo, VirtualLan and SessionMgr. Zero indicates to use our partition index - for the other types. */ int HvLpEvent_openPath(HvLpEvent_Type eventType, HvLpIndex lpIndex)
{ if ((eventType < HvLpEvent_Type_NumTypes) && lpEventHandler[eventType]) { if (lpIndex == 0) lpIndex = itLpNaca.xLpIndex; HvCallEvent_openLpEventPath(lpIndex, eventType); ++lpEventHandlerPaths[eventType]; return 0; } return 1; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* . Function: smc_enable . Purpose: let the chip talk to the outside work . Method: . 1. Enable the transmitter . 2. Enable the receiver . 3. Enable interrupts */
static void smc_enable(struct eth_device *dev)
/* . Function: smc_enable . Purpose: let the chip talk to the outside work . Method: . 1. Enable the transmitter . 2. Enable the receiver . 3. Enable interrupts */ static void smc_enable(struct eth_device *dev)
{ PRINTK2("%s: smc_enable\n", SMC_DEV_NAME); SMC_SELECT_BANK( dev, 0 ); SMC_outw( dev, TCR_DEFAULT, TCR_REG ); SMC_outw( dev, RCR_DEFAULT, RCR_REG ); }
EmcraftSystems/u-boot
C++
Other
181
/* Allocates a single sub-sequence structure and sets it to all 0's. */
static struct name_seq* tipc_nameseq_create(u32 type, struct hlist_head *seq_head)
/* Allocates a single sub-sequence structure and sets it to all 0's. */ static struct name_seq* tipc_nameseq_create(u32 type, struct hlist_head *seq_head)
{ struct name_seq *nseq = kzalloc(sizeof(*nseq), GFP_ATOMIC); struct sub_seq *sseq = tipc_subseq_alloc(1); if (!nseq || !sseq) { warn("Name sequence creation failed, no memory\n"); kfree(nseq); kfree(sseq); return NULL; } spin_lock_init(&nseq->lock); nseq->type = type; nseq->sseqs = sseq; dbg("tipc_nameseq_create(): nseq = %p, type %u, ssseqs %p, ff: %u\n", nseq, type, nseq->sseqs, nseq->first_free); nseq->alloc = 1; INIT_HLIST_NODE(&nseq->ns_list); INIT_LIST_HEAD(&nseq->subscriptions); hlist_add_head(&nseq->ns_list, seq_head); return nseq; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* freezes application IO while that the actual IO operations runs. This functions MAY NOT be called from worker context. */
int drbd_bitmap_io(struct drbd_conf *mdev, int(*io_fn)(struct drbd_conf *), char *why)
/* freezes application IO while that the actual IO operations runs. This functions MAY NOT be called from worker context. */ int drbd_bitmap_io(struct drbd_conf *mdev, int(*io_fn)(struct drbd_conf *), char *why)
{ int rv; D_ASSERT(current != mdev->worker.task); drbd_suspend_io(mdev); drbd_bm_lock(mdev, why); rv = io_fn(mdev); drbd_bm_unlock(mdev); drbd_resume_io(mdev); return rv; }
robutest/uclinux
C++
GPL-2.0
60
/* Failure to inject an interrupt should give us the information in IDT_VECTORING_INFO_FIELD. However, if the failure occurs when fetching the interrupt redirection bitmap in the real-mode tss, this doesn't happen. So we do it ourselves. */
static void fixup_rmode_irq(struct vcpu_vmx *vmx)
/* Failure to inject an interrupt should give us the information in IDT_VECTORING_INFO_FIELD. However, if the failure occurs when fetching the interrupt redirection bitmap in the real-mode tss, this doesn't happen. So we do it ourselves. */ static void fixup_rmode_irq(struct vcpu_vmx *vmx)
{ vmx->rmode.irq.pending = 0; if (kvm_rip_read(&vmx->vcpu) + 1 != vmx->rmode.irq.rip) return; kvm_rip_write(&vmx->vcpu, vmx->rmode.irq.rip); if (vmx->idt_vectoring_info & VECTORING_INFO_VALID_MASK) { vmx->idt_vectoring_info &= ~VECTORING_INFO_TYPE_MASK; vmx->idt_vectoring_info |= INTR_TYPE_EXT_INTR; return; } vmx->idt_vectoring_info = VECTORING_INFO_VALID_MASK | INTR_TYPE_EXT_INTR | vmx->rmode.irq.vector; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Send one word data and get returned words into destination data buffer. */
uint32_t QspiSendWordAndGetWords(uint32_t WrData, uint32_t *pRdData, uint8_t LastRd)
/* Send one word data and get returned words into destination data buffer. */ uint32_t QspiSendWordAndGetWords(uint32_t WrData, uint32_t *pRdData, uint8_t LastRd)
{ uint32_t timeout1 = 0; QspiSendWord(WrData); *pRdData = QspiReadWord(); if (LastRd != 0) { while (!GetQspiRxHaveDataStatus()) { if (++timeout1 >= QSPI_TIME_OUT_CNT) { return QSPI_NULL; } } *pRdData = QspiReadWord(); return QSPI_SUCCESS; } return QSPI_NULL; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Maximum value of a q7 vector without index. */
void arm_max_no_idx_q7(const q7_t *pSrc, uint32_t blockSize, q7_t *pResult)
/* Maximum value of a q7 vector without index. */ void arm_max_no_idx_q7(const q7_t *pSrc, uint32_t blockSize, q7_t *pResult)
{ q7_t maxVal1, out; uint32_t blkCnt; out = *pSrc++; blkCnt = (blockSize - 1U); while (blkCnt > 0U) { maxVal1 = *pSrc++; if (out < maxVal1) { out = maxVal1; } blkCnt--; } *pResult = out; }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* The class is added to priority event queue to indicate that class will change its mode in cl->pq_key microseconds. Make sure that class is not already in the queue. */
static void htb_add_to_wait_tree(struct htb_sched *q, struct htb_class *cl, long delay)
/* The class is added to priority event queue to indicate that class will change its mode in cl->pq_key microseconds. Make sure that class is not already in the queue. */ static void htb_add_to_wait_tree(struct htb_sched *q, struct htb_class *cl, long delay)
{ struct rb_node **p = &q->wait_pq[cl->level].rb_node, *parent = NULL; cl->pq_key = q->now + delay; if (cl->pq_key == q->now) cl->pq_key++; if (q->near_ev_cache[cl->level] > cl->pq_key) q->near_ev_cache[cl->level] = cl->pq_key; while (*p) { struct htb_class *c; parent = *p; c = rb_entry(parent, struct htb_class, pq_node); if (cl->pq_key >= c->pq_key) p = &parent->rb_right; else p = &parent->rb_left; } rb_link_node(&cl->pq_node, parent, p); rb_insert_color(&cl->pq_node, &q->wait_pq[cl->level]); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Get data size in bytes based on the payload option of a message. */
uint8_t can_ctrl_message_size(struct can_ctrl_dev *dev, enum can_ctrl_fifo_plsize pls)
/* Get data size in bytes based on the payload option of a message. */ uint8_t can_ctrl_message_size(struct can_ctrl_dev *dev, enum can_ctrl_fifo_plsize pls)
{ switch(pls) { case DATA_BYTES_8: return 8; case DATA_BYTES_12: return 12; case DATA_BYTES_16: return 16; case DATA_BYTES_20: return 20; case DATA_BYTES_24: return 24; case DATA_BYTES_32: return 32; case DATA_BYTES_48: return 48; case DATA_BYTES_64: return 64; default: return 0; } }
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* Support function for RXFIFO_ALLOC macro. This function allocates up to 'max' number of MFIFO elements by enqueuing pointers to memory elements with associated memq links. */
void ull_rxfifo_alloc(uint8_t s, uint8_t n, uint8_t f, uint8_t *l, uint8_t *m, void *mem_free, void *link_free, uint8_t max)
/* Support function for RXFIFO_ALLOC macro. This function allocates up to 'max' number of MFIFO elements by enqueuing pointers to memory elements with associated memq links. */ void ull_rxfifo_alloc(uint8_t s, uint8_t n, uint8_t f, uint8_t *l, uint8_t *m, void *mem_free, void *link_free, uint8_t max)
{ uint8_t idx; while ((max--) && mfifo_enqueue_idx_get(n, f, *l, &idx)) { memq_link_t *link; struct node_rx_hdr *rx; link = mem_acquire(link_free); if (!link) { break; } rx = mem_acquire(mem_free); if (!rx) { mem_release(link, link_free); break; } link->mem = NULL; rx->link = link; mfifo_by_idx_enqueue(m, s, idx, rx, l); } }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* The function performs a Trusted Send of a Buffer containing a TCG_COM_PACKET. */
TCG_RESULT OpalTrustedSend(EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *Sscp, UINT32 MediaId, UINT8 SecurityProtocol, UINT16 SpSpecific, UINTN TransferLength, VOID *Buffer, UINTN BufferSize)
/* The function performs a Trusted Send of a Buffer containing a TCG_COM_PACKET. */ TCG_RESULT OpalTrustedSend(EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *Sscp, UINT32 MediaId, UINT8 SecurityProtocol, UINT16 SpSpecific, UINTN TransferLength, VOID *Buffer, UINTN BufferSize)
{ UINTN TransferLength512; EFI_STATUS Status; TransferLength512 = (TransferLength + 511) & ~(UINTN)511; if (TransferLength512 > BufferSize) { return TcgResultFailureBufferTooSmall; } ZeroMem ((UINT8 *)Buffer + TransferLength, TransferLength512 - TransferLength); Status = Sscp->SendData ( Sscp, MediaId, TRUSTED_COMMAND_TIMEOUT_NS, SecurityProtocol, SwapBytes16 (SpSpecific), TransferLength512, Buffer ); return Status == EFI_SUCCESS ? TcgResultSuccess : TcgResultFailure; }
tianocore/edk2
C++
Other
4,240
/* Updates the Receive Address Registers and Multicast Table Array. The caller must have a packed mc_addr_list of multicast addresses. The parameter rar_count will usually be hw->mac.rar_entry_count unless there are workarounds that change this. */
static void e1000_update_mc_addr_list_82571(struct e1000_hw *hw, u8 *mc_addr_list, u32 mc_addr_count, u32 rar_used_count, u32 rar_count)
/* Updates the Receive Address Registers and Multicast Table Array. The caller must have a packed mc_addr_list of multicast addresses. The parameter rar_count will usually be hw->mac.rar_entry_count unless there are workarounds that change this. */ static void e1000_update_mc_addr_list_82571(struct e1000_hw *hw, u8 *mc_addr_list, u32 mc_addr_count, u32 rar_used_count, u32 rar_count)
{ if (e1000e_get_laa_state_82571(hw)) rar_count--; e1000e_update_mc_addr_list_generic(hw, mc_addr_list, mc_addr_count, rar_used_count, rar_count); }
robutest/uclinux
C++
GPL-2.0
60
/* This function looks for the device configuration based on the unique device ID. The table XGpioPs_ConfigTable contains the configuration information for each device in the system. */
XGpioPs_Config* XGpioPs_LookupConfig(u16 DeviceId)
/* This function looks for the device configuration based on the unique device ID. The table XGpioPs_ConfigTable contains the configuration information for each device in the system. */ XGpioPs_Config* XGpioPs_LookupConfig(u16 DeviceId)
{ XGpioPs_Config *CfgPtr = NULL; u32 Index; for (Index = 0U; Index < (u32)XPAR_XGPIOPS_NUM_INSTANCES; Index++) { if (XGpioPs_ConfigTable[Index].DeviceId == DeviceId) { CfgPtr = &XGpioPs_ConfigTable[Index]; break; } } return (XGpioPs_Config *)CfgPtr; } /** @}
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns return ENOMEM if transfer ring i not enough TRBs to start all requests. */
static int cdns3_start_all_request(struct cdns3_device *priv_dev, struct cdns3_endpoint *priv_ep)
/* Returns return ENOMEM if transfer ring i not enough TRBs to start all requests. */ static int cdns3_start_all_request(struct cdns3_device *priv_dev, struct cdns3_endpoint *priv_ep)
{ struct usb_request *request; int ret = 0; while (!list_empty(&priv_ep->deferred_req_list)) { request = cdns3_next_request(&priv_ep->deferred_req_list); ret = cdns3_ep_run_transfer(priv_ep, request); if (ret) return ret; list_del(&request->list); list_add_tail(&request->list, &priv_ep->pending_req_list); } priv_ep->flags &= ~EP_RING_FULL; return ret; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Ask ESP to join AP. This, just sends join command. It is not a big problem if network interface is not configured. */
err_t espif_join_ap(const char *ssid, const char *pass)
/* Ask ESP to join AP. This, just sends join command. It is not a big problem if network interface is not configured. */ err_t espif_join_ap(const char *ssid, const char *pass)
{ return ERR_IF; } log_info(ESPIF, "Joining AP %s:*(%d)", ssid, strlen(pass)); esp_operating_mode = ESPIF_RUNNING_MODE; return espif_tx_msg_clientconfig_v2(ssid, pass); }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Detect a NexGen CPU running without BIOS hypercode new enough to have CPUID. (Thanks to Herbert Oppmann) */
static int deep_magic_nexgen_probe(void)
/* Detect a NexGen CPU running without BIOS hypercode new enough to have CPUID. (Thanks to Herbert Oppmann) */ static int deep_magic_nexgen_probe(void)
{ int ret; __asm__ __volatile__ ( " movw $0x5555, %%ax\n" " xorw %%dx,%%dx\n" " movw $2, %%cx\n" " divw %%cx\n" " movl $0, %%eax\n" " jnz 1f\n" " movl $1, %%eax\n" "1:\n" : "=a" (ret) : : "cx", "dx"); return ret; }
4ms/stm32mp1-baremetal
C++
Other
137