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
/* Find the IRQ entry number of a certain pin. */
static int find_irq_entry(int apic, int pin, int type)
/* Find the IRQ entry number of a certain pin. */ static int find_irq_entry(int apic, int pin, int type)
{ int i; for (i = 0; i < mp_irq_entries; i++) if (mp_irqs[i].irqtype == type && (mp_irqs[i].dstapic == mp_ioapics[apic].apicid || mp_irqs[i].dstapic == MP_APIC_ALL) && mp_irqs[i].dstirq == pin) return i; return -1; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Be careful about ever adding any more callers of this function. Its flags must be in the namei format, not what get passed to sys_open(). */
static int __open_namei_create(struct nameidata *nd, struct path *path, int flag, int mode)
/* Be careful about ever adding any more callers of this function. Its flags must be in the namei format, not what get passed to sys_open(). */ static int __open_namei_create(struct nameidata *nd, struct path *path, int flag, int mode)
{ int error; struct dentry *dir = nd->path.dentry; if (!IS_POSIXACL(dir->d_inode)) mode &= ~current_umask(); error = security_path_mknod(&nd->path, path->dentry, mode, 0); if (error) goto out_unlock; error = vfs_create(dir->d_inode, path->dentry, mode, nd); out_unlock: mutex_unlock(&dir->d_inode->i_mutex); ...
robutest/uclinux
C++
GPL-2.0
60
/* #GZlibCompressor is an implementation of #GConverter that compresses data using zlib. */
static void g_zlib_compressor_iface_init(GConverterIface *iface)
/* #GZlibCompressor is an implementation of #GConverter that compresses data using zlib. */ static void g_zlib_compressor_iface_init(GConverterIface *iface)
{ iface->convert = g_zlib_compressor_convert; iface->reset = g_zlib_compressor_reset; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Base on the input option string to update the skip value for a menu option. */
VOID UpdateSkipInfoForMenu(IN UI_MENU_OPTION *MenuOption, IN CHAR16 *OptionString)
/* Base on the input option string to update the skip value for a menu option. */ VOID UpdateSkipInfoForMenu(IN UI_MENU_OPTION *MenuOption, IN CHAR16 *OptionString)
{ UINTN Index; UINT16 Width; UINTN Row; CHAR16 *OutputString; UINT16 GlyphWidth; Width = (UINT16)gOptionBlockWidth - 1; GlyphWidth = 1; Row = 1; for (Index = 0; GetLineByWidth (OptionString, Width, &GlyphWidth, &Index, &OutputString) != 0x0000;) { if (StrLen (&OptionString[Index...
tianocore/edk2
C++
Other
4,240
/* Send notifications to all registered drivers that a device was added. */
void i2o_driver_notify_device_add_all(struct i2o_device *i2o_dev)
/* Send notifications to all registered drivers that a device was added. */ void i2o_driver_notify_device_add_all(struct i2o_device *i2o_dev)
{ int i; struct i2o_driver *drv; for (i = 0; i < i2o_max_drivers; i++) { drv = i2o_drivers[i]; if (drv) i2o_driver_notify_device_add(drv, i2o_dev); } }
robutest/uclinux
C++
GPL-2.0
60
/* This function will return the name of the specified thread. */
rt_err_t rt_thread_get_name(rt_thread_t thread, char *name, rt_uint8_t name_size)
/* This function will return the name of the specified thread. */ rt_err_t rt_thread_get_name(rt_thread_t thread, char *name, rt_uint8_t name_size)
{ return (thread == RT_NULL) ? -RT_EINVAL : rt_object_get_name(&thread->parent, name, name_size); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* SYSCTRL IIR2 Bus&Function Clock Disable and Reset Assert. */
void LL_SYSCTRL_IIR2_ClkDisRstAssert(void)
/* SYSCTRL IIR2 Bus&Function Clock Disable and Reset Assert. */ void LL_SYSCTRL_IIR2_ClkDisRstAssert(void)
{ __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); __LL_SYSCTRL_IIR2BusClk_Dis(SYSCTRL); __LL_SYSCTRL_IIR2FunClk_Dis(SYSCTRL); __LL_SYSCTRL_IIR2SoftRst_Assert(SYSCTRL); __LL_SYSCTRL_Reg_Lock(SYSCTRL); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* See the vsprintf() documentation for format string extensions over C99. */
int sprintf(char *buf, const char *fmt,...)
/* See the vsprintf() documentation for format string extensions over C99. */ int sprintf(char *buf, const char *fmt,...)
{ va_list args; int i; va_start(args, fmt); i=vsprintf(buf,fmt,args); va_end(args); return i; }
EmcraftSystems/u-boot
C++
Other
181
/* Perform cable detection on the UDMA66, UDMA100 and early UDMA133 SiS IDE controllers. */
static int sis_66_cable_detect(struct ata_port *ap)
/* Perform cable detection on the UDMA66, UDMA100 and early UDMA133 SiS IDE controllers. */ static int sis_66_cable_detect(struct ata_port *ap)
{ struct pci_dev *pdev = to_pci_dev(ap->host->dev); u8 tmp; pci_read_config_byte(pdev, 0x48, &tmp); tmp >>= ap->port_no; if ((tmp & 0x10) && !sis_short_ata40(pdev)) return ATA_CBL_PATA40; return ATA_CBL_PATA80; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Check whether 'status' is not OK and, if so, prints the error message on the top of the stack. It assumes that the error object is a string, as it was either generated by Lua or by 'msghandler'. */
static int report(lua_State *L, int status)
/* Check whether 'status' is not OK and, if so, prints the error message on the top of the stack. It assumes that the error object is a string, as it was either generated by Lua or by 'msghandler'. */ static int report(lua_State *L, int status)
{ const char *msg = lua_tostring(L, -1); l_message(progname, msg); lua_pop(L, 1); } return status; }
Nicholas3388/LuaNode
C++
Other
1,055
/* Set Local Appearance. This API is used to set the local device appearance. This appearance is populated when discoverable if the device is peripheral or may be read by the remote device when connected. Setting the appearance will improve user experience. */
ADI_BLER_RESULT adi_radio_SetLocalAppearance(const ADI_BLE_GAP_APPEARANCE eAppearance)
/* Set Local Appearance. This API is used to set the local device appearance. This appearance is populated when discoverable if the device is peripheral or may be read by the remote device when connected. Setting the appearance will improve user experience. */ ADI_BLER_RESULT adi_radio_SetLocalAppearance(const ADI_BLE...
{ ADI_BLER_RESULT bleResult; uint16_t nAppearance = (uint16_t) eAppearance; ADI_BLE_LOGEVENT(LOGID_CMD_BLEGAP_SET_LOCAL_APPEARANCE); ADI_BLE_RADIO_CMD_START(CMD_BLEGAP_SET_LOCAL_APPEARANCE); memcpy(&pBLERadio->cmdPkt[ADI_RADIO_CMD_HEADER_LEN], &nAppearance, 2u); bleResult = bler_process_cmd(CMD_...
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* Retry logic exist outside these macros to protect from spurrious wakeups. */
static void TXN_SLEEP_DROP_LOCK(wait_queue_head_t *event)
/* Retry logic exist outside these macros to protect from spurrious wakeups. */ static void TXN_SLEEP_DROP_LOCK(wait_queue_head_t *event)
{ DECLARE_WAITQUEUE(wait, current); add_wait_queue(event, &wait); set_current_state(TASK_UNINTERRUPTIBLE); TXN_UNLOCK(); io_schedule(); __set_current_state(TASK_RUNNING); remove_wait_queue(event, &wait); }
robutest/uclinux
C++
GPL-2.0
60
/* Set the PWM frequency of the PWM module. The */
unsigned long xPWMFrequencyConfig(unsigned long ulBase, unsigned long ulChannel, unsigned long ulConfig)
/* Set the PWM frequency of the PWM module. The */ unsigned long xPWMFrequencyConfig(unsigned long ulBase, unsigned long ulChannel, unsigned long ulConfig)
{ return PWMFrequencyConfig(ulBase, ulChannel, ulConfig); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* param base ASRC base pointer. param handle ASRC eDMA handle pointer. param xfer Pointer to the DMA transfer structure. retval kStatus_Success Start a ASRC eDMA send successfully. retval kStatus_InvalidArgument The input argument is invalid. retval kStatus_ASRCQueueFull ASRC EDMA driver queue is full. */
status_t ASRC_TransferEDMA(ASRC_Type *base, asrc_edma_handle_t *handle, asrc_transfer_t *xfer)
/* param base ASRC base pointer. param handle ASRC eDMA handle pointer. param xfer Pointer to the DMA transfer structure. retval kStatus_Success Start a ASRC eDMA send successfully. retval kStatus_InvalidArgument The input argument is invalid. retval kStatus_ASRCQueueFull ASRC EDMA driver queue is full. */ status_t AS...
{ assert(handle != NULL); if (ASRC_TransferOutSubmitEDMA(base, handle, xfer->outData, xfer->outDataSize) != kStatus_Success) { return kStatus_ASRCQueueFull; } if (ASRC_TransferInSubmitEDMA(base, handle, xfer->inData, xfer->inDataSize) != kStatus_Success) { return kStatus_ASRCQueu...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Checks if the SPI module is ready to read data. This function will check if the SPI module is ready to read data. */
static bool _spi_is_ready_to_read(Spi *const spi_module)
/* Checks if the SPI module is ready to read data. This function will check if the SPI module is ready to read data. */ static bool _spi_is_ready_to_read(Spi *const spi_module)
{ Assert(spi_module); return (spi_module->RECEIVE_STATUS.bit.RX_FIFO_NOT_EMPTY); }
memfault/zero-to-main
C++
null
200
/* Get the some types info of the file into Buffer. */
EFI_STATUS EFIAPI FatGetInfo(IN EFI_FILE_PROTOCOL *FHand, IN EFI_GUID *Type, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
/* Get the some types info of the file into Buffer. */ EFI_STATUS EFIAPI FatGetInfo(IN EFI_FILE_PROTOCOL *FHand, IN EFI_GUID *Type, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
{ return FatSetOrGetInfo (FALSE, FHand, Type, BufferSize, Buffer); }
tianocore/edk2
C++
Other
4,240
/* Selects the specified I2C PEC position in SMBUS mode. */
void I2CPECPositionConfig(unsigned long ulBase, unsigned long ulPECPosition)
/* Selects the specified I2C PEC position in SMBUS mode. */ void I2CPECPositionConfig(unsigned long ulBase, unsigned long ulPECPosition)
{ xASSERT((ulBase == I2C1_BASE) || (ulBase == I2C2_BASE)); xASSERT((ulBase == I2C_PECPOS_NEXT) || (ulBase == I2C_PECPOS_CURRENT)); xHWREG(ulBase + I2C_CR1) &= ~I2C_CR1_POS; xHWREG(ulBase + I2C_CR1) |= ulPECPosition; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* returns SUCCESS if it successfully received a message notification and copied it into the receive buffer. */
static s32 igb_read_posted_mbx(struct e1000_hw *hw, u32 *msg, u16 size, u16 mbx_id)
/* returns SUCCESS if it successfully received a message notification and copied it into the receive buffer. */ static s32 igb_read_posted_mbx(struct e1000_hw *hw, u32 *msg, u16 size, u16 mbx_id)
{ struct e1000_mbx_info *mbx = &hw->mbx; s32 ret_val = -E1000_ERR_MBX; if (!mbx->ops.read) goto out; ret_val = igb_poll_for_msg(hw, mbx_id); if (!ret_val) ret_val = mbx->ops.read(hw, msg, size, mbx_id); out: return ret_val; }
robutest/uclinux
C++
GPL-2.0
60
/* This function sets the mask flag in the LVT LINT0 & LINT1 registers. */
VOID EFIAPI DisableLvtInterrupts(VOID)
/* This function sets the mask flag in the LVT LINT0 & LINT1 registers. */ VOID EFIAPI DisableLvtInterrupts(VOID)
{ LOCAL_APIC_LVT_LINT LvtLint; LvtLint.Uint32 = ReadLocalApicReg (XAPIC_LVT_LINT0_OFFSET); LvtLint.Bits.Mask = 1; WriteLocalApicReg (XAPIC_LVT_LINT0_OFFSET, LvtLint.Uint32); LvtLint.Uint32 = ReadLocalApicReg (XAPIC_LVT_LINT1_OFFSET); LvtLint.Bits.Mask = 1; WriteLocalApicReg (XAPIC_LVT_LINT1_OFFSET,...
tianocore/edk2
C++
Other
4,240
/* Advertise in the store a change of the given driver to the given new_state. Return 0 on success, or -errno on error. On error, the device will switch to XenbusStateClosing, and the error will be saved in the store. */
int xenbus_switch_state(struct xenbus_device *dev, enum xenbus_state state)
/* Advertise in the store a change of the given driver to the given new_state. Return 0 on success, or -errno on error. On error, the device will switch to XenbusStateClosing, and the error will be saved in the store. */ int xenbus_switch_state(struct xenbus_device *dev, enum xenbus_state state)
{ int current_state; int err; if (state == dev->state) return 0; err = xenbus_scanf(XBT_NIL, dev->nodename, "state", "%d", &current_state); if (err != 1) return 0; err = xenbus_printf(XBT_NIL, dev->nodename, "state", "%d", state); if (err) { if (state != XenbusStateClosing) xenbus_dev_fatal(dev, e...
robutest/uclinux
C++
GPL-2.0
60
/* Function to free the block identified by block number 'block_index'. */
static bool is_block_free(uint32_t block_index)
/* Function to free the block identified by block number 'block_index'. */ static bool is_block_free(uint32_t block_index)
{ uint32_t x; uint32_t y; get_block_coordinates(block_index, &x, &y); return IS_SET(m_mem_pool[x], y); }
labapart/polymcu
C++
null
201
/* Returs 0 on success or negative error code on failure. */
static int i2o_device_issue_claim(struct i2o_device *dev, u32 cmd, u32 type)
/* Returs 0 on success or negative error code on failure. */ static int i2o_device_issue_claim(struct i2o_device *dev, u32 cmd, u32 type)
{ struct i2o_message *msg; msg = i2o_msg_get_wait(dev->iop, I2O_TIMEOUT_MESSAGE_GET); if (IS_ERR(msg)) return PTR_ERR(msg); msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0); msg->u.head[1] = cpu_to_le32(cmd << 24 | HOST_TID << 12 | dev->lct_data.tid); msg->body[0] = cpu_to_le32(type); retur...
robutest/uclinux
C++
GPL-2.0
60
/* Setup timer 1 compare match to generate a tick interrupt. */
static void prvSetupTimerInterrupt(void)
/* Setup timer 1 compare match to generate a tick interrupt. */ static void prvSetupTimerInterrupt(void)
{ const unsigned long ulCompareMatch = ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) / portCLOCK_DIV; MSTPCR &= ~portMSTP13; TCR1 = portCLEAR_ON_TGRA_COMPARE_MATCH | portCLOCK_DIV_64; TGR1A = ulCompareMatch; TIER1 |= portTGRA_INTERRUPT_ENABLE; TSTR |= portTIMER_CHANNEL; }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). */
UINT32 EFIAPI PciExpressAndThenOr32(IN UINTN Address, IN UINT32 AndData, IN UINT32 OrData)
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). */ UINT32 EFIAPI PciExpressAndThenOr32(IN UINTN Address, IN UINT32 AndData, IN UINT32 OrData)
{ if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) { return (UINT32)-1; } return MmioAndThenOr32 ( GetPciExpressAddress (Address), AndData, OrData ); }
tianocore/edk2
C++
Other
4,240
/* Find the device struct by its device index. */
struct dasd_device* dasd_device_from_devindex(int devindex)
/* Find the device struct by its device index. */ struct dasd_device* dasd_device_from_devindex(int devindex)
{ struct dasd_devmap *devmap, *tmp; struct dasd_device *device; int i; spin_lock(&dasd_devmap_lock); devmap = NULL; for (i = 0; (i < 256) && !devmap; i++) list_for_each_entry(tmp, &dasd_hashlists[i], list) if (tmp->devindex == devindex) { devmap = tmp; break; } if (devmap && devmap->device) { d...
robutest/uclinux
C++
GPL-2.0
60
/* This function should be used whenever the status of any RPL must be modified by the driver, because the compiler may otherwise change the order of instructions such that writing the RPL status may be executed at an undesireable time. When this function is used, the status is always written when the function is calle...
static void tms380tr_write_rpl_status(RPL *rpl, unsigned int Status)
/* This function should be used whenever the status of any RPL must be modified by the driver, because the compiler may otherwise change the order of instructions such that writing the RPL status may be executed at an undesireable time. When this function is used, the status is always written when the function is calle...
{ rpl->Status = Status; return; }
robutest/uclinux
C++
GPL-2.0
60
/* Measure and log Separator event with error, and extend the measurement result into a specific PCR. */
EFI_STATUS MeasureSeparatorEventWithError(IN TPM_PCRINDEX PCRIndex)
/* Measure and log Separator event with error, and extend the measurement result into a specific PCR. */ EFI_STATUS MeasureSeparatorEventWithError(IN TPM_PCRINDEX PCRIndex)
{ TCG_PCR_EVENT_HDR TcgEvent; UINT32 EventData; EventData = 0x1; TcgEvent.PCRIndex = PCRIndex; TcgEvent.EventType = EV_SEPARATOR; TcgEvent.EventSize = (UINT32)sizeof (EventData); return HashLogExtendEvent (&mEdkiiTcgPpi, 0, (UINT8 *)&EventData, TcgEvent.EventSize, &TcgEvent, (UINT8 ...
tianocore/edk2
C++
Other
4,240
/* Programs a half word at a specified Option Byte Data address. */
FLASH_Status FLASH_OB_ProgramData(uint32_t Address, uint8_t Data)
/* Programs a half word at a specified Option Byte Data address. */ FLASH_Status FLASH_OB_ProgramData(uint32_t Address, uint8_t Data)
{ FLASH_Status status = FLASH_COMPLETE; assert_param(IS_OB_DATA_ADDRESS(Address)); status = FLASH_WaitForLastOperation(FLASH_ER_PRG_TIMEOUT); if (status == FLASH_COMPLETE) { FLASH->CR |= FLASH_CR_OPTPG; *(__IO uint16_t *)Address = Data; status = FLASH_WaitForLastOperation(FLA...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Config the SPI peripheral according to the specified parameters in the spiConfig. */
void SPI_Config(SPI_T *spi, SPI_Config_T *spiConfig)
/* Config the SPI peripheral according to the specified parameters in the spiConfig. */ void SPI_Config(SPI_T *spi, SPI_Config_T *spiConfig)
{ spi->CTRL1_B.MSMCFG = spiConfig->mode; spi->CTRL1_B.ISSEL = spiConfig->mode; spi->CTRL1_B.DFLSEL = spiConfig->length; spi->CTRL1_B.CPHA = spiConfig->phase; spi->CTRL1_B.CPOL = spiConfig->polarity; spi->CTRL1_B.SSEN = spiConfig->nss; spi->CTRL1_B.LSBSEL = spiConfig->firstBit; spi->CTRL1...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* SPI Set the Clock Phase to Capture on Leading Edge. */
void spi_set_clock_phase_0(uint32_t spi)
/* SPI Set the Clock Phase to Capture on Leading Edge. */ void spi_set_clock_phase_0(uint32_t spi)
{ SPI_CR1(spi) &= ~SPI_CR1_CPHA; }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* A partial UnAlloc must include the last BD in the list that was Alloc'd. */
LONG XEmacPs_BdRingUnAlloc(XEmacPs_BdRing *RingPtr, u32 NumBd, XEmacPs_Bd *BdSetPtr)
/* A partial UnAlloc must include the last BD in the list that was Alloc'd. */ LONG XEmacPs_BdRingUnAlloc(XEmacPs_BdRing *RingPtr, u32 NumBd, XEmacPs_Bd *BdSetPtr)
{ LONG Status; (void) BdSetPtr; Xil_AssertNonvoid(RingPtr != NULL); Xil_AssertNonvoid(BdSetPtr != NULL); if (RingPtr->PreCnt < NumBd) { Status = (LONG)(XST_FAILURE); } else { XEMACPS_RING_SEEKBACK(RingPtr, (RingPtr->FreeHead), NumBd); RingPtr->FreeCnt += NumBd; RingPtr->P...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* We can merge two free data extents only if the physical blocks are contiguous, AND the extents were freed by the same transaction, AND the blocks are associated with the same group. */
static int can_merge(struct ext4_free_data *entry1, struct ext4_free_data *entry2)
/* We can merge two free data extents only if the physical blocks are contiguous, AND the extents were freed by the same transaction, AND the blocks are associated with the same group. */ static int can_merge(struct ext4_free_data *entry1, struct ext4_free_data *entry2)
{ if ((entry1->t_tid == entry2->t_tid) && (entry1->group == entry2->group) && ((entry1->start_blk + entry1->count) == entry2->start_blk)) return 1; return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* This function gets the FSP global data pointer. */
FSP_GLOBAL_DATA* EFIAPI GetFspGlobalDataPointer(VOID)
/* This function gets the FSP global data pointer. */ FSP_GLOBAL_DATA* EFIAPI GetFspGlobalDataPointer(VOID)
{ FSP_GLOBAL_DATA *FspData; FspData = *(FSP_GLOBAL_DATA **)(UINTN)PcdGet32 (PcdGlobalDataPointerAddress); return FspData; }
tianocore/edk2
C++
Other
4,240
/* If any reserved bits in Address are set, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). */
UINT16 EFIAPI PciSegmentAnd16(IN UINT64 Address, IN UINT16 AndData)
/* If any reserved bits in Address are set, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). */ UINT16 EFIAPI PciSegmentAnd16(IN UINT64 Address, IN UINT16 AndData)
{ UINTN Count; PCI_SEGMENT_INFO *SegmentInfo; SegmentInfo = GetPciSegmentInfo (&Count); return MmioAnd16 (PciSegmentLibGetEcamAddress (Address, SegmentInfo, Count), AndData); }
tianocore/edk2
C++
Other
4,240
/* Returns a value to check the end of USB Configuration descriptor. */
static usb_conf_desc_t UDC_DESC_STORAGE* udc_get_eof_conf(void)
/* Returns a value to check the end of USB Configuration descriptor. */ static usb_conf_desc_t UDC_DESC_STORAGE* udc_get_eof_conf(void)
{ return (UDC_DESC_STORAGE usb_conf_desc_t *) ((uint8_t *) udc_ptr_conf->desc + le16_to_cpu(udc_ptr_conf->desc->wTotalLength)); }
remotemcu/remcu-chip-sdks
C++
null
436
/* Enables or disables the CRC value calculation of the transfered bytes. */
void SPI_CalculateCRCCmd(SPI_TypeDef *SPIx, FunctionalState NewState)
/* Enables or disables the CRC value calculation of the transfered bytes. */ void SPI_CalculateCRCCmd(SPI_TypeDef *SPIx, FunctionalState NewState)
{ assert_param(IS_FUNCTIONAL_STATE(NewState)); SPI_Cmd(SPI1, DISABLE); if (NewState != DISABLE) { SPIx->CR2 |= SPI_CR2_CRCEN; } else { SPIx->CR2 &= (uint8_t)(~SPI_CR2_CRCEN); } }
remotemcu/remcu-chip-sdks
C++
null
436
/* Sets the size of the array. When making the array larger, newly-added elements will be set to NULL. When making it smaller, if @array has a non-NULL #GDestroyNotify function then it will be called for the removed elements. */
void g_ptr_array_set_size(GPtrArray *array, gint length)
/* Sets the size of the array. When making the array larger, newly-added elements will be set to NULL. When making it smaller, if @array has a non-NULL #GDestroyNotify function then it will be called for the removed elements. */ void g_ptr_array_set_size(GPtrArray *array, gint length)
{ GRealPtrArray *rarray = (GRealPtrArray *)array; g_return_if_fail (rarray); if (length > rarray->len) { int i; g_ptr_array_maybe_expand (rarray, (length - rarray->len)); for (i = rarray->len; i < length; i++) rarray->pdata[i] = NULL; } else if (length < rarray->len) g_ptr_...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* @pgtable: Pointer to a 24iKB block of memory */
static void build_pagetable(uint32_t *pgtable)
/* @pgtable: Pointer to a 24iKB block of memory */ static void build_pagetable(uint32_t *pgtable)
{ uint i; memset(pgtable, '\0', PAGETABLE_SIZE); pgtable[0] = (ulong)&pgtable[1024] + 7; for (i = 0; i < 4; i++) pgtable[1024 + i * 2] = (ulong)&pgtable[2048] + 0x1000 * i + 7; for (i = 0; i < 2048; i++) pgtable[2048 + i * 2] = 0x183 + (i << 21UL); }
4ms/stm32mp1-baremetal
C++
Other
137
/* Sets the content type attribute for a given #GFileInfo. See G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE. */
void g_file_info_set_content_type(GFileInfo *info, const char *content_type)
/* Sets the content type attribute for a given #GFileInfo. See G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE. */ void g_file_info_set_content_type(GFileInfo *info, const char *content_type)
{ static guint32 attr = 0; GFileAttributeValue *value; g_return_if_fail (G_IS_FILE_INFO (info)); g_return_if_fail (content_type != NULL); if (attr == 0) attr = lookup_attribute (G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE); value = g_file_info_create_value (info, attr); if (value) _g_file_attribute_val...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Extends the #GIcon interface and adds the ability to load icons from streams. */
static void g_loadable_icon_real_load_async(GLoadableIcon *icon, int size, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
/* Extends the #GIcon interface and adds the ability to load icons from streams. */ static void g_loadable_icon_real_load_async(GLoadableIcon *icon, int size, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
{ GTask *task; LoadData *data; task = g_task_new (icon, cancellable, callback, user_data); data = g_new0 (LoadData, 1); g_task_set_task_data (task, data, (GDestroyNotify) load_data_free); g_task_run_in_thread (task, load_async_thread); g_object_unref (task); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* cdns3_ep_addr_to_index - Macro converts endpoint address to index of endpoint object in cdns3_device.eps container @ep_addr: endpoint address for which endpoint object is required */
u8 cdns3_ep_addr_to_index(u8 ep_addr)
/* cdns3_ep_addr_to_index - Macro converts endpoint address to index of endpoint object in cdns3_device.eps container @ep_addr: endpoint address for which endpoint object is required */ u8 cdns3_ep_addr_to_index(u8 ep_addr)
{ return (((ep_addr & 0x7F)) + ((ep_addr & USB_DIR_IN) ? 16 : 0)); }
4ms/stm32mp1-baremetal
C++
Other
137
/* This routine can be used from both task and interrupt context. */
atomic_val_t rhino_atomic_inc(atomic_t *target)
/* This routine can be used from both task and interrupt context. */ atomic_val_t rhino_atomic_inc(atomic_t *target)
{ CPSR_ALLOC(); atomic_val_t old_value; RHINO_CPU_INTRPT_DISABLE(); old_value = *target; (*target)++; RHINO_CPU_INTRPT_ENABLE(); return old_value; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Return 1 (true) on link up. Return 0 (false) on link down. */
static int pcie_advk_link_up(struct pcie_advk *pcie)
/* Return 1 (true) on link up. Return 0 (false) on link down. */ static int pcie_advk_link_up(struct pcie_advk *pcie)
{ u32 val, ltssm_state; val = advk_readl(pcie, CFG_REG); ltssm_state = (val >> LTSSM_SHIFT) & LTSSM_MASK; return ltssm_state >= LTSSM_L0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Description: Perform a label mapping to translate a CIPSO category list to the correct local MLS category bitmap using the given DOI definition. Returns zero on success, negative values on failure. */
static int cipso_v4_map_cat_enum_ntoh(const struct cipso_v4_doi *doi_def, const unsigned char *net_cat, u32 net_cat_len, struct netlbl_lsm_secattr *secattr)
/* Description: Perform a label mapping to translate a CIPSO category list to the correct local MLS category bitmap using the given DOI definition. Returns zero on success, negative values on failure. */ static int cipso_v4_map_cat_enum_ntoh(const struct cipso_v4_doi *doi_def, const unsigned char *net_cat, u32 net_cat...
{ int ret_val; u32 iter; for (iter = 0; iter < net_cat_len; iter += 2) { ret_val = netlbl_secattr_catmap_setbit(secattr->attr.mls.cat, get_unaligned_be16(&net_cat[iter]), GFP_ATOMIC); if (ret_val != 0) return ret_val; } return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Add a Firmare revision selector to a mapping */
static int mapping_addfirmware(struct if_mapping *ifnode, int *active, char *pos, size_t len, struct add_extra *extra, int linenum)
/* Add a Firmare revision selector to a mapping */ static int mapping_addfirmware(struct if_mapping *ifnode, int *active, char *pos, size_t len, struct add_extra *extra, int linenum)
{ extra = extra; if(len >= sizeof(ifnode->fw_version)) { fprintf(stderr, "Firmware revision too long at line %d\n", linenum); return(-1); } memcpy(ifnode->fw_version, string, len + 1); ifnode->active[SELECT_FIRMWARE] = 1; active[SELECT_FIRMWARE] = 1; if(verbose) fprintf(stderr, ...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* @itr: iterator to initialize @fsdata: filesystem data for the partition */
static int fat_itr_root(fat_itr *itr, fsdata *fsdata)
/* @itr: iterator to initialize @fsdata: filesystem data for the partition */ static int fat_itr_root(fat_itr *itr, fsdata *fsdata)
{ if (get_fs_info(fsdata)) return -ENXIO; itr->fsdata = fsdata; itr->start_clust = 0; itr->clust = fsdata->root_cluster; itr->next_clust = fsdata->root_cluster; itr->dent = NULL; itr->remaining = 0; itr->last_cluster = 0; itr->is_root = 1; return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Polls if an available TX descriptor is ready. Can be used to determine if the low level transmit function will block. */
s32_t lpc_tx_ready(struct netif *netif)
/* Polls if an available TX descriptor is ready. Can be used to determine if the low level transmit function will block. */ s32_t lpc_tx_ready(struct netif *netif)
{ s32_t fb; u32_t idx, cidx; cidx = LPC_EMAC->TxConsumeIndex; idx = LPC_EMAC->TxProduceIndex; if (idx == cidx) fb = LPC_NUM_BUFF_TXDESCS; else if (cidx > idx) fb = (LPC_NUM_BUFF_TXDESCS - 1) - ((idx + LPC_NUM_BUFF_TXDESCS) - cidx); else fb = (LPC_NUM_BUFF_...
ajhc/demo-cortex-m3
C++
null
38
/* This function retrieves the user readable name of a driver in the form of a Unicode string. If the driver specified by This has a user readable name in the language specified by Language, then a pointer to the driver name is returned in DriverName, and EFI_SUCCESS is returned. If the driver specified by This does no...
EFI_STATUS EFIAPI I2cHostComponentNameGetDriverName(IN EFI_COMPONENT_NAME2_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
/* This function retrieves the user readable name of a driver in the form of a Unicode string. If the driver specified by This has a user readable name in the language specified by Language, then a pointer to the driver name is returned in DriverName, and EFI_SUCCESS is returned. If the driver specified by This does no...
{ return LookupUnicodeString2 ( Language, This->SupportedLanguages, mI2cHostDriverNameTable, DriverName, (BOOLEAN)(This != &gI2cHostComponentName2) ); }
tianocore/edk2
C++
Other
4,240
/* Enable the ADC Watchdog monitor. Enables the comparator to monitor the analog input. */
void ADCMoniEnable(unsigned long ulBase, unsigned long ulChanType)
/* Enable the ADC Watchdog monitor. Enables the comparator to monitor the analog input. */ void ADCMoniEnable(unsigned long ulBase, unsigned long ulChanType)
{ xASSERT((ulBase == ADC1_BASE) || (ulBase == ADC2_BASE) || (ulBase == ADC3_BASE)); xASSERT((ulChanType == ADC_TYPE_REGULAR) || (ulChanType == ADC_TYPE_INJECTED) || (ulChanType == (ADC_TYPE_REGULAR|ADC_TYPE_INJECTED))); if(ulChanType == ADC_TYPE_REGULAR) { xHWREG(ulBase + ADC_CR1) |...
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* @addr: Address of base of memory region to read into L2 cache @len: Length (in bytes) of region to fault in */
static void fault_in(uint64_t addr, int len)
/* @addr: Address of base of memory region to read into L2 cache @len: Length (in bytes) of region to fault in */ static void fault_in(uint64_t addr, int len)
{ volatile char *ptr; volatile char dummy; len += addr & CVMX_CACHE_LINE_MASK; addr &= ~CVMX_CACHE_LINE_MASK; ptr = (volatile char *)cvmx_phys_to_ptr(addr); CVMX_DCACHE_INVALIDATE; while (len > 0) { dummy += *ptr; len -= CVMX_CACHE_LINE_SIZE; ptr += CVMX_CACHE_LINE_SIZE; } }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Disable AIC channel of RTC and both tick and alarm interrupt. */
UINT32 RTC_Close(void)
/* Disable AIC channel of RTC and both tick and alarm interrupt. */ UINT32 RTC_Close(void)
{ g_bIsEnableTickInt = FALSE; sysDisableInterrupt(RTC_IRQn); RTC_Ioctl(0, RTC_IOC_DISABLE_INT, RTC_ALL_INT, 0); return E_RTC_SUCCESS; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Deliver the packet for each IP6 child on the interface. */
VOID Ip6InterfaceDeliverPacket(IN IP6_SERVICE *IpSb, IN IP6_INTERFACE *IpIf)
/* Deliver the packet for each IP6 child on the interface. */ VOID Ip6InterfaceDeliverPacket(IN IP6_SERVICE *IpSb, IN IP6_INTERFACE *IpIf)
{ IP6_PROTOCOL *IpInstance; LIST_ENTRY *Entry; NET_LIST_FOR_EACH (Entry, &IpIf->IpInstances) { IpInstance = NET_LIST_USER_STRUCT (Entry, IP6_PROTOCOL, AddrLink); Ip6InstanceDeliverPacket (IpInstance); } }
tianocore/edk2
C++
Other
4,240
/* Memory allocated by this function must be released by free_pages_exact(). */
void* alloc_pages_exact(size_t size, gfp_t gfp_mask)
/* Memory allocated by this function must be released by free_pages_exact(). */ void* alloc_pages_exact(size_t size, gfp_t gfp_mask)
{ unsigned int order = get_order(size); unsigned long addr; addr = __get_free_pages(gfp_mask, order); if (addr) { unsigned long alloc_end = addr + (PAGE_SIZE << order); unsigned long used = addr + PAGE_ALIGN(size); split_page(virt_to_page((void *)addr), order); while (used < alloc_end) { free_page(used);...
robutest/uclinux
C++
GPL-2.0
60
/* ibmvfc_link_down - Handle a link down event from the adapter @vhost: ibmvfc host struct @state: ibmvfc host state to enter */
static void ibmvfc_link_down(struct ibmvfc_host *vhost, enum ibmvfc_host_state state)
/* ibmvfc_link_down - Handle a link down event from the adapter @vhost: ibmvfc host struct @state: ibmvfc host state to enter */ static void ibmvfc_link_down(struct ibmvfc_host *vhost, enum ibmvfc_host_state state)
{ struct ibmvfc_target *tgt; ENTER; scsi_block_requests(vhost->host); list_for_each_entry(tgt, &vhost->targets, queue) ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_DEL_RPORT); ibmvfc_set_host_state(vhost, state); ibmvfc_set_host_action(vhost, IBMVFC_HOST_ACTION_TGT_DEL); vhost->events_to_log |= IBMVFC_AE_LINKD...
robutest/uclinux
C++
GPL-2.0
60
/* This function will detach the device handler only if the sdev is not part of the internal list, ie if it has been attached manually. */
void scsi_dh_detach(struct request_queue *q)
/* This function will detach the device handler only if the sdev is not part of the internal list, ie if it has been attached manually. */ void scsi_dh_detach(struct request_queue *q)
{ unsigned long flags; struct scsi_device *sdev; struct scsi_device_handler *scsi_dh = NULL; spin_lock_irqsave(q->queue_lock, flags); sdev = q->queuedata; if (!sdev || !get_device(&sdev->sdev_gendev)) sdev = NULL; spin_unlock_irqrestore(q->queue_lock, flags); if (!sdev) return; if (sdev->scsi_dh_data) { ...
robutest/uclinux
C++
GPL-2.0
60
/* Finish up at the end of a Huffman-compressed scan. */
finish_pass_huff(j_compress_ptr cinfo)
/* Finish up at the end of a Huffman-compressed scan. */ finish_pass_huff(j_compress_ptr cinfo)
{ huff_entropy_ptr entropy = (huff_entropy_ptr)cinfo->entropy; working_state state; state.next_output_byte = cinfo->dest->next_output_byte; state.free_in_buffer = cinfo->dest->free_in_buffer; ASSIGN_STATE(state.cur, entropy->saved); state.cinfo = cinfo; if (!flush_bits(&state)) ERREX...
nanoframework/nf-interpreter
C++
MIT License
293
/* Calculate the RANGE value base on crystal frequency. To setup external crystal oscillator, must set the register bits RANGE base on the crystal frequency. This function returns the RANGE base on the input frequency. This is an internal function. */
static uint8_t CLOCK_GetOscRangeFromFreq(uint32_t freq)
/* Calculate the RANGE value base on crystal frequency. To setup external crystal oscillator, must set the register bits RANGE base on the crystal frequency. This function returns the RANGE base on the input frequency. This is an internal function. */ static uint8_t CLOCK_GetOscRangeFromFreq(uint32_t freq)
{ uint8_t range; if (freq <= 39063U) { range = 0U; } else if (freq <= 8000000U) { range = 1U; } else { range = 2U; } return range; }
labapart/polymcu
C++
null
201
/* Initialize the delay driver. This must be called during start up to initialize the delay routine with the current used main clock. It must run any time the main CPU clock is changed. */
void delay_init(void)
/* Initialize the delay driver. This must be called during start up to initialize the delay routine with the current used main clock. It must run any time the main CPU clock is changed. */ void delay_init(void)
{ cycles_per_ms = system_gclk_gen_get_hz(0); cycles_per_ms /= 1000; cycles_per_us = cycles_per_ms / 1000; SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk; }
memfault/zero-to-main
C++
null
200
/* Enables SIR (IrDA) mode on the specified UART. */
void UARTEnableSIR(unsigned long ulBase, tBoolean bLowPower)
/* Enables SIR (IrDA) mode on the specified UART. */ void UARTEnableSIR(unsigned long ulBase, tBoolean bLowPower)
{ ASSERT(UARTBaseValid(ulBase)); if(bLowPower) { HWREG(ulBase + UART_O_CTL) |= (UART_CTL_SIREN | UART_CTL_SIRLP); } else { HWREG(ulBase + UART_O_CTL) |= (UART_CTL_SIREN); } }
watterott/WebRadio
C++
null
71
/* Verifies programming of the desired flash area at a specified margin level. This function verifies the data programed in the flash memory using the Flash Program Check Command and compares it to the expected data for a given flash area as determined by the start address and length. */
status_t FLASH_VerifyProgram(flash_config_t *config, uint32_t start, uint32_t lengthInBytes, const uint8_t *expectedData, uint32_t *failedAddress, uint32_t *failedData)
/* Verifies programming of the desired flash area at a specified margin level. This function verifies the data programed in the flash memory using the Flash Program Check Command and compares it to the expected data for a given flash area as determined by the start address and length. */ status_t FLASH_VerifyProgram(...
{ if (get_rom_api_version() == 0u) { function_command_option_t runCmdFuncOption; runCmdFuncOption.commandAddr = 0x1300427dU; return runCmdFuncOption.verifyProgramCommand(config, start, lengthInBytes, expectedData, failedAddress, failed...
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* If the @read_pos is in the middle of padding, return the position of the first actually available byte, otherwise return the original value. */
static size_t relay_file_read_start_pos(size_t read_pos, struct rchan_buf *buf)
/* If the @read_pos is in the middle of padding, return the position of the first actually available byte, otherwise return the original value. */ static size_t relay_file_read_start_pos(size_t read_pos, struct rchan_buf *buf)
{ size_t read_subbuf, padding, padding_start, padding_end; size_t subbuf_size = buf->chan->subbuf_size; size_t n_subbufs = buf->chan->n_subbufs; size_t consumed = buf->subbufs_consumed % n_subbufs; if (!read_pos) read_pos = consumed * subbuf_size + buf->bytes_consumed; read_subbuf = read_pos / subbuf_size; pad...
EmcraftSystems/linux-emcraft
C++
Other
266
/* cdns3_set_register_bit - set bit in given register. @ptr: address of device controller register to be read and changed @mask: bits requested to set */
void cdns3_set_register_bit(void __iomem *ptr, u32 mask)
/* cdns3_set_register_bit - set bit in given register. @ptr: address of device controller register to be read and changed @mask: bits requested to set */ void cdns3_set_register_bit(void __iomem *ptr, u32 mask)
{ mask = readl(ptr) | mask; writel(mask, ptr); }
4ms/stm32mp1-baremetal
C++
Other
137
/* disk_name() is used by partition check code and the genhd driver. It formats the devicename of the indicated disk into the supplied buffer (of size at least 32), and returns a pointer to that same buffer (for convenience). */
char* disk_name(struct gendisk *hd, int partno, char *buf)
/* disk_name() is used by partition check code and the genhd driver. It formats the devicename of the indicated disk into the supplied buffer (of size at least 32), and returns a pointer to that same buffer (for convenience). */ char* disk_name(struct gendisk *hd, int partno, char *buf)
{ if (!partno) snprintf(buf, BDEVNAME_SIZE, "%s", hd->disk_name); else if (isdigit(hd->disk_name[strlen(hd->disk_name)-1])) snprintf(buf, BDEVNAME_SIZE, "%sp%d", hd->disk_name, partno); else snprintf(buf, BDEVNAME_SIZE, "%s%d", hd->disk_name, partno); return buf; }
robutest/uclinux
C++
GPL-2.0
60
/* Select the specified I2C NACK position in master receiver mode. */
void I2C_ConfigNACKPosition(I2C_T *i2c, I2C_NACK_POSITION_T NACKPosition)
/* Select the specified I2C NACK position in master receiver mode. */ void I2C_ConfigNACKPosition(I2C_T *i2c, I2C_NACK_POSITION_T NACKPosition)
{ if (NACKPosition == I2C_NACK_POSITION_NEXT) { i2c->CTRL1_B.ACKPOS = BIT_SET; } else { i2c->CTRL1_B.ACKPOS = BIT_RESET; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* ‘G XX...’ Writes the new values received into the input buffer to the general registers */
VOID EFIAPI WriteGeneralRegisters(IN EFI_SYSTEM_CONTEXT SystemContext, IN CHAR8 *InBuffer)
/* ‘G XX...’ Writes the new values received into the input buffer to the general registers */ VOID EFIAPI WriteGeneralRegisters(IN EFI_SYSTEM_CONTEXT SystemContext, IN CHAR8 *InBuffer)
{ UINTN i; CHAR8 *InBufPtr; if (AsciiStrLen (InBuffer) != 385) { SendError (GDB_EBADBUFSIZE); return; } InBufPtr = &InBuffer[1]; for (i = 0; i < MaxRegisterCount (); i++) { InBufPtr = BasicWriteRegister (SystemContext, i, InBufPtr); } SendSuccess (); }
tianocore/edk2
C++
Other
4,240
/* Sends a notification of Virtual COM Port statuses and line states. The function sends error and line status of the Virtual COM Port over the Interrupt endpoint. (SerialState notification is defined in usbcdc11.pdf, 6.3.5.) */
int32_t USBD_CDC_ACM_Notify(uint16_t stat)
/* Sends a notification of Virtual COM Port statuses and line states. The function sends error and line status of the Virtual COM Port over the Interrupt endpoint. (SerialState notification is defined in usbcdc11.pdf, 6.3.5.) */ int32_t USBD_CDC_ACM_Notify(uint16_t stat)
{ if (USBD_Configuration) { USBD_CDC_ACM_NotifyBuf[0] = 0xA1; USBD_CDC_ACM_NotifyBuf[1] = CDC_NOTIFICATION_SERIAL_STATE; USBD_CDC_ACM_NotifyBuf[2] = 0x00; USBD_CDC_ACM_NotifyBuf[3] = 0x00; USBD_CDC_ACM_NotifyBuf[4] = 0x00; USBD_CDC_ACM_NotifyBuf[5] = 0x00; USB...
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* This function retrieves the user readable name of a driver in the form of a Unicode string. If the driver specified by This has a user readable name in the language specified by Language, then a pointer to the driver name is returned in DriverName, and EFI_SUCCESS is returned. If the driver specified by This does no...
EFI_STATUS EFIAPI IsaBusComponentNameGetDriverName(IN EFI_COMPONENT_NAME_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
/* This function retrieves the user readable name of a driver in the form of a Unicode string. If the driver specified by This has a user readable name in the language specified by Language, then a pointer to the driver name is returned in DriverName, and EFI_SUCCESS is returned. If the driver specified by This does no...
{ return LookupUnicodeString2 ( Language, This->SupportedLanguages, mIsaBusDriverNameTable, DriverName, (BOOLEAN)(This == &gIsaBusComponentName) ); }
tianocore/edk2
C++
Other
4,240
/* handle program when an rx no empty interrupt flag arrived in non block mode */
static void __i2s_tx_recv_by_it(ald_i2s_handle_t *hperh)
/* handle program when an rx no empty interrupt flag arrived in non block mode */ static void __i2s_tx_recv_by_it(ald_i2s_handle_t *hperh)
{ if (hperh->tx_count != 0) { ald_i2s_clear_flag_status(hperh, ALD_I2S_IF_TXE); hperh->perh->DATA = 0xffff; --hperh->tx_count; if (hperh->tx_count == 0) ald_i2s_interrupt_config(hperh, ALD_I2S_IT_TXE, DISABLE); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* If successful, this function returns the number of SG elements. Otherwise, it returnes -1. */
static int megasas_make_sgl_skinny(struct megasas_instance *instance, struct scsi_cmnd *scp, union megasas_sgl *mfi_sgl)
/* If successful, this function returns the number of SG elements. Otherwise, it returnes -1. */ static int megasas_make_sgl_skinny(struct megasas_instance *instance, struct scsi_cmnd *scp, union megasas_sgl *mfi_sgl)
{ int i; int sge_count; struct scatterlist *os_sgl; sge_count = scsi_dma_map(scp); if (sge_count) { scsi_for_each_sg(scp, os_sgl, sge_count, i) { mfi_sgl->sge_skinny[i].length = sg_dma_len(os_sgl); mfi_sgl->sge_skinny[i].phys_addr = sg_dma_address(os_sgl); } } return sge_count; }
robutest/uclinux
C++
GPL-2.0
60
/* Allocates fc_frame structure and buffer but if fails to allocate then reduce can_queue. */
static struct fc_frame* fc_fcp_frame_alloc(struct fc_lport *lport, size_t len)
/* Allocates fc_frame structure and buffer but if fails to allocate then reduce can_queue. */ static struct fc_frame* fc_fcp_frame_alloc(struct fc_lport *lport, size_t len)
{ struct fc_frame *fp; unsigned long flags; fp = fc_frame_alloc(lport, len); if (likely(fp)) return fp; spin_lock_irqsave(lport->host->host_lock, flags); fc_fcp_can_queue_ramp_down(lport); spin_unlock_irqrestore(lport->host->host_lock, flags); return NULL; }
robutest/uclinux
C++
GPL-2.0
60
/* this function only sleeps if the free_fn() function sleeps. */
void mempool_free(void *element, mempool_t *pool)
/* this function only sleeps if the free_fn() function sleeps. */ void mempool_free(void *element, mempool_t *pool)
{ unsigned long flags; if (unlikely(element == NULL)) return; smp_mb(); if (pool->curr_nr < pool->min_nr) { spin_lock_irqsave(&pool->lock, flags); if (pool->curr_nr < pool->min_nr) { add_element(pool, element); spin_unlock_irqrestore(&pool->lock, flags); wake_up(&pool->wait); return; } spin_un...
robutest/uclinux
C++
GPL-2.0
60
/* Enable fault detect deglitch function of selected channel. */
void EPWM_EnableFaultDetectDeglitch(EPWM_T *epwm, uint32_t u32ChannelNum, uint32_t u32DeglitchSmpCycle)
/* Enable fault detect deglitch function of selected channel. */ void EPWM_EnableFaultDetectDeglitch(EPWM_T *epwm, uint32_t u32ChannelNum, uint32_t u32DeglitchSmpCycle)
{ (epwm)->FDCTL[(u32ChannelNum)] = ((epwm)->FDCTL[(u32ChannelNum)] & (~EPWM_FDCTL0_DGSMPCYC_Msk)) | \ (EPWM_FDCTL0_FDDGEN_Msk | ((u32DeglitchSmpCycle) << EPWM_FDCTL0_DGSMPCYC_Pos)); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Waits to send a character from the specified port. */
void UARTCharPut(uint32_t ui32Base, unsigned char ucData)
/* Waits to send a character from the specified port. */ void UARTCharPut(uint32_t ui32Base, unsigned char ucData)
{ ASSERT(_UARTBaseValid(ui32Base)); while(HWREG(ui32Base + UART_O_FR) & UART_FR_TXFF) { } HWREG(ui32Base + UART_O_DR) = ucData; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* I2C master restart after all bytes are sent. */
void i2c_send_restart(I2C_TypeDef *I2Cx, u8 *pBuf, u8 len, u8 restart)
/* I2C master restart after all bytes are sent. */ void i2c_send_restart(I2C_TypeDef *I2Cx, u8 *pBuf, u8 len, u8 restart)
{ u8 cnt = 0; assert_param(IS_I2C_ALL_PERIPH(I2Cx)); for(cnt = 0; cnt < len; cnt++) { while((I2C_CheckFlagState(I2Cx, BIT_IC_STATUS_TFNF)) == 0); if(cnt >= len - 1) { I2Cx->IC_DATA_CMD = (*pBuf++) | (restart << 10); } else { I2Cx->IC_DATA_CMD = (*pBuf++); } } while((I2C_CheckFlagState(I2Cx, BI...
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Handle bus service to send a message. Note: We do not allow the device to change the data direction! */
static void fas216_send_messageout(FAS216_Info *info, int start)
/* Handle bus service to send a message. Note: We do not allow the device to change the data direction! */ static void fas216_send_messageout(FAS216_Info *info, int start)
{ unsigned int tot_msglen = msgqueue_msglength(&info->scsi.msgs); fas216_checkmagic(info); fas216_cmd(info, CMD_FLUSHFIFO); if (tot_msglen) { struct message *msg; int msgnr = 0; while ((msg = msgqueue_getmsg(&info->scsi.msgs, msgnr++)) != NULL) { int i; for (i = start; i < msg->length; i++) fas216_w...
robutest/uclinux
C++
GPL-2.0
60
/* w_send_read_req() - Worker callback to send a read request (P_DATA_REQUEST) packet @mdev: DRBD device. @w: work object. @cancel: The connection will be closed anyways */
int w_send_read_req(struct drbd_conf *mdev, struct drbd_work *w, int cancel)
/* w_send_read_req() - Worker callback to send a read request (P_DATA_REQUEST) packet @mdev: DRBD device. @w: work object. @cancel: The connection will be closed anyways */ int w_send_read_req(struct drbd_conf *mdev, struct drbd_work *w, int cancel)
{ struct drbd_request *req = container_of(w, struct drbd_request, w); int ok; if (unlikely(cancel)) { req_mod(req, send_canceled); return 1; } ok = drbd_send_drequest(mdev, P_DATA_REQUEST, req->sector, req->size, (unsigned long)req); if (!ok) { if (mdev->state.conn >= C_CONNECTED) drbd_force_state(md...
robutest/uclinux
C++
GPL-2.0
60
/* serio_disconnect_port() unbinds a port from its driver. As a side effect all child ports are unbound and destroyed. */
static void serio_disconnect_port(struct serio *serio)
/* serio_disconnect_port() unbinds a port from its driver. As a side effect all child ports are unbound and destroyed. */ static void serio_disconnect_port(struct serio *serio)
{ struct serio *s, *parent; if (serio->child) { for (s = serio; s->child; s = s->child); do { parent = s->parent; device_release_driver(&s->dev); serio_destroy_port(s); } while ((s = parent) != serio); } device_release_driver(&serio->dev); }
robutest/uclinux
C++
GPL-2.0
60
/* A generic sense dump / resolve mechanism should be implemented across all ATAPI + SCSI devices. */
static void pkt_dump_sense(struct packet_command *cgc)
/* A generic sense dump / resolve mechanism should be implemented across all ATAPI + SCSI devices. */ static void pkt_dump_sense(struct packet_command *cgc)
{ static char *info[9] = { "No sense", "Recovered error", "Not ready", "Medium error", "Hardware error", "Illegal request", "Unit attention", "Data protect", "Blank check" }; int i; struct request_sense *sense = cgc->sense; printk(DRIVER_NAME":"); for (i = 0; i < CDROM_PACKET_SIZE; i++) printk(" %02x",...
robutest/uclinux
C++
GPL-2.0
60
/* Thus function used to acknowledge timer interrupt event, use it inside the interrupt handler. */
void gtm_ack_timer16(struct gtm_timer *tmr, u16 events)
/* Thus function used to acknowledge timer interrupt event, use it inside the interrupt handler. */ void gtm_ack_timer16(struct gtm_timer *tmr, u16 events)
{ out_be16(tmr->gtevr, events); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* if (_PRW at S-state x) choose from highest power _SxD to lowest power _SxW else // no _PRW at S-state x choose highest power _SxD or any lower power */
static pci_power_t acpi_pci_choose_state(struct pci_dev *pdev)
/* if (_PRW at S-state x) choose from highest power _SxD to lowest power _SxW else // no _PRW at S-state x choose highest power _SxD or any lower power */ static pci_power_t acpi_pci_choose_state(struct pci_dev *pdev)
{ int acpi_state; acpi_state = acpi_pm_device_sleep_state(&pdev->dev, NULL); if (acpi_state < 0) return PCI_POWER_ERROR; switch (acpi_state) { case ACPI_STATE_D0: return PCI_D0; case ACPI_STATE_D1: return PCI_D1; case ACPI_STATE_D2: return PCI_D2; case ACPI_STATE_D3: return PCI_D3hot; } return PCI_P...
robutest/uclinux
C++
GPL-2.0
60
/* Reads and returns the current value of MM3. This function is only available on IA-32 and X64. */
UINT64 EFIAPI AsmReadMm3(VOID)
/* Reads and returns the current value of MM3. This function is only available on IA-32 and X64. */ UINT64 EFIAPI AsmReadMm3(VOID)
{ UINT64 Data; __asm__ __volatile__ ( "movd %%mm3, %0 \n\t" : "=r" (Data) ); return Data; }
tianocore/edk2
C++
Other
4,240
/* Saturate the output signal to signed 16bit integers. */
static void saturate_output_float(COOKContext *q, int chan, int16_t *out)
/* Saturate the output signal to signed 16bit integers. */ static void saturate_output_float(COOKContext *q, int chan, int16_t *out)
{ int j; float *output = q->mono_mdct_output + q->samples_per_channel; for (j = 0; j < q->samples_per_channel; j++) { out[chan + q->nb_channels * j] = av_clip_int16(lrintf(output[j])); } }
DC-SWAT/DreamShell
C++
null
404
/* It returns 0 if the packet was acknowledge, -1 otherwise. */
static int gdb_send_packet(const uint8_t *data, size_t len)
/* It returns 0 if the packet was acknowledge, -1 otherwise. */ static int gdb_send_packet(const uint8_t *data, size_t len)
{ uint8_t buf[2]; uint8_t checksum = 0; z_gdb_putchar('$'); while (len-- > 0) { checksum += *data; z_gdb_putchar(*data++); } z_gdb_putchar('#'); if (gdb_bin2hex(&checksum, 1, buf, sizeof(buf)) == 0) { return -1; } z_gdb_putchar(buf[0]); z_gdb_putchar(buf[1]); if (z_gdb_getchar() == '+') { return 0; ...
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* The software interrupt instruction (SWI) is used for entering Supervisor mode, usually to request a particular supervisor function. */
void rt_hw_trap_swi(struct rt_hw_register *regs)
/* The software interrupt instruction (SWI) is used for entering Supervisor mode, usually to request a particular supervisor function. */ void rt_hw_trap_swi(struct rt_hw_register *regs)
{ rt_hw_show_register(regs); rt_kprintf("software interrupt\n"); rt_hw_cpu_shutdown(); }
armink/FreeModbus_Slave-Master-RTT-STM32
C++
Other
1,477
/* igb_clean_tx_ring - Free Tx Buffers @tx_ring: ring to be cleaned */
static void igb_clean_tx_ring(struct igb_ring *)
/* igb_clean_tx_ring - Free Tx Buffers @tx_ring: ring to be cleaned */ static void igb_clean_tx_ring(struct igb_ring *)
{ struct igb_buffer *buffer_info; unsigned long size; unsigned int i; if (!tx_ring->buffer_info) return; for (i = 0; i < tx_ring->count; i++) { buffer_info = &tx_ring->buffer_info[i]; igb_unmap_and_free_tx_resource(tx_ring, buffer_info); } size = sizeof(struct igb_buffer) * tx_ring->count; memset(tx_ring-...
robutest/uclinux
C++
GPL-2.0
60
/* shm_lock_(check_) routines are called in the paths where the rw_mutex is not necessarily held. */
static struct shmid_kernel* shm_lock(struct ipc_namespace *ns, int id)
/* shm_lock_(check_) routines are called in the paths where the rw_mutex is not necessarily held. */ static struct shmid_kernel* shm_lock(struct ipc_namespace *ns, int id)
{ struct kern_ipc_perm *ipcp = ipc_lock(&shm_ids(ns), id); if (IS_ERR(ipcp)) return (struct shmid_kernel *)ipcp; return container_of(ipcp, struct shmid_kernel, shm_perm); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Return Value: TRUE if short slot time; otherwise FALSE */
BOOL CARDbIsShorSlotTime(PVOID pDeviceHandler)
/* Return Value: TRUE if short slot time; otherwise FALSE */ BOOL CARDbIsShorSlotTime(PVOID pDeviceHandler)
{ PSDevice pDevice = (PSDevice) pDeviceHandler; return(pDevice->bShortSlotTime); }
robutest/uclinux
C++
GPL-2.0
60
/* Try to do the real allocation with a given size */
static void * ent_alloc(lv_mem_ent_t *e, uint32_t size)
/* Try to do the real allocation with a given size */ static void * ent_alloc(lv_mem_ent_t *e, uint32_t size)
{ void * alloc = NULL; if(e->header.used == 0 && e->header.d_size >= size) { ent_trunc(e, size), e->header.used = 1; alloc = &e->first_data; } return alloc; }
RavenSystem/esp-homekit-devices
C++
Other
2,577
/* The user Entry Point for module UfsPassThru. The user code starts with this function. */
EFI_STATUS EFIAPI InitializeUfsPassThru(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
/* The user Entry Point for module UfsPassThru. The user code starts with this function. */ EFI_STATUS EFIAPI InitializeUfsPassThru(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
{ EFI_STATUS Status; Status = EfiLibInstallDriverBindingComponentName2 ( ImageHandle, SystemTable, &gUfsPassThruDriverBinding, ImageHandle, &gUfsPassThruComponentName, &gUfsPassThruComponentName2 ); ASSERT_EFI_ERROR (Statu...
tianocore/edk2
C++
Other
4,240
/* Initialize system timer driver. Enable the hw timer, setting its tick period, and setup its interrupt */
static int sys_clock_driver_init(void)
/* Initialize system timer driver. Enable the hw timer, setting its tick period, and setup its interrupt */ static int sys_clock_driver_init(void)
{ tick_period = 1000000ul / CONFIG_SYS_CLOCK_TICKS_PER_SEC; last_tick_time = hwm_get_time(); hwtimer_enable(tick_period); IRQ_CONNECT(TIMER_TICK_IRQ, 1, np_timer_isr, 0, 0); irq_enable(TIMER_TICK_IRQ); return 0; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Returns: (transfer full): a #GFile. Free the returned object with g_object_unref(). */
GFile* g_vfs_get_file_for_uri(GVfs *vfs, const char *uri)
/* Returns: (transfer full): a #GFile. Free the returned object with g_object_unref(). */ GFile* g_vfs_get_file_for_uri(GVfs *vfs, const char *uri)
{ GVfsClass *class; g_return_val_if_fail (G_IS_VFS (vfs), NULL); g_return_val_if_fail (uri != NULL, NULL); class = G_VFS_GET_CLASS (vfs); if (g_str_has_prefix (uri, "resource:")) return _g_resource_file_new (uri); return (* class->get_file_for_uri) (vfs, uri); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* em28xx_v4l2_poll() will allocate buffers when called for the first time */
static unsigned int em28xx_v4l2_poll(struct file *filp, poll_table *wait)
/* em28xx_v4l2_poll() will allocate buffers when called for the first time */ static unsigned int em28xx_v4l2_poll(struct file *filp, poll_table *wait)
{ struct em28xx_fh *fh = filp->private_data; struct em28xx *dev = fh->dev; int rc; rc = check_dev(dev); if (rc < 0) return rc; if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { if (!res_get(fh, EM28XX_RESOURCE_VIDEO)) return POLLERR; return videobuf_poll_stream(filp, &fh->vb_vidq, wait); } else if (fh->typ...
robutest/uclinux
C++
GPL-2.0
60
/* If all files have the same frame type, then use that. Otherwise select WTAP_ENCAP_PER_PACKET. If the selected output file type doesn't support per packet frame types, then the wtap_dump_open call will fail with a reasonable error condition. */
static int merge_select_frame_type(int in_file_count, merge_in_file_t in_files[])
/* If all files have the same frame type, then use that. Otherwise select WTAP_ENCAP_PER_PACKET. If the selected output file type doesn't support per packet frame types, then the wtap_dump_open call will fail with a reasonable error condition. */ static int merge_select_frame_type(int in_file_count, merge_in_file_t in_...
{ int i; int selected_frame_type; selected_frame_type = wtap_file_encap(in_files[0].wth); for (i = 1; i < in_file_count; i++) { int this_frame_type = wtap_file_encap(in_files[i].wth); if (selected_frame_type != this_frame_type) { selected_frame_type = WTAP_ENCAP_PER_PACKET; ...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Internal trigger function to start acquisition on AO subdevice. */
static int pci224_ao_inttrig_start(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int trignum)
/* Internal trigger function to start acquisition on AO subdevice. */ static int pci224_ao_inttrig_start(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int trignum)
{ if (trignum != 0) return -EINVAL; s->async->inttrig = NULLFUNC; pci224_ao_start(dev, s); return 1; }
robutest/uclinux
C++
GPL-2.0
60
/* Read and write a data element from and to the SPI interface. */
unsigned long xSPISingleDataReadWrite(unsigned long ulBase, unsigned long ulWData)
/* Read and write a data element from and to the SPI interface. */ unsigned long xSPISingleDataReadWrite(unsigned long ulBase, unsigned long ulWData)
{ return SPISingleDataReadWrite(ulBase, ulWData); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* USB_OTG_WritePacket : Writes a packet into the Tx FIFO associated with the EP. */
USB_OTG_STS USB_OTG_WritePacket(USB_OTG_CORE_HANDLE *pdev, uint8_t *src, uint8_t ch_ep_num, uint16_t len)
/* USB_OTG_WritePacket : Writes a packet into the Tx FIFO associated with the EP. */ USB_OTG_STS USB_OTG_WritePacket(USB_OTG_CORE_HANDLE *pdev, uint8_t *src, uint8_t ch_ep_num, uint16_t len)
{ USB_OTG_STS status = USB_OTG_OK; if (pdev->cfg.dma_enable == 0) { uint32_t count32b= 0 , i= 0; __IO uint32_t *fifo; count32b = (len + 3) / 4; fifo = pdev->regs.DFIFO[ch_ep_num]; for (i = 0; i < count32b; i++, src+=4) { USB_OTG_WRITE_REG32( fifo, *((__packed uint32_t *)src) ); ...
MaJerle/stm32f429
C++
null
2,036
/* Return: 0 if all went ok, else return appropriate error */
static int k3_dsp_start(struct udevice *dev)
/* Return: 0 if all went ok, else return appropriate error */ static int k3_dsp_start(struct udevice *dev)
{ struct k3_dsp_privdata *dsp = dev_get_priv(dev); int ret; dev_dbg(dev, "%s\n", __func__); ret = ti_sci_proc_request(&dsp->tsp); if (ret) return ret; ret = ti_sci_proc_power_domain_on(&dsp->tsp); if (ret) goto proc_release; ret = reset_deassert(&dsp->dsp_rst); proc_release: ti_sci_proc_release(&dsp->tsp);...
4ms/stm32mp1-baremetal
C++
Other
137
/* Configs the SDIO Dataaccording to the specified parameters in the dataConfig. */
void SDIO_ConfigData(SDIO_DataConfig_T *dataConfig)
/* Configs the SDIO Dataaccording to the specified parameters in the dataConfig. */ void SDIO_ConfigData(SDIO_DataConfig_T *dataConfig)
{ uint32_t tmpreg = 0; SDIO->DATATIME = dataConfig->dataTimeOut; SDIO->DATALEN = dataConfig->dataLength; tmpreg = SDIO->DCTRL; tmpreg &= 0xFFFFFF08; tmpreg |= (uint32_t)dataConfig->dataBlockSize | dataConfig->transferDir | dataConfig->transferMode | dataConfig->DPSM; SDIO->DCTRL =...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* For a given base CRL find a delta... maybe extend to delta scoring or retrieve a chain of deltas... */
static void get_delta_sk(X509_STORE_CTX *ctx, X509_CRL **dcrl, int *pcrl_score, X509_CRL *base, STACK_OF(X509_CRL) *crls)
/* For a given base CRL find a delta... maybe extend to delta scoring or retrieve a chain of deltas... */ static void get_delta_sk(X509_STORE_CTX *ctx, X509_CRL **dcrl, int *pcrl_score, X509_CRL *base, STACK_OF(X509_CRL) *crls)
{ X509_CRL *delta; size_t i; if (!(ctx->param->flags & X509_V_FLAG_USE_DELTAS)) return; if (!((ctx->current_cert->ex_flags | base->flags) & EXFLAG_FRESHEST)) return; for (i = 0; i < sk_X509_CRL_num(crls); i++) { delta = sk_X509_CRL_value(crls, i); if (check_delta_base...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Function called while waiting for connectivity chip response. It handles incoming events. */
static void ser_sd_rsp_wait(void)
/* Function called while waiting for connectivity chip response. It handles incoming events. */ static void ser_sd_rsp_wait(void)
{ do { (void)sd_app_evt_wait(); } while (ser_sd_transport_is_busy()); }
labapart/polymcu
C++
null
201