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
/* Reads either a 16- or 32-bit data word from the remote CPU System address */
uint16_t IPCLiteLtoRDataRead(uint32_t ulFlag, uint32_t ulAddress, uint16_t usLength, uint32_t ulStatusFlag)
/* Reads either a 16- or 32-bit data word from the remote CPU System address */ uint16_t IPCLiteLtoRDataRead(uint32_t ulFlag, uint32_t ulAddress, uint16_t usLength, uint32_t ulStatusFlag)
{ uint16_t returnStatus; if (IpcRegs.IPCFLG.all & (ulFlag | ulStatusFlag)) { returnStatus = STATUS_FAIL; } else { if (usLength == IPC_LENGTH_16_BITS) { IpcRegs.IPCSENDCOM = IPC_DATA_READ_16; } else if (usLength == IPC_LENGTH_32_BITS) { IpcRegs.IPCSENDCOM = IPC_DATA_READ_32; } IpcRegs.IPCSENDADDR = ulAddress; IpcRegs.IPCSET.all |= (ulFlag | ulStatusFlag); returnStatus = STATUS_PASS; } return returnStatus; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function supports both ISO 639-2 and RFC 4646 language codes, but language code types may not be mixed in a single call to this function. */
CHAR8* DriverHealthManagerSelectBestLanguage(IN CHAR8 *SupportedLanguages, IN BOOLEAN Iso639Language)
/* This function supports both ISO 639-2 and RFC 4646 language codes, but language code types may not be mixed in a single call to this function. */ CHAR8* DriverHealthManagerSelectBestLanguage(IN CHAR8 *SupportedLanguages, IN BOOLEAN Iso639Language)
{ CHAR8 *LanguageVariable; CHAR8 *BestLanguage; GetEfiGlobalVariable2 (Iso639Language ? L"Lang" : L"PlatformLang", (VOID **)&LanguageVariable, NULL); BestLanguage = GetBestLanguage ( SupportedLanguages, Iso639Language, (LanguageVariable != NULL) ? LanguageVariable : "", Iso639Language ? "eng" : "en-US", NULL ); if (LanguageVariable != NULL) { FreePool (LanguageVariable); } return BestLanguage; }
tianocore/edk2
C++
Other
4,240
/* fifo_icap_set_read_size - Set the the size register. @drvdata: a pointer to the drvdata. @data: the size of the following read transaction, in words. */
static void fifo_icap_set_read_size(struct hwicap_drvdata *drvdata, u32 data)
/* fifo_icap_set_read_size - Set the the size register. @drvdata: a pointer to the drvdata. @data: the size of the following read transaction, in words. */ static void fifo_icap_set_read_size(struct hwicap_drvdata *drvdata, u32 data)
{ out_be32(drvdata->base_address + XHI_SZ_OFFSET, data); }
robutest/uclinux
C++
GPL-2.0
60
/* unix_listen() Create a unix domain socket, and listen on it. */
int unix_listen(char *)
/* unix_listen() Create a unix domain socket, and listen on it. */ int unix_listen(char *)
{ int s; if ((s = unix_bind(path)) < 0) return (-1); if (listen(s, 5) < 0) { close(s); return (-1); } return (s); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Reads a byte array from the on-chip EEPROM memory. */
RAMFUNC err_t readEEPROM(uint8_t *eeAddress, uint8_t *buffAddress, uint32_t byteCount)
/* Reads a byte array from the on-chip EEPROM memory. */ RAMFUNC err_t readEEPROM(uint8_t *eeAddress, uint8_t *buffAddress, uint32_t byteCount)
{ unsigned int command[5], result[4]; command[0] = 62; command[1] = (uint32_t) eeAddress; command[2] = (uint32_t) buffAddress; command[3] = byteCount; command[4] = (uint32_t) (SystemCoreClock/1000); __disable_irq(); iap_entry(command, result); __enable_irq(); if (0 != result[0]) { return ERROR_ADDRESSOUTOFRANGE; } return ERROR_NONE; }
microbuilder/LPC11U_LPC13U_CodeBase
C++
Other
54
/* Enable ADC Block to wake up ADC from PowerDown. */
void ADCEnable(unsigned long ulBase)
/* Enable ADC Block to wake up ADC from PowerDown. */ void ADCEnable(unsigned long ulBase)
{ xASSERT((ulBase == ADC1_BASE) || (ulBase == ADC2_BASE) || (ulBase == ADC3_BASE)); xHWREG(ulBase + ADC_CR2) |= ADC_CR2_ADON; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* If the conversion results in an overflow or an underflow condition, then Result is set to INT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeUint16ToInt16(IN UINT16 Operand, OUT INT16 *Result)
/* If the conversion results in an overflow or an underflow condition, then Result is set to INT16_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */ RETURN_STATUS EFIAPI SafeUint16ToInt16(IN UINT16 Operand, OUT INT16 *Result)
{ RETURN_STATUS Status; if (Result == NULL) { return RETURN_INVALID_PARAMETER; } if (Operand <= MAX_INT16) { *Result = (INT16)Operand; Status = RETURN_SUCCESS; } else { *Result = INT16_ERROR; Status = RETURN_BUFFER_TOO_SMALL; } return Status; }
tianocore/edk2
C++
Other
4,240
/* When an inode cannot be read due to a media or remote network failure this function makes the inode "bad" and causes I/O operations on it to fail from this point on. */
void make_bad_inode(struct inode *inode)
/* When an inode cannot be read due to a media or remote network failure this function makes the inode "bad" and causes I/O operations on it to fail from this point on. */ void make_bad_inode(struct inode *inode)
{ remove_inode_hash(inode); inode->i_mode = S_IFREG; inode->i_atime = inode->i_mtime = inode->i_ctime = current_fs_time(inode->i_sb); inode->i_op = &bad_inode_ops; inode->i_fop = &bad_file_ops;}
robutest/uclinux
C++
GPL-2.0
60
/* Set the boot bank to the alternate bank */
void cpld_set_altbank(void)
/* Set the boot bank to the alternate bank */ void cpld_set_altbank(void)
{ u8 val, curbank, altbank, override; val = CPLD_READ(vbank); curbank = val & CPLD_BANK_SEL_MASK; switch (curbank) { case CPLD_SELECT_BANK0: case CPLD_SELECT_BANK4: altbank = CPLD_SELECT_BANK4; CPLD_WRITE(vbank, altbank); override = CPLD_READ(software_on); CPLD_WRITE(software_on, override | CPLD_BANK_SEL_EN); CPLD_WRITE(sys_reset, CPLD_SYSTEM_RESET); break; default: printf("CPLD Altbank Fail: Invalid value!\n"); return; } }
4ms/stm32mp1-baremetal
C++
Other
137
/* Clear free trigger duty interrupt flag of selected channel. */
void EPWM_ClearFTDutyIntFlag(EPWM_T *epwm, uint32_t u32ChannelNum)
/* Clear free trigger duty interrupt flag of selected channel. */ void EPWM_ClearFTDutyIntFlag(EPWM_T *epwm, uint32_t u32ChannelNum)
{ (epwm)->FTCI = ((EPWM_FTCI_FTCMU0_Msk | EPWM_FTCI_FTCMD0_Msk) << (u32ChannelNum >> 1U)); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns the value associated to @data or NULL in case of error */
void* xmlListReverseSearch(xmlListPtr l, void *data)
/* Returns the value associated to @data or NULL in case of error */ void* xmlListReverseSearch(xmlListPtr l, void *data)
{ xmlLinkPtr lk; if (l == NULL) return(NULL); lk = xmlListLinkReverseSearch(l, data); if (lk) return (lk->data); return NULL; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* deadline_check_fifo returns 0 if there are no expired requests on the fifo, 1 otherwise. Requires !list_empty(&dd->fifo_list) */
static int deadline_check_fifo(struct deadline_data *dd, int ddir)
/* deadline_check_fifo returns 0 if there are no expired requests on the fifo, 1 otherwise. Requires !list_empty(&dd->fifo_list) */ static int deadline_check_fifo(struct deadline_data *dd, int ddir)
{ struct request *rq = rq_entry_fifo(dd->fifo_list[ddir].next); if (time_after(jiffies, rq_fifo_time(rq))) return 1; return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This function will compare two areas of memory */
RT_WEAK rt_int32_t rt_memcmp(const void *cs, const void *ct, rt_ubase_t count)
/* This function will compare two areas of memory */ RT_WEAK rt_int32_t rt_memcmp(const void *cs, const void *ct, rt_ubase_t count)
{ const unsigned char *su1, *su2; int res = 0; for (su1 = (const unsigned char *)cs, su2 = (const unsigned char *)ct; 0 < count; ++su1, ++su2, count--) if ((res = *su1 - *su2) != 0) break; return res; }
pikasTech/PikaPython
C++
MIT License
1,403
/* nilfs_bmap_lookup_dirty_buffers - @bmap: bmap @listp: pointer to buffer head list */
void nilfs_bmap_lookup_dirty_buffers(struct nilfs_bmap *bmap, struct list_head *listp)
/* nilfs_bmap_lookup_dirty_buffers - @bmap: bmap @listp: pointer to buffer head list */ void nilfs_bmap_lookup_dirty_buffers(struct nilfs_bmap *bmap, struct list_head *listp)
{ if (bmap->b_ops->bop_lookup_dirty_buffers != NULL) bmap->b_ops->bop_lookup_dirty_buffers(bmap, listp); }
robutest/uclinux
C++
GPL-2.0
60
/* Timer handler to convert the key from USB. */
VOID EFIAPI USBKeyboardTimerHandler(IN EFI_EVENT Event, IN VOID *Context)
/* Timer handler to convert the key from USB. */ VOID EFIAPI USBKeyboardTimerHandler(IN EFI_EVENT Event, IN VOID *Context)
{ EFI_STATUS Status; USB_KB_DEV *UsbKeyboardDevice; UINT8 KeyCode; EFI_KEY_DATA KeyData; UsbKeyboardDevice = (USB_KB_DEV *)Context; Status = USBParseKey (UsbKeyboardDevice, &KeyCode); if (EFI_ERROR (Status)) { return; } Status = UsbKeyCodeToEfiInputKey (UsbKeyboardDevice, KeyCode, &KeyData); if (EFI_ERROR (Status)) { return; } Enqueue (&UsbKeyboardDevice->EfiKeyQueue, &KeyData, sizeof (KeyData)); }
tianocore/edk2
C++
Other
4,240
/* Exception callback for printing out exceptions on master side */
ModbusError masterExceptionCallback(const ModbusMaster *master, uint8_t address, uint8_t function, ModbusExceptionCode code)
/* Exception callback for printing out exceptions on master side */ ModbusError masterExceptionCallback(const ModbusMaster *master, uint8_t address, uint8_t function, ModbusExceptionCode code)
{ printf("Received slave %d exception %s (function %d)\n", address, modbusExceptionCodeStr(code), function); return MODBUS_OK; }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* We filter at user level, since the kernel driver does't process the packets */
static int pcap_setfilter_win32_dag(pcap_t *, struct bpf_program *)
/* We filter at user level, since the kernel driver does't process the packets */ static int pcap_setfilter_win32_dag(pcap_t *, struct bpf_program *)
{ pcap_strlcpy(p->errbuf, "setfilter: No filter specified", sizeof(p->errbuf)); return (-1); } if (install_bpf_program(p, fp) < 0) return (-1); return (0); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Find an nfs_client on the list that matches the initialisation data that is supplied. */
static struct nfs_client* nfs_match_client(const struct nfs_client_initdata *data)
/* Find an nfs_client on the list that matches the initialisation data that is supplied. */ static struct nfs_client* nfs_match_client(const struct nfs_client_initdata *data)
{ struct nfs_client *clp; const struct sockaddr *sap = data->addr; list_for_each_entry(clp, &nfs_client_list, cl_share_link) { const struct sockaddr *clap = (struct sockaddr *)&clp->cl_addr; if (clp->cl_cons_state < 0) continue; if (clp->rpc_ops != data->rpc_ops) continue; if (clp->cl_proto != data->proto) continue; if (clp->cl_minorversion != data->minorversion) continue; if (!nfs_sockaddr_cmp(sap, clap)) continue; atomic_inc(&clp->cl_count); return clp; } return NULL; }
robutest/uclinux
C++
GPL-2.0
60
/* MR destructor and constructor used in Reregister MR verb, sets all fields in ehca_mr_t to 0, except struct ib_mr and spinlock */
void ehca_mr_deletenew(struct ehca_mr *mr)
/* MR destructor and constructor used in Reregister MR verb, sets all fields in ehca_mr_t to 0, except struct ib_mr and spinlock */ void ehca_mr_deletenew(struct ehca_mr *mr)
{ mr->flags = 0; mr->num_kpages = 0; mr->num_hwpages = 0; mr->acl = 0; mr->start = NULL; mr->fmr_page_size = 0; mr->fmr_max_pages = 0; mr->fmr_max_maps = 0; mr->fmr_map_cnt = 0; memset(&mr->ipz_mr_handle, 0, sizeof(mr->ipz_mr_handle)); memset(&mr->galpas, 0, sizeof(mr->galpas)); }
robutest/uclinux
C++
GPL-2.0
60
/* Called when the host timer expires. Handles unresponsive timeouts and periodic retries in case of resource shortage. */
static void ble_hs_timer_exp(struct ble_npl_event *ev)
/* Called when the host timer expires. Handles unresponsive timeouts and periodic retries in case of resource shortage. */ static void ble_hs_timer_exp(struct ble_npl_event *ev)
{ int32_t ticks_until_next; switch (ble_hs_sync_state) { case BLE_HS_SYNC_STATE_GOOD: ticks_until_next = ble_gattc_timer(); ble_hs_timer_sched(ticks_until_next); ticks_until_next = ble_gap_timer(); ble_hs_timer_sched(ticks_until_next); ticks_until_next = ble_l2cap_sig_timer(); ble_hs_timer_sched(ticks_until_next); ticks_until_next = ble_sm_timer(); ble_hs_timer_sched(ticks_until_next); ticks_until_next = ble_hs_conn_timer(); ble_hs_timer_sched(ticks_until_next); break; case BLE_HS_SYNC_STATE_BAD: ble_hs_reset(); break; case BLE_HS_SYNC_STATE_BRINGUP: default: assert(0); break; } }
Nicholas3388/LuaNode
C++
Other
1,055
/* Initializes an SRAM buffer for the IOS FIFO. The recommended buffer size for the IOS FIFO is 1024 bytes. */
void am_hal_ios_fifo_buffer_init(uint8_t *pui8Buffer, uint32_t ui32NumBytes)
/* Initializes an SRAM buffer for the IOS FIFO. The recommended buffer size for the IOS FIFO is 1024 bytes. */ void am_hal_ios_fifo_buffer_init(uint8_t *pui8Buffer, uint32_t ui32NumBytes)
{ if ( ui32NumBytes > (1023 - g_ui32HwFifoSize + 1) ) { ui32NumBytes = (1023 - g_ui32HwFifoSize + 1); } am_hal_ios_buffer_init(&g_sSRAMBuffer, pui8Buffer, ui32NumBytes); AM_BFW(IOSLAVE, FIFOCTR, FIFOCTR, 0x0); AM_BFW(IOSLAVE, FIFOPTR, FIFOSIZ, 0x0); am_hal_ios_fifo_ptr_set(g_ui32FifoBaseOffset); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* SEP member function. This function creates and returns a new section stream handle to represent the new section stream. */
EFI_STATUS EFIAPI OpenSectionStream(IN UINTN SectionStreamLength, IN VOID *SectionStream, OUT UINTN *SectionStreamHandle)
/* SEP member function. This function creates and returns a new section stream handle to represent the new section stream. */ EFI_STATUS EFIAPI OpenSectionStream(IN UINTN SectionStreamLength, IN VOID *SectionStream, OUT UINTN *SectionStreamHandle)
{ if (!IsValidSectionStream (SectionStream, SectionStreamLength)) { return EFI_INVALID_PARAMETER; } return OpenSectionStreamEx ( SectionStreamLength, SectionStream, FALSE, 0, SectionStreamHandle ); }
tianocore/edk2
C++
Other
4,240
/* Sets the value for a given parameter in the parameter table. */
void V2Params_SetParameterValue(const uint8_t ParamID, const uint8_t Value)
/* Sets the value for a given parameter in the parameter table. */ void V2Params_SetParameterValue(const uint8_t ParamID, const uint8_t Value)
{ ParameterItem_t* const ParamInfo = V2Params_GetParamFromTable(ParamID); if (ParamInfo == NULL) return; ParamInfo->ParamValue = Value; if (ParamID == PARAM_RESET_POLARITY) eeprom_update_byte(&EEPROM_Reset_Polarity, Value); if (ParamID == PARAM_SCK_DURATION) eeprom_update_byte(&EEPROM_SCK_Duration, Value); }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Configure new channel. This is the alternative API, which requires the caller to store the mask of used channels. */
uint8_t ppi_add_channel(uint32_t *chan_map, uint32_t eep, uint32_t tep, bool enable)
/* Configure new channel. This is the alternative API, which requires the caller to store the mask of used channels. */ uint8_t ppi_add_channel(uint32_t *chan_map, uint32_t eep, uint32_t tep, bool enable)
{ uint8_t i; uint32_t chan_bit; for (i = 0, chan_bit = 1; i <= PPI_MAX_PROG_CHANNEL; ++i, chan_bit <<= 1) { if (!(chan_bit & *chan_map)) { *chan_map |= chan_bit; break; } } if (i > PPI_MAX_PROG_CHANNEL) { return 0xff; } ppi_configure_channel(i, eep, tep); if (enable) { ppi_enable_channels(chan_bit); } return i; }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* Gets the interrupt status for a PWM module. */
unsigned long PWMIntStatus(unsigned long ulBase, tBoolean bMasked)
/* Gets the interrupt status for a PWM module. */ unsigned long PWMIntStatus(unsigned long ulBase, tBoolean bMasked)
{ ASSERT(ulBase == PWM_BASE); if(bMasked == true) { return(HWREG(ulBase + PWM_O_ISC)); } else { return(HWREG(ulBase + PWM_O_RIS)); } }
watterott/WebRadio
C++
null
71
/* Disable interrupts, and keep a count of the nesting depth. */
void vPortEnterCritical(void)
/* Disable interrupts, and keep a count of the nesting depth. */ void vPortEnterCritical(void)
{ portDISABLE_INTERRUPTS(); ulCriticalNesting++; }
labapart/polymcu
C++
null
201
/* The user Entry Point for module DiskIo. The user code starts with this function. */
EFI_STATUS EFIAPI InitializeDiskIo(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
/* The user Entry Point for module DiskIo. The user code starts with this function. */ EFI_STATUS EFIAPI InitializeDiskIo(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
{ EFI_STATUS Status; Status = EfiLibInstallDriverBindingComponentName2 ( ImageHandle, SystemTable, &gDiskIoDriverBinding, ImageHandle, &gDiskIoComponentName, &gDiskIoComponentName2 ); ASSERT_EFI_ERROR (Status); return Status; }
tianocore/edk2
C++
Other
4,240
/* brief Return PLL0 output clock rate from setup structure param pSetup : Pointer to a PLL setup structure return PLL0 output clock rate the setup structure will generate */
uint32_t CLOCK_GetPLLOutFromSetup(pll_setup_t *pSetup)
/* brief Return PLL0 output clock rate from setup structure param pSetup : Pointer to a PLL setup structure return PLL0 output clock rate the setup structure will generate */ uint32_t CLOCK_GetPLLOutFromSetup(pll_setup_t *pSetup)
{ uint32_t clkRate = 0; uint32_t prediv, postdiv; float workRate = 0.0F; clkRate = CLOCK_GetPLLInClockRateFromSetup(pSetup); prediv = findPllPreDivFromSetup(pSetup); postdiv = findPllPostDivFromSetup(pSetup); clkRate = clkRate / prediv; workRate = (float)clkRate * (float)findPllMMultFromSetup(pSetup); workRate /= (float)postdiv; return (uint32_t)workRate; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns: (skip): TRUE if the call succeded, FALSE if @error is set. */
gboolean _g_freedesktop_dbus_call_request_name_sync(_GFreedesktopDBus *proxy, const gchar *arg_name, guint arg_flags, guint *out_value, GCancellable *cancellable, GError **error)
/* Returns: (skip): TRUE if the call succeded, FALSE if @error is set. */ gboolean _g_freedesktop_dbus_call_request_name_sync(_GFreedesktopDBus *proxy, const gchar *arg_name, guint arg_flags, guint *out_value, GCancellable *cancellable, GError **error)
{ GVariant *_ret; _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy), "RequestName", g_variant_new ("(su)", arg_name, arg_flags), G_DBUS_CALL_FLAGS_NONE, -1, cancellable, error); if (_ret == NULL) goto _out; g_variant_get (_ret, "(u)", out_value); g_variant_unref (_ret); _out: return _ret != NULL; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* HCI read local supported features command. Returns the features supported by the controller. */
static int ble_ll_hci_le_read_local_features(uint8_t *rspbuf, uint8_t *rsplen)
/* HCI read local supported features command. Returns the features supported by the controller. */ static int ble_ll_hci_le_read_local_features(uint8_t *rspbuf, uint8_t *rsplen)
{ struct ble_hci_le_rd_loc_supp_feat_rp *rsp = (void *) rspbuf; rsp->features = htole64(ble_ll_read_supp_features()); *rsplen = sizeof(*rsp); return BLE_ERR_SUCCESS; }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* This function clears memory encryption bit for the MMIO region specified by PhysicalAddress and Length. */
RETURN_STATUS EFIAPI InternalMemEncryptSevClearMmioPageEncMask(IN PHYSICAL_ADDRESS Cr3BaseAddress, IN PHYSICAL_ADDRESS PhysicalAddress, IN UINTN Length)
/* This function clears memory encryption bit for the MMIO region specified by PhysicalAddress and Length. */ RETURN_STATUS EFIAPI InternalMemEncryptSevClearMmioPageEncMask(IN PHYSICAL_ADDRESS Cr3BaseAddress, IN PHYSICAL_ADDRESS PhysicalAddress, IN UINTN Length)
{ return SetMemoryEncDec ( Cr3BaseAddress, PhysicalAddress, Length, ClearCBit, FALSE, TRUE ); }
tianocore/edk2
C++
Other
4,240
/* 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; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Polarity is determined based on the PHY specific status register. */
static s32 igb_check_polarity_m88(struct e1000_hw *hw)
/* Polarity is determined based on the PHY specific status register. */ static s32 igb_check_polarity_m88(struct e1000_hw *hw)
{ struct e1000_phy_info *phy = &hw->phy; s32 ret_val; u16 data; ret_val = phy->ops.read_reg(hw, M88E1000_PHY_SPEC_STATUS, &data); if (!ret_val) phy->cable_polarity = (data & M88E1000_PSSR_REV_POLARITY) ? e1000_rev_polarity_reversed : e1000_rev_polarity_normal; return ret_val; }
robutest/uclinux
C++
GPL-2.0
60
/* Returns 1 if address can be used, otherwise 0 */
int tipc_addr_node_valid(u32 addr)
/* Returns 1 if address can be used, otherwise 0 */ int tipc_addr_node_valid(u32 addr)
{ return (tipc_addr_domain_valid(addr) && tipc_node(addr)); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Because this function is inlined, the 'state' parameter will be constant, and thus optimised away by the compiler. Likewise the 'timeout' parameter for the cases without timeouts. */
static int __sched __down_common(struct semaphore *sem, long state, long timeout)
/* Because this function is inlined, the 'state' parameter will be constant, and thus optimised away by the compiler. Likewise the 'timeout' parameter for the cases without timeouts. */ static int __sched __down_common(struct semaphore *sem, long state, long timeout)
{ struct task_struct *task = current; struct semaphore_waiter waiter; list_add_tail(&waiter.list, &sem->wait_list); waiter.task = task; waiter.up = 0; for (;;) { if (signal_pending_state(state, task)) goto interrupted; if (timeout <= 0) goto timed_out; __set_task_state(task, state); spin_unlock_irq(&sem->lock); timeout = schedule_timeout(timeout); spin_lock_irq(&sem->lock); if (waiter.up) return 0; } timed_out: list_del(&waiter.list); return -ETIME; interrupted: list_del(&waiter.list); return -EINTR; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Basic support for the pwm module on imx6. */
int pwm_init(int pwm_id, int div, int invert)
/* Basic support for the pwm module on imx6. */ int pwm_init(int pwm_id, int div, int invert)
{ struct pwm_regs *pwm = (struct pwm_regs *)pwm_id_to_reg(pwm_id); if (!pwm) return -1; writel(0, &pwm->ir); return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Blocks further parser processing don't override error for internal use */
static void xmlHaltParser(xmlParserCtxtPtr ctxt)
/* Blocks further parser processing don't override error for internal use */ static void xmlHaltParser(xmlParserCtxtPtr ctxt)
{ if (ctxt->input->free != NULL) { ctxt->input->free((xmlChar *) ctxt->input->base); ctxt->input->free = NULL; } ctxt->input->cur = BAD_CAST""; ctxt->input->base = ctxt->input->cur; } }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* According to the Device Tree specification, s2.3.5 "#address-cells and #size-cells": "If missing, a client program should assume a default value of 2 for #address-cells, and a value of 1 for #size-cells." */
EFI_STATUS EFIAPI FdtGetAddressInfo(IN CONST VOID *Fdt, IN INT32 Node, OUT INT32 *AddressCells, OPTIONAL OUT INT32 *SizeCells OPTIONAL)
/* According to the Device Tree specification, s2.3.5 "#address-cells and #size-cells": "If missing, a client program should assume a default value of 2 for #address-cells, and a value of 1 for #size-cells." */ EFI_STATUS EFIAPI FdtGetAddressInfo(IN CONST VOID *Fdt, IN INT32 Node, OUT INT32 *AddressCells, OPTIONAL OUT INT32 *SizeCells OPTIONAL)
{ if (Fdt == NULL) { ASSERT (0); return EFI_INVALID_PARAMETER; } if (AddressCells != NULL) { *AddressCells = fdt_address_cells (Fdt, Node); if (*AddressCells < 0) { ASSERT (0); return EFI_ABORTED; } } if (SizeCells != NULL) { *SizeCells = fdt_size_cells (Fdt, Node); if (*SizeCells < 0) { ASSERT (0); return EFI_ABORTED; } } return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Telephony For Linux device drivers request registration here. */
int phone_register_device(struct phone_device *p, int unit)
/* Telephony For Linux device drivers request registration here. */ int phone_register_device(struct phone_device *p, int unit)
{ int base; int end; int i; base = 0; end = PHONE_NUM_DEVICES - 1; if (unit != PHONE_UNIT_ANY) { base = unit; end = unit + 1; } mutex_lock(&phone_lock); for (i = base; i < end; i++) { if (phone_device[i] == NULL) { phone_device[i] = p; p->minor = i; mutex_unlock(&phone_lock); return 0; } } mutex_unlock(&phone_lock); return -ENFILE; }
robutest/uclinux
C++
GPL-2.0
60
/* This function validates the GT Block timer count. */
STATIC VOID EFIAPI ValidateGtBlockTimerCount(IN UINT8 *Ptr, IN VOID *Context)
/* This function validates the GT Block timer count. */ STATIC VOID EFIAPI ValidateGtBlockTimerCount(IN UINT8 *Ptr, IN VOID *Context)
{ UINT32 BlockTimerCount; BlockTimerCount = *(UINT32 *)Ptr; if (BlockTimerCount > GT_BLOCK_TIMER_COUNT_MAX) { IncrementErrorCount (); Print ( L"\nERROR: Timer Count = %d. Max Timer Count is %d.", BlockTimerCount, GT_BLOCK_TIMER_COUNT_MAX ); } }
tianocore/edk2
C++
Other
4,240
/* Internal function to add IO read/write opcode to the table. */
EFI_STATUS BootScriptWriteIoReadWrite(IN VA_LIST Marker)
/* Internal function to add IO read/write opcode to the table. */ EFI_STATUS BootScriptWriteIoReadWrite(IN VA_LIST Marker)
{ S3_BOOT_SCRIPT_LIB_WIDTH Width; UINT64 Address; UINT8 *Data; UINT8 *DataMask; Width = VA_ARG (Marker, S3_BOOT_SCRIPT_LIB_WIDTH); Address = VA_ARG (Marker, UINT64); Data = VA_ARG (Marker, UINT8 *); DataMask = VA_ARG (Marker, UINT8 *); return S3BootScriptSaveIoReadWrite (Width, Address, Data, DataMask); }
tianocore/edk2
C++
Other
4,240
/* If Map is NULL, then ASSERT(). If Item is NULL, then ASSERT(). */
BOOLEAN NetItemInMap(IN NET_MAP *Map, IN NET_MAP_ITEM *Item)
/* If Map is NULL, then ASSERT(). If Item is NULL, then ASSERT(). */ BOOLEAN NetItemInMap(IN NET_MAP *Map, IN NET_MAP_ITEM *Item)
{ LIST_ENTRY *ListEntry; ASSERT (Map != NULL && Item != NULL); NET_LIST_FOR_EACH (ListEntry, &Map->Used) { if (ListEntry == &Item->Link) { return TRUE; } } return FALSE; }
tianocore/edk2
C++
Other
4,240
/* brief Return Frequency of I3C function Slow TC clock return Frequency of I3C function slow TC Clock */
uint32_t CLOCK_GetI3cSTCClkFreq(void)
/* brief Return Frequency of I3C function Slow TC clock return Frequency of I3C function slow TC Clock */ uint32_t CLOCK_GetI3cSTCClkFreq(void)
{ uint32_t freq = 0U; switch (SYSCON->I3CFCLKSTCSEL) { case 0U: freq = CLOCK_GetI3cClkFreq(); break; case 1U: freq = CLOCK_GetFro1MFreq(); break; default: freq = 0U; break; } return freq / ((SYSCON->I3CFCLKSTCDIV & SYSCON_I3CFCLKSTCDIV_DIV_MASK) + 1U); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Recover reply buffers from pool. This happens when recovering from error conditions. Post-increment counter/array index. */
void rpcrdma_recv_buffer_get(struct rpcrdma_req *req)
/* Recover reply buffers from pool. This happens when recovering from error conditions. Post-increment counter/array index. */ void rpcrdma_recv_buffer_get(struct rpcrdma_req *req)
{ struct rpcrdma_buffer *buffers = req->rl_buffer; unsigned long flags; if (req->rl_iov.length == 0) buffers = ((struct rpcrdma_req *) buffers)->rl_buffer; spin_lock_irqsave(&buffers->rb_lock, flags); if (buffers->rb_recv_index < buffers->rb_max_requests) { req->rl_reply = buffers->rb_recv_bufs[buffers->rb_recv_index]; buffers->rb_recv_bufs[buffers->rb_recv_index++] = NULL; } spin_unlock_irqrestore(&buffers->rb_lock, flags); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Check if there is a new generated event. */
EFI_STATUS EFIAPI XhcCheckNewEvent(IN USB_XHCI_INSTANCE *Xhc, IN EVENT_RING *EvtRing, OUT TRB_TEMPLATE **NewEvtTrb)
/* Check if there is a new generated event. */ EFI_STATUS EFIAPI XhcCheckNewEvent(IN USB_XHCI_INSTANCE *Xhc, IN EVENT_RING *EvtRing, OUT TRB_TEMPLATE **NewEvtTrb)
{ ASSERT (EvtRing != NULL); *NewEvtTrb = EvtRing->EventRingDequeue; if (EvtRing->EventRingDequeue == EvtRing->EventRingEnqueue) { return EFI_NOT_READY; } EvtRing->EventRingDequeue++; if ((UINTN)EvtRing->EventRingDequeue >= ((UINTN)EvtRing->EventRingSeg0 + sizeof (TRB_TEMPLATE) * EvtRing->TrbNumber)) { EvtRing->EventRingDequeue = EvtRing->EventRingSeg0; } return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Configures the selected source to generate or not a global interrupt. */
uint8_t IOE_GITConfig(uint8_t DeviceAddr, uint8_t Global_IT, FunctionalState NewState)
/* Configures the selected source to generate or not a global interrupt. */ uint8_t IOE_GITConfig(uint8_t DeviceAddr, uint8_t Global_IT, FunctionalState NewState)
{ uint8_t tmp = 0; tmp = I2C_ReadDeviceRegister(DeviceAddr, IOE_REG_INT_EN); if (NewState != DISABLE) { tmp |= (uint8_t)Global_IT; } else { tmp &= ~(uint8_t)Global_IT; } I2C_WriteDeviceRegister(DeviceAddr, IOE_REG_INT_EN, tmp); return IOE_OK; }
remotemcu/remcu-chip-sdks
C++
null
436
/* compute nearest (signed) distance to calibrated value in 1024 circle */
int to_calibrated(const int calibrated, const int value)
/* compute nearest (signed) distance to calibrated value in 1024 circle */ int to_calibrated(const int calibrated, const int value)
{ return diff; } if (diff < 0) { return 1024 + diff; } return diff - 1024; }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Marks an entry to the directory index table as free. */
static void free_index(tid_t tid, struct inode *ip, u32 index, u32 next)
/* Marks an entry to the directory index table as free. */ static void free_index(tid_t tid, struct inode *ip, u32 index, u32 next)
{ struct dir_table_slot *dirtab_slot; s64 lblock; struct metapage *mp = NULL; dirtab_slot = find_index(ip, index, &mp, &lblock); if (!dirtab_slot) return; dirtab_slot->flag = DIR_INDEX_FREE; dirtab_slot->slot = dirtab_slot->addr1 = 0; dirtab_slot->addr2 = cpu_to_le32(next); if (mp) { lock_index(tid, ip, mp, index); mark_metapage_dirty(mp); release_metapage(mp); } else set_cflag(COMMIT_Dirtable, ip); }
robutest/uclinux
C++
GPL-2.0
60
/* Get detailed information on the requested logical processor. */
EFI_STATUS MpServicesUnitTestGetProcessorInfo(IN MP_SERVICES MpServices, IN UINTN ProcessorNumber, OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer)
/* Get detailed information on the requested logical processor. */ EFI_STATUS MpServicesUnitTestGetProcessorInfo(IN MP_SERVICES MpServices, IN UINTN ProcessorNumber, OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer)
{ return MpServices.Ppi->GetProcessorInfo (MpServices.Ppi, ProcessorNumber, ProcessorInfoBuffer); }
tianocore/edk2
C++
Other
4,240
/* Note that the mount structure gets modified to indicate that quotas are off AFTER this, in the case of quotaoff. */
void xfs_qm_dqrele_all_inodes(struct xfs_mount *mp, uint flags)
/* Note that the mount structure gets modified to indicate that quotas are off AFTER this, in the case of quotaoff. */ void xfs_qm_dqrele_all_inodes(struct xfs_mount *mp, uint flags)
{ ASSERT(mp->m_quotainfo); xfs_inode_ag_iterator(mp, xfs_dqrele_inode, flags, XFS_ICI_NO_TAG, 0); }
robutest/uclinux
C++
GPL-2.0
60
/* The function reads whole indexing tree and all nodes, so it is pretty heavy-weight. Returns zero if the file-system is consistent, %-EINVAL if not, and a negative error code in case of failure. */
int dbg_check_filesystem(struct ubifs_info *c)
/* The function reads whole indexing tree and all nodes, so it is pretty heavy-weight. Returns zero if the file-system is consistent, %-EINVAL if not, and a negative error code in case of failure. */ int dbg_check_filesystem(struct ubifs_info *c)
{ int err; struct fsck_data fsckd; if (!dbg_is_chk_fs(c)) return 0; fsckd.inodes = RB_ROOT; err = dbg_walk_index(c, check_leaf, NULL, &fsckd); if (err) goto out_free; err = check_inodes(c, &fsckd); if (err) goto out_free; free_inodes(&fsckd); return 0; out_free: ubifs_err(c, "file-system check failed with error %d", err); dump_stack(); free_inodes(&fsckd); return err; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Load the Target time stamp registers This function Loads the target time stamp registers with the values proviced */
void synopGMAC_TS_load_target_timestamp(synopGMACdevice *gmacdev, u32 sec_val, u32 sub_sec_val)
/* Load the Target time stamp registers This function Loads the target time stamp registers with the values proviced */ void synopGMAC_TS_load_target_timestamp(synopGMACdevice *gmacdev, u32 sec_val, u32 sub_sec_val)
{ synopGMACWriteReg(gmacdev->MacBase,GmacTSTargetTimeHigh,sec_val); synopGMACWriteReg(gmacdev->MacBase,GmacTSTargetTimeLow,sub_sec_val); return; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Clean all caches promptly. This just calls cache_clean repeatedly until we are sure that every cache has had a chance to be fully cleaned */
void cache_flush(void)
/* Clean all caches promptly. This just calls cache_clean repeatedly until we are sure that every cache has had a chance to be fully cleaned */ void cache_flush(void)
{ while (cache_clean() != -1) cond_resched(); while (cache_clean() != -1) cond_resched(); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Handles an incoming execute-write-response for the specified write-reliable-characteristic-values proc. */
static int ble_gattc_write_reliable_rx_exec(struct ble_gattc_proc *proc, int status)
/* Handles an incoming execute-write-response for the specified write-reliable-characteristic-values proc. */ static int ble_gattc_write_reliable_rx_exec(struct ble_gattc_proc *proc, int status)
{ ble_gattc_dbg_assert_proc_not_inserted(proc); ble_gattc_write_reliable_cb(proc, status, 0); return BLE_HS_EDONE; }
Nicholas3388/LuaNode
C++
Other
1,055
/* Puts a null terminaled string in the buffer or directly to the fifo. */
void am_hal_uart_string_transmit_buffered(uint32_t ui32Module, char *pcString)
/* Puts a null terminaled string in the buffer or directly to the fifo. */ void am_hal_uart_string_transmit_buffered(uint32_t ui32Module, char *pcString)
{ while (*pcString) { if (am_hal_queue_empty(&g_psTxQueue[ui32Module]) && !AM_BFRn(UART, ui32Module, FR, TXFF)) { AM_REGn(UART, ui32Module, DR) = *pcString; } else { am_hal_queue_item_add(&g_psTxQueue[ui32Module], pcString, 1); } pcString++; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Padlock instructions can generate a spurious DNA fault, so we have to call them in the context of irq_ts_save/restore() */
static u32 xstore(u32 *addr, u32 edx_in)
/* Padlock instructions can generate a spurious DNA fault, so we have to call them in the context of irq_ts_save/restore() */ static u32 xstore(u32 *addr, u32 edx_in)
{ u32 eax_out; int ts_state; ts_state = irq_ts_save(); asm(".byte 0x0F,0xA7,0xC0" :"=m"(*addr), "=a"(eax_out) :"D"(addr), "d"(edx_in)); irq_ts_restore(ts_state); return eax_out; }
robutest/uclinux
C++
GPL-2.0
60
/* Reads and returns the current value of MM2. This function is only available on IA-32 and x64. */
UINT64 EFIAPI AsmReadMm2(VOID)
/* Reads and returns the current value of MM2. This function is only available on IA-32 and x64. */ UINT64 EFIAPI AsmReadMm2(VOID)
{ _asm { push eax push eax movq [esp], mm2 pop eax pop edx emms } }
tianocore/edk2
C++
Other
4,240
/* Called when the "Export" dialog box is created and when the selected count changes. */
static void color_set_export_selected_sensitive(GtkWidget *cfselect_cb)
/* Called when the "Export" dialog box is created and when the selected count changes. */ static void color_set_export_selected_sensitive(GtkWidget *cfselect_cb)
{ if (color_selected_count() != 0) gtk_widget_set_sensitive(cfselect_cb, TRUE); else { color_selected = FALSE; gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cfselect_cb), FALSE); gtk_widget_set_sensitive(cfselect_cb, FALSE); } }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Fill in the ncpfs-specific information in the inode. */
static void ncp_update_dirent(struct inode *inode, struct ncp_entry_info *nwinfo)
/* Fill in the ncpfs-specific information in the inode. */ static void ncp_update_dirent(struct inode *inode, struct ncp_entry_info *nwinfo)
{ NCP_FINFO(inode)->DosDirNum = nwinfo->i.DosDirNum; NCP_FINFO(inode)->dirEntNum = nwinfo->i.dirEntNum; NCP_FINFO(inode)->volNumber = nwinfo->volume; }
robutest/uclinux
C++
GPL-2.0
60
/* It waits for the communication sequence with the device is completed. */
static USBPD_StatusTypeDef HW_IF_COMM_WAIT(uint8_t PortNum, int16_t Timeout)
/* It waits for the communication sequence with the device is completed. */ static USBPD_StatusTypeDef HW_IF_COMM_WAIT(uint8_t PortNum, int16_t Timeout)
{ USBPD_StatusTypeDef ret = USBPD_ERROR; int16_t timeout = Timeout; while (1) { if (Ports[PortNum].CommLock == 0) { Ports[PortNum].CommLock = 1; ret = USBPD_OK; break; } if (timeout == 0) { ret = USBPD_TIMEOUT; break; } if (timeout > 0) { timeout--; } } return ret; }
st-one/X-CUBE-USB-PD
C++
null
110
/* String comparison without regard to case for a limited number of characters. */
INTN StrniCmp(IN CONST CHAR16 *Source, IN CONST CHAR16 *Target, IN CONST UINTN Count)
/* String comparison without regard to case for a limited number of characters. */ INTN StrniCmp(IN CONST CHAR16 *Source, IN CONST CHAR16 *Target, IN CONST UINTN Count)
{ CHAR16 *SourceCopy; CHAR16 *TargetCopy; UINTN SourceLength; UINTN TargetLength; INTN Result; if (Count == 0) { return 0; } SourceLength = StrLen (Source); TargetLength = StrLen (Target); SourceLength = MIN (SourceLength, Count); TargetLength = MIN (TargetLength, Count); SourceCopy = AllocateCopyPool ((SourceLength + 1) * sizeof (CHAR16), Source); if (SourceCopy == NULL) { return -1; } TargetCopy = AllocateCopyPool ((TargetLength + 1) * sizeof (CHAR16), Target); if (TargetCopy == NULL) { FreePool (SourceCopy); return -1; } SourceCopy[SourceLength] = L'\0'; TargetCopy[TargetLength] = L'\0'; Result = gUnicodeCollation->StriColl (gUnicodeCollation, SourceCopy, TargetCopy); FreePool (SourceCopy); FreePool (TargetCopy); return Result; }
tianocore/edk2
C++
Other
4,240
/* Callback function for ADCIFE enter compasion window interrupt. */
static void adcife_set_wm_flag(void)
/* Callback function for ADCIFE enter compasion window interrupt. */ static void adcife_set_wm_flag(void)
{ adc_disable_interrupt(&g_adc_inst, ADC_WINDOW_MONITOR); g_uc_enter_win_flag = 1; adc_clear_status(&g_adc_inst, ADCIFE_SCR_WM); }
remotemcu/remcu-chip-sdks
C++
null
436
/* This function computes the start and end addresses for both erase and protect commands. The range of the addresses on which either of the commands is to operate can be given in two forms: */
static int addr_spec(char *arg1, char *arg2, ulong *addr_first, ulong *addr_last)
/* This function computes the start and end addresses for both erase and protect commands. The range of the addresses on which either of the commands is to operate can be given in two forms: */ static int addr_spec(char *arg1, char *arg2, ulong *addr_first, ulong *addr_last)
{ char *ep; char len_used; *addr_first = simple_strtoul(arg1, &ep, 16); if (ep == arg1 || *ep != '\0') return -1; len_used = 0; if (arg2 && *arg2 == '+'){ len_used = 1; ++arg2; } *addr_last = simple_strtoul(arg2, &ep, 16); if (ep == arg2 || *ep != '\0') return -1; if (len_used){ *addr_last = *addr_first + *addr_last - 1; if (flash_sect_roundb(addr_last) > 0) return -1; } return 1; }
EmcraftSystems/u-boot
C++
Other
181
/* Enables or disables access to the RTC and backup registers. */
void PWR_BackupAccessCmd(FunctionalState state)
/* Enables or disables access to the RTC and backup registers. */ void PWR_BackupAccessCmd(FunctionalState state)
{ (state) ? (RCC->BDCR |= RCC_BDCR_DBP) : (RCC->BDCR &= ~RCC_BDCR_DBP); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function is used to select the interrupt source used to trigger other modules. */
void TIMER_SetTriggerSource(TIMER_T *timer, uint32_t u32Src)
/* This function is used to select the interrupt source used to trigger other modules. */ void TIMER_SetTriggerSource(TIMER_T *timer, uint32_t u32Src)
{ timer->TRGCTL = (timer->TRGCTL & ~TIMER_TRGCTL_TRGSSEL_Msk) | u32Src; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This is the declaration of an EFI image entry point. This can be the entry point to an application written to this specification, an EFI boot service driver, or an EFI runtime driver. */
EFI_STATUS EFIAPI LibRtcInitialize(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
/* This is the declaration of an EFI image entry point. This can be the entry point to an application written to this specification, an EFI boot service driver, or an EFI runtime driver. */ EFI_STATUS EFIAPI LibRtcInitialize(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
{ EFI_STATUS Status; mPL031RtcBase = PcdGet32 (PcdPL031RtcBase); Status = gDS->AddMemorySpace ( EfiGcdMemoryTypeMemoryMappedIo, mPL031RtcBase, SIZE_4KB, EFI_MEMORY_UC | EFI_MEMORY_RUNTIME ); if (EFI_ERROR (Status)) { return Status; } Status = gDS->SetMemorySpaceAttributes (mPL031RtcBase, SIZE_4KB, EFI_MEMORY_UC | EFI_MEMORY_RUNTIME); if (EFI_ERROR (Status)) { return Status; } Status = gBS->CreateEventEx ( EVT_NOTIFY_SIGNAL, TPL_NOTIFY, VirtualNotifyEvent, NULL, &gEfiEventVirtualAddressChangeGuid, &mRtcVirtualAddrChangeEvent ); ASSERT_EFI_ERROR (Status); return Status; }
tianocore/edk2
C++
Other
4,240
/* Initialize the timer event for RTT (round trip time). */
EFI_STATUS PingInitRttTimer(PING_PRIVATE_DATA *Private)
/* Initialize the timer event for RTT (round trip time). */ EFI_STATUS PingInitRttTimer(PING_PRIVATE_DATA *Private)
{ EFI_STATUS Status; Private->TimerPeriod = GetTimerPeriod (); if (Private->TimerPeriod == 0) { return EFI_ABORTED; } Private->RttTimerTick = 0; Status = gBS->CreateEvent ( EVT_TIMER | EVT_NOTIFY_SIGNAL, TPL_NOTIFY, RttTimerTickRoutine, &Private->RttTimerTick, &Private->RttTimer ); if (EFI_ERROR (Status)) { return Status; } Status = gBS->SetTimer ( Private->RttTimer, TimerPeriodic, TICKS_PER_MS ); if (EFI_ERROR (Status)) { gBS->CloseEvent (Private->RttTimer); return Status; } return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Save the current location in LOC, return LOC. */
Location* loc_save(Location *loc)
/* Save the current location in LOC, return LOC. */ Location* loc_save(Location *loc)
{ *loc = *cur_loc; loc->prev = NULL; return loc; }
ve3wwg/teensy3_qemu
C++
Other
15
/* This function is used by rt_kprintf to display a string on console. */
void rt_hw_console_output(const char *str)
/* This function is used by rt_kprintf to display a string on console. */ void rt_hw_console_output(const char *str)
{ while (*str) { rt_hw_serial_putc(*str++); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Emit buffer after having waited long enough for more data to arrive. */
static void sclp_vt220_timeout(unsigned long data)
/* Emit buffer after having waited long enough for more data to arrive. */ static void sclp_vt220_timeout(unsigned long data)
{ sclp_vt220_emit_current(); }
robutest/uclinux
C++
GPL-2.0
60
/* This function does not return until the block has been erased. */
long FlashErase(unsigned long ulAddress)
/* This function does not return until the block has been erased. */ long FlashErase(unsigned long ulAddress)
{ ASSERT(!(ulAddress & (FLASH_ERASE_SIZE - 1))); HWREG(FLASH_FCMISC) = (FLASH_FCMISC_AMISC | FLASH_FCMISC_VOLTMISC | FLASH_FCMISC_ERMISC); HWREG(FLASH_FMA) = ulAddress; HWREG(FLASH_FMC) = FLASH_FMC_WRKEY | FLASH_FMC_ERASE; while(HWREG(FLASH_FMC) & FLASH_FMC_ERASE) { } if(HWREG(FLASH_FCRIS) & (FLASH_FCRIS_ARIS | FLASH_FCRIS_VOLTRIS | FLASH_FCRIS_ERRIS)) { return(-1); } return(0); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Enable the clock via the clock gating registers */
static void local_clk_enable(struct clk *clk)
/* Enable the clock via the clock gating registers */ static void local_clk_enable(struct clk *clk)
{ kinetis_periph_enable(clk->gate, 1); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Converts a PC Card device path structure to its string representative. */
VOID DevPathToTextPccard(IN OUT POOL_PRINT *Str, IN VOID *DevPath, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts)
/* Converts a PC Card device path structure to its string representative. */ VOID DevPathToTextPccard(IN OUT POOL_PRINT *Str, IN VOID *DevPath, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts)
{ PCCARD_DEVICE_PATH *Pccard; Pccard = DevPath; UefiDevicePathLibCatPrint (Str, L"PcCard(0x%x)", Pccard->FunctionNumber); }
tianocore/edk2
C++
Other
4,240
/* check if the specified device is MIDI mapped device */
static int is_midi_dev(struct seq_oss_devinfo *dp, int dev)
/* check if the specified device is MIDI mapped device */ static int is_midi_dev(struct seq_oss_devinfo *dp, int dev)
{ if (dev < 0 || dev >= dp->max_synthdev) return 0; if (dp->synths[dev].is_midi) return 1; return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Selects the data transfer direction in bi-directional mode for the specified SPI. */
void SPI_BiDirectionalLineConfig(SPI_TypeDef *SPIx, uint16_t SPI_Direction)
/* Selects the data transfer direction in bi-directional mode for the specified SPI. */ void SPI_BiDirectionalLineConfig(SPI_TypeDef *SPIx, uint16_t SPI_Direction)
{ assert_param(IS_SPI_ALL_PERIPH(SPIx)); assert_param(IS_SPI_DIRECTION(SPI_Direction)); if(SPI_Direction==SPI_Direction_Tx) { SPIx->GCTL |= SPI_Direction_Tx; } if(SPI_Direction==SPI_Direction_Rx) { SPIx->GCTL |= SPI_Direction_Rx; } if(SPI_Direction==SPI_Disable_Tx) { SPIx->GCTL &= SPI_Disable_Tx; } if(SPI_Direction==SPI_Disable_Rx) { SPIx->GCTL &= SPI_Disable_Rx; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function assumes there's a class methods table at index 1, and its metatable at 2, when it's initially called, and leaves them that way when done. */
int wslua_set__index(lua_State *L)
/* This function assumes there's a class methods table at index 1, and its metatable at 2, when it's initially called, and leaves them that way when done. */ int wslua_set__index(lua_State *L)
{ fprintf(stderr, "No metatable or class table in the Lua stack when registering __index!\n"); exit(1); } lua_pushvalue (L, 1); lua_rawsetfield(L, 2, "__methods"); lua_pushcfunction(L, wslua__index); lua_rawsetfield(L, 2, "__index"); return 0; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* LPTIM MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_LPTIM_MspDeInit(LPTIM_HandleTypeDef *hlptim)
/* LPTIM MSP De-Initialization This function freeze the hardware resources used in this example. */ void HAL_LPTIM_MspDeInit(LPTIM_HandleTypeDef *hlptim)
{ if(hlptim->Instance==LPTIM1) { __HAL_RCC_LPTIM1_CLK_DISABLE(); HAL_NVIC_DisableIRQ(LPTIM1_IRQn); } else if(hlptim->Instance==LPTIM2) { __HAL_RCC_LPTIM2_CLK_DISABLE(); HAL_NVIC_DisableIRQ(LPTIM2_IRQn); } else if(hlptim->Instance==LPTIM3) { __HAL_RCC_LPTIM3_CLK_DISABLE(); HAL_NVIC_DisableIRQ(LPTIM3_IRQn); } else if(hlptim->Instance==LPTIM4) { __HAL_RCC_LPTIM4_CLK_DISABLE(); HAL_NVIC_DisableIRQ(LPTIM4_IRQn); } else if(hlptim->Instance==LPTIM5) { __HAL_RCC_LPTIM5_CLK_DISABLE(); HAL_NVIC_DisableIRQ(LPTIM5_IRQn); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* #cairo_scaled_font_t represents a realization of a font face at a particular size and transformation and a certain set of font options. */
static uint32_t _cairo_scaled_font_compute_hash(cairo_scaled_font_t *scaled_font)
/* #cairo_scaled_font_t represents a realization of a font face at a particular size and transformation and a certain set of font options. */ static uint32_t _cairo_scaled_font_compute_hash(cairo_scaled_font_t *scaled_font)
{ uint32_t hash = FNV1_32_INIT; hash = _hash_matrix_fnv (&scaled_font->font_matrix, hash); hash = _hash_matrix_fnv (&scaled_font->ctm, hash); hash = _hash_mix_bits (hash); hash ^= (unsigned long) scaled_font->original_font_face; hash ^= cairo_font_options_hash (&scaled_font->options); hash = _hash_mix_bits (hash); assert (hash != ZOMBIE); return hash; }
xboot/xboot
C++
MIT License
779
/* Return an iteration function for 'io.lines'. If file has to be closed, also returns the file itself as a second result (to be closed as the state at the exit of a generic for). */
static int io_lines(lua_State *L)
/* Return an iteration function for 'io.lines'. If file has to be closed, also returns the file itself as a second result (to be closed as the state at the exit of a generic for). */ static int io_lines(lua_State *L)
{ lua_getfield(L, LUA_REGISTRYINDEX, IO_INPUT); lua_replace(L, 1); tofile(L); toclose = 0; } else { const char *filename = luaL_checkstring(L, 1); opencheck(L, filename, "r"); lua_replace(L, 1); toclose = 1; } aux_lines(L, toclose); if (toclose) { lua_pushnil(L); lua_pushnil(L); lua_pushvalue(L, 1); return 4; } else return 1; }
Nicholas3388/LuaNode
C++
Other
1,055
/* brief Return Frequency of LP_OSC return Frequency of LP_OSC */
static uint32_t CLOCK_GetLposcFreq(void)
/* brief Return Frequency of LP_OSC return Frequency of LP_OSC */ static uint32_t CLOCK_GetLposcFreq(void)
{ uint32_t freq = 0U; switch ((RTC0->CTRL & RTC_CTRL_CLK_SEL_MASK) >> RTC_CTRL_CLK_SEL_SHIFT) { case 1U: freq = CLOCK_GetOsc32KFreq((uint32_t)kCLOCK_Osc32kToVbat); break; case 2U: freq = CLOCK_GetClk16KFreq((uint32_t)kCLOCK_Clk16KToVbat); break; default: freq = 0U; break; } return freq; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function schedule the USB transaction and will process the endpoint in the following order: iso, interrupt, control and bulk. */
void fhci_schedule_transactions(struct fhci_usb *usb)
/* This function schedule the USB transaction and will process the endpoint in the following order: iso, interrupt, control and bulk. */ void fhci_schedule_transactions(struct fhci_usb *usb)
{ int left = 1; if (usb->actual_frame->frame_status & FRAME_END_TRANSMISSION) if (rotate_frames(usb) != 0) return; if (usb->actual_frame->frame_status & FRAME_END_TRANSMISSION) return; if (usb->actual_frame->total_bytes == 0) { scan_ed_list(usb, &usb->hc_list->iso_list, FHCI_TF_ISO); scan_ed_list(usb, &usb->hc_list->intr_list, FHCI_TF_INTR); left = scan_ed_list(usb, &usb->hc_list->ctrl_list, FHCI_TF_CTRL); } if (left > 0) scan_ed_list(usb, &usb->hc_list->bulk_list, FHCI_TF_BULK); }
robutest/uclinux
C++
GPL-2.0
60
/* Get a pointer to the window area struct. This function returns a pointer to the internal area struct of a window. It cannot be modified, but could be copied from. */
const struct win_area* win_get_area(const struct win_window *win)
/* Get a pointer to the window area struct. This function returns a pointer to the internal area struct of a window. It cannot be modified, but could be copied from. */ const struct win_area* win_get_area(const struct win_window *win)
{ Assert(win != NULL); return &win->attributes.area; }
memfault/zero-to-main
C++
null
200
/* If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT(). */
UINT8* EFIAPI S3MmioWriteBuffer8(IN UINTN StartAddress, IN UINTN Length, IN CONST UINT8 *Buffer)
/* If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT(). If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT(). */ UINT8* EFIAPI S3MmioWriteBuffer8(IN UINTN StartAddress, IN UINTN Length, IN CONST UINT8 *Buffer)
{ UINT8 *ReturnBuffer; RETURN_STATUS Status; ReturnBuffer = MmioWriteBuffer8 (StartAddress, Length, Buffer); Status = S3BootScriptSaveMemWrite ( S3BootScriptWidthUint8, StartAddress, Length / sizeof (UINT8), ReturnBuffer ); ASSERT (Status == RETURN_SUCCESS); return ReturnBuffer; }
tianocore/edk2
C++
Other
4,240
/* Erase Sector in Flash Memory Parameter: adr: Sector Address Return Value: 0 - OK, 1 - Failed */
uint32_t EraseSector(uint32_t adr)
/* Erase Sector in Flash Memory Parameter: adr: Sector Address Return Value: 0 - OK, 1 - Failed */ uint32_t EraseSector(uint32_t adr)
{ cortex_int_state_t state = cortex_int_get_and_disable(); int status = FLASH_Erase(&g_flash, adr, g_flash.PFlashSectorSize, kFLASH_ApiEraseKey); if (status == kStatus_Success) { status = FLASH_VerifyErase(&g_flash, adr, g_flash.PFlashSectorSize); } cortex_int_restore(state); return status; }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* port_uc_addr_set - This function Set the port Unicast address. */
static void port_uc_addr_set(struct kwgbe_registers *regs, u8 *p_addr)
/* port_uc_addr_set - This function Set the port Unicast address. */ static void port_uc_addr_set(struct kwgbe_registers *regs, u8 *p_addr)
{ u32 mac_h; u32 mac_l; mac_l = (p_addr[4] << 8) | (p_addr[5]); mac_h = (p_addr[0] << 24) | (p_addr[1] << 16) | (p_addr[2] << 8) | (p_addr[3] << 0); KWGBEREG_WR(regs->macal, mac_l); KWGBEREG_WR(regs->macah, mac_h); port_uc_addr(regs, p_addr[5], ACCEPT_MAC_ADDR); }
EmcraftSystems/u-boot
C++
Other
181
/* Get the number of valid entries in receive FIFO. */
u32 USI_SSI_GetRxCount(USI_TypeDef *usi_dev)
/* Get the number of valid entries in receive FIFO. */ u32 USI_SSI_GetRxCount(USI_TypeDef *usi_dev)
{ u32 valid_cnt = (USI_SSI_GetRxFIFOStatus(usi_dev) & USI_RXFIFO_VALID_CNT) >> 8; return valid_cnt; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Check the arguments provided in the command line: set args based on it or defaults, and check they are correct */
void nsi_handle_cmd_line(int argc, char *argv[])
/* Check the arguments provided in the command line: set args based on it or defaults, and check they are correct */ void nsi_handle_cmd_line(int argc, char *argv[])
{ bs_args_set_defaults(args_struct); global_args.verb = 2; bs_trace_set_level(global_args.verb); for (int i = 0; i < extra_argc; i++) { nsi_handle_one_cmdline_argument(extra_argv[i]); } for (int i = 1; i < argc; i++) { nsi_handle_one_cmdline_argument(argv[i]); } }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Initialises the CPU, setting up the PLL, etc. */
void cpuInit(void)
/* Initialises the CPU, setting up the PLL, etc. */ void cpuInit(void)
{ gpioInit(); GPIO_GPIO0DIR &= ~(GPIO_IO_ALL); GPIO_GPIO1DIR &= ~(GPIO_IO_ALL); GPIO_GPIO2DIR &= ~(GPIO_IO_ALL); GPIO_GPIO3DIR &= ~(GPIO_IO_ALL); cpuPllSetup(CPU_MULTIPLIER_6); }
microbuilder/LPC1343CodeBase
C++
Other
73
/* This call will set the mode for the @gpio to input. */
static int msp71xx_direction_input(struct gpio_chip *chip, unsigned offset)
/* This call will set the mode for the @gpio to input. */ static int msp71xx_direction_input(struct gpio_chip *chip, unsigned offset)
{ return msp71xx_set_gpio_mode(chip, offset, MSP71XX_GPIO_INPUT); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Called to set the global channel mask that we use for all connections. */
void ble_ll_conn_set_global_chanmap(uint8_t num_used_chans, const uint8_t *chanmap)
/* Called to set the global channel mask that we use for all connections. */ void ble_ll_conn_set_global_chanmap(uint8_t num_used_chans, const uint8_t *chanmap)
{ struct ble_ll_conn_sm *connsm; struct ble_ll_conn_global_params *conn_params; conn_params = &g_ble_ll_conn_params; if (!memcmp(conn_params->master_chan_map, chanmap, BLE_LL_CONN_CHMAP_LEN)) { return; } conn_params->num_used_chans = num_used_chans; memcpy(conn_params->master_chan_map, chanmap, BLE_LL_CONN_CHMAP_LEN); SLIST_FOREACH(connsm, &g_ble_ll_conn_active_list, act_sle) { if (connsm->conn_role == BLE_LL_CONN_ROLE_MASTER) { ble_ll_ctrl_proc_start(connsm, BLE_LL_CTRL_PROC_CHAN_MAP_UPD); } } }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* CCID_IsSlotStatusChange Provides the value of the variable for the slot change status. */
uint8_t CCID_IsSlotStatusChange(USBD_HandleTypeDef *pdev)
/* CCID_IsSlotStatusChange Provides the value of the variable for the slot change status. */ uint8_t CCID_IsSlotStatusChange(USBD_HandleTypeDef *pdev)
{ USBD_CCID_HandleTypeDef *hccid = (USBD_CCID_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId]; return hccid->SlotStatus.SlotStatusChange; }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Get actual prescaler division ratio. @rmtoll CFG PRESC LPTIM_GetPrescaler. */
uint32_t LPTIM_GetPrescaler(LPTIM_Module *LPTIMx)
/* Get actual prescaler division ratio. @rmtoll CFG PRESC LPTIM_GetPrescaler. */ uint32_t LPTIM_GetPrescaler(LPTIM_Module *LPTIMx)
{ return (uint32_t)(READ_BIT(LPTIMx->CFG, LPTIM_CFG_CLKPRE)); }
pikasTech/PikaPython
C++
MIT License
1,403
/* Enables or disables the receiver of an USART peripheral */
void USART_SetReceiverEnabled(AT91S_USART *usart, unsigned char enabled)
/* Enables or disables the receiver of an USART peripheral */ void USART_SetReceiverEnabled(AT91S_USART *usart, unsigned char enabled)
{ if (enabled) { usart->US_CR = AT91C_US_RXEN; } else { usart->US_CR = AT91C_US_RXDIS; } }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Returns the last conversion result data for injected channel of SDADC1 and SDADC3. JSYNC bit of the SDADC3 should be already set. */
uint32_t SDADC_GetInjectedConversionSDADC13Value(void)
/* Returns the last conversion result data for injected channel of SDADC1 and SDADC3. JSYNC bit of the SDADC3 should be already set. */ uint32_t SDADC_GetInjectedConversionSDADC13Value(void)
{ return (uint32_t) SDADC1->JDATA13R; }
avem-labs/Avem
C++
MIT License
1,752
/* Get the PWM duty of the PWM module. The */
unsigned long PWMDutyGet(unsigned long ulBase, unsigned long ulChannel)
/* Get the PWM duty of the PWM module. The */ unsigned long PWMDutyGet(unsigned long ulBase, unsigned long ulChannel)
{ unsigned long ulCMRData; unsigned long ulCNRData; xASSERT((ulBase == PWMA_BASE) || (ulBase == PWMB_BASE) || (ulBase == PWMC_BASE)); if(ulBase == PWMA_BASE) { xASSERT((ulChannel >= 0) && (ulChannel <= 5)); } else { xASSERT((ulChannel >= 0) && (ulChannel <= 1)); } ulCNRData = PWMMODGet(ulBase); ulCMRData = xHWREG(ulBase + TPM_C0V + ulChannel * 8); return ((ulCMRData + 1) * 100 / (ulCNRData + 1)); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Attribute write call back for the Long descriptor V2D1 attribute. */
static ssize_t write_long_des_v2d1_2(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 Long descriptor V2D1 attribute. */ static ssize_t write_long_des_v2d1_2(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(long_des_v2d1_2_value)) return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); if (offset + len > sizeof(long_des_v2d1_2_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
/* dispose of a reference to a writeback record */
void afs_put_writeback(struct afs_writeback *wb)
/* dispose of a reference to a writeback record */ void afs_put_writeback(struct afs_writeback *wb)
{ struct afs_vnode *vnode = wb->vnode; _enter("{%d}", wb->usage); spin_lock(&vnode->writeback_lock); if (--wb->usage == 0) afs_unlink_writeback(wb); else wb = NULL; spin_unlock(&vnode->writeback_lock); if (wb) afs_free_writeback(wb); }
robutest/uclinux
C++
GPL-2.0
60
/* socrates_nand_read_byte - read one byte from the chip @mtd: MTD device structure */
static uint8_t socrates_nand_read_byte(struct mtd_info *mtd)
/* socrates_nand_read_byte - read one byte from the chip @mtd: MTD device structure */ static uint8_t socrates_nand_read_byte(struct mtd_info *mtd)
{ uint8_t byte; socrates_nand_read_buf(mtd, &byte, sizeof(byte)); return byte; }
robutest/uclinux
C++
GPL-2.0
60
/* Get the player index of a joystick, or -1 if it's not available */
int SDL_JoystickGetDevicePlayerIndex(int device_index)
/* Get the player index of a joystick, or -1 if it's not available */ int SDL_JoystickGetDevicePlayerIndex(int device_index)
{ int player_index; SDL_LockJoysticks(); player_index = SDL_GetPlayerIndexForJoystickID(SDL_JoystickGetDeviceInstanceID(device_index)); SDL_UnlockJoysticks(); return player_index; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Configure the RTC timer count after which interrupts comes. */
static void configure_rtc_count(void)
/* Configure the RTC timer count after which interrupts comes. */ static void configure_rtc_count(void)
{ struct rtc_count_config config_rtc_count; rtc_count_get_config_defaults(&config_rtc_count); config_rtc_count.prescaler = RTC_COUNT_PRESCALER_DIV_1; config_rtc_count.mode = RTC_COUNT_MODE_16BIT; config_rtc_count.continuously_update = true; rtc_count_init(&rtc_instance,RTC,&config_rtc_count); rtc_count_enable(&rtc_instance); }
remotemcu/remcu-chip-sdks
C++
null
436