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 |
|---|---|---|---|---|---|---|---|
/* Selects the TIMx peripheral Capture Compare DMA source. */ | void TIM_SelectCCDMA(TIM_TypeDef *TIMx, FunctionalState NewState) | /* Selects the TIMx peripheral Capture Compare DMA source. */
void TIM_SelectCCDMA(TIM_TypeDef *TIMx, FunctionalState NewState) | {
assert_param(IS_TIM_LIST1_PERIPH(TIMx));
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
TIMx->CR2 |= TIM_CR2_CCDS;
}
else
{
TIMx->CR2 &= (uint16_t)~TIM_CR2_CCDS;
}
} | ajhc/demo-cortex-m3 | C++ | null | 38 |
/* Function: MX25_DREAD Arguments: flash_address, 32 bit flash memory address target_address, buffer address to store returned data byte_length, length of returned data in byte unit Description: The DREAD instruction enable double throughput of Serial Flash in read mode Return Message: FlashAddressInvalid, FlashOperationSuccess */ | ReturnMsg MX25_DREAD(uint32_t flash_address, uint8_t *target_address, uint32_t byte_length) | /* Function: MX25_DREAD Arguments: flash_address, 32 bit flash memory address target_address, buffer address to store returned data byte_length, length of returned data in byte unit Description: The DREAD instruction enable double throughput of Serial Flash in read mode Return Message: FlashAddressInvalid, FlashOperationSuccess */
ReturnMsg MX25_DREAD(uint32_t flash_address, uint8_t *target_address, uint32_t byte_length) | {
uint32_t index;
uint8_t addr_4byte_mode;
uint8_t dc;
if( flash_address > FlashSize ) return FlashAddressInvalid;
if( IsFlash4Byte() )
addr_4byte_mode = TRUE;
else
addr_4byte_mode = FALSE;
dc = GetDummyCycle( DUMMY_CONF_DREAD );
CS_Low();
SendByte( FLASH_CMD_DREAD, SIO );
SendFlashAddr( flash_address, SIO, addr_4byte_mode );
InsertDummyCycle( dc );
for( index=0; index < byte_length; index++ )
{
*(target_address + index) = GetByte( DIO );
}
CS_High();
return FlashOperationSuccess;
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* Adjust peripheral PLL to use the given divider and source. */ | static int adjust_periph_pll(enum periph_id periph_id, int source, int mux_bits, unsigned divider) | /* Adjust peripheral PLL to use the given divider and source. */
static int adjust_periph_pll(enum periph_id periph_id, int source, int mux_bits, unsigned divider) | {
u32 *reg = get_periph_source_reg(periph_id);
clrsetbits_le32(reg, OUT_CLK_DIVISOR_MASK,
divider << OUT_CLK_DIVISOR_SHIFT);
udelay(1);
if (source < 0)
return -1;
clock_ll_set_source_bits(periph_id, mux_bits, source);
udelay(2);
return 0;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Returns: the smallest prime number from a built-in array of primes which is larger than @num */ | guint g_spaced_primes_closest(guint num) | /* Returns: the smallest prime number from a built-in array of primes which is larger than @num */
guint g_spaced_primes_closest(guint num) | {
gint i;
for (i = 0; i < G_N_ELEMENTS (g_primes); i++)
if (g_primes[i] > num)
return g_primes[i];
return g_primes[G_N_ELEMENTS (g_primes) - 1];
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* copy frame data from buffer to AVFrame, handling stride. */ | static void copy_frame(AVFrame *f, const uint8_t *src, int width, int height) | /* copy frame data from buffer to AVFrame, handling stride. */
static void copy_frame(AVFrame *f, const uint8_t *src, int width, int height) | {
AVPicture pic;
avpicture_fill(&pic, src, PIX_FMT_YUV420P, width, height);
av_picture_copy((AVPicture *)f, &pic, PIX_FMT_YUV420P, width, height);
} | DC-SWAT/DreamShell | C++ | null | 404 |
/* Check user specified FileRow is under current screen. */ | BOOLEAN UnderCurrentScreen(IN UINTN FileRow) | /* Check user specified FileRow is under current screen. */
BOOLEAN UnderCurrentScreen(IN UINTN FileRow) | {
if (FileRow > FileBuffer.LowVisibleRange.Row + (MainEditor.ScreenSize.Row - 2) - 1) {
return TRUE;
}
return FALSE;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* The control element is supposed to have the private_value field set up via HDA_BIND_VOL() or HDA_BIND_SW() macros. */ | int snd_hda_mixer_bind_ctls_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | /* The control element is supposed to have the private_value field set up via HDA_BIND_VOL() or HDA_BIND_SW() macros. */
int snd_hda_mixer_bind_ctls_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | {
struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
struct hda_bind_ctls *c;
unsigned long *vals;
int err = 0, change = 0;
mutex_lock(&codec->control_mutex);
c = (struct hda_bind_ctls *)kcontrol->private_value;
for (vals = c->values; *vals; vals++) {
kcontrol->private_value = *vals;
err = c->ops->put(kcontrol, ucontrol);
if (err < 0)
break;
change |= err;
}
kcontrol->private_value = (long)c;
mutex_unlock(&codec->control_mutex);
return err < 0 ? err : change;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* mark a block and all blocks directly/indirectly reference the block as processed. */ | static void update_processed_blocks(struct reloc_control *rc, struct backref_node *node) | /* mark a block and all blocks directly/indirectly reference the block as processed. */
static void update_processed_blocks(struct reloc_control *rc, struct backref_node *node) | {
struct backref_node *next = node;
struct backref_edge *edge;
struct backref_edge *edges[BTRFS_MAX_LEVEL - 1];
int index = 0;
while (next) {
cond_resched();
while (1) {
if (next->processed)
break;
mark_block_processed(rc, next);
if (list_empty(&next->upper))
break;
edge = list_entry(next->upper.next,
struct backref_edge, list[LOWER]);
edges[index++] = edge;
next = edge->node[UPPER];
}
next = walk_down_backref(edges, &index);
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* The next set of routines handle the different operation-responses, associated with SMPP. */ | static void bind_receiver_resp(proto_tree *tree, tvbuff_t *tvb) | /* The next set of routines handle the different operation-responses, associated with SMPP. */
static void bind_receiver_resp(proto_tree *tree, tvbuff_t *tvb) | {
int offset = 0;
smpp_handle_string(tree, tvb, hf_smpp_system_id, &offset);
smpp_handle_tlv(tree, tvb, &offset);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* read CTC counter capture value when reference sync pulse occurred */ | uint16_t ctc_counter_capture_value_read(void) | /* read CTC counter capture value when reference sync pulse occurred */
uint16_t ctc_counter_capture_value_read(void) | {
uint16_t capture_value = 0U;
capture_value = (uint16_t)((CTC_STAT & CTC_STAT_REFCAP)>> CTC_REFCAP_OFFSET);
return (capture_value);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Writes and returns a new value to CR2. This function is only available on IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64. */ | UINTN EFIAPI AsmWriteCr2(UINTN Value) | /* Writes and returns a new value to CR2. This function is only available on IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64. */
UINTN EFIAPI AsmWriteCr2(UINTN Value) | {
_asm {
mov eax, Value
mov cr2, eax
}
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Lightweight file lookup - no refcnt increment if fd table isn't shared. You can use this only if it is guranteed that the current task already holds a refcnt to that file. That check has to be done at fget() only and a flag is returned to be passed to the corresponding fput_light(). There must not be a cloning between an fget_light/fput_light pair. */ | struct file* fget_light(unsigned int fd, int *fput_needed) | /* Lightweight file lookup - no refcnt increment if fd table isn't shared. You can use this only if it is guranteed that the current task already holds a refcnt to that file. That check has to be done at fget() only and a flag is returned to be passed to the corresponding fput_light(). There must not be a cloning between an fget_light/fput_light pair. */
struct file* fget_light(unsigned int fd, int *fput_needed) | {
struct file *file;
struct files_struct *files = current->files;
*fput_needed = 0;
if (likely((atomic_read(&files->count) == 1))) {
file = fcheck_files(files, fd);
} else {
rcu_read_lock();
file = fcheck_files(files, fd);
if (file) {
if (atomic_long_inc_not_zero(&file->f_count))
*fput_needed = 1;
else
file = NULL;
}
rcu_read_unlock();
}
return file;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Called when an inode is about to be open. We use this to disallow opening large files on 32bit systems if the caller didn't specify O_LARGEFILE. On 64bit systems we force on this flag in sys_open. */ | int generic_file_open(struct inode *inode, struct file *filp) | /* Called when an inode is about to be open. We use this to disallow opening large files on 32bit systems if the caller didn't specify O_LARGEFILE. On 64bit systems we force on this flag in sys_open. */
int generic_file_open(struct inode *inode, struct file *filp) | {
if (!(filp->f_flags & O_LARGEFILE) && i_size_read(inode) > MAX_NON_LFS)
return -EOVERFLOW;
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Disable the output pin.
Valid values for ui32TimerSegment are: */ | void am_hal_ctimer_pin_disable(uint32_t ui32TimerNumber, uint32_t ui32TimerSegment) | /* Disable the output pin.
Valid values for ui32TimerSegment are: */
void am_hal_ctimer_pin_disable(uint32_t ui32TimerNumber, uint32_t ui32TimerSegment) | {
volatile uint32_t *pui32ConfigReg;
pui32ConfigReg = (uint32_t *)(AM_REG_CTIMERn(0) + AM_REG_CTIMER_CTRL0_O +
(ui32TimerNumber * TIMER_OFFSET));
AM_CRITICAL_BEGIN_ASM
AM_REGVAL(pui32ConfigReg) &= ~(ui32TimerSegment &
(AM_REG_CTIMER_CTRL0_TMRA0PE_M |
AM_REG_CTIMER_CTRL0_TMRB0PE_M));
AM_CRITICAL_END_ASM
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Set new progress bar colors.
This sets new fill and background colors for the progress bar. If the bar is inverted, the two colors are switched. */ | void wtk_progress_bar_set_colors(struct wtk_progress_bar *bar, gfx_color_t fill_color, gfx_color_t background_color) | /* Set new progress bar colors.
This sets new fill and background colors for the progress bar. If the bar is inverted, the two colors are switched. */
void wtk_progress_bar_set_colors(struct wtk_progress_bar *bar, gfx_color_t fill_color, gfx_color_t background_color) | {
Assert(bar);
if (bar->option & WTK_PROGRESS_BAR_INVERT) {
bar->fill_color = background_color;
bar->background_color = fill_color;
} else {
bar->fill_color = fill_color;
bar->background_color = background_color;
}
} | memfault/zero-to-main | C++ | null | 200 |
/* Make all the timers in the idle state. */ | static void timer_deactive_control(dw_timer_reg_t *addr) | /* Make all the timers in the idle state. */
static void timer_deactive_control(dw_timer_reg_t *addr) | {
addr->TxControl &= ~DW_TIMER_TXCONTROL_ENABLE;
addr->TxControl |= DW_TIMER_TXCONTROL_INTMASK;
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* If the security protocol command completes without an error, the function shall return EFI_SUCCESS. If the security protocol command completes with an error, the function shall return EFI_DEVICE_ERROR. */ | EFI_STATUS EFIAPI NvmeStorageSecurityReceiveData(IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This, IN UINT32 MediaId, IN UINT64 Timeout, IN UINT8 SecurityProtocolId, IN UINT16 SecurityProtocolSpecificData, IN UINTN PayloadBufferSize, OUT VOID *PayloadBuffer, OUT UINTN *PayloadTransferSize) | /* If the security protocol command completes without an error, the function shall return EFI_SUCCESS. If the security protocol command completes with an error, the function shall return EFI_DEVICE_ERROR. */
EFI_STATUS EFIAPI NvmeStorageSecurityReceiveData(IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This, IN UINT32 MediaId, IN UINT64 Timeout, IN UINT8 SecurityProtocolId, IN UINT16 SecurityProtocolSpecificData, IN UINTN PayloadBufferSize, OUT VOID *PayloadBuffer, OUT UINTN *PayloadTransferSize) | {
EFI_STATUS Status;
NVME_DEVICE_PRIVATE_DATA *Device;
Status = EFI_SUCCESS;
if ((PayloadBuffer == NULL) || (PayloadTransferSize == NULL) || (PayloadBufferSize == 0)) {
return EFI_INVALID_PARAMETER;
}
Device = NVME_DEVICE_PRIVATE_DATA_FROM_STORAGE_SECURITY (This);
if (MediaId != Device->BlockIo.Media->MediaId) {
return EFI_MEDIA_CHANGED;
}
if (!Device->BlockIo.Media->MediaPresent) {
return EFI_NO_MEDIA;
}
Status = TrustTransferNvmeDevice (
Device->Controller,
PayloadBuffer,
SecurityProtocolId,
SecurityProtocolSpecificData,
PayloadBufferSize,
FALSE,
Timeout,
PayloadTransferSize
);
return Status;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Return devmap for cdev. If no devmap exists yet, create one and connect it to the cdev. */ | static struct dasd_devmap* dasd_devmap_from_cdev(struct ccw_device *cdev) | /* Return devmap for cdev. If no devmap exists yet, create one and connect it to the cdev. */
static struct dasd_devmap* dasd_devmap_from_cdev(struct ccw_device *cdev) | {
struct dasd_devmap *devmap;
devmap = dasd_find_busid(dev_name(&cdev->dev));
if (IS_ERR(devmap))
devmap = dasd_add_busid(dev_name(&cdev->dev),
DASD_FEATURE_DEFAULT);
return devmap;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* NOTE: The CPU must already be in a safe state for MTRR changes. RETURNS: 0 if no changes made, else a mask indicating what was changed. */ | static unsigned long set_mtrr_state(void) | /* NOTE: The CPU must already be in a safe state for MTRR changes. RETURNS: 0 if no changes made, else a mask indicating what was changed. */
static unsigned long set_mtrr_state(void) | {
unsigned long change_mask = 0;
unsigned int i;
for (i = 0; i < num_var_ranges; i++) {
if (set_mtrr_var_ranges(i, &mtrr_state.var_ranges[i]))
change_mask |= MTRR_CHANGE_MASK_VARIABLE;
}
if (mtrr_state.have_fixed && set_fixed_ranges(mtrr_state.fixed_ranges))
change_mask |= MTRR_CHANGE_MASK_FIXED;
if ((deftype_lo & 0xff) != mtrr_state.def_type
|| ((deftype_lo & 0xc00) >> 10) != mtrr_state.enabled) {
deftype_lo = (deftype_lo & ~0xcff) | mtrr_state.def_type |
(mtrr_state.enabled << 10);
change_mask |= MTRR_CHANGE_MASK_DEFTYPE;
}
return change_mask;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Number of external sensors to be read by the sensor hub.. */ | int32_t lsm6dso_sh_slave_connected_set(stmdev_ctx_t *ctx, lsm6dso_aux_sens_on_t val) | /* Number of external sensors to be read by the sensor hub.. */
int32_t lsm6dso_sh_slave_connected_set(stmdev_ctx_t *ctx, lsm6dso_aux_sens_on_t val) | {
lsm6dso_master_config_t reg;
int32_t ret;
ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK);
if (ret == 0) {
ret = lsm6dso_read_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t *)®,
1);
}
if (ret == 0) {
reg.aux_sens_on = (uint8_t)val;
ret = lsm6dso_write_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t *)®,
1);
}
if (ret == 0) {
ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK);
}
return ret;
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* This creates an orphan entry for the given inode in case something goes wrong in the middle of an unlink/truncate. */ | int btrfs_orphan_add(struct btrfs_trans_handle *trans, struct inode *inode) | /* This creates an orphan entry for the given inode in case something goes wrong in the middle of an unlink/truncate. */
int btrfs_orphan_add(struct btrfs_trans_handle *trans, struct inode *inode) | {
struct btrfs_root *root = BTRFS_I(inode)->root;
int ret = 0;
spin_lock(&root->list_lock);
if (!list_empty(&BTRFS_I(inode)->i_orphan)) {
spin_unlock(&root->list_lock);
return 0;
}
list_add(&BTRFS_I(inode)->i_orphan, &root->orphan_list);
spin_unlock(&root->list_lock);
ret = btrfs_insert_orphan_item(trans, root, inode->i_ino);
return ret;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Returns > 0 on success or negative error code on failure. */ | int __init i2o_pci_init(void) | /* Returns > 0 on success or negative error code on failure. */
int __init i2o_pci_init(void) | {
return pci_register_driver(&i2o_pci_driver);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Main program entry point. After reset, normal code execution will begin here. */ | int main(void) | /* Main program entry point. After reset, normal code execution will begin here. */
int main(void) | {
systemInit();
uint16_t lumMixed, lumInfrared;
while (1)
{
tsl2561GetLuminosity(&lumMixed, &lumInfrared);
printf("Luminosity: \r\n Broadband (Visible + IR) - %d \r\n Infrared - %d \r\n", lumMixed, lumInfrared);
systickDelay(1000);
}
return 0;
} | microbuilder/LPC1343CodeBase | C++ | Other | 73 |
/* Fills each CMP_TypeDef member with its default value. */ | void CMP_StructInit(CMP_TypeDef *InitStruct) | /* Fills each CMP_TypeDef member with its default value. */
void CMP_StructInit(CMP_TypeDef *InitStruct) | {
InitStruct->DebSel = CMP_DEB_NONE;
InitStruct->SignalSourceSel = CMP_SIGNALSRC_PPIN_TO_VREF;
InitStruct->BiasSel = CMP_BIAS_20nA;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* ps2_drain() waits for device to transmit requested number of bytes and discards them. */ | void ps2_drain(struct ps2dev *ps2dev, int maxbytes, int timeout) | /* ps2_drain() waits for device to transmit requested number of bytes and discards them. */
void ps2_drain(struct ps2dev *ps2dev, int maxbytes, int timeout) | {
if (maxbytes > sizeof(ps2dev->cmdbuf)) {
WARN_ON(1);
maxbytes = sizeof(ps2dev->cmdbuf);
}
ps2_begin_command(ps2dev);
serio_pause_rx(ps2dev->serio);
ps2dev->flags = PS2_FLAG_CMD;
ps2dev->cmdcnt = maxbytes;
serio_continue_rx(ps2dev->serio);
wait_event_timeout(ps2dev->wait,
!(ps2dev->flags & PS2_FLAG_CMD),
msecs_to_jiffies(timeout));
ps2_end_command(ps2dev);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* MCAN Clock initialization function.
Enables register interface and peripheral clock */ | void CAN_0_CLOCK_init() | /* MCAN Clock initialization function.
Enables register interface and peripheral clock */
void CAN_0_CLOCK_init() | {
_pmc_enable_periph_clock(ID_MCAN1);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* XXX ld.so expects the auxiliary table to start on a 16-byte boundary, so we have to find it and move it up. :-( */ | void shove_aux_table(unsigned long sp) | /* XXX ld.so expects the auxiliary table to start on a 16-byte boundary, so we have to find it and move it up. :-( */
void shove_aux_table(unsigned long sp) | {
int argc;
char *p;
unsigned long e;
unsigned long aux_start, offset;
argc = *(int *)sp;
sp += sizeof(int) + (argc + 1) * sizeof(char *);
do {
p = *(char **)sp;
sp += sizeof(char *);
} while (p != NULL);
aux_start = sp;
do {
e = *(unsigned long *)sp;
sp += 2 * sizeof(unsigned long);
} while (e != AT_NULL);
offset = ((aux_start + 15) & ~15) - aux_start;
if (offset != 0) {
do {
sp -= sizeof(unsigned long);
e = *(unsigned long *)sp;
*(unsigned long *)(sp + offset) = e;
} while (sp > aux_start);
}
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* See _g_freedesktop_dbus_call_start_service_by_name_sync() for the synchronous, blocking version of this method. */ | void _g_freedesktop_dbus_call_start_service_by_name(_GFreedesktopDBus *proxy, const gchar *arg_name, guint arg_flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) | /* See _g_freedesktop_dbus_call_start_service_by_name_sync() for the synchronous, blocking version of this method. */
void _g_freedesktop_dbus_call_start_service_by_name(_GFreedesktopDBus *proxy, const gchar *arg_name, guint arg_flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) | {
g_dbus_proxy_call (G_DBUS_PROXY (proxy),
"StartServiceByName",
g_variant_new ("(su)",
arg_name,
arg_flags),
G_DBUS_CALL_FLAGS_NONE,
-1,
cancellable,
callback,
user_data);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* These eliminate the overhead of transmitting the command-fifo address with every single command, just wrap a sequence of commands with these and the address is only transmitted once at the start of the block. Be careful to not use any functions in the sequence that do not address the command-fifo as for example any EVE_mem...() function. */ | void EVE_start_cmd_burst(void) | /* These eliminate the overhead of transmitting the command-fifo address with every single command, just wrap a sequence of commands with these and the address is only transmitted once at the start of the block. Be careful to not use any functions in the sequence that do not address the command-fifo as for example any EVE_mem...() function. */
void EVE_start_cmd_burst(void) | {
cmd_burst = 42;
WAIT_SPI()
BUFFER_SPI_WRITE_ADDRESS(EVE_RAM_CMD + cmdOffset)
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Queries the type system for information about a specific type. This function will fill in a user-provided structure to hold type-specific information. If an invalid #GType is passed in, the @type member of the #GTypeQuery is 0. All members filled into the #GTypeQuery structure should be considered constant and have to be left untouched. */ | void g_type_query(GType type, GTypeQuery *query) | /* Queries the type system for information about a specific type. This function will fill in a user-provided structure to hold type-specific information. If an invalid #GType is passed in, the @type member of the #GTypeQuery is 0. All members filled into the #GTypeQuery structure should be considered constant and have to be left untouched. */
void g_type_query(GType type, GTypeQuery *query) | {
TypeNode *node;
g_return_if_fail (query != NULL);
query->type = 0;
node = lookup_type_node_I (type);
if (node && node->is_classed && !node->plugin)
{
G_READ_LOCK (&type_rw_lock);
if (node->data)
{
query->type = NODE_TYPE (node);
query->type_name = NODE_NAME (node);
query->class_size = node->data->class.class_size;
query->instance_size = node->is_instantiatable ? node->data->instance.instance_size : 0;
}
G_READ_UNLOCK (&type_rw_lock);
}
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Allocate buffer for HCI command and fill in opCode for the command. */ | static struct net_buf* hci_cmd_create(uint16_t opcode, uint8_t param_len) | /* Allocate buffer for HCI command and fill in opCode for the command. */
static struct net_buf* hci_cmd_create(uint16_t opcode, uint8_t param_len) | {
struct bt_hci_cmd_hdr *hdr;
struct net_buf *buf;
buf = bt_buf_get_tx(BT_BUF_CMD, K_FOREVER, NULL, 0);
__ASSERT_NO_MSG(buf);
hdr = net_buf_add(buf, sizeof(*hdr));
hdr->opcode = sys_cpu_to_le16(opcode);
hdr->param_len = param_len;
return buf;
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Get the mem size need to be reserved in PEI phase. */ | UINT64 RetrieveRequiredMemorySize(IN EFI_PEI_SERVICES **PeiServices) | /* Get the mem size need to be reserved in PEI phase. */
UINT64 RetrieveRequiredMemorySize(IN EFI_PEI_SERVICES **PeiServices) | {
UINT64 Size;
Size = GetMemorySizeInMemoryTypeInformation (PeiServices);
return Size + PEI_ADDITIONAL_MEMORY_SIZE;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Check if the private key is located in valid range of curve. */ | int ECC_IsPrivateKeyValid(CRPT_T *crpt, E_ECC_CURVE ecc_curve, char private_k[]) | /* Check if the private key is located in valid range of curve. */
int ECC_IsPrivateKeyValid(CRPT_T *crpt, E_ECC_CURVE ecc_curve, char private_k[]) | {
uint32_t i;
(void)crpt;
pCurve = get_curve(ecc_curve);
if(pCurve == NULL)
{
return -1;
}
if(strlen(private_k) < strlen(pCurve->Eorder))
{
return 1;
}
if(strlen(private_k) > strlen(pCurve->Eorder))
{
return 0;
}
for(i = 0U; i < strlen(private_k); i++)
{
if(get_nibble_value(private_k[i]) < get_nibble_value(pCurve->Eorder[i]))
{
return 1;
}
if(get_nibble_value(private_k[i]) > get_nibble_value(pCurve->Eorder[i]))
{
return 0;
}
}
return 0;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Check whether the address is within any of the MMRAM ranges. */ | BOOLEAN EFIAPI IsAddressInMmram(IN EFI_PHYSICAL_ADDRESS Address, IN EFI_MMRAM_DESCRIPTOR *MmramRanges, IN UINTN MmramRangeCount) | /* Check whether the address is within any of the MMRAM ranges. */
BOOLEAN EFIAPI IsAddressInMmram(IN EFI_PHYSICAL_ADDRESS Address, IN EFI_MMRAM_DESCRIPTOR *MmramRanges, IN UINTN MmramRangeCount) | {
UINTN Index;
for (Index = 0; Index < MmramRangeCount; Index++) {
if ((Address >= MmramRanges[Index].CpuStart) &&
(Address < (MmramRanges[Index].CpuStart + MmramRanges[Index].PhysicalSize)))
{
return TRUE;
}
}
return FALSE;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Calculates the CRC-8-CCITT.
CRC-8-CCITT is defined to be x^8 + x^2 + x + 1 To use this function use the following template: crc = isp_crc8( crc, data ); */ | static uint8_t isp_crc8(uint8_t inCrc, uint8_t inData) | /* Calculates the CRC-8-CCITT.
CRC-8-CCITT is defined to be x^8 + x^2 + x + 1 To use this function use the following template: crc = isp_crc8( crc, data ); */
static uint8_t isp_crc8(uint8_t inCrc, uint8_t inData) | {
uint8_t i;
uint16_t data;
data = inCrc ^ inData;
data <<= 8;
for (i = 0; i < 8; i++) {
if ((data & 0x8000) != 0) {
data = data ^ (BOOT_CFG1_CRC8_POLYNOMIAL << 7);
}
data = data << 1;
}
return (uint8_t)(data >> 8);
} | memfault/zero-to-main | C++ | null | 200 |
/* Unlock the recursive mutex object previously locked using */ | OS_Status OS_RecursiveMutexUnlock(OS_Mutex_t *mutex) | /* Unlock the recursive mutex object previously locked using */
OS_Status OS_RecursiveMutexUnlock(OS_Mutex_t *mutex) | {
BaseType_t ret;
OS_HANDLE_ASSERT(OS_MutexIsValid(mutex), mutex->handle);
ret = xSemaphoreGiveRecursive(mutex->handle);
if (ret != pdPASS) {
OS_DBG("%s() fail @ %d\n", __func__, __LINE__);
return OS_FAIL;
}
return OS_OK;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* If found, the flash directory segment will be copied to @flash_dir. Return 1 if found, 0 if not. */ | static int asd_find_flash_dir(struct asd_ha_struct *asd_ha, struct asd_flash_dir *flash_dir) | /* If found, the flash directory segment will be copied to @flash_dir. Return 1 if found, 0 if not. */
static int asd_find_flash_dir(struct asd_ha_struct *asd_ha, struct asd_flash_dir *flash_dir) | {
u32 v;
for (v = 0; v < ASD_FLASH_SIZE; v += FLASH_NEXT_ENTRY_OFFS) {
asd_read_flash_seg(asd_ha, flash_dir, v,
sizeof(FLASH_DIR_COOKIE)-1);
if (memcmp(flash_dir->cookie, FLASH_DIR_COOKIE,
sizeof(FLASH_DIR_COOKIE)-1) == 0) {
asd_ha->hw_prof.flash.dir_offs = v;
asd_read_flash_seg(asd_ha, flash_dir, v,
sizeof(*flash_dir));
return 1;
}
}
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* DAC & CMP always on enable while 1 round sampling. */ | void DAC_CMP_ALWSONCmd(FunctionalState NewState) | /* DAC & CMP always on enable while 1 round sampling. */
void DAC_CMP_ALWSONCmd(FunctionalState NewState) | {
if (NewState != DISABLE)
{
LPRCNT->CAL3 |= LPRCNT_CAL3_DAC_CMP_ALWSON;
RCC_EnableMsi(DISABLE);
}
else
{
LPRCNT->CAL3 &= ~LPRCNT_CAL3_DAC_CMP_ALWSON;
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* switch_leds - switch the leds, go from one site to the other. @ctrl: controller to use @num_of_slots: number of slots to use @work_LED: LED control value @direction: 1 to start from the left side, 0 to start right. */ | static void switch_leds(struct controller *ctrl, const int num_of_slots, u32 *work_LED, const int direction) | /* switch_leds - switch the leds, go from one site to the other. @ctrl: controller to use @num_of_slots: number of slots to use @work_LED: LED control value @direction: 1 to start from the left side, 0 to start right. */
static void switch_leds(struct controller *ctrl, const int num_of_slots, u32 *work_LED, const int direction) | {
int loop;
for (loop = 0; loop < num_of_slots; loop++) {
if (direction)
*work_LED = *work_LED >> 1;
else
*work_LED = *work_LED << 1;
writel(*work_LED, ctrl->hpc_reg + LED_CONTROL);
set_SOGO(ctrl);
wait_for_ctrl_irq(ctrl);
long_delay((2*HZ)/10);
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* These might not be needed with the virtual SVGA device. */ | int vmw_pci_suspend(struct pci_dev *pdev, pm_message_t state) | /* These might not be needed with the virtual SVGA device. */
int vmw_pci_suspend(struct pci_dev *pdev, pm_message_t state) | {
pci_save_state(pdev);
pci_disable_device(pdev);
pci_set_power_state(pdev, PCI_D3hot);
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* External Trigger Enable and Polarity Selection for injected channels. */ | void ADC_ExternalTriggerInjectedConfig(ADC_TypeDef *ADCx, uint16_t ADC_ExternalTrigInjecConvEvent, uint16_t ADC_ExternalTrigInjecEventEdge) | /* External Trigger Enable and Polarity Selection for injected channels. */
void ADC_ExternalTriggerInjectedConfig(ADC_TypeDef *ADCx, uint16_t ADC_ExternalTrigInjecConvEvent, uint16_t ADC_ExternalTrigInjecEventEdge) | {
assert_param(IS_ADC_ALL_PERIPH(ADCx));
assert_param(IS_EXTERNALTRIGINJ_EDGE(ADC_ExternalTrigInjecEventEdge));
assert_param(IS_ADC_EXT_INJEC_TRIG(ADC_ExternalTrigInjecConvEvent));
ADCx->JSQR &= ~(ADC_JSQR_JEXTEN | ADC_JSQR_JEXTSEL);
ADCx->JSQR |= (uint32_t)(ADC_ExternalTrigInjecConvEvent | ADC_ExternalTrigInjecEventEdge);
} | ajhc/demo-cortex-m3 | C++ | null | 38 |
/* Returns the interrupt number for a given ADC base address and sequence number. */ | static uint_fast8_t _ADCIntNumberGet(uint32_t ui32Base, uint32_t ui32SequenceNum) | /* Returns the interrupt number for a given ADC base address and sequence number. */
static uint_fast8_t _ADCIntNumberGet(uint32_t ui32Base, uint32_t ui32SequenceNum) | {
uint_fast8_t ui8Int;
if(CLASS_IS_BLIZZARD)
{
ui8Int = ((ui32Base == ADC0_BASE) ?
(INT_ADC0SS0_BLIZZARD + ui32SequenceNum) :
(INT_ADC0SS0_BLIZZARD + ui32SequenceNum));
}
else
{
ui8Int = 0;
}
return(ui8Int);
} | feaser/openblt | C++ | GNU General Public License v3.0 | 601 |
/* Get the size of the first non-volatile program memory. */ | uint32_t chipid_read_nvpmsize(Chipid *p_chipid) | /* Get the size of the first non-volatile program memory. */
uint32_t chipid_read_nvpmsize(Chipid *p_chipid) | {
return p_chipid->CHIPID_CIDR & CHIPID_CIDR_NVPSIZ_Msk;
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* igb_configure - configure the hardware for RX and TX @adapter: private board structure */ | static void igb_configure(struct igb_adapter *adapter) | /* igb_configure - configure the hardware for RX and TX @adapter: private board structure */
static void igb_configure(struct igb_adapter *adapter) | {
struct net_device *netdev = adapter->netdev;
int i;
igb_get_hw_control(adapter);
igb_set_rx_mode(netdev);
igb_restore_vlan(adapter);
igb_setup_tctl(adapter);
igb_setup_mrqc(adapter);
igb_setup_rctl(adapter);
igb_configure_tx(adapter);
igb_configure_rx(adapter);
igb_rx_fifo_flush_82575(&adapter->hw);
for (i = 0; i < adapter->num_rx_queues; i++) {
struct igb_ring *ring = &adapter->rx_ring[i];
igb_alloc_rx_buffers_adv(ring, igb_desc_unused(ring));
}
adapter->tx_queue_len = netdev->tx_queue_len;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This function does not return until the protection has been saved. */ | int32_t FlashAllUserRegisterSave(void) | /* This function does not return until the protection has been saved. */
int32_t FlashAllUserRegisterSave(void) | {
uint32_t ui32Index;
for (ui32Index = 0; ui32Index < 4; ui32Index++)
{
HWREG(FLASH_FMA) = (0x80000000 + ui32Index);
HWREG(FLASH_FMC) = FLASH_FMC_WRKEY | FLASH_FMC_COMT;
while (HWREG(FLASH_FMC) & FLASH_FMC_COMT)
{
}
}
return (0);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Fills each init_struct member with its default value. */ | void CAN_StructInit(CAN_Basic_InitTypeDef *init_struct) | /* Fills each init_struct member with its default value. */
void CAN_StructInit(CAN_Basic_InitTypeDef *init_struct) | {
init_struct->BRP = 0x0;
init_struct->SJW = 0x0;
init_struct->TESG1 = 0x0;
init_struct->TESG2 = 0x0;
init_struct->SAM = RESET;
init_struct->GTS = DISABLE;
init_struct->CDCLK = 0x0;
init_struct->CLOSE_OPEN_CLK = 0x0;
init_struct->RXINTEN = 0x0;
init_struct->CBP = 0x0;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Enables or disables write protection on the serial EEPROM. */ | int t3_seeprom_wp(struct adapter *adapter, int enable) | /* Enables or disables write protection on the serial EEPROM. */
int t3_seeprom_wp(struct adapter *adapter, int enable) | {
return t3_seeprom_write(adapter, EEPROM_STAT_ADDR, enable ? 0xc : 0);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This function raises interrupt to SEP that signals that is has a new command from the host */ | static void sep_send_reply_command_handler(struct sep_device *sep) | /* This function raises interrupt to SEP that signals that is has a new command from the host */
static void sep_send_reply_command_handler(struct sep_device *sep) | {
dbg("sep:sep_send_reply_command_handler start\n");
flush_cache_all();
sep_dump_message(sep);
mutex_lock(&sep_mutex);
sep->send_ct++;
sep_write_reg(sep, HW_HOST_HOST_SEP_GPR2_REG_ADDR, sep->send_ct);
sep->send_ct++;
sep->reply_ct++;
mutex_unlock(&sep_mutex);
dbg("sep: sep_send_reply_command_handler end\n");
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Reast the DCI registers to their default reset values. */ | void DCI_Rest(void) | /* Reast the DCI registers to their default reset values. */
void DCI_Rest(void) | {
DCI->CTRL = 0x00;
DCI->INTEN = 0x00;
DCI->INTCLR = 0x1F;
DCI->ESYNCC = 0x00;
DCI->ESYNCUM = 0x00;
DCI->CROPWSTAT = 0x00;
DCI->CROPWSIZE = 0x00;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* This function is the entrypoint of USB Mouse Driver. It installs Driver Binding Protocols together with Component Name Protocols. */ | EFI_STATUS EFIAPI USBMouseAbsolutePointerDriverBindingEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable) | /* This function is the entrypoint of USB Mouse Driver. It installs Driver Binding Protocols together with Component Name Protocols. */
EFI_STATUS EFIAPI USBMouseAbsolutePointerDriverBindingEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable) | {
EFI_STATUS Status;
Status = EfiLibInstallDriverBindingComponentName2 (
ImageHandle,
SystemTable,
&gUsbMouseAbsolutePointerDriverBinding,
ImageHandle,
&gUsbMouseAbsolutePointerComponentName,
&gUsbMouseAbsolutePointerComponentName2
);
ASSERT_EFI_ERROR (Status);
return EFI_SUCCESS;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Read a single character from the serial port. */ | int serial_getc(void) | /* Read a single character from the serial port. */
int serial_getc(void) | {
while (!(uart_regs->s1 & KINETIS_UART_S1_RDRF_MSK));
return uart_regs->d;
} | EmcraftSystems/u-boot | C++ | Other | 181 |
/* This method will free @invocation, you cannot use it afterwards. */ | void _g_freedesktop_dbus_complete_list_activatable_names(_GFreedesktopDBus *object, GDBusMethodInvocation *invocation, const gchar *const *activatable_names) | /* This method will free @invocation, you cannot use it afterwards. */
void _g_freedesktop_dbus_complete_list_activatable_names(_GFreedesktopDBus *object, GDBusMethodInvocation *invocation, const gchar *const *activatable_names) | {
g_dbus_method_invocation_return_value (invocation,
g_variant_new ("(^as)",
activatable_names));
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* If RsaContext is NULL, then return FALSE. If MessageHash is NULL, then return FALSE. If Signature is NULL, then return FALSE. If HashSize is not equal to the size of MD5, SHA-1, SHA-256 digest, then return FALSE. */ | BOOLEAN EFIAPI CryptoServiceRsaPkcs1Verify(IN VOID *RsaContext, IN CONST UINT8 *MessageHash, IN UINTN HashSize, IN CONST UINT8 *Signature, IN UINTN SigSize) | /* If RsaContext is NULL, then return FALSE. If MessageHash is NULL, then return FALSE. If Signature is NULL, then return FALSE. If HashSize is not equal to the size of MD5, SHA-1, SHA-256 digest, then return FALSE. */
BOOLEAN EFIAPI CryptoServiceRsaPkcs1Verify(IN VOID *RsaContext, IN CONST UINT8 *MessageHash, IN UINTN HashSize, IN CONST UINT8 *Signature, IN UINTN SigSize) | {
return CALL_BASECRYPTLIB (Rsa.Services.Pkcs1Verify, RsaPkcs1Verify, (RsaContext, MessageHash, HashSize, Signature, SigSize), FALSE);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Sends a USB endpoint event to the core task */ | sl_status_t sli_usbd_core_endpoint_event(uint8_t ep_addr, sl_status_t status) | /* Sends a USB endpoint event to the core task */
sl_status_t sli_usbd_core_endpoint_event(uint8_t ep_addr, sl_status_t status) | {
sli_usbd_core_event_t core_event;
core_event.type = SLI_USBD_EVENT_ENDPOINT;
core_event.endpoint_address = ep_addr;
core_event.status = status;
sli_usbd_core_os_put_core_event(&core_event);
return SL_STATUS_OK;
} | nanoframework/nf-interpreter | C++ | MIT License | 293 |
/* param base Pointer to the FLEXIO_UART_Type structure. param mask Interrupt source. */ | void FLEXIO_UART_EnableInterrupts(FLEXIO_UART_Type *base, uint32_t mask) | /* param base Pointer to the FLEXIO_UART_Type structure. param mask Interrupt source. */
void FLEXIO_UART_EnableInterrupts(FLEXIO_UART_Type *base, uint32_t mask) | {
if ((mask & (uint32_t)kFLEXIO_UART_TxDataRegEmptyInterruptEnable) != 0U)
{
FLEXIO_EnableShifterStatusInterrupts(base->flexioBase, 1UL << base->shifterIndex[0]);
}
if ((mask & (uint32_t)kFLEXIO_UART_RxDataRegFullInterruptEnable) != 0U)
{
FLEXIO_EnableShifterStatusInterrupts(base->flexioBase, 1UL << base->shifterIndex[1]);
}
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* "Normalized" ADC value is one obtained with 400ms of integration time and 16x gain. This function returns the number of bits of shift needed to convert between normalized values and HW values obtained using given timing and gain settings. */ | static int adc_shiftbits(u8 timing) | /* "Normalized" ADC value is one obtained with 400ms of integration time and 16x gain. This function returns the number of bits of shift needed to convert between normalized values and HW values obtained using given timing and gain settings. */
static int adc_shiftbits(u8 timing) | {
int shift = 0;
switch (timing & TSL2563_TIMING_MASK) {
case TSL2563_TIMING_13MS:
shift += 5;
break;
case TSL2563_TIMING_100MS:
shift += 2;
break;
case TSL2563_TIMING_400MS:
break;
}
if (!(timing & TSL2563_TIMING_GAIN16))
shift += 4;
return shift;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This must be called under i_mutex, otherwise the FUSE_NOWRITE usage could conflict with truncation. */ | static void fuse_sync_writes(struct inode *inode) | /* This must be called under i_mutex, otherwise the FUSE_NOWRITE usage could conflict with truncation. */
static void fuse_sync_writes(struct inode *inode) | {
fuse_set_nowrite(inode);
fuse_release_nowrite(inode);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Checks whether the tx is aborted due to collisions. */ | bool synopGMAC_is_tx_aborted(u32 status) | /* Checks whether the tx is aborted due to collisions. */
bool synopGMAC_is_tx_aborted(u32 status) | {
return (((status & DescTxLateCollision) == DescTxLateCollision) | ((status & DescTxExcCollisions) == DescTxExcCollisions));
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Sets the RTC control register hour format to AM (24h)
Requires unlocking backup domain write protection (PWR_CR_DBP) */ | void rtc_set_am_format(void) | /* Sets the RTC control register hour format to AM (24h)
Requires unlocking backup domain write protection (PWR_CR_DBP) */
void rtc_set_am_format(void) | {
RTC_CR &= ~RTC_CR_FMT;
} | libopencm3/libopencm3 | C++ | GNU General Public License v3.0 | 2,931 |
/* If the conversion results in an overflow or an underflow condition, then Result is set to CHAR8_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */ | RETURN_STATUS EFIAPI SafeInt8ToChar8(IN INT8 Operand, OUT CHAR8 *Result) | /* If the conversion results in an overflow or an underflow condition, then Result is set to CHAR8_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeInt8ToChar8(IN INT8 Operand, OUT CHAR8 *Result) | {
RETURN_STATUS Status;
if (Result == NULL) {
return RETURN_INVALID_PARAMETER;
}
if (Operand >= 0) {
*Result = (CHAR8)Operand;
Status = RETURN_SUCCESS;
} else {
*Result = CHAR8_ERROR;
Status = RETURN_BUFFER_TOO_SMALL;
}
return Status;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Check if given line is a shell command. */ | static int is_shell_command(const char *line_p) | /* Check if given line is a shell command. */
static int is_shell_command(const char *line_p) | {
if (*line_p == '/') {
line_p++;
}
return (shell_command_compare(line_p, FSTR("logout"), 6)
|| shell_command_compare(line_p, FSTR("history"), 7)
|| shell_command_compare(line_p, FSTR("help"), 4));
} | eerimoq/simba | C++ | Other | 337 |
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ | static bool i915_pipe_enabled(struct drm_device *dev, enum pipe pipe) | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
static bool i915_pipe_enabled(struct drm_device *dev, enum pipe pipe) | {
struct drm_i915_private *dev_priv = dev->dev_private;
u32 dpll_reg;
if (IS_IRONLAKE(dev)) {
dpll_reg = (pipe == PIPE_A) ? PCH_DPLL_A: PCH_DPLL_B;
} else {
dpll_reg = (pipe == PIPE_A) ? DPLL_A: DPLL_B;
}
return (I915_READ(dpll_reg) & DPLL_VCO_ENABLE);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Check whether this value type can be transfer to EFI_IFR_TYPE_UINT64 */ | BOOLEAN IsTypeInUINT64(IN EFI_HII_VALUE *Value) | /* Check whether this value type can be transfer to EFI_IFR_TYPE_UINT64 */
BOOLEAN IsTypeInUINT64(IN EFI_HII_VALUE *Value) | {
switch (Value->Type) {
case EFI_IFR_TYPE_NUM_SIZE_8:
case EFI_IFR_TYPE_NUM_SIZE_16:
case EFI_IFR_TYPE_NUM_SIZE_32:
case EFI_IFR_TYPE_NUM_SIZE_64:
case EFI_IFR_TYPE_BOOLEAN:
return TRUE;
default:
return FALSE;
}
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Sets the BOD sampling mode (or disables it). */ | void SUPC_SetBodSampling(unsigned int mode) | /* Sets the BOD sampling mode (or disables it). */
void SUPC_SetBodSampling(unsigned int mode) | {
SANITY_CHECK((mode & ~AT91C_SUPC_BODSMPL) == 0);
AT91C_BASE_SUPC->SUPC_BOMR &= ~AT91C_SUPC_BODSMPL;
AT91C_BASE_SUPC->SUPC_BOMR |= mode;
} | apopple/Pandaboard-FreeRTOS | C++ | null | 25 |
/* release and free resources for the SSP port. */ | void ssp_exit(struct ssp_dev *dev) | /* release and free resources for the SSP port. */
void ssp_exit(struct ssp_dev *dev) | {
struct ssp_device *ssp = dev->ssp;
ssp_disable(dev);
if (dev->irq != NO_IRQ)
free_irq(dev->irq, dev);
clk_disable(ssp->clk);
ssp_free(ssp);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Convert a PIO mode and cycle time to the required on/off times for the interface. This has protection against runaway timings. */ | static unsigned int get_pio_timings(ide_drive_t *drive, u8 pio) | /* Convert a PIO mode and cycle time to the required on/off times for the interface. This has protection against runaway timings. */
static unsigned int get_pio_timings(ide_drive_t *drive, u8 pio) | {
struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio);
unsigned int cmd_on, cmd_off;
u8 iordy = 0;
cmd_on = (t->active + 29) / 30;
cmd_off = (ide_pio_cycle_time(drive, pio) - 30 * cmd_on + 29) / 30;
if (cmd_on == 0)
cmd_on = 1;
if (cmd_off == 0)
cmd_off = 1;
if (ide_pio_need_iordy(drive, pio))
iordy = 0x40;
return (cmd_on - 1) << 8 | (cmd_off - 1) | iordy;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* adi_init_digital() sends a trigger & delay sequence to reset and initialize a Logitech joystick into digital mode. */ | static void adi_init_digital(struct gameport *gameport) | /* adi_init_digital() sends a trigger & delay sequence to reset and initialize a Logitech joystick into digital mode. */
static void adi_init_digital(struct gameport *gameport) | {
int seq[] = { 4, -2, -3, 10, -6, -11, -7, -9, 11, 0 };
int i;
for (i = 0; seq[i]; i++) {
gameport_trigger(gameport);
if (seq[i] > 0)
msleep(seq[i]);
if (seq[i] < 0) {
mdelay(-seq[i]);
udelay(-seq[i]*14);
}
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* sn_pcidev_info_get() - Retrieve the pcidev_info struct for the specified device. */ | struct pcidev_info* sn_pcidev_info_get(struct pci_dev *dev) | /* sn_pcidev_info_get() - Retrieve the pcidev_info struct for the specified device. */
struct pcidev_info* sn_pcidev_info_get(struct pci_dev *dev) | {
struct pcidev_info *pcidev;
list_for_each_entry(pcidev,
&(SN_PLATFORM_DATA(dev)->pcidev_info), pdi_list) {
if (pcidev->pdi_linux_pcidev == dev)
return pcidev;
}
return NULL;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on. */ | long GPIOPinRead(unsigned long ulPort, unsigned char ucPins) | /* The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on. */
long GPIOPinRead(unsigned long ulPort, unsigned char ucPins) | {
ASSERT(GPIOBaseValid(ulPort));
return(HWREG(ulPort + (GPIO_O_GPIO_DATA + (ucPins << 2))));
} | micropython/micropython | C++ | Other | 18,334 |
/* ADC MSP de-initialization This function frees the hardware resources used in this example: */ | void HAL_ADC_MspDeInit(ADC_HandleTypeDef *hadc) | /* ADC MSP de-initialization This function frees the hardware resources used in this example: */
void HAL_ADC_MspDeInit(ADC_HandleTypeDef *hadc) | {
ADCx_FORCE_RESET();
ADCx_RELEASE_RESET();
HAL_GPIO_DeInit(ADCx_CHANNELa_GPIO_PORT, ADCx_CHANNELa_PIN);
if(hadc->DMA_Handle != NULL)
{
HAL_DMA_DeInit(hadc->DMA_Handle);
}
HAL_NVIC_DisableIRQ(ADCx_IRQn);
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* Note: This function is derived from "ArmVirtPkg/PlatformHasAcpiDtDxe", by dropping the word size check, and the fw_cfg check. */ | STATIC EFI_STATUS PlatformHasAcpiDt(IN EFI_HANDLE ImageHandle) | /* Note: This function is derived from "ArmVirtPkg/PlatformHasAcpiDtDxe", by dropping the word size check, and the fw_cfg check. */
STATIC EFI_STATUS PlatformHasAcpiDt(IN EFI_HANDLE ImageHandle) | {
if (!PcdGetBool (PcdForceNoAcpi)) {
return gBS->InstallProtocolInterface (
&ImageHandle,
&gEdkiiPlatformHasAcpiGuid,
EFI_NATIVE_INTERFACE,
NULL
);
}
return gBS->InstallProtocolInterface (
&ImageHandle,
&gEdkiiPlatformHasDeviceTreeGuid,
EFI_NATIVE_INTERFACE,
NULL
);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Any command marked 'failed' or 'timeout' must eventually have scsi_finish_cmd() called for it. we do all of the retry stuff here, so when we restart the host after we return it should have an empty queue. */ | static void scsi_unjam_host(struct Scsi_Host *shost) | /* Any command marked 'failed' or 'timeout' must eventually have scsi_finish_cmd() called for it. we do all of the retry stuff here, so when we restart the host after we return it should have an empty queue. */
static void scsi_unjam_host(struct Scsi_Host *shost) | {
unsigned long flags;
LIST_HEAD(eh_work_q);
LIST_HEAD(eh_done_q);
spin_lock_irqsave(shost->host_lock, flags);
list_splice_init(&shost->eh_cmd_q, &eh_work_q);
spin_unlock_irqrestore(shost->host_lock, flags);
SCSI_LOG_ERROR_RECOVERY(1, scsi_eh_prt_fail_stats(shost, &eh_work_q));
if (!scsi_eh_get_sense(&eh_work_q, &eh_done_q))
if (!scsi_eh_abort_cmds(&eh_work_q, &eh_done_q))
scsi_eh_ready_devs(shost, &eh_work_q, &eh_done_q);
scsi_eh_flush_done_q(&eh_done_q);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* acpiphp_disable_slot - power off slot @slot: ACPI PHP slot */ | int acpiphp_disable_slot(struct acpiphp_slot *slot) | /* acpiphp_disable_slot - power off slot @slot: ACPI PHP slot */
int acpiphp_disable_slot(struct acpiphp_slot *slot) | {
int retval = 0;
mutex_lock(&slot->crit_sect);
retval = disable_device(slot);
if (retval)
goto err_exit;
retval = power_off_slot(slot);
if (retval)
goto err_exit;
err_exit:
mutex_unlock(&slot->crit_sect);
return retval;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Reads the specified I2C register and returns its value. */ | u16 I2C_ReadRegister(I2C_TypeDef *i2c, u8 reg) | /* Reads the specified I2C register and returns its value. */
u16 I2C_ReadRegister(I2C_TypeDef *i2c, u8 reg) | {
return (*(vu16*)(*((u32*)&i2c) + reg));
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* retval kStatus_Success Enable IO Low Voltage Detect in low power mode successfully. */ | status_t SPC_EnableLowPowerModeIOLowVoltageDetect(SPC_Type *base, bool enable) | /* retval kStatus_Success Enable IO Low Voltage Detect in low power mode successfully. */
status_t SPC_EnableLowPowerModeIOLowVoltageDetect(SPC_Type *base, bool enable) | {
status_t status = kStatus_Success;
if (enable)
{
base->LP_CFG |= SPC_LP_CFG_IO_LVDE_MASK;
}
else
{
base->LP_CFG &= ~SPC_LP_CFG_IO_LVDE_MASK;
}
return status;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* param base XBARA peripheral address. return the mask of these status flag bits. */ | uint32_t XBARA_GetStatusFlags(XBARA_Type *base) | /* param base XBARA peripheral address. return the mask of these status flag bits. */
uint32_t XBARA_GetStatusFlags(XBARA_Type *base) | {
uint32_t status_flag;
status_flag = ((base->CTRL0 & (XBARA_CTRL0_STS0_MASK | XBARA_CTRL0_STS1_MASK)) |
((base->CTRL1 & (XBARA_CTRL1_STS2_MASK | XBARA_CTRL1_STS3_MASK)) << 16U));
return status_flag;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* here a sysex-common non-realtime midi time code cueing command is decoded. as the codepoints are the same, we decode both realtime and non-realtime here. */ | static unsigned int decode_sysex_common_nrt_mtc(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset, unsigned int data_len) | /* here a sysex-common non-realtime midi time code cueing command is decoded. as the codepoints are the same, we decode both realtime and non-realtime here. */
static unsigned int decode_sysex_common_nrt_mtc(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned int offset, unsigned int data_len) | {
proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_mtc_add, tvb, offset, data_len, ENC_NA );
offset += data_len;
}
return offset-start_offset;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Disable/Stop the RTC oscillator.
Stops the RTC oscillator. */ | void am_hal_rtc_osc_disable(void) | /* Disable/Stop the RTC oscillator.
Stops the RTC oscillator. */
void am_hal_rtc_osc_disable(void) | {
AM_REG(RTC, RTCCTL) |= AM_REG_RTC_RTCCTL_RSTOP(1);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Enables the IDLE state on the USB line. The IDLE state is enable when SOF are present on USB line. A Downstream Resume signal can be sent. */ | void ohci_bus_resume(void) | /* Enables the IDLE state on the USB line. The IDLE state is enable when SOF are present on USB line. A Downstream Resume signal can be sent. */
void ohci_bus_resume(void) | {
uint32_t temp_value;
OHCI->HcRhStatus = RH_HS_CRWE;
temp_value = OHCI->HcControl;
temp_value &= ~HC_CONTROL_HCFS;
temp_value |= HC_CONTROL_HCFS_USBRESUME;
OHCI->HcControl = temp_value;
delay_ms(50);
temp_value = OHCI->HcControl;
temp_value &= ~HC_CONTROL_HCFS;
temp_value |= HC_CONTROL_HCFS_USBOPERATIONAL;
OHCI->HcControl = temp_value;
OHCI->HcControl &= ~HC_CONTROL_RWE;
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* Called by the usb core when the device is removed from the system. */ | static void iowarrior_disconnect(struct usb_interface *interface) | /* Called by the usb core when the device is removed from the system. */
static void iowarrior_disconnect(struct usb_interface *interface) | {
struct iowarrior *dev;
int minor;
dev = usb_get_intfdata(interface);
mutex_lock(&iowarrior_open_disc_lock);
usb_set_intfdata(interface, NULL);
minor = dev->minor;
usb_deregister_dev(interface, &iowarrior_class);
mutex_lock(&dev->mutex);
dev->present = 0;
mutex_unlock(&dev->mutex);
mutex_unlock(&iowarrior_open_disc_lock);
if (dev->opened) {
usb_kill_urb(dev->int_in_urb);
wake_up_interruptible(&dev->read_wait);
wake_up_interruptible(&dev->write_wait);
} else {
iowarrior_delete(dev);
}
dev_info(&interface->dev, "I/O-Warror #%d now disconnected\n",
minor - IOWARRIOR_MINOR_BASE);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* brief SDIF abort the read data when SDIF card is in suspend state Once assert this bit,data state machine will be reset which is waiting for the next blocking data,used in SDIO card suspend sequence,should call after suspend cmd send param base SDIF peripheral base address. param timeout value to wait this bit self clear which indicate the data machine reset to idle */ | bool SDIF_AbortReadData(SDIF_Type *base, uint32_t timeout) | /* brief SDIF abort the read data when SDIF card is in suspend state Once assert this bit,data state machine will be reset which is waiting for the next blocking data,used in SDIO card suspend sequence,should call after suspend cmd send param base SDIF peripheral base address. param timeout value to wait this bit self clear which indicate the data machine reset to idle */
bool SDIF_AbortReadData(SDIF_Type *base, uint32_t timeout) | {
base->CTRL |= SDIF_CTRL_ABORT_READ_DATA_MASK;
while ((base->CTRL & SDIF_CTRL_ABORT_READ_DATA_MASK) == SDIF_CTRL_ABORT_READ_DATA_MASK)
{
if (0UL == timeout)
{
break;
}
timeout--;
}
return IS_SDIF_FLAG_SET(base->CTRL, SDIF_CTRL_ABORT_READ_DATA_MASK) ? false : true;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Read SCSI H/A configuration parameters from serial EEPROM */ | static int se2_rd_all(struct orc_host *host) | /* Read SCSI H/A configuration parameters from serial EEPROM */
static int se2_rd_all(struct orc_host *host) | {
int i;
u8 *np, chksum = 0;
np = (u8 *) nvramp;
for (i = 0; i < 64; i++, np++) {
if (orc_nv_read(host, (u8) i, np) == 0)
return -1;
}
np = (u8 *) nvramp;
for (i = 0; i < 63; i++)
chksum += *np++;
if (nvramp->CheckSum != (u8) chksum)
return -1;
return 1;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* USBH_LL_GetSpeed Return the USB Host Speed from the Low Level Driver. */ | USBH_SpeedTypeDef USBH_LL_GetSpeed(USBH_HandleTypeDef *phost) | /* USBH_LL_GetSpeed Return the USB Host Speed from the Low Level Driver. */
USBH_SpeedTypeDef USBH_LL_GetSpeed(USBH_HandleTypeDef *phost) | {
UNUSED(phost);
USBH_SpeedTypeDef speed = USBH_SPEED_FULL;
return speed;
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* Control the ADC module to do a conversion. Used as a start-convert event which is controlled by software. */ | void ADC_SWTrigCmd(u32 NewState) | /* Control the ADC module to do a conversion. Used as a start-convert event which is controlled by software. */
void ADC_SWTrigCmd(u32 NewState) | {
ADC_TypeDef *adc = ADC;
u8 div = adc->ADC_CLK_DIV;
u8 sync_time[4] = {12, 16, 32, 64};
if(NewState != DISABLE)
adc->ADC_SW_TRIG = BIT_ADC_SW_TRIG;
else
adc->ADC_SW_TRIG = 0;
DelayUs(sync_time[div]);
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* 2nd sample tracepoint probes. Here the caller only guarantees locking for struct file and struct inode. Locking must therefore be done in the probe to use the dentry. */ | static void probe_subsys_event(struct inode *inode, struct file *file) | /* 2nd sample tracepoint probes. Here the caller only guarantees locking for struct file and struct inode. Locking must therefore be done in the probe to use the dentry. */
static void probe_subsys_event(struct inode *inode, struct file *file) | {
printk(KERN_INFO "Event is encountered with inode number %lu\n",
inode->i_ino);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Default values in the event that policy does not override them. */ | static void ecryptfs_set_default_crypt_stat_vals(struct ecryptfs_crypt_stat *crypt_stat, struct ecryptfs_mount_crypt_stat *mount_crypt_stat) | /* Default values in the event that policy does not override them. */
static void ecryptfs_set_default_crypt_stat_vals(struct ecryptfs_crypt_stat *crypt_stat, struct ecryptfs_mount_crypt_stat *mount_crypt_stat) | {
ecryptfs_copy_mount_wide_flags_to_inode_flags(crypt_stat,
mount_crypt_stat);
ecryptfs_set_default_sizes(crypt_stat);
strcpy(crypt_stat->cipher, ECRYPTFS_DEFAULT_CIPHER);
crypt_stat->key_size = ECRYPTFS_DEFAULT_KEY_BYTES;
crypt_stat->flags &= ~(ECRYPTFS_KEY_VALID);
crypt_stat->file_version = ECRYPTFS_FILE_VERSION;
crypt_stat->mount_crypt_stat = mount_crypt_stat;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Fetch the mask bits of the selected CAM and store them into the provided mask buffer. */ | static void mac_get_cam_mask(struct mac_regs __iomem *regs, u8 *mask) | /* Fetch the mask bits of the selected CAM and store them into the provided mask buffer. */
static void mac_get_cam_mask(struct mac_regs __iomem *regs, u8 *mask) | {
int i;
BYTE_REG_BITS_SET(CAMCR_PS_CAM_MASK, CAMCR_PS1 | CAMCR_PS0, ®s->CAMCR);
writeb(0, ®s->CAMADDR);
for (i = 0; i < 8; i++)
*mask++ = readb(&(regs->MARCAM[i]));
writeb(0, ®s->CAMADDR);
BYTE_REG_BITS_SET(CAMCR_PS_MAR, CAMCR_PS1 | CAMCR_PS0, ®s->CAMCR);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Creates Status Change bitmap for the root hub and root port. The bitmap is returned in buf. Bit 0 is the status change indicator for the root hub. Bit 1 is the status change indicator for the single root port. Returns 1 if either change indicator is 1, otherwise returns 0. */ | static int _dwc2_hcd_hub_status_data(struct usb_hcd *hcd, char *buf) | /* Creates Status Change bitmap for the root hub and root port. The bitmap is returned in buf. Bit 0 is the status change indicator for the root hub. Bit 1 is the status change indicator for the single root port. Returns 1 if either change indicator is 1, otherwise returns 0. */
static int _dwc2_hcd_hub_status_data(struct usb_hcd *hcd, char *buf) | {
struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd);
buf[0] = dwc2_hcd_is_status_changed(hsotg, 1) << 1;
return buf[0] != 0;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Called when this line discipline is being attached to the terminal device. Can sleep. Called serialized so that no other events will occur in parallel. No further open will occur until a close. */ | static int n_tty_open(struct tty_struct *tty) | /* Called when this line discipline is being attached to the terminal device. Can sleep. Called serialized so that no other events will occur in parallel. No further open will occur until a close. */
static int n_tty_open(struct tty_struct *tty) | {
if (!tty)
return -EINVAL;
if (!tty->read_buf) {
tty->read_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL);
if (!tty->read_buf)
return -ENOMEM;
}
if (!tty->echo_buf) {
tty->echo_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL);
if (!tty->echo_buf)
return -ENOMEM;
}
reset_buffer_flags(tty);
tty->column = 0;
n_tty_set_termios(tty, NULL);
tty->minimum_to_wake = 1;
tty->closing = 0;
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Brief This function handles I2C2 (Master) interrupt request. Param None Retval None */ | void I2C2_EV_IRQHandler(void) | /* Brief This function handles I2C2 (Master) interrupt request. Param None Retval None */
void I2C2_EV_IRQHandler(void) | {
if(LL_I2C_IsActiveFlag_SB(I2C2))
{
LL_I2C_TransmitData8(I2C2, SLAVE_OWN_ADDRESS | I2C_REQUEST_WRITE);
}
else if(LL_I2C_IsActiveFlag_ADDR(I2C2))
{
LL_I2C_EnableDMAReq_TX(I2C2);
LL_I2C_ClearFlag_ADDR(I2C2);
}
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* Set the previous node pointer of a node */ | static void node_set_prev(lv_ll_t *ll_p, lv_ll_node_t *act, lv_ll_node_t *prev) | /* Set the previous node pointer of a node */
static void node_set_prev(lv_ll_t *ll_p, lv_ll_node_t *act, lv_ll_node_t *prev) | {
if(act == NULL) return;
uint8_t * act8 = (uint8_t *)act;
act8 += LL_PREV_P_OFFSET(ll_p);
lv_ll_node_t ** act_node_p = (lv_ll_node_t **) act8;
lv_ll_node_t ** prev_node_p = (lv_ll_node_t **) &prev;
*act_node_p = *prev_node_p;
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). If StartBit is greater than 31, then ASSERT(). If EndBit is greater than 31, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */ | UINT32 EFIAPI PciBitFieldWrite32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 Value) | /* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). If StartBit is greater than 31, then ASSERT(). If EndBit is greater than 31, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT32 EFIAPI PciBitFieldWrite32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 Value) | {
return PciExpressBitFieldWrite32 (Address, StartBit, EndBit, Value);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Configures one or more pin(s) of a PIO controller as being controlled by peripheral A. Optionally, the corresponding internal pull-up(s) can be enabled. */ | static void PIO_SetPeripheralB(AT91S_PIO *pio, unsigned int mask, unsigned char enablePullUp) | /* Configures one or more pin(s) of a PIO controller as being controlled by peripheral A. Optionally, the corresponding internal pull-up(s) can be enabled. */
static void PIO_SetPeripheralB(AT91S_PIO *pio, unsigned int mask, unsigned char enablePullUp) | {
WRITE(pio, PIO_IDR, mask);
if (enablePullUp) {
WRITE(pio, PIO_PPUER, mask);
}
else {
WRITE(pio, PIO_PPUDR, mask);
}
WRITE(pio, PIO_BSR, mask);
WRITE(pio, PIO_PDR, mask);
} | apopple/Pandaboard-FreeRTOS | C++ | null | 25 |
/* strlen_ok() - Check to see if packet size matches strlen of the string we want to populate. Returns 1 for valid length or 0 for failure. */ | static int strlen_ok(vpd_packet_t *packet, unsigned long length) | /* strlen_ok() - Check to see if packet size matches strlen of the string we want to populate. Returns 1 for valid length or 0 for failure. */
static int strlen_ok(vpd_packet_t *packet, unsigned long length) | {
if (packet->size >= length) {
printf("VPD Packet 0x%x corrupt.\n", packet->identifier);
return 0;
}
return 1;
} | EmcraftSystems/u-boot | C++ | Other | 181 |
/* Disable a module clock derived from the PBB clock. */ | void sysclk_disable_pbb_module(unsigned int index) | /* Disable a module clock derived from the PBB clock. */
void sysclk_disable_pbb_module(unsigned int index) | {
irqflags_t flags;
sysclk_priv_disable_module(AVR32_PM_CLK_GRP_PBB, index);
flags = cpu_irq_save();
sysclk_pbb_refcount--;
if (!sysclk_pbb_refcount)
sysclk_disable_hsb_module(SYSCLK_PBB_BRIDGE);
cpu_irq_restore(flags);
} | memfault/zero-to-main | C++ | null | 200 |
/* Enable clock of given device.
This enables (gates) the clock for the given device. */ | void ccm_clock_gate_enable(enum ccm_clock_gate gr) | /* Enable clock of given device.
This enables (gates) the clock for the given device. */
void ccm_clock_gate_enable(enum ccm_clock_gate gr) | {
uint32_t offset = (uint32_t)gr / 16;
uint32_t gr_mask = 0x3 << ((gr % 16) * 2);
CCM_CCGR(offset * 4) |= gr_mask;
} | insane-adding-machines/unicore-mx | C++ | GNU General Public License v3.0 | 50 |
/* SSP macro: read 1 bytes from FIFO buffer */ | STATIC void SSP_Read2BFifo(LPC_SSP_T *pSSP, Chip_SSP_DATA_SETUP_T *xf_setup) | /* SSP macro: read 1 bytes from FIFO buffer */
STATIC void SSP_Read2BFifo(LPC_SSP_T *pSSP, Chip_SSP_DATA_SETUP_T *xf_setup) | {
uint16_t rDat;
while ((Chip_SSP_GetStatus(pSSP, SSP_STAT_RNE) == SET) &&
(xf_setup->rx_cnt < xf_setup->length)) {
rDat = Chip_SSP_ReceiveFrame(pSSP);
if (xf_setup->rx_data) {
*(uint16_t *) ((uint32_t) xf_setup->rx_data + xf_setup->rx_cnt) = rDat;
xf_setup->rx_cnt += 2;
}
}
} | labapart/polymcu | C++ | null | 201 |
/* Prepare for input from a supplied memory buffer. The buffer must contain the whole JPEG data. */ | jpeg_mem_src(j_decompress_ptr cinfo, const unsigned char *inbuffer, size_t insize) | /* Prepare for input from a supplied memory buffer. The buffer must contain the whole JPEG data. */
jpeg_mem_src(j_decompress_ptr cinfo, const unsigned char *inbuffer, size_t insize) | {
struct jpeg_source_mgr * src;
if (inbuffer == NULL || insize == 0)
ERREXIT(cinfo, JERR_INPUT_EMPTY);
if (cinfo->src == NULL) {
cinfo->src = (struct jpeg_source_mgr *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(struct jpeg_source_mgr));
}
src = cinfo->src;
src->init_source = init_mem_source;
src->fill_input_buffer = fill_mem_input_buffer;
src->skip_input_data = skip_input_data;
src->resync_to_restart = jpeg_resync_to_restart;
src->term_source = term_source;
src->bytes_in_buffer = insize;
src->next_input_byte = (const JOCTET *) inbuffer;
} | xboot/xboot | C++ | MIT License | 779 |
/* Return the first free entry index in the threads table */ | static int ttable_get_empty_slot(void) | /* Return the first free entry index in the threads table */
static int ttable_get_empty_slot(void) | {
for (int i = 0; i < threads_table_size; i++) {
if ((threads_table[i].state == NOTUSED)
|| (PC_REUSE_ABORTED_ENTRIES
&& (threads_table[i].state == ABORTED))) {
return i;
}
}
threads_table = realloc(threads_table,
(threads_table_size + PC_ALLOC_CHUNK_SIZE)
* sizeof(struct threads_table_el));
if (threads_table == NULL) {
posix_print_error_and_exit(NO_MEM_ERR);
}
(void)memset(&threads_table[threads_table_size], 0,
PC_ALLOC_CHUNK_SIZE * sizeof(struct threads_table_el));
threads_table_size += PC_ALLOC_CHUNK_SIZE;
return threads_table_size - PC_ALLOC_CHUNK_SIZE;
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Read NumBytes bytes of data from the address specified by PAddress into Buffer. */ | EFI_STATUS EFIAPI LibFvbFlashDeviceRead(IN UINTN PAddress, IN OUT UINTN *NumBytes, OUT UINT8 *Buffer) | /* Read NumBytes bytes of data from the address specified by PAddress into Buffer. */
EFI_STATUS EFIAPI LibFvbFlashDeviceRead(IN UINTN PAddress, IN OUT UINTN *NumBytes, OUT UINT8 *Buffer) | {
EFI_STATUS Status;
UINT32 ByteCount;
UINT32 RgnSize;
UINT32 AddrOffset;
Status = SpiGetRegionAddress (FlashRegionBios, NULL, &RgnSize);
if (EFI_ERROR (Status)) {
return Status;
}
AddrOffset = (UINT32)((UINT32)PAddress + RgnSize);
ByteCount = (UINT32)*NumBytes;
return SpiFlashRead (FlashRegionBios, AddrOffset, ByteCount, Buffer);
} | tianocore/edk2 | C++ | Other | 4,240 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.