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
|
|---|---|---|---|---|---|---|---|
/* If StartAddress > 0x0FFFFFFF, then ASSERT(). If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). If Size > 0 and Buffer is NULL, then ASSERT(). */
|
UINTN EFIAPI PciReadBuffer(IN UINTN StartAddress, IN UINTN Size, OUT VOID *Buffer)
|
/* If StartAddress > 0x0FFFFFFF, then ASSERT(). If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). If Size > 0 and Buffer is NULL, then ASSERT(). */
UINTN EFIAPI PciReadBuffer(IN UINTN StartAddress, IN UINTN Size, OUT VOID *Buffer)
|
{
return mRunningOnQ35 ?
PciExpressReadBuffer (StartAddress, Size, Buffer) :
PciCf8ReadBuffer (StartAddress, Size, Buffer);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Description: Searches the settings array for the setting which matches the desired speed and duplex, and returns the index of that setting. Returns the index of the last setting if none of the others match. */
|
static int phy_find_setting(int speed, int duplex)
|
/* Description: Searches the settings array for the setting which matches the desired speed and duplex, and returns the index of that setting. Returns the index of the last setting if none of the others match. */
static int phy_find_setting(int speed, int duplex)
|
{
int idx = 0;
while (idx < ARRAY_SIZE(settings) &&
(settings[idx].speed != speed ||
settings[idx].duplex != duplex))
idx++;
return idx < MAX_NUM_SETTINGS ? idx : MAX_NUM_SETTINGS - 1;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Translate a generic cache event_id config to a raw event_id code. */
|
static int hw_perf_cache_event(u64 config, u64 *eventp)
|
/* Translate a generic cache event_id config to a raw event_id code. */
static int hw_perf_cache_event(u64 config, u64 *eventp)
|
{
unsigned long type, op, result;
int ev;
if (!ppmu->cache_events)
return -EINVAL;
type = config & 0xff;
op = (config >> 8) & 0xff;
result = (config >> 16) & 0xff;
if (type >= PERF_COUNT_HW_CACHE_MAX ||
op >= PERF_COUNT_HW_CACHE_OP_MAX ||
result >= PERF_COUNT_HW_CACHE_RESULT_MAX)
return -EINVAL;
ev = (*ppmu->cache_events)[type][op][result];
if (ev == 0)
return -EOPNOTSUPP;
if (ev == -1)
return -EINVAL;
*eventp = ev;
return 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Get dipswitch status The DIP switches are free for user programmable purposes. */
|
uint16_t DVK_getDipSwitch(void)
|
/* Get dipswitch status The DIP switches are free for user programmable purposes. */
uint16_t DVK_getDipSwitch(void)
|
{
uint16_t tmp;
tmp = (~(DVK_readRegister(BC_DIPSWITCH))) & 0x00ff;
return tmp;
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* Read sensor data.
This routine calls the appropriate internal data function to obtain the specified type of data from the sensor device. */
|
static bool bma250_read(sensor_t *sensor, sensor_read_t type, sensor_data_t *data)
|
/* Read sensor data.
This routine calls the appropriate internal data function to obtain the specified type of data from the sensor device. */
static bool bma250_read(sensor_t *sensor, sensor_read_t type, sensor_data_t *data)
|
{
sensor_hal_t *const hal = sensor->hal;
switch (type) {
case SENSOR_READ_ACCELERATION:
return bma250_get_accel(hal, data);
case SENSOR_READ_TEMPERATURE:
return bma250_get_temperature(hal, data);
case SENSOR_READ_ID:
return bma250_device_id(hal, data);
default:
sensor->err = SENSOR_ERR_FUNCTION;
return false;
}
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* These are passed a tvb that contains ] */
|
static void dissect_r3_cmd_handshake(tvbuff_t *tvb, guint32 start_offset, guint32 length _U_, packet_info *pinfo _U_, proto_tree *tree)
|
/* These are passed a tvb that contains ] */
static void dissect_r3_cmd_handshake(tvbuff_t *tvb, guint32 start_offset, guint32 length _U_, packet_info *pinfo _U_, proto_tree *tree)
|
{
if (tree)
{
proto_tree_add_item (tree, hf_r3_commandlength, tvb, start_offset + 0, 1, ENC_LITTLE_ENDIAN);
proto_tree_add_item (tree, hf_r3_command, tvb, start_offset + 1, 1, ENC_LITTLE_ENDIAN);
}
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Called very early, MMU is off, device-tree isn't unflattened */
|
static int __init mpc5121_generic_probe(void)
|
/* Called very early, MMU is off, device-tree isn't unflattened */
static int __init mpc5121_generic_probe(void)
|
{
unsigned long node = of_get_flat_dt_root();
int i = 0;
while (board[i]) {
if (of_flat_dt_is_compatible(node, board[i]))
break;
i++;
}
return board[i] != NULL;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Invoked in response to search_service when the GATT service search has been completed. */
|
void btgattc_search_complete_callback(int conn_id, int status)
|
/* Invoked in response to search_service when the GATT service search has been completed. */
void btgattc_search_complete_callback(int conn_id, int status)
|
{
int index = -1;
TLS_BT_APPL_TRACE_VERBOSE("%s, conn_id=%d\r\n", __FUNCTION__, conn_id);
index = get_app_env_index_by_conn_id(conn_id);
if(index<0)
{
TLS_BT_APPL_TRACE_ERROR("%s, status=%d, conn_id=%d\r\n", __FUNCTION__, status, conn_id);
return;
}
TLS_HAL_CBACK(app_env[index].ps_callbak, search_complete_cb, conn_id, status);
}
|
Nicholas3388/LuaNode
|
C++
|
Other
| 1,055
|
/* TIM MSP Initialization This function configures the hardware resources used in this example: */
|
void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef *htim)
|
/* TIM MSP Initialization This function configures the hardware resources used in this example: */
void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef *htim)
|
{
GPIO_InitTypeDef GPIO_InitStruct;
TIMx_CLK_ENABLE();
TIMx_CHANNEL_GPIO_PORT();
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Alternate = TIMx_GPIO_AF_CHANNEL1;
GPIO_InitStruct.Pin = TIMx_GPIO_PIN_CHANNEL1;
HAL_GPIO_Init(TIMx_GPIO_PORT_CHANNEL1, &GPIO_InitStruct);
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* Internally initializes data structures used later during library execution. */
|
EFI_STATUS EFIAPI PrmModuleDiscoveryLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
|
/* Internally initializes data structures used later during library execution. */
EFI_STATUS EFIAPI PrmModuleDiscoveryLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
|
{
InitializeListHead (&mPrmModuleList);
return EFI_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Returns the most recent received data by the USIx peripheral. */
|
u8 USI_I2C_ReceiveData(USI_TypeDef *USIx)
|
/* Returns the most recent received data by the USIx peripheral. */
u8 USI_I2C_ReceiveData(USI_TypeDef *USIx)
|
{
assert_param(IS_USI_I2C_ALL_PERIPH(USIx));
return (u8)USIx->RX_FIFO_READ;
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* Fills each TIM_BDTRInitStruct member with its default value. */
|
void TIM_BDTRStructInit(TIM_BDTRInitTypeDef *TIM_BDTRInitStruct)
|
/* Fills each TIM_BDTRInitStruct member with its default value. */
void TIM_BDTRStructInit(TIM_BDTRInitTypeDef *TIM_BDTRInitStruct)
|
{
TIM_BDTRInitStruct->TIM_OSSRState = TIM_OSSRState_Disable;
TIM_BDTRInitStruct->TIM_OSSIState = TIM_OSSIState_Disable;
TIM_BDTRInitStruct->TIM_LOCKLevel = TIM_LOCKLevel_OFF;
TIM_BDTRInitStruct->TIM_DeadTime = 0x00;
TIM_BDTRInitStruct->TIM_Break = TIM_Break_Disable;
TIM_BDTRInitStruct->TIM_BreakPolarity = TIM_BreakPolarity_Low;
TIM_BDTRInitStruct->TIM_AutomaticOutput = TIM_AutomaticOutput_Disable;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* function: nsfiletime_to_nstime converts a Windows FILETIME-like value, but given in nanoseconds rather than 10ths of microseconds, to an nstime_t returns TRUE if the conversion succeeds, FALSE if it doesn't (for example, with a 32-bit time_t, the time overflows or underflows time_t) */
|
gboolean nsfiletime_to_nstime(nstime_t *nstime, guint64 nsfiletime)
|
/* function: nsfiletime_to_nstime converts a Windows FILETIME-like value, but given in nanoseconds rather than 10ths of microseconds, to an nstime_t returns TRUE if the conversion succeeds, FALSE if it doesn't (for example, with a 32-bit time_t, the time overflows or underflows time_t) */
gboolean nsfiletime_to_nstime(nstime_t *nstime, guint64 nsfiletime)
|
{
guint64 ftsecs;
int nsecs;
ftsecs = nsfiletime / NS_PER_S;
nsecs = (int)(nsfiletime % NS_PER_S);
return common_filetime_to_nstime(nstime, ftsecs, nsecs);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* If interrupt is delivered through GPIO, IRQ are triggered on falling and rising edge of signal. Whereas IDE device request interrupt on high level (rising edge in our case). This mean we have fake interrupts, so we need to check interrupt pin and exit instantly from ISR when line is on low level. */
|
irqreturn_t at91_irq_handler(int irq, void *dev_id)
|
/* If interrupt is delivered through GPIO, IRQ are triggered on falling and rising edge of signal. Whereas IDE device request interrupt on high level (rising edge in our case). This mean we have fake interrupts, so we need to check interrupt pin and exit instantly from ISR when line is on low level. */
irqreturn_t at91_irq_handler(int irq, void *dev_id)
|
{
int ntries = 8;
int pin_val1, pin_val2;
do {
pin_val1 = at91_get_gpio_value(irq);
pin_val2 = at91_get_gpio_value(irq);
} while (pin_val1 != pin_val2 && --ntries > 0);
if (pin_val1 == 0 || ntries <= 0)
return IRQ_HANDLED;
return ide_intr(irq, dev_id);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). */
|
UINT32 EFIAPI PciExpressRead32(IN UINTN Address)
|
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). */
UINT32 EFIAPI PciExpressRead32(IN UINTN Address)
|
{
if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {
return (UINT32)-1;
}
return MmioRead32 (GetPciExpressAddress (Address));
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This API configure the interrupt PIN setting for no motion/slow motion interrupt. */
|
static int8_t config_no_motion_int_settg(const struct bmi160_int_settg *int_config, const struct bmi160_acc_no_motion_int_cfg *no_mot_int_cfg, const struct bmi160_dev *dev)
|
/* This API configure the interrupt PIN setting for no motion/slow motion interrupt. */
static int8_t config_no_motion_int_settg(const struct bmi160_int_settg *int_config, const struct bmi160_acc_no_motion_int_cfg *no_mot_int_cfg, const struct bmi160_dev *dev)
|
{
int8_t rslt;
rslt = set_intr_pin_config(int_config, dev);
if (rslt == BMI160_OK)
{
rslt = map_feature_interrupt(int_config, dev);
if (rslt == BMI160_OK)
{
rslt = config_no_motion_data_src(no_mot_int_cfg, dev);
if (rslt == BMI160_OK)
{
rslt = config_no_motion_dur_thr(no_mot_int_cfg, dev);
}
}
}
return rslt;
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* This is called by input_tstc() and input_getc() when they need more characters */
|
static int tegra_kbc_check(struct input_config *input)
|
/* This is called by input_tstc() and input_getc() when they need more characters */
static int tegra_kbc_check(struct input_config *input)
|
{
struct tegra_kbd_priv *priv = dev_get_priv(input->dev);
kbd_wait_for_fifo_init(priv);
check_for_keys(priv);
return 1;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* fc_fcp_timer_set() - Start a timer for a fcp_pkt @fsp: The FCP packet to start a timer for @delay: The timeout period for the timer */
|
static void fc_fcp_timer_set(struct fc_fcp_pkt *fsp, unsigned long delay)
|
/* fc_fcp_timer_set() - Start a timer for a fcp_pkt @fsp: The FCP packet to start a timer for @delay: The timeout period for the timer */
static void fc_fcp_timer_set(struct fc_fcp_pkt *fsp, unsigned long delay)
|
{
if (!(fsp->state & FC_SRB_COMPL))
mod_timer(&fsp->timer, jiffies + delay);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function should be called after finishing the process of mIpSec->ProcessExt() for outbound traffic. The (EFI_IPSEC2_PROTOCOL)->ProcessExt() allocates a new buffer for the ESP, so there needs a function to free the old net buffer. */
|
VOID NetIpSecNetbufFree(NET_BUF *Nbuf)
|
/* This function should be called after finishing the process of mIpSec->ProcessExt() for outbound traffic. The (EFI_IPSEC2_PROTOCOL)->ProcessExt() allocates a new buffer for the ESP, so there needs a function to free the old net buffer. */
VOID NetIpSecNetbufFree(NET_BUF *Nbuf)
|
{
NET_CHECK_SIGNATURE (Nbuf, NET_BUF_SIGNATURE);
ASSERT (Nbuf->RefCnt > 0);
Nbuf->RefCnt--;
if (Nbuf->RefCnt == 0) {
NET_CHECK_SIGNATURE (Nbuf->Vector, NET_VECTOR_SIGNATURE);
ASSERT (Nbuf->Vector->RefCnt > 0);
Nbuf->Vector->RefCnt--;
if (Nbuf->Vector->RefCnt > 0) {
return;
}
if ((Nbuf->Vector->Flag & NET_VECTOR_OWN_FIRST) != 0) {
FreePool (Nbuf->Vector->Block[0].Bulk);
}
FreePool (Nbuf->Vector);
FreePool (Nbuf);
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* 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 AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
|
UINT32 EFIAPI PciExpressBitFieldAnd32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 AndData)
|
/* 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 AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT32 EFIAPI PciExpressBitFieldAnd32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 AndData)
|
{
ASSERT_INVALID_PCI_ADDRESS (Address);
return MmioBitFieldAnd32 (
(UINTN)GetPciExpressBaseAddress () + Address,
StartBit,
EndBit,
AndData
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* param base eDMA peripheral base address. param channel eDMA channel number param config A pointer to the channel preemption configuration structure. */
|
void EDMA_SetChannelPreemptionConfig(DMA_Type *base, uint32_t channel, const edma_channel_Preemption_config_t *config)
|
/* param base eDMA peripheral base address. param channel eDMA channel number param config A pointer to the channel preemption configuration structure. */
void EDMA_SetChannelPreemptionConfig(DMA_Type *base, uint32_t channel, const edma_channel_Preemption_config_t *config)
|
{
assert(channel < (uint32_t)FSL_FEATURE_EDMA_MODULE_CHANNEL);
assert(config != NULL);
bool tmpEnablePreemptAbility = config->enablePreemptAbility;
bool tmpEnableChannelPreemption = config->enableChannelPreemption;
uint8_t tmpChannelPriority = config->channelPriority;
volatile uint8_t *tmpReg = &base->DCHPRI3;
tmpReg[DMA_DCHPRI_INDEX(channel)] =
(DMA_DCHPRI0_DPA((true == tmpEnablePreemptAbility ? 0U : 1U)) |
DMA_DCHPRI0_ECP((true == tmpEnableChannelPreemption ? 1U : 0U)) | DMA_DCHPRI0_CHPRI(tmpChannelPriority));
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Set the specified Signal Flags of an active thread. */
|
int32_t osSignalSet(osThreadId thread_id, int32_t signals)
|
/* Set the specified Signal Flags of an active thread. */
int32_t osSignalSet(osThreadId thread_id, int32_t signals)
|
{
int sig, key;
if ((thread_id == NULL) || (!signals) ||
(signals & 0x80000000) || (signals > MAX_VALID_SIGNAL_VAL)) {
return 0x80000000;
}
osThreadDef_t *thread_def =
(osThreadDef_t *)k_thread_other_custom_data_get(
(struct k_thread *)thread_id);
key = irq_lock();
sig = thread_def->signal_results;
thread_def->signal_results |= signals;
irq_unlock(key);
k_poll_signal_raise(thread_def->poll_signal, signals);
return sig;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Instead, if it is readable, run Curl_connalive() to peek at the socket and distinguish between closed and data. */
|
static bool rtsp_connisdead(struct connectdata *check)
|
/* Instead, if it is readable, run Curl_connalive() to peek at the socket and distinguish between closed and data. */
static bool rtsp_connisdead(struct connectdata *check)
|
{
int sval;
bool ret_val = TRUE;
sval = SOCKET_READABLE(check->sock[FIRSTSOCKET], 0);
if(sval == 0) {
ret_val = FALSE;
}
else if(sval & CURL_CSELECT_ERR) {
ret_val = TRUE;
}
else if(sval & CURL_CSELECT_IN) {
ret_val = !Curl_connalive(check);
}
return ret_val;
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* Returns 0 on success, < 0 indicates an internal error. */
|
static int add_aeb(struct ubi_attach_info *ai, struct list_head *list, int pnum, int ec, int scrub)
|
/* Returns 0 on success, < 0 indicates an internal error. */
static int add_aeb(struct ubi_attach_info *ai, struct list_head *list, int pnum, int ec, int scrub)
|
{
struct ubi_ainf_peb *aeb;
aeb = kmem_cache_alloc(ai->aeb_slab_cache, GFP_KERNEL);
if (!aeb)
return -ENOMEM;
aeb->pnum = pnum;
aeb->ec = ec;
aeb->lnum = -1;
aeb->scrub = scrub;
aeb->copy_flag = aeb->sqnum = 0;
ai->ec_sum += aeb->ec;
ai->ec_count++;
if (ai->max_ec < aeb->ec)
ai->max_ec = aeb->ec;
if (ai->min_ec > aeb->ec)
ai->min_ec = aeb->ec;
list_add_tail(&aeb->u.list, list);
return 0;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Note that the destination address is modified during the DMA transfer according to edma_set_dest_index(). */
|
void edma_set_dest(unsigned slot, rt_uint32_t dest_port, enum address_mode mode, enum fifo_width width)
|
/* Note that the destination address is modified during the DMA transfer according to edma_set_dest_index(). */
void edma_set_dest(unsigned slot, rt_uint32_t dest_port, enum address_mode mode, enum fifo_width width)
|
{
unsigned ctlr;
ctlr = EDMA_CTLR(slot);
slot = EDMA_CHAN_SLOT(slot);
if (slot < edma_cc[ctlr]->num_slots) {
unsigned int i = edma_parm_read(ctlr, PARM_OPT, slot);
if (mode) {
i = (i & ~(EDMA_FWID)) | (DAM | ((width & 0x7) << 8));
} else {
i &= ~DAM;
}
edma_parm_write(ctlr, PARM_OPT, slot, i);
edma_parm_write(ctlr, PARM_DST, slot, dest_port);
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Calculates and writes the checksum into the buffer. */
|
static void SharedParamsWriteChecksum(void)
|
/* Calculates and writes the checksum into the buffer. */
static void SharedParamsWriteChecksum(void)
|
{
sharedParamsBuffer.checksum = SharedParamsCalculateChecksum();
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* Frees an output endpoint. May be called when ep hasn't been initialized completely. */
|
static void snd_usbmidi_out_endpoint_delete(struct snd_usb_midi_out_endpoint *ep)
|
/* Frees an output endpoint. May be called when ep hasn't been initialized completely. */
static void snd_usbmidi_out_endpoint_delete(struct snd_usb_midi_out_endpoint *ep)
|
{
unsigned int i;
for (i = 0; i < OUTPUT_URBS; ++i)
if (ep->urbs[i].urb)
free_urb_and_buffer(ep->umidi, ep->urbs[i].urb,
ep->max_transfer);
kfree(ep);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function returns the delegation without reclaiming opens or protecting against delegation reclaims. It is therefore really only safe to be called from nfs4_clear_inode() */
|
void nfs_inode_return_delegation_noreclaim(struct inode *inode)
|
/* This function returns the delegation without reclaiming opens or protecting against delegation reclaims. It is therefore really only safe to be called from nfs4_clear_inode() */
void nfs_inode_return_delegation_noreclaim(struct inode *inode)
|
{
struct nfs_client *clp = NFS_SERVER(inode)->nfs_client;
struct nfs_inode *nfsi = NFS_I(inode);
struct nfs_delegation *delegation;
if (rcu_dereference(nfsi->delegation) != NULL) {
spin_lock(&clp->cl_lock);
delegation = nfs_detach_delegation_locked(nfsi, NULL);
spin_unlock(&clp->cl_lock);
if (delegation != NULL)
nfs_do_return_delegation(inode, delegation, 0);
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* The function is called from SLI ring event handler with no lock held. This function is the completion handler for ELS commands which are aborted. The function frees memory resources used for the aborted ELS commands. */
|
static void lpfc_ignore_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, struct lpfc_iocbq *rspiocb)
|
/* The function is called from SLI ring event handler with no lock held. This function is the completion handler for ELS commands which are aborted. The function frees memory resources used for the aborted ELS commands. */
static void lpfc_ignore_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, struct lpfc_iocbq *rspiocb)
|
{
IOCB_t *irsp = &rspiocb->iocb;
lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
"0139 Ignoring ELS cmd tag x%x completion Data: "
"x%x x%x x%x\n",
irsp->ulpIoTag, irsp->ulpStatus,
irsp->un.ulpWord[4], irsp->ulpTimeout);
if (cmdiocb->iocb.ulpCommand == CMD_GEN_REQUEST64_CR)
lpfc_ct_free_iocb(phba, cmdiocb);
else
lpfc_els_free_iocb(phba, cmdiocb);
return;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Further optimization could be realized by adding an ability to cache the directory in memory. The goal being a single comprehensive file read to put the file I need in a memory. typedef struct unz_file_pos_s { ZPOS64_T pos_in_zip_directory; // offset in file ZPOS64_T num_of_file; // # of file } unz_file_pos; */
|
int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos *file_pos)
|
/* Further optimization could be realized by adding an ability to cache the directory in memory. The goal being a single comprehensive file read to put the file I need in a memory. typedef struct unz_file_pos_s { ZPOS64_T pos_in_zip_directory; // offset in file ZPOS64_T num_of_file; // # of file } unz_file_pos; */
int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos *file_pos)
|
{
unz64_s* s;
if (file==NULL || file_pos==NULL)
return UNZ_PARAMERROR;
s=(unz64_s*)file;
if (!s->current_file_ok)
return UNZ_END_OF_LIST_OF_FILE;
file_pos->pos_in_zip_directory = s->pos_in_central_dir;
file_pos->num_of_file = s->num_file;
return UNZ_OK;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Free the DMA resources allocated by an ATA AHCI controller. */
|
VOID AhciFreeDmaResource(IN PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private)
|
/* Free the DMA resources allocated by an ATA AHCI controller. */
VOID AhciFreeDmaResource(IN PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private)
|
{
EFI_AHCI_REGISTERS *AhciRegisters;
ASSERT (Private != NULL);
AhciRegisters = &Private->AhciRegisters;
if (AhciRegisters->AhciRFisMap != NULL) {
IoMmuFreeBuffer (
EFI_SIZE_TO_PAGES (AhciRegisters->MaxRFisSize),
AhciRegisters->AhciRFis,
AhciRegisters->AhciRFisMap
);
}
if (AhciRegisters->AhciCmdListMap != NULL) {
IoMmuFreeBuffer (
EFI_SIZE_TO_PAGES (AhciRegisters->MaxCmdListSize),
AhciRegisters->AhciCmdList,
AhciRegisters->AhciCmdListMap
);
}
if (AhciRegisters->AhciCmdTableMap != NULL) {
IoMmuFreeBuffer (
EFI_SIZE_TO_PAGES (AhciRegisters->MaxCmdTableSize),
AhciRegisters->AhciCmdTable,
AhciRegisters->AhciCmdTableMap
);
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Configures the data size for the selected SPI. */
|
void SPI_DataSizeConfig(SPI_TypeDef *SPIx, uint16_t SPI_DataSize)
|
/* Configures the data size for the selected SPI. */
void SPI_DataSizeConfig(SPI_TypeDef *SPIx, uint16_t SPI_DataSize)
|
{
assert_param(IS_SPI_ALL_PERIPH(SPIx));
assert_param(IS_SPI_DATASIZE(SPI_DataSize));
SPIx->CR1 &= (uint16_t)~SPI_DataSize_16b;
SPIx->CR1 |= SPI_DataSize;
}
|
gcallipo/RadioDSP-Stm32f103
|
C++
|
Common Creative - Attribution 3.0
| 51
|
/* UBIFS has so-called "reserved pool" which is flash space reserved for the superuser and for uses whose UID/GID is recorded in UBIFS superblock. This function checks whether current user is allowed to use reserved pool. Returns %1 current user is allowed to use reserved pool and %0 otherwise. */
|
static int can_use_rp(struct ubifs_info *c)
|
/* UBIFS has so-called "reserved pool" which is flash space reserved for the superuser and for uses whose UID/GID is recorded in UBIFS superblock. This function checks whether current user is allowed to use reserved pool. Returns %1 current user is allowed to use reserved pool and %0 otherwise. */
static int can_use_rp(struct ubifs_info *c)
|
{
if (current_fsuid() == c->rp_uid || capable(CAP_SYS_RESOURCE) ||
(c->rp_gid != 0 && in_group_p(c->rp_gid)))
return 1;
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function will clear the handler to be called when the flash interrupt occurs. This will also mask off the interrupt in the interrupt controller so that the interrupt handler is no longer called. */
|
void FlashIntUnregister(void)
|
/* This function will clear the handler to be called when the flash interrupt occurs. This will also mask off the interrupt in the interrupt controller so that the interrupt handler is no longer called. */
void FlashIntUnregister(void)
|
{
IntDisable(INT_FLASH);
IntUnregister(INT_FLASH);
}
|
watterott/WebRadio
|
C++
| null | 71
|
/* Figures out if we are running inside Xen HVM. */
|
BOOLEAN XenDetect(VOID)
|
/* Figures out if we are running inside Xen HVM. */
BOOLEAN XenDetect(VOID)
|
{
UINT8 Signature[13];
if (mXenLeaf != 0) {
return TRUE;
}
Signature[12] = '\0';
for (mXenLeaf = 0x40000000; mXenLeaf < 0x40010000; mXenLeaf += 0x100) {
AsmCpuid (
mXenLeaf,
NULL,
(UINT32 *)&Signature[0],
(UINT32 *)&Signature[4],
(UINT32 *)&Signature[8]
);
if (!AsciiStrCmp ((CHAR8 *)Signature, "XenVMMXenVMM")) {
return TRUE;
}
}
mXenLeaf = 0;
return FALSE;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Returns success (0) or appropriate error code (none as of now) */
|
static void emac_setmac(struct emac_priv *priv, u32 ch, char *mac_addr)
|
/* Returns success (0) or appropriate error code (none as of now) */
static void emac_setmac(struct emac_priv *priv, u32 ch, char *mac_addr)
|
{
struct device *emac_dev = &priv->ndev->dev;
if (priv->rx_addr_type == 0) {
emac_set_type0addr(priv, ch, mac_addr);
} else if (priv->rx_addr_type == 1) {
u32 cnt;
for (cnt = 0; cnt < EMAC_MAX_TXRX_CHANNELS; cnt++)
emac_set_type1addr(priv, ch, mac_addr);
} else if (priv->rx_addr_type == 2) {
emac_set_type2addr(priv, ch, mac_addr, ch, 1);
emac_set_type0addr(priv, ch, mac_addr);
} else {
if (netif_msg_drv(priv))
dev_err(emac_dev, "DaVinci EMAC: Wrong addressing\n");
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function looks for the highest region of memory lower than 4GB which has enough space for U-Boot where U-Boot is aligned on a page boundary. It overrides the default implementation found elsewhere which simply picks the end of ram, wherever that may be. The location of the stack, the relocation address, and how far U-Boot is moved by relocation are set in the global data structure. */
|
ulong board_get_usable_ram_top(ulong total_size)
|
/* This function looks for the highest region of memory lower than 4GB which has enough space for U-Boot where U-Boot is aligned on a page boundary. It overrides the default implementation found elsewhere which simply picks the end of ram, wherever that may be. The location of the stack, the relocation address, and how far U-Boot is moved by relocation are set in the global data structure. */
ulong board_get_usable_ram_top(ulong total_size)
|
{
return fsp_get_usable_lowmem_top(gd->arch.hob_list);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Interrupt on "pin change" from switch to do wakeup on USB Callback running when USB Host enable mouse interface.
Note: This interrupt is enable when the USB host enable remotewakeup feature This interrupt wakeup the CPU if this one is in idle mode */
|
ISR(PORTE_INT0_vect)
|
/* Interrupt on "pin change" from switch to do wakeup on USB Callback running when USB Host enable mouse interface.
Note: This interrupt is enable when the USB host enable remotewakeup feature This interrupt wakeup the CPU if this one is in idle mode */
ISR(PORTE_INT0_vect)
|
{
PORT_t *port;
port = ioport_pin_to_port(GPIO_PUSH_BUTTON_0);
port->INTFLAGS = 0x01;
udc_remotewakeup();
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* If 32-bit MMIO register operations are not supported, 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 AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
|
UINT32 EFIAPI MmioBitFieldAnd32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 AndData)
|
/* If 32-bit MMIO register operations are not supported, 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 AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT32 EFIAPI MmioBitFieldAnd32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 AndData)
|
{
return MmioWrite32 (
Address,
BitFieldAnd32 (MmioRead32 (Address), StartBit, EndBit, AndData)
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Read a whole GPIO Port.
Gets all 32 GPIOs of a Port. */
|
uint32_t gpio_port_read(uint32_t gpioport)
|
/* Read a whole GPIO Port.
Gets all 32 GPIOs of a Port. */
uint32_t gpio_port_read(uint32_t gpioport)
|
{
return GPIO_PDIR(gpioport);
}
|
insane-adding-machines/unicore-mx
|
C++
|
GNU General Public License v3.0
| 50
|
/* dispose of the data dangling from the corpse of a user key */
|
void user_destroy(struct key *key)
|
/* dispose of the data dangling from the corpse of a user key */
void user_destroy(struct key *key)
|
{
struct user_key_payload *upayload = key->payload.data;
kfree(upayload);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Select one of EXTI inputs to the RTC TimeStamp event. */
|
void EXTI_RTCTimeStampSel(uint32_t EXTI_TSSEL_Line)
|
/* Select one of EXTI inputs to the RTC TimeStamp event. */
void EXTI_RTCTimeStampSel(uint32_t EXTI_TSSEL_Line)
|
{
assert_param(IS_EXTI_TSSEL_LINE(EXTI_TSSEL_Line));
EXTI->TSSEL &= EXTI_TSSEL_TSSEL_ALL;
EXTI->TSSEL |= EXTI_TSSEL_Line;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* This return the handle number for the calling processor. This service may be called from the BSP and APs. */
|
EFI_STATUS EFIAPI MpInitLibWhoAmI(OUT UINTN *ProcessorNumber)
|
/* This return the handle number for the calling processor. This service may be called from the BSP and APs. */
EFI_STATUS EFIAPI MpInitLibWhoAmI(OUT UINTN *ProcessorNumber)
|
{
if (ProcessorNumber == NULL) {
return EFI_INVALID_PARAMETER;
}
*ProcessorNumber = 0;
return EFI_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Read then Measure and log an EFI boot variable, and extend the measurement result into PCR. according to TCG PC Client PFP spec 0021 Section 2.4.4.2 */
|
EFI_STATUS ReadAndMeasureBootVariable(IN CHAR16 *VarName, IN EFI_GUID *VendorGuid, OUT UINTN *VarSize, OUT VOID **VarData)
|
/* Read then Measure and log an EFI boot variable, and extend the measurement result into PCR. according to TCG PC Client PFP spec 0021 Section 2.4.4.2 */
EFI_STATUS ReadAndMeasureBootVariable(IN CHAR16 *VarName, IN EFI_GUID *VendorGuid, OUT UINTN *VarSize, OUT VOID **VarData)
|
{
return ReadAndMeasureVariable (
1,
EV_EFI_VARIABLE_BOOT,
VarName,
VendorGuid,
VarSize,
VarData
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* returns: 0 on success Negative error code on failure */
|
static int overlay_update_local_references(void *fdto, uint32_t delta)
|
/* returns: 0 on success Negative error code on failure */
static int overlay_update_local_references(void *fdto, uint32_t delta)
|
{
int fixups;
fixups = fdt_path_offset(fdto, "/__local_fixups__");
if (fixups < 0) {
if (fixups == -FDT_ERR_NOTFOUND)
return 0;
return fixups;
}
return overlay_update_local_node_references(fdto, 0, fixups,
delta);
}
|
xboot/xboot
|
C++
|
MIT License
| 779
|
/* Determines if the schedule item overlaps the currently running schedule item. We only care about connection schedule items */
|
static int ble_ll_sched_overlaps_current(struct ble_ll_sched_item *sch)
|
/* Determines if the schedule item overlaps the currently running schedule item. We only care about connection schedule items */
static int ble_ll_sched_overlaps_current(struct ble_ll_sched_item *sch)
|
{
int rc;
uint32_t ce_end_time;
rc = 0;
if (ble_ll_state_get() == BLE_LL_STATE_CONNECTION) {
ce_end_time = ble_ll_conn_get_ce_end_time();
if (CPUTIME_GT(ce_end_time, sch->start_time)) {
rc = 1;
}
}
return rc;
}
|
arendst/Tasmota
|
C++
|
GNU General Public License v3.0
| 21,318
|
/* This function is the handler for Delayed Recovery event triggered by timer. After a device error occurs, the event would be triggered with interval of EFI_USB_INTERRUPT_DELAY. EFI_USB_INTERRUPT_DELAY is defined in USB standard for error handling. */
|
VOID EFIAPI USBKeyboardRecoveryHandler(IN EFI_EVENT Event, IN VOID *Context)
|
/* This function is the handler for Delayed Recovery event triggered by timer. After a device error occurs, the event would be triggered with interval of EFI_USB_INTERRUPT_DELAY. EFI_USB_INTERRUPT_DELAY is defined in USB standard for error handling. */
VOID EFIAPI USBKeyboardRecoveryHandler(IN EFI_EVENT Event, IN VOID *Context)
|
{
USB_KB_DEV *UsbKeyboardDevice;
EFI_USB_IO_PROTOCOL *UsbIo;
UINT8 PacketSize;
UsbKeyboardDevice = (USB_KB_DEV *)Context;
UsbIo = UsbKeyboardDevice->UsbIo;
PacketSize = (UINT8)(UsbKeyboardDevice->IntEndpointDescriptor.MaxPacketSize);
UsbIo->UsbAsyncInterruptTransfer (
UsbIo,
UsbKeyboardDevice->IntEndpointDescriptor.EndpointAddress,
TRUE,
UsbKeyboardDevice->IntEndpointDescriptor.Interval,
PacketSize,
KeyboardHandler,
UsbKeyboardDevice
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Allocate memory from the appropriate pools and return a pointer to it. NULL is returned if the allocation fails */
|
void* ipc_alloc(int size)
|
/* Allocate memory from the appropriate pools and return a pointer to it. NULL is returned if the allocation fails */
void* ipc_alloc(int size)
|
{
void* out;
if(size > PAGE_SIZE)
out = vmalloc(size);
else
out = kmalloc(size, GFP_KERNEL);
return out;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Write a local tag containing an ascii string as utf-16 */
|
static void mxf_write_local_tag_utf16(ByteIOContext *pb, int tag, const char *value)
|
/* Write a local tag containing an ascii string as utf-16 */
static void mxf_write_local_tag_utf16(ByteIOContext *pb, int tag, const char *value)
|
{
int i, size = strlen(value);
mxf_write_local_tag(pb, size*2, tag);
for (i = 0; i < size; i++)
put_be16(pb, value[i]);
}
|
DC-SWAT/DreamShell
|
C++
| null | 404
|
/* Function called from USART IRQ Handler when RXNE flag is set Function is in charge of reading character received on USART RX line. */
|
void USART_CharReception_Callback(void)
|
/* Function called from USART IRQ Handler when RXNE flag is set Function is in charge of reading character received on USART RX line. */
void USART_CharReception_Callback(void)
|
{
aUSART1RxBuffer[ubReceive++] = LL_USART_ReceiveData8(USART1);
if (ubReceive == ubUSART1NbDataToReceive)
{
ubUSART1ReceptionComplete = 1;
}
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* Called when allocating swap cache for existing swap entry, This can return error codes. Returns 0 at success. -EBUSY means there is a swap cache. Note: return code is different from swap_duplicate(). */
|
int swapcache_prepare(swp_entry_t entry)
|
/* Called when allocating swap cache for existing swap entry, This can return error codes. Returns 0 at success. -EBUSY means there is a swap cache. Note: return code is different from swap_duplicate(). */
int swapcache_prepare(swp_entry_t entry)
|
{
return __swap_duplicate(entry, SWAP_HAS_CACHE);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Set FeaturesVerified in published HSTI table. This API will update the HSTI table with indicated Role and ImplementationID, NULL ImplementationID means to find the first HSTI table with indicated Role. */
|
EFI_STATUS EFIAPI HstiLibSetFeaturesVerified(IN UINT32 Role, IN CHAR16 *ImplementationID OPTIONAL, IN UINT32 ByteIndex, IN UINT8 BitMask)
|
/* Set FeaturesVerified in published HSTI table. This API will update the HSTI table with indicated Role and ImplementationID, NULL ImplementationID means to find the first HSTI table with indicated Role. */
EFI_STATUS EFIAPI HstiLibSetFeaturesVerified(IN UINT32 Role, IN CHAR16 *ImplementationID OPTIONAL, IN UINT32 ByteIndex, IN UINT8 BitMask)
|
{
return InternalHstiRecordFeaturesVerified (
Role,
ImplementationID,
ByteIndex,
BitMask,
TRUE
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This applied after the check for the synthetic attributes in the system namespace. */
|
static bool btrfs_is_valid_xattr(const char *name)
|
/* This applied after the check for the synthetic attributes in the system namespace. */
static bool btrfs_is_valid_xattr(const char *name)
|
{
return !strncmp(name, XATTR_SECURITY_PREFIX,
XATTR_SECURITY_PREFIX_LEN) ||
!strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN) ||
!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN) ||
!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Disable I2C master module of the specified I2C port.
The */
|
void xI2CMasterDisable(unsigned long ulBase)
|
/* Disable I2C master module of the specified I2C port.
The */
void xI2CMasterDisable(unsigned long ulBase)
|
{
xASSERT((ulBase == I2C0_BASE) || (ulBase == I2C1_BASE) ||
(ulBase == I2C2_BASE) || (ulBase == I2C3_BASE) ||
(ulBase == I2C4_BASE));
xHWREG(ulBase + I2C_CON) &= ~I2C_CON_ENS1;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: */
|
static void draw_background(SDL_Renderer *renderer, int w, int h)
|
/* Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: */
static void draw_background(SDL_Renderer *renderer, int w, int h)
|
{
SDL_Color col[2] = {
{ 0x66, 0x66, 0x66, 0xff },
{ 0x99, 0x99, 0x99, 0xff },
};
int i, x, y;
SDL_Rect rect;
rect.w = 8;
rect.h = 8;
for (y = 0; y < h; y += rect.h) {
for (x = 0; x < w; x += rect.w) {
i = (((x ^ y) >> 3) & 1);
SDL_SetRenderDrawColor(renderer, col[i].r, col[i].g, col[i].b, col[i].a);
rect.x = x;
rect.y = y;
SDL_RenderFillRect(renderer, &rect);
}
}
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* Bits are shifted out in MSB to LSB order. */
|
static void e1000_shift_out_mdi_bits(struct e1000_hw *hw, u32 data, u16 count)
|
/* Bits are shifted out in MSB to LSB order. */
static void e1000_shift_out_mdi_bits(struct e1000_hw *hw, u32 data, u16 count)
|
{
u32 ctrl;
u32 mask;
mask = 0x01;
mask <<= (count - 1);
ctrl = er32(CTRL);
ctrl |= (E1000_CTRL_MDIO_DIR | E1000_CTRL_MDC_DIR);
while (mask) {
if (data & mask)
ctrl |= E1000_CTRL_MDIO;
else
ctrl &= ~E1000_CTRL_MDIO;
ew32(CTRL, ctrl);
E1000_WRITE_FLUSH();
udelay(10);
e1000_raise_mdi_clk(hw, &ctrl);
e1000_lower_mdi_clk(hw, &ctrl);
mask = mask >> 1;
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Retrieves the size, in bytes, of the context buffer required for SHA-1 hash operations. */
|
UINTN EFIAPI Sha1GetContextSize(VOID)
|
/* Retrieves the size, in bytes, of the context buffer required for SHA-1 hash operations. */
UINTN EFIAPI Sha1GetContextSize(VOID)
|
{
return (UINTN)(sizeof (mbedtls_sha1_context));
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* If a device is not yet associated with a domain, this function does assigns it visible for the hardware */
|
static int attach_device(struct device *dev, struct protection_domain *domain)
|
/* If a device is not yet associated with a domain, this function does assigns it visible for the hardware */
static int attach_device(struct device *dev, struct protection_domain *domain)
|
{
unsigned long flags;
int ret;
write_lock_irqsave(&amd_iommu_devtable_lock, flags);
ret = __attach_device(dev, domain);
write_unlock_irqrestore(&amd_iommu_devtable_lock, flags);
iommu_flush_tlb_pde(domain);
return ret;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* @uc_start: uncached starting address of a chunk of uncached memory @uc_end: uncached ending address of a chunk of uncached memory */
|
static int __init uncached_build_memmap(u64 uc_start, u64 uc_end, void *arg)
|
/* @uc_start: uncached starting address of a chunk of uncached memory @uc_end: uncached ending address of a chunk of uncached memory */
static int __init uncached_build_memmap(u64 uc_start, u64 uc_end, void *arg)
|
{
int nid = paddr_to_nid(uc_start - __IA64_UNCACHED_OFFSET);
struct gen_pool *pool = uncached_pools[nid].pool;
size_t size = uc_end - uc_start;
touch_softlockup_watchdog();
if (pool != NULL) {
memset((char *)uc_start, 0, size);
(void) gen_pool_add(pool, uc_start, size, nid);
}
return 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* param base FlexCAN peripheral base address. param handle FlexCAN handle pointer. param count Number of CAN messages receive so far by the non-blocking transaction. retval kStatus_InvalidArgument count is Invalid. retval kStatus_Success Successfully return the count. */
|
status_t FLEXCAN_TransferGetReceiveFifoCount(CAN_Type *base, flexcan_handle_t *handle, size_t *count)
|
/* param base FlexCAN peripheral base address. param handle FlexCAN handle pointer. param count Number of CAN messages receive so far by the non-blocking transaction. retval kStatus_InvalidArgument count is Invalid. retval kStatus_Success Successfully return the count. */
status_t FLEXCAN_TransferGetReceiveFifoCount(CAN_Type *base, flexcan_handle_t *handle, size_t *count)
|
{
assert(NULL != handle);
status_t result = kStatus_Success;
if (handle->rxFifoState == (uint32_t)kFLEXCAN_StateIdle)
{
result = kStatus_NoTransferInProgress;
}
else
{
*count = handle->rxFifoTransferTotalNum - handle->rxFifoFrameNum;
}
return result;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Returns the interrupt number of SSI module . */
|
static uint32_t _SSIIntNumberGet(uint32_t ui32Base)
|
/* Returns the interrupt number of SSI module . */
static uint32_t _SSIIntNumberGet(uint32_t ui32Base)
|
{
uint_fast8_t ui8Idx, ui8Rows;
const uint32_t (*ppui32SSIIntMap)[2];
ASSERT(_SSIBaseValid(ui32Base));
ppui32SSIIntMap = g_ppui32SSIIntMap;
ui8Rows = g_ui8SSIIntMapRows;
for(ui8Idx = 0; ui8Idx < ui8Rows; ui8Idx++)
{
if(ppui32SSIIntMap[ui8Idx][0] == ui32Base)
{
return(ppui32SSIIntMap[ui8Idx][1]);
}
}
return(0);
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* After a card is removed, tc574_release() will unregister the net device, and release the PCMCIA configuration. If the device is still open, this will be postponed until it is closed. */
|
static void tc574_release(struct pcmcia_device *link)
|
/* After a card is removed, tc574_release() will unregister the net device, and release the PCMCIA configuration. If the device is still open, this will be postponed until it is closed. */
static void tc574_release(struct pcmcia_device *link)
|
{
pcmcia_disable_device(link);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Returns: 0 if the strings match, a negative value if @s1 < @s2, or a positive value if @s1 > @s2. */
|
gint g_ascii_strcasecmp(const gchar *s1, const gchar *s2)
|
/* Returns: 0 if the strings match, a negative value if @s1 < @s2, or a positive value if @s1 > @s2. */
gint g_ascii_strcasecmp(const gchar *s1, const gchar *s2)
|
{
gint c1, c2;
g_return_val_if_fail (s1 != NULL, 0);
g_return_val_if_fail (s2 != NULL, 0);
while (*s1 && *s2)
{
c1 = (gint)(guchar) TOLOWER (*s1);
c2 = (gint)(guchar) TOLOWER (*s2);
if (c1 != c2)
return (c1 - c2);
s1++; s2++;
}
return (((gint)(guchar) *s1) - ((gint)(guchar) *s2));
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* 3. Mobile Identity (IMSI, IMEISV or IMEI as coded in 3GPP TS 24.008) Dissected in packet-gsm_a_common.c 3. OMCID For the OMC identity, see 3GPP TS 52.021 */
|
static guint16 be_trace_omc_id(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
|
/* 3. Mobile Identity (IMSI, IMEISV or IMEI as coded in 3GPP TS 24.008) Dissected in packet-gsm_a_common.c 3. OMCID For the OMC identity, see 3GPP TS 52.021 */
static guint16 be_trace_omc_id(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
|
{
guint32 curr_offset;
curr_offset = offset;
proto_tree_add_item(tree, hf_gsm_a_bssmap_trace_omc_id, tvb, curr_offset, len, ENC_ASCII|ENC_NA);
curr_offset += len;
return(curr_offset - offset);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Get Zephyr hardware flow control option from LL hardware flow control define. */
|
static enum uart_config_flow_control uart_stm32_ll2cfg_hwctrl(uint32_t fc)
|
/* Get Zephyr hardware flow control option from LL hardware flow control define. */
static enum uart_config_flow_control uart_stm32_ll2cfg_hwctrl(uint32_t fc)
|
{
if (fc == LL_USART_HWCONTROL_RTS_CTS) {
return UART_CFG_FLOW_CTRL_RTS_CTS;
}
return UART_CFG_FLOW_CTRL_NONE;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Performs an ARM-based specific relocation fixup and is a no-op on other instruction sets. */
|
RETURN_STATUS PeCoffLoaderRelocateImageEx(IN UINT16 *Reloc, IN OUT CHAR8 *Fixup, IN OUT CHAR8 **FixupData, IN UINT64 Adjust)
|
/* Performs an ARM-based specific relocation fixup and is a no-op on other instruction sets. */
RETURN_STATUS PeCoffLoaderRelocateImageEx(IN UINT16 *Reloc, IN OUT CHAR8 *Fixup, IN OUT CHAR8 **FixupData, IN UINT64 Adjust)
|
{
UINT16 *Fixup16;
UINT32 FixupVal;
Fixup16 = (UINT16 *)Fixup;
switch ((*Reloc) >> 12) {
case EFI_IMAGE_REL_BASED_ARM_MOV32T:
FixupVal = ThumbMovwMovtImmediateAddress (Fixup16) + (UINT32)Adjust;
ThumbMovwMovtImmediatePatch (Fixup16, FixupVal);
if (*FixupData != NULL) {
*FixupData = ALIGN_POINTER (*FixupData, sizeof (UINT64));
CopyMem (*FixupData, Fixup16, sizeof (UINT64));
*FixupData = *FixupData + sizeof (UINT64);
}
break;
case EFI_IMAGE_REL_BASED_ARM_MOV32A:
ASSERT (FALSE);
default:
return RETURN_UNSUPPORTED;
}
return RETURN_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* On an EOF (meaning all the files are at EOF), set *err to 0 and return NULL. */
|
static merge_in_file_t* merge_append_read_packet(int in_file_count, merge_in_file_t in_files[], int *err, gchar **err_info)
|
/* On an EOF (meaning all the files are at EOF), set *err to 0 and return NULL. */
static merge_in_file_t* merge_append_read_packet(int in_file_count, merge_in_file_t in_files[], int *err, gchar **err_info)
|
{
int i;
for (i = 0; i < in_file_count; i++) {
if (in_files[i].state == AT_EOF)
continue;
if (wtap_read(in_files[i].wth, err, err_info, &in_files[i].data_offset))
break;
if (*err != 0) {
in_files[i].state = GOT_ERROR;
return &in_files[i];
}
in_files[i].state = AT_EOF;
}
if (i == in_file_count) {
*err = 0;
return NULL;
}
*err = 0;
return &in_files[i];
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Stop Observation.
This API is used to stop the observation procedure. */
|
ADI_BLER_RESULT adi_radio_StopObsvProc(void)
|
/* Stop Observation.
This API is used to stop the observation procedure. */
ADI_BLER_RESULT adi_radio_StopObsvProc(void)
|
{
ADI_BLER_RESULT bleResult;
ADI_BLE_LOGEVENT(LOGID_CMD_BLEGAP_STOP_OBS_PROC);
ADI_BLE_RADIO_CMD_START(CMD_BLEGAP_STOP_OBS_PROC);
bleResult = bler_process_cmd(CMD_BLEGAP_STOP_OBS_PROC, 0u, NULL, 0u);
if(bleResult == ADI_BLER_SUCCESS){
bleResult = ADI_BLE_WAIT_FOR_COMPLETION(ADI_EVENT_FLAG_RESP_SUCCESS,ADI_BLER_CMD_TIMEOUT);
}
ADI_BLE_RADIO_CMD_END();
return (bleResult);
}
|
analogdevicesinc/EVAL-ADICUP3029
|
C++
|
Other
| 36
|
/* This function retrieves the user readable name of a driver in the form of a Unicode string. If the driver specified by This has a user readable name in the language specified by Language, then a pointer to the driver name is returned in DriverName, and EFI_SUCCESS is returned. If the driver specified by This does not support the language specified by Language, then EFI_UNSUPPORTED is returned. */
|
EFI_STATUS EFIAPI UsbMassStorageGetDriverName(IN EFI_COMPONENT_NAME_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
|
/* This function retrieves the user readable name of a driver in the form of a Unicode string. If the driver specified by This has a user readable name in the language specified by Language, then a pointer to the driver name is returned in DriverName, and EFI_SUCCESS is returned. If the driver specified by This does not support the language specified by Language, then EFI_UNSUPPORTED is returned. */
EFI_STATUS EFIAPI UsbMassStorageGetDriverName(IN EFI_COMPONENT_NAME_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
|
{
return LookupUnicodeString2 (
Language,
This->SupportedLanguages,
mUsbMassStorageDriverNameTable,
DriverName,
(BOOLEAN)(This == &gUsbMassStorageComponentName)
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* The user is not allowed to select the slave while a transfer is in progress. */
|
int XQspiPs_SetSlaveSelect(XQspiPs *InstancePtr)
|
/* The user is not allowed to select the slave while a transfer is in progress. */
int XQspiPs_SetSlaveSelect(XQspiPs *InstancePtr)
|
{
u32 ConfigReg;
Xil_AssertNonvoid(InstancePtr != NULL);
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
if (InstancePtr->IsBusy) {
return XST_DEVICE_BUSY;
}
ConfigReg = XQspiPs_ReadReg(InstancePtr->Config.BaseAddress,
XQSPIPS_CR_OFFSET);
ConfigReg &= ~XQSPIPS_CR_SSCTRL_MASK;
XQspiPs_WriteReg(InstancePtr->Config.BaseAddress,
XQSPIPS_CR_OFFSET, ConfigReg);
return XST_SUCCESS;
}
|
ua1arn/hftrx
|
C++
| null | 69
|
/* If any reserved bits in Address are set, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). If StartBit is greater than 15, then ASSERT(). If EndBit is greater than 15, 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(). */
|
UINT16 EFIAPI PciSegmentBitFieldAnd16(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 AndData)
|
/* If any reserved bits in Address are set, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). If StartBit is greater than 15, then ASSERT(). If EndBit is greater than 15, 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(). */
UINT16 EFIAPI PciSegmentBitFieldAnd16(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 AndData)
|
{
UINTN Count;
PCI_SEGMENT_INFO *SegmentInfo;
SegmentInfo = GetPciSegmentInfo (&Count);
return MmioBitFieldAnd16 (PciSegmentLibGetEcamAddress (Address, SegmentInfo, Count), StartBit, EndBit, AndData);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Allocates the number of pages of MemoryType and returns a pointer to the allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL is returned. If there is not enough memory availble to satisfy the request, then NULL is returned. */
|
VOID* EFIAPI AllocatePages(IN UINTN Pages)
|
/* Allocates the number of pages of MemoryType and returns a pointer to the allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL is returned. If there is not enough memory availble to satisfy the request, then NULL is returned. */
VOID* EFIAPI AllocatePages(IN UINTN Pages)
|
{
EFI_PEI_HOB_POINTERS Hob;
EFI_PHYSICAL_ADDRESS Offset;
EFI_HOB_HANDOFF_INFO_TABLE *HobTable;
Hob.Raw = GetHobList ();
HobTable = Hob.HandoffInformationTable;
if (Pages == 0) {
return NULL;
}
Offset = HobTable->EfiFreeMemoryTop & EFI_PAGE_MASK;
if (Offset != 0) {
HobTable->EfiFreeMemoryTop -= Offset;
}
if (HobTable->EfiFreeMemoryTop - ((Pages * EFI_PAGE_SIZE) + sizeof (EFI_HOB_MEMORY_ALLOCATION)) < HobTable->EfiFreeMemoryBottom) {
return NULL;
}
HobTable->EfiFreeMemoryTop -= Pages * EFI_PAGE_SIZE;
BuildMemoryAllocationHob (HobTable->EfiFreeMemoryTop, Pages * EFI_PAGE_SIZE, EfiBootServicesData);
return (VOID *)(UINTN)HobTable->EfiFreeMemoryTop;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* param base LPCMP peripheral base address. param config Pointer to "lpcmp_dac_config_t" structure. If config is "NULL", disable internal DAC. */
|
void LPCMP_SetDACConfig(LPCMP_Type *base, const lpcmp_dac_config_t *config)
|
/* param base LPCMP peripheral base address. param config Pointer to "lpcmp_dac_config_t" structure. If config is "NULL", disable internal DAC. */
void LPCMP_SetDACConfig(LPCMP_Type *base, const lpcmp_dac_config_t *config)
|
{
uint32_t tmp32;
if (config == NULL)
{
tmp32 = 0U;
}
else
{
tmp32 = LPCMP_DCR_VRSEL(config->referenceVoltageSource) | LPCMP_DCR_DAC_DATA(config->DACValue);
if (config->enableLowPowerMode)
{
tmp32 |= LPCMP_DCR_DAC_HPMD_MASK;
}
tmp32 |= LPCMP_DCR_DAC_EN_MASK;
}
base->DCR = tmp32;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Checks whether the specified LTDC's flag is set or not. */
|
FlagStatus LTDC_GetFlagStatus(uint32_t LTDC_FLAG)
|
/* Checks whether the specified LTDC's flag is set or not. */
FlagStatus LTDC_GetFlagStatus(uint32_t LTDC_FLAG)
|
{
FlagStatus bitstatus = RESET;
assert_param(IS_LTDC_FLAG(LTDC_FLAG));
if ((LTDC->ISR & LTDC_FLAG) != (uint32_t)RESET)
{
bitstatus = SET;
}
else
{
bitstatus = RESET;
}
return bitstatus;
}
|
MaJerle/stm32f429
|
C++
| null | 2,036
|
/* Disables the fault capture registers.
This function disables the DCODEFAULTADDR and ICODEFAULTADDR registers. */
|
void am_hal_mcuctrl_fault_capture_disable(void)
|
/* Disables the fault capture registers.
This function disables the DCODEFAULTADDR and ICODEFAULTADDR registers. */
void am_hal_mcuctrl_fault_capture_disable(void)
|
{
AM_BFW(MCUCTRL, FAULTCAPTUREEN, ENABLE, 0);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Make a mailbox call. Returns 0 on failure, non-zero on success */
|
int mbox_call(unsigned char ch, int mmu_enable)
|
/* Make a mailbox call. Returns 0 on failure, non-zero on success */
int mbox_call(unsigned char ch, int mmu_enable)
|
{
unsigned int r = ((((rt_uint32_t)MBOX_ADDR)&~0xF) | (ch&0xF));
if(mmu_enable)
r = BUS_ADDRESS(r);
do
{
asm volatile("nop");
} while (*MBOX_STATUS & MBOX_FULL);
*MBOX_WRITE = r;
while(1)
{
do
{
asm volatile("nop");
} while (*MBOX_STATUS & MBOX_EMPTY);
if (r == *MBOX_READ){
return mbox[1] == MBOX_RESPONSE;
}
}
return 0;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* This API is used to get the status of fifo (fifo_mode) in the register 0x3E bit 6 and 7. */
|
BMA2x2_RETURN_FUNCTION_TYPE bma2x2_get_fifo_mode(u8 *fifo_mode_u8)
|
/* This API is used to get the status of fifo (fifo_mode) in the register 0x3E bit 6 and 7. */
BMA2x2_RETURN_FUNCTION_TYPE bma2x2_get_fifo_mode(u8 *fifo_mode_u8)
|
{
BMA2x2_RETURN_FUNCTION_TYPE com_rslt = ERROR;
u8 data_u8 = BMA2x2_INIT_VALUE;
if (p_bma2x2 == BMA2x2_NULL)
{
return E_BMA2x2_NULL_PTR;
}
else
{
com_rslt = p_bma2x2->BMA2x2_BUS_READ_FUNC(
p_bma2x2->dev_addr,
BMA2x2_FIFO_MODE_REG, &data_u8,
BMA2x2_GEN_READ_WRITE_LENGTH);
*fifo_mode_u8 = BMA2x2_GET_BITSLICE(data_u8,
BMA2x2_FIFO_MODE);
}
return com_rslt;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* the data is returned with 0xAC in the first byte of the array, 0xDE in the second, 0x48 in the third and so on. */
|
void EMACAddrGet(uint32_t ui32Base, uint32_t ui32Index, uint8_t *pui8MACAddr)
|
/* the data is returned with 0xAC in the first byte of the array, 0xDE in the second, 0x48 in the third and so on. */
void EMACAddrGet(uint32_t ui32Base, uint32_t ui32Index, uint8_t *pui8MACAddr)
|
{
uint32_t ui32Val;
ASSERT(ui32Index < NUM_MAC_ADDR);
ASSERT(pui8MACAddr);
ui32Val = HWREG(ui32Base + EMAC_O_ADDRL(ui32Index));
pui8MACAddr[0] = ui32Val & 0xFF;
pui8MACAddr[1] = (ui32Val >> 8) & 0xFF;
pui8MACAddr[2] = (ui32Val >> 16) & 0xFF;
pui8MACAddr[3] = (ui32Val >> 24) & 0xFF;
ui32Val = HWREG(ui32Base + EMAC_O_ADDRH(ui32Index));
pui8MACAddr[4] = ui32Val & 0xFF;
pui8MACAddr[5] = (ui32Val >> 8) & 0xFF;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Try to find a name for a function based on how it was called. */
|
static const char * funcnamefromcall(lua_State *L, CallInfo *ci, const char **name)
|
/* Try to find a name for a function based on how it was called. */
static const char * funcnamefromcall(lua_State *L, CallInfo *ci, const char **name)
|
{
if (ci->callstatus & CIST_HOOKED) {
*name = "?";
return "hook";
}
else if (ci->callstatus & CIST_FIN) {
*name = "__gc";
return "metamethod";
}
else if (isLua(ci))
return funcnamefromcode(L, ci_func(ci)->p, currentpc(ci), name);
else
return NULL;
}
|
Nicholas3388/LuaNode
|
C++
|
Other
| 1,055
|
/* atl1c_clean - NAPI Rx polling callback @adapter: board private structure */
|
static int atl1c_clean(struct napi_struct *napi, int budget)
|
/* atl1c_clean - NAPI Rx polling callback @adapter: board private structure */
static int atl1c_clean(struct napi_struct *napi, int budget)
|
{
struct atl1c_adapter *adapter =
container_of(napi, struct atl1c_adapter, napi);
int work_done = 0;
if (!netif_carrier_ok(adapter->netdev))
goto quit_polling;
atl1c_clean_rx_irq(adapter, 0, &work_done, budget);
if (work_done < budget) {
quit_polling:
napi_complete(napi);
adapter->hw.intr_mask |= ISR_RX_PKT;
AT_WRITE_REG(&adapter->hw, REG_IMR, adapter->hw.intr_mask);
}
return work_done;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Separate tiles -> separate tiles (tile dimension change). */
|
DECLAREcpFunc(cpSeparateTiles2SeparateTiles)
|
/* Separate tiles -> separate tiles (tile dimension change). */
DECLAREcpFunc(cpSeparateTiles2SeparateTiles)
|
{
return cpImage(in, out,
readSeparateTilesIntoBuffer,
writeBufferToSeparateTiles,
imagelength, imagewidth, spp);
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* SECTION: files in sysfs failfast controls the behaviour, if no path is available */
|
static ssize_t dasd_ff_show(struct device *dev, struct device_attribute *attr, char *buf)
|
/* SECTION: files in sysfs failfast controls the behaviour, if no path is available */
static ssize_t dasd_ff_show(struct device *dev, struct device_attribute *attr, char *buf)
|
{
struct dasd_devmap *devmap;
int ff_flag;
devmap = dasd_find_busid(dev_name(dev));
if (!IS_ERR(devmap))
ff_flag = (devmap->features & DASD_FEATURE_FAILFAST) != 0;
else
ff_flag = (DASD_FEATURE_DEFAULT & DASD_FEATURE_FAILFAST) != 0;
return snprintf(buf, PAGE_SIZE, ff_flag ? "1\n" : "0\n");
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Clear the I2C interrupt flag of the specified I2C port.
The */
|
void I2CIntFlagClear(unsigned long ulBase)
|
/* Clear the I2C interrupt flag of the specified I2C port.
The */
void I2CIntFlagClear(unsigned long ulBase)
|
{
xASSERT((ulBase == I2C0_BASE) || (ulBase == I2C1_BASE));
xHWREG(ulBase + I2C_CON) |= I2C_CON_SI;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Return: Link attention type in terms of base driver's coding. */
|
static uint8_t lpfc_sli4_parse_latt_type(struct lpfc_hba *phba, struct lpfc_acqe_link *acqe_link)
|
/* Return: Link attention type in terms of base driver's coding. */
static uint8_t lpfc_sli4_parse_latt_type(struct lpfc_hba *phba, struct lpfc_acqe_link *acqe_link)
|
{
uint8_t att_type;
switch (bf_get(lpfc_acqe_link_status, acqe_link)) {
case LPFC_ASYNC_LINK_STATUS_DOWN:
case LPFC_ASYNC_LINK_STATUS_LOGICAL_DOWN:
att_type = AT_LINK_DOWN;
break;
case LPFC_ASYNC_LINK_STATUS_UP:
att_type = AT_RESERVED;
break;
case LPFC_ASYNC_LINK_STATUS_LOGICAL_UP:
att_type = AT_LINK_UP;
break;
default:
lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
"0399 Invalid link attention type: x%x\n",
bf_get(lpfc_acqe_link_status, acqe_link));
att_type = AT_RESERVED;
break;
}
return att_type;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Somemtimes we have to undo a charge we got by try_charge(). This function is for that and do uncharge, put css's refcnt. gotten by try_charge(). */
|
static void mem_cgroup_cancel_charge(struct mem_cgroup *mem)
|
/* Somemtimes we have to undo a charge we got by try_charge(). This function is for that and do uncharge, put css's refcnt. gotten by try_charge(). */
static void mem_cgroup_cancel_charge(struct mem_cgroup *mem)
|
{
if (!mem_cgroup_is_root(mem)) {
res_counter_uncharge(&mem->res, PAGE_SIZE);
if (do_swap_account)
res_counter_uncharge(&mem->memsw, PAGE_SIZE);
}
css_put(&mem->css);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* NOTE: a write lock must be held on snap->lock before calling this. */
|
static struct dm_snap_pending_exception* __find_pending_exception(struct dm_snapshot *s, struct dm_snap_pending_exception *pe, chunk_t chunk)
|
/* NOTE: a write lock must be held on snap->lock before calling this. */
static struct dm_snap_pending_exception* __find_pending_exception(struct dm_snapshot *s, struct dm_snap_pending_exception *pe, chunk_t chunk)
|
{
struct dm_snap_pending_exception *pe2;
pe2 = __lookup_pending_exception(s, chunk);
if (pe2) {
free_pending_exception(pe);
return pe2;
}
pe->e.old_chunk = chunk;
bio_list_init(&pe->origin_bios);
bio_list_init(&pe->snapshot_bios);
pe->started = 0;
if (s->store->type->prepare_exception(s->store, &pe->e)) {
free_pending_exception(pe);
return NULL;
}
dm_insert_exception(&s->pending, &pe->e);
return pe;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Implements interrupt delay for the operating modes. This is so that the program is not blocked and the CLI still works when waiting to do a mode cycle. */
|
static void mode_delay_callback(void *cb_param, uint32_t event, void *arg)
|
/* Implements interrupt delay for the operating modes. This is so that the program is not blocked and the CLI still works when waiting to do a mode cycle. */
static void mode_delay_callback(void *cb_param, uint32_t event, void *arg)
|
{
if(mode_timer_flag == 0)
mode_timer_flag = 1;
}
|
analogdevicesinc/EVAL-ADICUP3029
|
C++
|
Other
| 36
|
/* Get the mem size need to be consumed and reserved in PEI phase. */
|
UINT64 GetPeiMemSize(IN EFI_PEI_SERVICES **PeiServices, IN UINT32 BootMode)
|
/* Get the mem size need to be consumed and reserved in PEI phase. */
UINT64 GetPeiMemSize(IN EFI_PEI_SERVICES **PeiServices, IN UINT32 BootMode)
|
{
UINT64 Size;
UINT64 MinSize;
if (BootMode == BOOT_IN_RECOVERY_MODE) {
return PcdGet32 (PcdPeiRecoveryMinMemSize);
}
Size = GetMemorySizeInMemoryTypeInformation (PeiServices);
if (BootMode == BOOT_ON_FLASH_UPDATE) {
MinSize = PcdGet32 (PcdPeiMinMemSize);
} else {
MinSize = PcdGet32 (PcdPeiMinMemSize);
}
return MinSize + Size + PEI_ADDITIONAL_MEMORY_SIZE;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Get the specified port number from a port bitmap. */
|
EFI_STATUS AhciGetPortFromMap(IN UINT32 PortBitMap, IN UINT8 PortIndex, OUT UINT8 *Port)
|
/* Get the specified port number from a port bitmap. */
EFI_STATUS AhciGetPortFromMap(IN UINT32 PortBitMap, IN UINT8 PortIndex, OUT UINT8 *Port)
|
{
if (PortIndex == 0) {
return EFI_NOT_FOUND;
}
*Port = 0;
while (PortBitMap != 0) {
if ((PortBitMap & ((UINT32)BIT0)) != 0) {
PortIndex--;
if (PortIndex == 0) {
return EFI_SUCCESS;
}
}
PortBitMap = PortBitMap >> 1;
*Port = *Port + 1;
}
return EFI_NOT_FOUND;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* exynos_pinctrl_setup_peri: setup pinctrl for a peripheral. conf: soc specific pin configuration data array num_conf: number of configurations in the conf array. base: base address of the pin controller. */
|
void exynos_pinctrl_setup_peri(struct exynos_pinctrl_config_data *conf, unsigned int num_conf, unsigned long base)
|
/* exynos_pinctrl_setup_peri: setup pinctrl for a peripheral. conf: soc specific pin configuration data array num_conf: number of configurations in the conf array. base: base address of the pin controller. */
void exynos_pinctrl_setup_peri(struct exynos_pinctrl_config_data *conf, unsigned int num_conf, unsigned long base)
|
{
unsigned int idx, val;
for (idx = 0; idx < num_conf; idx++) {
val = readl(base + conf[idx].offset);
val &= ~(conf[idx].mask);
val |= conf[idx].value;
writel(val, base + conf[idx].offset);
}
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* If the listener has no buffer (NULL buffer), one is allocated for the right size (the amount of data received). @neh->ptr will point to the event payload, which always starts with a 'struct uwb_rceb'. kfree() it when done. */
|
static struct uwb_rc_neh* uwb_rc_neh_lookup(struct uwb_rc *rc, const struct uwb_rceb *rceb)
|
/* If the listener has no buffer (NULL buffer), one is allocated for the right size (the amount of data received). @neh->ptr will point to the event payload, which always starts with a 'struct uwb_rceb'. kfree() it when done. */
static struct uwb_rc_neh* uwb_rc_neh_lookup(struct uwb_rc *rc, const struct uwb_rceb *rceb)
|
{
struct uwb_rc_neh *neh = NULL, *h;
unsigned long flags;
spin_lock_irqsave(&rc->neh_lock, flags);
list_for_each_entry(h, &rc->neh_list, list_node) {
if (uwb_rc_neh_match(h, rceb)) {
neh = h;
break;
}
}
if (neh)
__uwb_rc_neh_rm(rc, neh);
spin_unlock_irqrestore(&rc->neh_lock, flags);
return neh;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* The selection of single DES or triple DES is specified with one of the following two flags. Only one is permitted. */
|
void DESConfigSet(uint32_t ui32Base, uint32_t ui32Config)
|
/* The selection of single DES or triple DES is specified with one of the following two flags. Only one is permitted. */
void DESConfigSet(uint32_t ui32Base, uint32_t ui32Config)
|
{
ASSERT(ui32Base == DES_BASE);
ui32Config |= (HWREG(ui32Base + DES_O_CTRL) & DES_CTRL_CONTEXT);
HWREG(ui32Base + DES_O_CTRL) = ui32Config;
}
|
micropython/micropython
|
C++
|
Other
| 18,334
|
/* iommu_restore_ctx - Restore registers for pm off-mode support @obj: target iommu */
|
void iommu_restore_ctx(struct iommu *obj)
|
/* iommu_restore_ctx - Restore registers for pm off-mode support @obj: target iommu */
void iommu_restore_ctx(struct iommu *obj)
|
{
arch_iommu->restore_ctx(obj);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Disable ADC Block to put it into PowerDown. */
|
void ADCDisable(unsigned long ulBase)
|
/* Disable ADC Block to put it into PowerDown. */
void ADCDisable(unsigned long ulBase)
|
{
xASSERT((ulBase == ADC1_BASE) || (ulBase == ADC2_BASE) || (ulBase == ADC3_BASE));
xHWREG(ulBase + ADC_CR2) &= ~ADC_CR2_ADON;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Converts a generic ACPI text device path node to ACPI device path structure. */
|
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextAcpiPath(IN CHAR16 *TextDeviceNode)
|
/* Converts a generic ACPI text device path node to ACPI device path structure. */
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextAcpiPath(IN CHAR16 *TextDeviceNode)
|
{
return DevPathFromTextGenericPath (ACPI_DEVICE_PATH, TextDeviceNode);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Refer to SDIO Simplified Spec 3 Section 3.2 for details. */
|
EFI_STATUS SdioSendOpCond(IN SD_PEIM_HC_SLOT *Slot, IN UINT32 VoltageWindow, IN BOOLEAN S18r)
|
/* Refer to SDIO Simplified Spec 3 Section 3.2 for details. */
EFI_STATUS SdioSendOpCond(IN SD_PEIM_HC_SLOT *Slot, IN UINT32 VoltageWindow, IN BOOLEAN S18r)
|
{
SD_COMMAND_BLOCK SdCmdBlk;
SD_STATUS_BLOCK SdStatusBlk;
SD_COMMAND_PACKET Packet;
EFI_STATUS Status;
UINT32 Switch;
ZeroMem (&SdCmdBlk, sizeof (SdCmdBlk));
ZeroMem (&SdStatusBlk, sizeof (SdStatusBlk));
ZeroMem (&Packet, sizeof (Packet));
Packet.SdCmdBlk = &SdCmdBlk;
Packet.SdStatusBlk = &SdStatusBlk;
Packet.Timeout = SD_TIMEOUT;
SdCmdBlk.CommandIndex = SDIO_SEND_OP_COND;
SdCmdBlk.CommandType = SdCommandTypeBcr;
SdCmdBlk.ResponseType = SdResponseTypeR4;
Switch = S18r ? BIT24 : 0;
SdCmdBlk.CommandArgument = (VoltageWindow & 0xFFFFFF) | Switch;
Status = SdPeimExecCmd (Slot, &Packet);
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Returns: NULL if the string does not contain the character, otherwise, a pointer to the start of the leftmost occurrence of the character in the string. */
|
gchar* g_utf8_strchr(const char *p, gssize len, gunichar c)
|
/* Returns: NULL if the string does not contain the character, otherwise, a pointer to the start of the leftmost occurrence of the character in the string. */
gchar* g_utf8_strchr(const char *p, gssize len, gunichar c)
|
{
gchar ch[10];
gint charlen = g_unichar_to_utf8 (c, ch);
ch[charlen] = '\0';
return g_strstr_len (p, len, ch);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Auxiliary function for clearing event bit in given flags value.
Function used to clear selected event bit. */
|
static uint32_t nrf_drv_twis_clear_bit(uint32_t flags, nrf_twis_event_t ev)
|
/* Auxiliary function for clearing event bit in given flags value.
Function used to clear selected event bit. */
static uint32_t nrf_drv_twis_clear_bit(uint32_t flags, nrf_twis_event_t ev)
|
{
return flags & ~(1U<<nrf_drv_event_to_bitpos(ev));
}
|
labapart/polymcu
|
C++
| null | 201
|
/* Return: 0 if all went well, else returns appropriate error value. */
|
static int ti_sci_cmd_set_board_config_pm(const struct ti_sci_handle *handle, u64 addr, u32 size)
|
/* Return: 0 if all went well, else returns appropriate error value. */
static int ti_sci_cmd_set_board_config_pm(const struct ti_sci_handle *handle, u64 addr, u32 size)
|
{
return cmd_set_board_config_using_msg(handle,
TI_SCI_MSG_BOARD_CONFIG_PM,
addr, size);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Expand a component horizontally from width input_cols to width output_cols, by duplicating the rightmost samples. */
|
expand_right_edge(JSAMPARRAY image_data, int num_rows, JDIMENSION input_cols, JDIMENSION output_cols)
|
/* Expand a component horizontally from width input_cols to width output_cols, by duplicating the rightmost samples. */
expand_right_edge(JSAMPARRAY image_data, int num_rows, JDIMENSION input_cols, JDIMENSION output_cols)
|
{
register JSAMPROW ptr;
register JSAMPLE pixval;
register int count;
int row;
int numcols = (int) (output_cols - input_cols);
if (numcols > 0) {
for (row = 0; row < num_rows; row++) {
ptr = image_data[row] + input_cols;
pixval = ptr[-1];
for (count = numcols; count > 0; count--)
*ptr++ = pixval;
}
}
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.