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
|
|---|---|---|---|---|---|---|---|
/* The usage description of udp client on rt-Thread. */
|
static void usage(void)
|
/* The usage description of udp client on rt-Thread. */
static void usage(void)
|
{
rt_kprintf("Usage: udpclient -h <host> -p <port> [--cnt] [count]\n");
rt_kprintf(" udpclient --stop\n");
rt_kprintf(" udpclient --help\n");
rt_kprintf("\n");
rt_kprintf("Miscellaneous:\n");
rt_kprintf(" -h Specify host address\n");
rt_kprintf(" -p Specify the host port number\n");
rt_kprintf(" --cnt Specify the send data count\n");
rt_kprintf(" --stop Stop udpclient program\n");
rt_kprintf(" --help Print help information\n");
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* In a single threaded sys_arch implementation, this function will simply return a pointer to a global sys_timeouts variable stored in the sys_arch module. */
|
struct sys_timeouts* sys_arch_timeouts(void)
|
/* In a single threaded sys_arch implementation, this function will simply return a pointer to a global sys_timeouts variable stored in the sys_arch module. */
struct sys_timeouts* sys_arch_timeouts(void)
|
{
int i;
xTaskHandle pid;
struct timeoutlist *tl;
pid = xTaskGetCurrentTaskHandle( );
for(i = 0; i < s_nextthread; i++)
{
tl = &(s_timeoutlist[i]);
if(tl->pid == pid)
{
return &(tl->timeouts);
}
}
return NULL;
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* Perform basic hardware initialization at boot.
This needs to be run from the very beginning. So the init priority has to be 0 (zero). */
|
static int stm32wl_init(void)
|
/* Perform basic hardware initialization at boot.
This needs to be run from the very beginning. So the init priority has to be 0 (zero). */
static int stm32wl_init(void)
|
{
LL_FLASH_EnableInstCache();
LL_FLASH_EnableDataCache();
SystemCoreClock = 4000000;
return 0;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Does Standard SMC to OP-TEE in secure world. */
|
STATIC UINT32 OpteeCallWithArg(IN UINT64 PhysicalArg)
|
/* Does Standard SMC to OP-TEE in secure world. */
STATIC UINT32 OpteeCallWithArg(IN UINT64 PhysicalArg)
|
{
ARM_SMC_ARGS ArmSmcArgs;
ZeroMem (&ArmSmcArgs, sizeof (ARM_SMC_ARGS));
ArmSmcArgs.Arg0 = OPTEE_SMC_CALL_WITH_ARG;
ArmSmcArgs.Arg1 = (UINT32)(PhysicalArg >> 32);
ArmSmcArgs.Arg2 = (UINT32)PhysicalArg;
while (TRUE) {
ArmCallSmc (&ArmSmcArgs);
if (IsOpteeSmcReturnRpc (ArmSmcArgs.Arg0)) {
switch (ArmSmcArgs.Arg0) {
case OPTEE_SMC_RETURN_RPC_FOREIGN_INTERRUPT:
break;
default:
break;
}
ArmSmcArgs.Arg0 = OPTEE_SMC_RETURN_FROM_RPC;
} else {
break;
}
}
return ArmSmcArgs.Arg0;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Sleep until gettimeofday() > waketime + add_usec This needs to be as precise as possible, but as the delay is usually between 2ms and 32ms, it is done using a scheduled msleep followed by usleep (normally a busy-wait loop) for the remainder */
|
void dvb_frontend_sleep_until(struct timeval *waketime, u32 add_usec)
|
/* Sleep until gettimeofday() > waketime + add_usec This needs to be as precise as possible, but as the delay is usually between 2ms and 32ms, it is done using a scheduled msleep followed by usleep (normally a busy-wait loop) for the remainder */
void dvb_frontend_sleep_until(struct timeval *waketime, u32 add_usec)
|
{
struct timeval lasttime;
s32 delta, newdelta;
timeval_usec_add(waketime, add_usec);
do_gettimeofday(&lasttime);
delta = timeval_usec_diff(lasttime, *waketime);
if (delta > 2500) {
msleep((delta - 1500) / 1000);
do_gettimeofday(&lasttime);
newdelta = timeval_usec_diff(lasttime, *waketime);
delta = (newdelta > delta) ? 0 : newdelta;
}
if (delta > 0)
udelay(delta);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* SPI MSP De-Initialization This function freeze the hardware resources used in this example. */
|
void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi)
|
/* SPI MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi)
|
{
if(hspi->Instance==SPI1)
{
__HAL_RCC_SPI1_CLK_DISABLE();
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_1|GPIO_PIN_6|GPIO_PIN_7);
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Deinitializes CRC peripheral registers to their default reset values. */
|
void CRC_DeInit(void)
|
/* Deinitializes CRC peripheral registers to their default reset values. */
void CRC_DeInit(void)
|
{
CRC->DR = 0xFFFFFFFF;
CRC->POL = 0x04C11DB7;
CRC->IDR = 0x00;
CRC->INIT = 0xFFFFFFFF;
CRC->CR = CRC_CR_RESET;
}
|
avem-labs/Avem
|
C++
|
MIT License
| 1,752
|
/* Return success if silicon family did not implement a family specific get_cfg_done function. */
|
static s32 e1000_get_phy_cfg_done(struct e1000_hw *hw)
|
/* Return success if silicon family did not implement a family specific get_cfg_done function. */
static s32 e1000_get_phy_cfg_done(struct e1000_hw *hw)
|
{
if (hw->phy.ops.get_cfg_done)
return hw->phy.ops.get_cfg_done(hw);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Disable the specified ADC start of the injected. */
|
void ADC_DisableSoftwareStartInjectedConv(ADC_T *adc)
|
/* Disable the specified ADC start of the injected. */
void ADC_DisableSoftwareStartInjectedConv(ADC_T *adc)
|
{
adc->CTRL2_B.INJEXTTRGEN = BIT_RESET;
adc->CTRL2_B.INJSWSC = BIT_RESET;
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* RFC 7668, section 3 (IPv6 over Bluetooth Low Energy) Functionality is comprised of link-local IPv6 addresses and stateless IPv6 address autoconfiguration, Neighbor Discovery, and header compression Fragmentation features from 6LoWPAN standards are not used due to Bluetooth LE's link-layer fragmentation support. */
|
static void set_datagram_size(uint8_t *ptr, uint16_t size)
|
/* RFC 7668, section 3 (IPv6 over Bluetooth Low Energy) Functionality is comprised of link-local IPv6 addresses and stateless IPv6 address autoconfiguration, Neighbor Discovery, and header compression Fragmentation features from 6LoWPAN standards are not used due to Bluetooth LE's link-layer fragmentation support. */
static void set_datagram_size(uint8_t *ptr, uint16_t size)
|
{
ptr[0] |= ((size & 0x7FF) >> 8);
ptr[1] = (uint8_t)size;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Resets a per cpu exches pool, releasing all of its sequences and exchanges. If sid is non-zero then reset only exchanges we sourced from the local port's FID. If did is non-zero then only reset exchanges destined for the local port's FID. */
|
static void fc_exch_pool_reset(struct fc_lport *lport, struct fc_exch_pool *pool, u32 sid, u32 did)
|
/* Resets a per cpu exches pool, releasing all of its sequences and exchanges. If sid is non-zero then reset only exchanges we sourced from the local port's FID. If did is non-zero then only reset exchanges destined for the local port's FID. */
static void fc_exch_pool_reset(struct fc_lport *lport, struct fc_exch_pool *pool, u32 sid, u32 did)
|
{
struct fc_exch *ep;
struct fc_exch *next;
spin_lock_bh(&pool->lock);
restart:
list_for_each_entry_safe(ep, next, &pool->ex_list, ex_list) {
if ((lport == ep->lp) &&
(sid == 0 || sid == ep->sid) &&
(did == 0 || did == ep->did)) {
fc_exch_hold(ep);
spin_unlock_bh(&pool->lock);
fc_exch_reset(ep);
fc_exch_release(ep);
spin_lock_bh(&pool->lock);
goto restart;
}
}
spin_unlock_bh(&pool->lock);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Returns a quaternion based only on gyro and accel. */
|
inv_error_t inv_get_6axis_quaternion(long *data)
|
/* Returns a quaternion based only on gyro and accel. */
inv_error_t inv_get_6axis_quaternion(long *data)
|
{
memcpy(data, rh.gam_quat, sizeof(rh.gam_quat));
return INV_SUCCESS;
}
|
Luos-io/luos_engine
|
C++
|
MIT License
| 496
|
/* Get the temperature trim parameters after configuring the ADC.
WARNING: only call this after the ADC has been configured with am_hal_adc_config. */
|
void am_hal_adc_temp_trims_get(float *pfTemp, float *pfVoltage, float *pfOffsetV)
|
/* Get the temperature trim parameters after configuring the ADC.
WARNING: only call this after the ADC has been configured with am_hal_adc_config. */
void am_hal_adc_temp_trims_get(float *pfTemp, float *pfVoltage, float *pfOffsetV)
|
{
if ( pfTemp != NULL )
{
*pfTemp = priv_temp_trims.flt.fCalibrationTemperature;
}
if ( pfVoltage != NULL )
{
*pfVoltage = priv_temp_trims.flt.fCalibrationVoltage;
}
if ( pfOffsetV != NULL )
{
*pfOffsetV = priv_temp_trims.flt.fCalibrationOffset;
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Read data from Rx registers.
This function replaces the original SSIDataNonBlockingGet() API and performs the same actions. A macro is provided in */
|
unsigned long SPIRxRegisterGet(unsigned long ulBase)
|
/* Read data from Rx registers.
This function replaces the original SSIDataNonBlockingGet() API and performs the same actions. A macro is provided in */
unsigned long SPIRxRegisterGet(unsigned long ulBase)
|
{
xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE));
return (xHWREG(ulBase + SPI_DR));
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Attribute read call back for the Value V12 attribute. */
|
static ssize_t read_value_v12(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset)
|
/* Attribute read call back for the Value V12 attribute. */
static ssize_t read_value_v12(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset)
|
{
const uint8_t *value = attr->user_data;
return bt_gatt_attr_read(conn, attr, buf, len, offset, value,
sizeof(value_v12_value));
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Wrapper for usb_control_msg(). Allocates a temp buffer to prevent dmaing from/to the stack. */
|
int snd_usb_ctl_msg(struct usb_device *dev, unsigned int pipe, __u8 request, __u8 requesttype, __u16 value, __u16 index, void *data, __u16 size, int timeout)
|
/* Wrapper for usb_control_msg(). Allocates a temp buffer to prevent dmaing from/to the stack. */
int snd_usb_ctl_msg(struct usb_device *dev, unsigned int pipe, __u8 request, __u8 requesttype, __u16 value, __u16 index, void *data, __u16 size, int timeout)
|
{
int err;
void *buf = NULL;
if (size > 0) {
buf = kmemdup(data, size, GFP_KERNEL);
if (!buf)
return -ENOMEM;
}
err = usb_control_msg(dev, pipe, request, requesttype,
value, index, buf, size, timeout);
if (size > 0) {
memcpy(data, buf, size);
kfree(buf);
}
return err;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Configure the MCI CLKDIV in the MCI_MR register. The max. for MCI clock is MCK/2 and corresponds to CLKDIV = 0 */
|
void MCI_SetSpeed(Mci *pMci, unsigned int mciSpeed)
|
/* Configure the MCI CLKDIV in the MCI_MR register. The max. for MCI clock is MCK/2 and corresponds to CLKDIV = 0 */
void MCI_SetSpeed(Mci *pMci, unsigned int mciSpeed)
|
{
AT91S_MCI *pMciHw = pMci->pMciHw;
unsigned int mciMr;
unsigned short clkdiv;
SANITY_CHECK(pMci);
SANITY_CHECK(pMci->pMciHw);
mciMr = READ_MCI(pMciHw, MCI_MR) & (~AT91C_MCI_CLKDIV);
if (mciSpeed > 0) {
clkdiv = (BOARD_MCK / (mciSpeed * 2));
if (clkdiv > 0) {
clkdiv -= 1;
}
}
else {
clkdiv = 0;
}
WRITE_MCI(pMciHw, MCI_MR, mciMr | clkdiv);
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* Return: pointer to handle if successful, else EINVAL if invalid conditions are encountered. */
|
const struct ti_sci_handle* ti_sci_get_handle_from_sysfw(struct udevice *sci_dev)
|
/* Return: pointer to handle if successful, else EINVAL if invalid conditions are encountered. */
const struct ti_sci_handle* ti_sci_get_handle_from_sysfw(struct udevice *sci_dev)
|
{
if (!sci_dev)
return ERR_PTR(-EINVAL);
struct ti_sci_info *info = dev_get_priv(sci_dev);
if (!info)
return ERR_PTR(-EINVAL);
struct ti_sci_handle *handle = &info->handle;
if (!handle)
return ERR_PTR(-EINVAL);
return handle;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Call after a packet has been received (interrupt context is OK). */
|
void hpsb_iso_packet_received(struct hpsb_iso *iso, u32 offset, u16 len, u16 total_len, u16 cycle, u8 channel, u8 tag, u8 sy)
|
/* Call after a packet has been received (interrupt context is OK). */
void hpsb_iso_packet_received(struct hpsb_iso *iso, u32 offset, u16 len, u16 total_len, u16 cycle, u8 channel, u8 tag, u8 sy)
|
{
unsigned long flags;
spin_lock_irqsave(&iso->lock, flags);
if (iso->n_ready_packets == iso->buf_packets) {
atomic_inc(&iso->overflows);
iso->bytes_discarded += total_len;
} else {
struct hpsb_iso_packet_info *info = &iso->infos[iso->pkt_dma];
info->offset = offset;
info->len = len;
info->total_len = total_len;
info->cycle = cycle;
info->channel = channel;
info->tag = tag;
info->sy = sy;
iso->pkt_dma = (iso->pkt_dma + 1) % iso->buf_packets;
iso->n_ready_packets++;
}
spin_unlock_irqrestore(&iso->lock, flags);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function replaces the original EthernetPacketNonBlockingPut() API and performs the same actions. A macro is provided in */
|
long EthernetPacketPutNonBlocking(unsigned long ulBase, unsigned char *pucBuf, long lBufLen)
|
/* This function replaces the original EthernetPacketNonBlockingPut() API and performs the same actions. A macro is provided in */
long EthernetPacketPutNonBlocking(unsigned long ulBase, unsigned char *pucBuf, long lBufLen)
|
{
ASSERT(ulBase == ETH_BASE);
ASSERT(pucBuf != 0);
ASSERT(lBufLen > 0);
if(HWREG(ulBase + MAC_O_TR) & MAC_TR_NEWTX)
{
return(0);
}
return(EthernetPacketPutInternal(ulBase, pucBuf, lBufLen));
}
|
watterott/WebRadio
|
C++
| null | 71
|
/* Initializes the TX an HR state machines and enters the PRL_TX_SUSPEND and PRL_TX_SUSPEND states respectively. */
|
void prl_subsys_init(const struct device *dev)
|
/* Initializes the TX an HR state machines and enters the PRL_TX_SUSPEND and PRL_TX_SUSPEND states respectively. */
void prl_subsys_init(const struct device *dev)
|
{
struct usbc_port_data *data = dev->data;
struct protocol_layer_tx_t *prl_tx = data->prl_tx;
struct protocol_hard_reset_t *prl_hr = data->prl_hr;
prl_tx->dev = dev;
prl_hr->dev = dev;
smf_set_initial(SMF_CTX(prl_hr), &prl_hr_states[PRL_HR_SUSPEND]);
smf_set_initial(SMF_CTX(prl_tx), &prl_tx_states[PRL_TX_SUSPEND]);
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Disable lptimer Preload mode.
Disable lptimer preload mode, ensureing updated period and compare registers values are taken in account immediatly. */
|
void lptimer_disable_preload(uint32_t lptimer_peripheral)
|
/* Disable lptimer Preload mode.
Disable lptimer preload mode, ensureing updated period and compare registers values are taken in account immediatly. */
void lptimer_disable_preload(uint32_t lptimer_peripheral)
|
{
LPTIM_CFGR(lptimer_peripheral) &= ~LPTIM_CFGR_PRELOAD;
}
|
libopencm3/libopencm3
|
C++
|
GNU General Public License v3.0
| 2,931
|
/* If this interface is not supported, then return FALSE. */
|
BOOLEAN EFIAPI Sm3HashAll(IN CONST VOID *Data, IN UINTN DataSize, OUT UINT8 *HashValue)
|
/* If this interface is not supported, then return FALSE. */
BOOLEAN EFIAPI Sm3HashAll(IN CONST VOID *Data, IN UINTN DataSize, OUT UINT8 *HashValue)
|
{
CALL_CRYPTO_SERVICE (Sm3HashAll, (Data, DataSize, HashValue), FALSE);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Lock the Configuration of a Group of Pins.
The configuration of one or more pins of the given GPIO port is locked. There is no mechanism to unlock these via software. Unlocking occurs at the next reset. */
|
void gpio_port_config_lock(uint32_t gpioport, uint16_t gpios)
|
/* Lock the Configuration of a Group of Pins.
The configuration of one or more pins of the given GPIO port is locked. There is no mechanism to unlock these via software. Unlocking occurs at the next reset. */
void gpio_port_config_lock(uint32_t gpioport, uint16_t gpios)
|
{
uint32_t reg32;
GPIO_LCKR(gpioport) = GPIO_LCKK | gpios;
GPIO_LCKR(gpioport) = ~GPIO_LCKK & gpios;
GPIO_LCKR(gpioport) = GPIO_LCKK | gpios;
reg32 = GPIO_LCKR(gpioport);
reg32 = GPIO_LCKR(gpioport);
reg32 = reg32;
}
|
insane-adding-machines/unicore-mx
|
C++
|
GNU General Public License v3.0
| 50
|
/* The number of bytes actually written to the SBI console is returned. If the return value is less than NumberOfBytes, then the write operation failed. */
|
UINTN SbiDbcnWrite(IN UINT8 *Buffer, IN UINTN NumberOfBytes)
|
/* The number of bytes actually written to the SBI console is returned. If the return value is less than NumberOfBytes, then the write operation failed. */
UINTN SbiDbcnWrite(IN UINT8 *Buffer, IN UINTN NumberOfBytes)
|
{
SBI_RET Ret;
Ret = SbiCall (
SBI_EXT_DBCN,
SBI_EXT_DBCN_WRITE,
3,
NumberOfBytes,
((UINTN)Buffer),
0
);
return Ret.Value;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Returns the number of remaining data units in the current DMAy Channelx transfer. */
|
uint16_t DMA_GetCurrDataCounter(DMA_ChannelType *DMAyChx)
|
/* Returns the number of remaining data units in the current DMAy Channelx transfer. */
uint16_t DMA_GetCurrDataCounter(DMA_ChannelType *DMAyChx)
|
{
assert_param(IS_DMA_ALL_PERIPH(DMAyChx));
return ((uint16_t)(DMAyChx->TXNUM));
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Get an available execution engine that is currently unused. */
|
static int lp5562_get_available_engine(const struct device *dev, enum lp5562_led_sources *engine)
|
/* Get an available execution engine that is currently unused. */
static int lp5562_get_available_engine(const struct device *dev, enum lp5562_led_sources *engine)
|
{
enum lp5562_led_sources src;
for (src = LP5562_SOURCE_ENGINE_1; src < LP5562_SOURCE_COUNT; src++) {
if (!lp5562_is_engine_executing(dev, src)) {
LOG_DBG("Available engine: %d", src);
*engine = src;
return 0;
}
}
LOG_ERR("No unused engine available");
return -ENODEV;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Maximum value of a q15 vector without index. */
|
void arm_max_no_idx_q15(const q15_t *pSrc, uint32_t blockSize, q15_t *pResult)
|
/* Maximum value of a q15 vector without index. */
void arm_max_no_idx_q15(const q15_t *pSrc, uint32_t blockSize, q15_t *pResult)
|
{
q15_t maxVal1, out;
uint32_t blkCnt;
out = *pSrc++;
blkCnt = (blockSize - 1U);
while (blkCnt > 0U)
{
maxVal1 = *pSrc++;
if (out < maxVal1)
{
out = maxVal1;
}
blkCnt--;
}
*pResult = out;
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* If the conversion results in an overflow or an underflow condition, then Result is set to UINT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
|
RETURN_STATUS EFIAPI SafeIntnToUint32(IN INTN Operand, OUT UINT32 *Result)
|
/* If the conversion results in an overflow or an underflow condition, then Result is set to UINT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeIntnToUint32(IN INTN Operand, OUT UINT32 *Result)
|
{
RETURN_STATUS Status;
if (Result == NULL) {
return RETURN_INVALID_PARAMETER;
}
if (Operand >= 0) {
*Result = (UINT32)Operand;
Status = RETURN_SUCCESS;
} else {
*Result = UINT32_ERROR;
Status = RETURN_BUFFER_TOO_SMALL;
}
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* XXX - can this be called from any other dissector? */
|
static int dissect_wtp_fromwtls(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
|
/* XXX - can this be called from any other dissector? */
static int dissect_wtp_fromwtls(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
|
{
col_set_str(pinfo->cinfo, COL_PROTOCOL, "WTLS+WTP+WSP");
col_clear(pinfo->cinfo, COL_INFO);
dissect_wtp_common(tvb, pinfo, tree);
return tvb_captured_length(tvb);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* this function handles External lines 21 and 22 interrupt exception */
|
void ADC_CMP_IRQHandler(void)
|
/* this function handles External lines 21 and 22 interrupt exception */
void ADC_CMP_IRQHandler(void)
|
{
if((RESET != exti_interrupt_flag_get(EXTI_21)) || RESET != (exti_interrupt_flag_get(EXTI_22))){
SystemInit();
check_state();
exti_interrupt_flag_clear(EXTI_21);
exti_interrupt_flag_clear(EXTI_22);
}
}
|
liuxuming/trochili
|
C++
|
Apache License 2.0
| 132
|
/* Check boot time settings for the base address of device. The found settings are set for the device to be used later in the device probing. Returns 0 if no settings found. */
|
unsigned long netdev_boot_base(const char *prefix, int unit)
|
/* Check boot time settings for the base address of device. The found settings are set for the device to be used later in the device probing. Returns 0 if no settings found. */
unsigned long netdev_boot_base(const char *prefix, int unit)
|
{
const struct netdev_boot_setup *s = dev_boot_setup;
char name[IFNAMSIZ];
int i;
sprintf(name, "%s%d", prefix, unit);
if (__dev_get_by_name(&init_net, name))
return 1;
for (i = 0; i < NETDEV_BOOT_SETUP_MAX; i++)
if (!strcmp(name, s[i].name))
return s[i].map.base_addr;
return 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* for now, they are expected to be zero, but ignored. */
|
static int drbd_send_handshake(struct drbd_conf *mdev)
|
/* for now, they are expected to be zero, but ignored. */
static int drbd_send_handshake(struct drbd_conf *mdev)
|
{
struct p_handshake *p = &mdev->data.sbuf.handshake;
int ok;
if (mutex_lock_interruptible(&mdev->data.mutex)) {
dev_err(DEV, "interrupted during initial handshake\n");
return 0;
}
if (mdev->data.socket == NULL) {
mutex_unlock(&mdev->data.mutex);
return 0;
}
memset(p, 0, sizeof(*p));
p->protocol_min = cpu_to_be32(PRO_VERSION_MIN);
p->protocol_max = cpu_to_be32(PRO_VERSION_MAX);
ok = _drbd_send_cmd( mdev, mdev->data.socket, P_HAND_SHAKE,
(struct p_header *)p, sizeof(*p), 0 );
mutex_unlock(&mdev->data.mutex);
return ok;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Disables callback.
Disables the callback function registered by the usart_register_callback. The callback function will not be called from the interrupt handler. */
|
void gpio_disable_callback(uint8_t gpio_pin)
|
/* Disables callback.
Disables the callback function registered by the usart_register_callback. The callback function will not be called from the interrupt handler. */
void gpio_disable_callback(uint8_t gpio_pin)
|
{
Assert(gpio_pin < 48);
uint8_t gpio_port = 0;
if (gpio_pin < 16) {
gpio_port = 0;
} else if (gpio_pin < 32) {
gpio_port = 1;
} else {
gpio_port = 2;
}
_gpio_instances[gpio_port].callback_enable_mask &= ~(1 << (gpio_pin % 16));
_gpio_instances[gpio_port].hw->INTENCLR.reg = (1 << (gpio_pin % 16));
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* This API writes the available sensor specific commands to the sensor. */
|
uint16_t bma4_set_command_register(uint8_t command_reg, struct bma4_dev *dev)
|
/* This API writes the available sensor specific commands to the sensor. */
uint16_t bma4_set_command_register(uint8_t command_reg, struct bma4_dev *dev)
|
{
uint16_t rslt = 0;
if (dev == NULL) {
rslt |= BMA4_E_NULL_PTR;
} else {
rslt |= bma4_write_regs(BMA4_CMD_ADDR, &command_reg, 1, dev);
}
return rslt;
}
|
arendst/Tasmota
|
C++
|
GNU General Public License v3.0
| 21,318
|
/* This comparator searches for the next Interface descriptor of the correct MIDI Streaming Class, Subclass and Protocol values. */
|
uint8_t DComp_NextMIDIStreamingInterface(void *CurrentDescriptor)
|
/* This comparator searches for the next Interface descriptor of the correct MIDI Streaming Class, Subclass and Protocol values. */
uint8_t DComp_NextMIDIStreamingInterface(void *CurrentDescriptor)
|
{
USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
if (Header->Type == DTYPE_Interface)
{
USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);
if ((Interface->Class == AUDIO_CSCP_AudioClass) &&
(Interface->SubClass == AUDIO_CSCP_MIDIStreamingSubclass) &&
(Interface->Protocol == AUDIO_CSCP_StreamingProtocol))
{
return DESCRIPTOR_SEARCH_Found;
}
}
return DESCRIPTOR_SEARCH_NotFound;
}
|
prusa3d/Prusa-Firmware-Buddy
|
C++
|
Other
| 1,019
|
/* mux the pin to the gpio controller (instead of "A" or "B" peripheral), and configure it for an input. */
|
int at91_set_pio_input(unsigned port, u32 pin, int use_pullup)
|
/* mux the pin to the gpio controller (instead of "A" or "B" peripheral), and configure it for an input. */
int at91_set_pio_input(unsigned port, u32 pin, int use_pullup)
|
{
at91_pio_t *pio = (at91_pio_t *) AT91_PIO_BASE;
u32 mask;
if ((port < AT91_PIO_PORTS) && (pin < 32)) {
mask = 1 << pin;
writel(mask, &pio->port[port].idr);
at91_set_pio_pullup(port, pin, use_pullup);
writel(mask, &pio->port[port].odr);
writel(mask, &pio->port[port].per);
}
return 0;
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* Retrieves the size, in bytes, of the context buffer required for SM3 hash operations. */
|
UINTN EFIAPI CryptoServiceSm3GetContextSize(VOID)
|
/* Retrieves the size, in bytes, of the context buffer required for SM3 hash operations. */
UINTN EFIAPI CryptoServiceSm3GetContextSize(VOID)
|
{
return CALL_BASECRYPTLIB (Sm3.Services.GetContextSize, Sm3GetContextSize, (), 0);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Creating GCM Context.
Change Logs: Date Author Notes tyx the first version */
|
struct rt_hwcrypto_ctx* rt_hwcrypto_gcm_create(struct rt_hwcrypto_device *device, hwcrypto_type crypt_type)
|
/* Creating GCM Context.
Change Logs: Date Author Notes tyx the first version */
struct rt_hwcrypto_ctx* rt_hwcrypto_gcm_create(struct rt_hwcrypto_device *device, hwcrypto_type crypt_type)
|
{
struct rt_hwcrypto_ctx *ctx;
ctx = rt_hwcrypto_ctx_create(device, HWCRYPTO_TYPE_GCM, sizeof(struct hwcrypto_gcm));
if (ctx)
{
((struct hwcrypto_gcm *)ctx)->crypt_type = crypt_type;
}
return ctx;
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* Configures and registers the External Interrupt callback function with the driver. */
|
static void configure_eic_callback(void)
|
/* Configures and registers the External Interrupt callback function with the driver. */
static void configure_eic_callback(void)
|
{
extint_register_callback(extint_callback,
BUTTON_0_EIC_LINE,
EXTINT_CALLBACK_TYPE_DETECT);
extint_chan_enable_callback(BUTTON_0_EIC_LINE,
EXTINT_CALLBACK_TYPE_DETECT);
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* De-initialize EFLASH Interface. stops operation and releases the software resources used by the interface. */
|
int32_t csi_eflash_uninitialize(eflash_handle_t handle)
|
/* De-initialize EFLASH Interface. stops operation and releases the software resources used by the interface. */
int32_t csi_eflash_uninitialize(eflash_handle_t handle)
|
{
EFLASH_NULL_PARAM_CHK(handle);
ck_eflash_priv_t *eflash_priv = handle;
eflash_priv->cb = NULL;
return 0;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Perform the given command and wait until its completion (or an error). */
|
uint32_t efc_perform_command(Efc *p_efc, uint32_t ul_command, uint32_t ul_argument)
|
/* Perform the given command and wait until its completion (or an error). */
uint32_t efc_perform_command(Efc *p_efc, uint32_t ul_command, uint32_t ul_argument)
|
{
uint32_t result;
irqflags_t flags;
if (ul_command == EFC_FCMD_STUI || ul_command == EFC_FCMD_SPUI) {
return EFC_RC_NOT_SUPPORT;
}
flags = cpu_irq_save();
result = efc_perform_fcr(p_efc,
EEFC_FCR_FKEY_PASSWD | EEFC_FCR_FARG(ul_argument) |
EEFC_FCR_FCMD(ul_command));
cpu_irq_restore(flags);
return result;
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Get the driver strength to be set on bus. */
|
EDKII_SD_MMC_DRIVER_STRENGTH EmmcGetTargetDriverStrength(IN SD_MMC_HC_PRIVATE_DATA *Private, IN UINT8 SlotIndex, IN EMMC_EXT_CSD *ExtCsd, IN SD_MMC_BUS_MODE BusTiming)
|
/* Get the driver strength to be set on bus. */
EDKII_SD_MMC_DRIVER_STRENGTH EmmcGetTargetDriverStrength(IN SD_MMC_HC_PRIVATE_DATA *Private, IN UINT8 SlotIndex, IN EMMC_EXT_CSD *ExtCsd, IN SD_MMC_BUS_MODE BusTiming)
|
{
EDKII_SD_MMC_DRIVER_STRENGTH PreferredDriverStrength;
EDKII_SD_MMC_DRIVER_STRENGTH DriverStrength;
PreferredDriverStrength = Private->Slot[SlotIndex].OperatingParameters.DriverStrength;
DriverStrength.Emmc = EmmcDriverStrengthType0;
if ((PreferredDriverStrength.Emmc != EDKII_SD_MMC_DRIVER_STRENGTH_IGNORE) &&
(ExtCsd->DriverStrength & (BIT0 << PreferredDriverStrength.Emmc)))
{
DriverStrength.Emmc = PreferredDriverStrength.Emmc;
}
return DriverStrength;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This function commits orphans to flash. On success, %0 is returned, otherwise a negative error code is returned. */
|
static int commit_orphans(struct ubifs_info *c)
|
/* This function commits orphans to flash. On success, %0 is returned, otherwise a negative error code is returned. */
static int commit_orphans(struct ubifs_info *c)
|
{
int avail, atomic = 0, err;
ubifs_assert(c->cmt_orphans > 0);
avail = avail_orphs(c);
if (avail < c->cmt_orphans) {
err = consolidate(c);
if (err)
return err;
atomic = 1;
}
err = write_orph_nodes(c, atomic);
return err;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Waits to send a character from the specified port. */
|
void xUARTCharPut(unsigned long ulBase, unsigned char ucData)
|
/* Waits to send a character from the specified port. */
void xUARTCharPut(unsigned long ulBase, unsigned char ucData)
|
{
xASSERT(UARTBaseValid(ulBase));
while(xHWREG(ulBase + UART_FSR) & UART_FSR_TX_FF)
{
}
xHWREG(ulBase + UART_THR) = ucData;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Returns 1 if they are equal, 0 if they are different */
|
int xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
|
/* Returns 1 if they are equal, 0 if they are different */
int xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
|
{
if (*str1++ != *str2) return(0);
} while (*str2++);
return(1);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Acquires semaphore, if necessary. Then reads the PHY register at offset using the kumeran interface. The information retrieved is stored in data. Release any acquired semaphores before exiting. */
|
static s32 __e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data, bool locked)
|
/* Acquires semaphore, if necessary. Then reads the PHY register at offset using the kumeran interface. The information retrieved is stored in data. Release any acquired semaphores before exiting. */
static s32 __e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data, bool locked)
|
{
u32 kmrnctrlsta;
s32 ret_val = 0;
if (!locked) {
if (!(hw->phy.ops.acquire))
goto out;
ret_val = hw->phy.ops.acquire(hw);
if (ret_val)
goto out;
}
kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) &
E1000_KMRNCTRLSTA_OFFSET) | E1000_KMRNCTRLSTA_REN;
ew32(KMRNCTRLSTA, kmrnctrlsta);
udelay(2);
kmrnctrlsta = er32(KMRNCTRLSTA);
*data = (u16)kmrnctrlsta;
if (!locked)
hw->phy.ops.release(hw);
out:
return ret_val;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Build a neighbour cache including all neighbours currently configured in the kernel. */
|
int rtnl_neigh_alloc_cache(struct nl_sock *sock, struct nl_cache **result)
|
/* Build a neighbour cache including all neighbours currently configured in the kernel. */
int rtnl_neigh_alloc_cache(struct nl_sock *sock, struct nl_cache **result)
|
{
return nl_cache_alloc_and_fill(&rtnl_neigh_ops, sock, result);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Returns a pointer to the interrupt parent node, or NULL if the interrupt parent could not be determined. */
|
static struct dtb_node* dtb_node_irq_find_parent(struct dtb_node *child)
|
/* Returns a pointer to the interrupt parent node, or NULL if the interrupt parent could not be determined. */
static struct dtb_node* dtb_node_irq_find_parent(struct dtb_node *child)
|
{
struct dtb_node *p;
phandle parent;
if (!dtb_node_get(child))
return NULL;
do
{
if (dtb_node_read_u32_array(child, "interrupt-parent", &parent, 1))
{
p = dtb_node_get_parent(child);
}
else
{
p = dtb_node_get_by_phandle(parent);
}
dtb_node_put(child);
child = p;
} while (p && dtb_node_get_property(p, "#interrupt-cells", NULL) == NULL);
return p;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* BACnetPrescale ::= SEQUENCE { multiplier Unsigned, moduloDivide Unsigned } */
|
static guint fPrescale(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
|
/* BACnetPrescale ::= SEQUENCE { multiplier Unsigned, moduloDivide Unsigned } */
static guint fPrescale(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
|
{
guint8 tag_no, tag_info;
guint32 lvt;
guint lastoffset = 0;
while (tvb_reported_length_remaining(tvb, offset) > 0) {
lastoffset = offset;
fTagHeader(tvb, pinfo, offset, &tag_no, &tag_info, &lvt);
if (tag_is_closing(tag_info) ) {
return offset;
}
switch (tag_no) {
case 0:
offset = fUnsignedTag(tvb, pinfo, tree, offset, "Multiplier: ");
break;
case 1:
offset = fUnsignedTag(tvb, pinfo, tree, offset, "Modulo Divide: ");
break;
default:
return offset;
}
if (offset == lastoffset) break;
}
return offset;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Note: For Pseudo OpCodes this function returns NULL. */
|
CONST AML_BYTE_ENCODING* EFIAPI AmlGetFieldEncoding(IN CONST UINT8 *Buffer)
|
/* Note: For Pseudo OpCodes this function returns NULL. */
CONST AML_BYTE_ENCODING* EFIAPI AmlGetFieldEncoding(IN CONST UINT8 *Buffer)
|
{
UINT8 OpCode;
UINT32 Index;
if (Buffer == NULL) {
ASSERT (0);
return NULL;
}
OpCode = *Buffer;
for (Index = 0;
Index < (sizeof (mAmlFieldEncoding) / sizeof (mAmlFieldEncoding[0]));
Index++)
{
if (mAmlFieldEncoding[Index].OpCode == OpCode) {
if ((mAmlFieldEncoding[Index].Attribute & AML_IS_PSEUDO_OPCODE) ==
AML_IS_PSEUDO_OPCODE)
{
ASSERT (0);
return NULL;
}
return &mAmlFieldEncoding[Index];
}
}
return NULL;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This function finds transition that matches with happened event, then executes related actions and finally changes state of connection. Returns 0 for success, 1 for failure. */
|
static int llc_conn_service(struct sock *sk, struct sk_buff *skb)
|
/* This function finds transition that matches with happened event, then executes related actions and finally changes state of connection. Returns 0 for success, 1 for failure. */
static int llc_conn_service(struct sock *sk, struct sk_buff *skb)
|
{
int rc = 1;
struct llc_sock *llc = llc_sk(sk);
struct llc_conn_state_trans *trans;
if (llc->state > NBR_CONN_STATES)
goto out;
rc = 0;
trans = llc_qualify_conn_ev(sk, skb);
if (trans) {
rc = llc_exec_conn_trans_actions(sk, trans, skb);
if (!rc && trans->next_state != NO_STATE_CHANGE) {
llc->state = trans->next_state;
if (!llc_data_accept_state(llc->state))
sk->sk_state_change(sk);
}
}
out:
return rc;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* iwlcore_rts_tx_cmd_flag: Set rts/cts. 3945 and 4965 only share this function. */
|
void iwlcore_rts_tx_cmd_flag(struct ieee80211_tx_info *info, __le32 *tx_flags)
|
/* iwlcore_rts_tx_cmd_flag: Set rts/cts. 3945 and 4965 only share this function. */
void iwlcore_rts_tx_cmd_flag(struct ieee80211_tx_info *info, __le32 *tx_flags)
|
{
if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) {
*tx_flags |= TX_CMD_FLG_RTS_MSK;
*tx_flags &= ~TX_CMD_FLG_CTS_MSK;
} else if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT) {
*tx_flags &= ~TX_CMD_FLG_RTS_MSK;
*tx_flags |= TX_CMD_FLG_CTS_MSK;
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Enable the High Speed APB (APB2) peripheral clock during Low Power (Sleep) mode. */
|
void RCM_EnableAPB2PeriphClockLPMode(uint32_t APB2Periph)
|
/* Enable the High Speed APB (APB2) peripheral clock during Low Power (Sleep) mode. */
void RCM_EnableAPB2PeriphClockLPMode(uint32_t APB2Periph)
|
{
RCM->LPAPB2CLKEN |= APB2Periph;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Input an Internet address and convert to binary. */
|
int iw_in_inet(char *name, struct sockaddr *sap)
|
/* Input an Internet address and convert to binary. */
int iw_in_inet(char *name, struct sockaddr *sap)
|
{
struct hostent *hp;
struct netent *np;
struct sockaddr_in *sain = (struct sockaddr_in *) sap;
sain->sin_family = AF_INET;
sain->sin_port = 0;
if (!strcmp(name, "default")) {
sain->sin_addr.s_addr = INADDR_ANY;
return(1);
}
if ((np = getnetbyname(name)) != (struct netent *)NULL) {
sain->sin_addr.s_addr = htonl(np->n_net);
strcpy(name, np->n_name);
return(1);
}
if ((hp = gethostbyname(name)) == (struct hostent *)NULL) {
errno = h_errno;
return(-1);
}
memcpy((char *) &sain->sin_addr, (char *) hp->h_addr_list[0], hp->h_length);
strcpy(name, hp->h_name);
return(0);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Reads a signed 16 bit value over I2C. */
|
err_t bmp085ReadS16(uint16_t reg, int16_t *value)
|
/* Reads a signed 16 bit value over I2C. */
err_t bmp085ReadS16(uint16_t reg, int16_t *value)
|
{
uint16_t i;
ASSERT_STATUS(bmp085Read16(reg, &i));
*value = (int16_t)i;
return ERROR_NONE;
}
|
microbuilder/LPC11U_LPC13U_CodeBase
|
C++
|
Other
| 54
|
/* Resets the internal counter of batching vents for a single sensor. This bit is automatically reset to zero if it was set to ‘1’.. */
|
int32_t lsm6dso_rst_batch_counter_set(stmdev_ctx_t *ctx, uint8_t val)
|
/* Resets the internal counter of batching vents for a single sensor. This bit is automatically reset to zero if it was set to ‘1’.. */
int32_t lsm6dso_rst_batch_counter_set(stmdev_ctx_t *ctx, uint8_t val)
|
{
lsm6dso_counter_bdr_reg1_t reg;
int32_t ret;
ret = lsm6dso_read_reg(ctx, LSM6DSO_COUNTER_BDR_REG1, (uint8_t *)®,
1);
if (ret == 0) {
reg.rst_counter_bdr = val;
ret = lsm6dso_write_reg(ctx, LSM6DSO_COUNTER_BDR_REG1,
(uint8_t *)®, 1);
}
return ret;
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* This function reads CR2 register when on-demand paging is enabled. */
|
VOID SaveCr2(OUT UINTN *Cr2)
|
/* This function reads CR2 register when on-demand paging is enabled. */
VOID SaveCr2(OUT UINTN *Cr2)
|
{
if (!mCpuSmmRestrictedMemoryAccess) {
*Cr2 = AsmReadCr2 ();
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Switch slow clock source selection to external 32k (Xtal or Bypass). */
|
void pmc_switch_sclk_to_32kxtal(uint32_t ul_bypass)
|
/* Switch slow clock source selection to external 32k (Xtal or Bypass). */
void pmc_switch_sclk_to_32kxtal(uint32_t ul_bypass)
|
{
if (ul_bypass == 1) {
SUPC->SUPC_MR |= SUPC_MR_KEY_PASSWD |
SUPC_MR_OSCBYPASS;
}
SUPC->SUPC_CR = SUPC_CR_KEY_PASSWD | SUPC_CR_XTALSEL;
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* if management frame or broadcast frame only return basic available rates. */
|
static u16 rs_get_supported_rates(struct iwl_lq_sta *lq_sta, struct ieee80211_hdr *hdr, enum iwl_table_type rate_type)
|
/* if management frame or broadcast frame only return basic available rates. */
static u16 rs_get_supported_rates(struct iwl_lq_sta *lq_sta, struct ieee80211_hdr *hdr, enum iwl_table_type rate_type)
|
{
if (hdr && is_multicast_ether_addr(hdr->addr1) &&
lq_sta->active_rate_basic)
return lq_sta->active_rate_basic;
if (is_legacy(rate_type)) {
return lq_sta->active_legacy_rate;
} else {
if (is_siso(rate_type))
return lq_sta->active_siso_rate;
else if (is_mimo2(rate_type))
return lq_sta->active_mimo2_rate;
else
return lq_sta->active_mimo3_rate;
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Split 'str' into strings separated by commas. Note: out points into 'str'. */
|
static bool split_str(char *str, char ***out, size_t *count)
|
/* Split 'str' into strings separated by commas. Note: out points into 'str'. */
static bool split_str(char *str, char ***out, size_t *count)
|
{
char **res;
char *lasts;
char *s;
size_t i;
size_t items = 1;
s = strchr(str, ',');
while(s) {
items++;
s = strchr(++s, ',');
}
res = calloc(items, sizeof(char *));
if(!res)
return FALSE;
for(i = 0, s = strtok_r(str, ",", &lasts); s && i < items;
s = strtok_r(NULL, ",", &lasts), i++)
res[i] = s;
*out = res;
*count = items;
return TRUE;
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* Free the memory block from the memory pool. */
|
VOID UsbHcFreeMemBlock(IN USBHC_MEM_POOL *Pool, IN USBHC_MEM_BLOCK *Block)
|
/* Free the memory block from the memory pool. */
VOID UsbHcFreeMemBlock(IN USBHC_MEM_POOL *Pool, IN USBHC_MEM_BLOCK *Block)
|
{
EFI_PCI_IO_PROTOCOL *PciIo;
ASSERT ((Pool != NULL) && (Block != NULL));
PciIo = Pool->PciIo;
PciIo->Unmap (PciIo, Block->Mapping);
PciIo->FreeBuffer (PciIo, EFI_SIZE_TO_PAGES (Block->BufLen), Block->BufHost);
gBS->FreePool (Block->Bits);
gBS->FreePool (Block);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* HASH Digest.
Starts the processing of the last data block. */
|
void hash_digest()
|
/* HASH Digest.
Starts the processing of the last data block. */
void hash_digest()
|
{
HASH_STR |= HASH_STR_DCAL;
}
|
insane-adding-machines/unicore-mx
|
C++
|
GNU General Public License v3.0
| 50
|
/* 8.37 UE Network Capability UE Network Capability is coded as depicted in Figure 8.37-1. Actual coding of the UE Network Capability field is defined in 3GPP TS 24.301 */
|
static void dissect_gtpv2_ue_net_capability(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_, session_args_t *args _U_)
|
/* 8.37 UE Network Capability UE Network Capability is coded as depicted in Figure 8.37-1. Actual coding of the UE Network Capability field is defined in 3GPP TS 24.301 */
static void dissect_gtpv2_ue_net_capability(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint16 length, guint8 message_type _U_, guint8 instance _U_, session_args_t *args _U_)
|
{
de_emm_ue_net_cap(tvb, tree, pinfo, 0, length, NULL, 0);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Note that the program must first call XLlFifo_iRxGetLen before pulling data out of the receive channel of the FIFO with XLlFifo_Read. */
|
u32 XLlFifo_iRxGetLen(XLlFifo *InstancePtr)
|
/* Note that the program must first call XLlFifo_iRxGetLen before pulling data out of the receive channel of the FIFO with XLlFifo_Read. */
u32 XLlFifo_iRxGetLen(XLlFifo *InstancePtr)
|
{
Xil_AssertNonvoid(InstancePtr);
return XLlFifo_ReadReg(InstancePtr->BaseAddress,
XLLF_RLF_OFFSET);
}
|
ua1arn/hftrx
|
C++
| null | 69
|
/* Compare whether two names of languages are identical. */
|
BOOLEAN CompareIso639LanguageCode(IN CONST CHAR8 *Language1, IN CONST CHAR8 *Language2)
|
/* Compare whether two names of languages are identical. */
BOOLEAN CompareIso639LanguageCode(IN CONST CHAR8 *Language1, IN CONST CHAR8 *Language2)
|
{
UINT32 Name1;
UINT32 Name2;
Name1 = ReadUnaligned24 ((CONST UINT32 *)Language1);
Name2 = ReadUnaligned24 ((CONST UINT32 *)Language2);
return (BOOLEAN)(Name1 == Name2);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* The function will check if IA32 PAE is supported. */
|
BOOLEAN IsIa32PaeSupport(VOID)
|
/* The function will check if IA32 PAE is supported. */
BOOLEAN IsIa32PaeSupport(VOID)
|
{
UINT32 RegEax;
UINT32 RegEdx;
BOOLEAN Ia32PaeSupport;
Ia32PaeSupport = FALSE;
AsmCpuid (0x0, &RegEax, NULL, NULL, NULL);
if (RegEax >= 0x1) {
AsmCpuid (0x1, NULL, NULL, NULL, &RegEdx);
if ((RegEdx & BIT6) != 0) {
Ia32PaeSupport = TRUE;
}
}
return Ia32PaeSupport;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Create template to be used to send tcp packets on a connection. Call after host entry created, fills in a skeletal tcp/ip header, minimizing the amount of work necessary when the connection is used. */
|
void tcp_template(struct tcpcb *tp)
|
/* Create template to be used to send tcp packets on a connection. Call after host entry created, fills in a skeletal tcp/ip header, minimizing the amount of work necessary when the connection is used. */
void tcp_template(struct tcpcb *tp)
|
{
struct socket *so = tp->t_socket;
register struct tcpiphdr *n = &tp->t_template;
n->ti_mbuf = NULL;
n->ti_x1 = 0;
n->ti_pr = IPPROTO_TCP;
n->ti_len = htons(sizeof (struct tcpiphdr) - sizeof (struct ip));
n->ti_src = so->so_faddr;
n->ti_dst = so->so_laddr;
n->ti_sport = so->so_fport;
n->ti_dport = so->so_lport;
n->ti_seq = 0;
n->ti_ack = 0;
n->ti_x2 = 0;
n->ti_off = 5;
n->ti_flags = 0;
n->ti_win = 0;
n->ti_sum = 0;
n->ti_urp = 0;
}
|
ve3wwg/teensy3_qemu
|
C++
|
Other
| 15
|
/* Caller should try to get an array of interrupt and/or exception vectors that are in use and need to persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification. If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL. If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly. */
|
EFI_STATUS EFIAPI InitializeCpuExceptionHandlers(IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL)
|
/* Caller should try to get an array of interrupt and/or exception vectors that are in use and need to persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification. If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL. If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly. */
EFI_STATUS EFIAPI InitializeCpuExceptionHandlers(IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL)
|
{
RiscVSetSupervisorStvec ((UINT64)SupervisorModeTrap);
return EFI_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Voltage indication is higher for lower voltage. Lower voltage requires more gain (lower gain table index). */
|
static s32 iwl4965_get_voltage_compensation(s32 eeprom_voltage, s32 current_voltage)
|
/* Voltage indication is higher for lower voltage. Lower voltage requires more gain (lower gain table index). */
static s32 iwl4965_get_voltage_compensation(s32 eeprom_voltage, s32 current_voltage)
|
{
s32 comp = 0;
if ((TX_POWER_IWL_ILLEGAL_VOLTAGE == eeprom_voltage) ||
(TX_POWER_IWL_ILLEGAL_VOLTAGE == current_voltage))
return 0;
iwl4965_math_div_round(current_voltage - eeprom_voltage,
TX_POWER_IWL_VOLTAGE_CODES_PER_03V, &comp);
if (current_voltage > eeprom_voltage)
comp *= 2;
if ((comp < -2) || (comp > 2))
comp = 0;
return comp;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This only works for the Gregorian calendar - i.e. after 1752 (in the UK) */
|
void GregorianDay(struct rtc_time *tm)
|
/* This only works for the Gregorian calendar - i.e. after 1752 (in the UK) */
void GregorianDay(struct rtc_time *tm)
|
{
int leapsToDate;
int lastYear;
int day;
int MonthOffset[] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
lastYear = tm->tm_year - 1;
leapsToDate = lastYear / 4 - lastYear / 100 + lastYear / 400;
day = tm->tm_mon > 2 && leapyear(tm->tm_year);
day += lastYear*365 + leapsToDate + MonthOffset[tm->tm_mon-1] +
tm->tm_mday;
tm->tm_wday = day % 7;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Finally, once recovery is over, we need to clear the revoke table so that it can be reused by the running filesystem. */
|
void jbd2_journal_clear_revoke(journal_t *journal)
|
/* Finally, once recovery is over, we need to clear the revoke table so that it can be reused by the running filesystem. */
void jbd2_journal_clear_revoke(journal_t *journal)
|
{
int i;
struct list_head *hash_list;
struct jbd2_revoke_record_s *record;
struct jbd2_revoke_table_s *revoke;
revoke = journal->j_revoke;
for (i = 0; i < revoke->hash_size; i++) {
hash_list = &revoke->hash_table[i];
while (!list_empty(hash_list)) {
record = (struct jbd2_revoke_record_s*) hash_list->next;
list_del(&record->hash);
kmem_cache_free(jbd2_revoke_record_cache, record);
}
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* If there is an associated rpipe to this endpoint, go ahead and put it. */
|
static void hwahc_op_endpoint_disable(struct usb_hcd *usb_hcd, struct usb_host_endpoint *ep)
|
/* If there is an associated rpipe to this endpoint, go ahead and put it. */
static void hwahc_op_endpoint_disable(struct usb_hcd *usb_hcd, struct usb_host_endpoint *ep)
|
{
struct wusbhc *wusbhc = usb_hcd_to_wusbhc(usb_hcd);
struct hwahc *hwahc = container_of(wusbhc, struct hwahc, wusbhc);
rpipe_ep_disable(&hwahc->wa, ep);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Set the PWM duty of the PWM module.
The */
|
void PWMDutySet(unsigned long ulBase, unsigned long ulChannel, unsigned char ulDuty)
|
/* Set the PWM duty of the PWM module.
The */
void PWMDutySet(unsigned long ulBase, unsigned long ulChannel, unsigned char ulDuty)
|
{
unsigned long ulChannelTemp;
unsigned long ulCMRData;
ulChannelTemp = (ulBase == PWMA_BASE) ? ulChannel : (ulChannel - 4);
xASSERT(ulBase == PWMA_BASE);
xASSERT(((ulChannelTemp >= 0) || (ulChannelTemp <= 3)));
xASSERT(((ulDuty > 0) || (ulDuty <= 100)));
ulCMRData = (xHWREG(ulBase + PWM_CNR0 +(ulChannelTemp * 12)) + 1) *
ulDuty / 100 - 1;
if ((xHWREG(ulBase + PWM_CNR0 +(ulChannelTemp * 12)) + 1) *ulDuty / 100 == 0)
{
ulCMRData = 0;
}
xHWREG(ulBase + PWM_CMR0 +(ulChannelTemp * 12)) = ulCMRData;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Atomically swap in the new signal mask, and wait for a signal. */
|
asmlinkage int sys_sigsuspend(int history0, int history1, old_sigset_t mask)
|
/* Atomically swap in the new signal mask, and wait for a signal. */
asmlinkage int sys_sigsuspend(int history0, int history1, old_sigset_t mask)
|
{
mask &= _BLOCKABLE;
spin_lock_irq(¤t->sighand->siglock);
current->saved_sigmask = current->blocked;
siginitset(¤t->blocked, mask);
recalc_sigpending();
spin_unlock_irq(¤t->sighand->siglock);
current->state = TASK_INTERRUPTIBLE;
schedule();
set_thread_flag(TIF_RESTORE_SIGMASK);
return -ERESTARTNOHAND;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Reset the SATA port. Algorithm follows AHCI spec 1.3.1 section 10.4.2 */
|
EFI_STATUS AhciResetPort(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Port)
|
/* Reset the SATA port. Algorithm follows AHCI spec 1.3.1 section 10.4.2 */
EFI_STATUS AhciResetPort(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Port)
|
{
UINT32 Offset;
EFI_STATUS Status;
Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_SCTL;
AhciOrReg (PciIo, Offset, EFI_AHCI_PORT_SCTL_DET_INIT);
MicroSecondDelay (1000);
AhciAndReg (PciIo, Offset, ~(UINT32)EFI_AHCI_PORT_SSTS_DET_MASK);
Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_SSTS;
Status = AhciWaitMmioSet (PciIo, Offset, EFI_AHCI_PORT_SSTS_DET_MASK, EFI_AHCI_PORT_SSTS_DET_PCE, ATA_ATAPI_TIMEOUT);
if (EFI_ERROR (Status)) {
return Status;
}
return AhciWaitDeviceReady (PciIo, Port);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* pm_runtime_suspend - Carry out run-time suspend of given device. @dev: Device to suspend. */
|
int pm_runtime_suspend(struct device *dev)
|
/* pm_runtime_suspend - Carry out run-time suspend of given device. @dev: Device to suspend. */
int pm_runtime_suspend(struct device *dev)
|
{
int retval;
spin_lock_irq(&dev->power.lock);
retval = __pm_runtime_suspend(dev, false);
spin_unlock_irq(&dev->power.lock);
return retval;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Construct encoded hash EM' wrt PKCSv1.5. This function calculates the pointers for padding, DER value and hash. And finally, constructs EM' which includes hash of complete CSF header and ESBC image. If SG flag is on, hash of SG table and entries is also included. */
|
static void construct_img_encoded_hash_second(struct fsl_secboot_img_priv *img)
|
/* Construct encoded hash EM' wrt PKCSv1.5. This function calculates the pointers for padding, DER value and hash. And finally, constructs EM' which includes hash of complete CSF header and ESBC image. If SG flag is on, hash of SG table and entries is also included. */
static void construct_img_encoded_hash_second(struct fsl_secboot_img_priv *img)
|
{
size_t len;
u8 *representative;
u8 *padding, *digest;
u8 *hash_id, *separator;
int i;
len = (get_key_len(img) / 2) - 1;
representative = img->img_encoded_hash_second;
representative[0] = 0;
representative[1] = 1;
padding = &representative[2];
digest = &representative[1] + len - 32;
hash_id = digest - sizeof(hash_identifier);
separator = hash_id - 1;
memset(padding, 0xff, separator - padding);
*separator = 0;
memcpy(hash_id, hash_identifier, sizeof(hash_identifier));
for (i = 0; i < SHA256_BYTES; i++)
digest[i] = hash_val[i];
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* This function closes a specified file handle. All "dirty" cached file data is flushed to the device, and the file is closed. In all cases the handle is closed. */
|
EFI_STATUS EFIAPI EfiShellClose(IN SHELL_FILE_HANDLE FileHandle)
|
/* This function closes a specified file handle. All "dirty" cached file data is flushed to the device, and the file is closed. In all cases the handle is closed. */
EFI_STATUS EFIAPI EfiShellClose(IN SHELL_FILE_HANDLE FileHandle)
|
{
ShellFileHandleRemove (FileHandle);
return (FileHandleClose (ConvertShellHandleToEfiFileProtocol (FileHandle)));
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Read the ETH DMA Rx Overflow Missed Frame Counter value. */
|
uint32_t ETH_ReadRxOverflowMissedFrameCounter(void)
|
/* Read the ETH DMA Rx Overflow Missed Frame Counter value. */
uint32_t ETH_ReadRxOverflowMissedFrameCounter(void)
|
{
return (uint32_t)(ETH->DMAMFABOCNT_B.AMISFCNT);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Clear one bit of the operational register while keeping other bits. */
|
VOID EhcClearOpRegBit(IN USB2_HC_DEV *Ehc, IN UINT32 Offset, IN UINT32 Bit)
|
/* Clear one bit of the operational register while keeping other bits. */
VOID EhcClearOpRegBit(IN USB2_HC_DEV *Ehc, IN UINT32 Offset, IN UINT32 Bit)
|
{
UINT32 Data;
Data = EhcReadOpReg (Ehc, Offset);
Data &= ~Bit;
EhcWriteOpReg (Ehc, Offset, Data);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This function is intended for SHORT delays only. It will overflow at around 10 seconds @ 400MHz, or 20 seconds @ 200MHz. */
|
unsigned long usec2ticks(unsigned long _usec)
|
/* This function is intended for SHORT delays only. It will overflow at around 10 seconds @ 400MHz, or 20 seconds @ 200MHz. */
unsigned long usec2ticks(unsigned long _usec)
|
{
unsigned long long usec = _usec;
usec *= get_tbclk();
usec += 999999;
do_div(usec, 1000000);
return usec;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Enables or disables the TIM Capture Compare Channel x. */
|
void TIM_CCxCmd(TIM_TypeDef *TIMx, uint16_t TIM_Channel, uint16_t TIM_CCx)
|
/* Enables or disables the TIM Capture Compare Channel x. */
void TIM_CCxCmd(TIM_TypeDef *TIMx, uint16_t TIM_Channel, uint16_t TIM_CCx)
|
{
assert_param(IS_TIM_123458_PERIPH(TIMx));
assert_param(IS_TIM_CHANNEL(TIM_Channel));
assert_param(IS_TIM_CCX(TIM_CCx));
TIMx->CCER &= (uint16_t)(~((uint16_t)(CCER_CCE_Set << TIM_Channel)));
TIMx->CCER |= (uint16_t)(TIM_CCx << TIM_Channel);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* RCC Set the HSE Frequency Divider used as PLL Clock Source. */
|
void rcc_set_pllxtpre(uint32_t pllxtpre)
|
/* RCC Set the HSE Frequency Divider used as PLL Clock Source. */
void rcc_set_pllxtpre(uint32_t pllxtpre)
|
{
RCC_CFGR = (RCC_CFGR & ~RCC_CFGR_PLLXTPRE) |
(pllxtpre << 17);
}
|
insane-adding-machines/unicore-mx
|
C++
|
GNU General Public License v3.0
| 50
|
/* Enables specific module modes for a set of pins. */
|
uint32_t gpio_enable_module(const gpio_map_t gpiomap, uint32_t size)
|
/* Enables specific module modes for a set of pins. */
uint32_t gpio_enable_module(const gpio_map_t gpiomap, uint32_t size)
|
{
uint32_t status = GPIO_SUCCESS;
uint32_t i;
for (i = 0; i < size; i++) {
status |= gpio_enable_module_pin(gpiomap->pin, gpiomap->function);
gpiomap++;
}
return status;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Since this function gets called with the 'nextarg' pointer from within the getparameter a lot, we must check it for NULL before accessing the str data. */
|
ParameterError str2udouble(double *valp, const char *str, long max)
|
/* Since this function gets called with the 'nextarg' pointer from within the getparameter a lot, we must check it for NULL before accessing the str data. */
ParameterError str2udouble(double *valp, const char *str, long max)
|
{
double value;
ParameterError result = str2double(&value, str, max);
if(result != PARAM_OK)
return result;
if(value < 0)
return PARAM_NEGATIVE_NUMERIC;
*valp = value;
return PARAM_OK;
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* Allocates new envlist and returns pointer to that or NULL in case of error. */
|
envlist_t* envlist_create(void)
|
/* Allocates new envlist and returns pointer to that or NULL in case of error. */
envlist_t* envlist_create(void)
|
{
envlist_t *envlist;
if ((envlist = malloc(sizeof (*envlist))) == NULL)
return (NULL);
QLIST_INIT(&envlist->el_entries);
envlist->el_count = 0;
return (envlist);
}
|
ve3wwg/teensy3_qemu
|
C++
|
Other
| 15
|
/* This FILTER_FUNCTION checks if a handle corresponds to a Virtio RNG device at the VIRTIO_DEVICE_PROTOCOL level. */
|
STATIC BOOLEAN EFIAPI IsVirtioRng(IN EFI_HANDLE Handle, IN CONST CHAR16 *ReportText)
|
/* This FILTER_FUNCTION checks if a handle corresponds to a Virtio RNG device at the VIRTIO_DEVICE_PROTOCOL level. */
STATIC BOOLEAN EFIAPI IsVirtioRng(IN EFI_HANDLE Handle, IN CONST CHAR16 *ReportText)
|
{
EFI_STATUS Status;
VIRTIO_DEVICE_PROTOCOL *VirtIo;
Status = gBS->HandleProtocol (
Handle,
&gVirtioDeviceProtocolGuid,
(VOID **)&VirtIo
);
if (EFI_ERROR (Status)) {
return FALSE;
}
return (BOOLEAN)(VirtIo->SubSystemDeviceId ==
VIRTIO_SUBSYSTEM_ENTROPY_SOURCE);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Pop the list of Expression Dependencies from the Stack */
|
EFI_STATUS PopDependencyExpDes(OUT HII_DEPENDENCY_EXPRESSION **Pointer)
|
/* Pop the list of Expression Dependencies from the Stack */
EFI_STATUS PopDependencyExpDes(OUT HII_DEPENDENCY_EXPRESSION **Pointer)
|
{
return PopDependencyStack (
mExpressionDependencyStack,
&mExpressionDependencyPointer,
Pointer
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This function will never return if the verification is failed. */
|
STATIC FV_HASH_INFO* GetHashInfo(IN EDKII_PEI_FIRMWARE_VOLUME_INFO_STORED_HASH_FV_PPI *StoredHashFvPpi, IN EFI_BOOT_MODE BootMode)
|
/* This function will never return if the verification is failed. */
STATIC FV_HASH_INFO* GetHashInfo(IN EDKII_PEI_FIRMWARE_VOLUME_INFO_STORED_HASH_FV_PPI *StoredHashFvPpi, IN EFI_BOOT_MODE BootMode)
|
{
FV_HASH_INFO *HashInfo;
if ((StoredHashFvPpi->HashInfo.HashFlag & FV_HASH_FLAG_BOOT_MODE (BootMode)) != 0) {
HashInfo = &StoredHashFvPpi->HashInfo;
} else {
HashInfo = NULL;
}
return HashInfo;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* What we want from the proc_fs is to be able to efficiently read and write the configuration. To do this, we want to read the configuration when the file is opened and write it when the file is closed. So basically we allocate a read buffer at open and fill it with data, and allocate a write buffer and read it at close. The read routine is generic, it relies on the preallocated rbuffer to supply the data. */
|
static ssize_t proc_read(struct file *file, char __user *buffer, size_t len, loff_t *offset)
|
/* What we want from the proc_fs is to be able to efficiently read and write the configuration. To do this, we want to read the configuration when the file is opened and write it when the file is closed. So basically we allocate a read buffer at open and fill it with data, and allocate a write buffer and read it at close. The read routine is generic, it relies on the preallocated rbuffer to supply the data. */
static ssize_t proc_read(struct file *file, char __user *buffer, size_t len, loff_t *offset)
|
{
struct proc_data *priv = file->private_data;
if (!priv->rbuffer)
return -EINVAL;
return simple_read_from_buffer(buffer, len, offset, priv->rbuffer,
priv->readlen);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* b) Driven by ALI M1543C (southbridge) 2 ISA slots 2 IDE connectors 1 dual drive capable FDD controller 2 serial ports 1 ECP/EPP/SP parallel port 2 USB ports */
|
static void __init nautilus_init_irq(void)
|
/* b) Driven by ALI M1543C (southbridge) 2 ISA slots 2 IDE connectors 1 dual drive capable FDD controller 2 serial ports 1 ECP/EPP/SP parallel port 2 USB ports */
static void __init nautilus_init_irq(void)
|
{
if (alpha_using_srm) {
alpha_mv.device_interrupt = srm_device_interrupt;
}
init_i8259a_irqs();
common_init_isa_dma();
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Enable/disable the 3 wire feature of the specified SPI port. */
|
void SPI3WireFunction(unsigned long ulBase, xtBoolean xtEnable)
|
/* Enable/disable the 3 wire feature of the specified SPI port. */
void SPI3WireFunction(unsigned long ulBase, xtBoolean xtEnable)
|
{
xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)||
(ulBase == SPI2_BASE) || (ulBase == SPI3_BASE));
if (xtEnable)
{
xHWREG(ulBase + SPI_CNTRL2) |= SPI_CNTRL2_NOSLVSEL;
xHWREG(ulBase + SPI_SSR) |= SPI_SS_LTRIG;
}
else
{
xHWREG(ulBase + SPI_CNTRL2) &= ~SPI_CNTRL2_NOSLVSEL;
}
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Save and compile IPv4 options into the request_sock if needed. */
|
static struct ip_options* tcp_v4_save_options(struct sock *sk, struct sk_buff *skb)
|
/* Save and compile IPv4 options into the request_sock if needed. */
static struct ip_options* tcp_v4_save_options(struct sock *sk, struct sk_buff *skb)
|
{
struct ip_options *opt = &(IPCB(skb)->opt);
struct ip_options *dopt = NULL;
if (opt && opt->optlen) {
int opt_size = optlength(opt);
dopt = kmalloc(opt_size, GFP_ATOMIC);
if (dopt) {
if (ip_options_echo(dopt, skb)) {
kfree(dopt);
dopt = NULL;
}
}
}
return dopt;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Erase is an asynchronous operation. Device drivers are supposed to call instr->callback() whenever the operation completes, even if it completes with a failure. Callers are supposed to pass a callback function and wait for it to be called before writing to the block. */
|
int mtd_erase(struct mtd_info *mtd, struct erase_info *instr)
|
/* Erase is an asynchronous operation. Device drivers are supposed to call instr->callback() whenever the operation completes, even if it completes with a failure. Callers are supposed to pass a callback function and wait for it to be called before writing to the block. */
int mtd_erase(struct mtd_info *mtd, struct erase_info *instr)
|
{
if (instr->addr > mtd->size || instr->len > mtd->size - instr->addr)
return -EINVAL;
if (!(mtd->flags & MTD_WRITEABLE))
return -EROFS;
instr->fail_addr = MTD_FAIL_ADDR_UNKNOWN;
if (!instr->len) {
instr->state = MTD_ERASE_DONE;
mtd_erase_callback(instr);
return 0;
}
return mtd->_erase(mtd, instr);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* e1000_alloc_queues - Allocate memory for all rings @adapter: board private structure to initialize */
|
static int __devinit e1000_alloc_queues(struct e1000_adapter *adapter)
|
/* e1000_alloc_queues - Allocate memory for all rings @adapter: board private structure to initialize */
static int __devinit e1000_alloc_queues(struct e1000_adapter *adapter)
|
{
adapter->tx_ring = kzalloc(sizeof(struct e1000_ring), GFP_KERNEL);
if (!adapter->tx_ring)
goto err;
adapter->rx_ring = kzalloc(sizeof(struct e1000_ring), GFP_KERNEL);
if (!adapter->rx_ring)
goto err;
return 0;
err:
e_err("Unable to allocate memory for queues\n");
kfree(adapter->rx_ring);
kfree(adapter->tx_ring);
return -ENOMEM;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Initialize a Timer to emulate an encoder sensor. */
|
static void Init_TIM_Emulator(TIM_HandleTypeDef *htim)
|
/* Initialize a Timer to emulate an encoder sensor. */
static void Init_TIM_Emulator(TIM_HandleTypeDef *htim)
|
{
htim->Instance = TIM3;
htim->Init.Period = EMU_PERIOD;
htim->Init.Prescaler = 0;
htim->Init.ClockDivision = 0;
htim->Init.CounterMode = TIM_COUNTERMODE_UP;
if(HAL_TIM_OC_Init(htim) != HAL_OK)
{
Error_Handler();
}
sConfig.OCMode = TIM_OCMODE_TOGGLE;
sConfig.Pulse = (EMU_PERIOD * 1 )/4;
sConfig.OCPolarity = TIM_OCPOLARITY_LOW;
if(HAL_TIM_OC_ConfigChannel(htim, &sConfig, TIM_CHANNEL_1) != HAL_OK)
{
Error_Handler();
}
sConfig.Pulse = (EMU_PERIOD * 3 )/4;
if(HAL_TIM_OC_ConfigChannel(htim, &sConfig, TIM_CHANNEL_2) != HAL_OK)
{
Error_Handler();
}
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* Create a platform device for the GPI port that receives the image data from the embedded camera. */
|
static int __init sgiwd93_devinit(void)
|
/* Create a platform device for the GPI port that receives the image data from the embedded camera. */
static int __init sgiwd93_devinit(void)
|
{
int res;
sgiwd93_0_pd.hregs = &hpc3c0->scsi_chan0;
sgiwd93_0_pd.wdregs = (unsigned char *) hpc3c0->scsi0_ext;
res = platform_device_register(&sgiwd93_0_device);
if (res)
return res;
if (!ip22_is_fullhouse())
return 0;
sgiwd93_1_pd.hregs = &hpc3c0->scsi_chan1;
sgiwd93_1_pd.wdregs = (unsigned char *) hpc3c0->scsi1_ext;
return platform_device_register(&sgiwd93_1_device);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Clear Stall for USB Device Endpoint Parameters: EPNum: Device Endpoint Number EPNum.0..3: Address EPNum.7: Dir Return Value: None */
|
void USBD_ClrStallEP(U32 EPNum)
|
/* Clear Stall for USB Device Endpoint Parameters: EPNum: Device Endpoint Number EPNum.0..3: Address EPNum.7: Dir Return Value: None */
void USBD_ClrStallEP(U32 EPNum)
|
{
USBD_ResetEP(EPNum);
MXC_USB->ep[EPNum & EPNUM_MASK] &= ~MXC_F_USB_EP_STALL;
}
|
ARMmbed/DAPLink
|
C++
|
Apache License 2.0
| 2,140
|
/* Get the current MCG_Lite LIRC_CLK frequency in Hz.
This function will return the LIRC_CLK value in frequency(Hz) based on current MCG_Lite configurations and settings. It is an internal function. */
|
static uint32_t CLOCK_GetLircClkFreq(void)
|
/* Get the current MCG_Lite LIRC_CLK frequency in Hz.
This function will return the LIRC_CLK value in frequency(Hz) based on current MCG_Lite configurations and settings. It is an internal function. */
static uint32_t CLOCK_GetLircClkFreq(void)
|
{
static const uint32_t lircFreqs[] = {MCG_LIRC_FREQ1, MCG_LIRC_FREQ2};
if ((MCG->C1 & MCG_C1_IRCLKEN_MASK) || (kMCGLITE_ClkSrcLirc == MCG_S_CLKST_VAL))
{
return lircFreqs[MCG_C2_IRCS_VAL];
}
else
{
return 0U;
}
}
|
labapart/polymcu
|
C++
| null | 201
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.