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
/* USART pinmux initialization function. Set each required pin to USART functionality */
void TARGET_IO_PORT_init()
/* USART pinmux initialization function. Set each required pin to USART functionality */ void TARGET_IO_PORT_init()
{ gpio_set_pin_function(PB25, PINMUX_PB25D_SERCOM2_PAD0); gpio_set_pin_function(PB24, PINMUX_PB24D_SERCOM2_PAD1); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Configure PTRO register, The CRYPT engine will write calculation result into this address. */
void CRYPT_AddressOConfig(uint16_t AddrO)
/* Configure PTRO register, The CRYPT engine will write calculation result into this address. */ void CRYPT_AddressOConfig(uint16_t AddrO)
{ assert_parameters(IS_CRYPT_ADDR(AddrO)); CRYPT->PTRO = AddrO & CRYPT_PTRO_PTRO; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* I2C NACK Next Byte. Causes the I2C controller to NACK the reception of the current byte */
void i2c_nack_current(uint32_t i2c)
/* I2C NACK Next Byte. Causes the I2C controller to NACK the reception of the current byte */ void i2c_nack_current(uint32_t i2c)
{ I2C_CR1(i2c) &= ~I2C_CR1_POS; }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* Functions and macros which are different for UP/SMP systems are kept in a single place */
static struct hrtimer_clock_base* lock_hrtimer_base(const struct hrtimer *timer, unsigned long *flags)
/* Functions and macros which are different for UP/SMP systems are kept in a single place */ static struct hrtimer_clock_base* lock_hrtimer_base(const struct hrtimer *timer, unsigned long *flags)
{ struct hrtimer_clock_base *base = timer->base; raw_spin_lock_irqsave(&base->cpu_base->lock, *flags); return base; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Report additional information for an error in command-line arguments. */
static void rawshark_cmdarg_err_cont(const char *fmt, va_list ap)
/* Report additional information for an error in command-line arguments. */ static void rawshark_cmdarg_err_cont(const char *fmt, va_list ap)
{ vfprintf(stderr, fmt, ap); fprintf(stderr, "\n"); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Set the platform secure boot mode into "Custom" or "Standard" mode. */
EFI_STATUS EFIAPI SetSecureBootMode(IN UINT8 SecureBootMode)
/* Set the platform secure boot mode into "Custom" or "Standard" mode. */ EFI_STATUS EFIAPI SetSecureBootMode(IN UINT8 SecureBootMode)
{ return gRT->SetVariable ( EFI_CUSTOM_MODE_NAME, &gEfiCustomModeEnableGuid, EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, sizeof (UINT8), &SecureBootMode ); }
tianocore/edk2
C++
Other
4,240
/* Wait for all root PCI Hot Plug controller finished initializing. */
EFI_STATUS AllRootHPCInitialized(IN UINTN TimeoutInMicroSeconds)
/* Wait for all root PCI Hot Plug controller finished initializing. */ EFI_STATUS AllRootHPCInitialized(IN UINTN TimeoutInMicroSeconds)
{ UINT32 Delay; UINTN Index; Delay = (UINT32)((TimeoutInMicroSeconds / 30) + 1); do { for (Index = 0; Index < gPciRootHpcCount; Index++) { if (gPciRootHpcData[Index].Found && !gPciRootHpcData[Index].Initialized) { break; } } if (Index == gPciRootHpcCount) { return EFI_SUCCESS; } gBS->Stall (30); Delay--; } while (Delay > 0); return EFI_TIMEOUT; }
tianocore/edk2
C++
Other
4,240
/* This function is used to set voltage to 1.8V. */
s32 XSdPs_SetVoltage18(XSdPs *InstancePtr)
/* This function is used to set voltage to 1.8V. */ s32 XSdPs_SetVoltage18(XSdPs *InstancePtr)
{ s32 Status; u16 CtrlReg; CtrlReg = XSdPs_ReadReg16(InstancePtr->Config.BaseAddress, XSDPS_HOST_CTRL2_OFFSET); CtrlReg |= XSDPS_HC2_1V8_EN_MASK; XSdPs_WriteReg16(InstancePtr->Config.BaseAddress, XSDPS_HOST_CTRL2_OFFSET, CtrlReg); (void)usleep(5000U); Status = XSdPs_CheckVoltage18(InstancePtr); if (Status != XST_SUCCESS) { Status = XST_FAILURE; } return Status; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Enable the gpio pins and set default state. */
int32_t init_gpio(void)
/* Enable the gpio pins and set default state. */ int32_t init_gpio(void)
{ int32_t ret = 0; ret = adi_gpio_Init(gpioMemory, ADI_GPIO_MEMORY_SIZE); ret |= adi_gpio_InputEnable(INTACC_PORT, INTACC_PIN, true); ret |= adi_gpio_SetGroupInterruptPins(INTACC_PORT, SYS_GPIO_INTA_IRQn, INTACC_PIN); ret |= adi_gpio_RegisterCallback (SYS_GPIO_INTA_IRQn, pinIntCallback, NULL ); ret |= adi_gpio_OutputEnable(DS3_PORT, DS3_PIN, true); ret |= adi_gpio_SetLow(DS3_PORT, DS3_PIN); ret |= adi_gpio_OutputEnable(DS4_PORT, DS4_PIN, true); ret |= adi_gpio_SetLow(DS4_PORT, DS4_PIN); return ret; }
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* Calculate the prefix length of the IPv4 subnet mask. */
UINT8 IScsiGetSubnetMaskPrefixLength(IN EFI_IPv4_ADDRESS *SubnetMask)
/* Calculate the prefix length of the IPv4 subnet mask. */ UINT8 IScsiGetSubnetMaskPrefixLength(IN EFI_IPv4_ADDRESS *SubnetMask)
{ UINT8 Len; UINT32 ReverseMask; ReverseMask = (SubnetMask->Addr[0] << 24) | (SubnetMask->Addr[1] << 16) | (SubnetMask->Addr[2] << 8) | (SubnetMask->Addr[3]); ReverseMask = ~ReverseMask; if ((ReverseMask & (ReverseMask + 1)) != 0) { return 0; } Len = 0; while (ReverseMask != 0) { ReverseMask = ReverseMask >> 1; Len++; } return (UINT8)(32 - Len); }
tianocore/edk2
C++
Other
4,240
/* Disable Peripheral Clock in running mode. Disable the clock on particular peripheral. */
void cmu_periph_clock_disable(enum cmu_periph_clken clken)
/* Disable Peripheral Clock in running mode. Disable the clock on particular peripheral. */ void cmu_periph_clock_disable(enum cmu_periph_clken clken)
{ _CMU_REG(clken) &= ~_CMU_BIT(clken); }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* Create the variable to save the base address of page table and stack for transferring into long mode in IA32 capsule PEI. */
VOID SaveLongModeContext(VOID)
/* Create the variable to save the base address of page table and stack for transferring into long mode in IA32 capsule PEI. */ VOID SaveLongModeContext(VOID)
{ if ((FeaturePcdGet (PcdSupportUpdateCapsuleReset)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode))) { PrepareContextForCapsulePei (); } }
tianocore/edk2
C++
Other
4,240
/* configure the delay between 2 sampling phases in ADC sync modes */
void adc_sync_delay_config(uint32_t sample_delay)
/* configure the delay between 2 sampling phases in ADC sync modes */ void adc_sync_delay_config(uint32_t sample_delay)
{ ADC_SYNCCTL &= ~(ADC_SYNCCTL_SYNCDLY); ADC_SYNCCTL |= sample_delay; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Signal event for every protocol in protocol entry. */
VOID MmNotifyProtocol(IN PROTOCOL_INTERFACE *Prot)
/* Signal event for every protocol in protocol entry. */ VOID MmNotifyProtocol(IN PROTOCOL_INTERFACE *Prot)
{ PROTOCOL_ENTRY *ProtEntry; PROTOCOL_NOTIFY *ProtNotify; LIST_ENTRY *Link; ProtEntry = Prot->Protocol; for (Link = ProtEntry->Notify.ForwardLink; Link != &ProtEntry->Notify; Link = Link->ForwardLink) { ProtNotify = CR (Link, PROTOCOL_NOTIFY, Link, PROTOCOL_NOTIFY_SIGNATURE); ProtNotify->Function (&ProtEntry->ProtocolID, Prot->Interface, Prot->Handle); } }
tianocore/edk2
C++
Other
4,240
/* USB Device Suspend Function Called automatically on USB Device Suspend Return Value: None */
void USBD_Suspend(void)
/* USB Device Suspend Function Called automatically on USB Device Suspend Return Value: None */ void USBD_Suspend(void)
{ UDPHS->UDPHS_IEN &= ~UDPHS_IEN_DET_SUSPD; UDPHS->UDPHS_IEN |= UDPHS_IEN_WAKE_UP; }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* Terminates the critical section module. Should be called once critical sections are no longer needed. Typically called from another module's termination function that also initialized it. It is okay to call this termination multiple times from different modules. */
void UtilCriticalSectionTerminate(void)
/* Terminates the critical section module. Should be called once critical sections are no longer needed. Typically called from another module's termination function that also initialized it. It is okay to call this termination multiple times from different modules. */ void UtilCriticalSectionTerminate(void)
{ if (criticalSectionInitialized) { criticalSectionInitialized = false; DeleteCriticalSection((CRITICAL_SECTION *)&criticalSection); } }
feaser/openblt
C++
GNU General Public License v3.0
601
/* hw_params callback: allocate the buffer and build up the buffer description table */
static int snd_via82xx_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params)
/* hw_params callback: allocate the buffer and build up the buffer description table */ static int snd_via82xx_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params)
{ struct via82xx_modem *chip = snd_pcm_substream_chip(substream); struct viadev *viadev = substream->runtime->private_data; int err; err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); if (err < 0) return err; err = build_via_table(viadev, substream, chip->pci, params_periods(hw_params), params_period_bytes(hw_params)); if (err < 0) return err; snd_ac97_write(chip->ac97, AC97_LINE1_RATE, params_rate(hw_params)); snd_ac97_write(chip->ac97, AC97_LINE1_LEVEL, 0); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Event handler for the library USB Control Request reception event. */
void EVENT_USB_Device_ControlRequest(void)
/* Event handler for the library USB Control Request reception event. */ void EVENT_USB_Device_ControlRequest(void)
{ CheckIfMSCompatibilityDescriptorRequest(); RNDIS_Device_ProcessControlRequest(&Ethernet_RNDIS_Interface); }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* @wm831x: Device to read from. @reg: Register to read. */
int wm831x_reg_read(struct wm831x *wm831x, unsigned short reg)
/* @wm831x: Device to read from. @reg: Register to read. */ int wm831x_reg_read(struct wm831x *wm831x, unsigned short reg)
{ unsigned short val; int ret; mutex_lock(&wm831x->io_lock); ret = wm831x_read(wm831x, reg, 2, &val); mutex_unlock(&wm831x->io_lock); if (ret < 0) return ret; else return val; }
robutest/uclinux
C++
GPL-2.0
60
/* This function is called to increment a global variable "u32TickCount". */
__WEAKDEF void SysTick_IncTick(void)
/* This function is called to increment a global variable "u32TickCount". */ __WEAKDEF void SysTick_IncTick(void)
{ m_u32TickCount += m_u32TickStep; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* If Guid is NULL, then ASSERT(). If Data is NULL and DataLength > 0, then ASSERT(). If there is no additional space for HOB creation, then ASSERT(). If DataLength > (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT(). HobLength is UINT16 and multiples of 8 bytes, so the max HobLength is 0xFFF8. */
VOID* EFIAPI BuildGuidDataHob(IN CONST EFI_GUID *Guid, IN VOID *Data, IN UINTN DataLength)
/* If Guid is NULL, then ASSERT(). If Data is NULL and DataLength > 0, then ASSERT(). If there is no additional space for HOB creation, then ASSERT(). If DataLength > (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT(). HobLength is UINT16 and multiples of 8 bytes, so the max HobLength is 0xFFF8. */ VOID* EFIAPI BuildGuidDataHob(IN CONST EFI_GUID *Guid, IN VOID *Data, IN UINTN DataLength)
{ VOID *HobData; ASSERT (Data != NULL || DataLength == 0); HobData = BuildGuidHob (Guid, DataLength); if (HobData == NULL) { return HobData; } return CopyMem (HobData, Data, DataLength); }
tianocore/edk2
C++
Other
4,240
/* Since both peers must reset the dictionary at the same time even in the absence of CLEAR codes (while packets are incompressible), they must compute the same ratio. */
static int bsd_check(struct bsd_db *db)
/* Since both peers must reset the dictionary at the same time even in the absence of CLEAR codes (while packets are incompressible), they must compute the same ratio. */ static int bsd_check(struct bsd_db *db)
{ unsigned int new_ratio; if (db->in_count >= db->checkpoint) { if (db->in_count >= RATIO_MAX || db->bytes_out >= RATIO_MAX) { db->in_count -= (db->in_count >> 2); db->bytes_out -= (db->bytes_out >> 2); } db->checkpoint = db->in_count + CHECK_GAP; if (db->max_ent >= db->maxmaxcode) { new_ratio = db->in_count << RATIO_SCALE_LOG; if (db->bytes_out != 0) { new_ratio /= db->bytes_out; } if (new_ratio < db->ratio || new_ratio < 1 * RATIO_SCALE) { bsd_clear (db); return 1; } db->ratio = new_ratio; } } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* TIM_Base MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim_base)
/* TIM_Base MSP De-Initialization This function freeze the hardware resources used in this example. */ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim_base)
{ if(htim_base->Instance==TIM2) { __HAL_RCC_TIM2_CLK_DISABLE(); } else if(htim_base->Instance==TIM14) { __HAL_RCC_TIM14_CLK_DISABLE(); } else if(htim_base->Instance==TIM16) { __HAL_RCC_TIM16_CLK_DISABLE(); } else if(htim_base->Instance==TIM17) { __HAL_RCC_TIM17_CLK_DISABLE(); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Get the word count of the specified Metadata key length. */
uint32_t KS_GetKeyWordCnt(uint32_t u32Meta)
/* Get the word count of the specified Metadata key length. */ uint32_t KS_GetKeyWordCnt(uint32_t u32Meta)
{ const uint16_t au8CntTbl[21] = { 4, 6, 6, 7, 8, 8, 8, 9, 12, 13, 16, 17, 18, 0, 0, 0, 32, 48, 64, 96, 128 }; return au8CntTbl[((u32Meta & KS_METADATA_SIZE_Msk) >> KS_METADATA_SIZE_Pos)]; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns the address of the requested capability structure within the device's PCI configuration space or 0 in case the device does not support it. */
int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap)
/* Returns the address of the requested capability structure within the device's PCI configuration space or 0 in case the device does not support it. */ int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap)
{ int pos; u8 hdr_type; pci_bus_read_config_byte(bus, devfn, PCI_HEADER_TYPE, &hdr_type); pos = __pci_bus_find_cap_start(bus, devfn, hdr_type & 0x7f); if (pos) pos = __pci_find_next_cap(bus, devfn, pos, cap); return pos; }
robutest/uclinux
C++
GPL-2.0
60
/* return an image reference index based upon image address. */
UINT32 AddressToImageRef(IN UINTN Address)
/* return an image reference index based upon image address. */ UINT32 AddressToImageRef(IN UINTN Address)
{ IMAGE_STRUCT *ImageStruct; ImageStruct = AddressToImageStruct (Address); if (ImageStruct != NULL) { return ImageStruct->ImageRef; } return (UINT32)-1; }
tianocore/edk2
C++
Other
4,240
/* Read one bit phy data from PHY controller */
static u16 phy_read_1bit(unsigned long)
/* Read one bit phy data from PHY controller */ static u16 phy_read_1bit(unsigned long)
{ u16 phy_data; outl(0x50000, ioaddr); udelay(1); phy_data = ( inl(ioaddr) >> 19 ) & 0x1; outl(0x40000, ioaddr); udelay(1); return phy_data; }
robutest/uclinux
C++
GPL-2.0
60
/* return timer owned by the process, used by exit_itimers */
static void itimer_delete(struct k_itimer *timer)
/* return timer owned by the process, used by exit_itimers */ static void itimer_delete(struct k_itimer *timer)
{ unsigned long flags; retry_delete: spin_lock_irqsave(&timer->it_lock, flags); if (timer_delete_hook(timer) == TIMER_RETRY) { unlock_timer(timer, flags); goto retry_delete; } list_del(&timer->list); timer->it_signal = NULL; unlock_timer(timer, flags); release_posix_timer(timer, IT_ID_SET); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* CustomHID_OutEvent Manage the CUSTOM HID class Out Event */
static int8_t CustomHID_OutEvent(uint8_t event_idx, uint8_t state)
/* CustomHID_OutEvent Manage the CUSTOM HID class Out Event */ static int8_t CustomHID_OutEvent(uint8_t event_idx, uint8_t state)
{ switch(event_idx) { case 1: (state == 1) ? BSP_LED_On(LED1) : BSP_LED_Off(LED1); break; case 2: (state == 1) ? BSP_LED_On(LED2) : BSP_LED_Off(LED2); break; case 3: (state == 1) ? BSP_LED_On(LED3) : BSP_LED_Off(LED3); break; case 4: (state == 1) ? BSP_LED_On(LED4) : BSP_LED_Off(LED4); break; default: BSP_LED_Off(LED1); BSP_LED_Off(LED2); BSP_LED_Off(LED3); BSP_LED_Off(LED4); break; } USBD_CUSTOM_HID_ReceivePacket(&USBD_Device); return (0); }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Blue led. (it can only be blue flashing led) */
static void h1940_blueled_set(struct led_classdev *led_dev, enum led_brightness value)
/* Blue led. (it can only be blue flashing led) */ static void h1940_blueled_set(struct led_classdev *led_dev, enum led_brightness value)
{ if (value) { h1940_latch_control(0, H1940_LATCH_LED_FLASH); s3c2410_gpio_setpin(S3C2410_GPA3, 1); } else { h1940_latch_control(H1940_LATCH_LED_FLASH, 0); s3c2410_gpio_setpin(S3C2410_GPA3, 0); } }
robutest/uclinux
C++
GPL-2.0
60
/* Registers a power management callback that prepares the clock system for entering deep sleep mode and restore the clocks upon wakeup from deep sleep. NOTE: This is called automatically as part of cybsp_init */
static cy_rslt_t cybsp_register_sysclk_pm_callback(void)
/* Registers a power management callback that prepares the clock system for entering deep sleep mode and restore the clocks upon wakeup from deep sleep. NOTE: This is called automatically as part of cybsp_init */ static cy_rslt_t cybsp_register_sysclk_pm_callback(void)
{ cy_rslt_t result = CY_RSLT_SUCCESS; static cy_stc_syspm_callback_params_t cybsp_sysclk_pm_callback_param = {NULL, NULL}; static cy_stc_syspm_callback_t cybsp_sysclk_pm_callback = { .callback = &Cy_SysClk_DeepSleepCallback, .type = CY_SYSPM_DEEPSLEEP, .callbackParams = &cybsp_sysclk_pm_callback_param, .order = CYBSP_SYSCLK_PM_CALLBACK_ORDER }; if (!Cy_SysPm_RegisterCallback(&cybsp_sysclk_pm_callback)) { result = CYBSP_RSLT_ERR_SYSCLK_PM_CALLBACK; } return result; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* clear DNA and UNA called from CFM if configuration changes */
static void smt_clear_una_dna(struct s_smc *smc)
/* clear DNA and UNA called from CFM if configuration changes */ static void smt_clear_una_dna(struct s_smc *smc)
{ smc->mib.m[MAC0].fddiMACUpstreamNbr = SMT_Unknown ; smc->mib.m[MAC0].fddiMACDownstreamNbr = SMT_Unknown ; }
robutest/uclinux
C++
GPL-2.0
60
/* This API reads the data from the given register. */
BMG160_RETURN_FUNCTION_TYPE bmg160_read_register(u8 v_addr_u8, u8 *v_data_u8, u8 v_len_u8)
/* This API reads the data from the given register. */ BMG160_RETURN_FUNCTION_TYPE bmg160_read_register(u8 v_addr_u8, u8 *v_data_u8, u8 v_len_u8)
{ BMG160_RETURN_FUNCTION_TYPE comres = ERROR; if (p_bmg160 == BMG160_NULL) { return E_BMG160_NULL_PTR; } else { comres = p_bmg160->BMG160_BUS_READ_FUNC (p_bmg160->dev_addr, v_addr_u8, v_data_u8, v_len_u8); } return comres; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* returns the high measurement range based on the chip version */
static uint16_t tmag5273_range_high(uint8_t version)
/* returns the high measurement range based on the chip version */ static uint16_t tmag5273_range_high(uint8_t version)
{ return (version == TMAG5273_VER_TMAG5273X1) ? TMAG5273_MEAS_RANGE_HIGH_MT_VER1 : TMAG5273_MEAS_RANGE_HIGH_MT_VER2; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Lower level send routine, copies report into a larger buffer and sends. */
void Send_Command_Report(const uint8_t *const Report, const uint16_t ReportSize)
/* Lower level send routine, copies report into a larger buffer and sends. */ void Send_Command_Report(const uint8_t *const Report, const uint16_t ReportSize)
{ memcpy(CmdBuffer, Report, 8); WriteNextReport(CmdBuffer, ReportSize); }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Check the status of the Rx buffer of the specified SPI port. */
xtBoolean SPIIsRxFull(unsigned long ulBase)
/* Check the status of the Rx buffer of the specified SPI port. */ xtBoolean SPIIsRxFull(unsigned long ulBase)
{ xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)); return ((xHWREG(ulBase + SPI_SR) & SPI_SR_RXBNE)? xtrue : xfalse); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Traverse the attached ATA devices list to find out the device to access. */
LIST_ENTRY* EFIAPI SearchDeviceInfoList(IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance, IN UINT16 Port, IN UINT16 PortMultiplier, IN EFI_ATA_DEVICE_TYPE DeviceType)
/* Traverse the attached ATA devices list to find out the device to access. */ LIST_ENTRY* EFIAPI SearchDeviceInfoList(IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance, IN UINT16 Port, IN UINT16 PortMultiplier, IN EFI_ATA_DEVICE_TYPE DeviceType)
{ EFI_ATA_DEVICE_INFO *DeviceInfo; LIST_ENTRY *Node; Node = GetFirstNode (&Instance->DeviceList); while (!IsNull (&Instance->DeviceList, Node)) { DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node); if ((Instance->Mode == EfiAtaAhciMode) && (DeviceInfo->Type == EfiIdeCdrom) && (PortMultiplier == 0xFF)) { PortMultiplier = 0xFFFF; } if ((DeviceInfo->Type == DeviceType) && (Port == DeviceInfo->Port) && (PortMultiplier == DeviceInfo->PortMultiplier)) { return Node; } Node = GetNextNode (&Instance->DeviceList, Node); } return NULL; }
tianocore/edk2
C++
Other
4,240
/* USB Device MSC Bulk Out Endpoint Event Callback Parameters: event: not used (just for compatibility) Return Value: None */
void USBD_MSC_EP_BULKOUT_Event(U32 event)
/* USB Device MSC Bulk Out Endpoint Event Callback Parameters: event: not used (just for compatibility) Return Value: None */ void USBD_MSC_EP_BULKOUT_Event(U32 event)
{ BulkLen = USBD_ReadEP(usbd_msc_ep_bulkout, USBD_MSC_BulkBuf, USBD_MSC_BulkBufSize); USBD_MSC_BulkOut(); }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* The implementation should probably change to an array access. */
static int atomdef(struct stmt *s)
/* The implementation should probably change to an array access. */ static int atomdef(struct stmt *s)
{ if (s->code == NOP) return -1; switch (BPF_CLASS(s->code)) { case BPF_LD: case BPF_ALU: return A_ATOM; case BPF_LDX: return X_ATOM; case BPF_ST: case BPF_STX: return s->k; case BPF_MISC: return BPF_MISCOP(s->code) == BPF_TAX ? X_ATOM : A_ATOM; } return -1; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* pnp_remove_card_device- removes a device from the specified card @dev: pointer to the device to remove */
void pnp_remove_card_device(struct pnp_dev *dev)
/* pnp_remove_card_device- removes a device from the specified card @dev: pointer to the device to remove */ void pnp_remove_card_device(struct pnp_dev *dev)
{ spin_lock(&pnp_lock); dev->card = NULL; list_del(&dev->card_list); spin_unlock(&pnp_lock); __pnp_remove_device(dev); }
robutest/uclinux
C++
GPL-2.0
60
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). If the register specified by Address >= 0x100, then ASSERT(). If StartBit is greater than 15, then ASSERT(). If EndBit is greater than 15, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). */
UINT16 EFIAPI PciCf8BitFieldRead16(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit)
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). If the register specified by Address >= 0x100, then ASSERT(). If StartBit is greater than 15, then ASSERT(). If EndBit is greater than 15, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). */ UINT16 EFIAPI PciCf8BitFieldRead16(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit)
{ BOOLEAN InterruptState; UINT32 AddressPort; UINT16 Result; ASSERT_INVALID_PCI_ADDRESS (Address, 1); InterruptState = SaveAndDisableInterrupts (); AddressPort = IoRead32 (PCI_CONFIGURATION_ADDRESS_PORT); IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); Result = IoBitFieldRead16 ( PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2), StartBit, EndBit ); IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, AddressPort); SetInterruptState (InterruptState); return Result; }
tianocore/edk2
C++
Other
4,240
/* Depending on bflag is set or not, AS number is converted into ASDOT notation or plain number notation. */
static char* as_printf(netdissect_options *ndo, char *str, int size, u_int asnum)
/* Depending on bflag is set or not, AS number is converted into ASDOT notation or plain number notation. */ static char* as_printf(netdissect_options *ndo, char *str, int size, u_int asnum)
{ if (!ndo->ndo_bflag || asnum <= 0xFFFF) { snprintf(str, size, "%u", asnum); } else { snprintf(str, size, "%u.%u", asnum >> 16, asnum & 0xFFFF); } return str; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Allocate segment tables for secondary CPUs. These must all go in the first (bolted) segment, so that do_stab_bolted won't get a recursive segment miss on the segment table itself. */
void __init stabs_alloc(void)
/* Allocate segment tables for secondary CPUs. These must all go in the first (bolted) segment, so that do_stab_bolted won't get a recursive segment miss on the segment table itself. */ void __init stabs_alloc(void)
{ int cpu; if (cpu_has_feature(CPU_FTR_SLB)) return; for_each_possible_cpu(cpu) { unsigned long newstab; if (cpu == 0) continue; newstab = lmb_alloc_base(HW_PAGE_SIZE, HW_PAGE_SIZE, 1<<SID_SHIFT); newstab = (unsigned long)__va(newstab); memset((void *)newstab, 0, HW_PAGE_SIZE); paca[cpu].stab_addr = newstab; paca[cpu].stab_real = virt_to_abs(newstab); printk(KERN_INFO "Segment table for CPU %d at 0x%llx " "virtual, 0x%llx absolute\n", cpu, paca[cpu].stab_addr, paca[cpu].stab_real); } }
EmcraftSystems/linux-emcraft
C++
Other
266
/* nilfs_dat_read - read dat inode @dat: dat inode @raw_inode: on-disk dat inode */
int nilfs_dat_read(struct inode *dat, struct nilfs_inode *raw_inode)
/* nilfs_dat_read - read dat inode @dat: dat inode @raw_inode: on-disk dat inode */ int nilfs_dat_read(struct inode *dat, struct nilfs_inode *raw_inode)
{ return nilfs_read_inode_common(dat, raw_inode); }
robutest/uclinux
C++
GPL-2.0
60
/* Determines if the SPI module is currently synchronizing to the bus. This function will check if the underlying hardware peripheral module is currently synchronizing across multiple clock domains to the hardware bus. This function can be used to delay further operations on the module until it is ready. */
static bool _spi_is_active(Spi *const spi_module)
/* Determines if the SPI module is currently synchronizing to the bus. This function will check if the underlying hardware peripheral module is currently synchronizing across multiple clock domains to the hardware bus. This function can be used to delay further operations on the module until it is ready. */ static bool _spi_is_active(Spi *const spi_module)
{ Assert(spi_module); return spi_module->SPI_BUS_STATUS.bit.SPI_ACTIVE; }
memfault/zero-to-main
C++
null
200
/* Return value: 0 on success / negative value on failure */
static int __init ipr_init(void)
/* Return value: 0 on success / negative value on failure */ static int __init ipr_init(void)
{ ipr_info("IBM Power RAID SCSI Device Driver version: %s %s\n", IPR_DRIVER_VERSION, IPR_DRIVER_DATE); return pci_register_driver(&ipr_driver); }
robutest/uclinux
C++
GPL-2.0
60
/* Timestamp first data output register (r). The value is expressed as a 32-bit word and the bit resolution is 25 μs.. */
int32_t lsm6dso_timestamp_raw_get(lsm6dso_ctx_t *ctx, uint8_t *buff)
/* Timestamp first data output register (r). The value is expressed as a 32-bit word and the bit resolution is 25 μs.. */ int32_t lsm6dso_timestamp_raw_get(lsm6dso_ctx_t *ctx, uint8_t *buff)
{ int32_t ret; ret = lsm6dso_read_reg(ctx, LSM6DSO_TIMESTAMP0, buff, 4); return ret; }
alexander-g-dean/ESF
C++
null
41
/* Read data from serial device and save the data in buffer. */
UINTN EFIAPI PL011UartRead(IN UINTN UartBase, OUT UINT8 *Buffer, IN UINTN NumberOfBytes)
/* Read data from serial device and save the data in buffer. */ UINTN EFIAPI PL011UartRead(IN UINTN UartBase, OUT UINT8 *Buffer, IN UINTN NumberOfBytes)
{ UINTN Count; for (Count = 0; Count < NumberOfBytes; Count++, Buffer++) { while ((MmioRead32 (UartBase + UARTFR) & UART_RX_EMPTY_FLAG_MASK) != 0) { } *Buffer = MmioRead8 (UartBase + UARTDR); } return NumberOfBytes; }
tianocore/edk2
C++
Other
4,240
/* It may be assumed that this function implies a write memory barrier before changing the task state if and only if any tasks are woken up. */
void __wake_up_sync_key(wait_queue_head_t *q, unsigned int mode, int nr_exclusive, void *key)
/* It may be assumed that this function implies a write memory barrier before changing the task state if and only if any tasks are woken up. */ void __wake_up_sync_key(wait_queue_head_t *q, unsigned int mode, int nr_exclusive, void *key)
{ unsigned long flags; int wake_flags = WF_SYNC; if (unlikely(!q)) return; if (unlikely(!nr_exclusive)) wake_flags = 0; spin_lock_irqsave(&q->lock, flags); __wake_up_common(q, mode, nr_exclusive, wake_flags, key); spin_unlock_irqrestore(&q->lock, flags); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Returns true iff the packet is from the client. */
static gboolean c_from_client(c_pkt_data *d)
/* Returns true iff the packet is from the client. */ static gboolean c_from_client(c_pkt_data *d)
{ return d->src == &d->convd->client; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* USBH_MSC_UnitIsReady The function check whether a LUN is ready. */
uint8_t USBH_MSC_UnitIsReady(USBH_HandleTypeDef *phost, uint8_t lun)
/* USBH_MSC_UnitIsReady The function check whether a LUN is ready. */ uint8_t USBH_MSC_UnitIsReady(USBH_HandleTypeDef *phost, uint8_t lun)
{ MSC_HandleTypeDef *MSC_Handle = phost->pActiveClass->pData; if(phost->gState == HOST_CLASS) { return (MSC_Handle->unit[lun].error == MSC_OK); } else { return 0; } }
micropython/micropython
C++
Other
18,334
/* disable the oscillator bypass mode, HXTALEN or LXTALEN must be reset before it */
void rcu_osci_bypass_mode_disable(rcu_osci_type_enum osci)
/* disable the oscillator bypass mode, HXTALEN or LXTALEN must be reset before it */ void rcu_osci_bypass_mode_disable(rcu_osci_type_enum osci)
{ uint32_t reg; switch(osci){ case RCU_HXTAL: reg = RCU_CTL; RCU_CTL &= ~RCU_CTL_HXTALEN; RCU_CTL = (reg & ~RCU_CTL_HXTALBPS); break; case RCU_LXTAL: reg = RCU_BDCTL; RCU_BDCTL &= ~RCU_BDCTL_LXTALEN; RCU_BDCTL = (reg & ~RCU_BDCTL_LXTALBPS); break; case RCU_IRC8M: case RCU_IRC40K: case RCU_PLL_CK: case RCU_PLL1_CK: case RCU_PLL2_CK: case RCU_PLLT_CK: break; default: break; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on. */
void GPIOPinTypeTrace(uint32_t ui32Port, uint8_t ui8Pins)
/* The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on. */ void GPIOPinTypeTrace(uint32_t ui32Port, uint8_t ui8Pins)
{ ASSERT(_GPIOBaseValid(ui32Port)); GPIODirModeSet(ui32Port, ui8Pins, GPIO_DIR_MODE_HW); GPIOPadConfigSet(ui32Port, ui8Pins, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* NOTE: This is quite an ineffective algorithm as it might need to look through the array of nodes N+2 times. A more effective algorithm could be used if the nodes were stored in a sorted list. */
static uint16_t find_lowest_free_addr(uint8_t num_elem)
/* NOTE: This is quite an ineffective algorithm as it might need to look through the array of nodes N+2 times. A more effective algorithm could be used if the nodes were stored in a sorted list. */ static uint16_t find_lowest_free_addr(uint8_t num_elem)
{ uint16_t addr = bt_mesh_cdb.lowest_avail_addr; uint16_t next; int err, i; for (i = 0; i < ARRAY_SIZE(bt_mesh_cdb.nodes) + 2; ++i) { err = addr_is_free(addr, num_elem, &next); if (err == 0) { break; } else if (err != -EAGAIN) { addr = BT_MESH_ADDR_UNASSIGNED; break; } addr = next; } return addr; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* This function is a veneer that replaces the function originally installed by the NAND Flash MTD code. */
static int mxs_nand_hook_block_markbad(struct mtd_info *mtd, loff_t ofs)
/* This function is a veneer that replaces the function originally installed by the NAND Flash MTD code. */ static int mxs_nand_hook_block_markbad(struct mtd_info *mtd, loff_t ofs)
{ struct nand_chip *chip = mtd_to_nand(mtd); struct mxs_nand_info *nand_info = nand_get_controller_data(chip); int ret; nand_info->marking_block_bad = 1; ret = nand_info->hooked_block_markbad(mtd, ofs); nand_info->marking_block_bad = 0; return ret; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Usb interrupt enable/disable Parameters: ena: enable/disable 0: disable interrupt 1: enable interrupt USB Device Initialize Function Called by the User to initialize USB Device Return Value: None */
void USBD_Init(void)
/* Usb interrupt enable/disable Parameters: ena: enable/disable 0: disable interrupt 1: enable interrupt USB Device Initialize Function Called by the User to initialize USB Device Return Value: None */ void USBD_Init(void)
{ hic_enable_usb_clocks(); USBHSD->DEVCMDSTAT |= USBHSD_DEVCMDSTAT_FORCE_NEEDCLK_MASK; USBHSD->DATABUFSTART = EP_BUF_BASE & 0xFFC00000; USBHSD->EPLISTSTART = EP_LIST_BASE; NVIC_EnableIRQ(USB1_IRQn); USBD_Reset(); }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* Clear one character at the cursor current position on the OLED screen. */
static void ssd1306_clear_char(void)
/* Clear one character at the cursor current position on the OLED screen. */ static void ssd1306_clear_char(void)
{ ssd1306_write_data(0x00); ssd1306_write_data(0x00); ssd1306_write_data(0x00); ssd1306_write_data(0x00); ssd1306_write_data(0x00); ssd1306_write_data(0x00); }
remotemcu/remcu-chip-sdks
C++
null
436
/* TIM_Base MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim_base)
/* TIM_Base MSP De-Initialization This function freeze the hardware resources used in this example. */ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim_base)
{ if(htim_base->Instance==TIM2) { __HAL_RCC_TIM2_CLK_DISABLE(); } else if(htim_base->Instance==TIM3) { __HAL_RCC_TIM3_CLK_DISABLE(); } else if(htim_base->Instance==TIM7) { __HAL_RCC_TIM7_CLK_DISABLE(); } else if(htim_base->Instance==TIM16) { __HAL_RCC_TIM16_CLK_DISABLE(); } else if(htim_base->Instance==TIM17) { __HAL_RCC_TIM17_CLK_DISABLE(); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Enable a specified APIC interrupt input line. This routine enables a specified APIC interrupt input line. */
__pinned_func void z_ioapic_irq_enable(unsigned int irq)
/* Enable a specified APIC interrupt input line. This routine enables a specified APIC interrupt input line. */ __pinned_func void z_ioapic_irq_enable(unsigned int irq)
{ IoApicRedUpdateLo(irq, 0, IOAPIC_INT_MASK); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Enable/Disable I2C 14-bit timeout counter of the specified I2C port. The */
void I2CTimeoutCounterSet(unsigned long ulBase, unsigned long ulEnable, unsigned long ulDiv4)
/* Enable/Disable I2C 14-bit timeout counter of the specified I2C port. The */ void I2CTimeoutCounterSet(unsigned long ulBase, unsigned long ulEnable, unsigned long ulDiv4)
{ xASSERT((ulBase == I2C0_BASE)); xASSERT((ulEnable == I2C_TIMEOUT_EN) || (ulEnable == I2C_TIMEOUT_DIS)); xASSERT((ulDiv4 == I2C_TIMEOUT_DIV4) || (ulDiv4 == I2C_TIMEOUT_DIV_NO)); xHWREG(ulBase + I2C_TOC) &= ~0x00000006; xHWREG(ulBase + I2C_TOC) |= ulEnable | ulDiv4; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Task to read in and processes the next report from the attached device, displaying the report contents on the board LEDs and via the serial port. */
void KeyboardHost_Task(void)
/* Task to read in and processes the next report from the attached device, displaying the report contents on the board LEDs and via the serial port. */ void KeyboardHost_Task(void)
{ if (USB_HostState != HOST_STATE_Configured) return; Pipe_SelectPipe(KEYBOARD_DATA_IN_PIPE); Pipe_Unfreeze(); if (Pipe_IsINReceived()) { if (Pipe_IsReadWriteAllowed()) { uint8_t KeyboardReport[Pipe_BytesInPipe()]; Pipe_Read_Stream_LE(KeyboardReport, Pipe_BytesInPipe(), NULL); ProcessKeyboardReport(KeyboardReport); } Pipe_ClearIN(); } Pipe_Freeze(); }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Cleans up the LED blink driver. This is intended to be used upon program exit. */
void LedBlinkExit(void)
/* Cleans up the LED blink driver. This is intended to be used upon program exit. */ void LedBlinkExit(void)
{ HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_RESET); }
feaser/openblt
C++
GNU General Public License v3.0
601
/* 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_calendar_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_calendar_is_syncing(struct rtc_module *const module)
{ Assert(module); Assert(module->hw); Rtc *const rtc_module = module->hw; if (rtc_module->MODE2.STATUS.reg & RTC_STATUS_SYNCBUSY) { return true; } return false; }
memfault/zero-to-main
C++
null
200
/* Probe the given I2C chip address. Returns 0 if a chip responded, not 0 on failure. */
int i2c_probe(uchar chip)
/* Probe the given I2C chip address. Returns 0 if a chip responded, not 0 on failure. */ int i2c_probe(uchar chip)
{ unsigned char res; pca_write_reg(PCA_CON, PCA_CON_STA | PCA_CON_ENSIO); pca_wait_busy(); pca_write_reg(PCA_CON, PCA_CON_STA | PCA_CON_ENSIO); pca_write_reg(PCA_DAT, (chip << 1) | 1); res = pca_wait_busy(); if ((res == 0) && (pca_read_reg(PCA_STA) == 0x48)) res = 1; pca_write_reg(PCA_CON, PCA_CON_STO | PCA_CON_ENSIO); return res; }
EmcraftSystems/u-boot
C++
Other
181
/* Inverts the logical output level set using DATAOUT register This inversion applicable only for LP_GPIO_x. */
enum status_code gpio_pin_invert_output_level(const uint8_t gpio_pin, const bool invert)
/* Inverts the logical output level set using DATAOUT register This inversion applicable only for LP_GPIO_x. */ enum status_code gpio_pin_invert_output_level(const uint8_t gpio_pin, const bool invert)
{ enum status_code status = STATUS_OK; if (gpio_pin <= 23) { if(invert) LPMCU_MISC_REGS0->INVERT_OUTPUT_CTRL.reg |= (1 << gpio_pin); else LPMCU_MISC_REGS0->INVERT_OUTPUT_CTRL.reg &= ~(1 << gpio_pin); } else status = STATUS_ERR_INVALID_ARG; return status; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Set a field value. The report this field belongs to has to be created and transferred to the device, to set this value in the device. */
int hid_set_field(struct hid_field *field, unsigned offset, __s32 value)
/* Set a field value. The report this field belongs to has to be created and transferred to the device, to set this value in the device. */ int hid_set_field(struct hid_field *field, unsigned offset, __s32 value)
{ unsigned size = field->report_size; hid_dump_input(field->report->device, field->usage + offset, value); if (offset >= field->report_count) { dbg_hid("offset (%d) exceeds report_count (%d)\n", offset, field->report_count); return -1; } if (field->logical_minimum < 0) { if (value != snto32(s32ton(value, size), size)) { dbg_hid("value %d is out of range\n", value); return -1; } } field->value[offset] = value; return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Play the effect with effect id @effect_id for @value times */
static int pidff_playback(struct input_dev *dev, int effect_id, int value)
/* Play the effect with effect id @effect_id for @value times */ static int pidff_playback(struct input_dev *dev, int effect_id, int value)
{ struct pidff_device *pidff = dev->ff->private; pidff_playback_pid(pidff, pidff->pid_id[effect_id], value); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Handle USB state change events, this function must be called each time the USB device state is changed. */
void HIDKBD_StateChangeEvent(USBD_State_TypeDef oldState, USBD_State_TypeDef newState)
/* Handle USB state change events, this function must be called each time the USB device state is changed. */ void HIDKBD_StateChangeEvent(USBD_State_TypeDef oldState, USBD_State_TypeDef newState)
{ if ( newState == USBD_STATE_CONFIGURED ) { if ( oldState != USBD_STATE_SUSPENDED ) { idleRate = DEFAULT_IDLE_RATE / 4; QueueInit(); } if ( idleRate ) { USBTIMER_Start( HIDKBD_IDLE_TIMER, idleRate * 4, IdleTimeout ); } } else if ( ( oldState == USBD_STATE_CONFIGURED ) && ( newState != USBD_STATE_SUSPENDED ) ) { USBTIMER_Stop( HIDKBD_IDLE_TIMER ); } else if ( newState == USBD_STATE_SUSPENDED ) { USBTIMER_Stop( HIDKBD_IDLE_TIMER ); } }
remotemcu/remcu-chip-sdks
C++
null
436
/* This function ends a CRC operation and produces a CRC value. */
int tls_crypto_crc_final(psCrcContext_t *ctx, u32 *crc_val)
/* This function ends a CRC operation and produces a CRC value. */ int tls_crypto_crc_final(psCrcContext_t *ctx, u32 *crc_val)
{ *crc_val = ctx->state; return ERR_CRY_OK; }
Nicholas3388/LuaNode
C++
Other
1,055
/* Identify the cable type for the ARTOP interface in question */
static int artop6260_cable_detect(struct ata_port *ap)
/* Identify the cable type for the ARTOP interface in question */ static int artop6260_cable_detect(struct ata_port *ap)
{ struct pci_dev *pdev = to_pci_dev(ap->host->dev); u8 tmp; pci_read_config_byte(pdev, 0x49, &tmp); if (tmp & (1 << ap->port_no)) return ATA_CBL_PATA40; return ATA_CBL_PATA80; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This function enables/disables the general purpose function for a particular signal. */
void mxc_iomux_set_gpr(enum iomux_gp_func gp, bool en)
/* This function enables/disables the general purpose function for a particular signal. */ void mxc_iomux_set_gpr(enum iomux_gp_func gp, bool en)
{ u32 l; spin_lock(&gpio_mux_lock); l = __raw_readl(IOMUXGPR); if (en) l |= gp; else l &= ~gp; __raw_writel(l, IOMUXGPR); spin_unlock(&gpio_mux_lock); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Converts a BBS text device path node to BBS device path structure. */
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextBbsPath(IN CHAR16 *TextDeviceNode)
/* Converts a BBS text device path node to BBS device path structure. */ EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextBbsPath(IN CHAR16 *TextDeviceNode)
{ return DevPathFromTextGenericPath (BBS_DEVICE_PATH, TextDeviceNode); }
tianocore/edk2
C++
Other
4,240
/* Some direct events for decodes of event bus byte 3 have alternative PMCSEL values on other counters. This returns the alternative event code for those that do, or -1 otherwise. */
static s64 find_alternative_bdecode(u64 event)
/* Some direct events for decodes of event bus byte 3 have alternative PMCSEL values on other counters. This returns the alternative event code for those that do, or -1 otherwise. */ static s64 find_alternative_bdecode(u64 event)
{ int pmc, altpmc, pp, j; pmc = (event >> PM_PMC_SH) & PM_PMC_MSK; if (pmc == 0 || pmc > 4) return -1; altpmc = 5 - pmc; pp = event & PM_PMCSEL_MSK; for (j = 0; j < 4; ++j) { if (bytedecode_alternatives[pmc - 1][j] == pp) { return (event & ~(PM_PMC_MSKS | PM_PMCSEL_MSK)) | (altpmc << PM_PMC_SH) | bytedecode_alternatives[altpmc - 1][j]; } } return -1; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Erase a Sector of FLASH. See the reference manual or the FLASH programming manual for details. */
void flash_erase_sector(uint8_t sector, uint32_t program_size)
/* Erase a Sector of FLASH. See the reference manual or the FLASH programming manual for details. */ void flash_erase_sector(uint8_t sector, uint32_t program_size)
{ flash_wait_for_last_operation(); flash_set_program_size(program_size); FLASH_CR &= ~(FLASH_CR_SNB_MASK << FLASH_CR_SNB_SHIFT); FLASH_CR |= (sector & FLASH_CR_SNB_MASK) << FLASH_CR_SNB_SHIFT; FLASH_CR |= FLASH_CR_SER; FLASH_CR |= FLASH_CR_STRT; flash_wait_for_last_operation(); FLASH_CR &= ~FLASH_CR_SER; FLASH_CR &= ~(FLASH_CR_SNB_MASK << FLASH_CR_SNB_SHIFT); }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* Returns a node pointer with refcount incremented, use of_node_put() on it when done. */
struct device_node* of_get_parent(const struct device_node *node)
/* Returns a node pointer with refcount incremented, use of_node_put() on it when done. */ struct device_node* of_get_parent(const struct device_node *node)
{ struct device_node *np; if (!node) return NULL; read_lock(&devtree_lock); np = of_node_get(node->parent); read_unlock(&devtree_lock); return np; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Enables or disables the Air Quality / Gas Sensor GPIO interrupt. */
uint32_t BOARD_gasSensorEnableIRQ(bool enable)
/* Enables or disables the Air Quality / Gas Sensor GPIO interrupt. */ uint32_t BOARD_gasSensorEnableIRQ(bool enable)
{ uint32_t status; status = BOARD_picRegBitsSet( BOARD_PIC_REG_INT_ENABLE, enable, BOARD_PIC_REG_INT_ENABLE_CCS811 ); return status; }
remotemcu/remcu-chip-sdks
C++
null
436
/* reinitializes LCD if Advanced Energy Monitor was enabled previously If user enables AEM on DK, LCD must be reinitialized and redrawn. This function checks AEM state and if detects that it is just disabled, reinitializes LCD controller and redraw LCD content. */
static void _checkForAEM(void)
/* reinitializes LCD if Advanced Energy Monitor was enabled previously If user enables AEM on DK, LCD must be reinitialized and redrawn. This function checks AEM state and if detects that it is just disabled, reinitializes LCD controller and redraw LCD content. */ static void _checkForAEM(void)
{ if (BSP_RegisterRead(BC_AEMSTATE) != BC_AEMSTATE_EFM ) aem_mode = 1; else if(aem_mode) { aem_mode = 0; LCD_InitializeDriver(); WM_InvalidateWindow(WM_HBKWIN); WM_ForEachDesc(WM_HBKWIN, _cbInvalidateWindow, (void *)0); GUI_Exec(); } }
remotemcu/remcu-chip-sdks
C++
null
436
/* The original driver used to rely on a fixed sx_table, containing periods for (only) the lower limits of the respective input-clock-frequency ranges (8-10/12-15/16-20 MHz). Although it seems, that no problems ocurred with this setting so far, it might be desirable to adjust the transfer periods closer to the really attached, possibly 25% higher, input-clock, since */
static unsigned int round_4(unsigned int x)
/* The original driver used to rely on a fixed sx_table, containing periods for (only) the lower limits of the respective input-clock-frequency ranges (8-10/12-15/16-20 MHz). Although it seems, that no problems ocurred with this setting so far, it might be desirable to adjust the transfer periods closer to the really attached, possibly 25% higher, input-clock, since */ static unsigned int round_4(unsigned int x)
{ switch (x & 3) { case 1: --x; break; case 2: ++x; case 3: ++x; } return x; }
robutest/uclinux
C++
GPL-2.0
60
/* Once configured, the non-blocking read is started by calling */
void EPINonBlockingReadConfigure(uint32_t ui32Base, uint32_t ui32Channel, uint32_t ui32DataSize, uint32_t ui32Address)
/* Once configured, the non-blocking read is started by calling */ void EPINonBlockingReadConfigure(uint32_t ui32Base, uint32_t ui32Channel, uint32_t ui32DataSize, uint32_t ui32Address)
{ uint32_t ui32Offset; ASSERT(ui32Base == EPI0_BASE); ASSERT(ui32Channel < 2); ASSERT(ui32DataSize < 4); ASSERT(ui32Address < 0x20000000); ui32Offset = ui32Channel * (EPI_O_RSIZE1 - EPI_O_RSIZE0); HWREG(ui32Base + EPI_O_RSIZE0 + ui32Offset) = ui32DataSize; HWREG(ui32Base + EPI_O_RADDR0 + ui32Offset) = ui32Address; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* If the requested operation results in an overflow or an underflow condition, then Result is set to CHAR8_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeChar8Mult(IN CHAR8 Multiplicand, IN CHAR8 Multiplier, OUT CHAR8 *Result)
/* If the requested operation results in an overflow or an underflow condition, then Result is set to CHAR8_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */ RETURN_STATUS EFIAPI SafeChar8Mult(IN CHAR8 Multiplicand, IN CHAR8 Multiplier, OUT CHAR8 *Result)
{ INT32 Multiplicand32; INT32 Multiplier32; if (Result == NULL) { return RETURN_INVALID_PARAMETER; } Multiplicand32 = (INT32)Multiplicand; Multiplier32 = (INT32)Multiplier; if ((Multiplicand32 < 0) || (Multiplicand32 > MAX_INT8)) { *Result = CHAR8_ERROR; return RETURN_BUFFER_TOO_SMALL; } if ((Multiplier32 < 0) || (Multiplier32 > MAX_INT8)) { *Result = CHAR8_ERROR; return RETURN_BUFFER_TOO_SMALL; } return SafeInt32ToChar8 (Multiplicand32 * Multiplier32, Result); }
tianocore/edk2
C++
Other
4,240
/* Please ensure to read the configuration and relevant port sections of the online documentation. */
void init_main(void)
/* Please ensure to read the configuration and relevant port sections of the online documentation. */ void init_main(void)
{ init_ipsbar( ); init_basics( ); init_clock_config( ); disable_interrupts( ); disable_watchdog_timer( ); disable_cache( ); init_chip_selects( ); init_bus_config( ); init_cache( ); init_eport( ); init_flexcan( ); init_power_management( ); init_dma_timers( ); init_interrupt_timers( ); init_watchdog_timers( ); init_pin_assignments( ); init_sdram_controller( ); init_interrupt_controller( ); }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* De-initialize DMA Interface. stops operation and releases the software resources used by the interface. */
int32_t csi_dma_uninitialize(dmac_handle_t handle)
/* De-initialize DMA Interface. stops operation and releases the software resources used by the interface. */ int32_t csi_dma_uninitialize(dmac_handle_t handle)
{ if (handle == NULL) { return ERR_DMA(EDRV_PARAMETER); } ck_dma_priv_t *dma_priv = handle; ck_dma_reg_t *addr = (ck_dma_reg_t *)(dma_priv->base); uint8_t count; for (count = 0; count < dma_priv->ch_num; count++) { addr = (ck_dma_reg_t *)(dma_priv->base + count * 0x30); addr->CHINTM = CK_DMA_MASK; addr->CHINTC = CK_DMA_INTC; } drv_nvic_disable_irq(dma_priv->irq); return 0; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* __audit_mq_sendrecv - record audit data for a POSIX MQ timed send/receive @mqdes: MQ descriptor @msg_len: Message length @msg_prio: Message priority @abs_timeout: Message timeout in absolute time */
void __audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec *abs_timeout)
/* __audit_mq_sendrecv - record audit data for a POSIX MQ timed send/receive @mqdes: MQ descriptor @msg_len: Message length @msg_prio: Message priority @abs_timeout: Message timeout in absolute time */ void __audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec *abs_timeout)
{ struct audit_context *context = current->audit_context; struct timespec *p = &context->mq_sendrecv.abs_timeout; if (abs_timeout) memcpy(p, abs_timeout, sizeof(struct timespec)); else memset(p, 0, sizeof(struct timespec)); context->mq_sendrecv.mqdes = mqdes; context->mq_sendrecv.msg_len = msg_len; context->mq_sendrecv.msg_prio = msg_prio; context->type = AUDIT_MQ_SENDRECV; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* If the requested operation results in an overflow or an underflow condition, then Result is set to INT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeInt32Mult(IN INT32 Multiplicand, IN INT32 Multiplier, OUT INT32 *Result)
/* If the requested operation results in an overflow or an underflow condition, then Result is set to INT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */ RETURN_STATUS EFIAPI SafeInt32Mult(IN INT32 Multiplicand, IN INT32 Multiplier, OUT INT32 *Result)
{ return SafeInt64ToInt32 (MultS64x64 (Multiplicand, Multiplier), Result); }
tianocore/edk2
C++
Other
4,240
/* strndup_user - duplicate an existing string from user space @s: The string to duplicate */
char* strndup_user(const char __user *s, long n)
/* strndup_user - duplicate an existing string from user space @s: The string to duplicate */ char* strndup_user(const char __user *s, long n)
{ char *p; long length; length = strnlen_user(s, n); if (!length) return ERR_PTR(-EFAULT); if (length > n) return ERR_PTR(-EINVAL); p = kmalloc(length, GFP_KERNEL); if (!p) return ERR_PTR(-ENOMEM); if (copy_from_user(p, s, length)) { kfree(p); return ERR_PTR(-EFAULT); } p[length - 1] = '\0'; return p; }
robutest/uclinux
C++
GPL-2.0
60
/* USBH_MSC_BOTReset This request is used to reset the mass storage device and its associated interface. This class-specific request shall ready the device for the next CBW from the host. */
static USBH_Status USBH_MSC_BOTReset(USB_OTG_CORE_HANDLE *pdev, USBH_HOST *phost)
/* USBH_MSC_BOTReset This request is used to reset the mass storage device and its associated interface. This class-specific request shall ready the device for the next CBW from the host. */ static USBH_Status USBH_MSC_BOTReset(USB_OTG_CORE_HANDLE *pdev, USBH_HOST *phost)
{ phost->Control.setup.b.bmRequestType = USB_H2D | USB_REQ_TYPE_CLASS | \ USB_REQ_RECIPIENT_INTERFACE; phost->Control.setup.b.bRequest = USB_REQ_BOT_RESET; phost->Control.setup.b.wValue.w = 0; phost->Control.setup.b.wIndex.w = 0; phost->Control.setup.b.wLength.w = 0; return USBH_CtlReq(pdev, phost, 0 , 0 ); }
MaJerle/stm32f429
C++
null
2,036
/* param base SAI base pointer. param handle SAI eDMA handle pointer. param base SAI peripheral base address. param callback Pointer to user callback function. param userData User parameter passed to the callback function. param dmaHandle eDMA handle pointer, this handle shall be static allocated by users. */
void SAI_TransferTxCreateHandleEDMA(I2S_Type *base, sai_edma_handle_t *handle, sai_edma_callback_t callback, void *userData, edma_handle_t *txDmaHandle)
/* param base SAI base pointer. param handle SAI eDMA handle pointer. param base SAI peripheral base address. param callback Pointer to user callback function. param userData User parameter passed to the callback function. param dmaHandle eDMA handle pointer, this handle shall be static allocated by users. */ void SAI_TransferTxCreateHandleEDMA(I2S_Type *base, sai_edma_handle_t *handle, sai_edma_callback_t callback, void *userData, edma_handle_t *txDmaHandle)
{ assert((handle != NULL) && (txDmaHandle != NULL)); uint32_t instance = SAI_GetInstance(base); (void)memset(handle, 0, sizeof(*handle)); handle->dmaHandle = txDmaHandle; handle->callback = callback; handle->userData = userData; handle->state = (uint32_t)kSAI_Idle; s_edmaPrivateHandle[instance][0].base = base; s_edmaPrivateHandle[instance][0].handle = handle; EDMA_InstallTCDMemory(txDmaHandle, (edma_tcd_t *)(STCD_ADDR(handle->tcd)), SAI_XFER_QUEUE_SIZE); EDMA_SetCallback(txDmaHandle, SAI_TxEDMACallback, &s_edmaPrivateHandle[instance][0]); }
eclipse-threadx/getting-started
C++
Other
310
/* This function indents and prints the ACPI table Field Name. */
VOID EFIAPI PrintFieldName(IN UINT32 Indent, IN CONST CHAR16 *FieldName)
/* This function indents and prints the ACPI table Field Name. */ VOID EFIAPI PrintFieldName(IN UINT32 Indent, IN CONST CHAR16 *FieldName)
{ Print ( L"%*a%-*s : ", gIndent + Indent, "", (OUTPUT_FIELD_COLUMN_WIDTH - gIndent - Indent), FieldName ); }
tianocore/edk2
C++
Other
4,240
/* Activate/Deactivate Tx DMA/FIFO channels according tx fifos mask must be called under priv->lock and mac access */
static void iwl4965_txq_set_sched(struct iwl_priv *priv, u32 mask)
/* Activate/Deactivate Tx DMA/FIFO channels according tx fifos mask must be called under priv->lock and mac access */ static void iwl4965_txq_set_sched(struct iwl_priv *priv, u32 mask)
{ iwl_write_prph(priv, IWL49_SCD_TXFACT, mask); }
robutest/uclinux
C++
GPL-2.0
60
/* INPUT: in: TLB format for both VHPT & TLB. */
struct thash_data* vtlb_lookup(struct kvm_vcpu *v, u64 va, int is_data)
/* INPUT: in: TLB format for both VHPT & TLB. */ struct thash_data* vtlb_lookup(struct kvm_vcpu *v, u64 va, int is_data)
{ struct thash_data *cch; u64 psbits, ps, tag; union ia64_rr vrr; struct thash_cb *hcb = &v->arch.vtlb; cch = __vtr_lookup(v, va, is_data); if (cch) return cch; if (vcpu_quick_region_check(v->arch.tc_regions, va) == 0) return NULL; psbits = VMX(v, psbits[(va >> 61)]); vrr.val = vcpu_get_rr(v, va); while (psbits) { ps = __ffs(psbits); psbits &= ~(1UL << ps); vrr.ps = ps; cch = vsa_thash(hcb->pta, va, vrr.val, &tag); if (cch->etag == tag && cch->ps == ps) return cch; } return NULL; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Get the tilt factor of a formant filter from its transfer function */
static float tilt_factor(const float *lpcs, int n_lpcs)
/* Get the tilt factor of a formant filter from its transfer function */ static float tilt_factor(const float *lpcs, int n_lpcs)
{ float rh0, rh1; rh0 = 1.0 + ff_dot_productf(lpcs, lpcs, n_lpcs); rh1 = lpcs[0] + ff_dot_productf(lpcs, &lpcs[1], n_lpcs - 1); return rh1 / rh0; }
DC-SWAT/DreamShell
C++
null
404
/* This function clears the handler to be called when the flash interrupt occurs. This function also masks off the interrupt in the interrupt controller so that the interrupt handler is no longer called. */
void FlashIntUnregister(void)
/* This function clears the handler to be called when the flash interrupt occurs. This function also masks off the interrupt in the interrupt controller so that the interrupt handler is no longer called. */ void FlashIntUnregister(void)
{ IntDisable(INT_FLASH_TM4C123); IntUnregister(INT_FLASH_TM4C123); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Attribute read call back for the Value V13 attribute. */
static ssize_t read_value_v13(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset)
/* Attribute read call back for the Value V13 attribute. */ static ssize_t read_value_v13(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset)
{ const uint8_t *value = attr->user_data; return bt_gatt_attr_read(conn, attr, buf, len, offset, value, sizeof(value_v13_value)); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* get the number of the bytes to be read */
int SSL_pending(const SSL *ssl)
/* get the number of the bytes to be read */ int SSL_pending(const SSL *ssl)
{ int ret; SSL_ASSERT1(ssl); ret = SSL_METHOD_CALL(pending, ssl); return ret; }
retro-esp32/RetroESP32
C++
Creative Commons Attribution Share Alike 4.0 International
581
/* ACPI doesn't provide any formal means to access latch status. Instead, we fake latch status from _STA. */
static int get_latch_status(struct hotplug_slot *slot, u8 *value)
/* ACPI doesn't provide any formal means to access latch status. Instead, we fake latch status from _STA. */ static int get_latch_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_latch_status(slot->acpi_slot); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* If AesContext is NULL, then return FALSE. If Key is NULL, then return FALSE. If KeyLength is not valid, then return FALSE. If this interface is not supported, then return FALSE. */
BOOLEAN EFIAPI AesInit(OUT VOID *AesContext, IN CONST UINT8 *Key, IN UINTN KeyLength)
/* If AesContext is NULL, then return FALSE. If Key is NULL, then return FALSE. If KeyLength is not valid, then return FALSE. If this interface is not supported, then return FALSE. */ BOOLEAN EFIAPI AesInit(OUT VOID *AesContext, IN CONST UINT8 *Key, IN UINTN KeyLength)
{ CALL_CRYPTO_SERVICE (AesInit, (AesContext, Key, KeyLength), FALSE); }
tianocore/edk2
C++
Other
4,240
/* Returns the RTC Day Light Saving stored operation. */
uint8_t RTC_ReadStoreOperation(void)
/* Returns the RTC Day Light Saving stored operation. */ uint8_t RTC_ReadStoreOperation(void)
{ return (uint8_t)RTC->CTRL_B.BAKP; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Get the ETHERNET DMA Buffer Unavailable Missed Frame Counter value. */
uint32_t ETH_GetBufUnavailableMissedFrameCounter(void)
/* Get the ETHERNET DMA Buffer Unavailable Missed Frame Counter value. */ uint32_t ETH_GetBufUnavailableMissedFrameCounter(void)
{ return ((uint32_t)(ETH->DMAMFBOCNT) & ETH_DMAMFBOCNT_MISFRMCNT); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Message: UpdateDSCPMessage Opcode: 0x0150 Type: IntraCCM Direction: pbx2pbx VarLength: no */
static void handle_UpdateDSCPMessage(ptvcursor_t *cursor, packet_info *pinfo _U_)
/* Message: UpdateDSCPMessage Opcode: 0x0150 Type: IntraCCM Direction: pbx2pbx VarLength: no */ static void handle_UpdateDSCPMessage(ptvcursor_t *cursor, packet_info *pinfo _U_)
{ ptvcursor_add(cursor, hf_skinny_conferenceID, 4, ENC_LITTLE_ENDIAN); si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor)); ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN); ptvcursor_add(cursor, hf_skinny_passThruPartyID, 4, ENC_LITTLE_ENDIAN); dissect_skinny_ipv4or6(cursor, hf_skinny_remoteIpAddr_ipv4, hf_skinny_remoteIpAddr_ipv6, pinfo); ptvcursor_add(cursor, hf_skinny_remotePortNumber, 4, ENC_LITTLE_ENDIAN); ptvcursor_add(cursor, hf_skinny_DSCPValue, 4, ENC_LITTLE_ENDIAN); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Warning RTOS timer resolution is 30.5 us. This is called by two code paths: */
uint32_t sys_clock_cycle_get_32(void)
/* Warning RTOS timer resolution is 30.5 us. This is called by two code paths: */ uint32_t sys_clock_cycle_get_32(void)
{ uint32_t ret; uint32_t ccr; k_spinlock_key_t key = k_spin_lock(&lock); ccr = timer_count(); ret = (total_cycles + (cached_icr - ccr)) & TIMER_COUNT_MASK; k_spin_unlock(&lock, key); return ret; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573