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
/* pfn_is_nosave - check if given pfn is in the 'nosave' section */
int pfn_is_nosave(unsigned long pfn)
/* pfn_is_nosave - check if given pfn is in the 'nosave' section */ int pfn_is_nosave(unsigned long pfn)
{ unsigned long nosave_begin_pfn = __pa_symbol(&__nosave_begin) >> PAGE_SHIFT; unsigned long nosave_end_pfn = PAGE_ALIGN(__pa_symbol(&__nosave_end)) >> PAGE_SHIFT; return (pfn >= nosave_begin_pfn) && (pfn < nosave_end_pfn); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Setup the endpoints to be bulk & register the callbacks. */
static void msc_set_config(usbd_device *usbd_dev, uint16_t wValue)
/* Setup the endpoints to be bulk & register the callbacks. */ static void msc_set_config(usbd_device *usbd_dev, uint16_t wValue)
{ usbd_mass_storage *ms = &_mass_storage; (void)wValue; usbd_ep_setup(usbd_dev, ms->ep_in, USB_ENDPOINT_ATTR_BULK, ms->ep_in_size, msc_data_tx_cb); usbd_ep_setup(usbd_dev, ms->ep_out, USB_ENDPOINT_ATTR_BULK, ms->ep_out_size, msc_data_rx_cb); usbd_register_control_callback( usbd_dev, USB_REQ_TYPE_CLASS | USB_REQ_TYPE_INTERFACE, USB_REQ_TYPE_TYPE | USB_REQ_TYPE_RECIPIENT, msc_control_request); }
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* Writes and returns a new value to DR1. This function is only available on IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64. */
UINTN EFIAPI AsmWriteDr1(UINTN Dr1)
/* Writes and returns a new value to DR1. This function is only available on IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64. */ UINTN EFIAPI AsmWriteDr1(UINTN Dr1)
{ __asm__ __volatile__ ( "mov %0, %%dr1" : : "r" (Dr1) ); return Dr1; }
tianocore/edk2
C++
Other
4,240
/* Routine: pinmux_init Description: Do individual peripheral pinmux configs */
void pinmux_init(void)
/* Routine: pinmux_init Description: Do individual peripheral pinmux configs */ void pinmux_init(void)
{ pinmux_clear_tristate_input_clamping(); gpio_config_table(p2371_2180_gpio_inits, ARRAY_SIZE(p2371_2180_gpio_inits)); pinmux_config_pingrp_table(p2371_2180_pingrps, ARRAY_SIZE(p2371_2180_pingrps)); pinmux_config_drvgrp_table(p2371_2180_drvgrps, ARRAY_SIZE(p2371_2180_drvgrps)); }
4ms/stm32mp1-baremetal
C++
Other
137
/* Read Counter. Read back the value of a timer's counter register contents */
uint32_t timer_get_counter(uint32_t timer_peripheral)
/* Read Counter. Read back the value of a timer's counter register contents */ uint32_t timer_get_counter(uint32_t timer_peripheral)
{ return TIM_CNT(timer_peripheral); }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* GUID is used e.g. in GPT (GUID Partition Table) as a partiions unique id. */
int uuid_str_valid(const char *uuid)
/* GUID is used e.g. in GPT (GUID Partition Table) as a partiions unique id. */ int uuid_str_valid(const char *uuid)
{ int i, valid; if (uuid == NULL) return 0; for (i = 0, valid = 1; uuid[i] && valid; i++) { switch (i) { case 8: case 13: case 18: case 23: valid = (uuid[i] == '-'); break; default: valid = isxdigit(uuid[i]); break; } } if (i != UUID_STR_LEN || !valid) return 0; return 1; }
4ms/stm32mp1-baremetal
C++
Other
137
/* User can (and should) define the platform from U-Boot */
static int __init kinetis_platform_parse(char *s)
/* User can (and should) define the platform from U-Boot */ static int __init kinetis_platform_parse(char *s)
{ if (!strcmp(s, "twr-k70f120m")) { kinetis_platform = PLATFORM_KINETIS_TWR_K70F120M; } else if (!strcmp(s, "k70-som")) { kinetis_platform = PLATFORM_KINETIS_K70_SOM; } else if (!strcmp(s, "k61-som")) { kinetis_platform = PLATFORM_KINETIS_K61_SOM; } else { pr_err("%s: An unknown platform requested: %s\n", __func__, s); } return 1; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Deserializes the supplied (wire) buffer into connack data - return code */
int MQTTDeserialize_connack(unsigned char *sessionPresent, unsigned char *connack_rc, unsigned char *buf, int buflen)
/* Deserializes the supplied (wire) buffer into connack data - return code */ int MQTTDeserialize_connack(unsigned char *sessionPresent, unsigned char *connack_rc, unsigned char *buf, int buflen)
{ MQTTHeader header = {0}; unsigned char* curdata = buf; unsigned char* enddata = NULL; int rc = 0; int mylen; MQTTConnackFlags flags = {0}; FUNC_ENTRY; header.byte = readChar(&curdata); if (header.bits.type != CONNACK) goto exit; curdata += (rc = MQTTPacket_decodeBuf(curdata, &mylen)); enddata = curdata + mylen; if (enddata - curdata < 2) goto exit; flags.all = readChar(&curdata); *sessionPresent = flags.bits.sessionpresent; *connack_rc = readChar(&curdata); rc = 1; exit: FUNC_EXIT_RC(rc); return rc; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Increment instance count for SBBR-mandatory ACPI table with the given signature. */
BOOLEAN EFIAPI ArmSbbrIncrementTableCount(UINT32 Signature)
/* Increment instance count for SBBR-mandatory ACPI table with the given signature. */ BOOLEAN EFIAPI ArmSbbrIncrementTableCount(UINT32 Signature)
{ UINT32 Table; for (Table = 0; Table < ARRAY_SIZE (ArmSbbrTableCounts); Table++) { if (Signature == ArmSbbrTableCounts[Table].Signature) { ArmSbbrTableCounts[Table].Count++; return TRUE; } } return FALSE; }
tianocore/edk2
C++
Other
4,240
/* This function handles External lines 9 to 5 interrupt request. */
void EXTI9_5_IRQHandler(void)
/* This function handles External lines 9 to 5 interrupt request. */ void EXTI9_5_IRQHandler(void)
{ NVIC_InitTypeDef NVIC_InitStructure; if(EXTI_GetITStatus(KEY_BUTTON_EXTI_LINE) != RESET) { PreemptionPriorityValue = !PreemptionPriorityValue; PreemptionOccured = 0; NVIC_InitStructure.NVIC_IRQChannel = WAKEUP_BUTTON_EXTI_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = PreemptionPriorityValue; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); NVIC_SetPriority(SysTick_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), !PreemptionPriorityValue, 0)); EXTI_ClearITPendingBit(KEY_BUTTON_EXTI_LINE); } }
remotemcu/remcu-chip-sdks
C++
null
436
/* This callback is called when the error recovery driver tells us that its OK to resume normal operation. Implementation resembles the second-half of the e1000_resume routine. */
static void e1000_io_resume(struct pci_dev *pdev)
/* This callback is called when the error recovery driver tells us that its OK to resume normal operation. Implementation resembles the second-half of the e1000_resume routine. */ static void e1000_io_resume(struct pci_dev *pdev)
{ struct net_device *netdev = pci_get_drvdata(pdev); struct e1000_adapter *adapter = netdev_priv(netdev); e1000_init_manageability(adapter); if (netif_running(netdev)) { if (e1000_up(adapter)) { printk("e1000: can't bring device back up after reset\n"); return; } } netif_device_attach(netdev); }
robutest/uclinux
C++
GPL-2.0
60
/* Funtion for initializing a BLE Connection State user flag. */
static void flag_id_init(ble_conn_state_user_flag_id_t *p_flag_id)
/* Funtion for initializing a BLE Connection State user flag. */ static void flag_id_init(ble_conn_state_user_flag_id_t *p_flag_id)
{ if (*p_flag_id == BLE_CONN_STATE_USER_FLAG_INVALID) { *p_flag_id = ble_conn_state_user_flag_acquire(); } }
labapart/polymcu
C++
null
201
/* Check whether ObjectNode has the input OpCode/SubOpcode couple. */
BOOLEAN EFIAPI AmlNodeCompareOpCode(IN CONST AML_OBJECT_NODE *ObjectNode, IN UINT8 OpCode, IN UINT8 SubOpCode)
/* Check whether ObjectNode has the input OpCode/SubOpcode couple. */ BOOLEAN EFIAPI AmlNodeCompareOpCode(IN CONST AML_OBJECT_NODE *ObjectNode, IN UINT8 OpCode, IN UINT8 SubOpCode)
{ if (!IS_AML_OBJECT_NODE (ObjectNode) || (ObjectNode->AmlByteEncoding == NULL)) { return FALSE; } ASSERT (AmlIsOpCodeValid (OpCode, SubOpCode)); return ((ObjectNode->AmlByteEncoding->OpCode == OpCode) && (ObjectNode->AmlByteEncoding->SubOpCode == SubOpCode)) ? TRUE : FALSE; }
tianocore/edk2
C++
Other
4,240
/* Returns all IOC Doorbell register bits if cooked==0, else just the Doorbell bits in MPI_IOC_STATE_MASK. */
u32 mpt2sas_base_get_iocstate(struct MPT2SAS_ADAPTER *ioc, int cooked)
/* Returns all IOC Doorbell register bits if cooked==0, else just the Doorbell bits in MPI_IOC_STATE_MASK. */ u32 mpt2sas_base_get_iocstate(struct MPT2SAS_ADAPTER *ioc, int cooked)
{ u32 s, sc; s = readl(&ioc->chip->Doorbell); sc = s & MPI2_IOC_STATE_MASK; return cooked ? sc : s; }
robutest/uclinux
C++
GPL-2.0
60
/* Called with shm_ids.rw_mutex (writer) and the shp structure locked. Only shm_ids.rw_mutex remains locked on exit. */
static void do_shm_rmid(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp)
/* Called with shm_ids.rw_mutex (writer) and the shp structure locked. Only shm_ids.rw_mutex remains locked on exit. */ static void do_shm_rmid(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp)
{ struct shmid_kernel *shp; shp = container_of(ipcp, struct shmid_kernel, shm_perm); if (shp->shm_nattch){ shp->shm_perm.mode |= SHM_DEST; shp->shm_perm.key = IPC_PRIVATE; shm_unlock(shp); } else shm_destroy(ns, shp); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Used by fix_read_error() to decay the per rdev read_errors. We halve the read error count for every hour that has elapsed since the last recorded read error. */
static void check_decay_read_errors(mddev_t *mddev, mdk_rdev_t *rdev)
/* Used by fix_read_error() to decay the per rdev read_errors. We halve the read error count for every hour that has elapsed since the last recorded read error. */ static void check_decay_read_errors(mddev_t *mddev, mdk_rdev_t *rdev)
{ struct timespec cur_time_mon; unsigned long hours_since_last; unsigned int read_errors = atomic_read(&rdev->read_errors); ktime_get_ts(&cur_time_mon); if (rdev->last_read_error.tv_sec == 0 && rdev->last_read_error.tv_nsec == 0) { rdev->last_read_error = cur_time_mon; return; } hours_since_last = (cur_time_mon.tv_sec - rdev->last_read_error.tv_sec) / 3600; rdev->last_read_error = cur_time_mon; if (hours_since_last >= 8 * sizeof(read_errors)) atomic_set(&rdev->read_errors, 0); else atomic_set(&rdev->read_errors, read_errors >> hours_since_last); }
robutest/uclinux
C++
GPL-2.0
60
/* This function gets the number of bytes that have been received. Note: Do not trying to use this api to get the number of received bytes, it make no sense to link transfer. param base DMIC peripheral base address. param handle DMIC handle pointer. param count Receive bytes count. retval kStatus_NoTransferInProgress No receive in progress. retval kStatus_InvalidArgument Parameter is invalid. retval kStatus_Success Get successfully through the parameter count; */
status_t DMIC_TransferGetReceiveCountDMA(DMIC_Type *base, dmic_dma_handle_t *handle, uint32_t *count)
/* This function gets the number of bytes that have been received. Note: Do not trying to use this api to get the number of received bytes, it make no sense to link transfer. param base DMIC peripheral base address. param handle DMIC handle pointer. param count Receive bytes count. retval kStatus_NoTransferInProgress No receive in progress. retval kStatus_InvalidArgument Parameter is invalid. retval kStatus_Success Get successfully through the parameter count; */ status_t DMIC_TransferGetReceiveCountDMA(DMIC_Type *base, dmic_dma_handle_t *handle, uint32_t *count)
{ assert(handle != NULL); assert(handle->rxDmaHandle != NULL); assert(count != NULL); if ((uint8_t)kDMIC_Idle == handle->state) { return kStatus_NoTransferInProgress; } *count = handle->transferSize - DMA_GetRemainingBytes(handle->rxDmaHandle->base, handle->rxDmaHandle->channel); return kStatus_Success; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Allocate a usb_request and its buffer. Returns a pointer to the usb_request or NULL if there is an error. */
struct usb_request* gs_alloc_req(struct usb_ep *ep, unsigned len, gfp_t kmalloc_flags)
/* Allocate a usb_request and its buffer. Returns a pointer to the usb_request or NULL if there is an error. */ struct usb_request* gs_alloc_req(struct usb_ep *ep, unsigned len, gfp_t kmalloc_flags)
{ struct usb_request *req; req = usb_ep_alloc_request(ep, kmalloc_flags); if (req != NULL) { req->length = len; req->buf = kmalloc(len, kmalloc_flags); if (req->buf == NULL) { usb_ep_free_request(ep, req); return NULL; } } return req; }
robutest/uclinux
C++
GPL-2.0
60
/* Configs the SDIO Command and send the command. */
void SDIO_TxCommand(SDIO_CmdConfig_T *cmdConfig)
/* Configs the SDIO Command and send the command. */ void SDIO_TxCommand(SDIO_CmdConfig_T *cmdConfig)
{ uint32_t tempReg = 0; SDIO->ARG = cmdConfig->argument; tempReg = SDIO->CMD; tempReg &= ((uint32_t)0xFFFFF800); tempReg |= (uint32_t)(cmdConfig->cmdIndex) | (cmdConfig->response) << 6 | (cmdConfig->wait) << 8 | (cmdConfig->CPSM) << 10; SDIO->CMD = tempReg; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Selects the SCK pin as the source of baud rate for the USART synchronous slave modes. */
static int usart_set_sync_slave_baudrate(volatile avr32_usart_t *usart)
/* Selects the SCK pin as the source of baud rate for the USART synchronous slave modes. */ static int usart_set_sync_slave_baudrate(volatile avr32_usart_t *usart)
{ usart->mr = (usart->mr & ~AVR32_USART_MR_USCLKS_MASK) | AVR32_USART_MR_USCLKS_SCK << AVR32_USART_MR_USCLKS_OFFSET | AVR32_USART_MR_SYNC_MASK; return USART_SUCCESS; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Invoked when AER root service driver is loaded. */
static int __init aer_service_init(void)
/* Invoked when AER root service driver is loaded. */ static int __init aer_service_init(void)
{ if (pcie_aer_disable) return -ENXIO; if (!pci_msi_enabled()) return -ENXIO; return pcie_port_service_register(&aerdriver); }
robutest/uclinux
C++
GPL-2.0
60
/* Configures timing unit (timer A to timer E) time base. */
void HRTIM_TimingUnitBase_Config(HRTIM_TypeDef *HRTIMx, uint32_t TimerIdx, HRTIM_BaseInitTypeDef *HRTIM_BaseInitStruct)
/* Configures timing unit (timer A to timer E) time base. */ void HRTIM_TimingUnitBase_Config(HRTIM_TypeDef *HRTIMx, uint32_t TimerIdx, HRTIM_BaseInitTypeDef *HRTIM_BaseInitStruct)
{ HRTIMx->HRTIM_TIMERx[TimerIdx].TIMxCR &= (uint32_t) ~(HRTIM_TIMCR_CK_PSC); HRTIMx->HRTIM_TIMERx[TimerIdx].TIMxCR |= (uint32_t)HRTIM_BaseInitStruct->PrescalerRatio; HRTIMx->HRTIM_TIMERx[TimerIdx].TIMxCR &= (uint32_t) ~(HRTIM_TIMCR_CONT | HRTIM_TIMCR_RETRIG); HRTIMx->HRTIM_TIMERx[TimerIdx].TIMxCR |= (uint32_t)HRTIM_BaseInitStruct->Mode; HRTIMx->HRTIM_TIMERx[TimerIdx].PERxR = HRTIM_BaseInitStruct->Period; HRTIMx->HRTIM_TIMERx[TimerIdx].REPxR = HRTIM_BaseInitStruct->RepetitionCounter; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Accelerometer full-scale management between UI chain and OIS chain. When XL UI is on, the full scale is the same between UI/OIS and is chosen by the UI CTRL registers; when XL UI is in PD, the OIS can choose the FS. Full scales are independent between the UI/OIS chain but both bound to 8 g.. */
int32_t lsm6dso_aux_xl_fs_mode_get(lsm6dso_ctx_t *ctx, lsm6dso_xl_fs_mode_t *val)
/* Accelerometer full-scale management between UI chain and OIS chain. When XL UI is on, the full scale is the same between UI/OIS and is chosen by the UI CTRL registers; when XL UI is in PD, the OIS can choose the FS. Full scales are independent between the UI/OIS chain but both bound to 8 g.. */ int32_t lsm6dso_aux_xl_fs_mode_get(lsm6dso_ctx_t *ctx, lsm6dso_xl_fs_mode_t *val)
{ lsm6dso_ctrl8_xl_t reg; int32_t ret; ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL8_XL, (uint8_t*)&reg, 1); switch (reg.xl_fs_mode) { case LSM6DSO_USE_SAME_XL_FS: *val = LSM6DSO_USE_SAME_XL_FS; break; case LSM6DSO_USE_DIFFERENT_XL_FS: *val = LSM6DSO_USE_DIFFERENT_XL_FS; break; default: *val = LSM6DSO_USE_SAME_XL_FS; break; } return ret; }
alexander-g-dean/ESF
C++
null
41
/* param base eDMA peripheral base address. param channel eDMA channel number. param config Pointer to eDMA transfer configuration structure. param nextTcd Point to TCD structure. It can be NULL if users do not want to enable scatter/gather feature. note If nextTcd is not NULL, it means scatter gather feature is enabled and DREQ bit is cleared in the previous transfer configuration, which is set in the eDMA_ResetChannel. */
void EDMA_SetTransferConfig(DMA_Type *base, uint32_t channel, const edma_transfer_config_t *config, edma_tcd_t *nextTcd)
/* param base eDMA peripheral base address. param channel eDMA channel number. param config Pointer to eDMA transfer configuration structure. param nextTcd Point to TCD structure. It can be NULL if users do not want to enable scatter/gather feature. note If nextTcd is not NULL, it means scatter gather feature is enabled and DREQ bit is cleared in the previous transfer configuration, which is set in the eDMA_ResetChannel. */ void EDMA_SetTransferConfig(DMA_Type *base, uint32_t channel, const edma_transfer_config_t *config, edma_tcd_t *nextTcd)
{ assert(channel < (uint32_t)FSL_FEATURE_EDMA_MODULE_CHANNEL); assert(config != NULL); assert(((uint32_t)nextTcd & 0x1FU) == 0U); EDMA_TcdSetTransferConfig((edma_tcd_t *)(uint32_t)&base->TCD[channel], config, nextTcd); }
eclipse-threadx/getting-started
C++
Other
310
/* The counter can either count up by 1 or count down by 1. If the physical performance counter counts by a larger increment, then the counter values must be translated. The properties of the counter can be retrieved from */
UINT64 EFIAPI GetPerformanceCounter(VOID)
/* The counter can either count up by 1 or count down by 1. If the physical performance counter counts by a larger increment, then the counter values must be translated. The properties of the counter can be retrieved from */ UINT64 EFIAPI GetPerformanceCounter(VOID)
{ return (UINT64)GetApicTimerCurrentCount (); }
tianocore/edk2
C++
Other
4,240
/* For internal use only. If a peripheral access semphore is not defined, just return STATUS_OK and take no other action. If a peripheral access semphore is defined, attempt to obtain the semphore. Return STATUS_OK if the semphore was obtained, and ERR_TIMEOUT if the semphore did not become available within max_block_time_ticks tick periods. */
status_code_t freertos_obtain_peripheral_access_semphore(freertos_dma_event_control_t *dma_event_control, portTickType *max_block_time_ticks)
/* For internal use only. If a peripheral access semphore is not defined, just return STATUS_OK and take no other action. If a peripheral access semphore is defined, attempt to obtain the semphore. Return STATUS_OK if the semphore was obtained, and ERR_TIMEOUT if the semphore did not become available within max_block_time_ticks tick periods. */ status_code_t freertos_obtain_peripheral_access_semphore(freertos_dma_event_control_t *dma_event_control, portTickType *max_block_time_ticks)
{ status_code_t return_value = STATUS_OK; xTimeOutType time_out_definition; if (dma_event_control->peripheral_access_sem != NULL) { vTaskSetTimeOutState(&time_out_definition); if (xSemaphoreTake(dma_event_control->peripheral_access_sem, *max_block_time_ticks) == pdFAIL) { return_value = ERR_TIMEOUT; } else { if (xTaskCheckForTimeOut(&time_out_definition, max_block_time_ticks) == pdTRUE) { *max_block_time_ticks = 0; } } } return return_value; }
memfault/zero-to-main
C++
null
200
/* Called very early, MMU is off, device-tree isn't unflattened */
static int __init ebony_probe(void)
/* Called very early, MMU is off, device-tree isn't unflattened */ static int __init ebony_probe(void)
{ unsigned long root = of_get_flat_dt_root(); if (!of_flat_dt_is_compatible(root, "ibm,ebony")) return 0; ppc_pci_set_flags(PPC_PCI_REASSIGN_ALL_RSRC); return 1; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* PCD MSP Initialization This function configures the hardware resources used in this example. */
void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
/* PCD MSP Initialization This function configures the hardware resources used in this example. */ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
{ GPIO_InitTypeDef GPIO_InitStruct = {0}; if(hpcd->Instance==USB_OTG_FS) { __HAL_RCC_GPIOA_CLK_ENABLE(); GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); HAL_NVIC_SetPriority(OTG_FS_IRQn, 0, 0); HAL_NVIC_EnableIRQ(OTG_FS_IRQn); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* The result is a convex window growth curve. */
static u32 alpha(struct illinois *ca, u32 da, u32 dm)
/* The result is a convex window growth curve. */ static u32 alpha(struct illinois *ca, u32 da, u32 dm)
{ u32 d1 = dm / 100; if (da <= d1) { if (!ca->rtt_above) return ALPHA_MAX; if (++ca->rtt_low < theta) return ca->alpha; ca->rtt_low = 0; ca->rtt_above = 0; return ALPHA_MAX; } ca->rtt_above = 1; dm -= d1; da -= d1; return (dm * ALPHA_MAX) / (dm + (da * (ALPHA_MAX - ALPHA_MIN)) / ALPHA_MIN); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Removes any name for the object. Note that this must be called before drm_gem_object_free or we'll be touching freed memory */
void drm_gem_object_handle_free(struct kref *kref)
/* Removes any name for the object. Note that this must be called before drm_gem_object_free or we'll be touching freed memory */ void drm_gem_object_handle_free(struct kref *kref)
{ struct drm_gem_object *obj = container_of(kref, struct drm_gem_object, handlecount); struct drm_device *dev = obj->dev; spin_lock(&dev->object_name_lock); if (obj->name) { idr_remove(&dev->object_name_idr, obj->name); obj->name = 0; spin_unlock(&dev->object_name_lock); drm_gem_object_unreference(obj); } else spin_unlock(&dev->object_name_lock); }
robutest/uclinux
C++
GPL-2.0
60
/* This function will resume all suspended threads in a list, including suspend list of IPC object and private list of mailbox etc. */
rt_inline rt_err_t rt_ipc_list_resume_all(rt_list_t *list)
/* This function will resume all suspended threads in a list, including suspend list of IPC object and private list of mailbox etc. */ rt_inline rt_err_t rt_ipc_list_resume_all(rt_list_t *list)
{ struct rt_thread *thread; register rt_ubase_t temp; while (!rt_list_isempty(list)) { temp = rt_hw_interrupt_disable(); thread = rt_list_entry(list->next, struct rt_thread, tlist); thread->error = -RT_ERROR; rt_thread_resume(thread); rt_hw_interrupt_enable(temp); } return RT_EOK; }
armink/FreeModbus_Slave-Master-RTT-STM32
C++
Other
1,477
/* For Td guest TDVMCALL_MMIO is invoked to write MMIO registers. */
UINT64 EFIAPI MmioWrite64(IN UINTN Address, IN UINT64 Value)
/* For Td guest TDVMCALL_MMIO is invoked to write MMIO registers. */ UINT64 EFIAPI MmioWrite64(IN UINTN Address, IN UINT64 Value)
{ BOOLEAN Flag; ASSERT ((Address & 7) == 0); Flag = FilterBeforeMmIoWrite (FilterWidth64, Address, &Value); if (Flag) { MemoryFence (); if (IsTdxGuest ()) { TdMmioWrite64 (Address, Value); } else { *(volatile UINT64 *)Address = Value; } MemoryFence (); } FilterAfterMmIoWrite (FilterWidth64, Address, &Value); return Value; }
tianocore/edk2
C++
Other
4,240
/* This function expects an IP packet with a prepended Ethernet header in the uip_buf buffer, and the length of the packet in the global variable uip_len. */
void uip_arp_ipin(void)
/* This function expects an IP packet with a prepended Ethernet header in the uip_buf buffer, and the length of the packet in the global variable uip_len. */ void uip_arp_ipin(void)
{ uip_len -= sizeof(struct uip_eth_hdr); if((IPBUF->srcipaddr[0] & uip_arp_netmask[0]) != (uip_hostaddr[0] & uip_arp_netmask[0])) { return; } if((IPBUF->srcipaddr[1] & uip_arp_netmask[1]) != (uip_hostaddr[1] & uip_arp_netmask[1])) { return; } uip_arp_update(IPBUF->srcipaddr, &(IPBUF->ethhdr.src)); return; }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Pull incoming environmental events off the physical link to the system controller and put them in a temporary holding area in SAL. Schedule scdrv_event() to move them along to their ultimate destination. */
static irqreturn_t scdrv_event_interrupt(int irq, void *subch_data)
/* Pull incoming environmental events off the physical link to the system controller and put them in a temporary holding area in SAL. Schedule scdrv_event() to move them along to their ultimate destination. */ static irqreturn_t scdrv_event_interrupt(int irq, void *subch_data)
{ struct subch_data_s *sd = subch_data; unsigned long flags; int status; spin_lock_irqsave(&sd->sd_rlock, flags); status = ia64_sn_irtr_intr(sd->sd_nasid, sd->sd_subch); if ((status > 0) && (status & SAL_IROUTER_INTR_RECV)) { tasklet_schedule(&sn_sysctl_event); } spin_unlock_irqrestore(&sd->sd_rlock, flags); return IRQ_HANDLED; }
robutest/uclinux
C++
GPL-2.0
60
/* Get the autofs super block info struct from the file opened on the autofs mount point. */
static struct autofs_sb_info* autofs_dev_ioctl_sbi(struct file *f)
/* Get the autofs super block info struct from the file opened on the autofs mount point. */ static struct autofs_sb_info* autofs_dev_ioctl_sbi(struct file *f)
{ struct autofs_sb_info *sbi = NULL; struct inode *inode; if (f) { inode = f->f_path.dentry->d_inode; sbi = autofs4_sbi(inode->i_sb); } return sbi; }
robutest/uclinux
C++
GPL-2.0
60
/* Set output offsets to 3270 datastream fragment of a console string. */
static void con3270_update_string(struct con3270 *cp, struct string *s, int nr)
/* Set output offsets to 3270 datastream fragment of a console string. */ static void con3270_update_string(struct con3270 *cp, struct string *s, int nr)
{ if (s->len >= cp->view.cols - 5) return; raw3270_buffer_address(cp->view.dev, s->string + s->len - 3, cp->view.cols * (nr + 1)); }
robutest/uclinux
C++
GPL-2.0
60
/* Sets the file type in a #GFileInfo to @type. See G_FILE_ATTRIBUTE_STANDARD_TYPE. */
void g_file_info_set_file_type(GFileInfo *info, GFileType type)
/* Sets the file type in a #GFileInfo to @type. See G_FILE_ATTRIBUTE_STANDARD_TYPE. */ void g_file_info_set_file_type(GFileInfo *info, GFileType type)
{ static guint32 attr = 0; GFileAttributeValue *value; g_return_if_fail (G_IS_FILE_INFO (info)); if (attr == 0) attr = lookup_attribute (G_FILE_ATTRIBUTE_STANDARD_TYPE); value = g_file_info_create_value (info, attr); if (value) _g_file_attribute_value_set_uint32 (value, type); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Retrieve the VBUS status for a specified port. */
FunctionalState HW_IF_PWR_IsEnabled(uint8_t PortNum)
/* Retrieve the VBUS status for a specified port. */ FunctionalState HW_IF_PWR_IsEnabled(uint8_t PortNum)
{ FunctionalState Status_ret = (FunctionalState) STUSB1602_VBUS_SRC_State_Get(STUSB1602_I2C_Add(PortNum)); return Status_ret; }
st-one/X-CUBE-USB-PD
C++
null
110
/* This function prints a formatted ASCII string to the console output device specified by ConOut in EFI_SYSTEM_TABLE and returns the number of ASCII characters that printed to ConOut. If the length of the formatted ASCII string is greater than PcdUefiLibMaxPrintBufferSize, then only the first PcdUefiLibMaxPrintBufferSize characters are sent to ConOut. If Format is NULL, then ASSERT(). If gST->ConOut is NULL, then ASSERT(). */
UINTN EFIAPI AsciiPrint(IN CONST CHAR8 *Format,...)
/* This function prints a formatted ASCII string to the console output device specified by ConOut in EFI_SYSTEM_TABLE and returns the number of ASCII characters that printed to ConOut. If the length of the formatted ASCII string is greater than PcdUefiLibMaxPrintBufferSize, then only the first PcdUefiLibMaxPrintBufferSize characters are sent to ConOut. If Format is NULL, then ASSERT(). If gST->ConOut is NULL, then ASSERT(). */ UINTN EFIAPI AsciiPrint(IN CONST CHAR8 *Format,...)
{ VA_LIST Marker; UINTN Return; ASSERT (Format != NULL); VA_START (Marker, Format); Return = AsciiInternalPrint (Format, gST->ConOut, Marker); VA_END (Marker); return Return; }
tianocore/edk2
C++
Other
4,240
/* This function is to be called when a tracer is about to be used. */
int tracing_update_buffers(void)
/* This function is to be called when a tracer is about to be used. */ int tracing_update_buffers(void)
{ int ret = 0; mutex_lock(&trace_types_lock); if (!ring_buffer_expanded) ret = tracing_resize_ring_buffer(trace_buf_size); mutex_unlock(&trace_types_lock); return ret; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* QSPI MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_QSPI_MspDeInit(QSPI_HandleTypeDef *hqspi)
/* QSPI MSP De-Initialization This function freeze the hardware resources used in this example. */ void HAL_QSPI_MspDeInit(QSPI_HandleTypeDef *hqspi)
{ if(hqspi->Instance==QUADSPI) { __HAL_RCC_QSPI_CLK_DISABLE(); HAL_GPIO_DeInit(GPIOE, GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13 |GPIO_PIN_14|GPIO_PIN_15); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Save private data from incoming connection requests to iw_cm_event, so the low level driver doesn't have to. Adjust the event ptr to point to the local copy. */
static int copy_private_data(struct iw_cm_event *event)
/* Save private data from incoming connection requests to iw_cm_event, so the low level driver doesn't have to. Adjust the event ptr to point to the local copy. */ static int copy_private_data(struct iw_cm_event *event)
{ void *p; p = kmemdup(event->private_data, event->private_data_len, GFP_ATOMIC); if (!p) return -ENOMEM; event->private_data = p; return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Decrements the page table entry counter of a L2 page table Decrements the page table entry counter of a level 2 page table. Contains a check to ensure that no attempts are made to remove entries from the respective table that aren't actually there. */
static void arm_mmu_dec_l2_table_entries(struct arm_mmu_l2_page_table *l2_page_table)
/* Decrements the page table entry counter of a L2 page table Decrements the page table entry counter of a level 2 page table. Contains a check to ensure that no attempts are made to remove entries from the respective table that aren't actually there. */ static void arm_mmu_dec_l2_table_entries(struct arm_mmu_l2_page_table *l2_page_table)
{ uint32_t l2_page_table_index = ARM_MMU_L2_PT_INDEX(l2_page_table); __ASSERT(l2_page_tables_status[l2_page_table_index].entries > 0, "Cannot decrement entry count of the L2 page table at index " "[%u] / addr %p / ref L1[%u]: entry count is already zero", l2_page_table_index, l2_page_table, l2_page_tables_status[l2_page_table_index].l1_index); if (--l2_page_tables_status[l2_page_table_index].entries == 0) { arm_mmu_release_l2_table(l2_page_table); } }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* param base SPC peripheral base address. param config Pointer the spc_LowPower_Request_config_t structure. */
void SPC_SetLowPowerRequestConfig(SPC_Type *base, const spc_lowpower_request_config_t *config)
/* param base SPC peripheral base address. param config Pointer the spc_LowPower_Request_config_t structure. */ void SPC_SetLowPowerRequestConfig(SPC_Type *base, const spc_lowpower_request_config_t *config)
{ assert(config != NULL); uint32_t reg; reg = base->LPREQ_CFG; reg &= ~(SPC_LPREQ_CFG_LPREQOE_MASK | SPC_LPREQ_CFG_LPREQPOL_MASK | SPC_LPREQ_CFG_LPREQOV_MASK); if (config->enable) { reg |= SPC_LPREQ_CFG_LPREQOE_MASK | SPC_LPREQ_CFG_LPREQPOL((uint8_t)(config->polarity)) | SPC_LPREQ_CFG_LPREQOV((uint8_t)(config->override)); } else { reg &= ~SPC_LPREQ_CFG_LPREQOE_MASK; } base->LPREQ_CFG = reg; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* 0, if the attempt succeeded and the file turned out not to be a directory. */
int test_for_directory(const char *path)
/* 0, if the attempt succeeded and the file turned out not to be a directory. */ int test_for_directory(const char *path)
{ ws_statb64 statb; if (ws_stat64(path, &statb) < 0) return errno; if (S_ISDIR(statb.st_mode)) return EISDIR; else return 0; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This function adds the local private key (DER-encoded or PEM-encoded or PKCS#8 private key) into the specified TLS object for TLS negotiation. */
EFI_STATUS EFIAPI TlsSetHostPrivateKeyEx(IN VOID *Tls, IN VOID *Data, IN UINTN DataSize, IN VOID *Password OPTIONAL)
/* This function adds the local private key (DER-encoded or PEM-encoded or PKCS#8 private key) into the specified TLS object for TLS negotiation. */ EFI_STATUS EFIAPI TlsSetHostPrivateKeyEx(IN VOID *Tls, IN VOID *Data, IN UINTN DataSize, IN VOID *Password OPTIONAL)
{ CALL_CRYPTO_SERVICE (TlsSetHostPrivateKeyEx, (Tls, Data, DataSize, Password), EFI_UNSUPPORTED); }
tianocore/edk2
C++
Other
4,240
/* If BufferSize is 0 or 1, then the output buffer is unmodified and 0 is returned. */
UINTN EFIAPI UnicodeSPrint(OUT CHAR16 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR16 *FormatString,...)
/* If BufferSize is 0 or 1, then the output buffer is unmodified and 0 is returned. */ UINTN EFIAPI UnicodeSPrint(OUT CHAR16 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR16 *FormatString,...)
{ VA_LIST Marker; UINTN NumberOfPrinted; VA_START (Marker, FormatString); NumberOfPrinted = UnicodeVSPrint (StartOfBuffer, BufferSize, FormatString, Marker); VA_END (Marker); return NumberOfPrinted; }
tianocore/edk2
C++
Other
4,240
/* Returns: TRUE if @drive has media, FALSE otherwise. */
gboolean g_drive_has_media(GDrive *drive)
/* Returns: TRUE if @drive has media, FALSE otherwise. */ gboolean g_drive_has_media(GDrive *drive)
{ GDriveIface *iface; g_return_val_if_fail (G_IS_DRIVE (drive), FALSE); iface = G_DRIVE_GET_IFACE (drive); return (* iface->has_media) (drive); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* CCID_UpdateCommandStatus Updates the variable for the BulkIn status. */
static void CCID_UpdateCommandStatus(USBD_HandleTypeDef *pdev, uint8_t cmd_status, uint8_t icc_status)
/* CCID_UpdateCommandStatus Updates the variable for the BulkIn status. */ static void CCID_UpdateCommandStatus(USBD_HandleTypeDef *pdev, uint8_t cmd_status, uint8_t icc_status)
{ USBD_CCID_HandleTypeDef *hccid = (USBD_CCID_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId]; hccid->UsbBlkInData.bStatus = (cmd_status | icc_status); }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* STUSB1602 checks the VBUS_SRC_State (EN or DIS) (bit0 0x27 */
VBUS_SRC_State_TypeDef STUSB1602_VBUS_SRC_State_Get(uint8_t Addr)
/* STUSB1602 checks the VBUS_SRC_State (EN or DIS) (bit0 0x27 */ VBUS_SRC_State_TypeDef STUSB1602_VBUS_SRC_State_Get(uint8_t Addr)
{ STUSB1602_VBUS_ENABLE_STATUS_RegTypeDef reg; STUSB1602_ReadReg(&reg.d8, Addr, STUSB1602_VBUS_ENABLE_STATUS_REG, 1); return (VBUS_SRC_State_TypeDef)(reg.b.VBUS_SOURCE_EN); }
st-one/X-CUBE-USB-PD
C++
null
110
/* Measure and log an action string, and extend the measurement result into PCR. */
EFI_STATUS TcgMeasureAction(IN TPM_PCRINDEX PCRIndex, IN CHAR8 *String)
/* Measure and log an action string, and extend the measurement result into PCR. */ EFI_STATUS TcgMeasureAction(IN TPM_PCRINDEX PCRIndex, IN CHAR8 *String)
{ TCG_PCR_EVENT_HDR TcgEvent; TcgEvent.PCRIndex = PCRIndex; TcgEvent.EventType = EV_EFI_ACTION; TcgEvent.EventSize = (UINT32)AsciiStrLen (String); return TcgDxeHashLogExtendEvent ( 0, (UINT8 *)String, TcgEvent.EventSize, &TcgEvent, (UINT8 *)String ); }
tianocore/edk2
C++
Other
4,240
/* Output: void, will modify proto_tree if not null. */
static void dissect_lsp_ipv6_int_addr_clv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int id_length _U_, int length)
/* Output: void, will modify proto_tree if not null. */ static void dissect_lsp_ipv6_int_addr_clv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int id_length _U_, int length)
{ isis_dissect_ipv6_int_clv(tree, pinfo, tvb, &ei_isis_lsp_short_packet, offset, length, hf_isis_lsp_clv_ipv6_int_addr ); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Enables or disables the specified SPI peripheral (in I2S mode). */
void I2S_Cmd(SPI_TypeDef *SPIx, FunctionalState NewState)
/* Enables or disables the specified SPI peripheral (in I2S mode). */ void I2S_Cmd(SPI_TypeDef *SPIx, FunctionalState NewState)
{ assert_param(IS_SPI_1_PERIPH(SPIx)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { SPIx->I2SCFGR |= SPI_I2SCFGR_I2SE; } else { SPIx->I2SCFGR &= (uint16_t)~((uint16_t)SPI_I2SCFGR_I2SE); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* ADC Set the Injected Channel Data Offset. This value is subtracted from the injected channel results after conversion is complete, and can result in negative results. A separate value can be specified for each injected data register. */
void adc_set_injected_offset(uint32_t adc, uint8_t reg, uint32_t offset)
/* ADC Set the Injected Channel Data Offset. This value is subtracted from the injected channel results after conversion is complete, and can result in negative results. A separate value can be specified for each injected data register. */ void adc_set_injected_offset(uint32_t adc, uint8_t reg, uint32_t offset)
{ switch (reg) { case 1: ADC_JOFR1(adc) = offset; break; case 2: ADC_JOFR2(adc) = offset; break; case 3: ADC_JOFR3(adc) = offset; break; case 4: ADC_JOFR4(adc) = offset; break; } }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* END OF "GENERIC" DECODE ROUTINES. Decode OPEN_DOWNGRADE response */
static int nfs4_xdr_dec_open_downgrade(struct rpc_rqst *rqstp, __be32 *p, struct nfs_closeres *res)
/* END OF "GENERIC" DECODE ROUTINES. Decode OPEN_DOWNGRADE response */ static int nfs4_xdr_dec_open_downgrade(struct rpc_rqst *rqstp, __be32 *p, struct nfs_closeres *res)
{ struct xdr_stream xdr; struct compound_hdr hdr; int status; xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); status = decode_compound_hdr(&xdr, &hdr); if (status) goto out; status = decode_sequence(&xdr, &res->seq_res, rqstp); if (status) goto out; status = decode_putfh(&xdr); if (status) goto out; status = decode_open_downgrade(&xdr, res); if (status != 0) goto out; decode_getfattr(&xdr, res->fattr, res->server, !RPC_IS_ASYNC(rqstp->rq_task)); out: return status; }
robutest/uclinux
C++
GPL-2.0
60
/* Returns the number of bytes received on success, or else the status code returned by the underlying usb_control_msg() call. */
int usb_get_device_descriptor(struct usb_device *dev, unsigned int size)
/* Returns the number of bytes received on success, or else the status code returned by the underlying usb_control_msg() call. */ int usb_get_device_descriptor(struct usb_device *dev, unsigned int size)
{ struct usb_device_descriptor *desc; int ret; if (size > sizeof(*desc)) return -EINVAL; desc = kmalloc(sizeof(*desc), GFP_NOIO); if (!desc) return -ENOMEM; ret = usb_get_descriptor(dev, USB_DT_DEVICE, 0, desc, size); if (ret >= 0) memcpy(&dev->descriptor, desc, size); kfree(desc); return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* Returns a pointer to the data referenced from this link */
void* xmlLinkGetData(xmlLinkPtr lk)
/* Returns a pointer to the data referenced from this link */ void* xmlLinkGetData(xmlLinkPtr lk)
{ if (lk == NULL) return(NULL); return lk->data; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Manages the sleep mode following the USB state. */
static void uhd_sleep_mode(enum uhd_usb_state_enum new_state)
/* Manages the sleep mode following the USB state. */ static void uhd_sleep_mode(enum uhd_usb_state_enum new_state)
{ if (uhd_state == new_state) { return; } if (new_state != UHD_STATE_OFF) { sleepmgr_lock_mode(sleep_mode[new_state]); } if (uhd_state != UHD_STATE_OFF) { sleepmgr_unlock_mode(sleep_mode[uhd_state]); } uhd_state = new_state; }
memfault/zero-to-main
C++
null
200
/* Clear FCM state, Clear FCM overflow, complete, error flag. */
void FCM_ClearStatus(uint32_t u32Flag)
/* Clear FCM state, Clear FCM overflow, complete, error flag. */ void FCM_ClearStatus(uint32_t u32Flag)
{ DDL_ASSERT(IS_FCM_FLAG(u32Flag)); SET_REG32_BIT(CM_FCM->CLR, u32Flag); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* return The current count for the fast clock. */
uint16_t CLOCK_OSC_GetCurrentOscRc400MFastClockCount(void)
/* return The current count for the fast clock. */ uint16_t CLOCK_OSC_GetCurrentOscRc400MFastClockCount(void)
{ uint32_t tmp32; tmp32 = ANATOP_AI_Read(kAI_Itf_400m, kAI_RCOSC400M_STAT1); return (uint16_t)((tmp32 & AI_RCOSC400M_STAT1_CURR_COUNT_VAL_MASK) >> AI_RCOSC400M_STAT1_CURR_COUNT_VAL_SHIFT); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns a negative error number on failure, or the number of bytes used / required on success. */
int ext4_xattr_get(struct inode *inode, int name_index, const char *name, void *buffer, size_t buffer_size)
/* Returns a negative error number on failure, or the number of bytes used / required on success. */ int ext4_xattr_get(struct inode *inode, int name_index, const char *name, void *buffer, size_t buffer_size)
{ int error; down_read(&EXT4_I(inode)->xattr_sem); error = ext4_xattr_ibody_get(inode, name_index, name, buffer, buffer_size); if (error == -ENODATA) error = ext4_xattr_block_get(inode, name_index, name, buffer, buffer_size); up_read(&EXT4_I(inode)->xattr_sem); return error; }
robutest/uclinux
C++
GPL-2.0
60
/* If Length > 0 and Destination is NULL, then ASSERT(). If Length > 0 and Source is NULL, then ASSERT(). If PcdMaximumAsciiStringLength is not zero and String contains more than PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator, then ASSERT(). */
UINTN EFIAPI AsciiStrLen(IN CONST CHAR8 *String)
/* If Length > 0 and Destination is NULL, then ASSERT(). If Length > 0 and Source is NULL, then ASSERT(). If PcdMaximumAsciiStringLength is not zero and String contains more than PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator, then ASSERT(). */ UINTN EFIAPI AsciiStrLen(IN CONST CHAR8 *String)
{ UINTN Length; ASSERT (String != NULL); for (Length = 0; *String != '\0'; String++, Length++) { if (PcdGet32 (PcdMaximumAsciiStringLength) != 0) { ASSERT (Length < PcdGet32 (PcdMaximumAsciiStringLength)); } } return Length; }
tianocore/edk2
C++
Other
4,240
/* If Address > 0x0FFFFFFF, then ASSERT(). If the register specified by Address >= 0x100, then ASSERT(). */
UINT8 EFIAPI PciCf8Write8(IN UINTN Address, IN UINT8 Value)
/* If Address > 0x0FFFFFFF, then ASSERT(). If the register specified by Address >= 0x100, then ASSERT(). */ UINT8 EFIAPI PciCf8Write8(IN UINTN Address, IN UINT8 Value)
{ BOOLEAN InterruptState; UINT32 AddressPort; UINT8 Result; ASSERT_INVALID_PCI_ADDRESS (Address, 0); InterruptState = SaveAndDisableInterrupts (); AddressPort = IoRead32 (PCI_CONFIGURATION_ADDRESS_PORT); IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); Result = IoWrite8 ( PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3), Value ); IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, AddressPort); SetInterruptState (InterruptState); return Result; }
tianocore/edk2
C++
Other
4,240
/* If the specified subchannel is running in transport-mode, perform the interrogate function. Return zero on success, non-zero otherwie. */
int cio_tm_intrg(struct subchannel *sch)
/* If the specified subchannel is running in transport-mode, perform the interrogate function. Return zero on success, non-zero otherwie. */ int cio_tm_intrg(struct subchannel *sch)
{ int cc; if (!to_io_private(sch)->orb.tm.b) return -EINVAL; cc = xsch(sch->schid); switch (cc) { case 0: case 2: return 0; case 1: return -EBUSY; default: return -ENODEV; } }
robutest/uclinux
C++
GPL-2.0
60
/* Send SEND_CSD command to get CSD from card. */
static status_t MMC_SendCsd(mmc_card_t *card)
/* Send SEND_CSD command to get CSD from card. */ static status_t MMC_SendCsd(mmc_card_t *card)
{ assert(card); assert(card->host.transfer); HOST_COMMAND command = {0}; HOST_TRANSFER content = {0}; command.index = kSDMMC_SendCsd; command.argument = (card->relativeAddress << 16U); command.responseType = kCARD_ResponseTypeR2; content.command = &command; content.data = 0U; if (kStatus_Success == card->host.transfer(card->host.base, &content)) { memcpy(card->rawCsd, command.response, sizeof(card->rawCsd)); MMC_DecodeCsd(card, card->rawCsd); return kStatus_Success; } return kStatus_SDMMC_TransferFailed; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Calculate the number of bytes used to store the indicated attribute (whether local or remote only calculate bytes in this block). */
STATIC int xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index)
/* Calculate the number of bytes used to store the indicated attribute (whether local or remote only calculate bytes in this block). */ STATIC int xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index)
{ xfs_attr_leaf_name_local_t *name_loc; xfs_attr_leaf_name_remote_t *name_rmt; int size; ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); if (leaf->entries[index].flags & XFS_ATTR_LOCAL) { name_loc = xfs_attr_leaf_name_local(leaf, index); size = xfs_attr_leaf_entsize_local(name_loc->namelen, be16_to_cpu(name_loc->valuelen)); } else { name_rmt = xfs_attr_leaf_name_remote(leaf, index); size = xfs_attr_leaf_entsize_remote(name_rmt->namelen); } return(size); }
robutest/uclinux
C++
GPL-2.0
60
/* g e t O b j V a l */
real_t QProblemB_getObjVal(QProblemB *_THIS)
/* g e t O b j V a l */ real_t QProblemB_getObjVal(QProblemB *_THIS)
{ real_t objVal; if ( ( QProblemB_getStatus( _THIS ) == QPS_AUXILIARYQPSOLVED ) || ( QProblemB_getStatus( _THIS ) == QPS_HOMOTOPYQPSOLVED ) || ( QProblemB_getStatus( _THIS ) == QPS_SOLVED ) ) { objVal = QProblemB_getObjValX( _THIS,_THIS->x ); } else { objVal = QPOASES_INFTY; } return objVal; }
DanielMartensson/EmbeddedLapack
C++
MIT License
129
/* Generates a breakpoint on the CPU. The breakpoint must be implemented such that code can resume normal execution after the breakpoint. */
VOID EFIAPI CpuBreakpoint(VOID)
/* Generates a breakpoint on the CPU. The breakpoint must be implemented such that code can resume normal execution after the breakpoint. */ VOID EFIAPI CpuBreakpoint(VOID)
{ __asm__ __volatile__ ("int $3"); }
tianocore/edk2
C++
Other
4,240
/* this api is used to read the fifo status of frame_counter and overrun in the register 0x0E */
BMG160_RETURN_FUNCTION_TYPE bmg160_get_fifo_stat_reg(u8 *v_fifo_stat_u8)
/* this api is used to read the fifo status of frame_counter and overrun in the register 0x0E */ BMG160_RETURN_FUNCTION_TYPE bmg160_get_fifo_stat_reg(u8 *v_fifo_stat_u8)
{ BMG160_RETURN_FUNCTION_TYPE comres = ERROR; u8 v_data_u8 = BMG160_INIT_VALUE; if (p_bmg160 == BMG160_NULL) { return E_BMG160_NULL_PTR; } else { comres = p_bmg160->BMG160_BUS_READ_FUNC(p_bmg160->dev_addr, BMG160_FIFO_STAT_ADDR, &v_data_u8, BMG160_GEN_READ_WRITE_DATA_LENGTH); *v_fifo_stat_u8 = v_data_u8; } return comres; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Look up a hostname in the array of known hostnames. */
u16_t* resolv_lookup(char *name)
/* Look up a hostname in the array of known hostnames. */ u16_t* resolv_lookup(char *name)
{ static u8_t i; struct namemap *nameptr; for (i = 0; i < RESOLV_ENTRIES; ++i) { nameptr = &names[i]; if (nameptr->state == STATE_DONE && strcmp(name, nameptr->name) == 0) { return nameptr->ipaddr; } } return NULL; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Wait for the RSTDONE bit to get set, or a one-second timeout. */
static void wait_for_rstdone(unsigned int bank)
/* Wait for the RSTDONE bit to get set, or a one-second timeout. */ static void wait_for_rstdone(unsigned int bank)
{ serdes_corenet_t *srds_regs = (void *)CONFIG_SYS_FSL_CORENET_SERDES_ADDR; unsigned long long end_tick; u32 rstctl; end_tick = usec2ticks(1000000) + get_ticks(); do { rstctl = in_be32(&srds_regs->bank[bank].rstctl); if (rstctl & SRDS_RSTCTL_RSTDONE) break; } while (end_tick > get_ticks()); if (!(rstctl & SRDS_RSTCTL_RSTDONE)) printf("SERDES: timeout resetting bank %u\n", bank + 1); }
4ms/stm32mp1-baremetal
C++
Other
137
/* rpc_remove_client_dir - Remove a directory created with rpc_create_client_dir() @dentry: directory to remove */
int rpc_remove_client_dir(struct dentry *dentry)
/* rpc_remove_client_dir - Remove a directory created with rpc_create_client_dir() @dentry: directory to remove */ int rpc_remove_client_dir(struct dentry *dentry)
{ return rpc_rmdir_depopulate(dentry, rpc_clntdir_depopulate); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Calculate square modulo. Please note, all "out" Big number arguments should be properly initialized by calling to BigNumInit() or BigNumFromBin() functions. */
BOOLEAN EFIAPI CryptoServiceBigNumSqrMod(IN CONST VOID *BnA, IN CONST VOID *BnM, OUT VOID *BnRes)
/* Calculate square modulo. Please note, all "out" Big number arguments should be properly initialized by calling to BigNumInit() or BigNumFromBin() functions. */ BOOLEAN EFIAPI CryptoServiceBigNumSqrMod(IN CONST VOID *BnA, IN CONST VOID *BnM, OUT VOID *BnRes)
{ return CALL_BASECRYPTLIB (Bn.Services.SqrMod, BigNumSqrMod, (BnA, BnM, BnRes), FALSE); }
tianocore/edk2
C++
Other
4,240
/* Get the length of TXT item's key name. */
static int _mdns_txt_item_name_get_len(const uint8_t *data, size_t len)
/* Get the length of TXT item's key name. */ static int _mdns_txt_item_name_get_len(const uint8_t *data, size_t len)
{ int i; if (*data == '=') { return -1; } for (i = 0; i < len; i++) { if (data[i] == '=') { return i; } } return len; }
retro-esp32/RetroESP32
C++
Creative Commons Attribution Share Alike 4.0 International
581
/* returns 0 on success, else error. side-effect: pci_dev->driver is set to drv when drv claims pci_dev. */
static int __pci_device_probe(struct pci_driver *drv, struct pci_dev *pci_dev)
/* returns 0 on success, else error. side-effect: pci_dev->driver is set to drv when drv claims pci_dev. */ static int __pci_device_probe(struct pci_driver *drv, struct pci_dev *pci_dev)
{ const struct pci_device_id *id; int error = 0; if (!pci_dev->driver && drv->probe) { error = -ENODEV; id = pci_match_device(drv, pci_dev); if (id) error = pci_call_probe(drv, pci_dev, id); if (error >= 0) { pci_dev->driver = drv; error = 0; } } return error; }
robutest/uclinux
C++
GPL-2.0
60
/* Caller should check returned pointer with dm_target_is_valid() to trap I/O beyond end of device. */
struct dm_target* dm_table_find_target(struct dm_table *t, sector_t sector)
/* Caller should check returned pointer with dm_target_is_valid() to trap I/O beyond end of device. */ struct dm_target* dm_table_find_target(struct dm_table *t, sector_t sector)
{ unsigned int l, n = 0, k = 0; sector_t *node; for (l = 0; l < t->depth; l++) { n = get_child(n, k); node = get_node(t, l, n); for (k = 0; k < KEYS_PER_NODE; k++) if (node[k] >= sector) break; } return &t->targets[(KEYS_PER_NODE * n) + k]; }
robutest/uclinux
C++
GPL-2.0
60
/* This function validates the length coded on 4 bytes of a shared memory range */
STATIC VOID EFIAPI ValidateRangeLength4(IN UINT8 *Ptr, IN VOID *Context)
/* This function validates the length coded on 4 bytes of a shared memory range */ STATIC VOID EFIAPI ValidateRangeLength4(IN UINT8 *Ptr, IN VOID *Context)
{ if (*(UINT32 *)Ptr < MIN_EXT_PCC_SUBSPACE_MEM_RANGE_LEN) { IncrementErrorCount (); Print ( L"\nError: Shared memory range length is too short.\n" L"Length is %u when it should be greater than or equal to %u", *(UINT32 *)Ptr, MIN_EXT_PCC_SUBSPACE_MEM_RANGE_LEN ); } }
tianocore/edk2
C++
Other
4,240
/* Calls a discover-service-by-uuid proc's callback with the specified parameters. If the proc has no callback, this function is a no-op. */
static int ble_gattc_disc_svc_uuid_cb(struct ble_gattc_proc *proc, int status, uint16_t att_handle, struct ble_gatt_svc *service)
/* Calls a discover-service-by-uuid proc's callback with the specified parameters. If the proc has no callback, this function is a no-op. */ static int ble_gattc_disc_svc_uuid_cb(struct ble_gattc_proc *proc, int status, uint16_t att_handle, struct ble_gatt_svc *service)
{ int rc; BLE_HS_DBG_ASSERT(!ble_hs_locked_by_cur_task()); BLE_HS_DBG_ASSERT(service != NULL || status != 0); ble_gattc_dbg_assert_proc_not_inserted(proc); if (status != 0 && status != BLE_HS_EDONE) { STATS_INC(ble_gattc_stats, disc_svc_uuid_fail); } if (proc->disc_svc_uuid.cb == NULL) { rc = 0; } else { rc = proc->disc_svc_uuid.cb(proc->conn_handle, ble_gattc_error(status, att_handle), service, proc->disc_svc_uuid.cb_arg); } return rc; }
Nicholas3388/LuaNode
C++
Other
1,055
/* Read data from simulated EEPROM. Function uses TWI interface to read data from EEPROM memory. */
static ret_code_t eeprom_read(size_t addr, uint8_t *pdata, size_t size)
/* Read data from simulated EEPROM. Function uses TWI interface to read data from EEPROM memory. */ static ret_code_t eeprom_read(size_t addr, uint8_t *pdata, size_t size)
{ ret_code_t ret; if (size > (EEPROM_SIM_SIZE)) { return NRF_ERROR_INVALID_LENGTH; } do { uint8_t addr8 = (uint8_t)addr; ret = nrf_drv_twi_tx(&m_twi_master, EEPROM_SIM_ADDR, &addr8, 1, true); if (NRF_SUCCESS != ret) { break; } ret = nrf_drv_twi_rx(&m_twi_master, EEPROM_SIM_ADDR, pdata, size); }while (0); return ret; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Get the CLI commands and correlate them to functions. */
int32_t cn0414_find_command(struct cn0414_dev *dev, uint8_t *command, cmd_func *function)
/* Get the CLI commands and correlate them to functions. */ int32_t cn0414_find_command(struct cn0414_dev *dev, uint8_t *command, cmd_func *function)
{ uint8_t i = 0; while (v_cmd_fun[i/2] != NULL) { if(strncmp((char *)command, (char *)cmd_commands[i], command_size[i]) == 0 || strncmp((char *)command, (char *)cmd_commands[i + 1], command_size[i+1]) == 0) { if(command_size == 0) break; *function = v_cmd_fun[i / 2]; break; } i += 2; } return 0; }
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* If 32-bit I/O port operations are not supported, then ASSERT(). If Port is not aligned on a 32-bit boundary, then ASSERT(). */
UINT32 EFIAPI IoAndThenOr32(IN UINTN Port, IN UINT32 AndData, IN UINT32 OrData)
/* If 32-bit I/O port operations are not supported, then ASSERT(). If Port is not aligned on a 32-bit boundary, then ASSERT(). */ UINT32 EFIAPI IoAndThenOr32(IN UINTN Port, IN UINT32 AndData, IN UINT32 OrData)
{ return IoWrite32 (Port, (IoRead32 (Port) & AndData) | OrData); }
tianocore/edk2
C++
Other
4,240
/* Slave 0 write operation is performed only at the first sensor hub cycle.. */
int32_t lsm6dso_sh_write_mode_set(stmdev_ctx_t *ctx, lsm6dso_write_once_t val)
/* Slave 0 write operation is performed only at the first sensor hub cycle.. */ int32_t lsm6dso_sh_write_mode_set(stmdev_ctx_t *ctx, lsm6dso_write_once_t val)
{ lsm6dso_master_config_t reg; int32_t ret; ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK); if (ret == 0) { ret = lsm6dso_read_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t *)&reg, 1); } if (ret == 0) { reg.write_once = (uint8_t)val; ret = lsm6dso_write_reg(ctx, LSM6DSO_MASTER_CONFIG, (uint8_t *)&reg, 1); } if (ret == 0) { ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK); } return ret; }
eclipse-threadx/getting-started
C++
Other
310
/* Set the frame address of the graphics layer. */
STATIC VOID LayerGraphicsSetFrame(IN CONST EFI_PHYSICAL_ADDRESS FrameBaseAddress)
/* Set the frame address of the graphics layer. */ STATIC VOID LayerGraphicsSetFrame(IN CONST EFI_PHYSICAL_ADDRESS FrameBaseAddress)
{ LayerGraphicsDisable (); MmioWrite32 ( DP_BASE + DP_DE_LG_PTR_LOW, DP_DE_LG_PTR_LOW_MASK & FrameBaseAddress ); MmioWrite32 ( DP_BASE + DP_DE_LG_PTR_HIGH, (UINT32)(FrameBaseAddress >> DP_DE_LG_PTR_HIGH_SHIFT) ); LayerGraphicsEnable (); }
tianocore/edk2
C++
Other
4,240
/* DeviceCommunicationControl-Request ::= SEQUENCE { timeDuration Unsigned16 OPTIONAL, enable-disable ENUMERATED { enable (0), disable (1) }, password CharacterString (SIZE(1..20)) OPTIONAL } */
static guint fDeviceCommunicationControlRequest(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
/* DeviceCommunicationControl-Request ::= SEQUENCE { timeDuration Unsigned16 OPTIONAL, enable-disable ENUMERATED { enable (0), disable (1) }, password CharacterString (SIZE(1..20)) OPTIONAL } */ static guint fDeviceCommunicationControlRequest(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 = fUnsignedTag(tvb, pinfo, tree, offset, "time Duration: "); break; case 1: offset = fEnumeratedTag(tvb, pinfo, tree, offset, "enable-disable: ", BACnetEnableDisable); break; case 2: offset = fCharacterString(tvb, pinfo, tree, offset, "Password: "); break; default: return offset; } if (offset == lastoffset) break; } return offset; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Check for a pattern at the given place. Used to search bad block tables and good / bad block identifiers. Same as check_pattern, but no optional empty check */
static int check_short_pattern(uint8_t *buf, struct nand_bbt_descr *td)
/* Check for a pattern at the given place. Used to search bad block tables and good / bad block identifiers. Same as check_pattern, but no optional empty check */ static int check_short_pattern(uint8_t *buf, struct nand_bbt_descr *td)
{ int i; uint8_t *p = buf; for (i = 0; i < td->len; i++) { if (p[td->offs + i] != td->pattern[i]) return -1; } if (td->options & NAND_BBT_SCANBYTE1AND6) { for (i = 0; i < td->len; i++) { if (p[NAND_SMALL_BADBLOCK_POS + i] != td->pattern[i]) return -1; } } return 0; }
EmcraftSystems/u-boot
C++
Other
181
/* Enables ADC, starts conversion of normal group with interruption. Interruptions enabled in this function: */
ald_status_t ald_adc_normal_start_by_it(ald_adc_handle_t *hperh)
/* Enables ADC, starts conversion of normal group with interruption. Interruptions enabled in this function: */ ald_status_t ald_adc_normal_start_by_it(ald_adc_handle_t *hperh)
{ assert_param(IS_ADC_TYPE(hperh->perh)); SET_BIT(hperh->state, ALD_ADC_STATE_BUSY_N); ALD_ADC_ENABLE(hperh); WRITE_REG(hperh->perh->CLR, ALD_ADC_FLAG_NCH); ald_adc_interrupt_config(hperh, ALD_ADC_IT_NCH, ENABLE); SET_BIT(hperh->perh->CON1, ADC_CON1_NCHTRG_MSK); return ALD_OK; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* NULL JSON value is kept as static value, and no need to do any cleanup work. */
EDKII_JSON_VALUE EFIAPI JsonValueInitFalse(VOID)
/* NULL JSON value is kept as static value, and no need to do any cleanup work. */ EDKII_JSON_VALUE EFIAPI JsonValueInitFalse(VOID)
{ return (EDKII_JSON_VALUE)json_false (); }
tianocore/edk2
C++
Other
4,240
/* Transmits the address byte to select the slave device. */
void I2C_Tx7BitAddress(I2C_T *i2c, uint8_t address, I2C_DIRECTION_T direction)
/* Transmits the address byte to select the slave device. */ void I2C_Tx7BitAddress(I2C_T *i2c, uint8_t address, I2C_DIRECTION_T direction)
{ if(direction != I2C_DIRECTION_TX) { i2c->DATA_B.DATA = address | 0x0001; } else { i2c->DATA_B.DATA = address & 0xFFFE; } }
pikasTech/PikaPython
C++
MIT License
1,403
/* The convention within GIO is that cancelling an asynchronous operation causes it to complete asynchronously. That is, if you cancel the operation from the same thread in which it is running, then the operation's #GAsyncReadyCallback will not be invoked until the application returns to the main loop. */
void g_cancellable_cancel(GCancellable *cancellable)
/* The convention within GIO is that cancelling an asynchronous operation causes it to complete asynchronously. That is, if you cancel the operation from the same thread in which it is running, then the operation's #GAsyncReadyCallback will not be invoked until the application returns to the main loop. */ void g_cancellable_cancel(GCancellable *cancellable)
{ GCancellablePrivate *priv; if (cancellable == NULL || cancellable->priv->cancelled) return; priv = cancellable->priv; g_mutex_lock (&cancellable_mutex); if (priv->cancelled) { g_mutex_unlock (&cancellable_mutex); return; } priv->cancelled = TRUE; priv->cancelled_running = TRUE; if (priv->wakeup) GLIB_PRIVATE_CALL (g_wakeup_signal) (priv->wakeup); g_mutex_unlock (&cancellable_mutex); g_object_ref (cancellable); g_signal_emit (cancellable, signals[CANCELLED], 0); g_mutex_lock (&cancellable_mutex); priv->cancelled_running = FALSE; if (priv->cancelled_running_waiting) g_cond_broadcast (&cancellable_cond); priv->cancelled_running_waiting = FALSE; g_mutex_unlock (&cancellable_mutex); g_object_unref (cancellable); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Set the LSM security ID in a set of credentials so that the subjective security is overridden when an alternative set of credentials is used. */
int set_security_override(struct cred *new, u32 secid)
/* Set the LSM security ID in a set of credentials so that the subjective security is overridden when an alternative set of credentials is used. */ int set_security_override(struct cred *new, u32 secid)
{ return security_kernel_act_as(new, secid); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* param base ENET peripheral base address. param srcClock_Hz This is the ENET module clock frequency. Normally it's the system clock. See clock distribution. param isPreambleDisabled The preamble disable flag. */
void ENET_SetSMI(ENET_Type *base, uint32_t srcClock_Hz, bool isPreambleDisabled)
/* param base ENET peripheral base address. param srcClock_Hz This is the ENET module clock frequency. Normally it's the system clock. See clock distribution. param isPreambleDisabled The preamble disable flag. */ void ENET_SetSMI(ENET_Type *base, uint32_t srcClock_Hz, bool isPreambleDisabled)
{ assert((srcClock_Hz / (2U * ENET_MDC_FREQUENCY)) != 0U); uint32_t clkCycle = 0; uint32_t speed = 0; uint32_t mscr = 0; speed = srcClock_Hz / (2U * ENET_MDC_FREQUENCY) - 1U; clkCycle = (10U + ENET_NANOSECOND_ONE_SECOND / srcClock_Hz - 1U) / (ENET_NANOSECOND_ONE_SECOND / srcClock_Hz) - 1U; mscr = ENET_MSCR_MII_SPEED(speed) | ENET_MSCR_HOLDTIME(clkCycle) | (isPreambleDisabled ? ENET_MSCR_DIS_PRE_MASK : 0U); base->MSCR = mscr; }
eclipse-threadx/getting-started
C++
Other
310
/* Shutdown the SSI if there are no other substreams open. */
static void fsl_ssi_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai)
/* Shutdown the SSI if there are no other substreams open. */ static void fsl_ssi_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai)
{ struct snd_soc_pcm_runtime *rtd = substream->private_data; struct fsl_ssi_private *ssi_private = rtd->dai->cpu_dai->private_data; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ssi_private->playback--; if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) ssi_private->capture--; if (ssi_private->first_stream == substream) ssi_private->first_stream = ssi_private->second_stream; ssi_private->second_stream = NULL; if (!ssi_private->playback && !ssi_private->capture) { struct ccsr_ssi __iomem *ssi = ssi_private->ssi; clrbits32(&ssi->scr, CCSR_SSI_SCR_SSIEN); free_irq(ssi_private->irq, ssi_private); } }
robutest/uclinux
C++
GPL-2.0
60
/* param base Pointer to the FLEXIO_UART_Type structure. param handle Pointer to the flexio_uart_handle_t structure to store the transfer state. param xfer FlexIO UART transfer structure. See #flexio_uart_transfer_t. retval kStatus_Success Successfully starts the data transmission. retval kStatus_UART_TxBusy Previous transmission still not finished, data not written to the TX register. */
status_t FLEXIO_UART_TransferSendNonBlocking(FLEXIO_UART_Type *base, flexio_uart_handle_t *handle, flexio_uart_transfer_t *xfer)
/* param base Pointer to the FLEXIO_UART_Type structure. param handle Pointer to the flexio_uart_handle_t structure to store the transfer state. param xfer FlexIO UART transfer structure. See #flexio_uart_transfer_t. retval kStatus_Success Successfully starts the data transmission. retval kStatus_UART_TxBusy Previous transmission still not finished, data not written to the TX register. */ status_t FLEXIO_UART_TransferSendNonBlocking(FLEXIO_UART_Type *base, flexio_uart_handle_t *handle, flexio_uart_transfer_t *xfer)
{ status_t status; if ((0U == xfer->dataSize) || (NULL == xfer->txData)) { return kStatus_InvalidArgument; } if ((uint8_t)kFLEXIO_UART_TxBusy == handle->txState) { status = kStatus_FLEXIO_UART_TxBusy; } else { handle->txData = xfer->txData; handle->txDataSize = xfer->dataSize; handle->txDataSizeAll = xfer->dataSize; handle->txState = (uint8_t)kFLEXIO_UART_TxBusy; FLEXIO_UART_EnableInterrupts(base, (uint32_t)kFLEXIO_UART_TxDataRegEmptyInterruptEnable); status = kStatus_Success; } return status; }
eclipse-threadx/getting-started
C++
Other
310
/* The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on. */
void GPIOPinTypePWM(unsigned long ulPort, unsigned char ucPins)
/* The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on. */ void GPIOPinTypePWM(unsigned long ulPort, unsigned char ucPins)
{ ASSERT(GPIOBaseValid(ulPort)); GPIODirModeSet(ulPort, ucPins, GPIO_DIR_MODE_HW); GPIOPadConfigSet(ulPort, ucPins, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD); }
watterott/WebRadio
C++
null
71
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). If StartBit is greater than 31, then ASSERT(). If EndBit is greater than 31, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT32 EFIAPI PciExpressBitFieldAnd32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 AndData)
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). If StartBit is greater than 31, then ASSERT(). If EndBit is greater than 31, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */ UINT32 EFIAPI PciExpressBitFieldAnd32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 AndData)
{ if (Address >= mSmmPciExpressLibPciExpressBaseSize) { return (UINT32)-1; } return MmioBitFieldAnd32 ( GetPciExpressAddress (Address), StartBit, EndBit, AndData ); }
tianocore/edk2
C++
Other
4,240
/* This function get fault brake interrupt flag of selected source. */
uint32_t EPWM_GetFaultBrakeIntFlag(EPWM_T *epwm, uint32_t u32BrakeSource)
/* This function get fault brake interrupt flag of selected source. */ uint32_t EPWM_GetFaultBrakeIntFlag(EPWM_T *epwm, uint32_t u32BrakeSource)
{ return (((epwm)->INTSTS1 & (0x3fUL << u32BrakeSource)) ? 1UL : 0UL); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Enable the MAC Back Pressure operation activation (Half-duplex only). */
void ETH_EnableBackPressureActivation(void)
/* Enable the MAC Back Pressure operation activation (Half-duplex only). */ void ETH_EnableBackPressureActivation(void)
{ ETH->FCTRL_B.FCTRLB = SET; ETH_Delay(ETH_REG_WRITE_DELAY); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* gelic_net_open allocates all the descriptors and memory needed for operation, sets up multicast list and enables interrupts */
int gelic_net_open(struct net_device *netdev)
/* gelic_net_open allocates all the descriptors and memory needed for operation, sets up multicast list and enables interrupts */ int gelic_net_open(struct net_device *netdev)
{ struct gelic_card *card = netdev_card(netdev); dev_dbg(ctodev(card), " -> %s %p\n", __func__, netdev); gelic_card_up(card); netif_start_queue(netdev); gelic_card_get_ether_port_status(card, 1); dev_dbg(ctodev(card), " <- %s\n", __func__); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* param base eDMA peripheral base address. param channel edma channel number. param sourceOffset source address offset. param destOffset destination address offset. */
void EDMA_SetMajorOffsetConfig(DMA_Type *base, uint32_t channel, int32_t sourceOffset, int32_t destOffset)
/* param base eDMA peripheral base address. param channel edma channel number. param sourceOffset source address offset. param destOffset destination address offset. */ void EDMA_SetMajorOffsetConfig(DMA_Type *base, uint32_t channel, int32_t sourceOffset, int32_t destOffset)
{ assert(channel < (uint32_t)FSL_FEATURE_EDMA_MODULE_CHANNEL); base->TCD[channel].SLAST = sourceOffset; base->TCD[channel].DLAST_SGA = destOffset; }
eclipse-threadx/getting-started
C++
Other
310
/* This function returns the system boot mode information from the PHIT HOB in HOB list. */
EFI_STATUS EFIAPI SetBootMode(IN EFI_BOOT_MODE BootMode)
/* This function returns the system boot mode information from the PHIT HOB in HOB list. */ EFI_STATUS EFIAPI SetBootMode(IN EFI_BOOT_MODE BootMode)
{ EFI_PEI_HOB_POINTERS Hob; Hob.Raw = GetHobList (); Hob.HandoffInformationTable->BootMode = BootMode; return BootMode; }
tianocore/edk2
C++
Other
4,240