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
/* do_bad_sync handles the impossible case in the Synchronous Abort vector. */
void do_bad_sync(struct pt_regs *pt_regs, unsigned int esr)
/* do_bad_sync handles the impossible case in the Synchronous Abort vector. */ void do_bad_sync(struct pt_regs *pt_regs, unsigned int esr)
{ efi_restore_gd(); printf("Bad mode in \"Synchronous Abort\" handler, esr 0x%08x\n", esr); show_regs(pt_regs); show_efi_loaded_images(pt_regs); panic("Resetting CPU ...\n"); }
4ms/stm32mp1-baremetal
C++
Other
137
/* prepare a host channel and start a transfer */
uint32_t host_driver_hostch_init(usb_core_instance *pdev, uint8_t hc_num)
/* prepare a host channel and start a transfer */ uint32_t host_driver_hostch_init(usb_core_instance *pdev, uint8_t hc_num)
{ return usb_inithch(&pdev->regs, hc_num, &pdev->host.hc[hc_num], pdev->basic_cfgs.dmaen); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Specifies the type of functions passed to g_list_foreach() and g_slist_foreach(). */
void g_list_foreach(GList *list, GFunc func, gpointer user_data)
/* Specifies the type of functions passed to g_list_foreach() and g_slist_foreach(). */ void g_list_foreach(GList *list, GFunc func, gpointer user_data)
{ while (list) { GList *next = list->next; (*func) (list->data, user_data); list = next; } }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This function will write a character to serial an cga */
void rt_console_putc(int c)
/* This function will write a character to serial an cga */ void rt_console_putc(int c)
{ rt_cga_putc(c); rt_serial_putc(c); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Set GO bit to send command to device */
static void start_command(struct nand_ctlr *reg)
/* Set GO bit to send command to device */ static void start_command(struct nand_ctlr *reg)
{ u32 reg_val; reg_val = readl(&reg->command); reg_val |= CMD_GO; writel(reg_val, &reg->command); }
4ms/stm32mp1-baremetal
C++
Other
137
/* Write PHY register Return 1 if successfully, 0 if timeout. */
unsigned char EMAC_WritePhy(unsigned char PhyAddress, unsigned char Address, unsigned int Value, unsigned int retry)
/* Write PHY register Return 1 if successfully, 0 if timeout. */ unsigned char EMAC_WritePhy(unsigned char PhyAddress, unsigned char Address, unsigned int Value, unsigned int retry)
{ AT91C_BASE_EMAC->EMAC_MAN = (AT91C_EMAC_SOF & (0x01 << 30)) | (AT91C_EMAC_CODE & (2 << 16)) | (AT91C_EMAC_RW & (1 << 28)) | (AT91C_EMAC_PHYA & ((PhyAddress & 0x1f) << 23)) | (AT91C_EMAC_REGA & (Address << 18)) | (AT91C_EMAC_DATA & Value) ; if ( EMAC_WaitPhy(retry) == 0 ) { trace_LOG(trace_ERROR, "TimeOut EMAC_WritePhy\n\r"); return 0; } return 1; }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* UART MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_UART_MspDeInit(UART_HandleTypeDef *huart)
/* UART MSP De-Initialization This function freeze the hardware resources used in this example. */ void HAL_UART_MspDeInit(UART_HandleTypeDef *huart)
{ if(huart->Instance==USART3) { __HAL_RCC_USART3_CLK_DISABLE(); HAL_GPIO_DeInit(GPIOB, GPIO_PIN_10|GPIO_PIN_11); } }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Local function to wait for a device interrupt (and clear it) */
static void Wait4DevInt(unsigned long dwIntr)
/* Local function to wait for a device interrupt (and clear it) */ static void Wait4DevInt(unsigned long dwIntr)
{ while ((LPC_USB->USBDevIntSt & dwIntr) != dwIntr); LPC_USB->USBDevIntClr = dwIntr; }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* platform wakeup will not becomes one of pds_wakeup source */
BL_Err_Type GLB_Platform_Wakeup_Disable(void)
/* platform wakeup will not becomes one of pds_wakeup source */ BL_Err_Type GLB_Platform_Wakeup_Disable(void)
{ uint32_t tmpVal; tmpVal = BL_RD_REG(GLB_BASE, GLB_DIG32K_WAKEUP_CTRL); tmpVal = BL_CLR_REG_BIT(tmpVal, GLB_REG_EN_PLATFORM_WAKEUP); BL_WR_REG(GLB_BASE, GLB_DIG32K_WAKEUP_CTRL, tmpVal); return SUCCESS; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Blocking read of data status register 1 (::FisRegister_Status1). */
uint8_t FisImu_readStatus1(void)
/* Blocking read of data status register 1 (::FisRegister_Status1). */ uint8_t FisImu_readStatus1(void)
{ uint8_t status; FisImu_read_reg(FisRegister_Status1, &status, sizeof(status)); return status; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* This is a version of ip_compute_csum() optimized for IP headers, which always checksum on 4 octet boundaries. */
__sum16 ip_fast_csum(const void *iph, unsigned int ihl)
/* This is a version of ip_compute_csum() optimized for IP headers, which always checksum on 4 octet boundaries. */ __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
{ return (__force __sum16)~do_csum(iph, ihl*4); }
robutest/uclinux
C++
GPL-2.0
60
/* The function will return on of the following values: */
unsigned long USBModeGet(unsigned long ulBase)
/* The function will return on of the following values: */ unsigned long USBModeGet(unsigned long ulBase)
{ ASSERT(ulBase == USB0_BASE); return(HWREGB(ulBase + USB_O_DEVCTL) & (USB_DEVCTL_DEV | USB_DEVCTL_HOST | USB_DEVCTL_SESSION | USB_DEVCTL_VBUS_M)); }
watterott/WebRadio
C++
null
71
/* Set the priority and write to a qmgr queue. */
PRIVATE IX_STATUS ixEthAccQmgrTxWrite(IxEthAccPortId portId, UINT32 qBuffer, UINT32 priority)
/* Set the priority and write to a qmgr queue. */ PRIVATE IX_STATUS ixEthAccQmgrTxWrite(IxEthAccPortId portId, UINT32 qBuffer, UINT32 priority)
{ qBuffer |= (priority << IX_ETHNPE_QM_Q_FIELD_PRIOR_R); return ixEthAccQmgrLockTxWrite(portId, qBuffer); }
EmcraftSystems/u-boot
C++
Other
181
/* Function configures the data structures used by a dedicated Rx Buffer. */
static void CANFD_InitRxDBuf(CANFD_T *psCanfd, CANFD_RAM_PART_T *psRamConfig, CANFD_ELEM_SIZE_T *psElemSize, E_CANFD_DATA_FIELD_SIZE eRxBufSize)
/* Function configures the data structures used by a dedicated Rx Buffer. */ static void CANFD_InitRxDBuf(CANFD_T *psCanfd, CANFD_RAM_PART_T *psRamConfig, CANFD_ELEM_SIZE_T *psElemSize, E_CANFD_DATA_FIELD_SIZE eRxBufSize)
{ uint32_t u32Address; uint32_t u32Size; psCanfd->RXBC = (psRamConfig->u32RXBC_RBSA & CANFD_RXBC_RBSA_Msk); u32Address = CANFD_SRAM_BASE_ADDR(psCanfd) + (psRamConfig->u32RXBC_RBSA & CANFD_RXBC_RBSA_Msk); psCanfd->RXESC = (psCanfd->RXESC & (~CANFD_RXESC_RBDS_Msk)) | (eRxBufSize << CANFD_RXESC_RBDS_Pos); u32Size = eRxBufSize; if (u32Size < 5U) { u32Size += 4U; } else { u32Size = u32Size * 4U - 10U; } memset((uint32_t *)(u32Address), 0x00, (u32Size * 4 * psElemSize->u32RxBuf)); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* v9fs_register_trans - register a new transport with 9p @m: structure describing the transport module and entry points */
void v9fs_register_trans(struct p9_trans_module *m)
/* v9fs_register_trans - register a new transport with 9p @m: structure describing the transport module and entry points */ void v9fs_register_trans(struct p9_trans_module *m)
{ spin_lock(&v9fs_trans_lock); list_add_tail(&m->list, &v9fs_trans_list); spin_unlock(&v9fs_trans_lock); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This file is released undert the GPL v2. */
static void remove_files(struct sysfs_dirent *dir_sd, struct kobject *kobj, const struct attribute_group *grp)
/* This file is released undert the GPL v2. */ static void remove_files(struct sysfs_dirent *dir_sd, struct kobject *kobj, const struct attribute_group *grp)
{ struct attribute *const* attr; int i; for (i = 0, attr = grp->attrs; *attr; i++, attr++) sysfs_hash_and_remove(dir_sd, (*attr)->name); }
robutest/uclinux
C++
GPL-2.0
60
/* lis2de12_enable_xl_int - XL enable selected int pin to generate interrupt */
static int lis2de12_enable_xl_int(const struct device *dev, int enable)
/* lis2de12_enable_xl_int - XL enable selected int pin to generate interrupt */ static int lis2de12_enable_xl_int(const struct device *dev, int enable)
{ const struct lis2de12_config *cfg = dev->config; stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; lis2de12_ctrl_reg3_t val = {0}; int ret; if (enable) { int16_t xl_data[3]; lis2de12_acceleration_raw_get(ctx, xl_data); } ret = lis2de12_pin_int1_config_get(ctx, &val); if (ret < 0) { LOG_ERR("pint_int1_route_get error"); return ret; } val.i1_zyxda = 1; return lis2de12_pin_int1_config_set(ctx, &val); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Store a partial block of planar data after c2p conversion */
static void store_planar_masked(void *dst, u32 dst_inc, u32 bpp, u32 d[8], u32 mask)
/* Store a partial block of planar data after c2p conversion */ static void store_planar_masked(void *dst, u32 dst_inc, u32 bpp, u32 d[8], u32 mask)
{ int i; for (i = 0; i < bpp; i++, dst += dst_inc) put_unaligned_be32(comp(d[perm_c2p_32x8[i]], get_unaligned_be32(dst), mask), dst); }
robutest/uclinux
C++
GPL-2.0
60
/* In case of error the return value is an error pointer. */
struct crypto_tfm* crypto_alloc_base(const char *alg_name, u32 type, u32 mask)
/* In case of error the return value is an error pointer. */ struct crypto_tfm* crypto_alloc_base(const char *alg_name, u32 type, u32 mask)
{ struct crypto_tfm *tfm; int err; for (;;) { struct crypto_alg *alg; alg = crypto_alg_mod_lookup(alg_name, type, mask); if (IS_ERR(alg)) { err = PTR_ERR(alg); goto err; } tfm = __crypto_alloc_tfm(alg, type, mask); if (!IS_ERR(tfm)) return tfm; crypto_mod_put(alg); err = PTR_ERR(tfm); err: if (err != -EAGAIN) break; if (signal_pending(current)) { err = -EINTR; break; } } return ERR_PTR(err); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Reads averaged ppb value from gas sensor. Reads sensor data utilizing custom gas sensor I2C library and sends this data over UART. */
int32_t CN0429_SensorReadoutPPB(uint8_t sensor_address)
/* Reads averaged ppb value from gas sensor. Reads sensor data utilizing custom gas sensor I2C library and sends this data over UART. */ int32_t CN0429_SensorReadoutPPB(uint8_t sensor_address)
{ int32_t PPB_Gas_Reading = 0; eSensorResult = pGasSensor->open(sensor_address); eSensorResult = pGasSensor->ReadDataPPB(&PPB_Gas_Reading); eSensorResult = pGasSensor->close(); delay_ms(10); return PPB_Gas_Reading; }
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* ZigBee Device Profile dissector for the direct join request. */
void dissect_zbee_zdp_req_mgmt_direct_join(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/* ZigBee Device Profile dissector for the direct join request. */ void dissect_zbee_zdp_req_mgmt_direct_join(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{ guint offset = 0; guint64 ext_addr; ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, 8, NULL); zdp_parse_cinfo(tree, ett_zbee_zdp_cinfo, tvb, &offset); zbee_append_info(tree, pinfo, ", Device: %s", eui64_to_display(wmem_packet_scope(), ext_addr)); zdp_dump_excess(tvb, offset, pinfo, tree); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This function removes an SMBIOS record using the handle specified by SmbiosHandle. */
EFI_STATUS EFIAPI SmbiosLibRemove(OUT EFI_SMBIOS_HANDLE SmbiosHandle)
/* This function removes an SMBIOS record using the handle specified by SmbiosHandle. */ EFI_STATUS EFIAPI SmbiosLibRemove(OUT EFI_SMBIOS_HANDLE SmbiosHandle)
{ return gSmbios->Remove (gSmbios, SmbiosHandle); }
tianocore/edk2
C++
Other
4,240
/* While we find nice hex chars, build an int. Return number of chars processed. */
static int hexToInt(char **ptr, int *intValue)
/* While we find nice hex chars, build an int. Return number of chars processed. */ static int hexToInt(char **ptr, int *intValue)
{ int numChars = 0; int hexValue; *intValue = 0; while (**ptr) { hexValue = hex(**ptr); if (hexValue < 0) break; *intValue = (*intValue << 4) | hexValue; numChars++; (*ptr)++; } return (numChars); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* DMA Stream Clear Interrupt Flag. The interrupt flag for the stream is cleared. More than one interrupt for the same stream may be cleared by using the bitwise OR of the interrupt flags. */
void dma_clear_interrupt_flags(uint32_t dma, uint8_t stream, uint32_t interrupts)
/* DMA Stream Clear Interrupt Flag. The interrupt flag for the stream is cleared. More than one interrupt for the same stream may be cleared by using the bitwise OR of the interrupt flags. */ void dma_clear_interrupt_flags(uint32_t dma, uint8_t stream, uint32_t interrupts)
{ uint32_t flags = (interrupts << DMA_ISR_OFFSET(stream)); if (stream < 4) { DMA_LIFCR(dma) = flags; } else { DMA_HIFCR(dma) = flags; } }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* Signed division operation. Run the signed division operation and return the quotient. */
int32_t divas_idiv(int32_t numerator, int32_t denominator)
/* Signed division operation. Run the signed division operation and return the quotient. */ int32_t divas_idiv(int32_t numerator, int32_t denominator)
{ cpu_irq_enter_critical(); DIVAS->CTRLA.reg |= DIVAS_CTRLA_SIGNED; DIVAS->DIVIDEND.reg = numerator; DIVAS->DIVISOR.reg = denominator; while(DIVAS->STATUS.bit.BUSY){ } int32_t quotient = DIVAS->RESULT.reg; cpu_irq_leave_critical(); return quotient; }
memfault/zero-to-main
C++
null
200
/* Increases a pointer while it points to a decimal digit character. */
static char * goNum(char *str)
/* Increases a pointer while it points to a decimal digit character. */ static char * goNum(char *str)
{ for (; *str != '\0'; ++str) { if (!isdigit((int)(*str))) return str; } return 0; }
Luos-io/luos_engine
C++
MIT License
496
/* The memchr() function scans the initial n bytes of the memory area pointed to by s for the first instance of c. Both c and the bytes of the memory area pointed to by s are interpreted as unsigned char. */
void* memrchr(const void *ptr, int ch, size_t pos)
/* The memchr() function scans the initial n bytes of the memory area pointed to by s for the first instance of c. Both c and the bytes of the memory area pointed to by s are interpreted as unsigned char. */ void* memrchr(const void *ptr, int ch, size_t pos)
{ char* end = (char*)ptr + pos - 1; while (end != ptr) { if (*end == ch) return end; end--; } return (*end == ch) ? (end) : (NULL); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Convert a drm_mode_modeinfo into a drm_display_mode structure to return to the caller. */
void drm_crtc_convert_umode(struct drm_display_mode *out, struct drm_mode_modeinfo *in)
/* Convert a drm_mode_modeinfo into a drm_display_mode structure to return to the caller. */ void drm_crtc_convert_umode(struct drm_display_mode *out, struct drm_mode_modeinfo *in)
{ out->clock = in->clock; out->hdisplay = in->hdisplay; out->hsync_start = in->hsync_start; out->hsync_end = in->hsync_end; out->htotal = in->htotal; out->hskew = in->hskew; out->vdisplay = in->vdisplay; out->vsync_start = in->vsync_start; out->vsync_end = in->vsync_end; out->vtotal = in->vtotal; out->vscan = in->vscan; out->vrefresh = in->vrefresh; out->flags = in->flags; out->type = in->type; strncpy(out->name, in->name, DRM_DISPLAY_MODE_LEN); out->name[DRM_DISPLAY_MODE_LEN-1] = 0; }
robutest/uclinux
C++
GPL-2.0
60
/* The Timer 1 default IRQ, declared in start up code. */
void TIMER1IntHandler(void)
/* The Timer 1 default IRQ, declared in start up code. */ void TIMER1IntHandler(void)
{ unsigned long ulBase = TIMER1_BASE; unsigned long ulTemp0; ulTemp0 = xHWREG(ulBase + TIMER_ICTR) ; xHWREG(ulBase + TIMER_ICTR) = ulTemp0; if (g_pfnTimerHandlerCallbacks[1] != 0) { g_pfnTimerHandlerCallbacks[1](0, 0, ulTemp0, 0); } }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* The "old" variants are for translation directly to font (using the 0xf000-0xf0ff "transparent" Unicodes) whereas the "new" variants set Unicodes explicitly. */
int con_set_trans_old(unsigned char __user *arg)
/* The "old" variants are for translation directly to font (using the 0xf000-0xf0ff "transparent" Unicodes) whereas the "new" variants set Unicodes explicitly. */ int con_set_trans_old(unsigned char __user *arg)
{ int i; unsigned short *p = translations[USER_MAP]; if (!access_ok(VERIFY_READ, arg, E_TABSZ)) return -EFAULT; for (i=0; i<E_TABSZ ; i++) { unsigned char uc; __get_user(uc, arg+i); p[i] = UNI_DIRECT_BASE | uc; } update_user_maps(); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Don't use this function from within an interrupt context, like a bottom half handler. If you need an asynchronous message, or need to send a message from within interrupt context, use usb_submit_urb() If a thread in your driver uses this call, make sure your disconnect() method can wait for it to complete. Since you don't have a handle on the URB used, you can't cancel the request. */
int usb_bulk_msg(struct usb_host_virt_dev *usb_dev, unsigned int pipe, void *data, int len, int *actual_length, int timeout)
/* Don't use this function from within an interrupt context, like a bottom half handler. If you need an asynchronous message, or need to send a message from within interrupt context, use usb_submit_urb() If a thread in your driver uses this call, make sure your disconnect() method can wait for it to complete. Since you don't have a handle on the URB used, you can't cancel the request. */ int usb_bulk_msg(struct usb_host_virt_dev *usb_dev, unsigned int pipe, void *data, int len, int *actual_length, int timeout)
{ if (usb_dev == NULL || data == NULL || len < 0) { return -EINVAL; } return _usb_internal_bulk_msg(usb_dev, pipe, data, len, actual_length, timeout); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* If 64-bit I/O port operations are not supported, then ASSERT(). If Port is not aligned on a 64-bit boundary, then ASSERT(). */
UINT64 EFIAPI IoOr64(IN UINTN Port, IN UINT64 OrData)
/* If 64-bit I/O port operations are not supported, then ASSERT(). If Port is not aligned on a 64-bit boundary, then ASSERT(). */ UINT64 EFIAPI IoOr64(IN UINTN Port, IN UINT64 OrData)
{ return IoWrite64 (Port, IoRead64 (Port) | OrData); }
tianocore/edk2
C++
Other
4,240
/* Deinitializes the EXTI peripheral registers to their default reset values. */
void EXTI_DeInit(void)
/* Deinitializes the EXTI peripheral registers to their default reset values. */ void EXTI_DeInit(void)
{ EXTI->IMASK = 0x00000000; EXTI->EMASK = 0x00000000; EXTI->RT_CFG = 0x00000000; EXTI->FT_CFG = 0x00000000; EXTI->PEND = 0x003FFFFF; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Static Helper Function to set customer info valid bits. Use this function to set the state of the 128 valid bits at the beginning of customer info space. If these bits are not set correctly then the customer protection bits in the INFO space will not be honored by the hardware. */
static int customer_info_signature_set(void)
/* Static Helper Function to set customer info valid bits. Use this function to set the state of the 128 valid bits at the beginning of customer info space. If these bits are not set correctly then the customer protection bits in the INFO space will not be honored by the hardware. */ static int customer_info_signature_set(void)
{ uint32_t ui32Valid[4]; int iRC; if ( am_hal_flash_customer_info_signature_check() ) { return 0; } if ( !customer_info_signature_erased() ) { return (2 << 16); } ui32Valid[3] = AM_HAL_FLASH_INFO_SIGNATURE3; ui32Valid[2] = AM_HAL_FLASH_INFO_SIGNATURE2; ui32Valid[1] = AM_HAL_FLASH_INFO_SIGNATURE1; ui32Valid[0] = AM_HAL_FLASH_INFO_SIGNATURE0; iRC = g_am_hal_flash.flash_program_info(AM_HAL_FLASH_PROGRAM_KEY, 0, ui32Valid, 0, 4); return iRC | ((iRC) ? (1 << 16) : 0); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Count the number of in-use tags in a journal descriptor block. */
static int count_tags(struct buffer_head *bh, int size)
/* Count the number of in-use tags in a journal descriptor block. */ static int count_tags(struct buffer_head *bh, int size)
{ char * tagp; journal_block_tag_t * tag; int nr = 0; tagp = &bh->b_data[sizeof(journal_header_t)]; while ((tagp - bh->b_data + sizeof(journal_block_tag_t)) <= size) { tag = (journal_block_tag_t *) tagp; nr++; tagp += sizeof(journal_block_tag_t); if (!(tag->t_flags & cpu_to_be32(JFS_FLAG_SAME_UUID))) tagp += 16; if (tag->t_flags & cpu_to_be32(JFS_FLAG_LAST_TAG)) break; } return nr; }
robutest/uclinux
C++
GPL-2.0
60
/* The answer is rounded up to at least 1, but may not equal or exceed the maximum number of the threads in the pool. This means we always have at least one thread that can process slow work items, and we always have at least one thread that won't get tied up doing so. */
static unsigned slow_work_calc_vsmax(void)
/* The answer is rounded up to at least 1, but may not equal or exceed the maximum number of the threads in the pool. This means we always have at least one thread that can process slow work items, and we always have at least one thread that won't get tied up doing so. */ static unsigned slow_work_calc_vsmax(void)
{ unsigned vsmax; vsmax = atomic_read(&slow_work_thread_count) * vslow_work_proportion; vsmax /= 100; vsmax = max(vsmax, 1U); return min(vsmax, slow_work_max_threads - 1); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Update the progress string through the offset value. */
EFI_STRING UpdateProgress(IN UINTN Offset, IN EFI_STRING Configuration)
/* Update the progress string through the offset value. */ EFI_STRING UpdateProgress(IN UINTN Offset, IN EFI_STRING Configuration)
{ UINTN Length; EFI_STRING StringPtr; EFI_STRING ReturnString; StringPtr = NULL; ReturnString = NULL; Length = StrLen (L"&OFFSET=") + 4 + 1; StringPtr = AllocateZeroPool (Length * sizeof (CHAR16)); if (StringPtr == NULL) { return NULL; } UnicodeSPrint ( StringPtr, (8 + 4 + 1) * sizeof (CHAR16), L"&OFFSET=%04x", Offset ); ReturnString = StrStr (Configuration, StringPtr); if (ReturnString == NULL) { HiiToLower (StringPtr); ReturnString = StrStr (Configuration, StringPtr); } FreePool (StringPtr); return ReturnString; }
tianocore/edk2
C++
Other
4,240
/* Enables the pmt interrupt generation in powerdown mode. */
void synopGMAC_enable_pmt_interrupt(synopGMACdevice *gmacdev)
/* Enables the pmt interrupt generation in powerdown mode. */ void synopGMAC_enable_pmt_interrupt(synopGMACdevice *gmacdev)
{ synopGMACClearBits(gmacdev->MacBase, GmacInterruptMask, GmacPmtIntMask); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Disables the clocking of the USB controller's PHY. */
void USBClockDisable(uint32_t ui32Base)
/* Disables the clocking of the USB controller's PHY. */ void USBClockDisable(uint32_t ui32Base)
{ ASSERT(ui32Base == USB0_BASE); HWREG(ui32Base + USB_O_CC) = 0; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Send a master data receive request when the master have obtained control of the bus.(Write Step2) For this function returns immediately, it is always using in the interrupt hander. */
void xI2CMasterReadRequestS2(unsigned long ulBase, xtBoolean bEndTransmition)
/* Send a master data receive request when the master have obtained control of the bus.(Write Step2) For this function returns immediately, it is always using in the interrupt hander. */ void xI2CMasterReadRequestS2(unsigned long ulBase, xtBoolean bEndTransmition)
{ xASSERT((ulBase == I2C0_BASE) || (ulBase == I2C1_BASE) || (ulBase == I2C2_BASE) || (ulBase == I2C3_BASE) || (ulBase == I2C4_BASE)); if(bEndTransmition) { xHWREG(ulBase + I2C_CON) &= ~I2C_CON_AA; I2CStopSend(ulBase); } }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Returns true if the request 'req' was successfully coalesced into the existing list of pages 'desc'. */
int nfs_pageio_add_request(struct nfs_pageio_descriptor *desc, struct nfs_page *req)
/* Returns true if the request 'req' was successfully coalesced into the existing list of pages 'desc'. */ int nfs_pageio_add_request(struct nfs_pageio_descriptor *desc, struct nfs_page *req)
{ while (!nfs_pageio_do_add_request(desc, req)) { nfs_pageio_doio(desc); if (desc->pg_error < 0) return 0; } return 1; }
robutest/uclinux
C++
GPL-2.0
60
/* Wait for Signal, Message, Mail, or Timeout. Wait for Timeout (Time Delay) */
osStatus osDelay(uint32_t millisec)
/* Wait for Signal, Message, Mail, or Timeout. Wait for Timeout (Time Delay) */ osStatus osDelay(uint32_t millisec)
{ return osErrorISR; } return __svcDelay(millisec); }
labapart/polymcu
C++
null
201
/* Add the PCI Enhanced Configuration Space Information to the MCFG Table. */
STATIC VOID AddPciConfigurationSpaceList(IN MCFG_TABLE *CONST Mcfg, IN CONST UINT32 PciCfgSpaceOffset, IN CONST CM_ARM_PCI_CONFIG_SPACE_INFO *PciCfgSpaceInfoList, IN UINT32 PciCfgSpaceCount)
/* Add the PCI Enhanced Configuration Space Information to the MCFG Table. */ STATIC VOID AddPciConfigurationSpaceList(IN MCFG_TABLE *CONST Mcfg, IN CONST UINT32 PciCfgSpaceOffset, IN CONST CM_ARM_PCI_CONFIG_SPACE_INFO *PciCfgSpaceInfoList, IN UINT32 PciCfgSpaceCount)
{ MCFG_CFG_SPACE_ADDR *PciCfgSpace; ASSERT (Mcfg != NULL); ASSERT (PciCfgSpaceInfoList != NULL); PciCfgSpace = (MCFG_CFG_SPACE_ADDR *)((UINT8 *)Mcfg + PciCfgSpaceOffset); while (PciCfgSpaceCount-- != 0) { PciCfgSpace->BaseAddress = PciCfgSpaceInfoList->BaseAddress; PciCfgSpace->PciSegmentGroupNumber = PciCfgSpaceInfoList->PciSegmentGroupNumber; PciCfgSpace->StartBusNumber = PciCfgSpaceInfoList->StartBusNumber; PciCfgSpace->EndBusNumber = PciCfgSpaceInfoList->EndBusNumber; PciCfgSpace->Reserved = EFI_ACPI_RESERVED_DWORD; PciCfgSpace++; PciCfgSpaceInfoList++; } }
tianocore/edk2
C++
Other
4,240
/* Interrupt handler for the TRNG. Display the random value on the terminal. */
void TRNG_Handler(void)
/* Interrupt handler for the TRNG. Display the random value on the terminal. */ void TRNG_Handler(void)
{ volatile uint32_t status; status = trng_get_interrupt_status(TRNG); if ((status & TRNG_ISR_DATRDY) == TRNG_ISR_DATRDY) { trng_int_flag = 1; trng_disable_interrupt(TRNG); } }
remotemcu/remcu-chip-sdks
C++
null
436
/* Calculate the CRC16 value and start with the previously calculated CRC as initial value. */
uint16_t CRC_CRC16_AccumulateData(uint8_t u8DataWidth, const void *pvData, uint32_t u32Len)
/* Calculate the CRC16 value and start with the previously calculated CRC as initial value. */ uint16_t CRC_CRC16_AccumulateData(uint8_t u8DataWidth, const void *pvData, uint32_t u32Len)
{ uint16_t u16CrcValue = 0U; if ((pvData != NULL) && (u32Len != 0UL)) { DDL_ASSERT(IS_CRC_DATA_WIDTH(u8DataWidth)); if (CRC_DATA_WIDTH_32BIT == u8DataWidth) { (void)CRC_WriteData32((const uint32_t *)pvData, u32Len); } else if (CRC_DATA_WIDTH_16BIT == u8DataWidth) { (void)CRC_WriteData16((const uint16_t *)pvData, u32Len); } else { (void)CRC_WriteData8((const uint8_t *)pvData, u32Len); } u16CrcValue = (uint16_t)READ_REG16(CM_CRC->RESLT); } return u16CrcValue; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs and starts the library USB task to begin the enumeration and USB management process. */
void EVENT_USB_Device_Connect(void)
/* Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs and starts the library USB task to begin the enumeration and USB management process. */ void EVENT_USB_Device_Connect(void)
{ LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); UsingReportProtocol = true; }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* This routine is called by the upper-layer tty layer to signal that */
static void isdn_tty_throttle(struct tty_struct *tty)
/* This routine is called by the upper-layer tty layer to signal that */ static void isdn_tty_throttle(struct tty_struct *tty)
{ modem_info *info = (modem_info *) tty->driver_data; if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_throttle")) return; if (I_IXOFF(tty)) info->x_char = STOP_CHAR(tty); info->mcr &= ~UART_MCR_RTS; }
robutest/uclinux
C++
GPL-2.0
60
/* Slave fill up the TX FIFO with data. This is not a public API. */
static void LPSPI_SlaveTransferFillUpTxFifo(LPSPI_Type *base, lpspi_slave_handle_t *handle)
/* Slave fill up the TX FIFO with data. This is not a public API. */ static void LPSPI_SlaveTransferFillUpTxFifo(LPSPI_Type *base, lpspi_slave_handle_t *handle)
{ assert(handle); uint32_t wordToSend = 0; while (LPSPI_GetTxFifoCount(base) < (handle->fifoSize)) { if (handle->txRemainingByteCount < handle->bytesEachWrite) { handle->bytesEachWrite = handle->txRemainingByteCount; } wordToSend = LPSPI_CombineWriteData(handle->txData, handle->bytesEachWrite, handle->isByteSwap); handle->txData += handle->bytesEachWrite; handle->txRemainingByteCount -= handle->bytesEachWrite; LPSPI_WriteData(base, wordToSend); if (handle->txRemainingByteCount == 0) { break; } } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This routine can be used from both task and interrupt context. */
atomic_val_t rhino_atomic_or(atomic_t *target, atomic_val_t value)
/* This routine can be used from both task and interrupt context. */ atomic_val_t rhino_atomic_or(atomic_t *target, atomic_val_t value)
{ CPSR_ALLOC(); atomic_val_t old_value; RHINO_CPU_INTRPT_DISABLE(); old_value = *target; *target |= value; RHINO_CPU_INTRPT_ENABLE(); return old_value; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Checks whether the specified LPRCNT interrupt has occurred or not. */
INTStatus LPRCNT_GetIntSts(uint32_t Int)
/* Checks whether the specified LPRCNT interrupt has occurred or not. */ INTStatus LPRCNT_GetIntSts(uint32_t Int)
{ INTStatus bitstatus = RESET; uint32_t Temp = 0; Temp = LPRCNT->INTSTS ; Temp &= 0x00070000; if (Temp == Int) { bitstatus = SET; } else { bitstatus = RESET; } return bitstatus; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* byte (1... 15-q) nonce byte (16-q...15) input length */
static void aes_ccm_format_b0(uint8_t *block, const uint8_t *iv, uint32_t iv_len, uint32_t mac_len, uint32_t aad_len, uint32_t input_len)
/* byte (1... 15-q) nonce byte (16-q...15) input length */ static void aes_ccm_format_b0(uint8_t *block, const uint8_t *iv, uint32_t iv_len, uint32_t mac_len, uint32_t aad_len, uint32_t input_len)
{ uint8_t q = 15U - iv_len; block[0] = 0; block[0] |= (aad_len > 0) ? (1U << 6) : 0U; block[0] |= ((mac_len - 2U) / 2U) << 3; block[0] |= q - 1U; (void) memcpy(block + 1U, iv, iv_len); uint32_to_be(block + 1U + iv_len, q, input_len); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Disables reception of all the frames to application. GMAC passes only those received frames to application which pass SA/DA address filtering. */
void synopGMAC_frame_filter_enable(synopGMACdevice *gmacdev)
/* Disables reception of all the frames to application. GMAC passes only those received frames to application which pass SA/DA address filtering. */ void synopGMAC_frame_filter_enable(synopGMACdevice *gmacdev)
{ synopGMACClearBits(gmacdev -> MacBase, GmacFrameFilter, GmacFilter); return; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* The event process routine when the DHCPv6 service binding protocol is installed in the system. */
VOID EFIAPI Ip6ConfigOnDhcp6SbInstalled(IN EFI_EVENT Event, IN VOID *Context)
/* The event process routine when the DHCPv6 service binding protocol is installed in the system. */ VOID EFIAPI Ip6ConfigOnDhcp6SbInstalled(IN EFI_EVENT Event, IN VOID *Context)
{ IP6_CONFIG_INSTANCE *Instance; Instance = (IP6_CONFIG_INSTANCE *)Context; if ((Instance->Dhcp6Handle != NULL) || (Instance->Policy != Ip6ConfigPolicyAutomatic)) { return; } Ip6ConfigStartStatefulAutoConfig (Instance, Instance->OtherInfoOnly); }
tianocore/edk2
C++
Other
4,240
/* Gets the enabled attributes of a uDMA channel. */
unsigned long uDMAChannelAttributeGet(unsigned long ulChannelNum)
/* Gets the enabled attributes of a uDMA channel. */ unsigned long uDMAChannelAttributeGet(unsigned long ulChannelNum)
{ unsigned long ulAttr = 0; ASSERT(ulChannelNum < 32); if(HWREG(UDMA_USEBURSTSET) & (1 << ulChannelNum)) { ulAttr |= UDMA_ATTR_USEBURST; } if(HWREG(UDMA_ALTSET) & (1 << ulChannelNum)) { ulAttr |= UDMA_ATTR_ALTSELECT; } if(HWREG(UDMA_PRIOSET) & (1 << ulChannelNum)) { ulAttr |= UDMA_ATTR_HIGH_PRIORITY; } if(HWREG(UDMA_REQMASKSET) & (1 << ulChannelNum)) { ulAttr |= UDMA_ATTR_REQMASK; } return(ulAttr); }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Prepare a uvesafb_ktask struct to be used again. */
static void uvesafb_reset(struct uvesafb_ktask *task)
/* Prepare a uvesafb_ktask struct to be used again. */ static void uvesafb_reset(struct uvesafb_ktask *task)
{ struct completion *cpl = task->done; memset(task, 0, sizeof(*task)); task->done = cpl; }
robutest/uclinux
C++
GPL-2.0
60
/* Called for each entry in the table of all dissector tables. */
static void dissector_all_tables_foreach_func(gpointer key, gpointer value, gpointer user_data)
/* Called for each entry in the table of all dissector tables. */ static void dissector_all_tables_foreach_func(gpointer key, gpointer value, gpointer user_data)
{ dissector_table_t sub_dissectors; dissector_foreach_info_t *info; g_assert(value); g_assert(user_data); sub_dissectors = (dissector_table_t)value; info = (dissector_foreach_info_t *)user_data; info->table_name = (gchar*) key; info->selector_type = get_dissector_table_selector_type(info->table_name); g_hash_table_foreach(sub_dissectors->hash_table, info->next_func, info); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Adds or substract one hour from the current time. */
void RTC_ConfigDayLightSaving(RTC_DLS_T saving, RTC_BACKUP_T bit)
/* Adds or substract one hour from the current time. */ void RTC_ConfigDayLightSaving(RTC_DLS_T saving, RTC_BACKUP_T bit)
{ RTC_DisableWriteProtection(); if (saving == RTC_DLS_ADD_1H) { RTC->CTRL_B.STCCFG = BIT_SET; } else { RTC->CTRL_B.WTCCFG = BIT_SET; } RTC->CTRL_B.BAKP = bit; RTC_EnableWriteProtection(); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Migrate PPI Pointers from the temporary memory to PEI installed memory. */
VOID ConvertPpiPointers(IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData, IN PEI_CORE_INSTANCE *PrivateData)
/* Migrate PPI Pointers from the temporary memory to PEI installed memory. */ VOID ConvertPpiPointers(IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData, IN PEI_CORE_INSTANCE *PrivateData)
{ UINT8 Index; for (Index = 0; Index < PrivateData->PpiData.PpiList.CurrentCount; Index++) { ConvertSinglePpiPointer ( SecCoreData, PrivateData, &PrivateData->PpiData.PpiList.PpiPtrs[Index] ); } for (Index = 0; Index < PrivateData->PpiData.CallbackNotifyList.CurrentCount; Index++) { ConvertSinglePpiPointer ( SecCoreData, PrivateData, &PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Index] ); } for (Index = 0; Index < PrivateData->PpiData.DispatchNotifyList.CurrentCount; Index++) { ConvertSinglePpiPointer ( SecCoreData, PrivateData, &PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index] ); } }
tianocore/edk2
C++
Other
4,240
/* USBD_VIDEO_GetNextDesc This function return the next descriptor header. */
static USBD_VIDEO_DescHeader_t * USBD_VIDEO_GetNextDesc(uint8_t *pbuf, uint16_t *ptr)
/* USBD_VIDEO_GetNextDesc This function return the next descriptor header. */ static USBD_VIDEO_DescHeader_t * USBD_VIDEO_GetNextDesc(uint8_t *pbuf, uint16_t *ptr)
{ USBD_VIDEO_DescHeader_t *pnext = (USBD_VIDEO_DescHeader_t *)(void *)pbuf; *ptr += pnext->bLength; pnext = (USBD_VIDEO_DescHeader_t *)(void *)(pbuf + pnext->bLength); return (pnext); }
4ms/stm32mp1-baremetal
C++
Other
137
/* vpfe_get_app_input - Get app input index for a given subdev input index driver stores the input index of the current sub device and translate it when application request the current input */
static int vpfe_get_app_input_index(struct vpfe_device *vpfe_dev, int *app_input_index)
/* vpfe_get_app_input - Get app input index for a given subdev input index driver stores the input index of the current sub device and translate it when application request the current input */ static int vpfe_get_app_input_index(struct vpfe_device *vpfe_dev, int *app_input_index)
{ struct vpfe_config *cfg = vpfe_dev->cfg; struct vpfe_subdev_info *sdinfo; int i, j = 0; for (i = 0; i < cfg->num_subdevs; i++) { sdinfo = &cfg->sub_devs[i]; if (!strcmp(sdinfo->name, vpfe_dev->current_subdev->name)) { if (vpfe_dev->current_input >= sdinfo->num_inputs) return -1; *app_input_index = j + vpfe_dev->current_input; return 0; } j += sdinfo->num_inputs; } return -EINVAL; }
robutest/uclinux
C++
GPL-2.0
60
/* @a1: first string @a2: second string @count: number of u16 to compare Return: -1 if a1 < a2, 0 if a1 == a2, 1 if a1 > a2 */
static int unicode_test_u16_strcmp(const u16 *a1, const u16 *a2, size_t count)
/* @a1: first string @a2: second string @count: number of u16 to compare Return: -1 if a1 < a2, 0 if a1 == a2, 1 if a1 > a2 */ static int unicode_test_u16_strcmp(const u16 *a1, const u16 *a2, size_t count)
{ for (; (*a1 || *a2) && count; ++a1, ++a2, --count) { if (*a1 < *a2) return -1; if (*a1 > *a2) return 1; } return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Makes the Dma as owner for this descriptor. This function sets the own bit of status field of the DMA descriptor, indicating the DMA is the owner for this descriptor. */
void synopGMAC_set_owner_dma(DmaDesc *desc)
/* Makes the Dma as owner for this descriptor. This function sets the own bit of status field of the DMA descriptor, indicating the DMA is the owner for this descriptor. */ void synopGMAC_set_owner_dma(DmaDesc *desc)
{ desc->status |= DescOwnByDma; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Check whether current element in the ConfigReqeust string. */
BOOLEAN ElementValidation(BROWSER_STORAGE *BrowserStorage, CHAR16 *RequestElement)
/* Check whether current element in the ConfigReqeust string. */ BOOLEAN ElementValidation(BROWSER_STORAGE *BrowserStorage, CHAR16 *RequestElement)
{ return StrStr (BrowserStorage->ConfigRequest, RequestElement) != NULL ? TRUE : FALSE; }
tianocore/edk2
C++
Other
4,240
/* When unicore comes across an instruction which it cannot handle, it takes the extn instruction trap. */
void rt_hw_trap_extn(struct rt_hw_register *regs)
/* When unicore comes across an instruction which it cannot handle, it takes the extn instruction trap. */ void rt_hw_trap_extn(struct rt_hw_register *regs)
{ rt_hw_show_register(regs); rt_kprintf("extn instruction\n"); rt_kprintf("thread - %s stack:\n", rt_current_thread->name); rt_hw_backtrace((rt_uint32_t *)regs->fp, (rt_uint32_t)rt_current_thread->entry); rt_hw_cpu_shutdown(); }
pikasTech/PikaPython
C++
MIT License
1,403
/* The timer routine: Check if adapter still open and working, reopen if not. */
static void tms380tr_timer_chk(unsigned long data)
/* The timer routine: Check if adapter still open and working, reopen if not. */ static void tms380tr_timer_chk(unsigned long data)
{ struct net_device *dev = (struct net_device*)data; struct net_local *tp = netdev_priv(dev); if(tp->HaltInProgress) return; tms380tr_chk_outstanding_cmds(dev); if(time_before(tp->LastSendTime + SEND_TIMEOUT, jiffies) && (tp->TplFree != tp->TplBusy)) { tp->LastSendTime = jiffies; tms380tr_exec_cmd(dev, OC_CLOSE); } tp->timer.expires = jiffies + 2*HZ; add_timer(&tp->timer); if(tp->AdapterOpenFlag || tp->ReOpenInProgress) return; tp->ReOpenInProgress = 1; tms380tr_open_adapter(dev); return; }
robutest/uclinux
C++
GPL-2.0
60
/* Clear the PWM interrupt flag of the PWM module. The */
void PWMIntFlagClear(unsigned long ulBase, unsigned long ulChannel, unsigned long ulIntType)
/* Clear the PWM interrupt flag of the PWM module. The */ void PWMIntFlagClear(unsigned long ulBase, unsigned long ulChannel, unsigned long ulIntType)
{ xASSERT((ulBase == PWMA_BASE) || (ulBase == PWMB_BASE) || (ulBase == PWMC_BASE)); if(ulBase == PWMA_BASE) { xASSERT((ulChannel >= 0) && (ulChannel <= 5)); } else { xASSERT((ulChannel >= 0) && (ulChannel <= 1)); } xASSERT((ulIntType == PWM_INT_CHXF) || (ulIntType == PWM_INT_TOF)); if (ulIntType == PWM_INT_TOF) { xHWREG(ulBase + TPM_STATUS) |= TPM_STATUS_TOF; } else { xHWREG(ulBase + TPM_STATUS) |= (TPM_STATUS_CH0F << ulChannel); } }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* @discussion This function sets the image pattern for filling an evo. The image pattern is a loaded ebo. The ebo's transformation is applied when drawing the evo. */
BOOL ElmSetPattern(ElmVecObj evo, ElmBitmapObj pattern)
/* @discussion This function sets the image pattern for filling an evo. The image pattern is a loaded ebo. The ebo's transformation is applied when drawing the evo. */ BOOL ElmSetPattern(ElmVecObj evo, ElmBitmapObj pattern)
{ return _set_pattern(evo, pattern); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Deletes all entries from the store that match the specified key. */
int ble_store_util_delete_all(int type, const union ble_store_key *key)
/* Deletes all entries from the store that match the specified key. */ int ble_store_util_delete_all(int type, const union ble_store_key *key)
{ int rc; do { rc = ble_store_delete(type, key); } while (rc == 0); if (rc != BLE_HS_ENOENT) { return rc; } return 0; }
Nicholas3388/LuaNode
C++
Other
1,055
/* This reads the next event in the ring buffer and increments the iterator. */
struct ring_buffer_event* ring_buffer_read(struct ring_buffer_iter *iter, u64 *ts)
/* This reads the next event in the ring buffer and increments the iterator. */ struct ring_buffer_event* ring_buffer_read(struct ring_buffer_iter *iter, u64 *ts)
{ struct ring_buffer_event *event; struct ring_buffer_per_cpu *cpu_buffer = iter->cpu_buffer; unsigned long flags; spin_lock_irqsave(&cpu_buffer->reader_lock, flags); again: event = rb_iter_peek(iter, ts); if (!event) goto out; if (event->type_len == RINGBUF_TYPE_PADDING) goto again; rb_advance_iter(iter); out: spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags); return event; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Execute ISP commands to erase then write User Configuration. */
int32_t FMC_WriteConfig(uint32_t u32Config[], uint32_t u32Count)
/* Execute ISP commands to erase then write User Configuration. */ int32_t FMC_WriteConfig(uint32_t u32Config[], uint32_t u32Count)
{ FMC_ENABLE_CFG_UPDATE(); FMC_Erase(FMC_CONFIG_BASE); FMC_Write(FMC_CONFIG_BASE, u32Config[0]); FMC_Write(FMC_CONFIG_BASE + 4UL, u32Config[1]); FMC_DISABLE_CFG_UPDATE(); return 0; }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* A couple of forward declarations required, due to cyclic reference loop: cgroup_mkdir -> cgroup_create -> cgroup_populate_dir -> cgroup_add_file -> cgroup_create_file -> cgroup_dir_inode_operations -> cgroup_mkdir. */
static int cgroup_mkdir(struct inode *dir, struct dentry *dentry, int mode)
/* A couple of forward declarations required, due to cyclic reference loop: cgroup_mkdir -> cgroup_create -> cgroup_populate_dir -> cgroup_add_file -> cgroup_create_file -> cgroup_dir_inode_operations -> cgroup_mkdir. */ static int cgroup_mkdir(struct inode *dir, struct dentry *dentry, int mode)
{ struct cgroup *c_parent = dentry->d_parent->d_fsdata; return cgroup_create(c_parent, dentry, mode | S_IFDIR); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Writes a data word into the SDHost write buffer. */
tBoolean SDHostDataNonBlockingWrite(unsigned long ulBase, unsigned long ulData)
/* Writes a data word into the SDHost write buffer. */ tBoolean SDHostDataNonBlockingWrite(unsigned long ulBase, unsigned long ulData)
{ if( (HWREG(ulBase + MMCHS_O_PSTATE) & (1<<10)) ) { HWREG(ulBase + MMCHS_O_DATA) = ulData; return(true); } else { return(false); } }
micropython/micropython
C++
Other
18,334
/* Get the Nic handle using any child handle in the IPv4 stack. */
EFI_HANDLE PxeBcGetNicByIp4Children(IN EFI_HANDLE ControllerHandle)
/* Get the Nic handle using any child handle in the IPv4 stack. */ EFI_HANDLE PxeBcGetNicByIp4Children(IN EFI_HANDLE ControllerHandle)
{ EFI_HANDLE NicHandle; NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiArpProtocolGuid); if (NicHandle == NULL) { NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiIp4ProtocolGuid); if (NicHandle == NULL) { NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiUdp4ProtocolGuid); if (NicHandle == NULL) { NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiDhcp4ProtocolGuid); if (NicHandle == NULL) { NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiMtftp4ProtocolGuid); if (NicHandle == NULL) { return NULL; } } } } } return NicHandle; }
tianocore/edk2
C++
Other
4,240
/* Registers a callback. Registers the user callback and enables the interrupt */
void aon_sleep_timer_register_callback(aon_sleep_timer_callback_t fun)
/* Registers a callback. Registers the user callback and enables the interrupt */ void aon_sleep_timer_register_callback(aon_sleep_timer_callback_t fun)
{ aon_sleep_timer_callback = fun; NVIC_EnableIRQ(AON_SLEEP_TIMER0_IRQn); }
remotemcu/remcu-chip-sdks
C++
null
436
/* This idea comes from the SD scheduler of Con Kolivas: */
static int get_update_sysctl_factor(void)
/* This idea comes from the SD scheduler of Con Kolivas: */ static int get_update_sysctl_factor(void)
{ unsigned int cpus = min_t(int, num_online_cpus(), 8); unsigned int factor; switch (sysctl_sched_tunable_scaling) { case SCHED_TUNABLESCALING_NONE: factor = 1; break; case SCHED_TUNABLESCALING_LINEAR: factor = cpus; break; case SCHED_TUNABLESCALING_LOG: default: factor = 1 + ilog2(cpus); break; } return factor; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Get the target clock frequency to be set on the bus. */
UINT32 SdGetTargetBusClockFreq(IN SD_MMC_HC_PRIVATE_DATA *Private, IN UINT8 SlotIndex, IN SD_MMC_BUS_MODE BusTiming)
/* Get the target clock frequency to be set on the bus. */ UINT32 SdGetTargetBusClockFreq(IN SD_MMC_HC_PRIVATE_DATA *Private, IN UINT8 SlotIndex, IN SD_MMC_BUS_MODE BusTiming)
{ UINT32 PreferredClockFreq; UINT32 MaxClockFreq; PreferredClockFreq = Private->Slot[SlotIndex].OperatingParameters.ClockFreq; switch (BusTiming) { case SdMmcUhsSdr104: MaxClockFreq = 208; break; case SdMmcUhsSdr50: MaxClockFreq = 100; break; case SdMmcUhsDdr50: case SdMmcUhsSdr25: case SdMmcSdHs: MaxClockFreq = 50; break; case SdMmcUhsSdr12: case SdMmcSdDs: default: MaxClockFreq = 25; } if ((PreferredClockFreq != EDKII_SD_MMC_CLOCK_FREQ_IGNORE) && (PreferredClockFreq < MaxClockFreq)) { return PreferredClockFreq; } else { return MaxClockFreq; } }
tianocore/edk2
C++
Other
4,240
/* Decode columns by checking if they are skipped */
static void decode_colskip(uint8_t *plane, int width, int height, int stride, GetBitContext *gb)
/* Decode columns by checking if they are skipped */ static void decode_colskip(uint8_t *plane, int width, int height, int stride, GetBitContext *gb)
{ if (!get_bits1(gb)) for (y=0; y<height; y++) plane[y*stride] = 0; else for (y=0; y<height; y++) plane[y*stride] = get_bits1(gb); plane ++; } }
DC-SWAT/DreamShell
C++
null
404
/* Read a value from the ADC and scale it before returning it to the caller. The scale factor is gained from the channel configuration passed via the platform data when the device was registered. */
static ssize_t s3c_hwmon_ch_show(struct device *dev, struct device_attribute *attr, char *buf)
/* Read a value from the ADC and scale it before returning it to the caller. The scale factor is gained from the channel configuration passed via the platform data when the device was registered. */ static ssize_t s3c_hwmon_ch_show(struct device *dev, struct device_attribute *attr, char *buf)
{ struct sensor_device_attribute *sen_attr = to_sensor_dev_attr(attr); struct s3c_hwmon *hwmon = platform_get_drvdata(to_platform_device(dev)); struct s3c_hwmon_pdata *pdata = dev->platform_data; struct s3c_hwmon_chcfg *cfg; int ret; cfg = pdata->in[sen_attr->index]; ret = s3c_hwmon_read_ch(dev, hwmon, sen_attr->index); if (ret < 0) return ret; ret *= cfg->mult; ret = DIV_ROUND_CLOSEST(ret, cfg->div); return snprintf(buf, PAGE_SIZE, "%d\n", ret); }
robutest/uclinux
C++
GPL-2.0
60
/* Enables the chip select in software controlled mode */
void SPICSEnable(unsigned long ulBase)
/* Enables the chip select in software controlled mode */ void SPICSEnable(unsigned long ulBase)
{ HWREG( ulBase+MCSPI_O_CH0CONF) |= MCSPI_CH0CONF_FORCE; }
micropython/micropython
C++
Other
18,334
/* allocates and initializes a mac descriptor smart pointer Uses */
IX_ETH_DB_PUBLIC MacDescriptor* ixEthDBAllocMacDescriptor(void)
/* allocates and initializes a mac descriptor smart pointer Uses */ IX_ETH_DB_PUBLIC MacDescriptor* ixEthDBAllocMacDescriptor(void)
{ MacDescriptor *allocatedDescriptor = ixEthDBPoolAllocMacDescriptor(); if (allocatedDescriptor != NULL) { LOCK_MAC_POOL; allocatedDescriptor->refCount++; UNLOCK_MAC_POOL; } return allocatedDescriptor; }
EmcraftSystems/u-boot
C++
Other
181
/* Simply calls the bootmem allocator to free the specified ranged from the given pg_data_t's bdata struct. After this function has been called for all the entries in the EFI memory map, the bootmem allocator will be ready to service allocation requests. */
static int __init free_node_bootmem(unsigned long start, unsigned long len, int node)
/* Simply calls the bootmem allocator to free the specified ranged from the given pg_data_t's bdata struct. After this function has been called for all the entries in the EFI memory map, the bootmem allocator will be ready to service allocation requests. */ static int __init free_node_bootmem(unsigned long start, unsigned long len, int node)
{ free_bootmem_node(pgdat_list[node], start, len); return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Read a value from a register in an OV7740 sensor device. */
uint32_t ov_read_reg(Twi *const p_twi, twi_packet_t *const p_packet)
/* Read a value from a register in an OV7740 sensor device. */ uint32_t ov_read_reg(Twi *const p_twi, twi_packet_t *const p_packet)
{ uint32_t ul_status; ul_status = twi_master_read(p_twi, p_packet); return ul_status; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Configures the voltage threshold detected by the Power Voltage Detector(PVD). */
void PWR_PVDLevelConfig(uint32_t PWR_PVDLevel)
/* Configures the voltage threshold detected by the Power Voltage Detector(PVD). */ void PWR_PVDLevelConfig(uint32_t PWR_PVDLevel)
{ uint32_t tmpreg = 0; assert_param(IS_PWR_PVD_LEVEL(PWR_PVDLevel)); tmpreg = PWR->CR; tmpreg &= CR_PLS_Mask; tmpreg |= PWR_PVDLevel; PWR->CR = tmpreg; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Configs the PLL clock source and multiplication factor. */
void RCM_ConfigPLL(RCM_PLLSEL_T pllSelect, RCM_PLLMF_T pllMf)
/* Configs the PLL clock source and multiplication factor. */ void RCM_ConfigPLL(RCM_PLLSEL_T pllSelect, RCM_PLLMF_T pllMf)
{ RCM->CFG_B.PLLMULCFG = pllMf; RCM->CFG_B.PLLSRCSEL = pllSelect & 0x01; RCM->CFG_B.PLLHSEPSC = (pllSelect >> 1) & 0x01; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* De-initialize RTC Interface. stops operation and releases the software resources used by the interface. */
int32_t csi_rtc_uninitialize(rtc_handle_t handle)
/* De-initialize RTC Interface. stops operation and releases the software resources used by the interface. */ int32_t csi_rtc_uninitialize(rtc_handle_t handle)
{ RTC_NULL_PARAM_CHK(handle); ck_rtc_priv_t *rtc_priv = handle; rtc_priv->cb_event = NULL; drv_nvic_disable_irq(rtc_priv->irq); return 0; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Return logical sector number of either Short or Long Allocation Descriptor. */
EFI_STATUS GetAllocationDescriptorLsn(IN UDF_FE_RECORDING_FLAGS RecordingFlags, IN UDF_VOLUME_INFO *Volume, IN UDF_LONG_ALLOCATION_DESCRIPTOR *ParentIcb, IN VOID *Ad, OUT UINT64 *Lsn)
/* Return logical sector number of either Short or Long Allocation Descriptor. */ EFI_STATUS GetAllocationDescriptorLsn(IN UDF_FE_RECORDING_FLAGS RecordingFlags, IN UDF_VOLUME_INFO *Volume, IN UDF_LONG_ALLOCATION_DESCRIPTOR *ParentIcb, IN VOID *Ad, OUT UINT64 *Lsn)
{ UDF_PARTITION_DESCRIPTOR *PartitionDesc; if (RecordingFlags == LongAdsSequence) { return GetLongAdLsn (Volume, (UDF_LONG_ALLOCATION_DESCRIPTOR *)Ad, Lsn); } else if (RecordingFlags == ShortAdsSequence) { PartitionDesc = GetPdFromLongAd (Volume, ParentIcb); if (PartitionDesc == NULL) { return EFI_UNSUPPORTED; } *Lsn = GetShortAdLsn ( Volume, PartitionDesc, (UDF_SHORT_ALLOCATION_DESCRIPTOR *)Ad ); return EFI_SUCCESS; } ASSERT (FALSE); return EFI_UNSUPPORTED; }
tianocore/edk2
C++
Other
4,240
/* Write contents of register REGNO in task TASK. */
static int put_reg(struct task_struct *task, unsigned long regno, unsigned long data)
/* Write contents of register REGNO in task TASK. */ static int put_reg(struct task_struct *task, unsigned long regno, unsigned long data)
{ if (regno == 63) { task_thread_info(task)->ieee_state = ((task_thread_info(task)->ieee_state & ~IEEE_SW_MASK) | (data & IEEE_SW_MASK)); data = (data & FPCR_DYN_MASK) | ieee_swcr_to_fpcr(data); } *get_reg_addr(task, regno) = data; return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Function for initialiasing the application instance identified by 'index'. */
static __INLINE void application_instance_init(uint32_t index)
/* Function for initialiasing the application instance identified by 'index'. */ static __INLINE void application_instance_init(uint32_t index)
{ DM_TRC("[DM]: Initializing Application Instance 0x%08X.\r\n", index); m_application_table[index].ntf_cb = NULL; m_application_table[index].state = 0x00; m_application_table[index].service = 0x00; }
labapart/polymcu
C++
null
201
/* param base peripheral base address. return Mask of asserted status flags. See to "_dcdc_status_flags_t". */
uint32_t DCDC_GetstatusFlags(DCDC_Type *base)
/* param base peripheral base address. return Mask of asserted status flags. See to "_dcdc_status_flags_t". */ uint32_t DCDC_GetstatusFlags(DCDC_Type *base)
{ uint32_t tmp32 = 0U; if (DCDC_REG0_STS_DC_OK_MASK == (DCDC_REG0_STS_DC_OK_MASK & base->REG0)) { tmp32 |= (uint32_t)kDCDC_LockedOKStatus; } return tmp32; }
eclipse-threadx/getting-started
C++
Other
310
/* Returns: A newly-allocated buffer containing the converted string, or NULL on an error, and error will be set. */
gchar* g_locale_to_utf8(const gchar *opsysstring, gssize len, gsize *bytes_read, gsize *bytes_written, GError **error)
/* Returns: A newly-allocated buffer containing the converted string, or NULL on an error, and error will be set. */ gchar* g_locale_to_utf8(const gchar *opsysstring, gssize len, gsize *bytes_read, gsize *bytes_written, GError **error)
{ const char *charset; if (g_get_charset (&charset)) return strdup_len (opsysstring, len, bytes_read, bytes_written, error); else return g_convert (opsysstring, len, "UTF-8", charset, bytes_read, bytes_written, error); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This routine is called whenever a serial port is opened. It enables interrupts for a serial port, linking in its async structure into the IRQ chain. It also performs the serial-specific initialization for the tty structure. */
static void rs_poll(unsigned long)
/* This routine is called whenever a serial port is opened. It enables interrupts for a serial port, linking in its async structure into the IRQ chain. It also performs the serial-specific initialization for the tty structure. */ static void rs_poll(unsigned long)
{ struct tty_struct* tty = (struct tty_struct*) priv; struct timeval tv = { .tv_sec = 0, .tv_usec = 0 }; int i = 0; unsigned char c; spin_lock(&timer_lock); while (__simc(SYS_select_one, 0, XTISS_SELECT_ONE_READ, (int)&tv,0,0)){ __simc (SYS_read, 0, (unsigned long)&c, 1, 0, 0); tty_insert_flip_char(tty, c, TTY_NORMAL); i++; } if (i) tty_flip_buffer_push(tty); mod_timer(&serial_timer, jiffies + SERIAL_TIMER_VALUE); spin_unlock(&timer_lock); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Return the status of I2C was initialized or not. */
static uint8_t ft3x67_Get_I2C_InitializedStatus(void)
/* Return the status of I2C was initialized or not. */ static uint8_t ft3x67_Get_I2C_InitializedStatus(void)
{ return(ft3x67_handle.i2cInitialized); }
eclipse-threadx/getting-started
C++
Other
310
/* RETURNS: true indicating that result TF is successfully filled. */
bool ata_sff_qc_fill_rtf(struct ata_queued_cmd *qc)
/* RETURNS: true indicating that result TF is successfully filled. */ bool ata_sff_qc_fill_rtf(struct ata_queued_cmd *qc)
{ qc->ap->ops->sff_tf_read(qc->ap, &qc->result_tf); return true; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* ctrl: NAND_NCE: bit 0 -> bit 2 NAND_CLE: bit 1 -> bit 7 NAND_ALE: bit 2 -> bit 6 */
static void ams_delta_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
/* ctrl: NAND_NCE: bit 0 -> bit 2 NAND_CLE: bit 1 -> bit 7 NAND_ALE: bit 2 -> bit 6 */ static void ams_delta_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
{ if (ctrl & NAND_CTRL_CHANGE) { unsigned long bits; bits = (~ctrl & NAND_NCE) ? AMS_DELTA_LATCH2_NAND_NCE : 0; bits |= (ctrl & NAND_CLE) ? AMS_DELTA_LATCH2_NAND_CLE : 0; bits |= (ctrl & NAND_ALE) ? AMS_DELTA_LATCH2_NAND_ALE : 0; ams_delta_latch2_write(AMS_DELTA_LATCH2_NAND_CLE | AMS_DELTA_LATCH2_NAND_ALE | AMS_DELTA_LATCH2_NAND_NCE, bits); } if (cmd != NAND_CMD_NONE) ams_delta_write_byte(mtd, cmd); }
robutest/uclinux
C++
GPL-2.0
60
/* Free all the lines in HBufferImage. Fields affected: Lines CurrentLine NumLines ListHead */
EFI_STATUS HFreeLines(IN LIST_ENTRY *ListHead, IN HEFI_EDITOR_LINE *Lines)
/* Free all the lines in HBufferImage. Fields affected: Lines CurrentLine NumLines ListHead */ EFI_STATUS HFreeLines(IN LIST_ENTRY *ListHead, IN HEFI_EDITOR_LINE *Lines)
{ LIST_ENTRY *Link; HEFI_EDITOR_LINE *Line; if (Lines != NULL) { Line = Lines; Link = &(Line->Link); do { Line = CR (Link, HEFI_EDITOR_LINE, Link, EFI_EDITOR_LINE_LIST); Link = Link->ForwardLink; HLineFree (Line); } while (Link != ListHead); } ListHead->ForwardLink = ListHead; ListHead->BackLink = ListHead; return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Returns: a signed 64-bit integer from the attribute. */
gint64 g_file_info_get_attribute_int64(GFileInfo *info, const char *attribute)
/* Returns: a signed 64-bit integer from the attribute. */ gint64 g_file_info_get_attribute_int64(GFileInfo *info, const char *attribute)
{ GFileAttributeValue *value; g_return_val_if_fail (G_IS_FILE_INFO (info), 0); g_return_val_if_fail (attribute != NULL && *attribute != '\0', 0); value = g_file_info_find_value_by_name (info, attribute); return _g_file_attribute_value_get_int64 (value); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Update buffers and history at the end of decoding a subframe. */
static void update_state(AMRContext *p)
/* Update buffers and history at the end of decoding a subframe. */ static void update_state(AMRContext *p)
{ memcpy(p->prev_lsp_sub4, p->lsp[3], LP_FILTER_ORDER * sizeof(p->lsp[3][0])); memmove(&p->excitation_buf[0], &p->excitation_buf[AMR_SUBFRAME_SIZE], (PITCH_DELAY_MAX + LP_FILTER_ORDER + 1) * sizeof(float)); memmove(&p->pitch_gain[0], &p->pitch_gain[1], 4 * sizeof(float)); memmove(&p->fixed_gain[0], &p->fixed_gain[1], 4 * sizeof(float)); memmove(&p->samples_in[0], &p->samples_in[AMR_SUBFRAME_SIZE], LP_FILTER_ORDER * sizeof(float)); }
DC-SWAT/DreamShell
C++
null
404
/* Callback used to signal the end of a setup request. */
static void uhc_setup_request_callback(usb_add_t add, uhd_trans_status_t status, uint16_t payload_trans)
/* Callback used to signal the end of a setup request. */ static void uhc_setup_request_callback(usb_add_t add, uhd_trans_status_t status, uint16_t payload_trans)
{ UNUSED(add); UNUSED(payload_trans); uhc_setup_request_finish_status = (status == UHD_TRANS_NOERROR); uhc_setup_request_finish = true; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Init the ADC of the motor shield for current get. */
unsigned long AMSMotorCurrentGet(unsigned long ulMotor)
/* Init the ADC of the motor shield for current get. */ unsigned long AMSMotorCurrentGet(unsigned long ulMotor)
{ unsigned long ulCurrentADCData; xASSERT((ulBase == AMS_MOTOR_A) || (ulBase == AMS_MOTOR_B)); if(ulMotor == AMS_MOTOR_A) { ulCurrentADCData = ADCDataInjectedGet(sADC_BASE, 1) & 0xFFF; } else if(ulMotor == AMS_MOTOR_B) { ulCurrentADCData = ADCDataInjectedGet(sADC_BASE, 2) & 0xFFF; } ulCurrentADCData = ulCurrentADCData *2000; ulCurrentADCData = ulCurrentADCData >> 12; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* This function parses the PCC Subspace type 4. */
STATIC VOID DumpPccSubspaceType4(IN UINT8 *Ptr, IN UINT8 Length)
/* This function parses the PCC Subspace type 4. */ STATIC VOID DumpPccSubspaceType4(IN UINT8 *Ptr, IN UINT8 Length)
{ ParseAcpi ( TRUE, 2, "Subspace Type 4", Ptr, Length, PARSER_PARAMS (PccSubspaceType3Parser) ); }
tianocore/edk2
C++
Other
4,240