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 |
|---|---|---|---|---|---|---|---|
/* Visible (exported) allocation/free functions. Some of these are used just by xfs_alloc_btree.c and this file. Compute and fill in value of m_ag_maxlevels. */ | void xfs_alloc_compute_maxlevels(xfs_mount_t *mp) | /* Visible (exported) allocation/free functions. Some of these are used just by xfs_alloc_btree.c and this file. Compute and fill in value of m_ag_maxlevels. */
void xfs_alloc_compute_maxlevels(xfs_mount_t *mp) | {
int level;
uint maxblocks;
uint maxleafents;
int minleafrecs;
int minnoderecs;
maxleafents = (mp->m_sb.sb_agblocks + 1) / 2;
minleafrecs = mp->m_alloc_mnr[0];
minnoderecs = mp->m_alloc_mnr[1];
maxblocks = (maxleafents + minleafrecs - 1) / minleafrecs;
for (level = 1; maxblocks > 1; level++)
maxblocks = (maxblocks + minnoderecs - 1) / minnoderecs;
mp->m_ag_maxlevels = level;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This function will switch the IP4 configuration policy to Static. */ | EFI_STATUS IScsiSetIp4Policy(IN EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2) | /* This function will switch the IP4 configuration policy to Static. */
EFI_STATUS IScsiSetIp4Policy(IN EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2) | {
EFI_IP4_CONFIG2_POLICY Policy;
EFI_STATUS Status;
UINTN DataSize;
DataSize = sizeof (EFI_IP4_CONFIG2_POLICY);
Status = Ip4Config2->GetData (
Ip4Config2,
Ip4Config2DataTypePolicy,
&DataSize,
&Policy
);
if (EFI_ERROR (Status)) {
return Status;
}
if (Policy != Ip4Config2PolicyStatic) {
Policy = Ip4Config2PolicyStatic;
Status = Ip4Config2->SetData (
Ip4Config2,
Ip4Config2DataTypePolicy,
sizeof (EFI_IP4_CONFIG2_POLICY),
&Policy
);
if (EFI_ERROR (Status)) {
return Status;
}
}
return EFI_SUCCESS;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Description: Process a user generated VERSION message and respond accordingly. Returns zero on success, negative values on failure. */ | static int netlbl_mgmt_version(struct sk_buff *skb, struct genl_info *info) | /* Description: Process a user generated VERSION message and respond accordingly. Returns zero on success, negative values on failure. */
static int netlbl_mgmt_version(struct sk_buff *skb, struct genl_info *info) | {
int ret_val = -ENOMEM;
struct sk_buff *ans_skb = NULL;
void *data;
ans_skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (ans_skb == NULL)
return -ENOMEM;
data = genlmsg_put_reply(ans_skb, info, &netlbl_mgmt_gnl_family,
0, NLBL_MGMT_C_VERSION);
if (data == NULL)
goto version_failure;
ret_val = nla_put_u32(ans_skb,
NLBL_MGMT_A_VERSION,
NETLBL_PROTO_VERSION);
if (ret_val != 0)
goto version_failure;
genlmsg_end(ans_skb, data);
return genlmsg_reply(ans_skb, info);
version_failure:
kfree_skb(ans_skb);
return ret_val;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* If the conversion results in an overflow or an underflow condition, then Result is set to INT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */ | RETURN_STATUS EFIAPI SafeInt32ToInt16(IN INT32 Operand, OUT INT16 *Result) | /* If the conversion results in an overflow or an underflow condition, then Result is set to INT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeInt32ToInt16(IN INT32 Operand, OUT INT16 *Result) | {
RETURN_STATUS Status;
if (Result == NULL) {
return RETURN_INVALID_PARAMETER;
}
if ((Operand >= MIN_INT16) && (Operand <= MAX_INT16)) {
*Result = (INT16)Operand;
Status = RETURN_SUCCESS;
} else {
*Result = INT16_ERROR;
Status = RETURN_BUFFER_TOO_SMALL;
}
return Status;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Set the HTS221 humidity sensor output data rate. */ | int32_t HTS221_HUM_SetOutputDataRate(HTS221_Object_t *pObj, float Odr) | /* Set the HTS221 humidity sensor output data rate. */
int32_t HTS221_HUM_SetOutputDataRate(HTS221_Object_t *pObj, float Odr) | {
return HTS221_SetOutputDataRate(pObj, Odr);
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* Adjust the send queue or the retransmit queue. */ | INTN TcpAdjustSndQue(IN TCP_CB *Tcb, IN TCP_SEQNO Ack) | /* Adjust the send queue or the retransmit queue. */
INTN TcpAdjustSndQue(IN TCP_CB *Tcb, IN TCP_SEQNO Ack) | {
LIST_ENTRY *Head;
LIST_ENTRY *Cur;
NET_BUF *Node;
TCP_SEG *Seg;
Head = &Tcb->SndQue;
Cur = Head->ForwardLink;
while (Cur != Head) {
Node = NET_LIST_USER_STRUCT (Cur, NET_BUF, List);
Seg = TCPSEG_NETBUF (Node);
if (TCP_SEQ_GEQ (Seg->Seq, Ack)) {
break;
}
if (TCP_SEQ_LEQ (Seg->End, Ack)) {
Cur = Cur->ForwardLink;
RemoveEntryList (&Node->List);
NetbufFree (Node);
continue;
}
return TcpTrimSegment (Node, Ack, Seg->End);
}
return 1;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Disables multicast hash filtering. When disabled GMAC performs perfect destination address filtering for multicast frames, it compares DA field with the value programmed in DA register. */ | void synopGMAC_multicast_hash_filter_disable(synopGMACdevice *gmacdev) | /* Disables multicast hash filtering. When disabled GMAC performs perfect destination address filtering for multicast frames, it compares DA field with the value programmed in DA register. */
void synopGMAC_multicast_hash_filter_disable(synopGMACdevice *gmacdev) | {
synopGMACClearBits(gmacdev->MacBase, GmacFrameFilter, GmacMcastHashFilter);
return;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Set up a new emulator and add it to the list */ | static int espi_emul_init(const struct device *dev) | /* Set up a new emulator and add it to the list */
static int espi_emul_init(const struct device *dev) | {
struct espi_emul_data *data = dev->data;
sys_slist_init(&data->emuls);
return emul_init_for_bus(dev);
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* USBD_CCID_ReceiveCmdHeader Receive the Data from USB BulkOut Buffer to Pointer. */ | static uint8_t USBD_CCID_ReceiveCmdHeader(USBD_HandleTypeDef *pdev, uint8_t *pDst, uint16_t u8length) | /* USBD_CCID_ReceiveCmdHeader Receive the Data from USB BulkOut Buffer to Pointer. */
static uint8_t USBD_CCID_ReceiveCmdHeader(USBD_HandleTypeDef *pdev, uint8_t *pDst, uint16_t u8length) | {
USBD_CCID_HandleTypeDef *hccid = (USBD_CCID_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
uint8_t *pdst = pDst;
uint32_t Counter;
for (Counter = 0U; Counter < u8length; Counter++)
{
*pdst = hccid->data[Counter];
pdst++;
}
return (uint8_t)USBD_OK;
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* Walk through all installed network states and resend all transactions, which are old enough. */ | static void pohmelfs_trans_scan(struct work_struct *work) | /* Walk through all installed network states and resend all transactions, which are old enough. */
static void pohmelfs_trans_scan(struct work_struct *work) | {
struct pohmelfs_sb *psb =
container_of(work, struct pohmelfs_sb, dwork.work);
struct netfs_state *st;
struct pohmelfs_config *c;
mutex_lock(&psb->state_lock);
list_for_each_entry(c, &psb->state_list, config_entry) {
st = &c->state;
pohmelfs_trans_scan_state(st);
}
mutex_unlock(&psb->state_lock);
if (psb->trans_scan_timeout)
schedule_delayed_work(&psb->dwork, psb->trans_scan_timeout);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This function is executed in case of error occurrence. */ | static void Error_Handler(void) | /* This function is executed in case of error occurrence. */
static void Error_Handler(void) | {
BSP_LED_On(LED3);
while (1)
{
}
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* Enables or disables the I2C automatic end mode (stop condition is automatically sent when nbytes data are transferred). */ | void I2C_AutoEndCmd(I2C_TypeDef *I2Cx, FunctionalState NewState) | /* Enables or disables the I2C automatic end mode (stop condition is automatically sent when nbytes data are transferred). */
void I2C_AutoEndCmd(I2C_TypeDef *I2Cx, FunctionalState NewState) | {
assert_param(IS_I2C_ALL_PERIPH(I2Cx));
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
I2Cx->CR2 |= I2C_CR2_AUTOEND;
}
else
{
I2Cx->CR2 &= (uint32_t)~((uint32_t)I2C_CR2_AUTOEND);
}
} | ajhc/demo-cortex-m3 | C++ | null | 38 |
/* Returns: the @context that was passed in (since 2.6) */ | GMainContext* g_main_context_ref(GMainContext *context) | /* Returns: the @context that was passed in (since 2.6) */
GMainContext* g_main_context_ref(GMainContext *context) | {
g_return_val_if_fail (context != NULL, NULL);
g_return_val_if_fail (g_atomic_int_get (&context->ref_count) > 0, NULL);
g_atomic_int_inc (&context->ref_count);
return context;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* ‘s ’ Single step. addr is the Address at which to resume. If addr is omitted, resume at same Address. */ | VOID EFIAPI SingleStep(IN EFI_SYSTEM_CONTEXT SystemContext, IN CHAR8 *PacketData) | /* ‘s ’ Single step. addr is the Address at which to resume. If addr is omitted, resume at same Address. */
VOID EFIAPI SingleStep(IN EFI_SYSTEM_CONTEXT SystemContext, IN CHAR8 *PacketData) | {
if (PacketData[1] != '\0') {
SystemContext.SystemContextIa32->Eip = AsciiStrHexToUintn (&PacketData[1]);
}
AddSingleStep (SystemContext);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Checks to see if the address pointed to is either a 16-bit CALL instruction, or a 32-bit CALL instruction */ | static bool is_bfin_call(unsigned short *addr) | /* Checks to see if the address pointed to is either a 16-bit CALL instruction, or a 32-bit CALL instruction */
static bool is_bfin_call(unsigned short *addr) | {
unsigned short opcode = 0, *ins_addr;
ins_addr = (unsigned short *)addr;
if (!get_instruction(&opcode, ins_addr))
return false;
if ((opcode >= 0x0060 && opcode <= 0x0067) ||
(opcode >= 0x0070 && opcode <= 0x0077))
return true;
ins_addr--;
if (!get_instruction(&opcode, ins_addr))
return false;
if (opcode >= 0xE300 && opcode <= 0xE3FF)
return true;
return false;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Fills each TIM_ICInitStruct member with its default value. */ | void TIM_ICStructInit(TIM_ICInitTypeDef *TIM_ICInitStruct) | /* Fills each TIM_ICInitStruct member with its default value. */
void TIM_ICStructInit(TIM_ICInitTypeDef *TIM_ICInitStruct) | {
TIM_ICInitStruct->TIM_Channel = TIM_Channel_1;
TIM_ICInitStruct->TIM_ICPolarity = TIM_ICPolarity_Rising;
TIM_ICInitStruct->TIM_ICSelection = TIM_ICSelection_DirectTI;
TIM_ICInitStruct->TIM_ICPrescaler = TIM_ICPSC_DIV1;
TIM_ICInitStruct->TIM_ICFilter = 0x00;
} | gcallipo/RadioDSP-Stm32f103 | C++ | Common Creative - Attribution 3.0 | 51 |
/* Returns 1 if the joystick has been opened, or 0 if it has not. */ | int SDL_JoystickOpened(int device_index) | /* Returns 1 if the joystick has been opened, or 0 if it has not. */
int SDL_JoystickOpened(int device_index) | {
int i, opened;
opened = 0;
for ( i=0; SDL_joysticks[i]; ++i ) {
if ( SDL_joysticks[i]->index == (Uint8)device_index ) {
opened = 1;
break;
}
}
return(opened);
} | DC-SWAT/DreamShell | C++ | null | 404 |
/* Prints a character to the default console, at the supplied cursor position, using L"%c" format. */ | UINTN EFIAPI PrintCharAt(IN UINTN Column, IN UINTN Row, CHAR16 Character) | /* Prints a character to the default console, at the supplied cursor position, using L"%c" format. */
UINTN EFIAPI PrintCharAt(IN UINTN Column, IN UINTN Row, CHAR16 Character) | {
return PrintAt (0, Column, Row, L"%c", Character);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Determine if the data that at the ptr address with the length is len is empty. */ | u8 exFLASH_FindEmpty(u16 *ptr, u16 len) | /* Determine if the data that at the ptr address with the length is len is empty. */
u8 exFLASH_FindEmpty(u16 *ptr, u16 len) | {
u16 i;
for (i = 0; i < (len / 2); i++) {
if (*(ptr + i) != 0xffff)
return 0;
}
return 1;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Note: the caller must hold a reference to host. In case of failure, this reference will be released. */ | struct nlm_rqst* nlm_alloc_call(struct nlm_host *host) | /* Note: the caller must hold a reference to host. In case of failure, this reference will be released. */
struct nlm_rqst* nlm_alloc_call(struct nlm_host *host) | {
struct nlm_rqst *call;
for(;;) {
call = kzalloc(sizeof(*call), GFP_KERNEL);
if (call != NULL) {
atomic_set(&call->a_count, 1);
locks_init_lock(&call->a_args.lock.fl);
locks_init_lock(&call->a_res.lock.fl);
call->a_host = host;
return call;
}
if (signalled())
break;
printk("nlm_alloc_call: failed, waiting for memory\n");
schedule_timeout_interruptible(5*HZ);
}
nlm_release_host(host);
return NULL;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* ZigBee Device Profile dissector for the system server */ | void dissect_zbee_zdp_req_system_server_disc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) | /* ZigBee Device Profile dissector for the system server */
void dissect_zbee_zdp_req_system_server_disc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) | {
guint offset = 0; zdp_parse_server_flags(tree, ett_zbee_zdp_server, tvb, &offset);
zdp_dump_excess(tvb, offset, pinfo, tree);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* param src USB HS does not care about the clock source, here must be ref kCLOCK_UsbSrcUnused. param freq USB HS does not care about the clock source, so this parameter is ignored. retval true The clock is set successfully. retval false The clock source is invalid to get proper USB HS clock. */ | bool CLOCK_EnableUsbhs0Clock(clock_usb_src_t src, uint32_t freq) | /* param src USB HS does not care about the clock source, here must be ref kCLOCK_UsbSrcUnused. param freq USB HS does not care about the clock source, so this parameter is ignored. retval true The clock is set successfully. retval false The clock source is invalid to get proper USB HS clock. */
bool CLOCK_EnableUsbhs0Clock(clock_usb_src_t src, uint32_t freq) | {
CCM->CCGR6 |= CCM_CCGR6_CG0_MASK;
USB1->USBCMD |= USBHS_USBCMD_RST_MASK;
for (volatile uint32_t i = 0; i < 400000;
i++)
{
__ASM("nop");
}
PMU->REG_3P0 = (PMU->REG_3P0 & (~PMU_REG_3P0_OUTPUT_TRG_MASK)) |
(PMU_REG_3P0_OUTPUT_TRG(0x17) | PMU_REG_3P0_ENABLE_LINREG_MASK);
return true;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* returns: 1 if image is of given os type 0 otherwise (or on error) */ | int fit_image_check_os(const void *fit, int noffset, uint8_t os) | /* returns: 1 if image is of given os type 0 otherwise (or on error) */
int fit_image_check_os(const void *fit, int noffset, uint8_t os) | {
uint8_t image_os;
if (fit_image_get_os(fit, noffset, &image_os))
return 0;
return (os == image_os);
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Allocate buffer hash table for a given target. For devices containing metadata (i.e. not the log/realtime devices) we need to allocate a much larger hash table. */ | STATIC void xfs_alloc_bufhash(xfs_buftarg_t *btp, int external) | /* Allocate buffer hash table for a given target. For devices containing metadata (i.e. not the log/realtime devices) we need to allocate a much larger hash table. */
STATIC void xfs_alloc_bufhash(xfs_buftarg_t *btp, int external) | {
unsigned int i;
btp->bt_hashshift = external ? 3 : 8;
btp->bt_hashmask = (1 << btp->bt_hashshift) - 1;
btp->bt_hash = kmem_zalloc((1 << btp->bt_hashshift) *
sizeof(xfs_bufhash_t), KM_SLEEP | KM_LARGE);
for (i = 0; i < (1 << btp->bt_hashshift); i++) {
spin_lock_init(&btp->bt_hash[i].bh_lock);
INIT_LIST_HEAD(&btp->bt_hash[i].bh_list);
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Wrapper function to implement mS based delay for USB functions. */ | void USBDelay(uint32_t ui32Delay) | /* Wrapper function to implement mS based delay for USB functions. */
void USBDelay(uint32_t ui32Delay) | {
DELAY_US(ui32Delay*1000);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* pxa_udc_get_frame - Returns usb frame number @_gadget: usb gadget */ | static int pxa_udc_get_frame(struct usb_gadget *_gadget) | /* pxa_udc_get_frame - Returns usb frame number @_gadget: usb gadget */
static int pxa_udc_get_frame(struct usb_gadget *_gadget) | {
struct pxa_udc *udc = to_gadget_udc(_gadget);
return (udc_readl(udc, UDCFNR) & 0x7ff);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Maximum duration is the maximum time of an over threshold signal detection to be recognized as a tap event. The default value of these bits is 00b which corresponds to 4*ODR_XL time. If the SHOCK bits are set to a different value, 1LSB corresponds to 8*ODR_XL time.. */ | int32_t lsm6dso_tap_shock_get(lsm6dso_ctx_t *ctx, uint8_t *val) | /* Maximum duration is the maximum time of an over threshold signal detection to be recognized as a tap event. The default value of these bits is 00b which corresponds to 4*ODR_XL time. If the SHOCK bits are set to a different value, 1LSB corresponds to 8*ODR_XL time.. */
int32_t lsm6dso_tap_shock_get(lsm6dso_ctx_t *ctx, uint8_t *val) | {
lsm6dso_int_dur2_t reg;
int32_t ret;
ret = lsm6dso_read_reg(ctx, LSM6DSO_INT_DUR2, (uint8_t*)®, 1);
*val = reg.shock;
return ret;
} | alexander-g-dean/ESF | C++ | null | 41 |
/* Perform basic hardware initialization.
Initialize the interrupt controller device drivers. Also initialize the counter device driver, if required. */ | static int mcimx6x_m4_init(void) | /* Perform basic hardware initialization.
Initialize the interrupt controller device drivers. Also initialize the counter device driver, if required. */
static int mcimx6x_m4_init(void) | {
SOC_RdcInit();
WDOG_DisablePowerdown(WDOG3);
SOC_CacheInit();
SOC_ClockInit();
return 0;
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* sys_pipe() is the normal C calling standard for creating a pipe. It's not the way Unix traditionally does this, though. */ | SYSCALL_DEFINE2(pipe2, int __user *, fildes, int, flags) | /* sys_pipe() is the normal C calling standard for creating a pipe. It's not the way Unix traditionally does this, though. */
SYSCALL_DEFINE2(pipe2, int __user *, fildes, int, flags) | {
int fd[2];
int error;
error = do_pipe_flags(fd, flags);
if (!error) {
if (copy_to_user(fildes, fd, sizeof(fd))) {
sys_close(fd[0]);
sys_close(fd[1]);
error = -EFAULT;
}
}
return error;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Helper for converting m/s^2 offset values into register values. */ | static int bma4xx_offset_to_reg_val(const struct sensor_value *val, uint8_t *reg_val) | /* Helper for converting m/s^2 offset values into register values. */
static int bma4xx_offset_to_reg_val(const struct sensor_value *val, uint8_t *reg_val) | {
int32_t ug = sensor_ms2_to_ug(val);
if (ug < BMA4XX_OFFSET_MICROG_MIN || ug > BMA4XX_OFFSET_MICROG_MAX) {
return -ERANGE;
}
*reg_val = ug / BMA4XX_OFFSET_MICROG_PER_BIT;
return 0;
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* This function will set network interface device gateway address. */ | int netdev_set_gw(struct netdev *netdev, const ip_addr_t *gw) | /* This function will set network interface device gateway address. */
int netdev_set_gw(struct netdev *netdev, const ip_addr_t *gw) | {
RT_ASSERT(netdev);
RT_ASSERT(gw);
if (!netdev->ops || !netdev->ops->set_addr_info)
{
LOG_E("The network interface device(%s) not support to set gateway address.", netdev->name);
return -RT_ERROR;
}
if (netdev_is_dhcp_enabled(netdev))
{
LOG_E("The network interface device(%s) DHCP capability is enable, not support set gateway address.", netdev->name);
return -RT_ERROR;
}
return netdev->ops->set_addr_info(netdev, RT_NULL, RT_NULL, (ip_addr_t *)gw);
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* Check whether USB keyboard driver supports this device. */ | EFI_STATUS EFIAPI USBKeyboardDriverBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath) | /* Check whether USB keyboard driver supports this device. */
EFI_STATUS EFIAPI USBKeyboardDriverBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath) | {
EFI_STATUS Status;
EFI_USB_IO_PROTOCOL *UsbIo;
Status = gBS->OpenProtocol (
Controller,
&gEfiUsbIoProtocolGuid,
(VOID **)&UsbIo,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (EFI_ERROR (Status)) {
return Status;
}
Status = EFI_SUCCESS;
if (!IsUSBKeyboard (UsbIo)) {
Status = EFI_UNSUPPORTED;
}
gBS->CloseProtocol (
Controller,
&gEfiUsbIoProtocolGuid,
This->DriverBindingHandle,
Controller
);
return Status;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Convert the multibyte field in IP header's byter order. In spite of its name, it can also be used to convert from host to network byte order. */ | IP4_HEAD* Ip4NtohHead(IN IP4_HEAD *Head) | /* Convert the multibyte field in IP header's byter order. In spite of its name, it can also be used to convert from host to network byte order. */
IP4_HEAD* Ip4NtohHead(IN IP4_HEAD *Head) | {
Head->TotalLen = NTOHS (Head->TotalLen);
Head->Id = NTOHS (Head->Id);
Head->Fragment = NTOHS (Head->Fragment);
Head->Src = NTOHL (Head->Src);
Head->Dst = NTOHL (Head->Dst);
return Head;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Performs an atomic increment of the 32-bit unsigned integer specified by Value and returns the incremented value. The increment operation must be performed using MP safe mechanisms. */ | UINT32 EFIAPI InternalSyncIncrement(IN volatile UINT32 *Value) | /* Performs an atomic increment of the 32-bit unsigned integer specified by Value and returns the incremented value. The increment operation must be performed using MP safe mechanisms. */
UINT32 EFIAPI InternalSyncIncrement(IN volatile UINT32 *Value) | {
UINT32 Result;
__asm__ __volatile__ (
"movl $1, %%eax \n\t"
"lock \n\t"
"xadd %%eax, %1 \n\t"
"inc %%eax \n\t"
: "=&a" (Result),
"+m" (*Value)
:
: "memory",
"cc"
);
return Result;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Check if it is the first-acknowledging core to the common interrupt if IDU is programmed in the first-acknowledged mode */ | uint32_t z_arc_connect_idu_check_first(uint32_t irq_num) | /* Check if it is the first-acknowledging core to the common interrupt if IDU is programmed in the first-acknowledged mode */
uint32_t z_arc_connect_idu_check_first(uint32_t irq_num) | {
uint32_t ret = 0;
K_SPINLOCK(&arc_connect_spinlock) {
z_arc_connect_cmd(ARC_CONNECT_CMD_IDU_CHECK_FIRST, irq_num);
ret = z_arc_connect_cmd_readback();
}
return ret;
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* if bssid != NULL its looking for a beacon frame */ | int attack_check(unsigned char *bssid, char *essid, unsigned char *capa, struct wif *wi) | /* if bssid != NULL its looking for a beacon frame */
int attack_check(unsigned char *bssid, char *essid, unsigned char *capa, struct wif *wi) | {
int ap_chan=0, iface_chan=0;
iface_chan = wi_get_channel(wi);
if(bssid != NULL)
{
ap_chan = wait_for_beacon(bssid, capa, essid);
if(ap_chan < 0)
{
PCT; printf("No such BSSID available.\n");
return -1;
}
if(ap_chan != iface_chan)
{
PCT; printf("%s is on channel %d, but the AP uses channel %d\n", wi_get_ifname(wi), iface_chan, ap_chan);
return -1;
}
}
return 0;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Do the ECDHE key exchange (part 2: computation of the shared secret from the point sent by the client). */ | static void do_ecdhe_part2(br_ssl_server_context *ctx, int prf_id, unsigned char *cpoint, size_t cpoint_len) | /* Do the ECDHE key exchange (part 2: computation of the shared secret from the point sent by the client). */
static void do_ecdhe_part2(br_ssl_server_context *ctx, int prf_id, unsigned char *cpoint, size_t cpoint_len) | {
int curve;
uint32_t ctl;
size_t xoff, xlen;
curve = ctx->eng.ecdhe_curve;
ctl = ctx->eng.iec->mul(cpoint, cpoint_len,
ctx->ecdhe_key, ctx->ecdhe_key_len, curve);
xoff = ctx->eng.iec->xoff(curve, &xlen);
ecdh_common(ctx, prf_id, cpoint + xoff, xlen, ctl);
memset(ctx->ecdhe_key, 0, ctx->ecdhe_key_len);
} | RavenSystem/esp-homekit-devices | C++ | Other | 2,577 |
/* DAC960_V1_ExecuteType3 executes a DAC960 V1 Firmware Controller Type 3 Command and waits for completion. It returns true on success and false on failure. */ | static bool DAC960_V1_ExecuteType3(DAC960_Controller_T *Controller, DAC960_V1_CommandOpcode_T CommandOpcode, dma_addr_t DataDMA) | /* DAC960_V1_ExecuteType3 executes a DAC960 V1 Firmware Controller Type 3 Command and waits for completion. It returns true on success and false on failure. */
static bool DAC960_V1_ExecuteType3(DAC960_Controller_T *Controller, DAC960_V1_CommandOpcode_T CommandOpcode, dma_addr_t DataDMA) | {
DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
DAC960_V1_CommandStatus_T CommandStatus;
DAC960_V1_ClearCommand(Command);
Command->CommandType = DAC960_ImmediateCommand;
CommandMailbox->Type3.CommandOpcode = CommandOpcode;
CommandMailbox->Type3.BusAddress = DataDMA;
DAC960_ExecuteCommand(Command);
CommandStatus = Command->V1.CommandStatus;
DAC960_DeallocateCommand(Command);
return (CommandStatus == DAC960_V1_NormalCompletion);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Exit parking mode, the channel will return to circular buffer mode */ | void XAxiVdma_StopParking(XAxiVdma *InstancePtr, u16 Direction) | /* Exit parking mode, the channel will return to circular buffer mode */
void XAxiVdma_StopParking(XAxiVdma *InstancePtr, u16 Direction) | {
XAxiVdma_Channel *Channel;
Channel = XAxiVdma_GetChannel(InstancePtr, Direction);
if (!Channel) {
return;
}
if (Channel->IsValid) {
XAxiVdma_ChannelStopParking(Channel);
}
return;
} | ua1arn/hftrx | C++ | null | 69 |
/* This is just needed to hard-code the address and size cell counts. 'fhc' and 'central' nodes lack the #address-cells and #size-cells properties, and if you walk to the root on such Enterprise boxes all you'll get is a #size-cells of 2 which is not what we want to use. */ | static int of_bus_fhc_match(struct device_node *np) | /* This is just needed to hard-code the address and size cell counts. 'fhc' and 'central' nodes lack the #address-cells and #size-cells properties, and if you walk to the root on such Enterprise boxes all you'll get is a #size-cells of 2 which is not what we want to use. */
static int of_bus_fhc_match(struct device_node *np) | {
return !strcmp(np->name, "fhc") ||
!strcmp(np->name, "central");
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* nt_password_hash_encrypted_with_block - NtPasswordHashEncryptedWithBlock() - RFC 2759, Sect 8.13 @password_hash: 16-octer PasswordHash (IN) @block: 16-octet Block (IN) @cypher: 16-octer Cypher (OUT) */ | void nt_password_hash_encrypted_with_block(const u8 *password_hash, const u8 *block, u8 *cypher) | /* nt_password_hash_encrypted_with_block - NtPasswordHashEncryptedWithBlock() - RFC 2759, Sect 8.13 @password_hash: 16-octer PasswordHash (IN) @block: 16-octet Block (IN) @cypher: 16-octer Cypher (OUT) */
void nt_password_hash_encrypted_with_block(const u8 *password_hash, const u8 *block, u8 *cypher) | {
des_encrypt(password_hash, block, cypher);
des_encrypt(password_hash + 8, block + 7, cypher + 8);
} | retro-esp32/RetroESP32 | C++ | Creative Commons Attribution Share Alike 4.0 International | 581 |
/* Allocates and initializes one RSA context for subsequent use. */ | VOID* EFIAPI RsaNew(VOID) | /* Allocates and initializes one RSA context for subsequent use. */
VOID* EFIAPI RsaNew(VOID) | {
VOID *RsaContext;
RsaContext = AllocateZeroPool (sizeof (mbedtls_rsa_context));
if (RsaContext == NULL) {
return RsaContext;
}
mbedtls_rsa_init (RsaContext);
if (mbedtls_rsa_set_padding (RsaContext, MBEDTLS_RSA_PKCS_V15, MBEDTLS_MD_NONE) != 0) {
return NULL;
}
return RsaContext;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Un-Register the Service B.1 and all its Characteristics... */ | void service_b_1_1_remove(void) | /* Un-Register the Service B.1 and all its Characteristics... */
void service_b_1_1_remove(void) | {
bt_gatt_service_unregister(&service_b_1_1_svc);
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Read data from Rx registers.
This function replaces the original SSIDataNonBlockingGet() API and performs the same actions. A macro is provided in */ | unsigned long SPIRxRegisterGet(unsigned long ulBase, unsigned long *pulData, unsigned long ulCount) | /* Read data from Rx registers.
This function replaces the original SSIDataNonBlockingGet() API and performs the same actions. A macro is provided in */
unsigned long SPIRxRegisterGet(unsigned long ulBase, unsigned long *pulData, unsigned long ulCount) | {
unsigned long i;
xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE));
xASSERT(ulCount < 2);
for (i=0; i<ulCount; i++)
{
pulData[i] = xHWREG(ulBase + SPI_RX0 + 4*i);
}
return ulCount;
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* Optimised routine to draw a horizontal line faster than setting individual pixels. */ | void lcdDrawHLine(uint16_t x0, uint16_t x1, uint16_t y, uint16_t color) | /* Optimised routine to draw a horizontal line faster than setting individual pixels. */
void lcdDrawHLine(uint16_t x0, uint16_t x1, uint16_t y, uint16_t color) | {
uint16_t x, pixels;
if (x1 < x0)
{
x = x1;
x1 = x0;
x0 = x;
}
if (x1 >= lcdGetWidth())
{
x1 = lcdGetWidth() - 1;
}
if (x0 >= lcdGetWidth())
{
x0 = lcdGetWidth() - 1;
}
ili9325SetCursor(x0, y);
ili9325WriteCmd(ILI9325_COMMANDS_WRITEDATATOGRAM);
for (pixels = 0; pixels < x1 - x0 + 1; pixels++)
{
ili9325WriteData(color);
}
} | microbuilder/LPC1343CodeBase | C++ | Other | 73 |
/* Check the status of the Rx buffer of the specified SPI port. */ | xtBoolean SPIIsRxEmpty(unsigned long ulBase) | /* Check the status of the Rx buffer of the specified SPI port. */
xtBoolean SPIIsRxEmpty(unsigned long ulBase) | {
xASSERT(ulBase == SPI0_BASE);
return ((xHWREG(ulBase + SPI_CNTRL) & SPI_CNTRL_RX_EMPTY)? xtrue : xfalse);
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* audit_socketcall - record audit data for sys_socketcall @nargs: number of args @args: args array */ | void audit_socketcall(int nargs, unsigned long *args) | /* audit_socketcall - record audit data for sys_socketcall @nargs: number of args @args: args array */
void audit_socketcall(int nargs, unsigned long *args) | {
struct audit_context *context = current->audit_context;
if (likely(!context || context->dummy))
return;
context->type = AUDIT_SOCKETCALL;
context->socketcall.nargs = nargs;
memcpy(context->socketcall.args, args, nargs * sizeof(unsigned long));
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Set lptimer counter Compare Value.
Set the timer compare value. Must only be set with timer enabled. */ | void lptimer_set_compare(uint32_t lptimer_peripheral, uint16_t compare_value) | /* Set lptimer counter Compare Value.
Set the timer compare value. Must only be set with timer enabled. */
void lptimer_set_compare(uint32_t lptimer_peripheral, uint16_t compare_value) | {
LPTIM_CMP(lptimer_peripheral) = compare_value;
} | libopencm3/libopencm3 | C++ | GNU General Public License v3.0 | 2,931 |
/* Check if a point is on an area */ | bool lv_area_is_point_on(const lv_area_t *a_p, const lv_point_t *p_p) | /* Check if a point is on an area */
bool lv_area_is_point_on(const lv_area_t *a_p, const lv_point_t *p_p) | {
bool is_on = false;
if((p_p->x >= a_p->x1 && p_p->x <= a_p->x2) &&
((p_p->y >= a_p->y1 && p_p->y <= a_p->y2))) {
is_on = true;
}
return is_on;
} | RavenSystem/esp-homekit-devices | C++ | Other | 2,577 |
/* Returns true if this is a SATA controller */ | static int is_sata(ide_hwif_t *hwif) | /* Returns true if this is a SATA controller */
static int is_sata(ide_hwif_t *hwif) | {
return pdev_is_sata(to_pci_dev(hwif->dev));
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Select GPIO pins to be used by this peripheral.
This needs to be configured when no transaction is in progress. */ | void i2c_select_pins(uint32_t i2c, uint32_t scl_pin, uint32_t sda_pin) | /* Select GPIO pins to be used by this peripheral.
This needs to be configured when no transaction is in progress. */
void i2c_select_pins(uint32_t i2c, uint32_t scl_pin, uint32_t sda_pin) | {
if (scl_pin != GPIO_UNCONNECTED) {
I2C_PSELSCL(i2c) = __GPIO2PIN(scl_pin);
} else {
I2C_PSELSCL(i2c) = scl_pin;
}
if (sda_pin != GPIO_UNCONNECTED) {
I2C_PSELSDA(i2c) = __GPIO2PIN(sda_pin);
} else {
I2C_PSELSDA(i2c) = sda_pin;
}
} | libopencm3/libopencm3 | C++ | GNU General Public License v3.0 | 2,931 |
/* If Address > 0x0FFFFFFF, then ASSERT(). If StartBit is greater than 7, then ASSERT(). If EndBit is greater than 7, 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(). */ | UINT8 EFIAPI PciExpressBitFieldOr8(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 OrData) | /* If Address > 0x0FFFFFFF, then ASSERT(). If StartBit is greater than 7, then ASSERT(). If EndBit is greater than 7, 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(). */
UINT8 EFIAPI PciExpressBitFieldOr8(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 OrData) | {
if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {
return (UINT8)-1;
}
return MmioBitFieldOr8 (
GetPciExpressAddress (Address),
StartBit,
EndBit,
OrData
);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Returns: a "conversion descriptor", or (GIConv)-1 if opening the converter failed. */ | GIConv g_iconv_open(const gchar *to_codeset, const gchar *from_codeset) | /* Returns: a "conversion descriptor", or (GIConv)-1 if opening the converter failed. */
GIConv g_iconv_open(const gchar *to_codeset, const gchar *from_codeset) | {
iconv_t cd;
if (!try_conversion (to_codeset, from_codeset, &cd))
{
const char **to_aliases = _g_charset_get_aliases (to_codeset);
const char **from_aliases = _g_charset_get_aliases (from_codeset);
if (from_aliases)
{
const char **p = from_aliases;
while (*p)
{
if (try_conversion (to_codeset, *p, &cd))
goto out;
if (try_to_aliases (to_aliases, *p, &cd))
goto out;
p++;
}
}
if (try_to_aliases (to_aliases, from_codeset, &cd))
goto out;
}
out:
return (cd == (iconv_t)-1) ? (GIConv)-1 : (GIConv)cd;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Tells each device driver that IO ports, MMIO and config space I/O are now enabled. Collects up and merges the device driver responses. Cumulative response passed back in "userdata". */ | static int eeh_report_mmio_enabled(struct pci_dev *dev, void *userdata) | /* Tells each device driver that IO ports, MMIO and config space I/O are now enabled. Collects up and merges the device driver responses. Cumulative response passed back in "userdata". */
static int eeh_report_mmio_enabled(struct pci_dev *dev, void *userdata) | {
enum pci_ers_result rc, *res = userdata;
struct pci_driver *driver = dev->driver;
if (!driver ||
!driver->err_handler ||
!driver->err_handler->mmio_enabled)
return 0;
rc = driver->err_handler->mmio_enabled (dev);
if (rc == PCI_ERS_RESULT_NEED_RESET) *res = rc;
if (*res == PCI_ERS_RESULT_NONE) *res = rc;
return 0;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Combine final list merge with restoration of standard doubly-linked list structure. This approach duplicates code from merge(), but runs faster than the tidier alternatives of either a separate final prev-link restoration pass, or maintaining the prev links throughout. */ | static void merge_and_restore_back_links(void *priv, int(*cmp)(void *priv, struct list_head *a, struct list_head *b), struct list_head *head, struct list_head *a, struct list_head *b) | /* Combine final list merge with restoration of standard doubly-linked list structure. This approach duplicates code from merge(), but runs faster than the tidier alternatives of either a separate final prev-link restoration pass, or maintaining the prev links throughout. */
static void merge_and_restore_back_links(void *priv, int(*cmp)(void *priv, struct list_head *a, struct list_head *b), struct list_head *head, struct list_head *a, struct list_head *b) | {
struct list_head *tail = head;
while (a && b) {
if ((*cmp)(priv, a, b) <= 0) {
tail->next = a;
a->prev = tail;
a = a->next;
} else {
tail->next = b;
b->prev = tail;
b = b->next;
}
tail = tail->next;
}
tail->next = a ? : b;
do {
(*cmp)(priv, tail->next, tail->next);
tail->next->prev = tail;
tail = tail->next;
} while (tail->next);
tail->next = head;
head->prev = tail;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* This API writes fifo_flush command to command register.This action clears all data in the Fifo without changing fifo configuration settings. */ | int8_t bmi160_set_fifo_flush(const struct bmi160_dev *dev) | /* This API writes fifo_flush command to command register.This action clears all data in the Fifo without changing fifo configuration settings. */
int8_t bmi160_set_fifo_flush(const struct bmi160_dev *dev) | {
int8_t rslt = 0;
uint8_t data = BMI160_FIFO_FLUSH_VALUE;
uint8_t reg_addr = BMI160_COMMAND_REG_ADDR;
if (dev == NULL)
{
rslt = BMI160_E_NULL_PTR;
}
else
{
rslt = bmi160_set_regs(reg_addr, &data, BMI160_ONE, dev);
}
return rslt;
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* Gets the states of the DTR and RTS modem control signals. */ | unsigned long UARTModemControlGet(unsigned long ulBase) | /* Gets the states of the DTR and RTS modem control signals. */
unsigned long UARTModemControlGet(unsigned long ulBase) | {
ASSERT(!CLASS_IS_SANDSTORM && !CLASS_IS_FURY && !CLASS_IS_DUSTDEVIL);
ASSERT(ulBase == UART1_BASE);
return(HWREG(ulBase + UART_O_CTL) & (UART_OUTPUT_RTS | UART_OUTPUT_DTR));
} | watterott/WebRadio | C++ | null | 71 |
/* Reads PE internal data memory (DMEM) from the host through indirect access registers. */ | u32 pe_dmem_read(int id, u32 addr, u8 size) | /* Reads PE internal data memory (DMEM) from the host through indirect access registers. */
u32 pe_dmem_read(int id, u32 addr, u8 size) | {
u32 offset = addr & 0x3;
u32 mask = 0xffffffff >> ((4 - size) << 3);
u32 val;
addr = pe[id].dmem_base_addr | (addr & ~0x3) | PE_MEM_ACCESS_READ |
PE_MEM_ACCESS_DMEM | PE_MEM_ACCESS_BYTE_ENABLE(offset, size);
writel(addr, pe[id].mem_access_addr);
val = be32_to_cpu(readl(pe[id].mem_access_rdata));
return (val >> (offset << 3)) & mask;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Attempt to free all partial slabs on a node. */ | static void free_partial(struct kmem_cache *s, struct kmem_cache_node *n) | /* Attempt to free all partial slabs on a node. */
static void free_partial(struct kmem_cache *s, struct kmem_cache_node *n) | {
unsigned long flags;
struct page *page, *h;
spin_lock_irqsave(&n->list_lock, flags);
list_for_each_entry_safe(page, h, &n->partial, lru) {
if (!page->inuse) {
list_del(&page->lru);
discard_slab(s, page);
n->nr_partial--;
} else {
list_slab_objects(s, page,
"Objects remaining on kmem_cache_close()");
}
}
spin_unlock_irqrestore(&n->list_lock, flags);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Enables the uDMA requests in the SHA/MD5 module. */ | void SHAMD5DMAEnable(uint32_t ui32Base) | /* Enables the uDMA requests in the SHA/MD5 module. */
void SHAMD5DMAEnable(uint32_t ui32Base) | {
ASSERT(ui32Base == SHAMD5_BASE);
HWREG(ui32Base + SHAMD5_O_SYSCONFIG) |=
SHAMD5_SYSCONFIG_SADVANCED | SHAMD5_SYSCONFIG_DMA_EN;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* cancel_pending - cancel all pending works. @ubi: UBI device description object */ | static void cancel_pending(struct ubi_device *ubi) | /* cancel_pending - cancel all pending works. @ubi: UBI device description object */
static void cancel_pending(struct ubi_device *ubi) | {
while (!list_empty(&ubi->works)) {
struct ubi_work *wrk;
wrk = list_entry(ubi->works.next, struct ubi_work, list);
list_del(&wrk->list);
wrk->func(ubi, wrk, 1);
ubi->works_count -= 1;
ubi_assert(ubi->works_count >= 0);
}
} | EmcraftSystems/u-boot | C++ | Other | 181 |
/* param base The I3C peripheral base address. param ibiRule Pointer to store the read out ibi rule description. */ | void I3C_MasterGetIBIRules(I3C_Type *base, i3c_register_ibi_addr_t *ibiRule) | /* param base The I3C peripheral base address. param ibiRule Pointer to store the read out ibi rule description. */
void I3C_MasterGetIBIRules(I3C_Type *base, i3c_register_ibi_addr_t *ibiRule) | {
assert(NULL != ibiRule);
uint32_t ruleValue = base->MIBIRULES;
for (uint32_t count = 0; count < ARRAY_SIZE(ibiRule->address); count++)
{
ibiRule->address[count] =
(uint8_t)(ruleValue >> (count * I3C_MIBIRULES_ADDR1_SHIFT)) & I3C_MIBIRULES_ADDR0_MASK;
}
ibiRule->ibiHasPayload = (0U == (ruleValue & I3C_MIBIRULES_NOBYTE_MASK));
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* UBIFS is trying to account the space which might not be usable, and this space is called "dark space". For example, if an LEB has only %512 free bytes, it is dark space, because it cannot fit a large data node. */ | int ubifs_calc_dark(const struct ubifs_info *c, int spc) | /* UBIFS is trying to account the space which might not be usable, and this space is called "dark space". For example, if an LEB has only %512 free bytes, it is dark space, because it cannot fit a large data node. */
int ubifs_calc_dark(const struct ubifs_info *c, int spc) | {
ubifs_assert(!(spc & 7));
if (spc < c->dark_wm)
return spc;
if (spc - c->dark_wm < MIN_WRITE_SZ)
return spc - MIN_WRITE_SZ;
return c->dark_wm;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Serial polling transmit data routines, This function will transmit data in a continuous loop by one by one byte. */ | rt_ssize_t _serial_poll_tx(struct rt_device *dev, rt_off_t pos, const void *buffer, rt_size_t size) | /* Serial polling transmit data routines, This function will transmit data in a continuous loop by one by one byte. */
rt_ssize_t _serial_poll_tx(struct rt_device *dev, rt_off_t pos, const void *buffer, rt_size_t size) | {
struct rt_serial_device *serial;
rt_size_t putc_size;
rt_uint8_t *putc_buffer;
RT_ASSERT(dev != RT_NULL);
serial = (struct rt_serial_device *)dev;
RT_ASSERT(serial != RT_NULL);
putc_buffer = (rt_uint8_t *)buffer;
putc_size = size;
while (size)
{
if (serial->parent.open_flag & RT_DEVICE_FLAG_STREAM)
{
if (*putc_buffer == '\n')
serial->ops->putc(serial, '\r');
}
serial->ops->putc(serial, *putc_buffer);
++ putc_buffer;
-- size;
}
return putc_size - size;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* param base LPSPI peripheral base address. param handle pointer to lpspi_slave_edma_handle_t structure which stores the transfer state. param count Number of bytes transferred so far by the eDMA transaction. return status of status_t. */ | status_t LPSPI_SlaveTransferGetCountEDMA(LPSPI_Type *base, lpspi_slave_edma_handle_t *handle, size_t *count) | /* param base LPSPI peripheral base address. param handle pointer to lpspi_slave_edma_handle_t structure which stores the transfer state. param count Number of bytes transferred so far by the eDMA transaction. return status of status_t. */
status_t LPSPI_SlaveTransferGetCountEDMA(LPSPI_Type *base, lpspi_slave_edma_handle_t *handle, size_t *count) | {
assert(handle);
if (!count)
{
return kStatus_InvalidArgument;
}
if (handle->state != kLPSPI_Busy)
{
*count = 0;
return kStatus_NoTransferInProgress;
}
size_t remainingByte;
remainingByte =
(uint32_t)handle->nbytes * EDMA_GetRemainingMajorLoopCount(handle->edmaRxRegToRxDataHandle->base,
handle->edmaRxRegToRxDataHandle->channel);
*count = handle->totalByteCount - remainingByte;
return kStatus_Success;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Signals that the caller is done with processing a reception PDU. Should be called by a channel after receiving the TBX_MB_EVENT_ID_PDU_RECEIVED event and no longer needing access to the PDU stored in the transport layer context. */ | static void TbxMbRtuReceptionDone(tTbxMbTp transport) | /* Signals that the caller is done with processing a reception PDU. Should be called by a channel after receiving the TBX_MB_EVENT_ID_PDU_RECEIVED event and no longer needing access to the PDU stored in the transport layer context. */
static void TbxMbRtuReceptionDone(tTbxMbTp transport) | {
TBX_ASSERT(transport != NULL);
if (transport != NULL)
{
tTbxMbTpCtx * tpCtx = (tTbxMbTpCtx *)transport;
TBX_ASSERT(tpCtx->type == TBX_MB_RTU_CONTEXT_TYPE);
TbxCriticalSectionEnter();
uint8_t currentState = tpCtx->state;
TbxCriticalSectionExit();
TBX_ASSERT(currentState == TBX_MB_RTU_STATE_VALIDATION);
if (currentState == TBX_MB_RTU_STATE_VALIDATION)
{
TbxCriticalSectionEnter();
tpCtx->state = TBX_MB_RTU_STATE_IDLE;
TbxCriticalSectionExit();
}
}
} | feaser/openblt | C++ | GNU General Public License v3.0 | 601 |
/* Perform a single write to an MII 16bit register. Returns zero on success or -ETIMEDOUT if the PHY did not respond. */ | static int velocity_mii_write(struct mac_regs __iomem *regs, u8 mii_addr, u16 data) | /* Perform a single write to an MII 16bit register. Returns zero on success or -ETIMEDOUT if the PHY did not respond. */
static int velocity_mii_write(struct mac_regs __iomem *regs, u8 mii_addr, u16 data) | {
u16 ww;
safe_disable_mii_autopoll(regs);
writeb(mii_addr, ®s->MIIADR);
writew(data, ®s->MIIDATA);
BYTE_REG_BITS_ON(MIICR_WCMD, ®s->MIICR);
for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
udelay(5);
if (!(readb(®s->MIICR) & MIICR_WCMD))
break;
}
enable_mii_autopoll(regs);
if (ww == W_MAX_TIMEOUT)
return -ETIMEDOUT;
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This function disables programming of the powerdown temperature for the OverTemp signal in the OT Powerdown register. */ | void XAdcPs_DisableUserOverTemp(XAdcPs *InstancePtr) | /* This function disables programming of the powerdown temperature for the OverTemp signal in the OT Powerdown register. */
void XAdcPs_DisableUserOverTemp(XAdcPs *InstancePtr) | {
u16 OtUpper;
Xil_AssertVoid(InstancePtr != NULL);
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
OtUpper = (u16)(XAdcPs_ReadInternalReg(InstancePtr,
XADCPS_ATR_OT_UPPER_OFFSET));
OtUpper &= ~((u16)XADCPS_ATR_OT_UPPER_ENB_MASK);
XAdcPs_WriteInternalReg(InstancePtr,
XADCPS_ATR_OT_UPPER_OFFSET, (u32)OtUpper);
} | ua1arn/hftrx | C++ | null | 69 |
/* Called by the platform code to process a tick. */ | VOID EFIAPI CoreTimerTick(IN UINT64 Duration) | /* Called by the platform code to process a tick. */
VOID EFIAPI CoreTimerTick(IN UINT64 Duration) | {
IEVENT *Event;
CoreAcquireLock (&mEfiSystemTimeLock);
mEfiSystemTime += Duration;
if (!IsListEmpty (&mEfiTimerList)) {
Event = CR (mEfiTimerList.ForwardLink, IEVENT, Timer.Link, EVENT_SIGNATURE);
if (Event->Timer.TriggerTime <= mEfiSystemTime) {
CoreSignalEvent (mEfiCheckTimerEvent);
}
}
CoreReleaseLock (&mEfiSystemTimeLock);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* UART DMA receive finished callback function.
This function is called when UART DMA receive finished. It disables the UART RX DMA request and sends kStatus_UART_RxIdle to UART callback. */ | static void UART_TransferReceiveDMACallback(dma_handle_t *handle, void *param) | /* UART DMA receive finished callback function.
This function is called when UART DMA receive finished. It disables the UART RX DMA request and sends kStatus_UART_RxIdle to UART callback. */
static void UART_TransferReceiveDMACallback(dma_handle_t *handle, void *param) | {
assert(handle);
assert(param);
uart_dma_private_handle_t *uartPrivateHandle = (uart_dma_private_handle_t *)param;
UART_EnableRxDMA(uartPrivateHandle->base, false);
DMA_DisableInterrupts(handle->base, handle->channel);
uartPrivateHandle->handle->rxState = kUART_RxIdle;
if (uartPrivateHandle->handle->callback)
{
uartPrivateHandle->handle->callback(uartPrivateHandle->base, uartPrivateHandle->handle, kStatus_UART_RxIdle,
uartPrivateHandle->handle->userData);
}
} | labapart/polymcu | C++ | null | 201 |
/* Returns 0 for success or negative error code otherwise */ | int nand_reset(struct nand_chip *chip, int chipnr) | /* Returns 0 for success or negative error code otherwise */
int nand_reset(struct nand_chip *chip, int chipnr) | {
struct mtd_info *mtd = nand_to_mtd(chip);
int ret;
ret = nand_reset_data_interface(chip, chipnr);
if (ret)
return ret;
chip->select_chip(mtd, chipnr);
ret = nand_reset_op(chip);
chip->select_chip(mtd, -1);
if (ret)
return ret;
chip->select_chip(mtd, chipnr);
ret = nand_setup_data_interface(chip, chipnr);
chip->select_chip(mtd, -1);
if (ret)
return ret;
return 0;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* This function prepares for the installation of DiskInfo protocol on the child handle. By default, it installs DiskInfo protocol with USB interface GUID. */ | VOID InitializeDiskInfo(IN USB_MASS_DEVICE *UsbMass) | /* This function prepares for the installation of DiskInfo protocol on the child handle. By default, it installs DiskInfo protocol with USB interface GUID. */
VOID InitializeDiskInfo(IN USB_MASS_DEVICE *UsbMass) | {
CopyMem (&UsbMass->DiskInfo, &gUsbDiskInfoProtocolTemplate, sizeof (gUsbDiskInfoProtocolTemplate));
} | tianocore/edk2 | C++ | Other | 4,240 |
/* This service enables discovery of additional firmware volumes. */ | EFI_STATUS EFIAPI FfsFindNextVolume(IN UINTN Instance, IN OUT EFI_PEI_FV_HANDLE *VolumeHandle) | /* This service enables discovery of additional firmware volumes. */
EFI_STATUS EFIAPI FfsFindNextVolume(IN UINTN Instance, IN OUT EFI_PEI_FV_HANDLE *VolumeHandle) | {
EFI_PEI_HOB_POINTERS Hob;
Hob.Raw = GetHobList ();
if (Hob.Raw == NULL) {
return EFI_NOT_FOUND;
}
do {
Hob.Raw = GetNextHob (EFI_HOB_TYPE_FV, Hob.Raw);
if (Hob.Raw != NULL) {
if (Instance-- == 0) {
*VolumeHandle = (EFI_PEI_FV_HANDLE)(UINTN)(Hob.FirmwareVolume->BaseAddress);
return EFI_SUCCESS;
}
Hob.Raw = GetNextHob (EFI_HOB_TYPE_FV, GET_NEXT_HOB (Hob));
}
} while (Hob.Raw != NULL);
return EFI_NOT_FOUND;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Function for sending an event to all registered event handlers. */ | static void evt_send(im_evt_t *p_event) | /* Function for sending an event to all registered event handlers. */
static void evt_send(im_evt_t *p_event) | {
for (uint32_t i = 0; i < m_im.n_registrants; i++)
{
m_im.evt_handlers[i](p_event);
}
} | labapart/polymcu | C++ | null | 201 |
/* offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p), distances + offset, maxLen) - (distances)); MOVE_POS_RET } */ | UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) | /* offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p), distances + offset, maxLen) - (distances)); MOVE_POS_RET } */
UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) | {
unsigned offset;
GET_MATCHES_HEADER(3)
HASH_ZIP_CALC;
curMatch = p->hash[hv];
p->hash[hv] = p->pos;
offset = (unsigned)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
distances, 2) - (distances));
MOVE_POS_RET
} | tianocore/edk2 | C++ | Other | 4,240 |
/* param base The LPI2C peripheral base address. param handle Pointer to the LPI2C master driver handle. param callback User provided pointer to the asynchronous callback function. param userData User provided pointer to the application callback data. */ | void LPI2C_MasterTransferCreateHandle(LPI2C_Type *base, lpi2c_master_handle_t *handle, lpi2c_master_transfer_callback_t callback, void *userData) | /* param base The LPI2C peripheral base address. param handle Pointer to the LPI2C master driver handle. param callback User provided pointer to the asynchronous callback function. param userData User provided pointer to the application callback data. */
void LPI2C_MasterTransferCreateHandle(LPI2C_Type *base, lpi2c_master_handle_t *handle, lpi2c_master_transfer_callback_t callback, void *userData) | {
uint32_t instance;
assert(NULL != handle);
(void)memset(handle, 0, sizeof(*handle));
instance = LPI2C_GetInstance(base);
handle->completionCallback = callback;
handle->userData = userData;
s_lpi2cMasterHandle[instance] = handle;
s_lpi2cMasterIsr = LPI2C_MasterTransferHandleIRQ;
LPI2C_MasterDisableInterrupts(base, (uint32_t)kLPI2C_MasterIrqFlags);
(void)EnableIRQ(kLpi2cIrqs[instance]);
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* Called to make a LL control channel map request PDU. */ | static void ble_ll_ctrl_chanmap_req_make(struct ble_ll_conn_sm *connsm, uint8_t *pyld) | /* Called to make a LL control channel map request PDU. */
static void ble_ll_ctrl_chanmap_req_make(struct ble_ll_conn_sm *connsm, uint8_t *pyld) | {
memcpy(pyld, g_ble_ll_conn_params.master_chan_map, BLE_LL_CONN_CHMAP_LEN);
memcpy(connsm->req_chanmap, pyld, BLE_LL_CONN_CHMAP_LEN);
connsm->chanmap_instant = connsm->event_cntr + connsm->slave_latency + 6 + 1;
put_le16(pyld + BLE_LL_CONN_CHMAP_LEN, connsm->chanmap_instant);
connsm->csmflags.cfbit.chanmap_update_scheduled = 1;
} | arendst/Tasmota | C++ | GNU General Public License v3.0 | 21,318 |
/* Enqueues a received SMP fragment for later processing. This function executes in the interrupt context. */ | static void smp_dummy_rx_frag(struct uart_mcumgr_rx_buf *rx_buf) | /* Enqueues a received SMP fragment for later processing. This function executes in the interrupt context. */
static void smp_dummy_rx_frag(struct uart_mcumgr_rx_buf *rx_buf) | {
k_fifo_put(&smp_dummy_rx_fifo, rx_buf);
k_work_submit(&smp_dummy_work);
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Fills each RTC_InitStruct member with its default value. */ | void RTC_StructInit(RTC_InitTypeDef *RTC_InitStruct) | /* Fills each RTC_InitStruct member with its default value. */
void RTC_StructInit(RTC_InitTypeDef *RTC_InitStruct) | {
RTC_InitStruct->RTC_HourFormat = RTC_HourFormat_24;
RTC_InitStruct->RTC_AsynchPrediv = (uint32_t)0x7F;
RTC_InitStruct->RTC_SynchPrediv = (uint32_t)0xFF;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Check the status of the Rx buffer of the specified SPI port. */ | xtBoolean SPIIsRxEmpty(unsigned long ulBase) | /* Check the status of the Rx buffer of the specified SPI port. */
xtBoolean SPIIsRxEmpty(unsigned long ulBase) | {
xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)||
(ulBase == SPI2_BASE)||(ulBase == SPI3_BASE) );
return ((xHWREG(ulBase + SPI_CNTRL) & SPI_CNTRL_RX_EMPTY)? xtrue : xfalse);
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* The control element is supposed to have the private_value field set up via HDA_BIND_VOL() macro. */ | int snd_hda_mixer_bind_tlv(struct snd_kcontrol *kcontrol, int op_flag, unsigned int size, unsigned int __user *tlv) | /* The control element is supposed to have the private_value field set up via HDA_BIND_VOL() macro. */
int snd_hda_mixer_bind_tlv(struct snd_kcontrol *kcontrol, int op_flag, unsigned int size, unsigned int __user *tlv) | {
struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
struct hda_bind_ctls *c;
int err;
mutex_lock(&codec->control_mutex);
c = (struct hda_bind_ctls *)kcontrol->private_value;
kcontrol->private_value = *c->values;
err = c->ops->tlv(kcontrol, op_flag, size, tlv);
kcontrol->private_value = (long)c;
mutex_unlock(&codec->control_mutex);
return err;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Unregisters an interrupt handler for the timer interrupt. */ | void TimerIntUnregister(unsigned long ulBase, unsigned long ulTimer) | /* Unregisters an interrupt handler for the timer interrupt. */
void TimerIntUnregister(unsigned long ulBase, unsigned long ulTimer) | {
ASSERT(TimerBaseValid(ulBase));
ASSERT((ulTimer == TIMER_A) || (ulTimer == TIMER_B) ||
(ulTimer == TIMER_BOTH));
ulBase = ((ulBase == TIMERA0_BASE) ? INT_TIMERA0A :
((ulBase == TIMERA1_BASE) ? INT_TIMERA1A :
((ulBase == TIMERA2_BASE) ? INT_TIMERA2A : INT_TIMERA3A)));
if(ulTimer & TIMER_A)
{
IntDisable(ulBase);
IntUnregister(ulBase);
}
if(ulTimer & TIMER_B)
{
IntDisable(ulBase + 1);
IntUnregister(ulBase + 1);
}
} | micropython/micropython | C++ | Other | 18,334 |
/* always ensure that the attributes are up to date if we're mounted with close-to-open semantics */ | void nfs_close_context(struct nfs_open_context *ctx, int is_sync) | /* always ensure that the attributes are up to date if we're mounted with close-to-open semantics */
void nfs_close_context(struct nfs_open_context *ctx, int is_sync) | {
struct inode *inode;
struct nfs_server *server;
if (!(ctx->mode & FMODE_WRITE))
return;
if (!is_sync)
return;
inode = ctx->path.dentry->d_inode;
if (!list_empty(&NFS_I(inode)->open_files))
return;
server = NFS_SERVER(inode);
if (server->flags & NFS_MOUNT_NOCTO)
return;
nfs_revalidate_inode(server, inode);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Indicates (when set) that a local machine check exception was generated. This indicates that the current machine-check event was delivered to only the logical processor. */ | BOOLEAN IsLmceSignaled(VOID) | /* Indicates (when set) that a local machine check exception was generated. This indicates that the current machine-check event was delivered to only the logical processor. */
BOOLEAN IsLmceSignaled(VOID) | {
MSR_IA32_MCG_STATUS_REGISTER McgStatus;
McgStatus.Uint64 = AsmReadMsr64 (MSR_IA32_MCG_STATUS);
return (BOOLEAN)(McgStatus.Bits.LMCE_S == 1);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Temporarily try to avoid having to use the specified PG */ | static void bypass_pg(struct multipath *m, struct priority_group *pg, int bypassed) | /* Temporarily try to avoid having to use the specified PG */
static void bypass_pg(struct multipath *m, struct priority_group *pg, int bypassed) | {
unsigned long flags;
spin_lock_irqsave(&m->lock, flags);
pg->bypassed = bypassed;
m->current_pgpath = NULL;
m->current_pg = NULL;
spin_unlock_irqrestore(&m->lock, flags);
schedule_work(&m->trigger_event);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Return the powerdomain pwrdm's previous power state. Returns -EINVAL if the powerdomain pointer is null or returns the previous power state upon success. */ | int pwrdm_read_prev_pwrst(struct powerdomain *pwrdm) | /* Return the powerdomain pwrdm's previous power state. Returns -EINVAL if the powerdomain pointer is null or returns the previous power state upon success. */
int pwrdm_read_prev_pwrst(struct powerdomain *pwrdm) | {
if (!pwrdm)
return -EINVAL;
return prm_read_mod_bits_shift(pwrdm->prcm_offs, OMAP3430_PM_PREPWSTST,
OMAP3430_LASTPOWERSTATEENTERED_MASK);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Returns a pointer to the master list entry for the Smack label or NULL if there was no label to fetch. */ | static char* smk_fetch(struct inode *ip, struct dentry *dp) | /* Returns a pointer to the master list entry for the Smack label or NULL if there was no label to fetch. */
static char* smk_fetch(struct inode *ip, struct dentry *dp) | {
int rc;
char in[SMK_LABELLEN];
if (ip->i_op->getxattr == NULL)
return NULL;
rc = ip->i_op->getxattr(dp, XATTR_NAME_SMACK, in, SMK_LABELLEN);
if (rc < 0)
return NULL;
return smk_import(in, rc);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* This function will init timer4 for system ticks */ | static void rt_hw_timer_init(void) | /* This function will init timer4 for system ticks */
static void rt_hw_timer_init(void) | {
TCFG0 &= 0xffff00ff;
TCFG0 |= 15 << 8;
TCFG1 &= 0xfff0ffff;
TCFG1 |= 0x00010000;
TCNTB4 = (rt_int32_t)(PCLK / (4 *16* RT_TICK_PER_SECOND)) - 1;
TCON = TCON & (~(0x0f<<20)) | (0x02<<20);
rt_hw_interrupt_install(INTTIMER4, rt_timer_handler, RT_NULL, "tick");
rt_hw_interrupt_umask(INTTIMER4);
TCON = TCON & (~(0x0f<<20)) | (0x05<<20);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Given an inode, first check if we care what happens to our children. Inotify and dnotify both tell their parents about events. If we care about any event on a child we run all of our children and set a dentry flag saying that the parent cares. Thus when an event happens on a child it can quickly tell if if there is a need to find a parent and send the event to the parent. */ | void __fsnotify_update_child_dentry_flags(struct inode *inode) | /* Given an inode, first check if we care what happens to our children. Inotify and dnotify both tell their parents about events. If we care about any event on a child we run all of our children and set a dentry flag saying that the parent cares. Thus when an event happens on a child it can quickly tell if if there is a need to find a parent and send the event to the parent. */
void __fsnotify_update_child_dentry_flags(struct inode *inode) | {
struct dentry *alias;
int watched;
if (!S_ISDIR(inode->i_mode))
return;
watched = fsnotify_inode_watches_children(inode);
spin_lock(&dcache_lock);
list_for_each_entry(alias, &inode->i_dentry, d_alias) {
struct dentry *child;
list_for_each_entry(child, &alias->d_subdirs, d_u.d_child) {
if (!child->d_inode)
continue;
spin_lock(&child->d_lock);
if (watched)
child->d_flags |= DCACHE_FSNOTIFY_PARENT_WATCHED;
else
child->d_flags &= ~DCACHE_FSNOTIFY_PARENT_WATCHED;
spin_unlock(&child->d_lock);
}
}
spin_unlock(&dcache_lock);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This function wraps EFI_PEI_PCI_CFG2_PPI.Write() service. It writes the PCI configuration register specified by Address with the value specified by Data. The width of data is specifed by Width. Data is returned. */ | UINT32 PeiPciSegmentLibPciCfg2WriteWorker(IN UINT64 Address, IN EFI_PEI_PCI_CFG_PPI_WIDTH Width, IN UINT32 Data) | /* This function wraps EFI_PEI_PCI_CFG2_PPI.Write() service. It writes the PCI configuration register specified by Address with the value specified by Data. The width of data is specifed by Width. Data is returned. */
UINT32 PeiPciSegmentLibPciCfg2WriteWorker(IN UINT64 Address, IN EFI_PEI_PCI_CFG_PPI_WIDTH Width, IN UINT32 Data) | {
CONST EFI_PEI_PCI_CFG2_PPI *PciCfg2Ppi;
UINT64 PciCfg2Address;
PciCfg2Ppi = InternalGetPciCfg2Ppi (Address);
PciCfg2Address = PCI_TO_PCICFG2_ADDRESS (Address);
PciCfg2Ppi->Write (
GetPeiServicesTablePointer (),
PciCfg2Ppi,
Width,
PciCfg2Address,
&Data
);
return Data;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Return: resource num if all went ok else TI_SCI_RESOURCE_NULL. */ | u16 ti_sci_get_free_resource(struct ti_sci_resource *res) | /* Return: resource num if all went ok else TI_SCI_RESOURCE_NULL. */
u16 ti_sci_get_free_resource(struct ti_sci_resource *res) | {
u16 set, free_bit;
for (set = 0; set < res->sets; set++) {
free_bit = find_first_zero_bit(res->desc[set].res_map,
res->desc[set].num);
if (free_bit != res->desc[set].num) {
set_bit(free_bit, res->desc[set].res_map);
return res->desc[set].start + free_bit;
}
}
return TI_SCI_RESOURCE_NULL;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Fetch a POS value directly from the hardware to obtain the current value. This is much slower than mca_device_read_stored_pos and may not be invoked from interrupt context. It handles the deep magic required for onboard devices transparently. */ | unsigned char mca_device_read_pos(struct mca_device *mca_dev, int reg) | /* Fetch a POS value directly from the hardware to obtain the current value. This is much slower than mca_device_read_stored_pos and may not be invoked from interrupt context. It handles the deep magic required for onboard devices transparently. */
unsigned char mca_device_read_pos(struct mca_device *mca_dev, int reg) | {
struct mca_bus *mca_bus = to_mca_bus(mca_dev->dev.parent);
return mca_bus->f.mca_read_pos(mca_dev, reg);
return mca_dev->pos[reg];
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Caught interrupts are forwarded to the upper parport layer if IRQ_mode is PARPORT_IP32_IRQ_FWD. */ | static irqreturn_t parport_ip32_interrupt(int irq, void *dev_id) | /* Caught interrupts are forwarded to the upper parport layer if IRQ_mode is PARPORT_IP32_IRQ_FWD. */
static irqreturn_t parport_ip32_interrupt(int irq, void *dev_id) | {
struct parport * const p = dev_id;
struct parport_ip32_private * const priv = p->physport->private_data;
enum parport_ip32_irq_mode irq_mode = priv->irq_mode;
switch (irq_mode) {
case PARPORT_IP32_IRQ_FWD:
return parport_irq_handler(irq, dev_id);
case PARPORT_IP32_IRQ_HERE:
parport_ip32_wakeup(p);
break;
}
return IRQ_HANDLED;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* SPI flash write enable.
Enable SPI flash write */ | static void spi_flash_write_enable(void) | /* SPI flash write enable.
Enable SPI flash write */
static void spi_flash_write_enable(void) | {
SPI_FLASH0->READ_CTRL.reg = SPI_FLASH_READ_CTRL_RDATA_COUNT(0);
SPI_FLASH0->CMD_BUFFER0.reg = SPI_FLASH_CMD_WRITE_ENABLE;
SPI_FLASH0->DIRECTION.reg = SPI_FLASH_DIRECTION_CMD;
SPI_FLASH0->DMA_START_ADDRESS.reg = SPI_FLASH_DMA_START_ADDRESS_RESETVALUE;
SPI_FLASH0->TRANSACTION_CTRL.reg = \
SPI_FLASH_TRANSACTION_CTRL_FLASH_TRANS_START | \
SPI_FLASH_TRANSACTION_CTRL_CMD_COUNT(0x01);
while (SPI_FLASH0->IRQ_STATUS.bit.FLASH_TRANS_DONE != \
SPI_FLASH_IRQ_STATUS_FLASH_TRANS_DONE) {
}
} | memfault/zero-to-main | C++ | null | 200 |
/* Release hardware semaphore used to access the PHY or NVM */ | void igb_put_hw_semaphore(struct e1000_hw *hw) | /* Release hardware semaphore used to access the PHY or NVM */
void igb_put_hw_semaphore(struct e1000_hw *hw) | {
u32 swsm;
swsm = rd32(E1000_SWSM);
swsm &= ~(E1000_SWSM_SMBI | E1000_SWSM_SWESMBI);
wr32(E1000_SWSM, swsm);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* meson_spifc_hw_init() - reset and initialize the SPI controller @spifc: the Meson SPI device */ | static void meson_spifc_hw_init(struct meson_spifc_priv *spifc) | /* meson_spifc_hw_init() - reset and initialize the SPI controller @spifc: the Meson SPI device */
static void meson_spifc_hw_init(struct meson_spifc_priv *spifc) | {
regmap_update_bits(spifc->regmap, REG_SLAVE, SLAVE_SW_RST,
SLAVE_SW_RST);
regmap_update_bits(spifc->regmap, REG_USER, USER_CMP_MODE, 0);
regmap_update_bits(spifc->regmap, REG_SLAVE, SLAVE_OP_MODE, 0);
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Forces the output 3 waveform to active or inactive level. */ | void TMR_ConfigForcedOC3(TMR_T *tmr, TMR_FORCED_ACTION_T forcesAction) | /* Forces the output 3 waveform to active or inactive level. */
void TMR_ConfigForcedOC3(TMR_T *tmr, TMR_FORCED_ACTION_T forcesAction) | {
tmr->CCM2_COMPARE_B.OC3MOD = BIT_RESET;
tmr->CCM2_COMPARE_B.OC3MOD = forcesAction;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* For the EFI_HII_VALUE value type is numeric, return TRUE if the value is not 0. */ | BOOLEAN IsTrue(IN EFI_HII_VALUE *Result) | /* For the EFI_HII_VALUE value type is numeric, return TRUE if the value is not 0. */
BOOLEAN IsTrue(IN EFI_HII_VALUE *Result) | {
switch (Result->Type) {
case EFI_IFR_TYPE_BOOLEAN:
return Result->Value.b;
case EFI_IFR_TYPE_NUM_SIZE_8:
return (BOOLEAN)(Result->Value.u8 != 0);
case EFI_IFR_TYPE_NUM_SIZE_16:
return (BOOLEAN)(Result->Value.u16 != 0);
case EFI_IFR_TYPE_NUM_SIZE_32:
return (BOOLEAN)(Result->Value.u32 != 0);
case EFI_IFR_TYPE_NUM_SIZE_64:
return (BOOLEAN)(Result->Value.u64 != 0);
default:
return FALSE;
}
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Release a Mutex that was obtained by osMutexWait. */ | osStatus_t osMutexRelease(osMutexId_t mutex_id) | /* Release a Mutex that was obtained by osMutexWait. */
osStatus_t osMutexRelease(osMutexId_t mutex_id) | {
struct cv2_mutex *mutex = (struct cv2_mutex *) mutex_id;
if (mutex_id == NULL) {
return osErrorParameter;
}
if (k_is_in_isr()) {
return osErrorISR;
}
if (k_mutex_unlock(&mutex->z_mutex) != 0) {
return osErrorResource;
}
return osOK;
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Match an uid independently of the version byte and up to len common bytes Returns: boolean */ | static int mxf_match_uid(const UID key, const UID uid, int len) | /* Match an uid independently of the version byte and up to len common bytes Returns: boolean */
static int mxf_match_uid(const UID key, const UID uid, int len) | {
int i;
for (i = 0; i < len; i++) {
if (i != 7 && key[i] != uid[i])
return 0;
}
return 1;
} | DC-SWAT/DreamShell | C++ | null | 404 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.