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 is passed as a callback to the menu code for displaying each menu entry. */
|
static void label_print(void *data)
|
/* This is passed as a callback to the menu code for displaying each menu entry. */
static void label_print(void *data)
|
{
struct pxe_label *label = data;
const char *c = label->menu ? label->menu : label->name;
printf("%s:\t%s\n", label->num, c);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* sends a piece of data in non-blocking way. */
|
static void SAI_WriteNonBlocking(I2S_Type *base, uint32_t channel, uint32_t channelMask, uint32_t endChannel, uint8_t bitWidth, uint8_t *buffer, uint32_t size)
|
/* sends a piece of data in non-blocking way. */
static void SAI_WriteNonBlocking(I2S_Type *base, uint32_t channel, uint32_t channelMask, uint32_t endChannel, uint8_t bitWidth, uint8_t *buffer, uint32_t size)
|
{
uint32_t i = 0, j = 0U;
uint8_t m = 0;
uint8_t bytesPerWord = bitWidth / 8U;
uint32_t data = 0;
uint32_t temp = 0;
for (i = 0; i < size / bytesPerWord; i++)
{
for (j = channel; j <= endChannel; j++)
{
if (IS_SAI_FLAG_SET((1UL << j), channelMask))
{
for (m = 0; m < bytesPerWord; m++)
{
temp = (uint32_t)(*buffer);
data |= (temp << (8U * m));
buffer++;
}
base->TDR[j] = data;
data = 0;
}
}
}
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Parse the packet header at the start of each packet (input data to this decoder). */
|
static int parse_packet_header(WMAVoiceContext *s)
|
/* Parse the packet header at the start of each packet (input data to this decoder). */
static int parse_packet_header(WMAVoiceContext *s)
|
{
GetBitContext *gb = &s->gb;
unsigned int res;
if (get_bits_left(gb) < 11)
return 1;
skip_bits(gb, 4);
s->has_residual_lsps = get_bits1(gb);
do {
res = get_bits(gb, 6);
if (get_bits_left(gb) < 6 * (res == 0x3F) + s->spillover_bitsize)
return 1;
} while (res == 0x3F);
s->spillover_nbits = get_bits(gb, s->spillover_bitsize);
return 0;
}
|
DC-SWAT/DreamShell
|
C++
| null | 404
|
/* Converts a text device path node to 1394 device path structure. */
|
EFI_DEVICE_PATH_PROTOCOL* DevPathFromText1394(IN CHAR16 *TextDeviceNode)
|
/* Converts a text device path node to 1394 device path structure. */
EFI_DEVICE_PATH_PROTOCOL* DevPathFromText1394(IN CHAR16 *TextDeviceNode)
|
{
CHAR16 *GuidStr;
F1394_DEVICE_PATH *F1394DevPath;
GuidStr = GetNextParamStr (&TextDeviceNode);
F1394DevPath = (F1394_DEVICE_PATH *)CreateDeviceNode (
MESSAGING_DEVICE_PATH,
MSG_1394_DP,
(UINT16)sizeof (F1394_DEVICE_PATH)
);
F1394DevPath->Reserved = 0;
F1394DevPath->Guid = StrHexToUint64 (GuidStr);
return (EFI_DEVICE_PATH_PROTOCOL *)F1394DevPath;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Close all upvalues up to the given stack level. */
|
void luaF_closeupval(lua_State *L, StkId level)
|
/* Close all upvalues up to the given stack level. */
void luaF_closeupval(lua_State *L, StkId level)
|
{
TValue *slot = &uv->u.value;
lua_assert(uplevel(uv) < L->top);
luaF_unlinkupval(uv);
setobj(L, slot, uv->v);
uv->v = slot;
if (!iswhite(uv)) {
nw2black(uv);
luaC_barrier(L, uv, slot);
}
}
}
|
Nicholas3388/LuaNode
|
C++
|
Other
| 1,055
|
/* Returns: a newly-allocated string that must be freed with g_free(). */
|
gchar* g_build_path(const gchar *separator, const gchar *first_element,...)
|
/* Returns: a newly-allocated string that must be freed with g_free(). */
gchar* g_build_path(const gchar *separator, const gchar *first_element,...)
|
{
gchar *str;
va_list args;
g_return_val_if_fail (separator != NULL, NULL);
va_start (args, first_element);
str = g_build_path_va (separator, first_element, &args, NULL);
va_end (args);
return str;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Handle start of frame.
Called by USB stack when a start of frame is received, i.e., every millisecond during normal operation. This function triggers processing of the user interface if the HID interface has been enabled. */
|
void main_sof_action(void)
|
/* Handle start of frame.
Called by USB stack when a start of frame is received, i.e., every millisecond during normal operation. This function triggers processing of the user interface if the HID interface has been enabled. */
void main_sof_action(void)
|
{
if (!main_b_mouse_enable) {
return;
}
ui_process(udd_get_frame_number());
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Return node pointer to first packet of requested type in list. */
|
static QDM2SubPNode* qdm2_search_subpacket_type_in_list(QDM2SubPNode *list, int type)
|
/* Return node pointer to first packet of requested type in list. */
static QDM2SubPNode* qdm2_search_subpacket_type_in_list(QDM2SubPNode *list, int type)
|
{
while (list != NULL && list->packet != NULL) {
if (list->packet->type == type)
return list;
list = list->next;
}
return NULL;
}
|
DC-SWAT/DreamShell
|
C++
| null | 404
|
/* This function initializes a basic mutual exclusion lock to the released state and returns the lock. Each lock provides mutual exclusion access at its task priority level. Since there is no preemption or multiprocessor support in EFI, acquiring the lock only consists of raising to the locks TPL. If Lock is NULL, then ASSERT(). If Priority is not a valid TPL value, then ASSERT(). */
|
EFI_LOCK* EFIAPI EfiInitializeLock(IN OUT EFI_LOCK *Lock, IN EFI_TPL Priority)
|
/* This function initializes a basic mutual exclusion lock to the released state and returns the lock. Each lock provides mutual exclusion access at its task priority level. Since there is no preemption or multiprocessor support in EFI, acquiring the lock only consists of raising to the locks TPL. If Lock is NULL, then ASSERT(). If Priority is not a valid TPL value, then ASSERT(). */
EFI_LOCK* EFIAPI EfiInitializeLock(IN OUT EFI_LOCK *Lock, IN EFI_TPL Priority)
|
{
ASSERT (Lock != NULL);
ASSERT (Priority <= TPL_HIGH_LEVEL);
Lock->Tpl = Priority;
Lock->OwnerTpl = TPL_APPLICATION;
Lock->Lock = EfiLockReleased;
return Lock;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Resets a network adapter and leaves it in a state that is safe for another driver to initialize. */
|
EFI_STATUS WinNtSnpShutdown(IN EMU_SNP_PROTOCOL *This)
|
/* Resets a network adapter and leaves it in a state that is safe for another driver to initialize. */
EFI_STATUS WinNtSnpShutdown(IN EMU_SNP_PROTOCOL *This)
|
{
WIN_NT_SNP_PRIVATE *Private;
Private = WIN_NT_SNP_PRIVATE_DATA_FROM_THIS (This);
switch ( Private->Mode->State ) {
case EfiSimpleNetworkInitialized:
break;
case EfiSimpleNetworkStopped:
return EFI_NOT_STARTED;
break;
default:
return EFI_DEVICE_ERROR;
break;
}
Private->Mode->State = EfiSimpleNetworkStarted;
Private->Mode->ReceiveFilterSetting = 0;
Private->Mode->MCastFilterCount = 0;
ZeroMem (Private->Mode->MCastFilter, sizeof (Private->Mode->MCastFilter));
return EFI_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Returns if the RTC_ISR init flag RTC_ISR_INITF is set.
Requires unlocking backup domain write protection (PWR_CR_DBP) */
|
bool rtc_init_flag_is_ready(void)
|
/* Returns if the RTC_ISR init flag RTC_ISR_INITF is set.
Requires unlocking backup domain write protection (PWR_CR_DBP) */
bool rtc_init_flag_is_ready(void)
|
{
return (RTC_ISR & RTC_ISR_INITF);
}
|
libopencm3/libopencm3
|
C++
|
GNU General Public License v3.0
| 2,931
|
/* rw_verify_area doesn't like huge counts. We limit them to something that fits in "int" so that others won't have to do range checks all the time. */
|
ssize_t rw_verify_area(struct dfs_file *file, off_t *ppos, size_t count)
|
/* rw_verify_area doesn't like huge counts. We limit them to something that fits in "int" so that others won't have to do range checks all the time. */
ssize_t rw_verify_area(struct dfs_file *file, off_t *ppos, size_t count)
|
{
off_t pos;
ssize_t retval = -EINVAL;
if ((size_t)count < 0)
return retval;
pos = *ppos;
if (pos < 0)
{
if (count >= -pos)
return -EOVERFLOW;
}
return count > MAX_RW_COUNT ? MAX_RW_COUNT : count;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* In current usage, the access requests are usually for nonoverlapping strips; that is, successive access start_row numbers differ by exactly num_rows = maxaccess. This means we can get good performance with simple buffer dump/reload logic, by making the in-memory buffer be a multiple of the access height; then there will never be accesses across bufferload boundaries. The code will still work with overlapping access requests, but it doesn't handle bufferload overlaps very efficiently. */
|
request_virt_sarray(j_common_ptr cinfo, int pool_id, boolean pre_zero, JDIMENSION samplesperrow, JDIMENSION numrows, JDIMENSION maxaccess)
|
/* In current usage, the access requests are usually for nonoverlapping strips; that is, successive access start_row numbers differ by exactly num_rows = maxaccess. This means we can get good performance with simple buffer dump/reload logic, by making the in-memory buffer be a multiple of the access height; then there will never be accesses across bufferload boundaries. The code will still work with overlapping access requests, but it doesn't handle bufferload overlaps very efficiently. */
request_virt_sarray(j_common_ptr cinfo, int pool_id, boolean pre_zero, JDIMENSION samplesperrow, JDIMENSION numrows, JDIMENSION maxaccess)
|
{
my_mem_ptr mem = (my_mem_ptr)cinfo->mem;
jvirt_sarray_ptr result;
if (pool_id != JPOOL_IMAGE)
ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id);
result = (jvirt_sarray_ptr)alloc_small(cinfo, pool_id,
SIZEOF(struct jvirt_sarray_control));
result->mem_buffer = NULL;
result->rows_in_array = numrows;
result->samplesperrow = samplesperrow;
result->maxaccess = maxaccess;
result->pre_zero = pre_zero;
result->b_s_open = FALSE;
result->next = mem->virt_sarray_list;
mem->virt_sarray_list = result;
return result;
}
|
nanoframework/nf-interpreter
|
C++
|
MIT License
| 293
|
/* If 64-bit MMIO register operations are not supported, then ASSERT(). */
|
UINT64 EFIAPI MmioRead64(IN UINTN Address)
|
/* If 64-bit MMIO register operations are not supported, then ASSERT(). */
UINT64 EFIAPI MmioRead64(IN UINTN Address)
|
{
ASSERT ((Address & 7) == 0);
return (UINT64)MmioReadWorker (Address, EfiCpuIoWidthUint64);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Configures system clock after wake-up from STOP: enable HSE, PLL and select PLL as system clock source. */
|
void SYSCLKConfig_STOP(void)
|
/* Configures system clock after wake-up from STOP: enable HSE, PLL and select PLL as system clock source. */
void SYSCLKConfig_STOP(void)
|
{
RCC_HSEConfig(RCC_HSE_ON);
while (RCC_GetFlagStatus(RCC_FLAG_HSERDY) == RESET)
{}
RCC_PLLCmd(ENABLE);
while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
{}
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
while (RCC_GetSYSCLKSource() != 0x08)
{}
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* SPIFI DMA send finished callback function.
This function is called when SPIFI DMA send finished. It disables the SPIFI TX DMA request and sends kStatus_SPIFI_TxIdle to SPIFI callback. */
|
static void SPIFI_SendDMACallback(dma_handle_t *handle, void *param, bool transferDone, uint32_t intmode)
|
/* SPIFI DMA send finished callback function.
This function is called when SPIFI DMA send finished. It disables the SPIFI TX DMA request and sends kStatus_SPIFI_TxIdle to SPIFI callback. */
static void SPIFI_SendDMACallback(dma_handle_t *handle, void *param, bool transferDone, uint32_t intmode)
|
{
spifi_dma_private_handle_t *spifiPrivateHandle = (spifi_dma_private_handle_t *)param;
handle = handle;
intmode = intmode;
if (transferDone)
{
SPIFI_TransferAbortSendDMA(spifiPrivateHandle->base, spifiPrivateHandle->handle);
if (spifiPrivateHandle->handle->callback)
{
spifiPrivateHandle->handle->callback(spifiPrivateHandle->base, spifiPrivateHandle->handle,
kStatus_SPIFI_Idle, spifiPrivateHandle->handle->userData);
}
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Get the Mac address in to the address specified. The mac register contents are read and written to buffer passed. */
|
s32 synopGMAC_get_mac_addr(synopGMACdevice *gmacdev, u32 MacHigh, u32 MacLow, u8 *MacAddr)
|
/* Get the Mac address in to the address specified. The mac register contents are read and written to buffer passed. */
s32 synopGMAC_get_mac_addr(synopGMACdevice *gmacdev, u32 MacHigh, u32 MacLow, u8 *MacAddr)
|
{
u32 data;
data = synopGMACReadReg(gmacdev -> MacBase, MacHigh);
MacAddr[5] = (data >> 8) & 0xff;
MacAddr[4] = (data) & 0xff;
data = synopGMACReadReg(gmacdev -> MacBase, MacLow);
MacAddr[3] = (data >> 24) & 0xff;
MacAddr[2] = (data >> 16) & 0xff;
MacAddr[1] = (data >> 8) & 0xff;
MacAddr[0] = (data) & 0xff;
return 0;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Attach our controls and configure the necessary codec mappings for our sound card instance. */
|
static int simtec_tlv320aic23_init(struct snd_soc_codec *codec)
|
/* Attach our controls and configure the necessary codec mappings for our sound card instance. */
static int simtec_tlv320aic23_init(struct snd_soc_codec *codec)
|
{
snd_soc_dapm_new_controls(codec, dapm_widgets,
ARRAY_SIZE(dapm_widgets));
snd_soc_dapm_add_routes(codec, base_map, ARRAY_SIZE(base_map));
snd_soc_dapm_enable_pin(codec, "Headphone Jack");
snd_soc_dapm_enable_pin(codec, "Line In");
snd_soc_dapm_enable_pin(codec, "Line Out");
snd_soc_dapm_enable_pin(codec, "Mic Jack");
simtec_audio_init(codec);
snd_soc_dapm_sync(codec);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* megasas_release_mfi - Reverses the FW initialization @intance: Adapter soft state */
|
static void megasas_release_mfi(struct megasas_instance *instance)
|
/* megasas_release_mfi - Reverses the FW initialization @intance: Adapter soft state */
static void megasas_release_mfi(struct megasas_instance *instance)
|
{
u32 reply_q_sz = sizeof(u32) * (instance->max_fw_cmds + 1);
pci_free_consistent(instance->pdev, reply_q_sz,
instance->reply_queue, instance->reply_queue_h);
megasas_free_cmds(instance);
iounmap(instance->reg_set);
pci_release_selected_regions(instance->pdev,
pci_select_bars(instance->pdev, IORESOURCE_MEM));
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Initialize BLE Radio.
This API is used to initialize the bluetooth radio module.The bluetooth framework layer provides configuration information such as event callback handler.It is expected that the upper layer shall initialize the transport layer before calling this function. This API also initializes the underlying radio by sending required commands to the radio firmware. */
|
ADI_BLER_RESULT adi_radio_Init(ADI_CALLBACK pCallbackFunc)
|
/* Initialize BLE Radio.
This API is used to initialize the bluetooth radio module.The bluetooth framework layer provides configuration information such as event callback handler.It is expected that the upper layer shall initialize the transport layer before calling this function. This API also initializes the underlying radio by sending required commands to the radio firmware. */
ADI_BLER_RESULT adi_radio_Init(ADI_CALLBACK pCallbackFunc)
|
{
ADI_BLE_TRANSPORT_RESULT tResult;
ADI_BLER_RESULT bleResult;
ASSERT(pCallbackFunc != NULL);
ADI_BLE_LOGEVENT(LOGID_CMD_BLEM_INIT);
ADI_BLE_RADIO_CMD_START(CMD_BLEM_INIT);
tResult = adi_tal_Init(pCallbackFunc);
RETURN_ERROR(tResult, ADI_BLE_TRANSPORT_SUCCESS, ADI_BLER_FAILURE);
bleResult = bler_process_cmd(CMD_BLEM_INIT, 0u, NULL, 0u);
if(bleResult == ADI_BLER_SUCCESS){
bleResult = ADI_BLE_WAIT_FOR_COMPLETION(ADI_EVENT_FLAG_EVENT_COMPLETE,ADI_BLER_CMD_TIMEOUT);
}
ADI_BLE_RADIO_CMD_END();
return (bleResult);
}
|
analogdevicesinc/EVAL-ADICUP3029
|
C++
|
Other
| 36
|
/* Deinitializes the EXTI peripheral registers to their default reset values. */
|
void EXTI_DeInit(void)
|
/* Deinitializes the EXTI peripheral registers to their default reset values. */
void EXTI_DeInit(void)
|
{
EXTI->IMR = 0x00000000;
EXTI->EMR = 0x00000000;
EXTI->RTSR = 0x00000000;
EXTI->FTSR = 0x00000000;
EXTI->PR = 0x001FFFFF;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Prepare for a new ULE SNDU: reset the decoder state. */
|
static void reset_ule(struct dvb_net_priv *p)
|
/* Prepare for a new ULE SNDU: reset the decoder state. */
static void reset_ule(struct dvb_net_priv *p)
|
{
p->ule_skb = NULL;
p->ule_next_hdr = NULL;
p->ule_sndu_len = 0;
p->ule_sndu_type = 0;
p->ule_sndu_type_1 = 0;
p->ule_sndu_remain = 0;
p->ule_dbit = 0xFF;
p->ule_bridged = 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Return value: 0 on success / -EIO on failure */
|
static int ipr_set_pcix_cmd_reg(struct ipr_ioa_cfg *ioa_cfg)
|
/* Return value: 0 on success / -EIO on failure */
static int ipr_set_pcix_cmd_reg(struct ipr_ioa_cfg *ioa_cfg)
|
{
int pcix_cmd_reg = pci_find_capability(ioa_cfg->pdev, PCI_CAP_ID_PCIX);
if (pcix_cmd_reg) {
if (pci_write_config_word(ioa_cfg->pdev, pcix_cmd_reg + PCI_X_CMD,
ioa_cfg->saved_pcix_cmd_reg) != PCIBIOS_SUCCESSFUL) {
dev_err(&ioa_cfg->pdev->dev, "Failed to setup PCI-X command register\n");
return -EIO;
}
}
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Recieve or send a report to HID interface. */
|
static bool udi_hid_multi_touch_setupreport(void)
|
/* Recieve or send a report to HID interface. */
static bool udi_hid_multi_touch_setupreport(void)
|
{
if ((USB_HID_REPORT_TYPE_FEATURE == (udd_g_ctrlreq.req.wValue >> 8))
&& (UDI_HID_REPORT_ID_MAX_COUNT == (0xFF & udd_g_ctrlreq.req.wValue))
&& (sizeof(udi_hid_multi_touch_report_feature) == udd_g_ctrlreq.req.wLength)) {
udi_hid_multi_touch_report_feature[0] = UDI_HID_REPORT_ID_MAX_COUNT;
udi_hid_multi_touch_report_feature[1] = 2;
udd_g_ctrlreq.payload = udi_hid_multi_touch_report_feature;
udd_g_ctrlreq.payload_size = 2;
return true;
}
return false;
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Description: Allocate a new bio with @nr_iovecs bvecs. If @gfp_mask contains __GFP_WAIT, the allocation is guaranteed to succeed. */
|
struct bio* bio_kmalloc(gfp_t gfp_mask, int nr_iovecs)
|
/* Description: Allocate a new bio with @nr_iovecs bvecs. If @gfp_mask contains __GFP_WAIT, the allocation is guaranteed to succeed. */
struct bio* bio_kmalloc(gfp_t gfp_mask, int nr_iovecs)
|
{
struct bio *bio;
bio = kmalloc(sizeof(struct bio) + nr_iovecs * sizeof(struct bio_vec),
gfp_mask);
if (unlikely(!bio))
return NULL;
bio_init(bio);
bio->bi_flags |= BIO_POOL_NONE << BIO_POOL_OFFSET;
bio->bi_max_vecs = nr_iovecs;
bio->bi_io_vec = bio->bi_inline_vecs;
bio->bi_destructor = bio_kmalloc_destructor;
return bio;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Displays channel specific registers and other control parameters. */
|
void dmacHw_printDebugInfo(dmacHw_HANDLE_t handle, void *pDescriptor, int(*fpPrint)(const char *,...))
|
/* Displays channel specific registers and other control parameters. */
void dmacHw_printDebugInfo(dmacHw_HANDLE_t handle, void *pDescriptor, int(*fpPrint)(const char *,...))
|
{
dmacHw_CBLK_t *pCblk = dmacHw_HANDLE_TO_CBLK(handle);
DisplayRegisterContents(pCblk->module, pCblk->channel, fpPrint);
DisplayDescRing(pDescriptor, fpPrint);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Parse and handle PALO table which is published at: */
|
static void __init handle_palo(unsigned long palo_phys)
|
/* Parse and handle PALO table which is published at: */
static void __init handle_palo(unsigned long palo_phys)
|
{
struct palo_table *palo = __va(palo_phys);
u8 checksum;
if (strncmp(palo->signature, PALO_SIG, sizeof(PALO_SIG) - 1)) {
printk(KERN_INFO "PALO signature incorrect.\n");
return;
}
checksum = palo_checksum((u8 *)palo, palo->length);
if (checksum) {
printk(KERN_INFO "PALO checksum incorrect.\n");
return;
}
setup_ptcg_sem(palo->max_tlb_purges, NPTCG_FROM_PALO);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Set the number of bytes in the buffer 0 of a double Buffer endpoint. */
|
void USB_SetEpDblBuf1Cnt(uint8_t bEpNum, uint8_t bDir, uint16_t wCount)
|
/* Set the number of bytes in the buffer 0 of a double Buffer endpoint. */
void USB_SetEpDblBuf1Cnt(uint8_t bEpNum, uint8_t bDir, uint16_t wCount)
|
{
_SetEPDblBuf1Count(bEpNum, bDir, wCount);
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* The check summ offload engine is bypassed in the tx path. Checksum is not computed in the Hardware. */
|
void synopGMAC_tx_checksum_offload_bypass(synopGMACdevice *gmacdev, DmaDesc *desc)
|
/* The check summ offload engine is bypassed in the tx path. Checksum is not computed in the Hardware. */
void synopGMAC_tx_checksum_offload_bypass(synopGMACdevice *gmacdev, DmaDesc *desc)
|
{
desc->status = (desc->status & (~DescTxCisMask));
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* match_pci_device - Matches a pci device against a given hardware path entry. @dev: the generic device (known to be contained by a pci_dev). @index: the current BC index @modpath: the hardware path. */
|
static int match_pci_device(struct device *dev, int index, struct hardware_path *modpath)
|
/* match_pci_device - Matches a pci device against a given hardware path entry. @dev: the generic device (known to be contained by a pci_dev). @index: the current BC index @modpath: the hardware path. */
static int match_pci_device(struct device *dev, int index, struct hardware_path *modpath)
|
{
struct pci_dev *pdev = to_pci_dev(dev);
int id;
if (index == 5) {
unsigned int devfn = pdev->devfn;
return ((modpath->bc[5] == PCI_SLOT(devfn)) &&
(modpath->mod == PCI_FUNC(devfn)));
}
id = PCI_SLOT(pdev->devfn) | (PCI_FUNC(pdev->devfn) << 5);
return (modpath->bc[index] == id);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* parport_ip32_read_data - return current contents of the DATA register */
|
static unsigned char parport_ip32_read_data(struct parport *p)
|
/* parport_ip32_read_data - return current contents of the DATA register */
static unsigned char parport_ip32_read_data(struct parport *p)
|
{
struct parport_ip32_private * const priv = p->physport->private_data;
return readb(priv->regs.data);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Stalls the CPU for the number of microseconds specified by MicroSeconds. */
|
UINTN EFIAPI MicroSecondDelay(IN UINTN MicroSeconds)
|
/* Stalls the CPU for the number of microseconds specified by MicroSeconds. */
UINTN EFIAPI MicroSecondDelay(IN UINTN MicroSeconds)
|
{
UINTN ApicBase;
ApicBase = InternalX86GetApicBase ();
InternalX86Delay (
ApicBase,
(UINT32)DivU64x32 (
MultU64x64 (
InternalX86GetTimerFrequency (ApicBase),
MicroSeconds
),
1000000u
)
);
return MicroSeconds;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Gets timer count rate.
This function returns the number of counts per second */
|
tmrHw_RATE_t tmrHw_getCountRate(tmrHw_ID_t timerId)
|
/* Gets timer count rate.
This function returns the number of counts per second */
tmrHw_RATE_t tmrHw_getCountRate(tmrHw_ID_t timerId)
|
{
uint32_t divider = 0;
switch (pTmrHw[timerId].Control & tmrHw_CONTROL_PRESCALE_MASK) {
case tmrHw_CONTROL_PRESCALE_1:
divider = 1;
break;
case tmrHw_CONTROL_PRESCALE_16:
divider = 16;
break;
case tmrHw_CONTROL_PRESCALE_256:
divider = 256;
break;
default:
tmrHw_ASSERT(0);
}
if (timerId == 0 || timerId == 1) {
return tmrHw_divide(tmrHw_LOW_RESOLUTION_CLOCK, divider);
} else {
return tmrHw_divide(tmrHw_HIGH_RESOLUTION_CLOCK, divider);
}
return 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* This function will find an usb interface alternate setting object. */
|
ualtsetting_t rt_usbd_find_altsetting(uintf_t intf, rt_uint8_t value)
|
/* This function will find an usb interface alternate setting object. */
ualtsetting_t rt_usbd_find_altsetting(uintf_t intf, rt_uint8_t value)
|
{
struct rt_list_node *i;
ualtsetting_t setting;
LOG_D("rt_usbd_find_altsetting");
RT_ASSERT(intf != RT_NULL);
if(intf->curr_setting != RT_NULL)
{
if(intf->curr_setting->intf_desc->bAlternateSetting == value)
return intf->curr_setting;
}
for(i=intf->setting_list.next; i!=&intf->setting_list; i=i->next)
{
setting =(ualtsetting_t)rt_list_entry(i, struct ualtsetting, list);
if(setting->intf_desc->bAlternateSetting == value)
return setting;
}
rt_kprintf("can't find alternate setting %d\n", value);
return RT_NULL;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* The stream current position is moved according to the stream direction (forward, backward). */
|
EFI_STATUS EFIAPI AmlStreamProgress(IN AML_STREAM *Stream, IN UINT32 Offset)
|
/* The stream current position is moved according to the stream direction (forward, backward). */
EFI_STATUS EFIAPI AmlStreamProgress(IN AML_STREAM *Stream, IN UINT32 Offset)
|
{
if (!IS_STREAM (Stream) ||
IS_END_OF_STREAM (Stream) ||
(Offset == 0))
{
ASSERT (0);
return EFI_INVALID_PARAMETER;
}
if (AmlStreamGetFreeSpace (Stream) < Offset) {
ASSERT (0);
return EFI_BUFFER_TOO_SMALL;
}
Stream->Index += Offset;
return EFI_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Optimised routine to draw a vertical line faster than setting individual pixels. */
|
void lcdDrawVLine(uint16_t x, uint16_t y0, uint16_t y1, uint16_t color)
|
/* Optimised routine to draw a vertical line faster than setting individual pixels. */
void lcdDrawVLine(uint16_t x, uint16_t y0, uint16_t y1, uint16_t color)
|
{
if (y1 < y0)
{
uint16_t y;
y = y1;
y1 = y0;
y0 = y;
}
if(x >= hx8347dProperties.width)
{
x = hx8347dProperties.width-1;
}
if(y0 >= hx8347dProperties.height)
{
y0 = hx8347dProperties.height-1;
}
if(y1 >= hx8347dProperties.height)
{
y1 = hx8347dProperties.height-1;
}
fillRect(x, y0, x, y1, color);
}
|
microbuilder/LPC1343CodeBase
|
C++
|
Other
| 73
|
/* If Sha384Context is NULL, then return FALSE. If HashValue is NULL, then return FALSE. */
|
BOOLEAN EFIAPI Sha384Final(IN OUT VOID *Sha384Context, OUT UINT8 *HashValue)
|
/* If Sha384Context is NULL, then return FALSE. If HashValue is NULL, then return FALSE. */
BOOLEAN EFIAPI Sha384Final(IN OUT VOID *Sha384Context, OUT UINT8 *HashValue)
|
{
CALL_CRYPTO_SERVICE (Sha384Final, (Sha384Context, HashValue), FALSE);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Event handler for the library USB Configuration Changed event. */
|
void EVENT_USB_Device_ConfigurationChanged(void)
|
/* Event handler for the library USB Configuration Changed event. */
void EVENT_USB_Device_ConfigurationChanged(void)
|
{
bool ConfigSuccess = true;
ConfigSuccess &= HID_Device_ConfigureEndpoints(&Joystick_HID_Interface);
USB_Device_EnableSOFEvents();
LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR);
}
|
prusa3d/Prusa-Firmware-Buddy
|
C++
|
Other
| 1,019
|
/* This function commands the sending of a LIN header and response, MASTER task only. */
|
static uint8_t lin_tx_header_and_response(uint8_t uc_node, uint8_t uc_handle, uint8_t uc_len)
|
/* This function commands the sending of a LIN header and response, MASTER task only. */
static uint8_t lin_tx_header_and_response(uint8_t uc_node, uint8_t uc_handle, uint8_t uc_len)
|
{
memcpy(&lin_tx_buffer_node[uc_node][1],
lin_descript_list_node[uc_node][uc_handle].uc_pt_data,
uc_len);
lin_tx_buffer_node[uc_node][0]
= lin_descript_list_node[uc_node][uc_handle].uc_id;
g_st_packet[uc_node].ul_addr = (uint32_t)lin_tx_buffer_node[uc_node];
g_st_packet[uc_node].ul_size = (uc_len + 1);
pdc_tx_init(g_p_pdc[uc_node], &g_st_packet[uc_node], NULL);
usart_enable_interrupt(USART0, US_IER_LINSNRE);
pdc_enable_transfer(g_p_pdc[uc_node], PERIPH_PTCR_TXTEN);
return PASS;
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Task function for blinking the LED as a fixed timer interval. */
|
void LedBlinkTask(void)
|
/* Task function for blinking the LED as a fixed timer interval. */
void LedBlinkTask(void)
|
{
static blt_bool ledOn = BLT_FALSE;
static blt_int32u nextBlinkEvent = 0;
if (TimerGet() >= nextBlinkEvent)
{
if (ledOn == BLT_FALSE)
{
ledOn = BLT_TRUE;
LL_GPIO_SetOutputPin(GPIOB, LL_GPIO_PIN_3);
}
else
{
ledOn = BLT_FALSE;
LL_GPIO_ResetOutputPin(GPIOB, LL_GPIO_PIN_3);
}
nextBlinkEvent = TimerGet() + ledBlinkIntervalMs;
}
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* The VIA pirq rules are nibble-based, like ALI, but without the ugly irq number munging. However, for 82C586, nibble map is different . */
|
static int pirq_via586_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
|
/* The VIA pirq rules are nibble-based, like ALI, but without the ugly irq number munging. However, for 82C586, nibble map is different . */
static int pirq_via586_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
|
{
static const unsigned int pirqmap[5] = { 3, 2, 5, 1, 1 };
WARN_ON_ONCE(pirq > 5);
return read_config_nybble(router, 0x55, pirqmap[pirq-1]);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Program a 64 bit Word to FLASH.
This performs all operations necessary to program a 64 bit word to FLASH memory. The program error flag should be checked separately for the event that memory was not properly erased. */
|
void flash_program_double_word(uint32_t address, uint64_t data)
|
/* Program a 64 bit Word to FLASH.
This performs all operations necessary to program a 64 bit word to FLASH memory. The program error flag should be checked separately for the event that memory was not properly erased. */
void flash_program_double_word(uint32_t address, uint64_t data)
|
{
flash_wait_for_last_operation();
flash_set_program_size(FLASH_CR_PROGRAM_X64);
FLASH_CR |= FLASH_CR_PG;
MMIO64(address) = data;
flash_wait_for_last_operation();
FLASH_CR &= ~FLASH_CR_PG;
}
|
insane-adding-machines/unicore-mx
|
C++
|
GNU General Public License v3.0
| 50
|
/* Returns the total number of whole milliseconds in the specified timespan */
|
int64_t timespanToMilliseconds(timespan_t *timespan)
|
/* Returns the total number of whole milliseconds in the specified timespan */
int64_t timespanToMilliseconds(timespan_t *timespan)
|
{
return ((int64_t)timespanToSeconds(timespan) * 1000) + timespan->milliseconds;
}
|
microbuilder/LPC11U_LPC13U_CodeBase
|
C++
|
Other
| 54
|
/* Check whether adding a file makes the file system to exceed the size of the block device Return -1 when overflow occurs, otherwise return 0 */
|
static int check_overflow(fsdata *mydata, __u32 clustnum, loff_t size)
|
/* Check whether adding a file makes the file system to exceed the size of the block device Return -1 when overflow occurs, otherwise return 0 */
static int check_overflow(fsdata *mydata, __u32 clustnum, loff_t size)
|
{
__u32 startsect, sect_num, offset;
if (clustnum > 0)
startsect = clust_to_sect(mydata, clustnum);
else
startsect = mydata->rootdir_sect;
sect_num = div_u64_rem(size, mydata->sect_size, &offset);
if (offset != 0)
sect_num++;
if (startsect + sect_num > total_sector)
return -1;
return 0;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Get the captured data for the ADC sample channel. */
|
unsigned long ADCDataGet(unsigned long ulBase, unsigned long ulChannel)
|
/* Get the captured data for the ADC sample channel. */
unsigned long ADCDataGet(unsigned long ulBase, unsigned long ulChannel)
|
{
unsigned long ulData;
xASSERT(ulBase == ADC_BASE);
xASSERT((ulChannel >= 0) && (ulChannel < 8));
ulData = xHWREG(ulBase + ADC_DR0 + (ulChannel * 4));
return (ulData & 0xFFF);
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Main program entry point. This routine configures the hardware required by the application, then enters a loop to run the application tasks in sequence. */
|
int main(void)
|
/* Main program entry point. This routine configures the hardware required by the application, then enters a loop to run the application tasks in sequence. */
int main(void)
|
{
SetupHardware();
puts_P(PSTR(ESC_FG_CYAN "MIDI Host Demo running.\r\n" ESC_FG_WHITE));
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
GlobalInterruptEnable();
for (;;)
{
MIDIHost_Task();
USB_USBTask();
}
}
|
prusa3d/Prusa-Firmware-Buddy
|
C++
|
Other
| 1,019
|
/* Function called from I2C IRQ Handler when RXNE flag is set Function is in charge of retrieving received byte on I2C lines. */
|
void Slave_Reception_Callback(void)
|
/* Function called from I2C IRQ Handler when RXNE flag is set Function is in charge of retrieving received byte on I2C lines. */
void Slave_Reception_Callback(void)
|
{
aReceiveBuffer[ubReceiveIndex++] = LL_I2C_ReceiveData8(I2C1);
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* Enables USB device callback generation for a given type.
Enables asynchronous callbacks for a given logical type. This must be called before USB device generate callback events. */
|
enum status_code usb_device_enable_callback(struct usb_module *module_inst, enum usb_device_callback callback_type)
|
/* Enables USB device callback generation for a given type.
Enables asynchronous callbacks for a given logical type. This must be called before USB device generate callback events. */
enum status_code usb_device_enable_callback(struct usb_module *module_inst, enum usb_device_callback callback_type)
|
{
Assert(module_inst);
Assert(module_inst->hw);
module_inst->hw->DEVICE.INTFLAG.reg = _usb_device_irq_bits[callback_type];
module_inst->device_enabled_callback_mask |= _usb_device_irq_bits[callback_type];
module_inst->hw->DEVICE.INTENSET.reg = _usb_device_irq_bits[callback_type];
return STATUS_OK;
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* Traverse the attached ATA devices list to find out the device with given trust computing device index. */
|
PEI_AHCI_ATA_DEVICE_DATA* SearchTrustComputingDeviceByIndex(IN PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private, IN UINTN TrustComputingDeviceIndex)
|
/* Traverse the attached ATA devices list to find out the device with given trust computing device index. */
PEI_AHCI_ATA_DEVICE_DATA* SearchTrustComputingDeviceByIndex(IN PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private, IN UINTN TrustComputingDeviceIndex)
|
{
PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
LIST_ENTRY *Node;
Node = GetFirstNode (&Private->DeviceList);
while (!IsNull (&Private->DeviceList, Node)) {
DeviceData = AHCI_PEI_ATA_DEVICE_INFO_FROM_THIS (Node);
if (DeviceData->TrustComputingDeviceIndex == TrustComputingDeviceIndex) {
return DeviceData;
}
Node = GetNextNode (&Private->DeviceList, Node);
}
return NULL;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* receive annoucement from system port, and check the midi device */
|
static int receive_announce(struct snd_seq_event *ev, int direct, void *private, int atomic, int hop)
|
/* receive annoucement from system port, and check the midi device */
static int receive_announce(struct snd_seq_event *ev, int direct, void *private, int atomic, int hop)
|
{
struct snd_seq_port_info pinfo;
if (atomic)
return 0;
switch (ev->type) {
case SNDRV_SEQ_EVENT_PORT_START:
case SNDRV_SEQ_EVENT_PORT_CHANGE:
if (ev->data.addr.client == system_client)
break;
memset(&pinfo, 0, sizeof(pinfo));
pinfo.addr = ev->data.addr;
if (call_ctl(SNDRV_SEQ_IOCTL_GET_PORT_INFO, &pinfo) >= 0)
snd_seq_oss_midi_check_new_port(&pinfo);
break;
case SNDRV_SEQ_EVENT_PORT_EXIT:
if (ev->data.addr.client == system_client)
break;
snd_seq_oss_midi_check_exit_port(ev->data.addr.client,
ev->data.addr.port);
break;
}
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Append a net buffer to the net buffer queue. */
|
VOID EFIAPI NetbufQueAppend(IN OUT NET_BUF_QUEUE *NbufQue, IN OUT NET_BUF *Nbuf)
|
/* Append a net buffer to the net buffer queue. */
VOID EFIAPI NetbufQueAppend(IN OUT NET_BUF_QUEUE *NbufQue, IN OUT NET_BUF *Nbuf)
|
{
NET_CHECK_SIGNATURE (NbufQue, NET_QUE_SIGNATURE);
NET_CHECK_SIGNATURE (Nbuf, NET_BUF_SIGNATURE);
InsertTailList (&NbufQue->BufList, &Nbuf->List);
NbufQue->BufSize += Nbuf->TotalSize;
NbufQue->BufNum++;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). */
|
UINT16 EFIAPI PciExpressOr16(IN UINTN Address, IN UINT16 OrData)
|
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). */
UINT16 EFIAPI PciExpressOr16(IN UINTN Address, IN UINT16 OrData)
|
{
if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {
return (UINT16)-1;
}
return MmioOr16 (GetPciExpressAddress (Address), OrData);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Low-level data write callback for the simplified SSL I/O API. */
|
static int sock_write(void *ctx, const unsigned char *buf, size_t len)
|
/* Low-level data write callback for the simplified SSL I/O API. */
static int sock_write(void *ctx, const unsigned char *buf, size_t len)
|
{
for (;;) {
ssize_t wlen;
wlen = write(*(int *)ctx, buf, len);
if (wlen <= 0) {
if (wlen < 0 && errno == EINTR) {
continue;
}
return -1;
}
return (int)wlen;
}
}
|
RavenSystem/esp-homekit-devices
|
C++
|
Other
| 2,577
|
/* Displays the code value as a character, not its ASCII value, as would be done by BASE_DEC and friends. */
|
static void format_cancel_reason(gchar *buf, guint32 value)
|
/* Displays the code value as a character, not its ASCII value, as would be done by BASE_DEC and friends. */
static void format_cancel_reason(gchar *buf, guint32 value)
|
{
g_snprintf(buf, ITEM_LABEL_LENGTH,
"%s (%c)",
val_to_str_const(value, ouch_cancel_reason_val, "Unknown"),
value);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Forces the TIMx output 2 waveform to active or inactive level. */
|
void TIM_ForcedOC2Config(TIM_TypeDef *TIMx, uint16_t TIM_ForcedAction)
|
/* Forces the TIMx output 2 waveform to active or inactive level. */
void TIM_ForcedOC2Config(TIM_TypeDef *TIMx, uint16_t TIM_ForcedAction)
|
{
uint16_t tmpccmr1 = 0;
assert_param(IS_TIM_123458_PERIPH(TIMx));
assert_param(IS_TIM_FORCED_ACTION(TIM_ForcedAction));
tmpccmr1 = TIMx->CCMR1;
tmpccmr1 &= CCMR_OC24M_Mask;
tmpccmr1 |= (uint16_t)(TIM_ForcedAction << 8);
TIMx->CCMR1 = tmpccmr1;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* A shallow copy is a copy of a structure, but not the copy of the contents. All data pointers ('path' in our case) of a list and its shallow copy will point to the same memory. */
|
dep_list* dl_shallow_copy(const dep_list *dl)
|
/* A shallow copy is a copy of a structure, but not the copy of the contents. All data pointers ('path' in our case) of a list and its shallow copy will point to the same memory. */
dep_list* dl_shallow_copy(const dep_list *dl)
|
{
if (dl == NULL) {
return NULL;
}
dep_list *head = calloc (1, sizeof (dep_list));
if (head == NULL) {
perror_msg ("Failed to allocate head during shallow copy");
return NULL;
}
dep_list *cp = head;
const dep_list *it = dl;
while (it != NULL) {
cp->path = it->path;
cp->inode = it->inode;
if (it->next) {
cp->next = calloc (1, sizeof (dep_list));
if (cp->next == NULL) {
perror_msg ("Failed to allocate a new element during shallow copy");
dl_shallow_free (head);
return NULL;
}
cp = cp->next;
}
it = it->next;
}
return head;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Display the names and sizes of all chunks in the PNG file. */
|
void displayChunkNames(const std::vector< unsigned char > &buffer)
|
/* Display the names and sizes of all chunks in the PNG file. */
void displayChunkNames(const std::vector< unsigned char > &buffer)
|
{
char type[5];
lodepng_chunk_type(type, chunk);
if(std::string(type).size() != 4) {
std::cout << "this is probably not a PNG" << std::endl;
return;
}
if(last_type != type) {
std::cout << std::endl;
std::cout << " " << type << ": ";
}
last_type = type;
std::cout << lodepng_chunk_length(chunk) << ", ";
chunk = lodepng_chunk_next_const(chunk, end);
}
std::cout << std::endl;
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* Scale an unsigned value with range 0..max for the given field */
|
static int pidff_rescale(int i, int max, struct hid_field *field)
|
/* Scale an unsigned value with range 0..max for the given field */
static int pidff_rescale(int i, int max, struct hid_field *field)
|
{
return i * (field->logical_maximum - field->logical_minimum) / max +
field->logical_minimum;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Intended to be called by the omap_device code. */
|
int omap_hwmod_disable_clocks(struct omap_hwmod *oh)
|
/* Intended to be called by the omap_device code. */
int omap_hwmod_disable_clocks(struct omap_hwmod *oh)
|
{
mutex_lock(&omap_hwmod_mutex);
_disable_clocks(oh);
mutex_unlock(&omap_hwmod_mutex);
return 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Reads and returns the current value of MM5. This function is only available on IA-32 and X64. */
|
UINT64 EFIAPI AsmReadMm5(VOID)
|
/* Reads and returns the current value of MM5. This function is only available on IA-32 and X64. */
UINT64 EFIAPI AsmReadMm5(VOID)
|
{
UINT64 Data;
__asm__ __volatile__ (
"movd %%mm5, %0 \n\t"
: "=r" (Data)
);
return Data;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* If String is not aligned on a 16-bit boundary, then ASSERT(). */
|
UINTN EFIAPI StrnSizeS(IN CONST CHAR16 *String, IN UINTN MaxSize)
|
/* If String is not aligned on a 16-bit boundary, then ASSERT(). */
UINTN EFIAPI StrnSizeS(IN CONST CHAR16 *String, IN UINTN MaxSize)
|
{
if (String == NULL) {
return 0;
}
return (StrnLenS (String, MaxSize) + 1) * sizeof (*String);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Brief interrupt enable/disable sequence to allow handling of pending interrupts. */
|
SL_WEAK void CORE_YieldCritical(void)
|
/* Brief interrupt enable/disable sequence to allow handling of pending interrupts. */
SL_WEAK void CORE_YieldCritical(void)
|
{
if ((__get_PRIMASK() & 1U) != 0U) {
__enable_irq();
__ISB();
__disable_irq();
}
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Characters provided to sclp_tty_put_char() are buffered by the SCLP driver. If the given character is a ' */
|
static int sclp_tty_put_char(struct tty_struct *tty, unsigned char ch)
|
/* Characters provided to sclp_tty_put_char() are buffered by the SCLP driver. If the given character is a ' */
static int sclp_tty_put_char(struct tty_struct *tty, unsigned char ch)
|
{
sclp_tty_chars[sclp_tty_chars_count++] = ch;
if (ch == '\n' || sclp_tty_chars_count >= SCLP_TTY_BUF_SIZE) {
sclp_tty_write_string(sclp_tty_chars, sclp_tty_chars_count, 0);
sclp_tty_chars_count = 0;
}
return 1;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* If 64-bit MMIO register operations are not supported, then ASSERT(). If Address is not aligned on a 64-bit boundary, then ASSERT(). */
|
UINT64 EFIAPI MmioOr64(IN UINTN Address, IN UINT64 OrData)
|
/* If 64-bit MMIO register operations are not supported, then ASSERT(). If Address is not aligned on a 64-bit boundary, then ASSERT(). */
UINT64 EFIAPI MmioOr64(IN UINTN Address, IN UINT64 OrData)
|
{
return MmioWrite64 (Address, MmioRead64 (Address) | OrData);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Manages the multicast receive filters of a network interface. */
|
EFI_STATUS WinNtSnpReceiveFilters(IN EMU_SNP_PROTOCOL *This, IN UINT32 Enable, IN UINT32 Disable, IN BOOLEAN ResetMCastFilter, IN UINTN MCastFilterCnt OPTIONAL, IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL)
|
/* Manages the multicast receive filters of a network interface. */
EFI_STATUS WinNtSnpReceiveFilters(IN EMU_SNP_PROTOCOL *This, IN UINT32 Enable, IN UINT32 Disable, IN BOOLEAN ResetMCastFilter, IN UINTN MCastFilterCnt OPTIONAL, IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL)
|
{
WIN_NT_SNP_PRIVATE *Private;
INT32 ReturnValue;
Private = WIN_NT_SNP_PRIVATE_DATA_FROM_THIS (This);
ReturnValue = Private->NtNetUtilityTable.SetReceiveFilter (
Private->Instance.InterfaceInfo.InterfaceIndex,
Enable,
(UINT32)MCastFilterCnt,
MCastFilter
);
if (ReturnValue <= 0) {
return EFI_DEVICE_ERROR;
}
return EFI_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Initialise the serial device hardware with default settings. */
|
RETURN_STATUS EFIAPI SerialPortInitialize(VOID)
|
/* Initialise the serial device hardware with default settings. */
RETURN_STATUS EFIAPI SerialPortInitialize(VOID)
|
{
UINT64 BaudRate;
UINT32 ReceiveFifoDepth;
EFI_PARITY_TYPE Parity;
UINT8 DataBits;
EFI_STOP_BITS_TYPE StopBits;
BaudRate = FixedPcdGet64 (PcdUartDefaultBaudRate);
ReceiveFifoDepth = 0;
Parity = (EFI_PARITY_TYPE)FixedPcdGet8 (PcdUartDefaultParity);
DataBits = FixedPcdGet8 (PcdUartDefaultDataBits);
StopBits = (EFI_STOP_BITS_TYPE)FixedPcdGet8 (PcdUartDefaultStopBits);
return PL011UartInitializePort (
(UINTN)PcdGet64 (PcdSerialRegisterBase),
PL011UartClockGetFreq (),
&BaudRate,
&ReceiveFifoDepth,
&Parity,
&DataBits,
&StopBits
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Exceptional case: normally we are not allowed to unhash a busy directory. In this case, however, we can do it - no aliasing problems due to the way we treat inodes. */
|
static int proc_base_revalidate(struct dentry *dentry, struct nameidata *nd)
|
/* Exceptional case: normally we are not allowed to unhash a busy directory. In this case, however, we can do it - no aliasing problems due to the way we treat inodes. */
static int proc_base_revalidate(struct dentry *dentry, struct nameidata *nd)
|
{
struct inode *inode = dentry->d_inode;
struct task_struct *task = get_proc_task(inode);
if (task) {
put_task_struct(task);
return 1;
}
d_drop(dentry);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This is it. Find all the controllers and register them. returns the number of block devices registered. */
|
static int __init cpqarray_init(void)
|
/* This is it. Find all the controllers and register them. returns the number of block devices registered. */
static int __init cpqarray_init(void)
|
{
int num_cntlrs_reg = 0;
int i;
int rc = 0;
printk(DRIVER_NAME "\n");
rc = pci_register_driver(&cpqarray_pci_driver);
if (rc)
return rc;
cpqarray_eisa_detect();
for (i=0; i < MAX_CTLR; i++) {
if (hba[i] != NULL)
num_cntlrs_reg++;
}
if (num_cntlrs_reg)
return 0;
else {
pci_unregister_driver(&cpqarray_pci_driver);
return -ENODEV;
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Is any part of emi2 contained within emi1 */
|
static int ocfs2_ei_is_contained(struct ocfs2_extent_map_item *emi1, struct ocfs2_extent_map_item *emi2)
|
/* Is any part of emi2 contained within emi1 */
static int ocfs2_ei_is_contained(struct ocfs2_extent_map_item *emi1, struct ocfs2_extent_map_item *emi2)
|
{
unsigned int range1, range2;
range1 = emi1->ei_cpos + emi1->ei_clusters;
if (emi2->ei_cpos >= emi1->ei_cpos && emi2->ei_cpos < range1)
return 1;
range2 = emi2->ei_cpos + emi2->ei_clusters;
if (range2 > emi1->ei_cpos && range2 <= range1)
return 1;
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Scroll the display right without changing the RAM */
|
void pi_lcd_scroll_right(const struct device *gpio_dev)
|
/* Scroll the display right without changing the RAM */
void pi_lcd_scroll_right(const struct device *gpio_dev)
|
{
_pi_lcd_command(gpio_dev, LCD_CURSOR_SHIFT |
LCD_DISPLAY_MOVE | LCD_MOVE_RIGHT);
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Returns a pointer to an TX FIFO element in message RAM */
|
struct fdcan_tx_buffer_element* fdcan_get_txbuf_addr(uint32_t canport, unsigned element_id)
|
/* Returns a pointer to an TX FIFO element in message RAM */
struct fdcan_tx_buffer_element* fdcan_get_txbuf_addr(uint32_t canport, unsigned element_id)
|
{
struct fdcan_tx_buffer_element *rxfifo = (struct fdcan_tx_buffer_element *)
(CAN_MSG_BASE + FDCAN_TXBUF_OFFSET(canport)
+ (element_id * fdcan_get_txbuf_element_size(canport))
);
return rxfifo;
}
|
libopencm3/libopencm3
|
C++
|
GNU General Public License v3.0
| 2,931
|
/* Return value: resource entry pointer if found / NULL if not found */
|
static struct ipr_resource_entry* ipr_find_sdev(struct scsi_device *sdev)
|
/* Return value: resource entry pointer if found / NULL if not found */
static struct ipr_resource_entry* ipr_find_sdev(struct scsi_device *sdev)
|
{
struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *) sdev->host->hostdata;
struct ipr_resource_entry *res;
list_for_each_entry(res, &ioa_cfg->used_res_q, queue) {
if ((res->cfgte.res_addr.bus == sdev->channel) &&
(res->cfgte.res_addr.target == sdev->id) &&
(res->cfgte.res_addr.lun == sdev->lun))
return res;
}
return NULL;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Enables generator and fault interrupts for a PWM module. */
|
void PWMIntEnable(unsigned long ulBase, unsigned long ulGenFault)
|
/* Enables generator and fault interrupts for a PWM module. */
void PWMIntEnable(unsigned long ulBase, unsigned long ulGenFault)
|
{
ASSERT(ulBase == PWM_BASE);
ASSERT((ulGenFault & ~(PWM_INT_GEN_0 | PWM_INT_GEN_1 | PWM_INT_GEN_2 |
PWM_INT_GEN_3 | PWM_INT_FAULT0 | PWM_INT_FAULT1 |
PWM_INT_FAULT2 | PWM_INT_FAULT3)) == 0);
HWREG(ulBase + PWM_O_INTEN) |= ulGenFault;
}
|
watterott/WebRadio
|
C++
| null | 71
|
/* Call a specific function in the thread context of tcpip_thread for easy access synchronization. A function called in that way may access lwIP core code without fearing concurrent access. Does NOT block when the request cannot be posted because the tcpip_mbox is full, but returns ERR_MEM instead. Can be called from interrupt context. */
|
err_t tcpip_try_callback(tcpip_callback_fn function, void *ctx)
|
/* Call a specific function in the thread context of tcpip_thread for easy access synchronization. A function called in that way may access lwIP core code without fearing concurrent access. Does NOT block when the request cannot be posted because the tcpip_mbox is full, but returns ERR_MEM instead. Can be called from interrupt context. */
err_t tcpip_try_callback(tcpip_callback_fn function, void *ctx)
|
{
struct tcpip_msg *msg;
LWIP_ASSERT("Invalid mbox", sys_mbox_valid_val(tcpip_mbox));
msg = (struct tcpip_msg *)memp_malloc(MEMP_TCPIP_MSG_API);
if (msg == NULL) {
return ERR_MEM;
}
msg->type = TCPIP_MSG_CALLBACK;
msg->msg.cb.function = function;
msg->msg.cb.ctx = ctx;
if (sys_mbox_trypost(&tcpip_mbox, msg) != ERR_OK) {
memp_free(MEMP_TCPIP_MSG_API, msg);
return ERR_MEM;
}
return ERR_OK;
}
|
ua1arn/hftrx
|
C++
| null | 69
|
/* Registers a USB device callback.
Registers a callback function which is implemented by the user. */
|
enum status_code usb_device_register_callback(struct usb_module *module_inst, enum usb_device_callback callback_type, usb_device_callback_t callback_func)
|
/* Registers a USB device callback.
Registers a callback function which is implemented by the user. */
enum status_code usb_device_register_callback(struct usb_module *module_inst, enum usb_device_callback callback_type, usb_device_callback_t callback_func)
|
{
Assert(module_inst);
Assert(callback_func);
module_inst->device_callback[callback_type] = callback_func;
module_inst->device_registered_callback_mask |= _usb_device_irq_bits[callback_type];
return STATUS_OK;
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* param base Pointer to FLEXIO_I2C_Type structure. param handle Pointer to flexio_i2c_master_handle_t structure to store the transfer state. param callback Pointer to user callback function. param userData User param passed to the callback function. retval kStatus_Success Successfully create the handle. retval kStatus_OutOfRange The FlexIO type/handle/isr table out of range. */
|
status_t FLEXIO_I2C_MasterTransferCreateHandle(FLEXIO_I2C_Type *base, flexio_i2c_master_handle_t *handle, flexio_i2c_master_transfer_callback_t callback, void *userData)
|
/* param base Pointer to FLEXIO_I2C_Type structure. param handle Pointer to flexio_i2c_master_handle_t structure to store the transfer state. param callback Pointer to user callback function. param userData User param passed to the callback function. retval kStatus_Success Successfully create the handle. retval kStatus_OutOfRange The FlexIO type/handle/isr table out of range. */
status_t FLEXIO_I2C_MasterTransferCreateHandle(FLEXIO_I2C_Type *base, flexio_i2c_master_handle_t *handle, flexio_i2c_master_transfer_callback_t callback, void *userData)
|
{
assert(handle != NULL);
IRQn_Type flexio_irqs[] = FLEXIO_IRQS;
(void)memset(handle, 0, sizeof(*handle));
handle->completionCallback = callback;
handle->userData = userData;
NVIC_ClearPendingIRQ(flexio_irqs[FLEXIO_I2C_GetInstance(base)]);
(void)EnableIRQ(flexio_irqs[FLEXIO_I2C_GetInstance(base)]);
return FLEXIO_RegisterHandleIRQ(base, handle, FLEXIO_I2C_MasterTransferHandleIRQ);
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Registers an interrupt handler for an Ethernet interrupt. */
|
void EthernetIntRegister(unsigned long ulBase, void(*pfnHandler)(void))
|
/* Registers an interrupt handler for an Ethernet interrupt. */
void EthernetIntRegister(unsigned long ulBase, void(*pfnHandler)(void))
|
{
ASSERT(ulBase == ETH_BASE);
ASSERT(pfnHandler != 0);
IntRegister(INT_ETH, pfnHandler);
IntEnable(INT_ETH);
}
|
watterott/WebRadio
|
C++
| null | 71
|
/* Set the PWM duty of the PWM module.
The */
|
void PWMDutySet(unsigned long ulBase, unsigned long ulChannel, unsigned char ulDuty)
|
/* Set the PWM duty of the PWM module.
The */
void PWMDutySet(unsigned long ulBase, unsigned long ulChannel, unsigned char ulDuty)
|
{
unsigned long ulChannelTemp;
unsigned long ulCMRData;
ulChannelTemp = (ulBase == PWMA_BASE) ? ulChannel : (ulChannel - 4);
xASSERT((ulBase == PWMA_BASE) || (ulBase == PWMB_BASE));
xASSERT(((ulChannelTemp >= 0) || (ulChannelTemp <= 3)));
xASSERT(((ulDuty > 0) || (ulDuty <= 100)));
ulCMRData = (xHWREG(ulBase + PWM_CNR0 +(ulChannelTemp * 12)) + 1) *
ulDuty / 100 - 1;
if ((xHWREG(ulBase + PWM_CNR0 +(ulChannelTemp * 12)) + 1) *ulDuty / 100 == 0)
{
ulCMRData = 0;
}
xHWREG(ulBase + PWM_CMR0 +(ulChannelTemp * 12)) = ulCMRData;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* See mss_uart.h for details of how to use this function. */
|
void MSS_UART_irq_tx(mss_uart_instance_t *this_uart, const uint8_t *pbuff, uint32_t tx_size)
|
/* See mss_uart.h for details of how to use this function. */
void MSS_UART_irq_tx(mss_uart_instance_t *this_uart, const uint8_t *pbuff, uint32_t tx_size)
|
{
ASSERT( (this_uart == &g_mss_uart0) || (this_uart == &g_mss_uart1) );
if ( tx_size > 0U )
{
this_uart->tx_buffer = pbuff;
this_uart->tx_buff_size = tx_size;
this_uart->tx_idx = (uint16_t)0;
this_uart->hw_reg_bit->IER_ETBEI = (uint32_t)1;
NVIC_EnableIRQ( this_uart->irqn );
}
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* Get the peripheral clock speed for the Timer at base specified. */
|
uint32_t rcc_get_timer_clk_freq(uint32_t timer)
|
/* Get the peripheral clock speed for the Timer at base specified. */
uint32_t rcc_get_timer_clk_freq(uint32_t timer)
|
{
if (timer >= TIM2_BASE && timer <= TIM14_BASE) {
uint8_t ppre1 = (RCC_CFGR >> RCC_CFGR_PPRE1_SHIFT) & RCC_CFGR_PPRE1_MASK;
return (ppre1 == RCC_CFGR_PPRE1_HCLK_NODIV) ? rcc_apb1_frequency
: 2 * rcc_apb1_frequency;
} else {
uint8_t ppre2 = (RCC_CFGR >> RCC_CFGR_PPRE2_SHIFT) & RCC_CFGR_PPRE2_MASK;
return (ppre2 == RCC_CFGR_PPRE2_HCLK_NODIV) ? rcc_apb2_frequency
: 2 * rcc_apb2_frequency;
}
cm3_assert_not_reached();
}
|
libopencm3/libopencm3
|
C++
|
GNU General Public License v3.0
| 2,931
|
/* Update an object's checksum and return true if it was modified. */
|
static bool update_checksum(struct kmemleak_object *object)
|
/* Update an object's checksum and return true if it was modified. */
static bool update_checksum(struct kmemleak_object *object)
|
{
u32 old_csum = object->checksum;
if (!kmemcheck_is_obj_initialized(object->pointer, object->size))
return false;
object->checksum = crc32(0, (void *)object->pointer, object->size);
return object->checksum != old_csum;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Output: void, will modify proto_tree if not null. */
|
static void dissect_hello_mt_clv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int id_length _U_, int length)
|
/* Output: void, will modify proto_tree if not null. */
static void dissect_hello_mt_clv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int id_length _U_, int length)
|
{
isis_dissect_mt_clv(tvb, pinfo, tree, offset, length,
hf_isis_hello_clv_mt, &ei_isis_hello_clv_mt);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* p9_fd_close - shutdown file descriptor transport @client: client instance */
|
static void p9_fd_close(struct p9_client *client)
|
/* p9_fd_close - shutdown file descriptor transport @client: client instance */
static void p9_fd_close(struct p9_client *client)
|
{
struct p9_trans_fd *ts;
if (!client)
return;
ts = client->trans;
if (!ts)
return;
client->status = Disconnected;
p9_conn_destroy(ts->conn);
if (ts->rd)
fput(ts->rd);
if (ts->wr)
fput(ts->wr);
kfree(ts);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Reads a file to a newly allocated buffer */
|
VOID* FileHandleReadToNewBuffer(IN EFI_FILE_HANDLE FileHandle, IN UINTN ReadSize)
|
/* Reads a file to a newly allocated buffer */
VOID* FileHandleReadToNewBuffer(IN EFI_FILE_HANDLE FileHandle, IN UINTN ReadSize)
|
{
EFI_STATUS Status;
UINTN ActualReadSize;
VOID *FileContents;
ActualReadSize = ReadSize;
FileContents = AllocatePool (ReadSize);
if (FileContents != NULL) {
Status = FileHandleRead (
FileHandle,
&ReadSize,
FileContents
);
if (EFI_ERROR (Status) || (ActualReadSize != ReadSize)) {
FreePool (FileContents);
return NULL;
}
}
return FileContents;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Returns the number of bytes which are printed into the buffer. */
|
static ssize_t i2o_device_show_tid(struct device *dev, struct device_attribute *attr, char *buf)
|
/* Returns the number of bytes which are printed into the buffer. */
static ssize_t i2o_device_show_tid(struct device *dev, struct device_attribute *attr, char *buf)
|
{
struct i2o_device *i2o_dev = to_i2o_device(dev);
sprintf(buf, "0x%03x\n", i2o_dev->lct_data.tid);
return strlen(buf) + 1;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Build a netlink request message to delete a neighbour */
|
int rtnl_neigh_build_delete_request(struct rtnl_neigh *neigh, int flags, struct nl_msg **result)
|
/* Build a netlink request message to delete a neighbour */
int rtnl_neigh_build_delete_request(struct rtnl_neigh *neigh, int flags, struct nl_msg **result)
|
{
return build_neigh_msg(neigh, RTM_DELNEIGH, flags, result);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* On success, the number of bytes read is returned and the offset @ppos is advanced by this number, or negative value is returned on error. */
|
ssize_t simple_read_from_buffer(void __user *to, size_t count, loff_t *ppos, const void *from, size_t available)
|
/* On success, the number of bytes read is returned and the offset @ppos is advanced by this number, or negative value is returned on error. */
ssize_t simple_read_from_buffer(void __user *to, size_t count, loff_t *ppos, const void *from, size_t available)
|
{
loff_t pos = *ppos;
size_t ret;
if (pos < 0)
return -EINVAL;
if (pos >= available || !count)
return 0;
if (count > available - pos)
count = available - pos;
ret = copy_to_user(to, from + pos, count);
if (ret == count)
return -EFAULT;
count -= ret;
*ppos = pos + count;
return count;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Message: StopMediaTransmissionMessage Opcode: 0x008b Type: MediaControl Direction: pbx2dev VarLength: no */
|
static void handle_StopMediaTransmissionMessage(ptvcursor_t *cursor, packet_info *pinfo _U_)
|
/* Message: StopMediaTransmissionMessage Opcode: 0x008b Type: MediaControl Direction: pbx2dev VarLength: no */
static void handle_StopMediaTransmissionMessage(ptvcursor_t *cursor, packet_info *pinfo _U_)
|
{
ptvcursor_add(cursor, hf_skinny_conferenceID, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_passThruPartyID, 4, ENC_LITTLE_ENDIAN);
si->callId = tvb_get_letohl(ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor));
ptvcursor_add(cursor, hf_skinny_callReference, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_portHandlingFlag, 4, ENC_LITTLE_ENDIAN);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Checks whether the FLASH Read Out Protection L2 Status is set or not. */
|
FlagStatus FLASH_GetReadOutProtectionL2STS(void)
|
/* Checks whether the FLASH Read Out Protection L2 Status is set or not. */
FlagStatus FLASH_GetReadOutProtectionL2STS(void)
|
{
FlagStatus readoutstatus = RESET;
if ((FLASH->OB & RDPRTL2_MSK) != (uint32_t)RESET)
{
readoutstatus = SET;
}
else
{
readoutstatus = RESET;
}
return readoutstatus;
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* Created on: 10 feb. 2019 Author: Daniel Mårtensson Create a identity matrix with size row x column */
|
void eye(double *A, int row, int column)
|
/* Created on: 10 feb. 2019 Author: Daniel Mårtensson Create a identity matrix with size row x column */
void eye(double *A, int row, int column)
|
{
*A = 1.0;
A += row + 1;
}
}
|
DanielMartensson/EmbeddedLapack
|
C++
|
MIT License
| 129
|
/* We can't ioremap the entire pci config space because it's too large. Nor can we call ioremap dynamically because some device drivers use the PCI config routines from within interrupt handlers and that becomes a problem in get_vm_area(). We use one wired TLB to handle all config accesses for all busses. */
|
void __init au1x_pci_cfg_init(void)
|
/* We can't ioremap the entire pci config space because it's too large. Nor can we call ioremap dynamically because some device drivers use the PCI config routines from within interrupt handlers and that becomes a problem in get_vm_area(). We use one wired TLB to handle all config accesses for all busses. */
void __init au1x_pci_cfg_init(void)
|
{
pci_cfg_vm = get_vm_area(0x2000, VM_IOREMAP);
if (!pci_cfg_vm)
panic(KERN_ERR "PCI unable to get vm area\n");
pci_cfg_wired_entry = read_c0_wired();
add_wired_entry(0, 0, (unsigned long)pci_cfg_vm->addr, PM_4K);
last_entryLo0 = last_entryLo1 = 0xffffffff;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Gets the error status of the I2C Master module. */
|
unsigned long xI2CMasterError(unsigned long ulBase)
|
/* Gets the error status of the I2C Master module. */
unsigned long xI2CMasterError(unsigned long ulBase)
|
{
unsigned long ulStatus;
xASSERT((ulBase == I2C0_BASE));
ulStatus = (xHWREG(ulBase + I2C_O_STATUS) & I2C_STATUS_M);
if((ulStatus == I2C_I2STAT_M_TX_DAT_NACK) ||
(ulStatus == I2C_I2STAT_M_RX_DAT_NACK))
{
return xI2C_MASTER_ERR_ADDR_ACK;
}
if((ulStatus == I2C_I2STAT_M_TX_SLAW_NACK) ||
(ulStatus == I2C_I2STAT_M_RX_SLAR_NACK))
{
return xI2C_MASTER_ERR_DATA_ACK;
}
if((ulStatus == I2C_I2STAT_M_TX_ARB_LOST))
{
return xI2C_MASTER_ERR_ARB_LOST;
}
return xI2C_MASTER_ERR_NONE;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Initializes the DMA AES channel3 registers to their default reset values. */
|
void DMA_ASEDeInit(void)
|
/* Initializes the DMA AES channel3 registers to their default reset values. */
void DMA_ASEDeInit(void)
|
{
DMA->AESCTL = DMA_AESCTL_RSTValue;
DMA->AESKEY[0] = DMA_AESKEY_RSTValue;
DMA->AESKEY[1] = DMA_AESKEY_RSTValue;
DMA->AESKEY[2] = DMA_AESKEY_RSTValue;
DMA->AESKEY[3] = DMA_AESKEY_RSTValue;
DMA->AESKEY[4] = DMA_AESKEY_RSTValue;
DMA->AESKEY[5] = DMA_AESKEY_RSTValue;
DMA->AESKEY[6] = DMA_AESKEY_RSTValue;
DMA->AESKEY[7] = DMA_AESKEY_RSTValue;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Causes all GATT procedures matching the specified criteria to fail with the specified status code. */
|
static void ble_gattc_fail_procs(uint16_t conn_handle, uint8_t op, int status)
|
/* Causes all GATT procedures matching the specified criteria to fail with the specified status code. */
static void ble_gattc_fail_procs(uint16_t conn_handle, uint8_t op, int status)
|
{
struct ble_gattc_proc_list temp_list;
struct ble_gattc_proc *proc;
ble_gattc_err_fn *err_cb;
ble_gattc_extract_by_conn_op(conn_handle, op, 0, &temp_list);
while ((proc = STAILQ_FIRST(&temp_list)) != NULL) {
err_cb = ble_gattc_err_dispatch_get(proc->op);
err_cb(proc, status, 0);
STAILQ_REMOVE_HEAD(&temp_list, next);
ble_gattc_proc_free(proc);
}
}
|
Nicholas3388/LuaNode
|
C++
|
Other
| 1,055
|
/* Execute timer if its remaining time is zero */
|
static bool lv_timer_exec(lv_timer_t *timer)
|
/* Execute timer if its remaining time is zero */
static bool lv_timer_exec(lv_timer_t *timer)
|
{
if(timer->paused) return false;
bool exec = false;
if(lv_timer_time_remaining(timer) == 0) {
int32_t original_repeat_count = timer->repeat_count;
if(timer->repeat_count > 0) timer->repeat_count--;
timer->last_run = lv_tick_get();
TIMER_TRACE("calling timer callback: %p", *((void **)&timer->timer_cb));
if(timer->timer_cb && original_repeat_count != 0) timer->timer_cb(timer);
TIMER_TRACE("timer callback %p finished", *((void **)&timer->timer_cb));
LV_ASSERT_MEM_INTEGRITY();
exec = true;
}
if(timer_deleted == false) {
if(timer->repeat_count == 0) {
TIMER_TRACE("deleting timer with %p callback because the repeat count is over", *((void **)&timer->timer_cb));
lv_timer_del(timer);
}
}
return exec;
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* This version requires touching the cache lines of kmem_cache which we avoid to do in the fast alloc free paths. There we obtain the offset from the page struct. */
|
static void* get_freepointer(struct kmem_cache *s, void *object)
|
/* This version requires touching the cache lines of kmem_cache which we avoid to do in the fast alloc free paths. There we obtain the offset from the page struct. */
static void* get_freepointer(struct kmem_cache *s, void *object)
|
{
return *(void **)(object + s->offset);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* machine_specific_memory_setup - Hook for machine specific memory setup. */
|
char* __init xen_memory_setup(void)
|
/* machine_specific_memory_setup - Hook for machine specific memory setup. */
char* __init xen_memory_setup(void)
|
{
unsigned long max_pfn = xen_start_info->nr_pages;
max_pfn = min(MAX_DOMAIN_PAGES, max_pfn);
e820.nr_map = 0;
e820_add_region(0, PFN_PHYS((u64)max_pfn), E820_RAM);
e820_add_region(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS,
E820_RESERVED);
reserve_early(__pa(xen_start_info->mfn_list),
__pa(xen_start_info->pt_base),
"XEN START INFO");
sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
return "Xen";
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Get the captured data for the ADC sample channel. */
|
unsigned long ADCDataGet(unsigned long ulBase)
|
/* Get the captured data for the ADC sample channel. */
unsigned long ADCDataGet(unsigned long ulBase)
|
{
unsigned long ulData;
xASSERT(ulBase == ADC_BASE);
ulData = xHWREG(ulBase + ADC_OUT);
return (ulData & 0x0000FFFF);
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* USBH_MSC_BOT_REQ_GetMaxLUN The function the MSC BOT GetMaxLUN request. */
|
USBH_StatusTypeDef USBH_MSC_BOT_REQ_GetMaxLUN(USBH_HandleTypeDef *phost, uint8_t *Maxlun)
|
/* USBH_MSC_BOT_REQ_GetMaxLUN The function the MSC BOT GetMaxLUN request. */
USBH_StatusTypeDef USBH_MSC_BOT_REQ_GetMaxLUN(USBH_HandleTypeDef *phost, uint8_t *Maxlun)
|
{
phost->Control.setup.b.bmRequestType = USB_D2H | USB_REQ_TYPE_CLASS | \
USB_REQ_RECIPIENT_INTERFACE;
phost->Control.setup.b.bRequest = USB_REQ_GET_MAX_LUN;
phost->Control.setup.b.wValue.w = 0;
phost->Control.setup.b.wIndex.w = 0;
phost->Control.setup.b.wLength.w = 1;
return USBH_CtlReq(phost, Maxlun , 1 );
}
|
labapart/polymcu
|
C++
| null | 201
|
/* Clear the port interrupt and error status. It will also clear HBA interrupt status. */
|
VOID AhciClearPortStatus(IN UINTN AhciBar, IN UINT8 Port)
|
/* Clear the port interrupt and error status. It will also clear HBA interrupt status. */
VOID AhciClearPortStatus(IN UINTN AhciBar, IN UINT8 Port)
|
{
UINT32 Offset;
Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_SERR;
AhciWriteReg (AhciBar, Offset, AhciReadReg (AhciBar, Offset));
Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_IS;
AhciWriteReg (AhciBar, Offset, AhciReadReg (AhciBar, Offset));
AhciWriteReg (AhciBar, AHCI_IS_OFFSET, AhciReadReg (AhciBar, AHCI_IS_OFFSET));
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.