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 |
|---|---|---|---|---|---|---|---|
/* Programs a word (32-bit) at a specified address. */ | FMC_STATUS_T FMC_ProgramWord(uint32_t address, uint32_t data) | /* Programs a word (32-bit) at a specified address. */
FMC_STATUS_T FMC_ProgramWord(uint32_t address, uint32_t data) | {
FMC_STATUS_T status = FMC_COMPLETE;
status = FMC_WaitForLastOperation();
if (status == FMC_COMPLETE)
{
FMC->CTRL &= 0xFFFFFCFF;
FMC->CTRL |= FMC_PSIZE_WORD;
FMC->CTRL |= FMC_CTRL_PG;
*(__IO uint32_t *)address = data;
status = FMC_WaitForLastOperation();
FMC->CTRL &= (~FMC_CTRL_PG);
}
return status;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Select given device on the SPI bus.
Set device specific setting and calls board chip select. */ | void spi_select_device(SPI_t *spi, struct spi_device *device) | /* Select given device on the SPI bus.
Set device specific setting and calls board chip select. */
void spi_select_device(SPI_t *spi, struct spi_device *device) | {
ioport_set_pin_low(device->id);
} | memfault/zero-to-main | C++ | null | 200 |
/* This function is used to calculate the minimum necessary DLC code for a number of bytes. */ | enum can_ctrl_dlc can_ctrl_size_to_dlc(uint8_t size) | /* This function is used to calculate the minimum necessary DLC code for a number of bytes. */
enum can_ctrl_dlc can_ctrl_size_to_dlc(uint8_t size) | {
if(size > 64)
return CAN_DLC_TOO_SMALL;
if((size > 8) && (size <= 12))
return CAN_DLC_12;
if((size > 12) && (size <= 16))
return CAN_DLC_16;
if((size > 16) && (size <= 20))
return CAN_DLC_20;
if((size > 20) && (size <= 24))
return CAN_DLC_24;
if((size > 24) && (size <= 32))
return CAN_DLC_32;
if((size > 32) && (size <= 48))
return CAN_DLC_48;
if((size > 48) && (size <= 64))
return CAN_DLC_64;
return size;
} | analogdevicesinc/EVAL-ADICUP3029 | C++ | Other | 36 |
/* param handle DMA handle pointer. param config Pointer to DMA transfer configuration structure. retval kStatus_DMA_Success It means submit transfer request succeed. retval kStatus_DMA_QueueFull It means TCD queue is full. Submit transfer request is not allowed. retval kStatus_DMA_Busy It means the given channel is busy, need to submit request later. */ | status_t DMA_SubmitTransfer(dma_handle_t *handle, dma_transfer_config_t *config) | /* param handle DMA handle pointer. param config Pointer to DMA transfer configuration structure. retval kStatus_DMA_Success It means submit transfer request succeed. retval kStatus_DMA_QueueFull It means TCD queue is full. Submit transfer request is not allowed. retval kStatus_DMA_Busy It means the given channel is busy, need to submit request later. */
status_t DMA_SubmitTransfer(dma_handle_t *handle, dma_transfer_config_t *config) | {
assert((NULL != handle) && (NULL != config));
assert(handle->channel < (uint32_t)FSL_FEATURE_DMA_NUMBER_OF_CHANNELSn(handle->base));
uint32_t instance = DMA_GetInstance(handle->base);
dma_descriptor_t *descriptor = (dma_descriptor_t *)(&s_dma_descriptor_table[instance][handle->channel]);
if (DMA_ChannelIsActive(handle->base, handle->channel))
{
return kStatus_DMA_Busy;
}
if (config->isPeriph)
{
DMA_EnableChannelPeriphRq(handle->base, handle->channel);
}
else
{
DMA_DisableChannelPeriphRq(handle->base, handle->channel);
}
DMA_CreateDescriptor(descriptor, &config->xfercfg, config->srcAddr, config->dstAddr, config->nextDesc);
handle->base->CHANNEL[handle->channel].XFERCFG = descriptor->xfercfg;
return kStatus_Success;
} | ARMmbed/DAPLink | C++ | Apache License 2.0 | 2,140 |
/* Get tracepoint if the tracepoint is present in the tracepoint hash table. Must be called with tracepoints_mutex held. Returns NULL if not present. */ | static struct tracepoint_entry* get_tracepoint(const char *name) | /* Get tracepoint if the tracepoint is present in the tracepoint hash table. Must be called with tracepoints_mutex held. Returns NULL if not present. */
static struct tracepoint_entry* get_tracepoint(const char *name) | {
struct hlist_head *head;
struct hlist_node *node;
struct tracepoint_entry *e;
u32 hash = jhash(name, strlen(name), 0);
head = &tracepoint_table[hash & (TRACEPOINT_TABLE_SIZE - 1)];
hlist_for_each_entry(e, node, head, hlist) {
if (!strcmp(name, e->name))
return e;
}
return NULL;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Should we display an "ndr_context_handle" with a tree holding the attributes and the uuid_t? */ | int dissect_ndr_ctx_hnd(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_, proto_tree *tree, dcerpc_info *di, guint8 *drep, int hfindex, e_ctx_hnd *pdata) | /* Should we display an "ndr_context_handle" with a tree holding the attributes and the uuid_t? */
int dissect_ndr_ctx_hnd(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_, proto_tree *tree, dcerpc_info *di, guint8 *drep, int hfindex, e_ctx_hnd *pdata) | {
static e_ctx_hnd ctx_hnd;
if (di->conformant_run) {
return offset;
}
if (!di->no_align && (offset % 4)) {
offset += 4 - (offset % 4);
}
ctx_hnd.attributes = dcerpc_tvb_get_ntohl(tvb, offset, drep);
dcerpc_tvb_get_uuid(tvb, offset+4, drep, &ctx_hnd.uuid);
if (tree) {
proto_tree_add_item(tree, hfindex, tvb, offset, 20, ENC_NA);
}
if (pdata) {
*pdata = ctx_hnd;
}
return offset + 20;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Enables or disables the USART's Half Duplex communication. */ | void USART_HalfDuplexCmd(USART_TypeDef *USARTx, FunctionalState NewState) | /* Enables or disables the USART's Half Duplex communication. */
void USART_HalfDuplexCmd(USART_TypeDef *USARTx, FunctionalState NewState) | {
assert_param(IS_USART_ALL_PERIPH(USARTx));
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
USARTx->CR3 |= USART_CR3_HDSEL;
}
else
{
USARTx->CR3 &= (uint32_t)~((uint32_t)USART_CR3_HDSEL);
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Sets the cursor to the home position (0,0) */ | void ili9325Home(void) | /* Sets the cursor to the home position (0,0) */
void ili9325Home(void) | {
ili9325SetCursor(0, 0);
ili9325WriteCmd(ILI9325_COMMANDS_WRITEDATATOGRAM);
} | microbuilder/LPC1343CodeBase | C++ | Other | 73 |
/* Activate DMA basic cycle (used for memory-peripheral transfers).
Prior to activating the DMA cycle, the channel and descriptor to be used must have been properly configured. */ | void DMA_ActivateBasic(unsigned int channel, bool primary, bool useBurst, void *dst, void *src, unsigned int nMinus1) | /* Activate DMA basic cycle (used for memory-peripheral transfers).
Prior to activating the DMA cycle, the channel and descriptor to be used must have been properly configured. */
void DMA_ActivateBasic(unsigned int channel, bool primary, bool useBurst, void *dst, void *src, unsigned int nMinus1) | {
EFM_ASSERT(channel < DMA_CHAN_COUNT);
EFM_ASSERT(nMinus1 <= (_DMA_CTRL_N_MINUS_1_MASK >> _DMA_CTRL_N_MINUS_1_SHIFT));
DMA_Prepare(channel,
dmaCycleCtrlBasic,
primary,
useBurst,
dst,
src,
nMinus1);
DMA->CHENS = 1 << channel;
} | feaser/openblt | C++ | GNU General Public License v3.0 | 601 |
/* Accelerometer Z-axis user offset correction expressed in two’s complement, weight depends on USR_OFF_W in CTRL6_C (15h). The value must be in the range .. */ | int32_t lsm6dso_xl_usr_offset_z_get(lsm6dso_ctx_t *ctx, uint8_t *buff) | /* Accelerometer Z-axis user offset correction expressed in two’s complement, weight depends on USR_OFF_W in CTRL6_C (15h). The value must be in the range .. */
int32_t lsm6dso_xl_usr_offset_z_get(lsm6dso_ctx_t *ctx, uint8_t *buff) | {
int32_t ret;
ret = lsm6dso_read_reg(ctx, LSM6DSO_Z_OFS_USR, buff, 1);
return ret;
} | alexander-g-dean/ESF | C++ | null | 41 |
/* Free a DMA buffer. 'size' must be page aligned. */ | static void __dma_free_buffer(struct page *page, size_t size) | /* Free a DMA buffer. 'size' must be page aligned. */
static void __dma_free_buffer(struct page *page, size_t size) | {
struct page *e = page + (size >> PAGE_SHIFT);
while (page < e) {
__free_page(page);
page++;
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Returns: TRUE if a source was found and removed. */ | gboolean g_source_remove_by_user_data(gpointer user_data) | /* Returns: TRUE if a source was found and removed. */
gboolean g_source_remove_by_user_data(gpointer user_data) | {
GSource *source;
source = g_main_context_find_source_by_user_data (NULL, user_data);
if (source)
{
g_source_destroy (source);
return TRUE;
}
else
return FALSE;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Function returns an array of handles that support the FVB protocol in a buffer allocated from pool. */ | EFI_STATUS GetFvbCountAndBuffer(OUT UINTN *NumberHandles, OUT EFI_HANDLE **Buffer) | /* Function returns an array of handles that support the FVB protocol in a buffer allocated from pool. */
EFI_STATUS GetFvbCountAndBuffer(OUT UINTN *NumberHandles, OUT EFI_HANDLE **Buffer) | {
EFI_STATUS Status;
Status = gBS->LocateHandleBuffer (
ByProtocol,
&gEfiFirmwareVolumeBlockProtocolGuid,
NULL,
NumberHandles,
Buffer
);
return Status;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Enables or disables the receiver Time Out feature. */ | void USART_ReceiverTimeOutCmd(USART_TypeDef *USARTx, FunctionalState NewState) | /* Enables or disables the receiver Time Out feature. */
void USART_ReceiverTimeOutCmd(USART_TypeDef *USARTx, FunctionalState NewState) | {
assert_param(IS_USART_1_PERIPH(USARTx));
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
USARTx->CR2 |= USART_CR2_RTOEN;
}
else
{
USARTx->CR2 &= (uint32_t)~((uint32_t)USART_CR2_RTOEN);
}
} | ajhc/demo-cortex-m3 | C++ | null | 38 |
/* Call PnP BIOS with function 0x05, "get docking station information" */ | int pnp_bios_dock_station_info(struct pnp_docking_station_info *data) | /* Call PnP BIOS with function 0x05, "get docking station information" */
int pnp_bios_dock_station_info(struct pnp_docking_station_info *data) | {
u16 status;
if (!pnp_bios_present())
return PNP_FUNCTION_NOT_SUPPORTED;
status = call_pnp_bios(PNP_GET_DOCKING_STATION_INFORMATION, 0, PNP_TS1,
PNP_DS, 0, 0, 0, 0, data,
sizeof(struct pnp_docking_station_info), NULL,
0);
return status;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Program a block of flash. Very simple because we can do it byte by byte anyway. */ | static int jsf_ioctl_program(void __user *arg) | /* Program a block of flash. Very simple because we can do it byte by byte anyway. */
static int jsf_ioctl_program(void __user *arg) | {
struct jsflash_program_arg abuf;
char __user *uptr;
unsigned long p;
unsigned int togo;
union {
unsigned int n;
char s[4];
} b;
if (copy_from_user(&abuf, arg, JSFPRGSZ))
return -EFAULT;
p = abuf.off;
togo = abuf.size;
if ((togo & 3) || (p & 3)) return -EINVAL;
uptr = (char __user *) (unsigned long) abuf.data;
while (togo != 0) {
togo -= 4;
if (copy_from_user(&b.s[0], uptr, 4))
return -EFAULT;
jsf_write4(p, b.n);
p += 4;
uptr += 4;
}
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* @block_dev: Pointer to block device @start: First block to write/erase @blkcnt: Count of blocks @buffer: Pointer to data buffer for write or NULL for erase */ | static lbaint_t fb_mmc_blk_write(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt, const void *buffer) | /* @block_dev: Pointer to block device @start: First block to write/erase @blkcnt: Count of blocks @buffer: Pointer to data buffer for write or NULL for erase */
static lbaint_t fb_mmc_blk_write(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt, const void *buffer) | {
lbaint_t blk = start;
lbaint_t blks_written;
lbaint_t cur_blkcnt;
lbaint_t blks = 0;
int i;
for (i = 0; i < blkcnt; i += FASTBOOT_MAX_BLK_WRITE) {
cur_blkcnt = min((int)blkcnt - i, FASTBOOT_MAX_BLK_WRITE);
if (buffer) {
if (fastboot_progress_callback)
fastboot_progress_callback("writing");
blks_written = blk_dwrite(block_dev, blk, cur_blkcnt,
buffer + (i * block_dev->blksz));
} else {
if (fastboot_progress_callback)
fastboot_progress_callback("erasing");
blks_written = blk_derase(block_dev, blk, cur_blkcnt);
}
blk += blks_written;
blks += blks_written;
}
return blks;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* User Interface - Board Monitor Initialization : and send SAM4L status. */ | void ui_bm_init(void) | /* User Interface - Board Monitor Initialization : and send SAM4L status. */
void ui_bm_init(void) | {
sysclk_enable_peripheral_clock(BM_USART_USART);
bm_init();
sysclk_disable_peripheral_clock(BM_USART_USART);
ui_bm_send_mcu_status();
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* Checks whether the CPU implements the Embedded Trace Extension. */ | BOOLEAN EFIAPI ArmHasEte(VOID) | /* Checks whether the CPU implements the Embedded Trace Extension. */
BOOLEAN EFIAPI ArmHasEte(VOID) | {
return ((ArmReadIdAA64Dfr0 () & AARCH64_DFR0_TRACEVER) != 0);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Get contents of register REGNO in task TASK. */ | long get_reg(struct task_struct *task, unsigned int regno) | /* Get contents of register REGNO in task TASK. */
long get_reg(struct task_struct *task, unsigned int regno) | {
if (regno == PT_USP)
return task->thread.usp;
else if (regno < PT_MAX)
return ((unsigned long *)task_pt_regs(task))[regno];
else
return 0;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Call hook function registered at hook table for the current thread (if there is one) */ | static void hookf(lua_State *L, lua_Debug *ar) | /* Call hook function registered at hook table for the current thread (if there is one) */
static void hookf(lua_State *L, lua_Debug *ar) | {"call", "return", "line", "count", "tail call"};
lua_getfield(L, LUA_REGISTRYINDEX, HOOKKEY);
lua_pushthread(L);
if (lua_rawget(L, -2) == LUA_TFUNCTION) {
lua_pushstring(L, hooknames[(int)ar->event]);
if (ar->currentline >= 0)
lua_pushinteger(L, ar->currentline);
else lua_pushnil(L);
lua_assert(lua_getinfo(L, "lS", ar));
lua_call(L, 2, 0);
}
} | Nicholas3388/LuaNode | C++ | Other | 1,055 |
/* Gets the states of the RTS modem control signals. */ | unsigned long UARTModemControlGet(unsigned long ulBase) | /* Gets the states of the RTS modem control signals. */
unsigned long UARTModemControlGet(unsigned long ulBase) | {
xASSERT((ulBase == UART0_BASE));
return(xHWREG(ulBase + UART_MCR) & (UART_MCR_RTS_ST));
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* param base MIPI DSI host peripheral base address. param payload Pointer to the payload. param payloadSize Payload size in byte. */ | void DSI_ReadApbRxPayload(const MIPI_DSI_Type *base, uint8_t *payload, uint16_t payloadSize) | /* param base MIPI DSI host peripheral base address. param payload Pointer to the payload. param payloadSize Payload size in byte. */
void DSI_ReadApbRxPayload(const MIPI_DSI_Type *base, uint8_t *payload, uint16_t payloadSize) | {
uint32_t tmp;
for (uint16_t i = 0; i < payloadSize / 4U; i++)
{
tmp = base->apb->PKT_RX_PAYLOAD;
payload[0] = (uint8_t)(tmp & 0xFFU);
payload[1] = (uint8_t)((tmp >> 8U) & 0xFFU);
payload[2] = (uint8_t)((tmp >> 16U) & 0xFFU);
payload[3] = (uint8_t)((tmp >> 24U) & 0xFFU);
payload += 4U;
}
if (0U != (payloadSize & 0x03U))
{
tmp = base->apb->PKT_RX_PAYLOAD;
for (uint16_t i = 0; i < (payloadSize & 0x3U); i++)
{
payload[i] = (uint8_t)(tmp & 0xFFU);
tmp >>= 8U;
}
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Enables the transmit path for LPI mode entry. */ | void EMACLPIEnter(uint32_t ui32Base) | /* Enables the transmit path for LPI mode entry. */
void EMACLPIEnter(uint32_t ui32Base) | {
ASSERT(ui32Base == EMAC0_BASE);
HWREG(ui32Base + EMAC_O_LPICTLSTAT) |= EMAC_LPICTLSTAT_LPIEN;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Returns: TRUE if @object has a floating reference */ | gboolean g_object_is_floating(gpointer _object) | /* Returns: TRUE if @object has a floating reference */
gboolean g_object_is_floating(gpointer _object) | {
GObject *object = _object;
g_return_val_if_fail (G_IS_OBJECT (object), FALSE);
return floating_flag_handler (object, 0);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Read the EEPROM for the default values for flow control and store the values. */ | static s32 e1000_set_default_fc_generic(struct e1000_hw *hw) | /* Read the EEPROM for the default values for flow control and store the values. */
static s32 e1000_set_default_fc_generic(struct e1000_hw *hw) | {
s32 ret_val;
u16 nvm_data;
ret_val = e1000_read_nvm(hw, NVM_INIT_CONTROL2_REG, 1, &nvm_data);
if (ret_val) {
e_dbg("NVM Read Error\n");
return ret_val;
}
if ((nvm_data & NVM_WORD0F_PAUSE_MASK) == 0)
hw->fc.requested_mode = e1000_fc_none;
else if ((nvm_data & NVM_WORD0F_PAUSE_MASK) ==
NVM_WORD0F_ASM_DIR)
hw->fc.requested_mode = e1000_fc_tx_pause;
else
hw->fc.requested_mode = e1000_fc_full;
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Start writeback on some inodes on this super_block. No guarantees are made on how many (if any) will be written, and this function does not wait for IO completion of submitted IO. The number of pages submitted is returned. */ | void writeback_inodes_sb(struct super_block *sb) | /* Start writeback on some inodes on this super_block. No guarantees are made on how many (if any) will be written, and this function does not wait for IO completion of submitted IO. The number of pages submitted is returned. */
void writeback_inodes_sb(struct super_block *sb) | {
unsigned long nr_dirty = global_page_state(NR_FILE_DIRTY);
unsigned long nr_unstable = global_page_state(NR_UNSTABLE_NFS);
long nr_to_write;
nr_to_write = nr_dirty + nr_unstable +
(inodes_stat.nr_inodes - inodes_stat.nr_unused);
bdi_start_writeback(sb->s_bdi, sb, nr_to_write);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Return: 0 if write operation was successful, -ve on error */ | static int aux_write(struct udevice *dev, u32 dpcd_address, u32 bytes_to_write, void *write_data) | /* Return: 0 if write operation was successful, -ve on error */
static int aux_write(struct udevice *dev, u32 dpcd_address, u32 bytes_to_write, void *write_data) | {
int status;
if (!is_connected(dev))
return -ENODEV;
status = aux_common(dev, AUX_CMD_WRITE, dpcd_address,
bytes_to_write, (u8 *)write_data);
return status;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Locking Note: This function expects that the disc_mutex is locked before it is called. */ | static int fc_disc_single(struct fc_lport *, struct fc_disc_port *) | /* Locking Note: This function expects that the disc_mutex is locked before it is called. */
static int fc_disc_single(struct fc_lport *, struct fc_disc_port *) | {
struct fc_rport_priv *rdata;
rdata = lport->tt.rport_create(lport, dp->port_id);
if (!rdata)
return -ENOMEM;
rdata->disc_id = 0;
return fc_disc_gpn_id_req(lport, rdata);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Configure USART in normal (serial rs232) mode, asynchronous, 8 bits, 1 stop bit, no parity, 115200 bauds and enable its transmitter and receiver. */ | static void configure_usart(void) | /* Configure USART in normal (serial rs232) mode, asynchronous, 8 bits, 1 stop bit, no parity, 115200 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_USART);
usart_init_rs232(BOARD_USART, &usart_console_settings,
sysclk_get_peripheral_bus_hz(BOARD_USART));
BOARD_USART->US_MR |= US_MR_CHMODE_LOCAL_LOOP;
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 |
/* bcm_tx_send - send a single CAN frame to the CAN interface (for bcm_sendmsg) */ | static int bcm_tx_send(struct msghdr *msg, int ifindex, struct sock *sk) | /* bcm_tx_send - send a single CAN frame to the CAN interface (for bcm_sendmsg) */
static int bcm_tx_send(struct msghdr *msg, int ifindex, struct sock *sk) | {
struct sk_buff *skb;
struct net_device *dev;
int err;
if (!ifindex)
return -ENODEV;
skb = alloc_skb(CFSIZ, GFP_KERNEL);
if (!skb)
return -ENOMEM;
err = memcpy_fromiovec(skb_put(skb, CFSIZ), msg->msg_iov, CFSIZ);
if (err < 0) {
kfree_skb(skb);
return err;
}
dev = dev_get_by_index(&init_net, ifindex);
if (!dev) {
kfree_skb(skb);
return -ENODEV;
}
skb->dev = dev;
skb->sk = sk;
err = can_send(skb, 1);
dev_put(dev);
if (err)
return err;
return CFSIZ + MHSIZ;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Configure all GPIO's to AN to reduce the power consumption. */ | static void GPIO_ConfigAN(void) | /* Configure all GPIO's to AN to reduce the power consumption. */
static void GPIO_ConfigAN(void) | {
GPIO_InitTypeDef GPIO_InitStruct;
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE();
__HAL_RCC_GPIOE_CLK_ENABLE();
__HAL_RCC_GPIOF_CLK_ENABLE();
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Pin = GPIO_PIN_All;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
__HAL_RCC_GPIOC_CLK_DISABLE();
__HAL_RCC_GPIOD_CLK_DISABLE();
__HAL_RCC_GPIOE_CLK_DISABLE();
__HAL_RCC_GPIOF_CLK_DISABLE();
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* Return: 0 on success, %-EINVAL if mtu too small */ | static int ip6_tnl_change_mtu(struct net_device *dev, int new_mtu) | /* Return: 0 on success, %-EINVAL if mtu too small */
static int ip6_tnl_change_mtu(struct net_device *dev, int new_mtu) | {
if (new_mtu < IPV6_MIN_MTU) {
return -EINVAL;
}
dev->mtu = new_mtu;
return 0;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Connects to a data source. param: one string for each connection parameter, said datasource, username, password, host and port. */ | static int env_connect(lua_State *L) | /* Connects to a data source. param: one string for each connection parameter, said datasource, username, password, host and port. */
static int env_connect(lua_State *L) | {
char error_msg[100];
strncpy (error_msg, mysql_error(conn), 99);
mysql_close (conn);
return luasql_failmessage (L, "Error connecting to database. MySQL: ", error_msg);
}
return create_connection(L, 1, conn);
} | DC-SWAT/DreamShell | C++ | null | 404 |
/* Cache invalidation occurs rarely, thus the LRU chain is not updated. It fixes itself after a while. */ | static void __fat_cache_inval_inode(struct inode *inode) | /* Cache invalidation occurs rarely, thus the LRU chain is not updated. It fixes itself after a while. */
static void __fat_cache_inval_inode(struct inode *inode) | {
struct msdos_inode_info *i = MSDOS_I(inode);
struct fat_cache *cache;
while (!list_empty(&i->cache_lru)) {
cache = list_entry(i->cache_lru.next, struct fat_cache, cache_list);
list_del_init(&cache->cache_list);
i->nr_caches--;
fat_cache_free(cache);
}
i->cache_valid_id++;
if (i->cache_valid_id == FAT_CACHE_VALID)
i->cache_valid_id++;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Configures a SPI peripheral as specified. The configuration can be computed using several macros (see "SPI configuration macros") and the constants defined in LibV3 (AT91C_SPI_*). */ | void SPI_Configure(AT91S_SPI *spi, unsigned int id, unsigned int configuration) | /* Configures a SPI peripheral as specified. The configuration can be computed using several macros (see "SPI configuration macros") and the constants defined in LibV3 (AT91C_SPI_*). */
void SPI_Configure(AT91S_SPI *spi, unsigned int id, unsigned int configuration) | {
AT91C_BASE_PMC->PMC_PCER = 1 << id;
spi->SPI_CR = AT91C_SPI_SPIDIS | AT91C_SPI_SWRST;
spi->SPI_MR = configuration;
} | apopple/Pandaboard-FreeRTOS | C++ | null | 25 |
/* Generate code which executes when the rule "rp" is reduced. Write the code to "out". Make sure lineno stays up-to-date. */ | PRIVATE void emit_code(FILE *out, struct rule *rp, struct lemon *lemp, int *lineno) | /* Generate code which executes when the rule "rp" is reduced. Write the code to "out". Make sure lineno stays up-to-date. */
PRIVATE void emit_code(FILE *out, struct rule *rp, struct lemon *lemp, int *lineno) | {
const char *cp;
if( rp->code ){
if( !lemp->nolinenosflag ){
(*lineno)++;
tplt_linedir(out,rp->line,lemp->filename);
}
fprintf(out,"{%s",rp->code);
for(cp=rp->code; *cp; cp++){
if( *cp=='\n' ) (*lineno)++;
}
fprintf(out,"}\n"); (*lineno)++;
if( !lemp->nolinenosflag ){
(*lineno)++;
tplt_linedir(out,*lineno,lemp->outname);
}
}
return;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Clock-gated I2C clock domain for address matching interrupts wake up. */ | void I2C_Sleep_Cmd(I2C_TypeDef *I2Cx, u32 NewStatus) | /* Clock-gated I2C clock domain for address matching interrupts wake up. */
void I2C_Sleep_Cmd(I2C_TypeDef *I2Cx, u32 NewStatus) | {
assert_param(IS_I2C_ALL_PERIPH(I2Cx));
if (NewStatus != DISABLE) {
I2C_INTConfig(I2Cx, BIT_IC_INTR_MASK_M_ADDR_1_MATCH|BIT_IC_INTR_MASK_M_ADDR_2_MATCH, ENABLE);
I2Cx->IC_SLEEP |= BIT_IC_SLEEP_CLOCK_CONTROL;
} else {
I2C_INTConfig(I2Cx, BIT_IC_INTR_MASK_M_ADDR_1_MATCH|BIT_IC_INTR_MASK_M_ADDR_2_MATCH, DISABLE);
I2Cx->IC_SLEEP &= ~BIT_IC_SLEEP_CLOCK_CONTROL;
}
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* For tight control over page level allocator and protection flags use __vmalloc() instead. */ | void* vmalloc(unsigned long size) | /* For tight control over page level allocator and protection flags use __vmalloc() instead. */
void* vmalloc(unsigned long size) | {
return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL,
-1, __builtin_return_address(0));
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This function get the Mac Address, Ethernet statistics, maximum segment size, number of multicast filters, and number of pattern filters from Ethernet functional Descriptor. */ | EFI_STATUS EFIAPI GetUsbRndisFunDescriptor(IN EDKII_USB_ETHERNET_PROTOCOL *This, OUT USB_ETHERNET_FUN_DESCRIPTOR *UsbEthFunDescriptor) | /* This function get the Mac Address, Ethernet statistics, maximum segment size, number of multicast filters, and number of pattern filters from Ethernet functional Descriptor. */
EFI_STATUS EFIAPI GetUsbRndisFunDescriptor(IN EDKII_USB_ETHERNET_PROTOCOL *This, OUT USB_ETHERNET_FUN_DESCRIPTOR *UsbEthFunDescriptor) | {
EFI_STATUS Status;
USB_RNDIS_DEVICE *UsbRndisDevice;
UsbRndisDevice = USB_RNDIS_DEVICE_FROM_THIS (This);
if (UsbEthFunDescriptor == NULL) {
return EFI_INVALID_PARAMETER;
}
Status = GetFunctionalDescriptor (
UsbRndisDevice->Config,
ETHERNET_FUN_DESCRIPTOR,
UsbEthFunDescriptor
);
return Status;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Close : when somebody close /dev/irnet Destroy the instance of /dev/irnet */ | static int dev_irnet_close(struct inode *inode, struct file *file) | /* Close : when somebody close /dev/irnet Destroy the instance of /dev/irnet */
static int dev_irnet_close(struct inode *inode, struct file *file) | {
irnet_socket * ap = (struct irnet_socket *) file->private_data;
DENTER(FS_TRACE, "(file=0x%p, ap=0x%p)\n",
file, ap);
DABORT(ap == NULL, 0, FS_ERROR, "ap is NULL !!!\n");
file->private_data = NULL;
irda_irnet_destroy(ap);
if(ap->ppp_open)
{
DERROR(FS_ERROR, "Channel still registered - deregistering !\n");
ap->ppp_open = 0;
ppp_unregister_channel(&ap->chan);
}
kfree(ap);
DEXIT(FS_TRACE, "\n");
return 0;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* This function parses the string descriptor from the received buffer. */ | void usb_host_parsestringdesc(uint8_t *psrc, uint8_t *pdest, uint16_t length) | /* This function parses the string descriptor from the received buffer. */
void usb_host_parsestringdesc(uint8_t *psrc, uint8_t *pdest, uint16_t length) | {
uint16_t strlength;
uint16_t tmp_idx;
if (psrc[1] == USB_DESC_TYPE_STRING) {
strlength = ((((uint16_t)psrc[0]) - 2U) <= length) ? (((uint16_t)psrc[0]) - 2U) : length;
psrc += 2U;
for (tmp_idx = 0U; tmp_idx < strlength; tmp_idx += 2U) {
*pdest = psrc[tmp_idx];
pdest++;
}
*pdest = 0U;
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Insert an entry into hash TLB or VHPT. NOTES: 1: When inserting VHPT to thash, "va" is a must covered address by the inserted machine VHPT entry. 2: The format of entry is always in TLB. 3: The caller need to make sure the new entry will not overlap with any existed entry. */ | void vtlb_insert(struct kvm_vcpu *v, u64 pte, u64 itir, u64 va) | /* Insert an entry into hash TLB or VHPT. NOTES: 1: When inserting VHPT to thash, "va" is a must covered address by the inserted machine VHPT entry. 2: The format of entry is always in TLB. 3: The caller need to make sure the new entry will not overlap with any existed entry. */
void vtlb_insert(struct kvm_vcpu *v, u64 pte, u64 itir, u64 va) | {
struct thash_data *head;
union ia64_rr vrr;
u64 tag;
struct thash_cb *hcb = &v->arch.vtlb;
vrr.val = vcpu_get_rr(v, va);
vrr.ps = itir_ps(itir);
VMX(v, psbits[va >> 61]) |= (1UL << vrr.ps);
head = vsa_thash(hcb->pta, va, vrr.val, &tag);
head->page_flags = pte;
head->itir = itir;
head->etag = tag;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* If 16-bit I/O port operations are not supported, then ASSERT(). */ | VOID EFIAPI IoWriteFifo16(IN UINTN Port, IN UINTN Count, IN VOID *Buffer) | /* If 16-bit I/O port operations are not supported, then ASSERT(). */
VOID EFIAPI IoWriteFifo16(IN UINTN Port, IN UINTN Count, IN VOID *Buffer) | {
ASSERT ((Port & 1) == 0);
IoWriteFifoWorker (Port, EfiCpuIoWidthFifoUint16, Count, Buffer);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Free all contained in the map entries and memory used by the map Should be always called after adapter removal from DIDD array */ | void diva_free_dma_map(void *hdev, struct _diva_dma_map_entry *pmap) | /* Free all contained in the map entries and memory used by the map Should be always called after adapter removal from DIDD array */
void diva_free_dma_map(void *hdev, struct _diva_dma_map_entry *pmap) | {
struct pci_dev *pdev = (struct pci_dev *) hdev;
int i;
dword phys_addr;
void *cpu_addr;
dma_addr_t dma_handle;
void *addr_handle;
for (i = 0; (pmap != NULL); i++) {
diva_get_dma_map_entry(pmap, i, &cpu_addr, &phys_addr);
if (!cpu_addr) {
break;
}
addr_handle = diva_get_entry_handle(pmap, i);
dma_handle = (dma_addr_t) phys_addr;
pci_free_consistent(pdev, PAGE_SIZE, addr_handle,
dma_handle);
DBG_TRC(("dma map free [%d]=(%08lx:%08x:%08lx)", i,
(unsigned long) cpu_addr, (dword) dma_handle,
(unsigned long) addr_handle))
}
diva_free_dma_mapping(pmap);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Note that the current directory string should exclude the tailing backslash character. */ | CONST CHAR16* EFIAPI ShellGetCurrentDir(IN CHAR16 *CONST DeviceName OPTIONAL) | /* Note that the current directory string should exclude the tailing backslash character. */
CONST CHAR16* EFIAPI ShellGetCurrentDir(IN CHAR16 *CONST DeviceName OPTIONAL) | {
if (gEfiShellProtocol != NULL) {
return (gEfiShellProtocol->GetCurDir (DeviceName));
}
if (mEfiShellEnvironment2 != NULL) {
return (mEfiShellEnvironment2->CurDir (DeviceName));
}
return (NULL);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* This function enables the GPIO pin state to be maintained during hibernation and remain active even when waking from hibernation. The GPIO module itself is reset upon entering hibernation and no longer controls the output pins. To maintain the current output level after waking from hibernation, the GPIO module must be reconfigured and then the */ | void HibernateGPIORetentionEnable(void) | /* This function enables the GPIO pin state to be maintained during hibernation and remain active even when waking from hibernation. The GPIO module itself is reset upon entering hibernation and no longer controls the output pins. To maintain the current output level after waking from hibernation, the GPIO module must be reconfigured and then the */
void HibernateGPIORetentionEnable(void) | {
HWREG(HIB_CTL) |= HIB_CTL_VDD3ON;
_HibernateWriteComplete();
} | feaser/openblt | C++ | GNU General Public License v3.0 | 601 |
/* find out if an object is in use or not */ | int cachefiles_check_in_use(struct cachefiles_cache *cache, struct dentry *dir, char *filename) | /* find out if an object is in use or not */
int cachefiles_check_in_use(struct cachefiles_cache *cache, struct dentry *dir, char *filename) | {
struct dentry *victim;
victim = cachefiles_check_active(cache, dir, filename);
if (IS_ERR(victim))
return PTR_ERR(victim);
mutex_unlock(&dir->d_inode->i_mutex);
dput(victim);
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Reset a lv_timer. It will be called the previously set period milliseconds later. */ | void lv_timer_reset(lv_timer_t *timer) | /* Reset a lv_timer. It will be called the previously set period milliseconds later. */
void lv_timer_reset(lv_timer_t *timer) | {
timer->last_run = lv_tick_get();
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* Deinitializes SDADCx peripheral registers to their default reset values. */ | void SDADC_DeInit(SDADC_TypeDef *SDADCx) | /* Deinitializes SDADCx peripheral registers to their default reset values. */
void SDADC_DeInit(SDADC_TypeDef *SDADCx) | {
assert_param(IS_SDADC_ALL_PERIPH(SDADCx));
if(SDADCx == SDADC1)
{
RCC_APB2PeriphResetCmd(RCC_APB2Periph_SDADC1, ENABLE);
RCC_APB2PeriphResetCmd(RCC_APB2Periph_SDADC1, DISABLE);
}
else if(SDADCx == SDADC2)
{
RCC_APB2PeriphResetCmd(RCC_APB2Periph_SDADC2, ENABLE);
RCC_APB2PeriphResetCmd(RCC_APB2Periph_SDADC2, DISABLE);
}
else
{
RCC_APB2PeriphResetCmd(RCC_APB2Periph_SDADC3, ENABLE);
RCC_APB2PeriphResetCmd(RCC_APB2Periph_SDADC3, DISABLE);
}
} | avem-labs/Avem | C++ | MIT License | 1,752 |
/* Description: Create a new CIPSO_V4_MAP_PASS 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_pass(struct genl_info *info, struct netlbl_audit *audit_info) | /* Description: Create a new CIPSO_V4_MAP_PASS 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_pass(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_PASS;
ret_val = netlbl_cipsov4_add_common(info, doi_def);
if (ret_val != 0)
goto add_pass_failure;
ret_val = cipso_v4_doi_add(doi_def, audit_info);
if (ret_val != 0)
goto add_pass_failure;
return 0;
add_pass_failure:
cipso_v4_doi_free(doi_def);
return ret_val;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Change Logs: Date Author Notes Abbcc first version stevetong459 FINSH_FUNCTION_EXPORT_ALIAS change to MSH_CMD_EXPORT for reboot function. */ | void rt_hw_systick_init(void) | /* Change Logs: Date Author Notes Abbcc first version stevetong459 FINSH_FUNCTION_EXPORT_ALIAS change to MSH_CMD_EXPORT for reboot function. */
void rt_hw_systick_init(void) | {
SysTick_Config(RCM_ReadHCLKFreq() / RT_TICK_PER_SECOND);
SysTick->CTRL |= 0x00000004U;
NVIC_SetPriority(SysTick_IRQn, 0xFF);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* This function is used for getting the count of block I/O devices that one specific block driver detects. If no device is detected, then the function will return zero. */ | EFI_STATUS EFIAPI NvmeBlockIoPeimGetDeviceNo2(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This, OUT UINTN *NumberBlockDevices) | /* This function is used for getting the count of block I/O devices that one specific block driver detects. If no device is detected, then the function will return zero. */
EFI_STATUS EFIAPI NvmeBlockIoPeimGetDeviceNo2(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This, OUT UINTN *NumberBlockDevices) | {
PEI_NVME_CONTROLLER_PRIVATE_DATA *Private;
if ((This == NULL) || (NumberBlockDevices == NULL)) {
return EFI_INVALID_PARAMETER;
}
Private = GET_NVME_PEIM_HC_PRIVATE_DATA_FROM_THIS_BLKIO2 (This);
*NumberBlockDevices = Private->ActiveNamespaceNum;
return EFI_SUCCESS;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* pop an existing item off the free queue, or create a new one */ | static lv_lru_item_t * lv_lru_pop_or_create_item(lv_lru_t *cache) | /* pop an existing item off the free queue, or create a new one */
static lv_lru_item_t * lv_lru_pop_or_create_item(lv_lru_t *cache) | {
lv_lru_item_t * item = NULL;
if(cache->free_items) {
item = cache->free_items;
cache->free_items = item->next;
lv_memzero(item, sizeof(lv_lru_item_t));
}
else {
item = lv_malloc_zeroed(sizeof(lv_lru_item_t));
}
return item;
} | arendst/Tasmota | C++ | GNU General Public License v3.0 | 21,318 |
/* Unpacks unsigned 8 bit value from the buffer from the offset requested. */ | static int unpack_uint8(struct buf_ctx *buf, uint8_t *val) | /* Unpacks unsigned 8 bit value from the buffer from the offset requested. */
static int unpack_uint8(struct buf_ctx *buf, uint8_t *val) | {
NET_DBG(">> cur:%p, end:%p", (void *)buf->cur, (void *)buf->end);
if ((buf->end - buf->cur) < sizeof(uint8_t)) {
return -EINVAL;
}
*val = *(buf->cur++);
NET_DBG("<< val:%02x", *val);
return 0;
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Do a depth first search on the flow graph, numbering the the basic blocks, and entering them into the 'blocks' array.` */ | static void number_blks_r(opt_state_t *opt_state, struct icode *ic, struct block *p) | /* Do a depth first search on the flow graph, numbering the the basic blocks, and entering them into the 'blocks' array.` */
static void number_blks_r(opt_state_t *opt_state, struct icode *ic, struct block *p) | {
int n;
if (p == 0 || isMarked(ic, p))
return;
Mark(ic, p);
n = opt_state->n_blocks++;
p->id = n;
opt_state->blocks[n] = p;
number_blks_r(opt_state, ic, JT(p));
number_blks_r(opt_state, ic, JF(p));
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Deinitializes the spi peripheral registers to their default reset values. */ | void SPI_DeInit(SPI_TypeDef *spi) | /* Deinitializes the spi peripheral registers to their default reset values. */
void SPI_DeInit(SPI_TypeDef *spi) | {
switch (*(vu32*)&spi) {
case (u32)SPI2:
RCC_APB1PeriphResetCmd(RCC_APB1ENR_SPI2, ENABLE);
RCC_APB1PeriphResetCmd(RCC_APB1ENR_SPI2, DISABLE);
break;
case (u32)SPI3:
RCC_APB1PeriphResetCmd(RCC_APB1ENR_SPI3, ENABLE);
RCC_APB1PeriphResetCmd(RCC_APB1ENR_SPI3, DISABLE);
break;
case (u32)SPI1:
RCC_APB2PeriphResetCmd(RCC_APB2ENR_SPI1, ENABLE);
RCC_APB2PeriphResetCmd(RCC_APB2ENR_SPI1, DISABLE);
break;
default:
break;
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Start a commit of the current running transaction (if any). Returns true if a transaction is going to be committed (or is currently already committing), and fills its tid in at *ptid */ | int jbd2_journal_start_commit(journal_t *journal, tid_t *ptid) | /* Start a commit of the current running transaction (if any). Returns true if a transaction is going to be committed (or is currently already committing), and fills its tid in at *ptid */
int jbd2_journal_start_commit(journal_t *journal, tid_t *ptid) | {
int ret = 0;
spin_lock(&journal->j_state_lock);
if (journal->j_running_transaction) {
tid_t tid = journal->j_running_transaction->t_tid;
__jbd2_log_start_commit(journal, tid);
if (ptid)
*ptid = tid;
ret = 1;
} else if (journal->j_committing_transaction) {
if (ptid)
*ptid = journal->j_committing_transaction->t_tid;
ret = 1;
}
spin_unlock(&journal->j_state_lock);
return ret;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* cxgb3i_ddp_adjust_page_table - adjust page table with PAGE_SIZE return the ddp page index, if no match is found return DDP_PGIDX_MAX. */ | int cxgb3i_ddp_adjust_page_table(void) | /* cxgb3i_ddp_adjust_page_table - adjust page table with PAGE_SIZE return the ddp page index, if no match is found return DDP_PGIDX_MAX. */
int cxgb3i_ddp_adjust_page_table(void) | {
int i;
unsigned int base_order, order;
if (PAGE_SIZE < (1UL << ddp_page_shift[0])) {
ddp_log_info("PAGE_SIZE 0x%lx too small, min. 0x%lx.\n",
PAGE_SIZE, 1UL << ddp_page_shift[0]);
return -EINVAL;
}
base_order = get_order(1UL << ddp_page_shift[0]);
order = get_order(1 << PAGE_SHIFT);
for (i = 0; i < DDP_PGIDX_MAX; i++) {
ddp_page_order[i] = order - base_order + i;
ddp_page_shift[i] = PAGE_SHIFT + i;
}
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* See if the directory is a single-leaf form directory. */ | int xfs_dir2_isleaf(xfs_trans_t *tp, xfs_inode_t *dp, int *vp) | /* See if the directory is a single-leaf form directory. */
int xfs_dir2_isleaf(xfs_trans_t *tp, xfs_inode_t *dp, int *vp) | {
xfs_fileoff_t last;
xfs_mount_t *mp;
int rval;
mp = dp->i_mount;
if ((rval = xfs_bmap_last_offset(tp, dp, &last, XFS_DATA_FORK)))
return rval;
*vp = last == mp->m_dirleafblk + (1 << mp->m_sb.sb_dirblklog);
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Process ABORT_REQ_RSS CPL message: -> host Process abort requests. If we are waiting for an ABORT_RPL we ignore this request except that we need to reply to it. */ | static int abort_status_to_errno(struct s3_conn *c3cn, int abort_reason, int *need_rst) | /* Process ABORT_REQ_RSS CPL message: -> host Process abort requests. If we are waiting for an ABORT_RPL we ignore this request except that we need to reply to it. */
static int abort_status_to_errno(struct s3_conn *c3cn, int abort_reason, int *need_rst) | {
switch (abort_reason) {
case CPL_ERR_BAD_SYN:
case CPL_ERR_CONN_RESET:
return c3cn->state > C3CN_STATE_ESTABLISHED ?
-EPIPE : -ECONNRESET;
case CPL_ERR_XMIT_TIMEDOUT:
case CPL_ERR_PERSIST_TIMEDOUT:
case CPL_ERR_FINWAIT2_TIMEDOUT:
case CPL_ERR_KEEPALIVE_TIMEDOUT:
return -ETIMEDOUT;
default:
return -EIO;
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* A refererence to a dissector, used to call a dissector against a packet or a part of it. */ | WSLUA_CONSTRUCTOR Dissector_get(lua_State *L) | /* A refererence to a dissector, used to call a dissector against a packet or a part of it. */
WSLUA_CONSTRUCTOR Dissector_get(lua_State *L) | {
pushDissector(L, d);
WSLUA_RETURN(1);
}
WSLUA_ARG_ERROR(Dissector_get,NAME,"No such dissector");
return 0;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* This function attempts to set the attributes into MTRR setting buffer for a memory range. */ | RETURN_STATUS EFIAPI MtrrSetMemoryAttributeInMtrrSettings(IN OUT MTRR_SETTINGS *MtrrSetting, IN PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN MTRR_MEMORY_CACHE_TYPE Attribute) | /* This function attempts to set the attributes into MTRR setting buffer for a memory range. */
RETURN_STATUS EFIAPI MtrrSetMemoryAttributeInMtrrSettings(IN OUT MTRR_SETTINGS *MtrrSetting, IN PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN MTRR_MEMORY_CACHE_TYPE Attribute) | {
UINT8 Scratch[SCRATCH_BUFFER_SIZE];
UINTN ScratchSize;
MTRR_MEMORY_RANGE Range;
Range.BaseAddress = BaseAddress;
Range.Length = Length;
Range.Type = Attribute;
ScratchSize = sizeof (Scratch);
return MtrrSetMemoryAttributesInMtrrSettings (MtrrSetting, Scratch, &ScratchSize, &Range, 1);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Sets the rounding options for the font options object. If rounding is set, a glyph's position will be rounded to integer values. */ | void _cairo_font_options_set_round_glyph_positions(cairo_font_options_t *options, cairo_round_glyph_positions_t round) | /* Sets the rounding options for the font options object. If rounding is set, a glyph's position will be rounded to integer values. */
void _cairo_font_options_set_round_glyph_positions(cairo_font_options_t *options, cairo_round_glyph_positions_t round) | {
if (cairo_font_options_status (options))
return;
options->round_glyph_positions = round;
} | xboot/xboot | C++ | MIT License | 779 |
/* The primary purpose of this interface is to allow callers who earlier created a placeholder slot in pci_create_slot() by passing a -1 as slot_nr, to update their struct pci_slot with the correct @slot_nr. */ | void pci_renumber_slot(struct pci_slot *slot, int slot_nr) | /* The primary purpose of this interface is to allow callers who earlier created a placeholder slot in pci_create_slot() by passing a -1 as slot_nr, to update their struct pci_slot with the correct @slot_nr. */
void pci_renumber_slot(struct pci_slot *slot, int slot_nr) | {
struct pci_slot *tmp;
down_write(&pci_bus_sem);
list_for_each_entry(tmp, &slot->bus->slots, list) {
WARN_ON(tmp->number == slot_nr);
goto out;
}
slot->number = slot_nr;
out:
up_write(&pci_bus_sem);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This call may be used with devices that are registered after arch init time. It returns a refcounted pointer to the relevant spi_master (which the caller must release), or NULL if there is no such master registered. */ | struct spi_master* spi_busnum_to_master(u16 bus_num) | /* This call may be used with devices that are registered after arch init time. It returns a refcounted pointer to the relevant spi_master (which the caller must release), or NULL if there is no such master registered. */
struct spi_master* spi_busnum_to_master(u16 bus_num) | {
struct device *dev;
struct spi_master *master = NULL;
dev = class_find_device(&spi_master_class, NULL, &bus_num,
__spi_master_match);
if (dev)
master = container_of(dev, struct spi_master, dev);
return master;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Unregisters a callback.
Unregisters a callback function which is implemented by the user. */ | void sdadc_unregister_callback(struct sdadc_module *const module, enum sdadc_callback callback_type) | /* Unregisters a callback.
Unregisters a callback function which is implemented by the user. */
void sdadc_unregister_callback(struct sdadc_module *const module, enum sdadc_callback callback_type) | {
Assert(module);
module->callback[callback_type] = NULL;
module->registered_callback_mask &= ~(1 << callback_type);
} | memfault/zero-to-main | C++ | null | 200 |
/* Changes the state of a network interface from "stopped" to "started". */ | EFI_STATUS EFIAPI EmuSnpStart(IN EFI_SIMPLE_NETWORK_PROTOCOL *This) | /* Changes the state of a network interface from "stopped" to "started". */
EFI_STATUS EFIAPI EmuSnpStart(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->Start (Private->Io);
return Status;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* USART Read a Received Data Word with Blocking.
Wait until a data word has been received then return the word. */ | uint16_t usart_recv_blocking(uint32_t usart) | /* USART Read a Received Data Word with Blocking.
Wait until a data word has been received then return the word. */
uint16_t usart_recv_blocking(uint32_t usart) | {
usart_wait_recv_ready(usart);
return usart_recv(usart);
} | insane-adding-machines/unicore-mx | C++ | GNU General Public License v3.0 | 50 |
/* Set tx&rx page start address and initialize page own. */ | void I2S_SetDMABuf(I2S_TypeDef *I2Sx, u8 *I2STxData, u8 *I2SRxData) | /* Set tx&rx page start address and initialize page own. */
void I2S_SetDMABuf(I2S_TypeDef *I2Sx, u8 *I2STxData, u8 *I2SRxData) | {
if (I2STxData) {
I2Sx->IS_TX_PAGE_PTR = (u32)I2STxData;
I2S_TxDmaCmd(I2Sx, DISABLE);
}
if (I2SRxData) {
I2Sx->IS_RX_PAGE_PTR = (u32)I2SRxData;
I2S_RxDmaCmd(I2Sx, ENABLE);
}
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Free the RedfishPayload and all its related resources. */ | VOID EFIAPI RedfishCleanupPayload(IN REDFISH_PAYLOAD Payload) | /* Free the RedfishPayload and all its related resources. */
VOID EFIAPI RedfishCleanupPayload(IN REDFISH_PAYLOAD Payload) | {
if (Payload == NULL) {
return;
}
cleanupPayload ((redfishPayload *)Payload);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* The function caches the pointer of the Unix thunk functions It will ASSERT() if Unix thunk ppi is not installed. */ | EFI_STATUS EFIAPI EmuPeCoffGetThunkStucture() | /* The function caches the pointer of the Unix thunk functions It will ASSERT() if Unix thunk ppi is not installed. */
EFI_STATUS EFIAPI EmuPeCoffGetThunkStucture() | {
EMU_THUNK_PPI *ThunkPpi;
EFI_STATUS Status;
Status = PeiServicesLocatePpi (
&gEmuThunkPpiGuid,
0,
NULL,
(VOID **)&ThunkPpi
);
ASSERT_EFI_ERROR (Status);
EMU_MAGIC_PAGE ()->Thunk = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();
return EFI_SUCCESS;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* returns whether the deleted timer was pending (1) or not (0) */ | int del_virt_timer(struct vtimer_list *timer) | /* returns whether the deleted timer was pending (1) or not (0) */
int del_virt_timer(struct vtimer_list *timer) | {
unsigned long flags;
struct vtimer_queue *vq;
if (!vtimer_pending(timer))
return 0;
vq = &per_cpu(virt_cpu_timer, timer->cpu);
spin_lock_irqsave(&vq->lock, flags);
list_del_init(&timer->entry);
spin_unlock_irqrestore(&vq->lock, flags);
return 1;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Handle the ICMPv6 packet. First validate the message format, then, according to the message types, process it as an informational packet or an error packet. */ | EFI_STATUS Ip6IcmpHandle(IN IP6_SERVICE *IpSb, IN EFI_IP6_HEADER *Head, IN NET_BUF *Packet) | /* Handle the ICMPv6 packet. First validate the message format, then, according to the message types, process it as an informational packet or an error packet. */
EFI_STATUS Ip6IcmpHandle(IN IP6_SERVICE *IpSb, IN EFI_IP6_HEADER *Head, IN NET_BUF *Packet) | {
IP6_ICMP_HEAD Icmp;
UINT16 PseudoCheckSum;
UINT16 CheckSum;
if (Packet->TotalSize < sizeof (Icmp)) {
goto DROP;
}
NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *)&Icmp);
PseudoCheckSum = NetIp6PseudoHeadChecksum (
&Head->SourceAddress,
&Head->DestinationAddress,
IP6_ICMP,
Packet->TotalSize
);
CheckSum = (UINT16) ~NetAddChecksum (PseudoCheckSum, NetbufChecksum (Packet));
if (CheckSum != 0) {
goto DROP;
}
if (Icmp.Type <= ICMP_V6_ERROR_MAX) {
return Ip6ProcessIcmpError (IpSb, Head, Packet);
} else {
return Ip6ProcessIcmpInformation (IpSb, Head, Packet);
}
DROP:
NetbufFree (Packet);
return EFI_INVALID_PARAMETER;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Returns: #TRUE on success or #FALSE on error. */ | gboolean g_file_enumerator_close(GFileEnumerator *enumerator, GCancellable *cancellable, GError **error) | /* Returns: #TRUE on success or #FALSE on error. */
gboolean g_file_enumerator_close(GFileEnumerator *enumerator, GCancellable *cancellable, GError **error) | {
GFileEnumeratorClass *class;
g_return_val_if_fail (G_IS_FILE_ENUMERATOR (enumerator), FALSE);
g_return_val_if_fail (enumerator != NULL, FALSE);
class = G_FILE_ENUMERATOR_GET_CLASS (enumerator);
if (enumerator->priv->closed)
return TRUE;
if (enumerator->priv->pending)
{
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_PENDING,
_("File enumerator has outstanding operation"));
return FALSE;
}
if (cancellable)
g_cancellable_push_current (cancellable);
enumerator->priv->pending = TRUE;
(* class->close_fn) (enumerator, cancellable, error);
enumerator->priv->pending = FALSE;
enumerator->priv->closed = TRUE;
if (cancellable)
g_cancellable_pop_current (cancellable);
return TRUE;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Submit data based on the input Setting level (Form, FormSet or System). */ | EFI_STATUS SubmitForm(IN FORM_BROWSER_FORMSET *FormSet, IN FORM_BROWSER_FORM *Form, IN BROWSER_SETTING_SCOPE SettingScope) | /* Submit data based on the input Setting level (Form, FormSet or System). */
EFI_STATUS SubmitForm(IN FORM_BROWSER_FORMSET *FormSet, IN FORM_BROWSER_FORM *Form, IN BROWSER_SETTING_SCOPE SettingScope) | {
EFI_STATUS Status;
switch (SettingScope) {
case FormLevel:
Status = SubmitForForm (FormSet, Form);
break;
case FormSetLevel:
Status = SubmitForFormSet (FormSet, FALSE);
break;
case SystemLevel:
Status = SubmitForSystem ();
break;
default:
Status = EFI_UNSUPPORTED;
break;
}
return Status;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). If StartBit is greater than 15, then ASSERT(). If EndBit is greater than 15, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */ | UINT16 EFIAPI PciExpressBitFieldOr16(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 OrData) | /* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). If StartBit is greater than 15, then ASSERT(). If EndBit is greater than 15, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT16 EFIAPI PciExpressBitFieldOr16(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 OrData) | {
ASSERT_INVALID_PCI_ADDRESS (Address);
return MmioBitFieldOr16 (
(UINTN)GetPciExpressBaseAddress () + Address,
StartBit,
EndBit,
OrData
);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Create instances of net_device and wl_private for the new adapter and register the device's entry points in the net_device structure. */ | struct net_device* et131x_device_alloc(void) | /* Create instances of net_device and wl_private for the new adapter and register the device's entry points in the net_device structure. */
struct net_device* et131x_device_alloc(void) | {
struct net_device *netdev;
netdev = alloc_etherdev(sizeof(struct et131x_adapter));
if (netdev == NULL) {
printk(KERN_ERR "et131x: Alloc of net_device struct failed\n");
return NULL;
}
netdev->watchdog_timeo = ET131X_TX_TIMEOUT;
netdev->netdev_ops = &et131x_netdev_ops;
return netdev;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* destroy the lock manager thread if it's running */ | void __exit afs_kill_lock_manager(void) | /* destroy the lock manager thread if it's running */
void __exit afs_kill_lock_manager(void) | {
if (afs_lock_manager)
destroy_workqueue(afs_lock_manager);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Set the sensor's acceleration offset (per axis). Use bma4xx_commit_nvm() to save these offsets to nonvolatile memory so they are automatically set during power-on-reset. */ | static int bma4xx_attr_set_odr(const struct device *dev, const struct sensor_value *val) | /* Set the sensor's acceleration offset (per axis). Use bma4xx_commit_nvm() to save these offsets to nonvolatile memory so they are automatically set during power-on-reset. */
static int bma4xx_attr_set_odr(const struct device *dev, const struct sensor_value *val) | {
struct bma4xx_data *bma4xx = dev->data;
int status;
uint8_t reg_val;
status = bma4xx_odr_to_reg(val->val1 * 1000000 + val->val2, ®_val);
if (status < 0) {
return status;
}
status = bma4xx->hw_ops->update_reg(dev, BMA4XX_REG_ACCEL_CONFIG, BMA4XX_MASK_ACC_CONF_ODR,
reg_val);
if (status < 0) {
return status;
}
bma4xx->accel_odr = reg_val;
return 0;
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Get maximum priority value for a given policy.
See IEEE 1003.1 */ | int sched_get_priority_max(int policy) | /* Get maximum priority value for a given policy.
See IEEE 1003.1 */
int sched_get_priority_max(int policy) | {
if (IS_ENABLED(CONFIG_COOP_ENABLED) && policy == SCHED_FIFO) {
return CONFIG_NUM_COOP_PRIORITIES - 1;
} else if (IS_ENABLED(CONFIG_PREEMPT_ENABLED) &&
(policy == SCHED_RR || policy == SCHED_OTHER)) {
return CONFIG_NUM_PREEMPT_PRIORITIES - 1;
}
errno = EINVAL;
return -1;
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Removes one #GHook from a #GHookList, marking it inactive and calling g_hook_unref() on it. */ | void g_hook_destroy_link(GHookList *hook_list, GHook *hook) | /* Removes one #GHook from a #GHookList, marking it inactive and calling g_hook_unref() on it. */
void g_hook_destroy_link(GHookList *hook_list, GHook *hook) | {
g_return_if_fail (hook_list != NULL);
g_return_if_fail (hook != NULL);
hook->flags &= ~G_HOOK_FLAG_ACTIVE;
if (hook->hook_id)
{
hook->hook_id = 0;
g_hook_unref (hook_list, hook);
}
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* This function reads proximity by ap3216c sensor measurement */ | uint16_t ap3216c_read_ps_data(void) | /* This function reads proximity by ap3216c sensor measurement */
uint16_t ap3216c_read_ps_data(void) | {
uint16_t proximity = 0;
uint32_t read_data;
read_data = read_low_and_high(AP3216C_PS_DATA_L_REG, 1);
if (1 == ((read_data >> 6) & 0x01 || (read_data >> 14) & 0x01)) {
return proximity =
55555;
}
proximity =
(read_data & 0x000f) + (((read_data >> 8) & 0x3f)
<< 4);
proximity |= read_data & 0x8000;
return proximity;
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Converts a text device path node to USB CDC Control device path structure. */ | EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextUsbCDCControl(IN CHAR16 *TextDeviceNode) | /* Converts a text device path node to USB CDC Control device path structure. */
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextUsbCDCControl(IN CHAR16 *TextDeviceNode) | {
USB_CLASS_TEXT UsbClassText;
UsbClassText.ClassExist = FALSE;
UsbClassText.Class = USB_CLASS_CDCCONTROL;
UsbClassText.SubClassExist = TRUE;
return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Sets the timer load value for a 64-bit timer. */ | void TimerLoadSet64(unsigned long ulBase, unsigned long long ullValue) | /* Sets the timer load value for a 64-bit timer. */
void TimerLoadSet64(unsigned long ulBase, unsigned long long ullValue) | {
ASSERT(TimerBaseValid(ulBase));
HWREG(ulBase + TIMER_O_TBILR) = ullValue >> 32;
HWREG(ulBase + TIMER_O_TAILR) = ullValue & 0xffffffff;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Gets the number of bits transferred per frame. */ | unsigned char SPIBitLengthGet(unsigned long ulBase) | /* Gets the number of bits transferred per frame. */
unsigned char SPIBitLengthGet(unsigned long ulBase) | {
xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE));
return ((xHWREG(ulBase + SPI_CNTRL) & SPI_CNTRL_TX_BIT_LEN_M)
>> SPI_CNTRL_TX_BIT_LEN_S);
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* Integer division; return 'm // n', that is, floor(m/n). C division truncates its result (rounds towards zero). 'floor(q) == trunc(q)' when 'q >= 0' or when 'q' is integer, otherwise 'floor(q) == trunc(q) - 1'. */ | lua_Integer luaV_div(lua_State *L, lua_Integer m, lua_Integer n) | /* Integer division; return 'm // n', that is, floor(m/n). C division truncates its result (rounds towards zero). 'floor(q) == trunc(q)' when 'q >= 0' or when 'q' is integer, otherwise 'floor(q) == trunc(q) - 1'. */
lua_Integer luaV_div(lua_State *L, lua_Integer m, lua_Integer n) | {
if (n == 0)
luaG_runerror(L, "attempt to divide by zero");
return intop(-, 0, m);
}
else {
lua_Integer q = m / n;
if ((m ^ n) < 0 && m % n != 0)
q -= 1;
return q;
}
} | nodemcu/nodemcu-firmware | C++ | MIT License | 7,566 |
/* Atomically swap in the new signal mask, and wait for a signal. */ | asmlinkage int sys_sigsuspend(old_sigset_t mask, unsigned long r5, unsigned long r6, unsigned long r7, struct pt_regs __regs) | /* Atomically swap in the new signal mask, and wait for a signal. */
asmlinkage int sys_sigsuspend(old_sigset_t mask, unsigned long r5, unsigned long r6, unsigned long r7, struct pt_regs __regs) | {
mask &= _BLOCKABLE;
spin_lock_irq(¤t->sighand->siglock);
current->saved_sigmask = current->blocked;
siginitset(¤t->blocked, mask);
recalc_sigpending();
spin_unlock_irq(¤t->sighand->siglock);
current->state = TASK_INTERRUPTIBLE;
schedule();
set_restore_sigmask();
return -ERESTARTNOHAND;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* This function handles the command when it is invoked in the shell. */ | SHELL_STATUS EFIAPI VarPolicyCommandHandler(IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This, IN EFI_SYSTEM_TABLE *SystemTable, IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters, IN EFI_SHELL_PROTOCOL *Shell) | /* This function handles the command when it is invoked in the shell. */
SHELL_STATUS EFIAPI VarPolicyCommandHandler(IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This, IN EFI_SYSTEM_TABLE *SystemTable, IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters, IN EFI_SHELL_PROTOCOL *Shell) | {
gEfiShellParametersProtocol = ShellParameters;
gEfiShellProtocol = Shell;
return RunVarPolicy (gImageHandle, SystemTable);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Try to recycle all the transmitted buffer address from SNP. */ | EFI_STATUS MnpRecycleTxBuf(IN OUT MNP_DEVICE_DATA *MnpDeviceData) | /* Try to recycle all the transmitted buffer address from SNP. */
EFI_STATUS MnpRecycleTxBuf(IN OUT MNP_DEVICE_DATA *MnpDeviceData) | {
UINT8 *TxBuf;
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
EFI_STATUS Status;
Snp = MnpDeviceData->Snp;
ASSERT (Snp != NULL);
do {
TxBuf = NULL;
Status = Snp->GetStatus (Snp, NULL, (VOID **)&TxBuf);
if (EFI_ERROR (Status)) {
return Status;
}
if (TxBuf != NULL) {
MnpFreeTxBuf (MnpDeviceData, TxBuf);
}
} while (TxBuf != NULL);
return EFI_SUCCESS;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned. */ | BOOLEAN EFIAPI ReportProgressCodeEnabled(VOID) | /* This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned. */
BOOLEAN EFIAPI ReportProgressCodeEnabled(VOID) | {
return (BOOLEAN)((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Message: LineStatReqMessage Opcode: 0x000b Type: RegistrationAndManagement Direction: dev2pbx VarLength: no */ | static void handle_LineStatReqMessage(ptvcursor_t *cursor, packet_info *pinfo _U_) | /* Message: LineStatReqMessage Opcode: 0x000b Type: RegistrationAndManagement Direction: dev2pbx VarLength: no */
static void handle_LineStatReqMessage(ptvcursor_t *cursor, packet_info *pinfo _U_) | {
ptvcursor_add(cursor, hf_skinny_lineNumber, 4, ENC_LITTLE_ENDIAN);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Function opens and returns a file handle to the root directory of a volume. */ | EFI_FILE_HANDLE LibOpenRoot(IN EFI_HANDLE DeviceHandle) | /* Function opens and returns a file handle to the root directory of a volume. */
EFI_FILE_HANDLE LibOpenRoot(IN EFI_HANDLE DeviceHandle) | {
EFI_STATUS Status;
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Volume;
EFI_FILE_HANDLE File;
File = NULL;
Status = gBS->HandleProtocol (
DeviceHandle,
&gEfiSimpleFileSystemProtocolGuid,
(VOID *)&Volume
);
if (!EFI_ERROR (Status)) {
Status = Volume->OpenVolume (
Volume,
&File
);
}
return EFI_ERROR (Status) ? NULL : File;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Example to clear an interrupt flag: code RTWDOG_ClearStatusFlags(wdog_base,kRTWDOG_InterruptFlag); endcode param base RTWDOG peripheral base address. param mask The status flags to clear. The parameter can be any combination of the following values: arg kRTWDOG_InterruptFlag */ | void RTWDOG_ClearStatusFlags(RTWDOG_Type *base, uint32_t mask) | /* Example to clear an interrupt flag: code RTWDOG_ClearStatusFlags(wdog_base,kRTWDOG_InterruptFlag); endcode param base RTWDOG peripheral base address. param mask The status flags to clear. The parameter can be any combination of the following values: arg kRTWDOG_InterruptFlag */
void RTWDOG_ClearStatusFlags(RTWDOG_Type *base, uint32_t mask) | {
if ((mask & (uint32_t)kRTWDOG_InterruptFlag) != 0U)
{
base->CS |= RTWDOG_CS_FLG_MASK;
}
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* 6.5.4.2. LAN Redundancy Put Information (Confirmed Service Id = 2) 6.5.4.2.1. Request Message Parameters */ | static void dissect_ff_msg_lr_put_info_req_lr_flags(tvbuff_t *tvb, gint offset, proto_tree *tree) | /* 6.5.4.2. LAN Redundancy Put Information (Confirmed Service Id = 2) 6.5.4.2.1. Request Message Parameters */
static void dissect_ff_msg_lr_put_info_req_lr_flags(tvbuff_t *tvb, gint offset, proto_tree *tree) | {
static const int * lan_flags[] = {
&hf_ff_lr_put_info_req_lr_flags_reserved,
&hf_ff_lr_put_info_req_lr_flags_load_balance,
&hf_ff_lr_put_info_req_lr_flags_diag,
&hf_ff_lr_put_info_req_lr_flags_multi_recv,
&hf_ff_lr_put_info_req_lr_flags_cross_cable,
&hf_ff_lr_put_info_req_lr_flags_multi_trans,
NULL
};
proto_tree_add_bitmask(tree, tvb, offset, hf_ff_lr_put_info_req_lr_flags, ett_ff_lr_put_info_req_lr_flags, lan_flags, ENC_BIG_ENDIAN);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* atkbd_cleanup() restores the keyboard state so that BIOS is happy after a reboot. */ | static void atkbd_cleanup(struct serio *serio) | /* atkbd_cleanup() restores the keyboard state so that BIOS is happy after a reboot. */
static void atkbd_cleanup(struct serio *serio) | {
struct atkbd *atkbd = serio_get_drvdata(serio);
atkbd_disable(atkbd);
ps2_command(&atkbd->ps2dev, NULL, ATKBD_CMD_RESET_DEF);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Enable DPLL automatic idle control. This automatic idle mode switching takes effect only when the DPLL is locked, at least on OMAP3430. The DPLL will enter low-power stop when its downstream clocks are gated. No return value. */ | void omap3_dpll_allow_idle(struct clk *clk) | /* Enable DPLL automatic idle control. This automatic idle mode switching takes effect only when the DPLL is locked, at least on OMAP3430. The DPLL will enter low-power stop when its downstream clocks are gated. No return value. */
void omap3_dpll_allow_idle(struct clk *clk) | {
const struct dpll_data *dd;
u32 v;
if (!clk || !clk->dpll_data)
return;
dd = clk->dpll_data;
v = __raw_readl(dd->autoidle_reg);
v &= ~dd->autoidle_mask;
v |= DPLL_AUTOIDLE_LOW_POWER_STOP << __ffs(dd->autoidle_mask);
__raw_writel(v, dd->autoidle_reg);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Allocates a RIO network structure, initializes per-network list heads, and adds the associated master port to the network list of associated master ports. Returns a RIO network pointer on success or NULL on failure. */ | static struct rio_net __devinit* rio_alloc_net(struct rio_mport *port) | /* Allocates a RIO network structure, initializes per-network list heads, and adds the associated master port to the network list of associated master ports. Returns a RIO network pointer on success or NULL on failure. */
static struct rio_net __devinit* rio_alloc_net(struct rio_mport *port) | {
struct rio_net *net;
net = kzalloc(sizeof(struct rio_net), GFP_KERNEL);
if (net) {
INIT_LIST_HEAD(&net->node);
INIT_LIST_HEAD(&net->devices);
INIT_LIST_HEAD(&net->mports);
list_add_tail(&port->nnode, &net->mports);
net->hport = port;
net->id = next_net++;
}
return net;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Writes Value to LCD CGRAM. Pointers internal to the LCD are also updated. */ | void halLcdDrawTextBlock(unsigned int Value) | /* Writes Value to LCD CGRAM. Pointers internal to the LCD are also updated. */
void halLcdDrawTextBlock(unsigned int Value) | {
int temp;
Draw_Block_Value_Macro[4] = Value >> 8;
Draw_Block_Value_Macro[5] = Value & 0xFF;
LCD_MEM[ LcdTableAddress ] = Value;
halLcdSendCommand(Draw_Block_Value_Macro);
LcdAddress++;
temp = LcdAddress >> 5;
temp = temp + (temp << 4);
LcdTableAddress = temp + (LcdAddress & 0x1F);
if ((LcdAddress & 0x1F) > 0x10)
halLcdSetAddress( (LcdAddress & 0xFFE0) + 0x20 );
if (LcdAddress >= LCD_Size)
halLcdSetAddress( 0 );
} | apopple/Pandaboard-FreeRTOS | C++ | null | 25 |
/* The task that receives messages posted to a queue by the higher priority timer interrupt. */ | static void prvHighFrequencyTimerTask(void *pvParameters) | /* The task that receives messages posted to a queue by the higher priority timer interrupt. */
static void prvHighFrequencyTimerTask(void *pvParameters) | {
( void ) pvParameters;
for( ;; )
{
xSemaphoreTake( xHighFrequencyTimerSemaphore, portMAX_DELAY );
ulHighFrequencyTaskIterations++;
}
} | apopple/Pandaboard-FreeRTOS | C++ | null | 25 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.