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
/* AtomicWriteFile-Request ::= SEQUENCE { fileIdentifier BACnetObjectIdentifier, accessMethod CHOICE { streamAccess SEQUENCE { fileStartPosition INTEGER, fileData OCTET STRING }, recordAccess SEQUENCE { fileStartRecord INTEGER, recordCount Unsigned, fileRecordData SEQUENCE OF OCTET STRING } } } */
static guint fAtomicWriteFileRequest(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
/* AtomicWriteFile-Request ::= SEQUENCE { fileIdentifier BACnetObjectIdentifier, accessMethod CHOICE { streamAccess SEQUENCE { fileStartPosition INTEGER, fileData OCTET STRING }, recordAccess SEQUENCE { fileStartRecord INTEGER, recordCount Unsigned, fileRecordData SEQUENCE OF OCTET STRING } } } */ static guint fAtomicWriteFileRequest(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
{ offset = fObjectIdentifier(tvb, pinfo, tree, offset); offset = fAccessMethod(tvb, pinfo, tree, offset); return offset; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This function is the same as ShellPromptForResponse, except that the prompt is automatically pulled from HII. */
EFI_STATUS EFIAPI ShellPromptForResponseHii(IN SHELL_PROMPT_REQUEST_TYPE Type, IN CONST EFI_STRING_ID HiiFormatStringId, IN CONST EFI_HII_HANDLE HiiFormatHandle, IN OUT VOID **Response)
/* This function is the same as ShellPromptForResponse, except that the prompt is automatically pulled from HII. */ EFI_STATUS EFIAPI ShellPromptForResponseHii(IN SHELL_PROMPT_REQUEST_TYPE Type, IN CONST EFI_STRING_ID HiiFormatStringId, IN CONST EFI_HII_HANDLE HiiFormatHandle, IN OUT VOID **Response)
{ CHAR16 *Prompt; EFI_STATUS Status; Prompt = HiiGetString (HiiFormatHandle, HiiFormatStringId, NULL); Status = ShellPromptForResponse (Type, Prompt, Response); FreePool (Prompt); return (Status); }
tianocore/edk2
C++
Other
4,240
/* Free a domain, only used if something went wrong in the allocation path and we need to free an already allocated page table */
static void dma_ops_domain_free(struct dma_ops_domain *dom)
/* Free a domain, only used if something went wrong in the allocation path and we need to free an already allocated page table */ static void dma_ops_domain_free(struct dma_ops_domain *dom)
{ int i; if (!dom) return; del_domain_from_list(&dom->domain); free_pagetable(&dom->domain); for (i = 0; i < APERTURE_MAX_RANGES; ++i) { if (!dom->aperture[i]) continue; free_page((unsigned long)dom->aperture[i]->bitmap); kfree(dom->aperture[i]); } kfree(dom); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Configures the alternate function of a GPIO pin. */
void GPIOPinConfigure(unsigned long ulPort, unsigned long ulPins, unsigned long ulPinConfig)
/* Configures the alternate function of a GPIO pin. */ void GPIOPinConfigure(unsigned long ulPort, unsigned long ulPins, unsigned long ulPinConfig)
{ xASSERT(GPIOBaseValid(ulPort)); xASSERT(((ulPinConfig >> 12) & 0x1F) <= 17 ); if(ulPinConfig & 0x10) { xHWREG(ulPort + GPIO_SLEWCTL) |= ulPins; } xHWREG(g_pulGPIOMFPRegs[GPIO_MFP_REG_GET(ulPinConfig)]) &= ~(GPIO_MFP_BIT_MASK << GPIO_PIN_SHIFT_GET(ulPinConfig)); xHWREG(g_pulGPIOMFPRegs[GPIO_MFP_REG_GET(ulPinConfig)]) |= (GPIO_MUT_VALUE_GET(ulPinConfig) << GPIO_PIN_SHIFT_GET(ulPinConfig)); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* FLEXSPI EDMA transfer finished callback function. This function is called when FLEXSPI EDMA transfer finished. It disables the FLEXSPI TX/RX EDMA request and sends status to FLEXSPI callback. */
static void FLEXSPI_TransferEDMACallback(edma_handle_t *handle, void *param, bool transferDone, uint32_t tcds)
/* FLEXSPI EDMA transfer finished callback function. This function is called when FLEXSPI EDMA transfer finished. It disables the FLEXSPI TX/RX EDMA request and sends status to FLEXSPI callback. */ static void FLEXSPI_TransferEDMACallback(edma_handle_t *handle, void *param, bool transferDone, uint32_t tcds)
{ flexspi_edma_private_handle_t *flexspiPrivateHandle = (flexspi_edma_private_handle_t *)param; handle = handle; tcds = tcds; if (transferDone) { while (!FLEXSPI_GetBusIdleStatus(flexspiPrivateHandle->base)) { } FLEXSPI_TransferAbortEDMA(flexspiPrivateHandle->base, flexspiPrivateHandle->handle); if (flexspiPrivateHandle->handle->completionCallback != NULL) { flexspiPrivateHandle->handle->completionCallback(flexspiPrivateHandle->base, flexspiPrivateHandle->handle, kStatus_Success, flexspiPrivateHandle->handle->userData); } } }
eclipse-threadx/getting-started
C++
Other
310
/* Writes a buffer to PE internal program memory (PMEM) from the host through indirect access registers. */
static void pe_pmem_memcpy_to32(int id, u32 dst, const void *src, unsigned int len)
/* Writes a buffer to PE internal program memory (PMEM) from the host through indirect access registers. */ static void pe_pmem_memcpy_to32(int id, u32 dst, const void *src, unsigned int len)
{ pe_mem_memcpy_to32(id, pe[id].pmem_base_addr | (dst & (pe[id].pmem_size - 1)) | PE_MEM_ACCESS_IMEM, src, len); }
4ms/stm32mp1-baremetal
C++
Other
137
/* scsi_destroy_command_freelist - Release the command freelist for a scsi host. @shost: host whose freelist is going to be destroyed */
void scsi_destroy_command_freelist(struct Scsi_Host *shost)
/* scsi_destroy_command_freelist - Release the command freelist for a scsi host. @shost: host whose freelist is going to be destroyed */ void scsi_destroy_command_freelist(struct Scsi_Host *shost)
{ if (!shost->cmd_pool) return; while (!list_empty(&shost->free_list)) { struct scsi_cmnd *cmd; cmd = list_entry(shost->free_list.next, struct scsi_cmnd, list); list_del_init(&cmd->list); scsi_pool_free_command(shost->cmd_pool, cmd); } shost->cmd_pool = NULL; scsi_put_host_cmd_pool(shost->unchecked_isa_dma ? GFP_DMA : GFP_KERNEL); }
robutest/uclinux
C++
GPL-2.0
60
/* Check validity of input arguments. This function checks the validity of input arguments. */
static status_t dcp_hash_check_input_args(DCP_Type *base, dcp_hash_ctx_t *ctx, dcp_hash_algo_t algo)
/* Check validity of input arguments. This function checks the validity of input arguments. */ static status_t dcp_hash_check_input_args(DCP_Type *base, dcp_hash_ctx_t *ctx, dcp_hash_algo_t algo)
{ if (kStatus_Success != dcp_hash_check_input_alg(algo)) { return kStatus_InvalidArgument; } if ((NULL == ctx) || (NULL == base)) { return kStatus_InvalidArgument; } return kStatus_Success; }
eclipse-threadx/getting-started
C++
Other
310
/* Get the waiting status of a received message. */
uint32_t CAN_IsNewDataReceived(CAN_T *tCAN, uint8_t u8MsgObj)
/* Get the waiting status of a received message. */ uint32_t CAN_IsNewDataReceived(CAN_T *tCAN, uint8_t u8MsgObj)
{ return (u8MsgObj < 16ul ? tCAN->NDAT1 & (1ul << u8MsgObj) : tCAN->NDAT2 & (1ul << (u8MsgObj - 16ul))); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* ZigBee Device Profile dissector for the store power descriptor */
void dissect_zbee_zdp_rsp_store_simple_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/* ZigBee Device Profile dissector for the store power descriptor */ void dissect_zbee_zdp_rsp_store_simple_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{ guint offset = 0; guint8 status; status = zdp_parse_status(tree, tvb, &offset); zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status)); zdp_dump_excess(tvb, offset, pinfo, tree); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Configure the given interrupt source. Interrupt can be configured to trigger on rising edge, falling edge, high level, low level or simply on level change. */
void pio_configure_interrupt(Pio *p_pio, const uint32_t ul_mask, const uint32_t ul_attr)
/* Configure the given interrupt source. Interrupt can be configured to trigger on rising edge, falling edge, high level, low level or simply on level change. */ void pio_configure_interrupt(Pio *p_pio, const uint32_t ul_mask, const uint32_t ul_attr)
{ if (ul_attr & PIO_IT_AIME) { p_pio->PIO_AIMER = ul_mask; if (ul_attr & PIO_IT_RE_OR_HL) { p_pio->PIO_REHLSR = ul_mask; } else { p_pio->PIO_FELLSR = ul_mask; } if (ul_attr & PIO_IT_EDGE) { p_pio->PIO_ESR = ul_mask; } else { p_pio->PIO_LSR = ul_mask; } } else { p_pio->PIO_AIMDR = ul_mask; } }
remotemcu/remcu-chip-sdks
C++
null
436
/* Synchronous API to check presence and compatibility of the WINC image that is stored in the inactive flash partition. This is the image that would run on the WINC IC if m2m_ota_switch_firmware or m2m_ota_rollback were called, followed by a reset of the WINC IC. */
sint8 m2m_wifi_check_ota_rb(void)
/* Synchronous API to check presence and compatibility of the WINC image that is stored in the inactive flash partition. This is the image that would run on the WINC IC if m2m_ota_switch_firmware or m2m_ota_rollback were called, followed by a reset of the WINC IC. */ sint8 m2m_wifi_check_ota_rb(void)
{ sint8 ret = M2M_SUCCESS; uint16 ota_hif_info = 0; ret = nm_get_hif_info(NULL, &ota_hif_info); if(ret == M2M_SUCCESS) { ret = hif_check_compatibility(ota_hif_info); } return ret; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Writes the current IDTR descriptor and returns it in Idtr. This function is only available on IA-32 and x64. */
VOID EFIAPI InternalX86WriteIdtr(IN CONST IA32_DESCRIPTOR *Idtr)
/* Writes the current IDTR descriptor and returns it in Idtr. This function is only available on IA-32 and x64. */ VOID EFIAPI InternalX86WriteIdtr(IN CONST IA32_DESCRIPTOR *Idtr)
{ _asm { mov eax, Idtr pushfd cli lidt fword ptr [eax] popfd } }
tianocore/edk2
C++
Other
4,240
/* smr = readl(AT91C_AIC_SMR(irq)) & ~AT91C_AIC_SRCTYPE; AT91C_BASE_AIC->AIC_SMR = smr | srctype; return 0; } */
rt_uint32_t rt_hw_interrupt_get_active(rt_uint32_t fiq_irq)
/* smr = readl(AT91C_AIC_SMR(irq)) & ~AT91C_AIC_SRCTYPE; AT91C_BASE_AIC->AIC_SMR = smr | srctype; return 0; } */ rt_uint32_t rt_hw_interrupt_get_active(rt_uint32_t fiq_irq)
{ rt_uint32_t id; if (fiq_irq == INT_FIQ) return 0; readl(AT91C_AIC_IVR); id = readl(AT91C_AIC_ISR); return id; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function is to convert unicode hex number to a UINT8. */
EFI_STATUS PxeBcUniHexToUint8(OUT UINT8 *Digit, IN CHAR16 Char)
/* This function is to convert unicode hex number to a UINT8. */ EFI_STATUS PxeBcUniHexToUint8(OUT UINT8 *Digit, IN CHAR16 Char)
{ if ((Char >= L'0') && (Char <= L'9')) { *Digit = (UINT8)(Char - L'0'); return EFI_SUCCESS; } if ((Char >= L'A') && (Char <= L'F')) { *Digit = (UINT8)(Char - L'A' + 0x0A); return EFI_SUCCESS; } if ((Char >= L'a') && (Char <= L'f')) { *Digit = (UINT8)(Char - L'a' + 0x0A); return EFI_SUCCESS; } return EFI_INVALID_PARAMETER; }
tianocore/edk2
C++
Other
4,240
/* Created on: 10 feb. 2019 Author: Daniel Mårtensson Turn a matrix A, with size row x column, into a upper triangular matrix B, with size row x column */
void triu(double *A, double *B, int shift, int row, int column)
/* Created on: 10 feb. 2019 Author: Daniel Mårtensson Turn a matrix A, with size row x column, into a upper triangular matrix B, with size row x column */ void triu(double *A, double *B, int shift, int row, int column)
{ for(int j = 0; j < column; j++){ if(j == 0){ j = i + shift; } if(j != column) *((B + i*(row-t)) + j) = *((A + i*(row-t)) + j); } } }
DanielMartensson/EmbeddedLapack
C++
MIT License
129
/* This function checks if a Unicode character is an upper case hexadecimal character. The valid upper case hexadecimal character is L'0' to L'9', or L'A' to L'F'. */
BOOLEAN EFIAPI VarCheckUefiIsHexaDecimalDigitCharacter(IN CHAR16 Char)
/* This function checks if a Unicode character is an upper case hexadecimal character. The valid upper case hexadecimal character is L'0' to L'9', or L'A' to L'F'. */ BOOLEAN EFIAPI VarCheckUefiIsHexaDecimalDigitCharacter(IN CHAR16 Char)
{ return (BOOLEAN)((Char >= L'0' && Char <= L'9') || (Char >= L'A' && Char <= L'F')); }
tianocore/edk2
C++
Other
4,240
/* Set scratch buffer to be used by softmax function. */
void esp_nn_set_softmax_scratch_buf_opt(void *buffer)
/* Set scratch buffer to be used by softmax function. */ void esp_nn_set_softmax_scratch_buf_opt(void *buffer)
{ scratch_buf = (int32_t *) buffer; }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* Send control message over ICMsg with mutex locked. Mutex must be locked because ICMsg may return error on concurrent invocations even when there is enough space in queue. */
static int send_control_message(struct backend_data *dev_data, enum msg_type msg_type, uint8_t ept_addr, uint8_t block_index)
/* Send control message over ICMsg with mutex locked. Mutex must be locked because ICMsg may return error on concurrent invocations even when there is enough space in queue. */ static int send_control_message(struct backend_data *dev_data, enum msg_type msg_type, uint8_t ept_addr, uint8_t block_index)
{ const struct icbmsg_config *conf = dev_data->conf; const struct control_message message = { .msg_type = (uint8_t)msg_type, .ept_addr = ept_addr, .block_index = block_index, }; int r; k_mutex_lock(&dev_data->mutex, K_FOREVER); r = icmsg_send(&conf->control_config, &dev_data->control_data, &message, sizeof(message)); k_mutex_unlock(&dev_data->mutex); if (r < 0) { LOG_ERR("Cannot send over ICMsg, err %d", r); } return r; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Fill RM header descriptor for next transfer with invalid toggle. */
static void rm_write_header_next_desc(void *desc, struct dma_iproc_pax_ring_data *r, uint32_t opq, uint32_t bdcount)
/* Fill RM header descriptor for next transfer with invalid toggle. */ static void rm_write_header_next_desc(void *desc, struct dma_iproc_pax_ring_data *r, uint32_t opq, uint32_t bdcount)
{ rm_write_header_desc(desc, (r->curr.toggle == 0) ? 1 : 0, opq, bdcount); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Raising to the task priority level of the mutual exclusion lock, and then acquires ownership of the lock. */
VOID CoreAcquireLock(IN EFI_LOCK *Lock)
/* Raising to the task priority level of the mutual exclusion lock, and then acquires ownership of the lock. */ VOID CoreAcquireLock(IN EFI_LOCK *Lock)
{ ASSERT (Lock != NULL); ASSERT (Lock->Lock == EfiLockReleased); Lock->OwnerTpl = CoreRaiseTpl (Lock->Tpl); Lock->Lock = EfiLockAcquired; }
tianocore/edk2
C++
Other
4,240
/* Increment the seqid if the LOCK/LOCKU succeeded, or failed with a seqid incrementing error - see comments nfs_fs.h:seqid_mutating_error() */
void nfs_increment_lock_seqid(int status, struct nfs_seqid *seqid)
/* Increment the seqid if the LOCK/LOCKU succeeded, or failed with a seqid incrementing error - see comments nfs_fs.h:seqid_mutating_error() */ void nfs_increment_lock_seqid(int status, struct nfs_seqid *seqid)
{ nfs_increment_seqid(status, seqid); }
robutest/uclinux
C++
GPL-2.0
60
/* Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: */
int SDL_SendDisplayEvent(SDL_VideoDisplay *display, Uint8 displayevent, int data1)
/* Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: */ int SDL_SendDisplayEvent(SDL_VideoDisplay *display, Uint8 displayevent, int data1)
{ int posted; if (!display) { return 0; } switch (displayevent) { case SDL_DISPLAYEVENT_ORIENTATION: if (data1 == SDL_ORIENTATION_UNKNOWN || data1 == display->orientation) { return 0; } display->orientation = (SDL_DisplayOrientation)data1; break; } posted = 0; if (SDL_GetEventState(SDL_DISPLAYEVENT) == SDL_ENABLE) { SDL_Event event; event.type = SDL_DISPLAYEVENT; event.display.event = displayevent; event.display.display = SDL_GetIndexOfDisplay(display); event.display.data1 = data1; posted = (SDL_PushEvent(&event) > 0); } return (posted); }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* extent_io.c merge_bio_hook, this must check the chunk tree to make sure we don't create bios that span stripes or chunks */
int btrfs_merge_bio_hook(struct page *page, unsigned long offset, size_t size, struct bio *bio, unsigned long bio_flags)
/* extent_io.c merge_bio_hook, this must check the chunk tree to make sure we don't create bios that span stripes or chunks */ int btrfs_merge_bio_hook(struct page *page, unsigned long offset, size_t size, struct bio *bio, unsigned long bio_flags)
{ struct btrfs_root *root = BTRFS_I(page->mapping->host)->root; struct btrfs_mapping_tree *map_tree; u64 logical = (u64)bio->bi_sector << 9; u64 length = 0; u64 map_length; int ret; if (bio_flags & EXTENT_BIO_COMPRESSED) return 0; length = bio->bi_size; map_tree = &root->fs_info->mapping_tree; map_length = length; ret = btrfs_map_block(map_tree, READ, logical, &map_length, NULL, 0); if (map_length < length + size) return 1; return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | Reserved (R) |S| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */
static void dissect_pmip6_opt_ipv4dsm(const mip6_opt *optp _U_, tvbuff_t *tvb, int offset, guint optlen _U_, packet_info *pinfo _U_, proto_tree *opt_tree, proto_item *hdr_item _U_)
/* 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | Reserved (R) |S| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ static void dissect_pmip6_opt_ipv4dsm(const mip6_opt *optp _U_, tvbuff_t *tvb, int offset, guint optlen _U_, packet_info *pinfo _U_, proto_tree *opt_tree, proto_item *hdr_item _U_)
{ offset++; proto_tree_add_item(opt_tree, hf_mip6_opt_len, tvb, offset, 1, ENC_BIG_ENDIAN); offset++; proto_tree_add_item(opt_tree, hf_mip6_ipv4dsm_reserved, tvb, offset, 2, ENC_BIG_ENDIAN); proto_tree_add_item(opt_tree, hf_mip6_ipv4dsm_s_flag, tvb, offset, 2, ENC_BIG_ENDIAN); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This API computes the number of bytes of Mag FIFO data which is to be parsed in header-less mode. */
static void get_mag_len_to_parse(uint16_t *start_idx, uint16_t *len, const uint16_t *mag_count, const struct bma4_dev *dev)
/* This API computes the number of bytes of Mag FIFO data which is to be parsed in header-less mode. */ static void get_mag_len_to_parse(uint16_t *start_idx, uint16_t *len, const uint16_t *mag_count, const struct bma4_dev *dev)
{ uint8_t dummy_byte_spi = 0; if (dev->fifo->mag_byte_start_idx == 0) dummy_byte_spi = dev->dummy_byte; *start_idx = dev->fifo->mag_byte_start_idx + dummy_byte_spi; if (dev->fifo->fifo_data_enable == BMA4_FIFO_M_ENABLE) { *len = (uint16_t)(((*mag_count) * BMA4_FIFO_M_LENGTH) + dummy_byte_spi); } else if (dev->fifo->fifo_data_enable == BMA4_FIFO_M_A_ENABLE) { *len = (uint16_t)(((*mag_count) * BMA4_FIFO_MA_LENGTH) + dummy_byte_spi); } else { *start_idx = dev->fifo->length; } if ((*len) > dev->fifo->length) { *len = dev->fifo->length; } }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* Sends a block of data to the SSP0 port. */
void sspSend(uint8_t portNum, uint8_t *buf, uint32_t length)
/* Sends a block of data to the SSP0 port. */ void sspSend(uint8_t portNum, uint8_t *buf, uint32_t length)
{ uint32_t i; uint8_t Dummy = Dummy; if (portNum == 0) { for (i = 0; i < length; i++) { while ((SSP_SSP0SR & (SSP_SSP0SR_TNF_NOTFULL | SSP_SSP0SR_BSY_BUSY)) != SSP_SSP0SR_TNF_NOTFULL); SSP_SSP0DR = *buf; buf++; while ( (SSP_SSP0SR & (SSP_SSP0SR_BSY_BUSY|SSP_SSP0SR_RNE_NOTEMPTY)) != SSP_SSP0SR_RNE_NOTEMPTY ); Dummy = SSP_SSP0DR; } } return; }
microbuilder/LPC1343CodeBase
C++
Other
73
/* Request the directory structure when an OFile is newly generated. If the directory structure is cached by volume, then just return this directory; Otherwise, allocate a new one for OFile. */
VOID FatRequestODir(IN FAT_OFILE *OFile)
/* Request the directory structure when an OFile is newly generated. If the directory structure is cached by volume, then just return this directory; Otherwise, allocate a new one for OFile. */ VOID FatRequestODir(IN FAT_OFILE *OFile)
{ UINTN DirCacheTag; FAT_VOLUME *Volume; FAT_ODIR *ODir; FAT_ODIR *CurrentODir; LIST_ENTRY *CurrentODirLink; Volume = OFile->Volume; ODir = NULL; DirCacheTag = OFile->FileCluster; for (CurrentODirLink = Volume->DirCacheList.ForwardLink; CurrentODirLink != &Volume->DirCacheList; CurrentODirLink = CurrentODirLink->ForwardLink ) { CurrentODir = ODIR_FROM_DIRCACHELINK (CurrentODirLink); if (CurrentODir->DirCacheTag == DirCacheTag) { RemoveEntryList (&CurrentODir->DirCacheLink); Volume->DirCacheCount--; ODir = CurrentODir; break; } } if (ODir == NULL) { ODir = FatAllocateODir (OFile); } OFile->ODir = ODir; }
tianocore/edk2
C++
Other
4,240
/* Immediately destroys the given cache, freeing all resources associated with it. As part of this process, the entry_destroy() function, (as passed to _cairo_cache_init()), will be called for each entry in the cache. */
void _cairo_cache_fini(cairo_cache_t *cache)
/* Immediately destroys the given cache, freeing all resources associated with it. As part of this process, the entry_destroy() function, (as passed to _cairo_cache_init()), will be called for each entry in the cache. */ void _cairo_cache_fini(cairo_cache_t *cache)
{ _cairo_hash_table_foreach (cache->hash_table, _cairo_cache_pluck, cache); assert (cache->size == 0); _cairo_hash_table_destroy (cache->hash_table); }
xboot/xboot
C++
MIT License
779
/* Set the color of a palette entry in 8bpp mode */
static void do_setpalentry(struct tdfx_par *par, unsigned regno, u32 c)
/* Set the color of a palette entry in 8bpp mode */ static void do_setpalentry(struct tdfx_par *par, unsigned regno, u32 c)
{ banshee_make_room(par, 2); tdfx_outl(par, DACADDR, regno); tdfx_inl(par, DACADDR); tdfx_outl(par, DACDATA, c); }
robutest/uclinux
C++
GPL-2.0
60
/* Clears the correct reception flag (bank 0 or bank 1) of an endpoint */
static void UDP_ClearRxFlag(unsigned char bEndpoint)
/* Clears the correct reception flag (bank 0 or bank 1) of an endpoint */ static void UDP_ClearRxFlag(unsigned char bEndpoint)
{ Endpoint *pEndpoint = &(endpoints[bEndpoint]); if (pEndpoint->bank == 0) { CLEAR_CSR(bEndpoint, UDP_CSR_RX_DATA_BK0); if (CHIP_USB_ENDPOINTS_BANKS(bEndpoint) > 1) { pEndpoint->bank = 1; } } else { CLEAR_CSR(bEndpoint, UDP_CSR_RX_DATA_BK1); pEndpoint->bank = 0; } }
opentx/opentx
C++
GNU General Public License v2.0
2,025
/* Add N to the value of a status record. It is assumed that the caller holds appropriate locks. */
SQLITE_PRIVATE void sqlite3StatusAdd(int, int)
/* Add N to the value of a status record. It is assumed that the caller holds appropriate locks. */ SQLITE_PRIVATE void sqlite3StatusAdd(int, int)
{ wsdStatInit; assert( op>=0 && op<ArraySize(wsdStat.nowValue) ); wsdStat.nowValue[op] += N; if( wsdStat.nowValue[op]>wsdStat.mxValue[op] ){ wsdStat.mxValue[op] = wsdStat.nowValue[op]; } }
DC-SWAT/DreamShell
C++
null
404
/* This function retrieves the amount of time the system will wait before firing the watchdog timer. This period is returned in TimerPeriod, and EFI_SUCCESS is returned. If TimerPeriod is NULL, then EFI_INVALID_PARAMETER is returned. */
EFI_STATUS EFIAPI WatchdogTimerDriverGetTimerPeriod(IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *This, IN UINT64 *TimerPeriod)
/* This function retrieves the amount of time the system will wait before firing the watchdog timer. This period is returned in TimerPeriod, and EFI_SUCCESS is returned. If TimerPeriod is NULL, then EFI_INVALID_PARAMETER is returned. */ EFI_STATUS EFIAPI WatchdogTimerDriverGetTimerPeriod(IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *This, IN UINT64 *TimerPeriod)
{ if (TimerPeriod == NULL) { return EFI_INVALID_PARAMETER; } *TimerPeriod = mWatchdogTimerPeriod; return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Unshare the filesystem structure if it is being shared */
static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
/* Unshare the filesystem structure if it is being shared */ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
{ struct fs_struct *fs = current->fs; if (!(unshare_flags & CLONE_FS) || !fs) return 0; if (fs->users == 1) return 0; *new_fsp = copy_fs_struct(fs); if (!*new_fsp) return -ENOMEM; return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Disables LIN Function mode on the specified UART. */
void xUARTLINDisable(unsigned long ulBase)
/* Disables LIN Function mode on the specified UART. */ void xUARTLINDisable(unsigned long ulBase)
{ xASSERT(UARTBaseValid(ulBase)); xHWREG(ulBase + UART_FUN_SEL) &= ~(UART_FUN_SEL_LIN_EN); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Set this bit to mark the last descriptor in the receive buffer descriptor list. */
static void XEmacPs_BdSetRxWrap(UINTPTR BdPtr)
/* Set this bit to mark the last descriptor in the receive buffer descriptor list. */ static void XEmacPs_BdSetRxWrap(UINTPTR BdPtr)
{ u32 DataValueRx; u32 *TempPtr; BdPtr += (u32)(XEMACPS_BD_ADDR_OFFSET); TempPtr = (u32 *)BdPtr; if(TempPtr != NULL) { DataValueRx = *TempPtr; DataValueRx |= XEMACPS_RXBUF_WRAP_MASK; *TempPtr = DataValueRx; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Called when a transfer is completed. Adds the given msg pointer to the list kept in the multi handle. */
static CURLMcode multi_addmsg(struct Curl_multi *multi, struct Curl_message *msg)
/* Called when a transfer is completed. Adds the given msg pointer to the list kept in the multi handle. */ static CURLMcode multi_addmsg(struct Curl_multi *multi, struct Curl_message *msg)
{ Curl_llist_insert_next(&multi->msglist, multi->msglist.tail, msg, &msg->list); return CURLM_OK; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Returns zero on success or negative value on failure */
static int cdns3_ep0_delegate_req(struct cdns3_device *priv_dev, struct usb_ctrlrequest *ctrl_req)
/* Returns zero on success or negative value on failure */ static int cdns3_ep0_delegate_req(struct cdns3_device *priv_dev, struct usb_ctrlrequest *ctrl_req)
{ int ret; spin_unlock(&priv_dev->lock); priv_dev->setup_pending = 1; ret = priv_dev->gadget_driver->setup(&priv_dev->gadget, ctrl_req); priv_dev->setup_pending = 0; spin_lock(&priv_dev->lock); return ret; }
4ms/stm32mp1-baremetal
C++
Other
137
/* I2C 1 interrupt handler. This function is the I2C interrupt handler, it simple execute the callback function if there be one. */
void I2C1IntHandler(void)
/* I2C 1 interrupt handler. This function is the I2C interrupt handler, it simple execute the callback function if there be one. */ void I2C1IntHandler(void)
{ if(g_pfnI2CHandlerCallbacks[1] != 0) { g_pfnI2CHandlerCallbacks[1](0, 0, 0, 0); } else { while(1); } }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Return the number of terms in the expression. */
int cr_term_nr_values(CRTerm *a_this)
/* Return the number of terms in the expression. */ int cr_term_nr_values(CRTerm *a_this)
{ CRTerm *cur = NULL ; int nr = 0; g_return_val_if_fail (a_this, -1) ; for (cur = a_this ; cur ; cur = cur->next) nr ++; return nr; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Calculate a 32-bit CRC for a given data word (8 bits) */
uint32_t CRC_CalculateCRC8bits(uint8_t data)
/* Calculate a 32-bit CRC for a given data word (8 bits) */ uint32_t CRC_CalculateCRC8bits(uint8_t data)
{ *(uint8_t*)(CRC_BASE) = (uint8_t) data; return (CRC->DATA); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* ADC Enable The Temperature Sensor. This enables both the sensor and the reference voltage measurements on channels 16 and 17. */
void adc_enable_temperature_sensor(uint32_t adc)
/* ADC Enable The Temperature Sensor. This enables both the sensor and the reference voltage measurements on channels 16 and 17. */ void adc_enable_temperature_sensor(uint32_t adc)
{ ADC_CR2(adc) |= ADC_CR2_TSVREFE; }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* Called by the Device Policy Manager to make a request of the USB-C Subsystem. */
int usbc_request(const struct device *dev, const enum usbc_policy_request_t req)
/* Called by the Device Policy Manager to make a request of the USB-C Subsystem. */ int usbc_request(const struct device *dev, const enum usbc_policy_request_t req)
{ struct usbc_port_data *data = dev->data; data->request.val = req; k_fifo_put(&data->request_fifo, &data->request); return 0; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* values = _cairo_array_index (&array, 0); for (i = 0; i < _cairo_array_num_elements (&array); i++) ... use values here ... </programlisting></informalexample> */
void* _cairo_array_index(cairo_array_t *array, unsigned int index)
/* values = _cairo_array_index (&array, 0); for (i = 0; i < _cairo_array_num_elements (&array); i++) ... use values here ... </programlisting></informalexample> */ void* _cairo_array_index(cairo_array_t *array, unsigned int index)
{ if (index == 0 && array->num_elements == 0) return NULL; assert (index < array->num_elements); return array->elements + index * array->element_size; }
xboot/xboot
C++
MIT License
779
/* Allow NOMMU mmap() to directly map the device (if not NULL) */
static unsigned long mapram_unmapped_area(struct mtd_info *, unsigned long, unsigned long, unsigned long)
/* Allow NOMMU mmap() to directly map the device (if not NULL) */ static unsigned long mapram_unmapped_area(struct mtd_info *, unsigned long, unsigned long, unsigned long)
{ struct map_info *map = mtd->priv; return (unsigned long) map->virt + offset; }
robutest/uclinux
C++
GPL-2.0
60
/* If we get a read error, return FALSE with *err and *err_info set appropriately. */
gboolean wtap_read_bytes(FILE_T fh, void *buf, unsigned int count, int *err, gchar **err_info)
/* If we get a read error, return FALSE with *err and *err_info set appropriately. */ gboolean wtap_read_bytes(FILE_T fh, void *buf, unsigned int count, int *err, gchar **err_info)
{ int bytes_read; bytes_read = file_read(buf, count, fh); if (bytes_read < 0 || (guint)bytes_read != count) { *err = file_error(fh, err_info); if (*err == 0) *err = WTAP_ERR_SHORT_READ; return FALSE; } return TRUE; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Attribute read call back for the Value V4 attribute. */
static ssize_t read_value_v4_1(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset)
/* Attribute read call back for the Value V4 attribute. */ static ssize_t read_value_v4_1(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset)
{ const uint8_t *value = attr->user_data; return bt_gatt_attr_read(conn, attr, buf, len, offset, value, sizeof(value_v4_1_value)); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Request the Tx or Rx buffers on the USB side be flushed. Tx flush: When all the currently buffered data has been sent, send an escape sequence back up the data stream to us Rx flush: add a flag in the data stream now so we know when it's made it's way up to us. */
static int qt2_box_flush(struct usb_serial *serial, unsigned char uart_number, unsigned short rcv_or_xmit)
/* Request the Tx or Rx buffers on the USB side be flushed. Tx flush: When all the currently buffered data has been sent, send an escape sequence back up the data stream to us Rx flush: add a flag in the data stream now so we know when it's made it's way up to us. */ static int qt2_box_flush(struct usb_serial *serial, unsigned char uart_number, unsigned short rcv_or_xmit)
{ int result; result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), QT2_FLUSH_DEVICE, 0x40, rcv_or_xmit, uart_number, NULL, 0, 300); return result; }
robutest/uclinux
C++
GPL-2.0
60
/* Check whether PCI-PCI bridge has PCI Hot Plug capability register block. */
BOOLEAN IsSHPC(IN PCI_IO_DEVICE *PciIoDevice)
/* Check whether PCI-PCI bridge has PCI Hot Plug capability register block. */ BOOLEAN IsSHPC(IN PCI_IO_DEVICE *PciIoDevice)
{ EFI_STATUS Status; UINT8 Offset; if (PciIoDevice == NULL) { return FALSE; } Offset = 0; Status = LocateCapabilityRegBlock ( PciIoDevice, EFI_PCI_CAPABILITY_ID_SHPC, &Offset, NULL ); if (!EFI_ERROR (Status)) { return TRUE; } return FALSE; }
tianocore/edk2
C++
Other
4,240
/* Clear interrupt flag accumulator interrupt of selected channel. */
void EPWM_ClearAccInt(EPWM_T *epwm, uint32_t u32ChannelNum)
/* Clear interrupt flag accumulator interrupt of selected channel. */ void EPWM_ClearAccInt(EPWM_T *epwm, uint32_t u32ChannelNum)
{ (epwm)->AINTSTS = (1UL << (u32ChannelNum)); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Called to read the public device address of the device */
static int ble_ll_hci_rd_bd_addr(uint8_t *rspbuf, uint8_t *rsplen)
/* Called to read the public device address of the device */ static int ble_ll_hci_rd_bd_addr(uint8_t *rspbuf, uint8_t *rsplen)
{ struct ble_hci_ip_rd_bd_addr_rp *rsp = (void *) rspbuf; memcpy(rsp->addr, g_dev_addr, BLE_DEV_ADDR_LEN); *rsplen = sizeof(*rsp); return BLE_ERR_SUCCESS; }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* Description: Create a new CIPSO_V4_MAP_LOCAL DOI definition based on the given ADD message and add it to the CIPSO V4 engine. Return zero on success and non-zero on error. */
static int netlbl_cipsov4_add_local(struct genl_info *info, struct netlbl_audit *audit_info)
/* Description: Create a new CIPSO_V4_MAP_LOCAL DOI definition based on the given ADD message and add it to the CIPSO V4 engine. Return zero on success and non-zero on error. */ static int netlbl_cipsov4_add_local(struct genl_info *info, struct netlbl_audit *audit_info)
{ int ret_val; struct cipso_v4_doi *doi_def = NULL; if (!info->attrs[NLBL_CIPSOV4_A_TAGLST]) return -EINVAL; doi_def = kmalloc(sizeof(*doi_def), GFP_KERNEL); if (doi_def == NULL) return -ENOMEM; doi_def->type = CIPSO_V4_MAP_LOCAL; ret_val = netlbl_cipsov4_add_common(info, doi_def); if (ret_val != 0) goto add_local_failure; ret_val = cipso_v4_doi_add(doi_def, audit_info); if (ret_val != 0) goto add_local_failure; return 0; add_local_failure: cipso_v4_doi_free(doi_def); return ret_val; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Return if a UEFI memory page should be marked as not present in SMM page table. If the memory map entries type is EfiLoaderCode/Data, EfiBootServicesCode/Data, EfiConventionalMemory, EfiUnusableMemory, EfiACPIReclaimMemory, return TRUE. Or return FALSE. */
BOOLEAN IsUefiPageNotPresent(IN EFI_MEMORY_DESCRIPTOR *MemoryMap)
/* Return if a UEFI memory page should be marked as not present in SMM page table. If the memory map entries type is EfiLoaderCode/Data, EfiBootServicesCode/Data, EfiConventionalMemory, EfiUnusableMemory, EfiACPIReclaimMemory, return TRUE. Or return FALSE. */ BOOLEAN IsUefiPageNotPresent(IN EFI_MEMORY_DESCRIPTOR *MemoryMap)
{ switch (MemoryMap->Type) { case EfiLoaderCode: case EfiLoaderData: case EfiBootServicesCode: case EfiBootServicesData: case EfiConventionalMemory: case EfiUnusableMemory: case EfiACPIReclaimMemory: return TRUE; default: return FALSE; } }
tianocore/edk2
C++
Other
4,240
/* validate k_wakeup() in some corner scenario trigger a timer and after expiration of timer call k_wakeup(), even the thread is not in sleep state neither in pending state */
ZTEST(threads_scheduling, test_wakeup_expired_timer_thread)
/* validate k_wakeup() in some corner scenario trigger a timer and after expiration of timer call k_wakeup(), even the thread is not in sleep state neither in pending state */ ZTEST(threads_scheduling, test_wakeup_expired_timer_thread)
{ k_tid_t tid = k_thread_create(&tthread[0], tstack, STACK_SIZE, thread_handler, NULL, NULL, NULL, K_PRIO_PREEMPT(0), 0, K_NO_WAIT); k_sem_take(&timer_sema, K_FOREVER); k_wakeup(tid); k_thread_abort(tid); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* If StartAddress > 0x0FFFFFFF, then ASSERT(). If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). If Size > 0 and Buffer is NULL, then ASSERT(). */
UINTN EFIAPI S3PciReadBuffer(IN UINTN StartAddress, IN UINTN Size, OUT VOID *Buffer)
/* If StartAddress > 0x0FFFFFFF, then ASSERT(). If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). If Size > 0 and Buffer is NULL, then ASSERT(). */ UINTN EFIAPI S3PciReadBuffer(IN UINTN StartAddress, IN UINTN Size, OUT VOID *Buffer)
{ RETURN_STATUS Status; Status = S3BootScriptSavePciCfgWrite ( S3BootScriptWidthUint8, PCILIB_TO_COMMON_ADDRESS (StartAddress), PciReadBuffer (StartAddress, Size, Buffer), Buffer ); ASSERT (Status == RETURN_SUCCESS); return Size; }
tianocore/edk2
C++
Other
4,240
/* put a workspace struct back on the list or free it if we have enough idle ones sitting around */
static int free_workspace(struct workspace *workspace)
/* put a workspace struct back on the list or free it if we have enough idle ones sitting around */ static int free_workspace(struct workspace *workspace)
{ spin_lock(&workspace_lock); if (num_workspace < num_online_cpus()) { list_add_tail(&workspace->list, &idle_workspace); num_workspace++; spin_unlock(&workspace_lock); if (waitqueue_active(&workspace_wait)) wake_up(&workspace_wait); return 0; } spin_unlock(&workspace_lock); vfree(workspace->def_strm.workspace); vfree(workspace->inf_strm.workspace); kfree(workspace->buf); kfree(workspace); atomic_dec(&alloc_workspace); if (waitqueue_active(&workspace_wait)) wake_up(&workspace_wait); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* fc_exch_done() - Indicate that an exchange/sequence tuple is complete and the memory allocated for the related objects may be freed. @sp: */
static void fc_exch_done(struct fc_seq *sp)
/* fc_exch_done() - Indicate that an exchange/sequence tuple is complete and the memory allocated for the related objects may be freed. @sp: */ static void fc_exch_done(struct fc_seq *sp)
{ struct fc_exch *ep = fc_seq_exch(sp); int rc; spin_lock_bh(&ep->ex_lock); rc = fc_exch_done_locked(ep); spin_unlock_bh(&ep->ex_lock); if (!rc) fc_exch_delete(ep); }
robutest/uclinux
C++
GPL-2.0
60
/* Get the error number from an RxRPC error message. */
int rxrpc_kernel_get_error_number(struct sk_buff *skb)
/* Get the error number from an RxRPC error message. */ int rxrpc_kernel_get_error_number(struct sk_buff *skb)
{ struct rxrpc_skb_priv *sp = rxrpc_skb(skb); return sp->error; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* CA checks common to all purposes return codes: 0 not a CA 1 is a CA 2 basicConstraints absent so "maybe" a CA 3 basicConstraints absent but self signed V1. 4 basicConstraints absent but keyUsage present and keyCertSign asserted. */
static int check_ca(const X509 *x)
/* CA checks common to all purposes return codes: 0 not a CA 1 is a CA 2 basicConstraints absent so "maybe" a CA 3 basicConstraints absent but self signed V1. 4 basicConstraints absent but keyUsage present and keyCertSign asserted. */ static int check_ca(const X509 *x)
{ if (ku_reject(x, KU_KEY_CERT_SIGN)) return 0; if (x->ex_flags & EXFLAG_BCONS) { if (x->ex_flags & EXFLAG_CA) return 1; else return 0; } else { if ((x->ex_flags & V1_ROOT) == V1_ROOT) return 3; else if (x->ex_flags & EXFLAG_KUSAGE) return 4; else if (x->ex_flags & EXFLAG_NSCERT && x->ex_nscert & NS_ANY_CA) return 5; return 0; } }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* UART MSP Initialization This function configures the hardware resources used in this example. */
void HAL_UART_MspInit(UART_HandleTypeDef *huart)
/* UART MSP Initialization This function configures the hardware resources used in this example. */ void HAL_UART_MspInit(UART_HandleTypeDef *huart)
{ GPIO_InitTypeDef GPIO_InitStruct = {0}; RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; if(huart->Instance==LPUART1) { PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_LPUART1; PeriphClkInit.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_PCLK1; if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) { Error_Handler(); } __HAL_RCC_LPUART1_CLK_ENABLE(); __HAL_RCC_GPIOG_CLK_ENABLE(); HAL_PWREx_EnableVddIO2(); GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_8; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Alternate = GPIO_AF8_LPUART1; HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); } }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Called from spice server thread context (via interface_release_resource) We do */
void qemu_spice_destroy_update(SimpleSpiceDisplay *sdpy, SimpleSpiceUpdate *update)
/* Called from spice server thread context (via interface_release_resource) We do */ void qemu_spice_destroy_update(SimpleSpiceDisplay *sdpy, SimpleSpiceUpdate *update)
{ g_free(update->bitmap); g_free(update); }
ve3wwg/teensy3_qemu
C++
Other
15
/* system init for baseboard usage. Will be called by mx31moboard init. */
void __init mx31moboard_devboard_init(void)
/* system init for baseboard usage. Will be called by mx31moboard init. */ void __init mx31moboard_devboard_init(void)
{ printk(KERN_INFO "Initializing mx31devboard peripherals\n"); mxc_iomux_setup_multiple_pins(devboard_pins, ARRAY_SIZE(devboard_pins), "devboard"); mxc_register_device(&mxc_uart_device1, &uart_pdata); mxc_register_device(&mxcsdhc_device1, &sdhc2_pdata); devboard_usbh1_init(); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* param base Quad Timer peripheral base address param channel Quad Timer channel number param mask The DMA to enable. This is a logical OR of members of the enumeration ::qtmr_dma_enable_t */
void QTMR_EnableDma(TMR_Type *base, qtmr_channel_selection_t channel, uint32_t mask)
/* param base Quad Timer peripheral base address param channel Quad Timer channel number param mask The DMA to enable. This is a logical OR of members of the enumeration ::qtmr_dma_enable_t */ void QTMR_EnableDma(TMR_Type *base, qtmr_channel_selection_t channel, uint32_t mask)
{ uint16_t reg; reg = base->CHANNEL[channel].DMA; if ((mask & (uint32_t)kQTMR_InputEdgeFlagDmaEnable) != 0U) { base->CHANNEL[channel].SCTRL &= (uint16_t)(~TMR_SCTRL_IEFIE_MASK); reg |= TMR_DMA_IEFDE_MASK; } if ((mask & (uint32_t)kQTMR_ComparatorPreload1DmaEnable) != 0U) { reg |= TMR_DMA_CMPLD1DE_MASK; } if ((mask & (uint32_t)kQTMR_ComparatorPreload2DmaEnable) != 0U) { reg |= TMR_DMA_CMPLD2DE_MASK; } base->CHANNEL[channel].DMA = reg; }
eclipse-threadx/getting-started
C++
Other
310
/* Attribute read call back for the Value V2 string attribute. */
static ssize_t read_str_value(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset)
/* Attribute read call back for the Value V2 string attribute. */ static ssize_t read_str_value(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset)
{ const char *value = attr->user_data; return bt_gatt_attr_read(conn, attr, buf, len, offset, value, strlen(value)); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Determines if a CPU feature is set in PcdCpuFeaturesSetting bit mask. */
BOOLEAN EFIAPI IsCpuFeatureInSetting(IN UINT32 Feature)
/* Determines if a CPU feature is set in PcdCpuFeaturesSetting bit mask. */ BOOLEAN EFIAPI IsCpuFeatureInSetting(IN UINT32 Feature)
{ return IsCpuFeatureSetInCpuPcd ( (UINT8 *)PcdGetPtr (PcdCpuFeaturesSetting), PcdGetSize (PcdCpuFeaturesSetting), Feature ); }
tianocore/edk2
C++
Other
4,240
/* Adds a record for dispatching specified arbitrary code into a specified boot script table. */
RETURN_STATUS EFIAPI S3BootScriptSaveDispatch2(IN VOID *EntryPoint, IN VOID *Context)
/* Adds a record for dispatching specified arbitrary code into a specified boot script table. */ RETURN_STATUS EFIAPI S3BootScriptSaveDispatch2(IN VOID *EntryPoint, IN VOID *Context)
{ UINT8 Length; UINT8 *Script; EFI_BOOT_SCRIPT_DISPATCH_2 ScriptDispatch2; if (!mS3BootScriptAcpiS3Enable) { return RETURN_SUCCESS; } Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_DISPATCH_2)); Script = S3BootScriptGetEntryAddAddress (Length); if (Script == NULL) { return RETURN_OUT_OF_RESOURCES; } ScriptDispatch2.OpCode = EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE; ScriptDispatch2.Length = Length; ScriptDispatch2.EntryPoint = (EFI_PHYSICAL_ADDRESS)(UINTN)EntryPoint; ScriptDispatch2.Context = (EFI_PHYSICAL_ADDRESS)(UINTN)Context; CopyMem ((VOID *)Script, (VOID *)&ScriptDispatch2, sizeof (EFI_BOOT_SCRIPT_DISPATCH_2)); SyncBootScript (Script); return RETURN_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* This function locks a logical eraseblock for writing. Returns zero in case of success and a negative error code in case of failure. */
static int leb_write_lock(struct ubi_device *ubi, int vol_id, int lnum)
/* This function locks a logical eraseblock for writing. Returns zero in case of success and a negative error code in case of failure. */ static int leb_write_lock(struct ubi_device *ubi, int vol_id, int lnum)
{ struct ubi_ltree_entry *le; le = ltree_add_entry(ubi, vol_id, lnum); if (IS_ERR(le)) return PTR_ERR(le); down_write(&le->mutex); return 0; }
EmcraftSystems/u-boot
C++
Other
181
/* Function for checking if the end of the tag data area was reached. */
static bool type_2_tag_is_end_reached(type_2_tag_t *p_type_2_tag, uint16_t offset)
/* Function for checking if the end of the tag data area was reached. */ static bool type_2_tag_is_end_reached(type_2_tag_t *p_type_2_tag, uint16_t offset)
{ return offset == (p_type_2_tag->cc.data_area_size + T2T_FIRST_DATA_BLOCK_OFFSET); }
labapart/polymcu
C++
null
201
/* Load the initial SIDs specified in a policy database structure into a SID table. */
int policydb_load_isids(struct policydb *p, struct sidtab *s)
/* Load the initial SIDs specified in a policy database structure into a SID table. */ int policydb_load_isids(struct policydb *p, struct sidtab *s)
{ struct ocontext *head, *c; int rc; rc = sidtab_init(s); if (rc) { printk(KERN_ERR "SELinux: out of memory on SID table init\n"); goto out; } head = p->ocontexts[OCON_ISID]; for (c = head; c; c = c->next) { if (!c->context[0].user) { printk(KERN_ERR "SELinux: SID %s was never " "defined.\n", c->u.name); rc = -EINVAL; goto out; } if (sidtab_insert(s, c->sid[0], &c->context[0])) { printk(KERN_ERR "SELinux: unable to load initial " "SID %s.\n", c->u.name); rc = -EINVAL; goto out; } } out: return rc; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* The method is slightly modified to shift B unconditionally up to just under the leading bit of b. This saves a lot of multiple precision shifting. */
int mp_montgomery_calc_normalization(mp_int *a, mp_int *b)
/* The method is slightly modified to shift B unconditionally up to just under the leading bit of b. This saves a lot of multiple precision shifting. */ int mp_montgomery_calc_normalization(mp_int *a, mp_int *b)
{ int x, bits, res; bits = mp_count_bits (b) % DIGIT_BIT; if (b->used > 1) { if ((res = mp_2expt (a, (b->used - 1) * DIGIT_BIT + bits - 1)) != MP_OKAY) { return res; } } else { if ((res = mp_set(a, 1)) != MP_OKAY) { return res; } bits = 1; } for (x = bits - 1; x < (int)DIGIT_BIT; x++) { if ((res = mp_mul_2 (a, a)) != MP_OKAY) { return res; } if (mp_cmp_mag (a, b) != MP_LT) { if ((res = s_mp_sub (a, b, a)) != MP_OKAY) { return res; } } } return MP_OKAY; }
RavenSystem/esp-homekit-devices
C++
Other
2,577
/* Gets a pointer to the Screen buffer associated with the given window. Note that the buffer is actually created in createWindow(). */
static int createWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
/* Gets a pointer to the Screen buffer associated with the given window. Note that the buffer is actually created in createWindow(). */ static int createWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
{ window_impl_t *impl = (window_impl_t *)window->driverdata; screen_buffer_t buffer; if (screen_get_window_property_pv(impl->window, SCREEN_PROPERTY_BUFFERS, (void **)&buffer) < 0) { return -1; } if (screen_get_buffer_property_pv(buffer, SCREEN_PROPERTY_POINTER, pixels) < 0) { return -1; } if (screen_get_buffer_property_iv(buffer, SCREEN_PROPERTY_STRIDE, pitch) < 0) { return -1; } *format = SDL_PIXELFORMAT_RGB888; return 0; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Locates the bhyve SMBIOS data if it exists */
SMBIOS_TABLE_ENTRY_POINT* GetBhyveSmbiosTables(VOID)
/* Locates the bhyve SMBIOS data if it exists */ SMBIOS_TABLE_ENTRY_POINT* GetBhyveSmbiosTables(VOID)
{ UINT8 *BhyveSmbiosPtr; SMBIOS_TABLE_ENTRY_POINT *BhyveSmbiosEntryPointStructure; for (BhyveSmbiosPtr = (UINT8 *)(UINTN)BHYVE_SMBIOS_PHYSICAL_ADDRESS; BhyveSmbiosPtr < (UINT8 *)(UINTN)BHYVE_SMBIOS_PHYSICAL_END; BhyveSmbiosPtr += 0x10) { BhyveSmbiosEntryPointStructure = (SMBIOS_TABLE_ENTRY_POINT *)BhyveSmbiosPtr; if (!AsciiStrnCmp ((CHAR8 *)BhyveSmbiosEntryPointStructure->AnchorString, "_SM_", 4) && !AsciiStrnCmp ((CHAR8 *)BhyveSmbiosEntryPointStructure->IntermediateAnchorString, "_DMI_", 5) && IsEntryPointStructureValid (BhyveSmbiosEntryPointStructure)) { return BhyveSmbiosEntryPointStructure; } } return NULL; }
tianocore/edk2
C++
Other
4,240
/* Instruction Nat Page Consumption Fault @ Nat Consumption Vector Refer to SDM Vol2 Table 5-6 & 8-1 */
void inat_page_consumption(struct kvm_vcpu *vcpu, u64 vadr)
/* Instruction Nat Page Consumption Fault @ Nat Consumption Vector Refer to SDM Vol2 Table 5-6 & 8-1 */ void inat_page_consumption(struct kvm_vcpu *vcpu, u64 vadr)
{ _nat_consumption_fault(vcpu, vadr, INSTRUCTION); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This function prints a formatted ASCII string to the console output device specified by StdErr in EFI_SYSTEM_TABLE and returns the number of ASCII characters that printed to StdErr. If the length of the formatted ASCII string is greater than PcdUefiLibMaxPrintBufferSize, then only the first PcdUefiLibMaxPrintBufferSize characters are sent to StdErr. If Format is NULL, then ASSERT(). If gST->StdErr is NULL, then ASSERT(). */
UINTN EFIAPI AsciiErrorPrint(IN CONST CHAR8 *Format,...)
/* This function prints a formatted ASCII string to the console output device specified by StdErr in EFI_SYSTEM_TABLE and returns the number of ASCII characters that printed to StdErr. If the length of the formatted ASCII string is greater than PcdUefiLibMaxPrintBufferSize, then only the first PcdUefiLibMaxPrintBufferSize characters are sent to StdErr. If Format is NULL, then ASSERT(). If gST->StdErr is NULL, then ASSERT(). */ UINTN EFIAPI AsciiErrorPrint(IN CONST CHAR8 *Format,...)
{ VA_LIST Marker; UINTN Return; ASSERT (Format != NULL); VA_START (Marker, Format); Return = AsciiInternalPrint (Format, gST->StdErr, Marker); VA_END (Marker); return Return; }
tianocore/edk2
C++
Other
4,240
/* End-of-IO handler helper function which does not touch the bh after unlocking it. Note: unlock_buffer() sort-of does touch the bh after unlocking it, but a race there is benign: unlock_buffer() only use the bh's address for hashing after unlocking the buffer, so it doesn't actually touch the bh itself. */
static void __end_buffer_read_notouch(struct buffer_head *bh, int uptodate)
/* End-of-IO handler helper function which does not touch the bh after unlocking it. Note: unlock_buffer() sort-of does touch the bh after unlocking it, but a race there is benign: unlock_buffer() only use the bh's address for hashing after unlocking the buffer, so it doesn't actually touch the bh itself. */ static void __end_buffer_read_notouch(struct buffer_head *bh, int uptodate)
{ if (uptodate) { set_buffer_uptodate(bh); } else { clear_buffer_uptodate(bh); } unlock_buffer(bh); }
robutest/uclinux
C++
GPL-2.0
60
/* This function is the implementation of SPI0 handler named in startup code. It passes the instance to the shared SPI DMA IRQ handler. */
void SPI0_IRQHandler(void)
/* This function is the implementation of SPI0 handler named in startup code. It passes the instance to the shared SPI DMA IRQ handler. */ void SPI0_IRQHandler(void)
{ SPI_DRV_DmaIRQHandler(SPI0_IDX); }
remotemcu/remcu-chip-sdks
C++
null
436
/* Clean up after the HPT372 and later DMA engine */
static void hpt37x_bmdma_stop(struct ata_queued_cmd *qc)
/* Clean up after the HPT372 and later DMA engine */ static void hpt37x_bmdma_stop(struct ata_queued_cmd *qc)
{ struct ata_port *ap = qc->ap; struct pci_dev *pdev = to_pci_dev(ap->host->dev); int mscreg = 0x50 + 4 * ap->port_no; u8 bwsr_stat, msc_stat; pci_read_config_byte(pdev, 0x6A, &bwsr_stat); pci_read_config_byte(pdev, mscreg, &msc_stat); if (bwsr_stat & (1 << ap->port_no)) pci_write_config_byte(pdev, mscreg, msc_stat | 0x30); ata_bmdma_stop(qc); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* got a msg to transfer, queue it in drv_data->queue. And kick off message pumper */
static int bfin_spi_transfer(struct spi_device *spi, struct spi_message *msg)
/* got a msg to transfer, queue it in drv_data->queue. And kick off message pumper */ static int bfin_spi_transfer(struct spi_device *spi, struct spi_message *msg)
{ struct driver_data *drv_data = spi_master_get_devdata(spi->master); unsigned long flags; spin_lock_irqsave(&drv_data->lock, flags); if (drv_data->run == QUEUE_STOPPED) { spin_unlock_irqrestore(&drv_data->lock, flags); return -ESHUTDOWN; } msg->actual_length = 0; msg->status = -EINPROGRESS; msg->state = START_STATE; dev_dbg(&spi->dev, "adding an msg in transfer() \n"); list_add_tail(&msg->queue, &drv_data->queue); if (drv_data->run == QUEUE_RUNNING && !drv_data->busy) queue_work(drv_data->workqueue, &drv_data->pump_messages); spin_unlock_irqrestore(&drv_data->lock, flags); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Expands a given area in all directions by a given amount. Note that the area boundaries are expanded on all sides by the given amount, thus the size expansion is twice the specified amount. */
void win_inflate_area(struct win_area *area, int16_t size)
/* Expands a given area in all directions by a given amount. Note that the area boundaries are expanded on all sides by the given amount, thus the size expansion is twice the specified amount. */ void win_inflate_area(struct win_area *area, int16_t size)
{ Assert(area); area->pos.x -= size; area->pos.y -= size; area->size.x += size * 2; area->size.y += size * 2; }
memfault/zero-to-main
C++
null
200
/* Check if this interface is USB NCM SubType */
BOOLEAN IsSupportedDevice(IN EFI_USB_IO_PROTOCOL *UsbIo)
/* Check if this interface is USB NCM SubType */ BOOLEAN IsSupportedDevice(IN EFI_USB_IO_PROTOCOL *UsbIo)
{ EFI_STATUS Status; EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor; Status = UsbIo->UsbGetInterfaceDescriptor (UsbIo, &InterfaceDescriptor); if (EFI_ERROR (Status)) { return FALSE; } if ((InterfaceDescriptor.InterfaceClass == USB_CDC_CLASS) && (InterfaceDescriptor.InterfaceSubClass == USB_CDC_NCM_SUBCLASS) && (InterfaceDescriptor.InterfaceProtocol == USB_NO_CLASS_PROTOCOL)) { return TRUE; } return FALSE; }
tianocore/edk2
C++
Other
4,240
/* param base CMC peripheral base address. param allowedModes Bitmaps of the allowed power modes. */
void CMC_SetPowerModeProtection(CMC_Type *base, uint32_t allowedModes)
/* param base CMC peripheral base address. param allowedModes Bitmaps of the allowed power modes. */ void CMC_SetPowerModeProtection(CMC_Type *base, uint32_t allowedModes)
{ uint32_t reg; reg = base->PMPROT; reg &= ~0xFUL; reg |= allowedModes; base->PMPROT = reg; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Gets the type of parity currently being used. */
unsigned long UARTParityModeGet(unsigned long ulBase)
/* Gets the type of parity currently being used. */ unsigned long UARTParityModeGet(unsigned long ulBase)
{ ASSERT(UARTBaseValid(ulBase)); return(HWREG(ulBase + UART_O_LCRH) & (UART_LCRH_SPS | UART_LCRH_EPS | UART_LCRH_PEN)); }
watterott/WebRadio
C++
null
71
/* If the application is using a static interrupt vector table stored in flash, then it is not necessary to register the interrupt handler this way. Instead, IntEnable() should be used to enable DES interrupts on the interrupt controller. */
void DESIntRegister(uint32_t ui32Base, void(*pfnHandler)(void))
/* If the application is using a static interrupt vector table stored in flash, then it is not necessary to register the interrupt handler this way. Instead, IntEnable() should be used to enable DES interrupts on the interrupt controller. */ void DESIntRegister(uint32_t ui32Base, void(*pfnHandler)(void))
{ ASSERT(ui32Base == DES_BASE); IntRegister(INT_DES0_TM4C129, pfnHandler); IntEnable(INT_DES0_TM4C129); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* One cpuset is a subset of another if all its allowed CPUs and Memory Nodes are a subset of the other, and its exclusive flags are only set if the other's are set. Call holding cgroup_mutex. */
static int is_cpuset_subset(const struct cpuset *p, const struct cpuset *q)
/* One cpuset is a subset of another if all its allowed CPUs and Memory Nodes are a subset of the other, and its exclusive flags are only set if the other's are set. Call holding cgroup_mutex. */ static int is_cpuset_subset(const struct cpuset *p, const struct cpuset *q)
{ return cpumask_subset(p->cpus_allowed, q->cpus_allowed) && nodes_subset(p->mems_allowed, q->mems_allowed) && is_cpu_exclusive(p) <= is_cpu_exclusive(q) && is_mem_exclusive(p) <= is_mem_exclusive(q); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* ReadPropertyMultiple-Ack ::= SEQUENCE { listOfReadAccessResults SEQUENCE OF ReadAccessResult } */
static guint fReadPropertyMultipleAck(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
/* ReadPropertyMultiple-Ack ::= SEQUENCE { listOfReadAccessResults SEQUENCE OF ReadAccessResult } */ static guint fReadPropertyMultipleAck(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
{ col_set_writable(pinfo->cinfo, COL_INFO, FALSE); return fReadAccessResult(tvb, pinfo, tree, offset); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Do not check arguments before starting the DMA memcpy. Break the transfer up into two pieces. The first transfer is in multiples of 64k and the second transfer is the piece smaller than 64k. */
void* dma_memcpy(void *pdst, const void *psrc, size_t size)
/* Do not check arguments before starting the DMA memcpy. Break the transfer up into two pieces. The first transfer is in multiples of 64k and the second transfer is the piece smaller than 64k. */ void* dma_memcpy(void *pdst, const void *psrc, size_t size)
{ unsigned long dst = (unsigned long)pdst; unsigned long src = (unsigned long)psrc; size_t bulk, rest; if (bfin_addr_dcacheable(src)) blackfin_dcache_flush_range(src, src + size); if (bfin_addr_dcacheable(dst)) blackfin_dcache_invalidate_range(dst, dst + size); bulk = size & ~0xffff; rest = size - bulk; if (bulk) _dma_memcpy(pdst, psrc, bulk); _dma_memcpy(pdst + bulk, psrc + bulk, rest); return pdst; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Get function for sysfs attribute anycast_mask. Attributes exported through sysfs */
static ssize_t lbs_anycast_get(struct device *dev, struct device_attribute *attr, char *buf)
/* Get function for sysfs attribute anycast_mask. Attributes exported through sysfs */ static ssize_t lbs_anycast_get(struct device *dev, struct device_attribute *attr, char *buf)
{ struct lbs_private *priv = to_net_dev(dev)->ml_priv; struct cmd_ds_mesh_access mesh_access; int ret; memset(&mesh_access, 0, sizeof(mesh_access)); ret = lbs_mesh_access(priv, CMD_ACT_MESH_GET_ANYCAST, &mesh_access); if (ret) return ret; return snprintf(buf, 12, "0x%X\n", le32_to_cpu(mesh_access.data[0])); }
robutest/uclinux
C++
GPL-2.0
60
/* Event handler for the USB_ConfigurationChanged event. This is fired when the host set the current configuration of the USB device after enumeration - the device endpoints are configured. */
void EVENT_USB_Device_ConfigurationChanged(void)
/* Event handler for the USB_ConfigurationChanged event. This is fired when the host set the current configuration of the USB device after enumeration - the device endpoints are configured. */ void EVENT_USB_Device_ConfigurationChanged(void)
{ bool ConfigSuccess = true; ConfigSuccess &= Endpoint_ConfigureEndpoint(AUDIO_STREAM_EPADDR, EP_TYPE_ISOCHRONOUS, AUDIO_STREAM_EPSIZE, 2); LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR); }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* set vga decode state - true == enable VGA decode */
int intel_modeset_vga_set_state(struct drm_device *dev, bool state)
/* set vga decode state - true == enable VGA decode */ int intel_modeset_vga_set_state(struct drm_device *dev, bool state)
{ struct drm_i915_private *dev_priv = dev->dev_private; u16 gmch_ctrl; pci_read_config_word(dev_priv->bridge_dev, INTEL_GMCH_CTRL, &gmch_ctrl); if (state) gmch_ctrl &= ~INTEL_GMCH_VGA_DISABLE; else gmch_ctrl |= INTEL_GMCH_VGA_DISABLE; pci_write_config_word(dev_priv->bridge_dev, INTEL_GMCH_CTRL, gmch_ctrl); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* speaker_gain_set - set the value of the speaker amp gain @value: The value to write. */
static void speaker_gain_set(int value)
/* speaker_gain_set - set the value of the speaker amp gain @value: The value to write. */ static void speaker_gain_set(int value)
{ gpio_set_value_cansleep(pdata->amp_gain[0], value & 1); gpio_set_value_cansleep(pdata->amp_gain[1], value >> 1); }
robutest/uclinux
C++
GPL-2.0
60
/* Note, even though MTD erase interface is asynchronous, all the current implementations are synchronous anyway. */
static void erase_callback(struct erase_info *ei)
/* Note, even though MTD erase interface is asynchronous, all the current implementations are synchronous anyway. */ static void erase_callback(struct erase_info *ei)
{ wake_up_interruptible((wait_queue_head_t *)ei->priv); }
EmcraftSystems/u-boot
C++
Other
181
/* Reload the watchdog timer. (ie, pat the watchdog) */
static void ks8695_wdt_reload(void)
/* Reload the watchdog timer. (ie, pat the watchdog) */ static void ks8695_wdt_reload(void)
{ unsigned long tmcon; spin_lock(&ks8695_lock); tmcon = __raw_readl(KS8695_TMR_VA + KS8695_TMCON); __raw_writel(tmcon & ~TMCON_T0EN, KS8695_TMR_VA + KS8695_TMCON); __raw_writel(tmcon | TMCON_T0EN, KS8695_TMR_VA + KS8695_TMCON); spin_unlock(&ks8695_lock); }
robutest/uclinux
C++
GPL-2.0
60
/* msg_ids.rw_mutex (writer) and the spinlock for this message queue are held before freeque() is called. msg_ids.rw_mutex remains locked on exit. */
static void freeque(struct ipc_namespace *, struct kern_ipc_perm *)
/* msg_ids.rw_mutex (writer) and the spinlock for this message queue are held before freeque() is called. msg_ids.rw_mutex remains locked on exit. */ static void freeque(struct ipc_namespace *, struct kern_ipc_perm *)
{ struct list_head *tmp; struct msg_queue *msq = container_of(ipcp, struct msg_queue, q_perm); expunge_all(msq, -EIDRM); ss_wakeup(&msq->q_senders, 1); msg_rmid(ns, msq); msg_unlock(msq); tmp = msq->q_messages.next; while (tmp != &msq->q_messages) { struct msg_msg *msg = list_entry(tmp, struct msg_msg, m_list); tmp = tmp->next; atomic_dec(&ns->msg_hdrs); free_msg(msg); } atomic_sub(msq->q_cbytes, &ns->msg_bytes); security_msg_queue_free(msq); ipc_rcu_putref(msq); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This function is used for getting the count of block I/O devices that one specific block driver detects. To the PEI ATAPI driver, it returns the number of all the detected ATAPI devices it detects during the enumeration process. To the PEI legacy floppy driver, it returns the number of all the legacy devices it finds during its enumeration process. If no device is detected, then the function will return zero. */
EFI_STATUS EFIAPI SdBlockIoPeimGetDeviceNo(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This, OUT UINTN *NumberBlockDevices)
/* This function is used for getting the count of block I/O devices that one specific block driver detects. To the PEI ATAPI driver, it returns the number of all the detected ATAPI devices it detects during the enumeration process. To the PEI legacy floppy driver, it returns the number of all the legacy devices it finds during its enumeration process. If no device is detected, then the function will return zero. */ EFI_STATUS EFIAPI SdBlockIoPeimGetDeviceNo(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This, OUT UINTN *NumberBlockDevices)
{ SD_PEIM_HC_PRIVATE_DATA *Private; Private = GET_SD_PEIM_HC_PRIVATE_DATA_FROM_THIS (This); *NumberBlockDevices = Private->TotalBlkIoDevices; return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Send an ASCII string to GDB. This function must be able to run in interrupt context. */
VOID GdbPutString(IN CHAR8 *String)
/* Send an ASCII string to GDB. This function must be able to run in interrupt context. */ VOID GdbPutString(IN CHAR8 *String)
{ while (*String != '\0') { GdbPutChar (*String); String++; } }
tianocore/edk2
C++
Other
4,240
/* Writes the given value in the status register of the serial flash device. */
static void s25fl1xx_write_status(struct qspid_t *qspid, uint8_t *status)
/* Writes the given value in the status register of the serial flash device. */ static void s25fl1xx_write_status(struct qspid_t *qspid, uint8_t *status)
{ s25fl1xx_enable_write(qspid); s25fl1xx_exec_command(qspid, S25FL1XX_WRITE_STATUS, (uint32_t *)status, 0, QSPI_WRITE_ACCESS, 3); s25fl1xx_disable_write(qspid); }
remotemcu/remcu-chip-sdks
C++
null
436
/* Multiply two Big Numbers modulo BnM. Please note, all "out" Big number arguments should be properly initialized by calling to BigNumInit() or BigNumFromBin() functions. */
BOOLEAN EFIAPI BigNumMulMod(IN CONST VOID *BnA, IN CONST VOID *BnB, IN CONST VOID *BnM, OUT VOID *BnRes)
/* Multiply two Big Numbers modulo BnM. Please note, all "out" Big number arguments should be properly initialized by calling to BigNumInit() or BigNumFromBin() functions. */ BOOLEAN EFIAPI BigNumMulMod(IN CONST VOID *BnA, IN CONST VOID *BnB, IN CONST VOID *BnM, OUT VOID *BnRes)
{ BOOLEAN RetVal; BN_CTX *Ctx; Ctx = BN_CTX_new (); if (Ctx == NULL) { return FALSE; } RetVal = (BOOLEAN)BN_mod_mul (BnRes, BnA, BnB, BnM, Ctx); BN_CTX_free (Ctx); return RetVal; }
tianocore/edk2
C++
Other
4,240
/* USART RS485 mode configuration. Configure USART in RS485 mode, asynchronous, 8 bits, 1 stop bit, no parity, 256000 bauds and enable its transmitter and receiver. */
static void configure_usart(void)
/* USART RS485 mode configuration. Configure USART in RS485 mode, asynchronous, 8 bits, 1 stop bit, no parity, 256000 bauds and enable its transmitter and receiver. */ static void configure_usart(void)
{ const sam_usart_opt_t usart_console_settings = { BOARD_USART_BAUDRATE, US_MR_CHRL_8_BIT, US_MR_PAR_NO, US_MR_NBSTOP_1_BIT, US_MR_CHMODE_NORMAL, 0 }; sysclk_enable_peripheral_clock(BOARD_ID_USART); usart_init_rs485(BOARD_USART, &usart_console_settings, sysclk_get_peripheral_hz()); usart_set_tx_timeguard(BOARD_USART, 4); usart_disable_interrupt(BOARD_USART, ALL_INTERRUPT_MASK); usart_enable_tx(BOARD_USART); usart_enable_rx(BOARD_USART); NVIC_EnableIRQ(USART_IRQn); }
remotemcu/remcu-chip-sdks
C++
null
436
/* acpi_idle_bm_check - checks if bus master activity was detected */
static int acpi_idle_bm_check(void)
/* acpi_idle_bm_check - checks if bus master activity was detected */ static int acpi_idle_bm_check(void)
{ u32 bm_status = 0; acpi_read_bit_register(ACPI_BITREG_BUS_MASTER_STATUS, &bm_status); if (bm_status) acpi_write_bit_register(ACPI_BITREG_BUS_MASTER_STATUS, 1); else if (errata.piix4.bmisx) { if ((inb_p(errata.piix4.bmisx + 0x02) & 0x01) || (inb_p(errata.piix4.bmisx + 0x0A) & 0x01)) bm_status = 1; } return bm_status; }
robutest/uclinux
C++
GPL-2.0
60
/* Starts final checksum computation. Configures the CRC module for the specified CRC protocol. */
static void CRC_SetProtocolConfig(CRC_Type *base, const crc_config_t *protocolConfig)
/* Starts final checksum computation. Configures the CRC module for the specified CRC protocol. */ static void CRC_SetProtocolConfig(CRC_Type *base, const crc_config_t *protocolConfig)
{ crc_module_config_t moduleConfig; moduleConfig.polynomial = protocolConfig->polynomial; moduleConfig.seed = protocolConfig->seed; moduleConfig.readTranspose = CRC_GetTransposeTypeFromReflectOut(protocolConfig->reflectOut); moduleConfig.writeTranspose = CRC_GetTransposeTypeFromReflectIn(protocolConfig->reflectIn); moduleConfig.complementChecksum = protocolConfig->complementChecksum; moduleConfig.crcBits = protocolConfig->crcBits; CRC_ConfigureAndStart(base, &moduleConfig); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535