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
/* Perform a non-blocking write of 16 words of data to the SHA/MD5 module. */
bool SHAMD5DataWriteNonBlocking(uint32_t ui32Base, uint32_t *pui32Src)
/* Perform a non-blocking write of 16 words of data to the SHA/MD5 module. */ bool SHAMD5DataWriteNonBlocking(uint32_t ui32Base, uint32_t *pui32Src)
{ uint32_t ui32Counter; ASSERT(ui32Base == SHAMD5_BASE); if((HWREG(ui32Base + SHAMD5_O_IRQSTATUS) & SHAMD5_INT_INPUT_READY) == 0) { return(false); } for(ui32Counter = 0; ui32Counter < 64; ui32Counter += 4) { HWREG(ui32Base + SHAMD5_O_DATA_0_IN + ui32Counter) = *pui32Src++; } return(true); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* release all the calls associated with a socket */
void rxrpc_release_calls_on_socket(struct rxrpc_sock *rx)
/* release all the calls associated with a socket */ void rxrpc_release_calls_on_socket(struct rxrpc_sock *rx)
{ struct rxrpc_call *call; struct rb_node *p; _enter("%p", rx); read_lock_bh(&rx->call_lock); for (p = rb_first(&rx->calls); p; p = rb_next(p)) { call = rb_entry(p, struct rxrpc_call, sock_node); rxrpc_mark_call_released(call); } list_for_each_entry(call, &rx->secureq, accept_link) { rxrpc_mark_call_released(call); } list_for_each_entry(call, &rx->acceptq, accept_link) { rxrpc_mark_call_released(call); } read_unlock_bh(&rx->call_lock); _leave(""); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Configures the ADCx external trigger for injected channels conversion. */
void ADC_ConfigExternalTrigInjectedConv(ADC_Module *ADCx, uint32_t ADC_ExternalTrigInjecConv)
/* Configures the ADCx external trigger for injected channels conversion. */ void ADC_ConfigExternalTrigInjectedConv(ADC_Module *ADCx, uint32_t ADC_ExternalTrigInjecConv)
{ uint32_t tmpregister = 0; assert_param(IsAdcModule(ADCx)); assert_param(IsAdcExtInjTrig(ADC_ExternalTrigInjecConv)); tmpregister = ADCx->CTRL2; tmpregister &= CTRL2_INJ_EXT_SEL_RESET; tmpregister |= ADC_ExternalTrigInjecConv; ADCx->CTRL2 = tmpregister; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Called by both boot and secondaries to move global data into per-processor storage. */
void __cpuinit smp_store_cpu_info(unsigned int cpuid)
/* Called by both boot and secondaries to move global data into per-processor storage. */ void __cpuinit smp_store_cpu_info(unsigned int cpuid)
{ struct cpuinfo_arm *cpu_info = &per_cpu(cpu_data, cpuid); cpu_info->loops_per_jiffy = loops_per_jiffy; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Accelerometer full-scale management between UI chain and OIS chain. When XL UI is on, the full scale is the same between UI/OIS and is chosen by the UI CTRL registers; when XL UI is in PD, the OIS can choose the FS. Full scales are independent between the UI/OIS chain but both bound to 8 g.. */
int32_t lsm6dso_aux_xl_fs_mode_set(lsm6dso_ctx_t *ctx, lsm6dso_xl_fs_mode_t val)
/* Accelerometer full-scale management between UI chain and OIS chain. When XL UI is on, the full scale is the same between UI/OIS and is chosen by the UI CTRL registers; when XL UI is in PD, the OIS can choose the FS. Full scales are independent between the UI/OIS chain but both bound to 8 g.. */ int32_t lsm6dso_aux_xl_fs_mode_set(lsm6dso_ctx_t *ctx, lsm6dso_xl_fs_mode_t val)
{ lsm6dso_ctrl8_xl_t reg; int32_t ret; ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL8_XL, (uint8_t*)&reg, 1); if (ret == 0) { reg.xl_fs_mode = (uint8_t)val; ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL8_XL, (uint8_t*)&reg, 1); } return ret; }
alexander-g-dean/ESF
C++
null
41
/* Detects whether Si1147 is on the i2c bus. */
int Si1147_Detect_Device(I2C_TypeDef *i2c, uint8_t addr)
/* Detects whether Si1147 is on the i2c bus. */ int Si1147_Detect_Device(I2C_TypeDef *i2c, uint8_t addr)
{ uint8_t data; si114x_handle->addr = addr; si114x_handle->i2c = i2c; data = Si114xReadFromRegister(si114x_handle, 0); if (data == SI1147_DEVICE_ID) { return 1; } return 0; }
remotemcu/remcu-chip-sdks
C++
null
436
/* s3c_hsotg_ep0_mps - turn max packet size into register setting @mps: The maximum packet size in bytes. */
static u32 s3c_hsotg_ep0_mps(unsigned int mps)
/* s3c_hsotg_ep0_mps - turn max packet size into register setting @mps: The maximum packet size in bytes. */ static u32 s3c_hsotg_ep0_mps(unsigned int mps)
{ switch (mps) { case 64: return S3C_D0EPCTL_MPS_64; case 32: return S3C_D0EPCTL_MPS_32; case 16: return S3C_D0EPCTL_MPS_16; case 8: return S3C_D0EPCTL_MPS_8; } WARN_ON(1); return (u32)-1; }
robutest/uclinux
C++
GPL-2.0
60
/* STUSB1602 sets the VCONN_SUPPLY status on CC (bit0 0x18 */
STUSB1602_StatusTypeDef STUSB1602_VCONN_Supply_Status_Set(uint8_t Addr, VCONN_Supply_Status_TypeDef st)
/* STUSB1602 sets the VCONN_SUPPLY status on CC (bit0 0x18 */ STUSB1602_StatusTypeDef STUSB1602_VCONN_Supply_Status_Set(uint8_t Addr, VCONN_Supply_Status_TypeDef st)
{ STUSB1602_StatusTypeDef status = STUSB1602_OK; STUSB1602_CC_CAPABILITY_CTRL_RegTypeDef reg; STUSB1602_ReadReg(&reg.d8, Addr, STUSB1602_CC_CAPABILITY_CTRL_REG, 1); reg.b.CC_VCONN_SUPPLY_EN = st; status = STUSB1602_WriteReg(&reg.d8, Addr, STUSB1602_CC_CAPABILITY_CTRL_REG, 1); return status; }
st-one/X-CUBE-USB-PD
C++
null
110
/* Read from SSC Receive Synchronization Holding Register. Read data that is received in SSC Synchronization frame. When the sync data is actually used, after successfully reading the application data by calling */
uint32_t ssc_read_sync_data(Ssc *p_ssc)
/* Read from SSC Receive Synchronization Holding Register. Read data that is received in SSC Synchronization frame. When the sync data is actually used, after successfully reading the application data by calling */ uint32_t ssc_read_sync_data(Ssc *p_ssc)
{ return p_ssc->SSC_RSHR; }
remotemcu/remcu-chip-sdks
C++
null
436
/* You can specify IO base for up to RC_NBOARD cards, using line "riscom8=0xiobase1,0xiobase2,.." at LILO prompt. Note that there will be no probing at default addresses in this case. */
static int __init riscom8_setup(char *str)
/* You can specify IO base for up to RC_NBOARD cards, using line "riscom8=0xiobase1,0xiobase2,.." at LILO prompt. Note that there will be no probing at default addresses in this case. */ static int __init riscom8_setup(char *str)
{ int ints[RC_NBOARD]; int i; str = get_options(str, ARRAY_SIZE(ints), ints); for (i = 0; i < RC_NBOARD; i++) { if (i < ints[0]) rc_board[i].base = ints[i+1]; else rc_board[i].base = 0; } return 1; }
robutest/uclinux
C++
GPL-2.0
60
/* DMA irq handler - determine channel involved, grab status and call real handler */
static irqreturn_t dma_irq_handler(int irq, void *_channel)
/* DMA irq handler - determine channel involved, grab status and call real handler */ static irqreturn_t dma_irq_handler(int irq, void *_channel)
{ struct frv_dma_channel *channel = _channel; frv_clear_dma_inprogress(channel - frv_dma_channels); return channel->handler(channel - frv_dma_channels, __get_DMAC(channel->ioaddr, CSTR), channel->data); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This call is similar to hwconfig_arg_f(), except that it takes an additional argument @subopt, and so works with sub-options. */
const char* hwconfig_subarg_f(const char *opt, const char *subopt, size_t *subarglen, char *buf)
/* This call is similar to hwconfig_arg_f(), except that it takes an additional argument @subopt, and so works with sub-options. */ const char* hwconfig_subarg_f(const char *opt, const char *subopt, size_t *subarglen, char *buf)
{ size_t arglen; const char *arg; arg = __hwconfig(opt, &arglen, buf); if (!arg) return NULL; return hwconfig_parse(arg, arglen, subopt, ",;", '=', subarglen); }
4ms/stm32mp1-baremetal
C++
Other
137
/* Guess the values for sigma_i ivlen - how long was the iv (is used differently in original klein attack) iv - IV which was used for this packet keystream - keystream recovered result - buffer for the values of sigma_i kb - how many keybytes should be guessed */
static void guesskeybytes(int ivlen, uint8_t *iv, uint8_t *keystream, uint8_t *result, int kb)
/* Guess the values for sigma_i ivlen - how long was the iv (is used differently in original klein attack) iv - IV which was used for this packet keystream - keystream recovered result - buffer for the values of sigma_i kb - how many keybytes should be guessed */ static void guesskeybytes(int ivlen, uint8_t *iv, uint8_t *keystream, uint8_t *result, int kb)
{ j += state[i] + iv[i]; tmp = state[i]; state[i] = state[j]; state[j] = tmp; } for (i = 0; i < kb; i++) { tmp = jj - keystream[jj-1]; ii = 0; while(tmp != state[ii]) { ii++; } s += state[jj]; ii -= (j+s); result[i] = ii; jj++; } return; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Return the number of TX buffer waiting for transfer. */
uint32_t gmac_dev_tx_buf_used(gmac_device_t *p_gmac_dev, gmac_quelist_t queue_idx)
/* Return the number of TX buffer waiting for transfer. */ uint32_t gmac_dev_tx_buf_used(gmac_device_t *p_gmac_dev, gmac_quelist_t queue_idx)
{ uint32_t used = 0; for (uint32_t i = 0; i < p_gmac_dev->gmac_queue_list[queue_idx].us_tx_list_size; ++i) { if ((p_gmac_dev->gmac_queue_list[queue_idx].p_tx_dscr[i].status.val & GMAC_TXD_USED) == 0) used += 1; } return used; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Set the number of application probes of a neighbour table to the specified value */
void rtnl_neightbl_set_app_probes(struct rtnl_neightbl *ntbl, int probes)
/* Set the number of application probes of a neighbour table to the specified value */ void rtnl_neightbl_set_app_probes(struct rtnl_neightbl *ntbl, int probes)
{ ntbl->nt_parms.ntp_app_probes = probes; ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_APP_PROBES; ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* reset the XGXS (between serdes and IBC). Slightly less intrusive than resetting the IBC or external link state, and useful in some cases to cause some retraining. To do this right, we reset IBC as well. */
static void ipath_ht_xgxs_reset(struct ipath_devdata *dd)
/* reset the XGXS (between serdes and IBC). Slightly less intrusive than resetting the IBC or external link state, and useful in some cases to cause some retraining. To do this right, we reset IBC as well. */ static void ipath_ht_xgxs_reset(struct ipath_devdata *dd)
{ u64 val, prev_val; prev_val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_xgxsconfig); val = prev_val | INFINIPATH_XGXS_RESET; prev_val &= ~INFINIPATH_XGXS_RESET; ipath_write_kreg(dd, dd->ipath_kregs->kr_control, dd->ipath_control & ~INFINIPATH_C_LINKENABLE); ipath_write_kreg(dd, dd->ipath_kregs->kr_xgxsconfig, val); ipath_read_kreg32(dd, dd->ipath_kregs->kr_scratch); ipath_write_kreg(dd, dd->ipath_kregs->kr_xgxsconfig, prev_val); ipath_write_kreg(dd, dd->ipath_kregs->kr_control, dd->ipath_control); }
robutest/uclinux
C++
GPL-2.0
60
/* This walks the bus device list and returns a pointer to the interface with the matching minor and driver. Note, this only works for devices that share the USB major number. */
struct usb_interface* usb_find_interface(struct usb_driver *drv, int minor)
/* This walks the bus device list and returns a pointer to the interface with the matching minor and driver. Note, this only works for devices that share the USB major number. */ struct usb_interface* usb_find_interface(struct usb_driver *drv, int minor)
{ struct find_interface_arg argb; struct device *dev; argb.minor = minor; argb.drv = &drv->drvwrap.driver; dev = bus_find_device(&usb_bus_type, NULL, &argb, __find_interface); put_device(dev); return dev ? to_usb_interface(dev) : NULL; }
robutest/uclinux
C++
GPL-2.0
60
/* Initialization function for the Q15 sparse FIR filter. */
void arm_fir_sparse_init_q15(arm_fir_sparse_instance_q15 *S, uint16_t numTaps, const q15_t *pCoeffs, q15_t *pState, int32_t *pTapDelay, uint16_t maxDelay, uint32_t blockSize)
/* Initialization function for the Q15 sparse FIR filter. */ void arm_fir_sparse_init_q15(arm_fir_sparse_instance_q15 *S, uint16_t numTaps, const q15_t *pCoeffs, q15_t *pState, int32_t *pTapDelay, uint16_t maxDelay, uint32_t blockSize)
{ S->numTaps = numTaps; S->pCoeffs = pCoeffs; S->pTapDelay = pTapDelay; S->maxDelay = maxDelay; S->stateIndex = 0U; memset(pState, 0, (maxDelay + blockSize) * sizeof(q15_t)); S->pState = pState; }
pikasTech/PikaPython
C++
MIT License
1,403
/* We pre-swap the bytes since PCX-W is Big Endian and the IOMMU uses little endian for the pdir. */
static void SBA_INLINE sba_io_pdir_entry(u64 *pdir_ptr, space_t sid, unsigned long vba, unsigned long hint)
/* We pre-swap the bytes since PCX-W is Big Endian and the IOMMU uses little endian for the pdir. */ static void SBA_INLINE sba_io_pdir_entry(u64 *pdir_ptr, space_t sid, unsigned long vba, unsigned long hint)
{ u64 pa; register unsigned ci; pa = virt_to_phys(vba); pa &= IOVP_MASK; mtsp(sid,1); asm("lci 0(%%sr1, %1), %0" : "=r" (ci) : "r" (vba)); pa |= (ci >> 12) & 0xff; pa |= SBA_PDIR_VALID_BIT; *pdir_ptr = cpu_to_le64(pa); if (ioc_needs_fdc) asm volatile("fdc %%r0(%0)" : : "r" (pdir_ptr)); }
robutest/uclinux
C++
GPL-2.0
60
/* Un-Register the Service C.2 and all its Characteristics... */
void service_c_2_1_remove(void)
/* Un-Register the Service C.2 and all its Characteristics... */ void service_c_2_1_remove(void)
{ bt_gatt_service_unregister(&service_c_2_1_svc); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Clears an ethernet address from a receive address register. */
s32 ixgbe_clear_rar_generic(struct ixgbe_hw *hw, u32 index)
/* Clears an ethernet address from a receive address register. */ s32 ixgbe_clear_rar_generic(struct ixgbe_hw *hw, u32 index)
{ u32 rar_high; u32 rar_entries = hw->mac.num_rar_entries; if (index < rar_entries) { rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(index)); rar_high &= ~(0x0000FFFF | IXGBE_RAH_AV); IXGBE_WRITE_REG(hw, IXGBE_RAL(index), 0); IXGBE_WRITE_REG(hw, IXGBE_RAH(index), rar_high); } else { hw_dbg(hw, "RAR index %d is out of range.\n", index); } hw->mac.ops.clear_vmdq(hw, index, IXGBE_CLEAR_VMDQ_ALL); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Reads the base/extended device id from the local device implementing the master port. Returns the 8/16-bit device id. */
u16 rio_local_get_device_id(struct rio_mport *port)
/* Reads the base/extended device id from the local device implementing the master port. Returns the 8/16-bit device id. */ u16 rio_local_get_device_id(struct rio_mport *port)
{ u32 result; rio_local_read_config_32(port, RIO_DID_CSR, &result); return (RIO_GET_DID(port->sys_size, result)); }
robutest/uclinux
C++
GPL-2.0
60
/* Scroll up/down for the number of specified lines. */
void ili9225_scroll(uint8_t uc_startline, uint8_t uc_endline)
/* Scroll up/down for the number of specified lines. */ void ili9225_scroll(uint8_t uc_startline, uint8_t uc_endline)
{ ili9225_write_register(ILI9225_VERTICAL_SCROLL_CTRL1, ILI9225_VERTICAL_SCROLL_CTRL1_SEA(uc_startline)); ili9225_write_register(ILI9225_VERTICAL_SCROLL_CTRL2, ILI9225_VERTICAL_SCROLL_CTRL2_SSA(uc_endline)); }
remotemcu/remcu-chip-sdks
C++
null
436
/* Enables or disables the temperature sensor and Vrefint channel. */
void ADC_TempSensorVrefintCmd(FunctionalState NewState)
/* Enables or disables the temperature sensor and Vrefint channel. */ void ADC_TempSensorVrefintCmd(FunctionalState NewState)
{ assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { ADC1->CR2 |= CR2_TSVREFE_Set; } else { ADC1->CR2 &= CR2_TSVREFE_Reset; } }
gcallipo/RadioDSP-Stm32f103
C++
Common Creative - Attribution 3.0
51
/* ADC Oversampling mode configuration. This function configures ADC as Oversampling mode with below Settings. GLCK for ADC -> GCLK_GENERATOR_1 (8MHz) CLK_ADC -> 512 KHz REFERENCE -> 1/2 VDDANA (1.65V) RESOLUTION -> 16 bit POSITIVE INPUT -> PA02 NEGATIVE INPUT -> GND */
void configure_adc_sampling(void)
/* ADC Oversampling mode configuration. This function configures ADC as Oversampling mode with below Settings. GLCK for ADC -> GCLK_GENERATOR_1 (8MHz) CLK_ADC -> 512 KHz REFERENCE -> 1/2 VDDANA (1.65V) RESOLUTION -> 16 bit POSITIVE INPUT -> PA02 NEGATIVE INPUT -> GND */ void configure_adc_sampling(void)
{ struct adc_config conf_adc; adc_get_config_defaults(&conf_adc); conf_adc.clock_source = GCLK_GENERATOR_1; conf_adc.reference = ADC_REFERENCE_INTVCC1; conf_adc.clock_prescaler = ADC_CLOCK_PRESCALER_DIV16; conf_adc.positive_input = ADC_POSITIVE_INPUT_PIN0; conf_adc.negative_input = ADC_NEGATIVE_INPUT_GND; conf_adc.resolution = ADC_RESOLUTION_16BIT; conf_adc.reference_compensation_enable = true; adc_init(&adc_instance, ADC, &conf_adc); adc_enable(&adc_instance); }
memfault/zero-to-main
C++
null
200
/* Tells the daemon whether it can umount the autofs mount. */
static int autofs4_ask_umount(struct vfsmount *mnt, int __user *p)
/* Tells the daemon whether it can umount the autofs mount. */ static int autofs4_ask_umount(struct vfsmount *mnt, int __user *p)
{ int status = 0; if (may_umount(mnt)) status = 1; DPRINTK("returning %d", status); status = put_user(status, p); return status; }
robutest/uclinux
C++
GPL-2.0
60
/* Clean up all the cached directory structures when the volume is going to be abandoned. */
VOID FatCleanupODirCache(IN FAT_VOLUME *Volume)
/* Clean up all the cached directory structures when the volume is going to be abandoned. */ VOID FatCleanupODirCache(IN FAT_VOLUME *Volume)
{ FAT_ODIR *ODir; while (Volume->DirCacheCount > 0) { ODir = ODIR_FROM_DIRCACHELINK (Volume->DirCacheList.BackLink); RemoveEntryList (&ODir->DirCacheLink); FatFreeODir (ODir); Volume->DirCacheCount--; } }
tianocore/edk2
C++
Other
4,240
/* It has to be called with shp and shm_ids.rw_mutex (writer) locked, but returns with shp unlocked and freed. */
static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
/* It has to be called with shp and shm_ids.rw_mutex (writer) locked, but returns with shp unlocked and freed. */ static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
{ ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT; shm_rmid(ns, shp); shm_unlock(shp); if (!is_file_hugepages(shp->shm_file)) shmem_lock(shp->shm_file, 0, shp->mlock_user); else if (shp->mlock_user) user_shm_unlock(shp->shm_file->f_path.dentry->d_inode->i_size, shp->mlock_user); fput (shp->shm_file); security_shm_free(shp); ipc_rcu_putref(shp); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Return: 0 in case of success, a negative error code otherwise. */
int nanddev_bbt_init(struct nand_device *nand)
/* Return: 0 in case of success, a negative error code otherwise. */ int nanddev_bbt_init(struct nand_device *nand)
{ unsigned int bits_per_block = fls(NAND_BBT_BLOCK_NUM_STATUS); unsigned int nblocks = nanddev_neraseblocks(nand); unsigned int nwords = DIV_ROUND_UP(nblocks * bits_per_block, BITS_PER_LONG); nand->bbt.cache = kzalloc(nwords, GFP_KERNEL); if (!nand->bbt.cache) return -ENOMEM; return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Sets the LPDS exit PC and SP restore vlaues. */
void PRCMLPDSRestoreInfoSet(unsigned long ulStackPtr, unsigned long ulProgCntr)
/* Sets the LPDS exit PC and SP restore vlaues. */ void PRCMLPDSRestoreInfoSet(unsigned long ulStackPtr, unsigned long ulProgCntr)
{ HWREG(0x4402E18C) = ulStackPtr; HWREG(0x4402E190) = ulProgCntr; }
micropython/micropython
C++
Other
18,334
/* Enables the selected SDADC software start conversion of the regular channels. */
void SDADC_SoftwareStartConv(SDADC_TypeDef *SDADCx)
/* Enables the selected SDADC software start conversion of the regular channels. */ void SDADC_SoftwareStartConv(SDADC_TypeDef *SDADCx)
{ assert_param(IS_SDADC_ALL_PERIPH(SDADCx)); SDADCx->CR2 |= (uint32_t)SDADC_CR2_RSWSTART; }
avem-labs/Avem
C++
MIT License
1,752
/* Pixel draw with blending enabled and using alpha weight on color - no locking. */
int pixelColorWeightNolock(SDL_Surface *dst, Sint16 x, Sint16 y, Uint32 color, Uint32 weight)
/* Pixel draw with blending enabled and using alpha weight on color - no locking. */ int pixelColorWeightNolock(SDL_Surface *dst, Sint16 x, Sint16 y, Uint32 color, Uint32 weight)
{ Uint32 a; a = (color & (Uint32) 0x000000ff); a = ((a * weight) >> 8); return (pixelColorNolock(dst, x, y, (color & (Uint32) 0xffffff00) | (Uint32) a)); }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Returns CR_OK if at least one character has been consumed, an error code otherwise. */
enum CRStatus cr_input_consume_chars(CRInput *a_this, guint32 a_char, gulong *a_nb_char)
/* Returns CR_OK if at least one character has been consumed, an error code otherwise. */ enum CRStatus cr_input_consume_chars(CRInput *a_this, guint32 a_char, gulong *a_nb_char)
{ enum CRStatus status = CR_OK; gulong nb_consumed = 0; g_return_val_if_fail (a_this && PRIVATE (a_this) && a_nb_char, CR_BAD_PARAM_ERROR); g_return_val_if_fail (a_char != 0 || a_nb_char != NULL, CR_BAD_PARAM_ERROR); for (nb_consumed = 0; ((status == CR_OK) && (*a_nb_char > 0 && nb_consumed < *a_nb_char)); nb_consumed++) { status = cr_input_consume_char (a_this, a_char); } *a_nb_char = nb_consumed; if ((nb_consumed > 0) && ((status == CR_PARSING_ERROR) || (status == CR_END_OF_INPUT_ERROR))) { status = CR_OK; } return status; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Creates an array for the hash part of a table with the given size, or reuses the dummy node if size is zero. The computation for size overflow is in two steps: the first comparison ensures that the shift in the second one does not overflow. */
static void setnodevector(lua_State *L, Table *t, unsigned int size)
/* Creates an array for the hash part of a table with the given size, or reuses the dummy node if size is zero. The computation for size overflow is in two steps: the first comparison ensures that the shift in the second one does not overflow. */ static void setnodevector(lua_State *L, Table *t, unsigned int size)
{ t->node = cast(Node *, dummynode); t->lsizenode = 0; t->lastfree = NULL; } else { int i; int lsize = luaO_ceillog2(size); if (lsize > MAXHBITS || (1u << lsize) > MAXHSIZE) luaG_runerror(L, "table overflow"); size = twoto(lsize); t->node = luaM_newvector(L, size, Node); for (i = 0; i < (int)size; i++) { Node *n = gnode(t, i); gnext(n) = 0; setnilkey(n); setempty(gval(n)); } t->lsizenode = cast_byte(lsize); t->lastfree = gnode(t, size); } }
Nicholas3388/LuaNode
C++
Other
1,055
/* This function returns the TLS/SSL master key material currently used in the specified TLS connection. */
EFI_STATUS EFIAPI CryptoServiceTlsGetKeyMaterial(IN VOID *Tls, IN OUT UINT8 *KeyMaterial)
/* This function returns the TLS/SSL master key material currently used in the specified TLS connection. */ EFI_STATUS EFIAPI CryptoServiceTlsGetKeyMaterial(IN VOID *Tls, IN OUT UINT8 *KeyMaterial)
{ return CALL_BASECRYPTLIB (TlsGet.Services.KeyMaterial, TlsGetKeyMaterial, (Tls, KeyMaterial), EFI_UNSUPPORTED); }
tianocore/edk2
C++
Other
4,240
/* Try whether drv matches dev with bus match function */
static int u_driver_match_device(struct u_driver *drv, struct u_device *dev)
/* Try whether drv matches dev with bus match function */ static int u_driver_match_device(struct u_driver *drv, struct u_device *dev)
{ if (!drv || !dev) { ddkc_err("invalid drv:%p or dev:%p\r\n", drv, dev); return 0; } ddkc_dbg("driver match device, drv:%p, drv->bus:%p, dev:%p\r\n", drv, drv->bus, dev); if (drv->bus) { ddkc_dbg("driver match device, drv->bus->match:%p\r\n", drv->bus->match); return drv->bus->match ? drv->bus->match(dev, drv) : 1; } else { ddkc_err("invalid drv->bus:%p\r\n", drv->bus); return 0; } }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* @ram_start: start address of a RAM memory area @ram_end: end address of a RAM memory area @ram_top: max address to be used as conventional memory Return: status code */
efi_status_t efi_add_conventional_memory_map(u64 ram_start, u64 ram_end, u64 ram_top)
/* @ram_start: start address of a RAM memory area @ram_end: end address of a RAM memory area @ram_top: max address to be used as conventional memory Return: status code */ efi_status_t efi_add_conventional_memory_map(u64 ram_start, u64 ram_end, u64 ram_top)
{ u64 pages; ram_end &= ~EFI_PAGE_MASK; ram_start = (ram_start + EFI_PAGE_MASK) & ~EFI_PAGE_MASK; if (ram_end <= ram_start) { return EFI_INVALID_PARAMETER; } pages = (ram_end - ram_start) >> EFI_PAGE_SHIFT; efi_add_memory_map(ram_start, pages, EFI_CONVENTIONAL_MEMORY, false); if (ram_top < ram_start) { efi_add_memory_map(ram_start, pages, EFI_BOOT_SERVICES_DATA, true); } else if ((ram_top >= ram_start) && (ram_top < ram_end)) { pages = (ram_end - ram_top) >> EFI_PAGE_SHIFT; efi_add_memory_map(ram_top, pages, EFI_BOOT_SERVICES_DATA, true); } return EFI_SUCCESS; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Locking Note: The rport lock is expected to be held before calling this routine. */
static void fc_rport_enter_ready(struct fc_rport_priv *)
/* Locking Note: The rport lock is expected to be held before calling this routine. */ static void fc_rport_enter_ready(struct fc_rport_priv *)
{ fc_rport_state_enter(rdata, RPORT_ST_READY); FC_RPORT_DBG(rdata, "Port is Ready\n"); if (rdata->event == RPORT_EV_NONE) queue_work(rport_event_queue, &rdata->event_work); rdata->event = RPORT_EV_READY; }
robutest/uclinux
C++
GPL-2.0
60
/* Used by a driver to check whether a Zorro device present in the system is in its list of supported devices.Returns the matching zorro_device_id structure or NULL if there is no match. */
static int zorro_bus_match(struct device *dev, struct device_driver *drv)
/* Used by a driver to check whether a Zorro device present in the system is in its list of supported devices.Returns the matching zorro_device_id structure or NULL if there is no match. */ static int zorro_bus_match(struct device *dev, struct device_driver *drv)
{ struct zorro_dev *z = to_zorro_dev(dev); struct zorro_driver *zorro_drv = to_zorro_driver(drv); const struct zorro_device_id *ids = zorro_drv->id_table; if (!ids) return 0; while (ids->id) { if (ids->id == ZORRO_WILDCARD || ids->id == z->id) return 1; ids++; } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* If Buffer is NULL, then ASSERT(). If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). */
VOID* EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
/* If Buffer is NULL, then ASSERT(). If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). */ VOID* EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
{ VOID *Memory; Memory = AllocatePool (AllocationSize); if (Memory != NULL) { Memory = CopyMem (Memory, Buffer, AllocationSize); } return Memory; }
tianocore/edk2
C++
Other
4,240
/* Flush exports table - called when last nfsd thread is killed */
void nfsd_export_flush(void)
/* Flush exports table - called when last nfsd thread is killed */ void nfsd_export_flush(void)
{ exp_writelock(); cache_purge(&svc_expkey_cache); cache_purge(&svc_export_cache); exp_writeunlock(); }
robutest/uclinux
C++
GPL-2.0
60
/* This code checks if variable header is valid or not. */
BOOLEAN IsValidVariableHeader(IN VARIABLE_HEADER *Variable, IN VARIABLE_HEADER *VariableStoreEnd)
/* This code checks if variable header is valid or not. */ BOOLEAN IsValidVariableHeader(IN VARIABLE_HEADER *Variable, IN VARIABLE_HEADER *VariableStoreEnd)
{ if ((Variable == NULL) || (Variable >= VariableStoreEnd) || (Variable->StartId != VARIABLE_DATA)) { return FALSE; } return TRUE; }
tianocore/edk2
C++
Other
4,240
/* 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}; RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; if(huart->Instance==USART1) { PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1; PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2; if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) { Error_Handler(); } __HAL_RCC_USART1_CLK_ENABLE(); __HAL_RCC_GPIOA_CLK_ENABLE(); GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Alternate = GPIO_AF7_USART1; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); } }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Returns: (transfer full): a #GIcon. The returned object should be unreffed with g_object_unref() when no longer needed. */
GIcon* g_mount_get_icon(GMount *mount)
/* Returns: (transfer full): a #GIcon. The returned object should be unreffed with g_object_unref() when no longer needed. */ GIcon* g_mount_get_icon(GMount *mount)
{ GMountIface *iface; g_return_val_if_fail (G_IS_MOUNT (mount), NULL); iface = G_MOUNT_GET_IFACE (mount); return (* iface->get_icon) (mount); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Convert region offsets to region sizes and truncate size to big_values. */
static void ff_region_offset2size(GranuleDef *g)
/* Convert region offsets to region sizes and truncate size to big_values. */ static void ff_region_offset2size(GranuleDef *g)
{ k = FFMIN(g->region_size[i], g->big_values); g->region_size[i] = k - j; j = k; } }
DC-SWAT/DreamShell
C++
null
404
/* Gets the selected ADC Software start injected conversion Status. */
FlagStatus ADC_GetSoftwareStartInjectedConvCmdStatus(ADC_TypeDef *ADCx)
/* Gets the selected ADC Software start injected conversion Status. */ FlagStatus ADC_GetSoftwareStartInjectedConvCmdStatus(ADC_TypeDef *ADCx)
{ FlagStatus bitstatus = RESET; assert_param(IS_ADC_ALL_PERIPH(ADCx)); if ((ADCx->CR2 & ADC_CR2_JSWSTART) != (uint32_t)RESET) { bitstatus = SET; } else { bitstatus = RESET; } return bitstatus; }
avem-labs/Avem
C++
MIT License
1,752
/* Given a radio controller descriptor, validate and refcount it */
struct uwb_rc* __uwb_rc_try_get(struct uwb_rc *target_rc)
/* Given a radio controller descriptor, validate and refcount it */ struct uwb_rc* __uwb_rc_try_get(struct uwb_rc *target_rc)
{ struct device *dev; struct uwb_rc *rc = NULL; dev = class_find_device(&uwb_rc_class, NULL, target_rc, find_rc_try_get); if (dev) { rc = dev_get_drvdata(dev); __uwb_rc_get(rc); } return rc; }
robutest/uclinux
C++
GPL-2.0
60
/* cooling device callback functions get maximal fan cooling state */
static int acerhdf_get_max_state(struct thermal_cooling_device *cdev, unsigned long *state)
/* cooling device callback functions get maximal fan cooling state */ static int acerhdf_get_max_state(struct thermal_cooling_device *cdev, unsigned long *state)
{ *state = 1; return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* DMA Set FIFO Threshold. This is the filled level at which data is transferred out of the FIFO to the destination. */
void dma_set_fifo_threshold(uint32_t dma, uint8_t stream, uint32_t threshold)
/* DMA Set FIFO Threshold. This is the filled level at which data is transferred out of the FIFO to the destination. */ void dma_set_fifo_threshold(uint32_t dma, uint8_t stream, uint32_t threshold)
{ uint32_t reg32 = (DMA_SFCR(dma, stream) & ~DMA_SxFCR_FTH_MASK); DMA_SFCR(dma, stream) = (reg32 | threshold); }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* Initializes and Configures the IO_Expanders Functionalities (Touch Screen ..) and configures all STM32100E-EVAL necessary hardware (GPIOs, APB clocks ..). */
uint8_t IOE_Config(void)
/* Initializes and Configures the IO_Expanders Functionalities (Touch Screen ..) and configures all STM32100E-EVAL necessary hardware (GPIOs, APB clocks ..). */ uint8_t IOE_Config(void)
{ IOE_GPIO_Config(); IOE_I2C_Config(); if(IOE_IsOperational(IOE_1_ADDR)) { return IOE1_NOT_OPERATIONAL; } IOE_Reset(IOE_1_ADDR); IOE_FnctCmd(IOE_1_ADDR, IOE_TS_FCT | IOE_ADC_FCT | IOE_IO_FCT | IOE_TEMPSENS_FCT , ENABLE); IOE_TS_Config(); IOE_TempSens_Config(); return IOE_OK; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Read an SGE egress context. The caller is responsible for ensuring only one context operation occurs at a time. */
int t3_sge_read_ecntxt(struct adapter *adapter, unsigned int id, u32 data[4])
/* Read an SGE egress context. The caller is responsible for ensuring only one context operation occurs at a time. */ int t3_sge_read_ecntxt(struct adapter *adapter, unsigned int id, u32 data[4])
{ if (id >= 65536) return -EINVAL; return t3_sge_read_context(F_EGRESS, adapter, id, data); }
robutest/uclinux
C++
GPL-2.0
60
/* Allocate @bytes linearly and creates 1-1-1 mapping and returns @da again, which might be adjusted if 'IOVMF_DA_ANON' is set. */
u32 iommu_kmalloc(struct iommu *obj, u32 da, size_t bytes, u32 flags)
/* Allocate @bytes linearly and creates 1-1-1 mapping and returns @da again, which might be adjusted if 'IOVMF_DA_ANON' is set. */ u32 iommu_kmalloc(struct iommu *obj, u32 da, size_t bytes, u32 flags)
{ void *va; u32 pa; if (!obj || !obj->dev || !bytes) return -EINVAL; bytes = PAGE_ALIGN(bytes); va = kmalloc(bytes, GFP_KERNEL | GFP_DMA); if (!va) return -ENOMEM; pa = virt_to_phys(va); flags &= IOVMF_HW_MASK; flags |= IOVMF_LINEAR; flags |= IOVMF_ALLOC; flags |= (da ? IOVMF_DA_FIXED : IOVMF_DA_ANON); da = __iommu_kmap(obj, da, pa, va, bytes, flags); if (IS_ERR_VALUE(da)) kfree(va); return da; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Event handler for the library USB Configuration Changed event. */
void EVENT_USB_Device_ConfigurationChanged(void)
/* Event handler for the library USB Configuration Changed event. */ void EVENT_USB_Device_ConfigurationChanged(void)
{ bool ConfigSuccess = true; ConfigSuccess &= HID_Device_ConfigureEndpoints(&Keyboard_HID_Interface); USB_Device_EnableSOFEvents(); LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR); }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Callback function called by PE to inform DPM about PE event. */
void USBPD_DPM_Notification(uint8_t PortNum, USBPD_NotifyEventValue_TypeDef EventVal)
/* Callback function called by PE to inform DPM about PE event. */ void USBPD_DPM_Notification(uint8_t PortNum, USBPD_NotifyEventValue_TypeDef EventVal)
{ switch(EventVal) { case USBPD_NOTIFY_POWER_EXPLICIT_CONTRACT : if (USBPD_PORTDATAROLE_DFP == DPM_Params[PortNum].PE_DataRole) { USBPD_PE_SVDM_RequestIdentity(PortNum, USBPD_SOPTYPE_SOP); } Led_Set((PortNum == USBPD_PORT_0 ? LED_PORT0_VBUS : LED_PORT1_VBUS) , LED_MODE_ON, 0); break; case USBPD_NOTIFY_HARDRESET_RX: case USBPD_NOTIFY_HARDRESET_TX: if (USBPD_PORTPOWERROLE_SNK == DPM_Params[PortNum].PE_PowerRole) { USBPD_VDM_UserReset(PortNum); } break; case USBPD_NOTIFY_STATE_SRC_DISABLED: { } break; default : break; } }
st-one/X-CUBE-USB-PD
C++
null
110
/* This function clears given attributes of the memory region specified by BaseAddress and Length. */
EFI_STATUS EFIAPI EdkiiSmmClearMemoryAttributes(IN EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL *This, IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT64 Attributes)
/* This function clears given attributes of the memory region specified by BaseAddress and Length. */ EFI_STATUS EFIAPI EdkiiSmmClearMemoryAttributes(IN EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL *This, IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT64 Attributes)
{ return SmmClearMemoryAttributes (BaseAddress, Length, Attributes); }
tianocore/edk2
C++
Other
4,240
/* Architecture specific function for relocating shared elf. Elf files contain a series of relocations described in multiple sections. These relocation instructions are architecture specific and each architecture supporting modules must implement this. */
void arch_elf_relocate_local(struct llext_loader *ldr, struct llext *ext, elf_rela_t *rel, size_t got_offset)
/* Architecture specific function for relocating shared elf. Elf files contain a series of relocations described in multiple sections. These relocation instructions are architecture specific and each architecture supporting modules must implement this. */ void arch_elf_relocate_local(struct llext_loader *ldr, struct llext *ext, elf_rela_t *rel, size_t got_offset)
{ uint8_t *text = ext->mem[LLEXT_MEM_TEXT]; int type = ELF32_R_TYPE(rel->r_info); if (type == R_XTENSA_RELATIVE) { elf_word ptr_offset = *(elf_word *)(text + got_offset); LOG_DBG("relocation type %u offset %#x value %#x", type, got_offset, ptr_offset); *(elf_word *)(text + got_offset) = (elf_word)(text + ptr_offset - ldr->sects[LLEXT_MEM_TEXT].sh_addr); } }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Disable EFM32 access to peripheral on DVK board. */
void DVK_disablePeripheral(DVKPeripheral peri)
/* Disable EFM32 access to peripheral on DVK board. */ void DVK_disablePeripheral(DVKPeripheral peri)
{ uint16_t bit; uint16_t tmp; bit = (uint16_t) peri; tmp = DVK_readRegister(BC_PERCTRL); tmp &= ~(bit); if ((peri == DVK_RS232A) || (peri == DVK_RS232B)) { tmp |= (BC_PERCTRL_RS232_SHUTDOWN); } if (peri == DVK_IRDA) { tmp |= (BC_PERCTRL_IRDA_SHUTDOWN); } DVK_writeRegister(BC_PERCTRL, tmp); }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Transmit a data packet using the ymodem protocol. */
void Ymodem_SendPacket(uint8_t *data, uint16_t length)
/* Transmit a data packet using the ymodem protocol. */ void Ymodem_SendPacket(uint8_t *data, uint16_t length)
{ uint16_t i; i = 0; while (i < length) { Send_Byte(data[i]); i++; } }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* param base Pointer to FLEXIO_I2S_Type structure. param handle Pointer to flexio_i2s_handle_t structure which stores the transfer state param xfer Pointer to flexio_i2s_transfer_t structure retval kStatus_Success Successfully start the data receive. retval kStatus_FLEXIO_I2S_RxBusy Previous receive still not finished. retval kStatus_InvalidArgument The input parameter is invalid. */
status_t FLEXIO_I2S_TransferReceiveNonBlocking(FLEXIO_I2S_Type *base, flexio_i2s_handle_t *handle, flexio_i2s_transfer_t *xfer)
/* param base Pointer to FLEXIO_I2S_Type structure. param handle Pointer to flexio_i2s_handle_t structure which stores the transfer state param xfer Pointer to flexio_i2s_transfer_t structure retval kStatus_Success Successfully start the data receive. retval kStatus_FLEXIO_I2S_RxBusy Previous receive still not finished. retval kStatus_InvalidArgument The input parameter is invalid. */ status_t FLEXIO_I2S_TransferReceiveNonBlocking(FLEXIO_I2S_Type *base, flexio_i2s_handle_t *handle, flexio_i2s_transfer_t *xfer)
{ assert(handle); if (handle->queue[handle->queueUser].data) { return kStatus_FLEXIO_I2S_QueueFull; } if ((xfer->dataSize == 0) || (xfer->data == NULL)) { return kStatus_InvalidArgument; } handle->queue[handle->queueUser].data = xfer->data; handle->queue[handle->queueUser].dataSize = xfer->dataSize; handle->transferSize[handle->queueUser] = xfer->dataSize; handle->queueUser = (handle->queueUser + 1) % FLEXIO_I2S_XFER_QUEUE_SIZE; handle->state = kFLEXIO_I2S_Busy; FLEXIO_I2S_EnableInterrupts(base, kFLEXIO_I2S_RxDataRegFullInterruptEnable); FLEXIO_I2S_Enable(base, true); return kStatus_Success; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Selects Batching Data Rate (writing frequency in FIFO) for third data set.. */
int32_t lsm6dsl_fifo_dataset_3_batch_set(stmdev_ctx_t *ctx, lsm6dsl_dec_ds3_fifo_t val)
/* Selects Batching Data Rate (writing frequency in FIFO) for third data set.. */ int32_t lsm6dsl_fifo_dataset_3_batch_set(stmdev_ctx_t *ctx, lsm6dsl_dec_ds3_fifo_t val)
{ lsm6dsl_fifo_ctrl4_t fifo_ctrl4; int32_t ret; ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_CTRL4, (uint8_t*)&fifo_ctrl4, 1); if(ret == 0){ fifo_ctrl4.dec_ds3_fifo = (uint8_t)val; ret = lsm6dsl_write_reg(ctx, LSM6DSL_FIFO_CTRL4, (uint8_t*)&fifo_ctrl4, 1); } return ret; }
eclipse-threadx/getting-started
C++
Other
310
/* set functions (stack -> Lua) t = value at the top of the stack (where 'k' is a string) */
static void auxsetstr(lua_State *L, const TValue *t, const char *k)
/* set functions (stack -> Lua) t = value at the top of the stack (where 'k' is a string) */ static void auxsetstr(lua_State *L, const TValue *t, const char *k)
{ setsvalue2s(L, L->top, str); api_incr_top(L); luaV_finishset(L, t, L->top - 1, L->top - 2, slot); L->top -= 2; } lua_unlock(L); }
nodemcu/nodemcu-firmware
C++
MIT License
7,566
/* param base SPDIF base pointer. param handle Pointer to the spdif_handle_t structure which stores the transfer state. */
void SPDIF_TransferAbortSend(SPDIF_Type *base, spdif_handle_t *handle)
/* param base SPDIF base pointer. param handle Pointer to the spdif_handle_t structure which stores the transfer state. */ void SPDIF_TransferAbortSend(SPDIF_Type *base, spdif_handle_t *handle)
{ assert(handle); SPDIF_DisableInterrupts(base, kSPDIF_TxFIFOEmpty); handle->state = kSPDIF_Idle; memset(handle->spdifQueue, 0, sizeof(spdif_transfer_t) * SPDIF_XFER_QUEUE_SIZE); handle->queueDriver = 0; handle->queueUser = 0; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function returns a reference to the window that should be used when managing the widget, such as move, resize, destroy and reparenting. */
struct win_window* wtk_radio_button_as_child(struct wtk_radio_button *radio_button)
/* This function returns a reference to the window that should be used when managing the widget, such as move, resize, destroy and reparenting. */ struct win_window* wtk_radio_button_as_child(struct wtk_radio_button *radio_button)
{ Assert(radio_button); return radio_button->container; }
memfault/zero-to-main
C++
null
200
/* If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 32-bit boundary, then ASSERT(). If Length is not aligned on a 128-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). */
VOID* EFIAPI ScanGuid(IN CONST VOID *Buffer, IN UINTN Length, IN CONST GUID *Guid)
/* If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 32-bit boundary, then ASSERT(). If Length is not aligned on a 128-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). */ VOID* EFIAPI ScanGuid(IN CONST VOID *Buffer, IN UINTN Length, IN CONST GUID *Guid)
{ CONST GUID *GuidPtr; ASSERT (((UINTN)Buffer & (sizeof (Guid->Data1) - 1)) == 0); ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1)); ASSERT ((Length & (sizeof (*GuidPtr) - 1)) == 0); GuidPtr = (GUID *)Buffer; Buffer = GuidPtr + Length / sizeof (*GuidPtr); while (GuidPtr < (CONST GUID *)Buffer) { if (CompareGuid (GuidPtr, Guid)) { return (VOID *)GuidPtr; } GuidPtr++; } return NULL; }
tianocore/edk2
C++
Other
4,240
/* If EntryPoint is NULL, then ASSERT(). If NewStack is NULL, then ASSERT(). */
VOID EFIAPI InternalSwitchStack(IN SWITCH_STACK_ENTRY_POINT EntryPoint, IN VOID *Context1 OPTIONAL, IN VOID *Context2 OPTIONAL, IN VOID *NewStack, IN VA_LIST Marker)
/* If EntryPoint is NULL, then ASSERT(). If NewStack is NULL, then ASSERT(). */ VOID EFIAPI InternalSwitchStack(IN SWITCH_STACK_ENTRY_POINT EntryPoint, IN VOID *Context1 OPTIONAL, IN VOID *Context2 OPTIONAL, IN VOID *NewStack, IN VA_LIST Marker)
{ InternalSwitchStackAsm (Context1, Context2, EntryPoint, (VOID *)((UINTN)NewStack - sizeof (VOID *))); ASSERT (FALSE); }
tianocore/edk2
C++
Other
4,240
/* Read all the FIFO status flag of the device.. */
int32_t lps22hh_fifo_src_get(stmdev_ctx_t *ctx, lps22hh_fifo_status2_t *val)
/* Read all the FIFO status flag of the device.. */ int32_t lps22hh_fifo_src_get(stmdev_ctx_t *ctx, lps22hh_fifo_status2_t *val)
{ int32_t ret; ret = lps22hh_read_reg(ctx, LPS22HH_FIFO_STATUS2, (uint8_t *) val, 1); return ret; }
eclipse-threadx/getting-started
C++
Other
310
/* This function sets the number of Acquisition cycles in the ADC Channel Acquisition Time Sequencer Registers. The sequencer must be disabled before writing to these regsiters. */
int XAdcPs_SetSeqAcqTime(XAdcPs *InstancePtr, u32 AcqCyclesChMask)
/* This function sets the number of Acquisition cycles in the ADC Channel Acquisition Time Sequencer Registers. The sequencer must be disabled before writing to these regsiters. */ int XAdcPs_SetSeqAcqTime(XAdcPs *InstancePtr, u32 AcqCyclesChMask)
{ Xil_AssertNonvoid(InstancePtr != NULL); Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); if ((XAdcPs_GetSequencerMode(InstancePtr) != XADCPS_SEQ_MODE_SAFE)) { return XST_FAILURE; } XAdcPs_WriteInternalReg(InstancePtr, XADCPS_SEQ06_OFFSET, (AcqCyclesChMask & XADCPS_SEQ06_CH_VALID_MASK)); XAdcPs_WriteInternalReg(InstancePtr, XADCPS_SEQ07_OFFSET, (AcqCyclesChMask >> XADCPS_SEQ_CH_AUX_SHIFT) & XADCPS_SEQ07_CH_VALID_MASK); return XST_SUCCESS; }
ua1arn/hftrx
C++
null
69
/* USBH_TEMPLATE_InterfaceDeInit The function DeInit the Pipes used for the TEMPLATE class. */
USBH_StatusTypeDef USBH_TEMPLATE_InterfaceDeInit(USBH_HandleTypeDef *phost)
/* USBH_TEMPLATE_InterfaceDeInit The function DeInit the Pipes used for the TEMPLATE class. */ USBH_StatusTypeDef USBH_TEMPLATE_InterfaceDeInit(USBH_HandleTypeDef *phost)
{ UNUSED(phost); return USBH_OK; }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* An strf atom is a BITMAPINFOHEADER struct. This struct is 40 bytes itself, but can have extradata appended at the end after the 40 bytes belonging to the struct. */
static int mov_read_strf(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
/* An strf atom is a BITMAPINFOHEADER struct. This struct is 40 bytes itself, but can have extradata appended at the end after the 40 bytes belonging to the struct. */ static int mov_read_strf(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
{ AVStream *st; if (c->fc->nb_streams < 1) return 0; if (atom.size <= 40) return 0; st = c->fc->streams[c->fc->nb_streams-1]; if((uint64_t)atom.size > (1<<30)) return -1; av_free(st->codec->extradata); st->codec->extradata = av_mallocz(atom.size - 40 + FF_INPUT_BUFFER_PADDING_SIZE); if (!st->codec->extradata) return AVERROR(ENOMEM); st->codec->extradata_size = atom.size - 40; url_fskip(pb, 40); get_buffer(pb, st->codec->extradata, atom.size - 40); return 0; }
DC-SWAT/DreamShell
C++
null
404
/* Set the PWM frequency of the PWM module. */
unsigned long xPWMFrequencyConfig(unsigned long ulBase, unsigned long ulChannel, unsigned long ulConfig)
/* Set the PWM frequency of the PWM module. */ unsigned long xPWMFrequencyConfig(unsigned long ulBase, unsigned long ulChannel, unsigned long ulConfig)
{ (void) ulChannel; xASSERT(ulBase == xPWM1_BASE); xASSERT( (ulChannel == xPWM_CHANNEL0) || (ulChannel == xPWM_CHANNEL1) || (ulChannel == xPWM_CHANNEL2) || (ulChannel == xPWM_CHANNEL3) || (ulChannel == xPWM_CHANNEL4) || (ulChannel == xPWM_CHANNEL5) || (ulChannel == xPWM_CHANNEL6) ); xHWREG(ulBase + PWM_PR) = ulConfig; return (SysCtlPeripheralClockGet(PCLKSEL_PWM1)/ulConfig); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Configure channel parameters by channel or operation.Support configure several channels at the same time. */
TSC_ErrorTypeDef TSC_SetChannelCfg(TSC_Module *TSC_Def, TSC_ChnCfg *ChnCfg, uint32_t Channels)
/* Configure channel parameters by channel or operation.Support configure several channels at the same time. */ TSC_ErrorTypeDef TSC_SetChannelCfg(TSC_Module *TSC_Def, TSC_ChnCfg *ChnCfg, uint32_t Channels)
{ TSC_ErrorTypeDef err; if (TSC_Def != TSC) return TSC_ERROR_PARAMETER; if (0 == ChnCfg) return TSC_ERROR_PARAMETER; err = TSC_ConfigInternalResistor(TSC_Def, Channels, ChnCfg->TSC_ResisValue); if (err != TSC_ERROR_OK) return err; err = TSC_ConfigThreshold(TSC_Def, Channels, ChnCfg->TSC_Base, ChnCfg->TSC_Delta); return err; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Convert a driver from the Untrused back to the Scheduled state. */
EFI_STATUS EFIAPI CoreTrust(IN EFI_HANDLE FirmwareVolumeHandle, IN EFI_GUID *DriverName)
/* Convert a driver from the Untrused back to the Scheduled state. */ EFI_STATUS EFIAPI CoreTrust(IN EFI_HANDLE FirmwareVolumeHandle, IN EFI_GUID *DriverName)
{ LIST_ENTRY *Link; EFI_CORE_DRIVER_ENTRY *DriverEntry; for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) { DriverEntry = CR (Link, EFI_CORE_DRIVER_ENTRY, Link, EFI_CORE_DRIVER_ENTRY_SIGNATURE); if ((DriverEntry->FvHandle == FirmwareVolumeHandle) && DriverEntry->Untrusted && CompareGuid (DriverName, &DriverEntry->FileName)) { CoreAcquireDispatcherLock (); DriverEntry->Untrusted = FALSE; DriverEntry->Scheduled = TRUE; InsertTailList (&mScheduledQueue, &DriverEntry->ScheduledLink); CoreReleaseDispatcherLock (); return EFI_SUCCESS; } } return EFI_NOT_FOUND; }
tianocore/edk2
C++
Other
4,240
/* Disables asynchronous callback generation for a given channel and type. Disables asynchronous callbacks for a given logical DAC channel and type. */
enum status_code dac_chan_disable_callback(struct dac_module *const module_inst, const enum dac_channel channel, const enum dac_callback type)
/* Disables asynchronous callback generation for a given channel and type. Disables asynchronous callbacks for a given logical DAC channel and type. */ enum status_code dac_chan_disable_callback(struct dac_module *const module_inst, const enum dac_channel channel, const enum dac_callback type)
{ Assert(module_inst); UNUSED(channel); if (module_inst->start_on_event[channel] == false) { return STATUS_ERR_UNSUPPORTED_DEV; } module_inst->callback_enable[channel][type] = false; return STATUS_OK; }
memfault/zero-to-main
C++
null
200
/* @work_queue_entry: Work queue entry to free Returns Zero on success, Negative on failure. */
int cvm_oct_free_work(void *work_queue_entry)
/* @work_queue_entry: Work queue entry to free Returns Zero on success, Negative on failure. */ int cvm_oct_free_work(void *work_queue_entry)
{ cvmx_wqe_t *work = work_queue_entry; int segments = work->word2.s.bufs; union cvmx_buf_ptr segment_ptr = work->packet_ptr; while (segments--) { union cvmx_buf_ptr next_ptr = *(union cvmx_buf_ptr *) cvmx_phys_to_ptr(segment_ptr.s.addr - 8); if (unlikely(!segment_ptr.s.i)) cvmx_fpa_free(cvm_oct_get_buffer_ptr(segment_ptr), segment_ptr.s.pool, DONT_WRITEBACK(CVMX_FPA_PACKET_POOL_SIZE / 128)); segment_ptr = next_ptr; } cvmx_fpa_free(work, CVMX_FPA_WQE_POOL, DONT_WRITEBACK(1)); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* If there is no additional space for HOB creation, then ASSERT(). */
VOID EFIAPI BuildMemoryAllocationHob(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN EFI_MEMORY_TYPE MemoryType)
/* If there is no additional space for HOB creation, then ASSERT(). */ VOID EFIAPI BuildMemoryAllocationHob(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN EFI_MEMORY_TYPE MemoryType)
{ EFI_HOB_MEMORY_ALLOCATION *Hob; ASSERT ( ((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) && ((Length & (EFI_PAGE_SIZE - 1)) == 0) ); Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, (UINT16)sizeof (EFI_HOB_MEMORY_ALLOCATION)); if (Hob == NULL) { return; } ZeroMem (&(Hob->AllocDescriptor.Name), sizeof (EFI_GUID)); Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress; Hob->AllocDescriptor.MemoryLength = Length; Hob->AllocDescriptor.MemoryType = MemoryType; ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved)); }
tianocore/edk2
C++
Other
4,240
/* USB Device Configure Function Parameters: cfg: Device Configure/Deconfigure Return Value: None */
void USBD_Configure(BOOL cfg)
/* USB Device Configure Function Parameters: cfg: Device Configure/Deconfigure Return Value: None */ void USBD_Configure(BOOL cfg)
{ if (cfg == __FALSE) { g_u32FreeBufAddr = CEP_BUF_BASE + CEP_BUF_LEN; } }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* RCC Turn on an Oscillator. Enable an oscillator and power on. Each oscillator requires an amount of time to settle to a usable state. Refer to datasheets for time delay information. A status flag is available to indicate when the oscillator becomes ready (see */
void rcc_osc_on(enum rcc_osc osc)
/* RCC Turn on an Oscillator. Enable an oscillator and power on. Each oscillator requires an amount of time to settle to a usable state. Refer to datasheets for time delay information. A status flag is available to indicate when the oscillator becomes ready (see */ void rcc_osc_on(enum rcc_osc osc)
{ switch (osc) { case RCC_PLL: RCC_CR |= RCC_CR_PLLON; break; case RCC_PLL2: RCC_CR |= RCC_CR_PLL2ON; break; case RCC_PLL3: RCC_CR |= RCC_CR_PLL3ON; break; case RCC_HSE: RCC_CR |= RCC_CR_HSEON; break; case RCC_HSI: RCC_CR |= RCC_CR_HSION; break; case RCC_LSE: RCC_BDCR |= RCC_BDCR_LSEON; break; case RCC_LSI: RCC_CSR |= RCC_CSR_LSION; break; } }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* toggle the led every 500ms , V1.0.0, firmware for GD32F1x0(x=3,5) , V2.0.0, firmware for GD32F1x0(x=3,5,7,9) , V3.0.0, firmware update for GD32F1x0(x=3,5,7,9) */
void led_spark(void)
/* toggle the led every 500ms , V1.0.0, firmware for GD32F1x0(x=3,5) , V2.0.0, firmware for GD32F1x0(x=3,5,7,9) , V3.0.0, firmware update for GD32F1x0(x=3,5,7,9) */ void led_spark(void)
{ static __IO uint32_t timingdelaylocal = 0; if(timingdelaylocal){ if(timingdelaylocal < 500){ gd_eval_ledon(LED2); }else{ gd_eval_ledoff(LED2); } timingdelaylocal--; }else{ timingdelaylocal = 1000; } }
liuxuming/trochili
C++
Apache License 2.0
132
/* Completes the Map() operation and releases any corresponding resources. */
EFI_STATUS EFIAPI IoMmuUnmap(IN EDKII_IOMMU_PROTOCOL *This, IN VOID *Mapping)
/* Completes the Map() operation and releases any corresponding resources. */ EFI_STATUS EFIAPI IoMmuUnmap(IN EDKII_IOMMU_PROTOCOL *This, IN VOID *Mapping)
{ return IoMmuUnmapWorker ( This, Mapping, FALSE ); }
tianocore/edk2
C++
Other
4,240
/* V6 voltage On I2C bus, sending a "x" byte to the max1586 means : set V6 to either 0V, 1.8V, 2.5V, 3V depending on (x & 0x3) As regulator framework doesn't accept voltages to be 0V, we use 1uV. */
static int max1586_v6_calc_voltage(unsigned selector)
/* V6 voltage On I2C bus, sending a "x" byte to the max1586 means : set V6 to either 0V, 1.8V, 2.5V, 3V depending on (x & 0x3) As regulator framework doesn't accept voltages to be 0V, we use 1uV. */ static int max1586_v6_calc_voltage(unsigned selector)
{ static int voltages_uv[] = { 1, 1800000, 2500000, 3000000 }; return voltages_uv[selector]; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* See mss_uart.h for details of how to use this function. */
void MSS_UART_set_rx_handler(mss_uart_instance_t *this_uart, mss_uart_irq_handler_t handler, mss_uart_rx_trig_level_t trigger_level)
/* See mss_uart.h for details of how to use this function. */ void MSS_UART_set_rx_handler(mss_uart_instance_t *this_uart, mss_uart_irq_handler_t handler, mss_uart_rx_trig_level_t trigger_level)
{ ASSERT((this_uart == &g_mss_uart0) || (this_uart == &g_mss_uart1)); ASSERT(handler != INVALID_IRQ_HANDLER ); ASSERT(trigger_level < MSS_UART_FIFO_INVALID_TRIG_LEVEL); if(((this_uart == &g_mss_uart0) || (this_uart == &g_mss_uart1)) && (handler != INVALID_IRQ_HANDLER) && (trigger_level < MSS_UART_FIFO_INVALID_TRIG_LEVEL)) { this_uart->rx_handler = handler; this_uart->hw_reg->FCR = (this_uart->hw_reg->FCR & (uint8_t)(~((uint8_t)FCR_TRIG_LEVEL_MASK))) | (uint8_t)trigger_level; NVIC_ClearPendingIRQ(this_uart->irqn); set_bit_reg8(&this_uart->hw_reg->IER,ERBFI); NVIC_EnableIRQ(this_uart->irqn); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This service is published by the SEC phase. The SEC phase handoff has an optional EFI_PEI_PPI_DESCRIPTOR list as its final argument when control is passed from SEC into the PEI Foundation. As such, if the platform supports collecting performance data in SEC, this information is encapsulated into the data structure abstracted by this service. This information is collected for the boot-strap processor (BSP) on IA-32. */
EFI_STATUS EFIAPI GetPerformancePostMemory(IN CONST EFI_PEI_SERVICES **PeiServices, IN PEI_SEC_PERFORMANCE_PPI *This, OUT FIRMWARE_SEC_PERFORMANCE *Performance)
/* This service is published by the SEC phase. The SEC phase handoff has an optional EFI_PEI_PPI_DESCRIPTOR list as its final argument when control is passed from SEC into the PEI Foundation. As such, if the platform supports collecting performance data in SEC, this information is encapsulated into the data structure abstracted by this service. This information is collected for the boot-strap processor (BSP) on IA-32. */ EFI_STATUS EFIAPI GetPerformancePostMemory(IN CONST EFI_PEI_SERVICES **PeiServices, IN PEI_SEC_PERFORMANCE_PPI *This, OUT FIRMWARE_SEC_PERFORMANCE *Performance)
{ SEC_PLATFORM_INFORMATION_CONTEXT_HOB *SecPlatformInformationContexHob; if ((This == NULL) || (Performance == NULL)) { return EFI_INVALID_PARAMETER; } SecPlatformInformationContexHob = GetFirstGuidHob (&gEfiCallerIdGuid); if (SecPlatformInformationContexHob == NULL) { return EFI_NOT_FOUND; } Performance->ResetEnd = SecPlatformInformationContexHob->FirmwareSecPerformance.ResetEnd; return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* This function use to configure smartcard UART mode line setting. */
uint32_t SCUART_SetLineConfig(SC_T *sc, uint32_t u32Baudrate, uint32_t u32DataWidth, uint32_t u32Parity, uint32_t u32StopBits)
/* This function use to configure smartcard UART mode line setting. */ uint32_t SCUART_SetLineConfig(SC_T *sc, uint32_t u32Baudrate, uint32_t u32DataWidth, uint32_t u32Parity, uint32_t u32StopBits)
{ uint32_t u32Clk = SCUART_GetClock(sc), u32Div; if(u32Baudrate == 0UL) { u32Div = sc->ETUCTL & SC_ETUCTL_ETURDIV_Msk; } else { u32Div = (u32Clk + (u32Baudrate >> 1) - 1UL)/ u32Baudrate - 1UL; sc->ETUCTL = u32Div; } sc->CTL = u32StopBits | SC_CTL_SCEN_Msk; sc->UARTCTL = u32Parity | u32DataWidth | SC_UARTCTL_UARTEN_Msk; return(u32Clk / (u32Div + 1UL)); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Caller must observe xtime_lock via read_seqbegin/read_seqretry to ensure that the clocksource does not change! */
u64 timekeeping_max_deferment(void)
/* Caller must observe xtime_lock via read_seqbegin/read_seqretry to ensure that the clocksource does not change! */ u64 timekeeping_max_deferment(void)
{ return timekeeper.clock->max_idle_ns; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Add a mac address to the device whitelist. */
sl_status_t sl_wfx_add_whitelist_address(const sl_wfx_mac_address_t *mac_address)
/* Add a mac address to the device whitelist. */ sl_status_t sl_wfx_add_whitelist_address(const sl_wfx_mac_address_t *mac_address)
{ sl_wfx_add_whitelist_addr_req_body_t payload; memcpy(payload.mac, &mac_address->octet, sizeof(payload.mac)); return sl_wfx_send_command(SL_WFX_ADD_WHITELIST_ADDR_REQ_ID, &payload, sizeof(payload), SL_WFX_SOFTAP_INTERFACE, NULL); }
eclipse-threadx/getting-started
C++
Other
310
/* Add a POSIX style lock to a file. We merge adjacent & overlapping locks whenever possible. POSIX locks are sorted by owner task, then by starting address */
int posix_lock_file_wait(struct file *filp, struct file_lock *fl)
/* Add a POSIX style lock to a file. We merge adjacent & overlapping locks whenever possible. POSIX locks are sorted by owner task, then by starting address */ int posix_lock_file_wait(struct file *filp, struct file_lock *fl)
{ int error; might_sleep (); for (;;) { error = posix_lock_file(filp, fl, NULL); if (error != FILE_LOCK_DEFERRED) break; error = wait_event_interruptible(fl->fl_wait, !fl->fl_next); if (!error) continue; locks_delete_block(fl); break; } return error; }
robutest/uclinux
C++
GPL-2.0
60
/* Update the Variable SystemCoreClock. This function is used to update the variable SystemCoreClock and must be called whenever the core clock is changed. */
void SystemCoreClockUpdate(void)
/* Update the Variable SystemCoreClock. This function is used to update the variable SystemCoreClock and must be called whenever the core clock is changed. */ void SystemCoreClockUpdate(void)
{ PllClock = CLK_GetPLLClockFreq(); SystemCoreClock = CLK_GetCPUFreq(); CyclesPerUs = (SystemCoreClock + 500000UL) / 1000000UL; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* challenge_response - ChallengeResponse() - RFC 2759, Sect. 8.5 @challenge: 8-octet Challenge (IN) @password_hash: 16-octet PasswordHash (IN) @response: 24-octet Response (OUT) */
void challenge_response(const u8 *challenge, const u8 *password_hash, u8 *response)
/* challenge_response - ChallengeResponse() - RFC 2759, Sect. 8.5 @challenge: 8-octet Challenge (IN) @password_hash: 16-octet PasswordHash (IN) @response: 24-octet Response (OUT) */ void challenge_response(const u8 *challenge, const u8 *password_hash, u8 *response)
{ u8 zpwd[7]; des_encrypt(challenge, password_hash, response); des_encrypt(challenge, password_hash + 7, response + 8); zpwd[0] = password_hash[14]; zpwd[1] = password_hash[15]; os_memset(zpwd + 2, 0, 5); des_encrypt(challenge, zpwd, response + 16); }
retro-esp32/RetroESP32
C++
Creative Commons Attribution Share Alike 4.0 International
581
/* Block until all the outstanding chunks have been delivered by the hardware. */
static int qemu_rdma_drain_cq(QEMUFile *f, RDMAContext *rdma)
/* Block until all the outstanding chunks have been delivered by the hardware. */ static int qemu_rdma_drain_cq(QEMUFile *f, RDMAContext *rdma)
{ int ret; if (qemu_rdma_write_flush(f, rdma) < 0) { return -EIO; } while (rdma->nb_sent) { ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_RDMA_WRITE, NULL); if (ret < 0) { fprintf(stderr, "rdma migration: complete polling error!\n"); return -EIO; } } qemu_rdma_unregister_waiting(rdma); return 0; }
ve3wwg/teensy3_qemu
C
Other
15
/* Indicates polarity of DEN signal on OIS chain.. */
int32_t lsm6dso_aux_den_polarity_get(lsm6dso_ctx_t *ctx, lsm6dso_den_lh_ois_t *val)
/* Indicates polarity of DEN signal on OIS chain.. */ int32_t lsm6dso_aux_den_polarity_get(lsm6dso_ctx_t *ctx, lsm6dso_den_lh_ois_t *val)
{ lsm6dso_int_ois_t reg; int32_t ret; ret = lsm6dso_read_reg(ctx, LSM6DSO_INT_OIS, (uint8_t*)&reg, 1); switch (reg.den_lh_ois) { case LSM6DSO_AUX_DEN_ACTIVE_LOW: *val = LSM6DSO_AUX_DEN_ACTIVE_LOW; break; case LSM6DSO_AUX_DEN_ACTIVE_HIGH: *val = LSM6DSO_AUX_DEN_ACTIVE_HIGH; break; default: *val = LSM6DSO_AUX_DEN_ACTIVE_LOW; break; } return ret; }
alexander-g-dean/ESF
C++
null
41
/* Configures the remapping capabilities of encoder mode. @ note This feature implement the so-called M/T method for measuring speed and position using quadrature encoders. */
void SYSCFG_EncoderRemapConfig(uint32_t SYSCFG_EncoderRemap)
/* Configures the remapping capabilities of encoder mode. @ note This feature implement the so-called M/T method for measuring speed and position using quadrature encoders. */ void SYSCFG_EncoderRemapConfig(uint32_t SYSCFG_EncoderRemap)
{ assert_param(IS_SYSCFG_ENCODER_REMAP(SYSCFG_EncoderRemap)); SYSCFG->CFGR1 &= (uint32_t)(~SYSCFG_CFGR1_ENCODER_MODE); SYSCFG->CFGR1 |= (uint32_t)(SYSCFG_EncoderRemap); }
ajhc/demo-cortex-m3
C++
null
38
/* Only the least significant 4 bits are used for both values, eg 0 to 15. */
void wdt_set_time(uint8_t time1, uint8_t time2)
/* Only the least significant 4 bits are used for both values, eg 0 to 15. */ void wdt_set_time(uint8_t time1, uint8_t time2)
{ WDT_TORR = ((0xF & time1) << 4) | (0xF & time2); }
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* Check user specified FileRow is above current screen. */
BOOLEAN AboveCurrentScreen(IN UINTN FileRow)
/* Check user specified FileRow is above current screen. */ BOOLEAN AboveCurrentScreen(IN UINTN FileRow)
{ if (FileRow < FileBuffer.LowVisibleRange.Row) { return TRUE; } return FALSE; }
tianocore/edk2
C++
Other
4,240
/* All callback functions below are called from the LwIP-thread. For ESP, this is the FreeRTOS LwIP-thread. Copy data to the reading threads' buffer and resume the thread. */
static void udp_recv_from_copy_resume(struct socket_t *socket_p, struct pbuf *pbuf_p)
/* All callback functions below are called from the LwIP-thread. For ESP, this is the FreeRTOS LwIP-thread. Copy data to the reading threads' buffer and resume the thread. */ static void udp_recv_from_copy_resume(struct socket_t *socket_p, struct pbuf *pbuf_p)
{ struct recv_from_args_t *args_p; ssize_t size; args_p = socket_p->input.cb.args_p; size = args_p->size; if (size > pbuf_p->tot_len) { size = pbuf_p->tot_len; } fs_counter_increment(&module.udp_rx_bytes, size); pbuf_copy_partial(pbuf_p, args_p->buf_p, size, 0); pbuf_free(pbuf_p); if (args_p->remote_addr_p != NULL) { *args_p->remote_addr_p = socket_p->input.u.recvfrom.remote_addr; } resume_thrd(socket_p->input.cb.thrd_p, size); }
eerimoq/simba
C++
Other
337
/* input: blade_id - blade on which resources should be reserved cbrs - number of CBRs dsr_bytes - number of DSR bytes needed output: handle to identify resource (0 = async resources already reserved) */
unsigned long gru_reserve_async_resources(int blade_id, int cbrs, int dsr_bytes, struct completion *cmp)
/* input: blade_id - blade on which resources should be reserved cbrs - number of CBRs dsr_bytes - number of DSR bytes needed output: handle to identify resource (0 = async resources already reserved) */ unsigned long gru_reserve_async_resources(int blade_id, int cbrs, int dsr_bytes, struct completion *cmp)
{ struct gru_blade_state *bs; struct gru_thread_state *kgts; int ret = 0; bs = gru_base[blade_id]; down_write(&bs->bs_kgts_sema); if (bs->bs_async_dsr_bytes + bs->bs_async_cbrs) goto done; bs->bs_async_dsr_bytes = dsr_bytes; bs->bs_async_cbrs = cbrs; bs->bs_async_wq = cmp; kgts = bs->bs_kgts; if (kgts && kgts->ts_gru) gru_unload_context(kgts, 0); ret = ASYNC_BID_TO_HAN(blade_id); done: up_write(&bs->bs_kgts_sema); return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* This comparator searches for the next Endpoint descriptor inside the current interface descriptor, aborting the search if another interface descriptor is found before the required endpoint. */
uint8_t DComp_NextMouseInterfaceDataEndpoint(void *CurrentDescriptor)
/* This comparator searches for the next Endpoint descriptor inside the current interface descriptor, aborting the search if another interface descriptor is found before the required endpoint. */ uint8_t DComp_NextMouseInterfaceDataEndpoint(void *CurrentDescriptor)
{ USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t); if (Header->Type == DTYPE_Endpoint) return DESCRIPTOR_SEARCH_Found; else if (Header->Type == DTYPE_Interface) return DESCRIPTOR_SEARCH_Fail; else return DESCRIPTOR_SEARCH_NotFound; }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* 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,ulTemp1; ulTemp0 = (xHWREG(ulBase + TIMER_TISR) & TIMER_TISR_TIF); xHWREG(ulBase + TIMER_TISR) = ulTemp0; ulTemp1 = (xHWREG(ulBase + TIMER_TEISR) & TIMER_TISR_TIF); xHWREG(ulBase + TIMER_TEISR) = ulTemp1; if (g_pfnTimerHandlerCallbacks[1] != 0) { g_pfnTimerHandlerCallbacks[1](0, 0, ulTemp0 | ulTemp1, 0); } }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Checks whether the specified SPI flag is set or not. */
uint8_t SPI_ReadStatusFlag(SPI_T *spi, SPI_FLAG_T flag)
/* Checks whether the specified SPI flag is set or not. */ uint8_t SPI_ReadStatusFlag(SPI_T *spi, SPI_FLAG_T flag)
{ uint16_t status; status = (uint16_t)(spi->STS & flag); if (status == flag) { return SET; } return RESET; }
pikasTech/PikaPython
C++
MIT License
1,403
/* This function rotates the 64-bit value Operand to the right by Count bits. The high Count bits are fill with the low Count bits of Operand. The rotated value is returned. */
UINT64 EFIAPI InternalMathRRotU64(IN UINT64 Operand, IN UINTN Count)
/* This function rotates the 64-bit value Operand to the right by Count bits. The high Count bits are fill with the low Count bits of Operand. The rotated value is returned. */ UINT64 EFIAPI InternalMathRRotU64(IN UINT64 Operand, IN UINTN Count)
{ return (Operand >> Count) | (Operand << (64 - Count)); }
tianocore/edk2
C++
Other
4,240
/* Returns: TRUE if @data was successfully added to the @stream. */
gboolean g_data_output_stream_put_uint32(GDataOutputStream *stream, guint32 data, GCancellable *cancellable, GError **error)
/* Returns: TRUE if @data was successfully added to the @stream. */ gboolean g_data_output_stream_put_uint32(GDataOutputStream *stream, guint32 data, GCancellable *cancellable, GError **error)
{ gsize bytes_written; g_return_val_if_fail (G_IS_DATA_OUTPUT_STREAM (stream), FALSE); switch (stream->priv->byte_order) { case G_DATA_STREAM_BYTE_ORDER_BIG_ENDIAN: data = GUINT32_TO_BE (data); break; case G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN: data = GUINT32_TO_LE (data); break; case G_DATA_STREAM_BYTE_ORDER_HOST_ENDIAN: default: break; } return g_output_stream_write_all (G_OUTPUT_STREAM (stream), &data, 4, &bytes_written, cancellable, error); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330