docstring stringlengths 22 576 | signature stringlengths 9 317 | prompt stringlengths 57 886 | code stringlengths 20 1.36k | repository stringclasses 49
values | language stringclasses 2
values | license stringclasses 9
values | stars int64 15 21.3k |
|---|---|---|---|---|---|---|---|
/* This function removes a connection from sk_list.list of a SAP if the connection was in this list. */ | void llc_sap_remove_socket(struct llc_sap *sap, struct sock *sk) | /* This function removes a connection from sk_list.list of a SAP if the connection was in this list. */
void llc_sap_remove_socket(struct llc_sap *sap, struct sock *sk) | {
write_lock_bh(&sap->sk_list.lock);
sk_del_node_init(sk);
write_unlock_bh(&sap->sk_list.lock);
llc_sap_put(sap);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Compare the tail of two strings. Return 0 if whole of either string is same as another's tail part. */ | static int strtailcmp(const char *s1, const char *s2) | /* Compare the tail of two strings. Return 0 if whole of either string is same as another's tail part. */
static int strtailcmp(const char *s1, const char *s2) | {
int i1 = strlen(s1);
int i2 = strlen(s2);
while (--i1 >= 0 && --i2 >= 0) {
if (s1[i1] != s2[i2])
return s1[i1] - s2[i2];
}
return 0;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Note: check_ucp is called only with a buffer of at least LEN+2 bytes. IOW: The buffer should contain a complete UCP PDU */ | static int check_ucp(tvbuff_t *tvb, int *endpkt) | /* Note: check_ucp is called only with a buffer of at least LEN+2 bytes. IOW: The buffer should contain a complete UCP PDU */
static int check_ucp(tvbuff_t *tvb, int *endpkt) | {
guint offset = 1;
guint checksum = 0;
int pkt_check, tmp;
int length;
length = tvb_find_guint8(tvb, offset, -1, UCP_ETX);
if (length == -1) {
*endpkt = tvb_reported_length_remaining(tvb, offset);
return UCP_MALFORMED;
}
for (; offset < (guint) (length - 2); offset++)
checksum += tvb_get_guint8(tvb, offset);
checksum &= 0xFF;
tmp = tvb_get_guint8(tvb, offset++);
pkt_check = AHex2Bin(tmp);
tmp = tvb_get_guint8(tvb, offset++);
pkt_check = 16 * pkt_check + AHex2Bin(tmp);
*endpkt = offset + 1;
if (checksum == (guint) pkt_check)
return 0;
else
return UCP_INV_CHK;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Initialises an ADC interface, Prepares an ADC hardware interface for sampling */ | int32_t hal_adc_init(adc_dev_t *adc) | /* Initialises an ADC interface, Prepares an ADC hardware interface for sampling */
int32_t hal_adc_init(adc_dev_t *adc) | {
if (adc->config.sampling_cycle) {
hal_gpadc_open(__hal_adc_port2chan(adc->port), HAL_GPADC_ATP_NULL, NULL);
} else {
hal_gpadc_open(__hal_adc_port2chan(adc->port), HAL_GPADC_ATP_ONESHOT, __hal_adc_irqhandler);
}
return 0;
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Enables or disables the TIM peripheral Main Outputs. */ | void TIM_CtrlPWMOutputs(TIM_TypeDef *tim, FunctionalState state) | /* Enables or disables the TIM peripheral Main Outputs. */
void TIM_CtrlPWMOutputs(TIM_TypeDef *tim, FunctionalState state) | {
(state) ? SET_BIT(tim->BDTR, TIM_BDTR_MOEN) : CLEAR_BIT(tim->BDTR, TIM_BDTR_MOEN);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Get length of bignum as an unsigned binary buffer. */ | int rt_hwcrypto_bignum_get_len(const struct hw_bignum_mpi *n) | /* Get length of bignum as an unsigned binary buffer. */
int rt_hwcrypto_bignum_get_len(const struct hw_bignum_mpi *n) | {
int tmp_len, total;
if (n == RT_NULL || n->p == RT_NULL)
{
return 0;
}
tmp_len = 0;
total = n->total;
while ((total > 0) && (n->p[total - 1] == 0))
{
tmp_len++;
total--;
}
return n->total - tmp_len;
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* When you use this code to patch more than one byte of an instruction you need to make sure that other CPUs cannot execute this code in parallel. Also no thread must be currently preempted in the middle of these instructions. And on the local CPU you need to be protected again NMI or MCE handlers seeing an inconsistent instruction while you patch. */ | static void *__init_or_module text_poke_early(void *addr, const void *opcode, size_t len) | /* When you use this code to patch more than one byte of an instruction you need to make sure that other CPUs cannot execute this code in parallel. Also no thread must be currently preempted in the middle of these instructions. And on the local CPU you need to be protected again NMI or MCE handlers seeing an inconsistent instruction while you patch. */
static void *__init_or_module text_poke_early(void *addr, const void *opcode, size_t len) | {
unsigned long flags;
local_irq_save(flags);
memcpy(addr, opcode, len);
sync_core();
local_irq_restore(flags);
return addr;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Set the I/O transfer over the ISA bus to 8-bit mode */ | static void wv_16_on(unsigned long ioaddr, u16 hacr) | /* Set the I/O transfer over the ISA bus to 8-bit mode */
static void wv_16_on(unsigned long ioaddr, u16 hacr) | {
hacr |= HACR_16BITS;
hacr_write(ioaddr, hacr);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This code checks if the file content complies with EFI_VARIABLE_AUTHENTICATION_2 format The function reads file content but won't open/close given FileHandle. */ | BOOLEAN IsAuthentication2Format(IN EFI_FILE_HANDLE FileHandle) | /* This code checks if the file content complies with EFI_VARIABLE_AUTHENTICATION_2 format The function reads file content but won't open/close given FileHandle. */
BOOLEAN IsAuthentication2Format(IN EFI_FILE_HANDLE FileHandle) | {
EFI_STATUS Status;
EFI_VARIABLE_AUTHENTICATION_2 *Auth2;
BOOLEAN IsAuth2Format;
IsAuth2Format = FALSE;
Status = ReadFileContent (
FileHandle,
(VOID **)&mImageBase,
&mImageSize,
0
);
if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
Auth2 = (EFI_VARIABLE_AUTHENTICATION_2 *)mImageBase;
if (Auth2->AuthInfo.Hdr.wCertificateType != WIN_CERT_TYPE_EFI_GUID) {
goto ON_EXIT;
}
if (CompareGuid (&gEfiCertPkcs7Guid, &Auth2->AuthInfo.CertType)) {
IsAuth2Format = TRUE;
}
ON_EXIT:
if (mImageBase != NULL) {
FreePool (mImageBase);
mImageBase = NULL;
}
return IsAuth2Format;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Enable interrupts on specified GPIO pins.
Note that the NVIC must be enabled and properly configured for the interrupt to be routed to the CPU. */ | void gpio_enable_interrupts(uint32_t gpioport, uint8_t gpios) | /* Enable interrupts on specified GPIO pins.
Note that the NVIC must be enabled and properly configured for the interrupt to be routed to the CPU. */
void gpio_enable_interrupts(uint32_t gpioport, uint8_t gpios) | {
GPIO_IM(gpioport) |= gpios;
} | insane-adding-machines/unicore-mx | C++ | GNU General Public License v3.0 | 50 |
/* Compute the solicited-node multicast address for an unicast or anycast address, by taking the low-order 24 bits of this address, and appending those bits to the prefix FF02:0:0:0:0:1:FF00::/104. */ | VOID Ip6CreateSNMulticastAddr(IN EFI_IPv6_ADDRESS *Ip6Addr, OUT EFI_IPv6_ADDRESS *MulticastAddr) | /* Compute the solicited-node multicast address for an unicast or anycast address, by taking the low-order 24 bits of this address, and appending those bits to the prefix FF02:0:0:0:0:1:FF00::/104. */
VOID Ip6CreateSNMulticastAddr(IN EFI_IPv6_ADDRESS *Ip6Addr, OUT EFI_IPv6_ADDRESS *MulticastAddr) | {
ASSERT (Ip6Addr != NULL && MulticastAddr != NULL);
ZeroMem (MulticastAddr, sizeof (EFI_IPv6_ADDRESS));
MulticastAddr->Addr[0] = 0xFF;
MulticastAddr->Addr[1] = 0x02;
MulticastAddr->Addr[11] = 0x1;
MulticastAddr->Addr[12] = 0xFF;
CopyMem (&MulticastAddr->Addr[13], &Ip6Addr->Addr[13], 3);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Indicates whether or not the I2C Master is busy. */ | xtBoolean I2CMasterBusy(unsigned long ulBase) | /* Indicates whether or not the I2C Master is busy. */
xtBoolean I2CMasterBusy(unsigned long ulBase) | {
xASSERT((ulBase == I2C0_BASE) || ((ulBase == I2C1_BASE)));
return (xHWREGB(ulBase + I2C_STATUS) & I2C_STATUS_TCF) ? xtrue : xfalse;
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* Create a menu entry by given menu type. */ | MENU_ENTRY* LibCreateMenuEntry(VOID) | /* Create a menu entry by given menu type. */
MENU_ENTRY* LibCreateMenuEntry(VOID) | {
MENU_ENTRY *MenuEntry;
MenuEntry = AllocateZeroPool (sizeof (MENU_ENTRY));
if (MenuEntry == NULL) {
return NULL;
}
MenuEntry->VariableContext = AllocateZeroPool (sizeof (FILE_CONTEXT));
if (MenuEntry->VariableContext == NULL) {
FreePool (MenuEntry);
return NULL;
}
MenuEntry->Signature = MENU_ENTRY_SIGNATURE;
return MenuEntry;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Frees the iommu virtually contiguous memory area starting at @da, which was passed to and was returned by'iommu_kmalloc()'. */ | void iommu_kfree(struct iommu *obj, u32 da) | /* Frees the iommu virtually contiguous memory area starting at @da, which was passed to and was returned by'iommu_kmalloc()'. */
void iommu_kfree(struct iommu *obj, u32 da) | {
struct sg_table *sgt;
sgt = unmap_vm_area(obj, da, kfree, IOVMF_LINEAR | IOVMF_ALLOC);
if (!sgt)
dev_dbg(obj->dev, "%s: No sgt\n", __func__);
sgtable_free(sgt);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Unregisters an interrupt handler for the SHA/MD5 module. */ | void SHAMD5IntUnregister(uint32_t ui32Base) | /* Unregisters an interrupt handler for the SHA/MD5 module. */
void SHAMD5IntUnregister(uint32_t ui32Base) | {
ASSERT(ui32Base == SHAMD5_BASE);
IntDisable(INT_SHA0_TM4C129);
IntUnregister(INT_SHA0_TM4C129);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* param base SRC peripheral base address. param sliceName The selected reset slice. See src_reset_slice_name_t for more details. */ | void SRC_AssertSliceSoftwareReset(SRC_Type *base, src_reset_slice_name_t sliceName) | /* param base SRC peripheral base address. param sliceName The selected reset slice. See src_reset_slice_name_t for more details. */
void SRC_AssertSliceSoftwareReset(SRC_Type *base, src_reset_slice_name_t sliceName) | {
uint32_t regAddress;
uint32_t sliceStatusRegAddress;
regAddress = SRC_GET_SLICE_REGISTER_ADDRESS(base, sliceName, SRC_SLICE_CONTROL_REGISTER_OFFSET);
sliceStatusRegAddress = SRC_GET_SLICE_REGISTER_ADDRESS(base, sliceName, SRC_SLICE_STATUS_REGISTER_OFFSET);
*(volatile uint32_t *)regAddress |= SRC_SLICE_CTRL_SW_RESET_MASK;
while (((*(volatile uint32_t *)sliceStatusRegAddress) & SRC_SLICE_STAT_UNDER_RST_MASK) != 0UL)
{
;
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* This function sets the OCT output delay in SCC manager. */ | static void scc_mgr_set_oct_out1_delay(struct socfpga_sdrseq *seq, const u32 write_group, const u32 delay) | /* This function sets the OCT output delay in SCC manager. */
static void scc_mgr_set_oct_out1_delay(struct socfpga_sdrseq *seq, const u32 write_group, const u32 delay) | {
const int ratio = seq->rwcfg->mem_if_read_dqs_width /
seq->rwcfg->mem_if_write_dqs_width;
const int base = write_group * ratio;
int i;
for (i = 0; i < ratio; i++)
scc_mgr_set(SCC_MGR_OCT_OUT1_DELAY_OFFSET, base + i, delay);
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* psmouse_set_state() sets new psmouse state and resets all flags and counters while holding serio lock so fighting with interrupt handler is not a concern. */ | void psmouse_set_state(struct psmouse *psmouse, enum psmouse_state new_state) | /* psmouse_set_state() sets new psmouse state and resets all flags and counters while holding serio lock so fighting with interrupt handler is not a concern. */
void psmouse_set_state(struct psmouse *psmouse, enum psmouse_state new_state) | {
serio_pause_rx(psmouse->ps2dev.serio);
__psmouse_set_state(psmouse, new_state);
serio_continue_rx(psmouse->ps2dev.serio);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* If the LIR_Click bit is not set, the interrupt is kept high for the duration of the latency window. If the LIR_Click bit is set, the interrupt is kept high until the CLICK_SRC(39h) register is read.. */ | int32_t lis2dh12_tap_notification_mode_get(stmdev_ctx_t *ctx, lis2dh12_lir_click_t *val) | /* If the LIR_Click bit is not set, the interrupt is kept high for the duration of the latency window. If the LIR_Click bit is set, the interrupt is kept high until the CLICK_SRC(39h) register is read.. */
int32_t lis2dh12_tap_notification_mode_get(stmdev_ctx_t *ctx, lis2dh12_lir_click_t *val) | {
lis2dh12_click_ths_t click_ths;
int32_t ret;
ret = lis2dh12_read_reg(ctx, LIS2DH12_CLICK_THS,
(uint8_t *)&click_ths, 1);
switch (click_ths.lir_click)
{
case LIS2DH12_TAP_PULSED:
*val = LIS2DH12_TAP_PULSED;
break;
case LIS2DH12_TAP_LATCHED:
*val = LIS2DH12_TAP_LATCHED;
break;
default:
*val = LIS2DH12_TAP_PULSED;
break;
}
return ret;
} | prusa3d/Prusa-Firmware-Buddy | C++ | Other | 1,019 |
/* Set a default value for the TMRA initialization structure. */ | int32_t TMRA_StructInit(stc_tmra_init_t *pstcTmraInit) | /* Set a default value for the TMRA initialization structure. */
int32_t TMRA_StructInit(stc_tmra_init_t *pstcTmraInit) | {
int32_t i32Ret = LL_ERR_INVD_PARAM;
if (pstcTmraInit != NULL) {
pstcTmraInit->u8CountSrc = TMRA_CNT_SRC_SW;
pstcTmraInit->sw_count.u8ClockDiv = TMRA_CLK_DIV1;
pstcTmraInit->sw_count.u8CountMode = TMRA_MD_SAWTOOTH;
pstcTmraInit->sw_count.u8CountDir = TMRA_DIR_UP;
pstcTmraInit->hw_count.u16CountUpCond = TMRA_CNT_UP_COND_INVD;
pstcTmraInit->hw_count.u16CountDownCond = TMRA_CNT_DOWN_COND_INVD;
pstcTmraInit->u32PeriodValue = (TMRA_REG_TYPE)0xFFFFFFFFUL;
i32Ret = LL_OK;
}
return i32Ret;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* This function clears all PUF internal logic and puts the PUF to zeroized state. */ | status_t PUF_Zeroize(PUF_Type *base) | /* This function clears all PUF internal logic and puts the PUF to zeroized state. */
status_t PUF_Zeroize(PUF_Type *base) | {
status_t status = kStatus_Fail;
base->CR = PUF_CR_ZEROIZE_MASK;
while (0u != (base->CR & PUF_CR_ZEROIZE_MASK))
{
}
while (0u != (base->SR & PUF_SR_BUSY_MASK))
{
}
if (((PUF_SR_ZEROIZED_MASK | PUF_SR_OK_MASK) == base->SR) && (0u == base->AR))
{
status = puf_makeStatus(base, kPUF_Zeroize);
}
return status;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Flushes an endpoint of the Low Level Driver. */ | USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) | /* Flushes an endpoint of the Low Level Driver. */
USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) | {
HAL_StatusTypeDef hal_status = HAL_OK;
USBD_StatusTypeDef usb_status = USBD_OK;
hal_status = HAL_PCD_EP_Flush(pdev->pData, ep_addr);
usb_status = USBD_Get_USB_Status(hal_status);
return usb_status;
} | feaser/openblt | C++ | GNU General Public License v3.0 | 601 |
/* Returns zero on success, a negative error code otherwise. */ | int mtd_ooblayout_set_eccbytes(struct mtd_info *mtd, const u8 *eccbuf, u8 *oobbuf, int start, int nbytes) | /* Returns zero on success, a negative error code otherwise. */
int mtd_ooblayout_set_eccbytes(struct mtd_info *mtd, const u8 *eccbuf, u8 *oobbuf, int start, int nbytes) | {
return mtd_ooblayout_set_bytes(mtd, eccbuf, oobbuf, start, nbytes,
mtd_ooblayout_ecc);
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Read AT25DF321 manufacturer and device ID, check the density. */ | static bool spi_at25df_mem_check(void) | /* Read AT25DF321 manufacturer and device ID, check the density. */
static bool spi_at25df_mem_check(void) | {
spi_select_device(SPI_EXAMPLE, &SPI_DEVICE_EXAMPLE);
spi_write_packet(SPI_EXAMPLE, data, 1);
spi_read_packet(SPI_EXAMPLE, data, DATA_BUFFER_SIZE);
spi_deselect_device(SPI_EXAMPLE, &SPI_DEVICE_EXAMPLE);
if ((data[1] & AT25DF_MSK_DENSITY) < AT25DF_DENSITY) {
return false;
} else {
return true;
}
} | memfault/zero-to-main | C++ | null | 200 |
/* Enqueue a work item to be picked up by the vfs xfssyncd thread. Doing this has two advantages: */ | STATIC void xfs_syncd_queue_work(struct xfs_mount *mp, void *data, void(*syncer)(struct xfs_mount *, void *), struct completion *completion) | /* Enqueue a work item to be picked up by the vfs xfssyncd thread. Doing this has two advantages: */
STATIC void xfs_syncd_queue_work(struct xfs_mount *mp, void *data, void(*syncer)(struct xfs_mount *, void *), struct completion *completion) | {
struct xfs_sync_work *work;
work = kmem_alloc(sizeof(struct xfs_sync_work), KM_SLEEP);
INIT_LIST_HEAD(&work->w_list);
work->w_syncer = syncer;
work->w_data = data;
work->w_mount = mp;
work->w_completion = completion;
spin_lock(&mp->m_sync_lock);
list_add_tail(&work->w_list, &mp->m_sync_list);
spin_unlock(&mp->m_sync_lock);
wake_up_process(mp->m_sync_task);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This function calculates amount of memory required for all hbq entries to be configured and returns the total memory required. */ | int lpfc_sli_hbq_size(void) | /* This function calculates amount of memory required for all hbq entries to be configured and returns the total memory required. */
int lpfc_sli_hbq_size(void) | {
return lpfc_sli_hbq_entry_count() * sizeof(struct lpfc_hbq_entry);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Some copy_from_user() implementations do not return the exact number of bytes remaining to copy on a fault. But copy_mount_options() requires that. Note that this function differs from copy_from_user() in that it will oops on bad values of */ | static long exact_copy_from_user(void *to, const void __user *from, unsigned long n) | /* Some copy_from_user() implementations do not return the exact number of bytes remaining to copy on a fault. But copy_mount_options() requires that. Note that this function differs from copy_from_user() in that it will oops on bad values of */
static long exact_copy_from_user(void *to, const void __user *from, unsigned long n) | {
char *t = to;
const char __user *f = from;
char c;
if (!access_ok(VERIFY_READ, from, n))
return n;
while (n) {
if (__get_user(c, f)) {
memset(t, 0, n);
break;
}
*t++ = c;
f++;
n--;
}
return n;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Refer to EMMC Electrical Standard Spec 5.1 Section 6.10.4 for details. */ | EFI_STATUS EmmcPeimSwitch(IN EMMC_PEIM_HC_SLOT *Slot, IN UINT8 Access, IN UINT8 Index, IN UINT8 Value, IN UINT8 CmdSet) | /* Refer to EMMC Electrical Standard Spec 5.1 Section 6.10.4 for details. */
EFI_STATUS EmmcPeimSwitch(IN EMMC_PEIM_HC_SLOT *Slot, IN UINT8 Access, IN UINT8 Index, IN UINT8 Value, IN UINT8 CmdSet) | {
EMMC_COMMAND_BLOCK EmmcCmdBlk;
EMMC_STATUS_BLOCK EmmcStatusBlk;
EMMC_COMMAND_PACKET Packet;
EFI_STATUS Status;
ZeroMem (&EmmcCmdBlk, sizeof (EmmcCmdBlk));
ZeroMem (&EmmcStatusBlk, sizeof (EmmcStatusBlk));
ZeroMem (&Packet, sizeof (Packet));
Packet.EmmcCmdBlk = &EmmcCmdBlk;
Packet.EmmcStatusBlk = &EmmcStatusBlk;
Packet.Timeout = EMMC_TIMEOUT;
EmmcCmdBlk.CommandIndex = EMMC_SWITCH;
EmmcCmdBlk.CommandType = EmmcCommandTypeAc;
EmmcCmdBlk.ResponseType = EmmcResponceTypeR1b;
EmmcCmdBlk.CommandArgument = (Access << 24) | (Index << 16) | (Value << 8) | CmdSet;
Status = EmmcPeimExecCmd (Slot, &Packet);
return Status;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Checks whether the specified RCC flag is set or not. */ | FlagStatus RCC_GetFlagStatus(uint8_t RCC_FLAG) | /* Checks whether the specified RCC flag is set or not. */
FlagStatus RCC_GetFlagStatus(uint8_t RCC_FLAG) | {
uint32_t tmp = 0;
uint32_t statusreg = 0;
FlagStatus bitstatus = RESET;
assert_param(IS_RCC_FLAG(RCC_FLAG));
tmp = RCC_FLAG >> 5;
if (tmp == 1)
{
statusreg = RCC->CR;
}
else
{
statusreg = RCC->CSR;
}
tmp = RCC_FLAG & FLAG_Mask;
if ((statusreg & ((uint32_t)1 << tmp)) != (uint32_t)RESET)
{
bitstatus = SET;
}
else
{
bitstatus = RESET;
}
return bitstatus;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* param base Pointer to the FLEXIO_UART_Type structure. param mask Interrupt source. */ | void FLEXIO_UART_DisableInterrupts(FLEXIO_UART_Type *base, uint32_t mask) | /* param base Pointer to the FLEXIO_UART_Type structure. param mask Interrupt source. */
void FLEXIO_UART_DisableInterrupts(FLEXIO_UART_Type *base, uint32_t mask) | {
if ((mask & (uint32_t)kFLEXIO_UART_TxDataRegEmptyInterruptEnable) != 0U)
{
FLEXIO_DisableShifterStatusInterrupts(base->flexioBase, 1UL << base->shifterIndex[0]);
}
if ((mask & (uint32_t)kFLEXIO_UART_RxDataRegFullInterruptEnable) != 0U)
{
FLEXIO_DisableShifterStatusInterrupts(base->flexioBase, 1UL << base->shifterIndex[1]);
}
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* Clear All Status Flags.
Clears program error, end of operation, busy flags. */ | void flash_clear_status_flags(void) | /* Clear All Status Flags.
Clears program error, end of operation, busy flags. */
void flash_clear_status_flags(void) | {
flash_clear_pgerr_flag();
flash_clear_wrprterr_flag();
flash_clear_eop_flag();
} | libopencm3/libopencm3 | C++ | GNU General Public License v3.0 | 2,931 |
/* Locking: must be called with both the N_Port and VN_Port lp_mutex held */ | static void __fc_vport_setlink(struct fc_lport *n_port, struct fc_lport *vn_port) | /* Locking: must be called with both the N_Port and VN_Port lp_mutex held */
static void __fc_vport_setlink(struct fc_lport *n_port, struct fc_lport *vn_port) | {
struct fc_vport *vport = vn_port->vport;
if (vn_port->state == LPORT_ST_DISABLED)
return;
if (n_port->state == LPORT_ST_READY) {
if (n_port->npiv_enabled) {
fc_vport_set_state(vport, FC_VPORT_INITIALIZING);
__fc_linkup(vn_port);
} else {
fc_vport_set_state(vport, FC_VPORT_NO_FABRIC_SUPP);
__fc_linkdown(vn_port);
}
} else {
fc_vport_set_state(vport, FC_VPORT_LINKDOWN);
__fc_linkdown(vn_port);
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Checks whether the Low Voltage Mode status is SET or RESET. */ | FlagStatus FLASH_GetLowVoltageModeSTS(void) | /* Checks whether the Low Voltage Mode status is SET or RESET. */
FlagStatus FLASH_GetLowVoltageModeSTS(void) | {
FlagStatus bitstatus = RESET;
if ((FLASH->AC & AC_LVMF_MSK) != (uint32_t)RESET)
{
bitstatus = SET;
}
else
{
bitstatus = RESET;
}
return bitstatus;
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* Writes and returns a new value to DR6. 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 AsmWriteDr6(UINTN Dr6) | /* Writes and returns a new value to DR6. 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 AsmWriteDr6(UINTN Dr6) | {
__asm__ __volatile__ (
"mov %0, %%dr6"
:
: "r" (Dr6)
);
return Dr6;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* An ORDERED_COLLECTION_KEY_COMPARE function that compares a root bridge protocol device path against a UID. */ | STATIC INTN EFIAPI RootBridgePathKeyCompare(IN CONST VOID *StandaloneKey, IN CONST VOID *UserStruct) | /* An ORDERED_COLLECTION_KEY_COMPARE function that compares a root bridge protocol device path against a UID. */
STATIC INTN EFIAPI RootBridgePathKeyCompare(IN CONST VOID *StandaloneKey, IN CONST VOID *UserStruct) | {
CONST UINT32 *Uid;
CONST ACPI_HID_DEVICE_PATH *Acpi;
Uid = StandaloneKey;
Acpi = UserStruct;
return *Uid < Acpi->UID ? -1 :
*Uid > Acpi->UID ? 1 :
0;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Parser a string to get a null value. If the first character after the value is different of '}' or ']' is set to '\0'. */ | static char* nullValue(char *ptr, json_t *property) | /* Parser a string to get a null value. If the first character after the value is different of '}' or ']' is set to '\0'. */
static char* nullValue(char *ptr, json_t *property) | {
return primitiveValue(ptr, property, "null", JSON_NULL);
} | Luos-io/luos_engine | C++ | MIT License | 496 |
/* Read All Status Flags.
Flags for the upper bank, where appropriate, are combined with those for the lower bank using bitwise OR, without distinction. */ | uint32_t flash_get_status_flags(void) | /* Read All Status Flags.
Flags for the upper bank, where appropriate, are combined with those for the lower bank using bitwise OR, without distinction. */
uint32_t flash_get_status_flags(void) | {
uint32_t flags = (FLASH_SR & (FLASH_SR_PGERR |
FLASH_SR_EOP |
FLASH_SR_WRPRTERR |
FLASH_SR_BSY));
if (DESIG_FLASH_SIZE > 512) {
flags |= (FLASH_SR2 & (FLASH_SR_PGERR |
FLASH_SR_EOP |
FLASH_SR_WRPRTERR |
FLASH_SR_BSY));
}
return flags;
} | insane-adding-machines/unicore-mx | C++ | GNU General Public License v3.0 | 50 |
/* Change Logs: Date Author Notes Bernard the first version */ | int pthread_barrierattr_destroy(pthread_barrierattr_t *attr) | /* Change Logs: Date Author Notes Bernard the first version */
int pthread_barrierattr_destroy(pthread_barrierattr_t *attr) | {
if (!attr)
return EINVAL;
return 0;
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* Check sense key to find if reset happens. */ | BOOLEAN ScsiDiskIsResetBefore(IN EFI_SCSI_SENSE_DATA *SenseData, IN UINTN SenseCounts) | /* Check sense key to find if reset happens. */
BOOLEAN ScsiDiskIsResetBefore(IN EFI_SCSI_SENSE_DATA *SenseData, IN UINTN SenseCounts) | {
EFI_SCSI_SENSE_DATA *SensePtr;
UINTN Index;
BOOLEAN IsResetBefore;
IsResetBefore = FALSE;
SensePtr = SenseData;
for (Index = 0; Index < SenseCounts; Index++) {
if ((SensePtr->Sense_Key == EFI_SCSI_SK_UNIT_ATTENTION) &&
(SensePtr->Addnl_Sense_Code == EFI_SCSI_ASC_RESET))
{
IsResetBefore = TRUE;
}
SensePtr++;
}
return IsResetBefore;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* this is a PIO-only driver, so there's nothing interesting for request or buffer allocation. */ | static struct usb_request* at91_ep_alloc_request(struct usb_ep *_ep, gfp_t gfp_flags) | /* this is a PIO-only driver, so there's nothing interesting for request or buffer allocation. */
static struct usb_request* at91_ep_alloc_request(struct usb_ep *_ep, gfp_t gfp_flags) | {
struct at91_request *req;
req = kzalloc(sizeof (struct at91_request), gfp_flags);
if (!req)
return NULL;
INIT_LIST_HEAD(&req->queue);
return &req->req;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Read Depex and pre-process the Depex for Before and After. If Section Extraction protocol returns an error via ReadSection defer the reading of the Depex. */ | EFI_STATUS SmmGetDepexSectionAndPreProccess(IN EFI_SMM_DRIVER_ENTRY *DriverEntry) | /* Read Depex and pre-process the Depex for Before and After. If Section Extraction protocol returns an error via ReadSection defer the reading of the Depex. */
EFI_STATUS SmmGetDepexSectionAndPreProccess(IN EFI_SMM_DRIVER_ENTRY *DriverEntry) | {
EFI_STATUS Status;
EFI_SECTION_TYPE SectionType;
UINT32 AuthenticationStatus;
EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
Fv = DriverEntry->Fv;
SectionType = EFI_SECTION_SMM_DEPEX;
Status = Fv->ReadSection (
DriverEntry->Fv,
&DriverEntry->FileName,
SectionType,
0,
&DriverEntry->Depex,
(UINTN *)&DriverEntry->DepexSize,
&AuthenticationStatus
);
if (EFI_ERROR (Status)) {
if (Status == EFI_PROTOCOL_ERROR) {
DriverEntry->DepexProtocolError = TRUE;
} else {
DriverEntry->Depex = NULL;
DriverEntry->Dependent = TRUE;
DriverEntry->DepexProtocolError = FALSE;
}
} else {
SmmPreProcessDepex (DriverEntry);
DriverEntry->DepexProtocolError = FALSE;
}
return Status;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Some of the detailed timing sections may contain mode information. Grab it and add it to the list. */ | static int add_detailed_info(struct drm_connector *connector, struct edid *edid, u32 quirks) | /* Some of the detailed timing sections may contain mode information. Grab it and add it to the list. */
static int add_detailed_info(struct drm_connector *connector, struct edid *edid, u32 quirks) | {
int i, modes = 0;
for (i = 0; i < EDID_DETAILED_TIMINGS; i++) {
struct detailed_timing *timing = &edid->detailed_timings[i];
int preferred = (i == 0) && (edid->features & DRM_EDID_FEATURE_PREFERRED_TIMING);
if (!timing->pixel_clock && edid->version == 1 &&
edid->revision == 0)
continue;
modes += add_detailed_modes(connector, timing, edid, quirks,
preferred);
}
return modes;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* @udev: the transport device @cfg_type: the VIRTIO_PCI_CAP_* value we seek */ | static int virtio_pci_find_capability(struct udevice *udev, u8 cfg_type) | /* @udev: the transport device @cfg_type: the VIRTIO_PCI_CAP_* value we seek */
static int virtio_pci_find_capability(struct udevice *udev, u8 cfg_type) | {
int pos;
int offset;
u8 type, bar;
for (pos = dm_pci_find_capability(udev, PCI_CAP_ID_VNDR);
pos > 0;
pos = dm_pci_find_next_capability(udev, pos, PCI_CAP_ID_VNDR)) {
offset = pos + offsetof(struct virtio_pci_cap, cfg_type);
dm_pci_read_config8(udev, offset, &type);
offset = pos + offsetof(struct virtio_pci_cap, bar);
dm_pci_read_config8(udev, offset, &bar);
if (bar > 0x5)
continue;
if (type == cfg_type)
return pos;
}
return 0;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). If StartBit is greater than 31, then ASSERT(). If EndBit is greater than 31, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */ | UINT32 EFIAPI PciBitFieldWrite32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 Value) | /* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). If StartBit is greater than 31, then ASSERT(). If EndBit is greater than 31, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT32 EFIAPI PciBitFieldWrite32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 Value) | {
return PciWrite32 (
Address,
BitFieldWrite32 (PciRead32 (Address), StartBit, EndBit, Value)
);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Returns second word of the unique device identifier (UID based on 96 bits) */ | uint32_t HAL_GetUIDw1(void) | /* Returns second word of the unique device identifier (UID based on 96 bits) */
uint32_t HAL_GetUIDw1(void) | {
return (READ_REG(*((uint32_t *)(UID_BASE + 4U))));
} | ua1arn/hftrx | C++ | null | 69 |
/* _detach is called to deconfigure a device. It should deallocate resources. This function is also called when _attach() fails, so it should be careful not to release resources that were not necessarily allocated by _attach(). dev->private and dev->subdevices are deallocated automatically by the core. */ | static int bonding_detach(struct comedi_device *dev) | /* _detach is called to deconfigure a device. It should deallocate resources. This function is also called when _attach() fails, so it should be careful not to release resources that were not necessarily allocated by _attach(). dev->private and dev->subdevices are deallocated automatically by the core. */
static int bonding_detach(struct comedi_device *dev) | {
LOG_MSG("comedi%d: remove\n", dev->minor);
doDevUnconfig(dev);
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Mass Storage class driver callback function the reception of SCSI commands from the host, which must be processed. */ | bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t *const MSInterfaceInfo) | /* Mass Storage class driver callback function the reception of SCSI commands from the host, which must be processed. */
bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t *const MSInterfaceInfo) | {
bool CommandSuccess;
LEDs_SetAllLEDs(LEDMASK_USB_BUSY);
CommandSuccess = SCSI_DecodeSCSICommand(MSInterfaceInfo);
LEDs_SetAllLEDs(LEDMASK_USB_READY);
return CommandSuccess;
} | prusa3d/Prusa-Firmware-Buddy | C++ | Other | 1,019 |
/* RETURNS: Vertical refresh rate. It will be the result of actual value plus 0.5. If it is 70.288, it will return 70Hz. If it is 59.6, it will return 60Hz. */ | int drm_mode_vrefresh(struct drm_display_mode *mode) | /* RETURNS: Vertical refresh rate. It will be the result of actual value plus 0.5. If it is 70.288, it will return 70Hz. If it is 59.6, it will return 60Hz. */
int drm_mode_vrefresh(struct drm_display_mode *mode) | {
int refresh = 0;
unsigned int calc_val;
if (mode->vrefresh > 0)
refresh = mode->vrefresh;
else if (mode->htotal > 0 && mode->vtotal > 0) {
int vtotal;
vtotal = mode->vtotal;
calc_val = (mode->clock * 1000);
calc_val /= mode->htotal;
refresh = (calc_val + vtotal / 2) / vtotal;
if (mode->flags & DRM_MODE_FLAG_INTERLACE)
refresh *= 2;
if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
refresh /= 2;
if (mode->vscan > 1)
refresh /= mode->vscan;
}
return refresh;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* De-initialises an ADC interface, Turns off an ADC hardware interface */ | int32_t hal_adc_finalize(adc_dev_t *adc) | /* De-initialises an ADC interface, Turns off an ADC hardware interface */
int32_t hal_adc_finalize(adc_dev_t *adc) | {
analogin_deinit(adc->priv);
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Command response callback function for sd_ble_gap_lesc_oob_data_set BLE command.
Callback for decoding the output parameters and the command response return code. */ | static uint32_t gap_lesc_oob_data_set_rsp_dec(const uint8_t *p_buffer, uint16_t length) | /* Command response callback function for sd_ble_gap_lesc_oob_data_set BLE command.
Callback for decoding the output parameters and the command response return code. */
static uint32_t gap_lesc_oob_data_set_rsp_dec(const uint8_t *p_buffer, uint16_t length) | {
uint32_t result_code = 0;
const uint32_t err_code = ble_gap_lesc_oob_data_set_rsp_dec(p_buffer,
length,
&result_code);
APP_ERROR_CHECK(err_code);
return result_code;
} | labapart/polymcu | C++ | null | 201 |
/* Sets the raw color of the RGB LEDs. The brightness is non-linear function of the raw color value. */ | void BOARD_rgbledSetRawColor(uint16_t red, uint16_t green, uint16_t blue) | /* Sets the raw color of the RGB LEDs. The brightness is non-linear function of the raw color value. */
void BOARD_rgbledSetRawColor(uint16_t red, uint16_t green, uint16_t blue) | {
if( ( red == 0 ) && ( green == 0 ) && ( blue == 0 ) ) {
timerEnable = false;
TIMER_Enable ( pwmTimer, timerEnable );
TIMER_CompareBufSet ( pwmTimer, 0, 0 );
TIMER_CompareBufSet ( pwmTimer, 1, 0 );
TIMER_CompareBufSet ( pwmTimer, 2, 0 );
BOARD_ledSet( 0 );
pwmTimer->ROUTEPEN = 0;
}
else {
timerEnable = true;
TIMER_Enable ( pwmTimer, timerEnable );
TIMER_CompareBufSet ( pwmTimer, 0, red );
TIMER_CompareBufSet ( pwmTimer, 1, green );
TIMER_CompareBufSet ( pwmTimer, 2, blue );
pwmTimer->ROUTEPEN = TIMER_ROUTEPEN_CC0PEN | TIMER_ROUTEPEN_CC1PEN | TIMER_ROUTEPEN_CC2PEN;
}
return;
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* Write a Unicode string to the output device. */ | EFI_STATUS EFIAPI FileBasedSimpleTextOutOutputString(IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN CHAR16 *WString) | /* Write a Unicode string to the output device. */
EFI_STATUS EFIAPI FileBasedSimpleTextOutOutputString(IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN CHAR16 *WString) | {
UINTN Size;
Size = StrLen (WString) * sizeof (CHAR16);
return (ShellInfoObject.NewEfiShellProtocol->WriteFile (
((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)This)->FileHandle,
&Size,
WString
));
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Reset control endpoint.
Called after a USB line reset or when UDD is enabled */ | static void udd_reset_ep_ctrl(void) | /* Reset control endpoint.
Called after a USB line reset or when UDD is enabled */
static void udd_reset_ep_ctrl(void) | {
irqflags_t flags;
udd_configure_address(0);
udd_enable_address();
udd_configure_endpoint(0,
USB_EP_TYPE_CONTROL,
0,
USB_DEVICE_EP_CTRL_SIZE,
UOTGHS_DEVEPTCFG_EPBK_1_BANK);
udd_allocate_memory(0);
udd_enable_endpoint(0);
flags = cpu_irq_save();
udd_enable_setup_received_interrupt(0);
udd_enable_out_received_interrupt(0);
udd_enable_endpoint_interrupt(0);
cpu_irq_restore(flags);
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* This function returns the uDMA error status. It should be called from within the uDMA error interrupt handler to determine if a uDMA error occurred. */ | uint32_t uDMAErrorStatusGet(void) | /* This function returns the uDMA error status. It should be called from within the uDMA error interrupt handler to determine if a uDMA error occurred. */
uint32_t uDMAErrorStatusGet(void) | {
return(HWREG(UDMA_ERRCLR));
} | feaser/openblt | C++ | GNU General Public License v3.0 | 601 |
/* "If the error is triggered by receipt of an ICMP message, the message is discarded and no response is permitted (consistent with general ICMP processing rules)." */ | void cipso_v4_error(struct sk_buff *skb, int error, u32 gateway) | /* "If the error is triggered by receipt of an ICMP message, the message is discarded and no response is permitted (consistent with general ICMP processing rules)." */
void cipso_v4_error(struct sk_buff *skb, int error, u32 gateway) | {
if (ip_hdr(skb)->protocol == IPPROTO_ICMP || error != -EACCES)
return;
if (gateway)
icmp_send(skb, ICMP_DEST_UNREACH, ICMP_NET_ANO, 0);
else
icmp_send(skb, ICMP_DEST_UNREACH, ICMP_HOST_ANO, 0);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* enable or disable the EXMC NAND ECC function */ | void exmc_nand_ecc_config(uint32_t exmc_nand_bank, ControlStatus newvalue) | /* enable or disable the EXMC NAND ECC function */
void exmc_nand_ecc_config(uint32_t exmc_nand_bank, ControlStatus newvalue) | {
if (ENABLE == newvalue){
EXMC_NPCTL(exmc_nand_bank) |= EXMC_NPCTL_ECCEN;
}else{
EXMC_NPCTL(exmc_nand_bank) &= (~EXMC_NPCTL_ECCEN);
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* We attempt to switch to interrupt mode here by calling request_irq. If that works out, we enable receive interrupts. */ | static void __init sn_sal_switch_to_interrupts(struct sn_cons_port *port) | /* We attempt to switch to interrupt mode here by calling request_irq. If that works out, we enable receive interrupts. */
static void __init sn_sal_switch_to_interrupts(struct sn_cons_port *port) | {
unsigned long flags;
if (port) {
DPRINTF("sn_console: switching to interrupt driven console\n");
if (request_irq(SGI_UART_VECTOR, sn_sal_interrupt,
IRQF_DISABLED | IRQF_SHARED,
"SAL console driver", port) >= 0) {
spin_lock_irqsave(&port->sc_port.lock, flags);
port->sc_port.irq = SGI_UART_VECTOR;
port->sc_ops = &intr_ops;
ia64_sn_console_intr_enable(SAL_CONSOLE_INTR_RECV);
spin_unlock_irqrestore(&port->sc_port.lock, flags);
}
else {
printk(KERN_INFO
"sn_console: console proceeding in polled mode\n");
}
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Performs an atomic compare exchange operation on the 32-bit unsigned integer specified by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue, then Value is returned. The compare exchange operation must be performed using MP safe mechanisms. */ | UINT32 EFIAPI InternalSyncCompareExchange32(IN volatile UINT32 *Value, IN UINT32 CompareValue, IN UINT32 ExchangeValue) | /* Performs an atomic compare exchange operation on the 32-bit unsigned integer specified by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue, then Value is returned. The compare exchange operation must be performed using MP safe mechanisms. */
UINT32 EFIAPI InternalSyncCompareExchange32(IN volatile UINT32 *Value, IN UINT32 CompareValue, IN UINT32 ExchangeValue) | {
_asm {
mov ecx, Value
mov eax, CompareValue
mov edx, ExchangeValue
lock cmpxchg [ecx], edx
}
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Compile time sanity checks for defined board clock setup Verify that the request PLL1 output frequency fits the range of 156 MHz to 320 MHz, so that the PLL1 Direct Mode is applicable. Our clock configuration code ( */ | static void cycle_delay(int n) | /* Compile time sanity checks for defined board clock setup Verify that the request PLL1 output frequency fits the range of 156 MHz to 320 MHz, so that the PLL1 Direct Mode is applicable. Our clock configuration code ( */
static void cycle_delay(int n) | {
volatile int i;
for (i = 0; i < n; i++);
} | EmcraftSystems/u-boot | C++ | Other | 181 |
/* Analyze the decimal part of a real number. */ | static char* fraqValue(char *ptr) | /* Analyze the decimal part of a real number. */
static char* fraqValue(char *ptr) | {
if (!isdigit((int)(*ptr)))
return 0;
ptr = goNum(++ptr);
if (!ptr)
return 0;
return ptr;
} | Luos-io/luos_engine | C++ | MIT License | 496 |
/* The Au1xxx wait is available only if using 32khz counter or external timer source, but specifically not CP0 Counter. alchemy/common/time.c may override cpu_wait! */ | static void au1k_wait(void) | /* The Au1xxx wait is available only if using 32khz counter or external timer source, but specifically not CP0 Counter. alchemy/common/time.c may override cpu_wait! */
static void au1k_wait(void) | {
__asm__(" .set mips3 \n"
" cache 0x14, 0(%0) \n"
" cache 0x14, 32(%0) \n"
" sync \n"
" nop \n"
" wait \n"
" nop \n"
" nop \n"
" nop \n"
" nop \n"
" .set mips0 \n"
: : "r" (au1k_wait));
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* This function returns the QH associated with particular endpoint and it's direction. */ | static struct ept_queue_item* ci_get_qtd(int ep_num, int dir_in) | /* This function returns the QH associated with particular endpoint and it's direction. */
static struct ept_queue_item* ci_get_qtd(int ep_num, int dir_in) | {
int index = (ep_num * 2) + dir_in;
uint8_t *imem = controller.items_mem + (index * ILIST_ENT_SZ);
return (struct ept_queue_item *)imem;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* open "/proc/fs/fscache/objects" to provide a list of active objects */ | static int fscache_objlist_open(struct inode *inode, struct file *file) | /* open "/proc/fs/fscache/objects" to provide a list of active objects */
static int fscache_objlist_open(struct inode *inode, struct file *file) | {
struct fscache_objlist_data *data;
struct seq_file *m;
int ret;
ret = seq_open(file, &fscache_objlist_ops);
if (ret < 0)
return ret;
m = file->private_data;
data = kmalloc(sizeof(struct fscache_objlist_data), GFP_KERNEL);
if (!data) {
seq_release(inode, file);
return -ENOMEM;
}
fscache_objlist_config(data);
m->private = data;
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Checks whether the specified ADC interrupt has occurred or not. */ | ITStatus ADC_GetITStatus(ADC_TypeDef *ADCx, uint32_t ADC_IT) | /* Checks whether the specified ADC interrupt has occurred or not. */
ITStatus ADC_GetITStatus(ADC_TypeDef *ADCx, uint32_t ADC_IT) | {
ITStatus bitstatus = RESET;
uint32_t enablestatus = 0;
assert_param(IS_ADC_ALL_PERIPH(ADCx));
assert_param(IS_ADC_GET_IT(ADC_IT));
enablestatus = (uint32_t)(ADCx->IER & ADC_IT);
if (((uint32_t)(ADCx->ISR & ADC_IT) != (uint32_t)RESET) && (enablestatus != (uint32_t)RESET))
{
bitstatus = SET;
}
else
{
bitstatus = RESET;
}
return bitstatus;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Return the enabled timer interrupts.
This function will return all enabled interrupts in the main CTIMER interrupt enable register. */ | uint32_t am_hal_ctimer_int_enable_get(void) | /* Return the enabled timer interrupts.
This function will return all enabled interrupts in the main CTIMER interrupt enable register. */
uint32_t am_hal_ctimer_int_enable_get(void) | {
return AM_REGn(CTIMER, 0, INTEN);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Fetches the number of handles of the specified SMBIOS type. */ | STATIC UINTN GetHandleCount(IN UINT8 SmbiosType) | /* Fetches the number of handles of the specified SMBIOS type. */
STATIC UINTN GetHandleCount(IN UINT8 SmbiosType) | {
UINTN HandleCount;
EFI_STATUS Status;
EFI_SMBIOS_HANDLE SmbiosHandle;
EFI_SMBIOS_TABLE_HEADER *Record;
HandleCount = 0;
do {
Status = mSmbiosMiscSmbios->GetNext (
mSmbiosMiscSmbios,
&SmbiosHandle,
&SmbiosType,
&Record,
NULL
);
if (Status == EFI_SUCCESS) {
HandleCount++;
}
} while (!EFI_ERROR (Status));
return HandleCount;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Unlock any spinlocks which will prevent us from getting the message out. */ | void bust_spinlocks(int yes) | /* Unlock any spinlocks which will prevent us from getting the message out. */
void bust_spinlocks(int yes) | {
if (yes) {
oops_in_progress = 1;
} else {
int loglevel_save = console_loglevel;
console_unblank();
oops_in_progress = 0;
console_loglevel = 15;
printk(" ");
console_loglevel = loglevel_save;
}
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Use the USB clear feature control transfer to clear the endpoint stall condition. */ | EFI_STATUS UsbClearEndpointStall(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT8 EndpointAddr) | /* Use the USB clear feature control transfer to clear the endpoint stall condition. */
EFI_STATUS UsbClearEndpointStall(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT8 EndpointAddr) | {
EFI_USB_DEVICE_REQUEST Request;
EFI_STATUS Status;
UINT32 CmdResult;
UINT32 Timeout;
Request.RequestType = 0x02;
Request.Request = USB_REQ_CLEAR_FEATURE;
Request.Value = USB_FEATURE_ENDPOINT_HALT;
Request.Index = EndpointAddr;
Request.Length = 0;
Timeout = USB_BOOT_GENERAL_CMD_TIMEOUT / USB_MASS_1_MILLISECOND;
Status = UsbIo->UsbControlTransfer (
UsbIo,
&Request,
EfiUsbNoData,
Timeout,
NULL,
0,
&CmdResult
);
return Status;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* vxge_ethtool_getpause_data - Pause frame frame generation and reception. @dev : device pointer. @ep : pointer to the structure with pause parameters given by ethtool. Description: Returns the Pause frame generation and reception capability of the NIC. Return value: void */ | static void vxge_ethtool_getpause_data(struct net_device *dev, struct ethtool_pauseparam *ep) | /* vxge_ethtool_getpause_data - Pause frame frame generation and reception. @dev : device pointer. @ep : pointer to the structure with pause parameters given by ethtool. Description: Returns the Pause frame generation and reception capability of the NIC. Return value: void */
static void vxge_ethtool_getpause_data(struct net_device *dev, struct ethtool_pauseparam *ep) | {
struct vxgedev *vdev = (struct vxgedev *)netdev_priv(dev);
struct __vxge_hw_device *hldev = (struct __vxge_hw_device *)
pci_get_drvdata(vdev->pdev);
vxge_hw_device_getpause_data(hldev, 0, &ep->tx_pause, &ep->rx_pause);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* NOTE: To better understand how these functions work (i.e what is a chip select and why do have to keep driving the eeprom clock?), read just about any data sheet for a Microwire compatible EEPROM. */ | static void eeprom_write_reg(struct ipw_priv *p, u32 data) | /* NOTE: To better understand how these functions work (i.e what is a chip select and why do have to keep driving the eeprom clock?), read just about any data sheet for a Microwire compatible EEPROM. */
static void eeprom_write_reg(struct ipw_priv *p, u32 data) | {
ipw_write_reg32(p, FW_MEM_REG_EEPROM_ACCESS, data);
udelay(p->eeprom_delay);
return;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This cleans up if an error causes us to abort the transmission of a request. In this case, the socket may need to be reset in order to avoid confusing the server. */ | static void xs_tcp_release_xprt(struct rpc_xprt *xprt, struct rpc_task *task) | /* This cleans up if an error causes us to abort the transmission of a request. In this case, the socket may need to be reset in order to avoid confusing the server. */
static void xs_tcp_release_xprt(struct rpc_xprt *xprt, struct rpc_task *task) | {
struct rpc_rqst *req;
if (task != xprt->snd_task)
return;
if (task == NULL)
goto out_release;
req = task->tk_rqstp;
if (req->rq_bytes_sent == 0)
goto out_release;
if (req->rq_bytes_sent == req->rq_snd_buf.len)
goto out_release;
set_bit(XPRT_CLOSE_WAIT, &task->tk_xprt->state);
out_release:
xprt_release_xprt(xprt, task);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* SYSCTRL USB Bus&Function Clock Enable and Reset Release. */ | void LL_SYSCTRL_USB_ClkEnRstRelease(void) | /* SYSCTRL USB Bus&Function Clock Enable and Reset Release. */
void LL_SYSCTRL_USB_ClkEnRstRelease(void) | {
__LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL);
__LL_SYSCTRL_USBBusClk_En(SYSCTRL);
__LL_SYSCTRL_USBFunClk_En(SYSCTRL);
__LL_SYSCTRL_USBSoftRst_Release(SYSCTRL);
__LL_SYSCTRL_Reg_Lock(SYSCTRL);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Enable Specific USB Interrupts.
Note that the NVIC must be enabled and properly configured for the interrupt to be routed to the CPU. */ | void usb_enable_interrupts(enum usb_interrupt ints, enum usb_ep_interrupt rx_ints, enum usb_ep_interrupt tx_ints) | /* Enable Specific USB Interrupts.
Note that the NVIC must be enabled and properly configured for the interrupt to be routed to the CPU. */
void usb_enable_interrupts(enum usb_interrupt ints, enum usb_ep_interrupt rx_ints, enum usb_ep_interrupt tx_ints) | {
USB_IE |= ints;
USB_RXIE |= rx_ints;
USB_TXIE |= tx_ints;
} | libopencm3/libopencm3 | C++ | GNU General Public License v3.0 | 2,931 |
/* RETURNS: Matching XFER_* value, 0xff if no match found. */ | u8 ata_xfer_mask2mode(unsigned long xfer_mask) | /* RETURNS: Matching XFER_* value, 0xff if no match found. */
u8 ata_xfer_mask2mode(unsigned long xfer_mask) | {
int highbit = fls(xfer_mask) - 1;
const struct ata_xfer_ent *ent;
for (ent = ata_xfer_tbl; ent->shift >= 0; ent++)
if (highbit >= ent->shift && highbit < ent->shift + ent->bits)
return ent->base + highbit - ent->shift;
return 0xff;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Free previously allocated EC Point object using EcPointInit(). */ | VOID EFIAPI CryptoServiceEcPointDeInit(IN VOID *EcPoint, IN BOOLEAN Clear) | /* Free previously allocated EC Point object using EcPointInit(). */
VOID EFIAPI CryptoServiceEcPointDeInit(IN VOID *EcPoint, IN BOOLEAN Clear) | {
CALL_VOID_BASECRYPTLIB (Ec.Services.PointDeInit, EcPointDeInit, (EcPoint, Clear));
} | tianocore/edk2 | C++ | Other | 4,240 |
/* __task_rq_lock - lock the runqueue a given task resides on. Must be called interrupts disabled. */ | static struct rq* __task_rq_lock(struct task_struct *p) __acquires(rq -> lock) | /* __task_rq_lock - lock the runqueue a given task resides on. Must be called interrupts disabled. */
static struct rq* __task_rq_lock(struct task_struct *p) __acquires(rq -> lock) | {
for (;;) {
struct rq *rq = task_rq(p);
raw_spin_lock(&rq->lock);
if (likely(rq == task_rq(p)))
return rq;
raw_spin_unlock(&rq->lock);
}
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* ADC Read the Analog Watchdog Flag.
This flag is set when the converted voltage crosses the high or low thresholds. */ | bool adc_get_watchdog_flag(uint32_t adc) | /* ADC Read the Analog Watchdog Flag.
This flag is set when the converted voltage crosses the high or low thresholds. */
bool adc_get_watchdog_flag(uint32_t adc) | {
return ADC_ISR(adc) & ADC_ISR_AWD1;
} | insane-adding-machines/unicore-mx | C++ | GNU General Public License v3.0 | 50 |
/* convert from the zero-based int to the byte/word for usb descriptor */ | static int convert_bytes_value(struct usb_mixer_elem_info *cval, int val) | /* convert from the zero-based int to the byte/word for usb descriptor */
static int convert_bytes_value(struct usb_mixer_elem_info *cval, int val) | {
switch (cval->val_type) {
case USB_MIXER_BOOLEAN:
return !!val;
case USB_MIXER_INV_BOOLEAN:
return !val;
case USB_MIXER_S8:
case USB_MIXER_U8:
return val & 0xff;
case USB_MIXER_S16:
case USB_MIXER_U16:
return val & 0xffff;
}
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Check if TPM chip is activated or not. */ | BOOLEAN IsTpmUsable(VOID) | /* Check if TPM chip is activated or not. */
BOOLEAN IsTpmUsable(VOID) | {
EFI_STATUS Status;
TPM_PERMANENT_FLAGS TpmPermanentFlags;
Status = Tpm12GetCapabilityFlagPermanent (&TpmPermanentFlags);
if (EFI_ERROR (Status)) {
return FALSE;
}
return (BOOLEAN)(!TpmPermanentFlags.deactivated);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* enable/disable the pull-down. If pull-up already enabled while calling the function, we disable it. */ | int at91_pio3_set_pio_pulldown(unsigned port, unsigned pin, int is_on) | /* enable/disable the pull-down. If pull-up already enabled while calling the function, we disable it. */
int at91_pio3_set_pio_pulldown(unsigned port, unsigned pin, int is_on) | {
struct at91_port *at91_port = at91_pio_get_port(port);
u32 mask;
if (at91_port && (pin < GPIO_PER_BANK)) {
mask = 1 << pin;
if (is_on) {
at91_set_pio_pullup(port, pin, 0);
writel(mask, &at91_port->mux.pio3.ppder);
} else
writel(mask, &at91_port->mux.pio3.ppddr);
}
return 0;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Gets the pulse width of a PWM output. */ | unsigned long PWMPulseWidthGet(unsigned long ulBase, unsigned long ulPWMOut) | /* Gets the pulse width of a PWM output. */
unsigned long PWMPulseWidthGet(unsigned long ulBase, unsigned long ulPWMOut) | {
unsigned long ulGenBase, ulReg, ulLoad;
ASSERT(ulBase == PWM_BASE);
ASSERT(PWMOutValid(ulPWMOut));
ulGenBase = PWM_OUT_BADDR(ulBase, ulPWMOut);
ulLoad = HWREG(ulGenBase + PWM_O_X_LOAD);
if(PWM_IS_OUTPUT_ODD(ulPWMOut))
{
ulReg = HWREG(ulGenBase + PWM_O_X_CMPB);
}
else
{
ulReg = HWREG(ulGenBase + PWM_O_X_CMPA);
}
ulReg = ulLoad - ulReg;
if(HWREG(ulGenBase + PWM_O_X_CTL) & PWM_X_CTL_MODE)
{
ulReg = ulReg * 2;
}
return(ulReg);
} | watterott/WebRadio | C++ | null | 71 |
/* Read current logic level of all IO pins */ | int tca642x_get_val(uchar chip, uint8_t gpio_bank) | /* Read current logic level of all IO pins */
int tca642x_get_val(uchar chip, uint8_t gpio_bank) | {
uint8_t val;
uint8_t in_reg = tca642x_regs[gpio_bank].input_reg;
if (tca642x_reg_read(chip, in_reg, &val) < 0)
return -1;
return (int)val;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Following a failed create operation, we drop the dentry rather than retain a negative dentry. This avoids a problem in the event that the operation succeeded on the server, but an error in the reply path made it appear to have failed. */ | static int nfs_create(struct inode *, struct dentry *, int, struct nameidata *) | /* Following a failed create operation, we drop the dentry rather than retain a negative dentry. This avoids a problem in the event that the operation succeeded on the server, but an error in the reply path made it appear to have failed. */
static int nfs_create(struct inode *, struct dentry *, int, struct nameidata *) | {
struct iattr attr;
int error;
int open_flags = 0;
dfprintk(VFS, "NFS: create(%s/%ld), %s\n",
dir->i_sb->s_id, dir->i_ino, dentry->d_name.name);
attr.ia_mode = mode;
attr.ia_valid = ATTR_MODE;
if ((nd->flags & LOOKUP_CREATE) != 0)
open_flags = nd->intent.open.flags;
error = NFS_PROTO(dir)->create(dir, dentry, &attr, open_flags, nd);
if (error != 0)
goto out_err;
return 0;
out_err:
d_drop(dentry);
return error;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* param base CMC peripheral base address. param lowPowerMode The low power mode to be entered. See cmc_low_power_mode_t for the details. */ | void CMC_GlobalEnterLowPowerMode(CMC_Type *base, cmc_low_power_mode_t lowPowerMode) | /* param base CMC peripheral base address. param lowPowerMode The low power mode to be entered. See cmc_low_power_mode_t for the details. */
void CMC_GlobalEnterLowPowerMode(CMC_Type *base, cmc_low_power_mode_t lowPowerMode) | {
CMC_SetClockMode(base, kCMC_GateAllSystemClocksEnterLowPowerMode);
CMC_SetGlobalPowerMode(base, lowPowerMode);
(void)base->GPMCTRL;
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
__DSB();
__WFI();
__ISB();
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* ADC group regular end of sequence conversions interruption callback. */ | void AdcGrpRegularSequenceConvComplete_Callback() | /* ADC group regular end of sequence conversions interruption callback. */
void AdcGrpRegularSequenceConvComplete_Callback() | {
ubAdcGrpRegularSequenceConvStatus = 1;
ubAdcGrpRegularSequenceConvCount++;
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* irq_udc_reconfig - Handle IRQ "UDC Change Configuration" @udc: udc device */ | static void irq_udc_reconfig(struct pxa_udc *udc) | /* irq_udc_reconfig - Handle IRQ "UDC Change Configuration" @udc: udc device */
static void irq_udc_reconfig(struct pxa_udc *udc) | {
unsigned config, interface, alternate, config_change;
u32 udccr = udc_readl(udc, UDCCR);
udc_writel(udc, UDCISR1, UDCISR1_IRCC);
udc->stats.irqs_reconfig++;
config = (udccr & UDCCR_ACN) >> UDCCR_ACN_S;
config_change = (config != udc->config);
pxa27x_change_configuration(udc, config);
interface = (udccr & UDCCR_AIN) >> UDCCR_AIN_S;
alternate = (udccr & UDCCR_AAISN) >> UDCCR_AAISN_S;
pxa27x_change_interface(udc, interface, alternate);
if (config_change)
update_pxa_ep_matches(udc);
udc_set_mask_UDCCR(udc, UDCCR_SMAC);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* param base LPSPI peripheral base address. param handle pointer to lpspi_master_edma_handle_t structure which stores the transfer state. param count Number of bytes transferred so far by the EDMA transaction. return status of status_t. */ | status_t LPSPI_MasterTransferGetCountEDMA(LPSPI_Type *base, lpspi_master_edma_handle_t *handle, size_t *count) | /* param base LPSPI peripheral base address. param handle pointer to lpspi_master_edma_handle_t structure which stores the transfer state. param count Number of bytes transferred so far by the EDMA transaction. return status of status_t. */
status_t LPSPI_MasterTransferGetCountEDMA(LPSPI_Type *base, lpspi_master_edma_handle_t *handle, size_t *count) | {
assert(handle != NULL);
if (NULL == count)
{
return kStatus_InvalidArgument;
}
if (handle->state != (uint8_t)kLPSPI_Busy)
{
*count = 0;
return kStatus_NoTransferInProgress;
}
size_t remainingByte;
remainingByte =
(uint32_t)handle->nbytes * EDMA_GetRemainingMajorLoopCount(handle->edmaRxRegToRxDataHandle->base,
handle->edmaRxRegToRxDataHandle->channel);
*count = handle->totalByteCount - remainingByte;
return kStatus_Success;
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* This function handles External lines 15 to 10 interrupt request. */ | void EXTI15_10_IRQHandler(void) | /* This function handles External lines 15 to 10 interrupt request. */
void EXTI15_10_IRQHandler(void) | {
*(__IO uint32_t *) 0xA0001000 = 0xFF;
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* Fill in the key and data for this big pair. */ | int __big_keydata(HTAB *hashp, BUFHEAD *bufp, DBT *key, DBT *val, int set) | /* Fill in the key and data for this big pair. */
int __big_keydata(HTAB *hashp, BUFHEAD *bufp, DBT *key, DBT *val, int set) | {
key->size = collect_key(hashp, bufp, 0, val, set);
if (key->size == -1)
return (-1);
key->data = (u_char *)hashp->tmp_key;
return (0);
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* This function is used for getting the count of block I/O devices that one specific block driver detects. To the PEI ATAPI driver, it returns the number of all the detected ATAPI devices it detects during the enumeration process. To the PEI legacy floppy driver, it returns the number of all the legacy devices it finds during its enumeration process. If no device is detected, then the function will return zero. */ | EFI_STATUS EFIAPI AtapiGetNumberOfBlockDevices(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This, OUT UINTN *NumberBlockDevices) | /* This function is used for getting the count of block I/O devices that one specific block driver detects. To the PEI ATAPI driver, it returns the number of all the detected ATAPI devices it detects during the enumeration process. To the PEI legacy floppy driver, it returns the number of all the legacy devices it finds during its enumeration process. If no device is detected, then the function will return zero. */
EFI_STATUS EFIAPI AtapiGetNumberOfBlockDevices(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This, OUT UINTN *NumberBlockDevices) | {
ATAPI_BLK_IO_DEV *AtapiBlkIoDev;
AtapiBlkIoDev = NULL;
AtapiBlkIoDev = PEI_RECOVERY_ATAPI_FROM_BLKIO_THIS (This);
*NumberBlockDevices = AtapiBlkIoDev->DeviceCount;
return EFI_SUCCESS;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* check if there is data in rx fifo. */ | u32 USI_UARTReadable(USI_TypeDef *USIx) | /* check if there is data in rx fifo. */
u32 USI_UARTReadable(USI_TypeDef *USIx) | {
assert_param(IS_ALL_USI_PERIPH(USIx));
if (!(USIx->RX_FIFO_STATUS & USI_RXFIFO_EMPTY)) {
return 1;
}
else {
return 0;
}
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Set up the measurement and comparison timer events. */ | static void setup_tc_events(void) | /* Set up the measurement and comparison timer events. */
static void setup_tc_events(void) | {
struct tc_events events_calib = { .on_event_perform_action = true };
tc_enable_events(&tc_calib, &events_calib);
struct tc_events events_comp = { .generate_event_on_compare_channel[0] = true };
tc_enable_events(&tc_comp, &events_comp);
tc_enable(&tc_calib);
tc_enable(&tc_comp);
} | memfault/zero-to-main | C++ | null | 200 |
/* Routine implementing u-boot chpart command. Sets new current partition based on the user supplied partition id. For partition id format see find_dev_and_part(). */ | static int do_chpart(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) | /* Routine implementing u-boot chpart command. Sets new current partition based on the user supplied partition id. For partition id format see find_dev_and_part(). */
static int do_chpart(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) | {
struct mtd_device *dev;
struct part_info *part;
u8 pnum;
if (mtdparts_init() !=0)
return 1;
if (argc < 2) {
printf("no partition id specified\n");
return 1;
}
if (find_dev_and_part(argv[1], &dev, &pnum, &part) != 0)
return 1;
current_mtd_dev = dev;
current_mtd_partnum = pnum;
current_save();
printf("partition changed to %s%d,%d\n",
MTD_DEV_TYPE(dev->id->type), dev->id->num, pnum);
return 0;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Security.9: Security Mode of Operation Initialization. If the packet info has knowledge of the active security mode of operation then this datagram can be further decoded. */ | static int dissect_2008_16_security_9(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) | /* Security.9: Security Mode of Operation Initialization. If the packet info has knowledge of the active security mode of operation then this datagram can be further decoded. */
static int dissect_2008_16_security_9(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) | {
gint offset = 0;
guint16 length;
{
gint start = offset;
guint16 value;
gint value_len;
proto_item *pi;
offset = read_c2(tvb, offset, &value, &value_len);
length = value;
pi = proto_tree_add_uint(tree, hf_security_9_length, tvb, start, offset - start, value);
validate_c2(pinfo, pi, value, value_len);
}
if (length > 0)
{
proto_tree_add_item(tree, hf_security_9_initial_state, tvb, offset, length, ENC_NA);
offset += length;
}
return offset;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Change the mode of the USB controller to device. */ | void USBDevMode(unsigned long ulBase) | /* Change the mode of the USB controller to device. */
void USBDevMode(unsigned long ulBase) | {
ASSERT(ulBase == USB0_BASE);
HWREGB(ulBase + USB_O_GPCS) = USB_GPCS_DEVMODOTG | USB_GPCS_DEVMOD;
} | feaser/openblt | C++ | GNU General Public License v3.0 | 601 |
/* 'LATCH' is hwclock ticks (see CLOCK_TICK_RATE in timex.h) per jiffy. 'tick' is usecs per jiffy. */ | static unsigned long clps711x_gettimeoffset(void) | /* 'LATCH' is hwclock ticks (see CLOCK_TICK_RATE in timex.h) per jiffy. 'tick' is usecs per jiffy. */
static unsigned long clps711x_gettimeoffset(void) | {
unsigned long hwticks;
hwticks = LATCH - (clps_readl(TC2D) & 0xffff);
return (hwticks * (tick_nsec / 1000)) / LATCH;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* SPI3 interrupt handler. Clear the SPI interrupt flag and execute the callback function. */ | void SPI3IntHandler(void) | /* SPI3 interrupt handler. Clear the SPI interrupt flag and execute the callback function. */
void SPI3IntHandler(void) | {
unsigned long ulEventFlags, ulCR1;
ulEventFlags = xHWREG(SPI3_BASE + SPI_SR);
if((ulEventFlags & SPI_SR_OVR) != 0)
{
xHWREG(SPI3_BASE + SPI_DR);
xHWREG(SPI3_BASE + SPI_SR);
}
else if((ulEventFlags & SPI_SR_MODF) != 0)
{
ulCR1 = xHWREG(SPI3_BASE + SPI_CR1);
xHWREG(SPI3_BASE + SPI_CR1) = ulCR1;
}
else if((ulEventFlags & SPI_SR_CRCERR) != 0)
{
xHWREG(SPI3_BASE + SPI_SR) &= ~SPI_SR_CRCERR;
}
if(g_pfnSPIHandlerCallbacks[2])
{
g_pfnSPIHandlerCallbacks[2](0, 0, ulEventFlags, 0);
}
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* Returns non-zero if the value is changed, zero if not changed. */ | void snd_range_mulkdiv(const snd_interval_t *a, unsigned int k, const snd_interval_t *b, snd_interval_t *c) | /* Returns non-zero if the value is changed, zero if not changed. */
void snd_range_mulkdiv(const snd_interval_t *a, unsigned int k, const snd_interval_t *b, snd_interval_t *c) | {
unsigned int r;
if (a->range.empty || b->range.empty) {
snd_range_none(c);
return;
}
c->range.empty = 0;
c->range.min = muldiv32(a->range.min, k, b->range.max, &r);
c->range.openmin = (r || a->range.openmin || b->range.openmax);
if (b->range.min > 0) {
c->range.max = muldiv32(a->range.max, k, b->range.min, &r);
if (r) {
c->range.max++;
c->range.openmax = 1;
} else {
c->range.openmax = (a->range.openmax || b->range.openmin);
}
} else {
c->range.max = UINT_MAX;
c->range.openmax = 0;
}
c->range.integer = 0;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Selects the trigger for the internal counter of batching events between XL and gyro.. */ | int32_t lsm6dso_fifo_cnt_event_batch_get(lsm6dso_ctx_t *ctx, lsm6dso_trig_counter_bdr_t *val) | /* Selects the trigger for the internal counter of batching events between XL and gyro.. */
int32_t lsm6dso_fifo_cnt_event_batch_get(lsm6dso_ctx_t *ctx, lsm6dso_trig_counter_bdr_t *val) | {
lsm6dso_counter_bdr_reg1_t reg;
int32_t ret;
ret = lsm6dso_read_reg(ctx, LSM6DSO_COUNTER_BDR_REG1, (uint8_t*)®, 1);
switch (reg.trig_counter_bdr) {
case LSM6DSO_XL_BATCH_EVENT:
*val = LSM6DSO_XL_BATCH_EVENT;
break;
case LSM6DSO_GYRO_BATCH_EVENT:
*val = LSM6DSO_GYRO_BATCH_EVENT;
break;
default:
*val = LSM6DSO_XL_BATCH_EVENT;
break;
}
return ret;
} | alexander-g-dean/ESF | C++ | null | 41 |
/* DMA Stream Read Interrupt Flag.
The interrupt flag for the stream is returned. */ | bool dma_get_interrupt_flag(uint32_t dma, uint8_t stream, uint32_t interrupt) | /* DMA Stream Read Interrupt Flag.
The interrupt flag for the stream is returned. */
bool dma_get_interrupt_flag(uint32_t dma, uint8_t stream, uint32_t interrupt) | {
uint32_t flag = (interrupt << DMA_ISR_OFFSET(stream));
if (stream < 4) {
return ((DMA_LISR(dma) & flag) > 0);
} else {
return ((DMA_HISR(dma) & flag) > 0);
}
} | insane-adding-machines/unicore-mx | C++ | GNU General Public License v3.0 | 50 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.