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
|
|---|---|---|---|---|---|---|---|
/* ide_fixstring() cleans up and (optionally) byte-swaps a text string, removing leading/trailing blanks and compressing internal blanks. It is primarily used to tidy up the model name/number fields as returned by the ATA_CMD_ID_ATA commands. */
|
void ide_fixstring(u8 *s, const int bytecount, const int byteswap)
|
/* ide_fixstring() cleans up and (optionally) byte-swaps a text string, removing leading/trailing blanks and compressing internal blanks. It is primarily used to tidy up the model name/number fields as returned by the ATA_CMD_ID_ATA commands. */
void ide_fixstring(u8 *s, const int bytecount, const int byteswap)
|
{
u8 *p, *end = &s[bytecount & ~1];
if (byteswap) {
for (p = s ; p != end ; p += 2)
be16_to_cpus((u16 *) p);
}
p = s;
while (s != end && *s == ' ')
++s;
while (s != end && *s) {
if (*s++ != ' ' || (s != end && *s && *s != ' '))
*p++ = *(s-1);
}
while (p != end)
*p++ = '\0';
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* zero_data_node_unused - zero out unused fields of an on-flash data node. @data: the data node to zero out */
|
static void zero_data_node_unused(struct ubifs_data_node *data)
|
/* zero_data_node_unused - zero out unused fields of an on-flash data node. @data: the data node to zero out */
static void zero_data_node_unused(struct ubifs_data_node *data)
|
{
memset(data->padding, 0, 2);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Reads NumberOfBytes data bytes from a serial device into the buffer specified by Buffer. The number of bytes actually read is returned. If the return value is less than NumberOfBytes, then the rest operation failed. If Buffer is NULL, then ASSERT(). If NumberOfBytes is zero, then return 0. */
|
UINTN EFIAPI SerialPortRead(OUT UINT8 *Buffer, IN UINTN NumberOfBytes)
|
/* Reads NumberOfBytes data bytes from a serial device into the buffer specified by Buffer. The number of bytes actually read is returned. If the return value is less than NumberOfBytes, then the rest operation failed. If Buffer is NULL, then ASSERT(). If NumberOfBytes is zero, then return 0. */
UINTN EFIAPI SerialPortRead(OUT UINT8 *Buffer, IN UINTN NumberOfBytes)
|
{
return gEmuThunk->ReadStdIn (Buffer, NumberOfBytes);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* param base ENET peripheral base address. param phyAddr The PHY address. param device The PHY device type. param phyReg The PHY register address. param data The data written to PHY. */
|
void ENET_QOS_StartExtC45SMIWrite(ENET_QOS_Type *base, uint32_t phyAddr, uint32_t device, uint32_t phyReg, uint32_t data)
|
/* param base ENET peripheral base address. param phyAddr The PHY address. param device The PHY device type. param phyReg The PHY register address. param data The data written to PHY. */
void ENET_QOS_StartExtC45SMIWrite(ENET_QOS_Type *base, uint32_t phyAddr, uint32_t device, uint32_t phyReg, uint32_t data)
|
{
uint32_t reg = base->MAC_MDIO_ADDRESS & ENET_QOS_MAC_MDIO_ADDRESS_CR_MASK;
base->MAC_MDIO_ADDRESS = reg | ENET_QOS_MAC_MDIO_ADDRESS_C45E_MASK | (uint32_t)kENET_QOS_MiiWriteFrame |
ENET_QOS_MAC_MDIO_ADDRESS_PA(phyAddr) | ENET_QOS_MAC_MDIO_ADDRESS_RDA(device);
base->MAC_MDIO_DATA = data | ENET_QOS_MAC_MDIO_DATA_RA(phyReg);
base->MAC_MDIO_ADDRESS |= ENET_QOS_MAC_MDIO_ADDRESS_GB_MASK;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Set the I/O transfer over the ISA bus to 8-bit mode */
|
static void wv_16_off(unsigned long ioaddr, u16 hacr)
|
/* Set the I/O transfer over the ISA bus to 8-bit mode */
static void wv_16_off(unsigned long ioaddr, u16 hacr)
|
{
hacr &= ~HACR_16BITS;
hacr_write(ioaddr, hacr);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Registers an interrupt handler for the specified PWM generator block. */
|
void PWMGenIntRegister(unsigned long ulBase, unsigned long ulGen, void(*pfnIntHandler)(void))
|
/* Registers an interrupt handler for the specified PWM generator block. */
void PWMGenIntRegister(unsigned long ulBase, unsigned long ulGen, void(*pfnIntHandler)(void))
|
{
unsigned long ulInt;
ASSERT((ulBase == PWM0_BASE) || (ulBase == PWM1_BASE));
ASSERT(PWMGenValid(ulGen));
ulInt = PWMGenIntGet(ulBase, ulGen);
IntRegister(ulInt, pfnIntHandler);
IntEnable(ulInt);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Clocks out one byte data via I2C data/clock */
|
static s32 ixgbe_clock_out_i2c_byte(struct ixgbe_hw *hw, u8 data)
|
/* Clocks out one byte data via I2C data/clock */
static s32 ixgbe_clock_out_i2c_byte(struct ixgbe_hw *hw, u8 data)
|
{
s32 status = 0;
s32 i;
u32 i2cctl;
bool bit = 0;
for (i = 7; i >= 0; i--) {
bit = (data >> i) & 0x1;
status = ixgbe_clock_out_i2c_bit(hw, bit);
if (status != 0)
break;
}
i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL);
i2cctl |= IXGBE_I2C_DATA_OUT;
IXGBE_WRITE_REG(hw, IXGBE_I2CCTL, i2cctl);
return status;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Enable a UFS bus driver to access UFS MMIO registers in the UFS Host Controller memory space. */
|
EFI_STATUS EFIAPI UfsHcMmioRead(IN EDKII_UFS_HOST_CONTROLLER_PROTOCOL *This, IN EDKII_UFS_HOST_CONTROLLER_PROTOCOL_WIDTH Width, IN UINT64 Offset, IN UINTN Count, IN OUT VOID *Buffer)
|
/* Enable a UFS bus driver to access UFS MMIO registers in the UFS Host Controller memory space. */
EFI_STATUS EFIAPI UfsHcMmioRead(IN EDKII_UFS_HOST_CONTROLLER_PROTOCOL *This, IN EDKII_UFS_HOST_CONTROLLER_PROTOCOL_WIDTH Width, IN UINT64 Offset, IN UINTN Count, IN OUT VOID *Buffer)
|
{
UFS_HOST_CONTROLLER_PRIVATE_DATA *Private;
EFI_PCI_IO_PROTOCOL *PciIo;
EFI_STATUS Status;
UINT8 BarIndex;
Private = UFS_HOST_CONTROLLER_PRIVATE_DATA_FROM_UFSHC (This);
PciIo = Private->PciIo;
BarIndex = Private->BarIndex;
Status = PciIo->Mem.Read (PciIo, (EFI_PCI_IO_PROTOCOL_WIDTH)Width, BarIndex, Offset, Count, Buffer);
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This PDC call will erase all contents of Stable Storage. Use with care! */
|
int pdc_stable_initialize(void)
|
/* This PDC call will erase all contents of Stable Storage. Use with care! */
int pdc_stable_initialize(void)
|
{
int retval;
unsigned long flags;
spin_lock_irqsave(&pdc_lock, flags);
retval = mem_pdc_call(PDC_STABLE, PDC_STABLE_INITIALIZE);
spin_unlock_irqrestore(&pdc_lock, flags);
return retval;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* This function will do USB_REQ_GET_STATUS request for the device instance to get usb hub status. */
|
rt_err_t rt_usb_hub_get_status(uinst_t uinst, rt_uint8_t *buffer)
|
/* This function will do USB_REQ_GET_STATUS request for the device instance to get usb hub status. */
rt_err_t rt_usb_hub_get_status(uinst_t uinst, rt_uint8_t *buffer)
|
{
struct ureqest setup;
int timeout = 100;
int length = 4;
RT_ASSERT(uinst != RT_NULL);
setup.request_type = USB_REQ_TYPE_DIR_IN | USB_REQ_TYPE_CLASS |
USB_REQ_TYPE_DEVICE;
setup.request = USB_REQ_GET_STATUS;
setup.index = 0;
setup.length = length;
setup.value = 0;
if(rt_usb_hcd_control_xfer(uinst->hcd, uinst, &setup, buffer, length,
timeout) == length) return RT_EOK;
else return -RT_FALSE;
}
|
armink/FreeModbus_Slave-Master-RTT-STM32
|
C++
|
Other
| 1,477
|
/* Initialise the task handle callback for a given priority. */
|
static int task_init_handler(void)
|
/* Initialise the task handle callback for a given priority. */
static int task_init_handler(void)
|
{
TQB.task_Q[p] = (os_event_t *) malloc( sizeof(os_event_t)*qlen );
if (TQB.task_Q[p]) {
os_memset(TQB.task_Q[p], 0, sizeof(os_event_t)*qlen);
system_os_task(platform_task_dispatch, p, TQB.task_Q[p], TASK_DEFAULT_QUEUE_LEN);
} else {
NODE_DBG ( "Malloc failure in platform_task_init_handler" );
return PLATFORM_ERR;
}
}
}
|
nodemcu/nodemcu-firmware
|
C++
|
MIT License
| 7,566
|
/* Delete a Mutex that was created by osMutexCreate. */
|
osStatus osMutexDelete(osMutexId mutex_id)
|
/* Delete a Mutex that was created by osMutexCreate. */
osStatus osMutexDelete(osMutexId mutex_id)
|
{
struct k_mutex *mutex = (struct k_mutex *) mutex_id;
if (mutex_id == NULL) {
return osErrorParameter;
}
if (k_is_in_isr()) {
return osErrorISR;
}
k_mem_slab_free(&cmsis_mutex_slab, (void *)mutex);
return osOK;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" documentation) by the application code so that the address and size of a requested descriptor can be given to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the USB host. */
|
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint16_t wIndex, const void **const DescriptorAddress)
|
/* This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" documentation) by the application code so that the address and size of a requested descriptor can be given to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the USB host. */
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint16_t wIndex, const void **const DescriptorAddress)
|
{
return AVRISP_GetDescriptor(wValue, wIndex, DescriptorAddress);
}
|
prusa3d/Prusa-Firmware-Buddy
|
C++
|
Other
| 1,019
|
/* Enables Receive Own bit (Only in Half Duplex Mode). When enaled GMAC receives all the packets given by phy while transmitting. */
|
void synopGMAC_rx_own_enable(synopGMACdevice *gmacdev)
|
/* Enables Receive Own bit (Only in Half Duplex Mode). When enaled GMAC receives all the packets given by phy while transmitting. */
void synopGMAC_rx_own_enable(synopGMACdevice *gmacdev)
|
{
synopGMACClearBits(gmacdev -> MacBase, GmacConfig, GmacRxOwn);
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 >= mDxeRuntimePciExpressLibPciExpressBaseSize) {
return (UINT32)-1;
}
return MmioWrite32 (GetPciExpressAddress (Address), Value);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Queue an RCU-sched callback for invocation after a grace period. */
|
void call_rcu_sched(struct rcu_head *head, void(*func)(struct rcu_head *rcu))
|
/* Queue an RCU-sched callback for invocation after a grace period. */
void call_rcu_sched(struct rcu_head *head, void(*func)(struct rcu_head *rcu))
|
{
__call_rcu(head, func, &rcu_sched_state);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Transforms a 24bpp pixel data into an RGB565 pixel. */
|
static uint16_t colorTransform24ToRGB565(uint8_t red, uint8_t green, uint8_t blue)
|
/* Transforms a 24bpp pixel data into an RGB565 pixel. */
static uint16_t colorTransform24ToRGB565(uint8_t red, uint8_t green, uint8_t blue)
|
{
red = red >> 3;
green = green >> 2;
blue = blue >> 3;
return (red << 11) | (green << 5) | blue;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Draw filled rectangle of RGBA color with alpha blending. */
|
int filledRectAlpha(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color)
|
/* Draw filled rectangle of RGBA color with alpha blending. */
int filledRectAlpha(SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color)
|
{
Uint8 alpha;
Uint32 mcolor;
int result = 0;
if (SDL_MUSTLOCK(dst)) {
if (SDL_LockSurface(dst) < 0) {
return (-1);
}
}
alpha = color & 0x000000ff;
mcolor =
SDL_MapRGBA(dst->format, (color & 0xff000000) >> 24,
(color & 0x00ff0000) >> 16, (color & 0x0000ff00) >> 8, alpha);
result = _filledRectAlpha(dst, x1, y1, x2, y2, mcolor, alpha);
if (SDL_MUSTLOCK(dst)) {
SDL_UnlockSurface(dst);
}
return (result);
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* sets the given MpegEncContext to defaults for encoding. the changed fields will not depend upon the prior state of the MpegEncContext. */
|
static void MPV_encode_defaults(MpegEncContext *s)
|
/* sets the given MpegEncContext to defaults for encoding. the changed fields will not depend upon the prior state of the MpegEncContext. */
static void MPV_encode_defaults(MpegEncContext *s)
|
{
default_fcode_tab[i + MAX_MV]= 1;
}
s->me.mv_penalty= default_mv_penalty;
s->fcode_tab= default_fcode_tab;
}
|
DC-SWAT/DreamShell
|
C++
| null | 404
|
/* This function enables and puts the MCU in sleep mode. */
|
static fsp_err_t lpm_mode_enter(uint8_t lpm_mode, lpm_instance_ctrl_t *const p_current_ctrl)
|
/* This function enables and puts the MCU in sleep mode. */
static fsp_err_t lpm_mode_enter(uint8_t lpm_mode, lpm_instance_ctrl_t *const p_current_ctrl)
|
{
fsp_err_t err = FSP_SUCCESS;
switch (lpm_mode)
{
case SW_STANDBY_STATE:
err = R_LPM_LowPowerModeEnter(p_current_ctrl);
break;
case SLEEP_STATE:
err = R_LPM_LowPowerModeEnter(p_current_ctrl);
break;
case SW_STANDBY_SNOOZE_STATE:
err = R_LPM_LowPowerModeEnter(p_current_ctrl);
break;
default:
err = FSP_ERR_INVALID_MODE;
break;
}
return err;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Given a source file that's been opened, read the contents into an internal buffer and pre-process it to remove comments. */
|
STATIC STATUS ProcessFile(SOURCE_FILE *SourceFile)
|
/* Given a source file that's been opened, read the contents into an internal buffer and pre-process it to remove comments. */
STATIC STATUS ProcessFile(SOURCE_FILE *SourceFile)
|
{
fseek (SourceFile->Fptr, 0, SEEK_END);
SourceFile->FileSize = ftell (SourceFile->Fptr);
if (mGlobals.VerboseFile) {
printf ("FileSize = %u (0x%X)\n", (unsigned) SourceFile->FileSize, (unsigned) SourceFile->FileSize);
}
fseek (SourceFile->Fptr, 0, SEEK_SET);
SourceFile->FileBuffer = (CHAR8 *) malloc (SourceFile->FileSize + sizeof (CHAR8 ));
if (SourceFile->FileBuffer == NULL) {
Error (NULL, 0, 4001, "Resource: memory cannot be allocated", NULL);
return STATUS_ERROR;
}
fread ((VOID *) SourceFile->FileBuffer, SourceFile->FileSize, 1, SourceFile->Fptr);
SourceFile->FileBuffer[(SourceFile->FileSize / sizeof (CHAR8 ))] = T_CHAR_NULL;
PreprocessFile (SourceFile);
SourceFile->LineNum = 1;
return STATUS_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* DAC Channel Output Buffer Enable.
Enable a digital to analog converter channel output drive buffer. This is an optional amplifying buffer that provides additional drive for the output signal. The buffer is enabled by default after a reset and needs to be explicitly disabled if required. */
|
void dac_buffer_enable(uint32_t dac, int channel)
|
/* DAC Channel Output Buffer Enable.
Enable a digital to analog converter channel output drive buffer. This is an optional amplifying buffer that provides additional drive for the output signal. The buffer is enabled by default after a reset and needs to be explicitly disabled if required. */
void dac_buffer_enable(uint32_t dac, int channel)
|
{
switch (channel) {
case DAC_CHANNEL1:
DAC_CR(dac) &= ~DAC_CR_BOFF1;
break;
case DAC_CHANNEL2:
DAC_CR(dac) &= ~DAC_CR_BOFF2;
break;
case DAC_CHANNEL_BOTH:
DAC_CR(dac) &= ~(DAC_CR_BOFF1 | DAC_CR_BOFF2);
break;
}
}
|
libopencm3/libopencm3
|
C++
|
GNU General Public License v3.0
| 2,931
|
/* param base GPC CPU module base address. param mask The interrupt status flags to be cleared. Should be the OR'ed value of _gpc_cm_interrupt_status_flag. */
|
void GPC_CM_ClearInterruptStatusFlags(GPC_CPU_MODE_CTRL_Type *base, uint32_t mask)
|
/* param base GPC CPU module base address. param mask The interrupt status flags to be cleared. Should be the OR'ed value of _gpc_cm_interrupt_status_flag. */
void GPC_CM_ClearInterruptStatusFlags(GPC_CPU_MODE_CTRL_Type *base, uint32_t mask)
|
{
uint32_t temp32;
temp32 = base->CM_INT_CTRL;
temp32 &= ~(GPC_CM_ALL_INTERRUPT_STATUS);
base->CM_INT_CTRL = (mask | temp32);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Calculate square modulo. Please note, all "out" Big number arguments should be properly initialized by calling to */
|
BOOLEAN EFIAPI BigNumSqrMod(IN CONST VOID *BnA, IN CONST VOID *BnM, OUT VOID *BnRes)
|
/* Calculate square modulo. Please note, all "out" Big number arguments should be properly initialized by calling to */
BOOLEAN EFIAPI BigNumSqrMod(IN CONST VOID *BnA, IN CONST VOID *BnM, OUT VOID *BnRes)
|
{
CALL_CRYPTO_SERVICE (BigNumSqrMod, (BnA, BnM, BnRes), FALSE);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* ieee80211_clear_tx_pending may not be called in a context where it is possible that it packets could come in again. */
|
void ieee80211_clear_tx_pending(struct ieee80211_local *local)
|
/* ieee80211_clear_tx_pending may not be called in a context where it is possible that it packets could come in again. */
void ieee80211_clear_tx_pending(struct ieee80211_local *local)
|
{
int i;
for (i = 0; i < local->hw.queues; i++)
skb_queue_purge(&local->pending[i]);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Description: For all of the NetLabel protocols that support some form of label mapping cache, invalidate the cache. Returns zero on success, negative values on error. */
|
void netlbl_cache_invalidate(void)
|
/* Description: For all of the NetLabel protocols that support some form of label mapping cache, invalidate the cache. Returns zero on success, negative values on error. */
void netlbl_cache_invalidate(void)
|
{
cipso_v4_cache_invalidate();
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* This service will invoke MP service to perform CPU features initialization on BSP/APs per user configuration. */
|
VOID EFIAPI CpuFeaturesInitialize(VOID)
|
/* This service will invoke MP service to perform CPU features initialization on BSP/APs per user configuration. */
VOID EFIAPI CpuFeaturesInitialize(VOID)
|
{
CPU_FEATURES_DATA *CpuFeaturesData;
UINTN OldBspNumber;
CpuFeaturesData = GetCpuFeaturesData ();
OldBspNumber = GetProcessorIndex (CpuFeaturesData);
CpuFeaturesData->BspNumber = OldBspNumber;
StartupAllCPUsWorker (SetProcessorRegister);
if (CpuFeaturesData->BspNumber != OldBspNumber) {
SwitchNewBsp (CpuFeaturesData->BspNumber);
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Fills each adcConfig member with its default value. */
|
void TSC_ConfigStructInit(TSC_Config_T *tscConfig)
|
/* Fills each adcConfig member with its default value. */
void TSC_ConfigStructInit(TSC_Config_T *tscConfig)
|
{
tscConfig->CTPHSEL = TSC_CTPH_2CYCLE;
tscConfig->CTPLSEL = TSC_CTPL_2CYCLE;
tscConfig->SpreadSpectrum = ENABLE;
tscConfig->SpreadSpectrumDev = 1;
tscConfig->SpreadSpectrumPre = TSC_SS_PRE1;
tscConfig->PulseGeneratorPre = TSC_PG_PRESC1;
tscConfig->MCountValue = TSC_MCE_4095;
tscConfig->IOMode = TSC_IODM_OUT_PP_LOW;
tscConfig->SynchroPinPolarity = TSC_SYNPPOL_FALLING;
tscConfig->AcqMode = TSC_ACQMOD_NORMAL;
tscConfig->Interrupts = TSC_INT_NONE;
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* Enables or Disables the Precharge of Tamper pin. */
|
void RTC_TamperPullUpCmd(FunctionalState NewState)
|
/* Enables or Disables the Precharge of Tamper pin. */
void RTC_TamperPullUpCmd(FunctionalState NewState)
|
{
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
RTC->TMPCFG &= (uint32_t)~RTC_TMPCFG_TPPUDIS;
}
else
{
RTC->TMPCFG |= (uint32_t)RTC_TMPCFG_TPPUDIS;
}
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* This procedure is passed a buffer descriptor for an iframe. It builds the rest of the control part of the frame and then writes it out. */
|
static void x25_send_iframe(struct sock *sk, struct sk_buff *skb)
|
/* This procedure is passed a buffer descriptor for an iframe. It builds the rest of the control part of the frame and then writes it out. */
static void x25_send_iframe(struct sock *sk, struct sk_buff *skb)
|
{
struct x25_sock *x25 = x25_sk(sk);
if (!skb)
return;
if (x25->neighbour->extended) {
skb->data[2] = (x25->vs << 1) & 0xFE;
skb->data[3] &= X25_EXT_M_BIT;
skb->data[3] |= (x25->vr << 1) & 0xFE;
} else {
skb->data[2] &= X25_STD_M_BIT;
skb->data[2] |= (x25->vs << 1) & 0x0E;
skb->data[2] |= (x25->vr << 5) & 0xE0;
}
x25_transmit_link(skb, x25->neighbour);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* adi_close() is a callback from the input close routine. */
|
static void adi_close(struct input_dev *dev)
|
/* adi_close() is a callback from the input close routine. */
static void adi_close(struct input_dev *dev)
|
{
struct adi_port *port = input_get_drvdata(dev);
gameport_stop_polling(port->gameport);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* The Device tree is traversed in a depth-first search, starting from Node. The input Node is skipped. */
|
EFI_STATUS EFIAPI FdtGetNextCompatNodeInBranch(IN CONST VOID *Fdt, IN INT32 FdtBranch, IN CONST COMPATIBILITY_INFO *CompatNamesInfo, IN OUT INT32 *Node)
|
/* The Device tree is traversed in a depth-first search, starting from Node. The input Node is skipped. */
EFI_STATUS EFIAPI FdtGetNextCompatNodeInBranch(IN CONST VOID *Fdt, IN INT32 FdtBranch, IN CONST COMPATIBILITY_INFO *CompatNamesInfo, IN OUT INT32 *Node)
|
{
return FdtGetNextCondNodeInBranch (
Fdt,
FdtBranch,
FdtNodeIsCompatible,
(CONST VOID *)CompatNamesInfo,
Node
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Write a special marker. This is only recommended for writing COM or APPn markers. Must be called after jpeg_start_compress() and before first call to jpeg_write_scanlines() or jpeg_write_raw_data(). */
|
jpeg_write_marker(j_compress_ptr cinfo, int marker, const JOCTET *dataptr, unsigned int datalen)
|
/* Write a special marker. This is only recommended for writing COM or APPn markers. Must be called after jpeg_start_compress() and before first call to jpeg_write_scanlines() or jpeg_write_raw_data(). */
jpeg_write_marker(j_compress_ptr cinfo, int marker, const JOCTET *dataptr, unsigned int datalen)
|
{
JMETHOD(void, write_marker_byte, (j_compress_ptr info, int val));
if (cinfo->next_scanline != 0 ||
(cinfo->global_state != CSTATE_SCANNING &&
cinfo->global_state != CSTATE_RAW_OK &&
cinfo->global_state != CSTATE_WRCOEFS))
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
(*cinfo->marker->write_marker_header) (cinfo, marker, datalen);
write_marker_byte = cinfo->marker->write_marker_byte;
while (datalen--) {
(*write_marker_byte) (cinfo, *dataptr);
dataptr++;
}
}
|
nanoframework/nf-interpreter
|
C++
|
MIT License
| 293
|
/* Configure the length setting for block and repeat mode. */
|
static void r_dtc_block_repeat_initialize(transfer_info_t *p_info)
|
/* Configure the length setting for block and repeat mode. */
static void r_dtc_block_repeat_initialize(transfer_info_t *p_info)
|
{
uint32_t i = 0;
do
{
if (TRANSFER_MODE_NORMAL != p_info[i].mode)
{
uint8_t CRAL = p_info[i].length & DTC_PRV_MASK_CRAL;
p_info[i].length = (uint16_t) ((CRAL << DTC_PRV_OFFSET_CRAH) | CRAL);
}
} while (TRANSFER_CHAIN_MODE_DISABLED != p_info[i++].chain_mode);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Change the operating mode of the USB controller. */
|
void USBModeConfig(uint32_t ui32Base, uint32_t ui32Mode)
|
/* Change the operating mode of the USB controller. */
void USBModeConfig(uint32_t ui32Base, uint32_t ui32Mode)
|
{
ASSERT(ui32Base == USB0_BASE);
HWREG(ui32Base + USB_O_GPCS) = ui32Mode;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* sys_ccu_axi - Set the freq of axi @freq: freq want to set */
|
void __startup sys_ccu_axi(uint32_t cpu, uint32_t freq)
|
/* sys_ccu_axi - Set the freq of axi @freq: freq want to set */
void __startup sys_ccu_axi(uint32_t cpu, uint32_t freq)
|
{
uint32_t val, div = cpu / freq;
val = read32(GCTL_BASE + GX6605S_CLOCK_DIV_CONFIG1);
val &= ~(0x0f << 0);
val |= (div & 0x0f) << 0;
write32(GCTL_BASE + GX6605S_CLOCK_DIV_CONFIG1, val);
}
|
xboot/xboot
|
C++
|
MIT License
| 779
|
/* This is the last known freq, without actually getting it from the driver. Return value will be same as what is shown in scaling_cur_freq in sysfs. */
|
unsigned int cpufreq_quick_get(unsigned int cpu)
|
/* This is the last known freq, without actually getting it from the driver. Return value will be same as what is shown in scaling_cur_freq in sysfs. */
unsigned int cpufreq_quick_get(unsigned int cpu)
|
{
struct cpufreq_policy *policy = cpufreq_cpu_get(cpu);
unsigned int ret_freq = 0;
if (policy) {
ret_freq = policy->cur;
cpufreq_cpu_put(policy);
}
return ret_freq;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Returns 0 in case of success, 1 in case of failure */
|
int xmlListAppend(xmlListPtr l, void *data)
|
/* Returns 0 in case of success, 1 in case of failure */
int xmlListAppend(xmlListPtr l, void *data)
|
{
xmlLinkPtr lkPlace, lkNew;
if (l == NULL)
return(1);
lkPlace = xmlListHigherSearch(l, data);
lkNew = (xmlLinkPtr) xmlMalloc(sizeof(xmlLink));
if (lkNew == NULL) {
xmlGenericError(xmlGenericErrorContext,
"Cannot initialize memory for new link");
return (1);
}
lkNew->data = data;
lkNew->next = lkPlace->next;
(lkPlace->next)->prev = lkNew;
lkPlace->next = lkNew;
lkNew->prev = lkPlace;
return 0;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Writes the number of data units to be transferred on the DMAy Streamx. */
|
void DMA_SetCurrDataCounter(DMA_Stream_TypeDef *DMAy_Streamx, uint16_t Counter)
|
/* Writes the number of data units to be transferred on the DMAy Streamx. */
void DMA_SetCurrDataCounter(DMA_Stream_TypeDef *DMAy_Streamx, uint16_t Counter)
|
{
assert_param(IS_DMA_ALL_PERIPH(DMAy_Streamx));
DMAy_Streamx->NDTR = (uint16_t)Counter;
}
|
MaJerle/stm32f429
|
C++
| null | 2,036
|
/* Clear the contents of the field in the internal structure. */
|
int TIFFUnsetField(TIFF *tif, uint32 tag)
|
/* Clear the contents of the field in the internal structure. */
int TIFFUnsetField(TIFF *tif, uint32 tag)
|
{
const TIFFField *fip = TIFFFieldWithTag(tif, tag);
TIFFDirectory* td = &tif->tif_dir;
if( !fip )
return 0;
if( fip->field_bit != FIELD_CUSTOM )
TIFFClrFieldBit(tif, fip->field_bit);
else
{
TIFFTagValue *tv = NULL;
int i;
for (i = 0; i < td->td_customValueCount; i++) {
tv = td->td_customValues + i;
if( tv->info->field_tag == tag )
break;
}
if( i < td->td_customValueCount )
{
_TIFFfree(tv->value);
for( ; i < td->td_customValueCount-1; i++) {
td->td_customValues[i] = td->td_customValues[i+1];
}
td->td_customValueCount--;
}
}
tif->tif_flags |= TIFF_DIRTYDIRECT;
return (1);
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* Disable the 32 kHz clock output to other peripherals. */
|
void RTCClockOutputPeripheralsDisable(void)
|
/* Disable the 32 kHz clock output to other peripherals. */
void RTCClockOutputPeripheralsDisable(void)
|
{
xHWREG(RTC_CR) |= RTC_CR_CLKO;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Return true if the pointer can be used for DMA. */
|
static bool ptr_dma_compatible(const void *ptr)
|
/* Return true if the pointer can be used for DMA. */
static bool ptr_dma_compatible(const void *ptr)
|
{
return (uintptr_t) ptr >= 0x3FFAE000 &&
(uintptr_t) ptr < 0x40000000;
}
|
retro-esp32/RetroESP32
|
C++
|
Creative Commons Attribution Share Alike 4.0 International
| 581
|
/* Disable selected GPIO Interrupts.
ui64InterruptMask should be a logical or of AM_HAL_GPIO_BITx defines. */
|
void am_hal_gpio_int_disable(uint64_t ui64InterruptMask)
|
/* Disable selected GPIO Interrupts.
ui64InterruptMask should be a logical or of AM_HAL_GPIO_BITx defines. */
void am_hal_gpio_int_disable(uint64_t ui64InterruptMask)
|
{
AM_CRITICAL_BEGIN_ASM
AM_REG(GPIO, INT1EN) &= ~(ui64InterruptMask >> 32);
AM_REG(GPIO, INT0EN) &= ~(ui64InterruptMask & 0xFFFFFFFF);
AM_CRITICAL_END_ASM
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Set the USCI_SPI bus clock. Only available in Master mode. */
|
uint32_t USPI_SetBusClock(USPI_T *uspi, uint32_t u32BusClock)
|
/* Set the USCI_SPI bus clock. Only available in Master mode. */
uint32_t USPI_SetBusClock(USPI_T *uspi, uint32_t u32BusClock)
|
{
uint32_t u32ClkDiv;
uint32_t u32Pclk;
if(uspi == USPI0)
{
u32Pclk = CLK_GetPCLK0Freq();
}
else
{
u32Pclk = CLK_GetPCLK1Freq();
}
u32ClkDiv = (uint32_t) ((((((u32Pclk/2ul)*10ul)/(u32BusClock))+5ul)/10ul)-1ul);
uspi->BRGEN &= ~USPI_BRGEN_CLKDIV_Msk;
uspi->BRGEN |= (u32ClkDiv << USPI_BRGEN_CLKDIV_Pos);
return ( u32Pclk / ((u32ClkDiv+1ul)<<1) );
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* See "mss_ace.h" for details of how to use this function. */
|
void ACE_clear_comp_rise_irq(comparator_id_t comp_id)
|
/* See "mss_ace.h" for details of how to use this function. */
void ACE_clear_comp_rise_irq(comparator_id_t comp_id)
|
{
ASSERT( comp_id < NB_OF_COMPARATORS );
ACE->COMP_IRQ_CLR |= (FIRST_RISE_IRQ_MASK << (uint32_t)comp_id);
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* Disable autoreload match interrupt (ARRMIE). @rmtoll IER ARRMIE LPTIM_DisableIT_ARRM. */
|
void LPTIM_DisableIT_ARRM(LPTIM_Module *LPTIMx)
|
/* Disable autoreload match interrupt (ARRMIE). @rmtoll IER ARRMIE LPTIM_DisableIT_ARRM. */
void LPTIM_DisableIT_ARRM(LPTIM_Module *LPTIMx)
|
{
CLEAR_BIT(LPTIMx->INTEN, LPTIM_INTEN_ARRMIE);
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* Set station id on hw using the provided mac address */
|
int ath5k_hw_set_lladdr(struct ath5k_hw *ah, const u8 *mac)
|
/* Set station id on hw using the provided mac address */
int ath5k_hw_set_lladdr(struct ath5k_hw *ah, const u8 *mac)
|
{
struct ath_common *common = ath5k_hw_common(ah);
u32 low_id, high_id;
u32 pcu_reg;
ATH5K_TRACE(ah->ah_sc);
memcpy(common->macaddr, mac, ETH_ALEN);
pcu_reg = ath5k_hw_reg_read(ah, AR5K_STA_ID1) & 0xffff0000;
low_id = get_unaligned_le32(mac);
high_id = get_unaligned_le16(mac + 4);
ath5k_hw_reg_write(ah, low_id, AR5K_STA_ID0);
ath5k_hw_reg_write(ah, pcu_reg | high_id, AR5K_STA_ID1);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Finds the protocol instance for the requested handle and protocol. Note: This function doesn't do parameters checking, it's caller's responsibility to pass in valid parameters. */
|
PROTOCOL_INTERFACE* SmmFindProtocolInterface(IN IHANDLE *Handle, IN EFI_GUID *Protocol, IN VOID *Interface)
|
/* Finds the protocol instance for the requested handle and protocol. Note: This function doesn't do parameters checking, it's caller's responsibility to pass in valid parameters. */
PROTOCOL_INTERFACE* SmmFindProtocolInterface(IN IHANDLE *Handle, IN EFI_GUID *Protocol, IN VOID *Interface)
|
{
PROTOCOL_INTERFACE *Prot;
PROTOCOL_ENTRY *ProtEntry;
LIST_ENTRY *Link;
Prot = NULL;
ProtEntry = SmmFindProtocolEntry (Protocol, FALSE);
if (ProtEntry != NULL) {
for (Link = Handle->Protocols.ForwardLink; Link != &Handle->Protocols; Link = Link->ForwardLink) {
Prot = CR (Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
if ((Prot->Interface == Interface) && (Prot->Protocol == ProtEntry)) {
break;
}
Prot = NULL;
}
}
return Prot;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Reads the block data for a constant block */
|
static void read_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
|
/* Reads the block data for a constant block */
static void read_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
|
{
ALSSpecificConfig *sconf = &ctx->sconf;
AVCodecContext *avctx = ctx->avctx;
GetBitContext *gb = &ctx->gb;
bd->const_val = 0;
bd->const_block = get_bits1(gb);
bd->js_blocks = get_bits1(gb);
skip_bits(gb, 5);
if (bd->const_block) {
unsigned int const_val_bits = sconf->floating ? 24 : avctx->bits_per_raw_sample;
bd->const_val = get_sbits_long(gb, const_val_bits);
}
bd->const_block = 1;
}
|
DC-SWAT/DreamShell
|
C++
| null | 404
|
/* Virtual address change notification call back. It converts global pointer to virtual address. */
|
VOID EFIAPI VirtualAddressChangeCallBack(IN EFI_EVENT Event, IN VOID *Context)
|
/* Virtual address change notification call back. It converts global pointer to virtual address. */
VOID EFIAPI VirtualAddressChangeCallBack(IN EFI_EVENT Event, IN VOID *Context)
|
{
EfiConvertPointer (
0,
(VOID **)&mRtMemoryStatusCodeTable
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* dccp_feat_prefer - Move preferred entry to the start of array Reorder the @array_len elements in @array so that @preferred_value comes first. Returns >0 to indicate that @preferred_value does occur in @array. */
|
static u8 dccp_feat_prefer(u8 preferred_value, u8 *array, u8 array_len)
|
/* dccp_feat_prefer - Move preferred entry to the start of array Reorder the @array_len elements in @array so that @preferred_value comes first. Returns >0 to indicate that @preferred_value does occur in @array. */
static u8 dccp_feat_prefer(u8 preferred_value, u8 *array, u8 array_len)
|
{
u8 i, does_occur = 0;
if (array != NULL) {
for (i = 0; i < array_len; i++)
if (array[i] == preferred_value) {
array[i] = array[0];
does_occur++;
}
if (does_occur)
array[0] = preferred_value;
}
return does_occur;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Stops the TIMER hall sensor interface in DMA mode. */
|
void ald_timer_hall_sensor_stop_by_dma(ald_timer_handle_t *hperh)
|
/* Stops the TIMER hall sensor interface in DMA mode. */
void ald_timer_hall_sensor_stop_by_dma(ald_timer_handle_t *hperh)
|
{
assert_param(IS_TIMER_XOR_INSTANCE(hperh->perh));
ald_timer_dma_req_config(hperh, ALD_TIMER_DMA_CC1, DISABLE);
timer_ccx_channel_cmd(hperh->perh, ALD_TIMER_CHANNEL_1, DISABLE);
ALD_TIMER_DISABLE(hperh);
return;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Appending pad buffer to a request modifies the last entry of a scatter list such that it includes the pad buffer. */
|
void blk_queue_dma_pad(struct request_queue *q, unsigned int mask)
|
/* Appending pad buffer to a request modifies the last entry of a scatter list such that it includes the pad buffer. */
void blk_queue_dma_pad(struct request_queue *q, unsigned int mask)
|
{
q->dma_pad_mask = mask;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Truncate a file to the specified size - all we have to do is set the size attribute. We make sure the object exists first. */
|
void exofs_truncate(struct inode *inode)
|
/* Truncate a file to the specified size - all we have to do is set the size attribute. We make sure the object exists first. */
void exofs_truncate(struct inode *inode)
|
{
struct exofs_i_info *oi = exofs_i(inode);
int ret;
if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)
|| S_ISLNK(inode->i_mode)))
return;
if (exofs_inode_is_fast_symlink(inode))
return;
if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
return;
if (unlikely(wait_obj_created(oi)))
goto fail;
ret = _do_truncate(inode);
if (ret)
goto fail;
out:
mark_inode_dirty(inode);
return;
fail:
make_bad_inode(inode);
goto out;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Extract zero terminated short name from a directory entry. */
|
static void get_name(dir_entry *dirent, char *s_name)
|
/* Extract zero terminated short name from a directory entry. */
static void get_name(dir_entry *dirent, char *s_name)
|
{
char *ptr;
memcpy (s_name, dirent->name, 8);
s_name[8] = '\0';
ptr = s_name;
while (*ptr && *ptr != ' ')
ptr++;
if (dirent->ext[0] && dirent->ext[0] != ' ') {
*ptr = '.';
ptr++;
memcpy (ptr, dirent->ext, 3);
ptr[3] = '\0';
while (*ptr && *ptr != ' ')
ptr++;
}
*ptr = '\0';
if (*s_name == DELETED_FLAG)
*s_name = '\0';
else if (*s_name == aRING)
*s_name = DELETED_FLAG;
downcase (s_name);
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* Try to post a callback-message to the tcpip_thread mbox This is intended to be used to send "static" messages from interrupt context. */
|
err_t tcpip_trycallback(struct tcpip_callback_msg *msg)
|
/* Try to post a callback-message to the tcpip_thread mbox This is intended to be used to send "static" messages from interrupt context. */
err_t tcpip_trycallback(struct tcpip_callback_msg *msg)
|
{
LWIP_ASSERT("Invalid mbox", sys_mbox_valid_val(mbox));
return sys_mbox_trypost(&mbox, msg);
}
|
Nicholas3388/LuaNode
|
C++
|
Other
| 1,055
|
/* This is called to fill in the vector of log iovecs for the given efi log item. We use only 1 iovec, and we point that at the efi_log_format structure embedded in the efi item. It is at this point that we assert that all of the extent slots in the efi item have been filled. */
|
STATIC void xfs_efi_item_format(xfs_efi_log_item_t *efip, xfs_log_iovec_t *log_vector)
|
/* This is called to fill in the vector of log iovecs for the given efi log item. We use only 1 iovec, and we point that at the efi_log_format structure embedded in the efi item. It is at this point that we assert that all of the extent slots in the efi item have been filled. */
STATIC void xfs_efi_item_format(xfs_efi_log_item_t *efip, xfs_log_iovec_t *log_vector)
|
{
uint size;
ASSERT(efip->efi_next_extent == efip->efi_format.efi_nextents);
efip->efi_format.efi_type = XFS_LI_EFI;
size = sizeof(xfs_efi_log_format_t);
size += (efip->efi_format.efi_nextents - 1) * sizeof(xfs_extent_t);
efip->efi_format.efi_size = 1;
log_vector->i_addr = (xfs_caddr_t)&(efip->efi_format);
log_vector->i_len = size;
XLOG_VEC_SET_TYPE(log_vector, XLOG_REG_TYPE_EFI_FORMAT);
ASSERT(size >= sizeof(xfs_efi_log_format_t));
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Writes multiple data with I2C communication channel from MCU to TouchScreen. */
|
void SENSOR_IO_WriteMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length)
|
/* Writes multiple data with I2C communication channel from MCU to TouchScreen. */
void SENSOR_IO_WriteMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length)
|
{
I2Cx_WriteMultiple(&hI2cHandler, Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, Buffer, Length);
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Perform automated behaviors in response to ifaces going admin-up. */
|
static void conn_mgr_conn_handle_iface_admin_up(struct net_if *iface)
|
/* Perform automated behaviors in response to ifaces going admin-up. */
static void conn_mgr_conn_handle_iface_admin_up(struct net_if *iface)
|
{
int err;
if (!conn_mgr_if_is_bound(iface)) {
return;
}
if (conn_mgr_if_get_flag(iface, CONN_MGR_IF_NO_AUTO_CONNECT)) {
return;
}
err = conn_mgr_if_connect(iface);
if (err < 0) {
NET_ERR("iface auto-connect failed: %d", err);
}
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* If PcdMaximumAsciiStringLength is not zero, and SearchString or String contains more than PcdMaximumAsciiStringLength Unicode characters not including the Null-terminator, then ASSERT(). */
|
CHAR8* EFIAPI AsciiStrStr(IN CONST CHAR8 *String, IN CONST CHAR8 *SearchString)
|
/* If PcdMaximumAsciiStringLength is not zero, and SearchString or String contains more than PcdMaximumAsciiStringLength Unicode characters not including the Null-terminator, then ASSERT(). */
CHAR8* EFIAPI AsciiStrStr(IN CONST CHAR8 *String, IN CONST CHAR8 *SearchString)
|
{
CONST CHAR8 *FirstMatch;
CONST CHAR8 *SearchStringTmp;
ASSERT (AsciiStrSize (String) != 0);
ASSERT (AsciiStrSize (SearchString) != 0);
if (*SearchString == '\0') {
return (CHAR8 *)String;
}
while (*String != '\0') {
SearchStringTmp = SearchString;
FirstMatch = String;
while ( (*String == *SearchStringTmp)
&& (*String != '\0'))
{
String++;
SearchStringTmp++;
}
if (*SearchStringTmp == '\0') {
return (CHAR8 *)FirstMatch;
}
if (*String == '\0') {
return NULL;
}
String = FirstMatch + 1;
}
return NULL;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* SMP_INCLUDED == TRUE.
SMP_INCLUDED == TRUE && BT_SSP_INCLUDED */
|
void bta_dm_loc_oob(tBTA_DM_MSG *p_data)
|
/* SMP_INCLUDED == TRUE.
SMP_INCLUDED == TRUE && BT_SSP_INCLUDED */
void bta_dm_loc_oob(tBTA_DM_MSG *p_data)
|
{
UNUSED(p_data);
BTM_ReadLocalOobData();
}
|
retro-esp32/RetroESP32
|
C++
|
Creative Commons Attribution Share Alike 4.0 International
| 581
|
/* MBMS Service Area Identity List octet 3 - 514 MBMS-Service-Area AVP encoded as in 3GPP TS 29.061, excluding AVP Header fields (as defined in IETF RFC 3588 ). */
|
static guint16 de_bssgp_mbms_sai_list(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
|
/* MBMS Service Area Identity List octet 3 - 514 MBMS-Service-Area AVP encoded as in 3GPP TS 29.061, excluding AVP Header fields (as defined in IETF RFC 3588 ). */
static guint16 de_bssgp_mbms_sai_list(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
|
{
tvbuff_t *new_tvb;
guint32 curr_offset;
curr_offset = offset;
new_tvb =tvb_new_subset_length(tvb, offset, len);
dissector_try_uint(diameter_3gpp_avp_dissector_table, 903, new_tvb, pinfo, tree);
return(curr_offset-offset);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values. It can block. */
|
void set_fs_root(struct fs_struct *fs, struct path *path)
|
/* Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values. It can block. */
void set_fs_root(struct fs_struct *fs, struct path *path)
|
{
struct path old_root;
write_lock(&fs->lock);
old_root = fs->root;
fs->root = *path;
path_get(path);
write_unlock(&fs->lock);
if (old_root.dentry)
path_put(&old_root);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This API is used to get the status of nvm program in the register 0x33 bit 2. */
|
BMG160_RETURN_FUNCTION_TYPE bmg160_get_nvm_rdy(u8 *v_nvm_rdy_u8)
|
/* This API is used to get the status of nvm program in the register 0x33 bit 2. */
BMG160_RETURN_FUNCTION_TYPE bmg160_get_nvm_rdy(u8 *v_nvm_rdy_u8)
|
{
BMG160_RETURN_FUNCTION_TYPE comres = ERROR;
u8 v_data_u8 = BMG160_INIT_VALUE;
if (p_bmg160 == BMG160_NULL)
{
return E_BMG160_NULL_PTR;
}
else
{
comres = p_bmg160->BMG160_BUS_READ_FUNC(p_bmg160->dev_addr,
BMG160_TRIM_NVM_CTRL_ADDR_NVM_RDY__REG,
&v_data_u8, BMG160_GEN_READ_WRITE_DATA_LENGTH);
*v_nvm_rdy_u8 = BMG160_GET_BITSLICE(v_data_u8,
BMG160_TRIM_NVM_CTRL_ADDR_NVM_RDY);
}
return comres;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
static struct ieee80211_hw* ath_get_virt_hw(struct ath_softc *sc, struct ieee80211_hdr *hdr)
|
/* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
static struct ieee80211_hw* ath_get_virt_hw(struct ath_softc *sc, struct ieee80211_hdr *hdr)
|
{
struct ieee80211_hw *hw = sc->pri_wiphy->hw;
int i;
spin_lock_bh(&sc->wiphy_lock);
for (i = 0; i < sc->num_sec_wiphy; i++) {
struct ath_wiphy *aphy = sc->sec_wiphy[i];
if (aphy == NULL)
continue;
if (compare_ether_addr(hdr->addr1, aphy->hw->wiphy->perm_addr)
== 0) {
hw = aphy->hw;
break;
}
}
spin_unlock_bh(&sc->wiphy_lock);
return hw;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Returns: TRUE if @type is a kind of @supertype, FALSE otherwise. */
|
gboolean g_content_type_is_a(const gchar *type, const gchar *supertype)
|
/* Returns: TRUE if @type is a kind of @supertype, FALSE otherwise. */
gboolean g_content_type_is_a(const gchar *type, const gchar *supertype)
|
{
gboolean res;
g_return_val_if_fail (type != NULL, FALSE);
g_return_val_if_fail (supertype != NULL, FALSE);
G_LOCK (gio_xdgmime);
res = xdg_mime_mime_type_subclass (type, supertype);
G_UNLOCK (gio_xdgmime);
return res;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Function for swap erase state entry action.
Function for swap erase state entry action, which includes erasing swap flash page. */
|
static void state_swap_erase_entry_run(void)
|
/* Function for swap erase state entry action.
Function for swap erase state entry action, which includes erasing swap flash page. */
static void state_swap_erase_entry_run(void)
|
{
flash_page_erase(PSTORAGE_SWAP_ADDR / PSTORAGE_FLASH_PAGE_SIZE);
}
|
labapart/polymcu
|
C++
| null | 201
|
/* Get the peripheral clock speed for the Timer at base specified. */
|
uint32_t rcc_get_timer_clk_freq(uint32_t timer)
|
/* Get the peripheral clock speed for the Timer at base specified. */
uint32_t rcc_get_timer_clk_freq(uint32_t timer)
|
{
if (timer >= TIM2_BASE && timer <= TIM7_BASE) {
uint8_t ppre1 = (RCC_CFGR >> RCC_CFGR_PPRE1_SHIFT) & RCC_CFGR_PPRE1_MASK;
return (ppre1 == RCC_CFGR_PPRE1_DIV_NONE) ? rcc_apb1_frequency
: 2 * rcc_apb1_frequency;
} else {
uint8_t ppre2 = (RCC_CFGR >> RCC_CFGR_PPRE2_SHIFT) & RCC_CFGR_PPRE2_MASK;
return (ppre2 == RCC_CFGR_PPRE2_DIV_NONE) ? rcc_apb2_frequency
: 2 * rcc_apb2_frequency;
}
}
|
libopencm3/libopencm3
|
C++
|
GNU General Public License v3.0
| 2,931
|
/* @native: pointer to pointer to U-Boot variable name @variable_name: UEFI variable name @vendor: vendor GUID Return: status code */
|
static efi_status_t efi_to_native(char **native, const u16 *variable_name, const efi_guid_t *vendor)
|
/* @native: pointer to pointer to U-Boot variable name @variable_name: UEFI variable name @vendor: vendor GUID Return: status code */
static efi_status_t efi_to_native(char **native, const u16 *variable_name, const efi_guid_t *vendor)
|
{
size_t len;
char *pos;
len = PREFIX_LEN + utf16_utf8_strlen(variable_name) + 1;
*native = malloc(len);
if (!*native)
return EFI_OUT_OF_RESOURCES;
pos = *native;
pos += sprintf(pos, "efi_%pUl_", vendor);
utf16_utf8_strcpy(&pos, variable_name);
return EFI_SUCCESS;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* ibmvfc_init_tgt - Set the next init job step for the target @tgt: ibmvfc target struct @job_step: job step to perform */
|
static void ibmvfc_init_tgt(struct ibmvfc_target *tgt, void(*job_step)(struct ibmvfc_target *))
|
/* ibmvfc_init_tgt - Set the next init job step for the target @tgt: ibmvfc target struct @job_step: job step to perform */
static void ibmvfc_init_tgt(struct ibmvfc_target *tgt, void(*job_step)(struct ibmvfc_target *))
|
{
ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_INIT);
tgt->job_step = job_step;
wake_up(&tgt->vhost->work_wait_q);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Configures a Timer to emulate an encoder sensor outputs in Backward direction */
|
static void Emulate_Backward_Direction(TIM_HandleTypeDef *htim)
|
/* Configures a Timer to emulate an encoder sensor outputs in Backward direction */
static void Emulate_Backward_Direction(TIM_HandleTypeDef *htim)
|
{
sConfig.Pulse = (EMU_PERIOD * 3 )/4;
if(HAL_TIM_OC_ConfigChannel(htim, &sConfig, TIM_CHANNEL_1) != HAL_OK)
{
Error_Handler();
}
sConfig.Pulse = (EMU_PERIOD * 1 )/4;
if(HAL_TIM_OC_ConfigChannel(htim, &sConfig, TIM_CHANNEL_2) != HAL_OK)
{
Error_Handler();
}
if(HAL_TIM_OC_Start(htim, TIM_CHANNEL_1) != HAL_OK)
{
Error_Handler();
}
if(HAL_TIM_OC_Start(htim, TIM_CHANNEL_2) != HAL_OK)
{
Error_Handler();
}
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* Write the geometry values of a single window to the recent file. */
|
static void write_recent_geom(gpointer key _U_, gpointer value, gpointer rfh)
|
/* Write the geometry values of a single window to the recent file. */
static void write_recent_geom(gpointer key _U_, gpointer value, gpointer rfh)
|
{
window_geometry_t *geom = (window_geometry_t *)value;
FILE *rf = (FILE *)rfh;
fprintf(rf, "\n# Geometry and maximized state of %s window.\n", geom->key);
fprintf(rf, "# Decimal integers.\n");
fprintf(rf, RECENT_GUI_GEOMETRY "%s.x: %d\n", geom->key, geom->x);
fprintf(rf, RECENT_GUI_GEOMETRY "%s.y: %d\n", geom->key, geom->y);
fprintf(rf, RECENT_GUI_GEOMETRY "%s.width: %d\n", geom->key,
geom->width);
fprintf(rf, RECENT_GUI_GEOMETRY "%s.height: %d\n", geom->key,
geom->height);
fprintf(rf, "# TRUE or FALSE (case-insensitive).\n");
fprintf(rf, RECENT_GUI_GEOMETRY "%s.maximized: %s\n", geom->key,
geom->maximized == TRUE ? "TRUE" : "FALSE");
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* This is the generic map function. It maps one 4kb page at paddr to the given address in the DMA address space for the domain. */
|
static dma_addr_t dma_ops_domain_map(struct dma_ops_domain *dom, unsigned long address, phys_addr_t paddr, int direction)
|
/* This is the generic map function. It maps one 4kb page at paddr to the given address in the DMA address space for the domain. */
static dma_addr_t dma_ops_domain_map(struct dma_ops_domain *dom, unsigned long address, phys_addr_t paddr, int direction)
|
{
u64 *pte, __pte;
WARN_ON(address > dom->aperture_size);
paddr &= PAGE_MASK;
pte = dma_ops_get_pte(dom, address);
if (!pte)
return DMA_ERROR_CODE;
__pte = paddr | IOMMU_PTE_P | IOMMU_PTE_FC;
if (direction == DMA_TO_DEVICE)
__pte |= IOMMU_PTE_IR;
else if (direction == DMA_FROM_DEVICE)
__pte |= IOMMU_PTE_IW;
else if (direction == DMA_BIDIRECTIONAL)
__pte |= IOMMU_PTE_IR | IOMMU_PTE_IW;
WARN_ON(*pte);
*pte = __pte;
return (dma_addr_t)address;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Weight of XL user offset bits of registers X_OFS_USR(73h), Y_OFS_USR(74h), Z_OFS_USR(75h).. */
|
int32_t lsm6dsl_xl_offset_weight_get(stmdev_ctx_t *ctx, lsm6dsl_usr_off_w_t *val)
|
/* Weight of XL user offset bits of registers X_OFS_USR(73h), Y_OFS_USR(74h), Z_OFS_USR(75h).. */
int32_t lsm6dsl_xl_offset_weight_get(stmdev_ctx_t *ctx, lsm6dsl_usr_off_w_t *val)
|
{
lsm6dsl_ctrl6_c_t ctrl6_c;
int32_t ret;
ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL6_C, (uint8_t*)&ctrl6_c, 1);
switch (ctrl6_c.usr_off_w) {
case LSM6DSL_LSb_1mg:
*val = LSM6DSL_LSb_1mg;
break;
case LSM6DSL_LSb_16mg:
*val = LSM6DSL_LSb_16mg;
break;
default:
*val = LSM6DSL_WEIGHT_ND;
break;
}
return ret;
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Output a single byte to the serial port. */
|
void serial_putc_dev(const char c, const int dev_index)
|
/* Output a single byte to the serial port. */
void serial_putc_dev(const char c, const int dev_index)
|
{
struct s5pc1xx_uart *const uart = s5pc1xx_get_base_uart(dev_index);
while (!(readl(&uart->utrstat) & 0x2)) {
if (serial_err_check(dev_index, 1))
return;
}
writel(c, &uart->utxh);
if (c == '\n')
serial_putc('\r');
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* Allow a kernel service to reject an incoming call with a BUSY message, assuming the incoming call is still valid. */
|
int rxrpc_kernel_reject_call(struct socket *sock)
|
/* Allow a kernel service to reject an incoming call with a BUSY message, assuming the incoming call is still valid. */
int rxrpc_kernel_reject_call(struct socket *sock)
|
{
int ret;
_enter("");
ret = rxrpc_reject_call(rxrpc_sk(sock->sk));
_leave(" = %d", ret);
return ret;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Selects the GPIO pin used as EXTI Line. */
|
void GPIO_ConfigEXTILine(uint8_t PortSource, uint8_t PinSource)
|
/* Selects the GPIO pin used as EXTI Line. */
void GPIO_ConfigEXTILine(uint8_t PortSource, uint8_t PinSource)
|
{
uint32_t tmp = 0x00;
assert_param(IS_GPIO_EXTI_PORT_SOURCE(PortSource));
assert_param(IS_GPIO_PIN_SOURCE(PinSource));
tmp = ((uint32_t)0x0F) << (0x04 * (PinSource & (uint8_t)0x03));
AFIO->EXTI_CFG[PinSource >> 0x02] &= ~tmp;
AFIO->EXTI_CFG[PinSource >> 0x02] |= (((uint32_t)PortSource) << (0x04 * (PinSource & (uint8_t)0x03)));
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Get actual external trigger filter. @rmtoll CFG TRGFLT LPTIM_GetTriggerFilter. */
|
uint32_t LPTIM_GetTriggerFilter(LPTIM_Module *LPTIMx)
|
/* Get actual external trigger filter. @rmtoll CFG TRGFLT LPTIM_GetTriggerFilter. */
uint32_t LPTIM_GetTriggerFilter(LPTIM_Module *LPTIMx)
|
{
return (uint32_t)(READ_BIT(LPTIMx->CFG, LPTIM_CFG_TRIGFLT));
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* Atomically swap in the new signal mask, and wait for a signal. */
|
asmlinkage int do_sigsuspend(struct pt_regs *regs)
|
/* Atomically swap in the new signal mask, and wait for a signal. */
asmlinkage int do_sigsuspend(struct pt_regs *regs)
|
{
old_sigset_t mask = regs->er3;
sigset_t saveset;
mask &= _BLOCKABLE;
spin_lock_irq(¤t->sighand->siglock);
saveset = current->blocked;
siginitset(¤t->blocked, mask);
recalc_sigpending();
spin_unlock_irq(¤t->sighand->siglock);
regs->er0 = -EINTR;
while (1) {
current->state = TASK_INTERRUPTIBLE;
schedule();
if (do_signal(regs, &saveset))
return -EINTR;
}
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* brief Initialize the trim value for FRO HF . */
|
void CLOCK_FroHfTrim(void)
|
/* brief Initialize the trim value for FRO HF . */
void CLOCK_FroHfTrim(void)
|
{
volatile unsigned int Fro192mCtrlEfuse = 0;
Fro192mCtrlEfuse = ANACTRL->FRO192M_CTRL;
ANACTRL->ANALOG_CTRL_CFG = ANACTRL->ANALOG_CTRL_CFG | ANACTRL_ANALOG_CTRL_CFG_FRO192M_TRIM_SRC_MASK;
ANACTRL->FRO192M_CTRL = ANACTRL_FRO192M_CTRL_WRTRIM_MASK | Fro192mCtrlEfuse;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* This function provides a service to send and receive messages from a registered UEFI service. */
|
EFI_STATUS EFIAPI SmmCommunicationMmCommunicate2(IN CONST EFI_MM_COMMUNICATION2_PROTOCOL *This, IN OUT VOID *CommBufferPhysical, IN OUT VOID *CommBufferVirtual, IN OUT UINTN *CommSize OPTIONAL)
|
/* This function provides a service to send and receive messages from a registered UEFI service. */
EFI_STATUS EFIAPI SmmCommunicationMmCommunicate2(IN CONST EFI_MM_COMMUNICATION2_PROTOCOL *This, IN OUT VOID *CommBufferPhysical, IN OUT VOID *CommBufferVirtual, IN OUT UINTN *CommSize OPTIONAL)
|
{
return SmmCommunicationCommunicate (
&mSmmCommunication,
CommBufferPhysical,
CommSize
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* HCI read local supported states command. Returns the states supported by the controller. */
|
static int ble_ll_hci_le_read_supp_states(uint8_t *rspbuf, uint8_t *rsplen)
|
/* HCI read local supported states command. Returns the states supported by the controller. */
static int ble_ll_hci_le_read_supp_states(uint8_t *rspbuf, uint8_t *rsplen)
|
{
struct ble_hci_le_rd_supp_states_rp *rsp = (void *) rspbuf;
rsp->states = htole64(ble_ll_read_supp_states());
*rsplen = sizeof(*rsp);
return BLE_ERR_SUCCESS;
}
|
arendst/Tasmota
|
C++
|
GNU General Public License v3.0
| 21,318
|
/* If Cert is NULL, then return FALSE. If SubjectSize is NULL, then return FALSE. If this interface is not supported, then return FALSE. */
|
BOOLEAN EFIAPI CryptoServiceX509GetSubjectName(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT UINT8 *CertSubject, IN OUT UINTN *SubjectSize)
|
/* If Cert is NULL, then return FALSE. If SubjectSize is NULL, then return FALSE. If this interface is not supported, then return FALSE. */
BOOLEAN EFIAPI CryptoServiceX509GetSubjectName(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT UINT8 *CertSubject, IN OUT UINTN *SubjectSize)
|
{
return CALL_BASECRYPTLIB (X509.Services.GetSubjectName, X509GetSubjectName, (Cert, CertSize, CertSubject, SubjectSize), FALSE);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* FLASH_SetStatus used to set register status. FLASH_WriteEn & FLASH_WaitBusy, and lock CPU when set are included in this function to avoid hardfault when TxCmd in XIP. */
|
IMAGE2_RAM_TEXT_SECTION void FLASH_SetStatusXIP(u8 Cmd, u32 Len, u8 *Status)
|
/* FLASH_SetStatus used to set register status. FLASH_WriteEn & FLASH_WaitBusy, and lock CPU when set are included in this function to avoid hardfault when TxCmd in XIP. */
IMAGE2_RAM_TEXT_SECTION void FLASH_SetStatusXIP(u8 Cmd, u32 Len, u8 *Status)
|
{
FLASH_Write_Lock();
FLASH_SetStatus(Cmd, Len, Status);
FLASH_Write_Unlock();
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* hdaps_calibrate - Set our "resting" values. Callers must hold hdaps_mtx. */
|
static void hdaps_calibrate(void)
|
/* hdaps_calibrate - Set our "resting" values. Callers must hold hdaps_mtx. */
static void hdaps_calibrate(void)
|
{
__hdaps_read_pair(HDAPS_PORT_XPOS, HDAPS_PORT_YPOS, &rest_x, &rest_y);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Find a free channel for a DMA resource.
Find a channel for the requested DMA resource. */
|
static uint8_t _dma_find_first_free_channel_and_allocate(void)
|
/* Find a free channel for a DMA resource.
Find a channel for the requested DMA resource. */
static uint8_t _dma_find_first_free_channel_and_allocate(void)
|
{
uint8_t count;
uint32_t tmp;
bool allocated = false;
system_interrupt_enter_critical_section();
tmp = _dma_inst.allocated_channels;
for (count = 0; count < CONF_MAX_USED_CHANNEL_NUM; ++count) {
if (!(tmp & 0x00000001)) {
_dma_inst.allocated_channels |= 1 << count;
_dma_inst.free_channels--;
allocated = true;
break;
}
tmp = tmp >> 1;
}
system_interrupt_leave_critical_section();
if (!allocated) {
return DMA_INVALID_CHANNEL;
} else {
return count;
}
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* Not an official SSCI function, but how to reset RocketModems. ISA bus version */
|
static void sModemReset(CONTROLLER_T *CtlP, int chan, int on)
|
/* Not an official SSCI function, but how to reset RocketModems. ISA bus version */
static void sModemReset(CONTROLLER_T *CtlP, int chan, int on)
|
{
ByteIO_t addr;
Byte_t val;
addr = CtlP->AiopIO[0] + 0x400;
val = sInB(CtlP->MReg3IO);
if ((val & 2) == 0) {
val = sInB(CtlP->MReg2IO);
sOutB(CtlP->MReg2IO, (val & 0xfc) | (1 & 0x03));
sOutB(CtlP->MBaseIO, (unsigned char) (addr >> 6));
}
sEnAiop(CtlP, 1);
if (!on)
addr += 8;
sOutB(addr + chan, 0);
sDisAiop(CtlP, 1);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* It is the same with flash_stream_read function which is used to read a stream of data from specified address. */
|
int flash_burst_read(flash_t *obj, u32 address, u32 Length, u8 *data)
|
/* It is the same with flash_stream_read function which is used to read a stream of data from specified address. */
int flash_burst_read(flash_t *obj, u32 address, u32 Length, u8 *data)
|
{
flash_stream_read(obj, address, Length, data);
return 1;
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* Copy data from kernel space to MMIO space, in units of 32 or 64 bits at a time. Order of access is not guaranteed, nor is a memory barrier performed afterwards. */
|
void __attribute__((weak))
|
/* Copy data from kernel space to MMIO space, in units of 32 or 64 bits at a time. Order of access is not guaranteed, nor is a memory barrier performed afterwards. */
void __attribute__((weak))
|
{
u32 __iomem *dst = to;
const u32 *src = from;
const u32 *end = src + count;
while (src < end)
__raw_writel(*src++, dst++);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This handle (of course) holds a reference to the object, so the object will not go away until the handle is deleted. */
|
int drm_gem_open_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
/* This handle (of course) holds a reference to the object, so the object will not go away until the handle is deleted. */
int drm_gem_open_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
{
struct drm_gem_open *args = data;
struct drm_gem_object *obj;
int ret;
u32 handle;
if (!(dev->driver->driver_features & DRIVER_GEM))
return -ENODEV;
spin_lock(&dev->object_name_lock);
obj = idr_find(&dev->object_name_idr, (int) args->name);
if (obj)
drm_gem_object_reference(obj);
spin_unlock(&dev->object_name_lock);
if (!obj)
return -ENOENT;
ret = drm_gem_handle_create(file_priv, obj, &handle);
mutex_lock(&dev->struct_mutex);
drm_gem_object_unreference(obj);
mutex_unlock(&dev->struct_mutex);
if (ret)
return ret;
args->handle = handle;
args->size = obj->size;
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Returns 0 on success or negative error code on failure. */
|
static int i2o_pci_irq_enable(struct i2o_controller *c)
|
/* Returns 0 on success or negative error code on failure. */
static int i2o_pci_irq_enable(struct i2o_controller *c)
|
{
struct pci_dev *pdev = c->pdev;
int rc;
writel(0xffffffff, c->irq_mask);
if (pdev->irq) {
rc = request_irq(pdev->irq, i2o_pci_interrupt, IRQF_SHARED,
c->name, c);
if (rc < 0) {
printk(KERN_ERR "%s: unable to allocate interrupt %d."
"\n", c->name, pdev->irq);
return rc;
}
}
writel(0x00000000, c->irq_mask);
printk(KERN_INFO "%s: Installed at IRQ %d\n", c->name, pdev->irq);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Called when the current connection state machine is no longer being used. */
|
static void ble_ll_conn_current_sm_over(struct ble_ll_conn_sm *connsm)
|
/* Called when the current connection state machine is no longer being used. */
static void ble_ll_conn_current_sm_over(struct ble_ll_conn_sm *connsm)
|
{
ble_ll_conn_halt();
if (connsm) {
ble_ll_event_send(&connsm->conn_ev_end);
}
}
|
arendst/Tasmota
|
C++
|
GNU General Public License v3.0
| 21,318
|
/* Generate NEC header value: active 9ms + negative 4.5ms. */
|
static void fill_item_header(rmt_item32_t *item)
|
/* Generate NEC header value: active 9ms + negative 4.5ms. */
static void fill_item_header(rmt_item32_t *item)
|
{
fill_item_level(item, HEADER_HIGH_US, HEADER_LOW_US);
}
|
retro-esp32/RetroESP32
|
C++
|
Creative Commons Attribution Share Alike 4.0 International
| 581
|
/* Note that DxeSmmReadyToLock must be signaled after this function returns; otherwise the script wouldn't be saved actually. */
|
STATIC VOID SaveS3BootScript(VOID)
|
/* Note that DxeSmmReadyToLock must be signaled after this function returns; otherwise the script wouldn't be saved actually. */
STATIC VOID SaveS3BootScript(VOID)
|
{
EFI_STATUS Status;
EFI_S3_SAVE_STATE_PROTOCOL *BootScript;
STATIC CONST UINT8 Info[] = { 0xDE, 0xAD, 0xBE, 0xEF };
Status = gBS->LocateProtocol (
&gEfiS3SaveStateProtocolGuid,
NULL,
(VOID **)&BootScript
);
ASSERT_EFI_ERROR (Status);
Status = BootScript->Write (
BootScript,
EFI_BOOT_SCRIPT_INFORMATION_OPCODE,
(UINT32)sizeof Info,
(EFI_PHYSICAL_ADDRESS)(UINTN)&Info
);
ASSERT_EFI_ERROR (Status);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Message: AlarmMessage Opcode: 0x0020 Type: RegistrationAndManagement Direction: dev2pbx VarLength: no */
|
static void handle_AlarmMessage(ptvcursor_t *cursor, packet_info *pinfo _U_)
|
/* Message: AlarmMessage Opcode: 0x0020 Type: RegistrationAndManagement Direction: dev2pbx VarLength: no */
static void handle_AlarmMessage(ptvcursor_t *cursor, packet_info *pinfo _U_)
|
{
ptvcursor_add(cursor, hf_skinny_alarmSeverity, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_text, 80, ENC_ASCII|ENC_NA);
ptvcursor_add(cursor, hf_skinny_parm1, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_parm2, 4, ENC_LITTLE_ENDIAN);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Decode a file name and make sure that the path contains no slashes or null bytes. */
|
static __be32* decode_filename(__be32 *p, char **namp, unsigned int *lenp)
|
/* Decode a file name and make sure that the path contains no slashes or null bytes. */
static __be32* decode_filename(__be32 *p, char **namp, unsigned int *lenp)
|
{
char *name;
unsigned int i;
if ((p = xdr_decode_string_inplace(p, namp, lenp, NFS_MAXNAMLEN)) != NULL) {
for (i = 0, name = *namp; i < *lenp; i++, name++) {
if (*name == '\0' || *name == '/')
return NULL;
}
}
return p;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Initializes the USARTx peripheral Clock according to the specified parameters in the USART_ClockInitStruct . */
|
void USART_ClockInit(USART_Module *USARTx, USART_ClockInitType *USART_ClockInitStruct)
|
/* Initializes the USARTx peripheral Clock according to the specified parameters in the USART_ClockInitStruct . */
void USART_ClockInit(USART_Module *USARTx, USART_ClockInitType *USART_ClockInitStruct)
|
{
uint32_t tmpregister = 0x00;
assert_param(IS_USART_123_PERIPH(USARTx));
assert_param(IS_USART_CLOCK(USART_ClockInitStruct->Clock));
assert_param(IS_USART_CPOL(USART_ClockInitStruct->Polarity));
assert_param(IS_USART_CPHA(USART_ClockInitStruct->Phase));
assert_param(IS_USART_LASTBIT(USART_ClockInitStruct->LastBit));
tmpregister = USARTx->CTRL2;
tmpregister &= CTRL2_CLOCK_CLR_MASK;
tmpregister |= (uint32_t)USART_ClockInitStruct->Clock | USART_ClockInitStruct->Polarity
| USART_ClockInitStruct->Phase | USART_ClockInitStruct->LastBit;
USARTx->CTRL2 = (uint16_t)tmpregister;
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* Disable ir led driver gpio output(gpio 22 or 23) */
|
BL_Err_Type GLB_IR_LED_Driver_Output_Disable(GLB_GPIO_Type gpio)
|
/* Disable ir led driver gpio output(gpio 22 or 23) */
BL_Err_Type GLB_IR_LED_Driver_Output_Disable(GLB_GPIO_Type gpio)
|
{
uint32_t tmpVal = 0;
if (gpio == GLB_GPIO_PIN_22) {
tmpVal = BL_RD_REG(GLB_BASE, GLB_LED_DRIVER);
tmpVal = BL_SET_REG_BITS_VAL(tmpVal, GLB_LEDDRV_OUT_EN, BL_GET_REG_BITS_VAL(tmpVal, GLB_LEDDRV_OUT_EN) & ~1);
BL_WR_REG(GLB_BASE, GLB_LED_DRIVER, tmpVal);
} else if (gpio == GLB_GPIO_PIN_23) {
tmpVal = BL_RD_REG(GLB_BASE, GLB_LED_DRIVER);
tmpVal = BL_SET_REG_BITS_VAL(tmpVal, GLB_LEDDRV_OUT_EN, BL_GET_REG_BITS_VAL(tmpVal, GLB_LEDDRV_OUT_EN) & ~2);
BL_WR_REG(GLB_BASE, GLB_LED_DRIVER, tmpVal);
}
return SUCCESS;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* ADC0 Interrupt Handler.
If users want to user the ADC0 Callback feature, Users should promise that the ADC0 Handle in the vector table is ADCIntHandler. */
|
unsigned long ADC0IntFucntion(void *pvCBData, unsigned long ulEvent, unsigned long ulMsgParam, void *pvMsgData)
|
/* ADC0 Interrupt Handler.
If users want to user the ADC0 Callback feature, Users should promise that the ADC0 Handle in the vector table is ADCIntHandler. */
unsigned long ADC0IntFucntion(void *pvCBData, unsigned long ulEvent, unsigned long ulMsgParam, void *pvMsgData)
|
{
ADCIntClear(ADC1_BASE, ADC_INT_END_CONVERSION);
return 0;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Restore a terminal to the driver default state. */
|
static void tty_reset_termios(struct tty_struct *tty)
|
/* Restore a terminal to the driver default state. */
static void tty_reset_termios(struct tty_struct *tty)
|
{
mutex_lock(&tty->termios_mutex);
*tty->termios = tty->driver->init_termios;
tty->termios->c_ispeed = tty_termios_input_baud_rate(tty->termios);
tty->termios->c_ospeed = tty_termios_baud_rate(tty->termios);
mutex_unlock(&tty->termios_mutex);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.