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
/* Initialize the GPIO Alternative Functions of the LPC178x/7x. */
void __init lpc178x_iomux_init(void)
/* Initialize the GPIO Alternative Functions of the LPC178x/7x. */ void __init lpc178x_iomux_init(void)
{ int platform; lpc178x_periph_enable(LPC178X_SCC_PCONP_PCGPIO_MSK, 1); platform = lpc178x_platform_get(); switch (platform) { case PLATFORM_LPC178X_EA_LPC1788: lpc178x_gpio_config_table( ea_lpc1788_gpio, ARRAY_SIZE(ea_lpc1788_gpio)); break; case PLATFORM_LPC178X_LNX_EVB: lpc178x_gpio_config_table( lpc_lnx_evb_gpio, ARRAY_SIZE(lpc_lnx_evb_gpio)); break; default: printk(KERN_WARNING "%s: unsupported platform %d\n", __func__, platform); break; } }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Return the io register to perform required cache action like clean or clean & invalidate by sets/ways. */
static u32* get_action_reg_set_ways(enum cache_action action)
/* Return the io register to perform required cache action like clean or clean & invalidate by sets/ways. */ static u32* get_action_reg_set_ways(enum cache_action action)
{ switch (action) { case INVALIDATE_SET_WAY: return V7M_CACHE_REG_DCISW; case FLUSH_SET_WAY: return V7M_CACHE_REG_DCCSW; case FLUSH_INVAL_SET_WAY: return V7M_CACHE_REG_DCCISW; default: break; }; return NULL; }
4ms/stm32mp1-baremetal
C++
Other
137
/* An extra init hook that enables the RuntimeDxe library instance to register VirtualAddress change callbacks. Among other things. */
EFI_STATUS VariablePolicyExtraInit(VOID)
/* An extra init hook that enables the RuntimeDxe library instance to register VirtualAddress change callbacks. Among other things. */ EFI_STATUS VariablePolicyExtraInit(VOID)
{ return gBS->CreateEventEx ( EVT_NOTIFY_SIGNAL, TPL_NOTIFY, VariablePolicyLibVirtualAddressCallback, NULL, &gEfiEventVirtualAddressChangeGuid, &mVariablePolicyLibVirtualAddressChangeEvent ); }
tianocore/edk2
C++
Other
4,240
/* This is much like hpsb_node_write(), except it ignores the response subaction and returns immediately. Can be used from atomic context. */
static int sbp2util_node_write_no_wait(struct node_entry *ne, u64 addr, quadlet_t *buf, size_t len)
/* This is much like hpsb_node_write(), except it ignores the response subaction and returns immediately. Can be used from atomic context. */ static int sbp2util_node_write_no_wait(struct node_entry *ne, u64 addr, quadlet_t *buf, size_t len)
{ struct hpsb_packet *packet; packet = hpsb_make_writepacket(ne->host, ne->nodeid, addr, buf, len); if (!packet) return -ENOMEM; hpsb_set_packet_complete_task(packet, sbp2_free_packet, packet); hpsb_node_fill_packet(ne, packet); if (hpsb_send_packet(packet) < 0) { sbp2_free_packet(packet); return -EIO; } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* This function relies on all ring buffer implementations having an iio_ring_buffer as their first element. */
int iio_ring_open(struct inode *inode, struct file *filp)
/* This function relies on all ring buffer implementations having an iio_ring_buffer as their first element. */ int iio_ring_open(struct inode *inode, struct file *filp)
{ struct iio_handler *hand = container_of(inode->i_cdev, struct iio_handler, chrdev); struct iio_ring_buffer *rb = hand->private; filp->private_data = hand->private; if (rb->access.mark_in_use) rb->access.mark_in_use(rb); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* note This function must be called by the lock owner. */
void XRDC2_UnlockPeriphExclAccess(XRDC2_Type *base, xrdc2_periph_t periph)
/* note This function must be called by the lock owner. */ void XRDC2_UnlockPeriphExclAccess(XRDC2_Type *base, xrdc2_periph_t periph)
{ uint32_t pac = XRDC2_GET_PAC((uint32_t)periph); uint32_t pdac = XRDC2_GET_PDAC((uint32_t)periph); base->PACI_PDACJ[pac][pdac].PAC_PDAC_W1 = XRDC2_EAL_UNLOCKED; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Set a group of Pins. Set a group of Pins for the given port. */
void gpio_set(uint32_t gpioport, uint32_t gpios)
/* Set a group of Pins. Set a group of Pins for the given port. */ void gpio_set(uint32_t gpioport, uint32_t gpios)
{ PORT_OUTSET(gpioport) = gpios; }
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* pci_platform_power_transition - Use platform to change device power state @dev: PCI device to handle. @state: State to put the device into. */
static int pci_platform_power_transition(struct pci_dev *dev, pci_power_t state)
/* pci_platform_power_transition - Use platform to change device power state @dev: PCI device to handle. @state: State to put the device into. */ static int pci_platform_power_transition(struct pci_dev *dev, pci_power_t state)
{ int error; if (platform_pci_power_manageable(dev)) { error = platform_pci_set_power_state(dev, state); if (!error) pci_update_current_state(dev, state); } else { error = -ENODEV; if (!dev->pm_cap) dev->current_state = PCI_D0; } return error; }
robutest/uclinux
C++
GPL-2.0
60
/* Calculate number of records in an alloc btree block. */
int xfs_allocbt_maxrecs(struct xfs_mount *mp, int blocklen, int leaf)
/* Calculate number of records in an alloc btree block. */ int xfs_allocbt_maxrecs(struct xfs_mount *mp, int blocklen, int leaf)
{ blocklen -= XFS_ALLOC_BLOCK_LEN(mp); if (leaf) return blocklen / sizeof(xfs_alloc_rec_t); return blocklen / (sizeof(xfs_alloc_key_t) + sizeof(xfs_alloc_ptr_t)); }
robutest/uclinux
C++
GPL-2.0
60
/* Converts a 2 digit decimal to BCD format. */
static uint8_t RTC_ByteConBcd2(uint8_t val)
/* Converts a 2 digit decimal to BCD format. */ static uint8_t RTC_ByteConBcd2(uint8_t val)
{ uint8_t bcdhigh = 0; while (val >= 10) { bcdhigh++; val -= 10; } return ((uint8_t)(bcdhigh << 4) | val); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* The initial reference count of a newly created #GParamSpec is 1, even though no one has explicitly called g_param_spec_ref() on it yet. So the initial reference count is flagged as "floating", until someone calls */
void g_param_spec_sink(GParamSpec *pspec)
/* The initial reference count of a newly created #GParamSpec is 1, even though no one has explicitly called g_param_spec_ref() on it yet. So the initial reference count is flagged as "floating", until someone calls */ void g_param_spec_sink(GParamSpec *pspec)
{ gsize oldvalue; g_return_if_fail (G_IS_PARAM_SPEC (pspec)); oldvalue = g_atomic_pointer_and (&pspec->qdata, ~(gsize)PARAM_FLOATING_FLAG); if (oldvalue & PARAM_FLOATING_FLAG) g_param_spec_unref (pspec); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Event handler for the library USB Control Request reception event. */
void EVENT_USB_Device_ControlRequest(void)
/* Event handler for the library USB Control Request reception event. */ void EVENT_USB_Device_ControlRequest(void)
{ HID_Device_ProcessControlRequest(&Device_HID_Interface); }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* param base Pointer to FLEXIO_UART_Type param handle Pointer to flexio_uart_edma_handle_t structure */
void FLEXIO_UART_TransferAbortReceiveEDMA(FLEXIO_UART_Type *base, flexio_uart_edma_handle_t *handle)
/* param base Pointer to FLEXIO_UART_Type param handle Pointer to flexio_uart_edma_handle_t structure */ void FLEXIO_UART_TransferAbortReceiveEDMA(FLEXIO_UART_Type *base, flexio_uart_edma_handle_t *handle)
{ assert(handle->rxEdmaHandle); FLEXIO_UART_EnableRxDMA(base, false); EDMA_StopTransfer(handle->rxEdmaHandle); handle->rxState = kFLEXIO_UART_RxIdle; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns the size of the whole device in bytes (this does not include the size of the spare zones). */
uint64_t nand_flash_model_get_device_size_in_bytes(const struct nand_flash_model *model)
/* Returns the size of the whole device in bytes (this does not include the size of the spare zones). */ uint64_t nand_flash_model_get_device_size_in_bytes(const struct nand_flash_model *model)
{ return ((uint64_t) model->device_size_in_megabytes) << 20; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Unregisters a callback. Unregisters a callback function which is implemented by the user. */
void wdt_unregister_callback(struct wdt_module *module, enum wdt_callback callback_type)
/* Unregisters a callback. Unregisters a callback function which is implemented by the user. */ void wdt_unregister_callback(struct wdt_module *module, enum wdt_callback callback_type)
{ Assert(module); module->callback[callback_type] = NULL; module->callback_reg_mask &= ~(1 << callback_type); }
memfault/zero-to-main
C++
null
200
/* Main program entry point. This routine configures the hardware required by the application, then enters a loop to run the application tasks in sequence. */
int main(void)
/* Main program entry point. This routine configures the hardware required by the application, then enters a loop to run the application tasks in sequence. */ int main(void)
{ SetupHardware(); TCP_Init(); Webserver_Init(); LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); GlobalInterruptEnable(); for (;;) { Ethernet_Task(); TCP_Task(); RNDIS_Task(); USB_USBTask(); } }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Get the top enable attribute of an object */
bool lv_obj_get_top(const lv_obj_t *obj)
/* Get the top enable attribute of an object */ bool lv_obj_get_top(const lv_obj_t *obj)
{ return obj->top == 0 ? false : true; }
RavenSystem/esp-homekit-devices
C++
Other
2,577
/* Gets skb from system, queues it and checks if it can be sent */
static netdev_tx_t tms380tr_send_packet(struct sk_buff *skb, struct net_device *dev)
/* Gets skb from system, queues it and checks if it can be sent */ static netdev_tx_t tms380tr_send_packet(struct sk_buff *skb, struct net_device *dev)
{ struct net_local *tp = netdev_priv(dev); netdev_tx_t rc; rc = tms380tr_hardware_send_packet(skb, dev); if(tp->TplFree->NextTPLPtr->BusyFlag) netif_stop_queue(dev); return rc; }
robutest/uclinux
C++
GPL-2.0
60
/* We are guaranteeing that the request queue will be goosed at some point during this call. Notes: If cmd was requeued, upon return it will be a stale pointer. */
static struct scsi_cmnd* scsi_end_request(struct scsi_cmnd *cmd, int error, int bytes, int requeue)
/* We are guaranteeing that the request queue will be goosed at some point during this call. Notes: If cmd was requeued, upon return it will be a stale pointer. */ static struct scsi_cmnd* scsi_end_request(struct scsi_cmnd *cmd, int error, int bytes, int requeue)
{ struct request_queue *q = cmd->device->request_queue; struct request *req = cmd->request; if (blk_end_request(req, error, bytes)) { if (error && scsi_noretry_cmd(cmd)) blk_end_request_all(req, error); else { if (requeue) { scsi_release_buffers(cmd); scsi_requeue_command(q, cmd); cmd = NULL; } return cmd; } } __scsi_release_buffers(cmd, 0); scsi_next_command(cmd); return NULL; }
robutest/uclinux
C++
GPL-2.0
60
/* This function gets the video timing structure settings currently used by generator in the VTC core. */
void XVtc_GetGeneratorTiming(XVtc *InstancePtr, XVtc_Timing *TimingPtr)
/* This function gets the video timing structure settings currently used by generator in the VTC core. */ void XVtc_GetGeneratorTiming(XVtc *InstancePtr, XVtc_Timing *TimingPtr)
{ XVtc_Polarity Polarity; XVtc_Signal Signal; XVtc_HoriOffsets Hoff; Xil_AssertVoid(InstancePtr != NULL); Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); Xil_AssertVoid(TimingPtr != NULL); Signal.OriginMode = 1; XVtc_GetPolarity(InstancePtr, &Polarity); XVtc_GetGeneratorHoriOffset(InstancePtr, &Hoff); XVtc_GetGenerator(InstancePtr, &Signal); XVtc_ConvSignal2Timing(InstancePtr, &Signal, &Hoff, &Polarity, TimingPtr); }
ua1arn/hftrx
C++
null
69
/* Clears or safeguards the OCREF1 signal on an external event. */
void TMR_ClearOC1Ref(TMR_T *tmr, TMR_OC_CLEAR_T OCClear)
/* Clears or safeguards the OCREF1 signal on an external event. */ void TMR_ClearOC1Ref(TMR_T *tmr, TMR_OC_CLEAR_T OCClear)
{ tmr->CCM1_COMPARE_B.OC1CEN = OCClear; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Close current connection from a client to the server. */
WIFI_Status_t WIFI_CloseServerConnection(int socket)
/* Close current connection from a client to the server. */ WIFI_Status_t WIFI_CloseServerConnection(int socket)
{ WIFI_Status_t ret = WIFI_STATUS_ERROR; if (ES_WIFI_STATUS_OK == ES_WIFI_CloseServerConnection(&EsWifiObj,socket)) { ret = WIFI_STATUS_OK; } return ret; }
eclipse-threadx/getting-started
C++
Other
310
/* Searches for the next matching file in the firmware volume. */
EFI_STATUS EFIAPI PeiFfsFindNextFile(IN CONST EFI_PEI_SERVICES **PeiServices, IN UINT8 SearchType, IN EFI_PEI_FV_HANDLE FvHandle, IN OUT EFI_PEI_FILE_HANDLE *FileHandle)
/* Searches for the next matching file in the firmware volume. */ EFI_STATUS EFIAPI PeiFfsFindNextFile(IN CONST EFI_PEI_SERVICES **PeiServices, IN UINT8 SearchType, IN EFI_PEI_FV_HANDLE FvHandle, IN OUT EFI_PEI_FILE_HANDLE *FileHandle)
{ PEI_CORE_FV_HANDLE *CoreFvHandle; CoreFvHandle = FvHandleToCoreHandle (FvHandle); if ((CoreFvHandle == NULL) || (CoreFvHandle->FvPpi == NULL)) { return EFI_NOT_FOUND; } return CoreFvHandle->FvPpi->FindFileByType (CoreFvHandle->FvPpi, SearchType, FvHandle, FileHandle); }
tianocore/edk2
C++
Other
4,240
/* __vxge_hw_ring_block_memblock_idx - Return the memblock index This function returns the index of memory block */
static u32 __vxge_hw_ring_block_memblock_idx(u8 *block)
/* __vxge_hw_ring_block_memblock_idx - Return the memblock index This function returns the index of memory block */ static u32 __vxge_hw_ring_block_memblock_idx(u8 *block)
{ return (u32)*((u64 *)(block + VXGE_HW_RING_MEMBLOCK_IDX_OFFSET)); }
robutest/uclinux
C++
GPL-2.0
60
/* 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)
{ xHWREG(ulPort + FIOMASK) = ~ulPins; return xHWREG(ulPort + FIOPIN); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Allocates and returns a cdev structure, or NULL on failure. */
struct cdev* cdev_alloc(void)
/* Allocates and returns a cdev structure, or NULL on failure. */ struct cdev* cdev_alloc(void)
{ struct cdev *p = kzalloc(sizeof(struct cdev), GFP_KERNEL); if (p) { INIT_LIST_HEAD(&p->list); kobject_init(&p->kobj, &ktype_cdev_dynamic); } return p; }
robutest/uclinux
C++
GPL-2.0
60
/* return the string of binary of u8 in the format of 1010 10_0. The masked bit is filled as underscore. */
const char* byte_to_binary_mask(u8 val, u8 mask, char *buf)
/* return the string of binary of u8 in the format of 1010 10_0. The masked bit is filled as underscore. */ const char* byte_to_binary_mask(u8 val, u8 mask, char *buf)
{ char *ptr; int i; ptr = buf; for (i = 0x80; i > 0x08 ; i >>= 1, ptr++) *ptr = (val & i) ? '1' : ((mask & i) ? '_' : '0'); *(ptr++) = ' '; for (i = 0x08; i > 0 ; i >>= 1, ptr++) *ptr = (val & i) ? '1' : ((mask & i) ? '_' : '0'); *ptr = '\0'; return buf; }
4ms/stm32mp1-baremetal
C++
Other
137
/* The insnslot_?arg_rflags() functions below are to keep the msr -> *fn -> mrs instruction sequences indivisible so that the state of the CPSR flags aren't inadvertently modified just before or just after the call. */
static long __kprobes insnslot_0arg_rflags(long cpsr, insn_0arg_fn_t *fn)
/* The insnslot_?arg_rflags() functions below are to keep the msr -> *fn -> mrs instruction sequences indivisible so that the state of the CPSR flags aren't inadvertently modified just before or just after the call. */ static long __kprobes insnslot_0arg_rflags(long cpsr, insn_0arg_fn_t *fn)
{ register long ret asm("r0"); __asm__ __volatile__ ( "msr cpsr_fs, %[cpsr] \n\t" "mov lr, pc \n\t" "mov pc, %[fn] \n\t" : "=r" (ret) : [cpsr] "r" (cpsr), [fn] "r" (fn) : "lr", "cc" ); return ret; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Sort @mode_list by favorability, putting good modes first. */
void drm_mode_sort(struct list_head *mode_list)
/* Sort @mode_list by favorability, putting good modes first. */ void drm_mode_sort(struct list_head *mode_list)
{ list_sort(NULL, mode_list, drm_mode_compare); }
robutest/uclinux
C++
GPL-2.0
60
/* hf_index must be a FT_UINT_STRING type Are these always in the Mac extended character set? */
static int dissect_pascal_string(tvbuff_t *tvb, int offset, proto_tree *tree, int hf_index)
/* hf_index must be a FT_UINT_STRING type Are these always in the Mac extended character set? */ static int dissect_pascal_string(tvbuff_t *tvb, int offset, proto_tree *tree, int hf_index)
{ int len; len = tvb_get_guint8(tvb, offset); proto_tree_add_item(tree, hf_index, tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); offset += (len+1); return offset; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Note that we don't use the hw_write function pointer of snd_soc_codec. That's because it's too clunky: the hw_write_t prototype does not match i2c_smbus_write_byte_data(), and it's just another layer of overhead. */
static int cs4270_i2c_write(struct snd_soc_codec *codec, unsigned int reg, unsigned int value)
/* Note that we don't use the hw_write function pointer of snd_soc_codec. That's because it's too clunky: the hw_write_t prototype does not match i2c_smbus_write_byte_data(), and it's just another layer of overhead. */ static int cs4270_i2c_write(struct snd_soc_codec *codec, unsigned int reg, unsigned int value)
{ u8 *cache = codec->reg_cache; if ((reg < CS4270_FIRSTREG) || (reg > CS4270_LASTREG)) return -EIO; if (cache[reg - CS4270_FIRSTREG] != value) { struct i2c_client *client = codec->control_data; if (i2c_smbus_write_byte_data(client, reg, value)) { dev_err(codec->dev, "i2c write failed\n"); return -EIO; } cache[reg - CS4270_FIRSTREG] = value; } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Returns 1 on success, or < 0 for error. */
int get_pxe_file(cmd_tbl_t *cmdtp, const char *file_path, unsigned long file_addr)
/* Returns 1 on success, or < 0 for error. */ int get_pxe_file(cmd_tbl_t *cmdtp, const char *file_path, unsigned long file_addr)
{ unsigned long config_file_size; char *tftp_filesize; int err; char *buf; err = get_relfile(cmdtp, file_path, file_addr); if (err < 0) return err; tftp_filesize = from_env("filesize"); if (!tftp_filesize) return -ENOENT; if (strict_strtoul(tftp_filesize, 16, &config_file_size) < 0) return -EINVAL; buf = map_sysmem(file_addr + config_file_size, 1); *buf = '\0'; unmap_sysmem(buf); return 1; }
4ms/stm32mp1-baremetal
C++
Other
137
/* This function read a character from serial without interrupt enable mode */
char rt_serial_getc()
/* This function read a character from serial without interrupt enable mode */ char rt_serial_getc()
{ while ((UTRSTAT0 & USTAT_RCV_READY) == 0); return URXH0; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Clear out all data in the circular buffer. */
static void gs_buf_clear(struct gs_buf *gb)
/* Clear out all data in the circular buffer. */ static void gs_buf_clear(struct gs_buf *gb)
{ gb->buf_get = gb->buf_put; }
robutest/uclinux
C++
GPL-2.0
60
/* Event handler for the USB_ConfigurationChanged event. This is fired when the host sets the current configuration of the USB device after enumeration, and configures the keyboard and mouse device endpoints. */
void EVENT_USB_Device_ConfigurationChanged(void)
/* Event handler for the USB_ConfigurationChanged event. This is fired when the host sets the current configuration of the USB device after enumeration, and configures the keyboard and mouse device endpoints. */ void EVENT_USB_Device_ConfigurationChanged(void)
{ bool ConfigSuccess = true; ConfigSuccess &= Endpoint_ConfigureEndpoint(KEYBOARD_IN_EPADDR, EP_TYPE_INTERRUPT, HID_EPSIZE, 1); ConfigSuccess &= Endpoint_ConfigureEndpoint(KEYBOARD_OUT_EPADDR, EP_TYPE_INTERRUPT, HID_EPSIZE, 1); ConfigSuccess &= Endpoint_ConfigureEndpoint(MOUSE_IN_EPADDR, EP_TYPE_INTERRUPT, HID_EPSIZE, 1); LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR); }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* If no initialization is required, then return RETURN_SUCCESS. If the serial device was successfully initialized, then return RETURN_SUCCESS. If the serial device could not be initialized, then return RETURN_DEVICE_ERROR. */
RETURN_STATUS EFIAPI SerialPortInitialize(VOID)
/* If no initialization is required, then return RETURN_SUCCESS. If the serial device was successfully initialized, then return RETURN_SUCCESS. If the serial device could not be initialized, then return RETURN_DEVICE_ERROR. */ RETURN_STATUS EFIAPI SerialPortInitialize(VOID)
{ if (!XenHypercallIsAvailable ()) { return RETURN_DEVICE_ERROR; } if (!mXenConsoleInterface) { mXenConsoleEventChain.port = (UINT32)XenHypercallHvmGetParam (HVM_PARAM_CONSOLE_EVTCHN); mXenConsoleInterface = (struct xencons_interface *)(UINTN) (XenHypercallHvmGetParam (HVM_PARAM_CONSOLE_PFN) << EFI_PAGE_SHIFT); } return RETURN_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Slave receive a byte to I2C bus. This function is to receive a byte on specified I2C BUS. */
unsigned long xI2CSlaveDataGet(unsigned long ulBase)
/* Slave receive a byte to I2C bus. This function is to receive a byte on specified I2C BUS. */ unsigned long xI2CSlaveDataGet(unsigned long ulBase)
{ return xI2CMasterDataGet(ulBase); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* The modification state of any associated pages is left unchanged. The buffer most not be on any hash - use xfs_buf_rele instead for hashed and refcounted buffers */
void xfs_buf_free(xfs_buf_t *bp)
/* The modification state of any associated pages is left unchanged. The buffer most not be on any hash - use xfs_buf_rele instead for hashed and refcounted buffers */ void xfs_buf_free(xfs_buf_t *bp)
{ trace_xfs_buf_free(bp, _RET_IP_); ASSERT(list_empty(&bp->b_hash_list)); if (bp->b_flags & (_XBF_PAGE_CACHE|_XBF_PAGES)) { uint i; if ((bp->b_flags & XBF_MAPPED) && (bp->b_page_count > 1)) free_address(bp->b_addr - bp->b_offset); for (i = 0; i < bp->b_page_count; i++) { struct page *page = bp->b_pages[i]; if (bp->b_flags & _XBF_PAGE_CACHE) ASSERT(!PagePrivate(page)); page_cache_release(page); } } _xfs_buf_free_pages(bp); xfs_buf_deallocate(bp); }
robutest/uclinux
C++
GPL-2.0
60
/* udc_startup - allow udc code to do any additional startup */
void udc_startup_events(struct usb_device_instance *device)
/* udc_startup - allow udc code to do any additional startup */ void udc_startup_events(struct usb_device_instance *device)
{ usbd_device_event_irq (device, DEVICE_INIT, 0); usbd_device_event_irq (device, DEVICE_CREATE, 0); udc_enable (device); }
EmcraftSystems/u-boot
C++
Other
181
/* General Purpose Input/Outputs Clear a Group of Pins Atomic. Clear one or more pins of the given GPIO port to 0 in an atomic operation. */
void gpio_clear(uint32_t gpioport, uint8_t gpios)
/* General Purpose Input/Outputs Clear a Group of Pins Atomic. Clear one or more pins of the given GPIO port to 0 in an atomic operation. */ void gpio_clear(uint32_t gpioport, uint8_t gpios)
{ GPIO_DATA(gpioport)[gpios] = 0x0; }
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* Returns: 0 on success 1 when the timer was active */
int hrtimer_start(struct hrtimer *timer, ktime_t tim, const enum hrtimer_mode mode)
/* Returns: 0 on success 1 when the timer was active */ int hrtimer_start(struct hrtimer *timer, ktime_t tim, const enum hrtimer_mode mode)
{ return __hrtimer_start_range_ns(timer, tim, 0, mode, 1); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Disable the interrupt mode for the selected IO pin(s). */
void stmpe1600_IO_DisablePinIT(uint16_t DeviceAddr, uint32_t IO_Pin)
/* Disable the interrupt mode for the selected IO pin(s). */ void stmpe1600_IO_DisablePinIT(uint16_t DeviceAddr, uint32_t IO_Pin)
{ uint8_t tmpData[2] = {0 , 0}; IOE_ReadMultiple(DeviceAddr, STMPE1600_REG_IEGPIOR, tmpData, 2); tmp = ((uint16_t)tmpData[0] | (((uint16_t)tmpData[1]) << 8)); tmp &= ~(uint16_t)IO_Pin; IOE_WriteMultiple(DeviceAddr, STMPE1600_REG_IEGPIOR, (uint8_t *)&tmp, 2); }
eclipse-threadx/getting-started
C++
Other
310
/* If the requested operation results in an overflow or an underflow condition, then Result is set to INT64_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeInt64Sub(IN INT64 Minuend, IN INT64 Subtrahend, OUT INT64 *Result)
/* If the requested operation results in an overflow or an underflow condition, then Result is set to INT64_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */ RETURN_STATUS EFIAPI SafeInt64Sub(IN INT64 Minuend, IN INT64 Subtrahend, OUT INT64 *Result)
{ RETURN_STATUS Status; if (Result == NULL) { return RETURN_INVALID_PARAMETER; } if (((Subtrahend > 0) && (Minuend < (MIN_INT64 + Subtrahend))) || ((Subtrahend < 0) && (Minuend > (MAX_INT64 + Subtrahend)))) { *Result = INT64_ERROR; Status = RETURN_BUFFER_TOO_SMALL; } else { *Result = Minuend - Subtrahend; Status = RETURN_SUCCESS; } return Status; }
tianocore/edk2
C++
Other
4,240
/* Obtains value of entry length in transmit queue/FIFO. This value covers both fixed-sized frame header block and payload buffer. User can configure payload buffer size. */
unsigned fdcan_get_txbuf_element_size(uint32_t canport)
/* Obtains value of entry length in transmit queue/FIFO. This value covers both fixed-sized frame header block and payload buffer. User can configure payload buffer size. */ unsigned fdcan_get_txbuf_element_size(uint32_t canport)
{ unsigned element_size; element_size = (FDCAN_TXESC(canport) >> FDCAN_TXESC_TBDS_SHIFT) & FDCAN_TXESC_TBDS_MASK; return 8 + fdcan_dlc_to_length((element_size & FDCAN_TXESC_TBDS_MASK) | 0x8); }
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* This API validates the ODR value set by the user. param bandwidth : odr for accelerometer */
static uint16_t validate_odr(uint8_t odr)
/* This API validates the ODR value set by the user. param bandwidth : odr for accelerometer */ static uint16_t validate_odr(uint8_t odr)
{ uint16_t rslt = BMA4_OK; if ((odr < BMA4_OUTPUT_DATA_RATE_0_78HZ) || (odr > BMA4_OUTPUT_DATA_RATE_1600HZ)) { rslt = BMA4_E_OUT_OF_RANGE; } return rslt; }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* LCD Light up or shut off Battery Indicator. */
void LCD_Battery(LCD_TypeDef *lcd, int batteryLevel)
/* LCD Light up or shut off Battery Indicator. */ void LCD_Battery(LCD_TypeDef *lcd, int batteryLevel)
{ uint32_t com, bitvalue; int i, on; for (i = 0; i < 4; i++) { if (i < batteryLevel) { on = 1; } else { on = 0; } com = EFMDisplay.Battery.com[i]; bitvalue = 1 << EFMDisplay.Battery.bit[i]; if (on) { LCD_enableSegment(lcd, com, bitvalue); } else { LCD_disableSegment(lcd, com, bitvalue); } } }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* USB Device Set Address Function Parameters: adr: USB Device Address setup: Called in setup stage (!=0), else after status stage Return Value: None */
void USBD_SetAddress(uint32_t adr, uint32_t setup)
/* USB Device Set Address Function Parameters: adr: USB Device Address setup: Called in setup stage (!=0), else after status stage Return Value: None */ void USBD_SetAddress(uint32_t adr, uint32_t setup)
{ UDPHS->UDPHS_CTRL |= (UDPHS_CTRL_FADDR_EN | adr); } else { UDPHS->UDPHS_CTRL &= ~(UDPHS_CTRL_FADDR_EN | UDPHS_CTRL_DEV_ADDR_Msk); } }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* This function handles External line 0 interrupt request. */
void EXTI0_IRQHandler(void)
/* This function handles External line 0 interrupt request. */ void EXTI0_IRQHandler(void)
{ *(__IO uint32_t *) 0xA0003000 = 0xFF; }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Provide the caller with a dynamically allocated SAP number according to the rules that are set in this function. Returns: 0, upon failure, SAP number otherwise. */
static int llc_ui_autoport(void)
/* Provide the caller with a dynamically allocated SAP number according to the rules that are set in this function. Returns: 0, upon failure, SAP number otherwise. */ static int llc_ui_autoport(void)
{ struct llc_sap *sap; int i, tries = 0; while (tries < LLC_SAP_DYN_TRIES) { for (i = llc_ui_sap_last_autoport; i < LLC_SAP_DYN_STOP; i += 2) { sap = llc_sap_find(i); if (!sap) { llc_ui_sap_last_autoport = i + 2; goto out; } llc_sap_put(sap); } llc_ui_sap_last_autoport = LLC_SAP_DYN_START; tries++; } i = 0; out: return i; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Change IP address configuration for a network interface (including netmask and default gateway). */
void netif_set_addr(struct netif *netif, struct ip_addr *ipaddr, struct ip_addr *netmask, struct ip_addr *gw)
/* Change IP address configuration for a network interface (including netmask and default gateway). */ void netif_set_addr(struct netif *netif, struct ip_addr *ipaddr, struct ip_addr *netmask, struct ip_addr *gw)
{ netif_set_ipaddr(netif, ipaddr); netif_set_netmask(netif, netmask); netif_set_gw(netif, gw); }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Create and send a dynamic Web Page. This page contains the list of running tasks and the number of page hits. */
void DynWebPage(struct netconn *conn)
/* Create and send a dynamic Web Page. This page contains the list of running tasks and the number of page hits. */ void DynWebPage(struct netconn *conn)
{ portCHAR PAGE_BODY[512]; portCHAR pagehits[10] = {0}; memset(PAGE_BODY, 0,512); nPageHits++; sprintf(pagehits, "%d", (int)nPageHits); strcat(PAGE_BODY, pagehits); strcat((char *)PAGE_BODY, "<pre><br>Name State Priority Stack Num" ); strcat((char *)PAGE_BODY, "<br>---------------------------------------------<br>"); osThreadList((unsigned char *)(PAGE_BODY + strlen(PAGE_BODY))); strcat((char *)PAGE_BODY, "<br><br>---------------------------------------------"); strcat((char *)PAGE_BODY, "<br>B : Blocked, R : Ready, D : Deleted, S : Suspended<br>"); netconn_write(conn, PAGE_START, strlen((char*)PAGE_START), NETCONN_COPY); netconn_write(conn, PAGE_BODY, strlen(PAGE_BODY), NETCONN_COPY); }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* after adding space to the filesystem, we need to clear the full flags on all the space infos. */
void btrfs_clear_space_info_full(struct btrfs_fs_info *info)
/* after adding space to the filesystem, we need to clear the full flags on all the space infos. */ void btrfs_clear_space_info_full(struct btrfs_fs_info *info)
{ struct list_head *head = &info->space_info; struct btrfs_space_info *found; rcu_read_lock(); list_for_each_entry_rcu(found, head, list) found->full = 0; rcu_read_unlock(); }
robutest/uclinux
C++
GPL-2.0
60
/* Set the LPTIM registers update mode (enable/disable register preload) */
void LPTIM_SetUpdateMode(LPTIM_Module *LPTIMx, uint32_t UpdateMode)
/* Set the LPTIM registers update mode (enable/disable register preload) */ void LPTIM_SetUpdateMode(LPTIM_Module *LPTIMx, uint32_t UpdateMode)
{ MODIFY_REG(LPTIMx->CFG, LPTIM_CFG_RELOAD, UpdateMode); }
pikasTech/PikaPython
C++
MIT License
1,403
/* Show and store fail_over_mac. User only allowed to change the value when there are no slaves. */
static ssize_t bonding_show_fail_over_mac(struct device *d, struct device_attribute *attr, char *buf)
/* Show and store fail_over_mac. User only allowed to change the value when there are no slaves. */ static ssize_t bonding_show_fail_over_mac(struct device *d, struct device_attribute *attr, char *buf)
{ struct bonding *bond = to_bond(d); return sprintf(buf, "%s %d\n", fail_over_mac_tbl[bond->params.fail_over_mac].modename, bond->params.fail_over_mac); }
robutest/uclinux
C++
GPL-2.0
60
/* Prepare a request as required by RFC1350. This packet can be sent out directly to the TFTP server. */
static size_t make_request(uint8_t *buf, int request, const char *remote_file, const char *mode)
/* Prepare a request as required by RFC1350. This packet can be sent out directly to the TFTP server. */ static size_t make_request(uint8_t *buf, int request, const char *remote_file, const char *mode)
{ char *ptr = (char *)buf; const char def_mode[] = "octet"; sys_put_be16(request, ptr); ptr += 2; strncpy(ptr, remote_file, TFTP_MAX_FILENAME_SIZE); ptr += strlen(remote_file); *ptr++ = '\0'; if (mode == NULL) { mode = def_mode; } strncpy(ptr, mode, TFTP_MAX_MODE_SIZE); ptr += strlen(mode); *ptr++ = '\0'; return ptr - (char *)buf; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Block UDMA on devices that cause trouble with this controller. */
static unsigned long hpt370a_filter(struct ata_device *adev, unsigned long mask)
/* Block UDMA on devices that cause trouble with this controller. */ static unsigned long hpt370a_filter(struct ata_device *adev, unsigned long mask)
{ if (adev->class == ATA_DEV_ATA) { if (hpt_dma_blacklisted(adev, "UDMA100", bad_ata100_5)) mask &= ~(0xE0 << ATA_SHIFT_UDMA); } return ata_bmdma_mode_filter(adev, mask); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Note that for cases 2 and 3, we will match later when the io driver calls hvc_instantiate() and call register again. */
static int __init hvc_console_init(void)
/* Note that for cases 2 and 3, we will match later when the io driver calls hvc_instantiate() and call register again. */ static int __init hvc_console_init(void)
{ register_console(&hvc_con_driver); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Initialize the string table and the key cache */
void luaS_init(lua_State *L)
/* Initialize the string table and the key cache */ void luaS_init(lua_State *L)
{ KeyCache *p = g->cache[i]; for (j = 0;j < KEYCACHE_M; j++) p[j] = STRING_ENTRY(g->memerrmsg); } }
nodemcu/nodemcu-firmware
C++
MIT License
7,566
/* This Function calc the Answersize for a command. */
static int mdc800_getAnswerSize(char command)
/* This Function calc the Answersize for a command. */ static int mdc800_getAnswerSize(char command)
{ switch ((unsigned char) command) { case 0x2a: case 0x49: case 0x51: case 0x0d: case 0x20: case 0x07: case 0x01: case 0x25: case 0x00: return 8; case 0x05: case 0x3e: return mdc800->pic_len; case 0x09: return 4096; default: return 0; } }
robutest/uclinux
C++
GPL-2.0
60
/* Send and receive a sequence of bytes from an SPI device. */
status_code_t spi_transceive_packet(Spi *p_spi, uint8_t *tx_data, uint8_t *rx_data, size_t len)
/* Send and receive a sequence of bytes from an SPI device. */ status_code_t spi_transceive_packet(Spi *p_spi, uint8_t *tx_data, uint8_t *rx_data, size_t len)
{ uint32_t timeout = SPI_TIMEOUT; uint8_t val; uint32_t i = 0; while (len) { timeout = SPI_TIMEOUT; while (!spi_is_tx_ready(p_spi)) { if (!timeout--) { return ERR_TIMEOUT; } } spi_write_single(p_spi, tx_data[i]); timeout = SPI_TIMEOUT; while (!spi_is_rx_ready(p_spi)) { if (!timeout--) { return ERR_TIMEOUT; } } spi_read_single(p_spi, &val); rx_data[i] = val; i++; len--; } return STATUS_OK; }
memfault/zero-to-main
C++
null
200
/* While we find nice hex chars, build an int. Return number of chars processed. */
static int hexToInt(char **ptr, int *intValue)
/* While we find nice hex chars, build an int. Return number of chars processed. */ static int hexToInt(char **ptr, int *intValue)
{ int numChars = 0; int hexValue; *intValue = 0; longjmp_on_fault = 1; while (**ptr) { hexValue = hex(**ptr); if (hexValue < 0) break; *intValue = (*intValue << 4) | hexValue; numChars ++; (*ptr)++; } longjmp_on_fault = 0; return (numChars); }
EmcraftSystems/u-boot
C++
Other
181
/* If Alignment is not a power of two and Alignment is not zero, then ASSERT(). If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT(). */
VOID* EFIAPI AllocateAlignedPages(IN UINTN Pages, IN UINTN Alignment)
/* If Alignment is not a power of two and Alignment is not zero, then ASSERT(). If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT(). */ VOID* EFIAPI AllocateAlignedPages(IN UINTN Pages, IN UINTN Alignment)
{ VOID *Buffer; Buffer = InternalAllocateAlignedPages (EfiRuntimeServicesData, Pages, Alignment); if (Buffer != NULL) { MemoryProfileLibRecord ( (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0), MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ALIGNED_PAGES, EfiRuntimeServicesData, Buffer, EFI_PAGES_TO_SIZE (Pages), NULL ); } return Buffer; }
tianocore/edk2
C++
Other
4,240
/* Initialize CRC Interface. 1. Initializes the resources needed for the CRC interface 2.registers event callback function. */
crc_handle_t csi_crc_initialize(int32_t idx, crc_event_cb_t cb_event)
/* Initialize CRC Interface. 1. Initializes the resources needed for the CRC interface 2.registers event callback function. */ crc_handle_t csi_crc_initialize(int32_t idx, crc_event_cb_t cb_event)
{ if (idx < 0 || idx >= CONFIG_CRC_NUM) { return NULL; } uint32_t base = 0u; int32_t real_idx = target_get_crc(idx, &base); if (real_idx != idx) { return NULL; } ck_crc_priv_t *crc_priv = &crc_handle[idx]; crc_reg = (ck_crc_reg_t *)(crc_priv->base); crc_priv->base = base; crc_priv->cb = cb_event; crc_priv->status.busy = 0; return (crc_handle_t)crc_priv; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Unregisters an interrupt handler for the AES module. */
void AESIntUnregister(uint32_t ui32Base)
/* Unregisters an interrupt handler for the AES module. */ void AESIntUnregister(uint32_t ui32Base)
{ ASSERT(ui32Base == AES_BASE); IntDisable(INT_AES0_TM4C129); IntUnregister(INT_AES0_TM4C129); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Retrieve the Extended Key Usage from one X.509 certificate. */
BOOLEAN EFIAPI X509GetExtendedKeyUsage(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT UINT8 *Usage, IN OUT UINTN *UsageSize)
/* Retrieve the Extended Key Usage from one X.509 certificate. */ BOOLEAN EFIAPI X509GetExtendedKeyUsage(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT UINT8 *Usage, IN OUT UINTN *UsageSize)
{ CALL_CRYPTO_SERVICE (X509GetExtendedKeyUsage, (Cert, CertSize, Usage, UsageSize), FALSE); }
tianocore/edk2
C++
Other
4,240
/* callback any registered clients to let them know we have a change in VGA cards */
static void vga_arbiter_notify_clients(void)
/* callback any registered clients to let them know we have a change in VGA cards */ static void vga_arbiter_notify_clients(void)
{ struct vga_device *vgadev; unsigned long flags; uint32_t new_decodes; bool new_state; if (!vga_arbiter_used) return; spin_lock_irqsave(&vga_lock, flags); list_for_each_entry(vgadev, &vga_list, list) { if (vga_count > 1) new_state = false; else new_state = true; if (vgadev->set_vga_decode) { new_decodes = vgadev->set_vga_decode(vgadev->cookie, new_state); vga_update_device_decodes(vgadev, new_decodes); } } spin_unlock_irqrestore(&vga_lock, flags); }
robutest/uclinux
C++
GPL-2.0
60
/* Choose the power state appropriate for the device depending on whether it can wake up the system and/or is power manageable by the platform (PCI_D3hot is the default) and put the device into that state. */
int pci_prepare_to_sleep(struct pci_dev *dev)
/* Choose the power state appropriate for the device depending on whether it can wake up the system and/or is power manageable by the platform (PCI_D3hot is the default) and put the device into that state. */ int pci_prepare_to_sleep(struct pci_dev *dev)
{ pci_power_t target_state = pci_target_state(dev); int error; if (target_state == PCI_POWER_ERROR) return -EIO; pci_enable_wake(dev, target_state, device_may_wakeup(&dev->dev)); error = pci_set_power_state(dev, target_state); if (error) pci_enable_wake(dev, target_state, false); return error; }
robutest/uclinux
C++
GPL-2.0
60
/* These are weird, but module loading must not be done with mutex held (since they will register), and we have to have a single function to use try_then_request_module(). */
struct xt_match* xt_find_match(u8 af, const char *name, u8 revision)
/* These are weird, but module loading must not be done with mutex held (since they will register), and we have to have a single function to use try_then_request_module(). */ struct xt_match* xt_find_match(u8 af, const char *name, u8 revision)
{ struct xt_match *m; int err = 0; if (mutex_lock_interruptible(&xt[af].mutex) != 0) return ERR_PTR(-EINTR); list_for_each_entry(m, &xt[af].match, list) { if (strcmp(m->name, name) == 0) { if (m->revision == revision) { if (try_module_get(m->me)) { mutex_unlock(&xt[af].mutex); return m; } } else err = -EPROTOTYPE; } } mutex_unlock(&xt[af].mutex); if (af != NFPROTO_UNSPEC) return xt_find_match(NFPROTO_UNSPEC, name, revision); return ERR_PTR(err); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Draws a string using the supplied font data. */
void ssd1306DrawString(uint16_t x, uint16_t y, char *text, struct FONT_DEF font)
/* Draws a string using the supplied font data. */ void ssd1306DrawString(uint16_t x, uint16_t y, char *text, struct FONT_DEF font)
{ uint8_t l; for (l = 0; l < strlen(text); l++) { ssd1306DrawChar(x + (l * (font.u8Width + 1)), y, text[l], font); } }
microbuilder/LPC1343CodeBase
C++
Other
73
/* Returns 1 when there's a match, 0 means no match. */
static int _scsih_srch_boot_sas_address(u64 sas_address, Mpi2BootDeviceSasWwid_t *boot_device)
/* Returns 1 when there's a match, 0 means no match. */ static int _scsih_srch_boot_sas_address(u64 sas_address, Mpi2BootDeviceSasWwid_t *boot_device)
{ return (sas_address == le64_to_cpu(boot_device->SASAddress)) ? 1 : 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Take the original command line, substitute any variables, free the original string, return the modified copy. */
EFI_STATUS ShellSubstituteVariables(IN CHAR16 **CmdLine)
/* Take the original command line, substitute any variables, free the original string, return the modified copy. */ EFI_STATUS ShellSubstituteVariables(IN CHAR16 **CmdLine)
{ CHAR16 *NewCmdLine; NewCmdLine = ShellConvertVariables (*CmdLine); SHELL_FREE_NON_NULL (*CmdLine); if (NewCmdLine == NULL) { return (EFI_OUT_OF_RESOURCES); } *CmdLine = NewCmdLine; return (EFI_SUCCESS); }
tianocore/edk2
C++
Other
4,240
/* Check if data has been loaded in SSC_THR and is waiting to be loaded in the Transmit Shift Register (TSR). */
uint32_t ssc_is_tx_ready(Ssc *p_ssc)
/* Check if data has been loaded in SSC_THR and is waiting to be loaded in the Transmit Shift Register (TSR). */ uint32_t ssc_is_tx_ready(Ssc *p_ssc)
{ if (p_ssc->SSC_SR & SSC_SR_TXRDY) { return SSC_RC_YES; } return SSC_RC_NO; }
remotemcu/remcu-chip-sdks
C++
null
436
/* bearer_find - locates bearer object with matching bearer name */
static struct bearer* bearer_find(const char *name)
/* bearer_find - locates bearer object with matching bearer name */ static struct bearer* bearer_find(const char *name)
{ struct bearer *b_ptr; u32 i; if (tipc_mode != TIPC_NET_MODE) return NULL; for (i = 0, b_ptr = tipc_bearers; i < MAX_BEARERS; i++, b_ptr++) { if (b_ptr->active && (!strcmp(b_ptr->publ.name, name))) return b_ptr; } return NULL; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Allocates the number of 4KB pages of a certain memory type and returns a pointer to the allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL is returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. */
VOID* InternalAllocatePages(IN EFI_MEMORY_TYPE MemoryType, IN UINTN Pages)
/* Allocates the number of 4KB pages of a certain memory type and returns a pointer to the allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL is returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. */ VOID* InternalAllocatePages(IN EFI_MEMORY_TYPE MemoryType, IN UINTN Pages)
{ EFI_STATUS Status; EFI_PHYSICAL_ADDRESS Memory; if (Pages == 0) { return NULL; } Status = PeiServicesAllocatePages (MemoryType, Pages, &Memory); if (EFI_ERROR (Status)) { return NULL; } return (VOID *)(UINTN)Memory; }
tianocore/edk2
C++
Other
4,240
/* Get the combination of flag bits exported through APIs to userspace. */
unsigned dev_get_flags(const struct net_device *dev)
/* Get the combination of flag bits exported through APIs to userspace. */ unsigned dev_get_flags(const struct net_device *dev)
{ unsigned flags; flags = (dev->flags & ~(IFF_PROMISC | IFF_ALLMULTI | IFF_RUNNING | IFF_LOWER_UP | IFF_DORMANT)) | (dev->gflags & (IFF_PROMISC | IFF_ALLMULTI)); if (netif_running(dev)) { if (netif_oper_up(dev)) flags |= IFF_RUNNING; if (netif_carrier_ok(dev)) flags |= IFF_LOWER_UP; if (netif_dormant(dev)) flags |= IFF_DORMANT; } return flags; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Upload code to the shared RAM of an IOP. */
void iop_upload_code(uint iop_num, __u8 *code_start, uint code_len, __u16 shared_ram_start)
/* Upload code to the shared RAM of an IOP. */ void iop_upload_code(uint iop_num, __u8 *code_start, uint code_len, __u16 shared_ram_start)
{ if ((iop_num >= NUM_IOPS) || !iop_base[iop_num]) return; iop_loadaddr(iop_base[iop_num], shared_ram_start); while (code_len--) { iop_base[iop_num]->ram_data = *code_start++; } }
EmcraftSystems/linux-emcraft
C++
Other
266
/* If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 32-bit boundary, then ASSERT(). If Length is not aligned on a 32-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). */
VOID* EFIAPI ScanMem32(IN CONST VOID *Buffer, IN UINTN Length, IN UINT32 Value)
/* If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 32-bit boundary, then ASSERT(). If Length is not aligned on a 32-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). */ VOID* EFIAPI ScanMem32(IN CONST VOID *Buffer, IN UINTN Length, IN UINT32 Value)
{ if (Length == 0) { return NULL; } ASSERT (Buffer != NULL); ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0); ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); ASSERT ((Length & (sizeof (Value) - 1)) == 0); return (VOID *)InternalMemScanMem32 (Buffer, Length / sizeof (Value), Value); }
tianocore/edk2
C++
Other
4,240
/* Write a value to a PHY's MII register. */
int mii_write(int ch, int phy_addr, int reg_addr, int data)
/* Write a value to a PHY's MII register. */ int mii_write(int ch, int phy_addr, int reg_addr, int data)
{ int timeout; ENET_EIR = ENET_EIR_MII_MASK; ENET_MMFR = 0 | ENET_MMFR_ST(0x01) | ENET_MMFR_OP(0x01) | ENET_MMFR_PA(phy_addr) | ENET_MMFR_RA(reg_addr) | ENET_MMFR_TA(0x02) | ENET_MMFR_DATA(data); for (timeout = 0; timeout < MII_TIMEOUT; timeout++) { if (ENET_EIR & ENET_EIR_MII_MASK) break; } if(timeout == MII_TIMEOUT) return 1; ENET_EIR = ENET_EIR_MII_MASK; return 0; }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* This function returns the window command of the specified icon button, as set when the widget was created. */
win_command_t wtk_icon_button_get_command(struct wtk_icon_button *icon_button)
/* This function returns the window command of the specified icon button, as set when the widget was created. */ win_command_t wtk_icon_button_get_command(struct wtk_icon_button *icon_button)
{ Assert(icon_button); return icon_button->command; }
memfault/zero-to-main
C++
null
200
/* Calculates a 16-bit CRC value over the specified data using byte wise computation with a table. */
uint16_t UtilChecksumCrc16Calculate(uint8_t const *data, uint32_t len)
/* Calculates a 16-bit CRC value over the specified data using byte wise computation with a table. */ uint16_t UtilChecksumCrc16Calculate(uint8_t const *data, uint32_t len)
{ uint16_t result = 0; uint32_t byteIdx; assert(data != NULL); assert(len > 0); if ( (data != NULL) && (len > 0) ) { for (byteIdx = 0; byteIdx < len; byteIdx++) { result = ((uint16_t)(result << 8)) ^ utilChecksumCrc16Table[(uint8_t)(data[byteIdx] ^ (result >> 8))]; } } return result; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* returns the capability of a port Note that this function is documented in the main component public header file, IxEthDB.h. */
IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBFeatureCapabilityGet(IxEthDBPortId portID, IxEthDBFeature *featureSet)
/* returns the capability of a port Note that this function is documented in the main component public header file, IxEthDB.h. */ IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBFeatureCapabilityGet(IxEthDBPortId portID, IxEthDBFeature *featureSet)
{ IX_ETH_DB_CHECK_PORT_INITIALIZED(portID); IX_ETH_DB_CHECK_REFERENCE(featureSet); *featureSet = ixEthDBPortInfo[portID].featureCapability; return IX_ETH_DB_SUCCESS; }
EmcraftSystems/u-boot
C++
Other
181
/* Enables or disables the specified SPI peripheral (in I2S mode). */
void I2S_Cmd(SPI_TypeDef *SPIx, FunctionalState NewState)
/* Enables or disables the specified SPI peripheral (in I2S mode). */ void I2S_Cmd(SPI_TypeDef *SPIx, FunctionalState NewState)
{ assert_param(IS_SPI_23_PERIPH_EXT(SPIx)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { SPIx->I2SCFGR |= SPI_I2SCFGR_I2SE; } else { SPIx->I2SCFGR &= (uint16_t)~((uint16_t)SPI_I2SCFGR_I2SE); } }
ajhc/demo-cortex-m3
C++
null
38
/* Exception level EL3 is meant to be used by the secure monitor only (ARM trusted firmware being one embodiment). The operating system shall be started at exception level EL2. So here we check the exception level and switch it if necessary. */
void switch_to_non_secure_mode(void)
/* Exception level EL3 is meant to be used by the secure monitor only (ARM trusted firmware being one embodiment). The operating system shall be started at exception level EL2. So here we check the exception level and switch it if necessary. */ void switch_to_non_secure_mode(void)
{ struct jmp_buf_data non_secure_jmp; if (current_el() == 3) { if (setjmp(&non_secure_jmp)) return; dcache_disable(); armv8_switch_to_el2((uintptr_t)&non_secure_jmp, 0, 0, 0, (uintptr_t)entry_non_secure, ES_TO_AARCH64); } }
4ms/stm32mp1-baremetal
C++
Other
137
/* Contracts a floating point image to 32bpp and then stores it using a regular 32-bit store proc. Despite the type, this function expects an argb_t buffer. */
static void store_scanline_generic_float(bits_image_t *image, int x, int y, int width, const uint32_t *values)
/* Contracts a floating point image to 32bpp and then stores it using a regular 32-bit store proc. Despite the type, this function expects an argb_t buffer. */ static void store_scanline_generic_float(bits_image_t *image, int x, int y, int width, const uint32_t *values)
{ uint32_t *argb8_pixels; assert (image->common.type == BITS); argb8_pixels = pixman_malloc_ab (width, sizeof(uint32_t)); if (!argb8_pixels) return; pixman_contract_from_float (argb8_pixels, (argb_t *)values, width); image->store_scanline_32 (image, x, y, width, argb8_pixels); free (argb8_pixels); }
xboot/xboot
C++
MIT License
779
/* These routines don't guarantee any alignment. The caller must include any space needed for alignment in the sizes of the structures that are passed in. */
static bool init_dma_loaf(struct pci_dev *dev, struct dma_loaf *loaf, size_t len)
/* These routines don't guarantee any alignment. The caller must include any space needed for alignment in the sizes of the structures that are passed in. */ static bool init_dma_loaf(struct pci_dev *dev, struct dma_loaf *loaf, size_t len)
{ void *cpu_addr; dma_addr_t dma_handle; cpu_addr = pci_alloc_consistent(dev, len, &dma_handle); if (cpu_addr == NULL) return false; loaf->cpu_free = loaf->cpu_base = cpu_addr; loaf->dma_free =loaf->dma_base = dma_handle; loaf->length = len; memset(cpu_addr, 0, len); return true; }
robutest/uclinux
C++
GPL-2.0
60
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). */
UINT16 EFIAPI PciExpressRead16(IN UINTN Address)
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). */ UINT16 EFIAPI PciExpressRead16(IN UINTN Address)
{ ASSERT_INVALID_PCI_ADDRESS (Address); return MmioRead16 ((UINTN)GetPciExpressBaseAddress () + Address); }
tianocore/edk2
C++
Other
4,240
/* The node is not changed if it (or its first child) is not a text node. */
int mxmlSetText(mxml_node_t *node, int whitespace, const char *string)
/* The node is not changed if it (or its first child) is not a text node. */ int mxmlSetText(mxml_node_t *node, int whitespace, const char *string)
{ if (node && node->type == MXML_ELEMENT && node->child && node->child->type == MXML_TEXT) node = node->child; if (!node || node->type != MXML_TEXT || !string) return (-1); if (node->value.text.string) free(node->value.text.string); node->value.text.whitespace = whitespace; node->value.text.string = strdup(string); return (0); }
DC-SWAT/DreamShell
C++
null
404
/* TIM MSP Initialization This function configures the hardware resources used in this example: */
void HAL_TIM_OC_MspInit(TIM_HandleTypeDef *htim)
/* TIM MSP Initialization This function configures the hardware resources used in this example: */ void HAL_TIM_OC_MspInit(TIM_HandleTypeDef *htim)
{ GPIO_InitTypeDef GPIO_InitStruct; TIMx_CLK_ENABLE(); TIMx_CHANNEL_GPIO_PORT(); GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF1_TIM2; GPIO_InitStruct.Pin = GPIO_PIN_CHANNEL1; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); GPIO_InitStruct.Pin = GPIO_PIN_CHANNEL2; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); GPIO_InitStruct.Pin = GPIO_PIN_CHANNEL3; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); GPIO_InitStruct.Pin = GPIO_PIN_CHANNEL4; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); HAL_NVIC_SetPriority(TIM2_IRQn, 0, 1); HAL_NVIC_EnableIRQ(TIM2_IRQn); }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* timer_interrupt - gets called when the decrementer overflows, with interrupts disabled. Trivial implementation - no need to be really accurate. */
void timer_interrupt(struct pt_regs *regs)
/* timer_interrupt - gets called when the decrementer overflows, with interrupts disabled. Trivial implementation - no need to be really accurate. */ void timer_interrupt(struct pt_regs *regs)
{ set_dec(decrementer_count); timestamp++; }
EmcraftSystems/u-boot
C++
Other
181
/* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
static uint32_t color_to_uint32(const pixman_color_t *color)
/* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ static uint32_t color_to_uint32(const pixman_color_t *color)
{ return ((unsigned int) color->alpha >> 8 << 24) | ((unsigned int) color->red >> 8 << 16) | ((unsigned int) color->green & 0xff00) | ((unsigned int) color->blue >> 8); }
xboot/xboot
C++
MIT License
779
/* Check if it's a valid FFS file header. */
BOOLEAN IsValidFfsHeader(IN UINT8 ErasePolarity, IN EFI_FFS_FILE_HEADER *FfsHeader, OUT EFI_FFS_FILE_STATE *FileState)
/* Check if it's a valid FFS file header. */ BOOLEAN IsValidFfsHeader(IN UINT8 ErasePolarity, IN EFI_FFS_FILE_HEADER *FfsHeader, OUT EFI_FFS_FILE_STATE *FileState)
{ *FileState = GetFileState (ErasePolarity, FfsHeader); switch (*FileState) { case EFI_FILE_HEADER_VALID: case EFI_FILE_DATA_VALID: case EFI_FILE_MARKED_FOR_UPDATE: case EFI_FILE_DELETED: return VerifyHeaderChecksum (FfsHeader); case EFI_FILE_HEADER_CONSTRUCTION: case EFI_FILE_HEADER_INVALID: default: return FALSE; } }
tianocore/edk2
C++
Other
4,240
/* igbvf_clean_tx_ring - Free Tx Buffers @tx_ring: ring to be cleaned */
static void igbvf_clean_tx_ring(struct igbvf_ring *tx_ring)
/* igbvf_clean_tx_ring - Free Tx Buffers @tx_ring: ring to be cleaned */ static void igbvf_clean_tx_ring(struct igbvf_ring *tx_ring)
{ struct igbvf_adapter *adapter = tx_ring->adapter; struct igbvf_buffer *buffer_info; unsigned long size; unsigned int i; if (!tx_ring->buffer_info) return; for (i = 0; i < tx_ring->count; i++) { buffer_info = &tx_ring->buffer_info[i]; igbvf_put_txbuf(adapter, buffer_info); } size = sizeof(struct igbvf_buffer) * tx_ring->count; memset(tx_ring->buffer_info, 0, size); memset(tx_ring->desc, 0, tx_ring->size); tx_ring->next_to_use = 0; tx_ring->next_to_clean = 0; writel(0, adapter->hw.hw_addr + tx_ring->head); writel(0, adapter->hw.hw_addr + tx_ring->tail); }
robutest/uclinux
C++
GPL-2.0
60
/* Registers a function to be called when an interrupt occurs. */
void IntRegister(uint32_t ui32Interrupt, void(*pfnHandler)(void))
/* Registers a function to be called when an interrupt occurs. */ void IntRegister(uint32_t ui32Interrupt, void(*pfnHandler)(void))
{ uint32_t ui32Idx, ui32Value; ASSERT(ui32Interrupt < NUM_INTERRUPTS); ASSERT(((uint32_t)g_pfnRAMVectors & 0x000003ff) == 0); if(HWREG(NVIC_VTABLE) != (uint32_t)g_pfnRAMVectors) { ui32Value = HWREG(NVIC_VTABLE); for(ui32Idx = 0; ui32Idx < NUM_INTERRUPTS; ui32Idx++) { g_pfnRAMVectors[ui32Idx] = (void (*)(void))HWREG((ui32Idx * 4) + ui32Value); } HWREG(NVIC_VTABLE) = (uint32_t)g_pfnRAMVectors; } g_pfnRAMVectors[ui32Interrupt] = pfnHandler; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Description: Configures MII_BMCR to force speed/duplex to the values in phydev. Assumes that the values are valid. */
static int genphy_setup_forced(struct phy_device *phydev)
/* Description: Configures MII_BMCR to force speed/duplex to the values in phydev. Assumes that the values are valid. */ static int genphy_setup_forced(struct phy_device *phydev)
{ int err; int ctl = 0; phydev->pause = phydev->asym_pause = 0; if (SPEED_1000 == phydev->speed) ctl |= BMCR_SPEED1000; else if (SPEED_100 == phydev->speed) ctl |= BMCR_SPEED100; if (DUPLEX_FULL == phydev->duplex) ctl |= BMCR_FULLDPLX; err = phy_write(phydev, MDIO_DEVAD_NONE, MII_BMCR, ctl); return err; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This is only split from the main interrupt handler so as to reduce the amount of code if the ring buffer is not enabled. */
void sca3000_ring_int_process(u8 val, struct iio_ring_buffer *ring)
/* This is only split from the main interrupt handler so as to reduce the amount of code if the ring buffer is not enabled. */ void sca3000_ring_int_process(u8 val, struct iio_ring_buffer *ring)
{ if (val & SCA3000_INT_STATUS_THREE_QUARTERS) iio_push_or_escallate_ring_event(ring, IIO_EVENT_CODE_RING_75_FULL, 0); else if (val & SCA3000_INT_STATUS_HALF) iio_push_ring_event(ring, IIO_EVENT_CODE_RING_50_FULL, 0); }
robutest/uclinux
C++
GPL-2.0
60
/* Change Logs: Date Author Notes Meco Man first version */
void __rt_libc_exit(int status)
/* Change Logs: Date Author Notes Meco Man first version */ void __rt_libc_exit(int status)
{ rt_thread_t self = rt_thread_self(); if (self != RT_NULL) { rt_kprintf("thread:%s exit:%d!\n", self->name, status); rt_thread_control(self, RT_THREAD_CTRL_CLOSE, RT_NULL); } }
pikasTech/PikaPython
C++
MIT License
1,403
/* Returns the timespec representation of the nsec parameter. */
struct timespec ns_to_timespec(const s64 nsec)
/* Returns the timespec representation of the nsec parameter. */ struct timespec ns_to_timespec(const s64 nsec)
{ struct timespec ts; s32 rem; if (!nsec) return (struct timespec) {0, 0}; ts.tv_sec = div_s64_rem(nsec, NSEC_PER_SEC, &rem); if (unlikely(rem < 0)) { ts.tv_sec--; rem += NSEC_PER_SEC; } ts.tv_nsec = rem; return ts; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Check whether the required access is compatible with an inode's permission. SMB doesn't recognize superuser privileges, so we need our own check for this. */
static int smb_file_permission(struct inode *inode, int mask)
/* Check whether the required access is compatible with an inode's permission. SMB doesn't recognize superuser privileges, so we need our own check for this. */ static int smb_file_permission(struct inode *inode, int mask)
{ int mode = inode->i_mode; int error = 0; VERBOSE("mode=%x, mask=%x\n", mode, mask); mode >>= 6; if (mask & ~mode & (MAY_READ | MAY_WRITE | MAY_EXEC)) error = -EACCES; return error; }
robutest/uclinux
C++
GPL-2.0
60
/* Disable any IRQs and clear the run/stop bit. HC will complete any current and actively pipelined transactions, and should halt within 16 microframes of the run/stop bit being cleared. Read HC Halted bit in the status register to see when the HC is finished. XXX: shouldn't we set HC_STATE_HALT here somewhere? */
int xhci_halt(struct xhci_hcd *xhci)
/* Disable any IRQs and clear the run/stop bit. HC will complete any current and actively pipelined transactions, and should halt within 16 microframes of the run/stop bit being cleared. Read HC Halted bit in the status register to see when the HC is finished. XXX: shouldn't we set HC_STATE_HALT here somewhere? */ int xhci_halt(struct xhci_hcd *xhci)
{ xhci_dbg(xhci, " xhci_quiesce(xhci); return handshake(xhci, &xhci->op_regs->status, STS_HALT, STS_HALT, XHCI_MAX_HALT_USEC); }
robutest/uclinux
C++
GPL-2.0
60
/* Enable USB Device Endpoint Parameters: EPNum: Device Endpoint Number EPNum.0..3: Address EPNum.7: Dir Return Value: None */
void USBD_EnableEP(U32 EPNum)
/* Enable USB Device Endpoint Parameters: EPNum: Device Endpoint Number EPNum.0..3: Address EPNum.7: Dir Return Value: None */ void USBD_EnableEP(U32 EPNum)
{ ep_buffer_t *desc = get_desc(EPNum); EPNum &= EPNUM_MASK; MXC_USB->ep[EPNum] |= (MXC_F_USB_EP_INT_EN | ep_info[EPNum].type | MXC_F_USB_EP_DT); if (ep_info[EPNum].type == MXC_S_USB_EP_DIR_OUT) { desc = get_desc(EPNum); desc->buf0_address = (uint32_t)ep_buffer[EPNum]; desc->buf0_desc = sizeof(ep_buffer[EPNum]); MXC_USB->out_owner = (1 << EPNum); } }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140