docstring
stringlengths
22
576
signature
stringlengths
9
317
prompt
stringlengths
57
886
code
stringlengths
20
1.36k
repository
stringclasses
49 values
language
stringclasses
2 values
license
stringclasses
9 values
stars
int64
15
21.3k
/* This routine is invoked to unset the PCI device memory space for device with SLI-4 interface spec. */
static void lpfc_sli4_pci_mem_unset(struct lpfc_hba *phba)
/* This routine is invoked to unset the PCI device memory space for device with SLI-4 interface spec. */ static void lpfc_sli4_pci_mem_unset(struct lpfc_hba *phba)
{ struct pci_dev *pdev; if (!phba->pcidev) return; else pdev = phba->pcidev; iounmap(phba->sli4_hba.drbl_regs_memmap_p); iounmap(phba->sli4_hba.ctrl_regs_memmap_p); iounmap(phba->sli4_hba.conf_regs_memmap_p); return; }
robutest/uclinux
C++
GPL-2.0
60
/* This function will copy the object pointer of the specified type, with the maximum size specified by maxlen. */
int rt_object_get_pointers(enum rt_object_class_type type, rt_object_t *pointers, int maxlen)
/* This function will copy the object pointer of the specified type, with the maximum size specified by maxlen. */ int rt_object_get_pointers(enum rt_object_class_type type, rt_object_t *pointers, int maxlen)
{ int index = 0; rt_ubase_t level; struct rt_object *object; struct rt_list_node *node = RT_NULL; struct rt_object_information *information = RT_NULL; if (maxlen <= 0) return 0; information = rt_object_get_information((enum rt_object_class_type)type); if (information == RT_NULL) return 0; level = rt_hw_interrupt_disable(); rt_list_for_each(node, &(information->object_list)) { object = rt_list_entry(node, struct rt_object, list); pointers[index] = object; index ++; if (index >= maxlen) break; } rt_hw_interrupt_enable(level); return index; }
pikasTech/PikaPython
C++
MIT License
1,403
/* __get_rx_machine_lock - lock the port's RX machine @port: the port we're looking at */
static void __get_rx_machine_lock(struct port *port)
/* __get_rx_machine_lock - lock the port's RX machine @port: the port we're looking at */ static void __get_rx_machine_lock(struct port *port)
{ spin_lock_bh(&(SLAVE_AD_INFO(port->slave).rx_machine_lock)); }
robutest/uclinux
C++
GPL-2.0
60
/* This is called after a frame of audio has been quantized and coded. It will write the encoded audio to the bitstream. Note that from a layer3 encoder's perspective the bit stream is primarily a series of main_data() blocks, with header and side information inserted at the proper locations to maintain framing. (See Figure A.7 in the IS). */
void shine_format_bitstream(shine_global_config *config)
/* This is called after a frame of audio has been quantized and coded. It will write the encoded audio to the bitstream. Note that from a layer3 encoder's perspective the bit stream is primarily a series of main_data() blocks, with header and side information inserted at the proper locations to maintain framing. (See Figure A.7 in the IS). */ void shine_format_bitstream(shine_global_config *config)
{ int *pi = &config->l3_enc[ch][gr][0]; int *pr = &config->mdct_freq[ch][gr][0]; for ( i = 0; i < GRANULE_SIZE; i++ ) { if ( (pr[i] < 0) && (pi[i] > 0) ) pi[i] *= -1; } } encodeSideInfo( config ); encodeMainData( config ); }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* Programs a half word at a specified Option Byte Data address. */
FLASH_STS FLASH_ProgramOBData(uint32_t Address, uint32_t Data)
/* Programs a half word at a specified Option Byte Data address. */ FLASH_STS FLASH_ProgramOBData(uint32_t Address, uint32_t Data)
{ FLASH_STS status = FLASH_COMPL; assert_param(IS_OB_DATA_ADDRESS(Address)); FLASH_ClearFlag(FLASH_STS_CLRFLAG); status = FLASH_WaitForLastOpt(ProgramTimeout); if (FLASH_GetReadOutProtectionL2STS() != RESET) { status = FLASH_ERR_RDP2; return status; } if (status == FLASH_COMPL) { FLASH->OPTKEY = FLASH_KEY1; FLASH->OPTKEY = FLASH_KEY2; FLASH->CTRL |= CTRL_Set_OPTPG; *(__IO uint32_t*)Address = (uint32_t)Data; status = FLASH_WaitForLastOpt(ProgramTimeout); if (status != FLASH_TIMEOUT) { FLASH->CTRL &= CTRL_Reset_OPTPG; } } return status; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Find Hii variable node by var store id. */
VAR_CHECK_HII_VARIABLE_NODE* FindHiiVariableNodeByVarStoreId(IN EFI_VARSTORE_ID VarStoreId)
/* Find Hii variable node by var store id. */ VAR_CHECK_HII_VARIABLE_NODE* FindHiiVariableNodeByVarStoreId(IN EFI_VARSTORE_ID VarStoreId)
{ VAR_CHECK_HII_VARIABLE_NODE *HiiVariableNode; LIST_ENTRY *Link; if (VarStoreId == 0) { return NULL; } for (Link = mVarCheckHiiList.ForwardLink ; Link != &mVarCheckHiiList ; Link = Link->ForwardLink) { HiiVariableNode = VAR_CHECK_HII_VARIABLE_FROM_LINK (Link); if (VarStoreId == HiiVariableNode->VarStoreId) { return HiiVariableNode; } } return NULL; }
tianocore/edk2
C++
Other
4,240
/* The heuristic below should work for all ACPI thermal zones which have a critical trip point with a value being a multiple of 0.5 degree Celsius. */
static void acpi_thermal_guess_offset(struct acpi_thermal *tz)
/* The heuristic below should work for all ACPI thermal zones which have a critical trip point with a value being a multiple of 0.5 degree Celsius. */ static void acpi_thermal_guess_offset(struct acpi_thermal *tz)
{ if (tz->trips.critical.flags.valid && (tz->trips.critical.temperature % 5) == 1) tz->kelvin_offset = 2731; else tz->kelvin_offset = 2732; }
robutest/uclinux
C++
GPL-2.0
60
/* The base library function returns an error equal to VC_EXCEPTION, to be propagated to the standard exception handling stack. */
EFI_STATUS EFIAPI CcExitHandleVc(IN OUT EFI_EXCEPTION_TYPE *ExceptionType, IN OUT EFI_SYSTEM_CONTEXT SystemContext)
/* The base library function returns an error equal to VC_EXCEPTION, to be propagated to the standard exception handling stack. */ EFI_STATUS EFIAPI CcExitHandleVc(IN OUT EFI_EXCEPTION_TYPE *ExceptionType, IN OUT EFI_SYSTEM_CONTEXT SystemContext)
{ *ExceptionType = VC_EXCEPTION; return EFI_UNSUPPORTED; }
tianocore/edk2
C++
Other
4,240
/* Cancel Connection. This API is used to cancel connection creation that is in process. */
ADI_BLER_RESULT adi_radio_CancelCreateConnection(void)
/* Cancel Connection. This API is used to cancel connection creation that is in process. */ ADI_BLER_RESULT adi_radio_CancelCreateConnection(void)
{ ADI_BLER_RESULT bleResult; ADI_BLE_LOGEVENT(LOGID_CMD_BLEGAP_CANCEL_CONNECTION); ADI_BLE_RADIO_CMD_START(CMD_BLEGAP_CANCEL_CONNECTION); bleResult = bler_process_cmd(CMD_BLEGAP_CANCEL_CONNECTION, 0u, NULL, 0u); if(bleResult == ADI_BLER_SUCCESS){ bleResult = ADI_BLE_WAIT_FOR_COMPLETION(ADI_EVENT_FLAG_EVENT_COMPLETE,ADI_BLER_CMD_TIMEOUT); } ADI_BLE_RADIO_CMD_END(); return (bleResult); }
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* Converts a text device path node to USB Image device path structure. */
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextUsbImage(CHAR16 *TextDeviceNode)
/* Converts a text device path node to USB Image device path structure. */ EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextUsbImage(CHAR16 *TextDeviceNode)
{ USB_CLASS_TEXT UsbClassText; UsbClassText.ClassExist = FALSE; UsbClassText.Class = USB_CLASS_IMAGE; UsbClassText.SubClassExist = TRUE; return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText); }
tianocore/edk2
C++
Other
4,240
/* requeue inode for re-scanning after bdi->b_io list is exhausted. */
static void requeue_io(struct inode *inode)
/* requeue inode for re-scanning after bdi->b_io list is exhausted. */ static void requeue_io(struct inode *inode)
{ struct bdi_writeback *wb = &inode_to_bdi(inode)->wb; list_move(&inode->i_list, &wb->b_more_io); }
robutest/uclinux
C++
GPL-2.0
60
/* Compute an ISS to be used by a new connection. */
TCP_SEQNO TcpGetIss(VOID)
/* Compute an ISS to be used by a new connection. */ TCP_SEQNO TcpGetIss(VOID)
{ mTcpGlobalIss += TCP_ISS_INCREMENT_1; return mTcpGlobalIss; }
tianocore/edk2
C++
Other
4,240
/* ISR to manage the reception of data from the serial port, placing received bytes into a circular buffer for later transmission to the host. */
ISR(USART1_RX_vect, ISR_BLOCK)
/* ISR to manage the reception of data from the serial port, placing received bytes into a circular buffer for later transmission to the host. */ ISR(USART1_RX_vect, ISR_BLOCK)
{ uint8_t ReceivedByte = UDR1; if (USB_DeviceState == DEVICE_STATE_Configured) RingBuffer_Insert(&USARTtoUSB_Buffer, ReceivedByte); }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* VPSR can't keep track of below bits of guest PSR This function gets guest PSR */
unsigned long vcpu_get_psr(struct kvm_vcpu *vcpu)
/* VPSR can't keep track of below bits of guest PSR This function gets guest PSR */ unsigned long vcpu_get_psr(struct kvm_vcpu *vcpu)
{ unsigned long mask; struct kvm_pt_regs *regs = vcpu_regs(vcpu); mask = IA64_PSR_BE | IA64_PSR_UP | IA64_PSR_AC | IA64_PSR_MFL | IA64_PSR_MFH | IA64_PSR_CPL | IA64_PSR_RI; return (VCPU(vcpu, vpsr) & ~mask) | (regs->cr_ipsr & mask); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Print the hexical QWORD raw index data to instruction content. */
UINTN EdbPrintRawIndexData64(IN UINT64 Data64)
/* Print the hexical QWORD raw index data to instruction content. */ UINTN EdbPrintRawIndexData64(IN UINT64 Data64)
{ BOOLEAN Sign; UINT64 NaturalUnits; UINT64 ConstantUnits; UINTN Offset; Sign = EdbGetNaturalIndex64 (Data64, &NaturalUnits, &ConstantUnits); Offset = EdbPrintIndexData64 (Sign, NaturalUnits, ConstantUnits); return Offset; }
tianocore/edk2
C++
Other
4,240
/* This function transfer control back to BootLoader after FspSiliconInit. */
VOID EFIAPI FspSiliconInitDone(VOID)
/* This function transfer control back to BootLoader after FspSiliconInit. */ VOID EFIAPI FspSiliconInitDone(VOID)
{ FspSiliconInitDone2 (EFI_SUCCESS); }
tianocore/edk2
C++
Other
4,240
/* Programs the DmaTxBaseAddress with the Tx descriptor base address. Tx Descriptor's base address is available in the gmacdev structure. This function progrms the Dma Tx Base address with the starting address of the descriptor ring or chain. */
void synopGMAC_init_tx_desc_base(synopGMACdevice *gmacdev)
/* Programs the DmaTxBaseAddress with the Tx descriptor base address. Tx Descriptor's base address is available in the gmacdev structure. This function progrms the Dma Tx Base address with the starting address of the descriptor ring or chain. */ void synopGMAC_init_tx_desc_base(synopGMACdevice *gmacdev)
{ synopGMACWriteReg(gmacdev -> DmaBase, DmaTxBaseAddr, (u32)gmacdev -> TxDescDma); return; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Freeing the efi item requires that we remove it from the AIL. We'll use the AIL lock to protect our counters as well as the removal from the AIL. */
void xfs_efi_release(xfs_efi_log_item_t *efip, uint nextents)
/* Freeing the efi item requires that we remove it from the AIL. We'll use the AIL lock to protect our counters as well as the removal from the AIL. */ void xfs_efi_release(xfs_efi_log_item_t *efip, uint nextents)
{ struct xfs_ail *ailp = efip->efi_item.li_ailp; int extents_left; ASSERT(efip->efi_next_extent > 0); ASSERT(efip->efi_flags & XFS_EFI_COMMITTED); spin_lock(&ailp->xa_lock); ASSERT(efip->efi_next_extent >= nextents); efip->efi_next_extent -= nextents; extents_left = efip->efi_next_extent; if (extents_left == 0) { xfs_trans_ail_delete(ailp, (xfs_log_item_t *)efip); xfs_efi_item_free(efip); } else { spin_unlock(&ailp->xa_lock); } }
robutest/uclinux
C++
GPL-2.0
60
/* Noise Mode. When set to 1, low noise mode is enabled. */
static int adxl367_set_low_noise(const struct device *dev, bool enable)
/* Noise Mode. When set to 1, low noise mode is enabled. */ static int adxl367_set_low_noise(const struct device *dev, bool enable)
{ struct adxl367_data *data = dev->data; return data->hw_tf->write_reg_mask(dev, ADXL367_POWER_CTL, ADXL367_POWER_CTL_NOISE_MSK, FIELD_PREP(ADXL367_POWER_CTL_NOISE_MSK, enable)); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Programs the FLASH User Option Byte: IWDG_SW / RST_STOP / RST_STDBY. */
FLASH_Status FLASH_OB_UserConfig(uint8_t OB_IWDG, uint8_t OB_STOP, uint8_t OB_STDBY)
/* Programs the FLASH User Option Byte: IWDG_SW / RST_STOP / RST_STDBY. */ FLASH_Status FLASH_OB_UserConfig(uint8_t OB_IWDG, uint8_t OB_STOP, uint8_t OB_STDBY)
{ FLASH_Status status = FLASH_COMPLETE; assert_param(IS_OB_IWDG_SOURCE(OB_IWDG)); assert_param(IS_OB_STOP_SOURCE(OB_STOP)); assert_param(IS_OB_STDBY_SOURCE(OB_STDBY)); FLASH->OPTKEYR = FLASH_KEY1; FLASH->OPTKEYR = FLASH_KEY2; status = FLASH_WaitForLastOperation(FLASH_ER_PRG_TIMEOUT); if(status == FLASH_COMPLETE) { FLASH->CR |= FLASH_CR_OPTPG; OB->USER = (uint8_t)((uint8_t)(OB_IWDG | OB_STOP) | (uint8_t)(OB_STDBY |0xF8)); status = FLASH_WaitForLastOperation(FLASH_ER_PRG_TIMEOUT); if(status != FLASH_TIMEOUT) { FLASH->CR &= ~FLASH_CR_OPTPG; } } return status; }
ajhc/demo-cortex-m3
C++
null
38
/* Scans a target buffer for a 16-bit value, and returns a pointer to the matching 16-bit value in the target buffer. */
CONST VOID* EFIAPI InternalMemScanMem16(IN CONST VOID *Buffer, IN UINTN Length, IN UINT16 Value)
/* Scans a target buffer for a 16-bit value, and returns a pointer to the matching 16-bit value in the target buffer. */ CONST VOID* EFIAPI InternalMemScanMem16(IN CONST VOID *Buffer, IN UINTN Length, IN UINT16 Value)
{ CONST UINT16 *Pointer; Pointer = (CONST UINT16 *)Buffer; do { if (*(Pointer++) == Value) { return --Pointer; } } while (--Length != 0); return NULL; }
tianocore/edk2
C++
Other
4,240
/* Set ROP. Translate X rop into ROP3. Internal routine. */
static void riva_set_rop_solid(struct riva_par *par, int rop)
/* Set ROP. Translate X rop into ROP3. Internal routine. */ static void riva_set_rop_solid(struct riva_par *par, int rop)
{ riva_set_pattern(par, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF); RIVA_FIFO_FREE(par->riva, Rop, 1); NV_WR32(&par->riva.Rop->Rop3, 0, rop); }
robutest/uclinux
C++
GPL-2.0
60
/* Set write enable latch with Write Enable command. Returns negative if error occurred. */
static int write_enable(struct spi_nor *nor)
/* Set write enable latch with Write Enable command. Returns negative if error occurred. */ static int write_enable(struct spi_nor *nor)
{ return nor->write_reg(nor, SPINOR_OP_WREN, NULL, 0); }
4ms/stm32mp1-baremetal
C++
Other
137
/* Calculate the sum of two Big Numbers. Please note, all "out" Big number arguments should be properly initialized by calling to BigNumInit() or BigNumFromBin() functions. */
BOOLEAN EFIAPI CryptoServiceBigNumAdd(IN CONST VOID *BnA, IN CONST VOID *BnB, OUT VOID *BnRes)
/* Calculate the sum of two Big Numbers. Please note, all "out" Big number arguments should be properly initialized by calling to BigNumInit() or BigNumFromBin() functions. */ BOOLEAN EFIAPI CryptoServiceBigNumAdd(IN CONST VOID *BnA, IN CONST VOID *BnB, OUT VOID *BnRes)
{ return CALL_BASECRYPTLIB (Bn.Services.Add, BigNumAdd, (BnA, BnB, BnRes), FALSE); }
tianocore/edk2
C++
Other
4,240
/* This function enables the specified interrupts in the device. */
void XAdcPs_IntrEnable(XAdcPs *InstancePtr, u32 Mask)
/* This function enables the specified interrupts in the device. */ void XAdcPs_IntrEnable(XAdcPs *InstancePtr, u32 Mask)
{ u32 RegValue; Xil_AssertVoid(InstancePtr != NULL); Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); RegValue = XAdcPs_ReadReg(InstancePtr->Config.BaseAddress, XADCPS_INT_MASK_OFFSET); RegValue &= ~(Mask & XADCPS_INTX_ALL_MASK); XAdcPs_WriteReg(InstancePtr->Config.BaseAddress, XADCPS_INT_MASK_OFFSET, RegValue); }
ua1arn/hftrx
C++
null
69
/* Returns 1 if a deallocation occured, or 0 if not found */
int xmlListRemoveLast(xmlListPtr l, void *data)
/* Returns 1 if a deallocation occured, or 0 if not found */ int xmlListRemoveLast(xmlListPtr l, void *data)
{ xmlLinkPtr lk; if (l == NULL) return(0); lk = xmlListLinkReverseSearch(l, data); if (lk != NULL) { xmlLinkDeallocator(l, lk); return 1; } return 0; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Subtract one value from another in F255. Partial reduction is performed (down to less than twice the modulus). */
static void f255_sub(uint32_t *d, const uint32_t *a, const uint32_t *b)
/* Subtract one value from another in F255. Partial reduction is performed (down to less than twice the modulus). */ static void f255_sub(uint32_t *d, const uint32_t *a, const uint32_t *b)
{ int i; uint32_t cc, w; cc = (uint32_t)-38; for (i = 0; i < 9; i ++) { w = a[i] - b[i] + cc; d[i] = w & 0x3FFFFFFF; cc = ARSH(w, 30); } cc = MUL15((w + 0x10000) >> 15, 19); d[8] &= 0x7FFF; for (i = 0; i < 9; i ++) { w = d[i] + cc; d[i] = w & 0x3FFFFFFF; cc = w >> 30; } }
RavenSystem/esp-homekit-devices
C++
Other
2,577
/* Count the number of joysticks attached to the system */
int SDL_NumJoysticks(void)
/* Count the number of joysticks attached to the system */ int SDL_NumJoysticks(void)
{ int i, total_joysticks = 0; SDL_LockJoysticks(); for (i = 0; i < SDL_arraysize(SDL_joystick_drivers); ++i) { total_joysticks += SDL_joystick_drivers[i]->GetCount(); } SDL_UnlockJoysticks(); return total_joysticks; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Internal function creates opcode based on the template opcode. */
UINT8* EFIAPI InternalHiiCreateOpCodeExtended(IN VOID *OpCodeHandle, IN VOID *OpCodeTemplate, IN UINT8 OpCode, IN UINTN OpCodeSize, IN UINTN ExtensionSize, IN UINT8 Scope)
/* Internal function creates opcode based on the template opcode. */ UINT8* EFIAPI InternalHiiCreateOpCodeExtended(IN VOID *OpCodeHandle, IN VOID *OpCodeTemplate, IN UINT8 OpCode, IN UINTN OpCodeSize, IN UINTN ExtensionSize, IN UINT8 Scope)
{ EFI_IFR_OP_HEADER *Header; UINT8 *Buffer; ASSERT (OpCodeTemplate != NULL); ASSERT ((OpCodeSize + ExtensionSize) <= 0x7F); Header = (EFI_IFR_OP_HEADER *)OpCodeTemplate; Header->OpCode = OpCode; Header->Scope = Scope; Header->Length = (UINT8)(OpCodeSize + ExtensionSize); Buffer = InternalHiiGrowOpCodeHandle (OpCodeHandle, Header->Length); return (UINT8 *)CopyMem (Buffer, Header, OpCodeSize); }
tianocore/edk2
C++
Other
4,240
/* Frees all memory allocated by the #GStringChunk. After calling g_string_chunk_free() it is not safe to access any of the strings which were contained within it. */
void g_string_chunk_free(GStringChunk *chunk)
/* Frees all memory allocated by the #GStringChunk. After calling g_string_chunk_free() it is not safe to access any of the strings which were contained within it. */ void g_string_chunk_free(GStringChunk *chunk)
{ g_return_if_fail (chunk != NULL); if (chunk->storage_list) g_slist_free_full (chunk->storage_list, g_free); if (chunk->const_table) g_hash_table_destroy (chunk->const_table); g_free (chunk); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Count the number of each code length for a Huffman tree. */
VOID CountLen(IN INT32 LoopVar1)
/* Count the number of each code length for a Huffman tree. */ VOID CountLen(IN INT32 LoopVar1)
{ if (LoopVar1 < mTempInt32) { mLenCnt[(mHuffmanDepth < 16) ? mHuffmanDepth : 16]++; } else { mHuffmanDepth++; CountLen (mLeft[LoopVar1]); CountLen (mRight[LoopVar1]); mHuffmanDepth--; } }
tianocore/edk2
C++
Other
4,240
/* Check next character in a string and decide if the character is part of the command or not */
bool lv_txt_is_cmd(lv_txt_cmd_state_t *state, uint32_t c)
/* Check next character in a string and decide if the character is part of the command or not */ bool lv_txt_is_cmd(lv_txt_cmd_state_t *state, uint32_t c)
{ bool ret = false; if(c == (uint32_t)LV_TXT_COLOR_CMD[0]) { if(*state == LV_TXT_CMD_STATE_WAIT) { *state = LV_TXT_CMD_STATE_PAR; ret = true; } else if(*state == LV_TXT_CMD_STATE_PAR) { *state = LV_TXT_CMD_STATE_WAIT; } else if(*state == LV_TXT_CMD_STATE_IN) { *state = LV_TXT_CMD_STATE_WAIT; ret = true; } } if(*state == LV_TXT_CMD_STATE_PAR) { if(c == ' ') { *state = LV_TXT_CMD_STATE_IN; } ret = true; } return ret; }
RavenSystem/esp-homekit-devices
C++
Other
2,577
/* Prints a unicode string to the default console, at the supplied cursor position, using L"%s" format. */
UINTN EFIAPI PrintStringAt(IN UINTN Column, IN UINTN Row, IN CHAR16 *String)
/* Prints a unicode string to the default console, at the supplied cursor position, using L"%s" format. */ UINTN EFIAPI PrintStringAt(IN UINTN Column, IN UINTN Row, IN CHAR16 *String)
{ return PrintAt (0, Column, Row, L"%s", String); }
tianocore/edk2
C++
Other
4,240
/* Calls a local function with a single optional parameter. */
void IPCRtoLFunctionCall(tIpcMessage *psMessage)
/* Calls a local function with a single optional parameter. */ void IPCRtoLFunctionCall(tIpcMessage *psMessage)
{ tfIpcFuncCall func_call = (tfIpcFuncCall)psMessage->uladdress; func_call(psMessage->uldataw1); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* param base GPIO peripheral base pointer (GPIOA, GPIOB, GPIOC, and so on.) param pin GPIO port pin number param config GPIO pin configuration pointer */
void GPIO_PinInit(GPIO_Type *base, uint32_t pin, const gpio_pin_config_t *config)
/* param base GPIO peripheral base pointer (GPIOA, GPIOB, GPIOC, and so on.) param pin GPIO port pin number param config GPIO pin configuration pointer */ void GPIO_PinInit(GPIO_Type *base, uint32_t pin, const gpio_pin_config_t *config)
{ assert(NULL != config); if (config->pinDirection == kGPIO_DigitalInput) { base->PDDR &= GPIO_FIT_REG(~(1UL << pin)); } else { GPIO_PinWrite(base, pin, config->outputLogic); base->PDDR |= GPIO_FIT_REG((1UL << pin)); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* vxge_hw_device_terminate - Terminate Titan device. Terminate HW device. */
void vxge_hw_device_terminate(struct __vxge_hw_device *hldev)
/* vxge_hw_device_terminate - Terminate Titan device. Terminate HW device. */ void vxge_hw_device_terminate(struct __vxge_hw_device *hldev)
{ vxge_assert(hldev->magic == VXGE_HW_DEVICE_MAGIC); hldev->magic = VXGE_HW_DEVICE_DEAD; __vxge_hw_blockpool_destroy(&hldev->block_pool); vfree(hldev); }
robutest/uclinux
C++
GPL-2.0
60
/* Change Logs: Date Author Notes Bernard the first version */
void LPIT0_IRQHandler(void)
/* Change Logs: Date Author Notes Bernard the first version */ void LPIT0_IRQHandler(void)
{ rt_tick_increase(); SystemClearSystickFlag(); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Determines the LAN function id by reading memory-mapped registers and swaps the port value if requested. */
void ixgbe_set_lan_id_multi_port_pcie(struct ixgbe_hw *hw)
/* Determines the LAN function id by reading memory-mapped registers and swaps the port value if requested. */ void ixgbe_set_lan_id_multi_port_pcie(struct ixgbe_hw *hw)
{ struct ixgbe_bus_info *bus = &hw->bus; u32 reg; reg = IXGBE_READ_REG(hw, IXGBE_STATUS); bus->func = (reg & IXGBE_STATUS_LAN_ID) >> IXGBE_STATUS_LAN_ID_SHIFT; bus->lan_id = bus->func; reg = IXGBE_READ_REG(hw, IXGBE_FACTPS); if (reg & IXGBE_FACTPS_LFS) bus->func ^= 0x1; }
robutest/uclinux
C++
GPL-2.0
60
/* Fills each CRYP_IVInitStruct member with its default value. */
void CRYP_IVStructInit(CRYP_IVInitTypeDef *CRYP_IVInitStruct)
/* Fills each CRYP_IVInitStruct member with its default value. */ void CRYP_IVStructInit(CRYP_IVInitTypeDef *CRYP_IVInitStruct)
{ CRYP_IVInitStruct->CRYP_IV0Left = 0; CRYP_IVInitStruct->CRYP_IV0Right = 0; CRYP_IVInitStruct->CRYP_IV1Left = 0; CRYP_IVInitStruct->CRYP_IV1Right = 0; }
MaJerle/stm32f429
C++
null
2,036
/* Function for processing the BLE_GAP_EVT_CONN_SEC_UPDATE event from the SoftDevice. */
static void conn_sec_update_process(ble_gap_evt_t *p_gap_evt)
/* Function for processing the BLE_GAP_EVT_CONN_SEC_UPDATE event from the SoftDevice. */ static void conn_sec_update_process(ble_gap_evt_t *p_gap_evt)
{ if (ble_conn_state_encrypted(p_gap_evt->conn_handle)) { if (!ble_conn_state_user_flag_get(p_gap_evt->conn_handle, m_smd.flag_id_sec_proc_pairing)) { ble_conn_state_user_flag_set(p_gap_evt->conn_handle, m_smd.flag_id_sec_proc, false); } smd_evt_t evt; evt.conn_handle = p_gap_evt->conn_handle; evt.evt_id = SMD_EVT_LINK_ENCRYPTION_UPDATE; evt.params.link_encryption_update.mitm_protected = ble_conn_state_mitm_protected(p_gap_evt->conn_handle); evt_send(&evt); } else { encryption_failure(p_gap_evt->conn_handle, PM_CONN_SEC_ERROR_PIN_OR_KEY_MISSING, BLE_GAP_SEC_STATUS_SOURCE_REMOTE); } }
labapart/polymcu
C++
null
201
/* This fixes the problem where directories might have inadvertently been deleted leaving the object "hanging" without being rooted in the directory tree. */
static int yaffs_has_null_parent(struct yaffs_dev *dev, struct yaffs_obj *obj)
/* This fixes the problem where directories might have inadvertently been deleted leaving the object "hanging" without being rooted in the directory tree. */ static int yaffs_has_null_parent(struct yaffs_dev *dev, struct yaffs_obj *obj)
{ return (obj == dev->del_dir || obj == dev->unlinked_dir || obj == dev->root_dir); }
4ms/stm32mp1-baremetal
C++
Other
137
/* We model this as a regular bus type, and hang devices directly off this. */
static int locomo_match(struct device *_dev, struct device_driver *_drv)
/* We model this as a regular bus type, and hang devices directly off this. */ static int locomo_match(struct device *_dev, struct device_driver *_drv)
{ struct locomo_dev *dev = LOCOMO_DEV(_dev); struct locomo_driver *drv = LOCOMO_DRV(_drv); return dev->devid == drv->devid; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Inform the PRL that the first message in an AMS is being sent. */
void prl_first_msg_notificaiton(const struct device *dev)
/* Inform the PRL that the first message in an AMS is being sent. */ void prl_first_msg_notificaiton(const struct device *dev)
{ struct usbc_port_data *data = dev->data; struct protocol_layer_tx_t *prl_tx = data->prl_tx; atomic_set_bit(&prl_tx->flags, PRL_FLAGS_FIRST_MSG_PENDING); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Opens the list of all fieldbus adapters registered with the VCI. */
static HRESULT IxxatVciLibFuncVciEnumDeviceOpen(PHANDLE hEnum)
/* Opens the list of all fieldbus adapters registered with the VCI. */ static HRESULT IxxatVciLibFuncVciEnumDeviceOpen(PHANDLE hEnum)
{ HRESULT result = VCI_E_UNEXPECTED; assert(ixxatVciLibFuncVciEnumDeviceOpenPtr != NULL); assert(ixxatVciDllHandle != NULL); if ((ixxatVciLibFuncVciEnumDeviceOpenPtr != NULL) && (ixxatVciDllHandle != NULL)) { result = ixxatVciLibFuncVciEnumDeviceOpenPtr(hEnum); } return result; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Lock free operation, be careful of the use scheme Returns: pointer popped out */
void* rtw_cbuf_pop(struct rtw_cbuf *cbuf)
/* Lock free operation, be careful of the use scheme Returns: pointer popped out */ void* rtw_cbuf_pop(struct rtw_cbuf *cbuf)
{ void *buf; if (rtw_cbuf_empty(cbuf)) return NULL; if (0) DBG_871X("%s on %u\n", __func__, cbuf->read); buf = cbuf->bufs[cbuf->read]; cbuf->read = (cbuf->read+1)%cbuf->size; return buf; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* The main oscillator verification timer is only available on Sandstorm-class devices. */
void SysCtlMOSCVerificationSet(tBoolean bEnable)
/* The main oscillator verification timer is only available on Sandstorm-class devices. */ void SysCtlMOSCVerificationSet(tBoolean bEnable)
{ if(bEnable) { HWREG(SYSCTL_RCC) |= SYSCTL_RCC_MOSCVER; } else { HWREG(SYSCTL_RCC) &= ~(SYSCTL_RCC_MOSCVER); } }
watterott/WebRadio
C++
null
71
/* Enables the I2C Slave block. This will enable operation of the I2C Slave block. */
void xI2CSlaveEnable(unsigned long ulBase)
/* Enables the I2C Slave block. This will enable operation of the I2C Slave block. */ void xI2CSlaveEnable(unsigned long ulBase)
{ xASSERT((ulBase == I2C0_BASE)); xHWREG(ulBase + I2C_CON) |= I2C_CON_ENS1; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Novation USB MIDI protocol: number of data bytes is in the first byte (when receiving) (+1!) or in the second byte (when sending); data begins at the third byte. */
static void snd_usbmidi_novation_input(struct snd_usb_midi_in_endpoint *ep, uint8_t *buffer, int buffer_length)
/* Novation USB MIDI protocol: number of data bytes is in the first byte (when receiving) (+1!) or in the second byte (when sending); data begins at the third byte. */ static void snd_usbmidi_novation_input(struct snd_usb_midi_in_endpoint *ep, uint8_t *buffer, int buffer_length)
{ if (buffer_length < 2 || !buffer[0] || buffer_length < buffer[0] + 1) return; snd_usbmidi_input_data(ep, 0, &buffer[2], buffer[0] - 1); }
robutest/uclinux
C++
GPL-2.0
60
/* Write a data to the slave, when the master have obtained control of the bus, and waiting for all bus transmiton complete.(Write Step2) This function is always used in thread mode. */
unsigned long xI2CMasterWriteS2(unsigned long ulBase, unsigned char ucData, xtBoolean bEndTransmition)
/* Write a data to the slave, when the master have obtained control of the bus, and waiting for all bus transmiton complete.(Write Step2) This function is always used in thread mode. */ unsigned long xI2CMasterWriteS2(unsigned long ulBase, unsigned char ucData, xtBoolean bEndTransmition)
{ unsigned long ulStatus; xASSERT((ulBase == I2C0_BASE)); xI2CMasterWriteRequestS2(ulBase, ucData, xfalse); while (!(xHWREG(ulBase + I2C_CON) & I2C_CON_SI)); ulStatus = xHWREG(ulBase + I2C_STATUS) & I2C_STATUS_M; if(!(ulStatus == I2C_I2STAT_M_TX_DAT_ACK)) { ulStatus = xI2CMasterError(ulBase); I2CStopSend(ulBase); return ulStatus; } if(bEndTransmition) { I2CStopSend(ulBase); } return xI2C_MASTER_ERR_NONE; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Returns zero if event is invalid, one otherwise. */
static int valid_event_struct(struct event_pool *pool, struct srp_event_struct *evt)
/* Returns zero if event is invalid, one otherwise. */ static int valid_event_struct(struct event_pool *pool, struct srp_event_struct *evt)
{ int index = evt - pool->events; if (index < 0 || index >= pool->size) return 0; if (evt != pool->events + index) return 0; return 1; }
robutest/uclinux
C++
GPL-2.0
60
/* Returns the current MDC divider value programmed in the ip. */
u32 synopGMAC_get_mdc_clk_div(synopGMACdevice *gmacdev)
/* Returns the current MDC divider value programmed in the ip. */ u32 synopGMAC_get_mdc_clk_div(synopGMACdevice *gmacdev)
{ u32 data; data = synopGMACReadReg(gmacdev->MacBase, GmacGmiiAddr); data &= GmiiCsrClkMask; return data; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Disable the PWM interrupt of the PWM module. //! The */
void xPWMIntDisable(unsigned long ulBase, unsigned long ulChannel, unsigned long ulIntType)
/* Disable the PWM interrupt of the PWM module. //! The */ void xPWMIntDisable(unsigned long ulBase, unsigned long ulChannel, unsigned long ulIntType)
{ unsigned long ulChannelTemp; ulChannelTemp = (ulBase == PWMA_BASE) ? ulChannel : (ulChannel - 4); xASSERT((ulBase == PWMA_BASE) || (ulBase == PWMB_BASE)); xASSERT(((ulChannelTemp >= 0) || (ulChannelTemp <= 3))); xASSERT((ulIntType == PWM_INT_CAP_BOTH) || (ulIntType == PWM_INT_CAP_FALL) || (ulIntType == PWM_INT_CAP_RISE) || (ulIntType == PWM_INT_PWM)); if (ulIntType == PWM_INT_PWM) { xHWREG(ulBase + PWM_PIER) &= ~(PWM_PIER_PWMIE0 << ulChannelTemp); } else { xHWREG(ulBase + PWM_CCR0 + (ulChannelTemp >> 1)*4) &= ~(ulIntType << ((ulChannel % 2) ? 16 : 0)); } }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Start waiting for a character before clocking the timeout count. Reset the status bit TIMEOUT in US_CSR. */
void usart_start_rx_timeout(Usart *p_usart)
/* Start waiting for a character before clocking the timeout count. Reset the status bit TIMEOUT in US_CSR. */ void usart_start_rx_timeout(Usart *p_usart)
{ p_usart->US_CR = US_CR_STTTO; }
remotemcu/remcu-chip-sdks
C++
null
436
/* This procedure will find the highest period which will give a timeout greater than the one required. e.g. for a bus speed of 66666666 and and a parameter of 2 secs, then this procedure will return a value of 38. */
static unsigned int sec_to_period(unsigned int secs)
/* This procedure will find the highest period which will give a timeout greater than the one required. e.g. for a bus speed of 66666666 and and a parameter of 2 secs, then this procedure will return a value of 38. */ static unsigned int sec_to_period(unsigned int secs)
{ unsigned int period; for (period = 63; period > 0; period--) { if (period_to_sec(period) >= secs) return period; } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* enable or disable USI UART RX DMA . */
void USI_UARTRXDMACmd(USI_TypeDef *USIx, u32 NewState)
/* enable or disable USI UART RX DMA . */ void USI_UARTRXDMACmd(USI_TypeDef *USIx, u32 NewState)
{ assert_param(IS_ALL_USI_PERIPH(USIx)); if(NewState != DISABLE ){ USIx->DMA_ENABLE |= USI_RX_DMA_ENABLE; } else { USIx->DMA_ENABLE &= (~ USI_RX_DMA_ENABLE); } }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Function for write data to the swap state entry action. Function for write data to the swap state entry action, which includes writing the current data page to the swap flash page. */
static void state_write_data_swap_entry_run(void)
/* Function for write data to the swap state entry action. Function for write data to the swap state entry action, which includes writing the current data page to the swap flash page. */ static void state_write_data_swap_entry_run(void)
{ flash_write((uint32_t *)(PSTORAGE_SWAP_ADDR), (uint32_t *)(m_current_page_id * PSTORAGE_FLASH_PAGE_SIZE), PSTORAGE_FLASH_PAGE_SIZE / sizeof(uint32_t)); }
labapart/polymcu
C++
null
201
/* This gets called every 1ms when we paniced. */
static long gta02_panic_blink(long count)
/* This gets called every 1ms when we paniced. */ static long gta02_panic_blink(long count)
{ long delay = 0; static long last_blink; static char led; if (count - last_blink < 100) return 0; led ^= 1; gpio_direction_output(GTA02_GPIO_AUX_LED, led); last_blink = count; return delay; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Clear the counter direction change to down interrupt flag (DOWNCF). @rmtoll ICR DOWNCF LPTIM_ClearFlag_DOWN. */
void LPTIM_ClearFlag_DOWN(LPTIM_Module *LPTIMx)
/* Clear the counter direction change to down interrupt flag (DOWNCF). @rmtoll ICR DOWNCF LPTIM_ClearFlag_DOWN. */ void LPTIM_ClearFlag_DOWN(LPTIM_Module *LPTIMx)
{ SET_BIT(LPTIMx->INTCLR, LPTIM_INTCLR_DOWNCF); }
pikasTech/PikaPython
C++
MIT License
1,403
/* Selects the TIMx peripheral Capture Compare DMA source. */
void TIM_SelectCCDMA(TIM_TypeDef *TIMx, FunctionalState NewState)
/* Selects the TIMx peripheral Capture Compare DMA source. */ void TIM_SelectCCDMA(TIM_TypeDef *TIMx, FunctionalState NewState)
{ assert_param(IS_TIM_LIST3_PERIPH(TIMx)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { TIMx->CR2 |= TIM_CR2_CCDS; } else { TIMx->CR2 &= (uint16_t)~TIM_CR2_CCDS; } }
MaJerle/stm32f429
C++
null
2,036
/* STUSB1602 checks the VCONN power switch Over Voltage Protection Fault Transition (bit0 0x12 */
VCONN_SW_OVP_Fault_Trans_TypeDef STUSB1602_VCONN_SW_OVP_Fault_Trans_Get(uint8_t Addr)
/* STUSB1602 checks the VCONN power switch Over Voltage Protection Fault Transition (bit0 0x12 */ VCONN_SW_OVP_Fault_Trans_TypeDef STUSB1602_VCONN_SW_OVP_Fault_Trans_Get(uint8_t Addr)
{ STUSB1602_HW_FAULT_STATUS_TRANS_RegTypeDef reg; STUSB1602_ReadReg(&reg.d8, Addr, STUSB1602_HW_FAULT_STATUS_TRANS_REG, 1); return (VCONN_SW_OVP_Fault_Trans_TypeDef)(reg.b.VCONN_SW_OVP_FAULT_TRANS); }
st-one/X-CUBE-USB-PD
C++
null
110
/* Converts a 2 digit decimal to BCD format. */
static uint8_t ByteToBcd2(uint8_t Value)
/* Converts a 2 digit decimal to BCD format. */ static uint8_t ByteToBcd2(uint8_t Value)
{ uint8_t bcdhigh = 0; while (Value >= 10) { bcdhigh++; Value -= 10; } return (uint8_t)((uint8_t)(bcdhigh << 4) | Value); }
remotemcu/remcu-chip-sdks
C++
null
436
/* Create a platform device for the GPI port that receives the image data from the embedded camera. */
static int __init mipsnet_devinit(void)
/* Create a platform device for the GPI port that receives the image data from the embedded camera. */ static int __init mipsnet_devinit(void)
{ int err; err = platform_device_register(&eth1_device); if (err) printk(KERN_ERR "%s: registration failed\n", mipsnet_string); return err; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Returns: (element-type utf8) (transfer full): list of the registered content types */
GList* g_content_types_get_registered(void)
/* Returns: (element-type utf8) (transfer full): list of the registered content types */ GList* g_content_types_get_registered(void)
{ const char * const* dirs; GHashTable *mimetypes; GHashTableIter iter; gpointer key; int i; GList *l; mimetypes = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); enumerate_mimetypes_dir (g_get_user_data_dir (), mimetypes); dirs = g_get_system_data_dirs (); for (i = 0; dirs[i] != NULL; i++) enumerate_mimetypes_dir (dirs[i], mimetypes); l = NULL; g_hash_table_iter_init (&iter, mimetypes); while (g_hash_table_iter_next (&iter, &key, NULL)) { l = g_list_prepend (l, key); g_hash_table_iter_steal (&iter); } g_hash_table_destroy (mimetypes); return l; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Clear receive overrun error flag @rmtoll ICR CRXOVRF LL_SWPMI_ClearFlag_RXOVR. */
void LL_SWPMI_ClearFlag_RXOVR(SWPMI_TypeDef *SWPMIx)
/* Clear receive overrun error flag @rmtoll ICR CRXOVRF LL_SWPMI_ClearFlag_RXOVR. */ void LL_SWPMI_ClearFlag_RXOVR(SWPMI_TypeDef *SWPMIx)
{ WRITE_REG(SWPMIx->ICR, SWPMI_ICR_CRXOVRF); }
remotemcu/remcu-chip-sdks
C++
null
436
/* Trivial helpers to strip endian annotation and compare; the endianness doesn't actually matter since we just need a stable order for the RB tree. */
static int be32_lt(__be32 a, __be32 b)
/* Trivial helpers to strip endian annotation and compare; the endianness doesn't actually matter since we just need a stable order for the RB tree. */ static int be32_lt(__be32 a, __be32 b)
{ return (__force u32) a < (__force u32) b; }
robutest/uclinux
C++
GPL-2.0
60
/* must be called with the lock held and interrupts disabled. */
static void enable_transmit_interrupt(struct xircom_private *card)
/* must be called with the lock held and interrupts disabled. */ static void enable_transmit_interrupt(struct xircom_private *card)
{ unsigned int val; enter("enable_transmit_interrupt"); val = inl(card->io_port + CSR7); val |= 1; outl(val, card->io_port + CSR7); leave("enable_transmit_interrupt"); }
robutest/uclinux
C++
GPL-2.0
60
/* Use the VMGEXIT instruction to handle a INVD event. */
STATIC UINT64 InvdExit(IN OUT GHCB *Ghcb, IN OUT EFI_SYSTEM_CONTEXT_X64 *Regs, IN CC_INSTRUCTION_DATA *InstructionData)
/* Use the VMGEXIT instruction to handle a INVD event. */ STATIC UINT64 InvdExit(IN OUT GHCB *Ghcb, IN OUT EFI_SYSTEM_CONTEXT_X64 *Regs, IN CC_INSTRUCTION_DATA *InstructionData)
{ return CcExitVmgExit (Ghcb, SVM_EXIT_INVD, 0, 0); }
tianocore/edk2
C++
Other
4,240
/* process completed requests for channels that have done status */
static void talitos_done(unsigned long data)
/* process completed requests for channels that have done status */ static void talitos_done(unsigned long data)
{ struct device *dev = (struct device *)data; struct talitos_private *priv = dev_get_drvdata(dev); int ch; for (ch = 0; ch < priv->num_channels; ch++) flush_channel(dev, ch, 0, 0); setbits32(priv->reg + TALITOS_IMR, TALITOS_IMR_INIT); setbits32(priv->reg + TALITOS_IMR_LO, TALITOS_IMR_LO_INIT); }
robutest/uclinux
C++
GPL-2.0
60
/* snt_hw_puts_buffered - Send string to console, polled or interrupt mode @s: String @len: Length */
static int snt_hw_puts_buffered(const char *, int)
/* snt_hw_puts_buffered - Send string to console, polled or interrupt mode @s: String @len: Length */ static int snt_hw_puts_buffered(const char *, int)
{ return ia64_sn_console_xmit_chars((char *)s, len); }
robutest/uclinux
C++
GPL-2.0
60
/* dump Lua function as precompiled chunk with specified target */
int luaU_dump_crosscompile(lua_State *L, const Proto *f, lua_Writer w, void *data, int strip, DumpTargetInfo target)
/* dump Lua function as precompiled chunk with specified target */ int luaU_dump_crosscompile(lua_State *L, const Proto *f, lua_Writer w, void *data, int strip, DumpTargetInfo target)
{ DumpState D; D.L=L; D.writer=w; D.data=data; D.strip=strip; D.status=0; D.target=target; D.wrote=0; DumpHeader(&D); DumpFunction(f,NULL,&D); return D.status; }
Nicholas3388/LuaNode
C++
Other
1,055
/* If the requested operation results in an overflow or an underflow condition, then Result is set to INT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeInt16Sub(IN INT16 Minuend, IN INT16 Subtrahend, OUT INT16 *Result)
/* If the requested operation results in an overflow or an underflow condition, then Result is set to INT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */ RETURN_STATUS EFIAPI SafeInt16Sub(IN INT16 Minuend, IN INT16 Subtrahend, OUT INT16 *Result)
{ return SafeInt32ToInt16 (((INT32)Minuend) - ((INT32)Subtrahend), Result); }
tianocore/edk2
C++
Other
4,240
/* Saves the Initial Vector (IV) registers to a user-defined location. */
void AESIVRead(uint32_t ui32Base, uint32_t *pui32IVData)
/* Saves the Initial Vector (IV) registers to a user-defined location. */ void AESIVRead(uint32_t ui32Base, uint32_t *pui32IVData)
{ ASSERT(ui32Base == AES_BASE); while((AES_CTRL_SVCTXTRDY & (HWREG(ui32Base + AES_O_CTRL))) == 0) { } pui32IVData[0] = HWREG((ui32Base + AES_O_IV_IN_0)); pui32IVData[1] = HWREG((ui32Base + AES_O_IV_IN_1)); pui32IVData[2] = HWREG((ui32Base + AES_O_IV_IN_2)); pui32IVData[3] = HWREG((ui32Base + AES_O_IV_IN_3)); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Configure a FIFOCON register of the CAN controller to be transmit FIFO. */
static int32_t can_ctrl_tx_fifo_config(struct can_ctrl_dev *dev, uint8_t fifo_nr, struct can_ctrl_init_param *init_param)
/* Configure a FIFOCON register of the CAN controller to be transmit FIFO. */ static int32_t can_ctrl_tx_fifo_config(struct can_ctrl_dev *dev, uint8_t fifo_nr, struct can_ctrl_init_param *init_param)
{ int32_t ret; uint32_t temp; ret = can_ctrl_sfr_word_read(dev, CAN_CTRL_REG_FIFOCON(fifo_nr), &temp); if(ret != 0) return ret; temp &= ~FIFOCON_PLSIZE_MODE(WORD_MASK); temp &= ~FIFOCON_FSIZE_MODE(WORD_MASK); temp &= ~FIFOCON_TXPRI_MODE(WORD_MASK); temp &= ~FIFOCON_TXEN_MODE(WORD_MASK); temp |= FIFOCON_PLSIZE_MODE(init_param->tx_fifo_plsize); temp |= FIFOCON_FSIZE_MODE((init_param->tx_fifo_size - 1)); temp |= FIFOCON_TXPRI_MODE(init_param->tx_fifo_priority); temp |= FIFOCON_TXEN_MODE(true); return can_ctrl_sfr_word_write(dev, CAN_CTRL_REG_FIFOCON(fifo_nr), temp); }
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* For each address in the range, find the pte for the address and check _PAGE_HASHPTE bit; if it is set, find and destroy the corresponding HPTE. */
void flush_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned long end)
/* For each address in the range, find the pte for the address and check _PAGE_HASHPTE bit; if it is set, find and destroy the corresponding HPTE. */ void flush_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned long end)
{ flush_range(vma->vm_mm, start, end); FINISH_FLUSH; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* password - ascii string up to 63 characters in length ssid - octet string up to 32 octets ssidlength - length of ssid in octets output must be 40 octets in length and outputs 256 bits of key */
int PasswordHash(char *password, u8 *ssid, int ssidlength, u8 *output)
/* password - ascii string up to 63 characters in length ssid - octet string up to 32 octets ssidlength - length of ssid in octets output must be 40 octets in length and outputs 256 bits of key */ int PasswordHash(char *password, u8 *ssid, int ssidlength, u8 *output)
{ if ((strlen(password) > 63) || (ssidlength > 32)) return 0; F(password, ssid, ssidlength, 4096, 1, output); F(password, ssid, ssidlength, 4096, 2, &output[SHA1_DIGEST_SIZE]); return 1; }
robutest/uclinux
C++
GPL-2.0
60
/* Should allocate a pbuf and transfer the bytes of the incoming packet from the interface into the pbuf. */
static struct pbuf* low_level_input(struct netif *netif)
/* Should allocate a pbuf and transfer the bytes of the incoming packet from the interface into the pbuf. */ static struct pbuf* low_level_input(struct netif *netif)
{ struct xemac_s *xemac = (struct xemac_s *)(netif->state); xemacpsif_s *xemacpsif = (xemacpsif_s *)(xemac->state); struct pbuf *p; if (pq_qlength(xemacpsif->recv_q) == 0) return NULL; p = (struct pbuf *)pq_dequeue(xemacpsif->recv_q); return p; }
ua1arn/hftrx
C++
null
69
/* Return the pointer to the largepage write count for a given gfn, handling slots that are not large page aligned. */
static int* slot_largepage_idx(gfn_t gfn, struct kvm_memory_slot *slot, int level)
/* Return the pointer to the largepage write count for a given gfn, handling slots that are not large page aligned. */ static int* slot_largepage_idx(gfn_t gfn, struct kvm_memory_slot *slot, int level)
{ unsigned long idx; idx = (gfn / KVM_PAGES_PER_HPAGE(level)) - (slot->base_gfn / KVM_PAGES_PER_HPAGE(level)); return &slot->lpage_info[level - 2][idx].write_count; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Unregisters a node device @node. All the devices on the node must be unregistered before calling this function. */
void unregister_node(struct node *node)
/* Unregisters a node device @node. All the devices on the node must be unregistered before calling this function. */ void unregister_node(struct node *node)
{ sysdev_remove_file(&node->sysdev, &attr_cpumap); sysdev_remove_file(&node->sysdev, &attr_cpulist); sysdev_remove_file(&node->sysdev, &attr_meminfo); sysdev_remove_file(&node->sysdev, &attr_numastat); sysdev_remove_file(&node->sysdev, &attr_distance); scan_unevictable_unregister_node(node); hugetlb_unregister_node(node); sysdev_unregister(&node->sysdev); }
robutest/uclinux
C++
GPL-2.0
60
/* cxgb3i_hba_find_by_netdev - find the cxgb3i_hba structure via net_device @t3dev: t3cdev adapter */
static struct cxgb3i_hba* cxgb3i_hba_find_by_netdev(struct net_device *ndev)
/* cxgb3i_hba_find_by_netdev - find the cxgb3i_hba structure via net_device @t3dev: t3cdev adapter */ static struct cxgb3i_hba* cxgb3i_hba_find_by_netdev(struct net_device *ndev)
{ struct cxgb3i_adapter *snic; int i; if (ndev->priv_flags & IFF_802_1Q_VLAN) ndev = vlan_dev_real_dev(ndev); read_lock(&cxgb3i_snic_rwlock); list_for_each_entry(snic, &cxgb3i_snic_list, list_head) { for (i = 0; i < snic->hba_cnt; i++) { if (snic->hba[i]->ndev == ndev) { read_unlock(&cxgb3i_snic_rwlock); return snic->hba[i]; } } } read_unlock(&cxgb3i_snic_rwlock); return NULL; }
robutest/uclinux
C++
GPL-2.0
60
/* An abort indicates that the current memory access cannot be completed, which occurs during a data access. */
void rt_hw_trap_dabt(struct rt_hw_register *regs)
/* An abort indicates that the current memory access cannot be completed, which occurs during a data access. */ void rt_hw_trap_dabt(struct rt_hw_register *regs)
{ rt_kprintf("Data Abort "); rt_hw_show_register(regs); if (rt_thread_self() != RT_NULL) rt_kprintf("Current Thread: %s\n", rt_thread_self()->name); rt_hw_cpu_shutdown(); }
pikasTech/PikaPython
C++
MIT License
1,403
/* Returns a matching nsm_handle if found in the nsm cache; the returned nsm_handle's reference count is bumped and sm_monitored is cleared. Otherwise returns NULL if some error occurred. */
struct nsm_handle* nsm_reboot_lookup(const struct nlm_reboot *info)
/* Returns a matching nsm_handle if found in the nsm cache; the returned nsm_handle's reference count is bumped and sm_monitored is cleared. Otherwise returns NULL if some error occurred. */ struct nsm_handle* nsm_reboot_lookup(const struct nlm_reboot *info)
{ struct nsm_handle *cached; spin_lock(&nsm_lock); cached = nsm_lookup_priv(&info->priv); if (unlikely(cached == NULL)) { spin_unlock(&nsm_lock); dprintk("lockd: never saw rebooted peer '%.*s' before\n", info->len, info->mon); return cached; } atomic_inc(&cached->sm_count); spin_unlock(&nsm_lock); cached->sm_monitored = 0; dprintk("lockd: host %s (%s) rebooted, cnt %d\n", cached->sm_name, cached->sm_addrbuf, atomic_read(&cached->sm_count)); return cached; }
robutest/uclinux
C++
GPL-2.0
60
/* USBD_CtlReceiveStatus receive zero lzngth packet on the ctl pipe. */
USBD_Status USBD_CtlReceiveStatus(USB_OTG_CORE_HANDLE *pdev)
/* USBD_CtlReceiveStatus receive zero lzngth packet on the ctl pipe. */ USBD_Status USBD_CtlReceiveStatus(USB_OTG_CORE_HANDLE *pdev)
{ USBD_Status ret = USBD_OK; pdev->dev.device_state = USB_OTG_EP0_STATUS_OUT; DCD_EP_PrepareRx ( pdev, 0, NULL, 0); USB_OTG_EP0_OutStart(pdev); return ret; }
MaJerle/stm32f429
C++
null
2,036
/* Prepeare HCI header and initiate an HCI data write operation. hci_data_command_send */
void hci_data_command_send(UINT16 usOpcode, UINT8 *pucBuff, UINT8 ucArgsLength, UINT16 ucDataLength)
/* Prepeare HCI header and initiate an HCI data write operation. hci_data_command_send */ void hci_data_command_send(UINT16 usOpcode, UINT8 *pucBuff, UINT8 ucArgsLength, UINT16 ucDataLength)
{ UINT8 *stream = (pucBuff + SPI_HEADER_SIZE); UINT8_TO_STREAM(stream, HCI_TYPE_DATA); UINT8_TO_STREAM(stream, usOpcode); UINT8_TO_STREAM(stream, ucArgsLength); stream = UINT16_TO_STREAM(stream, ucArgsLength + ucDataLength); SpiWrite(pucBuff, ucArgsLength + ucDataLength + SIMPLE_LINK_HCI_DATA_CMND_HEADER_SIZE); return; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* @handle: handle of the loaded image @systable: system table Return: EFI_ST_SUCCESS for success */
static int setup(const efi_handle_t handle, const struct efi_system_table *systable)
/* @handle: handle of the loaded image @systable: system table Return: EFI_ST_SUCCESS for success */ static int setup(const efi_handle_t handle, const struct efi_system_table *systable)
{ size_t i; boottime = systable->boottime; for (i = 0; i < systable->nr_tables; ++i) { if (!memcmp(&systable->tables[i].guid, &fdt_guid, sizeof(efi_guid_t))) { if (fdt_addr) { efi_st_error("Duplicate device tree\n"); return EFI_ST_FAILURE; } fdt_addr = (uintptr_t)systable->tables[i].table; } } return EFI_ST_SUCCESS; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Calculate buffer size able to transmit in a specific time and rate. */
int rtnl_tc_calc_bufsize(int txtime, int rate)
/* Calculate buffer size able to transmit in a specific time and rate. */ int rtnl_tc_calc_bufsize(int txtime, int rate)
{ double bufsize; bufsize = (double) txtime * (double) rate; return bufsize / 1000000.; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Returns: TRUE if the file is a hidden file, FALSE otherwise. */
gboolean g_file_info_get_is_hidden(GFileInfo *info)
/* Returns: TRUE if the file is a hidden file, FALSE otherwise. */ gboolean g_file_info_get_is_hidden(GFileInfo *info)
{ static guint32 attr = 0; GFileAttributeValue *value; g_return_val_if_fail (G_IS_FILE_INFO (info), FALSE); if (attr == 0) attr = lookup_attribute (G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN); value = g_file_info_find_value (info, attr); return (GFileType)_g_file_attribute_value_get_boolean (value); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* fill in the option field with message type of a dhcp message. */
static uint8_t* add_msg_type(uint8_t *msg_option_base_addr, uint8_t message_type)
/* fill in the option field with message type of a dhcp message. */ static uint8_t* add_msg_type(uint8_t *msg_option_base_addr, uint8_t message_type)
{ uint8_t *option_start; msg_option_base_addr[0] = DHCP_OPTION_CODE_MSG_TYPE; msg_option_base_addr[1] = DHCP_OPTION_LENGTH_ONE; msg_option_base_addr[2] = message_type; option_start = msg_option_base_addr + 3; if (DHCP_MESSAGE_TYPE_NAK == message_type) *option_start++ = DHCP_OPTION_CODE_END; return option_start; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* adds a WiFi header conversion record Note that this function is documented in the main component header file, IxEthDB.h. */
IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBWiFiStationEntryAdd(IxEthDBPortId portID, IxEthDBMacAddr *macAddr)
/* adds a WiFi header conversion record Note that this function is documented in the main component header file, IxEthDB.h. */ IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBWiFiStationEntryAdd(IxEthDBPortId portID, IxEthDBMacAddr *macAddr)
{ return ixEthDBWiFiEntryAdd(portID, macAddr, NULL); }
EmcraftSystems/u-boot
C++
Other
181
/* This function sets the FspMemoryInit UPD data pointer. */
VOID EFIAPI SetFspMemoryInitUpdDataPointer(IN VOID *MemoryInitUpdPtr)
/* This function sets the FspMemoryInit UPD data pointer. */ VOID EFIAPI SetFspMemoryInitUpdDataPointer(IN VOID *MemoryInitUpdPtr)
{ FSP_GLOBAL_DATA *FspData; FspData = GetFspGlobalDataPointer (); FspData->MemoryInitUpdPtr = MemoryInitUpdPtr; }
tianocore/edk2
C++
Other
4,240
/* Return zero if current may access user memory in @task, -error if not. */
static int check_mem_permission(struct task_struct *task)
/* Return zero if current may access user memory in @task, -error if not. */ static int check_mem_permission(struct task_struct *task)
{ if (task == current) return 0; if (task_is_stopped_or_traced(task)) { int match; rcu_read_lock(); match = (tracehook_tracer_task(task) == current); rcu_read_unlock(); if (match && ptrace_may_access(task, PTRACE_MODE_ATTACH)) return 0; } return -EPERM; }
robutest/uclinux
C++
GPL-2.0
60
/* This function checks whether reset operation is done */
int XAxiVdma_ChannelResetNotDone(XAxiVdma_Channel *Channel)
/* This function checks whether reset operation is done */ int XAxiVdma_ChannelResetNotDone(XAxiVdma_Channel *Channel)
{ return (XAxiVdma_ReadReg(Channel->ChanBase, XAXIVDMA_CR_OFFSET) & XAXIVDMA_CR_RESET_MASK); }
ua1arn/hftrx
C++
null
69
/* The main entry for NAND booting. It's necessary that SDRAM is already configured and available since this code loads the main U-Boot image from NAND into SDRAM and starts it from there. */
void nand_boot(void)
/* The main entry for NAND booting. It's necessary that SDRAM is already configured and available since this code loads the main U-Boot image from NAND into SDRAM and starts it from there. */ void nand_boot(void)
{ __attribute__((noreturn)) void (*uboot)(void); nfc = (void *)NFC_BASE_ADDR; if (!nand_load(CONFIG_SYS_NAND_U_BOOT_OFFS, CONFIG_SYS_NAND_U_BOOT_SIZE, (uchar *)CONFIG_SYS_NAND_U_BOOT_DST)) { uboot = (void *)CONFIG_SYS_NAND_U_BOOT_START; uboot(); } else { hang(); } }
EmcraftSystems/u-boot
C++
Other
181
/* DAC960_UnregisterBlockDevice unregisters the Block Device structures associated with Controller. */
static void DAC960_UnregisterBlockDevice(DAC960_Controller_T *Controller)
/* DAC960_UnregisterBlockDevice unregisters the Block Device structures associated with Controller. */ static void DAC960_UnregisterBlockDevice(DAC960_Controller_T *Controller)
{ int MajorNumber = DAC960_MAJOR + Controller->ControllerNumber; int disk; for (disk = 0; disk < DAC960_MaxLogicalDrives; disk++) { del_gendisk(Controller->disks[disk]); blk_cleanup_queue(Controller->RequestQueue[disk]); Controller->RequestQueue[disk] = NULL; } unregister_blkdev(MajorNumber, "dac960"); }
robutest/uclinux
C++
GPL-2.0
60
/* dca_get_tag - return the dca tag for the given cpu (old api) @cpu - the cpuid as returned by get_cpu() */
u8 dca_get_tag(int cpu)
/* dca_get_tag - return the dca tag for the given cpu (old api) @cpu - the cpuid as returned by get_cpu() */ u8 dca_get_tag(int cpu)
{ struct device *dev = NULL; return dca_common_get_tag(dev, cpu); }
robutest/uclinux
C++
GPL-2.0
60
/* 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_23_PERIPH(SPIx)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { SPIx->I2SCFGR |= I2SCFGR_I2SE_Set; } else { SPIx->I2SCFGR &= I2SCFGR_I2SE_Reset; } }
gcallipo/RadioDSP-Stm32f103
C++
Common Creative - Attribution 3.0
51
/* Add Text Input Device in Consplitter Text Input list. */
EFI_STATUS ConSplitterTextInAddDevice(IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private, IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn)
/* Add Text Input Device in Consplitter Text Input list. */ EFI_STATUS ConSplitterTextInAddDevice(IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private, IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn)
{ EFI_STATUS Status; if (Private->CurrentNumberOfConsoles >= Private->TextInListCount) { Status = ConSplitterGrowBuffer ( sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL *), &Private->TextInListCount, (VOID **)&Private->TextInList ); if (EFI_ERROR (Status)) { return EFI_OUT_OF_RESOURCES; } } Private->TextInList[Private->CurrentNumberOfConsoles] = TextIn; Private->CurrentNumberOfConsoles++; gBS->CheckEvent (TextIn->WaitForKey); return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Config the slave select pins of the specified SPI port. The */
void SPISSConfig(unsigned long ulBase, unsigned long ulSSTriggerMode, unsigned long ulSSActType)
/* Config the slave select pins of the specified SPI port. The */ void SPISSConfig(unsigned long ulBase, unsigned long ulSSTriggerMode, unsigned long ulSSActType)
{ xASSERT(ulBase == SPI0_BASE); xASSERT((ulSSTriggerMode == SPI_SS_EDGE_TRIGGER) || (ulSSTriggerMode == SPI_SS_LEVEL_TRIGGER)); xASSERT((ulSSActType == SPI_SS_ACTIVE_LOW_FALLING) || (ulSSActType == SPI_SS_ACTIVE_HIGH_RISING)); xHWREG(ulBase + SPI_SSR) |= ulSSTriggerMode | ulSSActType; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Set the fields of structure stc_crc_init_t to default values. */
int32_t CRC_StructInit(stc_crc_init_t *pstcCrcInit)
/* Set the fields of structure stc_crc_init_t to default values. */ int32_t CRC_StructInit(stc_crc_init_t *pstcCrcInit)
{ int32_t i32Ret = LL_ERR_INVD_PARAM; if (NULL != pstcCrcInit) { pstcCrcInit->u32Protocol = CRC_CRC16; pstcCrcInit->u32InitValue = CRC_INIT_VALUE_DEFAULT; i32Ret = LL_OK; } return i32Ret; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* STUSB1602 checks the VCONN switch Current Limitation on CC (bit3-0 0x1E */
VCONN_Switch_Current_Limit_TypeDef STUSB1602_VCONN_Switch_Current_Limit_Get(uint8_t Addr)
/* STUSB1602 checks the VCONN switch Current Limitation on CC (bit3-0 0x1E */ VCONN_Switch_Current_Limit_TypeDef STUSB1602_VCONN_Switch_Current_Limit_Get(uint8_t Addr)
{ STUSB1602_CC_VCONN_SWITCH_CTRL_RegTypeDef reg; STUSB1602_ReadReg(&reg.d8, Addr, STUSB1602_CC_VCONN_SWITCH_CTRL_REG, 1); return (VCONN_Switch_Current_Limit_TypeDef)(reg.b.CC_VCONN_SWITCH_ILIM); }
st-one/X-CUBE-USB-PD
C++
null
110
/* Sets the application specific function that should be called when the seed for the random number generation should be initialized. The actual value is not really important as long as it is a value that is different every time the software program runs, so after each reset event. Here are a few different approaches that could be implemented to realize an seed value that is different each time the software program runs: */
void TbxRandomSetSeedInitHandler(tTbxRandomSeedInitHandler seedInitHandler)
/* Sets the application specific function that should be called when the seed for the random number generation should be initialized. The actual value is not really important as long as it is a value that is different every time the software program runs, so after each reset event. Here are a few different approaches that could be implemented to realize an seed value that is different each time the software program runs: */ void TbxRandomSetSeedInitHandler(tTbxRandomSeedInitHandler seedInitHandler)
{ TBX_ASSERT(seedInitHandler != NULL); if (seedInitHandler != NULL) { tbxRandomSeedInitHandler = seedInitHandler; } }
feaser/openblt
C++
GNU General Public License v3.0
601