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 |
|---|---|---|---|---|---|---|---|
/* Initializes the timer peripheral registers to their default reset values. */ | void TMR_DeInit(TMR_Type *TMRx) | /* Initializes the timer peripheral registers to their default reset values. */
void TMR_DeInit(TMR_Type *TMRx) | {
assert_parameters(IS_TMR_ALL_INSTANCE(TMRx));
TMRx->CTRL &= ~TMR_CTRL_EN;
TMRx->INTSTS = TMR_INTSTS_INTSTS;
TMRx->CTRL = TMR_CTRL_RSTValue;
TMRx->RELOAD = TMR_RELOAD_RSTValue;
TMRx->VALUE = TMR_VALUE_RSTValue;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* The length of the hash result is dependent on the algorithm that is in use. The following table shows the correct array size for each algorithm: */ | bool SHAMD5DataProcess(uint32_t ui32Base, uint8_t *pui8DataSrc, uint32_t ui32DataLength, uint8_t *pui8HashResult) | /* The length of the hash result is dependent on the algorithm that is in use. The following table shows the correct array size for each algorithm: */
bool SHAMD5DataProcess(uint32_t ui32Base, uint8_t *pui8DataSrc, uint32_t ui32DataLength, uint8_t *pui8HashResult) | {
ASSERT(ui32Base == SHAMD5_BASE);
ASSERT((ui32DataLength % 64) == 0);
while((HWREG(ui32Base + SHAMD5_O_IRQSTATUS) & SHAMD5_INT_CONTEXT_READY) ==
0)
{
}
SHAMD5DataLengthSet(ui32Base, ui32DataLength);
SHAMD5DataWriteMultiple(pui8DataSrc, ui32DataLength);
while((HWREG(ui32Base + ... | micropython/micropython | C++ | Other | 18,334 |
/* Wait until an operation is completed by checking a bit in a register up to @attempts times. Returns %0 if the operation completes and %1 otherwise. */ | static int t1_wait_op_done(adapter_t *adapter, int reg, u32 mask, int polarity, int attempts, int delay) | /* Wait until an operation is completed by checking a bit in a register up to @attempts times. Returns %0 if the operation completes and %1 otherwise. */
static int t1_wait_op_done(adapter_t *adapter, int reg, u32 mask, int polarity, int attempts, int delay) | {
while (1) {
u32 val = readl(adapter->regs + reg) & mask;
if (!!val == polarity)
return 0;
if (--attempts == 0)
return 1;
if (delay)
udelay(delay);
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Special lseek() function for /dev/null and /dev/zero. Most notably, you can fopen() both devices with "a" now. This was previously impossible. */ | static loff_t null_lseek(struct file *file, loff_t offset, int orig) | /* Special lseek() function for /dev/null and /dev/zero. Most notably, you can fopen() both devices with "a" now. This was previously impossible. */
static loff_t null_lseek(struct file *file, loff_t offset, int orig) | {
return file->f_pos = 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Process function helper. Updates the ADC read register on the update timer interrupt. */ | static int32_t cn0414_process_update_adc(struct cn0414_dev *dev) | /* Process function helper. Updates the ADC read register on the update timer interrupt. */
static int32_t cn0414_process_update_adc(struct cn0414_dev *dev) | {
int32_t ret;
NVIC_DisableIRQ(TMR0_INT);
NVIC_DisableIRQ(HART_CD_INT);
ret = cn0414_read_channel(dev, dev->channel_index);
if(ret != CN0414_SUCCESS)
goto finish;
if(dev->channel_index == IIN4)
dev->channel_index = VIN1;
else
dev->channel_index++;
adc_channel_flag = 0;
adc_sw_prescaler = 0;
finish:
NVIC... | analogdevicesinc/EVAL-ADICUP3029 | C++ | Other | 36 |
/* \method names() Returns the cpu and board names for this pin. */ | STATIC mp_obj_t pin_names(mp_obj_t self_in) | /* \method names() Returns the cpu and board names for this pin. */
STATIC mp_obj_t pin_names(mp_obj_t self_in) | {
if (elem->value == self_in) {
mp_obj_list_append(result, elem->key);
}
}
return result;
} | micropython/micropython | C++ | Other | 18,334 |
/* get a list of this system's interface IPv4 addresses, netmasks and MTUs */ | int afs_get_ipv4_interfaces(struct afs_interface *bufs, size_t maxbufs, bool wantloopback) | /* get a list of this system's interface IPv4 addresses, netmasks and MTUs */
int afs_get_ipv4_interfaces(struct afs_interface *bufs, size_t maxbufs, bool wantloopback) | {
struct net_device *dev;
struct in_device *idev;
int n = 0;
ASSERT(maxbufs > 0);
rtnl_lock();
for_each_netdev(&init_net, dev) {
if (dev->type == ARPHRD_LOOPBACK && !wantloopback)
continue;
idev = __in_dev_get_rtnl(dev);
if (!idev)
continue;
for_primary_ifa(idev) {
bufs[n].address.s_addr = ifa->i... | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* If HmacSha384Context is NULL, then return FALSE. If HmacValue is NULL, then return FALSE. If this interface is not supported, then return FALSE. */ | BOOLEAN EFIAPI CryptoServiceHmacSha384Final(IN OUT VOID *HmacSha384Context, OUT UINT8 *HmacValue) | /* If HmacSha384Context is NULL, then return FALSE. If HmacValue is NULL, then return FALSE. If this interface is not supported, then return FALSE. */
BOOLEAN EFIAPI CryptoServiceHmacSha384Final(IN OUT VOID *HmacSha384Context, OUT UINT8 *HmacValue) | {
return CALL_BASECRYPTLIB (HmacSha384.Services.Final, HmacSha384Final, (HmacSha384Context, HmacValue), FALSE);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* argument 'wait' is the time we know the voltage difference can be measured this function keeps reading the voltage until it is stable */ | static int wait_for_voltage_stable(int wait) | /* argument 'wait' is the time we know the voltage difference can be measured this function keeps reading the voltage until it is stable */
static int wait_for_voltage_stable(int wait) | {
int timeout, vdd_current, vdd_last;
vdd_last = read_voltage();
udelay(wait * NUM_READINGS * WAIT_FOR_ADC);
vdd_current = read_voltage();
for (timeout = 0; abs(vdd_last - vdd_current) >= 4 &&
timeout < 100; timeout++) {
vdd_last = vdd_current;
udelay(wait * NUM_READINGS * WAIT_FOR_ADC);
vdd_current = read... | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* gfs2_glock_thaw - Thaw any frozen glocks @sdp: The super block */ | void gfs2_glock_thaw(struct gfs2_sbd *sdp) | /* gfs2_glock_thaw - Thaw any frozen glocks @sdp: The super block */
void gfs2_glock_thaw(struct gfs2_sbd *sdp) | {
unsigned x;
for (x = 0; x < GFS2_GL_HASH_SIZE; x++)
examine_bucket(thaw_glock, sdp, x);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Returns TRUE if the connection was dead and extracted. */ | static bool extract_if_dead(struct connectdata *conn, struct Curl_easy *data) | /* Returns TRUE if the connection was dead and extracted. */
static bool extract_if_dead(struct connectdata *conn, struct Curl_easy *data) | {
if(!CONN_INUSE(conn) && !conn->data) {
bool dead;
if(conn->handler->connection_check) {
unsigned int state;
struct Curl_easy *olddata = conn->data;
conn->data = data;
state = conn->handler->connection_check(conn, CONNCHECK_ISDEAD);
conn->data = olddata;
dead = (state & CO... | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Returns the timer counter. NOTE: if the timer is a 16-bit timer, only the lower 16 bits are valid. If the timer is a 64-bit timer, only the low 32-bits are returned. */ | uint32_t hal_timer_read(int timer_num) | /* Returns the timer counter. NOTE: if the timer is a 16-bit timer, only the lower 16 bits are valid. If the timer is a 64-bit timer, only the low 32-bits are returned. */
uint32_t hal_timer_read(int timer_num) | {
int rc;
uint32_t tcntr;
struct nrf52_hal_timer *bsptimer;
NRF52_HAL_TIMER_RESOLVE(timer_num, bsptimer);
if (bsptimer->tmr_rtc) {
tcntr = hal_timer_read_bsptimer(bsptimer);
} else {
tcntr = nrf_read_timer_cntr(bsptimer->tmr_reg);
}
return tcntr;
err:
assert(0);
... | arendst/Tasmota | C++ | GNU General Public License v3.0 | 21,318 |
/* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ` */ | int strcasecmp(const char *s1, const char *s2) | /* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ` */
int strcasecmp(const char *s1, const char *s2) | {
const unsigned char *us1 = (const unsigned char *)s1,
*us2 = (const unsigned char *)s2;
while (tolower((int) *us1) == tolower((int) *us2++))
if (*us1++ == '\0')
return (0);
return (tolower((int) *us1) - tolower((int) *--us2));
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Fills each SPI_InitType member with its default value. */ | void SPI_StructInit(SPI_InitType *InitStruct) | /* Fills each SPI_InitType member with its default value. */
void SPI_StructInit(SPI_InitType *InitStruct) | {
InitStruct->ClockDivision = SPI_CLKDIV_2;
InitStruct->CSNSoft = SPI_CSNSOFT_DISABLE;
InitStruct->Mode = SPI_MODE_MASTER;
InitStruct->SPH = SPI_SPH_0;
InitStruct->SPO = SPI_SPO_0;
InitStruct->SWAP = SPI_SWAP_DISABLE;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* The interrupt handler for the I2C0 interface. It deals only with the master mode. */ | void i2c_interface0_master_handler(void) | /* The interrupt handler for the I2C0 interface. It deals only with the master mode. */
void i2c_interface0_master_handler(void) | {
printf("i2cInterface = %d\n", i2c_interface);
i2c_clear_buffer((uint8_t *) i2c_master_buffer,
I2C_BUFSIZE * sizeof(uint8_t));
i2c_active_power(i2c_interface);
i2c_pin_select(i2c_interface);
i2c_clear_control_register(i2c_interface);
i2c_set_baud_rate(i2c_interface, baud_ra... | labapart/polymcu | C++ | null | 201 |
/* When a context switch is performed from the task level the saved task context is made to look as if it occurred from within the tick ISR. This way the same restore context function can be used when restoring the context saved from the ISR or that saved from a call to vPortYieldProcessor. */ | void vPortYieldProcessor(void) | /* When a context switch is performed from the task level the saved task context is made to look as if it occurred from within the tick ISR. This way the same restore context function can be used when restoring the context saved from the ISR or that saved from a call to vPortYieldProcessor. */
void vPortYieldProcessor... | {
__asm volatile ( "ADD LR, LR, #4" );
portSAVE_CONTEXT();
__asm volatile( "bl vTaskSwitchContext" );
portRESTORE_CONTEXT();} | apopple/Pandaboard-FreeRTOS | C++ | null | 25 |
/* Function to start the first task executing - written in asm code as direct access to registers is required. */ | static void prvStartFirstTask(void) | /* Function to start the first task executing - written in asm code as direct access to registers is required. */
static void prvStartFirstTask(void) | {
SETPSW U
MOV.L #_pxCurrentTCB, R15
MOV.L [R15], R15
MOV.L [R15], R0
POP R15
MVTACLO R15
POP R15
MVTACHI R15
POPM R1-R15
RTE
NOP
NOP
} | apopple/Pandaboard-FreeRTOS | C++ | null | 25 |
/* Function for dispatching a system event to interested modules.
This function is called from the System event interrupt handler after a system event has been received. */ | static void sys_evt_dispatch(uint32_t sys_evt) | /* Function for dispatching a system event to interested modules.
This function is called from the System event interrupt handler after a system event has been received. */
static void sys_evt_dispatch(uint32_t sys_evt) | {
pstorage_sys_event_handler(sys_evt);
ble_advertising_on_sys_evt(sys_evt);
} | labapart/polymcu | C++ | null | 201 |
/* Get the time offset from the system PIT. Note that if we have missed an interrupt, then the PIT counter will roll over (ie, be negative). This actually works out to be convenient. */ | static unsigned long ebsa110_gettimeoffset(void) | /* Get the time offset from the system PIT. Note that if we have missed an interrupt, then the PIT counter will roll over (ie, be negative). This actually works out to be convenient. */
static unsigned long ebsa110_gettimeoffset(void) | {
unsigned long offset, count;
__raw_writeb(0x40, PIT_CTRL);
count = __raw_readb(PIT_T1);
count |= __raw_readb(PIT_T1) << 8;
if (count > COUNT)
count |= 0xffff0000;
offset = COUNT;
offset -= count;
offset = offset * (1000000 / HZ) / COUNT;
return offset;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Set the anycast delay of a neighbour table to the specified value */ | void rtnl_neightbl_set_anycast_delay(struct rtnl_neightbl *ntbl, uint64_t ms) | /* Set the anycast delay of a neighbour table to the specified value */
void rtnl_neightbl_set_anycast_delay(struct rtnl_neightbl *ntbl, uint64_t ms) | {
ntbl->nt_parms.ntp_anycast_delay = ms;
ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_ANYCAST_DELAY;
ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Return an allocated memory block back to a specific memory pool. */ | osStatus osPoolFree(osPoolId pool_id, void *block) | /* Return an allocated memory block back to a specific memory pool. */
osStatus osPoolFree(osPoolId pool_id, void *block) | {
rt_mp_free(block);
return osOK;
} | armink/FreeModbus_Slave-Master-RTT-STM32 | C++ | Other | 1,477 |
/* Given an existing resource, change its start and size to match the arguments. Returns 0 on success, -EBUSY if it can't fit. Existing children of the resource are assumed to be immutable. */ | int adjust_resource(struct resource *res, resource_size_t start, resource_size_t size) | /* Given an existing resource, change its start and size to match the arguments. Returns 0 on success, -EBUSY if it can't fit. Existing children of the resource are assumed to be immutable. */
int adjust_resource(struct resource *res, resource_size_t start, resource_size_t size) | {
struct resource *tmp, *parent = res->parent;
resource_size_t end = start + size - 1;
int result = -EBUSY;
write_lock(&resource_lock);
if ((start < parent->start) || (end > parent->end))
goto out;
for (tmp = res->child; tmp; tmp = tmp->sibling) {
if ((tmp->start < start) || (tmp->end > end))
goto out;
}
... | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Returns the total number of whole microseconds in the specified timespan */ | int64_t timespanToMicroseconds(timespan_t *timespan) | /* Returns the total number of whole microseconds in the specified timespan */
int64_t timespanToMicroseconds(timespan_t *timespan) | {
return ((int64_t)timespanToMilliseconds(timespan) * 1000) + timespan->microseconds;
} | microbuilder/LPC11U_LPC13U_CodeBase | C++ | Other | 54 |
/* Accepts multiple requests - one per line in hex format */ | void hex(ModbusSlave *s) | /* Accepts multiple requests - one per line in hex format */
void hex(ModbusSlave *s) | {
char *line = NULL;
size_t linesize = 0;
while (getline(&line, &linesize, stdin) > 0)
{
uint8_t data[1024];
int offset = 0;
unsigned int len = 1;
while (len < sizeof(data) - 2)
{
int c = 0, n = 0;
if (sscanf(&line[offset], "%02x%n", &c, &n) != 1)
break;
offset += n;
data[len++] = c;
}
... | prusa3d/Prusa-Firmware-Buddy | C++ | Other | 1,019 |
/* fast_hmac_sha256 - HMAC-SHA256 over data buffer (RFC 2104) @key: Key for HMAC operations @key_len: Length of the key in bytes @data: Pointers to the data area @data_len: Length of the data area @mac: Buffer for the hash (20 bytes) */ | void fast_hmac_sha256(const uint8_t *key, size_t key_len, const uint8_t *data, size_t data_len, uint8_t *mac) | /* fast_hmac_sha256 - HMAC-SHA256 over data buffer (RFC 2104) @key: Key for HMAC operations @key_len: Length of the key in bytes @data: Pointers to the data area @data_len: Length of the data area @mac: Buffer for the hash (20 bytes) */
void fast_hmac_sha256(const uint8_t *key, size_t key_len, const uint8_t *data, siz... | {
fast_hmac_sha256_vector(key, key_len, 1, &data, &data_len, mac);
} | retro-esp32/RetroESP32 | C++ | Creative Commons Attribution Share Alike 4.0 International | 581 |
/* Checks whether the packet received is a magic packet?. */ | bool synopGMAC_is_magic_packet_received(synopGMACdevice *gmacdev) | /* Checks whether the packet received is a magic packet?. */
bool synopGMAC_is_magic_packet_received(synopGMACdevice *gmacdev) | {
u32 data;
data = synopGMACReadReg(gmacdev->MacBase,GmacPmtCtrlStatus);
return((data & GmacPmtMagicPktReceived) == GmacPmtMagicPktReceived);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* This service enables a PEIM to ascertain the address of the list of HOBs in memory. */ | EFI_STATUS EFIAPI PeiServicesGetHobList(OUT VOID **HobList) | /* This service enables a PEIM to ascertain the address of the list of HOBs in memory. */
EFI_STATUS EFIAPI PeiServicesGetHobList(OUT VOID **HobList) | {
CONST EFI_PEI_SERVICES **PeiServices;
PeiServices = GetPeiServicesTablePointer ();
return (*PeiServices)->GetHobList (PeiServices, HobList);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Initializes the APS dissectors prior to beginning protocol */ | static void proto_init_zbee_aps(void) | /* Initializes the APS dissectors prior to beginning protocol */
static void proto_init_zbee_aps(void) | {
reassembly_table_init(&zbee_aps_reassembly_table,
&addresses_reassembly_table_functions);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* timer without interrupts This function is derived from PowerPC code (read timebase as long long). On ARM it just returns the timer value. */ | unsigned long long get_ticks(void) | /* timer without interrupts This function is derived from PowerPC code (read timebase as long long). On ARM it just returns the timer value. */
unsigned long long get_ticks(void) | {
ulong now = read_timer();
if (lastdec >= now) {
timestamp += lastdec - now;
} else {
timestamp += lastdec + timer_load_val - now;
}
lastdec = now;
return timestamp;
} | EmcraftSystems/u-boot | C++ | Other | 181 |
/* Factorization helper for the command state machine: Submit a CSW read and go to STAT state. */ | static void ub_state_stat(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | /* Factorization helper for the command state machine: Submit a CSW read and go to STAT state. */
static void ub_state_stat(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | {
if (__ub_state_stat(sc, cmd) != 0)
return;
cmd->stat_count = 0;
cmd->state = UB_CMDST_STAT;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Stalls the CPU for at least the given number of ticks. It's invoked by */ | VOID InternalCpuDelay(IN UINT64 Delay) | /* Stalls the CPU for at least the given number of ticks. It's invoked by */
VOID InternalCpuDelay(IN UINT64 Delay) | {
UINT64 Ticks;
Ticks = AsmReadTsc () + Delay;
while (AsmReadTsc () <= Ticks) {
CpuPause ();
}
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Writes requested amount of data to the SPI.
This function will return after writing requested amount of data */ | enum status_code spi_write_buffer_wait(struct spi_module *const module, uint8_t *tx_data, uint16_t length) | /* Writes requested amount of data to the SPI.
This function will return after writing requested amount of data */
enum status_code spi_write_buffer_wait(struct spi_module *const module, uint8_t *tx_data, uint16_t length) | {
return spi_transceive_buffer_wait(module, tx_data, NULL, length);
} | memfault/zero-to-main | C++ | null | 200 |
/* Set Lock Bits.
Set the lock bits for an advanced timer. Three levels of lock providing protection against software errors. Once written they cannot be changed until a timer reset has occurred. */ | void timer_set_break_lock(uint32_t timer_peripheral, uint32_t lock) | /* Set Lock Bits.
Set the lock bits for an advanced timer. Three levels of lock providing protection against software errors. Once written they cannot be changed until a timer reset has occurred. */
void timer_set_break_lock(uint32_t timer_peripheral, uint32_t lock) | {
TIM_BDTR(timer_peripheral) |= lock;
} | libopencm3/libopencm3 | C++ | GNU General Public License v3.0 | 2,931 |
/* tlsv1_server_get_keyblock_size - Get TLS key_block size @conn: TLSv1 server connection data from tlsv1_server_init() Returns: Size of the key_block for the negotiated cipher suite or -1 on failure */ | int tlsv1_server_get_keyblock_size(struct tlsv1_server *conn) | /* tlsv1_server_get_keyblock_size - Get TLS key_block size @conn: TLSv1 server connection data from tlsv1_server_init() Returns: Size of the key_block for the negotiated cipher suite or -1 on failure */
int tlsv1_server_get_keyblock_size(struct tlsv1_server *conn) | {
if (conn->state == CLIENT_HELLO || conn->state == SERVER_HELLO)
return -1;
return 2 * (conn->rl.hash_size + conn->rl.key_material_len +
conn->rl.iv_size);
} | retro-esp32/RetroESP32 | C++ | Creative Commons Attribution Share Alike 4.0 International | 581 |
/* Add platform devices present on this baseboard and init them from CPU side as far as required to use them later on */ | void __init pcm970_baseboard_init(void) | /* Add platform devices present on this baseboard and init them from CPU side as far as required to use them later on */
void __init pcm970_baseboard_init(void) | {
mxc_gpio_setup_multiple_pins(pcm970_pins, ARRAY_SIZE(pcm970_pins),
"PCM970");
mxc_register_device(&mxc_fb_device, &pcm038_fb_data);
mxc_gpio_mode(GPIO_PORTC | 28 | GPIO_GPIO | GPIO_IN);
mxc_register_device(&mxc_sdhc_device1, &sdhc_pdata);
platform_device_register(&pcm970_sja1000);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* This API is used to parse and store the skipped_frame_count from the FIFO data in the structure instance dev. */ | static void unpack_skipped_frame(uint16_t *data_index, const struct bmi160_dev *dev) | /* This API is used to parse and store the skipped_frame_count from the FIFO data in the structure instance dev. */
static void unpack_skipped_frame(uint16_t *data_index, const struct bmi160_dev *dev) | {
if (*data_index >= dev->fifo->length)
{
*data_index = dev->fifo->length;
}
else
{
dev->fifo->skipped_frame_count = dev->fifo->data[*data_index];
*data_index = (*data_index) + 1;
}
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* Calculate GICD_ICFGRn base address and corresponding bit field Int_config of the GIC distributor register. */ | EFI_STATUS GicGetDistributorIcfgBaseAndBit(IN HARDWARE_INTERRUPT_SOURCE Source, OUT UINTN *RegAddress, OUT UINTN *Config1Bit) | /* Calculate GICD_ICFGRn base address and corresponding bit field Int_config of the GIC distributor register. */
EFI_STATUS GicGetDistributorIcfgBaseAndBit(IN HARDWARE_INTERRUPT_SOURCE Source, OUT UINTN *RegAddress, OUT UINTN *Config1Bit) | {
UINTN RegIndex;
UINTN Field;
if (Source >= mGicNumInterrupts) {
ASSERT (Source < mGicNumInterrupts);
return EFI_UNSUPPORTED;
}
RegIndex = Source / ARM_GIC_ICDICFR_F_STRIDE;
Field = Source % ARM_GIC_ICDICFR_F_STRIDE;
*RegAddress = (UINTN)PcdGet64 (PcdGicDistributorBase)
... | tianocore/edk2 | C++ | Other | 4,240 |
/* Try to find a boundary in table 't'. A 'boundary' is an integer index such that t is non-nil and t is nil (and 0 if t is nil). */ | lua_Unsigned luaH_getn(Table *t) | /* Try to find a boundary in table 't'. A 'boundary' is an integer index such that t is non-nil and t is nil (and 0 if t is nil). */
lua_Unsigned luaH_getn(Table *t) | {
unsigned int i = 0;
while (j - i > 1) {
unsigned int m = (i+j)/2;
if (ttisnil(&t->array[m - 1])) j = m;
else i = m;
}
return i;
}
else if (isdummy(t))
return j;
else return unbound_search(t, j);
} | nodemcu/nodemcu-firmware | C++ | MIT License | 7,566 |
/* Returns 0 if access is permitted, an error code otherwise */ | static int smack_inode_rename(struct inode *old_inode, struct dentry *old_dentry, struct inode *new_inode, struct dentry *new_dentry) | /* Returns 0 if access is permitted, an error code otherwise */
static int smack_inode_rename(struct inode *old_inode, struct dentry *old_dentry, struct inode *new_inode, struct dentry *new_dentry) | {
int rc;
char *isp;
struct smk_audit_info ad;
smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_FS);
smk_ad_setfield_u_fs_path_dentry(&ad, old_dentry);
isp = smk_of_inode(old_dentry->d_inode);
rc = smk_curacc(isp, MAY_READWRITE, &ad);
if (rc == 0 && new_dentry->d_inode != NULL) {
isp = smk_of_inode(new_dentry->d_ino... | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Enables or disables the TIMx peripheral Preload register on CCDAT1. */ | void TIM_ConfigOc1Preload(TIM_Module *TIMx, uint16_t TIM_OCPreload) | /* Enables or disables the TIMx peripheral Preload register on CCDAT1. */
void TIM_ConfigOc1Preload(TIM_Module *TIMx, uint16_t TIM_OCPreload) | {
uint16_t tmpccmr1 = 0;
assert_param(IsTimList8Module(TIMx));
assert_param(IsTimOcPreLoadState(TIM_OCPreload));
tmpccmr1 = TIMx->CCMOD1;
tmpccmr1 &= (uint16_t) ~((uint16_t)TIM_CCMOD1_OC1PEN);
tmpccmr1 |= TIM_OCPreload;
TIMx->CCMOD1 = tmpccmr1;
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* Note: this function is being called from a non qemu thread so we need to be careful about what we do here. Generally we only schedule a BH, and do the rest of the io completion handling from rbd_finish_bh() which runs in a qemu context. */ | static void rbd_finish_aiocb(rbd_completion_t c, RADOSCB *rcb) | /* Note: this function is being called from a non qemu thread so we need to be careful about what we do here. Generally we only schedule a BH, and do the rest of the io completion handling from rbd_finish_bh() which runs in a qemu context. */
static void rbd_finish_aiocb(rbd_completion_t c, RADOSCB *rcb) | {
RBDAIOCB *acb = rcb->acb;
rcb->ret = rbd_aio_get_return_value(c);
rbd_aio_release(c);
acb->bh = qemu_bh_new(rbd_finish_bh, rcb);
qemu_bh_schedule(acb->bh);
} | ve3wwg/teensy3_qemu | C++ | Other | 15 |
/* Returns sglq ponter = success, NULL = Failure. */ | static struct lpfc_sglq* __lpfc_clear_active_sglq(struct lpfc_hba *phba, uint16_t xritag) | /* Returns sglq ponter = success, NULL = Failure. */
static struct lpfc_sglq* __lpfc_clear_active_sglq(struct lpfc_hba *phba, uint16_t xritag) | {
uint16_t adj_xri;
struct lpfc_sglq *sglq;
adj_xri = xritag - phba->sli4_hba.max_cfg_param.xri_base;
if (adj_xri > phba->sli4_hba.max_cfg_param.max_xri)
return NULL;
sglq = phba->sli4_hba.lpfc_sglq_active_list[adj_xri];
phba->sli4_hba.lpfc_sglq_active_list[adj_xri] = NULL;
return sglq;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Verify if the supplied sector contains valid fields of a Partition Boot Sector. Internal function. */ | RtStatus_t VerifyPBS(uint8_t *pSectorData) | /* Verify if the supplied sector contains valid fields of a Partition Boot Sector. Internal function. */
RtStatus_t VerifyPBS(uint8_t *pSectorData) | {
uint32_t u8SecValue = 1;
uint8_t u8SecPerClus = pSectorData[0x0d];
uint32_t i;
for (i = 0; i < 8; i++) {
if (u8SecPerClus == u8SecValue) {
break;
}
u8SecValue <<= 1;
}
if ((u8SecValue == 256) || ((pSectorData[0] != 0xEB) && (pSectorData[0] != 0xE9))) {
... | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* DevicePathNode must be SerialAtapi Channel type and this will populate the MappingItem. */ | EFI_STATUS DevPathSerialAtapi(IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode, IN DEVICE_CONSIST_MAPPING_INFO *MappingItem, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath) | /* DevicePathNode must be SerialAtapi Channel type and this will populate the MappingItem. */
EFI_STATUS DevPathSerialAtapi(IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode, IN DEVICE_CONSIST_MAPPING_INFO *MappingItem, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath) | {
ATAPI_DEVICE_PATH *Atapi;
ASSERT (DevicePathNode != NULL);
ASSERT (MappingItem != NULL);
Atapi = (ATAPI_DEVICE_PATH *)DevicePathNode;
return AppendCSDNum (MappingItem, (Atapi->PrimarySecondary * 2 + Atapi->SlaveMaster));
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Get the instance id for this opened joystick */ | SDL_JoystickID SDL_JoystickInstanceID(SDL_Joystick *joystick) | /* Get the instance id for this opened joystick */
SDL_JoystickID SDL_JoystickInstanceID(SDL_Joystick *joystick) | {
if (!SDL_PrivateJoystickValid(joystick)) {
return -1;
}
return joystick->instance_id;
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Output a string to the usb client port - implementing flow control */ | static void __usbtty_puts(const char *str, int len) | /* Output a string to the usb client port - implementing flow control */
static void __usbtty_puts(const char *str, int len) | {
int maxlen = usbtty_output.totalsize;
int space, n;
while (len > 0) {
usbtty_poll ();
space = maxlen - usbtty_output.size;
if (space) {
write_buffer (&usbtty_output);
n = MIN (space, MIN (len, maxlen));
buf_push (&usbtty_output, str, n);
str += n;
len -= n;
}
}
} | EmcraftSystems/u-boot | C++ | Other | 181 |
/* Get pointer to a block of DMA memory, allocate if necessary. This is used if the application provided buffer is not in DMA capable memory. */ | static esp_err_t get_block_buf(int slot, uint8_t **out_buf) | /* Get pointer to a block of DMA memory, allocate if necessary. This is used if the application provided buffer is not in DMA capable memory. */
static esp_err_t get_block_buf(int slot, uint8_t **out_buf) | {
if (s_slots[slot].block_buf == NULL) {
s_slots[slot].block_buf = heap_caps_malloc(SDSPI_BLOCK_BUF_SIZE, MALLOC_CAP_DMA);
if (s_slots[slot].block_buf == NULL) {
return ESP_ERR_NO_MEM;
}
}
*out_buf = s_slots[slot].block_buf;
return ESP_OK;
} | retro-esp32/RetroESP32 | C++ | Creative Commons Attribution Share Alike 4.0 International | 581 |
/* ZigBee Device Profile dissector for the discovery cache */ | void dissect_zbee_zdp_req_discovery_cache(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) | /* ZigBee Device Profile dissector for the discovery cache */
void dissect_zbee_zdp_req_discovery_cache(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) | {
guint offset = 0;
guint64 ext_addr; zbee_parse_uint(tree, hf_zbee_zdp_device, tvb, &offset, (int)sizeof(guint16), NULL);
ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, (int)sizeof(guint64), NULL);
zbee_append_info(tree, pinfo, ", Device: %s", eui64_to_display(wmem_packet_scope... | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* stmmac_mdio_write @bus: points to the mii_bus structure @phyaddr: MII addr reg bits 15-11 @phyreg: MII addr reg bits 10-6 @phydata: phy data Description: it writes the data into the MII register from within the device. */ | static int stmmac_mdio_write(struct mii_bus *bus, int phyaddr, int phyreg, u16 phydata) | /* stmmac_mdio_write @bus: points to the mii_bus structure @phyaddr: MII addr reg bits 15-11 @phyreg: MII addr reg bits 10-6 @phydata: phy data Description: it writes the data into the MII register from within the device. */
static int stmmac_mdio_write(struct mii_bus *bus, int phyaddr, int phyreg, u16 phydata) | {
struct net_device *ndev = bus->priv;
struct stmmac_priv *priv = netdev_priv(ndev);
unsigned long ioaddr = ndev->base_addr;
unsigned int mii_address = priv->mac_type->hw.mii.addr;
unsigned int mii_data = priv->mac_type->hw.mii.data;
u16 value =
(((phyaddr << 11) & (0x0000F800)) | ((phyreg << 6) & (0x000007C... | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* I2C Disable ACK.
Disables acking of own 7/10 bit address */ | void i2c_disable_ack(uint32_t i2c) | /* I2C Disable ACK.
Disables acking of own 7/10 bit address */
void i2c_disable_ack(uint32_t i2c) | {
I2C_CR1(i2c) &= ~I2C_CR1_ACK;
} | insane-adding-machines/unicore-mx | C++ | GNU General Public License v3.0 | 50 |
/* Checks if Big Number equals to the given Num. */ | BOOLEAN EFIAPI BigNumIsWord(IN CONST VOID *Bn, IN UINTN Num) | /* Checks if Big Number equals to the given Num. */
BOOLEAN EFIAPI BigNumIsWord(IN CONST VOID *Bn, IN UINTN Num) | {
return (BOOLEAN)BN_is_word (Bn, Num);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Returns the previous value of the deregistration function */ | xmlDeregisterNodeFunc xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func) | /* Returns the previous value of the deregistration function */
xmlDeregisterNodeFunc xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func) | {
xmlDeregisterNodeFunc old = xmlDeregisterNodeDefaultValue;
__xmlRegisterCallbacks = 1;
xmlDeregisterNodeDefaultValue = func;
return(old);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* USBH_GetNextDesc This function return the next descriptor header. */ | USBH_DescHeader_t* USBH_GetNextDesc(uint8_t *pbuf, uint16_t *ptr) | /* USBH_GetNextDesc This function return the next descriptor header. */
USBH_DescHeader_t* USBH_GetNextDesc(uint8_t *pbuf, uint16_t *ptr) | {
USBH_DescHeader_t *pnext;
*ptr += ((USBH_DescHeader_t *)pbuf)->bLength;
pnext = (USBH_DescHeader_t *)((uint8_t *)pbuf + \
((USBH_DescHeader_t *)pbuf)->bLength);
return(pnext);
} | MaJerle/stm32f429 | C++ | null | 2,036 |
/* Must be protected by xfrm_cfg_mutex. State and tunnel user references are always incremented on success. */ | static int ipcomp_tunnel_attach(struct xfrm_state *x) | /* Must be protected by xfrm_cfg_mutex. State and tunnel user references are always incremented on success. */
static int ipcomp_tunnel_attach(struct xfrm_state *x) | {
int err = 0;
struct xfrm_state *t;
t = xfrm_state_lookup(&init_net, (xfrm_address_t *)&x->id.daddr.a4,
x->props.saddr.a4, IPPROTO_IPIP, AF_INET);
if (!t) {
t = ipcomp_tunnel_create(x);
if (!t) {
err = -EINVAL;
goto out;
}
xfrm_state_insert(t);
xfrm_state_hold(t);
}
x->tunnel = t;
atomi... | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* MSS_GPIO_config See "mss_gpio.h" for details of how to use this function. */ | void MSS_GPIO_config(mss_gpio_id_t port_id, uint32_t config) | /* MSS_GPIO_config See "mss_gpio.h" for details of how to use this function. */
void MSS_GPIO_config(mss_gpio_id_t port_id, uint32_t config) | {
uint32_t gpio_idx = (uint32_t)port_id;
ASSERT(gpio_idx < NB_OF_GPIO);
if(gpio_idx < NB_OF_GPIO)
{
*(g_config_reg_lut[gpio_idx]) = config;
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Divide a by b, and return rounded integer. */ | CLR_INT32 RoundDiv(CLR_INT32 a, CLR_INT32 b) | /* Divide a by b, and return rounded integer. */
CLR_INT32 RoundDiv(CLR_INT32 a, CLR_INT32 b) | {
if (b == 0)
return 0xFFFF;
CLR_INT32 d = a / b;
CLR_INT32 r = abs(a) % abs(b);
if ((r * 2) > abs(a))
{
d = (abs(d) + 1) * sign(b) * sign(a);
}
return d;
} | nanoframework/nf-interpreter | C++ | MIT License | 293 |
/* PIO to indicate that memory mapped Q contains valid descriptor(s). */ | static void doorbell_pio(struct adapter *adapter, u32 val) | /* PIO to indicate that memory mapped Q contains valid descriptor(s). */
static void doorbell_pio(struct adapter *adapter, u32 val) | {
wmb();
writel(val, adapter->regs + A_SG_DOORBELL);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Enable the DMA Tx Desc padding for frame shorter than 64 bytes. */ | void ETH_EnableDMATxDescShortFramePadding(ETH_DMADescConfig_T *DMATxDesc) | /* Enable the DMA Tx Desc padding for frame shorter than 64 bytes. */
void ETH_EnableDMATxDescShortFramePadding(ETH_DMADescConfig_T *DMATxDesc) | {
DMATxDesc->Status &= (~(uint32_t)ETH_DMATXDESC_DISP);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* get_line() makes sure to only return complete whole lines that fit in 'len' bytes and end with a newline. */ | char* Curl_get_line(char *buf, int len, FILE *input) | /* get_line() makes sure to only return complete whole lines that fit in 'len' bytes and end with a newline. */
char* Curl_get_line(char *buf, int len, FILE *input) | {
bool partial = FALSE;
while(1) {
char *b = fgets(buf, len, input);
if(b) {
size_t rlen = strlen(b);
if(rlen && (b[rlen-1] == '\n')) {
if(partial) {
partial = FALSE;
continue;
}
return b;
}
partial = TRUE;
}
else
break;
}
... | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Enable the automatic slave select function of the specified SPI port.
The */ | void SPIAutoSSEnable(unsigned long ulBase, unsigned long ulSlaveSel) | /* Enable the automatic slave select function of the specified SPI port.
The */
void SPIAutoSSEnable(unsigned long ulBase, unsigned long ulSlaveSel) | {
xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)||
(ulBase == SPI2_BASE)||(ulBase == SPI3_BASE) );
xASSERT((ulSlaveSel == SPI_SS_NONE) || (ulSlaveSel == SPI_SS0) ||
(ulSlaveSel == SPI_SS1) || (ulSlaveSel == SPI_SS0_SS1));
xHWREG(ulBase + SPI_SSR) |= SPI_AUTOSS;
xHWREG(ulB... | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* UART Set Baudrate.
The baud rate is computed from the IPG bus clock. The bus clock must be calculated by using ccm_calculate_clocks before calling this function. */ | void uart_set_baudrate(uint32_t uart, uint32_t baud) | /* UART Set Baudrate.
The baud rate is computed from the IPG bus clock. The bus clock must be calculated by using ccm_calculate_clocks before calling this function. */
void uart_set_baudrate(uint32_t uart, uint32_t baud) | {
uint32_t bd_clk = ccm_ipg_bus_clk / baud;
uint32_t sbr;
bd_clk /= 8;
sbr = bd_clk / 2 + (bd_clk & 0x1);
UART_BDL(uart) = sbr & UART_BDL_SBR_MASK;
UART_BDH(uart) = (sbr >> 8) & UART_BDH_SBR_MASK;
} | insane-adding-machines/unicore-mx | C++ | GNU General Public License v3.0 | 50 |
/* 3.c Cell Identifier List Segment for cells to be established */ | static guint16 be_cell_id_lst_seg_f_cell_tb_est(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_) | /* 3.c Cell Identifier List Segment for cells to be established */
static guint16 be_cell_id_lst_seg_f_cell_tb_est(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_) | {
guint32 curr_offset;
curr_offset = offset;
proto_tree_add_bits_item(tree, hf_gsm_a_bssmap_spare_bits, tvb, curr_offset<<3, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_gsm_a_bssap_cell_id_list_seg_cell_id_disc, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
curr_offset++;
proto_tree_add_expert(tree... | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Change the controller for the specified range of irq, which will be used to manage these irq. auto/user irq already have a default controller, which can be changed as well, but the controller probably should use m68k_irq_startup/ m68k_irq_shutdown. */ | void m68k_setup_irq_controller(struct irq_controller *contr, unsigned int irq, unsigned int cnt) | /* Change the controller for the specified range of irq, which will be used to manage these irq. auto/user irq already have a default controller, which can be changed as well, but the controller probably should use m68k_irq_startup/ m68k_irq_shutdown. */
void m68k_setup_irq_controller(struct irq_controller *contr, uns... | {
int i;
for (i = 0; i < cnt; i++)
irq_controller[irq + i] = contr;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Calibration is achieved via the mhz_delay_count device tree parameter. See lattice,ice40-fpga.yaml for details. */ | static void fpga_ice40_delay(size_t n) | /* Calibration is achieved via the mhz_delay_count device tree parameter. See lattice,ice40-fpga.yaml for details. */
static void fpga_ice40_delay(size_t n) | {
for (; n > 0; --n) {
__asm__ __volatile__("");
}
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* These exports can't be _GPL due to .h files using this within them, and it might break something that was previously working... */ | void* dev_get_drvdata(const struct device *dev) | /* These exports can't be _GPL due to .h files using this within them, and it might break something that was previously working... */
void* dev_get_drvdata(const struct device *dev) | {
if (dev && dev->p)
return dev->p->driver_data;
return NULL;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* fc_change_queue_depth() - Change a device's queue depth @sdev: The SCSI device whose queue depth is to change @qdepth: The new queue depth @reason: The resason for the change */ | int fc_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason) | /* fc_change_queue_depth() - Change a device's queue depth @sdev: The SCSI device whose queue depth is to change @qdepth: The new queue depth @reason: The resason for the change */
int fc_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason) | {
switch (reason) {
case SCSI_QDEPTH_DEFAULT:
scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth);
break;
case SCSI_QDEPTH_QFULL:
scsi_track_queue_full(sdev, qdepth);
break;
case SCSI_QDEPTH_RAMP_UP:
scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth);
break;
default:
return -EO... | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Description: This does WB_SYNC_NONE opportunistic writeback. The IO is only started when this function returns, we make no guarentees on completion. Caller need not hold sb s_umount semaphore. */ | void bdi_start_writeback(struct backing_dev_info *bdi, struct super_block *sb, long nr_pages) | /* Description: This does WB_SYNC_NONE opportunistic writeback. The IO is only started when this function returns, we make no guarentees on completion. Caller need not hold sb s_umount semaphore. */
void bdi_start_writeback(struct backing_dev_info *bdi, struct super_block *sb, long nr_pages) | {
struct wb_writeback_args args = {
.sb = sb,
.sync_mode = WB_SYNC_NONE,
.nr_pages = nr_pages,
.range_cyclic = 1,
};
if (!nr_pages) {
args.nr_pages = LONG_MAX;
args.for_background = 1;
}
bdi_alloc_queue_work(bdi, &args);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Callback function that returns the pdu length. Used by TCP dissector. */ | static guint get_knet_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_) | /* Callback function that returns the pdu length. Used by TCP dissector. */
static guint get_knet_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_) | {
return count_vle_bytes(tvb, offset) + dissect_content_length_vle(tvb, &offset, NULL);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* param handle codec handle. param channel audio codec play channel, can be a value or combine value of _codec_play_channel. param mute true is mute, false is unmute. return kStatus_Success is success, else configure failed. */ | status_t CODEC_SetMute(codec_handle_t *handle, uint32_t channel, bool mute) | /* param handle codec handle. param channel audio codec play channel, can be a value or combine value of _codec_play_channel. param mute true is mute, false is unmute. return kStatus_Success is success, else configure failed. */
status_t CODEC_SetMute(codec_handle_t *handle, uint32_t channel, bool mute) | {
assert((handle != NULL) && (handle->codecConfig != NULL));
assert(handle->codecCapability != NULL);
if ((GET_PLAY_CHANNEL_CAPABILITY(handle->codecCapability->codecPlayCapability) & channel) == 0U)
{
return kStatus_CODEC_NotSupport;
}
return HAL_CODEC_SetMute(handle, channel, mute);
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* Return whether the integer string is a hex string. */ | BOOLEAN IsHexStr(CHAR16 *Str) | /* Return whether the integer string is a hex string. */
BOOLEAN IsHexStr(CHAR16 *Str) | {
while ((*Str != 0) && *Str == L' ') {
Str ++;
}
while ((*Str != 0) && *Str == L'0') {
Str ++;
}
return (BOOLEAN) (*Str == L'x' || *Str == L'X');
} | tianocore/edk2 | C++ | Other | 4,240 |
/* For licensing information, see the file 'LICENCE' in this directory. */ | static int jffs2_user_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size, int type) | /* For licensing information, see the file 'LICENCE' in this directory. */
static int jffs2_user_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size, int type) | {
if (!strcmp(name, ""))
return -EINVAL;
return do_jffs2_getxattr(dentry->d_inode, JFFS2_XPREFIX_USER,
name, buffer, size);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Program QMSPI frequency. MEC1501 base frequency is 48MHz. QMSPI frequency divider field in the mode register is defined as: 0=maximum divider of 256. Values 1 through 255 divide 48MHz by that value. */ | static void qmspi_set_frequency(QMSPI_Type *regs, uint32_t freq_hz) | /* Program QMSPI frequency. MEC1501 base frequency is 48MHz. QMSPI frequency divider field in the mode register is defined as: 0=maximum divider of 256. Values 1 through 255 divide 48MHz by that value. */
static void qmspi_set_frequency(QMSPI_Type *regs, uint32_t freq_hz) | {
uint32_t div, qmode;
if (freq_hz == 0) {
div = 0;
} else {
div = MCHP_QMSPI_INPUT_CLOCK_FREQ_HZ / freq_hz;
if (div == 0) {
div = 1;
} else if (div > 0xffu) {
div = 0u;
}
}
qmode = regs->MODE & ~(MCHP_QMSPI_M_FDIV_MASK);
qmode |= (div << MCHP_QMSPI_M_FDIV_POS) & MCHP_QMSPI_M_FDIV_MASK;
regs->MOD... | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Return: Executed command, or -1 if not recognized */ | int fastboot_handle_command(char *cmd_string, char *response) | /* Return: Executed command, or -1 if not recognized */
int fastboot_handle_command(char *cmd_string, char *response) | {
int i;
char *cmd_parameter;
cmd_parameter = cmd_string;
strsep(&cmd_parameter, ":");
for (i = 0; i < FASTBOOT_COMMAND_COUNT; i++) {
if (!strcmp(commands[i].command, cmd_string)) {
if (commands[i].dispatch) {
commands[i].dispatch(cmd_parameter,
response);
return i;
} else {
break;
}
... | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Writing to the status register resets the ICAP logic in an internal version of the core. For the version of the core published in EDK, this is a noop. */ | void buffer_icap_reset(struct hwicap_drvdata *drvdata) | /* Writing to the status register resets the ICAP logic in an internal version of the core. For the version of the core published in EDK, this is a noop. */
void buffer_icap_reset(struct hwicap_drvdata *drvdata) | {
out_be32(drvdata->base_address + XHI_STATUS_REG_OFFSET, 0xFEFE);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This function enter the QSPI memory in deep power down mode. */ | uint8_t BSP_QSPI_EnterDeepPowerDown(void) | /* This function enter the QSPI memory in deep power down mode. */
uint8_t BSP_QSPI_EnterDeepPowerDown(void) | {
QSPI_CommandTypeDef sCommand;
sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE;
sCommand.Instruction = DEEP_POWER_DOWN_CMD;
sCommand.AddressMode = QSPI_ADDRESS_NONE;
sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE;
sCommand.DataMode = QSPI_DATA_NONE;
sCommand.DummyCycles ... | eclipse-threadx/getting-started | C++ | Other | 310 |
/* Task function for blinking the LED as a fixed timer interval. */ | void LedBlinkTask(void) | /* Task function for blinking the LED as a fixed timer interval. */
void LedBlinkTask(void) | {
static blt_bool ledOn = BLT_FALSE;
static blt_int32u nextBlinkEvent = 0;
if (TimerGet() >= nextBlinkEvent)
{
if (ledOn == BLT_FALSE)
{
ledOn = BLT_TRUE;
LL_GPIO_SetOutputPin(GPIOE, LL_GPIO_PIN_8);
}
else
{
ledOn = BLT_FALSE;
LL_GPIO_ResetOutputPin(GPIOE, LL_GPIO_PIN... | feaser/openblt | C++ | GNU General Public License v3.0 | 601 |
/* Disable the UART, RX, and TX.
This function disables the UART, RX, and TX. */ | void am_hal_uart_disable(uint32_t ui32Module) | /* Disable the UART, RX, and TX.
This function disables the UART, RX, and TX. */
void am_hal_uart_disable(uint32_t ui32Module) | {
AM_REGan_CLR(UART, ui32Module, CR, (AM_REG_UART_CR_UARTEN_M |
AM_REG_UART_CR_RXE_M |
AM_REG_UART_CR_TXE_M) );
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* This function is the entry point for a PEIM. This function must call ProcessLibraryConstructorList() and ProcessModuleEntryPointList(). The return value from ProcessModuleEntryPointList() is returned. If _gPeimRevision is not zero and PeiServices->Hdr.Revision is less than _gPeimRevison, then ASSERT(). */ | EFI_STATUS EFIAPI _ModuleEntryPoint(IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices) | /* This function is the entry point for a PEIM. This function must call ProcessLibraryConstructorList() and ProcessModuleEntryPointList(). The return value from ProcessModuleEntryPointList() is returned. If _gPeimRevision is not zero and PeiServices->Hdr.Revision is less than _gPeimRevison, then ASSERT(). */
EFI_STATUS... | {
if (_gPeimRevision != 0) {
ASSERT ((*PeiServices)->Hdr.Revision >= _gPeimRevision);
}
ProcessLibraryConstructorList (FileHandle, PeiServices);
return ProcessModuleEntryPointList (FileHandle, PeiServices);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* If HmacSha256Context is NULL, then return FALSE. If NewHmacSha256Context is NULL, then return FALSE. */ | BOOLEAN EFIAPI HmacSha256Duplicate(IN CONST VOID *HmacSha256Context, OUT VOID *NewHmacSha256Context) | /* If HmacSha256Context is NULL, then return FALSE. If NewHmacSha256Context is NULL, then return FALSE. */
BOOLEAN EFIAPI HmacSha256Duplicate(IN CONST VOID *HmacSha256Context, OUT VOID *NewHmacSha256Context) | {
return HmacMdDuplicate (MBEDTLS_MD_SHA256, HmacSha256Context, NewHmacSha256Context);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Worker function returns the firmware usable variable MTRR count for the CPU. */ | UINT32 GetFirmwareVariableMtrrCountWorker(VOID) | /* Worker function returns the firmware usable variable MTRR count for the CPU. */
UINT32 GetFirmwareVariableMtrrCountWorker(VOID) | {
UINT32 VariableMtrrCount;
UINT32 ReservedMtrrNumber;
VariableMtrrCount = GetVariableMtrrCountWorker ();
ReservedMtrrNumber = PcdGet32 (PcdCpuNumberOfReservedVariableMtrrs);
if (VariableMtrrCount < ReservedMtrrNumber) {
return 0;
}
return VariableMtrrCount - ReservedMtrrNumber;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Copy bytes from SrcBuffer to DstBuffer and convert to upper case. Don't copy more than MaxDstBufferSize bytes. */ | EFI_STATUS EFIAPI AmlUpperCaseMemCpyS(OUT CHAR8 *DstBuffer, IN UINT32 MaxDstBufferSize, IN CONST CHAR8 *SrcBuffer, IN UINT32 Count) | /* Copy bytes from SrcBuffer to DstBuffer and convert to upper case. Don't copy more than MaxDstBufferSize bytes. */
EFI_STATUS EFIAPI AmlUpperCaseMemCpyS(OUT CHAR8 *DstBuffer, IN UINT32 MaxDstBufferSize, IN CONST CHAR8 *SrcBuffer, IN UINT32 Count) | {
UINT32 Index;
if ((DstBuffer == NULL) ||
(SrcBuffer == NULL))
{
ASSERT (0);
return EFI_INVALID_PARAMETER;
}
if (Count == 0) {
return EFI_SUCCESS;
}
if (Count > MaxDstBufferSize) {
Count = MaxDstBufferSize;
}
for (Index = 0; Index < Count; Index++) {
if ((SrcBuffer[Index] >... | tianocore/edk2 | C++ | Other | 4,240 |
/* Returns: a 16 bit hint value, with the service bit set */ | __u16 irlmp_service_to_hint(int service) | /* Returns: a 16 bit hint value, with the service bit set */
__u16 irlmp_service_to_hint(int service) | {
__u16_host_order hint;
hint.byte[0] = service_hint_mapping[service][0];
hint.byte[1] = service_hint_mapping[service][1];
return hint.word;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Function for encoding device address to Bluetooth Carrier Configuration EP record.
This fuction is used to encode device address to Bluetooth Carrier Configuration EP record. */ | static ret_code_t nfc_ep_oob_bluetooth_device_address_encode(uint8_t *const p_encoded_data, uint16_t max_len) | /* Function for encoding device address to Bluetooth Carrier Configuration EP record.
This fuction is used to encode device address to Bluetooth Carrier Configuration EP record. */
static ret_code_t nfc_ep_oob_bluetooth_device_address_encode(uint8_t *const p_encoded_data, uint16_t max_len) | {
ret_code_t err_code = NRF_SUCCESS;
ble_gap_addr_t device_address;
if (NFC_EP_OOB_REC_GAP_ADDR_LEN > max_len)
{
return NRF_ERROR_NO_MEM;
}
err_code = sd_ble_gap_address_get(&device_address);
if (err_code != NRF_SUCCESS)
{
return err_code;
}
memcpy(p_encoded... | labapart/polymcu | C++ | null | 201 |
/* __iio_request_ring_buffer_event_chrdev() allocate ring event chrdev @buf: ring buffer whose event chrdev we are allocating @owner: the module who owns the ring buffer (for ref counting) @dev: device with which the chrdev is associated */ | static int __iio_request_ring_buffer_event_chrdev(struct iio_ring_buffer *buf, int id, struct module *owner, struct device *dev) | /* __iio_request_ring_buffer_event_chrdev() allocate ring event chrdev @buf: ring buffer whose event chrdev we are allocating @owner: the module who owns the ring buffer (for ref counting) @dev: device with which the chrdev is associated */
static int __iio_request_ring_buffer_event_chrdev(struct iio_ring_buffer *buf,... | {
int ret;
ret = iio_get_new_idr_val(&iio_ring_event_idr);
if (ret < 0)
goto error_ret;
else
buf->ev_int.id = ret;
snprintf(buf->ev_int._name, 20,
"ring_event_line%d",
buf->ev_int.id);
ret = iio_setup_ev_int(&(buf->ev_int),
buf->ev_int._name,
owner,
dev);
if (ret)
goto e... | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Reads the specified DAC channel data output value. */ | uint16_t DAC_ReadDataOutputValue(DAC_CHANNEL_T channel) | /* Reads the specified DAC channel data output value. */
uint16_t DAC_ReadDataOutputValue(DAC_CHANNEL_T channel) | {
__IO uint32_t temp = 0;
temp = (uint32_t) DAC_BASE ;
temp += 0x0000002C + ((uint32_t)channel >> 2);
return (uint16_t)(*(__IO uint32_t *) temp);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* param handle codec handle. param config codec configuration. return kStatus_Success is success, else initial failed. */ | status_t HAL_CODEC_Init(void *handle, void *config) | /* param handle codec handle. param config codec configuration. return kStatus_Success is success, else initial failed. */
status_t HAL_CODEC_Init(void *handle, void *config) | {
assert((config != NULL) && (handle != NULL));
codec_config_t *codecConfig = (codec_config_t *)config;
cs42888_config_t *cs42888Config = (cs42888_config_t *)(codecConfig->codecDevConfig);
cs42888_handle_t *cs42888Handle = (cs42888_handle_t *)((uint32_t)(((codec_handle_t *)handle)->codecDevHandle));
... | eclipse-threadx/getting-started | C++ | Other | 310 |
/* This function converts a string to ACPI table signature. */ | STATIC UINT32 ConvertStrToAcpiSignature(IN CONST CHAR16 *Str) | /* This function converts a string to ACPI table signature. */
STATIC UINT32 ConvertStrToAcpiSignature(IN CONST CHAR16 *Str) | {
UINT8 Index;
CHAR8 Ptr[4];
ZeroMem (Ptr, sizeof (Ptr));
Index = 0;
while ((Index < 4) && (Str[Index] != 0)) {
if ((Str[Index] >= L'a') && (Str[Index] <= L'z')) {
Ptr[Index] = (CHAR8)(Str[Index] - (L'a' - L'A'));
} else {
Ptr[Index] = (CHAR8)Str[Index];
}
Index++;
}
return *... | tianocore/edk2 | C++ | Other | 4,240 |
/* (Ensure that all memory it bound is unbound.) */ | void agp_backend_release(struct agp_bridge_data *bridge) | /* (Ensure that all memory it bound is unbound.) */
void agp_backend_release(struct agp_bridge_data *bridge) | {
if (bridge)
atomic_dec(&bridge->agp_in_use);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Get the mapped of a number given an input and output range */ | int32_t lv_map(int32_t x, int32_t min_in, int32_t max_in, int32_t min_out, int32_t max_out) | /* Get the mapped of a number given an input and output range */
int32_t lv_map(int32_t x, int32_t min_in, int32_t max_in, int32_t min_out, int32_t max_out) | {
if(x >= max_in) return max_out;
if(x <= min_in) return min_out;
int32_t delta_in = max_in - min_in;
int32_t delta_out = max_out - min_out;
return ((x - min_in) * delta_out) / delta_in + min_out;
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* This function builds the Ip4 configdata from the Udp4ConfigData. */ | VOID Udp4BuildIp4ConfigData(IN EFI_UDP4_CONFIG_DATA *Udp4ConfigData, IN OUT EFI_IP4_CONFIG_DATA *Ip4ConfigData) | /* This function builds the Ip4 configdata from the Udp4ConfigData. */
VOID Udp4BuildIp4ConfigData(IN EFI_UDP4_CONFIG_DATA *Udp4ConfigData, IN OUT EFI_IP4_CONFIG_DATA *Ip4ConfigData) | {
CopyMem (Ip4ConfigData, &mIp4IoDefaultIpConfigData, sizeof (*Ip4ConfigData));
Ip4ConfigData->DefaultProtocol = EFI_IP_PROTO_UDP;
Ip4ConfigData->AcceptBroadcast = Udp4ConfigData->AcceptBroadcast;
Ip4ConfigData->AcceptPromiscuous = Udp4ConfigData->AcceptPromiscuous;
Ip4ConfigData->UseDefaultAddress = Udp4... | tianocore/edk2 | C++ | Other | 4,240 |
/* Returns zero if successful, or a negative code at error. */ | int snd_dma_reserve_buf(struct snd_dma_buffer *dmab, unsigned int id) | /* Returns zero if successful, or a negative code at error. */
int snd_dma_reserve_buf(struct snd_dma_buffer *dmab, unsigned int id) | {
struct snd_mem_list *mem;
if (WARN_ON(!dmab))
return -EINVAL;
mem = kmalloc(sizeof(*mem), GFP_KERNEL);
if (! mem)
return -ENOMEM;
mutex_lock(&list_mutex);
mem->buffer = *dmab;
mem->id = id;
list_add_tail(&mem->list, &mem_list_head);
mutex_unlock(&list_mutex);
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Init all required variables. Clone the handling from Vegas module implementation. */ | static void tcp_lp_init(struct sock *sk) | /* Init all required variables. Clone the handling from Vegas module implementation. */
static void tcp_lp_init(struct sock *sk) | {
struct lp *lp = inet_csk_ca(sk);
lp->flag = 0;
lp->sowd = 0;
lp->owd_min = 0xffffffff;
lp->owd_max = 0;
lp->owd_max_rsv = 0;
lp->remote_hz = 0;
lp->remote_ref_time = 0;
lp->local_ref_time = 0;
lp->last_drop = 0;
lp->inference = 0;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Free an EFI_BOOT_MANGER_LOAD_OPTION entry that was allocate by the library. */ | EFI_STATUS EFIAPI EfiBootManagerFreeLoadOption(IN EFI_BOOT_MANAGER_LOAD_OPTION *LoadOption) | /* Free an EFI_BOOT_MANGER_LOAD_OPTION entry that was allocate by the library. */
EFI_STATUS EFIAPI EfiBootManagerFreeLoadOption(IN EFI_BOOT_MANAGER_LOAD_OPTION *LoadOption) | {
if (LoadOption == NULL) {
return EFI_NOT_FOUND;
}
if (LoadOption->Description != NULL) {
FreePool (LoadOption->Description);
}
if (LoadOption->FilePath != NULL) {
FreePool (LoadOption->FilePath);
}
if (LoadOption->OptionalData != NULL) {
FreePool (LoadOption->OptionalData);
}
return ... | tianocore/edk2 | C++ | Other | 4,240 |
/* Returns: the value corresponding to the found key, or NULL if the key was not found */ | gpointer g_tree_search(GTree *tree, GCompareFunc search_func, gconstpointer user_data) | /* Returns: the value corresponding to the found key, or NULL if the key was not found */
gpointer g_tree_search(GTree *tree, GCompareFunc search_func, gconstpointer user_data) | {
g_return_val_if_fail (tree != NULL, NULL);
if (tree->root)
return g_tree_node_search (tree->root, search_func, user_data);
else
return NULL;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Lookup for a vport withing a fabric given its pwwn */ | struct bfa_fcs_vport_s* bfa_fcs_fabric_vport_lookup(struct bfa_fcs_fabric_s *fabric, wwn_t pwwn) | /* Lookup for a vport withing a fabric given its pwwn */
struct bfa_fcs_vport_s* bfa_fcs_fabric_vport_lookup(struct bfa_fcs_fabric_s *fabric, wwn_t pwwn) | {
struct bfa_fcs_vport_s *vport;
struct list_head *qe;
list_for_each(qe, &fabric->vport_q) {
vport = (struct bfa_fcs_vport_s *)qe;
if (bfa_fcs_port_get_pwwn(&vport->lport) == pwwn)
return vport;
}
return NULL;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Description: The block layer may perform asynchronous callback activity on a queue, such as calling the unplug function after a timeout. A block device may call blk_sync_queue to ensure that any such activity is cancelled, thus allowing it to release resources that the callbacks might use. The caller must already ha... | void blk_sync_queue(struct request_queue *q) | /* Description: The block layer may perform asynchronous callback activity on a queue, such as calling the unplug function after a timeout. A block device may call blk_sync_queue to ensure that any such activity is cancelled, thus allowing it to release resources that the callbacks might use. The caller must already ha... | {
del_timer_sync(&q->unplug_timer);
del_timer_sync(&q->timeout);
cancel_work_sync(&q->unplug_work);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* DevicePathNode must be SerialFibre Channel type and this will populate the MappingItem. */ | EFI_STATUS DevPathSerialFibre(IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode, IN DEVICE_CONSIST_MAPPING_INFO *MappingItem, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath) | /* DevicePathNode must be SerialFibre Channel type and this will populate the MappingItem. */
EFI_STATUS DevPathSerialFibre(IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode, IN DEVICE_CONSIST_MAPPING_INFO *MappingItem, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath) | {
EFI_STATUS Status;
FIBRECHANNEL_DEVICE_PATH *Fibre;
ASSERT (DevicePathNode != NULL);
ASSERT (MappingItem != NULL);
Fibre = (FIBRECHANNEL_DEVICE_PATH *)DevicePathNode;
Status = AppendCSDNum (MappingItem, Fibre->WWN);
if (!EFI_ERROR (Status)) {
Status = AppendCSDNum (MappingItem, Fibr... | tianocore/edk2 | C++ | Other | 4,240 |
/* Starts the TIMER PWM signal generation on the complementary output. in interrupt mode. */ | void ald_timer_pwmn_start_by_it(ald_timer_handle_t *hperh, ald_timer_channel_t ch) | /* Starts the TIMER PWM signal generation on the complementary output. in interrupt mode. */
void ald_timer_pwmn_start_by_it(ald_timer_handle_t *hperh, ald_timer_channel_t ch) | {
ald_timer_ocn_start_by_it(hperh, ch);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Allow ioctl operations by apps only if they have superuser privilege. */ | static int mraid_mm_open(struct inode *, struct file *) | /* Allow ioctl operations by apps only if they have superuser privilege. */
static int mraid_mm_open(struct inode *, struct file *) | {
if (!capable(CAP_SYS_ADMIN)) return (-EACCES);
cycle_kernel_lock();
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Try to allocate a specific address range: must be in defined memory but not reserved */ | phys_addr_t lmb_alloc_addr(struct lmb *lmb, phys_addr_t base, phys_size_t size) | /* Try to allocate a specific address range: must be in defined memory but not reserved */
phys_addr_t lmb_alloc_addr(struct lmb *lmb, phys_addr_t base, phys_size_t size) | {
long rgn;
rgn = lmb_overlaps_region(&lmb->memory, base, size);
if (rgn >= 0) {
if (lmb_addrs_overlap(lmb->memory.region[rgn].base,
lmb->memory.region[rgn].size,
base + size - 1, 1)) {
if (lmb_reserve(lmb, base, size) >= 0)
return base;
}
}
return 0;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.