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
/* 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; RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; RCC_OscInitStruct.LSIState = RCC_LSI_ON; RCC_OscInitStruct.LSEState = RCC_LSE_OFF; if(HAL_RCC_OscConfig(&R...
STMicroelectronics/STM32CubeF4
C++
Other
789
/* param base Pointer to the FLEXIO_MCULCD_Type structure. param mask Interrupts to enable, it is the OR'ed value of ref _flexio_mculcd_interrupt_enable. */
void FLEXIO_MCULCD_EnableInterrupts(FLEXIO_MCULCD_Type *base, uint32_t mask)
/* param base Pointer to the FLEXIO_MCULCD_Type structure. param mask Interrupts to enable, it is the OR'ed value of ref _flexio_mculcd_interrupt_enable. */ void FLEXIO_MCULCD_EnableInterrupts(FLEXIO_MCULCD_Type *base, uint32_t mask)
{ uint32_t interrupts = 0U; if (mask & kFLEXIO_MCULCD_RxFullFlag) { interrupts |= (1U << base->rxShifterEndIndex); } if (mask & kFLEXIO_MCULCD_TxEmptyFlag) { interrupts |= (1U << base->txShifterStartIndex); } FLEXIO_EnableShifterStatusInterrupts(base->flexioBase, interrup...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* serial core request to check that port information in serinfo are suitable */
static int bcm_uart_verify_port(struct uart_port *port, struct serial_struct *serinfo)
/* serial core request to check that port information in serinfo are suitable */ static int bcm_uart_verify_port(struct uart_port *port, struct serial_struct *serinfo)
{ if (port->type != PORT_BCM63XX) return -EINVAL; if (port->irq != serinfo->irq) return -EINVAL; if (port->iotype != serinfo->io_type) return -EINVAL; if (port->mapbase != (unsigned long)serinfo->iomem_base) return -EINVAL; return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* This function retrieves the period of timer interrupts in 100 ns units, returns that value in TimerPeriod, and returns EFI_SUCCESS. If TimerPeriod is NULL, then EFI_INVALID_PARAMETER is returned. If a TimerPeriod of 0 is returned, then the timer is currently disabled. */
EFI_STATUS EFIAPI TimerDriverGetTimerPeriod(IN EFI_TIMER_ARCH_PROTOCOL *This, OUT UINT64 *TimerPeriod)
/* This function retrieves the period of timer interrupts in 100 ns units, returns that value in TimerPeriod, and returns EFI_SUCCESS. If TimerPeriod is NULL, then EFI_INVALID_PARAMETER is returned. If a TimerPeriod of 0 is returned, then the timer is currently disabled. */ EFI_STATUS EFIAPI TimerDriverGetTimerPeriod(I...
{ *TimerPeriod = mTimerPeriod; return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Configures a slave image on the local bus, based on the parameters and some hardcoded system values. Slave Images are images that cause the PowerSpan II to be a master on the PCI bus. Thus, they are outgoing from the standpoint of the local bus. */
int SetSlaveImage(int theImageIndex, unsigned int theBlockSize, int theMemIOFlag, int theEndianness, unsigned int theLocalBaseAddr, unsigned int thePCIBaseAddr)
/* Configures a slave image on the local bus, based on the parameters and some hardcoded system values. Slave Images are images that cause the PowerSpan II to be a master on the PCI bus. Thus, they are outgoing from the standpoint of the local bus. */ int SetSlaveImage(int theImageIndex, unsigned int theBlockSize, int...
{ unsigned int reg_offset = theImageIndex * PB_SLAVE_IMAGE_OFF; unsigned int reg_value = 0; PowerSpanClearBits ((REGS_PB_SLAVE_CSR + reg_offset), PB_SLAVE_CSR_IMG_EN); reg_value = PB_SLAVE_CSR_TA_EN | theEndianness | (theBlockSize << 24); if (theMemIOFlag == PB_SLAVE_USE_MEM_IO) { reg_value |= PB_SLAVE_CS...
EmcraftSystems/u-boot
C++
Other
181
/* Add a socket to the bound sockets list. */
static void __lapb_insert_cb(struct lapb_cb *lapb)
/* Add a socket to the bound sockets list. */ static void __lapb_insert_cb(struct lapb_cb *lapb)
{ list_add(&lapb->node, &lapb_list); lapb_hold(lapb); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Perform any hardware configuration necessary to generate the tick interrupt. */
static void prvSetupTimerInterrupt(void)
/* Perform any hardware configuration necessary to generate the tick interrupt. */ static void prvSetupTimerInterrupt(void)
{ counter1->reload = ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) - 1; counter1->value = counter1->reload; counter1->mask = 1; irq[ IRQ_COUNTER1 ].ien = 1; irq[ IRQ_COUNTER1 ].ipl = portKERNEL_INTERRUPT_PRIORITY_LEVEL; }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Get the status of the specified TMR2 flag. */
en_flag_status_t TMR2_GetStatus(const CM_TMR2_TypeDef *TMR2x, uint32_t u32Flag)
/* Get the status of the specified TMR2 flag. */ en_flag_status_t TMR2_GetStatus(const CM_TMR2_TypeDef *TMR2x, uint32_t u32Flag)
{ en_flag_status_t enStatus = RESET; DDL_ASSERT(IS_TMR2_UNIT(TMR2x)); DDL_ASSERT(IS_TMR2_FLAG(u32Flag)); if (READ_REG32_BIT(TMR2x->STFLR, u32Flag) != 0U) { enStatus = SET; } return enStatus; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Verifies cleanup a stack that still be needed by another thread. */
ZTEST(stack_fail, test_stack_cleanup_error)
/* Verifies cleanup a stack that still be needed by another thread. */ ZTEST(stack_fail, test_stack_cleanup_error)
{ stack_data_t rx_data[STACK_LEN - 1]; k_stack_init(&stack, data, STACK_LEN); k_tid_t tid = k_thread_create(&thread_data2, threadstack2, STACK_SIZE, tStack_pop_entry, &stack, rx_data, NULL, K_PRIO_PREEMPT(0), 0, K_NO_WAIT); k_sleep(K_MSEC(500)); zassert_true(k_stack_cleanup(&stack) == -EAGAIN, "The ...
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Poll wait for the SLVPENDING flag. Wait for the pending status to be set (SLVPENDING = 1) by polling the STAT register. */
static uint32_t I2C_SlavePollPending(I2C_Type *base)
/* Poll wait for the SLVPENDING flag. Wait for the pending status to be set (SLVPENDING = 1) by polling the STAT register. */ static uint32_t I2C_SlavePollPending(I2C_Type *base)
{ uint32_t stat; do { stat = base->STAT; } while (0u == (stat & I2C_STAT_SLVPENDING_MASK)); return stat; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Check whether there is Ps/2 mouse device in system */
BOOLEAN CheckMouseConnect(IN PS2_MOUSE_DEV *MouseDev)
/* Check whether there is Ps/2 mouse device in system */ BOOLEAN CheckMouseConnect(IN PS2_MOUSE_DEV *MouseDev)
{ EFI_STATUS Status; Status = PS2MouseEnable (); if (!EFI_ERROR (Status)) { return TRUE; } return FALSE; }
tianocore/edk2
C++
Other
4,240
/* param base SPDIF base pointer. param handle Pointer to the spdif_handle_t structure which stores the transfer state. param count Bytes count received. retval kStatus_Success Succeed get the transfer count. retval kStatus_NoTransferInProgress There is not a non-blocking transaction currently in progress. */
status_t SPDIF_TransferGetReceiveCount(SPDIF_Type *base, spdif_handle_t *handle, size_t *count)
/* param base SPDIF base pointer. param handle Pointer to the spdif_handle_t structure which stores the transfer state. param count Bytes count received. retval kStatus_Success Succeed get the transfer count. retval kStatus_NoTransferInProgress There is not a non-blocking transaction currently in progress. */ status_t...
{ assert(handle != NULL); status_t status = kStatus_Success; uint8_t queueDriver = handle->queueDriver; if (handle->state != (uint32_t)kSPDIF_Busy) { status = kStatus_NoTransferInProgress; } else { *count = (handle->transferSize[queueDriver] - handle->spdifQueue[queue...
eclipse-threadx/getting-started
C++
Other
310
/* Different semantics to the set_c0_* function built by __BUILD_SET_C0 */
static __cpuinit unsigned int bis_c0_errctl(unsigned int set)
/* Different semantics to the set_c0_* function built by __BUILD_SET_C0 */ static __cpuinit unsigned int bis_c0_errctl(unsigned int set)
{ unsigned int res; res = read_c0_errctl(); write_c0_errctl(res | set); return res; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* After the inode slimming patch, i_pipe/i_bdev/i_cdev share the same location, so checking ->i_pipe is not enough to verify that this is a pipe. */
static struct pipe_inode_info* pipe_info(struct inode *inode)
/* After the inode slimming patch, i_pipe/i_bdev/i_cdev share the same location, so checking ->i_pipe is not enough to verify that this is a pipe. */ static struct pipe_inode_info* pipe_info(struct inode *inode)
{ if (S_ISFIFO(inode->i_mode)) return inode->i_pipe; return NULL; }
robutest/uclinux
C++
GPL-2.0
60
/* return expired entry, or NULL to just start from scratch in rbtree */
static struct request* cfq_check_fifo(struct cfq_queue *cfqq)
/* return expired entry, or NULL to just start from scratch in rbtree */ static struct request* cfq_check_fifo(struct cfq_queue *cfqq)
{ struct request *rq = NULL; if (cfq_cfqq_fifo_expire(cfqq)) return NULL; cfq_mark_cfqq_fifo_expire(cfqq); if (list_empty(&cfqq->fifo)) return NULL; rq = rq_entry_fifo(cfqq->fifo.next); if (time_before(jiffies, rq_fifo_time(rq))) rq = NULL; cfq_log_cfqq(cfqq->cfqd, cfqq, "fifo=%p", rq); return rq; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* priv - priv void ptr to store in the device */
void sandbox_eth_set_priv(int index, void *priv)
/* priv - priv void ptr to store in the device */ void sandbox_eth_set_priv(int index, void *priv)
{ struct udevice *dev; struct eth_sandbox_priv *dev_priv; int ret; ret = uclass_get_device(UCLASS_ETH, index, &dev); if (ret) return; dev_priv = dev_get_priv(dev); dev_priv->priv = priv; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Disables multicast address in RAR and the use of the multicast hash table. */
s32 ixgbe_disable_mc_generic(struct ixgbe_hw *hw)
/* Disables multicast address in RAR and the use of the multicast hash table. */ s32 ixgbe_disable_mc_generic(struct ixgbe_hw *hw)
{ u32 i; u32 rar_entries = hw->mac.num_rar_entries; struct ixgbe_addr_filter_info *a = &hw->addr_ctrl; if (a->mc_addr_in_rar_count > 0) for (i = (rar_entries - a->mc_addr_in_rar_count); i < rar_entries; i++) ixgbe_disable_rar(hw, i); if (a->mta_in_use > 0) IXGBE_WRITE_REG(hw, IXGBE_MCSTCTRL, hw->mac....
robutest/uclinux
C++
GPL-2.0
60
/* This is a helper function that does minimal validation of EAP messages. The length field is verified to be large enough to include the header and not too large to go beyond the end of the buffer. */
int eap_hdr_len_valid(const struct wpabuf *msg, size_t min_payload)
/* This is a helper function that does minimal validation of EAP messages. The length field is verified to be large enough to include the header and not too large to go beyond the end of the buffer. */ int eap_hdr_len_valid(const struct wpabuf *msg, size_t min_payload)
{ const struct eap_hdr *hdr; size_t len; if (msg == NULL) return 0; hdr = wpabuf_head(msg); if (wpabuf_len(msg) < sizeof(*hdr)) { wpa_printf(MSG_INFO, "EAP: Too short EAP frame"); return 0; } len = be_to_host16(hdr->length); if (len < sizeof(*hdr) + min_payload || len > wpabuf_len(msg)) { wpa_printf(MSG...
retro-esp32/RetroESP32
C++
Creative Commons Attribution Share Alike 4.0 International
581
/* Close the directory entry and free the OFile. */
VOID FatCloseDirEnt(IN FAT_DIRENT *DirEnt)
/* Close the directory entry and free the OFile. */ VOID FatCloseDirEnt(IN FAT_DIRENT *DirEnt)
{ FAT_OFILE *OFile; FAT_VOLUME *Volume; OFile = DirEnt->OFile; ASSERT (OFile != NULL); Volume = OFile->Volume; if (OFile->ODir != NULL) { FatDiscardODir (OFile); } if (OFile->Parent == NULL) { Volume->Root = NULL; } else { RemoveEntryList (&OFile->ChildLink); } FreePool (OFile); D...
tianocore/edk2
C++
Other
4,240
/* this function is a POSIX compliant version, which shall perform a variety of control functions on devices. */
int fcntl(int fildes, int cmd,...)
/* this function is a POSIX compliant version, which shall perform a variety of control functions on devices. */ int fcntl(int fildes, int cmd,...)
{ int ret = -1; struct dfs_file *d; d = fd_get(fildes); if (d) { void *arg; va_list ap; va_start(ap, cmd); arg = va_arg(ap, void *); va_end(ap); ret = dfs_file_ioctl(d, cmd, arg); } else ret = -EBADF; if (ret < 0) { rt_set_errno...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* In hello-world.h we have defined the UIP_APPCALL macro to hello_world_appcall so that this funcion is uIP's application function. This function is called whenever an uIP event occurs (e.g. when a new connection is established, new data arrives, sent data is acknowledged, data needs to be retransmitted, etc.). */
void hello_world_appcall(void)
/* In hello-world.h we have defined the UIP_APPCALL macro to hello_world_appcall so that this funcion is uIP's application function. This function is called whenever an uIP event occurs (e.g. when a new connection is established, new data arrives, sent data is acknowledged, data needs to be retransmitted, etc.). */ vo...
{ struct hello_world_state *s = &(uip_conn->appstate); if (uip_connected()) { PSOCK_INIT(&s->p, s->inputbuffer, sizeof(s->inputbuffer)); } handle_connection(s); }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Sends the contents of supplied text buffer over UART. */
void uartSend(uint8_t *bufferPtr, uint32_t length)
/* Sends the contents of supplied text buffer over UART. */ void uartSend(uint8_t *bufferPtr, uint32_t length)
{ while (length != 0) { while ( !(UART_U0LSR & UART_U0LSR_THRE) ); UART_U0THR = *bufferPtr; bufferPtr++; length--; } return; }
microbuilder/LPC1343CodeBase
C++
Other
73
/* Wrappers for chunk registration, shared by read/write chunk code. */
static void rpcrdma_map_one(struct rpcrdma_ia *ia, struct rpcrdma_mr_seg *seg, int writing)
/* Wrappers for chunk registration, shared by read/write chunk code. */ static void rpcrdma_map_one(struct rpcrdma_ia *ia, struct rpcrdma_mr_seg *seg, int writing)
{ seg->mr_dir = writing ? DMA_FROM_DEVICE : DMA_TO_DEVICE; seg->mr_dmalen = seg->mr_len; if (seg->mr_page) seg->mr_dma = ib_dma_map_page(ia->ri_id->device, seg->mr_page, offset_in_page(seg->mr_offset), seg->mr_dmalen, seg->mr_dir); else seg->mr_dma = ib_dma_map_single(ia->ri_id->device, seg->mr_offs...
EmcraftSystems/linux-emcraft
C++
Other
266
/* dispose of a permits list in which all the key pointers have been copied */
static void afs_dispose_of_permits(struct rcu_head *rcu)
/* dispose of a permits list in which all the key pointers have been copied */ static void afs_dispose_of_permits(struct rcu_head *rcu)
{ struct afs_permits *permits = container_of(rcu, struct afs_permits, rcu); _enter("{%d}", permits->count); kfree(permits); }
robutest/uclinux
C++
GPL-2.0
60
/* Callback function called when a command is received from the cloud. */
int Leds_Controll(const char *str)
/* Callback function called when a command is received from the cloud. */ int Leds_Controll(const char *str)
{ memset(strstr((char *)str, (char *)"}") + 1, 0, strlen(str)); JsonNode *_main = json_decode(str); JsonNode *red = json_find_member(_main, "red"); JsonNode *blue = json_find_member(_main, "blue"); JsonNode *green = json_find_member(_main, "green"); cn0410->Controll((float)red->number_, (float)blue->number_, (flo...
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* The main function of the adi7417 Get Temperature. return none */
void TemperatureGet(void)
/* The main function of the adi7417 Get Temperature. return none */ void TemperatureGet(void)
{ unsigned long ulTemp; int i; xSysCtlClockSet(12000000, xSYSCTL_XTAL_12MHZ | xSYSCTL_OSC_MAIN); AD7415Init(10000, AD7415_MODE_POWER_DOWN); while(1) { for(i = 0; i < 10; i++) { if(i == 3) { AD7415OneShotConvert(); ...
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* See README.rockchip for details of the rksd format */
static int rksd_check_image_type(uint8_t type)
/* See README.rockchip for details of the rksd format */ static int rksd_check_image_type(uint8_t type)
{ if (type == IH_TYPE_RKSD) return EXIT_SUCCESS; else return EXIT_FAILURE; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Get the number of wait states for read and write operations. */
uint8_t _flash_get_wait_state(struct _flash_device *const device)
/* Get the number of wait states for read and write operations. */ uint8_t _flash_get_wait_state(struct _flash_device *const device)
{ return hri_nvmctrl_get_CTRLB_reg(device->hw, NVMCTRL_CTRLB_RWS_Msk); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* edac_device_free_ctl_info() frees the memory allocated by the edac_device_alloc_ctl_info() function */
void edac_device_free_ctl_info(struct edac_device_ctl_info *ctl_info)
/* edac_device_free_ctl_info() frees the memory allocated by the edac_device_alloc_ctl_info() function */ void edac_device_free_ctl_info(struct edac_device_ctl_info *ctl_info)
{ edac_device_unregister_sysfs_main_kobj(ctl_info); }
robutest/uclinux
C++
GPL-2.0
60
/* Here, we then check if the disconnect reason is due to a timout, and if so, we call the ble_svc_lls_event_fn callback with the current alert level. The actual alert implementation is left up to the developer. */
void ble_svc_lls_on_gap_disconnect(int reason)
/* Here, we then check if the disconnect reason is due to a timout, and if so, we call the ble_svc_lls_event_fn callback with the current alert level. The actual alert implementation is left up to the developer. */ void ble_svc_lls_on_gap_disconnect(int reason)
{ if (reason == BLE_HS_HCI_ERR(BLE_ERR_CONN_SPVN_TMO)) { ble_svc_lls_cb_fn(ble_svc_lls_alert_level); } }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* Event handler for the library USB Connection event. */
void EVENT_USB_Device_Connect(void)
/* Event handler for the library USB Connection event. */ void EVENT_USB_Device_Connect(void)
{ LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); uIPManagement_Init(); }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Unfortunately, the enable/disable functions may be called either from process or IRQ context, and we */
static void clcdfb_sleep(unsigned int ms)
/* Unfortunately, the enable/disable functions may be called either from process or IRQ context, and we */ static void clcdfb_sleep(unsigned int ms)
{ if (in_atomic()) { mdelay(ms); } else { msleep(ms); } }
robutest/uclinux
C++
GPL-2.0
60
/* check if the specified flag in SYSCFG_CFG2 is set or not. */
FlagStatus syscfg_flag_get(uint32_t syscfg_flag)
/* check if the specified flag in SYSCFG_CFG2 is set or not. */ FlagStatus syscfg_flag_get(uint32_t syscfg_flag)
{ if((SYSCFG_CFG2 & syscfg_flag) != (uint32_t)RESET){ return SET; }else{ return RESET; } }
liuxuming/trochili
C++
Apache License 2.0
132
/* iwm_hal_send_umac_cmd(): This is a special case for iwm_hal_send_host_cmd() to send direct UMAC cmd (without LMAC involved). */
int iwm_hal_send_umac_cmd(struct iwm_priv *iwm, struct iwm_udma_wifi_cmd *udma_cmd, struct iwm_umac_cmd *umac_cmd, const void *payload, u16 payload_size)
/* iwm_hal_send_umac_cmd(): This is a special case for iwm_hal_send_host_cmd() to send direct UMAC cmd (without LMAC involved). */ int iwm_hal_send_umac_cmd(struct iwm_priv *iwm, struct iwm_udma_wifi_cmd *udma_cmd, struct iwm_umac_cmd *umac_cmd, const void *payload, u16 payload_size)
{ return iwm_hal_send_host_cmd(iwm, udma_cmd, umac_cmd, NULL, payload, payload_size); }
robutest/uclinux
C++
GPL-2.0
60
/* Return value: number of bytes printed to buffer */
static ssize_t pmcraid_show_adapter_id(struct device *dev, struct device_attribute *attr, char *buf)
/* Return value: number of bytes printed to buffer */ static ssize_t pmcraid_show_adapter_id(struct device *dev, struct device_attribute *attr, char *buf)
{ struct Scsi_Host *shost = class_to_shost(dev); struct pmcraid_instance *pinstance = (struct pmcraid_instance *)shost->hostdata; u32 adapter_id = (pinstance->pdev->bus->number << 8) | pinstance->pdev->devfn; u32 aen_group = pmcraid_event_family.id; return snprintf(buf, PAGE_SIZE, "adapter id: %d\nminor: %d...
robutest/uclinux
C++
GPL-2.0
60
/* This function is used to backup tm_year parameter in rtc_timeinfo global variable before system reset. */
void rtc_backup_timeinfo(void)
/* This function is used to backup tm_year parameter in rtc_timeinfo global variable before system reset. */ void rtc_backup_timeinfo(void)
{ u32 value = BKUP_Read(0); value = (value & ~BIT_RTC_BACKUP) | (rtc_timeinfo.tm_year << BIT_RTC_BACKUP_SHIFT); BKUP_Write(0, value); BKUP_Set(0, BIT_RTC_RESTORE); }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* The constructor function caches the pointer to PEI services. It will always return EFI_SUCCESS. */
EFI_STATUS EFIAPI PeiServicesTablePointerLibConstructor(IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)
/* The constructor function caches the pointer to PEI services. It will always return EFI_SUCCESS. */ EFI_STATUS EFIAPI PeiServicesTablePointerLibConstructor(IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)
{ gPeiServices = PeiServices; return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* The data port provides fast access to some things. We still have all the 5uS delays to worry about. */
static u8 read_zsdata(struct z8530_channel *c)
/* The data port provides fast access to some things. We still have all the 5uS delays to worry about. */ static u8 read_zsdata(struct z8530_channel *c)
{ u8 r; r=z8530_read_port(c->dataio); return r; }
robutest/uclinux
C++
GPL-2.0
60
/* SPI MSP Initialization This function configures the hardware resources used in this example. */
void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi)
/* SPI MSP Initialization This function configures the hardware resources used in this example. */ void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi)
{ GPIO_InitTypeDef GPIO_InitStruct = {0}; if(hspi->Instance==SPI1) { __HAL_RCC_SPI1_CLK_ENABLE(); __HAL_RCC_GPIOA_CLK_ENABLE(); GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_11|GPIO_PIN_12; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* These routines are just dispatchers to the VIA/OSS/PSC routines. */
void mac_enable_irq(unsigned int irq)
/* These routines are just dispatchers to the VIA/OSS/PSC routines. */ void mac_enable_irq(unsigned int irq)
{ int irq_src = IRQ_SRC(irq); switch(irq_src) { case 1: via_irq_enable(irq); break; case 2: case 7: if (oss_present) oss_irq_enable(irq); else via_irq_enable(irq); break; case 3: case 4: case 5: case 6: if (psc_present) psc_irq_enable(irq); else if (oss_present) oss_irq_enable(irq); ...
EmcraftSystems/linux-emcraft
C++
Other
266
/* @params ticks - Number of miliseconds to delay. */
void timer_sleep(uint32_t ticks)
/* @params ticks - Number of miliseconds to delay. */ void timer_sleep(uint32_t ticks)
{ timer_delay_count = ticks; while (timer_delay_count != 0u); }
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* The main purpose of this is to make sure that a CHECK_CONDITION is properly treated. */
void scsi_report_bus_reset(struct Scsi_Host *shost, int channel)
/* The main purpose of this is to make sure that a CHECK_CONDITION is properly treated. */ void scsi_report_bus_reset(struct Scsi_Host *shost, int channel)
{ struct scsi_device *sdev; __shost_for_each_device(sdev, shost) { if (channel == sdev_channel(sdev)) __scsi_report_device_reset(sdev, NULL); } }
robutest/uclinux
C++
GPL-2.0
60
/* Managed overflow event of OUT packet on control endpoint. */
static void udd_ctrl_overflow(void)
/* Managed overflow event of OUT packet on control endpoint. */ static void udd_ctrl_overflow(void)
{ if (Is_udd_in_send(0)) return; if (UDD_EPCTRL_HANDSHAKE_WAIT_IN_ZLP == udd_ep_control_state) { udd_enable_stall_handshake(0); } }
remotemcu/remcu-chip-sdks
C++
null
436
/* Collect the number of bits set within a port bitmap. */
UINT8 AhciGetNumberOfPortsFromMap(IN UINT32 PortBitMap)
/* Collect the number of bits set within a port bitmap. */ UINT8 AhciGetNumberOfPortsFromMap(IN UINT32 PortBitMap)
{ UINT8 NumberOfPorts; NumberOfPorts = 0; while (PortBitMap != 0) { if ((PortBitMap & ((UINT32)BIT0)) != 0) { NumberOfPorts++; } PortBitMap = PortBitMap >> 1; } return NumberOfPorts; }
tianocore/edk2
C++
Other
4,240
/* This function is called in order to decode "LogNotification" and */
static void dissect_zcl_appl_stats_log_rsp(tvbuff_t *tvb, proto_tree *tree, guint *offset)
/* This function is called in order to decode "LogNotification" and */ static void dissect_zcl_appl_stats_log_rsp(tvbuff_t *tvb, proto_tree *tree, guint *offset)
{ guint32 log_len; proto_tree_add_item(tree, hf_zbee_zcl_appl_stats_utc_time, tvb, *offset, 4, ENC_LITTLE_ENDIAN); *offset += 4; proto_tree_add_item(tree, hf_zbee_zcl_appl_stats_log_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN); *offset += 4; log_len = tvb_get_letohl(tvb, *offset); proto_tree_add_...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* pdacf_pcm_hw_free - hw_free callback for playback and capture */
static int pdacf_pcm_hw_free(struct snd_pcm_substream *subs)
/* pdacf_pcm_hw_free - hw_free callback for playback and capture */ static int pdacf_pcm_hw_free(struct snd_pcm_substream *subs)
{ return snd_pcm_free_vmalloc_buffer(subs); }
robutest/uclinux
C++
GPL-2.0
60
/* A buffer cannot be placed on two lists at the same time. */
void skb_insert(struct sk_buff *old, struct sk_buff *newsk, struct sk_buff_head *list)
/* A buffer cannot be placed on two lists at the same time. */ void skb_insert(struct sk_buff *old, struct sk_buff *newsk, struct sk_buff_head *list)
{ unsigned long flags; spin_lock_irqsave(&list->lock, flags); __skb_insert(newsk, old->prev, old, list); spin_unlock_irqrestore(&list->lock, flags); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Removes all SAS PHYs and remote PHYs for a given Scsi_Host. Must be called just before scsi_remove_host for SAS HBAs. */
void sas_remove_host(struct Scsi_Host *shost)
/* Removes all SAS PHYs and remote PHYs for a given Scsi_Host. Must be called just before scsi_remove_host for SAS HBAs. */ void sas_remove_host(struct Scsi_Host *shost)
{ sas_remove_children(&shost->shost_gendev); }
robutest/uclinux
C++
GPL-2.0
60
/* strnstr - Find the first substring in a length-limited string @s1: The string to be searched @s2: The string to search for @len: the maximum number of characters to search */
char* strnstr(const char *s1, const char *s2, size_t len)
/* strnstr - Find the first substring in a length-limited string @s1: The string to be searched @s2: The string to search for @len: the maximum number of characters to search */ char* strnstr(const char *s1, const char *s2, size_t len)
{ size_t l1 = len, l2; l2 = strlen(s2); if (!l2) return (char *)s1; while (l1 >= l2) { l1--; if (!memcmp(s1, s2, l2)) return (char *)s1; s1++; } return NULL; }
robutest/uclinux
C++
GPL-2.0
60
/* Allocates and initializes one HMAC_CTX context for subsequent HMAC-MD use. */
STATIC VOID* HmacMdNew(VOID)
/* Allocates and initializes one HMAC_CTX context for subsequent HMAC-MD use. */ STATIC VOID* HmacMdNew(VOID)
{ VOID *HmacMdCtx; HmacMdCtx = AllocateZeroPool (sizeof (mbedtls_md_context_t)); if (HmacMdCtx == NULL) { return NULL; } return HmacMdCtx; }
tianocore/edk2
C++
Other
4,240
/* Initializes the SDIO data path according to the specified parameters in the SDIO_DataInitStruct. */
void SDIO_ClockSet(u32 value)
/* Initializes the SDIO data path according to the specified parameters in the SDIO_DataInitStruct. */ void SDIO_ClockSet(u32 value)
{ SDIO->MMC_CARDSEL = (SDIO_MMC_CARDSEL_CTREN | SDIO_MMC_CARDSEL_ENPCLK | (value & 0x3F)); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Modify the bad block marker inside a spare area, using the given scheme. */
void nand_flash_spare_scheme_write_bad_block_marker(const struct nand_flash_spare_scheme *scheme, uint8_t *spare, uint8_t marker)
/* Modify the bad block marker inside a spare area, using the given scheme. */ void nand_flash_spare_scheme_write_bad_block_marker(const struct nand_flash_spare_scheme *scheme, uint8_t *spare, uint8_t marker)
{ spare[scheme->bad_block_marker_position] = marker; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Sets the flow control high/low threshold (watermark) registers. If flow control XON frame transmission is enabled, then set XON frame transmission as well. */
s32 e1000e_set_fc_watermarks(struct e1000_hw *hw)
/* Sets the flow control high/low threshold (watermark) registers. If flow control XON frame transmission is enabled, then set XON frame transmission as well. */ s32 e1000e_set_fc_watermarks(struct e1000_hw *hw)
{ u32 fcrtl = 0, fcrth = 0; if (hw->fc.current_mode & e1000_fc_tx_pause) { fcrtl = hw->fc.low_water; fcrtl |= E1000_FCRTL_XONE; fcrth = hw->fc.high_water; } ew32(FCRTL, fcrtl); ew32(FCRTH, fcrth); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* If AuthenticationOperation is not recongnized, return FALSE. If AuthenticationOperation is EFI_AUTH_OPERATION_NONE, return FALSE. If AuthenticationOperation includes security operation and authentication operation, return FALSE. If the previous register handler can't be executed before the later register handler, re...
BOOLEAN CheckAuthentication2Operation(IN UINT32 CurrentAuthOperation, IN UINT32 CheckAuthOperation)
/* If AuthenticationOperation is not recongnized, return FALSE. If AuthenticationOperation is EFI_AUTH_OPERATION_NONE, return FALSE. If AuthenticationOperation includes security operation and authentication operation, return FALSE. If the previous register handler can't be executed before the later register handler, re...
{ if (CheckAuthOperation == EFI_AUTH_OPERATION_NONE) { return FALSE; } if ((CheckAuthOperation & ~(EFI_AUTH_IMAGE_OPERATION_MASK | EFI_AUTH_NONE_IMAGE_OPERATION_MASK | EFI_AUTH_OPERATION_IMAGE_REQUIRED)) != 0) { return FALSE; } if ((Current...
tianocore/edk2
C++
Other
4,240
/* UART MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_UART_MspDeInit(UART_HandleTypeDef *huart)
/* UART MSP De-Initialization This function freeze the hardware resources used in this example. */ void HAL_UART_MspDeInit(UART_HandleTypeDef *huart)
{ if(huart->Instance==USART3) { __HAL_RCC_USART3_CLK_DISABLE(); HAL_GPIO_DeInit(GPIOB, GPIO_PIN_11|GPIO_PIN_10); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function will not return until data has been transmitted */
long SPITransfer(unsigned long ulBase, unsigned char *ucDout, unsigned char *ucDin, unsigned long ulCount, unsigned long ulFlags)
/* This function will not return until data has been transmitted */ long SPITransfer(unsigned long ulBase, unsigned char *ucDout, unsigned char *ucDin, unsigned long ulCount, unsigned long ulFlags)
{ unsigned long ulWordLength; long lRet; ulWordLength = (HWREG(ulBase + MCSPI_O_CH0CONF) & MCSPI_CH0CONF_WL_M); if( !((ulWordLength == SPI_WL_8) || (ulWordLength == SPI_WL_16) || (ulWordLength == SPI_WL_32)) ) { return -1; } if( ulWordLength == SPI_WL_8 ) { lRet = SPITransfer8(ulBase,ucDout...
micropython/micropython
C++
Other
18,334
/* static double predict_qp(Predictor *p, double size, double var) { printf("coeff:%f, count:%f, var:%f, size:%f//\n", p->coeff, p->count, var, size); return p->coeff*var / (size*p->count); } */
static void update_predictor(Predictor *p, double q, double var, double size)
/* static double predict_qp(Predictor *p, double size, double var) { printf("coeff:%f, count:%f, var:%f, size:%f//\n", p->coeff, p->count, var, size); return p->coeff*var / (size*p->count); } */ static void update_predictor(Predictor *p, double q, double var, double size)
{ double new_coeff= size*q / (var + 1); if(var<10) return; p->count*= p->decay; p->coeff*= p->decay; p->count++; p->coeff+= new_coeff; }
DC-SWAT/DreamShell
C++
null
404
/* Checks whether the specified EXTI line is asserted or not. */
INTStatus EXTI_GetITStatus(uint32_t EXTI_Line)
/* Checks whether the specified EXTI line is asserted or not. */ INTStatus EXTI_GetITStatus(uint32_t EXTI_Line)
{ INTStatus bitstatus = RESET; uint32_t enablestatus = 0; assert_param(IS_GET_EXTI_LINE(EXTI_Line)); enablestatus = EXTI->IMASK & EXTI_Line; if (((EXTI->PEND & EXTI_Line) != (uint32_t)RESET) && (enablestatus != (uint32_t)RESET)) { bitstatus = SET; } else { bitstatus...
pikasTech/PikaPython
C++
MIT License
1,403
/* alloc_dca_provider - get data struct for describing a dca provider @ops - pointer to struct of dca operation function pointers @priv_size - size of extra mem to be added for provider's needs */
struct dca_provider* alloc_dca_provider(struct dca_ops *ops, int priv_size)
/* alloc_dca_provider - get data struct for describing a dca provider @ops - pointer to struct of dca operation function pointers @priv_size - size of extra mem to be added for provider's needs */ struct dca_provider* alloc_dca_provider(struct dca_ops *ops, int priv_size)
{ struct dca_provider *dca; int alloc_size; alloc_size = (sizeof(*dca) + priv_size); dca = kzalloc(alloc_size, GFP_KERNEL); if (!dca) return NULL; dca->ops = ops; return dca; }
robutest/uclinux
C++
GPL-2.0
60
/* Set the specified data holding register value for dual channel DAC. */
void DAC_SetDualChData(uint32_t DAC_Align, uint16_t Data2, uint16_t Data1)
/* Set the specified data holding register value for dual channel DAC. */ void DAC_SetDualChData(uint32_t DAC_Align, uint16_t Data2, uint16_t Data1)
{ uint32_t data = 0, tmp = 0; assert_param(IS_DAC_ALIGN(DAC_Align)); assert_param(IS_DAC_DATA(Data1)); assert_param(IS_DAC_DATA(Data2)); if (DAC_Align == DAC_ALIGN_R_8BIT) { data = ((uint32_t)Data2 << 8) | Data1; } else { data = ((uint32_t)Data2 << 16) | Data1; } ...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* tipc_nametbl_subscribe - add a subscription object to the name table */
void tipc_nametbl_subscribe(struct subscription *s)
/* tipc_nametbl_subscribe - add a subscription object to the name table */ void tipc_nametbl_subscribe(struct subscription *s)
{ u32 type = s->seq.type; struct name_seq *seq; write_lock_bh(&tipc_nametbl_lock); seq = nametbl_find_seq(type); if (!seq) { seq = tipc_nameseq_create(type, &table.types[hash(type)]); } if (seq){ spin_lock_bh(&seq->lock); dbg("tipc_nametbl_subscribe:found %p for {%u,%u,%u}\n", seq, type, s->seq.lower...
EmcraftSystems/linux-emcraft
C++
Other
266
/* then we just return, if multiple IRQs are pending then we will just take another exception, big deal. */
asmlinkage void plat_irq_dispatch(void)
/* then we just return, if multiple IRQs are pending then we will just take another exception, big deal. */ asmlinkage void plat_irq_dispatch(void)
{ unsigned int pending = read_c0_status() & read_c0_cause(); if (pending & CAUSEF_IP7) do_IRQ(SGI_TIMER_IRQ); else if (pending & CAUSEF_IP2) indy_local0_irqdispatch(); else if (pending & CAUSEF_IP3) indy_local1_irqdispatch(); else if (pending & CAUSEF_IP6) indy_buserror_irq(); else if (pending & (CAUSEF_I...
EmcraftSystems/linux-emcraft
C++
Other
266
/* Searches for the next matching section within the specified file. */
EFI_STATUS EFIAPI PeiFfsFindSectionData3(IN CONST EFI_PEI_SERVICES **PeiServices, IN EFI_SECTION_TYPE SectionType, IN UINTN SectionInstance, IN EFI_PEI_FILE_HANDLE FileHandle, OUT VOID **SectionData, OUT UINT32 *AuthenticationStatus)
/* Searches for the next matching section within the specified file. */ EFI_STATUS EFIAPI PeiFfsFindSectionData3(IN CONST EFI_PEI_SERVICES **PeiServices, IN EFI_SECTION_TYPE SectionType, IN UINTN SectionInstance, IN EFI_PEI_FILE_HANDLE FileHandle, OUT VOID **SectionData, OUT UINT32 *AuthenticationStatus)
{ PEI_CORE_FV_HANDLE *CoreFvHandle; CoreFvHandle = FileHandleToVolume (FileHandle); if ((CoreFvHandle == NULL) || (CoreFvHandle->FvPpi == NULL)) { return EFI_NOT_FOUND; } if ((CoreFvHandle->FvPpi->Signature == EFI_PEI_FIRMWARE_VOLUME_PPI_SIGNATURE) && (CoreFvHandle->FvPpi->Revision == EFI_PEI_FIRMW...
tianocore/edk2
C++
Other
4,240
/* Configure MPU for the thread. This function configures per thread memory map reprogramming the MPU. */
void configure_mpu_thread(struct k_thread *thread)
/* Configure MPU for the thread. This function configures per thread memory map reprogramming the MPU. */ void configure_mpu_thread(struct k_thread *thread)
{ arc_core_mpu_disable(); arc_core_mpu_configure_thread(thread); arc_core_mpu_enable(); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Allow the caller to discover all of the SMBIOS records. */
EFI_STATUS EFIAPI GetNextSmbiosRecord(IN CONST EFI_SMBIOS_PROTOCOL *This, IN OUT EFI_SMBIOS_ENTRY **CurrentSmbiosEntry, OUT EFI_SMBIOS_TABLE_HEADER **Record)
/* Allow the caller to discover all of the SMBIOS records. */ EFI_STATUS EFIAPI GetNextSmbiosRecord(IN CONST EFI_SMBIOS_PROTOCOL *This, IN OUT EFI_SMBIOS_ENTRY **CurrentSmbiosEntry, OUT EFI_SMBIOS_TABLE_HEADER **Record)
{ LIST_ENTRY *Link; LIST_ENTRY *Head; SMBIOS_INSTANCE *Private; EFI_SMBIOS_ENTRY *SmbiosEntry; EFI_SMBIOS_TABLE_HEADER *SmbiosTableHeader; Private = SMBIOS_INSTANCE_FROM_THIS (This); if (*CurrentSmbiosEntry == NULL) { Head = &Private->DataListHead; } els...
tianocore/edk2
C++
Other
4,240
/* During device pull we need to appropiately set the sdev state. */
static void _scsih_ublock_io_device(struct MPT2SAS_ADAPTER *ioc, u16 handle)
/* During device pull we need to appropiately set the sdev state. */ static void _scsih_ublock_io_device(struct MPT2SAS_ADAPTER *ioc, u16 handle)
{ struct MPT2SAS_DEVICE *sas_device_priv_data; struct scsi_device *sdev; shost_for_each_device(sdev, ioc->shost) { sas_device_priv_data = sdev->hostdata; if (!sas_device_priv_data) continue; if (!sas_device_priv_data->block) continue; if (sas_device_priv_data->sas_target->handle == handle) { dewtpri...
robutest/uclinux
C++
GPL-2.0
60
/* Enables or disables the selected DAC channel wave generation. */
void DAC_WaveGenerationCmd(uint32_t DAC_Channel, uint32_t DAC_Wave, FunctionalState NewState)
/* Enables or disables the selected DAC channel wave generation. */ void DAC_WaveGenerationCmd(uint32_t DAC_Channel, uint32_t DAC_Wave, FunctionalState NewState)
{ assert_param(IS_DAC_CHANNEL(DAC_Channel)); assert_param(IS_DAC_WAVE(DAC_Wave)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { DAC->CR |= DAC_Wave << DAC_Channel; } else { DAC->CR &= ~(DAC_Wave << DAC_Channel); } }
gcallipo/RadioDSP-Stm32f103
C++
Common Creative - Attribution 3.0
51
/* set the ipu channel buffer mode, single or double */
void ipu_idmac_channel_mode_sel(int32_t ipu_index, int32_t channel, int32_t double_buf_en)
/* set the ipu channel buffer mode, single or double */ void ipu_idmac_channel_mode_sel(int32_t ipu_index, int32_t channel, int32_t double_buf_en)
{ int32_t idx = channel / 32; int32_t offset = channel % 32; ipu_write_field(ipu_index, IPU_IPU_CH_DB_MODE_SEL_0__ADDR + idx * 4, 1 << offset, double_buf_en); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* function to be used with macro "fasttm": optimized for absence of tag methods */
const TValue* luaT_gettm(Table *events, TMS event, TString *ename)
/* function to be used with macro "fasttm": optimized for absence of tag methods */ const TValue* luaT_gettm(Table *events, TMS event, TString *ename)
{ events->flags |= cast_byte(1u<<event); return NULL; } else return tm; }
DC-SWAT/DreamShell
C++
null
404
/* Probably it should be a library function... search for first non-zero word or memcmp with zero_page, whatever is better for particular architecture. Linus? */
static int all_zeroes(__le32 *p, __le32 *q)
/* Probably it should be a library function... search for first non-zero word or memcmp with zero_page, whatever is better for particular architecture. Linus? */ static int all_zeroes(__le32 *p, __le32 *q)
{ while (p < q) if (*p++) return 0; return 1; }
robutest/uclinux
C++
GPL-2.0
60
/* Enables or disables the I2C nbytes reload mode. */
void I2C_ReloadCmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
/* Enables or disables the I2C nbytes reload mode. */ void I2C_ReloadCmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
{ assert_param(IS_I2C_ALL_PERIPH(I2Cx)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { I2Cx->CR2 |= I2C_CR2_RELOAD; } else { I2Cx->CR2 &= (uint32_t)~((uint32_t)I2C_CR2_RELOAD); } }
ajhc/demo-cortex-m3
C++
null
38
/* Abort an essential thread. The kernel shall raise a fatal system error if an essential thread aborts, implement k_sys_fatal_error_handler to handle this error. */
ZTEST(threads_lifecycle, test_essential_thread_abort)
/* Abort an essential thread. The kernel shall raise a fatal system error if an essential thread aborts, implement k_sys_fatal_error_handler to handle this error. */ ZTEST(threads_lifecycle, test_essential_thread_abort)
{ k_tid_t tid = k_thread_create(&kthread_thread1, kthread_stack, STACKSIZE, abort_thread_entry, NULL, NULL, NULL, K_PRIO_PREEMPT(0), 0, K_NO_WAIT); k_sem_take(&sync_sem, K_FOREVER); k_thread_abort(tid); zassert_true(fatal_error_signaled, "fatal error was not signaled"); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Declaration of the uart configuration function. \biref uart0 configre */
void UART0Configuration(void)
/* Declaration of the uart configuration function. \biref uart0 configre */ void UART0Configuration(void)
{ xSPinTypeUART(UART0Rx,PB0); xSPinTypeUART(UART0Tx,PB1); xSysCtlPeripheralEnable(xSYSCTL_PERIPH_UART0); SysCtlPeripheralClockSourceSet(SYSCTL_PERIPH_UART_S_EXT12M); xHWREG(UART0_BASE + UART_FCR) |= 0x6; xHWREG(UART0_BASE + UART_FCR) &= ~(0xF0); xHWREG(UART0_BASE + UART_FCR) |= 0; ...
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Functions to lock and unlock any filesystem running on the device. */
static int lock_fs(struct mapped_device *md)
/* Functions to lock and unlock any filesystem running on the device. */ static int lock_fs(struct mapped_device *md)
{ int r; WARN_ON(md->frozen_sb); md->frozen_sb = freeze_bdev(md->bdev); if (IS_ERR(md->frozen_sb)) { r = PTR_ERR(md->frozen_sb); md->frozen_sb = NULL; return r; } set_bit(DMF_FROZEN, &md->flags); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* If Address > 0x0FFFFFFF, then ASSERT(). If StartBit is greater than 7, then ASSERT(). If EndBit is greater than 7, 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(). */
UINT8 EFIAPI PciExpressBitFieldOr8(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 OrData)
/* If Address > 0x0FFFFFFF, then ASSERT(). If StartBit is greater than 7, then ASSERT(). If EndBit is greater than 7, 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(). */ UINT8 EFIAPI PciExpressBitFieldOr8(IN ...
{ ASSERT_INVALID_PCI_ADDRESS (Address); return MmioBitFieldOr8 ( (UINTN)GetPciExpressBaseAddress () + Address, StartBit, EndBit, OrData ); }
tianocore/edk2
C++
Other
4,240
/* Return: Pointer to the newly allocated completion-queue event if successful NULL otherwise. */
struct lpfc_cq_event* lpfc_sli4_cq_event_alloc(struct lpfc_hba *phba)
/* Return: Pointer to the newly allocated completion-queue event if successful NULL otherwise. */ struct lpfc_cq_event* lpfc_sli4_cq_event_alloc(struct lpfc_hba *phba)
{ struct lpfc_cq_event *cq_event; unsigned long iflags; spin_lock_irqsave(&phba->hbalock, iflags); cq_event = __lpfc_sli4_cq_event_alloc(phba); spin_unlock_irqrestore(&phba->hbalock, iflags); return cq_event; }
robutest/uclinux
C++
GPL-2.0
60
/* I-Have-Request ::= SEQUENCE { deviceIdentifier BACnetObjectIdentifier, objectIdentifier BACnetObjectIdentifier, objectName CharacterString } */
static guint fIHaveRequest(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
/* I-Have-Request ::= SEQUENCE { deviceIdentifier BACnetObjectIdentifier, objectIdentifier BACnetObjectIdentifier, objectName CharacterString } */ static guint fIHaveRequest(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
{ offset = fApplicationTypes(tvb, pinfo, tree, offset, "Device Identifier: "); offset = fApplicationTypes(tvb, pinfo, tree, offset, "Object Identifier: "); return fApplicationTypes(tvb, pinfo, tree, offset, "Object Name: "); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* There are only two requests that we are going to see in actual practise: LM_ST_SHARED and LM_ST_UNLOCKED */
static void handle_callback(struct gfs2_glock *gl, unsigned int state, unsigned long delay)
/* There are only two requests that we are going to see in actual practise: LM_ST_SHARED and LM_ST_UNLOCKED */ static void handle_callback(struct gfs2_glock *gl, unsigned int state, unsigned long delay)
{ int bit = delay ? GLF_PENDING_DEMOTE : GLF_DEMOTE; set_bit(bit, &gl->gl_flags); if (gl->gl_demote_state == LM_ST_EXCLUSIVE) { gl->gl_demote_state = state; gl->gl_demote_time = jiffies; } else if (gl->gl_demote_state != LM_ST_UNLOCKED && gl->gl_demote_state != state) { gl->gl_demote_state = LM_ST_UNLOCKED...
robutest/uclinux
C++
GPL-2.0
60
/* returns: the targetted node offset in the base device tree Negative error code on error */
static int overlay_get_target(const void *fdt, const void *fdto, int fragment, char const **pathp)
/* returns: the targetted node offset in the base device tree Negative error code on error */ static int overlay_get_target(const void *fdt, const void *fdto, int fragment, char const **pathp)
{ uint32_t phandle; const char *path = NULL; int path_len = 0, ret; phandle = overlay_get_target_phandle (fdto, fragment); if (phandle == (uint32_t)-1) { return -FDT_ERR_BADPHANDLE; } if (!phandle) { path = fdt_getprop (fdto, fragment, "target-path", &path_len); if (path) { r...
tianocore/edk2
C++
Other
4,240
/* TIM_Base MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim_base)
/* TIM_Base MSP De-Initialization This function freeze the hardware resources used in this example. */ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim_base)
{ if(htim_base->Instance==TIM1) { __HAL_RCC_TIM1_CLK_DISABLE(); } else if(htim_base->Instance==TIM2) { __HAL_RCC_TIM2_CLK_DISABLE(); } else if(htim_base->Instance==TIM4) { __HAL_RCC_TIM4_CLK_DISABLE(); } else if(htim_base->Instance==TIM7) { __HAL_RCC_TIM7_CLK_DISABLE(); } else ...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Definition of the button poll task described in the comments at the top of this file. */
static void prvButtonPollTask(void *pvParameters)
/* Definition of the button poll task described in the comments at the top of this file. */ static void prvButtonPollTask(void *pvParameters)
{ unsigned char ucLastState = pdFALSE, ucState; xQueueMessage xMessage; for( ;; ) { ucState = ( halButtonsPressed() & BUTTON_UP ); if( ucState != 0 ) { ucState = pdTRUE; } if( ucState != ucLastState ) { xMessage.cMessageID = mainMESSAGE_BUTTON_UP; xMessage.ulMessageValue = ( unsigned long ) ucSta...
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Enable or disable a DMA channel (by index ch: 0 .. 31) by setting a bit in DMA_ERQ. */
static int __kinetis_dma_ch_enable(int ch, int enable, int single)
/* Enable or disable a DMA channel (by index ch: 0 .. 31) by setting a bit in DMA_ERQ. */ static int __kinetis_dma_ch_enable(int ch, int enable, int single)
{ DMAAPI_LOCKED_BEGIN if (single) KINETIS_DMA->tcd[ch].csr |= (1 << 3); if (enable) KINETIS_DMA->erq |= 1 << ch; else KINETIS_DMA->erq &= ~(1 << ch); DMAAPI_LOCKED_END }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Allocate a circular buffer and all associated memory. */
static struct edge_buf * edge_buf_alloc(unsigned int size)
/* Allocate a circular buffer and all associated memory. */ static struct edge_buf * edge_buf_alloc(unsigned int size)
{ struct edge_buf *eb; if (size == 0) return NULL; eb = kmalloc(sizeof(struct edge_buf), GFP_KERNEL); if (eb == NULL) return NULL; eb->buf_buf = kmalloc(size, GFP_KERNEL); if (eb->buf_buf == NULL) { kfree(eb); return NULL; } eb->buf_size = size; eb->buf_get = eb->buf_put = eb->buf_buf; return eb; }
robutest/uclinux
C++
GPL-2.0
60
/* Note: we hold the dentry use count while the file is open. */
static __be32 nlm_fopen(struct svc_rqst *rqstp, struct nfs_fh *f, struct file **filp)
/* Note: we hold the dentry use count while the file is open. */ static __be32 nlm_fopen(struct svc_rqst *rqstp, struct nfs_fh *f, struct file **filp)
{ __be32 nfserr; struct svc_fh fh; fh_init(&fh,0); fh.fh_handle.fh_size = f->size; memcpy((char*)&fh.fh_handle.fh_base, f->data, f->size); fh.fh_export = NULL; exp_readlock(); nfserr = nfsd_open(rqstp, &fh, S_IFREG, NFSD_MAY_LOCK, filp); fh_put(&fh); rqstp->rq_client = NULL; exp_readunlock(); switch (nfse...
robutest/uclinux
C++
GPL-2.0
60
/* This function determines the size of the SRAM on the Stellaris device. */
unsigned long SysCtlSRAMSizeGet(void)
/* This function determines the size of the SRAM on the Stellaris device. */ unsigned long SysCtlSRAMSizeGet(void)
{ return(((HWREG(SYSCTL_DC0) & SYSCTL_DC0_SRAMSZ_M) >> 8) + 0x100); }
watterott/WebRadio
C++
null
71
/* Retrieves this PCI controller's current PCI bus number, device number, and function number. */
STATIC EFI_STATUS EFIAPI PciIoGetLocation(IN EFI_PCI_IO_PROTOCOL *This, OUT UINTN *SegmentNumber, OUT UINTN *BusNumber, OUT UINTN *DeviceNumber, OUT UINTN *FunctionNumber)
/* Retrieves this PCI controller's current PCI bus number, device number, and function number. */ STATIC EFI_STATUS EFIAPI PciIoGetLocation(IN EFI_PCI_IO_PROTOCOL *This, OUT UINTN *SegmentNumber, OUT UINTN *BusNumber, OUT UINTN *DeviceNumber, OUT UINTN *FunctionNumber)
{ NON_DISCOVERABLE_PCI_DEVICE *Dev; if ((SegmentNumber == NULL) || (BusNumber == NULL) || (DeviceNumber == NULL) || (FunctionNumber == NULL)) { return EFI_INVALID_PARAMETER; } Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO (This); *SegmentNumber = 0xff; *BusNumber = Dev->Unique...
tianocore/edk2
C++
Other
4,240
/* Sets the current local time and date information. */
EFI_STATUS EFIAPI PcRtcEfiSetTime(IN EFI_TIME *Time)
/* Sets the current local time and date information. */ EFI_STATUS EFIAPI PcRtcEfiSetTime(IN EFI_TIME *Time)
{ return PcRtcSetTime (Time, &mModuleGlobal); }
tianocore/edk2
C++
Other
4,240
/* Enable or disable flash cache sleep mode. This function enables or disables flash cache sleep mode. */
uint32_t am_hal_cachectrl_sleep_mode_enable(uint32_t ui32EnableMask, uint32_t ui32DisableMask)
/* Enable or disable flash cache sleep mode. This function enables or disables flash cache sleep mode. */ uint32_t am_hal_cachectrl_sleep_mode_enable(uint32_t ui32EnableMask, uint32_t ui32DisableMask)
{ uint32_t ui32Ret = am_hal_cachectrl_sleep_mode_status(); if ( ui32DisableMask & 0x1 ) { AM_REG(CACHECTRL, CACHECTRL) |= AM_REG_CACHECTRL_CACHECTRL_FLASH0_SLM_DISABLE_M; } if ( ui32DisableMask & 0x2 ) { AM_REG(CACHECTRL, CACHECTRL) |= AM_REG_CACHECTRL_CACHECTRL_FLASH1_SLM_DISABL...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* We use the address of the rsb struct as a simple local identifier for the rsb so we can match an rcom reply with the rsb it was sent for. */
static int recover_list_empty(struct dlm_ls *ls)
/* We use the address of the rsb struct as a simple local identifier for the rsb so we can match an rcom reply with the rsb it was sent for. */ static int recover_list_empty(struct dlm_ls *ls)
{ int empty; spin_lock(&ls->ls_recover_list_lock); empty = list_empty(&ls->ls_recover_list); spin_unlock(&ls->ls_recover_list_lock); return empty; }
robutest/uclinux
C++
GPL-2.0
60
/* Extract filename from device path. The returned buffer is allocated using AllocateCopyPool. The caller is responsible for freeing the allocated buffer using FreePool(). */
CHAR16* ExtractFileNameFromDevicePath(IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
/* Extract filename from device path. The returned buffer is allocated using AllocateCopyPool. The caller is responsible for freeing the allocated buffer using FreePool(). */ CHAR16* ExtractFileNameFromDevicePath(IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
{ CHAR16 *String; CHAR16 *MatchString; CHAR16 *LastMatch; CHAR16 *FileName; UINTN Length; ASSERT (DevicePath != NULL); String = UiDevicePathToStr (DevicePath); MatchString = String; LastMatch = String; FileName = NULL; while (MatchString != NULL) { LastMatch = MatchString + 1...
tianocore/edk2
C++
Other
4,240
/* Writes a Port group configuration group to the hardware module. Writes out a given configuration of a Port group configuration to the hardware module. */
void port_group_set_config(PortGroup *const port, const uint32_t mask, const struct port_config *const config)
/* Writes a Port group configuration group to the hardware module. Writes out a given configuration of a Port group configuration to the hardware module. */ void port_group_set_config(PortGroup *const port, const uint32_t mask, const struct port_config *const config)
{ Assert(port); Assert(config); struct system_pinmux_config pinmux_config; system_pinmux_get_config_defaults(&pinmux_config); pinmux_config.mux_position = SYSTEM_PINMUX_GPIO; pinmux_config.direction = (enum system_pinmux_pin_dir)config->direction; pinmux_config.input_pull = (enum system_pinmux_pin_pull)conf...
remotemcu/remcu-chip-sdks
C++
null
436
/* Send (write) an item to the back of the queue. */
OS_Status OS_QueueSend(OS_Queue_t *queue, const void *item, OS_Time_t waitMS)
/* Send (write) an item to the back of the queue. */ OS_Status OS_QueueSend(OS_Queue_t *queue, const void *item, OS_Time_t waitMS)
{ BaseType_t ret; BaseType_t taskWoken; OS_HANDLE_ASSERT(OS_QueueIsValid(queue), queue->handle); if (OS_IsISRContext()) { taskWoken = pdFALSE; ret = xQueueSendFromISR(queue->handle, item, &taskWoken); if (ret != pdPASS) { OS_DBG("%s() fail @ %d\n", __func__, __LINE__)...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Seek a file and read its data into memory on an UDF volume. */
EFI_STATUS ReadFileData(IN EFI_BLOCK_IO_PROTOCOL *BlockIo, IN EFI_DISK_IO_PROTOCOL *DiskIo, IN UDF_VOLUME_INFO *Volume, IN UDF_FILE_INFO *File, IN UINT64 FileSize, IN OUT UINT64 *FilePosition, IN OUT VOID *Buffer, IN OUT UINT64 *BufferSize)
/* Seek a file and read its data into memory on an UDF volume. */ EFI_STATUS ReadFileData(IN EFI_BLOCK_IO_PROTOCOL *BlockIo, IN EFI_DISK_IO_PROTOCOL *DiskIo, IN UDF_VOLUME_INFO *Volume, IN UDF_FILE_INFO *File, IN UINT64 FileSize, IN OUT UINT64 *FilePosition, IN OUT VOID *Buffer, IN OUT UINT64 *BufferSize)
{ EFI_STATUS Status; UDF_READ_FILE_INFO ReadFileInfo; ReadFileInfo.Flags = ReadFileSeekAndRead; ReadFileInfo.FilePosition = *FilePosition; ReadFileInfo.FileData = Buffer; ReadFileInfo.FileDataSize = *BufferSize; ReadFileInfo.FileSize = FileSize; Status = ReadFile ( ...
tianocore/edk2
C++
Other
4,240
/* Update a record with the data of the Request */
static void update_tcaphash_ansicall(struct tcaphash_ansicall_t *p_tcaphash_ansicall, packet_info *pinfo)
/* Update a record with the data of the Request */ static void update_tcaphash_ansicall(struct tcaphash_ansicall_t *p_tcaphash_ansicall, packet_info *pinfo)
{ p_tcaphash_ansicall->context->first_frame = pinfo->num; p_tcaphash_ansicall->context->last_frame = 0; p_tcaphash_ansicall->context->responded = FALSE; p_tcaphash_ansicall->context->begin_time = pinfo->abs_ts; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Redirect @gstate rendering to a "child" target. The original "parent" target with which the gstate was created will not be affected. See _cairo_gstate_get_target(). */
cairo_status_t _cairo_gstate_redirect_target(cairo_gstate_t *gstate, cairo_surface_t *child)
/* Redirect @gstate rendering to a "child" target. The original "parent" target with which the gstate was created will not be affected. See _cairo_gstate_get_target(). */ cairo_status_t _cairo_gstate_redirect_target(cairo_gstate_t *gstate, cairo_surface_t *child)
{ assert (gstate->parent_target == NULL); gstate->parent_target = gstate->target; gstate->target = cairo_surface_reference (child); gstate->is_identity &= _cairo_matrix_is_identity (&child->device_transform); cairo_list_move (&gstate->device_transform_observer.link, &gstate->target->device_tr...
xboot/xboot
C++
MIT License
779
/* Locking: the function must me called within a rcu_read_lock region */
void mesh_path_discard_frame(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata)
/* Locking: the function must me called within a rcu_read_lock region */ void mesh_path_discard_frame(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata)
{ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; struct mesh_path *mpath; u32 sn = 0; if (memcmp(hdr->addr4, sdata->dev->dev_addr, ETH_ALEN) != 0) { u8 *ra, *da; da = hdr->addr3; ra = hdr->addr1; mpath = mesh_path_lookup(da, sdata); if (mpath) sn = ++mpath->sn; mesh_path_error_tx(MES...
EmcraftSystems/linux-emcraft
C++
Other
266
/* This API enables the offset compensation for filtered and unfiltered Accel data. */
uint16_t bma4_set_offset_comp(uint8_t offset_en, struct bma4_dev *dev)
/* This API enables the offset compensation for filtered and unfiltered Accel data. */ uint16_t bma4_set_offset_comp(uint8_t offset_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_NV_CONFIG_ADDR, &data, 1, dev); if (rslt == BMA4_OK) { data = BMA4_SET_BITSLICE(data, BMA4_NV_ACCEL_OFFSET, offset_en); rslt |= bma4_wri...
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* Default function to write a byte to I/O */
static void nand_write_byte(struct mtd_info *mtd, uint8_t byte)
/* Default function to write a byte to I/O */ static void nand_write_byte(struct mtd_info *mtd, uint8_t byte)
{ struct nand_chip *chip = mtd_to_nand(mtd); chip->write_buf(mtd, &byte, 1); }
4ms/stm32mp1-baremetal
C++
Other
137
/* sweep at most 'count' elements from a list of GCObjects erasing dead objects, where a dead object is one marked with the old (non current) white; change all non-dead objects back to white, preparing for next collection cycle. Return where to continue the traversal or NULL if list is finished. */
static GCObject ** sweeplist(lua_State *L, GCObject **p, lu_mem count)
/* sweep at most 'count' elements from a list of GCObjects erasing dead objects, where a dead object is one marked with the old (non current) white; change all non-dead objects back to white, preparing for next collection cycle. Return where to continue the traversal or NULL if list is finished. */ static GCObject ** ...
{ GCObject *curr = *p; int marked = curr->marked; if (isdeadm(ow, marked)) { *p = curr->next; freeobj(L, curr); } else { curr->marked = cast_byte((marked & maskcolors) | white); p = &curr->next; } } return (*p == NULL) ? NULL : p; }
nodemcu/nodemcu-firmware
C++
MIT License
7,566
/* Get a bandwidth table index associated with a bandwidth value. */
static bool sensor_band_index(const sensor_caps_t *caps, int16_t band, int *index)
/* Get a bandwidth table index associated with a bandwidth value. */ static bool sensor_band_index(const sensor_caps_t *caps, int16_t band, int *index)
{ if (caps && caps->band_table) { for (int i = 0; i < caps->band_count; ++i) { if (caps->band_table[i].bandwidth_Hz == band) { *index = i; return true; } } } return false; }
memfault/zero-to-main
C++
null
200