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
/* 8.3 EPS session management messages 8.3.1 Activate dedicated EPS bearer context accept */
static void nas_esm_act_ded_eps_bearer_ctx_acc(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
/* 8.3 EPS session management messages 8.3.1 Activate dedicated EPS bearer context accept */ static void nas_esm_act_ded_eps_bearer_ctx_acc(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
{ guint32 curr_offset; guint32 consumed; guint curr_len; if (len == 0) return; curr_offset = offset; curr_len = len; pinfo->link_dir = P2P_DIR_UL; ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL ); ELEM_OPT_TLV(0x33, NAS_PDU_TYPE_ESM, DE_ESM_NBIFOM_CONT, NULL); ELEM_OPT_TLV_E(0x7B, NAS_PDU_TYPE_ESM, DE_ESM_EXT_PCO, NULL); EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_nas_eps_extraneous_data); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* memstick_resume_host - notify bus driver of host resumption @host - host to use */
void memstick_resume_host(struct memstick_host *host)
/* memstick_resume_host - notify bus driver of host resumption @host - host to use */ void memstick_resume_host(struct memstick_host *host)
{ int rc = 0; mutex_lock(&host->lock); if (host->card) rc = memstick_power_on(host); mutex_unlock(&host->lock); if (!rc) memstick_detect_change(host); }
robutest/uclinux
C++
GPL-2.0
60
/* The example of the function of read and write. */
void M24CxxReadWrite(void)
/* The example of the function of read and write. */ void M24CxxReadWrite(void)
{ unsigned long i; xSysCtlClockSet(72000000, xSYSCTL_OSC_MAIN | SYSCTL_XTAL_25MHZ); UartInit(); M24CxxInit(); UartPrintfChar('\r'); UartPrintfChar('\n'); M24CxxBufferWrite(ucWriteData, WriteAddress, Length); M24CxxBufferRead(ucReadData, WriteAddress, Length); for(i = 0; i < Length; i++) { UartPrintfChar(ucReadData[i]); } }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* This temporarily disables EDMA hardware events on the specified channel, preventing them from triggering new transfers on its behalf */
void edma_pause(unsigned channel)
/* This temporarily disables EDMA hardware events on the specified channel, preventing them from triggering new transfers on its behalf */ void edma_pause(unsigned channel)
{ unsigned ctlr; ctlr = EDMA_CTLR(channel); channel = EDMA_CHAN_SLOT(channel); if (channel < edma_info[ctlr]->num_channels) { unsigned int mask = (1 << (channel & 0x1f)); edma_shadow0_write_array(ctlr, SH_EECR, channel >> 5, mask); } }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Deinitializes the SPIx peripheral registers to their default reset values. */
void SPI_DeInit(SPI_TypeDef *SPIx)
/* Deinitializes the SPIx peripheral registers to their default reset values. */ void SPI_DeInit(SPI_TypeDef *SPIx)
{ assert_param(IS_SPI_ALL_PERIPH(SPIx)); if (SPIx == SPI1) { RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI1, ENABLE); RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI1, DISABLE); } else { if (SPIx == SPI2) { RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI2, ENABLE); RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI2, DISABLE); } } }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* The following code is used to support IPX Interfaces (IPXITF). An IPX interface is defined by a physical device and a frame type. */
static void ipxitf_clear_primary_net(void)
/* The following code is used to support IPX Interfaces (IPXITF). An IPX interface is defined by a physical device and a frame type. */ static void ipxitf_clear_primary_net(void)
{ ipx_primary_net = NULL; if (ipxcfg_auto_select_primary) ipx_primary_net = ipx_interfaces_head(); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Send a Start-up IPI to all processors excluding self. This function returns after the IPI has been accepted by the target processors. if StartupRoutine >= 1M, then ASSERT. if StartupRoutine is not multiple of 4K, then ASSERT. */
VOID EFIAPI SendStartupIpiAllExcludingSelf(IN UINT32 StartupRoutine)
/* Send a Start-up IPI to all processors excluding self. This function returns after the IPI has been accepted by the target processors. if StartupRoutine >= 1M, then ASSERT. if StartupRoutine is not multiple of 4K, then ASSERT. */ VOID EFIAPI SendStartupIpiAllExcludingSelf(IN UINT32 StartupRoutine)
{ LOCAL_APIC_ICR_LOW IcrLow; ASSERT (StartupRoutine < 0x100000); ASSERT ((StartupRoutine & 0xfff) == 0); IcrLow.Uint32 = 0; IcrLow.Bits.Vector = (StartupRoutine >> 12); IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_STARTUP; IcrLow.Bits.Level = 1; IcrLow.Bits.DestinationShorthand = LOCAL_APIC_DESTINATION_SHORTHAND_ALL_EXCLUDING_SELF; SendIpi (IcrLow.Uint32, 0); }
tianocore/edk2
C++
Other
4,240
/* Send an interrupt to the i960 and breakpoint it. */
static void aac_rx_interrupt_adapter(struct aac_dev *dev)
/* Send an interrupt to the i960 and breakpoint it. */ static void aac_rx_interrupt_adapter(struct aac_dev *dev)
{ rx_sync_cmd(dev, BREAKPOINT_REQUEST, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL); }
robutest/uclinux
C++
GPL-2.0
60
/* Start in offline state - awaiting NS to send start. */
static void bfa_fcs_port_ms_sm_offline(struct bfa_fcs_port_ms_s *ms, enum port_ms_event event)
/* Start in offline state - awaiting NS to send start. */ static void bfa_fcs_port_ms_sm_offline(struct bfa_fcs_port_ms_s *ms, enum port_ms_event event)
{ bfa_trc(ms->port->fcs, ms->port->port_cfg.pwwn); bfa_trc(ms->port->fcs, event); switch (event) { case MSSM_EVENT_PORT_ONLINE: bfa_sm_set_state(ms, bfa_fcs_port_ms_sm_plogi_sending); bfa_fcs_port_ms_send_plogi(ms, NULL); break; case MSSM_EVENT_PORT_OFFLINE: break; default: bfa_assert(0); } }
robutest/uclinux
C++
GPL-2.0
60
/* Converts the raw R/G/B values to color temperature in degrees Kelvin. */
uint16_t tcs34725CalculateLux(uint16_t r, uint16_t g, uint16_t b)
/* Converts the raw R/G/B values to color temperature in degrees Kelvin. */ uint16_t tcs34725CalculateLux(uint16_t r, uint16_t g, uint16_t b)
{ float illuminance; illuminance = (-0.32466F * r) + (1.57837F * g) + (-0.73191F * b); return (uint16_t)illuminance; }
microbuilder/LPC11U_LPC13U_CodeBase
C++
Other
54
/* get the specified DAC0 flag(DAC0 DMA underrun flag) */
FlagStatus dac0_flag_get(void)
/* get the specified DAC0 flag(DAC0 DMA underrun flag) */ FlagStatus dac0_flag_get(void)
{ if((uint8_t)RESET != (DAC_STAT & DAC_STAT_DDUDR0)){ return SET; }else{ return RESET; } }
liuxuming/trochili
C++
Apache License 2.0
132
/* The range isn't guaranteed to be minimal, but it tries to. */
void _cairo_gradient_pattern_box_to_parameter(const cairo_gradient_pattern_t *gradient, double x0, double y0, double x1, double y1, double tolerance, double out_range[2])
/* The range isn't guaranteed to be minimal, but it tries to. */ void _cairo_gradient_pattern_box_to_parameter(const cairo_gradient_pattern_t *gradient, double x0, double y0, double x1, double y1, double tolerance, double out_range[2])
{ assert (gradient->base.type == CAIRO_PATTERN_TYPE_LINEAR || gradient->base.type == CAIRO_PATTERN_TYPE_RADIAL); if (gradient->base.type == CAIRO_PATTERN_TYPE_LINEAR) { _cairo_linear_pattern_box_to_parameter ((cairo_linear_pattern_t *) gradient, x0, y0, x1, y1, out_range); } else { _cairo_radial_pattern_box_to_parameter ((cairo_radial_pattern_t *) gradient, x0, y0, x1, y1, tolerance, out_range); } }
xboot/xboot
C++
MIT License
779
/* This function must not be called if the LIDD interface is currently configured to expect DMA transactions. If DMA was previously used to write to the panel, */
void LCDIDDIndexedWrite(uint32_t ui32Base, uint32_t ui32CS, uint16_t ui16Addr, uint16_t ui16Data)
/* This function must not be called if the LIDD interface is currently configured to expect DMA transactions. If DMA was previously used to write to the panel, */ void LCDIDDIndexedWrite(uint32_t ui32Base, uint32_t ui32CS, uint16_t ui16Addr, uint16_t ui16Data)
{ uint32_t ui32Addr; ASSERT(ui32Base == LCD0_BASE); ASSERT((ui32CS == 0) || (ui32CS == 1)); ui32Addr = ui32CS ? LCD_O_LIDDCS1ADDR : LCD_O_LIDDCS0ADDR; HWREG(ui32Base + ui32Addr) = ui16Addr; ui32Addr = ui32CS ? LCD_O_LIDDCS1DATA : LCD_O_LIDDCS0DATA; HWREG(ui32Base + ui32Addr) = ui16Data; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function removes the TLS object pointed to by Tls and frees up the allocated memory. If Tls is NULL, nothing is done. */
VOID EFIAPI CryptoServiceTlsFree(IN VOID *Tls)
/* This function removes the TLS object pointed to by Tls and frees up the allocated memory. If Tls is NULL, nothing is done. */ VOID EFIAPI CryptoServiceTlsFree(IN VOID *Tls)
{ CALL_VOID_BASECRYPTLIB (Tls.Services.Free, TlsFree, (Tls)); }
tianocore/edk2
C++
Other
4,240
/* Returns a boolean to indicate whether SEV-SNP is enabled. */
BOOLEAN EFIAPI MemEncryptSevSnpIsEnabled(VOID)
/* Returns a boolean to indicate whether SEV-SNP is enabled. */ BOOLEAN EFIAPI MemEncryptSevSnpIsEnabled(VOID)
{ MSR_SEV_STATUS_REGISTER Msr; Msr.Uint32 = InternalMemEncryptSevStatus (); return Msr.Bits.SevSnpBit ? TRUE : FALSE; }
tianocore/edk2
C++
Other
4,240
/* param base MU peripheral base address. param regIndex TX register index. param msg Message to send. */
void MU_SendMsg(MU_Type *base, uint32_t regIndex, uint32_t msg)
/* param base MU peripheral base address. param regIndex TX register index. param msg Message to send. */ void MU_SendMsg(MU_Type *base, uint32_t regIndex, uint32_t msg)
{ assert(regIndex < MU_TR_COUNT); while (0U == (base->SR & (((uint32_t)kMU_Tx0EmptyFlag) >> regIndex))) { ; } base->TR[regIndex] = msg; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Closes the present (TCP and UDP) socket connection. This function sends a shutdown() on the socket in order to disable send() calls (while recv() ones are still allowed). Then, it closes the socket. */
int sock_close(SOCKET sock, char *errbuf, int errbuflen)
/* Closes the present (TCP and UDP) socket connection. This function sends a shutdown() on the socket in order to disable send() calls (while recv() ones are still allowed). Then, it closes the socket. */ int sock_close(SOCKET sock, char *errbuf, int errbuflen)
{ if (shutdown(sock, SHUT_WR)) { sock_geterror("shutdown()", errbuf, errbuflen); closesocket(sock); return -1; } closesocket(sock); return 0; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* The function is used to Selects the reset pin bus clock filter width. The */
void SysCtlResetPinFilterBusClkWidthSet(unsigned char ulBusClkWidth)
/* The function is used to Selects the reset pin bus clock filter width. The */ void SysCtlResetPinFilterBusClkWidthSet(unsigned char ulBusClkWidth)
{ xASSERT((ulBusClkWidth > 0 && ulBusClkWidth <= 32)); xHWREGB(RCM_RPFW) &= ~RCM_RPFW_RSTFLTSEL_M; xHWREGB(RCM_RPFW) |= ulBusClkWidth; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* This function determines the flash sector size on the device. This size determines the erase granularity of the device flash. */
uint32_t SysCtlFlashSectorSizeGet(void)
/* This function determines the flash sector size on the device. This size determines the erase granularity of the device flash. */ uint32_t SysCtlFlashSectorSizeGet(void)
{ return (1 << (10 + ((HWREG(FLASH_PP) & FLASH_PP_MAINSS_M) >> FLASH_PP_MAINSS_S))); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Wait for the current IOM command to complete. */
void am_hal_iom_poll_complete(uint32_t ui32Module)
/* Wait for the current IOM command to complete. */ void am_hal_iom_poll_complete(uint32_t ui32Module)
{ if ( ui32Module >= AM_REG_IOMSTR_NUM_MODULES ) { return; } while ( g_bIomBusy[ui32Module] ); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Interface to ax25_link_up. Changes my level 2 callsign depending on whether we have a global ROSE callsign or use the default port callsign. */
static int rose_link_up(struct rose_neigh *neigh)
/* Interface to ax25_link_up. Changes my level 2 callsign depending on whether we have a global ROSE callsign or use the default port callsign. */ static int rose_link_up(struct rose_neigh *neigh)
{ ax25_address *rose_call; ax25_cb *ax25s; if (ax25cmp(&rose_callsign, &null_ax25_address) == 0) rose_call = (ax25_address *)neigh->dev->dev_addr; else rose_call = &rose_callsign; ax25s = neigh->ax25; neigh->ax25 = ax25_find_cb(rose_call, &neigh->callsign, neigh->digipeat, neigh->dev); if (ax25s) ax25_cb_put(ax25s); return (neigh->ax25 != NULL); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Free all the lines in HBufferImage. Fields affected: Lines CurrentLine NumLines ListHead */
EFI_STATUS HBufferImageFreeLines(VOID)
/* Free all the lines in HBufferImage. Fields affected: Lines CurrentLine NumLines ListHead */ EFI_STATUS HBufferImageFreeLines(VOID)
{ HFreeLines (HBufferImage.ListHead, HBufferImage.Lines); HBufferImage.Lines = NULL; HBufferImage.CurrentLine = NULL; HBufferImage.NumLines = 0; return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Retrieves the size, in bytes, of the context buffer required for SHA-256 hash operations. */
UINTN EFIAPI Sha256GetContextSize(VOID)
/* Retrieves the size, in bytes, of the context buffer required for SHA-256 hash operations. */ UINTN EFIAPI Sha256GetContextSize(VOID)
{ return (UINTN)(sizeof (mbedtls_sha256_context)); }
tianocore/edk2
C++
Other
4,240
/* Update the record referred to by cur to the value given by . This either works (return 0) or gets an EFSCORRUPTED error. */
STATIC int xfs_bmbt_update(struct xfs_btree_cur *cur, xfs_fileoff_t off, xfs_fsblock_t bno, xfs_filblks_t len, xfs_exntst_t state)
/* Update the record referred to by cur to the value given by . This either works (return 0) or gets an EFSCORRUPTED error. */ STATIC int xfs_bmbt_update(struct xfs_btree_cur *cur, xfs_fileoff_t off, xfs_fsblock_t bno, xfs_filblks_t len, xfs_exntst_t state)
{ union xfs_btree_rec rec; xfs_bmbt_disk_set_allf(&rec.bmbt, off, bno, len, state); return xfs_btree_update(cur, &rec); }
robutest/uclinux
C++
GPL-2.0
60
/* Instruct the DMA to drop the packets fails tcp ip checksum. This is to instruct the receive DMA engine to drop the recevied packet if they fails the tcp/ip checksum in hardware. Valid only when full checksum offloading is enabled(type-2). */
void synopGMAC_rx_tcpip_chksum_drop_enable(synopGMACdevice *gmacdev)
/* Instruct the DMA to drop the packets fails tcp ip checksum. This is to instruct the receive DMA engine to drop the recevied packet if they fails the tcp/ip checksum in hardware. Valid only when full checksum offloading is enabled(type-2). */ void synopGMAC_rx_tcpip_chksum_drop_enable(synopGMACdevice *gmacdev)
{ synopGMACClearBits(gmacdev->DmaBase, DmaControl, DmaDisableDropTcpCs); return; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* applesmc_get_key_type - get key type, and put the result in type (char). Returns zero on success or a negative error on failure. Callers must hold applesmc_lock. */
static int applesmc_get_key_type(char *key, char *type)
/* applesmc_get_key_type - get key type, and put the result in type (char). Returns zero on success or a negative error on failure. Callers must hold applesmc_lock. */ static int applesmc_get_key_type(char *key, char *type)
{ int i; if (send_command(APPLESMC_GET_KEY_TYPE_CMD)) return -EIO; for (i = 0; i < 4; i++) { outb(key[i], APPLESMC_DATA_PORT); if (__wait_status(0x04)) return -EIO; } outb(6, APPLESMC_DATA_PORT); for (i = 0; i < 6; i++) { if (__wait_status(0x05)) return -EIO; type[i] = inb(APPLESMC_DATA_PORT); } type[5] = 0; return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Enables or disables simultaneously the two DAC channels software triggers. */
void DAC_DualSoftwareTriggerCmd(FunctionalState state)
/* Enables or disables simultaneously the two DAC channels software triggers. */ void DAC_DualSoftwareTriggerCmd(FunctionalState state)
{ (state) ? (DAC->SWTRIGR |= (DAC_SWTRIGR_SWTRIG1 | DAC_SWTRIGR_SWTRIG2)) : (DAC->SWTRIGR &= ~(DAC_SWTRIGR_SWTRIG1 | DAC_SWTRIGR_SWTRIG2)); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Find the first item with a key matching item_key, if any exists. */
static struct menu_item* menu_item_by_key(struct menu *m, char *item_key)
/* Find the first item with a key matching item_key, if any exists. */ static struct menu_item* menu_item_by_key(struct menu *m, char *item_key)
{ return menu_items_iter(m, menu_item_key_match, item_key); }
4ms/stm32mp1-baremetal
C++
Other
137
/* This function sets the attributes for the memory region specified by BaseAddress and Length from their current attributes to the attributes specified by Attributes. */
EFI_STATUS SmmSetMemoryAttributes(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT64 Attributes)
/* This function sets the attributes for the memory region specified by BaseAddress and Length from their current attributes to the attributes specified by Attributes. */ EFI_STATUS SmmSetMemoryAttributes(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT64 Attributes)
{ UINTN PageTableBase; PageTableBase = AsmReadCr3 () & PAGING_4K_ADDRESS_MASK_64; return SmmSetMemoryAttributesEx (PageTableBase, mPagingMode, BaseAddress, Length, Attributes); }
tianocore/edk2
C++
Other
4,240
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). */
UINT16 EFIAPI S3PciAndThenOr16(IN UINTN Address, IN UINT16 AndData, IN UINT16 OrData)
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). */ UINT16 EFIAPI S3PciAndThenOr16(IN UINTN Address, IN UINT16 AndData, IN UINT16 OrData)
{ return InternalSavePciWrite16ValueToBootScript (Address, PciAndThenOr16 (Address, AndData, OrData)); }
tianocore/edk2
C++
Other
4,240
/* Reads a byte from the LPC channel pool. */
unsigned char LPCByteRead(unsigned long ulBase, unsigned long ulOffset)
/* Reads a byte from the LPC channel pool. */ unsigned char LPCByteRead(unsigned long ulBase, unsigned long ulOffset)
{ ASSERT(ulBase == LPC0_BASE); ASSERT(ulOffset < (((HWREG(ulBase + LPC_O_STS) & LPC_STS_POOLSZ_M) >> 16) * 256)); return(HWREGB(ulBase + LPC_O_POOL + ulOffset)); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Reads the GPIO output data(status) for bit. @method GPIO_ReadOutputDataBit */
uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef GPIOx, GPIO_Pin_TypeDef GPIO_Pin)
/* Reads the GPIO output data(status) for bit. @method GPIO_ReadOutputDataBit */ uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef GPIOx, GPIO_Pin_TypeDef GPIO_Pin)
{ _ASSERT(IS_GPIO_PORT(GPIOx)); _ASSERT(IS_GPIO_PIN_SINGLE(GPIO_Pin)); if (((MGPIO->IN_LEVEL.reg[GPIOx]) & GPIO_Pin) != (uint32_t)Bit_RESET) { return (uint8_t)Bit_SET; } return (uint8_t)Bit_RESET; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns the FLASH Write Protection Option Bytes value. */
uint16_t FLASH_OB_GetWRP(void)
/* Returns the FLASH Write Protection Option Bytes value. */ uint16_t FLASH_OB_GetWRP(void)
{ return (*(__IO uint16_t *)(OPTCR_BYTE2_ADDRESS)); }
MaJerle/stm32f429
C++
null
2,036
/* Running in interpreter thread context, safe to sleep */
void acpi_os_sleep(acpi_integer ms)
/* Running in interpreter thread context, safe to sleep */ void acpi_os_sleep(acpi_integer ms)
{ schedule_timeout_interruptible(msecs_to_jiffies(ms)); }
robutest/uclinux
C++
GPL-2.0
60
/* Remove the current LED configuration and set the LED configuration to the default value, saved from the EEPROM. */
s32 igb_cleanup_led(struct e1000_hw *hw)
/* Remove the current LED configuration and set the LED configuration to the default value, saved from the EEPROM. */ s32 igb_cleanup_led(struct e1000_hw *hw)
{ wr32(E1000_LEDCTL, hw->mac.ledctl_default); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* MSS_GPIO_disable_irq See "mss_gpio.h" for details of how to use this function. */
void MSS_GPIO_disable_irq(mss_gpio_id_t port_id)
/* MSS_GPIO_disable_irq See "mss_gpio.h" for details of how to use this function. */ void MSS_GPIO_disable_irq(mss_gpio_id_t port_id)
{ uint32_t cfg_value; uint32_t gpio_idx = (uint32_t)port_id; ASSERT(gpio_idx < NB_OF_GPIO); if(gpio_idx < NB_OF_GPIO) { cfg_value = *(g_config_reg_lut[gpio_idx]); *(g_config_reg_lut[gpio_idx]) = (cfg_value & ~GPIO_INT_ENABLE_MASK); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* translate ns coding of SPD timing values into 10 ps unit values */
static unsigned short NSto10PS(unsigned char spd_byte)
/* translate ns coding of SPD timing values into 10 ps unit values */ static unsigned short NSto10PS(unsigned char spd_byte)
{ return(spd_byte*100); }
EmcraftSystems/u-boot
C++
Other
181
/* Return whether the legacy console putchar extension is implemented. */
BOOLEAN SbiImplementsLegacyPutchar(VOID)
/* Return whether the legacy console putchar extension is implemented. */ BOOLEAN SbiImplementsLegacyPutchar(VOID)
{ SBI_RET Ret; Ret = SbiCall (SBI_EXT_BASE, SBI_EXT_BASE_PROBE_EXT, 1, SBI_EXT_0_1_CONSOLE_PUTCHAR); if ((TranslateError (Ret.Error) == EFI_SUCCESS) && (Ret.Value != 0)) { return TRUE; } return FALSE; }
tianocore/edk2
C++
Other
4,240
/* sys_sched_getscheduler - get the policy (scheduling class) of a thread @pid: the pid in question. */
SYSCALL_DEFINE1(sched_getscheduler, pid_t, pid)
/* sys_sched_getscheduler - get the policy (scheduling class) of a thread @pid: the pid in question. */ SYSCALL_DEFINE1(sched_getscheduler, pid_t, pid)
{ struct task_struct *p; int retval; if (pid < 0) return -EINVAL; retval = -ESRCH; rcu_read_lock(); p = find_process_by_pid(pid); if (p) { retval = security_task_getscheduler(p); if (!retval) retval = p->policy | (p->sched_reset_on_fork ? SCHED_RESET_ON_FORK : 0); } rcu_read_unlock(); return retval; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Submit a USB set HID protocol request for the USB device specified by UsbIo and Interface and set the protocol to the value specified by Protocol. If UsbIo is NULL, then ASSERT(). */
EFI_STATUS EFIAPI UsbSetProtocolRequest(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT8 Interface, IN UINT8 Protocol)
/* Submit a USB set HID protocol request for the USB device specified by UsbIo and Interface and set the protocol to the value specified by Protocol. If UsbIo is NULL, then ASSERT(). */ EFI_STATUS EFIAPI UsbSetProtocolRequest(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT8 Interface, IN UINT8 Protocol)
{ UINT32 Status; EFI_STATUS Result; EFI_USB_DEVICE_REQUEST Request; ASSERT (UsbIo != NULL); Request.RequestType = USB_HID_CLASS_SET_REQ_TYPE; Request.Request = EFI_USB_SET_PROTOCOL_REQUEST; Request.Value = Protocol; Request.Index = Interface; Request.Length = 0; Result = UsbIo->UsbControlTransfer ( UsbIo, &Request, EfiUsbNoData, PcdGet32 (PcdUsbTransferTimeoutValue), NULL, 0, &Status ); return Result; }
tianocore/edk2
C++
Other
4,240
/* IWDG Enable Watchdog Timer. The watchdog timer is started. The timeout period defaults to 512 milliseconds unless it has been previously defined. */
void iwdg_start(void)
/* IWDG Enable Watchdog Timer. The watchdog timer is started. The timeout period defaults to 512 milliseconds unless it has been previously defined. */ void iwdg_start(void)
{ IWDG_KR = IWDG_KR_START; }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* Comparator 0 Interrupt Handler. If users want to user the ACMP Interrupt Callback feature, Users should promise that the ACMP Handle in the vector table is ACMPIntHandler. */
void ACMPIntHandler(void)
/* Comparator 0 Interrupt Handler. If users want to user the ACMP Interrupt Callback feature, Users should promise that the ACMP Handle in the vector table is ACMPIntHandler. */ void ACMPIntHandler(void)
{ unsigned long ulBase = ACMP_BASE; unsigned long ulIntFlags; ulIntFlags = xHWREGB(ulBase + CMP0_SCR); xHWREGB(ulBase + CMP0_SCR) = ulIntFlags; if((ulIntFlags & 0x06) && g_pfnACMPHandlerCallbacks[0]) { g_pfnACMPHandlerCallbacks[0](0, 0, ulIntFlags, 0); } }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* This is called to mark the dquot as needing to be logged when the transaction is committed. The dquot must already be associated with the given transaction. Note that it marks the entire transaction as dirty. In the ordinary case, this gets called via xfs_trans_commit, after the transaction is already dirty. However, there's nothing stop this from getting called directly, as done by xfs_qm_scall_setqlim. Hence, the TRANS_DIRTY flag. */
void xfs_trans_log_dquot(xfs_trans_t *tp, xfs_dquot_t *dqp)
/* This is called to mark the dquot as needing to be logged when the transaction is committed. The dquot must already be associated with the given transaction. Note that it marks the entire transaction as dirty. In the ordinary case, this gets called via xfs_trans_commit, after the transaction is already dirty. However, there's nothing stop this from getting called directly, as done by xfs_qm_scall_setqlim. Hence, the TRANS_DIRTY flag. */ void xfs_trans_log_dquot(xfs_trans_t *tp, xfs_dquot_t *dqp)
{ xfs_log_item_desc_t *lidp; ASSERT(XFS_DQ_IS_ADDEDTO_TRX(tp, dqp)); ASSERT(XFS_DQ_IS_LOCKED(dqp)); lidp = xfs_trans_find_item(tp, (xfs_log_item_t*)(&dqp->q_logitem)); ASSERT(lidp != NULL); tp->t_flags |= XFS_TRANS_DIRTY; lidp->lid_flags |= XFS_LID_DIRTY; }
robutest/uclinux
C++
GPL-2.0
60
/* Make it look like the remote partition, which is associated with the specified channel, sent us a notify IRQ. This faked IRQ will be handled by xpc_check_for_dropped_notify_IRQ_sn2(). */
static void xpc_send_local_notify_IRQ_sn2(struct xpc_channel *ch, u8 chctl_flag, char *chctl_flag_string)
/* Make it look like the remote partition, which is associated with the specified channel, sent us a notify IRQ. This faked IRQ will be handled by xpc_check_for_dropped_notify_IRQ_sn2(). */ static void xpc_send_local_notify_IRQ_sn2(struct xpc_channel *ch, u8 chctl_flag, char *chctl_flag_string)
{ struct xpc_partition *part = &xpc_partitions[ch->partid]; union xpc_channel_ctl_flags chctl = { 0 }; chctl.flags[ch->number] = chctl_flag; FETCHOP_STORE_OP(TO_AMO((u64)&part->sn.sn2.local_chctl_amo_va-> variable), FETCHOP_OR, chctl.all_flags); dev_dbg(xpc_chan, "%s sent local from partid=%d, channel=%d\n", chctl_flag_string, ch->partid, ch->number); }
robutest/uclinux
C++
GPL-2.0
60
/* Receive a packet from B-Channel. (Called from low-level-module) */
static void isdn_receive_skb_callback(int di, int channel, struct sk_buff *skb)
/* Receive a packet from B-Channel. (Called from low-level-module) */ static void isdn_receive_skb_callback(int di, int channel, struct sk_buff *skb)
{ int i; if ((i = isdn_dc2minor(di, channel)) == -1) { dev_kfree_skb(skb); return; } dev->ibytes[i] += skb->len; if (isdn_net_rcv_skb(i, skb)) return; if (dev->v110[i]) { atomic_inc(&dev->v110use[i]); skb = isdn_v110_decode(dev->v110[i], skb); atomic_dec(&dev->v110use[i]); if (!skb) return; } if (skb->len) { if (isdn_tty_rcv_skb(i, di, channel, skb)) return; wake_up_interruptible(&dev->drv[di]->rcv_waitq[channel]); } else dev_kfree_skb(skb); }
robutest/uclinux
C++
GPL-2.0
60
/* param handle codec handle. param channel audio codec play channel, can be a value or combine value of _codec_play_channel. param volume volume value, support 0 ~ 100, 0 is mute, 100 is the maximum volume value. return kStatus_Success is success, else configure failed. */
status_t HAL_CODEC_SetVolume(void *handle, uint32_t playChannel, uint32_t volume)
/* param handle codec handle. param channel audio codec play channel, can be a value or combine value of _codec_play_channel. param volume volume value, support 0 ~ 100, 0 is mute, 100 is the maximum volume value. return kStatus_Success is success, else configure failed. */ status_t HAL_CODEC_SetVolume(void *handle, uint32_t playChannel, uint32_t volume)
{ assert(handle != NULL); return WM8904_SetChannelVolume((wm8904_handle_t *)((uint32_t)(((codec_handle_t *)handle)->codecDevHandle)), playChannel, volume); }
eclipse-threadx/getting-started
C++
Other
310
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, 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(). If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT16 EFIAPI PciBitFieldWrite16(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 Value)
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, 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(). If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */ UINT16 EFIAPI PciBitFieldWrite16(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 Value)
{ return PciWrite16 ( Address, BitFieldWrite16 (PciRead16 (Address), StartBit, EndBit, Value) ); }
tianocore/edk2
C++
Other
4,240
/* Standard modes can be calculated using the CVT standard. Grab them from @edid, calculate them, and add them to the list. */
static int add_standard_modes(struct drm_connector *connector, struct edid *edid)
/* Standard modes can be calculated using the CVT standard. Grab them from @edid, calculate them, and add them to the list. */ static int add_standard_modes(struct drm_connector *connector, struct edid *edid)
{ struct drm_device *dev = connector->dev; int i, modes = 0; int timing_level; timing_level = standard_timing_level(edid); for (i = 0; i < EDID_STD_TIMINGS; i++) { struct std_timing *t = &edid->standard_timings[i]; struct drm_display_mode *newmode; if (t->hsize == 1 && t->vfreq_aspect == 1) continue; newmode = drm_mode_std(dev, &edid->standard_timings[i], edid->revision, timing_level); if (newmode) { drm_mode_probed_add(connector, newmode); modes++; } } return modes; }
robutest/uclinux
C++
GPL-2.0
60
/* Selectes the differential mode for a specific channel. */
void ADC_SelectDifferentialMode(ADC_TypeDef *ADCx, uint8_t ADC_Channel, FunctionalState NewState)
/* Selectes the differential mode for a specific channel. */ void ADC_SelectDifferentialMode(ADC_TypeDef *ADCx, uint8_t ADC_Channel, FunctionalState NewState)
{ assert_param(IS_ADC_ALL_PERIPH(ADCx)); assert_param(IS_ADC_DIFFCHANNEL(ADC_Channel)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { ADCx->DIFSEL |= (uint32_t)(1 << ADC_Channel ); } else { ADCx->DIFSEL &= ~(uint32_t)(1 << ADC_Channel); } }
ajhc/demo-cortex-m3
C++
null
38
/* Enables or disables the PEC value calculation of the transferred bytes. */
void I2C_CalculatePEC(I2C_TypeDef *I2Cx, FunctionalState NewState)
/* Enables or disables the PEC value calculation of the transferred bytes. */ void I2C_CalculatePEC(I2C_TypeDef *I2Cx, FunctionalState NewState)
{ assert_param(IS_I2C_ALL_PERIPH(I2Cx)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { I2Cx->CR1 |= I2C_CR1_ENPEC; } else { I2Cx->CR1 &= (uint16_t)~((uint16_t)I2C_CR1_ENPEC); } }
MaJerle/stm32f429
C++
null
2,036
/* This API stops Timer counting and disable the Timer interrupt function. */
void ETIMER_Close(UINT timer)
/* This API stops Timer counting and disable the Timer interrupt function. */ void ETIMER_Close(UINT timer)
{ if (timer == 0) { outpw(REG_ETMR0_CTL, 0); outpw(REG_ETMR0_IER, 0); } else if (timer == 1) { outpw(REG_ETMR1_CTL, 0); outpw(REG_ETMR1_IER, 0); } else if (timer == 2) { outpw(REG_ETMR2_CTL, 0); outpw(REG_ETMR2_IER, 0); } else { outpw(REG_ETMR3_CTL, 0); outpw(REG_ETMR3_IER, 0); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Skip the ASN1.1 object type and its length. Get ready to read the object's data. */
int ICACHE_FLASH_ATTR asn1_next_obj(const uint8_t *buf, int *offset, int obj_type)
/* Skip the ASN1.1 object type and its length. Get ready to read the object's data. */ int ICACHE_FLASH_ATTR asn1_next_obj(const uint8_t *buf, int *offset, int obj_type)
{ if (buf[*offset] != obj_type) return X509_NOT_OK; (*offset)++; return get_asn1_length(buf, offset); }
eerimoq/simba
C++
Other
337
/* Iterates all variables found in the variable serialization instance */
RETURN_STATUS EFIAPI SerializeVariablesIterateInstanceVariables(IN EFI_HANDLE Handle, IN VARIABLE_SERIALIZATION_ITERATION_CALLBACK CallbackFunction, IN VOID *Context)
/* Iterates all variables found in the variable serialization instance */ RETURN_STATUS EFIAPI SerializeVariablesIterateInstanceVariables(IN EFI_HANDLE Handle, IN VARIABLE_SERIALIZATION_ITERATION_CALLBACK CallbackFunction, IN VOID *Context)
{ SV_INSTANCE *Instance; Instance = SV_FROM_HANDLE (Handle); if ((Instance->BufferPtr != NULL) && (Instance->DataSize != 0)) { return IterateVariablesInBuffer ( CallbackFunction, Context, Instance->BufferPtr, Instance->DataSize ); } else { return RETURN_SUCCESS; } }
tianocore/edk2
C++
Other
4,240
/* Retrieves the current state of a given TCP connection to a host. */
uint8_t TCP_GetConnectionState(const uint16_t Port, const IP_Address_t *RemoteAddress, const uint16_t RemotePort)
/* Retrieves the current state of a given TCP connection to a host. */ uint8_t TCP_GetConnectionState(const uint16_t Port, const IP_Address_t *RemoteAddress, const uint16_t RemotePort)
{ for (uint8_t CSTableEntry = 0; CSTableEntry < MAX_TCP_CONNECTIONS; CSTableEntry++) { if ((ConnectionStateTable[CSTableEntry].Port == Port) && IP_COMPARE(&ConnectionStateTable[CSTableEntry].RemoteAddress, RemoteAddress) && ConnectionStateTable[CSTableEntry].RemotePort == RemotePort) { return ConnectionStateTable[CSTableEntry].State; } } return TCP_Connection_Closed; }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Call a callback for each child class of a qdisc */
void rtnl_qdisc_foreach_child(struct rtnl_qdisc *qdisc, struct nl_cache *cache, void(*cb)(struct nl_object *, void *), void *arg)
/* Call a callback for each child class of a qdisc */ void rtnl_qdisc_foreach_child(struct rtnl_qdisc *qdisc, struct nl_cache *cache, void(*cb)(struct nl_object *, void *), void *arg)
{ struct rtnl_class *filter; filter = rtnl_class_alloc(); if (!filter) return; rtnl_class_set_parent(filter, qdisc->q_handle); rtnl_class_set_ifindex(filter, qdisc->q_ifindex); rtnl_class_set_kind(filter, qdisc->q_kind); nl_cache_foreach_filter(cache, (struct nl_object *) filter, cb, arg); rtnl_class_put(filter); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Clears all the LCD display with the specified colour. */
void ST7735DisplayClear(unsigned long ulColor)
/* Clears all the LCD display with the specified colour. */ void ST7735DisplayClear(unsigned long ulColor)
{ ST7735DisplayRectFill(0, 127, 0, 159, ulColor); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* This takes in the register number and the System Context, and returns a pointer to the RegNumber-th register in gdb ordering It is, by default, set to find the register pointer of the X64 member */
UINTN* FindPointerToRegister(IN EFI_SYSTEM_CONTEXT SystemContext, IN UINTN RegNumber)
/* This takes in the register number and the System Context, and returns a pointer to the RegNumber-th register in gdb ordering It is, by default, set to find the register pointer of the X64 member */ UINTN* FindPointerToRegister(IN EFI_SYSTEM_CONTEXT SystemContext, IN UINTN RegNumber)
{ UINT8 *TempPtr; TempPtr = ((UINT8 *)SystemContext.SystemContextX64) + gRegisterOffsets[RegNumber]; return (UINTN *)TempPtr; }
tianocore/edk2
C++
Other
4,240
/* Reads the 8-bits of CMOS data at the location specified by Index. The 8-bit read value is returned. */
UINT8 EFIAPI CmosRead8(IN UINTN Index)
/* Reads the 8-bits of CMOS data at the location specified by Index. The 8-bit read value is returned. */ UINT8 EFIAPI CmosRead8(IN UINTN Index)
{ IoWrite8 (0x70, (UINT8)Index); return IoRead8 (0x71); }
tianocore/edk2
C++
Other
4,240
/* Set the I2C peripheral registers to their default reset values. */
void I2C_Reset(I2C_T *i2c)
/* Set the I2C peripheral registers to their default reset values. */ void I2C_Reset(I2C_T *i2c)
{ if (i2c == I2C1) { RCM_EnableAPB1PeriphReset(RCM_APB1_PERIPH_I2C1); RCM_DisableAPB1PeriphReset(RCM_APB1_PERIPH_I2C1); } else { RCM_EnableAPB1PeriphReset(RCM_APB1_PERIPH_I2C2); RCM_DisableAPB1PeriphReset(RCM_APB1_PERIPH_I2C2); } }
pikasTech/PikaPython
C++
MIT License
1,403
/* Unregisters an interrupt handler for the 1-Wire module. */
void OneWireIntUnregister(uint32_t ui32Base)
/* Unregisters an interrupt handler for the 1-Wire module. */ void OneWireIntUnregister(uint32_t ui32Base)
{ uint32_t ui32Int; ASSERT(ui32Base == ONEWIRE0_BASE); ui32Int = _OneWireIntNumberGet(ui32Base); ASSERT(ui32Int != 0); IntDisable(ui32Int); IntUnregister(ui32Int); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Enable the input direction of the specified GPIO. */
int32_t gpio_direction_input(struct gpio_desc *desc)
/* Enable the input direction of the specified GPIO. */ int32_t gpio_direction_input(struct gpio_desc *desc)
{ if (!desc || !nb_gpio) return FAILURE; if (ADI_GPIO_SUCCESS != adi_gpio_InputEnable(PORT(desc->number), PIN(desc->number), true)) return FAILURE; return SUCCESS; }
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* Make a mailbox call. Returns 0 on failure, non-zero on success */
void init_mbox_mmu_map()
/* Make a mailbox call. Returns 0 on failure, non-zero on success */ void init_mbox_mmu_map()
{ rt_hw_change_mmu_table(MBOX_ADDR, 96, MBOX_ADDR, STRONG_ORDER_MEM); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function will init led on the board */
static void rt_hw_board_led_init(void)
/* This function will init led on the board */ static void rt_hw_board_led_init(void)
{ AT91C_BASE_PMC->PMC_PCER = 1 << AT91C_ID_PIOA | 1 << AT91C_ID_PIOB; AT91C_BASE_PIOB->PIO_PER = LED_MASK; AT91C_BASE_PIOB->PIO_OER = LED_MASK; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns the number of characters in the output buffer */
static int tty3215_chars_in_buffer(struct tty_struct *tty)
/* Returns the number of characters in the output buffer */ static int tty3215_chars_in_buffer(struct tty_struct *tty)
{ struct raw3215_info *raw; raw = (struct raw3215_info *) tty->driver_data; return raw->count; }
robutest/uclinux
C++
GPL-2.0
60
/* If the requested operation results in an overflow or an underflow condition, then Result is set to UINTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeUintnSub(IN UINTN Minuend, IN UINTN Subtrahend, OUT UINTN *Result)
/* If the requested operation results in an overflow or an underflow condition, then Result is set to UINTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */ RETURN_STATUS EFIAPI SafeUintnSub(IN UINTN Minuend, IN UINTN Subtrahend, OUT UINTN *Result)
{ return SafeUint64Sub ((UINT64)Minuend, (UINT64)Subtrahend, (UINT64 *)Result); }
tianocore/edk2
C++
Other
4,240
/* Converts a given input byte of data from an ASCII encoded HEX value to an integer value. */
static int8_t HexToDecimal(const char Byte)
/* Converts a given input byte of data from an ASCII encoded HEX value to an integer value. */ static int8_t HexToDecimal(const char Byte)
{ if ((Byte >= 'A') && (Byte <= 'F')) return (10 + (Byte - 'A')); else if ((Byte >= '0') && (Byte <= '9')) return (Byte - '0'); return -1; }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Timer Enable the Output Compare Clear Function. When this is enabled, the output compare signal is cleared when a high is detected on the external trigger input. This works in the output compare and PWM modes only (not forced mode). The output compare signal remains off until the next update event. */
void timer_enable_oc_clear(uint32_t timer_peripheral, enum tim_oc_id oc_id)
/* Timer Enable the Output Compare Clear Function. When this is enabled, the output compare signal is cleared when a high is detected on the external trigger input. This works in the output compare and PWM modes only (not forced mode). The output compare signal remains off until the next update event. */ void timer_enable_oc_clear(uint32_t timer_peripheral, enum tim_oc_id oc_id)
{ switch (oc_id) { case TIM_OC1: TIM_CCMR1(timer_peripheral) |= TIM_CCMR1_OC1CE; break; case TIM_OC2: TIM_CCMR1(timer_peripheral) |= TIM_CCMR1_OC2CE; break; case TIM_OC3: TIM_CCMR2(timer_peripheral) |= TIM_CCMR2_OC3CE; break; case TIM_OC4: TIM_CCMR2(timer_peripheral) |= TIM_CCMR2_OC4CE; break; case TIM_OC1N: case TIM_OC2N: case TIM_OC3N: break; } }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* Get RTC Interrupt status. This function is used to get RTC interrupt status. */
unsigned long RTCIntFlagGet(void)
/* Get RTC Interrupt status. This function is used to get RTC interrupt status. */ unsigned long RTCIntFlagGet(void)
{ return xHWREG(RTC_BASE + RTC_ILR); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* If Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 16-byte boundary, then ASSERT(). */
VOID EFIAPI AsmFxSave(OUT IA32_FX_BUFFER *Buffer)
/* If Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 16-byte boundary, then ASSERT(). */ VOID EFIAPI AsmFxSave(OUT IA32_FX_BUFFER *Buffer)
{ ASSERT (Buffer != NULL); ASSERT (0 == ((UINTN)Buffer & 0xf)); InternalX86FxSave (Buffer); *(UINT32 *)(&Buffer->Buffer[sizeof (Buffer->Buffer) - 4]) = 0xAA5555AA; }
tianocore/edk2
C++
Other
4,240
/* extracts the tag number from the tag header. */
static guint fTagNo(tvbuff_t *tvb, guint offset)
/* extracts the tag number from the tag header. */ static guint fTagNo(tvbuff_t *tvb, guint offset)
{ return (guint)(tvb_get_guint8(tvb, offset) >> 4); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Set the SPI peripheral registers to their default reset values. */
void SPI_Reset(SPI_T *spi)
/* Set the SPI peripheral registers to their default reset values. */ void SPI_Reset(SPI_T *spi)
{ if (spi == SPI1) { RCM_EnableAPB2PeriphReset(RCM_APB2_PERIPH_SPI1); RCM_DisableAPB2PeriphReset(RCM_APB2_PERIPH_SPI1); } else { RCM_EnableAPB1PeriphReset(RCM_APB1_PERIPH_SPI2); RCM_DisableAPB1PeriphReset(RCM_APB1_PERIPH_SPI2); } }
pikasTech/PikaPython
C++
MIT License
1,403
/* Config the DAC peripheral according to the specified parameters in the dacConfig. */
void DAC_Config(uint32_t channel, DAC_Config_T *dacConfig)
/* Config the DAC peripheral according to the specified parameters in the dacConfig. */ void DAC_Config(uint32_t channel, DAC_Config_T *dacConfig)
{ uint32_t tmp1 = 0, tmp2 = 0; tmp1 = DAC->CTRL; tmp1 &= ~(((uint32_t)0x00000FFE) << channel); tmp2 = ((uint32_t)dacConfig->trigger | \ (uint32_t)dacConfig->waveGeneration | \ (uint32_t)dacConfig->maskAmplitudeSelect | \ (uint32_t)dacConfig->outputBuffer); tmp1 |= tmp2 << channel; DAC->CTRL = tmp1; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Draw or delete indicator in front of spinner data. */
static void gfx_mono_spinctrl_draw_spin_indicator(struct gfx_mono_spinctrl *spinner, bool draw)
/* Draw or delete indicator in front of spinner data. */ static void gfx_mono_spinctrl_draw_spin_indicator(struct gfx_mono_spinctrl *spinner, bool draw)
{ if (draw) { gfx_mono_put_bitmap(&gfx_mono_spinctrl_bitmap_spin_indicator, GFX_MONO_LCD_WIDTH - GFX_MONO_SPINCTRL_SPIN_INDICATOR_WIDTH, spinner->y); } else { gfx_mono_draw_filled_rect(GFX_MONO_LCD_WIDTH - GFX_MONO_SPINCTRL_SPIN_INDICATOR_WIDTH, spinner->y, GFX_MONO_SPINCTRL_SPIN_INDICATOR_WIDTH, GFX_MONO_SPINCTRL_SPIN_INDICATOR_HEIGHT, GFX_PIXEL_CLR); } }
memfault/zero-to-main
C++
null
200
/* ZigBee Device Profile dissector for the routing table */
void dissect_zbee_zdp_req_mgmt_rtg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/* ZigBee Device Profile dissector for the routing table */ void dissect_zbee_zdp_req_mgmt_rtg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{ guint offset = 0; zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, 1, NULL); zdp_dump_excess(tvb, offset, pinfo, tree); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This is a helper function for 'dbg_check_idx_size()' which is called for every indexing node and adds its size to the 'long long' variable pointed to by @priv. */
static int add_size(struct ubifs_info *c, struct ubifs_znode *znode, void *priv)
/* This is a helper function for 'dbg_check_idx_size()' which is called for every indexing node and adds its size to the 'long long' variable pointed to by @priv. */ static int add_size(struct ubifs_info *c, struct ubifs_znode *znode, void *priv)
{ long long *idx_size = priv; int add; add = ubifs_idx_node_sz(c, znode->child_cnt); add = ALIGN(add, 8); *idx_size += add; return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* param base SPDIF base pointer. param buffer Pointer to the data to be written. param size Bytes to be written. */
void SPDIF_WriteBlocking(SPDIF_Type *base, uint8_t *buffer, uint32_t size)
/* param base SPDIF base pointer. param buffer Pointer to the data to be written. param size Bytes to be written. */ void SPDIF_WriteBlocking(SPDIF_Type *base, uint8_t *buffer, uint32_t size)
{ assert(buffer != NULL); assert((size % 6U) == 0U); uint32_t i = 0, j = 0, data = 0; while (i < size) { while ((SPDIF_GetStatusFlag(base) & (uint32_t)kSPDIF_TxFIFOEmpty) == 0x00U) { } for (j = 0; j < 3U; j++) { data |= ((uint32_t)(*buffer) << (j * 8U)); buffer++; } SPDIF_WriteLeftData(base, data); data = 0; for (j = 0; j < 3U; j++) { data |= ((uint32_t)(*buffer) << (j * 8U)); buffer++; } SPDIF_WriteRightData(base, data); i += 6U; } }
eclipse-threadx/getting-started
C++
Other
310
/* Control interfaces are largely identical to the legacy Intel 440BX.. */
static int efficeon_fetch_size(void)
/* Control interfaces are largely identical to the legacy Intel 440BX.. */ static int efficeon_fetch_size(void)
{ int i; u16 temp; struct aper_size_info_lvl2 *values; pci_read_config_word(agp_bridge->dev, INTEL_APSIZE, &temp); values = A_SIZE_LVL2(agp_bridge->driver->aperture_sizes); for (i = 0; i < agp_bridge->driver->num_aperture_sizes; i++) { if (temp == values[i].size_value) { agp_bridge->previous_size = agp_bridge->current_size = (void *) (values + i); agp_bridge->aperture_size_idx = i; return values[i].size; } } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* @priv: Private driver data @reg: Register number to read */
static int rt5677_i2c_read(struct rt5677_priv *priv, uint reg)
/* @priv: Private driver data @reg: Register number to read */ static int rt5677_i2c_read(struct rt5677_priv *priv, uint reg)
{ u8 buf[2]; int ret; ret = dm_i2c_read(priv->dev, reg, buf, sizeof(u16)); if (ret) return ret; return buf[0] << 8 | buf[1]; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Entry point of PEI Secure Variable read driver */
EFI_STATUS EFIAPI PeiMmVariableInitialize(IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)
/* Entry point of PEI Secure Variable read driver */ EFI_STATUS EFIAPI PeiMmVariableInitialize(IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)
{ return PeiServicesInstallPpi (&mPeiMmVariablePpi); }
tianocore/edk2
C++
Other
4,240
/* The string pointer is incremented if it does not point to '\0'. */
static u8 read_string(void *data)
/* The string pointer is incremented if it does not point to '\0'. */ static u8 read_string(void *data)
{ const char **src = (const char **)data; u8 c; if (!src || !*src || !**src) return 0; c = **src; ++*src; return c; }
4ms/stm32mp1-baremetal
C++
Other
137
/* It checks if NVM is loaded correctly (bit0:1 0x2F */
NVM_OK_TypeDef STUSB1602_NVM_OK_Get(uint8_t Addr)
/* It checks if NVM is loaded correctly (bit0:1 0x2F */ NVM_OK_TypeDef STUSB1602_NVM_OK_Get(uint8_t Addr)
{ STUSB1602_DEVICE_CUT_RegTypeDef reg; STUSB1602_ReadReg(&reg.d8, Addr, STUSB1602_DEVICE_CUT_REG, 1); return (NVM_OK_TypeDef)(reg.b.Reserved_0_2); }
st-one/X-CUBE-USB-PD
C++
null
110
/* Return false if folding can raise an error. Bitwise operations need operands convertible to integers; division operations cannot have 0 as divisor. */
static int validop(int op, TValue *v1, TValue *v2)
/* Return false if folding can raise an error. Bitwise operations need operands convertible to integers; division operations cannot have 0 as divisor. */ static int validop(int op, TValue *v1, TValue *v2)
{ case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR: case LUA_OPSHL: case LUA_OPSHR: case LUA_OPBNOT: { lua_Integer i; return (tointeger(v1, &i) && tointeger(v2, &i)); } case LUA_OPDIV: case LUA_OPIDIV: case LUA_OPMOD: return (nvalue(v2) != 0); default: return 1; } }
nodemcu/nodemcu-firmware
C++
MIT License
7,566
/* Reads the counter for a given entry in linux,drconf-usable-memory property */
static int __init read_usm_ranges(const u32 **usm)
/* Reads the counter for a given entry in linux,drconf-usable-memory property */ static int __init read_usm_ranges(const u32 **usm)
{ return read_n_cells(n_mem_size_cells, usm); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Configures the: Break feature, dead time, Lock level, the IMOS. */
void TMR_ConfigBDT(TMR_T *tmr, TMR_BDTConfig_T *BDTConfig)
/* Configures the: Break feature, dead time, Lock level, the IMOS. */ void TMR_ConfigBDT(TMR_T *tmr, TMR_BDTConfig_T *BDTConfig)
{ tmr->BDT = (BDTConfig->IMOS)<<10 |\ (BDTConfig->RMOS)<<11 |\ (BDTConfig->lockLevel)<<8 |\ (BDTConfig->deadTime) |\ (BDTConfig->BRKState)<<12 |\ (BDTConfig->BRKPolarity)<<13 |\ (BDTConfig->automaticOutput)<<14; }
pikasTech/PikaPython
C++
MIT License
1,403
/* This function sanity-checks the internal table of supported CHAP hashing algorithms, as well. */
VOID IScsiCHAPInitHashList(VOID)
/* This function sanity-checks the internal table of supported CHAP hashing algorithms, as well. */ VOID IScsiCHAPInitHashList(VOID)
{ CHAR8 *Position; UINTN Left; UINTN HashIndex; CONST CHAP_HASH *Hash; UINTN Printed; Position = mChapHashListString; Left = sizeof (mChapHashListString); for (HashIndex = 0; HashIndex < ARRAY_SIZE (mChapHash); HashIndex++) { Hash = &mChapHash[HashIndex]; ASSERT (Left >= 2); Printed = AsciiSPrint ( Position, Left, "%a%d", (HashIndex == 0) ? "" : ",", Hash->Algorithm ); ASSERT (Printed + 1 < Left); Position += Printed; Left -= Printed; ASSERT (Hash->DigestSize <= ISCSI_CHAP_MAX_DIGEST_SIZE); } }
tianocore/edk2
C++
Other
4,240
/* Set the extent state field in a bmap extent record. */
void xfs_bmbt_set_state(xfs_bmbt_rec_host_t *r, xfs_exntst_t v)
/* Set the extent state field in a bmap extent record. */ void xfs_bmbt_set_state(xfs_bmbt_rec_host_t *r, xfs_exntst_t v)
{ ASSERT(v == XFS_EXT_NORM || v == XFS_EXT_UNWRITTEN); if (v == XFS_EXT_NORM) r->l0 &= xfs_mask64lo(64 - BMBT_EXNTFLAG_BITLEN); else r->l0 |= xfs_mask64hi(BMBT_EXNTFLAG_BITLEN); }
robutest/uclinux
C++
GPL-2.0
60
/* Build a qdisc cache including all qdiscs currently configured in the kernel */
int rtnl_qdisc_alloc_cache(struct nl_sock *sk, struct nl_cache **result)
/* Build a qdisc cache including all qdiscs currently configured in the kernel */ int rtnl_qdisc_alloc_cache(struct nl_sock *sk, struct nl_cache **result)
{ return nl_cache_alloc_and_fill(&rtnl_qdisc_ops, sk, result); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This API performs roundoff on given value. This API performs the roundoff on given value. */
static int8_t roundoff(int32_t value)
/* This API performs roundoff on given value. This API performs the roundoff on given value. */ static int8_t roundoff(int32_t value)
{ int8_t ret = 0; if (value < 0) ret = (int8_t)(((value) - 50) / 100); else ret = (int8_t)(((value) + 50) / 100); return ret; }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* Setup the NVIC, LED outputs, and button inputs. */
static void prvSetupHardware(void)
/* Setup the NVIC, LED outputs, and button inputs. */ static void prvSetupHardware(void)
{ NVIC_PriorityGroupConfig( NVIC_PriorityGroup_4 ); STM32vldiscovery_LEDInit( LED3 ); STM32vldiscovery_LEDInit( LED4 ); STM32vldiscovery_PBInit( BUTTON_USER, BUTTON_MODE_EXTI ); STM32vldiscovery_LEDOff( LED3 ); STM32vldiscovery_LEDOff( LED4 ); }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Provide our own set_mode() as we don't want to change anything that has already been configured.. */
static int pata_platform_set_mode(struct ata_link *link, struct ata_device **unused)
/* Provide our own set_mode() as we don't want to change anything that has already been configured.. */ static int pata_platform_set_mode(struct ata_link *link, struct ata_device **unused)
{ struct ata_device *dev; ata_for_each_dev(dev, link, ENABLED) { dev->pio_mode = dev->xfer_mode = XFER_PIO_0; dev->xfer_shift = ATA_SHIFT_PIO; dev->flags |= ATA_DFLAG_PIO; ata_dev_printk(dev, KERN_INFO, "configured for PIO\n"); } return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Allocate pages for creating 4KB-page based on 2MB-page when page fault happens. */
VOID InitPagesForPFHandler(VOID)
/* Allocate pages for creating 4KB-page based on 2MB-page when page fault happens. */ VOID InitPagesForPFHandler(VOID)
{ VOID *Address; Address = NULL; Address = AllocatePages (MAX_PF_PAGE_COUNT); ASSERT (Address != NULL); mPFPageBuffer = (UINT64)(UINTN)Address; mPFPageIndex = 0; ZeroMem ((VOID *)(UINTN)mPFPageBuffer, EFI_PAGE_SIZE * MAX_PF_PAGE_COUNT); ZeroMem (mPFPageUplink, sizeof (mPFPageUplink)); return; }
tianocore/edk2
C++
Other
4,240
/* mux the pin to the "B" internal peripheral role. */
int at91_pio3_set_b_periph(unsigned port, unsigned pin, int use_pullup)
/* mux the pin to the "B" internal peripheral role. */ int at91_pio3_set_b_periph(unsigned port, unsigned pin, int use_pullup)
{ struct at91_port *at91_port = at91_pio_get_port(port); u32 mask; if (at91_port && (pin < GPIO_PER_BANK)) { mask = 1 << pin; writel(mask, &at91_port->idr); at91_set_pio_pullup(port, pin, use_pullup); writel(readl(&at91_port->mux.pio3.abcdsr1) | mask, &at91_port->mux.pio3.abcdsr1); writel(readl(&at91_port->mux.pio3.abcdsr2) & ~mask, &at91_port->mux.pio3.abcdsr2); writel(mask, &at91_port->pdr); } return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Locking: output_lock to protect column state and space left (also, this is called from n_tty_write under the tty layer write lock) */
static int process_output(unsigned char c, struct tty_struct *tty)
/* Locking: output_lock to protect column state and space left (also, this is called from n_tty_write under the tty layer write lock) */ static int process_output(unsigned char c, struct tty_struct *tty)
{ int space, retval; mutex_lock(&tty->output_lock); space = tty_write_room(tty); retval = do_output_char(c, tty, space); mutex_unlock(&tty->output_lock); if (retval < 0) return -1; else return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Returns 0 on success. If a PIO fallback is required then 1 is returned. */
static int scc_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd)
/* Returns 0 on success. If a PIO fallback is required then 1 is returned. */ static int scc_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd)
{ ide_hwif_t *hwif = drive->hwif; u32 rw = (cmd->tf_flags & IDE_TFLAG_WRITE) ? 0 : ATA_DMA_WR; u8 dma_stat; if (ide_build_dmatable(drive, cmd) == 0) return 1; out_be32((void __iomem *)(hwif->dma_base + 8), hwif->dmatable_dma); out_be32((void __iomem *)hwif->dma_base, rw); dma_stat = scc_dma_sff_read_status(hwif); out_be32((void __iomem *)(hwif->dma_base + 4), dma_stat | 6); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Initialize arguments for GRANTED call. The nlm_rqst structure has been cleared already. */
static int nlmsvc_setgrantargs(struct nlm_rqst *call, struct nlm_lock *lock)
/* Initialize arguments for GRANTED call. The nlm_rqst structure has been cleared already. */ static int nlmsvc_setgrantargs(struct nlm_rqst *call, struct nlm_lock *lock)
{ locks_copy_lock(&call->a_args.lock.fl, &lock->fl); memcpy(&call->a_args.lock.fh, &lock->fh, sizeof(call->a_args.lock.fh)); call->a_args.lock.caller = utsname()->nodename; call->a_args.lock.oh.len = lock->oh.len; call->a_args.lock.oh.data = call->a_owner; call->a_args.lock.svid = lock->fl.fl_pid; if (lock->oh.len > NLMCLNT_OHSIZE) { void *data = kmalloc(lock->oh.len, GFP_KERNEL); if (!data) return 0; call->a_args.lock.oh.data = (u8 *) data; } memcpy(call->a_args.lock.oh.data, lock->oh.data, lock->oh.len); return 1; }
robutest/uclinux
C++
GPL-2.0
60
/* Return value: Zero on success, otherwise non-zero. A non-zero return generally means there are no available tlabels. If this is called out of interrupt or atomic context, then it will sleep until can return a tlabel or a signal is received. */
int hpsb_get_tlabel(struct hpsb_packet *packet)
/* Return value: Zero on success, otherwise non-zero. A non-zero return generally means there are no available tlabels. If this is called out of interrupt or atomic context, then it will sleep until can return a tlabel or a signal is received. */ int hpsb_get_tlabel(struct hpsb_packet *packet)
{ if (irqs_disabled() || in_atomic()) return hpsb_get_tlabel_atomic(packet); return wait_event_interruptible(tlabel_wq, !hpsb_get_tlabel_atomic(packet)); }
robutest/uclinux
C++
GPL-2.0
60
/* Decrements the reference counter associated to this instance of #CRCascade. If the reference counter reaches zero, the instance is destroyed using cr_cascade_destroy() */
void cr_cascade_unref(CRCascade *a_this)
/* Decrements the reference counter associated to this instance of #CRCascade. If the reference counter reaches zero, the instance is destroyed using cr_cascade_destroy() */ void cr_cascade_unref(CRCascade *a_this)
{ g_return_if_fail (a_this && PRIVATE (a_this)); if (PRIVATE (a_this)->ref_count) PRIVATE (a_this)->ref_count--; if (!PRIVATE (a_this)->ref_count) { cr_cascade_destroy (a_this); } }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Enables or disables the USART's DMA interface when reception error occurs. */
void USART_DMAReceptionErrorConfig(USART_TypeDef *USARTx, uint32_t USART_DMAOnError)
/* Enables or disables the USART's DMA interface when reception error occurs. */ void USART_DMAReceptionErrorConfig(USART_TypeDef *USARTx, uint32_t USART_DMAOnError)
{ assert_param(IS_USART_1234_PERIPH(USARTx)); assert_param(IS_USART_DMAONERROR(USART_DMAOnError)); USARTx->CR3 &= (uint32_t)~((uint32_t)USART_CR3_DDRE); USARTx->CR3 |= USART_DMAOnError; }
ajhc/demo-cortex-m3
C++
null
38
/* This function writes extradata "as is". Extradata must be formated like a valid atom (with size and tag) */
static int mov_write_extradata_tag(ByteIOContext *pb, MOVTrack *track)
/* This function writes extradata "as is". Extradata must be formated like a valid atom (with size and tag) */ static int mov_write_extradata_tag(ByteIOContext *pb, MOVTrack *track)
{ put_buffer(pb, track->enc->extradata, track->enc->extradata_size); return track->enc->extradata_size; }
DC-SWAT/DreamShell
C++
null
404
/* USART Set Rx/Tx Mode. The mode can be selected as Rx only, Tx only or Rx+Tx. */
void usart_set_mode(uint32_t usart, uint32_t mode)
/* USART Set Rx/Tx Mode. The mode can be selected as Rx only, Tx only or Rx+Tx. */ void usart_set_mode(uint32_t usart, uint32_t mode)
{ USART_CR1(usart) = (USART_CR1(usart) & ~USART_MODE) | mode; }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50