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
|
|---|---|---|---|---|---|---|---|
/* Find NAND Timing.
This function determines the NAND Timing parameter which is given in units of GPMI cycles. The GPMI period is used to determine how many cycles fit into the NAND parameter. */
|
uint32_t gpmi_find_cycles_ceiling(uint64_t u32NandTime_ns, uint32_t u32GpmiPeriod_ns, uint32_t u32MinVal)
|
/* Find NAND Timing.
This function determines the NAND Timing parameter which is given in units of GPMI cycles. The GPMI period is used to determine how many cycles fit into the NAND parameter. */
uint32_t gpmi_find_cycles_ceiling(uint64_t u32NandTime_ns, uint32_t u32GpmiPeriod_ns, uint32_t u32MinVal)
|
{
uint32_t retVal = ((u32NandTime_ns + (u32GpmiPeriod_ns - 1)) / u32GpmiPeriod_ns);
return std::max(retVal, u32MinVal);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* This function registers ciphers and digests used directly and indirectly by SSL/TLS, and initializes the readable error messages. This function must be called before any other action takes places. */
|
BOOLEAN EFIAPI TlsInitialize(VOID)
|
/* This function registers ciphers and digests used directly and indirectly by SSL/TLS, and initializes the readable error messages. This function must be called before any other action takes places. */
BOOLEAN EFIAPI TlsInitialize(VOID)
|
{
INTN Ret;
Ret = OPENSSL_init_ssl (
OPENSSL_INIT_LOAD_SSL_STRINGS | OPENSSL_INIT_LOAD_CRYPTO_STRINGS,
NULL
);
if (Ret != 1) {
return FALSE;
}
return RandomSeed (NULL, 0);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Reset, and then set host adaptor into default mode. */
|
static void wv_hacr_reset(unsigned long ioaddr)
|
/* Reset, and then set host adaptor into default mode. */
static void wv_hacr_reset(unsigned long ioaddr)
|
{
hacr_write_slow(ioaddr, HACR_RESET);
hacr_write(ioaddr, HACR_DEFAULT);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* routine to create an XML buffer. returns the new structure. */
|
xmlBufPtr xmlBufCreateSize(size_t size)
|
/* routine to create an XML buffer. returns the new structure. */
xmlBufPtr xmlBufCreateSize(size_t size)
|
{
xmlBufMemoryError(NULL, "creating buffer");
return(NULL);
}
ret->compat_use = 0;
ret->use = 0;
ret->error = 0;
ret->buffer = NULL;
ret->alloc = xmlBufferAllocScheme;
ret->size = (size ? size+2 : 0);
ret->compat_size = (int) ret->size;
if (ret->size){
ret->content = (xmlChar *) xmlMallocAtomic(ret->size * sizeof(xmlChar));
if (ret->content == NULL) {
xmlBufMemoryError(ret, "creating buffer");
xmlFree(ret);
return(NULL);
}
ret->content[0] = 0;
} else
ret->content = NULL;
ret->contentIO = NULL;
return(ret);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* In a fault condition, pins which have not been configured to be suppressed via a call to */
|
void PWMOutputFaultLevel(uint32_t ui32Base, uint32_t ui32PWMOutBits, bool bDriveHigh)
|
/* In a fault condition, pins which have not been configured to be suppressed via a call to */
void PWMOutputFaultLevel(uint32_t ui32Base, uint32_t ui32PWMOutBits, bool bDriveHigh)
|
{
ASSERT(ui32Base == PWM0_BASE);
ASSERT(!(ui32PWMOutBits & ~(PWM_OUT_0_BIT | PWM_OUT_1_BIT | PWM_OUT_2_BIT |
PWM_OUT_3_BIT | PWM_OUT_4_BIT | PWM_OUT_5_BIT |
PWM_OUT_6_BIT | PWM_OUT_7_BIT)));
if (bDriveHigh == true)
{
HWREG(ui32Base + PWM_O_FAULTVAL) |= ui32PWMOutBits;
}
else
{
HWREG(ui32Base + PWM_O_FAULTVAL) &= ~(ui32PWMOutBits);
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* ZigBee ZCL Illuminance Level Sensing cluster dissector for wireshark. */
|
static int dissect_zbee_zcl_illum_level_sen(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_)
|
/* ZigBee ZCL Illuminance Level Sensing cluster dissector for wireshark. */
static int dissect_zbee_zcl_illum_level_sen(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_)
|
{
return tvb_captured_length(tvb);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* this function is a POSIX compliant version, which will get file status. */
|
int fstat(int fildes, struct stat *buf)
|
/* this function is a POSIX compliant version, which will get file status. */
int fstat(int fildes, struct stat *buf)
|
{
struct dfs_file *d;
d = fd_get(fildes);
if (d == NULL)
{
rt_set_errno(-EBADF);
return -1;
}
return stat(d->vnode->fullpath, buf);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Default read function for 16bit buswith with endianess conversion */
|
static uint8_t nand_read_byte16(struct mtd_info *mtd)
|
/* Default read function for 16bit buswith with endianess conversion */
static uint8_t nand_read_byte16(struct mtd_info *mtd)
|
{
struct nand_chip *chip = mtd->priv;
return (uint8_t) cpu_to_le16(readw(chip->IO_ADDR_R));
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* Internal pixel drawing - fast, no blending, locking, RGB input. */
|
int fastPixelRGBA(SDL_Surface *dst, Sint16 x, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
/* Internal pixel drawing - fast, no blending, locking, RGB input. */
int fastPixelRGBA(SDL_Surface *dst, Sint16 x, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
{
Uint32 color;
color = SDL_MapRGBA(dst->format, r, g, b, a);
return (fastPixelColor(dst, x, y, color));
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* System calibration osc disable.
Use this function to disable system calibration osc. */
|
void system_osc_calibration_disable(void)
|
/* System calibration osc disable.
Use this function to disable system calibration osc. */
void system_osc_calibration_disable(void)
|
{
LP_CLK_CAL_REGS0->CONFIG_REG.reg &= \
~LP_CLK_CAL_REGS_CONFIG_REG_START_OSC_CALIB;
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* Init routine for the IEEE 802.15.4 dissector. Creates hash tables for mapping between 16-bit to 64-bit addresses and populates them with static address pairs from a UAT preference table. */
|
static void proto_init_ieee802154(void)
|
/* Init routine for the IEEE 802.15.4 dissector. Creates hash tables for mapping between 16-bit to 64-bit addresses and populates them with static address pairs from a UAT preference table. */
static void proto_init_ieee802154(void)
|
{
guint i;
ieee802154_map.short_table = g_hash_table_new(ieee802154_short_addr_hash, ieee802154_short_addr_equal);
ieee802154_map.long_table = g_hash_table_new(ieee802154_long_addr_hash, ieee802154_long_addr_equal);
for (i=0; (i<num_static_addrs) && (static_addrs); i++) {
ieee802154_addr_update(&ieee802154_map,(guint16)static_addrs[i].addr16, (guint16)static_addrs[i].pan,
pntoh64(static_addrs[i].eui64), ieee802154_user, IEEE802154_USER_MAPPING);
}
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* This function will connect all current system handles recursively. The connection will finish until every handle's child handle created if it have. */
|
EFI_STATUS ConnectAllEfi(VOID)
|
/* This function will connect all current system handles recursively. The connection will finish until every handle's child handle created if it have. */
EFI_STATUS ConnectAllEfi(VOID)
|
{
EFI_STATUS Status;
UINTN HandleCount;
EFI_HANDLE *HandleBuffer;
UINTN Index;
Status = gBS->LocateHandleBuffer (
AllHandles,
NULL,
NULL,
&HandleCount,
&HandleBuffer
);
if (EFI_ERROR (Status)) {
return Status;
}
for (Index = 0; Index < HandleCount; Index++) {
Status = gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
}
if (HandleBuffer != NULL) {
FreePool (HandleBuffer);
}
return EFI_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Clear out all data in the circular buffer. */
|
static void edge_buf_clear(struct edge_buf *eb)
|
/* Clear out all data in the circular buffer. */
static void edge_buf_clear(struct edge_buf *eb)
|
{
if (eb != NULL)
eb->buf_get = eb->buf_put;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Event handler for the library USB Control Request reception event. */
|
void EVENT_USB_Device_ControlRequest(void)
|
/* Event handler for the library USB Control Request reception event. */
void EVENT_USB_Device_ControlRequest(void)
|
{
MS_Device_ProcessControlRequest(&Disk_MS_Interface);
}
|
prusa3d/Prusa-Firmware-Buddy
|
C++
|
Other
| 1,019
|
/* Generate random count of MTRRs for each cache type. */
|
VOID GenerateRandomMemoryTypeCombination(IN UINT32 TotalCount, OUT UINT32 *UcCount, OUT UINT32 *WtCount, OUT UINT32 *WbCount, OUT UINT32 *WpCount, OUT UINT32 *WcCount)
|
/* Generate random count of MTRRs for each cache type. */
VOID GenerateRandomMemoryTypeCombination(IN UINT32 TotalCount, OUT UINT32 *UcCount, OUT UINT32 *WtCount, OUT UINT32 *WbCount, OUT UINT32 *WpCount, OUT UINT32 *WcCount)
|
{
UINTN Index;
UINT32 TotalMtrrCount;
UINT32 *CountPerType[5];
CountPerType[0] = UcCount;
CountPerType[1] = WtCount;
CountPerType[2] = WbCount;
CountPerType[3] = WpCount;
CountPerType[4] = WcCount;
for (Index = 0; Index < ARRAY_SIZE (CountPerType); Index++) {
*(CountPerType[Index]) = 0;
}
TotalMtrrCount = Random32 (1, TotalCount);
for (Index = 0; Index < TotalMtrrCount; Index++) {
(*(CountPerType[Random32 (0, ARRAY_SIZE (CountPerType) - 1)]))++;
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This function is wrapper to get the file size using TFTP. */
|
EFI_STATUS PxeBcTftpGetFileSize(IN PXEBC_PRIVATE_DATA *Private, IN VOID *Config, IN UINT8 *Filename, IN UINTN *BlockSize, IN UINTN *WindowSize, IN OUT UINT64 *BufferSize)
|
/* This function is wrapper to get the file size using TFTP. */
EFI_STATUS PxeBcTftpGetFileSize(IN PXEBC_PRIVATE_DATA *Private, IN VOID *Config, IN UINT8 *Filename, IN UINTN *BlockSize, IN UINTN *WindowSize, IN OUT UINT64 *BufferSize)
|
{
if (Private->PxeBc.Mode->UsingIpv6) {
return PxeBcMtftp6GetFileSize (
Private,
(EFI_MTFTP6_CONFIG_DATA *)Config,
Filename,
BlockSize,
WindowSize,
BufferSize
);
} else {
return PxeBcMtftp4GetFileSize (
Private,
(EFI_MTFTP4_CONFIG_DATA *)Config,
Filename,
BlockSize,
WindowSize,
BufferSize
);
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Return code 0 - Successfully released lpfc DMA buffer (currently, always return 0) */
|
static int lpfc_els_free_data(struct lpfc_hba *phba, struct lpfc_dmabuf *buf_ptr1)
|
/* Return code 0 - Successfully released lpfc DMA buffer (currently, always return 0) */
static int lpfc_els_free_data(struct lpfc_hba *phba, struct lpfc_dmabuf *buf_ptr1)
|
{
struct lpfc_dmabuf *buf_ptr;
if (!list_empty(&buf_ptr1->list)) {
list_remove_head(&buf_ptr1->list, buf_ptr,
struct lpfc_dmabuf,
list);
lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys);
kfree(buf_ptr);
}
lpfc_mbuf_free(phba, buf_ptr1->virt, buf_ptr1->phys);
kfree(buf_ptr1);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Initialize the state of virtual wires to default based on the vw_state_default array. */
|
static void emul_host_init_vw_state(struct espi_host_emul_data *data)
|
/* Initialize the state of virtual wires to default based on the vw_state_default array. */
static void emul_host_init_vw_state(struct espi_host_emul_data *data)
|
{
unsigned i;
for (i = 0; i < NUMBER_OF_VWIRES; i++) {
data->vw_state[i] = vw_state_default[i];
}
return;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Check for receive CRC error. Retruns true if rx frame CRC error occured. */
|
bool synopGMAC_is_rx_crc(u32 status)
|
/* Check for receive CRC error. Retruns true if rx frame CRC error occured. */
bool synopGMAC_is_rx_crc(u32 status)
|
{
return ((status & DescRxCrc) == DescRxCrc);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* we cannot loop indefinitely here to avoid userspace starvation, but we also don't want to introduce a worst case 1/HZ latency to the pending events, so lets the scheduler to balance the softirq load for us. */
|
void wakeup_softirqd(void)
|
/* we cannot loop indefinitely here to avoid userspace starvation, but we also don't want to introduce a worst case 1/HZ latency to the pending events, so lets the scheduler to balance the softirq load for us. */
void wakeup_softirqd(void)
|
{
struct task_struct *tsk = __get_cpu_var(ksoftirqd);
if (tsk && tsk->state != TASK_RUNNING)
wake_up_process(tsk);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Deinitializes the I2Cx peripheral registers to their default reset values. */
|
void I2C_DeInit(I2C_TypeDef *I2Cx)
|
/* Deinitializes the I2Cx peripheral registers to their default reset values. */
void I2C_DeInit(I2C_TypeDef *I2Cx)
|
{
assert_param(IS_I2C_ALL_PERIPH(I2Cx));
switch (*(uint32_t*)&I2Cx)
{
case I2C1_BASE:
RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C1, ENABLE);
RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C1, DISABLE);
break;
default:
break;
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* This routine services a user request to discover the SMRAM capabilities of this platform. This will report the possible ranges that are possible for SMRAM access, based upon the memory controller capabilities. */
|
EFI_STATUS EFIAPI GetCapabilities(IN CONST EFI_SMM_ACCESS2_PROTOCOL *This, IN OUT UINTN *SmramMapSize, IN OUT EFI_SMRAM_DESCRIPTOR *SmramMap)
|
/* This routine services a user request to discover the SMRAM capabilities of this platform. This will report the possible ranges that are possible for SMRAM access, based upon the memory controller capabilities. */
EFI_STATUS EFIAPI GetCapabilities(IN CONST EFI_SMM_ACCESS2_PROTOCOL *This, IN OUT UINTN *SmramMapSize, IN OUT EFI_SMRAM_DESCRIPTOR *SmramMap)
|
{
EFI_STATUS Status;
UINTN NecessaryBufferSize;
NecessaryBufferSize = mSmmAccess.NumberRegions * sizeof (EFI_SMRAM_DESCRIPTOR);
if (*SmramMapSize < NecessaryBufferSize) {
Status = EFI_BUFFER_TOO_SMALL;
} else {
CopyMem (SmramMap, mSmmAccess.SmramDesc, NecessaryBufferSize);
Status = EFI_SUCCESS;
}
*SmramMapSize = NecessaryBufferSize;
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Disable a tracepoint and its probe callback. Note: only waiting an RCU period after setting elem->call to the empty function insures that the original callback is not used anymore. This insured by preempt_disable around the call site. */
|
static void disable_tracepoint(struct tracepoint *elem)
|
/* Disable a tracepoint and its probe callback. Note: only waiting an RCU period after setting elem->call to the empty function insures that the original callback is not used anymore. This insured by preempt_disable around the call site. */
static void disable_tracepoint(struct tracepoint *elem)
|
{
if (elem->unregfunc && elem->state)
elem->unregfunc();
elem->state = 0;
rcu_assign_pointer(elem->funcs, NULL);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* initialize the DMA multi data mode parameters struct with the default values */
|
void dma_multi_data_para_struct_init(dma_multi_data_parameter_struct *init_struct)
|
/* initialize the DMA multi data mode parameters struct with the default values */
void dma_multi_data_para_struct_init(dma_multi_data_parameter_struct *init_struct)
|
{
init_struct->periph_addr = 0U;
init_struct->periph_width = 0U;
init_struct->periph_inc = DMA_PERIPH_INCREASE_DISABLE;
init_struct->memory0_addr = 0U;
init_struct->memory_width = 0U;
init_struct->memory_inc = DMA_MEMORY_INCREASE_DISABLE;
init_struct->memory_burst_width = 0U;
init_struct->periph_burst_width = 0U;
init_struct->circular_mode = DMA_CIRCULAR_MODE_DISABLE;
init_struct->direction = DMA_PERIPH_TO_MEMORY;
init_struct->number = 0U;
init_struct->priority = DMA_PRIORITY_LOW;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Register the Service C.1 and all its Characteristics... */
|
void service_c_1_1_init(void)
|
/* Register the Service C.1 and all its Characteristics... */
void service_c_1_1_init(void)
|
{
bt_gatt_service_register(&service_c_1_1_svc);
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* ISR handler for a specific vector index in the interrupt vector table for linking the actual interrupts vectors to the one in the user program's vector table. */
|
void Vector51_handler(void)
|
/* ISR handler for a specific vector index in the interrupt vector table for linking the actual interrupts vectors to the one in the user program's vector table. */
void Vector51_handler(void)
|
{
asm
{
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (51 * 2))
JMP 0,X
}
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* monotonic_to_bootbased - Convert the monotonic time to boot based. @ts: pointer to the timespec to be converted */
|
void monotonic_to_bootbased(struct timespec *ts)
|
/* monotonic_to_bootbased - Convert the monotonic time to boot based. @ts: pointer to the timespec to be converted */
void monotonic_to_bootbased(struct timespec *ts)
|
{
*ts = timespec_add_safe(*ts, total_sleep_time);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* param base asrc base pointer. param handle Pointer to the ASRC_handle_t structure which stores the transfer state. */
|
void ASRC_TransferAbortConvert(ASRC_Type *base, asrc_handle_t *handle)
|
/* param base asrc base pointer. param handle Pointer to the ASRC_handle_t structure which stores the transfer state. */
void ASRC_TransferAbortConvert(ASRC_Type *base, asrc_handle_t *handle)
|
{
assert(handle != NULL);
ASRC_ModuleEnable(base, false);
handle->state = kStatus_ASRCIdle;
handle->in.queueDriver = 0;
handle->in.queueUser = 0;
handle->out.queueDriver = 0;
handle->out.queueUser = 0;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* get a number comprised of multiple GPIO values. gpio_num_array points to the array of gpio pin numbers to scan, terminated by -1. */
|
int gpio_get_values_as_int(const int *gpio_list)
|
/* get a number comprised of multiple GPIO values. gpio_num_array points to the array of gpio pin numbers to scan, terminated by -1. */
int gpio_get_values_as_int(const int *gpio_list)
|
{
int gpio;
unsigned bitmask = 1;
unsigned vector = 0;
int ret;
while (bitmask &&
((gpio = *gpio_list++) != -1)) {
ret = gpio_get_value(gpio);
if (ret < 0)
return ret;
else if (ret)
vector |= bitmask;
bitmask <<= 1;
}
return vector;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* insert/remove a new card. for removal, card == NULL */
|
VReaderStatus vreader_insert_card(VReader *reader, VCard *card)
|
/* insert/remove a new card. for removal, card == NULL */
VReaderStatus vreader_insert_card(VReader *reader, VCard *card)
|
{
vreader_lock(reader);
if (reader->card) {
vcard_free(reader->card);
reader->card = NULL;
}
reader->card = vcard_reference(card);
vreader_unlock(reader);
vreader_queue_card_event(reader);
return VREADER_OK;
}
|
ve3wwg/teensy3_qemu
|
C++
|
Other
| 15
|
/* Enables or disables simultaneously the two DAC channels software triggers. */
|
void DAC_SoftwareTrgEnable(FunctionalState Cmd)
|
/* Enables or disables simultaneously the two DAC channels software triggers. */
void DAC_SoftwareTrgEnable(FunctionalState Cmd)
|
{
assert_param(IS_FUNCTIONAL_STATE(Cmd));
if (Cmd != DISABLE)
{
DAC->SOTTR |= DUAL_SWTRIG_SET;
}
else
{
DAC->SOTTR &= DUAL_SWTRIG_RESET;
}
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* inserts a new key into a hash table; first, check whether key's main position is free. If not, check whether colliding node is in its main position or not: if it is not, move colliding node to an empty place and put new key in its main position; otherwise (colliding node is in its main position), new key goes to an empty position. */
|
static TValue* newkey(lua_State *L, Table *t, const TValue *key)
|
/* inserts a new key into a hash table; first, check whether key's main position is free. If not, check whether colliding node is in its main position or not: if it is not, move colliding node to an empty place and put new key in its main position; otherwise (colliding node is in its main position), new key goes to an empty position. */
static TValue* newkey(lua_State *L, Table *t, const TValue *key)
|
{
Node *othern;
Node *n = getfreepos(t);
if (n == NULL) {
rehash(L, t, key);
return luaH_set(L, t, key);
}
lua_assert(n != dummynode);
othern = mainposition(t, key2tval(mp));
if (othern != mp) {
while (gnext(othern) != mp) othern = gnext(othern);
gnext(othern) = n;
*n = *mp;
gnext(mp) = NULL;
setnilvalue(gval(mp));
}
else {
gnext(n) = gnext(mp);
gnext(mp) = n;
mp = n;
}
}
setobj2t(L, gkey(mp), key);
luaC_barriert(L, t, key);
lua_assert(ttisnil(gval(mp)));
return gval(mp);
}
|
Nicholas3388/LuaNode
|
C++
|
Other
| 1,055
|
/* brief Get peripheral clock dividers. param div_name : Clock divider name return peripheral clock dividers */
|
uint32_t CLOCK_GetClkDiv(clock_div_name_t div_name)
|
/* brief Get peripheral clock dividers. param div_name : Clock divider name return peripheral clock dividers */
uint32_t CLOCK_GetClkDiv(clock_div_name_t div_name)
|
{
uint32_t div;
volatile uint32_t *pClkDiv;
pClkDiv = &(SYSCON->SYSTICKCLKDIV[0]);
if ((uint32_t)(((volatile uint32_t *)pClkDiv)[(uint32_t)div_name] & (0x3UL << 29U)) != 0UL)
{
div = 0U;
}
else
{
div = (uint32_t)((((volatile uint32_t *)pClkDiv)[(uint32_t)div_name] & 0xFFU) + 1U);
}
return div;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Search IP6_DAD_ENTRY from the Duplicate Address Detection List. */
|
IP6_DAD_ENTRY* Ip6FindDADEntry(IN IP6_SERVICE *IpSb, IN EFI_IPv6_ADDRESS *Target, OUT IP6_INTERFACE **Interface OPTIONAL)
|
/* Search IP6_DAD_ENTRY from the Duplicate Address Detection List. */
IP6_DAD_ENTRY* Ip6FindDADEntry(IN IP6_SERVICE *IpSb, IN EFI_IPv6_ADDRESS *Target, OUT IP6_INTERFACE **Interface OPTIONAL)
|
{
LIST_ENTRY *Entry;
LIST_ENTRY *Entry2;
IP6_INTERFACE *IpIf;
IP6_DAD_ENTRY *DupAddrDetect;
IP6_ADDRESS_INFO *AddrInfo;
NET_LIST_FOR_EACH (Entry, &IpSb->Interfaces) {
IpIf = NET_LIST_USER_STRUCT (Entry, IP6_INTERFACE, Link);
NET_LIST_FOR_EACH (Entry2, &IpIf->DupAddrDetectList) {
DupAddrDetect = NET_LIST_USER_STRUCT_S (Entry2, IP6_DAD_ENTRY, Link, IP6_DAD_ENTRY_SIGNATURE);
AddrInfo = DupAddrDetect->AddressInfo;
if (EFI_IP6_EQUAL (&AddrInfo->Address, Target)) {
if (Interface != NULL) {
*Interface = IpIf;
}
return DupAddrDetect;
}
}
}
return NULL;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Get the HTS221 humidity sensor output data rate. */
|
int32_t HTS221_HUM_GetOutputDataRate(HTS221_Object_t *pObj, float *Odr)
|
/* Get the HTS221 humidity sensor output data rate. */
int32_t HTS221_HUM_GetOutputDataRate(HTS221_Object_t *pObj, float *Odr)
|
{
return HTS221_GetOutputDataRate(pObj, Odr);
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Remove and return the first bio from a single linked list defined by its head and tail pointers. */
|
static struct bio* pkt_get_list_first(struct bio **list_head, struct bio **list_tail)
|
/* Remove and return the first bio from a single linked list defined by its head and tail pointers. */
static struct bio* pkt_get_list_first(struct bio **list_head, struct bio **list_tail)
|
{
struct bio *bio;
if (*list_head == NULL)
return NULL;
bio = *list_head;
*list_head = bio->bi_next;
if (*list_head == NULL)
*list_tail = NULL;
bio->bi_next = NULL;
return bio;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Configures the ST25DV GPO.
Needs the I2C Password presentation to be effective. */
|
static int32_t ST25DV_ConfigureGPO(ST25DV_Object_t *pObj, const uint16_t ITConf)
|
/* Configures the ST25DV GPO.
Needs the I2C Password presentation to be effective. */
static int32_t ST25DV_ConfigureGPO(ST25DV_Object_t *pObj, const uint16_t ITConf)
|
{
return st25dv_set_gpo_all( &(pObj->Ctx), (uint8_t *)&ITConf);
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* When AIO DIO IO is completed, the work to convert unwritten extents to written is queued on workqueue but may not get immediately scheduled. When fsync is called, we need to ensure the conversion is complete before fsync returns. The inode keeps track of a list of completed AIO from DIO path that might needs to do the conversion. This function walks through the list and convert the related unwritten extents to written. */
|
int flush_aio_dio_completed_IO(struct inode *inode)
|
/* When AIO DIO IO is completed, the work to convert unwritten extents to written is queued on workqueue but may not get immediately scheduled. When fsync is called, we need to ensure the conversion is complete before fsync returns. The inode keeps track of a list of completed AIO from DIO path that might needs to do the conversion. This function walks through the list and convert the related unwritten extents to written. */
int flush_aio_dio_completed_IO(struct inode *inode)
|
{
ext4_io_end_t *io;
int ret = 0;
int ret2 = 0;
if (list_empty(&EXT4_I(inode)->i_aio_dio_complete_list))
return ret;
dump_aio_dio_list(inode);
while (!list_empty(&EXT4_I(inode)->i_aio_dio_complete_list)){
io = list_entry(EXT4_I(inode)->i_aio_dio_complete_list.next,
ext4_io_end_t, list);
ret = ext4_end_aio_dio_nolock(io);
if (ret < 0)
ret2 = ret;
else
list_del_init(&io->list);
}
return (ret2 < 0) ? ret2 : 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Returns the size of the TXFIFO message needed to send this packet. */
|
static unsigned calc_txlen(unsigned len)
|
/* Returns the size of the TXFIFO message needed to send this packet. */
static unsigned calc_txlen(unsigned len)
|
{
return ALIGN(len + 4, 4);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Resets all configured hardware required for the bootloader back to their original states. */
|
static void ResetHardware(void)
|
/* Resets all configured hardware required for the bootloader back to their original states. */
static void ResetHardware(void)
|
{
USB_Disable();
LEDs_Disable();
TIMSK1 = 0;
TCCR1B = 0;
MCUCR = (1 << IVCE);
MCUCR = 0;
}
|
prusa3d/Prusa-Firmware-Buddy
|
C++
|
Other
| 1,019
|
/* Check Timer Interrupt Flag. This function is used to check whether special flag is set or not. */
|
xtBoolean TimerIntStatusCheck(unsigned long ulBase, unsigned long ulIntFlags)
|
/* Check Timer Interrupt Flag. This function is used to check whether special flag is set or not. */
xtBoolean TimerIntStatusCheck(unsigned long ulBase, unsigned long ulIntFlags)
|
{
xASSERT((ulBase == TIMER0_BASE) || (ulBase == TIMER1_BASE) ||
(ulBase == TIMER2_BASE) || (ulBase == TIMER3_BASE) );
if(xHWREG(ulBase + TIMER_IR) & ulIntFlags)
{
return (xtrue);
}
else
{
return (xfalse);
}
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Clear the slave select pins of the specified SPI port.
The */
|
void SPISSClear(unsigned long ulBase, unsigned long ulSlaveSel)
|
/* Clear the slave select pins of the specified SPI port.
The */
void SPISSClear(unsigned long ulBase, unsigned long ulSlaveSel)
|
{
xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE));
xASSERT((ulSlaveSel == SPI_SS_NONE) || (ulSlaveSel == SPI_SS0));
xHWREG(ulBase + SPI_SSR) &= ~ulSlaveSel;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Gets the index in iface_states for the state corresponding to a provided iface. */
|
static int conn_mgr_get_index_for_if(struct net_if *iface)
|
/* Gets the index in iface_states for the state corresponding to a provided iface. */
static int conn_mgr_get_index_for_if(struct net_if *iface)
|
{
return net_if_get_by_iface(iface) - 1;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). */
|
UINT16 EFIAPI PciExpressRead16(IN UINTN Address)
|
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). */
UINT16 EFIAPI PciExpressRead16(IN UINTN Address)
|
{
if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {
return (UINT16)-1;
}
return MmioRead16 (GetPciExpressAddress (Address));
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Clear the DMA interrupt flag of a channel. */
|
void DMAChannelIntFlagClear(unsigned long ulChannelID, unsigned long ulIntFlags)
|
/* Clear the DMA interrupt flag of a channel. */
void DMAChannelIntFlagClear(unsigned long ulChannelID, unsigned long ulIntFlags)
|
{
xASSERT(xDMAChannelIDValid(ulChannelID));
xASSERT(((ulIntFlags & DMA_INT_TG) == DMA_INT_TG) ||
((ulIntFlags & DMA_INT_TC) == DMA_INT_TC) ||
((ulIntFlags & DMA_INT_HT) == DMA_INT_HT) ||
((ulIntFlags & DMA_INT_ERROR) == DMA_INT_ERROR));
if((ulChannelID) < 7)
{
ulIntFlags = ulIntFlags << (ulChannelID * 4);
xHWREG(DMA1_BASE + DMA_IFCR) |= ulIntFlags;
}
else
{
ulIntFlags = ulIntFlags << ((ulChannelID-1024) * 4);
xHWREG(DMA1_BASE + DMA_IFCR) |= ulIntFlags;
}
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* If appropriate, check DAC only. If not appropriate, or short-cut DAC fails, then call ->permission() to do more complete permission check. */
|
static int exec_permission(struct inode *inode)
|
/* If appropriate, check DAC only. If not appropriate, or short-cut DAC fails, then call ->permission() to do more complete permission check. */
static int exec_permission(struct inode *inode)
|
{
int ret;
if (inode->i_op->permission) {
ret = inode->i_op->permission(inode, MAY_EXEC);
if (!ret)
goto ok;
return ret;
}
ret = acl_permission_check(inode, MAY_EXEC, inode->i_op->check_acl);
if (!ret)
goto ok;
if (capable(CAP_DAC_OVERRIDE) || capable(CAP_DAC_READ_SEARCH))
goto ok;
return ret;
ok:
return security_inode_permission(inode, MAY_EXEC);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* function : wb_ebios_get_reg_base(u32 sel) description : get write-back controller register base parameters : sel <controller select> return : registers base */
|
uintptr_t wb_ebios_get_reg_base(u32 sel)
|
/* function : wb_ebios_get_reg_base(u32 sel) description : get write-back controller register base parameters : sel <controller select> return : registers base */
uintptr_t wb_ebios_get_reg_base(u32 sel)
|
{
uintptr_t ret = 0;
ret = (uintptr_t) wb_dev[sel];
return ret;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Enable The Timer counter as a timer capture. */
|
void TimerCaptureEnable(unsigned long ulBase)
|
/* Enable The Timer counter as a timer capture. */
void TimerCaptureEnable(unsigned long ulBase)
|
{
xASSERT((ulBase == TIMER3_BASE) || (ulBase == TIMER2_BASE) ||
(ulBase == TIMER1_BASE) || (ulBase == TIMER0_BASE));
xHWREG(ulBase + TIMER_TEXCON) |= TIMER_TEXCON_TEXEN;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* This is a stub for the status callback. The stub is here in case the upper layers do not set the handler. */
|
void StubHandler(void *CallBackRef, u32 Bank, u32 Status)
|
/* This is a stub for the status callback. The stub is here in case the upper layers do not set the handler. */
void StubHandler(void *CallBackRef, u32 Bank, u32 Status)
|
{
(void) CallBackRef;
(void) Bank;
(void) Status;
Xil_AssertVoidAlways();
}
/** @}
|
ua1arn/hftrx
|
C++
| null | 69
|
/* Return the pointer to register settings of specific ADC. */
|
static uint8_t _adc_get_regs(const uint32_t hw_addr)
|
/* Return the pointer to register settings of specific ADC. */
static uint8_t _adc_get_regs(const uint32_t hw_addr)
|
{
uint8_t n = _adc_get_hardware_index((const void *)hw_addr);
uint8_t i;
for (i = 0; i < sizeof(_adcs) / sizeof(struct adc_configuration); i++) {
if (_adcs[i].number == n) {
return i;
}
}
ASSERT(false);
return 0;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* enable/disable the glitch filter. mostly used with IRQ handling. */
|
int at91_set_pio_deglitch(unsigned port, unsigned pin, int is_on)
|
/* enable/disable the glitch filter. mostly used with IRQ handling. */
int at91_set_pio_deglitch(unsigned port, unsigned pin, int is_on)
|
{
struct at91_port *at91_port = at91_pio_get_port(port);
u32 mask;
if (at91_port && (pin < GPIO_PER_BANK)) {
mask = 1 << pin;
if (is_on)
writel(mask, &at91_port->ifer);
else
writel(mask, &at91_port->ifdr);
}
return 0;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Registers an interrupt handler for the flash interrupt. */
|
void FlashLibIntRegister(void(*pfnHandler)(void))
|
/* Registers an interrupt handler for the flash interrupt. */
void FlashLibIntRegister(void(*pfnHandler)(void))
|
{
IntRegister(INT_FLASH_BLIZZARD, pfnHandler);
IntEnable(INT_FLASH_BLIZZARD);
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* Description: This function prepares a bio for attaching integrity metadata. nr_vecs specifies the maximum number of pages containing integrity metadata that can be attached. */
|
struct bio_integrity_payload* bio_integrity_alloc(struct bio *bio, gfp_t gfp_mask, unsigned int nr_vecs)
|
/* Description: This function prepares a bio for attaching integrity metadata. nr_vecs specifies the maximum number of pages containing integrity metadata that can be attached. */
struct bio_integrity_payload* bio_integrity_alloc(struct bio *bio, gfp_t gfp_mask, unsigned int nr_vecs)
|
{
return bio_integrity_alloc_bioset(bio, gfp_mask, nr_vecs, fs_bio_set);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function traverses the whole HOB list and update the stack HOB to reflect the real stack that is used by DXE core. */
|
VOID UpdateStackHob(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length)
|
/* This function traverses the whole HOB list and update the stack HOB to reflect the real stack that is used by DXE core. */
VOID UpdateStackHob(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length)
|
{
EFI_PEI_HOB_POINTERS Hob;
Hob.Raw = GetHobList ();
while ((Hob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, Hob.Raw)) != NULL) {
if (CompareGuid (&gEfiHobMemoryAllocStackGuid, &(Hob.MemoryAllocationStack->AllocDescriptor.Name))) {
BuildMemoryAllocationHob (
Hob.MemoryAllocationStack->AllocDescriptor.MemoryBaseAddress,
Hob.MemoryAllocationStack->AllocDescriptor.MemoryLength,
EfiBootServicesData
);
Hob.MemoryAllocationStack->AllocDescriptor.MemoryBaseAddress = BaseAddress;
Hob.MemoryAllocationStack->AllocDescriptor.MemoryLength = Length;
break;
}
Hob.Raw = GET_NEXT_HOB (Hob);
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* PLIC will mask all interrupts of a priority less than or equal to threshold. Maximum threshold is 7. For example, a threshold value of zero permits all interrupts with non-zero priority, whereas a value of 7 masks all interrupts. Notice, the threshold is global for PLIC, not for each interrupt source. */
|
void plic_set_threshold(int threshold)
|
/* PLIC will mask all interrupts of a priority less than or equal to threshold. Maximum threshold is 7. For example, a threshold value of zero permits all interrupts with non-zero priority, whereas a value of 7 masks all interrupts. Notice, the threshold is global for PLIC, not for each interrupt source. */
void plic_set_threshold(int threshold)
|
{
int hart = __raw_hartid();
*(uint32_t *)PLIC_THRESHOLD(hart) = threshold;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Calculate the next alarm time given the requested alarm time mask and the current time. */
|
static void rtc_next_alarm_time(struct rtc_time *next, struct rtc_time *now, struct rtc_time *alrm)
|
/* Calculate the next alarm time given the requested alarm time mask and the current time. */
static void rtc_next_alarm_time(struct rtc_time *next, struct rtc_time *now, struct rtc_time *alrm)
|
{
unsigned long next_time;
unsigned long now_time;
next->tm_year = now->tm_year;
next->tm_mon = now->tm_mon;
next->tm_mday = now->tm_mday;
next->tm_hour = alrm->tm_hour;
next->tm_min = alrm->tm_min;
next->tm_sec = alrm->tm_sec;
rtc_tm_to_time(now, &now_time);
rtc_tm_to_time(next, &next_time);
if (next_time < now_time) {
next_time += 60 * 60 * 24;
rtc_time_to_tm(next_time, next);
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* no valid lookup procedure on this sort of dir */
|
static struct dentry * afs_mntpt_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
|
/* no valid lookup procedure on this sort of dir */
static struct dentry * afs_mntpt_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
|
{
_enter("%p,%p{%p{%s},%s}",
dir,
dentry,
dentry->d_parent,
dentry->d_parent ?
dentry->d_parent->d_name.name : (const unsigned char *) "",
dentry->d_name.name);
return ERR_PTR(-EREMOTE);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function gets the file information from an open file descriptor, and stores it in a buffer allocated from pool. */
|
EFI_FILE_INFO* FileInfo(IN EFI_FILE_HANDLE FHand)
|
/* This function gets the file information from an open file descriptor, and stores it in a buffer allocated from pool. */
EFI_FILE_INFO* FileInfo(IN EFI_FILE_HANDLE FHand)
|
{
EFI_STATUS Status;
EFI_FILE_INFO *Buffer;
UINTN BufferSize;
Buffer = NULL;
BufferSize = SIZE_OF_EFI_FILE_INFO + 200;
while (GrowBuffer (&Status, (VOID **)&Buffer, BufferSize)) {
Status = FHand->GetInfo (
FHand,
&gEfiFileInfoGuid,
&BufferSize,
Buffer
);
}
return Buffer;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* ethoc_remove() - shutdown OpenCores ethernet MAC @pdev: platform device */
|
static int ethoc_remove(struct platform_device *pdev)
|
/* ethoc_remove() - shutdown OpenCores ethernet MAC @pdev: platform device */
static int ethoc_remove(struct platform_device *pdev)
|
{
struct net_device *netdev = platform_get_drvdata(pdev);
struct ethoc *priv = netdev_priv(netdev);
platform_set_drvdata(pdev, NULL);
if (netdev) {
phy_disconnect(priv->phy);
priv->phy = NULL;
if (priv->mdio) {
mdiobus_unregister(priv->mdio);
kfree(priv->mdio->irq);
mdiobus_free(priv->mdio);
}
if (priv->dma_alloc)
dma_free_coherent(NULL, priv->dma_alloc, priv->membase,
netdev->mem_start);
unregister_netdev(netdev);
free_netdev(netdev);
}
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Clean up process after a packet is received. */
|
void EMAC_RecvPktDoneWoRxTrigger(EMAC_MEMMGR_T *psMemMgr)
|
/* Clean up process after a packet is received. */
void EMAC_RecvPktDoneWoRxTrigger(EMAC_MEMMGR_T *psMemMgr)
|
{
EMAC_DESCRIPTOR_T *desc = (EMAC_DESCRIPTOR_T *)psMemMgr->psCurrentRxDesc;
desc->u32Data = desc->u32Backup1;
desc->u32Next = desc->u32Backup2;
desc->u32Status1 |= EMAC_DESC_OWN_EMAC;
desc = (EMAC_DESCRIPTOR_T *)desc->u32Next;
psMemMgr->psCurrentRxDesc = desc;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* The attach() and detach() entry points are used to create and destroy "instances" of the driver, where each instance represents everything needed to manage one actual PCMCIA card. */
|
static int das08_pcmcia_attach(struct pcmcia_device *)
|
/* The attach() and detach() entry points are used to create and destroy "instances" of the driver, where each instance represents everything needed to manage one actual PCMCIA card. */
static int das08_pcmcia_attach(struct pcmcia_device *)
|
{
struct local_info_t *local;
dev_dbg(&link->dev, "das08_pcmcia_attach()\n");
local = kzalloc(sizeof(struct local_info_t), GFP_KERNEL);
if (!local)
return -ENOMEM;
local->link = link;
link->priv = local;
link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
link->irq.Handler = NULL;
link->conf.Attributes = 0;
link->conf.IntType = INT_MEMORY_AND_IO;
cur_dev = link;
das08_pcmcia_config(link);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* check the I/O compensation cell is ready or not */
|
FlagStatus gpio_compensation_flag_get(void)
|
/* check the I/O compensation cell is ready or not */
FlagStatus gpio_compensation_flag_get(void)
|
{
if(((uint32_t)RESET) != (AFIO_CPSCTL & AFIO_CPSCTL_CPS_RDY)){
return SET;
}else{
return RESET;
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* @client: i2c device. @reg: the register to read from. @buf: raw write data buffer. @len: length of the buffer to write */
|
static int goodix_i2c_read(struct i2c_client *client, u16 reg, u8 *buf, int len)
|
/* @client: i2c device. @reg: the register to read from. @buf: raw write data buffer. @len: length of the buffer to write */
static int goodix_i2c_read(struct i2c_client *client, u16 reg, u8 *buf, int len)
|
{
struct i2c_msg msgs[2];
u16 wbuf = cpu_to_be16(reg);
int ret;
msgs[0].flags = 0;
msgs[0].addr = client->addr;
msgs[0].len = 2;
msgs[0].buf = (u8 *)&wbuf;
msgs[1].flags = I2C_M_RD;
msgs[1].addr = client->addr;
msgs[1].len = len;
msgs[1].buf = buf;
ret = i2c_transfer(client->adapter, msgs, 2);
return ret < 0 ? ret : (ret != ARRAY_SIZE(msgs) ? -EIO : 0);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* given a group and inode, find the mark associated with that combination. if found take a reference to that mark and return it, else return NULL */
|
struct fsnotify_mark_entry* fsnotify_find_mark_entry(struct fsnotify_group *group, struct inode *inode)
|
/* given a group and inode, find the mark associated with that combination. if found take a reference to that mark and return it, else return NULL */
struct fsnotify_mark_entry* fsnotify_find_mark_entry(struct fsnotify_group *group, struct inode *inode)
|
{
struct fsnotify_mark_entry *entry;
struct hlist_node *pos;
assert_spin_locked(&inode->i_lock);
hlist_for_each_entry(entry, pos, &inode->i_fsnotify_mark_entries, i_list) {
if (entry->group == group) {
fsnotify_get_mark(entry);
return entry;
}
}
return NULL;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Configures the PLLSAI clock multiplication and division factors. */
|
void RCC_PLLSAIConfig(uint32_t PLLSAIN, uint32_t PLLSAIQ, uint32_t PLLSAIR)
|
/* Configures the PLLSAI clock multiplication and division factors. */
void RCC_PLLSAIConfig(uint32_t PLLSAIN, uint32_t PLLSAIQ, uint32_t PLLSAIR)
|
{
assert_param(IS_RCC_PLLSAIN_VALUE(PLLSAIN));
assert_param(IS_RCC_PLLSAIR_VALUE(PLLSAIR));
RCC->PLLSAICFGR = (PLLSAIN << 6) | (PLLSAIQ << 24) | (PLLSAIR << 28);
}
|
MaJerle/stm32f429
|
C++
| null | 2,036
|
/* Locate a certain GUID protocol interface in a Handle's protocols. */
|
PROTOCOL_INTERFACE* SmmGetProtocolInterface(IN EFI_HANDLE UserHandle, IN EFI_GUID *Protocol)
|
/* Locate a certain GUID protocol interface in a Handle's protocols. */
PROTOCOL_INTERFACE* SmmGetProtocolInterface(IN EFI_HANDLE UserHandle, IN EFI_GUID *Protocol)
|
{
EFI_STATUS Status;
PROTOCOL_ENTRY *ProtEntry;
PROTOCOL_INTERFACE *Prot;
IHANDLE *Handle;
LIST_ENTRY *Link;
Status = SmmValidateHandle (UserHandle);
if (EFI_ERROR (Status)) {
return NULL;
}
Handle = (IHANDLE *)UserHandle;
for (Link = Handle->Protocols.ForwardLink; Link != &Handle->Protocols; Link = Link->ForwardLink) {
Prot = CR (Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
ProtEntry = Prot->Protocol;
if (CompareGuid (&ProtEntry->ProtocolID, Protocol)) {
return Prot;
}
}
return NULL;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* ADC Software Triggered Conversion on Injected Channels.
This starts conversion on a set of defined injected channels. Depending on the configuration bits JEXTEN, a conversion will start immediately (software trigger configuration) or once an injected hardware trigger event occurs (hardware trigger configuration). */
|
void adc_start_conversion_injected(uint32_t adc)
|
/* ADC Software Triggered Conversion on Injected Channels.
This starts conversion on a set of defined injected channels. Depending on the configuration bits JEXTEN, a conversion will start immediately (software trigger configuration) or once an injected hardware trigger event occurs (hardware trigger configuration). */
void adc_start_conversion_injected(uint32_t adc)
|
{
ADC_CR(adc) |= ADC_CR_JADSTART;
}
|
libopencm3/libopencm3
|
C++
|
GNU General Public License v3.0
| 2,931
|
/* Setup the w100 clocks for the specified mode */
|
static void w100_init_clocks(struct w100fb_par *)
|
/* Setup the w100 clocks for the specified mode */
static void w100_init_clocks(struct w100fb_par *)
|
{
struct w100_mode *mode = par->mode;
if (mode->pixclk_src == CLK_SRC_PLL || mode->sysclk_src == CLK_SRC_PLL)
w100_set_pll_freq(par, (par->fastpll_mode && mode->fast_pll_freq) ? mode->fast_pll_freq : mode->pll_freq);
w100_pwr_state.sclk_cntl.f.sclk_src_sel = mode->sysclk_src;
w100_pwr_state.sclk_cntl.f.sclk_post_div_fast = mode->sysclk_divider;
w100_pwr_state.sclk_cntl.f.sclk_post_div_slow = mode->sysclk_divider;
writel((u32) (w100_pwr_state.sclk_cntl.val), remapped_regs + mmSCLK_CNTL);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Read two bytes from the IFC hardware buffer read function for 16-bit buswith */
|
static uint8_t fsl_ifc_read_byte16(struct mtd_info *mtd)
|
/* Read two bytes from the IFC hardware buffer read function for 16-bit buswith */
static uint8_t fsl_ifc_read_byte16(struct mtd_info *mtd)
|
{
struct nand_chip *chip = mtd_to_nand(mtd);
struct fsl_ifc_mtd *priv = nand_get_controller_data(chip);
struct fsl_ifc_ctrl *ctrl = priv->ctrl;
uint16_t data;
if (ctrl->index < ctrl->read_bytes) {
data = ifc_in16(ctrl->addr + ctrl->index);
ctrl->index += 2;
return (uint8_t)data;
}
printf("%s beyond end of buffer\n", __func__);
return ERR_BYTE;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* This should be sufficient to wait for GPU idle without having to worry about starvation. */
|
void drm_idlelock_take(struct drm_lock_data *lock_data)
|
/* This should be sufficient to wait for GPU idle without having to worry about starvation. */
void drm_idlelock_take(struct drm_lock_data *lock_data)
|
{
int ret = 0;
spin_lock_bh(&lock_data->spinlock);
lock_data->kernel_waiters++;
if (!lock_data->idle_has_lock) {
spin_unlock_bh(&lock_data->spinlock);
ret = drm_lock_take(lock_data, DRM_KERNEL_CONTEXT);
spin_lock_bh(&lock_data->spinlock);
if (ret == 1)
lock_data->idle_has_lock = 1;
}
spin_unlock_bh(&lock_data->spinlock);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Change notifications will be emitted for affected keys. */
|
void g_settings_revert(GSettings *settings)
|
/* Change notifications will be emitted for affected keys. */
void g_settings_revert(GSettings *settings)
|
{
if (settings->priv->delayed)
{
GDelayedSettingsBackend *delayed;
delayed = G_DELAYED_SETTINGS_BACKEND (settings->priv->backend);
g_delayed_settings_backend_revert (delayed);
}
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Create a new line and append it to the line list. Fields affected: NumLines Lines */
|
EFI_EDITOR_LINE* FileBufferCreateLine(VOID)
|
/* Create a new line and append it to the line list. Fields affected: NumLines Lines */
EFI_EDITOR_LINE* FileBufferCreateLine(VOID)
|
{
EFI_EDITOR_LINE *Line;
Line = AllocateZeroPool (sizeof (EFI_EDITOR_LINE));
if (Line == NULL) {
return NULL;
}
Line->Signature = LINE_LIST_SIGNATURE;
Line->Size = 0;
Line->TotalSize = 0;
Line->Type = NewLineTypeDefault;
ASSERT (CHAR_NULL == CHAR_NULL);
Line->Buffer = CatSPrint (NULL, L"\0");
if (Line->Buffer == NULL) {
return NULL;
}
FileBuffer.NumLines++;
InsertTailList (FileBuffer.ListHead, &Line->Link);
if (FileBuffer.Lines == NULL) {
FileBuffer.Lines = CR (FileBuffer.ListHead->ForwardLink, EFI_EDITOR_LINE, Link, LINE_LIST_SIGNATURE);
}
return Line;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* There are a number of constraints that must be followed before calling this function: 1) Interrupts must be disabled. 2) The caller must be in 32-bit paged mode. 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode. 4) CR3 must point to valid page tables that guarantee that the pages for this function and the stack are identity mapped. */
|
VOID EFIAPI AsmDisablePaging32(IN SWITCH_STACK_ENTRY_POINT EntryPoint, IN VOID *Context1 OPTIONAL, IN VOID *Context2 OPTIONAL, IN VOID *NewStack)
|
/* There are a number of constraints that must be followed before calling this function: 1) Interrupts must be disabled. 2) The caller must be in 32-bit paged mode. 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode. 4) CR3 must point to valid page tables that guarantee that the pages for this function and the stack are identity mapped. */
VOID EFIAPI AsmDisablePaging32(IN SWITCH_STACK_ENTRY_POINT EntryPoint, IN VOID *Context1 OPTIONAL, IN VOID *Context2 OPTIONAL, IN VOID *NewStack)
|
{
ASSERT (EntryPoint != NULL);
ASSERT (NewStack != NULL);
InternalX86DisablePaging32 (EntryPoint, Context1, Context2, NewStack);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* f l i p F i x e d */
|
returnValue Constraints_flipFixed(Constraints *_THIS, int number)
|
/* f l i p F i x e d */
returnValue Constraints_flipFixed(Constraints *_THIS, int number)
|
{
if ( ( number < 0 ) || ( number >= _THIS->n ) )
return THROWERROR( RET_INDEX_OUT_OF_BOUNDS );
if ( _THIS->status != 0 )
switch (_THIS->status[number])
{
case ST_LOWER: _THIS->status[number] = ST_UPPER; break;
case ST_UPPER: _THIS->status[number] = ST_LOWER; break;
default: return THROWERROR( RET_MOVING_CONSTRAINT_FAILED );
}
return SUCCESSFUL_RETURN;
}
|
DanielMartensson/EmbeddedLapack
|
C++
|
MIT License
| 129
|
/* Extend the transaction by enough credits to complete the rotation, and still leave at least the original number of credits allocated to this transaction. */
|
static int ocfs2_extend_rotate_transaction(handle_t *handle, int subtree_depth, int op_credits, struct ocfs2_path *path)
|
/* Extend the transaction by enough credits to complete the rotation, and still leave at least the original number of credits allocated to this transaction. */
static int ocfs2_extend_rotate_transaction(handle_t *handle, int subtree_depth, int op_credits, struct ocfs2_path *path)
|
{
int ret;
int credits = (path->p_tree_depth - subtree_depth) * 2 + 1 + op_credits;
if (handle->h_buffer_credits < credits) {
ret = ocfs2_extend_trans(handle,
credits - handle->h_buffer_credits);
if (ret)
return ret;
if (unlikely(handle->h_buffer_credits < credits))
return ocfs2_extend_trans(handle, credits);
}
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* blk_queue_segment_boundary - set boundary rules for segment merging @q: the request queue for the device @mask: the memory boundary mask */
|
void blk_queue_segment_boundary(struct request_queue *q, unsigned long mask)
|
/* blk_queue_segment_boundary - set boundary rules for segment merging @q: the request queue for the device @mask: the memory boundary mask */
void blk_queue_segment_boundary(struct request_queue *q, unsigned long mask)
|
{
if (mask < PAGE_CACHE_SIZE - 1) {
mask = PAGE_CACHE_SIZE - 1;
printk(KERN_INFO "%s: set to minimum %lx\n",
__func__, mask);
}
q->limits.seg_boundary_mask = mask;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* XXX - should this include the user preference as well? */
|
void set_window_title(GtkWidget *win, const gchar *caption)
|
/* XXX - should this include the user preference as well? */
void set_window_title(GtkWidget *win, const gchar *caption)
|
{
char *title;
char *display_name;
display_name = cf_get_display_name(&cfile);
title = g_strdup_printf("%s: %s", caption, display_name);
g_free(display_name);
gtk_window_set_title(GTK_WINDOW(win), title);
g_free(title);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Forces or releases High Speed APB (APB2) peripheral reset. */
|
void RCC_APB2PeriphResetCmd(uint32_t RCC_APB2Periph, FunctionalState NewState)
|
/* Forces or releases High Speed APB (APB2) peripheral reset. */
void RCC_APB2PeriphResetCmd(uint32_t RCC_APB2Periph, FunctionalState NewState)
|
{
assert_param(IS_RCC_APB2_RESET_PERIPH(RCC_APB2Periph));
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
RCC->APB2RSTR |= RCC_APB2Periph;
}
else
{
RCC->APB2RSTR &= ~RCC_APB2Periph;
}
}
|
MaJerle/stm32f429
|
C++
| null | 2,036
|
/* Process one block through 16 successive rounds, omitting the swap in the final round. */
|
static void process_block_unit(uint32_t *pl, uint32_t *pr, const uint32_t *sk_exp)
|
/* Process one block through 16 successive rounds, omitting the swap in the final round. */
static void process_block_unit(uint32_t *pl, uint32_t *pr, const uint32_t *sk_exp)
|
{
int i;
uint32_t l, r;
l = *pl;
r = *pr;
for (i = 0; i < 16; i ++) {
uint32_t t;
t = l ^ Fconf(r, sk_exp);
l = r;
r = t;
sk_exp += 6;
}
*pl = r;
*pr = l;
}
|
RavenSystem/esp-homekit-devices
|
C++
|
Other
| 2,577
|
/* ISR handler for a specific vector index in the interrupt vector table for linking the actual interrupts vectors to the one in the user program's vector table. */
|
void Vector11_handler(void)
|
/* ISR handler for a specific vector index in the interrupt vector table for linking the actual interrupts vectors to the one in the user program's vector table. */
void Vector11_handler(void)
|
{
asm
{
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (11 * 2))
JMP 0,X
}
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* In a single threaded sys_arch implementation, this function will simply return a pointer to a global sys_timeouts variable stored in the sys_arch module. */
|
struct sys_timeouts* sys_arch_timeouts(void)
|
/* In a single threaded sys_arch implementation, this function will simply return a pointer to a global sys_timeouts variable stored in the sys_arch module. */
struct sys_timeouts* sys_arch_timeouts(void)
|
{
int i;
xTaskHandle pid;
struct timeoutlist *tl;
pid = xTaskGetCurrentTaskHandle( );
for(i = 0; i < nextthread; i++)
{
tl = &timeoutlist[i];
if(tl->pid == pid)
{
return &(tl->timeouts);
}
}
return NULL;
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* Converts a text device path node to Fibre device path structure. */
|
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextFibre(IN CHAR16 *TextDeviceNode)
|
/* Converts a text device path node to Fibre device path structure. */
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextFibre(IN CHAR16 *TextDeviceNode)
|
{
CHAR16 *WWNStr;
CHAR16 *LunStr;
FIBRECHANNEL_DEVICE_PATH *Fibre;
WWNStr = GetNextParamStr (&TextDeviceNode);
LunStr = GetNextParamStr (&TextDeviceNode);
Fibre = (FIBRECHANNEL_DEVICE_PATH *)CreateDeviceNode (
MESSAGING_DEVICE_PATH,
MSG_FIBRECHANNEL_DP,
(UINT16)sizeof (FIBRECHANNEL_DEVICE_PATH)
);
Fibre->Reserved = 0;
Strtoi64 (WWNStr, &Fibre->WWN);
Strtoi64 (LunStr, &Fibre->Lun);
return (EFI_DEVICE_PATH_PROTOCOL *)Fibre;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* USB Device Resume Function Called automatically on USB Device Resume Return Value: None */
|
void USBD_Resume(void)
|
/* USB Device Resume Function Called automatically on USB Device Resume Return Value: None */
void USBD_Resume(void)
|
{
USB0->INTEN &= ~USB_INTEN_RESUMEEN_MASK;
}
|
ARMmbed/DAPLink
|
C++
|
Apache License 2.0
| 2,140
|
/* Function for changing the swap sub state and dispatching state entry action. */
|
static void swap_sub_state_state_change(flash_swap_sub_state_t new_state)
|
/* Function for changing the swap sub state and dispatching state entry action. */
static void swap_sub_state_state_change(flash_swap_sub_state_t new_state)
|
{
m_swap_sub_state = new_state;
swap_sub_state_entry_action_run();
}
|
labapart/polymcu
|
C++
| null | 201
|
/* Cleanup TM command and associated IOs as part of ITNIM offline. */
|
void bfa_tskim_cleanup(struct bfa_tskim_s *tskim)
|
/* Cleanup TM command and associated IOs as part of ITNIM offline. */
void bfa_tskim_cleanup(struct bfa_tskim_s *tskim)
|
{
tskim->notify = BFA_TRUE;
bfa_stats(tskim->itnim, tm_cleanups);
bfa_sm_send_event(tskim, BFA_TSKIM_SM_CLEANUP);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* If the On parameter evaluates to TRUE, this function enables memory reads in the address range Start to (Start + Length - 1). If the On parameter evaluates to FALSE, this function disables memory reads in the address range Start to (Start + Length - 1). */
|
EFI_STATUS EFIAPI LegacyRegion2Decode(IN EFI_LEGACY_REGION2_PROTOCOL *This, IN UINT32 Start, IN UINT32 Length, OUT UINT32 *Granularity, IN BOOLEAN *On)
|
/* If the On parameter evaluates to TRUE, this function enables memory reads in the address range Start to (Start + Length - 1). If the On parameter evaluates to FALSE, this function disables memory reads in the address range Start to (Start + Length - 1). */
EFI_STATUS EFIAPI LegacyRegion2Decode(IN EFI_LEGACY_REGION2_PROTOCOL *This, IN UINT32 Start, IN UINT32 Length, OUT UINT32 *Granularity, IN BOOLEAN *On)
|
{
if ((Start < 0xC0000) || ((Start + Length - 1) > 0xFFFFF)) {
return EFI_INVALID_PARAMETER;
}
ASSERT (Granularity != NULL);
*Granularity = 0;
return EFI_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Setup initial wakeup sources on SoC.
Setup the SoC wakeup sources. */
|
static ALWAYS_INLINE void wakeup_src_init(void)
|
/* Setup initial wakeup sources on SoC.
Setup the SoC wakeup sources. */
static ALWAYS_INLINE void wakeup_src_init(void)
|
{
__BEETLE_SYSCON->pwrdncfg1set = APB_CLK_BITS;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* If Expression is FALSE, then TRUE is returned. If Expression is TRUE, then an assert is triggered and the location of the assert provided by FunctionName, LineNumber, FileName, and Description are recorded and FALSE is returned. */
|
BOOLEAN EFIAPI UnitTestAssertFalse(IN BOOLEAN Expression, IN CONST CHAR8 *FunctionName, IN UINTN LineNumber, IN CONST CHAR8 *FileName, IN CONST CHAR8 *Description)
|
/* If Expression is FALSE, then TRUE is returned. If Expression is TRUE, then an assert is triggered and the location of the assert provided by FunctionName, LineNumber, FileName, and Description are recorded and FALSE is returned. */
BOOLEAN EFIAPI UnitTestAssertFalse(IN BOOLEAN Expression, IN CONST CHAR8 *FunctionName, IN UINTN LineNumber, IN CONST CHAR8 *FileName, IN CONST CHAR8 *Description)
|
{
CHAR8 TempStr[MAX_STRING_SIZE];
snprintf (TempStr, sizeof (TempStr), "UT_ASSERT_FALSE(%s:%x)", Description, Expression);
_assert_true (!Expression, TempStr, FileName, (INT32)LineNumber);
return !Expression;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* CAN initialization function.
Enables CAN peripheral, clocks and initializes CAN driver */
|
void CAN_0_init(void)
|
/* CAN initialization function.
Enables CAN peripheral, clocks and initializes CAN driver */
void CAN_0_init(void)
|
{
hri_mclk_set_AHBMASK_CAN0_bit(MCLK);
hri_gclk_write_PCHCTRL_reg(GCLK, CAN0_GCLK_ID, CONF_GCLK_CAN0_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
can_async_init(&CAN_0, CAN0);
CAN_0_PORT_init();
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* 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};
if(huart->Instance==USART1)
{
__HAL_RCC_USART1_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Resets a network adapter and leaves it in a state that is safe for another driver to initialize. */
|
EFI_STATUS EFIAPI EmuSnpShutdown(IN EFI_SIMPLE_NETWORK_PROTOCOL *This)
|
/* Resets a network adapter and leaves it in a state that is safe for another driver to initialize. */
EFI_STATUS EFIAPI EmuSnpShutdown(IN EFI_SIMPLE_NETWORK_PROTOCOL *This)
|
{
EFI_STATUS Status;
EMU_SNP_PRIVATE_DATA *Private;
Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (This);
Status = Private->Io->Shutdown (Private->Io);
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Check whether two locks have the same owner. */
|
static int posix_same_owner(struct file_lock *fl1, struct file_lock *fl2)
|
/* Check whether two locks have the same owner. */
static int posix_same_owner(struct file_lock *fl1, struct file_lock *fl2)
|
{
if (fl1->fl_lmops && fl1->fl_lmops->fl_compare_owner)
return fl2->fl_lmops == fl1->fl_lmops &&
fl1->fl_lmops->fl_compare_owner(fl1, fl2);
return fl1->fl_owner == fl2->fl_owner;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Program interrupt controller.
The Galileo board virtualizes IRQs as follows: */
|
__boot_func void z_irq_controller_irq_config(unsigned int vector, unsigned int irq, uint32_t flags)
|
/* Program interrupt controller.
The Galileo board virtualizes IRQs as follows: */
__boot_func void z_irq_controller_irq_config(unsigned int vector, unsigned int irq, uint32_t flags)
|
{
__ASSERT(irq <= HARDWARE_IRQ_LIMIT, "invalid irq line");
if (IS_IOAPIC_IRQ(irq)) {
z_ioapic_irq_set(irq, vector, flags);
} else {
z_loapic_int_vec_set(irq - z_loapic_irq_base(), vector);
}
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Cleanup after an error on one of the addbufs() functions. */
|
static void drm_cleanup_buf_error(struct drm_device *dev, struct drm_buf_entry *entry)
|
/* Cleanup after an error on one of the addbufs() functions. */
static void drm_cleanup_buf_error(struct drm_device *dev, struct drm_buf_entry *entry)
|
{
int i;
if (entry->seg_count) {
for (i = 0; i < entry->seg_count; i++) {
if (entry->seglist[i]) {
drm_pci_free(dev, entry->seglist[i]);
}
}
kfree(entry->seglist);
entry->seg_count = 0;
}
if (entry->buf_count) {
for (i = 0; i < entry->buf_count; i++) {
kfree(entry->buflist[i].dev_private);
}
kfree(entry->buflist);
entry->buf_count = 0;
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* 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(&Mouse_HID_Interface);
USB_Device_EnableSOFEvents();
LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR);
}
|
prusa3d/Prusa-Firmware-Buddy
|
C++
|
Other
| 1,019
|
/* Writes the command to the IOMMUs command buffer and informs the hardware about the new command. Must be called with iommu->lock held. */
|
static int __iommu_queue_command(struct amd_iommu *iommu, struct iommu_cmd *cmd)
|
/* Writes the command to the IOMMUs command buffer and informs the hardware about the new command. Must be called with iommu->lock held. */
static int __iommu_queue_command(struct amd_iommu *iommu, struct iommu_cmd *cmd)
|
{
u32 tail, head;
u8 *target;
tail = readl(iommu->mmio_base + MMIO_CMD_TAIL_OFFSET);
target = iommu->cmd_buf + tail;
memcpy_toio(target, cmd, sizeof(*cmd));
tail = (tail + sizeof(*cmd)) % iommu->cmd_buf_size;
head = readl(iommu->mmio_base + MMIO_CMD_HEAD_OFFSET);
if (tail == head)
return -ENOMEM;
writel(tail, iommu->mmio_base + MMIO_CMD_TAIL_OFFSET);
return 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Description: Reads the ID registers of the PHY at @addr on the @bus, stores it in @phy_id and returns zero on success. */
|
int __weak get_phy_id(struct mii_dev *bus, int addr, int devad, u32 *phy_id)
|
/* Description: Reads the ID registers of the PHY at @addr on the @bus, stores it in @phy_id and returns zero on success. */
int __weak get_phy_id(struct mii_dev *bus, int addr, int devad, u32 *phy_id)
|
{
int phy_reg;
phy_reg = bus->read(bus, addr, devad, MII_PHYSID1);
if (phy_reg < 0)
return -EIO;
*phy_id = (phy_reg & 0xffff) << 16;
phy_reg = bus->read(bus, addr, devad, MII_PHYSID2);
if (phy_reg < 0)
return -EIO;
*phy_id |= (phy_reg & 0xffff);
return 0;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Description: Returns last LBA value on success, 0 on error. This is stored (by sd and ide-geometry) in the part entry for this disk, and is the number of physical sectors available on the disk. */
|
static u64 last_lba(struct block_device *bdev)
|
/* Description: Returns last LBA value on success, 0 on error. This is stored (by sd and ide-geometry) in the part entry for this disk, and is the number of physical sectors available on the disk. */
static u64 last_lba(struct block_device *bdev)
|
{
if (!bdev || !bdev->bd_inode)
return 0;
return div_u64(bdev->bd_inode->i_size,
bdev_logical_block_size(bdev)) - 1ULL;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Resets the RCC clock configuration to default state. */
|
void RCC_DeInit()
|
/* Resets the RCC clock configuration to default state. */
void RCC_DeInit()
|
{
SET_BIT(RCC->CR, RCC_CR_HSION);
CLEAR_BIT(RCC->CFGR, RCC_CFGR_SW);
CLEAR_BIT(RCC->CR, RCC_CR_HSEON | RCC_CR_CSSON | RCC_CR_PLLON );
CLEAR_BIT(RCC->PLLCFGR, RCC_PLLCFGR_PLL_DN | RCC_PLLCFGR_PLL_DP);
CLEAR_BIT(RCC->CR, RCC_CR_HSEBYP);
CLEAR_REG(RCC->CFGR);
CLEAR_REG(RCC->CIR);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* The return value is a combination of the values described in the */
|
unsigned long HibernateLowBatGet(void)
|
/* The return value is a combination of the values described in the */
unsigned long HibernateLowBatGet(void)
|
{
return(HWREG(HIB_CTL) & (HIB_CTL_VBATSEL_M | HIBERNATE_LOW_BAT_ABORT));
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.