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
/* Sets the UART hardware flow control mode to be used. */
void UARTFlowControlSet(unsigned long ulBase, unsigned long ulMode)
/* Sets the UART hardware flow control mode to be used. */ void UARTFlowControlSet(unsigned long ulBase, unsigned long ulMode)
{ ASSERT(!CLASS_IS_SANDSTORM && !CLASS_IS_FURY && !CLASS_IS_DUSTDEVIL); ASSERT((ulBase == UART0_BASE) || (ulBase == UART1_BASE) || (ulBase == UART2_BASE)); ASSERT((ulMode & ~(UART_FLOWCONTROL_TX | UART_FLOWCONTROL_RX)) == 0); HWREG(ulBase + UART_O_CTL) = ((HWREG(ulBase + UART_O_CTL) & ~(UART_FLOWCONTROL_TX | UART_FLOWCONTROL_RX)) | ulMode); }
watterott/WebRadio
C++
null
71
/* Converts a text device path node to Bluetooth device path structure. */
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextBluetooth(IN CHAR16 *TextDeviceNode)
/* Converts a text device path node to Bluetooth device path structure. */ EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextBluetooth(IN CHAR16 *TextDeviceNode)
{ CHAR16 *BluetoothStr; BLUETOOTH_DEVICE_PATH *BluetoothDp; BluetoothStr = GetNextParamStr (&TextDeviceNode); BluetoothDp = (BLUETOOTH_DEVICE_PATH *)CreateDeviceNode ( MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_DP, (UINT16)sizeof (BLUETOOTH_DEVICE_PATH) ); StrHexToBytes ( BluetoothStr, sizeof (BLUETOOTH_ADDRESS) * 2, BluetoothDp->BD_ADDR.Address, sizeof (BLUETOOTH_ADDRESS) ); return (EFI_DEVICE_PATH_PROTOCOL *)BluetoothDp; }
tianocore/edk2
C++
Other
4,240
/* Please refer to the official documentation for function purpose and expected parameters. */
int ph7_value_is_resource(ph7_value *pVal)
/* Please refer to the official documentation for function purpose and expected parameters. */ int ph7_value_is_resource(ph7_value *pVal)
{ return (pVal->iFlags & MEMOBJ_OBJ) ? TRUE : FALSE; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Returns: Zero on success, else a negativ error code (-EIO). */
static int vxfs_getblk(struct inode *ip, sector_t iblock, struct buffer_head *bp, int create)
/* Returns: Zero on success, else a negativ error code (-EIO). */ static int vxfs_getblk(struct inode *ip, sector_t iblock, struct buffer_head *bp, int create)
{ daddr_t pblock; pblock = vxfs_bmap1(ip, iblock); if (pblock != 0) { map_bh(bp, ip->i_sb, pblock); return 0; } return -EIO; }
robutest/uclinux
C++
GPL-2.0
60
/* Clears a Stall condition on an endpoint of the Low Level Driver. */
USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
/* Clears a Stall condition on an endpoint of the Low Level Driver. */ USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
{ HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; hal_status = HAL_PCD_EP_ClrStall(pdev->pData, ep_addr); usb_status = USBD_Get_USB_Status(hal_status); return usb_status; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Release the memory region(s) being used by 'port' */
static void pl010_release_port(struct uart_port *port)
/* Release the memory region(s) being used by 'port' */ static void pl010_release_port(struct uart_port *port)
{ release_mem_region(port->mapbase, SZ_4K); }
robutest/uclinux
C++
GPL-2.0
60
/* Sets all elements of a vector to 0. */
void IMU_vectorZero(float v[3])
/* Sets all elements of a vector to 0. */ void IMU_vectorZero(float v[3])
{ int n; for( n = 0; n < 3; n++ ) { v[n] = 0.0f; } return; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Setup the PC, SP, and GP of a secondary processor and start it running! */
static void __cpuinit bcm1480_boot_secondary(int cpu, struct task_struct *idle)
/* Setup the PC, SP, and GP of a secondary processor and start it running! */ static void __cpuinit bcm1480_boot_secondary(int cpu, struct task_struct *idle)
{ int retval; retval = cfe_cpu_start(cpu_logical_map(cpu), &smp_bootstrap, __KSTK_TOS(idle), (unsigned long)task_thread_info(idle), 0); if (retval != 0) printk("cfe_start_cpu(%i) returned %i\n" , cpu, retval); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This function validates the chip ID of device */
static int drv_acc_gyro_bosch_bmi160_validate_id(i2c_dev_t *drv, uint8_t id_value)
/* This function validates the chip ID of device */ static int drv_acc_gyro_bosch_bmi160_validate_id(i2c_dev_t *drv, uint8_t id_value)
{ uint8_t value = 0x00; int ret = 0; if(drv == NULL) { return -1; } ret = sensor_i2c_read(drv, BMI160_USER_CHIP_ID__REG, &value, I2C_DATA_LEN, I2C_OP_RETRIES); if(unlikely(ret) != 0) { printf("read CHIPID failed \n"); return ret; } printf("read CHIPID %x\n", value); if(id_value != value) { printf("failed read CHIPID %x\n", value); return -1; } return 0; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* ADC Enable an External Trigger for Regular Channels. This enables an external trigger for set of defined regular channels, and sets the polarity of the trigger event: rising or falling edge or both. Note that if the trigger polarity is zero, triggering is disabled. */
void adc_enable_external_trigger_regular(uint32_t adc, uint32_t trigger, uint32_t polarity)
/* ADC Enable an External Trigger for Regular Channels. This enables an external trigger for set of defined regular channels, and sets the polarity of the trigger event: rising or falling edge or both. Note that if the trigger polarity is zero, triggering is disabled. */ void adc_enable_external_trigger_regular(uint32_t adc, uint32_t trigger, uint32_t polarity)
{ uint32_t reg32 = ADC_CR2(adc); reg32 &= ~(ADC_CR2_EXTSEL_MASK | ADC_CR2_EXTEN_MASK); reg32 |= (trigger | polarity); ADC_CR2(adc) = reg32; }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* Unregisters a callback. Unregisters a callback function which is implemented by the user. */
void m2m_unregister_callback(struct m2m_module *const m2m, enum m2m_callback_type type)
/* Unregisters a callback. Unregisters a callback function which is implemented by the user. */ void m2m_unregister_callback(struct m2m_module *const m2m, enum m2m_callback_type type)
{ Assert(m2m); if (type < M2M_CALLBACK_N) { m2m->callbacks[type] = NULL; } }
remotemcu/remcu-chip-sdks
C++
null
436
/* So this is used by sn_sal_serial_console_init (early on, before we're registered with serial core). It's also used by sn_sal_module_init right after we've registered with serial core. The later only happens if we didn't already come through here via sn_sal_serial_console_init. */
static void __init sn_sal_switch_to_asynch(struct sn_cons_port *port)
/* So this is used by sn_sal_serial_console_init (early on, before we're registered with serial core). It's also used by sn_sal_module_init right after we've registered with serial core. The later only happens if we didn't already come through here via sn_sal_serial_console_init. */ static void __init sn_sal_switch_to_asynch(struct sn_cons_port *port)
{ unsigned long flags; if (!port) return; DPRINTF("sn_console: about to switch to asynchronous console\n"); spin_lock_irqsave(&port->sc_port.lock, flags); if (!port->sc_ops) port->sc_ops = &poll_ops; init_timer(&port->sc_timer); port->sc_timer.function = sn_sal_timer_poll; port->sc_timer.data = (unsigned long)port; if (IS_RUNNING_ON_SIMULATOR()) port->sc_interrupt_timeout = 6; else { port->sc_interrupt_timeout = HZ * SN_SAL_UART_FIFO_DEPTH / SN_SAL_UART_FIFO_SPEED_CPS; } mod_timer(&port->sc_timer, jiffies + port->sc_interrupt_timeout); port->sc_is_asynch = 1; spin_unlock_irqrestore(&port->sc_port.lock, flags); }
robutest/uclinux
C++
GPL-2.0
60
/* LSM hook implementation that authorizes that a flow can use a xfrm policy rule. */
int selinux_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir)
/* LSM hook implementation that authorizes that a flow can use a xfrm policy rule. */ int selinux_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir)
{ int rc; u32 sel_sid; if (ctx) { if (!selinux_authorizable_ctx(ctx)) return -EINVAL; sel_sid = ctx->ctx_sid; } else return 0; rc = avc_has_perm(fl_secid, sel_sid, SECCLASS_ASSOCIATION, ASSOCIATION__POLMATCH, NULL); if (rc == -EACCES) return -ESRCH; return rc; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Usb hub control transfer to set the port feature. */
EFI_STATUS UsbHubCtrlSetPortFeature(IN USB_DEVICE *HubDev, IN UINT8 Port, IN UINT8 Feature)
/* Usb hub control transfer to set the port feature. */ EFI_STATUS UsbHubCtrlSetPortFeature(IN USB_DEVICE *HubDev, IN UINT8 Port, IN UINT8 Feature)
{ EFI_STATUS Status; Status = UsbCtrlRequest ( HubDev, EfiUsbNoData, USB_REQ_TYPE_CLASS, USB_HUB_TARGET_PORT, USB_HUB_REQ_SET_FEATURE, Feature, (UINT16)(Port + 1), NULL, 0 ); return Status; }
tianocore/edk2
C++
Other
4,240
/* Disables PCI-Express master access and verifies there are no pending requests. */
s32 igb_disable_pcie_master(struct e1000_hw *hw)
/* Disables PCI-Express master access and verifies there are no pending requests. */ s32 igb_disable_pcie_master(struct e1000_hw *hw)
{ u32 ctrl; s32 timeout = MASTER_DISABLE_TIMEOUT; s32 ret_val = 0; if (hw->bus.type != e1000_bus_type_pci_express) goto out; ctrl = rd32(E1000_CTRL); ctrl |= E1000_CTRL_GIO_MASTER_DISABLE; wr32(E1000_CTRL, ctrl); while (timeout) { if (!(rd32(E1000_STATUS) & E1000_STATUS_GIO_MASTER_ENABLE)) break; udelay(100); timeout--; } if (!timeout) { hw_dbg("Master requests are pending.\n"); ret_val = -E1000_ERR_MASTER_REQUESTS_PENDING; goto out; } out: return ret_val; }
robutest/uclinux
C++
GPL-2.0
60
/* param handle WM8904 handle structure. param reg register address. param value value to write. return kStatus_Success, else failed. */
status_t WM8904_WriteRegister(wm8904_handle_t *handle, uint8_t reg, uint16_t value)
/* param handle WM8904 handle structure. param reg register address. param value value to write. return kStatus_Success, else failed. */ status_t WM8904_WriteRegister(wm8904_handle_t *handle, uint8_t reg, uint16_t value)
{ assert(handle->config != NULL); assert(handle->config->slaveAddress != 0U); uint16_t writeValue = (uint16_t)WM8904_SWAP_UINT16_BYTE_SEQUENCE(value); return CODEC_I2C_Send(handle->i2cHandle, handle->config->slaveAddress, reg, 1U, (uint8_t *)&writeValue, 2U); }
eclipse-threadx/getting-started
C++
Other
310
/* This routine is called from the PCI subsystem for error handling to device with SLI-3 interface spec. It is called when kernel error recovery tells the lpfc driver that it is ok to resume normal PCI operation after PCI bus error recovery. After this call, traffic can start to flow from this device again. */
static void lpfc_io_resume_s3(struct pci_dev *pdev)
/* This routine is called from the PCI subsystem for error handling to device with SLI-3 interface spec. It is called when kernel error recovery tells the lpfc driver that it is ok to resume normal PCI operation after PCI bus error recovery. After this call, traffic can start to flow from this device again. */ static void lpfc_io_resume_s3(struct pci_dev *pdev)
{ struct Scsi_Host *shost = pci_get_drvdata(pdev); struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; lpfc_online(phba); if (phba->hba_flag & HBA_AER_ENABLED) pci_cleanup_aer_uncorrect_error_status(pdev); }
robutest/uclinux
C++
GPL-2.0
60
/* This is called to pin the buffer associated with the buf log item in memory so it cannot be written out. Simply call bpin() on the buffer to do this. */
STATIC void xfs_buf_item_pin(xfs_buf_log_item_t *bip)
/* This is called to pin the buffer associated with the buf log item in memory so it cannot be written out. Simply call bpin() on the buffer to do this. */ STATIC void xfs_buf_item_pin(xfs_buf_log_item_t *bip)
{ xfs_buf_t *bp; bp = bip->bli_buf; ASSERT(XFS_BUF_ISBUSY(bp)); ASSERT(atomic_read(&bip->bli_refcount) > 0); ASSERT((bip->bli_flags & XFS_BLI_LOGGED) || (bip->bli_flags & XFS_BLI_STALE)); trace_xfs_buf_item_pin(bip); xfs_bpin(bp); }
robutest/uclinux
C++
GPL-2.0
60
/* Disable Snapshot for messages relevant to Master. When disabled, snapshot is taken for messages relevant to slave node. Valid only for Ordinary clock and Boundary clock Reserved when "Advanced Time Stamp" is not selected */
void synopGMAC_TS_master_disable(synopGMACdevice *gmacdev)
/* Disable Snapshot for messages relevant to Master. When disabled, snapshot is taken for messages relevant to slave node. Valid only for Ordinary clock and Boundary clock Reserved when "Advanced Time Stamp" is not selected */ void synopGMAC_TS_master_disable(synopGMACdevice *gmacdev)
{ synopGMACClearBits(gmacdev->MacBase,GmacTSControl,GmacTSMSTRENA); return; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Map the kernel address into a bio suitable for io to a block device. Returns an error pointer in case of error. */
struct bio* bio_map_kern(struct request_queue *q, void *data, unsigned int len, gfp_t gfp_mask)
/* Map the kernel address into a bio suitable for io to a block device. Returns an error pointer in case of error. */ struct bio* bio_map_kern(struct request_queue *q, void *data, unsigned int len, gfp_t gfp_mask)
{ struct bio *bio; bio = __bio_map_kern(q, data, len, gfp_mask); if (IS_ERR(bio)) return bio; if (bio->bi_size == len) return bio; bio_put(bio); return ERR_PTR(-EINVAL); }
robutest/uclinux
C++
GPL-2.0
60
/* Function to decide if a column number is stored in the high bits. */
BOOLEAN HBufferImageIsAtHighBits(IN UINTN Column, OUT UINTN *FCol)
/* Function to decide if a column number is stored in the high bits. */ BOOLEAN HBufferImageIsAtHighBits(IN UINTN Column, OUT UINTN *FCol)
{ Column -= 10; if (Column == 24) { *FCol = 0; return FALSE; } if (Column > 24) { Column--; } *FCol = (Column / 3) + 1; if (Column % 3 == 0) { return TRUE; } if ((Column % 3 == 2)) { *FCol = 0; } return FALSE; }
tianocore/edk2
C++
Other
4,240
/* Reads the values present of the specified pin(s). The values at the specified pin(s) are read, as specified by */
unsigned long xGPIOPinRead(unsigned long ulPort, unsigned long ulPins)
/* Reads the values present of the specified pin(s). The values at the specified pin(s) are read, as specified by */ unsigned long xGPIOPinRead(unsigned long ulPort, unsigned long ulPins)
{ return(xHWREG(ulPort +GPIO_PIN ) & (ulPins)) ? 1 : 0; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* If 8-bit I/O port operations are not supported, then ASSERT(). If StartBit is greater than 7, then ASSERT(). If EndBit is greater than 7, 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(). */
UINT8 EFIAPI S3IoBitFieldAnd8(IN UINTN Port, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 AndData)
/* If 8-bit I/O port operations are not supported, then ASSERT(). If StartBit is greater than 7, then ASSERT(). If EndBit is greater than 7, 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(). */ UINT8 EFIAPI S3IoBitFieldAnd8(IN UINTN Port, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 AndData)
{ return InternalSaveIoWrite8ValueToBootScript (Port, IoBitFieldAnd8 (Port, StartBit, EndBit, AndData)); }
tianocore/edk2
C++
Other
4,240
/* brief Setup peripheral clock dividers. param div_name : Clock divider name param divided_by_value: Value to be divided param reset : Whether to reset the divider counter. return Nothing */
void CLOCK_SetClkDiv(clock_div_name_t div_name, uint32_t divided_by_value, bool reset)
/* brief Setup peripheral clock dividers. param div_name : Clock divider name param divided_by_value: Value to be divided param reset : Whether to reset the divider counter. return Nothing */ void CLOCK_SetClkDiv(clock_div_name_t div_name, uint32_t divided_by_value, bool reset)
{ volatile uint32_t *pClkDiv; pClkDiv = &(SYSCON->SYSTICKCLKDIV0); if (reset) { pClkDiv[(uint8_t)div_name] = 1UL << 29U; } if (divided_by_value == 0U) { pClkDiv[(uint8_t)div_name] = 1UL << 30U; } else { pClkDiv[(uint8_t)div_name] = (divided_by_value - 1U); } }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* This function tries to write BufferSize bytes data from the Buffer into the specified TLS connection. */
INTN EFIAPI CryptoServiceTlsWrite(IN VOID *Tls, IN VOID *Buffer, IN UINTN BufferSize)
/* This function tries to write BufferSize bytes data from the Buffer into the specified TLS connection. */ INTN EFIAPI CryptoServiceTlsWrite(IN VOID *Tls, IN VOID *Buffer, IN UINTN BufferSize)
{ return CALL_BASECRYPTLIB (Tls.Services.Write, TlsWrite, (Tls, Buffer, BufferSize), 0); }
tianocore/edk2
C++
Other
4,240
/* Configures the touch Screen IC device to start detecting touches. */
void ft3x67_TS_Start(uint16_t DeviceAddr)
/* Configures the touch Screen IC device to start detecting touches. */ void ft3x67_TS_Start(uint16_t DeviceAddr)
{ ft3x67_TS_Configure(DeviceAddr); ft3x67_TS_DisableIT(DeviceAddr); }
eclipse-threadx/getting-started
C++
Other
310
/* System calibration osc get status. Use this function to get system calibration osc status. */
enum system_calibration_status system_osc_calibration_get_status(void)
/* System calibration osc get status. Use this function to get system calibration osc status. */ enum system_calibration_status system_osc_calibration_get_status(void)
{ if (LP_CLK_CAL_REGS0->CALIB_OSC_COUNT_REG.bit.NO_CAL_IN_PROGRESS) { return CALBRATION_NO_IN_PROGRESS; } else if (LP_CLK_CAL_REGS0->CALIB_OSC_COUNT_REG.bit.CAL_DONE) { return CALBRATION_DONE; } else { return CALBRATION_IN_PROGRESS; } }
memfault/zero-to-main
C++
null
200
/* Returns: a UTF-8 string associated with the given @attribute. When you're done with the string it must be freed with g_free(). */
char* g_file_info_get_attribute_as_string(GFileInfo *info, const char *attribute)
/* Returns: a UTF-8 string associated with the given @attribute. When you're done with the string it must be freed with g_free(). */ char* g_file_info_get_attribute_as_string(GFileInfo *info, const char *attribute)
{ GFileAttributeValue *val; val = _g_file_info_get_attribute_value (info, attribute); if (val) return _g_file_attribute_value_as_string (val); return NULL; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* "AmlAttachNode (ParentNode, NewNode)" will result in: ASL code: Device (PCI0) { Name(_HID, EISAID("PNP0A08")) Name (_UID, 0) } */
EFI_STATUS EFIAPI AmlAttachNode(IN AML_NODE_HANDLE ParentNode, IN AML_NODE_HANDLE NewNode)
/* "AmlAttachNode (ParentNode, NewNode)" will result in: ASL code: Device (PCI0) { Name(_HID, EISAID("PNP0A08")) Name (_UID, 0) } */ EFI_STATUS EFIAPI AmlAttachNode(IN AML_NODE_HANDLE ParentNode, IN AML_NODE_HANDLE NewNode)
{ return AmlVarListAddTail (ParentNode, NewNode); }
tianocore/edk2
C++
Other
4,240
/* Creates a new phy_fixup and adds it to the list @bus_id: A string which matches phydev->dev.bus_id (or PHY_ANY_ID) @phy_uid: Used to match against phydev->phy_id (the UID of the */
int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask, int(*run)(struct phy_device *))
/* Creates a new phy_fixup and adds it to the list @bus_id: A string which matches phydev->dev.bus_id (or PHY_ANY_ID) @phy_uid: Used to match against phydev->phy_id (the UID of the */ int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask, int(*run)(struct phy_device *))
{ struct phy_fixup *fixup; fixup = kzalloc(sizeof(struct phy_fixup), GFP_KERNEL); if (!fixup) return -ENOMEM; strlcpy(fixup->bus_id, bus_id, sizeof(fixup->bus_id)); fixup->phy_uid = phy_uid; fixup->phy_uid_mask = phy_uid_mask; fixup->run = run; mutex_lock(&phy_fixup_lock); list_add_tail(&fixup->list, &phy_fixup_list); mutex_unlock(&phy_fixup_lock); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* ADC Set Clock Source. The ADC clock taken from the APB2 clock can be scaled down by 2, 4, 6 or 8. */
void adc_set_clk_source(uint32_t adc, uint32_t source)
/* ADC Set Clock Source. The ADC clock taken from the APB2 clock can be scaled down by 2, 4, 6 or 8. */ void adc_set_clk_source(uint32_t adc, uint32_t source)
{ uint32_t reg32 = ((ADC_CCR(adc) & ~ADC_CCR_CKMODE_MASK) | source); ADC_CCR(adc) = reg32; }
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* Configure the push button. Configure the PIO as inputs and generate corresponding interrupt when pressed or released. */
static void configure_button(void)
/* Configure the push button. Configure the PIO as inputs and generate corresponding interrupt when pressed or released. */ static void configure_button(void)
{ pio_set_debounce_filter(PIN_PUSHBUTTON_WAKEUP_PIO, PIN_PUSHBUTTON_WAKEUP_MASK, 10); pio_handler_set(PIN_PUSHBUTTON_WAKEUP_PIO, PIN_PUSHBUTTON_WAKEUP_ID, PIN_PUSHBUTTON_WAKEUP_MASK, PIN_PUSHBUTTON_WAKEUP_ATTR, button_handler); NVIC_EnableIRQ((IRQn_Type)PIN_PUSHBUTTON_WAKEUP_ID); pio_enable_interrupt(PIN_PUSHBUTTON_WAKEUP_PIO, PIN_PUSHBUTTON_WAKEUP_MASK); }
remotemcu/remcu-chip-sdks
C++
null
436
/* The Tx ring has been full longer than the watchdog timeout value. The transmitter must be hung? */
static void au1000_tx_timeout(struct net_device *dev)
/* The Tx ring has been full longer than the watchdog timeout value. The transmitter must be hung? */ static void au1000_tx_timeout(struct net_device *dev)
{ printk(KERN_ERR "%s: au1000_tx_timeout: dev=%p\n", dev->name, dev); reset_mac(dev); au1000_init(dev); dev->trans_start = jiffies; netif_wake_queue(dev); }
robutest/uclinux
C++
GPL-2.0
60
/* After executing actions of the event, upper layer will be indicated if needed(on receiving an UI frame). sk can be null for the datalink_proto case. */
static void llc_sap_state_process(struct llc_sap *sap, struct sk_buff *skb)
/* After executing actions of the event, upper layer will be indicated if needed(on receiving an UI frame). sk can be null for the datalink_proto case. */ static void llc_sap_state_process(struct llc_sap *sap, struct sk_buff *skb)
{ struct llc_sap_state_ev *ev = llc_sap_ev(skb); skb_get(skb); ev->ind_cfm_flag = 0; llc_sap_next_state(sap, skb); if (ev->ind_cfm_flag == LLC_IND) { if (skb->sk->sk_state == TCP_LISTEN) kfree_skb(skb); else { llc_save_primitive(skb->sk, skb, ev->prim); if (sock_queue_rcv_skb(skb->sk, skb)) kfree_skb(skb); } } kfree_skb(skb); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* param base eLCDIF peripheral base address. param config Pointer to the configuration structure. */
void ELCDIF_SetAlphaSurfaceBufferConfig(LCDIF_Type *base, const elcdif_as_buffer_config_t *config)
/* param base eLCDIF peripheral base address. param config Pointer to the configuration structure. */ void ELCDIF_SetAlphaSurfaceBufferConfig(LCDIF_Type *base, const elcdif_as_buffer_config_t *config)
{ assert(config); base->AS_CTRL = (base->AS_CTRL & ~LCDIF_AS_CTRL_FORMAT_MASK) | LCDIF_AS_CTRL_FORMAT(config->pixelFormat); base->AS_BUF = config->bufferAddr; base->AS_NEXT_BUF = config->bufferAddr; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* ZigBee Device Profile dissector for the discovery cache */
void dissect_zbee_zdp_rsp_discovery_cache(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/* ZigBee Device Profile dissector for the discovery cache */ void dissect_zbee_zdp_rsp_discovery_cache(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{ guint offset = 0; guint8 status; status = zdp_parse_status(tree, tvb, &offset); zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status)); zdp_dump_excess(tvb, offset, pinfo, tree); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* get the read only socket handle of the SSL */
int SSL_get_rfd(const SSL *ssl)
/* get the read only socket handle of the SSL */ int SSL_get_rfd(const SSL *ssl)
{ int ret; SSL_ASSERT1(ssl); ret = SSL_METHOD_CALL(get_fd, ssl, 0); return ret; }
retro-esp32/RetroESP32
C++
Creative Commons Attribution Share Alike 4.0 International
581
/* If we're lucky and live on a modern system, the setup code will have given us a memory map that we can use to properly set up memory. If we aren't, we'll fake a memory map. */
static int __init append_e820_map(struct e820entry *biosmap, int nr_map)
/* If we're lucky and live on a modern system, the setup code will have given us a memory map that we can use to properly set up memory. If we aren't, we'll fake a memory map. */ static int __init append_e820_map(struct e820entry *biosmap, int nr_map)
{ if (nr_map < 2) return -1; return __append_e820_map(biosmap, nr_map); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Parameter nnn is the combination of bits at positions 0, 1 and 2 in the RTS opcode that respectively initiate transmission for buffers TXB0, TXB1 and TXB2. */
static int mcp2515_cmd_rts(const struct device *dev, uint8_t nnn)
/* Parameter nnn is the combination of bits at positions 0, 1 and 2 in the RTS opcode that respectively initiate transmission for buffers TXB0, TXB1 and TXB2. */ static int mcp2515_cmd_rts(const struct device *dev, uint8_t nnn)
{ const struct mcp2515_config *dev_cfg = dev->config; __ASSERT(nnn < BIT(MCP2515_TX_CNT), "nnn < BIT(MCP2515_TX_CNT)"); uint8_t cmd_buf[] = { MCP2515_OPCODE_RTS | nnn }; struct spi_buf tx_buf[] = { { .buf = cmd_buf, .len = sizeof(cmd_buf) } }; const struct spi_buf_set tx = { .buffers = tx_buf, .count = ARRAY_SIZE(tx_buf) }; return spi_write_dt(&dev_cfg->bus, &tx); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Returns mpu virtual addr which corresponds to a given device virtual addr */
void* da_to_va(struct iommu *obj, u32 da)
/* Returns mpu virtual addr which corresponds to a given device virtual addr */ void* da_to_va(struct iommu *obj, u32 da)
{ void *va = NULL; struct iovm_struct *area; mutex_lock(&obj->mmap_lock); area = __find_iovm_area(obj, da); if (!area) { dev_dbg(obj->dev, "%s: no da area(%08x)\n", __func__, da); goto out; } va = area->va; out: mutex_unlock(&obj->mmap_lock); return va; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */
void __iomem* pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */ void __iomem* pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
{ resource_size_t start = pci_resource_start(dev, bar); resource_size_t len = pci_resource_len(dev, bar); unsigned long flags = pci_resource_flags(dev, bar); if (!len || !start) return NULL; if (maxlen && len > maxlen) len = maxlen; if (flags & IORESOURCE_IO) return ioport_map_pci(dev, start, len); if (flags & IORESOURCE_MEM) { if (flags & IORESOURCE_CACHEABLE) return ioremap(start, len); return ioremap_nocache(start, len); } return NULL; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Drop a Received packet (too small packet, etc...) */
void ETH_DropRxPacket(void)
/* Drop a Received packet (too small packet, etc...) */ void ETH_DropRxPacket(void)
{ DMARxDescToGet->Status = ETH_DMA_RX_DESC_OWN; if ((DMARxDescToGet->CtrlOrBufSize & ETH_DMA_RX_DESC_RCH) != (uint32_t)RESET) { DMARxDescToGet = (ETH_DMADescType*)(DMARxDescToGet->Buf2OrNextDescAddr); } else { if ((DMARxDescToGet->CtrlOrBufSize & ETH_DMA_RX_DESC_RER) != (uint32_t)RESET) { DMARxDescToGet = (ETH_DMADescType*)(ETH->DMARXDLADDR); } else { DMARxDescToGet = (ETH_DMADescType*)((uint32_t)DMARxDescToGet + 0x10 + ((ETH->DMABUSMOD & ETH_DMABUSMOD_DSL))); } } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Return 0, 1, or 2 as a <, =, > b respectively. Neither a nor b are considered signed. */
int __ucmpdi2(u_quad_t a, u_quad_t b)
/* Return 0, 1, or 2 as a <, =, > b respectively. Neither a nor b are considered signed. */ int __ucmpdi2(u_quad_t a, u_quad_t b)
{ union uu aa, bb; aa.uq = a; bb.uq = b; return aa.ul[H] < bb.ul[H] ? 0 : aa.ul[H] > bb.ul[H] ? 2 : aa.ul[L] < bb.ul[L] ? 0 : aa.ul[L] > bb.ul[L] ? 2 : 1; }
labapart/polymcu
C++
null
201
/* Check the availability of adafruit 1.8" TFT shield on top of STM32NUCLEO board. This is done by reading the state of IO PB.00 pin (mapped to JoyStick available on adafruit 1.8" TFT shield). If the state of PB.00 is high then the adafruit 1.8" TFT shield is available. */
static ShieldStatus TFT_ShieldDetect(void)
/* Check the availability of adafruit 1.8" TFT shield on top of STM32NUCLEO board. This is done by reading the state of IO PB.00 pin (mapped to JoyStick available on adafruit 1.8" TFT shield). If the state of PB.00 is high then the adafruit 1.8" TFT shield is available. */ static ShieldStatus TFT_ShieldDetect(void)
{ GPIO_InitTypeDef GPIO_InitStruct; __HAL_RCC_GPIOB_CLK_ENABLE(); GPIO_InitStruct.Pin = GPIO_PIN_0; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_PULLDOWN; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); if(HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_0) != 0) { return SHIELD_DETECTED; } else { return SHIELD_NOT_DETECTED; } }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Query the EC for specified mask indicating enabled events. The EC maintains separate event masks for SMI, SCI and WAKE. */
static int cros_ec_uhepi_cmd(struct udevice *dev, uint mask, uint action, uint64_t *value)
/* Query the EC for specified mask indicating enabled events. The EC maintains separate event masks for SMI, SCI and WAKE. */ static int cros_ec_uhepi_cmd(struct udevice *dev, uint mask, uint action, uint64_t *value)
{ int ret; struct ec_params_host_event req; struct ec_response_host_event rsp; req.action = action; req.mask_type = mask; if (action != EC_HOST_EVENT_GET) req.value = *value; else *value = 0; ret = ec_command(dev, EC_CMD_HOST_EVENT, 0, &req, sizeof(req), &rsp, sizeof(rsp)); if (action != EC_HOST_EVENT_GET) return ret; if (ret == 0) *value = rsp.value; return ret; }
4ms/stm32mp1-baremetal
C++
Other
137
/* STP sync check machine check. This is called when the timing state changes from the synchronized state to the unsynchronized state. After a STP sync check the clock is not in sync. The machine check is broadcasted to all cpus at the same time. */
void stp_sync_check(void)
/* STP sync check machine check. This is called when the timing state changes from the synchronized state to the unsynchronized state. After a STP sync check the clock is not in sync. The machine check is broadcasted to all cpus at the same time. */ void stp_sync_check(void)
{ disable_sync_clock(NULL); queue_work(time_sync_wq, &stp_work); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Fills each GPIO_InitStruct member with its default value. */
void GPIO_StructInit(GPIO_InitTypeDef *GPIO_InitStruct)
/* Fills each GPIO_InitStruct member with its default value. */ void GPIO_StructInit(GPIO_InitTypeDef *GPIO_InitStruct)
{ GPIO_InitStruct->GPIO_Pin = GPIO_Pin_All; GPIO_InitStruct->GPIO_Mode = GPIO_Mode_IN; GPIO_InitStruct->GPIO_Speed = GPIO_Speed_Level_2; GPIO_InitStruct->GPIO_OType = GPIO_OType_PP; GPIO_InitStruct->GPIO_PuPd = GPIO_PuPd_NOPULL; }
ajhc/demo-cortex-m3
C++
null
38
/* This function checks if the IPMI channel already identified previously. */
EFI_STATUS CheckCachedIpmiLanMac(IN UINT8 ChannelNum, OUT BMC_IPMI_LAN_CHANNEL_INFO **CachedIpmiLanChannel)
/* This function checks if the IPMI channel already identified previously. */ EFI_STATUS CheckCachedIpmiLanMac(IN UINT8 ChannelNum, OUT BMC_IPMI_LAN_CHANNEL_INFO **CachedIpmiLanChannel)
{ BMC_IPMI_LAN_CHANNEL_INFO *ThisInstance; if (IsListEmpty (&mBmcIpmiLan)) { return EFI_NOT_FOUND; } ThisInstance = (BMC_IPMI_LAN_CHANNEL_INFO *)GetFirstNode (&mBmcIpmiLan); while (TRUE) { if (ThisInstance->Channel == ChannelNum) { *CachedIpmiLanChannel = ThisInstance; return EFI_SUCCESS; } if (IsNodeAtEnd (&mBmcIpmiLan, &ThisInstance->NextInstance)) { break; } ThisInstance = (BMC_IPMI_LAN_CHANNEL_INFO *) GetNextNode (&mBmcIpmiLan, &ThisInstance->NextInstance); } return EFI_NOT_FOUND; }
tianocore/edk2
C++
Other
4,240
/* Read the counter value on the specified channel. */
uint32_t tc_read_cv(Tc *p_tc, uint32_t ul_channel)
/* Read the counter value on the specified channel. */ uint32_t tc_read_cv(Tc *p_tc, uint32_t ul_channel)
{ Assert(p_tc); Assert(ul_channel < (sizeof(p_tc->TC_CHANNEL) / sizeof(p_tc->TC_CHANNEL[0]))); return p_tc->TC_CHANNEL[ul_channel].TC_CV; }
remotemcu/remcu-chip-sdks
C++
null
436
/* this API is used to get the fifo over run in the register 0x0E bit 7 */
BMG160_RETURN_FUNCTION_TYPE bmg160_get_fifo_overrun(u8 *v_fifo_overrun_u8)
/* this API is used to get the fifo over run in the register 0x0E bit 7 */ BMG160_RETURN_FUNCTION_TYPE bmg160_get_fifo_overrun(u8 *v_fifo_overrun_u8)
{ BMG160_RETURN_FUNCTION_TYPE comres = ERROR; u8 v_data_u8 = BMG160_INIT_VALUE; if (p_bmg160 == BMG160_NULL) { return E_BMG160_NULL_PTR; } else { comres = p_bmg160->BMG160_BUS_READ_FUNC(p_bmg160->dev_addr, BMG160_FIFO_STAT_OVERRUN__REG, &v_data_u8, BMG160_GEN_READ_WRITE_DATA_LENGTH); *v_fifo_overrun_u8 = BMG160_GET_BITSLICE(v_data_u8, BMG160_FIFO_STAT_OVERRUN); } return comres; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Enable the SPI interrupt of the specified SPI port. */
void SPIIntEnable(unsigned long ulBase, unsigned long ulIntFlags)
/* Enable the SPI interrupt of the specified SPI port. */ void SPIIntEnable(unsigned long ulBase, unsigned long ulIntFlags)
{ xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)|| (ulBase == SPI2_BASE)||(ulBase == SPI3_BASE) ); if(ulIntFlags & SPI_CNTRL_IE) { xHWREG(ulBase + SPI_CNTRL) |= SPI_CNTRL_IE; } if(ulIntFlags & SPI_CNTRL2_SSTA_INTEN) { xHWREG(ulBase + SPI_CNTRL2) |= SPI_CNTRL2_SSTA_INTEN; } xHWREG(ulBase + SPI_FIFOCTL) |= ulIntFlags; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Call the C function 'func' in protected mode, restoring basic thread information ('allowhook', etc.) and in particular its stack level in case of errors. */
int luaD_pcall(lua_State *L, Pfunc func, void *u, ptrdiff_t old_top, ptrdiff_t ef)
/* Call the C function 'func' in protected mode, restoring basic thread information ('allowhook', etc.) and in particular its stack level in case of errors. */ int luaD_pcall(lua_State *L, Pfunc func, void *u, ptrdiff_t old_top, ptrdiff_t ef)
{ int status; CallInfo *old_ci = L->ci; lu_byte old_allowhooks = L->allowhook; ptrdiff_t old_errfunc = L->errfunc; L->errfunc = ef; status = luaD_rawrunprotected(L, func, u); if (l_unlikely(status != LUA_OK)) { L->ci = old_ci; L->allowhook = old_allowhooks; status = luaD_closeprotected(L, old_top, status); luaD_seterrorobj(L, status, restorestack(L, old_top)); luaD_shrinkstack(L); } L->errfunc = old_errfunc; return status; }
Nicholas3388/LuaNode
C++
Other
1,055
/* sunxi_lcd_cpu_write - write command and para to cpu panel. @screen_id: The index of screen. @command: Command to be transfer. @para: The pointer to para @para_num: The number of para */
s32 sunxi_lcd_cpu_write(u32 screen_id, u32 index, u32 data)
/* sunxi_lcd_cpu_write - write command and para to cpu panel. @screen_id: The index of screen. @command: Command to be transfer. @para: The pointer to para @para_num: The number of para */ s32 sunxi_lcd_cpu_write(u32 screen_id, u32 index, u32 data)
{ if (g_lcd_drv.src_ops.sunxi_lcd_cpu_write) return g_lcd_drv.src_ops.sunxi_lcd_cpu_write(screen_id, index, data); return -1; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* display a list of all the REGIONs the kernel knows about */
static int nommu_region_list_show(struct seq_file *m, void *_p)
/* display a list of all the REGIONs the kernel knows about */ static int nommu_region_list_show(struct seq_file *m, void *_p)
{ struct rb_node *p = _p; return nommu_region_show(m, rb_entry(p, struct vm_region, vm_rb)); }
robutest/uclinux
C++
GPL-2.0
60
/* The function is used to Enable low voltage reset. */
void SysCtlLowVoltRstEnable(xtBoolean bEnable)
/* The function is used to Enable low voltage reset. */ void SysCtlLowVoltRstEnable(xtBoolean bEnable)
{ SysCtlKeyAddrUnlock(); if(bEnable) { xHWREG(GCR_BODCR) |= GCR_BODCR_LVR_EN; } else { xHWREG(GCR_BODCR) &= ~GCR_BODCR_LVR_EN; } SysCtlKeyAddrLock(); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Clear the specified Thread Flags of current running thread. */
static uint32_t svcRtxThreadFlagsClear(uint32_t flags)
/* Clear the specified Thread Flags of current running thread. */ static uint32_t svcRtxThreadFlagsClear(uint32_t flags)
{ EvrRtxThreadFlagsError(NULL, osRtxErrorKernelNotRunning); return ((uint32_t)osError); } if ((flags & ~(((uint32_t)1U << osRtxThreadFlagsLimit) - 1U)) != 0U) { EvrRtxThreadFlagsError(thread, (int32_t)osErrorParameter); return ((uint32_t)osErrorParameter); } thread_flags = ThreadFlagsClear(thread, flags); EvrRtxThreadFlagsClearDone(thread_flags); return thread_flags; }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* The callback function to free the net buffer list. */
VOID EFIAPI FreeNbufList(IN VOID *Arg)
/* The callback function to free the net buffer list. */ VOID EFIAPI FreeNbufList(IN VOID *Arg)
{ ASSERT (Arg != NULL); NetbufFreeList ((LIST_ENTRY *)Arg); FreePool (Arg); }
tianocore/edk2
C++
Other
4,240
/* Remove Simple Pointer Device from Consplitter Simple Pointer list. */
EFI_STATUS ConSplitterSimplePointerDeleteDevice(IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private, IN EFI_SIMPLE_POINTER_PROTOCOL *SimplePointer)
/* Remove Simple Pointer Device from Consplitter Simple Pointer list. */ EFI_STATUS ConSplitterSimplePointerDeleteDevice(IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private, IN EFI_SIMPLE_POINTER_PROTOCOL *SimplePointer)
{ UINTN Index; for (Index = 0; Index < Private->CurrentNumberOfPointers; Index++) { if (Private->PointerList[Index] == SimplePointer) { for ( ; Index < Private->CurrentNumberOfPointers - 1; Index++) { Private->PointerList[Index] = Private->PointerList[Index + 1]; } Private->CurrentNumberOfPointers--; return EFI_SUCCESS; } } return EFI_NOT_FOUND; }
tianocore/edk2
C++
Other
4,240
/* Enable dCache & iCache, whether cache is actually enabled depend on CONFIG_SYS_DCACHE_OFF and CONFIG_SYS_ICACHE_OFF */
void __weak enable_caches(void)
/* Enable dCache & iCache, whether cache is actually enabled depend on CONFIG_SYS_DCACHE_OFF and CONFIG_SYS_ICACHE_OFF */ void __weak enable_caches(void)
{ icache_enable(); dcache_enable(); }
4ms/stm32mp1-baremetal
C++
Other
137
/* LED device (Mail LED only, no other LEDs known yet) */
static void mail_led_set(struct led_classdev *led_cdev, enum led_brightness value)
/* LED device (Mail LED only, no other LEDs known yet) */ static void mail_led_set(struct led_classdev *led_cdev, enum led_brightness value)
{ set_u32(value, ACER_CAP_MAILLED); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Return: true if the eraseblock is reserved, false otherwise. */
bool nanddev_isreserved(struct nand_device *nand, const struct nand_pos *pos)
/* Return: true if the eraseblock is reserved, false otherwise. */ bool nanddev_isreserved(struct nand_device *nand, const struct nand_pos *pos)
{ unsigned int entry; int status; if (!nanddev_bbt_is_initialized(nand)) return false; entry = nanddev_bbt_pos_to_entry(nand, pos); status = nanddev_bbt_get_block_status(nand, entry); return status == NAND_BBT_BLOCK_RESERVED; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Used to catch tasks that attempt to return from their implementing function. */
static void prvTaskExitError(void)
/* Used to catch tasks that attempt to return from their implementing function. */ static void prvTaskExitError(void)
{ configASSERT( uxSavedTaskStackPointer == 0UL ); portDISABLE_INTERRUPTS(); for( ;; ); }
labapart/polymcu
C++
null
201
/* Allow only one person to hold it open */
static int epx_c3_open(struct inode *inode, struct file *file)
/* Allow only one person to hold it open */ static int epx_c3_open(struct inode *inode, struct file *file)
{ if (epx_c3_alive) return -EBUSY; if (nowayout) __module_get(THIS_MODULE); epx_c3_start(); epx_c3_pet(); epx_c3_alive = 1; printk(KERN_INFO "Started watchdog timer.\n"); return nonseekable_open(inode, file); }
robutest/uclinux
C++
GPL-2.0
60
/* Remove the kernel and hotplug representations of an I/O Slot. Return Codes: 0 Success -EINVAL Vio dev doesn't exist */
static int dlpar_remove_vio_slot(char *drc_name, struct device_node *dn)
/* Remove the kernel and hotplug representations of an I/O Slot. Return Codes: 0 Success -EINVAL Vio dev doesn't exist */ static int dlpar_remove_vio_slot(char *drc_name, struct device_node *dn)
{ struct vio_dev *vio_dev; vio_dev = vio_find_node(dn); if (!vio_dev) return -EINVAL; vio_unregister_device(vio_dev); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* init WDG as interrupt mode (close reset mode). */
void WDG_IrqInit(void *handler, u32 Id)
/* init WDG as interrupt mode (close reset mode). */ void WDG_IrqInit(void *handler, u32 Id)
{ WDG_TypeDef* WDG = ((WDG_TypeDef *) WDG_REG_BASE); u32 temp = WDG->VENDOR; InterruptRegister((IRQ_FUN)handler, WDG_IRQ, Id, 0); InterruptEn(WDG_IRQ, 0); temp |= WDG_BIT_ISR_CLEAR; temp &= ~WDG_BIT_RST_MODE; WDG->VENDOR = temp; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Performs an atomic compare exchange operation on the 16-bit unsigned integer specified by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue, then Value is returned. The compare exchange operation must be performed using MP safe mechanisms. */
UINT16 EFIAPI InternalSyncCompareExchange16(IN OUT volatile UINT16 *Value, IN UINT16 CompareValue, IN UINT16 ExchangeValue)
/* Performs an atomic compare exchange operation on the 16-bit unsigned integer specified by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue, then Value is returned. The compare exchange operation must be performed using MP safe mechanisms. */ UINT16 EFIAPI InternalSyncCompareExchange16(IN OUT volatile UINT16 *Value, IN UINT16 CompareValue, IN UINT16 ExchangeValue)
{ __asm__ __volatile__ ( "lock \n\t" "cmpxchgw %2, %1 \n\t" : "+a" (CompareValue), "+m" (*Value) : "r" (ExchangeValue) : "memory", "cc" ); return CompareValue; }
tianocore/edk2
C++
Other
4,240
/* Returns: TRUE if @instance is valid, FALSE otherwise */
gboolean g_type_check_instance(GTypeInstance *type_instance)
/* Returns: TRUE if @instance is valid, FALSE otherwise */ gboolean g_type_check_instance(GTypeInstance *type_instance)
{ if (type_instance) { if (type_instance->g_class) { TypeNode *node = lookup_type_node_I (type_instance->g_class->g_type); if (node && node->is_instantiatable) return TRUE; g_warning ("instance of invalid non-instantiatable type '%s'", type_descriptive_name_I (type_instance->g_class->g_type)); } else g_warning ("instance with invalid (NULL) class pointer"); } else g_warning ("invalid (NULL) pointer instance"); return FALSE; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Gets the number of bits transferred per frame. This function gets the number of bits transferred per frame. */
unsigned long xSPIBitLengthGet(unsigned long ulBase)
/* Gets the number of bits transferred per frame. This function gets the number of bits transferred per frame. */ unsigned long xSPIBitLengthGet(unsigned long ulBase)
{ unsigned long ulTmpReg = 0; xASSERT(ulBase == SPI0_BASE); ulTmpReg = xHWREG(ulBase + S0SPCR); if(ulTmpReg & S0SPCR_BIT_EN) { if(ulTmpReg & S0SPCR_BITS_M) { return ((ulTmpReg & S0SPCR_BITS_M) >> S0SPCR_BITS_S); } else { return (16); } } else { return (8); } }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Checks whether the TIM interrupt has occurred or not. */
INTStatus TIM_GetIntStatus(TIM_Module *TIMx, uint32_t TIM_IT)
/* Checks whether the TIM interrupt has occurred or not. */ INTStatus TIM_GetIntStatus(TIM_Module *TIMx, uint32_t TIM_IT)
{ INTStatus bitstatus = RESET; uint32_t itstatus = 0x0, itenable = 0x0; assert_param(IsTimAllModule(TIMx)); assert_param(IsTimGetInt(TIM_IT)); itstatus = TIMx->STS & TIM_IT; itenable = TIMx->DINTEN & TIM_IT; if ((itstatus != (uint32_t)RESET) && (itenable != (uint32_t)RESET)) { bitstatus = SET; } else { bitstatus = RESET; } return bitstatus; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Sends a string out the opened com port. */
void SendComPort(ISP_ENVIRONMENT *IspEnvironment, const char *s)
/* Sends a string out the opened com port. */ void SendComPort(ISP_ENVIRONMENT *IspEnvironment, const char *s)
{ SendComPortBlock(IspEnvironment, s, strlen(s)); }
microbuilder/LPC11U_LPC13U_CodeBase
C++
Other
54
/* The function panics if the request can not be satisfied. */
void* __init __alloc_bootmem(unsigned long size, unsigned long align, unsigned long goal)
/* The function panics if the request can not be satisfied. */ void* __init __alloc_bootmem(unsigned long size, unsigned long align, unsigned long goal)
{ return ___alloc_bootmem(size, align, goal, 0); }
robutest/uclinux
C++
GPL-2.0
60
/* Clears promiscous mode. When called the GMAC falls back to normal operation from promiscous mode. */
void synopGMAC_promisc_disable(synopGMACdevice *gmacdev)
/* Clears promiscous mode. When called the GMAC falls back to normal operation from promiscous mode. */ void synopGMAC_promisc_disable(synopGMACdevice *gmacdev)
{ synopGMACClearBits(gmacdev->MacBase, GmacFrameFilter, GmacPromiscuousMode); return; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Used when configuring the devices ot set the PIO timings. All the actual work is done by the PIO/MWDMA setting helper */
static void cmd64x_set_piomode(struct ata_port *ap, struct ata_device *adev)
/* Used when configuring the devices ot set the PIO timings. All the actual work is done by the PIO/MWDMA setting helper */ static void cmd64x_set_piomode(struct ata_port *ap, struct ata_device *adev)
{ cmd64x_set_timing(ap, adev, adev->pio_mode); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Bind to an existing interdomain event channel in another domain. Returns 0 on success and stores the local port in *port. On error, returns -errno, switches the device to XenbusStateClosing, and saves the error in XenStore. */
int xenbus_bind_evtchn(struct xenbus_device *dev, int remote_port, int *port)
/* Bind to an existing interdomain event channel in another domain. Returns 0 on success and stores the local port in *port. On error, returns -errno, switches the device to XenbusStateClosing, and saves the error in XenStore. */ int xenbus_bind_evtchn(struct xenbus_device *dev, int remote_port, int *port)
{ struct evtchn_bind_interdomain bind_interdomain; int err; bind_interdomain.remote_dom = dev->otherend_id; bind_interdomain.remote_port = remote_port; err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain, &bind_interdomain); if (err) xenbus_dev_fatal(dev, err, "binding to event channel %d from domain %d", remote_port, dev->otherend_id); else *port = bind_interdomain.local_port; return err; }
robutest/uclinux
C++
GPL-2.0
60
/* Closes the device list opened with the function vciEnumDeviceOpen. */
static HRESULT IxxatVciLibFuncVciEnumDeviceClose(HANDLE hEnum)
/* Closes the device list opened with the function vciEnumDeviceOpen. */ static HRESULT IxxatVciLibFuncVciEnumDeviceClose(HANDLE hEnum)
{ HRESULT result = VCI_E_UNEXPECTED; assert(ixxatVciLibFuncVciEnumDeviceClosePtr != NULL); assert(ixxatVciDllHandle != NULL); if ((ixxatVciLibFuncVciEnumDeviceClosePtr != NULL) && (ixxatVciDllHandle != NULL)) { result = ixxatVciLibFuncVciEnumDeviceClosePtr(hEnum); } return result; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* uart_get_lsr_info - get line status register info. Note: uart_ioctl protects us against hangups. */
static int uart_get_lsr_info(struct uart_state *state, unsigned int __user *value)
/* uart_get_lsr_info - get line status register info. Note: uart_ioctl protects us against hangups. */ static int uart_get_lsr_info(struct uart_state *state, unsigned int __user *value)
{ struct uart_port *uport = state->uart_port; struct tty_port *port = &state->port; unsigned int result; result = uport->ops->tx_empty(uport); if (uport->x_char || ((uart_circ_chars_pending(&state->xmit) > 0) && !port->tty->stopped && !port->tty->hw_stopped)) result &= ~TIOCSER_TEMT; return put_user(result, value); }
robutest/uclinux
C++
GPL-2.0
60
/* nilfs_sufile_new - create sufile @nilfs: nilfs object @susize: size of a segment usage entry */
struct inode* nilfs_sufile_new(struct the_nilfs *nilfs, size_t susize)
/* nilfs_sufile_new - create sufile @nilfs: nilfs object @susize: size of a segment usage entry */ struct inode* nilfs_sufile_new(struct the_nilfs *nilfs, size_t susize)
{ struct inode *sufile; sufile = nilfs_mdt_new(nilfs, NULL, NILFS_SUFILE_INO, sizeof(struct nilfs_sufile_info)); if (sufile) nilfs_mdt_set_entry_size(sufile, susize, sizeof(struct nilfs_sufile_header)); return sufile; }
robutest/uclinux
C++
GPL-2.0
60
/* Write info about the ZipFile in the *pglobal_info structure. No preparation of the structure is needed return UNZ_OK if there is no problem. */
int ZEXPORT unzGetCurrentFileInfo64(unzFile file, unz_file_info64 *pfile_info, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)
/* Write info about the ZipFile in the *pglobal_info structure. No preparation of the structure is needed return UNZ_OK if there is no problem. */ int ZEXPORT unzGetCurrentFileInfo64(unzFile file, unz_file_info64 *pfile_info, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)
{ return unz64local_GetCurrentFileInfoInternal(file,pfile_info,NULL, szFileName,fileNameBufferSize, extraField,extraFieldBufferSize, szComment,commentBufferSize); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Set a new parent for an object. Its relative position will be the same. */
void lv_obj_set_parent(lv_obj_t *obj, lv_obj_t *parent)
/* Set a new parent for an object. Its relative position will be the same. */ void lv_obj_set_parent(lv_obj_t *obj, lv_obj_t *parent)
{ if(obj->par == NULL) { LV_LOG_WARN("Can't set the parent of a screen"); return; } if(parent == NULL) { LV_LOG_WARN("Can't set parent == NULL to an object"); return; } lv_obj_invalidate(obj); lv_point_t old_pos; old_pos.x = lv_obj_get_x(obj); old_pos.y = lv_obj_get_y(obj); lv_obj_t * old_par = obj->par; lv_ll_chg_list(&obj->par->child_ll, &parent->child_ll, obj, true); obj->par = parent; lv_obj_set_pos(obj, old_pos.x, old_pos.y); old_par->signal_cb(old_par, LV_SIGNAL_CHILD_CHG, NULL); parent->signal_cb(parent, LV_SIGNAL_CHILD_CHG, obj); lv_obj_invalidate(obj); }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Minimal serial functions needed to use one of the SMC ports as serial console interface. */
void smc1_setbrg(void)
/* Minimal serial functions needed to use one of the SMC ports as serial console interface. */ void smc1_setbrg(void)
{ volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR; volatile cpm8xx_t *cp = &(im->im_cpm); cp->cp_simode = 0x00001000; cp->cp_brgc2 = (((gd->cpu_clk / 16 / RBC823_KBD_BAUDRATE)-1) << 1) | CPM_BRG_EN; }
EmcraftSystems/u-boot
C++
Other
181
/* Converts a FibreEx device path structure to its string representative. */
VOID DevPathToTextFibreEx(IN OUT POOL_PRINT *Str, IN VOID *DevPath, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts)
/* Converts a FibreEx device path structure to its string representative. */ VOID DevPathToTextFibreEx(IN OUT POOL_PRINT *Str, IN VOID *DevPath, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts)
{ FIBRECHANNELEX_DEVICE_PATH *FibreEx; UINTN Index; FibreEx = DevPath; UefiDevicePathLibCatPrint (Str, L"FibreEx(0x"); for (Index = 0; Index < sizeof (FibreEx->WWN) / sizeof (FibreEx->WWN[0]); Index++) { UefiDevicePathLibCatPrint (Str, L"%02x", FibreEx->WWN[Index]); } UefiDevicePathLibCatPrint (Str, L",0x"); for (Index = 0; Index < sizeof (FibreEx->Lun) / sizeof (FibreEx->Lun[0]); Index++) { UefiDevicePathLibCatPrint (Str, L"%02x", FibreEx->Lun[Index]); } UefiDevicePathLibCatPrint (Str, L")"); }
tianocore/edk2
C++
Other
4,240
/* Message: ServiceURLStatReqMessage Opcode: 0x0033 Type: RegistrationAndManagement Direction: dev2pbx VarLength: no */
static void handle_ServiceURLStatReqMessage(ptvcursor_t *cursor, packet_info *pinfo _U_)
/* Message: ServiceURLStatReqMessage Opcode: 0x0033 Type: RegistrationAndManagement Direction: dev2pbx VarLength: no */ static void handle_ServiceURLStatReqMessage(ptvcursor_t *cursor, packet_info *pinfo _U_)
{ ptvcursor_add(cursor, hf_skinny_serviceURLIndex, 4, ENC_LITTLE_ENDIAN); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Forces the TIMx output 3 waveform to active or inactive level. */
void TIM_ForcedOC3Config(TIM_TypeDef *TIMx, uint16_t TIM_ForcedAction)
/* Forces the TIMx output 3 waveform to active or inactive level. */ void TIM_ForcedOC3Config(TIM_TypeDef *TIMx, uint16_t TIM_ForcedAction)
{ uint16_t tmpccmr2 = 0; assert_param(IS_TIM_123458_PERIPH(TIMx)); assert_param(IS_TIM_FORCED_ACTION(TIM_ForcedAction)); tmpccmr2 = TIMx->CCMR2; tmpccmr2 &= CCMR_OC13M_Mask; tmpccmr2 |= TIM_ForcedAction; TIMx->CCMR2 = tmpccmr2; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Set the rate mode allowed by the station once connected. */
sl_status_t sl_wfx_set_tx_rate_parameters(sl_wfx_rate_set_bitmask_t rate_set_bitmask)
/* Set the rate mode allowed by the station once connected. */ sl_status_t sl_wfx_set_tx_rate_parameters(sl_wfx_rate_set_bitmask_t rate_set_bitmask)
{ sl_wfx_set_tx_rate_parameters_req_body_t payload; payload.reserved = 0; memcpy(&payload.rate_set_bitmask, &rate_set_bitmask, sizeof(sl_wfx_rate_set_bitmask_t)); return sl_wfx_send_command(SL_WFX_SET_TX_RATE_PARAMETERS_REQ_ID, &payload, sizeof(payload), SL_WFX_STA_INTERFACE, NULL); }
eclipse-threadx/getting-started
C++
Other
310
/* Auxiliary function used by several library functions: check for an optional thread as function's first argument and set 'arg' with 1 if this argument is present (so that functions can skip it to access their other arguments) */
static lua_State* getthread(lua_State *L, int *arg)
/* Auxiliary function used by several library functions: check for an optional thread as function's first argument and set 'arg' with 1 if this argument is present (so that functions can skip it to access their other arguments) */ static lua_State* getthread(lua_State *L, int *arg)
{ *arg = 1; return lua_tothread(L, 1); } else { *arg = 0; return L; } }
Nicholas3388/LuaNode
C++
Other
1,055
/* Looks up the device configuration based on the unique device ID. A table contains the configuration info for each device in the system. */
XSdPs_Config* XSdPs_LookupConfig(u16 DeviceId)
/* Looks up the device configuration based on the unique device ID. A table contains the configuration info for each device in the system. */ XSdPs_Config* XSdPs_LookupConfig(u16 DeviceId)
{ XSdPs_Config *CfgPtr = NULL; u32 Index; for (Index = 0U; Index < (u32)XPAR_XSDPS_NUM_INSTANCES; Index++) { if (XSdPs_ConfigTable[Index].DeviceId == DeviceId) { CfgPtr = &XSdPs_ConfigTable[Index]; break; } } return (XSdPs_Config *)CfgPtr; } /** @}
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Override the default functions in cpu/ppc4xx/44x_spd_ddr2.c with board specific values. */
static int ppc440spe_rev_a(void)
/* Override the default functions in cpu/ppc4xx/44x_spd_ddr2.c with board specific values. */ static int ppc440spe_rev_a(void)
{ if ((get_pvr() == PVR_440SPe_6_RA) || (get_pvr() == PVR_440SPe_RA)) return 1; else return 0; }
EmcraftSystems/u-boot
C++
Other
181
/* this function is a POSIX compliant version, which cause the regular file referenced by fd to be truncated to a size of precisely length bytes. */
int ftruncate(int fd, off_t length)
/* this function is a POSIX compliant version, which cause the regular file referenced by fd to be truncated to a size of precisely length bytes. */ int ftruncate(int fd, off_t length)
{ int result; struct dfs_file *d; d = fd_get(fd); if (d == NULL) { rt_set_errno(-EBADF); return -1; } if (length < 0) { rt_set_errno(-EINVAL); return -1; } result = dfs_file_ftruncate(d, length); if (result < 0) { rt_set_errno(result); return -1; } return 0; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* If 64-bit MMIO register operations are not supported, then ASSERT(). If StartBit is greater than 63, then ASSERT(). If EndBit is greater than 63, 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(). If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT64 EFIAPI S3MmioBitFieldAndThenOr64(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT64 AndData, IN UINT64 OrData)
/* If 64-bit MMIO register operations are not supported, then ASSERT(). If StartBit is greater than 63, then ASSERT(). If EndBit is greater than 63, 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(). If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */ UINT64 EFIAPI S3MmioBitFieldAndThenOr64(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT64 AndData, IN UINT64 OrData)
{ return InternalSaveMmioWrite64ValueToBootScript (Address, MmioBitFieldAndThenOr64 (Address, StartBit, EndBit, AndData, OrData)); }
tianocore/edk2
C++
Other
4,240
/* Programs a half word at a specified address. */
FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data)
/* Programs a half word at a specified address. */ FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data)
{ FLASH_Status status = FLASH_COMPLETE; assert_param(IS_FLASH_PROGRAM_ADDRESS(Address)); status = FLASH_WaitForLastOperation(FLASH_ER_PRG_TIMEOUT); if (status == FLASH_COMPLETE) { FLASH->CR |= FLASH_CR_PG; *(__IO uint16_t *)Address = Data; status = FLASH_WaitForLastOperation(FLASH_ER_PRG_TIMEOUT); FLASH->CR &= ~FLASH_CR_PG; } return status; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function closes a specified file handle. All "dirty" cached file data is flushed to the device, and the file is closed. In all cases the handle is closed. */
EFI_STATUS EFIAPI FileHandleClose(IN EFI_FILE_HANDLE FileHandle)
/* This function closes a specified file handle. All "dirty" cached file data is flushed to the device, and the file is closed. In all cases the handle is closed. */ EFI_STATUS EFIAPI FileHandleClose(IN EFI_FILE_HANDLE FileHandle)
{ EFI_STATUS Status; if (FileHandle == NULL) { return (EFI_INVALID_PARAMETER); } Status = FileHandle->Close (FileHandle); return Status; }
tianocore/edk2
C++
Other
4,240
/* Notes: We do not need to lock this. There is the potential for a race only in that the normal completion handling might run, but if the normal completion function determines that the timer has already fired, then it mustn't do anything. */
enum blk_eh_timer_return scsi_times_out(struct request *req)
/* Notes: We do not need to lock this. There is the potential for a race only in that the normal completion handling might run, but if the normal completion function determines that the timer has already fired, then it mustn't do anything. */ enum blk_eh_timer_return scsi_times_out(struct request *req)
{ struct scsi_cmnd *scmd = req->special; enum blk_eh_timer_return rtn = BLK_EH_NOT_HANDLED; scsi_log_completion(scmd, TIMEOUT_ERROR); if (scmd->device->host->transportt->eh_timed_out) rtn = scmd->device->host->transportt->eh_timed_out(scmd); else if (scmd->device->host->hostt->eh_timed_out) rtn = scmd->device->host->hostt->eh_timed_out(scmd); if (unlikely(rtn == BLK_EH_NOT_HANDLED && !scsi_eh_scmd_add(scmd, SCSI_EH_CANCEL_CMD))) { scmd->result |= DID_TIME_OUT << 16; rtn = BLK_EH_HANDLED; } return rtn; }
robutest/uclinux
C++
GPL-2.0
60
/* Reads last received SPI character. This function will return the last SPI character shifted into the receive register by the */
enum status_code spi_read(struct spi_module *const module, uint8_t *rx_data)
/* Reads last received SPI character. This function will return the last SPI character shifted into the receive register by the */ enum status_code spi_read(struct spi_module *const module, uint8_t *rx_data)
{ Assert(module); Assert(module->hw); Spi *const spi_module = (module->hw); if (!_spi_is_ready_to_read(spi_module)) { return STATUS_ERR_IO; } enum status_code retval = STATUS_OK; if (spi_module->RECEIVE_STATUS.bit.FIFO_OVERRUN) { retval = STATUS_ERR_OVERFLOW; } *rx_data = ((uint8_t)spi_module->RECEIVE_DATA.reg & SPI_RECEIVE_DATA_MASK); return retval; }
memfault/zero-to-main
C++
null
200
/* ch Pointer to channel struct to be released. */
static void channel_free(struct channel *ch)
/* ch Pointer to channel struct to be released. */ static void channel_free(struct channel *ch)
{ CTCM_DBF_TEXT_(SETUP, CTC_DBF_INFO, "%s(%s)", CTCM_FUNTAIL, ch->id); ch->flags &= ~CHANNEL_FLAGS_INUSE; fsm_newstate(ch->fsm, CTC_STATE_IDLE); }
robutest/uclinux
C++
GPL-2.0
60
/* The constructor function for the Traditional MM library instance without STM. */
EFI_STATUS EFIAPI SmmCpuFeaturesLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
/* The constructor function for the Traditional MM library instance without STM. */ EFI_STATUS EFIAPI SmmCpuFeaturesLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
{ CpuFeaturesLibInitialization (); return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* General Purpose Input/Outputs Determine if interrupt is generated by the given pin. */
uint8_t gpio_is_interrupt_source(uint32_t gpioport, uint8_t gpios)
/* General Purpose Input/Outputs Determine if interrupt is generated by the given pin. */ uint8_t gpio_is_interrupt_source(uint32_t gpioport, uint8_t gpios)
{ return GPIO_MIS(gpioport) & gpios; }
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* It copies the amount of data contained into 'buffer' into 'tempbuf'. and it checks for buffer overflows. This function is useful in case the userland application does not know immediately all the data it has to write into the socket. This function provides a way to create the "stream" step by step, appending the new data to the old one. Then, when all the data has been bufferized, the application can call the */
int sock_bufferize(const char *buffer, int size, char *tempbuf, int *offset, int totsize, int checkonly, char *errbuf, int errbuflen)
/* It copies the amount of data contained into 'buffer' into 'tempbuf'. and it checks for buffer overflows. This function is useful in case the userland application does not know immediately all the data it has to write into the socket. This function provides a way to create the "stream" step by step, appending the new data to the old one. Then, when all the data has been bufferized, the application can call the */ int sock_bufferize(const char *buffer, int size, char *tempbuf, int *offset, int totsize, int checkonly, char *errbuf, int errbuflen)
{ if ((*offset + size) > totsize) { if (errbuf) pcap_snprintf(errbuf, errbuflen, "Not enough space in the temporary send buffer."); return -1; } if (!checkonly) memcpy(tempbuf + (*offset), buffer, size); (*offset) += size; return 0; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Enable the DMA of the specified SPI port. The */
void xSPIDMAEnable(unsigned long ulBase, unsigned long ulDmaMode)
/* Enable the DMA of the specified SPI port. The */ void xSPIDMAEnable(unsigned long ulBase, unsigned long ulDmaMode)
{ xASSERT(ulBase == SPI0_BASE); xHWREG(ulBase + SPI_DMA) |= ulDmaMode; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* enable the oscillator bypass mode, HXTALEN or LXTALEN must be reset before it */
void rcu_osci_bypass_mode_enable(rcu_osci_type_enum osci)
/* enable the oscillator bypass mode, HXTALEN or LXTALEN must be reset before it */ void rcu_osci_bypass_mode_enable(rcu_osci_type_enum osci)
{ uint32_t reg; switch(osci){ case RCU_HXTAL: reg = RCU_CTL; RCU_CTL &= ~RCU_CTL_HXTALEN; RCU_CTL = (reg | RCU_CTL_HXTALBPS); break; case RCU_LXTAL: reg = RCU_BDCTL; RCU_BDCTL &= ~RCU_BDCTL_LXTALEN; RCU_BDCTL = (reg | RCU_BDCTL_LXTALBPS); break; case RCU_IRC8M: case RCU_IRC40K: case RCU_PLL_CK: case RCU_PLL1_CK: case RCU_PLL2_CK: break; default: break; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function is a wrapper to get file using TFTP. */
EFI_STATUS PxeBcTftpReadFile(IN PXEBC_PRIVATE_DATA *Private, IN VOID *Config, IN UINT8 *Filename, IN UINTN *BlockSize, IN UINTN *WindowSize, IN UINT8 *BufferPtr, IN OUT UINT64 *BufferSize, IN BOOLEAN DontUseBuffer)
/* This function is a wrapper to get file using TFTP. */ EFI_STATUS PxeBcTftpReadFile(IN PXEBC_PRIVATE_DATA *Private, IN VOID *Config, IN UINT8 *Filename, IN UINTN *BlockSize, IN UINTN *WindowSize, IN UINT8 *BufferPtr, IN OUT UINT64 *BufferSize, IN BOOLEAN DontUseBuffer)
{ if (Private->PxeBc.Mode->UsingIpv6) { return PxeBcMtftp6ReadFile ( Private, (EFI_MTFTP6_CONFIG_DATA *)Config, Filename, BlockSize, WindowSize, BufferPtr, BufferSize, DontUseBuffer ); } else { return PxeBcMtftp4ReadFile ( Private, (EFI_MTFTP4_CONFIG_DATA *)Config, Filename, BlockSize, WindowSize, BufferPtr, BufferSize, DontUseBuffer ); } }
tianocore/edk2
C++
Other
4,240