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
|
|---|---|---|---|---|---|---|---|
/* Power down mode wake up event trigger config. */
|
void PWC_PD_SetWakeupTriggerEdge(uint8_t u8Event, uint8_t u8TrigEdge)
|
/* Power down mode wake up event trigger config. */
void PWC_PD_SetWakeupTriggerEdge(uint8_t u8Event, uint8_t u8TrigEdge)
|
{
DDL_ASSERT(IS_PWC_WAKEUP_TRIG_EVT(u8Event));
DDL_ASSERT(IS_PWC_WAKEUP_TRIG(u8TrigEdge));
DDL_ASSERT(IS_PWC_UNLOCKED());
if (PWC_PD_WKUP_TRIG_RISING == u8TrigEdge) {
SET_REG8_BIT(CM_PWC->PDWKES, u8Event);
} else {
CLR_REG8_BIT(CM_PWC->PDWKES, u8Event);
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* De-initialize the TEMP driver.
This will clear all the registered callbacks and disable the EMU IRQ in the NVIC. */
|
Ecode_t TEMPDRV_DeInit(void)
|
/* De-initialize the TEMP driver.
This will clear all the registered callbacks and disable the EMU IRQ in the NVIC. */
Ecode_t TEMPDRV_DeInit(void)
|
{
TEMPDRV_InitState = false;
NVIC_DisableIRQ(EMU_IRQn);
NVIC_ClearPendingIRQ(EMU_IRQn);
disableInterrupts();
memset(tempdrvHighCallbacks, 0, sizeof (TEMPDRV_CallbackSet_t) * TEMPDRV_CALLBACK_DEPTH);
memset(tempdrvLowCallbacks, 0, sizeof (TEMPDRV_CallbackSet_t) * TEMPDRV_CALLBACK_DEPTH);
return ECODE_EMDRV_TEMPDRV_OK;
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* This function is called by ZCL foundation dissector in order to decode */
|
void dissect_zcl_fan_control_attr_data(proto_tree *tree, tvbuff_t *tvb, guint *offset, guint16 attr_id, guint data_type)
|
/* This function is called by ZCL foundation dissector in order to decode */
void dissect_zcl_fan_control_attr_data(proto_tree *tree, tvbuff_t *tvb, guint *offset, guint16 attr_id, guint data_type)
|
{
switch (attr_id) {
case ZBEE_ZCL_ATTR_ID_FAN_CONTROL_FAN_MODE:
proto_tree_add_item(tree, hf_zbee_zcl_fan_control_attr_fan_mode, tvb, *offset, 1, ENC_NA);
*offset += 1;
break;
case ZBEE_ZCL_ATTR_ID_FAN_CONTROL_FAN_MODE_SEQUENCE:
proto_tree_add_item(tree, hf_zbee_zcl_fan_control_attr_fan_mode_seq, tvb, *offset, 1, ENC_NA);
*offset += 1;
break;
default:
dissect_zcl_attr_data(tvb, tree, offset, data_type);
break;
}
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Some times, there is no 1:1 relationship between NET_BLOCK and NET_BLOCK_OP. For example, that in NetbufGetFragment. */
|
VOID NetbufSetBlockOp(IN OUT NET_BUF *Nbuf, IN UINT8 *Bulk, IN UINT32 Len, IN UINT32 Index)
|
/* Some times, there is no 1:1 relationship between NET_BLOCK and NET_BLOCK_OP. For example, that in NetbufGetFragment. */
VOID NetbufSetBlockOp(IN OUT NET_BUF *Nbuf, IN UINT8 *Bulk, IN UINT32 Len, IN UINT32 Index)
|
{
NET_BLOCK_OP *BlockOp;
NET_CHECK_SIGNATURE (Nbuf, NET_BUF_SIGNATURE);
ASSERT (Index < Nbuf->BlockOpNum);
BlockOp = &(Nbuf->BlockOp[Index]);
BlockOp->BlockHead = Bulk;
BlockOp->BlockTail = Bulk + Len;
BlockOp->Head = Bulk;
BlockOp->Tail = Bulk + Len;
BlockOp->Size = Len;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Remove a net buffer from the head in the specific queue and return it. */
|
NET_BUF* EFIAPI NetbufQueRemove(IN OUT NET_BUF_QUEUE *NbufQue)
|
/* Remove a net buffer from the head in the specific queue and return it. */
NET_BUF* EFIAPI NetbufQueRemove(IN OUT NET_BUF_QUEUE *NbufQue)
|
{
NET_BUF *First;
NET_CHECK_SIGNATURE (NbufQue, NET_QUE_SIGNATURE);
if (NbufQue->BufNum == 0) {
return NULL;
}
First = NET_LIST_USER_STRUCT (NbufQue->BufList.ForwardLink, NET_BUF, List);
NetListRemoveHead (&NbufQue->BufList);
NbufQue->BufSize -= First->TotalSize;
NbufQue->BufNum--;
return First;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* STUSB1602 sets the VCONN_UVLO_Threshold Enabling bit (bit6 0x20 */
|
STUSB1602_StatusTypeDef STUSB1602_VCONN_UVLO_Thresh_Status_Set(uint8_t Addr, VCONN_UVLO_Threshold_TypeDef thr)
|
/* STUSB1602 sets the VCONN_UVLO_Threshold Enabling bit (bit6 0x20 */
STUSB1602_StatusTypeDef STUSB1602_VCONN_UVLO_Thresh_Status_Set(uint8_t Addr, VCONN_UVLO_Threshold_TypeDef thr)
|
{
STUSB1602_StatusTypeDef status = STUSB1602_OK;
STUSB1602_VCONN_MONITORING_CTRL_RegTypeDef reg;
STUSB1602_ReadReg(®.d8, Addr, STUSB1602_VCONN_MONITORING_CTRL_REG, 1);
reg.b.VCONN_UVLO_THRESHOLD = thr;
status = STUSB1602_WriteReg(®.d8, Addr, STUSB1602_VCONN_MONITORING_CTRL_REG, 1);
return status;
}
|
st-one/X-CUBE-USB-PD
|
C++
| null | 110
|
/* USB Device Connect Function Called by the User to Connect/Disconnect USB Device Parameters: con: Connect/Disconnect Return Value: None */
|
void USBD_Connect(BOOL con)
|
/* USB Device Connect Function Called by the User to Connect/Disconnect USB Device Parameters: con: Connect/Disconnect Return Value: None */
void USBD_Connect(BOOL con)
|
{
if (con) {
USBHS->USBCMD |= 1;
} else {
USBHS->USBCMD &= ~1;
}
}
|
ARMmbed/DAPLink
|
C++
|
Apache License 2.0
| 2,140
|
/* Port 0x4d0-4d1 are ECLR1 and ECLR2, the Edge/Level Control Registers for the 8259 PIC. bit = 1 means irq is Level, otherwise Edge. ECLR1 is IRQs 0-7 (IRQ 0, 1, 2 must be 0) ECLR2 is IRQs 8-15 (IRQ 8, 13 must be 0) */
|
void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
|
/* Port 0x4d0-4d1 are ECLR1 and ECLR2, the Edge/Level Control Registers for the 8259 PIC. bit = 1 means irq is Level, otherwise Edge. ECLR1 is IRQs 0-7 (IRQ 0, 1, 2 must be 0) ECLR2 is IRQs 8-15 (IRQ 8, 13 must be 0) */
void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
|
{
unsigned int mask = 1 << irq;
unsigned int old, new;
old = inb(0x4d0) | (inb(0x4d1) << 8);
new = acpi_noirq ? old : 0;
switch (trigger) {
case 1:
new &= ~mask;
break;
case 3:
new |= mask;
break;
}
if (old == new)
return;
printk(PREFIX "setting ELCR to %04x (from %04x)\n", new, old);
outb(new, 0x4d0);
outb(new >> 8, 0x4d1);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Initialize a spincollection.
This function initializes a spincollection to which spinners can be added. */
|
void gfx_mono_spinctrl_spincollection_init(struct gfx_mono_spinctrl_spincollection *collection)
|
/* Initialize a spincollection.
This function initializes a spincollection to which spinners can be added. */
void gfx_mono_spinctrl_spincollection_init(struct gfx_mono_spinctrl_spincollection *collection)
|
{
collection->active_spinner = false;
collection->current_selection = 0;
collection->number_of_spinners = 0;
collection->init = true;
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* This function is the entrypoint of NCM Driver. It installs Driver Binding Protocols together with Component Name Protocols. */
|
EFI_STATUS EFIAPI UsbNcmEntry(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
|
/* This function is the entrypoint of NCM Driver. It installs Driver Binding Protocols together with Component Name Protocols. */
EFI_STATUS EFIAPI UsbNcmEntry(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
|
{
gUsbNcmDriverBinding.DriverBindingHandle = ImageHandle;
gUsbNcmDriverBinding.ImageHandle = ImageHandle;
return gBS->InstallMultipleProtocolInterfaces (
&gUsbNcmDriverBinding.DriverBindingHandle,
&gEfiDriverBindingProtocolGuid,
&gUsbNcmDriverBinding,
&gEfiComponentName2ProtocolGuid,
&gUsbNcmComponentName2,
NULL
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* gpio init ,Set the GPC12 as gpio output. */
|
void GPIOInit()
|
/* gpio init ,Set the GPC12 as gpio output. */
void GPIOInit()
|
{
xGPIODirModeSet(GPIO_PORTC_BASE, GPIO_BIT_12, GPIO_DIR_MODE_OUT);
xGPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_12, 1);
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* configure whether next DMA EOT is DMA last transfer or not */
|
void i2c_dma_last_transfer_config(uint32_t i2c_periph, uint32_t dmalast)
|
/* configure whether next DMA EOT is DMA last transfer or not */
void i2c_dma_last_transfer_config(uint32_t i2c_periph, uint32_t dmalast)
|
{
uint32_t ctl = 0U;
ctl = I2C_CTL1(i2c_periph);
ctl &= ~(I2C_CTL1_DMALST);
ctl |= dmalast;
I2C_CTL1(i2c_periph) = ctl;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Write data to the display controller.
This functions sets the pin D/C# before writing to the controller. Different data write function is called based on the selected interface. */
|
void ssd1306_write_data(uint8_t data)
|
/* Write data to the display controller.
This functions sets the pin D/C# before writing to the controller. Different data write function is called based on the selected interface. */
void ssd1306_write_data(uint8_t data)
|
{
spi_select_slave(&ssd1306_master, &ssd1306_slave, true);
port_pin_set_output_level(SSD1306_DC_PIN, true);
spi_write_buffer_wait(&ssd1306_master, &data, 1);
spi_select_slave(&ssd1306_master, &ssd1306_slave, false);
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* param base SPDIF base pointer param handle SPDIF handle pointer. param callback Pointer to the user callback function. param userData User parameter passed to the callback function */
|
void SPDIF_TransferTxCreateHandle(SPDIF_Type *base, spdif_handle_t *handle, spdif_transfer_callback_t callback, void *userData)
|
/* param base SPDIF base pointer param handle SPDIF handle pointer. param callback Pointer to the user callback function. param userData User parameter passed to the callback function */
void SPDIF_TransferTxCreateHandle(SPDIF_Type *base, spdif_handle_t *handle, spdif_transfer_callback_t callback, void *userData)
|
{
assert(handle);
memset(handle, 0, sizeof(*handle));
s_spdifHandle[SPDIF_GetInstance(base)][0] = handle;
handle->callback = callback;
handle->userData = userData;
handle->watermark =
s_spdif_tx_watermark[(base->SCR & SPDIF_SCR_TXFIFOEMPTY_SEL_MASK) >> SPDIF_SCR_TXFIFOEMPTY_SEL_SHIFT];
s_spdifTxIsr = SPDIF_TransferTxHandleIRQ;
EnableIRQ(s_spdifIRQ[SPDIF_GetInstance(base)]);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* __audit_mq_getsetattr - record audit data for a POSIX MQ get/set attribute @mqdes: MQ descriptor @mqstat: MQ flags */
|
void __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat)
|
/* __audit_mq_getsetattr - record audit data for a POSIX MQ get/set attribute @mqdes: MQ descriptor @mqstat: MQ flags */
void __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat)
|
{
struct audit_context *context = current->audit_context;
context->mq_getsetattr.mqdes = mqdes;
context->mq_getsetattr.mqstat = *mqstat;
context->type = AUDIT_MQ_GETSETATTR;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Figure 2-1 in the manual shows 3 chips labeled DAC8800, which are 8-channel 8-bit DACs. These are most likely the calibration DACs. It is not explicitly stated in the manual how to access the caldacs, but we can guess. */
|
static int atao_calib_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
|
/* Figure 2-1 in the manual shows 3 chips labeled DAC8800, which are 8-channel 8-bit DACs. These are most likely the calibration DACs. It is not explicitly stated in the manual how to access the caldacs, but we can guess. */
static int atao_calib_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
|
{
int i;
for (i = 0; i < insn->n; i++)
data[i] = 0;
return insn->n;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* The descend argument controls whether the previous node's last child is considered to be the previous node. The top node argument constrains the walk to the node's children. */
|
mxml_node_t* mxmlWalkPrev(mxml_node_t *node, mxml_node_t *top, int descend)
|
/* The descend argument controls whether the previous node's last child is considered to be the previous node. The top node argument constrains the walk to the node's children. */
mxml_node_t* mxmlWalkPrev(mxml_node_t *node, mxml_node_t *top, int descend)
|
{
if (!node || node == top)
return (NULL);
else if (node->prev)
{
if (node->prev->last_child && descend)
{
node = node->prev->last_child;
while (node->last_child)
node = node->last_child;
return (node);
}
else
return (node->prev);
}
else if (node->parent != top)
return (node->parent);
else
return (NULL);
}
|
DC-SWAT/DreamShell
|
C++
| null | 404
|
/* hmatrix_write_reg - write HMATRIX configuration register @offset: register offset @value: value to be written to the register at @offset */
|
void hmatrix_write_reg(unsigned long offset, u32 value)
|
/* hmatrix_write_reg - write HMATRIX configuration register @offset: register offset @value: value to be written to the register at @offset */
void hmatrix_write_reg(unsigned long offset, u32 value)
|
{
clk_enable(&at32_hmatrix_clk);
__hmatrix_write_reg(offset, value);
__hmatrix_read_reg(offset);
clk_disable(&at32_hmatrix_clk);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Enable speical ADC interrupt. This function can be used to enable ADC convert done interrupt. */
|
void ADCIntEnable(unsigned long ulBase, unsigned long ulChs)
|
/* Enable speical ADC interrupt. This function can be used to enable ADC convert done interrupt. */
void ADCIntEnable(unsigned long ulBase, unsigned long ulChs)
|
{
unsigned long ulTmpReg = 0;
xASSERT(ulBase == ADC_BASE);
xASSERT( (ulChs & ~ADC_CH_M) == 0 );
ulTmpReg = xHWREG(ulBase + AD_INTEN);
ulTmpReg &= ~INTEN_GEN;
ulTmpReg |= ulChs;
xHWREG(ulBase + AD_INTEN) = ulTmpReg;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* This function look up and reads a node which contains name hash in the key. Since the hash may have collisions, there may be many nodes with the same key, so we have to sequentially look to all of them until the needed one is found. This function returns zero in case of success, %-ENOENT if the node was not found, and a negative error code in case of failure. */
|
int ubifs_tnc_lookup_nm(struct ubifs_info *c, const union ubifs_key *key, void *node, const struct qstr *nm)
|
/* This function look up and reads a node which contains name hash in the key. Since the hash may have collisions, there may be many nodes with the same key, so we have to sequentially look to all of them until the needed one is found. This function returns zero in case of success, %-ENOENT if the node was not found, and a negative error code in case of failure. */
int ubifs_tnc_lookup_nm(struct ubifs_info *c, const union ubifs_key *key, void *node, const struct qstr *nm)
|
{
int err, len;
const struct ubifs_dent_node *dent = node;
err = ubifs_tnc_lookup(c, key, node);
if (err)
return err;
len = le16_to_cpu(dent->nlen);
if (nm->len == len && !memcmp(dent->name, nm->name, len))
return 0;
return do_lookup_nm(c, key, node, nm);
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* Check whether USB mouse driver supports this device. */
|
EFI_STATUS EFIAPI USBMouseDriverBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
|
/* Check whether USB mouse driver supports this device. */
EFI_STATUS EFIAPI USBMouseDriverBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
|
{
EFI_STATUS Status;
EFI_USB_IO_PROTOCOL *UsbIo;
Status = gBS->OpenProtocol (
Controller,
&gEfiUsbIoProtocolGuid,
(VOID **)&UsbIo,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (EFI_ERROR (Status)) {
return Status;
}
Status = EFI_SUCCESS;
if (!IsUsbMouse (UsbIo)) {
Status = EFI_UNSUPPORTED;
}
gBS->CloseProtocol (
Controller,
&gEfiUsbIoProtocolGuid,
This->DriverBindingHandle,
Controller
);
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This function converts Tx/Rx rates from the Marvell WLAN format (see Table 2 in Section 3.1) to IEEE80211_RADIOTAP_RATE units (500 Kb/s) */
|
static u8 convert_mv_rate_to_radiotap(u8 rate)
|
/* This function converts Tx/Rx rates from the Marvell WLAN format (see Table 2 in Section 3.1) to IEEE80211_RADIOTAP_RATE units (500 Kb/s) */
static u8 convert_mv_rate_to_radiotap(u8 rate)
|
{
switch (rate) {
case 0:
return 2;
case 1:
return 4;
case 2:
return 11;
case 3:
return 22;
case 5:
return 12;
case 6:
return 18;
case 7:
return 24;
case 8:
return 36;
case 9:
return 48;
case 10:
return 72;
case 11:
return 96;
case 12:
return 108;
}
lbs_pr_alert("Invalid Marvell WLAN rate %i\n", rate);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Returns : OK if exit ccu succeeded, others if failed. */
|
s32 ccu_exit(void)
|
/* Returns : OK if exit ccu succeeded, others if failed. */
s32 ccu_exit(void)
|
{
ccu_pll_c0_cpux_reg_addr = NULL;
ccu_reg_addr = NULL;
ccu_pll_periph0_reg_addr = NULL;
ccu_pll_audio0_reg_addr = NULL;
return OK;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* skip_space - find first non-whitespace in given pointer */
|
static char* skip_space(char *buf)
|
/* skip_space - find first non-whitespace in given pointer */
static char* skip_space(char *buf)
|
{
while (buf[0] == ' ' || buf[0] == '\t')
++buf;
return buf;
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* 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 str2tls_max(long *val, const char *str)
|
/* 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 str2tls_max(long *val, const char *str)
|
{
static struct s_tls_max {
const char *tls_max_str;
long tls_max;
} const tls_max_array[] = {
{ "default", CURL_SSLVERSION_MAX_DEFAULT },
{ "1.0", CURL_SSLVERSION_MAX_TLSv1_0 },
{ "1.1", CURL_SSLVERSION_MAX_TLSv1_1 },
{ "1.2", CURL_SSLVERSION_MAX_TLSv1_2 },
{ "1.3", CURL_SSLVERSION_MAX_TLSv1_3 }
};
size_t i = 0;
if(!str)
return PARAM_REQUIRES_PARAMETER;
for(i = 0; i < sizeof(tls_max_array)/sizeof(tls_max_array[0]); i++) {
if(!strcmp(str, tls_max_array[i].tls_max_str)) {
*val = tls_max_array[i].tls_max;
return PARAM_OK;
}
}
return PARAM_BAD_USE;
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* Returns 0 if successful, or a negative error code on failure. */
|
int snd_ctl_remove_id(struct snd_card *card, struct snd_ctl_elem_id *id)
|
/* Returns 0 if successful, or a negative error code on failure. */
int snd_ctl_remove_id(struct snd_card *card, struct snd_ctl_elem_id *id)
|
{
struct snd_kcontrol *kctl;
int ret;
down_write(&card->controls_rwsem);
kctl = snd_ctl_find_id(card, id);
if (kctl == NULL) {
up_write(&card->controls_rwsem);
return -ENOENT;
}
ret = snd_ctl_remove(card, kctl);
up_write(&card->controls_rwsem);
return ret;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Returns the SNDRV_PCM_RATE_xxx flag that corresponds to the given rate, or SNDRV_PCM_RATE_KNOT for an unknown rate. */
|
unsigned int snd_pcm_rate_to_rate_bit(unsigned int rate)
|
/* Returns the SNDRV_PCM_RATE_xxx flag that corresponds to the given rate, or SNDRV_PCM_RATE_KNOT for an unknown rate. */
unsigned int snd_pcm_rate_to_rate_bit(unsigned int rate)
|
{
unsigned int i;
for (i = 0; i < snd_pcm_known_rates.count; i++)
if (snd_pcm_known_rates.list[i] == rate)
return 1u << i;
return SNDRV_PCM_RATE_KNOT;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* If this interface is not supported, then return FALSE. */
|
BOOLEAN EFIAPI HmacSha256All(IN CONST VOID *Data, IN UINTN DataSize, IN CONST UINT8 *Key, IN UINTN KeySize, OUT UINT8 *HmacValue)
|
/* If this interface is not supported, then return FALSE. */
BOOLEAN EFIAPI HmacSha256All(IN CONST VOID *Data, IN UINTN DataSize, IN CONST UINT8 *Key, IN UINTN KeySize, OUT UINT8 *HmacValue)
|
{
return HmacMdAll (MBEDTLS_MD_SHA256, Data, DataSize, Key, KeySize, HmacValue);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* If we have fewer than thresh credits, extend by EXT3_MAX_TRANS_DATA. If that fails, restart the transaction & regain write access for the buffer head which is used for block_bitmap modifications. */
|
static int extend_or_restart_transaction(handle_t *handle, int thresh, struct buffer_head *bh)
|
/* If we have fewer than thresh credits, extend by EXT3_MAX_TRANS_DATA. If that fails, restart the transaction & regain write access for the buffer head which is used for block_bitmap modifications. */
static int extend_or_restart_transaction(handle_t *handle, int thresh, struct buffer_head *bh)
|
{
int err;
if (handle->h_buffer_credits >= thresh)
return 0;
err = ext3_journal_extend(handle, EXT3_MAX_TRANS_DATA);
if (err < 0)
return err;
if (err) {
err = ext3_journal_restart(handle, EXT3_MAX_TRANS_DATA);
if (err)
return err;
err = ext3_journal_get_write_access(handle, bh);
if (err)
return err;
}
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Converts a text device path node to USB CDC data device path structure. */
|
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextUsbCDCData(IN CHAR16 *TextDeviceNode)
|
/* Converts a text device path node to USB CDC data device path structure. */
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextUsbCDCData(IN CHAR16 *TextDeviceNode)
|
{
USB_CLASS_TEXT UsbClassText;
UsbClassText.ClassExist = FALSE;
UsbClassText.Class = USB_CLASS_CDCDATA;
UsbClassText.SubClassExist = TRUE;
return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Enables or disables the ADCx injected channels conversion through external trigger. */
|
void ADC_EnableExternalTrigInjectedConv(ADC_Module *ADCx, FunctionalState Cmd)
|
/* Enables or disables the ADCx injected channels conversion through external trigger. */
void ADC_EnableExternalTrigInjectedConv(ADC_Module *ADCx, FunctionalState Cmd)
|
{
assert_param(IsAdcModule(ADCx));
assert_param(IS_FUNCTIONAL_STATE(Cmd));
if (Cmd != DISABLE)
{
ADCx->CTRL2 |= CTRL2_INJ_EXT_TRIG_SET;
}
else
{
ADCx->CTRL2 &= CTRL2_INJ_EXT_TRIG_RESET;
}
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* This service is a wrapper for the UEFI Runtime Service SetVariable() */
|
EFI_STATUS EFIAPI InternalSetVariable(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN UINT32 Attributes, IN UINTN DataSize, IN VOID *Data)
|
/* This service is a wrapper for the UEFI Runtime Service SetVariable() */
EFI_STATUS EFIAPI InternalSetVariable(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN UINT32 Attributes, IN UINTN DataSize, IN VOID *Data)
|
{
return mSmmVariable->SmmSetVariable (
VariableName,
VendorGuid,
Attributes,
DataSize,
Data
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Create boot option base on the input file path info. */
|
BOOLEAN EFIAPI CreateBootOptionFromFile(IN EFI_DEVICE_PATH_PROTOCOL *FilePath)
|
/* Create boot option base on the input file path info. */
BOOLEAN EFIAPI CreateBootOptionFromFile(IN EFI_DEVICE_PATH_PROTOCOL *FilePath)
|
{
return ReSendForm (FilePath, FORM_BOOT_ADD_ID);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* An assumption is made that the size of the data is at least the size of struct boot_params. */
|
STATIC EFI_STATUS EFIAPI BasicKernelSetupCheck(IN VOID *KernelSetup)
|
/* An assumption is made that the size of the data is at least the size of struct boot_params. */
STATIC EFI_STATUS EFIAPI BasicKernelSetupCheck(IN VOID *KernelSetup)
|
{
return LoadLinuxCheckKernelSetup (KernelSetup, sizeof (struct boot_params));
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Copy pixels from progmem to the screen.
This function can be used to copy data from program memory (flash) to the display. Limits have to be set prior to calling this function, e.g.: */
|
void hx8347a_copy_progmem_pixels_to_screen(hx8347a_color_t PROGMEM_PTR_T pixels, uint32_t count)
|
/* Copy pixels from progmem to the screen.
This function can be used to copy data from program memory (flash) to the display. Limits have to be set prior to calling this function, e.g.: */
void hx8347a_copy_progmem_pixels_to_screen(hx8347a_color_t PROGMEM_PTR_T pixels, uint32_t count)
|
{
uint32_t byte_count;
uint8_t PROGMEM_PTR_T byte_ptr = (uint8_t PROGMEM_PTR_T)pixels;
Assert(count > 0);
hx8347a_select_register(HX8347A_SRAMWRITE);
hx8347a_select_chip();
hx8347a_send_byte(HX8347A_START_WRITEREG);
byte_count = count * sizeof(hx8347a_color_t);
while (byte_count > 0) {
hx8347a_send_byte(PROGMEM_READ_BYTE(byte_ptr));
byte_count--;
byte_ptr++;
}
hx8347a_deselect_chip();
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Set the IMU-3000 low-pass filter bandwidth.
This routine sets the IMU-3000 low-pass filter bandwidth and the internal sample rate used by the device. This internal sample rate is then further scaled by the sample rate divider (SMPLRT_DIV) value to produce the gyro sample rate according to the formula: */
|
static bool imu3000_set_bandwidth(sensor_hal_t *hal, int16_t band)
|
/* Set the IMU-3000 low-pass filter bandwidth.
This routine sets the IMU-3000 low-pass filter bandwidth and the internal sample rate used by the device. This internal sample rate is then further scaled by the sample rate divider (SMPLRT_DIV) value to produce the gyro sample rate according to the formula: */
static bool imu3000_set_bandwidth(sensor_hal_t *hal, int16_t band)
|
{
sensor_dlpf_cfg = band;
uint8_t const dlpf_fs = (~DLPF_CFG_FIELD) &
sensor_bus_get(hal, IMU3000_DLPF_FS);
sensor_bus_put(hal, IMU3000_DLPF_FS,
dlpf_fs | band_table [sensor_dlpf_cfg].reserved_val);
return true;
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* param base GPIO base pointer. param pin GPIO port pin number. param output GPIOpin output logic level. */
|
void GPIO_PinWrite(GPIO_Type *base, uint32_t pin, uint8_t output)
|
/* param base GPIO base pointer. param pin GPIO port pin number. param output GPIOpin output logic level. */
void GPIO_PinWrite(GPIO_Type *base, uint32_t pin, uint8_t output)
|
{
assert(pin < 32);
if (output == 0U)
{
base->DR &= ~(1U << pin);
}
else
{
base->DR |= (1U << pin);
}
}
|
nanoframework/nf-interpreter
|
C++
|
MIT License
| 293
|
/* ring_buffer_size - return the size of the ring buffer (in bytes) @buffer: The ring buffer. */
|
unsigned long ring_buffer_size(struct ring_buffer *buffer)
|
/* ring_buffer_size - return the size of the ring buffer (in bytes) @buffer: The ring buffer. */
unsigned long ring_buffer_size(struct ring_buffer *buffer)
|
{
return BUF_PAGE_SIZE * buffer->pages;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Invoke writeback_inodes_sb if no writeback is currently underway. Returns 1 if writeback was started, 0 if not. */
|
int writeback_inodes_sb_if_idle(struct super_block *sb)
|
/* Invoke writeback_inodes_sb if no writeback is currently underway. Returns 1 if writeback was started, 0 if not. */
int writeback_inodes_sb_if_idle(struct super_block *sb)
|
{
if (!writeback_in_progress(sb->s_bdi)) {
writeback_inodes_sb(sb);
return 1;
} else
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* param handle codec handle. param cmd module control cmd, reference _codec_module_ctrl_cmd. param data value to write, when cmd is kCODEC_ModuleRecordSourceChannel, the data should be a value combine of channel and source, please reference macro CODEC_MODULE_RECORD_SOURCE_CHANNEL(source, LP, LN, RP, RN), reference codec specific driver for detail configurations. return kStatus_Success is success, else configure failed. */
|
status_t CODEC_ModuleControl(codec_handle_t *handle, codec_module_ctrl_cmd_t cmd, uint32_t data)
|
/* param handle codec handle. param cmd module control cmd, reference _codec_module_ctrl_cmd. param data value to write, when cmd is kCODEC_ModuleRecordSourceChannel, the data should be a value combine of channel and source, please reference macro CODEC_MODULE_RECORD_SOURCE_CHANNEL(source, LP, LN, RP, RN), reference codec specific driver for detail configurations. return kStatus_Success is success, else configure failed. */
status_t CODEC_ModuleControl(codec_handle_t *handle, codec_module_ctrl_cmd_t cmd, uint32_t data)
|
{
assert((handle != NULL) && (handle->codecConfig != NULL));
assert(handle->codecCapability != NULL);
switch (cmd)
{
case kCODEC_ModuleSwitchI2SInInterface:
if ((handle->codecCapability->codecModuleCapability & kCODEC_SupportModuleI2SInSwitchInterface) == 0U)
{
return kStatus_CODEC_NotSupport;
}
break;
default:
return kStatus_CODEC_NotSupport;
}
return HAL_CODEC_ModuleControl(handle, (uint32_t)cmd, data);
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Find the most appropriate command matching the command line */
|
static const iwlist_cmd* find_command(const char *cmd)
|
/* Find the most appropriate command matching the command line */
static const iwlist_cmd* find_command(const char *cmd)
|
{
const iwlist_cmd * found = NULL;
int ambig = 0;
unsigned int len = strlen(cmd);
int i;
for(i = 0; iwlist_cmds[i].cmd != NULL; ++i)
{
if(strncasecmp(iwlist_cmds[i].cmd, cmd, len) != 0)
continue;
if(len == strlen(iwlist_cmds[i].cmd))
return &iwlist_cmds[i];
if(found == NULL)
found = &iwlist_cmds[i];
else
if (iwlist_cmds[i].fn != found->fn)
ambig = 1;
}
if(found == NULL)
{
fprintf(stderr, "iwlist: unknown command `%s' (check 'iwlist --help').\n", cmd);
return NULL;
}
if(ambig)
{
fprintf(stderr, "iwlist: command `%s' is ambiguous (check 'iwlist --help').\n", cmd);
return NULL;
}
return found;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Generate a null RxRPC key that can be used to indicate anonymous security is required for a particular domain. */
|
struct key* rxrpc_get_null_key(const char *keyname)
|
/* Generate a null RxRPC key that can be used to indicate anonymous security is required for a particular domain. */
struct key* rxrpc_get_null_key(const char *keyname)
|
{
const struct cred *cred = current_cred();
struct key *key;
int ret;
key = key_alloc(&key_type_rxrpc, keyname, 0, 0, cred,
KEY_POS_SEARCH, KEY_ALLOC_NOT_IN_QUOTA);
if (IS_ERR(key))
return key;
ret = key_instantiate_and_link(key, NULL, 0, NULL, NULL);
if (ret < 0) {
key_revoke(key);
key_put(key);
return ERR_PTR(ret);
}
return key;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Returns: the found child #GNode, or NULL if the data is not found */
|
GNode* g_node_find_child(GNode *node, GTraverseFlags flags, gpointer data)
|
/* Returns: the found child #GNode, or NULL if the data is not found */
GNode* g_node_find_child(GNode *node, GTraverseFlags flags, gpointer data)
|
{
g_return_val_if_fail (node != NULL, NULL);
g_return_val_if_fail (flags <= G_TRAVERSE_MASK, NULL);
node = node->children;
while (node)
{
if (node->data == data)
{
if (G_NODE_IS_LEAF (node))
{
if (flags & G_TRAVERSE_LEAFS)
return node;
}
else
{
if (flags & G_TRAVERSE_NON_LEAFS)
return node;
}
}
node = node->next;
}
return NULL;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Return: 0 on success or a negative error code on failure. */
|
int mipi_dsi_shutdown_peripheral(struct mipi_dsi_device *dsi)
|
/* Return: 0 on success or a negative error code on failure. */
int mipi_dsi_shutdown_peripheral(struct mipi_dsi_device *dsi)
|
{
struct mipi_dsi_msg msg = {
.channel = dsi->channel,
.type = MIPI_DSI_SHUTDOWN_PERIPHERAL,
.tx_buf = (u8 [2]) { 0, 0 },
.tx_len = 2,
};
int ret = mipi_dsi_device_transfer(dsi, &msg);
return (ret < 0) ? ret : 0;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* This function will look for a signal/event in the SignalReq/ObsEvent string and return true if it is found */
|
static gboolean is_mgcp_signal(const gchar *signal_str_p, const gchar *signalStr)
|
/* This function will look for a signal/event in the SignalReq/ObsEvent string and return true if it is found */
static gboolean is_mgcp_signal(const gchar *signal_str_p, const gchar *signalStr)
|
{
gint i;
gchar **resultArray;
if (signalStr == NULL) return FALSE;
if ( (*signal_str_p == '\0') && (*signalStr == '\0') ) return TRUE;
resultArray = g_strsplit(signalStr, ",", 10);
for (i = 0; resultArray[i]; i++) {
g_strstrip(resultArray[i]);
if (strcmp(resultArray[i], signal_str_p) == 0) return TRUE;
}
g_strfreev(resultArray);
return FALSE;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Initialize all the default core exception handlers.
The core exception handler for each exception id will be initialized to system_default_exception_handler. */
|
static void Exception_Init(void)
|
/* Initialize all the default core exception handlers.
The core exception handler for each exception id will be initialized to system_default_exception_handler. */
static void Exception_Init(void)
|
{
for (int i = 0; i < MAX_SYSTEM_EXCEPTION_NUM + 1; i++) {
SystemExceptionHandlers[i] = (unsigned long)system_default_exception_handler;
}
}
|
prusa3d/Prusa-Firmware-Buddy
|
C++
|
Other
| 1,019
|
/* DeInitializes peripherals used by the I2C EEPROM driver. */
|
void sEE_I2C_LowLevel_DeInit(void)
|
/* DeInitializes peripherals used by the I2C EEPROM driver. */
void sEE_I2C_LowLevel_DeInit(void)
|
{
GPIO_InitTypeDef GPIO_InitStructure;
I2C_Cmd(sEE_I2C, DISABLE);
I2C_DeInit(sEE_I2C);
RCC_APB1PeriphClockCmd(sEE_I2C_CLK, DISABLE);
SYSCFG_I2CFastModePlusConfig(SYSCFG_I2CFastModePlus_I2C2, DISABLE);
GPIO_InitStructure.GPIO_Pin = sEE_I2C_SCL_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(sEE_I2C_SCL_GPIO_PORT, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = sEE_I2C_SDA_PIN;
GPIO_Init(sEE_I2C_SDA_GPIO_PORT, &GPIO_InitStructure);
}
|
avem-labs/Avem
|
C++
|
MIT License
| 1,752
|
/* sunxi_lcd_dsi_gen_short_read1p - generic read with 1 param @screen_id: The index of screen. @paran: Para to be transfer. */
|
s32 sunxi_lcd_dsi_gen_short_read1p(u32 screen_id, u8 para0, u8 *result)
|
/* sunxi_lcd_dsi_gen_short_read1p - generic read with 1 param @screen_id: The index of screen. @paran: Para to be transfer. */
s32 sunxi_lcd_dsi_gen_short_read1p(u32 screen_id, u8 para0, u8 *result)
|
{
u8 tmp[2];
tmp[0] = para0;
sunxi_lcd_dsi_gen_short_read(screen_id, tmp, 1, result);
return -1;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Interrupts Interrupts are handled in the OS/Application layer above this driver. XLlFifo_iRxOccupancy returns the number of 32-bit words available (occupancy) to be read from the receive channel of the FIFO, specified by */
|
xdbg_stmnt(u32 _xllfifo_rr_value;)
|
/* Interrupts Interrupts are handled in the OS/Application layer above this driver. XLlFifo_iRxOccupancy returns the number of 32-bit words available (occupancy) to be read from the receive channel of the FIFO, specified by */
xdbg_stmnt(u32 _xllfifo_rr_value;)
|
{
Xil_AssertNonvoid(InstancePtr);
return XLlFifo_ReadReg(InstancePtr->BaseAddress,
XLLF_RDFO_OFFSET);
}
|
ua1arn/hftrx
|
C++
| null | 69
|
/* Returns a pointer to the menu if successful, or NULL if there is insufficient memory available to create the menu. */
|
struct menu* menu_create(char *title, int timeout, int prompt, void(*item_data_print)(void *), char *(*item_choice)(void *), void *item_choice_data)
|
/* Returns a pointer to the menu if successful, or NULL if there is insufficient memory available to create the menu. */
struct menu* menu_create(char *title, int timeout, int prompt, void(*item_data_print)(void *), char *(*item_choice)(void *), void *item_choice_data)
|
{
struct menu *m;
m = malloc(sizeof *m);
if (!m)
return NULL;
m->default_item = NULL;
m->prompt = prompt;
m->timeout = timeout;
m->item_data_print = item_data_print;
m->item_choice = item_choice;
m->item_choice_data = item_choice_data;
m->item_cnt = 0;
if (title) {
m->title = strdup(title);
if (!m->title) {
free(m);
return NULL;
}
} else
m->title = NULL;
INIT_LIST_HEAD(&m->items);
return m;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Find the configuration item corresponding to the firmware configuration file. */
|
RETURN_STATUS EFIAPI QemuFwCfgFindFile(IN CONST CHAR8 *Name, OUT FIRMWARE_CONFIG_ITEM *Item, OUT UINTN *Size)
|
/* Find the configuration item corresponding to the firmware configuration file. */
RETURN_STATUS EFIAPI QemuFwCfgFindFile(IN CONST CHAR8 *Name, OUT FIRMWARE_CONFIG_ITEM *Item, OUT UINTN *Size)
|
{
UINT32 Count;
UINT32 Idx;
if (!QemuFwCfgIsAvailable ()) {
return RETURN_UNSUPPORTED;
}
QemuFwCfgSelectItem (QemuFwCfgItemFileDir);
Count = SwapBytes32 (QemuFwCfgRead32 ());
for (Idx = 0; Idx < Count; ++Idx) {
UINT32 FileSize;
UINT16 FileSelect;
CHAR8 FName[QEMU_FW_CFG_FNAME_SIZE];
FileSize = QemuFwCfgRead32 ();
FileSelect = QemuFwCfgRead16 ();
QemuFwCfgRead16 ();
InternalQemuFwCfgReadBytes (sizeof (FName), FName);
if (AsciiStrCmp (Name, FName) == 0) {
*Item = (FIRMWARE_CONFIG_ITEM)SwapBytes16 (FileSelect);
*Size = SwapBytes32 (FileSize);
return RETURN_SUCCESS;
}
}
return RETURN_NOT_FOUND;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Close it down - release our resources and go home.. */
|
static void __devexit yenta_close(struct pci_dev *dev)
|
/* Close it down - release our resources and go home.. */
static void __devexit yenta_close(struct pci_dev *dev)
|
{
struct yenta_socket *sock = pci_get_drvdata(dev);
device_remove_file(&dev->dev, &dev_attr_yenta_registers);
pcmcia_unregister_socket(&sock->socket);
cb_writel(sock, CB_SOCKET_MASK, 0x0);
exca_writeb(sock, I365_CSCINT, 0);
if (sock->cb_irq)
free_irq(sock->cb_irq, sock);
else
del_timer_sync(&sock->poll_timer);
if (sock->base)
iounmap(sock->base);
yenta_free_resources(sock);
pci_release_regions(dev);
pci_disable_device(dev);
pci_set_drvdata(dev, NULL);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* strpbrk - Find the first occurrence of a set of characters @cs: The string to be searched @ct: The characters to search for */
|
char* strpbrk(const char *cs, const char *ct)
|
/* strpbrk - Find the first occurrence of a set of characters @cs: The string to be searched @ct: The characters to search for */
char* strpbrk(const char *cs, const char *ct)
|
{
const char *sc1, *sc2;
for (sc1 = cs; *sc1 != '\0'; ++sc1) {
for (sc2 = ct; *sc2 != '\0'; ++sc2) {
if (*sc1 == *sc2)
return (char *)sc1;
}
}
return NULL;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on. */
|
void GPIOPinTypeQEI(unsigned long ulPort, unsigned char ucPins)
|
/* The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on. */
void GPIOPinTypeQEI(unsigned long ulPort, unsigned char ucPins)
|
{
ASSERT(GPIOBaseValid(ulPort));
GPIODirModeSet(ulPort, ucPins, GPIO_DIR_MODE_HW);
GPIOPadConfigSet(ulPort, ucPins, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
}
|
watterott/WebRadio
|
C++
| null | 71
|
/* Reads the E2PROM data into main memory. Ensures that the checksum and header marker are valid. Returns 1 on success -1 on error. */
|
static int initio_se2_rd_all(unsigned long base)
|
/* Reads the E2PROM data into main memory. Ensures that the checksum and header marker are valid. Returns 1 on success -1 on error. */
static int initio_se2_rd_all(unsigned long base)
|
{
int i;
u16 chksum = 0;
u16 *np;
i91unvramp = &i91unvram;
np = (u16 *) i91unvramp;
for (i = 0; i < 32; i++)
*np++ = initio_se2_rd(base, i);
if (i91unvramp->NVM_Signature != INI_SIGNATURE)
return -1;
np = (u16 *) i91unvramp;
for (i = 0; i < 31; i++)
chksum += *np++;
if (i91unvramp->NVM_CheckSum != chksum)
return -1;
return 1;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* clk_disable - inform the system when the clock source is no longer required */
|
void clk_disable(struct clk *clk)
|
/* clk_disable - inform the system when the clock source is no longer required */
void clk_disable(struct clk *clk)
|
{
unsigned long flags;
WARN_ON(clk->enabled == 0);
spin_lock_irqsave(&clocks_lock, flags);
if (--clk->enabled == 0 && clk->clk_disable)
clk->clk_disable(clk);
spin_unlock_irqrestore(&clocks_lock, flags);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Set the input/output data address of a tcw (depending on the value of the r-flag and w-flag). If @use_tidal is non-zero, the corresponding tida flag is set as well. */
|
void tcw_set_data(struct tcw *tcw, void *data, int use_tidal)
|
/* Set the input/output data address of a tcw (depending on the value of the r-flag and w-flag). If @use_tidal is non-zero, the corresponding tida flag is set as well. */
void tcw_set_data(struct tcw *tcw, void *data, int use_tidal)
|
{
if (tcw->r) {
tcw->input = (u64) ((addr_t) data);
if (use_tidal)
tcw->flags |= TCW_FLAGS_INPUT_TIDA;
} else if (tcw->w) {
tcw->output = (u64) ((addr_t) data);
if (use_tidal)
tcw->flags |= TCW_FLAGS_OUTPUT_TIDA;
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* slave mode tx data transmit phase adjust set. */
|
void SPI_SlaveAdjust(SPI_TypeDef *SPIx, uint16_t AdjustValue)
|
/* slave mode tx data transmit phase adjust set. */
void SPI_SlaveAdjust(SPI_TypeDef *SPIx, uint16_t AdjustValue)
|
{
assert_param(IS_SPI_ALL_PERIPH(SPIx));
assert_param(IS_SPI_SlaveAdjust(AdjustValue));
SPIx->CCTL |= AdjustValue;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* param base CMP peripheral base address. param mask Mask value for interrupts. See "_cmp_interrupt_enable". */
|
void CMP_DisableInterrupts(CMP_Type *base, uint32_t mask)
|
/* param base CMP peripheral base address. param mask Mask value for interrupts. See "_cmp_interrupt_enable". */
void CMP_DisableInterrupts(CMP_Type *base, uint32_t mask)
|
{
uint8_t tmp8 = base->SCR & ~(CMP_SCR_CFR_MASK | CMP_SCR_CFF_MASK);
if (0U != (kCMP_OutputRisingInterruptEnable & mask))
{
tmp8 &= ~CMP_SCR_IER_MASK;
}
if (0U != (kCMP_OutputFallingInterruptEnable & mask))
{
tmp8 &= ~CMP_SCR_IEF_MASK;
}
base->SCR = tmp8;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Disables the TPIU.
This function disables the ARM TPIU by disabling the TPIU clock source in MCU control register. */
|
void am_hal_tpiu_disable(void)
|
/* Disables the TPIU.
This function disables the ARM TPIU by disabling the TPIU clock source in MCU control register. */
void am_hal_tpiu_disable(void)
|
{
AM_REG(MCUCTRL, TPIUCTRL) = AM_REG_MCUCTRL_TPIUCTRL_CLKSEL_0MHz |
AM_REG_MCUCTRL_TPIUCTRL_ENABLE_DIS;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Asynchronous write a single char.
Sets up the driver to write the data given. If registered and enabled, a callback function will be called when the transmit is completed. */
|
enum status_code usart_write_job(struct usart_module *const module, const uint16_t *tx_data)
|
/* Asynchronous write a single char.
Sets up the driver to write the data given. If registered and enabled, a callback function will be called when the transmit is completed. */
enum status_code usart_write_job(struct usart_module *const module, const uint16_t *tx_data)
|
{
Assert(module);
Assert(tx_data);
if (!(module->transmitter_enabled)) {
return STATUS_ERR_DENIED;
}
return _usart_write_buffer(module, (uint8_t *)tx_data, 1);
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). */
|
UINT16 EFIAPI PciExpressWrite16(IN UINTN Address, IN UINT16 Value)
|
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). */
UINT16 EFIAPI PciExpressWrite16(IN UINTN Address, IN UINT16 Value)
|
{
ASSERT_INVALID_PCI_ADDRESS (Address);
return MmioWrite16 ((UINTN)GetPciExpressBaseAddress () + Address, Value);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* the caller is responsible for holding the necessary locks. */
|
static int adfs_dir_find_entry(struct adfs_dir *dir, unsigned long object_id)
|
/* the caller is responsible for holding the necessary locks. */
static int adfs_dir_find_entry(struct adfs_dir *dir, unsigned long object_id)
|
{
int pos, ret;
ret = -ENOENT;
for (pos = 5; pos < ADFS_NUM_DIR_ENTRIES * 26 + 5; pos += 26) {
struct object_info obj;
if (!__adfs_dir_get(dir, pos, &obj))
break;
if (obj.file_id == object_id) {
ret = pos;
break;
}
}
return ret;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* RETURN VALUES: next smallest power of 2 number. */
|
static s64 extRoundDown(s64 nb)
|
/* RETURN VALUES: next smallest power of 2 number. */
static s64 extRoundDown(s64 nb)
|
{
int i;
u64 m, k;
for (i = 0, m = (u64) 1 << 63; i < 64; i++, m >>= 1) {
if (m & nb)
break;
}
i = 63 - i;
k = (u64) 1 << i;
k = ((k - 1) & nb) ? k : k >> 1;
return (k);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* The idea is to use this when deciding if you can safely delete an extent from the extent allocation tree. There may be a pending ref in the rbtree that adds or removes references, so as long as this returns one you need to leave the BTRFS_EXTENT_ITEM in the extent allocation tree. */
|
int btrfs_delayed_ref_pending(struct btrfs_trans_handle *trans, u64 bytenr)
|
/* The idea is to use this when deciding if you can safely delete an extent from the extent allocation tree. There may be a pending ref in the rbtree that adds or removes references, so as long as this returns one you need to leave the BTRFS_EXTENT_ITEM in the extent allocation tree. */
int btrfs_delayed_ref_pending(struct btrfs_trans_handle *trans, u64 bytenr)
|
{
struct btrfs_delayed_ref_node *ref;
struct btrfs_delayed_ref_root *delayed_refs;
struct rb_node *prev_node;
int ret = 0;
delayed_refs = &trans->transaction->delayed_refs;
spin_lock(&delayed_refs->lock);
ref = find_ref_head(&delayed_refs->root, bytenr, NULL);
if (ref) {
prev_node = rb_prev(&ref->rb_node);
if (!prev_node)
goto out;
ref = rb_entry(prev_node, struct btrfs_delayed_ref_node,
rb_node);
if (ref->bytenr == bytenr)
ret = 1;
}
out:
spin_unlock(&delayed_refs->lock);
return ret;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* The originating slot should not be part of any active DMA transfer. */
|
void edma_link(unsigned from, unsigned to)
|
/* The originating slot should not be part of any active DMA transfer. */
void edma_link(unsigned from, unsigned to)
|
{
unsigned ctlr_from, ctlr_to;
ctlr_from = EDMA_CTLR(from);
from = EDMA_CHAN_SLOT(from);
ctlr_to = EDMA_CTLR(to);
to = EDMA_CHAN_SLOT(to);
if (from >= edma_info[ctlr_from]->num_slots)
return;
if (to >= edma_info[ctlr_to]->num_slots)
return;
edma_parm_modify(ctlr_from, PARM_LINK_BCNTRLD, from, 0xffff0000,
PARM_OFFSET(to));
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Just keep counting the shared variable up. The control task will suspend this task when it wants. */
|
static portTASK_FUNCTION(vContinuousIncrementTask, pvParameters)
|
/* Just keep counting the shared variable up. The control task will suspend this task when it wants. */
static portTASK_FUNCTION(vContinuousIncrementTask, pvParameters)
|
{
unsigned long *pulCounter;
unsigned portBASE_TYPE uxOurPriority;
pulCounter = ( unsigned long * ) pvParameters;
uxOurPriority = uxTaskPriorityGet( NULL );
for( ;; )
{
vTaskPrioritySet( NULL, uxOurPriority + 1 );
( *pulCounter )++; vTaskPrioritySet( NULL, uxOurPriority );
}
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* show_related_cpus - show the CPUs affected by each transition even if hw coordination is in use */
|
static ssize_t show_related_cpus(struct cpufreq_policy *policy, char *buf)
|
/* show_related_cpus - show the CPUs affected by each transition even if hw coordination is in use */
static ssize_t show_related_cpus(struct cpufreq_policy *policy, char *buf)
|
{
if (cpumask_empty(policy->related_cpus))
return show_cpus(policy->cpus, buf);
return show_cpus(policy->related_cpus, buf);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* The default show function that must be passed to sysfs. This will be called by sysfs for whenever a show function is called by the user on a sysfs file associated with the kobjects we have registered. We need to transpose back from a "default" kobject to our custom struct */
|
static ssize_t foo_attr_show(struct kobject *kobj, struct attribute *attr, char *buf)
|
/* The default show function that must be passed to sysfs. This will be called by sysfs for whenever a show function is called by the user on a sysfs file associated with the kobjects we have registered. We need to transpose back from a "default" kobject to our custom struct */
static ssize_t foo_attr_show(struct kobject *kobj, struct attribute *attr, char *buf)
|
{
struct foo_attribute *attribute;
struct foo_obj *foo;
attribute = to_foo_attr(attr);
foo = to_foo_obj(kobj);
if (!attribute->show)
return -EIO;
return attribute->show(foo, attribute, buf);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Open/create errors are reported with an console message in TFShark. */
|
static void open_failure_message(const char *filename, int err, gboolean for_writing)
|
/* Open/create errors are reported with an console message in TFShark. */
static void open_failure_message(const char *filename, int err, gboolean for_writing)
|
{
fprintf(stderr, "tfshark: ");
fprintf(stderr, file_open_error_message(err, for_writing), filename);
fprintf(stderr, "\n");
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Initialises stuff and adds the entries in the map_entries list to sysfs. Important is that firmware_map_add() and firmware_map_add_early() must be called before late_initcall. That's just because that function is called as late_initcall() function, which means that if you call firmware_map_add() or firmware_map_add_early() afterwards, the entries are not added to sysfs. */
|
static int __init memmap_init(void)
|
/* Initialises stuff and adds the entries in the map_entries list to sysfs. Important is that firmware_map_add() and firmware_map_add_early() must be called before late_initcall. That's just because that function is called as late_initcall() function, which means that if you call firmware_map_add() or firmware_map_add_early() afterwards, the entries are not added to sysfs. */
static int __init memmap_init(void)
|
{
int i = 0;
struct firmware_map_entry *entry;
struct kset *memmap_kset;
memmap_kset = kset_create_and_add("memmap", NULL, firmware_kobj);
if (WARN_ON(!memmap_kset))
return -ENOMEM;
list_for_each_entry(entry, &map_entries, list) {
entry->kobj.kset = memmap_kset;
if (kobject_add(&entry->kobj, NULL, "%d", i++))
kobject_put(&entry->kobj);
}
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* If AP device is still alive, re-schedule request timeout if there are still pending requests. */
|
static void ap_decrease_queue_count(struct ap_device *ap_dev)
|
/* If AP device is still alive, re-schedule request timeout if there are still pending requests. */
static void ap_decrease_queue_count(struct ap_device *ap_dev)
|
{
int timeout = ap_dev->drv->request_timeout;
ap_dev->queue_count--;
if (ap_dev->queue_count > 0)
mod_timer(&ap_dev->timeout, jiffies + timeout);
else
ap_dev->reset = AP_RESET_IGNORE;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* I2C MSP De-Initialization This function freeze the hardware resources used in this example. */
|
void HAL_I2C_MspDeInit(I2C_HandleTypeDef *hi2c)
|
/* I2C MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_I2C_MspDeInit(I2C_HandleTypeDef *hi2c)
|
{
if(hi2c->Instance==I2C2)
{
__HAL_RCC_I2C2_CLK_DISABLE();
HAL_GPIO_DeInit(GPIOF, GPIO_PIN_0);
HAL_GPIO_DeInit(GPIOF, GPIO_PIN_1);
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* param base eDMA peripheral base address. param channel edma channel number. param sourceOffset source address offset. param destOffset destination address offset. */
|
void EDMA_SetMajorOffsetConfig(EDMA_Type *base, uint32_t channel, int32_t sourceOffset, int32_t destOffset)
|
/* param base eDMA peripheral base address. param channel edma channel number. param sourceOffset source address offset. param destOffset destination address offset. */
void EDMA_SetMajorOffsetConfig(EDMA_Type *base, uint32_t channel, int32_t sourceOffset, int32_t destOffset)
|
{
assert(channel < (uint32_t)FSL_FEATURE_EDMA_MODULE_CHANNEL(base));
EDMA_TCD_BASE(base, channel)->SLAST = sourceOffset;
EDMA_TCD_BASE(base, channel)->DLAST_SGA = destOffset;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Performs an atomic decrement operation for semaphore. The compare exchange operation must be performed using MP safe mechanisms. */
|
VOID S3WaitForSemaphore(IN OUT volatile UINT32 *Sem)
|
/* Performs an atomic decrement operation for semaphore. The compare exchange operation must be performed using MP safe mechanisms. */
VOID S3WaitForSemaphore(IN OUT volatile UINT32 *Sem)
|
{
UINT32 Value;
do {
Value = *Sem;
} while (Value == 0 ||
InterlockedCompareExchange32 (
Sem,
Value,
Value - 1
) != Value);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Intialize the memory interface of the IAP API. */
|
status_t MEM_Init(api_core_context_t *coreCtx)
|
/* Intialize the memory interface of the IAP API. */
status_t MEM_Init(api_core_context_t *coreCtx)
|
{
assert(BOOTLOADER_API_TREE_POINTER);
return BOOTLOADER_API_TREE_POINTER->iapAPIDriver->mem_init(coreCtx);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* IOC start called from bfa_start(). Called to start IOC operations at driver instantiation for this instance. */
|
void bfa_iocfc_start(struct bfa_s *bfa)
|
/* IOC start called from bfa_start(). Called to start IOC operations at driver instantiation for this instance. */
void bfa_iocfc_start(struct bfa_s *bfa)
|
{
if (bfa->iocfc.cfgdone)
bfa_iocfc_start_submod(bfa);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* function : wb_ebios_set_reg_base(u32 sel, u32 base) description : setup write-back controller register base parameters : sel <controller select> base <register base> return : success */
|
s32 wb_ebios_set_reg_base(u32 sel, uintptr_t base)
|
/* function : wb_ebios_set_reg_base(u32 sel, u32 base) description : setup write-back controller register base parameters : sel <controller select> base <register base> return : success */
s32 wb_ebios_set_reg_base(u32 sel, uintptr_t base)
|
{
int i = 0;
DE_INF("sel=%d, base=0x%p\n", sel, (void *)(base + WB_OFFSET));
for (i = 0; i < DE_NUM; ++i)
wb_dev[i] = (struct __wb_reg_t *) (base + WB_OFFSET);
return 0;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* There are a number of constraints that must be followed before calling this function: 1) Interrupts must be disabled. 2) The caller must be in 32-bit paged mode. 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode. 4) CR3 must point to valid page tables that guarantee that the pages for this function and the stack are identity mapped. */
|
__declspec(naked)
|
/* There are a number of constraints that must be followed before calling this function: 1) Interrupts must be disabled. 2) The caller must be in 32-bit paged mode. 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode. 4) CR3 must point to valid page tables that guarantee that the pages for this function and the stack are identity mapped. */
__declspec(naked)
|
{
_asm {
push ebp
mov ebp, esp
mov ebx, EntryPoint
mov ecx, Context1
mov edx, Context2
pushfd
pop edi
cli
mov eax, cr0
btr eax, 31
mov esp, NewStack
mov cr0, eax
push edi
popfd
push edx
push ecx
call ebx
jmp $
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Helper method for drivers which want to hardwire 40 wire cable detection. */
|
int ata_cable_40wire(struct ata_port *ap)
|
/* Helper method for drivers which want to hardwire 40 wire cable detection. */
int ata_cable_40wire(struct ata_port *ap)
|
{
return ATA_CBL_PATA40;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* This state is set when a discovered rport is also in intiator mode. This ITN is marked as no_op and is not active and will not be truned into online state. */
|
static void bfa_fcs_itnim_sm_initiator(struct bfa_fcs_itnim_s *itnim, enum bfa_fcs_itnim_event event)
|
/* This state is set when a discovered rport is also in intiator mode. This ITN is marked as no_op and is not active and will not be truned into online state. */
static void bfa_fcs_itnim_sm_initiator(struct bfa_fcs_itnim_s *itnim, enum bfa_fcs_itnim_event event)
|
{
bfa_trc(itnim->fcs, itnim->rport->pwwn);
bfa_trc(itnim->fcs, event);
switch (event) {
case BFA_FCS_ITNIM_SM_OFFLINE:
bfa_sm_set_state(itnim, bfa_fcs_itnim_sm_offline);
bfa_fcs_rport_itnim_ack(itnim->rport);
break;
case BFA_FCS_ITNIM_SM_RSP_ERROR:
case BFA_FCS_ITNIM_SM_ONLINE:
case BFA_FCS_ITNIM_SM_INITIATOR:
break;
case BFA_FCS_ITNIM_SM_DELETE:
bfa_sm_set_state(itnim, bfa_fcs_itnim_sm_offline);
bfa_fcs_itnim_free(itnim);
break;
default:
bfa_assert(0);
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Return 1 if 'key' exists in the dict, 0 otherwise */
|
int qdict_haskey(const QDict *qdict, const char *key)
|
/* Return 1 if 'key' exists in the dict, 0 otherwise */
int qdict_haskey(const QDict *qdict, const char *key)
|
{
unsigned int bucket = tdb_hash(key) % QDICT_BUCKET_MAX;
return (qdict_find(qdict, key, bucket) == NULL ? 0 : 1);
}
|
ve3wwg/teensy3_qemu
|
C++
|
Other
| 15
|
/* Program either using stimecmp (when Sstc extension is enabled) or using SBI TIME call. */
|
STATIC VOID RiscVProgramTimer(UINT64 NextValue)
|
/* Program either using stimecmp (when Sstc extension is enabled) or using SBI TIME call. */
STATIC VOID RiscVProgramTimer(UINT64 NextValue)
|
{
if (mSstcEnabled) {
RiscVSetSupervisorTimeCompareRegister (NextValue);
} else {
SbiSetTimer (NextValue);
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* CPLD_BASE - The virtual address of the base of the CPLD register map */
|
static u8 __cpld_read(unsigned int reg)
|
/* CPLD_BASE - The virtual address of the base of the CPLD register map */
static u8 __cpld_read(unsigned int reg)
|
{
void *p = (void *)CPLD_BASE;
return in_8(p + reg);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* VHPT Instruction Fault @ VHPT Translation vector Refer to SDM Vol2 Table 5-6 & 8-1 */
|
void ivhpt_fault(struct kvm_vcpu *vcpu, u64 vadr)
|
/* VHPT Instruction Fault @ VHPT Translation vector Refer to SDM Vol2 Table 5-6 & 8-1 */
void ivhpt_fault(struct kvm_vcpu *vcpu, u64 vadr)
|
{
_vhpt_fault(vcpu, vadr);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Remote device notification callback, invoked when a remote device sends a notification or indication that a client has registered for. */
|
void btgattc_notify_callback(int conn_id, uint8_t *value, tls_bt_addr_t *bda, uint16_t handle, uint16_t len, uint8_t is_notify)
|
/* Remote device notification callback, invoked when a remote device sends a notification or indication that a client has registered for. */
void btgattc_notify_callback(int conn_id, uint8_t *value, tls_bt_addr_t *bda, uint16_t handle, uint16_t len, uint8_t is_notify)
|
{
int index = -1;
index = get_app_env_index_by_conn_id(conn_id);
if(index<0)
{
TLS_BT_APPL_TRACE_ERROR("%s, is_notify=%d, conn_id=%d,len=%d, handle=%d\r\n", __FUNCTION__, is_notify, conn_id,len, handle);
return;
}
TLS_HAL_CBACK(app_env[index].ps_callbak, notify_cb, conn_id, value, bda, handle, len, is_notify);
}
|
Nicholas3388/LuaNode
|
C++
|
Other
| 1,055
|
/* Get the last touch gesture identification (zoom, move up/down...). */
|
void ft3x67_TS_GetGestureID(uint16_t DeviceAddr, uint32_t *pGestureId)
|
/* Get the last touch gesture identification (zoom, move up/down...). */
void ft3x67_TS_GetGestureID(uint16_t DeviceAddr, uint32_t *pGestureId)
|
{
volatile uint8_t ucReadData = 0U;
ucReadData = TS_IO_Read(DeviceAddr, FT3X67_GEST_ID_REG);
*pGestureId = ucReadData;
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Root, ParentPrefix and SegCount cannot be 0 at the same time. This function works for ASL and AML name strings. */
|
BOOLEAN EFIAPI AmlIsNameString(IN UINT32 Root, IN UINT32 ParentPrefix, IN UINT32 SegCount)
|
/* Root, ParentPrefix and SegCount cannot be 0 at the same time. This function works for ASL and AML name strings. */
BOOLEAN EFIAPI AmlIsNameString(IN UINT32 Root, IN UINT32 ParentPrefix, IN UINT32 SegCount)
|
{
if (((Root == 0) || (Root == 1)) &&
(ParentPrefix <= MAX_UINT8) &&
(!((ParentPrefix != 0) && (Root != 0))) &&
(SegCount <= MAX_UINT8) &&
((SegCount + Root + ParentPrefix) != 0))
{
return TRUE;
}
return FALSE;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Function for reading the tag field of a TLV block from the p_raw_data buffer.
This function reads the tag field containing a TLV block type and inserts its value into a structure pointed by the p_tlv_buf pointer. */
|
static ret_code_t type_2_tag_type_extract(type_2_tag_t *p_type_2_tag, uint8_t *p_raw_data, uint16_t *p_t_offset, tlv_block_t *p_tlv_buf)
|
/* Function for reading the tag field of a TLV block from the p_raw_data buffer.
This function reads the tag field containing a TLV block type and inserts its value into a structure pointed by the p_tlv_buf pointer. */
static ret_code_t type_2_tag_type_extract(type_2_tag_t *p_type_2_tag, uint8_t *p_raw_data, uint16_t *p_t_offset, tlv_block_t *p_tlv_buf)
|
{
if (!type_2_tag_is_field_within_data_range(p_type_2_tag, *p_t_offset, TLV_T_LENGTH))
{
return NRF_ERROR_INVALID_DATA;
}
p_tlv_buf->tag = p_raw_data[*p_t_offset];
*p_t_offset += TLV_T_LENGTH;
return NRF_SUCCESS;
}
|
labapart/polymcu
|
C++
| null | 201
|
/* Check whether current IP is EBC BREAK3 instruction. */
|
BOOLEAN IsEBCBREAK3(IN UINTN Address)
|
/* Check whether current IP is EBC BREAK3 instruction. */
BOOLEAN IsEBCBREAK3(IN UINTN Address)
|
{
if (GET_OPCODE (Address) != OPCODE_BREAK) {
return FALSE;
}
if (GET_OPERANDS (Address) != 3) {
return FALSE;
} else {
return TRUE;
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Append an indication that we were not compiled with WinPcap to a GString. */
|
void get_compiled_caplibs_version(GString *str)
|
/* Append an indication that we were not compiled with WinPcap to a GString. */
void get_compiled_caplibs_version(GString *str)
|
{
g_string_append(str, "without WinPcap");
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Note that passing in INADDR_ANY does not create the same service registration as IN6ADDR_ANY. The former advertises an RPC service on any IPv4 address, but not on IPv6. The latter advertises the service on all IPv4 and IPv6 addresses. */
|
int rpcb_v4_register(const u32 program, const u32 version, const struct sockaddr *address, const char *netid)
|
/* Note that passing in INADDR_ANY does not create the same service registration as IN6ADDR_ANY. The former advertises an RPC service on any IPv4 address, but not on IPv6. The latter advertises the service on all IPv4 and IPv6 addresses. */
int rpcb_v4_register(const u32 program, const u32 version, const struct sockaddr *address, const char *netid)
|
{
struct rpcbind_args map = {
.r_prog = program,
.r_vers = version,
.r_netid = netid,
.r_owner = RPCB_OWNER_STRING,
};
struct rpc_message msg = {
.rpc_argp = &map,
};
int error;
error = rpcb_create_local();
if (error)
return error;
if (rpcb_local_clnt4 == NULL)
return -EPROTONOSUPPORT;
if (address == NULL)
return rpcb_unregister_all_protofamilies(&msg);
switch (address->sa_family) {
case AF_INET:
return rpcb_register_inet4(address, &msg);
case AF_INET6:
return rpcb_register_inet6(address, &msg);
}
return -EAFNOSUPPORT;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Handles an incoming "attribute data" entry from a read-by-type response for the specified read-using-characteristic-uuid proc. */
|
static int ble_gattc_read_uuid_rx_adata(struct ble_gattc_proc *proc, struct ble_att_read_type_adata *adata)
|
/* Handles an incoming "attribute data" entry from a read-by-type response for the specified read-using-characteristic-uuid proc. */
static int ble_gattc_read_uuid_rx_adata(struct ble_gattc_proc *proc, struct ble_att_read_type_adata *adata)
|
{
struct ble_gatt_attr attr;
int rc;
ble_gattc_dbg_assert_proc_not_inserted(proc);
attr.handle = adata->att_handle;
attr.offset = 0;
attr.om = ble_hs_mbuf_from_flat(adata->value, adata->value_len);
if (attr.om == NULL) {
rc = BLE_HS_ENOMEM;
} else {
rc = 0;
}
rc = ble_gattc_read_uuid_cb(proc, rc, 0, &attr);
os_mbuf_free_chain(attr.om);
if (rc != 0) {
return BLE_HS_EDONE;
}
return 0;
}
|
Nicholas3388/LuaNode
|
C++
|
Other
| 1,055
|
/* If Buffer was not allocated with a pool allocation function in the Memory Allocation Library, then ASSERT(). */
|
VOID EFIAPI FreePool(IN VOID *Buffer)
|
/* If Buffer was not allocated with a pool allocation function in the Memory Allocation Library, then ASSERT(). */
VOID EFIAPI FreePool(IN VOID *Buffer)
|
{
EFI_STATUS Status;
if (BufferInSmram (Buffer)) {
Status = gSmst->SmmFreePool (Buffer);
} else {
Status = gBS->FreePool (Buffer);
}
ASSERT_EFI_ERROR (Status);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Allocate @buffer->page if it hasn't been already, then copy the user-supplied buffer into it. */
|
static int fill_write_buffer(struct sysfs_buffer *buffer, const char __user *buf, size_t count)
|
/* Allocate @buffer->page if it hasn't been already, then copy the user-supplied buffer into it. */
static int fill_write_buffer(struct sysfs_buffer *buffer, const char __user *buf, size_t count)
|
{
int error;
if (!buffer->page)
buffer->page = (char *)get_zeroed_page(GFP_KERNEL);
if (!buffer->page)
return -ENOMEM;
if (count >= PAGE_SIZE)
count = PAGE_SIZE - 1;
error = copy_from_user(buffer->page,buf,count);
buffer->needs_read_fill = 1;
buffer->page[count] = 0;
return error ? -EFAULT : count;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Copy data from one mbuf to the end of the other.. if result is too big for one mbuf, malloc() an M_EXT data segment */
|
void m_cat(struct mbuf *m, struct mbuf *n)
|
/* Copy data from one mbuf to the end of the other.. if result is too big for one mbuf, malloc() an M_EXT data segment */
void m_cat(struct mbuf *m, struct mbuf *n)
|
{
if (M_FREEROOM(m) < n->m_len)
m_inc(m,m->m_size+MINCSIZE);
memcpy(m->m_data+m->m_len, n->m_data, n->m_len);
m->m_len += n->m_len;
m_free(n);
}
|
ve3wwg/teensy3_qemu
|
C++
|
Other
| 15
|
/* If Value >= 0xA0, then ASSERT(). If (Value & 0x0F) >= 0x0A, then ASSERT(). */
|
CHAR8 EFIAPI AsciiCharToUpper(IN CHAR8 Chr)
|
/* If Value >= 0xA0, then ASSERT(). If (Value & 0x0F) >= 0x0A, then ASSERT(). */
CHAR8 EFIAPI AsciiCharToUpper(IN CHAR8 Chr)
|
{
return (UINT8)((Chr >= 'a' && Chr <= 'z') ? Chr - ('a' - 'A') : Chr);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* map the specified device/slot/pin to an IRQ. This works out such that slot 9 pin 1 is INT0, pin 2 is INT1, and slot 10 pin 1 is INT1. */
|
static int __init integrator_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
|
/* map the specified device/slot/pin to an IRQ. This works out such that slot 9 pin 1 is INT0, pin 2 is INT1, and slot 10 pin 1 is INT1. */
static int __init integrator_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
|
{
int intnr = ((slot - 9) + (pin - 1)) & 3;
return irq_tab[intnr];
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* If the requested format is supported, configures the HW to use that format, returns error code if format not supported or HW can't be correctly configured. */
|
static int tvp514x_s_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f)
|
/* If the requested format is supported, configures the HW to use that format, returns error code if format not supported or HW can't be correctly configured. */
static int tvp514x_s_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f)
|
{
struct tvp514x_decoder *decoder = to_decoder(sd);
struct v4l2_pix_format *pix;
int rval;
if (f == NULL)
return -EINVAL;
if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
pix = &f->fmt.pix;
rval = tvp514x_try_fmt_cap(sd, f);
if (rval)
return rval;
decoder->pix = *pix;
return rval;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Invoked automatically when device is being removed in response to device_unregister(dev). Release all resources being claimed. */
|
static void release_pcie_device(struct device *dev)
|
/* Invoked automatically when device is being removed in response to device_unregister(dev). Release all resources being claimed. */
static void release_pcie_device(struct device *dev)
|
{
kfree(to_pcie_device(dev));
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.