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
|
|---|---|---|---|---|---|---|---|
/* Fills a target buffer with a 32-bit value, and returns the target buffer. */
|
VOID* EFIAPI InternalMemSetMem32(OUT VOID *Buffer, IN UINTN Length, IN UINT32 Value)
|
/* Fills a target buffer with a 32-bit value, and returns the target buffer. */
VOID* EFIAPI InternalMemSetMem32(OUT VOID *Buffer, IN UINTN Length, IN UINT32 Value)
|
{
for ( ; Length != 0; Length--) {
((UINT32 *)Buffer)[Length - 1] = Value;
}
return Buffer;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Configure the Calibration Pinout (RTC_CALIB) Selection (1Hz or 512Hz). */
|
void RTC_CalibOutputConfig(uint32_t RTC_CalibOutput)
|
/* Configure the Calibration Pinout (RTC_CALIB) Selection (1Hz or 512Hz). */
void RTC_CalibOutputConfig(uint32_t RTC_CalibOutput)
|
{
assert_param(IS_RTC_CALIB_OUTPUT(RTC_CalibOutput));
RTC->WPR = 0xCA;
RTC->WPR = 0x53;
RTC->CR &= (uint32_t)~(RTC_CR_CALSEL);
RTC->CR |= (uint32_t)RTC_CalibOutput;
RTC->WPR = 0xFF;
}
|
ajhc/demo-cortex-m3
|
C++
| null | 38
|
/* CAN MSP Initialization This function configures the hardware resources used in this example. */
|
void HAL_CAN_MspInit(CAN_HandleTypeDef *hcan)
|
/* CAN MSP Initialization This function configures the hardware resources used in this example. */
void HAL_CAN_MspInit(CAN_HandleTypeDef *hcan)
|
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
if(hcan->Instance==CAN1)
{
__HAL_RCC_CAN1_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF9_CAN1;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
}
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* Get a partial page, lock it and return it. */
|
static struct page* get_partial(struct kmem_cache *s, gfp_t flags, int node)
|
/* Get a partial page, lock it and return it. */
static struct page* get_partial(struct kmem_cache *s, gfp_t flags, int node)
|
{
struct page *page;
int searchnode = (node == -1) ? numa_node_id() : node;
page = get_partial_node(get_node(s, searchnode));
if (page || (flags & __GFP_THISNODE))
return page;
return get_any_partial(s, flags);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Create vme slave window (access: vme -> crcsr) */
|
int tsi148_vme_crcsr_window(unsigned int vmeAddr)
|
/* Create vme slave window (access: vme -> crcsr) */
int tsi148_vme_crcsr_window(unsigned int vmeAddr)
|
{
int result;
unsigned int ctl;
result = 0;
if (NULL == dev) {
result = 1;
} else {
__raw_writel(htonl(vmeAddr), &dev->uregs->crol);
__raw_writel(0x00000000, &dev->uregs->crou);
ctl = 0x00000080;
__raw_writel(htonl(ctl), &dev->uregs->crat);
}
return result;
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* TIM_Base MSP Initialization This function configures the hardware resources used in this example. */
|
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim_base)
|
/* TIM_Base MSP Initialization This function configures the hardware resources used in this example. */
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim_base)
|
{
if(htim_base->Instance==TIM1)
{
__HAL_RCC_TIM1_CLK_ENABLE();
}
else if(htim_base->Instance==TIM2)
{
__HAL_RCC_TIM2_CLK_ENABLE();
}
else if(htim_base->Instance==TIM4)
{
__HAL_RCC_TIM4_CLK_ENABLE();
}
else if(htim_base->Instance==TIM7)
{
__HAL_RCC_TIM7_CLK_ENABLE();
}
else if(htim_base->Instance==TIM15)
{
__HAL_RCC_TIM15_CLK_ENABLE();
}
else if(htim_base->Instance==TIM16)
{
__HAL_RCC_TIM16_CLK_ENABLE();
}
else if(htim_base->Instance==TIM17)
{
__HAL_RCC_TIM17_CLK_ENABLE();
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Clear the compare match flag (CMPMCF) @rmtoll ICR CMPMCF LPTIM_ClearFLAG_CMPM. */
|
void LPTIM_ClearFLAG_CMPM(LPTIM_Module *LPTIMx)
|
/* Clear the compare match flag (CMPMCF) @rmtoll ICR CMPMCF LPTIM_ClearFLAG_CMPM. */
void LPTIM_ClearFLAG_CMPM(LPTIM_Module *LPTIMx)
|
{
SET_BIT(LPTIMx->INTCLR, LPTIM_INTCLR_CMPMCF);
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* Lower values of k allow to connect a faster fan without the risk of counter overflow. The price is lower resolution. You can also set counttime using the module parameter. Note that the module parameter "prescaler" also influences the behaviour. Unfortunately, there's no sysfs attribute defined for that. See the data sheet for details. */
|
static ssize_t get_div(struct device *dev, struct device_attribute *devattr, char *buf)
|
/* Lower values of k allow to connect a faster fan without the risk of counter overflow. The price is lower resolution. You can also set counttime using the module parameter. Note that the module parameter "prescaler" also influences the behaviour. Unfortunately, there's no sysfs attribute defined for that. See the data sheet for details. */
static ssize_t get_div(struct device *dev, struct device_attribute *devattr, char *buf)
|
{
struct max6650_data *data = max6650_update_device(dev);
return sprintf(buf, "%d\n", DIV_FROM_REG(data->count));
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Implementation of handler named in startup code.
Passes 0 to generic PWM IRQ handler. */
|
void PWMA_RELOAD1_IRQHandler(void)
|
/* Implementation of handler named in startup code.
Passes 0 to generic PWM IRQ handler. */
void PWMA_RELOAD1_IRQHandler(void)
|
{
PWM_HAL_ClearReloadFlag(g_pwmBase[0], 1U);
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Default memory allocation implementation. Should return standard 8-bit memory. malloc() essentially resolves to this function. */
|
IRAM_ATTR void* heap_caps_malloc_default(size_t size)
|
/* Default memory allocation implementation. Should return standard 8-bit memory. malloc() essentially resolves to this function. */
IRAM_ATTR void* heap_caps_malloc_default(size_t size)
|
{
if (malloc_alwaysinternal_limit==MALLOC_DISABLE_EXTERNAL_ALLOCS) {
return heap_caps_malloc( size, MALLOC_CAP_DEFAULT | MALLOC_CAP_INTERNAL);
} else {
void *r;
if (size <= malloc_alwaysinternal_limit) {
r=heap_caps_malloc( size, MALLOC_CAP_DEFAULT | MALLOC_CAP_INTERNAL );
} else {
r=heap_caps_malloc( size, MALLOC_CAP_DEFAULT | MALLOC_CAP_SPIRAM );
}
if (r==NULL) {
r=heap_caps_malloc( size, MALLOC_CAP_DEFAULT );
}
return r;
}
}
|
retro-esp32/RetroESP32
|
C++
|
Creative Commons Attribution Share Alike 4.0 International
| 581
|
/* Check, if the device is disfunctional and a place holder, which needs to be handled by the broadcast device. */
|
int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
|
/* Check, if the device is disfunctional and a place holder, which needs to be handled by the broadcast device. */
int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
|
{
unsigned long flags;
int ret = 0;
raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
if (!tick_device_is_functional(dev)) {
dev->event_handler = tick_handle_periodic;
cpumask_set_cpu(cpu, tick_get_broadcast_mask());
tick_broadcast_start_periodic(tick_broadcast_device.evtdev);
ret = 1;
} else {
if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) {
int cpu = smp_processor_id();
cpumask_clear_cpu(cpu, tick_get_broadcast_mask());
tick_broadcast_clear_oneshot(cpu);
}
}
raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
return ret;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* param base LPUART peripheral base address. param handle LPUART handle pointer. param count Send bytes count. retval kStatus_NoTransferInProgress No send in progress. retval kStatus_InvalidArgument Parameter is invalid. retval kStatus_Success Get successfully through the parameter */
|
status_t LPUART_TransferGetSendCount(LPUART_Type *base, lpuart_handle_t *handle, uint32_t *count)
|
/* param base LPUART peripheral base address. param handle LPUART handle pointer. param count Send bytes count. retval kStatus_NoTransferInProgress No send in progress. retval kStatus_InvalidArgument Parameter is invalid. retval kStatus_Success Get successfully through the parameter */
status_t LPUART_TransferGetSendCount(LPUART_Type *base, lpuart_handle_t *handle, uint32_t *count)
|
{
(void)base;
assert(handle);
assert(count);
if (kLPUART_TxIdle == handle->txState)
{
return kStatus_NoTransferInProgress;
}
*count = handle->txDataSizeAll - handle->txDataSize;
return kStatus_Success;
}
|
nanoframework/nf-interpreter
|
C++
|
MIT License
| 293
|
/* Enables or disables the TIM Capture Compare Channel x. */
|
void TIM_CCxCmd(TIM_TypeDef *TIMx, uint16_t TIM_Channel, uint16_t TIM_CCx)
|
/* Enables or disables the TIM Capture Compare Channel x. */
void TIM_CCxCmd(TIM_TypeDef *TIMx, uint16_t TIM_Channel, uint16_t TIM_CCx)
|
{
uint16_t tmp = 0;
assert_param(IS_TIM_LIST4_PERIPH(TIMx));
assert_param(IS_TIM_CCX(TIM_CCx));
tmp = CCER_CCE_SET << TIM_Channel;
TIMx->CCER &= (uint16_t)~ tmp;
TIMx->CCER |= (uint16_t)(TIM_CCx << TIM_Channel);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* cpuidle_unregister_governor - unregisters a governor @gov: the governor */
|
void cpuidle_unregister_governor(struct cpuidle_governor *gov)
|
/* cpuidle_unregister_governor - unregisters a governor @gov: the governor */
void cpuidle_unregister_governor(struct cpuidle_governor *gov)
|
{
if (!gov)
return;
mutex_lock(&cpuidle_lock);
if (gov == cpuidle_curr_governor) {
struct cpuidle_governor *new_gov;
new_gov = cpuidle_replace_governor(gov->rating);
cpuidle_switch_governor(new_gov);
}
list_del(&gov->governor_list);
mutex_unlock(&cpuidle_lock);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Calls the #GHookList @finalize_hook function if it exists, and frees the memory allocated for the #GHook. */
|
void g_hook_free(GHookList *hook_list, GHook *hook)
|
/* Calls the #GHookList @finalize_hook function if it exists, and frees the memory allocated for the #GHook. */
void g_hook_free(GHookList *hook_list, GHook *hook)
|
{
g_return_if_fail (hook_list != NULL);
g_return_if_fail (hook_list->is_setup);
g_return_if_fail (hook != NULL);
g_return_if_fail (G_HOOK_IS_UNLINKED (hook));
g_return_if_fail (!G_HOOK_IN_CALL (hook));
if(hook_list->finalize_hook != NULL)
hook_list->finalize_hook (hook_list, hook);
g_slice_free1 (hook_list->hook_size, hook);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Get USB Device Last Frame Number Parameters: None Return Value: Frame Number */
|
uint32_t USBD_GetFrame(void)
|
/* Get USB Device Last Frame Number Parameters: None Return Value: Frame Number */
uint32_t USBD_GetFrame(void)
|
{
return ((USB0->FRMNUML | (USB0->FRMNUMH << 8) & 0x07FF));
}
|
ARMmbed/DAPLink
|
C++
|
Apache License 2.0
| 2,140
|
/* Retrieves previously saved state on a given stream. */
|
static spdy_stream_info_t* spdy_get_stream_info(spdy_conv_t *conv_data, guint32 stream_id)
|
/* Retrieves previously saved state on a given stream. */
static spdy_stream_info_t* spdy_get_stream_info(spdy_conv_t *conv_data, guint32 stream_id)
|
{
if (conv_data->streams == NULL)
return NULL;
return (spdy_stream_info_t*)wmem_tree_lookup32(conv_data->streams, stream_id);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Although written for the SPARSEMEM_EXTREME case, this happens to also work for the flat array case because NR_SECTION_ROOTS==NR_MEM_SECTIONS. */
|
int __section_nr(struct mem_section *ms)
|
/* Although written for the SPARSEMEM_EXTREME case, this happens to also work for the flat array case because NR_SECTION_ROOTS==NR_MEM_SECTIONS. */
int __section_nr(struct mem_section *ms)
|
{
unsigned long root_nr;
struct mem_section* root;
for (root_nr = 0; root_nr < NR_SECTION_ROOTS; root_nr++) {
root = __nr_to_section(root_nr * SECTIONS_PER_ROOT);
if (!root)
continue;
if ((ms >= root) && (ms < (root + SECTIONS_PER_ROOT)))
break;
}
return (root_nr * SECTIONS_PER_ROOT) + (ms - root);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Callback for function 'g_hash_table_foreach()'. We don't keep references to hash table keys. Keys have memory allocated which must be freed when they are not used anymore. This function finds the reference to a key corresponding to a particular class id. The reference to the key is stored in a global variable. */
|
void _cnd_find_hash_key_for_class_id(gpointer key, gpointer value _U_, gpointer user_data)
|
/* Callback for function 'g_hash_table_foreach()'. We don't keep references to hash table keys. Keys have memory allocated which must be freed when they are not used anymore. This function finds the reference to a key corresponding to a particular class id. The reference to the key is stored in a global variable. */
void _cnd_find_hash_key_for_class_id(gpointer key, gpointer value _U_, gpointer user_data)
|
{
char *class_id = (char *)user_data;
char *key_value = (char *)key;
if (strcmp(class_id, key_value) == 0)
pkey = key_value;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Return the udp file handle for select() usage to wait for several RTP streams at the same time. */
|
int udp_get_file_handle(URLContext *h)
|
/* Return the udp file handle for select() usage to wait for several RTP streams at the same time. */
int udp_get_file_handle(URLContext *h)
|
{
UDPContext *s = h->priv_data;
return s->udp_fd;
}
|
DC-SWAT/DreamShell
|
C++
| null | 404
|
/* Select the signal that need to route on int pad.. */
|
int32_t lps22hh_pin_int_route_get(stmdev_ctx_t *ctx, lps22hh_ctrl_reg3_t *val)
|
/* Select the signal that need to route on int pad.. */
int32_t lps22hh_pin_int_route_get(stmdev_ctx_t *ctx, lps22hh_ctrl_reg3_t *val)
|
{
int32_t ret;
ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG3, (uint8_t *) val, 1);
return ret;
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Clear a pending interrupt bit in the NVIC without servicing it. */
|
void am_hal_interrupt_pend_clear(uint32_t ui32Interrupt)
|
/* Clear a pending interrupt bit in the NVIC without servicing it. */
void am_hal_interrupt_pend_clear(uint32_t ui32Interrupt)
|
{
if ( ui32Interrupt > AM_HAL_INTERRUPT_MAX )
{
return;
}
if ( ui32Interrupt > 15 )
{
AM_REG(NVIC, ICPR0) = 0x1 << ((ui32Interrupt - 16) & 0x1F);
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* clk_enable - inform the system when the clock source should be running. */
|
int clk_enable(struct clk *clk)
|
/* clk_enable - inform the system when the clock source should be running. */
int clk_enable(struct clk *clk)
|
{
unsigned long flags;
spin_lock_irqsave(&clocks_lock, flags);
if (clk->enabled++ == 0)
local_clk_enable(clk);
spin_unlock_irqrestore(&clocks_lock, flags);
return 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Functions for the dlm to get the info that's been configured */
|
static struct dlm_space* get_space(char *name)
|
/* Functions for the dlm to get the info that's been configured */
static struct dlm_space* get_space(char *name)
|
{
struct config_item *i;
if (!space_list)
return NULL;
mutex_lock(&space_list->cg_subsys->su_mutex);
i = config_group_find_item(space_list, name);
mutex_unlock(&space_list->cg_subsys->su_mutex);
return config_item_to_space(i);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Note: This function must be called with slot->lock held */
|
static void handle_surprise_event(struct slot *p_slot)
|
/* Note: This function must be called with slot->lock held */
static void handle_surprise_event(struct slot *p_slot)
|
{
u8 getstatus;
struct power_work_info *info;
info = kmalloc(sizeof(*info), GFP_KERNEL);
if (!info) {
ctrl_err(p_slot->ctrl, "%s: Cannot allocate memory\n",
__func__);
return;
}
info->p_slot = p_slot;
INIT_WORK(&info->work, pciehp_power_thread);
pciehp_get_adapter_status(p_slot, &getstatus);
if (!getstatus)
p_slot->state = POWEROFF_STATE;
else
p_slot->state = POWERON_STATE;
queue_work(pciehp_wq, &info->work);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function is executed in case of error occurrence. */
|
static void Error_Handler(void)
|
/* This function is executed in case of error occurrence. */
static void Error_Handler(void)
|
{
BSP_LED_On(LED2);
while (1)
{
}
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* Submit a USB set interface request for the USB device specified by UsbIo, and Interface, and set the alternate setting to the value specified by AlternateSetting. The status of the transfer is returned in Status. If UsbIo is NULL, then ASSERT(). If Status is NULL, then ASSERT(). */
|
EFI_STATUS EFIAPI UsbSetInterface(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT16 Interface, IN UINT16 AlternateSetting, OUT UINT32 *Status)
|
/* Submit a USB set interface request for the USB device specified by UsbIo, and Interface, and set the alternate setting to the value specified by AlternateSetting. The status of the transfer is returned in Status. If UsbIo is NULL, then ASSERT(). If Status is NULL, then ASSERT(). */
EFI_STATUS EFIAPI UsbSetInterface(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT16 Interface, IN UINT16 AlternateSetting, OUT UINT32 *Status)
|
{
EFI_USB_DEVICE_REQUEST DevReq;
ASSERT (UsbIo != NULL);
ASSERT (Status != NULL);
ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
DevReq.RequestType = USB_DEV_SET_INTERFACE_REQ_TYPE;
DevReq.Request = USB_REQ_SET_INTERFACE;
DevReq.Value = AlternateSetting;
DevReq.Index = Interface;
return UsbIo->UsbControlTransfer (
UsbIo,
&DevReq,
EfiUsbNoData,
PcdGet32 (PcdUsbTransferTimeoutValue),
NULL,
0,
Status
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Checks availability of HW AES key.
This function checks if the AES key is present at dedicated hardware bus and can be used at actual security level. */
|
static status_t hashcrypt_check_need_key(HASHCRYPT_Type *base, hashcrypt_handle_t *handle)
|
/* Checks availability of HW AES key.
This function checks if the AES key is present at dedicated hardware bus and can be used at actual security level. */
static status_t hashcrypt_check_need_key(HASHCRYPT_Type *base, hashcrypt_handle_t *handle)
|
{
if (handle->keyType == kHASHCRYPT_SecretKey)
{
volatile uint32_t wait = 50u;
while ((wait > 0U) && (base->STATUS == 0U))
{
wait--;
}
if (0U == (base->STATUS & HASHCRYPT_STATUS_NEEDKEY_MASK))
{
return kStatus_Success;
}
return kStatus_Fail;
}
else
{
return kStatus_Success;
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Get the DMA Current Byte Count of a channel. */
|
unsigned long DMARemainTransferCountGet(unsigned long ulChannelID)
|
/* Get the DMA Current Byte Count of a channel. */
unsigned long DMARemainTransferCountGet(unsigned long ulChannelID)
|
{
xASSERT(xDMAChannelIDValid(ulChannelID));
return xHWREG(g_psDMAChannelAddress[ulChannelID] + DMA_CTRL) >> DMA_CTRL_TFR_CNT_S;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Returns the USB Host Speed from the Low Level Driver. */
|
USBH_SpeedTypeDef USBH_LL_GetSpeed(USBH_HandleTypeDef *phost)
|
/* Returns the USB Host Speed from the Low Level Driver. */
USBH_SpeedTypeDef USBH_LL_GetSpeed(USBH_HandleTypeDef *phost)
|
{
USBH_SpeedTypeDef speed = USBH_SPEED_FULL;
switch (HAL_HCD_GetCurrentSpeed(phost->pData))
{
case 0:
speed = USBH_SPEED_HIGH;
break;
case 1:
speed = USBH_SPEED_FULL;
break;
case 2:
speed = USBH_SPEED_LOW;
break;
default:
speed = USBH_SPEED_FULL;
break;
}
return speed;
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* This function is used to get cpu clock. */
|
void SystemClock_Get(wm_sys_clk *sysclk)
|
/* This function is used to get cpu clock. */
void SystemClock_Get(wm_sys_clk *sysclk)
|
{
clk_div_reg clk_div;
clk_div.w = READ_REG(RCC->CLK_DIV);
sysclk->cpuclk = W805_PLL_CLK_MHZ/(clk_div.b.CPU);
sysclk->wlanclk = W805_PLL_CLK_MHZ/(clk_div.b.WLAN);
sysclk->apbclk = sysclk->cpuclk / clk_div.b.BUS2;
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* Sets led current limit.
Sets the current limit for the LED driver. This is a separate value from per-led brightness, and applies to all LEDs. This value sets the output current limit according to the following formula: (840/R_ISET) * (limit/256) See table 14 of the datasheet for additional details. */
|
int is31fl3733_current_limit(const struct device *dev, uint8_t limit)
|
/* Sets led current limit.
Sets the current limit for the LED driver. This is a separate value from per-led brightness, and applies to all LEDs. This value sets the output current limit according to the following formula: (840/R_ISET) * (limit/256) See table 14 of the datasheet for additional details. */
int is31fl3733_current_limit(const struct device *dev, uint8_t limit)
|
{
const struct is31fl3733_config *config = dev->config;
int ret;
ret = is31fl3733_select_page(dev, CMD_SEL_FUNC);
if (ret < 0) {
return ret;
}
return i2c_reg_write_byte_dt(&config->bus, GLOBAL_CURRENT_CTRL_REG, limit);
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Do per-CPU grace-period initialization for running CPU. The caller must hold the lock of the leaf rcu_node structure corresponding to this CPU. */
|
static void rcu_start_gp_per_cpu(struct rcu_state *rsp, struct rcu_node *rnp, struct rcu_data *rdp)
|
/* Do per-CPU grace-period initialization for running CPU. The caller must hold the lock of the leaf rcu_node structure corresponding to this CPU. */
static void rcu_start_gp_per_cpu(struct rcu_state *rsp, struct rcu_node *rnp, struct rcu_data *rdp)
|
{
__rcu_process_gp_end(rsp, rnp, rdp);
rdp->nxttail[RCU_NEXT_READY_TAIL] = rdp->nxttail[RCU_NEXT_TAIL];
rdp->nxttail[RCU_WAIT_TAIL] = rdp->nxttail[RCU_NEXT_TAIL];
__note_new_gpnum(rsp, rnp, rdp);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Command send function for invalidating a device table entry */
|
static int iommu_flush_device(struct device *dev)
|
/* Command send function for invalidating a device table entry */
static int iommu_flush_device(struct device *dev)
|
{
struct amd_iommu *iommu;
struct iommu_cmd cmd;
u16 devid;
devid = get_device_id(dev);
iommu = amd_iommu_rlookup_table[devid];
memset(&cmd, 0, sizeof(cmd));
CMD_SET_TYPE(&cmd, CMD_INV_DEV_ENTRY);
cmd.data[0] = devid;
return iommu_queue_command(iommu, &cmd);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Check if an area is fully on an other */
|
bool lv_area_is_in(const lv_area_t *ain_p, const lv_area_t *aholder_p)
|
/* Check if an area is fully on an other */
bool lv_area_is_in(const lv_area_t *ain_p, const lv_area_t *aholder_p)
|
{
bool is_in = false;
if(ain_p->x1 >= aholder_p->x1 && ain_p->y1 >= aholder_p->y1 && ain_p->x2 <= aholder_p->x2 &&
ain_p->y2 <= aholder_p->y2) {
is_in = true;
}
return is_in;
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* This function will silently fail if the fifo is empty. */
|
static u32 fifo_icap_fifo_read(struct hwicap_drvdata *drvdata)
|
/* This function will silently fail if the fifo is empty. */
static u32 fifo_icap_fifo_read(struct hwicap_drvdata *drvdata)
|
{
u32 data = in_be32(drvdata->base_address + XHI_RF_OFFSET);
dev_dbg(drvdata->dev, "fifo_read: %x\n", data);
return data;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Low pass filter 2 on 6D function selection.. */
|
int32_t lsm6dso_xl_lp2_on_6d_get(stmdev_ctx_t *ctx, uint8_t *val)
|
/* Low pass filter 2 on 6D function selection.. */
int32_t lsm6dso_xl_lp2_on_6d_get(stmdev_ctx_t *ctx, uint8_t *val)
|
{
lsm6dso_ctrl8_xl_t reg;
int32_t ret;
ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL8_XL, (uint8_t *)®, 1);
*val = reg.low_pass_on_6d;
return ret;
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Map a virtual address to a physical address and optionally invalidate any old mapping. */
|
static void x86_phys_map_page(uintptr_t virt, phys_addr_t phys, int invlpg)
|
/* Map a virtual address to a physical address and optionally invalidate any old mapping. */
static void x86_phys_map_page(uintptr_t virt, phys_addr_t phys, int invlpg)
|
{
uintptr_t pdpt_idx = (virt >> 30) & 0x3;
uintptr_t pdt_idx = (virt >> 21) & 0x1ff;
struct pde *pde = &(pdts[pdpt_idx][pdt_idx]);
memset(pde, 0, sizeof(struct pde));
pde->p = 1;
pde->rw = 1;
pde->us = 1;
pde->ps = 1;
pde->base = phys >> 21;
if (invlpg) {
__asm__ __volatile__(
"invlpg %0\n\t"
:
: "m" (*(uint8_t *)virt)
);
}
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Returns: TRUE if the @volume can be mounted. FALSE otherwise */
|
gboolean g_volume_can_mount(GVolume *volume)
|
/* Returns: TRUE if the @volume can be mounted. FALSE otherwise */
gboolean g_volume_can_mount(GVolume *volume)
|
{
GVolumeIface *iface;
g_return_val_if_fail (G_IS_VOLUME (volume), FALSE);
iface = G_VOLUME_GET_IFACE (volume);
if (iface->can_mount == NULL)
return FALSE;
return (* iface->can_mount) (volume);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Enables or disables the specified KeyScan interrupts mask. */
|
void KeyScan_INTConfig(KEYSCAN_TypeDef *KeyScan, uint32_t KeyScan_IT, u8 newState)
|
/* Enables or disables the specified KeyScan interrupts mask. */
void KeyScan_INTConfig(KEYSCAN_TypeDef *KeyScan, uint32_t KeyScan_IT, u8 newState)
|
{
assert_param(IS_KEYSCAN_ALL_PERIPH(KeyScan));
if (newState == ENABLE) {
KeyScan->KS_IMR |= KeyScan_IT;
} else {
KeyScan->KS_IMR &= (~KeyScan_IT);
}
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* Configures internally by software the NSS pin for the selected SPI. */
|
void SPI_NSSInternalSoftwareConfig(SPI_TypeDef *SPIx, uint16_t SPI_NSSInternalSoft)
|
/* Configures internally by software the NSS pin for the selected SPI. */
void SPI_NSSInternalSoftwareConfig(SPI_TypeDef *SPIx, uint16_t SPI_NSSInternalSoft)
|
{
assert_param(IS_SPI_ALL_PERIPH(SPIx));
assert_param(IS_SPI_NSS_INTERNAL(SPI_NSSInternalSoft));
if (SPI_NSSInternalSoft != SPI_NSSInternalSoft_Reset)
{
SPIx->CR1 |= SPI_NSSInternalSoft_Set;
}
else
{
SPIx->CR1 &= SPI_NSSInternalSoft_Reset;
}
}
|
gcallipo/RadioDSP-Stm32f103
|
C++
|
Common Creative - Attribution 3.0
| 51
|
/* HID class driver callback function for the creation of HID reports to the host. */
|
bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t *const HIDInterfaceInfo, uint8_t *const ReportID, const uint8_t ReportType, void *ReportData, uint16_t *const ReportSize)
|
/* HID class driver callback function for the creation of HID reports to the host. */
bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t *const HIDInterfaceInfo, uint8_t *const ReportID, const uint8_t ReportType, void *ReportData, uint16_t *const ReportSize)
|
{
uint8_t* Data = (uint8_t*)ReportData;
uint8_t CurrLEDMask = LEDs_GetLEDs();
Data[0] = ((CurrLEDMask & LEDS_LED1) ? 1 : 0);
Data[1] = ((CurrLEDMask & LEDS_LED2) ? 1 : 0);
Data[2] = ((CurrLEDMask & LEDS_LED3) ? 1 : 0);
Data[3] = ((CurrLEDMask & LEDS_LED4) ? 1 : 0);
*ReportSize = GENERIC_REPORT_SIZE;
return false;
}
|
prusa3d/Prusa-Firmware-Buddy
|
C++
|
Other
| 1,019
|
/* The per-cpu batchsize and zone watermarks are determined by present_pages. In the DMA zone, a significant percentage may be consumed by kernel image and other unfreeable allocations which can skew the watermarks badly. This function may optionally be used to account for unfreeable pages in the first zone (e.g., ZONE_DMA). The effect will be lower watermarks and smaller per-cpu batchsize. */
|
void __init set_dma_reserve(unsigned long new_dma_reserve)
|
/* The per-cpu batchsize and zone watermarks are determined by present_pages. In the DMA zone, a significant percentage may be consumed by kernel image and other unfreeable allocations which can skew the watermarks badly. This function may optionally be used to account for unfreeable pages in the first zone (e.g., ZONE_DMA). The effect will be lower watermarks and smaller per-cpu batchsize. */
void __init set_dma_reserve(unsigned long new_dma_reserve)
|
{
dma_reserve = new_dma_reserve;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Note bis : Don't try to access HERMES_CMD during the reset phase. It just won't work ! */
|
static int orinoco_nortel_cor_reset(struct orinoco_private *priv)
|
/* Note bis : Don't try to access HERMES_CMD during the reset phase. It just won't work ! */
static int orinoco_nortel_cor_reset(struct orinoco_private *priv)
|
{
struct orinoco_pci_card *card = priv->card;
iowrite16(8, card->bridge_io + 2);
ioread16(card->attr_io + COR_OFFSET);
iowrite16(0x80, card->attr_io + COR_OFFSET);
mdelay(1);
iowrite16(0, card->attr_io + COR_OFFSET);
iowrite16(0, card->attr_io + COR_OFFSET);
mdelay(1);
iowrite16(COR_VALUE, card->attr_io + COR_OFFSET);
iowrite16(COR_VALUE, card->attr_io + COR_OFFSET);
mdelay(1);
iowrite16(0x228, card->bridge_io + 2);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Returns: the number of bytes which would be produced if the buffer was large enough. */
|
gint g_snprintf(gchar *string, gulong n, gchar const *format,...)
|
/* Returns: the number of bytes which would be produced if the buffer was large enough. */
gint g_snprintf(gchar *string, gulong n, gchar const *format,...)
|
{
va_list args;
gint retval;
va_start (args, format);
retval = g_vsnprintf (string, n, format, args);
va_end (args);
return retval;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Get the drag parent attribute of an object */
|
bool lv_obj_get_parent_event(const lv_obj_t *obj)
|
/* Get the drag parent attribute of an object */
bool lv_obj_get_parent_event(const lv_obj_t *obj)
|
{
return obj->parent_event == 0 ? false : true;
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* . This is called by the kernel in response to 'ifconfig ethX down'. It . is responsible for cleaning up everything that the open routine . does, and maybe putting the card into a powerdown state. */
|
static int smc_close(struct net_device *dev)
|
/* . This is called by the kernel in response to 'ifconfig ethX down'. It . is responsible for cleaning up everything that the open routine . does, and maybe putting the card into a powerdown state. */
static int smc_close(struct net_device *dev)
|
{
netif_stop_queue(dev);
smc_shutdown( dev->base_addr );
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Enable IDE DMA for a device on this IDE controller. */
|
void ide_dma_on(ide_drive_t *drive)
|
/* Enable IDE DMA for a device on this IDE controller. */
void ide_dma_on(ide_drive_t *drive)
|
{
drive->dev_flags |= IDE_DFLAG_USING_DMA;
ide_toggle_bounce(drive, 1);
drive->hwif->dma_ops->dma_host_set(drive, 1);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* 1 == DS3 payload scrambled, 0 == not scrambled */
|
static void lmc_ds3_set_scram(lmc_softc_t *const, int)
|
/* 1 == DS3 payload scrambled, 0 == not scrambled */
static void lmc_ds3_set_scram(lmc_softc_t *const, int)
|
{
if (ie == LMC_CTL_ON)
{
sc->lmc_miireg16 |= LMC_MII16_DS3_SCRAM;
sc->ictl.scrambler_onoff = LMC_CTL_ON;
}
else
{
sc->lmc_miireg16 &= ~LMC_MII16_DS3_SCRAM;
sc->ictl.scrambler_onoff = LMC_CTL_OFF;
}
lmc_mii_writereg (sc, 0, 16, sc->lmc_miireg16);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Gets the selected ADC Software start injected conversion Status. */
|
FlagStatus ADC_GetStartInjectedConversionStatus(ADC_TypeDef *ADCx)
|
/* Gets the selected ADC Software start injected conversion Status. */
FlagStatus ADC_GetStartInjectedConversionStatus(ADC_TypeDef *ADCx)
|
{
FlagStatus bitstatus = RESET;
assert_param(IS_ADC_ALL_PERIPH(ADCx));
if ((ADCx->CR & ADC_CR_JADSTART) != (uint32_t)RESET)
{
bitstatus = SET;
}
else
{
bitstatus = RESET;
}
return bitstatus;
}
|
ajhc/demo-cortex-m3
|
C++
| null | 38
|
/* NVIC recover after wake up from stop mode. */
|
void PWC_STOP_NvicRecover(void)
|
/* NVIC recover after wake up from stop mode. */
void PWC_STOP_NvicRecover(void)
|
{
uint8_t u8Count;
for (u8Count = 0U; u8Count < sizeof(NVIC_ISER_BAK) / sizeof(uint32_t); u8Count++) {
NVIC->ISER[u8Count] = NVIC_ISER_BAK[u8Count];
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* param base USART peripheral base address. param handle USART handle pointer. param ringBuffer Start address of the ring buffer for background receiving. Pass NULL to disable the ring buffer. param ringBufferSize size of the ring buffer. */
|
void USART_TransferStartRingBuffer(USART_Type *base, usart_handle_t *handle, uint8_t *ringBuffer, size_t ringBufferSize)
|
/* param base USART peripheral base address. param handle USART handle pointer. param ringBuffer Start address of the ring buffer for background receiving. Pass NULL to disable the ring buffer. param ringBufferSize size of the ring buffer. */
void USART_TransferStartRingBuffer(USART_Type *base, usart_handle_t *handle, uint8_t *ringBuffer, size_t ringBufferSize)
|
{
assert(NULL != base);
assert(NULL != handle);
assert(NULL != ringBuffer);
handle->rxRingBuffer = ringBuffer;
handle->rxRingBufferSize = ringBufferSize;
handle->rxRingBufferHead = 0U;
handle->rxRingBufferTail = 0U;
base->FIFOINTENSET = USART_FIFOINTENSET_RXLVL_MASK | USART_FIFOINTENSET_RXERR_MASK;
}
|
ARMmbed/DAPLink
|
C++
|
Apache License 2.0
| 2,140
|
/* set the private field for a given byte offset in the tree. If there isn't an extent_state there already, this does nothing. */
|
int set_state_private(struct extent_io_tree *tree, u64 start, u64 private)
|
/* set the private field for a given byte offset in the tree. If there isn't an extent_state there already, this does nothing. */
int set_state_private(struct extent_io_tree *tree, u64 start, u64 private)
|
{
struct rb_node *node;
struct extent_state *state;
int ret = 0;
spin_lock(&tree->lock);
node = tree_search(tree, start);
if (!node) {
ret = -ENOENT;
goto out;
}
state = rb_entry(node, struct extent_state, rb_node);
if (state->start != start) {
ret = -ENOENT;
goto out;
}
state->private = private;
out:
spin_unlock(&tree->lock);
return ret;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Appending pad buffer to a request modifies the last entry of a scatter list such that it includes the pad buffer. */
|
void blk_queue_update_dma_pad(struct request_queue *q, unsigned int mask)
|
/* Appending pad buffer to a request modifies the last entry of a scatter list such that it includes the pad buffer. */
void blk_queue_update_dma_pad(struct request_queue *q, unsigned int mask)
|
{
if (mask > q->dma_pad_mask)
q->dma_pad_mask = mask;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* M e s s a g e H a n d l i n g */
|
void MessageHandlingCPY(MessageHandling *FROM, MessageHandling *TO)
|
/* M e s s a g e H a n d l i n g */
void MessageHandlingCPY(MessageHandling *FROM, MessageHandling *TO)
|
{
TO->errorVisibility = FROM->errorVisibility;
TO->warningVisibility = FROM->warningVisibility;
TO->infoVisibility = FROM->infoVisibility;
TO->outputFile = FROM->outputFile;
TO->errorCount = FROM->errorCount;
}
|
DanielMartensson/EmbeddedLapack
|
C++
|
MIT License
| 129
|
/* Disable a riscv PLIC-specific interrupt line.
This routine disables a RISCV PLIC-specific interrupt line. riscv_plic_irq_disable is called by RISCV_PRIVILEGED arch_irq_disable function to disable external interrupts, for IRQS level == 2, whenever CONFIG_RISCV_HAS_PLIC variable is set. */
|
void riscv_plic_irq_disable(uint32_t irq)
|
/* Disable a riscv PLIC-specific interrupt line.
This routine disables a RISCV PLIC-specific interrupt line. riscv_plic_irq_disable is called by RISCV_PRIVILEGED arch_irq_disable function to disable external interrupts, for IRQS level == 2, whenever CONFIG_RISCV_HAS_PLIC variable is set. */
void riscv_plic_irq_disable(uint32_t irq)
|
{
plic_irq_enable_set_state(irq, false);
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Acquires semaphore, if necessary, then writes the data to PHY register at the offset. Release any acquired semaphores before exiting. */
|
static s32 __e1000e_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data, bool locked)
|
/* Acquires semaphore, if necessary, then writes the data to PHY register at the offset. Release any acquired semaphores before exiting. */
static s32 __e1000e_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data, bool locked)
|
{
s32 ret_val = 0;
if (!locked) {
if (!(hw->phy.ops.acquire))
goto out;
ret_val = hw->phy.ops.acquire(hw);
if (ret_val)
goto out;
}
if (offset > MAX_PHY_MULTI_PAGE_REG) {
ret_val = e1000e_write_phy_reg_mdic(hw,
IGP01E1000_PHY_PAGE_SELECT,
(u16)offset);
if (ret_val)
goto release;
}
ret_val = e1000e_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset,
data);
release:
if (!locked)
hw->phy.ops.release(hw);
out:
return ret_val;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* When this function is called, the engine is triggered to start using this context for GCM and CCM. */
|
void AESAuthDataLengthSet(uint32_t ui32Base, uint32_t ui32Length)
|
/* When this function is called, the engine is triggered to start using this context for GCM and CCM. */
void AESAuthDataLengthSet(uint32_t ui32Base, uint32_t ui32Length)
|
{
ASSERT(ui32Base == AES_BASE);
HWREG(ui32Base + AES_O_AUTH_LENGTH) = ui32Length;
}
|
micropython/micropython
|
C++
|
Other
| 18,334
|
/* Attempt to get semaphore, return immediately, no error info because users expect some failures when using this API. */
|
PUBLIC IX_STATUS ixOsalSemaphoreTryWait(IxOsalSemaphore *sid)
|
/* Attempt to get semaphore, return immediately, no error info because users expect some failures when using this API. */
PUBLIC IX_STATUS ixOsalSemaphoreTryWait(IxOsalSemaphore *sid)
|
{
diag_printf("%s called\n", __FUNCTION__);
return IX_FAIL;
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* Initialize the SHA engine for new hash.
This function sets kDCP_CONTROL0_HASH_INIT for control0 in work packet to start a new hash. */
|
static status_t dcp_hash_engine_init(DCP_Type *base, dcp_hash_ctx_internal_t *ctxInternal)
|
/* Initialize the SHA engine for new hash.
This function sets kDCP_CONTROL0_HASH_INIT for control0 in work packet to start a new hash. */
static status_t dcp_hash_engine_init(DCP_Type *base, dcp_hash_ctx_internal_t *ctxInternal)
|
{
status_t status;
status = kStatus_InvalidArgument;
if ((kDCP_Sha256 == ctxInternal->algo) || (kDCP_Sha1 == ctxInternal->algo) || (kDCP_Crc32 == ctxInternal->algo))
{
ctxInternal->ctrl0 = (uint32_t)kDCP_CONTROL0_HASH_INIT;
status = kStatus_Success;
}
return status;
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* For the DS5100 the writeback buffer seems to be a part of Coprocessor 3. But CP3 has to enabled first. */
|
static void wbflush_kn210(void)
|
/* For the DS5100 the writeback buffer seems to be a part of Coprocessor 3. But CP3 has to enabled first. */
static void wbflush_kn210(void)
|
{
asm(".set\tpush\n\t"
".set\tnoreorder\n\t"
"mfc0\t$2,$12\n\t"
"lui\t$3,0x8000\n\t"
"or\t$3,$2,$3\n\t"
"mtc0\t$3,$12\n\t"
"nop\n"
"1:\tbc3f\t1b\n\t"
"nop\n\t"
"mtc0\t$2,$12\n\t"
"nop\n\t"
".set\tpop"
: : : "$2", "$3");
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Return the powerdomain pwrdm's next power state. Returns -EINVAL if the powerdomain pointer is null or returns the next power state upon success. */
|
int pwrdm_read_next_pwrst(struct powerdomain *pwrdm)
|
/* Return the powerdomain pwrdm's next power state. Returns -EINVAL if the powerdomain pointer is null or returns the next power state upon success. */
int pwrdm_read_next_pwrst(struct powerdomain *pwrdm)
|
{
if (!pwrdm)
return -EINVAL;
return prm_read_mod_bits_shift(pwrdm->prcm_offs, PM_PWSTCTRL,
OMAP_POWERSTATE_MASK);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Return non-zero if device is operating in multipath mode, zero otherwise. */
|
int ccw_device_is_multipath(struct ccw_device *cdev)
|
/* Return non-zero if device is operating in multipath mode, zero otherwise. */
int ccw_device_is_multipath(struct ccw_device *cdev)
|
{
return cdev->private->flags.mpath;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Setup the systick timer to generate the tick interrupts at the required frequency. */
|
void prvSetupTimerInterrupt(void)
|
/* Setup the systick timer to generate the tick interrupts at the required frequency. */
void prvSetupTimerInterrupt(void)
|
{
*(portNVIC_SYSTICK_LOAD) = ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;
*(portNVIC_SYSTICK_CTRL) = portNVIC_SYSTICK_CLK | portNVIC_SYSTICK_INT | portNVIC_SYSTICK_ENABLE;
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* preemptively destroy all the transport session records rather than waiting for them to time out */
|
void __exit rxrpc_destroy_all_transports(void)
|
/* preemptively destroy all the transport session records rather than waiting for them to time out */
void __exit rxrpc_destroy_all_transports(void)
|
{
_enter("");
rxrpc_transport_timeout = 0;
cancel_delayed_work(&rxrpc_transport_reap);
rxrpc_queue_delayed_work(&rxrpc_transport_reap, 0);
_leave("");
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Checks whether the specified RCC flag is set or not. */
|
FlagStatus RCC_GetFlagStatus(uint8_t RCC_FLAG)
|
/* Checks whether the specified RCC flag is set or not. */
FlagStatus RCC_GetFlagStatus(uint8_t RCC_FLAG)
|
{
uint32_t tmp = 0;
uint32_t statusreg = 0;
FlagStatus bitstatus = RESET;
assert_param(IS_RCC_FLAG(RCC_FLAG));
tmp = RCC_FLAG >> 5;
if (tmp == 1)
{
statusreg = RCC->CTRL;
}
else if (tmp == 2)
{
statusreg = RCC->LDCTRL;
}
else
{
statusreg = RCC->CTRLSTS;
}
tmp = RCC_FLAG & FLAG_MASK;
if ((statusreg & ((uint32_t)1 << tmp)) != (uint32_t)RESET)
{
bitstatus = SET;
}
else
{
bitstatus = RESET;
}
return bitstatus;
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* Check the receive packet FIFO for errors. FIFO error interrupts are: */
|
void XEmac_CheckFifoRecvError(XEmac *InstancePtr)
|
/* Check the receive packet FIFO for errors. FIFO error interrupts are: */
void XEmac_CheckFifoRecvError(XEmac *InstancePtr)
|
{
if (XPF_V100B_IS_DEADLOCKED(&InstancePtr->RecvFifo)) {
u32 IntrEnable;
InstancePtr->Stats.FifoErrors++;
IntrEnable = XIIF_V123B_READ_DIER(InstancePtr->BaseAddress);
XIIF_V123B_WRITE_DIER(InstancePtr->BaseAddress,
IntrEnable & ~XEM_IPIF_RECV_FIFO_MASK);
InstancePtr->ErrorHandler(InstancePtr->ErrorRef,
XST_FIFO_ERROR);
}
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* Initializes the HRTIMx timer in basic PWM mode. */
|
void HRTIM_SimplePWM_Init(HRTIM_TypeDef *HRTIMx, uint32_t TimerIdx, HRTIM_BaseInitTypeDef *HRTIM_BaseInitStruct)
|
/* Initializes the HRTIMx timer in basic PWM mode. */
void HRTIM_SimplePWM_Init(HRTIM_TypeDef *HRTIMx, uint32_t TimerIdx, HRTIM_BaseInitTypeDef *HRTIM_BaseInitStruct)
|
{
assert_param(IS_HRTIM_TIMERINDEX(TimerIdx));
assert_param(IS_HRTIM_MODE(HRTIM_BaseInitStruct->Mode));
HRTIM_TimingUnitBase_Config(HRTIMx, TimerIdx, HRTIM_BaseInitStruct);
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Configures the LPSPI peripheral chip select polarity.
This function takes in the desired peripheral chip select (Pcs) and it's corresponding desired polarity and configures the Pcs signal to operate with the desired characteristic. */
|
static void LPSPI_SetOnePcsPolarity(LPSPI_Type *base, lpspi_which_pcs_t pcs, lpspi_pcs_polarity_config_t activeLowOrHigh)
|
/* Configures the LPSPI peripheral chip select polarity.
This function takes in the desired peripheral chip select (Pcs) and it's corresponding desired polarity and configures the Pcs signal to operate with the desired characteristic. */
static void LPSPI_SetOnePcsPolarity(LPSPI_Type *base, lpspi_which_pcs_t pcs, lpspi_pcs_polarity_config_t activeLowOrHigh)
|
{
uint32_t cfgr1Value = 0;
cfgr1Value = base->CFGR1 & ~(1UL << (LPSPI_CFGR1_PCSPOL_SHIFT + (uint32_t)pcs));
base->CFGR1 = cfgr1Value | ((uint32_t)activeLowOrHigh << (LPSPI_CFGR1_PCSPOL_SHIFT + (uint32_t)pcs));
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* If 16-bit MMIO register operations are not supported, then ASSERT(). If StartBit is greater than 15, then ASSERT(). If EndBit is greater than 15, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
|
UINT16 EFIAPI S3MmioBitFieldOr16(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 OrData)
|
/* If 16-bit MMIO register operations are not supported, then ASSERT(). If StartBit is greater than 15, then ASSERT(). If EndBit is greater than 15, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT16 EFIAPI S3MmioBitFieldOr16(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 OrData)
|
{
return InternalSaveMmioWrite16ValueToBootScript (Address, MmioBitFieldOr16 (Address, StartBit, EndBit, OrData));
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Same as get_index_page(), but get's a new page without reading */
|
static struct metapage* get_index_page(struct inode *inode, s64 blkno)
|
/* Same as get_index_page(), but get's a new page without reading */
static struct metapage* get_index_page(struct inode *inode, s64 blkno)
|
{
int rc;
s64 xaddr;
int xflag;
s32 xlen;
rc = xtLookup(inode, blkno, 1, &xflag, &xaddr, &xlen, 1);
if (rc || (xaddr == 0))
return NULL;
return get_metapage(inode, xaddr, PSIZE, 1);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* set the mute status of the given audio */
|
static int vx_set_audio_switch(struct vx_core *chip, int audio, int active)
|
/* set the mute status of the given audio */
static int vx_set_audio_switch(struct vx_core *chip, int audio, int active)
|
{
struct vx_audio_level info;
memset(&info, 0, sizeof(info));
info.has_mute = 1;
info.mute = !active;
chip->audio_active[audio] = active;
return vx_adjust_audio_level(chip, audio, 0, &info);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Command response callback function for sd_ble_gap_device_name_set BLE command.
Callback for decoding the command response return code. */
|
static uint32_t gap_device_name_set_rsp_dec(const uint8_t *p_buffer, uint16_t length)
|
/* Command response callback function for sd_ble_gap_device_name_set BLE command.
Callback for decoding the command response return code. */
static uint32_t gap_device_name_set_rsp_dec(const uint8_t *p_buffer, uint16_t length)
|
{
uint32_t result_code;
const uint32_t err_code = ble_gap_device_name_set_rsp_dec(p_buffer, length, &result_code);
APP_ERROR_CHECK(err_code);
return result_code;
}
|
labapart/polymcu
|
C++
| null | 201
|
/* check a superblock to see if it's the one we're looking for */
|
static int afs_test_super(struct super_block *sb, void *data)
|
/* check a superblock to see if it's the one we're looking for */
static int afs_test_super(struct super_block *sb, void *data)
|
{
struct afs_mount_params *params = data;
struct afs_super_info *as = sb->s_fs_info;
return as->volume == params->volume;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* The PWMB default IRQ, declared in StartUp code. */
|
void PWM1CH4_IRQHandler(void)
|
/* The PWMB default IRQ, declared in StartUp code. */
void PWM1CH4_IRQHandler(void)
|
{
unsigned long ulPWMStastus;
unsigned long ulBase = PWMB_BASE;
ulPWMStastus = xHWREG(ulBase + PWM_INTSTS) & 0x10101010;
xHWREG(ulBase + PWM_INTSTS) = ulPWMStastus;
if (g_pfnPWMHandlerCallbacks[0] != 0)
{
if(ulPWMStastus & 0x1010)
{
g_pfnPWMHandlerCallbacks[1](0, PWM_EVENT_PWM, ulPWMStastus, 0);
}
if((ulPWMStastus & 0x10100000))
{
g_pfnPWMHandlerCallbacks[1](0, PWM_EVENT_CAP, (1 << PWM_CHANNEL4), 0);
}
}
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* This function registers an event that is to be signaled whenever a configuration process on the specified configuration data is performed. An event can be registered for a different DataType simultaneously. The caller is responsible for determining which type of configuration data causes the signaling of the event in such an event. */
|
EFI_STATUS EFIAPI EfiIp6ConfigRegisterDataNotify(IN EFI_IP6_CONFIG_PROTOCOL *This, IN EFI_IP6_CONFIG_DATA_TYPE DataType, IN EFI_EVENT Event)
|
/* This function registers an event that is to be signaled whenever a configuration process on the specified configuration data is performed. An event can be registered for a different DataType simultaneously. The caller is responsible for determining which type of configuration data causes the signaling of the event in such an event. */
EFI_STATUS EFIAPI EfiIp6ConfigRegisterDataNotify(IN EFI_IP6_CONFIG_PROTOCOL *This, IN EFI_IP6_CONFIG_DATA_TYPE DataType, IN EFI_EVENT Event)
|
{
EFI_TPL OldTpl;
EFI_STATUS Status;
IP6_CONFIG_INSTANCE *Instance;
NET_MAP *EventMap;
NET_MAP_ITEM *Item;
if ((This == NULL) || (Event == NULL)) {
return EFI_INVALID_PARAMETER;
}
if (DataType >= Ip6ConfigDataTypeMaximum) {
return EFI_UNSUPPORTED;
}
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
Instance = IP6_CONFIG_INSTANCE_FROM_PROTOCOL (This);
EventMap = &Instance->DataItem[DataType].EventMap;
Item = NetMapFindKey (EventMap, Event);
if (Item == NULL) {
Status = NetMapInsertTail (EventMap, Event, NULL);
if (EFI_ERROR (Status)) {
Status = EFI_OUT_OF_RESOURCES;
}
} else {
Status = EFI_ACCESS_DENIED;
}
gBS->RestoreTPL (OldTpl);
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Switch on the ATTR2 superblock bit (implies also FEATURES2) */
|
STATIC void xfs_sbversion_add_attr2(xfs_mount_t *mp, xfs_trans_t *tp)
|
/* Switch on the ATTR2 superblock bit (implies also FEATURES2) */
STATIC void xfs_sbversion_add_attr2(xfs_mount_t *mp, xfs_trans_t *tp)
|
{
if ((mp->m_flags & XFS_MOUNT_ATTR2) &&
!(xfs_sb_version_hasattr2(&mp->m_sb))) {
spin_lock(&mp->m_sb_lock);
if (!xfs_sb_version_hasattr2(&mp->m_sb)) {
xfs_sb_version_addattr2(&mp->m_sb);
spin_unlock(&mp->m_sb_lock);
xfs_mod_sb(tp, XFS_SB_VERSIONNUM | XFS_SB_FEATURES2);
} else
spin_unlock(&mp->m_sb_lock);
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* vx_set_pcx_time - convert from the PC time to the RMH status time. @pc_time: the pointer for the PC-time to set @dsp_time: the pointer for RMH status time array */
|
static void vx_set_pcx_time(struct vx_core *chip, pcx_time_t *pc_time, unsigned int *dsp_time)
|
/* vx_set_pcx_time - convert from the PC time to the RMH status time. @pc_time: the pointer for the PC-time to set @dsp_time: the pointer for RMH status time array */
static void vx_set_pcx_time(struct vx_core *chip, pcx_time_t *pc_time, unsigned int *dsp_time)
|
{
dsp_time[0] = (unsigned int)((*pc_time) >> 24) & PCX_TIME_HI_MASK;
dsp_time[1] = (unsigned int)(*pc_time) & MASK_DSP_WORD;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Disable interrupt mode for the selected IO pin(s). */
|
void stmpe811_IO_DisablePinIT(uint16_t DeviceAddr, uint32_t IO_Pin)
|
/* Disable interrupt mode for the selected IO pin(s). */
void stmpe811_IO_DisablePinIT(uint16_t DeviceAddr, uint32_t IO_Pin)
|
{
uint8_t tmp = 0;
tmp = IOE_Read(DeviceAddr, STMPE811_REG_IO_INT_EN);
tmp &= ~(uint8_t)IO_Pin;
IOE_Write(DeviceAddr, STMPE811_REG_IO_INT_EN, tmp);
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Caller disables interrupt before call and enables interrupt after return. */
|
static void acpi_idle_do_entry(struct acpi_processor_cx *cx)
|
/* Caller disables interrupt before call and enables interrupt after return. */
static void acpi_idle_do_entry(struct acpi_processor_cx *cx)
|
{
stop_critical_timings();
if (cx->entry_method == ACPI_CSTATE_FFH) {
acpi_processor_ffh_cstate_enter(cx);
} else if (cx->entry_method == ACPI_CSTATE_HALT) {
acpi_safe_halt();
} else {
int unused;
inb(cx->address);
unused = inl(acpi_gbl_FADT.xpm_timer_block.address);
}
start_critical_timings();
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Returns TRUE if the rgb is set to the value "inherit", FALSE otherwise. */
|
gboolean cr_rgb_is_set_to_inherit(CRRgb *a_this)
|
/* Returns TRUE if the rgb is set to the value "inherit", FALSE otherwise. */
gboolean cr_rgb_is_set_to_inherit(CRRgb *a_this)
|
{
g_return_val_if_fail (a_this, CR_BAD_PARAM_ERROR) ;
return a_this->inherit ;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Transforms an 16-bit RGB565 pixel into a 24bpp pixel. */
|
EMSTATUS DMDIF_writeReg(uint8_t reg, uint16_t data)
|
/* Transforms an 16-bit RGB565 pixel into a 24bpp pixel. */
EMSTATUS DMDIF_writeReg(uint8_t reg, uint16_t data)
|
{
SPI_TFT_WriteRegister(reg, data);
return DMD_OK;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Prepare for output to a stdio stream. The caller must have already opened the stream, and is responsible for closing it after finishing compression. */
|
jpeg_stdio_dest(j_compress_ptr cinfo, FILE *outfile)
|
/* Prepare for output to a stdio stream. The caller must have already opened the stream, and is responsible for closing it after finishing compression. */
jpeg_stdio_dest(j_compress_ptr cinfo, FILE *outfile)
|
{
my_dest_ptr dest;
if (cinfo->dest == NULL) {
cinfo->dest = (struct jpeg_destination_mgr *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(my_destination_mgr));
}
dest = (my_dest_ptr) cinfo->dest;
dest->pub.init_destination = init_destination;
dest->pub.empty_output_buffer = empty_output_buffer;
dest->pub.term_destination = term_destination;
dest->outfile = outfile;
}
|
xboot/xboot
|
C++
|
MIT License
| 779
|
/* This function retrieves data from HID item. It only supports short items, which has 4 types of data: 0, 1, 2, or 4 bytes. */
|
UINT32 GetItemData(IN HID_ITEM *HidItem)
|
/* This function retrieves data from HID item. It only supports short items, which has 4 types of data: 0, 1, 2, or 4 bytes. */
UINT32 GetItemData(IN HID_ITEM *HidItem)
|
{
switch (HidItem->Size) {
case 1:
return HidItem->Data.Uint8;
case 2:
return HidItem->Data.Uint16;
case 4:
return HidItem->Data.Uint32;
}
return 0;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* translate ns.ns/4 coding of SPD timing values into 10 ps unit values */
|
unsigned short NS4to10PS(unsigned char spd_byte, unsigned char spd_version)
|
/* translate ns.ns/4 coding of SPD timing values into 10 ps unit values */
unsigned short NS4to10PS(unsigned char spd_byte, unsigned char spd_version)
|
{
unsigned short ns, ns4;
ns = (spd_byte >> 2) & 0x3F;
ns4 = (spd_byte & 0x03);
return (ns * 100 + ns4 * 25);
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* If Context is NULL, then ASSERT(). If CpuIndex == BspIndex, then ASSERT(). If BspIndex or CpuIndex exceed the range of all CPUs in the system, then ASSERT(). */
|
VOID EFIAPI SmmCpuSyncReleaseBsp(IN OUT SMM_CPU_SYNC_CONTEXT *Context, IN UINTN CpuIndex, IN UINTN BspIndex)
|
/* If Context is NULL, then ASSERT(). If CpuIndex == BspIndex, then ASSERT(). If BspIndex or CpuIndex exceed the range of all CPUs in the system, then ASSERT(). */
VOID EFIAPI SmmCpuSyncReleaseBsp(IN OUT SMM_CPU_SYNC_CONTEXT *Context, IN UINTN CpuIndex, IN UINTN BspIndex)
|
{
ASSERT (Context != NULL);
ASSERT (BspIndex != CpuIndex);
ASSERT (CpuIndex < Context->NumberOfCpus);
ASSERT (BspIndex < Context->NumberOfCpus);
InternalReleaseSemaphore (Context->CpuSem[BspIndex].Run);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Set up the transport system for use by Fastboot. e.g. For USB this probably means making the device enumerable. */
|
EFI_STATUS FastbootTransportUsbStart(EFI_EVENT ReceiveEvent)
|
/* Set up the transport system for use by Fastboot. e.g. For USB this probably means making the device enumerable. */
EFI_STATUS FastbootTransportUsbStart(EFI_EVENT ReceiveEvent)
|
{
GET_CONFIG_DESCRIPTOR_RESPONSE *Responses;
mReceiveEvent = ReceiveEvent;
mGetConfigDescriptorResponse.ConfigDescriptor.TotalLength = sizeof (GET_CONFIG_DESCRIPTOR_RESPONSE);
Responses = &mGetConfigDescriptorResponse;
InitializeListHead (&mPacketList);
return mUsbDevice->Start (&mDeviceDescriptor, (VOID **)&Responses, DataReceived, DataSent);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Used when in panic, no locks are taken. */
|
static void panic_nand_get_device(struct nand_chip *chip, struct mtd_info *mtd, int new_state)
|
/* Used when in panic, no locks are taken. */
static void panic_nand_get_device(struct nand_chip *chip, struct mtd_info *mtd, int new_state)
|
{
chip->controller->active = chip;
chip->state = new_state;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* megasas_disable_intr_skinny - Disables interrupt @regs: MFI register set */
|
static void megasas_disable_intr_skinny(struct megasas_register_set __iomem *regs)
|
/* megasas_disable_intr_skinny - Disables interrupt @regs: MFI register set */
static void megasas_disable_intr_skinny(struct megasas_register_set __iomem *regs)
|
{
u32 mask = 0xFFFFFFFF;
writel(mask, ®s->outbound_intr_mask);
readl(®s->outbound_intr_mask);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Description: If auto-negotiation is enabled, we configure the advertising, and then restart auto-negotiation. If it is not enabled, then we write the BMCR. */
|
int genphy_config_aneg(struct phy_device *phydev)
|
/* Description: If auto-negotiation is enabled, we configure the advertising, and then restart auto-negotiation. If it is not enabled, then we write the BMCR. */
int genphy_config_aneg(struct phy_device *phydev)
|
{
int result;
if (phydev->autoneg != AUTONEG_ENABLE)
return genphy_setup_forced(phydev);
result = genphy_config_advert(phydev);
if (result < 0)
return result;
if (result == 0) {
int ctl = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMCR);
if (ctl < 0)
return ctl;
if (!(ctl & BMCR_ANENABLE) || (ctl & BMCR_ISOLATE))
result = 1;
}
if (result > 0)
result = genphy_restart_aneg(phydev);
return result;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Register a preference with an unsigned integral value. */
|
void prefs_register_uint_preference(module_t *module, const char *name, const char *title, const char *description, guint base, guint *var)
|
/* Register a preference with an unsigned integral value. */
void prefs_register_uint_preference(module_t *module, const char *name, const char *title, const char *description, guint base, guint *var)
|
{
pref_t *preference;
preference = register_preference(module, name, title, description,
PREF_UINT);
preference->varp.uint = var;
preference->default_val.uint = *var;
g_assert(base > 0 && base != 1 && base < 37);
preference->info.base = base;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Returns the length of the ID string, according to known wraparound/trailing zero patterns. If no pattern exists, returns the length of the array. */
|
static int nand_id_len(u8 *id_data, int arrlen)
|
/* Returns the length of the ID string, according to known wraparound/trailing zero patterns. If no pattern exists, returns the length of the array. */
static int nand_id_len(u8 *id_data, int arrlen)
|
{
int last_nonzero, period;
for (last_nonzero = arrlen - 1; last_nonzero >= 0; last_nonzero--)
if (id_data[last_nonzero])
break;
if (last_nonzero < 0)
return 0;
for (period = 1; period < arrlen; period++)
if (nand_id_has_period(id_data, arrlen, period))
break;
if (period < arrlen)
return period;
if (last_nonzero < arrlen - 1)
return last_nonzero + 1;
return arrlen;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Sets the @attribute to contain the given @attr_value, if possible. */
|
void g_file_info_set_attribute_object(GFileInfo *info, const char *attribute, GObject *attr_value)
|
/* Sets the @attribute to contain the given @attr_value, if possible. */
void g_file_info_set_attribute_object(GFileInfo *info, const char *attribute, GObject *attr_value)
|
{
g_return_if_fail (G_IS_FILE_INFO (info));
g_return_if_fail (attribute != NULL && *attribute != '\0');
g_return_if_fail (G_IS_OBJECT (attr_value));
_g_file_info_set_attribute_object_by_id (info,
lookup_attribute (attribute),
attr_value);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Returns 0 on success or a negative error code. */
|
int nla_policy_len(const struct nla_policy *p, int n)
|
/* Returns 0 on success or a negative error code. */
int nla_policy_len(const struct nla_policy *p, int n)
|
{
int i, len = 0;
for (i = 0; i < n; i++) {
if (p->len)
len += nla_total_size(p->len);
else if (nla_attr_minlen[p->type])
len += nla_total_size(nla_attr_minlen[p->type]);
}
return len;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* BACnetObjectPropertyReference ::= SEQUENCE { objectIdentifier BACnetObjectIdentifier, propertyIdentifier BACnetPropertyIdentifier, propertyArrayIndex Unsigned OPTIONAL, */
|
static guint fBACnetObjectPropertyReference(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
|
/* BACnetObjectPropertyReference ::= SEQUENCE { objectIdentifier BACnetObjectIdentifier, propertyIdentifier BACnetPropertyIdentifier, propertyArrayIndex Unsigned OPTIONAL, */
static guint fBACnetObjectPropertyReference(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
|
{
guint lastoffset = 0;
while (tvb_reported_length_remaining(tvb, offset) > 0) {
lastoffset = offset;
switch (fTagNo(tvb, offset)) {
case 0:
offset = fObjectIdentifier(tvb, pinfo, tree, offset);
break;
case 1:
offset = fPropertyReference(tvb, pinfo, tree, offset, 1, 0);
col_set_writable(pinfo->cinfo, COL_INFO, FALSE);
default:
lastoffset = offset;
break;
}
if (offset == lastoffset) break;
}
return offset;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* These simple memset/memcpy alternatives are necessary as the optimized ones depend on the MMU to be active (see commit c5b898743a20). */
|
void z_early_memset(void *dst, int c, size_t n)
|
/* These simple memset/memcpy alternatives are necessary as the optimized ones depend on the MMU to be active (see commit c5b898743a20). */
void z_early_memset(void *dst, int c, size_t n)
|
{
uint8_t *d = dst;
while (n--) {
*d++ = c;
}
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Determine which DMA controllers are present on this CPU */
|
void __init frv_dma_init(void)
|
/* Determine which DMA controllers are present on this CPU */
void __init frv_dma_init(void)
|
{
unsigned long psr = __get_PSR();
int num_dma, i;
switch (PSR_IMPLE(psr)) {
case PSR_IMPLE_FR405:
case PSR_IMPLE_FR451:
case PSR_IMPLE_FR501:
case PSR_IMPLE_FR551:
num_dma = FRV_DMA_8CHANS;
break;
case PSR_IMPLE_FR401:
default:
num_dma = FRV_DMA_4CHANS;
break;
}
for(i = num_dma; i < FRV_DMA_NCHANS; i++)
frv_dma_channels[i].flags = FRV_DMA_FLAGS_RESERVED;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Return value: a pointer to the found occurrence, or NULL if not found. */
|
gchar* g_strstr_len(const gchar *haystack, gssize haystack_len, const gchar *needle)
|
/* Return value: a pointer to the found occurrence, or NULL if not found. */
gchar* g_strstr_len(const gchar *haystack, gssize haystack_len, const gchar *needle)
|
{
g_return_val_if_fail (haystack != NULL, NULL);
g_return_val_if_fail (needle != NULL, NULL);
if (haystack_len < 0)
return strstr (haystack, needle);
else
{
const gchar *p = haystack;
gsize needle_len = strlen (needle);
const gchar *end;
gsize i;
if (needle_len == 0)
return (gchar *)haystack;
if (haystack_len < needle_len)
return NULL;
end = haystack + haystack_len - needle_len;
while (*p && p <= end)
{
for (i = 0; i < needle_len; i++)
if (p[i] != needle[i])
goto next;
return (gchar *)p;
next:
p++;
}
return NULL;
}
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Send a management message through control queue 0 */
|
int t3_mgmt_tx(struct adapter *adap, struct sk_buff *skb)
|
/* Send a management message through control queue 0 */
int t3_mgmt_tx(struct adapter *adap, struct sk_buff *skb)
|
{
int ret;
local_bh_disable();
ret = ctrl_xmit(adap, &adap->sge.qs[0].txq[TXQ_CTRL], skb);
local_bh_enable();
return ret;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Filter predicate for dynamic sized arrays of characters. These are implemented through a list of strings at the end of the entry. Also each of these strings have a field in the entry which contains its offset from the beginning of the entry. We have then first to get this field, dereference it and add it to the address of the entry, and at last we have the address of the string. */
|
static int filter_pred_strloc(struct filter_pred *pred, void *event, int val1, int val2)
|
/* Filter predicate for dynamic sized arrays of characters. These are implemented through a list of strings at the end of the entry. Also each of these strings have a field in the entry which contains its offset from the beginning of the entry. We have then first to get this field, dereference it and add it to the address of the entry, and at last we have the address of the string. */
static int filter_pred_strloc(struct filter_pred *pred, void *event, int val1, int val2)
|
{
u32 str_item = *(u32 *)(event + pred->offset);
int str_loc = str_item & 0xffff;
int str_len = str_item >> 16;
char *addr = (char *)(event + str_loc);
int cmp, match;
cmp = pred->regex.match(addr, &pred->regex, str_len);
match = cmp ^ pred->not;
return match;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.