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 |
|---|---|---|---|---|---|---|---|
/* This routine goes all-out, setting everything up anew at each open, even though many of these registers should only need to be set once at boot. */ | static int __ei_open(struct net_device *dev) | /* This routine goes all-out, setting everything up anew at each open, even though many of these registers should only need to be set once at boot. */
static int __ei_open(struct net_device *dev) | {
unsigned long flags;
struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
if (dev->watchdog_timeo <= 0)
dev->watchdog_timeo = TX_TIMEOUT;
spin_lock_irqsave(&ei_local->page_lock, flags);
__NS8390_init(dev, 1);
netif_start_queue(dev);
spin_unlock_irqrestore(&ei_local->page_lock, fla... | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Set the Timer to Count Down.
This has no effect if the timer is set to center aligned. */ | void timer_direction_down(uint32_t timer_peripheral) | /* Set the Timer to Count Down.
This has no effect if the timer is set to center aligned. */
void timer_direction_down(uint32_t timer_peripheral) | {
TIM_CR1(timer_peripheral) |= TIM_CR1_DIR_DOWN;
} | insane-adding-machines/unicore-mx | C++ | GNU General Public License v3.0 | 50 |
/* Encrypts the len-bytes in the specified data-array, using the specified 256-bit (32 bytes) key. The results are written back into the same array. */ | LIBOPENBLT_EXPORT uint32_t BltUtilCryptoAes256Encrypt(uint8_t *data, uint32_t len, uint8_t const *key) | /* Encrypts the len-bytes in the specified data-array, using the specified 256-bit (32 bytes) key. The results are written back into the same array. */
LIBOPENBLT_EXPORT uint32_t BltUtilCryptoAes256Encrypt(uint8_t *data, uint32_t len, uint8_t const *key) | {
uint32_t result = BLT_RESULT_ERROR_GENERIC;
assert(data != NULL);
assert(key != NULL);
if ( (data != NULL) && (key != NULL) && ((len % 16u) == 0) )
{
if (UtilCryptoAes256Encrypt(data, len, key))
{
result = BLT_RESULT_OK;
}
}
return result;
} | feaser/openblt | C++ | GNU General Public License v3.0 | 601 |
/* Simple read-only (writable only for RAM) mtdblock driver */ | static int mtdblock_readsect(struct mtd_blktrans_dev *dev, unsigned long block, char *buf) | /* Simple read-only (writable only for RAM) mtdblock driver */
static int mtdblock_readsect(struct mtd_blktrans_dev *dev, unsigned long block, char *buf) | {
size_t retlen;
if (dev->mtd->read(dev->mtd, (block * 512), 512, &retlen, buf))
return 1;
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* enable or disable the EXMC NAND ECC function */ | void exmc_nand_ecc_config(uint32_t nand_bank, ControlStatus newvalue) | /* enable or disable the EXMC NAND ECC function */
void exmc_nand_ecc_config(uint32_t nand_bank, ControlStatus newvalue) | {
if (ENABLE == newvalue){
EXMC_NPCTL(nand_bank) |= EXMC_NPCTL_ECCEN;
}else{
EXMC_NPCTL(nand_bank) &= ~EXMC_NPCTL_ECCEN;
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* ide_stall_queue() can be used by a drive to give excess bandwidth back to the port by sleeping for timeout jiffies. */ | void ide_stall_queue(ide_drive_t *drive, unsigned long timeout) | /* ide_stall_queue() can be used by a drive to give excess bandwidth back to the port by sleeping for timeout jiffies. */
void ide_stall_queue(ide_drive_t *drive, unsigned long timeout) | {
if (timeout > WAIT_WORSTCASE)
timeout = WAIT_WORSTCASE;
drive->sleep = timeout + jiffies;
drive->dev_flags |= IDE_DFLAG_SLEEPING;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* cxgb3i_adpater_find_by_tdev - find the cxgb3i_adapter structure via t3cdev @tdev: t3cdev pointer */ | struct cxgb3i_adapter* cxgb3i_adapter_find_by_tdev(struct t3cdev *tdev) | /* cxgb3i_adpater_find_by_tdev - find the cxgb3i_adapter structure via t3cdev @tdev: t3cdev pointer */
struct cxgb3i_adapter* cxgb3i_adapter_find_by_tdev(struct t3cdev *tdev) | {
struct cxgb3i_adapter *snic;
read_lock(&cxgb3i_snic_rwlock);
list_for_each_entry(snic, &cxgb3i_snic_list, list_head) {
if (snic->tdev == tdev) {
read_unlock(&cxgb3i_snic_rwlock);
return snic;
}
}
read_unlock(&cxgb3i_snic_rwlock);
return NULL;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Config the RTC alarm Output Way and output polarity. */ | void RTC_ConfigOutput(RTC_OUT_SEL_T outputSel, RTC_OUT_POLARITY_T polarity) | /* Config the RTC alarm Output Way and output polarity. */
void RTC_ConfigOutput(RTC_OUT_SEL_T outputSel, RTC_OUT_POLARITY_T polarity) | {
RTC_DisableWriteProtection();
RTC->CTRL_B.OUTSEL = outputSel;
RTC->CTRL_B.POLCFG = polarity;
RTC_EnableWriteProtection();
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Setup the MAC address in the MAC itself, and in the uIP stack. */ | static void prvSetMACAddress(void) | /* Setup the MAC address in the MAC itself, and in the uIP stack. */
static void prvSetMACAddress(void) | {
struct uip_eth_addr xAddr;
xAddr.addr[ 0 ] = uipMAC_ADDR0;
xAddr.addr[ 1 ] = uipMAC_ADDR1;
xAddr.addr[ 2 ] = uipMAC_ADDR2;
xAddr.addr[ 3 ] = uipMAC_ADDR3;
xAddr.addr[ 4 ] = uipMAC_ADDR4;
xAddr.addr[ 5 ] = uipMAC_ADDR5;
uip_setethaddr( xAddr ); ENET_MAC->MAL = ( uipMAC_ADDR3 << 24 ) | ( uipMAC_ADDR2 << 16 ) | (... | apopple/Pandaboard-FreeRTOS | C++ | null | 25 |
/* Checks whether the ETHERNET transmit DATFIFO bit is cleared or not. */ | FlagStatus ETH_GetFlushTxFifoStatus(void) | /* Checks whether the ETHERNET transmit DATFIFO bit is cleared or not. */
FlagStatus ETH_GetFlushTxFifoStatus(void) | {
FlagStatus bitstatus = RESET;
if ((ETH->DMAOPMOD & ETH_DMAOPMOD_FTF) != (uint32_t)RESET)
{
bitstatus = SET;
}
else
{
bitstatus = RESET;
}
return bitstatus;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* DMA Channel Set Request Selection.
Set DMA request mapping selection for given channel. Refer to datasheet for channel request mapping tables. */ | void dma_set_channel_request(uint32_t dma, uint8_t channel, uint8_t request) | /* DMA Channel Set Request Selection.
Set DMA request mapping selection for given channel. Refer to datasheet for channel request mapping tables. */
void dma_set_channel_request(uint32_t dma, uint8_t channel, uint8_t request) | {
uint32_t reg32 = DMA_CSELR(dma) & ~(DMA_CSELR_CxS_MASK << DMA_CSELR_CxS_SHIFT(channel));
DMA_CSELR(dma) = reg32 | ((DMA_CSELR_CxS_MASK & request) << DMA_CSELR_CxS_SHIFT(channel));
} | libopencm3/libopencm3 | C++ | GNU General Public License v3.0 | 2,931 |
/* Queries a handle to determine if it supports a specified protocol. */ | EFI_STATUS EFIAPI MmHandleProtocol(IN EFI_HANDLE UserHandle, IN EFI_GUID *Protocol, OUT VOID **Interface) | /* Queries a handle to determine if it supports a specified protocol. */
EFI_STATUS EFIAPI MmHandleProtocol(IN EFI_HANDLE UserHandle, IN EFI_GUID *Protocol, OUT VOID **Interface) | {
EFI_STATUS Status;
PROTOCOL_INTERFACE *Prot;
if (Protocol == NULL) {
return EFI_INVALID_PARAMETER;
}
if (Interface == NULL) {
return EFI_INVALID_PARAMETER;
} else {
*Interface = NULL;
}
Status = MmValidateHandle (UserHandle);
if (EFI_ERROR (Status)) {
return Status;
}
P... | tianocore/edk2 | C++ | Other | 4,240 |
/* Polls the EEPROM status bit for either read or write completion based upon the value of 'ee_reg'. */ | s32 e1000e_poll_eerd_eewr_done(struct e1000_hw *hw, int ee_reg) | /* Polls the EEPROM status bit for either read or write completion based upon the value of 'ee_reg'. */
s32 e1000e_poll_eerd_eewr_done(struct e1000_hw *hw, int ee_reg) | {
u32 attempts = 100000;
u32 i, reg = 0;
for (i = 0; i < attempts; i++) {
if (ee_reg == E1000_NVM_POLL_READ)
reg = er32(EERD);
else
reg = er32(EEWR);
if (reg & E1000_NVM_RW_REG_DONE)
return 0;
udelay(5);
}
return -E1000_ERR_NVM;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* param fabric - Fabric instance. This can be a base fabric or vf. */ | int bfa_fcs_fabric_is_online(struct bfa_fcs_fabric_s *fabric) | /* param fabric - Fabric instance. This can be a base fabric or vf. */
int bfa_fcs_fabric_is_online(struct bfa_fcs_fabric_s *fabric) | {
return bfa_sm_cmp_state(fabric, bfa_fcs_fabric_sm_online);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* The maximum time (1 LSB = 1/ODR) interval that can elapse between the start of the click-detection procedure and when the acceleration falls back below the threshold.. */ | int32_t lis2dh12_shock_dur_set(stmdev_ctx_t *ctx, uint8_t val) | /* The maximum time (1 LSB = 1/ODR) interval that can elapse between the start of the click-detection procedure and when the acceleration falls back below the threshold.. */
int32_t lis2dh12_shock_dur_set(stmdev_ctx_t *ctx, uint8_t val) | {
lis2dh12_time_limit_t time_limit;
int32_t ret;
ret = lis2dh12_read_reg(ctx, LIS2DH12_TIME_LIMIT,
(uint8_t *)&time_limit, 1);
if (ret == 0)
{
time_limit.tli = val;
ret = lis2dh12_write_reg(ctx, LIS2DH12_TIME_LIMIT,
(uint8_t *)&time_limit, 1);
}... | prusa3d/Prusa-Firmware-Buddy | C++ | Other | 1,019 |
/* Convert the poll interval from application to that be used by EHCI interface data structure. Only need to get the max 2^n that is less than interval. UEFI can't support high speed endpoint with a interval less than 8 microframe because interval is specified in the unit of ms (millisecond). */ | UINTN EhcConvertPollRate(IN UINTN Interval) | /* Convert the poll interval from application to that be used by EHCI interface data structure. Only need to get the max 2^n that is less than interval. UEFI can't support high speed endpoint with a interval less than 8 microframe because interval is specified in the unit of ms (millisecond). */
UINTN EhcConvertPollRat... | {
UINTN BitCount;
if (Interval == 0) {
return 1;
}
BitCount = 0;
while (Interval != 0) {
Interval >>= 1;
BitCount++;
}
return (UINTN)1 << (BitCount - 1);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* If we support more console drivers, this function is used when a driver wants to take over some existing consoles and become default driver for newly opened ones. */ | int take_over_console(const struct consw *csw, int first, int last, int deflt) | /* If we support more console drivers, this function is used when a driver wants to take over some existing consoles and become default driver for newly opened ones. */
int take_over_console(const struct consw *csw, int first, int last, int deflt) | {
int err;
err = register_con_driver(csw, first, last);
if (!err)
bind_con_driver(csw, first, last, deflt);
return err;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* we temporarily boost lower priority queues if they are holding fs exclusive resources. they are boosted to normal prio (CLASS_BE/4) */ | static void cfq_prio_boost(struct cfq_queue *cfqq) | /* we temporarily boost lower priority queues if they are holding fs exclusive resources. they are boosted to normal prio (CLASS_BE/4) */
static void cfq_prio_boost(struct cfq_queue *cfqq) | {
if (has_fs_excl()) {
if (cfq_class_idle(cfqq))
cfqq->ioprio_class = IOPRIO_CLASS_BE;
if (cfqq->ioprio > IOPRIO_NORM)
cfqq->ioprio = IOPRIO_NORM;
} else {
cfqq->ioprio_class = cfqq->org_ioprio_class;
cfqq->ioprio = cfqq->org_ioprio;
}
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* On return it will hold the BIOS revision supported in the same format. */ | static int apm_driver_version(u_short *val) | /* On return it will hold the BIOS revision supported in the same format. */
static int apm_driver_version(u_short *val) | {
u32 eax;
int err;
if (apm_bios_call_simple(APM_FUNC_VERSION, 0, *val, &eax, &err))
return err;
*val = eax;
return APM_SUCCESS;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Increment *c until we get to the end of the current line, or EOF. */ | static void eol_or_eof(char **c) | /* Increment *c until we get to the end of the current line, or EOF. */
static void eol_or_eof(char **c) | {
while (**c && **c != '\n')
(*c)++;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Gets the FIFO level at which interrupts are generated. */ | void UARTFIFOLevelGet(unsigned long ulBase, unsigned long *pulTxLevel, unsigned long *pulRxLevel) | /* Gets the FIFO level at which interrupts are generated. */
void UARTFIFOLevelGet(unsigned long ulBase, unsigned long *pulTxLevel, unsigned long *pulRxLevel) | {
unsigned long ulTemp;
ASSERT(UARTBaseValid(ulBase));
ulTemp = HWREG(ulBase + UART_O_IFLS);
*pulTxLevel = ulTemp & UART_IFLS_TX_M;
*pulRxLevel = ulTemp & UART_IFLS_RX_M;
} | watterott/WebRadio | C++ | null | 71 |
/* Disables reception of all the frames to application. GMAC passes only those received frames to application which pass SA/DA address filtering. */ | void synopGMAC_frame_filter_disable(synopGMACdevice *gmacdev) | /* Disables reception of all the frames to application. GMAC passes only those received frames to application which pass SA/DA address filtering. */
void synopGMAC_frame_filter_disable(synopGMACdevice *gmacdev) | {
synopGMACSetBits(gmacdev->MacBase, GmacFrameFilter, GmacFilter);
return;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Create the first memory status code GUID'ed HOB as initialization for memory status code worker. */ | EFI_STATUS MemoryStatusCodeInitializeWorker(VOID) | /* Create the first memory status code GUID'ed HOB as initialization for memory status code worker. */
EFI_STATUS MemoryStatusCodeInitializeWorker(VOID) | {
MEMORY_STATUSCODE_PACKET_HEADER *PacketHeader;
PacketHeader = BuildGuidHob (
&gMemoryStatusCodeRecordGuid,
PcdGet16 (PcdStatusCodeMemorySize) * 1024 + sizeof (MEMORY_STATUSCODE_PACKET_HEADER)
);
ASSERT (PacketHeader != NULL);
PacketHeader->MaxRecordsNu... | tianocore/edk2 | C++ | Other | 4,240 |
/* Mark Big Number for constant time computations. This function should be called before any constant time computations are performed on the given Big number. */ | VOID EFIAPI BigNumConstTime(IN VOID *Bn) | /* Mark Big Number for constant time computations. This function should be called before any constant time computations are performed on the given Big number. */
VOID EFIAPI BigNumConstTime(IN VOID *Bn) | {
BN_set_flags (Bn, BN_FLG_CONSTTIME);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Unregistration is done in 2 steps. First we release all resources and remove it from the subsystem, then we drop reference count by calling platform_device_put(). */ | void platform_device_unregister(struct platform_device *pdev) | /* Unregistration is done in 2 steps. First we release all resources and remove it from the subsystem, then we drop reference count by calling platform_device_put(). */
void platform_device_unregister(struct platform_device *pdev) | {
platform_device_del(pdev);
platform_device_put(pdev);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Disable the SPI interrupt of the specified SPI port. */ | void SPIIntDisable(unsigned long ulBase) | /* Disable the SPI interrupt of the specified SPI port. */
void SPIIntDisable(unsigned long ulBase) | {
xASSERT(ulBase == SPI0_BASE);
xHWREG(ulBase + SPI_CNTRL) &= ~SPI_CNTRL_IE;
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* deinitialize DMA a channel registers
, V1.0.0, firmware for GD32F1x0(x=3,5) , V2.0.0, firmware for GD32F1x0(x=3,5,7,9) , V3.0.0, firmware update for GD32F1x0(x=3,5,7,9) */ | void dma_deinit(dma_channel_enum channelx) | /* deinitialize DMA a channel registers
, V1.0.0, firmware for GD32F1x0(x=3,5) , V2.0.0, firmware for GD32F1x0(x=3,5,7,9) , V3.0.0, firmware update for GD32F1x0(x=3,5,7,9) */
void dma_deinit(dma_channel_enum channelx) | {
DMA_CHCTL(channelx) &= ~DMA_CHXCTL_CHEN;
DMA_CHCTL(channelx) = DMA_CHCTL_RESET_VALUE;
DMA_CHCNT(channelx) = DMA_CHCNT_RESET_VALUE;
DMA_CHPADDR(channelx) = DMA_CHPADDR_RESET_VALUE;
DMA_CHMADDR(channelx) = DMA_CHMADDR_RESET_VALUE;
DMA_INTC |= DMA_FLAG_ADD(DMA_CHINTF_RESET_VALUE,channelx);
} | liuxuming/trochili | C++ | Apache License 2.0 | 132 |
/* No need to set need_resched since signal event passing goes through ->blocked */ | void signal_wake_up(struct task_struct *t, int resume) | /* No need to set need_resched since signal event passing goes through ->blocked */
void signal_wake_up(struct task_struct *t, int resume) | {
unsigned int mask;
set_tsk_thread_flag(t, TIF_SIGPENDING);
mask = TASK_INTERRUPTIBLE;
if (resume)
mask |= TASK_WAKEKILL;
if (!wake_up_state(t, mask))
kick_process(t);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* @reason: Pointer to returned reason string, or NULL to send a bare "OKAY" @response: Pointer to fastboot response buffer */ | void fastboot_okay(const char *reason, char *response) | /* @reason: Pointer to returned reason string, or NULL to send a bare "OKAY" @response: Pointer to fastboot response buffer */
void fastboot_okay(const char *reason, char *response) | {
if (reason)
fastboot_response("OKAY", response, "%s", reason);
else
fastboot_response("OKAY", response, NULL);
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* return 0 and set rio_dev->driver when drv claims rio_dev, else error */ | static int rio_device_probe(struct device *dev) | /* return 0 and set rio_dev->driver when drv claims rio_dev, else error */
static int rio_device_probe(struct device *dev) | {
struct rio_driver *rdrv = to_rio_driver(dev->driver);
struct rio_dev *rdev = to_rio_dev(dev);
int error = -ENODEV;
const struct rio_device_id *id;
if (!rdev->driver && rdrv->probe) {
if (!rdrv->id_table)
return error;
id = rio_match_device(rdrv->id_table, rdev);
rio_dev_get(rdev);
if (id)
error = r... | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Compute a default strip size based on the image characteristics and a requested value. If the request is <1 then we choose a strip size according to certain heuristics. */ | uint32 TIFFDefaultStripSize(TIFF *tif, uint32 request) | /* Compute a default strip size based on the image characteristics and a requested value. If the request is <1 then we choose a strip size according to certain heuristics. */
uint32 TIFFDefaultStripSize(TIFF *tif, uint32 request) | {
return (*tif->tif_defstripsize)(tif, request);
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Checks whether the specified DMAy Channelx interrupt has occurred or not. */ | ITStatus DMA_GetITStatus(uint32_t DMAy_IT) | /* Checks whether the specified DMAy Channelx interrupt has occurred or not. */
ITStatus DMA_GetITStatus(uint32_t DMAy_IT) | {
ITStatus bitstatus = RESET;
uint32_t tmpreg = 0;
assert_param(IS_DMA_GET_IT(DMAy_IT));
if ((DMAy_IT & FLAG_Mask) != (uint32_t)RESET)
{
;
}
else
{
tmpreg = DMA1->ISR;
}
if ((tmpreg & DMAy_IT) != (uint32_t)RESET)
{
bitstatus = SET;
}
else
{
bitstatus = RESET;
}
return... | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Clears or safeguards the OCREF2 signal on an external event. */ | void TIM_ClearOC2Ref(TIM_TypeDef *TIMx, uint16_t TIM_OCClear) | /* Clears or safeguards the OCREF2 signal on an external event. */
void TIM_ClearOC2Ref(TIM_TypeDef *TIMx, uint16_t TIM_OCClear) | {
uint16_t tmpccmr1 = 0;
assert_param(IS_TIM_123458_PERIPH(TIMx));
assert_param(IS_TIM_OCCLEAR_STATE(TIM_OCClear));
tmpccmr1 = TIMx->CCMR1;
tmpccmr1 &= CCMR_OC24CE_Reset;
tmpccmr1 |= (uint16_t)(TIM_OCClear << 8);
TIMx->CCMR1 = tmpccmr1;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Pertubation of rt_genid by a small quantity Using 8 bits of shuffling ensure we can call rt_cache_invalidate() many times (2^24) without giving recent rt_genid. Jenkins hash is strong enough that litle changes of rt_genid are OK. */ | static void rt_cache_invalidate(struct net *net) | /* Pertubation of rt_genid by a small quantity Using 8 bits of shuffling ensure we can call rt_cache_invalidate() many times (2^24) without giving recent rt_genid. Jenkins hash is strong enough that litle changes of rt_genid are OK. */
static void rt_cache_invalidate(struct net *net) | {
unsigned char shuffle;
get_random_bytes(&shuffle, sizeof(shuffle));
atomic_add(shuffle + 1U, &net->ipv4.rt_genid);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Frees all the data elements of the datalist. The data elements' destroy functions are called if they have been set. */ | void g_datalist_clear(GData **datalist) | /* Frees all the data elements of the datalist. The data elements' destroy functions are called if they have been set. */
void g_datalist_clear(GData **datalist) | {
GData *data;
gint i;
g_return_if_fail (datalist != NULL);
g_datalist_lock (datalist);
data = G_DATALIST_GET_POINTER (datalist);
G_DATALIST_SET_POINTER (datalist, NULL);
g_datalist_unlock (datalist);
if (data)
{
for (i = 0; i < data->len; i++)
{
if (data->data[i].data && dat... | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* This function finds an unused CMT channel, configures it for the requested frequency, associates a user callback function with the timer’s interrupt, and powers up and starts the timer. */ | bool R_CMT_CreatePeriodic(uint32_t frequency_hz, void(*callback)(void *pdata), uint32_t *channel) | /* This function finds an unused CMT channel, configures it for the requested frequency, associates a user callback function with the timer’s interrupt, and powers up and starts the timer. */
bool R_CMT_CreatePeriodic(uint32_t frequency_hz, void(*callback)(void *pdata), uint32_t *channel) | {
return cmt_create(frequency_hz, callback, CMT_RX_MODE_PERIODIC, channel);
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* this function is a POSIX compliant version, which will return a pointer to a dirent structure representing the next directory entry in the directory stream. */ | struct dirent* readdir(DIR *d) | /* this function is a POSIX compliant version, which will return a pointer to a dirent structure representing the next directory entry in the directory stream. */
struct dirent* readdir(DIR *d) | {
int result;
struct dfs_file *fd;
fd = fd_get(d->fd);
if (fd == NULL)
{
rt_set_errno(-EBADF);
return NULL;
}
if (d->num)
{
struct dirent *dirent_ptr;
dirent_ptr = (struct dirent *)&d->buf[d->cur];
d->cur += dirent_ptr->d_reclen;
}
if (!d->... | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* USART Return Interrupt Source.
Returns true if the specified interrupt flag (IDLE, RXNE, TC, TXE or OE) was set and the interrupt was enabled. If the specified flag is not an interrupt flag, the function returns false. */ | bool usart_get_interrupt_source(uint32_t usart, uint32_t flag) | /* USART Return Interrupt Source.
Returns true if the specified interrupt flag (IDLE, RXNE, TC, TXE or OE) was set and the interrupt was enabled. If the specified flag is not an interrupt flag, the function returns false. */
bool usart_get_interrupt_source(uint32_t usart, uint32_t flag) | {
uint32_t flag_set = (USART_SR(usart) & flag);
if ((flag >= USART_SR_IDLE) && (flag <= USART_SR_TXE)) {
return ((flag_set & USART_CR1(usart)) != 0);
} else if (flag == USART_SR_ORE) {
return flag_set && (USART_CR3(usart) & USART_CR3_CTSIE);
}
return false;
} | insane-adding-machines/unicore-mx | C++ | GNU General Public License v3.0 | 50 |
/* Registers a callback.
Registers a callback function which is implemented by the user. */ | void m2m_register_callback(struct m2m_module *const m2m, m2m_callback_t callback, enum m2m_callback_type type) | /* Registers a callback.
Registers a callback function which is implemented by the user. */
void m2m_register_callback(struct m2m_module *const m2m, m2m_callback_t callback, enum m2m_callback_type type) | {
Assert(m2m);
Assert(callback);
if (type < M2M_CALLBACK_N) {
m2m->callbacks[type] = callback;
}
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* Write the hash length to the SHA/MD5 module. */ | void SHAMD5DataLengthSet(uint32_t ui32Base, uint32_t ui32Length) | /* Write the hash length to the SHA/MD5 module. */
void SHAMD5DataLengthSet(uint32_t ui32Base, uint32_t ui32Length) | {
ASSERT(ui32Base == SHAMD5_BASE);
HWREG(ui32Base + SHAMD5_O_LENGTH) = ui32Length;
} | micropython/micropython | C++ | Other | 18,334 |
/* DAC MSP Initialization This function configures the hardware resources used in this example: */ | void HAL_DAC_MspInit(DAC_HandleTypeDef *hdac) | /* DAC MSP Initialization This function configures the hardware resources used in this example: */
void HAL_DAC_MspInit(DAC_HandleTypeDef *hdac) | {
GPIO_InitTypeDef GPIO_InitStruct;
DACx_CHANNEL_GPIO_CLK_ENABLE();
DACx_CLK_ENABLE();
GPIO_InitStruct.Pin = DACx_CHANNEL_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(DACx_CHANNEL_GPIO_PORT, &GPIO_InitStruct);
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* We've collected all the stats we can in software already. Now it's time to update those kept on-card and return the lot. */ | static struct net_device_stats * mc32_get_stats(struct net_device *dev) | /* We've collected all the stats we can in software already. Now it's time to update those kept on-card and return the lot. */
static struct net_device_stats * mc32_get_stats(struct net_device *dev) | {
mc32_update_stats(dev);
return &dev->stats;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France, Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod, 91893 Orsay, France */ | static int compressed_guarded_poly_bound(__isl_take isl_basic_set *bset, __isl_take isl_qpolynomial *poly, void *user) | /* Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France, Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod, 91893 Orsay, France */
static int compressed_guarded_poly_bound(__isl_take isl_basic_set *bset, __isl_take isl_qpolynomial *poly, void *user) | {
struct isl_bound *bound = (struct isl_bound *)user;
int bounded;
if (!bset || !poly)
goto error;
if (bset->ctx->opt->bound == ISL_BOUND_RANGE)
return isl_qpolynomial_bound_on_domain_range(bset, poly, bound);
bounded = isl_basic_set_is_bounded(bset);
if (bounded < 0)
goto error;
if (bounded)
return isl_... | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* This function is used for copying received stream to 16 bit in little endian format.
STREAM_TO_UINT16_f */ | UINT16 STREAM_TO_UINT16_f(CHAR *p, UINT16 offset) | /* This function is used for copying received stream to 16 bit in little endian format.
STREAM_TO_UINT16_f */
UINT16 STREAM_TO_UINT16_f(CHAR *p, UINT16 offset) | {
return (UINT16)((UINT16)((UINT16)
(*(p + offset + 1)) << 8) + (UINT16)(*(p + offset)));
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Writes a number of bytes, at most
If */ | size_t __write(int handle, const unsigned char *buffer, size_t size) | /* Writes a number of bytes, at most
If */
size_t __write(int handle, const unsigned char *buffer, size_t size) | {
size_t nChars = 0;
if (buffer == 0)
{
return 0;
}
if (handle != _LLIO_STDOUT && handle != _LLIO_STDERR)
{
return _LLIO_ERROR;
}
for (; size != 0; --size)
{
if (usart_putchar(stdio_usart_base, *buffer++) < 0)
{
return _LLIO_ERROR;
}
++nChars;
}
return nChars;
} | apopple/Pandaboard-FreeRTOS | C++ | null | 25 |
/* The Intel PIIX4 pirq rules are fairly simple: "pirq" is just a pointer to the config space. */ | static int pirq_piix_get(struct pci_dev *router, struct pci_dev *dev, int pirq) | /* The Intel PIIX4 pirq rules are fairly simple: "pirq" is just a pointer to the config space. */
static int pirq_piix_get(struct pci_dev *router, struct pci_dev *dev, int pirq) | {
u8 x;
pci_read_config_byte(router, pirq, &x);
return (x < 16) ? x : 0;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Make ther structure we read from the beacon packet has the right values */ | static int libipw_verify_qos_info(struct libipw_qos_information_element *info_element, int sub_type) | /* Make ther structure we read from the beacon packet has the right values */
static int libipw_verify_qos_info(struct libipw_qos_information_element *info_element, int sub_type) | {
if (info_element->qui_subtype != sub_type)
return -1;
if (memcmp(info_element->qui, qos_oui, QOS_OUI_LEN))
return -1;
if (info_element->qui_type != QOS_OUI_TYPE)
return -1;
if (info_element->version != QOS_VERSION_1)
return -1;
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Command response callback function for sd_ble_gattc_hv_confirm BLE command.
Callback for decoding the command response return code. */ | static uint32_t gattc_hv_confirm_rsp_dec(const uint8_t *p_buffer, uint16_t length) | /* Command response callback function for sd_ble_gattc_hv_confirm BLE command.
Callback for decoding the command response return code. */
static uint32_t gattc_hv_confirm_rsp_dec(const uint8_t *p_buffer, uint16_t length) | {
uint32_t result_code;
const uint32_t err_code = ble_gattc_hv_confirm_rsp_dec(p_buffer, length, &result_code);
APP_ERROR_CHECK(err_code);
return result_code;
} | labapart/polymcu | C++ | null | 201 |
/* Patch a character at the beginning of a string. */ | VOID EFIAPI PatchForAsciiStrTokenBefore(IN CHAR8 *Buffer, IN CHAR8 Patch) | /* Patch a character at the beginning of a string. */
VOID EFIAPI PatchForAsciiStrTokenBefore(IN CHAR8 *Buffer, IN CHAR8 Patch) | {
CHAR8 *Str;
if (Buffer == NULL) {
return;
}
Str = Buffer;
while (*(Str--) != '\0') {
if ((*Str == 0) || (*Str == Patch)) {
*Str = Patch;
} else {
break;
}
}
return;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* ufshcd_memory_alloc - allocate memory for host memory space data structures */ | static int ufshcd_memory_alloc(struct ufs_hba *hba) | /* ufshcd_memory_alloc - allocate memory for host memory space data structures */
static int ufshcd_memory_alloc(struct ufs_hba *hba) | {
hba->utrdl = memalign(1024, sizeof(struct utp_transfer_req_desc));
if (!hba->utrdl) {
dev_err(hba->dev, "Transfer Descriptor memory allocation failed\n");
return -ENOMEM;
}
hba->ucdl = memalign(1024, sizeof(struct utp_transfer_cmd_desc));
if (!hba->ucdl) {
dev_err(hba->dev, "Command descriptor memory alloc... | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Populate pipe descriptors for copying to/from pipe buffer.
This routine is only called if the pipe buffer is not empty (when reading), or if not full (when writing). */ | static size_t pipe_buffer_list_populate(sys_dlist_t *list, struct _pipe_desc *desc, unsigned char *buffer, size_t size, size_t start, size_t end) | /* Populate pipe descriptors for copying to/from pipe buffer.
This routine is only called if the pipe buffer is not empty (when reading), or if not full (when writing). */
static size_t pipe_buffer_list_populate(sys_dlist_t *list, struct _pipe_desc *desc, unsigned char *buffer, size_t size, size_t start, size_t end) | {
sys_dlist_append(list, &desc[0].node);
desc[0].thread = NULL;
desc[0].buffer = &buffer[start];
if (start < end) {
desc[0].bytes_to_xfer = end - start;
return end - start;
}
desc[0].bytes_to_xfer = size - start;
desc[1].thread = NULL;
desc[1].buffer = &buffer[0];
desc[1].bytes_to_xfer = end;
sys_dlist_ap... | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Function used by tinflate_partial to write a byte to an address in the output buffer here it is implemented to directly write to the object memory of the d11 core */ | void tinflate_write_objmem(void *out_base, unsigned long idx, unsigned char value) | /* Function used by tinflate_partial to write a byte to an address in the output buffer here it is implemented to directly write to the object memory of the d11 core */
void tinflate_write_objmem(void *out_base, unsigned long idx, unsigned char value) | {
wlc_bmac_write_objmem_byte((struct wlc_hw_info *) out_base, idx, value, OBJADDR_UCM_SEL);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Map the v4 IP address into v6 IP address. */ | VOID IScsiMapV4ToV6Addr(IN EFI_IPv4_ADDRESS *V4, OUT EFI_IPv6_ADDRESS *V6) | /* Map the v4 IP address into v6 IP address. */
VOID IScsiMapV4ToV6Addr(IN EFI_IPv4_ADDRESS *V4, OUT EFI_IPv6_ADDRESS *V6) | {
UINTN Index;
ZeroMem (V6, sizeof (EFI_IPv6_ADDRESS));
V6->Addr[10] = 0xff;
V6->Addr[11] = 0xff;
for (Index = 0; Index < 4; Index++) {
V6->Addr[12 + Index] = V4->Addr[Index];
}
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Executes an SMBUS read data byte command on the SMBUS device specified by SmBusAddress. Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. The 8-bit value read from the SMBUS is returned. If Status is not NULL, then the status of the executed command is returned in Status. If Length ... | UINT8 EFIAPI S3SmBusReadDataByte(IN UINTN SmBusAddress, OUT RETURN_STATUS *Status OPTIONAL) | /* Executes an SMBUS read data byte command on the SMBUS device specified by SmBusAddress. Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. The 8-bit value read from the SMBUS is returned. If Status is not NULL, then the status of the executed command is returned in Status. If Length ... | {
UINT8 Byte;
Byte = SmBusReadDataByte (SmBusAddress, Status);
InternalSaveSmBusExecToBootScript (EfiSmbusReadByte, SmBusAddress, 1, &Byte);
return Byte;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* The LSB of all start and end addresses in the node map is the value of the maximum possible shift. */ | static int __init extract_lsb_from_nodes(const struct bootnode *nodes, int numnodes) | /* The LSB of all start and end addresses in the node map is the value of the maximum possible shift. */
static int __init extract_lsb_from_nodes(const struct bootnode *nodes, int numnodes) | {
int i, nodes_used = 0;
unsigned long start, end;
unsigned long bitfield = 0, memtop = 0;
for (i = 0; i < numnodes; i++) {
start = nodes[i].start;
end = nodes[i].end;
if (start >= end)
continue;
bitfield |= start;
nodes_used++;
if (end > memtop)
memtop = end;
}
if (nodes_used <= 1)
i = 63;
e... | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Pop a message referring to file access off the statusbar. */ | static void statusbar_pop_file_msg(void) | /* Pop a message referring to file access off the statusbar. */
static void statusbar_pop_file_msg(void) | {
if (status_levels[STATUS_LEVEL_FILE] > 0) {
status_levels[STATUS_LEVEL_FILE]--;
}
gtk_statusbar_pop(GTK_STATUSBAR(info_bar), file_ctx);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* This routine will get the first valid Completion Queue Entry from @q, update the queue's internal hba index, and return the CQE. If no valid CQEs are in the Queue (no more work to do), or the Queue is full of CQEs that have been processed, but not popped back to the HBA then this routine will return NULL. */ | static struct lpfc_cqe* lpfc_sli4_cq_get(struct lpfc_queue *q) | /* This routine will get the first valid Completion Queue Entry from @q, update the queue's internal hba index, and return the CQE. If no valid CQEs are in the Queue (no more work to do), or the Queue is full of CQEs that have been processed, but not popped back to the HBA then this routine will return NULL. */
static... | {
struct lpfc_cqe *cqe;
if (!bf_get(lpfc_cqe_valid, q->qe[q->hba_index].cqe))
return NULL;
if (((q->hba_index + 1) % q->entry_count) == q->host_index)
return NULL;
cqe = q->qe[q->hba_index].cqe;
q->hba_index = ((q->hba_index + 1) % q->entry_count);
return cqe;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Reconfigure UART console for changed MCK and baudrate. */ | static void reconfigure_console(uint32_t ul_mck, uint32_t ul_baudrate) | /* Reconfigure UART console for changed MCK and baudrate. */
static void reconfigure_console(uint32_t ul_mck, uint32_t ul_baudrate) | {
const sam_uart_opt_t uart_console_settings =
{ ul_mck, ul_baudrate, UART_MR_PAR_NO };
pmc_enable_periph_clk(CONSOLE_UART_ID);
pio_configure_pin_group(PINS_UART_PIO, PINS_UART_PORT,
PINS_UART_FLAGS);
uart_init(CONF_UART, &uart_console_settings);
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* USBH_LL_GetURBState Get a URB state from the low level driver. */ | USBH_URBStateTypeDef USBH_LL_GetURBState(USBH_HandleTypeDef *phost, uint8_t pipe) | /* USBH_LL_GetURBState Get a URB state from the low level driver. */
USBH_URBStateTypeDef USBH_LL_GetURBState(USBH_HandleTypeDef *phost, uint8_t pipe) | {
UNUSED(phost);
UNUSED(pipe);
return USBH_URB_IDLE;
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* Search list of net-interfaces for an interface with given name. */ | isdn_net_dev* isdn_net_findif(char *name) | /* Search list of net-interfaces for an interface with given name. */
isdn_net_dev* isdn_net_findif(char *name) | {
isdn_net_dev *p = dev->netdev;
while (p) {
if (!strcmp(p->dev->name, name))
return p;
p = (isdn_net_dev *) p->next;
}
return (isdn_net_dev *) NULL;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* ZigBee ZCL Pressure Measurement cluster dissector for wireshark. */ | static int dissect_zbee_zcl_press_meas(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) | /* ZigBee ZCL Pressure Measurement cluster dissector for wireshark. */
static int dissect_zbee_zcl_press_meas(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) | {
return tvb_captured_length(tvb);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* when this function is called. preemption or interrupt must be disabled */ | u32 crypto4xx_get_n_gd(struct crypto4xx_device *dev, int n) | /* when this function is called. preemption or interrupt must be disabled */
u32 crypto4xx_get_n_gd(struct crypto4xx_device *dev, int n) | {
u32 retval;
u32 tmp;
if (n >= PPC4XX_NUM_GD)
return ERING_WAS_FULL;
retval = dev->gdr_head;
tmp = (dev->gdr_head + n) % PPC4XX_NUM_GD;
if (dev->gdr_head > dev->gdr_tail) {
if (tmp < dev->gdr_head && tmp >= dev->gdr_tail)
return ERING_WAS_FULL;
} else if (dev->gdr_head < dev->gdr_tail) {
if (tmp < dev-... | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Gets interrupt status for the specified ADC module. */ | uint32_t ADCIntStatusEx(uint32_t ui32Base, bool bMasked) | /* Gets interrupt status for the specified ADC module. */
uint32_t ADCIntStatusEx(uint32_t ui32Base, bool bMasked) | {
uint32_t ui32Temp;
ASSERT((ui32Base == ADC0_BASE) || (ui32Base == ADC1_BASE));
if(bMasked)
{
ui32Temp = HWREG(ui32Base + ADC_O_ISC);
}
else
{
ui32Temp = HWREG(ui32Base + ADC_O_RIS);
if(ui32Temp & ADC_RIS_INRDC)
{
ui32Temp |= (ADC_INT_DCON_SS3 | A... | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Erase one invalid page according to two invalid physical page. */ | static void _eeprom_emulator_erase_invalid_page(uint16_t pre_phy_page, uint16_t next_phy_page) | /* Erase one invalid page according to two invalid physical page. */
static void _eeprom_emulator_erase_invalid_page(uint16_t pre_phy_page, uint16_t next_phy_page) | {
if(_eeprom_emulator_is_full_row(pre_phy_page)) {
_eeprom_emulator_nvm_erase_row(pre_phy_page/4);
} else {
_eeprom_emulator_nvm_erase_row(next_phy_page/4);
}
} | memfault/zero-to-main | C++ | null | 200 |
/* Modified by the GLib Team and others 1997-2000. See the AUTHORS file for a list of people on the GLib Team. See the ChangeLog files for a list of changes. These files are distributed with GLib at */ | void g_printerr(const gchar *format,...) | /* Modified by the GLib Team and others 1997-2000. See the AUTHORS file for a list of people on the GLib Team. See the ChangeLog files for a list of changes. These files are distributed with GLib at */
void g_printerr(const gchar *format,...) | {
va_list args;
va_start (args, format);
vfprintf (stderr, format, args);
va_end (args);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Fills each USI_UARTInitStruct member with its default value. */ | void USI_UARTStructInit(USI_UARTInitTypeDef *USI_UARTInitStruct) | /* Fills each USI_UARTInitStruct member with its default value. */
void USI_UARTStructInit(USI_UARTInitTypeDef *USI_UARTInitStruct) | {
USI_UARTInitStruct->USI_UARTParity = USI_RUART_PARITY_ENABLE;
USI_UARTInitStruct->USI_UARTParityType = USI_RUART_ODD_PARITY;
USI_UARTInitStruct->USI_UARTStickParity = USI_RUART_STICK_PARITY_DISABLE;
USI_UARTInitStruct->USI_UARTStopBit = USI_RUART_STOP_BIT_1;
USI_UARTInitStruct->USI_UARTWordLen ... | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Selects the data transfer direction in bi-directional mode for the specified SPI. */ | void SPI_BiDirectionalLineConfig(SPI_TypeDef *SPIx, uint16_t SPI_Direction) | /* Selects the data transfer direction in bi-directional mode for the specified SPI. */
void SPI_BiDirectionalLineConfig(SPI_TypeDef *SPIx, uint16_t SPI_Direction) | {
assert_param(IS_SPI_ALL_PERIPH(SPIx));
assert_param(IS_SPI_DIRECTION(SPI_Direction));
if (SPI_Direction == SPI_Direction_Tx)
{
SPIx->CR1 |= SPI_Direction_Tx;
}
else
{
SPIx->CR1 &= SPI_Direction_Rx;
}
} | gcallipo/RadioDSP-Stm32f103 | C++ | Common Creative - Attribution 3.0 | 51 |
/* Get Random Address.
This funtions is used to get the randomly generated address. */ | void adi_ble_GetRandomAddress(ADI_BLER_CONFIG_ADDR *pRandomAddress) | /* Get Random Address.
This funtions is used to get the randomly generated address. */
void adi_ble_GetRandomAddress(ADI_BLER_CONFIG_ADDR *pRandomAddress) | {
ASSERT(pRandomAddress != NULL);
memcpy(pRandomAddress, &pBLERadio->sRandomAddress, sizeof(ADI_BLER_CONFIG_ADDR));
} | analogdevicesinc/EVAL-ADICUP3029 | C++ | Other | 36 |
/* 16-bit packed samples => RGBA w/ unassociated alpha (known to have Map == NULL) */ | DECLAREContigPutFunc(putRGBUAcontig16bittile) | /* 16-bit packed samples => RGBA w/ unassociated alpha (known to have Map == NULL) */
DECLAREContigPutFunc(putRGBUAcontig16bittile) | {
int samplesperpixel = img->samplesperpixel;
uint16 *wp = (uint16 *)pp;
(void) y;
fromskew *= samplesperpixel;
for( ; h > 0; --h) {
uint32 r,g,b,a;
uint8* m;
for (x = w; x > 0; --x) {
a = img->Bitdepth16To8[wp[3]];
m = img->UaToAa+((size_t) a<<8);
r = m[img->Bitdepth16To8[wp[0]]];
g = m[img->Bit... | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Return: 0 if all went well, else returns appropriate error value. */ | static int ti_sci_cmd_get_clock(const struct ti_sci_handle *handle, u32 dev_id, u8 clk_id, bool needs_ssc, bool can_change_freq, bool enable_input_term) | /* Return: 0 if all went well, else returns appropriate error value. */
static int ti_sci_cmd_get_clock(const struct ti_sci_handle *handle, u32 dev_id, u8 clk_id, bool needs_ssc, bool can_change_freq, bool enable_input_term) | {
u32 flags = 0;
flags |= needs_ssc ? MSG_FLAG_CLOCK_ALLOW_SSC : 0;
flags |= can_change_freq ? MSG_FLAG_CLOCK_ALLOW_FREQ_CHANGE : 0;
flags |= enable_input_term ? MSG_FLAG_CLOCK_INPUT_TERM : 0;
return ti_sci_set_clock_state(handle, dev_id, clk_id, flags,
MSG_CLOCK_SW_STATE_REQ);
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Returns: a newly allocated string containing the requested identfier, or NULL if the #GDrive doesn't have this kind of identifier. */ | char* g_drive_get_identifier(GDrive *drive, const char *kind) | /* Returns: a newly allocated string containing the requested identfier, or NULL if the #GDrive doesn't have this kind of identifier. */
char* g_drive_get_identifier(GDrive *drive, const char *kind) | {
GDriveIface *iface;
g_return_val_if_fail (G_IS_DRIVE (drive), NULL);
g_return_val_if_fail (kind != NULL, NULL);
iface = G_DRIVE_GET_IFACE (drive);
if (iface->get_identifier == NULL)
return NULL;
return (* iface->get_identifier) (drive, kind);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Waits for as per specified amount of time for the "result" to match with "done" */ | static int handshake(uint32_t volatile *ptr, uint32_t mask, uint32_t done, int usec) | /* Waits for as per specified amount of time for the "result" to match with "done" */
static int handshake(uint32_t volatile *ptr, uint32_t mask, uint32_t done, int usec) | {
uint32_t result;
do {
result = xhci_readl(ptr);
if (result == ~(uint32_t)0)
return -ENODEV;
result &= mask;
if (result == done)
return 0;
usec--;
udelay(1);
} while (usec > 0);
return -ETIMEDOUT;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Configures the Ethernet MAC PPS output in command mode.
To use command mode, an application must call this function to enable the mode, then call: */ | void EMACTimestampPPSCommandModeSet(uint32_t ui32Base, uint32_t ui32Config) | /* Configures the Ethernet MAC PPS output in command mode.
To use command mode, an application must call this function to enable the mode, then call: */
void EMACTimestampPPSCommandModeSet(uint32_t ui32Base, uint32_t ui32Config) | {
ASSERT(ui32Base == EMAC0_BASE);
ASSERT(!(ui32Config & (EMAC_PPS_TARGET_INT | EMAC_PPS_TARGET_PPS |
EMAC_PPS_TARGET_BOTH)));
while(HWREG(ui32Base + EMAC_O_PPSCTRL) & EMAC_PPSCTRL_PPSCTRL_M)
{
}
HWREG(ui32Base + EMAC_O_PPSCTRL) = (EMAC_PPSCTRL_PPSEN0 | ui32Config);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Gets the current value of the SysTick counter.
This function returns the current value of the SysTick counter; this will be a value between the period - 1 and zero, inclusive. */ | unsigned long xSysTickValueGet(void) | /* Gets the current value of the SysTick counter.
This function returns the current value of the SysTick counter; this will be a value between the period - 1 and zero, inclusive. */
unsigned long xSysTickValueGet(void) | {
return(xHWREG(NVIC_ST_CURRENT));
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* __vxge_hw_device_register_poll Will poll certain register for specified amount of time. Will poll until masked bit is not cleared. */ | enum vxge_hw_status __vxge_hw_device_register_poll(void __iomem *reg, u64 mask, u32 max_millis) | /* __vxge_hw_device_register_poll Will poll certain register for specified amount of time. Will poll until masked bit is not cleared. */
enum vxge_hw_status __vxge_hw_device_register_poll(void __iomem *reg, u64 mask, u32 max_millis) | {
u64 val64;
u32 i = 0;
enum vxge_hw_status ret = VXGE_HW_FAIL;
udelay(10);
do {
val64 = readq(reg);
if (!(val64 & mask))
return VXGE_HW_OK;
udelay(100);
} while (++i <= 9);
i = 0;
do {
val64 = readq(reg);
if (!(val64 & mask))
return VXGE_HW_OK;
mdelay(1);
} while (++i <= max_millis);
return... | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Read a line of string from receiving buffer. */ | unsigned char BTReadLine(char *pData) | /* Read a line of string from receiving buffer. */
unsigned char BTReadLine(char *pData) | {
unsigned char ucLineLen = 0;
unsigned long ulTimeOut = TEL0026_TIMEOUT_LONG;
while(ulTimeOut && (s_ucLinesCnt == 0))
{
if(--ulTimeOut == 0)
return 0;
}
s_ucLinesCnt--;
while(s_cUartRecBuffer[ucHead]!='\r')
{
*pData++ = s_cUartRecBuffer[ucHead++];
if(ucHead == UART_RXD_BUFFER_SIZE)
ucHead = 0;
u... | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* Return non-zero if both readings show that the pen is down. */ | static bool get_down(unsigned long data0, unsigned long data1) | /* Return non-zero if both readings show that the pen is down. */
static bool get_down(unsigned long data0, unsigned long data1) | {
return (!(data0 & S3C2410_ADCDAT0_UPDOWN) &&
!(data1 & S3C2410_ADCDAT0_UPDOWN));
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Handle set the alternate setting of a interface request.
This function is used to handle set the alternate setting of a interface request. */ | static usb_status_t USB_DeviceCh9SetInterface(usb_device_handle handle, usb_setup_struct_t *setup, uint8_t **buffer, uint32_t *length) | /* Handle set the alternate setting of a interface request.
This function is used to handle set the alternate setting of a interface request. */
static usb_status_t USB_DeviceCh9SetInterface(usb_device_handle handle, usb_setup_struct_t *setup, uint8_t **buffer, uint32_t *length) | {
uint8_t state;
USB_DeviceGetStatus(handle, kUSB_DeviceStatusDeviceState, &state);
if (state != kUSB_DeviceStateConfigured)
{
return kStatus_USB_InvalidRequest;
}
return USB_DeviceSetInterface(handle, (setup->wIndex & 0xFFU), (setup->wValue & 0xFFU));
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Enables or disables the VBAT (Voltage Battery) channel. */ | void ADC_VBATCmd(FunctionalState NewState) | /* Enables or disables the VBAT (Voltage Battery) channel. */
void ADC_VBATCmd(FunctionalState NewState) | {
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
ADC->CCR |= (uint32_t)ADC_CCR_VBATE;
}
else
{
ADC->CCR &= (uint32_t)(~ADC_CCR_VBATE);
}
} | MaJerle/stm32f429 | C++ | null | 2,036 |
/* disable the function that stop the read wait process(SD I/O only) */ | void sdio_stop_readwait_disable(void) | /* disable the function that stop the read wait process(SD I/O only) */
void sdio_stop_readwait_disable(void) | {
SDIO_DATACTL &= ~SDIO_DATACTL_RWSTOP;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* param base USART peripheral base address param handle Pointer to usart_dma_handle_t structure */ | void USART_TransferAbortSendDMA(USART_Type *base, usart_dma_handle_t *handle) | /* param base USART peripheral base address param handle Pointer to usart_dma_handle_t structure */
void USART_TransferAbortSendDMA(USART_Type *base, usart_dma_handle_t *handle) | {
assert(NULL != handle);
assert(NULL != handle->txDmaHandle);
DMA_AbortTransfer(handle->txDmaHandle);
handle->txState = (uint8_t)kUSART_TxIdle;
} | ARMmbed/DAPLink | C++ | Apache License 2.0 | 2,140 |
/* Write two datas element to the SPI interface. */ | void SPIBurstDataWrite(unsigned long ulBase, unsigned long *pulData) | /* Write two datas element to the SPI interface. */
void SPIBurstDataWrite(unsigned long ulBase, unsigned long *pulData) | {
xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE));
while((xHWREG(ulBase + SPI_CNTRL) & SPI_CNTRL_GO_BUSY))
{
}
xHWREG(ulBase + SPI_TX0) = pulData[0];
xHWREG(ulBase + SPI_TX1) = pulData[1];
xHWREG(ulBase + SPI_CNTRL) |= SPI_CNTRL_GO_BUSY;
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* Called by the eraser function, which knows how many character columns have been used since either a previous tab or the start of input. This information will be used later, along with canon column (if applicable), to go back the correct number of columns. */ | static void echo_erase_tab(unsigned int num_chars, int after_tab, struct n_tty_data *ldata) | /* Called by the eraser function, which knows how many character columns have been used since either a previous tab or the start of input. This information will be used later, along with canon column (if applicable), to go back the correct number of columns. */
static void echo_erase_tab(unsigned int num_chars, int af... | {
add_echo_byte(ECHO_OP_START, ldata);
add_echo_byte(ECHO_OP_ERASE_TAB, ldata);
num_chars &= 7;
if (after_tab)
{
num_chars |= 0x80;
}
add_echo_byte(num_chars, ldata);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* This function creates a new device node in a newly allocated buffer of size NodeLength and initializes the device path node header with NodeType and NodeSubType. The new device path node is returned. If NodeLength is smaller than a device path header, then NULL is returned. If there is not enough memory to allocate ... | EFI_DEVICE_PATH_PROTOCOL* EFIAPI UefiDevicePathLibCreateDeviceNode(IN UINT8 NodeType, IN UINT8 NodeSubType, IN UINT16 NodeLength) | /* This function creates a new device node in a newly allocated buffer of size NodeLength and initializes the device path node header with NodeType and NodeSubType. The new device path node is returned. If NodeLength is smaller than a device path header, then NULL is returned. If there is not enough memory to allocate ... | {
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
if (NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL)) {
return NULL;
}
DevicePath = AllocateZeroPool (NodeLength);
if (DevicePath != NULL) {
DevicePath->Type = NodeType;
DevicePath->SubType = NodeSubType;
SetDevicePathNodeLength (DevicePath, NodeLength... | tianocore/edk2 | C++ | Other | 4,240 |
/* Set SPI interrupt bus tx done handler if needed. */ | void spi_bus_tx_done_irq_hook(spi_t *obj, spi_irq_handler handler, uint32_t id) | /* Set SPI interrupt bus tx done handler if needed. */
void spi_bus_tx_done_irq_hook(spi_t *obj, spi_irq_handler handler, uint32_t id) | {
obj->bus_tx_done_handler = (u32)handler;
obj->bus_tx_done_irq_id = (u32)id;
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* A private routine to initialize the multi-step elements of an edge structure */ | static void _pixman_edge_multi_init(pixman_edge_t *e, int n, pixman_fixed_t *stepx_p, pixman_fixed_t *dx_p) | /* A private routine to initialize the multi-step elements of an edge structure */
static void _pixman_edge_multi_init(pixman_edge_t *e, int n, pixman_fixed_t *stepx_p, pixman_fixed_t *dx_p) | {
pixman_fixed_t stepx;
pixman_fixed_48_16_t ne;
ne = n * (pixman_fixed_48_16_t) e->dx;
stepx = n * e->stepx;
if (ne > 0)
{
int nx = ne / e->dy;
ne -= nx * (pixman_fixed_48_16_t)e->dy;
stepx += nx * e->signdx;
}
*dx_p = ne;
*stepx_p = stepx;
} | xboot/xboot | C++ | MIT License | 779 |
/* Returns whether the specified processor is the BSP. */ | STATIC BOOLEAN IsProcessorBSP(UINTN ProcessorIndex) | /* Returns whether the specified processor is the BSP. */
STATIC BOOLEAN IsProcessorBSP(UINTN ProcessorIndex) | {
EFI_PROCESSOR_INFORMATION *CpuInfo;
CpuInfo = &mCpuMpData.CpuData[ProcessorIndex].Info;
return (CpuInfo->StatusFlag & PROCESSOR_AS_BSP_BIT) != 0;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Similar to xfs_trans_inode_buf(), this marks the buffer as a cluster of dquots. However, unlike in inode buffer recovery, dquot buffers get recovered in their entirety. (Hence, no XFS_BLI_DQUOT_ALLOC_BUF flag). The only thing that makes dquot buffers different from regular buffers is that we must not replay dquot bu... | void xfs_trans_dquot_buf(xfs_trans_t *tp, xfs_buf_t *bp, uint type) | /* Similar to xfs_trans_inode_buf(), this marks the buffer as a cluster of dquots. However, unlike in inode buffer recovery, dquot buffers get recovered in their entirety. (Hence, no XFS_BLI_DQUOT_ALLOC_BUF flag). The only thing that makes dquot buffers different from regular buffers is that we must not replay dquot bu... | {
xfs_buf_log_item_t *bip;
ASSERT(XFS_BUF_ISBUSY(bp));
ASSERT(XFS_BUF_FSPRIVATE2(bp, xfs_trans_t *) == tp);
ASSERT(XFS_BUF_FSPRIVATE(bp, void *) != NULL);
ASSERT(type == XFS_BLI_UDQUOT_BUF ||
type == XFS_BLI_PDQUOT_BUF ||
type == XFS_BLI_GDQUOT_BUF);
bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t ... | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Get to know the Rx FIFO is Empty or not from the specified port. */ | xtBoolean UARTFIFORxIsEmpty(unsigned long ulBase) | /* Get to know the Rx FIFO is Empty or not from the specified port. */
xtBoolean UARTFIFORxIsEmpty(unsigned long ulBase) | {
xASSERT(UARTBaseValid(ulBase));
return((xHWREG(ulBase + UART_FSR) & UART_FSR_RX_EF) ? xtrue : xfalse);
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* Get BurstCount by reading the burstCount field of a TIS register in the time of default TIS_TIMEOUT_D. */ | EFI_STATUS Tpm12TisPcReadBurstCount(IN TIS_PC_REGISTERS_PTR TisReg, OUT UINT16 *BurstCount) | /* Get BurstCount by reading the burstCount field of a TIS register in the time of default TIS_TIMEOUT_D. */
EFI_STATUS Tpm12TisPcReadBurstCount(IN TIS_PC_REGISTERS_PTR TisReg, OUT UINT16 *BurstCount) | {
UINT32 WaitTime;
UINT8 DataByte0;
UINT8 DataByte1;
if ((BurstCount == NULL) || (TisReg == NULL)) {
return EFI_INVALID_PARAMETER;
}
WaitTime = 0;
do {
DataByte0 = MmioRead8 ((UINTN)&TisReg->BurstCount);
DataByte1 = MmioRead8 ((UINTN)&TisReg->BurstCount + 1);
*BurstCount = (UINT16... | tianocore/edk2 | C++ | Other | 4,240 |
/* Continue. addr is Address to resume. If addr is omitted, resume at current Address. */ | VOID EFIAPI ContinueAtAddress(IN EFI_SYSTEM_CONTEXT SystemContext, IN CHAR8 *PacketData) | /* Continue. addr is Address to resume. If addr is omitted, resume at current Address. */
VOID EFIAPI ContinueAtAddress(IN EFI_SYSTEM_CONTEXT SystemContext, IN CHAR8 *PacketData) | {
if (PacketData[1] != '\0') {
SystemContext.SystemContextArm->PC = AsciiStrHexToUintn (&PacketData[1]);
}
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Function called at completion of last byte transmission. */ | void USART_CharTransmitComplete_Callback(void) | /* Function called at completion of last byte transmission. */
void USART_CharTransmitComplete_Callback(void) | {
if(ubSend == ubUSART1NbDataToTransmit)
{
LL_USART_DisableIT_TC(USART1);
ubUSART1TransmissionComplete = 1;
}
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* Return value: CAIRO_STATUS_SUCCESS if successful or CAIRO_STATUS_NO_MEMORY if insufficient memory is available for the operation. */ | cairo_status_t _cairo_array_append_multiple(cairo_array_t *array, const void *elements, unsigned int num_elements) | /* Return value: CAIRO_STATUS_SUCCESS if successful or CAIRO_STATUS_NO_MEMORY if insufficient memory is available for the operation. */
cairo_status_t _cairo_array_append_multiple(cairo_array_t *array, const void *elements, unsigned int num_elements) | {
cairo_status_t status;
void *dest;
status = _cairo_array_allocate (array, num_elements, &dest);
if (unlikely (status))
return status;
memcpy (dest, elements, num_elements * array->element_size);
return CAIRO_STATUS_SUCCESS;
} | xboot/xboot | C++ | MIT License | 779 |
/* If 8-bit operations are not supported, then ASSERT(). If StartBit is greater than 7, then ASSERT(). If EndBit is greater than 7, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */ | UINT8 EFIAPI BitFieldOr8(IN UINT8 Operand, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 OrData) | /* If 8-bit operations are not supported, then ASSERT(). If StartBit is greater than 7, then ASSERT(). If EndBit is greater than 7, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT8 EFIAPI BitFieldOr8... | {
ASSERT (EndBit < 8);
ASSERT (StartBit <= EndBit);
return (UINT8)InternalBaseLibBitFieldOrUint (Operand, StartBit, EndBit, OrData);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Used for emergency unfreeze of all filesystems via SysRq */ | void emergency_thaw_all(void) | /* Used for emergency unfreeze of all filesystems via SysRq */
void emergency_thaw_all(void) | {
struct work_struct *work;
work = kmalloc(sizeof(*work), GFP_ATOMIC);
if (work) {
INIT_WORK(work, do_thaw_all);
schedule_work(work);
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Free a SCB structure Note: We assume the scsi commands associated with this scb is not free yet. */ | static void mega_free_scb(adapter_t *adapter, scb_t *scb) | /* Free a SCB structure Note: We assume the scsi commands associated with this scb is not free yet. */
static void mega_free_scb(adapter_t *adapter, scb_t *scb) | {
switch( scb->dma_type ) {
case MEGA_DMA_TYPE_NONE:
break;
case MEGA_SGLIST:
scsi_dma_unmap(scb->cmd);
break;
default:
break;
}
list_del_init(&scb->list);
scb->state = SCB_FREE;
scb->cmd = NULL;
list_add(&scb->list, &adapter->free_list);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* The common constructor function for SMI handler profile. */ | EFI_STATUS MmSmiHandlerProfileLibInitialization(VOID) | /* The common constructor function for SMI handler profile. */
EFI_STATUS MmSmiHandlerProfileLibInitialization(VOID) | {
gMmst->MmLocateProtocol (
&gSmiHandlerProfileGuid,
NULL,
(VOID **)&mSmiHandlerProfile
);
return EFI_SUCCESS;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* The return value is the rounded version of the @j parameter. */ | unsigned long __round_jiffies_relative(unsigned long j, int cpu) | /* The return value is the rounded version of the @j parameter. */
unsigned long __round_jiffies_relative(unsigned long j, int cpu) | {
unsigned long j0 = jiffies;
return round_jiffies_common(j + j0, cpu, false) - j0;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Selects the GPIO pin used as Event output. */ | void GPIO_ConfigEventOutput(uint8_t PortSource, uint8_t PinSource) | /* Selects the GPIO pin used as Event output. */
void GPIO_ConfigEventOutput(uint8_t PortSource, uint8_t PinSource) | {
uint32_t tmpregister = 0x00;
assert_param(IS_GPIO_EVENTOUT_PORT_SOURCE(PortSource));
assert_param(IS_GPIO_PIN_SOURCE(PinSource));
tmpregister = AFIO->ECTRL;
tmpregister &= EVCR_PORTPINCONFIG_MASK;
tmpregister |= (uint32_t)PortSource << 0x04;
tmpregister |= PinSource;
AFIO->ECTRL = tmpr... | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* 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 ... | UINT16 EFIAPI PciExpressBitFieldWrite16(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 ... | {
ASSERT_INVALID_PCI_ADDRESS (Address);
return MmioBitFieldWrite16 (
(UINTN)GetPciExpressBaseAddress () + Address,
StartBit,
EndBit,
Value
);
} | tianocore/edk2 | C++ | Other | 4,240 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.