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
|
|---|---|---|---|---|---|---|---|
/* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. TIFF Library. Dummy functions to fill the omitted client procedures. */
|
static int _tiffDummyMapProc(thandle_t fd, void **pbase, toff_t *psize)
|
/* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. TIFF Library. Dummy functions to fill the omitted client procedures. */
static int _tiffDummyMapProc(thandle_t fd, void **pbase, toff_t *psize)
|
{
(void) fd; (void) pbase; (void) psize;
return (0);
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* __free_iova - frees the given iova @iovad: iova domain in question. @iova: iova in question. Frees the given iova belonging to the giving domain */
|
void __free_iova(struct iova_domain *iovad, struct iova *iova)
|
/* __free_iova - frees the given iova @iovad: iova domain in question. @iova: iova in question. Frees the given iova belonging to the giving domain */
void __free_iova(struct iova_domain *iovad, struct iova *iova)
|
{
unsigned long flags;
spin_lock_irqsave(&iovad->iova_rbtree_lock, flags);
__cached_rbnode_delete_update(iovad, iova);
rb_erase(&iova->node, &iovad->rbroot);
spin_unlock_irqrestore(&iovad->iova_rbtree_lock, flags);
free_iova_mem(iova);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Determines the physical layer module found on the current adapter. */
|
static s32 ixgbe_identify_phy_82599(struct ixgbe_hw *hw)
|
/* Determines the physical layer module found on the current adapter. */
static s32 ixgbe_identify_phy_82599(struct ixgbe_hw *hw)
|
{
s32 status = IXGBE_ERR_PHY_ADDR_INVALID;
status = ixgbe_identify_phy_generic(hw);
if (status != 0)
status = ixgbe_identify_sfp_module_generic(hw);
return status;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* returns: 0 on busy or 1 on ready state */
|
static int zynq_nand_device_ready(struct mtd_info *mtd)
|
/* returns: 0 on busy or 1 on ready state */
static int zynq_nand_device_ready(struct mtd_info *mtd)
|
{
u32 csr_val;
csr_val = readl(&zynq_nand_smc_base->csr);
if (csr_val & ZYNQ_MEMC_SR_RAW_INT_ST1) {
writel(ZYNQ_MEMC_SR_INT_ST1, &zynq_nand_smc_base->cfr);
return 1;
}
return 0;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* By default, print the specified data out in hex and ASCII. */
|
static void ndo_default_print(netdissect_options *ndo, const u_char *bp, u_int length)
|
/* By default, print the specified data out in hex and ASCII. */
static void ndo_default_print(netdissect_options *ndo, const u_char *bp, u_int length)
|
{
hex_and_ascii_print(ndo, "\n\t", bp, length);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Writes and returns a new value to CR0. 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 AsmWriteCr0(UINTN Cr0)
|
/* Writes and returns a new value to CR0. 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 AsmWriteCr0(UINTN Cr0)
|
{
__asm__ __volatile__ (
"mov %0, %%cr0"
:
: "r" (Cr0)
);
return Cr0;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Returns total memory used by allocator (userdata + metadata) */
|
u64 xv_get_total_size_bytes(struct xv_pool *pool)
|
/* Returns total memory used by allocator (userdata + metadata) */
u64 xv_get_total_size_bytes(struct xv_pool *pool)
|
{
return pool->total_pages << PAGE_SHIFT;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Sun May 11 12:34:56 UTC 2003 Clemens Ladisch */
|
irqreturn_t snd_sb8dsp_midi_interrupt(struct snd_sb *chip)
|
/* Sun May 11 12:34:56 UTC 2003 Clemens Ladisch */
irqreturn_t snd_sb8dsp_midi_interrupt(struct snd_sb *chip)
|
{
struct snd_rawmidi *rmidi;
int max = 64;
char byte;
if (!chip)
return IRQ_NONE;
rmidi = chip->rmidi;
if (!rmidi) {
inb(SBP(chip, DATA_AVAIL));
return IRQ_NONE;
}
spin_lock(&chip->midi_input_lock);
while (max-- > 0) {
if (inb(SBP(chip, DATA_AVAIL)) & 0x80) {
byte = inb(SBP(chip, READ));
if (chip->open & SB_OPEN_MIDI_INPUT_TRIGGER) {
snd_rawmidi_receive(chip->midi_substream_input, &byte, 1);
}
}
}
spin_unlock(&chip->midi_input_lock);
return IRQ_HANDLED;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* The driver entry point which installs multiple protocols to the ImageHandle. */
|
EFI_STATUS EFIAPI Mtftp4DriverEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
|
/* The driver entry point which installs multiple protocols to the ImageHandle. */
EFI_STATUS EFIAPI Mtftp4DriverEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
|
{
return EfiLibInstallDriverBindingComponentName2 (
ImageHandle,
SystemTable,
&gMtftp4DriverBinding,
ImageHandle,
&gMtftp4ComponentName,
&gMtftp4ComponentName2
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Return 0 on success and -errno in error cases. -EAGAIN means that the function has been waiting for another request and the allocation must be restarted, but the whole request should not be failed. */
|
static int do_alloc_cluster_offset(BlockDriverState *bs, uint64_t guest_offset, uint64_t *host_offset, unsigned int *nb_clusters)
|
/* Return 0 on success and -errno in error cases. -EAGAIN means that the function has been waiting for another request and the allocation must be restarted, but the whole request should not be failed. */
static int do_alloc_cluster_offset(BlockDriverState *bs, uint64_t guest_offset, uint64_t *host_offset, unsigned int *nb_clusters)
|
{
BDRVQcowState *s = bs->opaque;
trace_qcow2_do_alloc_clusters_offset(qemu_coroutine_self(), guest_offset,
*host_offset, *nb_clusters);
trace_qcow2_cluster_alloc_phys(qemu_coroutine_self());
if (*host_offset == 0) {
int64_t cluster_offset =
qcow2_alloc_clusters(bs, *nb_clusters * s->cluster_size);
if (cluster_offset < 0) {
return cluster_offset;
}
*host_offset = cluster_offset;
return 0;
} else {
int ret = qcow2_alloc_clusters_at(bs, *host_offset, *nb_clusters);
if (ret < 0) {
return ret;
}
*nb_clusters = ret;
return 0;
}
}
|
ve3wwg/teensy3_qemu
|
C++
|
Other
| 15
|
/* Generic bitmap get function used in 'font->get_bitmap' when the font contains all characters in the range */
|
const uint8_t* lv_font_get_bitmap_continuous(const lv_font_t *font, uint32_t unicode_letter)
|
/* Generic bitmap get function used in 'font->get_bitmap' when the font contains all characters in the range */
const uint8_t* lv_font_get_bitmap_continuous(const lv_font_t *font, uint32_t unicode_letter)
|
{
if(unicode_letter < font->unicode_first || unicode_letter > font->unicode_last) return NULL;
uint32_t index = (unicode_letter - font->unicode_first);
return &font->glyph_bitmap[font->glyph_dsc[index].glyph_index];
}
|
RavenSystem/esp-homekit-devices
|
C++
|
Other
| 2,577
|
/* No need to exit to userspace if we already have an interrupt queued. */
|
static int dm_request_for_irq_injection(struct kvm_vcpu *vcpu)
|
/* No need to exit to userspace if we already have an interrupt queued. */
static int dm_request_for_irq_injection(struct kvm_vcpu *vcpu)
|
{
return (!irqchip_in_kernel(vcpu->kvm) && !kvm_cpu_has_interrupt(vcpu) &&
vcpu->run->request_interrupt_window &&
kvm_arch_interrupt_allowed(vcpu));
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Local function to send a command to the USB protocol engine and read data */
|
static unsigned char USBHwCmdRead(unsigned char bCmd)
|
/* Local function to send a command to the USB protocol engine and read data */
static unsigned char USBHwCmdRead(unsigned char bCmd)
|
{
USBHwCmd(bCmd);
LPC_USB->USBCmdCode = 0x00000200 | (bCmd << 16);
Wait4DevInt(CDFULL);
return LPC_USB->USBCmdData;
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* Reset parameters and call scsi_done for data->cur_lunt. Be careful setting SCpnt->result = DID_* before calling this function. */
|
static void nsp32_scsi_done(struct scsi_cmnd *)
|
/* Reset parameters and call scsi_done for data->cur_lunt. Be careful setting SCpnt->result = DID_* before calling this function. */
static void nsp32_scsi_done(struct scsi_cmnd *)
|
{
nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata;
unsigned int base = SCpnt->device->host->io_port;
scsi_dma_unmap(SCpnt);
nsp32_write2(base, TRANSFER_CONTROL, 0);
nsp32_write4(base, BM_CNT, 0);
(*SCpnt->scsi_done)(SCpnt);
data->cur_lunt->SCpnt = NULL;
data->cur_lunt = NULL;
data->cur_target = NULL;
data->CurrentSC = NULL;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Set the device's configuration. This function changes the device's internal state. UsbSelectConfig changes the Usb bus's internal state. */
|
EFI_STATUS UsbSetConfig(IN USB_DEVICE *UsbDev, IN UINT8 ConfigIndex)
|
/* Set the device's configuration. This function changes the device's internal state. UsbSelectConfig changes the Usb bus's internal state. */
EFI_STATUS UsbSetConfig(IN USB_DEVICE *UsbDev, IN UINT8 ConfigIndex)
|
{
EFI_STATUS Status;
Status = UsbCtrlRequest (
UsbDev,
EfiUsbNoData,
USB_REQ_TYPE_STANDARD,
USB_TARGET_DEVICE,
USB_REQ_SET_CONFIG,
ConfigIndex,
0,
NULL,
0
);
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* ic3_shutdown - shut down the port - free irq and disable @port: port to shut down */
|
static void ic3_shutdown(struct uart_port *the_port)
|
/* ic3_shutdown - shut down the port - free irq and disable @port: port to shut down */
static void ic3_shutdown(struct uart_port *the_port)
|
{
unsigned long port_flags;
struct ioc3_port *port;
struct uart_state *state;
port = get_ioc3_port(the_port);
if (!port)
return;
state = the_port->state;
wake_up_interruptible(&state->port.delta_msr_wait);
spin_lock_irqsave(&the_port->lock, port_flags);
set_notification(port, N_ALL, 0);
spin_unlock_irqrestore(&the_port->lock, port_flags);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* MSS_SPI_set_slave_select() See "mss_spi.h" for details of how to use this function. */
|
void MSS_SPI_set_slave_select(mss_spi_instance_t *this_spi, mss_spi_slave_t slave)
|
/* MSS_SPI_set_slave_select() See "mss_spi.h" for details of how to use this function. */
void MSS_SPI_set_slave_select(mss_spi_instance_t *this_spi, mss_spi_slave_t slave)
|
{
ASSERT( (this_spi == &g_mss_spi0) || (this_spi == &g_mss_spi1) );
ASSERT( this_spi->hw_reg_bit->CTRL_MASTER == MSS_SPI_MODE_MASTER );
ASSERT( this_spi->slaves_cfg[slave].ctrl_reg != NOT_CONFIGURED );
this_spi->hw_reg_bit->CTRL_ENABLE = 0U;
this_spi->hw_reg->CONTROL = this_spi->slaves_cfg[slave].ctrl_reg;
this_spi->hw_reg->CLK_GEN = this_spi->slaves_cfg[slave].clk_gen;
this_spi->hw_reg->TXRXDF_SIZE = this_spi->slaves_cfg[slave].txrxdf_size_reg;
this_spi->hw_reg_bit->CTRL_ENABLE = 1U;
this_spi->hw_reg->SLAVE_SELECT |= ((uint32_t)1 << (uint32_t)slave);
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* VTOpen-Request ::= SEQUENCE { vtClass BACnetVTClass, localVTSessionIdentifier Unsigned8 } */
|
static guint fVtOpenRequest(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
|
/* VTOpen-Request ::= SEQUENCE { vtClass BACnetVTClass, localVTSessionIdentifier Unsigned8 } */
static guint fVtOpenRequest(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
|
{
offset = fApplicationTypesEnumerated(tvb, pinfo, tree, offset,
"vtClass: ", BACnetVTClass);
return fApplicationTypes(tvb, pinfo, tree, offset, "local VT Session ID: ");
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* \classmethod \constructor(id, ...) Construct a new timer object of the given id. If additional arguments are given, then the timer is initialised by */
|
STATIC mp_obj_t pyb_timer_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args)
|
/* \classmethod \constructor(id, ...) Construct a new timer object of the given id. If additional arguments are given, then the timer is initialised by */
STATIC mp_obj_t pyb_timer_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args)
|
{
tim = m_new_obj(pyb_timer_obj_t);
memset(tim, 0, sizeof(*tim));
tim->base.type = &pyb_timer_type;
tim->tim_id = tim_id;
tim->callback = mp_const_none;
MP_STATE_PORT(pyb_timer_obj_all)[tim_id - 1] = tim;
} else {
tim = MP_STATE_PORT(pyb_timer_obj_all)[tim_id - 1];
}
if (n_args > 1 || n_kw > 0) {
mp_map_t kw_args;
mp_map_init_fixed_table(&kw_args, n_kw, args + n_args);
pyb_timer_init_helper(tim, n_args - 1, args + 1, &kw_args);
}
return MP_OBJ_FROM_PTR(tim);
}
|
micropython/micropython
|
C++
|
Other
| 18,334
|
/* This function is the implementation of SPI2 handler named in startup code.
It passes the instance to the shared DSPI IRQ handler. */
|
void SPI2_IRQHandler(void)
|
/* This function is the implementation of SPI2 handler named in startup code.
It passes the instance to the shared DSPI IRQ handler. */
void SPI2_IRQHandler(void)
|
{
DSPI_DRV_IRQHandler(SPI2_IDX);
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Note we don't actually disable the device until all callers of pci_device_enable() have called pci_device_disable(). */
|
void pci_disable_device(struct pci_dev *dev)
|
/* Note we don't actually disable the device until all callers of pci_device_enable() have called pci_device_disable(). */
void pci_disable_device(struct pci_dev *dev)
|
{
struct pci_devres *dr;
dr = find_pci_dr(dev);
if (dr)
dr->enabled = 0;
if (atomic_sub_return(1, &dev->enable_cnt) != 0)
return;
do_pci_disable_device(dev);
dev->is_busmaster = 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Helper function for calculating gyroscope ranges. Considers the current full-scale register config. */
|
static void icm42688_emul_get_gyro_ranges(const struct emul *target, q31_t *lower, q31_t *upper, q31_t *epsilon, int8_t *shift)
|
/* Helper function for calculating gyroscope ranges. Considers the current full-scale register config. */
static void icm42688_emul_get_gyro_ranges(const struct emul *target, q31_t *lower, q31_t *upper, q31_t *epsilon, int8_t *shift)
|
{
int fs_mdps;
int sensitivity;
icm42688_emul_get_gyro_settings(target, &fs_mdps, &sensitivity, shift);
fs_mdps *= 0.99;
*epsilon = (3 * SENSOR_PI * Q31_SCALE * 10LL / 1000000LL / 180LL / sensitivity / 2LL) >>
*shift;
*upper = (((fs_mdps * SENSOR_PI / 1000000LL) * Q31_SCALE) / 1000LL / 180LL) >> *shift;
*lower = -*upper;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Convert FvHandle and DriverName into an EFI device path */
|
EFI_DEVICE_PATH_PROTOCOL * CoreFvToDevicePath(IN EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv, IN EFI_HANDLE FvHandle, IN EFI_GUID *DriverName)
|
/* Convert FvHandle and DriverName into an EFI device path */
EFI_DEVICE_PATH_PROTOCOL * CoreFvToDevicePath(IN EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv, IN EFI_HANDLE FvHandle, IN EFI_GUID *DriverName)
|
{
EFI_STATUS Status;
EFI_DEVICE_PATH_PROTOCOL *FvDevicePath;
EFI_DEVICE_PATH_PROTOCOL *FileNameDevicePath;
Status = CoreHandleProtocol (FvHandle, &gEfiDevicePathProtocolGuid, (VOID **)&FvDevicePath);
if (EFI_ERROR (Status)) {
FileNameDevicePath = NULL;
} else {
EfiInitializeFwVolDevicepathNode (&mFvDevicePath.File, DriverName);
SetDevicePathEndNode (&mFvDevicePath.End);
FileNameDevicePath = AppendDevicePath (
FvDevicePath,
(EFI_DEVICE_PATH_PROTOCOL *)&mFvDevicePath
);
}
return FileNameDevicePath;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This function retrieves a memory region starting from a given base address. */
|
EFI_STATUS GetMemoryRegion(IN OUT UINTN *BaseAddress, OUT UINTN *RegionLength, OUT UINTN *RegionAttributes)
|
/* This function retrieves a memory region starting from a given base address. */
EFI_STATUS GetMemoryRegion(IN OUT UINTN *BaseAddress, OUT UINTN *RegionLength, OUT UINTN *RegionAttributes)
|
{
EFI_STATUS Status;
UINT64 *TranslationTable;
UINTN TableLevel;
UINTN EntryCount;
UINTN T0SZ;
if ((BaseAddress == NULL) || (RegionLength == NULL) || (RegionAttributes == NULL)) {
ASSERT ((BaseAddress != NULL) && (RegionLength != NULL) && (RegionAttributes != NULL));
return EFI_INVALID_PARAMETER;
}
TranslationTable = ArmGetTTBR0BaseAddress ();
*RegionLength = 0;
*RegionAttributes = 0;
T0SZ = ArmGetTCR () & TCR_T0SZ_MASK;
GetRootTranslationTableInfo (T0SZ, &TableLevel, &EntryCount);
Status = GetMemoryRegionRec (
TranslationTable,
TableLevel,
(UINTN *)TT_LAST_BLOCK_ADDRESS (TranslationTable, EntryCount),
BaseAddress,
RegionLength,
RegionAttributes
);
if ((Status == EFI_NOT_FOUND) && (*RegionLength > 0)) {
return EFI_SUCCESS;
}
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Returns true if @buffer possibly be a domainname, false otherwise. */
|
bool tomoyo_is_domain_def(const unsigned char *buffer)
|
/* Returns true if @buffer possibly be a domainname, false otherwise. */
bool tomoyo_is_domain_def(const unsigned char *buffer)
|
{
return !strncmp(buffer, TOMOYO_ROOT_NAME, TOMOYO_ROOT_NAME_LEN);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* ADC Set the Injected Channel Data Offset.
This value is subtracted from the injected channel results after conversion is complete, and can result in negative results. A separate value can be specified for each injected data register. */
|
void adc_set_injected_offset(uint32_t adc, uint8_t reg, uint32_t offset)
|
/* ADC Set the Injected Channel Data Offset.
This value is subtracted from the injected channel results after conversion is complete, and can result in negative results. A separate value can be specified for each injected data register. */
void adc_set_injected_offset(uint32_t adc, uint8_t reg, uint32_t offset)
|
{
switch (reg) {
case 1:
ADC_OFR1(adc) |= ADC_OFR1_OFFSET1_EN;
ADC_OFR1(adc) |= offset;
break;
case 2:
ADC_OFR2(adc) |= ADC_OFR2_OFFSET2_EN;
ADC_OFR2(adc) |= offset;
break;
case 3:
ADC_OFR3(adc) |= ADC_OFR3_OFFSET3_EN;
ADC_OFR3(adc) |= offset;
break;
case 4:
ADC_OFR4(adc) |= ADC_OFR4_OFFSET4_EN;
ADC_OFR4(adc) |= offset;
break;
}
}
|
insane-adding-machines/unicore-mx
|
C++
|
GNU General Public License v3.0
| 50
|
/* Emit code for binary expressions that "produce values" (everything but logical operators 'and'/'or' and comparison operators). Expression to produce final result will be encoded in 'e1'. Because 'luaK_exp2RK' can free registers, its calls must be in "stack order" (that is, first on 'e2', which may have more recent registers to be released). */
|
static void codebinexpval(FuncState *fs, OpCode op, expdesc *e1, expdesc *e2, int line)
|
/* Emit code for binary expressions that "produce values" (everything but logical operators 'and'/'or' and comparison operators). Expression to produce final result will be encoded in 'e1'. Because 'luaK_exp2RK' can free registers, its calls must be in "stack order" (that is, first on 'e2', which may have more recent registers to be released). */
static void codebinexpval(FuncState *fs, OpCode op, expdesc *e1, expdesc *e2, int line)
|
{
int rk2 = luaK_exp2RK(fs, e2);
int rk1 = luaK_exp2RK(fs, e1);
freeexps(fs, e1, e2);
e1->u.info = luaK_codeABC(fs, op, 0, rk1, rk2);
e1->k = VRELOCABLE;
luaK_addlineinfo(fs, fs->pc -1, line);
}
|
nodemcu/nodemcu-firmware
|
C++
|
MIT License
| 7,566
|
/* Get fuses from user row.
Read out the fuse settings from the user row. */
|
enum status_code nvm_get_fuses(struct nvm_fusebits *fusebits)
|
/* Get fuses from user row.
Read out the fuse settings from the user row. */
enum status_code nvm_get_fuses(struct nvm_fusebits *fusebits)
|
{
enum status_code error_code = STATUS_OK;
uint32_t raw_fusebits[2];
while (!nvm_is_ready()) {
}
((uint16_t*)&raw_fusebits)[0] = (uint16_t)NVM_MEMORY[NVMCTRL_USER / 2];
((uint16_t*)&raw_fusebits)[1] = (uint16_t)NVM_MEMORY[(NVMCTRL_USER / 2) + 1];
((uint16_t*)&raw_fusebits)[2] = (uint16_t)NVM_MEMORY[(NVMCTRL_USER / 2) + 2];
((uint16_t*)&raw_fusebits)[3] = (uint16_t)NVM_MEMORY[(NVMCTRL_USER / 2) + 3];
_nvm_translate_raw_fusebits_to_struct(raw_fusebits, fusebits);
return error_code;
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* Returns: the new start of the #GSList, without the element */
|
GSList* g_slist_remove_link(GSList *list, GSList *link_)
|
/* Returns: the new start of the #GSList, without the element */
GSList* g_slist_remove_link(GSList *list, GSList *link_)
|
{
return _g_slist_remove_link (list, link_);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* blk_init_tags - initialize the tag info for an external tag map @depth: the maximum queue depth supported */
|
struct blk_queue_tag* blk_init_tags(int depth)
|
/* blk_init_tags - initialize the tag info for an external tag map @depth: the maximum queue depth supported */
struct blk_queue_tag* blk_init_tags(int depth)
|
{
return __blk_queue_init_tags(NULL, depth);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* introduce function I3C_TransferStateMachineWaitForCompletionState. This function was deal with Wait For Completion State. */
|
static void I3C_TransferStateMachineWaitForCompletionState(i3c_master_handle_t *handle, i3c_master_state_machine_param_t *stateParams)
|
/* introduce function I3C_TransferStateMachineWaitForCompletionState. This function was deal with Wait For Completion State. */
static void I3C_TransferStateMachineWaitForCompletionState(i3c_master_handle_t *handle, i3c_master_state_machine_param_t *stateParams)
|
{
if (0UL != (stateParams->status & (uint32_t)kI3C_MasterCompleteFlag))
{
handle->state = (uint8_t)kStopState;
}
else
{
stateParams->state_complete = true;
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* This is done by changing the page table attribute to be NOT PRSENT. */
|
VOID EFIAPI SetGuardPage(IN EFI_PHYSICAL_ADDRESS BaseAddress)
|
/* This is done by changing the page table attribute to be NOT PRSENT. */
VOID EFIAPI SetGuardPage(IN EFI_PHYSICAL_ADDRESS BaseAddress)
|
{
EFI_STATUS Status;
if (gCpu == NULL) {
return;
}
mOnGuarding = TRUE;
Status = gCpu->SetMemoryAttributes (gCpu, BaseAddress, EFI_PAGE_SIZE, EFI_MEMORY_RP);
ASSERT_EFI_ERROR (Status);
mOnGuarding = FALSE;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Returns the default channel for a regulatory domain */
|
static int iw_default_channel(int reg_domain)
|
/* Returns the default channel for a regulatory domain */
static int iw_default_channel(int reg_domain)
|
{
int i, rc = 1;
for (i = 0; i < ARRAY_SIZE(iw_channel_table); i++)
if (reg_domain == iw_channel_table[i].reg_domain) {
rc = iw_channel_table[i].deflt;
break;
}
return rc;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Initialize the serial port with the given baudrate. The settings are always 8 data bits, no parity, 1 stop bit, no start bits. */
|
static int pic32_serial_init(void __iomem *base, ulong clk, u32 baudrate)
|
/* Initialize the serial port with the given baudrate. The settings are always 8 data bits, no parity, 1 stop bit, no start bits. */
static int pic32_serial_init(void __iomem *base, ulong clk, u32 baudrate)
|
{
u32 div = DIV_ROUND_CLOSEST(clk, baudrate * 16);
wait_for_bit_le32(base + U_STA, UART_TX_EMPTY,
true, CONFIG_SYS_HZ, false);
writel(UART_TX_BRK, base + U_STASET);
writel(0, base + U_MOD);
writel(0, base + U_STA);
writel(div - 1, base + U_BRG);
writel(UART_TX_ENABLE | UART_RX_ENABLE, base + U_STASET);
writel(UART_ENABLE, base + U_MODSET);
return 0;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* The peripheral clock is the same as the processor clock. The frequency of the system clock is the value returned by SysCtlClockGet(), or it can be explicitly hard coded if it is constant and known (to save the code/execution overhead of a call to SysCtlClockGet()). */
|
void UARTConfigSetExpClk(unsigned long ulBase, unsigned long ulUARTClk, unsigned long ulBaud, unsigned long ulConfig)
|
/* The peripheral clock is the same as the processor clock. The frequency of the system clock is the value returned by SysCtlClockGet(), or it can be explicitly hard coded if it is constant and known (to save the code/execution overhead of a call to SysCtlClockGet()). */
void UARTConfigSetExpClk(unsigned long ulBase, unsigned long ulUARTClk, unsigned long ulBaud, unsigned long ulConfig)
|
{
unsigned long ulDiv;
ASSERT(UARTBaseValid(ulBase));
ASSERT(ulBaud != 0);
UARTDisable(ulBase);
if((ulBaud * 16) > ulUARTClk)
{
HWREG(ulBase + UART_O_CTL) |= UART_CTL_HSE;
ulBaud /= 2;
}
else
{
HWREG(ulBase + UART_O_CTL) &= ~(UART_CTL_HSE);
}
ulDiv = (((ulUARTClk * 8) / ulBaud) + 1) / 2;
HWREG(ulBase + UART_O_IBRD) = ulDiv / 64;
HWREG(ulBase + UART_O_FBRD) = ulDiv % 64;
HWREG(ulBase + UART_O_LCRH) = ulConfig;
HWREG(ulBase + UART_O_FR) = 0;
UARTEnable(ulBase);
}
|
micropython/micropython
|
C++
|
Other
| 18,334
|
/* If any reserved bits in Address are set, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). */
|
UINT16 EFIAPI S3PciSegmentOr16(IN UINT64 Address, IN UINT16 OrData)
|
/* If any reserved bits in Address are set, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). */
UINT16 EFIAPI S3PciSegmentOr16(IN UINT64 Address, IN UINT16 OrData)
|
{
return InternalSavePciSegmentWrite16ValueToBootScript (Address, PciSegmentOr16 (Address, OrData));
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* r e a d O Q P d i m e n s i o n s */
|
BEGIN_NAMESPACE_QPOASES returnValue readOQPdimensions(const char *path, int *nQP, int *nV, int *nC, int *nEC)
|
/* r e a d O Q P d i m e n s i o n s */
BEGIN_NAMESPACE_QPOASES returnValue readOQPdimensions(const char *path, int *nQP, int *nV, int *nC, int *nEC)
|
{
int dims[4];
char filename[QPOASES_MAX_STRING_LENGTH];
snprintf( filename,QPOASES_MAX_STRING_LENGTH,"%sdims.oqp",path );
if ( qpOASES_readFromFileI( dims,4,filename ) != SUCCESSFUL_RETURN )
return THROWERROR( RET_UNABLE_TO_READ_FILE );
*nQP = dims[0];
*nV = dims[1];
*nC = dims[2];
*nEC = dims[3];
if ( ( *nQP <= 0 ) || ( *nV <= 0 ) || ( *nC < 0 ) || ( *nEC < 0 ) )
return THROWERROR( RET_FILEDATA_INCONSISTENT );
if ( ( *nV > NVMAX ) || ( *nC > NCMAX ) || ( *nQP > NQPMAX ) )
return THROWERROR( RET_UNABLE_TO_READ_BENCHMARK );
return SUCCESSFUL_RETURN;
}
|
DanielMartensson/EmbeddedLapack
|
C++
|
MIT License
| 129
|
/* Set the 'next node pointer' of a node */
|
static void node_set_next(lv_ll_t *ll_p, lv_ll_node_t *act, lv_ll_node_t *next)
|
/* Set the 'next node pointer' of a node */
static void node_set_next(lv_ll_t *ll_p, lv_ll_node_t *act, lv_ll_node_t *next)
|
{
if(act == NULL) return;
uint32_t node_p_size = sizeof(lv_ll_node_t *);
if(next) memcpy(act + LL_NEXT_P_OFFSET(ll_p), &next, node_p_size);
else memset(act + LL_NEXT_P_OFFSET(ll_p), 0, node_p_size);
}
|
RavenSystem/esp-homekit-devices
|
C++
|
Other
| 2,577
|
/* find an ordered extent corresponding to file_offset. return NULL if nothing is found, otherwise take a reference on the extent and return it */
|
struct btrfs_ordered_extent* btrfs_lookup_ordered_extent(struct inode *inode, u64 file_offset)
|
/* find an ordered extent corresponding to file_offset. return NULL if nothing is found, otherwise take a reference on the extent and return it */
struct btrfs_ordered_extent* btrfs_lookup_ordered_extent(struct inode *inode, u64 file_offset)
|
{
struct btrfs_ordered_inode_tree *tree;
struct rb_node *node;
struct btrfs_ordered_extent *entry = NULL;
tree = &BTRFS_I(inode)->ordered_tree;
mutex_lock(&tree->mutex);
node = tree_search(tree, file_offset);
if (!node)
goto out;
entry = rb_entry(node, struct btrfs_ordered_extent, rb_node);
if (!offset_in_entry(entry, file_offset))
entry = NULL;
if (entry)
atomic_inc(&entry->refs);
out:
mutex_unlock(&tree->mutex);
return entry;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Return: The number of bytes transmitted on success or a negative error code on failure. */
|
ssize_t mipi_dsi_generic_write(struct mipi_dsi_device *dsi, const void *payload, size_t size)
|
/* Return: The number of bytes transmitted on success or a negative error code on failure. */
ssize_t mipi_dsi_generic_write(struct mipi_dsi_device *dsi, const void *payload, size_t size)
|
{
struct mipi_dsi_msg msg = {
.channel = dsi->channel,
.tx_buf = payload,
.tx_len = size
};
switch (size) {
case 0:
msg.type = MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM;
break;
case 1:
msg.type = MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM;
break;
case 2:
msg.type = MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM;
break;
default:
msg.type = MIPI_DSI_GENERIC_LONG_WRITE;
break;
}
return mipi_dsi_device_transfer(dsi, &msg);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* ENET Rx function enable (include MAC and DMA module) */
|
void enet_rx_enable(void)
|
/* ENET Rx function enable (include MAC and DMA module) */
void enet_rx_enable(void)
|
{
ENET_MAC_CFG |= ENET_MAC_CFG_REN;
ENET_DMA_CTL |= ENET_DMA_CTL_SRE;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Generate a challenge response, given an eight byte challenge and either the NT or the Lan Manager password hash (16 bytes). Returns output in response, which is expected to be 24 bytes. */
|
static int ntlmssp_generate_challenge_response(guint8 *response, const guint8 *passhash, const guint8 *challenge)
|
/* Generate a challenge response, given an eight byte challenge and either the NT or the Lan Manager password hash (16 bytes). Returns output in response, which is expected to be 24 bytes. */
static int ntlmssp_generate_challenge_response(guint8 *response, const guint8 *passhash, const guint8 *challenge)
|
{
guint8 pw21[21];
memset(pw21, 0x0, sizeof(pw21));
memcpy(pw21, passhash, 16);
memset(response, 0, 24);
crypt_des_ecb(response, challenge, pw21, 1);
crypt_des_ecb(response + 8, challenge, pw21 + 7, 1);
crypt_des_ecb(response + 16, challenge, pw21 + 14, 1);
return 1;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* s e t C o n s t r a i n t P r o d u c t */
|
returnValue QProblem_setConstraintProduct(QProblem *_THIS, ConstraintProduct _constraintProduct)
|
/* s e t C o n s t r a i n t P r o d u c t */
returnValue QProblem_setConstraintProduct(QProblem *_THIS, ConstraintProduct _constraintProduct)
|
{
_THIS->constraintProduct = _constraintProduct;
return SUCCESSFUL_RETURN;
}
|
DanielMartensson/EmbeddedLapack
|
C++
|
MIT License
| 129
|
/* If Buffer is NULL, then ASSERT(). If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). */
|
UINT8 EFIAPI CalculateCheckSum8(IN CONST UINT8 *Buffer, IN UINTN Length)
|
/* If Buffer is NULL, then ASSERT(). If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). */
UINT8 EFIAPI CalculateCheckSum8(IN CONST UINT8 *Buffer, IN UINTN Length)
|
{
UINT8 CheckSum;
CheckSum = CalculateSum8 (Buffer, Length);
return (UINT8)(0x100 - CheckSum);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Return 0 on success, an error code on failure. (Based on the results of appraise_measurement().) */
|
int ima_bprm_check(struct linux_binprm *bprm)
|
/* Return 0 on success, an error code on failure. (Based on the results of appraise_measurement().) */
int ima_bprm_check(struct linux_binprm *bprm)
|
{
int rc;
rc = process_measurement(bprm->file, bprm->filename,
MAY_EXEC, BPRM_CHECK);
return 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* This function checks if the battery input voltage is higher than 3.6V and therefore allows the system to successfully boot using this power source. */
|
static int mxs_is_batt_ready(void)
|
/* This function checks if the battery input voltage is higher than 3.6V and therefore allows the system to successfully boot using this power source. */
static int mxs_is_batt_ready(void)
|
{
return (mxs_get_batt_volt() >= 3600);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* If we can't use the TSC, the kernel falls back to our lower-priority "lguest_clock", where we read the time value given to us by the Host. */
|
static cycle_t lguest_clock_read(struct clocksource *cs)
|
/* If we can't use the TSC, the kernel falls back to our lower-priority "lguest_clock", where we read the time value given to us by the Host. */
static cycle_t lguest_clock_read(struct clocksource *cs)
|
{
unsigned long sec, nsec;
do {
sec = lguest_data.time.tv_sec;
rmb();
nsec = lguest_data.time.tv_nsec;
rmb();
} while (unlikely(lguest_data.time.tv_sec != sec));
return sec*1000000000ULL + nsec;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* param base Pointer to FLEXIO_UART_Type param handle Pointer to flexio_uart_edma_handle_t structure param count Number of bytes received so far by the non-blocking transaction. retval kStatus_NoTransferInProgress transfer has finished or no transfer in progress. retval kStatus_Success Successfully return the count. */
|
status_t FLEXIO_UART_TransferGetReceiveCountEDMA(FLEXIO_UART_Type *base, flexio_uart_edma_handle_t *handle, size_t *count)
|
/* param base Pointer to FLEXIO_UART_Type param handle Pointer to flexio_uart_edma_handle_t structure param count Number of bytes received so far by the non-blocking transaction. retval kStatus_NoTransferInProgress transfer has finished or no transfer in progress. retval kStatus_Success Successfully return the count. */
status_t FLEXIO_UART_TransferGetReceiveCountEDMA(FLEXIO_UART_Type *base, flexio_uart_edma_handle_t *handle, size_t *count)
|
{
assert(handle != NULL);
assert(handle->rxEdmaHandle != NULL);
assert(count != NULL);
if ((uint8_t)kFLEXIO_UART_RxIdle == handle->rxState)
{
return kStatus_NoTransferInProgress;
}
*count = handle->rxDataSizeAll -
(uint32_t)handle->nbytes *
EDMA_GetRemainingMajorLoopCount(handle->rxEdmaHandle->base, handle->rxEdmaHandle->channel);
return kStatus_Success;
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* task_lock() is needed to prevent the race with refrigerator() which may occur if the freezing of tasks fails. Namely, without the lock, if the freezing of tasks failed, thaw_tasks() might have run before a task in refrigerator() could call frozen_process(), in which case the task would be frozen and no one would thaw it. */
|
int thaw_process(struct task_struct *p)
|
/* task_lock() is needed to prevent the race with refrigerator() which may occur if the freezing of tasks fails. Namely, without the lock, if the freezing of tasks failed, thaw_tasks() might have run before a task in refrigerator() could call frozen_process(), in which case the task would be frozen and no one would thaw it. */
int thaw_process(struct task_struct *p)
|
{
task_lock(p);
if (__thaw_process(p) == 1) {
task_unlock(p);
wake_up_process(p);
return 1;
}
task_unlock(p);
return 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Refresh the style of all children of an object. (Called recursively) */
|
static void report_style_mod_core(void *style_p, lv_obj_t *obj)
|
/* Refresh the style of all children of an object. (Called recursively) */
static void report_style_mod_core(void *style_p, lv_obj_t *obj)
|
{
lv_obj_t * i;
LV_LL_READ(obj->child_ll, i)
{
if(i->style_p == style_p || style_p == NULL) {
refresh_children_style(i);
lv_obj_refresh_style(i);
}
report_style_mod_core(style_p, i);
}
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* Flushes the ADC pipeline.
Flushes the pipeline and restarts the ADC clock on the next peripheral clock edge. All conversions in progress will be lost. When flush is complete, the module will resume where it left off. */
|
void adc_flush(struct adc_module *const module_inst)
|
/* Flushes the ADC pipeline.
Flushes the pipeline and restarts the ADC clock on the next peripheral clock edge. All conversions in progress will be lost. When flush is complete, the module will resume where it left off. */
void adc_flush(struct adc_module *const module_inst)
|
{
Assert(module_inst);
Assert(module_inst->hw);
Adc *const adc_module = module_inst->hw;
while (adc_is_syncing(module_inst)) {
}
adc_module->SWTRIG.reg |= ADC_SWTRIG_FLUSH;
while (adc_is_syncing(module_inst)) {
}
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Returns: (transfer full) (type _GFreedesktopDBusSkeleton): The skeleton object. */
|
_GFreedesktopDBus* _g_freedesktop_dbus_skeleton_new(void)
|
/* Returns: (transfer full) (type _GFreedesktopDBusSkeleton): The skeleton object. */
_GFreedesktopDBus* _g_freedesktop_dbus_skeleton_new(void)
|
{
return _G_FREEDESKTOP_DBUS (g_object_new (_G_TYPE_FREEDESKTOP_DBUS_SKELETON, NULL));
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Return the number of bytes of space available in the circular buffer. */
|
static unsigned gs_buf_space_avail(struct gs_buf *gb)
|
/* Return the number of bytes of space available in the circular buffer. */
static unsigned gs_buf_space_avail(struct gs_buf *gb)
|
{
return (gb->buf_size + gb->buf_get - gb->buf_put - 1) % gb->buf_size;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Simply call tioce_do_dma_map() to create a map with the barrier bit set in the address. */
|
static u64 tioce_dma_consistent(struct pci_dev *pdev, unsigned long paddr, size_t byte_count, int dma_flags)
|
/* Simply call tioce_do_dma_map() to create a map with the barrier bit set in the address. */
static u64 tioce_dma_consistent(struct pci_dev *pdev, unsigned long paddr, size_t byte_count, int dma_flags)
|
{
return tioce_do_dma_map(pdev, paddr, byte_count, 1, dma_flags);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* If this peer is monitored, this function sends an upcall to tell the local rpc.statd not to send this peer a notification when we reboot. */
|
void nsm_unmonitor(const struct nlm_host *host)
|
/* If this peer is monitored, this function sends an upcall to tell the local rpc.statd not to send this peer a notification when we reboot. */
void nsm_unmonitor(const struct nlm_host *host)
|
{
struct nsm_handle *nsm = host->h_nsmhandle;
struct nsm_res res;
int status;
if (atomic_read(&nsm->sm_count) == 1
&& nsm->sm_monitored && !nsm->sm_sticky) {
dprintk("lockd: nsm_unmonitor(%s)\n", nsm->sm_name);
status = nsm_mon_unmon(nsm, NSMPROC_UNMON, &res);
if (res.status != 0)
status = -EIO;
if (status < 0)
printk(KERN_NOTICE "lockd: cannot unmonitor %s\n",
nsm->sm_name);
else
nsm->sm_monitored = 0;
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Returns 0 on success or error code from kernel_thread() */
|
int zfcp_erp_thread_setup(struct zfcp_adapter *adapter)
|
/* Returns 0 on success or error code from kernel_thread() */
int zfcp_erp_thread_setup(struct zfcp_adapter *adapter)
|
{
struct task_struct *thread;
thread = kthread_run(zfcp_erp_thread, adapter, "zfcperp%s",
dev_name(&adapter->ccw_device->dev));
if (IS_ERR(thread)) {
dev_err(&adapter->ccw_device->dev,
"Creating an ERP thread for the FCP device failed.\n");
return PTR_ERR(thread);
}
adapter->erp_thread = thread;
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* gem_update_int_status: Raise or lower interrupt based on current status. */
|
static void gem_update_int_status(GemState *s)
|
/* gem_update_int_status: Raise or lower interrupt based on current status. */
static void gem_update_int_status(GemState *s)
|
{
if (s->regs[GEM_ISR]) {
DB_PRINT("asserting int. (0x%08x)\n", s->regs[GEM_ISR]);
qemu_set_irq(s->irq, 1);
}
}
|
ve3wwg/teensy3_qemu
|
C++
|
Other
| 15
|
/* Atomically swap in the new signal mask, and wait for a signal. */
|
asmlinkage int do_sigsuspend(struct pt_regs *regs)
|
/* Atomically swap in the new signal mask, and wait for a signal. */
asmlinkage int do_sigsuspend(struct pt_regs *regs)
|
{
old_sigset_t mask = regs->d3;
sigset_t saveset;
mask &= _BLOCKABLE;
spin_lock_irq(¤t->sighand->siglock);
saveset = current->blocked;
siginitset(¤t->blocked, mask);
recalc_sigpending();
spin_unlock_irq(¤t->sighand->siglock);
regs->d0 = -EINTR;
while (1) {
current->state = TASK_INTERRUPTIBLE;
schedule();
if (do_signal(&saveset, regs))
return -EINTR;
}
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Allocate a bestcomm task structure for receiving data from a PSC. */
|
struct bcom_task* bcom_psc_gen_bd_rx_init(unsigned psc_num, int queue_len, phys_addr_t fifo, int maxbufsize)
|
/* Allocate a bestcomm task structure for receiving data from a PSC. */
struct bcom_task* bcom_psc_gen_bd_rx_init(unsigned psc_num, int queue_len, phys_addr_t fifo, int maxbufsize)
|
{
if (psc_num >= MPC52xx_PSC_MAXNUM)
return NULL;
return bcom_gen_bd_rx_init(queue_len, fifo,
bcom_psc_params[psc_num].rx_initiator,
bcom_psc_params[psc_num].rx_ipr,
maxbufsize);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* This function may be called - with care - from IRQ context. */
|
void synchronize_irq(unsigned int irq)
|
/* This function may be called - with care - from IRQ context. */
void synchronize_irq(unsigned int irq)
|
{
struct irq_desc *desc = irq_to_desc(irq);
unsigned int status;
if (!desc)
return;
do {
unsigned long flags;
while (desc->status & IRQ_INPROGRESS)
cpu_relax();
raw_spin_lock_irqsave(&desc->lock, flags);
status = desc->status;
raw_spin_unlock_irqrestore(&desc->lock, flags);
} while (status & IRQ_INPROGRESS);
wait_event(desc->wait_for_threads, !atomic_read(&desc->threads_active));
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Internal function to move Bresenham line iterator to the next position.
Maybe updates the x and y coordinates of the iterator struct. */
|
int _bresenhamIterate(SDL_gfxBresenhamIterator *b)
|
/* Internal function to move Bresenham line iterator to the next position.
Maybe updates the x and y coordinates of the iterator struct. */
int _bresenhamIterate(SDL_gfxBresenhamIterator *b)
|
{ if (b==NULL) {
return (-1);
}
if (b->count==0) {
return (2);
}
while (b->error >= 0) {
if (b->swapdir) {
b->x += b->s1;
} else {
b->y += b->s2;
}
b->error -= b->dx;
}
if (b->swapdir) {
b->y += b->s2;
} else {
b->x += b->s1;
}
b->error += b->dy; b->count--;
return ((b->count) ? 0 : 1);
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* Frame handler for the application.
Handles all command events from the widgets in the application frame. */
|
static bool widget_settings_frame_command_handler(struct wtk_basic_frame *frame, win_command_t command_data)
|
/* Frame handler for the application.
Handles all command events from the widgets in the application frame. */
static bool widget_settings_frame_command_handler(struct wtk_basic_frame *frame, win_command_t command_data)
|
{
char command;
command = (uintptr_t)command_data;
UNUSED(frame);
switch (command) {
case ICON_SETTINGS_TIME_ID:
app_widget_settings_on(false);
app_widget_settings_time_on(true);
break;
case ICON_SETTINGS_DATE_ID:
app_widget_settings_on(false);
app_widget_settings_date_on(true);
break;
case ICON_SETTINGS_BACKLIGHT_ID:
app_widget_settings_on(false);
app_widget_settings_backlight_on(true);
break;
case ICON_SETTINGS_TSD_ID:
demo_set_special_mode_status(DEMO_LCD_CALIBRATE_MODE, 1);
break;
case ICON_SETTINGS_RET_ID:
app_widget_settings_on(false);
app_widget_main_on(true);
break;
}
return false;
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Uses a critical section to determine if there is any data in a queue. */
|
static signed portBASE_TYPE prvIsQueueEmpty(const xQueueHandle pxQueue) PRIVILEGED_FUNCTION
|
/* Uses a critical section to determine if there is any data in a queue. */
static signed portBASE_TYPE prvIsQueueEmpty(const xQueueHandle pxQueue) PRIVILEGED_FUNCTION
|
{
signed portBASE_TYPE xReturn;
taskENTER_CRITICAL();
xReturn = ( pxQueue->uxMessagesWaiting == ( unsigned portBASE_TYPE ) 0 );
taskEXIT_CRITICAL();
return xReturn;
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* Lock the request. Up to the next unlock_request() there mustn't be anything that could cause a page-fault. If the request was already aborted bail out. */
|
static int lock_request(struct fuse_conn *fc, struct fuse_req *req)
|
/* Lock the request. Up to the next unlock_request() there mustn't be anything that could cause a page-fault. If the request was already aborted bail out. */
static int lock_request(struct fuse_conn *fc, struct fuse_req *req)
|
{
int err = 0;
if (req) {
spin_lock(&fc->lock);
if (req->aborted)
err = -ENOENT;
else
req->locked = 1;
spin_unlock(&fc->lock);
}
return err;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Flush range(clean & invalidate) from all levels of D-cache/unified cache used: Affects the range */
|
void flush_dcache_range(unsigned long start, unsigned long stop)
|
/* Flush range(clean & invalidate) from all levels of D-cache/unified cache used: Affects the range */
void flush_dcache_range(unsigned long start, unsigned long stop)
|
{
check_cache_range(start, stop);
v7_dcache_maint_range(start, stop, ARMV7_DCACHE_CLEAN_INVAL_RANGE);
v7_outer_cache_flush_range(start, stop);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Reset high pass-filter.
Reading at this address zeroes instantaneously the content of the internal high pass-filter. If the high pass filter is enabled all three axes are instantaneously set to 0g. This allows to overcome the settling time of the high pass filter. */
|
Result LIS302DLHPFilterReset(void)
|
/* Reset high pass-filter.
Reading at this address zeroes instantaneously the content of the internal high pass-filter. If the high pass filter is enabled all three axes are instantaneously set to 0g. This allows to overcome the settling time of the high pass filter. */
Result LIS302DLHPFilterReset(void)
|
{
Result retv = SUCCESS;
uint8_t TmpReg = 0;
retv = LIS302DLRegReadByte(HP_FILTER_RESET, &TmpReg);
if(retv != SUCCESS)
{
return (FAILURE);
}
return (SUCCESS);
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* This API shall disable the the flash interrupt event. */
|
void XMC_FLASH_DisableEvent(const uint32_t event_msk)
|
/* This API shall disable the the flash interrupt event. */
void XMC_FLASH_DisableEvent(const uint32_t event_msk)
|
{
NVM->NVMCONF &= (uint16_t)(~(uint16_t)event_msk);
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Return if this FMP is a system FMP or a device FMP, based upon FmpImageInfo. */
|
BOOLEAN IsSystemFmp(IN EFI_FIRMWARE_IMAGE_DESCRIPTOR *FmpImageInfo)
|
/* Return if this FMP is a system FMP or a device FMP, based upon FmpImageInfo. */
BOOLEAN IsSystemFmp(IN EFI_FIRMWARE_IMAGE_DESCRIPTOR *FmpImageInfo)
|
{
GUID *Guid;
UINTN Count;
UINTN Index;
Guid = PcdGetPtr (PcdSystemFmpCapsuleImageTypeIdGuid);
Count = PcdGetSize (PcdSystemFmpCapsuleImageTypeIdGuid) / sizeof (GUID);
for (Index = 0; Index < Count; Index++, Guid++) {
if (CompareGuid (&FmpImageInfo->ImageTypeId, Guid)) {
return TRUE;
}
}
return FALSE;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Caches and returns the value with the changes applied. */
|
static int sc_ctrl(const struct device *dev, uint8_t set, uint8_t clear)
|
/* Caches and returns the value with the changes applied. */
static int sc_ctrl(const struct device *dev, uint8_t set, uint8_t clear)
|
{
struct ds3231_data *data = dev->data;
const struct ds3231_config *cfg = dev->config;
struct register_map *rp = &data->registers;
uint8_t ctrl = (rp->ctrl & ~clear) | set;
int rc = ctrl;
if (rp->ctrl != ctrl) {
uint8_t buf[2] = {
offsetof(struct register_map, ctrl),
ctrl,
};
rc = i2c_write_dt(&cfg->bus, buf, sizeof(buf));
if (rc >= 0) {
rp->ctrl = ctrl;
rc = ctrl;
}
}
return rc;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* P2P needs mac addresses for P2P device and interface. If no device address it specified, these are derived from a random ethernet address. */
|
static void brcmf_p2p_generate_bss_mac(struct brcmf_p2p_info *p2p, u8 *dev_addr)
|
/* P2P needs mac addresses for P2P device and interface. If no device address it specified, these are derived from a random ethernet address. */
static void brcmf_p2p_generate_bss_mac(struct brcmf_p2p_info *p2p, u8 *dev_addr)
|
{
bool random_addr = false;
if (!dev_addr || is_zero_ether_addr(dev_addr))
random_addr = true;
if (random_addr)
eth_random_addr(p2p->dev_addr);
else
memcpy(p2p->dev_addr, dev_addr, ETH_ALEN);
memcpy(p2p->int_addr, p2p->dev_addr, ETH_ALEN);
p2p->int_addr[0] |= 0x02;
p2p->int_addr[4] ^= 0x80;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* sysfs_add_file_to_group - add an attribute file to a pre-existing group. @kobj: object we're acting for. @attr: attribute descriptor. @group: group name. */
|
int sysfs_add_file_to_group(struct kobject *kobj, const struct attribute *attr, const char *group)
|
/* sysfs_add_file_to_group - add an attribute file to a pre-existing group. @kobj: object we're acting for. @attr: attribute descriptor. @group: group name. */
int sysfs_add_file_to_group(struct kobject *kobj, const struct attribute *attr, const char *group)
|
{
struct sysfs_dirent *dir_sd;
int error;
if (group)
dir_sd = sysfs_get_dirent(kobj->sd, group);
else
dir_sd = sysfs_get(kobj->sd);
if (!dir_sd)
return -ENOENT;
error = sysfs_add_file(dir_sd, attr, SYSFS_KOBJ_ATTR);
sysfs_put(dir_sd);
return error;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 64-bit boundary, then ASSERT(). If Length is not aligned on a 64-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). */
|
VOID* EFIAPI ScanMem64(IN CONST VOID *Buffer, IN UINTN Length, IN UINT64 Value)
|
/* If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 64-bit boundary, then ASSERT(). If Length is not aligned on a 64-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). */
VOID* EFIAPI ScanMem64(IN CONST VOID *Buffer, IN UINTN Length, IN UINT64 Value)
|
{
if (Length == 0) {
return NULL;
}
ASSERT (Buffer != NULL);
ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0);
ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));
ASSERT ((Length & (sizeof (Value) - 1)) == 0);
return (VOID *)InternalMemScanMem64 (Buffer, Length / sizeof (Value), Value);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Find the lowest, highest page frame number we have available */
|
void __init find_min_max_pfn(void)
|
/* Find the lowest, highest page frame number we have available */
void __init find_min_max_pfn(void)
|
{
int i;
max_pfn = 0;
min_low_pfn = memory_end;
for (i = 0; i < bfin_memmap.nr_map; i++) {
unsigned long start, end;
if (bfin_memmap.map[i].type != BFIN_MEMMAP_RAM)
continue;
start = PFN_UP(bfin_memmap.map[i].addr);
end = PFN_DOWN(bfin_memmap.map[i].addr +
bfin_memmap.map[i].size);
if (start >= end)
continue;
if (end > max_pfn)
max_pfn = end;
if (start < min_low_pfn)
min_low_pfn = start;
}
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Select the RTC output source to output on the Tamper pin. */
|
void BKP_RTCOutputConfig(uint16_t BKP_RTCOutputSource)
|
/* Select the RTC output source to output on the Tamper pin. */
void BKP_RTCOutputConfig(uint16_t BKP_RTCOutputSource)
|
{
uint16_t tmpreg = 0;
assert_param(IS_BKP_RTC_OUTPUT_SOURCE(BKP_RTCOutputSource));
tmpreg = BKP->RTCCR;
tmpreg &= RTCCR_Mask;
tmpreg |= BKP_RTCOutputSource;
BKP->RTCCR = tmpreg;
}
|
ajhc/demo-cortex-m3
|
C++
| null | 38
|
/* strnchr - Find a character in a length limited string @s: The string to be searched @count: The number of characters to be searched */
|
char* strnchr(const char *s, size_t count, int c)
|
/* strnchr - Find a character in a length limited string @s: The string to be searched @count: The number of characters to be searched */
char* strnchr(const char *s, size_t count, int c)
|
{
for (; count-- && *s != '\0'; ++s)
if (*s == (char)c)
return (char *)s;
return NULL;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Initiates a write packet operation.
The I2C_SLAVE_CALLBACK_READ_REQUEST callback can be used to call this function. */
|
enum status_code i2c_slave_write_packet_job(struct i2c_slave_module *const module, struct i2c_slave_packet *const packet)
|
/* Initiates a write packet operation.
The I2C_SLAVE_CALLBACK_READ_REQUEST callback can be used to call this function. */
enum status_code i2c_slave_write_packet_job(struct i2c_slave_module *const module, struct i2c_slave_packet *const packet)
|
{
Assert(module);
Assert(module->hw);
Assert(packet);
I2c *const i2c_module = module->hw;
if (module->buffer_remaining > 0) {
return STATUS_BUSY;
}
module->buffer = packet->data;
module->buffer_remaining = packet->data_length;
module->buffer_length = packet->data_length;
module->status = STATUS_BUSY;
i2c_slave_tx_interrupt(i2c_module, true);
return STATUS_OK;
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* If bool is set this will kill any frame which is currently being transferred between the MAC and baseband and also prevent any new frames from getting started. */
|
bool ath9k_hw_setrxabort(struct ath_hw *ah, bool set)
|
/* If bool is set this will kill any frame which is currently being transferred between the MAC and baseband and also prevent any new frames from getting started. */
bool ath9k_hw_setrxabort(struct ath_hw *ah, bool set)
|
{
u32 reg;
if (set) {
REG_SET_BIT(ah, AR_DIAG_SW,
(AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT));
if (!ath9k_hw_wait(ah, AR_OBS_BUS_1, AR_OBS_BUS_1_RX_STATE,
0, AH_WAIT_TIMEOUT)) {
REG_CLR_BIT(ah, AR_DIAG_SW,
(AR_DIAG_RX_DIS |
AR_DIAG_RX_ABORT));
reg = REG_READ(ah, AR_OBS_BUS_1);
ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL,
"RX failed to go idle in 10 ms RXSM=0x%x\n",
reg);
return false;
}
} else {
REG_CLR_BIT(ah, AR_DIAG_SW,
(AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT));
}
return true;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Save the performance counter value after running the MP procedure. */
|
VOID MpPerfEnd(IN UINTN CpuIndex, IN UINTN MpProcedureId)
|
/* Save the performance counter value after running the MP procedure. */
VOID MpPerfEnd(IN UINTN CpuIndex, IN UINTN MpProcedureId)
|
{
mSmmMpProcedurePerformance[CpuIndex].End[MpProcedureId] = GetPerformanceCounter ();
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Reads registers that are accessed indirectly through an address/data register pair. */
|
static void t3_read_indirect(struct adapter *adap, unsigned int addr_reg, unsigned int data_reg, u32 *vals, unsigned int nregs, unsigned int start_idx)
|
/* Reads registers that are accessed indirectly through an address/data register pair. */
static void t3_read_indirect(struct adapter *adap, unsigned int addr_reg, unsigned int data_reg, u32 *vals, unsigned int nregs, unsigned int start_idx)
|
{
while (nregs--) {
t3_write_reg(adap, addr_reg, start_idx);
*vals++ = t3_read_reg(adap, data_reg);
start_idx++;
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Read the Virtio Filesystem device configuration structure in full. */
|
STATIC EFI_STATUS VirtioFsReadConfig(IN VIRTIO_DEVICE_PROTOCOL *Virtio, OUT VIRTIO_FS_CONFIG *Config)
|
/* Read the Virtio Filesystem device configuration structure in full. */
STATIC EFI_STATUS VirtioFsReadConfig(IN VIRTIO_DEVICE_PROTOCOL *Virtio, OUT VIRTIO_FS_CONFIG *Config)
|
{
UINTN Idx;
EFI_STATUS Status;
for (Idx = 0; Idx < VIRTIO_FS_TAG_BYTES; Idx++) {
Status = Virtio->ReadDevice (
Virtio,
OFFSET_OF (VIRTIO_FS_CONFIG, Tag[Idx]),
sizeof Config->Tag[Idx],
sizeof Config->Tag[Idx],
&Config->Tag[Idx]
);
if (EFI_ERROR (Status)) {
return Status;
}
}
Status = Virtio->ReadDevice (
Virtio,
OFFSET_OF (VIRTIO_FS_CONFIG, NumReqQueues),
sizeof Config->NumReqQueues,
sizeof Config->NumReqQueues,
&Config->NumReqQueues
);
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Allow the caller to discover a specific SMBIOS entry, and patch it if necissary. */
|
SMBIOS_STRUCTURE* EFIAPI SmbiosLibGetRecord(IN EFI_SMBIOS_TYPE Type, IN UINTN Instance, OUT EFI_SMBIOS_HANDLE *SmbiosHandle)
|
/* Allow the caller to discover a specific SMBIOS entry, and patch it if necissary. */
SMBIOS_STRUCTURE* EFIAPI SmbiosLibGetRecord(IN EFI_SMBIOS_TYPE Type, IN UINTN Instance, OUT EFI_SMBIOS_HANDLE *SmbiosHandle)
|
{
EFI_STATUS Status;
EFI_SMBIOS_TABLE_HEADER *Record;
UINTN Match;
Match = 0;
*SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
do {
Status = gSmbios->GetNext (gSmbios, SmbiosHandle, &Type, &Record, NULL);
if (!EFI_ERROR (Status)) {
if (Match == Instance) {
return (SMBIOS_STRUCTURE *)Record;
}
Match++;
}
} while (!EFI_ERROR (Status));
return NULL;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* returns: data address and size of the component, if idx is valid 0 in data and len, if idx is out of range */
|
void image_multi_getimg(const image_header_t *hdr, ulong idx, ulong *data, ulong *len)
|
/* returns: data address and size of the component, if idx is valid 0 in data and len, if idx is out of range */
void image_multi_getimg(const image_header_t *hdr, ulong idx, ulong *data, ulong *len)
|
{
int i;
uint32_t *size;
ulong offset, count, img_data;
count = image_multi_count (hdr);
size = (uint32_t *)image_get_data (hdr);
img_data = image_get_data (hdr) + (count + 1) * sizeof (uint32_t);
if (idx < count) {
*len = uimage_to_cpu (size[idx]);
offset = 0;
for (i = 0; i < idx; i++) {
offset += (uimage_to_cpu (size[i]) + 3) & ~3 ;
}
*data = img_data + offset;
} else {
*len = 0;
*data = 0;
}
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* Returns the clock source used as system clock. */
|
uint8_t RCC_GetSYSCLKSource(void)
|
/* Returns the clock source used as system clock. */
uint8_t RCC_GetSYSCLKSource(void)
|
{
return ((uint8_t)(RCC->CFGR & CFGR_SWS_Mask));
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Calculates the CRC16-ANSI checksum of the given buffer. */
|
UINT16 EFIAPI CalculateCrc16Ansi(IN CONST VOID *Buffer, IN UINTN Length, IN UINT16 InitialValue)
|
/* Calculates the CRC16-ANSI checksum of the given buffer. */
UINT16 EFIAPI CalculateCrc16Ansi(IN CONST VOID *Buffer, IN UINTN Length, IN UINT16 InitialValue)
|
{
CONST UINT8 *Buf;
UINT16 Crc;
Buf = Buffer;
Crc = InitialValue;
while (Length-- != 0) {
Crc = mCrc16LookupTable[(Crc & 0xFF) ^ *(Buf++)] ^ (Crc >> 8);
}
return Crc;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Specifies that the next DMA transfer is the last one. */
|
void I2C_DMALastTransferCmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
|
/* Specifies that the next DMA transfer is the last one. */
void I2C_DMALastTransferCmd(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_LAST;
}
else
{
I2Cx->CR2 &= (uint16_t)~((uint16_t)I2C_CR2_LAST);
}
}
|
MaJerle/stm32f429
|
C++
| null | 2,036
|
/* The caller will ensure that there is a node ready for the state. The node may already contain the old state, in which case it is overridden. */
|
static int cros_ec_write_state(void *blob, int node)
|
/* The caller will ensure that there is a node ready for the state. The node may already contain the old state, in which case it is overridden. */
static int cros_ec_write_state(void *blob, int node)
|
{
struct ec_state *ec = g_state;
fdt_setprop_u32(blob, node, "current-image", ec->current_image);
fdt_setprop(blob, node, "vbnv-context", ec->vbnv_context,
sizeof(ec->vbnv_context));
return state_setprop(node, "flash-data", ec->flash_data,
ec->ec_config.flash.length);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Configure pins as Analog Input Output EVENT_OUT EXTI */
|
void MX_GPIO_Init(void)
|
/* Configure pins as Analog Input Output EVENT_OUT EXTI */
void MX_GPIO_Init(void)
|
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, GPIO_PIN_RESET);
GPIO_InitStruct.Pin = GPIO_PIN_13;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* Reads the 8-bits of CMOS data at the location specified by Index. The 8-bit read value is returned. */
|
UINT8 EFIAPI PlatformCmosRead8(IN UINTN Index)
|
/* Reads the 8-bits of CMOS data at the location specified by Index. The 8-bit read value is returned. */
UINT8 EFIAPI PlatformCmosRead8(IN UINTN Index)
|
{
IoWrite8 (0x70, (UINT8)Index);
return IoRead8 (0x71);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Stops the TIMER PWM signal generation on the complementary output. */
|
void ald_timer_pwmn_stop(ald_timer_handle_t *hperh, ald_timer_channel_t ch)
|
/* Stops the TIMER PWM signal generation on the complementary output. */
void ald_timer_pwmn_stop(ald_timer_handle_t *hperh, ald_timer_channel_t ch)
|
{
ald_timer_ocn_stop(hperh, ch);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Start the channel selected. The channel start condition is: (EO or EP) and DO and (HO or HE). In this function HE is set. There're 2 cases to consider: */
|
int32_t sdma_channel_start(uint32_t channel)
|
/* Start the channel selected. The channel start condition is: (EO or EP) and DO and (HO or HE). In this function HE is set. There're 2 cases to consider: */
int32_t sdma_channel_start(uint32_t channel)
|
{
if (channel >= SDMA_NUM_CHANNELS) {
return SDMA_RETV_FAIL;
}
if (HW_SDMAARM_SDMA_CHNPRIn_RD(channel) == SDMA_CHANNEL_PRIORITY_FREE) {
return SDMA_RETV_FAIL;
}
if ((HW_SDMAARM_HSTART_RD() & (1 << channel)) == 0) {
HW_SDMAARM_HSTART_SET(1 << channel);
}
return SDMA_RETV_SUCCESS;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Provide modem info if modem shell is enabled. This can be shown with "modem list" shell command. */
|
MODEM_CMD_DEFINE(on_cmd_atcmdinfo_manufacturer)
|
/* Provide modem info if modem shell is enabled. This can be shown with "modem list" shell command. */
MODEM_CMD_DEFINE(on_cmd_atcmdinfo_manufacturer)
|
{
size_t out_len;
out_len = net_buf_linearize(modem.minfo.mdm_manufacturer,
sizeof(modem.minfo.mdm_manufacturer) - 1,
data->rx_buf, 0, len);
modem.minfo.mdm_manufacturer[out_len] = '\0';
LOG_INF("Manufacturer: %s", modem.minfo.mdm_manufacturer);
return 0;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* @blob: Pointer to device tree blob, or NULL if no data to read @node: Node offset to read from */
|
static int sandbox_tpm_read_state(const void *blob, int node)
|
/* @blob: Pointer to device tree blob, or NULL if no data to read @node: Node offset to read from */
static int sandbox_tpm_read_state(const void *blob, int node)
|
{
const char *prop;
int len;
int i;
if (!blob)
return 0;
for (i = 0; i < NV_SEQ_COUNT; i++) {
char prop_name[20];
sprintf(prop_name, "nvdata%d", i);
prop = fdt_getprop(blob, node, prop_name, &len);
if (prop && len == NV_DATA_SIZE) {
memcpy(g_state.nvdata[i].data, prop, NV_DATA_SIZE);
g_state.nvdata[i].present = true;
}
}
g_state.valid = true;
return 0;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Request the PE to send a GOTOMIN message. */
|
USBPD_StatusTypeDef USBPD_DPM_RequestGotoMin(uint8_t PortNum)
|
/* Request the PE to send a GOTOMIN message. */
USBPD_StatusTypeDef USBPD_DPM_RequestGotoMin(uint8_t PortNum)
|
{
return USBPD_PE_Request_CtrlMessage(PortNum, USBPD_CONTROLMSG_GOTOMIN, USBPD_SOPTYPE_SOP);
}
|
st-one/X-CUBE-USB-PD
|
C++
| null | 110
|
/* Fetches the next data block from the file */
|
int Extractor_getNextDataBlock(char *data, thread_Settings *mSettings)
|
/* Fetches the next data block from the file */
int Extractor_getNextDataBlock(char *data, thread_Settings *mSettings)
|
{
return(fread( data, 1, mSettings->Extractor_size,
mSettings->Extractor_file ));
}
return 0;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* load the last error code in the error list */
|
void scsi_sense_code(usb_core_driver *udev, uint8_t lun, uint8_t skey, uint8_t asc)
|
/* load the last error code in the error list */
void scsi_sense_code(usb_core_driver *udev, uint8_t lun, uint8_t skey, uint8_t asc)
|
{
usbd_msc_handler *msc = (usbd_msc_handler *)udev->dev.class_data[USBD_MSC_INTERFACE];
msc->scsi_sense[msc->scsi_sense_tail].SenseKey = skey;
msc->scsi_sense[msc->scsi_sense_tail].ASC = asc;
msc->scsi_sense_tail++;
if (SENSE_LIST_DEEPTH == msc->scsi_sense_tail) {
msc->scsi_sense_tail = 0U;
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Configure Timer Counter 0 (TC0) to generate an interrupt every 200ms. This interrupt will be used to flush USART input and echo back. */
|
static void configure_tc(void)
|
/* Configure Timer Counter 0 (TC0) to generate an interrupt every 200ms. This interrupt will be used to flush USART input and echo back. */
static void configure_tc(void)
|
{
uint32_t ul_div;
uint32_t ul_tcclks;
static uint32_t ul_pbaclk;
sysclk_enable_peripheral_clock(TC0);
ul_pbaclk = sysclk_get_peripheral_bus_hz(TC0);
tc_find_mck_divisor(TC_FREQ, ul_pbaclk, &ul_div, &ul_tcclks, ul_pbaclk);
tc_init(TC0, 0, ul_tcclks | TC_CMR_CPCTRG);
tc_write_rc(TC0, 0, (ul_pbaclk / ul_div) / TC_FREQ);
NVIC_EnableIRQ(TC00_IRQn);
tc_enable_interrupt(TC0, 0, TC_IER_CPCS);
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* registers all bnx2i adapter instances with the cnic driver while holding the global resource lock */
|
void bnx2i_reg_dev_all(void)
|
/* registers all bnx2i adapter instances with the cnic driver while holding the global resource lock */
void bnx2i_reg_dev_all(void)
|
{
struct bnx2i_hba *hba, *temp;
mutex_lock(&bnx2i_dev_lock);
list_for_each_entry_safe(hba, temp, &adapter_list, link)
bnx2i_register_device(hba);
mutex_unlock(&bnx2i_dev_lock);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Enables or disables the temperature sensor and Vrefint channel. */
|
void ADC_VrefintCmd(FunctionalState NewState)
|
/* Enables or disables the temperature sensor and Vrefint channel. */
void ADC_VrefintCmd(FunctionalState NewState)
|
{
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
ADC1->ADCFG|=ADCFG_VSEN_Set;
ADC1->ADCHS |= ADCHS_VSVREFE_Set ;
}
else
{
ADC1->ADCFG&=~ADCFG_VSEN_Set;
ADC1->ADCHS &= ADCHS_VSVREFE_Reset;
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Converts a 24-bit RGB color to an equivalent 16-bit RGB565 value. */
|
uint16_t colorsRGB24toRGB565(uint8_t r, uint8_t g, uint8_t b)
|
/* Converts a 24-bit RGB color to an equivalent 16-bit RGB565 value. */
uint16_t colorsRGB24toRGB565(uint8_t r, uint8_t g, uint8_t b)
|
{
return ((r / 8) << 11) | ((g / 4) << 5) | (b / 8);
}
|
microbuilder/LPC1343CodeBase
|
C++
|
Other
| 73
|
/* Check if this interface is USB Rndis SubType but not CDC Data interface */
|
BOOLEAN IsRndisInterface(IN EFI_USB_IO_PROTOCOL *UsbIo)
|
/* Check if this interface is USB Rndis SubType but not CDC Data interface */
BOOLEAN IsRndisInterface(IN EFI_USB_IO_PROTOCOL *UsbIo)
|
{
EFI_STATUS Status;
EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
Status = UsbIo->UsbGetInterfaceDescriptor (UsbIo, &InterfaceDescriptor);
if (EFI_ERROR (Status)) {
return FALSE;
}
if (((InterfaceDescriptor.InterfaceClass == USB_CDC_CLASS) &&
(InterfaceDescriptor.InterfaceSubClass == USB_CDC_ACM_SUBCLASS) &&
(InterfaceDescriptor.InterfaceProtocol == USB_VENDOR_PROTOCOL)) || \
((InterfaceDescriptor.InterfaceClass == USB_MISC_CLASS) &&
(InterfaceDescriptor.InterfaceSubClass == USB_RNDIS_SUBCLASS) &&
(InterfaceDescriptor.InterfaceProtocol == USB_RNDIS_ETHERNET_PROTOCOL))
)
{
return TRUE;
}
return FALSE;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.