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
/* Read multiple random data from TRNG. As soon as the TRNG is enabled, the module provides a new 32-bits random data for every 84 CLK_TRNG_APB clock cycles. */
enum status_code trng_read_buffer_job(struct trng_module *const module_inst, uint32_t *buffer, uint32_t number)
/* Read multiple random data from TRNG. As soon as the TRNG is enabled, the module provides a new 32-bits random data for every 84 CLK_TRNG_APB clock cycles. */ enum status_code trng_read_buffer_job(struct trng_module *const module_inst, uint32_t *buffer, uint32_t number)
{ Assert(module_inst); Assert(number); Assert(buffer); if (module_inst->remaining_number != 0 || module_inst->job_status == STATUS_BUSY) { return STATUS_BUSY; } module_inst->job_status = STATUS_BUSY; module_inst->remaining_number = number; module_inst->job_buffer = buffer; module_inst->hw->INTENSET.reg = TRNG_INTENSET_DATARDY; return STATUS_OK; }
memfault/zero-to-main
C++
null
200
/* param handle Pointer to i2s DMA transfer handle. param dmaDescriptorAddr DMA descriptor start address. param dmaDescriptorNum DMA descriptor number. */
void I2S_TransferInstallLoopDMADescriptorMemory(i2s_dma_handle_t *handle, void *dmaDescriptorAddr, size_t dmaDescriptorNum)
/* param handle Pointer to i2s DMA transfer handle. param dmaDescriptorAddr DMA descriptor start address. param dmaDescriptorNum DMA descriptor number. */ void I2S_TransferInstallLoopDMADescriptorMemory(i2s_dma_handle_t *handle, void *dmaDescriptorAddr, size_t dmaDescriptorNum)
{ assert(handle != NULL); assert((((uint32_t)(uint32_t *)dmaDescriptorAddr) & ((uint32_t)FSL_FEATURE_DMA_LINK_DESCRIPTOR_ALIGN_SIZE - 1UL)) == 0UL); handle->i2sLoopDMADescriptor = (dma_descriptor_t *)dmaDescriptorAddr; handle->i2sLoopDMADescriptorNum = dmaDescriptorNum; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Set the channel to run in circular mode, exiting parking mode */
void XAxiVdma_ChannelStopParking(XAxiVdma_Channel *Channel)
/* Set the channel to run in circular mode, exiting parking mode */ void XAxiVdma_ChannelStopParking(XAxiVdma_Channel *Channel)
{ u32 CrBits; CrBits = XAxiVdma_ReadReg(Channel->ChanBase, XAXIVDMA_CR_OFFSET) | XAXIVDMA_CR_TAIL_EN_MASK; XAxiVdma_WriteReg(Channel->ChanBase, XAXIVDMA_CR_OFFSET, CrBits); return; }
ua1arn/hftrx
C++
null
69
/* Interrupt handler for the over-temperature alarm. This interrupt handler gets the current die temperature and calls the alarm callback function that was previously installed with tempmon_set_alarm(). If for some reason there is no alarm callback set, this routine does nothing except clear the IRQ. */
static void tempmon_alarm_isr(void)
/* Interrupt handler for the over-temperature alarm. This interrupt handler gets the current die temperature and calls the alarm callback function that was previously installed with tempmon_set_alarm(). If for some reason there is no alarm callback set, this routine does nothing except clear the IRQ. */ static void tempmon_alarm_isr(void)
{ if (s_tempmon.alarmCallback) { float currentTemp = tempmon_get_temp(); s_tempmon.alarmCallback(currentTemp); } BF_SET(PMU_MISC1, IRQ_TEMPSENSE); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Check if the last data written in SSC_THR has been loaded in TSR and the last data loaded in TSR has been transmitted. */
uint32_t ssc_is_tx_empty(Ssc *p_ssc)
/* Check if the last data written in SSC_THR has been loaded in TSR and the last data loaded in TSR has been transmitted. */ uint32_t ssc_is_tx_empty(Ssc *p_ssc)
{ if (p_ssc->SSC_SR & SSC_SR_TXEMPTY) { return SSC_RC_YES; } return SSC_RC_NO; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Such detection looks very ugly, but can detect at least some of numerous PnP modems, alternatively we must hardcode all modems in pnp_devices table. */
static int __devinit serial_pnp_guess_board(struct pnp_dev *dev, int *flags)
/* Such detection looks very ugly, but can detect at least some of numerous PnP modems, alternatively we must hardcode all modems in pnp_devices table. */ static int __devinit serial_pnp_guess_board(struct pnp_dev *dev, int *flags)
{ if (!(check_name(pnp_dev_name(dev)) || (dev->card && check_name(dev->card->name)))) return -ENODEV; if (check_resources(dev)) return 0; return -ENODEV; }
robutest/uclinux
C++
GPL-2.0
60
/* IDL typedef struct { IDL long element_7; IDL byte *element_8; IDL } TYPE_4; */
static int dissect_browser_TYPE_4_data(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep)
/* IDL typedef struct { IDL long element_7; IDL byte *element_8; IDL } TYPE_4; */ static int dissect_browser_TYPE_4_data(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep)
{ guint32 len; if(di->conformant_run){ offset =dissect_ndr_ucarray(tvb, offset, pinfo, tree, di, drep, NULL); return offset; } offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, di, drep, hf_browser_unknown_long, &len); proto_tree_add_item(tree, hf_browser_unknown_bytes, tvb, offset, len, ENC_NA); offset += len; return offset; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Change DFU status to notify that the memory is protected. */
static bool udi_dfu_atmel_mem_protected(void)
/* Change DFU status to notify that the memory is protected. */ static bool udi_dfu_atmel_mem_protected(void)
{ udi_dfu_atmel_status.bStatus = DFU_STATUS_ERRWRITE; udi_dfu_atmel_status.bState = DFU_STATE_DFUIDLE; return false; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Probe the nth BAR assigned to an endpoint. A PCI(e) endpoint has 0 or more BARs. This function allows the caller to enumerate them by calling with index=0..n. Value of n has to be below 6, as there is a maximum of 6 BARs. The indices are order-preserving with respect to the endpoint BARs: e.g., index 0 will return the lowest-numbered BAR on the endpoint. */
static bool pcie_probe_bar(pcie_bdf_t bdf, unsigned int index, struct pcie_bar *bar, bool io)
/* Probe the nth BAR assigned to an endpoint. A PCI(e) endpoint has 0 or more BARs. This function allows the caller to enumerate them by calling with index=0..n. Value of n has to be below 6, as there is a maximum of 6 BARs. The indices are order-preserving with respect to the endpoint BARs: e.g., index 0 will return the lowest-numbered BAR on the endpoint. */ static bool pcie_probe_bar(pcie_bdf_t bdf, unsigned int index, struct pcie_bar *bar, bool io)
{ uint32_t reg; for (reg = PCIE_CONF_BAR0; index > 0 && reg <= PCIE_CONF_BAR5; reg++, index--) { uintptr_t addr = pcie_conf_read(bdf, reg); if (PCIE_CONF_BAR_MEM(addr) && PCIE_CONF_BAR_64(addr)) { reg++; } } if (index != 0) { return false; } return pcie_get_bar(bdf, reg - PCIE_CONF_BAR0, bar, io); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* pagevec_lookup() returns the number of pages which were found. */
unsigned pagevec_lookup(struct pagevec *pvec, struct address_space *mapping, pgoff_t start, unsigned nr_pages)
/* pagevec_lookup() returns the number of pages which were found. */ unsigned pagevec_lookup(struct pagevec *pvec, struct address_space *mapping, pgoff_t start, unsigned nr_pages)
{ pvec->nr = find_get_pages(mapping, start, nr_pages, pvec->pages); return pagevec_count(pvec); }
robutest/uclinux
C++
GPL-2.0
60
/* Remove a mapping of a previously mapped ROM */
void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom)
/* Remove a mapping of a previously mapped ROM */ void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom)
{ struct resource *res = &pdev->resource[PCI_ROM_RESOURCE]; if (res->flags & (IORESOURCE_ROM_COPY | IORESOURCE_ROM_BIOS_COPY)) return; iounmap(rom); if (!(res->flags & (IORESOURCE_ROM_ENABLE | IORESOURCE_ROM_SHADOW))) pci_disable_rom(pdev); }
robutest/uclinux
C++
GPL-2.0
60
/* Reads a packet whose byte number is len from the Rx FIFO. */
void usb_rdpkt(LL_USB_TypeDef *USBx, uint8_t *dest, uint16_t len)
/* Reads a packet whose byte number is len from the Rx FIFO. */ void usb_rdpkt(LL_USB_TypeDef *USBx, uint8_t *dest, uint16_t len)
{ uint32_t u32Tmp; __IO uint32_t u32Count32b; __IO uint32_t u32pAddr; __IO uint32_t *fifo = USBx->DFIFO[0]; u32Count32b = (len + 3UL); u32Count32b = u32Count32b >> 2U; u32pAddr = 0UL; u32Tmp = 0UL; while (u32Tmp < u32Count32b) { *(uint32_t *)dest = READ_REG32(*fifo); u32pAddr = (uint32_t)dest; dest = (uint8_t *)(u32pAddr + 4U); u32Tmp++; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Send an event to the Link Layer task */
void ble_ll_event_send(struct ble_npl_event *ev)
/* Send an event to the Link Layer task */ void ble_ll_event_send(struct ble_npl_event *ev)
{ ble_npl_eventq_put(&g_ble_ll_data.ll_evq, ev); }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* Guarantee that the kmalloc'd memory is cacheline aligned. */
void* xpc_kmalloc_cacheline_aligned(size_t size, gfp_t flags, void **base)
/* Guarantee that the kmalloc'd memory is cacheline aligned. */ void* xpc_kmalloc_cacheline_aligned(size_t size, gfp_t flags, void **base)
{ *base = kmalloc(size, flags); if (*base == NULL) return NULL; if ((u64)*base == L1_CACHE_ALIGN((u64)*base)) return *base; kfree(*base); *base = kmalloc(size + L1_CACHE_BYTES, flags); if (*base == NULL) return NULL; return (void *)L1_CACHE_ALIGN((u64)*base); }
robutest/uclinux
C++
GPL-2.0
60
/* Set the value for dynamic memory clock control: stops or runs continuously. */
void EMC_DynCtrlClockControl(int32_t clock_control)
/* Set the value for dynamic memory clock control: stops or runs continuously. */ void EMC_DynCtrlClockControl(int32_t clock_control)
{ uint32_t mask = ~(uint32_t)(2); LPC_EMC->DynamicControl = ((LPC_EMC->DynamicControl & mask) |clock_control); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* PE calls this function to Enable (5V) or Disable (0V) the Power Supply. */
int port0_policy_cb_src_en(const struct device *dev, bool en)
/* PE calls this function to Enable (5V) or Disable (0V) the Power Supply. */ int port0_policy_cb_src_en(const struct device *dev, bool en)
{ source_ctrl_set(en ? SOURCE_5V : SOURCE_0V); return 0; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Link a high-period interrupt QH into the schedule at the end of its skeleton's list */
static void link_interrupt(struct uhci_hcd *uhci, struct uhci_qh *qh)
/* Link a high-period interrupt QH into the schedule at the end of its skeleton's list */ static void link_interrupt(struct uhci_hcd *uhci, struct uhci_qh *qh)
{ struct uhci_qh *pqh; list_add_tail(&qh->node, &uhci->skelqh[qh->skel]->node); pqh = list_entry(qh->node.prev, struct uhci_qh, node); qh->link = pqh->link; wmb(); pqh->link = LINK_TO_QH(qh); }
robutest/uclinux
C++
GPL-2.0
60
/* Submit a USB get HID report idle request for the USB device specified by UsbIo, Interface, and ReportId, and return the ide rate in Duration. If UsbIo is NULL, then ASSERT(). If Duration is NULL, then ASSERT(). */
EFI_STATUS EFIAPI UsbGetIdleRequest(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT8 Interface, IN UINT8 ReportId, OUT UINT8 *Duration)
/* Submit a USB get HID report idle request for the USB device specified by UsbIo, Interface, and ReportId, and return the ide rate in Duration. If UsbIo is NULL, then ASSERT(). If Duration is NULL, then ASSERT(). */ EFI_STATUS EFIAPI UsbGetIdleRequest(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT8 Interface, IN UINT8 ReportId, OUT UINT8 *Duration)
{ UINT32 Status; EFI_STATUS Result; EFI_USB_DEVICE_REQUEST Request; ASSERT (UsbIo != NULL); ASSERT (Duration != NULL); Request.RequestType = USB_HID_CLASS_GET_REQ_TYPE; Request.Request = EFI_USB_GET_IDLE_REQUEST; Request.Value = ReportId; Request.Index = Interface; Request.Length = 1; Result = UsbIo->UsbControlTransfer ( UsbIo, &Request, EfiUsbDataIn, PcdGet32 (PcdUsbTransferTimeoutValue), Duration, 1, &Status ); return Result; }
tianocore/edk2
C++
Other
4,240
/* Return 0 on success or a negative error code. */
int genl_register_family_with_ops(struct genl_family *family, struct genl_ops *ops, size_t n_ops)
/* Return 0 on success or a negative error code. */ int genl_register_family_with_ops(struct genl_family *family, struct genl_ops *ops, size_t n_ops)
{ int err, i; err = genl_register_family(family); if (err) return err; for (i = 0; i < n_ops; ++i, ++ops) { err = genl_register_ops(family, ops); if (err) goto err_out; } return 0; err_out: genl_unregister_family(family); return err; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Maps in a memory region such that it can be used for performing a DMA. */
int dma_map_mem(DMA_MemMap_t *memMap, void *mem, size_t numBytes, enum dma_data_direction dir)
/* Maps in a memory region such that it can be used for performing a DMA. */ int dma_map_mem(DMA_MemMap_t *memMap, void *mem, size_t numBytes, enum dma_data_direction dir)
{ int rc; rc = dma_map_start(memMap, dir); if (rc == 0) { rc = dma_map_add_region(memMap, mem, numBytes); if (rc < 0) { dma_unmap(memMap, 0); } } return rc; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Gets the error status of the I2C Master module. This function is used to obtain the error status of the Master module send and receive operations. */
unsigned long xI2CMasterError(unsigned long ulBase)
/* Gets the error status of the I2C Master module. This function is used to obtain the error status of the Master module send and receive operations. */ unsigned long xI2CMasterError(unsigned long ulBase)
{ unsigned long ulStatus; xASSERT((ulBase == I2C0_BASE)); ulStatus = (xHWREG(ulBase + I2C_STATUS) & I2C_STATUS_M); if((ulStatus == I2C_I2STAT_M_TX_DAT_NACK) || (ulStatus == I2C_I2STAT_M_RX_DAT_NACK)) { return xI2C_MASTER_ERR_ADDR_ACK; } if((ulStatus == I2C_I2STAT_M_TX_SLAW_NACK) || (ulStatus == I2C_I2STAT_M_RX_SLAR_NACK)) { return xI2C_MASTER_ERR_DATA_ACK; } if((ulStatus == I2C_I2STAT_M_TX_ARB_LOST)) { return xI2C_MASTER_ERR_ARB_LOST; } return xI2C_MASTER_ERR_NONE; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* param base ENET peripheral base address. param macAddr The six-byte Mac address pointer. The pointer is allocated by application and input into the API. */
void ENET_GetMacAddr(ENET_Type *base, uint8_t *macAddr)
/* param base ENET peripheral base address. param macAddr The six-byte Mac address pointer. The pointer is allocated by application and input into the API. */ void ENET_GetMacAddr(ENET_Type *base, uint8_t *macAddr)
{ assert(macAddr); uint32_t address = base->MAC_ADDRESS0_LOW; macAddr[2] = (uint8_t)(0xFFU & (address >> 24U)); macAddr[3] = (uint8_t)(0xFFU & (address >> 16U)); macAddr[4] = (uint8_t)(0xFFU & (address >> 8U)); macAddr[5] = (uint8_t)(0xFFU & address); address = base->MAC_ADDRESS0_HIGH; macAddr[0] = (uint8_t)(0xFFU & (address >> 8U)); macAddr[1] = (uint8_t)(0xFFU & address); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Routine to create a global VO/VOL header for MP4 container. What we do here is extract the header from the Xvid bitstream as it is encoded. We also strip the repeated headers from the bitstream when a global header is requested for MPEG-4 ISO compliance. */
int xvid_strip_vol_header(AVCodecContext *avctx, unsigned char *frame, unsigned int header_len, unsigned int frame_len)
/* Routine to create a global VO/VOL header for MP4 container. What we do here is extract the header from the Xvid bitstream as it is encoded. We also strip the repeated headers from the bitstream when a global header is requested for MPEG-4 ISO compliance. */ int xvid_strip_vol_header(AVCodecContext *avctx, unsigned char *frame, unsigned int header_len, unsigned int frame_len)
{ int vo_len = 0, i; for( i = 0; i < header_len - 3; i++ ) { if( frame[i] == 0x00 && frame[i+1] == 0x00 && frame[i+2] == 0x01 && frame[i+3] == 0xB6 ) { vo_len = i; break; } } if( vo_len > 0 ) { if( avctx->extradata == NULL ) { avctx->extradata = av_malloc(vo_len); memcpy(avctx->extradata, frame, vo_len); avctx->extradata_size = vo_len; } memmove(frame, &(frame[vo_len]), frame_len - vo_len); return frame_len - vo_len; } else return frame_len; }
DC-SWAT/DreamShell
C++
null
404
/* Returns: A NULL-pointer on success, else an negative error code encoded in the return pointer. */
static struct dentry * vxfs_lookup(struct inode *, struct dentry *, struct nameidata *)
/* Returns: A NULL-pointer on success, else an negative error code encoded in the return pointer. */ static struct dentry * vxfs_lookup(struct inode *, struct dentry *, struct nameidata *)
{ struct inode *ip = NULL; ino_t ino; if (dp->d_name.len > VXFS_NAMELEN) return ERR_PTR(-ENAMETOOLONG); lock_kernel(); ino = vxfs_inode_by_name(dip, dp); if (ino) { ip = vxfs_iget(dip->i_sb, ino); if (IS_ERR(ip)) { unlock_kernel(); return ERR_CAST(ip); } } unlock_kernel(); d_add(dp, ip); return NULL; }
robutest/uclinux
C++
GPL-2.0
60
/* Reads and returns the current value of MM1. This function is only available on IA-32 and X64. */
UINT64 EFIAPI AsmReadMm1(VOID)
/* Reads and returns the current value of MM1. This function is only available on IA-32 and X64. */ UINT64 EFIAPI AsmReadMm1(VOID)
{ UINT64 Data; __asm__ __volatile__ ( "push %%eax \n\t" "push %%eax \n\t" "movq %%mm1, (%%esp)\n\t" "pop %%eax \n\t" "pop %%edx \n\t" : "=A" (Data) ); return Data; }
tianocore/edk2
C++
Other
4,240
/* Allocate buffers for the Rx ring For receive: rx_ring.to_clean is next received frame */
static int c2_rx_fill(struct c2_port *c2_port)
/* Allocate buffers for the Rx ring For receive: rx_ring.to_clean is next received frame */ static int c2_rx_fill(struct c2_port *c2_port)
{ struct c2_ring *rx_ring = &c2_port->rx_ring; struct c2_element *elem; int ret = 0; elem = rx_ring->start; do { if (c2_rx_alloc(c2_port, elem)) { ret = 1; break; } } while ((elem = elem->next) != rx_ring->start); rx_ring->to_clean = rx_ring->start; return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* Locking Note: This function should not be called with the lport lock held. */
int fc_fabric_login(struct fc_lport *lport)
/* Locking Note: This function should not be called with the lport lock held. */ int fc_fabric_login(struct fc_lport *lport)
{ int rc = -1; mutex_lock(&lport->lp_mutex); if (lport->state == LPORT_ST_DISABLED || lport->state == LPORT_ST_LOGO) { fc_lport_state_enter(lport, LPORT_ST_RESET); fc_lport_enter_reset(lport); rc = 0; } mutex_unlock(&lport->lp_mutex); return rc; }
robutest/uclinux
C++
GPL-2.0
60
/* Program Page in Flash Memory Parameter: adr: Page Start Address sz: Page Size buf: Page Data Return Value: 0 - OK, 1 - Failed */
uint32_t ProgramPage(uint32_t adr, uint32_t sz, uint32_t *buf)
/* Program Page in Flash Memory Parameter: adr: Page Start Address sz: Page Size buf: Page Data Return Value: 0 - OK, 1 - Failed */ uint32_t ProgramPage(uint32_t adr, uint32_t sz, uint32_t *buf)
{ cortex_int_state_t state = cortex_int_get_and_disable(); int status = FLASH_Program(&g_flash, adr, buf, sz); if (status == kStatus_Success) { status = FLASH_VerifyProgram(&g_flash, adr, sz, buf, kFLASH_marginValueUser, NULL, NULL); } cortex_int_restore(state); return status; }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* Enable the time tick or alarm interrupt of RTC. The */
void RTCIntEnable(unsigned long ulIntType)
/* Enable the time tick or alarm interrupt of RTC. The */ void RTCIntEnable(unsigned long ulIntType)
{ xASSERT(((ulIntType & RTC_INT_TIME_TICK) == RTC_INT_TIME_TICK) || ((ulIntType & RTC_INT_ALARM) == RTC_INT_ALARM) || ((ulIntType & RTC_INT_OVERFLOW) == RTC_INT_OVERFLOW)); xHWREG(RTC_CRH) |= ulIntType; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Allocate buffer and initiate a new control OUT transfer, use successive buffer descriptor when next is true. */
static int usbfsotg_ctrl_feed_dout(const struct device *dev, const size_t length, const bool next, const bool resume_tx)
/* Allocate buffer and initiate a new control OUT transfer, use successive buffer descriptor when next is true. */ static int usbfsotg_ctrl_feed_dout(const struct device *dev, const size_t length, const bool next, const bool resume_tx)
{ struct net_buf *buf; int ret; buf = udc_ctrl_alloc(dev, USB_CONTROL_EP_OUT, length); if (buf == NULL) { return -ENOMEM; } if (next) { ret = usbfsotg_ctrl_feed_start_next(dev, buf); } else { ret = usbfsotg_ctrl_feed_start(dev, buf); } if (ret) { net_buf_unref(buf); return ret; } if (resume_tx) { usbfsotg_resume_tx(dev); } return 0; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* param base DMIC peripheral base address param handle Pointer to dmic_dma_handle_t structure */
void DMIC_TransferAbortReceiveDMA(DMIC_Type *base, dmic_dma_handle_t *handle)
/* param base DMIC peripheral base address param handle Pointer to dmic_dma_handle_t structure */ void DMIC_TransferAbortReceiveDMA(DMIC_Type *base, dmic_dma_handle_t *handle)
{ assert(NULL != handle); assert(NULL != handle->rxDmaHandle); DMA_AbortTransfer(handle->rxDmaHandle); handle->state = kDMIC_Idle; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Write a long word (32 bits) to a memory location after the value has been byte swapped (big to little endian or vice versa) */
void mpc824x_mpc107_write32(unsigned int address, unsigned int data)
/* Write a long word (32 bits) to a memory location after the value has been byte swapped (big to little endian or vice versa) */ void mpc824x_mpc107_write32(unsigned int address, unsigned int data)
{ *(volatile unsigned int *) address = LONGSWAP (data); __asm__ ("sync"); }
EmcraftSystems/u-boot
C++
Other
181
/* Checks whether the specified SPI/I2S interrupt has occurred or not. */
ITStatus SPI_I2S_GetITStatus(SPI_TypeDef *SPIx, uint8_t SPI_I2S_IT)
/* Checks whether the specified SPI/I2S interrupt has occurred or not. */ ITStatus SPI_I2S_GetITStatus(SPI_TypeDef *SPIx, uint8_t SPI_I2S_IT)
{ ITStatus bitstatus = RESET; uint16_t itpos = 0, itmask = 0, enablestatus = 0; assert_param(IS_SPI_ALL_PERIPH(SPIx)); assert_param(IS_SPI_I2S_GET_IT(SPI_I2S_IT)); itpos = 0x01 << (SPI_I2S_IT & 0x0F); itmask = SPI_I2S_IT >> 4; itmask = 0x01 << itmask; enablestatus = (SPIx->CR2 & itmask) ; if (((SPIx->SR & itpos) != (uint16_t)RESET) && enablestatus) { bitstatus = SET; } else { bitstatus = RESET; } return bitstatus; }
gcallipo/RadioDSP-Stm32f103
C++
Common Creative - Attribution 3.0
51
/* Determines if the hardware module(s) are currently synchronizing to the bus. Checks to see if the underlying hardware peripheral module(s) are currently synchronizing across multiple clock domains to the hardware bus, This function can be used to delay further operations on a module until such time that it is ready, to prevent blocking delays for synchronization in the user application. */
static bool rtc_count_is_syncing(struct rtc_module *const module)
/* Determines if the hardware module(s) are currently synchronizing to the bus. Checks to see if the underlying hardware peripheral module(s) are currently synchronizing across multiple clock domains to the hardware bus, This function can be used to delay further operations on a module until such time that it is ready, to prevent blocking delays for synchronization in the user application. */ static bool rtc_count_is_syncing(struct rtc_module *const module)
{ Assert(module); Assert(module->hw); Rtc *const rtc_module = module->hw; if (rtc_module->MODE0.STATUS.reg & RTC_STATUS_SYNCBUSY) { return true; } return false; }
memfault/zero-to-main
C++
null
200
/* If Buffer was not allocated with an aligned page allocation function in the Memory Allocation Library, then ASSERT(). If Pages is zero, then ASSERT(). */
VOID EFIAPI FreeAlignedPages(IN VOID *Buffer, IN UINTN Pages)
/* If Buffer was not allocated with an aligned page allocation function in the Memory Allocation Library, then ASSERT(). If Pages is zero, then ASSERT(). */ VOID EFIAPI FreeAlignedPages(IN VOID *Buffer, IN UINTN Pages)
{ EFI_STATUS Status; ASSERT (Pages != 0); if (BufferInSmram (Buffer)) { Status = gSmst->SmmFreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, Pages); } else { Status = gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, Pages); } ASSERT_EFI_ERROR (Status); }
tianocore/edk2
C++
Other
4,240
/* Returns: Whether the channel will be closed on the final unref of the GIOChannel data structure. */
gboolean g_io_channel_get_close_on_unref(GIOChannel *channel)
/* Returns: Whether the channel will be closed on the final unref of the GIOChannel data structure. */ gboolean g_io_channel_get_close_on_unref(GIOChannel *channel)
{ g_return_val_if_fail (channel != NULL, FALSE); return channel->close_on_unref; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Set SLCD circular shift. Set circular shift mode. */
enum status_code slcd_circular_shift_set_config(struct slcd_circular_shift_config *const config)
/* Set SLCD circular shift. Set circular shift mode. */ enum status_code slcd_circular_shift_set_config(struct slcd_circular_shift_config *const config)
{ if (!config) { return STATUS_ERR_INVALID_ARG; } SLCD->CSRCFG.reg = SLCD_CSRCFG_FCS(config->fc) | (config->dir << SLCD_CSRCFG_DIR_Pos) | SLCD_CSRCFG_SIZE(config->size) | SLCD_CSRCFG_DATA(config->data); return STATUS_OK; }
memfault/zero-to-main
C++
null
200
/* USB standard control transfer support routine. This function is used by USB device. It is possible that the device's interfaces are still waiting to be enumerated. */
EFI_STATUS UsbCtrlRequest(IN USB_DEVICE *UsbDev, IN EFI_USB_DATA_DIRECTION Direction, IN UINTN Type, IN UINTN Target, IN UINTN Request, IN UINT16 Value, IN UINT16 Index, IN OUT VOID *Buf, IN UINTN Length)
/* USB standard control transfer support routine. This function is used by USB device. It is possible that the device's interfaces are still waiting to be enumerated. */ EFI_STATUS UsbCtrlRequest(IN USB_DEVICE *UsbDev, IN EFI_USB_DATA_DIRECTION Direction, IN UINTN Type, IN UINTN Target, IN UINTN Request, IN UINT16 Value, IN UINT16 Index, IN OUT VOID *Buf, IN UINTN Length)
{ EFI_USB_DEVICE_REQUEST DevReq; EFI_STATUS Status; UINT32 Result; UINTN Len; ASSERT ((UsbDev != NULL) && (UsbDev->Bus != NULL)); DevReq.RequestType = USB_REQUEST_TYPE (Direction, Type, Target); DevReq.Request = (UINT8)Request; DevReq.Value = Value; DevReq.Index = Index; DevReq.Length = (UINT16)Length; Len = Length; Status = UsbHcControlTransfer ( UsbDev->Bus, UsbDev->Address, UsbDev->Speed, UsbDev->MaxPacket0, &DevReq, Direction, Buf, &Len, USB_GENERAL_DEVICE_REQUEST_TIMEOUT, &UsbDev->Translator, &Result ); return Status; }
tianocore/edk2
C++
Other
4,240
/* If the application is using a static interrupt vector table stored in flash, then it is not necessary to register the interrupt handler this way. Instead, IntEnable() is used to enable AES interrupts on the interrupt controller. */
void AESIntRegister(uint32_t ui32Base, void(*pfnHandler)(void))
/* If the application is using a static interrupt vector table stored in flash, then it is not necessary to register the interrupt handler this way. Instead, IntEnable() is used to enable AES interrupts on the interrupt controller. */ void AESIntRegister(uint32_t ui32Base, void(*pfnHandler)(void))
{ ASSERT(ui32Base == AES_BASE); IntRegister(INT_AES0_TM4C129, pfnHandler); IntEnable(INT_AES0_TM4C129); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Get the I2C interrupt flag of the specified I2C port. The */
unsigned long xI2CMasterIntFlagGet(unsigned long ulBase)
/* Get the I2C interrupt flag of the specified I2C port. The */ unsigned long xI2CMasterIntFlagGet(unsigned long ulBase)
{ xASSERT((ulBase == I2C0_BASE)); return ((xHWREG(ulBase + I2C_CON) & I2C_CON_SI) ? xtrue : xfalse); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* This is a semi-private blit function and it performs low-level surface scaled blitting only. */
int SDL_LowerBlitScaled(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
/* This is a semi-private blit function and it performs low-level surface scaled blitting only. */ int SDL_LowerBlitScaled(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
{ static const Uint32 complex_copy_flags = ( SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_COLORKEY ); if (!(src->map->info.flags & SDL_COPY_NEAREST)) { src->map->info.flags |= SDL_COPY_NEAREST; SDL_InvalidateMap(src->map); } if ( !(src->map->info.flags & complex_copy_flags) && src->format->format == dst->format->format && !SDL_ISPIXELFORMAT_INDEXED(src->format->format) ) { return SDL_SoftStretch( src, srcrect, dst, dstrect ); } else { return SDL_LowerBlit( src, srcrect, dst, dstrect ); } }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Registers a callback. Registers a callback function which is implemented by the user. */
enum status_code freqm_register_callback(struct freqm_module *const module, freqm_callback_t callback_func, enum freqm_callback callback_type)
/* Registers a callback. Registers a callback function which is implemented by the user. */ enum status_code freqm_register_callback(struct freqm_module *const module, freqm_callback_t callback_func, enum freqm_callback callback_type)
{ Assert(module); Assert(callback_func); if (callback_type >= FREQM_CALLBACK_TYPE_NUM) { Assert(false); return STATUS_ERR_INVALID_ARG; } module->callback[callback_type] = callback_func; return STATUS_OK; }
memfault/zero-to-main
C++
null
200
/* Write generic device register (platform dependent) WARNING: Functions declare in this section are defined at the end of this file and are strictly related to the hardware platform used. */
static int32_t platform_write(void *handle, uint8_t reg, uint8_t *bufp, uint16_t len)
/* Write generic device register (platform dependent) WARNING: Functions declare in this section are defined at the end of this file and are strictly related to the hardware platform used. */ static int32_t platform_write(void *handle, uint8_t reg, uint8_t *bufp, uint16_t len)
{ if (handle == &hi2c1) { reg |= 0x80; HAL_I2C_Mem_Write(handle, LIS2MDL_I2C_ADD, reg, I2C_MEMADD_SIZE_8BIT, bufp, len, 1000); } return 0; }
eclipse-threadx/getting-started
C++
Other
310
/* Enables or disables the Pin(s) active level inversion. */
void USART_InvPinCmd(USART_TypeDef *USARTx, uint32_t USART_InvPin, FunctionalState NewState)
/* Enables or disables the Pin(s) active level inversion. */ void USART_InvPinCmd(USART_TypeDef *USARTx, uint32_t USART_InvPin, FunctionalState NewState)
{ assert_param(IS_USART_ALL_PERIPH(USARTx)); assert_param(IS_USART_INVERSTION_PIN(USART_InvPin)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { USARTx->CR2 |= USART_InvPin; } else { USARTx->CR2 &= (uint32_t)~USART_InvPin; } }
ajhc/demo-cortex-m3
C++
null
38
/* Locate HII Database protocol and HII Font protocol. */
EFI_STATUS EfiLocateHiiProtocol(VOID)
/* Locate HII Database protocol and HII Font protocol. */ EFI_STATUS EfiLocateHiiProtocol(VOID)
{ EFI_STATUS Status; Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, (VOID **)&mHiiDatabase); if (EFI_ERROR (Status)) { return Status; } Status = gBS->LocateProtocol (&gEfiHiiFontProtocolGuid, NULL, (VOID **)&mHiiFont); return Status; }
tianocore/edk2
C++
Other
4,240
/* a20r platform uses 2 counters to divide the input frequency. Counter 2 output is connected to Counter 0 & 1 input. */
static void __init sni_a20r_timer_setup(void)
/* a20r platform uses 2 counters to divide the input frequency. Counter 2 output is connected to Counter 0 & 1 input. */ static void __init sni_a20r_timer_setup(void)
{ struct clock_event_device *cd = &a20r_clockevent_device; struct irqaction *action = &a20r_irqaction; unsigned int cpu = smp_processor_id(); cd->cpumask = cpumask_of(cpu); clockevents_register_device(cd); action->dev_id = cd; setup_irq(SNI_A20R_IRQ_TIMER, &a20r_irqaction); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Register a file to be a destination of configuration. */
int settings_file_dst(struct settings_file *cf)
/* Register a file to be a destination of configuration. */ int settings_file_dst(struct settings_file *cf)
{ if (!cf->cf_name) { return -EINVAL; } cf->cf_store.cs_itf = &settings_file_itf; settings_dst_register(&cf->cf_store); return 0; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* lp->indirect_mutex must be held when calling this function */
void temac_indirect_out32(struct temac_local *lp, int reg, u32 value)
/* lp->indirect_mutex must be held when calling this function */ void temac_indirect_out32(struct temac_local *lp, int reg, u32 value)
{ if (temac_indirect_busywait(lp)) return; temac_iow(lp, XTE_LSW0_OFFSET, value); temac_iow(lp, XTE_CTL0_OFFSET, CNTLREG_WRITE_ENABLE_MASK | reg); }
robutest/uclinux
C++
GPL-2.0
60
/* Converts a text device path node to Vendor device path structure based on the input Type and SubType. */
EFI_DEVICE_PATH_PROTOCOL* ConvertFromTextVendor(CHAR16 *TextDeviceNode, UINT8 Type, UINT8 SubType)
/* Converts a text device path node to Vendor device path structure based on the input Type and SubType. */ EFI_DEVICE_PATH_PROTOCOL* ConvertFromTextVendor(CHAR16 *TextDeviceNode, UINT8 Type, UINT8 SubType)
{ CHAR16 *GuidStr; CHAR16 *DataStr; UINTN Length; VENDOR_DEVICE_PATH *Vendor; GuidStr = GetNextParamStr (&TextDeviceNode); DataStr = GetNextParamStr (&TextDeviceNode); Length = StrLen (DataStr); Length = (Length + 1) / 2; Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode ( Type, SubType, (UINT16) (sizeof (VENDOR_DEVICE_PATH) + Length) ); StrToGuid (GuidStr, &Vendor->Guid); StrHexToBytes (DataStr, Length * 2, (UINT8 *) (Vendor + 1), Length); return (EFI_DEVICE_PATH_PROTOCOL *) Vendor; }
tianocore/edk2
C++
Other
4,240
/* Special care is needed if the underlying block device has a small max_phys_segments value. */
static int pkt_set_segment_merging(struct pktcdvd_device *pd, struct request_queue *q)
/* Special care is needed if the underlying block device has a small max_phys_segments value. */ static int pkt_set_segment_merging(struct pktcdvd_device *pd, struct request_queue *q)
{ if ((pd->settings.size << 9) / CD_FRAMESIZE <= queue_max_phys_segments(q)) { clear_bit(PACKET_MERGE_SEGS, &pd->flags); return 0; } else if ((pd->settings.size << 9) / PAGE_SIZE <= queue_max_phys_segments(q)) { set_bit(PACKET_MERGE_SEGS, &pd->flags); return 0; } else { printk(DRIVER_NAME": cdrom max_phys_segments too small\n"); return -EIO; } }
robutest/uclinux
C++
GPL-2.0
60
/* Get Remote Device Name. This API is used to get the name of the remote device the local device is connected to. */
ADI_BLER_RESULT adi_radio_GetRemoteDeviceName(const uint16_t nConnHandle)
/* Get Remote Device Name. This API is used to get the name of the remote device the local device is connected to. */ ADI_BLER_RESULT adi_radio_GetRemoteDeviceName(const uint16_t nConnHandle)
{ ADI_BLER_RESULT bleResult; ADI_BLE_LOGEVENT(LOGID_CMD_BLEGAP_GET_REMOTE_DEV_NAME); ADI_BLE_RADIO_CMD_START(CMD_BLEGAP_GET_REMOTE_DEV_NAME); memcpy(&pBLERadio->cmdPkt[ADI_RADIO_CMD_HEADER_LEN], &nConnHandle, 2u); bleResult = bler_process_cmd(CMD_BLEGAP_GET_REMOTE_DEV_NAME, 2u, NULL, 0u); if(bleResult == ADI_BLER_SUCCESS){ bleResult = ADI_BLE_WAIT_FOR_COMPLETION(ADI_EVENT_FLAG_EVENT_COMPLETE,ADI_BLER_CMD_TIMEOUT); } ADI_BLE_RADIO_CMD_END(); return (bleResult); }
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* Reset control endpoint management. Called after a USB line reset or at the end of SETUP request (after ZLP) */
static void udd_ctrl_init(void)
/* Reset control endpoint management. Called after a USB line reset or at the end of SETUP request (after ZLP) */ static void udd_ctrl_init(void)
{ irqflags_t flags; dbg_print("ctlInit "); flags = cpu_irq_save(); udd_disable_in_send_interrupt(0); cpu_irq_restore(flags); udd_ack_out_received(0); udd_g_ctrlreq.callback = NULL; udd_g_ctrlreq.over_under_run = NULL; udd_g_ctrlreq.payload_size = 0; udd_ep_control_state = UDD_EPCTRL_SETUP; }
remotemcu/remcu-chip-sdks
C++
null
436
/* brief DMA instance 1, channel 12 IRQ handler. */
void EDMA_1_CH12_DriverIRQHandler(void)
/* brief DMA instance 1, channel 12 IRQ handler. */ void EDMA_1_CH12_DriverIRQHandler(void)
{ EDMA_DriverIRQHandler(1U, 12U); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Note: Pass buf and len to kernel. Start with one page and increase until buffer is sufficient or maxium size is reached */
static void kvm_flic_save(QEMUFile *f, void *opaque)
/* Note: Pass buf and len to kernel. Start with one page and increase until buffer is sufficient or maxium size is reached */ static void kvm_flic_save(QEMUFile *f, void *opaque)
{ KVMS390FLICState *flic = opaque; int len = FLIC_SAVE_INITIAL_SIZE; void *buf; int count; flic_disable_wait_pfault((struct KVMS390FLICState *) opaque); buf = g_try_malloc0(len); if (!buf) { error_report("flic: couldn't allocate memory"); qemu_put_be64(f, FLIC_FAILED); return; } count = __get_all_irqs(flic, &buf, len); if (count < 0) { error_report("flic: couldn't retrieve irqs from kernel, rc %d", count); qemu_put_be64(f, FLIC_FAILED); } else { qemu_put_be64(f, count); qemu_put_buffer(f, (uint8_t *) buf, count * sizeof(struct kvm_s390_irq)); } g_free(buf); }
ve3wwg/teensy3_qemu
C++
Other
15
/* param handle codec handle. param channel audio codec play channel, can be a value or combine value of _codec_play_channel. param isMute true is mute, false is unmute. return kStatus_Success is success, else configure failed. */
status_t HAL_CODEC_SetMute(void *handle, uint32_t playChannel, bool isMute)
/* param handle codec handle. param channel audio codec play channel, can be a value or combine value of _codec_play_channel. param isMute true is mute, false is unmute. return kStatus_Success is success, else configure failed. */ status_t HAL_CODEC_SetMute(void *handle, uint32_t playChannel, bool isMute)
{ assert(handle != NULL); return DA7212_SetChannelMute((da7212_handle_t *)((uint32_t)(((codec_handle_t *)handle)->codecDevHandle)), playChannel, isMute); }
eclipse-threadx/getting-started
C++
Other
310
/* Routine adds class to the list (actually tree) sorted by classid. Make sure that class is not already on such list for given prio. */
static void htb_add_to_id_tree(struct rb_root *root, struct htb_class *cl, int prio)
/* Routine adds class to the list (actually tree) sorted by classid. Make sure that class is not already on such list for given prio. */ static void htb_add_to_id_tree(struct rb_root *root, struct htb_class *cl, int prio)
{ struct rb_node **p = &root->rb_node, *parent = NULL; while (*p) { struct htb_class *c; parent = *p; c = rb_entry(parent, struct htb_class, node[prio]); if (cl->common.classid > c->common.classid) p = &parent->rb_right; else p = &parent->rb_left; } rb_link_node(&cl->node[prio], parent, p); rb_insert_color(&cl->node[prio], root); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* The get and put routines for the struct scsi_cd. Note this entity has a scsi_device pointer and owns a reference to this. */
static struct scsi_cd* scsi_cd_get(struct gendisk *disk)
/* The get and put routines for the struct scsi_cd. Note this entity has a scsi_device pointer and owns a reference to this. */ static struct scsi_cd* scsi_cd_get(struct gendisk *disk)
{ struct scsi_cd *cd = NULL; mutex_lock(&sr_ref_mutex); if (disk->private_data == NULL) goto out; cd = scsi_cd(disk); kref_get(&cd->kref); if (scsi_device_get(cd->device)) goto out_put; goto out; out_put: kref_put(&cd->kref, sr_kref_release); cd = NULL; out: mutex_unlock(&sr_ref_mutex); return cd; }
robutest/uclinux
C++
GPL-2.0
60
/* Note: This function is blocking mode, and it will return only after the number of APs released by calling */
VOID EFIAPI SmmCpuSyncWaitForAPs(IN OUT SMM_CPU_SYNC_CONTEXT *Context, IN UINTN NumberOfAPs, IN UINTN BspIndex)
/* Note: This function is blocking mode, and it will return only after the number of APs released by calling */ VOID EFIAPI SmmCpuSyncWaitForAPs(IN OUT SMM_CPU_SYNC_CONTEXT *Context, IN UINTN NumberOfAPs, IN UINTN BspIndex)
{ UINTN Arrived; ASSERT (Context != NULL); ASSERT (NumberOfAPs < Context->NumberOfCpus); ASSERT (BspIndex < Context->NumberOfCpus); for (Arrived = 0; Arrived < NumberOfAPs; Arrived++) { InternalWaitForSemaphore (Context->CpuSem[BspIndex].Run); } }
tianocore/edk2
C++
Other
4,240
/* Notes : au1000 SoC have only one GPIO block : GPIO1 Au1100, Au15x0, Au12x0 have a second one : GPIO2 */
static int gpio2_get(struct gpio_chip *chip, unsigned offset)
/* Notes : au1000 SoC have only one GPIO block : GPIO1 Au1100, Au15x0, Au12x0 have a second one : GPIO2 */ static int gpio2_get(struct gpio_chip *chip, unsigned offset)
{ return alchemy_gpio2_get_value(offset + ALCHEMY_GPIO2_BASE); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Released under the terms of the GNU GPL v2.0. */
static void sh2__flush_wback_region(void *start, int size)
/* Released under the terms of the GNU GPL v2.0. */ static void sh2__flush_wback_region(void *start, int size)
{ unsigned long v; unsigned long begin, end; begin = (unsigned long)start & ~(L1_CACHE_BYTES-1); end = ((unsigned long)start + size + L1_CACHE_BYTES-1) & ~(L1_CACHE_BYTES-1); for (v = begin; v < end; v+=L1_CACHE_BYTES) { unsigned long addr = CACHE_OC_ADDRESS_ARRAY | (v & 0x00000ff0); int way; for (way = 0; way < 4; way++) { unsigned long data = ctrl_inl(addr | (way << 12)); if ((data & CACHE_PHYSADDR_MASK) == (v & CACHE_PHYSADDR_MASK)) { data &= ~SH_CACHE_UPDATED; ctrl_outl(data, addr | (way << 12)); } } } }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Check whether this value type can be transfer to EFI_IFR_TYPE_UINT64 */
BOOLEAN IsTypeInUINT64(IN EFI_HII_VALUE *Value)
/* Check whether this value type can be transfer to EFI_IFR_TYPE_UINT64 */ BOOLEAN IsTypeInUINT64(IN EFI_HII_VALUE *Value)
{ if (Value == NULL) { return FALSE; } switch (Value->Type) { case EFI_IFR_TYPE_NUM_SIZE_8: case EFI_IFR_TYPE_NUM_SIZE_16: case EFI_IFR_TYPE_NUM_SIZE_32: case EFI_IFR_TYPE_NUM_SIZE_64: case EFI_IFR_TYPE_BOOLEAN: return TRUE; default: return FALSE; } }
tianocore/edk2
C++
Other
4,240
/* Empty a collection of PCI_CAP structures, optionally releasing the referenced PCI_CAP structures themselves. Release the collection at last. */
STATIC VOID EmptyAndUninitPciCapCollection(IN OUT ORDERED_COLLECTION *PciCapCollection, IN BOOLEAN FreePciCap)
/* Empty a collection of PCI_CAP structures, optionally releasing the referenced PCI_CAP structures themselves. Release the collection at last. */ STATIC VOID EmptyAndUninitPciCapCollection(IN OUT ORDERED_COLLECTION *PciCapCollection, IN BOOLEAN FreePciCap)
{ ORDERED_COLLECTION_ENTRY *PciCapEntry; ORDERED_COLLECTION_ENTRY *NextEntry; for (PciCapEntry = OrderedCollectionMin (PciCapCollection); PciCapEntry != NULL; PciCapEntry = NextEntry) { PCI_CAP *PciCap; NextEntry = OrderedCollectionNext (PciCapEntry); OrderedCollectionDelete (PciCapCollection, PciCapEntry, (VOID **)&PciCap); if (FreePciCap) { FreePool (PciCap); } } OrderedCollectionUninit (PciCapCollection); }
tianocore/edk2
C++
Other
4,240
/* This function handles USB On The Go HS global interrupt. */
void OTG_HS_IRQHandler(void)
/* This function handles USB On The Go HS global interrupt. */ void OTG_HS_IRQHandler(void)
{ HAL_HCD_IRQHandler(&hhcd_USB_OTG_HS); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* See mss_uart.h for details of how to use this function. */
void MSS_UART_set_tx_handler(mss_uart_instance_t *this_uart, mss_uart_irq_handler_t handler)
/* See mss_uart.h for details of how to use this function. */ void MSS_UART_set_tx_handler(mss_uart_instance_t *this_uart, mss_uart_irq_handler_t handler)
{ ASSERT((this_uart == &g_mss_uart0) || (this_uart == &g_mss_uart1)); ASSERT(handler != INVALID_IRQ_HANDLER); if(((this_uart == &g_mss_uart0) || (this_uart == &g_mss_uart1)) && (handler != INVALID_IRQ_HANDLER)) { this_uart->tx_handler = handler; this_uart->tx_buffer = (const uint8_t *)0; this_uart->tx_buff_size = 0u; NVIC_ClearPendingIRQ(this_uart->irqn); set_bit_reg8(&this_uart->hw_reg->IER,ETBEI); NVIC_EnableIRQ(this_uart->irqn); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function is only for Micron 128MB flash to access beyond 16MB by switching between eight 16MB-area(segment). Please refer to flash datasheet for more information about memory mapping. */
int flash_set_extend_addr(flash_t *obj, u32 data)
/* This function is only for Micron 128MB flash to access beyond 16MB by switching between eight 16MB-area(segment). Please refer to flash datasheet for more information about memory mapping. */ int flash_set_extend_addr(flash_t *obj, u32 data)
{ ( void ) obj; u8 segnum = (u8)(data & 0x07); FLASH_Write_Lock(); FLASH_SetStatus(0xC5, 1, &segnum); FLASH_Write_Unlock(); return 1; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* This function is executed in uncached address space. */
static __cpuinit void __rm7k_sc_enable(void)
/* This function is executed in uncached address space. */ static __cpuinit void __rm7k_sc_enable(void)
{ int i; set_c0_config(RM7K_CONF_SE); write_c0_taglo(0); write_c0_taghi(0); for (i = 0; i < scache_size; i += sc_lsize) { __asm__ __volatile__ ( ".set noreorder\n\t" ".set mips3\n\t" "cache %1, (%0)\n\t" ".set mips0\n\t" ".set reorder" : : "r" (CKSEG0ADDR(i)), "i" (Index_Store_Tag_SD)); } }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This is apparently the standard way to initailise an MPU-401 */
static void initialise_mpu401(const struct snd_mpu401 *mpu)
/* This is apparently the standard way to initailise an MPU-401 */ static void initialise_mpu401(const struct snd_mpu401 *mpu)
{ outb(0, MPU401D(mpu)); }
robutest/uclinux
C++
GPL-2.0
60
/* removes a firewall record Note that this function is documented in the main component header file, IxEthDB.h. */
IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBFirewallEntryRemove(IxEthDBPortId portID, IxEthDBMacAddr *macAddr)
/* removes a firewall record Note that this function is documented in the main component header file, IxEthDB.h. */ IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBFirewallEntryRemove(IxEthDBPortId portID, IxEthDBMacAddr *macAddr)
{ MacDescriptor recordTemplate; IX_ETH_DB_CHECK_PORT(portID); IX_ETH_DB_CHECK_SINGLE_NPE(portID); IX_ETH_DB_CHECK_REFERENCE(macAddr); IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_FIREWALL); memcpy(recordTemplate.macAddress, macAddr, sizeof (IxEthDBMacAddr)); recordTemplate.type = IX_ETH_DB_FIREWALL_RECORD; recordTemplate.portID = portID; return ixEthDBRemove(&recordTemplate, NULL); }
EmcraftSystems/u-boot
C++
Other
181
/* Removes a subscription from a list of missing files. */
void _km_remove(kqueue_sub *sub)
/* Removes a subscription from a list of missing files. */ void _km_remove(kqueue_sub *sub)
{ G_LOCK (missing_lock); missing_subs_list = g_slist_remove (missing_subs_list, sub); G_UNLOCK (missing_lock); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* ACPI doesn't provide any formal means to access adapter status. Instead, we fake adapter status from _STA. */
static int get_adapter_status(struct hotplug_slot *slot, u8 *value)
/* ACPI doesn't provide any formal means to access adapter status. Instead, we fake adapter status from _STA. */ static int get_adapter_status(struct hotplug_slot *slot, u8 *value)
{ struct slot *slot = hotplug_slot->private; dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); *value = acpiphp_get_adapter_status(slot->acpi_slot); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* This code gets the size of variable header. */
UINTN GetVariableHeaderSize(IN BOOLEAN AuthFormat)
/* This code gets the size of variable header. */ UINTN GetVariableHeaderSize(IN BOOLEAN AuthFormat)
{ UINTN Value; if (AuthFormat) { Value = sizeof (AUTHENTICATED_VARIABLE_HEADER); } else { Value = sizeof (VARIABLE_HEADER); } return Value; }
tianocore/edk2
C++
Other
4,240
/* sys_ccu_apb - Set the freq of the apb @freq: freq want to set */
void __startup sys_ccu_apb(uint32_t dto, uint32_t freq)
/* sys_ccu_apb - Set the freq of the apb @freq: freq want to set */ void __startup sys_ccu_apb(uint32_t dto, uint32_t freq)
{ uint32_t val; dto_freq_set(10, dto, freq); val = read32(GCTL_BASE + GX6605S_SOURCE_SEL0); val |= GX6605S_SOURCE_SEL0_APB; write32(GCTL_BASE + GX6605S_SOURCE_SEL0, val); dto_freq_set(11, dto, freq); val = read32(GCTL_BASE + GX6605S_SOURCE_SEL0); val |= GX6605S_SOURCE_SEL0_UART; write32(GCTL_BASE + GX6605S_SOURCE_SEL0, val); }
xboot/xboot
C++
MIT License
779
/* NOTE: SPI devices do not have a default 'name' attribute, which is likely to be used by hwmon applications to distinguish between different devices, explicitly add a name attribute here. */
static ssize_t show_name(struct device *dev, struct device_attribute *attr, char *buf)
/* NOTE: SPI devices do not have a default 'name' attribute, which is likely to be used by hwmon applications to distinguish between different devices, explicitly add a name attribute here. */ static ssize_t show_name(struct device *dev, struct device_attribute *attr, char *buf)
{ return sprintf(buf, "max1111\n"); }
robutest/uclinux
C++
GPL-2.0
60
/* This function must be called between cpuidle_pause_and_lock and cpuidle_resume_and_unlock when used externally. */
void cpuidle_disable_device(struct cpuidle_device *dev)
/* This function must be called between cpuidle_pause_and_lock and cpuidle_resume_and_unlock when used externally. */ void cpuidle_disable_device(struct cpuidle_device *dev)
{ if (!dev->enabled) return; if (!cpuidle_curr_driver || !cpuidle_curr_governor) return; dev->enabled = 0; if (cpuidle_curr_governor->disable) cpuidle_curr_governor->disable(dev); cpuidle_remove_state_sysfs(dev); enabled_devices--; }
robutest/uclinux
C++
GPL-2.0
60
/* This routine is called when the serial port gets closed. First, we wait for the last remaining data to be sent. Then, we unlink its async structure from the interrupt chain if necessary, and we free */
static void rs_close(struct tty_struct *tty, struct file *filp)
/* This routine is called when the serial port gets closed. First, we wait for the last remaining data to be sent. Then, we unlink its async structure from the interrupt chain if necessary, and we free */ static void rs_close(struct tty_struct *tty, struct file *filp)
{ spin_lock(&timer_lock); if (tty->count == 1) del_timer_sync(&serial_timer); spin_unlock(&timer_lock); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Initialize one edge structure given a line, starting y value and a pixel offset for the line */
PIXMAN_EXPORT void pixman_line_fixed_edge_init(pixman_edge_t *e, int n, pixman_fixed_t y, const pixman_line_fixed_t *line, int x_off, int y_off)
/* Initialize one edge structure given a line, starting y value and a pixel offset for the line */ PIXMAN_EXPORT void pixman_line_fixed_edge_init(pixman_edge_t *e, int n, pixman_fixed_t y, const pixman_line_fixed_t *line, int x_off, int y_off)
{ pixman_fixed_t x_off_fixed = pixman_int_to_fixed (x_off); pixman_fixed_t y_off_fixed = pixman_int_to_fixed (y_off); const pixman_point_fixed_t *top, *bot; if (line->p1.y <= line->p2.y) { top = &line->p1; bot = &line->p2; } else { top = &line->p2; bot = &line->p1; } pixman_edge_init (e, n, y, top->x + x_off_fixed, top->y + y_off_fixed, bot->x + x_off_fixed, bot->y + y_off_fixed); }
xboot/xboot
C++
MIT License
779
/* Write a specified value to a register of the OV7740 sensor. */
uint32_t ov_write_reg(Twi *const p_twi, twi_packet_t *const p_packet)
/* Write a specified value to a register of the OV7740 sensor. */ uint32_t ov_write_reg(Twi *const p_twi, twi_packet_t *const p_packet)
{ uint32_t ul_status; ul_status = twi_master_write(p_twi, p_packet); return ul_status; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Returns the contents of the IOM status register. */
uint32_t am_hal_iom_status_get(uint32_t ui32Module)
/* Returns the contents of the IOM status register. */ uint32_t am_hal_iom_status_get(uint32_t ui32Module)
{ if ( ui32Module >= AM_REG_IOMSTR_NUM_MODULES ) { return 0; } return AM_REGn(IOMSTR, ui32Module, STATUS); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* translate Hex to String pbDest: the memory to stored encoding string pbSrc: the input hex nLen: the length of hex */
void HexToStr(unsigned char *pbDest, unsigned char *pbSrc, int nLen)
/* translate Hex to String pbDest: the memory to stored encoding string pbSrc: the input hex nLen: the length of hex */ void HexToStr(unsigned char *pbDest, unsigned char *pbSrc, int nLen)
{ char ddl,ddh; int i; for (i=0; i<nLen; i++) { ddh = 48 + pbSrc[i] / 16; ddl = 48 + pbSrc[i] % 16; if (ddh > 57) ddh = ddh + 7; if (ddl > 57) ddl = ddl + 7; pbDest[i*2] = ddh; pbDest[i*2+1] = ddl; } pbDest[nLen*2] = '\0'; }
Nicholas3388/LuaNode
C++
Other
1,055
/* Reads a block of data from a remote CPU system address and stores into shared RAM */
void IPCRtoLBlockRead(tIpcMessage *psMessage)
/* Reads a block of data from a remote CPU system address and stores into shared RAM */ void IPCRtoLBlockRead(tIpcMessage *psMessage)
{ uint16_t usLength; volatile uint16_t* pusRAddress; volatile uint16_t* pusWAddress; uint16_t usIndex; pusRAddress = (volatile uint16_t *)psMessage->uladdress; pusWAddress = (volatile uint16_t *)psMessage->uldataw2; usLength = (uint16_t)psMessage->uldataw1; for (usIndex=0; usIndex<usLength; usIndex++) { *pusWAddress = *pusRAddress; pusWAddress += 1; pusRAddress += 1; } IpcRegs.IPCACK.all |= (psMessage->uldataw1 & 0xFFFF0000); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Initializes the tim Channel3 according to the specified parameters in the init_struct. */
void TIM_OC3Init(TIM_TypeDef *tim, TIM_OCInitTypeDef *init_struct)
/* Initializes the tim Channel3 according to the specified parameters in the init_struct. */ void TIM_OC3Init(TIM_TypeDef *tim, TIM_OCInitTypeDef *init_struct)
{ MODIFY_REG(tim->CCMR2, TIM_CCMR2_OC3M, init_struct->TIM_OCMode); MODIFY_REG(tim->CCER, TIM_CCER_CC3EN | TIM_CCER_CC3P, \ (init_struct->TIM_OCPolarity << 8) | (init_struct->TIM_OutputState << 8)); WRITE_REG(tim->CCR3, init_struct->TIM_Pulse); if ((tim == TIM1) || (tim == TIM8)) { MODIFY_REG(tim->CCER, TIM_CCER_CC3NP | TIM_CCER_CC3NEN, \ (init_struct->TIM_OCNPolarity << 8) | (init_struct->TIM_OutputNState << 8)); MODIFY_REG(tim->CR2, TIM_CR2_OIS3 | TIM_CR2_OIS3N, \ (init_struct->TIM_OCIdleState << 4) | (init_struct->TIM_OCNIdleState << 4)); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Cache the create session result into the create session single DRC slot cache by saving the xdr structure. sl_seqid has been set. Do this for solo or embedded create session operations. */
static void nfsd4_cache_create_session(struct nfsd4_create_session *cr_ses, struct nfsd4_clid_slot *slot, int nfserr)
/* Cache the create session result into the create session single DRC slot cache by saving the xdr structure. sl_seqid has been set. Do this for solo or embedded create session operations. */ static void nfsd4_cache_create_session(struct nfsd4_create_session *cr_ses, struct nfsd4_clid_slot *slot, int nfserr)
{ slot->sl_status = nfserr; memcpy(&slot->sl_cr_ses, cr_ses, sizeof(*cr_ses)); }
robutest/uclinux
C++
GPL-2.0
60
/* Deinitializes the USARTx peripheral registers to their default reset values. */
void USART_DeInit(USART_TypeDef *USARTx)
/* Deinitializes the USARTx peripheral registers to their default reset values. */ void USART_DeInit(USART_TypeDef *USARTx)
{ assert_param(IS_USART_ALL_PERIPH(USARTx)); if (USARTx == USART1) { RCC_APB2PeriphResetCmd(RCC_APB2Periph_USART1, ENABLE); RCC_APB2PeriphResetCmd(RCC_APB2Periph_USART1, DISABLE); } else if (USARTx == USART2) { RCC_APB1PeriphResetCmd(RCC_APB1Periph_USART2, ENABLE); RCC_APB1PeriphResetCmd(RCC_APB1Periph_USART2, DISABLE); } else { if (USARTx == USART3) { RCC_APB1PeriphResetCmd(RCC_APB1Periph_USART3, ENABLE); RCC_APB1PeriphResetCmd(RCC_APB1Periph_USART3, DISABLE); } } }
avem-labs/Avem
C++
MIT License
1,752
/* Sets a rate limit on a particular event, so no more than 1 event will be emitted within @rate milliseconds */
static void monitor_protocol_event_throttle(MonitorEvent event, int64_t rate)
/* Sets a rate limit on a particular event, so no more than 1 event will be emitted within @rate milliseconds */ static void monitor_protocol_event_throttle(MonitorEvent event, int64_t rate)
{ MonitorEventState *evstate; assert(event < QEVENT_MAX); evstate = &(monitor_event_state[event]); trace_monitor_protocol_event_throttle(event, rate); evstate->event = event; evstate->rate = rate * SCALE_MS; evstate->timer = timer_new(QEMU_CLOCK_REALTIME, SCALE_MS, monitor_protocol_event_handler, evstate); evstate->last = 0; evstate->data = NULL; }
ve3wwg/teensy3_qemu
C
Other
15
/* "min_len" is the minimum length of the PDU; the length field in the TPKT header must be at least "4+min_len" in order for this to be a valid TPKT PDU for the protocol in question. */
int is_tpkt(tvbuff_t *tvb, int min_len)
/* "min_len" is the minimum length of the PDU; the length field in the TPKT header must be at least "4+min_len" in order for this to be a valid TPKT PDU for the protocol in question. */ int is_tpkt(tvbuff_t *tvb, int min_len)
{ guint16 pkt_len; if (!proto_is_protocol_enabled(proto_tpkt_ptr)) return -1; if (tvb_captured_length(tvb) < 4) return -1; if (!(tvb_get_guint8(tvb, 0) == 3 && tvb_get_guint8(tvb, 1) == 0)) return -1; pkt_len = tvb_get_ntohs(tvb, 2); if (pkt_len < 4 + min_len) return -1; return pkt_len; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* DevicePathNode must be SerialLun type and this will populate the MappingItem. */
EFI_STATUS DevPathSerialLun(IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode, IN DEVICE_CONSIST_MAPPING_INFO *MappingItem, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
/* DevicePathNode must be SerialLun type and this will populate the MappingItem. */ EFI_STATUS DevPathSerialLun(IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode, IN DEVICE_CONSIST_MAPPING_INFO *MappingItem, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
{ DEVICE_LOGICAL_UNIT_DEVICE_PATH *Lun; ASSERT (DevicePathNode != NULL); ASSERT (MappingItem != NULL); Lun = (DEVICE_LOGICAL_UNIT_DEVICE_PATH *)DevicePathNode; return AppendCSDNum (MappingItem, Lun->Lun); }
tianocore/edk2
C++
Other
4,240
/* Called after each bus is probed, but before its children are examined. */
void __devinit pcibios_fixup_bus(struct pci_bus *b)
/* Called after each bus is probed, but before its children are examined. */ void __devinit pcibios_fixup_bus(struct pci_bus *b)
{ struct pci_dev *dev; if (b->self) { pci_read_bridge_bases(b); pcibios_fixup_bridge_resources(b->self); } else { pcibios_setup_root_windows(b, b->sysdata); } list_for_each_entry(dev, &b->devices, bus_list) pcibios_fixup_device_resources(dev); platform_pci_fixup_bus(b); return; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Convert a character index (in an UTF-8 text) to byte index. E.g. in "AÁRT" index of 'R' is 2th char but start at byte 3 because 'Á' is 2 bytes long */
static uint32_t lv_txt_utf8_get_byte_id(const char *txt, uint32_t utf8_id)
/* Convert a character index (in an UTF-8 text) to byte index. E.g. in "AÁRT" index of 'R' is 2th char but start at byte 3 because 'Á' is 2 bytes long */ static uint32_t lv_txt_utf8_get_byte_id(const char *txt, uint32_t utf8_id)
{ uint32_t i; uint32_t byte_cnt = 0; for(i = 0; i < utf8_id && txt[byte_cnt] != '\0'; i++) { uint8_t c_size = _lv_txt_encoded_size(&txt[byte_cnt]); byte_cnt += c_size ? c_size : 1; } return byte_cnt; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Removes a registered interrupt handler for the EPI module. */
void EPIIntUnregister(uint32_t ui32Base)
/* Removes a registered interrupt handler for the EPI module. */ void EPIIntUnregister(uint32_t ui32Base)
{ uint32_t ui32Int; ASSERT(ui32Base == EPI0_BASE); ui32Int = _EPIIntNumberGet(ui32Base); ASSERT(ui32Int != 0); IntDisable(ui32Int); IntUnregister(ui32Int); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Read BMA220 acceleration data. Along with the actual sensor data, the LSB byte contains a "new" flag indicating if the data for this axis has been updated since the last time the axis data was read. Reading either LSB or MSB data will clear this flag. */
static bool bma220_get_accel(sensor_hal_t *hal, sensor_data_t *data)
/* Read BMA220 acceleration data. Along with the actual sensor data, the LSB byte contains a "new" flag indicating if the data for this axis has been updated since the last time the axis data was read. Reading either LSB or MSB data will clear this flag. */ static bool bma220_get_accel(sensor_hal_t *hal, sensor_data_t *data)
{ size_t const count = sensor_bus_read(hal, hal->burst_addr, event_regs.acc, sizeof(event_regs.acc)); format_axis_data(hal, event_regs.acc, data); return (count == sizeof(event_regs.acc)); }
memfault/zero-to-main
C++
null
200
/* Gets the 16-bit color of the pixel at the specified location. */
uint16_t lcdGetPixel(uint16_t x, uint16_t y)
/* Gets the 16-bit color of the pixel at the specified location. */ uint16_t lcdGetPixel(uint16_t x, uint16_t y)
{ if ((x >= hx8347gProperties.width) || (y >= hx8347gProperties.height)) return 0; hx8347gSetCursor(x,y); hx8347gWriteCommand(HX8347G_CMD_SRAMWRITECONTROL); return hx8347gReadData(); }
microbuilder/LPC11U_LPC13U_CodeBase
C++
Other
54
/* Deinitialize the OPAMPs register to its default reset value. */
void OPAMP_DeInit(void)
/* Deinitialize the OPAMPs register to its default reset value. */ void OPAMP_DeInit(void)
{ OPAMP->CSR = 0x00010101; OPAMP->OTR = (uint32_t)(* (uint32_t*)FLASH_R_BASE + 0x00000038); OPAMP->LPOTR = (uint32_t)(* (uint32_t*)FLASH_R_BASE + 0x0000003C); }
avem-labs/Avem
C++
MIT License
1,752
/* Retrieves number of bytes received over the USB CDC ACM Virtual COM Port. The function retrieves number of bytes available in the intermediate buffer that were received over the Virtual COM Port. */
int32_t USBD_CDC_ACM_DataAvailable(void)
/* Retrieves number of bytes received over the USB CDC ACM Virtual COM Port. The function retrieves number of bytes available in the intermediate buffer that were received over the Virtual COM Port. */ int32_t USBD_CDC_ACM_DataAvailable(void)
{ return (ptr_data_received - ptr_data_read); }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* THIS SOFTWARE IS PROVIDED BY Google Inc. ` */
static int trim_to_p256_bytes(unsigned char dst[P256_NBYTES], unsigned char *src, int src_len)
/* THIS SOFTWARE IS PROVIDED BY Google Inc. ` */ static int trim_to_p256_bytes(unsigned char dst[P256_NBYTES], unsigned char *src, int src_len)
{ int dst_offset; while (*src == '\0' && src_len > 0) { src++; src_len--; } if (src_len > P256_NBYTES || src_len < 1) { return 0; } dst_offset = P256_NBYTES - src_len; memset(dst, 0, dst_offset); memcpy(dst + dst_offset, src, src_len); return 1; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Return value is 0 for off, 1 for on, or a negative error code if reading failed. */
static int tsl2563_get_power(struct tsl2563_chip *chip)
/* Return value is 0 for off, 1 for on, or a negative error code if reading failed. */ static int tsl2563_get_power(struct tsl2563_chip *chip)
{ struct i2c_client *client = chip->client; int ret; u8 val; ret = tsl2563_read(client, TSL2563_REG_CTRL, &val, sizeof(val)); if (ret != sizeof(val)) return ret; return (val & TSL2563_CTRL_POWER_MASK) == TSL2563_CMD_POWER_ON; }
robutest/uclinux
C++
GPL-2.0
60
/* IDL long UnlockServiceDatabase( IDL SC_HANDLE lock, IDL ); */
static int svcctl_dissect_UnlockServiceDatabase_rqst(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep)
/* IDL long UnlockServiceDatabase( IDL SC_HANDLE lock, IDL ); */ static int svcctl_dissect_UnlockServiceDatabase_rqst(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep)
{ offset = dissect_nt_policy_hnd( tvb, offset, pinfo, tree, di, drep, hf_svcctl_lock, NULL, NULL, FALSE, TRUE); return offset; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* cx231xx_i2c_check_for_device() check if there is a i2c_device at the supplied address */
static int cx231xx_i2c_check_for_device(struct i2c_adapter *i2c_adap, const struct i2c_msg *msg)
/* cx231xx_i2c_check_for_device() check if there is a i2c_device at the supplied address */ static int cx231xx_i2c_check_for_device(struct i2c_adapter *i2c_adap, const struct i2c_msg *msg)
{ struct cx231xx_i2c *bus = i2c_adap->algo_data; struct cx231xx *dev = bus->dev; struct cx231xx_i2c_xfer_data req_data; int status = 0; req_data.dev_addr = msg->addr; req_data.direction = msg->flags; req_data.saddr_len = 0; req_data.saddr_dat = 0; req_data.buf_size = 0; req_data.p_buffer = NULL; status = dev->cx231xx_send_usb_command(bus, &req_data); return status < 0 ? status : 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Accept a pending connection. The TCP layer now gives BSD semantics. */
int inet_accept(struct socket *sock, struct socket *newsock, int flags)
/* Accept a pending connection. The TCP layer now gives BSD semantics. */ int inet_accept(struct socket *sock, struct socket *newsock, int flags)
{ struct sock *sk1 = sock->sk; int err = -EINVAL; struct sock *sk2 = sk1->sk_prot->accept(sk1, flags, &err); if (!sk2) goto do_err; lock_sock(sk2); WARN_ON(!((1 << sk2->sk_state) & (TCPF_ESTABLISHED | TCPF_CLOSE_WAIT | TCPF_CLOSE))); sock_graft(sk2, newsock); newsock->state = SS_CONNECTED; err = 0; release_sock(sk2); do_err: return err; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Event handler for the library USB Configuration Changed event. */
void EVENT_USB_Device_ConfigurationChanged(void)
/* Event handler for the library USB Configuration Changed event. */ void EVENT_USB_Device_ConfigurationChanged(void)
{ bool ConfigSuccess = true; ConfigSuccess &= CCID_Device_ConfigureEndpoints(&CCID_Interface); LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR); }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Change Logs: Date Author Notes RT-Thread the first version */
void ac97_reset(void)
/* Change Logs: Date Author Notes RT-Thread the first version */ void ac97_reset(void)
{ aaci_ac97_write(AC97_RESET, 0xFFFF); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535