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 |
|---|---|---|---|---|---|---|---|
/* Cleanup @crtc. Removes from drm modesetting space does NOT free object, caller does that. */ | void drm_crtc_cleanup(struct drm_crtc *crtc) | /* Cleanup @crtc. Removes from drm modesetting space does NOT free object, caller does that. */
void drm_crtc_cleanup(struct drm_crtc *crtc) | {
struct drm_device *dev = crtc->dev;
if (crtc->gamma_store) {
kfree(crtc->gamma_store);
crtc->gamma_store = NULL;
}
drm_mode_object_put(dev, &crtc->base);
list_del(&crtc->head);
dev->mode_config.num_crtc--;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* The context of the search is stored within the hashbin, so you must protect yourself from concurrent enumerations. - Jean II */ | irda_queue_t* hashbin_get_next(hashbin_t *hashbin) | /* The context of the search is stored within the hashbin, so you must protect yourself from concurrent enumerations. - Jean II */
irda_queue_t* hashbin_get_next(hashbin_t *hashbin) | {
irda_queue_t* entry;
int bin;
int i;
IRDA_ASSERT( hashbin != NULL, return NULL;);
IRDA_ASSERT( hashbin->magic == HB_MAGIC, return NULL;);
if ( hashbin->hb_current == NULL) {
IRDA_ASSERT( hashbin->hb_current != NULL, return NULL;);
return NULL;
}
entry = hashbin->hb_current->q_next;
bin = GET_HASHBIN( entry->q_hash);
if ( entry != hashbin->hb_queue[ bin ]) {
hashbin->hb_current = entry;
return entry;
}
if ( bin >= HASHBIN_SIZE)
return NULL;
bin++;
for ( i = bin; i < HASHBIN_SIZE; i++ ) {
entry = hashbin->hb_queue[ i];
if ( entry) {
hashbin->hb_current = entry;
return entry;
}
}
return NULL;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Must be called with interrupts disabled. Exceptions will be unmasked on return. */ | static void avr32_pm_unmap_sram(void) | /* Must be called with interrupts disabled. Exceptions will be unmasked on return. */
static void avr32_pm_unmap_sram(void) | {
u32 mmucr;
u32 tlbehi;
u32 tlbarlo;
mmucr = sysreg_read(MMUCR);
tlbehi = sysreg_read(TLBEHI);
sysreg_write(MMUCR, SYSREG_BFINS(DRP, 0, mmucr));
tlbehi = SYSREG_BF(ASID, SYSREG_BFEXT(ASID, tlbehi));
sysreg_write(TLBEHI, tlbehi);
tlbarlo = sysreg_read(TLBARLO);
sysreg_write(TLBARLO, tlbarlo | 0x80000000U);
__builtin_tlbw();
asm volatile("csrf %0" : : "i"(SYSREG_EM_OFFSET) : "memory");
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Print out the target and command data in hex */ | static int sprint_Scsi_Cmnd(char *buffer, int len, Scsi_Cmnd *cmd) | /* Print out the target and command data in hex */
static int sprint_Scsi_Cmnd(char *buffer, int len, Scsi_Cmnd *cmd) | {
int start = len;
PRINTP("host number %d destination target %d, lun %d\n" ANDP cmd->device->host->host_no ANDP cmd->device->id ANDP cmd->device->lun);
PRINTP(" command = ");
len += sprint_command(buffer, len, cmd->cmnd);
return len - start;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Sets the WatchDog Timer Control register to the */ | static void wdt_set_ctrl(uint32_t ctrl) | /* Sets the WatchDog Timer Control register to the */
static void wdt_set_ctrl(uint32_t ctrl) | {
volatile uint32_t dly;
if ((WDT->WDT_CTRL & WDT_CTRL_CSSEL) == WDT_CLK_SRC_RCSYS) {
dly = div_ceil(sysclk_get_cpu_hz() * 2, OSC_RCSYS_NOMINAL_HZ);
} else {
dly = div_ceil(sysclk_get_cpu_hz() * 2, OSC_RC32K_NOMINAL_HZ);
}
dly >>= 3;
while(dly--);
WDT->WDT_CTRL = ctrl | WDT_CTRL_KEY(WDT_FIRST_KEY);
WDT->WDT_CTRL = ctrl | WDT_CTRL_KEY(WDT_SECOND_KEY);
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* SPI MSP De-Initialization This function freeze the hardware resources used in this example. */ | void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi) | /* SPI MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi) | {
if(hspi->Instance==SPI1)
{
__HAL_RCC_SPI1_CLK_DISABLE();
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_1|GPIO_PIN_6|GPIO_PIN_7);
}
else if(hspi->Instance==SPI2)
{
__HAL_RCC_SPI2_CLK_DISABLE();
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_1|GPIO_PIN_2);
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9);
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Signal event for every protocol in protocol entry. */ | VOID SmmNotifyProtocol(IN PROTOCOL_INTERFACE *Prot) | /* Signal event for every protocol in protocol entry. */
VOID SmmNotifyProtocol(IN PROTOCOL_INTERFACE *Prot) | {
PROTOCOL_ENTRY *ProtEntry;
PROTOCOL_NOTIFY *ProtNotify;
LIST_ENTRY *Link;
ProtEntry = Prot->Protocol;
for (Link = ProtEntry->Notify.ForwardLink; Link != &ProtEntry->Notify; Link = Link->ForwardLink) {
ProtNotify = CR (Link, PROTOCOL_NOTIFY, Link, PROTOCOL_NOTIFY_SIGNATURE);
ProtNotify->Function (&ProtEntry->ProtocolID, Prot->Interface, Prot->Handle);
}
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Converts a three byte length value into a UINT32. */ | UINT32 GetLength(UINT8 *ThreeByteLength) | /* Converts a three byte length value into a UINT32. */
UINT32 GetLength(UINT8 *ThreeByteLength) | {
UINT32 Length;
if (ThreeByteLength == NULL) {
return 0;
}
Length = *((UINT32 *) ThreeByteLength);
Length = Length & 0x00FFFFFF;
return Length;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* RTC MSP Initialization This function configures the hardware resources used in this example. */ | void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc) | /* RTC MSP Initialization This function configures the hardware resources used in this example. */
void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc) | {
RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
__HAL_RCC_PWR_CLK_ENABLE();
HAL_PWR_EnableBkUpAccess();
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC;
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSI;
if(HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
{
Error_Handler();
}
__HAL_RCC_RTC_ENABLE();
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* Setup the CLI module of the application. Allocate memory for the driver handler and initialize the physical layer. */ | int32_t cli_setup(struct cli_desc **device, struct cli_init_param *init_param) | /* Setup the CLI module of the application. Allocate memory for the driver handler and initialize the physical layer. */
int32_t cli_setup(struct cli_desc **device, struct cli_init_param *init_param) | {
int32_t ret;
int8_t i;
*device = (struct cli_desc *)calloc(1, sizeof(**device));
if (!(*device))
return -1;
ret = uart_init(&((*device)->uart_device), &(init_param->uart_init));
if (ret != SUCCESS)
goto error_dev;
for (i = 0; i < CLI_WIDTH; i++)
uart_current_line[i] = 0;
uart_cmd = 0;
uart_tab = 0;
ret = uart_read_nonblocking((*device)->uart_device, &uart_buff, 1);
if (ret != SUCCESS)
goto error_uart;
return SUCCESS;
error_uart:
uart_remove((*device)->uart_device);
error_dev:
free(*device);
return FAILURE;
} | analogdevicesinc/EVAL-ADICUP3029 | C++ | Other | 36 |
/* Indicates whether the direction change to down interrupt (DOWNIE) is enabled. @rmtoll IER DOWNIE LPTIM_IsEnabledIT_DOWN. */ | uint32_t LPTIM_IsEnabledIT_DOWN(LPTIM_Module *LPTIMx) | /* Indicates whether the direction change to down interrupt (DOWNIE) is enabled. @rmtoll IER DOWNIE LPTIM_IsEnabledIT_DOWN. */
uint32_t LPTIM_IsEnabledIT_DOWN(LPTIM_Module *LPTIMx) | {
return ((READ_BIT(LPTIMx->INTEN, LPTIM_INTEN_DOWNIE) == LPTIM_INTEN_DOWNIE)? 1UL : 0UL);
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* I had expected the following to work for the first descriptor (tx_fd->state = 0xc0000000) */ | static struct sk_buff* dscc4_init_dummy_skb(struct dscc4_dev_priv *dpriv) | /* I had expected the following to work for the first descriptor (tx_fd->state = 0xc0000000) */
static struct sk_buff* dscc4_init_dummy_skb(struct dscc4_dev_priv *dpriv) | {
struct sk_buff *skb;
skb = dev_alloc_skb(DUMMY_SKB_SIZE);
if (skb) {
int last = dpriv->tx_dirty%TX_RING_SIZE;
struct TxFD *tx_fd = dpriv->tx_fd + last;
skb->len = DUMMY_SKB_SIZE;
skb_copy_to_linear_data(skb, version,
strlen(version) % DUMMY_SKB_SIZE);
tx_fd->state = FrameEnd | TO_STATE_TX(DUMMY_SKB_SIZE);
tx_fd->data = cpu_to_le32(pci_map_single(dpriv->pci_priv->pdev,
skb->data, DUMMY_SKB_SIZE,
PCI_DMA_TODEVICE));
dpriv->tx_skbuff[last] = skb;
}
return skb;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* USBH_HID_InterfaceDeInit The function DeInit the Pipes used for the HID class. */ | USBH_StatusTypeDef USBH_HID_InterfaceDeInit(USBH_HandleTypeDef *phost) | /* USBH_HID_InterfaceDeInit The function DeInit the Pipes used for the HID class. */
USBH_StatusTypeDef USBH_HID_InterfaceDeInit(USBH_HandleTypeDef *phost) | { HID_HandleTypeDef *HID_Handle = phost->pActiveClass->pData;
if(HID_Handle->InPipe != 0x00)
{
USBH_ClosePipe (phost, HID_Handle->InPipe);
USBH_FreePipe (phost, HID_Handle->InPipe);
HID_Handle->InPipe = 0;
}
if(HID_Handle->OutPipe != 0x00)
{
USBH_ClosePipe(phost, HID_Handle->OutPipe);
USBH_FreePipe (phost, HID_Handle->OutPipe);
HID_Handle->OutPipe = 0;
}
if(phost->pActiveClass->pData)
{
USBH_free (phost->pActiveClass->pData);
}
return USBH_OK;
} | micropython/micropython | C++ | Other | 18,334 |
/* Normal UNIX filesystem behaviour: delete the inode when the usage count drops to zero, and i_nlink is zero. */ | void generic_drop_inode(struct inode *inode) | /* Normal UNIX filesystem behaviour: delete the inode when the usage count drops to zero, and i_nlink is zero. */
void generic_drop_inode(struct inode *inode) | {
if (!inode->i_nlink)
generic_delete_inode(inode);
else
generic_forget_inode(inode);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Attribute write call back for the Long descriptor V2D3 attribute. */ | static ssize_t write_long_des_v2d3_1(struct bt_conn *conn, const struct bt_gatt_attr *attr, const void *buf, uint16_t len, uint16_t offset, uint8_t flags) | /* Attribute write call back for the Long descriptor V2D3 attribute. */
static ssize_t write_long_des_v2d3_1(struct bt_conn *conn, const struct bt_gatt_attr *attr, const void *buf, uint16_t len, uint16_t offset, uint8_t flags) | {
uint8_t *value = attr->user_data;
if (offset >= sizeof(long_des_v2d3_1_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(long_des_v2d3_1_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Unregister a server Must be called with the server lock held. */ | void smbiod_unregister_server(struct smb_sb_info *server) | /* Unregister a server Must be called with the server lock held. */
void smbiod_unregister_server(struct smb_sb_info *server) | {
spin_lock(&servers_lock);
list_del_init(&server->entry);
VERBOSE("%p\n", server);
spin_unlock(&servers_lock);
smbiod_wake_up();
smbiod_flush(server);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Deinitializes the EXTI registers to default reset values. */ | void EXTI_DeInit() | /* Deinitializes the EXTI registers to default reset values. */
void EXTI_DeInit() | {
uint32_t i;
for (i = 0; i < EXIT_Num; i++)
{
MGPIO->INTR.reg[i] = 0;
MGPIO->IRQ_LEVEL.reg[i] = 0;
MGPIO->IRQ_RISE.reg[i] = 0;
MGPIO->IRQ_FALL.reg[i] = 0;
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* qdict_clone_shallow(): Clones a given QDict. Its entries are not copied, but another reference is added. */ | QDict* qdict_clone_shallow(const QDict *src) | /* qdict_clone_shallow(): Clones a given QDict. Its entries are not copied, but another reference is added. */
QDict* qdict_clone_shallow(const QDict *src) | {
QDict *dest;
QDictEntry *entry;
int i;
dest = qdict_new();
for (i = 0; i < QDICT_BUCKET_MAX; i++) {
QLIST_FOREACH(entry, &src->table[i], next) {
qobject_incref(entry->value);
qdict_put_obj(dest, entry->key, entry->value);
}
}
return dest;
} | ve3wwg/teensy3_qemu | C++ | Other | 15 |
/* Extract the startoff field from an in memory bmap extent record. */ | xfs_fileoff_t xfs_bmbt_get_startoff(xfs_bmbt_rec_host_t *r) | /* Extract the startoff field from an in memory bmap extent record. */
xfs_fileoff_t xfs_bmbt_get_startoff(xfs_bmbt_rec_host_t *r) | {
return ((xfs_fileoff_t)r->l0 &
xfs_mask64lo(64 - BMBT_EXNTFLAG_BITLEN)) >> 9;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* GetEnrollmentSummary-ACK ::= SEQUENCE OF SEQUENCE { objectIdentifier BACnetObjectIdentifer, eventType BACnetEventType, eventState BACnetEventState, priority Unsigned8, notificationClass Unsigned OPTIONAL } */ | static guint fGetEnrollmentSummaryAck(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset) | /* GetEnrollmentSummary-ACK ::= SEQUENCE OF SEQUENCE { objectIdentifier BACnetObjectIdentifer, eventType BACnetEventType, eventState BACnetEventState, priority Unsigned8, notificationClass Unsigned OPTIONAL } */
static guint fGetEnrollmentSummaryAck(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset) | {
guint lastoffset = 0;
while (tvb_reported_length_remaining(tvb, offset) > 0) {
lastoffset = offset;
offset = fApplicationTypes(tvb, pinfo, tree, offset, "Object Identifier: ");
offset = fApplicationTypesEnumeratedSplit(tvb, pinfo, tree, offset,
"event Type: ", BACnetEventType, 64);
offset = fApplicationTypesEnumerated(tvb, pinfo, tree, offset,
"event State: ", BACnetEventState);
offset = fApplicationTypes(tvb, pinfo, tree, offset, "Priority: ");
if (tvb_reported_length_remaining(tvb, offset) > 0 && fTagNo(tvb, offset) == 2)
offset = fUnsignedTag(tvb, pinfo, tree, offset, "Notification Class: ");
if (offset == lastoffset) break;
}
return offset;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Sets the RF Disable configuration.
Needs the I2C Password presentation to be effective. */ | int32_t BSP_NFCTAG_SetRFDisable(uint32_t Instance) | /* Sets the RF Disable configuration.
Needs the I2C Password presentation to be effective. */
int32_t BSP_NFCTAG_SetRFDisable(uint32_t Instance) | {
UNUSED(Instance);
return ST25DV_SetRFDisable(&NfcTagObj);
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* Write uuid atom. Needed to make file play in iPods running newest firmware goes after avcC atom in moov.trak.mdia.minf.stbl.stsd.avc1 */ | static int mov_write_uuid_tag_ipod(ByteIOContext *pb) | /* Write uuid atom. Needed to make file play in iPods running newest firmware goes after avcC atom in moov.trak.mdia.minf.stbl.stsd.avc1 */
static int mov_write_uuid_tag_ipod(ByteIOContext *pb) | {
put_be32(pb, 28);
put_tag(pb, "uuid");
put_be32(pb, 0x6b6840f2);
put_be32(pb, 0x5f244fc5);
put_be32(pb, 0xba39a51b);
put_be32(pb, 0xcf0323f3);
put_be32(pb, 0x0);
return 28;
} | DC-SWAT/DreamShell | C++ | null | 404 |
/* Locate and Install the ACPI tables from the Firmware Volume */ | EFI_STATUS LocateAndInstallAcpiFromFv(IN CONST EFI_GUID *AcpiFile) | /* Locate and Install the ACPI tables from the Firmware Volume */
EFI_STATUS LocateAndInstallAcpiFromFv(IN CONST EFI_GUID *AcpiFile) | {
return LocateAndInstallAcpiFromFvConditional (AcpiFile, NULL);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* This function will create an usb device object. */ | udevice_t rt_usbd_device_new(void) | /* This function will create an usb device object. */
udevice_t rt_usbd_device_new(void) | {
udevice_t udevice;
LOG_D("rt_usbd_device_new");
udevice = (udevice_t)rt_malloc(sizeof(struct udevice));
if(udevice == RT_NULL)
{
rt_kprintf("alloc memory failed\n");
return RT_NULL;
}
rt_memset(udevice, 0, sizeof(struct udevice));
rt_list_init(&udevice->cfg_list);
rt_list_insert_before(&device_list, &udevice->list);
return udevice;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Wait for MSTATUS bits to be set with time out. */ | static int mcux_i3c_status_wait_timeout(I3C_Type *base, uint32_t mask, uint32_t init_delay_us, uint32_t step_delay_us, uint32_t total_delay_us) | /* Wait for MSTATUS bits to be set with time out. */
static int mcux_i3c_status_wait_timeout(I3C_Type *base, uint32_t mask, uint32_t init_delay_us, uint32_t step_delay_us, uint32_t total_delay_us) | {
return reg32_poll_timeout(&base->MSTATUS, mask, mask,
init_delay_us, step_delay_us, total_delay_us);
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Reads and returns the current value of DR5. This function is only available on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on X64. */ | UINTN EFIAPI AsmReadDr5(VOID) | /* Reads and returns the current value of DR5. This function is only available on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on X64. */
UINTN EFIAPI AsmReadDr5(VOID) | {
UINTN Data;
__asm__ __volatile__ (
"movl %%dr5, %0"
: "=r" (Data)
);
return Data;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Allocates an mbuf to contain an outgoing ACL data fragment. */ | static struct os_mbuf* ble_hs_hci_frag_alloc(uint16_t frag_size, void *arg) | /* Allocates an mbuf to contain an outgoing ACL data fragment. */
static struct os_mbuf* ble_hs_hci_frag_alloc(uint16_t frag_size, void *arg) | {
struct os_mbuf *om;
om = os_mbuf_get_pkthdr(&ble_hs_hci_frag_mbuf_pool, 0);
if (om != NULL) {
om->om_data += BLE_HCI_DATA_HDR_SZ;
return om;
}
om = ble_hs_mbuf_acl_pkt();
if (om != NULL) {
return om;
}
return NULL;
} | Nicholas3388/LuaNode | C++ | Other | 1,055 |
/* Convert an integer from unsigned big-endian encoding to a sequence of 13-bit words in little-endian order. The final "partial" word is returned. */ | static uint32_t be8_to_le13(uint32_t *dst, const unsigned char *src, size_t len) | /* Convert an integer from unsigned big-endian encoding to a sequence of 13-bit words in little-endian order. The final "partial" word is returned. */
static uint32_t be8_to_le13(uint32_t *dst, const unsigned char *src, size_t len) | {
uint32_t acc;
int acc_len;
acc = 0;
acc_len = 0;
while (len -- > 0) {
acc |= (uint32_t)src[len] << acc_len;
acc_len += 8;
if (acc_len >= 13) {
*dst ++ = acc & 0x1FFF;
acc >>= 13;
acc_len -= 13;
}
}
return acc;
} | RavenSystem/esp-homekit-devices | C++ | Other | 2,577 |
/* Sends a data byte through the I2Cx peripheral. */ | void I2C_SendData(I2C_TypeDef *I2Cx, uint8_t Data) | /* Sends a data byte through the I2Cx peripheral. */
void I2C_SendData(I2C_TypeDef *I2Cx, uint8_t Data) | {
assert_param(IS_I2C_ALL_PERIPH(I2Cx));
I2Cx->IC_DATA_CMD = CMD_WRITE | Data;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* configure counter reload value, and prescaler divider value */ | ErrStatus fwdgt_config(uint16_t reload_value, uint8_t prescaler_div) | /* configure counter reload value, and prescaler divider value */
ErrStatus fwdgt_config(uint16_t reload_value, uint8_t prescaler_div) | {
uint32_t timeout = FWDGT_PSC_TIMEOUT;
uint32_t flag_status = RESET;
FWDGT_CTL = FWDGT_WRITEACCESS_ENABLE;
do{
flag_status = FWDGT_STAT & FWDGT_STAT_PUD;
}while((--timeout > 0U) && ((uint32_t)RESET != flag_status));
if((uint32_t)RESET != flag_status){
return ERROR;
}
FWDGT_PSC = (uint32_t)prescaler_div;
timeout = FWDGT_RLD_TIMEOUT;
do{
flag_status = FWDGT_STAT & FWDGT_STAT_RUD;
}while((--timeout > 0U) && ((uint32_t)RESET != flag_status));
if((uint32_t)RESET != flag_status){
return ERROR;
}
FWDGT_RLD = RLD_RLD(reload_value);
FWDGT_CTL = FWDGT_KEY_RELOAD;
return SUCCESS;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Since: 2.8 Returns: the allocated memory, or NULL */ | gpointer g_try_malloc0(gsize n_bytes) | /* Since: 2.8 Returns: the allocated memory, or NULL */
gpointer g_try_malloc0(gsize n_bytes) | {
gpointer mem;
if (G_LIKELY (n_bytes))
mem = calloc (1, n_bytes);
else
mem = NULL;
return mem;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Atomic bitwise exclusive OR (XOR) primitive.
is atomically bitwise XOR'ed with the value at <target>, placing the result at <target>, and the previous value at <target> is returned. */ | atomic_val_t z_impl_atomic_xor(atomic_t *target, atomic_val_t value) | /* Atomic bitwise exclusive OR (XOR) primitive.
is atomically bitwise XOR'ed with the value at <target>, placing the result at <target>, and the previous value at <target> is returned. */
atomic_val_t z_impl_atomic_xor(atomic_t *target, atomic_val_t value) | {
k_spinlock_key_t key;
atomic_val_t ret;
key = k_spin_lock(&lock);
ret = *target;
*target ^= value;
k_spin_unlock(&lock, key);
return ret;
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Extracts stream types from a program stream map According to ISO/IEC 13818-1 ('MPEG-2 Systems') table 2-35 */ | static long mpegps_psm_parse(MpegDemuxContext *m, ByteIOContext *pb) | /* Extracts stream types from a program stream map According to ISO/IEC 13818-1 ('MPEG-2 Systems') table 2-35 */
static long mpegps_psm_parse(MpegDemuxContext *m, ByteIOContext *pb) | {
int psm_length, ps_info_length, es_map_length;
psm_length = get_be16(pb);
get_byte(pb);
get_byte(pb);
ps_info_length = get_be16(pb);
url_fskip(pb, ps_info_length);
es_map_length = get_be16(pb);
while (es_map_length >= 4){
unsigned char type = get_byte(pb);
unsigned char es_id = get_byte(pb);
uint16_t es_info_length = get_be16(pb);
m->psm_es_type[es_id] = type;
url_fskip(pb, es_info_length);
es_map_length -= 4 + es_info_length;
}
get_be32(pb);
return 2 + psm_length;
} | DC-SWAT/DreamShell | C++ | null | 404 |
/* Convert to 64 bit value from two 32 bit words. */ | STATIC UINT64 ConvertTo64Bit(IN UINT32 Low, IN UINT32 High) | /* Convert to 64 bit value from two 32 bit words. */
STATIC UINT64 ConvertTo64Bit(IN UINT32 Low, IN UINT32 High) | {
return (Low | ((UINT64)High << 32));
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Disable the MAC Back Pressure operation activation (Half-duplex only). */ | void ETH_DisableBackPressureActivation(void) | /* Disable the MAC Back Pressure operation activation (Half-duplex only). */
void ETH_DisableBackPressureActivation(void) | {
ETH->FCTRL_B.FCTRLB = RESET;
ETH_Delay(ETH_REG_WRITE_DELAY);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Allocate a fib from the adapter fib pool. If the pool is empty we return NULL. */ | struct fib* aac_fib_alloc(struct aac_dev *dev) | /* Allocate a fib from the adapter fib pool. If the pool is empty we return NULL. */
struct fib* aac_fib_alloc(struct aac_dev *dev) | {
struct fib * fibptr;
unsigned long flags;
spin_lock_irqsave(&dev->fib_lock, flags);
fibptr = dev->free_fib;
if(!fibptr){
spin_unlock_irqrestore(&dev->fib_lock, flags);
return fibptr;
}
dev->free_fib = fibptr->next;
spin_unlock_irqrestore(&dev->fib_lock, flags);
fibptr->type = FSAFS_NTC_FIB_CONTEXT;
fibptr->size = sizeof(struct fib);
fibptr->hw_fib_va->header.XferState = 0;
fibptr->flags = 0;
fibptr->callback = NULL;
fibptr->callback_data = NULL;
return fibptr;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Return dasd_device structure associated with cdev. This function needs to be called with the ccw device lock held. It can be used from interrupt context. */ | struct dasd_device* dasd_device_from_cdev_locked(struct ccw_device *cdev) | /* Return dasd_device structure associated with cdev. This function needs to be called with the ccw device lock held. It can be used from interrupt context. */
struct dasd_device* dasd_device_from_cdev_locked(struct ccw_device *cdev) | {
struct dasd_device *device = dev_get_drvdata(&cdev->dev);
if (!device)
return ERR_PTR(-ENODEV);
dasd_get_device(device);
return device;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* param base ENET peripheral base address. param config The configuration for ENET. param bufferConfig All buffers configuration. */ | status_t ENET_DescriptorInit(ENET_Type *base, enet_config_t *config, enet_buffer_config_t *bufferConfig) | /* param base ENET peripheral base address. param config The configuration for ENET. param bufferConfig All buffers configuration. */
status_t ENET_DescriptorInit(ENET_Type *base, enet_config_t *config, enet_buffer_config_t *bufferConfig) | {
assert(config);
assert(bufferConfig);
uint8_t ringNum = config->multiqueueCfg == NULL ? 1U : 2U;
uint8_t channel;
for (channel = 0; channel < ringNum; channel++)
{
if (ENET_TxDescriptorsInit(base, bufferConfig, channel) != kStatus_Success)
{
return kStatus_Fail;
}
if (ENET_RxDescriptorsInit(base, config, bufferConfig, channel) != kStatus_Success)
{
return kStatus_Fail;
}
bufferConfig++;
}
return kStatus_Success;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* 3 max (|p1-p0|, |p2-p0|/2, |p3-p1|/2, |p3-p2|) sqrt(2) steps */ | static double bezier_steps_sq(cairo_point_double_t p[4]) | /* 3 max (|p1-p0|, |p2-p0|/2, |p3-p1|/2, |p3-p2|) sqrt(2) steps */
static double bezier_steps_sq(cairo_point_double_t p[4]) | {
double tmp = sqlen (p[0], p[1]);
tmp = MAX (tmp, sqlen (p[2], p[3]));
tmp = MAX (tmp, sqlen (p[0], p[2]) * .25);
tmp = MAX (tmp, sqlen (p[1], p[3]) * .25);
return 18.0 * tmp;
} | xboot/xboot | C++ | MIT License | 779 |
/* master send target length data use DMA mode. */ | int32_t spi_master_write_stream_dma(spi_t *obj, char *tx_buffer, uint32_t length) | /* master send target length data use DMA mode. */
int32_t spi_master_write_stream_dma(spi_t *obj, char *tx_buffer, uint32_t length) | {
uint8_t spi_idx = obj->spi_idx &0x0F;
PHAL_SSI_ADAPTOR ssi_adapter = &ssi_adapter_g[spi_idx];
int32_t ret;
if (obj->state & SPI_STATE_TX_BUSY) {
DBG_PRINTF(MODULE_SPI, LEVEL_WARN, "spim dma tx: state(0x%x) is not ready\r\n",
obj->state);
return HAL_BUSY;
}
obj->state |= SPI_STATE_TX_BUSY;
ret = ssi_dma_send(ssi_adapter, (u8 *) tx_buffer, length);
if (ret != _TRUE) {
obj->state &= ~SPI_STATE_TX_BUSY;
}
return (ret == _TRUE) ? HAL_OK : HAL_BUSY;
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* where NUM is an IRQ number. For the PC, interrupts can be intercepted simply with "irq_intercept_in ioapic" (note that IRQ0 comes out with NUM=0 even though it is remapped to GSI 2). */ | static int hex2nib(char ch) | /* where NUM is an IRQ number. For the PC, interrupts can be intercepted simply with "irq_intercept_in ioapic" (note that IRQ0 comes out with NUM=0 even though it is remapped to GSI 2). */
static int hex2nib(char ch) | {
if (ch >= '0' && ch <= '9') {
return ch - '0';
} else if (ch >= 'a' && ch <= 'f') {
return 10 + (ch - 'a');
} else if (ch >= 'A' && ch <= 'F') {
return 10 + (ch - 'a');
} else {
return -1;
}
} | ve3wwg/teensy3_qemu | C | Other | 15 |
/* Read raw accel data directly from the registers. */ | int mpu_get_accel_reg(short *data, unsigned long *timestamp) | /* Read raw accel data directly from the registers. */
int mpu_get_accel_reg(short *data, unsigned long *timestamp) | {
unsigned char tmp[6];
if (!(st.chip_cfg.sensors & INV_XYZ_ACCEL))
return -1;
if (i2c_read(st.hw->addr, st.reg->raw_accel, 6, tmp))
return -1;
data[0] = (tmp[0] << 8) | tmp[1];
data[1] = (tmp[2] << 8) | tmp[3];
data[2] = (tmp[4] << 8) | tmp[5];
if (timestamp)
timestamp = HAL_GetTick();
return 0;
} | Luos-io/luos_engine | C++ | MIT License | 496 |
/* Retrieves the current state of a given TCP port, specified in big endian. */ | uint8_t TCP_GetPortState(const uint16_t Port) | /* Retrieves the current state of a given TCP port, specified in big endian. */
uint8_t TCP_GetPortState(const uint16_t Port) | {
for (uint8_t PTableEntry = 0; PTableEntry < MAX_OPEN_TCP_PORTS; PTableEntry++)
{
if (PortStateTable[PTableEntry].Port == Port)
return PortStateTable[PTableEntry].State;
}
return TCP_Port_Closed;
} | prusa3d/Prusa-Firmware-Buddy | C++ | Other | 1,019 |
/* Reads the I2C register and returns its value. */ | uint16_t I2C_ReadRegister(I2C_T *i2c, I2C_REGISTER_T i2cRegister) | /* Reads the I2C register and returns its value. */
uint16_t I2C_ReadRegister(I2C_T *i2c, I2C_REGISTER_T i2cRegister) | {
switch (i2cRegister)
{
case I2C_REGISTER_CTRL1:
return i2c->CTRL1;
case I2C_REGISTER_CTRL2:
return i2c->CTRL2;
case I2C_REGISTER_SADDR1:
return i2c->SADDR1;
case I2C_REGISTER_SADDR2:
return i2c->SADDR2;
case I2C_REGISTER_DATA:
return i2c->DATA;
case I2C_REGISTER_STS1:
return i2c->STS1;
case I2C_REGISTER_STS2:
return i2c->STS2;
case I2C_REGISTER_CLKCTRL:
return i2c->CLKCTRL;
case I2C_REGISTER_RISETMAX:
return i2c->RISETMAX;
case I2C_REGISTER_SWITCH:
return i2c->SWITCH;
default:
return 0;
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* There are times when the data lines are allowed to tristate. What is actually sensed on the line depends on the hardware. It could always be 0xFF/0x00 (if there are pull ups/downs), or things could float and so we'd get garbage back. This func encapsulates that scenario so we can worry about the details here. */ | static void sandbox_spi_tristate(u8 *buf, uint len) | /* There are times when the data lines are allowed to tristate. What is actually sensed on the line depends on the hardware. It could always be 0xFF/0x00 (if there are pull ups/downs), or things could float and so we'd get garbage back. This func encapsulates that scenario so we can worry about the details here. */
static void sandbox_spi_tristate(u8 *buf, uint len) | {
memset(buf, 0xff, len);
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Writes the command header after does the checksum calculation. */ | static s32 e1000_mng_write_cmd_header(struct e1000_hw *hw, struct e1000_host_mng_command_header *hdr) | /* Writes the command header after does the checksum calculation. */
static s32 e1000_mng_write_cmd_header(struct e1000_hw *hw, struct e1000_host_mng_command_header *hdr) | {
u16 i, length = sizeof(struct e1000_host_mng_command_header);
hdr->checksum = e1000_calculate_checksum((u8 *)hdr, length);
length >>= 2;
for (i = 0; i < length; i++) {
E1000_WRITE_REG_ARRAY(hw, E1000_HOST_IF, i,
*((u32 *) hdr + i));
e1e_flush();
}
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* The timer function that's executed when the timer expires. */ | static void usbc_timer_handler(struct k_timer *timer) | /* The timer function that's executed when the timer expires. */
static void usbc_timer_handler(struct k_timer *timer) | {
struct usbc_timer_t *usbc_timer = k_timer_user_data_get(timer);
atomic_set_bit(&usbc_timer->flags, TIMER_EXPIRED);
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* iscsi_sw_tcp_recv - TCP receive in sendfile fashion @rd_desc: read descriptor @skb: socket buffer @offset: offset in skb @len: skb->len - offset */ | static int iscsi_sw_tcp_recv(read_descriptor_t *rd_desc, struct sk_buff *skb, unsigned int offset, size_t len) | /* iscsi_sw_tcp_recv - TCP receive in sendfile fashion @rd_desc: read descriptor @skb: socket buffer @offset: offset in skb @len: skb->len - offset */
static int iscsi_sw_tcp_recv(read_descriptor_t *rd_desc, struct sk_buff *skb, unsigned int offset, size_t len) | {
struct iscsi_conn *conn = rd_desc->arg.data;
unsigned int consumed, total_consumed = 0;
int status;
ISCSI_SW_TCP_DBG(conn, "in %d bytes\n", skb->len - offset);
do {
status = 0;
consumed = iscsi_tcp_recv_skb(conn, skb, offset, 0, &status);
offset += consumed;
total_consumed += consumed;
} while (consumed != 0 && status != ISCSI_TCP_SKB_DONE);
ISCSI_SW_TCP_DBG(conn, "read %d bytes status %d\n",
skb->len - offset, status);
return total_consumed;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Enable/Disable I2C 14-bit timeout counter of the specified I2C port.
The */ | void I2CTimeoutCounterSet(unsigned long ulBase, unsigned long ulDiv64, unsigned long ulTimeout) | /* Enable/Disable I2C 14-bit timeout counter of the specified I2C port.
The */
void I2CTimeoutCounterSet(unsigned long ulBase, unsigned long ulDiv64, unsigned long ulTimeout) | {
xASSERT((ulBase == I2C0_BASE) || ((ulBase == I2C1_BASE)));
xASSERT((ulDiv64 == I2C_TIMEOUT_DIV64) ||
(ulDiv64 == I2C_TIMEOUT_DIV_NO));
xHWREGB(ulBase + I2C_SMB) &= ~I2C_TIMEOUT_DIV64;
xHWREGB(ulBase + I2C_SMB) |= ulDiv64;
xHWREGB(ulBase + I2C_SLTH) = (ulTimeout & 0xFF00) >> 8;
xHWREGB(ulBase + I2C_SLTL) = (ulTimeout & 0x00FF);
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* This function returns %1 if @offs was in the last write to the LEB whose data is in @buf, otherwise %0 is returned. The determination is made by checking for subsequent empty space starting from the next */ | static int is_last_write(const struct ubifs_info *c, void *buf, int offs) | /* This function returns %1 if @offs was in the last write to the LEB whose data is in @buf, otherwise %0 is returned. The determination is made by checking for subsequent empty space starting from the next */
static int is_last_write(const struct ubifs_info *c, void *buf, int offs) | {
int empty_offs, check_len;
uint8_t *p;
empty_offs = ALIGN(offs + 1, c->max_write_size);
check_len = c->leb_size - empty_offs;
p = buf + empty_offs - offs;
return is_empty(p, check_len);
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Returns the format pattern to fill or NULL if error. */ | const unsigned char* snd_pcm_format_silence_64(snd_pcm_format_t format) | /* Returns the format pattern to fill or NULL if error. */
const unsigned char* snd_pcm_format_silence_64(snd_pcm_format_t format) | {
if (format < 0 || format > SNDRV_PCM_FORMAT_LAST)
return NULL;
if (! pcm_formats[format].phys)
return NULL;
return pcm_formats[format].silence;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* param base LPSPI peripheral base address. param handle pointer to lpspi_slave_edma_handle_t structure which stores the transfer state. param count Number of bytes transferred so far by the eDMA transaction. return status of status_t. */ | status_t LPSPI_SlaveTransferGetCountEDMA(LPSPI_Type *base, lpspi_slave_edma_handle_t *handle, size_t *count) | /* param base LPSPI peripheral base address. param handle pointer to lpspi_slave_edma_handle_t structure which stores the transfer state. param count Number of bytes transferred so far by the eDMA transaction. return status of status_t. */
status_t LPSPI_SlaveTransferGetCountEDMA(LPSPI_Type *base, lpspi_slave_edma_handle_t *handle, size_t *count) | {
assert(handle != NULL);
if (NULL == count)
{
return kStatus_InvalidArgument;
}
if (handle->state != (uint8_t)kLPSPI_Busy)
{
*count = 0;
return kStatus_NoTransferInProgress;
}
size_t remainingByte;
remainingByte =
(uint32_t)handle->nbytes * EDMA_GetRemainingMajorLoopCount(handle->edmaRxRegToRxDataHandle->base,
handle->edmaRxRegToRxDataHandle->channel);
*count = handle->totalByteCount - remainingByte;
return kStatus_Success;
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* Reenables given mailbox for reception of new CAN messages */ | static void at91_activate_rx_mb(const struct at91_priv *priv, unsigned int mb) | /* Reenables given mailbox for reception of new CAN messages */
static void at91_activate_rx_mb(const struct at91_priv *priv, unsigned int mb) | {
u32 mask = 1 << mb;
at91_write(priv, AT91_TCR, mask);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Note: This relies on the fact we never fail from UDMA to MWDMA2 but instead drop to PIO. */ | static u8 cs5530_udma_filter(ide_drive_t *drive) | /* Note: This relies on the fact we never fail from UDMA to MWDMA2 but instead drop to PIO. */
static u8 cs5530_udma_filter(ide_drive_t *drive) | {
ide_hwif_t *hwif = drive->hwif;
ide_drive_t *mate = ide_get_pair_dev(drive);
u16 *mateid;
u8 mask = hwif->ultra_mask;
if (mate == NULL)
goto out;
mateid = mate->id;
if (ata_id_has_dma(mateid) && __ide_dma_bad_drive(mate) == 0) {
if ((mateid[ATA_ID_FIELD_VALID] & 4) &&
(mateid[ATA_ID_UDMA_MODES] & 7))
goto out;
if (mateid[ATA_ID_MWDMA_MODES] & 7)
mask = 0;
}
out:
return mask;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Addend Register Update This function loads the contents of Time stamp addend register with the supplied 32 value. This is reserved function when only coarse correction option is selected */ | s32 synopGMAC_TS_addend_update(synopGMACdevice *gmacdev, u32 addend_value) | /* Addend Register Update This function loads the contents of Time stamp addend register with the supplied 32 value. This is reserved function when only coarse correction option is selected */
s32 synopGMAC_TS_addend_update(synopGMACdevice *gmacdev, u32 addend_value) | {
u32 loop_variable;
synopGMACWriteReg(gmacdev->MacBase, GmacTSAddend, addend_value);
for (loop_variable = 0; loop_variable < DEFAULT_LOOP_VARIABLE; loop_variable++)
{
if (!((synopGMACReadReg(gmacdev->MacBase, GmacTSControl)) & GmacTSADDREG))
{
break;
}
plat_delay(DEFAULT_DELAY_VARIABLE);
}
if (loop_variable < DEFAULT_LOOP_VARIABLE)
synopGMACSetBits(gmacdev->MacBase, GmacTSControl, GmacTSADDREG);
else
{
TR("Error::: The TSADDREG bit is not getting cleared !!!!!!\n");
return -ESYNOPGMACPHYERR;
}
return 0;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Reads the adapter's MAC address from first Receive Address Register (RAR0) A reset of the adapter must be performed prior to calling this function in order for the MAC address to have been loaded from the EEPROM into RAR0 */ | s32 ixgbe_get_mac_addr_generic(struct ixgbe_hw *hw, u8 *mac_addr) | /* Reads the adapter's MAC address from first Receive Address Register (RAR0) A reset of the adapter must be performed prior to calling this function in order for the MAC address to have been loaded from the EEPROM into RAR0 */
s32 ixgbe_get_mac_addr_generic(struct ixgbe_hw *hw, u8 *mac_addr) | {
u32 rar_high;
u32 rar_low;
u16 i;
rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(0));
rar_low = IXGBE_READ_REG(hw, IXGBE_RAL(0));
for (i = 0; i < 4; i++)
mac_addr[i] = (u8)(rar_low >> (i*8));
for (i = 0; i < 2; i++)
mac_addr[i+4] = (u8)(rar_high >> (i*8));
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* @handle: handle of the loaded image @systable: system table */ | static int setup(const efi_handle_t handle, const struct efi_system_table *systable) | /* @handle: handle of the loaded image @systable: system table */
static int setup(const efi_handle_t handle, const struct efi_system_table *systable) | {
efi_status_t ret;
boottime = systable->boottime;
ret = boottime->locate_protocol(&efi_gop_guid, NULL, (void **)&gop);
if (ret != EFI_SUCCESS) {
gop = NULL;
efi_st_printf("Graphical output protocol is not available.\n");
}
return EFI_ST_SUCCESS;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Returns a boolean to indicate whether SEV-SNP is enabled. */ | BOOLEAN EFIAPI MemEncryptSevSnpIsEnabled(VOID) | /* Returns a boolean to indicate whether SEV-SNP is enabled. */
BOOLEAN EFIAPI MemEncryptSevSnpIsEnabled(VOID) | {
return ConfidentialComputingGuestHas (CCAttrAmdSevSnp);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Set up the ide_hwif_t for the PIIX interface according to the capabilities of the hardware. */ | static void __devinit init_hwif_piix(ide_hwif_t *hwif) | /* Set up the ide_hwif_t for the PIIX interface according to the capabilities of the hardware. */
static void __devinit init_hwif_piix(ide_hwif_t *hwif) | {
if (!hwif->dma_base)
return;
if (no_piix_dma)
hwif->ultra_mask = hwif->mwdma_mask = hwif->swdma_mask = 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* param base CSI peripheral base address. param fifo The FIFO DMA to reflash. */ | void CSI_ReflashFifoDma(CSI_Type *base, csi_fifo_t fifo) | /* param base CSI peripheral base address. param fifo The FIFO DMA to reflash. */
void CSI_ReflashFifoDma(CSI_Type *base, csi_fifo_t fifo) | {
uint32_t cr3 = 0U;
if (0U != ((uint32_t)fifo & (uint32_t)kCSI_RxFifo))
{
cr3 |= CSI_CSICR3_DMA_REFLASH_RFF_MASK;
}
if (0U != ((uint32_t)fifo & (uint32_t)kCSI_StatFifo))
{
cr3 |= CSI_CSICR3_DMA_REFLASH_SFF_MASK;
}
CSI_REG_CR3(base) |= cr3;
while (0U != (CSI_REG_CR3(base) & cr3))
{
}
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* Disable FLASH INFO space.
Use this function to set the state of the 128 valid bits at the beginning of customer info space, if needed. Then disable FLASH erasure. */ | int32_t am_hal_flash_info_erase_disable(void) | /* Disable FLASH INFO space.
Use this function to set the state of the 128 valid bits at the beginning of customer info space, if needed. Then disable FLASH erasure. */
int32_t am_hal_flash_info_erase_disable(void) | {
int iRC;
uint32_t ui32SecurityValue;
iRC = customer_info_signature_set();
if ( iRC )
{
return iRC;
}
ui32SecurityValue = AM_REGVAL(AM_HAL_FLASH_INFO_SECURITY_ADDR) &
~AM_HAL_FLASH_INFO_SECURITY_ENINFOERASE_M;
return g_am_hal_flash.flash_program_info(
AM_HAL_FLASH_PROGRAM_KEY,
0,
&ui32SecurityValue,
AM_HAL_FLASH_INFO_SECURITY_O / 4,
1 );
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* This must be called before any eeprom access. */ | void init_eeprom(int bus_num, int addr, int addr_len) | /* This must be called before any eeprom access. */
void init_eeprom(int bus_num, int addr, int addr_len) | {
eeprom_bus_num = bus_num;
eeprom_addr = addr;
eeprom_addr_len = addr_len;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Look up the task based on what TID userspace gave us. We dont trust it. */ | static struct task_struct* futex_find_get_task(pid_t pid) | /* Look up the task based on what TID userspace gave us. We dont trust it. */
static struct task_struct* futex_find_get_task(pid_t pid) | {
struct task_struct *p;
const struct cred *cred = current_cred(), *pcred;
rcu_read_lock();
p = find_task_by_vpid(pid);
if (!p) {
p = ERR_PTR(-ESRCH);
} else {
pcred = __task_cred(p);
if (cred->euid != pcred->euid &&
cred->euid != pcred->uid)
p = ERR_PTR(-ESRCH);
else
get_task_struct(p);
}
rcu_read_unlock();
return p;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Check NAND status to see if it is ready or not */ | static int nand_dev_ready(struct mtd_info *mtd) | /* Check NAND status to see if it is ready or not */
static int nand_dev_ready(struct mtd_info *mtd) | {
struct nand_chip *chip = mtd_to_nand(mtd);
int reg_val;
struct nand_drv *info;
info = (struct nand_drv *)nand_get_controller_data(chip);
reg_val = readl(&info->reg->status);
if (reg_val & STATUS_RBSY0)
return 1;
else
return 0;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* This printer is used when generating the resulting configuration after kconfig invocation and */ | static void kconfig_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg) | /* This printer is used when generating the resulting configuration after kconfig invocation and */
static void kconfig_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg) | {
switch (sym->type) {
case S_BOOLEAN:
case S_TRISTATE:
if (*value == 'n') {
value = "";
}
break;
default:
break;
}
fprintf(fp, "%s%s=%s\n", CONFIG_, sym->name, value);
} | retro-esp32/RetroESP32 | C++ | Creative Commons Attribution Share Alike 4.0 International | 581 |
/* Gets the LCD instance according to the LCD base. */ | static uint32_t LCDC_GetInstance(LCD_Type *base) | /* Gets the LCD instance according to the LCD base. */
static uint32_t LCDC_GetInstance(LCD_Type *base) | {
uint32_t instance;
for (instance = 0; instance < ARRAY_SIZE(s_lcdBases); instance++)
{
if (s_lcdBases[instance] == base)
{
break;
}
}
assert(instance < ARRAY_SIZE(s_lcdBases));
return instance;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* The following only work if pte_present() is true. Undefined behaviour if not.. */ | static pte_t sun4c_pte_mkwrite(pte_t pte) | /* The following only work if pte_present() is true. Undefined behaviour if not.. */
static pte_t sun4c_pte_mkwrite(pte_t pte) | {
pte = __pte(pte_val(pte) | _SUN4C_PAGE_WRITE);
if (pte_val(pte) & _SUN4C_PAGE_MODIFIED)
pte = __pte(pte_val(pte) | _SUN4C_PAGE_SILENT_WRITE);
return pte;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Function for parsing the length of an iOS attribute. Used in the parse_get_notif_attrs_response state machine.
Second byte of the length field. If the length is zero, it means that the attribute is not present and the state machine is set to parse the next attribute. */ | static ble_ancs_c_parse_state_t attr_len2_parse(ble_ancs_c_t *p_ancs, const uint8_t *p_data_src, uint32_t *index) | /* Function for parsing the length of an iOS attribute. Used in the parse_get_notif_attrs_response state machine.
Second byte of the length field. If the length is zero, it means that the attribute is not present and the state machine is set to parse the next attribute. */
static ble_ancs_c_parse_state_t attr_len2_parse(ble_ancs_c_t *p_ancs, const uint8_t *p_data_src, uint32_t *index) | {
p_ancs->evt.attr.attr_len |= (p_data_src[(*index)++] << 8);
p_ancs->current_attr_index = 0;
if (p_ancs->evt.attr.attr_len != 0)
{
return ATTR_DATA;
}
else
{
ANCS_LOG("[ANCS]: Attribute LEN %i \n\r", p_ancs->evt.attr.attr_len);
p_ancs->evt.evt_type = BLE_ANCS_C_EVT_NOTIF_ATTRIBUTE;
p_ancs->evt_handler(&p_ancs->evt);
return ATTR_ID;
}
} | labapart/polymcu | C++ | null | 201 |
/* Set Transmit Power.
This API is used to set the transmit power level that will be used during advertising. */ | ADI_BLER_RESULT adi_radio_SetTxPowerLevel(const int8_t nTxPowerLevel) | /* Set Transmit Power.
This API is used to set the transmit power level that will be used during advertising. */
ADI_BLER_RESULT adi_radio_SetTxPowerLevel(const int8_t nTxPowerLevel) | {
ADI_BLER_RESULT bleResult;
ADI_BLE_LOGEVENT(LOGID_CMD_BLEGAP_SET_TX_PWR_LEVEL);
ADI_BLE_RADIO_CMD_START(CMD_BLEGAP_SET_TX_PWR_LEVEL);
ASSERT(nTxPowerLevel >= -127);
memcpy(&pBLERadio->cmdPkt[ADI_RADIO_CMD_HEADER_LEN], &nTxPowerLevel, 1u);
bleResult = bler_process_cmd(CMD_BLEGAP_SET_TX_PWR_LEVEL, 1u, NULL, 0u);
if(bleResult == ADI_BLER_SUCCESS){
bleResult = ADI_BLE_WAIT_FOR_COMPLETION(ADI_EVENT_FLAG_RESP_SUCCESS,ADI_BLER_CMD_TIMEOUT);
}
ADI_BLE_RADIO_CMD_END();
return (bleResult);
} | analogdevicesinc/EVAL-ADICUP3029 | C++ | Other | 36 |
/* Fills each TADC_InitStruct member with its default value. */ | void TADC_StructInit(TADCInitType *TADC_InitStruct) | /* Fills each TADC_InitStruct member with its default value. */
void TADC_StructInit(TADCInitType *TADC_InitStruct) | {
TADC_InitStruct->SignalSel = ADCTINY_SIGNALSEL_IOE6;
TADC_InitStruct->ADTREF1 = ADCTINY_REF1_0_9;
TADC_InitStruct->ADTREF2 = ADCTINY_REF2_1_8;
TADC_InitStruct->ADTREF3 = ADCTINY_REF3_2_7;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Read a single byte from the serial port. Returns 1 on success, 0 otherwise. When the function is succesfull, the character read is written into its argument c. */ | int pxa_getc_dev(unsigned int uart_index) | /* Read a single byte from the serial port. Returns 1 on success, 0 otherwise. When the function is succesfull, the character read is written into its argument c. */
int pxa_getc_dev(unsigned int uart_index) | {
struct pxa_uart_regs *uart_regs;
uart_regs = pxa_uart_index_to_regs(uart_index);
if (!uart_regs)
return -1;
while (!(readl(&uart_regs->lsr) & LSR_DR))
WATCHDOG_RESET();
return readl(&uart_regs->rbr) & 0xff;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* : Enable FIFO batching of pedometer embedded function values. */ | int32_t lsm6dso_fifo_pedo_batch_set(stmdev_ctx_t *ctx, uint8_t val) | /* : Enable FIFO batching of pedometer embedded function values. */
int32_t lsm6dso_fifo_pedo_batch_set(stmdev_ctx_t *ctx, uint8_t val) | {
lsm6dso_emb_func_fifo_cfg_t reg;
int32_t ret;
ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK);
if (ret == 0) {
ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_FIFO_CFG,
(uint8_t *)®, 1);
}
if (ret == 0) {
reg.pedo_fifo_en = val;
ret = lsm6dso_write_reg(ctx, LSM6DSO_EMB_FUNC_FIFO_CFG,
(uint8_t *)®, 1);
}
if (ret == 0) {
ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK);
}
return ret;
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* Remove and free service answer from answer list (destination) */ | static void _mdns_dealloc_scheduled_service_answers(mdns_out_answer_t **destination, mdns_service_t *service) | /* Remove and free service answer from answer list (destination) */
static void _mdns_dealloc_scheduled_service_answers(mdns_out_answer_t **destination, mdns_service_t *service) | {
mdns_out_answer_t * d = *destination;
if (!d) {
return;
}
while (d && d->service == service) {
*destination = d->next;
free(d);
d = *destination;
}
while (d && d->next) {
mdns_out_answer_t * a = d->next;
if (a->service == service) {
d->next = a->next;
free(a);
} else {
d = d->next;
}
}
} | retro-esp32/RetroESP32 | C++ | Creative Commons Attribution Share Alike 4.0 International | 581 |
/* This event aggregates all the events of the pointer devices in the splitter. If any events of physical pointer devices are signaled, signal the pointer splitter event. This will cause the calling code to call ConSplitterAbsolutePointerGetState (). */ | VOID EFIAPI ConSplitterAbsolutePointerWaitForInput(IN EFI_EVENT Event, IN VOID *Context) | /* This event aggregates all the events of the pointer devices in the splitter. If any events of physical pointer devices are signaled, signal the pointer splitter event. This will cause the calling code to call ConSplitterAbsolutePointerGetState (). */
VOID EFIAPI ConSplitterAbsolutePointerWaitForInput(IN EFI_EVENT Event, IN VOID *Context) | {
EFI_STATUS Status;
TEXT_IN_SPLITTER_PRIVATE_DATA *Private;
UINTN Index;
Private = (TEXT_IN_SPLITTER_PRIVATE_DATA *)Context;
if (Private->AbsoluteInputEventSignalState) {
gBS->SignalEvent (Event);
return;
}
for (Index = 0; Index < Private->CurrentNumberOfAbsolutePointers; Index++) {
Status = gBS->CheckEvent (Private->AbsolutePointerList[Index]->WaitForInput);
if (!EFI_ERROR (Status)) {
gBS->SignalEvent (Event);
Private->AbsoluteInputEventSignalState = TRUE;
}
}
} | tianocore/edk2 | C++ | Other | 4,240 |
/* USART Enable RX pin active level inversion.
@This bit field can only be written when the USART is disabled. */ | void usart_enable_rx_inversion(uint32_t usart) | /* USART Enable RX pin active level inversion.
@This bit field can only be written when the USART is disabled. */
void usart_enable_rx_inversion(uint32_t usart) | {
USART_CR2(usart) |= USART_CR2_RXINV;
} | insane-adding-machines/unicore-mx | C++ | GNU General Public License v3.0 | 50 |
/* Increment reference count on buffer, to hold the buffer concurrently with another thread which may release (free) the buffer asynchronously. Must hold the buffer already to call this function. */ | void xfs_buf_hold(xfs_buf_t *bp) | /* Increment reference count on buffer, to hold the buffer concurrently with another thread which may release (free) the buffer asynchronously. Must hold the buffer already to call this function. */
void xfs_buf_hold(xfs_buf_t *bp) | {
trace_xfs_buf_hold(bp, _RET_IP_);
atomic_inc(&bp->b_hold);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* The class is added to row at priorities marked in mask. It does nothing if mask == 0. */ | static void htb_add_class_to_row(struct htb_sched *q, struct htb_class *cl, int mask) | /* The class is added to row at priorities marked in mask. It does nothing if mask == 0. */
static void htb_add_class_to_row(struct htb_sched *q, struct htb_class *cl, int mask) | {
q->row_mask[cl->level] |= mask;
while (mask) {
int prio = ffz(~mask);
mask &= ~(1 << prio);
htb_add_to_id_tree(q->row[cl->level] + prio, cl, prio);
}
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Constructs a new net device, complete with a private data area of size @sizeof_priv. A 32-byte (not bit) alignment is enforced for this private data area. */ | struct net_device* alloc_hippi_dev(int sizeof_priv) | /* Constructs a new net device, complete with a private data area of size @sizeof_priv. A 32-byte (not bit) alignment is enforced for this private data area. */
struct net_device* alloc_hippi_dev(int sizeof_priv) | {
return alloc_netdev(sizeof_priv, "hip%d", hippi_setup);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* this function will return the information about a mounted file system. */ | int dfs_statfs(const char *path, struct statfs *buffer) | /* this function will return the information about a mounted file system. */
int dfs_statfs(const char *path, struct statfs *buffer) | {
struct dfs_filesystem *fs;
fs = dfs_filesystem_lookup(path);
if (fs != NULL)
{
if (fs->ops->statfs != NULL)
return fs->ops->statfs(fs, buffer);
}
return -1;
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* Deinitializes the SPIx peripheral registers to their default reset values . */ | void SPI_DeInit(SPI_TypeDef *SPIx) | /* Deinitializes the SPIx peripheral registers to their default reset values . */
void SPI_DeInit(SPI_TypeDef *SPIx) | {
assert_param(IS_SPI_ALL_PERIPH(SPIx));
switch (*(uint32_t*)&SPIx)
{
case SPI1_BASE:
RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI1, ENABLE);
RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI1, DISABLE);
break;
case SPI2_BASE:
RCC_APB2PeriphResetCmd(RCC_APB1Periph_SPI2, ENABLE);
RCC_APB2PeriphResetCmd(RCC_APB1Periph_SPI2, DISABLE);
break;
default:
break;
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* codepoint(s, ]]) -> returns codepoints for all characters that start in the range */ | static int codepoint(lua_State *L) | /* codepoint(s, ]]) -> returns codepoints for all characters that start in the range */
static int codepoint(lua_State *L) | {
utfint code;
s = utf8_decode(s, &code, !lax);
if (s == NULL)
return luaL_error(L, "invalid UTF-8 code");
lua_pushinteger(L, code);
n++;
}
return n;
} | Nicholas3388/LuaNode | C++ | Other | 1,055 |
/* Returns the last conversion result data for injected channel of SDADC1 and SDADC2. JSYNC bit of the SDADC2 should be already set. */ | uint32_t SDADC_GetInjectedConversionSDADC12Value(void) | /* Returns the last conversion result data for injected channel of SDADC1 and SDADC2. JSYNC bit of the SDADC2 should be already set. */
uint32_t SDADC_GetInjectedConversionSDADC12Value(void) | {
return (uint32_t) SDADC1->JDATA12R;
} | avem-labs/Avem | C++ | MIT License | 1,752 |
/* These routines must be called with the uidhash spinlock held! */ | static void uid_hash_insert(struct user_struct *up, struct hlist_head *hashent) | /* These routines must be called with the uidhash spinlock held! */
static void uid_hash_insert(struct user_struct *up, struct hlist_head *hashent) | {
hlist_add_head(&up->uidhash_node, hashent);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* This function calculates the CRC16 of the input data. */ | static uint16_t _eval_crc_16(const uint8_t *puc_buf_ptr, uint32_t ul_len, uint32_t ul_crc_init) | /* This function calculates the CRC16 of the input data. */
static uint16_t _eval_crc_16(const uint8_t *puc_buf_ptr, uint32_t ul_len, uint32_t ul_crc_init) | {
uint16_t us_crc;
us_crc = ul_crc_init;
while (ul_len--) {
us_crc = (uint16_t)(pus_crc16_table [(us_crc >> 8) & 0xff] ^
(us_crc << 8) ^ (*puc_buf_ptr++ & 0x00ff));
}
return us_crc;
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* virtqueue_get_available_buffer - Returns buffer available for use in the VirtIO queue */ | void* virtqueue_get_available_buffer(struct virtqueue *vq, uint16_t *avail_idx, uint32_t *len) | /* virtqueue_get_available_buffer - Returns buffer available for use in the VirtIO queue */
void* virtqueue_get_available_buffer(struct virtqueue *vq, uint16_t *avail_idx, uint32_t *len) | {
uint16_t head_idx = 0;
void *buffer;
atomic_thread_fence(memory_order_seq_cst);
if (vq->vq_available_idx == vq->vq_ring.avail->idx) {
return NULL;
}
VQUEUE_BUSY(vq);
head_idx = vq->vq_available_idx++ & (vq->vq_nentries - 1);
*avail_idx = vq->vq_ring.avail->ring[head_idx];
buffer = virtqueue_phys_to_virt(vq, vq->vq_ring.desc[*avail_idx].addr);
*len = vq->vq_ring.desc[*avail_idx].len;
VQUEUE_IDLE(vq);
return buffer;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Specify a pressure-altitude layer.
The routine sets the */ | bool pressure_isa_layer(int index) | /* Specify a pressure-altitude layer.
The routine sets the */
bool pressure_isa_layer(int index) | {
if ((layer_min <= index) && (index <= layer_max)) {
layer = index;
RL_g0 = (R_g0 * Lb);
RT_g0 = (R_g0 * Tb);
return true;
}
return false;
} | memfault/zero-to-main | C++ | null | 200 |
/* "Generic" get version. (Not that generic: not valid for integers, which may be in array part, nor for floats with integral values.) See explanation about 'deadok' in function 'equalkey'. */ | static const TValue* getgeneric(Table *t, const TValue *key, int deadok) | /* "Generic" get version. (Not that generic: not valid for integers, which may be in array part, nor for floats with integral values.) See explanation about 'deadok' in function 'equalkey'. */
static const TValue* getgeneric(Table *t, const TValue *key, int deadok) | {
if (equalkey(key, n, deadok))
return gval(n);
else {
int nx = gnext(n);
if (nx == 0)
return &absentkey;
n += nx;
}
}
} | Nicholas3388/LuaNode | C++ | Other | 1,055 |
/* this function will register a file system instance to device file system. */ | int dfs_register(const struct dfs_filesystem_ops *ops) | /* this function will register a file system instance to device file system. */
int dfs_register(const struct dfs_filesystem_ops *ops) | {
int ret = RT_EOK;
const struct dfs_filesystem_ops **empty = NULL;
const struct dfs_filesystem_ops **iter;
dfs_lock();
for (iter = &filesystem_operation_table[0];
iter < &filesystem_operation_table[DFS_FILESYSTEM_TYPES_MAX]; iter ++)
{
if (*iter == NULL)
(empty == NULL) ? (empty = iter) : 0;
else if (strcmp((*iter)->name, ops->name) == 0)
{
rt_set_errno(-EEXIST);
ret = -1;
break;
}
}
if (empty == NULL)
{
rt_set_errno(-ENOSPC);
LOG_E("There is no space to register this file system (%s).", ops->name);
ret = -1;
}
else if (ret == RT_EOK)
{
*empty = ops;
}
dfs_unlock();
return ret;
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* Remove a registered notification function from a particular keystroke. */ | EFI_STATUS EFIAPI TerminalConInUnregisterKeyNotify(IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN VOID *NotificationHandle) | /* Remove a registered notification function from a particular keystroke. */
EFI_STATUS EFIAPI TerminalConInUnregisterKeyNotify(IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN VOID *NotificationHandle) | {
TERMINAL_DEV *TerminalDevice;
LIST_ENTRY *Link;
TERMINAL_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
LIST_ENTRY *NotifyList;
if (NotificationHandle == NULL) {
return EFI_INVALID_PARAMETER;
}
TerminalDevice = TERMINAL_CON_IN_EX_DEV_FROM_THIS (This);
NotifyList = &TerminalDevice->NotifyList;
for (Link = GetFirstNode (NotifyList); !IsNull (NotifyList, Link); Link = GetNextNode (NotifyList, Link)) {
CurrentNotify = CR (
Link,
TERMINAL_CONSOLE_IN_EX_NOTIFY,
NotifyEntry,
TERMINAL_CONSOLE_IN_EX_NOTIFY_SIGNATURE
);
if (CurrentNotify == NotificationHandle) {
RemoveEntryList (&CurrentNotify->NotifyEntry);
gBS->FreePool (CurrentNotify);
return EFI_SUCCESS;
}
}
return EFI_INVALID_PARAMETER;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* param base USART peripheral base address. param handle USART handle pointer. param xfer USART transfer structure. See #usart_transfer_t. retval kStatus_Success Successfully start the data transmission. retval kStatus_USART_TxBusy Previous transmission still not finished, data not all written to TX register yet. retval kStatus_InvalidArgument Invalid argument. */ | status_t USART_TransferSendNonBlocking(USART_Type *base, usart_handle_t *handle, usart_transfer_t *xfer) | /* param base USART peripheral base address. param handle USART handle pointer. param xfer USART transfer structure. See #usart_transfer_t. retval kStatus_Success Successfully start the data transmission. retval kStatus_USART_TxBusy Previous transmission still not finished, data not all written to TX register yet. retval kStatus_InvalidArgument Invalid argument. */
status_t USART_TransferSendNonBlocking(USART_Type *base, usart_handle_t *handle, usart_transfer_t *xfer) | {
assert(!((NULL == base) || (NULL == handle) || (NULL == xfer)));
if ((NULL == base) || (NULL == handle) || (NULL == xfer))
{
return kStatus_InvalidArgument;
}
assert(!((0U == xfer->dataSize) || (NULL == xfer->data)));
if ((0U == xfer->dataSize) || (NULL == xfer->data))
{
return kStatus_InvalidArgument;
}
if ((uint8_t)kUSART_TxBusy == handle->txState)
{
return kStatus_USART_TxBusy;
}
else
{
uint32_t regPrimask = DisableGlobalIRQ();
handle->txData = xfer->data;
handle->txDataSize = xfer->dataSize;
handle->txDataSizeAll = xfer->dataSize;
handle->txState = (uint8_t)kUSART_TxBusy;
base->FIFOINTENSET = USART_FIFOINTENSET_TXLVL_MASK;
EnableGlobalIRQ(regPrimask);
}
return kStatus_Success;
} | ARMmbed/DAPLink | C++ | Apache License 2.0 | 2,140 |
/* This function scans the cpu-private fault map & clears all bits that are set. The function returns a bitmap that indicates the bits that were cleared. Note that sense the maps may be updated asynchronously by the GRU, atomic operations must be used to clear bits. */ | static void get_clear_fault_map(struct gru_state *gru, struct gru_tlb_fault_map *imap, struct gru_tlb_fault_map *dmap) | /* This function scans the cpu-private fault map & clears all bits that are set. The function returns a bitmap that indicates the bits that were cleared. Note that sense the maps may be updated asynchronously by the GRU, atomic operations must be used to clear bits. */
static void get_clear_fault_map(struct gru_state *gru, struct gru_tlb_fault_map *imap, struct gru_tlb_fault_map *dmap) | {
unsigned long i, k;
struct gru_tlb_fault_map *tfm;
tfm = get_tfm_for_cpu(gru, gru_cpu_fault_map_id());
prefetchw(tfm);
for (i = 0; i < BITS_TO_LONGS(GRU_NUM_CBE); i++) {
k = tfm->fault_bits[i];
if (k)
k = xchg(&tfm->fault_bits[i], 0UL);
imap->fault_bits[i] = k;
k = tfm->done_bits[i];
if (k)
k = xchg(&tfm->done_bits[i], 0UL);
dmap->fault_bits[i] = k;
}
gru_flush_cache(tfm);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Delay function. Will add a delay equal to GZLL_RX_PERIOD * rx_periods using the gazell timer and not a delay loop. */ | void gzp_tick_sleep_rx_periods(uint32_t rx_periods) | /* Delay function. Will add a delay equal to GZLL_RX_PERIOD * rx_periods using the gazell timer and not a delay loop. */
void gzp_tick_sleep_rx_periods(uint32_t rx_periods) | {
nrf_gzll_clear_tick_count();
while(nrf_gzll_get_tick_count() < 2*rx_periods)
{
__WFI();
}
} | labapart/polymcu | C++ | null | 201 |
/* Read hardware ECC value and pack into three bytes */ | static int nand_davinci_calculate_1bit(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code) | /* Read hardware ECC value and pack into three bytes */
static int nand_davinci_calculate_1bit(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code) | {
unsigned int ecc_val = nand_davinci_readecc_1bit(mtd);
unsigned int ecc24 = (ecc_val & 0x0fff) | ((ecc_val & 0x0fff0000) >> 4);
ecc24 = ~ecc24;
ecc_code[0] = (u_char)(ecc24);
ecc_code[1] = (u_char)(ecc24 >> 8);
ecc_code[2] = (u_char)(ecc24 >> 16);
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Spinlock based trylock, we take the spinlock and check whether we can get the lock: */ | static int __mutex_trylock_slowpath(atomic_t *lock_count) | /* Spinlock based trylock, we take the spinlock and check whether we can get the lock: */
static int __mutex_trylock_slowpath(atomic_t *lock_count) | {
struct mutex *lock = container_of(lock_count, struct mutex, count);
unsigned long flags;
int prev;
spin_lock_mutex(&lock->wait_lock, flags);
prev = atomic_xchg(&lock->count, -1);
if (likely(prev == 1)) {
mutex_set_owner(lock);
mutex_acquire(&lock->dep_map, 0, 1, _RET_IP_);
}
if (likely(list_empty(&lock->wait_list)))
atomic_set(&lock->count, 0);
spin_unlock_mutex(&lock->wait_lock, flags);
return prev == 1;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Returns the value of the requested RTC sub second match register. */ | uint32_t HibernateRTCSSMatchGet(uint32_t ui32Match) | /* Returns the value of the requested RTC sub second match register. */
uint32_t HibernateRTCSSMatchGet(uint32_t ui32Match) | {
ASSERT(ui32Match == 0);
return(HWREG(HIB_RTCSS) >> HIB_RTCSS_RTCSSM_S);
} | feaser/openblt | C++ | GNU General Public License v3.0 | 601 |
/* Register user's interrupt callback function for the PWM. */ | void xPWMIntCallbackInit(unsigned long ulBase, xtEventCallback pfnCallback) | /* Register user's interrupt callback function for the PWM. */
void xPWMIntCallbackInit(unsigned long ulBase, xtEventCallback pfnCallback) | {
(void)ulBase;
xASSERT(ulBase == PWM1_BASE);
xASSERT(pfnCallback != 0);
g_pfnPWMHandlerCallbacks = pfnCallback;
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* Check a register that we set up to see if clock_early_init() has already been called. */ | bool clock_early_init_done(void) | /* Check a register that we set up to see if clock_early_init() has already been called. */
bool clock_early_init_done(void) | {
struct clk_rst_ctlr *clkrst = (struct clk_rst_ctlr *)NV_PA_CLK_RST_BASE;
u32 val;
val = readl(&clkrst->crc_sclk_brst_pol);
return val == 0x20002222;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* This service executes a caller provided function on all enabled CPUs. */ | EFI_STATUS EFIAPI MpInitLibStartupAllCPUs(IN EFI_AP_PROCEDURE Procedure, IN UINTN TimeoutInMicroseconds, IN VOID *ProcedureArgument OPTIONAL) | /* This service executes a caller provided function on all enabled CPUs. */
EFI_STATUS EFIAPI MpInitLibStartupAllCPUs(IN EFI_AP_PROCEDURE Procedure, IN UINTN TimeoutInMicroseconds, IN VOID *ProcedureArgument OPTIONAL) | {
return StartupAllCPUsWorker (
Procedure,
FALSE,
FALSE,
NULL,
TimeoutInMicroseconds,
ProcedureArgument,
NULL
);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Reset stack pointer to begin of the stack. */ | VOID ResetMapExpressionListStack(VOID) | /* Reset stack pointer to begin of the stack. */
VOID ResetMapExpressionListStack(VOID) | {
mMapExpressionListPointer = mMapExpressionListStack;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Again, use g_ascii_strcasecmp(), not strcasecmp(), so that only ASCII letters are mapped, and they're mapped to the lower-case ASCII equivalents. */ | static gboolean strcase_equal(gconstpointer ka, gconstpointer kb) | /* Again, use g_ascii_strcasecmp(), not strcasecmp(), so that only ASCII letters are mapped, and they're mapped to the lower-case ASCII equivalents. */
static gboolean strcase_equal(gconstpointer ka, gconstpointer kb) | {
const char *a = (const char *)ka;
const char *b = (const char *)kb;
return g_ascii_strcasecmp(a,b) == 0;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.