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 primitive provides the guarantees made by the (now removed) synchronize_kernel() API. In contrast, synchronize_rcu() only guarantees that rcu_read_lock() sections will have completed. In "classic RCU", these two guarantees happen to be one and the same, but can differ in realtime RCU implementations. */
void synchronize_sched(void)
/* This primitive provides the guarantees made by the (now removed) synchronize_kernel() API. In contrast, synchronize_rcu() only guarantees that rcu_read_lock() sections will have completed. In "classic RCU", these two guarantees happen to be one and the same, but can differ in realtime RCU implementations. */ void synchronize_sched(void)
{ struct rcu_synchronize rcu; if (rcu_blocking_is_gp()) return; init_completion(&rcu.completion); call_rcu_sched(&rcu.head, wakeme_after_rcu); wait_for_completion(&rcu.completion); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Enables a peripheral. Peripherals are enabled with this function. At power-up, all peripherals are disabled; they must be enabled in order to operate or respond to register reads/writes. */
void xSysCtlPeripheralEnable(unsigned long ulPeripheralID)
/* Enables a peripheral. Peripherals are enabled with this function. At power-up, all peripherals are disabled; they must be enabled in order to operate or respond to register reads/writes. */ void xSysCtlPeripheralEnable(unsigned long ulPeripheralID)
{ SysCtlPeripheralEnable(ulPeripheralID); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Get detailed information of the requested logical processor. */
VOID CpuCacheInfoGetProcessorInfo(IN MP_SERVICES MpServices, IN UINTN ProcessorNum, OUT EFI_PROCESSOR_INFORMATION *ProcessorInfo)
/* Get detailed information of the requested logical processor. */ VOID CpuCacheInfoGetProcessorInfo(IN MP_SERVICES MpServices, IN UINTN ProcessorNum, OUT EFI_PROCESSOR_INFORMATION *ProcessorInfo)
{ EFI_STATUS Status; Status = MpServices.Protocol->GetProcessorInfo (MpServices.Protocol, ProcessorNum, ProcessorInfo); ASSERT_EFI_ERROR (Status); }
tianocore/edk2
C++
Other
4,240
/* Count keys in array part of table 't': Fill 'nums' with number of keys that will go into corresponding slice and return total number of non-nil keys. */
static unsigned int numusearray(const Table *t, unsigned int *nums)
/* Count keys in array part of table 't': Fill 'nums' with number of keys that will go into corresponding slice and return total number of non-nil keys. */ static unsigned int numusearray(const Table *t, unsigned int *nums)
{ unsigned int lc = 0; unsigned int lim = ttlg; if (lim > asize) { lim = asize; if (i > lim) break; } for (; i <= lim; i++) { if (!isempty(&t->array[i-1])) lc++; } nums[lg] += lc; ause += lc; } return ause; }
Nicholas3388/LuaNode
C++
Other
1,055
/* Set the video device into the specified mode and clears the visible portions of the output display to black. */
EFI_STATUS EFIAPI GraphicsOutputSetMode(IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This, IN UINT32 ModeNumber)
/* Set the video device into the specified mode and clears the visible portions of the output display to black. */ EFI_STATUS EFIAPI GraphicsOutputSetMode(IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This, IN UINT32 ModeNumber)
{ RETURN_STATUS Status; EFI_GRAPHICS_OUTPUT_BLT_PIXEL Black; GRAPHICS_OUTPUT_PRIVATE_DATA *Private; if (ModeNumber >= This->Mode->MaxMode) { return EFI_UNSUPPORTED; } Private = GRAPHICS_OUTPUT_PRIVATE_FROM_THIS (This); Black.Blue = 0; Black.Green = 0; Black.Red = 0; Black.Reserved = 0; Status = FrameBufferBlt ( Private->FrameBufferBltLibConfigure, &Black, EfiBltVideoFill, 0, 0, 0, 0, This->Mode->Info->HorizontalResolution, This->Mode->Info->VerticalResolution, 0 ); return RETURN_ERROR (Status) ? EFI_DEVICE_ERROR : EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Returns: matching lport pointer or NULL if there is no match */
struct fc_lport* fc_vport_id_lookup(struct fc_lport *n_port, u32 port_id)
/* Returns: matching lport pointer or NULL if there is no match */ struct fc_lport* fc_vport_id_lookup(struct fc_lport *n_port, u32 port_id)
{ struct fc_lport *lport = NULL; struct fc_lport *vn_port; if (fc_host_port_id(n_port->host) == port_id) return n_port; mutex_lock(&n_port->lp_mutex); list_for_each_entry(vn_port, &n_port->vports, list) { if (fc_host_port_id(vn_port->host) == port_id) { lport = vn_port; break; } } mutex_unlock(&n_port->lp_mutex); return lport; }
robutest/uclinux
C++
GPL-2.0
60
/* Toggle a single pin in GPIO port data out register. */
void GPIO_PortOutToggle(GPIO_Port_TypeDef port, uint32_t pins)
/* Toggle a single pin in GPIO port data out register. */ void GPIO_PortOutToggle(GPIO_Port_TypeDef port, uint32_t pins)
{ EFM_ASSERT(GPIO_PORT_VALID(port)); GPIO->P[port].DOUTTGL = pins & _GPIO_P_DOUTTGL_DOUTTGL_MASK; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Gets the error status of the I2C Master module. */
unsigned long I2CMasterErr(unsigned long ulBase)
/* Gets the error status of the I2C Master module. */ unsigned long I2CMasterErr(unsigned long ulBase)
{ unsigned long ulErr; xASSERT((ulBase == I2C1_BASE) || (ulBase == I2C2_BASE)); ulErr = xHWREG(ulBase + I2C_SR1); if(ulErr & (I2C_SR1_ARLO | I2C_SR1_AF | I2C_SR1_BERR)) { return(ulErr & (I2C_SR1_ARLO | I2C_SR1_AF | I2C_SR1_BERR)); } else { return(I2C_MASTER_ERR_NONE); } }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Analyse the changes in an effect, and tell if we need to send an effect packet */
static int need_core(struct ff_effect *old, struct ff_effect *new)
/* Analyse the changes in an effect, and tell if we need to send an effect packet */ static int need_core(struct ff_effect *old, struct ff_effect *new)
{ if (old->direction != new->direction || old->trigger.button != new->trigger.button || old->trigger.interval != new->trigger.interval || old->replay.length != new->replay.length || old->replay.delay != new->replay.delay) return 1; return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Sets the states of the RTS modem control signals and trigger level. The */
void UARTModemControlSet(unsigned long ulBase, unsigned long ulControl)
/* Sets the states of the RTS modem control signals and trigger level. The */ void UARTModemControlSet(unsigned long ulBase, unsigned long ulControl)
{ xASSERT(ulBase == UART0_BASE); xHWREG(ulBase + USART_MCR) &= ~(USART_MCR_DTR_L | USART_MCR_RTS_L); xHWREG(ulBase + USART_MCR) |= (ulControl); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Set Bitrate prescaler SWPMI_freq = SWPMI_clk / (((BitRate) + 1) * 4) @rmtoll BRR BR LL_SWPMI_SetBitRatePrescaler. */
void LL_SWPMI_SetBitRatePrescaler(SWPMI_TypeDef *SWPMIx, uint32_t BitRatePrescaler)
/* Set Bitrate prescaler SWPMI_freq = SWPMI_clk / (((BitRate) + 1) * 4) @rmtoll BRR BR LL_SWPMI_SetBitRatePrescaler. */ void LL_SWPMI_SetBitRatePrescaler(SWPMI_TypeDef *SWPMIx, uint32_t BitRatePrescaler)
{ WRITE_REG(SWPMIx->BRR, BitRatePrescaler); }
remotemcu/remcu-chip-sdks
C++
null
436
/* APIs to access CMPA pages Read data stored in 'Customer Factory CFG Page'. */
status_t FFR_GetCustomerData(flash_config_t *config, uint8_t *pData, uint32_t offset, uint32_t len)
/* APIs to access CMPA pages Read data stored in 'Customer Factory CFG Page'. */ status_t FFR_GetCustomerData(flash_config_t *config, uint8_t *pData, uint32_t offset, uint32_t len)
{ if (get_rom_api_version() == 0u) { assert(VERSION0_FLASH_API_TREE); return VERSION0_FLASH_API_TREE->ffr_get_customer_data(config, pData, offset, len); } else { assert(VERSION1_FLASH_API_TREE); return VERSION1_FLASH_API_TREE->ffr_get_customer_data(config, pData, offset, len); } }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* If 32-bit operations are not supported, 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 Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT32 EFIAPI BitFieldWrite32(IN UINT32 Operand, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 Value)
/* If 32-bit operations are not supported, 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 Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */ UINT32 EFIAPI BitFieldWrite32(IN UINT32 Operand, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 Value)
{ ASSERT (EndBit < 32); ASSERT (StartBit <= EndBit); return BitFieldAndThenOr32 (Operand, StartBit, EndBit, 0, Value); }
tianocore/edk2
C++
Other
4,240
/* This function changes properties of LEB @lnum. It is a helper wrapper over 'ubifs_change_lp()' which hides lprops get/release. The arguments are the same as in case of 'ubifs_change_lp()'. Returns zero in case of success and a negative error code in case of failure. */
int ubifs_change_one_lp(struct ubifs_info *c, int lnum, int free, int dirty, int flags_set, int flags_clean, int idx_gc_cnt)
/* This function changes properties of LEB @lnum. It is a helper wrapper over 'ubifs_change_lp()' which hides lprops get/release. The arguments are the same as in case of 'ubifs_change_lp()'. Returns zero in case of success and a negative error code in case of failure. */ int ubifs_change_one_lp(struct ubifs_info *c, int lnum, int free, int dirty, int flags_set, int flags_clean, int idx_gc_cnt)
{ int err = 0, flags; const struct ubifs_lprops *lp; ubifs_get_lprops(c); lp = ubifs_lpt_lookup_dirty(c, lnum); if (IS_ERR(lp)) { err = PTR_ERR(lp); goto out; } flags = (lp->flags | flags_set) & ~flags_clean; lp = ubifs_change_lp(c, lp, free, dirty, flags, idx_gc_cnt); if (IS_ERR(lp)) err = PTR_ERR(lp); out: ubifs_release_lprops(c); if (err) ubifs_err("cannot change properties of LEB %d, error %d", lnum, err); return err; }
robutest/uclinux
C++
GPL-2.0
60
/* This function disables USB HS PHY PLL clock. */
void CLOCK_DisableUsbhsPhyPllClock(void)
/* This function disables USB HS PHY PLL clock. */ void CLOCK_DisableUsbhsPhyPllClock(void)
{ USBPHY->CTRL |= USBPHY_CTRL_CLKGATE_MASK; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Function called from SPI2 IRQ Handler when RXNE flag is set Function is in charge of retrieving received byte from SPI lines. */
void SPI2_Rx_Callback(void)
/* Function called from SPI2 IRQ Handler when RXNE flag is set Function is in charge of retrieving received byte from SPI lines. */ void SPI2_Rx_Callback(void)
{ aRxBuffer[ubReceiveIndex++] = LL_SPI_ReceiveData8(SPI2); }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* phy_print_status - Convenience function to print out the current phy status @phydev: the phy_device struct */
void phy_print_status(struct phy_device *phydev)
/* phy_print_status - Convenience function to print out the current phy status @phydev: the phy_device struct */ void phy_print_status(struct phy_device *phydev)
{ pr_info("PHY: %s - Link is %s", dev_name(&phydev->dev), phydev->link ? "Up" : "Down"); if (phydev->link) printk(" - %d/%s", phydev->speed, DUPLEX_FULL == phydev->duplex ? "Full" : "Half"); printk("\n"); }
robutest/uclinux
C++
GPL-2.0
60
/* Sets a low output level on all the PIOs defined in the given Pin instance. This has no immediate effects on PIOs that are not output, but the PIO controller will memorize the value they are changed to outputs. */
void PIO_Clear(const Pin *pin)
/* Sets a low output level on all the PIOs defined in the given Pin instance. This has no immediate effects on PIOs that are not output, but the PIO controller will memorize the value they are changed to outputs. */ void PIO_Clear(const Pin *pin)
{ pin->pio->PIO_CODR = pin->mask; }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Event handler for the library USB Configuration Changed event. */
void EVENT_USB_Device_ConfigurationChanged(void)
/* Event handler for the library USB Configuration Changed event. */ void EVENT_USB_Device_ConfigurationChanged(void)
{ bool ConfigSuccess = true; ConfigSuccess &= Endpoint_ConfigureEndpoint(AVRISP_DATA_OUT_EPADDR, EP_TYPE_BULK, AVRISP_DATA_EPSIZE, 1); if ((AVRISP_DATA_IN_EPADDR & ENDPOINT_EPNUM_MASK) != (AVRISP_DATA_OUT_EPADDR & ENDPOINT_EPNUM_MASK)) ConfigSuccess &= Endpoint_ConfigureEndpoint(AVRISP_DATA_IN_EPADDR, EP_TYPE_BULK, AVRISP_DATA_EPSIZE, 1); LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR); }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* The exception table needs to be sorted so that the binary search that we use to find entries in it works properly. This is used both for the kernel exception table and for the exception tables of modules that get loaded. */
static int cmp_ex(const void *a, const void *b)
/* The exception table needs to be sorted so that the binary search that we use to find entries in it works properly. This is used both for the kernel exception table and for the exception tables of modules that get loaded. */ static int cmp_ex(const void *a, const void *b)
{ const struct exception_table_entry *x = a, *y = b; if (ex_to_addr(x) > ex_to_addr(y)) return 1; if (ex_to_addr(x) < ex_to_addr(y)) return -1; return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Block input and output are easy on shared memory ethercards, the only complication is when the ring buffer wraps. The count will already be rounded up to a doubleword value via lne390_get_8390_hdr() above. */
static void lne390_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset)
/* Block input and output are easy on shared memory ethercards, the only complication is when the ring buffer wraps. The count will already be rounded up to a doubleword value via lne390_get_8390_hdr() above. */ static void lne390_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset)
{ void __iomem *xfer_start = ei_status.mem + ring_offset - (LNE390_START_PG<<8); if (ring_offset + count > (LNE390_STOP_PG<<8)) { int semi_count = (LNE390_STOP_PG<<8) - ring_offset; memcpy_fromio(skb->data, xfer_start, semi_count); count -= semi_count; memcpy_fromio(skb->data + semi_count, ei_status.mem + (TX_PAGES<<8), count); } else { memcpy_fromio(skb->data, xfer_start, count); } }
robutest/uclinux
C++
GPL-2.0
60
/* The spin_unlock() itself is semi-permeable and only protects one way (it only protects stuff inside the critical region and stops them from bleeding out - it would still allow subsequent loads to move into the critical region). */
void prepare_to_wait(wait_queue_head_t *q, wait_queue_t *wait, int state)
/* The spin_unlock() itself is semi-permeable and only protects one way (it only protects stuff inside the critical region and stops them from bleeding out - it would still allow subsequent loads to move into the critical region). */ void prepare_to_wait(wait_queue_head_t *q, wait_queue_t *wait, int state)
{ unsigned long flags; wait->flags &= ~WQ_FLAG_EXCLUSIVE; spin_lock_irqsave(&q->lock, flags); if (list_empty(&wait->task_list)) __add_wait_queue(q, wait); set_current_state(state); spin_unlock_irqrestore(&q->lock, flags); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This function handles sEE DMA RX interrupt request. */
void EEPROM_I2C_DMA_RX_IRQHandler(void)
/* This function handles sEE DMA RX interrupt request. */ void EEPROM_I2C_DMA_RX_IRQHandler(void)
{ HAL_DMA_IRQHandler(heval_I2c.hdmarx); }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Start Broadcasting. This API is used to start the broadcast procedure. */
ADI_BLER_RESULT adi_radio_StartBroadcastProc(const uint16_t nBroadcastInterval)
/* Start Broadcasting. This API is used to start the broadcast procedure. */ ADI_BLER_RESULT adi_radio_StartBroadcastProc(const uint16_t nBroadcastInterval)
{ ADI_BLER_RESULT bleResult; ADI_BLE_LOGEVENT(LOGID_CMD_BLEGAP_START_BROADCAST); ADI_BLE_RADIO_CMD_START(CMD_BLEGAP_START_BROADCAST); ASSERT(nBroadcastInterval <= 0x4000u); ASSERT(nBroadcastInterval >= 0x00A0u); memcpy(&pBLERadio->cmdPkt[ADI_RADIO_CMD_HEADER_LEN], &nBroadcastInterval, 2u); bleResult = bler_process_cmd(CMD_BLEGAP_START_BROADCAST, 2u, 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
/* System reset should not return, if it returns, it means the system does not support warm reset. */
VOID EFIAPI ResetWarm(VOID)
/* System reset should not return, if it returns, it means the system does not support warm reset. */ VOID EFIAPI ResetWarm(VOID)
{ IoWrite8 (0x64, 0xfe); CpuDeadLoop (); }
tianocore/edk2
C++
Other
4,240
/* param base TDET peripheral base address param tamperTimeSeconds Time in seconds at which the tamper detection SR flag was set. return kStatus_Fail when Tamper Seconds Register reading is not allowed return kStatus_Success when Tamper Seconds Register is read */
status_t TDET_GetTamperTimeSeconds(DIGTMP_Type *base, uint32_t *tamperTimeSeconds)
/* param base TDET peripheral base address param tamperTimeSeconds Time in seconds at which the tamper detection SR flag was set. return kStatus_Fail when Tamper Seconds Register reading is not allowed return kStatus_Success when Tamper Seconds Register is read */ status_t TDET_GetTamperTimeSeconds(DIGTMP_Type *base, uint32_t *tamperTimeSeconds)
{ status_t status; if (tamperTimeSeconds != NULL) { *tamperTimeSeconds = base->TSR; status = kStatus_Success; } else { status = kStatus_Fail; } return status; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* If Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 16-bit boundary, then ASSERT(). If Length is not aligned on a 16-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). */
UINT16 EFIAPI CalculateCheckSum16(IN CONST UINT16 *Buffer, IN UINTN Length)
/* If Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 16-bit boundary, then ASSERT(). If Length is not aligned on a 16-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). */ UINT16 EFIAPI CalculateCheckSum16(IN CONST UINT16 *Buffer, IN UINTN Length)
{ UINT16 CheckSum; CheckSum = CalculateSum16 (Buffer, Length); return (UINT16)(0x10000 - CheckSum); }
tianocore/edk2
C++
Other
4,240
/* Notify the system that the SMM variable driver is ready. */
VOID VariableNotifySmmReady(VOID)
/* Notify the system that the SMM variable driver is ready. */ VOID VariableNotifySmmReady(VOID)
{ EFI_STATUS Status; EFI_HANDLE Handle; Handle = NULL; Status = gBS->InstallProtocolInterface ( &Handle, &gEfiSmmVariableProtocolGuid, EFI_NATIVE_INTERFACE, NULL ); ASSERT_EFI_ERROR (Status); }
tianocore/edk2
C++
Other
4,240
/* Boolean JSON value is kept as static value, and no need to do any cleanup work. */
EDKII_JSON_VALUE EFIAPI JsonValueInitBoolean(IN BOOLEAN Value)
/* Boolean JSON value is kept as static value, and no need to do any cleanup work. */ EDKII_JSON_VALUE EFIAPI JsonValueInitBoolean(IN BOOLEAN Value)
{ return (EDKII_JSON_VALUE)json_boolean (Value); }
tianocore/edk2
C++
Other
4,240
/* If the conversion results in an overflow or an underflow condition, then Result is set to INT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeInt32ToInt8(IN INT32 Operand, OUT INT8 *Result)
/* If the conversion results in an overflow or an underflow condition, then Result is set to INT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */ RETURN_STATUS EFIAPI SafeInt32ToInt8(IN INT32 Operand, OUT INT8 *Result)
{ RETURN_STATUS Status; if (Result == NULL) { return RETURN_INVALID_PARAMETER; } if ((Operand >= MIN_INT8) && (Operand <= MAX_INT8)) { *Result = (INT8)Operand; Status = RETURN_SUCCESS; } else { *Result = INT8_ERROR; Status = RETURN_BUFFER_TOO_SMALL; } return Status; }
tianocore/edk2
C++
Other
4,240
/* Free all memory and restore the system to the state it was in before calling CreatePopulateInstallShellProtocol. */
EFI_STATUS CleanUpShellProtocol(IN OUT EFI_SHELL_PROTOCOL *NewShell)
/* Free all memory and restore the system to the state it was in before calling CreatePopulateInstallShellProtocol. */ EFI_STATUS CleanUpShellProtocol(IN OUT EFI_SHELL_PROTOCOL *NewShell)
{ SHELL_PROTOCOL_HANDLE_LIST *Node2; if (!IsListEmpty (&ShellInfoObject.OldShellList.Link)) { for (Node2 = (SHELL_PROTOCOL_HANDLE_LIST *)GetFirstNode (&ShellInfoObject.OldShellList.Link) ; !IsListEmpty (&ShellInfoObject.OldShellList.Link) ; Node2 = (SHELL_PROTOCOL_HANDLE_LIST *)GetFirstNode (&ShellInfoObject.OldShellList.Link) ) { RemoveEntryList (&Node2->Link); gBS->ReinstallProtocolInterface (Node2->Handle, &gEfiShellProtocolGuid, NewShell, Node2->Interface); FreePool (Node2); } } else { gBS->UninstallProtocolInterface (gImageHandle, &gEfiShellProtocolGuid, NewShell); } return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Set the full display drawing limits. Use this function to set the full drawing limit box. */
void ili9325_set_limits(ili9325_coord_t start_x, ili9325_coord_t start_y, ili9325_coord_t end_x, ili9325_coord_t end_y)
/* Set the full display drawing limits. Use this function to set the full drawing limit box. */ void ili9325_set_limits(ili9325_coord_t start_x, ili9325_coord_t start_y, ili9325_coord_t end_x, ili9325_coord_t end_y)
{ limit_start_x = start_x; limit_start_y = start_y; limit_end_x = end_x; limit_end_y = end_y; ili9325_send_draw_limits(true); }
remotemcu/remcu-chip-sdks
C++
null
436
/* HUF_selectDecoder() : Tells which decoder is likely to decode faster, based on a set of pre-determined metrics. */
U32 HUF_selectDecoder(size_t dstSize, size_t cSrcSize)
/* HUF_selectDecoder() : Tells which decoder is likely to decode faster, based on a set of pre-determined metrics. */ U32 HUF_selectDecoder(size_t dstSize, size_t cSrcSize)
{ U32 const Q = (U32)(cSrcSize * 16 / dstSize); U32 const D256 = (U32)(dstSize >> 8); U32 const DTime0 = algoTime[Q][0].tableTime + (algoTime[Q][0].decode256Time * D256); U32 DTime1 = algoTime[Q][1].tableTime + (algoTime[Q][1].decode256Time * D256); DTime1 += DTime1 >> 3; return DTime1 < DTime0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Converts a text device path node to I20 device path structure. */
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextI2O(CHAR16 *TextDeviceNode)
/* Converts a text device path node to I20 device path structure. */ EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextI2O(CHAR16 *TextDeviceNode)
{ CHAR16 *TIDStr; I2O_DEVICE_PATH *I2ODevPath; TIDStr = GetNextParamStr (&TextDeviceNode); I2ODevPath = (I2O_DEVICE_PATH *) CreateDeviceNode ( MESSAGING_DEVICE_PATH, MSG_I2O_DP, (UINT16) sizeof (I2O_DEVICE_PATH) ); I2ODevPath->Tid = (UINT32) Strtoi (TIDStr); return (EFI_DEVICE_PATH_PROTOCOL *) I2ODevPath; }
tianocore/edk2
C++
Other
4,240
/* Converts a text device path node to Hardware Vendor device path structure. */
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextEmuFs(IN CHAR16 *TextDeviceNode)
/* Converts a text device path node to Hardware Vendor device path structure. */ EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextEmuFs(IN CHAR16 *TextDeviceNode)
{ CHAR16 *Str; EMU_VENDOR_DEVICE_PATH_NODE *Vendor; Str = GetNextParamStr (&TextDeviceNode); Vendor = (EMU_VENDOR_DEVICE_PATH_NODE *)CreateDeviceNode ( HARDWARE_DEVICE_PATH, HW_VENDOR_DP, (UINT16)sizeof (EMU_VENDOR_DEVICE_PATH_NODE) ); CopyGuid (&Vendor->VendorDevicePath.Guid, &gEfiSimpleFileSystemProtocolGuid); Vendor->Instance = (UINT32)StrDecimalToUintn (Str); return (EFI_DEVICE_PATH_PROTOCOL *)Vendor; }
tianocore/edk2
C++
Other
4,240
/* We have no generic implementation of a non destructive write to the user address. We know that we faulted in the atomic pagefault disabled section so we can as well avoid the #PF overhead by calling get_user_pages() right away. */
static int fault_in_user_writeable(u32 __user *uaddr)
/* We have no generic implementation of a non destructive write to the user address. We know that we faulted in the atomic pagefault disabled section so we can as well avoid the #PF overhead by calling get_user_pages() right away. */ static int fault_in_user_writeable(u32 __user *uaddr)
{ struct mm_struct *mm = current->mm; int ret; down_read(&mm->mmap_sem); ret = get_user_pages(current, mm, (unsigned long)uaddr, 1, 1, 0, NULL, NULL); up_read(&mm->mmap_sem); return ret < 0 ? ret : 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Removes all the #GHook elements from a #GHookList. */
void g_hook_list_clear(GHookList *hook_list)
/* Removes all the #GHook elements from a #GHookList. */ void g_hook_list_clear(GHookList *hook_list)
{ g_return_if_fail (hook_list != NULL); if (hook_list->is_setup) { GHook *hook; hook_list->is_setup = FALSE; hook = hook_list->hooks; if (!hook) { } else do { GHook *tmp; g_hook_ref (hook_list, hook); g_hook_destroy_link (hook_list, hook); tmp = hook->next; g_hook_unref (hook_list, hook); hook = tmp; } while (hook); } }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* param base PMU peripheral base address. param mode The control mode of the Bandgap Reference. Please refer to pmu_control_mode_t. */
void PMU_SetBandgapControlMode(ANADIG_PMU_Type *base, pmu_control_mode_t mode)
/* param base PMU peripheral base address. param mode The control mode of the Bandgap Reference. Please refer to pmu_control_mode_t. */ void PMU_SetBandgapControlMode(ANADIG_PMU_Type *base, pmu_control_mode_t mode)
{ if (mode == kPMU_StaticMode) { base->PMU_REF_CTRL &= ~ANADIG_PMU_PMU_REF_CTRL_REF_CONTROL_MODE_MASK; } else { base->PMU_REF_CTRL |= ANADIG_PMU_PMU_REF_CTRL_REF_CONTROL_MODE_MASK; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Wait for a client connection to the server. */
WIFI_Status_t WIFI_WaitServerConnection(int socket, uint32_t Timeout, uint8_t *RemoteIp, uint16_t *RemotePort)
/* Wait for a client connection to the server. */ WIFI_Status_t WIFI_WaitServerConnection(int socket, uint32_t Timeout, uint8_t *RemoteIp, uint16_t *RemotePort)
{ ES_WIFI_Conn_t conn; ES_WIFI_Status_t ret; conn.Number = socket; ret = ES_WIFI_WaitServerConnection(&EsWifiObj,Timeout,&conn); if (ES_WIFI_STATUS_OK == ret) { if (RemotePort) *RemotePort=conn.RemotePort; if (RemoteIp) { memcpy(RemoteIp,conn.RemoteIP,sizeof(conn.RemoteIP)); } return WIFI_STATUS_OK; } if (ES_WIFI_STATUS_TIMEOUT ==ret) { if (RemotePort) *RemotePort=0; if (RemoteIp) { memset(RemoteIp,0,sizeof(conn.RemoteIP)); } return WIFI_STATUS_TIMEOUT; } return WIFI_STATUS_ERROR; }
eclipse-threadx/getting-started
C++
Other
310
/* Enables AHB1 peripheral clock during Low Power (Sleep) mode. */
void RCM_EnableAHB1PeriphClockLPMode(uint32_t AHB1Periph)
/* Enables AHB1 peripheral clock during Low Power (Sleep) mode. */ void RCM_EnableAHB1PeriphClockLPMode(uint32_t AHB1Periph)
{ RCM->LPAHB1CLKEN |= AHB1Periph; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Set the full display drawing limits. Use this function to set the full drawing limit box. */
void ili9341_set_limits(ili9341_coord_t start_x, ili9341_coord_t start_y, ili9341_coord_t end_x, ili9341_coord_t end_y)
/* Set the full display drawing limits. Use this function to set the full drawing limit box. */ void ili9341_set_limits(ili9341_coord_t start_x, ili9341_coord_t start_y, ili9341_coord_t end_x, ili9341_coord_t end_y)
{ limit_start_x = start_x; limit_start_y = start_y; limit_end_x = end_x; limit_end_y = end_y; ili9341_send_draw_limits(true); }
remotemcu/remcu-chip-sdks
C++
null
436
/* eth_header_cache - fill cache entry from neighbour @neigh: source neighbour @hh: destination cache entry Create an Ethernet header template from the neighbour. */
int eth_header_cache(const struct neighbour *neigh, struct hh_cache *hh)
/* eth_header_cache - fill cache entry from neighbour @neigh: source neighbour @hh: destination cache entry Create an Ethernet header template from the neighbour. */ int eth_header_cache(const struct neighbour *neigh, struct hh_cache *hh)
{ __be16 type = hh->hh_type; struct ethhdr *eth; const struct net_device *dev = neigh->dev; eth = (struct ethhdr *) (((u8 *) hh->hh_data) + (HH_DATA_OFF(sizeof(*eth)))); if (type == htons(ETH_P_802_3)) return -1; eth->h_proto = type; memcpy(eth->h_source, dev->dev_addr, ETH_ALEN); memcpy(eth->h_dest, neigh->ha, ETH_ALEN); hh->hh_len = ETH_HLEN; return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* get the current register value of WM codec */
static unsigned short wm_get(struct snd_ice1712 *ice, int reg)
/* get the current register value of WM codec */ static unsigned short wm_get(struct snd_ice1712 *ice, int reg)
{ reg <<= 1; return ((unsigned short)ice->akm[0].images[reg] << 8) | ice->akm[0].images[reg + 1]; }
robutest/uclinux
C++
GPL-2.0
60
/* This function is called when a user space program attempts to read /dev/nwbutton. It puts the device to sleep on the wait queue until button_sequence_finished writes some data to the buffer and flushes the queue, at which point it writes the data out to the device and returns the number of characters it has written. This function is reentrant, so that many processes can be attempting to read from the device at any one time. */
static int button_read(struct file *filp, char __user *buffer, size_t count, loff_t *ppos)
/* This function is called when a user space program attempts to read /dev/nwbutton. It puts the device to sleep on the wait queue until button_sequence_finished writes some data to the buffer and flushes the queue, at which point it writes the data out to the device and returns the number of characters it has written. This function is reentrant, so that many processes can be attempting to read from the device at any one time. */ static int button_read(struct file *filp, char __user *buffer, size_t count, loff_t *ppos)
{ interruptible_sleep_on (&button_wait_queue); return (copy_to_user (buffer, &button_output_buffer, bcount)) ? -EFAULT : bcount; }
robutest/uclinux
C++
GPL-2.0
60
/* Set TIMER0 module enable. Enable the TIMER0 module */
void timer_enable(void)
/* Set TIMER0 module enable. Enable the TIMER0 module */ void timer_enable(void)
{ TIMER0->CTRL.reg |= TIMER_CTRL_ENABLE; }
memfault/zero-to-main
C++
null
200
/* tipc_shutdown(): Send a SHUTDOWN msg to peer and disconnect */
int tipc_shutdown(u32 ref)
/* tipc_shutdown(): Send a SHUTDOWN msg to peer and disconnect */ int tipc_shutdown(u32 ref)
{ struct port *p_ptr; struct sk_buff *buf = NULL; p_ptr = tipc_port_lock(ref); if (!p_ptr) return -EINVAL; if (p_ptr->publ.connected) { u32 imp = msg_importance(&p_ptr->publ.phdr); if (imp < TIPC_CRITICAL_IMPORTANCE) imp++; buf = port_build_proto_msg(port_peerport(p_ptr), port_peernode(p_ptr), ref, tipc_own_addr, imp, TIPC_CONN_MSG, TIPC_CONN_SHUTDOWN, port_out_seqno(p_ptr), 0); } tipc_port_unlock(p_ptr); tipc_net_route_msg(buf); return tipc_disconnect(ref); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT(). */
UINT8* EFIAPI MmioWriteBuffer8(IN UINTN StartAddress, IN UINTN Length, IN CONST UINT8 *Buffer)
/* If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT(). */ UINT8* EFIAPI MmioWriteBuffer8(IN UINTN StartAddress, IN UINTN Length, IN CONST UINT8 *Buffer)
{ VOID *ReturnBuffer; ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress)); ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); ReturnBuffer = (UINT8 *)Buffer; while (Length-- != 0) { MmioWrite8 (StartAddress++, *(Buffer++)); } return ReturnBuffer; }
tianocore/edk2
C++
Other
4,240
/* Check whether the DestinationAddress is an anycast address. */
BOOLEAN Ip6IsAnycast(IN IP6_SERVICE *IpSb, IN EFI_IPv6_ADDRESS *DestinationAddress)
/* Check whether the DestinationAddress is an anycast address. */ BOOLEAN Ip6IsAnycast(IN IP6_SERVICE *IpSb, IN EFI_IPv6_ADDRESS *DestinationAddress)
{ IP6_PREFIX_LIST_ENTRY *PrefixEntry; EFI_IPv6_ADDRESS Prefix; BOOLEAN Flag; ZeroMem (&Prefix, sizeof (EFI_IPv6_ADDRESS)); Flag = FALSE; do { PrefixEntry = Ip6FindPrefixListEntry (IpSb, Flag, 255, DestinationAddress); if (PrefixEntry != NULL) { IP6_COPY_ADDRESS (&Prefix, &PrefixEntry->Prefix); Ip6GetPrefix (PrefixEntry->PrefixLength, &Prefix); if (EFI_IP6_EQUAL (&Prefix, DestinationAddress)) { return TRUE; } } Flag = (BOOLEAN) !Flag; } while (Flag); return FALSE; }
tianocore/edk2
C++
Other
4,240
/* @key: registration key Return: valid registration key or NULL */
static struct efi_register_notify_event* efi_check_register_notify_event(void *key)
/* @key: registration key Return: valid registration key or NULL */ static struct efi_register_notify_event* efi_check_register_notify_event(void *key)
{ struct efi_register_notify_event *event; list_for_each_entry(event, &efi_register_notify_events, link) { if (event == (struct efi_register_notify_event *)key) return event; } return NULL; }
4ms/stm32mp1-baremetal
C++
Other
137
/* This function must not be called if the LIDD interface is currently configured to expect DMA transactions. If DMA was previously used to write to the panel, */
uint16_t LCDIDDIndexedRead(uint32_t ui32Base, uint32_t ui32CS, uint16_t ui16Addr)
/* This function must not be called if the LIDD interface is currently configured to expect DMA transactions. If DMA was previously used to write to the panel, */ uint16_t LCDIDDIndexedRead(uint32_t ui32Base, uint32_t ui32CS, uint16_t ui16Addr)
{ uint32_t ui32Addr; ASSERT(ui32Base == LCD0_BASE); ASSERT((ui32CS == 0) || (ui32CS == 1)); ui32Addr = ui32CS ? LCD_O_LIDDCS1ADDR : LCD_O_LIDDCS0ADDR; HWREG(ui32Base + ui32Addr) = ui16Addr; ui32Addr = ui32CS ? LCD_O_LIDDCS1DATA : LCD_O_LIDDCS0DATA; return ((uint16_t)HWREG(ui32Base + ui32Addr)); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Check that the version is within the supported range, otherwise warn about it. */
static gshort c_warn_ver(proto_item *ti, gint act, gint min, gint max, c_pkt_data *data)
/* Check that the version is within the supported range, otherwise warn about it. */ static gshort c_warn_ver(proto_item *ti, gint act, gint min, gint max, c_pkt_data *data)
{ DISSECTOR_ASSERT_CMPINT(min, <=, max); if (act < min) { expert_add_info_format(data->pinfo, ti, &ei_ver_tooold, "Version %d is lower then the minimum " "supported version (%d).", act, min); return -1; } if (act > max) { expert_add_info_format(data->pinfo, ti, &ei_ver_toonew, "Version %d is higher then the maximum " "supported version (%d).", act, max); return 1; } return 0; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This function waits for a sync signal of the specific sync object. */
OsiReturnVal_e osi_SyncObjWait(OsiSyncObj_t *pSyncObj, OsiTime_t Timeout)
/* This function waits for a sync signal of the specific sync object. */ OsiReturnVal_e osi_SyncObjWait(OsiSyncObj_t *pSyncObj, OsiTime_t Timeout)
{ if(pdTRUE == xSemaphoreTake( (SemaphoreHandle_t)*pSyncObj, ( TickType_t )Timeout)) { return OSI_OK; } else { return OSI_OPERATION_FAILED; } }
micropython/micropython
C++
Other
18,334
/* Accepts an array of octets as the next portion of the message. */
void ICACHE_FLASH_ATTR SHA384_Update(SHA384_CTX *ctx, const uint8_t *msg, int len)
/* Accepts an array of octets as the next portion of the message. */ void ICACHE_FLASH_ATTR SHA384_Update(SHA384_CTX *ctx, const uint8_t *msg, int len)
{ SHA512_Update(ctx, msg, len); }
eerimoq/simba
C++
Other
337
/* Wake up users waiting for IO so they can disconnect from dead device. */
static void evdev_hangup(struct evdev *evdev)
/* Wake up users waiting for IO so they can disconnect from dead device. */ static void evdev_hangup(struct evdev *evdev)
{ struct evdev_client *client; spin_lock(&evdev->client_lock); list_for_each_entry(client, &evdev->client_list, node) kill_fasync(&client->fasync, SIGIO, POLL_HUP); spin_unlock(&evdev->client_lock); wake_up_interruptible(&evdev->wait); }
robutest/uclinux
C++
GPL-2.0
60
/* Task to read in data received from the attached CDC device and print it to the serial port. */
void CDCHost_Task(void)
/* Task to read in data received from the attached CDC device and print it to the serial port. */ void CDCHost_Task(void)
{ if (USB_HostState != HOST_STATE_Configured) return; Pipe_SelectPipe(CDC_DATA_IN_PIPE); Pipe_Unfreeze(); if (Pipe_IsINReceived()) { Pipe_Freeze(); if (Pipe_IsReadWriteAllowed()) { uint16_t BufferLength = Pipe_BytesInPipe(); uint8_t Buffer[BufferLength]; Pipe_Read_Stream_LE(Buffer, BufferLength, NULL); for (uint16_t BufferByte = 0; BufferByte < BufferLength; BufferByte++) putchar(Buffer[BufferByte]); } Pipe_ClearIN(); } Pipe_Freeze(); Pipe_SelectPipe(CDC_NOTIFICATION_PIPE); Pipe_Unfreeze(); if (Pipe_IsINReceived()) { Pipe_ClearIN(); } Pipe_Freeze(); }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* This function re-names or removes volumes specified in the re-name list. Returns zero in case of success and a negative error code in case of failure. */
int ubi_rename_volumes(struct ubi_device *ubi, struct list_head *rename_list)
/* This function re-names or removes volumes specified in the re-name list. Returns zero in case of success and a negative error code in case of failure. */ int ubi_rename_volumes(struct ubi_device *ubi, struct list_head *rename_list)
{ int err; struct ubi_rename_entry *re; err = ubi_vtbl_rename_volumes(ubi, rename_list); if (err) return err; list_for_each_entry(re, rename_list, list) { if (re->remove) { err = ubi_remove_volume(re->desc, 1); if (err) break; } else { struct ubi_volume *vol = re->desc->vol; spin_lock(&ubi->volumes_lock); vol->name_len = re->new_name_len; memcpy(vol->name, re->new_name, re->new_name_len + 1); spin_unlock(&ubi->volumes_lock); ubi_volume_notify(ubi, vol, UBI_VOLUME_RENAMED); } } if (!err) self_check_volumes(ubi); return err; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Wait PHY operation complete. Return 1 if the operation completed successfully. May be need to re-implemented to reduce CPU load. */
static unsigned char EMAC_WaitPhy(unsigned int retry)
/* Wait PHY operation complete. Return 1 if the operation completed successfully. May be need to re-implemented to reduce CPU load. */ static unsigned char EMAC_WaitPhy(unsigned int retry)
{ unsigned int retry_count = 0; while((AT91C_BASE_EMAC->EMAC_NSR & AT91C_EMAC_IDLE) == 0) { if (retry == 0) { continue; } retry_count++; if(retry_count >= retry) { TRACE_ERROR("E: Wait PHY time out\n\r"); return 0; } } return 1; }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* dev_set_name - set a device name @dev: device @fmt: format string for the device's name */
int dev_set_name(struct device *dev, const char *fmt,...)
/* dev_set_name - set a device name @dev: device @fmt: format string for the device's name */ int dev_set_name(struct device *dev, const char *fmt,...)
{ va_list vargs; int err; va_start(vargs, fmt); err = kobject_set_name_vargs(&dev->kobj, fmt, vargs); va_end(vargs); return err; }
robutest/uclinux
C++
GPL-2.0
60
/* Function for initializing services that will be used by the application. */
static void services_init(void)
/* Function for initializing services that will be used by the application. */ static void services_init(void)
{ uint32_t err_code; ble_dfu_init_t dfu_init_obj; memset(&dfu_init_obj, 0, sizeof(dfu_init_obj)); dfu_init_obj.revision = DFU_REVISION; dfu_init_obj.evt_handler = on_dfu_evt; dfu_init_obj.error_handler = service_error_handler; err_code = ble_dfu_init(&m_dfu, &dfu_init_obj); APP_ERROR_CHECK(err_code); }
labapart/polymcu
C++
null
201
/* Check whether an abstract address object is shared. */
int nl_addr_shared(struct nl_addr *addr)
/* Check whether an abstract address object is shared. */ int nl_addr_shared(struct nl_addr *addr)
{ return addr->a_refcnt > 1; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Create buffers for the specified block device block's page. If that page was dirty, the buffers are set dirty also. */
static int grow_buffers(struct block_device *bdev, sector_t block, int size)
/* Create buffers for the specified block device block's page. If that page was dirty, the buffers are set dirty also. */ static int grow_buffers(struct block_device *bdev, sector_t block, int size)
{ struct page *page; pgoff_t index; int sizebits; sizebits = -1; do { sizebits++; } while ((size << sizebits) < PAGE_SIZE); index = block >> sizebits; if (unlikely(index != block >> sizebits)) { char b[BDEVNAME_SIZE]; printk(KERN_ERR "%s: requested out-of-range block %llu for " "device %s\n", __func__, (unsigned long long)block, bdevname(bdev, b)); return -EIO; } block = index << sizebits; page = grow_dev_page(bdev, block, index, size); if (!page) return 0; unlock_page(page); page_cache_release(page); return 1; }
robutest/uclinux
C++
GPL-2.0
60
/* vpfe_remove : It un-register device from V4L2 driver */
static int __devexit vpfe_remove(struct platform_device *pdev)
/* vpfe_remove : It un-register device from V4L2 driver */ static int __devexit vpfe_remove(struct platform_device *pdev)
{ struct vpfe_device *vpfe_dev = platform_get_drvdata(pdev); struct resource *res; v4l2_info(pdev->dev.driver, "vpfe_remove\n"); free_irq(vpfe_dev->ccdc_irq0, vpfe_dev); kfree(vpfe_dev->sd); v4l2_device_unregister(&vpfe_dev->v4l2_dev); video_unregister_device(vpfe_dev->video_dev); mutex_lock(&ccdc_lock); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); release_mem_region(res->start, res->end - res->start + 1); iounmap(ccdc_cfg->ccdc_addr); mutex_unlock(&ccdc_lock); vpfe_disable_clock(vpfe_dev); kfree(vpfe_dev); kfree(ccdc_cfg); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Note: it takes about as long to flash all sectors together with Chip Erase as it does to flash them one at a time (about 30 seconds for 2 MB). Also since we want to be able to treat subsets of sectors as if they were complete devices, we don't use Chip Erase. */
STATUS flashErase(flash_dev_t *dev)
/* Note: it takes about as long to flash all sectors together with Chip Erase as it does to flash them one at a time (about 30 seconds for 2 MB). Also since we want to be able to treat subsets of sectors as if they were complete devices, we don't use Chip Erase. */ STATUS flashErase(flash_dev_t *dev)
{ int sector; PRINTF ("flashErase: dev=%d sectors=%d\n", DEV_NO (dev), dev->sectors); if (flashCheck (dev) == ERROR) return ERROR; for (sector = 0; sector < dev->sectors; sector++) { if (flashEraseSector (dev, sector) == ERROR) return ERROR; } return OK; }
EmcraftSystems/u-boot
C++
Other
181
/* Sets the control parameters for a DMA channel. Choose the the Circular mode from one of */
void DMAChannelControlSet(unsigned long ulChannelID, unsigned long ulControl)
/* Sets the control parameters for a DMA channel. Choose the the Circular mode from one of */ void DMAChannelControlSet(unsigned long ulChannelID, unsigned long ulControl)
{ unsigned long ulTmpReg = 0 ; unsigned long ulRegMask = ( DMA_MEM_WIDTH_8BIT | DMA_MEM_WIDTH_16BIT | DMA_MEM_WIDTH_32BIT | DMA_PER_WIDTH_8BIT | DMA_PER_WIDTH_16BIT | DMA_PER_WIDTH_32BIT | DMA_MEM_DIR_INC | DMA_MEM_DIR_FIXED | DMA_PER_DIR_INC | DMA_PER_DIR_FIXED | DMA_MODE_CIRC_EN | DMA_MODE_CIRC_DIS ); xASSERT(xDMAChannelIDValid(ulChannelID)); xASSERT((ulControl & ulRegMask) != 0); ulTmpReg = xHWREG(g_psDMAChannel[ulChannelID]); ulTmpReg &= ~ulRegMask; ulTmpReg |= ulControl; xHWREG(g_psDMAChannel[ulChannelID]) = ulTmpReg; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Enable or disable an SGE egress context. The caller is responsible for ensuring only one context operation occurs at a time. */
int t3_sge_enable_ecntxt(struct adapter *adapter, unsigned int id, int enable)
/* Enable or disable an SGE egress context. The caller is responsible for ensuring only one context operation occurs at a time. */ int t3_sge_enable_ecntxt(struct adapter *adapter, unsigned int id, int enable)
{ if (t3_read_reg(adapter, A_SG_CONTEXT_CMD) & F_CONTEXT_CMD_BUSY) return -EBUSY; t3_write_reg(adapter, A_SG_CONTEXT_MASK0, 0); t3_write_reg(adapter, A_SG_CONTEXT_MASK1, 0); t3_write_reg(adapter, A_SG_CONTEXT_MASK2, 0); t3_write_reg(adapter, A_SG_CONTEXT_MASK3, F_EC_VALID); t3_write_reg(adapter, A_SG_CONTEXT_DATA3, V_EC_VALID(enable)); t3_write_reg(adapter, A_SG_CONTEXT_CMD, V_CONTEXT_CMD_OPCODE(1) | F_EGRESS | V_CONTEXT(id)); return t3_wait_op_done(adapter, A_SG_CONTEXT_CMD, F_CONTEXT_CMD_BUSY, 0, SG_CONTEXT_CMD_ATTEMPTS, 1); }
robutest/uclinux
C++
GPL-2.0
60
/* If AesContext is NULL, then return FALSE. If Input is NULL, then return FALSE. If InputSize is not multiple of block size (16 bytes), then return FALSE. If Ivec is NULL, then return FALSE. If Output is NULL, then return FALSE. */
BOOLEAN EFIAPI AesCbcEncrypt(IN VOID *AesContext, IN CONST UINT8 *Input, IN UINTN InputSize, IN CONST UINT8 *Ivec, OUT UINT8 *Output)
/* If AesContext is NULL, then return FALSE. If Input is NULL, then return FALSE. If InputSize is not multiple of block size (16 bytes), then return FALSE. If Ivec is NULL, then return FALSE. If Output is NULL, then return FALSE. */ BOOLEAN EFIAPI AesCbcEncrypt(IN VOID *AesContext, IN CONST UINT8 *Input, IN UINTN InputSize, IN CONST UINT8 *Ivec, OUT UINT8 *Output)
{ mbedtls_aes_context *AesCtx; UINT8 IvecBuffer[AES_BLOCK_SIZE]; if ((AesContext == NULL) || (Input == NULL) || ((InputSize % AES_BLOCK_SIZE) != 0)) { return FALSE; } if ((Ivec == NULL) || (Output == NULL) || (InputSize > INT_MAX)) { return FALSE; } AesCtx = (mbedtls_aes_context *)AesContext; CopyMem (IvecBuffer, Ivec, AES_BLOCK_SIZE); if (mbedtls_aes_crypt_cbc ( AesCtx, MBEDTLS_AES_ENCRYPT, (UINT32)InputSize, IvecBuffer, Input, Output ) != 0) { return FALSE; } else { return TRUE; } }
tianocore/edk2
C++
Other
4,240
/* This service enables PEIMs to register a given service to be invoked when another service is installed or reinstalled. */
EFI_STATUS EFIAPI PeiServicesNotifyPpi(IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList)
/* This service enables PEIMs to register a given service to be invoked when another service is installed or reinstalled. */ EFI_STATUS EFIAPI PeiServicesNotifyPpi(IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList)
{ CONST EFI_PEI_SERVICES **PeiServices; PeiServices = GetPeiServicesTablePointer (); return (*PeiServices)->NotifyPpi (PeiServices, NotifyList); }
tianocore/edk2
C++
Other
4,240
/* Description: Perform a label mapping to translate a local MLS category bitmap to the correct CIPSO category list using the given DOI definition. Returns the size in bytes of the network category bitmap on success, negative values otherwise. */
static int cipso_v4_map_cat_enum_hton(const struct cipso_v4_doi *doi_def, const struct netlbl_lsm_secattr *secattr, unsigned char *net_cat, u32 net_cat_len)
/* Description: Perform a label mapping to translate a local MLS category bitmap to the correct CIPSO category list using the given DOI definition. Returns the size in bytes of the network category bitmap on success, negative values otherwise. */ static int cipso_v4_map_cat_enum_hton(const struct cipso_v4_doi *doi_def, const struct netlbl_lsm_secattr *secattr, unsigned char *net_cat, u32 net_cat_len)
{ int cat = -1; u32 cat_iter = 0; for (;;) { cat = netlbl_secattr_catmap_walk(secattr->attr.mls.cat, cat + 1); if (cat < 0) break; if ((cat_iter + 2) > net_cat_len) return -ENOSPC; *((__be16 *)&net_cat[cat_iter]) = htons(cat); cat_iter += 2; } return cat_iter; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* ECR is reset in a sane state (interrupts and DMA disabled), and placed in mode @mode. Go through PS2 mode if needed. */
static void parport_ip32_set_mode(struct parport *p, unsigned int mode)
/* ECR is reset in a sane state (interrupts and DMA disabled), and placed in mode @mode. Go through PS2 mode if needed. */ static void parport_ip32_set_mode(struct parport *p, unsigned int mode)
{ unsigned int omode; mode &= ECR_MODE_MASK; omode = parport_ip32_read_econtrol(p) & ECR_MODE_MASK; if (!(mode == ECR_MODE_SPP || mode == ECR_MODE_PS2 || omode == ECR_MODE_SPP || omode == ECR_MODE_PS2)) { unsigned int ecr = ECR_MODE_PS2 | ECR_nERRINTR | ECR_SERVINTR; parport_ip32_write_econtrol(p, ecr); } parport_ip32_write_econtrol(p, mode | ECR_nERRINTR | ECR_SERVINTR); }
robutest/uclinux
C++
GPL-2.0
60
/* scsi_proc_host_add - Add entry for this host to appropriate /proc dir @shost: host to add */
void scsi_proc_host_add(struct Scsi_Host *shost)
/* scsi_proc_host_add - Add entry for this host to appropriate /proc dir @shost: host to add */ void scsi_proc_host_add(struct Scsi_Host *shost)
{ struct scsi_host_template *sht = shost->hostt; struct proc_dir_entry *p; char name[10]; if (!sht->proc_dir) return; sprintf(name,"%d", shost->host_no); p = create_proc_read_entry(name, S_IFREG | S_IRUGO | S_IWUSR, sht->proc_dir, proc_scsi_read, shost); if (!p) { printk(KERN_ERR "%s: Failed to register host %d in" "%s\n", __func__, shost->host_no, sht->proc_name); return; } p->write_proc = proc_scsi_write_proc; }
robutest/uclinux
C++
GPL-2.0
60
/* Read the specified SMC interrupt has occurred or not. */
uint16_t SMC_ReadIntFlag(SMC_BANK_NAND_T bank, SMC_INT_T flag)
/* Read the specified SMC interrupt has occurred or not. */ uint16_t SMC_ReadIntFlag(SMC_BANK_NAND_T bank, SMC_INT_T flag)
{ uint32_t tmpStatus = 0x0, itstatus = 0x0, itenable = 0x0; if (bank == SMC_BANK2_NAND) { tmpStatus = SMC_Bank2->STSINT2; } else if (bank == SMC_BANK3_NAND) { tmpStatus = SMC_Bank3->STSINT3; } else { tmpStatus = SMC_Bank4->STSINT4; } itstatus = tmpStatus & flag; itenable = tmpStatus & (flag >> 3); if ((itstatus != RESET) && (itenable != RESET)) { return SET; } else { return RESET; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Called from the receive_buf path so single threaded. Does not need locking as num_overrun and overrun_time are function private. */
static void n_tty_receive_overrun(struct tty_struct *tty)
/* Called from the receive_buf path so single threaded. Does not need locking as num_overrun and overrun_time are function private. */ static void n_tty_receive_overrun(struct tty_struct *tty)
{ char buf[64]; tty->num_overrun++; if (time_before(tty->overrun_time, jiffies - HZ) || time_after(tty->overrun_time, jiffies)) { printk(KERN_WARNING "%s: %d input overrun(s)\n", tty_name(tty, buf), tty->num_overrun); tty->overrun_time = jiffies; tty->num_overrun = 0; } }
robutest/uclinux
C++
GPL-2.0
60
/* Utility procedures to print a buffer in hex/ascii */
static void ppp_print_hex(register __u8 *out, const __u8 *in, int count)
/* Utility procedures to print a buffer in hex/ascii */ static void ppp_print_hex(register __u8 *out, const __u8 *in, int count)
{ register __u8 next_ch; static const char hex[] = "0123456789ABCDEF"; while (count-- > 0) { next_ch = *in++; *out++ = hex[(next_ch >> 4) & 0x0F]; *out++ = hex[next_ch & 0x0F]; ++out; } }
robutest/uclinux
C++
GPL-2.0
60
/* FREE_ALL: Release all locks and shares held by client */
static __be32 nlm4svc_proc_free_all(struct svc_rqst *rqstp, struct nlm_args *argp, void *resp)
/* FREE_ALL: Release all locks and shares held by client */ static __be32 nlm4svc_proc_free_all(struct svc_rqst *rqstp, struct nlm_args *argp, void *resp)
{ struct nlm_host *host; if (nlm4svc_retrieve_args(rqstp, argp, &host, NULL)) return rpc_success; nlmsvc_free_host_resources(host); nlm_release_host(host); return rpc_success; }
robutest/uclinux
C++
GPL-2.0
60
/* This will search for a matching channel:id in the scsi_lookup array, returning 1 if found. */
static u8 _scsih_scsi_lookup_find_by_target(struct MPT2SAS_ADAPTER *ioc, int id, int channel)
/* This will search for a matching channel:id in the scsi_lookup array, returning 1 if found. */ static u8 _scsih_scsi_lookup_find_by_target(struct MPT2SAS_ADAPTER *ioc, int id, int channel)
{ u8 found; unsigned long flags; int i; spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); found = 0; for (i = 0 ; i < ioc->scsiio_depth; i++) { if (ioc->scsi_lookup[i].scmd && (ioc->scsi_lookup[i].scmd->device->id == id && ioc->scsi_lookup[i].scmd->device->channel == channel)) { found = 1; goto out; } } out: spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); return found; }
robutest/uclinux
C++
GPL-2.0
60
/* dccp_determine_ccmps - Find out about CCID-specfic packet-size limits We only consider the HC-sender CCID for setting the CCMPS (RFC 4340, 14.), since the RX CCID is restricted to feedback packets (Acks), which are small in comparison with the data traffic. A value of 0 means "no current CCMPS". */
static u32 dccp_determine_ccmps(const struct dccp_sock *dp)
/* dccp_determine_ccmps - Find out about CCID-specfic packet-size limits We only consider the HC-sender CCID for setting the CCMPS (RFC 4340, 14.), since the RX CCID is restricted to feedback packets (Acks), which are small in comparison with the data traffic. A value of 0 means "no current CCMPS". */ static u32 dccp_determine_ccmps(const struct dccp_sock *dp)
{ const struct ccid *tx_ccid = dp->dccps_hc_tx_ccid; if (tx_ccid == NULL || tx_ccid->ccid_ops == NULL) return 0; return tx_ccid->ccid_ops->ccid_ccmps; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This is written in C rather than assembly since, during the port bring up, Zephyr is being booted by the Espressif bootloader. With it, the C stack is already set up. */
void __app_cpu_start(void)
/* This is written in C rather than assembly since, during the port bring up, Zephyr is being booted by the Espressif bootloader. With it, the C stack is already set up. */ void __app_cpu_start(void)
{ extern uint32_t _init_start; extern uint32_t _bss_start; extern uint32_t _bss_end; __asm__ __volatile__ ( "wsr %0, vecbase" : : "r"(&_init_start)); z_bss_zero(); __asm__ __volatile__ ( "" : : "g"(&__bss_start) : "memory"); __asm__ __volatile__ ( "wsr %0, PS" : : "r"(PS_INTLEVEL(XCHAL_EXCM_LEVEL) | PS_UM | PS_WOE)); __asm__ volatile("wsr.MISC0 %0; rsync" : : "r"(&_kernel.cpus[0])); esp_intr_initialize(); z_cstart(); CODE_UNREACHABLE; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* This function seraches for gluebi device corresponding to UBI device @ubi_num and UBI volume @vol_id. Returns the gluebi device description object in case of success and NULL in case of failure. The caller has to have the &devices_mutex locked. */
static struct gluebi_device* find_gluebi_nolock(int ubi_num, int vol_id)
/* This function seraches for gluebi device corresponding to UBI device @ubi_num and UBI volume @vol_id. Returns the gluebi device description object in case of success and NULL in case of failure. The caller has to have the &devices_mutex locked. */ static struct gluebi_device* find_gluebi_nolock(int ubi_num, int vol_id)
{ struct gluebi_device *gluebi; list_for_each_entry(gluebi, &gluebi_devices, list) if (gluebi->ubi_num == ubi_num && gluebi->vol_id == vol_id) return gluebi; return NULL; }
robutest/uclinux
C++
GPL-2.0
60
/* It is worth noting that these functions all access bytes of general purpose memory in the NVRAM - that is to say, they all add the NVRAM_FIRST_BYTE offset. Pass them offsets into NVRAM as if you did not know about the RTC cruft. */
unsigned char __nvram_read_byte(int i)
/* It is worth noting that these functions all access bytes of general purpose memory in the NVRAM - that is to say, they all add the NVRAM_FIRST_BYTE offset. Pass them offsets into NVRAM as if you did not know about the RTC cruft. */ unsigned char __nvram_read_byte(int i)
{ return CMOS_READ(NVRAM_FIRST_BYTE + i); }
robutest/uclinux
C++
GPL-2.0
60
/* Helper function for getting the audio_dev_data by the interface number. This function searches through all audio devices the one with given interface number and returns the audio_dev_data structure for this device. */
static struct usb_audio_dev_data* get_audio_dev_data_by_iface(uint8_t interface)
/* Helper function for getting the audio_dev_data by the interface number. This function searches through all audio devices the one with given interface number and returns the audio_dev_data structure for this device. */ static struct usb_audio_dev_data* get_audio_dev_data_by_iface(uint8_t interface)
{ struct usb_dev_data *dev_data; struct usb_audio_dev_data *audio_dev_data; SYS_SLIST_FOR_EACH_CONTAINER(&usb_audio_data_devlist, dev_data, node) { audio_dev_data = CONTAINER_OF(dev_data, struct usb_audio_dev_data, common); if (is_interface_valid(audio_dev_data, interface)) { return audio_dev_data; } } return NULL; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Force the running and committing transactions to commit, and wait on the commit. */
int ext4_force_commit(struct super_block *sb)
/* Force the running and committing transactions to commit, and wait on the commit. */ int ext4_force_commit(struct super_block *sb)
{ journal_t *journal; int ret = 0; if (sb->s_flags & MS_RDONLY) return 0; journal = EXT4_SB(sb)->s_journal; if (journal) ret = ext4_journal_force_commit(journal); return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* This function is the main entry of the UI entry. The function will present the main menu of the system UI. */
VOID EFIAPI UiEntry(IN BOOLEAN ConnectAllHappened)
/* This function is the main entry of the UI entry. The function will present the main menu of the system UI. */ VOID EFIAPI UiEntry(IN BOOLEAN ConnectAllHappened)
{ EFI_STATUS Status; EFI_BOOT_LOGO_PROTOCOL *BootLogo; REPORT_STATUS_CODE ( EFI_PROGRESS_CODE, (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_USER_SETUP) ); if (!ConnectAllHappened) { EfiBootManagerConnectAll (); } EfiBootManagerRefreshAllBootOption (); Status = gBS->LocateProtocol (&gEfiBootLogoProtocolGuid, NULL, (VOID **)&BootLogo); if (!EFI_ERROR (Status) && (BootLogo != NULL)) { BootLogo->SetBootLogo (BootLogo, NULL, 0, 0, 0, 0); } InitializeFrontPage (); CallFrontPage (); FreeFrontPage (); if (mLanguageString != NULL) { FreePool (mLanguageString); mLanguageString = NULL; } SetupResetReminder (); }
tianocore/edk2
C++
Other
4,240
/* Check if Reset is generated due to DWD. */
dwdResetStatus_t dwdGetStatus(void)
/* Check if Reset is generated due to DWD. */ dwdResetStatus_t dwdGetStatus(void)
{ dwdResetStatus_t Reset_Status; if((rtiREG1->WDSTATUS & 0x2U) == 0x2U) { Reset_Status = Reset_Generated; } else { Reset_Status = No_Reset_Generated; } return Reset_Status; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Converts an ascii char to an LCD digit. */
static void Convert(uint8_t *c, Point_Typedef point, Apostrophe_Typedef apostrophe)
/* Converts an ascii char to an LCD digit. */ static void Convert(uint8_t *c, Point_Typedef point, Apostrophe_Typedef apostrophe)
{ uint16_t ch = 0, tmp = 0; uint8_t i = 0; if ((*c < 0x5B) & (*c > 0x40)) { ch = LetterMap[*c - 0x41]; } if ((*c < 0x3A) & (*c > 0x2F)) { ch = NumberMap[*c - 0x30]; } if (*c == 0x20) { ch =0x00; } if (point == POINT_ON) { ch |= 0x0004; } if (apostrophe == APOSTROPHE_ON) { ch |= 0x1000; } for (i = 0; i < 4; i++) { tmp = ch & mask[i]; digit[i] =(uint8_t)(tmp >> shift[i]); } }
avem-labs/Avem
C++
MIT License
1,752
/* Released under the terms of the GNU GPL v2.0. Nothing too terribly exciting here .. */
void copy_page(void *to, void *from)
/* Released under the terms of the GNU GPL v2.0. Nothing too terribly exciting here .. */ void copy_page(void *to, void *from)
{ memcpy(to, from, PAGE_SIZE); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* You can obtain optimized timing values by running Holtek IDESETUP.COM for DOS. DOS drivers get their timing values from command line, where the first value is the Recovery Time and the second value is the Active Time for each drive. Smaller value gives higher speed. In case of failures you should probably fall back to a higher value. */
static u8 HT_TIMING(ide_drive_t *drive)
/* You can obtain optimized timing values by running Holtek IDESETUP.COM for DOS. DOS drivers get their timing values from command line, where the first value is the Recovery Time and the second value is the Active Time for each drive. Smaller value gives higher speed. In case of failures you should probably fall back to a higher value. */ static u8 HT_TIMING(ide_drive_t *drive)
{ return (unsigned long)ide_get_drivedata(drive) & 0x00ff; }
robutest/uclinux
C++
GPL-2.0
60
/* Shift right Big Number. Please note, all "out" Big number arguments should be properly initialized by calling to BigNumInit() or BigNumFromBin() functions. */
BOOLEAN EFIAPI CryptoServiceBigNumRShift(IN CONST VOID *Bn, IN UINTN N, OUT VOID *BnRes)
/* Shift right Big Number. Please note, all "out" Big number arguments should be properly initialized by calling to BigNumInit() or BigNumFromBin() functions. */ BOOLEAN EFIAPI CryptoServiceBigNumRShift(IN CONST VOID *Bn, IN UINTN N, OUT VOID *BnRes)
{ return CALL_BASECRYPTLIB (Bn.Services.RShift, BigNumRShift, (Bn, N, BnRes), FALSE); }
tianocore/edk2
C++
Other
4,240
/* Stalls the BSP for the minimum of POLL_INTERVAL_US and Timeout. */
STATIC UINTN CalculateAndStallInterval(IN UINTN Timeout)
/* Stalls the BSP for the minimum of POLL_INTERVAL_US and Timeout. */ STATIC UINTN CalculateAndStallInterval(IN UINTN Timeout)
{ UINTN StallTime; if ((Timeout < POLL_INTERVAL_US) && (Timeout != 0)) { StallTime = Timeout; } else { StallTime = POLL_INTERVAL_US; } gBS->Stall (StallTime); return StallTime; }
tianocore/edk2
C++
Other
4,240
/* Calculate the inverse of the supplied EC point. */
BOOLEAN EFIAPI CryptoServiceEcPointInvert(IN CONST VOID *EcGroup, IN OUT VOID *EcPoint, IN VOID *BnCtx)
/* Calculate the inverse of the supplied EC point. */ BOOLEAN EFIAPI CryptoServiceEcPointInvert(IN CONST VOID *EcGroup, IN OUT VOID *EcPoint, IN VOID *BnCtx)
{ return CALL_BASECRYPTLIB (Ec.Services.PointInvert, EcPointInvert, (EcGroup, EcPoint, BnCtx), FALSE); }
tianocore/edk2
C++
Other
4,240
/* this function is a POSIX compliant version, which will unlink (remove) a specified path file from file system. */
int unlink(const char *pathname)
/* this function is a POSIX compliant version, which will unlink (remove) a specified path file from file system. */ int unlink(const char *pathname)
{ int result; struct stat stat; if (pathname == NULL) { rt_set_errno(-EBADF); return -1; } result = dfs_file_lstat(pathname, &stat); if (result == 0 && S_ISDIR(stat.st_mode)) { rt_set_errno(-RT_ERROR); return -1; } result = dfs_file_unlink(pathname); if (result < 0) { rt_set_errno(result); return -1; } return 0; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Map the EVENTOUT signal. Enable the EVENTOUT signal and select the port and pin to be used. */
void gpio_set_eventout(uint8_t evoutport, uint8_t evoutpin)
/* Map the EVENTOUT signal. Enable the EVENTOUT signal and select the port and pin to be used. */ void gpio_set_eventout(uint8_t evoutport, uint8_t evoutpin)
{ AFIO_EVCR = AFIO_EVCR_EVOE | evoutport | evoutpin; }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* Move remain part of the buffer to the start position in the buffer. */
void _http_client_move_buffer(struct http_client_module *const module, char *base)
/* Move remain part of the buffer to the start position in the buffer. */ void _http_client_move_buffer(struct http_client_module *const module, char *base)
{ char *buffer = module->config.recv_buffer; int remain = (int)module->recved_size - (int)base + (int)buffer; if (remain > 0) { memmove(buffer, base, remain); module->recved_size = remain; } else { module->recved_size = 0; } }
remotemcu/remcu-chip-sdks
C++
null
436
/* 3) Update the vector table within mcf5225x_vectors.s to install the handler _vPortYieldISR() in the correct vector position (by default vector number 16 is used). */
__declspec(interrupt:0)
/* 3) Update the vector table within mcf5225x_vectors.s to install the handler _vPortYieldISR() in the correct vector position (by default vector number 16 is used). */ __declspec(interrupt:0)
{ const unsigned portSHORT usCompareMatchValue = ( ( configCPU_CLOCK_HZ / portPRESCALE_VALUE ) / configTICK_RATE_HZ ); MCF_INTC0_ICR55 = ( 1 | ( configKERNEL_INTERRUPT_PRIORITY << 3 ) ); MCF_INTC0_IMRH &= ~( MCF_INTC_IMRH_INT_MASK55 ); MCF_INTC0_ICR16 = ( 0 | configKERNEL_INTERRUPT_PRIORITY << 3 ); MCF_INTC0_IMRL &= ~( MCF_INTC_IMRL_INT_MASK16 | 0x01 ); MCF_PIT0_PCSR |= MCF_PIT_PCSR_PIF; MCF_PIT0_PCSR = ( portPRESCALE_REG_SETTING | MCF_PIT_PCSR_PIE | MCF_PIT_PCSR_RLD | MCF_PIT_PCSR_EN ); MCF_PIT0_PMR = usCompareMatchValue; }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). If StartBit is greater than 15, then ASSERT(). If EndBit is greater than 15, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT16 EFIAPI S3PciBitFieldAnd16(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 AndData)
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). If StartBit is greater than 15, then ASSERT(). If EndBit is greater than 15, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */ UINT16 EFIAPI S3PciBitFieldAnd16(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 AndData)
{ return InternalSavePciWrite16ValueToBootScript (Address, PciBitFieldAnd16 (Address, StartBit, EndBit, AndData)); }
tianocore/edk2
C++
Other
4,240
/* Returns the FLASH Write Protection Option Bytes value. */
uint32_t FLASH_OB_GetWRP2(void)
/* Returns the FLASH Write Protection Option Bytes value. */ uint32_t FLASH_OB_GetWRP2(void)
{ return (uint32_t)(FLASH->WRPR2); }
avem-labs/Avem
C++
MIT License
1,752
/* Configures the high and low thresholds of the analog watchdog1. */
void ADC_AnalogWatchdog1ThresholdsConfig(ADC_TypeDef *ADCx, uint16_t HighThreshold, uint16_t LowThreshold)
/* Configures the high and low thresholds of the analog watchdog1. */ void ADC_AnalogWatchdog1ThresholdsConfig(ADC_TypeDef *ADCx, uint16_t HighThreshold, uint16_t LowThreshold)
{ assert_param(IS_ADC_ALL_PERIPH(ADCx)); assert_param(IS_ADC_THRESHOLD(HighThreshold)); assert_param(IS_ADC_THRESHOLD(LowThreshold)); ADCx->TR1 &= ~(uint32_t)ADC_TR1_HT1; ADCx->TR1 |= (uint32_t)((uint32_t)HighThreshold << 16); ADCx->TR1 &= ~(uint32_t)ADC_TR1_LT1; ADCx->TR1 |= LowThreshold; }
ajhc/demo-cortex-m3
C++
null
38
/* USBD_HID_SendReport Send HID Report if TX buffer is free and USB device is configured. */
uint8_t USBD_HID_SendReport(USB_OTG_CORE_HANDLE *pdev, uint8_t *report, uint16_t len)
/* USBD_HID_SendReport Send HID Report if TX buffer is free and USB device is configured. */ uint8_t USBD_HID_SendReport(USB_OTG_CORE_HANDLE *pdev, uint8_t *report, uint16_t len)
{ if (pdev->dev.device_status == USB_OTG_CONFIGURED) { if (ReportSent) { if (report) { ReportSent = 0; DCD_EP_Tx (pdev, HID_IN_EP, report, len); } return USBD_OK; } } return USBD_FAIL; }
opentx/opentx
C++
GNU General Public License v2.0
2,025
/* Clean out excess bytes from the input buffer. */
static void read_excess_bytes(uint16_t size)
/* Clean out excess bytes from the input buffer. */ static void read_excess_bytes(uint16_t size)
{ if (size > 0) { uint8_t buffer[size]; edtt_read((uint8_t *)buffer, size, EDTTT_BLOCK); LOG_ERR("command size wrong! (%u extra bytes removed)", size); } }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Match an RGB value to a particular palette index */
Uint8 SDL_FindColor(SDL_Palette *pal, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
/* Match an RGB value to a particular palette index */ Uint8 SDL_FindColor(SDL_Palette *pal, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
{ unsigned int smallest; unsigned int distance; int rd, gd, bd, ad; int i; Uint8 pixel = 0; smallest = ~0; for (i = 0; i < pal->ncolors; ++i) { rd = pal->colors[i].r - r; gd = pal->colors[i].g - g; bd = pal->colors[i].b - b; ad = pal->colors[i].a - a; distance = (rd * rd) + (gd * gd) + (bd * bd) + (ad * ad); if (distance < smallest) { pixel = i; if (distance == 0) { break; } smallest = distance; } } return (pixel); }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Create a sub-tree and fill it with a net_addr structure */
static proto_tree* create_address_tree(tvbuff_t *tvb, proto_item *ti, guint32 offset)
/* Create a sub-tree and fill it with a net_addr structure */ static proto_tree* create_address_tree(tvbuff_t *tvb, proto_item *ti, guint32 offset)
{ proto_tree *tree; tree = proto_item_add_subtree(ti, ett_address); ti = proto_tree_add_item(tree, &hfi_address_services, tvb, offset, 8, ENC_LITTLE_ENDIAN); create_services_tree(tvb, ti, offset); offset += 8; proto_tree_add_item(tree, &hfi_address_address, tvb, offset, 16, ENC_NA); offset += 16; proto_tree_add_item(tree, &hfi_address_port, tvb, offset, 2, ENC_BIG_ENDIAN); return tree; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330