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
|
|---|---|---|---|---|---|---|---|
/* Chip Enable is also controlled by the Chip Select (CS5) and Address lines (A24-A22), so no action is required here. */
|
static void rtc_from4_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
|
/* Chip Enable is also controlled by the Chip Select (CS5) and Address lines (A24-A22), so no action is required here. */
static void rtc_from4_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
|
{
struct nand_chip *chip = (mtd->priv);
if (cmd == NAND_CMD_NONE)
return;
if (ctrl & NAND_CLE)
writeb(cmd, chip->IO_ADDR_W | RTC_FROM4_CLE);
else
writeb(cmd, chip->IO_ADDR_W | RTC_FROM4_ALE);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* If the allocated heap size is >= 3*used and 2*used >= KEVENTS_EXTEND_COUNT, reduce it to 2*used. */
|
void kevents_reduce(kevents *kv)
|
/* If the allocated heap size is >= 3*used and 2*used >= KEVENTS_EXTEND_COUNT, reduce it to 2*used. */
void kevents_reduce(kevents *kv)
|
{
g_assert (kv != NULL);
gsize candidate_sz;
if (kv->kq_size == 0 || kv->kq_allocated == 0 || kv->memory == NULL)
return;
candidate_sz = 2 * kv->kq_size;
if (((double) kv->kq_allocated / kv->kq_size) >= 3 &&
candidate_sz >= KEVENTS_EXTEND_COUNT)
{
kv->kq_allocated = candidate_sz;
kv->memory = g_renew (struct kevent, kv->memory, kv->kq_allocated);
}
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Return: 0 on success or error code in case of error */
|
int rsa_parse_pub_key(struct rsa_key *rsa_key, const void *key, unsigned int key_len)
|
/* Return: 0 on success or error code in case of error */
int rsa_parse_pub_key(struct rsa_key *rsa_key, const void *key, unsigned int key_len)
|
{
return asn1_ber_decoder(&rsapubkey_decoder, rsa_key, key, key_len);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Tells whether the page to which the last Quick Page Read or Quick Page Read User Page command was applied was erased. */
|
bool flashcalw_is_page_erased(void)
|
/* Tells whether the page to which the last Quick Page Read or Quick Page Read User Page command was applied was erased. */
bool flashcalw_is_page_erased(void)
|
{
return ((HFLASHC->FLASHCALW_FSR & FLASHCALW_FSR_QPRR) != 0);
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* return 1 -> Reg written 0 -> usbvision is not yet ready -1 -> Something went wrong */
|
int usbvision_write_reg(struct usb_usbvision *usbvision, unsigned char reg, unsigned char value)
|
/* return 1 -> Reg written 0 -> usbvision is not yet ready -1 -> Something went wrong */
int usbvision_write_reg(struct usb_usbvision *usbvision, unsigned char reg, unsigned char value)
|
{
int errCode = 0;
if (!USBVISION_IS_OPERATIONAL(usbvision))
return 0;
errCode = usb_control_msg(usbvision->dev, usb_sndctrlpipe(usbvision->dev, 1),
USBVISION_OP_CODE,
USB_DIR_OUT | USB_TYPE_VENDOR |
USB_RECIP_ENDPOINT, 0, (__u16) reg, &value, 1, HZ);
if (errCode < 0) {
dev_err(&usbvision->dev->dev,
"%s: failed: error %d\n", __func__, errCode);
}
return errCode;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). If StartBit is greater than 31, then ASSERT(). If EndBit is greater than 31, 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(). */
|
UINT32 EFIAPI PciBitFieldOr32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 OrData)
|
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). If StartBit is greater than 31, then ASSERT(). If EndBit is greater than 31, 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(). */
UINT32 EFIAPI PciBitFieldOr32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 OrData)
|
{
return mRunningOnQ35 ?
PciExpressBitFieldOr32 (Address, StartBit, EndBit, OrData) :
PciCf8BitFieldOr32 (Address, StartBit, EndBit, OrData);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Allocates the number bytes specified by AllocationSize of a certain pool type and returns a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. */
|
VOID* InternalAllocatePool(IN EFI_MEMORY_TYPE MemoryType, IN UINTN AllocationSize)
|
/* Allocates the number bytes specified by AllocationSize of a certain pool type and returns a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. */
VOID* InternalAllocatePool(IN EFI_MEMORY_TYPE MemoryType, IN UINTN AllocationSize)
|
{
EFI_STATUS Status;
VOID *Memory;
Status = gSmst->SmmAllocatePool (MemoryType, AllocationSize, &Memory);
if (EFI_ERROR (Status)) {
Memory = NULL;
}
return Memory;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Assabet uses COM_RTS and COM_DTR for both UART1 (com port) and UART3 (radio module). We only handle them for UART1 here. */
|
static void assabet_set_mctrl(struct uart_port *port, u_int mctrl)
|
/* Assabet uses COM_RTS and COM_DTR for both UART1 (com port) and UART3 (radio module). We only handle them for UART1 here. */
static void assabet_set_mctrl(struct uart_port *port, u_int mctrl)
|
{
if (port->mapbase == _Ser1UTCR0) {
u_int set = 0, clear = 0;
if (mctrl & TIOCM_RTS)
clear |= ASSABET_BCR_COM_RTS;
else
set |= ASSABET_BCR_COM_RTS;
if (mctrl & TIOCM_DTR)
clear |= ASSABET_BCR_COM_DTR;
else
set |= ASSABET_BCR_COM_DTR;
ASSABET_BCR_clear(clear);
ASSABET_BCR_set(set);
}
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Determines whether the given IPC flags are busy or not. */
|
Uint16 IPCLtoRFlagBusy(uint32_t ulFlags)
|
/* Determines whether the given IPC flags are busy or not. */
Uint16 IPCLtoRFlagBusy(uint32_t ulFlags)
|
{
Uint16 returnStatus;
if ((IpcRegs.IPCFLG.all & ulFlags) == 0)
{
returnStatus = 0;
}
else
{
returnStatus = 1;
}
return returnStatus;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Activate MBMS Context Accept Direction: network to MS */
|
static void dtap_sm_act_mbms_acc(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
|
/* Activate MBMS Context Accept Direction: network to MS */
static void dtap_sm_act_mbms_acc(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
|
{
guint32 curr_offset;
guint32 consumed;
guint curr_len;
curr_offset = offset;
curr_len = len;
pinfo->p2p_dir = P2P_DIR_SENT;
ELEM_MAND_LV( GSM_A_PDU_TYPE_GM, DE_TMGI, NULL);
ELEM_MAND_V( GSM_A_PDU_TYPE_GM, DE_LLC_SAPI, " - Negotiated LLC SAPI");
ELEM_OPT_TLV( 0x35, GSM_A_PDU_TYPE_GM, DE_MBMS_PROT_CONF_OPT, NULL);
EXTRANEOUS_DATA_CHECK(curr_len, 0, pinfo, &ei_gsm_a_gm_extraneous_data);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Enable MMX check for filter functions and use MMX code if available. */
|
void SDL_imageFilterMMXon()
|
/* Enable MMX check for filter functions and use MMX code if available. */
void SDL_imageFilterMMXon()
|
{
SDL_imageFilterUseMMX = 1;
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* dmar_parse_one_drhd - parses exactly one DMA remapping hardware definition structure which uniquely represent one DMA remapping hardware unit present in the platform */
|
static int __init dmar_parse_one_drhd(struct acpi_dmar_header *header)
|
/* dmar_parse_one_drhd - parses exactly one DMA remapping hardware definition structure which uniquely represent one DMA remapping hardware unit present in the platform */
static int __init dmar_parse_one_drhd(struct acpi_dmar_header *header)
|
{
struct acpi_dmar_hardware_unit *drhd;
struct dmar_drhd_unit *dmaru;
int ret = 0;
drhd = (struct acpi_dmar_hardware_unit *)header;
dmaru = kzalloc(sizeof(*dmaru), GFP_KERNEL);
if (!dmaru)
return -ENOMEM;
dmaru->hdr = header;
dmaru->reg_base_addr = drhd->address;
dmaru->segment = drhd->segment;
dmaru->include_all = drhd->flags & 0x1;
ret = alloc_iommu(dmaru);
if (ret) {
kfree(dmaru);
return ret;
}
dmar_register_drhd_unit(dmaru);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* STUSB1602 checks the entire HW_FAULT_STATUS_TRANS reg (bit7 0x12 */
|
STUSB1602_HW_FAULT_STATUS_TRANS_RegTypeDef STUSB1602_Hard_Fault_Trans_Status_Get(uint8_t Addr)
|
/* STUSB1602 checks the entire HW_FAULT_STATUS_TRANS reg (bit7 0x12 */
STUSB1602_HW_FAULT_STATUS_TRANS_RegTypeDef STUSB1602_Hard_Fault_Trans_Status_Get(uint8_t Addr)
|
{
STUSB1602_HW_FAULT_STATUS_TRANS_RegTypeDef reg;
STUSB1602_ReadReg(®.d8, Addr, STUSB1602_HW_FAULT_STATUS_TRANS_REG, 1);
return (reg);
}
|
st-one/X-CUBE-USB-PD
|
C++
| null | 110
|
/* Function to reset the GMAC core. This reests the DMA and GMAC core. After reset all the registers holds their respective reset value */
|
s32 synopGMAC_reset(synopGMACdevice *gmacdev)
|
/* Function to reset the GMAC core. This reests the DMA and GMAC core. After reset all the registers holds their respective reset value */
s32 synopGMAC_reset(synopGMACdevice *gmacdev)
|
{
u32 data = 0;
synopGMACWriteReg(gmacdev -> DmaBase, DmaBusMode, DmaResetOn);
plat_delay(DEFAULT_LOOP_VARIABLE);
data = synopGMACReadReg(gmacdev -> DmaBase, DmaBusMode);
TR("DATA after Reset = %08x\n", data);
return 0;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* This API sets the feature config. data start address in the sensor. */
|
static uint16_t set_feature_config_start_addr(struct bma4_dev *dev)
|
/* This API sets the feature config. data start address in the sensor. */
static uint16_t set_feature_config_start_addr(struct bma4_dev *dev)
|
{
uint16_t rslt;
rslt = write_regs(BMA4_RESERVED_REG_5B_ADDR, &dev->asic_data.asic_lsb, 1, dev);
rslt |= write_regs(BMA4_RESERVED_REG_5C_ADDR, &dev->asic_data.asic_msb, 1, dev);
return rslt;
}
|
arendst/Tasmota
|
C++
|
GNU General Public License v3.0
| 21,318
|
/* Enables simultaneously the two DAC channels software triggers. */
|
void DAC_EnableDualSoftwareTrigger(void)
|
/* Enables simultaneously the two DAC channels software triggers. */
void DAC_EnableDualSoftwareTrigger(void)
|
{
DAC->SWTRG |= DUAL_SWTRIG_SET;
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* Fill zeros to esai tx fifo to avoid noise data transfered. */
|
static int32_t esai_stuff_tx_fifo(audio_ctrl_p ctrl)
|
/* Fill zeros to esai tx fifo to avoid noise data transfered. */
static int32_t esai_stuff_tx_fifo(audio_ctrl_p ctrl)
|
{
uint32_t i;
uint32_t instance = ctrl->instance;
UNUSED_VARIABLE(instance);
for (i = 0; i < ESAI_TX_FIFO_SIZE; i++) {
HW_ESAI_ETDR_WR(0);
}
return 0;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* To Enable optimize the I/O speed when the product voltage is low. */
|
void HAL_SYSCFG_EnableIOSpeedOptimize(uint32_t SYSCFG_HighSpeedSignal)
|
/* To Enable optimize the I/O speed when the product voltage is low. */
void HAL_SYSCFG_EnableIOSpeedOptimize(uint32_t SYSCFG_HighSpeedSignal)
|
{
SYSCFG->IOCTRLSETR = SYSCFG_HighSpeedSignal;
}
|
ua1arn/hftrx
|
C++
| null | 69
|
/* Deliver the packet for each IP4 child on the interface. */
|
EFI_STATUS Ip4InterfaceDeliverPacket(IN IP4_SERVICE *IpSb, IN IP4_INTERFACE *IpIf)
|
/* Deliver the packet for each IP4 child on the interface. */
EFI_STATUS Ip4InterfaceDeliverPacket(IN IP4_SERVICE *IpSb, IN IP4_INTERFACE *IpIf)
|
{
IP4_PROTOCOL *Ip4Instance;
LIST_ENTRY *Entry;
NET_LIST_FOR_EACH (Entry, &IpIf->IpInstances) {
Ip4Instance = NET_LIST_USER_STRUCT (Entry, IP4_PROTOCOL, AddrLink);
Ip4InstanceDeliverPacket (Ip4Instance);
}
return EFI_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* The function panics if the request can not be satisfied. */
|
void* __init __alloc_bootmem_low(unsigned long size, unsigned long align, unsigned long goal)
|
/* The function panics if the request can not be satisfied. */
void* __init __alloc_bootmem_low(unsigned long size, unsigned long align, unsigned long goal)
|
{
return ___alloc_bootmem(size, align, goal, ARCH_LOW_ADDRESS_LIMIT);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Do the callback functions of expired vtimer events. Called from within the interrupt handler. */
|
static void do_callbacks(struct list_head *cb_list)
|
/* Do the callback functions of expired vtimer events. Called from within the interrupt handler. */
static void do_callbacks(struct list_head *cb_list)
|
{
struct vtimer_queue *vq;
struct vtimer_list *event, *tmp;
if (list_empty(cb_list))
return;
vq = &__get_cpu_var(virt_cpu_timer);
list_for_each_entry_safe(event, tmp, cb_list, entry) {
list_del_init(&event->entry);
(event->function)(event->data);
if (event->interval) {
event->expires = event->interval + vq->elapsed;
spin_lock(&vq->lock);
list_add_sorted(event, &vq->list);
spin_unlock(&vq->lock);
}
}
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Close a MCI driver instance and the underlying peripheral. */
|
void MCI_Close(Mci *pMci)
|
/* Close a MCI driver instance and the underlying peripheral. */
void MCI_Close(Mci *pMci)
|
{
AT91S_MCI *pMciHw = pMci->pMciHw;
SANITY_CHECK(pMci);
SANITY_CHECK(pMciHw);
pMci->semaphore = 1;
pMci->pCommand = 0;
WRITE_PMC(AT91C_BASE_PMC, PMC_PCDR, (1 << pMci->mciId));
WRITE_MCI(pMciHw, MCI_CR, AT91C_MCI_MCIDIS);
WRITE_MCI(pMciHw, MCI_IDR, 0xFFFFFFFF);
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* Calculate the number of seconds we should be showing the FrontPage progress bar for. */
|
UINT16 EFIAPI GetFrontPageTimeoutFromQemu(VOID)
|
/* Calculate the number of seconds we should be showing the FrontPage progress bar for. */
UINT16 EFIAPI GetFrontPageTimeoutFromQemu(VOID)
|
{
FIRMWARE_CONFIG_ITEM BootMenuWaitItem;
UINTN BootMenuWaitSize;
UINT16 Timeout = PcdGet16 (PcdPlatformBootTimeOut);
if (!QemuFwCfgIsAvailable ()) {
return Timeout;
}
QemuFwCfgSelectItem (QemuFwCfgItemBootMenu);
if (QemuFwCfgRead16 () == 0) {
return PcdGet16 (PcdPlatformBootTimeOut);
}
if (RETURN_ERROR (
QemuFwCfgFindFile (
"etc/boot-menu-wait",
&BootMenuWaitItem,
&BootMenuWaitSize
)
) ||
(BootMenuWaitSize != sizeof (UINT16)))
{
if (Timeout == 0) {
Timeout = 3;
}
return Timeout;
}
QemuFwCfgSelectItem (BootMenuWaitItem);
return (UINT16)((QemuFwCfgRead16 () + 999) / 1000);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Returns the name of the slot to which the PCIe or SATA controller is connected */
|
const char* board_serdes_name(enum srds_prtcl device)
|
/* Returns the name of the slot to which the PCIe or SATA controller is connected */
const char* board_serdes_name(enum srds_prtcl device)
|
{
ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
u32 pordevsr = in_be32(&gur->pordevsr);
unsigned int srds_cfg = (pordevsr & MPC85xx_PORDEVSR_IO_SEL) >>
MPC85xx_PORDEVSR_IO_SEL_SHIFT;
enum slot_id slot = serdes_dev_slot[srds_cfg][device];
const char *name = slot_names[slot];
if (name)
return name;
else
return "Nothing";
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Called when the IRQ is triggered. Read the current device state, and push the input events to the user space. */
|
static void goodix_process_events(struct goodix_ts_data *ts)
|
/* Called when the IRQ is triggered. Read the current device state, and push the input events to the user space. */
static void goodix_process_events(struct goodix_ts_data *ts)
|
{
u8 point_data[1 + GOODIX_CONTACT_SIZE * GOODIX_MAX_CONTACTS];
int touch_num;
int i;
touch_num = goodix_ts_read_input_report(ts, point_data);
if (touch_num < 0)
return;
if (!touch_num) {
input_event(ts->input_dev, EV_KEY, BTN_TOUCH, 0);
input_report_abs(ts->input_dev, ABS_PRESSURE, 0);
}
for (i = 0; i < touch_num; i++)
goodix_ts_report_touch(ts,
&point_data[1 + GOODIX_CONTACT_SIZE * i]);
input_sync(ts->input_dev);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Load the Target time stamp registers This function Loads the target time stamp registers with the values proviced */
|
void synopGMAC_TS_load_target_timestamp(synopGMACdevice *gmacdev, u32 sec_val, u32 sub_sec_val)
|
/* Load the Target time stamp registers This function Loads the target time stamp registers with the values proviced */
void synopGMAC_TS_load_target_timestamp(synopGMACdevice *gmacdev, u32 sec_val, u32 sub_sec_val)
|
{
synopGMACWriteReg(gmacdev->MacBase, GmacTSTargetTimeHigh, sec_val);
synopGMACWriteReg(gmacdev->MacBase, GmacTSTargetTimeLow, sub_sec_val);
return;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* read ahead and find the next MPEG header, to guess framesize return value: success code 1: found a valid frame size (stored in the handle). <0: error codes, possibly from feeder buffer (NEED_MORE) 0: cannot get the framesize for some reason and shall silentry try the next possible header (if this is no free format stream after all...) */
|
static int guess_freeformat_framesize(mpg123_handle *fr)
|
/* read ahead and find the next MPEG header, to guess framesize return value: success code 1: found a valid frame size (stored in the handle). <0: error codes, possibly from feeder buffer (NEED_MORE) 0: cannot get the framesize for some reason and shall silentry try the next possible header (if this is no free format stream after all...) */
static int guess_freeformat_framesize(mpg123_handle *fr)
|
{
long i;
int ret;
unsigned long head;
if(!(fr->rdat.flags & (READER_SEEKABLE|READER_BUFFERED)))
{
if(NOQUIET) error("Cannot look for freeformat frame size with non-seekable and non-buffered stream!");
return 0;
}
if((ret=fr->rd->head_read(fr,&head))<=0)
return ret;
for(i=4;i<65536;i++)
{
if((ret=fr->rd->head_shift(fr,&head))<=0) return ret;
if((head & HDR_SAMEMASK) == (fr->oldhead & HDR_SAMEMASK))
{
fr->rd->back_bytes(fr,i+1);
fr->framesize = i-3;
return 1;
}
}
fr->rd->back_bytes(fr,i);
return 0;
}
|
DC-SWAT/DreamShell
|
C++
| null | 404
|
/* Toggle the specified pixel/segment in the LCDCA display memory. */
|
void lcdca_toggle_pixel(uint8_t pix_com, uint8_t pix_seg)
|
/* Toggle the specified pixel/segment in the LCDCA display memory. */
void lcdca_toggle_pixel(uint8_t pix_com, uint8_t pix_seg)
|
{
if ((pix_com < LCDCA_MAX_NR_OF_COM) &&
(pix_seg < LCDCA_MAX_NBR_OF_SEG)) {
uint64_t register_value = lcdca_get_pixel_register(pix_com);
if (register_value & ((uint64_t)1 << pix_seg)) {
lcdca_clear_pixel(pix_com, pix_seg);
} else {
lcdca_set_pixel(pix_com, pix_seg);
}
}
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Returns CR_OK upon successful completion, an error code otherwise. */
|
enum CRStatus cr_input_increment_line_num(CRInput *a_this, glong a_increment)
|
/* Returns CR_OK upon successful completion, an error code otherwise. */
enum CRStatus cr_input_increment_line_num(CRInput *a_this, glong a_increment)
|
{
g_return_val_if_fail (a_this && PRIVATE (a_this), CR_BAD_PARAM_ERROR);
PRIVATE (a_this)->line += a_increment;
return CR_OK;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Function used to free the airpcap interface list */
|
void free_airpcap_interface_list(GList *if_list)
|
/* Function used to free the airpcap interface list */
void free_airpcap_interface_list(GList *if_list)
|
{
g_list_foreach(if_list, free_airpcap_if_cb, NULL);
g_list_free(if_list);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Decodes a Long-integer from the protocol data Long-integer = Short-length Multi-octet-integer Short-length = <Any octet 0-30> Multi-octet-integer = 1*30OCTET */
|
static guint get_long_integer(tvbuff_t *tvb, guint offset, guint *byte_count)
|
/* Decodes a Long-integer from the protocol data Long-integer = Short-length Multi-octet-integer Short-length = <Any octet 0-30> Multi-octet-integer = 1*30OCTET */
static guint get_long_integer(tvbuff_t *tvb, guint offset, guint *byte_count)
|
{
guint val;
*byte_count = tvb_get_guint8(tvb, offset++);
switch (*byte_count) {
case 1:
val = tvb_get_guint8(tvb, offset);
break;
case 2:
val = tvb_get_ntohs(tvb, offset);
break;
case 3:
val = tvb_get_ntoh24(tvb, offset);
break;
case 4:
val = tvb_get_ntohl(tvb, offset);
break;
default:
val = 0;
break;
}
(*byte_count)++;
return val;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Check the busy status of the specified SPI port. */
|
xtBoolean SPIIsBusy(unsigned long ulBase)
|
/* Check the busy status of the specified SPI port. */
xtBoolean SPIIsBusy(unsigned long ulBase)
|
{
xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)||
(ulBase == SPI2_BASE) || (ulBase == SPI3_BASE));
return ((xHWREG(ulBase + SPI_CNTRL) & SPI_CNTRL_GO_BUSY) ? xtrue : xfalse);
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Returns true if the running PIO transfer is a PIO out (i.e. data is transferred from the device to the guest), false if it's a PIO in */
|
static bool ide_is_pio_out(IDEState *s)
|
/* Returns true if the running PIO transfer is a PIO out (i.e. data is transferred from the device to the guest), false if it's a PIO in */
static bool ide_is_pio_out(IDEState *s)
|
{
if (s->end_transfer_func == ide_sector_write ||
s->end_transfer_func == ide_atapi_cmd) {
return false;
} else if (s->end_transfer_func == ide_sector_read ||
s->end_transfer_func == ide_transfer_stop ||
s->end_transfer_func == ide_atapi_cmd_reply_end ||
s->end_transfer_func == ide_dummy_transfer_stop) {
return true;
}
abort();
}
|
ve3wwg/teensy3_qemu
|
C++
|
Other
| 15
|
/* If this interface is not supported, then return FALSE. */
|
BOOLEAN EFIAPI HmacSha384All(IN CONST VOID *Data, IN UINTN DataSize, IN CONST UINT8 *Key, IN UINTN KeySize, OUT UINT8 *HmacValue)
|
/* If this interface is not supported, then return FALSE. */
BOOLEAN EFIAPI HmacSha384All(IN CONST VOID *Data, IN UINTN DataSize, IN CONST UINT8 *Key, IN UINTN KeySize, OUT UINT8 *HmacValue)
|
{
CALL_CRYPTO_SERVICE (HmacSha384All, (Data, DataSize, Key, KeySize, HmacValue), FALSE);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Deinitializes the SPIx peripheral registers to their default reset values. */
|
void SPI_I2S_DeInit(SPI_TypeDef *SPIx)
|
/* Deinitializes the SPIx peripheral registers to their default reset values. */
void SPI_I2S_DeInit(SPI_TypeDef *SPIx)
|
{
assert_param(IS_SPI_ALL_PERIPH(SPIx));
if (SPIx == SPI1)
{
RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI1, ENABLE);
RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI1, DISABLE);
}
else
{
if (SPIx == SPI2)
{
RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI2, ENABLE);
RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI2, DISABLE);
}
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* The attach() and detach() entry points are used to create and destroy "instances" of the driver, where each instance represents everything needed to manage one actual PCMCIA card. */
|
static void avmcs_detach(struct pcmcia_device *p_dev)
|
/* The attach() and detach() entry points are used to create and destroy "instances" of the driver, where each instance represents everything needed to manage one actual PCMCIA card. */
static void avmcs_detach(struct pcmcia_device *p_dev)
|
{
avmcs_release(link);
kfree(link->priv);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* In case of 0xff erased flash this does not modify data that is written to flash; in case of other flash devices, e.g. that erase to 0x00, it allows to correctly use the first bit of byte to figure out how many bytes are there and if there is any data at all or both bytes are equal to erase value. */
|
int fcb_put_len(const struct fcb *fcb, uint8_t *buf, uint16_t len)
|
/* In case of 0xff erased flash this does not modify data that is written to flash; in case of other flash devices, e.g. that erase to 0x00, it allows to correctly use the first bit of byte to figure out how many bytes are there and if there is any data at all or both bytes are equal to erase value. */
int fcb_put_len(const struct fcb *fcb, uint8_t *buf, uint16_t len)
|
{
if (len < 0x80) {
buf[0] = len ^ ~fcb->f_erase_value;
return 1;
} else if (len < FCB_MAX_LEN) {
buf[0] = (len | 0x80) ^ ~fcb->f_erase_value;
buf[1] = (len >> 7) ^ ~fcb->f_erase_value;
return 2;
} else {
return -EINVAL;
}
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* The routines beyond this point handle the behaviour of an AF_INET socket object. Mostly it punts to the subprotocols of IP to do the work. Automatically bind an unbound socket. */
|
static int inet_autobind(struct sock *sk)
|
/* The routines beyond this point handle the behaviour of an AF_INET socket object. Mostly it punts to the subprotocols of IP to do the work. Automatically bind an unbound socket. */
static int inet_autobind(struct sock *sk)
|
{
struct inet_sock *inet;
lock_sock(sk);
inet = inet_sk(sk);
if (!inet->inet_num) {
if (sk->sk_prot->get_port(sk, 0)) {
release_sock(sk);
return -EAGAIN;
}
inet->inet_sport = htons(inet->inet_num);
}
release_sock(sk);
return 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* ufshcd_comp_devman_upiu - UFS Protocol Information Unit(UPIU) for Device Management Purposes */
|
static int ufshcd_comp_devman_upiu(struct ufs_hba *hba, enum dev_cmd_type cmd_type)
|
/* ufshcd_comp_devman_upiu - UFS Protocol Information Unit(UPIU) for Device Management Purposes */
static int ufshcd_comp_devman_upiu(struct ufs_hba *hba, enum dev_cmd_type cmd_type)
|
{
u32 upiu_flags;
int ret = 0;
struct utp_transfer_req_desc *req_desc = hba->utrdl;
hba->dev_cmd.type = cmd_type;
ufshcd_prepare_req_desc_hdr(req_desc, &upiu_flags, DMA_NONE);
switch (cmd_type) {
case DEV_CMD_TYPE_QUERY:
ufshcd_prepare_utp_query_req_upiu(hba, upiu_flags);
break;
case DEV_CMD_TYPE_NOP:
ufshcd_prepare_utp_nop_upiu(hba);
break;
default:
ret = -EINVAL;
}
return ret;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* It returns amount of memory configured in bytes. */
|
phys_size_t fsl_ddr_sdram(void)
|
/* It returns amount of memory configured in bytes. */
phys_size_t fsl_ddr_sdram(void)
|
{
fsl_ddr_info_t info;
memset(&info, 0, sizeof(fsl_ddr_info_t));
info.mem_base = CONFIG_SYS_FSL_DDR_SDRAM_BASE_PHY;
info.first_ctrl = 0;
info.num_ctrls = CONFIG_SYS_FSL_DDR_MAIN_NUM_CTRLS;
info.dimm_slots_per_ctrl = CONFIG_DIMM_SLOTS_PER_CTLR;
info.board_need_mem_reset = board_need_mem_reset;
info.board_mem_reset = board_assert_mem_reset;
info.board_mem_de_reset = board_deassert_mem_reset;
remove_unused_controllers(&info);
return __fsl_ddr_sdram(&info);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Returns a newly built xmlURIPtr or NULL in case of error */
|
xmlURIPtr xmlParseURIRaw(const char *str, int raw)
|
/* Returns a newly built xmlURIPtr or NULL in case of error */
xmlURIPtr xmlParseURIRaw(const char *str, int raw)
|
{
if (raw) {
uri->cleanup |= 2;
}
ret = xmlParseURIReference(uri, str);
if (ret) {
xmlFreeURI(uri);
return(NULL);
}
}
return(uri);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Call the driver model init functions to initialize their subsystems. Called early from init/main.c. */
|
void __init driver_init(void)
|
/* Call the driver model init functions to initialize their subsystems. Called early from init/main.c. */
void __init driver_init(void)
|
{
devtmpfs_init();
devices_init();
buses_init();
classes_init();
firmware_init();
hypervisor_init();
platform_bus_init();
system_bus_init();
cpu_dev_init();
memory_dev_init();
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* If 32-bit MMIO register operations are not supported, then ASSERT(). */
|
UINT32 EFIAPI MmioWrite32(IN UINTN Address, IN UINT32 Value)
|
/* If 32-bit MMIO register operations are not supported, then ASSERT(). */
UINT32 EFIAPI MmioWrite32(IN UINTN Address, IN UINT32 Value)
|
{
BOOLEAN Flag;
ASSERT ((Address & 3) == 0);
Flag = FilterBeforeMmIoWrite (FilterWidth32, Address, &Value);
if (Flag) {
MmioWrite32Internal (Address, Value);
}
FilterAfterMmIoWrite (FilterWidth32, Address, &Value);
return Value;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* sets the Frame Control WiFi frame header conversion parameter */
|
IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBWiFiFrameControlSet(IxEthDBPortId portID, UINT16 frameControl)
|
/* sets the Frame Control WiFi frame header conversion parameter */
IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBWiFiFrameControlSet(IxEthDBPortId portID, UINT16 frameControl)
|
{
IX_ETH_DB_CHECK_PORT(portID);
IX_ETH_DB_CHECK_SINGLE_NPE(portID);
IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_WIFI_HEADER_CONVERSION);
ixEthDBPortInfo[portID].frameControlDurationID = (ixEthDBPortInfo[portID].frameControlDurationID & 0xFFFF) | (frameControl << 16);
return ixEthDBWiFiFrameControlDurationIDUpdate(portID);
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* Registers an interrupt handler for a I2S interrupt. */
|
void I2SIntRegister(unsigned long ulBase, void(*pfnHandler)(void))
|
/* Registers an interrupt handler for a I2S interrupt. */
void I2SIntRegister(unsigned long ulBase, void(*pfnHandler)(void))
|
{
IntRegister(INT_I2S,pfnHandler);
IntEnable(INT_I2S);
}
|
micropython/micropython
|
C++
|
Other
| 18,334
|
/* Change the period of a timer.
If OS_TimerChangePeriod() is used to change the period of a timer that is not already running, then the timer will use the new period value to calculate an expiry time, and the timer will start running. */
|
OS_Status OS_TimerChangePeriod(OS_Timer_t *timer, OS_Time_t periodMS)
|
/* Change the period of a timer.
If OS_TimerChangePeriod() is used to change the period of a timer that is not already running, then the timer will use the new period value to calculate an expiry time, and the timer will start running. */
OS_Status OS_TimerChangePeriod(OS_Timer_t *timer, OS_Time_t periodMS)
|
{
rt_err_t ret;
OS_DBG("%s(), handle %p\n", __func__, timer->handle);
OS_HANDLE_ASSERT(OS_TimerIsValid(timer), timer->handle);
if (OS_TimerIsActive(timer)) {
ret = rt_timer_stop(timer->handle);
if (ret != RT_EOK) {
OS_ERR("err %"OS_BASETYPE_F"\n", ret);
return OS_FAIL;
}
}
ret = rt_timer_control(timer->handle, RT_TIMER_CTRL_SET_TIME, &periodMS);
if (ret != RT_EOK) {
OS_ERR("err %"OS_BASETYPE_F"\n", ret);
return OS_FAIL;
}
ret = rt_timer_start(timer->handle);
if (ret != RT_EOK) {
OS_ERR("err %"OS_BASETYPE_F"\n", ret);
return OS_FAIL;
}
return OS_OK;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* We have to do a lock/unlock here to refresh the inode size for O_APPEND writes, otherwise we can land up writing at the wrong offset. There is still a race, but provided the app is using its own file locking, this will make O_APPEND work as expected. */
|
static ssize_t gfs2_file_aio_write(struct kiocb *iocb, const struct iovec *iov, unsigned long nr_segs, loff_t pos)
|
/* We have to do a lock/unlock here to refresh the inode size for O_APPEND writes, otherwise we can land up writing at the wrong offset. There is still a race, but provided the app is using its own file locking, this will make O_APPEND work as expected. */
static ssize_t gfs2_file_aio_write(struct kiocb *iocb, const struct iovec *iov, unsigned long nr_segs, loff_t pos)
|
{
struct file *file = iocb->ki_filp;
if (file->f_flags & O_APPEND) {
struct dentry *dentry = file->f_dentry;
struct gfs2_inode *ip = GFS2_I(dentry->d_inode);
struct gfs2_holder gh;
int ret;
ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, 0, &gh);
if (ret)
return ret;
gfs2_glock_dq_uninit(&gh);
}
return generic_file_aio_write(iocb, iov, nr_segs, pos);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Function to check IO scan chain engine status and wait if the engine is is active. Poll the IO scan chain engine till maximum iteration reached. */
|
static u32 scan_chain_engine_is_idle(u32 max_iter)
|
/* Function to check IO scan chain engine status and wait if the engine is is active. Poll the IO scan chain engine till maximum iteration reached. */
static u32 scan_chain_engine_is_idle(u32 max_iter)
|
{
const u32 mask = SCANMGR_STAT_ACTIVE | SCANMGR_STAT_WFIFOCNT_MASK;
u32 status;
do {
status = readl(&scan_manager_base->stat);
if (!(status & mask))
return 0;
} while (max_iter--);
return -ETIMEDOUT;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Free the host once all references to it have been dropped. */
|
void mmc_free_host(struct mmc_host *host)
|
/* Free the host once all references to it have been dropped. */
void mmc_free_host(struct mmc_host *host)
|
{
spin_lock(&mmc_host_lock);
idr_remove(&mmc_host_idr, host->index);
spin_unlock(&mmc_host_lock);
put_device(&host->class_dev);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* IvSize must be 12, otherwise FALSE is returned. KeySize must be 16, 24 or 32, otherwise FALSE is returned. TagSize must be 12, 13, 14, 15, 16, otherwise FALSE is returned. If additional authenticated data verification fails, FALSE is returned. */
|
BOOLEAN EFIAPI CryptoServiceAeadAesGcmDecrypt(IN CONST UINT8 *Key, IN UINTN KeySize, IN CONST UINT8 *Iv, IN UINTN IvSize, IN CONST UINT8 *AData, IN UINTN ADataSize, IN CONST UINT8 *DataIn, IN UINTN DataInSize, IN CONST UINT8 *Tag, IN UINTN TagSize, OUT UINT8 *DataOut, OUT UINTN *DataOutSize)
|
/* IvSize must be 12, otherwise FALSE is returned. KeySize must be 16, 24 or 32, otherwise FALSE is returned. TagSize must be 12, 13, 14, 15, 16, otherwise FALSE is returned. If additional authenticated data verification fails, FALSE is returned. */
BOOLEAN EFIAPI CryptoServiceAeadAesGcmDecrypt(IN CONST UINT8 *Key, IN UINTN KeySize, IN CONST UINT8 *Iv, IN UINTN IvSize, IN CONST UINT8 *AData, IN UINTN ADataSize, IN CONST UINT8 *DataIn, IN UINTN DataInSize, IN CONST UINT8 *Tag, IN UINTN TagSize, OUT UINT8 *DataOut, OUT UINTN *DataOutSize)
|
{
return CALL_BASECRYPTLIB (AeadAesGcm.Services.Decrypt, AeadAesGcmDecrypt, (Key, KeySize, Iv, IvSize, AData, ADataSize, DataIn, DataInSize, Tag, TagSize, DataOut, DataOutSize), FALSE);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Command that prints the status of one or all of the PPCs. */
|
static int cmd_ppc_status(const struct shell *sh, size_t argc, char **argv)
|
/* Command that prints the status of one or all of the PPCs. */
static int cmd_ppc_status(const struct shell *sh, size_t argc, char **argv)
|
{
int ret = 0;
if (argc <= 1) {
DT_FOREACH_STATUS_OKAY_VARGS(usb_c_connector, CALL_IF_HAS_PPC, print_status);
} else {
const struct device *dev = device_get_binding(argv[1]);
ret = print_status(dev);
}
return ret;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Please refer to the official documentation for function purpose and expected parameters. */
|
int ph7_context_push_aux_data(ph7_context *pCtx, void *pUserData)
|
/* Please refer to the official documentation for function purpose and expected parameters. */
int ph7_context_push_aux_data(ph7_context *pCtx, void *pUserData)
|
{
return pCtx->pFunc->pUserData;
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* Enables or disables the selected ADC software start conversion . */
|
void ADC_SoftwareStartConvCmd(ADC_TypeDef *ADCx, FunctionalState NewState)
|
/* Enables or disables the selected ADC software start conversion . */
void ADC_SoftwareStartConvCmd(ADC_TypeDef *ADCx, FunctionalState NewState)
|
{
assert_param(IS_ADC_ALL_PERIPH(ADCx));
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
ADCx->CR2 |= CR2_EXTTRIG_SWSTART_Set;
}
else
{
ADCx->CR2 &= CR2_EXTTRIG_SWSTART_Reset;
}
}
|
gcallipo/RadioDSP-Stm32f103
|
C++
|
Common Creative - Attribution 3.0
| 51
|
/* igb_receive_skb - helper function to handle rx indications @q_vector: structure containing interrupt and ring information @skb: packet to send up @vlan_tag: vlan tag for packet */
|
static void igb_receive_skb(struct igb_q_vector *q_vector, struct sk_buff *skb, u16 vlan_tag)
|
/* igb_receive_skb - helper function to handle rx indications @q_vector: structure containing interrupt and ring information @skb: packet to send up @vlan_tag: vlan tag for packet */
static void igb_receive_skb(struct igb_q_vector *q_vector, struct sk_buff *skb, u16 vlan_tag)
|
{
struct igb_adapter *adapter = q_vector->adapter;
if (vlan_tag)
vlan_gro_receive(&q_vector->napi, adapter->vlgrp,
vlan_tag, skb);
else
napi_gro_receive(&q_vector->napi, skb);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Enable the ADC.
Use this function to enable the ADC. */
|
void am_hal_adc_enable(void)
|
/* Enable the ADC.
Use this function to enable the ADC. */
void am_hal_adc_enable(void)
|
{
AM_BFW(ADC, CFG, ADCEN, 0x1);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Un-Register the Service B.3 and all its Characteristics... */
|
void service_b_3_3_remove(void)
|
/* Un-Register the Service B.3 and all its Characteristics... */
void service_b_3_3_remove(void)
|
{
bt_gatt_service_unregister(&service_b_3_3_svc);
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* See the Unified Extensible Firmware Interface (UEFI) specification for details. */
|
static efi_status_t EFIAPI efi_cin_reset(struct efi_simple_text_input_protocol *this, bool extended_verification)
|
/* See the Unified Extensible Firmware Interface (UEFI) specification for details. */
static efi_status_t EFIAPI efi_cin_reset(struct efi_simple_text_input_protocol *this, bool extended_verification)
|
{
efi_status_t ret = EFI_SUCCESS;
EFI_ENTRY("%p, %d", this, extended_verification);
if (!this) {
ret = EFI_INVALID_PARAMETER;
goto out;
}
efi_cin_empty_buffer();
out:
return EFI_EXIT(ret);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* XDR the MSG_ACCEPTED part of a reply message union */
|
static bool_t xdr_accepted_reply(XDR *xdrs, struct accepted_reply *ar)
|
/* XDR the MSG_ACCEPTED part of a reply message union */
static bool_t xdr_accepted_reply(XDR *xdrs, struct accepted_reply *ar)
|
{
if (!xdr_opaque_auth(xdrs, &(ar->ar_verf)))
return (FALSE);
if (!xdr_enum(xdrs, (enum_t *) & (ar->ar_stat)))
return (FALSE);
switch (ar->ar_stat) {
case SUCCESS:
return ((*(ar->ar_results.proc)) (xdrs, ar->ar_results.where));
case PROG_MISMATCH:
if (!xdr_u_long(xdrs, &(ar->ar_vers.low)))
return (FALSE);
return (xdr_u_long(xdrs, &(ar->ar_vers.high)));
}
return (TRUE);
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* Populates @insn->modrm and updates @insn->next_byte to point past the ModRM byte, if any. If necessary, first collects the preceding bytes (prefixes and opcode(s)). No effect if @insn->modrm.got is already 1. */
|
void insn_get_modrm(struct insn *insn)
|
/* Populates @insn->modrm and updates @insn->next_byte to point past the ModRM byte, if any. If necessary, first collects the preceding bytes (prefixes and opcode(s)). No effect if @insn->modrm.got is already 1. */
void insn_get_modrm(struct insn *insn)
|
{
struct insn_field *modrm = &insn->modrm;
insn_byte_t pfx, mod;
if (modrm->got)
return;
if (!insn->opcode.got)
insn_get_opcode(insn);
if (inat_has_modrm(insn->attr)) {
mod = get_next(insn_byte_t, insn);
modrm->value = mod;
modrm->nbytes = 1;
if (inat_is_group(insn->attr)) {
pfx = insn_last_prefix(insn);
insn->attr = inat_get_group_attribute(mod, pfx,
insn->attr);
}
}
if (insn->x86_64 && inat_is_force64(insn->attr))
insn->opnd_bytes = 8;
modrm->got = 1;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* 6.5.3.6. FMS Identify (Confirmed Service Id = 1) 6.5.3.6.1. Request Message Parameters */
|
static void dissect_ff_msg_fms_id_req(tvbuff_t *tvb, gint offset, guint32 length, packet_info *pinfo, proto_tree *tree)
|
/* 6.5.3.6. FMS Identify (Confirmed Service Id = 1) 6.5.3.6.1. Request Message Parameters */
static void dissect_ff_msg_fms_id_req(tvbuff_t *tvb, gint offset, guint32 length, packet_info *pinfo, proto_tree *tree)
|
{
proto_tree *sub_tree;
col_set_str(pinfo->cinfo, COL_INFO, "FMS Identify Request");
if (!tree) {
return;
}
if (length) {
sub_tree = proto_tree_add_subtree(tree, tvb, offset, length,
ett_ff_fms_id_req, NULL, "FMS Identify Request");
proto_tree_add_item(sub_tree, hf_ff_unknown_data, tvb, offset, length, ENC_NA);
}
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Acquires a context element from the free list and locks the mutex on the context. Sets the msg_ctx task to current. Returns zero on success; non-zero on error or upon failure to acquire a free context element. Must be called with ecryptfs_msg_ctx_lists_mux held. */
|
static int ecryptfs_acquire_free_msg_ctx(struct ecryptfs_msg_ctx **msg_ctx)
|
/* Acquires a context element from the free list and locks the mutex on the context. Sets the msg_ctx task to current. Returns zero on success; non-zero on error or upon failure to acquire a free context element. Must be called with ecryptfs_msg_ctx_lists_mux held. */
static int ecryptfs_acquire_free_msg_ctx(struct ecryptfs_msg_ctx **msg_ctx)
|
{
struct list_head *p;
int rc;
if (list_empty(&ecryptfs_msg_ctx_free_list)) {
printk(KERN_WARNING "%s: The eCryptfs free "
"context list is empty. It may be helpful to "
"specify the ecryptfs_message_buf_len "
"parameter to be greater than the current "
"value of [%d]\n", __func__, ecryptfs_message_buf_len);
rc = -ENOMEM;
goto out;
}
list_for_each(p, &ecryptfs_msg_ctx_free_list) {
*msg_ctx = list_entry(p, struct ecryptfs_msg_ctx, node);
if (mutex_trylock(&(*msg_ctx)->mux)) {
(*msg_ctx)->task = current;
rc = 0;
goto out;
}
}
rc = -ENOMEM;
out:
return rc;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Note that this function destroys the original nameidata */
|
struct file* nameidata_to_filp(struct nameidata *nd)
|
/* Note that this function destroys the original nameidata */
struct file* nameidata_to_filp(struct nameidata *nd)
|
{
const struct cred *cred = current_cred();
struct file *filp;
filp = nd->intent.open.file;
if (filp->f_path.dentry == NULL)
filp = __dentry_open(nd->path.dentry, nd->path.mnt, filp,
NULL, cred);
else
path_put(&nd->path);
return filp;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). */
|
UINT16 EFIAPI PciExpressAnd16(IN UINTN Address, IN UINT16 AndData)
|
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). */
UINT16 EFIAPI PciExpressAnd16(IN UINTN Address, IN UINT16 AndData)
|
{
if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {
return (UINT16)-1;
}
return MmioAnd16 (GetPciExpressAddress (Address), AndData);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* close and disable the interface, leaving the 586 in reset. */
|
static int eexp_close(struct net_device *dev)
|
/* close and disable the interface, leaving the 586 in reset. */
static int eexp_close(struct net_device *dev)
|
{
unsigned short ioaddr = dev->base_addr;
struct net_local *lp = netdev_priv(dev);
int irq = dev->irq;
netif_stop_queue(dev);
outb(SIRQ_dis|irqrmap[irq],ioaddr+SET_IRQ);
lp->started = 0;
scb_command(dev, SCB_CUsuspend|SCB_RUsuspend);
outb(0,ioaddr+SIGNAL_CA);
free_irq(irq,dev);
outb(i586_RST,ioaddr+EEPROM_Ctrl);
release_region(ioaddr, EEXP_IO_EXTENT);
release_region(ioaddr+0x4000, 16);
release_region(ioaddr+0x8000, 16);
release_region(ioaddr+0xc000, 16);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Function for transferring the SLIP end frame byte, 0xC0. */
|
static uint32_t send_tx_byte_end(void)
|
/* Function for transferring the SLIP end frame byte, 0xC0. */
static uint32_t send_tx_byte_end(void)
|
{
uint32_t err_code = app_uart_put(APP_SLIP_END);
if ((err_code == NRF_SUCCESS) && (m_tx_buffer_index == 0))
{
send_tx_byte = send_tx_byte_default;
}
return err_code;
}
|
labapart/polymcu
|
C++
| null | 201
|
/* If 16-bit operations are not supported, 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(). */
|
UINT16 EFIAPI BitFieldRead16(IN UINT16 Operand, IN UINTN StartBit, IN UINTN EndBit)
|
/* If 16-bit operations are not supported, 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(). */
UINT16 EFIAPI BitFieldRead16(IN UINT16 Operand, IN UINTN StartBit, IN UINTN EndBit)
|
{
ASSERT (EndBit < 16);
ASSERT (StartBit <= EndBit);
return (UINT16)InternalBaseLibBitFieldReadUint (Operand, StartBit, EndBit);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* The function will delete a memory region that is only accessible by the calling thread. The deleted region will be accessible by other threads. */
|
rt_err_t rt_mprotect_delete_exclusive_region(void *start, rt_size_t size)
|
/* The function will delete a memory region that is only accessible by the calling thread. The deleted region will be accessible by other threads. */
rt_err_t rt_mprotect_delete_exclusive_region(void *start, rt_size_t size)
|
{
rt_uint8_t i;
rt_enter_critical();
for (i = 0; i < NUM_EXCLUSIVE_REGIONS; i++)
{
if (exclusive_regions[i].owner == rt_thread_self() && exclusive_regions[i].region.start == start && exclusive_regions[i].region.size == size)
{
exclusive_regions[i].owner = RT_NULL;
rt_exit_critical();
return RT_EOK;
}
}
rt_exit_critical();
LOG_E("Region not found");
return RT_ERROR;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Each passed coefficient array must be the right size for that coefficient: width_in_blocks wide and height_in_blocks high, with unitheight at least v_samp_factor. */
|
transencode_coef_controller(j_compress_ptr cinfo, jvirt_barray_ptr *coef_arrays)
|
/* Each passed coefficient array must be the right size for that coefficient: width_in_blocks wide and height_in_blocks high, with unitheight at least v_samp_factor. */
transencode_coef_controller(j_compress_ptr cinfo, jvirt_barray_ptr *coef_arrays)
|
{
my_coef_ptr coef;
JBLOCKROW buffer;
int i;
coef = (my_coef_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
SIZEOF(my_coef_controller));
cinfo->coef = (struct jpeg_c_coef_controller*) coef;
coef->pub.start_pass = start_pass_coef;
coef->pub.compress_data = compress_output;
coef->whole_image = coef_arrays;
buffer = (JBLOCKROW)
(*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE,
C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK));
jzero_far((void FAR*) buffer, C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK));
for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) {
coef->dummy_buffer[i] = buffer + i;
}
}
|
nanoframework/nf-interpreter
|
C++
|
MIT License
| 293
|
/* Command response callback function for sd_ble_gattc_info_discover BLE command.
Callback for decoding the command response return code. */
|
static uint32_t gattc_attr_info_discover_rsp_dec(const uint8_t *p_buffer, uint16_t length)
|
/* Command response callback function for sd_ble_gattc_info_discover BLE command.
Callback for decoding the command response return code. */
static uint32_t gattc_attr_info_discover_rsp_dec(const uint8_t *p_buffer, uint16_t length)
|
{
uint32_t result_code;
const uint32_t err_code = ble_gattc_attr_info_discover_rsp_dec(p_buffer, length, &result_code);
APP_ERROR_CHECK(err_code);
return result_code;
}
|
labapart/polymcu
|
C++
| null | 201
|
/* Clean RX queue, any received data still stored in the buffers is abandoned. */
|
static void rx_error_handler(Gmac *gmac, struct gmac_queue *queue)
|
/* Clean RX queue, any received data still stored in the buffers is abandoned. */
static void rx_error_handler(Gmac *gmac, struct gmac_queue *queue)
|
{
queue->err_rx_flushed_count++;
gmac->GMAC_NCR &= ~GMAC_NCR_RXEN;
queue->rx_desc_list.tail = 0U;
for (int i = 0; i < queue->rx_desc_list.len; i++) {
queue->rx_desc_list.buf[i].w1 = 0U;
queue->rx_desc_list.buf[i].w0 &= ~GMAC_RXW0_OWNERSHIP;
}
set_receive_buf_queue_pointer(gmac, queue);
gmac->GMAC_NCR |= GMAC_NCR_RXEN;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* The initiator checks the CHAP response replied by target against its own calculation of the expected hash value. */
|
EFI_STATUS IScsiCHAPAuthTarget(IN ISCSI_CHAP_AUTH_DATA *AuthData, IN UINT8 *TargetResponse)
|
/* The initiator checks the CHAP response replied by target against its own calculation of the expected hash value. */
EFI_STATUS IScsiCHAPAuthTarget(IN ISCSI_CHAP_AUTH_DATA *AuthData, IN UINT8 *TargetResponse)
|
{
EFI_STATUS Status;
UINT32 SecretSize;
UINT8 VerifyRsp[ISCSI_CHAP_MAX_DIGEST_SIZE];
INTN Mismatch;
Status = EFI_SUCCESS;
SecretSize = (UINT32)AsciiStrLen (AuthData->AuthConfig->ReverseCHAPSecret);
ASSERT (AuthData->Hash != NULL);
Status = IScsiCHAPCalculateResponse (
AuthData->OutIdentifier,
AuthData->AuthConfig->ReverseCHAPSecret,
SecretSize,
AuthData->OutChallenge,
AuthData->Hash->DigestSize,
AuthData->Hash,
VerifyRsp
);
Mismatch = CompareMem (
VerifyRsp,
TargetResponse,
AuthData->Hash->DigestSize
);
if (Mismatch != 0) {
Status = EFI_SECURITY_VIOLATION;
}
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This file is part of the Simba project. */
|
int mock_write_dac_module_init(int res)
|
/* This file is part of the Simba project. */
int mock_write_dac_module_init(int res)
|
{
harness_mock_write("dac_module_init()",
NULL,
0);
harness_mock_write("dac_module_init(): return (res)",
&res,
sizeof(res));
return (0);
}
|
eerimoq/simba
|
C++
|
Other
| 337
|
/* param base XBARA peripheral address. param input XBARA input signal. param output XBARA output signal. */
|
void XBARA_SetSignalsConnection(XBARA_Type *base, xbar_input_signal_t input, xbar_output_signal_t output)
|
/* param base XBARA peripheral address. param input XBARA input signal. param output XBARA output signal. */
void XBARA_SetSignalsConnection(XBARA_Type *base, xbar_input_signal_t input, xbar_output_signal_t output)
|
{
xbara_u8_u16_t regVal;
uint8_t byteInReg;
uint8_t outputIndex = (uint8_t)output;
byteInReg = outputIndex % 2U;
regVal._u16 = XBARA_SELx(base, outputIndex);
regVal._u8[byteInReg] = (uint8_t)input;
XBARA_SELx(base, outputIndex) = regVal._u16;
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Calls a function on each valid #GHook and destroys it if the function returns FALSE. */
|
void g_hook_list_marshal_check(GHookList *hook_list, gboolean may_recurse, GHookCheckMarshaller marshaller, gpointer data)
|
/* Calls a function on each valid #GHook and destroys it if the function returns FALSE. */
void g_hook_list_marshal_check(GHookList *hook_list, gboolean may_recurse, GHookCheckMarshaller marshaller, gpointer data)
|
{
GHook *hook;
g_return_if_fail (hook_list != NULL);
g_return_if_fail (hook_list->is_setup);
g_return_if_fail (marshaller != NULL);
hook = g_hook_first_valid (hook_list, may_recurse);
while (hook)
{
gboolean was_in_call;
gboolean need_destroy;
was_in_call = G_HOOK_IN_CALL (hook);
hook->flags |= G_HOOK_FLAG_IN_CALL;
need_destroy = !marshaller (hook, data);
if (!was_in_call)
hook->flags &= ~G_HOOK_FLAG_IN_CALL;
if (need_destroy)
g_hook_destroy_link (hook_list, hook);
hook = g_hook_next_valid (hook_list, hook, may_recurse);
}
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* This is the code that gets called on processor reset. To initialize the device, and call the main() routine. */
|
void Reset_Handler(void)
|
/* This is the code that gets called on processor reset. To initialize the device, and call the main() routine. */
void Reset_Handler(void)
|
{
uint32_t *pSrc, *pDest;
pSrc = &_etext;
pDest = &_srelocate;
if (pSrc != pDest) {
for (; pDest < &_erelocate;) {
*pDest++ = *pSrc++;
}
}
for (pDest = &_szero; pDest < &_ezero;) {
*pDest++ = 0;
}
pSrc = (uint32_t *) & _sfixed;
SCB->VTOR = ((uint32_t) pSrc & SCB_VTOR_TBLOFF_Msk);
if (((uint32_t) pSrc >= IRAM0_ADDR) && ((uint32_t) pSrc < IRAM0_ADDR + IRAM_SIZE)) {
SCB->VTOR |= 1 << SCB_VTOR_TBLBASE_Pos;
}
__libc_init_array();
main();
while (1);
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Change Logs: Date Author Notes Bernard the first verion */
|
void vmm_guest_isr(int irqno, void *parameter)
|
/* Change Logs: Date Author Notes Bernard the first verion */
void vmm_guest_isr(int irqno, void *parameter)
|
{
rt_hw_interrupt_clear(irqno);
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* Retrieve the amount of cycles to delay for the given amount of us. */
|
static uint32_t _get_cycles_for_us_internal(const uint16_t us, const uint32_t freq, const uint8_t power)
|
/* Retrieve the amount of cycles to delay for the given amount of us. */
static uint32_t _get_cycles_for_us_internal(const uint16_t us, const uint32_t freq, const uint8_t power)
|
{
switch (power) {
case 9:
return (us * (freq / 1000000));
case 8:
return (us * (freq / 100000) + 9) / 10;
case 7:
return (us * (freq / 10000) + 99) / 100;
case 6:
return (us * (freq / 1000) + 999) / 1000;
case 5:
return (us * (freq / 100) + 9999) / 10000;
default:
return (us * freq + 999999) / 1000000;
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* \This function will force the processor enter sleep mode,after operating the action,some clocks will be closed except "Internal 32 kHz low speed
oscillator clock". */
|
void PWRCtlStandby(void)
|
/* \This function will force the processor enter sleep mode,after operating the action,some clocks will be closed except "Internal 32 kHz low speed
oscillator clock". */
void PWRCtlStandby(void)
|
{
xSysCtlClockSet(72000000, xSYSCTL_XTAL_8MHZ | xSYSCTL_OSC_MAIN);
xSysCtlSleep();
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Parse a list of impulse response arguments Helper function for cn0503_impulse_response, cn0503_fluo_decay_calibrate/measure. */
|
int32_t impulse_response_parse_arg_list(struct cn0503_impulse_response *impresp, uint8_t *arg, void **argvals, uint8_t *arg_types, uint8_t nb_args, uint8_t nb_required_args, uint8_t *nb_args_parsed)
|
/* Parse a list of impulse response arguments Helper function for cn0503_impulse_response, cn0503_fluo_decay_calibrate/measure. */
int32_t impulse_response_parse_arg_list(struct cn0503_impulse_response *impresp, uint8_t *arg, void **argvals, uint8_t *arg_types, uint8_t nb_args, uint8_t nb_required_args, uint8_t *nb_args_parsed)
|
{
uint8_t i, *space_ptr;
if (nb_args_parsed != NULL)
*nb_args_parsed = 0;
for (i = 0; i < nb_args; i++) {
space_ptr = (uint8_t *)strchr((char *)arg, ' ');
if (space_ptr)
*space_ptr = 0;
if (arg_types[i] == METHOD && strnlen((char *) arg, 4) < 3)
return FAILURE;
impulse_response_parse_arg(impresp, arg, argvals[i], arg_types[i]);
if (nb_args_parsed != NULL)
*nb_args_parsed++;
if (space_ptr == NULL) {
if (i < nb_required_args - 1)
return FAILURE;
else
break;
}
arg = space_ptr + 1;
}
i++;
return SUCCESS;
}
|
analogdevicesinc/EVAL-ADICUP3029
|
C++
|
Other
| 36
|
/* Check whether the emulator supports executing a certain PE/COFF image */
|
BOOLEAN EFIAPI EbcIsImageSupported(IN EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL *This, IN UINT16 ImageType, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL)
|
/* Check whether the emulator supports executing a certain PE/COFF image */
BOOLEAN EFIAPI EbcIsImageSupported(IN EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL *This, IN UINT16 ImageType, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL)
|
{
if ((ImageType != EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION) &&
(ImageType != EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER))
{
return FALSE;
}
return TRUE;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This API is used to parse and store the sensor time from the FIFO data in the structure instance dev. */
|
static void unpack_sensortime_frame(uint16_t *data_index, const struct bmi160_dev *dev)
|
/* This API is used to parse and store the sensor time from the FIFO data in the structure instance dev. */
static void unpack_sensortime_frame(uint16_t *data_index, const struct bmi160_dev *dev)
|
{
uint32_t sensor_time_byte3 = 0;
uint16_t sensor_time_byte2 = 0;
uint8_t sensor_time_byte1 = 0;
if ((*data_index + BMI160_SENSOR_TIME_LENGTH) > dev->fifo->length)
{
*data_index = dev->fifo->length;
}
else
{
sensor_time_byte3 = dev->fifo->data[(*data_index) + BMI160_SENSOR_TIME_MSB_BYTE] << 16;
sensor_time_byte2 = dev->fifo->data[(*data_index) + BMI160_SENSOR_TIME_XLSB_BYTE] << 8;
sensor_time_byte1 = dev->fifo->data[(*data_index)];
dev->fifo->sensor_time = (uint32_t)(sensor_time_byte3 | sensor_time_byte2 | sensor_time_byte1);
*data_index = (*data_index) + BMI160_SENSOR_TIME_LENGTH;
}
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* enable the DMA1 channel 5 Full_Data transfer mode */
|
void dma_1_channel_5_fulldata_transfer_enable(void)
|
/* enable the DMA1 channel 5 Full_Data transfer mode */
void dma_1_channel_5_fulldata_transfer_enable(void)
|
{
DMA_ACFG |= DMA_ACFG_FD_CH5EN;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Enables critical writes operation on a serial flash device, such as sector protection, status register, etc. */
|
void s25fl1xx_enable_wrap(struct qspid_t *qspid, uint8_t byte_align)
|
/* Enables critical writes operation on a serial flash device, such as sector protection, status register, etc. */
void s25fl1xx_enable_wrap(struct qspid_t *qspid, uint8_t byte_align)
|
{
uint8_t status[3];
status[0] = s25fl1xx_read_status1(qspid);
status[1] = s25fl1xx_read_status2(qspid);
status[2] = s25fl1xx_read_status3(qspid);
status[2] |= (byte_align << 5);
dev->inst_frame.bm.b_dummy_cycles = 24;
s25fl1xx_exec_command(qspid, S25FL1XX_WRAP_ENABLE,(uint32_t *)&status[2], 0, QSPI_WRITE_ACCESS, 1);
s25fl1xx_write_volatile_status(qspid, status);
status[2] = s25fl1xx_read_status3(qspid);
while(!(status[2] & 0x10));
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* This function returns zero in case of success and a negative error code in case of failure. */
|
static int replay_buds(struct ubifs_info *c)
|
/* This function returns zero in case of success and a negative error code in case of failure. */
static int replay_buds(struct ubifs_info *c)
|
{
struct bud_entry *b;
int err, uninitialized_var(free), uninitialized_var(dirty);
list_for_each_entry(b, &c->replay_buds, list) {
err = replay_bud(c, b->bud->lnum, b->bud->start, b->bud->jhead,
&free, &dirty);
if (err)
return err;
err = insert_ref_node(c, b->bud->lnum, b->bud->start, b->sqnum,
free, dirty);
if (err)
return err;
}
return 0;
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* find_inode_fast is the fast path version of find_inode, see the comment at iget_locked for details. */
|
static struct inode* find_inode_fast(struct super_block *sb, struct hlist_head *head, unsigned long ino)
|
/* find_inode_fast is the fast path version of find_inode, see the comment at iget_locked for details. */
static struct inode* find_inode_fast(struct super_block *sb, struct hlist_head *head, unsigned long ino)
|
{
struct hlist_node *node;
struct inode *inode = NULL;
repeat:
hlist_for_each_entry(inode, node, head, i_hash) {
if (inode->i_ino != ino)
continue;
if (inode->i_sb != sb)
continue;
if (inode->i_state & (I_FREEING|I_CLEAR|I_WILL_FREE)) {
__wait_on_freeing_inode(inode);
goto repeat;
}
break;
}
return node ? inode : NULL;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Field Filling Function. Transform an EFI_EXP_BASE2_DATA to a byte, with '64k' as the unit. */
|
UINT8 Base2ToByteWith64KUnit(IN UINTN Value)
|
/* Field Filling Function. Transform an EFI_EXP_BASE2_DATA to a byte, with '64k' as the unit. */
UINT8 Base2ToByteWith64KUnit(IN UINTN Value)
|
{
UINT8 Size;
Size = ((Value + (SIZE_64KB - 1)) >> 16);
return Size;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Discover all Nvm Express device namespaces, and create child handles for them with BlockIo and DiskInfo protocol instances. */
|
EFI_STATUS DiscoverAllNamespaces(IN NVME_CONTROLLER_PRIVATE_DATA *Private)
|
/* Discover all Nvm Express device namespaces, and create child handles for them with BlockIo and DiskInfo protocol instances. */
EFI_STATUS DiscoverAllNamespaces(IN NVME_CONTROLLER_PRIVATE_DATA *Private)
|
{
EFI_STATUS Status;
UINT32 NamespaceId;
EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *Passthru;
NamespaceId = 0xFFFFFFFF;
Passthru = &Private->Passthru;
while (TRUE) {
Status = Passthru->GetNextNamespace (
Passthru,
(UINT32 *)&NamespaceId
);
if (EFI_ERROR (Status)) {
break;
}
Status = EnumerateNvmeDevNamespace (
Private,
NamespaceId
);
if (EFI_ERROR (Status)) {
continue;
}
}
return EFI_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This service enables discovery of additional firmware files. */
|
EFI_STATUS EFIAPI FfsFindNextFile(IN UINT8 SearchType, IN EFI_PEI_FV_HANDLE VolumeHandle, IN OUT EFI_PEI_FILE_HANDLE *FileHandle)
|
/* This service enables discovery of additional firmware files. */
EFI_STATUS EFIAPI FfsFindNextFile(IN UINT8 SearchType, IN EFI_PEI_FV_HANDLE VolumeHandle, IN OUT EFI_PEI_FILE_HANDLE *FileHandle)
|
{
return FindFileEx (VolumeHandle, NULL, SearchType, FileHandle);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Change Logs: Date Author Notes flybreak the first version. */
|
int __ARM_TPL_execute_once(__ARM_TPL_exec_once_flag *__flag, void(*__init_routine)(void))
|
/* Change Logs: Date Author Notes flybreak the first version. */
int __ARM_TPL_execute_once(__ARM_TPL_exec_once_flag *__flag, void(*__init_routine)(void))
|
{
if (*__flag == 0)
{
__init_routine();
*__flag = 1;
}
return 0;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* fsl_epu_setup - Setup EPU registers to default values */
|
void fsl_epu_setup(void *epu_base)
|
/* fsl_epu_setup - Setup EPU registers to default values */
void fsl_epu_setup(void *epu_base)
|
{
struct fsm_reg_vals *data = epu_default_val;
if (!epu_base || !data)
return;
while (data->offset != FSM_END_FLAG) {
out_be32(epu_base + data->offset, data->value);
data++;
}
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* ADC Enable the Overrun Interrupt.
The overrun interrupt is generated when data is not read from a result register before the next conversion is written. If DMA is enabled, all transfers are terminated and any conversion sequence is aborted. */
|
void adc_enable_overrun_interrupt(uint32_t adc)
|
/* ADC Enable the Overrun Interrupt.
The overrun interrupt is generated when data is not read from a result register before the next conversion is written. If DMA is enabled, all transfers are terminated and any conversion sequence is aborted. */
void adc_enable_overrun_interrupt(uint32_t adc)
|
{
ADC_IER(adc) |= ADC_IER_OVRIE;
}
|
insane-adding-machines/unicore-mx
|
C++
|
GNU General Public License v3.0
| 50
|
/* This API is used to get the interrupt enable of flat hysteresis("flat_hy) in the register 0x2F bit 0 to 2. */
|
BMA2x2_RETURN_FUNCTION_TYPE bma2x2_get_flat_hyst(u8 *flat_hyst_u8)
|
/* This API is used to get the interrupt enable of flat hysteresis("flat_hy) in the register 0x2F bit 0 to 2. */
BMA2x2_RETURN_FUNCTION_TYPE bma2x2_get_flat_hyst(u8 *flat_hyst_u8)
|
{
u8 data_u8 = BMA2x2_INIT_VALUE;
BMA2x2_RETURN_FUNCTION_TYPE com_rslt = ERROR;
if (p_bma2x2 == BMA2x2_NULL)
{
return E_BMA2x2_NULL_PTR;
}
else
{
com_rslt = p_bma2x2->BMA2x2_BUS_READ_FUNC
(p_bma2x2->dev_addr,
BMA2x2_FLAT_HYST_REG, &data_u8,
BMA2x2_GEN_READ_WRITE_LENGTH);
*flat_hyst_u8 = BMA2x2_GET_BITSLICE
(data_u8, BMA2x2_FLAT_HYST);
}
return com_rslt;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Get the oscillator frequency, from the corresponding hardware configuration field. T20 has 4 frequencies that it supports. */
|
enum clock_osc_freq clock_get_osc_freq(void)
|
/* Get the oscillator frequency, from the corresponding hardware configuration field. T20 has 4 frequencies that it supports. */
enum clock_osc_freq clock_get_osc_freq(void)
|
{
struct clk_rst_ctlr *clkrst =
(struct clk_rst_ctlr *)NV_PA_CLK_RST_BASE;
u32 reg;
reg = readl(&clkrst->crc_osc_ctrl);
return (reg & OSC_FREQ_MASK) >> OSC_FREQ_SHIFT;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* fst_half and snd_half must be different, but they can be the same as nodes. */
|
static void split_bezier(cairo_point_double_t p[4], cairo_point_double_t fst_half[4], cairo_point_double_t snd_half[4])
|
/* fst_half and snd_half must be different, but they can be the same as nodes. */
static void split_bezier(cairo_point_double_t p[4], cairo_point_double_t fst_half[4], cairo_point_double_t snd_half[4])
|
{
split_bezier_1D (p[0].x, p[1].x, p[2].x, p[3].x,
&fst_half[0].x, &fst_half[1].x, &fst_half[2].x, &fst_half[3].x,
&snd_half[0].x, &snd_half[1].x, &snd_half[2].x, &snd_half[3].x);
split_bezier_1D (p[0].y, p[1].y, p[2].y, p[3].y,
&fst_half[0].y, &fst_half[1].y, &fst_half[2].y, &fst_half[3].y,
&snd_half[0].y, &snd_half[1].y, &snd_half[2].y, &snd_half[3].y);
}
|
xboot/xboot
|
C++
|
MIT License
| 779
|
/* This function is used to set break mode. */
|
int tls_pwm_brake_mode_config(u8 channel, bool en, enum tls_pwm_brake_out_level brok)
|
/* This function is used to set break mode. */
int tls_pwm_brake_mode_config(u8 channel, bool en, enum tls_pwm_brake_out_level brok)
|
{
if(channel > (PWM_CHANNEL_MAX_NUM - 1))
return WM_FAILED;
if (ENABLE == en)
{
if (WM_PWM_BRAKE_OUT_HIGH == brok)
tls_reg_write32(HR_PWM_BRKCTL, tls_reg_read32(HR_PWM_BRKCTL) | BIT(3+channel));
else
tls_reg_write32(HR_PWM_BRKCTL, tls_reg_read32(HR_PWM_BRKCTL) & (~BIT(3+channel)));
tls_reg_write32(HR_PWM_BRKCTL, tls_reg_read32(HR_PWM_BRKCTL) | BIT(11+channel));
}
else
{
tls_reg_write32(HR_PWM_BRKCTL, tls_reg_read32(HR_PWM_BRKCTL) & (~BIT(11+channel)));
}
return WM_SUCCESS;
}
|
Nicholas3388/LuaNode
|
C++
|
Other
| 1,055
|
/* Message: ClearConferenceMessage Opcode: 0x0032 Type: Conference Direction: dev2pbx VarLength: no */
|
static void handle_ClearConferenceMessage(ptvcursor_t *cursor, packet_info *pinfo _U_)
|
/* Message: ClearConferenceMessage Opcode: 0x0032 Type: Conference Direction: dev2pbx VarLength: no */
static void handle_ClearConferenceMessage(ptvcursor_t *cursor, packet_info *pinfo _U_)
|
{
ptvcursor_add(cursor, hf_skinny_conferenceID, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_serviceNum, 4, ENC_LITTLE_ENDIAN);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* bios hold a dio reference between submit_bio and ->end_io. */
|
static void dio_bio_submit(struct dio *dio)
|
/* bios hold a dio reference between submit_bio and ->end_io. */
static void dio_bio_submit(struct dio *dio)
|
{
struct bio *bio = dio->bio;
unsigned long flags;
bio->bi_private = dio;
spin_lock_irqsave(&dio->bio_lock, flags);
dio->refcount++;
spin_unlock_irqrestore(&dio->bio_lock, flags);
if (dio->is_async && dio->rw == READ)
bio_set_pages_dirty(bio);
submit_bio(dio->rw, bio);
dio->bio = NULL;
dio->boundary = 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Returns 0 on success or negative error code on failure. */
|
int i2o_event_register(struct i2o_device *dev, struct i2o_driver *drv, int tcntxt, u32 evt_mask)
|
/* Returns 0 on success or negative error code on failure. */
int i2o_event_register(struct i2o_device *dev, struct i2o_driver *drv, int tcntxt, u32 evt_mask)
|
{
struct i2o_controller *c = dev->iop;
struct i2o_message *msg;
msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
if (IS_ERR(msg))
return PTR_ERR(msg);
msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0);
msg->u.head[1] =
cpu_to_le32(I2O_CMD_UTIL_EVT_REGISTER << 24 | HOST_TID << 12 | dev->
lct_data.tid);
msg->u.s.icntxt = cpu_to_le32(drv->context);
msg->u.s.tcntxt = cpu_to_le32(tcntxt);
msg->body[0] = cpu_to_le32(evt_mask);
i2o_msg_post(c, msg);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Set the target node's Single Phase Retry limit. Affects the target's retry behaviour if our node is too busy to accept requests. */
|
static int sbp2_set_busy_timeout(struct sbp2_lu *)
|
/* Set the target node's Single Phase Retry limit. Affects the target's retry behaviour if our node is too busy to accept requests. */
static int sbp2_set_busy_timeout(struct sbp2_lu *)
|
{
quadlet_t data;
data = cpu_to_be32(SBP2_BUSY_TIMEOUT_VALUE);
if (hpsb_node_write(lu->ne, SBP2_BUSY_TIMEOUT_ADDRESS, &data, 4))
SBP2_ERR("%s error", __func__);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function will search SBL HOB list to find the first GUIDed HOB that its GUID matches Guid. */
|
VOID* GetGuidHobDataFromSbl(IN EFI_GUID *Guid)
|
/* This function will search SBL HOB list to find the first GUIDed HOB that its GUID matches Guid. */
VOID* GetGuidHobDataFromSbl(IN EFI_GUID *Guid)
|
{
UINT8 *GuidHob;
CONST VOID *HobList;
HobList = GetParameterBase ();
ASSERT (HobList != NULL);
GuidHob = GetNextGuidHob (Guid, HobList);
if (GuidHob != NULL) {
return GET_GUID_HOB_DATA (GuidHob);
}
return NULL;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.