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 |
|---|---|---|---|---|---|---|---|
/* fast_aes_128_cbc_decrypt - AES-128 CBC decryption @key: Decryption key @iv: Decryption IV for CBC mode (16 bytes) @data: Data to decrypt in-place @data_len: Length of data in bytes (must be divisible by 16) Returns: 0 on success, -1 on failure */ | int fast_aes_128_cbc_decrypt(const uint8_t *key, const uint8_t *iv, uint8_t *data, size_t data_len) | /* fast_aes_128_cbc_decrypt - AES-128 CBC decryption @key: Decryption key @iv: Decryption IV for CBC mode (16 bytes) @data: Data to decrypt in-place @data_len: Length of data in bytes (must be divisible by 16) Returns: 0 on success, -1 on failure */
int fast_aes_128_cbc_decrypt(const uint8_t *key, const uint8_t *iv, uint8_t *data, size_t data_len) | {
int ret = 0;
mbedtls_aes_context ctx;
uint8_t cbc[AES_BLOCK_SIZE];
mbedtls_aes_init(&ctx);
ret = mbedtls_aes_setkey_dec(&ctx, key, 128);
if(ret < 0) {
mbedtls_aes_free(&ctx);
return ret;
}
os_memcpy(cbc, iv, AES_BLOCK_SIZE);
ret = mbedtls_aes_crypt_cbc(&ctx, MBEDTLS_AES_DECRYPT, data_len, cbc, data, data);
mbedtls_aes_free(&ctx);
return ret;
} | retro-esp32/RetroESP32 | C++ | Creative Commons Attribution Share Alike 4.0 International | 581 |
/* Message: SetLampMessage Opcode: 0x0086 Type: CallControl Direction: pbx2dev VarLength: no */ | static void handle_SetLampMessage(ptvcursor_t *cursor, packet_info *pinfo _U_) | /* Message: SetLampMessage Opcode: 0x0086 Type: CallControl Direction: pbx2dev VarLength: no */
static void handle_SetLampMessage(ptvcursor_t *cursor, packet_info *pinfo _U_) | {
ptvcursor_add(cursor, hf_skinny_stimulus, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_stimulusInstance, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_lampMode, 4, ENC_LITTLE_ENDIAN);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* This function extracts poll/final bit from LLC header (based on type of PDU). In I or S pdus, p/f bit is right bit of fourth byte in header. In U pdus p/f bit is fifth bit of third byte. */ | void llc_pdu_decode_pf_bit(struct sk_buff *skb, u8 *pf_bit) | /* This function extracts poll/final bit from LLC header (based on type of PDU). In I or S pdus, p/f bit is right bit of fourth byte in header. In U pdus p/f bit is fifth bit of third byte. */
void llc_pdu_decode_pf_bit(struct sk_buff *skb, u8 *pf_bit) | {
u8 pdu_type;
struct llc_pdu_sn *pdu;
llc_pdu_decode_pdu_type(skb, &pdu_type);
pdu = llc_pdu_sn_hdr(skb);
switch (pdu_type) {
case LLC_PDU_TYPE_I:
case LLC_PDU_TYPE_S:
*pf_bit = pdu->ctrl_2 & LLC_S_PF_BIT_MASK;
break;
case LLC_PDU_TYPE_U:
*pf_bit = (pdu->ctrl_1 & LLC_U_PF_BIT_MASK) >> 4;
break;
}
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Get a device structure from a devicetree node with alias eeprom-0 */ | static const struct device* get_eeprom_device(void) | /* Get a device structure from a devicetree node with alias eeprom-0 */
static const struct device* get_eeprom_device(void) | {
const struct device *const dev = DEVICE_DT_GET(DT_ALIAS(eeprom_0));
if (!device_is_ready(dev)) {
printk("\nError: Device \"%s\" is not ready; "
"check the driver initialization logs for errors.\n",
dev->name);
return NULL;
}
printk("Found EEPROM device \"%s\"\n", dev->name);
return dev;
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* This function returns the TLS/SSL session ID currently used by the specified TLS connection. */ | EFI_STATUS EFIAPI TlsGetSessionId(IN VOID *Tls, IN OUT UINT8 *SessionId, IN OUT UINT16 *SessionIdLen) | /* This function returns the TLS/SSL session ID currently used by the specified TLS connection. */
EFI_STATUS EFIAPI TlsGetSessionId(IN VOID *Tls, IN OUT UINT8 *SessionId, IN OUT UINT16 *SessionIdLen) | {
CALL_CRYPTO_SERVICE (TlsGetSessionId, (Tls, SessionId, SessionIdLen), EFI_UNSUPPORTED);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* This API is used to set the tap sample in the register 0x2B bit 6 and 7. */ | BMA2x2_RETURN_FUNCTION_TYPE bma2x2_set_tap_sample(u8 tap_sample_u8) | /* This API is used to set the tap sample in the register 0x2B bit 6 and 7. */
BMA2x2_RETURN_FUNCTION_TYPE bma2x2_set_tap_sample(u8 tap_sample_u8) | {
u8 data_u8 = BMA2x2_INIT_VALUE;
BMA2x2_RETURN_FUNCTION_TYPE com_rslt = ERROR;
if (p_bma2x2 == BMA2x2_NULL)
{
return E_BMA2x2_NULL_PTR;
}
else
{
com_rslt = p_bma2x2->BMA2x2_BUS_READ_FUNC
(p_bma2x2->dev_addr, BMA2x2_TAP_SAMPLES_REG,
&data_u8, BMA2x2_GEN_READ_WRITE_LENGTH);
data_u8 = BMA2x2_SET_BITSLICE
(data_u8, BMA2x2_TAP_SAMPLES, tap_sample_u8);
com_rslt += bma2x2_write_reg(
BMA2x2_TAP_SAMPLES_REG, &data_u8,
BMA2x2_GEN_READ_WRITE_LENGTH);
}
return com_rslt;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Delete all partitions from parts head list, free memory. */ | static void part_delall(struct list_head *head) | /* Delete all partitions from parts head list, free memory. */
static void part_delall(struct list_head *head) | {
struct list_head *entry, *n;
struct part_info *part_tmp;
list_for_each_safe(entry, n, head) {
part_tmp = list_entry(entry, struct part_info, link);
list_del(entry);
free(part_tmp);
}
} | EmcraftSystems/u-boot | C++ | Other | 181 |
/* Waits until the RTC Time and Date registers (RTC_TSH and RTC_DATE) are synchronized with RTC APB clock. */ | ErrorStatus RTC_WaitForSynchro(void) | /* Waits until the RTC Time and Date registers (RTC_TSH and RTC_DATE) are synchronized with RTC APB clock. */
ErrorStatus RTC_WaitForSynchro(void) | {
__IO uint32_t synchrocounter = 0;
ErrorStatus status = ERROR;
uint32_t synchrostatus = 0x00;
RTC->WRP = 0xCA;
RTC->WRP = 0x53;
RTC->INITSTS &= (uint32_t)RTC_RSF_MASK;
do
{
synchrostatus = RTC->INITSTS & RTC_INITSTS_RSYF;
synchrocounter++;
} while ((synchrocounter != SYNCHRO_TIMEOUT) && (synchrostatus == 0x00));
if ((RTC->INITSTS & RTC_INITSTS_RSYF) != RESET)
{
status = SUCCESS;
}
else
{
status = ERROR;
}
RTC->WRP = 0xFF;
return (status);
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* Free up the transmit ring for this particular velocity adapter. We free the ring contents but not the ring itself. */ | static void velocity_free_td_ring(struct velocity_info *vptr) | /* Free up the transmit ring for this particular velocity adapter. We free the ring contents but not the ring itself. */
static void velocity_free_td_ring(struct velocity_info *vptr) | {
int i, j;
for (j = 0; j < vptr->tx.numq; j++) {
if (vptr->tx.infos[j] == NULL)
continue;
for (i = 0; i < vptr->options.numtx; i++)
velocity_free_td_ring_entry(vptr, j, i);
kfree(vptr->tx.infos[j]);
vptr->tx.infos[j] = NULL;
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Return Value: The 6 most significant bits of the 32-bit CRC result */ | static unsigned portCHAR fec_hash_address(const unsigned portCHAR *addr) | /* Return Value: The 6 most significant bits of the 32-bit CRC result */
static unsigned portCHAR fec_hash_address(const unsigned portCHAR *addr) | {
unsigned portLONG crc;
unsigned portCHAR byte;
int i, j;
crc = 0xFFFFFFFF;
for(i=0; i<6; ++i)
{
byte = addr[i];
for(j=0; j<8; ++j)
{
if((byte & 0x01)^(crc & 0x01))
{
crc >>= 1;
crc = crc ^ 0xEDB88320;
}
else
{
crc >>= 1;
}
byte >>= 1;
}
}
return (unsigned portCHAR)(crc >> 26);
} | apopple/Pandaboard-FreeRTOS | C++ | null | 25 |
/* @start: start address of range operation (don't care for "all" operation) @size: data size of range operation (don't care for "all" operation) @ways: target ways (don't care for operations other than pre-fetch, touch @operation: flags to specify the desired cache operation */ | static void uniphier_cache_maint_common(u32 start, u32 size, u32 ways, u32 operation) | /* @start: start address of range operation (don't care for "all" operation) @size: data size of range operation (don't care for "all" operation) @ways: target ways (don't care for operations other than pre-fetch, touch @operation: flags to specify the desired cache operation */
static void uniphier_cache_maint_common(u32 start, u32 size, u32 ways, u32 operation) | {
writel(UNIPHIER_SSCOLPQS_EF, UNIPHIER_SSCOLPQS);
do {
writel(UNIPHIER_SSCOQM_CE | operation, UNIPHIER_SSCOQM);
if (likely(UNIPHIER_SSCOQAD_IS_NEEDED(operation))) {
writel(start, UNIPHIER_SSCOQAD);
writel(size, UNIPHIER_SSCOQSZ);
}
if (unlikely(UNIPHIER_SSCOQWM_IS_NEEDED(operation)))
writel(ways, UNIPHIER_SSCOQWN);
} while (unlikely(readl(UNIPHIER_SSCOPPQSEF) &
(UNIPHIER_SSCOPPQSEF_FE | UNIPHIER_SSCOPPQSEF_OE)));
while (likely(readl(UNIPHIER_SSCOLPQS) != UNIPHIER_SSCOLPQS_EF))
cpu_relax();
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* For all these reasons, the caller must be prepared for this function to return. The simplest way to handle it is to just enter an infinite loop and wait for the power to be removed. */ | void HibernateRequest(void) | /* For all these reasons, the caller must be prepared for this function to return. The simplest way to handle it is to just enter an infinite loop and wait for the power to be removed. */
void HibernateRequest(void) | {
HWREG(HIB_CTL) |= HIB_CTL_HIBREQ;
HibernateWriteComplete();
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Reads and returns the current value of MM7. This function is only available on IA-32 and X64. */ | UINT64 EFIAPI AsmReadMm7(VOID) | /* Reads and returns the current value of MM7. This function is only available on IA-32 and X64. */
UINT64 EFIAPI AsmReadMm7(VOID) | {
UINT64 Data;
__asm__ __volatile__ (
"push %%eax \n\t"
"push %%eax \n\t"
"movq %%mm7, (%%esp)\n\t"
"pop %%eax \n\t"
"pop %%edx \n\t"
: "=A" (Data)
);
return Data;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Executes "full continuation" (everything in the stack) of a previously interrupted coroutine until the stack is empty (or another interruption long-jumps out of the loop). */ | static void unroll(lua_State *L, void *ud) | /* Executes "full continuation" (everything in the stack) of a previously interrupted coroutine until the stack is empty (or another interruption long-jumps out of the loop). */
static void unroll(lua_State *L, void *ud) | {
if (!isLua(ci))
finishCcall(L, ci);
else {
luaV_finishOp(L);
luaV_execute(L, ci);
}
}
} | Nicholas3388/LuaNode | C++ | Other | 1,055 |
/* Reads data from the specified address on the serial flash. */ | uint8_t s25fl1xx_read_quad(struct qspid_t *qspid, uint32_t *data, uint32_t size, uint32_t address) | /* Reads data from the specified address on the serial flash. */
uint8_t s25fl1xx_read_quad(struct qspid_t *qspid, uint32_t *data, uint32_t size, uint32_t address) | {
uint8_t secure = 0;
mem->inst_frame.bm.b_dummy_cycles = 8;
mem->inst_frame.bm.b_width = QSPI_IFR_WIDTH_QUAD_OUTPUT;
s25fl1xx_memory_access(qspid, S25FL1XX_READ_ARRAY_QUAD, address, 0, data, QSPI_READ_ACCESS, size, secure);
return 0;
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* Select the ACMP- input source of the comparator. */ | void ACMPNegativeSrcSet(unsigned long ulBase, unsigned long ulComp, unsigned long ulSource) | /* Select the ACMP- input source of the comparator. */
void ACMPNegativeSrcSet(unsigned long ulBase, unsigned long ulComp, unsigned long ulSource) | {
unsigned long ulCRAddr;
xASSERT((ulBase == ACMP_BASE));
xASSERT((ulComp >= 0) && (ulComp < 2));
xASSERT((ulSource == ACMP_ASRCN_PIN) || (ulSource == ACMP_ASRCN_REF));
ulCRAddr = ulBase + ACMP_CR0 + (4 * ulComp);
xHWREG(ulCRAddr) &= ~ACMP_CR_CN;
xHWREG(ulCRAddr) |= ulSource;
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* Clear the compare register update interrupt flag (CMPOKCF). @rmtoll ICR CMPOKCF LPTIM_ClearFlag_CMPOK. */ | void LPTIM_ClearFlag_CMPOK(LPTIM_Module *LPTIMx) | /* Clear the compare register update interrupt flag (CMPOKCF). @rmtoll ICR CMPOKCF LPTIM_ClearFlag_CMPOK. */
void LPTIM_ClearFlag_CMPOK(LPTIM_Module *LPTIMx) | {
SET_BIT(LPTIMx->INTCLR, LPTIM_INTCLR_CMPUPDCF);
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* If Length is not aligned on a 32-bit boundary, then ASSERT(). If Buffer is not aligned on a 32-bit boundary, then ASSERT(). */ | UINT32* EFIAPI MmioReadBuffer32(IN UINTN StartAddress, IN UINTN Length, OUT UINT32 *Buffer) | /* If Length is not aligned on a 32-bit boundary, then ASSERT(). If Buffer is not aligned on a 32-bit boundary, then ASSERT(). */
UINT32* EFIAPI MmioReadBuffer32(IN UINTN StartAddress, IN UINTN Length, OUT UINT32 *Buffer) | {
UINT32 *ReturnBuffer;
ASSERT ((StartAddress & (sizeof (UINT32) - 1)) == 0);
ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress));
ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));
ASSERT ((Length & (sizeof (UINT32) - 1)) == 0);
ASSERT (((UINTN)Buffer & (sizeof (UINT32) - 1)) == 0);
ReturnBuffer = Buffer;
while (Length != 0) {
*(Buffer++) = MmioRead32 (StartAddress);
StartAddress += sizeof (UINT32);
Length -= sizeof (UINT32);
}
return ReturnBuffer;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Convert a channel to a frequency (negative -> error) Return the channel on success */ | int iw_channel_to_freq(int channel, double *pfreq, const struct iw_range *range) | /* Convert a channel to a frequency (negative -> error) Return the channel on success */
int iw_channel_to_freq(int channel, double *pfreq, const struct iw_range *range) | {
int has_freq = 0;
int k;
for(k = 0; k < range->num_frequency; k++)
{
if((range->freq[k].e != 0) || (range->freq[k].m > (int) KILO))
has_freq = 1;
}
if(!has_freq)
return(-1);
for(k = 0; k < range->num_frequency; k++)
{
if(range->freq[k].i == channel)
{
*pfreq = iw_freq2float(&(range->freq[k]));
return(channel);
}
}
return(-2);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Adds a new alert to the given category then notifies the client if the given category is valid and enabled. */ | int ble_svc_ans_new_alert_add(uint8_t cat_id, const char *info_str) | /* Adds a new alert to the given category then notifies the client if the given category is valid and enabled. */
int ble_svc_ans_new_alert_add(uint8_t cat_id, const char *info_str) | {
uint8_t cat_bit_mask;
if (cat_id < BLE_SVC_ANS_CAT_NUM) {
cat_bit_mask = (1 << cat_id);
} else {
return BLE_HS_EINVAL;
}
if ((cat_bit_mask & ble_svc_ans_new_alert_cat) == 0) {
return BLE_HS_EINVAL;
}
ble_svc_ans_new_alert_cnt[cat_id] += 1;
return ble_svc_ans_new_alert_notify(cat_id, info_str);
} | arendst/Tasmota | C++ | GNU General Public License v3.0 | 21,318 |
/* Message: FeatureStatV2Message Opcode: 0x0146 Type: RegistrationAndManagement Direction: pbx2dev VarLength: yes */ | static void handle_FeatureStatV2Message(ptvcursor_t *cursor, packet_info *pinfo _U_) | /* Message: FeatureStatV2Message Opcode: 0x0146 Type: RegistrationAndManagement Direction: pbx2dev VarLength: yes */
static void handle_FeatureStatV2Message(ptvcursor_t *cursor, packet_info *pinfo _U_) | {
guint32 featureTextLabel_len = 0;
ptvcursor_add(cursor, hf_skinny_featureIndex, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_featureID, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_featureStatus, 4, ENC_LITTLE_ENDIAN);
featureTextLabel_len = tvb_strnlen(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), -1)+1;
if (featureTextLabel_len > 1) {
ptvcursor_add(cursor, hf_skinny_featureTextLabel, featureTextLabel_len, ENC_ASCII|ENC_NA);
} else {
ptvcursor_advance(cursor, 1);
}
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* param base ITRC peripheral base address return Status of the init operation */ | status_t ITRC_Init(ITRC_Type *base) | /* param base ITRC peripheral base address return Status of the init operation */
status_t ITRC_Init(ITRC_Type *base) | {
NVIC_EnableIRQ(ITRC0_IRQn);
return kStatus_Success;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* param base ADC peripheral base address. param channelGroup Channel group index. param config Pointer to the "adc_channel_config_t" structure for the conversion channel. */ | void ADC_SetChannelConfig(ADC_Type *base, uint32_t channelGroup, const adc_channel_config_t *config) | /* param base ADC peripheral base address. param channelGroup Channel group index. param config Pointer to the "adc_channel_config_t" structure for the conversion channel. */
void ADC_SetChannelConfig(ADC_Type *base, uint32_t channelGroup, const adc_channel_config_t *config) | {
assert(NULL != config);
assert(channelGroup < FSL_FEATURE_ADC_CONVERSION_CONTROL_COUNT);
uint32_t tmp32;
tmp32 = ADC_HC_ADCH(config->channelNumber);
if (config->enableInterruptOnConversionCompleted)
{
tmp32 |= ADC_HC_AIEN_MASK;
}
base->HC[channelGroup] = tmp32;
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* Set the simulated time when the process will stop */ | void hwm_set_end_of_time(uint64_t new_end_of_time) | /* Set the simulated time when the process will stop */
void hwm_set_end_of_time(uint64_t new_end_of_time) | {
end_of_time = new_end_of_time;
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* The code in this function is based on the code from */ | static int lcd_clk_set_rate(struct clk *clk, unsigned long rate) | /* The code in this function is based on the code from */
static int lcd_clk_set_rate(struct clk *clk, unsigned long rate) | {
u32 tmp, prate, div;
tmp = __raw_readl(LPC178X_LCD_BASE + CLCD_TIM2) | TIM2_BCD;
prate = lpc178x_clock_get(CLOCK_CCLK);
if (rate < prate) {
div = prate / rate;
if (div >= 2) {
div -= 2;
tmp &= ~TIM2_BCD;
}
tmp &= ~(0xF800001F);
tmp |= (div & 0x1F);
tmp |= (((div >> 5) & 0x1F) << 27);
}
__raw_writel(tmp, LPC178X_LCD_BASE + CLCD_TIM2);
return 0;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* return pointer to the edac class of 'edac' */ | struct sysdev_class* edac_get_edac_class(void) | /* return pointer to the edac class of 'edac' */
struct sysdev_class* edac_get_edac_class(void) | {
struct sysdev_class *classptr = NULL;
if (edac_class_valid)
classptr = &edac_class;
return classptr;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* ADC Set Scan Mode.
In this mode a conversion consists of a scan of the predefined set of channels, regular and injected, each channel conversion immediately following the previous one. It can use single, continuous or discontinuous mode. */ | void adc_enable_eoc_interrupt_injected(uint32_t adc) | /* ADC Set Scan Mode.
In this mode a conversion consists of a scan of the predefined set of channels, regular and injected, each channel conversion immediately following the previous one. It can use single, continuous or discontinuous mode. */
void adc_enable_eoc_interrupt_injected(uint32_t adc) | {
ADC_IER(adc) |= ADC_IER_JEOCIE;
} | insane-adding-machines/unicore-mx | C++ | GNU General Public License v3.0 | 50 |
/* Refer to SD Host Controller Simplified spec 3.0 Section 3.1 for details. */ | EFI_STATUS EmmcPeimHcCardDetect(IN UINTN Bar) | /* Refer to SD Host Controller Simplified spec 3.0 Section 3.1 for details. */
EFI_STATUS EmmcPeimHcCardDetect(IN UINTN Bar) | {
EFI_STATUS Status;
UINT16 Data;
UINT32 PresentState;
Status = EmmcPeimHcRwMmio (Bar + EMMC_HC_NOR_INT_STS, TRUE, sizeof (Data), &Data);
if (EFI_ERROR (Status)) {
return Status;
}
if ((Data & (BIT6 | BIT7)) != 0) {
Data &= BIT6 | BIT7;
Status = EmmcPeimHcRwMmio (Bar + EMMC_HC_NOR_INT_STS, FALSE, sizeof (Data), &Data);
if (EFI_ERROR (Status)) {
return Status;
}
}
Status = EmmcPeimHcRwMmio (Bar + EMMC_HC_PRESENT_STATE, TRUE, sizeof (PresentState), &PresentState);
if (EFI_ERROR (Status)) {
return Status;
}
if ((PresentState & BIT16) != 0) {
return EFI_SUCCESS;
} else {
return EFI_NO_MEDIA;
}
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Brief This function handles USARTx Instance interrupt request. Param None Retval None */ | void USARTx_IRQHandler(void) | /* Brief This function handles USARTx Instance interrupt request. Param None Retval None */
void USARTx_IRQHandler(void) | {
if(LL_USART_IsEnabledIT_TXE(USARTx_INSTANCE) && LL_USART_IsActiveFlag_TXE(USARTx_INSTANCE))
{
USART_TXEmpty_Callback();
}
if(LL_USART_IsEnabledIT_TC(USARTx_INSTANCE) && LL_USART_IsActiveFlag_TC(USARTx_INSTANCE))
{
LL_USART_ClearFlag_TC(USARTx_INSTANCE);
USART_CharTransmitComplete_Callback();
}
if(LL_USART_IsEnabledIT_ERROR(USARTx_INSTANCE) && LL_USART_IsActiveFlag_NE(USARTx_INSTANCE))
{
Error_Callback();
}
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* Function to return to normal output whent he scrolling is complete. */ | EFI_STATUS ConsoleLoggerStopHistory(IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo) | /* Function to return to normal output whent he scrolling is complete. */
EFI_STATUS ConsoleLoggerStopHistory(IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo) | {
ASSERT (ConsoleInfo != NULL);
if (ConsoleInfo->CurrentStartRow == ConsoleInfo->OriginalStartRow) {
return (EFI_SUCCESS);
}
ConsoleInfo->OldConOut->ClearScreen (ConsoleInfo->OldConOut);
ConsoleInfo->CurrentStartRow = ConsoleInfo->OriginalStartRow;
return (UpdateDisplayFromHistory (ConsoleInfo));
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Use this function to detect that the ADC is finished sampling data before putting the device into deep sleep. Before using this function, it is highly recommended that the event trigger is changed to */ | bool ADCBusy(uint32_t ui32Base) | /* Use this function to detect that the ADC is finished sampling data before putting the device into deep sleep. Before using this function, it is highly recommended that the event trigger is changed to */
bool ADCBusy(uint32_t ui32Base) | {
ASSERT((ui32Base == ADC0_BASE) || (ui32Base == ADC1_BASE));
return((HWREG(ui32Base + ADC_O_ACTSS) & ADC_ACTSS_BUSY) ? true : false);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* allow the slow work item processor to discard a ref on a work item */ | static void fscache_object_slow_work_put_ref(struct slow_work *) | /* allow the slow work item processor to discard a ref on a work item */
static void fscache_object_slow_work_put_ref(struct slow_work *) | {
struct fscache_object *object =
container_of(work, struct fscache_object, work);
fscache_stat(&fscache_n_cop_put_object);
object->cache->ops->put_object(object);
fscache_stat_d(&fscache_n_cop_put_object);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Tx Complete event handler. This is used to retry sending a packet.
Tx Complete event handler. Handles WRITE events from the BLE stack and if an indication was pending try sending it again. */ | static void on_tx_complete(ble_lns_t *p_lns) | /* Tx Complete event handler. This is used to retry sending a packet.
Tx Complete event handler. Handles WRITE events from the BLE stack and if an indication was pending try sending it again. */
static void on_tx_complete(ble_lns_t *p_lns) | {
notification_buffer_process(p_lns);
} | labapart/polymcu | C++ | null | 201 |
/* Open/create errors are reported with an console message in Rawshark. */ | static void open_failure_message(const char *filename, int err, gboolean for_writing) | /* Open/create errors are reported with an console message in Rawshark. */
static void open_failure_message(const char *filename, int err, gboolean for_writing) | {
fprintf(stderr, "rawshark: ");
fprintf(stderr, file_open_error_message(err, for_writing), filename);
fprintf(stderr, "\n");
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Release all the resource used the MTFTP service binding instance. */ | VOID Mtftp4CleanService(IN MTFTP4_SERVICE *MtftpSb) | /* Release all the resource used the MTFTP service binding instance. */
VOID Mtftp4CleanService(IN MTFTP4_SERVICE *MtftpSb) | {
UdpIoFreeIo (MtftpSb->ConnectUdp);
gBS->CloseEvent (MtftpSb->TimerToGetMap);
gBS->CloseEvent (MtftpSb->TimerNotifyLevel);
gBS->CloseEvent (MtftpSb->Timer);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Try to kill dentries associated with this inode. WARNING: you must own a reference to inode. */ | void d_prune_aliases(struct inode *inode) | /* Try to kill dentries associated with this inode. WARNING: you must own a reference to inode. */
void d_prune_aliases(struct inode *inode) | {
struct dentry *dentry;
restart:
spin_lock(&dcache_lock);
list_for_each_entry(dentry, &inode->i_dentry, d_alias) {
spin_lock(&dentry->d_lock);
if (!atomic_read(&dentry->d_count)) {
__dget_locked(dentry);
__d_drop(dentry);
spin_unlock(&dentry->d_lock);
spin_unlock(&dcache_lock);
dput(dentry);
goto restart;
}
spin_unlock(&dentry->d_lock);
}
spin_unlock(&dcache_lock);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Sets the integration time to the specified value. */ | int tcs34725LuaSetIntegrationTime(lua_State *L) | /* Sets the integration time to the specified value. */
int tcs34725LuaSetIntegrationTime(lua_State *L) | {
tcs34725IntegrationTime_t it = luaL_checkinteger(L, 1);
return tcs34725SetIntegrationTime(it,L);
} | nodemcu/nodemcu-firmware | C++ | MIT License | 7,566 |
/* Build subband samples with noise weighted by q->tone_level. Called by synthfilt_build_sb_samples. */ | static void build_sb_samples_from_noise(QDM2Context *q, int sb) | /* Build subband samples with noise weighted by q->tone_level. Called by synthfilt_build_sb_samples. */
static void build_sb_samples_from_noise(QDM2Context *q, int sb) | {
int ch, j;
FIX_NOISE_IDX(q->noise_idx);
if (!q->nb_channels)
return;
for (ch = 0; ch < q->nb_channels; ch++)
for (j = 0; j < 64; j++) {
q->sb_samples[ch][j * 2][sb] = (int32_t)(f2i_scale * SB_DITHERING_NOISE(sb,q->noise_idx) * q->tone_level[ch][sb][j] + .5);
q->sb_samples[ch][j * 2 + 1][sb] = (int32_t)(f2i_scale * SB_DITHERING_NOISE(sb,q->noise_idx) * q->tone_level[ch][sb][j] + .5);
}
} | DC-SWAT/DreamShell | C++ | null | 404 |
/* Check whether any MFGPTs are available for the kernel to use. In most cases, firmware that uses AMD's VSA code will claim all timers during bootup; we certainly don't want to take them if they're already in use. In other cases (such as with VSAless OpenFirmware), the system firmware leaves timers available for us to use. */ | static int __init scan_timers(struct cs5535_mfgpt_chip *mfgpt) | /* Check whether any MFGPTs are available for the kernel to use. In most cases, firmware that uses AMD's VSA code will claim all timers during bootup; we certainly don't want to take them if they're already in use. In other cases (such as with VSAless OpenFirmware), the system firmware leaves timers available for us to use. */
static int __init scan_timers(struct cs5535_mfgpt_chip *mfgpt) | {
struct cs5535_mfgpt_timer timer = { .chip = mfgpt };
unsigned long flags;
int timers = 0;
uint16_t val;
int i;
if (mfgpt_reset_timers)
reset_all_timers();
spin_lock_irqsave(&mfgpt->lock, flags);
for (i = 0; i < MFGPT_MAX_TIMERS; i++) {
timer.nr = i;
val = cs5535_mfgpt_read(&timer, MFGPT_REG_SETUP);
if (!(val & MFGPT_SETUP_SETUP)) {
__set_bit(i, mfgpt->avail);
timers++;
}
}
spin_unlock_irqrestore(&mfgpt->lock, flags);
return timers;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Print on the screen in a neat fashion all the info we have collected on a device. */ | static int print_info(int skfd, char *ifname, char *args[], int count) | /* Print on the screen in a neat fashion all the info we have collected on a device. */
static int print_info(int skfd, char *ifname, char *args[], int count) | {
struct wireless_info info;
int rc;
args = args; count = count;
rc = get_info(skfd, ifname, &info);
switch(rc)
{
case 0:
display_info(&info, ifname);
break;
case -ENOTSUP:
fprintf(stderr, "%-8.16s no wireless extensions.\n\n",
ifname);
break;
default:
fprintf(stderr, "%-8.16s %s\n\n", ifname, strerror(-rc));
}
return(rc);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* NOTE: ownership of 'value' is transferred to the QList */ | void qlist_append_obj(QList *qlist, QObject *value) | /* NOTE: ownership of 'value' is transferred to the QList */
void qlist_append_obj(QList *qlist, QObject *value) | {
QListEntry *entry;
entry = g_malloc(sizeof(*entry));
entry->value = value;
QTAILQ_INSERT_TAIL(&qlist->head, entry, next);
} | ve3wwg/teensy3_qemu | C++ | Other | 15 |
/* Only compare H/M/S in EFI_TIME and ignore other fields here. */ | INTN CompareHMS(IN EFI_TIME *From, IN EFI_TIME *To) | /* Only compare H/M/S in EFI_TIME and ignore other fields here. */
INTN CompareHMS(IN EFI_TIME *From, IN EFI_TIME *To) | {
if ((From->Hour > To->Hour) ||
((From->Hour == To->Hour) && (From->Minute > To->Minute)) ||
((From->Hour == To->Hour) && (From->Minute == To->Minute) && (From->Second > To->Second)))
{
return 1;
} else if ((From->Hour == To->Hour) && (From->Minute == To->Minute) && (From->Second == To->Second)) {
return 0;
} else {
return -1;
}
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Set the card to max transfer speed in non-high speed mode. */ | static void MMC_SetMaxFrequency(mmc_card_t *card) | /* Set the card to max transfer speed in non-high speed mode. */
static void MMC_SetMaxFrequency(mmc_card_t *card) | {
assert(card);
uint32_t frequencyUnit;
uint32_t multiplierFactor;
uint32_t maxBusClock_Hz;
frequencyUnit = g_transerSpeedFrequencyUnit[READ_MMC_TRANSFER_SPEED_FREQUENCY_UNIT(card->csd)];
multiplierFactor = g_transerSpeedMultiplierFactor[READ_MMC_TRANSFER_SPEED_MULTIPLIER(card->csd)];
maxBusClock_Hz = (frequencyUnit * multiplierFactor) / DIVIDER_IN_TRANSFER_SPEED;
card->busClock_Hz = HOST_SET_CARD_CLOCK(card->host.base, card->host.sourceClock_Hz, maxBusClock_Hz);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Make sure that the value being sent to FSP will not conflict with certain commands. */ | static unsigned char fsp_test_invert_cmd(unsigned char reg_val) | /* Make sure that the value being sent to FSP will not conflict with certain commands. */
static unsigned char fsp_test_invert_cmd(unsigned char reg_val) | {
switch (reg_val) {
case 0xe9: case 0xee: case 0xf2: case 0xff:
return ~reg_val;
default:
return reg_val;
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Frame handler for the application.
Handles all command events from the widgets in the application frame. */ | static bool widget_frame_command_handler(struct wtk_basic_frame *frame, win_command_t command_data) | /* Frame handler for the application.
Handles all command events from the widgets in the application frame. */
static bool widget_frame_command_handler(struct wtk_basic_frame *frame, win_command_t command_data) | {
struct widget_context *widget;
char command;
widget = (struct widget_context *)wtk_basic_frame_get_custom_data(frame);
command = (uintptr_t)command_data;
switch (command) {
case BUTTON_ID:
wtk_plot_add_value(widget->plot, wtk_slider_get_value(widget->slider));
win_redraw(wtk_plot_as_child(widget->plot));
break;
}
return false;
} | memfault/zero-to-main | C++ | null | 200 |
/* Returns the most recent received data by the SPIx peripheral. */ | uint32_t SPI_ReceiveData(SPI_TypeDef *SPIx) | /* Returns the most recent received data by the SPIx peripheral. */
uint32_t SPI_ReceiveData(SPI_TypeDef *SPIx) | {
uint32_t temp=0;
assert_param(IS_SPI_ALL_PERIPH(SPIx));
temp=temp;
temp |=(uint32_t)SPIx->RXREG;
if(SPIx->EXTCTL>8||SPIx->EXTCTL==0) temp |=(uint32_t) (SPIx->RXREG)<<8;
if(SPIx->EXTCTL>16||SPIx->EXTCTL==0) temp |=(uint32_t)( SPIx->RXREG)<<16;
if(SPIx->EXTCTL>24||SPIx->EXTCTL==0) temp |=(uint32_t)( SPIx->RXREG)<<24;
return temp;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* A custom allocator. Returns memory from a statically allocated array. */ | ModbusError staticAllocator(ModbusBuffer *buffer, uint16_t size, void *context) | /* A custom allocator. Returns memory from a statically allocated array. */
ModbusError staticAllocator(ModbusBuffer *buffer, uint16_t size, void *context) | {
static uint8_t response[MAX_RESPONSE];
if (size != 0)
{
if (size <= MAX_RESPONSE)
{
buffer->data = response;
return MODBUS_OK;
}
else
{
buffer->data = NULL;
return MODBUS_ERROR_ALLOC;
}
}
else
{
buffer->data = NULL;
return MODBUS_OK;
}
} | prusa3d/Prusa-Firmware-Buddy | C++ | Other | 1,019 |
/* The return value is the disposition of the chunk. */ | sctp_disposition_t sctp_sf_operr_notify(const struct sctp_endpoint *ep, const struct sctp_association *asoc, const sctp_subtype_t type, void *arg, sctp_cmd_seq_t *commands) | /* The return value is the disposition of the chunk. */
sctp_disposition_t sctp_sf_operr_notify(const struct sctp_endpoint *ep, const struct sctp_association *asoc, const sctp_subtype_t type, void *arg, sctp_cmd_seq_t *commands) | {
struct sctp_chunk *chunk = arg;
if (!sctp_vtag_verify(chunk, asoc))
return sctp_sf_pdiscard(ep, asoc, type, arg, commands);
if (!sctp_chunk_length_valid(chunk, sizeof(sctp_operr_chunk_t)))
return sctp_sf_violation_chunklen(ep, asoc, type, arg,
commands);
sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_OPERR,
SCTP_CHUNK(chunk));
return SCTP_DISPOSITION_CONSUME;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* nand_block_isbad - Check if block at offset is bad @mtd: MTD device structure @offs: offset relative to mtd start */ | static int nand_block_isbad(struct mtd_info *mtd, loff_t offs) | /* nand_block_isbad - Check if block at offset is bad @mtd: MTD device structure @offs: offset relative to mtd start */
static int nand_block_isbad(struct mtd_info *mtd, loff_t offs) | {
if (offs > mtd->size)
return -EINVAL;
return nand_block_checkbad(mtd, offs, 1, 0);
} | EmcraftSystems/u-boot | C++ | Other | 181 |
/* Returns the page offset into bdev for the specified page's swap entry. */ | sector_t map_swap_page(struct page *page, struct block_device **bdev) | /* Returns the page offset into bdev for the specified page's swap entry. */
sector_t map_swap_page(struct page *page, struct block_device **bdev) | {
swp_entry_t entry;
entry.val = page_private(page);
return map_swap_entry(entry, bdev);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Seek the address of the first byte of the option header. */ | UINT8* Dhcp6SeekOption(IN UINT8 *Buf, IN UINT32 SeekLen, IN UINT16 OptType) | /* Seek the address of the first byte of the option header. */
UINT8* Dhcp6SeekOption(IN UINT8 *Buf, IN UINT32 SeekLen, IN UINT16 OptType) | {
UINT8 *Cursor;
UINT8 *Option;
UINT16 DataLen;
UINT16 OpCode;
Option = NULL;
Cursor = Buf;
while (Cursor < Buf + SeekLen) {
OpCode = ReadUnaligned16 ((UINT16 *)Cursor);
if (OpCode == HTONS (OptType)) {
Option = Cursor;
break;
}
DataLen = NTOHS (ReadUnaligned16 ((UINT16 *)(Cursor + 2)));
Cursor += (DataLen + 4);
}
return Option;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Enable output pins.
Onlyc the ones where bits are set to "1" are touched, everything else remains in the old state. */ | void gpio_enable(uint32_t gpioport, uint32_t gpios, enum gpio_mode mode) | /* Enable output pins.
Onlyc the ones where bits are set to "1" are touched, everything else remains in the old state. */
void gpio_enable(uint32_t gpioport, uint32_t gpios, enum gpio_mode mode) | {
if (mode < GPIO_MODE_IN) {
GPIO_GPERC(gpioport) = gpios;
uint8_t i = 0;
for (; i < 3; ++i, mode >>= 1) {
GPIO_PMR_FLIP(gpioport, i, mode & 1) = gpios;
}
} else if (mode == GPIO_MODE_OUT) {
GPIO_GPERS(gpioport) = gpios;
GPIO_ODERS(gpioport) = gpios;
} else if (mode == GPIO_MODE_IN) {
GPIO_GPERS(gpioport) = gpios;
GPIO_ODERC(gpioport) = gpios;
}
} | insane-adding-machines/unicore-mx | C++ | GNU General Public License v3.0 | 50 |
/* Determine if an SCB for a packetized transaction is active in a FIFO. */ | static int ahd_scb_active_in_fifo(struct ahd_softc *ahd, struct scb *scb) | /* Determine if an SCB for a packetized transaction is active in a FIFO. */
static int ahd_scb_active_in_fifo(struct ahd_softc *ahd, struct scb *scb) | {
if (ahd_get_scbptr(ahd) != SCB_GET_TAG(scb)
|| ((ahd_inb(ahd, LONGJMP_ADDR+1) & INVALID_ADDR) != 0
&& (ahd_inb(ahd, SEQINTSRC) & (CFG4DATA|SAVEPTRS)) == 0))
return (0);
return (1);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Difference in percentage of the effective ODR(and timestamp rate) with respect to the typical. Step: 0.15%. 8-bit format, 2's complement.. */ | int32_t lsm6dso_odr_cal_reg_set(stmdev_ctx_t *ctx, uint8_t val) | /* Difference in percentage of the effective ODR(and timestamp rate) with respect to the typical. Step: 0.15%. 8-bit format, 2's complement.. */
int32_t lsm6dso_odr_cal_reg_set(stmdev_ctx_t *ctx, uint8_t val) | {
lsm6dso_internal_freq_fine_t reg;
int32_t ret;
ret = lsm6dso_read_reg(ctx, LSM6DSO_INTERNAL_FREQ_FINE,
(uint8_t *)®, 1);
if (ret == 0) {
reg.freq_fine = val;
ret = lsm6dso_write_reg(ctx, LSM6DSO_INTERNAL_FREQ_FINE,
(uint8_t *)®, 1);
}
return ret;
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* USBH_FindInterfaceIndex Find the interface index for a specific class interface and alternate setting number. */ | uint8_t USBH_FindInterfaceIndex(USBH_HandleTypeDef *phost, uint8_t interface_number, uint8_t alt_settings) | /* USBH_FindInterfaceIndex Find the interface index for a specific class interface and alternate setting number. */
uint8_t USBH_FindInterfaceIndex(USBH_HandleTypeDef *phost, uint8_t interface_number, uint8_t alt_settings) | {
USBH_InterfaceDescTypeDef *pif ;
USBH_CfgDescTypeDef *pcfg ;
int8_t if_ix = 0;
pif = (USBH_InterfaceDescTypeDef *)0;
pcfg = &phost->device.CfgDesc;
while (if_ix < USBH_MAX_NUM_INTERFACES)
{
pif = &pcfg->Itf_Desc[if_ix];
if((pif->bInterfaceNumber == interface_number) && (pif->bAlternateSetting == alt_settings))
{
return if_ix;
}
if_ix++;
}
return 0xFF;
} | labapart/polymcu | C++ | null | 201 |
/* Enables endpoint interrupts on a given USB controller. */ | void USBIntEnableEndpoint(uint32_t ui32Base, uint32_t ui32Flags) | /* Enables endpoint interrupts on a given USB controller. */
void USBIntEnableEndpoint(uint32_t ui32Base, uint32_t ui32Flags) | {
ASSERT(ui32Base == USB0_BASE);
HWREGH(ui32Base + USB_O_TXIE) |=
ui32Flags & (USB_INTEP_HOST_OUT | USB_INTEP_DEV_IN | USB_INTEP_0);
HWREGH(ui32Base + USB_O_RXIE) |=
((ui32Flags & (USB_INTEP_HOST_IN | USB_INTEP_DEV_OUT)) >>
USB_INTEP_RX_SHIFT);
} | feaser/openblt | C++ | GNU General Public License v3.0 | 601 |
/* Returns 0 on success, -ENODEV if handler not registered. */ | int scsi_unregister_device_handler(struct scsi_device_handler *scsi_dh) | /* Returns 0 on success, -ENODEV if handler not registered. */
int scsi_unregister_device_handler(struct scsi_device_handler *scsi_dh) | {
struct scsi_dh_devinfo_list *tmp, *pos;
if (!get_device_handler(scsi_dh->name))
return -ENODEV;
bus_for_each_dev(&scsi_bus_type, NULL, scsi_dh,
scsi_dh_notifier_remove);
spin_lock(&list_lock);
list_del(&scsi_dh->list);
list_for_each_entry_safe(pos, tmp, &scsi_dh_dev_list, node) {
if (pos->handler == scsi_dh) {
list_del(&pos->node);
kfree(pos);
}
}
spin_unlock(&list_lock);
printk(KERN_INFO "%s: device handler unregistered\n", scsi_dh->name);
return SCSI_DH_OK;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* USBH_LL_ClosePipe Close a pipe of the Low Level Driver. */ | USBH_StatusTypeDef USBH_LL_ClosePipe(USBH_HandleTypeDef *phost, uint8_t pipe) | /* USBH_LL_ClosePipe Close a pipe of the Low Level Driver. */
USBH_StatusTypeDef USBH_LL_ClosePipe(USBH_HandleTypeDef *phost, uint8_t pipe) | {
UNUSED(phost);
UNUSED(pipe);
return USBH_OK;
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* Version of write_gdt_entry for use at early boot-time needed to update an entry as simply as possible. */ | static __init void xen_write_gdt_entry_boot(struct desc_struct *dt, int entry, const void *desc, int type) | /* Version of write_gdt_entry for use at early boot-time needed to update an entry as simply as possible. */
static __init void xen_write_gdt_entry_boot(struct desc_struct *dt, int entry, const void *desc, int type) | {
switch (type) {
case DESC_LDT:
case DESC_TSS:
break;
default: {
xmaddr_t maddr = virt_to_machine(&dt[entry]);
if (HYPERVISOR_update_descriptor(maddr.maddr, *(u64 *)desc))
dt[entry] = *(struct desc_struct *)desc;
}
}
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Retrieves the clock frequency of a Generic Clock generator.
Determines the clock frequency (in Hz) of a specified Generic Clock generator, used as a source to a Generic Clock Channel module. */ | uint32_t system_gclk_gen_get_hz(const uint8_t generator) | /* Retrieves the clock frequency of a Generic Clock generator.
Determines the clock frequency (in Hz) of a specified Generic Clock generator, used as a source to a Generic Clock Channel module. */
uint32_t system_gclk_gen_get_hz(const uint8_t generator) | {
while (system_gclk_is_syncing(generator)) {
};
system_interrupt_enter_critical_section();
uint32_t gen_input_hz = system_clock_source_get_hz(
(enum system_clock_source)GCLK->GENCTRL[generator].bit.SRC);
uint8_t divsel = GCLK->GENCTRL[generator].bit.DIVSEL;
uint32_t divider = GCLK->GENCTRL[generator].bit.DIV;
system_interrupt_leave_critical_section();
if (!divsel && divider > 1) {
gen_input_hz /= divider;
} else if (divsel) {
gen_input_hz >>= (divider+1);
}
return gen_input_hz;
} | memfault/zero-to-main | C++ | null | 200 |
/* Attribute write call back for the Value V2 attribute. */ | static ssize_t write_value_v2_4(struct bt_conn *conn, const struct bt_gatt_attr *attr, const void *buf, uint16_t len, uint16_t offset, uint8_t flags) | /* Attribute write call back for the Value V2 attribute. */
static ssize_t write_value_v2_4(struct bt_conn *conn, const struct bt_gatt_attr *attr, const void *buf, uint16_t len, uint16_t offset, uint8_t flags) | {
uint8_t *value = attr->user_data;
if (offset >= sizeof(value_v2_4_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v2_4_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* This API sets the flat interrupt of the sensor.This interrupt occurs in case of flat orientation. */ | static int8_t set_accel_flat_detect_int(struct bmi160_int_settg *int_config, const struct bmi160_dev *dev) | /* This API sets the flat interrupt of the sensor.This interrupt occurs in case of flat orientation. */
static int8_t set_accel_flat_detect_int(struct bmi160_int_settg *int_config, const struct bmi160_dev *dev) | {
int8_t rslt;
rslt = null_ptr_check(dev);
if ((rslt != BMI160_OK) || (int_config == NULL))
{
rslt = BMI160_E_NULL_PTR;
}
else
{
struct bmi160_acc_flat_detect_int_cfg *flat_detect_int = &(int_config->int_type_cfg.acc_flat_int);
rslt = enable_flat_int(flat_detect_int, dev);
if (rslt == BMI160_OK)
{
rslt = set_intr_pin_config(int_config, dev);
if (rslt == BMI160_OK)
{
rslt = map_feature_interrupt(int_config, dev);
if (rslt == BMI160_OK)
{
rslt = config_flat_int_settg(flat_detect_int, dev);
}
}
}
}
return rslt;
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* Determine if a PCI BAR is IO or MMIO. */ | STATIC EFI_STATUS GetBarType(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 BarIndex, OUT VIRTIO_1_0_BAR_TYPE *BarType) | /* Determine if a PCI BAR is IO or MMIO. */
STATIC EFI_STATUS GetBarType(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 BarIndex, OUT VIRTIO_1_0_BAR_TYPE *BarType) | {
EFI_STATUS Status;
VOID *Resources;
Status = PciIo->GetBarAttributes (PciIo, BarIndex, NULL, &Resources);
if (EFI_ERROR (Status)) {
return Status;
}
Status = EFI_UNSUPPORTED;
if (*(UINT8 *)Resources == ACPI_QWORD_ADDRESS_SPACE_DESCRIPTOR) {
EFI_ACPI_QWORD_ADDRESS_SPACE_DESCRIPTOR *Descriptor;
Descriptor = Resources;
switch (Descriptor->ResType) {
case ACPI_ADDRESS_SPACE_TYPE_MEM:
*BarType = Virtio10BarTypeMem;
Status = EFI_SUCCESS;
break;
case ACPI_ADDRESS_SPACE_TYPE_IO:
*BarType = Virtio10BarTypeIo;
Status = EFI_SUCCESS;
break;
default:
break;
}
}
FreePool (Resources);
return Status;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* param base SAI base pointer. param handle SAI eDMA handle pointer. */ | void SAI_TransferTerminateSend(I2S_Type *base, sai_handle_t *handle) | /* param base SAI base pointer. param handle SAI eDMA handle pointer. */
void SAI_TransferTerminateSend(I2S_Type *base, sai_handle_t *handle) | {
assert(handle);
SAI_TransferAbortSend(base, handle);
memset(handle->saiQueue, 0U, sizeof(handle->saiQueue));
memset(handle->transferSize, 0U, sizeof(handle->transferSize));
handle->queueUser = 0U;
handle->queueDriver = 0U;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Check if SDIOH bus switch to a specified state in some time. */ | u32 SDIOH_CheckBusState(u8 status, u32 timeout_us) | /* Check if SDIOH bus switch to a specified state in some time. */
u32 SDIOH_CheckBusState(u8 status, u32 timeout_us) | {
SDIOH_TypeDef *psdioh = SDIOH_BASE;
u8 idle_level = sdioh_init_para.SDIOH_idle_level;
u32 tmp;
do {
tmp = psdioh->SD_BUS_STATUS & idle_level;
if(status) {
if(tmp == idle_level)
return HAL_OK;
} else {
if(tmp == 0)
return HAL_OK;
}
DelayUs(1);
} while (timeout_us-- != 0);
return HAL_TIMEOUT;
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Miscelaneous platform dependent initialisations while still running in flash */ | int misc_init_f(void) | /* Miscelaneous platform dependent initialisations while still running in flash */
int misc_init_f(void) | {
printf ("DIPSW: ");
dipsw_init ();
return (0);
} | EmcraftSystems/u-boot | C++ | Other | 181 |
/* Disable I2C module of the specified I2C port.
The */ | void I2CDisable(unsigned long ulBase) | /* Disable I2C module of the specified I2C port.
The */
void I2CDisable(unsigned long ulBase) | {
xASSERT((ulBase == I2C0_BASE));
xHWREG(ulBase + I2C_O_CON) &= ~I2C_CON_ENS1;
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* If Address > 0x0FFFFFFF, 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 Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */ | UINT8 EFIAPI PciExpressBitFieldWrite8(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 Value) | /* If Address > 0x0FFFFFFF, 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 Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT8 EFIAPI PciExpressBitFieldWrite8(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 Value) | {
if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {
return (UINT8)-1;
}
return MmioBitFieldWrite8 (
GetPciExpressAddress (Address),
StartBit,
EndBit,
Value
);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* This macro is used to enable input channel interrupt. */ | void ECAP_EnableINT(ECAP_T *ecap, uint32_t u32Mask) | /* This macro is used to enable input channel interrupt. */
void ECAP_EnableINT(ECAP_T *ecap, uint32_t u32Mask) | {
ecap->CTL0 |= (u32Mask);
if(ecap == (ECAP_T*)ECAP0)
{
NVIC_EnableIRQ((IRQn_Type)ECAP0_IRQn);
}
else
{
NVIC_EnableIRQ((IRQn_Type)ECAP1_IRQn);
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Definition of the button poll task described in the comments at the top of this file. */ | static void prvButtonPollTask(void *pvParameters) | /* Definition of the button poll task described in the comments at the top of this file. */
static void prvButtonPollTask(void *pvParameters) | {
long lLastState = pdTRUE;
long lState;
xQueueMessage xMessage;
for( ;; )
{
lState = STM_EVAL_PBGetState( BUTTON_UP );
if( lState != lLastState )
{
xMessage.cMessageID = mainMESSAGE_BUTTON_UP;
xMessage.lMessageValue = lState;
lLastState = lState;
xQueueSend( xLCDQueue, &xMessage, portMAX_DELAY );
}
vTaskDelay( 10 / portTICK_RATE_MS );
}
} | apopple/Pandaboard-FreeRTOS | C++ | null | 25 |
/* If disabling the interrupt also does a final read to ensure it is clear. This is only important in some cases where the scan enable elements are switched before the ring is reenabled. */ | static int lis3l02dq_data_rdy_trigger_set_state(struct iio_trigger *trig, bool state) | /* If disabling the interrupt also does a final read to ensure it is clear. This is only important in some cases where the scan enable elements are switched before the ring is reenabled. */
static int lis3l02dq_data_rdy_trigger_set_state(struct iio_trigger *trig, bool state) | {
struct lis3l02dq_state *st = trig->private_data;
int ret = 0;
u8 t;
__lis3l02dq_write_data_ready_config(&st->indio_dev->dev,
&iio_event_data_rdy_trig,
state);
if (state == false) {
flush_scheduled_work();
ret = lis3l02dq_read_all(st, NULL);
}
lis3l02dq_spi_read_reg_8(&st->indio_dev->dev,
LIS3L02DQ_REG_WAKE_UP_SRC_ADDR,
&t);
return ret;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Returns the DMA bus address of the byte with the given @offset relative to the beginning of the @dma. */ | dma_addr_t dma_region_offset_to_bus(struct dma_region *dma, unsigned long offset) | /* Returns the DMA bus address of the byte with the given @offset relative to the beginning of the @dma. */
dma_addr_t dma_region_offset_to_bus(struct dma_region *dma, unsigned long offset) | {
unsigned long rem = 0;
struct scatterlist *sg =
&dma->sglist[dma_region_find(dma, offset, 0, &rem)];
return sg_dma_address(sg) + rem;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Does a triplet - used for searching ROM addresses. Return bits: bit 0 = id_bit bit 1 = comp_bit bit 2 = dir_taken If both bits 0 & 1 are set, the search should be restarted. */ | u8 w1_triplet(struct w1_master *dev, int bdir) | /* Does a triplet - used for searching ROM addresses. Return bits: bit 0 = id_bit bit 1 = comp_bit bit 2 = dir_taken If both bits 0 & 1 are set, the search should be restarted. */
u8 w1_triplet(struct w1_master *dev, int bdir) | {
if (dev->bus_master->triplet)
return dev->bus_master->triplet(dev->bus_master->data, bdir);
else {
u8 id_bit = w1_touch_bit(dev, 1);
u8 comp_bit = w1_touch_bit(dev, 1);
u8 retval;
if (id_bit && comp_bit)
return 0x03;
if (!id_bit && !comp_bit) {
retval = bdir ? 0x04 : 0;
} else {
bdir = id_bit;
retval = id_bit ? 0x05 : 0x02;
}
if (dev->bus_master->touch_bit)
w1_touch_bit(dev, bdir);
else
w1_write_bit(dev, bdir);
return retval;
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Specifies the clock divider for the specified TMR2 channel. */ | void TMR2_SetClockDiv(CM_TMR2_TypeDef *TMR2x, uint32_t u32Ch, uint32_t u32Div) | /* Specifies the clock divider for the specified TMR2 channel. */
void TMR2_SetClockDiv(CM_TMR2_TypeDef *TMR2x, uint32_t u32Ch, uint32_t u32Div) | {
DDL_ASSERT(IS_TMR2_UNIT(TMR2x));
DDL_ASSERT(IS_TMR2_CH(u32Ch));
DDL_ASSERT(IS_TMR2_CLK_DIV(u32Div));
u32Ch *= TMR2_CH_OFFSET;
MODIFY_REG32(TMR2x->BCONR, (TMR2_BCONR_CKDIVA << u32Ch), (u32Div << u32Ch));
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Check if some error occurs when SDIOH transfer. */ | u32 SDIOH_CheckTxError(u16 *status) | /* Check if some error occurs when SDIOH transfer. */
u32 SDIOH_CheckTxError(u16 *status) | {
SDIOH_TypeDef *psdioh = SDIOH_BASE;
if(psdioh->SD_TRANSFER & SDIOH_ERR_OCCUR) {
if(status != NULL)
*status = psdioh->SD_STATUS1 | (psdioh->SD_STATUS2 << 8);
return HAL_ERR_UNKNOWN;
} else
return HAL_OK;
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Set the card to max transfer speed in non-high speed mode. */ | static void MMC_SetMaxFrequency(mmc_card_t *card) | /* Set the card to max transfer speed in non-high speed mode. */
static void MMC_SetMaxFrequency(mmc_card_t *card) | {
assert(card);
uint32_t frequencyUnit;
uint32_t multiplierFactor;
uint32_t maxBusClock_Hz;
frequencyUnit = g_transerSpeedFrequencyUnit[READ_MMC_TRANSFER_SPEED_FREQUENCY_UNIT(card->csd)];
multiplierFactor = g_transerSpeedMultiplierFactor[READ_MMC_TRANSFER_SPEED_MULTIPLIER(card->csd)];
maxBusClock_Hz = (frequencyUnit * multiplierFactor) / DIVIDER_IN_TRANSFER_SPEED;
card->busClock_Hz = SDHC_SetSdClock(card->host.base, card->host.sourceClock_Hz, maxBusClock_Hz);
} | labapart/polymcu | C++ | null | 201 |
/* Ensables SDIO SD I/O Mode suspend command sending. */ | void SDIO_EnableTxSDIOSuspend(void) | /* Ensables SDIO SD I/O Mode suspend command sending. */
void SDIO_EnableTxSDIOSuspend(void) | {
SDIO->CMD_B.SDIOSC = SET;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* This routine is IOCB completion routine for device reset and target reset routine. This routine release scsi buffer associated with lpfc_cmd. */ | static void lpfc_tskmgmt_def_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocbq, struct lpfc_iocbq *rspiocbq) | /* This routine is IOCB completion routine for device reset and target reset routine. This routine release scsi buffer associated with lpfc_cmd. */
static void lpfc_tskmgmt_def_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocbq, struct lpfc_iocbq *rspiocbq) | {
struct lpfc_scsi_buf *lpfc_cmd =
(struct lpfc_scsi_buf *) cmdiocbq->context1;
if (lpfc_cmd)
lpfc_release_scsi_buf(phba, lpfc_cmd);
return;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Note: This function is the entry point of Tx Path for Os delivery packet to our driver. You only can put OS-depened & STA/AP common handle procedures */ | int rt28xx_packet_xmit(struct sk_buff *skb) | /* Note: This function is the entry point of Tx Path for Os delivery packet to our driver. You only can put OS-depened & STA/AP common handle procedures */
int rt28xx_packet_xmit(struct sk_buff *skb) | {
struct net_device *net_dev = skb->dev;
struct rt_rtmp_adapter *pAd = NULL;
int status = NETDEV_TX_OK;
void *pPacket = (void *)skb;
GET_PAD_FROM_NET_DEV(pAd, net_dev);
{
if (MONITOR_ON(pAd)) {
RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
goto done;
}
}
if (skb->len < 14) {
hex_dump("bad packet", skb->data, skb->len);
RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
goto done;
}
RTMP_SET_PACKET_5VT(pPacket, 0);
STASendPackets((void *)pAd, (void **)& pPacket, 1);
status = NETDEV_TX_OK;
done:
return status;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Called from connection statemachine when a connection has been shutdown. */ | static void dev_action_conndown(fsm_instance *fi, int event, void *arg) | /* Called from connection statemachine when a connection has been shutdown. */
static void dev_action_conndown(fsm_instance *fi, int event, void *arg) | {
IUCV_DBF_TEXT(trace, 3, __func__);
switch (fsm_getstate(fi)) {
case DEV_STATE_RUNNING:
fsm_newstate(fi, DEV_STATE_STARTWAIT);
break;
case DEV_STATE_STOPWAIT:
fsm_newstate(fi, DEV_STATE_STOPPED);
IUCV_DBF_TEXT(setup, 3, "connection is down\n");
break;
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* PageLocked prevents anyone from starting writeback of a page which is under read I/O (PageWriteback is only ever set against a locked page). */ | static void mark_buffer_async_read(struct buffer_head *bh) | /* PageLocked prevents anyone from starting writeback of a page which is under read I/O (PageWriteback is only ever set against a locked page). */
static void mark_buffer_async_read(struct buffer_head *bh) | {
bh->b_end_io = end_buffer_async_read;
set_buffer_async_read(bh);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Enables the period interrupt for the given PWM channel. */ | void PWMC_EnableChannelIt(unsigned char channel) | /* Enables the period interrupt for the given PWM channel. */
void PWMC_EnableChannelIt(unsigned char channel) | {
AT91C_BASE_PWMC->PWMC_IER = 1 << channel;
} | apopple/Pandaboard-FreeRTOS | C++ | null | 25 |
/* Asynchronous timer (ASF) handler for the QTouch acquisition. and clear Watchdog counter - generates interrupt every 100ms. */ | static void ast_per_callback(void) | /* Asynchronous timer (ASF) handler for the QTouch acquisition. and clear Watchdog counter - generates interrupt every 100ms. */
static void ast_per_callback(void) | {
touch_sensors_update_time();
event_qtouch_sensors_idle_count++;
ast_clear_interrupt_flag(AST, AST_INTERRUPT_PER);
wdt_clear();
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* Encodes fixed header for the MQTT message and provides pointer to start of the header. */ | static uint32_t mqtt_encode_fixed_header(uint8_t message_type, uint8_t *start, struct buf_ctx *buf) | /* Encodes fixed header for the MQTT message and provides pointer to start of the header. */
static uint32_t mqtt_encode_fixed_header(uint8_t message_type, uint8_t *start, struct buf_ctx *buf) | {
uint32_t length = buf->cur - start;
uint8_t fixed_header_length;
if (length > MQTT_MAX_PAYLOAD_SIZE) {
return -EMSGSIZE;
}
NET_DBG("<< msg type:0x%02x length:0x%08x", message_type, length);
fixed_header_length = packet_length_encode(length, NULL);
fixed_header_length += sizeof(uint8_t);
NET_DBG("Fixed header length = %02x", fixed_header_length);
buf->cur = start - fixed_header_length;
(void)pack_uint8(message_type, buf);
(void)packet_length_encode(length, buf);
buf->cur = buf->cur - fixed_header_length;
buf->end = buf->cur + length + fixed_header_length;
return 0;
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* This function is used to set IP divider number from the corresponding clock source.
The divider number is chosen with one of the following values: divider 1-16 for peripheral */ | void SysCtlIPClockDividerSet(unsigned long ulConfig) | /* This function is used to set IP divider number from the corresponding clock source.
The divider number is chosen with one of the following values: divider 1-16 for peripheral */
void SysCtlIPClockDividerSet(unsigned long ulConfig) | {
xASSERT((ulConfig & 0xFF)<=256);
xHWREG(SYSCLK_CLKDIV) &= ~(SYSCTL_PERIPH_MASK_DIV(ulConfig));
xHWREG(SYSCLK_CLKDIV) |= (SYSCTL_PERIPH_ENUM_CLK(ulConfig)-1);
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* Have the same behavior of parse_uint(), but with an additional check for additional data after the parsed number. If extra characters are present after the parsed number, the function will return -EINVAL, and *@v will be set to 0. */ | int parse_uint_full(const char *s, unsigned long long *value, int base) | /* Have the same behavior of parse_uint(), but with an additional check for additional data after the parsed number. If extra characters are present after the parsed number, the function will return -EINVAL, and *@v will be set to 0. */
int parse_uint_full(const char *s, unsigned long long *value, int base) | {
char *endp;
int r;
r = parse_uint(s, value, &endp, base);
if (r < 0) {
return r;
}
if (*endp) {
*value = 0;
return -EINVAL;
}
return 0;
} | ve3wwg/teensy3_qemu | C++ | Other | 15 |
/* A callback function for the directory diff calculation routine, produces G_FILE_MONITOR_EVENT_DELETED event for a deleted file. */ | static void handle_deleted(void *udata, const char *path, ino_t inode) | /* A callback function for the directory diff calculation routine, produces G_FILE_MONITOR_EVENT_DELETED event for a deleted file. */
static void handle_deleted(void *udata, const char *path, ino_t inode) | {
handle_ctx *ctx = NULL;
(void) inode;
ctx = (handle_ctx *) udata;
g_assert (udata != NULL);
g_assert (ctx->sub != NULL);
g_assert (ctx->source != NULL);
g_file_monitor_source_handle_event (ctx->source, G_FILE_MONITOR_EVENT_DELETED, path,
NULL, NULL, g_get_monotonic_time ());
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Configure the Edge for which a transition is detectable for the selected pin. */ | void mfxstm32l152_IO_SetIrqTypeMode(uint16_t DeviceAddr, uint32_t IO_Pin, uint8_t Type) | /* Configure the Edge for which a transition is detectable for the selected pin. */
void mfxstm32l152_IO_SetIrqTypeMode(uint16_t DeviceAddr, uint32_t IO_Pin, uint8_t Type) | {
mfxstm32l152_reg24_setPinValue(DeviceAddr, MFXSTM32L152_REG_ADR_IRQ_GPI_TYPE1, IO_Pin, Type);
rt_thread_delay(1);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Read from the DMP memory. This function prevents I2C reads past the bank boundaries. The DMP memory is only accessible when the chip is awake. */ | int mpu_read_mem(unsigned short mem_addr, unsigned short length, unsigned char *data) | /* Read from the DMP memory. This function prevents I2C reads past the bank boundaries. The DMP memory is only accessible when the chip is awake. */
int mpu_read_mem(unsigned short mem_addr, unsigned short length, unsigned char *data) | {
unsigned char tmp[2];
if (!data)
return -1;
if (!st.chip_cfg.sensors)
return -1;
tmp[0] = (unsigned char)(mem_addr >> 8);
tmp[1] = (unsigned char)(mem_addr & 0xFF);
if (tmp[1] + length > st.hw->bank_size)
return -1;
if (i2c_write(st.hw->addr, st.reg->bank_sel, 2, tmp))
return -1;
if (i2c_read(st.hw->addr, st.reg->mem_r_w, length, data))
return -1;
return 0;
} | Luos-io/luos_engine | C++ | MIT License | 496 |
/* Atomically swap in the new signal mask, and wait for a signal. */ | long sys_sigsuspend(int history0, int history1, old_sigset_t mask) | /* Atomically swap in the new signal mask, and wait for a signal. */
long sys_sigsuspend(int history0, int history1, old_sigset_t mask) | {
mask &= _BLOCKABLE;
spin_lock_irq(¤t->sighand->siglock);
current->saved_sigmask = current->blocked;
siginitset(¤t->blocked, mask);
recalc_sigpending();
spin_unlock_irq(¤t->sighand->siglock);
current->state = TASK_INTERRUPTIBLE;
schedule();
set_thread_flag(TIF_RESTORE_SIGMASK);
return -ERESTARTNOHAND;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Get the interframe gap, parts 1 and 2. See the description of interframe gap above in */ | void XEmac_GetInterframeGap(XEmac *InstancePtr, u8 *Part1Ptr, u8 *Part2Ptr) | /* Get the interframe gap, parts 1 and 2. See the description of interframe gap above in */
void XEmac_GetInterframeGap(XEmac *InstancePtr, u8 *Part1Ptr, u8 *Part2Ptr) | {
u32 Ifg;
XASSERT_VOID(InstancePtr != NULL);
XASSERT_VOID(Part1Ptr != NULL);
XASSERT_VOID(Part2Ptr != NULL);
XASSERT_VOID(InstancePtr->IsReady == XCOMPONENT_IS_READY);
Ifg = XIo_In32(InstancePtr->BaseAddress + XEM_IFGP_OFFSET);
*Part1Ptr = (Ifg & XEM_IFGP_PART1_MASK) >> XEM_IFGP_PART1_SHIFT;
*Part2Ptr = (Ifg & XEM_IFGP_PART2_MASK) >> XEM_IFGP_PART2_SHIFT;
} | EmcraftSystems/u-boot | C++ | Other | 181 |
/* Translate all VT-UTF8 characters in the Raw FIFI into unicode characters, and insert them into Unicode FIFO. */ | VOID VTUTF8RawDataToUnicode(IN TERMINAL_DEV *TerminalDevice) | /* Translate all VT-UTF8 characters in the Raw FIFI into unicode characters, and insert them into Unicode FIFO. */
VOID VTUTF8RawDataToUnicode(IN TERMINAL_DEV *TerminalDevice) | {
UTF8_CHAR Utf8Char;
UINT8 ValidBytes;
UINT16 UnicodeChar;
ValidBytes = 0;
while (!IsRawFiFoEmpty (TerminalDevice) && !IsUnicodeFiFoFull (TerminalDevice)) {
GetOneValidUtf8Char (TerminalDevice, &Utf8Char, &ValidBytes);
if ((ValidBytes < 1) || (ValidBytes > 3)) {
continue;
}
Utf8ToUnicode (Utf8Char, ValidBytes, (CHAR16 *)&UnicodeChar);
UnicodeFiFoInsertOneKey (TerminalDevice, UnicodeChar);
}
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Pad the iSCSI AHS or data segment to an integer number of 4 byte words. */ | EFI_STATUS IScsiPadSegment(IN OUT NET_BUF *Pdu, IN UINT32 Len) | /* Pad the iSCSI AHS or data segment to an integer number of 4 byte words. */
EFI_STATUS IScsiPadSegment(IN OUT NET_BUF *Pdu, IN UINT32 Len) | {
UINT32 PadLen;
UINT8 *Data;
PadLen = ISCSI_GET_PAD_LEN (Len);
if (PadLen != 0) {
Data = NetbufAllocSpace (Pdu, PadLen, NET_BUF_TAIL);
if (Data == NULL) {
return EFI_OUT_OF_RESOURCES;
}
ZeroMem (Data, PadLen);
}
return EFI_SUCCESS;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Get the know the Rx FIFO is Empty or not from the specified port. */ | xtBoolean xUARTCharsAvail(unsigned long ulBase) | /* Get the know the Rx FIFO is Empty or not from the specified port. */
xtBoolean xUARTCharsAvail(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 |
/* Returns: the data of the last element in the queue, or NULL if the queue is empty */ | gpointer g_queue_pop_tail(GQueue *queue) | /* Returns: the data of the last element in the queue, or NULL if the queue is empty */
gpointer g_queue_pop_tail(GQueue *queue) | {
g_return_val_if_fail (queue != NULL, NULL);
if (queue->tail)
{
GList *node = queue->tail;
gpointer data = node->data;
queue->tail = node->prev;
if (queue->tail)
queue->tail->next = NULL;
else
queue->head = NULL;
queue->length--;
g_list_free_1 (node);
return data;
}
return NULL;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* The caller is responsible for initializing *Indices with */ | VOID EFIAPI VirtioAppendDesc(IN OUT VRING *Ring, IN UINT64 BufferDeviceAddress, IN UINT32 BufferSize, IN UINT16 Flags, IN OUT DESC_INDICES *Indices) | /* The caller is responsible for initializing *Indices with */
VOID EFIAPI VirtioAppendDesc(IN OUT VRING *Ring, IN UINT64 BufferDeviceAddress, IN UINT32 BufferSize, IN UINT16 Flags, IN OUT DESC_INDICES *Indices) | {
volatile VRING_DESC *Desc;
Desc = &Ring->Desc[Indices->NextDescIdx++ % Ring->QueueSize];
Desc->Addr = BufferDeviceAddress;
Desc->Len = BufferSize;
Desc->Flags = Flags;
Desc->Next = Indices->NextDescIdx % Ring->QueueSize;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* If the conversion 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 SafeInt16ToUintn(IN INT16 Operand, OUT UINTN *Result) | /* If the conversion 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 SafeInt16ToUintn(IN INT16 Operand, OUT UINTN *Result) | {
RETURN_STATUS Status;
if (Result == NULL) {
return RETURN_INVALID_PARAMETER;
}
if (Operand >= 0) {
*Result = (UINTN)Operand;
Status = RETURN_SUCCESS;
} else {
*Result = UINTN_ERROR;
Status = RETURN_BUFFER_TOO_SMALL;
}
return Status;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* This function processes the results of changes in configuration. */ | EFI_STATUS EFIAPI TcgRouteConfig(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Configuration, OUT EFI_STRING *Progress) | /* This function processes the results of changes in configuration. */
EFI_STATUS EFIAPI TcgRouteConfig(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Configuration, OUT EFI_STRING *Progress) | {
EFI_STATUS Status;
UINTN BufferSize;
TCG_CONFIGURATION TcgConfiguration;
if ((Configuration == NULL) || (Progress == NULL)) {
return EFI_INVALID_PARAMETER;
}
*Progress = Configuration;
if (!HiiIsConfigHdrMatch (Configuration, &gTcgConfigFormSetGuid, mTcgStorageName)) {
return EFI_NOT_FOUND;
}
BufferSize = sizeof (TCG_CONFIGURATION);
Status = gHiiConfigRouting->ConfigToBlock (
gHiiConfigRouting,
Configuration,
(UINT8 *)&TcgConfiguration,
&BufferSize,
Progress
);
if (EFI_ERROR (Status)) {
return Status;
}
return EFI_SUCCESS;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* @event notified event @context pointer to the notification count */ | static void EFIAPI notify(struct efi_event *event, void *context) | /* @event notified event @context pointer to the notification count */
static void EFIAPI notify(struct efi_event *event, void *context) | {
struct context *cp = context;
efi_status_t ret;
efi_uintn_t handle_count;
efi_handle_t *handles;
cp->notify_count++;
for (;;) {
ret = boottime->locate_handle_buffer(BY_REGISTER_NOTIFY, NULL,
cp->registration_key,
&handle_count, &handles);
if (ret != EFI_SUCCESS)
break;
cp->handle_count += handle_count;
cp->handles = handles;
}
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* This function returns %0 on success and a negative error code on failure. */ | int ubifs_log_post_commit(struct ubifs_info *c, int old_ltail_lnum) | /* This function returns %0 on success and a negative error code on failure. */
int ubifs_log_post_commit(struct ubifs_info *c, int old_ltail_lnum) | {
int lnum, err = 0;
while (!list_empty(&c->old_buds)) {
struct ubifs_bud *bud;
bud = list_entry(c->old_buds.next, struct ubifs_bud, list);
err = ubifs_return_leb(c, bud->lnum);
if (err)
return err;
list_del(&bud->list);
kfree(bud);
}
mutex_lock(&c->log_mutex);
for (lnum = old_ltail_lnum; lnum != c->ltail_lnum;
lnum = next_log_lnum(c, lnum)) {
dbg_log("unmap log LEB %d", lnum);
err = ubifs_leb_unmap(c, lnum);
if (err)
goto out;
}
out:
mutex_unlock(&c->log_mutex);
return err;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.