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
/* ixgbe_atr_get_l4type_82599 - Gets the layer 4 packet type @input: input stream to modify @l4type: the layer 4 type value to load */
static s32 ixgbe_atr_get_l4type_82599(struct ixgbe_atr_input *input, u8 *l4type)
/* ixgbe_atr_get_l4type_82599 - Gets the layer 4 packet type @input: input stream to modify @l4type: the layer 4 type value to load */ static s32 ixgbe_atr_get_l4type_82599(struct ixgbe_atr_input *input, u8 *l4type)
{ *l4type = input->byte_stream[IXGBE_ATR_L4TYPE_OFFSET]; return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* When we up the command semaphore, everybody possibly held trying to execute a command should be granted entry and then they'll see the host is quiescing and up it (so it will chain to the next waiter). This should not happen (in any case), as we can only remove when there are no handles open... */
static void whcrc_remove(struct umc_dev *umc_dev)
/* When we up the command semaphore, everybody possibly held trying to execute a command should be granted entry and then they'll see the host is quiescing and up it (so it will chain to the next waiter). This should not happen (in any case), as we can only remove when there are no handles open... */ static void whcrc_remove(struct umc_dev *umc_dev)
{ struct whcrc *whcrc = umc_get_drvdata(umc_dev); struct uwb_rc *uwb_rc = whcrc->uwb_rc; umc_set_drvdata(umc_dev, NULL); uwb_rc_rm(uwb_rc); whcrc_release_rc_umc(whcrc); kfree(whcrc); uwb_rc_put(uwb_rc); }
robutest/uclinux
C++
GPL-2.0
60
/* Set the address of the tccb in the specified tcw. */
void tcw_set_tccb(struct tcw *tcw, struct tccb *tccb)
/* Set the address of the tccb in the specified tcw. */ void tcw_set_tccb(struct tcw *tcw, struct tccb *tccb)
{ tcw->tccb = (u64) ((addr_t) tccb); }
robutest/uclinux
C++
GPL-2.0
60
/* Writes user data to the specified Data Backup Register. */
void BKP_WriteBkpData(uint16_t BKP_DAT, uint16_t Data)
/* Writes user data to the specified Data Backup Register. */ void BKP_WriteBkpData(uint16_t BKP_DAT, uint16_t Data)
{ __IO uint32_t tmp = 0; assert_param(IS_BKP_DAT(BKP_DAT)); tmp = (uint32_t)BKP_BASE; tmp += BKP_DAT; *(__IO uint32_t*)tmp = Data; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Clears the status bits in this endpoint in host mode. */
void USBHostEndpointStatusClear(uint32_t ui32Base, uint32_t ui32Endpoint, uint32_t ui32Flags)
/* Clears the status bits in this endpoint in host mode. */ void USBHostEndpointStatusClear(uint32_t ui32Base, uint32_t ui32Endpoint, uint32_t ui32Flags)
{ ASSERT(ui32Base == USB0_BASE); ASSERT((ui32Endpoint == USB_EP_0) || (ui32Endpoint == USB_EP_1) || (ui32Endpoint == USB_EP_2) || (ui32Endpoint == USB_EP_3) || (ui32Endpoint == USB_EP_4) || (ui32Endpoint == USB_EP_5) || (ui32Endpoint == USB_EP_6) || (ui32Endpoint == USB_EP_7)); if (ui32Endpoint == USB_EP_0) { HWREGB(ui32Base + USB_O_CSRL0) &= ~ui32Flags; } else { HWREGB(ui32Base + USB_O_TXCSRL1 + EP_OFFSET(ui32Endpoint)) &= ~ui32Flags; HWREGB(ui32Base + USB_O_RXCSRL1 + EP_OFFSET(ui32Endpoint)) &= ~(ui32Flags >> USB_RX_EPSTATUS_SHIFT); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* allow the fileserver to see if the cache manager is still alive */
static void SRXAFSCB_Probe(struct work_struct *work)
/* allow the fileserver to see if the cache manager is still alive */ static void SRXAFSCB_Probe(struct work_struct *work)
{ struct afs_call *call = container_of(work, struct afs_call, work); _enter(""); afs_send_empty_reply(call); _leave(""); }
robutest/uclinux
C++
GPL-2.0
60
/* Transmit one 8-9 bit frame with extended control. Notice that possible parity/stop bits in asynchronous mode are not considered part of specified frame bit length. */
void LEUART_TxExt(LEUART_TypeDef *leuart, uint16_t data)
/* Transmit one 8-9 bit frame with extended control. Notice that possible parity/stop bits in asynchronous mode are not considered part of specified frame bit length. */ void LEUART_TxExt(LEUART_TypeDef *leuart, uint16_t data)
{ while (!(leuart->STATUS & LEUART_STATUS_TXBL)) ; LEUART_Sync(leuart, LEUART_SYNCBUSY_TXDATAX); leuart->TXDATAX = (uint32_t)data; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Walk one dissector table calling a user supplied function only on any entry that has been changed from its original state. */
void dissector_table_foreach_changed(const char *table_name, DATFunc func, gpointer user_data)
/* Walk one dissector table calling a user supplied function only on any entry that has been changed from its original state. */ void dissector_table_foreach_changed(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_changed_func, &info); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* The a_arg dance is to avoid annoying whining by compilers that a might be clobbered by longjmp - yeah, it might, but */
struct arth* gen_neg(compiler_state_t *cstate, struct arth *a_arg)
/* The a_arg dance is to avoid annoying whining by compilers that a might be clobbered by longjmp - yeah, it might, but */ struct arth* gen_neg(compiler_state_t *cstate, struct arth *a_arg)
{ struct arth *a = a_arg; struct slist *s; if (setjmp(cstate->top_ctx)) return (NULL); s = xfer_to_a(cstate, a); sappend(a->s, s); s = new_stmt(cstate, BPF_ALU|BPF_NEG); s->s.k = 0; sappend(a->s, s); s = new_stmt(cstate, BPF_ST); s->s.k = a->regno; sappend(a->s, s); return a; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* UART MSP Initialization This function configures the hardware resources used in this example. */
void HAL_UART_MspInit(UART_HandleTypeDef *huart)
/* UART MSP Initialization This function configures the hardware resources used in this example. */ void HAL_UART_MspInit(UART_HandleTypeDef *huart)
{ GPIO_InitTypeDef GPIO_InitStruct = {0}; if(huart->Instance==USART2) { __HAL_RCC_USART2_CLK_ENABLE(); __HAL_RCC_GPIOD_CLK_ENABLE(); GPIO_InitStruct.Pin = GPIO_PIN_5; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); GPIO_InitStruct.Pin = GPIO_PIN_6; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_PULLUP; HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); __HAL_AFIO_REMAP_USART2_ENABLE(); HAL_NVIC_SetPriority(USART2_IRQn, 0, 0); HAL_NVIC_EnableIRQ(USART2_IRQn); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function will ASSERT if the APIC timer intial count returned from GetApicTimerInitCount() is zero. */
VOID EFIAPI InternalX86Delay(IN UINT32 Delay)
/* This function will ASSERT if the APIC timer intial count returned from GetApicTimerInitCount() is zero. */ VOID EFIAPI InternalX86Delay(IN UINT32 Delay)
{ INT32 Ticks; UINT32 Times; UINT32 InitCount; UINT32 StartTick; InitCount = GetApicTimerInitCount (); ASSERT (InitCount != 0); Times = Delay / (InitCount / 2); Delay = Delay % (InitCount / 2); StartTick = GetApicTimerCurrentCount (); do { do { CpuPause (); Ticks = StartTick - GetApicTimerCurrentCount (); if (Ticks < 0) { Ticks += InitCount; } } while ((UINT32)Ticks < Delay); StartTick -= (StartTick > Delay) ? Delay : (Delay - InitCount); Delay = InitCount / 2; } while (Times-- > 0); }
tianocore/edk2
C++
Other
4,240
/* Reads the specified DAC channel data output value. */
uint16_t DAC_ReadDataOutputValue(DAC_CHANNEL_T channel)
/* Reads the specified DAC channel data output value. */ uint16_t DAC_ReadDataOutputValue(DAC_CHANNEL_T channel)
{ __IO uint32_t tmp = 0; tmp = (uint32_t) DAC_BASE ; tmp += 0x0000002C + ((uint32_t)channel >> 2); return (uint16_t) (*(__IO uint32_t*) tmp); }
pikasTech/PikaPython
C++
MIT License
1,403
/* Steps through buffer one byte at at time, calculates reflected crc using table. */
static u32 crc32c(u32 crc, const u8 *data, unsigned int length)
/* Steps through buffer one byte at at time, calculates reflected crc using table. */ static u32 crc32c(u32 crc, const u8 *data, unsigned int length)
{ while (length--) crc = crc32c_table[(crc ^ *data++) & 0xFFL] ^ (crc >> 8); return crc; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* One notified function to stop the Host Controller at the end of PEI */
EFI_STATUS EFIAPI UhcEndOfPei(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi)
/* One notified function to stop the Host Controller at the end of PEI */ EFI_STATUS EFIAPI UhcEndOfPei(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi)
{ USB_UHC_DEV *Uhc; Uhc = PEI_RECOVERY_USB_UHC_DEV_FROM_THIS_NOTIFY (NotifyDescriptor); UhciStopHc (Uhc, 1000 * 1000); return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Sets the direction and mode of the specified pin(s). The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on. */
void xGPIODirModeSet(unsigned long ulPort, unsigned long ulPins, unsigned long ulPinIO)
/* Sets the direction and mode of the specified pin(s). The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on. */ void xGPIODirModeSet(unsigned long ulPort, unsigned long ulPins, unsigned long ulPinIO)
{ unsigned long ulBit; xASSERT(GPIOBaseValid(ulPort)); xASSERT((ulPinIO == xGPIO_DIR_MODE_IN) || (ulPinIO == xGPIO_DIR_MODE_OUT) || (ulPinIO == xGPIO_DIR_MODE_OD) || (ulPinIO == xGPIO_DIR_MODE_QB)); for(ulBit=0; ulBit<16; ulBit++) { if(ulPins & (1 << ulBit)) { GPIODirModeSet(ulPort, ulBit, ulPinIO); } } }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* This function is used to set the number of period to be generated. */
int tls_pwm_stoptime_by_period_config(u8 channel, u8 pnum)
/* This function is used to set the number of period to be generated. */ int tls_pwm_stoptime_by_period_config(u8 channel, u8 pnum)
{ u32 temp = 0; if(channel > (PWM_CHANNEL_MAX_NUM - 1)) return WM_FAILED; if (4 == channel) { temp = tls_reg_read32(HR_PWM_CH4_REG1) & ~0x000000FF; temp |= pnum; tls_reg_write32(HR_PWM_CH4_REG1, temp); } else { temp = tls_reg_read32(HR_PWM_PNUM) & ~(0xFF << channel * 8); temp |= (pnum << (channel * 8)); tls_reg_write32(HR_PWM_PNUM, temp); } return WM_SUCCESS; }
Nicholas3388/LuaNode
C++
Other
1,055
/* Function for handling the timer timeout and blinking LED_0. This function will be called each time the timer expires. */
static void led_toggle_timer_handler(void const *arg)
/* Function for handling the timer timeout and blinking LED_0. This function will be called each time the timer expires. */ static void led_toggle_timer_handler(void const *arg)
{ UNUSED_PARAMETER(arg); bsp_board_led_invert(BSP_BOARD_LED_0); }
remotemcu/remcu-chip-sdks
C++
null
436
/* Xilinx PS GPIO controller parent device ISR. Interrupt service routine for the Xilinx PS GPIO controller's IRQ. The ISR iterates all associated MIO / EMIO GPIO pink bank child device instances and checks each bank's interrupt status. If any pending interrupt is detected within a GPIO pin bank, the callbacks registered for the respective bank are triggered using the functionality provided by the GPIO sub-system. */
static void gpio_xlnx_ps_isr(const struct device *dev)
/* Xilinx PS GPIO controller parent device ISR. Interrupt service routine for the Xilinx PS GPIO controller's IRQ. The ISR iterates all associated MIO / EMIO GPIO pink bank child device instances and checks each bank's interrupt status. If any pending interrupt is detected within a GPIO pin bank, the callbacks registered for the respective bank are triggered using the functionality provided by the GPIO sub-system. */ static void gpio_xlnx_ps_isr(const struct device *dev)
{ const struct gpio_xlnx_ps_dev_cfg *dev_conf = dev->config; const struct gpio_driver_api *api; struct gpio_xlnx_ps_bank_dev_data *bank_data; uint32_t bank; uint32_t int_mask; for (bank = 0; bank < dev_conf->num_banks; bank++) { api = dev_conf->bank_devices[bank]->api; int_mask = 0; if (api != NULL) { int_mask = api->get_pending_int(dev_conf->bank_devices[bank]); } if (int_mask) { bank_data = (struct gpio_xlnx_ps_bank_dev_data *) dev_conf->bank_devices[bank]->data; gpio_fire_callbacks(&bank_data->callbacks, dev_conf->bank_devices[bank], int_mask); } } }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Gets detailed MP-related information on the requested processor at the instant this call is made. */
EFI_STATUS GetProcessorInformation(IN UINTN ProcessorNumber, OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer)
/* Gets detailed MP-related information on the requested processor at the instant this call is made. */ EFI_STATUS GetProcessorInformation(IN UINTN ProcessorNumber, OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer)
{ EFI_STATUS Status; EFI_MP_SERVICES_PROTOCOL *MpServices; CPU_FEATURES_DATA *CpuFeaturesData; CpuFeaturesData = GetCpuFeaturesData (); MpServices = CpuFeaturesData->MpService.Protocol; Status = MpServices->GetProcessorInfo ( MpServices, ProcessorNumber, ProcessorInfoBuffer ); return Status; }
tianocore/edk2
C++
Other
4,240
/* This routine will update the HBA index of a queue to reflect consumption of one Receive Queue Entry by the HBA. When the HBA indicates that it has consumed an entry the host calls this function to update the queue's internal pointers. This routine returns the number of entries that were consumed by the HBA. */
static uint32_t lpfc_sli4_rq_release(struct lpfc_queue *hq, struct lpfc_queue *dq)
/* This routine will update the HBA index of a queue to reflect consumption of one Receive Queue Entry by the HBA. When the HBA indicates that it has consumed an entry the host calls this function to update the queue's internal pointers. This routine returns the number of entries that were consumed by the HBA. */ static uint32_t lpfc_sli4_rq_release(struct lpfc_queue *hq, struct lpfc_queue *dq)
{ if ((hq->type != LPFC_HRQ) || (dq->type != LPFC_DRQ)) return 0; hq->hba_index = ((hq->hba_index + 1) % hq->entry_count); dq->hba_index = ((dq->hba_index + 1) % dq->entry_count); return 1; }
robutest/uclinux
C++
GPL-2.0
60
/* Wait until last write operation on RTC registers has finished. */
void RTC_WaitForLastTask(void)
/* Wait until last write operation on RTC registers has finished. */ void RTC_WaitForLastTask(void)
{ while (RTC->CSTS_B.OCFLG == BIT_RESET) { } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Given an EFI_FILE_INFO object received in an EFI_FILE_PROTOCOL.SetInfo() call, determine whether updating the size of the file is necessary, relative to an EFI_FILE_INFO object describing the current state of the file. */
VOID VirtioFsGetFuseSizeUpdate(IN EFI_FILE_INFO *Info, IN EFI_FILE_INFO *NewInfo, OUT BOOLEAN *Update, OUT UINT64 *Size)
/* Given an EFI_FILE_INFO object received in an EFI_FILE_PROTOCOL.SetInfo() call, determine whether updating the size of the file is necessary, relative to an EFI_FILE_INFO object describing the current state of the file. */ VOID VirtioFsGetFuseSizeUpdate(IN EFI_FILE_INFO *Info, IN EFI_FILE_INFO *NewInfo, OUT BOOLEAN *Update, OUT UINT64 *Size)
{ BOOLEAN IsDirectory; IsDirectory = (BOOLEAN)((Info->Attribute & EFI_FILE_DIRECTORY) != 0); if (IsDirectory || (Info->FileSize == NewInfo->FileSize)) { *Update = FALSE; return; } *Update = TRUE; *Size = NewInfo->FileSize; }
tianocore/edk2
C++
Other
4,240
/* Stops the firmware update. This is where the bootloader starts the user program on the target if a valid one is present. After this the connection with the target is severed. */
static void XcpLoaderStop(void)
/* Stops the firmware update. This is where the bootloader starts the user program on the target if a valid one is present. After this the connection with the target is severed. */ static void XcpLoaderStop(void)
{ assert(xcpSettings.transport != NULL); if ( (xcpSettings.transport != NULL) && (xcpConnected) ) { if (XcpLoaderSendCmdProgram(0, NULL)) { (void)XcpLoaderSendCmdProgramReset(); } xcpSettings.transport->Disconnect(); xcpConnected = false; } }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Send a sequence of bytes to a SPI device using USART in SPI mode. Received bytes on the USART in SPI mode are discarded. */
status_code_t usart_spi_write_packet(USART_t *usart, const uint8_t *data, size_t len)
/* Send a sequence of bytes to a SPI device using USART in SPI mode. Received bytes on the USART in SPI mode are discarded. */ status_code_t usart_spi_write_packet(USART_t *usart, const uint8_t *data, size_t len)
{ size_t i = 0; while (len) { usart_spi_transmit(usart, *(data + i)); len--; i++; } return STATUS_OK; }
memfault/zero-to-main
C++
null
200
/* This is the iodone() function for buffers which have been logged. It is called when they are eventually flushed out. It should remove the buf item from the AIL, and free the buf item. It is called by xfs_buf_iodone_callbacks() above which will take care of cleaning up the buffer itself. */
void xfs_buf_iodone(xfs_buf_t *bp, xfs_buf_log_item_t *bip)
/* This is the iodone() function for buffers which have been logged. It is called when they are eventually flushed out. It should remove the buf item from the AIL, and free the buf item. It is called by xfs_buf_iodone_callbacks() above which will take care of cleaning up the buffer itself. */ void xfs_buf_iodone(xfs_buf_t *bp, xfs_buf_log_item_t *bip)
{ struct xfs_ail *ailp = bip->bli_item.li_ailp; ASSERT(bip->bli_buf == bp); xfs_buf_rele(bp); spin_lock(&ailp->xa_lock); xfs_trans_ail_delete(ailp, (xfs_log_item_t *)bip); xfs_buf_item_free(bip); }
robutest/uclinux
C++
GPL-2.0
60
/* Initializes the AES peripheral according to the specified parameters in the AES_InitStruct: */
void AES_Init(AES_InitTypeDef *AES_InitStruct)
/* Initializes the AES peripheral according to the specified parameters in the AES_InitStruct: */ void AES_Init(AES_InitTypeDef *AES_InitStruct)
{ uint32_t tmpreg = 0; assert_param(IS_AES_MODE(AES_InitStruct->AES_Operation)); assert_param(IS_AES_CHAINING(AES_InitStruct->AES_Chaining)); assert_param(IS_AES_DATATYPE(AES_InitStruct->AES_DataType)); tmpreg = AES->CR; tmpreg &= (uint32_t)CR_CLEAR_MASK; tmpreg |= (AES_InitStruct->AES_Operation | AES_InitStruct->AES_Chaining | AES_InitStruct->AES_DataType); AES->CR = (uint32_t) tmpreg; }
avem-labs/Avem
C++
MIT License
1,752
/* Checks whether the specified ADC interrupt has occurred or not. */
ITStatus ADC_GetITStatus(ADC_TypeDef *ADCx, uint16_t ADC_IT)
/* Checks whether the specified ADC interrupt has occurred or not. */ ITStatus ADC_GetITStatus(ADC_TypeDef *ADCx, uint16_t ADC_IT)
{ ITStatus bitstatus = RESET; uint32_t itmask = 0, enablestatus = 0; assert_param(IS_ADC_ALL_PERIPH(ADCx)); assert_param(IS_ADC_IT(ADC_IT)); itmask = ADC_IT >> 8; enablestatus = (ADCx->CR1 & ((uint32_t)0x01 << (uint8_t)ADC_IT)) ; if (((ADCx->SR & itmask) != (uint32_t)RESET) && enablestatus) { bitstatus = SET; } else { bitstatus = RESET; } return bitstatus; }
MaJerle/stm32f429
C++
null
2,036
/* param tcd A point to the TCD structure. param config A pointer to the minor offset configuration structure. */
void EDMA_TcdSetMinorOffsetConfig(edma_tcd_t *tcd, const edma_minor_offset_config_t *config)
/* param tcd A point to the TCD structure. param config A pointer to the minor offset configuration structure. */ void EDMA_TcdSetMinorOffsetConfig(edma_tcd_t *tcd, const edma_minor_offset_config_t *config)
{ assert(tcd != NULL); assert(((uint32_t)tcd & 0x1FU) == 0); uint32_t tmpreg; tmpreg = tcd->NBYTES & ~(DMA_NBYTES_MLOFFYES_SMLOE_MASK | DMA_NBYTES_MLOFFYES_DMLOE_MASK | DMA_NBYTES_MLOFFYES_MLOFF_MASK); tmpreg |= (DMA_NBYTES_MLOFFYES_SMLOE(config->enableSrcMinorOffset) | DMA_NBYTES_MLOFFYES_DMLOE(config->enableDestMinorOffset) | DMA_NBYTES_MLOFFYES_MLOFF(config->minorOffset)); tcd->NBYTES = tmpreg; }
nanoframework/nf-interpreter
C++
MIT License
293
/* Initialise the serial port with the given baudrate. The settings are always 8 data bits, no parity, 1 stop bit, no start bits. */
int serial_init(void)
/* Initialise the serial port with the given baudrate. The settings are always 8 data bits, no parity, 1 stop bit, no start bits. */ int serial_init(void)
{ serial_setbrg (); return 0; }
EmcraftSystems/u-boot
C++
Other
181
/* Convert UINT32 data to big-endian for aligned with the FDT blob */
UINT32 EFIAPI CpuToFdt32(IN UINT32 Value)
/* Convert UINT32 data to big-endian for aligned with the FDT blob */ UINT32 EFIAPI CpuToFdt32(IN UINT32 Value)
{ return cpu_to_fdt32 (Value); }
tianocore/edk2
C++
Other
4,240
/* Tell if a device supports a given Hypertransport capability. Returns an address within the device's PCI configuration space or 0 in case the device does not support the request capability. The address points to the PCI capability, of type PCI_CAP_ID_HT, which has a Hypertransport capability matching @ht_cap. */
int pci_find_ht_capability(struct pci_dev *dev, int ht_cap)
/* Tell if a device supports a given Hypertransport capability. Returns an address within the device's PCI configuration space or 0 in case the device does not support the request capability. The address points to the PCI capability, of type PCI_CAP_ID_HT, which has a Hypertransport capability matching @ht_cap. */ int pci_find_ht_capability(struct pci_dev *dev, int ht_cap)
{ int pos; pos = __pci_bus_find_cap_start(dev->bus, dev->devfn, dev->hdr_type); if (pos) pos = __pci_find_next_ht_cap(dev, pos, ht_cap); return pos; }
robutest/uclinux
C++
GPL-2.0
60
/* Custom handler for standard requests in order to catch the request and return the WebUSB Platform Capability Descriptor. */
int custom_handle_req(struct usb_setup_packet *pSetup, int32_t *len, uint8_t **data)
/* Custom handler for standard requests in order to catch the request and return the WebUSB Platform Capability Descriptor. */ int custom_handle_req(struct usb_setup_packet *pSetup, int32_t *len, uint8_t **data)
{ if (usb_reqtype_is_to_device(pSetup)) { return -ENOTSUP; } if (USB_GET_DESCRIPTOR_TYPE(pSetup->wValue) == USB_DESC_STRING && USB_GET_DESCRIPTOR_INDEX(pSetup->wValue) == 0xEE) { *data = (uint8_t *)(&msos1_string_descriptor); *len = sizeof(msos1_string_descriptor); LOG_DBG("Get MS OS Descriptor v1 string"); return 0; } return -EINVAL; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* dmi_is_end_of_table - check for end-of-table marker @dmi: pointer to the dmi_system_id structure to check */
static bool dmi_is_end_of_table(const struct dmi_system_id *dmi)
/* dmi_is_end_of_table - check for end-of-table marker @dmi: pointer to the dmi_system_id structure to check */ static bool dmi_is_end_of_table(const struct dmi_system_id *dmi)
{ return dmi->matches[0].slot == DMI_NONE; }
robutest/uclinux
C++
GPL-2.0
60
/* param base CMP peripheral base address. param mask Mask value for the flags. See "_cmp_status_flags". */
void CMP_ClearStatusFlags(CMP_Type *base, uint32_t mask)
/* param base CMP peripheral base address. param mask Mask value for the flags. See "_cmp_status_flags". */ void CMP_ClearStatusFlags(CMP_Type *base, uint32_t mask)
{ uint8_t tmp8 = base->SCR & ~(CMP_SCR_CFR_MASK | CMP_SCR_CFF_MASK); if (0U != (kCMP_OutputRisingEventFlag & mask)) { tmp8 |= CMP_SCR_CFR_MASK; } if (0U != (kCMP_OutputFallingEventFlag & mask)) { tmp8 |= CMP_SCR_CFF_MASK; } base->SCR = tmp8; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Get to know the Rx FIFO is Empty or not from the specified port. */
xtBoolean UARTFIFORxIsEmpty(unsigned long ulBase)
/* Get to know the Rx FIFO is Empty or not from the specified port. */ xtBoolean UARTFIFORxIsEmpty(unsigned long ulBase)
{ xASSERT(UARTBaseValid(ulBase)); return((xHWREG(ulBase + USART_LSR) & USART_LSR_RXFIFO_READY) ? xfalse : xtrue); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Decrement the refcount, and if 0, call kobject_cleanup(). */
void kobject_put(struct kobject *kobj)
/* Decrement the refcount, and if 0, call kobject_cleanup(). */ void kobject_put(struct kobject *kobj)
{ if (kobj) { if (!kobj->state_initialized) WARN(1, KERN_WARNING "kobject: '%s' (%p): is not " "initialized, yet kobject_put() is being " "called.\n", kobject_name(kobj), kobj); kref_put(&kobj->kref, kobject_release); } }
robutest/uclinux
C++
GPL-2.0
60
/* Returns the state of the serial modem control lines. These next 2 functions are the way kernel versions > 2.5 handle modem control lines rather than IOCTLs. */
static int rp_tiocmget(struct tty_struct *tty, struct file *file)
/* Returns the state of the serial modem control lines. These next 2 functions are the way kernel versions > 2.5 handle modem control lines rather than IOCTLs. */ static int rp_tiocmget(struct tty_struct *tty, struct file *file)
{ struct r_port *info = tty->driver_data; unsigned int control, result, ChanStatus; ChanStatus = sGetChanStatusLo(&info->channel); control = info->channel.TxControl[3]; result = ((control & SET_RTS) ? TIOCM_RTS : 0) | ((control & SET_DTR) ? TIOCM_DTR : 0) | ((ChanStatus & CD_ACT) ? TIOCM_CAR : 0) | (sGetChanRI(&info->channel) ? TIOCM_RNG : 0) | ((ChanStatus & DSR_ACT) ? TIOCM_DSR : 0) | ((ChanStatus & CTS_ACT) ? TIOCM_CTS : 0); return result; }
robutest/uclinux
C++
GPL-2.0
60
/* atl1_hash_mc_addr purpose set hash value for a multicast address hash calcu processing : */
u32 atl1_hash_mc_addr(struct atl1_hw *hw, u8 *mc_addr)
/* atl1_hash_mc_addr purpose set hash value for a multicast address hash calcu processing : */ u32 atl1_hash_mc_addr(struct atl1_hw *hw, u8 *mc_addr)
{ u32 crc32, value = 0; int i; crc32 = ether_crc_le(6, mc_addr); for (i = 0; i < 32; i++) value |= (((crc32 >> i) & 1) << (31 - i)); return value; }
robutest/uclinux
C++
GPL-2.0
60
/* Register Device. Register the Bluetooth device in a particular GAP role. This API must be called after calling */
ADI_BLER_RESULT adi_radio_RegisterDevice(const ADI_BLE_ROLE eBleRole)
/* Register Device. Register the Bluetooth device in a particular GAP role. This API must be called after calling */ ADI_BLER_RESULT adi_radio_RegisterDevice(const ADI_BLE_ROLE eBleRole)
{ ADI_BLER_RESULT bleResult; ADI_BLE_LOGEVENT(LOGID_CMD_BLEGAP_REGISTER_DEVICE); ADI_BLE_RADIO_CMD_START(CMD_BLEGAP_REGISTER_DEVICE); pBLERadio->eBleDevRole = eBleRole; memcpy(&pBLERadio->cmdPkt[ADI_RADIO_CMD_HEADER_LEN], &eBleRole, 1u); bleResult = bler_process_cmd(CMD_BLEGAP_REGISTER_DEVICE, 1u, NULL, 0u); if(bleResult == ADI_BLER_SUCCESS){ bleResult = ADI_BLE_WAIT_FOR_COMPLETION(ADI_EVENT_FLAG_RESP_SUCCESS,ADI_BLER_CMD_TIMEOUT); } ADI_BLE_RADIO_CMD_END(); return (bleResult); }
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* Lock a given peripheral's control registers. Locks a given peripheral's control registers, to deny write access to the peripheral to prevent accidental changes to the module's configuration. */
__no_inline enum status_code system_peripheral_lock(const uint32_t peripheral_id, const uint32_t key)
/* Lock a given peripheral's control registers. Locks a given peripheral's control registers, to deny write access to the peripheral to prevent accidental changes to the module's configuration. */ __no_inline enum status_code system_peripheral_lock(const uint32_t peripheral_id, const uint32_t key)
{ if (~peripheral_id != key) { Assert(false); return STATUS_ERR_INVALID_ARG; } PAC->WRCTRL.reg = peripheral_id | PAC_WRCTRL_KEY(PAC_WRCTRL_KEY_SET_Val); return STATUS_OK; }
memfault/zero-to-main
C++
null
200
/* Caller has made sure that the swapdevice corresponding to entry is still around or has not been recycled. */
void swap_free(swp_entry_t entry)
/* Caller has made sure that the swapdevice corresponding to entry is still around or has not been recycled. */ void swap_free(swp_entry_t entry)
{ struct swap_info_struct *p; p = swap_info_get(entry); if (p) { swap_entry_free(p, entry, 1); spin_unlock(&swap_lock); } }
robutest/uclinux
C++
GPL-2.0
60
/* Returns true if the utf8 character 'c' is a multibyte continuation character and the terminal is in unicode mode. */
rt_inline int is_continuation(unsigned char c, struct tty_struct *tty)
/* Returns true if the utf8 character 'c' is a multibyte continuation character and the terminal is in unicode mode. */ rt_inline int is_continuation(unsigned char c, struct tty_struct *tty)
{ return I_IUTF8(tty) && is_utf8_continuation(c); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Reads the specified I2C register and returns its value. */
uint32_t I2C_ReadRegister(I2C_TypeDef *I2Cx, uint8_t I2C_Register)
/* Reads the specified I2C register and returns its value. */ uint32_t I2C_ReadRegister(I2C_TypeDef *I2Cx, uint8_t I2C_Register)
{ __IO uint32_t tmp = 0; assert_param(IS_I2C_ALL_PERIPH(I2Cx)); assert_param(IS_I2C_REGISTER(I2C_Register)); tmp = (uint32_t)I2Cx; tmp += I2C_Register; return (*(__IO uint32_t *) tmp); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Enables or disables the ADC DMA request after last transfer in multi ADC mode */
void ADC_MultiModeDMARequestAfterLastTransferCmd(FunctionalState NewState)
/* Enables or disables the ADC DMA request after last transfer in multi ADC mode */ void ADC_MultiModeDMARequestAfterLastTransferCmd(FunctionalState NewState)
{ assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { ADC->CCR |= (uint32_t)ADC_CCR_DDS; } else { ADC->CCR &= (uint32_t)(~ADC_CCR_DDS); } }
MaJerle/stm32f429
C++
null
2,036
/* If Cert is NULL, then return FALSE. If SingleX509Cert is NULL, then return FALSE. If this interface is not supported, then return FALSE. */
BOOLEAN EFIAPI X509ConstructCertificate(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT UINT8 **SingleX509Cert)
/* If Cert is NULL, then return FALSE. If SingleX509Cert is NULL, then return FALSE. If this interface is not supported, then return FALSE. */ BOOLEAN EFIAPI X509ConstructCertificate(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT UINT8 **SingleX509Cert)
{ CALL_CRYPTO_SERVICE (X509ConstructCertificate, (Cert, CertSize, SingleX509Cert), FALSE); }
tianocore/edk2
C++
Other
4,240
/* @ops: AvbOps, contains AVB ops handlers @partition_name: partition name @offset_from_partition: offset from the beginning of partition @num_bytes: amount of bytes to write @buf: data to write @out_num_read: */
static AvbIOResult write_to_partition(AvbOps *ops, const char *partition_name, s64 offset_from_partition, size_t num_bytes, const void *buffer)
/* @ops: AvbOps, contains AVB ops handlers @partition_name: partition name @offset_from_partition: offset from the beginning of partition @num_bytes: amount of bytes to write @buf: data to write @out_num_read: */ static AvbIOResult write_to_partition(AvbOps *ops, const char *partition_name, s64 offset_from_partition, size_t num_bytes, const void *buffer)
{ return mmc_byte_io(ops, partition_name, offset_from_partition, num_bytes, (void *)buffer, NULL, IO_WRITE); }
4ms/stm32mp1-baremetal
C++
Other
137
/* Returns a offset of next node from the given node. */
INT32 EFIAPI FdtNextNode(IN CONST VOID *Fdt, IN INT32 Offset, IN INT32 *Depth)
/* Returns a offset of next node from the given node. */ INT32 EFIAPI FdtNextNode(IN CONST VOID *Fdt, IN INT32 Offset, IN INT32 *Depth)
{ return fdt_next_node (Fdt, Offset, Depth); }
tianocore/edk2
C++
Other
4,240
/* Initialize LVD config structure. Fill each pstcLvdInit with default value. */
int32_t PWC_LVD_StructInit(stc_pwc_lvd_init_t *pstcLvdInit)
/* Initialize LVD config structure. Fill each pstcLvdInit with default value. */ int32_t PWC_LVD_StructInit(stc_pwc_lvd_init_t *pstcLvdInit)
{ int32_t i32Ret = LL_OK; if (NULL == pstcLvdInit) { i32Ret = LL_ERR_INVD_PARAM; } else { pstcLvdInit->u32State = PWC_LVD_OFF; pstcLvdInit->u32CompareOutputState = PWC_LVD_CMP_OFF; pstcLvdInit->u32ExceptionType = PWC_LVD_EXP_TYPE_NONE; pstcLvdInit->u32Filter = PWC_LVD_FILTER_OFF; pstcLvdInit->u32FilterClock = PWC_LVD_FILTER_LRC_MUL2; pstcLvdInit->u32ThresholdVoltage = PWC_LVD_THRESHOLD_LVL0; pstcLvdInit->u32TriggerEdge = PWC_LVD_TRIG_FALLING; } return i32Ret; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function is called with hbalock held to release driver iocb object to the iocb pool. The iotag in the iocb object does not change for each use of the iocb object. This function clears all other fields of the iocb object when it is freed. */
static void __lpfc_sli_release_iocbq_s3(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq)
/* This function is called with hbalock held to release driver iocb object to the iocb pool. The iotag in the iocb object does not change for each use of the iocb object. This function clears all other fields of the iocb object when it is freed. */ static void __lpfc_sli_release_iocbq_s3(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq)
{ size_t start_clean = offsetof(struct lpfc_iocbq, iocb); memset((char*)iocbq + start_clean, 0, sizeof(*iocbq) - start_clean); iocbq->sli4_xritag = NO_XRI; list_add_tail(&iocbq->list, &phba->lpfc_iocb_list); }
robutest/uclinux
C++
GPL-2.0
60
/* Returns: (element-type GVolume) (transfer full): a #GList of #GVolume objects. */
GList* g_volume_monitor_get_volumes(GVolumeMonitor *volume_monitor)
/* Returns: (element-type GVolume) (transfer full): a #GList of #GVolume objects. */ GList* g_volume_monitor_get_volumes(GVolumeMonitor *volume_monitor)
{ GVolumeMonitorClass *class; g_return_val_if_fail (G_IS_VOLUME_MONITOR (volume_monitor), NULL); class = G_VOLUME_MONITOR_GET_CLASS (volume_monitor); return class->get_volumes (volume_monitor); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* get TLI flag or state in TLI_INTF register or TLI_STAT register */
FlagStatus tli_flag_get(uint32_t flag)
/* get TLI flag or state in TLI_INTF register or TLI_STAT register */ FlagStatus tli_flag_get(uint32_t flag)
{ uint32_t stat; if(flag >> 31U) { stat = TLI_INTF; } else { stat = TLI_STAT; } if(flag & stat) { return SET; } else { return RESET; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* 8-bit packed samples => RGBA w/ unassociated alpha (known to have Map == NULL) */
DECLAREContigPutFunc(putRGBUAcontig8bittile)
/* 8-bit packed samples => RGBA w/ unassociated alpha (known to have Map == NULL) */ DECLAREContigPutFunc(putRGBUAcontig8bittile)
{ int samplesperpixel = img->samplesperpixel; (void) y; fromskew *= samplesperpixel; for( ; h > 0; --h) { uint32 r, g, b, a; uint8* m; for (x = w; x > 0; --x) { a = pp[3]; m = img->UaToAa+((size_t) a<<8); r = m[pp[0]]; g = m[pp[1]]; b = m[pp[2]]; *cp++ = PACK4(r,g,b,a); pp += samplesperpixel; } cp += toskew; pp += fromskew; } }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Get alarm stati: Possible values: 0 = no alarm 1 = alarm */
static ssize_t get_alarm(struct device *dev, struct device_attribute *devattr, char *buf)
/* Get alarm stati: Possible values: 0 = no alarm 1 = alarm */ static ssize_t get_alarm(struct device *dev, struct device_attribute *devattr, char *buf)
{ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct max6650_data *data = max6650_update_device(dev); struct i2c_client *client = to_i2c_client(dev); int alarm = 0; if (data->alarm & attr->index) { mutex_lock(&data->update_lock); alarm = 1; data->alarm &= ~attr->index; data->alarm |= i2c_smbus_read_byte_data(client, MAX6650_REG_ALARM); mutex_unlock(&data->update_lock); } return sprintf(buf, "%d\n", alarm); }
robutest/uclinux
C++
GPL-2.0
60
/* Switch slow clock source selection to external 32k (Xtal or Bypass) oscillator. This function disables the PLLs. */
void supc_switch_sclk_to_32kxtal(Supc *p_supc, uint32_t ul_bypass)
/* Switch slow clock source selection to external 32k (Xtal or Bypass) oscillator. This function disables the PLLs. */ void supc_switch_sclk_to_32kxtal(Supc *p_supc, uint32_t ul_bypass)
{ if (ul_bypass == 1) { p_supc->SUPC_MR |= SUPC_MR_KEY_PASSWD | SUPC_MR_OSCBYPASS; } else { p_supc->SUPC_MR &= ~(SUPC_MR_KEY_PASSWD | SUPC_MR_OSCBYPASS); } p_supc->SUPC_CR |= SUPC_CR_KEY_PASSWD | SUPC_CR_XTALSEL; }
remotemcu/remcu-chip-sdks
C++
null
436
/* RTC MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc)
/* RTC MSP De-Initialization This function freeze the hardware resources used in this example. */ void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc)
{ if(hrtc->Instance==RTC) { __HAL_RCC_RTC_DISABLE(); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Init interrupts callback for the specified UART Port. */
void UARTIntCallbackInit(unsigned long ulBase, xtEventCallback xtUARTCallback)
/* Init interrupts callback for the specified UART Port. */ void UARTIntCallbackInit(unsigned long ulBase, xtEventCallback xtUARTCallback)
{ xASSERT(UARTBaseValid(ulBase)); g_pfnUARTHandlerCallbacks[0] = xtUARTCallback; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* This functions should be called when the device goes bus-off to tell the netif layer that no more packets can be sent or received. If enabled, a timer is started to trigger bus-off recovery. */
void can_bus_off(struct net_device *dev)
/* This functions should be called when the device goes bus-off to tell the netif layer that no more packets can be sent or received. If enabled, a timer is started to trigger bus-off recovery. */ void can_bus_off(struct net_device *dev)
{ struct can_priv *priv = netdev_priv(dev); dev_dbg(dev->dev.parent, "bus-off\n"); netif_carrier_off(dev); priv->can_stats.bus_off++; if (priv->restart_ms) mod_timer(&priv->restart_timer, jiffies + (priv->restart_ms * HZ) / 1000); }
robutest/uclinux
C++
GPL-2.0
60
/* ZigBee ZCL Relative Humidity Measurement cluster dissector for wireshark. */
static int dissect_zbee_zcl_relhum_meas(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_)
/* ZigBee ZCL Relative Humidity Measurement cluster dissector for wireshark. */ static int dissect_zbee_zcl_relhum_meas(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_)
{ return tvb_captured_length(tvb); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Returns: the element's data, or NULL if the position is off the end of the #GSList */
gpointer g_slist_nth_data(GSList *list, guint n)
/* Returns: the element's data, or NULL if the position is off the end of the #GSList */ gpointer g_slist_nth_data(GSList *list, guint n)
{ while (n-- > 0 && list) list = list->next; return list ? list->data : NULL; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Computes the CRC checksum for a data buffer. */
uint8_t AD717X_ComputeCRC8(uint8_t *pBuf, uint8_t bufSize)
/* Computes the CRC checksum for a data buffer. */ uint8_t AD717X_ComputeCRC8(uint8_t *pBuf, uint8_t bufSize)
{ uint8_t i = 0; uint8_t crc = 0; while(bufSize) { for(i = 0x80; i != 0; i >>= 1) { if(((crc & 0x80) != 0) != ((*pBuf & i) != 0)) { crc <<= 1; crc ^= AD717X_CRC8_POLYNOMIAL_REPRESENTATION; } else { crc <<= 1; } } pBuf++; bufSize--; } return crc; }
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* Enable or disable synchronous-start. When an even unit enables synchronous-start function, start the symmetric odd unit can start the even unit at the same time. */
void TMRA_SyncStartCmd(CM_TMRA_TypeDef *TMRAx, en_functional_state_t enNewState)
/* Enable or disable synchronous-start. When an even unit enables synchronous-start function, start the symmetric odd unit can start the even unit at the same time. */ void TMRA_SyncStartCmd(CM_TMRA_TypeDef *TMRAx, en_functional_state_t enNewState)
{ uint32_t u32Addr; DDL_ASSERT(IS_TMRA_SYNC_UNIT(TMRAx)); DDL_ASSERT(IS_FUNCTIONAL_STATE(enNewState)); u32Addr = (uint32_t)&TMRAx->BCSTRL; WRITE_REG32(PERIPH_BIT_BAND(u32Addr, TMRA_BCSTRL_SYNST_POS), enNewState); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Retunes the index of a suitable lookup table for a given delta */
static uint8_t* bgmc_lut_getp(uint8_t *lut, unsigned int *lut_status, unsigned int delta)
/* Retunes the index of a suitable lookup table for a given delta */ static uint8_t* bgmc_lut_getp(uint8_t *lut, unsigned int *lut_status, unsigned int delta)
{ unsigned int i = av_clip(delta, 0, LUT_BUFF - 1); lut += (i * LUT_SIZE) << 4; if (lut_status[i] != delta) bgmc_lut_fillp(lut, &lut_status[i], delta); return lut; }
DC-SWAT/DreamShell
C++
null
404
/* Failure to call this function after a reset may lead to permanent data loss if the EEPROM is later written! */
unsigned long EEPROMInit(void)
/* Failure to call this function after a reset may lead to permanent data loss if the EEPROM is later written! */ unsigned long EEPROMInit(void)
{ unsigned long ulStatus; SysCtlDelay(2); EEPROMWaitForDone(); ulStatus = HWREG(EEPROM_EESUPP); if(ulStatus & (EEPROM_EESUPP_PRETRY | EEPROM_EESUPP_ERETRY)) { SysCtlPeripheralReset(SYSCTL_PERIPH_EEPROM0); SysCtlDelay(2); EEPROMWaitForDone(); ulStatus = HWREG(EEPROM_EESUPP); if(ulStatus & (EEPROM_EESUPP_PRETRY | EEPROM_EESUPP_ERETRY)) { return(EEPROM_INIT_ERROR); } else { return(EEPROM_INIT_RETRY); } } return(EEPROM_INIT_OK); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Dequeue the saved key from internal key queue. */
EFI_STATUS ConSplitterTextInExDequeueKey(IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private, OUT EFI_KEY_DATA *KeyData)
/* Dequeue the saved key from internal key queue. */ EFI_STATUS ConSplitterTextInExDequeueKey(IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private, OUT EFI_KEY_DATA *KeyData)
{ if (Private->CurrentNumberOfKeys == 0) { return EFI_NOT_FOUND; } CopyMem (KeyData, &Private->KeyQueue[0], sizeof (EFI_KEY_DATA)); Private->CurrentNumberOfKeys--; CopyMem ( &Private->KeyQueue[0], &Private->KeyQueue[1], Private->CurrentNumberOfKeys * sizeof (EFI_KEY_DATA) ); return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Convert a time in milliseconds to a combination of prescale and step_time for the execution engine programs. This function expects the given time in milliseconds to be in the allowed range the device can handle (0ms to 1000ms). */
static void lp5562_ms_to_prescale_and_step(struct led_data *data, uint32_t ms, uint8_t *prescale, uint8_t *step_time)
/* Convert a time in milliseconds to a combination of prescale and step_time for the execution engine programs. This function expects the given time in milliseconds to be in the allowed range the device can handle (0ms to 1000ms). */ static void lp5562_ms_to_prescale_and_step(struct led_data *data, uint32_t ms, uint8_t *prescale, uint8_t *step_time)
{ if (ms < 31) { *prescale = 0U; *step_time = ms << 1; return; } *prescale = 1U; *step_time = ms >> 4; return; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Set the specified data holding register value for DAC channel 1. */
void DAC_ConfigChannel1Data(DAC_ALIGN_T align, uint16_t data)
/* Set the specified data holding register value for DAC channel 1. */ void DAC_ConfigChannel1Data(DAC_ALIGN_T align, uint16_t data)
{ __IO uint32_t temp = 0; temp = (uint32_t)DAC_BASE; temp += 0x00000008 + align; *(__IO uint32_t *) temp = data; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Only the bytes up to the crc32_le field are considered for the CRC-32 calculation. */
static uint32_t ab_control_compute_crc(struct bootloader_control *abc)
/* Only the bytes up to the crc32_le field are considered for the CRC-32 calculation. */ static uint32_t ab_control_compute_crc(struct bootloader_control *abc)
{ return crc32(0, (void *)abc, offsetof(typeof(*abc), crc32_le)); }
4ms/stm32mp1-baremetal
C++
Other
137
/* Configures the specified ADC external trigger for injected channels conversion. */
void ADC_ConfigExternalTrigInjectedConv(ADC_T *adc, ADC_EXT_TRIG_INJEC_CONV_T extTrigInjecConv)
/* Configures the specified ADC external trigger for injected channels conversion. */ void ADC_ConfigExternalTrigInjectedConv(ADC_T *adc, ADC_EXT_TRIG_INJEC_CONV_T extTrigInjecConv)
{ adc->CTRL2_B.INJGEXTTRGSEL = extTrigInjecConv; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* DMA Channel Enable Interrupt on Transfer Half Complete. */
void dma_enable_half_transfer_interrupt(uint32_t dma, uint8_t channel)
/* DMA Channel Enable Interrupt on Transfer Half Complete. */ void dma_enable_half_transfer_interrupt(uint32_t dma, uint8_t channel)
{ DMA_CCR(dma, channel) |= DMA_CCR_HTIE; }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* Read the PHY management control register and check whether a PHY reset is blocked. If a reset is not blocked return 0, otherwise return E1000_BLK_PHY_RESET (12). */
s32 e1000e_check_reset_block_generic(struct e1000_hw *hw)
/* Read the PHY management control register and check whether a PHY reset is blocked. If a reset is not blocked return 0, otherwise return E1000_BLK_PHY_RESET (12). */ s32 e1000e_check_reset_block_generic(struct e1000_hw *hw)
{ u32 manc; manc = er32(MANC); return (manc & E1000_MANC_BLK_PHY_RST_ON_IDE) ? E1000_BLK_PHY_RESET : 0; }
robutest/uclinux
C++
GPL-2.0
60
/* This routine handles register-level access of the adapter but dispatches (calls) a protocol-specific callback routine to handle the protocol-specific details of the MPT request completion. */
static irqreturn_t mpt_interrupt(int irq, void *bus_id)
/* This routine handles register-level access of the adapter but dispatches (calls) a protocol-specific callback routine to handle the protocol-specific details of the MPT request completion. */ static irqreturn_t mpt_interrupt(int irq, void *bus_id)
{ MPT_ADAPTER *ioc = bus_id; u32 pa = CHIPREG_READ32_dmasync(&ioc->chip->ReplyFifo); if (pa == 0xFFFFFFFF) return IRQ_NONE; do { if (pa & MPI_ADDRESS_REPLY_A_BIT) mpt_reply(ioc, pa); else mpt_turbo_reply(ioc, pa); pa = CHIPREG_READ32_dmasync(&ioc->chip->ReplyFifo); } while (pa != 0xFFFFFFFF); return IRQ_HANDLED; }
robutest/uclinux
C++
GPL-2.0
60
/* Fix a string to only have the environment variable name, removing starting at the first space of whatever is quoted and removing the leading and trailing %. */
CHAR16* FixVarName(IN CHAR16 *FileName)
/* Fix a string to only have the environment variable name, removing starting at the first space of whatever is quoted and removing the leading and trailing %. */ CHAR16* FixVarName(IN CHAR16 *FileName)
{ CHAR16 *Copy; CHAR16 *TempLocation; Copy = FileName; if (FileName[0] == L'%') { Copy = FileName+1; if ((TempLocation = StrStr (Copy, L"%")) != NULL) { TempLocation[0] = CHAR_NULL; } } return (FixFileName (Copy)); }
tianocore/edk2
C++
Other
4,240
/* netapp_dhcp is used to configure the network interface, static or dynamic (DHCP). netapp_dhcp */
INT32 netapp_dhcp(UINT32 *aucIP, UINT32 *aucSubnetMask, UINT32 *aucDefaultGateway, UINT32 *aucDNSServer)
/* netapp_dhcp is used to configure the network interface, static or dynamic (DHCP). netapp_dhcp */ INT32 netapp_dhcp(UINT32 *aucIP, UINT32 *aucSubnetMask, UINT32 *aucDefaultGateway, UINT32 *aucDNSServer)
{ INT8 scRet; UINT8 *ptr; UINT8 *args; scRet = EFAIL; ptr = tSLInformation.pucTxCommandBuffer; args = (ptr + HEADERS_SIZE_CMD); ARRAY_TO_STREAM(args,aucIP,4); ARRAY_TO_STREAM(args,aucSubnetMask,4); ARRAY_TO_STREAM(args,aucDefaultGateway,4); args = UINT32_TO_STREAM(args, 0); ARRAY_TO_STREAM(args,aucDNSServer,4); hci_command_send(HCI_NETAPP_DHCP, ptr, NETAPP_DHCP_PARAMS_LEN); SimpleLinkWaitEvent(HCI_NETAPP_DHCP, &scRet); return(scRet); }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* The meaning of return value on success depends on the specific backend being used. */
int qemu_fclose(QEMUFile *f)
/* The meaning of return value on success depends on the specific backend being used. */ int qemu_fclose(QEMUFile *f)
{ int ret; qemu_fflush(f); ret = qemu_file_get_error(f); if (f->ops->close) { int ret2 = f->ops->close(f->opaque); if (ret >= 0) { ret = ret2; } } if (f->last_error) { ret = f->last_error; } g_free(f); trace_qemu_file_fclose(); return ret; }
ve3wwg/teensy3_qemu
C
Other
15
/* Doesn't take quota and stuff into account. IOW, in some cases it will give false negatives. The main reason why it's here is that we need a non-destructive way to look for easily umountable filesystems. */
int may_umount(struct vfsmount *mnt)
/* Doesn't take quota and stuff into account. IOW, in some cases it will give false negatives. The main reason why it's here is that we need a non-destructive way to look for easily umountable filesystems. */ int may_umount(struct vfsmount *mnt)
{ int ret = 1; down_read(&namespace_sem); spin_lock(&vfsmount_lock); if (propagate_mount_busy(mnt, 2)) ret = 0; spin_unlock(&vfsmount_lock); up_read(&namespace_sem); return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* Get the number of ticks (in CONFIG_SYS_HZ resolution) */
unsigned long long get_ticks(void)
/* Get the number of ticks (in CONFIG_SYS_HZ resolution) */ unsigned long long get_ticks(void)
{ unsigned long long sys_ticks; read_timer(); sys_ticks = timer.ticks * CONFIG_SYS_HZ; do_div(sys_ticks, TIMER_FREQ); return sys_ticks; }
4ms/stm32mp1-baremetal
C++
Other
137
/* delay < 0 : invalidate cache (fast : entries will be deleted later) delay >= 0 : invalidate & flush cache (can be long) */
void rt_cache_flush(struct net *net, int delay)
/* delay < 0 : invalidate cache (fast : entries will be deleted later) delay >= 0 : invalidate & flush cache (can be long) */ void rt_cache_flush(struct net *net, int delay)
{ rt_cache_invalidate(net); if (delay >= 0) rt_do_flush(!in_softirq()); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* param base SAI base pointer. param handle SAI eDMA handle pointer. */
void SAI_TransferTerminateReceive(I2S_Type *base, sai_handle_t *handle)
/* param base SAI base pointer. param handle SAI eDMA handle pointer. */ void SAI_TransferTerminateReceive(I2S_Type *base, sai_handle_t *handle)
{ assert(handle != NULL); SAI_TransferAbortReceive(base, handle); (void)memset(handle->saiQueue, 0, sizeof(handle->saiQueue)); (void)memset(handle->transferSize, 0, sizeof(handle->transferSize)); handle->queueUser = 0U; handle->queueDriver = 0U; }
eclipse-threadx/getting-started
C++
Other
310
/* This function will set callback to be called when the network interface device address has been changed. */
void netdev_set_addr_callback(struct netdev *netdev, netdev_callback_fn addr_callback)
/* This function will set callback to be called when the network interface device address has been changed. */ void netdev_set_addr_callback(struct netdev *netdev, netdev_callback_fn addr_callback)
{ ASSERT(netdev); ASSERT(addr_callback); netdev->addr_callback = addr_callback; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Check if allowed config changed and something needs to be disabled. */
static void check_disable()
/* Check if allowed config changed and something needs to be disabled. */ static void check_disable()
{ metric_handler_syslog_configure("", 0); syslog_configure("", 0); } else if (metrics_allow == MetricsAllow::One) { if (strcmp(metric_handler_syslog_get_host(), config_store().metrics_host.get_c_str()) != 0 || metric_handler_syslog_get_port() != config_store().metrics_port.get()) { metric_handler_syslog_configure("", 0); } if (strcmp(syslog_get_host(), config_store().metrics_host.get_c_str()) != 0 || syslog_get_port() != config_store().syslog_port.get()) { syslog_configure("", 0); } } }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Returns zero if sucecessful, or a negative error code on failure */
int snd_unregister_device(int type, struct snd_card *card, int dev)
/* Returns zero if sucecessful, or a negative error code on failure */ int snd_unregister_device(int type, struct snd_card *card, int dev)
{ int minor; mutex_lock(&sound_mutex); minor = find_snd_minor(type, card, dev); if (minor < 0) { mutex_unlock(&sound_mutex); return -EINVAL; } device_destroy(sound_class, MKDEV(major, minor)); kfree(snd_minors[minor]); snd_minors[minor] = NULL; mutex_unlock(&sound_mutex); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* HASH Set Data Type. Sets up the specified data type: 32Bit, 16Bit, 8Bit, Bitstring. */
void hash_set_data_type(uint8_t datatype)
/* HASH Set Data Type. Sets up the specified data type: 32Bit, 16Bit, 8Bit, Bitstring. */ void hash_set_data_type(uint8_t datatype)
{ HASH_CR &= ~HASH_CR_DATATYPE; HASH_CR |= datatype; }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* clear the interface value to the connected device */
usbh_status usbh_clrdevfeature(usbh_host *uhost, uint8_t feature_selector, uint16_t windex)
/* clear the interface value to the connected device */ usbh_status usbh_clrdevfeature(usbh_host *uhost, uint8_t feature_selector, uint16_t windex)
{ usbh_status status = USBH_BUSY; usbh_control *usb_ctl = &uhost->control; if (CTL_IDLE == usb_ctl->ctl_state) { usb_ctl->setup.req = (usb_req) { .bmRequestType = USB_TRX_OUT | USB_RECPTYPE_DEV | USB_REQTYPE_STRD, .bRequest = USB_CLEAR_FEATURE, .wValue = feature_selector, .wIndex = windex, .wLength = 0U }; usbh_ctlstate_config (uhost, NULL, 0U); } status = usbh_ctl_handler (uhost); return status; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Given an inode and mask determine if dnotify would be interested in sending userspace notification for that pair. */
static bool dnotify_should_send_event(struct fsnotify_group *group, struct inode *inode, __u32 mask)
/* Given an inode and mask determine if dnotify would be interested in sending userspace notification for that pair. */ static bool dnotify_should_send_event(struct fsnotify_group *group, struct inode *inode, __u32 mask)
{ struct fsnotify_mark_entry *entry; bool send; if (!S_ISDIR(inode->i_mode)) return false; spin_lock(&inode->i_lock); entry = fsnotify_find_mark_entry(group, inode); spin_unlock(&inode->i_lock); if (!entry) return false; mask = (mask & ~FS_EVENT_ON_CHILD); send = (mask & entry->mask); fsnotify_put_mark(entry); return send; }
robutest/uclinux
C++
GPL-2.0
60
/* Returns 0 when the timer has expired otherwise -EINTR */
int __sched schedule_hrtimeout(ktime_t *expires, const enum hrtimer_mode mode)
/* Returns 0 when the timer has expired otherwise -EINTR */ int __sched schedule_hrtimeout(ktime_t *expires, const enum hrtimer_mode mode)
{ return schedule_hrtimeout_range(expires, 0, mode); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* param base I2C peripheral base address param handle pointer to i2c_master_dma_handle_t structure param count Number of bytes transferred so far by the non-blocking transaction. */
status_t I2C_MasterTransferGetCountDMA(I2C_Type *base, i2c_master_dma_handle_t *handle, size_t *count)
/* param base I2C peripheral base address param handle pointer to i2c_master_dma_handle_t structure param count Number of bytes transferred so far by the non-blocking transaction. */ status_t I2C_MasterTransferGetCountDMA(I2C_Type *base, i2c_master_dma_handle_t *handle, size_t *count)
{ assert(handle != NULL); if (NULL == count) { return kStatus_InvalidArgument; } if (handle->state == (uint8_t)kIdleState) { *count = 0; return kStatus_NoTransferInProgress; } *count = handle->transferCount; return kStatus_Success; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Retrieve additional information about subsequent address ranges for modules with multiple address ranges. */
int pdc_system_map_find_addrs(struct pdc_system_map_addr_info *pdc_addr_info, long mod_index, long addr_index)
/* Retrieve additional information about subsequent address ranges for modules with multiple address ranges. */ int pdc_system_map_find_addrs(struct pdc_system_map_addr_info *pdc_addr_info, long mod_index, long addr_index)
{ int retval; unsigned long flags; spin_lock_irqsave(&pdc_lock, flags); retval = mem_pdc_call(PDC_SYSTEM_MAP, PDC_FIND_ADDRESS, __pa(pdc_result), mod_index, addr_index); convert_to_wide(pdc_result); memcpy(pdc_addr_info, pdc_result, sizeof(*pdc_addr_info)); spin_unlock_irqrestore(&pdc_lock, flags); pdc_addr_info->mod_addr = f_extend(pdc_addr_info->mod_addr); return retval; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Stalls the CPU for the number of microseconds specified by MicroSeconds. */
UINTN EFIAPI MicroSecondDelay(IN UINTN MicroSeconds)
/* Stalls the CPU for the number of microseconds specified by MicroSeconds. */ UINTN EFIAPI MicroSecondDelay(IN UINTN MicroSeconds)
{ InternalCpuDelay ( DivU64x32 ( MultU64x64 ( MicroSeconds, InternalGetPerformanceCounterFrequency () ), 1000000u ) ); return MicroSeconds; }
tianocore/edk2
C++
Other
4,240
/* Return x^(n * 2^k) modulo p(x). Requires that x2n_table has been initialized. */
z_crc_t x2nmodp(z_off64_t n, unsigned k)
/* Return x^(n * 2^k) modulo p(x). Requires that x2n_table has been initialized. */ z_crc_t x2nmodp(z_off64_t n, unsigned k)
{ z_crc_t p; p = (z_crc_t)1 << 31; while (n) { if (n & 1) p = multmodp(x2n_table[k & 31], p); n >>= 1; k++; } return p; }
pikasTech/PikaPython
C++
MIT License
1,403
/* This function writes the specified number of bytes to the file at the current file position. The current file position is advanced the actual number of bytes written, which is returned in BufferSize. Partial writes only occur when there has been a data error during the write attempt (such as "volume space full"). The file is automatically grown to hold the data if required. Direct writes to opened directories are not supported. */
EFI_STATUS EFIAPI ShellWriteFile(IN SHELL_FILE_HANDLE FileHandle, IN OUT UINTN *BufferSize, IN VOID *Buffer)
/* This function writes the specified number of bytes to the file at the current file position. The current file position is advanced the actual number of bytes written, which is returned in BufferSize. Partial writes only occur when there has been a data error during the write attempt (such as "volume space full"). The file is automatically grown to hold the data if required. Direct writes to opened directories are not supported. */ EFI_STATUS EFIAPI ShellWriteFile(IN SHELL_FILE_HANDLE FileHandle, IN OUT UINTN *BufferSize, IN VOID *Buffer)
{ return (FileFunctionMap.WriteFile (FileHandle, BufferSize, Buffer)); }
tianocore/edk2
C++
Other
4,240
/* Extract the port number form the given identifier. The port number is extracted by looking at bits 10, 11, 12, 13 of the base register addresses. */
static int _port_num(gpio_t pin)
/* Extract the port number form the given identifier. The port number is extracted by looking at bits 10, 11, 12, 13 of the base register addresses. */ static int _port_num(gpio_t pin)
{ return ((pin >> 10) & 0x0f); }
labapart/polymcu
C++
null
201
/* Invoked when Root Port's AER service is loaded. */
static struct aer_rpc* aer_alloc_rpc(struct pcie_device *dev)
/* Invoked when Root Port's AER service is loaded. */ static struct aer_rpc* aer_alloc_rpc(struct pcie_device *dev)
{ struct aer_rpc *rpc; rpc = kzalloc(sizeof(struct aer_rpc), GFP_KERNEL); if (!rpc) return NULL; spin_lock_init(&rpc->e_lock); rpc->rpd = dev; INIT_WORK(&rpc->dpc_handler, aer_isr); rpc->prod_idx = rpc->cons_idx = 0; mutex_init(&rpc->rpc_mutex); init_waitqueue_head(&rpc->wait_release); set_service_data(dev, rpc); return rpc; }
robutest/uclinux
C++
GPL-2.0
60