docstring
stringlengths
22
576
signature
stringlengths
9
317
prompt
stringlengths
57
886
code
stringlengths
20
1.36k
repository
stringclasses
49 values
language
stringclasses
2 values
license
stringclasses
9 values
stars
int64
15
21.3k
/* This function performs periodic timer processing in the ARP module and should be called at regular intervals. The recommended interval is 10 seconds between the calls. */
void uip_arp_timer(void)
/* This function performs periodic timer processing in the ARP module and should be called at regular intervals. The recommended interval is 10 seconds between the calls. */ void uip_arp_timer(void)
{ struct arp_entry *tabptr; ++arptime; for( i = 0; i < UIP_ARPTAB_SIZE; ++i ) { tabptr = &arp_table[i]; if( uip_ipaddr_cmp(&tabptr->ipaddr, &uip_all_zeroes_addr) && arptime - tabptr->time >= UIP_ARP_MAXAGE ) { memset( &tabptr->ipaddr, 0, 4 ); } } }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* free_iova - finds and frees the iova for a given pfn @iovad: - iova domain in question. @pfn: - pfn that is allocated previously This functions finds an iova for a given pfn and then frees the iova from that domain. */
void free_iova(struct iova_domain *iovad, unsigned long pfn)
/* free_iova - finds and frees the iova for a given pfn @iovad: - iova domain in question. @pfn: - pfn that is allocated previously This functions finds an iova for a given pfn and then frees the iova from that domain. */ void free_iova(struct iova_domain *iovad, unsigned long pfn)
{ struct iova *iova = find_iova(iovad, pfn); if (iova) __free_iova(iovad, iova); }
robutest/uclinux
C++
GPL-2.0
60
/* sweep a list until a live object (or end of list) */
static GCObject** sweeptolive(lua_State *L, GCObject **p, int *n)
/* sweep a list until a live object (or end of list) */ static GCObject** sweeptolive(lua_State *L, GCObject **p, int *n)
{ i++; p = sweeplist(L, p, 1); } while (p == old); if (n) *n += i; return p; }
opentx/opentx
C++
GNU General Public License v2.0
2,025
/* ehca2ib_qp_state maps ehca to IB qp_state returns ib qp state corresponding to given ehca qp state */
static enum ib_qp_state ehca2ib_qp_state(enum ehca_qp_state ehca_qp_state)
/* ehca2ib_qp_state maps ehca to IB qp_state returns ib qp state corresponding to given ehca qp state */ static enum ib_qp_state ehca2ib_qp_state(enum ehca_qp_state ehca_qp_state)
{ switch (ehca_qp_state) { case EHCA_QPS_RESET: return IB_QPS_RESET; case EHCA_QPS_INIT: return IB_QPS_INIT; case EHCA_QPS_RTR: return IB_QPS_RTR; case EHCA_QPS_RTS: return IB_QPS_RTS; case EHCA_QPS_SQD: return IB_QPS_SQD; case EHCA_QPS_SQE: return IB_QPS_SQE; case EHCA_QPS_ERR: return IB_QPS_ERR; default: ehca_gen_err("invalid ehca_qp_state=%x", ehca_qp_state); return -EINVAL; } }
robutest/uclinux
C++
GPL-2.0
60
/* Configurate The WatchDog Timer(WDT)'s Timer Interval. This function is to configureThe WatchDog Timer(WDT)'s Timer Interval. There are three factors to determine the Timer Interval, they are: */
void xWDTInit(unsigned long ulBase, unsigned long ulConfig, unsigned long ulReload)
/* Configurate The WatchDog Timer(WDT)'s Timer Interval. This function is to configureThe WatchDog Timer(WDT)'s Timer Interval. There are three factors to determine the Timer Interval, they are: */ void xWDTInit(unsigned long ulBase, unsigned long ulConfig, unsigned long ulReload)
{ (void) ulBase; _PreValue = ulReload; WDTCfg(ulConfig, ulReload); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Toggles the LED at a fixed time interval. */
void LedToggle(void)
/* Toggles the LED at a fixed time interval. */ void LedToggle(void)
{ static unsigned char led_toggle_state = 0; static unsigned long timer_counter_last = 0; unsigned long timer_counter_now; timer_counter_now = TimerGet(); if ( (timer_counter_now - timer_counter_last) < LED_TOGGLE_MS) { return; } if (led_toggle_state == 0) { led_toggle_state = 1; HAL_GPIO_WritePin(GPIOF, GPIO_PIN_8, GPIO_PIN_SET); } else { led_toggle_state = 0; HAL_GPIO_WritePin(GPIOF, GPIO_PIN_8, GPIO_PIN_RESET); } timer_counter_last = timer_counter_now; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Local function to handle the USB-CDC class requests */
static BOOL HandleClassRequest(TSetupPacket *setupPacket, int *answerLength, unsigned char **answer)
/* Local function to handle the USB-CDC class requests */ static BOOL HandleClassRequest(TSetupPacket *setupPacket, int *answerLength, unsigned char **answer)
{ case SET_LINE_CODING: memcpy((unsigned char *)&lineCoding, *answer, 7); *answerLength = 7; break; case GET_LINE_CODING: *answer = (unsigned char *)&lineCoding; *answerLength = 7; break; case SET_CONTROL_LINE_STATE: break; default: return FALSE; } return TRUE; }
ajhc/demo-cortex-m3
C++
null
38
/* Get a Message from a Queue or timeout if Queue is empty. */
__STATIC_INLINE osStatus_t isrRtxMessageQueueGet(osMessageQueueId_t mq_id, void *msg_ptr, uint8_t *msg_prio, uint32_t timeout)
/* Get a Message from a Queue or timeout if Queue is empty. */ __STATIC_INLINE osStatus_t isrRtxMessageQueueGet(osMessageQueueId_t mq_id, void *msg_ptr, uint8_t *msg_prio, uint32_t timeout)
{ EvrRtxMessageQueueError(mq, (int32_t)osErrorParameter); return osErrorParameter; } msg = MessageQueueGet(mq); if (msg != NULL) { memcpy(msg_ptr, &msg[1], mq->msg_size); if (msg_prio != NULL) { *msg_prio = msg->priority; } *((os_message_queue_t **)(void *)&msg[1]) = mq; osRtxPostProcess(osRtxObject(msg)); EvrRtxMessageQueueRetrieved(mq, msg_ptr); status = osOK; } else { EvrRtxMessageQueueNotRetrieved(mq, msg_ptr); status = osErrorResource; } return status; }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* Perform init required for both SD and SDIO cards. This function performs the following portions of SD initialization */
static int sd_common_init(struct sd_card *card)
/* Perform init required for both SD and SDIO cards. This function performs the following portions of SD initialization */ static int sd_common_init(struct sd_card *card)
{ int ret; ret = sd_idle(card); if (ret) { LOG_ERR("Card error on CMD0"); return ret; } ret = sd_retry(sd_send_interface_condition, card, CONFIG_SD_RETRY_COUNT); if (ret == -ETIMEDOUT) { LOG_INF("Card does not support CMD8, assuming legacy card"); return sd_idle(card); } else if (ret) { LOG_ERR("Card error on CMD 8"); return ret; } if (card->host_props.is_spi && IS_ENABLED(CONFIG_SDHC_SUPPORTS_SPI_MODE)) { ret = sd_enable_crc(card); } return ret; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Atomically xchgs the value of @ptr to @new_val and returns the old value. */
u64 atomic64_xchg(atomic64_t *ptr, u64 new_val)
/* Atomically xchgs the value of @ptr to @new_val and returns the old value. */ u64 atomic64_xchg(atomic64_t *ptr, u64 new_val)
{ u64 old_val, real_val = 0; do { old_val = real_val; real_val = atomic64_cmpxchg(ptr, old_val, new_val); } while (real_val != old_val); return old_val; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* We support strings in multiple languages ... string descriptor zero says which languages are supported. The typical case will be that only one language (probably English) is used, with I18N handled on the host side. */
static void collect_langs(struct usb_gadget_strings **sp, void *buf)
/* We support strings in multiple languages ... string descriptor zero says which languages are supported. The typical case will be that only one language (probably English) is used, with I18N handled on the host side. */ static void collect_langs(struct usb_gadget_strings **sp, void *buf)
{ const struct usb_gadget_strings *s; u16 language; __le16_packed *tmp; __le16_packed *end = (buf + 252); while (*sp) { s = *sp; language = cpu_to_le16(s->language); for (tmp = buf; tmp->val && tmp < end; tmp++) { if (tmp->val == language) goto repeat; } tmp->val = language; repeat: sp++; } }
4ms/stm32mp1-baremetal
C++
Other
137
/* Filter the received packet using the source port. */
BOOLEAN PxeBcFilterBySrcPort(IN EFI_PXE_BASE_CODE_MODE *Mode, IN VOID *Session, IN OUT UINT16 *SrcPort, IN UINT16 OpFlags)
/* Filter the received packet using the source port. */ BOOLEAN PxeBcFilterBySrcPort(IN EFI_PXE_BASE_CODE_MODE *Mode, IN VOID *Session, IN OUT UINT16 *SrcPort, IN UINT16 OpFlags)
{ UINT16 Port; if (Mode->UsingIpv6) { Port = ((EFI_UDP6_SESSION_DATA *)Session)->SourcePort; } else { Port = ((EFI_UDP4_SESSION_DATA *)Session)->SourcePort; } if ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_PORT) != 0) { if (SrcPort != NULL) { *SrcPort = Port; } return TRUE; } else if ((SrcPort != NULL) && (*SrcPort == Port)) { return TRUE; } return FALSE; }
tianocore/edk2
C++
Other
4,240
/* brief Aborts the slave non-blocking transfers. note This API could be called at any time to stop slave for handling the bus events. param base The I3C peripheral base address. param handle Pointer to #i3c_slave_handle_t structure which stores the transfer state. retval #kStatus_Success retval #kStatus_I3C_Idle */
void I3C_SlaveTransferAbort(I3C_Type *base, i3c_slave_handle_t *handle)
/* brief Aborts the slave non-blocking transfers. note This API could be called at any time to stop slave for handling the bus events. param base The I3C peripheral base address. param handle Pointer to #i3c_slave_handle_t structure which stores the transfer state. retval #kStatus_Success retval #kStatus_I3C_Idle */ void I3C_SlaveTransferAbort(I3C_Type *base, i3c_slave_handle_t *handle)
{ assert(NULL != handle); if (handle->isBusy) { I3C_SlaveDisableInterrupts(base, (uint32_t)kSlaveIrqFlags); (void)memset(&handle->transfer, 0, sizeof(handle->transfer)); handle->isBusy = false; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* In this implementation, "virq" == "IRQ plug number", "(irq_hw_number_t)hwirq" == "IRQ outlet number". */
static void beatic_update_irq_mask(unsigned int irq_plug)
/* In this implementation, "virq" == "IRQ plug number", "(irq_hw_number_t)hwirq" == "IRQ outlet number". */ static void beatic_update_irq_mask(unsigned int irq_plug)
{ int off; unsigned long masks[4]; off = (irq_plug / 256) * 4; masks[0] = beatic_irq_mask_enable[off + 0] & beatic_irq_mask_ack[off + 0]; masks[1] = beatic_irq_mask_enable[off + 1] & beatic_irq_mask_ack[off + 1]; masks[2] = beatic_irq_mask_enable[off + 2] & beatic_irq_mask_ack[off + 2]; masks[3] = beatic_irq_mask_enable[off + 3] & beatic_irq_mask_ack[off + 3]; if (beat_set_interrupt_mask(irq_plug&~255UL, masks[0], masks[1], masks[2], masks[3]) != 0) panic("Failed to set mask IRQ!"); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Function to compare 2 EFI_SMRAM_DESCRIPTOR based on CpuStart. */
INTN EFIAPI CpuSmramRangeCompare(IN CONST VOID *Buffer1, IN CONST VOID *Buffer2)
/* Function to compare 2 EFI_SMRAM_DESCRIPTOR based on CpuStart. */ INTN EFIAPI CpuSmramRangeCompare(IN CONST VOID *Buffer1, IN CONST VOID *Buffer2)
{ if (((EFI_SMRAM_DESCRIPTOR *)Buffer1)->CpuStart > ((EFI_SMRAM_DESCRIPTOR *)Buffer2)->CpuStart) { return 1; } else if (((EFI_SMRAM_DESCRIPTOR *)Buffer1)->CpuStart < ((EFI_SMRAM_DESCRIPTOR *)Buffer2)->CpuStart) { return -1; } return 0; }
tianocore/edk2
C++
Other
4,240
/* Add addresses and corresponding TLVs to current message Called by oonf_api during message creation */
static void _nhdp_add_addresses_cb(struct rfc5444_writer *wr)
/* Add addresses and corresponding TLVs to current message Called by oonf_api during message creation */ static void _nhdp_add_addresses_cb(struct rfc5444_writer *wr)
{ lib_fill_wr_addresses(nhdp_wr_curr_if_entry->if_pid, wr); iib_fill_wr_addresses(nhdp_wr_curr_if_entry->if_pid, wr); nib_fill_wr_addresses(wr); nhdp_reset_addresses_tmp_usg(0); }
labapart/polymcu
C++
null
201
/* This waits for either a completion of a specific task to be signaled or for a specified timeout to expire. The timeout is in jiffies. It is not interruptible. */
unsigned long __sched wait_for_completion_timeout(struct completion *x, unsigned long timeout)
/* This waits for either a completion of a specific task to be signaled or for a specified timeout to expire. The timeout is in jiffies. It is not interruptible. */ unsigned long __sched wait_for_completion_timeout(struct completion *x, unsigned long timeout)
{ return wait_for_common(x, timeout, TASK_UNINTERRUPTIBLE); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Returns: (skip): TRUE if the call succeded, FALSE if @error is set. */
gboolean _g_freedesktop_dbus_call_request_name_finish(_GFreedesktopDBus *proxy, guint *out_value, GAsyncResult *res, GError **error)
/* Returns: (skip): TRUE if the call succeded, FALSE if @error is set. */ gboolean _g_freedesktop_dbus_call_request_name_finish(_GFreedesktopDBus *proxy, guint *out_value, GAsyncResult *res, GError **error)
{ GVariant *_ret; _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error); if (_ret == NULL) goto _out; g_variant_get (_ret, "(u)", out_value); g_variant_unref (_ret); _out: return _ret != NULL; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Disable the High Speed APB (APB2) peripheral clock. */
void RCM_DisableAPB2PeriphClock(uint32_t APB2Periph)
/* Disable the High Speed APB (APB2) peripheral clock. */ void RCM_DisableAPB2PeriphClock(uint32_t APB2Periph)
{ RCM->APB2CLKEN &= (uint32_t)~APB2Periph; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns: an unsigned 32-bit integer from the attribute. */
guint32 g_file_info_get_attribute_uint32(GFileInfo *info, const char *attribute)
/* Returns: an unsigned 32-bit integer from the attribute. */ guint32 g_file_info_get_attribute_uint32(GFileInfo *info, const char *attribute)
{ GFileAttributeValue *value; g_return_val_if_fail (G_IS_FILE_INFO (info), 0); g_return_val_if_fail (attribute != NULL && *attribute != '\0', 0); value = g_file_info_find_value_by_name (info, attribute); return _g_file_attribute_value_get_uint32 (value); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Select the specified I2C fast mode duty cycle. */
void I2C_ConfigFastModeDutyCycle(I2C_T *i2c, I2C_DUTYCYCLE_T dutyCycle)
/* Select the specified I2C fast mode duty cycle. */ void I2C_ConfigFastModeDutyCycle(I2C_T *i2c, I2C_DUTYCYCLE_T dutyCycle)
{ if (dutyCycle == I2C_DUTYCYCLE_16_9) { i2c->CLKCTRL_B.FDUTYCFG = BIT_SET; } else { i2c->CLKCTRL_B.FDUTYCFG = BIT_RESET; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* The function returns 'true' if it thinks the attributes in 'fattr' are more recent than the ones cached in the inode. */
static int nfs_inode_attrs_need_update(const struct inode *inode, const struct nfs_fattr *fattr)
/* The function returns 'true' if it thinks the attributes in 'fattr' are more recent than the ones cached in the inode. */ static int nfs_inode_attrs_need_update(const struct inode *inode, const struct nfs_fattr *fattr)
{ const struct nfs_inode *nfsi = NFS_I(inode); return ((long)fattr->gencount - (long)nfsi->attr_gencount) > 0 || nfs_ctime_need_update(inode, fattr) || nfs_size_need_update(inode, fattr) || ((long)nfsi->attr_gencount - (long)nfs_read_attr_generation_counter() > 0); }
robutest/uclinux
C++
GPL-2.0
60
/* ADC Read the End-of-Sequence Flag for Regular Conversions. This flag is set after all channels of an regular group have been converted. */
bool adc_eos(uint32_t adc)
/* ADC Read the End-of-Sequence Flag for Regular Conversions. This flag is set after all channels of an regular group have been converted. */ bool adc_eos(uint32_t adc)
{ return ADC_ISR(adc) & ADC_ISR_EOS; }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* vApplicationGetIdleTaskMemory gets called when configSUPPORT_STATIC_ALLOCATION equals to 1 and is required for static memory allocation support. */
void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize)
/* vApplicationGetIdleTaskMemory gets called when configSUPPORT_STATIC_ALLOCATION equals to 1 and is required for static memory allocation support. */ void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize)
{ *ppxIdleTaskTCBBuffer = &Idle_TCB; *ppxIdleTaskStackBuffer = &Idle_Stack[0]; *pulIdleTaskStackSize = (uint32_t)configMINIMAL_STACK_SIZE; }
Luos-io/luos_engine
C++
MIT License
496
/* Allocate buffer for bpdt header, entries and all sub-partition content. Returns offset in data where BPDT ends. */
static size_t alloc_bpdt_buffer(void *data, size_t size, size_t offset, struct buffer *b, const char *name)
/* Allocate buffer for bpdt header, entries and all sub-partition content. Returns offset in data where BPDT ends. */ static size_t alloc_bpdt_buffer(void *data, size_t size, size_t offset, struct buffer *b, const char *name)
{ struct bpdt_header bpdt_header; assert((offset + BPDT_HEADER_SIZE) < size); bpdt_read_header((uint8_t *)data + offset, &bpdt_header, name); alloc_buffer(b, get_bpdt_size(&bpdt_header), name); struct bpdt *bpdt = buffer_get(b); memcpy(&bpdt->h, &bpdt_header, BPDT_HEADER_SIZE); if (bpdt->h.descriptor_count == 0) return (offset + BPDT_HEADER_SIZE); assert((offset + get_bpdt_size(&bpdt->h)) < size); bpdt_read_entries((uint8_t *)data + offset + BPDT_HEADER_SIZE, bpdt, name); return read_subpart_buf(data, size, &bpdt->e[0], bpdt->h.descriptor_count); }
4ms/stm32mp1-baremetal
C++
Other
137
/* Returns the CORE_CLK rate. CORE_CLK can have one of three rate sources on OMAP2xxx: the DPLL CLKOUT rate, DPLL CLKOUTX2, or 32KHz (the latter is unusual). This currently should be called with struct clk *dpll_ck, which is a composite clock of dpll_ck and core_ck. */
unsigned long omap2xxx_clk_get_core_rate(struct clk *clk)
/* Returns the CORE_CLK rate. CORE_CLK can have one of three rate sources on OMAP2xxx: the DPLL CLKOUT rate, DPLL CLKOUTX2, or 32KHz (the latter is unusual). This currently should be called with struct clk *dpll_ck, which is a composite clock of dpll_ck and core_ck. */ unsigned long omap2xxx_clk_get_core_rate(struct clk *clk)
{ long long core_clk; u32 v; core_clk = omap2_get_dpll_rate(clk); v = cm_read_mod_reg(PLL_MOD, CM_CLKSEL2); v &= OMAP24XX_CORE_CLK_SRC_MASK; if (v == CORE_CLK_SRC_32K) core_clk = 32768; else core_clk *= v; return core_clk; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Convert the absolute value of Bn into big-endian form and store it at Buf. The Buf array should have at least BigNumBytes() in it. */
INTN EFIAPI CryptoServiceBigNumToBin(IN CONST VOID *Bn, OUT UINT8 *Buf)
/* Convert the absolute value of Bn into big-endian form and store it at Buf. The Buf array should have at least BigNumBytes() in it. */ INTN EFIAPI CryptoServiceBigNumToBin(IN CONST VOID *Bn, OUT UINT8 *Buf)
{ return CALL_BASECRYPTLIB (Bn.Services.ToBin, BigNumToBin, (Bn, Buf), -1); }
tianocore/edk2
C++
Other
4,240
/* Look up the variable from the default environment */
char* env_get_default(const char *name)
/* Look up the variable from the default environment */ char* env_get_default(const char *name)
{ char *ret_val; unsigned long really_valid = gd->env_valid; unsigned long real_gd_flags = gd->flags; gd->flags &= ~GD_FLG_ENV_READY; gd->env_valid = ENV_INVALID; ret_val = env_get(name); gd->env_valid = really_valid; gd->flags = real_gd_flags; return ret_val; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Transition from the PBE (PLL Bypassed External) to the PEE (PLL Engaged External) mode. */
static void clock_pbe_to_pee(void)
/* Transition from the PBE (PLL Bypassed External) to the PEE (PLL Engaged External) mode. */ static void clock_pbe_to_pee(void)
{ KINETIS_MCG->c1 = (KINETIS_MCG->c1 & ~KINETIS_MCG_C1_CLKS_MSK) | KINETIS_MCG_C1_CLKS_FLLPLL_MSK; while ((KINETIS_MCG->status & KINETIS_MCG_S_CLKST_MSK) != KINETIS_MCG_S_CLKST_PLL); }
EmcraftSystems/u-boot
C++
Other
181
/* Calls a Local CPU function with a single optional parameter and return value. */
void IPCLiteRtoLFunctionCall(uint32_t ulFlag, uint32_t ulStatusFlag)
/* Calls a Local CPU function with a single optional parameter and return value. */ void IPCLiteRtoLFunctionCall(uint32_t ulFlag, uint32_t ulStatusFlag)
{ while (!(IpcRegs.IPCSTS.all & ulFlag)) { } if (IpcRegs.IPCRECVCOM == IPC_FUNC_CALL) { tfIpcFuncCall func_call = (tfIpcFuncCall)IpcRegs.IPCRECVADDR; IpcRegs.IPCLOCALREPLY = func_call(IpcRegs.IPCRECVDATA); IpcRegs.IPCACK.all |= (ulStatusFlag | ulFlag); } else { IpcRegs.IPCACK.all |= (ulFlag); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* adu_abort_transfers aborts transfers and frees associated data structures */
static void adu_abort_transfers(struct adu_device *dev)
/* adu_abort_transfers aborts transfers and frees associated data structures */ static void adu_abort_transfers(struct adu_device *dev)
{ unsigned long flags; dbg(2," %s : enter", __func__); if (dev->udev == NULL) { dbg(1," %s : udev is null", __func__); goto exit; } spin_lock_irqsave(&dev->buflock, flags); if (!dev->read_urb_finished) { spin_unlock_irqrestore(&dev->buflock, flags); usb_kill_urb(dev->interrupt_in_urb); } else spin_unlock_irqrestore(&dev->buflock, flags); spin_lock_irqsave(&dev->buflock, flags); if (!dev->out_urb_finished) { spin_unlock_irqrestore(&dev->buflock, flags); usb_kill_urb(dev->interrupt_out_urb); } else spin_unlock_irqrestore(&dev->buflock, flags); exit: dbg(2," %s : leave", __func__); }
robutest/uclinux
C++
GPL-2.0
60
/* Set the time in the Global Timer Counter Register. */
void XTime_SetTime(XTime Xtime_Global)
/* Set the time in the Global Timer Counter Register. */ void XTime_SetTime(XTime Xtime_Global)
{ Xil_Out32((u32)GLOBAL_TMR_BASEADDR + (u32)GTIMER_CONTROL_OFFSET, (u32)0x0); Xil_Out32((u32)GLOBAL_TMR_BASEADDR + (u32)GTIMER_COUNTER_LOWER_OFFSET, (u32)Xtime_Global); Xil_Out32((u32)GLOBAL_TMR_BASEADDR + (u32)GTIMER_COUNTER_UPPER_OFFSET, (u32)((u32)(Xtime_Global>>32U))); Xil_Out32((u32)GLOBAL_TMR_BASEADDR + (u32)GTIMER_CONTROL_OFFSET, (u32)0x1); }
ua1arn/hftrx
C++
null
69
/* Reset control endpoint. Called after a USB line reset or when UDD is enabled */
static void udd_reset_ep_ctrl(void)
/* Reset control endpoint. Called after a USB line reset or when UDD is enabled */ static void udd_reset_ep_ctrl(void)
{ irqflags_t flags; udd_configure_address(0); udd_enable_address(); udd_configure_endpoint(0, USB_EP_TYPE_CONTROL, 0, USB_DEVICE_EP_CTRL_SIZE, USBHS_DEVEPTCFG_EPBK_1_BANK); udd_allocate_memory(0); udd_enable_endpoint(0); flags = cpu_irq_save(); udd_enable_setup_received_interrupt(0); udd_enable_out_received_interrupt(0); udd_enable_endpoint_interrupt(0); cpu_irq_restore(flags); }
remotemcu/remcu-chip-sdks
C++
null
436
/* Erase one byte of 93LC46A in the specific address. */
void eep_93LC46A_Erase(unsigned char addr)
/* Erase one byte of 93LC46A in the specific address. */ void eep_93LC46A_Erase(unsigned char addr)
{ short cmd = _93LC46A_Erase | addr; eep_93LC46A_Cmd(cmd); eep_93LC46A_WaitForWriteEnd(); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* The descriptor is assumed to be properly initialized (ie: you got it through __rpipe_get_descr()). */
static int __rpipe_set_descr(struct wahc *wa, struct usb_rpipe_descriptor *descr, u16 index)
/* The descriptor is assumed to be properly initialized (ie: you got it through __rpipe_get_descr()). */ static int __rpipe_set_descr(struct wahc *wa, struct usb_rpipe_descriptor *descr, u16 index)
{ ssize_t result; struct device *dev = &wa->usb_iface->dev; result = usb_control_msg( wa->usb_dev, usb_sndctrlpipe(wa->usb_dev, 0), USB_REQ_SET_DESCRIPTOR, USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_RPIPE, USB_DT_RPIPE<<8, index, descr, sizeof(*descr), HZ / 10); if (result < 0) { dev_err(dev, "rpipe %u: set descriptor failed: %d\n", index, (int)result); goto error; } if (result < sizeof(*descr)) { dev_err(dev, "rpipe %u: sent short descriptor " "(%zd vs %zd bytes required)\n", index, result, sizeof(*descr)); result = -EINVAL; goto error; } result = 0; error: return result; }
robutest/uclinux
C++
GPL-2.0
60
/* release() implementation for gcov data files. Release resources allocated by open(). */
static int gcov_seq_release(struct inode *inode, struct file *file)
/* release() implementation for gcov data files. Release resources allocated by open(). */ static int gcov_seq_release(struct inode *inode, struct file *file)
{ struct gcov_iterator *iter; struct gcov_info *info; struct seq_file *seq; seq = file->private_data; iter = seq->private; info = gcov_iter_get_info(iter); gcov_iter_free(iter); gcov_info_free(info); seq_release(inode, file); return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Returns 1 if a byte has been received and can be read on the given TWI peripheral; otherwise, returns 0. This function resets the status register of the TWI. */
unsigned char TWI_ByteReceived(AT91S_TWI *pTwi)
/* Returns 1 if a byte has been received and can be read on the given TWI peripheral; otherwise, returns 0. This function resets the status register of the TWI. */ unsigned char TWI_ByteReceived(AT91S_TWI *pTwi)
{ return ((pTwi->TWI_SR & AT91C_TWI_RXRDY) == AT91C_TWI_RXRDY); }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Request the PE to perform a VDM mode exit. */
USBPD_StatusTypeDef USBPD_DPM_RequestVDM_ExitMode(uint8_t PortNum, USBPD_SOPType_TypeDef SOPType, uint16_t SVID, uint8_t ModeIndex)
/* Request the PE to perform a VDM mode exit. */ USBPD_StatusTypeDef USBPD_DPM_RequestVDM_ExitMode(uint8_t PortNum, USBPD_SOPType_TypeDef SOPType, uint16_t SVID, uint8_t ModeIndex)
{ return USBPD_PE_SVDM_RequestModeExit(PortNum, SOPType, SVID, ModeIndex); }
st-one/X-CUBE-USB-PD
C++
null
110
/* The HiiValue->Buffer is allocated from EFI boot services memory. It is the responsibility of the caller to free the memory allocated. */
EFI_STATUS HiiStatementValueToHiiValue(IN HII_STATEMENT_VALUE *StatementValue, OUT EFI_HII_VALUE *HiiValue)
/* The HiiValue->Buffer is allocated from EFI boot services memory. It is the responsibility of the caller to free the memory allocated. */ EFI_STATUS HiiStatementValueToHiiValue(IN HII_STATEMENT_VALUE *StatementValue, OUT EFI_HII_VALUE *HiiValue)
{ if ((StatementValue == NULL) || (HiiValue == NULL)) { return EFI_INVALID_PARAMETER; } ZeroMem (HiiValue, sizeof (EFI_HII_VALUE)); HiiValue->Type = StatementValue->Type; HiiValue->BufferLen = StatementValue->BufferLen; if ((StatementValue->Buffer != NULL) && (StatementValue->BufferLen > 0)) { HiiValue->Buffer = AllocateCopyPool (HiiValue->BufferLen, StatementValue->Buffer); } CopyMem (&HiiValue->Value, &StatementValue->Value, sizeof (EFI_IFR_TYPE_VALUE)); return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Internal function that places ASCII or Unicode character into the Buffer. */
CHAR8* BasePrintLibFillBuffer(OUT CHAR8 *Buffer, IN CHAR8 *EndBuffer, IN INTN Length, IN UINTN Character, IN INTN Increment)
/* Internal function that places ASCII or Unicode character into the Buffer. */ CHAR8* BasePrintLibFillBuffer(OUT CHAR8 *Buffer, IN CHAR8 *EndBuffer, IN INTN Length, IN UINTN Character, IN INTN Increment)
{ INTN Index; for (Index = 0; Index < Length && Buffer < EndBuffer; Index++) { *Buffer = (CHAR8)Character; if (Increment != 1) { *(Buffer + 1) = (CHAR8)(Character >> 8); } Buffer += Increment; } return Buffer; }
tianocore/edk2
C++
Other
4,240
/* \classmethod dict() Get or set the pin mapper dictionary. */
STATIC mp_obj_t pin_map_dict(mp_uint_t n_args, const mp_obj_t *args)
/* \classmethod dict() Get or set the pin mapper dictionary. */ STATIC mp_obj_t pin_map_dict(mp_uint_t n_args, const mp_obj_t *args)
{ MP_STATE_PORT(pin_class_map_dict) = args[1]; return mp_const_none; } return MP_STATE_PORT(pin_class_map_dict); }
labapart/polymcu
C++
null
201
/* Selects the specified I2C NACK position in master receiver mode. */
void I2C_ConfigNACKPosition(I2C_T *i2c, I2C_NACK_POSITION_T NACKPosition)
/* Selects the specified I2C NACK position in master receiver mode. */ void I2C_ConfigNACKPosition(I2C_T *i2c, I2C_NACK_POSITION_T NACKPosition)
{ if(NACKPosition == I2C_NACK_POSITION_NEXT) { i2c->CTRL1_B.ACKPOS = BIT_SET; } else { i2c->CTRL1_B.ACKPOS = BIT_RESET; } }
pikasTech/PikaPython
C++
MIT License
1,403
/* ADC MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_ADC_MspDeInit(ADC_HandleTypeDef *hadc)
/* ADC MSP De-Initialization This function freeze the hardware resources used in this example. */ void HAL_ADC_MspDeInit(ADC_HandleTypeDef *hadc)
{ if(hadc->Instance==ADC1) { __HAL_RCC_ADC1_CLK_DISABLE(); HAL_GPIO_DeInit(GPIOA, GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6 |GPIO_PIN_7); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This API is used to get the shadow dis in the register 0x13 bit 6. */
BMG160_RETURN_FUNCTION_TYPE bmg160_get_shadow_dis(u8 *v_shadow_dis_u8)
/* This API is used to get the shadow dis in the register 0x13 bit 6. */ BMG160_RETURN_FUNCTION_TYPE bmg160_get_shadow_dis(u8 *v_shadow_dis_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_SHADOW_DIS__REG, &v_data_u8, BMG160_GEN_READ_WRITE_DATA_LENGTH); *v_shadow_dis_u8 = BMG160_GET_BITSLICE(v_data_u8, BMG160_SHADOW_DIS); } return comres; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Converts a generic text device path node to device path structure. */
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextGenericPath(IN UINT8 Type, IN CHAR16 *TextDeviceNode)
/* Converts a generic text device path node to device path structure. */ EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextGenericPath(IN UINT8 Type, IN CHAR16 *TextDeviceNode)
{ EFI_DEVICE_PATH_PROTOCOL *Node; CHAR16 *SubtypeStr; CHAR16 *DataStr; UINTN DataLength; SubtypeStr = GetNextParamStr (&TextDeviceNode); DataStr = GetNextParamStr (&TextDeviceNode); if (DataStr == NULL) { DataLength = 0; } else { DataLength = StrLen (DataStr) / 2; } Node = CreateDeviceNode ( Type, (UINT8)Strtoi (SubtypeStr), (UINT16)(sizeof (EFI_DEVICE_PATH_PROTOCOL) + DataLength) ); StrHexToBytes (DataStr, DataLength * 2, (UINT8 *)(Node + 1), DataLength); return Node; }
tianocore/edk2
C++
Other
4,240
/* Allocate and initialize request queue and default I/O scheduler. */
static int dasd_alloc_queue(struct dasd_block *)
/* Allocate and initialize request queue and default I/O scheduler. */ static int dasd_alloc_queue(struct dasd_block *)
{ int rc; block->request_queue = blk_init_queue(do_dasd_request, &block->request_queue_lock); if (block->request_queue == NULL) return -ENOMEM; block->request_queue->queuedata = block; elevator_exit(block->request_queue->elevator); block->request_queue->elevator = NULL; rc = elevator_init(block->request_queue, "deadline"); if (rc) { blk_cleanup_queue(block->request_queue); return rc; } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Invert byte order within each 32-bits of an array. */
FourByteSwap(unsigned char *buf, size_t nbytes)
/* Invert byte order within each 32-bits of an array. */ FourByteSwap(unsigned char *buf, size_t nbytes)
{ FT_UInt32* b = (FT_UInt32*)buf; for ( ; nbytes >= 4; nbytes -= 4, b++ ) *b = BSWAP32( *b ); }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* Used to reset command or data internal state machines, using respectively SRC or SRD bit of SYSCTL register Can be called from interrupt context */
static void omap_hsmmc_reset_controller_fsm(struct omap_hsmmc_host *host, unsigned long bit)
/* Used to reset command or data internal state machines, using respectively SRC or SRD bit of SYSCTL register Can be called from interrupt context */ static void omap_hsmmc_reset_controller_fsm(struct omap_hsmmc_host *host, unsigned long bit)
{ unsigned long i = 0; unsigned long limit = (loops_per_jiffy * msecs_to_jiffies(MMC_TIMEOUT_MS)); OMAP_HSMMC_WRITE(host->base, SYSCTL, OMAP_HSMMC_READ(host->base, SYSCTL) | bit); while ((OMAP_HSMMC_READ(host->base, SYSCTL) & bit) && (i++ < limit)) cpu_relax(); if (OMAP_HSMMC_READ(host->base, SYSCTL) & bit) dev_err(mmc_dev(host->mmc), "Timeout waiting on controller reset in %s\n", __func__); }
robutest/uclinux
C++
GPL-2.0
60
/* If 8-bit MMIO register operations are not supported, then ASSERT(). */
UINT8 EFIAPI MmioWrite8(IN UINTN Address, IN UINT8 Value)
/* If 8-bit MMIO register operations are not supported, then ASSERT(). */ UINT8 EFIAPI MmioWrite8(IN UINTN Address, IN UINT8 Value)
{ BOOLEAN Flag; Flag = FilterBeforeMmIoWrite (FilterWidth8, Address, &Value); if (Flag) { MmioWrite8Internal (Address, Value); } FilterAfterMmIoWrite (FilterWidth8, Address, &Value); return Value; }
tianocore/edk2
C++
Other
4,240
/* This routine is called when a Restart Confirmation is needed */
static void rose_transmit_restart_confirmation(struct rose_neigh *neigh)
/* This routine is called when a Restart Confirmation is needed */ static void rose_transmit_restart_confirmation(struct rose_neigh *neigh)
{ struct sk_buff *skb; unsigned char *dptr; int len; len = AX25_BPQ_HEADER_LEN + AX25_MAX_HEADER_LEN + ROSE_MIN_LEN + 1; if ((skb = alloc_skb(len, GFP_ATOMIC)) == NULL) return; skb_reserve(skb, AX25_BPQ_HEADER_LEN + AX25_MAX_HEADER_LEN); dptr = skb_put(skb, ROSE_MIN_LEN + 1); *dptr++ = AX25_P_ROSE; *dptr++ = ROSE_GFI; *dptr++ = 0x00; *dptr++ = ROSE_RESTART_CONFIRMATION; if (!rose_send_frame(skb, neigh)) kfree_skb(skb); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Guess address family of an abstract address object based on address size. */
int nl_addr_guess_family(struct nl_addr *addr)
/* Guess address family of an abstract address object based on address size. */ int nl_addr_guess_family(struct nl_addr *addr)
{ switch (addr->a_len) { case 4: return AF_INET; case 6: return AF_LLC; case 16: return AF_INET6; default: return AF_UNSPEC; } }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Calculate the crc-16 (x^16 + x^15 + x^2 + 1) value for data. Note that this CRC is not equal to crc16_plain. */
guint16 crc16_8005_noreflect_noxor(const guint8 *data, guint64 data_len)
/* Calculate the crc-16 (x^16 + x^15 + x^2 + 1) value for data. Note that this CRC is not equal to crc16_plain. */ guint16 crc16_8005_noreflect_noxor(const guint8 *data, guint64 data_len)
{ guint tbl_idx; guint16 crc = 0; while (data_len--) { tbl_idx = ((crc >> 8) ^ *data) & 0xff; crc = (crc16_table_8005_noreflect_noxor[tbl_idx] ^ (crc << 8)) & 0xffff; data++; } return crc & 0xffff; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Set CMP0 Plus and Minus Comparator Input Mux. */
void CMPInputMuxSet(unsigned long ulBase, unsigned long ulPlus, unsigned long ulMinus)
/* Set CMP0 Plus and Minus Comparator Input Mux. */ void CMPInputMuxSet(unsigned long ulBase, unsigned long ulPlus, unsigned long ulMinus)
{ xASSERT(ulBase == ACMP_BASE); xASSERT((ulPlus >= 0) && (ulPlus < 8)); xASSERT((ulMinus >= 0) && (ulMinus < 8)); xHWREGB(ulBase + CMP0_MUXCR) &= ~CMP0_MUXCR_PSEL_M; xHWREGB(ulBase + CMP0_MUXCR) |= (ulPlus << CMP0_MUXCR_PSEL_S); xHWREGB(ulBase + CMP0_MUXCR) &= ~CMP0_MUXCR_MSEL_M; xHWREGB(ulBase + CMP0_MUXCR) |= (ulMinus << CMP0_MUXCR_MSEL_S); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* This function is the entry point of this Status Code Router PEIM. It produces Report Stataus Code Handler PPI and Status Code PPI. */
EFI_STATUS EFIAPI GenericStatusCodePeiEntry(IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)
/* This function is the entry point of this Status Code Router PEIM. It produces Report Stataus Code Handler PPI and Status Code PPI. */ EFI_STATUS EFIAPI GenericStatusCodePeiEntry(IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)
{ EFI_STATUS Status; EFI_PEI_PPI_DESCRIPTOR *OldDescriptor; EFI_PEI_PROGRESS_CODE_PPI *OldStatusCodePpi; CreateRscHandlerCallbackPacket (); Status = PeiServicesInstallPpi (mRscHandlerPpiList); ASSERT_EFI_ERROR (Status); Status = PeiServicesLocatePpi ( &gEfiPeiStatusCodePpiGuid, 0, &OldDescriptor, (VOID **)&OldStatusCodePpi ); if (!EFI_ERROR (Status)) { Status = PeiServicesReInstallPpi (OldDescriptor, mStatusCodePpiList); } else { Status = PeiServicesInstallPpi (mStatusCodePpiList); } ASSERT_EFI_ERROR (Status); return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* This call will set the mode for the @gpio to output. It will set the gpio pin low if value is 0 otherwise it will be high. */
static int msp71xx_direction_output(struct gpio_chip *chip, unsigned offset, int value)
/* This call will set the mode for the @gpio to output. It will set the gpio pin low if value is 0 otherwise it will be high. */ static int msp71xx_direction_output(struct gpio_chip *chip, unsigned offset, int value)
{ msp71xx_gpio_set(chip, offset, value); return msp71xx_set_gpio_mode(chip, offset, MSP71XX_GPIO_OUTPUT); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source. */
STATIC VOID FillBuf(IN SCRATCH_DATA *Sd, IN UINT16 NumOfBits)
/* Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source. */ STATIC VOID FillBuf(IN SCRATCH_DATA *Sd, IN UINT16 NumOfBits)
{ Sd->mBitBuf = (UINT32) (((UINT64)Sd->mBitBuf) << NumOfBits); while (NumOfBits > Sd->mBitCount) { Sd->mBitBuf |= (UINT32) (((UINT64)Sd->mSubBitBuf) << (NumOfBits = (UINT16) (NumOfBits - Sd->mBitCount))); if (Sd->mCompSize > 0) { Sd->mCompSize--; Sd->mSubBitBuf = 0; Sd->mSubBitBuf = Sd->mSrcBase[Sd->mInBuf++]; Sd->mBitCount = 8; } else { Sd->mSubBitBuf = 0; Sd->mBitCount = 8; } } Sd->mBitCount = (UINT16) (Sd->mBitCount - NumOfBits); Sd->mBitBuf |= Sd->mSubBitBuf >> Sd->mBitCount; }
tianocore/edk2
C++
Other
4,240
/* Called by bport in private loop topology to indicate that a rport has been discovered and plogi has been completed. */
void bfa_fcs_rport_start(struct bfa_fcs_port_s *port, struct fchs_s *fchs, struct fc_logi_s *plogi)
/* Called by bport in private loop topology to indicate that a rport has been discovered and plogi has been completed. */ void bfa_fcs_rport_start(struct bfa_fcs_port_s *port, struct fchs_s *fchs, struct fc_logi_s *plogi)
{ struct bfa_fcs_rport_s *rport; rport = bfa_fcs_rport_alloc(port, WWN_NULL, fchs->s_id); if (!rport) return; bfa_fcs_rport_update(rport, plogi); bfa_sm_send_event(rport, RPSM_EVENT_PLOGI_COMP); }
robutest/uclinux
C++
GPL-2.0
60
/* Checks whether the specified SPI flag is set or not. */
FlagStatus SPI_GetFlagStatus(SPI_TypeDef *SPIx, uint16_t SPI_FLAG)
/* Checks whether the specified SPI flag is set or not. */ FlagStatus SPI_GetFlagStatus(SPI_TypeDef *SPIx, uint16_t SPI_FLAG)
{ FlagStatus bitstatus = RESET; assert_param(IS_SPI_ALL_PERIPH(SPIx)); assert_param(IS_SPI_GET_FLAG(SPI_FLAG)); if ((SPIx->SR & SPI_FLAG) != (uint16_t)RESET) { bitstatus = SET; } else { bitstatus = RESET; } return bitstatus; }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* flexonenand_block - Return block number for flash address */
static unsigned int flexonenand_block(struct onenand_chip *this, loff_t addr)
/* flexonenand_block - Return block number for flash address */ static unsigned int flexonenand_block(struct onenand_chip *this, loff_t addr)
{ unsigned int boundary, blk, die = 0; if (ONENAND_IS_DDP(this) && addr >= this->diesize[0]) { die = 1; addr -= this->diesize[0]; } boundary = this->boundary[die]; blk = addr >> (this->erase_shift - 1); if (blk > boundary) blk = (blk + boundary + 1) >> 1; blk += die ? this->density_mask : 0; return blk; }
EmcraftSystems/u-boot
C++
Other
181
/* Calculate length of a given File Identifier Descriptor. */
UINT64 GetFidDescriptorLength(IN UDF_FILE_IDENTIFIER_DESCRIPTOR *FileIdentifierDesc)
/* Calculate length of a given File Identifier Descriptor. */ UINT64 GetFidDescriptorLength(IN UDF_FILE_IDENTIFIER_DESCRIPTOR *FileIdentifierDesc)
{ return (UINT64)( (INTN)((OFFSET_OF (UDF_FILE_IDENTIFIER_DESCRIPTOR, Data[0]) + 3 + FileIdentifierDesc->LengthOfFileIdentifier + FileIdentifierDesc->LengthOfImplementationUse) >> 2) << 2 ); }
tianocore/edk2
C++
Other
4,240
/* Mallocs a block of memory and initializes a mempool to use it. */
int mem_malloc_mempool(struct os_mempool *mempool, uint16_t num_blocks, uint32_t block_size, char *name, void **out_buf)
/* Mallocs a block of memory and initializes a mempool to use it. */ int mem_malloc_mempool(struct os_mempool *mempool, uint16_t num_blocks, uint32_t block_size, char *name, void **out_buf)
{ void *buf; int rc; rc = mem_malloc_mempool_gen(num_blocks, block_size, &buf); if (rc != 0) { return rc; } rc = os_mempool_init(mempool, num_blocks, block_size, buf, name); if (rc != 0) { tls_mem_free(buf); return rc; } if (out_buf != NULL) { *out_buf = buf; } return 0; }
Nicholas3388/LuaNode
C++
Other
1,055
/* If the pointer to the HOB list is NULL, then ASSERT(). */
VOID* EFIAPI GetHobList(VOID)
/* If the pointer to the HOB list is NULL, then ASSERT(). */ VOID* EFIAPI GetHobList(VOID)
{ ASSERT (mHobList != NULL); return mHobList; }
tianocore/edk2
C++
Other
4,240
/* This API is used to get the any motion(int1_any) interrupt1 enable bits of the sensor in the registers 0x17 bit 1. */
BMG160_RETURN_FUNCTION_TYPE bmg160_get_intr1_any_motion(u8 *v_int1r_any_motion_u8)
/* This API is used to get the any motion(int1_any) interrupt1 enable bits of the sensor in the registers 0x17 bit 1. */ BMG160_RETURN_FUNCTION_TYPE bmg160_get_intr1_any_motion(u8 *v_int1r_any_motion_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_INTR_MAP_ZERO_INTR1_ANY_MOTION__REG, &v_data_u8, BMG160_GEN_READ_WRITE_DATA_LENGTH); *v_int1r_any_motion_u8 = BMG160_GET_BITSLICE(v_data_u8, BMG160_INTR_MAP_ZERO_INTR1_ANY_MOTION); } return comres; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Disables the keyboard so that key strokes no longer generate scancodes to the host. */
static int i8042_disable(void)
/* Disables the keyboard so that key strokes no longer generate scancodes to the host. */ static int i8042_disable(void)
{ if (kbd_input_empty() == 0) return -1; out8(I8042_CMD_REG, CMD_KBD_DIS); if (kbd_input_empty() == 0) return -1; return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Description: Output an ASC_SCSI_Q structure to the chip */
static void DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
/* Description: Output an ASC_SCSI_Q structure to the chip */ static void DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
{ int i; ASC_DBG_PRT_HEX(2, "DvcPutScsiQ", outbuf, 2 * words); AscSetChipLramAddr(iop_base, s_addr); for (i = 0; i < 2 * words; i += 2) { if (i == 4 || i == 20) { continue; } outpw(iop_base + IOP_RAM_DATA, ((ushort)outbuf[i + 1] << 8) | outbuf[i]); } }
robutest/uclinux
C++
GPL-2.0
60
/* Get the empty frame buffer. This function should only be called when frame buffer count larger than 0. */
static uint32_t CSI_TransferGetEmptyBuffer(csi_handle_t *handle)
/* Get the empty frame buffer. This function should only be called when frame buffer count larger than 0. */ static uint32_t CSI_TransferGetEmptyBuffer(csi_handle_t *handle)
{ pvoid_to_u32_t buf; buf.pvoid = handle->emptyBuffer; handle->emptyBufferCnt--; handle->emptyBuffer = *(void **)(buf.pvoid); return buf.u32; }
eclipse-threadx/getting-started
C++
Other
310
/* Main program entry point. This routine contains the overall program flow, including initial setup of all components and the main program loop. */
int main(void)
/* Main program entry point. This routine contains the overall program flow, including initial setup of all components and the main program loop. */ int main(void)
{ SetupHardware(); LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); GlobalInterruptEnable(); for (;;) { MS_Device_USBTask(&Disk_MS_Interface); USB_USBTask(); } }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Initialize the boards on-board LEDs (LD3 and LD4) The LEDs are connected to the following pins: */
static void leds_init(void)
/* Initialize the boards on-board LEDs (LD3 and LD4) The LEDs are connected to the following pins: */ static void leds_init(void)
{ RCC->AHB1ENR |= RCC_AHB1ENR_GPIODEN; LED_PORT->MODER &= ~(0xff000000); LED_PORT->MODER |= 0x55000000; LED_PORT->OSPEEDR |= 0xff000000; LED_PORT->OTYPER &= ~(0xf000); LED_PORT->PUPDR &= ~(0xff000000); LED_PORT->BSRRH = 0xf000; }
labapart/polymcu
C++
null
201
/* This function checks if the voltage is set to 1.8V or not. */
s32 XSdPs_CheckVoltage18(XSdPs *InstancePtr)
/* This function checks if the voltage is set to 1.8V or not. */ s32 XSdPs_CheckVoltage18(XSdPs *InstancePtr)
{ u32 Status; if ((XSdPs_ReadReg16(InstancePtr->Config.BaseAddress, XSDPS_HOST_CTRL2_OFFSET) & XSDPS_HC2_1V8_EN_MASK) == 0U) { Status = XST_FAILURE; goto RETURN_PATH; } Status = XST_SUCCESS; RETURN_PATH: return Status; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Function for tracing page 0 and common data. */
static void page0_data_log(ant_hrm_page0_data_t const *p_page_data)
/* Function for tracing page 0 and common data. */ static void page0_data_log(ant_hrm_page0_data_t const *p_page_data)
{ LOG_PAGE0("Heart beat count: %u\n\r", (unsigned int)p_page_data->beat_count); LOG_PAGE0("Computed heart rate: %u\n\r", (unsigned int)p_page_data->computed_heart_rate); LOG_PAGE0("Heart beat event time: %u.", (unsigned int)ANT_HRM_BEAT_TIME_SEC(p_page_data->beat_time)); LOG_PAGE0("%03us\n\r", (unsigned int)ANT_HRM_BEAT_TIME_MSEC(p_page_data->beat_time)); }
labapart/polymcu
C++
null
201
/* Routine: set_muxconf_regs Description: Setting up the configuration Mux registers specific to the hardware. Many pins need to be moved from protect to primary mode. */
void set_muxconf_regs(void)
/* Routine: set_muxconf_regs Description: Setting up the configuration Mux registers specific to the hardware. Many pins need to be moved from protect to primary mode. */ void set_muxconf_regs(void)
{ MUX_AM3517EVM(); }
4ms/stm32mp1-baremetal
C++
Other
137
/* @buffer output buffer @dp device path or node */
static char* efi_convert_single_device_node_to_text(char *buffer, struct efi_device_path *dp)
/* @buffer output buffer @dp device path or node */ static char* efi_convert_single_device_node_to_text(char *buffer, struct efi_device_path *dp)
{ char *str = buffer; switch (dp->type) { case DEVICE_PATH_TYPE_HARDWARE_DEVICE: str = dp_hardware(str, dp); break; case DEVICE_PATH_TYPE_ACPI_DEVICE: str = dp_acpi(str, dp); break; case DEVICE_PATH_TYPE_MESSAGING_DEVICE: str = dp_msging(str, dp); break; case DEVICE_PATH_TYPE_MEDIA_DEVICE: str = dp_media(str, dp); break; case DEVICE_PATH_TYPE_END: break; default: str = dp_unknown(str, dp); } *str = '\0'; return str; }
4ms/stm32mp1-baremetal
C++
Other
137
/* user space has updated our poll period value, need to reset our workq delays */
void edac_mc_reset_delay_period(int value)
/* user space has updated our poll period value, need to reset our workq delays */ void edac_mc_reset_delay_period(int value)
{ struct mem_ctl_info *mci; struct list_head *item; mutex_lock(&mem_ctls_mutex); list_for_each(item, &mc_devices) { mci = list_entry(item, struct mem_ctl_info, link); if (mci->op_state == OP_RUNNING_POLL) cancel_delayed_work(&mci->work); } mutex_unlock(&mem_ctls_mutex); mutex_lock(&mem_ctls_mutex); list_for_each(item, &mc_devices) { mci = list_entry(item, struct mem_ctl_info, link); edac_mc_workq_setup(mci, (unsigned long) value); } mutex_unlock(&mem_ctls_mutex); }
robutest/uclinux
C++
GPL-2.0
60
/* Send the column address to the NAND Flash chip. */
static void write_column_address(const struct nand_flash_raw *raw, uint16_t column_address)
/* Send the column address to the NAND Flash chip. */ static void write_column_address(const struct nand_flash_raw *raw, uint16_t column_address)
{ uint16_t page_data_size = nand_flash_model_get_page_data_size(MODEL(raw)); if (nand_flash_model_get_data_bus_width(MODEL(raw)) == 16) { column_address >>= 1; } while (page_data_size > 2) { if (nand_flash_model_get_data_bus_width(MODEL(raw)) == 16) { WRITE_ADDRESS16(raw, (column_address & 0xFF)); } else { WRITE_ADDRESS(raw, (column_address & 0xFF)); } page_data_size >>= 8; column_address >>= 8; } }
remotemcu/remcu-chip-sdks
C++
null
436
/* genimg_get_kernel_addr() is the simple version of genimg_get_kernel_addr_fit(). It ignores those return FIT strings */
ulong genimg_get_kernel_addr(char *const img_addr)
/* genimg_get_kernel_addr() is the simple version of genimg_get_kernel_addr_fit(). It ignores those return FIT strings */ ulong genimg_get_kernel_addr(char *const img_addr)
{ const char *fit_uname_config = NULL; const char *fit_uname_kernel = NULL; return genimg_get_kernel_addr_fit(img_addr, &fit_uname_config, &fit_uname_kernel); }
4ms/stm32mp1-baremetal
C++
Other
137
/* Remove given timer from given list of active timers. */
static int timer_list_remove_isr(struct timer_list_t *self_p, struct timer_t *timer_p)
/* Remove given timer from given list of active timers. */ static int timer_list_remove_isr(struct timer_list_t *self_p, struct timer_t *timer_p)
{ struct timer_t *elem_p; struct timer_t *prev_p; elem_p = self_p->head_p; prev_p = NULL; while (elem_p != NULL) { if (elem_p == timer_p) { if (prev_p != NULL) { prev_p->next_p = elem_p->next_p; } else { self_p->head_p = elem_p->next_p; } if (elem_p->next_p != &self_p->tail) { elem_p->next_p->delta += elem_p->delta; } return (1); } prev_p = elem_p; elem_p = elem_p->next_p; } return (0); }
eerimoq/simba
C++
Other
337
/* Converts a text device path node to PCIE root device path structure. */
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextPcieRoot(CHAR16 *TextDeviceNode)
/* Converts a text device path node to PCIE root device path structure. */ EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextPcieRoot(CHAR16 *TextDeviceNode)
{ return ConvertFromTextAcpi (TextDeviceNode, 0x0a08); }
tianocore/edk2
C++
Other
4,240
/* Receives a byte that has been sent to the I2C Slave. */
uint32_t I2CSlaveDataGet(uint32_t ui32Base)
/* Receives a byte that has been sent to the I2C Slave. */ uint32_t I2CSlaveDataGet(uint32_t ui32Base)
{ ASSERT(_I2CBaseValid(ui32Base)); return(HWREG(ui32Base + I2C_O_SDR)); }
micropython/micropython
C++
Other
18,334
/* When in the 'enable' state the card operates as normal. When in the 'disable' state, the card enters into a low power mode. When in the 'halt' state, the card is shut down and must be fully restarted to come back on. */
int iwl_send_card_state(struct iwl_priv *priv, u32 flags, u8 meta_flag)
/* When in the 'enable' state the card operates as normal. When in the 'disable' state, the card enters into a low power mode. When in the 'halt' state, the card is shut down and must be fully restarted to come back on. */ int iwl_send_card_state(struct iwl_priv *priv, u32 flags, u8 meta_flag)
{ struct iwl_host_cmd cmd = { .id = REPLY_CARD_STATE_CMD, .len = sizeof(u32), .data = &flags, .flags = meta_flag, }; return iwl_send_cmd(priv, &cmd); }
robutest/uclinux
C++
GPL-2.0
60
/* Returns: (transfer full): a string with the data that was read before encountering any of the stop characters. Set @length to a #gsize to get the length of the string. This function will return NULL on an error. */
gchar* g_data_input_stream_read_until_finish(GDataInputStream *stream, GAsyncResult *result, gsize *length, GError **error)
/* Returns: (transfer full): a string with the data that was read before encountering any of the stop characters. Set @length to a #gsize to get the length of the string. This function will return NULL on an error. */ gchar* g_data_input_stream_read_until_finish(GDataInputStream *stream, GAsyncResult *result, gsize *length, GError **error)
{ g_return_val_if_fail (g_task_is_valid (result, stream), NULL); return g_data_input_stream_read_finish (stream, result, length, error); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This is an internal function to add a terminate node the entry, recalculate the table length and fill into the table. */
UINT8* S3BootScriptInternalCloseTable(VOID)
/* This is an internal function to add a terminate node the entry, recalculate the table length and fill into the table. */ UINT8* S3BootScriptInternalCloseTable(VOID)
{ UINT8 *S3TableBase; EFI_BOOT_SCRIPT_TERMINATE ScriptTerminate; EFI_BOOT_SCRIPT_TABLE_HEADER *ScriptTableInfo; S3TableBase = mS3BootScriptTablePtr->TableBase; if (S3TableBase == NULL) { return S3TableBase; } ScriptTerminate.OpCode = S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE; ScriptTerminate.Length = (UINT8)sizeof (EFI_BOOT_SCRIPT_TERMINATE); CopyMem (mS3BootScriptTablePtr->TableBase + mS3BootScriptTablePtr->TableLength, &ScriptTerminate, sizeof (EFI_BOOT_SCRIPT_TERMINATE)); ScriptTableInfo = (EFI_BOOT_SCRIPT_TABLE_HEADER *)(mS3BootScriptTablePtr->TableBase); ScriptTableInfo->TableLength = mS3BootScriptTablePtr->TableLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE); return S3TableBase; }
tianocore/edk2
C++
Other
4,240
/* This callback is called when the error recovery driver tells us that its OK to resume normal operation. Implementation resembles the second-half of the e1000_resume routine. */
static void e1000_io_resume(struct pci_dev *pdev)
/* This callback is called when the error recovery driver tells us that its OK to resume normal operation. Implementation resembles the second-half of the e1000_resume routine. */ static void e1000_io_resume(struct pci_dev *pdev)
{ struct net_device *netdev = pci_get_drvdata(pdev); struct e1000_adapter *adapter = netdev_priv(netdev); e1000_init_manageability(adapter); if (netif_running(netdev)) { if (e1000e_up(adapter)) { dev_err(&pdev->dev, "can't bring device back up after reset\n"); return; } } netif_device_attach(netdev); if (!(adapter->flags & FLAG_HAS_AMT)) e1000_get_hw_control(adapter); }
robutest/uclinux
C++
GPL-2.0
60
/* Return true if any of the pages in the mapping are marked with the passed tag. */
int mapping_tagged(struct address_space *mapping, int tag)
/* Return true if any of the pages in the mapping are marked with the passed tag. */ int mapping_tagged(struct address_space *mapping, int tag)
{ int ret; rcu_read_lock(); ret = radix_tree_tagged(&mapping->page_tree, tag); rcu_read_unlock(); return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* this function is a POSIX compliant version, which will reset directory stream. */
void rewinddir(DIR *d)
/* this function is a POSIX compliant version, which will reset directory stream. */ void rewinddir(DIR *d)
{ struct dfs_fd *fd; fd = fd_get(d->fd); if (fd == NULL) { rt_set_errno(-EBADF); return ; } if (dfs_file_lseek(fd, 0) >= 0) d->num = d->cur = 0; fd_put(fd); }
pikasTech/PikaPython
C++
MIT License
1,403
/* Returns: the position of the element in the #GSList, or -1 if the element is not found */
gint g_slist_position(GSList *list, GSList *llink)
/* Returns: the position of the element in the #GSList, or -1 if the element is not found */ gint g_slist_position(GSList *list, GSList *llink)
{ gint i; i = 0; while (list) { if (list == llink) return i; i++; list = list->next; } return -1; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Read the workarea to determine whether SEV is enabled. If enabled, then return the SevEsWorkArea pointer. */
STATIC SEC_SEV_ES_WORK_AREA* EFIAPI GetSevEsWorkArea(VOID)
/* Read the workarea to determine whether SEV is enabled. If enabled, then return the SevEsWorkArea pointer. */ STATIC SEC_SEV_ES_WORK_AREA* EFIAPI GetSevEsWorkArea(VOID)
{ OVMF_WORK_AREA *WorkArea; WorkArea = (OVMF_WORK_AREA *)FixedPcdGet32 (PcdOvmfWorkAreaBase); if ((WorkArea == NULL) || (WorkArea->Header.GuestType != CcGuestTypeAmdSev)) { return NULL; } return (SEC_SEV_ES_WORK_AREA *)FixedPcdGet32 (PcdSevEsWorkAreaBase); }
tianocore/edk2
C++
Other
4,240
/* Sends and reads protocol packet data byte on I2C. */
void adp_interface_transceive_procotol(uint8_t *tx_buf, uint16_t length, uint8_t *rx_buf)
/* Sends and reads protocol packet data byte on I2C. */ void adp_interface_transceive_procotol(uint8_t *tx_buf, uint16_t length, uint8_t *rx_buf)
{ adp_interface_send(tx_buf, length); adp_interface_read_response(rx_buf, length); }
memfault/zero-to-main
C++
null
200
/* This can store pdcs_size - 224 bytes of OS-Dependent data. We use a byte-by-byte write approach. It's up to userspace to deal with it when constructing its input buffer. */
static ssize_t pdcs_osdep2_write(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count)
/* This can store pdcs_size - 224 bytes of OS-Dependent data. We use a byte-by-byte write approach. It's up to userspace to deal with it when constructing its input buffer. */ static ssize_t pdcs_osdep2_write(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count)
{ unsigned long size; unsigned short i; u8 in[4]; if (!capable(CAP_SYS_ADMIN)) return -EACCES; if (!buf || !count) return -EINVAL; if (unlikely(pdcs_size <= 224)) return -ENOSYS; if (unlikely(pdcs_osid != OS_ID_LINUX)) return -EPERM; size = pdcs_size - 224; if (count > size) return -EMSGSIZE; for (i=0; i<count; i+=4) { memset(in, 0, 4); memcpy(in, buf+i, (count-i < 4) ? count-i : 4); if (unlikely(pdc_stable_write(PDCS_ADDR_OSD2 + i, &in, sizeof(in)) != PDC_OK)) return -EIO; } return count; }
robutest/uclinux
C++
GPL-2.0
60
/* Stop all timers, empty all queues and reset all flags. */
int llc_conn_reset(struct sock *sk, struct sk_buff *skb)
/* Stop all timers, empty all queues and reset all flags. */ int llc_conn_reset(struct sock *sk, struct sk_buff *skb)
{ llc_sk_reset(sk); return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* We have 2 types of commands: wifi and non-wifi ones. */
static int iwm_nonwifi_cmd_init(struct iwm_priv *iwm, struct iwm_nonwifi_cmd *cmd, struct iwm_udma_nonwifi_cmd *udma_cmd)
/* We have 2 types of commands: wifi and non-wifi ones. */ static int iwm_nonwifi_cmd_init(struct iwm_priv *iwm, struct iwm_nonwifi_cmd *cmd, struct iwm_udma_nonwifi_cmd *udma_cmd)
{ INIT_LIST_HEAD(&cmd->pending); spin_lock(&iwm->cmd_lock); cmd->resp_received = 0; cmd->seq_num = iwm->nonwifi_seq_num; udma_cmd->seq_num = cpu_to_le16(cmd->seq_num); iwm->nonwifi_seq_num++; iwm->nonwifi_seq_num %= UMAC_NONWIFI_SEQ_NUM_MAX; if (udma_cmd->resp) list_add_tail(&cmd->pending, &iwm->nonwifi_pending_cmd); spin_unlock(&iwm->cmd_lock); cmd->buf.start = cmd->buf.payload; cmd->buf.len = 0; memcpy(&cmd->udma_cmd, udma_cmd, sizeof(*udma_cmd)); return cmd->seq_num; }
robutest/uclinux
C++
GPL-2.0
60
/* template: location in which to build the desired set of subsystem state objects for the new cgroup group */
static struct css_set* find_existing_css_set(struct css_set *oldcg, struct cgroup *cgrp, struct cgroup_subsys_state *template[])
/* template: location in which to build the desired set of subsystem state objects for the new cgroup group */ static struct css_set* find_existing_css_set(struct css_set *oldcg, struct cgroup *cgrp, struct cgroup_subsys_state *template[])
{ int i; struct cgroupfs_root *root = cgrp->root; struct hlist_head *hhead; struct hlist_node *node; struct css_set *cg; for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) { if (root->subsys_bits & (1UL << i)) { template[i] = cgrp->subsys[i]; } else { template[i] = oldcg->subsys[i]; } } hhead = css_set_hash(template); hlist_for_each_entry(cg, node, hhead, hlist) { if (!compare_css_sets(cg, oldcg, cgrp, template)) continue; return cg; } return NULL; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* param base SPI peripheral base address. param handle Pointer to the spi_master_handle_t structure which stores the transfer state. */
void SPI_MasterTransferAbort(SPI_Type *base, spi_master_handle_t *handle)
/* param base SPI peripheral base address. param handle Pointer to the spi_master_handle_t structure which stores the transfer state. */ void SPI_MasterTransferAbort(SPI_Type *base, spi_master_handle_t *handle)
{ assert(NULL != handle); base->FIFOINTENSET &= ~(SPI_FIFOINTENSET_TXLVL_MASK | SPI_FIFOINTENSET_RXLVL_MASK); base->FIFOCFG |= SPI_FIFOCFG_EMPTYTX_MASK | SPI_FIFOCFG_EMPTYRX_MASK; handle->state = (uint32_t)kStatus_SPI_Idle; handle->txRemainingBytes = 0U; handle->rxRemainingBytes = 0U; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Return the child ACPI objects from Root Handle. */
EFI_STATUS AmlGetChildFromRoot(IN EFI_AML_HANDLE *AmlParentHandle, IN EFI_AML_HANDLE *AmlHandle, OUT VOID **Buffer)
/* Return the child ACPI objects from Root Handle. */ EFI_STATUS AmlGetChildFromRoot(IN EFI_AML_HANDLE *AmlParentHandle, IN EFI_AML_HANDLE *AmlHandle, OUT VOID **Buffer)
{ UINT8 *CurrentBuffer; if (AmlHandle == NULL) { CurrentBuffer = (VOID *)AmlParentHandle->Buffer; } else { CurrentBuffer = (VOID *)(AmlHandle->Buffer + AmlHandle->Size); } return AmlGetChildFromObjectBuffer (AmlParentHandle, CurrentBuffer, Buffer); }
tianocore/edk2
C++
Other
4,240
/* After the clock is registered, the host will keep writing to the registered memory location. If the guest happens to shutdown, this memory won't be valid. In cases like kexec, in which you install a new kernel, this means a random memory location will be kept being written. So before any kind of shutdown from our side, we unregister the clock by writting anything that does not have the 'enable' bit set in the msr */
static void kvm_shutdown(void)
/* After the clock is registered, the host will keep writing to the registered memory location. If the guest happens to shutdown, this memory won't be valid. In cases like kexec, in which you install a new kernel, this means a random memory location will be kept being written. So before any kind of shutdown from our side, we unregister the clock by writting anything that does not have the 'enable' bit set in the msr */ static void kvm_shutdown(void)
{ native_write_msr_safe(MSR_KVM_SYSTEM_TIME, 0, 0); native_machine_shutdown(); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Returns the status for the specified circuit. flags points to a longword which receives a combination of the canSTAT_xxx flags. */
static canStatus LeafLightLibFuncReadStatus(const CanHandle hnd, uint32_t *const flags)
/* Returns the status for the specified circuit. flags points to a longword which receives a combination of the canSTAT_xxx flags. */ static canStatus LeafLightLibFuncReadStatus(const CanHandle hnd, uint32_t *const flags)
{ canStatus result = canERR_NOTINITIALIZED; assert(leafLightLibFuncReadStatusPtr != NULL); assert(leafLightDllHandle != NULL); if ((leafLightLibFuncReadStatusPtr != NULL) && (leafLightDllHandle != NULL)) { result = leafLightLibFuncReadStatusPtr(hnd, flags); } return result; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Create the appropriate control structures to manage a new EHCI host controller. */
int ehci_hcd_init(int index, enum usb_init_type init, struct ehci_hccr **hccr, struct ehci_hcor **hcor)
/* Create the appropriate control structures to manage a new EHCI host controller. */ int ehci_hcd_init(int index, enum usb_init_type init, struct ehci_hccr **hccr, struct ehci_hcor **hcor)
{ int ret; u32 vct_hccr; u32 vct_hcor; ret = vct_ehci_hcd_init(&vct_hccr, &vct_hcor); if (ret) return ret; *hccr = (struct ehci_hccr *)vct_hccr; *hcor = (struct ehci_hcor *)vct_hcor; return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* This function prepares the state before issuing the class specific commands. */
USBH_StatusTypeDef USBH_CDC_GetLineCoding(USBH_HandleTypeDef *phost, CDC_LineCodingTypeDef *linecodin)
/* This function prepares the state before issuing the class specific commands. */ USBH_StatusTypeDef USBH_CDC_GetLineCoding(USBH_HandleTypeDef *phost, CDC_LineCodingTypeDef *linecodin)
{ CDC_HandleTypeDef *CDC_Handle = phost->pActiveClass->pData; if((phost->gState == HOST_CLASS) ||(phost->gState == HOST_CLASS_REQUEST)) { *linecodin = CDC_Handle->LineCoding; return USBH_OK; } else { return USBH_FAIL; } }
micropython/micropython
C++
Other
18,334
/* Return a pointer to the struct powerdomain that the specified clockdomain 'clkdm' exists in, or returns NULL if clkdm argument is NULL. */
struct powerdomain* clkdm_get_pwrdm(struct clockdomain *clkdm)
/* Return a pointer to the struct powerdomain that the specified clockdomain 'clkdm' exists in, or returns NULL if clkdm argument is NULL. */ struct powerdomain* clkdm_get_pwrdm(struct clockdomain *clkdm)
{ if (!clkdm) return NULL; return clkdm->pwrdm.ptr; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This function is called via BASE_CUSTOM, and displays the packet type code as a character like it is in the specification, rather than using BASE_DEC which shows it as an integer value. */
static void format_packet_type(gchar *buf, guint32 value)
/* This function is called via BASE_CUSTOM, and displays the packet type code as a character like it is in the specification, rather than using BASE_DEC which shows it as an integer value. */ static void format_packet_type(gchar *buf, guint32 value)
{ gchar* tmp_str; tmp_str = val_to_str_wmem(NULL, value, pkt_type_val, "Unknown packet"); g_snprintf(buf, ITEM_LABEL_LENGTH, "%s (%c)", tmp_str, (char)(value & 0xff)); wmem_free(NULL, tmp_str); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Execute a caller provided function on all enabled APs. */
EFI_STATUS MpServicesUnitTestStartupAllAPs(IN MP_SERVICES MpServices, IN EFI_AP_PROCEDURE Procedure, IN BOOLEAN SingleThread, IN UINTN TimeoutInMicroSeconds, IN VOID *ProcedureArgument)
/* Execute a caller provided function on all enabled APs. */ EFI_STATUS MpServicesUnitTestStartupAllAPs(IN MP_SERVICES MpServices, IN EFI_AP_PROCEDURE Procedure, IN BOOLEAN SingleThread, IN UINTN TimeoutInMicroSeconds, IN VOID *ProcedureArgument)
{ return MpServices.Protocol->StartupAllAPs (MpServices.Protocol, Procedure, SingleThread, NULL, TimeoutInMicroSeconds, ProcedureArgument, NULL); }
tianocore/edk2
C++
Other
4,240