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
/* Writes and returns a new value to DR2. This function is only available on IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64. */
UINTN EFIAPI AsmWriteDr2(IN UINTN Value)
/* Writes and returns a new value to DR2. This function is only available on IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64. */ UINTN EFIAPI AsmWriteDr2(IN UINTN Value)
{ _asm { mov eax, Value mov dr2, eax } }
tianocore/edk2
C++
Other
4,240
/* This routine handles an fast-path WQ entry comsumed event by invoking the proper WQ release routine to the slow-path WQ. */
static void lpfc_sli4_fp_handle_rel_wcqe(struct lpfc_hba *phba, struct lpfc_queue *cq, struct lpfc_wcqe_release *wcqe)
/* This routine handles an fast-path WQ entry comsumed event by invoking the proper WQ release routine to the slow-path WQ. */ static void lpfc_sli4_fp_handle_rel_wcqe(struct lpfc_hba *phba, struct lpfc_queue *cq, struct lpfc_wcqe_release *wcqe)
{ struct lpfc_queue *childwq; bool wqid_matched = false; uint16_t fcp_wqid; fcp_wqid = bf_get(lpfc_wcqe_r_wq_id, wcqe); list_for_each_entry(childwq, &cq->child_list, list) { if (childwq->queue_id == fcp_wqid) { lpfc_sli4_wq_release(childwq, bf_get(lpfc_wcqe_r_wqe_index, wcqe)); wqid_matched = true; ...
robutest/uclinux
C++
GPL-2.0
60
/* Threshold for wakeup: 1 LSB weight depends on WAKE_THS_W in WAKE_UP_DUR.. */
int32_t lsm6dso_wkup_threshold_get(lsm6dso_ctx_t *ctx, uint8_t *val)
/* Threshold for wakeup: 1 LSB weight depends on WAKE_THS_W in WAKE_UP_DUR.. */ int32_t lsm6dso_wkup_threshold_get(lsm6dso_ctx_t *ctx, uint8_t *val)
{ lsm6dso_wake_up_ths_t reg; int32_t ret; ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_THS, (uint8_t*)&reg, 1); *val = reg.wk_ths; return ret; }
alexander-g-dean/ESF
C++
null
41
/* Set a high output level on all the PIOs defined in ul_mask. This has no immediate effects on PIOs that are not output, but the PIO controller will save the value if they are changed to outputs. */
void pio_set(Pio *p_pio, const uint32_t ul_mask)
/* Set a high output level on all the PIOs defined in ul_mask. This has no immediate effects on PIOs that are not output, but the PIO controller will save the value if they are changed to outputs. */ void pio_set(Pio *p_pio, const uint32_t ul_mask)
{ p_pio->PIO_SODR = ul_mask; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Initializes the ADCs peripherals according to the specified parameters in the ADC_CommonInitStruct. */
void ADC_CommonInit(ADC_CommonInitTypeDef *ADC_CommonInitStruct)
/* Initializes the ADCs peripherals according to the specified parameters in the ADC_CommonInitStruct. */ void ADC_CommonInit(ADC_CommonInitTypeDef *ADC_CommonInitStruct)
{ uint32_t tmpreg1 = 0; assert_param(IS_ADC_MODE(ADC_CommonInitStruct->ADC_Mode)); assert_param(IS_ADC_PRESCALER(ADC_CommonInitStruct->ADC_Prescaler)); assert_param(IS_ADC_DMA_ACCESS_MODE(ADC_CommonInitStruct->ADC_DMAAccessMode)); assert_param(IS_ADC_SAMPLING_DELAY(ADC_CommonInitStruct->ADC_TwoSamplingDelay))...
MaJerle/stm32f429
C++
null
2,036
/* param base Pointer to the device. param mask status flag The parameter can be any combination of the following values: arg kFLEXIO_CAMERA_RxDataRegFullFlag arg kFLEXIO_CAMERA_RxErrorFlag */
void FLEXIO_CAMERA_ClearStatusFlags(FLEXIO_CAMERA_Type *base, uint32_t mask)
/* param base Pointer to the device. param mask status flag The parameter can be any combination of the following values: arg kFLEXIO_CAMERA_RxDataRegFullFlag arg kFLEXIO_CAMERA_RxErrorFlag */ void FLEXIO_CAMERA_ClearStatusFlags(FLEXIO_CAMERA_Type *base, uint32_t mask)
{ if ((mask & (uint32_t)kFLEXIO_CAMERA_RxDataRegFullFlag) != 0U) { FLEXIO_ClearShifterStatusFlags(base->flexioBase, ((1UL << (base->shifterCount)) - 1U) << (base->shifterStartIdx)); } if ((mask & (uint32_t)kFLEXIO_CAMERA_RxErrorFlag) !...
eclipse-threadx/getting-started
C++
Other
310
/* Converts a big endian byte stream into a 16-bit integer (short) */
short inv_big8_to_int16(const unsigned char *big8)
/* Converts a big endian byte stream into a 16-bit integer (short) */ short inv_big8_to_int16(const unsigned char *big8)
{ short x; x = ((short)big8[0] << 8) | ((short)big8[1]); return x; }
Luos-io/luos_engine
C++
MIT License
496
/* If OpCodeHandle is NULL, then ASSERT(). If RawBuffer is NULL, then ASSERT(); */
UINT8* EFIAPI HiiCreateRawOpCodes(IN VOID *OpCodeHandle, IN UINT8 *RawBuffer, IN UINTN RawBufferSize)
/* If OpCodeHandle is NULL, then ASSERT(). If RawBuffer is NULL, then ASSERT(); */ UINT8* EFIAPI HiiCreateRawOpCodes(IN VOID *OpCodeHandle, IN UINT8 *RawBuffer, IN UINTN RawBufferSize)
{ UINT8 *Buffer; ASSERT (RawBuffer != NULL); Buffer = InternalHiiGrowOpCodeHandle (OpCodeHandle, RawBufferSize); return (UINT8 *)CopyMem (Buffer, RawBuffer, RawBufferSize); }
tianocore/edk2
C++
Other
4,240
/* Set the given value to the period. Sets the given value to the period. */
enum status_code rtc_count_set_period(struct rtc_module *const module, const uint16_t period_value)
/* Set the given value to the period. Sets the given value to the period. */ enum status_code rtc_count_set_period(struct rtc_module *const module, const uint16_t period_value)
{ Assert(module); Assert(module->hw); Rtc *const rtc_module = module->hw; if (module->mode != RTC_COUNT_MODE_16BIT) { return STATUS_ERR_UNSUPPORTED_DEV; } while (rtc_count_is_syncing(module)) { } rtc_module->MODE1.PER.reg = period_value; return STATUS_OK; }
memfault/zero-to-main
C++
null
200
/* this function is used to send supervisory data, i.e. data which was not received from the network layer, but e.g. frames from ipppd, CCP reset frames etc. */
void isdn_net_write_super(isdn_net_local *lp, struct sk_buff *skb)
/* this function is used to send supervisory data, i.e. data which was not received from the network layer, but e.g. frames from ipppd, CCP reset frames etc. */ void isdn_net_write_super(isdn_net_local *lp, struct sk_buff *skb)
{ if (in_irq()) { skb_queue_tail(&lp->super_tx_queue, skb); schedule_work(&lp->tqueue); return; } spin_lock_bh(&lp->xmit_lock); if (!isdn_net_lp_busy(lp)) { isdn_net_writebuf_skb(lp, skb); } else { skb_queue_tail(&lp->super_tx_queue, skb); } spin_unlock_bh(&lp->xmit_lock); }
robutest/uclinux
C++
GPL-2.0
60
/* Verify the Guided Section GUID by checking if there is the Guided Section GUID configuration table recorded the GUID itself. */
BOOLEAN VerifyGuidedSectionGuid(IN EFI_GUID *GuidedSectionGuid, OUT EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL **GuidedSectionExtraction)
/* Verify the Guided Section GUID by checking if there is the Guided Section GUID configuration table recorded the GUID itself. */ BOOLEAN VerifyGuidedSectionGuid(IN EFI_GUID *GuidedSectionGuid, OUT EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL **GuidedSectionExtraction)
{ EFI_GUID *GuidRecorded; VOID *Interface; EFI_STATUS Status; Interface = NULL; Status = EfiGetSystemConfigurationTable (GuidedSectionGuid, (VOID **)&GuidRecorded); if (Status == EFI_SUCCESS) { if (CompareGuid (GuidRecorded, GuidedSectionGuid)) { Status = CoreLocateProtocol (GuidedSecti...
tianocore/edk2
C++
Other
4,240
/* Disable I2C Range Address Matching of the specified I2C port. The */
void I2CRangeAddrDisable(unsigned long ulBase)
/* Disable I2C Range Address Matching of the specified I2C port. The */ void I2CRangeAddrDisable(unsigned long ulBase)
{ xASSERT((ulBase == I2C0_BASE) || ((ulBase == I2C1_BASE))); xHWREGB(ulBase + I2C_CON2) &= ~I2C_CON2_RMEN; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Cirrus 6832 Cardbus reports wrong irq on RDI Tadpole PARISC Laptop ( */
static void __devinit quirk_cirrus_cardbus(struct pci_dev *dev)
/* Cirrus 6832 Cardbus reports wrong irq on RDI Tadpole PARISC Laptop ( */ static void __devinit quirk_cirrus_cardbus(struct pci_dev *dev)
{ u8 new_irq = dev->irq - 1; printk(KERN_INFO "PCI: Cirrus Cardbus IRQ fixup for %s, from %d to %d\n", pci_name(dev), dev->irq, new_irq); dev->irq = new_irq; }
robutest/uclinux
C++
GPL-2.0
60
/* DevicePathNode must be SerialI20 type and this will populate the MappingItem. */
EFI_STATUS DevPathSerialI2O(IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode, IN DEVICE_CONSIST_MAPPING_INFO *MappingItem, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
/* DevicePathNode must be SerialI20 type and this will populate the MappingItem. */ EFI_STATUS DevPathSerialI2O(IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode, IN DEVICE_CONSIST_MAPPING_INFO *MappingItem, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
{ I2O_DEVICE_PATH *DevicePath_I20; ASSERT (DevicePathNode != NULL); ASSERT (MappingItem != NULL); DevicePath_I20 = (I2O_DEVICE_PATH *)DevicePathNode; return AppendCSDNum (MappingItem, DevicePath_I20->Tid); }
tianocore/edk2
C++
Other
4,240
/* Add 'str' to the buffer. If string is larger than the buffer space, push the string directly to the stack. */
static void addstr2buff(BuffFS *buff, const char *str, size_t slen)
/* Add 'str' to the buffer. If string is larger than the buffer space, push the string directly to the stack. */ static void addstr2buff(BuffFS *buff, const char *str, size_t slen)
{ char *bf = getbuff(buff, cast_int(slen)); memcpy(bf, str, slen); addsize(buff, cast_int(slen)); } else { clearbuff(buff); pushstr(buff, str, slen); } }
Nicholas3388/LuaNode
C++
Other
1,055
/* If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT(). If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT(). */
VOID* EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
/* If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT(). If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT(). */ VOID* EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
{ if (Length == 0) { return DestinationBuffer; } ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)DestinationBuffer)); ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)SourceBuffer)); if (DestinationBuffer == SourceBuffer) { return DestinationBuffer; } return InternalMemCopyMem (DestinationBuffer, Sourc...
tianocore/edk2
C++
Other
4,240
/* Function for scheduling a check for timeouts by generating a RTC1 interrupt. */
static void timer_timeouts_check_sched(void)
/* Function for scheduling a check for timeouts by generating a RTC1 interrupt. */ static void timer_timeouts_check_sched(void)
{ NVIC_SetPendingIRQ(RTC1_IRQn); }
labapart/polymcu
C++
null
201
/* Read accelerometer device ID and revision numbers. This function reads the accelerometer hardware identification registers and returns these values in the specified data structure. */
static bool bma020_device_id(sensor_hal_t *hal, sensor_data_t *data)
/* Read accelerometer device ID and revision numbers. This function reads the accelerometer hardware identification registers and returns these values in the specified data structure. */ static bool bma020_device_id(sensor_hal_t *hal, sensor_data_t *data)
{ data->device.id = sensor_bus_get(hal, BMA020_CHIP_ID); data->device.version = sensor_bus_get(hal, BMA020_CHIP_VERSION); return true; }
memfault/zero-to-main
C++
null
200
/* Updates the size of the native window using the geometry of the SDL window. */
static void setWindowSize(_THIS, SDL_Window *window)
/* Updates the size of the native window using the geometry of the SDL window. */ static void setWindowSize(_THIS, SDL_Window *window)
{ window_impl_t *impl = (window_impl_t *)window->driverdata; int size[2]; size[0] = window->w; size[1] = window->h; screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_SIZE, size); screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_SOURCE_SIZE, ...
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Returns a fully allocated command (with the allied sense buffer) or NULL on failure */
static struct scsi_cmnd* scsi_pool_alloc_command(struct scsi_host_cmd_pool *pool, gfp_t gfp_mask)
/* Returns a fully allocated command (with the allied sense buffer) or NULL on failure */ static struct scsi_cmnd* scsi_pool_alloc_command(struct scsi_host_cmd_pool *pool, gfp_t gfp_mask)
{ struct scsi_cmnd *cmd; cmd = kmem_cache_zalloc(pool->cmd_slab, gfp_mask | pool->gfp_mask); if (!cmd) return NULL; cmd->sense_buffer = kmem_cache_alloc(pool->sense_slab, gfp_mask | pool->gfp_mask); if (!cmd->sense_buffer) { kmem_cache_free(pool->cmd_slab, cmd); return NULL; } return cmd; }
robutest/uclinux
C++
GPL-2.0
60
/* Programs the DmaTxBaseAddress with the Tx descriptor base address. Tx Descriptor's base address is available in the gmacdev structure. This function progrms the Dma Tx Base address with the starting address of the descriptor ring or chain. */
void synopGMAC_init_tx_desc_base(synopGMACdevice *gmacdev)
/* Programs the DmaTxBaseAddress with the Tx descriptor base address. Tx Descriptor's base address is available in the gmacdev structure. This function progrms the Dma Tx Base address with the starting address of the descriptor ring or chain. */ void synopGMAC_init_tx_desc_base(synopGMACdevice *gmacdev)
{ synopGMACWriteReg(gmacdev->DmaBase,DmaTxBaseAddr,(u32)gmacdev->TxDescDma); return; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Callback function executed when the EndOfDxe event group is signaled. */
VOID EFIAPI DxeCapsuleLibEndOfDxe(IN EFI_EVENT Event, IN VOID *Context)
/* Callback function executed when the EndOfDxe event group is signaled. */ VOID EFIAPI DxeCapsuleLibEndOfDxe(IN EFI_EVENT Event, IN VOID *Context)
{ mDxeCapsuleLibEndOfDxe = TRUE; }
tianocore/edk2
C++
Other
4,240
/* This function converts budget which was allocated for a new page of data to the budget of changing an existing page of data. The latter is smaller than the former, so this function only does simple re-calculation and does not involve any write-back. */
void ubifs_convert_page_budget(struct ubifs_info *c)
/* This function converts budget which was allocated for a new page of data to the budget of changing an existing page of data. The latter is smaller than the former, so this function only does simple re-calculation and does not involve any write-back. */ void ubifs_convert_page_budget(struct ubifs_info *c)
{ spin_lock(&c->space_lock); c->bi.idx_growth -= c->max_idx_node_sz << UBIFS_BLOCKS_PER_PAGE_SHIFT; c->bi.data_growth -= c->bi.page_budget; c->bi.dd_growth += c->bi.page_budget; c->bi.min_idx_lebs = ubifs_calc_min_idx_lebs(c); spin_unlock(&c->space_lock); }
4ms/stm32mp1-baremetal
C++
Other
137
/* Since: 2.24 Returns: a pointer to the allocated memory */
gpointer g_malloc_n(gsize n_blocks, gsize n_block_bytes)
/* Since: 2.24 Returns: a pointer to the allocated memory */ gpointer g_malloc_n(gsize n_blocks, gsize n_block_bytes)
{ if (SIZE_OVERFLOWS (n_blocks, n_block_bytes)) { g_error ("%s: overflow allocating %"G_GSIZE_FORMAT"*%"G_GSIZE_FORMAT" bytes", G_STRLOC, n_blocks, n_block_bytes); } return g_malloc (n_blocks * n_block_bytes); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* brief Setup rtc 1khz clock divider. param divided_by_value: Value to be divided return Nothing */
void CLOCK_SetRtc1khzClkDiv(uint32_t divided_by_value)
/* brief Setup rtc 1khz clock divider. param divided_by_value: Value to be divided return Nothing */ void CLOCK_SetRtc1khzClkDiv(uint32_t divided_by_value)
{ PMC->RTCOSC32K = (PMC->RTCOSC32K & ~PMC_RTCOSC32K_CLK1KHZDIV_MASK) | PMC_RTCOSC32K_CLK1KHZDIV(divided_by_value - 28U); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Helper function for NetbufGetFragment. NetbufGetFragment may allocate the first block to reserve HeadSpace bytes header space. So it needs to create a new net vector for the first block and can avoid copy for the remaining data by sharing the old net vector. */
VOID EFIAPI NetbufGetFragmentFree(IN VOID *Arg)
/* Helper function for NetbufGetFragment. NetbufGetFragment may allocate the first block to reserve HeadSpace bytes header space. So it needs to create a new net vector for the first block and can avoid copy for the remaining data by sharing the old net vector. */ VOID EFIAPI NetbufGetFragmentFree(IN VOID *Arg)
{ NET_VECTOR *Vector; Vector = (NET_VECTOR *)Arg; NetbufFreeVector (Vector); }
tianocore/edk2
C++
Other
4,240
/* @value: value to be printed @prec: minimum number of digits to display @buf: pointer to buffer address on return position of terminating zero word */
static void int2dec(s32 value, int prec, u16 **buf)
/* @value: value to be printed @prec: minimum number of digits to display @buf: pointer to buffer address on return position of terminating zero word */ static void int2dec(s32 value, int prec, u16 **buf)
{ u32 u; u16 *pos = *buf; if (value < 0) { *pos++ = '-'; u = -value; } else { u = value; } uint2dec(u, prec, &pos); *buf = pos; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Returns: TRUE if it is possible to remove supported content types from a given @appinfo, FALSE if not. */
gboolean g_app_info_can_remove_supports_type(GAppInfo *appinfo)
/* Returns: TRUE if it is possible to remove supported content types from a given @appinfo, FALSE if not. */ gboolean g_app_info_can_remove_supports_type(GAppInfo *appinfo)
{ GAppInfoIface *iface; g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE); iface = G_APP_INFO_GET_IFACE (appinfo); if (iface->can_remove_supports_type) return (* iface->can_remove_supports_type) (appinfo); return FALSE; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Caller doesn't need to free the returned JSON value because it will be released in corresponding */
EDKII_JSON_VALUE EFIAPI RedfishJsonInPayload(IN REDFISH_PAYLOAD Payload)
/* Caller doesn't need to free the returned JSON value because it will be released in corresponding */ EDKII_JSON_VALUE EFIAPI RedfishJsonInPayload(IN REDFISH_PAYLOAD Payload)
{ if (Payload == NULL) { return NULL; } return ((redfishPayload *)Payload)->json; }
tianocore/edk2
C++
Other
4,240
/* Reads data from the specified address on the serial flash. */
void s25fl1xx_enter_continous_read_mode(struct qspid_t *qspid)
/* Reads data from the specified address on the serial flash. */ void s25fl1xx_enter_continous_read_mode(struct qspid_t *qspid)
{ uint32_t data; mem->inst_frame.bm.b_opt_len= (QSPI_IFR_OPTL_OPTION_4BIT >> QSPI_IFR_OPTL_Pos); qspid->qspi_command.option = 0x02; mem->inst_frame.bm.b_continues_read = 1; mem->inst_frame.bm.b_dummy_cycles = 5; mem->inst_frame.bm.b_opt_en = 1; mem->inst_frame.bm.b_width = QSPI_IFR_WIDTH_QUAD_IO; s25fl1xx_memor...
remotemcu/remcu-chip-sdks
C++
null
436
/* Generate some initially weak seeding values to allow to start the random32() engine. */
static int __init random32_init(void)
/* Generate some initially weak seeding values to allow to start the random32() engine. */ static int __init random32_init(void)
{ int i; for_each_possible_cpu(i) { struct rnd_state *state = &per_cpu(net_rand_state,i); #define LCG(x) ((x) * 69069) state->s1 = __seed(LCG(i + jiffies), 1); state->s2 = __seed(LCG(state->s1), 7); state->s3 = __seed(LCG(state->s2), 15); __random32(state); __random32(state); __random32(state); __rand...
robutest/uclinux
C++
GPL-2.0
60
/* Returns: The converted string, or NULL on an error. */
gchar* g_filename_to_utf8(const gchar *opsysstring, gssize len, gsize *bytes_read, gsize *bytes_written, GError **error)
/* Returns: The converted string, or NULL on an error. */ gchar* g_filename_to_utf8(const gchar *opsysstring, gssize len, gsize *bytes_read, gsize *bytes_written, GError **error)
{ const gchar *charset; g_return_val_if_fail (opsysstring != NULL, NULL); if (get_filename_charset (&charset)) return strdup_len (opsysstring, len, bytes_read, bytes_written, error); else return g_convert (opsysstring, len, "UTF-8", charset, bytes_read, bytes_written, error); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Return a minimum chunk size of all snapshots that have the specified origin. Return zero if the origin has no snapshots. */
static sector_t __minimum_chunk_size(struct origin *o)
/* Return a minimum chunk size of all snapshots that have the specified origin. Return zero if the origin has no snapshots. */ static sector_t __minimum_chunk_size(struct origin *o)
{ struct dm_snapshot *snap; unsigned chunk_size = 0; if (o) list_for_each_entry(snap, &o->snapshots, list) chunk_size = min_not_zero(chunk_size, snap->store->chunk_size); return chunk_size; }
robutest/uclinux
C++
GPL-2.0
60
/* Query and return the pin's Presence Detect status. */
int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid)
/* Query and return the pin's Presence Detect status. */ int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid)
{ u32 sense = snd_hda_pin_sense(codec, nid); return !!(sense & AC_PINSENSE_PRESENCE); }
robutest/uclinux
C++
GPL-2.0
60
/* Initialises the SPI block (CLK set low when inactive, trigger on leading edge). */
void at25Init(void)
/* Initialises the SPI block (CLK set low when inactive, trigger on leading edge). */ void at25Init(void)
{ sspInit(0, sspClockPolarity_Low, sspClockPhase_RisingEdge); }
microbuilder/LPC1343CodeBase
C++
Other
73
/* Call with timer IRQ closed. First time we do it with disable_irq, later prom code uses spin_lock_irq(). */
void install_linux_ticker(void)
/* Call with timer IRQ closed. First time we do it with disable_irq, later prom code uses spin_lock_irq(). */ void install_linux_ticker(void)
{ if (!linux_lvl14) return; linux_lvl14[0] = lvl14_save[0]; linux_lvl14[1] = lvl14_save[1]; linux_lvl14[2] = lvl14_save[2]; linux_lvl14[3] = lvl14_save[3]; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* /proc handlers We write our info in page, we begin at offset off and cannot write more than count bytes. We set eof to 1 if we handle those 2 values. We return the number of bytes written in page */
static int read_led(const char *ledname, int ledmask)
/* /proc handlers We write our info in page, we begin at offset off and cannot write more than count bytes. We set eof to 1 if we handle those 2 values. We return the number of bytes written in page */ static int read_led(const char *ledname, int ledmask)
{ if (ledname) { int led_status; if (read_acpi_int(NULL, ledname, &led_status)) return led_status; else printk(KERN_WARNING "Asus ACPI: Error reading LED " "status\n"); } return (hotk->status & ledmask) ? 1 : 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This function executes the _PS0/_PS3 ACPI method to set the power state. ACPI spec requires _PS0 when IDE power on and _PS3 when power off */
void ide_acpi_set_state(ide_hwif_t *hwif, int on)
/* This function executes the _PS0/_PS3 ACPI method to set the power state. ACPI spec requires _PS0 when IDE power on and _PS3 when power off */ void ide_acpi_set_state(ide_hwif_t *hwif, int on)
{ ide_drive_t *drive; int i; if (ide_noacpi_psx) return; DEBPRINT("ENTER:\n"); if (on) acpi_bus_set_power(hwif->acpidata->obj_handle, ACPI_STATE_D0); ide_port_for_each_present_dev(i, drive, hwif) { if (drive->acpidata->obj_handle) acpi_bus_set_power(drive->acpidata->obj_handle, on ? ACPI_STATE_D0...
robutest/uclinux
C++
GPL-2.0
60
/* Function for handling the BLE_GAP_EVT_CONNECTED event from the S110 SoftDevice. */
static void on_connect(ble_dfu_t *p_dfu, ble_evt_t *p_ble_evt)
/* Function for handling the BLE_GAP_EVT_CONNECTED event from the S110 SoftDevice. */ static void on_connect(ble_dfu_t *p_dfu, ble_evt_t *p_ble_evt)
{ p_dfu->conn_handle = p_ble_evt->evt.gap_evt.conn_handle; }
labapart/polymcu
C++
null
201
/* This function deinitializes shared TLS functionality that was initialized with eap_peer_tls_ssl_init(). */
void eap_peer_tls_ssl_deinit(struct eap_sm *sm, struct eap_ssl_data *data)
/* This function deinitializes shared TLS functionality that was initialized with eap_peer_tls_ssl_init(). */ void eap_peer_tls_ssl_deinit(struct eap_sm *sm, struct eap_ssl_data *data)
{ tls_connection_deinit(data->ssl_ctx, data->conn); eap_peer_tls_reset_input(data); eap_peer_tls_reset_output(data); }
retro-esp32/RetroESP32
C++
Creative Commons Attribution Share Alike 4.0 International
581
/* Check the status of the FIFO buffer of the specified SPI port. */
void SPIFIFOLevelSet(unsigned long ulBase, unsigned long ulRxTx, unsigned long ulLength)
/* Check the status of the FIFO buffer of the specified SPI port. */ void SPIFIFOLevelSet(unsigned long ulBase, unsigned long ulRxTx, unsigned long ulLength)
{ xASSERT(ulBase == SPI0_BASE); xASSERT((ulRxTx == SPI_FSR_RX) || (ulRxTx == SPI_FSR_TX)); xASSERT((ulLength >= 0) || (ulLength <= 8)); if(ulRxTx == SPI_FSR_RX) { xHWREG(ulBase + SPI_FCR) &= ~((ulLength << SPI_FCR_RXFTLS_S) & SPI_FCR_RXFTLS_M); xHWREG(ulBase + SPI_FCR) |= (ulLength << S...
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Src and Dst are in network byte order, and Len is in host byte order. */
UINT16 EFIAPI NetIp6PseudoHeadChecksum(IN EFI_IPv6_ADDRESS *Src, IN EFI_IPv6_ADDRESS *Dst, IN UINT8 NextHeader, IN UINT32 Len)
/* Src and Dst are in network byte order, and Len is in host byte order. */ UINT16 EFIAPI NetIp6PseudoHeadChecksum(IN EFI_IPv6_ADDRESS *Src, IN EFI_IPv6_ADDRESS *Dst, IN UINT8 NextHeader, IN UINT32 Len)
{ NET_IP6_PSEUDO_HDR Hdr; ZeroMem (&Hdr, sizeof (Hdr)); IP6_COPY_ADDRESS (&Hdr.SrcIp, Src); IP6_COPY_ADDRESS (&Hdr.DstIp, Dst); Hdr.NextHeader = NextHeader; Hdr.Len = HTONL (Len); return NetblockChecksum ((UINT8 *)&Hdr, sizeof (Hdr)); }
tianocore/edk2
C++
Other
4,240
/* If this array is NULL or not a JSON array, or if index is out of range, NULL will be returned. */
EDKII_JSON_VALUE EFIAPI JsonArrayGetValue(IN EDKII_JSON_ARRAY JsonArray, IN UINTN Index)
/* If this array is NULL or not a JSON array, or if index is out of range, NULL will be returned. */ EDKII_JSON_VALUE EFIAPI JsonArrayGetValue(IN EDKII_JSON_ARRAY JsonArray, IN UINTN Index)
{ return (EDKII_JSON_VALUE)json_array_get ((json_t *)JsonArray, Index); }
tianocore/edk2
C++
Other
4,240
/* hvc_instantiate() is an early console discovery method which locates consoles * prior to the vio subsystem discovering them. Hotplugged vty adapters do NOT get an hvc_instantiate() callback since they appear after early console init. */
int hvc_instantiate(uint32_t vtermno, int index, struct hv_ops *ops)
/* hvc_instantiate() is an early console discovery method which locates consoles * prior to the vio subsystem discovering them. Hotplugged vty adapters do NOT get an hvc_instantiate() callback since they appear after early console init. */ int hvc_instantiate(uint32_t vtermno, int index, struct hv_ops *ops)
{ struct hvc_struct *hp; if (index < 0 || index >= MAX_NR_HVC_CONSOLES) return -1; if (vtermnos[index] != -1) return -1; hp = hvc_get_by_index(index); if (hp) { kref_put(&hp->kref, destroy_hvc_struct); return -1; } vtermnos[index] = vtermno; cons_ops[index] = ops; if (last_hvc < index) last_hvc = ind...
robutest/uclinux
C++
GPL-2.0
60
/* Set the SP1011 HT/PCI bridge's TRDY timeout to the finite max. */
static void __init quirk_sp1011(struct pci_dev *dev)
/* Set the SP1011 HT/PCI bridge's TRDY timeout to the finite max. */ static void __init quirk_sp1011(struct pci_dev *dev)
{ pci_write_config_byte(dev, 0x64, 0xff); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Begin unmount by attempting to remove all automounted mountpoints we added in response to xdev traversals and referrals */
static void nfs_umount_begin(struct super_block *)
/* Begin unmount by attempting to remove all automounted mountpoints we added in response to xdev traversals and referrals */ static void nfs_umount_begin(struct super_block *)
{ struct nfs_server *server; struct rpc_clnt *rpc; server = NFS_SB(sb); rpc = server->client_acl; if (!IS_ERR(rpc)) rpc_killall_tasks(rpc); rpc = server->client; if (!IS_ERR(rpc)) rpc_killall_tasks(rpc); }
robutest/uclinux
C++
GPL-2.0
60
/* The qualifier defined here is not the value that is masked, it defines conditions for the write to take place. The actual masked qualifier (and other related details) are defined beforehand with _set_shuttle_features(). */
static int usbat_read_blocks(struct us_data *us, void *buffer, int len, int use_sg)
/* The qualifier defined here is not the value that is masked, it defines conditions for the write to take place. The actual masked qualifier (and other related details) are defined beforehand with _set_shuttle_features(). */ static int usbat_read_blocks(struct us_data *us, void *buffer, int len, int use_sg)
{ int result; unsigned char *command = us->iobuf; command[0] = 0xC0; command[1] = USBAT_ATA | USBAT_CMD_COND_READ_BLOCK; command[2] = USBAT_ATA_DATA; command[3] = USBAT_ATA_STATUS; command[4] = 0xFD; command[5] = USBAT_QUAL_FCQ; command[6] = LSB_of(len); command[7] = MSB_of(len); result = usbat_execute_comma...
robutest/uclinux
C++
GPL-2.0
60
/* This function returns the device path protocol from the handle specified by Handle. If Handle is NULL or Handle does not contain a device path protocol, then NULL is returned. */
EFI_DEVICE_PATH_PROTOCOL* EFIAPI DevicePathFromHandle(IN EFI_HANDLE Handle)
/* This function returns the device path protocol from the handle specified by Handle. If Handle is NULL or Handle does not contain a device path protocol, then NULL is returned. */ EFI_DEVICE_PATH_PROTOCOL* EFIAPI DevicePathFromHandle(IN EFI_HANDLE Handle)
{ EFI_DEVICE_PATH_PROTOCOL *DevicePath; EFI_STATUS Status; Status = gBS->HandleProtocol ( Handle, &gEfiDevicePathProtocolGuid, (VOID *)&DevicePath ); if (EFI_ERROR (Status)) { DevicePath = NULL; } return DevicePath; ...
tianocore/edk2
C++
Other
4,240
/* CRC Reset. Reset the CRC unit and forces the data register to all 1s. */
void crc_reset(void)
/* CRC Reset. Reset the CRC unit and forces the data register to all 1s. */ void crc_reset(void)
{ CRC_CR |= CRC_CR_RESET; }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* Attention! The len must be a multiple of 4 * sizeof(long) due to restriction of optimizations in this function. */
bool buffer_is_zero(const void *buf, size_t len)
/* Attention! The len must be a multiple of 4 * sizeof(long) due to restriction of optimizations in this function. */ bool buffer_is_zero(const void *buf, size_t len)
{ size_t i; long d0, d1, d2, d3; const long * const data = buf; if (can_use_buffer_find_nonzero_offset(buf, len)) { return buffer_find_nonzero_offset(buf, len) == len; } assert(len % (4 * sizeof(long)) == 0); len /= sizeof(long); for (i = 0; i < len; i += 4) { d0 = data[i...
ve3wwg/teensy3_qemu
C++
Other
15
/* This function set the API status code returned to the BootLoader. */
VOID EFIAPI SetFspApiReturnStatus(IN UINTN ReturnStatus)
/* This function set the API status code returned to the BootLoader. */ VOID EFIAPI SetFspApiReturnStatus(IN UINTN ReturnStatus)
{ FSP_GLOBAL_DATA *FspData; FspData = GetFspGlobalDataPointer (); *(UINTN *)(FspData->CoreStack + CONTEXT_STACK_OFFSET (Registers[7])) = ReturnStatus; }
tianocore/edk2
C++
Other
4,240
/* Perform cable detection for the 8213 ATA interface. This is different to the PIIX arrangement */
static int it8213_cable_detect(struct ata_port *ap)
/* Perform cable detection for the 8213 ATA interface. This is different to the PIIX arrangement */ static int it8213_cable_detect(struct ata_port *ap)
{ struct pci_dev *pdev = to_pci_dev(ap->host->dev); u8 tmp; pci_read_config_byte(pdev, 0x42, &tmp); if (tmp & 2) return ATA_CBL_PATA40; return ATA_CBL_PATA80; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Performs additional actions just before a PE/COFF image is unloaded. Any resources that were allocated by */
VOID EFIAPI PeCoffLoaderUnloadImageExtraAction(IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext)
/* Performs additional actions just before a PE/COFF image is unloaded. Any resources that were allocated by */ VOID EFIAPI PeCoffLoaderUnloadImageExtraAction(IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext)
{ PeCoffLoaderExtraActionCommon (ImageContext, IMAGE_UNLOAD_SIGNATURE); }
tianocore/edk2
C++
Other
4,240
/* Deinitializes the ADCx peripheral registers to their default reset values. */
void ADC_DeInit(ADC_TypeDef *ADCx)
/* Deinitializes the ADCx peripheral registers to their default reset values. */ void ADC_DeInit(ADC_TypeDef *ADCx)
{ assert_param(IS_ADC_ALL_PERIPH(ADCx)); switch (*(uint32_t*)&ADCx) { case ADC1_BASE: RCC_APB2PeriphResetCmd(RCC_APB2Periph_ADC1, ENABLE); RCC_APB2PeriphResetCmd(RCC_APB2Periph_ADC1, DISABLE); break; default: break; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* As noted above, we can assume a single CPU for now but it may be multithreaded. */
static void __init msmtc_smp_setup(void)
/* As noted above, we can assume a single CPU for now but it may be multithreaded. */ static void __init msmtc_smp_setup(void)
{ smp_num_siblings = smtc_build_cpu_map(0); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This is the top-level routine plugged into the EBC protocol. Since thunks are very processor-specific, from here we dispatch directly to the very processor-specific routine EbcCreateThunks(). */
EFI_STATUS EFIAPI EbcCreateThunk(IN EFI_EBC_PROTOCOL *This, IN EFI_HANDLE ImageHandle, IN VOID *EbcEntryPoint, OUT VOID **Thunk)
/* This is the top-level routine plugged into the EBC protocol. Since thunks are very processor-specific, from here we dispatch directly to the very processor-specific routine EbcCreateThunks(). */ EFI_STATUS EFIAPI EbcCreateThunk(IN EFI_EBC_PROTOCOL *This, IN EFI_HANDLE ImageHandle, IN VOID *EbcEntryPoint, OUT VOID **...
{ EFI_STATUS Status; Status = EbcCreateThunks ( ImageHandle, EbcEntryPoint, Thunk, FLAG_THUNK_ENTRY_POINT ); return Status; }
tianocore/edk2
C++
Other
4,240
/* LPCOMP event handler is called when LPCOMP detects voltage drop. This function is called from interrupt context so it is very important to return quickly. Don't put busy loops or any other CPU intensive actions here. It is also not allowed to call soft device functions from it (if LPCOMP IRQ priority is set to APP_...
static void lpcomp_event_handler(nrf_lpcomp_event_t event)
/* LPCOMP event handler is called when LPCOMP detects voltage drop. This function is called from interrupt context so it is very important to return quickly. Don't put busy loops or any other CPU intensive actions here. It is also not allowed to call soft device functions from it (if LPCOMP IRQ priority is set to APP_...
{ if (event == NRF_LPCOMP_EVENT_DOWN) { bsp_board_led_invert(BSP_BOARD_LED_0); voltage_falls_detected++; voltage_falls_total++; } }
remotemcu/remcu-chip-sdks
C++
null
436
/* rcu_barrier_bh - Wait until all in-flight call_rcu_bh() callbacks complete. */
void rcu_barrier_bh(void)
/* rcu_barrier_bh - Wait until all in-flight call_rcu_bh() callbacks complete. */ void rcu_barrier_bh(void)
{ _rcu_barrier(&rcu_bh_state, call_rcu_bh); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Enable or disable the mute feature on the audio codec. */
uint32_t cs42l51_SetMute(uint16_t DeviceAddr, uint32_t Cmd)
/* Enable or disable the mute feature on the audio codec. */ uint32_t cs42l51_SetMute(uint16_t DeviceAddr, uint32_t Cmd)
{ uint32_t counter = 0; uint8_t Value; Value = AUDIO_IO_Read(DeviceAddr, 0x08); if(Cmd == AUDIO_MUTE_ON) { counter += CODEC_IO_Write(DeviceAddr, 0x08, (Value | 0x03)); } else { counter += CODEC_IO_Write(DeviceAddr, 0x08, (Value & 0xFC)); } return counter; }
eclipse-threadx/getting-started
C++
Other
310
/* Note that the source address is modified during the DMA transfer according to edma3_set_src_index(). */
void edma3_set_src(u32 base, int slot, u32 src, enum edma3_address_mode mode, enum edma3_fifo_width width)
/* Note that the source address is modified during the DMA transfer according to edma3_set_src_index(). */ void edma3_set_src(u32 base, int slot, u32 src, enum edma3_address_mode mode, enum edma3_fifo_width width)
{ u32 opt; struct edma3_slot_layout *rg; rg = (struct edma3_slot_layout *)(base + EDMA3_SL_BASE(slot)); opt = __raw_readl(&rg->opt); if (mode == FIFO) opt = (opt & EDMA3_SLOPT_FIFO_WIDTH_MASK) | (EDMA3_SLOPT_DST_ADDR_CONST_MODE | EDMA3_SLOPT_FIFO_WIDTH_SET(width)); else opt &= ~EDMA3_SLOPT_DST_ADD...
4ms/stm32mp1-baremetal
C++
Other
137
/* This function sets the information about the file for the opened handle specified. */
EFI_STATUS EFIAPI ShellSetFileInfo(IN SHELL_FILE_HANDLE FileHandle, IN EFI_FILE_INFO *FileInfo)
/* This function sets the information about the file for the opened handle specified. */ EFI_STATUS EFIAPI ShellSetFileInfo(IN SHELL_FILE_HANDLE FileHandle, IN EFI_FILE_INFO *FileInfo)
{ return (FileFunctionMap.SetFileInfo (FileHandle, FileInfo)); }
tianocore/edk2
C++
Other
4,240
/* Clears out all files from the Fv buffer in memory */
EFI_STATUS FvBufClearAllFiles(IN OUT VOID *Fv)
/* Clears out all files from the Fv buffer in memory */ EFI_STATUS FvBufClearAllFiles(IN OUT VOID *Fv)
{ EFI_FIRMWARE_VOLUME_HEADER *hdr = (EFI_FIRMWARE_VOLUME_HEADER*)Fv; EFI_STATUS Status; UINTN size = 0; Status = FvBufGetSize (Fv, &size); if (EFI_ERROR (Status)) { return Status; } CommonLibBinderSetMem( (UINT8*)hdr + hdr->HeaderLength, size - hdr->HeaderLength, (hdr->Attributes & EFI_FVB...
tianocore/edk2
C++
Other
4,240
/* Waits until the LCD FCR register is synchronized in the LCDCLK domain. This function must be called after any write operation to LCD_FCR register. */
void LCD_WaitForSynchro(void)
/* Waits until the LCD FCR register is synchronized in the LCDCLK domain. This function must be called after any write operation to LCD_FCR register. */ void LCD_WaitForSynchro(void)
{ while ((LCD->SR & LCD_FLAG_FCRSF) == (uint32_t)RESET) { } }
avem-labs/Avem
C++
MIT License
1,752
/* usb_eye_configure() for optimizing the USB eye on Calliope. */
static void __init usb_eye_configure(unsigned int value)
/* usb_eye_configure() for optimizing the USB eye on Calliope. */ static void __init usb_eye_configure(unsigned int value)
{ asic_write(asic_read(crt_spare) | value, crt_spare); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Event notification that is fired when a GUIDed Event Group is signaled. */
VOID EFIAPI SmmIplGuidedEventNotify(IN EFI_EVENT Event, IN VOID *Context)
/* Event notification that is fired when a GUIDed Event Group is signaled. */ VOID EFIAPI SmmIplGuidedEventNotify(IN EFI_EVENT Event, IN VOID *Context)
{ UINTN Size; CopyGuid (&mCommunicateHeader.HeaderGuid, (EFI_GUID *)Context); mCommunicateHeader.MessageLength = 1; mCommunicateHeader.Data[0] = 0; Size = sizeof (mCommunicateHeader); SmmCommunicationCommunicate (&mSmmCommunication, &mCommunicateHeader, &Size); }
tianocore/edk2
C++
Other
4,240
/* In TDX a serial of TdIoRead16 is invoked to read data from the I/O port. */
VOID EFIAPI TdIoReadFifo16(IN UINTN Port, IN UINTN Count, OUT VOID *Buffer)
/* In TDX a serial of TdIoRead16 is invoked to read data from the I/O port. */ VOID EFIAPI TdIoReadFifo16(IN UINTN Port, IN UINTN Count, OUT VOID *Buffer)
{ UINT16 *Buf16; UINTN Index; Buf16 = (UINT16 *)Buffer; for (Index = 0; Index < Count; Index++) { Buf16[Index] = TdIoRead16 (Port); } }
tianocore/edk2
C++
Other
4,240
/* USBH_IsocSendData Sends the data on Isochronous OUT Endpoint. */
USBH_StatusTypeDef USBH_IsocSendData(USBH_HandleTypeDef *phost, uint8_t *buff, uint32_t length, uint8_t pipe_num)
/* USBH_IsocSendData Sends the data on Isochronous OUT Endpoint. */ USBH_StatusTypeDef USBH_IsocSendData(USBH_HandleTypeDef *phost, uint8_t *buff, uint32_t length, uint8_t pipe_num)
{ USBH_LL_SubmitURB (phost, pipe_num, 0, USBH_EP_ISO, USBH_PID_DATA, buff, length, 0); return USBH_OK; }
micropython/micropython
C++
Other
18,334
/* If there is no additional space for HOB creation, then ASSERT(). */
VOID EFIAPI BuildBspStoreHob(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN EFI_MEMORY_TYPE MemoryType)
/* If there is no additional space for HOB creation, then ASSERT(). */ VOID EFIAPI BuildBspStoreHob(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN EFI_MEMORY_TYPE MemoryType)
{ EFI_HOB_MEMORY_ALLOCATION_BSP_STORE *Hob; ASSERT ( ((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) && ((Length & (EFI_PAGE_SIZE - 1)) == 0) ); Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, (UINT16)sizeof (EFI_HOB_MEMORY_ALLOCATION_BSP_STORE)); if (Hob == NULL) { return; } CopyGui...
tianocore/edk2
C++
Other
4,240
/* param base LPSPI peripheral address. param handle pointer to lpspi_master_handle_t structure which stores the transfer state. */
void LPSPI_MasterTransferAbort(LPSPI_Type *base, lpspi_master_handle_t *handle)
/* param base LPSPI peripheral address. param handle pointer to lpspi_master_handle_t structure which stores the transfer state. */ void LPSPI_MasterTransferAbort(LPSPI_Type *base, lpspi_master_handle_t *handle)
{ assert(handle); LPSPI_DisableInterrupts(base, (uint32_t)kLPSPI_AllInterruptEnable); LPSPI_Reset(base); handle->state = (uint8_t)kLPSPI_Idle; handle->txRemainingByteCount = 0; handle->rxRemainingByteCount = 0; }
eclipse-threadx/getting-started
C++
Other
310
/* Enables or disables the I2C automatic end mode (stop condition is automatically sent when nbytes data are transferred). */
void I2C_AutoEndCmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
/* Enables or disables the I2C automatic end mode (stop condition is automatically sent when nbytes data are transferred). */ void I2C_AutoEndCmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
{ assert_param(IS_I2C_ALL_PERIPH(I2Cx)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { I2Cx->CR2 |= I2C_CR2_AUTOEND; } else { I2Cx->CR2 &= (uint32_t)~((uint32_t)I2C_CR2_AUTOEND); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* If 64-bit MMIO register operations are not supported, then ASSERT(). */
UINT64 EFIAPI MmioWrite64(IN UINTN Address, IN UINT64 Value)
/* If 64-bit MMIO register operations are not supported, then ASSERT(). */ UINT64 EFIAPI MmioWrite64(IN UINTN Address, IN UINT64 Value)
{ BOOLEAN Flag; ASSERT ((Address & 7) == 0); Flag = FilterBeforeMmIoWrite (FilterWidth64, Address, &Value); if (Flag) { *(volatile UINT64 *)Address = Value; } FilterAfterMmIoWrite (FilterWidth64, Address, &Value); return Value; }
tianocore/edk2
C++
Other
4,240
/* ICH8 use the PCI Express bus, but does not contain a PCI Express Capability register, so the the bus width is hard coded. */
static s32 e1000_get_bus_info_ich8lan(struct e1000_hw *hw)
/* ICH8 use the PCI Express bus, but does not contain a PCI Express Capability register, so the the bus width is hard coded. */ static s32 e1000_get_bus_info_ich8lan(struct e1000_hw *hw)
{ struct e1000_bus_info *bus = &hw->bus; s32 ret_val; ret_val = e1000e_get_bus_info_pcie(hw); if (bus->width == e1000_bus_width_unknown) bus->width = e1000_bus_width_pcie_x1; return ret_val; }
robutest/uclinux
C++
GPL-2.0
60
/* a thread pends on a lifo then times out */
void test_thread_pend_and_timeout(void *p1, void *p2, void *p3)
/* a thread pends on a lifo then times out */ void test_thread_pend_and_timeout(void *p1, void *p2, void *p3)
{ struct timeout_order_data *d = (struct timeout_order_data *)p1; uint32_t start_time; void *packet; start_time = k_cycle_get_32(); packet = k_lifo_get(d->klifo, K_MSEC(d->timeout)); zassert_true(packet == NULL); zassert_true(is_timeout_in_range(start_time, d->timeout)); k_lifo_put(&timeout_order_lifo, d); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Setup timeout for a device. On timeout trigger an update. */
static void tty3270_set_timer(struct tty3270 *tp, int expires)
/* Setup timeout for a device. On timeout trigger an update. */ static void tty3270_set_timer(struct tty3270 *tp, int expires)
{ if (expires == 0) del_timer(&tp->timer); else mod_timer(&tp->timer, jiffies + expires); }
robutest/uclinux
C++
GPL-2.0
60
/* When we have a situtaion where we run out of memory and cannot allocate messages, we just leave them in the BMC and run the system polled until we can allocate some memory. Once we have some memory, we will re-enable the interrupt. */
static void disable_si_irq(struct smi_info *smi_info)
/* When we have a situtaion where we run out of memory and cannot allocate messages, we just leave them in the BMC and run the system polled until we can allocate some memory. Once we have some memory, we will re-enable the interrupt. */ static void disable_si_irq(struct smi_info *smi_info)
{ if ((smi_info->irq) && (!smi_info->interrupt_disabled)) { start_disable_irq(smi_info); smi_info->interrupt_disabled = 1; } }
robutest/uclinux
C++
GPL-2.0
60
/* Initialization function for the floating-point transposed direct form II Biquad cascade filter. */
void arm_biquad_cascade_df2T_init_f64(arm_biquad_cascade_df2T_instance_f64 *S, uint8_t numStages, float64_t *pCoeffs, float64_t *pState)
/* Initialization function for the floating-point transposed direct form II Biquad cascade filter. */ void arm_biquad_cascade_df2T_init_f64(arm_biquad_cascade_df2T_instance_f64 *S, uint8_t numStages, float64_t *pCoeffs, float64_t *pState)
{ S->numStages = numStages; S->pCoeffs = pCoeffs; memset(pState, 0, (2U * (uint32_t) numStages) * sizeof(float64_t)); S->pState = pState; }
pikasTech/PikaPython
C++
MIT License
1,403
/* c67x00_ll_read_mem_le16 - read from c67x00 memory Only data is little endian, addr has cpu endianess. */
void c67x00_ll_read_mem_le16(struct c67x00_device *dev, u16 addr, void *data, int len)
/* c67x00_ll_read_mem_le16 - read from c67x00 memory Only data is little endian, addr has cpu endianess. */ void c67x00_ll_read_mem_le16(struct c67x00_device *dev, u16 addr, void *data, int len)
{ u8 *buf = data; if (addr & 0x01) { u16 tmp; tmp = hpi_read_word(dev, addr - 1); *buf++ = (tmp >> 8) & 0x00ff; addr++; len--; } hpi_read_words_le16(dev, addr, (__le16 *)buf, len / 2); buf += len & ~0x01; addr += len & ~0x01; len &= 0x01; if (len) { u16 tmp; tmp = hpi_read_word(dev, addr); *buf ...
robutest/uclinux
C++
GPL-2.0
60
/* find a "name" for the RK value 'c' */
static void kname(Proto *p, int pc, int c, const char **name)
/* find a "name" for the RK value 'c' */ static void kname(Proto *p, int pc, int c, const char **name)
{ TValue *kvalue = &p->k[INDEXK(c)]; if (ttisstring(kvalue)) { *name = svalue(kvalue); return; } } else { const char *what = getobjname(p, pc, c, name); if (what && *what == 'c') { return; } } *name = "?"; }
opentx/opentx
C++
GNU General Public License v2.0
2,025
/* Submit a USB get HID descriptor request for the USB device specified by UsbIo and Interface and return the HID descriptor in HidDescriptor. If UsbIo is NULL, then ASSERT(). If HidDescriptor is NULL, then ASSERT(). */
EFI_STATUS EFIAPI UsbGetHidDescriptor(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT8 Interface, OUT EFI_USB_HID_DESCRIPTOR *HidDescriptor)
/* Submit a USB get HID descriptor request for the USB device specified by UsbIo and Interface and return the HID descriptor in HidDescriptor. If UsbIo is NULL, then ASSERT(). If HidDescriptor is NULL, then ASSERT(). */ EFI_STATUS EFIAPI UsbGetHidDescriptor(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT8 Interface, OUT EFI_USB...
{ UINT32 Status; EFI_STATUS Result; EFI_USB_DEVICE_REQUEST Request; ASSERT (UsbIo != NULL); ASSERT (HidDescriptor != NULL); Request.RequestType = USB_HID_GET_DESCRIPTOR_REQ_TYPE; Request.Request = USB_REQ_GET_DESCRIPTOR; Request.Value = (UINT16)(USB_DESC_TYPE_HID...
tianocore/edk2
C++
Other
4,240
/* Get the I2C interrupt flag of the specified I2C port. The */
xtBoolean I2CIntFlagGet(unsigned long ulBase)
/* Get the I2C interrupt flag of the specified I2C port. The */ xtBoolean I2CIntFlagGet(unsigned long ulBase)
{ xASSERT((ulBase == I2C0_BASE) || ((ulBase == I2C1_BASE))); return ((xHWREGB(ulBase + I2C_STATUS) & I2C_STATUS_IF) ? xtrue : xfalse); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* For more information, see the application note below on Read-While-Write */
static int flash_mcux_erase(const struct device *dev, off_t offset, size_t len)
/* For more information, see the application note below on Read-While-Write */ static int flash_mcux_erase(const struct device *dev, off_t offset, size_t len)
{ struct flash_priv *priv = dev->data; uint32_t addr; status_t rc; unsigned int key; if (k_sem_take(&priv->write_lock, K_FOREVER)) { return -EACCES; } addr = offset + priv->pflash_block_base; key = irq_lock(); rc = FLASH_Erase(&priv->config, addr, len, kFLASH_ApiEraseKey); irq_unlock(key); k_sem_give(&priv...
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Configures the mono mode for the selected SAI block. */
void SAI_MonoModeConfig(SAI_Block_TypeDef *SAI_Block_x, uint32_t SAI_Mono_StreoMode)
/* Configures the mono mode for the selected SAI block. */ void SAI_MonoModeConfig(SAI_Block_TypeDef *SAI_Block_x, uint32_t SAI_Mono_StreoMode)
{ assert_param(IS_SAI_BLOCK_PERIPH(SAI_Block_x)); assert_param(IS_SAI_BLOCK_MONO_STREO_MODE(SAI_MonoMode)); SAI_Block_x->CR1 &= ~(SAI_xCR1_MONO); SAI_Block_x->CR1 |= SAI_MonoMode; }
MaJerle/stm32f429
C++
null
2,036
/* Often used to find any cpu but smp_processor_id() in a mask. Returns >= nr_cpu_ids if no cpus set. */
int cpumask_any_but(const struct cpumask *mask, unsigned int cpu)
/* Often used to find any cpu but smp_processor_id() in a mask. Returns >= nr_cpu_ids if no cpus set. */ int cpumask_any_but(const struct cpumask *mask, unsigned int cpu)
{ unsigned int i; cpumask_check(cpu); for_each_cpu(i, mask) if (i != cpu) break; return i; }
robutest/uclinux
C++
GPL-2.0
60
/* Configure Timer Counter 0 to generate an interrupt with the specific frequency. */
static void configure_tc(uint32_t freq)
/* Configure Timer Counter 0 to generate an interrupt with the specific frequency. */ static void configure_tc(uint32_t freq)
{ uint32_t ul_div; uint32_t ul_tcclks; uint32_t ul_sysclk = sysclk_get_cpu_hz(); tc_stop(TC0, 0); tc_disable_interrupt(TC0, 0, TC_IER_CPCS); tc_find_mck_divisor(freq, ul_sysclk, &ul_div, &ul_tcclks, ul_sysclk); tc_init(TC0, 0, ul_tcclks | TC_CMR_CPCTRG); tc_write_rc(TC0, 0, (ul_sysclk / ul_div) / 4); NVIC_Enab...
remotemcu/remcu-chip-sdks
C++
null
436
/* This call is used to indicate that the buffer is going to be staled and was an inode buffer. This means it gets special processing during unpin - where any inodes associated with the buffer should be removed from ail. There is also special processing during recovery, any replay of the inodes in the buffer needs to b...
void xfs_trans_stale_inode_buf(xfs_trans_t *tp, xfs_buf_t *bp)
/* This call is used to indicate that the buffer is going to be staled and was an inode buffer. This means it gets special processing during unpin - where any inodes associated with the buffer should be removed from ail. There is also special processing during recovery, any replay of the inodes in the buffer needs to b...
{ xfs_buf_log_item_t *bip; ASSERT(XFS_BUF_ISBUSY(bp)); ASSERT(XFS_BUF_FSPRIVATE2(bp, xfs_trans_t *) == tp); ASSERT(XFS_BUF_FSPRIVATE(bp, void *) != NULL); bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t *); ASSERT(atomic_read(&bip->bli_refcount) > 0); bip->bli_flags |= XFS_BLI_STALE_INODE; bip->bli_item.li_cb = ...
robutest/uclinux
C++
GPL-2.0
60
/* Switch back to polling (used when shutting down the device) */
void mthca_cmd_use_polling(struct mthca_dev *dev)
/* Switch back to polling (used when shutting down the device) */ void mthca_cmd_use_polling(struct mthca_dev *dev)
{ int i; dev->cmd.flags &= ~MTHCA_CMD_USE_EVENTS; for (i = 0; i < dev->cmd.max_cmds; ++i) down(&dev->cmd.event_sem); kfree(dev->cmd.context); up(&dev->cmd.poll_sem); }
robutest/uclinux
C++
GPL-2.0
60
/* Receives a character from the specified port. This function replaces the original UARTCharNonBlockingGet() API and performs the same actions. A macro is provided in */
unsigned long UARTCharGetNonBlocking(unsigned long ulBase)
/* Receives a character from the specified port. This function replaces the original UARTCharNonBlockingGet() API and performs the same actions. A macro is provided in */ unsigned long UARTCharGetNonBlocking(unsigned long ulBase)
{ xtBoolean ulStatus = xfalse; unsigned long ulChar = 0; xASSERT((ulBase == UART0_BASE) || (ulBase == UART1_BASE) || (ulBase == UART2_BASE) ); ulStatus = (xtBoolean) (xHWREGB(ulBase + UART_012_S1) & (unsigned char)(UART_012_S1_RDRF_MASK)); if(xtrue == ulS...
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Enables or Disables the one pulse immediate active function. The */
void Timer1PulseActiveConfigure(unsigned long ulBase, unsigned long ulChannel, unsigned long ulActive)
/* Enables or Disables the one pulse immediate active function. The */ void Timer1PulseActiveConfigure(unsigned long ulBase, unsigned long ulChannel, unsigned long ulActive)
{ xASSERT((ulBase == TIMER1_BASE) || (ulBase == TIMER0_BASE)); xASSERT((ulChannel == TIMER_CH_0) || (ulChannel == TIMER_CH_1) || (ulChannel == TIMER_CH_2) || (ulChannel == TIMER_CH_3)); xASSERT((ulActive == TIMER_ONE_PULSE_ACTIVE_DIS) || (ulActive == TIMER_ONE_PULSE_ACTIVE_EN)); ...
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Enables or disables access to the Backup domain registers. */
void PWR_BackupAccessCmd(FunctionalState NewState)
/* Enables or disables access to the Backup domain registers. */ void PWR_BackupAccessCmd(FunctionalState NewState)
{ assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { PWR->CR |= PWR_CR_DBP; } else { PWR->CR &= (uint32_t)~((uint32_t)PWR_CR_DBP); } }
ajhc/demo-cortex-m3
C++
null
38
/* Clean up the PCI ring buffers allocated to this velocity. */
static void velocity_free_dma_rings(struct velocity_info *vptr)
/* Clean up the PCI ring buffers allocated to this velocity. */ static void velocity_free_dma_rings(struct velocity_info *vptr)
{ const int size = vptr->options.numrx * sizeof(struct rx_desc) + vptr->options.numtx * sizeof(struct tx_desc) * vptr->tx.numq; pci_free_consistent(vptr->pdev, size, vptr->rx.ring, vptr->rx.pool_dma); }
robutest/uclinux
C++
GPL-2.0
60
/* release_slot - free up the memory used by a slot @hotplug_slot: slot to free */
static void release_slot(struct hotplug_slot *hotplug_slot)
/* release_slot - free up the memory used by a slot @hotplug_slot: slot to free */ static void release_slot(struct hotplug_slot *hotplug_slot)
{ struct slot *slot = hotplug_slot->private; dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); kfree(slot->hotplug_slot); kfree(slot); }
robutest/uclinux
C++
GPL-2.0
60
/* See mss_uart.h for details of how to use this function. */
int8_t MSS_UART_tx_complete(mss_uart_instance_t *this_uart)
/* See mss_uart.h for details of how to use this function. */ int8_t MSS_UART_tx_complete(mss_uart_instance_t *this_uart)
{ int8_t ret_value = 0; uint32_t transmit_empty = this_uart->hw_reg_bit->LSR_TEMT; ASSERT( (this_uart == &g_mss_uart0) || (this_uart == &g_mss_uart1) ); if ( ( TX_COMPLETE == this_uart->tx_buff_size ) && transmit_empty ) { ret_value = 1; } return ret_value; }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Initializes TIMER0 module instance. Initializes the TIMER0 module, based on the given configuration values. */
void timer_init(const struct timer_config *config)
/* Initializes TIMER0 module instance. Initializes the TIMER0 module, based on the given configuration values. */ void timer_init(const struct timer_config *config)
{ system_peripheral_reset(PERIPHERAL_TIMER); TIMER0->CTRL.reg = config->interrupt_enable << TIMER_CTRL_INTERRUPT_ENABLE_Pos; TIMER0->RELOAD.reg = config->reload_value; timer_callback = NULL; system_register_isr(RAM_ISR_TABLE_TIMER0_INDEX, (uint32_t)timer_isr_handler); }
memfault/zero-to-main
C++
null
200
/* Set the number of commands to queue per device for the specified host adapter. */
static int advansys_slave_configure(struct scsi_device *sdev)
/* Set the number of commands to queue per device for the specified host adapter. */ static int advansys_slave_configure(struct scsi_device *sdev)
{ struct asc_board *boardp = shost_priv(sdev->host); if (ASC_NARROW_BOARD(boardp)) advansys_narrow_slave_configure(sdev, &boardp->dvc_var.asc_dvc_var); else advansys_wide_slave_configure(sdev, &boardp->dvc_var.adv_dvc_var); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Run the filter code and then cut skb->data to correct size returned by sk_run_filter. If pkt_len is 0 we toss packet. If skb->len is smaller than pkt_len we keep whole skb->data. This is the socket level wrapper to sk_run_filter. It returns 0 if the packet should be accepted or -EPERM if the packet should be tossed....
int sk_filter(struct sock *sk, struct sk_buff *skb)
/* Run the filter code and then cut skb->data to correct size returned by sk_run_filter. If pkt_len is 0 we toss packet. If skb->len is smaller than pkt_len we keep whole skb->data. This is the socket level wrapper to sk_run_filter. It returns 0 if the packet should be accepted or -EPERM if the packet should be tossed....
{ int err; struct sk_filter *filter; err = security_sock_rcv_skb(sk, skb); if (err) return err; rcu_read_lock_bh(); filter = rcu_dereference(sk->sk_filter); if (filter) { unsigned int pkt_len = sk_run_filter(skb, filter->insns, filter->len); err = pkt_len ? pskb_trim(skb, pkt_len) : -EPERM; } rcu_rea...
EmcraftSystems/linux-emcraft
C++
Other
266
/* Reads the device MAC address from the EEPROM and stores the value. Since devices with two ports use the same EEPROM, we increment the last bit in the MAC address for the second port. */
s32 igb_read_mac_addr(struct e1000_hw *hw)
/* Reads the device MAC address from the EEPROM and stores the value. Since devices with two ports use the same EEPROM, we increment the last bit in the MAC address for the second port. */ s32 igb_read_mac_addr(struct e1000_hw *hw)
{ u32 rar_high; u32 rar_low; u16 i; rar_high = rd32(E1000_RAH(0)); rar_low = rd32(E1000_RAL(0)); for (i = 0; i < E1000_RAL_MAC_ADDR_LEN; i++) hw->mac.perm_addr[i] = (u8)(rar_low >> (i*8)); for (i = 0; i < E1000_RAH_MAC_ADDR_LEN; i++) hw->mac.perm_addr[i+4] = (u8)(rar_high >> (i*8)); for (i = 0; i < ETH_ALEN...
robutest/uclinux
C++
GPL-2.0
60
/* Callback invoked when the MTU for a given connection changes */
void btgattc_configure_mtu_callback(int conn_id, int status, int mtu)
/* Callback invoked when the MTU for a given connection changes */ void btgattc_configure_mtu_callback(int conn_id, int status, int mtu)
{ int index = -1; TLS_BT_APPL_TRACE_VERBOSE("%s, status=%d, conn_id=%d,mtu=%d\r\n", __FUNCTION__, status, conn_id,mtu); index = get_app_env_index_by_conn_id(conn_id); if(index<0) { TLS_BT_APPL_TRACE_ERROR("%s, status=%d, conn_id=%d,mtu=%d\r\n", __FUNCTION__, status, conn_id,mtu); return; } TLS_HA...
Nicholas3388/LuaNode
C++
Other
1,055
/* This is the main function: add a bunch of extensions based on a config file section to an extension STACK. */
int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, char *section, STACK_OF(X509_EXTENSION) **sk)
/* This is the main function: add a bunch of extensions based on a config file section to an extension STACK. */ int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, char *section, STACK_OF(X509_EXTENSION) **sk)
{ X509_EXTENSION *ext; STACK_OF(CONF_VALUE) *nval; CONF_VALUE *val; size_t i; if (!(nval = NCONF_get_section(conf, section))) return 0; for (i = 0; i < sk_CONF_VALUE_num(nval); i++) { val = sk_CONF_VALUE_value(nval, i); if (!(ext = X509V3_EXT_nconf(conf, ctx, val->name, v...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Returns either NULL on allocation failure, or a */
struct subprocess_info* call_usermodehelper_setup(char *path, char **argv, char **envp, gfp_t gfp_mask)
/* Returns either NULL on allocation failure, or a */ struct subprocess_info* call_usermodehelper_setup(char *path, char **argv, char **envp, gfp_t gfp_mask)
{ struct subprocess_info *sub_info; sub_info = kzalloc(sizeof(struct subprocess_info), gfp_mask); if (!sub_info) goto out; INIT_WORK(&sub_info->work, __call_usermodehelper); sub_info->path = path; sub_info->argv = argv; sub_info->envp = envp; sub_info->cred = prepare_usermodehelper_creds(); if (!sub_info->cr...
EmcraftSystems/linux-emcraft
C++
Other
266
/* Free the memory associated with the provided EFI_ACPI_TABLE_LIST instance. */
STATIC VOID FreeTableMemory(EFI_ACPI_TABLE_LIST *TableEntry)
/* Free the memory associated with the provided EFI_ACPI_TABLE_LIST instance. */ STATIC VOID FreeTableMemory(EFI_ACPI_TABLE_LIST *TableEntry)
{ if (TableEntry->PoolAllocation) { gBS->FreePool (TableEntry->Table); } else { gBS->FreePages ( (EFI_PHYSICAL_ADDRESS)(UINTN)TableEntry->Table, EFI_SIZE_TO_PAGES (TableEntry->TableSize) ); } }
tianocore/edk2
C++
Other
4,240