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
|
|---|---|---|---|---|---|---|---|
/* Update the coalescing settings for an SGE queue set. Nothing is done if the queue set is not initialized yet. */
|
void t3_update_qset_coalesce(struct sge_qset *qs, const struct qset_params *p)
|
/* Update the coalescing settings for an SGE queue set. Nothing is done if the queue set is not initialized yet. */
void t3_update_qset_coalesce(struct sge_qset *qs, const struct qset_params *p)
|
{
qs->rspq.holdoff_tmr = max(p->coalesce_usecs * 10, 1U);
qs->rspq.polling = p->polling;
qs->napi.poll = p->polling ? napi_rx_handler : ofld_poll;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function is called after a PCI bus error affecting this device has been detected. */
|
static pci_ers_result_t vxge_io_error_detected(struct pci_dev *pdev, pci_channel_state_t state)
|
/* This function is called after a PCI bus error affecting this device has been detected. */
static pci_ers_result_t vxge_io_error_detected(struct pci_dev *pdev, pci_channel_state_t state)
|
{
struct __vxge_hw_device *hldev =
(struct __vxge_hw_device *) pci_get_drvdata(pdev);
struct net_device *netdev = hldev->ndev;
netif_device_detach(netdev);
if (state == pci_channel_io_perm_failure)
return PCI_ERS_RESULT_DISCONNECT;
if (netif_running(netdev)) {
do_vxge_close(netdev, 0);
}
pci_disable_device(pdev);
return PCI_ERS_RESULT_NEED_RESET;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* 8.2.5. Get the Current Number of Associations (SCTP_GET_ASSOC_NUMBER) This option gets the current number of associations that are attached to a one-to-many style socket. The option value is an uint32_t. */
|
static int sctp_getsockopt_assoc_number(struct sock *sk, int len, char __user *optval, int __user *optlen)
|
/* 8.2.5. Get the Current Number of Associations (SCTP_GET_ASSOC_NUMBER) This option gets the current number of associations that are attached to a one-to-many style socket. The option value is an uint32_t. */
static int sctp_getsockopt_assoc_number(struct sock *sk, int len, char __user *optval, int __user *optlen)
|
{
struct sctp_sock *sp = sctp_sk(sk);
struct sctp_association *asoc;
u32 val = 0;
if (sctp_style(sk, TCP))
return -EOPNOTSUPP;
if (len < sizeof(u32))
return -EINVAL;
len = sizeof(u32);
list_for_each_entry(asoc, &(sp->ep->asocs), asocs) {
val++;
}
if (put_user(len, optlen))
return -EFAULT;
if (copy_to_user(optval, &val, len))
return -EFAULT;
return 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* For Td guest TDVMCALL_IO is invoked to read I/O port. */
|
UINT8 EFIAPI IoRead8(IN UINTN Port)
|
/* For Td guest TDVMCALL_IO is invoked to read I/O port. */
UINT8 EFIAPI IoRead8(IN UINTN Port)
|
{
UINT8 Data;
BOOLEAN Flag;
Flag = FilterBeforeIoRead (FilterWidth8, Port, &Data);
if (Flag) {
if (IsTdxGuest ()) {
Data = TdIoRead8 (Port);
} else {
__asm__ __volatile__ ("inb %w1,%b0" : "=a" (Data) : "d" ((UINT16)Port));
}
}
FilterAfterIoRead (FilterWidth8, Port, &Data);
return Data;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This procedure runs as a kernel thread to poll the media bay once each tick and register and unregister the IDE interface with the IDE driver. It needs to be a thread because ide_register can't be called from interrupt context. */
|
static int media_bay_task(void *x)
|
/* This procedure runs as a kernel thread to poll the media bay once each tick and register and unregister the IDE interface with the IDE driver. It needs to be a thread because ide_register can't be called from interrupt context. */
static int media_bay_task(void *x)
|
{
int i;
while (!kthread_should_stop()) {
for (i = 0; i < media_bay_count; ++i) {
mutex_lock(&media_bays[i].lock);
if (!media_bays[i].sleeping)
media_bay_step(i);
mutex_unlock(&media_bays[i].lock);
}
msleep_interruptible(MB_POLL_DELAY);
}
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function will register hub class driver to the usb class driver manager. and it should be invoked in the usb system initialization. */
|
ucd_t rt_usbh_class_driver_hub(void)
|
/* This function will register hub class driver to the usb class driver manager. and it should be invoked in the usb system initialization. */
ucd_t rt_usbh_class_driver_hub(void)
|
{
hub_driver.class_code = USB_CLASS_HUB;
hub_driver.enable = rt_usbh_hub_enable;
hub_driver.disable = rt_usbh_hub_disable;
return &hub_driver;
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* Command response callback function for sd_ble_gatts_descriptor_add BLE command.
Callback for decoding the output parameters and the command response return code. */
|
static uint32_t gatts_descriptor_add_rsp_dec(const uint8_t *p_buffer, uint16_t length)
|
/* Command response callback function for sd_ble_gatts_descriptor_add BLE command.
Callback for decoding the output parameters and the command response return code. */
static uint32_t gatts_descriptor_add_rsp_dec(const uint8_t *p_buffer, uint16_t length)
|
{
uint32_t result_code = NRF_SUCCESS;
const uint32_t err_code =
ble_gatts_descriptor_add_rsp_dec(p_buffer,
length,
(uint16_t *) mp_out_params[0],
&result_code);
APP_ERROR_CHECK(err_code);
return result_code;
}
|
labapart/polymcu
|
C++
| null | 201
|
/* Propogate the hardware specific terminal setting bits from the old termios structure to the new one. This is used in cases where the hardware does not support reconfiguration or as a helper in some cases where only minimal reconfiguration is supported */
|
void tty_termios_copy_hw(struct ktermios *new, struct ktermios *old)
|
/* Propogate the hardware specific terminal setting bits from the old termios structure to the new one. This is used in cases where the hardware does not support reconfiguration or as a helper in some cases where only minimal reconfiguration is supported */
void tty_termios_copy_hw(struct ktermios *new, struct ktermios *old)
|
{
new->c_cflag &= HUPCL | CREAD | CLOCAL;
new->c_cflag |= old->c_cflag & ~(HUPCL | CREAD | CLOCAL);
new->c_ispeed = old->c_ispeed;
new->c_ospeed = old->c_ospeed;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function is used to send a high-priority XON/XOFF character to the device */
|
static void uart_send_xchar(struct tty_struct *tty, char ch)
|
/* This function is used to send a high-priority XON/XOFF character to the device */
static void uart_send_xchar(struct tty_struct *tty, char ch)
|
{
struct uart_state *state = tty->driver_data;
struct uart_port *port = state->uart_port;
unsigned long flags;
if (port->ops->send_xchar)
port->ops->send_xchar(port, ch);
else {
port->x_char = ch;
if (ch) {
spin_lock_irqsave(&port->lock, flags);
port->ops->start_tx(port);
spin_unlock_irqrestore(&port->lock, flags);
}
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This helper function reads properties of a LEB @lnum and stores them in @lp. Returns zero in case of success and a negative error code in case of failure. */
|
int ubifs_read_one_lp(struct ubifs_info *c, int lnum, struct ubifs_lprops *lp)
|
/* This helper function reads properties of a LEB @lnum and stores them in @lp. Returns zero in case of success and a negative error code in case of failure. */
int ubifs_read_one_lp(struct ubifs_info *c, int lnum, struct ubifs_lprops *lp)
|
{
int err = 0;
const struct ubifs_lprops *lpp;
ubifs_get_lprops(c);
lpp = ubifs_lpt_lookup(c, lnum);
if (IS_ERR(lpp)) {
err = PTR_ERR(lpp);
goto out;
}
memcpy(lp, lpp, sizeof(struct ubifs_lprops));
out:
ubifs_release_lprops(c);
return err;
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* Clear (release owned resources) and reinitialize a parser context */
|
void xmlClearParserCtxt(xmlParserCtxtPtr ctxt)
|
/* Clear (release owned resources) and reinitialize a parser context */
void xmlClearParserCtxt(xmlParserCtxtPtr ctxt)
|
{
if (ctxt==NULL)
return;
xmlClearNodeInfoSeq(&ctxt->node_seq);
xmlCtxtReset(ctxt);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Must be called when a user of a client is finished with it. */
|
void i2c_release_client(struct i2c_client *client)
|
/* Must be called when a user of a client is finished with it. */
void i2c_release_client(struct i2c_client *client)
|
{
if (client)
put_device(&client->dev);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Converts an 8-bit Hex Char into a INTN. */
|
INTN HexCharToInt(IN CHAR8 Char)
|
/* Converts an 8-bit Hex Char into a INTN. */
INTN HexCharToInt(IN CHAR8 Char)
|
{
if ((Char >= 'A') && (Char <= 'F')) {
return Char - 'A' + 10;
} else if ((Char >= 'a') && (Char <= 'f')) {
return Char - 'a' + 10;
} else if ((Char >= '0') && (Char <= '9')) {
return Char - '0';
} else {
return -1;
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Enables or disables the specified I2C general call feature. */
|
void I2C_GeneralCallCmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
|
/* Enables or disables the specified I2C general call feature. */
void I2C_GeneralCallCmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
|
{
assert_param(IS_I2C_ALL_PERIPH(I2Cx));
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
I2Cx->IC_TAR |= IC_TAR_GC_Set;
}
else
{
I2Cx->IC_TAR &= IC_TAR_GC_Reset;
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Submits the INT request to XHCI Host cotroller */
|
static int _xhci_submit_int_msg(struct usb_device *udev, unsigned long pipe, void *buffer, int length, int interval, bool nonblock)
|
/* Submits the INT request to XHCI Host cotroller */
static int _xhci_submit_int_msg(struct usb_device *udev, unsigned long pipe, void *buffer, int length, int interval, bool nonblock)
|
{
if (usb_pipetype(pipe) != PIPE_INTERRUPT) {
printf("non-interrupt pipe (type=%lu)", usb_pipetype(pipe));
return -EINVAL;
}
return xhci_bulk_tx(udev, pipe, length, buffer);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* This function will handle the uninitalization of any architecture specific callbacks, for dynamic registration and unregistration. */
|
void kgdb_arch_exit(void)
|
/* This function will handle the uninitalization of any architecture specific callbacks, for dynamic registration and unregistration. */
void kgdb_arch_exit(void)
|
{
unregister_undef_hook(&kgdb_brkpt_hook);
unregister_undef_hook(&kgdb_compiled_brkpt_hook);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* For Td guest TDVMCALL_IO is invoked to write I/O port. */
|
UINT16 EFIAPI IoWrite16(IN UINTN Port, IN UINT16 Value)
|
/* For Td guest TDVMCALL_IO is invoked to write I/O port. */
UINT16 EFIAPI IoWrite16(IN UINTN Port, IN UINT16 Value)
|
{
BOOLEAN Flag;
ASSERT ((Port & 1) == 0);
Flag = FilterBeforeIoWrite (FilterWidth16, Port, &Value);
if (Flag) {
if (IsTdxGuest ()) {
TdIoWrite16 (Port, Value);
} else {
_ReadWriteBarrier ();
_outpw ((UINT16)Port, Value);
_ReadWriteBarrier ();
}
}
FilterAfterIoWrite (FilterWidth16, Port, &Value);
return Value;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* If the enable or disable AP operation cannot be completed prior to the return from this service, then EFI_UNSUPPORTED must be returned. */
|
EFI_STATUS EFIAPI EnableDisableAP(IN EFI_MP_SERVICES_PROTOCOL *This, IN UINTN ProcessorNumber, IN BOOLEAN EnableAP, IN UINT32 *HealthFlag OPTIONAL)
|
/* If the enable or disable AP operation cannot be completed prior to the return from this service, then EFI_UNSUPPORTED must be returned. */
EFI_STATUS EFIAPI EnableDisableAP(IN EFI_MP_SERVICES_PROTOCOL *This, IN UINTN ProcessorNumber, IN BOOLEAN EnableAP, IN UINT32 *HealthFlag OPTIONAL)
|
{
return MpInitLibEnableDisableAP (ProcessorNumber, EnableAP, HealthFlag);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This function returns a reference to an XVtc_Config structure based on the core id, */
|
XVtc_Config* XVtc_LookupConfig(u16 DeviceId)
|
/* This function returns a reference to an XVtc_Config structure based on the core id, */
XVtc_Config* XVtc_LookupConfig(u16 DeviceId)
|
{
extern XVtc_Config XVtc_ConfigTable[];
XVtc_Config *CfgPtr = NULL;
int i;
for (i = 0; i < XPAR_XVTC_NUM_INSTANCES; i++) {
if (XVtc_ConfigTable[i].DeviceId == DeviceId) {
CfgPtr = &XVtc_ConfigTable[i];
break;
}
}
return CfgPtr;
}
/** @}
|
ua1arn/hftrx
|
C++
| null | 69
|
/* @osdp: Pointer to structure that will receive the currently selected OSD device. Return: 0 if OK, -ve on error */
|
static int osd_get_osd_cur(struct udevice **osdp)
|
/* @osdp: Pointer to structure that will receive the currently selected OSD device. Return: 0 if OK, -ve on error */
static int osd_get_osd_cur(struct udevice **osdp)
|
{
if (!osd_cur) {
puts("No osd selected\n");
return -ENODEV;
}
*osdp = osd_cur;
return 0;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Reads a block of data from the Si1147 sensor. */
|
uint32_t Si1147_Read_Block_Register(I2C_TypeDef *i2c, uint8_t addr, uint8_t reg, uint8_t length, uint8_t *data)
|
/* Reads a block of data from the Si1147 sensor. */
uint32_t Si1147_Read_Block_Register(I2C_TypeDef *i2c, uint8_t addr, uint8_t reg, uint8_t length, uint8_t *data)
|
{
I2C_TransferSeq_TypeDef seq;
I2C_TransferReturn_TypeDef ret;
uint8_t i2c_write_data[1];
seq.addr = addr;
seq.flags = I2C_FLAG_WRITE_READ;
i2c_write_data[0] = reg;
seq.buf[0].data = i2c_write_data;
seq.buf[0].len = 1;
seq.buf[1].data = data;
seq.buf[1].len = length;
ret = I2CSPM_Transfer(i2c, &seq);
if (ret != i2cTransferDone)
{
return (uint32_t)ret;
}
return (uint32_t)0;
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Use a non standard set_mode function. We don't want to be tuned. The BIOS configured everything. Our job is not to fiddle. We read the dma enabled bits from the PCI configuration of the device and respect them. */
|
static int it821x_smart_set_mode(struct ata_link *link, struct ata_device **unused)
|
/* Use a non standard set_mode function. We don't want to be tuned. The BIOS configured everything. Our job is not to fiddle. We read the dma enabled bits from the PCI configuration of the device and respect them. */
static int it821x_smart_set_mode(struct ata_link *link, struct ata_device **unused)
|
{
struct ata_device *dev;
ata_for_each_dev(dev, link, ENABLED) {
dev->pio_mode = XFER_PIO_0;
dev->dma_mode = XFER_MW_DMA_0;
if (ata_id_has_dma(dev->id)) {
ata_dev_printk(dev, KERN_INFO, "configured for DMA\n");
dev->xfer_mode = XFER_MW_DMA_0;
dev->xfer_shift = ATA_SHIFT_MWDMA;
dev->flags &= ~ATA_DFLAG_PIO;
} else {
ata_dev_printk(dev, KERN_INFO, "configured for PIO\n");
dev->xfer_mode = XFER_PIO_0;
dev->xfer_shift = ATA_SHIFT_PIO;
dev->flags |= ATA_DFLAG_PIO;
}
}
return 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* This function searches config region data to find the begining of the record specified by record_type. If record found, this function return pointer to the record else return NULL. */
|
static uint8_t* lpfc_get_rec_conf23(uint8_t *buff, uint32_t size, uint8_t rec_type)
|
/* This function searches config region data to find the begining of the record specified by record_type. If record found, this function return pointer to the record else return NULL. */
static uint8_t* lpfc_get_rec_conf23(uint8_t *buff, uint32_t size, uint8_t rec_type)
|
{
uint32_t offset = 0, rec_length;
if ((buff[0] == LPFC_REGION23_LAST_REC) ||
(size < sizeof(uint32_t)))
return NULL;
rec_length = buff[offset + 1];
while ((offset + rec_length * sizeof(uint32_t) + sizeof(uint32_t))
<= size) {
if (buff[offset] == rec_type)
return &buff[offset];
if (buff[offset] == LPFC_REGION23_LAST_REC)
return NULL;
offset += rec_length * sizeof(uint32_t) + sizeof(uint32_t);
rec_length = buff[offset + 1];
}
return NULL;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* pwm_auto_point_pwm mapping table: Note that the PWM auto points 0 & 3 are hard-wired in the VT1211 and can't be changed. */
|
static ssize_t show_pwm_auto_point_pwm(struct device *dev, struct device_attribute *attr, char *buf)
|
/* pwm_auto_point_pwm mapping table: Note that the PWM auto points 0 & 3 are hard-wired in the VT1211 and can't be changed. */
static ssize_t show_pwm_auto_point_pwm(struct device *dev, struct device_attribute *attr, char *buf)
|
{
struct vt1211_data *data = vt1211_update_device(dev);
struct sensor_device_attribute_2 *sensor_attr_2 =
to_sensor_dev_attr_2(attr);
int ix = sensor_attr_2->index;
int ap = sensor_attr_2->nr;
return sprintf(buf, "%d\n", data->pwm_auto_pwm[ix][ap]);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* TIM MSP Initialization This function configures the hardware resources used in this example: */
|
void HAL_TIM_OnePulse_MspInit(TIM_HandleTypeDef *htim)
|
/* TIM MSP Initialization This function configures the hardware resources used in this example: */
void HAL_TIM_OnePulse_MspInit(TIM_HandleTypeDef *htim)
|
{
GPIO_InitTypeDef GPIO_InitStruct;
TIMx_CLK_ENABLE();
TIMx_CHANNEL_GPIO_PORT();
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF_TIMx;
GPIO_InitStruct.Pull = GPIO_PUPD_CHANNEL1;
GPIO_InitStruct.Pin = GPIO_PIN_CHANNEL1;
HAL_GPIO_Init(TIMx_GPIO_PORT, &GPIO_InitStruct);
GPIO_InitStruct.Pull = GPIO_PUPD_CHANNEL2;
GPIO_InitStruct.Pin = GPIO_PIN_CHANNEL2;
HAL_GPIO_Init(TIMx_GPIO_PORT, &GPIO_InitStruct);
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* Returns: TRUE if @Ginfo has an attribute named @attribute, FALSE otherwise. */
|
gboolean g_file_info_has_attribute(GFileInfo *info, const char *attribute)
|
/* Returns: TRUE if @Ginfo has an attribute named @attribute, FALSE otherwise. */
gboolean g_file_info_has_attribute(GFileInfo *info, const char *attribute)
|
{
GFileAttributeValue *value;
g_return_val_if_fail (G_IS_FILE_INFO (info), FALSE);
g_return_val_if_fail (attribute != NULL && *attribute != '\0', FALSE);
value = g_file_info_find_value_by_name (info, attribute);
return value != NULL;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Find a available port on a hub; otherwise create one new port */
|
NetClientState* net_hub_port_find(int hub_id)
|
/* Find a available port on a hub; otherwise create one new port */
NetClientState* net_hub_port_find(int hub_id)
|
{
NetHub *hub;
NetHubPort *port;
NetClientState *nc;
QLIST_FOREACH(hub, &hubs, next) {
if (hub->id == hub_id) {
QLIST_FOREACH(port, &hub->ports, next) {
nc = port->nc.peer;
if (!nc) {
return &(port->nc);
}
}
break;
}
}
nc = net_hub_add_port(hub_id, NULL);
return nc;
}
|
ve3wwg/teensy3_qemu
|
C++
|
Other
| 15
|
/* Check whether the string between a pair of % is a valid environment variable name. */
|
BOOLEAN IsValidEnvironmentVariableName(IN CONST CHAR16 *BeginPercent, IN CONST CHAR16 *EndPercent)
|
/* Check whether the string between a pair of % is a valid environment variable name. */
BOOLEAN IsValidEnvironmentVariableName(IN CONST CHAR16 *BeginPercent, IN CONST CHAR16 *EndPercent)
|
{
CONST CHAR16 *Walker;
Walker = NULL;
ASSERT (BeginPercent != NULL);
ASSERT (EndPercent != NULL);
ASSERT (BeginPercent < EndPercent);
if ((BeginPercent + 1) == EndPercent) {
return FALSE;
}
for (Walker = BeginPercent + 1; Walker < EndPercent; Walker++) {
if (
((*Walker >= L'0') && (*Walker <= L'9')) ||
((*Walker >= L'A') && (*Walker <= L'Z')) ||
((*Walker >= L'a') && (*Walker <= L'z')) ||
(*Walker == L'_')
)
{
if ((Walker == BeginPercent + 1) && ((*Walker >= L'0') && (*Walker <= L'9'))) {
return FALSE;
} else {
continue;
}
} else {
return FALSE;
}
}
return TRUE;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Use oprofile_add_data(&entry, val) to add data and oprofile_write_commit(&entry) to commit the sample. */
|
void oprofile_write_reserve(struct op_entry *entry, struct pt_regs *const regs, unsigned long pc, int code, int size)
|
/* Use oprofile_add_data(&entry, val) to add data and oprofile_write_commit(&entry) to commit the sample. */
void oprofile_write_reserve(struct op_entry *entry, struct pt_regs *const regs, unsigned long pc, int code, int size)
|
{
struct op_sample *sample;
int is_kernel = !user_mode(regs);
struct oprofile_cpu_buffer *cpu_buf = &__get_cpu_var(op_cpu_buffer);
cpu_buf->sample_received++;
if (op_add_code(cpu_buf, 0, is_kernel, current))
goto fail;
sample = op_cpu_buffer_write_reserve(entry, size + 2);
if (!sample)
goto fail;
sample->eip = ESCAPE_CODE;
sample->event = 0;
op_cpu_buffer_add_data(entry, code);
op_cpu_buffer_add_data(entry, pc);
return;
fail:
entry->event = NULL;
cpu_buf->sample_lost_overflow++;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* sunxi_lcd_dsi_gen_read - generic short read @screen_id: The index of screen. */
|
static s32 sunxi_lcd_dsi_gen_short_read(u32 screen_id, u8 *para, u8 para_num, u8 *result)
|
/* sunxi_lcd_dsi_gen_read - generic short read @screen_id: The index of screen. */
static s32 sunxi_lcd_dsi_gen_short_read(u32 screen_id, u8 *para, u8 para_num, u8 *result)
|
{
if (g_lcd_drv.src_ops.sunxi_lcd_dsi_gen_short_read)
return g_lcd_drv.src_ops.sunxi_lcd_dsi_gen_short_read(screen_id,
para, para_num,
result);
return -1;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* The constructor function locates PCI Root Bridge I/O protocol from protocol database. It will ASSERT() if that operation fails and it will always return EFI_SUCCESS. */
|
EFI_STATUS EFIAPI PciLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
|
/* The constructor function locates PCI Root Bridge I/O protocol from protocol database. It will ASSERT() if that operation fails and it will always return EFI_SUCCESS. */
EFI_STATUS EFIAPI PciLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
|
{
EFI_STATUS Status;
Status = gBS->LocateProtocol (&gEfiPciRootBridgeIoProtocolGuid, NULL, (VOID **)&mPciRootBridgeIo);
ASSERT_EFI_ERROR (Status);
ASSERT (mPciRootBridgeIo != NULL);
return EFI_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* If 8-bit MMIO register operations are not supported, then ASSERT(). */
|
UINT8 EFIAPI MmioRead8(IN UINTN Address)
|
/* If 8-bit MMIO register operations are not supported, then ASSERT(). */
UINT8 EFIAPI MmioRead8(IN UINTN Address)
|
{
UINT8 Value;
BOOLEAN Flag;
Flag = FilterBeforeMmIoRead (FilterWidth8, Address, &Value);
if (Flag) {
Value = *(volatile UINT8 *)Address;
}
FilterAfterMmIoRead (FilterWidth8, Address, &Value);
return Value;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Our LCD controller task (which is called when we blank or unblank) via keventd. */
|
static void sa1100fb_task(struct work_struct *w)
|
/* Our LCD controller task (which is called when we blank or unblank) via keventd. */
static void sa1100fb_task(struct work_struct *w)
|
{
struct sa1100fb_info *fbi = container_of(w, struct sa1100fb_info, task);
u_int state = xchg(&fbi->task_state, -1);
set_ctrlr_state(fbi, state);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Memory for mmapped videobuf_buffers is not allocated conventionally, but by several kmalloc allocations and then creating the scatterlist on our own. User-space buffers are handled normally. Free the memory-mapped buffer memory allocated for a videobuf_buffer and the associated scatterlist. */
|
static void omap24xxcam_vbq_free_mmap_buffer(struct videobuf_buffer *vb)
|
/* Memory for mmapped videobuf_buffers is not allocated conventionally, but by several kmalloc allocations and then creating the scatterlist on our own. User-space buffers are handled normally. Free the memory-mapped buffer memory allocated for a videobuf_buffer and the associated scatterlist. */
static void omap24xxcam_vbq_free_mmap_buffer(struct videobuf_buffer *vb)
|
{
struct videobuf_dmabuf *dma = videobuf_to_dma(vb);
size_t alloc_size;
struct page *page;
int i;
if (dma->sglist == NULL)
return;
i = dma->sglen;
while (i) {
i--;
alloc_size = sg_dma_len(&dma->sglist[i]);
page = sg_page(&dma->sglist[i]);
do {
ClearPageReserved(page++);
} while (alloc_size -= PAGE_SIZE);
__free_pages(sg_page(&dma->sglist[i]),
get_order(sg_dma_len(&dma->sglist[i])));
}
kfree(dma->sglist);
dma->sglist = NULL;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* see if an authorisation key is associated with a particular key */
|
static int key_get_instantiation_authkey_match(const struct key *key, const void *_id)
|
/* see if an authorisation key is associated with a particular key */
static int key_get_instantiation_authkey_match(const struct key *key, const void *_id)
|
{
struct request_key_auth *rka = key->payload.data;
key_serial_t id = (key_serial_t)(unsigned long) _id;
return rka->target_key->serial == id;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* See the Unified Extensible Firmware Interface (UEFI) specification for details. */
|
static efi_status_t EFIAPI efi_cin_read_key_stroke(struct efi_simple_text_input_protocol *this, struct efi_input_key *key)
|
/* See the Unified Extensible Firmware Interface (UEFI) specification for details. */
static efi_status_t EFIAPI efi_cin_read_key_stroke(struct efi_simple_text_input_protocol *this, struct efi_input_key *key)
|
{
efi_status_t ret = EFI_SUCCESS;
EFI_ENTRY("%p, %p", this, key);
if (!this || !key) {
ret = EFI_INVALID_PARAMETER;
goto out;
}
efi_timer_check();
efi_cin_check();
if (!key_available) {
ret = EFI_NOT_READY;
goto out;
}
*key = next_key.key;
key_available = false;
efi_con_in.wait_for_key->is_signaled = false;
out:
return EFI_EXIT(ret);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Dissect 802.11 with a variable-length link-layer header without qos elements and a pseudo-header containing radio information. */
|
static int dissect_wlan_noqos_radio(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
|
/* Dissect 802.11 with a variable-length link-layer header without qos elements and a pseudo-header containing radio information. */
static int dissect_wlan_noqos_radio(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
|
{
dissect_wlan_radio_phdr (tvb, pinfo, tree, data);
return call_dissector_with_data(ieee80211_noqos_handle, tvb, pinfo, tree, data);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Function indicates success when phy link is available. If phy is not ready within 5 seconds of MAC indicating link, the function returns error. */
|
static s32 ixgbe_validate_link_ready(struct ixgbe_hw *hw)
|
/* Function indicates success when phy link is available. If phy is not ready within 5 seconds of MAC indicating link, the function returns error. */
static s32 ixgbe_validate_link_ready(struct ixgbe_hw *hw)
|
{
u32 timeout;
u16 an_reg;
if (hw->device_id != IXGBE_DEV_ID_82598AT2)
return 0;
for (timeout = 0;
timeout < IXGBE_VALIDATE_LINK_READY_TIMEOUT; timeout++) {
hw->phy.ops.read_reg(hw, MDIO_STAT1, MDIO_MMD_AN, &an_reg);
if ((an_reg & MDIO_AN_STAT1_COMPLETE) &&
(an_reg & MDIO_STAT1_LSTATUS))
break;
msleep(100);
}
if (timeout == IXGBE_VALIDATE_LINK_READY_TIMEOUT) {
hw_dbg(hw, "Link was indicated but link is down\n");
return IXGBE_ERR_LINK_SETUP;
}
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* SMM profile specific INT 1 (single-step) exception handler. */
|
VOID EFIAPI DebugExceptionHandler(IN EFI_EXCEPTION_TYPE InterruptType, IN EFI_SYSTEM_CONTEXT SystemContext)
|
/* SMM profile specific INT 1 (single-step) exception handler. */
VOID EFIAPI DebugExceptionHandler(IN EFI_EXCEPTION_TYPE InterruptType, IN EFI_SYSTEM_CONTEXT SystemContext)
|
{
UINTN CpuIndex;
UINTN PFEntry;
if (!mSmmProfileStart &&
!HEAP_GUARD_NONSTOP_MODE &&
!NULL_DETECTION_NONSTOP_MODE)
{
return;
}
CpuIndex = GetCpuIndex ();
for (PFEntry = 0; PFEntry < mPFEntryCount[CpuIndex]; PFEntry++) {
*mLastPFEntryPointer[CpuIndex][PFEntry] = mLastPFEntryValue[CpuIndex][PFEntry];
}
mPFEntryCount[CpuIndex] = 0;
CpuFlushTlb ();
ClearTrapFlag (SystemContext);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* fifo_icap_start_config - Initiate a configuration (write) to the device. @drvdata: a pointer to the drvdata. */
|
static void fifo_icap_start_config(struct hwicap_drvdata *drvdata)
|
/* fifo_icap_start_config - Initiate a configuration (write) to the device. @drvdata: a pointer to the drvdata. */
static void fifo_icap_start_config(struct hwicap_drvdata *drvdata)
|
{
out_be32(drvdata->base_address + XHI_CR_OFFSET, XHI_CR_WRITE_MASK);
dev_dbg(drvdata->dev, "configuration started\n");
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* lp->indirect_mutex must be held when calling this function */
|
u32 temac_indirect_in32(struct temac_local *lp, int reg)
|
/* lp->indirect_mutex must be held when calling this function */
u32 temac_indirect_in32(struct temac_local *lp, int reg)
|
{
u32 val;
if (temac_indirect_busywait(lp))
return -ETIMEDOUT;
temac_iow(lp, XTE_CTL0_OFFSET, reg);
if (temac_indirect_busywait(lp))
return -ETIMEDOUT;
val = temac_ior(lp, XTE_LSW0_OFFSET);
return val;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Initializes the COMP peripheral according to the specified parameters in COMP_InitStruct. */
|
void COMP_Init(uint32_t COMP_Selection, COMP_InitTypeDef *COMP_InitStruct)
|
/* Initializes the COMP peripheral according to the specified parameters in COMP_InitStruct. */
void COMP_Init(uint32_t COMP_Selection, COMP_InitTypeDef *COMP_InitStruct)
|
{
uint32_t tmpreg = 0;
assert_param(IS_COMP_ALL_PERIPH(COMP_Selection));
assert_param(IS_COMP_INVERTING_INPUT(COMP_InitStruct->COMP_InvertingInput));
assert_param(IS_COMP_OUTPUT(COMP_InitStruct->COMP_Output));
assert_param(IS_COMP_OUTPUT_POL(COMP_InitStruct->COMP_OutputPol));
assert_param(IS_COMP_HYSTERESIS(COMP_InitStruct->COMP_Hysteresis));
assert_param(IS_COMP_MODE(COMP_InitStruct->COMP_Mode));
tmpreg = COMP->CSR;
tmpreg &= (uint32_t) ~(COMP_CSR_CLEAR_MASK<<COMP_Selection);
tmpreg |= (uint32_t)((COMP_InitStruct->COMP_InvertingInput | COMP_InitStruct->COMP_Output |
COMP_InitStruct->COMP_OutputPol | COMP_InitStruct->COMP_Hysteresis |
COMP_InitStruct->COMP_Mode)<<COMP_Selection);
COMP->CSR = tmpreg;
}
|
ajhc/demo-cortex-m3
|
C++
| null | 38
|
/* Get the FMC Read Out Protection Status is set or not. */
|
uint8_t FMC_GetReadProtectionStatus(void)
|
/* Get the FMC Read Out Protection Status is set or not. */
uint8_t FMC_GetReadProtectionStatus(void)
|
{
uint8_t flagstatus = RESET;
if (FMC->OBCS_B.READPROT != RESET)
{
flagstatus = SET;
}
else
{
flagstatus = RESET;
}
return flagstatus;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* This function only works for ASL NameStrings/pathnames. ASL NameStrings/pathnames are at most 4 chars long. */
|
BOOLEAN EFIAPI AslIsNameSeg(IN CONST CHAR8 *AslBuffer, OUT UINT32 *Size)
|
/* This function only works for ASL NameStrings/pathnames. ASL NameStrings/pathnames are at most 4 chars long. */
BOOLEAN EFIAPI AslIsNameSeg(IN CONST CHAR8 *AslBuffer, OUT UINT32 *Size)
|
{
UINT32 Index;
if ((AslBuffer == NULL) ||
(Size == NULL))
{
return FALSE;
}
if (!AmlIsLeadNameChar (AslBuffer[0])) {
return FALSE;
}
for (Index = 1; Index < AML_NAME_SEG_SIZE; Index++) {
if ((AslBuffer[Index] == '.') ||
(AslBuffer[Index] == '\0'))
{
*Size = Index;
return TRUE;
} else if (!AmlIsNameChar (AslBuffer[Index])) {
return FALSE;
}
}
*Size = Index;
return TRUE;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Usb UsbIo interface to clear the feature. This is should only be used by HUB which is considered a device driver on top of the UsbIo interface. */
|
EFI_STATUS UsbIoClearFeature(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINTN Target, IN UINT16 Feature, IN UINT16 Index)
|
/* Usb UsbIo interface to clear the feature. This is should only be used by HUB which is considered a device driver on top of the UsbIo interface. */
EFI_STATUS UsbIoClearFeature(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINTN Target, IN UINT16 Feature, IN UINT16 Index)
|
{
EFI_USB_DEVICE_REQUEST DevReq;
UINT32 UsbResult;
EFI_STATUS Status;
DevReq.RequestType = USB_REQUEST_TYPE (EfiUsbNoData, USB_REQ_TYPE_STANDARD, Target);
DevReq.Request = USB_REQ_CLEAR_FEATURE;
DevReq.Value = Feature;
DevReq.Index = Index;
DevReq.Length = 0;
Status = UsbIo->UsbControlTransfer (
UsbIo,
&DevReq,
EfiUsbNoData,
USB_CLEAR_FEATURE_REQUEST_TIMEOUT,
NULL,
0,
&UsbResult
);
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Enables or disables the specified DMAy Channelx interrupts. */
|
void DMA_ITConfig(DMA_Channel_TypeDef *DMAy_Channelx, uint32_t DMA_IT, FunctionalState NewState)
|
/* Enables or disables the specified DMAy Channelx interrupts. */
void DMA_ITConfig(DMA_Channel_TypeDef *DMAy_Channelx, uint32_t DMA_IT, FunctionalState NewState)
|
{
assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx));
assert_param(IS_DMA_CONFIG_IT(DMA_IT));
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
DMAy_Channelx->CCR |= DMA_IT;
}
else
{
DMAy_Channelx->CCR &= ~DMA_IT;
}
}
|
gcallipo/RadioDSP-Stm32f103
|
C++
|
Common Creative - Attribution 3.0
| 51
|
/* If this service is called from an AP, then EFI_DEVICE_ERROR is returned. If NumberOfProcessors or NumberOfEnabledProcessors is NULL, then EFI_INVALID_PARAMETER is returned. Otherwise, the total number of processors is returned in NumberOfProcessors, the number of currently enabled processor is returned in NumberOfEnabledProcessors, and EFI_SUCCESS is returned. */
|
EFI_STATUS EFIAPI EdkiiPeiGetNumberOfProcessors(IN EDKII_PEI_MP_SERVICES2_PPI *This, OUT UINTN *NumberOfProcessors, OUT UINTN *NumberOfEnabledProcessors)
|
/* If this service is called from an AP, then EFI_DEVICE_ERROR is returned. If NumberOfProcessors or NumberOfEnabledProcessors is NULL, then EFI_INVALID_PARAMETER is returned. Otherwise, the total number of processors is returned in NumberOfProcessors, the number of currently enabled processor is returned in NumberOfEnabledProcessors, and EFI_SUCCESS is returned. */
EFI_STATUS EFIAPI EdkiiPeiGetNumberOfProcessors(IN EDKII_PEI_MP_SERVICES2_PPI *This, OUT UINTN *NumberOfProcessors, OUT UINTN *NumberOfEnabledProcessors)
|
{
if ((NumberOfProcessors == NULL) || (NumberOfEnabledProcessors == NULL)) {
return EFI_INVALID_PARAMETER;
}
return MpInitLibGetNumberOfProcessors (
NumberOfProcessors,
NumberOfEnabledProcessors
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Uart common interrupt process. This need add to uart ISR. */
|
static void uart_isr(struct rt_serial_device *serial)
|
/* Uart common interrupt process. This need add to uart ISR. */
static void uart_isr(struct rt_serial_device *serial)
|
{
RT_ASSERT(serial != RT_NULL);
if (*(char *)(pdev_uart0_state_addr) == pdev_uart0_readbusy_state)
{
rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_IND);
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Converts a text device path node to Serial device path structure. */
|
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextSerial(CHAR16 *TextDeviceNode)
|
/* Converts a text device path node to Serial device path structure. */
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextSerial(CHAR16 *TextDeviceNode)
|
{
return ConvertFromTextAcpi (TextDeviceNode, 0x0501);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Waits for a character from the specified port. */
|
int32_t UARTCharGet(uint32_t ui32Base)
|
/* Waits for a character from the specified port. */
int32_t UARTCharGet(uint32_t ui32Base)
|
{
ASSERT(_UARTBaseValid(ui32Base));
while(HWREG(ui32Base + UART_O_FR) & UART_FR_RXFE)
{
}
return(HWREG(ui32Base + UART_O_DR));
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* The three functions w83697hf_get_reg(), w83697hf_set_reg() and w83697hf_write_timeout() must be called with the device unlocked. */
|
static unsigned char w83697hf_get_reg(unsigned char reg)
|
/* The three functions w83697hf_get_reg(), w83697hf_set_reg() and w83697hf_write_timeout() must be called with the device unlocked. */
static unsigned char w83697hf_get_reg(unsigned char reg)
|
{
outb_p(reg, W83697HF_EFIR);
return inb_p(W83697HF_EFDR);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Fills each SDIO_InitStruct member with its default value. */
|
void SDIO_StructInit(SDIO_InitTypeDef *SDIO_InitStruct)
|
/* Fills each SDIO_InitStruct member with its default value. */
void SDIO_StructInit(SDIO_InitTypeDef *SDIO_InitStruct)
|
{
SDIO_InitStruct->TXBD_BAR = (u32)NULL;
SDIO_InitStruct->TXBD_RING_SIZE = 20;
SDIO_InitStruct->TX_BUFFER_SIZE = 0xFF;
SDIO_InitStruct->RXBD_BAR = (u32)NULL;
SDIO_InitStruct->RXBD_RING_SIZE = 32;
SDIO_InitStruct->RXBD_FREE_TH = 5;
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* This API is used to enable or disable auxiliary Mag in the sensor. */
|
uint16_t bma4_set_mag_enable(uint8_t mag_en, struct bma4_dev *dev)
|
/* This API is used to enable or disable auxiliary Mag in the sensor. */
uint16_t bma4_set_mag_enable(uint8_t mag_en, struct bma4_dev *dev)
|
{
uint16_t rslt = 0;
uint8_t data = 0;
if (dev == NULL) {
rslt |= BMA4_E_NULL_PTR;
} else {
rslt |= bma4_read_regs(BMA4_POWER_CTRL_ADDR, &data, 1, dev);
if (rslt == BMA4_OK) {
data = BMA4_SET_BITS_POS_0(data, BMA4_MAG_ENABLE, mag_en);
rslt |= bma4_write_regs(BMA4_POWER_CTRL_ADDR, &data, 1, dev);
}
}
return rslt;
}
|
arendst/Tasmota
|
C++
|
GNU General Public License v3.0
| 21,318
|
/* wake up the network -> net_device queue. For slaves, wake the corresponding master interface. */
|
static __inline__ void isdn_net_device_wake_queue(isdn_net_local *lp)
|
/* wake up the network -> net_device queue. For slaves, wake the corresponding master interface. */
static __inline__ void isdn_net_device_wake_queue(isdn_net_local *lp)
|
{
if (lp->master)
netif_wake_queue(lp->master);
else
netif_wake_queue(lp->netdev->dev);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* mmc_unregister_driver - unregister a media driver @drv: MMC media driver */
|
void mmc_unregister_driver(struct mmc_driver *drv)
|
/* mmc_unregister_driver - unregister a media driver @drv: MMC media driver */
void mmc_unregister_driver(struct mmc_driver *drv)
|
{
drv->drv.bus = &mmc_bus_type;
driver_unregister(&drv->drv);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Writes NumberOfBytes data bytes from Buffer to the serial device. The number of bytes actually written to the serial device is returned. If the return value is less than NumberOfBytes, then the write operation failed. If Buffer is NULL, then ASSERT(). If NumberOfBytes is zero, then return 0. */
|
UINTN EFIAPI SerialPortWrite(IN UINT8 *Buffer, IN UINTN NumberOfBytes)
|
/* Writes NumberOfBytes data bytes from Buffer to the serial device. The number of bytes actually written to the serial device is returned. If the return value is less than NumberOfBytes, then the write operation failed. If Buffer is NULL, then ASSERT(). If NumberOfBytes is zero, then return 0. */
UINTN EFIAPI SerialPortWrite(IN UINT8 *Buffer, IN UINTN NumberOfBytes)
|
{
XENCONS_RING_IDX Consumer, Producer;
UINTN Sent;
ASSERT (Buffer != NULL);
if (NumberOfBytes == 0) {
return 0;
}
if (!mXenConsoleInterface) {
return 0;
}
Sent = 0;
do {
Consumer = mXenConsoleInterface->out_cons;
Producer = mXenConsoleInterface->out_prod;
MemoryFence ();
while (Sent < NumberOfBytes && ((Producer - Consumer) < sizeof (mXenConsoleInterface->out))) {
mXenConsoleInterface->out[MASK_XENCONS_IDX (Producer++, mXenConsoleInterface->out)] = Buffer[Sent++];
}
MemoryFence ();
mXenConsoleInterface->out_prod = Producer;
XenHypercallEventChannelOp (EVTCHNOP_send, &mXenConsoleEventChain);
} while (Sent < NumberOfBytes);
return Sent;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This function computes the value of the highest bit set in the 32-bit value specified by Operand. If Operand is zero, then zero is returned. */
|
UINT32 EFIAPI GetPowerOfTwo32(IN UINT32 Operand)
|
/* This function computes the value of the highest bit set in the 32-bit value specified by Operand. If Operand is zero, then zero is returned. */
UINT32 EFIAPI GetPowerOfTwo32(IN UINT32 Operand)
|
{
if (0 == Operand) {
return 0;
}
return 1ul << HighBitSet32 (Operand);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* When suspending, the decompressor will back up to a convenient restart point (typically the start of the current MCU). next_input_byte & bytes_in_buffer indicate where the restart point will be if the current call returns FALSE. Data beyond this point must be rescanned after resumption, so move it to the front of the buffer rather than discarding it. */
|
fill_mem_input_buffer(j_decompress_ptr cinfo)
|
/* When suspending, the decompressor will back up to a convenient restart point (typically the start of the current MCU). next_input_byte & bytes_in_buffer indicate where the restart point will be if the current call returns FALSE. Data beyond this point must be rescanned after resumption, so move it to the front of the buffer rather than discarding it. */
fill_mem_input_buffer(j_decompress_ptr cinfo)
|
{
static const JOCTET mybuffer[4] = {
(JOCTET) 0xFF, (JOCTET) JPEG_EOI, 0, 0
};
WARNMS(cinfo, JWRN_JPEG_EOF);
cinfo->src->next_input_byte = mybuffer;
cinfo->src->bytes_in_buffer = 2;
return TRUE;
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). If StartBit is greater than 31, then ASSERT(). If EndBit is greater than 31, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
|
UINT32 EFIAPI PciBitFieldOr32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 OrData)
|
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). If StartBit is greater than 31, then ASSERT(). If EndBit is greater than 31, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT32 EFIAPI PciBitFieldOr32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 OrData)
|
{
return PciWrite32 (
Address,
BitFieldOr32 (PciRead32 (Address), StartBit, EndBit, OrData)
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Allocates and formats a new cluster for use in an indexed dir leaf. This version will not do the extent insert, so that it can be used by operations which need careful ordering. */
|
static int __ocfs2_dx_dir_new_cluster(struct inode *dir, u32 cpos, handle_t *handle, struct ocfs2_alloc_context *data_ac, struct buffer_head **dx_leaves, int num_dx_leaves, u64 *ret_phys_blkno)
|
/* Allocates and formats a new cluster for use in an indexed dir leaf. This version will not do the extent insert, so that it can be used by operations which need careful ordering. */
static int __ocfs2_dx_dir_new_cluster(struct inode *dir, u32 cpos, handle_t *handle, struct ocfs2_alloc_context *data_ac, struct buffer_head **dx_leaves, int num_dx_leaves, u64 *ret_phys_blkno)
|
{
int ret;
u32 phys, num;
u64 phys_blkno;
struct ocfs2_super *osb = OCFS2_SB(dir->i_sb);
ret = __ocfs2_claim_clusters(osb, handle, data_ac, 1, 1, &phys, &num);
if (ret) {
mlog_errno(ret);
goto out;
}
phys_blkno = ocfs2_clusters_to_blocks(osb->sb, phys);
ret = ocfs2_dx_dir_format_cluster(osb, handle, dir, dx_leaves,
num_dx_leaves, phys_blkno);
if (ret) {
mlog_errno(ret);
goto out;
}
*ret_phys_blkno = phys_blkno;
out:
return ret;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* TX_EN GPIO control function.
It sets or reset the TX_EN pin */
|
void STUSB16xx_HW_IF_TX_EN_Status(uint8_t PortNum, GPIO_PinState status)
|
/* TX_EN GPIO control function.
It sets or reset the TX_EN pin */
void STUSB16xx_HW_IF_TX_EN_Status(uint8_t PortNum, GPIO_PinState status)
|
{
HAL_GPIO_WritePin(TX_EN_GPIO_PORT(PortNum), TX_EN_GPIO_PIN(PortNum), status);
}
|
st-one/X-CUBE-USB-PD
|
C++
| null | 110
|
/* Parse incoming frame and find the handler to process the request. */
|
static void usart_frame_parse(uint8_t *buffer, uint8_t size)
|
/* Parse incoming frame and find the handler to process the request. */
static void usart_frame_parse(uint8_t *buffer, uint8_t size)
|
{
if (size == 0) {
return;
}
for (uint32_t i = 0; i < HANDLER_SIZE; i++) {
if (size >= usart_handler[i].min_size &&
!memcmp(usart_handler[i].header, buffer, usart_handler[i].header_size)) {
if (usart_handler[i].handler) {
if ((usart_handler[i].handler(buffer, size)) == 0) {
return;
} else {
break;
}
}
}
}
if (buffer[0] == 0xFF) {
usart_stream_reset();
} else if (buffer[0] != 0x12 && buffer[0] != 0xA5) {
usart_stream_write(0xEA);
usart_stream_reset();
}
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* This function caculate the PM tick from OS tick */
|
static rt_tick_t stm32l4_pm_tick_from_os_tick(rt_tick_t tick)
|
/* This function caculate the PM tick from OS tick */
static rt_tick_t stm32l4_pm_tick_from_os_tick(rt_tick_t tick)
|
{
rt_uint32_t freq = stm32l4_lptim_get_countfreq();
return (freq * tick / RT_TICK_PER_SECOND);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Writes a value to the specified pin(s).
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 GPIOPinWrite(unsigned long ulPort, unsigned long ulPins, unsigned char ucVal)
|
/* Writes a value to the specified pin(s).
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 GPIOPinWrite(unsigned long ulPort, unsigned long ulPins, unsigned char ucVal)
|
{
xASSERT(GPIOBaseValid(ulPort));
xHWREG(ulPort + GPIO_DOUT) = ((ucVal & 1) ?
(xHWREG(ulPort + GPIO_DOUT) | ulPins) :
(xHWREG(ulPort + GPIO_DOUT) & ~(ulPins)));
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Section 4.11.1.1: "All components of all Command and Transfer TRBs shall be initialized to '0'" */
|
static struct xhci_segment* xhci_segment_alloc(struct xhci_hcd *xhci, gfp_t flags)
|
/* Section 4.11.1.1: "All components of all Command and Transfer TRBs shall be initialized to '0'" */
static struct xhci_segment* xhci_segment_alloc(struct xhci_hcd *xhci, gfp_t flags)
|
{
struct xhci_segment *seg;
dma_addr_t dma;
seg = kzalloc(sizeof *seg, flags);
if (!seg)
return 0;
xhci_dbg(xhci, "Allocating priv segment structure at %p\n", seg);
seg->trbs = dma_pool_alloc(xhci->segment_pool, flags, &dma);
if (!seg->trbs) {
kfree(seg);
return 0;
}
xhci_dbg(xhci, "
seg->trbs, (unsigned long long)dma);
memset(seg->trbs, 0, SEGMENT_SIZE);
seg->dma = dma;
seg->next = NULL;
return seg;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Performs a full GC cycle; if 'isemergency', set a flag to avoid some operations which could change the interpreter state in some unexpected ways (running finalizers and shrinking some structures). Before running the collection, check 'keepinvariant'; if it is true, there may be some objects marked as black, so the collector has to sweep all objects to turn them back to white (as white has not changed, nothing will be collected). */
|
void luaC_fullgc(lua_State *L, int isemergency)
|
/* Performs a full GC cycle; if 'isemergency', set a flag to avoid some operations which could change the interpreter state in some unexpected ways (running finalizers and shrinking some structures). Before running the collection, check 'keepinvariant'; if it is true, there may be some objects marked as black, so the collector has to sweep all objects to turn them back to white (as white has not changed, nothing will be collected). */
void luaC_fullgc(lua_State *L, int isemergency)
|
{
entersweep(L);
}
luaC_runtilstate(L, bitmask(GCSpause));
luaC_runtilstate(L, ~bitmask(GCSpause));
luaC_runtilstate(L, bitmask(GCScallfin));
lua_assert(g->GCestimate == gettotalbytes(g));
luaC_runtilstate(L, bitmask(GCSpause));
g->gckind = KGC_NORMAL;
setpause(g);
}
|
nodemcu/nodemcu-firmware
|
C++
|
MIT License
| 7,566
|
/* remove a single leaf ref from the tree. This drops the ref held by the tree only */
|
int btrfs_remove_leaf_ref(struct btrfs_root *root, struct btrfs_leaf_ref *ref)
|
/* remove a single leaf ref from the tree. This drops the ref held by the tree only */
int btrfs_remove_leaf_ref(struct btrfs_root *root, struct btrfs_leaf_ref *ref)
|
{
struct btrfs_leaf_ref_tree *tree;
if (!xchg(&ref->in_tree, 0))
return 0;
tree = ref->tree;
spin_lock(&tree->lock);
rb_erase(&ref->rb_node, &tree->root);
list_del_init(&ref->list);
spin_unlock(&tree->lock);
btrfs_free_leaf_ref(root, ref);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Transmit an amount of data in non-blocking mode with Interrupt. */
|
static void I2S_Transmit_IT(I2S_HandleTypeDef *hi2s)
|
/* Transmit an amount of data in non-blocking mode with Interrupt. */
static void I2S_Transmit_IT(I2S_HandleTypeDef *hi2s)
|
{
uint32_t fifo_count = I2S_FIFO_FULL - __HAL_I2S_GET_TXFIFO(hi2s);
if (fifo_count > hi2s->TxXferCount)
{
fifo_count = hi2s->TxXferCount;
}
while (fifo_count > 0)
{
hi2s->Instance->TXDR = *(hi2s->pTxBuffPtr);
hi2s->pTxBuffPtr++;
hi2s->TxXferCount--;
fifo_count--;
}
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* This routine is called by the kernel after it has written a series of characters to the tty device using put_char(). */
|
static void sclp_tty_flush_chars(struct tty_struct *tty)
|
/* This routine is called by the kernel after it has written a series of characters to the tty device using put_char(). */
static void sclp_tty_flush_chars(struct tty_struct *tty)
|
{
if (sclp_tty_chars_count > 0) {
sclp_tty_write_string(sclp_tty_chars, sclp_tty_chars_count, 0);
sclp_tty_chars_count = 0;
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* hpsb_get_hostinfo_bykey - retrieve a hostinfo pointer by its alternate key */
|
void* hpsb_get_hostinfo_bykey(struct hpsb_highlevel *hl, unsigned long key)
|
/* hpsb_get_hostinfo_bykey - retrieve a hostinfo pointer by its alternate key */
void* hpsb_get_hostinfo_bykey(struct hpsb_highlevel *hl, unsigned long key)
|
{
struct hl_host_info *hi;
void *data = NULL;
if (!hl)
return NULL;
read_lock(&hl->host_info_lock);
list_for_each_entry(hi, &hl->host_info_list, list) {
if (hi->key == key) {
data = hi->data;
break;
}
}
read_unlock(&hl->host_info_lock);
return data;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* param base SAI base pointer param handle SAI eDMA handle pointer. param count Bytes count received by SAI. retval kStatus_Success Succeed get the transfer count. retval kStatus_NoTransferInProgress There is no non-blocking transaction in progress. */
|
status_t SAI_TransferGetReceiveCountEDMA(I2S_Type *base, sai_edma_handle_t *handle, size_t *count)
|
/* param base SAI base pointer param handle SAI eDMA handle pointer. param count Bytes count received by SAI. retval kStatus_Success Succeed get the transfer count. retval kStatus_NoTransferInProgress There is no non-blocking transaction in progress. */
status_t SAI_TransferGetReceiveCountEDMA(I2S_Type *base, sai_edma_handle_t *handle, size_t *count)
|
{
assert(handle);
status_t status = kStatus_Success;
if (handle->state != kSAI_Busy)
{
status = kStatus_NoTransferInProgress;
}
else
{
*count = (handle->transferSize[handle->queueDriver] -
(uint32_t)handle->nbytes *
EDMA_GetRemainingMajorLoopCount(handle->dmaHandle->base, handle->dmaHandle->channel));
}
return status;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Enables or Disables the Precharge of Tamper pin. */
|
void RTC_TamperPullUpCmd(FunctionalState NewState)
|
/* Enables or Disables the Precharge of Tamper pin. */
void RTC_TamperPullUpCmd(FunctionalState NewState)
|
{
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
RTC->TMPCFG &= (uint32_t)~RTC_TMPCFG_TPPUDIS;
}
else
{
RTC->TMPCFG |= (uint32_t)RTC_TMPCFG_TPPUDIS;
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Interrupt handler for legacy INTx interrupts for T3B-based cards. Handles data events from SGE response queues as well as error and other async events as they all use the same interrupt pin. We use one SGE response queue per port in this mode and protect all response queues with queue 0's lock. */
|
static irqreturn_t t3b_intr(int irq, void *cookie)
|
/* Interrupt handler for legacy INTx interrupts for T3B-based cards. Handles data events from SGE response queues as well as error and other async events as they all use the same interrupt pin. We use one SGE response queue per port in this mode and protect all response queues with queue 0's lock. */
static irqreturn_t t3b_intr(int irq, void *cookie)
|
{
u32 map;
struct adapter *adap = cookie;
struct sge_rspq *q0 = &adap->sge.qs[0].rspq;
t3_write_reg(adap, A_PL_CLI, 0);
map = t3_read_reg(adap, A_SG_DATA_INTR);
if (unlikely(!map))
return IRQ_NONE;
spin_lock(&q0->lock);
if (unlikely(map & F_ERRINTR))
t3_slow_intr_handler(adap);
if (likely(map & 1))
process_responses_gts(adap, q0);
if (map & 2)
process_responses_gts(adap, &adap->sge.qs[1].rspq);
spin_unlock(&q0->lock);
return IRQ_HANDLED;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Set relative the position of an object (relative to the parent) */
|
void lv_obj_set_pos(lv_obj_t *obj, lv_coord_t x, lv_coord_t y)
|
/* Set relative the position of an object (relative to the parent) */
void lv_obj_set_pos(lv_obj_t *obj, lv_coord_t x, lv_coord_t y)
|
{
lv_obj_t * par = obj->par;
x = x + par->coords.x1;
y = y + par->coords.y1;
lv_point_t diff;
diff.x = x - obj->coords.x1;
diff.y = y - obj->coords.y1;
if(diff.x == 0 && diff.y == 0) return;
lv_obj_invalidate(obj);
lv_area_t ori;
lv_obj_get_coords(obj, &ori);
obj->coords.x1 += diff.x;
obj->coords.y1 += diff.y;
obj->coords.x2 += diff.x;
obj->coords.y2 += diff.y;
refresh_children_position(obj, diff.x, diff.y);
obj->signal_cb(obj, LV_SIGNAL_CORD_CHG, &ori);
par->signal_cb(par, LV_SIGNAL_CHILD_CHG, obj);
lv_obj_invalidate(obj);
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* this function gets the value of the environment variable set by the ShellSetEnvironmentVariable function */
|
CONST CHAR16* EFIAPI ShellGetEnvironmentVariable(IN CONST CHAR16 *EnvKey)
|
/* this function gets the value of the environment variable set by the ShellSetEnvironmentVariable function */
CONST CHAR16* EFIAPI ShellGetEnvironmentVariable(IN CONST CHAR16 *EnvKey)
|
{
if (gEfiShellProtocol != NULL) {
return (gEfiShellProtocol->GetEnv (EnvKey));
}
if (mEfiShellEnvironment2 != NULL) {
return (mEfiShellEnvironment2->GetEnv ((CHAR16 *)EnvKey));
}
return NULL;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* XXX - should map surrogate errors to REPLACEMENT CHARACTERs (0xFFFD). XXX - should map code points > 10FFFF to REPLACEMENT CHARACTERs. XXX - if there are an odd number of bytes, should put a REPLACEMENT CHARACTER at the end. */
|
static guint8* tvb_get_utf_16_string(wmem_allocator_t *scope, tvbuff_t *tvb, const gint offset, gint length, const guint encoding)
|
/* XXX - should map surrogate errors to REPLACEMENT CHARACTERs (0xFFFD). XXX - should map code points > 10FFFF to REPLACEMENT CHARACTERs. XXX - if there are an odd number of bytes, should put a REPLACEMENT CHARACTER at the end. */
static guint8* tvb_get_utf_16_string(wmem_allocator_t *scope, tvbuff_t *tvb, const gint offset, gint length, const guint encoding)
|
{
const guint8 *ptr;
ptr = ensure_contiguous(tvb, offset, length);
return get_utf_16_string(scope, ptr, length, encoding);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Send lValue to the lPhyReg within the PHY. */
|
static long prvWritePHY(long lPhyReg, long lValue)
|
/* Send lValue to the lPhyReg within the PHY. */
static long prvWritePHY(long lPhyReg, long lValue)
|
{
const long lMaxTime = 10;
long x;
LPC_EMAC->MADR = DP83848C_DEF_ADR | lPhyReg;
LPC_EMAC->MWTD = lValue;
x = 0;
for( x = 0; x < lMaxTime; x++ )
{
if( ( LPC_EMAC->MIND & MIND_BUSY ) == 0 )
{
break;
}
vTaskDelay( emacSHORT_DELAY );
}
if( x < lMaxTime )
{
return pdPASS;
}
else
{
return pdFAIL;
}
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* Add a Driver name selector to a mapping */
|
static int mapping_adddriver(struct if_mapping *ifnode, int *active, char *pos, size_t len, struct add_extra *extra, int linenum)
|
/* Add a Driver name selector to a mapping */
static int mapping_adddriver(struct if_mapping *ifnode, int *active, char *pos, size_t len, struct add_extra *extra, int linenum)
|
{
extra = extra;
if(len >= sizeof(ifnode->driver))
{
fprintf(stderr, "Error: Driver name too long at line %d\n", linenum);
return(-1);
}
memcpy(ifnode->driver, string, len + 1);
ifnode->active[SELECT_DRIVER] = 1;
active[SELECT_DRIVER] = 1;
if(verbose)
fprintf(stderr,
"Parsing : Added Driver name `%s' from line %d.\n",
ifnode->driver, linenum);
return(0);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Allocate a SCB structure. This is the central structure for controller commands. */
|
static scb_t* mega_allocate_scb(adapter_t *adapter, Scsi_Cmnd *cmd)
|
/* Allocate a SCB structure. This is the central structure for controller commands. */
static scb_t* mega_allocate_scb(adapter_t *adapter, Scsi_Cmnd *cmd)
|
{
struct list_head *head = &adapter->free_list;
scb_t *scb;
if( !list_empty(head) ) {
scb = list_entry(head->next, scb_t, list);
list_del_init(head->next);
scb->state = SCB_ACTIVE;
scb->cmd = cmd;
scb->dma_type = MEGA_DMA_TYPE_NONE;
return scb;
}
return NULL;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Setup timer 1 compare match A to generate a tick interrupt. */
|
static void prvSetupTimerInterrupt(void)
|
/* Setup timer 1 compare match A to generate a tick interrupt. */
static void prvSetupTimerInterrupt(void)
|
{
uint32_t ulCompareMatch;
uint8_t ucHighByte, ucLowByte;
ulCompareMatch = configCPU_CLOCK_HZ / configTICK_RATE_HZ;
ulCompareMatch /= portCLOCK_PRESCALER;
ulCompareMatch -= ( uint32_t ) 1;
ucLowByte = ( uint8_t ) ( ulCompareMatch & ( uint32_t ) 0xff );
ulCompareMatch >>= 8;
ucHighByte = ( uint8_t ) ( ulCompareMatch & ( uint32_t ) 0xff );
OCR1AH = ucHighByte;
OCR1AL = ucLowByte;
ucLowByte = portCLEAR_COUNTER_ON_MATCH | portPRESCALE_64;
TCCR1B = ucLowByte;
ucLowByte = TIMSK;
ucLowByte |= portCOMPARE_MATCH_A_INTERRUPT_ENABLE;
TIMSK = ucLowByte;
}
|
labapart/polymcu
|
C++
| null | 201
|
/* Get a anonymous page for the mapping. Make sure we can DMA to that memory location with 32bit PCI devices (i.e. don't use highmem for now ...). Bounce buffers don't work very well for the data rates video capture has. */
|
static int videobuf_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
|
/* Get a anonymous page for the mapping. Make sure we can DMA to that memory location with 32bit PCI devices (i.e. don't use highmem for now ...). Bounce buffers don't work very well for the data rates video capture has. */
static int videobuf_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
|
{
struct page *page;
dprintk(3,"fault: fault @ %08lx [vma %08lx-%08lx]\n",
(unsigned long)vmf->virtual_address,vma->vm_start,vma->vm_end);
page = alloc_page(GFP_USER | __GFP_DMA32);
if (!page)
return VM_FAULT_OOM;
clear_user_highpage(page, (unsigned long)vmf->virtual_address);
vmf->page = page;
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Set the position of an area (width and height will be kept) */
|
void lv_area_set_pos(lv_area_t *area_p, lv_coord_t x, lv_coord_t y)
|
/* Set the position of an area (width and height will be kept) */
void lv_area_set_pos(lv_area_t *area_p, lv_coord_t x, lv_coord_t y)
|
{
lv_coord_t w = lv_area_get_width(area_p);
lv_coord_t h = lv_area_get_height(area_p);
area_p->x1 = x;
area_p->y1 = y;
lv_area_set_width(area_p, w);
lv_area_set_height(area_p, h);
}
|
RavenSystem/esp-homekit-devices
|
C++
|
Other
| 2,577
|
/* It checks if VBus is present or not. */
|
USBPD_FunctionalState HW_IF_Check_VBus(uint8_t PortNum)
|
/* It checks if VBus is present or not. */
USBPD_FunctionalState HW_IF_Check_VBus(uint8_t PortNum)
|
{
return ((STUSB1602_VBUS_Presence_Get(STUSB1602_I2C_Add(PortNum)) == VBUS_above_UVLO_threshold) ? USBPD_ENABLE : USBPD_DISABLE);
}
|
st-one/X-CUBE-USB-PD
|
C++
| null | 110
|
/* Returns the matched pxa_ep structure or NULL if none found */
|
static struct pxa_ep* find_pxa_ep(struct pxa_udc *udc, struct udc_usb_ep *udc_usb_ep)
|
/* Returns the matched pxa_ep structure or NULL if none found */
static struct pxa_ep* find_pxa_ep(struct pxa_udc *udc, struct udc_usb_ep *udc_usb_ep)
|
{
int i;
struct pxa_ep *ep;
int cfg = udc->config;
int iface = udc->last_interface;
int alt = udc->last_alternate;
if (udc_usb_ep == &udc->udc_usb_ep[0])
return &udc->pxa_ep[0];
for (i = 1; i < NR_PXA_ENDPOINTS; i++) {
ep = &udc->pxa_ep[i];
if (is_match_usb_pxa(udc_usb_ep, ep, cfg, iface, alt))
return ep;
}
return NULL;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function returns a code that indicates whether the scan should continue (LPT_SCAN_CONTINUE), whether the LEB properties should be added to the tree in main memory (LPT_SCAN_ADD), or whether the scan should stop (LPT_SCAN_STOP). */
|
static int scan_for_idx_cb(struct ubifs_info *c, const struct ubifs_lprops *lprops, int in_tree, struct scan_data *data)
|
/* This function returns a code that indicates whether the scan should continue (LPT_SCAN_CONTINUE), whether the LEB properties should be added to the tree in main memory (LPT_SCAN_ADD), or whether the scan should stop (LPT_SCAN_STOP). */
static int scan_for_idx_cb(struct ubifs_info *c, const struct ubifs_lprops *lprops, int in_tree, struct scan_data *data)
|
{
int ret = LPT_SCAN_CONTINUE;
if (lprops->flags & LPROPS_TAKEN)
return LPT_SCAN_CONTINUE;
if (!in_tree && valuable(c, lprops))
ret |= LPT_SCAN_ADD;
if (lprops->flags & LPROPS_INDEX)
return ret;
if (lprops->free + lprops->dirty != c->leb_size)
return ret;
data->lnum = lprops->lnum;
return LPT_SCAN_ADD | LPT_SCAN_STOP;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Voltage: Core, DDR and another configurable voltages Clock : Critical clocks which are not printed already RCW : RCW source if not printed already Misc : Other important information not in above catagories */
|
void board_detail(void)
|
/* Voltage: Core, DDR and another configurable voltages Clock : Critical clocks which are not printed already RCW : RCW source if not printed already Misc : Other important information not in above catagories */
void board_detail(void)
|
{
int rcwsrc;
rcwsrc = 0x0;
puts("RCW source = ");
switch (rcwsrc & 0x1) {
case 0x1:
puts("SDHC/eMMC\n");
break;
default:
puts("I2C normal addressing\n");
break;
}
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* This function returns the number of samples of averaging configured for all the channels in the Configuration Register 0. */
|
u8 XAdcPs_GetAvg(XAdcPs *InstancePtr)
|
/* This function returns the number of samples of averaging configured for all the channels in the Configuration Register 0. */
u8 XAdcPs_GetAvg(XAdcPs *InstancePtr)
|
{
u32 Average;
Xil_AssertNonvoid(InstancePtr != NULL);
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
Average = XAdcPs_ReadInternalReg(InstancePtr,
XADCPS_CFR0_OFFSET) & XADCPS_CFR0_AVG_VALID_MASK;
return ((u8) (Average >> XADCPS_CFR0_AVG_SHIFT));
}
|
ua1arn/hftrx
|
C++
| null | 69
|
/* Validate PDU Type.3 Validaes the encoding. Add Expert Info if format invalid This also validates Spec Type.3.1. */
|
static void validate_c4(packet_info *pinfo, proto_item *pi, guint32, gint len)
|
/* Validate PDU Type.3 Validaes the encoding. Add Expert Info if format invalid This also validates Spec Type.3.1. */
static void validate_c4(packet_info *pinfo, proto_item *pi, guint32, gint len)
|
{
if (len > 1 && val < 0x80)
{
expert_add_info_format(pinfo, pi, &ei_c2_c3_c4_format, "DOF Violation: Type.3.1: Compressed 32-bit Compression Manditory.");
}
if (len > 2 && val < 0x4000)
{
expert_add_info_format(pinfo, pi, &ei_c2_c3_c4_format, "DOF Violation: Type.3.1: Compressed 32-bit Compression Manditory.");
}
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Configures the TIMx Output Compare 2 Fast feature. */
|
void TIM_OC2FastConfig(TIM_TypeDef *TIMx, uint16_t TIM_OCFast)
|
/* Configures the TIMx Output Compare 2 Fast feature. */
void TIM_OC2FastConfig(TIM_TypeDef *TIMx, uint16_t TIM_OCFast)
|
{
uint16_t tmpccmr1 = 0;
assert_param(IS_TIM_LIST6_PERIPH(TIMx));
assert_param(IS_TIM_OCFAST_STATE(TIM_OCFast));
tmpccmr1 = TIMx->CCMR1;
tmpccmr1 &= (uint16_t)~((uint16_t)TIM_CCMR1_OC2FE);
tmpccmr1 |= (uint16_t)(TIM_OCFast << 8);
TIMx->CCMR1 = tmpccmr1;
}
|
gcallipo/RadioDSP-Stm32f103
|
C++
|
Common Creative - Attribution 3.0
| 51
|
/* Get Hif info of images in both partitions (Firmware and Ota). */
|
nm_get_hif_info(uint16 *pu16FwHifInfo, uint16 *pu16OtaHifInfo)
|
/* Get Hif info of images in both partitions (Firmware and Ota). */
nm_get_hif_info(uint16 *pu16FwHifInfo, uint16 *pu16OtaHifInfo)
|
{
sint8 ret = M2M_SUCCESS;
uint32 reg = 0;
ret = nm_read_reg_with_ret(NMI_REV_REG, ®);
if(ret == M2M_SUCCESS)
{
if(pu16FwHifInfo != NULL)
{
*pu16FwHifInfo = (uint16)reg;
}
if(pu16OtaHifInfo)
{
*pu16OtaHifInfo = (uint16)(reg>>16);
}
}
return ret;
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* @this block IO protocol @media_id media id @lba start of the write in logical blocks @buffer_size number of bytes to read @buffer source buffer */
|
static efi_status_t EFIAPI write_blocks(struct efi_block_io *this, u32 media_id, u64 lba, efi_uintn_t buffer_size, void *buffer)
|
/* @this block IO protocol @media_id media id @lba start of the write in logical blocks @buffer_size number of bytes to read @buffer source buffer */
static efi_status_t EFIAPI write_blocks(struct efi_block_io *this, u32 media_id, u64 lba, efi_uintn_t buffer_size, void *buffer)
|
{
u8 *start;
if ((lba << LB_BLOCK_SIZE) + buffer_size > img.length)
return EFI_INVALID_PARAMETER;
start = image + (lba << LB_BLOCK_SIZE);
boottime->copy_mem(start, buffer, buffer_size);
return EFI_SUCCESS;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Set Input Capture Prescaler.
Set the number of events between each capture. */
|
void timer_ic_set_prescaler(uint32_t timer_peripheral, enum tim_ic_id ic, enum tim_ic_psc psc)
|
/* Set Input Capture Prescaler.
Set the number of events between each capture. */
void timer_ic_set_prescaler(uint32_t timer_peripheral, enum tim_ic_id ic, enum tim_ic_psc psc)
|
{
switch (ic) {
case TIM_IC1:
TIM_CCMR1(timer_peripheral) &= ~TIM_CCMR1_IC1PSC_MASK;
TIM_CCMR1(timer_peripheral) |= psc << 2;
break;
case TIM_IC2:
TIM_CCMR1(timer_peripheral) &= ~TIM_CCMR1_IC2PSC_MASK;
TIM_CCMR1(timer_peripheral) |= psc << 10;
break;
case TIM_IC3:
TIM_CCMR2(timer_peripheral) &= ~TIM_CCMR2_IC3PSC_MASK;
TIM_CCMR2(timer_peripheral) |= psc << 2;
break;
case TIM_IC4:
TIM_CCMR2(timer_peripheral) &= ~TIM_CCMR2_IC4PSC_MASK;
TIM_CCMR2(timer_peripheral) |= psc << 10;
break;
}
}
|
insane-adding-machines/unicore-mx
|
C++
|
GNU General Public License v3.0
| 50
|
/* Read a register value.
Registers have an address and a 16-bit value */
|
static int max17055_reg_read(const struct device *dev, uint8_t reg_addr, int16_t *valp)
|
/* Read a register value.
Registers have an address and a 16-bit value */
static int max17055_reg_read(const struct device *dev, uint8_t reg_addr, int16_t *valp)
|
{
const struct max17055_config *config = dev->config;
uint8_t i2c_data[2];
int rc;
rc = i2c_burst_read_dt(&config->i2c, reg_addr, i2c_data, 2);
if (rc < 0) {
LOG_ERR("Unable to read register");
return rc;
}
*valp = sys_get_le16(i2c_data);
return 0;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Configures the LCD Blink mode and Blink frequency. */
|
void LCD_BlinkConfig(uint32_t LCD_BlinkMode, uint32_t LCD_BlinkFrequency)
|
/* Configures the LCD Blink mode and Blink frequency. */
void LCD_BlinkConfig(uint32_t LCD_BlinkMode, uint32_t LCD_BlinkFrequency)
|
{
assert_param(IS_LCD_BLINK_MODE(LCD_BlinkMode));
assert_param(IS_LCD_BLINK_FREQUENCY(LCD_BlinkFrequency));
LCD->FCR &= (uint32_t)BLINK_MASK;
LCD->FCR |= (uint32_t)(LCD_BlinkMode | LCD_BlinkFrequency);
}
|
avem-labs/Avem
|
C++
|
MIT License
| 1,752
|
/* Reads the GPIO output data(status) for byte.
@method GPIO_ReadOutputData */
|
uint16_t GPIO_ReadOutputData(GPIO_TypeDef GPIOx)
|
/* Reads the GPIO output data(status) for byte.
@method GPIO_ReadOutputData */
uint16_t GPIO_ReadOutputData(GPIO_TypeDef GPIOx)
|
{
_ASSERT(IS_GPIO_PORT(GPIOx));
return MGPIO->IN_LEVEL.reg[GPIOx];
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Retrieves the descriptor for an I/O region containing a specified address. */
|
EFI_STATUS EFIAPI CoreGetIoSpaceDescriptor(IN EFI_PHYSICAL_ADDRESS BaseAddress, OUT EFI_GCD_IO_SPACE_DESCRIPTOR *Descriptor)
|
/* Retrieves the descriptor for an I/O region containing a specified address. */
EFI_STATUS EFIAPI CoreGetIoSpaceDescriptor(IN EFI_PHYSICAL_ADDRESS BaseAddress, OUT EFI_GCD_IO_SPACE_DESCRIPTOR *Descriptor)
|
{
EFI_STATUS Status;
LIST_ENTRY *StartLink;
LIST_ENTRY *EndLink;
EFI_GCD_MAP_ENTRY *Entry;
if (Descriptor == NULL) {
return EFI_INVALID_PARAMETER;
}
CoreAcquireGcdIoLock ();
Status = CoreSearchGcdMapEntry (BaseAddress, 1, &StartLink, &EndLink, &mGcdIoSpaceMap);
if (EFI_ERROR (Status)) {
Status = EFI_NOT_FOUND;
} else {
ASSERT (StartLink != NULL && EndLink != NULL);
Entry = CR (StartLink, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);
BuildIoDescriptor (Descriptor, Entry);
}
CoreReleaseGcdIoLock ();
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* In TDX a serial of TdIoWrite32 is invoked to write data to the I/O port. */
|
VOID EFIAPI TdIoWriteFifo32(IN UINTN Port, IN UINTN Count, IN VOID *Buffer)
|
/* In TDX a serial of TdIoWrite32 is invoked to write data to the I/O port. */
VOID EFIAPI TdIoWriteFifo32(IN UINTN Port, IN UINTN Count, IN VOID *Buffer)
|
{
UINT32 *Buf32;
UINTN Index;
Buf32 = (UINT32 *)Buffer;
for (Index = 0; Index < Count; Index++) {
TdIoWrite32 (Port, Buf32[Index]);
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Enables or disables the PLL. The PLL can not be disabled if it is used as system clock. */
|
void RCC_PLLCmd(FunctionalState NewState)
|
/* Enables or disables the PLL. The PLL can not be disabled if it is used as system clock. */
void RCC_PLLCmd(FunctionalState NewState)
|
{
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
RCC->CR |= 0x01000000;
}
else
{
RCC->CR &= 0xfeffffff;
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Run through the list of completed requests and finish it */
|
static void mega_rundoneq(adapter_t *adapter)
|
/* Run through the list of completed requests and finish it */
static void mega_rundoneq(adapter_t *adapter)
|
{
Scsi_Cmnd *cmd;
struct list_head *pos;
list_for_each(pos, &adapter->completed_list) {
struct scsi_pointer* spos = (struct scsi_pointer *)pos;
cmd = list_entry(spos, Scsi_Cmnd, SCp);
cmd->scsi_done(cmd);
}
INIT_LIST_HEAD(&adapter->completed_list);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* We can make the NVIC behave in the way that Linux expects by making our "acknowledge" routine disable the interrupt, then mark it as complete. */
|
static void nvic_ack_irq(unsigned int irq)
|
/* We can make the NVIC behave in the way that Linux expects by making our "acknowledge" routine disable the interrupt, then mark it as complete. */
static void nvic_ack_irq(unsigned int irq)
|
{
u32 mask = 1 << (irq % 32);
spin_lock(&irq_controller_lock);
writel(mask, NVIC_CLEAR_ENABLE + irq / 32 * 4);
spin_unlock(&irq_controller_lock);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.