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
/* param base ADC peripheral base address. param mode Setting the hardware average mode. See "adc_hardware_average_mode_t". */
void ADC_SetHardwareAverageConfig(ADC_Type *base, adc_hardware_average_mode_t mode)
/* param base ADC peripheral base address. param mode Setting the hardware average mode. See "adc_hardware_average_mode_t". */ void ADC_SetHardwareAverageConfig(ADC_Type *base, adc_hardware_average_mode_t mode)
{ uint32_t tmp32; if (mode == kADC_HardwareAverageDiasable) { base->GC &= ~ADC_GC_AVGE_MASK; } else { tmp32 = base->CFG & ~ADC_CFG_AVGS_MASK; tmp32 |= ADC_CFG_AVGS(mode); base->CFG = tmp32; base->GC |= ADC_GC_AVGE_MASK; } }
eclipse-threadx/getting-started
C++
Other
310
/* platform_restore_cleanup - switch the platform to the normal mode of operation after a failing restore. If platform_pre_restore() has been called before the failing restore, this function must be called too, regardless of the result of platform_pre_restore(). */
static void platform_restore_cleanup(int platform_mode)
/* platform_restore_cleanup - switch the platform to the normal mode of operation after a failing restore. If platform_pre_restore() has been called before the failing restore, this function must be called too, regardless of the result of platform_pre_restore(). */ static void platform_restore_cleanup(int platform_mod...
{ if (platform_mode && hibernation_ops) hibernation_ops->restore_cleanup(); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* this function calculates the size of data that can be inserted into the lli table from this array the condition is that either the table is full (all etnries are entered), or there are no more entries in the lli array */
static unsigned long sep_calculate_lli_table_max_size(struct sep_lli_entry_t *lli_in_array_ptr, unsigned long num_array_entries)
/* this function calculates the size of data that can be inserted into the lli table from this array the condition is that either the table is full (all etnries are entered), or there are no more entries in the lli array */ static unsigned long sep_calculate_lli_table_max_size(struct sep_lli_entry_t *lli_in_array_ptr,...
{ unsigned long table_data_size = 0; unsigned long counter; for (counter = 0; (counter < (SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP - 1)) && (counter < num_array_entries); counter++) table_data_size += lli_in_array_ptr[counter].block_size; return table_data_size; }
robutest/uclinux
C++
GPL-2.0
60
/* return the total number of blocks to be allocate, including the direct and indirect blocks. */
static int ext4_blks_to_allocate(Indirect *branch, int k, unsigned int blks, int blocks_to_boundary)
/* return the total number of blocks to be allocate, including the direct and indirect blocks. */ static int ext4_blks_to_allocate(Indirect *branch, int k, unsigned int blks, int blocks_to_boundary)
{ unsigned int count = 0; if (k > 0) { if (blks < blocks_to_boundary + 1) count += blks; else count += blocks_to_boundary + 1; return count; } count++; while (count < blks && count <= blocks_to_boundary && le32_to_cpu(*(branch[0].p + count)) == 0) { count++; } return count; }
robutest/uclinux
C++
GPL-2.0
60
/* This function returns %0 on success and a negative error code on failure. */
static int make_node_dirty(struct ubifs_info *c, int node_type, int node_num, int lnum, int offs)
/* This function returns %0 on success and a negative error code on failure. */ static int make_node_dirty(struct ubifs_info *c, int node_type, int node_num, int lnum, int offs)
{ switch (node_type) { case UBIFS_LPT_NNODE: return make_nnode_dirty(c, node_num, lnum, offs); case UBIFS_LPT_PNODE: return make_pnode_dirty(c, node_num, lnum, offs); case UBIFS_LPT_LTAB: return make_ltab_dirty(c, lnum, offs); case UBIFS_LPT_LSAVE: return make_lsave_dirty(c, lnum, offs); } return -EINVAL...
robutest/uclinux
C++
GPL-2.0
60
/* If DhContext is NULL, then return FALSE. If PeerPublicKey is NULL, then return FALSE. If KeySize is NULL, then return FALSE. If Key is NULL, then return FALSE. If KeySize is not large enough, then return FALSE. */
BOOLEAN EFIAPI DhComputeKey(IN OUT VOID *DhContext, IN CONST UINT8 *PeerPublicKey, IN UINTN PeerPublicKeySize, OUT UINT8 *Key, IN OUT UINTN *KeySize)
/* If DhContext is NULL, then return FALSE. If PeerPublicKey is NULL, then return FALSE. If KeySize is NULL, then return FALSE. If Key is NULL, then return FALSE. If KeySize is not large enough, then return FALSE. */ BOOLEAN EFIAPI DhComputeKey(IN OUT VOID *DhContext, IN CONST UINT8 *PeerPublicKey, IN UINTN PeerPublicK...
{ BIGNUM *Bn; INTN Size; if ((DhContext == NULL) || (PeerPublicKey == NULL) || (KeySize == NULL) || (Key == NULL)) { return FALSE; } if (PeerPublicKeySize > INT_MAX) { return FALSE; } Bn = BN_bin2bn (PeerPublicKey, (UINT32)PeerPublicKeySize, NULL); if (Bn == NULL) { return FALSE; } S...
tianocore/edk2
C++
Other
4,240
/* Find the symbol string according to address, then print it. */
UINTN EdbFindAndPrintSymbol(IN UINTN Address)
/* Find the symbol string according to address, then print it. */ UINTN EdbFindAndPrintSymbol(IN UINTN Address)
{ CHAR8 *SymbolStr; SymbolStr = FindSymbolStr (Address); if (SymbolStr != NULL) { EDBSPrintWithOffset ( mInstructionString.Content, EDB_INSTRUCTION_CONTENT_MAX_SIZE, mInstructionContentOffset, L"[%a]", SymbolStr ); return 1; } return 0; }
tianocore/edk2
C++
Other
4,240
/* Output: void, but we will add to proto tree if !NULL. */
static void dissect_lsp_l1_es_neighbors_clv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int id_length, int length)
/* Output: void, but we will add to proto tree if !NULL. */ static void dissect_lsp_l1_es_neighbors_clv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int id_length, int length)
{ dissect_lsp_eis_neighbors_clv_inner(tvb, pinfo, tree, offset, length, id_length, TRUE, TRUE); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Disable Timer Capture/Compare Control Update with Trigger. If the capture/compare control bits CCxE, CCxNE and OCxM are set to be preloaded, they are updated by software generating the COMG event ( */
void timer_disable_compare_control_update_on_trigger(uint32_t timer_peripheral)
/* Disable Timer Capture/Compare Control Update with Trigger. If the capture/compare control bits CCxE, CCxNE and OCxM are set to be preloaded, they are updated by software generating the COMG event ( */ void timer_disable_compare_control_update_on_trigger(uint32_t timer_peripheral)
{ TIM_CR2(timer_peripheral) &= ~TIM_CR2_CCUS; }
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* Examine the instruction parsing context to determine if the address offset is relative to the instruction pointer. */
STATIC BOOLEAN IsRipRelative(IN CC_INSTRUCTION_DATA *InstructionData)
/* Examine the instruction parsing context to determine if the address offset is relative to the instruction pointer. */ STATIC BOOLEAN IsRipRelative(IN CC_INSTRUCTION_DATA *InstructionData)
{ CC_INSTRUCTION_OPCODE_EXT *Ext; Ext = &InstructionData->Ext; return ((InstructionData->Mode == LongMode64Bit) && (Ext->ModRm.Mod == 0) && (Ext->ModRm.Rm == 5) && (InstructionData->SibPresent == FALSE)); }
tianocore/edk2
C++
Other
4,240
/* get max lun of the mass storage device */
static usbh_status usbh_msc_maxlun_get(usbh_host *puhost, uint8_t *maxlun)
/* get max lun of the mass storage device */ static usbh_status usbh_msc_maxlun_get(usbh_host *puhost, uint8_t *maxlun)
{ usbh_status status = USBH_BUSY; if (puhost->control.ctl_state == CTL_IDLE) { puhost->control.setup.req = (usb_req) { .bmRequestType = USB_TRX_IN | USB_REQTYPE_CLASS | USB_RECPTYPE_ITF, .bRequest = BBB_GET_MAX_LUN, .wValue = 0U, .wIndex ...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Calculate the CRC value of a 8-bit data buffer. */
static int32_t CRC_WriteData8(const uint8_t au8Data[], uint32_t u32Len)
/* Calculate the CRC value of a 8-bit data buffer. */ static int32_t CRC_WriteData8(const uint8_t au8Data[], uint32_t u32Len)
{ uint32_t i; int32_t i32Ret = LL_ERR_INVD_PARAM; const uint32_t u32DataAddr = CRC_DATA_ADDR; if ((au8Data != NULL) && (u32Len != 0UL)) { for (i = 0UL; i < u32Len; i++) { RW_MEM8(u32DataAddr) = au8Data[i]; } i32Ret = LL_OK; } return i32Ret; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Set each fields of the LPTIM_InitStruct structure to its default value. */
void LPTIM_StructInit(LPTIM_InitType *LPTIM_InitStruct)
/* Set each fields of the LPTIM_InitStruct structure to its default value. */ void LPTIM_StructInit(LPTIM_InitType *LPTIM_InitStruct)
{ LPTIM_InitStruct->ClockSource = LPTIM_CLK_SOURCE_INTERNAL; LPTIM_InitStruct->Prescaler = LPTIM_PRESCALER_DIV1; LPTIM_InitStruct->Waveform = LPTIM_OUTPUT_WAVEFORM_PWM; LPTIM_InitStruct->Polarity = LPTIM_OUTPUT_POLARITY_REGULAR; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Called when the copy I/O has finished. kcopyd actually runs this code so don't block. */
static void copy_callback(int read_err, unsigned long write_err, void *context)
/* Called when the copy I/O has finished. kcopyd actually runs this code so don't block. */ static void copy_callback(int read_err, unsigned long write_err, void *context)
{ struct dm_snap_pending_exception *pe = context; struct dm_snapshot *s = pe->snap; if (read_err || write_err) pending_complete(pe, 0); else s->store->type->commit_exception(s->store, &pe->e, commit_callback, pe); }
robutest/uclinux
C++
GPL-2.0
60
/* Exactly @nmaskbits bits are displayed. Hex digits are grouped into comma-separated sets of eight digits per set. */
int bitmap_scnprintf(char *buf, unsigned int buflen, const unsigned long *maskp, int nmaskbits)
/* Exactly @nmaskbits bits are displayed. Hex digits are grouped into comma-separated sets of eight digits per set. */ int bitmap_scnprintf(char *buf, unsigned int buflen, const unsigned long *maskp, int nmaskbits)
{ int i, word, bit, len = 0; unsigned long val; const char *sep = ""; int chunksz; u32 chunkmask; chunksz = nmaskbits & (CHUNKSZ - 1); if (chunksz == 0) chunksz = CHUNKSZ; i = ALIGN(nmaskbits, CHUNKSZ) - CHUNKSZ; for (; i >= 0; i -= CHUNKSZ) { chunkmask = ((1ULL << chunksz) - 1); word = i / BITS_PER_LONG...
robutest/uclinux
C++
GPL-2.0
60
/* Update CR6 value Firstly stop DM910X , then written value and start */
static void update_cr6(u32, unsigned long)
/* Update CR6 value Firstly stop DM910X , then written value and start */ static void update_cr6(u32, unsigned long)
{ u32 cr6_tmp; cr6_tmp = cr6_data & ~0x2002; outl(cr6_tmp, ioaddr + DCR6); udelay(5); outl(cr6_data, ioaddr + DCR6); udelay(5); }
robutest/uclinux
C++
GPL-2.0
60
/* 6.5.4.1. LAN Redundancy Get Information (Confirmed Service Id = 1) 6.5.4.1.1. Request Message Parameters */
static void dissect_ff_msg_lr_get_info_req(tvbuff_t *tvb, gint offset, guint32 length, packet_info *pinfo, proto_tree *tree)
/* 6.5.4.1. LAN Redundancy Get Information (Confirmed Service Id = 1) 6.5.4.1.1. Request Message Parameters */ static void dissect_ff_msg_lr_get_info_req(tvbuff_t *tvb, gint offset, guint32 length, packet_info *pinfo, proto_tree *tree)
{ proto_tree *sub_tree; col_set_str(pinfo->cinfo, COL_INFO, "LAN Redundancy Get Information Request"); if (!tree) { return; } if (length) { sub_tree = proto_tree_add_subtree(tree, tvb, offset, length, ett_ff_lr_get_info_req, NULL, "LAN Redundancy Get Information Request")...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* The PAL call uwb_rsv_destroy() for all accepted reservations before calling uwb_pal_unregister(). */
void uwb_rsv_accept(struct uwb_rsv *rsv, uwb_rsv_cb_f cb, void *pal_priv)
/* The PAL call uwb_rsv_destroy() for all accepted reservations before calling uwb_pal_unregister(). */ void uwb_rsv_accept(struct uwb_rsv *rsv, uwb_rsv_cb_f cb, void *pal_priv)
{ uwb_rsv_get(rsv); rsv->callback = cb; rsv->pal_priv = pal_priv; rsv->state = UWB_RSV_STATE_T_ACCEPTED; }
robutest/uclinux
C++
GPL-2.0
60
/* introduce function I3C_SlaveTransferHandleEventSent. This function was deal sent event. */
static void I3C_SlaveTransferHandleEventSent(I3C_Type *base, i3c_slave_handle_t *handle, i3c_slave_transfer_t *xfer)
/* introduce function I3C_SlaveTransferHandleEventSent. This function was deal sent event. */ static void I3C_SlaveTransferHandleEventSent(I3C_Type *base, i3c_slave_handle_t *handle, i3c_slave_transfer_t *xfer)
{ xfer->event = (uint32_t)kI3C_SlaveRequestSentEvent; if (handle->ibiData != NULL) { size_t count = 0U; while (count < handle->ibiDataSize) { base->SCTRL = (base->SCTRL & ~I3C_SCTRL_IBIDATA_MASK) | I3C_SCTRL_IBIDATA(handle->ibiData[count]) | I3C_...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* USB control transaction data out & status out stage. */
static void usb_ctl_out(usb_dev *udev)
/* USB control transaction data out & status out stage. */ static void usb_ctl_out(usb_dev *udev)
{ udev->drv_handler->ep_rx_enable(udev, 0U); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Xen sched_clock implementation. Returns the number of unstolen nanoseconds, which is nanoseconds the VCPU spent in RUNNING+BLOCKED states. */
unsigned long long xen_sched_clock(void)
/* Xen sched_clock implementation. Returns the number of unstolen nanoseconds, which is nanoseconds the VCPU spent in RUNNING+BLOCKED states. */ unsigned long long xen_sched_clock(void)
{ struct vcpu_runstate_info state; cycle_t now; u64 ret; s64 offset; preempt_disable(); now = xen_clocksource_read(); get_runstate_snapshot(&state); WARN_ON(state.state != RUNSTATE_running); offset = now - state.state_entry_time; if (offset < 0) offset = 0; ret = state.time[RUNSTATE_blocked] + state.time...
EmcraftSystems/linux-emcraft
C++
Other
266
/* RETURN VALUES: 0 - success -ENOMEM - insufficient free virtual memory. -EIO - i/o error. */
int diUnmount(struct inode *ipimap, int mounterror)
/* RETURN VALUES: 0 - success -ENOMEM - insufficient free virtual memory. -EIO - i/o error. */ int diUnmount(struct inode *ipimap, int mounterror)
{ struct inomap *imap = JFS_IP(ipimap)->i_imap; if (!(mounterror || isReadOnly(ipimap))) diSync(ipimap); truncate_inode_pages(ipimap->i_mapping, 0); kfree(imap); return (0); }
robutest/uclinux
C++
GPL-2.0
60
/* Read a natural value from memory. May or may not be aligned. */
UINTN VmReadMemN(IN VM_CONTEXT *VmPtr, IN UINTN Addr)
/* Read a natural value from memory. May or may not be aligned. */ UINTN VmReadMemN(IN VM_CONTEXT *VmPtr, IN UINTN Addr)
{ UINTN Data; volatile UINT32 Size; UINT8 *FromPtr; UINT8 *ToPtr; Addr = ConvertStackAddr (VmPtr, Addr); if (ADDRESS_IS_ALIGNED (Addr, sizeof (UINTN))) { return *(UINTN *)Addr; } Data = 0; FromPtr = (UINT8 *)Addr; ToPtr = (UINT8 *)&Data; for (Size = 0; Si...
tianocore/edk2
C++
Other
4,240
/* Note: In order to improve efficiency, register is operated directly */
static void ledc_set_left_duty_fast(uint32_t duty_val)
/* Note: In order to improve efficiency, register is operated directly */ static void ledc_set_left_duty_fast(uint32_t duty_val)
{ pwm_audio_handle_t handle = g_pwm_audio_handle; R_GPT_DutyCycleSet(handle->pwm_timer_ctrl, duty_val, GPT_IO_PIN_GTIOCA); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Register the key option to exit the waiting of the Boot Manager timeout. Platform should ensure that the continue key option isn't conflict with other boot key options. */
EFI_STATUS EFIAPI EfiBootManagerRegisterContinueKeyOption(IN UINT32 Modifier,...)
/* Register the key option to exit the waiting of the Boot Manager timeout. Platform should ensure that the continue key option isn't conflict with other boot key options. */ EFI_STATUS EFIAPI EfiBootManagerRegisterContinueKeyOption(IN UINT32 Modifier,...)
{ EFI_STATUS Status; EFI_BOOT_MANAGER_KEY_OPTION KeyOption; VA_LIST Args; if (mBmContinueKeyOption != NULL) { return EFI_ALREADY_STARTED; } ZeroMem (&KeyOption, sizeof (EFI_BOOT_MANAGER_KEY_OPTION)); VA_START (Args, Modifier); Status = BmInitializeKeyFields (M...
tianocore/edk2
C++
Other
4,240
/* This file is part of the TinyUSB stack. */
void button_init(void)
/* This file is part of the TinyUSB stack. */ void button_init(void)
{ ANSELBCLR = TU_BIT(12); TRISBSET = TU_BIT(12); CNPUBSET = TU_BIT(12); }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Get the platform dependent type of this sensor */
int SDL_SensorGetNonPortableType(SDL_Sensor *sensor)
/* Get the platform dependent type of this sensor */ int SDL_SensorGetNonPortableType(SDL_Sensor *sensor)
{ if (!SDL_PrivateSensorValid(sensor)) { return -1; } return sensor->non_portable_type; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Attribute write call back for the Value V4 attribute. */
static ssize_t write_value_v4(struct bt_conn *conn, const struct bt_gatt_attr *attr, const void *buf, uint16_t len, uint16_t offset, uint8_t flags)
/* Attribute write call back for the Value V4 attribute. */ static ssize_t write_value_v4(struct bt_conn *conn, const struct bt_gatt_attr *attr, const void *buf, uint16_t len, uint16_t offset, uint8_t flags)
{ uint8_t *value = attr->user_data; if (offset >= sizeof(value_v4_value)) return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); if (offset + len > sizeof(value_v4_value)) return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); memcpy(value + offset, buf, len); return len; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* __gc tag method for CLIBS table: calls 'lsys_unloadlib' for all lib handles in list CLIBS */
static int gctm(lua_State *L)
/* __gc tag method for CLIBS table: calls 'lsys_unloadlib' for all lib handles in list CLIBS */ static int gctm(lua_State *L)
{ lua_rawgeti(L, 1, n); lsys_unloadlib(lua_touserdata(L, -1)); lua_pop(L, 1); } return 0; }
Nicholas3388/LuaNode
C++
Other
1,055
/* NOTE. Kernel clients don't need to call this function if the channel mode is 'overwrite'. */
void relay_subbufs_consumed(struct rchan *chan, unsigned int cpu, size_t subbufs_consumed)
/* NOTE. Kernel clients don't need to call this function if the channel mode is 'overwrite'. */ void relay_subbufs_consumed(struct rchan *chan, unsigned int cpu, size_t subbufs_consumed)
{ struct rchan_buf *buf; if (!chan) return; if (cpu >= NR_CPUS || !chan->buf[cpu] || subbufs_consumed > chan->n_subbufs) return; buf = chan->buf[cpu]; if (subbufs_consumed > buf->subbufs_produced - buf->subbufs_consumed) buf->subbufs_consumed = buf->subbufs_produced; else buf->subbufs_consumed += sub...
EmcraftSystems/linux-emcraft
C++
Other
266
/* We do the basic set up of the interface structure. The SCC requires several custom handlers so we override the default ide DMA handlers appropriately. */
static void __devinit init_hwif_scc(ide_hwif_t *hwif)
/* We do the basic set up of the interface structure. The SCC requires several custom handlers so we override the default ide DMA handlers appropriately. */ static void __devinit init_hwif_scc(ide_hwif_t *hwif)
{ out_be32((void __iomem *)(hwif->dma_base + 0x018), hwif->dmatable_dma); if (in_be32((void __iomem *)(hwif->config_data + 0xff0)) & CCKCTRL_ATACLKOEN) hwif->ultra_mask = ATA_UDMA6; else hwif->ultra_mask = ATA_UDMA5; }
robutest/uclinux
C++
GPL-2.0
60
/* This function returns %0 on success and a negative error code on failure. */
void ubifs_end_scan(const struct ubifs_info *c, struct ubifs_scan_leb *sleb, int lnum, int offs)
/* This function returns %0 on success and a negative error code on failure. */ void ubifs_end_scan(const struct ubifs_info *c, struct ubifs_scan_leb *sleb, int lnum, int offs)
{ lnum = lnum; dbg_scan("stop scanning LEB %d at offset %d", lnum, offs); ubifs_assert(offs % c->min_io_size == 0); sleb->endpt = ALIGN(offs, c->min_io_size); }
EmcraftSystems/u-boot
C++
Other
181
/* SPI MSP Initialization This function configures the hardware resources used in this example. */
void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi)
/* SPI MSP Initialization This function configures the hardware resources used in this example. */ void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi)
{ GPIO_InitTypeDef GPIO_InitStruct = {0}; if(hspi->Instance==SPI5) { __HAL_RCC_SPI5_CLK_ENABLE(); __HAL_RCC_GPIOF_CLK_ENABLE(); GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_9|GPIO_PIN_8; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_S...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* eeprom_layout_print() - print the layout and the data which is assigned to it @layout: A pointer to an existing struct layout. */
static void eeprom_layout_print(const struct eeprom_layout *layout)
/* eeprom_layout_print() - print the layout and the data which is assigned to it @layout: A pointer to an existing struct layout. */ static void eeprom_layout_print(const struct eeprom_layout *layout)
{ int i; struct eeprom_field *fields = layout->fields; for (i = 0; i < layout->num_of_fields; i++) fields[i].print(&fields[i]); }
4ms/stm32mp1-baremetal
C++
Other
137
/* 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 OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT8 EFIAPI PciBitFieldOr8(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, 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 OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */ UINT8 EFIAPI PciBitFieldOr8(IN UINTN A...
{ return PciCf8BitFieldOr8 (Address, StartBit, EndBit, OrData); }
tianocore/edk2
C++
Other
4,240
/* inotify_init - allocate and initialize an inotify instance @ops: caller's inotify operations */
struct inotify_handle* inotify_init(const struct inotify_operations *ops)
/* inotify_init - allocate and initialize an inotify instance @ops: caller's inotify operations */ struct inotify_handle* inotify_init(const struct inotify_operations *ops)
{ struct inotify_handle *ih; ih = kmalloc(sizeof(struct inotify_handle), GFP_KERNEL); if (unlikely(!ih)) return ERR_PTR(-ENOMEM); idr_init(&ih->idr); INIT_LIST_HEAD(&ih->watches); mutex_init(&ih->mutex); ih->last_wd = 0; ih->in_ops = ops; atomic_set(&ih->count, 0); get_inotify_handle(ih); return ih; }
robutest/uclinux
C++
GPL-2.0
60
/* Blink the LEDs which are set to be on. */
s32 e1000e_blink_led(struct e1000_hw *hw)
/* Blink the LEDs which are set to be on. */ s32 e1000e_blink_led(struct e1000_hw *hw)
{ u32 ledctl_blink = 0; u32 i; if (hw->phy.media_type == e1000_media_type_fiber) { ledctl_blink = E1000_LEDCTL_LED0_BLINK | (E1000_LEDCTL_MODE_LED_ON << E1000_LEDCTL_LED0_MODE_SHIFT); } else { ledctl_blink = hw->mac.ledctl_mode2; for (i = 0; i < 4; i++) if (((hw->mac.ledctl_mode2 >> (i * 8)) & 0xFF)...
robutest/uclinux
C++
GPL-2.0
60
/* param config Pointer to configuration structure. See to "dcdc_loop_control_config_t" */
void DCDC_GetDefaultLoopControlConfig(dcdc_loop_control_config_t *config)
/* param config Pointer to configuration structure. See to "dcdc_loop_control_config_t" */ void DCDC_GetDefaultLoopControlConfig(dcdc_loop_control_config_t *config)
{ assert(NULL != config); memset(config, 0, sizeof(*config)); config->enableCommonHysteresis = false; config->enableCommonThresholdDetection = false; config->enableInvertHysteresisSign = false; config->enableRCThresholdDetection = false; config->enableRCScaleCircuit ...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* flush_iotlb_all - Clear all iommu tlb entries @obj: target iommu */
void flush_iotlb_all(struct iommu *obj)
/* flush_iotlb_all - Clear all iommu tlb entries @obj: target iommu */ void flush_iotlb_all(struct iommu *obj)
{ struct iotlb_lock l; clk_enable(obj->clk); l.base = 0; l.vict = 0; iotlb_lock_set(obj, &l); iommu_write_reg(obj, 1, MMU_GFLUSH); clk_disable(obj->clk); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* pack_pfns - pfns corresponding to the set bits found in the bitmap @bm are stored in the array @buf (1 page at a time) */
static void pack_pfns(unsigned long *buf, struct memory_bitmap *bm)
/* pack_pfns - pfns corresponding to the set bits found in the bitmap @bm are stored in the array @buf (1 page at a time) */ static void pack_pfns(unsigned long *buf, struct memory_bitmap *bm)
{ int j; for (j = 0; j < PAGE_SIZE / sizeof(long); j++) { buf[j] = memory_bm_next_pfn(bm); if (unlikely(buf[j] == BM_END_OF_MAP)) break; } }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Enables or disables the ADC DMA request after last transfer (Single-ADC mode) */
void ADC_DMARequestModeConfig(ADC_TypeDef *ADCx, uint32_t ADC_DMARequestMode)
/* Enables or disables the ADC DMA request after last transfer (Single-ADC mode) */ void ADC_DMARequestModeConfig(ADC_TypeDef *ADCx, uint32_t ADC_DMARequestMode)
{ assert_param(IS_ADC_ALL_PERIPH(ADCx)); ADCx->CFGR1 &= (uint32_t)~ADC_CFGR1_DMACFG; ADCx->CFGR1 |= (uint32_t)ADC_DMARequestMode; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Writes 8-bits of CMOS data to the location specified by Index with the value specified by Value and returns Value. */
UINT8 EFIAPI PlatformCmosWrite8(IN UINTN Index, IN UINT8 Value)
/* Writes 8-bits of CMOS data to the location specified by Index with the value specified by Value and returns Value. */ UINT8 EFIAPI PlatformCmosWrite8(IN UINTN Index, IN UINT8 Value)
{ IoWrite8 (0x70, (UINT8)Index); IoWrite8 (0x71, Value); return Value; }
tianocore/edk2
C++
Other
4,240
/* Set the clock rate of the specified I2C port. The */
void I2CMasterInit(unsigned long ulBase, unsigned long ulI2CClk)
/* Set the clock rate of the specified I2C port. The */ void I2CMasterInit(unsigned long ulBase, unsigned long ulI2CClk)
{ unsigned long ulBusClk; xASSERT((ulBase == I2C0_BASE) || ((ulBase == I2C1_BASE))); xHWREGB(ulBase + I2C_CON1) |= I2C_CON1_EN; ulBusClk = SysCtlBusClkGet(); xHWREGB(ulBase + I2C_FREQ) = 0x80; xHWREGB(ulBase + I2C_CON1) |= I2C_CON1_TX; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Unlike newer cards, the MC16/32 have their speed selection circuit connected to the Madge ASICs and not to the TMS380 NSELOUT pins. Set the ASIC bits correctly here, and return zero to leave the TMS NSELOUT bits unaffected. */
static unsigned short madgemc_setnselout_pins(struct net_device *dev)
/* Unlike newer cards, the MC16/32 have their speed selection circuit connected to the Madge ASICs and not to the TMS380 NSELOUT pins. Set the ASIC bits correctly here, and return zero to leave the TMS NSELOUT bits unaffected. */ static unsigned short madgemc_setnselout_pins(struct net_device *dev)
{ unsigned char reg1; struct net_local *tp = netdev_priv(dev); reg1 = inb(dev->base_addr + MC_CONTROL_REG1); if(tp->DataRate == SPEED_16) reg1 |= MC_CONTROL_REG1_SPEED_SEL; else if (reg1 & MC_CONTROL_REG1_SPEED_SEL) reg1 ^= MC_CONTROL_REG1_SPEED_SEL; outb(reg1, dev->base_addr + MC_CONTROL_REG1); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Description: This function is designed to be used as a callback to the call_rcu() function so that memory allocated to a hash table interface entry can be released safely. */
static void sel_netif_free(struct rcu_head *p)
/* Description: This function is designed to be used as a callback to the call_rcu() function so that memory allocated to a hash table interface entry can be released safely. */ static void sel_netif_free(struct rcu_head *p)
{ struct sel_netif *netif = container_of(p, struct sel_netif, rcu_head); kfree(netif); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Failure to call this function after a reset may lead to incorrect operation or permanent data loss if the EEPROM is later written. */
uint32_t EEPROMInit(void)
/* Failure to call this function after a reset may lead to incorrect operation or permanent data loss if the EEPROM is later written. */ uint32_t EEPROMInit(void)
{ uint32_t ui32Status; SysCtlDelay(2); _EEPROMWaitForDone(); ui32Status = HWREG(EEPROM_EESUPP); if (ui32Status & (EEPROM_EESUPP_PRETRY | EEPROM_EESUPP_ERETRY)) { return (EEPROM_INIT_ERROR); } SysCtlPeripheralReset(SYSCTL_PERIPH_EEPROM0); SysCtlDelay(2); _EEPROMWaitForDone...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Start the Mtftp6 instance to upload. It will first init some states, then send the WRQ request packet, and start to receive the packet. */
EFI_STATUS Mtftp6WrqStart(IN MTFTP6_INSTANCE *Instance, IN UINT16 Operation)
/* Start the Mtftp6 instance to upload. It will first init some states, then send the WRQ request packet, and start to receive the packet. */ EFI_STATUS Mtftp6WrqStart(IN MTFTP6_INSTANCE *Instance, IN UINT16 Operation)
{ EFI_STATUS Status; Status = Mtftp6InitBlockRange (&Instance->BlkList, 0, 0xffff); if (EFI_ERROR (Status)) { return Status; } Status = Mtftp6SendRequest (Instance, Operation); if (EFI_ERROR (Status)) { return Status; } return UdpIoRecvDatagram ( Instance->UdpIo, Mtftp6Wrq...
tianocore/edk2
C++
Other
4,240
/* This function is similar as strlen_s defined in C11. */
UINTN EFIAPI AsciiStrnLenS(IN CONST CHAR8 *String, IN UINTN MaxSize)
/* This function is similar as strlen_s defined in C11. */ UINTN EFIAPI AsciiStrnLenS(IN CONST CHAR8 *String, IN UINTN MaxSize)
{ UINTN Length; if ((String == NULL) || (MaxSize == 0)) { return 0; } Length = 0; while (String[Length] != 0) { if (Length >= MaxSize - 1) { return MaxSize; } Length++; } return Length; }
tianocore/edk2
C++
Other
4,240
/* 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)
{ return InternalAllocateCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer); }
tianocore/edk2
C++
Other
4,240
/* Corroutine type funtion, is call while Message_t->length is not EOF. */
Message_t hello_world(void *arg)
/* Corroutine type funtion, is call while Message_t->length is not EOF. */ Message_t hello_world(void *arg)
{ return (Message_t) { NULL, NULL, NULL, EOF }; } Response_t *res = (Response_t *)arg; if (res->done) { free(res); return (Message_t) { NULL, NULL, NULL, EOF }; } res->done = 1; return (Message_t) { res->response, res->header, (const uint8_t *)res->payload, strlen...
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* This will start the SysTick counter. If an interrupt handler has been registered, it will be called when the SysTick counter rolls over. */
void xSysTickEnable(void)
/* This will start the SysTick counter. If an interrupt handler has been registered, it will be called when the SysTick counter rolls over. */ void xSysTickEnable(void)
{ xHWREG(NVIC_ST_CTRL) |= NVIC_ST_CTRL_ENABLE; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Enables IWDG (write access to IWDG_PR and IWDG_RLR registers disabled). */
void IWDG_Enable(void)
/* Enables IWDG (write access to IWDG_PR and IWDG_RLR registers disabled). */ void IWDG_Enable(void)
{ IWDG->KEY = KEY_EnableKey; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Executes an SMBUS read data word command on the SMBUS device specified by SmBusAddress. Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. The 16-bit value read from the SMBUS is returned. If Status is not NULL, then the status of the executed command is returned in Status. If Length...
UINT16 EFIAPI S3SmBusReadDataWord(IN UINTN SmBusAddress, OUT RETURN_STATUS *Status OPTIONAL)
/* Executes an SMBUS read data word command on the SMBUS device specified by SmBusAddress. Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. The 16-bit value read from the SMBUS is returned. If Status is not NULL, then the status of the executed command is returned in Status. If Length...
{ UINT16 Word; Word = SmBusReadDataWord (SmBusAddress, Status); InternalSaveSmBusExecToBootScript (EfiSmbusReadWord, SmBusAddress, 2, &Word); return Word; }
tianocore/edk2
C++
Other
4,240
/* Disable Output in Break. Disables the output in the Break feature of an advanced timer. This clears the Master Output Enable in the Break and Deadtime Register. */
void timer_disable_break_main_output(uint32_t timer_peripheral)
/* Disable Output in Break. Disables the output in the Break feature of an advanced timer. This clears the Master Output Enable in the Break and Deadtime Register. */ void timer_disable_break_main_output(uint32_t timer_peripheral)
{ TIM_BDTR(timer_peripheral) &= ~TIM_BDTR_MOE; }
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* Set the fields of structure stc_eth_mac_addr_config_t to default values. */
int32_t ETH_MACADDR_StructInit(stc_eth_mac_addr_config_t *pstcMacAddrInit)
/* Set the fields of structure stc_eth_mac_addr_config_t to default values. */ int32_t ETH_MACADDR_StructInit(stc_eth_mac_addr_config_t *pstcMacAddrInit)
{ int32_t i32Ret = LL_OK; uint8_t i; if (NULL == pstcMacAddrInit) { i32Ret = LL_ERR_INVD_PARAM; } else { pstcMacAddrInit->u32MacAddrFilter = ETH_MAC_ADDR_FILTER_DISABLE; pstcMacAddrInit->u32MacAddrMask = ETH_MAC_ADDR_MASK_DISABLE; for (i = 0U; i < ETH_MAC_ADDR_BYTE_LEN;...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Finalizes a handled event TRB by advancing our dequeue pointer and giving the TRB back to the hardware for recycling. Must call this exactly once at the end of each event handler, and not touch the TRB again afterwards. */
void xhci_acknowledge_event(struct xhci_ctrl *ctrl)
/* Finalizes a handled event TRB by advancing our dequeue pointer and giving the TRB back to the hardware for recycling. Must call this exactly once at the end of each event handler, and not touch the TRB again afterwards. */ void xhci_acknowledge_event(struct xhci_ctrl *ctrl)
{ inc_deq(ctrl, ctrl->event_ring); xhci_writeq(&ctrl->ir_set->erst_dequeue, (uintptr_t)ctrl->event_ring->dequeue | ERST_EHB); }
4ms/stm32mp1-baremetal
C++
Other
137
/* <0 - low prio interrupt, 0 - no interrupt, >0 - interrupt number */
static int apic_irq_pending(APICCommonState *s)
/* <0 - low prio interrupt, 0 - no interrupt, >0 - interrupt number */ static int apic_irq_pending(APICCommonState *s)
{ int irrv, ppr; irrv = get_highest_priority_int(s->irr); if (irrv < 0) { return 0; } ppr = apic_get_ppr(s); if (ppr && (irrv & 0xf0) <= (ppr & 0xf0)) { return -1; } return irrv; }
ve3wwg/teensy3_qemu
C++
Other
15
/* During commit it is sometimes necessary to copy a pnode (see dirty_cow_pnode) and the lprops that the pnode contains. When that happens, references in category lists and heaps must be replaced. This function does that. */
void ubifs_replace_cat(struct ubifs_info *c, struct ubifs_lprops *old_lprops, struct ubifs_lprops *new_lprops)
/* During commit it is sometimes necessary to copy a pnode (see dirty_cow_pnode) and the lprops that the pnode contains. When that happens, references in category lists and heaps must be replaced. This function does that. */ void ubifs_replace_cat(struct ubifs_info *c, struct ubifs_lprops *old_lprops, struct ubifs_lpr...
{ int cat; cat = new_lprops->flags & LPROPS_CAT_MASK; switch (cat) { case LPROPS_DIRTY: case LPROPS_DIRTY_IDX: case LPROPS_FREE: lpt_heap_replace(c, old_lprops, new_lprops, cat); break; case LPROPS_UNCAT: case LPROPS_EMPTY: case LPROPS_FREEABLE: case LPROPS_FRDI_IDX: list_replace(&old_lprops->list, &new...
EmcraftSystems/u-boot
C++
Other
181
/* Stop timer and free the resources allocated by */
int32_t timer_counter_remove(struct timer_counter_desc *dev)
/* Stop timer and free the resources allocated by */ int32_t timer_counter_remove(struct timer_counter_desc *dev)
{ int32_t ret; if(!dev) return -1; ret = timer_counter_activate(dev, false); if(ret != SUCCESS) return ret; free(dev); return ret; }
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* Unsigned 64bit divide with 32bit divisor with remainder */
uint64_t div_u64_rem(uint64_t dividend, uint32_t divisor, uint32_t *remainder)
/* Unsigned 64bit divide with 32bit divisor with remainder */ uint64_t div_u64_rem(uint64_t dividend, uint32_t divisor, uint32_t *remainder)
{ *remainder = do_div(&dividend, divisor); return dividend; }
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* Loads saved non-volatile parameter values from the EEPROM into the parameter table, as needed. */
void V2Params_LoadNonVolatileParamValues(void)
/* Loads saved non-volatile parameter values from the EEPROM into the parameter table, as needed. */ void V2Params_LoadNonVolatileParamValues(void)
{ uint8_t ResetPolarity = eeprom_read_byte(&EEPROM_Reset_Polarity); uint8_t SCKDuration = eeprom_read_byte(&EEPROM_SCK_Duration); if (ResetPolarity != 0xFF) V2Params_GetParamFromTable(PARAM_RESET_POLARITY)->ParamValue = ResetPolarity; if (SCKDuration != 0xFF) V2Params_GetParamFromTable(PARAM_SCK_DURATION)->...
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* By protocol definition, bit data defaults to a 1. Thus if a slave did not signal any 0-bit data, this read returns 0xffffffff. */
bool OneWireDataGetNonBlocking(uint32_t ui32Base, uint32_t *pui32Data)
/* By protocol definition, bit data defaults to a 1. Thus if a slave did not signal any 0-bit data, this read returns 0xffffffff. */ bool OneWireDataGetNonBlocking(uint32_t ui32Base, uint32_t *pui32Data)
{ ASSERT(ui32Base == ONEWIRE0_BASE); ASSERT(pui32Data); if (HWREG(ui32Base + ONEWIRE_O_CS) & ONEWIRE_CS_BUSY) { return (false); } *pui32Data = HWREG(ui32Base + ONEWIRE_O_DATR); return (true); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Program the Option Bytes. This performs all operations necessary to program the option bytes. The option bytes do not need to be erased first. */
void flash_program_option_bytes(uint32_t data)
/* Program the Option Bytes. This performs all operations necessary to program the option bytes. The option bytes do not need to be erased first. */ void flash_program_option_bytes(uint32_t data)
{ flash_wait_for_last_operation(); if (FLASH_OPTCR & FLASH_OPTCR_OPTLOCK) { flash_unlock_option_bytes(); } FLASH_OPTCR = data & ~0x3; FLASH_OPTCR |= FLASH_OPTCR_OPTSTRT; flash_wait_for_last_operation(); } /**@}
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* This function gets controller name from Component Name 2 protocol interface and Component Name protocol interface in turn. It first tries UEFI 2.0 Component Name 2 protocol interface and try to get the controller name. If the attempt fails, it then gets the controller name from EFI 1.1 Component Name protocol for ba...
EFI_STATUS DriverHealthManagerGetControllerNameWorker(IN EFI_GUID *ProtocolGuid, IN EFI_HANDLE DriverBindingHandle, IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE ChildHandle, OUT CHAR16 **ControllerName)
/* This function gets controller name from Component Name 2 protocol interface and Component Name protocol interface in turn. It first tries UEFI 2.0 Component Name 2 protocol interface and try to get the controller name. If the attempt fails, it then gets the controller name from EFI 1.1 Component Name protocol for ba...
{ EFI_STATUS Status; CHAR8 *BestLanguage; EFI_COMPONENT_NAME_PROTOCOL *ComponentName; Status = DriverHealthManagerGetComponentNameWorker ( ProtocolGuid, DriverBindingHandle, &ComponentName, &BestLanguage )...
tianocore/edk2
C++
Other
4,240
/* GFileInputStream implements #GSeekable, which allows the input stream to jump to arbitrary positions in the file, provided the filesystem of the file allows it. To find the position of a file input stream, use g_seekable_tell(). To find out if a file input stream supports seeking, use g_seekable_can_seek(). To posit...
static void g_file_input_stream_seekable_iface_init(GSeekableIface *iface)
/* GFileInputStream implements #GSeekable, which allows the input stream to jump to arbitrary positions in the file, provided the filesystem of the file allows it. To find the position of a file input stream, use g_seekable_tell(). To find out if a file input stream supports seeking, use g_seekable_can_seek(). To posit...
{ iface->tell = g_file_input_stream_seekable_tell; iface->can_seek = g_file_input_stream_seekable_can_seek; iface->seek = g_file_input_stream_seekable_seek; iface->can_truncate = g_file_input_stream_seekable_can_truncate; iface->truncate_fn = g_file_input_stream_seekable_truncate; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* We cache the source and target instance ids for each partition. */
HvLpInstanceId viopath_sourceinst(HvLpIndex lp)
/* We cache the source and target instance ids for each partition. */ HvLpInstanceId viopath_sourceinst(HvLpIndex lp)
{ return viopathStatus[lp].mSourceInst; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Create performance record with event description and a timestamp. */
EFI_STATUS EFIAPI CreatePerformanceMeasurement(IN CONST VOID *CallerIdentifier, IN CONST VOID *Guid OPTIONAL, IN CONST CHAR8 *String OPTIONAL, IN UINT64 TimeStamp, IN UINT64 Address OPTIONAL, IN UINT32 Identifier, IN PERF_MEASUREMENT_ATTRIBUTE Attribute)
/* Create performance record with event description and a timestamp. */ EFI_STATUS EFIAPI CreatePerformanceMeasurement(IN CONST VOID *CallerIdentifier, IN CONST VOID *Guid OPTIONAL, IN CONST CHAR8 *String OPTIONAL, IN UINT64 TimeStamp, IN UINT64 Address OPTIONAL, IN UINT32 Identifier, IN PERF_MEASUREMENT_ATTRIBUTE Attr...
{ EFI_STATUS Status; Status = EFI_SUCCESS; if (mLockInsertRecord) { return EFI_INVALID_PARAMETER; } mLockInsertRecord = TRUE; Status = InsertFpdtRecord (CallerIdentifier, Guid, String, TimeStamp, Address, (UINT16)Identifier, Attribute); mLockInsertRecord = FALSE; return Status; }
tianocore/edk2
C++
Other
4,240
/* wait_for_space - check ring buffer free space @space: amount of ringbuffer space needed in bytes */
static int wait_for_space(struct fb_info *info, u32 space)
/* wait_for_space - check ring buffer free space @space: amount of ringbuffer space needed in bytes */ static int wait_for_space(struct fb_info *info, u32 space)
{ struct i810fb_par *par = info->par; u32 head, count = WAIT_COUNT, tail; u8 __iomem *mmio = par->mmio_start_virtual; tail = par->cur_tail; while (count--) { head = i810_readl(IRING + 4, mmio) & RBUFFER_HEAD_MASK; if ((tail == head) || (tail > head && (par->iring.size - tail + head) >= space) || ...
robutest/uclinux
C++
GPL-2.0
60
/* Assert that two CAN frames are equal given a CAN ID mask. */
void assert_frame_equal(const struct can_frame *frame1, const struct can_frame *frame2, uint32_t id_mask)
/* Assert that two CAN frames are equal given a CAN ID mask. */ void assert_frame_equal(const struct can_frame *frame1, const struct can_frame *frame2, uint32_t id_mask)
{ zassert_equal(frame1->flags, frame2->flags, "Flags do not match"); zassert_equal(frame1->id | id_mask, frame2->id | id_mask, "ID does not match"); zassert_equal(frame1->dlc, frame2->dlc, "DLC does not match"); if ((frame1->flags & CAN_FRAME_RTR) == 0U) { zassert_mem_equal(frame1->data, frame2->data, can_dlc_to_...
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Various dodgy firmware might give us nodes and/or properties with conflicting names. That's generally ok, except for exporting via /proc, so munge names here to ensure they're unique. */
static int duplicate_name(struct proc_dir_entry *de, const char *name)
/* Various dodgy firmware might give us nodes and/or properties with conflicting names. That's generally ok, except for exporting via /proc, so munge names here to ensure they're unique. */ static int duplicate_name(struct proc_dir_entry *de, const char *name)
{ struct proc_dir_entry *ent; int found = 0; spin_lock(&proc_subdir_lock); for (ent = de->subdir; ent != NULL; ent = ent->next) { if (strcmp(ent->name, name) == 0) { found = 1; break; } } spin_unlock(&proc_subdir_lock); return found; }
robutest/uclinux
C++
GPL-2.0
60
/* Configures User push-button in GPIO or EXTI Line Mode. */
void UserButton_Init(void)
/* Configures User push-button in GPIO or EXTI Line Mode. */ void UserButton_Init(void)
{ USER_BUTTON_GPIO_CLK_ENABLE(); LL_GPIO_SetPinMode(USER_BUTTON_GPIO_PORT, USER_BUTTON_PIN, LL_GPIO_MODE_INPUT); LL_GPIO_SetPinPull(USER_BUTTON_GPIO_PORT, USER_BUTTON_PIN, LL_GPIO_PULL_NO); USER_BUTTON_SYSCFG_SET_EXTI(); USER_BUTTON_EXTI_LINE_ENABLE(); USER_BUTTON_EXTI_FALLING_TRIG_ENABLE(); NVIC_EnableIR...
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Performs an atomic compare exchange operation on the 64-bit unsigned integer specified by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue, then Value is returned. The compare exchange operation must be performed using MP...
UINT64 EFIAPI InternalSyncCompareExchange64(IN volatile UINT64 *Value, IN UINT64 CompareValue, IN UINT64 ExchangeValue)
/* Performs an atomic compare exchange operation on the 64-bit unsigned integer specified by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue, then Value is returned. The compare exchange operation must be performed using MP...
{ return *Value != CompareValue ? *Value : ((*Value = ExchangeValue), CompareValue); }
tianocore/edk2
C++
Other
4,240
/* Reset the adapter. Older PCIe cards lose their config space during reset, PCI-X ones don't. */
int t3_reset_adapter(struct adapter *adapter)
/* Reset the adapter. Older PCIe cards lose their config space during reset, PCI-X ones don't. */ int t3_reset_adapter(struct adapter *adapter)
{ int i, save_and_restore_pcie = adapter->params.rev < T3_REV_B2 && is_pcie(adapter); uint16_t devid = 0; if (save_and_restore_pcie) pci_save_state(adapter->pdev); t3_write_reg(adapter, A_PL_RST, F_CRSTWRM | F_CRSTWRMMODE); for (i = 0; i < 10; i++) { msleep(50); pci_read_config_word(adapter->pdev, 0x00,...
robutest/uclinux
C++
GPL-2.0
60
/* 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 *)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++ = (tmp >> 8...
pikasTech/PikaPython
C++
MIT License
1,403
/* If you want to use msi see pci_enable_msi and friends. This is a lower level primitive that allows us to disable msi operation at the device level. */
void pci_msi_off(struct pci_dev *dev)
/* If you want to use msi see pci_enable_msi and friends. This is a lower level primitive that allows us to disable msi operation at the device level. */ void pci_msi_off(struct pci_dev *dev)
{ int pos; u16 control; pos = pci_find_capability(dev, PCI_CAP_ID_MSI); if (pos) { pci_read_config_word(dev, pos + PCI_MSI_FLAGS, &control); control &= ~PCI_MSI_FLAGS_ENABLE; pci_write_config_word(dev, pos + PCI_MSI_FLAGS, control); } pos = pci_find_capability(dev, PCI_CAP_ID_MSIX); if (pos) { pci_read_c...
robutest/uclinux
C++
GPL-2.0
60
/* Change Logs: Date Author Notes Sherman the first version */
int rt_link_utils_num1(rt_uint32_t n)
/* Change Logs: Date Author Notes Sherman the first version */ int rt_link_utils_num1(rt_uint32_t n)
{ int ret = 0; while (n) { n &= n - 1; ret++; } return ret; }
pikasTech/PikaPython
C++
MIT License
1,403
/* This function is derived from PowerPC code (timebase clock frequency). On ARM it returns the number of timer ticks per second. */
unsigned long get_tbclk(void)
/* This function is derived from PowerPC code (timebase clock frequency). On ARM it returns the number of timer ticks per second. */ unsigned long get_tbclk(void)
{ unsigned long freq; asm volatile("mrc p15, 0, %0, c14, c0, 0" : "=r" (freq)); return freq; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Configure Timer Counter 0 to generate an interrupt every second. */
static void configure_tc(void)
/* Configure Timer Counter 0 to generate an interrupt every second. */ static void configure_tc(void)
{ uint32_t ul_div; uint32_t ul_tcclks; uint32_t ul_sysclk; ul_sysclk = sysclk_get_cpu_hz(); pmc_enable_periph_clk(ID_TC0); tc_find_mck_divisor(TC_FREQ, ul_sysclk, &ul_div, &ul_tcclks, ul_sysclk); tc_init(TC0, 0, ul_tcclks | TC_CMR_CPCTRG); tc_write_rc(TC0, 0, (ul_sysclk / ul_div) / TC_FREQ); NVIC_EnableIRQ((IR...
remotemcu/remcu-chip-sdks
C++
null
436
/* Read TC Register A (RA) on the specified channel. */
uint32_t tc_read_ra(Tc *p_tc, uint32_t ul_channel)
/* Read TC Register A (RA) on the specified channel. */ uint32_t tc_read_ra(Tc *p_tc, uint32_t ul_channel)
{ Assert(p_tc); Assert(ul_channel < (sizeof(p_tc->TC_CHANNEL) / sizeof(p_tc->TC_CHANNEL[0]))); return p_tc->TC_CHANNEL[ul_channel].TC_RA; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Backup function for HBufferImage. Only a few fields need to be backup. This is for making the file buffer refresh as few as possible. */
EFI_STATUS HBufferImageBackup(VOID)
/* Backup function for HBufferImage. Only a few fields need to be backup. This is for making the file buffer refresh as few as possible. */ EFI_STATUS HBufferImageBackup(VOID)
{ HBufferImageBackupVar.MousePosition = HBufferImage.MousePosition; HBufferImageBackupVar.BufferPosition = HBufferImage.BufferPosition; HBufferImageBackupVar.Modified = HBufferImage.Modified; HBufferImageBackupVar.BufferType = HBufferImage.BufferType; HBufferImageBackupVar.LowVisibleRow = HBufferImage.LowV...
tianocore/edk2
C++
Other
4,240
/* Airpcap wrapper, used to get the fcs validation of an airpcap adapter */
gboolean airpcap_if_get_fcs_validation(PAirpcapHandle ah, PAirpcapValidationType val)
/* Airpcap wrapper, used to get the fcs validation of an airpcap adapter */ gboolean airpcap_if_get_fcs_validation(PAirpcapHandle ah, PAirpcapValidationType val)
{ if (!AirpcapLoaded) return FALSE; return g_PAirpcapGetFcsValidation(ah,val); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This is called after U-Boot has been copied from Flash/ROM to RAM. It gives us an opportunity to do some additional setup before the rest of the system is initialised. We don't need to do anything, so we just call board_init_r() which should never return. */
void after_reloc(ulong dest_addr, gd_t *gd)
/* This is called after U-Boot has been copied from Flash/ROM to RAM. It gives us an opportunity to do some additional setup before the rest of the system is initialised. We don't need to do anything, so we just call board_init_r() which should never return. */ void after_reloc(ulong dest_addr, gd_t *gd)
{ board_init_r( gd, dest_addr ); }
EmcraftSystems/u-boot
C++
Other
181
/* Generate a stop condition on I2C bus. The */
void I2CStopSend(unsigned long ulBase)
/* Generate a stop condition on I2C bus. The */ void I2CStopSend(unsigned long ulBase)
{ xASSERT((ulBase == I2C2_BASE) || (ulBase == I2C1_BASE)); xHWREG(ulBase + I2C_CR1) |= I2C_CR1_STOP; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* This function returns TRUE if the POST_CODE_PROPERTY_POST_CODE_ENABLED bit of PcdPostCodePropertyMask is set. Otherwise FALSE is returned. */
BOOLEAN EFIAPI PostCodeEnabled(VOID)
/* This function returns TRUE if the POST_CODE_PROPERTY_POST_CODE_ENABLED bit of PcdPostCodePropertyMask is set. Otherwise FALSE is returned. */ BOOLEAN EFIAPI PostCodeEnabled(VOID)
{ return (BOOLEAN)((PcdGet8 (PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0); }
tianocore/edk2
C++
Other
4,240
/* ipath_mcast_qp_alloc - alloc a struct to link a QP to mcast GID struct @qp: the QP to link */
static struct ipath_mcast_qp* ipath_mcast_qp_alloc(struct ipath_qp *qp)
/* ipath_mcast_qp_alloc - alloc a struct to link a QP to mcast GID struct @qp: the QP to link */ static struct ipath_mcast_qp* ipath_mcast_qp_alloc(struct ipath_qp *qp)
{ struct ipath_mcast_qp *mqp; mqp = kmalloc(sizeof *mqp, GFP_KERNEL); if (!mqp) goto bail; mqp->qp = qp; atomic_inc(&qp->refcount); bail: return mqp; }
robutest/uclinux
C++
GPL-2.0
60
/* If the enable or disable AP operation cannot be completed prior to the return from this service, then EFI_UNSUPPORTED must be returned. */
EFI_STATUS EFIAPI EdkiiPeiEnableDisableAP(IN EDKII_PEI_MP_SERVICES2_PPI *This, IN UINTN ProcessorNumber, IN BOOLEAN EnableAP, IN UINT32 *HealthFlag OPTIONAL)
/* If the enable or disable AP operation cannot be completed prior to the return from this service, then EFI_UNSUPPORTED must be returned. */ EFI_STATUS EFIAPI EdkiiPeiEnableDisableAP(IN EDKII_PEI_MP_SERVICES2_PPI *This, IN UINTN ProcessorNumber, IN BOOLEAN EnableAP, IN UINT32 *HealthFlag OPTIONAL)
{ return MpInitLibEnableDisableAP (ProcessorNumber, EnableAP, HealthFlag); }
tianocore/edk2
C++
Other
4,240
/* Configures the specified DMA Peripheral increment offset size. */
void DMA_ConfigPeriphIncOffsetSize(DMA_Stream_T *stream, DMA_PERIOSIZE_T perioSize)
/* Configures the specified DMA Peripheral increment offset size. */ void DMA_ConfigPeriphIncOffsetSize(DMA_Stream_T *stream, DMA_PERIOSIZE_T perioSize)
{ stream->SCFG_B.PERIOSIZE = perioSize; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* For backward compatibility? Maybe this should be moved into arch/i386 instead? */
SYSCALL_DEFINE2(creat, const char __user *, pathname, int, mode)
/* For backward compatibility? Maybe this should be moved into arch/i386 instead? */ SYSCALL_DEFINE2(creat, const char __user *, pathname, int, mode)
{ return sys_open(pathname, O_CREAT | O_WRONLY | O_TRUNC, mode); }
robutest/uclinux
C++
GPL-2.0
60
/* This API sets the I2C interface configuration(if) mode for auxiliary Mag. */
uint16_t bma4_set_aux_if_mode(uint8_t if_mode, struct bma4_dev *dev)
/* This API sets the I2C interface configuration(if) mode for auxiliary Mag. */ uint16_t bma4_set_aux_if_mode(uint8_t if_mode, struct bma4_dev *dev)
{ uint16_t rslt = 0; uint8_t data = 0; if (dev == NULL) { rslt |= BMA4_E_NULL_PTR; } else { rslt |= bma4_read_regs(BMA4_IF_CONFIG_ADDR, &data, 1, dev); if (rslt == BMA4_OK) { data = BMA4_SET_BITSLICE(data, BMA4_IF_CONFIG_IF_MODE, if_mode); rslt |= bma4_wri...
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* we need to lock this section since fb_cursor may use fb_imageblit() */
char* fb_get_buffer_offset(struct fb_info *info, struct fb_pixmap *buf, u32 size)
/* we need to lock this section since fb_cursor may use fb_imageblit() */ char* fb_get_buffer_offset(struct fb_info *info, struct fb_pixmap *buf, u32 size)
{ u32 align = buf->buf_align - 1, offset; char *addr = buf->addr; if (buf->flags & FB_PIXMAP_IO) { if (info->fbops->fb_sync && (buf->flags & FB_PIXMAP_SYNC)) info->fbops->fb_sync(info); return addr; } offset = buf->offset + align; offset &= ~align; if (offset + size > buf->size) { if (info->fbops->fb_sy...
robutest/uclinux
C++
GPL-2.0
60
/* param base Pointer to FLEXIO_I2S_Type structure. param handle Pointer to flexio_i2s_handle_t structure which stores the transfer state */
void FLEXIO_I2S_TransferAbortReceive(FLEXIO_I2S_Type *base, flexio_i2s_handle_t *handle)
/* param base Pointer to FLEXIO_I2S_Type structure. param handle Pointer to flexio_i2s_handle_t structure which stores the transfer state */ void FLEXIO_I2S_TransferAbortReceive(FLEXIO_I2S_Type *base, flexio_i2s_handle_t *handle)
{ assert(handle); FLEXIO_I2S_DisableInterrupts(base, kFLEXIO_I2S_RxDataRegFullInterruptEnable); handle->state = kFLEXIO_I2S_Idle; memset(handle->queue, 0, sizeof(flexio_i2s_transfer_t) * FLEXIO_I2S_XFER_QUEUE_SIZE); handle->queueDriver = 0; handle->queueUser = 0; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Function for setting the next background page number. */
__STATIC_INLINE void next_bkgd_page_number_set(ant_bsc_profile_t *p_profile)
/* Function for setting the next background page number. */ __STATIC_INLINE void next_bkgd_page_number_set(ant_bsc_profile_t *p_profile)
{ ant_bsc_page_t last_bkgd_page = p_profile->_cb.p_sens_cb->page_4_present ? ANT_BSC_PAGE_4 : ANT_BSC_PAGE_3; ++(p_profile->_cb.p_sens_cb->bkgd_page_number); if (p_profile->_cb.p_sens_cb->bkgd_page_number > last_bkgd_page) { p_profile->_cb.p_sens_cb->bkgd_page_number = ...
labapart/polymcu
C++
null
201
/* Waits until the device finishes the power-on reset operation. */
int32_t ad7124_wait_to_power_on(struct ad7124_dev *dev, uint32_t timeout)
/* Waits until the device finishes the power-on reset operation. */ int32_t ad7124_wait_to_power_on(struct ad7124_dev *dev, uint32_t timeout)
{ struct ad7124_st_reg *regs; int32_t ret; int8_t powered_on = 0; if(!dev) return INVALID_VAL; regs = dev->regs; while(!powered_on && timeout--) { ret = ad7124_read_register(dev, &regs[AD7124_Status]); if(ret < 0) return ret; powered_on = (regs[AD7124_Status].value & AD7124_STATUS_REG_...
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* host send ctrl request to set control line state */
HOST_STATUS usb_host_cdc_setcontrollinestate(usb_core_instance *pdev, USBH_HOST *phost)
/* host send ctrl request to set control line state */ HOST_STATUS usb_host_cdc_setcontrollinestate(usb_core_instance *pdev, USBH_HOST *phost)
{ phost->ctrlparam.setup.b.bmRequestType = USB_H2D | USB_REQ_TYPE_CLASS | \ USB_REQ_RECIPIENT_INTERFACE; phost->ctrlparam.setup.b.bRequest = CDC_SET_CONTROL_LINE_STATE; phost->ctrlparam.setup.b.wValue.w = CDC_DEACTIVATE_CARRIER_SIGNAL_RTS | \ ...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* RETURNS: Zero on success, error code on failure. */
int drm_framebuffer_init(struct drm_device *dev, struct drm_framebuffer *fb, const struct drm_framebuffer_funcs *funcs)
/* RETURNS: Zero on success, error code on failure. */ int drm_framebuffer_init(struct drm_device *dev, struct drm_framebuffer *fb, const struct drm_framebuffer_funcs *funcs)
{ int ret; ret = drm_mode_object_get(dev, &fb->base, DRM_MODE_OBJECT_FB); if (ret) { return ret; } fb->dev = dev; fb->funcs = funcs; dev->mode_config.num_fb++; list_add(&fb->head, &dev->mode_config.fb_list); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* If String is NULL, then ASSERT(). If String is not aligned on a 16-bit boundary, then ASSERT(). */
UINTN BmStrSizeEx(IN CONST CHAR16 *String, IN UINTN MaxStringLen)
/* If String is NULL, then ASSERT(). If String is not aligned on a 16-bit boundary, then ASSERT(). */ UINTN BmStrSizeEx(IN CONST CHAR16 *String, IN UINTN MaxStringLen)
{ UINTN Length; ASSERT (String != NULL && MaxStringLen != 0); ASSERT (((UINTN)String & BIT0) == 0); for (Length = 0; *String != L'\0' && MaxStringLen != Length; String++, Length += 2) { } if ((*String != L'\0') && (MaxStringLen == Length)) { return 0; } return Length + 2; }
tianocore/edk2
C++
Other
4,240
/* ACPI 6.4, s6.4.2.9 "End Tag": "This checksum is generated such that adding it to the sum of all the data bytes will produce a zero sum." "If the checksum field is zero, the resource data is treated as if the checksum operation succeeded. Configuration proceeds normally." */
EFI_STATUS EFIAPI AmlRdSetEndTagChecksum(IN CONST AML_RD_HEADER *Header, IN UINT8 CheckSum)
/* ACPI 6.4, s6.4.2.9 "End Tag": "This checksum is generated such that adding it to the sum of all the data bytes will produce a zero sum." "If the checksum field is zero, the resource data is treated as if the checksum operation succeeded. Configuration proceeds normally." */ EFI_STATUS EFIAPI AmlRdSetEndTagChecksum(I...
{ if ((Header == NULL) || !AmlRdCompareDescId ( Header, AML_RD_BUILD_SMALL_DESC_ID (ACPI_SMALL_END_TAG_DESCRIPTOR_NAME) )) { ASSERT (0); return EFI_INVALID_PARAMETER; } ((EFI_ACPI_END_TAG_DESCRIPTOR *)Header)->Checksum = CheckSum; return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* This routine should not be called by a driver after its disconnect method has returned. */
void usb_kill_anchored_urbs(struct usb_anchor *anchor)
/* This routine should not be called by a driver after its disconnect method has returned. */ void usb_kill_anchored_urbs(struct usb_anchor *anchor)
{ struct urb *victim; spin_lock_irq(&anchor->lock); while (!list_empty(&anchor->urb_list)) { victim = list_entry(anchor->urb_list.prev, struct urb, anchor_list); usb_get_urb(victim); spin_unlock_irq(&anchor->lock); usb_kill_urb(victim); usb_put_urb(victim); spin_lock_irq(&anchor->lock); } spin_...
robutest/uclinux
C++
GPL-2.0
60
/* If the file name begins with >v, then the file handle which is returned refers to the shell environment variable with the specified name. If the shell environment variable already exists and is non-volatile then EFI_INVALID_PARAMETER is returned. */
EFI_STATUS EFIAPI EfiShellCreateFile(IN CONST CHAR16 *FileName, IN UINT64 FileAttribs, OUT SHELL_FILE_HANDLE *FileHandle)
/* If the file name begins with >v, then the file handle which is returned refers to the shell environment variable with the specified name. If the shell environment variable already exists and is non-volatile then EFI_INVALID_PARAMETER is returned. */ EFI_STATUS EFIAPI EfiShellCreateFile(IN CONST CHAR16 *FileName, IN ...
{ EFI_DEVICE_PATH_PROTOCOL *DevicePath; EFI_STATUS Status; BOOLEAN Volatile; if (StrStr (FileName, L">v") == FileName) { Status = IsVolatileEnv (FileName + 2, &Volatile); if (EFI_ERROR (Status)) { return Status; } if (!Volatile) { return (EFI_INVALID...
tianocore/edk2
C++
Other
4,240
/* Queues the request in the endpoint's queue, and enables the interrupts on the endpoint. */
static void ep_add_request(struct pxa_ep *ep, struct pxa27x_request *req)
/* Queues the request in the endpoint's queue, and enables the interrupts on the endpoint. */ static void ep_add_request(struct pxa_ep *ep, struct pxa27x_request *req)
{ if (unlikely(!req)) return; ep_vdbg(ep, "req:%p, lg=%d, udccsr=0x%03x\n", req, req->req.length, udc_ep_readl(ep, UDCCSR)); req->in_use = 1; list_add_tail(&req->queue, &ep->queue); pio_irq_enable(ep); }
robutest/uclinux
C++
GPL-2.0
60