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
|
|---|---|---|---|---|---|---|---|
/* Starts the transfer of len bytes from the data array on the specified serial port. */
|
uint8_t TbxMbUartTransmit(tTbxMbUartPort port, uint8_t const *data, uint16_t len)
|
/* Starts the transfer of len bytes from the data array on the specified serial port. */
uint8_t TbxMbUartTransmit(tTbxMbUartPort port, uint8_t const *data, uint16_t len)
|
{
uint8_t result = TBX_ERROR;
TBX_ASSERT((port < TBX_MB_UART_NUM_PORT) &&
(data != NULL) &&
(len > 0U));
if ((port < TBX_MB_UART_NUM_PORT) &&
(data != NULL) &&
(len > 0U))
{
result = TbxMbPortUartTransmit(port, data, len);
}
return result;
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* Restore CPU exception context when handling EFI_VECTOR_HANDOFF_HOOK_AFTER case. */
|
VOID ArchRestoreExceptionContext(IN UINTN ExceptionType, IN EFI_SYSTEM_CONTEXT SystemContext, IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData)
|
/* Restore CPU exception context when handling EFI_VECTOR_HANDOFF_HOOK_AFTER case. */
VOID ArchRestoreExceptionContext(IN UINTN ExceptionType, IN EFI_SYSTEM_CONTEXT SystemContext, IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData)
|
{
RESERVED_VECTORS_DATA *ReservedVectors;
ReservedVectors = ExceptionHandlerData->ReservedVectors;
SystemContext.SystemContextIa32->Eflags = ReservedVectors[ExceptionType].OldFlags;
SystemContext.SystemContextIa32->Cs = ReservedVectors[ExceptionType].OldCs;
SystemContext.SystemContextIa32->Eip = ReservedVectors[ExceptionType].OldIp;
SystemContext.SystemContextIa32->ExceptionData = ReservedVectors[ExceptionType].ExceptionData;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Return value: Position of the added entry in the array */
|
static int pcie_port_msix_add_entry(struct msix_entry *entries, int new_entry, int nr_entries)
|
/* Return value: Position of the added entry in the array */
static int pcie_port_msix_add_entry(struct msix_entry *entries, int new_entry, int nr_entries)
|
{
int j;
for (j = 0; j < nr_entries; j++)
if (entries[j].entry == new_entry)
return j;
entries[j].entry = new_entry;
return j;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Detect if SD card is correctly plugged in the memory slot. */
|
uint8_t SD_Detect(void)
|
/* Detect if SD card is correctly plugged in the memory slot. */
uint8_t SD_Detect(void)
|
{
__IO uint8_t status = SD_PRESENT;
if (GPIO_ReadInputDataBit(SD_DETECT_GPIO_PORT, SD_DETECT_PIN) != Bit_RESET)
{
status = SD_NOT_PRESENT;
}
return status;
}
|
avem-labs/Avem
|
C++
|
MIT License
| 1,752
|
/* Send SET_DATA_WIDTH command to set SD bus width. */
|
static status_t SD_SetDataBusWidth(sd_card_t *card, sd_data_bus_width_t width)
|
/* Send SET_DATA_WIDTH command to set SD bus width. */
static status_t SD_SetDataBusWidth(sd_card_t *card, sd_data_bus_width_t width)
|
{
assert(card);
HOST_TRANSFER content = {0};
HOST_COMMAND command = {0};
if (kStatus_Success != SD_SendApplicationCmd(card, card->relativeAddress))
{
return kStatus_SDMMC_SendApplicationCommandFailed;
}
command.index = kSD_ApplicationSetBusWdith;
command.responseType = kCARD_ResponseTypeR1;
switch (width)
{
case kSD_DataBusWidth1Bit:
command.argument = 0U;
break;
case kSD_DataBusWidth4Bit:
command.argument = 2U;
break;
default:
return kStatus_InvalidArgument;
}
content.command = &command;
content.data = NULL;
if ((kStatus_Success != card->host.transfer(card->host.base, &content)) ||
((command.response[0U]) & kSDMMC_R1ErrorAllFlag))
{
return kStatus_SDMMC_TransferFailed;
}
return kStatus_Success;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* A device has been "downed" remove its link status. Blow away all through routes and connections that use this device. */
|
void rose_link_device_down(struct net_device *dev)
|
/* A device has been "downed" remove its link status. Blow away all through routes and connections that use this device. */
void rose_link_device_down(struct net_device *dev)
|
{
struct rose_neigh *rose_neigh;
for (rose_neigh = rose_neigh_list; rose_neigh != NULL; rose_neigh = rose_neigh->next) {
if (rose_neigh->dev == dev) {
rose_del_route_by_neigh(rose_neigh);
rose_kill_by_neigh(rose_neigh);
}
}
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* An abort indicates that the current memory access cannot be completed, which occurs during an instruction prefetch. */
|
void rt_hw_trap_pabt(struct rt_hw_register *regs)
|
/* An abort indicates that the current memory access cannot be completed, which occurs during an instruction prefetch. */
void rt_hw_trap_pabt(struct rt_hw_register *regs)
|
{
rt_kprintf("prefetch abort\n");
rt_hw_show_register(regs);
if (rt_thread_self() != RT_NULL)
rt_kprintf("Current Thread: %s\n", rt_thread_self()->name);
rt_hw_cpu_shutdown();
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* Allocate a memory block from a block of memory declared with MEMB(). */
|
char* memb_alloc(struct memb_blocks *m)
|
/* Allocate a memory block from a block of memory declared with MEMB(). */
char* memb_alloc(struct memb_blocks *m)
|
{
int i;
char *ptr;
ptr = m->mem;
for(i = 0; i < m->num; ++i) {
if(*ptr == 0) {
++*ptr;
return ptr + 1;
}
ptr += m->size + 1;
}
return NULL;
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* Returns the highest bit set of the State field */
|
STATIC EFI_FFS_FILE_STATE GetFileState(IN UINT8 ErasePolarity, IN EFI_FFS_FILE_HEADER *FfsHeader)
|
/* Returns the highest bit set of the State field */
STATIC EFI_FFS_FILE_STATE GetFileState(IN UINT8 ErasePolarity, IN EFI_FFS_FILE_HEADER *FfsHeader)
|
{
EFI_FFS_FILE_STATE FileState;
EFI_FFS_FILE_STATE HighestBit;
FileState = FfsHeader->State;
if (ErasePolarity != 0) {
FileState = (EFI_FFS_FILE_STATE) ~FileState;
}
HighestBit = 0x80;
while (HighestBit != 0 && (HighestBit & FileState) == 0) {
HighestBit >>= 1;
}
return HighestBit;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* PE calls this function to get the Source Caps that will be sent to the Sink. */
|
int port0_policy_cb_get_src_caps(const struct device *dev, const uint32_t **pdos, uint32_t *num_pdos)
|
/* PE calls this function to get the Source Caps that will be sent to the Sink. */
int port0_policy_cb_get_src_caps(const struct device *dev, const uint32_t **pdos, uint32_t *num_pdos)
|
{
struct port0_data_t *dpm_data = usbc_get_dpm_data(dev);
*pdos = dpm_data->src_caps;
*num_pdos = dpm_data->src_cap_cnt;
return 0;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Deserializes the supplied (wire) buffer into unsuback data */
|
int MQTTDeserialize_unsuback(unsigned short *packetid, unsigned char *buf, int buflen)
|
/* Deserializes the supplied (wire) buffer into unsuback data */
int MQTTDeserialize_unsuback(unsigned short *packetid, unsigned char *buf, int buflen)
|
{
unsigned char type = 0;
unsigned char dup = 0;
int rc = 0;
FUNC_ENTRY;
rc = MQTTDeserialize_ack(&type, &dup, packetid, buf, buflen);
if (type == UNSUBACK)
rc = 1;
FUNC_EXIT_RC(rc);
return rc;
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* Enable the 32 kHz clock output to other peripherals. */
|
void RTCClockOutputPeripheralsEnable(void)
|
/* Enable the 32 kHz clock output to other peripherals. */
void RTCClockOutputPeripheralsEnable(void)
|
{
xHWREG(RTC_CR) &= ~RTC_CR_CLKO;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Wait for one or more Signal Flags to become signaled for the current */
|
os_InRegs osEvent osSignalWait(int32_t signals, uint32_t millisec)
|
/* Wait for one or more Signal Flags to become signaled for the current */
os_InRegs osEvent osSignalWait(int32_t signals, uint32_t millisec)
|
{
thread->event_group = xEventGroupCreate();
}
EventBits_t bits = xEventGroupWaitBits(
thread->event_group,
signals,
pdTRUE,
pdTRUE,
millisec / portTICK_PERIOD_MS);
if (bits & signals) {
event.status = osEventSignal;
event.value.v = bits;
} else {
event.status = osEventTimeout;
}
return event;
}
|
labapart/polymcu
|
C++
| null | 201
|
/* Called whenever a 32-bit process running under a 64-bit kernel performs an ioctl on /dev/dri/card<n>. */
|
long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
|
/* Called whenever a 32-bit process running under a 64-bit kernel performs an ioctl on /dev/dri/card<n>. */
long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
|
{
unsigned int nr = DRM_IOCTL_NR(cmd);
drm_ioctl_compat_t *fn = NULL;
int ret;
if (nr < DRM_COMMAND_BASE)
return drm_compat_ioctl(filp, cmd, arg);
if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
if (fn != NULL)
ret = (*fn) (filp, cmd, arg);
else
ret = drm_ioctl(filp, cmd, arg);
return ret;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Write/copy data associated with an ASCII or opaque tag value. */
|
static int TIFFWriteByteArray(TIFF *, TIFFDirEntry *, char *)
|
/* Write/copy data associated with an ASCII or opaque tag value. */
static int TIFFWriteByteArray(TIFF *, TIFFDirEntry *, char *)
|
{
if (dir->tdir_count > 4) {
if (!TIFFWriteData(tif, dir, cp))
return (0);
} else
_TIFFmemcpy(&dir->tdir_offset, cp, dir->tdir_count);
return (1);
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* Master finish up a transfer. It would call back if there is callback function and set the state to idle. This is not a public API. */
|
static void LPSPI_MasterTransferComplete(LPSPI_Type *base, lpspi_master_handle_t *handle)
|
/* Master finish up a transfer. It would call back if there is callback function and set the state to idle. This is not a public API. */
static void LPSPI_MasterTransferComplete(LPSPI_Type *base, lpspi_master_handle_t *handle)
|
{
assert(handle != NULL);
LPSPI_DisableInterrupts(base, (uint32_t)kLPSPI_AllInterruptEnable);
handle->state = (uint8_t)kLPSPI_Idle;
if (handle->callback != NULL)
{
handle->callback(base, handle, kStatus_Success, handle->userData);
}
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Helper function to add all the known stable barkers to the barker database. */
|
static int i2400m_barker_db_known_barkers(void)
|
/* Helper function to add all the known stable barkers to the barker database. */
static int i2400m_barker_db_known_barkers(void)
|
{
int result;
result = i2400m_barker_db_add(I2400M_NBOOT_BARKER);
if (result < 0)
goto error_add;
result = i2400m_barker_db_add(I2400M_SBOOT_BARKER);
if (result < 0)
goto error_add;
result = i2400m_barker_db_add(I2400M_SBOOT_BARKER_6050);
if (result < 0)
goto error_add;
error_add:
return result;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Puts a data element into the SSI transmit FIFO as the end of a frame. */
|
int32_t SSIAdvDataPutFrameEndNonBlocking(uint32_t ui32Base, uint32_t ui32Data)
|
/* Puts a data element into the SSI transmit FIFO as the end of a frame. */
int32_t SSIAdvDataPutFrameEndNonBlocking(uint32_t ui32Base, uint32_t ui32Data)
|
{
ASSERT(_SSIBaseValid(ui32Base));
ASSERT((ui32Data & 0xff) == 0);
if(HWREG(ui32Base + SSI_O_SR) & SSI_SR_TNF)
{
HWREG(ui32Base + SSI_O_CR1) |= SSI_CR1_EOM;
HWREG(ui32Base + SSI_O_DR) = ui32Data;
return(1);
}
else
{
return(0);
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Retrieve a last message from the list, using position in fifo. */
|
static unsigned short fas216_get_last_msg(FAS216_Info *info, int pos)
|
/* Retrieve a last message from the list, using position in fifo. */
static unsigned short fas216_get_last_msg(FAS216_Info *info, int pos)
|
{
unsigned short packed_msg = NOP;
struct message *msg;
int msgnr = 0;
while ((msg = msgqueue_getmsg(&info->scsi.msgs, msgnr++)) != NULL) {
if (pos >= msg->fifo)
break;
}
if (msg) {
if (msg->msg[0] == EXTENDED_MESSAGE)
packed_msg = EXTENDED_MESSAGE | msg->msg[2] << 8;
else
packed_msg = msg->msg[0];
}
fas216_log(info, LOG_MESSAGES,
"Message: %04x found at position %02x\n", packed_msg, pos);
return packed_msg;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* For version 0 file format; this function is only for backwards compatibility for files created with the prior versions of eCryptfs. */
|
static void set_default_header_data(struct ecryptfs_crypt_stat *crypt_stat)
|
/* For version 0 file format; this function is only for backwards compatibility for files created with the prior versions of eCryptfs. */
static void set_default_header_data(struct ecryptfs_crypt_stat *crypt_stat)
|
{
crypt_stat->num_header_bytes_at_front =
ECRYPTFS_MINIMUM_HEADER_EXTENT_SIZE;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Returns: Always 0 (return value required by FC transport template) */
|
int fcoe_reset(struct Scsi_Host *)
|
/* Returns: Always 0 (return value required by FC transport template) */
int fcoe_reset(struct Scsi_Host *)
|
{
struct fc_lport *lport = shost_priv(shost);
fc_lport_reset(lport);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Fills each CAN1_PELI_InitStruct member with its default value. */
|
void CAN_Peli_StructInit(CAN_Peli_InitTypeDef *init_struct)
|
/* Fills each CAN1_PELI_InitStruct member with its default value. */
void CAN_Peli_StructInit(CAN_Peli_InitTypeDef *init_struct)
|
{
init_struct->BRP = 0x0;
init_struct->SJW = 0x0;
init_struct->TESG1 = 0x0;
init_struct->TESG2 = 0x0;
init_struct->SAM = RESET;
init_struct->LOM = DISABLE;
init_struct->STM = DISABLE;
init_struct->SM = DISABLE;
init_struct->SRR = DISABLE;
init_struct->EWLR = 0x96;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* vma is the first one with address < vma->vm_start. Have to extend vma. */
|
static int expand_downwards(struct vm_area_struct *vma, unsigned long address)
|
/* vma is the first one with address < vma->vm_start. Have to extend vma. */
static int expand_downwards(struct vm_area_struct *vma, unsigned long address)
|
{
int error;
if (unlikely(anon_vma_prepare(vma)))
return -ENOMEM;
address &= PAGE_MASK;
error = security_file_mmap(NULL, 0, 0, 0, address, 1);
if (error)
return error;
anon_vma_lock(vma);
if (address < vma->vm_start) {
unsigned long size, grow;
size = vma->vm_end - address;
grow = (vma->vm_start - address) >> PAGE_SHIFT;
error = acct_stack_growth(vma, size, grow);
if (!error) {
vma->vm_start = address;
vma->vm_pgoff -= grow;
}
}
anon_vma_unlock(vma);
return error;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* System clock peripheral aon disable.
Use this function to enable system clock peripheral aon. */
|
enum status_code system_clock_peripheral_aon_disable(enum system_peripheral_aon peripheral_aon)
|
/* System clock peripheral aon disable.
Use this function to enable system clock peripheral aon. */
enum status_code system_clock_peripheral_aon_disable(enum system_peripheral_aon peripheral_aon)
|
{
switch (peripheral_aon) {
case PERIPHERAL_AON_SLEEP_TIMER:
AON_GP_REGS0->AON_MISC_CTRL.reg &= \
~AON_GP_REGS_AON_MISC_CTRL_AON_SLEEP_TIMER_CLK_EN;
break;
case PERIPHERAL_AON_PD:
AON_GP_REGS0->AON_MISC_CTRL.reg &= \
~AON_GP_REGS_AON_MISC_CTRL_AON_EXT_32KHZ_OUT_EN;
break;
default:
return STATUS_ERR_INVALID_ARG;
}
return STATUS_OK;
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* SYSCTRL IIR0 Bus&Function Clock Enable and Reset Release. */
|
void LL_SYSCTRL_IIR0_ClkEnRstRelease(void)
|
/* SYSCTRL IIR0 Bus&Function Clock Enable and Reset Release. */
void LL_SYSCTRL_IIR0_ClkEnRstRelease(void)
|
{
__LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL);
__LL_SYSCTRL_IIR0BusClk_En(SYSCTRL);
__LL_SYSCTRL_IIR0FunClk_En(SYSCTRL);
__LL_SYSCTRL_IIR0SoftRst_Release(SYSCTRL);
__LL_SYSCTRL_Reg_Lock(SYSCTRL);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Function that updates the USI flow control timers. */
|
void usi_txrx_block_timer(void)
|
/* Function that updates the USI flow control timers. */
void usi_txrx_block_timer(void)
|
{
uint8_t i;
for (i = 0; i < NUM_PORTS; i++) {
if (usi_cfg_param[i].us_rx_block_timer) {
usi_cfg_param[i].us_rx_block_timer--;
}
if (usi_cfg_param[i].us_tx_block_timer) {
usi_cfg_param[i].us_tx_block_timer--;
}
}
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* If the system is REALLY out of memory this function returns 0, otherwise 1. */
|
int idr_pre_get(struct idr *idp, gfp_t gfp_mask)
|
/* If the system is REALLY out of memory this function returns 0, otherwise 1. */
int idr_pre_get(struct idr *idp, gfp_t gfp_mask)
|
{
while (idp->id_free_cnt < IDR_FREE_MAX) {
struct idr_layer *new;
new = kmem_cache_zalloc(idr_layer_cache, gfp_mask);
if (new == NULL)
return (0);
move_to_free_list(idp, new);
}
return 1;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Same for realloc() Note: keep the logic in here the same as in heap_caps_malloc_default (or merge the two as soon as this gets more complex...) */
|
IRAM_ATTR void* heap_caps_realloc_default(void *ptr, size_t size)
|
/* Same for realloc() Note: keep the logic in here the same as in heap_caps_malloc_default (or merge the two as soon as this gets more complex...) */
IRAM_ATTR void* heap_caps_realloc_default(void *ptr, size_t size)
|
{
if (malloc_alwaysinternal_limit==MALLOC_DISABLE_EXTERNAL_ALLOCS) {
return heap_caps_realloc( ptr, size, MALLOC_CAP_DEFAULT | MALLOC_CAP_INTERNAL );
} else {
void *r;
if (size <= malloc_alwaysinternal_limit) {
r=heap_caps_realloc( ptr, size, MALLOC_CAP_DEFAULT | MALLOC_CAP_INTERNAL );
} else {
r=heap_caps_realloc( ptr, size, MALLOC_CAP_DEFAULT | MALLOC_CAP_SPIRAM );
}
if (r==NULL && size>0) {
r=heap_caps_realloc( ptr, size, MALLOC_CAP_DEFAULT );
}
return r;
}
}
|
retro-esp32/RetroESP32
|
C++
|
Creative Commons Attribution Share Alike 4.0 International
| 581
|
/* Sets the cursor to the specified X/Y position. */
|
void ssd1331SetCursor(uint8_t x, uint8_t y)
|
/* Sets the cursor to the specified X/Y position. */
void ssd1331SetCursor(uint8_t x, uint8_t y)
|
{
if ((x >= ssd1331Properties.width) || (y >= ssd1331Properties.height))
return;
CMD(SSD1331_CMD_SETCOLUMN);
CMD(x);
CMD(ssd1331Properties.width-1);
CMD(SSD1331_CMD_SETROW);
CMD(y);
CMD(ssd1331Properties.height-1);
}
|
microbuilder/LPC1343CodeBase
|
C++
|
Other
| 73
|
/* Enables or disables I2C Idle Clock Timeout (Bus idle SCL and SDA high detection). */
|
void I2C_IdleClockTimeoutCmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
|
/* Enables or disables I2C Idle Clock Timeout (Bus idle SCL and SDA high detection). */
void I2C_IdleClockTimeoutCmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
|
{
assert_param(IS_I2C_ALL_PERIPH(I2Cx));
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
I2Cx->TIMEOUTR |= I2C_TIMEOUTR_TIDLE;
}
else
{
I2Cx->TIMEOUTR &= (uint32_t)~((uint32_t)I2C_TIMEOUTR_TIDLE);
}
}
|
ajhc/demo-cortex-m3
|
C++
| null | 38
|
/* journal_dev_name: format a character string to describe on what device this journal is present. */
|
static const char* journal_dev_name(journal_t *journal, char *buffer)
|
/* journal_dev_name: format a character string to describe on what device this journal is present. */
static const char* journal_dev_name(journal_t *journal, char *buffer)
|
{
struct block_device *bdev;
if (journal->j_inode)
bdev = journal->j_inode->i_sb->s_bdev;
else
bdev = journal->j_dev;
return bdevname(bdev, buffer);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Check if the key_len is supported by the HW. Returns 0 if it is, a positive number if it is not and software fallback is required or a negative number in case the key size is not valid */
|
static int need_fallback(unsigned int key_len)
|
/* Check if the key_len is supported by the HW. Returns 0 if it is, a positive number if it is not and software fallback is required or a negative number in case the key size is not valid */
static int need_fallback(unsigned int key_len)
|
{
switch (key_len) {
case 16:
if (!(keylen_flag & AES_KEYLEN_128))
return 1;
break;
case 24:
if (!(keylen_flag & AES_KEYLEN_192))
return 1;
break;
case 32:
if (!(keylen_flag & AES_KEYLEN_256))
return 1;
break;
default:
return -1;
break;
}
return 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* The routine cancels a pending sndbuf work, calls hvc_iucv_send() to flush any buffered terminal output data and waits for completion. */
|
static void flush_sndbuf_sync(struct hvc_iucv_private *priv)
|
/* The routine cancels a pending sndbuf work, calls hvc_iucv_send() to flush any buffered terminal output data and waits for completion. */
static void flush_sndbuf_sync(struct hvc_iucv_private *priv)
|
{
int sync_wait;
cancel_delayed_work_sync(&priv->sndbuf_work);
spin_lock_bh(&priv->lock);
hvc_iucv_send(priv);
sync_wait = !list_empty(&priv->tty_outqueue);
spin_unlock_bh(&priv->lock);
if (sync_wait)
wait_event_timeout(priv->sndbuf_waitq,
tty_outqueue_empty(priv), HZ/10);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Returns a new AC97 codec structure. AC97 codecs may become refcounted soon so this interface is needed. Returns with one reference taken. */
|
struct ac97_codec* ac97_alloc_codec(void)
|
/* Returns a new AC97 codec structure. AC97 codecs may become refcounted soon so this interface is needed. Returns with one reference taken. */
struct ac97_codec* ac97_alloc_codec(void)
|
{
struct ac97_codec *codec = kzalloc(sizeof(struct ac97_codec), GFP_KERNEL);
if(!codec)
return NULL;
spin_lock_init(&codec->lock);
INIT_LIST_HEAD(&codec->list);
return codec;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Configures the tim Output Compare 1 Fast feature. */
|
void TIM_OC1FastConfig(TIM_TypeDef *tim, TIMOCFE_Typedef fast)
|
/* Configures the tim Output Compare 1 Fast feature. */
void TIM_OC1FastConfig(TIM_TypeDef *tim, TIMOCFE_Typedef fast)
|
{
MODIFY_REG(tim->CCMR1, TIM_CCMR1_OC1FEN, fast);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Decode a 32-bit index to determine the offset. */
|
INT32 VmReadIndex32(IN VM_CONTEXT *VmPtr, IN UINT32 CodeOffset)
|
/* Decode a 32-bit index to determine the offset. */
INT32 VmReadIndex32(IN VM_CONTEXT *VmPtr, IN UINT32 CodeOffset)
|
{
UINT32 Index;
INT32 Offset;
INT32 ConstUnits;
INT32 NaturalUnits;
INT32 NBits;
INT32 Mask;
Index = VmReadImmed32 (VmPtr, CodeOffset);
NBits = (Index & 0x70000000) >> 28;
NBits *= 4;
Mask = (INT32) ~0 << NBits;
NaturalUnits = Index &~Mask;
ConstUnits = ((Index &~0xF0000000) & Mask) >> NBits;
Offset = NaturalUnits * sizeof (UINTN) + ConstUnits;
if ((Index & 0x80000000) != 0) {
Offset = Offset * -1;
}
return Offset;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This is all read from chip specific data in the driver. Not all of the sca3000 series support modes other than normal. */
|
static ssize_t sca3000_show_available_measurement_modes(struct device *dev, struct device_attribute *attr, char *buf)
|
/* This is all read from chip specific data in the driver. Not all of the sca3000 series support modes other than normal. */
static ssize_t sca3000_show_available_measurement_modes(struct device *dev, struct device_attribute *attr, char *buf)
|
{
struct iio_dev *dev_info = dev_get_drvdata(dev);
struct sca3000_state *st = dev_info->dev_data;
int len = 0;
len += sprintf(buf + len, "0 - normal mode");
switch (st->info->option_mode_1) {
case SCA3000_OP_MODE_NARROW:
len += sprintf(buf + len, ", 1 - narrow mode");
break;
case SCA3000_OP_MODE_BYPASS:
len += sprintf(buf + len, ", 1 - bypass mode");
break;
};
switch (st->info->option_mode_2) {
case SCA3000_OP_MODE_WIDE:
len += sprintf(buf + len, ", 2 - wide mode");
break;
}
len += sprintf(buf + len, " 3 - motion detection \n");
return len;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Ignore Symbios chips controlled by various RAID controllers. These controllers set value 0x52414944 at RAM end - 16. */
|
static int __devinit sym_check_raid(struct sym_device *device)
|
/* Ignore Symbios chips controlled by various RAID controllers. These controllers set value 0x52414944 at RAM end - 16. */
static int __devinit sym_check_raid(struct sym_device *device)
|
{
unsigned int ram_size, ram_val;
if (!device->s.ramaddr)
return 0;
if (device->chip.features & FE_RAM8K)
ram_size = 8192;
else
ram_size = 4096;
ram_val = readl(device->s.ramaddr + ram_size - 16);
if (ram_val != 0x52414944)
return 0;
dev_info(&device->pdev->dev,
"not initializing, driven by RAID controller.\n");
return -ENODEV;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Register the handler to extract CRC32 guided section. */
|
EFI_STATUS EFIAPI PeiCrc32GuidedSectionExtractLibConstructor(IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)
|
/* Register the handler to extract CRC32 guided section. */
EFI_STATUS EFIAPI PeiCrc32GuidedSectionExtractLibConstructor(IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)
|
{
return ExtractGuidedSectionRegisterHandlers (
&gEfiCrc32GuidedSectionExtractionGuid,
Crc32GuidedSectionGetInfo,
Crc32GuidedSectionHandler
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Write to TX register using non-blocking method.
This function writes data to the TX register directly, upper layer must make sure the TX register is empty or TX FIFO has empty room before calling this function. */
|
static void UART_WriteNonBlocking(UART_Type *base, const uint8_t *data, size_t length)
|
/* Write to TX register using non-blocking method.
This function writes data to the TX register directly, upper layer must make sure the TX register is empty or TX FIFO has empty room before calling this function. */
static void UART_WriteNonBlocking(UART_Type *base, const uint8_t *data, size_t length)
|
{
assert(data);
size_t i;
for (i = 0; i < length; i++)
{
base->UTXD = data[i] & UART_UTXD_TX_DATA_MASK;
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* This routine it invoked to log the currently used active interrupt mode to the device. */
|
static void lpfc_log_intr_mode(struct lpfc_hba *phba, uint32_t intr_mode)
|
/* This routine it invoked to log the currently used active interrupt mode to the device. */
static void lpfc_log_intr_mode(struct lpfc_hba *phba, uint32_t intr_mode)
|
{
switch (intr_mode) {
case 0:
lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
"0470 Enable INTx interrupt mode.\n");
break;
case 1:
lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
"0481 Enabled MSI interrupt mode.\n");
break;
case 2:
lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
"0480 Enabled MSI-X interrupt mode.\n");
break;
default:
lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
"0482 Illegal interrupt mode.\n");
break;
}
return;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function is executed in case of error occurrence. */
|
void Error_Handler(void)
|
/* This function is executed in case of error occurrence. */
void Error_Handler(void)
|
{
HAL_RTC_DeInit(&RtcHandle);
BSP_LED_On(LED3);
while(1)
{
}
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* Function: CS_Low, CS_High Arguments: None. Description: Chip select go low / high. Return Message: None. */
|
void CS_Low(void)
|
/* Function: CS_Low, CS_High Arguments: None. Description: Chip select go low / high. Return Message: None. */
void CS_Low(void)
|
{
GPIO_PinOutClear( MX25_PORT_CS, MX25_PIN_CS );
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* This function returns the current value of the sub second match 0 register for the RTC. The value returned is in 1/32768 second increments. */
|
unsigned long HibernateRTCSSMatch0Get(void)
|
/* This function returns the current value of the sub second match 0 register for the RTC. The value returned is in 1/32768 second increments. */
unsigned long HibernateRTCSSMatch0Get(void)
|
{
return(HWREG(HIB_RTCSS) >> HIB_RTCSS_RTCSSM_S);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* read the value of the free data register */
|
uint8_t crc_free_data_register_read(void)
|
/* read the value of the free data register */
uint8_t crc_free_data_register_read(void)
|
{
uint8_t fdata;
fdata = (uint8_t)CRC_FDATA;
return (fdata);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Enables or disables the specified NOR/SRAM Memory Bank. */
|
void FSMC_NORSRAMCmd(uint32_t FSMC_Bank, FunctionalState NewState)
|
/* Enables or disables the specified NOR/SRAM Memory Bank. */
void FSMC_NORSRAMCmd(uint32_t FSMC_Bank, FunctionalState NewState)
|
{
assert_param(IS_FSMC_NORSRAM_BANK(FSMC_Bank));
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
FSMC_Bank1->BTCR[FSMC_Bank] |= FSMC_BCR1_MBKEN;
}
else
{
FSMC_Bank1->BTCR[FSMC_Bank] &= (uint32_t)(~FSMC_BCR1_MBKEN);
}
}
|
avem-labs/Avem
|
C++
|
MIT License
| 1,752
|
/* g_menu_append_section: @menu: a #GMenu @label: (allow-none): the section label, or NULL */
|
void g_menu_append_section(GMenu *menu, const gchar *label, GMenuModel *section)
|
/* g_menu_append_section: @menu: a #GMenu @label: (allow-none): the section label, or NULL */
void g_menu_append_section(GMenu *menu, const gchar *label, GMenuModel *section)
|
{
g_menu_insert_section (menu, -1, label, section);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Enable the PWM interrupt of the PWM module.
The */
|
void xPWMIntEnable(unsigned long ulBase, unsigned long ulChannel, unsigned long ulIntType)
|
/* Enable the PWM interrupt of the PWM module.
The */
void xPWMIntEnable(unsigned long ulBase, unsigned long ulChannel, unsigned long ulIntType)
|
{
PWMIntEnable(ulBase, ulChannel, ulIntType);
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Sets the LCD orientation to horizontal and vertical. */
|
void lcdSetOrientation(lcdOrientation_t orientation)
|
/* Sets the LCD orientation to horizontal and vertical. */
void lcdSetOrientation(lcdOrientation_t orientation)
|
{
uint16_t entryMode = 0x1030;
uint16_t outputControl = 0x0100;
switch (orientation)
{
case LCD_ORIENTATION_PORTRAIT:
entryMode = 0x1030;
outputControl = 0x0100;
break;
case LCD_ORIENTATION_LANDSCAPE:
entryMode = 0x1028;
outputControl = 0x0000;
break;
}
ili9328Command(ILI9328_COMMANDS_ENTRYMODE, entryMode);
ili9328Command(ILI9328_COMMANDS_DRIVEROUTPUTCONTROL1, outputControl);
lcdOrientation = orientation;
ili9328SetCursor(0, 0);
}
|
microbuilder/LPC1343CodeBase
|
C++
|
Other
| 73
|
/* param handle codec handle. param config codec configuration. return kStatus_Success is success, else initial failed. */
|
status_t HAL_CODEC_CS42888_Init(void *handle, void *config)
|
/* param handle codec handle. param config codec configuration. return kStatus_Success is success, else initial failed. */
status_t HAL_CODEC_CS42888_Init(void *handle, void *config)
|
{
assert((config != NULL) && (handle != NULL));
status_t ret = kStatus_Success;
codec_config_t *codecConfig = (codec_config_t *)config;
cs42888_config_t *devConfig = (cs42888_config_t *)(codecConfig->codecDevConfig);
cs42888_handle_t *devHandle = (cs42888_handle_t *)((uint32_t)(((codec_handle_t *)handle)->codecDevHandle));
((codec_handle_t *)handle)->codecCapability = &s_cs42888_capability;
ret = CS42888_Init(devHandle, devConfig);
if (ret != kStatus_Success)
{
return ret;
}
return kStatus_Success;
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Set the prescaler, TLOW:SEXT, TLOW:MEXT and clock high max cycles for SMBUS mode. */
|
void twihs_smbus_set_timing(Twihs *p_twihs, uint32_t ul_timing)
|
/* Set the prescaler, TLOW:SEXT, TLOW:MEXT and clock high max cycles for SMBUS mode. */
void twihs_smbus_set_timing(Twihs *p_twihs, uint32_t ul_timing)
|
{
p_twihs->TWIHS_SMBTR = ul_timing;;
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Send data contained in specified block. It will adjust data size and flush cache if necessary. If sending failed, allocated blocks will be released. */
|
static int send_block(struct backend_data *dev_data, enum msg_type msg_type, uint8_t ept_addr, size_t tx_block_index, size_t size)
|
/* Send data contained in specified block. It will adjust data size and flush cache if necessary. If sending failed, allocated blocks will be released. */
static int send_block(struct backend_data *dev_data, enum msg_type msg_type, uint8_t ept_addr, size_t tx_block_index, size_t size)
|
{
struct block_content *block;
int r;
block = block_from_index(&dev_data->conf->tx, tx_block_index);
block->header.size = size;
__sync_synchronize();
sys_cache_data_flush_range(block, size + BLOCK_HEADER_SIZE);
r = send_control_message(dev_data, msg_type, ept_addr, tx_block_index);
if (r < 0) {
release_tx_blocks(dev_data, tx_block_index, size, -1);
}
return r;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Write a set color to the screen.
Use this function to write a certain number of pixels to the same color within a set limit. Limits have to be set prior to calling this function, e.g.: */
|
void hx8347a_duplicate_pixel(const hx8347a_color_t color, uint32_t count)
|
/* Write a set color to the screen.
Use this function to write a certain number of pixels to the same color within a set limit. Limits have to be set prior to calling this function, e.g.: */
void hx8347a_duplicate_pixel(const hx8347a_color_t color, uint32_t count)
|
{
uint32_t transmit_count;
Assert(count > 0);
hx8347a_select_register(HX8347A_SRAMWRITE);
hx8347a_select_chip();
hx8347a_send_byte(HX8347A_START_WRITEREG);
transmit_count = count;
while (transmit_count--) {
hx8347a_write_packet((uint8_t *)(&color), 2);
}
hx8347a_deselect_chip();
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Put a color map to a rectangular area on the active display */
|
void lv_disp_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t *color_map)
|
/* Put a color map to a rectangular area on the active display */
void lv_disp_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t *color_map)
|
{
if(active == NULL) return;
if(active->driver.disp_map != NULL) active->driver.disp_map(x1, y1, x2, y2, color_map);
}
|
RavenSystem/esp-homekit-devices
|
C++
|
Other
| 2,577
|
/* Registers a function to be called when an interrupt occurs. */
|
void IntRegister(unsigned long ulInterrupt, void(*pfnHandler)(void))
|
/* Registers a function to be called when an interrupt occurs. */
void IntRegister(unsigned long ulInterrupt, void(*pfnHandler)(void))
|
{
unsigned long *ulNvicTbl;
ASSERT(ulInterrupt < NUM_INTERRUPTS);
ulNvicTbl = (unsigned long *)HWREG(NVIC_VTABLE);
ulNvicTbl[ulInterrupt]= (unsigned long)pfnHandler;
}
|
micropython/micropython
|
C++
|
Other
| 18,334
|
/* returns the address of the first occurrence of */
|
void* memchr(const void *s, int c, size_t n)
|
/* returns the address of the first occurrence of */
void* memchr(const void *s, int c, size_t n)
|
{
register int r0 asm("0") = (char) c;
const void *ret = s + n;
asm volatile ("0: srst %0,%1\n"
" jo 0b\n"
" jl 1f\n"
" la %0,0\n"
"1:"
: "+a" (ret), "+&a" (s) : "d" (r0) : "cc" );
return (void *) ret;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Get the FMC Read Out Protection Status is set or not. */
|
uint8_t FMC_GetReadProtectionStatus(void)
|
/* Get the FMC Read Out Protection Status is set or not. */
uint8_t FMC_GetReadProtectionStatus(void)
|
{
uint8_t flagstatus = RESET;
if(FMC->OBCS_B.READPROT != RESET)
{
flagstatus = SET;
}
else
{
flagstatus = RESET;
}
return flagstatus;
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* This function reserves GTM timer for later use. It returns gtm_timer structure to use with the rest of GTM API, you should use timer->irq to manage timer interrupt. */
|
struct gtm_timer* gtm_get_timer16(void)
|
/* This function reserves GTM timer for later use. It returns gtm_timer structure to use with the rest of GTM API, you should use timer->irq to manage timer interrupt. */
struct gtm_timer* gtm_get_timer16(void)
|
{
struct gtm *gtm = NULL;
int i;
list_for_each_entry(gtm, >ms, list_node) {
spin_lock_irq(>m->lock);
for (i = 0; i < ARRAY_SIZE(gtm->timers); i++) {
if (!gtm->timers[i].requested) {
gtm->timers[i].requested = true;
spin_unlock_irq(>m->lock);
return >m->timers[i];
}
}
spin_unlock_irq(>m->lock);
}
if (gtm)
return ERR_PTR(-EBUSY);
return ERR_PTR(-ENODEV);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* If any reserved bits in Address are set, 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 PciSegmentBitFieldWrite32(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 Value)
|
/* If any reserved bits in Address are set, 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 PciSegmentBitFieldWrite32(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 Value)
|
{
UINTN Count;
PCI_SEGMENT_INFO *SegmentInfo;
SegmentInfo = GetPciSegmentInfo (&Count);
return MmioBitFieldWrite32 (PciSegmentLibGetEcamAddress (Address, SegmentInfo, Count), StartBit, EndBit, Value);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This reclaims a channel by freeing its resources and reseting its inuse flag. */
|
static void p9_virtio_close(struct p9_client *client)
|
/* This reclaims a channel by freeing its resources and reseting its inuse flag. */
static void p9_virtio_close(struct p9_client *client)
|
{
struct virtio_chan *chan = client->trans;
mutex_lock(&virtio_9p_lock);
if (chan)
chan->inuse = false;
mutex_unlock(&virtio_9p_lock);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Setup a directory entry of an array of LONG or SLONG and write the associated indirect values. */
|
static int TIFFWriteLongArray(TIFF *, TIFFDataType, ttag_t, TIFFDirEntry *, uint32, uint32 *)
|
/* Setup a directory entry of an array of LONG or SLONG and write the associated indirect values. */
static int TIFFWriteLongArray(TIFF *, TIFFDataType, ttag_t, TIFFDirEntry *, uint32, uint32 *)
|
{
dir->tdir_tag = tag;
dir->tdir_type = (short) type;
dir->tdir_count = n;
if (n == 1) {
dir->tdir_offset = v[0];
return (1);
} else
return (TIFFWriteData(tif, dir, (char*) v));
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* Enable or disable the access control of the unit. */
|
void MPU_UnitCmd(uint32_t u32Unit, en_functional_state_t enNewState)
|
/* Enable or disable the access control of the unit. */
void MPU_UnitCmd(uint32_t u32Unit, en_functional_state_t enNewState)
|
{
uint32_t u32UnitPos = 0UL;
uint32_t u32Temp;
DDL_ASSERT(IS_MPU_UNLOCK());
DDL_ASSERT(IS_MPU_UNIT(u32Unit));
DDL_ASSERT(IS_FUNCTIONAL_STATE(enNewState));
u32Temp = u32Unit;
while (0UL != u32Temp) {
if (0UL != (u32Temp & 0x1UL)) {
if (DISABLE != enNewState) {
SET_REG32_BIT(CM_MPU->CR, MPU_CR_SMPU2E << (u32UnitPos << 3U));
} else {
CLR_REG32_BIT(CM_MPU->CR, MPU_CR_SMPU2E << (u32UnitPos << 3U));
}
}
u32Temp >>= 1UL;
u32UnitPos++;
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Function for checking device ready pin Written by jsgood */
|
static int s3c_nand_device_ready(struct mtd_info *mtdinfo)
|
/* Function for checking device ready pin Written by jsgood */
static int s3c_nand_device_ready(struct mtd_info *mtdinfo)
|
{
return !!(readl(NFSTAT) & NFSTAT_RnB);
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* ISR handler for a specific vector index in the interrupt vector table for linking the actual interrupts vectors to the one in the user program's vector table. */
|
void Vector40_handler(void)
|
/* ISR handler for a specific vector index in the interrupt vector table for linking the actual interrupts vectors to the one in the user program's vector table. */
void Vector40_handler(void)
|
{
asm
{
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (40 * 2))
JMP 0,X
}
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* Remove congestion control algorithm, called from the module's remove function. Module ref counts are used to ensure that this can't be done till all sockets using that method are closed. */
|
void tcp_unregister_congestion_control(struct tcp_congestion_ops *ca)
|
/* Remove congestion control algorithm, called from the module's remove function. Module ref counts are used to ensure that this can't be done till all sockets using that method are closed. */
void tcp_unregister_congestion_control(struct tcp_congestion_ops *ca)
|
{
spin_lock(&tcp_cong_list_lock);
list_del_rcu(&ca->list);
spin_unlock(&tcp_cong_list_lock);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* fc_rport_destroy() - Free a remote port after last reference is released @kref: The remote port's kref */
|
static void fc_rport_destroy(struct kref *kref)
|
/* fc_rport_destroy() - Free a remote port after last reference is released @kref: The remote port's kref */
static void fc_rport_destroy(struct kref *kref)
|
{
struct fc_rport_priv *rdata;
rdata = container_of(kref, struct fc_rport_priv, kref);
kfree(rdata);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Translate a guest virtual address to a guest physical address. */
|
int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu, struct kvm_translation *tr)
|
/* Translate a guest virtual address to a guest physical address. */
int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu, struct kvm_translation *tr)
|
{
unsigned long vaddr = tr->linear_address;
gpa_t gpa;
vcpu_load(vcpu);
down_read(&vcpu->kvm->slots_lock);
gpa = vcpu->arch.mmu.gva_to_gpa(vcpu, vaddr);
up_read(&vcpu->kvm->slots_lock);
tr->physical_address = gpa;
tr->valid = gpa != UNMAPPED_GVA;
tr->writeable = 1;
tr->usermode = 0;
vcpu_put(vcpu);
return 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Selects Batching Data Rate (writing frequency in FIFO) for accelerometer data.. */
|
int32_t lsm6dsl_fifo_xl_batch_set(stmdev_ctx_t *ctx, lsm6dsl_dec_fifo_xl_t val)
|
/* Selects Batching Data Rate (writing frequency in FIFO) for accelerometer data.. */
int32_t lsm6dsl_fifo_xl_batch_set(stmdev_ctx_t *ctx, lsm6dsl_dec_fifo_xl_t val)
|
{
lsm6dsl_fifo_ctrl3_t fifo_ctrl3;
int32_t ret;
ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_CTRL3, (uint8_t*)&fifo_ctrl3, 1);
if(ret == 0){
fifo_ctrl3.dec_fifo_xl = (uint8_t)val;
ret = lsm6dsl_write_reg(ctx, LSM6DSL_FIFO_CTRL3,
(uint8_t*)&fifo_ctrl3, 1);
}
return ret;
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Checks whether the specified DMAy Channelx flag is set or not. */
|
FlagStatus DMA_GetFlagStatus(uint32_t DMAy_FLAG)
|
/* Checks whether the specified DMAy Channelx flag is set or not. */
FlagStatus DMA_GetFlagStatus(uint32_t DMAy_FLAG)
|
{
FlagStatus bitstatus = RESET;
uint32_t tmpreg = 0;
assert_param(IS_DMA_GET_FLAG(DMAy_FLAG));
if ((DMAy_FLAG & FLAG_Mask) == (uint32_t)RESET)
{
tmpreg = DMA1->ISR ;
}
if ((tmpreg & DMAy_FLAG) != (uint32_t)RESET)
{
bitstatus = SET;
}
else
{
bitstatus = RESET;
}
return bitstatus;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Attach the iSCSI connection to the iSCSI session. */
|
VOID IScsiAttatchConnection(IN OUT ISCSI_SESSION *Session, IN OUT ISCSI_CONNECTION *Conn)
|
/* Attach the iSCSI connection to the iSCSI session. */
VOID IScsiAttatchConnection(IN OUT ISCSI_SESSION *Session, IN OUT ISCSI_CONNECTION *Conn)
|
{
InsertTailList (&Session->Conns, &Conn->Link);
Conn->Session = Session;
Session->NumConns++;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* serial core request to return RI, CTS, DCD and DSR pin state */
|
static unsigned int bcm_uart_get_mctrl(struct uart_port *port)
|
/* serial core request to return RI, CTS, DCD and DSR pin state */
static unsigned int bcm_uart_get_mctrl(struct uart_port *port)
|
{
unsigned int val, mctrl;
mctrl = 0;
val = bcm_uart_readl(port, UART_EXTINP_REG);
if (val & UART_EXTINP_RI_MASK)
mctrl |= TIOCM_RI;
if (val & UART_EXTINP_CTS_MASK)
mctrl |= TIOCM_CTS;
if (val & UART_EXTINP_DCD_MASK)
mctrl |= TIOCM_CD;
if (val & UART_EXTINP_DSR_MASK)
mctrl |= TIOCM_DSR;
return mctrl;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Shell command that prints the vbus measures for all available USB-C ports. */
|
static int cmd_tcpc_vbus(const struct shell *sh, size_t argc, char **argv)
|
/* Shell command that prints the vbus measures for all available USB-C ports. */
static int cmd_tcpc_vbus(const struct shell *sh, size_t argc, char **argv)
|
{
int ret = 0;
if (argc <= 1) {
DT_FOREACH_STATUS_OKAY(usb_c_connector, TCPC_VBUS_CONN_NODE);
} else {
const struct device *dev = device_get_binding(argv[1]);
if (dev != NULL) {
TCPC_VBUS_DEV(dev);
} else {
ret = -ENODEV;
}
}
return ret;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* @dev: the keyboard emulation device @scancode: scancode buffer with USB_KBD_BOOT_REPORT_SIZE bytes */
|
int sandbox_usb_keyb_add_string(struct udevice *dev, const char scancode[USB_KBD_BOOT_REPORT_SIZE])
|
/* @dev: the keyboard emulation device @scancode: scancode buffer with USB_KBD_BOOT_REPORT_SIZE bytes */
int sandbox_usb_keyb_add_string(struct udevice *dev, const char scancode[USB_KBD_BOOT_REPORT_SIZE])
|
{
struct sandbox_keyb_priv *priv = dev_get_priv(dev);
int ret;
ret = membuff_put(&priv->in, scancode, USB_KBD_BOOT_REPORT_SIZE);
if (ret != USB_KBD_BOOT_REPORT_SIZE)
return -ENOSPC;
return 0;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* The BIOS configured everything. Our job is not to fiddle. Just use whatever PIO the hardware is using and leave it at that. When we get some kind of nice user driven API for control then we can expand on this as per hdparm in the base kernel. */
|
static int legacy_set_mode(struct ata_link *link, struct ata_device **unused)
|
/* The BIOS configured everything. Our job is not to fiddle. Just use whatever PIO the hardware is using and leave it at that. When we get some kind of nice user driven API for control then we can expand on this as per hdparm in the base kernel. */
static int legacy_set_mode(struct ata_link *link, struct ata_device **unused)
|
{
struct ata_device *dev;
ata_for_each_dev(dev, link, ENABLED) {
ata_dev_printk(dev, KERN_INFO, "configured for PIO\n");
dev->pio_mode = XFER_PIO_0;
dev->xfer_mode = XFER_PIO_0;
dev->xfer_shift = ATA_SHIFT_PIO;
dev->flags |= ATA_DFLAG_PIO;
}
return 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Configure UART parameters in single call.
Any pin number can be set to 0xff (or any number larger than UART_MAX_PIN) to disconnect that pin. */
|
void uart_configure(uint32_t uart, uint32_t tx_pin, uint32_t rx_pin, uint32_t rts_pin, uint32_t cts_pin, enum uart_baud br, bool enable_parity)
|
/* Configure UART parameters in single call.
Any pin number can be set to 0xff (or any number larger than UART_MAX_PIN) to disconnect that pin. */
void uart_configure(uint32_t uart, uint32_t tx_pin, uint32_t rx_pin, uint32_t rts_pin, uint32_t cts_pin, enum uart_baud br, bool enable_parity)
|
{
uart_set_pins(uart, rx_pin, tx_pin, cts_pin, rts_pin);
uint32_t reg_config = enable_parity ? UART_CONFIG_PARITY : 0;
if (rts_pin <= UART_MAX_PIN || cts_pin <= UART_MAX_PIN) {
reg_config |= UART_CONFIG_HWFC;
}
UART_CONFIG(uart) = reg_config;
uart_set_baudrate(uart, br);
}
|
libopencm3/libopencm3
|
C++
|
GNU General Public License v3.0
| 2,931
|
/* best effort, GUP based copy_from_user() that assumes IRQ or NMI context */
|
static unsigned long copy_from_user_nmi(void *to, const void __user *from, unsigned long n)
|
/* best effort, GUP based copy_from_user() that assumes IRQ or NMI context */
static unsigned long copy_from_user_nmi(void *to, const void __user *from, unsigned long n)
|
{
unsigned long offset, addr = (unsigned long)from;
int type = in_nmi() ? KM_NMI : KM_IRQ0;
unsigned long size, len = 0;
struct page *page;
void *map;
int ret;
do {
ret = __get_user_pages_fast(addr, 1, 0, &page);
if (!ret)
break;
offset = addr & (PAGE_SIZE - 1);
size = min(PAGE_SIZE - offset, n - len);
map = kmap_atomic(page, type);
memcpy(to, map+offset, size);
kunmap_atomic(map, type);
put_page(page);
len += size;
to += size;
addr += size;
} while (len < n);
return len;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* return kStatus_Success: success in setting the SNVS RTC alarm kStatus_InvalidArgument: Error because the alarm datetime format is incorrect kStatus_Fail: Error because the alarm time has already passed */
|
status_t SNVS_HP_RTC_SetAlarm(SNVS_Type *base, const snvs_hp_rtc_datetime_t *alarmTime)
|
/* return kStatus_Success: success in setting the SNVS RTC alarm kStatus_InvalidArgument: Error because the alarm datetime format is incorrect kStatus_Fail: Error because the alarm time has already passed */
status_t SNVS_HP_RTC_SetAlarm(SNVS_Type *base, const snvs_hp_rtc_datetime_t *alarmTime)
|
{
assert(alarmTime != NULL);
uint32_t alarmSeconds = 0U;
uint32_t currSeconds = 0U;
uint32_t tmp = base->HPCR;
if (!(SNVS_HP_CheckDatetimeFormat(alarmTime)))
{
return kStatus_InvalidArgument;
}
alarmSeconds = SNVS_HP_ConvertDatetimeToSeconds(alarmTime);
currSeconds = SNVS_HP_RTC_GetSeconds(base);
if (alarmSeconds < currSeconds)
{
return kStatus_Fail;
}
base->HPCR &= ~SNVS_HPCR_HPTA_EN_MASK;
while ((base->HPCR & SNVS_HPCR_HPTA_EN_MASK) != 0U)
{
}
base->HPTAMR = (uint32_t)(alarmSeconds >> 17U);
base->HPTALR = (uint32_t)(alarmSeconds << 15U);
base->HPCR = tmp;
return kStatus_Success;
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Show text on XPRO_LCD LCD glass alphanumeric field.
This function will show text on the alphanumeric field of the LCD glass. */
|
void xpro_lcd_show_text(const uint8_t *data)
|
/* Show text on XPRO_LCD LCD glass alphanumeric field.
This function will show text on the alphanumeric field of the LCD glass. */
void xpro_lcd_show_text(const uint8_t *data)
|
{
Assert(data);
uint32_t len = (uint32_t)strlen((char *) data);
len = (len > XPRO_LCD_MAX_CHAR) ? XPRO_LCD_MAX_CHAR : len;
slcd_character_map_set(SLCD_AUTOMATED_CHAR_START_FROM_BOTTOM_RIGHT,
XPRO_LCD_MAX_NUM-2);
for (uint32_t i = 0; *data != '\0'; i++) {
slcd_character_write_data(0, XPRO_LCD_TXT_SEG_INDEX_S +
i * (XPRO_LCD_MAX_NUM-1), DIGI_LUT[*(data++) - 32], 0x4002);
}
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* Initializes the DAC peripheral according to the specified parameters in the DAC_InitStruct. */
|
void DAC_Init(uint32_t DAC_Channel, DAC_InitTypeDef *DAC_InitStruct)
|
/* Initializes the DAC peripheral according to the specified parameters in the DAC_InitStruct. */
void DAC_Init(uint32_t DAC_Channel, DAC_InitTypeDef *DAC_InitStruct)
|
{
uint32_t tmpreg1 = 0, tmpreg2 = 0;
assert_param(IS_DAC_CHANNEL(DAC_Channel));
assert_param(IS_DAC_TRIGGER(DAC_InitStruct->DAC_Trigger));
assert_param(IS_DAC_OUTPUT_BUFFER_STATE(DAC_InitStruct->DAC_OutputBuffer));
tmpreg1 = DAC->CR;
tmpreg1 &= ~(CR_CLEAR_MASK << DAC_Channel);
tmpreg2 = (DAC_InitStruct->DAC_Trigger | DAC_InitStruct->DAC_OutputBuffer);
tmpreg1 |= tmpreg2 << DAC_Channel;
DAC->CR = tmpreg1;
}
|
ajhc/demo-cortex-m3
|
C++
| null | 38
|
/* Sets the address that the I2C Master places on the bus. */
|
void I2CMasterSlaveAddrSet(uint32_t ui32Base, uint8_t ui8SlaveAddr, bool bReceive)
|
/* Sets the address that the I2C Master places on the bus. */
void I2CMasterSlaveAddrSet(uint32_t ui32Base, uint8_t ui8SlaveAddr, bool bReceive)
|
{
ASSERT(_I2CBaseValid(ui32Base));
ASSERT(!(ui8SlaveAddr & 0x80));
HWREG(ui32Base + I2C_O_MSA) = (ui8SlaveAddr << 1) | bReceive;
}
|
micropython/micropython
|
C++
|
Other
| 18,334
|
/* fcoe_interface_get() - Get a reference to a FCoE interface @fcoe: The FCoE interface to be held */
|
static void fcoe_interface_get(struct fcoe_interface *fcoe)
|
/* fcoe_interface_get() - Get a reference to a FCoE interface @fcoe: The FCoE interface to be held */
static void fcoe_interface_get(struct fcoe_interface *fcoe)
|
{
kref_get(&fcoe->kref);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Notes: After command completion, there may be blocks left over which weren't finished by the previous command this can be for a number of reasons - the main one is I/O errors in the middle of the request, in which case we need to request the blocks that come after the bad sector. Notes: Upon return, cmd is a stale pointer. */
|
static void scsi_requeue_command(struct request_queue *q, struct scsi_cmnd *cmd)
|
/* Notes: After command completion, there may be blocks left over which weren't finished by the previous command this can be for a number of reasons - the main one is I/O errors in the middle of the request, in which case we need to request the blocks that come after the bad sector. Notes: Upon return, cmd is a stale pointer. */
static void scsi_requeue_command(struct request_queue *q, struct scsi_cmnd *cmd)
|
{
struct request *req = cmd->request;
unsigned long flags;
spin_lock_irqsave(q->queue_lock, flags);
scsi_unprep_request(req);
blk_requeue_request(q, req);
spin_unlock_irqrestore(q->queue_lock, flags);
scsi_run_queue(q);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Register callback routine for a GPIO interrupt group. */
|
int32_t gpio_reg_callback(uint8_t int_group, void *cb_ptr, void *cb_param)
|
/* Register callback routine for a GPIO interrupt group. */
int32_t gpio_reg_callback(uint8_t int_group, void *cb_ptr, void *cb_param)
|
{
return adi_gpio_RegisterCallback(int_group, cb_ptr, cb_param);
}
|
analogdevicesinc/EVAL-ADICUP3029
|
C++
|
Other
| 36
|
/* This function sets up the generator (Polarity, H/V values and horizontal offsets) by reading the configuration from a video timing structure. */
|
void XVtc_SetGeneratorTiming(XVtc *InstancePtr, XVtc_Timing *TimingPtr)
|
/* This function sets up the generator (Polarity, H/V values and horizontal offsets) by reading the configuration from a video timing structure. */
void XVtc_SetGeneratorTiming(XVtc *InstancePtr, XVtc_Timing *TimingPtr)
|
{
XVtc_Polarity Polarity;
XVtc_Signal Signal;
XVtc_HoriOffsets Hoff;
Xil_AssertVoid(InstancePtr != NULL);
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
Xil_AssertVoid(TimingPtr != NULL);
XVtc_ConvTiming2Signal(InstancePtr, TimingPtr, &Signal, &Hoff,
&Polarity);
XVtc_SetPolarity(InstancePtr, &Polarity);
XVtc_SetGenerator(InstancePtr, &Signal);
XVtc_SetGeneratorHoriOffset(InstancePtr, &Hoff);
}
|
ua1arn/hftrx
|
C++
| null | 69
|
/* CS8427 via SPI mode (for Audiophile), emulated I2C */
|
static void ap_cs8427_write_byte(struct snd_ice1712 *ice, unsigned char data, unsigned char tmp)
|
/* CS8427 via SPI mode (for Audiophile), emulated I2C */
static void ap_cs8427_write_byte(struct snd_ice1712 *ice, unsigned char data, unsigned char tmp)
|
{
int idx;
for (idx = 7; idx >= 0; idx--) {
tmp &= ~(ICE1712_DELTA_AP_DOUT|ICE1712_DELTA_AP_CCLK);
if (data & (1 << idx))
tmp |= ICE1712_DELTA_AP_DOUT;
snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, tmp);
udelay(5);
tmp |= ICE1712_DELTA_AP_CCLK;
snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, tmp);
udelay(5);
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Change Logs: Date Author Notes flybreak first version */
|
static void pico_pin_mode(struct rt_device *dev, rt_base_t pin, rt_uint8_t mode)
|
/* Change Logs: Date Author Notes flybreak first version */
static void pico_pin_mode(struct rt_device *dev, rt_base_t pin, rt_uint8_t mode)
|
{
RT_ASSERT((0 <= pin) && (pin < NUM_BANK0_GPIOS));
gpio_init(pin);
switch (mode)
{
case PIN_MODE_OUTPUT:
gpio_set_dir(pin, GPIO_OUT);
break;
case PIN_MODE_INPUT:
gpio_set_dir(pin, GPIO_IN);
break;
case PIN_MODE_INPUT_PULLUP:
gpio_pull_up(pin);
break;
case PIN_MODE_INPUT_PULLDOWN:
gpio_pull_down(pin);
break;
case PIN_MODE_OUTPUT_OD:
gpio_disable_pulls(pin);
break;
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Un-map previously mapped virtual memory address. This field can be set to zero only if the Map_Mem() service is also set to zero. */
|
VOID UnMapIt(IN NIC_DATA *Nic, IN UINT64 MemAddr, IN UINT32 Size, IN UINT32 Direction, IN UINT64 MappedAddr)
|
/* Un-map previously mapped virtual memory address. This field can be set to zero only if the Map_Mem() service is also set to zero. */
VOID UnMapIt(IN NIC_DATA *Nic, IN UINT64 MemAddr, IN UINT32 Size, IN UINT32 Direction, IN UINT64 MappedAddr)
|
{
if (Nic->PxeStart.UnMap_Mem != 0) {
((void (*)(UINT64, UINT64, UINT32, UINT32, UINT64))(UINTN) Nic->PxeStart.UnMap_Mem)(
Nic->PxeStart.Unique_ID,
MemAddr,
Size,
Direction,
MappedAddr
);
}
return;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Create a fragment key for temporary use; it can point to non- persistent data, and so must only be used to look up and delete entries, not to add them. */
|
static gpointer fragment_addresses_ports_temporary_key(const packet_info *pinfo, const guint32 id, const void *data _U_)
|
/* Create a fragment key for temporary use; it can point to non- persistent data, and so must only be used to look up and delete entries, not to add them. */
static gpointer fragment_addresses_ports_temporary_key(const packet_info *pinfo, const guint32 id, const void *data _U_)
|
{
fragment_addresses_ports_key *key = g_slice_new(fragment_addresses_ports_key);
copy_address_shallow(&key->src_addr, &pinfo->src);
copy_address_shallow(&key->dst_addr, &pinfo->dst);
key->src_port = pinfo->srcport;
key->dst_port = pinfo->destport;
key->id = id;
return (gpointer)key;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Deletes a previously created linked list. Afterwards, the pointer to the linked list is no longer valid and should not be used anymore. */
|
void TbxListDelete(tTbxList *list)
|
/* Deletes a previously created linked list. Afterwards, the pointer to the linked list is no longer valid and should not be used anymore. */
void TbxListDelete(tTbxList *list)
|
{
TBX_ASSERT(list != NULL);
if (list != NULL)
{
TbxCriticalSectionEnter();
TbxListClear(list);
TbxMemPoolRelease(list);
TbxCriticalSectionExit();
}
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* vpd_find_packet() - Locates and returns the specified VPD packet or NULL on error. */
|
static vpd_packet_t* vpd_find_packet(vpd_t *vpd, unsigned char ident)
|
/* vpd_find_packet() - Locates and returns the specified VPD packet or NULL on error. */
static vpd_packet_t* vpd_find_packet(vpd_t *vpd, unsigned char ident)
|
{
vpd_packet_t *packet = (vpd_packet_t *)&vpd->packets;
if (ident == VPD_PID_GI)
return NULL;
while ((packet->identifier != ident) &&
(packet->identifier != VPD_PID_TERM))
packet = vpd_get_packet(packet);
if ((packet->identifier) && (packet->identifier != ident))
return NULL;
return packet;
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* Tell whether this Operand is an known OpCode. */
|
BOOLEAN IsUnKnownOpCode(IN UINT8 Operand)
|
/* Tell whether this Operand is an known OpCode. */
BOOLEAN IsUnKnownOpCode(IN UINT8 Operand)
|
{
return Operand > EFI_IFR_MATCH2_OP ? TRUE : FALSE;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This function implements the API that's compatible with current GPIO API used in U-Boot. The request is forwarded to particular GPIO driver. Returns 0 on success, negative value on error. */
|
int gpio_direction_output(unsigned gpio, int value)
|
/* This function implements the API that's compatible with current GPIO API used in U-Boot. The request is forwarded to particular GPIO driver. Returns 0 on success, negative value on error. */
int gpio_direction_output(unsigned gpio, int value)
|
{
struct gpio_desc desc;
int ret;
ret = gpio_to_device(gpio, &desc);
if (ret)
return ret;
ret = check_reserved(&desc, "dir_output");
if (ret)
return ret;
return gpio_get_ops(desc.dev)->direction_output(desc.dev,
desc.offset, value);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Get the next sequence number based on the last used values. */
|
static uint32_t get_next_sn(uint32_t last_sn, int64_t *last_ticks, uint32_t interval_us)
|
/* Get the next sequence number based on the last used values. */
static uint32_t get_next_sn(uint32_t last_sn, int64_t *last_ticks, uint32_t interval_us)
|
{
int64_t uptime_ticks, delta_ticks;
uint64_t delta_us;
uint64_t sn_incr;
uint64_t next_sn;
uptime_ticks = k_uptime_ticks();
delta_ticks = uptime_ticks - *last_ticks;
*last_ticks = uptime_ticks;
delta_us = k_ticks_to_us_near64((uint64_t)delta_ticks);
sn_incr = delta_us / interval_us;
next_sn = (sn_incr + last_sn);
return (uint32_t)next_sn;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Configure chipselect base address and size (bytes). Size must be a power of two between 8k and 256M. */
|
int bcm63xx_set_cs_base(unsigned int cs, u32 base, unsigned int size)
|
/* Configure chipselect base address and size (bytes). Size must be a power of two between 8k and 256M. */
int bcm63xx_set_cs_base(unsigned int cs, u32 base, unsigned int size)
|
{
unsigned long flags;
u32 val;
if (!is_valid_cs(cs))
return -EINVAL;
if (size != roundup_pow_of_two(size))
return -EINVAL;
if (size < 8 * 1024 || size > 256 * 1024 * 1024)
return -EINVAL;
val = (base & MPI_CSBASE_BASE_MASK);
val |= (ilog2(size) - ilog2(8 * 1024)) << MPI_CSBASE_SIZE_SHIFT;
spin_lock_irqsave(&bcm63xx_cs_lock, flags);
bcm_mpi_writel(val, MPI_CSBASE_REG(cs));
spin_unlock_irqrestore(&bcm63xx_cs_lock, flags);
return 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* bus_probe_device - probe drivers for a new device @dev: device to probe */
|
void bus_probe_device(struct device *dev)
|
/* bus_probe_device - probe drivers for a new device @dev: device to probe */
void bus_probe_device(struct device *dev)
|
{
struct bus_type *bus = dev->bus;
int ret;
if (bus && bus->p->drivers_autoprobe) {
ret = device_attach(dev);
WARN_ON(ret < 0);
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Description: A new connection has been established using @sk, we've already labeled the socket via the request_sock struct in selinux_netlbl_inet_conn_request() but we need to set the NetLabel state here since we now have a sock structure. */
|
void selinux_netlbl_inet_csk_clone(struct sock *sk, u16 family)
|
/* Description: A new connection has been established using @sk, we've already labeled the socket via the request_sock struct in selinux_netlbl_inet_conn_request() but we need to set the NetLabel state here since we now have a sock structure. */
void selinux_netlbl_inet_csk_clone(struct sock *sk, u16 family)
|
{
struct sk_security_struct *sksec = sk->sk_security;
if (family == PF_INET)
sksec->nlbl_state = NLBL_LABELED;
else
sksec->nlbl_state = NLBL_UNSET;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* step7 of enumeration - wait a USB reset */
|
static void main_usb_enum_step7(void)
|
/* step7 of enumeration - wait a USB reset */
static void main_usb_enum_step7(void)
|
{
main_usb_wait_end_of_reset();
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Needed to print out L2 cache info used in the misc_init_r function */
|
unsigned long get_l2cr(void)
|
/* Needed to print out L2 cache info used in the misc_init_r function */
unsigned long get_l2cr(void)
|
{
unsigned long l2controlreg;
asm volatile ("mfspr %0, 1017":"=r" (l2controlreg):);
return l2controlreg;
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* Convert a CFString to a UTF-8-encoded C string; the resulting string is allocated with g_malloc(). Returns NULL if the conversion fails. */
|
char* CFString_to_C_string(CFStringRef cfstring)
|
/* Convert a CFString to a UTF-8-encoded C string; the resulting string is allocated with g_malloc(). Returns NULL if the conversion fails. */
char* CFString_to_C_string(CFStringRef cfstring)
|
{
CFIndex string_len;
char *string;
string_len = CFStringGetMaximumSizeForEncoding(CFStringGetLength(cfstring),
kCFStringEncodingUTF8);
string = (char *)g_malloc(string_len + 1);
if (!CFStringGetCString(cfstring, string, string_len + 1,
kCFStringEncodingUTF8)) {
g_free(string);
return NULL;
}
return string;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Selects decimation for timestamp batching in FIFO. Writing rate will be the maximum rate between XL and GYRO BDR divided by decimation decoder.. */
|
int32_t lsm6dso_fifo_timestamp_decimation_set(lsm6dso_ctx_t *ctx, lsm6dso_odr_ts_batch_t val)
|
/* Selects decimation for timestamp batching in FIFO. Writing rate will be the maximum rate between XL and GYRO BDR divided by decimation decoder.. */
int32_t lsm6dso_fifo_timestamp_decimation_set(lsm6dso_ctx_t *ctx, lsm6dso_odr_ts_batch_t val)
|
{
lsm6dso_fifo_ctrl4_t reg;
int32_t ret;
ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL4, (uint8_t*)®, 1);
if (ret == 0) {
reg.odr_ts_batch = (uint8_t)val;
ret = lsm6dso_write_reg(ctx, LSM6DSO_FIFO_CTRL4, (uint8_t*)®, 1);
}
return ret;
}
|
alexander-g-dean/ESF
|
C++
| null | 41
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.