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
/* Description: Take care of setting up the phy_device structure, set the state to READY (the driver's init function should set it to STARTING if needed). */
static int phy_probe(struct device *dev)
/* Description: Take care of setting up the phy_device structure, set the state to READY (the driver's init function should set it to STARTING if needed). */ static int phy_probe(struct device *dev)
{ struct phy_device *phydev; struct phy_driver *phydrv; struct device_driver *drv; int err = 0; phydev = to_phy_device(dev); drv = get_driver(phydev->dev.driver); phydrv = to_phy_driver(drv); phydev->drv = phydrv; if (!(phydrv->flags & PHY_HAS_INTERRUPT)) phydev->irq = PHY_POLL; mutex_lock(&phydev->lock); ...
robutest/uclinux
C++
GPL-2.0
60
/* 转义打包 标识Flag,即包头包尾加入Flag 数据中遇到Flag -> Code F1 数据中遇到Code -> Code F2 */
uint32_t TransferPack(uint8_t Flag, uint8_t Code, uint8_t F1, uint8_t F2, uint8_t *InBuf, uint32_t Len, uint8_t *OutBuf)
/* 转义打包 标识Flag,即包头包尾加入Flag 数据中遇到Flag -> Code F1 数据中遇到Code -> Code F2 */ uint32_t TransferPack(uint8_t Flag, uint8_t Code, uint8_t F1, uint8_t F2, uint8_t *InBuf, uint32_t Len, uint8_t *OutBuf)
{ uint32_t TxLen = 0; uint32_t i; OutBuf[0] = Flag; TxLen = 1; for (i = 0; i < Len; i++) { if (InBuf[i] == Flag) { OutBuf[TxLen++] = Code; OutBuf[TxLen++] = F1; } else if (InBuf[i] == Code) { OutBuf[TxLen++] = Code; ...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Description: Removes a NetLabel/LSM domain mapping. A @domain value of NULL causes the default domain mapping to be removed. Returns zero on success, negative values on failure. */
int netlbl_cfg_map_del(const char *domain, u16 family, const void *addr, const void *mask, struct netlbl_audit *audit_info)
/* Description: Removes a NetLabel/LSM domain mapping. A @domain value of NULL causes the default domain mapping to be removed. Returns zero on success, negative values on failure. */ int netlbl_cfg_map_del(const char *domain, u16 family, const void *addr, const void *mask, struct netlbl_audit *audit_info)
{ if (addr == NULL && mask == NULL) { return netlbl_domhsh_remove(domain, audit_info); } else if (addr != NULL && mask != NULL) { switch (family) { case AF_INET: return netlbl_domhsh_remove_af4(domain, addr, mask, audit_info); default: return -EPFNOSUPPORT; } } else return -EINVAL; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Execute FMC_ISPCMD_READ command to read a word from flash. */
uint32_t FMC_Read(uint32_t u32Addr)
/* Execute FMC_ISPCMD_READ command to read a word from flash. */ uint32_t FMC_Read(uint32_t u32Addr)
{ int32_t i32TimeOutCnt; g_FMC_i32ErrCode = 0; FMC->ISPCMD = FMC_ISPCMD_READ; FMC->ISPADDR = u32Addr; FMC->ISPTRG = FMC_ISPTRG_ISPGO_Msk; i32TimeOutCnt = FMC_TIMEOUT_READ; while (FMC->ISPTRG & FMC_ISPTRG_ISPGO_Msk) { if (i32TimeOutCnt-- <= 0) { g_FMC_i32ErrCod...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Return: 0 if all goes good, else appropriate error message. */
static int k3_arm64_load(struct udevice *dev, ulong addr, ulong size)
/* Return: 0 if all goes good, else appropriate error message. */ static int k3_arm64_load(struct udevice *dev, ulong addr, ulong size)
{ struct k3_arm64_privdata *rproc = dev_get_priv(dev); int ret; dev_dbg(dev, "%s addr = 0x%lx, size = 0x%lx\n", __func__, addr, size); ret = ti_sci_proc_request(&rproc->tsp); if (ret) return ret; return ti_sci_proc_set_config(&rproc->tsp, addr, 0, 0); }
4ms/stm32mp1-baremetal
C++
Other
137
/* If 'write' is non-zero, then we wipe out the journal on disk; otherwise we merely suppress recovery. */
int jbd2_journal_wipe(journal_t *journal, int write)
/* If 'write' is non-zero, then we wipe out the journal on disk; otherwise we merely suppress recovery. */ int jbd2_journal_wipe(journal_t *journal, int write)
{ journal_superblock_t *sb; int err = 0; J_ASSERT (!(journal->j_flags & JBD2_LOADED)); err = load_superblock(journal); if (err) return err; sb = journal->j_superblock; if (!journal->j_tail) goto no_recovery; printk (KERN_WARNING "JBD: %s recovery information on journal\n", write ? "Clearing" : "Ignoring")...
robutest/uclinux
C++
GPL-2.0
60
/* Wait for the frequency EEprom to complete a command... */
static void fee_wait(u_long base, int delay, int number)
/* Wait for the frequency EEprom to complete a command... */ static void fee_wait(u_long base, int delay, int number)
{ int count = 0; while((count++ < number) && (mmc_in(base, mmroff(0, mmr_fee_status)) & MMR_FEE_STATUS_BUSY)) udelay(delay); }
robutest/uclinux
C++
GPL-2.0
60
/* Sample a process (thread group) clock for the given group_leader task. Must be called with tasklist_lock held for reading. */
static int cpu_clock_sample_group(const clockid_t which_clock, struct task_struct *p, union cpu_time_count *cpu)
/* Sample a process (thread group) clock for the given group_leader task. Must be called with tasklist_lock held for reading. */ static int cpu_clock_sample_group(const clockid_t which_clock, struct task_struct *p, union cpu_time_count *cpu)
{ struct task_cputime cputime; switch (CPUCLOCK_WHICH(which_clock)) { default: return -EINVAL; case CPUCLOCK_PROF: thread_group_cputime(p, &cputime); cpu->cpu = cputime_add(cputime.utime, cputime.stime); break; case CPUCLOCK_VIRT: thread_group_cputime(p, &cputime); cpu->cpu = cputime.utime; break; c...
EmcraftSystems/linux-emcraft
C++
Other
266
/* Maximal file size. There is a direct, and {,double-,triple-}indirect block limit, and also a limit of (2^32 - 1) 512-byte sectors in i_blocks. We need to be 1 filesystem block less than the 2^32 sector limit. */
static loff_t ext2_max_size(int bits)
/* Maximal file size. There is a direct, and {,double-,triple-}indirect block limit, and also a limit of (2^32 - 1) 512-byte sectors in i_blocks. We need to be 1 filesystem block less than the 2^32 sector limit. */ static loff_t ext2_max_size(int bits)
{ loff_t res = EXT2_NDIR_BLOCKS; int meta_blocks; loff_t upper_limit; upper_limit = (1LL << 32) - 1; upper_limit >>= (bits - 9); meta_blocks = 1; meta_blocks += 1 + (1LL << (bits-2)); meta_blocks += 1 + (1LL << (bits-2)) + (1LL << (2*(bits-2))); upper_limit -= meta_blocks; upper_limit <<= bits; res += 1LL <<...
robutest/uclinux
C++
GPL-2.0
60
/* brief Initialize the external osc clock to given frequency. param iFreq : Desired frequency (must be equal to exact rate in Hz) return returns success or fail status. */
status_t CLOCK_SetupExtClocking(uint32_t iFreq)
/* brief Initialize the external osc clock to given frequency. param iFreq : Desired frequency (must be equal to exact rate in Hz) return returns success or fail status. */ status_t CLOCK_SetupExtClocking(uint32_t iFreq)
{ if (iFreq >= 32000000U) { return kStatus_Fail; } POWER_DisablePD(kPDRUNCFG_PD_XTALHF); POWER_DisablePD(kPDRUNCFG_PD_LDOXTALHF); SYSCON->CLOCK_CTRL |= SYSCON_CLOCK_CTRL_CLKIN_ENA_MASK; s_Ext_Clk_Freq = iFreq; return kStatus_Success; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Read a buffer of data to a selected endpoint. */
void USBD_ReadDataFromEP(USBD_EP_T ep, uint8_t *rBuf, uint32_t rLen)
/* Read a buffer of data to a selected endpoint. */ void USBD_ReadDataFromEP(USBD_EP_T ep, uint8_t *rBuf, uint32_t rLen)
{ uint32_t i; uint32_t *addrEP; uint32_t tmp; rLen = (rLen + 1) >> 1; addrEP = (uint32_t *)((uint32_t)USBD_ReadEPRxAddr(ep)); addrEP = (uint32_t *)(((uint32_t)addrEP << 1) + USBD_PMA_ADDR); for(i = 0; i < rLen; i++) { tmp = *addrEP++; *rBuf++ = tmp & 0XFF; *rBuf++...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* this function has a separated environment, which defines the correct __close for 'popen' files */
static int getiofile(lua_State *L, int findex)
/* this function has a separated environment, which defines the correct __close for 'popen' files */ static int getiofile(lua_State *L, int findex)
{ luaL_error(L, "default %s file is closed", fnames[findex - 1]); return ESP_OK - 1; } return *pf; }
Nicholas3388/LuaNode
C++
Other
1,055
/* UART MSP Initialization This function configures the hardware resources used in this example. */
void HAL_UART_MspInit(UART_HandleTypeDef *huart)
/* UART MSP Initialization This function configures the hardware resources used in this example. */ void HAL_UART_MspInit(UART_HandleTypeDef *huart)
{ GPIO_InitTypeDef GPIO_InitStruct = {0}; if(huart->Instance==USART3) { __HAL_RCC_USART3_CLK_ENABLE(); __HAL_RCC_GPIOD_CLK_ENABLE(); GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_F...
feaser/openblt
C++
GNU General Public License v3.0
601
/* Set the size of the string in characters. */
EFI_STATUS InputBarSetStringSize(UINTN Size)
/* Set the size of the string in characters. */ EFI_STATUS InputBarSetStringSize(UINTN Size)
{ SHELL_FREE_NON_NULL (mReturnString); StringSize = Size; mReturnString = AllocateZeroPool ((StringSize + 1) * sizeof (mReturnString[0])); if (mReturnString == NULL) { return EFI_OUT_OF_RESOURCES; } return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* The callback function for the net buffer that wraps the packet processed by IPsec. It releases the wrap packet and also signals IPsec to free the resources. */
VOID EFIAPI Ip6IpSecFree(IN VOID *Arg)
/* The callback function for the net buffer that wraps the packet processed by IPsec. It releases the wrap packet and also signals IPsec to free the resources. */ VOID EFIAPI Ip6IpSecFree(IN VOID *Arg)
{ IP6_IPSEC_WRAP *Wrap; Wrap = (IP6_IPSEC_WRAP *)Arg; if (Wrap->IpSecRecycleSignal != NULL) { gBS->SignalEvent (Wrap->IpSecRecycleSignal); } NetbufFree (Wrap->Packet); FreePool (Wrap); return; }
tianocore/edk2
C++
Other
4,240
/* Help command helper function. Display help function prompt. */
static int32_t ad7124_8pmdz_help_prompt(struct ad7124_8pmdz_dev *dev, bool short_command)
/* Help command helper function. Display help function prompt. */ static int32_t ad7124_8pmdz_help_prompt(struct ad7124_8pmdz_dev *dev, bool short_command)
{ int32_t ret; if (!short_command) { ret = cli_write_string(dev->cli_handler, (uint8_t*)"\tCN0424 application.\n"); if(ret != SUCCESS) return ret; ret = cli_write_string(dev->cli_handler, (uint8_t*) "For commands with options as arguments typing the command and 'space' withou...
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* this function will seek the offset for specified file descriptor. */
off_t dfs_file_lseek(struct dfs_file *fd, off_t offset)
/* this function will seek the offset for specified file descriptor. */ off_t dfs_file_lseek(struct dfs_file *fd, off_t offset)
{ int result; if (fd == NULL) return -EINVAL; if (fd->vnode->fops->lseek == NULL) return -ENOSYS; result = fd->vnode->fops->lseek(fd, offset); if (result >= 0) fd->pos = result; return result; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* fifo_icap_flush_fifo - This function flushes the FIFOs in the device. @drvdata: a pointer to the drvdata. */
void fifo_icap_flush_fifo(struct hwicap_drvdata *drvdata)
/* fifo_icap_flush_fifo - This function flushes the FIFOs in the device. @drvdata: a pointer to the drvdata. */ void fifo_icap_flush_fifo(struct hwicap_drvdata *drvdata)
{ u32 reg_data; reg_data = in_be32(drvdata->base_address + XHI_CR_OFFSET); out_be32(drvdata->base_address + XHI_CR_OFFSET, reg_data | XHI_CR_FIFO_CLR_MASK); out_be32(drvdata->base_address + XHI_CR_OFFSET, reg_data & (~XHI_CR_FIFO_CLR_MASK)); }
robutest/uclinux
C++
GPL-2.0
60
/* The caller is not required to hold any lock for calling this function. This function updates the chip attention bits for the ring to inform firmware that there are pending work to be done for this ring and requests an interrupt when there is space available in the ring. This function is called when the driver is una...
static void lpfc_sli_update_full_ring(struct lpfc_hba *phba, struct lpfc_sli_ring *pring)
/* The caller is not required to hold any lock for calling this function. This function updates the chip attention bits for the ring to inform firmware that there are pending work to be done for this ring and requests an interrupt when there is space available in the ring. This function is called when the driver is una...
{ int ringno = pring->ringno; pring->flag |= LPFC_CALL_RING_AVAILABLE; wmb(); writel((CA_R0ATT|CA_R0CE_REQ) << (ringno*4), phba->CAregaddr); readl(phba->CAregaddr); pring->stats.iocb_cmd_full++; }
robutest/uclinux
C++
GPL-2.0
60
/* Airpcap wrapper, used to set the channel of an airpcap adapter */
gboolean airpcap_if_set_device_channel(PAirpcapHandle ah, guint ch)
/* Airpcap wrapper, used to set the channel of an airpcap adapter */ gboolean airpcap_if_set_device_channel(PAirpcapHandle ah, guint ch)
{ if (!AirpcapLoaded) return FALSE; return g_PAirpcapSetDeviceChannel(ah,ch); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* rts_ds_steer - Receive traffic steering based on IPv4 or IPv6 TOS or Traffic class respectively. @nic: device private variable Description: The function configures the receive steering to desired receive ring. Return Value: SUCCESS on success and '-1' on failure (endian settings incorrect). */
static int rts_ds_steer(struct s2io_nic *nic, u8 ds_codepoint, u8 ring)
/* rts_ds_steer - Receive traffic steering based on IPv4 or IPv6 TOS or Traffic class respectively. @nic: device private variable Description: The function configures the receive steering to desired receive ring. Return Value: SUCCESS on success and '-1' on failure (endian settings incorrect). */ static int rts_ds_ste...
{ struct XENA_dev_config __iomem *bar0 = nic->bar0; register u64 val64 = 0; if (ds_codepoint > 63) return FAILURE; val64 = RTS_DS_MEM_DATA(ring); writeq(val64, &bar0->rts_ds_mem_data); val64 = RTS_DS_MEM_CTRL_WE | RTS_DS_MEM_CTRL_STROBE_NEW_CMD | RTS_DS_MEM_CTRL_OFFSET(ds_codepoint); writeq(val64, &bar0->r...
robutest/uclinux
C++
GPL-2.0
60
/* START: Virtual Address (U0, P1, or P3) SIZE: Size of the region. */
static void sh3__flush_purge_region(void *start, int size)
/* START: Virtual Address (U0, P1, or P3) SIZE: Size of the region. */ static void sh3__flush_purge_region(void *start, int size)
{ unsigned long v; unsigned long begin, end; begin = (unsigned long)start & ~(L1_CACHE_BYTES-1); end = ((unsigned long)start + size + L1_CACHE_BYTES-1) & ~(L1_CACHE_BYTES-1); for (v = begin; v < end; v+=L1_CACHE_BYTES) { unsigned long data, addr; data = (v & 0xfffffc00); addr = CACHE_OC_ADDRESS_ARRAY | ...
EmcraftSystems/linux-emcraft
C++
Other
266
/* @params pCBParam - Application passed pointer. @params nEvent - Code of the event that triggered the interrupt. @params pArg - Driver passed pointer. */
void SysTick_Handler(void)
/* @params pCBParam - Application passed pointer. @params nEvent - Code of the event that triggered the interrupt. @params pArg - Driver passed pointer. */ void SysTick_Handler(void)
{ if (timer_delay_count != 0u) --timer_delay_count; }
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* Calculates a 32-bit CRC value over the specified data. It uses the CRC32_MPEG2 algorithm: */
uint32_t TbxChecksumCrc32Calculate(uint8_t const *data, size_t len)
/* Calculates a 32-bit CRC value over the specified data. It uses the CRC32_MPEG2 algorithm: */ uint32_t TbxChecksumCrc32Calculate(uint8_t const *data, size_t len)
{ uint32_t result = 0; TBX_ASSERT((data != NULL) && (len > 0U)); if ( (data != NULL) && (len > 0U) ) { result = TBX_CONF_CHECKSUM_CRC32_INITIAL; for (size_t byteIdx = 0U; byteIdx < len; byteIdx++) { result = result ^ ((uint32_t)data[byteIdx] << 24U); for (uint8_t bitIdx = 0U; bitIdx <= 7...
feaser/openblt
C++
GNU General Public License v3.0
601
/* Default C language implementation of a 32x32->32 multiply. This function may be replaced by a platform-specific version for speed. */
INLINE OI_INT32 default_mul_32s_32s_hi(OI_INT32 u, OI_INT32 v)
/* Default C language implementation of a 32x32->32 multiply. This function may be replaced by a platform-specific version for speed. */ INLINE OI_INT32 default_mul_32s_32s_hi(OI_INT32 u, OI_INT32 v)
{ OI_UINT32 u0, v0; OI_INT32 u1, v1, w1, w2, t; u0 = u & 0xFFFF; u1 = u >> 16; v0 = v & 0xFFFF; v1 = v >> 16; t = u0 * v0; t = u1 * v0 + ((OI_UINT32)t >> 16); w1 = t & 0xFFFF; w2 = t >> 16; w1 = u0 * v1 + w1; return u1 * v1 + w2 + (w1 >> 16); }
Nicholas3388/LuaNode
C++
Other
1,055
/* Memory regions need to be registered with the device and queue pairs setup in advanced before the migration starts. This tells us where the RAM blocks are so that we can register them individually. */
static void qemu_rdma_init_one_block(void *host_addr, ram_addr_t block_offset, ram_addr_t length, void *opaque)
/* Memory regions need to be registered with the device and queue pairs setup in advanced before the migration starts. This tells us where the RAM blocks are so that we can register them individually. */ static void qemu_rdma_init_one_block(void *host_addr, ram_addr_t block_offset, ram_addr_t length, void *opaque)
{ __qemu_rdma_add_block(opaque, host_addr, block_offset, length); }
ve3wwg/teensy3_qemu
C
Other
15
/* If Address > 0x0FFFFFFF, then ASSERT(). If StartBit is greater than 7, then ASSERT(). If EndBit is greater than 7, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). If OrData is larger than the bitmask val...
UINT8 EFIAPI PciBitFieldAndThenOr8(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 AndData, IN UINT8 OrData)
/* If Address > 0x0FFFFFFF, then ASSERT(). If StartBit is greater than 7, then ASSERT(). If EndBit is greater than 7, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). If OrData is larger than the bitmask val...
{ return PciWrite8 ( Address, BitFieldAndThenOr8 (PciRead8 (Address), StartBit, EndBit, AndData, OrData) ); }
tianocore/edk2
C++
Other
4,240
/* This function gets the line skip setting used by the Generator in the VTC core. */
void XVtc_GetSkipLine(XVtc *InstancePtr, int *GeneratorChromaSkipPtr)
/* This function gets the line skip setting used by the Generator in the VTC core. */ void XVtc_GetSkipLine(XVtc *InstancePtr, int *GeneratorChromaSkipPtr)
{ u32 FrameEncodeRegValue; Xil_AssertVoid(InstancePtr != NULL); Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); Xil_AssertVoid(GeneratorChromaSkipPtr != NULL); FrameEncodeRegValue = XVtc_ReadReg(InstancePtr->Config.BaseAddress, (XVTC_GFENC_OFFSET)); if (FrameEncodeRegValue & XVTC_ENC_GACLS_M...
ua1arn/hftrx
C++
null
69
/* Enter Power Down mode with co-operated instruction by the Cortex-M3. */
void CLKPWR_PowerDown(void)
/* Enter Power Down mode with co-operated instruction by the Cortex-M3. */ void CLKPWR_PowerDown(void)
{ SCB->SCR = 0x4; LPC_SC->PCON = 0x09; __WFI(); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns a pointer to the allocated buffer on success; otherwise, NULL. */
void* mtd_kmalloc_up_to(const struct mtd_info *mtd, size_t *size)
/* Returns a pointer to the allocated buffer on success; otherwise, NULL. */ void* mtd_kmalloc_up_to(const struct mtd_info *mtd, size_t *size)
{ gfp_t flags = __GFP_NOWARN | __GFP_WAIT | __GFP_NORETRY | __GFP_NO_KSWAPD; size_t min_alloc = max_t(size_t, mtd->writesize, PAGE_SIZE); void *kbuf; *size = min_t(size_t, *size, KMALLOC_MAX_SIZE); while (*size > min_alloc) { kbuf = kmalloc(*size, flags); if (kbuf) return kbuf; *size >>= 1; *si...
4ms/stm32mp1-baremetal
C++
Other
137
/* function : de_rtmx_set_bld_reg_base(unsigned int sel, unsigned int base) description : set de reg base parameters : sel <rtmx select> base <reg base> return : success */
int de_rtmx_set_bld_reg_base(unsigned int sel, void *base)
/* function : de_rtmx_set_bld_reg_base(unsigned int sel, unsigned int base) description : set de reg base parameters : sel <rtmx select> base <reg base> return : success */ int de_rtmx_set_bld_reg_base(unsigned int sel, void *base)
{ DE_INF("sel=%d, base=0x%p\n", sel, base); de200_rtmx[sel].bld_ctl = (struct __bld_reg_t *) base; return 0; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* param base Pointer to the FLEXIO_UART_Type structure. param handle Pointer to the flexio_uart_handle_t structure to store the transfer state. */
void FLEXIO_UART_TransferStopRingBuffer(FLEXIO_UART_Type *base, flexio_uart_handle_t *handle)
/* param base Pointer to the FLEXIO_UART_Type structure. param handle Pointer to the flexio_uart_handle_t structure to store the transfer state. */ void FLEXIO_UART_TransferStopRingBuffer(FLEXIO_UART_Type *base, flexio_uart_handle_t *handle)
{ assert(handle); if (handle->rxState == kFLEXIO_UART_RxIdle) { FLEXIO_UART_DisableInterrupts(base, kFLEXIO_UART_RxDataRegFullInterruptEnable); } handle->rxRingBuffer = NULL; handle->rxRingBufferSize = 0U; handle->rxRingBufferHead = 0U; handle->rxRingBufferTail = 0U; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Extract device path for given HII handle and class guid. */
CHAR16* ExtractDevicePathFromHiiHandle(IN EFI_HII_HANDLE Handle)
/* Extract device path for given HII handle and class guid. */ CHAR16* ExtractDevicePathFromHiiHandle(IN EFI_HII_HANDLE Handle)
{ EFI_STATUS Status; EFI_HANDLE DriverHandle; ASSERT (Handle != NULL); if (Handle == NULL) { return NULL; } Status = gHiiDatabase->GetPackageListHandle (gHiiDatabase, Handle, &DriverHandle); if (EFI_ERROR (Status)) { return NULL; } return ConvertDevicePathToText (DevicePathFromHandle (Driver...
tianocore/edk2
C++
Other
4,240
/* Change Logs: Date Author Notes flybreak the first version. */
static int check_create(volatile __ARM_TPL_mutex_t *__vm, bool recursive=false)
/* Change Logs: Date Author Notes flybreak the first version. */ static int check_create(volatile __ARM_TPL_mutex_t *__vm, bool recursive=false)
{ if (__vm->data == 0) { uintptr_t mut_null = 0; arm_tpl_mutex_struct *mutex_p = (arm_tpl_mutex_struct *)rt_malloc(sizeof(arm_tpl_mutex_struct)); if (mutex_p == nullptr) return -1; if (recursive) mutex_p->mutex = rt_mutex_create("mutexx", RT_IPC_FLAG_PRIO); el...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Retrieves the error dispatch entry with the specified op code. */
static ble_gattc_resume_fn* ble_gattc_resume_dispatch_get(uint8_t op)
/* Retrieves the error dispatch entry with the specified op code. */ static ble_gattc_resume_fn* ble_gattc_resume_dispatch_get(uint8_t op)
{ BLE_HS_DBG_ASSERT(op < BLE_GATT_OP_CNT); return ble_gattc_resume_dispatch[op]; }
Nicholas3388/LuaNode
C++
Other
1,055
/* This code gets the pointer to the variable data. */
UINT8* GetVariableDataPtr(IN VARIABLE_HEADER *Variable, IN VARIABLE_HEADER *VariableHeader, IN BOOLEAN AuthFlag)
/* This code gets the pointer to the variable data. */ UINT8* GetVariableDataPtr(IN VARIABLE_HEADER *Variable, IN VARIABLE_HEADER *VariableHeader, IN BOOLEAN AuthFlag)
{ UINTN Value; Value = (UINTN)GetVariableNamePtr (Variable, AuthFlag); Value += NameSizeOfVariable (VariableHeader, AuthFlag); Value += GET_PAD_SIZE (NameSizeOfVariable (VariableHeader, AuthFlag)); return (UINT8 *)Value; }
tianocore/edk2
C++
Other
4,240
/* Unloads the Lawicel CANUSBDRV DLL and resets the API function pointers. */
static void CanUsbLibUnloadDll(void)
/* Unloads the Lawicel CANUSBDRV DLL and resets the API function pointers. */ static void CanUsbLibUnloadDll(void)
{ canUsbLibFuncOpenPtr = NULL; canUsbLibFuncClosePtr = NULL; canUsbLibFuncWritePtr = NULL; canUsbLibFuncStatusPtr = NULL; canUsbLibFuncSetReceiveCallBackPtr = NULL; canUsbCanHandle = 0; if (canUsbDllHandle != NULL) { (void)FreeLibrary(canUsbDllHandle); canUsbDllHandle = NULL; } }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Check if the supplied point is on EC curve. */
BOOLEAN EFIAPI EcPointIsOnCurve(IN CONST VOID *EcGroup, IN CONST VOID *EcPoint, IN VOID *BnCtx)
/* Check if the supplied point is on EC curve. */ BOOLEAN EFIAPI EcPointIsOnCurve(IN CONST VOID *EcGroup, IN CONST VOID *EcPoint, IN VOID *BnCtx)
{ return EC_POINT_is_on_curve (EcGroup, EcPoint, BnCtx) == 1; }
tianocore/edk2
C++
Other
4,240
/* HID class driver callback function for the processing of HID reports from the host. */
void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t *const HIDInterfaceInfo, const uint8_t ReportID, const uint8_t ReportType, const void *ReportData, const uint16_t ReportSize)
/* HID class driver callback function for the processing of HID reports from the host. */ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t *const HIDInterfaceInfo, const uint8_t ReportID, const uint8_t ReportType, const void *ReportData, const uint16_t ReportSize)
{ uint8_t* Data = (uint8_t*)ReportData; Data[0] ? XMC_GPIO_SetOutputHigh(LED1) : XMC_GPIO_SetOutputLow(LED1); Data[1] ? XMC_GPIO_SetOutputHigh(LED2) : XMC_GPIO_SetOutputLow(LED2); }
remotemcu/remcu-chip-sdks
C++
null
436
/* Returns the next completed dtr with out removing it from work array */
void vxge_hw_channel_dtr_try_complete(struct __vxge_hw_channel *channel, void **dtrh)
/* Returns the next completed dtr with out removing it from work array */ void vxge_hw_channel_dtr_try_complete(struct __vxge_hw_channel *channel, void **dtrh)
{ vxge_assert(channel->compl_index < channel->length); *dtrh = channel->work_arr[channel->compl_index]; prefetch(*dtrh); }
robutest/uclinux
C++
GPL-2.0
60
/* smk_unlbl_ambient - initialize the unlabeled domain @oldambient: previous domain string */
static void smk_unlbl_ambient(char *oldambient)
/* smk_unlbl_ambient - initialize the unlabeled domain @oldambient: previous domain string */ static void smk_unlbl_ambient(char *oldambient)
{ int rc; struct netlbl_audit nai; smk_netlabel_audit_set(&nai); if (oldambient != NULL) { rc = netlbl_cfg_map_del(oldambient, PF_INET, NULL, NULL, &nai); if (rc != 0) printk(KERN_WARNING "%s:%d remove rc = %d\n", __func__, __LINE__, rc); } rc = netlbl_cfg_unlbl_map_add(smack_net_ambient, PF_INET...
EmcraftSystems/linux-emcraft
C++
Other
266
/* Disable Auto-Reload Buffering. This causes the counter to be loaded immediately with a new count value when the auto-reload register is written, so that the new value becomes effective for the current count cycle rather than for the cycle following an update event. */
void timer_disable_preload(uint32_t timer_peripheral)
/* Disable Auto-Reload Buffering. This causes the counter to be loaded immediately with a new count value when the auto-reload register is written, so that the new value becomes effective for the current count cycle rather than for the cycle following an update event. */ void timer_disable_preload(uint32_t timer_perip...
{ TIM_CR1(timer_peripheral) &= ~TIM_CR1_ARPE; }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* simple_strtoll - convert a string to a signed long long @cp: The start of the string @endp: A pointer to the end of the parsed string will be placed here @base: The number base to use */
long long simple_strtoll(const char *cp, char **endp, unsigned int base)
/* simple_strtoll - convert a string to a signed long long @cp: The start of the string @endp: A pointer to the end of the parsed string will be placed here @base: The number base to use */ long long simple_strtoll(const char *cp, char **endp, unsigned int base)
{ if (*cp == '-') return -simple_strtoull(cp + 1, endp, base); return simple_strtoull(cp, endp, base); }
robutest/uclinux
C++
GPL-2.0
60
/* Gets a data element from the SSI receive FIFO. */
int32_t SSIDataGetNonBlocking(uint32_t ui32Base, uint32_t *pui32Data)
/* Gets a data element from the SSI receive FIFO. */ int32_t SSIDataGetNonBlocking(uint32_t ui32Base, uint32_t *pui32Data)
{ ASSERT(_SSIBaseValid(ui32Base)); if(HWREG(ui32Base + SSI_O_SR) & SSI_SR_RNE) { *pui32Data = HWREG(ui32Base + SSI_O_DR); return(1); } else { return(0); } }
feaser/openblt
C++
GNU General Public License v3.0
601
/* ps2_adjust_timeout() is called after receiving 1st byte of command response and tries to reduce remaining timeout to speed up command completion. */
static int ps2_adjust_timeout(struct ps2dev *ps2dev, int command, int timeout)
/* ps2_adjust_timeout() is called after receiving 1st byte of command response and tries to reduce remaining timeout to speed up command completion. */ static int ps2_adjust_timeout(struct ps2dev *ps2dev, int command, int timeout)
{ switch (command) { case PS2_CMD_RESET_BAT: if (timeout > msecs_to_jiffies(100)) timeout = msecs_to_jiffies(100); break; case PS2_CMD_GETID: if (ps2dev->cmdbuf[1] == 0xaa) { serio_pause_rx(ps2dev->serio); ps2dev->flags = 0; serio_continue_rx(ps2dev->serio); timeout = 0; } if (!p...
robutest/uclinux
C++
GPL-2.0
60
/* Checks the argtable array for NULL entries and returns 1 if any are found, zero otherwise. */
int arg_nullcheck(void **argtable)
/* Checks the argtable array for NULL entries and returns 1 if any are found, zero otherwise. */ int arg_nullcheck(void **argtable)
{ struct arg_hdr * *table = (struct arg_hdr * *)argtable; int tabindex; if (!table) return 1; tabindex = 0; do { if (!table[tabindex]) return 1; } while(!(table[tabindex++]->flag & ARG_TERMINATOR)); return 0; }
retro-esp32/RetroESP32
C++
Creative Commons Attribution Share Alike 4.0 International
581
/* Initializes a Watchdog Timer configuration structure to defaults. The default configuration is as follows: */
void wdt_get_config_defaults(struct wdt_config *const cfg)
/* Initializes a Watchdog Timer configuration structure to defaults. The default configuration is as follows: */ void wdt_get_config_defaults(struct wdt_config *const cfg)
{ Assert(cfg); cfg->clk_src = WDT_CLK_SRC_RCSYS; cfg->wdt_mode = WDT_MODE_BASIC; cfg->wdt_int = WDT_INT_DIS; cfg->timeout_period = WDT_PERIOD_131072_CLK; cfg->window_period = WDT_PERIOD_NONE; cfg->disable_flash_cali = true; cfg->disable_wdt_after_reset = true; cfg->always_on = false; }
remotemcu/remcu-chip-sdks
C++
null
436
/* cancel_wbuf_timer - cancel write-buffer timer. @wbuf: write-buffer descriptor */
static void cancel_wbuf_timer_nolock(struct ubifs_wbuf *wbuf)
/* cancel_wbuf_timer - cancel write-buffer timer. @wbuf: write-buffer descriptor */ static void cancel_wbuf_timer_nolock(struct ubifs_wbuf *wbuf)
{ if (wbuf->no_timer) return; wbuf->need_sync = 0; hrtimer_cancel(&wbuf->timer); }
robutest/uclinux
C++
GPL-2.0
60
/* Check if Transmit interrupt is enabled @rmtoll IER TIE LL_SWPMI_IsEnabledIT_TX. */
uint32_t LL_SWPMI_IsEnabledIT_TX(SWPMI_TypeDef *SWPMIx)
/* Check if Transmit interrupt is enabled @rmtoll IER TIE LL_SWPMI_IsEnabledIT_TX. */ uint32_t LL_SWPMI_IsEnabledIT_TX(SWPMI_TypeDef *SWPMIx)
{ return ((READ_BIT(SWPMIx->IER, SWPMI_IER_TIE) == (SWPMI_IER_TIE)) ? 1UL : 0UL); }
remotemcu/remcu-chip-sdks
C++
null
436
/* Returns: (transfer full): a new #GFile. Free the returned object with g_object_unref(). */
GFile* g_file_new_for_commandline_arg(const char *arg)
/* Returns: (transfer full): a new #GFile. Free the returned object with g_object_unref(). */ GFile* g_file_new_for_commandline_arg(const char *arg)
{ g_return_val_if_fail (arg != NULL, NULL); return new_for_cmdline_arg (arg, NULL); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This function calls qdio_shutdown() for @cdev with method @how. and qdio_free(). The qdio_free() return value is ignored since !irq_ptr is already checked. */
int qdio_cleanup(struct ccw_device *cdev, int how)
/* This function calls qdio_shutdown() for @cdev with method @how. and qdio_free(). The qdio_free() return value is ignored since !irq_ptr is already checked. */ int qdio_cleanup(struct ccw_device *cdev, int how)
{ struct qdio_irq *irq_ptr = cdev->private->qdio_data; int rc; if (!irq_ptr) return -ENODEV; rc = qdio_shutdown(cdev, how); qdio_free(cdev); return rc; }
robutest/uclinux
C++
GPL-2.0
60
/* Synchronous API to obtain the firmware version currently running on the WINC IC. */
sint8 m2m_wifi_get_firmware_version(tstrM2mRev *pstrRev)
/* Synchronous API to obtain the firmware version currently running on the WINC IC. */ sint8 m2m_wifi_get_firmware_version(tstrM2mRev *pstrRev)
{ sint8 ret = M2M_SUCCESS; ret = hif_chip_wake(); if(ret == M2M_SUCCESS) { ret = nm_get_firmware_full_info(pstrRev); hif_chip_sleep(); } return ret; }
remotemcu/remcu-chip-sdks
C++
null
436
/* read the pin's value (works even if it's not muxed as a gpio). */
int at91_get_pio_value(unsigned port, unsigned pin)
/* read the pin's value (works even if it's not muxed as a gpio). */ int at91_get_pio_value(unsigned port, unsigned pin)
{ struct at91_port *at91_port = at91_pio_get_port(port); if (at91_port && (pin < GPIO_PER_BANK)) return at91_get_port_value(at91_port, pin); return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* i5000_clear_error Retrieve any error from the hardware but do NOT process that error. Used for 'clearing' out of previous errors Called by the Core module. */
static void i5000_clear_error(struct mem_ctl_info *mci)
/* i5000_clear_error Retrieve any error from the hardware but do NOT process that error. Used for 'clearing' out of previous errors Called by the Core module. */ static void i5000_clear_error(struct mem_ctl_info *mci)
{ struct i5000_error_info info; i5000_get_error_info(mci, &info); }
robutest/uclinux
C++
GPL-2.0
60
/* Returns the variable MTRR count for the CPU. */
UINT32 EFIAPI GetVariableMtrrCount(VOID)
/* Returns the variable MTRR count for the CPU. */ UINT32 EFIAPI GetVariableMtrrCount(VOID)
{ if (!IsMtrrSupported ()) { return 0; } return GetVariableMtrrCountWorker (); }
tianocore/edk2
C++
Other
4,240
/* Enable Peripheral Clock in running mode. Enable the clock on particular peripheral. */
void rcc_periph_clock_enable(enum rcc_periph_clken clken)
/* Enable Peripheral Clock in running mode. Enable the clock on particular peripheral. */ void rcc_periph_clock_enable(enum rcc_periph_clken clken)
{ _RCC_REG(clken) |= _RCC_BIT(clken); }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* Spawn thread with forever delay and highest priority. Create an user thread with forever delay and yield the current thread. Even though the current thread has yielded, the thread will not be put in ready queue since it has forever delay, the thread is explicitly started using k_thread_start() and checked if thread...
ZTEST(threads_lifecycle, test_threads_spawn_forever)
/* Spawn thread with forever delay and highest priority. Create an user thread with forever delay and yield the current thread. Even though the current thread has yielded, the thread will not be put in ready queue since it has forever delay, the thread is explicitly started using k_thread_start() and checked if thread...
{ tp2 = 10; k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE, thread_entry_delay, NULL, NULL, NULL, K_HIGHEST_THREAD_PRIO, K_USER, K_FOREVER); k_yield(); zassert_true(tp2 == 10); k_thread_start(tid); k_yield(); zassert_true(tp2 == 100); k_thread_abort(tid); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* This function is called from the iocb ring event handlers when put pointer is ahead of the get pointer for a ring. This function signal an error attention condition to the worker thread and the worker thread will transition the HBA to offline state. */
static void lpfc_sli_rsp_pointers_error(struct lpfc_hba *phba, struct lpfc_sli_ring *pring)
/* This function is called from the iocb ring event handlers when put pointer is ahead of the get pointer for a ring. This function signal an error attention condition to the worker thread and the worker thread will transition the HBA to offline state. */ static void lpfc_sli_rsp_pointers_error(struct lpfc_hba *phba, ...
{ struct lpfc_pgp *pgp = &phba->port_gp[pring->ringno]; lpfc_printf_log(phba, KERN_ERR, LOG_SLI, "0312 Ring %d handler: portRspPut %d " "is bigger than rsp ring %d\n", pring->ringno, le32_to_cpu(pgp->rspPutInx), pring->numRiocb); phba->link_state = LPFC_HBA_ERROR; phba->work_ha |= HA_ERATT; phba->work_...
robutest/uclinux
C++
GPL-2.0
60
/* prev_priority control...this will be used in memory reclaim path. */
int mem_cgroup_get_reclaim_priority(struct mem_cgroup *mem)
/* prev_priority control...this will be used in memory reclaim path. */ int mem_cgroup_get_reclaim_priority(struct mem_cgroup *mem)
{ int prev_priority; spin_lock(&mem->reclaim_param_lock); prev_priority = mem->prev_priority; spin_unlock(&mem->reclaim_param_lock); return prev_priority; }
robutest/uclinux
C++
GPL-2.0
60
/* Sets the number of wait states of flash read accesses. */
void flashcalw_set_wait_state(uint32_t wait_state)
/* Sets the number of wait states of flash read accesses. */ void flashcalw_set_wait_state(uint32_t wait_state)
{ HFLASHC->FLASHCALW_FCR = (HFLASHC->FLASHCALW_FCR & ~FLASHCALW_FCR_FWS) | (wait_state ? FLASHCALW_FCR_FWS_1 : FLASHCALW_FCR_FWS_0); }
remotemcu/remcu-chip-sdks
C++
null
436
/* net manage config for gprs device(developed not yet, reserved) */
int netmgr_config_gprs(netmgr_hdl_t hdl, int mode)
/* net manage config for gprs device(developed not yet, reserved) */ int netmgr_config_gprs(netmgr_hdl_t hdl, int mode)
{ int ret = -1; param_gprs_setting_t param; gprs_setting_t *config = &param.config; aos_check_return_einval(hdl); param.hdl = hdl; config->foo = mode; uservice_call_sync(netmgr_svc.srv, API_GPRS_CONFIG, &param, &ret, sizeof(int)); return ret; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* The receiving device may be in another namespace, so we have to clear all information in the skb that could impact namespace isolation. */
int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
/* The receiving device may be in another namespace, so we have to clear all information in the skb that could impact namespace isolation. */ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
{ skb_orphan(skb); if (!(dev->flags & IFF_UP)) return NET_RX_DROP; if (skb->len > (dev->mtu + dev->hard_header_len)) return NET_RX_DROP; skb_dst_drop(skb); skb->tstamp.tv64 = 0; skb->pkt_type = PACKET_HOST; skb->protocol = eth_type_trans(skb, dev); skb->mark = 0; secpath_reset(skb); nf_reset(skb); return...
EmcraftSystems/linux-emcraft
C++
Other
266
/* Write a data to the slave when the bus is idle, and waiting for all bus transmiton complete.(Write Step1) This function is always used in thread mode. */
unsigned long I2CMasterWriteS1(unsigned long ulBase, unsigned char ucSlaveAddr, unsigned char ucData, xtBoolean bEndTransmition)
/* Write a data to the slave when the bus is idle, and waiting for all bus transmiton complete.(Write Step1) This function is always used in thread mode. */ unsigned long I2CMasterWriteS1(unsigned long ulBase, unsigned char ucSlaveAddr, unsigned char ucData, xtBoolean bEndTransmition)
{ unsigned long ulStatus; xASSERT((ulBase == I2C0_BASE)); xASSERT(!(ucSlaveAddr & 0x80)); I2CMasterWriteRequestS1(ulBase, ucSlaveAddr, ucData, xfalse); do { ulStatus = I2CStatusGet(ulBase); if(xHWREG(ulBase + I2C_CSR) & 0x0F00) break; } while(!(ulStatus == I...
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Handling messages not implemented in the default handler nor in the SerialUSB handler. */
static bool requests_hook(USBDriver *usbp)
/* Handling messages not implemented in the default handler nor in the SerialUSB handler. */ static bool requests_hook(USBDriver *usbp)
{ usbSetupTransfer(usbp, NULL, 0, NULL); return true; } return sduRequestsHook(usbp); }
nanoframework/nf-interpreter
C++
MIT License
293
/* Indicates rx frame has non integer multiple of bytes. (odd nibbles). Retruns true if dribbling error in rx frame. */
bool synopGMAC_is_frame_dribbling_errors(u32 status)
/* Indicates rx frame has non integer multiple of bytes. (odd nibbles). Retruns true if dribbling error in rx frame. */ bool synopGMAC_is_frame_dribbling_errors(u32 status)
{ return ((status & DescRxDribbling) == DescRxDribbling); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Finalizes a hash operation in progress and returns calculation result. The output is final with any necessary padding added by the function. The hash may not be further updated or extended after HashFinal(). */
EFI_STATUS EFIAPI BaseCrypto2HashFinal(IN CONST EFI_HASH2_PROTOCOL *This, IN OUT EFI_HASH2_OUTPUT *Hash)
/* Finalizes a hash operation in progress and returns calculation result. The output is final with any necessary padding added by the function. The hash may not be further updated or extended after HashFinal(). */ EFI_STATUS EFIAPI BaseCrypto2HashFinal(IN CONST EFI_HASH2_PROTOCOL *This, IN OUT EFI_HASH2_OUTPUT *Hash)
{ EFI_HASH_INFO *HashInfo; VOID *HashCtx; BOOLEAN Ret; HASH2_INSTANCE_DATA *Instance; if ((This == NULL) || (Hash == NULL)) { return EFI_INVALID_PARAMETER; } Instance = HASH2_INSTANCE_DATA_FROM_THIS (This); if ((Instance->HashContext == NULL) || (Instance->HashIn...
tianocore/edk2
C++
Other
4,240
/* Make sure to use the correct group definitions as the older bitmask definitions for */
int nl_socket_add_memberships(struct nl_sock *sk, int group,...)
/* Make sure to use the correct group definitions as the older bitmask definitions for */ int nl_socket_add_memberships(struct nl_sock *sk, int group,...)
{ int err; va_list ap; if (sk->s_fd == -1) return -NLE_BAD_SOCK; va_start(ap, group); while (group != 0) { if (group < 0) return -NLE_INVAL; err = setsockopt(sk->s_fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP, &group, sizeof(group)); if (err < 0) return -nl_syserr2nlerr(errno); group = va_arg(ap,...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Looks at a memory address and categorizes it. */
DMA_MemType_t dma_mem_type(void *addr)
/* Looks at a memory address and categorizes it. */ DMA_MemType_t dma_mem_type(void *addr)
{ unsigned long addrVal = (unsigned long)addr; if (addrVal >= VMALLOC_END) { return DMA_MEM_TYPE_DMA; } if (is_vmalloc_addr(addr)) { return DMA_MEM_TYPE_VMALLOC; } if (addrVal >= PAGE_OFFSET) { return DMA_MEM_TYPE_KMALLOC; } return DMA_MEM_TYPE_USER; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Reads and returns the current value of DR6. This function is only available on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on X64. */
UINTN EFIAPI AsmReadDr6(VOID)
/* Reads and returns the current value of DR6. This function is only available on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on X64. */ UINTN EFIAPI AsmReadDr6(VOID)
{ UINTN Data; __asm__ __volatile__ ( "movl %%dr6, %0" : "=r" (Data) ); return Data; }
tianocore/edk2
C++
Other
4,240
/* Disable USB Device Endpoint Parameters: EPNum: Device Endpoint Number EPNum.0..3: Address EPNum.7: Dir Return Value: None */
void USBD_DisableEP(uint32_t EPNum)
/* Disable USB Device Endpoint Parameters: EPNum: Device Endpoint Number EPNum.0..3: Address EPNum.7: Dir Return Value: None */ void USBD_DisableEP(uint32_t EPNum)
{ UDPHS->UDPHS_EPT[EPNum & 0x0F].UDPHS_EPTCTLDIS = (0x1 << 0); eptsta_copy[EPNum & 0x0F] = UDPHS->UDPHS_EPT[EPNum].UDPHS_EPTSETSTA; }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* Sets the address of the UART Rx MASK. */
void UART_SetRXMASK(UART_TypeDef *uart, u8 address)
/* Sets the address of the UART Rx MASK. */ void UART_SetRXMASK(UART_TypeDef *uart, u8 address)
{ MODIFY_REG(uart->RXMR, UART_RXMR_MASK, address); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This is the code that gets called on processor reset. To initialize the device, and call the main() routine. */
void Reset_Handler(void)
/* This is the code that gets called on processor reset. To initialize the device, and call the main() routine. */ void Reset_Handler(void)
{ uint32_t *pSrc, *pDest; pSrc = &_etext; pDest = &_srelocate; if (pSrc != pDest) { for (; pDest < &_erelocate;) { *pDest++ = *pSrc++; } } for (pDest = &_szero; pDest < &_ezero;) { *pDest++ = 0; ...
memfault/zero-to-main
C++
null
200
/* Read the specified image into an ABGR-format raster. Use bottom left origin for raster by default. */
int TIFFReadRGBAImage(TIFF *tif, uint32 rwidth, uint32 rheight, uint32 *raster, int stop)
/* Read the specified image into an ABGR-format raster. Use bottom left origin for raster by default. */ int TIFFReadRGBAImage(TIFF *tif, uint32 rwidth, uint32 rheight, uint32 *raster, int stop)
{ return TIFFReadRGBAImageOriented(tif, rwidth, rheight, raster, ORIENTATION_BOTLEFT, stop); }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* cdns3_ep_inc_enq - increment endpoint's enqueue pointer @priv_ep: The endpoint whose enqueue pointer we're incrementing */
static void cdns3_ep_inc_enq(struct cdns3_endpoint *priv_ep)
/* cdns3_ep_inc_enq - increment endpoint's enqueue pointer @priv_ep: The endpoint whose enqueue pointer we're incrementing */ static void cdns3_ep_inc_enq(struct cdns3_endpoint *priv_ep)
{ priv_ep->free_trbs--; cdns3_ep_inc_trb(&priv_ep->enqueue, &priv_ep->pcs, priv_ep->num_trbs); }
4ms/stm32mp1-baremetal
C++
Other
137
/* stts751_handle_interrupt - handle the thsld event read data and call handler if registered any */
static void stts751_handle_interrupt(const struct device *dev)
/* stts751_handle_interrupt - handle the thsld event read data and call handler if registered any */ static void stts751_handle_interrupt(const struct device *dev)
{ struct stts751_data *stts751 = dev->data; const struct stts751_config *cfg = dev->config; stts751_status_t status; stts751_status_reg_get(stts751->ctx, &status); if (stts751->thsld_handler != NULL && (status.t_high || status.t_low)) { stts751->thsld_handler(dev, stts751->thsld_trigger); } gpio_pin_inter...
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Extracts the Bluetooth connection from a net_buf's user data. */
static struct bt_conn* smp_bt_conn_from_pkt(const struct net_buf *nb)
/* Extracts the Bluetooth connection from a net_buf's user data. */ static struct bt_conn* smp_bt_conn_from_pkt(const struct net_buf *nb)
{ struct smp_bt_user_data *ud = net_buf_user_data(nb); if (!ud->conn) { return NULL; } return ud->conn; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* scsi_scan_host - scan the given adapter @shost: adapter to scan */
void scsi_scan_host(struct Scsi_Host *shost)
/* scsi_scan_host - scan the given adapter @shost: adapter to scan */ void scsi_scan_host(struct Scsi_Host *shost)
{ struct task_struct *p; struct async_scan_data *data; if (strncmp(scsi_scan_type, "none", 4) == 0) return; data = scsi_prep_async_scan(shost); if (!data) { do_scsi_scan_host(shost); return; } p = kthread_run(do_scan_async, data, "scsi_scan_%d", shost->host_no); if (IS_ERR(p)) do_scan_async(data); }
robutest/uclinux
C++
GPL-2.0
60
/* param base SPI peripheral address. return return configurations which contain datawidth and SSEL numbers. return data type is a pointer of spi_config_t. */
void* SPI_GetConfig(SPI_Type *base)
/* param base SPI peripheral address. return return configurations which contain datawidth and SSEL numbers. return data type is a pointer of spi_config_t. */ void* SPI_GetConfig(SPI_Type *base)
{ uint32_t instance; instance = SPI_GetInstance(base); return &g_configs[instance]; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Curl_write_plain() is an internal write function that sends data to the server using plain sockets only. Otherwise meant to have the exact same proto as Curl_write() */
CURLcode Curl_write_plain(struct connectdata *conn, curl_socket_t sockfd, const void *mem, size_t len, ssize_t *written)
/* Curl_write_plain() is an internal write function that sends data to the server using plain sockets only. Otherwise meant to have the exact same proto as Curl_write() */ CURLcode Curl_write_plain(struct connectdata *conn, curl_socket_t sockfd, const void *mem, size_t len, ssize_t *written)
{ ssize_t bytes_written; CURLcode result; int num = (sockfd == conn->sock[SECONDARYSOCKET]); bytes_written = Curl_send_plain(conn, num, mem, len, &result); *written = bytes_written; return result; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Returns the number of Markers of this MPA FPDU. The endpoint is either the Initiator or the Responder. */
static guint32 number_of_markers(mpa_state_t *state, struct tcpinfo *tcpinfo, guint8 endpoint)
/* Returns the number of Markers of this MPA FPDU. The endpoint is either the Initiator or the Responder. */ static guint32 number_of_markers(mpa_state_t *state, struct tcpinfo *tcpinfo, guint8 endpoint)
{ guint32 size; guint32 offset; size = fpdu_total_length(tcpinfo); offset = get_first_marker_offset(state, tcpinfo, endpoint); if (offset < size) { return ((size - offset) / MPA_MARKER_INTERVAL)+1; } else { return 0; } }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* If 8-bit MMIO register operations are not supported, then ASSERT(). */
UINT8 EFIAPI S3MmioRead8(IN UINTN Address)
/* If 8-bit MMIO register operations are not supported, then ASSERT(). */ UINT8 EFIAPI S3MmioRead8(IN UINTN Address)
{ return InternalSaveMmioWrite8ValueToBootScript (Address, MmioRead8 (Address)); }
tianocore/edk2
C++
Other
4,240
/* Atomically swap in the new signal mask, and wait for a signal. */
asmlinkage int sys_sigsuspend(old_sigset_t mask, unsigned long r3, unsigned long r4, unsigned long r5, unsigned long r6, unsigned long r7, struct pt_regs *regs)
/* Atomically swap in the new signal mask, and wait for a signal. */ asmlinkage int sys_sigsuspend(old_sigset_t mask, unsigned long r3, unsigned long r4, unsigned long r5, unsigned long r6, unsigned long r7, struct pt_regs *regs)
{ sigset_t saveset; mask &= _BLOCKABLE; spin_lock_irq(&current->sighand->siglock); saveset = current->blocked; siginitset(&current->blocked, mask); recalc_sigpending(); spin_unlock_irq(&current->sighand->siglock); REF_REG_RET = -EINTR; while (1) { current->state = TASK_INTERRUPTIBLE; schedule(); set_rest...
EmcraftSystems/linux-emcraft
C++
Other
266
/* Enables LIN Function mode on the specified UART. */
void UARTLINEnable(unsigned long ulBase)
/* Enables LIN Function mode on the specified UART. */ void UARTLINEnable(unsigned long ulBase)
{ xASSERT((ulBase == UART0_BASE) || (ulBase == UART1_BASE) || (ulBase == UART2_BASE) ); xHWREGB(ulBase + UART_012_S2) |= (unsigned char)(UART_012_S2_LBKDE); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Apply a very good linear approximation of the Callendar-Van Dusen equation to convert the RTD resistance to temperature: */
static double calculate_temperature(double resistance, double resistance_0)
/* Apply a very good linear approximation of the Callendar-Van Dusen equation to convert the RTD resistance to temperature: */ static double calculate_temperature(double resistance, double resistance_0)
{ double temperature; temperature = (resistance - resistance_0) / (resistance_0 * RTD_A); return temperature; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Stop the PWM of the PWM module. The */
void PWMStop(unsigned long ulBase, unsigned long ulChannel)
/* Stop the PWM of the PWM module. The */ void PWMStop(unsigned long ulBase, unsigned long ulChannel)
{ unsigned long ulChannelTemp; ulChannelTemp = (ulBase == PWMA_BASE) ? ulChannel : (ulChannel - 4); xASSERT(ulBase == PWMA_BASE); xASSERT(((ulChannelTemp >= 0) || (ulChannelTemp <= 3))); xHWREG(ulBase + PWM_PCR) &= ~(PWM_PCR_CH0EN << (ulChannelTemp << 3)); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Initializes the RTC used to display the help message. */
static void ui_display_init_rtc(void)
/* Initializes the RTC used to display the help message. */ static void ui_display_init_rtc(void)
{ irq_register_handler(display_rtc_irq, DISPLAY_RTC_IRQ, DISPLAY_RTC_IRQ_PRIORITY); rtc_init(&AVR32_RTC, RTC_OSC_RC, RTC_PSEL_RC_1_76HZ - 1); rtc_enable_wake_up(&AVR32_RTC); rtc_set_top_value(&AVR32_RTC, 0); rtc_enable_interrupt(&AVR32_RTC); rtc_enable(&AVR32_RTC); }
remotemcu/remcu-chip-sdks
C++
null
436
/* Returns a string describing the current filesystem, or the sentinel "unsupported" for any unrecognised filesystem. */
const char* fs_get_type_name(void)
/* Returns a string describing the current filesystem, or the sentinel "unsupported" for any unrecognised filesystem. */ const char* fs_get_type_name(void)
{ return fs_get_info(fs_type)->name; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Output a single byte to the serial port. */
void serial_putc(const char c)
/* Output a single byte to the serial port. */ void serial_putc(const char c)
{ volatile unsigned char *fifo; if (c == '\n') serial_putc ('\r'); fifo = (volatile unsigned char *) &(serial_reg_ch1->fifo); TXWAITRDY (serial_reg_ch1); *fifo = c; }
EmcraftSystems/u-boot
C++
Other
181
/* Free a socket. The socket's netconn must have been delete before! */
static void free_socket(lwIP_sock *sock)
/* Free a socket. The socket's netconn must have been delete before! */ static void free_socket(lwIP_sock *sock)
{ void *lastdata = NULL; sock->conn = NULL; sock->recv_data_len = 0; sock->recv_index = 0; sock->send_buffer = NULL; sock->send_index = 0; }
nodemcu/nodemcu-firmware
C++
MIT License
7,566
/* Disable Specific USB Interrupts. Note that the NVIC must be enabled and properly configured for the interrupt to be routed to the CPU. */
void usb_disable_interrupts(enum usb_interrupt ints, enum usb_ep_interrupt rx_ints, enum usb_ep_interrupt tx_ints)
/* Disable Specific USB Interrupts. Note that the NVIC must be enabled and properly configured for the interrupt to be routed to the CPU. */ void usb_disable_interrupts(enum usb_interrupt ints, enum usb_ep_interrupt rx_ints, enum usb_ep_interrupt tx_ints)
{ USB_IE &= ~ints; USB_RXIE &= ~rx_ints; USB_TXIE &= ~tx_ints; }
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* param base Pointer to the FlexIO simulated peripheral type. retval kStatus_Success Successfully create the handle. retval kStatus_OutOfRange The FlexIO type/handle/ISR table out of range. */
status_t FLEXIO_UnregisterHandleIRQ(void *base)
/* param base Pointer to the FlexIO simulated peripheral type. retval kStatus_Success Successfully create the handle. retval kStatus_OutOfRange The FlexIO type/handle/ISR table out of range. */ status_t FLEXIO_UnregisterHandleIRQ(void *base)
{ assert(base != NULL); uint8_t index; for (index = 0U; index < (uint8_t)FLEXIO_HANDLE_COUNT; index++) { if (s_flexioType[index] == base) { s_flexioType[index] = NULL; s_flexioHandle[index] = NULL; s_flexioIsr[index] = NULL; break; ...
eclipse-threadx/getting-started
C++
Other
310
/* Set the watchdog time interval. Counter is 32 bit. */
static int designware_wdt_settimeout(unsigned int timeout)
/* Set the watchdog time interval. Counter is 32 bit. */ static int designware_wdt_settimeout(unsigned int timeout)
{ signed int i; i = (log_2_n_round_up(timeout * CONFIG_DW_WDT_CLOCK_KHZ)) - 16; if (i > 15) i = 15; if (i < 0) i = 0; writel((i | (i << 4)), (CONFIG_DW_WDT_BASE + DW_WDT_TORR)); return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Simple interface to ip_output_if. It finds the outgoing network interface and calls upon ip_output_if to do the actual work. */
err_t ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, u8_t ttl, u8_t tos, u8_t proto)
/* Simple interface to ip_output_if. It finds the outgoing network interface and calls upon ip_output_if to do the actual work. */ err_t ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, u8_t ttl, u8_t tos, u8_t proto)
{ struct netif *netif; if ((netif = ip_route(dest)) == NULL) { return ERR_RTE; } return ip_output_if(p, src, dest, ttl, tos, proto, netif); }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Process a CPL_ACT_OPEN_RPL message: -> host Handle active open failures. */
static int act_open_rpl_status_to_errno(int status)
/* Process a CPL_ACT_OPEN_RPL message: -> host Handle active open failures. */ static int act_open_rpl_status_to_errno(int status)
{ switch (status) { case CPL_ERR_CONN_RESET: return -ECONNREFUSED; case CPL_ERR_ARP_MISS: return -EHOSTUNREACH; case CPL_ERR_CONN_TIMEDOUT: return -ETIMEDOUT; case CPL_ERR_TCAM_FULL: return -ENOMEM; case CPL_ERR_CONN_EXIST: cxgb3i_log_error("ACTIVE_OPEN_RPL: 4-tuple in use\n"); return -EADDRINUSE; de...
robutest/uclinux
C++
GPL-2.0
60
/* Attribute read call back for the Server Characteristic Configuration attribute. */
static ssize_t read_server_cha_con(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset)
/* Attribute read call back for the Server Characteristic Configuration attribute. */ static ssize_t read_server_cha_con(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset)
{ const uint16_t *value = attr->user_data; uint16_t server_cha_con_conv = sys_cpu_to_le16(*value); return bt_gatt_attr_read(conn, attr, buf, len, offset, &server_cha_con_conv, sizeof(server_cha_con_conv)); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Enables or disables the specified SRAM1/2 parity error interrupts. */
void RCC_ConfigSRAMParityErrorInt(uint32_t SramErrorInt, FunctionalState Cmd)
/* Enables or disables the specified SRAM1/2 parity error interrupts. */ void RCC_ConfigSRAMParityErrorInt(uint32_t SramErrorInt, FunctionalState Cmd)
{ assert_param(IS_RCC_SRAMERRORINT(SramErrorInt)); assert_param(IS_FUNCTIONAL_STATE(Cmd)); if (Cmd != DISABLE) { RCC->SRAM_CTRLSTS |= SramErrorInt; } else { RCC->SRAM_CTRLSTS &= (~SramErrorInt); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* stb0899_dvbs2_calc_dev compute the correction to be applied to symbol rate */
static u32 stb0899_dvbs2_calc_dev(struct stb0899_state *state)
/* stb0899_dvbs2_calc_dev compute the correction to be applied to symbol rate */ static u32 stb0899_dvbs2_calc_dev(struct stb0899_state *state)
{ struct stb0899_internal *internal = &state->internal; u32 dec_ratio, correction, master_clk, srate; dec_ratio = (internal->master_clk * 2) / (5 * internal->srate); dec_ratio = (dec_ratio == 0) ? 1 : dec_ratio; master_clk = internal->master_clk / 1000; srate = internal->srate / 1000; correction = (512 * master_...
robutest/uclinux
C++
GPL-2.0
60
/* Polls the serial device and feeds the IP layer with incoming packets. */
void slipif_poll(struct netif *netif)
/* Polls the serial device and feeds the IP layer with incoming packets. */ void slipif_poll(struct netif *netif)
{ u8_t c; struct slipif_priv *priv; LWIP_ASSERT("netif != NULL", (netif != NULL)); LWIP_ASSERT("netif->state != NULL", (netif->state != NULL)); priv = (struct slipif_priv *)netif->state; while (sio_tryread(priv->sd, &c, 1) > 0) { slipif_rxbyte_input(netif, c); } }
ua1arn/hftrx
C++
null
69
/* Draws a single pixel at the specified X/Y location. */
void lcdDrawPixel(uint16_t x, uint16_t y, uint16_t color)
/* Draws a single pixel at the specified X/Y location. */ void lcdDrawPixel(uint16_t x, uint16_t y, uint16_t color)
{ if ((x >= ssd1331Properties.width) || (y >= ssd1331Properties.height)) return; ssd1331SetCursor((uint8_t)x, (uint8_t)y); DATA(color >> 8); DATA(color); }
microbuilder/LPC1343CodeBase
C++
Other
73
/* param base ENET peripheral base address. param phyAddr The PHY address. param phyReg The PHY register. Range from 0 ~ 31. param operation The write operation. param data The data written to PHY. */
void ENET_StartSMIWrite(ENET_Type *base, uint32_t phyAddr, uint32_t phyReg, enet_mii_write_t operation, uint32_t data)
/* param base ENET peripheral base address. param phyAddr The PHY address. param phyReg The PHY register. Range from 0 ~ 31. param operation The write operation. param data The data written to PHY. */ void ENET_StartSMIWrite(ENET_Type *base, uint32_t phyAddr, uint32_t phyReg, enet_mii_write_t operation, uint32_t data)
{ uint32_t mmfr = 0; mmfr = ENET_MMFR_ST(1U) | ENET_MMFR_OP(operation) | ENET_MMFR_PA(phyAddr) | ENET_MMFR_RA(phyReg) | ENET_MMFR_TA(2U) | (data & 0xFFFFU); base->MMFR = mmfr; }
eclipse-threadx/getting-started
C++
Other
310