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
|
|---|---|---|---|---|---|---|---|
/* select the sigma delta config return: sigma delta val */
|
static u32 pll_sigma_delta_val(u32 clkout_dco)
|
/* select the sigma delta config return: sigma delta val */
static u32 pll_sigma_delta_val(u32 clkout_dco)
|
{
u32 sig_val = 0;
sig_val = (clkout_dco + 225) / 250;
sig_val = sig_val << 24;
return sig_val;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Additionally, in the non-mode setting case, we'll tear down the AGP and DMA structures, since the kernel won't be using them, and clea up any GEM state. */
|
void i915_driver_lastclose(struct drm_device *dev)
|
/* Additionally, in the non-mode setting case, we'll tear down the AGP and DMA structures, since the kernel won't be using them, and clea up any GEM state. */
void i915_driver_lastclose(struct drm_device *dev)
|
{
drm_i915_private_t *dev_priv = dev->dev_private;
if (!dev_priv || drm_core_check_feature(dev, DRIVER_MODESET)) {
drm_fb_helper_restore();
return;
}
i915_gem_lastclose(dev);
if (dev_priv->agp_heap)
i915_mem_takedown(&(dev_priv->agp_heap));
i915_dma_cleanup(dev);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function is used to calculate month and day of month according to year and day of the year. */
|
static void rtc_calculate_mday(int year, int yday, int *mon, int *mday)
|
/* This function is used to calculate month and day of month according to year and day of the year. */
static void rtc_calculate_mday(int year, int yday, int *mon, int *mday)
|
{
int t_mon = -1, t_yday = yday + 1;
while(t_yday > 0){
t_mon ++;
t_yday -= days_in_month(t_mon, year);
}
*mon = t_mon;
*mday = t_yday + days_in_month(t_mon, year);
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* Toggles the LED at a fixed time interval. */
|
void LedToggle(void)
|
/* Toggles the LED at a fixed time interval. */
void LedToggle(void)
|
{
static unsigned char led_toggle_state = 0;
static unsigned long timer_counter_last = 0;
unsigned long timer_counter_now;
timer_counter_now = TimerGet();
if ( (timer_counter_now - timer_counter_last) < LED_TOGGLE_MS)
{
return;
}
if (led_toggle_state == 0)
{
led_toggle_state = 1;
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_9, GPIO_PIN_SET);
}
else
{
led_toggle_state = 0;
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_9, GPIO_PIN_RESET);
}
timer_counter_last = timer_counter_now;
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* Writes a packet whose byte number is len into the Tx FIFO associated with the EP. */
|
void usb_wrpkt(LL_USB_TypeDef *USBx, uint8_t *src, uint8_t ch_ep_num, uint16_t len, uint8_t u8DmaEn)
|
/* Writes a packet whose byte number is len into the Tx FIFO associated with the EP. */
void usb_wrpkt(LL_USB_TypeDef *USBx, uint8_t *src, uint8_t ch_ep_num, uint16_t len, uint8_t u8DmaEn)
|
{
__IO uint32_t u32pAddr;
__IO uint32_t *fifo;
uint32_t u32Count32b;
uint32_t u32Tmp;
if (u8DmaEn == 0U) {
u32Count32b = (len + 3UL);
u32Count32b = u32Count32b >> 2U;
fifo = USBx->DFIFO[ch_ep_num];
u32Tmp = 0UL;
while (u32Tmp < u32Count32b) {
WRITE_REG32(*fifo, *((uint32_t *)src));
u32pAddr = (uint32_t)src;
src = (uint8_t *)(u32pAddr + 4U);
u32Tmp++;
}
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Converts a device node to its string representation. */
|
CHAR16* EFIAPI ConvertDeviceNodeToText(IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts)
|
/* Converts a device node to its string representation. */
CHAR16* EFIAPI ConvertDeviceNodeToText(IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts)
|
{
return UefiDevicePathLibConvertDeviceNodeToText (DeviceNode, DisplayOnly, AllowShortcuts);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Get platform Redfish host interface protocol data. Caller should pass NULL in ProtocolRecord to retrive the first protocol record. Then continuously pass previous ProtocolRecord for retrieving the next ProtocolRecord. */
|
EFI_STATUS RedfishPlatformHostInterfaceProtocolData(OUT MC_HOST_INTERFACE_PROTOCOL_RECORD **ProtocolRecord, IN UINT8 IndexOfProtocolData)
|
/* Get platform Redfish host interface protocol data. Caller should pass NULL in ProtocolRecord to retrive the first protocol record. Then continuously pass previous ProtocolRecord for retrieving the next ProtocolRecord. */
EFI_STATUS RedfishPlatformHostInterfaceProtocolData(OUT MC_HOST_INTERFACE_PROTOCOL_RECORD **ProtocolRecord, IN UINT8 IndexOfProtocolData)
|
{
MC_HOST_INTERFACE_PROTOCOL_RECORD *ThisProtocolRecord;
if (mRedfishOverIpProtocolData == 0) {
return EFI_NOT_FOUND;
}
if (IndexOfProtocolData == 0) {
ThisProtocolRecord = (MC_HOST_INTERFACE_PROTOCOL_RECORD *)AllocatePool (mRedfishProtocolDataSize + sizeof (MC_HOST_INTERFACE_PROTOCOL_RECORD) - 1);
ThisProtocolRecord->ProtocolType = MCHostInterfaceProtocolTypeRedfishOverIP;
ThisProtocolRecord->ProtocolTypeDataLen = mRedfishProtocolDataSize;
CopyMem ((VOID *)&ThisProtocolRecord->ProtocolTypeData, (VOID *)mRedfishOverIpProtocolData, mRedfishProtocolDataSize);
*ProtocolRecord = ThisProtocolRecord;
return EFI_SUCCESS;
}
return EFI_NOT_FOUND;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Return value: 0 on success / other on failure */
|
static int ibmvfc_send_crq(struct ibmvfc_host *vhost, u64 word1, u64 word2)
|
/* Return value: 0 on success / other on failure */
static int ibmvfc_send_crq(struct ibmvfc_host *vhost, u64 word1, u64 word2)
|
{
struct vio_dev *vdev = to_vio_dev(vhost->dev);
return plpar_hcall_norets(H_SEND_CRQ, vdev->unit_address, word1, word2);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Derive SHA384 HMAC-based Extract-and-Expand Key Derivation Function (HKDF). */
|
BOOLEAN EFIAPI CryptoServiceHkdfSha384ExtractAndExpand(IN CONST UINT8 *Key, IN UINTN KeySize, IN CONST UINT8 *Salt, IN UINTN SaltSize, IN CONST UINT8 *Info, IN UINTN InfoSize, OUT UINT8 *Out, IN UINTN OutSize)
|
/* Derive SHA384 HMAC-based Extract-and-Expand Key Derivation Function (HKDF). */
BOOLEAN EFIAPI CryptoServiceHkdfSha384ExtractAndExpand(IN CONST UINT8 *Key, IN UINTN KeySize, IN CONST UINT8 *Salt, IN UINTN SaltSize, IN CONST UINT8 *Info, IN UINTN InfoSize, OUT UINT8 *Out, IN UINTN OutSize)
|
{
return CALL_BASECRYPTLIB (Hkdf.Services.Sha384ExtractAndExpand, HkdfSha384ExtractAndExpand, (Key, KeySize, Salt, SaltSize, Info, InfoSize, Out, OutSize), FALSE);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* The user Entry Point for I2C host module. The user code starts with this function. */
|
EFI_STATUS EFIAPI InitializeI2cHost(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
|
/* The user Entry Point for I2C host module. The user code starts with this function. */
EFI_STATUS EFIAPI InitializeI2cHost(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
|
{
EFI_STATUS Status;
Status = EfiLibInstallDriverBindingComponentName2 (
ImageHandle,
SystemTable,
&gI2cHostDriverBinding,
ImageHandle,
&gI2cHostComponentName,
&gI2cHostComponentName2
);
ASSERT_EFI_ERROR (Status);
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Enables or disables the Internal High Speed oscillator (HSI). HSI can not be stopped if it is used directly or through the PLL as system clock. */
|
void RCC_HSICmd(FunctionalState NewState)
|
/* Enables or disables the Internal High Speed oscillator (HSI). HSI can not be stopped if it is used directly or through the PLL as system clock. */
void RCC_HSICmd(FunctionalState NewState)
|
{
assert_param(IS_FUNCTIONAL_STATE(NewState));
if(NewState==ENABLE)
{
RCC->CR |= 0x01;
}
else
{
RCC->CR &= 0xfffffffe;
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Returns the string name corresponding to the given AirpcapLinkType, or NULL in case of error. */
|
const gchar* airpcap_get_link_name(AirpcapLinkType lt)
|
/* Returns the string name corresponding to the given AirpcapLinkType, or NULL in case of error. */
const gchar* airpcap_get_link_name(AirpcapLinkType lt)
|
{
if (lt == AIRPCAP_LT_802_11) {
return AIRPCAP_LINK_TYPE_NAME_802_11_ONLY;
}else if (lt == AIRPCAP_LT_802_11_PLUS_RADIO) {
return AIRPCAP_LINK_TYPE_NAME_802_11_PLUS_RADIO;
}else if (lt == AIRPCAP_LT_802_11_PLUS_PPI) {
return AIRPCAP_LINK_TYPE_NAME_802_11_PLUS_PPI;
}else if (lt == AIRPCAP_LT_UNKNOWN) {
return AIRPCAP_LINK_TYPE_NAME_UNKNOWN;
}
return NULL;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Set lptimer Counter.
Set the value of a lptimer counter. */
|
void lptimer_set_counter(uint32_t lptimer_peripheral, uint16_t count)
|
/* Set lptimer Counter.
Set the value of a lptimer counter. */
void lptimer_set_counter(uint32_t lptimer_peripheral, uint16_t count)
|
{
LPTIM_CNT(lptimer_peripheral) = count;
}
|
libopencm3/libopencm3
|
C++
|
GNU General Public License v3.0
| 2,931
|
/* Function for handling the BLE_GAP_EVT_DISCONNECTED event from the S110 SoftDevice. */
|
static void on_disconnect(ble_dfu_t *p_dfu, ble_evt_t *p_ble_evt)
|
/* Function for handling the BLE_GAP_EVT_DISCONNECTED event from the S110 SoftDevice. */
static void on_disconnect(ble_dfu_t *p_dfu, ble_evt_t *p_ble_evt)
|
{
p_dfu->conn_handle = BLE_CONN_HANDLE_INVALID;
}
|
labapart/polymcu
|
C++
| null | 201
|
/* Enables or Disables the specified interrupts of the Timer.
The */
|
void TimerIntEnable(unsigned long ulBase, unsigned long ulIntFlags)
|
/* Enables or Disables the specified interrupts of the Timer.
The */
void TimerIntEnable(unsigned long ulBase, unsigned long ulIntFlags)
|
{
xASSERT((ulBase == TIMER1_BASE) || (ulBase == TIMER0_BASE));
xASSERT((ulIntFlags == TIMER_INT_CH0CC) || (ulIntFlags == TIMER_INT_CH1CC) ||
(ulIntFlags == TIMER_INT_CH2CC) || (ulIntFlags == TIMER_INT_CH3CC) ||
(ulIntFlags == TIMER_INT_UEV1) || (ulIntFlags == TIMER_INT_TEV));
xHWREG(ulBase + TIMER_ICTR) |= ulIntFlags;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Convert an integer from unsigned little-endian encoding to a sequence of 30-bit words in little-endian order. The final "partial" word is returned. */
|
static uint32_t le8_to_le30(uint32_t *dst, const unsigned char *src, size_t len)
|
/* Convert an integer from unsigned little-endian encoding to a sequence of 30-bit words in little-endian order. The final "partial" word is returned. */
static uint32_t le8_to_le30(uint32_t *dst, const unsigned char *src, size_t len)
|
{
uint32_t acc;
int acc_len;
acc = 0;
acc_len = 0;
while (len -- > 0) {
uint32_t b;
b = *src ++;
if (acc_len < 22) {
acc |= b << acc_len;
acc_len += 8;
} else {
*dst ++ = (acc | (b << acc_len)) & 0x3FFFFFFF;
acc = b >> (30 - acc_len);
acc_len -= 22;
}
}
return acc;
}
|
RavenSystem/esp-homekit-devices
|
C++
|
Other
| 2,577
|
/* Flushes all PCI posted write transactions from a PCI host bridge to system memory. */
|
EFI_STATUS EFIAPI PciIoFlush(IN EFI_PCI_IO_PROTOCOL *This)
|
/* Flushes all PCI posted write transactions from a PCI host bridge to system memory. */
EFI_STATUS EFIAPI PciIoFlush(IN EFI_PCI_IO_PROTOCOL *This)
|
{
EFI_STATUS Status;
PCI_IO_DEVICE *PciIoDevice;
PciIoDevice = PCI_IO_DEVICE_FROM_PCI_IO_THIS (This);
Status = PciIoDevice->PciRootBridgeIo->Flush (
PciIoDevice->PciRootBridgeIo
);
if (EFI_ERROR (Status)) {
REPORT_STATUS_CODE_WITH_DEVICE_PATH (
EFI_ERROR_CODE | EFI_ERROR_MINOR,
EFI_IO_BUS_PCI | EFI_IOB_EC_CONTROLLER_ERROR,
PciIoDevice->DevicePath
);
}
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* dccp_sample_rtt - Validate and finalise computation of RTT sample @delta: number of microseconds between packet and acknowledgment The routine is kept generic to work in different contexts. It should be called immediately when the ACK used for the RTT sample arrives. */
|
u32 dccp_sample_rtt(struct sock *sk, long delta)
|
/* dccp_sample_rtt - Validate and finalise computation of RTT sample @delta: number of microseconds between packet and acknowledgment The routine is kept generic to work in different contexts. It should be called immediately when the ACK used for the RTT sample arrives. */
u32 dccp_sample_rtt(struct sock *sk, long delta)
|
{
delta -= dccp_sk(sk)->dccps_options_received.dccpor_elapsed_time * 10;
if (unlikely(delta <= 0)) {
DCCP_WARN("unusable RTT sample %ld, using min\n", delta);
return DCCP_SANE_RTT_MIN;
}
if (unlikely(delta > DCCP_SANE_RTT_MAX)) {
DCCP_WARN("RTT sample %ld too large, using max\n", delta);
return DCCP_SANE_RTT_MAX;
}
return delta;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* set_baud sets the baud rate to the rate defined by baudcode */
|
static void set_baud(struct tty_struct *tty, speed_t baudrate)
|
/* set_baud sets the baud rate to the rate defined by baudcode */
static void set_baud(struct tty_struct *tty, speed_t baudrate)
|
{
struct ktermios old_termios;
mutex_lock(&tty->termios_mutex);
old_termios =*(tty->termios);
tty_encode_baud_rate(tty, baudrate, baudrate);
tty->ops->set_termios(tty, &old_termios);
mutex_unlock(&tty->termios_mutex);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). */
|
UINT16 EFIAPI PciWrite16(IN UINTN Address, IN UINT16 Value)
|
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). */
UINT16 EFIAPI PciWrite16(IN UINTN Address, IN UINT16 Value)
|
{
ASSERT_INVALID_PCI_ADDRESS (Address, 1);
return (UINT16)SmmPciLibPciRootBridgeIoWriteWorker (Address, EfiPciWidthUint16, Value);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* LSM hook implementation that frees xfrm_state security information. */
|
void selinux_xfrm_state_free(struct xfrm_state *x)
|
/* LSM hook implementation that frees xfrm_state security information. */
void selinux_xfrm_state_free(struct xfrm_state *x)
|
{
struct xfrm_sec_ctx *ctx = x->security;
kfree(ctx);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Enables or disables the MAC Magic Packet Detection. */
|
void ETH_EnableMagicPacketDetection(FunctionalState Cmd)
|
/* Enables or disables the MAC Magic Packet Detection. */
void ETH_EnableMagicPacketDetection(FunctionalState Cmd)
|
{
assert_param(IS_FUNCTIONAL_STATE(Cmd));
if (Cmd != DISABLE)
{
ETH->MACPMTCTRLSTS |= ETH_MACPMTCTRLSTS_MGKPKTEN;
}
else
{
ETH->MACPMTCTRLSTS &= ~ETH_MACPMTCTRLSTS_MGKPKTEN;
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Get the target bus timing to set on the link. This function will try to select highest bus timing supported by card, controller and the driver. */
|
SD_MMC_BUS_MODE SdGetTargetBusTiming(IN SD_MMC_HC_PRIVATE_DATA *Private, IN UINT8 SlotIndex, IN UINT8 CardSupportedBusTimings, IN BOOLEAN IsInUhsI)
|
/* Get the target bus timing to set on the link. This function will try to select highest bus timing supported by card, controller and the driver. */
SD_MMC_BUS_MODE SdGetTargetBusTiming(IN SD_MMC_HC_PRIVATE_DATA *Private, IN UINT8 SlotIndex, IN UINT8 CardSupportedBusTimings, IN BOOLEAN IsInUhsI)
|
{
SD_MMC_BUS_MODE BusTiming;
if (IsInUhsI) {
BusTiming = SdMmcUhsSdr104;
} else {
BusTiming = SdMmcSdHs;
}
while (BusTiming > SdMmcSdDs) {
if (SdIsBusTimingSupported (Private, SlotIndex, CardSupportedBusTimings, IsInUhsI, BusTiming)) {
break;
}
BusTiming--;
}
return BusTiming;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Can be used to emulate code execution time. */
|
void posix_cpu_hold(uint32_t usec_to_waste)
|
/* Can be used to emulate code execution time. */
void posix_cpu_hold(uint32_t usec_to_waste)
|
{
bs_time_t time_start;
int64_t to_wait = usec_to_waste;
while (to_wait > 0) {
time_start = nsi_hws_get_time();
nhw_fake_timer_wake_in_time(CONFIG_NATIVE_SIMULATOR_MCU_N, time_start + to_wait);
posix_change_cpu_state_and_wait(true);
to_wait -= nsi_hws_get_time() - time_start;
posix_irq_handler();
}
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* @chip: address of the chip which is to be written @addr: i2c data address within the chip @alen: length of the i2c data address (1..2 bytes) @buffer: where to find the data to be written @len: how much byte do we want to read */
|
int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
|
/* @chip: address of the chip which is to be written @addr: i2c data address within the chip @alen: length of the i2c data address (1..2 bytes) @buffer: where to find the data to be written @len: how much byte do we want to read */
int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
|
{
u8 addr_bytes[4];
addr_bytes[0] = (addr >> 0) & 0xFF;
addr_bytes[1] = (addr >> 8) & 0xFF;
addr_bytes[2] = (addr >> 16) & 0xFF;
addr_bytes[3] = (addr >> 24) & 0xFF;
return __i2c_write(base_glob, chip, addr_bytes, alen, buffer, len);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Parse the ACPI XSDT for later access by sfi_acpi_table_parse(). */
|
static int __init sfi_acpi_parse_xsdt(struct sfi_table_header *th)
|
/* Parse the ACPI XSDT for later access by sfi_acpi_table_parse(). */
static int __init sfi_acpi_parse_xsdt(struct sfi_table_header *th)
|
{
struct sfi_table_key key = SFI_ANY_KEY;
int tbl_cnt, i;
void *ret;
xsdt_va = (struct acpi_table_xsdt *)th;
tbl_cnt = XSDT_GET_NUM_ENTRIES(xsdt_va, u64);
for (i = 0; i < tbl_cnt; i++) {
ret = sfi_check_table(xsdt_va->table_offset_entry[i], &key);
if (IS_ERR(ret)) {
disable_sfi();
return -1;
}
}
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT(). */
|
VOID* EFIAPI InvalidateDataCacheRange(IN VOID *Address, IN UINTN Length)
|
/* If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT(). */
VOID* EFIAPI InvalidateDataCacheRange(IN VOID *Address, IN UINTN Length)
|
{
ASSERT (Length <= MAX_ADDRESS - (UINTN)Address + 1);
ASSERT (FALSE);
return Address;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Pool allocation service. Before permanent memory is discovered, the pool will be allocated in the heap in temporary memory. Generally, the size of the heap in temporary memory does not exceed 64K, so the biggest pool size could be allocated is 64K. */
|
EFI_STATUS EFIAPI PeiAllocatePool(IN CONST EFI_PEI_SERVICES **PeiServices, IN UINTN Size, OUT VOID **Buffer)
|
/* Pool allocation service. Before permanent memory is discovered, the pool will be allocated in the heap in temporary memory. Generally, the size of the heap in temporary memory does not exceed 64K, so the biggest pool size could be allocated is 64K. */
EFI_STATUS EFIAPI PeiAllocatePool(IN CONST EFI_PEI_SERVICES **PeiServices, IN UINTN Size, OUT VOID **Buffer)
|
{
EFI_STATUS Status;
EFI_HOB_MEMORY_POOL *Hob;
if (Size > (0xFFF8 - sizeof (EFI_HOB_MEMORY_POOL))) {
return EFI_OUT_OF_RESOURCES;
}
Status = PeiServicesCreateHob (
EFI_HOB_TYPE_MEMORY_POOL,
(UINT16)(sizeof (EFI_HOB_MEMORY_POOL) + Size),
(VOID **)&Hob
);
ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
*Buffer = NULL;
} else {
*Buffer = Hob + 1;
}
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* LOCKING: called with the pending list lock held. */
|
static void asd_swap_head_scb(struct asd_ha_struct *asd_ha, struct asd_ascb *ascb)
|
/* LOCKING: called with the pending list lock held. */
static void asd_swap_head_scb(struct asd_ha_struct *asd_ha, struct asd_ascb *ascb)
|
{
struct asd_seq_data *seq = &asd_ha->seq;
struct asd_ascb *last = list_entry(ascb->list.prev,
struct asd_ascb,
list);
struct asd_dma_tok t = ascb->dma_scb;
memcpy(seq->next_scb.vaddr, ascb->scb, sizeof(*ascb->scb));
ascb->dma_scb = seq->next_scb;
ascb->scb = ascb->dma_scb.vaddr;
seq->next_scb = t;
last->scb->header.next_scb =
cpu_to_le64(((u64)seq->next_scb.dma_handle));
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Writes a value to an extended PHY register in MMD address space. */
|
void EMACPHYMMDWrite(uint32_t ui32Base, uint8_t ui8PhyAddr, uint16_t ui16RegAddr, uint16_t ui16Data)
|
/* Writes a value to an extended PHY register in MMD address space. */
void EMACPHYMMDWrite(uint32_t ui32Base, uint8_t ui8PhyAddr, uint16_t ui16RegAddr, uint16_t ui16Data)
|
{
ASSERT(ui8PhyAddr < 32);
EMACPHYWrite(ui32Base, ui8PhyAddr, EPHY_REGCTL, DEV_ADDR(ui16RegAddr));
EMACPHYWrite(ui32Base, ui8PhyAddr, EPHY_ADDAR, REG_ADDR(ui16RegAddr));
EMACPHYWrite(ui32Base, ui8PhyAddr, EPHY_REGCTL,
(0x4000 | DEV_ADDR(ui16RegAddr)));
EMACPHYWrite(ui32Base, ui8PhyAddr, EPHY_REGCTL, ui16Data);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Return an allocated memory block back to a Memory Pool. */
|
__WEAK uint32_t osRtxMemoryFree(void *mem, void *block)
|
/* Return an allocated memory block back to a Memory Pool. */
__WEAK uint32_t osRtxMemoryFree(void *mem, void *block)
|
{
EvrRtxMemoryFree(mem, block, 0U);
return 0U;
}
ptr = MemBlockPtr(block, 0U);
ptr--;
p_prev = NULL;
p = MemBlockPtr(mem, sizeof(mem_head_t));
while (p != ptr) {
p_prev = p;
p = p->next;
if (p == NULL) {
EvrRtxMemoryFree(mem, block, 0U);
return 0U;
}
}
(MemHeadPtr(mem))->used -= p->info & MB_INFO_LEN_MASK;
if (p_prev == NULL) {
p->info = 0U;
} else {
p_prev->next = p->next;
}
EvrRtxMemoryFree(mem, block, 1U);
return 1U;
}
|
ARMmbed/DAPLink
|
C++
|
Apache License 2.0
| 2,140
|
/* If String is NULL, then ASSERT(). If PcdMaximumAsciiStringLength is not zero and String contains more than PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator, then ASSERT(). */
|
UINTN EFIAPI AsciiStrSize(IN CONST CHAR8 *String)
|
/* If String is NULL, then ASSERT(). If PcdMaximumAsciiStringLength is not zero and String contains more than PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator, then ASSERT(). */
UINTN EFIAPI AsciiStrSize(IN CONST CHAR8 *String)
|
{
return (AsciiStrLen (String) + 1) * sizeof (*String);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* DMAMUX Set DMA Request Synchronization Event Polarity.
Set DMAMUX request synchronization input signal polarity (dmamux_cxcr_spol) for a given DMA channel. */
|
void dmamux_set_dma_request_sync_pol(uint32_t dmamux, uint8_t channel, uint8_t polarity)
|
/* DMAMUX Set DMA Request Synchronization Event Polarity.
Set DMAMUX request synchronization input signal polarity (dmamux_cxcr_spol) for a given DMA channel. */
void dmamux_set_dma_request_sync_pol(uint32_t dmamux, uint8_t channel, uint8_t polarity)
|
{
uint32_t reg32 = DMAMUX_CxCR(dmamux, channel);
reg32 &= ~(DMAMUX_CxCR_SPOL_MASK << DMAMUX_CxCR_SPOL_SHIFT);
reg32 |= ((polarity & DMAMUX_CxCR_SPOL_MASK) << DMAMUX_CxCR_SPOL_SHIFT);
DMAMUX_CxCR(dmamux, channel) = reg32;
}
|
libopencm3/libopencm3
|
C++
|
GNU General Public License v3.0
| 2,931
|
/* Configures clocks, LCD, port pints, etc. necessary to execute this demo. */
|
static void prvSetupHardware(void)
|
/* Configures clocks, LCD, port pints, etc. necessary to execute this demo. */
static void prvSetupHardware(void)
|
{
unsigned long ulCPU_Clock_KHz = ( configCPU_CLOCK_HZ / 1000UL );
halBoardInit();
LFXT_Start( XT1DRIVE_0 );
Init_FLL_Settle( ( unsigned short ) ulCPU_Clock_KHz, 488 );
halButtonsInit( BUTTON_ALL );
halButtonsInterruptEnable( BUTTON_SELECT );
halLcdInit();
halLcdSetContrast( 100 );
halLcdClearScreen();
halLcdPrintLine( " www.FreeRTOS.org", 0, OVERWRITE_TEXT );
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* This function is called every time an UBI volume is re-size. It changes the corresponding fake MTD device size. This function returns zero in case of success and a negative error code in case of error. */
|
static int gluebi_resized(struct ubi_volume_info *vi)
|
/* This function is called every time an UBI volume is re-size. It changes the corresponding fake MTD device size. This function returns zero in case of success and a negative error code in case of error. */
static int gluebi_resized(struct ubi_volume_info *vi)
|
{
struct gluebi_device *gluebi;
mutex_lock(&devices_mutex);
gluebi = find_gluebi_nolock(vi->ubi_num, vi->vol_id);
if (!gluebi) {
mutex_unlock(&devices_mutex);
err_msg("got update notification for unknown UBI device %d "
"volume %d", vi->ubi_num, vi->vol_id);
return -ENOENT;
}
gluebi->mtd.size = vi->used_bytes;
mutex_unlock(&devices_mutex);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Casey says that CIPSO is good enough for now. It can be used to effect. It can also be abused to effect when necessary. Appologies to the TSIG group in general and GW in particular. */
|
static void smack_to_secattr(char *smack, struct netlbl_lsm_secattr *nlsp)
|
/* Casey says that CIPSO is good enough for now. It can be used to effect. It can also be abused to effect when necessary. Appologies to the TSIG group in general and GW in particular. */
static void smack_to_secattr(char *smack, struct netlbl_lsm_secattr *nlsp)
|
{
struct smack_cipso cipso;
int rc;
nlsp->domain = smack;
nlsp->flags = NETLBL_SECATTR_DOMAIN | NETLBL_SECATTR_MLS_LVL;
rc = smack_to_cipso(smack, &cipso);
if (rc == 0) {
nlsp->attr.mls.lvl = cipso.smk_level;
smack_set_catset(cipso.smk_catset, nlsp);
} else {
nlsp->attr.mls.lvl = smack_cipso_direct;
smack_set_catset(smack, nlsp);
}
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Allocate and map the receive buffer, unless it is already allocated. */
|
static int sa1100_irda_rx_alloc(struct sa1100_irda *si)
|
/* Allocate and map the receive buffer, unless it is already allocated. */
static int sa1100_irda_rx_alloc(struct sa1100_irda *si)
|
{
if (si->rxskb)
return 0;
si->rxskb = alloc_skb(HPSIR_MAX_RXLEN + 1, GFP_ATOMIC);
if (!si->rxskb) {
printk(KERN_ERR "sa1100_ir: out of memory for RX SKB\n");
return -ENOMEM;
}
skb_reserve(si->rxskb, 1);
si->rxbuf_dma = dma_map_single(si->dev, si->rxskb->data,
HPSIR_MAX_RXLEN,
DMA_FROM_DEVICE);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Gets a data element from the SSI receive FIFO. */
|
void SSIDataGet(uint32_t ui32Base, uint32_t *pui32Data)
|
/* Gets a data element from the SSI receive FIFO. */
void SSIDataGet(uint32_t ui32Base, uint32_t *pui32Data)
|
{
ASSERT(_SSIBaseValid(ui32Base));
while(!(HWREG(ui32Base + SSI_O_SR) & SSI_SR_RNE))
{
}
*pui32Data = HWREG(ui32Base + SSI_O_DR);
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* For a dissector table, print on the stream described by output, its short name (which is what's used in the "-d" option) and its descriptive name. */
|
static void display_dissector_table_names(const char *table_name, const char *ui_name, gpointer output)
|
/* For a dissector table, print on the stream described by output, its short name (which is what's used in the "-d" option) and its descriptive name. */
static void display_dissector_table_names(const char *table_name, const char *ui_name, gpointer output)
|
{
fprintf((FILE *)output, "\t%s (%s)\n", table_name, ui_name);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* This function is executed in case of error occurrence. */
|
static void Error_Handler(void)
|
/* This function is executed in case of error occurrence. */
static void Error_Handler(void)
|
{
BSP_LED_Off(LED1);
while(1)
{
}
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* SPI MSP De-Initialization This function frees the hardware resources used in this example: */
|
void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi)
|
/* SPI MSP De-Initialization This function frees the hardware resources used in this example: */
void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi)
|
{
SPIx_FORCE_RESET();
SPIx_RELEASE_RESET();
HAL_GPIO_DeInit(SPIx_SCK_GPIO_PORT, SPIx_SCK_PIN);
HAL_GPIO_DeInit(SPIx_MISO_GPIO_PORT, SPIx_MISO_PIN);
HAL_GPIO_DeInit(SPIx_MOSI_GPIO_PORT, SPIx_MOSI_PIN);
HAL_NVIC_DisableIRQ(SPIx_IRQn);
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* USB String descriptors can contain at most 126 characters; input strings longer than that are truncated. */
|
static unsigned ascii2desc(char const *s, u8 *buf, unsigned len)
|
/* USB String descriptors can contain at most 126 characters; input strings longer than that are truncated. */
static unsigned ascii2desc(char const *s, u8 *buf, unsigned len)
|
{
unsigned n, t = 2 + 2*strlen(s);
if (t > 254)
t = 254;
if (len > t)
len = t;
t += USB_DT_STRING << 8;
n = len;
while (n--) {
*buf++ = t;
if (!n--)
break;
*buf++ = t >> 8;
t = (unsigned char)*s++;
}
return len;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Function for updating the TEMP field of TLM. */
|
static void update_temp(void)
|
/* Function for updating the TEMP field of TLM. */
static void update_temp(void)
|
{
int32_t temp;
(void)sd_temp_get(&temp);
int16_t temp_new = (int16_t) temp;
m_tlm.temp[0] = (uint8_t)((temp_new >> 2) & 0xFFUL);
m_tlm.temp[1] = (uint8_t)((temp_new << 6) & 0xFFUL);
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Converts a text device path node to PCI root device path structure. */
|
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextPciRoot(CHAR16 *TextDeviceNode)
|
/* Converts a text device path node to PCI root device path structure. */
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextPciRoot(CHAR16 *TextDeviceNode)
|
{
return ConvertFromTextAcpi (TextDeviceNode, 0x0a03);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Finds start offset of desired category of transitions. Returns the desired start offset. */
|
static int llc_find_offset(int state, int ev_type)
|
/* Finds start offset of desired category of transitions. Returns the desired start offset. */
static int llc_find_offset(int state, int ev_type)
|
{
int rc = 0;
switch (ev_type) {
case LLC_CONN_EV_TYPE_PRIM:
rc = llc_offset_table[state][0]; break;
case LLC_CONN_EV_TYPE_PDU:
rc = llc_offset_table[state][4]; break;
case LLC_CONN_EV_TYPE_SIMPLE:
rc = llc_offset_table[state][1]; break;
case LLC_CONN_EV_TYPE_P_TMR:
case LLC_CONN_EV_TYPE_ACK_TMR:
case LLC_CONN_EV_TYPE_REJ_TMR:
case LLC_CONN_EV_TYPE_BUSY_TMR:
rc = llc_offset_table[state][3]; break;
}
return rc;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Function for getting the sequence number of the next reliable packet expected. */
|
static __INLINE uint8_t packet_number_expected_get(void)
|
/* Function for getting the sequence number of the next reliable packet expected. */
static __INLINE uint8_t packet_number_expected_get(void)
|
{
return (uint8_t) m_packet_expected_seq_number;
}
|
labapart/polymcu
|
C++
| null | 201
|
/* Disables all the endpoints for the interface's current altsetting. */
|
void usb_disable_interface(struct usb_host_virt_dev *dev, struct usb_interface *intf)
|
/* Disables all the endpoints for the interface's current altsetting. */
void usb_disable_interface(struct usb_host_virt_dev *dev, struct usb_interface *intf)
|
{
struct usb_host_virt_interface *alt = intf->cur_altsetting;
int i;
for (i = 0; i < alt->desc.bNumEndpoints; ++i)
{
usb_disable_endpoint(dev, alt->endpoint[i].desc.bEndpointAddress);
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* allocates a mac descriptor from the pool
Allocates a mac descriptor and resets its value. This function is not used directly, instead */
|
IX_ETH_DB_PRIVATE MacDescriptor * ixEthDBPoolAllocMacDescriptor(void)
|
/* allocates a mac descriptor from the pool
Allocates a mac descriptor and resets its value. This function is not used directly, instead */
IX_ETH_DB_PRIVATE MacDescriptor * ixEthDBPoolAllocMacDescriptor(void)
|
{
MacDescriptor *allocatedDescriptor = NULL;
if (macPool != NULL)
{
LOCK_MAC_POOL;
allocatedDescriptor = macPool;
macPool = macPool->nextFree;
UNLOCK_MAC_POOL;
memset(allocatedDescriptor, 0, sizeof(MacDescriptor));
}
return allocatedDescriptor;
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* Get the time from the Global Timer Counter Register. */
|
void XTime_GetTime(XTime *Xtime_Global)
|
/* Get the time from the Global Timer Counter Register. */
void XTime_GetTime(XTime *Xtime_Global)
|
{
u32 low;
u32 high;
do
{
high = Xil_In32(GLOBAL_TMR_BASEADDR + GTIMER_COUNTER_UPPER_OFFSET);
low = Xil_In32(GLOBAL_TMR_BASEADDR + GTIMER_COUNTER_LOWER_OFFSET);
} while(Xil_In32(GLOBAL_TMR_BASEADDR + GTIMER_COUNTER_UPPER_OFFSET) != high);
*Xtime_Global = (((XTime) high) << 32U) | (XTime) low;
}
|
ua1arn/hftrx
|
C++
| null | 69
|
/* Return: 0 on success or error code in case of error */
|
int rsa_parse_priv_key(struct rsa_key *rsa_key, const void *key, unsigned int key_len)
|
/* Return: 0 on success or error code in case of error */
int rsa_parse_priv_key(struct rsa_key *rsa_key, const void *key, unsigned int key_len)
|
{
return asn1_ber_decoder(&rsaprivkey_decoder, rsa_key, key, key_len);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Round up a positive 64-bit value to the next whole power of two, and return the bit position of the highest bit set in the result. Equivalent to ceil(log2(x)). */
|
STATIC INTN HighBitSetRoundUp64(IN UINT64 Operand)
|
/* Round up a positive 64-bit value to the next whole power of two, and return the bit position of the highest bit set in the result. Equivalent to ceil(log2(x)). */
STATIC INTN HighBitSetRoundUp64(IN UINT64 Operand)
|
{
INTN HighBit;
HighBit = HighBitSet64 (Operand);
if (HighBit == -1) {
return HighBit;
}
if ((Operand & (Operand - 1)) != 0) {
++HighBit;
}
return (HighBit < 64) ? HighBit : -1;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This function retrieves the user readable name of a driver in the form of a Unicode string. If the driver specified by This has a user readable name in the language specified by Language, then a pointer to the driver name is returned in DriverName, and EFI_SUCCESS is returned. If the driver specified by This does not support the language specified by Language, then EFI_UNSUPPORTED is returned. */
|
EFI_STATUS EFIAPI EmmcDxeComponentNameGetDriverName(IN EFI_COMPONENT_NAME_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
|
/* This function retrieves the user readable name of a driver in the form of a Unicode string. If the driver specified by This has a user readable name in the language specified by Language, then a pointer to the driver name is returned in DriverName, and EFI_SUCCESS is returned. If the driver specified by This does not support the language specified by Language, then EFI_UNSUPPORTED is returned. */
EFI_STATUS EFIAPI EmmcDxeComponentNameGetDriverName(IN EFI_COMPONENT_NAME_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
|
{
return LookupUnicodeString2 (
Language,
This->SupportedLanguages,
mEmmcDxeDriverNameTable,
DriverName,
(BOOLEAN)(This == &gEmmcDxeComponentName)
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Report how many bytes the ldisc can send into the queue for the other device. */
|
static int pty_write_room(struct tty_struct *tty)
|
/* Report how many bytes the ldisc can send into the queue for the other device. */
static int pty_write_room(struct tty_struct *tty)
|
{
if (tty->stopped)
return 0;
return pty_space(tty->link);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Device enumeration step 4 Lets USB line in IDLE state during 100ms. */
|
static void uhc_enumeration_step4(void)
|
/* Device enumeration step 4 Lets USB line in IDLE state during 100ms. */
static void uhc_enumeration_step4(void)
|
{
uhc_dev_enum->speed = uhd_get_speed();
uhc_enable_timeout_callback(100, uhc_enumeration_step5);
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Usually drivers set the DMA timing at the point the set_dmamode call is made. Triflex however requires we load new timings on the transition or keep matching PIO/DMA pairs (ie MWDMA2/PIO4 etc). We load the DMA timings just before starting DMA and then restore the PIO timing when the DMA is finished. */
|
static void triflex_bmdma_start(struct ata_queued_cmd *qc)
|
/* Usually drivers set the DMA timing at the point the set_dmamode call is made. Triflex however requires we load new timings on the transition or keep matching PIO/DMA pairs (ie MWDMA2/PIO4 etc). We load the DMA timings just before starting DMA and then restore the PIO timing when the DMA is finished. */
static void triflex_bmdma_start(struct ata_queued_cmd *qc)
|
{
triflex_load_timing(qc->ap, qc->dev, qc->dev->dma_mode);
ata_bmdma_start(qc);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Returns: TRUE if the @drive contains volumes, FALSE otherwise. */
|
gboolean g_drive_has_volumes(GDrive *drive)
|
/* Returns: TRUE if the @drive contains volumes, FALSE otherwise. */
gboolean g_drive_has_volumes(GDrive *drive)
|
{
GDriveIface *iface;
g_return_val_if_fail (G_IS_DRIVE (drive), FALSE);
iface = G_DRIVE_GET_IFACE (drive);
return (* iface->has_volumes) (drive);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Attribute write call back for the Value V2 attribute. */
|
static ssize_t write_value_v2_5(struct bt_conn *conn, const struct bt_gatt_attr *attr, const void *buf, uint16_t len, uint16_t offset, uint8_t flags)
|
/* Attribute write call back for the Value V2 attribute. */
static ssize_t write_value_v2_5(struct bt_conn *conn, const struct bt_gatt_attr *attr, const void *buf, uint16_t len, uint16_t offset, uint8_t flags)
|
{
uint8_t *value = attr->user_data;
if (offset >= sizeof(value_v2_5_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
if (offset + len > sizeof(value_v2_5_value))
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
memcpy(value + offset, buf, len);
return len;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Get the status of the specified analog watchdog flag. */
|
en_flag_status_t ADC_AWD_GetStatus(const CM_ADC_TypeDef *ADCx, uint32_t u32Flag)
|
/* Get the status of the specified analog watchdog flag. */
en_flag_status_t ADC_AWD_GetStatus(const CM_ADC_TypeDef *ADCx, uint32_t u32Flag)
|
{
en_flag_status_t enStatus = RESET;
DDL_ASSERT(IS_ADC_AWD_FLAG(ADCx, u32Flag));
if (READ_REG32_BIT(ADCx->AWDSR, u32Flag) != 0U) {
enStatus = SET;
}
return enStatus;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* We do not use horrible macros here because we want to advance pointer by sizeof(size). */
|
void outsb(unsigned long addr, const void *src, unsigned long count)
|
/* We do not use horrible macros here because we want to advance pointer by sizeof(size). */
void outsb(unsigned long addr, const void *src, unsigned long count)
|
{
while (count) {
count -= 1;
outb(*(const char *)src, addr);
src += 1;
}
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Configure Rx Data Arbiter and credits for each traffic class. */
|
s32 ixgbe_dcb_config_rx_arbiter(struct ixgbe_hw *hw, struct ixgbe_dcb_config *dcb_config)
|
/* Configure Rx Data Arbiter and credits for each traffic class. */
s32 ixgbe_dcb_config_rx_arbiter(struct ixgbe_hw *hw, struct ixgbe_dcb_config *dcb_config)
|
{
s32 ret = 0;
if (hw->mac.type == ixgbe_mac_82598EB)
ret = ixgbe_dcb_config_rx_arbiter_82598(hw, dcb_config);
else if (hw->mac.type == ixgbe_mac_82599EB)
ret = ixgbe_dcb_config_rx_arbiter_82599(hw, dcb_config);
return ret;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Specifies work mode for the specified CAN unit. */
|
static void CAN_SetWorkMode(CM_CAN_TypeDef *CANx, uint8_t u8WorkMode)
|
/* Specifies work mode for the specified CAN unit. */
static void CAN_SetWorkMode(CM_CAN_TypeDef *CANx, uint8_t u8WorkMode)
|
{
uint8_t u8CFGSTAT = 0U;
uint8_t u8TCMD = 0U;
switch (u8WorkMode) {
case CAN_WORK_MD_SILENT:
u8TCMD = CAN_TCMD_LOM;
break;
case CAN_WORK_MD_ILB:
u8CFGSTAT = CAN_CFG_STAT_LBMI;
break;
case CAN_WORK_MD_ELB:
u8CFGSTAT = CAN_CFG_STAT_LBME;
break;
case CAN_WORK_MD_ELB_SILENT:
u8TCMD = CAN_TCMD_LOM;
u8CFGSTAT = CAN_CFG_STAT_LBME;
break;
case CAN_WORK_MD_NORMAL:
default:
break;
}
MODIFY_REG8(CANx->CFG_STAT, CAN_CFG_STAT_LBMI | CAN_CFG_STAT_LBME, u8CFGSTAT);
MODIFY_REG8(CANx->TCMD, CAN_TCMD_LOM, u8TCMD);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Find URL component for the device's deployment operations resource */
|
static int hawkbit_find_deployment_base(struct hawkbit_ctl_res *res, char *deployment_base)
|
/* Find URL component for the device's deployment operations resource */
static int hawkbit_find_deployment_base(struct hawkbit_ctl_res *res, char *deployment_base)
|
{
const char *href;
const char *helper;
size_t len;
href = res->_links.deploymentBase.href;
if (!href) {
*deployment_base = '\0';
return 0;
}
LOG_DBG("_links.%s.href=%s", "deploymentBase", href);
helper = strstr(href, "deploymentBase/");
if (!helper) {
LOG_ERR("Missing deploymentBase/ in href %s", href);
return -EINVAL;
}
len = strlen(helper);
if (len > DEPLOYMENT_BASE_SIZE - 1) {
LOG_ERR("deploymentBase %s is too big (len %zu, max %zu)", helper, len,
DEPLOYMENT_BASE_SIZE - 1);
return -ENOMEM;
}
strncpy(deployment_base, helper, DEPLOYMENT_BASE_SIZE);
return 0;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* adds or removes a VLAN from a VLAN set */
|
IX_ETH_DB_PRIVATE void ixEthDBLocalVlanMembershipChange(UINT32 vlanID, IxEthDBVlanSet table, UINT32 action)
|
/* adds or removes a VLAN from a VLAN set */
IX_ETH_DB_PRIVATE void ixEthDBLocalVlanMembershipChange(UINT32 vlanID, IxEthDBVlanSet table, UINT32 action)
|
{
UINT32 setOffset;
setOffset = VLAN_SET_OFFSET(vlanID);
if (action == ADD_VLAN)
{
table[setOffset] |= 1 << VLAN_SET_MASK(vlanID);
}
else if (action == REMOVE_VLAN)
{
table[setOffset] &= ~(1 << VLAN_SET_MASK(vlanID));
}
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* This function handles External line 2 interrupt request. */
|
void EXTI2_IRQHandler(void)
|
/* This function handles External line 2 interrupt request. */
void EXTI2_IRQHandler(void)
|
{
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_2);
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* param base eDMA peripheral base address. param channel eDMA channel number. param config A pointer to the minor offset configuration structure. */
|
void EDMA_SetMinorOffsetConfig(EDMA_Type *base, uint32_t channel, const edma_minor_offset_config_t *config)
|
/* param base eDMA peripheral base address. param channel eDMA channel number. param config A pointer to the minor offset configuration structure. */
void EDMA_SetMinorOffsetConfig(EDMA_Type *base, uint32_t channel, const edma_minor_offset_config_t *config)
|
{
assert(channel < (uint32_t)FSL_FEATURE_EDMA_MODULE_CHANNEL(base));
assert(config != NULL);
uint32_t tmpreg;
tmpreg = EDMA_TCD_BASE(base, channel)->NBYTES;
tmpreg &= ~(DMA_NBYTES_MLOFFYES_SMLOE_MASK | DMA_NBYTES_MLOFFYES_DMLOE_MASK | DMA_NBYTES_MLOFFYES_MLOFF_MASK);
tmpreg |=
(DMA_NBYTES_MLOFFYES_SMLOE(config->enableSrcMinorOffset) |
DMA_NBYTES_MLOFFYES_DMLOE(config->enableDestMinorOffset) | DMA_NBYTES_MLOFFYES_MLOFF(config->minorOffset));
EDMA_TCD_BASE(base, channel)->NBYTES = tmpreg;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Remove a SHELL_FILE_HANDLE from the list of SHELL_FILE_HANDLES. */
|
BOOLEAN EFIAPI ShellFileHandleRemove(IN CONST SHELL_FILE_HANDLE Handle)
|
/* Remove a SHELL_FILE_HANDLE from the list of SHELL_FILE_HANDLES. */
BOOLEAN EFIAPI ShellFileHandleRemove(IN CONST SHELL_FILE_HANDLE Handle)
|
{
BUFFER_LIST *Node;
for (Node = (BUFFER_LIST *)GetFirstNode (&mFileHandleList.Link)
; !IsNull (&mFileHandleList.Link, &Node->Link)
; Node = (BUFFER_LIST *)GetNextNode (&mFileHandleList.Link, &Node->Link)
)
{
if ((Node->Buffer) && (((SHELL_COMMAND_FILE_HANDLE *)Node->Buffer)->FileHandle == Handle)) {
RemoveEntryList (&Node->Link);
SHELL_FREE_NON_NULL (((SHELL_COMMAND_FILE_HANDLE *)Node->Buffer)->Path);
SHELL_FREE_NON_NULL (Node->Buffer);
SHELL_FREE_NON_NULL (Node);
return (TRUE);
}
}
return (FALSE);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Similar to unmap_kernel_range_noflush() but flushes vcache before the unmapping and tlb after. */
|
void unmap_kernel_range(unsigned long addr, unsigned long size)
|
/* Similar to unmap_kernel_range_noflush() but flushes vcache before the unmapping and tlb after. */
void unmap_kernel_range(unsigned long addr, unsigned long size)
|
{
unsigned long end = addr + size;
flush_cache_vunmap(addr, end);
vunmap_page_range(addr, end);
flush_tlb_kernel_range(addr, end);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Fills each dmaConfig member with its default value. */
|
void DMA_ConfigStructInit(DMA_Config_T *dmaConfig)
|
/* Fills each dmaConfig member with its default value. */
void DMA_ConfigStructInit(DMA_Config_T *dmaConfig)
|
{
dmaConfig->direction = DMA_DIR_PERIPHERAL;
dmaConfig->circular = DMA_CIRCULAR_DISABLE;
dmaConfig->memoryTomemory = DMA_M2M_DISABLE;
dmaConfig->priority = DMA_PRIORITY_LEVEL_LOW;
dmaConfig->memoryInc = DMA_MEMORY_INC_DISABLE;
dmaConfig->peripheralInc = DMA_PERIPHERAL_INC_DISABLE;
dmaConfig->memoryDataSize = DMA_MEMORY_DATASIZE_BYTE;
dmaConfig->peripheralDataSize = DMA_PERIPHERAL_DATASIZE_BYTE;
dmaConfig->bufferSize = 0;
dmaConfig->memoryAddress = 0;
dmaConfig->peripheralAddress = 0;
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* Scroll display content to left by one character width. */
|
void LCD1602ScrollDisplayLeft(void)
|
/* Scroll display content to left by one character width. */
void LCD1602ScrollDisplayLeft(void)
|
{
LCD1602IICWriteCmd(LCD1602IIC_DISPLAYMOVE | LCD1602IIC_CURSORSHIFT | LCD1602IIC_MOVELEFT);
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* this function sends a 'reschedule' IPI to another CPU. it goes straight through and wastes no time serializing anything. Worst case is that we lose a reschedule ... */
|
void smp_send_reschedule(int cpu)
|
/* this function sends a 'reschedule' IPI to another CPU. it goes straight through and wastes no time serializing anything. Worst case is that we lose a reschedule ... */
void smp_send_reschedule(int cpu)
|
{
smp_ext_bitcall(cpu, ec_schedule);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* The node is not changed if it (or its first child) is not a CDATA element node. */
|
int mxmlSetCDATA(mxml_node_t *node, const char *data)
|
/* The node is not changed if it (or its first child) is not a CDATA element node. */
int mxmlSetCDATA(mxml_node_t *node, const char *data)
|
{
if (node && node->type == MXML_ELEMENT &&
strncmp(node->value.element.name, "![CDATA[", 8) &&
node->child && node->child->type == MXML_ELEMENT &&
!strncmp(node->child->value.element.name, "![CDATA[", 8))
node = node->child;
if (!node || node->type != MXML_ELEMENT || !data ||
strncmp(node->value.element.name, "![CDATA[", 8))
return (-1);
if (node->value.element.name)
free(node->value.element.name);
node->value.element.name = _mxml_strdupf("![CDATA[%s]]", data);
return (0);
}
|
DC-SWAT/DreamShell
|
C++
| null | 404
|
/* implement "/proc/keys" to provides a list of the keys on the system */
|
static struct rb_node* __key_user_next(struct rb_node *n)
|
/* implement "/proc/keys" to provides a list of the keys on the system */
static struct rb_node* __key_user_next(struct rb_node *n)
|
{
while (n) {
struct key_user *user = rb_entry(n, struct key_user, node);
if (user->user_ns == current_user_ns())
break;
n = rb_next(n);
}
return n;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Convert string 's' to a Lua number (put in 'result'). Return NULL on fail or the address of the ending '\0' on success. 'pmode' points to (and 'mode' contains) special things in the string: */
|
static const char* l_str2d(const char *s, lua_Number *result)
|
/* Convert string 's' to a Lua number (put in 'result'). Return NULL on fail or the address of the ending '\0' on success. 'pmode' points to (and 'mode' contains) special things in the string: */
static const char* l_str2d(const char *s, lua_Number *result)
|
{
char buff[L_MAXLENNUM + 1];
const char *pdot = strchr(s, '.');
if (strlen(s) > L_MAXLENNUM || pdot == NULL)
return NULL;
strcpy(buff, s);
buff[pdot - s] = lua_getlocaledecpoint();
endptr = l_str2dloc(buff, result, mode);
if (endptr != NULL)
endptr = s + (endptr - buff);
}
return endptr;
}
|
nodemcu/nodemcu-firmware
|
C++
|
MIT License
| 7,566
|
/* Initialize the LL part of the WIFI core. */
|
WIFI_Status_t WIFI_Init(void)
|
/* Initialize the LL part of the WIFI core. */
WIFI_Status_t WIFI_Init(void)
|
{
WIFI_Status_t ret = WIFI_STATUS_ERROR;
if(ES_WIFI_RegisterBusIO(&EsWifiObj,
SPI_WIFI_Init,
SPI_WIFI_DeInit,
SPI_WIFI_Delay,
SPI_WIFI_SendData,
SPI_WIFI_ReceiveData) == ES_WIFI_STATUS_OK)
{
if(ES_WIFI_Init(&EsWifiObj) == ES_WIFI_STATUS_OK)
{
ret = WIFI_STATUS_OK;
}
}
return ret;
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* Read whether the specified DMA Channel interrupts is set or not. */
|
uint8_t DMA_ReadIntFlag(DMA_INT_FLAG_T flag)
|
/* Read whether the specified DMA Channel interrupts is set or not. */
uint8_t DMA_ReadIntFlag(DMA_INT_FLAG_T flag)
|
{
if ((DMA1->INTSTS & flag) != RESET)
{
return SET ;
}
else
{
return RESET ;
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Make get_sync_clock return 0 again. Needs to be called from a context disabled for preemption. */
|
static void enable_sync_clock(void)
|
/* Make get_sync_clock return 0 again. Needs to be called from a context disabled for preemption. */
static void enable_sync_clock(void)
|
{
atomic_t *sw_ptr = &__get_cpu_var(clock_sync_word);
atomic_set_mask(0x80000000, sw_ptr);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* cx231xx_realease_resources() unregisters the v4l2,i2c and usb devices called when the device gets disconected or at module unload */
|
void cx231xx_remove_from_devlist(struct cx231xx *dev)
|
/* cx231xx_realease_resources() unregisters the v4l2,i2c and usb devices called when the device gets disconected or at module unload */
void cx231xx_remove_from_devlist(struct cx231xx *dev)
|
{
mutex_lock(&cx231xx_devlist_mutex);
list_del(&dev->devlist);
mutex_unlock(&cx231xx_devlist_mutex);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Insert the given log item into the AIL. We almost always insert at the end of the list, so on inserts we search from the end of the list to find where the new item belongs. */
|
STATIC void xfs_ail_insert(struct xfs_ail *, xfs_log_item_t *)
|
/* Insert the given log item into the AIL. We almost always insert at the end of the list, so on inserts we search from the end of the list to find where the new item belongs. */
STATIC void xfs_ail_insert(struct xfs_ail *, xfs_log_item_t *)
|
{
xfs_log_item_t *next_lip;
if (list_empty(&ailp->xa_ail)) {
list_add(&lip->li_ail, &ailp->xa_ail);
return;
}
list_for_each_entry_reverse(next_lip, &ailp->xa_ail, li_ail) {
if (XFS_LSN_CMP(next_lip->li_lsn, lip->li_lsn) <= 0)
break;
}
ASSERT((&next_lip->li_ail == &ailp->xa_ail) ||
(XFS_LSN_CMP(next_lip->li_lsn, lip->li_lsn) <= 0));
list_add(&lip->li_ail, &next_lip->li_ail);
xfs_ail_check(ailp, lip);
return;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Pass in a pointer to an ARM MOVW/MOVT instruction pair and return the immediate data encoded in the two` instruction */
|
UINT32 EFIAPI ThumbMovwMovtImmediateAddress(IN UINT16 *Instructions)
|
/* Pass in a pointer to an ARM MOVW/MOVT instruction pair and return the immediate data encoded in the two` instruction */
UINT32 EFIAPI ThumbMovwMovtImmediateAddress(IN UINT16 *Instructions)
|
{
UINT16 *Word;
UINT16 *Top;
Word = Instructions;
Top = Word + 2;
return (ThumbMovtImmediateAddress (Top) << 16) + ThumbMovtImmediateAddress (Word);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Unrolls a coroutine in protected mode while there are recoverable errors, that is, errors inside a protected call. (Any error interrupts 'unroll', and this loop protects it again so it can continue.) Stops with a normal end (status == LUA_OK), an yield (status == LUA_YIELD), or an unprotected error ('findpcall' doesn't find a recover point). */
|
static int precover(lua_State *L, int status)
|
/* Unrolls a coroutine in protected mode while there are recoverable errors, that is, errors inside a protected call. (Any error interrupts 'unroll', and this loop protects it again so it can continue.) Stops with a normal end (status == LUA_OK), an yield (status == LUA_YIELD), or an unprotected error ('findpcall' doesn't find a recover point). */
static int precover(lua_State *L, int status)
|
{
L->ci = ci;
setcistrecst(ci, status);
status = luaD_rawrunprotected(L, unroll, NULL);
}
return status;
}
|
Nicholas3388/LuaNode
|
C++
|
Other
| 1,055
|
/* Initialize the boards on-board LEDs.
The LEDs are initialized here in order to be able to use them in the early boot for diagnostics. */
|
static void leds_init(void)
|
/* Initialize the boards on-board LEDs.
The LEDs are initialized here in order to be able to use them in the early boot for diagnostics. */
static void leds_init(void)
|
{
gpio_init(LED_RED_GPIO, GPIO_DIR_OUT, GPIO_NOPULL);
gpio_init(LED_YELLOW_GPIO, GPIO_DIR_OUT, GPIO_NOPULL);
gpio_init(LED_GREEN_GPIO, GPIO_DIR_OUT, GPIO_NOPULL);
}
|
labapart/polymcu
|
C++
| null | 201
|
/* Start to manage all the PCI devices it found previously under the entire host bridge. */
|
EFI_STATUS StartPciDevices(IN EFI_HANDLE Controller)
|
/* Start to manage all the PCI devices it found previously under the entire host bridge. */
EFI_STATUS StartPciDevices(IN EFI_HANDLE Controller)
|
{
PCI_IO_DEVICE *RootBridge;
EFI_HANDLE ThisHostBridge;
LIST_ENTRY *CurrentLink;
RootBridge = GetRootBridgeByHandle (Controller);
ASSERT (RootBridge != NULL);
ThisHostBridge = RootBridge->PciRootBridgeIo->ParentHandle;
CurrentLink = mPciDevicePool.ForwardLink;
while (CurrentLink != NULL && CurrentLink != &mPciDevicePool) {
RootBridge = PCI_IO_DEVICE_FROM_LINK (CurrentLink);
if (RootBridge->PciRootBridgeIo->ParentHandle == ThisHostBridge) {
StartPciDevicesOnBridge (
RootBridge->Handle,
RootBridge,
NULL,
NULL,
NULL
);
}
CurrentLink = CurrentLink->ForwardLink;
}
return EFI_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* param base LPUART peripheral base address. param handle LPUART handle pointer. param count Send bytes count. retval kStatus_NoTransferInProgress No send in progress. retval kStatus_InvalidArgument Parameter is invalid. retval kStatus_Success Get successfully through the parameter */
|
status_t LPUART_TransferGetSendCountEDMA(LPUART_Type *base, lpuart_edma_handle_t *handle, uint32_t *count)
|
/* param base LPUART peripheral base address. param handle LPUART handle pointer. param count Send bytes count. retval kStatus_NoTransferInProgress No send in progress. retval kStatus_InvalidArgument Parameter is invalid. retval kStatus_Success Get successfully through the parameter */
status_t LPUART_TransferGetSendCountEDMA(LPUART_Type *base, lpuart_edma_handle_t *handle, uint32_t *count)
|
{
assert(handle);
assert(handle->txEdmaHandle);
assert(count);
(void) base;
if (kLPUART_TxIdle == handle->txState)
{
return kStatus_NoTransferInProgress;
}
*count = handle->txDataSizeAll -
(uint32_t)handle->nbytes *
EDMA_GetRemainingMajorLoopCount(handle->txEdmaHandle->base, handle->txEdmaHandle->channel);
return kStatus_Success;
}
|
nanoframework/nf-interpreter
|
C++
|
MIT License
| 293
|
/* This functionally is ideally called regularly during an idle period. */
|
int nl_cache_mngr_poll(struct nl_cache_mngr *mngr, int timeout)
|
/* This functionally is ideally called regularly during an idle period. */
int nl_cache_mngr_poll(struct nl_cache_mngr *mngr, int timeout)
|
{
int ret;
struct pollfd fds = {
.fd = nl_socket_get_fd(mngr->cm_handle),
.events = POLLIN,
};
NL_DBG(3, "Cache manager %p, poll() fd %d\n", mngr, fds.fd);
ret = poll(&fds, 1, timeout);
NL_DBG(3, "Cache manager %p, poll() returned %d\n", mngr, ret);
if (ret < 0)
return -nl_syserr2nlerr(errno);
if (ret == 0)
return 0;
return nl_cache_mngr_data_ready(mngr);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* It enables the data trasmission from microcontroller to STUSB1602 device. */
|
USBPD_StatusTypeDef STUSB16xx_HW_IF_Send_Packet(uint8_t PortNum, uint8_t *pData, uint16_t Size)
|
/* It enables the data trasmission from microcontroller to STUSB1602 device. */
USBPD_StatusTypeDef STUSB16xx_HW_IF_Send_Packet(uint8_t PortNum, uint8_t *pData, uint16_t Size)
|
{
USBPD_StatusTypeDef ret = USBPD_ERROR;
ret = HW_IF_check_bus_idle(PortNum);
if (ret == USBPD_OK && 1)
{
Ports[PortNum].State = HAL_USBPD_PORT_STATE_BUSY_TX;
STUSB16xx_HW_IF_Switch_Mode(PortNum, STUSB16xx_SPI_Mode_TX);
HAL_SPI_DMAStop(&Ports[PortNum].hspi);
__HAL_DMA_CLEAR_FLAG(hdma, 0x0FFFFFFF);
HAL_SPI_Transmit_DMA(&Ports[PortNum].hspi, pData, Size);
STUSB16xx_HW_IF_TX_EN_Status(PortNum, GPIO_PIN_SET);
}
else
{
__NOP();
}
return ret;
}
|
st-one/X-CUBE-USB-PD
|
C++
| null | 110
|
/* Draw a pixel on the LCD with the provided color. */
|
void LCD_DrawPixel(u8 XPos, u8 YPos, u16 Color)
|
/* Draw a pixel on the LCD with the provided color. */
void LCD_DrawPixel(u8 XPos, u8 YPos, u16 Color)
|
{
LCD_SetRect_For_Cmd( XPos, YPos, 1, 1 );
LCD_SendLCDCmd( ST7637_RAMWR );
LCD_SendLCDData( Color );
LCD_SendLCDData( Color >> 8 );
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* Disable the double buffer mode for the selected DMA channel. */
|
void DMA_DisableDoubleBufferMode(DMA_Stream_T *stream)
|
/* Disable the double buffer mode for the selected DMA channel. */
void DMA_DisableDoubleBufferMode(DMA_Stream_T *stream)
|
{
stream->SCFG_B.DBM = BIT_RESET;
}
|
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(). If StartBit is greater than 31, then ASSERT(). If EndBit is greater than 31, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
|
UINT32 EFIAPI PciExpressBitFieldOr32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 OrData)
|
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). If StartBit is greater than 31, then ASSERT(). If EndBit is greater than 31, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT32 EFIAPI PciExpressBitFieldOr32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 OrData)
|
{
ASSERT_INVALID_PCI_ADDRESS (Address);
return MmioBitFieldOr32 (
(UINTN)GetPciExpressBaseAddress () + Address,
StartBit,
EndBit,
OrData
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Get thread attributes object scheduling parameters.
See IEEE 1003.1 */
|
int pthread_attr_getschedparam(const pthread_attr_t *_attr, struct sched_param *schedparam)
|
/* Get thread attributes object scheduling parameters.
See IEEE 1003.1 */
int pthread_attr_getschedparam(const pthread_attr_t *_attr, struct sched_param *schedparam)
|
{
struct posix_thread_attr *attr = (struct posix_thread_attr *)_attr;
if (!__attr_is_initialized(attr) || (schedparam == NULL)) {
return EINVAL;
}
schedparam->sched_priority = attr->priority;
return 0;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* Release a Mutex that was obtained by osMutexWait. */
|
osStatus osMutexRelease(osMutexId mutex_id)
|
/* Release a Mutex that was obtained by osMutexWait. */
osStatus osMutexRelease(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;
}
if (k_mutex_unlock(mutex) != 0) {
return osErrorResource;
}
return osOK;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* The function is used to Get reset source from last operation. */
|
unsigned long SysCtlResetSrcGet(void)
|
/* The function is used to Get reset source from last operation. */
unsigned long SysCtlResetSrcGet(void)
|
{
return xHWREG(GCR_RSTSRC);
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* If one of our conninit messages is returned, this function deals with it. It puts the socket into the NO_COMMUNICATION state. */
|
static void dn_returned_conn_init(struct sock *sk, struct sk_buff *skb)
|
/* If one of our conninit messages is returned, this function deals with it. It puts the socket into the NO_COMMUNICATION state. */
static void dn_returned_conn_init(struct sock *sk, struct sk_buff *skb)
|
{
struct dn_scp *scp = DN_SK(sk);
if (scp->state == DN_CI) {
scp->state = DN_NC;
sk->sk_state = TCP_CLOSE;
if (!sock_flag(sk, SOCK_DEAD))
sk->sk_state_change(sk);
}
kfree_skb(skb);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* This function handles USB-On-The-Go FS global interrupt requests. */
|
void OTG_FS_IRQHandler(void)
|
/* This function handles USB-On-The-Go FS global interrupt requests. */
void OTG_FS_IRQHandler(void)
|
{
HAL_HCD_IRQHandler(&hhcd);
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* ufshcd_get_tr_ocs - Get the UTRD Overall Command Status */
|
static int ufshcd_get_tr_ocs(struct ufs_hba *hba)
|
/* ufshcd_get_tr_ocs - Get the UTRD Overall Command Status */
static int ufshcd_get_tr_ocs(struct ufs_hba *hba)
|
{
return le32_to_cpu(hba->utrdl->header.dword_2) & MASK_OCS;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Returns: 1 if event matches starget / 0 if event does not match starget */
|
static int ibmvfc_match_target(struct ibmvfc_event *evt, void *device)
|
/* Returns: 1 if event matches starget / 0 if event does not match starget */
static int ibmvfc_match_target(struct ibmvfc_event *evt, void *device)
|
{
if (evt->cmnd && scsi_target(evt->cmnd->device) == device)
return 1;
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Perform the chip setup work that must be done at both init and resume time */
|
static void hpt36x_init_chipset(struct pci_dev *dev)
|
/* Perform the chip setup work that must be done at both init and resume time */
static void hpt36x_init_chipset(struct pci_dev *dev)
|
{
u8 drive_fast;
pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, (L1_CACHE_BYTES / 4));
pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x78);
pci_write_config_byte(dev, PCI_MIN_GNT, 0x08);
pci_write_config_byte(dev, PCI_MAX_LAT, 0x08);
pci_read_config_byte(dev, 0x51, &drive_fast);
if (drive_fast & 0x80)
pci_write_config_byte(dev, 0x51, drive_fast & ~0x80);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Get Voltage Detector Output.
The voltage detector threshold must be set when the power voltage detector is enabled, see */
|
bool pwr_voltage_high(void)
|
/* Get Voltage Detector Output.
The voltage detector threshold must be set when the power voltage detector is enabled, see */
bool pwr_voltage_high(void)
|
{
return !(PWR_CSR & PWR_CSR_PVDO);
}
|
libopencm3/libopencm3
|
C++
|
GNU General Public License v3.0
| 2,931
|
/* The OLED_write_char function displays a single character to the display. */
|
void OLED_write_char(const uint8_t data_char)
|
/* The OLED_write_char function displays a single character to the display. */
void OLED_write_char(const uint8_t data_char)
|
{
uint8_t txbuff[10];
uint8_t i;
for ( i = 0; i < CHARACTER_WIDTH; ++i )
{
txbuff[i * 2] = OLED_DATA_CODE;
txbuff[(i * 2) + 1] = oled_ascii_character_set[data_char][i];
}
MSS_I2C_write( g_p_oled_i2c, OLED_SLAVE_ADDRESS, txbuff, sizeof(txbuff), MSS_I2C_RELEASE_BUS );
MSS_I2C_wait_complete( g_p_oled_i2c );
}
|
apopple/Pandaboard-FreeRTOS
|
C++
| null | 25
|
/* Check the status of the FIFO buffer of the specified SPI port. */
|
unsigned long SPIFIFOStatusGet(unsigned long ulBase)
|
/* Check the status of the FIFO buffer of the specified SPI port. */
unsigned long SPIFIFOStatusGet(unsigned long ulBase)
|
{
xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)||
(ulBase == SPI2_BASE) || (ulBase == SPI3_BASE));
return (xHWREG(ulBase + SPI_CNTRL) & (SPI_CNTRL_TX_FULL) ||
(SPI_CNTRL_RX_FULL) || (SPI_CNTRL_TX_EMPTY) || (SPI_CNTRL_RX_EMPTY));
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Get detach state attribute in thread attributes object.
See IEEE 1003.1 */
|
int pthread_attr_getdetachstate(const pthread_attr_t *_attr, int *detachstate)
|
/* Get detach state attribute in thread attributes object.
See IEEE 1003.1 */
int pthread_attr_getdetachstate(const pthread_attr_t *_attr, int *detachstate)
|
{
const struct posix_thread_attr *attr = (const struct posix_thread_attr *)_attr;
if (!__attr_is_initialized(attr) || (detachstate == NULL)) {
return EINVAL;
}
*detachstate = attr->detachstate;
return 0;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.