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
/* qt_setuart issuse a SET_UART vendor-spcific request on the default control pipe If successful sets baud rate divisor and LCR value */
static int qt_setuart(struct usb_serial *serial, unsigned short Uart_Number, unsigned short default_divisor, unsigned char default_LCR)
/* qt_setuart issuse a SET_UART vendor-spcific request on the default control pipe If successful sets baud rate divisor and LCR value */ static int qt_setuart(struct usb_serial *serial, unsigned short Uart_Number, unsigned short default_divisor, unsigned char default_LCR)
{ int result; unsigned short UartNumandLCR; UartNumandLCR = (default_LCR << 8) + Uart_Number; result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), QT_GET_SET_UART, 0x40, default_divisor, UartNumandLCR, NULL, 0, 300); return result; }
robutest/uclinux
C++
GPL-2.0
60
/* Forces the output 4 waveform to active or inactive level. */
void TMR_ConfigForcedOC4(TMR_T *tmr, TMR_FORCED_ACTION_T forcesAction)
/* Forces the output 4 waveform to active or inactive level. */ void TMR_ConfigForcedOC4(TMR_T *tmr, TMR_FORCED_ACTION_T forcesAction)
{ tmr->CCM2_COMPARE_B.OC4MODE = BIT_RESET; tmr->CCM2_COMPARE_B.OC4MODE = forcesAction; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Programs the FLASH User Option Byte: IWDG_SW / RST_STOP / RST_STDBY/ BOOT1 and OB_VDDA_ANALOG. */
FLASH_Status FLASH_OB_WriteUser(uint8_t OB_USER)
/* Programs the FLASH User Option Byte: IWDG_SW / RST_STOP / RST_STDBY/ BOOT1 and OB_VDDA_ANALOG. */ FLASH_Status FLASH_OB_WriteUser(uint8_t OB_USER)
{ FLASH_Status status = FLASH_COMPLETE; FLASH->OPTKEYR = FLASH_KEY1; FLASH->OPTKEYR = FLASH_KEY2; status = FLASH_WaitForLastOperation(FLASH_ER_PRG_TIMEOUT); if(status == FLASH_COMPLETE) { FLASH->CR |= FLASH_CR_OPTPG; OB->USER = OB_USER | 0x88; status = FLASH_WaitForLastOperation(FLASH_ER_PRG_TIMEOUT); if(status != FLASH_TIMEOUT) { FLASH->CR &= ~FLASH_CR_OPTPG; } } return status; }
ajhc/demo-cortex-m3
C++
null
38
/* Dumps a font face rule statement to a file. */
void cr_statement_dump_font_face_rule(CRStatement *a_this, FILE *a_fp, glong a_indent)
/* Dumps a font face rule statement to a file. */ void cr_statement_dump_font_face_rule(CRStatement *a_this, FILE *a_fp, glong a_indent)
{ gchar *str = NULL ; g_return_if_fail (a_this && a_this->type == AT_FONT_FACE_RULE_STMT); str = cr_statement_font_face_rule_to_string (a_this, a_indent) ; if (str) { fprintf (a_fp, "%s", str) ; g_free (str) ; str = NULL ; } }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This function checks if a specific unity mapping entry is needed for this specific IOMMU. */
static int iommu_for_unity_map(struct amd_iommu *iommu, struct unity_map_entry *entry)
/* This function checks if a specific unity mapping entry is needed for this specific IOMMU. */ static int iommu_for_unity_map(struct amd_iommu *iommu, struct unity_map_entry *entry)
{ u16 bdf, i; for (i = entry->devid_start; i <= entry->devid_end; ++i) { bdf = amd_iommu_alias_table[i]; if (amd_iommu_rlookup_table[bdf] == iommu) return 1; } return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This function walks the UBIFS index, calculates its size and checks that the size is equivalent to @idx_size. Returns zero in case of success and a negative error code in case of failure. */
int dbg_check_idx_size(struct ubifs_info *c, long long idx_size)
/* This function walks the UBIFS index, calculates its size and checks that the size is equivalent to @idx_size. Returns zero in case of success and a negative error code in case of failure. */ int dbg_check_idx_size(struct ubifs_info *c, long long idx_size)
{ int err; long long calc = 0; if (!dbg_is_chk_index(c)) return 0; err = dbg_walk_index(c, NULL, add_size, &calc); if (err) { ubifs_err(c, "error %d while walking the index", err); return err; } if (calc != idx_size) { ubifs_err(c, "index size check failed: calculated size is %lld, should be %lld", calc, idx_size); dump_stack(); return -EINVAL; } return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Return the MAC/BB name. "????" is returned if the MAC/BB is unknown. */
static const char* ath9k_hw_mac_bb_name(u32 mac_bb_version)
/* Return the MAC/BB name. "????" is returned if the MAC/BB is unknown. */ static const char* ath9k_hw_mac_bb_name(u32 mac_bb_version)
{ int i; for (i=0; i<ARRAY_SIZE(ath_mac_bb_names); i++) { if (ath_mac_bb_names[i].version == mac_bb_version) { return ath_mac_bb_names[i].name; } } return "????"; }
robutest/uclinux
C++
GPL-2.0
60
/* Unlink all currently active capture URBs, and wait for finishing. */
void unlink_wait_clear_audio_in_urbs(struct snd_line6_pcm *line6pcm)
/* Unlink all currently active capture URBs, and wait for finishing. */ void unlink_wait_clear_audio_in_urbs(struct snd_line6_pcm *line6pcm)
{ unlink_audio_in_urbs(line6pcm); wait_clear_audio_in_urbs(line6pcm); }
robutest/uclinux
C++
GPL-2.0
60
/* ic3_start_tx - Start transmitter. Called with the_port->lock @port: Port to operate on */
static void ic3_start_tx(struct uart_port *the_port)
/* ic3_start_tx - Start transmitter. Called with the_port->lock @port: Port to operate on */ static void ic3_start_tx(struct uart_port *the_port)
{ struct ioc3_port *port = get_ioc3_port(the_port); if (port) { set_notification(port, N_OUTPUT_LOWAT, 1); enable_intrs(port, port->ip_hooks->intr_tx_mt); } }
robutest/uclinux
C++
GPL-2.0
60
/* Excess bits not allocated by allocaAdjustedBits are allocated round-robin. */
INLINE OI_INT allocExcessBits(OI_UINT8 *dest, OI_INT excess)
/* Excess bits not allocated by allocaAdjustedBits are allocated round-robin. */ INLINE OI_INT allocExcessBits(OI_UINT8 *dest, OI_INT excess)
{ if(*dest < 16) { *dest += 1; return excess - 1; } else { return excess; } }
Nicholas3388/LuaNode
C++
Other
1,055
/* param masterConfig User provided configuration structure for default values. Refer to #i3c_master_config_t. */
void I3C_MasterGetDefaultConfig(i3c_master_config_t *masterConfig)
/* param masterConfig User provided configuration structure for default values. Refer to #i3c_master_config_t. */ void I3C_MasterGetDefaultConfig(i3c_master_config_t *masterConfig)
{ masterConfig->enableMaster = kI3C_MasterOn; masterConfig->disableTimeout = false; masterConfig->hKeep = kI3C_MasterHighKeeperNone; masterConfig->enableOpenDrainStop = true; masterConfig->enableOpenDrainHigh = true; masterConfig->baudRate_Hz.i2cBaud = 400000U; masterConfig->baudRate_Hz.i3cPushPullBaud = 12500000U; masterConfig->baudRate_Hz.i3cOpenDrainBaud = 2500000U; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Release all the fragments of a packet, then free the assemble entry. */
VOID Ip4FreeAssembleEntry(IN IP4_ASSEMBLE_ENTRY *Assemble)
/* Release all the fragments of a packet, then free the assemble entry. */ VOID Ip4FreeAssembleEntry(IN IP4_ASSEMBLE_ENTRY *Assemble)
{ LIST_ENTRY *Entry; LIST_ENTRY *Next; NET_BUF *Fragment; NET_LIST_FOR_EACH_SAFE (Entry, Next, &Assemble->Fragments) { Fragment = NET_LIST_USER_STRUCT (Entry, NET_BUF, List); RemoveEntryList (Entry); NetbufFree (Fragment); } FreePool (Assemble); }
tianocore/edk2
C++
Other
4,240
/* Actual INFTL access routines. Read oob data from flash */
int inftl_read_oob(struct mtd_info *mtd, loff_t offs, size_t len, size_t *retlen, uint8_t *buf)
/* Actual INFTL access routines. Read oob data from flash */ int inftl_read_oob(struct mtd_info *mtd, loff_t offs, size_t len, size_t *retlen, uint8_t *buf)
{ struct mtd_oob_ops ops; int res; ops.mode = MTD_OOB_PLACE; ops.ooboffs = offs & (mtd->writesize - 1); ops.ooblen = len; ops.oobbuf = buf; ops.datbuf = NULL; res = mtd->read_oob(mtd, offs & ~(mtd->writesize - 1), &ops); *retlen = ops.oobretlen; return res; }
robutest/uclinux
C++
GPL-2.0
60
/* Arm request timeout if an AP device was idle and a new request is submitted. */
static void ap_increase_queue_count(struct ap_device *ap_dev)
/* Arm request timeout if an AP device was idle and a new request is submitted. */ static void ap_increase_queue_count(struct ap_device *ap_dev)
{ int timeout = ap_dev->drv->request_timeout; ap_dev->queue_count++; if (ap_dev->queue_count == 1) { mod_timer(&ap_dev->timeout, jiffies + timeout); ap_dev->reset = AP_RESET_ARMED; } }
robutest/uclinux
C++
GPL-2.0
60
/* This function will install a interrupt service routine to a interrupt. */
rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler, void *param, const char *name)
/* This function will install a interrupt service routine to a interrupt. */ rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler, void *param, const char *name)
{ rt_isr_handler_t old_handler = RT_NULL; if(vector >= 0 && vector < MAX_HANDLERS) { rt_uint32_t* vect_ctl = (rt_uint32_t *)(VIC_BASE_ADDR + 0x200 + (vector << 2)); *vect_ctl = 0x20 | (vector & 0x1F); old_handler = irq_desc[vector].handler; if (handler != RT_NULL) { irq_desc[vector].handler = handler; irq_desc[vector].param = param; } } return old_handler; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Can be called in a soft IRQ context, so xprt_write_space never sleeps. */
void xprt_write_space(struct rpc_xprt *xprt)
/* Can be called in a soft IRQ context, so xprt_write_space never sleeps. */ void xprt_write_space(struct rpc_xprt *xprt)
{ if (unlikely(xprt->shutdown)) return; spin_lock_bh(&xprt->transport_lock); if (xprt->snd_task) { dprintk("RPC: write space: waking waiting task on " "xprt %p\n", xprt); rpc_wake_up_queued_task(&xprt->pending, xprt->snd_task); } spin_unlock_bh(&xprt->transport_lock); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Noise generation functions. I'm not sure what these are for - they seem to be some kind of pseudorandom sequence generators, used to generate noise data which is used when the channels are rematrixed. I'm not sure if they provide a practical benefit to compression, or just obfuscate the decoder. Are they for some kind of dithering? Generate two channels of noise, used in the matrix when restart sync word == 0x31ea. */
static void generate_2_noise_channels(MLPDecodeContext *m, unsigned int substr)
/* Noise generation functions. I'm not sure what these are for - they seem to be some kind of pseudorandom sequence generators, used to generate noise data which is used when the channels are rematrixed. I'm not sure if they provide a practical benefit to compression, or just obfuscate the decoder. Are they for some kind of dithering? Generate two channels of noise, used in the matrix when restart sync word == 0x31ea. */ static void generate_2_noise_channels(MLPDecodeContext *m, unsigned int substr)
{ SubStream *s = &m->substream[substr]; unsigned int i; uint32_t seed = s->noisegen_seed; unsigned int maxchan = s->max_matrix_channel; for (i = 0; i < s->blockpos; i++) { uint16_t seed_shr7 = seed >> 7; m->sample_buffer[i][maxchan+1] = ((int8_t)(seed >> 15)) << s->noise_shift; m->sample_buffer[i][maxchan+2] = ((int8_t) seed_shr7) << s->noise_shift; seed = (seed << 16) ^ seed_shr7 ^ (seed_shr7 << 5); } s->noisegen_seed = seed; }
DC-SWAT/DreamShell
C++
null
404
/* simple_strtol - convert a string to a signed long @cp: The start of the string @endp: A pointer to the end of the parsed string will be placed here @base: The number base to use */
long simple_strtol(const char *cp, char **endp, unsigned int base)
/* simple_strtol - convert a string to a signed long @cp: The start of the string @endp: A pointer to the end of the parsed string will be placed here @base: The number base to use */ long simple_strtol(const char *cp, char **endp, unsigned int base)
{ if (*cp == '-') return -simple_strtoul(cp + 1, endp, base); return simple_strtoul(cp, endp, base); }
robutest/uclinux
C++
GPL-2.0
60
/* This function replaces the original SSIDataNonBlockingPut() API and performs the same actions. A macro is provided in */
long SSIDataPutNonBlocking(unsigned long ulBase, unsigned long ulData)
/* This function replaces the original SSIDataNonBlockingPut() API and performs the same actions. A macro is provided in */ long SSIDataPutNonBlocking(unsigned long ulBase, unsigned long ulData)
{ ASSERT((ulBase == SSI0_BASE) || (ulBase == SSI1_BASE)); ASSERT((ulData & (0xfffffffe << (HWREG(ulBase + SSI_O_CR0) & SSI_CR0_DSS_M))) == 0); if(HWREG(ulBase + SSI_O_SR) & SSI_SR_TNF) { HWREG(ulBase + SSI_O_DR) = ulData; return(1); } else { return(0); } }
watterott/WebRadio
C++
null
71
/* So the lguest_set_pte_at() and lguest_set_pmd() functions above are only called when a valid entry is written, not when it's removed (ie. marked not present). Instead, this is where we come when the Guest wants to remove a page table entry: we tell the Host to set that entry to 0 (ie. the present bit is zero). */
static void lguest_flush_tlb_single(unsigned long addr)
/* So the lguest_set_pte_at() and lguest_set_pmd() functions above are only called when a valid entry is written, not when it's removed (ie. marked not present). Instead, this is where we come when the Guest wants to remove a page table entry: we tell the Host to set that entry to 0 (ie. the present bit is zero). */ static void lguest_flush_tlb_single(unsigned long addr)
{ lazy_hcall3(LHCALL_SET_PTE, lguest_data.pgdir, addr, 0); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Add a new data source to the list of data sources for a frame, given the tvbuff for the data source and its name. */
void add_new_data_source(packet_info *pinfo, tvbuff_t *tvb, const char *name)
/* Add a new data source to the list of data sources for a frame, given the tvbuff for the data source and its name. */ void add_new_data_source(packet_info *pinfo, tvbuff_t *tvb, const char *name)
{ struct data_source *src; src = wmem_new(pinfo->pool, struct data_source); src->tvb = tvb; src->name = wmem_strdup(pinfo->pool, name); pinfo->data_src = g_slist_append(pinfo->data_src, src); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Fills each ADC_InitStruct member with its default value. */
void ADC_StructInit(ADC_InitTypeDef *ADC_InitStruct)
/* Fills each ADC_InitStruct member with its default value. */ void ADC_StructInit(ADC_InitTypeDef *ADC_InitStruct)
{ ADC_InitStruct->ADC_Resolution = ADC_Resolution_12b; ADC_InitStruct->ADC_PRESCARE = ADC_PCLK2_PRESCARE_2; ADC_InitStruct->ADC_Mode = ADC_Mode_Single; ADC_InitStruct->ADC_ContinuousConvMode = DISABLE; ADC_InitStruct->ADC_ExternalTrigConv = ADC_ExternalTrigConv_T1_CC1; ADC_InitStruct->ADC_DataAlign = ADC_DataAlign_Right; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Forces or releases Low Speed AHB2 peripheral reset. */
void RCC_AHB3PeriphResetCmd(u32 ahb_periph, FunctionalState state)
/* Forces or releases Low Speed AHB2 peripheral reset. */ void RCC_AHB3PeriphResetCmd(u32 ahb_periph, FunctionalState state)
{ (state) ? (RCC->AHB3RSTR |= ahb_periph) : (RCC->AHB3RSTR &= ~ahb_periph); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Handle any change of modem status signal since we were last called. */
static void sa1100_mctrl_check(struct sa1100_port *sport)
/* Handle any change of modem status signal since we were last called. */ static void sa1100_mctrl_check(struct sa1100_port *sport)
{ unsigned int status, changed; status = sport->port.ops->get_mctrl(&sport->port); changed = status ^ sport->old_status; if (changed == 0) return; sport->old_status = status; if (changed & TIOCM_RI) sport->port.icount.rng++; if (changed & TIOCM_DSR) sport->port.icount.dsr++; if (changed & TIOCM_CAR) uart_handle_dcd_change(&sport->port, status & TIOCM_CAR); if (changed & TIOCM_CTS) uart_handle_cts_change(&sport->port, status & TIOCM_CTS); wake_up_interruptible(&sport->port.state->port.delta_msr_wait); }
robutest/uclinux
C++
GPL-2.0
60
/* Performs the triplet function, which reads two bits and writes a bit. The bit written is determined by the two reads: 00 => dbit, 01 => 0, 10 => 1 */
static u8 ds2482_w1_triplet(void *data, u8 dbit)
/* Performs the triplet function, which reads two bits and writes a bit. The bit written is determined by the two reads: 00 => dbit, 01 => 0, 10 => 1 */ static u8 ds2482_w1_triplet(void *data, u8 dbit)
{ struct ds2482_w1_chan *pchan = data; struct ds2482_data *pdev = pchan->pdev; int status = (3 << 5); mutex_lock(&pdev->access_lock); ds2482_wait_1wire_idle(pdev); if (pdev->w1_count > 1) ds2482_set_channel(pdev, pchan->channel); if (!ds2482_send_cmd_data(pdev, DS2482_CMD_1WIRE_TRIPLET, dbit ? 0xFF : 0)) status = ds2482_wait_1wire_idle(pdev); mutex_unlock(&pdev->access_lock); return (status >> 5); }
robutest/uclinux
C++
GPL-2.0
60
/* Get flash total page count for the specified bank. */
uint32_t flash_get_page_count(const uint32_t *pul_flash_descriptor)
/* Get flash total page count for the specified bank. */ uint32_t flash_get_page_count(const uint32_t *pul_flash_descriptor)
{ return (pul_flash_descriptor[1] / pul_flash_descriptor[2]); }
remotemcu/remcu-chip-sdks
C++
null
436
/* Some versions of Open Firmware incorrectly initialize the IRQ settings for keyboard and mouse */
static void __init sio_write(u8 val, u8 index)
/* Some versions of Open Firmware incorrectly initialize the IRQ settings for keyboard and mouse */ static void __init sio_write(u8 val, u8 index)
{ outb(index, 0x15c); outb(val, 0x15d); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Read current date/time or alarm date/time from RTC setting. The */
void RTCTimeRead(tTime *tTime, unsigned long ulTimeAlarm)
/* Read current date/time or alarm date/time from RTC setting. The */ void RTCTimeRead(tTime *tTime, unsigned long ulTimeAlarm)
{ unsigned long ulTemp; xASSERT((ulTimeAlarm == RTC_TIME_CURRENT) || (ulTimeAlarm == RTC_TIME_ALARM)); if(ulTimeAlarm == RTC_TIME_CURRENT) { ulTemp = xHWREG(RTC_CNT); ulTemp += SysCtlBackupRegRead(0); xRTCConvertCounterToTime((xtTime *)tTime, ulTemp); } else { ulTemp = xHWREG(RTC_CMP); ulTemp += SysCtlBackupRegRead(1); xRTCConvertCounterToTime((xtTime *)tTime, ulTemp); } }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* This function will allocate an usb device instance from system. */
uinst_t rt_usbh_alloc_instance(uhcd_t uhcd)
/* This function will allocate an usb device instance from system. */ uinst_t rt_usbh_alloc_instance(uhcd_t uhcd)
{ int i; rt_enter_critical(); for(i=0; i<USB_MAX_DEVICE; i++) { if(dev[i].status != DEV_STATUS_IDLE) continue; rt_memset(&dev[i], 0, sizeof(struct uinstance)); dev[i].status = DEV_STATUS_BUSY; dev[i].index = i + 1; dev[i].address = 0; dev[i].max_packet_size = 0x8; rt_list_init(&dev[i].pipe); dev[i].hcd = uhcd; rt_exit_critical(); return &dev[i]; } rt_exit_critical(); return RT_NULL; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Converts an utf8 string into an ucs4 string. */
enum CRStatus cr_utils_utf8_str_to_ucs4(const guchar *a_in, gulong *a_in_len, guint32 **a_out, gulong *a_out_len)
/* Converts an utf8 string into an ucs4 string. */ enum CRStatus cr_utils_utf8_str_to_ucs4(const guchar *a_in, gulong *a_in_len, guint32 **a_out, gulong *a_out_len)
{ enum CRStatus status = CR_OK; g_return_val_if_fail (a_in && a_in_len && a_out && a_out_len, CR_BAD_PARAM_ERROR); status = cr_utils_utf8_str_len_as_ucs4 (a_in, &a_in[*a_in_len - 1], a_out_len); g_return_val_if_fail (status == CR_OK, status); *a_out = g_malloc0 (*a_out_len * sizeof (guint32)); status = cr_utils_utf8_to_ucs4 (a_in, a_in_len, *a_out, a_out_len); return status; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* qdict_destroy_obj(): Free all the memory allocated by a QDict */
static void qdict_destroy_obj(QObject *obj)
/* qdict_destroy_obj(): Free all the memory allocated by a QDict */ static void qdict_destroy_obj(QObject *obj)
{ int i; QDict *qdict; assert(obj != NULL); qdict = qobject_to_qdict(obj); for (i = 0; i < QDICT_BUCKET_MAX; i++) { QDictEntry *entry = QLIST_FIRST(&qdict->table[i]); while (entry) { QDictEntry *tmp = QLIST_NEXT(entry, next); QLIST_REMOVE(entry, next); qentry_destroy(entry); entry = tmp; } } g_free(qdict); }
ve3wwg/teensy3_qemu
C++
Other
15
/* Configure the root GUI window. Configures the root window background to blank white. */
static void setup_gui_root_window(void)
/* Configure the root GUI window. Configures the root window background to blank white. */ static void setup_gui_root_window(void)
{ struct win_attributes root_attr; struct win_window *win_root; win_root = win_get_root(); root_attr = *win_get_attributes(win_root); root_attr.background = &win_root_background; win_set_attributes(win_root, &root_attr, WIN_ATTR_BACKGROUND); win_show(win_root); }
remotemcu/remcu-chip-sdks
C++
null
436
/* Return the size of the header in 32 bit words. */
u32 ipath_make_grh(struct ipath_ibdev *dev, struct ib_grh *hdr, struct ib_global_route *grh, u32 hwords, u32 nwords)
/* Return the size of the header in 32 bit words. */ u32 ipath_make_grh(struct ipath_ibdev *dev, struct ib_grh *hdr, struct ib_global_route *grh, u32 hwords, u32 nwords)
{ hdr->version_tclass_flow = cpu_to_be32((6 << 28) | (grh->traffic_class << 20) | grh->flow_label); hdr->paylen = cpu_to_be16((hwords - 2 + nwords + SIZE_OF_CRC) << 2); hdr->next_hdr = 0x1B; hdr->hop_limit = grh->hop_limit; hdr->sgid.global.subnet_prefix = dev->gid_prefix; hdr->sgid.global.interface_id = dev->dd->ipath_guid; hdr->dgid = grh->dgid; return sizeof(struct ib_grh) / sizeof(u32); }
robutest/uclinux
C++
GPL-2.0
60
/* Invoke initialization function in Mipi Sys-T module to initialize Mipi Sys-T handle. */
RETURN_STATUS EFIAPI InitMipiSystHandle(IN OUT VOID *MipiSystHandle)
/* Invoke initialization function in Mipi Sys-T module to initialize Mipi Sys-T handle. */ RETURN_STATUS EFIAPI InitMipiSystHandle(IN OUT VOID *MipiSystHandle)
{ MIPI_SYST_HANDLE *MipiSystH; MipiSystH = (MIPI_SYST_HANDLE *)MipiSystHandle; if (MipiSystH == NULL) { return RETURN_INVALID_PARAMETER; } mipi_syst_init (MipiSystH->systh_header, 0, NULL); return RETURN_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Free the directory structure and release the memory. */
STATIC VOID FatFreeODir(IN FAT_ODIR *ODir)
/* Free the directory structure and release the memory. */ STATIC VOID FatFreeODir(IN FAT_ODIR *ODir)
{ FAT_DIRENT *DirEnt; while (!IsListEmpty (&ODir->ChildList)) { DirEnt = DIRENT_FROM_LINK (ODir->ChildList.ForwardLink); RemoveEntryList (&DirEnt->Link); ASSERT (DirEnt->OFile == NULL); FatFreeDirEnt (DirEnt); } FreePool (ODir); }
tianocore/edk2
C++
Other
4,240
/* Get the number of cells for a given property */
STATIC INT32 GetNumCells(IN VOID *Fdt, IN INT32 Node, IN CONST CHAR8 *Name)
/* Get the number of cells for a given property */ STATIC INT32 GetNumCells(IN VOID *Fdt, IN INT32 Node, IN CONST CHAR8 *Name)
{ CONST INT32 *Prop; INT32 Len; UINT32 Val; Prop = fdt_getprop (Fdt, Node, Name, &Len); if (Prop == NULL) { return Len; } if (Len != sizeof (*Prop)) { return -FDT_ERR_BADNCELLS; } Val = fdt32_to_cpu (*Prop); if (Val > FDT_MAX_NCELLS) { return -FDT_ERR_BADNCELLS; } return (INT32)Val; }
tianocore/edk2
C++
Other
4,240
/* Stop any current commands to the EEPROM and clear the EEPROM request bit. */
void igb_release_nvm(struct e1000_hw *hw)
/* Stop any current commands to the EEPROM and clear the EEPROM request bit. */ void igb_release_nvm(struct e1000_hw *hw)
{ u32 eecd; e1000_stop_nvm(hw); eecd = rd32(E1000_EECD); eecd &= ~E1000_EECD_REQ; wr32(E1000_EECD, eecd); }
robutest/uclinux
C++
GPL-2.0
60
/* Reads an unsigned 8 bit value over I2C. */
err_t l3gd20Read8(uint8_t reg, uint8_t *value)
/* Reads an unsigned 8 bit value over I2C. */ err_t l3gd20Read8(uint8_t reg, uint8_t *value)
{ I2CWriteLength = 2; I2CReadLength = 0; I2CMasterBuffer[0] = L3GD20_ADDRESS; I2CMasterBuffer[1] = reg; i2cEngine(); I2CWriteLength = 0; I2CReadLength = 1; I2CMasterBuffer[0] = L3GD20_ADDRESS | L3GD20_READBIT; ASSERT_I2C_STATUS(i2cEngine()); *value = I2CSlaveBuffer[0]; return ERROR_NONE; }
microbuilder/LPC11U_LPC13U_CodeBase
C++
Other
54
/* Returns CR_OK upon successful completion, an error code otherwise. */
enum CRStatus cr_statement_at_charset_rule_get_charset(CRStatement *a_this, CRString **a_charset)
/* Returns CR_OK upon successful completion, an error code otherwise. */ enum CRStatus cr_statement_at_charset_rule_get_charset(CRStatement *a_this, CRString **a_charset)
{ g_return_val_if_fail (a_this && a_this->type == AT_CHARSET_RULE_STMT && a_this->kind.charset_rule, CR_BAD_PARAM_ERROR); *a_charset = a_this->kind.charset_rule->charset; return CR_OK; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Assert the nRTS pin, transmit the message and deassert nRTS pin. */
int32_t ad5700_transmit(struct ad5700_dev *dev, uint8_t *data, uint32_t size)
/* Assert the nRTS pin, transmit the message and deassert nRTS pin. */ int32_t ad5700_transmit(struct ad5700_dev *dev, uint8_t *data, uint32_t size)
{ int32_t ret; ret = gpio_set_value(dev->gpio_nrts, GPIO_LOW); if(ret < 0) return ret; mdelay(6); ret = swuart_write_string(dev->swuart_desc, data, size); if(ret < 0) return ret; mdelay(6); return gpio_set_value(dev->gpio_nrts, GPIO_HIGH); }
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* XXX Keep a usecount in the clockdomain code */
int omap_hwmod_del_initiator_dep(struct omap_hwmod *oh, struct omap_hwmod *init_oh)
/* XXX Keep a usecount in the clockdomain code */ int omap_hwmod_del_initiator_dep(struct omap_hwmod *oh, struct omap_hwmod *init_oh)
{ return _del_initiator_dep(oh, init_oh); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* void rtl8192_restart(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); */
void rtl8192_restart(struct work_struct *work)
/* void rtl8192_restart(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); */ void rtl8192_restart(struct work_struct *work)
{ struct r8192_priv *priv = container_of(work, struct r8192_priv, reset_wq); struct net_device *dev = priv->ieee80211->dev; down(&priv->wx_sem); rtl8192_commit(dev); up(&priv->wx_sem); }
robutest/uclinux
C++
GPL-2.0
60
/* USB Device Reset Function Called automatically on USB Device Reset Return Value: None */
void USBD_Reset(void)
/* USB Device Reset Function Called automatically on USB Device Reset Return Value: None */ void USBD_Reset(void)
{ uint32_t i; for (i = 0; i < HSUSBD_MAX_EP; i++) { HSUSBD->EP[EPA + i].EPRSPCTL = HSUSBD_EPRSPCTL_FLUSH_Msk; } if (HSUSBD->OPER & HSUSBD_OPER_CURSPD_Msk) { USBD_HighSpeed = __TRUE; } else { USBD_HighSpeed = __FALSE; } g_u32FreeBufAddr = CEP_BUF_BASE + CEP_BUF_LEN; g_u8StatusIn = 0; HSUSBD_SET_ADDR(0); }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* Clear All Status Flags. Program error, end of operation, write protect error, busy. Both banks cleared. */
void flash_clear_status_flags(void)
/* Clear All Status Flags. Program error, end of operation, write protect error, busy. Both banks cleared. */ void flash_clear_status_flags(void)
{ flash_clear_pgerr_flag(); flash_clear_eop_flag(); flash_clear_wrprterr_flag(); flash_clear_bsy_flag(); if (DESIG_FLASH_SIZE > 512) { flash_clear_pgerr_flag_upper(); flash_clear_eop_flag_upper(); flash_clear_wrprterr_flag_upper(); flash_clear_bsy_flag_upper(); } }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* Retrieve the amount of cycles to delay for the given amount of ms. */
uint32_t _get_cycles_for_ms(const uint16_t ms)
/* Retrieve the amount of cycles to delay for the given amount of ms. */ uint32_t _get_cycles_for_ms(const uint16_t ms)
{ return _get_cycles_for_ms_internal(ms, CONF_CPU_FREQUENCY, CPU_FREQ_POWER); }
eclipse-threadx/getting-started
C++
Other
310
/* Note that in contrast to strncpy(), strncat() ensures the result is terminated. */
char* strncat(char *dest, const char *src, size_t count)
/* Note that in contrast to strncpy(), strncat() ensures the result is terminated. */ char* strncat(char *dest, const char *src, size_t count)
{ char *tmp = dest; if (count) { while (*dest) dest++; while ((*dest++ = *src++) != 0) { if (--count == 0) { *dest = '\0'; break; } } } return tmp; }
robutest/uclinux
C++
GPL-2.0
60
/* IDL long NetrServerAuthenticate2( IDL wchar_t *logonserver, IDL wchar_t *username, IDL short secure_channel_type, IDL wchar_t *computername, IDL CREDENTIAL *client_chal, IDL CREDENTIAL *server_chal, IDL long *negotiate_flags, IDL ); */
static int netlogon_dissect_netrserverauthenticate2_rqst(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep)
/* IDL long NetrServerAuthenticate2( IDL wchar_t *logonserver, IDL wchar_t *username, IDL short secure_channel_type, IDL wchar_t *computername, IDL CREDENTIAL *client_chal, IDL CREDENTIAL *server_chal, IDL long *negotiate_flags, IDL ); */ static int netlogon_dissect_netrserverauthenticate2_rqst(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep)
{ return netlogon_dissect_netrserverauthenticate3_rqst(tvb,offset,pinfo,tree,di,drep); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Helper function for getting channel number directly from the feature unit descriptor. */
static uint8_t get_num_of_channels(const struct feature_unit_descriptor *fu)
/* Helper function for getting channel number directly from the feature unit descriptor. */ static uint8_t get_num_of_channels(const struct feature_unit_descriptor *fu)
{ return (fu->bLength - FU_FIXED_ELEMS_SIZE)/sizeof(uint16_t); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* RETURNS: 0 for successful copy to inline area; -1 if area not available */
static int ea_write_inline(struct inode *ip, struct jfs_ea_list *ealist, int size, dxd_t *ea)
/* RETURNS: 0 for successful copy to inline area; -1 if area not available */ static int ea_write_inline(struct inode *ip, struct jfs_ea_list *ealist, int size, dxd_t *ea)
{ struct jfs_inode_info *ji = JFS_IP(ip); if (ealist && size > sizeof (struct jfs_ea_list)) { assert(size <= sizeof (ji->i_inline_ea)); if (!(ji->mode2 & INLINEEA) && !(ji->ea.flag & DXD_INLINE)) return -EPERM; DXDsize(ea, size); DXDlength(ea, 0); DXDaddress(ea, 0); memcpy(ji->i_inline_ea, ealist, size); ea->flag = DXD_INLINE; ji->mode2 &= ~INLINEEA; } else { ea->flag = 0; DXDsize(ea, 0); DXDlength(ea, 0); DXDaddress(ea, 0); if (ji->ea.flag & DXD_INLINE) ji->mode2 |= INLINEEA; } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* ISR handler for a specific vector index in the interrupt vector table for linking the actual interrupts vectors to the one in the user program's vector table. */
void Vector38_handler(void)
/* ISR handler for a specific vector index in the interrupt vector table for linking the actual interrupts vectors to the one in the user program's vector table. */ void Vector38_handler(void)
{ asm { LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (38 * 2)) JMP 0,X } }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Specify TTL for outgoing multicasts on a sending socket */
static void set_mcast_ttl(struct sock *sk, u_char ttl)
/* Specify TTL for outgoing multicasts on a sending socket */ static void set_mcast_ttl(struct sock *sk, u_char ttl)
{ struct inet_sock *inet = inet_sk(sk); lock_sock(sk); inet->mc_ttl = ttl; release_sock(sk); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Cause a processor trigger for a sample sequence. */
void ADCProcessorTrigger(unsigned long ulBase)
/* Cause a processor trigger for a sample sequence. */ void ADCProcessorTrigger(unsigned long ulBase)
{ xASSERT(ulBase == ADC_BASE); xHWREG(ulBase + ADC_CR) |= ADC_CR_ADST; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Returns CR_OK upon successful completion, an error code otherwise */
enum CRStatus cr_om_parser_simply_parse_paths_to_cascade(const guchar *a_author_path, const guchar *a_user_path, const guchar *a_ua_path, enum CREncoding a_encoding, CRCascade **a_result)
/* Returns CR_OK upon successful completion, an error code otherwise */ enum CRStatus cr_om_parser_simply_parse_paths_to_cascade(const guchar *a_author_path, const guchar *a_user_path, const guchar *a_ua_path, enum CREncoding a_encoding, CRCascade **a_result)
{ enum CRStatus status = CR_OK; CROMParser *parser = NULL; parser = cr_om_parser_new (NULL); if (!parser) { cr_utils_trace_info ("could not allocated om parser"); cr_utils_trace_info ("System may be out of memory"); return CR_ERROR; } status = cr_om_parser_parse_paths_to_cascade (parser, a_author_path, a_user_path, a_ua_path, a_encoding, a_result); if (parser) { cr_om_parser_destroy (parser); parser = NULL; } return status; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* List of board exceptions with correctly wired IRQs */
static int an_exception(struct de4x5_private *lp)
/* List of board exceptions with correctly wired IRQs */ static int an_exception(struct de4x5_private *lp)
{ if ((*(u_short *)lp->srom.sub_vendor_id == 0x00c0) && (*(u_short *)lp->srom.sub_system_id == 0x95e0)) { return -1; } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* In case of error the return value is an error pointer. */
void* crypto_alloc_tfm(const char *alg_name, const struct crypto_type *frontend, u32 type, u32 mask)
/* In case of error the return value is an error pointer. */ void* crypto_alloc_tfm(const char *alg_name, const struct crypto_type *frontend, u32 type, u32 mask)
{ void *tfm; int err; for (;;) { struct crypto_alg *alg; alg = crypto_find_alg(alg_name, frontend, type, mask); if (IS_ERR(alg)) { err = PTR_ERR(alg); goto err; } tfm = crypto_create_tfm(alg, frontend); if (!IS_ERR(tfm)) return tfm; crypto_mod_put(alg); err = PTR_ERR(tfm); err: if (err != -EAGAIN) break; if (signal_pending(current)) { err = -EINTR; break; } } return ERR_PTR(err); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Created on: 16 feb. 2019 Author: Daniel Mårtensson Find the rank of matrix A, size row x column, where row == column */
int rank(double *A, int row)
/* Created on: 16 feb. 2019 Author: Daniel Mårtensson Find the rank of matrix A, size row x column, where row == column */ int rank(double *A, int row)
{ return row; }else return -1; }
DanielMartensson/EmbeddedLapack
C++
MIT License
129
/* Do the one-time initialization of the Nokia LCD hardware. Specifically: Set up platform specific GPIO for control of the Nokia LCD. */
static void nokia6100fb_init(struct nokia6100fb_par *p)
/* Do the one-time initialization of the Nokia LCD hardware. Specifically: Set up platform specific GPIO for control of the Nokia LCD. */ static void nokia6100fb_init(struct nokia6100fb_par *p)
{ int r = p->reset; int b = r < 16 ? 25 : 0; int d = r < 16 ? r : r - 16; writel(0x14, &MSS_IOMUX->cr[b + d]); writel(0x5, &MSS_GPIO->cfg[r]); d_printk(2, "r=%d\n", r); }
robutest/uclinux
C++
GPL-2.0
60
/* Parse the binary flags from a hash table entry into the varaccess enum. */
enum env_flags_varaccess env_flags_parse_varaccess_from_binflags(int binflags)
/* Parse the binary flags from a hash table entry into the varaccess enum. */ enum env_flags_varaccess env_flags_parse_varaccess_from_binflags(int binflags)
{ int i; for (i = 0; i < ARRAY_SIZE(env_flags_varaccess_mask); i++) if (env_flags_varaccess_mask[i] == (binflags & ENV_FLAGS_VARACCESS_BIN_MASK)) return (enum env_flags_varaccess)i; printf("Warning: Non-standard access flags. (0x%x)\n", binflags & ENV_FLAGS_VARACCESS_BIN_MASK); return env_flags_varaccess_any; }
4ms/stm32mp1-baremetal
C++
Other
137
/* See is_module_text_address() if you simply want to see if the address is code (not data). */
bool is_module_address(unsigned long addr)
/* See is_module_text_address() if you simply want to see if the address is code (not data). */ bool is_module_address(unsigned long addr)
{ bool ret; preempt_disable(); ret = __module_address(addr) != NULL; preempt_enable(); return ret; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* orc_exec_sb - Queue an SCB with the HA @host: host adapter the SCB belongs to @scb: SCB to queue for execution */
static void orc_exec_scb(struct orc_host *host, struct orc_scb *scb)
/* orc_exec_sb - Queue an SCB with the HA @host: host adapter the SCB belongs to @scb: SCB to queue for execution */ static void orc_exec_scb(struct orc_host *host, struct orc_scb *scb)
{ scb->status = ORCSCB_POST; outb(scb->scbidx, host->base + ORC_PQUEUE); }
robutest/uclinux
C++
GPL-2.0
60
/* When a context switch is performed from the task level the saved task context is made to look as if it occurred from within the tick ISR. This way the same restore context function can be used when restoring the context saved from the ISR or that saved from a call to vPortYieldProcessor. */
void vPortYieldProcessor(void)
/* When a context switch is performed from the task level the saved task context is made to look as if it occurred from within the tick ISR. This way the same restore context function can be used when restoring the context saved from the ISR or that saved from a call to vPortYieldProcessor. */ void vPortYieldProcessor(void)
{ __asm volatile ( "ADD LR, LR, #4" ); portSAVE_CONTEXT(); __asm volatile ( "bl vTaskSwitchContext" ); portRESTORE_CONTEXT(); }
labapart/polymcu
C++
null
201
/* Read filter and post-filter options from the device. */
static int32_t ad7124_8pmdz_flt_logic_get(struct ad7124_8pmdz_dev *dev, int8_t *flt_opt, int8_t *post_flt_opt)
/* Read filter and post-filter options from the device. */ static int32_t ad7124_8pmdz_flt_logic_get(struct ad7124_8pmdz_dev *dev, int8_t *flt_opt, int8_t *post_flt_opt)
{ struct ad7124_st_reg *reg_map; int32_t ret; reg_map = dev->ad7124_handler->regs; ret = ad7124_read_register(dev->ad7124_handler, &reg_map[AD7124_Filter_0]); if (ret != SUCCESS) return FAILURE; *flt_opt = (reg_map[AD7124_Filter_0].value & AD7124_FILT_REG_FILTER(7)) >> 21; *post_flt_opt = (reg_map[AD7124_Filter_0].value & AD7124_FILT_REG_POST_FILTER(7)) >> 17; return SUCCESS; }
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* Function used by tinflate_partial to write a byte to an address in the output buffer here it is implemented to directly write to the object memory of the d11 core */
void tinflate_write_objmemx(void *out_base, unsigned long idx, unsigned char value)
/* Function used by tinflate_partial to write a byte to an address in the output buffer here it is implemented to directly write to the object memory of the d11 core */ void tinflate_write_objmemx(void *out_base, unsigned long idx, unsigned char value)
{ wlc_bmac_write_objmem_byte((struct wlc_hw_info *) out_base, idx, value, OBJADDR_UCMX_SEL); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Run handler function in the netif thread context and wait for function return. */
void os_hook_dispatch_wait(wifi_task_cb handler, struct params_dispatch *p, void *pv)
/* Run handler function in the netif thread context and wait for function return. */ void os_hook_dispatch_wait(wifi_task_cb handler, struct params_dispatch *p, void *pv)
{ hif_msg_t msg; if (hif_thread == xTaskGetCurrentTaskHandle()) { p->signal_semaphore = 0; handler(pv); } else { p->signal_semaphore = 1; msg.id = MSG_CMD; msg.handler = handler; msg.priv = pv; xQueueSend(hif_queue, (void *)&msg, portMAX_DELAY); xSemaphoreTake(hif_notify_sem, portMAX_DELAY); } }
remotemcu/remcu-chip-sdks
C++
null
436
/* Enables forwarding of control frames. When set forwards all the control frames (incl. unicast and multicast PAUSE frames). */
void synopGMAC_set_pass_control(synopGMACdevice *gmacdev, u32 passcontrol)
/* Enables forwarding of control frames. When set forwards all the control frames (incl. unicast and multicast PAUSE frames). */ void synopGMAC_set_pass_control(synopGMACdevice *gmacdev, u32 passcontrol)
{ u32 data; data = synopGMACReadReg(gmacdev->MacBase, GmacFrameFilter); data &= (~GmacPassControl); data |= passcontrol; synopGMACWriteReg(gmacdev->MacBase, GmacFrameFilter, data); return; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Allocate a new extent_map structure. The new structure is returned with a reference count of one and needs to be freed using free_extent_map() */
struct extent_map* alloc_extent_map(gfp_t mask)
/* Allocate a new extent_map structure. The new structure is returned with a reference count of one and needs to be freed using free_extent_map() */ struct extent_map* alloc_extent_map(gfp_t mask)
{ struct extent_map *em; em = kmem_cache_alloc(extent_map_cache, mask); if (!em || IS_ERR(em)) return em; em->in_tree = 0; em->flags = 0; atomic_set(&em->refs, 1); return em; }
robutest/uclinux
C++
GPL-2.0
60
/* step3 of enumeration - wait a USB reset */
static void main_usb_enum_step3(void)
/* step3 of enumeration - wait a USB reset */ static void main_usb_enum_step3(void)
{ main_usb_wait_end_of_reset(); }
remotemcu/remcu-chip-sdks
C++
null
436
/* NOTE: this will only disable the regulator output if no other consumer devices have it enabled, the regulator device supports disabling and machine constraints permit this operation. */
int regulator_disable(struct regulator *regulator)
/* NOTE: this will only disable the regulator output if no other consumer devices have it enabled, the regulator device supports disabling and machine constraints permit this operation. */ int regulator_disable(struct regulator *regulator)
{ struct regulator_dev *rdev = regulator->rdev; int ret = 0; mutex_lock(&rdev->mutex); ret = _regulator_disable(rdev); mutex_unlock(&rdev->mutex); return ret; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Turn on reporting of profiling data load/unload-events through the gcov_event() callback. Also replay all previous events once. This function is needed because some events are potentially generated too early for the callback implementation to handle them initially. */
void gcov_enable_events(void)
/* Turn on reporting of profiling data load/unload-events through the gcov_event() callback. Also replay all previous events once. This function is needed because some events are potentially generated too early for the callback implementation to handle them initially. */ void gcov_enable_events(void)
{ struct gcov_info *info; mutex_lock(&gcov_lock); gcov_events_enabled = 1; for (info = gcov_info_head; info; info = info->next) gcov_event(GCOV_ADD, info); mutex_unlock(&gcov_lock); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Reads the MMIO registers specified by Address with registers width specified by Width. The read value is returned. If such operations are not supported, then ASSERT(). This function must guarantee that all MMIO read and write operations are serialized. */
UINT64 EFIAPI MmioReadWorker(IN UINTN Address, IN EFI_CPU_IO_PROTOCOL_WIDTH Width)
/* Reads the MMIO registers specified by Address with registers width specified by Width. The read value is returned. If such operations are not supported, then ASSERT(). This function must guarantee that all MMIO read and write operations are serialized. */ UINT64 EFIAPI MmioReadWorker(IN UINTN Address, IN EFI_CPU_IO_PROTOCOL_WIDTH Width)
{ EFI_STATUS Status; UINT64 Data; Status = mCpuIo->Mem.Read (mCpuIo, Width, Address, 1, &Data); ASSERT_EFI_ERROR (Status); return Data; }
tianocore/edk2
C++
Other
4,240
/* Checks the slave response to master's start signal. */
static status_t I2C_MasterCheckStartResponse(I2C_Type *base)
/* Checks the slave response to master's start signal. */ static status_t I2C_MasterCheckStartResponse(I2C_Type *base)
{ status_t result = I2C_PendingStatusWait(base); if (result != kStatus_Success) { return result; } if (((base->STAT & I2C_STAT_MSTSTATE_MASK) >> I2C_STAT_MSTSTATE_SHIFT) == I2C_STAT_MSTCODE_NACKADR) { (void)I2C_MasterStop(base); return kStatus_I2C_Addr_Nak; } return kStatus_Success; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Get the current normalized channelValue for a channel. */
uint32_t CAPLESENSE_getNormalizedVal(uint8_t channel)
/* Get the current normalized channelValue for a channel. */ uint32_t CAPLESENSE_getNormalizedVal(uint8_t channel)
{ uint32_t max = channelMaxValues[channel]; return (channelValues[channel] << 8) / max; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Changing the baud clock source changes the data rate generated by the SSI. Therefore, the data rate should be reconfigured after any change to the SSI clock source. */
void SSIClockSourceSet(unsigned long ulBase, unsigned long ulSource)
/* Changing the baud clock source changes the data rate generated by the SSI. Therefore, the data rate should be reconfigured after any change to the SSI clock source. */ void SSIClockSourceSet(unsigned long ulBase, unsigned long ulSource)
{ ASSERT(SSIBaseValid(ulBase)); ASSERT((ulSource == SSI_CLOCK_SYSTEM) || (ulSource == SSI_CLOCK_PIOSC)); HWREG(ulBase + SSI_O_CC) = ulSource; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Fills each init_struct member with its default value. */
void TIM_TimeBaseStructInit(TIM_TimeBaseInitTypeDef *init_struct)
/* Fills each init_struct member with its default value. */ void TIM_TimeBaseStructInit(TIM_TimeBaseInitTypeDef *init_struct)
{ init_struct->TIM_Period = 0xFFFFFFFF; init_struct->TIM_Prescaler = 0x0000; init_struct->TIM_ClockDivision = TIM_CKD_DIV1; init_struct->TIM_CounterMode = TIM_CounterMode_Up; init_struct->TIM_RepetitionCounter = 0x00; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Deinitializes the ADCx peripheral registers to their default reset values. */
void ADC_DeInit(ADC_Module *ADCx)
/* Deinitializes the ADCx peripheral registers to their default reset values. */ void ADC_DeInit(ADC_Module *ADCx)
{ assert_param(IsAdcModule(ADCx)); if (ADCx == ADC) { RCC_EnableAHBPeriphReset(RCC_AHB_PERIPH_ADC, ENABLE); RCC_EnableAHBPeriphReset(RCC_AHB_PERIPH_ADC, DISABLE); } }
pikasTech/PikaPython
C++
MIT License
1,403
/* Write to DS4510, taking page boundaries into account */
int ds4510_mem_write(uint8_t chip, int offset, uint8_t *buf, int count)
/* Write to DS4510, taking page boundaries into account */ int ds4510_mem_write(uint8_t chip, int offset, uint8_t *buf, int count)
{ int wrlen; int i = 0; do { wrlen = DS4510_EEPROM_PAGE_SIZE - DS4510_EEPROM_PAGE_OFFSET(offset); if (count < wrlen) wrlen = count; if (i2c_write(chip, offset, 1, &buf[i], wrlen)) return -1; udelay(DS4510_EEPROM_PAGE_WRITE_DELAY_MS * 1000); count -= wrlen; offset += wrlen; i += wrlen; } while (count > 0); return 0; }
EmcraftSystems/u-boot
C++
Other
181
/* This PDC function returns the number of entries in the specified cell's interrupt table. Similar to PDC_PAT stuff - but added for Forte/Allegro boxes */
int pdc_pci_irt_size(unsigned long *num_entries, unsigned long hpa)
/* This PDC function returns the number of entries in the specified cell's interrupt table. Similar to PDC_PAT stuff - but added for Forte/Allegro boxes */ int pdc_pci_irt_size(unsigned long *num_entries, unsigned long hpa)
{ int retval; unsigned long flags; spin_lock_irqsave(&pdc_lock, flags); retval = mem_pdc_call(PDC_PCI_INDEX, PDC_PCI_GET_INT_TBL_SIZE, __pa(pdc_result), hpa); convert_to_wide(pdc_result); *num_entries = pdc_result[0]; spin_unlock_irqrestore(&pdc_lock, flags); return retval; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Evaluates the convolution of a vector with a sparse vector. */
static void convolute_with_sparse(float *out, const AMRFixed *pulses, const float *shape, int length)
/* Evaluates the convolution of a vector with a sparse vector. */ static void convolute_with_sparse(float *out, const AMRFixed *pulses, const float *shape, int length)
{ int i, j; memset(out, 0, length*sizeof(float)); for (i = 0; i < pulses->n; i++) for (j = pulses->x[i]; j < length; j++) out[j] += pulses->y[i] * shape[j - pulses->x[i]]; }
DC-SWAT/DreamShell
C++
null
404
/* Function: void queue_free (Queue_t *queue) Purpose : free a queue Params : queue - queue to free */
void queue_free(Queue_t *queue)
/* Function: void queue_free (Queue_t *queue) Purpose : free a queue Params : queue - queue to free */ void queue_free(Queue_t *queue)
{ if (!list_empty(&queue->head)) printk(KERN_WARNING "freeing non-empty queue %p\n", queue); kfree(queue->alloc); }
robutest/uclinux
C++
GPL-2.0
60
/* Used by a driver to check whether a DIO device present in the system is in its list of supported devices. Returns the matching dio_device_id structure or NULL if there is no match. */
static int dio_bus_match(struct device *dev, struct device_driver *drv)
/* Used by a driver to check whether a DIO device present in the system is in its list of supported devices. Returns the matching dio_device_id structure or NULL if there is no match. */ static int dio_bus_match(struct device *dev, struct device_driver *drv)
{ struct dio_dev *d = to_dio_dev(dev); struct dio_driver *dio_drv = to_dio_driver(drv); const struct dio_device_id *ids = dio_drv->id_table; if (!ids) return 0; return dio_match_device(ids, d) ? 1 : 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Check if the supplied point is on EC curve. */
BOOLEAN EFIAPI CryptoServiceEcPointIsOnCurve(IN CONST VOID *EcGroup, IN CONST VOID *EcPoint, IN VOID *BnCtx)
/* Check if the supplied point is on EC curve. */ BOOLEAN EFIAPI CryptoServiceEcPointIsOnCurve(IN CONST VOID *EcGroup, IN CONST VOID *EcPoint, IN VOID *BnCtx)
{ return CALL_BASECRYPTLIB (Ec.Services.PointIsOnCurve, EcPointIsOnCurve, (EcGroup, EcPoint, BnCtx), FALSE); }
tianocore/edk2
C++
Other
4,240
/* add option to url of the form: " */
static void url_add_option(char *buf, int buf_size, const char *fmt,...)
/* add option to url of the form: " */ static void url_add_option(char *buf, int buf_size, const char *fmt,...)
{ char buf1[1024]; va_list ap; va_start(ap, fmt); if (strchr(buf, '?')) av_strlcat(buf, "&", buf_size); else av_strlcat(buf, "?", buf_size); vsnprintf(buf1, sizeof(buf1), fmt, ap); av_strlcat(buf, buf1, buf_size); va_end(ap); }
DC-SWAT/DreamShell
C++
null
404
/* Return the CDC ACM line coding structure start address. */
const struct usb_cdc_line_coding* cdcdf_acm_get_line_coding(void)
/* Return the CDC ACM line coding structure start address. */ const struct usb_cdc_line_coding* cdcdf_acm_get_line_coding(void)
{ return (const struct usb_cdc_line_coding *)&usbd_cdc_line_coding; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Receive a piece of data for SPI master. This function computes the number of data to receive from D register or Rx FIFO, and write the data to destination address. At the same time, this function updates the values in master handle structure. */
static void SPI_ReceiveTransfer(SPI_Type *base, spi_master_handle_t *handle)
/* Receive a piece of data for SPI master. This function computes the number of data to receive from D register or Rx FIFO, and write the data to destination address. At the same time, this function updates the values in master handle structure. */ static void SPI_ReceiveTransfer(SPI_Type *base, spi_master_handle_t *handle)
{ uint8_t bytes = MIN((handle->watermark * 2U), handle->rxRemainingBytes); uint8_t val = 1U; if (handle->watermark == 1U) { val = base->S & SPI_S_SPRF_MASK; if (bytes != 0U) { bytes = handle->bytePerFrame; } } if (val) { SPI_ReadNonBlocking(base, handle->rxData, bytes); if (handle->rxData) { handle->rxData += bytes; } handle->rxRemainingBytes -= bytes; } }
labapart/polymcu
C++
null
201
/* Handling of Extents both in catalog and extents overflow trees */
int hfsplus_ext_cmp_key(const hfsplus_btree_key *k1, const hfsplus_btree_key *k2)
/* Handling of Extents both in catalog and extents overflow trees */ int hfsplus_ext_cmp_key(const hfsplus_btree_key *k1, const hfsplus_btree_key *k2)
{ __be32 k1id, k2id; __be32 k1s, k2s; k1id = k1->ext.cnid; k2id = k2->ext.cnid; if (k1id != k2id) return be32_to_cpu(k1id) < be32_to_cpu(k2id) ? -1 : 1; if (k1->ext.fork_type != k2->ext.fork_type) return k1->ext.fork_type < k2->ext.fork_type ? -1 : 1; k1s = k1->ext.start_block; k2s = k2->ext.start_block; if (k1s == k2s) return 0; return be32_to_cpu(k1s) < be32_to_cpu(k2s) ? -1 : 1; }
robutest/uclinux
C++
GPL-2.0
60
/* Notifier chain core routines. The exported routines below are layered on top of these, with appropriate locking added. */
static int notifier_chain_register(struct notifier_block **nl, struct notifier_block *n)
/* Notifier chain core routines. The exported routines below are layered on top of these, with appropriate locking added. */ static int notifier_chain_register(struct notifier_block **nl, struct notifier_block *n)
{ while ((*nl) != NULL) { if (n->priority > (*nl)->priority) break; nl = &((*nl)->next); } n->next = *nl; rcu_assign_pointer(*nl, n); return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Returns the clock source used as LPTIM clock (LPTIMCLK). */
uint32_t RCC_GetLPTIMClkSrc(void)
/* Returns the clock source used as LPTIM clock (LPTIMCLK). */ uint32_t RCC_GetLPTIMClkSrc(void)
{ return ((uint32_t)(RCC->RDCTRL & RDCTRL_LPTIMCLKSEL_MASK)); }
pikasTech/PikaPython
C++
MIT License
1,403
/* Use the PITC in full 32 bit incrementing mode */
int timer_init(void)
/* Use the PITC in full 32 bit incrementing mode */ int timer_init(void)
{ at91_pit_t *pit = (at91_pit_t *)ATMEL_BASE_PIT; at91_periph_clk_enable(ATMEL_ID_PIT); writel(TIMER_LOAD_VAL | AT91_PIT_MR_EN , &pit->mr); gd->arch.timer_rate_hz = get_pit_clk_rate() / 16; return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Clear all the interrutp status bits, these bits are Write-Clean. */
VOID EhcAckAllInterrupt(IN PEI_USB2_HC_DEV *Ehc)
/* Clear all the interrutp status bits, these bits are Write-Clean. */ VOID EhcAckAllInterrupt(IN PEI_USB2_HC_DEV *Ehc)
{ EhcWriteOpReg (Ehc, EHC_USBSTS_OFFSET, USBSTS_INTACK_MASK); }
tianocore/edk2
C++
Other
4,240
/* param handle codec handle. return kStatus_Success is success, else de-initial failed. */
status_t HAL_CODEC_CS42448_Deinit(void *handle)
/* param handle codec handle. return kStatus_Success is success, else de-initial failed. */ status_t HAL_CODEC_CS42448_Deinit(void *handle)
{ assert(handle != NULL); return CS42448_Deinit((cs42448_handle_t *)((uint32_t)(((codec_handle_t *)handle)->codecDevHandle))); }
eclipse-threadx/getting-started
C++
Other
310
/* IDL long NetrBrowserStatisticsGet( IDL wchar_t *element_75, IDL long element_76, IDL TYPE_7 *element_77 IDL ); */
static int dissect_browser_netr_browser_statistics_get_rqst(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep)
/* IDL long NetrBrowserStatisticsGet( IDL wchar_t *element_75, IDL long element_76, IDL TYPE_7 *element_77 IDL ); */ static int dissect_browser_netr_browser_statistics_get_rqst(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep)
{ offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, di, drep, NDR_POINTER_UNIQUE, "unknown string", hf_browser_unknown_string, 0); offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, di, drep, hf_browser_unknown_long, NULL); offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, di, drep, dissect_browser_TYPE_7, NDR_POINTER_REF, "unknown TYPE_7", -1); return offset; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Program a command to ramp the brightness over time. In each step the PWM value is increased or decreased by 1/255th until the maximum or minimum value is reached or step_count steps have been done. */
static int lp5562_program_ramp(const struct device *dev, enum lp5562_led_sources engine, uint8_t command_index, uint32_t time_per_step, uint8_t step_count, enum lp5562_engine_fade_dirs fade_dir)
/* Program a command to ramp the brightness over time. In each step the PWM value is increased or decreased by 1/255th until the maximum or minimum value is reached or step_count steps have been done. */ static int lp5562_program_ramp(const struct device *dev, enum lp5562_led_sources engine, uint8_t command_index, uint32_t time_per_step, uint8_t step_count, enum lp5562_engine_fade_dirs fade_dir)
{ struct lp5562_data *data = dev->data; struct led_data *dev_data = &data->dev_data; uint8_t prescale, step_time; if ((time_per_step < dev_data->min_period) || (time_per_step > dev_data->max_period)) { return -EINVAL; } lp5562_ms_to_prescale_and_step(dev_data, time_per_step, &prescale, &step_time); return lp5562_program_command(dev, engine, command_index, LP5562_PROG_COMMAND_RAMP_TIME(prescale, step_time), LP5562_PROG_COMMAND_STEP_COUNT(fade_dir, step_count)); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Returns the UART hardware flow control mode currently in use. */
uint32_t UARTFlowControlGet(uint32_t ui32Base)
/* Returns the UART hardware flow control mode currently in use. */ uint32_t UARTFlowControlGet(uint32_t ui32Base)
{ ASSERT(_UARTBaseValid(ui32Base)); return(HWREG(ui32Base + UART_O_CTL) & (UART_FLOWCONTROL_TX | UART_FLOWCONTROL_RX)); }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Locking Note: This function expects that the disc mutex is already locked. */
static void fc_disc_restart(struct fc_disc *)
/* Locking Note: This function expects that the disc mutex is already locked. */ static void fc_disc_restart(struct fc_disc *)
{ if (!disc->disc_callback) return; FC_DISC_DBG(disc, "Restarting discovery\n"); disc->requested = 1; if (disc->pending) return; disc->disc_id = (disc->disc_id + 2) | 1; disc->retry_count = 0; fc_disc_gpn_ft_req(disc); }
robutest/uclinux
C++
GPL-2.0
60
/* Add a copy of the resources to the platform device. The memory associated with the resources will be freed when the platform device is released. */
int platform_device_add_resources(struct platform_device *pdev, struct resource *res, unsigned int num)
/* Add a copy of the resources to the platform device. The memory associated with the resources will be freed when the platform device is released. */ int platform_device_add_resources(struct platform_device *pdev, struct resource *res, unsigned int num)
{ struct resource *r; r = kmalloc(sizeof(struct resource) * num, GFP_KERNEL); if (r) { memcpy(r, res, sizeof(struct resource) * num); pdev->resource = r; pdev->num_resources = num; } return r ? 0 : -ENOMEM; }
robutest/uclinux
C++
GPL-2.0
60
/* Send GET_CID command to get CID from card. */
static status_t SD_AllSendCid(sd_card_t *card)
/* Send GET_CID command to get CID from card. */ static status_t SD_AllSendCid(sd_card_t *card)
{ assert(card); HOST_TRANSFER content = {0}; HOST_COMMAND command = {0}; command.index = kSDMMC_AllSendCid; command.argument = 0U; command.responseType = kCARD_ResponseTypeR2; content.command = &command; content.data = NULL; if (kStatus_Success == card->host.transfer(card->host.base, &content)) { memcpy(card->rawCid, command.response, sizeof(card->rawCid)); SD_DecodeCid(card, command.response); return kStatus_Success; } return kStatus_SDMMC_TransferFailed; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Return NRST pin level ( 1 or 0 ). */
unsigned char RSTC_GetNrstLevel(AT91PS_RSTC rstc)
/* Return NRST pin level ( 1 or 0 ). */ unsigned char RSTC_GetNrstLevel(AT91PS_RSTC rstc)
{ if (READ_RSTC(rstc, RSTC_RSR) & AT91C_RSTC_NRSTL) { return 1; } return 0; }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Set function to write firmware to device's persistent memory */
static ssize_t if_usb_boot2_set(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
/* Set function to write firmware to device's persistent memory */ static ssize_t if_usb_boot2_set(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{ struct lbs_private *priv = to_net_dev(dev)->ml_priv; struct if_usb_card *cardp = priv->card; int ret; ret = if_usb_prog_firmware(cardp, buf, BOOT_CMD_UPDATE_BOOT2); if (ret == 0) return count; return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* usb_alphatrack_abort_transfers aborts transfers and frees associated data structures */
static void usb_alphatrack_abort_transfers(struct usb_alphatrack *dev)
/* usb_alphatrack_abort_transfers aborts transfers and frees associated data structures */ static void usb_alphatrack_abort_transfers(struct usb_alphatrack *dev)
{ if (dev->interrupt_in_running) { dev->interrupt_in_running = 0; if (dev->intf) usb_kill_urb(dev->interrupt_in_urb); } if (dev->interrupt_out_busy) if (dev->intf) usb_kill_urb(dev->interrupt_out_urb); }
robutest/uclinux
C++
GPL-2.0
60
/* Returns 1 when there's a match, 0 means no match. */
static int _scsih_srch_boot_device_name(u64 device_name, Mpi2BootDeviceDeviceName_t *boot_device)
/* Returns 1 when there's a match, 0 means no match. */ static int _scsih_srch_boot_device_name(u64 device_name, Mpi2BootDeviceDeviceName_t *boot_device)
{ return (device_name == le64_to_cpu(boot_device->DeviceName)) ? 1 : 0; }
robutest/uclinux
C++
GPL-2.0
60