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
|
|---|---|---|---|---|---|---|---|
/* This function should only be called in Slave mode. The Do Ping bit is set in the HCTSIZ register, then the channel is enabled. */
|
void dwc2_hc_do_ping(struct dwc2_hsotg *hsotg, struct dwc2_host_chan *chan)
|
/* This function should only be called in Slave mode. The Do Ping bit is set in the HCTSIZ register, then the channel is enabled. */
void dwc2_hc_do_ping(struct dwc2_hsotg *hsotg, struct dwc2_host_chan *chan)
|
{
u32 hcchar;
u32 hctsiz;
if (dbg_hc(chan))
dev_vdbg(hsotg->dev, "%s: Channel %d\n", __func__,
chan->hc_num);
hctsiz = TSIZ_DOPNG;
hctsiz |= 1 << TSIZ_PKTCNT_SHIFT;
writel(hctsiz, hsotg->regs + HCTSIZ(chan->hc_num));
hcchar = readl(hsotg->regs + HCCHAR(chan->hc_num));
hcchar |= HCCHAR_CHENA;
hcchar &= ~HCCHAR_CHDIS;
writel(hcchar, hsotg->regs + HCCHAR(chan->hc_num));
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Tail memsets can be optimized away by compilers. To sidestep this problem, we cast the pointer to volatile and then operate on it. */
|
static void osdp_memzero(void *mem, size_t size)
|
/* Tail memsets can be optimized away by compilers. To sidestep this problem, we cast the pointer to volatile and then operate on it. */
static void osdp_memzero(void *mem, size_t size)
|
{
size_t i;
volatile uint8_t *p = mem;
for (i = 0; i < size; i++) {
p[i] = 0;
}
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Disable Automatic Output in Break.
Disables the automatic output feature of the Break function of an advanced timer so that the output is re-enabled at the next update event following a break event. */
|
void timer_disable_break_automatic_output(uint32_t timer_peripheral)
|
/* Disable Automatic Output in Break.
Disables the automatic output feature of the Break function of an advanced timer so that the output is re-enabled at the next update event following a break event. */
void timer_disable_break_automatic_output(uint32_t timer_peripheral)
|
{
TIM_BDTR(timer_peripheral) &= ~TIM_BDTR_AOE;
}
|
libopencm3/libopencm3
|
C++
|
GNU General Public License v3.0
| 2,931
|
/* param base Pointer to the FLEXIO_SPI_Type structure. param mask status flag The parameter can be any combination of the following values: arg kFLEXIO_SPI_TxEmptyFlag arg kFLEXIO_SPI_RxEmptyFlag */
|
void FLEXIO_SPI_ClearStatusFlags(FLEXIO_SPI_Type *base, uint32_t mask)
|
/* param base Pointer to the FLEXIO_SPI_Type structure. param mask status flag The parameter can be any combination of the following values: arg kFLEXIO_SPI_TxEmptyFlag arg kFLEXIO_SPI_RxEmptyFlag */
void FLEXIO_SPI_ClearStatusFlags(FLEXIO_SPI_Type *base, uint32_t mask)
|
{
if ((mask & (uint32_t)kFLEXIO_SPI_TxBufferEmptyFlag) != 0U)
{
FLEXIO_ClearShifterStatusFlags(base->flexioBase, 1UL << base->shifterIndex[0]);
}
if ((mask & (uint32_t)kFLEXIO_SPI_RxBufferFullFlag) != 0U)
{
FLEXIO_ClearShifterStatusFlags(base->flexioBase, 1UL << base->shifterIndex[1]);
}
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Get the driver to reprobe for more disks. */
|
static ssize_t probe_disks(struct device_driver *drv, const char *buf, size_t count)
|
/* Get the driver to reprobe for more disks. */
static ssize_t probe_disks(struct device_driver *drv, const char *buf, size_t count)
|
{
struct viodasd_device *d;
for (d = viodasd_devices; d < &viodasd_devices[MAX_DISKNO]; d++) {
if (d->disk == NULL)
probe_disk(d);
}
return count;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Checks whether the specified DMA Channeln interrupt has occurred or not. */
|
ITStatus DMA_GetITStatus(DMA_Interrupts_TypeDef it)
|
/* Checks whether the specified DMA Channeln interrupt has occurred or not. */
ITStatus DMA_GetITStatus(DMA_Interrupts_TypeDef it)
|
{
if(it >= DMA2_IT_GL1 ) {
return (DMA2->ISR & it) ? SET : RESET;
}
return (DMA1->ISR & it) ? SET : RESET;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Software reset. Restore the default values in user registers.. */
|
int32_t lis2mdl_reset_get(stmdev_ctx_t *ctx, uint8_t *val)
|
/* Software reset. Restore the default values in user registers.. */
int32_t lis2mdl_reset_get(stmdev_ctx_t *ctx, uint8_t *val)
|
{
lis2mdl_cfg_reg_a_t reg;
int32_t ret;
ret = lis2mdl_read_reg(ctx, LIS2MDL_CFG_REG_A, (uint8_t*)®, 1);
*val = reg.soft_rst;
return ret;
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* This function returns %0 on success and a negative error code on failure. */
|
static int check_lpt_type(const struct ubifs_info *c, uint8_t **addr, int *pos, int type)
|
/* This function returns %0 on success and a negative error code on failure. */
static int check_lpt_type(const struct ubifs_info *c, uint8_t **addr, int *pos, int type)
|
{
int node_type;
node_type = ubifs_unpack_bits(addr, pos, UBIFS_LPT_TYPE_BITS);
if (node_type != type) {
ubifs_err(c, "invalid type (%d) in LPT node type %d",
node_type, type);
dump_stack();
return -EINVAL;
}
return 0;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* initializes EthDB
Note that this function is documented in the public component header file, IxEthDB.h. */
|
IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBInit(void)
|
/* initializes EthDB
Note that this function is documented in the public component header file, IxEthDB.h. */
IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBInit(void)
|
{
IxEthDBStatus result;
if (ethDBInitializationComplete)
{
return IX_ETH_DB_SUCCESS;
}
IX_ETH_DB_PORTS_ASSERTION;
ixEthDBInitMemoryPools();
ixEthDBMatchMethodsRegister(matchFunctions);
ixEthDBUpdateTypeRegister(ixEthDBPortUpdateRequired);
ixEthDBKeyTypeRegister(ixEthDBKeyType);
ixEthDBInitHash(&dbHashtable, NUM_BUCKETS, ixEthDBEntryXORHash, matchFunctions, (FreeFunction) ixEthDBFreeMacDescriptor);
ixEthDBNPEUpdateAreasInit();
ixEthDBRecordSerializeMethodsRegister();
result = ixEthDBEventProcessorInit();
if (result == IX_ETH_DB_SUCCESS)
{
ixEthDBFeatureCapabilityScan();
}
ethDBInitializationComplete = TRUE;
return result;
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* Device starts unprovisioned. Stops being responsive to Mesh message after initial setup. Later becomes responsive but becomes unresponsive again after provisioning link opens. Then becomes responsive again allowing successful provisioning. Never stops advertising Unprovisioned Device beacons. */
|
static void test_device_unresponsive(void)
|
/* Device starts unprovisioned. Stops being responsive to Mesh message after initial setup. Later becomes responsive but becomes unresponsive again after provisioning link opens. Then becomes responsive again allowing successful provisioning. Never stops advertising Unprovisioned Device beacons. */
static void test_device_unresponsive(void)
|
{
bt_mesh_device_setup(&prov, &comp);
k_sem_init(&prov_sem, 0, 1);
ASSERT_OK(bt_mesh_prov_enable(BT_MESH_PROV_ADV));
bt_mesh_scan_disable();
k_sleep(K_SECONDS(30));
bt_mesh_scan_enable();
k_sem_take(&link_open_sem, K_SECONDS(20));
bt_mesh_scan_disable();
k_sleep(K_SECONDS(60));
bt_mesh_scan_enable();
k_sem_take(&prov_sem, K_SECONDS(20));
PASS();
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* raise irq to CPU if necessary. must be called every time the active irq may change */
|
static void pic_update_irq(struct kvm_pic *s)
|
/* raise irq to CPU if necessary. must be called every time the active irq may change */
static void pic_update_irq(struct kvm_pic *s)
|
{
int irq2, irq;
irq2 = pic_get_irq(&s->pics[1]);
if (irq2 >= 0) {
pic_set_irq1(&s->pics[0], 2, 1);
pic_set_irq1(&s->pics[0], 2, 0);
}
irq = pic_get_irq(&s->pics[0]);
if (irq >= 0)
s->irq_request(s->irq_request_opaque, 1);
else
s->irq_request(s->irq_request_opaque, 0);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Check for OAM cells. OAM F4 is VCI 3 or 4 and PT 0X0. OAM F5 is PT 10X. */
|
gboolean atm_is_oam_cell(const guint16 vci, const guint8 pt)
|
/* Check for OAM cells. OAM F4 is VCI 3 or 4 and PT 0X0. OAM F5 is PT 10X. */
gboolean atm_is_oam_cell(const guint16 vci, const guint8 pt)
|
{
return (((vci == 3 || vci == 4) && ((pt & 0x5) == 0))
|| ((pt & 0x6) == 0x4));
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Worker function returns the variable MTRR count for the CPU. */
|
UINT32 GetVariableMtrrCountWorker(VOID)
|
/* Worker function returns the variable MTRR count for the CPU. */
UINT32 GetVariableMtrrCountWorker(VOID)
|
{
MSR_IA32_MTRRCAP_REGISTER MtrrCap;
MtrrCap.Uint64 = AsmReadMsr64 (MSR_IA32_MTRRCAP);
ASSERT (MtrrCap.Bits.VCNT <= ARRAY_SIZE (((MTRR_VARIABLE_SETTINGS *)0)->Mtrr));
return MtrrCap.Bits.VCNT;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Configures the appropriate peripherals and puts the MCU in sleep mode. */
|
void PMU_Sleep(uint32_t SleepMode, uint32_t SleepCtrl)
|
/* Configures the appropriate peripherals and puts the MCU in sleep mode. */
void PMU_Sleep(uint32_t SleepMode, uint32_t SleepCtrl)
|
{
LPC_SYSCON->PDAWAKECFG = LPC_SYSCON->PDRUNCFG;
LPC_SYSCON->PDSLEEPCFG = SleepCtrl;
switch ( SleepMode )
{
case MCU_POWER_DOWN:
SCB->SCR |= NVIC_LP_SLEEPDEEP;
LPC_PMU->PCON = 0x2;
break;
case MCU_DEEP_SLEEP:
SCB->SCR |= NVIC_LP_SLEEPDEEP;
LPC_PMU->PCON = 0x1;
break;
case MCU_SLEEP:
default:
break;
}
__WFI();
return;
}
|
microbuilder/LPC11U_LPC13U_CodeBase
|
C++
|
Other
| 54
|
/* sets the STP blocking state of a port */
|
IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBSpanningTreeBlockingStateSet(IxEthDBPortId portID, BOOL blocked)
|
/* sets the STP blocking state of a port */
IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBSpanningTreeBlockingStateSet(IxEthDBPortId portID, BOOL blocked)
|
{
IxNpeMhMessage message;
IX_STATUS result;
IX_ETH_DB_CHECK_PORT(portID);
IX_ETH_DB_CHECK_SINGLE_NPE(portID);
IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_SPANNING_TREE_PROTOCOL);
ixEthDBPortInfo[portID].stpBlocked = blocked;
FILL_SETBLOCKINGSTATE_MSG(message, portID, blocked);
IX_ETHDB_SEND_NPE_MSG(IX_ETH_DB_PORT_ID_TO_NPE(portID), message, result);
return result;
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* Locking Note: The rport lock is exected to be held before calling this function. */
|
static void fc_rport_recv_prlo_req(struct fc_rport_priv *, struct fc_seq *, struct fc_frame *)
|
/* Locking Note: The rport lock is exected to be held before calling this function. */
static void fc_rport_recv_prlo_req(struct fc_rport_priv *, struct fc_seq *, struct fc_frame *)
|
{
struct fc_lport *lport = rdata->local_port;
struct fc_frame_header *fh;
struct fc_seq_els_data rjt_data;
fh = fc_frame_header_get(fp);
FC_RPORT_DBG(rdata, "Received PRLO request while in state %s\n",
fc_rport_state(rdata));
rjt_data.fp = NULL;
rjt_data.reason = ELS_RJT_UNAB;
rjt_data.explan = ELS_EXPL_NONE;
lport->tt.seq_els_rsp_send(sp, ELS_LS_RJT, &rjt_data);
fc_frame_free(fp);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Return 0 if dqput() won't block. (note that 1 doesn't necessarily mean blocking) */
|
static int dqput_blocks(struct dquot *dquot)
|
/* Return 0 if dqput() won't block. (note that 1 doesn't necessarily mean blocking) */
static int dqput_blocks(struct dquot *dquot)
|
{
if (atomic_read(&dquot->dq_count) <= 1)
return 1;
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Allocates a new configfs_dirent and links it to the parent configfs_dirent */
|
static struct configfs_dirent* configfs_new_dirent(struct configfs_dirent *parent_sd, void *element, int type)
|
/* Allocates a new configfs_dirent and links it to the parent configfs_dirent */
static struct configfs_dirent* configfs_new_dirent(struct configfs_dirent *parent_sd, void *element, int type)
|
{
struct configfs_dirent * sd;
sd = kmem_cache_zalloc(configfs_dir_cachep, GFP_KERNEL);
if (!sd)
return ERR_PTR(-ENOMEM);
atomic_set(&sd->s_count, 1);
INIT_LIST_HEAD(&sd->s_links);
INIT_LIST_HEAD(&sd->s_children);
sd->s_element = element;
sd->s_type = type;
configfs_init_dirent_depth(sd);
spin_lock(&configfs_dirent_lock);
if (parent_sd->s_type & CONFIGFS_USET_DROPPING) {
spin_unlock(&configfs_dirent_lock);
kmem_cache_free(configfs_dir_cachep, sd);
return ERR_PTR(-ENOENT);
}
list_add(&sd->s_sibling, &parent_sd->s_children);
spin_unlock(&configfs_dirent_lock);
return sd;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* MTBSR: Backward space over 'count' tape blocks. (blocksize is set via MTSETBLK. */
|
int tape_std_mtbsr(struct tape_device *device, int mt_count)
|
/* MTBSR: Backward space over 'count' tape blocks. (blocksize is set via MTSETBLK. */
int tape_std_mtbsr(struct tape_device *device, int mt_count)
|
{
struct tape_request *request;
struct ccw1 *ccw;
int rc;
request = tape_alloc_request(mt_count + 2, 0);
if (IS_ERR(request))
return PTR_ERR(request);
request->op = TO_BSB;
ccw = tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1,
device->modeset_byte);
ccw = tape_ccw_repeat(ccw, BACKSPACEBLOCK, mt_count);
ccw = tape_ccw_end(ccw, NOP, 0, NULL);
rc = tape_do_io(device, request);
if (rc == 0 && request->rescnt > 0) {
DBF_LH(3, "BSR over tapemark\n");
rc = 1;
}
tape_free_request(request);
return rc;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Returns: the index of the element containing the data, or -1 if the data is not found */
|
gint g_slist_index(GSList *list, gconstpointer data)
|
/* Returns: the index of the element containing the data, or -1 if the data is not found */
gint g_slist_index(GSList *list, gconstpointer data)
|
{
gint i;
i = 0;
while (list)
{
if (list->data == data)
return i;
i++;
list = list->next;
}
return -1;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Initialize the USB device controller hardware of the STM32. */
|
static usbd_device * st_usbfs_v1_usbd_init(void)
|
/* Initialize the USB device controller hardware of the STM32. */
static usbd_device * st_usbfs_v1_usbd_init(void)
|
{
rcc_periph_clock_enable(RCC_USB);
SET_REG(USB_CNTR_REG, 0);
SET_REG(USB_BTABLE_REG, 0);
SET_REG(USB_ISTR_REG, 0);
SET_REG(USB_CNTR_REG, USB_CNTR_RESETM | USB_CNTR_CTRM |
USB_CNTR_SUSPM | USB_CNTR_WKUPM);
return &st_usbfs_dev;
}
|
libopencm3/libopencm3
|
C++
|
GNU General Public License v3.0
| 2,931
|
/* Change Logs: Date Author Notes WillianChan first version */
|
static int ve_cmd_help(int argc, char **argv)
|
/* Change Logs: Date Author Notes WillianChan first version */
static int ve_cmd_help(int argc, char **argv)
|
{
rt_kprintf("Usage:\n");
rt_kprintf("ve_find module <module> - Find by module name\n");
rt_kprintf("ve_find value <module> <identifier> - Find accurately\n");
return RT_EOK;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Fills each SGPIO_MULInitStruct member with its default value. */
|
void SGPIO_MUL_StructInit(SGPIO_MULInitTypeDef *SGPIO_MULInitStruct)
|
/* Fills each SGPIO_MULInitStruct member with its default value. */
void SGPIO_MUL_StructInit(SGPIO_MULInitTypeDef *SGPIO_MULInitStruct)
|
{
SGPIO_MULInitStruct->BiOut = MUL_DISABLE_BIOUT;
SGPIO_MULInitStruct->MulMode_Sel = MUL_TIMER_MODE;
SGPIO_MULInitStruct->MulPRVal = (2-1);
SGPIO_MULInitStruct->MulPRTC = 0x0;
SGPIO_MULInitStruct->MulTC = 0x0;
SGPIO_MULInitStruct->MulData_Dir = MUL_DATA_DIR_LSB;
SGPIO_MULInitStruct->MulPosTC = (8-1);
SGPIO_MULInitStruct->MulPosRST = (8-1);
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* Given a frame_data structure, scroll to and select the row in the packet list corresponding to that frame. If there is no such row, return FALSE, otherwise return TRUE. */
|
gboolean packet_list_select_row_from_data(frame_data *fdata_needle)
|
/* Given a frame_data structure, scroll to and select the row in the packet list corresponding to that frame. If there is no such row, return FALSE, otherwise return TRUE. */
gboolean packet_list_select_row_from_data(frame_data *fdata_needle)
|
{
gbl_cur_packet_list->packetListModel()->flushVisibleRows();
int row = gbl_cur_packet_list->packetListModel()->visibleIndexOf(fdata_needle);
if (row >= 0) {
gbl_cur_packet_list->setCurrentIndex(gbl_cur_packet_list->packetListModel()->index(row,0));
return TRUE;
}
return FALSE;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Change Logs: Date Author Notes ArdaFu first version */
|
void HW_SetPinMux(rt_uint8_t port, rt_uint8_t pin, rt_uint8_t mux_type)
|
/* Change Logs: Date Author Notes ArdaFu first version */
void HW_SetPinMux(rt_uint8_t port, rt_uint8_t pin, rt_uint8_t mux_type)
|
{
rt_uint32_t addr = HW_IOCON(port, pin);
rt_uint32_t val = inl(addr);
val &= ~7UL;
val |= mux_type;
outl(val ,addr);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Returns: TRUE if @value will fit inside a pointer value. */
|
gboolean g_value_fits_pointer(const GValue *value)
|
/* Returns: TRUE if @value will fit inside a pointer value. */
gboolean g_value_fits_pointer(const GValue *value)
|
{
GTypeValueTable *value_table;
g_return_val_if_fail (G_IS_VALUE (value), FALSE);
value_table = g_type_value_table_peek (G_VALUE_TYPE (value));
return value_table->value_peek_pointer != NULL;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Return the SDL_GameController associated with a player index. */
|
SDL_GameController* SDL_GameControllerFromPlayerIndex(int player_index)
|
/* Return the SDL_GameController associated with a player index. */
SDL_GameController* SDL_GameControllerFromPlayerIndex(int player_index)
|
{
SDL_Joystick *joystick = SDL_JoystickFromPlayerIndex(player_index);
if (joystick) {
return SDL_GameControllerFromInstanceID(joystick->instance_id);
}
return NULL;
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). If the register specified by Address >= 0x100, then ASSERT(). */
|
UINT16 EFIAPI PciCf8Write16(IN UINTN Address, IN UINT16 Value)
|
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). If the register specified by Address >= 0x100, then ASSERT(). */
UINT16 EFIAPI PciCf8Write16(IN UINTN Address, IN UINT16 Value)
|
{
BOOLEAN InterruptState;
UINT32 AddressPort;
UINT16 Result;
ASSERT_INVALID_PCI_ADDRESS (Address, 1);
InterruptState = SaveAndDisableInterrupts ();
AddressPort = IoRead32 (PCI_CONFIGURATION_ADDRESS_PORT);
IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));
Result = IoWrite16 (
PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2),
Value
);
IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, AddressPort);
SetInterruptState (InterruptState);
return Result;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* The interrupt block recognition checks data after/before the hard-iron correction to discover the interrupt.. */
|
int32_t iis2mdc_offset_int_conf_get(stmdev_ctx_t *ctx, iis2mdc_int_on_dataoff_t *val)
|
/* The interrupt block recognition checks data after/before the hard-iron correction to discover the interrupt.. */
int32_t iis2mdc_offset_int_conf_get(stmdev_ctx_t *ctx, iis2mdc_int_on_dataoff_t *val)
|
{
iis2mdc_cfg_reg_b_t reg;
int32_t ret;
ret = iis2mdc_read_reg(ctx, IIS2MDC_CFG_REG_B, (uint8_t *) ®, 1);
switch (reg.int_on_dataoff) {
case IIS2MDC_CHECK_BEFORE:
*val = IIS2MDC_CHECK_BEFORE;
break;
case IIS2MDC_CHECK_AFTER:
*val = IIS2MDC_CHECK_AFTER;
break;
default:
*val = IIS2MDC_CHECK_BEFORE;
break;
}
return ret;
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Release a DMA channel from exclusive access, similar to clk_put(). */
|
int kinetis_dma_ch_put(int ch)
|
/* Release a DMA channel from exclusive access, similar to clk_put(). */
int kinetis_dma_ch_put(int ch)
|
{
unsigned long fl;
int rv;
if (!kinetis_dma_ch_valid(ch)) {
rv = -EINVAL;
goto out;
}
spin_lock_irqsave(&dma_ch[ch].lock, fl);
rv = dma_ch[ch].in_use ? 0 : -EBUSY;
dma_ch[ch].in_use = 0;
spin_unlock_irqrestore(&dma_ch[ch].lock, fl);
out:
return rv;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Receive a piece of data in non-blocking way. */
|
static void FLEXIO_I2S_ReadNonBlocking(FLEXIO_I2S_Type *base, uint8_t bitWidth, uint8_t *rxData, size_t size)
|
/* Receive a piece of data in non-blocking way. */
static void FLEXIO_I2S_ReadNonBlocking(FLEXIO_I2S_Type *base, uint8_t bitWidth, uint8_t *rxData, size_t size)
|
{
uint32_t i = 0;
uint8_t j = 0;
uint8_t bytesPerWord = bitWidth / 8U;
uint32_t data = 0;
for (i = 0; i < size / bytesPerWord; i++)
{
data = base->flexioBase->SHIFTBUFBIS[base->rxShifterIndex];
for (j = 0; j < bytesPerWord; j++)
{
*rxData = (data >> (8U * j)) & 0xFF;
rxData++;
}
}
}
|
labapart/polymcu
|
C++
| null | 201
|
/* This will aim to fill the RX descriptor queue up to @rx_queue->@fast_fill_limit. If there is insufficient memory to do so, it will schedule a work item to immediately continue the fast fill */
|
void efx_fast_push_rx_descriptors(struct efx_rx_queue *rx_queue)
|
/* This will aim to fill the RX descriptor queue up to @rx_queue->@fast_fill_limit. If there is insufficient memory to do so, it will schedule a work item to immediately continue the fast fill */
void efx_fast_push_rx_descriptors(struct efx_rx_queue *rx_queue)
|
{
int rc;
rc = __efx_fast_push_rx_descriptors(rx_queue, 0);
if (unlikely(rc)) {
efx_schedule_slow_fill(rx_queue, 0);
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function returns the interrupt number for a system exception. */
|
static uint32_t _SysExcIntNumberGet(void)
|
/* This function returns the interrupt number for a system exception. */
static uint32_t _SysExcIntNumberGet(void)
|
{
uint32_t ui32Int;
ui32Int = INT_SYSEXC;
return (ui32Int);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Fills in smi_info.device_id.start_transaction_pre_hook when we know what function to use there. */
|
static void setup_dell_poweredge_bt_xaction_handler(struct smi_info *smi_info)
|
/* Fills in smi_info.device_id.start_transaction_pre_hook when we know what function to use there. */
static void setup_dell_poweredge_bt_xaction_handler(struct smi_info *smi_info)
|
{
struct ipmi_device_id *id = &smi_info->device_id;
if (id->manufacturer_id == DELL_IANA_MFR_ID &&
smi_info->si_type == SI_BT)
register_xaction_notifier(&dell_poweredge_bt_xaction_notifier);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Converts a text device path node to USB CDC Control device path structure. */
|
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextUsbCDCControl(CHAR16 *TextDeviceNode)
|
/* Converts a text device path node to USB CDC Control device path structure. */
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextUsbCDCControl(CHAR16 *TextDeviceNode)
|
{
USB_CLASS_TEXT UsbClassText;
UsbClassText.ClassExist = FALSE;
UsbClassText.Class = USB_CLASS_CDCCONTROL;
UsbClassText.SubClassExist = TRUE;
return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Takes a single sample from an ADC interface */
|
int32_t hal_adc_value_get(adc_dev_t *adc, uint32_t *output, uint32_t timeout)
|
/* Takes a single sample from an ADC interface */
int32_t hal_adc_value_get(adc_dev_t *adc, uint32_t *output, uint32_t timeout)
|
{
int count = 5;
enum HAL_GPADC_CHAN_T channel;
HAL_GPADC_MV_T volt = HAL_GPADC_BAD_VALUE;
if (output == NULL)
return -EINVAL;
channel = __hal_adc_port2chan(adc->port);
if (channel >= HAL_GPADC_CHAN_QTY)
return -EINVAL;
hal_gpadc_open(channel, HAL_GPADC_ATP_ONESHOT, NULL);
osDelay(1);
while (count--) {
if (hal_gpadc_get_volt(channel, &volt)) {
*output = volt;
return 0;
}
osDelay(1);
}
return -EIO;
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* param base SAI base pointer param handle SAI handle pointer. param callback Pointer to the user callback function. param userData User parameter passed to the callback function */
|
void SAI_TransferTxCreateHandle(I2S_Type *base, sai_handle_t *handle, sai_transfer_callback_t callback, void *userData)
|
/* param base SAI base pointer param handle SAI handle pointer. param callback Pointer to the user callback function. param userData User parameter passed to the callback function */
void SAI_TransferTxCreateHandle(I2S_Type *base, sai_handle_t *handle, sai_transfer_callback_t callback, void *userData)
|
{
assert(handle);
memset(handle, 0, sizeof(*handle));
s_saiHandle[SAI_GetInstance(base)][0] = handle;
handle->callback = callback;
handle->userData = userData;
handle->base = base;
s_saiTxIsr = SAI_TransferTxHandleIRQ;
EnableIRQ(s_saiTxIRQ[SAI_GetInstance(base)]);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* A call to try to shrink memory usage on charge failure at shmem's swapin. Calling hierarchical_reclaim is not enough because we should update last_oom_jiffies to prevent pagefault_out_of_memory from invoking global OOM. Moreover considering hierarchy, we should reclaim from the mem_over_limit, not from the memcg which this page would be charged to. try_charge_swapin does all of these works properly. */
|
int mem_cgroup_shmem_charge_fallback(struct page *page, struct mm_struct *mm, gfp_t gfp_mask)
|
/* A call to try to shrink memory usage on charge failure at shmem's swapin. Calling hierarchical_reclaim is not enough because we should update last_oom_jiffies to prevent pagefault_out_of_memory from invoking global OOM. Moreover considering hierarchy, we should reclaim from the mem_over_limit, not from the memcg which this page would be charged to. try_charge_swapin does all of these works properly. */
int mem_cgroup_shmem_charge_fallback(struct page *page, struct mm_struct *mm, gfp_t gfp_mask)
|
{
struct mem_cgroup *mem = NULL;
int ret;
if (mem_cgroup_disabled())
return 0;
ret = mem_cgroup_try_charge_swapin(mm, page, gfp_mask, &mem);
if (!ret)
mem_cgroup_cancel_charge_swapin(mem);
return ret;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Checks whether the specified SDIO interrupt has occurred or not. */
|
INTStatus SDIO_GetIntStatus(uint32_t SDIO_IT)
|
/* Checks whether the specified SDIO interrupt has occurred or not. */
INTStatus SDIO_GetIntStatus(uint32_t SDIO_IT)
|
{
INTStatus bitstatus = RESET;
assert_param(IS_SDIO_GET_INT(SDIO_IT));
if ((SDIO->STS & SDIO_IT) != (uint32_t)RESET)
{
bitstatus = SET;
}
else
{
bitstatus = RESET;
}
return bitstatus;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Starts the PWM signal generation in interrupt mode. */
|
void ald_timer_pwm_start_by_it(ald_timer_handle_t *hperh, ald_timer_channel_t ch)
|
/* Starts the PWM signal generation in interrupt mode. */
void ald_timer_pwm_start_by_it(ald_timer_handle_t *hperh, ald_timer_channel_t ch)
|
{
ald_timer_oc_start_by_it(hperh, ch);
return;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Set the Value for the Timer Prescaler.
The timer clock is prescaled by the 16 bit scale value plus 1. */
|
void timer_set_prescaler(uint32_t timer_peripheral, uint32_t value)
|
/* Set the Value for the Timer Prescaler.
The timer clock is prescaled by the 16 bit scale value plus 1. */
void timer_set_prescaler(uint32_t timer_peripheral, uint32_t value)
|
{
TIM_PSC(timer_peripheral) = value;
}
|
insane-adding-machines/unicore-mx
|
C++
|
GNU General Public License v3.0
| 50
|
/* Extract structure information about the picture described by pic_num in the current decoding context (frame or field). Note that pic_num is picture number without wrapping (so, 0<=pic_num<max_pic_num). */
|
static int pic_num_extract(H264Context *h, int pic_num, int *structure)
|
/* Extract structure information about the picture described by pic_num in the current decoding context (frame or field). Note that pic_num is picture number without wrapping (so, 0<=pic_num<max_pic_num). */
static int pic_num_extract(H264Context *h, int pic_num, int *structure)
|
{
if (!(pic_num & 1))
*structure ^= PICT_FRAME;
pic_num >>= 1;
}
return pic_num;
}
|
DC-SWAT/DreamShell
|
C++
| null | 404
|
/* Set PHY placed in a loopback mode of operation. */
|
int32_t ethernet_phy_set_loopback(struct ethernet_phy_descriptor *const descr, bool state)
|
/* Set PHY placed in a loopback mode of operation. */
int32_t ethernet_phy_set_loopback(struct ethernet_phy_descriptor *const descr, bool state)
|
{
ASSERT(descr);
if (state) {
return ethernet_phy_set_reg_bit(descr, MDIO_REG0_BMCR, MDIO_REG0_BIT_LOOPBACK);
} else {
return ethernet_phy_clear_reg_bit(descr, MDIO_REG0_BMCR, MDIO_REG0_BIT_LOOPBACK);
}
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Reads from the address space of a given SDIO function. Return value indicates if the transfer succeeded or not. */
|
int sdio_memcpy_fromio(struct sdio_func *func, void *dst, unsigned int addr, int count)
|
/* Reads from the address space of a given SDIO function. Return value indicates if the transfer succeeded or not. */
int sdio_memcpy_fromio(struct sdio_func *func, void *dst, unsigned int addr, int count)
|
{
return sdio_io_rw_ext_helper(func, 0, addr, 1, dst, count);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Configures the I2C Bus Timeout B (SCL cumulative Timeout). */
|
void I2C_TimeoutBConfig(I2C_TypeDef *I2Cx, uint16_t Timeout)
|
/* Configures the I2C Bus Timeout B (SCL cumulative Timeout). */
void I2C_TimeoutBConfig(I2C_TypeDef *I2Cx, uint16_t Timeout)
|
{
uint32_t tmpreg = 0;
assert_param(IS_I2C_ALL_PERIPH(I2Cx));
assert_param(IS_I2C_TIMEOUT(Timeout));
tmpreg = I2Cx->TIMEOUTR;
tmpreg &= (uint32_t)~((uint32_t)I2C_TIMEOUTR_TIMEOUTB);
tmpreg |= (uint32_t)(((uint32_t)Timeout << 16) & I2C_TIMEOUTR_TIMEOUTB) ;
I2Cx->TIMEOUTR = tmpreg;
}
|
ajhc/demo-cortex-m3
|
C++
| null | 38
|
/* See "mss_ace.h" for details of how to use this function. */
|
ace_channel_handle_t ACE_get_first_channel(void)
|
/* See "mss_ace.h" for details of how to use this function. */
ace_channel_handle_t ACE_get_first_channel(void)
|
{
ace_channel_handle_t channel_handle;
channel_handle = (ace_channel_handle_t)0;
return channel_handle;
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* This function builds a Firmware Volume HOB. It can only be invoked during PEI phase; for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. If there is no additional space for HOB creation, then ASSERT(). */
|
VOID EFIAPI BuildFvHob(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length)
|
/* This function builds a Firmware Volume HOB. It can only be invoked during PEI phase; for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. If there is no additional space for HOB creation, then ASSERT(). */
VOID EFIAPI BuildFvHob(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length)
|
{
EFI_HOB_FIRMWARE_VOLUME *Hob;
Hob = CreateHob (EFI_HOB_TYPE_FV, sizeof (EFI_HOB_FIRMWARE_VOLUME));
ASSERT (Hob != NULL);
if (Hob == NULL) {
return;
}
Hob->BaseAddress = BaseAddress;
Hob->Length = Length;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Returns: -EINVAL if the buffer does not contain the string "selective" length of buf if lpfc-selective_reset() if the call succeeds return value of lpfc_selective_reset() if the call fails */
|
static ssize_t lpfc_issue_reset(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
|
/* Returns: -EINVAL if the buffer does not contain the string "selective" length of buf if lpfc-selective_reset() if the call succeeds return value of lpfc_selective_reset() if the call fails */
static ssize_t lpfc_issue_reset(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
|
{
struct Scsi_Host *shost = class_to_shost(dev);
struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
struct lpfc_hba *phba = vport->phba;
int status = -EINVAL;
if (strncmp(buf, "selective", sizeof("selective") - 1) == 0)
status = lpfc_selective_reset(phba);
if (status == 0)
return strlen(buf);
else
return status;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function enable the HSE when it is used by PLL or PLL2. */
|
static ErrorStatus UTILS_PLL_HSE_ConfigSystemClock(uint32_t PLL_InputFrequency, uint32_t HSEBypass, LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct, LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct)
|
/* This function enable the HSE when it is used by PLL or PLL2. */
static ErrorStatus UTILS_PLL_HSE_ConfigSystemClock(uint32_t PLL_InputFrequency, uint32_t HSEBypass, LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct, LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct)
|
{
ErrorStatus status = SUCCESS;
if (UTILS_PLL_IsBusy() == SUCCESS)
{
if (LL_RCC_HSE_IsReady() != 1U)
{
if (HSEBypass == LL_UTILS_HSEBYPASS_ON)
{
LL_RCC_HSE_EnableBypass();
}
else
{
LL_RCC_HSE_DisableBypass();
}
LL_RCC_HSE_Enable();
while (LL_RCC_HSE_IsReady() != 1U)
{
}
}
}
else
{
status = ERROR;
}
return status;
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* DAC960_V1_ClearCommand clears critical fields of Command for DAC960 V1 Firmware Controllers. */
|
static void DAC960_V1_ClearCommand(DAC960_Command_T *Command)
|
/* DAC960_V1_ClearCommand clears critical fields of Command for DAC960 V1 Firmware Controllers. */
static void DAC960_V1_ClearCommand(DAC960_Command_T *Command)
|
{
DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
memset(CommandMailbox, 0, sizeof(DAC960_V1_CommandMailbox_T));
Command->V1.CommandStatus = 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* zfcp_qdio_allocate - allocate queue memory and initialize QDIO data @adapter: pointer to struct zfcp_adapter Returns: -ENOMEM on memory allocation error or return value from qdio_allocate */
|
static int zfcp_qdio_allocate(struct zfcp_qdio *qdio)
|
/* zfcp_qdio_allocate - allocate queue memory and initialize QDIO data @adapter: pointer to struct zfcp_adapter Returns: -ENOMEM on memory allocation error or return value from qdio_allocate */
static int zfcp_qdio_allocate(struct zfcp_qdio *qdio)
|
{
struct qdio_initialize init_data;
if (zfcp_qdio_buffers_enqueue(qdio->req_q.sbal) ||
zfcp_qdio_buffers_enqueue(qdio->resp_q.sbal))
return -ENOMEM;
zfcp_qdio_setup_init_data(&init_data, qdio);
return qdio_allocate(&init_data);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* For both inputs and outputs tv_nsec must be in the range [0, NSEC_PER_SEC). tv_sec may be negative, zero, or positive. */
|
void timespec_subtract(struct timespec *amb, const struct timespec *a, const struct timespec *b)
|
/* For both inputs and outputs tv_nsec must be in the range [0, NSEC_PER_SEC). tv_sec may be negative, zero, or positive. */
void timespec_subtract(struct timespec *amb, const struct timespec *a, const struct timespec *b)
|
{
if (a->tv_nsec >= b->tv_nsec) {
amb->tv_nsec = a->tv_nsec - b->tv_nsec;
amb->tv_sec = a->tv_sec - b->tv_sec;
} else {
amb->tv_nsec = NSEC_PER_SEC + a->tv_nsec - b->tv_nsec;
amb->tv_sec = a->tv_sec - b->tv_sec - 1;
}
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* clear checked flag of each node in the node list */
|
static void clear_check_flags(struct hda_gspec *spec)
|
/* clear checked flag of each node in the node list */
static void clear_check_flags(struct hda_gspec *spec)
|
{
struct hda_gnode *node;
list_for_each_entry(node, &spec->nid_list, list) {
node->checked = 0;
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* splits Tag Header coresponding to 20.2.1 General Rules For BACnet Tags */
|
static guint fTagHeader(tvbuff_t *tvb, packet_info *pinfo, guint offset, guint8 *tag_no, guint8 *class_tag, guint32 *lvt)
|
/* splits Tag Header coresponding to 20.2.1 General Rules For BACnet Tags */
static guint fTagHeader(tvbuff_t *tvb, packet_info *pinfo, guint offset, guint8 *tag_no, guint8 *class_tag, guint32 *lvt)
|
{
return fTagHeaderTree(tvb, pinfo, NULL, offset, tag_no, tag_info, lvt);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* If HmacSha256Context is NULL, then return FALSE. If NewHmacSha256Context is NULL, then return FALSE. */
|
BOOLEAN EFIAPI HmacSha256Duplicate(IN CONST VOID *HmacSha256Context, OUT VOID *NewHmacSha256Context)
|
/* If HmacSha256Context is NULL, then return FALSE. If NewHmacSha256Context is NULL, then return FALSE. */
BOOLEAN EFIAPI HmacSha256Duplicate(IN CONST VOID *HmacSha256Context, OUT VOID *NewHmacSha256Context)
|
{
return HmacMdDuplicate (HmacSha256Context, NewHmacSha256Context);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Gets the direction and mode of a pin. */
|
unsigned long GPIODirModeGet(unsigned long ulPort, unsigned char ucPin)
|
/* Gets the direction and mode of a pin. */
unsigned long GPIODirModeGet(unsigned long ulPort, unsigned char ucPin)
|
{
unsigned long ulDir;
ASSERT(GPIOBaseValid(ulPort));
ulDir = HWREG(ulPort + GPIO_O_GPIO_DIR);
return(((ulDir & ucPin) ? 1 : 0));
}
|
micropython/micropython
|
C++
|
Other
| 18,334
|
/* Converts a text device path node to firmware file device path structure. */
|
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextFvFile(IN CHAR16 *TextDeviceNode)
|
/* Converts a text device path node to firmware file device path structure. */
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextFvFile(IN CHAR16 *TextDeviceNode)
|
{
CHAR16 *GuidStr;
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFile;
GuidStr = GetNextParamStr (&TextDeviceNode);
FvFile = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)CreateDeviceNode (
MEDIA_DEVICE_PATH,
MEDIA_PIWG_FW_FILE_DP,
(UINT16)sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH)
);
StrToGuid (GuidStr, &FvFile->FvFileName);
return (EFI_DEVICE_PATH_PROTOCOL *)FvFile;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* AirPDcapGetBssidAddress() and AirPDcapGetBssidAddress() are used for key caching. In each case, it's more important to return a value than to return a */
|
static const UCHAR * AirPDcapGetStaAddress(const AIRPDCAP_MAC_FRAME_ADDR4 *frame)
|
/* AirPDcapGetBssidAddress() and AirPDcapGetBssidAddress() are used for key caching. In each case, it's more important to return a value than to return a */
static const UCHAR * AirPDcapGetStaAddress(const AIRPDCAP_MAC_FRAME_ADDR4 *frame)
|
{
switch(AIRPDCAP_DS_BITS(frame->fc[1])) {
case 0:
if (memcmp(frame->addr2, frame->addr3, AIRPDCAP_MAC_LEN) == 0)
return frame->addr1;
else
return frame->addr2;
case 1:
return frame->addr2;
case 2:
return frame->addr1;
case 3:
if (memcmp(frame->addr1, frame->addr2, AIRPDCAP_MAC_LEN) < 0)
return frame->addr1;
else
return frame->addr2;
default:
return NULL;
}
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Note : we can't use iw_enum_devices() because we want a different behaviour : 1) Stop at the first valid wireless device 2) Only go through active devices */
|
static int scan_devices(int skfd, int format, int wtype)
|
/* Note : we can't use iw_enum_devices() because we want a different behaviour : 1) Stop at the first valid wireless device 2) Only go through active devices */
static int scan_devices(int skfd, int format, int wtype)
|
{
char buff[1024];
struct ifconf ifc;
struct ifreq *ifr;
int i;
ifc.ifc_len = sizeof(buff);
ifc.ifc_buf = buff;
if(ioctl(skfd, SIOCGIFCONF, &ifc) < 0)
{
perror("SIOCGIFCONF");
return(-1);
}
ifr = ifc.ifc_req;
for(i = ifc.ifc_len / sizeof(struct ifreq); --i >= 0; ifr++)
{
if(print_one_device(skfd, format, wtype, ifr->ifr_name) >= 0)
return 0;
}
return(-1);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Calculates the size of an MC7 memory in bytes from the value of its configuration register. */
|
static unsigned int mc7_calc_size(u32 cfg)
|
/* Calculates the size of an MC7 memory in bytes from the value of its configuration register. */
static unsigned int mc7_calc_size(u32 cfg)
|
{
unsigned int width = G_WIDTH(cfg);
unsigned int banks = !!(cfg & F_BKS) + 1;
unsigned int org = !!(cfg & F_ORG) + 1;
unsigned int density = G_DEN(cfg);
unsigned int MBs = ((256 << density) * banks) / (org << width);
return MBs << 20;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Removes and deletes the top of the stack, if present. The next element becomes the new top. */
|
void zconfpop_buffer_state(void)
|
/* Removes and deletes the top of the stack, if present. The next element becomes the new top. */
void zconfpop_buffer_state(void)
|
{
if (!YY_CURRENT_BUFFER)
return;
zconf_delete_buffer(YY_CURRENT_BUFFER );
YY_CURRENT_BUFFER_LVALUE = NULL;
if ((yy_buffer_stack_top) > 0)
--(yy_buffer_stack_top);
if (YY_CURRENT_BUFFER) {
zconf_load_buffer_state( );
(yy_did_buffer_switch_on_eof) = 1;
}
}
|
Nicholas3388/LuaNode
|
C++
|
Other
| 1,055
|
/* Search the list array to find an IP6 prefix list entry. */
|
IP6_PREFIX_LIST_ENTRY* Ip6FindPrefixListEntry(IN IP6_SERVICE *IpSb, IN BOOLEAN OnLinkOrAuto, IN UINT8 PrefixLength, IN EFI_IPv6_ADDRESS *Prefix)
|
/* Search the list array to find an IP6 prefix list entry. */
IP6_PREFIX_LIST_ENTRY* Ip6FindPrefixListEntry(IN IP6_SERVICE *IpSb, IN BOOLEAN OnLinkOrAuto, IN UINT8 PrefixLength, IN EFI_IPv6_ADDRESS *Prefix)
|
{
IP6_PREFIX_LIST_ENTRY *PrefixList;
LIST_ENTRY *Entry;
LIST_ENTRY *ListHead;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
ASSERT (Prefix != NULL);
if (OnLinkOrAuto) {
ListHead = &IpSb->OnlinkPrefix;
} else {
ListHead = &IpSb->AutonomousPrefix;
}
NET_LIST_FOR_EACH (Entry, ListHead) {
PrefixList = NET_LIST_USER_STRUCT (Entry, IP6_PREFIX_LIST_ENTRY, Link);
if (PrefixLength != 255) {
if ((PrefixList->PrefixLength == PrefixLength) &&
NetIp6IsNetEqual (&PrefixList->Prefix, Prefix, PrefixLength))
{
return PrefixList;
}
} else {
if (NetIp6IsNetEqual (&PrefixList->Prefix, Prefix, PrefixList->PrefixLength)) {
return PrefixList;
}
}
}
return NULL;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Whether the TCG or TCG2 protocols are installed in the UEFI protocol database. This information is used by the MorLock code to infer whether an existing MOR variable is legitimate or not. */
|
BOOLEAN VariableHaveTcgProtocols(VOID)
|
/* Whether the TCG or TCG2 protocols are installed in the UEFI protocol database. This information is used by the MorLock code to infer whether an existing MOR variable is legitimate or not. */
BOOLEAN VariableHaveTcgProtocols(VOID)
|
{
EFI_STATUS Status;
VOID *Interface;
Status = gBS->LocateProtocol (
&gEfiTcg2ProtocolGuid,
NULL,
&Interface
);
if (!EFI_ERROR (Status)) {
return TRUE;
}
Status = gBS->LocateProtocol (
&gEfiTcgProtocolGuid,
NULL,
&Interface
);
return !EFI_ERROR (Status);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* s3c_hsotg_ep0_mps - turn max packet size into register setting @mps: The maximum packet size in bytes. */
|
static u32 s3c_hsotg_ep0_mps(unsigned int mps)
|
/* s3c_hsotg_ep0_mps - turn max packet size into register setting @mps: The maximum packet size in bytes. */
static u32 s3c_hsotg_ep0_mps(unsigned int mps)
|
{
switch (mps) {
case 64:
return D0EPCTL_MPS_64;
case 32:
return D0EPCTL_MPS_32;
case 16:
return D0EPCTL_MPS_16;
case 8:
return D0EPCTL_MPS_8;
}
WARN_ON(1);
return (u32)-1;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). If the register specified by Address >= 0x100, then ASSERT(). */
|
UINT16 EFIAPI PciCf8Or16(IN UINTN Address, IN UINT16 OrData)
|
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). If the register specified by Address >= 0x100, then ASSERT(). */
UINT16 EFIAPI PciCf8Or16(IN UINTN Address, IN UINT16 OrData)
|
{
BOOLEAN InterruptState;
UINT32 AddressPort;
UINT16 Result;
ASSERT_INVALID_PCI_ADDRESS (Address, 1);
InterruptState = SaveAndDisableInterrupts ();
AddressPort = IoRead32 (PCI_CONFIGURATION_ADDRESS_PORT);
IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));
Result = IoOr16 (
PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2),
OrData
);
IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, AddressPort);
SetInterruptState (InterruptState);
return Result;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Get the recorded NIC info from global structure by the Index. */
|
ISCSI_NIC_INFO* IScsiGetNicInfoByIndex(IN UINT8 NicIndex)
|
/* Get the recorded NIC info from global structure by the Index. */
ISCSI_NIC_INFO* IScsiGetNicInfoByIndex(IN UINT8 NicIndex)
|
{
LIST_ENTRY *Entry;
ISCSI_NIC_INFO *NicInfo;
NET_LIST_FOR_EACH (Entry, &mPrivate->NicInfoList) {
NicInfo = NET_LIST_USER_STRUCT (Entry, ISCSI_NIC_INFO, Link);
if (NicInfo->NicIndex == NicIndex) {
return NicInfo;
}
}
return NULL;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Enables or disables the specified DAC channel DMA request. */
|
void DAC_DMACmd(uint32_t DAC_Channel, FunctionalState NewState)
|
/* Enables or disables the specified DAC channel DMA request. */
void DAC_DMACmd(uint32_t DAC_Channel, FunctionalState NewState)
|
{
assert_param(IS_DAC_CHANNEL(DAC_Channel));
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
DAC->CR |= (DAC_CR_DMAEN1 << DAC_Channel);
}
else
{
DAC->CR &= ~(DAC_CR_DMAEN1 << DAC_Channel);
}
}
|
gcallipo/RadioDSP-Stm32f103
|
C++
|
Common Creative - Attribution 3.0
| 51
|
/* set the key for the volume index entry */
|
static uint16_t afs_volume_cache_get_key(const void *cookie_netfs_data, void *buffer, uint16_t buflen)
|
/* set the key for the volume index entry */
static uint16_t afs_volume_cache_get_key(const void *cookie_netfs_data, void *buffer, uint16_t buflen)
|
{
const struct afs_volume *volume = cookie_netfs_data;
uint16_t klen;
_enter("{%u},%p,%u", volume->type, buffer, bufmax);
klen = sizeof(volume->type);
if (klen > bufmax)
return 0;
memcpy(buffer, &volume->type, sizeof(volume->type));
_leave(" = %u", klen);
return klen;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* The ConnectDevicePath() function allows the caller to connect a DevicePath using the same policy as the EFI Boot Manger. */
|
EFI_STATUS EFIAPI BootManagerPolicyConnectDevicePath(IN EFI_BOOT_MANAGER_POLICY_PROTOCOL *This, IN EFI_DEVICE_PATH *DevicePath, IN BOOLEAN Recursive)
|
/* The ConnectDevicePath() function allows the caller to connect a DevicePath using the same policy as the EFI Boot Manger. */
EFI_STATUS EFIAPI BootManagerPolicyConnectDevicePath(IN EFI_BOOT_MANAGER_POLICY_PROTOCOL *This, IN EFI_DEVICE_PATH *DevicePath, IN BOOLEAN Recursive)
|
{
EFI_STATUS Status;
EFI_HANDLE Controller;
if (EfiGetCurrentTpl () != TPL_APPLICATION) {
return EFI_UNSUPPORTED;
}
if (DevicePath == NULL) {
EfiBootManagerConnectAll ();
return EFI_SUCCESS;
}
if (Recursive) {
Status = EfiBootManagerConnectDevicePath (DevicePath, NULL);
} else {
Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &DevicePath, &Controller);
if (!EFI_ERROR (Status)) {
Status = gBS->ConnectController (Controller, NULL, DevicePath, FALSE);
}
}
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Adds the RegNumber-th register's value to the output buffer, starting at the given OutBufPtr */
|
CHAR8* BasicReadRegister(IN EFI_SYSTEM_CONTEXT SystemContext, IN UINTN RegNumber, IN CHAR8 *OutBufPtr)
|
/* Adds the RegNumber-th register's value to the output buffer, starting at the given OutBufPtr */
CHAR8* BasicReadRegister(IN EFI_SYSTEM_CONTEXT SystemContext, IN UINTN RegNumber, IN CHAR8 *OutBufPtr)
|
{
UINTN RegSize;
CHAR8 Char;
if (gRegisterOffsets[RegNumber] > 0xF00) {
AsciiSPrint (OutBufPtr, 9, "00000000");
OutBufPtr += 8;
return OutBufPtr;
}
RegSize = 0;
while (RegSize < 32) {
Char = mHexToStr[(UINT8)((*FindPointerToRegister (SystemContext, RegNumber) >> (RegSize+4)) & 0xf)];
if ((Char >= 'A') && (Char <= 'F')) {
Char = Char - 'A' + 'a';
}
*OutBufPtr++ = Char;
Char = mHexToStr[(UINT8)((*FindPointerToRegister (SystemContext, RegNumber) >> RegSize) & 0xf)];
if ((Char >= 'A') && (Char <= 'F')) {
Char = Char - 'A' + 'a';
}
*OutBufPtr++ = Char;
RegSize = RegSize + 8;
}
return OutBufPtr;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Register the Service B.1 and all its Characteristics... */
|
void service_b_1_1_init(void)
|
/* Register the Service B.1 and all its Characteristics... */
void service_b_1_1_init(void)
|
{
bt_gatt_service_register(&service_b_1_1_svc);
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* If 8-bit I/O port operations are not supported, then ASSERT(). If StartBit is greater than 7, then ASSERT(). If EndBit is greater than 7, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
|
UINT8 EFIAPI IoBitFieldAndThenOr8(IN UINTN Port, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 AndData, IN UINT8 OrData)
|
/* If 8-bit I/O port operations are not supported, then ASSERT(). If StartBit is greater than 7, then ASSERT(). If EndBit is greater than 7, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT8 EFIAPI IoBitFieldAndThenOr8(IN UINTN Port, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 AndData, IN UINT8 OrData)
|
{
return IoWrite8 (
Port,
BitFieldAndThenOr8 (IoRead8 (Port), StartBit, EndBit, AndData, OrData)
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This file is part of the Simba project. */
|
int mock_write_usb_host_class_hid_init(struct usb_host_driver_t *usb_p, struct usb_host_class_hid_device_t *devices_p, size_t length, int res)
|
/* This file is part of the Simba project. */
int mock_write_usb_host_class_hid_init(struct usb_host_driver_t *usb_p, struct usb_host_class_hid_device_t *devices_p, size_t length, int res)
|
{
harness_mock_write("usb_host_class_hid_init(usb_p)",
usb_p,
sizeof(*usb_p));
harness_mock_write("usb_host_class_hid_init(devices_p)",
devices_p,
sizeof(*devices_p));
harness_mock_write("usb_host_class_hid_init(length)",
&length,
sizeof(length));
harness_mock_write("usb_host_class_hid_init(): return (res)",
&res,
sizeof(res));
return (0);
}
|
eerimoq/simba
|
C++
|
Other
| 337
|
/* This function clears memory encryption bit for the mmio region specified by BaseAddress and NumPages. */
|
RETURN_STATUS EFIAPI MemEncryptSevClearMmioPageEncMask(IN PHYSICAL_ADDRESS Cr3BaseAddress, IN PHYSICAL_ADDRESS BaseAddress, IN UINTN NumPages)
|
/* This function clears memory encryption bit for the mmio region specified by BaseAddress and NumPages. */
RETURN_STATUS EFIAPI MemEncryptSevClearMmioPageEncMask(IN PHYSICAL_ADDRESS Cr3BaseAddress, IN PHYSICAL_ADDRESS BaseAddress, IN UINTN NumPages)
|
{
return InternalMemEncryptSevClearMmioPageEncMask (
Cr3BaseAddress,
BaseAddress,
EFI_PAGES_TO_SIZE (NumPages)
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* retrieve the contents of FRV userspace FP/Media registers */
|
static int fpmregs_get(struct task_struct *target, const struct user_regset *regset, unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf)
|
/* retrieve the contents of FRV userspace FP/Media registers */
static int fpmregs_get(struct task_struct *target, const struct user_regset *regset, unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf)
|
{
const struct user_fpmedia_regs *fpregs = &target->thread.user->f;
int ret;
ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
fpregs, 0, sizeof(*fpregs));
if (ret < 0)
return ret;
return user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf,
sizeof(*fpregs), -1);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Selects the clock source to output on MCO pin. */
|
void RCC_MCOConfig(RCC_MCO_TypeDef mco_src)
|
/* Selects the clock source to output on MCO pin. */
void RCC_MCOConfig(RCC_MCO_TypeDef mco_src)
|
{
MODIFY_REG(RCC->CFGR, RCC_CFGR_MCO, mco_src);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* tipc_nodesub_unsubscribe - cancel "node down" subscription (if any) */
|
void tipc_nodesub_unsubscribe(struct tipc_node_subscr *node_sub)
|
/* tipc_nodesub_unsubscribe - cancel "node down" subscription (if any) */
void tipc_nodesub_unsubscribe(struct tipc_node_subscr *node_sub)
|
{
if (!node_sub->node)
return;
tipc_node_lock(node_sub->node);
list_del_init(&node_sub->nodesub_list);
tipc_node_unlock(node_sub->node);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Enables the selected SDADC software start conversion of the injected channels. */
|
void SDADC_SoftwareStartInjectedConv(SDADC_TypeDef *SDADCx)
|
/* Enables the selected SDADC software start conversion of the injected channels. */
void SDADC_SoftwareStartInjectedConv(SDADC_TypeDef *SDADCx)
|
{
assert_param(IS_SDADC_ALL_PERIPH(SDADCx));
SDADCx->CR2 |= (uint32_t)SDADC_CR2_JSWSTART;
}
|
avem-labs/Avem
|
C++
|
MIT License
| 1,752
|
/* CustomHID_OutEvent Manage the CUSTOM HID class Out Event */
|
static int8_t CustomHID_OutEvent(uint8_t event_idx, uint8_t state)
|
/* CustomHID_OutEvent Manage the CUSTOM HID class Out Event */
static int8_t CustomHID_OutEvent(uint8_t event_idx, uint8_t state)
|
{
switch (event_idx)
{
case 1:
(state == 1) ? BSP_LED_On(LED1) : BSP_LED_Off(LED1);
break;
case 2:
(state == 1) ? BSP_LED_On(LED2) : BSP_LED_Off(LED2);
break;
case 3:
(state == 1) ? BSP_LED_On(LED3) : BSP_LED_Off(LED3);
break;
case 4:
(state == 1) ? BSP_LED_On(LED4) : BSP_LED_Off(LED4);
break;
default:
BSP_LED_Off(LED1);
BSP_LED_Off(LED2);
BSP_LED_Off(LED3);
BSP_LED_Off(LED4);
break;
}
USBD_CUSTOM_HID_ReceivePacket(&USBD_Device);
return (0);
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* The callback argument specifies a function that returns a whitespace string or NULL before and after each element. If MXML_NO_CALLBACK is specified, whitespace will only be added before MXML_TEXT nodes with leading whitespace and before attribute names inside opening element tags. */
|
int mxmlSaveString(mxml_node_t *node, char *buffer, int bufsize, mxml_save_cb_t cb)
|
/* The callback argument specifies a function that returns a whitespace string or NULL before and after each element. If MXML_NO_CALLBACK is specified, whitespace will only be added before MXML_TEXT nodes with leading whitespace and before attribute names inside opening element tags. */
int mxmlSaveString(mxml_node_t *node, char *buffer, int bufsize, mxml_save_cb_t cb)
|
{
int col;
char *ptr[2];
_mxml_global_t *global = _mxml_global();
ptr[0] = buffer;
ptr[1] = buffer + bufsize;
if ((col = mxml_write_node(node, ptr, cb, 0, mxml_string_putc, global)) < 0)
return (-1);
if (col > 0)
mxml_string_putc('\n', ptr);
if (ptr[0] >= ptr[1])
buffer[bufsize - 1] = '\0';
else
ptr[0][0] = '\0';
return (ptr[0] - buffer);
}
|
DC-SWAT/DreamShell
|
C++
| null | 404
|
/* This function is used for getting the count of block I/O devices that one specific block driver detects. To the PEI ATAPI driver, it returns the number of all the detected ATAPI devices it detects during the enumeration process. To the PEI legacy floppy driver, it returns the number of all the legacy devices it finds during its enumeration process. If no device is detected, then the function will return zero. */
|
EFI_STATUS EFIAPI BotGetNumberOfBlockDevices2(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This, OUT UINTN *NumberBlockDevices)
|
/* This function is used for getting the count of block I/O devices that one specific block driver detects. To the PEI ATAPI driver, it returns the number of all the detected ATAPI devices it detects during the enumeration process. To the PEI legacy floppy driver, it returns the number of all the legacy devices it finds during its enumeration process. If no device is detected, then the function will return zero. */
EFI_STATUS EFIAPI BotGetNumberOfBlockDevices2(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This, OUT UINTN *NumberBlockDevices)
|
{
*NumberBlockDevices = 1;
return EFI_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This routine prepares the mailbox command for issuing a heart beat in the form of mailbox command to the HBA. The timely completion of the heart beat mailbox command indicates the health of the HBA. */
|
void lpfc_heart_beat(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
|
/* This routine prepares the mailbox command for issuing a heart beat in the form of mailbox command to the HBA. The timely completion of the heart beat mailbox command indicates the health of the HBA. */
void lpfc_heart_beat(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
|
{
MAILBOX_t *mb;
mb = &pmb->u.mb;
memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
mb->mbxCommand = MBX_HEARTBEAT;
mb->mbxOwner = OWN_HOST;
return;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Check the status of the FIFO buffer of the specified SPI port. */
|
unsigned long SPIFIFOStatusGet(unsigned long ulBase, unsigned long ulRxTx)
|
/* Check the status of the FIFO buffer of the specified SPI port. */
unsigned long SPIFIFOStatusGet(unsigned long ulBase, unsigned long ulRxTx)
|
{
unsigned long ulDataNum;
xASSERT(ulBase == SPI0_BASE);
xASSERT((ulRxTx == SPI_FSR_RX) || (ulRxTx == SPI_FSR_TX));
if(ulRxTx == SPI_FSR_RX)
{
ulDataNum = (xHWREG(ulBase + SPI_FSR) & SPI_FSR_RXFS_M) >> SPI_FSR_RXFS_S;
}
else
{
ulDataNum = (xHWREG(ulBase + SPI_FSR) & SPI_FSR_TXFS_M) >> SPI_FSR_TXFS_S;
}
return ulDataNum;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* find a timer instance from the given timer id */
|
static struct snd_timer* snd_timer_find(struct snd_timer_id *tid)
|
/* find a timer instance from the given timer id */
static struct snd_timer* snd_timer_find(struct snd_timer_id *tid)
|
{
struct snd_timer *timer = NULL;
list_for_each_entry(timer, &snd_timer_list, device_list) {
if (timer->tmr_class != tid->dev_class)
continue;
if ((timer->tmr_class == SNDRV_TIMER_CLASS_CARD ||
timer->tmr_class == SNDRV_TIMER_CLASS_PCM) &&
(timer->card == NULL ||
timer->card->number != tid->card))
continue;
if (timer->tmr_device != tid->device)
continue;
if (timer->tmr_subdevice != tid->subdevice)
continue;
return timer;
}
return NULL;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Make sure the single step bit is not set. */
|
void ptrace_disable(struct task_struct *child)
|
/* Make sure the single step bit is not set. */
void ptrace_disable(struct task_struct *child)
|
{
ptrace_cancel_bpt(child);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Get maximum message size in a Memory Pool. */
|
uint32_t osMessageQueueGetMsgSize(osMessageQueueId_t mq_id)
|
/* Get maximum message size in a Memory Pool. */
uint32_t osMessageQueueGetMsgSize(osMessageQueueId_t mq_id)
|
{
msg_size = svcRtxMessageQueueGetMsgSize(mq_id);
} else {
msg_size = __svcMessageQueueGetMsgSize(mq_id);
}
return msg_size;
}
|
ARMmbed/DAPLink
|
C++
|
Apache License 2.0
| 2,140
|
/* vmalloc=size forces the vmalloc area to be exactly 'size' bytes. This can be used to increase (or decrease) the vmalloc area - the default is 128m. */
|
static void __init early_vmalloc(char **arg)
|
/* vmalloc=size forces the vmalloc area to be exactly 'size' bytes. This can be used to increase (or decrease) the vmalloc area - the default is 128m. */
static void __init early_vmalloc(char **arg)
|
{
vmalloc_reserve = memparse(*arg, arg);
if (vmalloc_reserve < SZ_16M) {
vmalloc_reserve = SZ_16M;
printk(KERN_WARNING
"vmalloc area too small, limiting to %luMB\n",
vmalloc_reserve >> 20);
}
if (vmalloc_reserve > VMALLOC_END - (PAGE_OFFSET + SZ_32M)) {
vmalloc_reserve = VMALLOC_END - (PAGE_OFFSET + SZ_32M);
printk(KERN_WARNING
"vmalloc area is too big, limiting to %luMB\n",
vmalloc_reserve >> 20);
}
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* remove_from_lpt_heap - remove LEB properties from a LEB category heap. */
|
static void remove_from_lpt_heap(struct ubifs_info *c, struct ubifs_lprops *lprops, int cat)
|
/* remove_from_lpt_heap - remove LEB properties from a LEB category heap. */
static void remove_from_lpt_heap(struct ubifs_info *c, struct ubifs_lprops *lprops, int cat)
|
{
struct ubifs_lpt_heap *heap;
int hpos = lprops->hpos;
heap = &c->lpt_heap[cat - 1];
ubifs_assert(hpos >= 0 && hpos < heap->cnt);
ubifs_assert(heap->arr[hpos] == lprops);
heap->cnt -= 1;
if (hpos < heap->cnt) {
heap->arr[hpos] = heap->arr[heap->cnt];
heap->arr[hpos]->hpos = hpos;
adjust_lpt_heap(c, heap, heap->arr[hpos], hpos, cat);
}
dbg_check_heap(c, heap, cat, -1);
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* Converts a text device path node to USB Image device path structure. */
|
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextUsbImage(IN CHAR16 *TextDeviceNode)
|
/* Converts a text device path node to USB Image device path structure. */
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextUsbImage(IN CHAR16 *TextDeviceNode)
|
{
USB_CLASS_TEXT UsbClassText;
UsbClassText.ClassExist = FALSE;
UsbClassText.Class = USB_CLASS_IMAGE;
UsbClassText.SubClassExist = TRUE;
return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* It is vital that we remove the page mapping if we have mapped a tiled object through the GTT and then lose the fence register due to resource pressure. Similarly if the object has been moved out of the aperture, than pages mapped into userspace must be revoked. Removing the mapping will then trigger a page fault on the next user access, allowing fixup by i915_gem_fault(). */
|
void i915_gem_release_mmap(struct drm_gem_object *obj)
|
/* It is vital that we remove the page mapping if we have mapped a tiled object through the GTT and then lose the fence register due to resource pressure. Similarly if the object has been moved out of the aperture, than pages mapped into userspace must be revoked. Removing the mapping will then trigger a page fault on the next user access, allowing fixup by i915_gem_fault(). */
void i915_gem_release_mmap(struct drm_gem_object *obj)
|
{
struct drm_device *dev = obj->dev;
struct drm_i915_gem_object *obj_priv = obj->driver_private;
if (dev->dev_mapping)
unmap_mapping_range(dev->dev_mapping,
obj_priv->mmap_offset, obj->size, 1);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Initialize USART Interface. 1. Initializes the resources needed for the USART interface 2.registers event callback function. */
|
usart_handle_t csi_usart_initialize(pin_t tx, pin_t rx, usart_event_cb_t cb_event, void *cb_arg)
|
/* Initialize USART Interface. 1. Initializes the resources needed for the USART interface 2.registers event callback function. */
usart_handle_t csi_usart_initialize(pin_t tx, pin_t rx, usart_event_cb_t cb_event, void *cb_arg)
|
{
uint32_t base = 0u;
uint32_t irq = 0u;
int32_t idx = target_usart_init(tx, rx, &base, &irq);
if (idx < 0 || idx >= CONFIG_USART_NUM) {
return NULL;
}
dw_usart_priv_t *usart_priv = &usart_instance[idx];
usart_priv->base = base;
usart_priv->irq = irq;
usart_priv->cb_event = cb_event;
usart_priv->cb_arg = cb_arg;
dw_usart_reg_t *addr = (dw_usart_reg_t *)(usart_priv->base);
addr->FCR = DW_FCR_FIFOE;
drv_nvic_enable_irq(usart_priv->irq);
return usart_priv;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* This function will removes a previously registed usb class driver. */
|
rt_err_t rt_usb_class_driver_unregister(ucd_t drv)
|
/* This function will removes a previously registed usb class driver. */
rt_err_t rt_usb_class_driver_unregister(ucd_t drv)
|
{
RT_ASSERT(drv != RT_NULL);
rt_list_remove(&(drv->list));
return RT_EOK;
}
|
armink/FreeModbus_Slave-Master-RTT-STM32
|
C++
|
Other
| 1,477
|
/* Free the route table entry. It is reference counted. */
|
VOID Ip6FreeRouteEntry(IN OUT IP6_ROUTE_ENTRY *RtEntry)
|
/* Free the route table entry. It is reference counted. */
VOID Ip6FreeRouteEntry(IN OUT IP6_ROUTE_ENTRY *RtEntry)
|
{
ASSERT ((RtEntry != NULL) && (RtEntry->RefCnt > 0));
if (--RtEntry->RefCnt == 0) {
FreePool (RtEntry);
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* create a stream for an interface with proper descriptors */
|
static int create_standard_audio_quirk(struct snd_usb_audio *chip, struct usb_interface *iface, const struct snd_usb_audio_quirk *quirk)
|
/* create a stream for an interface with proper descriptors */
static int create_standard_audio_quirk(struct snd_usb_audio *chip, struct usb_interface *iface, const struct snd_usb_audio_quirk *quirk)
|
{
struct usb_host_interface *alts;
struct usb_interface_descriptor *altsd;
int err;
alts = &iface->altsetting[0];
altsd = get_iface_desc(alts);
err = parse_audio_endpoints(chip, altsd->bInterfaceNumber);
if (err < 0) {
snd_printk(KERN_ERR "cannot setup if %d: error %d\n",
altsd->bInterfaceNumber, err);
return err;
}
usb_set_interface(chip->dev, altsd->bInterfaceNumber, 0);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* write 32 bit values, not 64 bit; for memories that only support 32 bit write; usually a single dword. */
|
static int ipath_write_umem32(struct ipath_devdata *dd, void __iomem *caddr, const void __user *uaddr, size_t count)
|
/* write 32 bit values, not 64 bit; for memories that only support 32 bit write; usually a single dword. */
static int ipath_write_umem32(struct ipath_devdata *dd, void __iomem *caddr, const void __user *uaddr, size_t count)
|
{
u32 __iomem *reg_addr = caddr;
const u32 __iomem *reg_end = reg_addr + (count / sizeof(u32));
int ret;
if (reg_addr < (u32 __iomem *) dd->ipath_kregbase ||
reg_end > (u32 __iomem *) dd->ipath_kregend) {
ret = -EINVAL;
goto bail;
}
while (reg_addr < reg_end) {
u32 data;
if (copy_from_user(&data, uaddr, sizeof(data))) {
ret = -EFAULT;
goto bail;
}
writel(data, reg_addr);
reg_addr++;
uaddr += sizeof(u32);
}
ret = 0;
bail:
return ret;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Convert text to the binary representation of a device path. */
|
EFI_DEVICE_PATH_PROTOCOL* ConvertTextToDevicePath(CONST CHAR16 *TextDevicePath)
|
/* Convert text to the binary representation of a device path. */
EFI_DEVICE_PATH_PROTOCOL* ConvertTextToDevicePath(CONST CHAR16 *TextDevicePath)
|
{
return UefiDevicePathLibConvertTextToDevicePath (TextDevicePath);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* s2io_ethtool_gdrvinfo - Returns driver specific information. @sp : private member of the device structure, which is a pointer to the s2io_nic structure. @info : pointer to the structure with parameters given by ethtool to return driver information. Description: Returns driver specefic information like name, version etc.. to ethtool. Return value: void */
|
static void s2io_ethtool_gdrvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
|
/* s2io_ethtool_gdrvinfo - Returns driver specific information. @sp : private member of the device structure, which is a pointer to the s2io_nic structure. @info : pointer to the structure with parameters given by ethtool to return driver information. Description: Returns driver specefic information like name, version etc.. to ethtool. Return value: void */
static void s2io_ethtool_gdrvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
|
{
struct s2io_nic *sp = netdev_priv(dev);
strncpy(info->driver, s2io_driver_name, sizeof(info->driver));
strncpy(info->version, s2io_driver_version, sizeof(info->version));
strncpy(info->fw_version, "", sizeof(info->fw_version));
strncpy(info->bus_info, pci_name(sp->pdev), sizeof(info->bus_info));
info->regdump_len = XENA_REG_SPACE;
info->eedump_len = XENA_EEPROM_SPACE;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* @be: Beacon event information @bf: Beacon frame (part of b, really) @ts_jiffies: Timestamp (in jiffies) when the beacon was received */
|
static struct uwb_beca_e* __uwb_beca_add(struct uwb_rc *rc, struct uwb_rc_evt_beacon *be, struct uwb_beacon_frame *bf, unsigned long ts_jiffies)
|
/* @be: Beacon event information @bf: Beacon frame (part of b, really) @ts_jiffies: Timestamp (in jiffies) when the beacon was received */
static struct uwb_beca_e* __uwb_beca_add(struct uwb_rc *rc, struct uwb_rc_evt_beacon *be, struct uwb_beacon_frame *bf, unsigned long ts_jiffies)
|
{
struct uwb_beca_e *bce;
bce = kzalloc(sizeof(*bce), GFP_KERNEL);
if (bce == NULL)
return NULL;
uwb_beca_e_init(bce);
bce->ts_jiffies = ts_jiffies;
bce->uwb_dev = NULL;
list_add(&bce->node, &rc->uwb_beca.list);
return bce;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Update the requested action field of the dialog. This routine is called by GTK when either of the two radio buttons in the dialog is clicked. */
|
static void decode_update_action(GtkWidget *w _U_, gpointer user_data)
|
/* Update the requested action field of the dialog. This routine is called by GTK when either of the two radio buttons in the dialog is clicked. */
static void decode_update_action(GtkWidget *w _U_, gpointer user_data)
|
{
GSList *tmp;
gboolean enable;
requested_action = (enum action_type)GPOINTER_TO_INT(user_data);
enable = (requested_action == E_DECODE_YES);
for (tmp = decode_dimmable; tmp; tmp = g_slist_next(tmp)) {
gtk_widget_set_sensitive((GtkWidget *)tmp->data, enable);
}
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Message: HookFlashMessage Opcode: 0x0008 Type: CallControl Direction: dev2pbx VarLength: no */
|
static void handle_HookFlashMessage(ptvcursor_t *cursor, packet_info *pinfo _U_)
|
/* Message: HookFlashMessage Opcode: 0x0008 Type: CallControl Direction: dev2pbx VarLength: no */
static void handle_HookFlashMessage(ptvcursor_t *cursor, packet_info *pinfo _U_)
|
{
si->lineId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_lineInstance, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.