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
/* Find the best available 7.1 format divisor given a parent clock rate and required child clock rate. This function assumes that a second-stage divisor is available which can divide by powers of 2 from 1 to 256. */
static int find_best_divider(unsigned divider_bits, unsigned long parent_rate, unsigned long rate, int *extra_div)
/* Find the best available 7.1 format divisor given a parent clock rate and required child clock rate. This function assumes that a second-stage divisor is available which can divide by powers of 2 from 1 to 256. */ static int find_best_divider(unsigned divider_bits, unsigned long parent_rate, unsigned long rate, int *extra_div)
{ int shift; int best_divider = -1; int best_error = rate; for (shift = 0; shift <= 8 && best_error > 0; shift++) { unsigned divided_parent = parent_rate >> shift; int divider = clk_get_divider(divider_bits, divided_parent, rate); unsigned effective_rate = get_rate_from_divider(divided_parent, divider); int error = rate - effective_rate; if (divider != -1 && error < best_error) { best_error = error; *extra_div = 1 << shift; best_divider = divider; } } return best_divider; }
4ms/stm32mp1-baremetal
C++
Other
137
/* When a cpu is hot-plugged, do a check and initiate cache kobject if necessary */
static int __cpuinit cache_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
/* When a cpu is hot-plugged, do a check and initiate cache kobject if necessary */ static int __cpuinit cache_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
{ unsigned int cpu = (unsigned long)hcpu; struct sys_device *sys_dev; sys_dev = get_cpu_sysdev(cpu); switch (action) { case CPU_ONLINE: case CPU_ONLINE_FROZEN: cache_add_dev(sys_dev); break; case CPU_DEAD: case CPU_DEAD_FROZEN: cache_remove_dev(sys_dev); break; } return NOTIFY_OK; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Event handler for the library USB Control Request reception event. */
void EVENT_USB_Device_ControlRequest(void)
/* Event handler for the library USB Control Request reception event. */ void EVENT_USB_Device_ControlRequest(void)
{ HID_Device_ProcessControlRequest(&Keyboard_HID_Interface); }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* De-initialises an TIMER interface, Turns off an TIMER hardware interface */
int32_t hal_timer_finalize(timer_dev_t *tim)
/* De-initialises an TIMER interface, Turns off an TIMER hardware interface */ int32_t hal_timer_finalize(timer_dev_t *tim)
{ int32_t ret = 0; ENTER_FUNCTION(); _hal_timer_stop(); LEAVE_FUNCTION(); return ret; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Enable The Timer counter as a timer capture. */
void TimerCaptureEnable(unsigned long ulBase)
/* Enable The Timer counter as a timer capture. */ void TimerCaptureEnable(unsigned long ulBase)
{ xASSERT((ulBase == TIMER3_BASE) || (ulBase == TIMER2_BASE) || (ulBase == TIMER1_BASE) || (ulBase == TIMER0_BASE)); xHWREG(ulBase + TIMER_O_TEXCON) |= TIMER_TEXCON_TEXEN; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Called very early, MMU is off, device-tree isn't unflattened */
static int __init maple_probe(void)
/* Called very early, MMU is off, device-tree isn't unflattened */ static int __init maple_probe(void)
{ unsigned long root = of_get_flat_dt_root(); if (!of_flat_dt_is_compatible(root, "Momentum,Maple") && !of_flat_dt_is_compatible(root, "Momentum,Apache")) return 0; alloc_dart_table(); hpte_init_native(); return 1; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Reads data from an USART peripheral, filling the provided buffer until it becomes full. This function returns immediately with 1 if the buffer has been queued for transmission; otherwise 0. */
unsigned char USART_ReadBuffer(AT91S_USART *usart, void *buffer, unsigned int size)
/* Reads data from an USART peripheral, filling the provided buffer until it becomes full. This function returns immediately with 1 if the buffer has been queued for transmission; otherwise 0. */ unsigned char USART_ReadBuffer(AT91S_USART *usart, void *buffer, unsigned int size)
{ if ((usart->US_RCR == 0) && (usart->US_RNCR == 0)) { usart->US_RPR = (unsigned int) buffer; usart->US_RCR = size; usart->US_PTCR = AT91C_PDC_RXTEN; return 1; } else if (usart->US_RNCR == 0) { usart->US_RNPR = (unsigned int) buffer; usart->US_RNCR = size; return 1; } else { return 0; } }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Check if the supplied point is at infinity. */
BOOLEAN EFIAPI EcPointIsAtInfinity(IN CONST VOID *EcGroup, IN CONST VOID *EcPoint)
/* Check if the supplied point is at infinity. */ BOOLEAN EFIAPI EcPointIsAtInfinity(IN CONST VOID *EcGroup, IN CONST VOID *EcPoint)
{ CALL_CRYPTO_SERVICE (EcPointIsAtInfinity, (EcGroup, EcPoint), FALSE); }
tianocore/edk2
C++
Other
4,240
/* Writes the current value of MM6. This function is only available on IA32 and x64. */
VOID EFIAPI AsmWriteMm6(IN UINT64 Value)
/* Writes the current value of MM6. This function is only available on IA32 and x64. */ VOID EFIAPI AsmWriteMm6(IN UINT64 Value)
{ _asm { movq mm6, qword ptr [Value] emms } }
tianocore/edk2
C++
Other
4,240
/* Please refer to the official documentation for function purpose and expected parameters. */
int ph7_value_is_null(ph7_value *pVal)
/* Please refer to the official documentation for function purpose and expected parameters. */ int ph7_value_is_null(ph7_value *pVal)
{ return (pVal->iFlags & MEMOBJ_STRING) ? TRUE : FALSE; }
pikasTech/PikaPython
C++
MIT License
1,403
/* As above, but return -1 for no deadline, and do not cap to 2^32 as we know the result is always positive. */
int64_t timerlist_deadline_ns(QEMUTimerList *timer_list)
/* As above, but return -1 for no deadline, and do not cap to 2^32 as we know the result is always positive. */ int64_t timerlist_deadline_ns(QEMUTimerList *timer_list)
{ int64_t delta; int64_t expire_time; if (!timer_list->clock->enabled) { return -1; } qemu_mutex_lock(&timer_list->active_timers_lock); if (!timer_list->active_timers) { qemu_mutex_unlock(&timer_list->active_timers_lock); return -1; } expire_time = timer_list->active_timers->expire_time; qemu_mutex_unlock(&timer_list->active_timers_lock); delta = expire_time - qemu_clock_get_ns(timer_list->clock->type); if (delta <= 0) { return 0; } return delta; }
ve3wwg/teensy3_qemu
C
Other
15
/* USART Enable Half-duplex. @This bit field can only be written when the USART is disabled. */
void usart_enable_halfduplex(uint32_t usart)
/* USART Enable Half-duplex. @This bit field can only be written when the USART is disabled. */ void usart_enable_halfduplex(uint32_t usart)
{ USART_CR3(usart) |= USART_CR3_HDSEL; }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* Check if Received data is ready. Check if data has been received and loaded in UART_RHR. */
uint32_t uart_is_rx_ready(Uart *p_uart)
/* Check if Received data is ready. Check if data has been received and loaded in UART_RHR. */ uint32_t uart_is_rx_ready(Uart *p_uart)
{ return (p_uart->UART_SR & UART_SR_RXRDY) > 0; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Internal function to read the next keystroke from the keyboard buffer. */
EFI_STATUS USBKeyboardReadKeyStrokeWorker(IN OUT USB_KB_DEV *UsbKeyboardDevice, OUT EFI_KEY_DATA *KeyData)
/* Internal function to read the next keystroke from the keyboard buffer. */ EFI_STATUS USBKeyboardReadKeyStrokeWorker(IN OUT USB_KB_DEV *UsbKeyboardDevice, OUT EFI_KEY_DATA *KeyData)
{ if (KeyData == NULL) { return EFI_INVALID_PARAMETER; } if (IsQueueEmpty (&UsbKeyboardDevice->EfiKeyQueue)) { ZeroMem (&KeyData->Key, sizeof (KeyData->Key)); InitializeKeyState (UsbKeyboardDevice, &KeyData->KeyState); return EFI_NOT_READY; } Dequeue (&UsbKeyboardDevice->EfiKeyQueue, KeyData, sizeof (*KeyData)); return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Gets interrupt status for the specified PWM generator block. */
unsigned long PWMGenIntStatus(unsigned long ulBase, unsigned long ulGen, tBoolean bMasked)
/* Gets interrupt status for the specified PWM generator block. */ unsigned long PWMGenIntStatus(unsigned long ulBase, unsigned long ulGen, tBoolean bMasked)
{ ASSERT((ulBase == PWM0_BASE) || (ulBase == PWM1_BASE)); ASSERT(PWMGenValid(ulGen)); ulGen = PWM_GEN_BADDR(ulBase, ulGen); if(bMasked == true) { return(HWREG(ulGen + PWM_O_X_ISC)); } else { return(HWREG(ulGen + PWM_O_X_RIS)); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* vpfe_unregister_ccdc_device. CCDC module calls this to unregister with vpfe capture */
void vpfe_unregister_ccdc_device(struct ccdc_hw_device *dev)
/* vpfe_unregister_ccdc_device. CCDC module calls this to unregister with vpfe capture */ void vpfe_unregister_ccdc_device(struct ccdc_hw_device *dev)
{ if (NULL == dev) { printk(KERN_ERR "invalid ccdc device ptr\n"); return; } printk(KERN_NOTICE "vpfe_unregister_ccdc_device, dev->name = %s\n", dev->name); if (strcmp(dev->name, ccdc_cfg->name)) { return; } mutex_lock(&ccdc_lock); ccdc_dev = NULL; mutex_unlock(&ccdc_lock); return; }
robutest/uclinux
C++
GPL-2.0
60
/* When HBQ is enabled, buffers are searched based on tags. This function allocates a tag for buffer posted using CMD_QUE_XRI64_CX iocb. The tag is bit wise or-ed with QUE_BUFTAG_BIT to make sure that the tag does not conflict with tags of buffer posted for unsolicited events. The function returns the allocated tag. The function is called with no locks held. */
uint32_t lpfc_sli_get_buffer_tag(struct lpfc_hba *phba)
/* When HBQ is enabled, buffers are searched based on tags. This function allocates a tag for buffer posted using CMD_QUE_XRI64_CX iocb. The tag is bit wise or-ed with QUE_BUFTAG_BIT to make sure that the tag does not conflict with tags of buffer posted for unsolicited events. The function returns the allocated tag. The function is called with no locks held. */ uint32_t lpfc_sli_get_buffer_tag(struct lpfc_hba *phba)
{ spin_lock_irq(&phba->hbalock); phba->buffer_tag_count++; phba->buffer_tag_count |= QUE_BUFTAG_BIT; spin_unlock_irq(&phba->hbalock); return phba->buffer_tag_count; }
robutest/uclinux
C++
GPL-2.0
60
/* ic4_startup_local - Start up the serial port - returns >= 0 if no errors @the_port: Port to operate on */
static int ic4_startup_local(struct uart_port *the_port)
/* ic4_startup_local - Start up the serial port - returns >= 0 if no errors @the_port: Port to operate on */ static int ic4_startup_local(struct uart_port *the_port)
{ set_notification(port, the_port->ignore_status_mask, 1); } }
robutest/uclinux
C++
GPL-2.0
60
/* Attribute write call back for the Value V3 attribute. */
static ssize_t write_value_v3(struct bt_conn *conn, const struct bt_gatt_attr *attr, const void *buf, uint16_t len, uint16_t offset, uint8_t flags)
/* Attribute write call back for the Value V3 attribute. */ static ssize_t write_value_v3(struct bt_conn *conn, const struct bt_gatt_attr *attr, const void *buf, uint16_t len, uint16_t offset, uint8_t flags)
{ uint8_t *value = attr->user_data; if (offset >= sizeof(value_v3_value)) return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); if (offset + len > sizeof(value_v3_value)) return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); memcpy(value + offset, buf, len); return len; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Time period register for step detection on delta time (r/w).. */
int32_t lsm6dsl_pedo_steps_period_set(stmdev_ctx_t *ctx, uint8_t *buff)
/* Time period register for step detection on delta time (r/w).. */ int32_t lsm6dsl_pedo_steps_period_set(stmdev_ctx_t *ctx, uint8_t *buff)
{ int32_t ret; ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); if(ret == 0){ ret = lsm6dsl_write_reg(ctx, LSM6DSL_STEP_COUNT_DELTA, buff, 1); if(ret == 0){ ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK); } } return ret; }
eclipse-threadx/getting-started
C++
Other
310
/* OLED_contrast() See "oled.h" for details of how to use this function. */
void OLED_contrast(uint8_t color_contrast)
/* OLED_contrast() See "oled.h" for details of how to use this function. */ void OLED_contrast(uint8_t color_contrast)
{ uint8_t oled_contrast[] = { OLED_COMMAND_CODE, CMD_CONTRAST, OLED_COMMAND_CODE, CONTRAST_DEFAULT, }; oled_contrast[3] = color_contrast; MSS_I2C_write( g_p_oled_i2c, OLED_SLAVE_ADDRESS, oled_contrast, sizeof(oled_contrast), MSS_I2C_RELEASE_BUS ); MSS_I2C_wait_complete( g_p_oled_i2c ); }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Form the 64 bit 8390 multicast table from the linked list of addresses associated with this dev structure. */
static void make_mc_bits(u8 *bits, struct net_device *dev)
/* Form the 64 bit 8390 multicast table from the linked list of addresses associated with this dev structure. */ static void make_mc_bits(u8 *bits, struct net_device *dev)
{ struct dev_mc_list *dmi; for (dmi=dev->mc_list; dmi; dmi=dmi->next) { u32 crc; if (dmi->dmi_addrlen != ETH_ALEN) { printk(KERN_INFO "%s: invalid multicast address length given.\n", dev->name); continue; } crc = ether_crc(ETH_ALEN, dmi->dmi_addr); bits[crc>>29] |= (1<<((crc>>26)&7)); } }
robutest/uclinux
C++
GPL-2.0
60
/* Set the specified data holding register value for dual channel DAC. */
void DAC_SetDualChannelData(uint32_t DAC_Align, uint16_t Data2, uint16_t Data1)
/* Set the specified data holding register value for dual channel DAC. */ void DAC_SetDualChannelData(uint32_t DAC_Align, uint16_t Data2, uint16_t Data1)
{ uint32_t data = 0, tmp = 0; assert_param(IS_DAC_ALIGN(DAC_Align)); assert_param(IS_DAC_DATA(Data1)); assert_param(IS_DAC_DATA(Data2)); if (DAC_Align == DAC_Align_8b_R) { data = ((uint32_t)Data2 << 8) | Data1; } else { data = ((uint32_t)Data2 << 16) | Data1; } tmp = (uint32_t)DAC_BASE; tmp += DHR12RD_OFFSET + DAC_Align; *(__IO uint32_t *)tmp = data; }
gcallipo/RadioDSP-Stm32f103
C++
Common Creative - Attribution 3.0
51
/* Enable the MII link status autopoll feature on the Velocity hardware. Wait for it to enable. */
static void enable_mii_autopoll(struct mac_regs __iomem *regs)
/* Enable the MII link status autopoll feature on the Velocity hardware. Wait for it to enable. */ static void enable_mii_autopoll(struct mac_regs __iomem *regs)
{ int ii; writeb(0, &(regs->MIICR)); writeb(MIIADR_SWMPL, &regs->MIIADR); for (ii = 0; ii < W_MAX_TIMEOUT; ii++) { udelay(1); if (BYTE_REG_BITS_IS_ON(MIISR_MIDLE, &regs->MIISR)) break; } writeb(MIICR_MAUTO, &regs->MIICR); for (ii = 0; ii < W_MAX_TIMEOUT; ii++) { udelay(1); if (!BYTE_REG_BITS_IS_ON(MIISR_MIDLE, &regs->MIISR)) break; } }
robutest/uclinux
C++
GPL-2.0
60
/* Convert text to the binary representation of a device node. */
EFI_DEVICE_PATH_PROTOCOL* EFIAPI ConvertTextToDeviceNode(IN CONST CHAR16 *TextDeviceNode)
/* Convert text to the binary representation of a device node. */ EFI_DEVICE_PATH_PROTOCOL* EFIAPI ConvertTextToDeviceNode(IN CONST CHAR16 *TextDeviceNode)
{ if (mDevicePathLibDevicePathFromText == NULL) { mDevicePathLibDevicePathFromText = UefiDevicePathLibLocateProtocol (&gEfiDevicePathFromTextProtocolGuid); } if (mDevicePathLibDevicePathFromText != NULL) { return mDevicePathLibDevicePathFromText->ConvertTextToDeviceNode (TextDeviceNode); } return UefiDevicePathLibConvertTextToDeviceNode (TextDeviceNode); }
tianocore/edk2
C++
Other
4,240
/* Description: Set up a bio_set to be used with @bio_alloc_bioset. Allows the caller to ask for a number of bytes to be allocated in front of the bio. Front pad allocation is useful for embedding the bio inside another structure, to avoid allocating extra data to go with the bio. Note that the bio must be embedded at the END of that structure always, or things will break badly. */
struct bio_set* bioset_create(unsigned int pool_size, unsigned int front_pad)
/* Description: Set up a bio_set to be used with @bio_alloc_bioset. Allows the caller to ask for a number of bytes to be allocated in front of the bio. Front pad allocation is useful for embedding the bio inside another structure, to avoid allocating extra data to go with the bio. Note that the bio must be embedded at the END of that structure always, or things will break badly. */ struct bio_set* bioset_create(unsigned int pool_size, unsigned int front_pad)
{ unsigned int back_pad = BIO_INLINE_VECS * sizeof(struct bio_vec); struct bio_set *bs; bs = kzalloc(sizeof(*bs), GFP_KERNEL); if (!bs) return NULL; bs->front_pad = front_pad; bs->bio_slab = bio_find_or_create_slab(front_pad + back_pad); if (!bs->bio_slab) { kfree(bs); return NULL; } bs->bio_pool = mempool_create_slab_pool(pool_size, bs->bio_slab); if (!bs->bio_pool) goto bad; if (bioset_integrity_create(bs, pool_size)) goto bad; if (!biovec_create_pools(bs, pool_size)) return bs; bad: bioset_free(bs); return NULL; }
robutest/uclinux
C++
GPL-2.0
60
/* Must be called after omap2_clk_init(). Resolves the struct clk names to struct clk pointers for each registered omap_hwmod. Also calls _setup() on each hwmod. Returns 0. */
int omap_hwmod_late_init(void)
/* Must be called after omap2_clk_init(). Resolves the struct clk names to struct clk pointers for each registered omap_hwmod. Also calls _setup() on each hwmod. Returns 0. */ int omap_hwmod_late_init(void)
{ int r; r = omap_hwmod_for_each(_init_clocks); WARN(r, "omap_hwmod: omap_hwmod_late_init(): _init_clocks failed\n"); mpu_oh = omap_hwmod_lookup(MPU_INITIATOR_NAME); WARN(!mpu_oh, "omap_hwmod: could not find MPU initiator hwmod %s\n", MPU_INITIATOR_NAME); omap_hwmod_for_each(_setup); return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* When suspending, the compressor will back up to a convenient restart point (typically the start of the current MCU). next_output_byte & free_in_buffer indicate where the restart point will be if the current call returns FALSE. Data beyond this point will be regenerated after resumption, so do not write it out when emptying the buffer externally. */
empty_mem_output_buffer(j_compress_ptr cinfo)
/* When suspending, the compressor will back up to a convenient restart point (typically the start of the current MCU). next_output_byte & free_in_buffer indicate where the restart point will be if the current call returns FALSE. Data beyond this point will be regenerated after resumption, so do not write it out when emptying the buffer externally. */ empty_mem_output_buffer(j_compress_ptr cinfo)
{ size_t nextsize; JOCTET * nextbuffer; my_mem_dest_ptr dest = (my_mem_dest_ptr) cinfo->dest; nextsize = dest->bufsize * 2; nextbuffer = (JOCTET *) malloc(nextsize); if (nextbuffer == NULL) ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10); MEMCOPY(nextbuffer, dest->buffer, dest->bufsize); if (dest->newbuffer != NULL) free(dest->newbuffer); dest->newbuffer = nextbuffer; dest->pub.next_output_byte = nextbuffer + dest->bufsize; dest->pub.free_in_buffer = dest->bufsize; dest->buffer = nextbuffer; dest->bufsize = nextsize; return TRUE; }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* invaild or writeback cache and convert virtual address to physical address */
dma_addr_t linux_pci_map_single(void *handle, void *ptr, size_t size, int sd_idx, int direction)
/* invaild or writeback cache and convert virtual address to physical address */ dma_addr_t linux_pci_map_single(void *handle, void *ptr, size_t size, int sd_idx, int direction)
{ struct rt_rtmp_adapter *pAd; struct os_cookie *pObj; pAd = (struct rt_rtmp_adapter *)handle; pObj = (struct os_cookie *)pAd->OS_Cookie; if (sd_idx == 1) { struct rt_tx_blk *pTxBlk; pTxBlk = (struct rt_tx_blk *)ptr; return pci_map_single(pObj->pci_dev, pTxBlk->pSrcBufData, pTxBlk->SrcBufLen, direction); } else { return pci_map_single(pObj->pci_dev, ptr, size, direction); } }
robutest/uclinux
C++
GPL-2.0
60
/* This function clear fault brake interrupt of selected source. */
void PWM_ClearFaultBrakeIntFlag(PWM_T *pwm, uint32_t u32BrakeSource)
/* This function clear fault brake interrupt of selected source. */ void PWM_ClearFaultBrakeIntFlag(PWM_T *pwm, uint32_t u32BrakeSource)
{ (pwm)->INTSTS1 = (0x3fUL << u32BrakeSource); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Get the media mode stored in EEPROM or module options and load mii_status accordingly. The requested link state information is also returned. */
static u32 velocity_get_opt_media_mode(struct velocity_info *vptr)
/* Get the media mode stored in EEPROM or module options and load mii_status accordingly. The requested link state information is also returned. */ static u32 velocity_get_opt_media_mode(struct velocity_info *vptr)
{ u32 status = 0; switch (vptr->options.spd_dpx) { case SPD_DPX_AUTO: status = VELOCITY_AUTONEG_ENABLE; break; case SPD_DPX_100_FULL: status = VELOCITY_SPEED_100 | VELOCITY_DUPLEX_FULL; break; case SPD_DPX_10_FULL: status = VELOCITY_SPEED_10 | VELOCITY_DUPLEX_FULL; break; case SPD_DPX_100_HALF: status = VELOCITY_SPEED_100; break; case SPD_DPX_10_HALF: status = VELOCITY_SPEED_10; break; } vptr->mii_status = status; return status; }
robutest/uclinux
C++
GPL-2.0
60
/* This is our "base" multiqueue mode. RSS (Receive Side Scaling) will try to allocate one Rx queue per CPU, and if available, one Tx queue per CPU. */
static bool ixgbe_set_rss_queues(struct ixgbe_adapter *adapter)
/* This is our "base" multiqueue mode. RSS (Receive Side Scaling) will try to allocate one Rx queue per CPU, and if available, one Tx queue per CPU. */ static bool ixgbe_set_rss_queues(struct ixgbe_adapter *adapter)
{ bool ret = false; struct ixgbe_ring_feature *f = &adapter->ring_feature[RING_F_RSS]; if (adapter->flags & IXGBE_FLAG_RSS_ENABLED) { f->mask = 0xF; adapter->num_rx_queues = f->indices; adapter->num_tx_queues = f->indices; ret = true; } else { ret = false; } return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* This function reads the Minimum/Maximum measurement for one of the specified parameters. Use XADCPS_MAX_* and XADCPS_MIN_* constants defined in xadcps.h to specify the parameters (Temperature, VccInt, VccAux, VBram, VccPInt, VccPAux and VccPDro). */
u16 XAdcPs_GetMinMaxMeasurement(XAdcPs *InstancePtr, u8 MeasurementType)
/* This function reads the Minimum/Maximum measurement for one of the specified parameters. Use XADCPS_MAX_* and XADCPS_MIN_* constants defined in xadcps.h to specify the parameters (Temperature, VccInt, VccAux, VBram, VccPInt, VccPAux and VccPDro). */ u16 XAdcPs_GetMinMaxMeasurement(XAdcPs *InstancePtr, u8 MeasurementType)
{ u32 RegData; Xil_AssertNonvoid(InstancePtr != NULL); Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); Xil_AssertNonvoid((MeasurementType <= XADCPS_MAX_VCCPDRO) || ((MeasurementType >= XADCPS_MIN_VCCPINT) && (MeasurementType <= XADCPS_MIN_VCCPDRO))) RegData = XAdcPs_ReadInternalReg(InstancePtr, (XADCPS_MAX_TEMP_OFFSET + (u32)MeasurementType)); return (u16) RegData; }
ua1arn/hftrx
C++
null
69
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). */
UINT32 EFIAPI S3PciRead32(IN UINTN Address)
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). */ UINT32 EFIAPI S3PciRead32(IN UINTN Address)
{ return InternalSavePciWrite32ValueToBootScript (Address, PciRead32 (Address)); }
tianocore/edk2
C++
Other
4,240
/* Enable HW ECC : unused on most chips */
static void atmel_nand_hwctl(struct mtd_info *mtd, int mode)
/* Enable HW ECC : unused on most chips */ static void atmel_nand_hwctl(struct mtd_info *mtd, int mode)
{ if (cpu_is_at32ap7000()) { struct nand_chip *nand_chip = mtd->priv; struct atmel_nand_host *host = nand_chip->priv; ecc_writel(host->ecc, CR, ATMEL_ECC_RST); } }
robutest/uclinux
C++
GPL-2.0
60
/* Task to manage an enumerated USB MIDI device once connected, to display received note events from the host and send note changes in response to the board's joystick. */
void JoystickHost_Task(void)
/* Task to manage an enumerated USB MIDI device once connected, to display received note events from the host and send note changes in response to the board's joystick. */ void JoystickHost_Task(void)
{ if (USB_HostState != HOST_STATE_Configured) return; MIDI_EventPacket_t MIDIEvent; while (MIDI_Host_ReceiveEventPacket(&Keyboard_MIDI_Interface, &MIDIEvent)) { bool NoteOnEvent = (MIDIEvent.Event == MIDI_EVENT(0, MIDI_COMMAND_NOTE_ON)); bool NoteOffEvent = (MIDIEvent.Event == MIDI_EVENT(0, MIDI_COMMAND_NOTE_OFF)); if (NoteOnEvent || NoteOffEvent) { printf_P(PSTR("MIDI Note %s - Channel %d, Pitch %d, Velocity %d\r\n"), NoteOnEvent ? "On" : "Off", ((MIDIEvent.Data1 & 0x0F) + 1), MIDIEvent.Data2, MIDIEvent.Data3); } } CheckJoystickMovement(); }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Returns: (nullable) (transfer full): a #GWin32RegistryKey or NULL if can't be opened. Free with g_object_unref(). */
GWin32RegistryKey* g_win32_registry_key_new_w(const gunichar2 *path, GError **error)
/* Returns: (nullable) (transfer full): a #GWin32RegistryKey or NULL if can't be opened. Free with g_object_unref(). */ GWin32RegistryKey* g_win32_registry_key_new_w(const gunichar2 *path, GError **error)
{ GObject *result; g_return_val_if_fail (path != NULL, NULL); result = g_initable_new (G_TYPE_WIN32_REGISTRY_KEY, NULL, error, "path-utf16", g_wcsdup (path, -1), NULL); return result ? G_WIN32_REGISTRY_KEY (result) : NULL; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* For a single GDT entry which changes, we do the lazy thing: alter our GDT, then tell the Host to reload the entire thing. This operation is so rare that this naive implementation is reasonable. */
static void lguest_write_gdt_entry(struct desc_struct *dt, int entrynum, const void *desc, int type)
/* For a single GDT entry which changes, we do the lazy thing: alter our GDT, then tell the Host to reload the entire thing. This operation is so rare that this naive implementation is reasonable. */ static void lguest_write_gdt_entry(struct desc_struct *dt, int entrynum, const void *desc, int type)
{ native_write_gdt_entry(dt, entrynum, desc, type); kvm_hypercall3(LHCALL_LOAD_GDT_ENTRY, entrynum, dt[entrynum].a, dt[entrynum].b); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* If any reserved bits in Address are set, then ASSERT(). */
UINT8 EFIAPI PciSegmentWrite8(IN UINT64 Address, IN UINT8 Value)
/* If any reserved bits in Address are set, then ASSERT(). */ UINT8 EFIAPI PciSegmentWrite8(IN UINT64 Address, IN UINT8 Value)
{ ASSERT_INVALID_PCI_SEGMENT_ADDRESS (Address, 0); return PciWrite8 (PCI_SEGMENT_TO_PCI_ADDRESS (Address), Value); }
tianocore/edk2
C++
Other
4,240
/* Copy a page from "oldmem". For this page, there is no pte mapped in the current kernel. We stitch up a pte, similar to kmap_atomic. */
ssize_t copy_oldmem_page(unsigned long pfn, char *buf, size_t csize, unsigned long offset, int userbuf)
/* Copy a page from "oldmem". For this page, there is no pte mapped in the current kernel. We stitch up a pte, similar to kmap_atomic. */ ssize_t copy_oldmem_page(unsigned long pfn, char *buf, size_t csize, unsigned long offset, int userbuf)
{ void *vaddr; if (!csize) return 0; vaddr = ioremap(pfn << PAGE_SHIFT, PAGE_SIZE); if (userbuf) { if (copy_to_user(buf, (vaddr + offset), csize)) { iounmap(vaddr); return -EFAULT; } } else memcpy(buf, (vaddr + offset), csize); iounmap(vaddr); return csize; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This is called to update the er_extoff field in the indirection array when extents have been added or removed from one of the extent lists. erp_idx contains the irec index to begin updating at and ext_diff contains the number of extents that were added or removed. */
void xfs_iext_irec_update_extoffs(xfs_ifork_t *ifp, int erp_idx, int ext_diff)
/* This is called to update the er_extoff field in the indirection array when extents have been added or removed from one of the extent lists. erp_idx contains the irec index to begin updating at and ext_diff contains the number of extents that were added or removed. */ void xfs_iext_irec_update_extoffs(xfs_ifork_t *ifp, int erp_idx, int ext_diff)
{ int i; int nlists; ASSERT(ifp->if_flags & XFS_IFEXTIREC); nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ; for (i = erp_idx; i < nlists; i++) { ifp->if_u1.if_ext_irec[i].er_extoff += ext_diff; } }
robutest/uclinux
C++
GPL-2.0
60
/* Add an active request to the tracked requests list */
static void tracked_request_begin(BdrvTrackedRequest *req, BlockDriverState *bs, int64_t offset, unsigned int bytes, bool is_write)
/* Add an active request to the tracked requests list */ static void tracked_request_begin(BdrvTrackedRequest *req, BlockDriverState *bs, int64_t offset, unsigned int bytes, bool is_write)
{ *req = (BdrvTrackedRequest){ .bs = bs, .offset = offset, .bytes = bytes, .is_write = is_write, .co = qemu_coroutine_self(), .serialising = false, .overlap_offset = offset, .overlap_bytes = bytes, }; qemu_co_queue_init(&req->wait_queue); QLIST_INSERT_HEAD(&bs->tracked_requests, req, list); }
ve3wwg/teensy3_qemu
C
Other
15
/* Disable LIN Function mode on the specified UART. */
void UARTDisableLIN(unsigned long ulBase)
/* Disable LIN Function mode on the specified UART. */ void UARTDisableLIN(unsigned long ulBase)
{ xASSERT(UARTBaseValid(ulBase)); xHWREG(ulBase + UART_FUN_SEL) &= ~(UART_FUN_SEL_LIN_EN); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* initialize the parameters of SPI struct with the default values */
void spi_struct_para_init(spi_parameter_struct *spi_struct)
/* initialize the parameters of SPI struct with the default values */ void spi_struct_para_init(spi_parameter_struct *spi_struct)
{ spi_struct->device_mode = SPI_SLAVE; spi_struct->trans_mode = SPI_TRANSMODE_FULLDUPLEX; spi_struct->frame_size = SPI_FRAMESIZE_8BIT; spi_struct->nss = SPI_NSS_HARD; spi_struct->clock_polarity_phase = SPI_CK_PL_LOW_PH_1EDGE; spi_struct->prescale = SPI_PSC_2; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Once a protocol type and station address have been assigned to this ARP instance, all the following ARP functions will use this information. Attempting to change the protocol type or station address to a configured ARP instance will result in errors. */
EFI_STATUS EFIAPI ArpConfigure(IN EFI_ARP_PROTOCOL *This, IN EFI_ARP_CONFIG_DATA *ConfigData OPTIONAL)
/* Once a protocol type and station address have been assigned to this ARP instance, all the following ARP functions will use this information. Attempting to change the protocol type or station address to a configured ARP instance will result in errors. */ EFI_STATUS EFIAPI ArpConfigure(IN EFI_ARP_PROTOCOL *This, IN EFI_ARP_CONFIG_DATA *ConfigData OPTIONAL)
{ EFI_STATUS Status; ARP_INSTANCE_DATA *Instance; EFI_TPL OldTpl; if (This == NULL) { return EFI_INVALID_PARAMETER; } if ((ConfigData != NULL) && ((ConfigData->SwAddressLength == 0) || (ConfigData->StationAddress == NULL) || (ConfigData->SwAddressType <= 1500))) { return EFI_INVALID_PARAMETER; } Instance = ARP_INSTANCE_DATA_FROM_THIS (This); OldTpl = gBS->RaiseTPL (TPL_CALLBACK); Status = ArpConfigureInstance (Instance, ConfigData); gBS->RestoreTPL (OldTpl); return Status; }
tianocore/edk2
C++
Other
4,240
/* CONFIG_MMU architectures set up ZERO_PAGE in their paging_init() */
static int __init init_zero_pfn(void)
/* CONFIG_MMU architectures set up ZERO_PAGE in their paging_init() */ static int __init init_zero_pfn(void)
{ zero_pfn = page_to_pfn(ZERO_PAGE(0)); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Verify that the data in serial_struct is suitable for this device. */
static int qe_uart_verify_port(struct uart_port *port, struct serial_struct *ser)
/* Verify that the data in serial_struct is suitable for this device. */ static int qe_uart_verify_port(struct uart_port *port, struct serial_struct *ser)
{ if (ser->type != PORT_UNKNOWN && ser->type != PORT_CPM) return -EINVAL; if (ser->irq < 0 || ser->irq >= nr_irqs) return -EINVAL; if (ser->baud_base < 9600) return -EINVAL; return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* hw - Struct containing variables accessed by shared code hash_value - Multicast address hash value */
static void atl2_hash_set(struct atl2_hw *hw, u32 hash_value)
/* hw - Struct containing variables accessed by shared code hash_value - Multicast address hash value */ static void atl2_hash_set(struct atl2_hw *hw, u32 hash_value)
{ u32 hash_bit, hash_reg; u32 mta; hash_reg = (hash_value >> 31) & 0x1; hash_bit = (hash_value >> 26) & 0x1F; mta = ATL2_READ_REG_ARRAY(hw, REG_RX_HASH_TABLE, hash_reg); mta |= (1 << hash_bit); ATL2_WRITE_REG_ARRAY(hw, REG_RX_HASH_TABLE, hash_reg, mta); }
robutest/uclinux
C++
GPL-2.0
60
/* Configures the SysTick to generate an interrupt each 250 millisecond. */
void SysTick_Configuration(void)
/* Configures the SysTick to generate an interrupt each 250 millisecond. */ void SysTick_Configuration(void)
{ if (SysTick_Config((SystemCoreClock/8) / 4)) { while (1); } SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8); NVIC_SetPriority(SysTick_IRQn, 0x04); }
remotemcu/remcu-chip-sdks
C++
null
436
/* Configures a DAI for TDM operation. Both mask and slots are codec and DAI specific. */
int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width)
/* Configures a DAI for TDM operation. Both mask and slots are codec and DAI specific. */ int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width)
{ if (dai->ops && dai->ops->set_tdm_slot) return dai->ops->set_tdm_slot(dai, tx_mask, rx_mask, slots, slot_width); else return -EINVAL; }
robutest/uclinux
C++
GPL-2.0
60
/* Clear the slave select pins of the specified SPI port. The */
void SPISSClear(unsigned long ulBase, unsigned long ulSlaveSel)
/* Clear the slave select pins of the specified SPI port. The */ void SPISSClear(unsigned long ulBase, unsigned long ulSlaveSel)
{ xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)|| (ulBase == SPI2_BASE) || (ulBase == SPI3_BASE)); xASSERT((ulSlaveSel == SPI_SS_NONE) || (ulSlaveSel == SPI_SS0) || (ulSlaveSel == SPI_SS1) || (ulSlaveSel == SPI_SS0_SS1)); xHWREG(ulBase + SPI_SSR) &= ~ulSlaveSel; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Function: MX25_QREAD Arguments: flash_address, 32 bit flash memory address target_address, buffer address to store returned data byte_length, length of returned data in byte unit Description: The QREAD instruction enable quad throughput of Serial Flash in read mode. Return Message: FlashAddressInvalid, FlashQuadNotEnable, FlashOperationSuccess */
ReturnMsg MX25_QREAD(uint32_t flash_address, uint8_t *target_address, uint32_t byte_length)
/* Function: MX25_QREAD Arguments: flash_address, 32 bit flash memory address target_address, buffer address to store returned data byte_length, length of returned data in byte unit Description: The QREAD instruction enable quad throughput of Serial Flash in read mode. Return Message: FlashAddressInvalid, FlashQuadNotEnable, FlashOperationSuccess */ ReturnMsg MX25_QREAD(uint32_t flash_address, uint8_t *target_address, uint32_t byte_length)
{ uint32_t index=0; uint8_t addr_4byte_mode; uint8_t dc; if( flash_address > FlashSize ) return FlashAddressInvalid; if( IsFlashQIO() != TRUE ) return FlashQuadNotEnable; if( IsFlash4Byte() ) addr_4byte_mode = TRUE; else addr_4byte_mode = FALSE; dc = GetDummyCycle( DUMMY_CONF_QREAD ); CS_Low(); SendByte( FLASH_CMD_QREAD, SIO ); SendFlashAddr( flash_address, SIO, addr_4byte_mode ); InsertDummyCycle ( dc ); for( index=0; index < byte_length; index=index+1) { *(target_address + index) = GetByte( QIO ); } CS_High(); return FlashOperationSuccess; }
remotemcu/remcu-chip-sdks
C++
null
436
/* regAdress: Address that has to be read returns: register content or -1 on fail */
int16_t readByte(uint8_t regAddress)
/* regAdress: Address that has to be read returns: register content or -1 on fail */ int16_t readByte(uint8_t regAddress)
{ uint8_t data; int ret = sensor_i2c_read(&(dps310_ctx.i2c), regAddress, &data, 1, I2C_OP_RETRIES); if (ret == 0) return data; else return -1; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* This function returns the interrupt number for the hibernate module. */
static uint32_t _HibernateIntNumberGet(void)
/* This function returns the interrupt number for the hibernate module. */ static uint32_t _HibernateIntNumberGet(void)
{ uint32_t ui32Int; ui32Int = INT_HIBERNATE; return (ui32Int); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Finds the protocol entry for the requested protocol. */
PROTOCOL_ENTRY* SmmFindProtocolEntry(IN EFI_GUID *Protocol, IN BOOLEAN Create)
/* Finds the protocol entry for the requested protocol. */ PROTOCOL_ENTRY* SmmFindProtocolEntry(IN EFI_GUID *Protocol, IN BOOLEAN Create)
{ LIST_ENTRY *Link; PROTOCOL_ENTRY *Item; PROTOCOL_ENTRY *ProtEntry; ProtEntry = NULL; for (Link = mProtocolDatabase.ForwardLink; Link != &mProtocolDatabase; Link = Link->ForwardLink) { Item = CR (Link, PROTOCOL_ENTRY, AllEntries, PROTOCOL_ENTRY_SIGNATURE); if (CompareGuid (&Item->ProtocolID, Protocol)) { ProtEntry = Item; break; } } if ((ProtEntry == NULL) && Create) { ProtEntry = AllocatePool (sizeof (PROTOCOL_ENTRY)); if (ProtEntry != NULL) { ProtEntry->Signature = PROTOCOL_ENTRY_SIGNATURE; CopyGuid ((VOID *)&ProtEntry->ProtocolID, Protocol); InitializeListHead (&ProtEntry->Protocols); InitializeListHead (&ProtEntry->Notify); InsertTailList (&mProtocolDatabase, &ProtEntry->AllEntries); } } return ProtEntry; }
tianocore/edk2
C++
Other
4,240
/* Flush a range of addresses from all caches including L4. All addresses fully or partially contained within @flush_addr to @flush_addr + @bytes are flushed from all caches. */
void sn_flush_all_caches(long flush_addr, long bytes)
/* Flush a range of addresses from all caches including L4. All addresses fully or partially contained within @flush_addr to @flush_addr + @bytes are flushed from all caches. */ void sn_flush_all_caches(long flush_addr, long bytes)
{ unsigned long addr = flush_addr; if (is_shub1() && (addr & RGN_BITS) == RGN_BASE(RGN_UNCACHED)) addr = (addr - RGN_BASE(RGN_UNCACHED)) + RGN_BASE(RGN_KERNEL); flush_icache_range(addr, addr + bytes); flush_icache_range(addr, addr + bytes); mb(); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* APIs to access CFPA pages Generic read function, used by customer to read data stored in 'Customer In-field Page'. */
status_t FFR_GetCustomerInfieldData(flash_config_t *config, uint8_t *pData, uint32_t offset, uint32_t len)
/* APIs to access CFPA pages Generic read function, used by customer to read data stored in 'Customer In-field Page'. */ status_t FFR_GetCustomerInfieldData(flash_config_t *config, uint8_t *pData, uint32_t offset, uint32_t len)
{ if (get_rom_api_version() == 0u) { assert(VERSION0_FLASH_API_TREE); return VERSION0_FLASH_API_TREE->ffr_get_customer_infield_data(config, pData, offset, len); } else { assert(VERSION1_FLASH_API_TREE); return VERSION1_FLASH_API_TREE->ffr_get_customer_infield_data(config, pData, offset, len); } }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* Returns: (skip): TRUE if the call succeded, FALSE if @error is set. */
gboolean _g_freedesktop_dbus_call_get_connection_unix_process_id_finish(_GFreedesktopDBus *proxy, guint *out_pid, GAsyncResult *res, GError **error)
/* Returns: (skip): TRUE if the call succeded, FALSE if @error is set. */ gboolean _g_freedesktop_dbus_call_get_connection_unix_process_id_finish(_GFreedesktopDBus *proxy, guint *out_pid, GAsyncResult *res, GError **error)
{ GVariant *_ret; _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error); if (_ret == NULL) goto _out; g_variant_get (_ret, "(u)", out_pid); g_variant_unref (_ret); _out: return _ret != NULL; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* nes_cm_stop stop and dealloc all cm core instances */
int nes_cm_stop(void)
/* nes_cm_stop stop and dealloc all cm core instances */ int nes_cm_stop(void)
{ g_cm_core->api->destroy_cm_core(g_cm_core); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Configures system clock after wakeup from STOP mode. */
static void SystemClockConfig_STOP(void)
/* Configures system clock after wakeup from STOP mode. */ static void SystemClockConfig_STOP(void)
{ __HAL_RCC_HSE_CONFIG(RCC_HSE_ON); while(__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY) == RESET) {} __HAL_RCC_PLL_ENABLE(); while(__HAL_RCC_GET_FLAG(RCC_FLAG_PLLRDY) == RESET) {} MODIFY_REG(RCC->CFGR, RCC_CFGR_SW, RCC_SYSCLKSOURCE_PLLCLK); while (__HAL_RCC_GET_SYSCLK_SOURCE() != RCC_CFGR_SWS_PLL) {} }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* USB Device Set Address Function Parameters: adr: USB Device Address Return Value: None */
void USBD_SetAddress(uint32_t adr, uint32_t setup)
/* USB Device Set Address Function Parameters: adr: USB Device Address Return Value: None */ void USBD_SetAddress(uint32_t adr, uint32_t setup)
{ if (!setup) { USB0->ADDR = adr & 0x7F; } }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* Checks whether the specified UART flag is set or not. */
FlagStatus UART_GetFlagStatus(UART_TypeDef *uart, u16 flag)
/* Checks whether the specified UART flag is set or not. */ FlagStatus UART_GetFlagStatus(UART_TypeDef *uart, u16 flag)
{ return (uart->CSR & flag) ? SET : RESET; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function both reads and writes data. For write operations, include data to be written as argument. For read ops, use dummy data as arg. Returned data is read byte val. */
uint8_t w25q16bv_TransferByte(uint8_t data)
/* This function both reads and writes data. For write operations, include data to be written as argument. For read ops, use dummy data as arg. Returned data is read byte val. */ uint8_t w25q16bv_TransferByte(uint8_t data)
{ while ((SSP_SSP0SR & (SSP_SSP0SR_TNF_MASK | SSP_SSP0SR_BSY_MASK)) != SSP_SSP0SR_TNF_NOTFULL); SSP_SSP0DR = data; while ((SSP_SSP0SR & (SSP_SSP0SR_BSY_MASK | SSP_SSP0SR_RNE_MASK)) != SSP_SSP0SR_RNE_NOTEMPTY); return SSP_SSP0DR; }
microbuilder/LPC1343CodeBase
C++
Other
73
/* I2C MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_I2C_MspDeInit(I2C_HandleTypeDef *hi2c)
/* I2C MSP De-Initialization This function freeze the hardware resources used in this example. */ void HAL_I2C_MspDeInit(I2C_HandleTypeDef *hi2c)
{ if(hi2c->Instance==I2C1) { __HAL_RCC_I2C1_CLK_DISABLE(); HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6); HAL_GPIO_DeInit(GPIOB, GPIO_PIN_7); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Update EMU module with CMU oscillator selection/enable status. This function is mainly intended for internal use by the CMU module, but if the applications changes oscillator configurations without using the CMU API, this function can be used to keep the EMU module up-to-date. */
void EMU_UpdateOscConfig(void)
/* Update EMU module with CMU oscillator selection/enable status. This function is mainly intended for internal use by the CMU module, but if the applications changes oscillator configurations without using the CMU API, this function can be used to keep the EMU module up-to-date. */ void EMU_UpdateOscConfig(void)
{ cmuStatus = (uint16_t)(CMU->STATUS); }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Remove all the TDs for an Isochronous URB from the frame list */
static void uhci_unlink_isochronous_tds(struct uhci_hcd *uhci, struct urb *urb)
/* Remove all the TDs for an Isochronous URB from the frame list */ static void uhci_unlink_isochronous_tds(struct uhci_hcd *uhci, struct urb *urb)
{ struct urb_priv *urbp = (struct urb_priv *) urb->hcpriv; struct uhci_td *td; list_for_each_entry(td, &urbp->td_list, list) uhci_remove_td_from_frame_list(uhci, td); }
robutest/uclinux
C++
GPL-2.0
60
/* login pending - awaiting space in request queue */
static void bfa_lps_sm_loginwait(struct bfa_lps_s *lps, enum bfa_lps_event event)
/* login pending - awaiting space in request queue */ static void bfa_lps_sm_loginwait(struct bfa_lps_s *lps, enum bfa_lps_event event)
{ bfa_trc(lps->bfa, lps->lp_tag); bfa_trc(lps->bfa, event); switch (event) { case BFA_LPS_SM_RESUME: bfa_sm_set_state(lps, bfa_lps_sm_login); break; case BFA_LPS_SM_OFFLINE: bfa_sm_set_state(lps, bfa_lps_sm_init); bfa_reqq_wcancel(&lps->wqe); break; default: bfa_assert(0); } }
robutest/uclinux
C++
GPL-2.0
60
/* Enable the assertion of the core reset signal when a supply monitor detection occurs. */
void supc_enable_monitor_reset(Supc *p_supc)
/* Enable the assertion of the core reset signal when a supply monitor detection occurs. */ void supc_enable_monitor_reset(Supc *p_supc)
{ p_supc->SUPC_SMMR |= SUPC_SMMR_SMRSTEN; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Adds a record for dispatching specified arbitrary code into a specified boot script table. */
RETURN_STATUS EFIAPI S3BootScriptSaveDispatch(IN VOID *EntryPoint)
/* Adds a record for dispatching specified arbitrary code into a specified boot script table. */ RETURN_STATUS EFIAPI S3BootScriptSaveDispatch(IN VOID *EntryPoint)
{ UINT8 Length; UINT8 *Script; EFI_BOOT_SCRIPT_DISPATCH ScriptDispatch; if (!mS3BootScriptAcpiS3Enable) { return RETURN_SUCCESS; } Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_DISPATCH)); Script = S3BootScriptGetEntryAddAddress (Length); if (Script == NULL) { return RETURN_OUT_OF_RESOURCES; } ScriptDispatch.OpCode = EFI_BOOT_SCRIPT_DISPATCH_OPCODE; ScriptDispatch.Length = Length; ScriptDispatch.EntryPoint = (EFI_PHYSICAL_ADDRESS)(UINTN)EntryPoint; CopyMem ((VOID *)Script, (VOID *)&ScriptDispatch, sizeof (EFI_BOOT_SCRIPT_DISPATCH)); SyncBootScript (Script); return RETURN_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Read the specified number of 32-bit words from the serial flash. If @byte_oriented is set the read data is stored as a byte array (i.e., big-endian), otherwise as 32-bit words in the platform's natural endianess. */
int t3_read_flash(struct adapter *adapter, unsigned int addr, unsigned int nwords, u32 *data, int byte_oriented)
/* Read the specified number of 32-bit words from the serial flash. If @byte_oriented is set the read data is stored as a byte array (i.e., big-endian), otherwise as 32-bit words in the platform's natural endianess. */ int t3_read_flash(struct adapter *adapter, unsigned int addr, unsigned int nwords, u32 *data, int byte_oriented)
{ int ret; if (addr + nwords * sizeof(u32) > SF_SIZE || (addr & 3)) return -EINVAL; addr = swab32(addr) | SF_RD_DATA_FAST; if ((ret = sf1_write(adapter, 4, 1, addr)) != 0 || (ret = sf1_read(adapter, 1, 1, data)) != 0) return ret; for (; nwords; nwords--, data++) { ret = sf1_read(adapter, 4, nwords > 1, data); if (ret) return ret; if (byte_oriented) *data = htonl(*data); } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* tick_is_oneshot_available - check for a oneshot capable event device */
int tick_is_oneshot_available(void)
/* tick_is_oneshot_available - check for a oneshot capable event device */ int tick_is_oneshot_available(void)
{ struct clock_event_device *dev = __get_cpu_var(tick_cpu_device).evtdev; return dev && (dev->features & CLOCK_EVT_FEAT_ONESHOT); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Enables gyroscope digital LPF1 if auxiliary SPI is disabled; the bandwidth can be selected through FTYPE in CTRL6_C (15h).. */
int32_t lsm6dso_gy_filter_lp1_set(lsm6dso_ctx_t *ctx, uint8_t val)
/* Enables gyroscope digital LPF1 if auxiliary SPI is disabled; the bandwidth can be selected through FTYPE in CTRL6_C (15h).. */ int32_t lsm6dso_gy_filter_lp1_set(lsm6dso_ctx_t *ctx, uint8_t val)
{ lsm6dso_ctrl4_c_t reg; int32_t ret; ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t*)&reg, 1); if (ret == 0) { reg.lpf1_sel_g = val; ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t*)&reg, 1); } return ret; }
alexander-g-dean/ESF
C++
null
41
/* Helper function to obtain the last memory address of the firmware data that is present in the linked list with segments. */
static uint32_t FirmwareGetLastAddress(void)
/* Helper function to obtain the last memory address of the firmware data that is present in the linked list with segments. */ static uint32_t FirmwareGetLastAddress(void)
{ uint32_t result = 0; tFirmwareSegment * lastSegment; lastSegment = FirmwareGetSegment(FirmwareGetSegmentCount() - 1u); assert(lastSegment != NULL); if (lastSegment != NULL) { result = lastSegment->base + lastSegment->length - 1u; } return result; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* For a stroke in the given style, compute the maximum distance from the path that vertices could be generated. In the case of rotation in the ctm, the distance will not be exact. */
void _cairo_stroke_style_max_distance_from_path(const cairo_stroke_style_t *style, const cairo_path_fixed_t *path, const cairo_matrix_t *ctm, double *dx, double *dy)
/* For a stroke in the given style, compute the maximum distance from the path that vertices could be generated. In the case of rotation in the ctm, the distance will not be exact. */ void _cairo_stroke_style_max_distance_from_path(const cairo_stroke_style_t *style, const cairo_path_fixed_t *path, const cairo_matrix_t *ctm, double *dx, double *dy)
{ double style_expansion = 0.5; if (style->line_cap == CAIRO_LINE_CAP_SQUARE) style_expansion = M_SQRT1_2; if (style->line_join == CAIRO_LINE_JOIN_MITER && ! path->stroke_is_rectilinear && style_expansion < M_SQRT2 * style->miter_limit) { style_expansion = M_SQRT2 * style->miter_limit; } style_expansion *= style->line_width; if (_cairo_matrix_has_unity_scale (ctm)) { *dx = *dy = style_expansion; } else { *dx = style_expansion * hypot (ctm->xx, ctm->xy); *dy = style_expansion * hypot (ctm->yy, ctm->yx); } }
xboot/xboot
C++
MIT License
779
/* Enables the selected interrupts sources on a TWI peripheral. */
void TWI_EnableIt(AT91S_TWI *pTwi, unsigned int sources)
/* Enables the selected interrupts sources on a TWI peripheral. */ void TWI_EnableIt(AT91S_TWI *pTwi, unsigned int sources)
{ SANITY_CHECK(pTwi); SANITY_CHECK((sources & 0xFFFFF088) == 0); pTwi->TWI_IER = sources; }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* This function returns the window command of the specified slider, as set when the widget was created. */
win_command_t wtk_slider_get_command(struct wtk_slider *slider)
/* This function returns the window command of the specified slider, as set when the widget was created. */ win_command_t wtk_slider_get_command(struct wtk_slider *slider)
{ Assert(slider); return slider->command; }
memfault/zero-to-main
C++
null
200
/* Enable the SPI interrupt of the specified SPI port. */
void xSPIIntEnable(unsigned long ulBase, unsigned long ulIntFlags)
/* Enable the SPI interrupt of the specified SPI port. */ void xSPIIntEnable(unsigned long ulBase, unsigned long ulIntFlags)
{ xASSERT(ulBase == SPI0_BASE); xHWREG(ulBase + SPI_CNTRL) |= SPI_CNTRL_IE; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Disable callback. Disables the callback function registered by the usart_register_callback, and the callback will not be called from the interrupt routine. */
void uart_disable_callback(struct uart_module *const module, enum uart_callback callback_type)
/* Disable callback. Disables the callback function registered by the usart_register_callback, and the callback will not be called from the interrupt routine. */ void uart_disable_callback(struct uart_module *const module, enum uart_callback callback_type)
{ Assert(module); module->callback_enable_mask &= ~(1 << callback_type); if (callback_type == UART_CTS_ACTIVE) { module->hw->TX_INTERRUPT_MASK.reg &= ~UART_TX_INTERRUPT_MASK_CTS_ACTIVE_MASK; } }
memfault/zero-to-main
C++
null
200
/* Return the specified configuration descriptor for the specified device. */
struct usb_configuration_descriptor* usbd_device_configuration_descriptor(struct usb_device_instance *device, int port, int configuration)
/* Return the specified configuration descriptor for the specified device. */ struct usb_configuration_descriptor* usbd_device_configuration_descriptor(struct usb_device_instance *device, int port, int configuration)
{ struct usb_configuration_instance *configuration_instance; if (!(configuration_instance = usbd_device_configuration_instance (device, port, configuration))) { return NULL; } return (configuration_instance->configuration_descriptor); }
EmcraftSystems/u-boot
C++
Other
181
/* Preprocess dependency expression and update DriverEntry to reflect the state of Before and After dependencies. If DriverEntry->Before or DriverEntry->After is set it will never be cleared. */
EFI_STATUS MmPreProcessDepex(IN EFI_MM_DRIVER_ENTRY *DriverEntry)
/* Preprocess dependency expression and update DriverEntry to reflect the state of Before and After dependencies. If DriverEntry->Before or DriverEntry->After is set it will never be cleared. */ EFI_STATUS MmPreProcessDepex(IN EFI_MM_DRIVER_ENTRY *DriverEntry)
{ UINT8 *Iterator; Iterator = DriverEntry->Depex; DriverEntry->Dependent = TRUE; if (*Iterator == EFI_DEP_BEFORE) { DriverEntry->Before = TRUE; } else if (*Iterator == EFI_DEP_AFTER) { DriverEntry->After = TRUE; } if (DriverEntry->Before || DriverEntry->After) { CopyMem (&DriverEntry->BeforeAfterGuid, Iterator + 1, sizeof (EFI_GUID)); } return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* ps3_repository_read_num_spu_resource_id - Number of spu resource reservations. @num_resource_id: Number of spu resource ids. */
int ps3_repository_read_num_spu_resource_id(unsigned int *num_resource_id)
/* ps3_repository_read_num_spu_resource_id - Number of spu resource reservations. @num_resource_id: Number of spu resource ids. */ int ps3_repository_read_num_spu_resource_id(unsigned int *num_resource_id)
{ int result; u64 v1; result = read_node(PS3_LPAR_ID_CURRENT, make_first_field("bi", 0), make_field("spursvn", 0), 0, 0, &v1, NULL); *num_resource_id = v1; return result; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Parse dad in string format from Args with the "-s" option and convert it to UINT32 format. */
EFI_STATUS IfConfig6ParseDadXmits(IN OUT ARG_LIST **Arg, OUT UINT32 *Xmits)
/* Parse dad in string format from Args with the "-s" option and convert it to UINT32 format. */ EFI_STATUS IfConfig6ParseDadXmits(IN OUT ARG_LIST **Arg, OUT UINT32 *Xmits)
{ CHAR16 *ValStr; if (*Arg == NULL) { return EFI_INVALID_PARAMETER; } ValStr = (*Arg)->Arg; *Xmits = 0; while (*ValStr != L'\0') { if ((*ValStr <= L'9') && (*ValStr >= L'0')) { *Xmits = (*Xmits * 10) + (*ValStr - L'0'); } else { return EFI_INVALID_PARAMETER; } ValStr++; } *Arg = (*Arg)->Next; return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Close a vm structure and free it, returning the next. */
static struct vm_area_struct* remove_vma(struct vm_area_struct *vma)
/* Close a vm structure and free it, returning the next. */ static struct vm_area_struct* remove_vma(struct vm_area_struct *vma)
{ struct vm_area_struct *next = vma->vm_next; might_sleep(); if (vma->vm_ops && vma->vm_ops->close) vma->vm_ops->close(vma); if (vma->vm_file) { fput(vma->vm_file); if (vma->vm_flags & VM_EXECUTABLE) removed_exe_file_vma(vma->vm_mm); } mpol_put(vma_policy(vma)); kmem_cache_free(vm_area_cachep, vma); return next; }
robutest/uclinux
C++
GPL-2.0
60
/* Retrieves and prepares the virtual address needed to access the hardware. */
static void __iomem* ug_udbg_setup_exi_io_base(struct device_node *np)
/* Retrieves and prepares the virtual address needed to access the hardware. */ static void __iomem* ug_udbg_setup_exi_io_base(struct device_node *np)
{ void __iomem *exi_io_base = NULL; phys_addr_t paddr; const unsigned int *reg; reg = of_get_property(np, "reg", NULL); if (reg) { paddr = of_translate_address(np, reg); if (paddr) exi_io_base = ioremap(paddr, reg[1]); } return exi_io_base; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Write data to the device. The bit should be set after 3 subframe times (each frame is 64 clocks). We wait a maximum of 6 subframes. We really should try doing something more productive while we wait. */
static void mcp_sa11x0_write(struct mcp *mcp, unsigned int reg, unsigned int val)
/* Write data to the device. The bit should be set after 3 subframe times (each frame is 64 clocks). We wait a maximum of 6 subframes. We really should try doing something more productive while we wait. */ static void mcp_sa11x0_write(struct mcp *mcp, unsigned int reg, unsigned int val)
{ int ret = -ETIME; int i; Ser4MCDR2 = reg << 17 | MCDR2_Wr | (val & 0xffff); for (i = 0; i < 2; i++) { udelay(mcp->rw_timeout); if (Ser4MCSR & MCSR_CWC) { ret = 0; break; } } if (ret < 0) printk(KERN_WARNING "mcp: write timed out\n"); }
robutest/uclinux
C++
GPL-2.0
60
/* Set the SysTick Clock Source. The clock source can be either the AHB clock or the same clock divided by 8. */
void systick_set_clocksource(uint8_t clocksource)
/* Set the SysTick Clock Source. The clock source can be either the AHB clock or the same clock divided by 8. */ void systick_set_clocksource(uint8_t clocksource)
{ STK_CSR = (STK_CSR & ~STK_CSR_CLKSOURCE) | (clocksource & STK_CSR_CLKSOURCE); }
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* encrypt and decrypt using DES in ECB mode */
ErrStatus cau_des_ecb(uint32_t algo_dir, uint8_t key[24], cau_text_struct *text)
/* encrypt and decrypt using DES in ECB mode */ ErrStatus cau_des_ecb(uint32_t algo_dir, uint8_t key[24], cau_text_struct *text)
{ ErrStatus ret = ERROR; cau_key_parameter_struct key_initpara; uint32_t keyaddr = (uint32_t)key; cau_key_parameter_init(&key_initpara); cau_init(algo_dir, CAU_MODE_DES_ECB, CAU_SWAPPING_8BIT); key_initpara.key_1_high = __REV(*(uint32_t*)(keyaddr)); keyaddr += 4U; key_initpara.key_1_low= __REV(*(uint32_t*)(keyaddr)); cau_key_init(& key_initpara); cau_fifo_flush(); cau_enable(); ret = cau_des_calculate(text->input, text->in_length, text->output); cau_disable(); return ret; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Sets or Resets the TIM peripheral Capture Compare Preload Control bit. */
void TIM_EnableCapCmpPreloadControl(TIM_Module *TIMx, FunctionalState Cmd)
/* Sets or Resets the TIM peripheral Capture Compare Preload Control bit. */ void TIM_EnableCapCmpPreloadControl(TIM_Module *TIMx, FunctionalState Cmd)
{ assert_param(IsTimList5Module(TIMx)); assert_param(IS_FUNCTIONAL_STATE(Cmd)); if (Cmd != DISABLE) { TIMx->CTRL2 |= TIM_CTRL2_CCPCTL; } else { TIMx->CTRL2 &= (uint32_t) ~((uint32_t)TIM_CTRL2_CCPCTL); } }
pikasTech/PikaPython
C++
MIT License
1,403
/* hrtimer_get_remaining - get remaining time for the timer @timer: the timer to read */
ktime_t hrtimer_get_remaining(const struct hrtimer *timer)
/* hrtimer_get_remaining - get remaining time for the timer @timer: the timer to read */ ktime_t hrtimer_get_remaining(const struct hrtimer *timer)
{ struct hrtimer_clock_base *base; unsigned long flags; ktime_t rem; base = lock_hrtimer_base(timer, &flags); rem = hrtimer_expires_remaining(timer); unlock_hrtimer_base(timer, &flags); return rem; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* The MosChip MCS9990 controller updates its microframe counter a little before the frame counter, and occasionally we will read the invalid intermediate value. Avoid problems by checking the microframe number (the low-order 3 bits); if they are 0 then re-read the register to get the correct value. */
static unsigned ehci_moschip_read_frame_index(struct ehci_hcd *ehci)
/* The MosChip MCS9990 controller updates its microframe counter a little before the frame counter, and occasionally we will read the invalid intermediate value. Avoid problems by checking the microframe number (the low-order 3 bits); if they are 0 then re-read the register to get the correct value. */ static unsigned ehci_moschip_read_frame_index(struct ehci_hcd *ehci)
{ unsigned uf; uf = ehci_readl(ehci, &ehci->regs->frame_index); if (unlikely((uf & 7) == 0)) uf = ehci_readl(ehci, &ehci->regs->frame_index); return uf; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* param base PMIC module base address. param mode Target CPU power mode. */
void PGMC_PPC_ControlByCpuPowerMode(PGMC_PPC_Type *base, pgmc_cpu_mode_t mode)
/* param base PMIC module base address. param mode Target CPU power mode. */ void PGMC_PPC_ControlByCpuPowerMode(PGMC_PPC_Type *base, pgmc_cpu_mode_t mode)
{ base->PPC_MODE = PGMC_PPC_PPC_MODE_CTRL_MODE(kPGMC_ControlledByCpuPowerMode); switch (mode) { case kPGMC_RunMode: break; case kPGMC_WaitMode: base->PPC_STBY_CM_CTRL |= PGMC_PPC_PPC_STBY_CM_CTRL_STBY_ON_AT_WAIT_MASK; break; case kPGMC_StopMode: base->PPC_STBY_CM_CTRL |= PGMC_PPC_PPC_STBY_CM_CTRL_STBY_ON_AT_STOP_MASK; break; case kPGMC_SuspendMode: base->PPC_STBY_CM_CTRL |= PGMC_PPC_PPC_STBY_CM_CTRL_STBY_ON_AT_SUSPEND_MASK; break; default: assert(false); break; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* The function registers the legacy boot support capabilities. */
VOID EFIAPI EfiBootManagerRegisterLegacyBootSupport(EFI_BOOT_MANAGER_REFRESH_LEGACY_BOOT_OPTION RefreshLegacyBootOption, EFI_BOOT_MANAGER_LEGACY_BOOT LegacyBoot)
/* The function registers the legacy boot support capabilities. */ VOID EFIAPI EfiBootManagerRegisterLegacyBootSupport(EFI_BOOT_MANAGER_REFRESH_LEGACY_BOOT_OPTION RefreshLegacyBootOption, EFI_BOOT_MANAGER_LEGACY_BOOT LegacyBoot)
{ mBmRefreshLegacyBootOption = RefreshLegacyBootOption; mBmLegacyBoot = LegacyBoot; }
tianocore/edk2
C++
Other
4,240
/* Device is about to be destroyed: clean up. */
void ipv6_mc_destroy_dev(struct inet6_dev *idev)
/* Device is about to be destroyed: clean up. */ void ipv6_mc_destroy_dev(struct inet6_dev *idev)
{ struct ifmcaddr6 *i; ipv6_mc_down(idev); __ipv6_dev_mc_dec(idev, &in6addr_linklocal_allnodes); if (idev->cnf.forwarding) __ipv6_dev_mc_dec(idev, &in6addr_linklocal_allrouters); write_lock_bh(&idev->lock); while ((i = idev->mc_list) != NULL) { idev->mc_list = i->next; write_unlock_bh(&idev->lock); igmp6_group_dropped(i); ma_put(i); write_lock_bh(&idev->lock); } write_unlock_bh(&idev->lock); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Returns if an LSA is opaque, i.e. requires special treatment */
static int is_opaque(int lsa_type)
/* Returns if an LSA is opaque, i.e. requires special treatment */ static int is_opaque(int lsa_type)
{ return (lsa_type >= OSPF_LSTYPE_OP_LINKLOCAL && lsa_type <= OSPF_LSTYPE_OP_ASWIDE); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* A special thanks goes to Realtek for their support ! */
static void ieee80211_monitor_rx(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats)
/* A special thanks goes to Realtek for their support ! */ static void ieee80211_monitor_rx(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats)
{ struct ieee80211_hdr_4addr *hdr = (struct ieee80211_hdr_4addr *)skb->data; u16 fc = le16_to_cpu(hdr->frame_ctl); skb->dev = ieee->dev; skb_reset_mac_header(skb); skb_pull(skb, ieee80211_get_hdrlen(fc)); skb->pkt_type = PACKET_OTHERHOST; skb->protocol = __constant_htons(ETH_P_80211_RAW); memset(skb->cb, 0, sizeof(skb->cb)); netif_rx(skb); }
robutest/uclinux
C++
GPL-2.0
60
/* this function will seek the offset for specified file descriptor. */
int dfs_file_lseek(struct dfs_fd *fd, off_t offset)
/* this function will seek the offset for specified file descriptor. */ int dfs_file_lseek(struct dfs_fd *fd, off_t offset)
{ int result; if (fd == NULL) return -EINVAL; if (fd->fops->lseek == NULL) return -ENOSYS; result = fd->fops->lseek(fd, offset); if (result >= 0) fd->pos = result; return result; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Virtual: write_nonblocking Returns: the number of bytes written, or -1 on error (including G_IO_ERROR_WOULD_BLOCK). */
gssize g_pollable_output_stream_write_nonblocking(GPollableOutputStream *stream, const void *buffer, gsize count, GCancellable *cancellable, GError **error)
/* Virtual: write_nonblocking Returns: the number of bytes written, or -1 on error (including G_IO_ERROR_WOULD_BLOCK). */ gssize g_pollable_output_stream_write_nonblocking(GPollableOutputStream *stream, const void *buffer, gsize count, GCancellable *cancellable, GError **error)
{ gssize res; g_return_val_if_fail (G_IS_POLLABLE_OUTPUT_STREAM (stream), -1); g_return_val_if_fail (buffer != NULL, 0); if (g_cancellable_set_error_if_cancelled (cancellable, error)) return -1; if (count == 0) return 0; if (((gssize) count) < 0) { g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT, _("Too large count value passed to %s"), G_STRFUNC); return -1; } if (cancellable) g_cancellable_push_current (cancellable); res = G_POLLABLE_OUTPUT_STREAM_GET_INTERFACE (stream)-> write_nonblocking (stream, buffer, count, error); if (cancellable) g_cancellable_pop_current (cancellable); return res; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Print out each alias registered with the Shell. */
SHELL_STATUS PrintAllShellAlias(VOID)
/* Print out each alias registered with the Shell. */ SHELL_STATUS PrintAllShellAlias(VOID)
{ CONST CHAR16 *ConstAllAliasList; CHAR16 *Alias; CHAR16 *Walker; ConstAllAliasList = gEfiShellProtocol->GetAlias (NULL, NULL); if (ConstAllAliasList == NULL) { return (SHELL_SUCCESS); } Alias = AllocateZeroPool (StrSize (ConstAllAliasList)); if (Alias == NULL) { return (SHELL_OUT_OF_RESOURCES); } Walker = (CHAR16 *)ConstAllAliasList; do { CopyMem (Alias, Walker, StrSize (Walker)); Walker = StrStr (Alias, L";"); if (Walker != NULL) { Walker[0] = CHAR_NULL; Walker = Walker + 1; } PrintSingleShellAlias (Alias); } while (Walker != NULL && Walker[0] != CHAR_NULL); FreePool (Alias); return (SHELL_SUCCESS); }
tianocore/edk2
C++
Other
4,240
/* Create Smbios Table and installs the Smbios Table to the System Table. */
VOID EFIAPI SmbiosTableConstruction(BOOLEAN Smbios32BitTable, BOOLEAN Smbios64BitTable)
/* Create Smbios Table and installs the Smbios Table to the System Table. */ VOID EFIAPI SmbiosTableConstruction(BOOLEAN Smbios32BitTable, BOOLEAN Smbios64BitTable)
{ UINT8 *Eps; UINT8 *Eps64Bit; EFI_STATUS Status; if (Smbios32BitTable) { Status = SmbiosCreateTable ((VOID **)&Eps); if (!EFI_ERROR (Status)) { gBS->InstallConfigurationTable (&gEfiSmbiosTableGuid, Eps); } } if (Smbios64BitTable) { Status = SmbiosCreate64BitTable ((VOID **)&Eps64Bit); if (!EFI_ERROR (Status)) { gBS->InstallConfigurationTable (&gEfiSmbios3TableGuid, Eps64Bit); } } }
tianocore/edk2
C++
Other
4,240
/* Read configuration register, returning its value in the location. Return the configuration register value. Returns negative if error occurred. Write status register 1 byte Returns negative if error occurred. */
static int write_sr(struct spi_nor *nor, u8 val)
/* Read configuration register, returning its value in the location. Return the configuration register value. Returns negative if error occurred. Write status register 1 byte Returns negative if error occurred. */ static int write_sr(struct spi_nor *nor, u8 val)
{ nor->cmd_buf[0] = val; return nor->write_reg(nor, SPINOR_OP_WRSR, nor->cmd_buf, 1); }
4ms/stm32mp1-baremetal
C++
Other
137