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
|
|---|---|---|---|---|---|---|---|
/* Determines if there are any characters in receiver register. */
|
xtBoolean UARTFIFORxIsEmpty(unsigned long ulBase)
|
/* Determines if there are any characters in receiver register. */
xtBoolean UARTFIFORxIsEmpty(unsigned long ulBase)
|
{
xASSERT(UARTBaseValid(ulBase));
return (xHWREG(ulBase + USART_SR) & USART_SR_RXNE);
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Write to QSPI Tx register in SPI mode. */
|
static void qspi_write_spi(Qspi *qspi, uint16_t w_data)
|
/* Write to QSPI Tx register in SPI mode. */
static void qspi_write_spi(Qspi *qspi, uint16_t w_data)
|
{
assert(qspi);
while(!(qspi->QSPI_SR & QSPI_SR_TXEMPTY));
qspi->QSPI_TDR = w_data ;
while(!(qspi->QSPI_SR & QSPI_SR_TDRE));
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Starts the on-chip watchdog. Automatically loads WDOG_CNT into WDOG_STAT for us. */
|
static int bfin_wdt_start(void)
|
/* Starts the on-chip watchdog. Automatically loads WDOG_CNT into WDOG_STAT for us. */
static int bfin_wdt_start(void)
|
{
stampit();
bfin_write_WDOG_CTL(WDEN_ENABLE | ICTL_RESET);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* 16-bit unpacked samples => RGBA w/ associated alpha */
|
DECLARESepPutFunc(putRGBAAseparate16bittile)
|
/* 16-bit unpacked samples => RGBA w/ associated alpha */
DECLARESepPutFunc(putRGBAAseparate16bittile)
|
{
uint16 *wr = (uint16*) r;
uint16 *wg = (uint16*) g;
uint16 *wb = (uint16*) b;
uint16 *wa = (uint16*) a;
(void) img; (void) y;
for( ; h > 0; --h) {
for (x = 0; x < w; x++)
*cp++ = PACK4(img->Bitdepth16To8[*wr++],
img->Bitdepth16To8[*wg++],
img->Bitdepth16To8[*wb++],
img->Bitdepth16To8[*wa++]);
SKEW4(wr, wg, wb, wa, fromskew);
cp += toskew;
}
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* Set the modem control timer to fire immediately. */
|
static void imx_enable_ms(struct uart_port *port)
|
/* Set the modem control timer to fire immediately. */
static void imx_enable_ms(struct uart_port *port)
|
{
struct imx_port *sport = (struct imx_port *)port;
mod_timer(&sport->timer, jiffies);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Removes a callback function pair from the list of 'users' to be notified upon addition or removal of MTD devices. Causes the 'remove' callback to be immediately invoked for each MTD device currently present in the system. */
|
int unregister_mtd_user(struct mtd_notifier *old)
|
/* Removes a callback function pair from the list of 'users' to be notified upon addition or removal of MTD devices. Causes the 'remove' callback to be immediately invoked for each MTD device currently present in the system. */
int unregister_mtd_user(struct mtd_notifier *old)
|
{
int i;
mutex_lock(&mtd_table_mutex);
module_put(THIS_MODULE);
for (i=0; i< MAX_MTD_DEVICES; i++)
if (mtd_table[i])
old->remove(mtd_table[i]);
list_del(&old->list);
mutex_unlock(&mtd_table_mutex);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Change Logs: Date Author Notes weety first version */
|
void psc_change_state(int id, int state)
|
/* Change Logs: Date Author Notes weety first version */
void psc_change_state(int id, int state)
|
{
rt_uint32_t mdstat, mdctl;
if (id > DAVINCI_DM365_LPSC_KALEIDO)
return;
mdstat = PSC_MDSTAT_BASE + (id * 4);
mdctl = PSC_MDCTL_BASE + (id * 4);
if ((readl(mdstat) & 0x1f) == state)
return;
while (readl(PSC_PTSTAT) & 1) ;
writel(readl(mdctl) & (~0x1f), mdctl);
writel(readl(mdctl) | state, mdctl);
writel(readl(PSC_PTCMD) | 1, PSC_PTCMD);
while (readl(PSC_PTSTAT) & 1) ;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* UART MSP Initialization This function configures the hardware resources used in this example. */
|
void HAL_UART_MspInit(UART_HandleTypeDef *huart)
|
/* UART MSP Initialization This function configures the hardware resources used in this example. */
void HAL_UART_MspInit(UART_HandleTypeDef *huart)
|
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
if(huart->Instance==USART1)
{
__HAL_RCC_USART1_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
}
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* Disable Write Protect on pages marked as read-only. */
|
VOID DisableReadOnlyPageWriteProtect(VOID)
|
/* Disable Write Protect on pages marked as read-only. */
VOID DisableReadOnlyPageWriteProtect(VOID)
|
{
IA32_CR0 Cr0;
if (!IsInSmm ()) {
Cr0.UintN = AsmReadCr0 ();
Cr0.Bits.WP = 0;
AsmWriteCr0 (Cr0.UintN);
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* spider_net_write_phy_register writes to an arbitrary PHY register via the spider GPCWOPCMD register. We assume the queue does not run full (not more than 15 commands outstanding). */
|
static void spider_net_write_phy(struct net_device *netdev, int mii_id, int reg, int val)
|
/* spider_net_write_phy_register writes to an arbitrary PHY register via the spider GPCWOPCMD register. We assume the queue does not run full (not more than 15 commands outstanding). */
static void spider_net_write_phy(struct net_device *netdev, int mii_id, int reg, int val)
|
{
struct spider_net_card *card = netdev_priv(netdev);
u32 writevalue;
writevalue = ((u32)mii_id << 21) |
((u32)reg << 16) | ((u32)val);
spider_net_write_reg(card, SPIDER_NET_GPCWOPCMD, writevalue);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* phy_disable_interrupts - Disable the PHY interrupts from the PHY side @phydev: target phy_device struct */
|
int phy_disable_interrupts(struct phy_device *phydev)
|
/* phy_disable_interrupts - Disable the PHY interrupts from the PHY side @phydev: target phy_device struct */
int phy_disable_interrupts(struct phy_device *phydev)
|
{
int err;
err = phy_config_interrupt(phydev, PHY_INTERRUPT_DISABLED);
if (err)
goto phy_err;
err = phy_clear_interrupt(phydev);
if (err)
goto phy_err;
return 0;
phy_err:
phy_error(phydev);
return err;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Checks whether the specified CRYP flag is set or not. */
|
FlagStatus CRYP_GetFlagStatus(uint8_t CRYP_FLAG)
|
/* Checks whether the specified CRYP flag is set or not. */
FlagStatus CRYP_GetFlagStatus(uint8_t CRYP_FLAG)
|
{
FlagStatus bitstatus = RESET;
uint32_t tempreg = 0;
assert_param(IS_CRYP_GET_FLAG(CRYP_FLAG));
if ((CRYP_FLAG & FLAG_MASK) != 0x00)
{
tempreg = CRYP->RISR;
}
else
{
tempreg = CRYP->SR;
}
if ((tempreg & CRYP_FLAG ) != (uint8_t)RESET)
{
bitstatus = SET;
}
else
{
bitstatus = RESET;
}
return bitstatus;
}
|
MaJerle/stm32f429
|
C++
| null | 2,036
|
/* Check the status of the FIFO buffer of the specified SPI port. */
|
unsigned long SPIFIFOStatusGet(unsigned long ulBase, unsigned long ulRxTx)
|
/* Check the status of the FIFO buffer of the specified SPI port. */
unsigned long SPIFIFOStatusGet(unsigned long ulBase, unsigned long ulRxTx)
|
{
unsigned long ulDataNum;
xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE));
xASSERT((ulRxTx == SPI_FSR_RX) || (ulRxTx == SPI_FSR_TX));
if(ulRxTx == SPI_FSR_RX)
{
ulDataNum = (xHWREG(ulBase + SPI_FSR) & SPI_FSR_RXFS_M) >> SPI_FSR_RXFS_S;
}
else
{
ulDataNum = (xHWREG(ulBase + SPI_FSR) & SPI_FSR_TXFS_M) >> SPI_FSR_TXFS_S;
}
return ulDataNum;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* This function logs rx or tx data as hex-ascii. */
|
void log_sha204(uint8_t length, uint8_t *buffer, bool is_rx)
|
/* This function logs rx or tx data as hex-ascii. */
void log_sha204(uint8_t length, uint8_t *buffer, bool is_rx)
|
{
uint8_t i;
uint8_t nibble;
usart_serial_write_packet(USART_SHA204, (uint8_t *) (is_rx ? "r" : "t"), 1);
usart_serial_write_packet(USART_SHA204, (uint8_t *) "x: ", 3);
for (i = 0; i < length; i++) {
nibble = convert_nibble_to_hexascii(buffer[i] >> 4);
usart_putchar(USART_SHA204, nibble);
nibble = convert_nibble_to_hexascii(buffer[i] & 0x0F);
usart_putchar(USART_SHA204, nibble);
usart_putchar(USART_SHA204, ' ');
}
usart_write_crlf();
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Reads the IT status register from the ST25DV. */
|
int32_t ST25DV_ReadITSTStatus_Dyn(ST25DV_Object_t *pObj, uint8_t *const pITStatus)
|
/* Reads the IT status register from the ST25DV. */
int32_t ST25DV_ReadITSTStatus_Dyn(ST25DV_Object_t *pObj, uint8_t *const pITStatus)
|
{
return st25dv_get_itsts_dyn_all(&(pObj->Ctx), pITStatus );
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* psmouse_sliced_command() sends an extended PS/2 command to the mouse using sliced syntax, understood by advanced devices, such as Logitech or Synaptics touchpads. The command is encoded as: 0xE6 0xE8 rr 0xE8 ss 0xE8 tt 0xE8 uu where (rr*64)+(ss*16)+(tt*4)+uu is the command. */
|
int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command)
|
/* psmouse_sliced_command() sends an extended PS/2 command to the mouse using sliced syntax, understood by advanced devices, such as Logitech or Synaptics touchpads. The command is encoded as: 0xE6 0xE8 rr 0xE8 ss 0xE8 tt 0xE8 uu where (rr*64)+(ss*16)+(tt*4)+uu is the command. */
int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command)
|
{
int i;
if (ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETSCALE11))
return -1;
for (i = 6; i >= 0; i -= 2) {
unsigned char d = (command >> i) & 3;
if (ps2_command(&psmouse->ps2dev, &d, PSMOUSE_CMD_SETRES))
return -1;
}
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Removes all SRP remote ports for a given Scsi_Host. Must be called just before scsi_remove_host for SRP HBAs. */
|
void srp_remove_host(struct Scsi_Host *shost)
|
/* Removes all SRP remote ports for a given Scsi_Host. Must be called just before scsi_remove_host for SRP HBAs. */
void srp_remove_host(struct Scsi_Host *shost)
|
{
device_for_each_child(&shost->shost_gendev, NULL, do_srp_rport_del);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* set up the GDB stub serial port baud rate timers */
|
void gdbstub_io_set_baud(unsigned baud)
|
/* set up the GDB stub serial port baud rate timers */
void gdbstub_io_set_baud(unsigned baud)
|
{
unsigned value;
u8 lcr;
value = 18432000 / 16 / baud;
lcr = GDBPORT_SERIAL_LCR;
GDBPORT_SERIAL_LCR |= UART_LCR_DLAB;
GDBPORT_SERIAL_DLL = value & 0xff;
GDBPORT_SERIAL_DLM = (value >> 8) & 0xff;
GDBPORT_SERIAL_LCR = lcr;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* This function writes a node to the orphan head from the orphan buffer. If atomic is not zero, then the write is done atomically. On success, %0 is returned, otherwise a negative error code is returned. */
|
static int do_write_orph_node(struct ubifs_info *c, int len, int atomic)
|
/* This function writes a node to the orphan head from the orphan buffer. If atomic is not zero, then the write is done atomically. On success, %0 is returned, otherwise a negative error code is returned. */
static int do_write_orph_node(struct ubifs_info *c, int len, int atomic)
|
{
int err = 0;
if (atomic) {
ubifs_assert(c->ohead_offs == 0);
ubifs_prepare_node(c, c->orph_buf, len, 1);
len = ALIGN(len, c->min_io_size);
err = ubifs_leb_change(c, c->ohead_lnum, c->orph_buf, len);
} else {
if (c->ohead_offs == 0) {
err = ubifs_leb_unmap(c, c->ohead_lnum);
if (err)
return err;
}
err = ubifs_write_node(c, c->orph_buf, len, c->ohead_lnum,
c->ohead_offs);
}
return err;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* This function is called by lib_ppc/board.c:board_init_r. At this point, basic setup is done, U-Boot has been moved into SDRAM and PCI has been set up. From here we done late setup. */
|
int misc_init_r(void)
|
/* This function is called by lib_ppc/board.c:board_init_r. At this point, basic setup is done, U-Boot has been moved into SDRAM and PCI has been set up. From here we done late setup. */
int misc_init_r(void)
|
{
host_bridge_init ();
return 0;
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* Globally disables interrupts.
This function globally disables interrupts. This is performed by clearing the 'I' bit in the CPU's Processor Status Word (PSW) register. */
|
void R_BSP_InterruptsDisable(void)
|
/* Globally disables interrupts.
This function globally disables interrupts. This is performed by clearing the 'I' bit in the CPU's Processor Status Word (PSW) register. */
void R_BSP_InterruptsDisable(void)
|
{
uint32_t pmode;
pmode = (R_BSP_GET_PSW() & 0x00100000);
if (0 == pmode)
{
R_BSP_CLRPSW_I();
}
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Returns: the element data if @free_segment is FALSE, otherwise NULL. The element data should be freed using g_free(). */
|
guint8* g_byte_array_free(GByteArray *array, gboolean free_segment)
|
/* Returns: the element data if @free_segment is FALSE, otherwise NULL. The element data should be freed using g_free(). */
guint8* g_byte_array_free(GByteArray *array, gboolean free_segment)
|
{
return (guint8 *)g_array_free ((GArray *)array, free_segment);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* USBD_LL_SetDevAddress Assign an USB address to the device. */
|
USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_addr)
|
/* USBD_LL_SetDevAddress Assign an USB address to the device. */
USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_addr)
|
{
HAL_PCD_SetAddress(pdev->pData, dev_addr);
return USBD_OK;
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* Disable the PWM interrupt of the PWM module.
The */
|
void PWMIntDisable(unsigned long ulBase, unsigned long ulChannel, unsigned long ulIntType)
|
/* Disable the PWM interrupt of the PWM module.
The */
void PWMIntDisable(unsigned long ulBase, unsigned long ulChannel, unsigned long ulIntType)
|
{
unsigned long ulChannelTemp;
ulChannelTemp = ulChannel;
xASSERT((ulBase == PWMA_BASE));
xASSERT(((ulChannelTemp >= 0) || (ulChannelTemp <= 5)));
xASSERT((ulIntType == PWM_INT_DUTY) || (ulIntType == PWM_INT_BRAKE) ||
(ulIntType == PWM_INT_PWM));
if(ulIntType == PWM_INT_PWM)
{
xHWREG(ulBase + PWM_PIER) &= ~(PWM_PIER_PWMPIE0 << ulChannelTemp);
}
else if(ulIntType == PWM_INT_DUTY)
{
xHWREG(ulBase + PWM_PIER) &= ~(PWM_PIER_PWMDIE0 << ulChannelTemp);
}
else
{
xHWREG(ulBase + PWM_PIER) &= ~PWM_PIER_BRKIE;
}
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* USB Device Endpoint 0 Event Callback - MSC specific handling (Setup Request To Interface) Parameters: none Return Value: TRUE - Setup class request ok, FALSE - Setup class request not supported */
|
__WEAK BOOL USBD_EndPoint0_Setup_MSC_ReqToIF(void)
|
/* USB Device Endpoint 0 Event Callback - MSC specific handling (Setup Request To Interface) Parameters: none Return Value: TRUE - Setup class request ok, FALSE - Setup class request not supported */
__WEAK BOOL USBD_EndPoint0_Setup_MSC_ReqToIF(void)
|
{
if (USBD_SetupPacket.wIndexL == usbd_msc_if_num) {
switch (USBD_SetupPacket.bRequest) {
case MSC_REQUEST_RESET:
if ((USBD_SetupPacket.wValue == 0) &&
(USBD_SetupPacket.wLength == 0)) {
if (USBD_MSC_Reset()) {
USBD_StatusInStage();
return (__TRUE);
}
}
break;
case MSC_REQUEST_GET_MAX_LUN:
if ((USBD_SetupPacket.wValue == 0) &&
(USBD_SetupPacket.wLength == 1)) {
if (USBD_MSC_GetMaxLUN()) {
USBD_EP0Data.pData = USBD_EP0Buf;
USBD_DataInStage();
return (__TRUE);
}
}
break;
}
}
return (__FALSE);
}
|
ARMmbed/DAPLink
|
C++
|
Apache License 2.0
| 2,140
|
/* Clear PMECR (Power Management Event Control Register) flags. */
|
void KSZ8851SNL_PMECRStatusClear(uint16_t flags)
|
/* Clear PMECR (Power Management Event Control Register) flags. */
void KSZ8851SNL_PMECRStatusClear(uint16_t flags)
|
{
uint16_t status = KSZ8851SNL_SPI_ReadRegister(PMECR) | flags;
KSZ8851SNL_SPI_WriteRegister(PMECR, status);
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* The GetModeData() function is used to read the current mode data (operational parameters) from the MNP or the underlying SNP. */
|
EFI_STATUS EFIAPI MnpGetModeData(IN EFI_MANAGED_NETWORK_PROTOCOL *This, OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL, OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL)
|
/* The GetModeData() function is used to read the current mode data (operational parameters) from the MNP or the underlying SNP. */
EFI_STATUS EFIAPI MnpGetModeData(IN EFI_MANAGED_NETWORK_PROTOCOL *This, OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL, OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL)
|
{
MNP_INSTANCE_DATA *Instance;
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
EFI_TPL OldTpl;
EFI_STATUS Status;
UINT32 InterruptStatus;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
}
Instance = MNP_INSTANCE_DATA_FROM_THIS (This);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
if (MnpConfigData != NULL) {
CopyMem (MnpConfigData, &Instance->ConfigData, sizeof (*MnpConfigData));
}
if (SnpModeData != NULL) {
Snp = Instance->MnpServiceData->MnpDeviceData->Snp;
Snp->GetStatus (Snp, &InterruptStatus, NULL);
CopyMem (SnpModeData, Snp->Mode, sizeof (*SnpModeData));
}
if (!Instance->Configured) {
Status = EFI_NOT_STARTED;
} else {
Status = EFI_SUCCESS;
}
gBS->RestoreTPL (OldTpl);
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Dumps (serializes) one css declaration to a file. */
|
static void dump(CRDeclaration *a_this, FILE *a_fp, glong a_indent)
|
/* Dumps (serializes) one css declaration to a file. */
static void dump(CRDeclaration *a_this, FILE *a_fp, glong a_indent)
|
{
guchar *str = NULL;
g_return_if_fail (a_this);
str = cr_declaration_to_string (a_this, a_indent);
if (str) {
fprintf (a_fp, "%s", str);
g_free (str);
str = NULL;
}
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* try to close a goto with existing labels; this solves backward jumps */
|
static int findlabel(LexState *ls, int g)
|
/* try to close a goto with existing labels; this solves backward jumps */
static int findlabel(LexState *ls, int g)
|
{
Labeldesc *lb = &dyd->label.arr[i];
if (luaS_eqstr(lb->name, gt->name)) {
if (gt->nactvar > lb->nactvar &&
(bl->upval || dyd->label.n > bl->firstlabel))
luaK_patchclose(ls->fs, gt->pc, lb->nactvar);
closegoto(ls, g, lb);
return 1;
}
}
return 0;
}
|
opentx/opentx
|
C++
|
GNU General Public License v2.0
| 2,025
|
/* Should be called without the journal lock held. */
|
void jbd2_journal_unlock_updates(journal_t *journal)
|
/* Should be called without the journal lock held. */
void jbd2_journal_unlock_updates(journal_t *journal)
|
{
J_ASSERT(journal->j_barrier_count != 0);
mutex_unlock(&journal->j_barrier);
spin_lock(&journal->j_state_lock);
--journal->j_barrier_count;
spin_unlock(&journal->j_state_lock);
wake_up(&journal->j_wait_transaction_locked);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function is called after a PCI bus error affecting this device has been detected. */
|
static pci_ers_result_t ixgbe_io_error_detected(struct pci_dev *pdev, pci_channel_state_t state)
|
/* This function is called after a PCI bus error affecting this device has been detected. */
static pci_ers_result_t ixgbe_io_error_detected(struct pci_dev *pdev, pci_channel_state_t state)
|
{
struct net_device *netdev = pci_get_drvdata(pdev);
struct ixgbe_adapter *adapter = netdev_priv(netdev);
netif_device_detach(netdev);
if (state == pci_channel_io_perm_failure)
return PCI_ERS_RESULT_DISCONNECT;
if (netif_running(netdev))
ixgbe_down(adapter);
pci_disable_device(pdev);
return PCI_ERS_RESULT_NEED_RESET;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Initialises the klist structure. If the klist_node structures are going to be embedded in refcounted objects (necessary for safe deletion) then the get/put arguments are used to initialise functions that take and release references on the embedding objects. */
|
void klist_init(struct klist *k, void(*get)(struct klist_node *), void(*put)(struct klist_node *))
|
/* Initialises the klist structure. If the klist_node structures are going to be embedded in refcounted objects (necessary for safe deletion) then the get/put arguments are used to initialise functions that take and release references on the embedding objects. */
void klist_init(struct klist *k, void(*get)(struct klist_node *), void(*put)(struct klist_node *))
|
{
INIT_LIST_HEAD(&k->k_list);
spin_lock_init(&k->k_lock);
k->get = get;
k->put = put;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Enables the Jabber frame support. When enabled, GMAC disabled the jabber timer, and can transfer 16,384 byte frames. */
|
void synopGMAC_jab_enable(synopGMACdevice *gmacdev)
|
/* Enables the Jabber frame support. When enabled, GMAC disabled the jabber timer, and can transfer 16,384 byte frames. */
void synopGMAC_jab_enable(synopGMACdevice *gmacdev)
|
{
synopGMACSetBits(gmacdev->MacBase, GmacConfig, GmacJabber);
return;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* For synchronous operations: force any uncommitted transactions to disk. May seem kludgy, but it reuses all the handle batching code in a very simple manner. */
|
int journal_force_commit(journal_t *journal)
|
/* For synchronous operations: force any uncommitted transactions to disk. May seem kludgy, but it reuses all the handle batching code in a very simple manner. */
int journal_force_commit(journal_t *journal)
|
{
handle_t *handle;
int ret;
handle = journal_start(journal, 1);
if (IS_ERR(handle)) {
ret = PTR_ERR(handle);
} else {
handle->h_sync = 1;
ret = journal_stop(handle);
}
return ret;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Write a byte to the given I2C instance. */
|
void _i2c_s_sync_write_byte(struct _i2c_s_sync_device *const device, const uint8_t data)
|
/* Write a byte to the given I2C instance. */
void _i2c_s_sync_write_byte(struct _i2c_s_sync_device *const device, const uint8_t data)
|
{
hri_sercomi2cs_write_DATA_reg(device->hw, data);
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* @count: Number of ranges to be allocated for the regmap. Return: A pointer to the newly allocated regmap, or NULL on error. */
|
static struct regmap* regmap_alloc(int count)
|
/* @count: Number of ranges to be allocated for the regmap. Return: A pointer to the newly allocated regmap, or NULL on error. */
static struct regmap* regmap_alloc(int count)
|
{
struct regmap *map;
map = malloc(sizeof(*map) + sizeof(map->ranges[0]) * count);
if (!map)
return NULL;
map->range_count = count;
return map;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Return-probe handler: Log the return value and duration. Duration may turn out to be zero consistently, depending upon the granularity of time accounting on the platform. */
|
static int ret_handler(struct kretprobe_instance *ri, struct pt_regs *regs)
|
/* Return-probe handler: Log the return value and duration. Duration may turn out to be zero consistently, depending upon the granularity of time accounting on the platform. */
static int ret_handler(struct kretprobe_instance *ri, struct pt_regs *regs)
|
{
int retval = regs_return_value(regs);
struct my_data *data = (struct my_data *)ri->data;
s64 delta;
ktime_t now;
now = ktime_get();
delta = ktime_to_ns(ktime_sub(now, data->entry_stamp));
printk(KERN_INFO "%s returned %d and took %lld ns to execute\n",
func_name, retval, (long long)delta);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* DMA Channel Set Memory Word Width.
Set the memory word width 8 bits, 16 bits, or 32 bits. Refer to datasheet for alignment information if the source and destination widths do not match. */
|
void dma_set_memory_size(uint32_t dma, uint8_t channel, uint32_t mem_size)
|
/* DMA Channel Set Memory Word Width.
Set the memory word width 8 bits, 16 bits, or 32 bits. Refer to datasheet for alignment information if the source and destination widths do not match. */
void dma_set_memory_size(uint32_t dma, uint8_t channel, uint32_t mem_size)
|
{
DMA_CCR(dma, channel) &= ~(DMA_CCR_MSIZE_MASK);
DMA_CCR(dma, channel) |= mem_size;
}
|
insane-adding-machines/unicore-mx
|
C++
|
GNU General Public License v3.0
| 50
|
/* ctrl: NAND_NCE: bit 0 -> bit 2 NAND_CLE: bit 1 -> bit 1 NAND_ALE: bit 2 -> bit 0 */
|
static void ts78xx_ts_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
|
/* ctrl: NAND_NCE: bit 0 -> bit 2 NAND_CLE: bit 1 -> bit 1 NAND_ALE: bit 2 -> bit 0 */
static void ts78xx_ts_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
|
{
struct nand_chip *this = mtd->priv;
if (ctrl & NAND_CTRL_CHANGE) {
unsigned char bits;
bits = (ctrl & NAND_NCE) << 2;
bits |= ctrl & NAND_CLE;
bits |= (ctrl & NAND_ALE) >> 2;
writeb((readb(TS_NAND_CTRL) & ~0x7) | bits, TS_NAND_CTRL);
}
if (cmd != NAND_CMD_NONE)
writeb(cmd, this->IO_ADDR_W);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Returns non-zero if it can do so, zero if the system code is unknown. */
|
static int arcnet_encap_print(netdissect_options *, u_char arctype, const u_char *p, u_int length, u_int caplen)
|
/* Returns non-zero if it can do so, zero if the system code is unknown. */
static int arcnet_encap_print(netdissect_options *, u_char arctype, const u_char *p, u_int length, u_int caplen)
|
{
switch (arctype) {
case ARCTYPE_IP_OLD:
case ARCTYPE_IP:
ip_print(ndo, p, length);
return (1);
case ARCTYPE_INET6:
ip6_print(ndo, p, length);
return (1);
case ARCTYPE_ARP_OLD:
case ARCTYPE_ARP:
case ARCTYPE_REVARP:
arp_print(ndo, p, length, caplen);
return (1);
case ARCTYPE_ATALK:
if (ndo->ndo_vflag)
ND_PRINT((ndo, "et1 "));
atalk_print(ndo, p, length);
return (1);
case ARCTYPE_IPX:
ipx_print(ndo, p, length);
return (1);
default:
return (0);
}
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* In this example, user task fetches the sensor values every seconds. */
|
void user_task_periodic(void *pvParameters)
|
/* In this example, user task fetches the sensor values every seconds. */
void user_task_periodic(void *pvParameters)
|
{
vTaskDelay (100/portTICK_PERIOD_MS);
while (1)
{
read_data ();
vTaskDelay(200/portTICK_PERIOD_MS);
}
}
|
RavenSystem/esp-homekit-devices
|
C++
|
Other
| 2,577
|
/* Find the channel frequency power info with specific channel. */
|
struct chan_freq_power* lbs_find_cfp_by_band_and_channel(struct lbs_private *priv, u8 band, u16 channel)
|
/* Find the channel frequency power info with specific channel. */
struct chan_freq_power* lbs_find_cfp_by_band_and_channel(struct lbs_private *priv, u8 band, u16 channel)
|
{
struct chan_freq_power *cfp = NULL;
struct region_channel *rc;
int i, j;
for (j = 0; !cfp && (j < ARRAY_SIZE(priv->region_channel)); j++) {
rc = &priv->region_channel[j];
if (!rc->valid || !rc->CFP)
continue;
if (rc->band != band)
continue;
for (i = 0; i < rc->nrcfp; i++) {
if (rc->CFP[i].channel == channel) {
cfp = &rc->CFP[i];
break;
}
}
}
if (!cfp && channel)
lbs_deb_wext("lbs_find_cfp_by_band_and_channel: can't find "
"cfp by band %d / channel %d\n", band, channel);
return cfp;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Remove the tracepoint from the tracepoint hash table. Must be called with mutex_lock held. */
|
static void remove_tracepoint(struct tracepoint_entry *e)
|
/* Remove the tracepoint from the tracepoint hash table. Must be called with mutex_lock held. */
static void remove_tracepoint(struct tracepoint_entry *e)
|
{
hlist_del(&e->hlist);
kfree(e);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Returns zero if carrier state does not change, nonzero if it does. */
|
static int bond_set_carrier(struct bonding *bond)
|
/* Returns zero if carrier state does not change, nonzero if it does. */
static int bond_set_carrier(struct bonding *bond)
|
{
struct slave *slave;
int i;
if (bond->slave_cnt == 0)
goto down;
if (bond->params.mode == BOND_MODE_8023AD)
return bond_3ad_set_carrier(bond);
bond_for_each_slave(bond, slave, i) {
if (slave->link == BOND_LINK_UP) {
if (!netif_carrier_ok(bond->dev)) {
netif_carrier_on(bond->dev);
return 1;
}
return 0;
}
}
down:
if (netif_carrier_ok(bond->dev)) {
netif_carrier_off(bond->dev);
return 1;
}
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Functions to push and pop a job onto the head of a given job list. */
|
static struct kcopyd_job* pop(struct list_head *jobs, struct dm_kcopyd_client *kc)
|
/* Functions to push and pop a job onto the head of a given job list. */
static struct kcopyd_job* pop(struct list_head *jobs, struct dm_kcopyd_client *kc)
|
{
struct kcopyd_job *job = NULL;
unsigned long flags;
spin_lock_irqsave(&kc->job_lock, flags);
if (!list_empty(jobs)) {
job = list_entry(jobs->next, struct kcopyd_job, list);
list_del(&job->list);
}
spin_unlock_irqrestore(&kc->job_lock, flags);
return job;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* check EXMC interrupt flag is set or not */
|
FlagStatus exmc_interrupt_flag_get(uint32_t bank, uint32_t interrupt_source)
|
/* check EXMC interrupt flag is set or not */
FlagStatus exmc_interrupt_flag_get(uint32_t bank, uint32_t interrupt_source)
|
{
uint32_t status = 0x00000000U,interrupt_enable = 0x00000000U,interrupt_state = 0x00000000U;
status = EXMC_NPINTEN(bank);
interrupt_state = (status & (interrupt_source >> INTEN_INTS_OFFSET));
interrupt_enable = (status & interrupt_source);
if ((interrupt_enable) && (interrupt_state)){
return SET;
}else{
return RESET;
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Read the status register for the current speed/duplex and store the current speed and duplex for copper connections. */
|
s32 igb_get_speed_and_duplex_copper(struct e1000_hw *hw, u16 *speed, u16 *duplex)
|
/* Read the status register for the current speed/duplex and store the current speed and duplex for copper connections. */
s32 igb_get_speed_and_duplex_copper(struct e1000_hw *hw, u16 *speed, u16 *duplex)
|
{
u32 status;
status = rd32(E1000_STATUS);
if (status & E1000_STATUS_SPEED_1000) {
*speed = SPEED_1000;
hw_dbg("1000 Mbs, ");
} else if (status & E1000_STATUS_SPEED_100) {
*speed = SPEED_100;
hw_dbg("100 Mbs, ");
} else {
*speed = SPEED_10;
hw_dbg("10 Mbs, ");
}
if (status & E1000_STATUS_FD) {
*duplex = FULL_DUPLEX;
hw_dbg("Full Duplex\n");
} else {
*duplex = HALF_DUPLEX;
hw_dbg("Half Duplex\n");
}
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* USART Clock initialization function.
Enables register interface and peripheral clock */
|
void TARGET_IO_CLOCK_init()
|
/* USART Clock initialization function.
Enables register interface and peripheral clock */
void TARGET_IO_CLOCK_init()
|
{
_pmc_enable_periph_clock(ID_USART1);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* This routine gets translation offset from a root bridge instance by resource type. */
|
UINT64 GetTranslationByResourceType(IN PCI_ROOT_BRIDGE_INSTANCE *RootBridge, IN PCI_RESOURCE_TYPE ResourceType)
|
/* This routine gets translation offset from a root bridge instance by resource type. */
UINT64 GetTranslationByResourceType(IN PCI_ROOT_BRIDGE_INSTANCE *RootBridge, IN PCI_RESOURCE_TYPE ResourceType)
|
{
switch (ResourceType) {
case TypeIo:
return RootBridge->Io.Translation;
case TypeMem32:
return RootBridge->Mem.Translation;
case TypePMem32:
return RootBridge->PMem.Translation;
case TypeMem64:
return RootBridge->MemAbove4G.Translation;
case TypePMem64:
return RootBridge->PMemAbove4G.Translation;
case TypeBus:
return RootBridge->Bus.Translation;
default:
ASSERT (FALSE);
return 0;
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* The Start() function is designed to be invoked from the EFI boot service ConnectController(). As a result, much of the error checking on the parameters to Start() has been moved into this common boot service. It is legal to call Start() from other locations, but the following calling restrictions must be followed, or the system behavior will not be deterministic. */
|
EFI_STATUS EFIAPI RedfishConfigDriverBindingStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL)
|
/* The Start() function is designed to be invoked from the EFI boot service ConnectController(). As a result, much of the error checking on the parameters to Start() has been moved into this common boot service. It is legal to call Start() from other locations, but the following calling restrictions must be followed, or the system behavior will not be deterministic. */
EFI_STATUS EFIAPI RedfishConfigDriverBindingStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL)
|
{
VOID *ConfigHandlerRegistration;
if (gRedfishConfigData.Event != NULL) {
return EFI_ALREADY_STARTED;
}
gRedfishConfigData.Event = EfiCreateProtocolNotifyEvent (
&gEdkIIRedfishConfigHandlerProtocolGuid,
TPL_CALLBACK,
RedfishConfigHandlerInstalledCallback,
(VOID *)&gRedfishConfigData,
&ConfigHandlerRegistration
);
return EFI_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Indicates if the calibration of the touch screen is Ok. */
|
static uint8_t rtouch_is_calibrated(void)
|
/* Indicates if the calibration of the touch screen is Ok. */
static uint8_t rtouch_is_calibrated(void)
|
{
return g_ul_is_calibrated;
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Instruct the DMA not to drop the packets even if it fails tcp ip checksum. This is to instruct the receive DMA engine to allow the packets even if recevied packet fails the tcp/ip checksum in hardware. Valid only when full checksum offloading is enabled(type-2). */
|
void synopGMAC_rx_tcpip_chksum_drop_disable(synopGMACdevice *gmacdev)
|
/* Instruct the DMA not to drop the packets even if it fails tcp ip checksum. This is to instruct the receive DMA engine to allow the packets even if recevied packet fails the tcp/ip checksum in hardware. Valid only when full checksum offloading is enabled(type-2). */
void synopGMAC_rx_tcpip_chksum_drop_disable(synopGMACdevice *gmacdev)
|
{
synopGMACSetBits(gmacdev->DmaBase, DmaControl, DmaDisableDropTcpCs);
return;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Command response callback function for sd_ble_gattc_write BLE command.
Callback for decoding the command response return code. */
|
static uint32_t gattc_write_rsp_dec(const uint8_t *p_buffer, uint16_t length)
|
/* Command response callback function for sd_ble_gattc_write BLE command.
Callback for decoding the command response return code. */
static uint32_t gattc_write_rsp_dec(const uint8_t *p_buffer, uint16_t length)
|
{
uint32_t result_code;
const uint32_t err_code = ble_gattc_write_rsp_dec(p_buffer, length, &result_code);
APP_ERROR_CHECK(err_code);
return result_code;
}
|
labapart/polymcu
|
C++
| null | 201
|
/* Mark the inode as not needing to be unlocked when the inode item's IOP_UNLOCK() routine is called. The inode must already be locked and associated with the given transaction. */
|
void xfs_trans_ihold(xfs_trans_t *tp, xfs_inode_t *ip)
|
/* Mark the inode as not needing to be unlocked when the inode item's IOP_UNLOCK() routine is called. The inode must already be locked and associated with the given transaction. */
void xfs_trans_ihold(xfs_trans_t *tp, xfs_inode_t *ip)
|
{
ASSERT(ip->i_transp == tp);
ASSERT(ip->i_itemp != NULL);
ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
ip->i_itemp->ili_flags |= XFS_ILI_HOLD;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* If the aio_fsync() function fails or aiocbp indicates an error condition, data is not guaranteed to have been successfully transferred. */
|
static void aio_fync_work(struct rt_work *work, void *work_data)
|
/* If the aio_fsync() function fails or aiocbp indicates an error condition, data is not guaranteed to have been successfully transferred. */
static void aio_fync_work(struct rt_work *work, void *work_data)
|
{
int result;
rt_base_t level;
struct aiocb *cb = (struct aiocb*)work_data;
RT_ASSERT(cb != RT_NULL);
result = fsync(cb->aio_fildes);
level = rt_hw_interrupt_disable();
if (result < 0)
cb->aio_result = errno;
else
cb->aio_result = 0;
rt_hw_interrupt_enable(level);
return ;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Stops the TIMER PWM signal generation in DMA mode. */
|
void ald_timer_pwm_stop_by_dma(ald_timer_handle_t *hperh, ald_timer_channel_t ch)
|
/* Stops the TIMER PWM signal generation in DMA mode. */
void ald_timer_pwm_stop_by_dma(ald_timer_handle_t *hperh, ald_timer_channel_t ch)
|
{
ald_timer_oc_stop_by_dma(hperh, ch);
return;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). */
|
UINT32 EFIAPI PciExpressWrite32(IN UINTN Address, IN UINT32 Value)
|
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). */
UINT32 EFIAPI PciExpressWrite32(IN UINTN Address, IN UINT32 Value)
|
{
if (Address >= mSmmPciExpressLibPciExpressBaseSize) {
return (UINT32)-1;
}
return MmioWrite32 (GetPciExpressAddress (Address), Value);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Returns the current device address in device mode. */
|
unsigned long USBDevAddrGet(unsigned long ulBase)
|
/* Returns the current device address in device mode. */
unsigned long USBDevAddrGet(unsigned long ulBase)
|
{
ASSERT(ulBase == USB0_BASE);
return(HWREGB(ulBase + USB_O_FADDR));
}
|
watterott/WebRadio
|
C++
| null | 71
|
/* Add a Pcmcia Slot selector to a mapping */
|
static int mapping_addpcmciaslot(struct if_mapping *ifnode, int *active, char *pos, size_t len, struct add_extra *extra, int linenum)
|
/* Add a Pcmcia Slot selector to a mapping */
static int mapping_addpcmciaslot(struct if_mapping *ifnode, int *active, char *pos, size_t len, struct add_extra *extra, int linenum)
|
{
size_t n;
extra = extra;
n = strspn(string, "0123456789");
if((n < len) || (sscanf(string, "%d", &ifnode->pcmcia_slot) != 1))
{
fprintf(stderr, "Error: Invalid Pcmcia Slot `%s' at line %d\n",
string, linenum);
return(-1);
}
ifnode->active[SELECT_PCMCIASLOT] = 1;
active[SELECT_PCMCIASLOT] = 1;
if(verbose)
fprintf(stderr, "Parsing : Added Pcmcia Slot `%d' from line %d.\n",
ifnode->pcmcia_slot, linenum);
return(0);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Zero the heap and initialize start, end and lowest-free */
|
void mem_init(void)
|
/* Zero the heap and initialize start, end and lowest-free */
void mem_init(void)
|
{
struct mem *mem;
LWIP_ASSERT("Sanity check alignment",
(SIZEOF_STRUCT_MEM & (MEM_ALIGNMENT - 1)) == 0);
ram = (u8_t *)LWIP_MEM_ALIGN(LWIP_RAM_HEAP_POINTER);
mem = (struct mem *)(void *)ram;
mem->next = MEM_SIZE_ALIGNED;
mem->prev = 0;
mem->used = 0;
ram_end = ptr_to_mem(MEM_SIZE_ALIGNED);
ram_end->used = 1;
ram_end->next = MEM_SIZE_ALIGNED;
ram_end->prev = MEM_SIZE_ALIGNED;
MEM_SANITY();
lfree = (struct mem *)(void *)ram;
MEM_STATS_AVAIL(avail, MEM_SIZE_ALIGNED);
if (sys_mutex_new(&mem_mutex) != ERR_OK) {
LWIP_ASSERT("failed to create mem_mutex", 0);
}
}
|
ua1arn/hftrx
|
C++
| null | 69
|
/* Returns NULL if the task has no mm. Checks PF_KTHREAD (meaning this kernel workthread has transiently adopted a user mm with use_mm, to do its AIO) is not set and if so returns a reference to it, after bumping up the use count. User must release the mm via mmput() after use. Typically used by /proc and ptrace. */
|
struct mm_struct* get_task_mm(struct task_struct *task)
|
/* Returns NULL if the task has no mm. Checks PF_KTHREAD (meaning this kernel workthread has transiently adopted a user mm with use_mm, to do its AIO) is not set and if so returns a reference to it, after bumping up the use count. User must release the mm via mmput() after use. Typically used by /proc and ptrace. */
struct mm_struct* get_task_mm(struct task_struct *task)
|
{
struct mm_struct *mm;
task_lock(task);
mm = task->mm;
if (mm) {
if (task->flags & PF_KTHREAD)
mm = NULL;
else
atomic_inc(&mm->mm_users);
}
task_unlock(task);
return mm;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* g_value_take_param: (skip) @value: a valid #GValue of type G_TYPE_PARAM */
|
void g_value_take_param(GValue *value, GParamSpec *param)
|
/* g_value_take_param: (skip) @value: a valid #GValue of type G_TYPE_PARAM */
void g_value_take_param(GValue *value, GParamSpec *param)
|
{
g_return_if_fail (G_VALUE_HOLDS_PARAM (value));
if (param)
g_return_if_fail (G_IS_PARAM_SPEC (param));
if (value->data[0].v_pointer)
g_param_spec_unref (value->data[0].v_pointer);
value->data[0].v_pointer = param;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* If String is not NULL and not aligned on a 16-bit boundary, then ASSERT(). If FormatString is NULL, then ASSERT(). If FormatString is not aligned on a 16-bit boundary, then ASSERT(). */
|
CHAR16* EFIAPI CatSPrint(IN CHAR16 *String OPTIONAL, IN CONST CHAR16 *FormatString,...)
|
/* If String is not NULL and not aligned on a 16-bit boundary, then ASSERT(). If FormatString is NULL, then ASSERT(). If FormatString is not aligned on a 16-bit boundary, then ASSERT(). */
CHAR16* EFIAPI CatSPrint(IN CHAR16 *String OPTIONAL, IN CONST CHAR16 *FormatString,...)
|
{
VA_LIST Marker;
CHAR16 *NewString;
VA_START (Marker, FormatString);
NewString = CatVSPrint (String, FormatString, Marker);
VA_END (Marker);
return NewString;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* All APs execute this function in parallel. The BSP executes the function separately. */
|
STATIC VOID EFIAPI WriteFeatureControl(IN OUT VOID *WorkSpace)
|
/* All APs execute this function in parallel. The BSP executes the function separately. */
STATIC VOID EFIAPI WriteFeatureControl(IN OUT VOID *WorkSpace)
|
{
EFI_HOB_PLATFORM_INFO *PlatformInfoHob = WorkSpace;
if (TdIsEnabled ()) {
TdVmCall (
TDVMCALL_WRMSR,
(UINT64)MSR_IA32_FEATURE_CONTROL,
PlatformInfoHob->FeatureControlValue,
0,
0,
0
);
} else {
AsmWriteMsr64 (
MSR_IA32_FEATURE_CONTROL,
PlatformInfoHob->FeatureControlValue
);
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Search the environment for a variable. Return the value, if found, or NULL, if not found. */
|
char* fw_getenv(char *name)
|
/* Search the environment for a variable. Return the value, if found, or NULL, if not found. */
char* fw_getenv(char *name)
|
{
char *env, *nxt;
if (fw_env_open())
return NULL;
for (env = environment.data; *env; env = nxt + 1) {
char *val;
for (nxt = env; *nxt; ++nxt) {
if (nxt >= &environment.data[ENV_SIZE]) {
fprintf (stderr, "## Error: "
"environment not terminated\n");
return NULL;
}
}
val = envmatch (name, env);
if (!val)
continue;
return val;
}
return NULL;
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* Get a Message or Wait for a Message from a Queue. */
|
os_InRegs osEvent_type svcMessageGet(osMessageQId queue_id, uint32_t millisec)
|
/* Get a Message or Wait for a Message from a Queue. */
os_InRegs osEvent_type svcMessageGet(osMessageQId queue_id, uint32_t millisec)
|
{
ret.status = osErrorParameter;
return osEvent_ret_status;
}
if (((P_MCB)queue_id)->cb_type != MCB) {
ret.status = osErrorParameter;
return osEvent_ret_status;
}
res = rt_mbx_wait(queue_id, &ret.value.p, rt_ms2tick(millisec));
if (res == OS_R_TMO) {
ret.status = millisec ? osEventTimeout : osOK;
return osEvent_ret_value;
}
ret.status = osEventMessage;
return osEvent_ret_value;
}
|
ajhc/demo-cortex-m3
|
C++
| null | 38
|
/* Reads and returns the current value of MM6. This function is only available on IA-32 and x64. */
|
UINT64 EFIAPI AsmReadMm6(VOID)
|
/* Reads and returns the current value of MM6. This function is only available on IA-32 and x64. */
UINT64 EFIAPI AsmReadMm6(VOID)
|
{
_asm {
push eax
push eax
movq [esp], mm6
pop eax
pop edx
emms
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This function returns the current value of the SysTick counter, which is a value between the period - 1 and zero, inclusive. */
|
uint32_t SysTickValueGet(void)
|
/* This function returns the current value of the SysTick counter, which is a value between the period - 1 and zero, inclusive. */
uint32_t SysTickValueGet(void)
|
{
return(HWREG(NVIC_ST_CURRENT));
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* Check WDT status flag. This function checks whether special flag is set or not. */
|
xtBoolean WDTStatusFlagCheck(unsigned long ulFlags)
|
/* Check WDT status flag. This function checks whether special flag is set or not. */
xtBoolean WDTStatusFlagCheck(unsigned long ulFlags)
|
{
xASSERT((ulFlags == WDT_FLAG_TIMEOUT) ||
(ulFlags == WDT_FLAG_INT ) ||
(ulFlags == (WDT_FLAG_TIMEOUT | WDT_FLAG_INT))
);
if( xHWREG(WDT_BASE + WDT_MOD) & ulFlags )
{
return (xtrue);
}
else
{
return (xfalse);
}
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Returns 0 if kobject_uevent() is completed with success or the corresponding error when it fails. */
|
int kobject_uevent(struct kobject *kobj, enum kobject_action action)
|
/* Returns 0 if kobject_uevent() is completed with success or the corresponding error when it fails. */
int kobject_uevent(struct kobject *kobj, enum kobject_action action)
|
{
return kobject_uevent_env(kobj, action, NULL);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Returns BAR position in config space, or 0 if the BAR is invalid. */
|
int pci_resource_bar(struct pci_dev *dev, int resno, enum pci_bar_type *type)
|
/* Returns BAR position in config space, or 0 if the BAR is invalid. */
int pci_resource_bar(struct pci_dev *dev, int resno, enum pci_bar_type *type)
|
{
int reg;
if (resno < PCI_ROM_RESOURCE) {
*type = pci_bar_unknown;
return PCI_BASE_ADDRESS_0 + 4 * resno;
} else if (resno == PCI_ROM_RESOURCE) {
*type = pci_bar_mem32;
return dev->rom_base_reg;
} else if (resno < PCI_BRIDGE_RESOURCES) {
reg = pci_iov_resource_bar(dev, resno, type);
if (reg)
return reg;
}
dev_err(&dev->dev, "BAR %d: invalid resource\n", resno);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Set GPIO Output Options.
When the pin is set to output mode, this sets the configuration (analog/digital and open drain/push pull) and speed, for a set of GPIO pins on a given GPIO port. */
|
void gpio_set_output_options(uint32_t gpioport, uint8_t otype, uint8_t speed, uint16_t gpios)
|
/* Set GPIO Output Options.
When the pin is set to output mode, this sets the configuration (analog/digital and open drain/push pull) and speed, for a set of GPIO pins on a given GPIO port. */
void gpio_set_output_options(uint32_t gpioport, uint8_t otype, uint8_t speed, uint16_t gpios)
|
{
uint16_t i;
uint32_t ospeedr;
if (otype == 0x1) {
GPIO_OTYPER(gpioport) |= gpios;
} else {
GPIO_OTYPER(gpioport) &= ~gpios;
}
ospeedr = GPIO_OSPEEDR(gpioport);
for (i = 0; i < 16; i++) {
if (!((1 << i) & gpios)) {
continue;
}
ospeedr &= ~GPIO_OSPEED_MASK(i);
ospeedr |= GPIO_OSPEED(i, speed);
}
GPIO_OSPEEDR(gpioport) = ospeedr;
}
|
insane-adding-machines/unicore-mx
|
C++
|
GNU General Public License v3.0
| 50
|
/* SM_NOTIFY: private callback from statd (not part of official NLM proto) */
|
static __be32 nlmsvc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp, void *resp)
|
/* SM_NOTIFY: private callback from statd (not part of official NLM proto) */
static __be32 nlmsvc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp, void *resp)
|
{
dprintk("lockd: SM_NOTIFY called\n");
if (!nlm_privileged_requester(rqstp)) {
char buf[RPC_MAX_ADDRBUFLEN];
printk(KERN_WARNING "lockd: rejected NSM callback from %s\n",
svc_print_addr(rqstp, buf, sizeof(buf)));
return rpc_system_err;
}
nlm_host_rebooted(argp);
return rpc_success;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* The temporary buffer (t) must have room for at least 4 integers of the size of p. */
|
static uint32_t invert_pubexp(uint16_t *d, const uint16_t *m, uint32_t e, uint16_t *t)
|
/* The temporary buffer (t) must have room for at least 4 integers of the size of p. */
static uint32_t invert_pubexp(uint16_t *d, const uint16_t *m, uint32_t e, uint16_t *t)
|
{
uint16_t *f;
uint32_t r;
f = t;
t += 1 + ((m[0] + 15) >> 4);
br_i15_zero(d, m[0]);
d[1] = 1;
br_i15_zero(f, m[0]);
f[1] = e & 0x7FFF;
f[2] = (e >> 15) & 0x7FFF;
f[3] = e >> 30;
r = br_i15_moddiv(d, f, m, br_i15_ninv15(m[1]), t);
br_i15_add(d, m, (uint32_t)(1 - (d[1] & 1)));
return r;
}
|
arendst/Tasmota
|
C++
|
GNU General Public License v3.0
| 21,318
|
/* Notifies the USB connection bus events to the device stack */
|
sl_status_t sli_usbd_core_connect_event(void)
|
/* Notifies the USB connection bus events to the device stack */
sl_status_t sli_usbd_core_connect_event(void)
|
{
usbd_core_set_event(SLI_USBD_EVENT_BUS_CONNECT);
return SL_STATUS_OK;
}
|
nanoframework/nf-interpreter
|
C++
|
MIT License
| 293
|
/* SPI MSP De-Initialization This function freeze the hardware resources used in this example. */
|
void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi)
|
/* SPI MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi)
|
{
if(hspi->Instance==SPI1)
{
__HAL_RCC_SPI1_CLK_DISABLE();
HAL_GPIO_DeInit(GPIOA, SPI1_SCK_Pin|SPI1_MISO_Pin|SPI1_MOSI_Pin);
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* wait the command done function and check error status */
|
static status_t SDIF_WaitCommandDone(SDIF_Type *base, sdif_command_t *command)
|
/* wait the command done function and check error status */
static status_t SDIF_WaitCommandDone(SDIF_Type *base, sdif_command_t *command)
|
{
uint32_t status = 0U;
uint32_t errorStatus = (uint32_t)kSDIF_ResponseError | (uint32_t)kSDIF_ResponseTimeout |
(uint32_t)kSDIF_DataStartBitError | (uint32_t)kSDIF_HardwareLockError |
(uint32_t)kSDIF_ResponseCRCError;
do
{
status = SDIF_GetInterruptStatus(base);
} while ((status & (errorStatus | (uint32_t)kSDIF_CommandDone)) == 0UL);
SDIF_ClearInterruptStatus(base, status & (uint32_t)kSDIF_CommandTransferStatus);
if ((status & errorStatus) != 0UL)
{
return kStatus_SDIF_SendCmdFail;
}
else
{
return SDIF_ReadCommandResponse(base, command);
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Notes: This routine assumes no locks are held on entry. */
|
struct fc_vport* fc_vport_create(struct Scsi_Host *shost, int channel, struct fc_vport_identifiers *ids)
|
/* Notes: This routine assumes no locks are held on entry. */
struct fc_vport* fc_vport_create(struct Scsi_Host *shost, int channel, struct fc_vport_identifiers *ids)
|
{
int stat;
struct fc_vport *vport;
stat = fc_vport_setup(shost, channel, &shost->shost_gendev,
ids, &vport);
return stat ? NULL : vport;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* NVIC Return Pending Interrupt.
True if the interrupt has occurred and is waiting for service. */
|
uint8_t nvic_get_pending_irq(uint8_t irqn)
|
/* NVIC Return Pending Interrupt.
True if the interrupt has occurred and is waiting for service. */
uint8_t nvic_get_pending_irq(uint8_t irqn)
|
{
return NVIC_ISPR(irqn / 32) & (1 << (irqn % 32)) ? 1 : 0;
}
|
insane-adding-machines/unicore-mx
|
C++
|
GNU General Public License v3.0
| 50
|
/* Derive SHA384 HMAC-based Expand Key Derivation Function (HKDF). */
|
BOOLEAN EFIAPI HkdfSha384Expand(IN CONST UINT8 *Prk, IN UINTN PrkSize, IN CONST UINT8 *Info, IN UINTN InfoSize, OUT UINT8 *Out, IN UINTN OutSize)
|
/* Derive SHA384 HMAC-based Expand Key Derivation Function (HKDF). */
BOOLEAN EFIAPI HkdfSha384Expand(IN CONST UINT8 *Prk, IN UINTN PrkSize, IN CONST UINT8 *Info, IN UINTN InfoSize, OUT UINT8 *Out, IN UINTN OutSize)
|
{
return HkdfMdExpand (MBEDTLS_MD_SHA384, Prk, PrkSize, Info, InfoSize, Out, OutSize);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Initialize the header of the specified tccb by resetting all values to zero and filling in defaults for format, sac and initial tcal fields. */
|
void tccb_init(struct tccb *tccb, size_t size, u32 sac)
|
/* Initialize the header of the specified tccb by resetting all values to zero and filling in defaults for format, sac and initial tcal fields. */
void tccb_init(struct tccb *tccb, size_t size, u32 sac)
|
{
memset(tccb, 0, size);
tccb->tcah.format = TCCB_FORMAT_DEFAULT;
tccb->tcah.sac = sac;
tccb->tcah.tcal = 12;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Ensure that whatever was written thru printk is displayed now */
|
void posix_flush_stdout(void)
|
/* Ensure that whatever was written thru printk is displayed now */
void posix_flush_stdout(void)
|
{
if (n_pend) {
stdout_buff[n_pend] = 0;
posix_print_trace("%s", stdout_buff);
n_pend = 0;
stdout_buff[0] = 0;
}
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Blink the led's which are set to be on. */
|
s32 igb_blink_led(struct e1000_hw *hw)
|
/* Blink the led's which are set to be on. */
s32 igb_blink_led(struct e1000_hw *hw)
|
{
u32 ledctl_blink = 0;
u32 i;
ledctl_blink = hw->mac.ledctl_mode2;
for (i = 0; i < 4; i++)
if (((hw->mac.ledctl_mode2 >> (i * 8)) & 0xFF) ==
E1000_LEDCTL_MODE_LED_ON)
ledctl_blink |= (E1000_LEDCTL_LED0_BLINK <<
(i * 8));
wr32(E1000_LEDCTL, ledctl_blink);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Writes a 29-bit extended id filter element in the Message RAM. Size of an Extended Id filter element is 2 words. So 2 words are written into the Message RAM for each filter element. */
|
void CANFD_SetXIDFltr(CANFD_T *psCanfd, uint32_t u32FltrIdx, uint32_t u32FilterLow, uint32_t u32FilterHigh)
|
/* Writes a 29-bit extended id filter element in the Message RAM. Size of an Extended Id filter element is 2 words. So 2 words are written into the Message RAM for each filter element. */
void CANFD_SetXIDFltr(CANFD_T *psCanfd, uint32_t u32FltrIdx, uint32_t u32FilterLow, uint32_t u32FilterHigh)
|
{
CANFD_EXT_FILTER_T *psFilter;
if (u32FltrIdx >= CANFD_MAX_29_BIT_FTR_ELEMS) return;
psFilter = (CANFD_EXT_FILTER_T *)(CANFD_SRAM_BASE_ADDR(psCanfd) + (psCanfd->XIDFC & CANFD_XIDFC_FLESA_Msk) + (u32FltrIdx * sizeof(CANFD_EXT_FILTER_T)));
psFilter->LOWVALUE = u32FilterLow;
psFilter->HIGHVALUE = u32FilterHigh;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* disable msi interrupt if enabled, and clear the flag. flag is used primarily for the fallback to INTx, but is also used in reinit after reset as a flag. */
|
static void ipath_7220_nomsi(struct ipath_devdata *dd)
|
/* disable msi interrupt if enabled, and clear the flag. flag is used primarily for the fallback to INTx, but is also used in reinit after reset as a flag. */
static void ipath_7220_nomsi(struct ipath_devdata *dd)
|
{
dd->ipath_msi_lo = 0;
if (ipath_msi_enabled(dd->pcidev)) {
if (dd->ipath_irq)
free_irq(dd->ipath_irq, dd);
pci_disable_msi(dd->pcidev);
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Forces the output 4 waveform to active or inactive level. */
|
void TMR_ConfigForcedOC4(TMR_T *tmr, TMR_FORCED_ACTION_T forcesAction)
|
/* Forces the output 4 waveform to active or inactive level. */
void TMR_ConfigForcedOC4(TMR_T *tmr, TMR_FORCED_ACTION_T forcesAction)
|
{
tmr->CCM2_COMPARE_B.OC4MOD = forcesAction;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Determine if a directory has no files in it. */
|
BOOLEAN IsDirectoryEmpty(IN SHELL_FILE_HANDLE FileHandle)
|
/* Determine if a directory has no files in it. */
BOOLEAN IsDirectoryEmpty(IN SHELL_FILE_HANDLE FileHandle)
|
{
EFI_STATUS Status;
EFI_FILE_INFO *FileInfo;
BOOLEAN NoFile;
BOOLEAN RetVal;
RetVal = TRUE;
NoFile = FALSE;
FileInfo = NULL;
for (Status = FileHandleFindFirstFile (FileHandle, &FileInfo)
; !NoFile && !EFI_ERROR (Status)
; FileHandleFindNextFile (FileHandle, FileInfo, &NoFile)
)
{
if ( (StrStr (FileInfo->FileName, L".") != FileInfo->FileName)
&& (StrStr (FileInfo->FileName, L"..") != FileInfo->FileName))
{
RetVal = FALSE;
}
}
return (RetVal);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* stm32_copro_device_to_virt() - Convert device address to virtual address @dev: corresponding STM32 remote processor device @da: device address @size: Size of the memory region @da is pointing to */
|
static void* stm32_copro_device_to_virt(struct udevice *dev, ulong da, ulong size)
|
/* stm32_copro_device_to_virt() - Convert device address to virtual address @dev: corresponding STM32 remote processor device @da: device address @size: Size of the memory region @da is pointing to */
static void* stm32_copro_device_to_virt(struct udevice *dev, ulong da, ulong size)
|
{
fdt32_t in_addr = cpu_to_be32(da), end_addr;
u64 paddr;
paddr = dev_translate_dma_address(dev, &in_addr);
if (paddr == OF_BAD_ADDR) {
dev_err(dev, "Unable to convert address %ld\n", da);
return NULL;
}
end_addr = cpu_to_be32(da + size - 1);
if (dev_translate_dma_address(dev, &end_addr) == OF_BAD_ADDR) {
dev_err(dev, "Unable to convert address %ld\n", da + size - 1);
return NULL;
}
return phys_to_virt(paddr);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Unregister a SDIO function with the driver model, and (eventually) free it. This function can be called through error paths where sdio_add_func() was never executed (because a failure occurred at an earlier point). */
|
void sdio_remove_func(struct sdio_func *func)
|
/* Unregister a SDIO function with the driver model, and (eventually) free it. This function can be called through error paths where sdio_add_func() was never executed (because a failure occurred at an earlier point). */
void sdio_remove_func(struct sdio_func *func)
|
{
if (!sdio_func_present(func))
return;
device_del(&func->dev);
put_device(&func->dev);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Map Alternate Function Port Bits (Main Set)
The AFIO remapping feature is used only with the STM32F10x series. */
|
void gpio_primary_remap(uint32_t swjdisable, uint32_t maps)
|
/* Map Alternate Function Port Bits (Main Set)
The AFIO remapping feature is used only with the STM32F10x series. */
void gpio_primary_remap(uint32_t swjdisable, uint32_t maps)
|
{
uint32_t reg = AFIO_MAPR & ~AFIO_MAPR_SWJ_MASK;
AFIO_MAPR = reg | swjdisable | maps;
}
|
insane-adding-machines/unicore-mx
|
C++
|
GNU General Public License v3.0
| 50
|
/* If Hot Plug is supported by the platform, call PCI Hot Plug Init protocol to get PCI Hot Plug controller's information and constructor the root hot plug private data structure. */
|
EFI_STATUS InitializeHotPlugSupport(VOID)
|
/* If Hot Plug is supported by the platform, call PCI Hot Plug Init protocol to get PCI Hot Plug controller's information and constructor the root hot plug private data structure. */
EFI_STATUS InitializeHotPlugSupport(VOID)
|
{
EFI_STATUS Status;
EFI_HPC_LOCATION *HpcList;
UINTN HpcCount;
Status = gBS->LocateProtocol (
&gEfiPciHotPlugInitProtocolGuid,
NULL,
(VOID **)&gPciHotPlugInit
);
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
Status = gPciHotPlugInit->GetRootHpcList (
gPciHotPlugInit,
&HpcCount,
&HpcList
);
if (!EFI_ERROR (Status)) {
gPciRootHpcPool = HpcList;
gPciRootHpcCount = HpcCount;
gPciRootHpcData = AllocateZeroPool (sizeof (ROOT_HPC_DATA) * gPciRootHpcCount);
if (gPciRootHpcData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
}
return EFI_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Deinitializes OPAMP peripheral registers to their default reset values. */
|
void OPAMP_DeInit(uint32_t OPAMP_Selection)
|
/* Deinitializes OPAMP peripheral registers to their default reset values. */
void OPAMP_DeInit(uint32_t OPAMP_Selection)
|
{
*(__IO uint32_t *) (OPAMP_BASE + OPAMP_Selection) = ((uint32_t)0x00000000);
}
|
ajhc/demo-cortex-m3
|
C++
| null | 38
|
/* Register fully available low RAM pages with the bootmem allocator. */
|
static void __init register_bootmem_low_pages(void)
|
/* Register fully available low RAM pages with the bootmem allocator. */
static void __init register_bootmem_low_pages(void)
|
{
unsigned long curr_pfn, last_pfn, pages;
curr_pfn = PFN_UP(__MEMORY_START);
last_pfn = PFN_DOWN(__pa(memory_end));
if (last_pfn > max_low_pfn)
last_pfn = max_low_pfn;
pages = last_pfn - curr_pfn;
free_bootmem(PFN_PHYS(curr_pfn), PFN_PHYS(pages));
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Intialize the memory interface of the IAP API. */
|
status_t MEM_Init(api_core_context_t *coreCtx)
|
/* Intialize the memory interface of the IAP API. */
status_t MEM_Init(api_core_context_t *coreCtx)
|
{
assert(API_INTERFACE);
return API_INTERFACE->mem_init(coreCtx);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* USB Device Remote Wakeup Function Called automatically on USB Device Remote Wakeup Return Value: None */
|
void USBD_WakeUp(void)
|
/* USB Device Remote Wakeup Function Called automatically on USB Device Remote Wakeup Return Value: None */
void USBD_WakeUp(void)
|
{
SYSCON->USB1NEEDCLKCTRL = SYSCON_USB1NEEDCLKCTRL_AP_HS_DEV_NEEDCLK_MASK;
USBHSD->DEVCMDSTAT &= ~USBHSD_DEVCMDSTAT_DSUS_MASK;
while (USBHSD->DEVCMDSTAT & USBHSD_DEVCMDSTAT_DSUS_MASK);
SYSCON->USB1NEEDCLKCTRL = 0;
}
|
ARMmbed/DAPLink
|
C++
|
Apache License 2.0
| 2,140
|
/* Given a string of the form "<recent name>:<recent value>", as might appear as an argument to a "-o" option, parse it and set the recent value in question. Return an indication of whether it succeeded or failed in some fashion. */
|
int recent_set_arg(char *prefarg)
|
/* Given a string of the form "<recent name>:<recent value>", as might appear as an argument to a "-o" option, parse it and set the recent value in question. Return an indication of whether it succeeded or failed in some fashion. */
int recent_set_arg(char *prefarg)
|
{
gchar *p, *colonp;
int ret;
colonp = strchr(prefarg, ':');
if (colonp == NULL)
return PREFS_SET_SYNTAX_ERR;
p = colonp;
*p++ = '\0';
while (g_ascii_isspace(*p))
p++;
if (*p == '\0') {
*colonp = ':';
return PREFS_SET_SYNTAX_ERR;
}
ret = read_set_recent_pair_static(prefarg, p, NULL, TRUE);
*colonp = ':';
return ret;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Return value: number of bytes printed to buffer */
|
static ssize_t ipr_show_log_level(struct device *dev, struct device_attribute *attr, char *buf)
|
/* Return value: number of bytes printed to buffer */
static ssize_t ipr_show_log_level(struct device *dev, struct device_attribute *attr, char *buf)
|
{
struct Scsi_Host *shost = class_to_shost(dev);
struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
unsigned long lock_flags = 0;
int len;
spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
len = snprintf(buf, PAGE_SIZE, "%d\n", ioa_cfg->log_level);
spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
return len;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Clear the GO_BUSY bit to stop a SPI data transfer. */
|
void SPIBitGoBusyClear(unsigned long ulBase)
|
/* Clear the GO_BUSY bit to stop a SPI data transfer. */
void SPIBitGoBusyClear(unsigned long ulBase)
|
{
xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)||
(ulBase == SPI2_BASE) );
xHWREG(ulBase + SPI_CNTRL) &= ~SPI_CNTRL_GO_BUSY;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Open LIN mode on the specified UART.
The */
|
void UARTLINConfig(unsigned long ulBase, unsigned long ulBaud, unsigned long ulConfig)
|
/* Open LIN mode on the specified UART.
The */
void UARTLINConfig(unsigned long ulBase, unsigned long ulBaud, unsigned long ulConfig)
|
{
xASSERT(UARTBaseValid(ulBase));
xASSERT(((ulConfig & UART_CONFIG_BKFL_MASK) ==UART_CONFIG_BKFL_10) ||
((ulConfig & UART_CONFIG_BKFL_MASK) ==UART_CONFIG_BKFL_11));
UARTConfigSet(ulBase, ulBaud,
UART_CONFIG_WLEN_8 |
UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE);
UARTEnableLIN(ulBase);
xHWREG(ulBase + USART_CR2) &= ~UART_CONFIG_BKFL_11;
xHWREG(ulBase + USART_CR2) = (ulConfig);
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* If Address > 0x0FFFFFFF, then ASSERT(). If StartBit is greater than 7, then ASSERT(). If EndBit is greater than 7, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). */
|
UINT8 EFIAPI PciBitFieldRead8(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit)
|
/* If Address > 0x0FFFFFFF, then ASSERT(). If StartBit is greater than 7, then ASSERT(). If EndBit is greater than 7, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). */
UINT8 EFIAPI PciBitFieldRead8(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit)
|
{
return PciExpressBitFieldRead8 (Address, StartBit, EndBit);
}
|
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.