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
|
|---|---|---|---|---|---|---|---|
/* Utilities ... tolerate 12-hour AM/PM notation in case of non-Linux software (like a bootloader) which may require it. */
|
static unsigned bcd2hour(u8 bcd)
|
/* Utilities ... tolerate 12-hour AM/PM notation in case of non-Linux software (like a bootloader) which may require it. */
static unsigned bcd2hour(u8 bcd)
|
{
if (bcd & DS1305_HR_12) {
unsigned hour = 0;
bcd &= ~DS1305_HR_12;
if (bcd & DS1305_HR_PM) {
hour = 12;
bcd &= ~DS1305_HR_PM;
}
hour += bcd2bin(bcd);
return hour - 1;
}
return bcd2bin(bcd);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Returns true if a valid digital packet was received, false otherwise. */
|
static int dig_mode_start(struct gameport *gameport, u32 *packet)
|
/* Returns true if a valid digital packet was received, false otherwise. */
static int dig_mode_start(struct gameport *gameport, u32 *packet)
|
{
int i;
int flags, tries = 0, bads = 0;
for (i = 0; i < ARRAY_SIZE(init_seq); i++) {
if (init_seq[i])
gameport_trigger(gameport);
udelay(GRIP_INIT_DELAY);
}
for (i = 0; i < 16; i++)
udelay(GRIP_INIT_DELAY);
while (tries < 64 && bads < 8) {
flags = multiport_io(gameport, IO_RESET, 0x27, packet);
if (flags & IO_MODE_FAST)
return 1;
if (flags & IO_RETRY)
tries++;
else
bads++;
}
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Configures the adc external trigger for injected channels conversion. */
|
void ADC_ExternalTrigInjectedConvertConfig(ADC_TypeDef *adc, EXTER_INJ_TRIG_TypeDef ADC_ExtInjTrigSource)
|
/* Configures the adc external trigger for injected channels conversion. */
void ADC_ExternalTrigInjectedConvertConfig(ADC_TypeDef *adc, EXTER_INJ_TRIG_TypeDef ADC_ExtInjTrigSource)
|
{
u32 tmpreg = 0;
tmpreg = adc->ANYCR;
tmpreg &= ADC_ANY_CR_JTRGSEL;
tmpreg |= ADC_ExtInjTrigSource;
adc->ANYCR = tmpreg;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* The pdc2027x hardware will look at "SET FEATURES" and change the timing registers automatically. The values set by the hardware might be incorrect, under 133Mhz PLL. This function overwrites the possibly incorrect values set by the hardware to be correct. */
|
static int pdc2027x_set_mode(struct ata_link *link, struct ata_device **r_failed)
|
/* The pdc2027x hardware will look at "SET FEATURES" and change the timing registers automatically. The values set by the hardware might be incorrect, under 133Mhz PLL. This function overwrites the possibly incorrect values set by the hardware to be correct. */
static int pdc2027x_set_mode(struct ata_link *link, struct ata_device **r_failed)
|
{
struct ata_port *ap = link->ap;
struct ata_device *dev;
int rc;
rc = ata_do_set_mode(link, r_failed);
if (rc < 0)
return rc;
ata_for_each_dev(dev, link, ENABLED) {
pdc2027x_set_piomode(ap, dev);
if (dev->xfer_shift == ATA_SHIFT_PIO) {
u32 ctcr1 = ioread32(dev_mmio(ap, dev, PDC_CTCR1));
ctcr1 |= (1 << 25);
iowrite32(ctcr1, dev_mmio(ap, dev, PDC_CTCR1));
PDPRINTK("Turn on prefetch\n");
} else {
pdc2027x_set_dmamode(ap, dev);
}
}
return 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Deselect the chip.
This function deselects the specified chip by driving its CS line high. */
|
static void _at25dfx_chip_deselect(struct at25dfx_chip_module *chip)
|
/* Deselect the chip.
This function deselects the specified chip by driving its CS line high. */
static void _at25dfx_chip_deselect(struct at25dfx_chip_module *chip)
|
{
port_pin_set_output_level(chip->cs_pin, true);
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* In an augmented interval tree, each node saves the maximum edge of its child subtrees This function compares the children max_edge with the current max_edge and propagates any change to the parent nodes. */
|
static void update_max_edge(wmem_tree_node_t *node)
|
/* In an augmented interval tree, each node saves the maximum edge of its child subtrees This function compares the children max_edge with the current max_edge and propagates any change to the parent nodes. */
static void update_max_edge(wmem_tree_node_t *node)
|
{
wmem_range_t *range;
wmem_range_t *range_l;
wmem_range_t *range_r;
guint64 maxEdge = 0;
if(!node) {
return ;
}
range = (wmem_range_t *)node->key;
range_l = (node->left) ? (wmem_range_t *) (node->left->key) : NULL;
range_r = (node->right) ? (wmem_range_t *) (node->right->key) : NULL;
maxEdge = range->max_edge;
if(range_r) {
maxEdge = MAX(maxEdge, range_r->max_edge) ;
}
if(range_l) {
maxEdge = MAX(maxEdge, range_l->max_edge) ;
}
if(range->max_edge != maxEdge) {
range->max_edge = maxEdge;
update_max_edge(node->parent);
}
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* @ah: The &struct ath5k_hw @timeout: Timeout in usec */
|
int ath5k_hw_set_cts_timeout(struct ath5k_hw *ah, unsigned int timeout)
|
/* @ah: The &struct ath5k_hw @timeout: Timeout in usec */
int ath5k_hw_set_cts_timeout(struct ath5k_hw *ah, unsigned int timeout)
|
{
ATH5K_TRACE(ah->ah_sc);
if (ath5k_hw_clocktoh(AR5K_REG_MS(0xffffffff, AR5K_TIME_OUT_CTS),
ah->ah_turbo) <= timeout)
return -EINVAL;
AR5K_REG_WRITE_BITS(ah, AR5K_TIME_OUT, AR5K_TIME_OUT_CTS,
ath5k_hw_htoclock(timeout, ah->ah_turbo));
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* The function is called by QuickSort to compare the order of offsets of two microcode patches in RAM relative to their base address. Elements will be in ascending order. */
|
INTN EFIAPI MicrocodePatchOffsetCompareFunction(IN CONST VOID *Offset1, IN CONST VOID *Offset2)
|
/* The function is called by QuickSort to compare the order of offsets of two microcode patches in RAM relative to their base address. Elements will be in ascending order. */
INTN EFIAPI MicrocodePatchOffsetCompareFunction(IN CONST VOID *Offset1, IN CONST VOID *Offset2)
|
{
if (*(UINT64 *)(Offset1) > *(UINT64 *)(Offset2)) {
return 1;
} else if (*(UINT64 *)(Offset1) < *(UINT64 *)(Offset2)) {
return -1;
} else {
return 0;
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Turn off micro SD card power. DK doesn't support socket power control, only disable the SPI clock. */
|
void MICROSD_PowerOff(void)
|
/* Turn off micro SD card power. DK doesn't support socket power control, only disable the SPI clock. */
void MICROSD_PowerOff(void)
|
{
MICROSD_Select();
MICROSD_Deselect();
CMU_ClockEnable(MICROSD_CMUCLOCK, false);
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* This function replaces the original HibernateEnable() API and performs the same actions. A macro is provided in */
|
void HibernateEnableExpClk(unsigned long ulHibClk)
|
/* This function replaces the original HibernateEnable() API and performs the same actions. A macro is provided in */
void HibernateEnableExpClk(unsigned long ulHibClk)
|
{
HWREG(HIB_CTL) |= HIB_CTL_CLK32EN;
if(CLASS_IS_FURY)
{
g_ulWriteDelay = (((ulHibClk / 1000) * DELAY_USECS) /
(1000L * LOOP_CYCLES));
g_ulWriteDelay++;
}
}
|
watterott/WebRadio
|
C++
| null | 71
|
/* ipath_verbs_send - send a packet @qp: the QP to send on @hdr: the packet header @hdrwords: the number of 32-bit words in the header @ss: the SGE to send @len: the length of the packet in bytes */
|
int ipath_verbs_send(struct ipath_qp *qp, struct ipath_ib_header *hdr, u32 hdrwords, struct ipath_sge_state *ss, u32 len)
|
/* ipath_verbs_send - send a packet @qp: the QP to send on @hdr: the packet header @hdrwords: the number of 32-bit words in the header @ss: the SGE to send @len: the length of the packet in bytes */
int ipath_verbs_send(struct ipath_qp *qp, struct ipath_ib_header *hdr, u32 hdrwords, struct ipath_sge_state *ss, u32 len)
|
{
struct ipath_devdata *dd = to_idev(qp->ibqp.device)->dd;
u32 plen;
int ret;
u32 dwords = (len + 3) >> 2;
plen = hdrwords + dwords + 1;
if (qp->ibqp.qp_type == IB_QPT_SMI ||
!(dd->ipath_flags & IPATH_HAS_SEND_DMA))
ret = ipath_verbs_send_pio(qp, hdr, hdrwords, ss, len,
plen, dwords);
else
ret = ipath_verbs_send_dma(qp, hdr, hdrwords, ss, len,
plen, dwords);
return ret;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Since an RQ completion handler is called on interrupt context, we need to defer the handling of the I/O to a tasklet */
|
static void rq_comp_handler(struct ib_cq *cq, void *cq_context)
|
/* Since an RQ completion handler is called on interrupt context, we need to defer the handling of the I/O to a tasklet */
static void rq_comp_handler(struct ib_cq *cq, void *cq_context)
|
{
struct svcxprt_rdma *xprt = cq_context;
unsigned long flags;
if (atomic_read(&xprt->sc_xprt.xpt_ref.refcount)==0)
return;
set_bit(RDMAXPRT_RQ_PENDING, &xprt->sc_flags);
spin_lock_irqsave(&dto_lock, flags);
if (list_empty(&xprt->sc_dto_q)) {
svc_xprt_get(&xprt->sc_xprt);
list_add_tail(&xprt->sc_dto_q, &dto_xprt_q);
}
spin_unlock_irqrestore(&dto_lock, flags);
tasklet_schedule(&dto_tasklet);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* GPIO EXTI Callback function Handle remote-wakeup through key button. */
|
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
/* GPIO EXTI Callback function Handle remote-wakeup through key button. */
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
{
if (GPIO_Pin == KEY_BUTTON_PIN)
{
if ((((USBD_HandleTypeDef *)hpcd.pData)->dev_remote_wakeup == 1)&&
(((USBD_HandleTypeDef *)hpcd.pData)->dev_state == USBD_STATE_SUSPENDED))
{
if ((&hpcd)->Init.low_power_enable)
{
SCB->SCR &= (uint32_t)~((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk));
SystemClockConfig_STOP();
}
__HAL_PCD_UNGATE_PHYCLOCK((&hpcd));
HAL_PCD_ActivateRemoteWakeup((&hpcd));
HAL_Delay(10);
HAL_PCD_DeActivateRemoteWakeup((&hpcd));
((USBD_HandleTypeDef *)hpcd.pData)->dev_state = USBD_STATE_CONFIGURED;
((USBD_HandleTypeDef *)hpcd.pData)->dev_remote_wakeup=0;
}
}
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* This function returns %0 on success and a negative error code on failure. */
|
static int check_lpt_type(uint8_t **addr, int *pos, int type)
|
/* This function returns %0 on success and a negative error code on failure. */
static int check_lpt_type(uint8_t **addr, int *pos, int type)
|
{
int node_type;
node_type = ubifs_unpack_bits(addr, pos, UBIFS_LPT_TYPE_BITS);
if (node_type != type) {
ubifs_err("invalid type (%d) in LPT node type %d", node_type,
type);
dbg_dump_stack();
return -EINVAL;
}
return 0;
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* Return: TRUE if c is an upper or lower case alphabetical character, FALSE otherwise. */
|
static gboolean is_rfc2234_alpha(guint8 c)
|
/* Return: TRUE if c is an upper or lower case alphabetical character, FALSE otherwise. */
static gboolean is_rfc2234_alpha(guint8 c)
|
{
return ((c <= 'Z' && c >= 'A' ) || (c <= 'z' && c >= 'a'));
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Pixel off: return = 0 Pixel on: return = 1 */
|
static unsigned char cfag12864b_isset(unsigned char x, unsigned char y)
|
/* Pixel off: return = 0 Pixel on: return = 1 */
static unsigned char cfag12864b_isset(unsigned char x, unsigned char y)
|
{
if (CFAG12864B_CHECK(x, y))
if (cfag12864b_buffer[CFAG12864B_ADDRESS(x, y)] &
CFAG12864B_BIT(x % CFAG12864B_BPB))
return 1;
return 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* This routine handles processing a REG_LOGIN mailbox command upon completion. It is setup in the LPFC_MBOXQ as the completion routine when the command is handed off to the SLI layer. */
|
void lpfc_mbx_cmpl_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
|
/* This routine handles processing a REG_LOGIN mailbox command upon completion. It is setup in the LPFC_MBOXQ as the completion routine when the command is handed off to the SLI layer. */
void lpfc_mbx_cmpl_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
|
{
struct lpfc_vport *vport = pmb->vport;
struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *) (pmb->context1);
struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) pmb->context2;
pmb->context1 = NULL;
lpfc_disc_state_machine(vport, ndlp, pmb, NLP_EVT_CMPL_REG_LOGIN);
lpfc_mbuf_free(phba, mp->virt, mp->phys);
kfree(mp);
mempool_free(pmb, phba->mbox_mem_pool);
lpfc_nlp_put(ndlp);
return;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Return path to "%SystemRoot%/drivers/etc/<file>" (Win-NT+) or to "%Windir%/etc/<file>" (Win-9x/ME) */
|
const char* etc_path(const char *file)
|
/* Return path to "%SystemRoot%/drivers/etc/<file>" (Win-NT+) or to "%Windir%/etc/<file>" (Win-9x/ME) */
const char* etc_path(const char *file)
|
{
BOOL win9x = is_win9x();
const char *env = win9x ? getenv("WinDir") : getenv("SystemRoot");
static char path[MAX_PATH];
if (!env)
return (file);
if (win9x)
snprintf (path, sizeof(path), "%s\\etc\\%s", env, file);
else
snprintf (path, sizeof(path), "%s\\system32\\drivers\\etc\\%s", env, file);
return (path);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Checks whether the specified CEC interrupt has occurred or not. */
|
ITStatus CEC_GetITStatus(uint16_t CEC_IT)
|
/* Checks whether the specified CEC interrupt has occurred or not. */
ITStatus CEC_GetITStatus(uint16_t CEC_IT)
|
{
ITStatus bitstatus = RESET;
uint32_t enablestatus = 0;
assert_param(IS_CEC_GET_IT(CEC_IT));
enablestatus = (CEC->IER & CEC_IT);
if (((CEC->ISR & CEC_IT) != (uint32_t)RESET) && enablestatus)
{
bitstatus = SET;
}
else
{
bitstatus = RESET;
}
return bitstatus;
}
|
avem-labs/Avem
|
C++
|
MIT License
| 1,752
|
/* Because entries can be reallocated to other neighbors once their ref count drops to 0 we need to take the entry's lock to avoid races with a new incarnation. */
|
void t3_l2e_free(struct l2t_data *d, struct l2t_entry *e)
|
/* Because entries can be reallocated to other neighbors once their ref count drops to 0 we need to take the entry's lock to avoid races with a new incarnation. */
void t3_l2e_free(struct l2t_data *d, struct l2t_entry *e)
|
{
spin_lock_bh(&e->lock);
if (atomic_read(&e->refcnt) == 0) {
if (e->neigh) {
neigh_release(e->neigh);
e->neigh = NULL;
}
}
spin_unlock_bh(&e->lock);
atomic_inc(&d->nfree);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Function to set the MDC clock for mdio transactiona */
|
s32 synopGMAC_set_mdc_clk_div(synopGMACdevice *gmacdev, u32 clk_div_val)
|
/* Function to set the MDC clock for mdio transactiona */
s32 synopGMAC_set_mdc_clk_div(synopGMACdevice *gmacdev, u32 clk_div_val)
|
{
u32 orig_data;
orig_data = synopGMACReadReg(gmacdev->MacBase, GmacGmiiAddr);
orig_data &= (~ GmiiCsrClkMask);
orig_data |= clk_div_val;
synopGMACWriteReg(gmacdev->MacBase, GmacGmiiAddr, orig_data);
return 0;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Retrieves a string representation of the mux setting for a pin. */
|
const char* chipcHw_getGpioPinFunctionStr(int pin)
|
/* Retrieves a string representation of the mux setting for a pin. */
const char* chipcHw_getGpioPinFunctionStr(int pin)
|
{
if ((pin < 0) || (pin >= chipcHw_GPIO_COUNT)) {
return "";
}
return gMuxStr[chipcHw_getGpioPinFunction(pin)];
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Subtract two Big Numbers. Please note, all "out" Big number arguments should be properly initialized by calling to BigNumInit() or BigNumFromBin() functions. */
|
BOOLEAN EFIAPI BigNumSub(IN CONST VOID *BnA, IN CONST VOID *BnB, OUT VOID *BnRes)
|
/* Subtract two Big Numbers. Please note, all "out" Big number arguments should be properly initialized by calling to BigNumInit() or BigNumFromBin() functions. */
BOOLEAN EFIAPI BigNumSub(IN CONST VOID *BnA, IN CONST VOID *BnB, OUT VOID *BnRes)
|
{
return (BOOLEAN)BN_sub (BnRes, BnA, BnB);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* CANopen sync thread.
The CANopen real-time sync thread processes SYNC RPDOs and TPDOs through the CANopenNode stack with an interval of 1 millisecond. */
|
static void canopen_sync_thread(void *p1, void *p2, void *p3)
|
/* CANopen sync thread.
The CANopen real-time sync thread processes SYNC RPDOs and TPDOs through the CANopenNode stack with an interval of 1 millisecond. */
static void canopen_sync_thread(void *p1, void *p2, void *p3)
|
{
uint32_t start;
uint32_t stop;
uint32_t delta;
uint32_t elapsed = 0;
bool sync;
ARG_UNUSED(p1);
ARG_UNUSED(p2);
ARG_UNUSED(p3);
while (true) {
start = k_cycle_get_32();
if (CO && CO->CANmodule[0] && CO->CANmodule[0]->CANnormal) {
CO_LOCK_OD();
sync = CO_process_SYNC(CO, elapsed);
CO_process_RPDO(CO, sync);
CO_process_TPDO(CO, sync, elapsed);
CO_UNLOCK_OD();
}
k_sleep(K_MSEC(1));
stop = k_cycle_get_32();
delta = stop - start;
elapsed = (uint32_t)k_cyc_to_ns_floor64(delta) / NSEC_PER_USEC;
}
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* It checks if the sockaddr variable contains a multicast address.
So, on Windows, if we don't have ssize_t defined, define it as an int, so we can use it, on all platforms, as the type of variables that hold the return values from send() and recv(). */
|
static int sock_ismcastaddr(const struct sockaddr *saddr)
|
/* It checks if the sockaddr variable contains a multicast address.
So, on Windows, if we don't have ssize_t defined, define it as an int, so we can use it, on all platforms, as the type of variables that hold the return values from send() and recv(). */
static int sock_ismcastaddr(const struct sockaddr *saddr)
|
{
if (saddr->sa_family == PF_INET)
{
struct sockaddr_in *saddr4 = (struct sockaddr_in *) saddr;
if (IN_MULTICAST(ntohl(saddr4->sin_addr.s_addr))) return 0;
else return -1;
}
else
{
struct sockaddr_in6 *saddr6 = (struct sockaddr_in6 *) saddr;
if (IN6_IS_ADDR_MULTICAST(&saddr6->sin6_addr)) return 0;
else return -1;
}
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Wait up to 1s for mask to be set in given reg. */
|
static void await_bits_set(u32 *reg, u32 mask)
|
/* Wait up to 1s for mask to be set in given reg. */
static void await_bits_set(u32 *reg, u32 mask)
|
{
mctl_await_completion(reg, mask, mask);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* brief Set the flexcomm output frequency. param id : flexcomm instance id freq : output frequency return 0 : the frequency range is out of range. 1 : switch successfully. */
|
uint32_t CLOCK_SetFlexCommClock(uint32_t id, uint32_t freq)
|
/* brief Set the flexcomm output frequency. param id : flexcomm instance id freq : output frequency return 0 : the frequency range is out of range. 1 : switch successfully. */
uint32_t CLOCK_SetFlexCommClock(uint32_t id, uint32_t freq)
|
{
uint32_t input = CLOCK_GetFlexCommClkFreq(id);
uint32_t mul;
if ((freq > 48000000UL) || (freq > input) || (input / freq >= 2UL))
{
return 0UL;
}
else
{
mul = (uint32_t)((((uint64_t)input - freq) * 256ULL) / ((uint64_t)freq));
SYSCON->FLEXFRGXCTRL[id] = (mul << 8U) | 0xFFU;
return 1UL;
}
}
|
ARMmbed/DAPLink
|
C++
|
Apache License 2.0
| 2,140
|
/* Released under the terms of the GNU GPL v2.0. */
|
struct file* file_lookup(const char *name)
|
/* Released under the terms of the GNU GPL v2.0. */
struct file* file_lookup(const char *name)
|
{
struct file *file;
for (file = file_list; file; file = file->next) {
if (!strcmp(name, file->name))
return file;
}
file = malloc(sizeof(*file));
memset(file, 0, sizeof(*file));
file->name = strdup(name);
file->next = file_list;
file_list = file;
return file;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* get the status of a given memory and store in buffer */
|
uint8_t dfu_mem_getstatus(uint32_t addr, uint8_t cmd, uint8_t *buffer)
|
/* get the status of a given memory and store in buffer */
uint8_t dfu_mem_getstatus(uint32_t addr, uint8_t cmd, uint8_t *buffer)
|
{
uint32_t mem_index = dfu_mem_checkaddr(addr);
if (mem_index < MAX_USED_MEMORY_MEDIA) {
if (cmd & 0x01U) {
POLLING_TIMEOUT_SET(mem_tab[mem_index]->write_timeout);
} else {
POLLING_TIMEOUT_SET(mem_tab[mem_index]->erase_timeout);
}
return MEM_OK;
} else {
return MEM_FAIL;
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* BFA log set log level for all aen sub-modules */
|
bfa_status_t bfa_log_set_level_aen(struct bfa_log_mod_s *log_mod, enum bfa_log_severity log_level)
|
/* BFA log set log level for all aen sub-modules */
bfa_status_t bfa_log_set_level_aen(struct bfa_log_mod_s *log_mod, enum bfa_log_severity log_level)
|
{
int mod_id = BFA_LOG_AEN_MIN + 1;
if (log_mod) {
for (; mod_id <= BFA_LOG_AEN_MAX; mod_id++)
log_mod->log_level[mod_id] = log_level;
} else {
for (; mod_id <= BFA_LOG_AEN_MAX; mod_id++)
bfa_log_info[mod_id].level = log_level;
}
return BFA_STATUS_OK;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Sends an sk_buff to an offload queue driver after dealing with any active network taps. */
|
static int offload_tx(struct t3cdev *tdev, struct sk_buff *skb)
|
/* Sends an sk_buff to an offload queue driver after dealing with any active network taps. */
static int offload_tx(struct t3cdev *tdev, struct sk_buff *skb)
|
{
int ret;
local_bh_disable();
ret = t3_offload_tx(tdev, skb);
local_bh_enable();
return ret;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Count and optionally record pointers to a number of NUL terminated strings in a buffer. */
|
STATIC UINT32 ExtractStrings(IN CONST CHAR8 *Strings, IN UINTN Len, OUT CONST CHAR8 **Dst OPTIONAL)
|
/* Count and optionally record pointers to a number of NUL terminated strings in a buffer. */
STATIC UINT32 ExtractStrings(IN CONST CHAR8 *Strings, IN UINTN Len, OUT CONST CHAR8 **Dst OPTIONAL)
|
{
UINT32 Num = 0;
CONST CHAR8 *Ptr;
for (Ptr = Strings; Ptr < Strings + Len; Ptr += AsciiStrSize (Ptr)) {
if (Dst != NULL) {
*Dst++ = Ptr;
}
Num++;
}
return Num;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* param base SAI base pointer. param handle SAI eDMA handle pointer. */
|
void SAI_TransferTerminateReceive(I2S_Type *base, sai_handle_t *handle)
|
/* param base SAI base pointer. param handle SAI eDMA handle pointer. */
void SAI_TransferTerminateReceive(I2S_Type *base, sai_handle_t *handle)
|
{
assert(handle);
SAI_TransferAbortReceive(base, handle);
memset(handle->saiQueue, 0U, sizeof(handle->saiQueue));
memset(handle->transferSize, 0U, sizeof(handle->transferSize));
handle->queueUser = 0U;
handle->queueDriver = 0U;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* PTP_GetStorageIDs Gets Storage Ids and fills stor_ids structure. */
|
static void PTP_GetStorageIDs(USBH_HandleTypeDef *phost, PTP_StorageIDsTypedef *stor_ids)
|
/* PTP_GetStorageIDs Gets Storage Ids and fills stor_ids structure. */
static void PTP_GetStorageIDs(USBH_HandleTypeDef *phost, PTP_StorageIDsTypedef *stor_ids)
|
{
MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
uint8_t *data = MTP_Handle->ptp.data_container.payload.data;
stor_ids->n = PTP_GetArray32(stor_ids->Storage, data, 0U);
}
|
ua1arn/hftrx
|
C++
| null | 69
|
/* Returns: day of the week as a #GDateWeekday. */
|
GDateWeekday g_date_get_weekday(const GDate *d)
|
/* Returns: day of the week as a #GDateWeekday. */
GDateWeekday g_date_get_weekday(const GDate *d)
|
{
g_return_val_if_fail (g_date_valid (d), G_DATE_BAD_WEEKDAY);
if (!d->julian)
g_date_update_julian (d);
g_return_val_if_fail (d->julian, G_DATE_BAD_WEEKDAY);
return ((d->julian_days - 1) % 7) + 1;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Options "fragmenting", just fill options not allowed in fragments with NOOPs. Simple and stupid 8), but the most efficient way. */
|
void ip_options_fragment(struct sk_buff *skb)
|
/* Options "fragmenting", just fill options not allowed in fragments with NOOPs. Simple and stupid 8), but the most efficient way. */
void ip_options_fragment(struct sk_buff *skb)
|
{
unsigned char *optptr = skb_network_header(skb) + sizeof(struct iphdr);
struct ip_options * opt = &(IPCB(skb)->opt);
int l = opt->optlen;
int optlen;
while (l > 0) {
switch (*optptr) {
case IPOPT_END:
return;
case IPOPT_NOOP:
l--;
optptr++;
continue;
}
optlen = optptr[1];
if (optlen<2 || optlen>l)
return;
if (!IPOPT_COPIED(*optptr))
memset(optptr, IPOPT_NOOP, optlen);
l -= optlen;
optptr += optlen;
}
opt->ts = 0;
opt->rr = 0;
opt->rr_needaddr = 0;
opt->ts_needaddr = 0;
opt->ts_needtime = 0;
return;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* The HyperVisor expects the "flags" argument in this form: bits 0..59 : reserved bit 60 : N bits 61..63 : PP2,PP1,PP0 */
|
static long iSeries_hpte_updatepp(unsigned long slot, unsigned long newpp, unsigned long va, int psize, int ssize, int local)
|
/* The HyperVisor expects the "flags" argument in this form: bits 0..59 : reserved bit 60 : N bits 61..63 : PP2,PP1,PP0 */
static long iSeries_hpte_updatepp(unsigned long slot, unsigned long newpp, unsigned long va, int psize, int ssize, int local)
|
{
struct hash_pte hpte;
unsigned long want_v;
iSeries_hlock(slot);
HvCallHpt_get(&hpte, slot);
want_v = hpte_encode_v(va, MMU_PAGE_4K, MMU_SEGSIZE_256M);
if (HPTE_V_COMPARE(hpte.v, want_v) && (hpte.v & HPTE_V_VALID)) {
HvCallHpt_setPp(slot, (newpp & 0x3) | ((newpp & 0x4) << 1));
iSeries_hunlock(slot);
return 0;
}
iSeries_hunlock(slot);
return -1;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Do the hard work of removing an element from the buddy allocator. Call me with the zone->lock already held. */
|
static struct page* __rmqueue(struct zone *zone, unsigned int order, int migratetype)
|
/* Do the hard work of removing an element from the buddy allocator. Call me with the zone->lock already held. */
static struct page* __rmqueue(struct zone *zone, unsigned int order, int migratetype)
|
{
struct page *page;
retry_reserve:
page = __rmqueue_smallest(zone, order, migratetype);
if (unlikely(!page) && migratetype != MIGRATE_RESERVE) {
page = __rmqueue_fallback(zone, order, migratetype);
if (!page) {
migratetype = MIGRATE_RESERVE;
goto retry_reserve;
}
}
trace_mm_page_alloc_zone_locked(page, order, migratetype);
return page;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* These expectations mean that we know that we have seen the transition from one expected value to another with a fairly high accuracy, and we didn't miss any events. We can thus use the TSC value at the transitions to calculate a pretty good value for the TSC frequencty. */
|
static int pit_verify_msb(unsigned char val)
|
/* These expectations mean that we know that we have seen the transition from one expected value to another with a fairly high accuracy, and we didn't miss any events. We can thus use the TSC value at the transitions to calculate a pretty good value for the TSC frequencty. */
static int pit_verify_msb(unsigned char val)
|
{
inb(0x42);
return inb(0x42) == val;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Return 0, 1, or 2 as a <, =, > b respectively. Both a and b are considered signed */
|
int __cmpdi2(quad_t a, quad_t b)
|
/* Return 0, 1, or 2 as a <, =, > b respectively. Both a and b are considered signed */
int __cmpdi2(quad_t a, quad_t b)
|
{
union uu aa, bb;
aa.q = a;
bb.q = b;
return aa.sl[H] < bb.sl[H] ? 0
: aa.sl[H] > bb.sl[H] ? 2
: aa.ul[L] < bb.ul[L] ? 0
: aa.ul[L] > bb.ul[L] ? 2
: 1;
}
|
labapart/polymcu
|
C++
| null | 201
|
/* Allocate and initialise a new SDIO function structure. */
|
struct sdio_func* sdio_alloc_func(struct mmc_card *card)
|
/* Allocate and initialise a new SDIO function structure. */
struct sdio_func* sdio_alloc_func(struct mmc_card *card)
|
{
struct sdio_func *func;
func = kzalloc(sizeof(struct sdio_func), GFP_KERNEL);
if (!func)
return ERR_PTR(-ENOMEM);
func->card = card;
device_initialize(&func->dev);
func->dev.parent = &card->dev;
func->dev.bus = &sdio_bus_type;
func->dev.release = sdio_release_func;
return func;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Returns: The resource group, or NULL if not found */
|
struct gfs2_rgrpd* gfs2_blk2rgrpd(struct gfs2_sbd *sdp, u64 blk)
|
/* Returns: The resource group, or NULL if not found */
struct gfs2_rgrpd* gfs2_blk2rgrpd(struct gfs2_sbd *sdp, u64 blk)
|
{
struct gfs2_rgrpd *rgd;
spin_lock(&sdp->sd_rindex_spin);
list_for_each_entry(rgd, &sdp->sd_rindex_mru_list, rd_list_mru) {
if (rgrp_contains_block(rgd, blk)) {
list_move(&rgd->rd_list_mru, &sdp->sd_rindex_mru_list);
spin_unlock(&sdp->sd_rindex_spin);
return rgd;
}
}
spin_unlock(&sdp->sd_rindex_spin);
return NULL;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* The UCB1x00 can generate interrupts when the SIBCLK is stopped. Since we need to read an internal register, we must re-enable SIBCLK to talk to the chip. We leave the clock running until we have finished processing all interrupts from the chip. */
|
static irqreturn_t ucb1x00_irq(int irqnr, void *devid)
|
/* The UCB1x00 can generate interrupts when the SIBCLK is stopped. Since we need to read an internal register, we must re-enable SIBCLK to talk to the chip. We leave the clock running until we have finished processing all interrupts from the chip. */
static irqreturn_t ucb1x00_irq(int irqnr, void *devid)
|
{
struct ucb1x00 *ucb = devid;
struct ucb1x00_irq *irq;
unsigned int isr, i;
ucb1x00_enable(ucb);
isr = ucb1x00_reg_read(ucb, UCB_IE_STATUS);
ucb1x00_reg_write(ucb, UCB_IE_CLEAR, isr);
ucb1x00_reg_write(ucb, UCB_IE_CLEAR, 0);
for (i = 0, irq = ucb->irq_handler; i < 16 && isr; i++, isr >>= 1, irq++)
if (isr & 1 && irq->fn)
irq->fn(i, irq->devid);
ucb1x00_disable(ucb);
return IRQ_HANDLED;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Returns: TRUE on success, FALSE if there was an error */
|
gboolean g_output_stream_vprintf(GOutputStream *stream, gsize *bytes_written, GCancellable *cancellable, GError **error, const gchar *format, va_list args)
|
/* Returns: TRUE on success, FALSE if there was an error */
gboolean g_output_stream_vprintf(GOutputStream *stream, gsize *bytes_written, GCancellable *cancellable, GError **error, const gchar *format, va_list args)
|
{
gchar *text;
gboolean success;
g_return_val_if_fail (G_IS_OUTPUT_STREAM (stream), FALSE);
g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (stream), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
g_return_val_if_fail (format != NULL, FALSE);
text = g_strdup_vprintf (format, args);
success = g_output_stream_write_all (stream,
text, strlen (text),
bytes_written, cancellable, error);
g_free (text);
return success;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Set corresponding bits in bitmap table to 1 according to given memory range. */
|
VOID EFIAPI SetGuardedMemoryBits(IN EFI_PHYSICAL_ADDRESS Address, IN UINTN NumberOfPages)
|
/* Set corresponding bits in bitmap table to 1 according to given memory range. */
VOID EFIAPI SetGuardedMemoryBits(IN EFI_PHYSICAL_ADDRESS Address, IN UINTN NumberOfPages)
|
{
UINT64 *BitMap;
UINTN Bits;
UINTN BitsToUnitEnd;
while (NumberOfPages > 0) {
BitsToUnitEnd = FindGuardedMemoryMap (Address, TRUE, &BitMap);
ASSERT (BitMap != NULL);
if (NumberOfPages > BitsToUnitEnd) {
Bits = BitsToUnitEnd;
} else {
Bits = NumberOfPages;
}
SetBits (Address, Bits, BitMap);
NumberOfPages -= Bits;
Address += EFI_PAGES_TO_SIZE (Bits);
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This optional function does a "fast" set of critical region protection to the value specified by pval. See the documentation for sys_arch_protect() for more information. This function is only required if your port is supporting an operating system. */
|
void sys_arch_unprotect(sys_prot_t pval)
|
/* This optional function does a "fast" set of critical region protection to the value specified by pval. See the documentation for sys_arch_protect() for more information. This function is only required if your port is supporting an operating system. */
void sys_arch_unprotect(sys_prot_t pval)
|
{
( void ) pval;
vPortExitCritical();
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* Returns: TRUE if the key was found in the #GHashTable */
|
gboolean g_hash_table_lookup_extended(GHashTable *hash_table, gconstpointer lookup_key, gpointer *orig_key, gpointer *value)
|
/* Returns: TRUE if the key was found in the #GHashTable */
gboolean g_hash_table_lookup_extended(GHashTable *hash_table, gconstpointer lookup_key, gpointer *orig_key, gpointer *value)
|
{
guint node_index;
guint node_hash;
g_return_val_if_fail (hash_table != NULL, FALSE);
node_index = g_hash_table_lookup_node (hash_table, lookup_key, &node_hash);
if (!HASH_IS_REAL (hash_table->hashes[node_index]))
return FALSE;
if (orig_key)
*orig_key = hash_table->keys[node_index];
if (value)
*value = hash_table->values[node_index];
return TRUE;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Cleans up the LED blink driver. This is intended to be used upon program exit. */
|
void LedBlinkExit(void)
|
/* Cleans up the LED blink driver. This is intended to be used upon program exit. */
void LedBlinkExit(void)
|
{
LL_GPIO_SetOutputPin(GPIOC, LL_GPIO_PIN_12);
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* Waiting for rport create response from firmware. A delete is pending. */
|
static void bfa_rport_sm_delete_pending(struct bfa_rport_s *rp, enum bfa_rport_event event)
|
/* Waiting for rport create response from firmware. A delete is pending. */
static void bfa_rport_sm_delete_pending(struct bfa_rport_s *rp, enum bfa_rport_event event)
|
{
bfa_trc(rp->bfa, rp->rport_tag);
bfa_trc(rp->bfa, event);
switch (event) {
case BFA_RPORT_SM_FWRSP:
bfa_stats(rp, sm_delp_fwrsp);
if (bfa_rport_send_fwdelete(rp))
bfa_sm_set_state(rp, bfa_rport_sm_deleting);
else
bfa_sm_set_state(rp, bfa_rport_sm_deleting_qfull);
break;
case BFA_RPORT_SM_HWFAIL:
bfa_stats(rp, sm_delp_hwf);
bfa_sm_set_state(rp, bfa_rport_sm_uninit);
bfa_rport_free(rp);
break;
default:
bfa_stats(rp, sm_delp_unexp);
bfa_assert(0);
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Returns the interrupt number of SSI module . */
|
static uint32_t _SSIIntNumberGet(uint32_t ui32Base)
|
/* Returns the interrupt number of SSI module . */
static uint32_t _SSIIntNumberGet(uint32_t ui32Base)
|
{
uint_fast8_t ui8Idx, ui8Rows;
const uint32_t (*ppui32SSIIntMap)[2];
ASSERT(_SSIBaseValid(ui32Base));
ppui32SSIIntMap = g_ppui32SSIIntMap;
ui8Rows = g_ui8SSIIntMapRows;
for (ui8Idx = 0; ui8Idx < ui8Rows; ui8Idx++)
{
if (ppui32SSIIntMap[ui8Idx][0] == ui32Base)
{
return (ppui32SSIIntMap[ui8Idx][1]);
}
}
return (0);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Returns: (transfer full): a #GVolume or NULL if no such volume is available. Free the returned object with g_object_unref(). */
|
GVolume* g_volume_monitor_get_volume_for_uuid(GVolumeMonitor *volume_monitor, const char *uuid)
|
/* Returns: (transfer full): a #GVolume or NULL if no such volume is available. Free the returned object with g_object_unref(). */
GVolume* g_volume_monitor_get_volume_for_uuid(GVolumeMonitor *volume_monitor, const char *uuid)
|
{
GVolumeMonitorClass *class;
g_return_val_if_fail (G_IS_VOLUME_MONITOR (volume_monitor), NULL);
g_return_val_if_fail (uuid != NULL, NULL);
class = G_VOLUME_MONITOR_GET_CLASS (volume_monitor);
return class->get_volume_for_uuid (volume_monitor, uuid);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Attempts to acquire the semaphore. If no more tasks are allowed to acquire the semaphore, calling this function will put the task to sleep. If the sleep is interrupted by a fatal signal, this function will return -EINTR. If the semaphore is successfully acquired, this function returns 0. */
|
int down_killable(struct semaphore *sem)
|
/* Attempts to acquire the semaphore. If no more tasks are allowed to acquire the semaphore, calling this function will put the task to sleep. If the sleep is interrupted by a fatal signal, this function will return -EINTR. If the semaphore is successfully acquired, this function returns 0. */
int down_killable(struct semaphore *sem)
|
{
unsigned long flags;
int result = 0;
spin_lock_irqsave(&sem->lock, flags);
if (likely(sem->count > 0))
sem->count--;
else
result = __down_killable(sem);
spin_unlock_irqrestore(&sem->lock, flags);
return result;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* We remove the WLP IE from the beacon before initiating local cleanup. */
|
void wlp_wss_remove(struct wlp_wss *wss)
|
/* We remove the WLP IE from the beacon before initiating local cleanup. */
void wlp_wss_remove(struct wlp_wss *wss)
|
{
struct wlp *wlp = container_of(wss, struct wlp, wss);
mutex_lock(&wss->mutex);
if (wss->state == WLP_WSS_STATE_ACTIVE)
uwb_rc_ie_rm(wlp->rc, UWB_IE_WLP);
if (wss->state != WLP_WSS_STATE_NONE) {
sysfs_remove_group(&wss->kobj, &wss_attr_group);
kobject_put(&wss->kobj);
}
wss->kobj.parent = NULL;
memset(&wss->virtual_addr, 0, sizeof(wss->virtual_addr));
wlp_eda_release(&wlp->eda);
wlp_eda_init(&wlp->eda);
mutex_unlock(&wss->mutex);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Locks the transfer and gets the current status of it. */
|
IFX_STATIC SpiIf_Status IfxQspi_SpiMaster_lock(IfxQspi_SpiMaster *handle)
|
/* Locks the transfer and gets the current status of it. */
IFX_STATIC SpiIf_Status IfxQspi_SpiMaster_lock(IfxQspi_SpiMaster *handle)
|
{
sint32 sending = __swap((void *)&handle->base.sending, 1UL);
return (sending == 0) ? SpiIf_Status_ok : SpiIf_Status_busy;
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* We need to store the untouched command line for future reference. We also need to store the touched command line since the parameter parsing is performed in place, and we should allow a component to store reference of name/value for future reference. */
|
static void __init setup_command_line(char *command_line)
|
/* We need to store the untouched command line for future reference. We also need to store the touched command line since the parameter parsing is performed in place, and we should allow a component to store reference of name/value for future reference. */
static void __init setup_command_line(char *command_line)
|
{
saved_command_line = alloc_bootmem(strlen (boot_command_line)+1);
static_command_line = alloc_bootmem(strlen (command_line)+1);
strcpy (saved_command_line, boot_command_line);
strcpy (static_command_line, command_line);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* NOTE: If you called usb_register_dev(), you still need to call usb_deregister_dev() to clean up your driver's allocated minor numbers, this * call will no longer do it for you. */
|
void usb_deregister(struct usb_driver *driver)
|
/* NOTE: If you called usb_register_dev(), you still need to call usb_deregister_dev() to clean up your driver's allocated minor numbers, this * call will no longer do it for you. */
void usb_deregister(struct usb_driver *driver)
|
{
pr_info("%s: deregistering interface driver %s\n",
usbcore_name, driver->name);
usb_remove_removeid_file(driver);
usb_remove_newid_file(driver);
usb_free_dynids(driver);
driver_unregister(&driver->drvwrap.driver);
usbfs_update_special();
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Unregisters a USB device endpoint callback.
Unregisters an callback implemented by the user. Removing it from the internal callback registration table. */
|
enum status_code usb_device_endpoint_unregister_callback(struct usb_module *module_inst, uint8_t ep_num, enum usb_device_endpoint_callback callback_type)
|
/* Unregisters a USB device endpoint callback.
Unregisters an callback implemented by the user. Removing it from the internal callback registration table. */
enum status_code usb_device_endpoint_unregister_callback(struct usb_module *module_inst, uint8_t ep_num, enum usb_device_endpoint_callback callback_type)
|
{
Assert(module_inst);
Assert(ep_num < USB_EPT_NUM);
module_inst->device_endpoint_callback[ep_num][callback_type] = NULL;
module_inst->device_endpoint_registered_callback_mask[ep_num] &= ~_usb_endpoint_irq_bits[callback_type];
return STATUS_OK;
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* Return if there is touches detected or not. Try to detect new touches and forget the old ones (reset internal global variables). */
|
uint8_t ft5336_TS_DetectTouch(uint16_t DeviceAddr)
|
/* Return if there is touches detected or not. Try to detect new touches and forget the old ones (reset internal global variables). */
uint8_t ft5336_TS_DetectTouch(uint16_t DeviceAddr)
|
{
volatile uint8_t nbTouch = 0;
nbTouch = TS_IO_Read(DeviceAddr, FT5336_TD_STAT_REG);
nbTouch &= FT5336_TD_STAT_MASK;
if(nbTouch > FT5336_MAX_DETECTABLE_TOUCH)
{
nbTouch = 0;
}
ft5336_handle.currActiveTouchNb = nbTouch;
ft5336_handle.currActiveTouchIdx = 0;
return(nbTouch);
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* pmcraid_reinit_buffers - resets various buffer pointers @pinstance: pointer to adapter instance Return value none */
|
static void pmcraid_reinit_buffers(struct pmcraid_instance *)
|
/* pmcraid_reinit_buffers - resets various buffer pointers @pinstance: pointer to adapter instance Return value none */
static void pmcraid_reinit_buffers(struct pmcraid_instance *)
|
{
int i;
int buffer_size = HRRQ_ENTRY_SIZE * PMCRAID_MAX_CMD;
for (i = 0; i < pinstance->num_hrrq; i++) {
memset(pinstance->hrrq_start[i], 0, buffer_size);
pinstance->hrrq_curr[i] = pinstance->hrrq_start[i];
pinstance->hrrq_end[i] =
pinstance->hrrq_start[i] + PMCRAID_MAX_CMD - 1;
pinstance->host_toggle_bit[i] = 1;
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function performs any platform-specific cleanup needed for hardware watch dog. */
|
int32_t hal_wdg_finalize(wdg_dev_t *wdg)
|
/* This function performs any platform-specific cleanup needed for hardware watch dog. */
int32_t hal_wdg_finalize(wdg_dev_t *wdg)
|
{
watchdog_stopfeed();
return 0;
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* Write data element to the SPI interface with Noblock. */
|
long xSPIDataPutNonBlocking(unsigned long ulBase, unsigned long ulData)
|
/* Write data element to the SPI interface with Noblock. */
long xSPIDataPutNonBlocking(unsigned long ulBase, unsigned long ulData)
|
{
xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE));
if(!((xHWREG(ulBase + SPI_CNTRL) & SPI_CNTRL_GO_BUSY)))
{
xHWREG(ulBase + SPI_TX0) = ulData;
return(1);
}
else
{
return(0);
}
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Retrieves a Unicode string that is the user readable name of the controller that is being managed by an EFI Driver. */
|
EFI_STATUS EFIAPI WifiMgrDxeComponentNameGetControllerName(IN EFI_COMPONENT_NAME2_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE ChildHandle OPTIONAL, IN CHAR8 *Language, OUT CHAR16 **ControllerName)
|
/* Retrieves a Unicode string that is the user readable name of the controller that is being managed by an EFI Driver. */
EFI_STATUS EFIAPI WifiMgrDxeComponentNameGetControllerName(IN EFI_COMPONENT_NAME2_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE ChildHandle OPTIONAL, IN CHAR8 *Language, OUT CHAR16 **ControllerName)
|
{
EFI_STATUS Status;
WIFI_MGR_PRIVATE_PROTOCOL *WifiMgrPrivate;
if ((ControllerHandle == NULL) || (ChildHandle != NULL)) {
return EFI_UNSUPPORTED;
}
Status = gBS->OpenProtocol (
ControllerHandle,
&mEfiWifiMgrPrivateGuid,
(VOID **)&WifiMgrPrivate,
NULL,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
return LookupUnicodeString2 (
Language,
This->SupportedLanguages,
mWifiMgrDxeControllerNameTable,
ControllerName,
(BOOLEAN)(This != &gWifiMgrDxeComponentName2)
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Retrieve the common name (CN) string from one X.509 certificate. */
|
RETURN_STATUS EFIAPI X509GetCommonName(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT CHAR8 *CommonName OPTIONAL, IN OUT UINTN *CommonNameSize)
|
/* Retrieve the common name (CN) string from one X.509 certificate. */
RETURN_STATUS EFIAPI X509GetCommonName(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT CHAR8 *CommonName OPTIONAL, IN OUT UINTN *CommonNameSize)
|
{
return InternalX509GetNIDName (Cert, CertSize, NID_commonName, CommonName, CommonNameSize);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Convenience function for callers which just want the block number mapped to a name and don't require the full dirent info, etc. */
|
int ocfs2_lookup_ino_from_name(struct inode *dir, const char *name, int namelen, u64 *blkno)
|
/* Convenience function for callers which just want the block number mapped to a name and don't require the full dirent info, etc. */
int ocfs2_lookup_ino_from_name(struct inode *dir, const char *name, int namelen, u64 *blkno)
|
{
int ret;
struct ocfs2_dir_lookup_result lookup = { NULL, };
ret = ocfs2_find_files_on_disk(name, namelen, blkno, dir, &lookup);
ocfs2_free_dir_lookup_result(&lookup);
return ret;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Toggles the LED at a fixed time interval. */
|
void LedToggle(void)
|
/* Toggles the LED at a fixed time interval. */
void LedToggle(void)
|
{
static unsigned char led_toggle_state = 0;
static unsigned long timer_counter_last = 0;
unsigned long timer_counter_now;
timer_counter_now = TimerGet();
if ( (timer_counter_now - timer_counter_last) < LED_TOGGLE_MS)
{
return;
}
if (led_toggle_state == 0)
{
led_toggle_state = 1;
XMC_GPIO_SetOutputLevel(P4_0, XMC_GPIO_OUTPUT_LEVEL_LOW);
}
else
{
led_toggle_state = 0;
XMC_GPIO_SetOutputLevel(P4_0, XMC_GPIO_OUTPUT_LEVEL_HIGH);
}
timer_counter_last = timer_counter_now;
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* et131x_init_send - Initialize send data structures @adapter: pointer to our private adapter structure */
|
void et131x_init_send(struct et131x_adapter *adapter)
|
/* et131x_init_send - Initialize send data structures @adapter: pointer to our private adapter structure */
void et131x_init_send(struct et131x_adapter *adapter)
|
{
struct tcb *tcb;
u32 ct;
struct tx_ring *tx_ring;
tx_ring = &adapter->tx_ring;
tcb = adapter->tx_ring.tcb_ring;
tx_ring->tcb_qhead = tcb;
memset(tcb, 0, sizeof(struct tcb) * NUM_TCB);
for (ct = 0; ct++ < NUM_TCB; tcb++)
tcb->next = tcb + 1;
tcb--;
tx_ring->tcb_qtail = tcb;
tcb->next = NULL;
tx_ring->send_head = NULL;
tx_ring->send_tail = NULL;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Returns the base of the PCI configuration registers for this port number. */
|
static int sis_old_port_base(struct ata_device *adev)
|
/* Returns the base of the PCI configuration registers for this port number. */
static int sis_old_port_base(struct ata_device *adev)
|
{
return 0x40 + (4 * adev->link->ap->port_no) + (2 * adev->devno);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* This service is an MOR/MorLock checker handler for the SetVariable(). */
|
EFI_STATUS SetVariableCheckHandlerMor(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN UINT32 Attributes, IN UINTN DataSize, IN VOID *Data)
|
/* This service is an MOR/MorLock checker handler for the SetVariable(). */
EFI_STATUS SetVariableCheckHandlerMor(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN UINT32 Attributes, IN UINTN DataSize, IN VOID *Data)
|
{
if (!IsAnyMorVariable (VariableName, VendorGuid)) {
return EFI_SUCCESS;
}
if (!IsVariablePolicyEnabled () && ((Attributes == 0) || (DataSize == 0))) {
return EFI_SUCCESS;
}
if (IsMorLockVariable (VariableName, VendorGuid)) {
return SetVariableCheckHandlerMorLock (
VariableName,
VendorGuid,
Attributes,
DataSize,
Data
);
}
if (((Attributes == 0) || (DataSize == 0)) && mMorPassThru) {
return EFI_SUCCESS;
}
if ((Attributes != (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS)) ||
(DataSize != sizeof (UINT8)) ||
(Data == NULL))
{
return EFI_INVALID_PARAMETER;
}
if (mMorLockState == MorLockStateLocked) {
return EFI_ACCESS_DENIED;
}
return EFI_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Scanning routines to add standard types (byte, int, string, data) to the protocol-tree. Each field is seperated with a slash ('/'). */
|
static void ucp_handle_string(proto_tree *tree, tvbuff_t *tvb, int field, int *offset)
|
/* Scanning routines to add standard types (byte, int, string, data) to the protocol-tree. Each field is seperated with a slash ('/'). */
static void ucp_handle_string(proto_tree *tree, tvbuff_t *tvb, int field, int *offset)
|
{
gint idx, len;
idx = tvb_find_guint8(tvb, *offset, -1, '/');
if (idx == -1) {
len = tvb_captured_length_remaining(tvb, *offset);
tvb_ensure_bytes_exist(tvb, *offset, len + 1);
} else
len = idx - *offset;
if (len > 0)
proto_tree_add_item(tree, field, tvb, *offset, len, ENC_ASCII|ENC_NA);
*offset += len;
if (idx != -1)
*offset += 1;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* See if the current context is inside an ISR. */
|
int irq_arch_in(void)
|
/* See if the current context is inside an ISR. */
int irq_arch_in(void)
|
{
return (__get_IPSR() & 0xFF);
}
|
labapart/polymcu
|
C++
| null | 201
|
/* Return value: 1 - work queued for execution 0 - work is already queued -EINVAL - work queue doesn't exist */
|
static int fc_queue_work(struct Scsi_Host *, struct work_struct *)
|
/* Return value: 1 - work queued for execution 0 - work is already queued -EINVAL - work queue doesn't exist */
static int fc_queue_work(struct Scsi_Host *, struct work_struct *)
|
{
if (unlikely(!fc_host_work_q(shost))) {
printk(KERN_ERR
"ERROR: FC host '%s' attempted to queue work, "
"when no workqueue created.\n", shost->hostt->name);
dump_stack();
return -EINVAL;
}
return queue_work(fc_host_work_q(shost), work);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Add a group address to the array of group addresses. The caller should make sure that no duplicated address existed in the array. Although the function doesn't assume the byte order of the both Source and Addr, the network byte order is used by the caller. */
|
IP4_ADDR* Ip4CombineGroups(IN IP4_ADDR *Source, IN UINT32 Count, IN IP4_ADDR Addr)
|
/* Add a group address to the array of group addresses. The caller should make sure that no duplicated address existed in the array. Although the function doesn't assume the byte order of the both Source and Addr, the network byte order is used by the caller. */
IP4_ADDR* Ip4CombineGroups(IN IP4_ADDR *Source, IN UINT32 Count, IN IP4_ADDR Addr)
|
{
IP4_ADDR *Groups;
Groups = AllocatePool (sizeof (IP4_ADDR) * (Count + 1));
if (Groups == NULL) {
return NULL;
}
CopyMem (Groups, Source, Count * sizeof (IP4_ADDR));
Groups[Count] = Addr;
return Groups;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Return the N-th compile-time option string. If N is out of range, return a NULL pointer. */
|
SQLITE_API const char * sqlite3_compileoption_get(int N)
|
/* Return the N-th compile-time option string. If N is out of range, return a NULL pointer. */
SQLITE_API const char * sqlite3_compileoption_get(int N)
|
{
if( N>=0 && N<ArraySize(azCompileOpt) ){
return azCompileOpt[N];
}
return 0;
}
|
DC-SWAT/DreamShell
|
C++
| null | 404
|
/* Return 1 if the pending bit is set. Unless we just instructed the processor to transition to a new state, seeing this bit set is really bad news. */
|
static int pending_bit_stuck(void)
|
/* Return 1 if the pending bit is set. Unless we just instructed the processor to transition to a new state, seeing this bit set is really bad news. */
static int pending_bit_stuck(void)
|
{
u32 lo, hi;
if (cpu_family == CPU_HW_PSTATE)
return 0;
rdmsr(MSR_FIDVID_STATUS, lo, hi);
return lo & MSR_S_LO_CHANGE_PENDING ? 1 : 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* This comparator searches for the next Interface descriptor of the correct Still Image Class, Subclass and Protocol values. */
|
uint8_t DComp_NextStillImageInterface(void *CurrentDescriptor)
|
/* This comparator searches for the next Interface descriptor of the correct Still Image Class, Subclass and Protocol values. */
uint8_t DComp_NextStillImageInterface(void *CurrentDescriptor)
|
{
USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
if (Header->Type == DTYPE_Interface)
{
USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);
if ((Interface->Class == SI_CSCP_StillImageClass) &&
(Interface->SubClass == SI_CSCP_StillImageSubclass) &&
(Interface->Protocol == SI_CSCP_BulkOnlyProtocol))
{
return DESCRIPTOR_SEARCH_Found;
}
}
return DESCRIPTOR_SEARCH_NotFound;
}
|
prusa3d/Prusa-Firmware-Buddy
|
C++
|
Other
| 1,019
|
/* Reset the PWM module.
This function will reset the PWM module. */
|
void pwm_reset(enum pwm_device_select device_select)
|
/* Reset the PWM module.
This function will reset the PWM module. */
void pwm_reset(enum pwm_device_select device_select)
|
{
switch (device_select) {
case PWM0:
system_peripheral_reset(PERIPHERAL_PWM0);
break;
case PWM1:
system_peripheral_reset(PERIPHERAL_PWM1);
break;
case PWM2:
system_peripheral_reset(PERIPHERAL_PWM2);
break;
case PWM3:
system_peripheral_reset(PERIPHERAL_PWM3);
break;
}
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* Fills each ADC_CommonInitStruct member with its default value. */
|
void ADC_CommonStructInit(ADC_CommonInitTypeDef *ADC_CommonInitStruct)
|
/* Fills each ADC_CommonInitStruct member with its default value. */
void ADC_CommonStructInit(ADC_CommonInitTypeDef *ADC_CommonInitStruct)
|
{
ADC_CommonInitStruct->ADC_Prescaler = ADC_Prescaler_Div1;
}
|
avem-labs/Avem
|
C++
|
MIT License
| 1,752
|
/* __vxge_hw_ring_item_dma_addr - Return the dma address of an item This function returns the dma address of a given item */
|
static dma_addr_t __vxge_hw_ring_item_dma_addr(struct vxge_hw_mempool *mempoolh, void *item)
|
/* __vxge_hw_ring_item_dma_addr - Return the dma address of an item This function returns the dma address of a given item */
static dma_addr_t __vxge_hw_ring_item_dma_addr(struct vxge_hw_mempool *mempoolh, void *item)
|
{
u32 memblock_idx;
void *memblock;
struct vxge_hw_mempool_dma *memblock_dma_object;
ptrdiff_t dma_item_offset;
memblock_idx = __vxge_hw_ring_block_memblock_idx(item);
memblock = mempoolh->memblocks_arr[memblock_idx];
memblock_dma_object = mempoolh->memblocks_dma_arr + memblock_idx;
dma_item_offset = (u8 *)item - (u8 *)memblock;
return memblock_dma_object->addr + dma_item_offset;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Buffer allocation/deallocation routines. The buffer descriptor returned has the virtual and dma address of a buffer suitable for both, receive and transmit operations. */
|
static db_dest_t* GetFreeDB(struct au1000_private *aup)
|
/* Buffer allocation/deallocation routines. The buffer descriptor returned has the virtual and dma address of a buffer suitable for both, receive and transmit operations. */
static db_dest_t* GetFreeDB(struct au1000_private *aup)
|
{
db_dest_t *pDB;
pDB = aup->pDBfree;
if (pDB) {
aup->pDBfree = pDB->pnext;
}
return pDB;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* If the daemon is not running, we just free the event. */
|
void uwbd_event_queue(struct uwb_event *evt)
|
/* If the daemon is not running, we just free the event. */
void uwbd_event_queue(struct uwb_event *evt)
|
{
struct uwb_rc *rc = evt->rc;
unsigned long flags;
spin_lock_irqsave(&rc->uwbd.event_list_lock, flags);
if (rc->uwbd.pid != 0) {
list_add(&evt->list_node, &rc->uwbd.event_list);
wake_up_all(&rc->uwbd.wq);
} else {
__uwb_rc_put(evt->rc);
if (evt->type == UWB_EVT_TYPE_NOTIF)
kfree(evt->notif.rceb);
kfree(evt);
}
spin_unlock_irqrestore(&rc->uwbd.event_list_lock, flags);
return;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Disable direction change to down interrupt (DOWNIE). @rmtoll IER DOWNIE LPTIM_DisableIT_DOWN. */
|
void LPTIM_DisableIT_DOWN(LPTIM_Module *LPTIMx)
|
/* Disable direction change to down interrupt (DOWNIE). @rmtoll IER DOWNIE LPTIM_DisableIT_DOWN. */
void LPTIM_DisableIT_DOWN(LPTIM_Module *LPTIMx)
|
{
CLEAR_BIT(LPTIMx->INTEN, LPTIM_INTEN_DOWNIE);
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* Note that "task" can be NULL. No congestion control is provided. */
|
void xprt_release_xprt(struct rpc_xprt *xprt, struct rpc_task *task)
|
/* Note that "task" can be NULL. No congestion control is provided. */
void xprt_release_xprt(struct rpc_xprt *xprt, struct rpc_task *task)
|
{
if (xprt->snd_task == task) {
xprt_clear_locked(xprt);
__xprt_lock_write_next(xprt);
}
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* DO NOT USE THIS FUNCTION UNLESS YOU KNOW WHAT YOU'RE DOING. */
|
void __init vm_area_register_early(struct vm_struct *vm, size_t align)
|
/* DO NOT USE THIS FUNCTION UNLESS YOU KNOW WHAT YOU'RE DOING. */
void __init vm_area_register_early(struct vm_struct *vm, size_t align)
|
{
static size_t vm_init_off __initdata;
unsigned long addr;
addr = ALIGN(VMALLOC_START + vm_init_off, align);
vm_init_off = PFN_ALIGN(addr + vm->size) - VMALLOC_START;
vm->addr = (void *)addr;
vm->next = vmlist;
vmlist = vm;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Safely sample tick timer without the risk of race. */
|
static void sample_timer(uint32_t &sec, uint32_t &subsec)
|
/* Safely sample tick timer without the risk of race. */
static void sample_timer(uint32_t &sec, uint32_t &subsec)
|
{
sec_1st_read = tick_cnt_s;
lower_cnt = TICK_TIMER_CNT;
sec_2nd_read = tick_cnt_s;
} while (sec_1st_read != sec_2nd_read);
sec = sec_1st_read;
subsec = lower_cnt;
}
|
prusa3d/Prusa-Firmware-Buddy
|
C++
|
Other
| 1,019
|
/* returns SUCCESS if it successfuly read message from buffer */
|
s32 igb_read_mbx(struct e1000_hw *hw, u32 *msg, u16 size, u16 mbx_id)
|
/* returns SUCCESS if it successfuly read message from buffer */
s32 igb_read_mbx(struct e1000_hw *hw, u32 *msg, u16 size, u16 mbx_id)
|
{
struct e1000_mbx_info *mbx = &hw->mbx;
s32 ret_val = -E1000_ERR_MBX;
if (size > mbx->size)
size = mbx->size;
if (mbx->ops.read)
ret_val = mbx->ops.read(hw, msg, size, mbx_id);
return ret_val;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Perform I2C write operation for mipi camera sensor. */
|
static int32_t mipi_sensor_write_reg(uint32_t i2c_base, uint16_t reg, uint8_t pval)
|
/* Perform I2C write operation for mipi camera sensor. */
static int32_t mipi_sensor_write_reg(uint32_t i2c_base, uint16_t reg, uint8_t pval)
|
{
int ret = 0;
struct imx_i2c_request rq = {0};
reg = ((reg & 0x00FF) << 8) | ((reg & 0xFF00) >> 8);
rq.ctl_addr = i2c_base;
rq.dev_addr = MIPI_SENSOR_ADDR;
rq.reg_addr = reg;
rq.reg_addr_sz = 2;
rq.buffer_sz = 1;
rq.buffer = &pval;
ret = i2c_xfer(&rq, I2C_WRITE);
return ret;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Send SET_DATA_WIDTH command to set SD bus width. */
|
static status_t SD_SetDataBusWidth(sd_card_t *card, sd_data_bus_width_t width)
|
/* Send SET_DATA_WIDTH command to set SD bus width. */
static status_t SD_SetDataBusWidth(sd_card_t *card, sd_data_bus_width_t width)
|
{
assert(card);
sdhc_transfer_t content = {0};
sdhc_command_t command = {0};
if (kStatus_Success != SD_SendApplicationCmd(card))
{
return kStatus_SDMMC_SendApplicationCommandFailed;
}
command.index = kSD_ApplicationSetBusWdith;
command.responseType = kSDHC_ResponseTypeR1;
switch (width)
{
case kSD_DataBusWidth1Bit:
command.argument = 0U;
break;
case kSD_DataBusWidth4Bit:
command.argument = 2U;
break;
default:
return kStatus_InvalidArgument;
}
content.command = &command;
content.data = NULL;
if ((kStatus_Success != card->host.transfer(card->host.base, &content)) ||
((command.response[0U]) & kSDMMC_R1ErrorAllFlag))
{
return kStatus_SDMMC_TransferFailed;
}
return kStatus_Success;
}
|
labapart/polymcu
|
C++
| null | 201
|
/* Max offset is achieved with index = 0x7FFF giving an offset of 0x27B (32-bit machine) or 0x477 (64-bit machine). Min offset is achieved with index = */
|
INT16 VmReadIndex16(IN VM_CONTEXT *VmPtr, IN UINT32 CodeOffset)
|
/* Max offset is achieved with index = 0x7FFF giving an offset of 0x27B (32-bit machine) or 0x477 (64-bit machine). Min offset is achieved with index = */
INT16 VmReadIndex16(IN VM_CONTEXT *VmPtr, IN UINT32 CodeOffset)
|
{
UINT16 Index;
INT16 Offset;
INT16 ConstUnits;
INT16 NaturalUnits;
INT16 NBits;
INT16 Mask;
Index = VmReadCode16 (VmPtr, CodeOffset);
NBits = (INT16)((Index & 0x7000) >> 12);
NBits *= 2;
Mask = (INT16)((INT16) ~0 << NBits);
NaturalUnits = (INT16)(Index &~Mask);
ConstUnits = (INT16)(((Index &~0xF000) & Mask) >> NBits);
Offset = (INT16)(NaturalUnits * sizeof (UINTN) + ConstUnits);
if ((Index & 0x8000) != 0) {
Offset = (INT16)((INT32)Offset * -1);
}
return Offset;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Map the first page of the FIFO read-only to user-space. */
|
static int vmw_fifo_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
|
/* Map the first page of the FIFO read-only to user-space. */
static int vmw_fifo_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
|
{
int ret;
unsigned long address = (unsigned long)vmf->virtual_address;
if (address != vma->vm_start)
return VM_FAULT_SIGBUS;
ret = vm_insert_pfn(vma, address, vma->vm_pgoff);
if (likely(ret == -EBUSY || ret == 0))
return VM_FAULT_NOPAGE;
else if (ret == -ENOMEM)
return VM_FAULT_OOM;
return VM_FAULT_SIGBUS;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Extend A1/2/4 to A8 with interpolation to reduce rounding error. */
|
static uint8_t bit_extend(uint8_t value, uint8_t bpp)
|
/* Extend A1/2/4 to A8 with interpolation to reduce rounding error. */
static uint8_t bit_extend(uint8_t value, uint8_t bpp)
|
{
if(value == 0) return 0;
uint8_t res = value;
uint8_t bpp_now = bpp;
while(bpp_now < 8) {
res |= value << (8 - bpp_now);
bpp_now += bpp;
};
return res;
}
|
arendst/Tasmota
|
C++
|
GNU General Public License v3.0
| 21,318
|
/* Try to reclaim the Nbuf into the buffer pool. */
|
VOID MnpFreeNbuf(IN OUT MNP_DEVICE_DATA *MnpDeviceData, IN OUT NET_BUF *Nbuf)
|
/* Try to reclaim the Nbuf into the buffer pool. */
VOID MnpFreeNbuf(IN OUT MNP_DEVICE_DATA *MnpDeviceData, IN OUT NET_BUF *Nbuf)
|
{
EFI_TPL OldTpl;
NET_CHECK_SIGNATURE (MnpDeviceData, MNP_DEVICE_DATA_SIGNATURE);
ASSERT (Nbuf->RefCnt > 1);
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
NET_PUT_REF (Nbuf);
if (Nbuf->RefCnt == 1) {
NetbufTrim (Nbuf, Nbuf->TotalSize, NET_BUF_TAIL);
if (NetbufAllocSpace (Nbuf, NET_VLAN_TAG_LEN, NET_BUF_HEAD) != NULL) {
NetbufTrim (Nbuf, NET_VLAN_TAG_LEN, NET_BUF_TAIL);
}
NetbufQueAppend (&MnpDeviceData->FreeNbufQue, Nbuf);
}
gBS->RestoreTPL (OldTpl);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Transmit a chunk of data to the ethernet controller. The chunk can be either a full ethernet frame or a partial chunk of an ethernet frame. */
|
void KSZ8851SNL_Transmit(uint16_t length, const uint8_t *buffer)
|
/* Transmit a chunk of data to the ethernet controller. The chunk can be either a full ethernet frame or a partial chunk of an ethernet frame. */
void KSZ8851SNL_Transmit(uint16_t length, const uint8_t *buffer)
|
{
EFM_ASSERT(buffer != NULL);
KSZ8851SNL_SPI_WriteFifo(length, buffer);
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Path all jumps in 'list' to jump to 'target'. (The assert means that we cannot fix a jump to a forward address because we only know addresses once code is generated.) */
|
void luaK_patchlist(FuncState *fs, int list, int target)
|
/* Path all jumps in 'list' to jump to 'target'. (The assert means that we cannot fix a jump to a forward address because we only know addresses once code is generated.) */
void luaK_patchlist(FuncState *fs, int list, int target)
|
{
lua_assert(target < fs->pc);
patchlistaux(fs, list, target, NO_REG, target);
}
}
|
nodemcu/nodemcu-firmware
|
C++
|
MIT License
| 7,566
|
/* ++andreas: atari_mksound rewritten to always use the envelope, no timer, atari_nosound removed. stuff from the old atasound.c */
|
void atari_microwire_cmd(int cmd)
|
/* ++andreas: atari_mksound rewritten to always use the envelope, no timer, atari_nosound removed. stuff from the old atasound.c */
void atari_microwire_cmd(int cmd)
|
{
tt_microwire.mask = 0x7ff;
tt_microwire.data = MW_LM1992_ADDR | cmd;
while( tt_microwire.mask != 0x7ff)
;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Only setdomainname; getdomainname can be implemented by calling uname() */
|
SYSCALL_DEFINE2(setdomainname, char __user *, name, int, len)
|
/* Only setdomainname; getdomainname can be implemented by calling uname() */
SYSCALL_DEFINE2(setdomainname, char __user *, name, int, len)
|
{
int errno;
char tmp[__NEW_UTS_LEN];
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
if (len < 0 || len > __NEW_UTS_LEN)
return -EINVAL;
down_write(&uts_sem);
errno = -EFAULT;
if (!copy_from_user(tmp, name, len)) {
struct new_utsname *u = utsname();
memcpy(u->domainname, tmp, len);
memset(u->domainname + len, 0, sizeof(u->domainname) - len);
errno = 0;
}
up_write(&uts_sem);
return errno;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* TIM_Base MSP Initialization This function configures the hardware resources used in this example. */
|
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim_base)
|
/* TIM_Base MSP Initialization This function configures the hardware resources used in this example. */
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim_base)
|
{
if(htim_base->Instance==TIM2)
{
__HAL_RCC_TIM2_CLK_ENABLE();
}
else if(htim_base->Instance==TIM11)
{
__HAL_RCC_TIM11_CLK_ENABLE();
}
else if(htim_base->Instance==TIM13)
{
__HAL_RCC_TIM13_CLK_ENABLE();
}
else if(htim_base->Instance==TIM14)
{
__HAL_RCC_TIM14_CLK_ENABLE();
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Set the RSA key is read from key store. */
|
int32_t RSA_SetKey_KS(CRPT_T *crpt, uint32_t u32KeyNum, uint32_t u32KSMemType, uint32_t u32BlindKeyNum)
|
/* Set the RSA key is read from key store. */
int32_t RSA_SetKey_KS(CRPT_T *crpt, uint32_t u32KeyNum, uint32_t u32KSMemType, uint32_t u32BlindKeyNum)
|
{
if (s_u32RsaOpMode & CRPT_RSA_CTL_SCAP_Msk)
{
crpt->RSA_KSCTL = (u32BlindKeyNum << 8) | (u32KSMemType << CRPT_RSA_KSCTL_RSSRC_Pos) | CRPT_RSA_KSCTL_RSRC_Msk | u32KeyNum;
}
else
{
crpt->RSA_KSCTL = (u32KSMemType << CRPT_RSA_KSCTL_RSSRC_Pos) | CRPT_RSA_KSCTL_RSRC_Msk | u32KeyNum;
}
return 0;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Power up the specified port and reset PHY */
|
static int mv88361xx_powerup(struct mv88e61xx_config *swconfig, u32 prt)
|
/* Power up the specified port and reset PHY */
static int mv88361xx_powerup(struct mv88e61xx_config *swconfig, u32 prt)
|
{
char *name = swconfig->name;
WR_PHY(name, MV88E61XX_GLB2REG_DEVADR, MV88E61XX_PHY_DATA, 0x3360);
WR_PHY(name, MV88E61XX_GLB2REG_DEVADR,
MV88E61XX_PHY_CMD, (0x9410 | (prt << 5)));
if (mv88e61xx_busychk(name))
return -1;
WR_PHY(name, MV88E61XX_GLB2REG_DEVADR, MV88E61XX_PHY_DATA, 0x1140);
WR_PHY(name, MV88E61XX_GLB2REG_DEVADR,
MV88E61XX_PHY_CMD, (0x9400 | (prt << 5)));
if (mv88e61xx_busychk(name))
return -1;
return 0;
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* Unhashes a service from ip_vs_svc_table/ip_vs_svc_fwm_table. Should be called with locked tables. */
|
static int ip_vs_svc_unhash(struct ip_vs_service *svc)
|
/* Unhashes a service from ip_vs_svc_table/ip_vs_svc_fwm_table. Should be called with locked tables. */
static int ip_vs_svc_unhash(struct ip_vs_service *svc)
|
{
if (!(svc->flags & IP_VS_SVC_F_HASHED)) {
pr_err("%s(): request for unhash flagged, called from %pF\n",
__func__, __builtin_return_address(0));
return 0;
}
if (svc->fwmark == 0) {
list_del(&svc->s_list);
} else {
list_del(&svc->f_list);
}
svc->flags &= ~IP_VS_SVC_F_HASHED;
atomic_dec(&svc->refcnt);
return 1;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* param base eDMA peripheral base address. param channel eDMA channel number. param mask The mask of the interrupt source to be set. Use the defined edma_interrupt_enable_t type. */
|
void EDMA_DisableChannelInterrupts(DMA_Type *base, uint32_t channel, uint32_t mask)
|
/* param base eDMA peripheral base address. param channel eDMA channel number. param mask The mask of the interrupt source to be set. Use the defined edma_interrupt_enable_t type. */
void EDMA_DisableChannelInterrupts(DMA_Type *base, uint32_t channel, uint32_t mask)
|
{
assert(channel < (uint32_t)FSL_FEATURE_EDMA_MODULE_CHANNEL);
if (0U != (mask & (uint32_t)kEDMA_ErrorInterruptEnable))
{
base->EEI &= (~((uint32_t)0x1U << channel));
}
if (0U != (mask & (uint32_t)kEDMA_MajorInterruptEnable))
{
base->TCD[channel].CSR &= ~(uint16_t)DMA_CSR_INTMAJOR_MASK;
}
if (0U != (mask & (uint32_t)kEDMA_HalfInterruptEnable))
{
base->TCD[channel].CSR &= ~(uint16_t)DMA_CSR_INTHALF_MASK;
}
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.