iPXE
Functions | Variables
timer.c File Reference
#include <string.h>
#include <ipxe/process.h>
#include <ipxe/console.h>
#include <ipxe/keys.h>
#include <ipxe/nap.h>
#include <ipxe/init.h>
#include <ipxe/timer.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
unsigned long currticks (void)
 Get current system time in ticks.
void udelay (unsigned long usecs)
 Delay for a fixed number of microseconds.
void mdelay (unsigned long msecs)
 Delay for a fixed number of milliseconds.
static unsigned int sleep_interruptible (unsigned int secs, int(*interrupted)(void))
 Sleep (possibly interruptibly) for a fixed number of seconds.
static int keypress_interrupted (void)
 Check if sleep has been interrupted by keypress.
unsigned int sleep (unsigned int secs)
 Sleep (interruptibly) for a fixed number of seconds.
void sleep_fixed (unsigned int secs)
 Sleep (uninterruptibly) for a fixed number of seconds.
static void timer_probe (void)
 Find a working timer.
struct init_fn timer_init_fn __init_fn (INIT_EARLY)
 Timer initialisation function.
 REQUIRING_SYMBOL (timer_init_fn)
 REQUIRE_OBJECT (config_timer)

Variables

static struct timertimer
 Current timer.

Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
unsigned long currticks ( void  )

Get current system time in ticks.

Return values:
ticksCurrent time, in ticks

Definition at line 42 of file timer.c.

References timer::currticks, and DBGC.

Referenced by ath5k_attach(), ath5k_poll(), ath_ani_calibrate(), ath_hw_pll_work(), ath_isr(), ath_set_channel(), ath_start_ani(), ath_tx_complete_poll_work(), ath_tx_start_dma(), control_dc_dc(), cs89x0_reset(), cs89x0_transmit(), davicom_media_chk(), davicom_reset(), davicom_transmit(), davicom_wait(), detect_tp(), dhcp_discovery_expired(), dhcp_discovery_rx(), dhcp_proxy_expired(), dhcp_pxebs_expired(), dhcp_set_state(), dhcpv6_tx(), epic100_transmit(), eth_rx_overrun(), getchar_timeout(), hermon_set_port_type(), hunt_mcdi_request_poll(), hunt_poll(), monojob_wait(), net80211_probe_start(), net80211_probe_step(), net80211_rx_frag(), net80211_step_associate(), nv_mgmt_get_version(), peerblk_timestamp(), pxe_menu_prompt_and_select(), random(), retry_poll(), send_test_pkt(), sis900_transmit(), sleep_interruptible(), smc9000_transmit(), start_dhcpv6(), start_timer_fixed(), stop_timer(), sundance_transmit(), t3c515_wait(), tcp_shutdown(), tcp_xmit_sack(), time_exec(), timer_expired(), tlan_transmit(), tulip_reset(), tulip_transmit(), tulip_wait(), w89c840_transmit(), wait_eeprom_ready(), and xenbus_backend_wait().

                                 {

        /* Guard against use during early initialisation */
        if ( ! timer ) {
                DBGC ( &timer, "TIMER currticks() called before initialisation "
                       "from %p\n", __builtin_return_address ( 0 ) );
                return 0;
        }

        /* Use selected timer */
        return timer->currticks();
}
void udelay ( unsigned long  usecs)

Delay for a fixed number of microseconds.

Parameters:
usecsNumber of microseconds for which to delay

Definition at line 60 of file timer.c.

References DBGC, and timer::udelay.

Referenced by __gm_phy_read(), __tg3_set_rx_mode(), __vxge_hw_device_register_poll(), __xm_phy_read(), _tw32_flush(), a3c90x_internal_WaitForEeprom(), amd8111e_read_phy(), ar5008_hw_init_bb(), ar5008_hw_process_ini(), ar5008_hw_rfbus_done(), ar9002_hw_configpcipowersave(), ar9002_olc_init(), ar9003_get_pll_sqsum_dvc(), ar9003_hw_init_bb(), ar9003_hw_init_cal(), ar9003_hw_internal_regulator_apply(), ar9003_hw_rfbus_done(), ar9271_hw_pa_cal(), ar9285_hw_pa_cal(), ath5k_hw_eeprom_read(), ath5k_hw_nic_reset(), ath5k_hw_nic_wakeup(), ath5k_hw_reset(), ath5k_hw_rf5110_calibrate(), ath5k_hw_stop_rx_dma(), ath5k_hw_stop_tx_dma(), ath5k_hw_wake(), ath9k_hw_abort_tx_dma(), ath9k_hw_analog_shift_regwrite(), ath9k_hw_analog_shift_rmw(), ath9k_hw_chip_test(), ath9k_hw_def_set_board_values(), ath9k_hw_init_pll(), ath9k_hw_loadnf(), ath9k_hw_reset(), ath9k_hw_set_power_awake(), ath9k_hw_set_reset(), ath9k_hw_set_reset_power_on(), ath9k_hw_set_reset_reg(), ath9k_hw_stopdmarecv(), ath9k_hw_wait(), atl1e_read_phy_reg(), atl1e_write_phy_reg(), b44_phy_reset(), b44_wait_bit(), bflush(), bnx2_init_chip(), bnx2_read_phy(), bnx2_reset_chip(), bnx2_reset_phy(), bnx2_setup_copper_phy(), bnx2_setup_serdes_phy(), bnx2_write_phy(), deactivate_t509_device(), dm96xx_reset(), dmfe_disable(), dmfe_init_dm910x(), eepro_transmit(), eeprom_rdy(), eisa_device_enabled(), falcon_gmii_wait(), falcon_mdio_read(), falcon_mdio_write(), falcon_reset_xaui(), falcon_reset_xmac(), falcon_setup_nic(), falcon_spi_wait(), falcon_tenxpress_check_c11(), falcon_txc_logic_reset(), fiber_autoneg(), flexboot_nodnic_complete_all_tx(), forcedeth_open(), genesis_mac_init(), gm_phy_write(), hfa384x_docmd_wait(), hfa384x_prepare_bap(), hfa384x_wait_for_event(), hunt_mcdi_request_poll(), i2c_delay(), ifec_mdio_read(), ifec_mdio_write(), ifec_reset(), ifec_scb_cmd_wait(), intelxl_close(), intelxl_enable_ring(), intelxl_open(), is_pmu_set(), isapnp_delay(), jme_check_link(), jme_mdio_read(), jme_mdio_write(), jme_reset_mac_processor(), linda_ib_epb_request(), linda_ib_epb_wait(), linda_init_ib_serdes(), linda_link_state_check(), mdelay(), mentormac_init(), mentormac_reset(), mii_bit_xfer(), mii_rw(), mlx_utils_delay_in_us_priv(), myri10ge_command(), net80211_probe_step(), nii_delay(), nv_mac_reset(), nv_mgmt_acquire_sema(), nv_stop_rx(), nv_stop_tx(), nv_txrx_reset(), phy_read_1bit(), phy_write_1bit(), qib7322_ahb_wait(), qib7322_link_state_check(), read_srom_word(), realtek_mii_read(), realtek_mii_write(), reg_delay(), rhine_mii_autopoll(), rhine_mii_read(), rhine_mii_write(), rhine_reload_eeprom(), rhine_reset(), rtl818x_probe(), rtl818x_spi_write_bit(), rtl8225_read(), rtl8225_write(), sfe4001_init(), sis190_get_mac_addr_from_apc(), sis190_mii_probe_88e1111_fixup(), sis190_phy_task(), sis96x_get_mac_addr(), smc_read_phy_register(), smc_write_phy_register(), smsc95xx_reset(), spi_bit_delay(), spi_wait(), sundance_probe(), t509_enable(), t509_id_read_eeprom(), t509_poll(), t515_poll(), t595_disable(), t595_poll(), t595_reset(), t5x9_disable(), tg3_abort_hw(), tg3_bmcr_reset(), tg3_chip_reset(), tg3_clear_mac_status(), tg3_do_test_dma(), tg3_fiber_aneg_smachine(), tg3_get_invariants(), tg3_init_5401phy_dsp(), tg3_init_bcm8002(), tg3_issue_otp_command(), tg3_nvram_exec_cmd(), tg3_nvram_lock(), tg3_phy_reset(), tg3_poll_fw(), tg3_readphy(), tg3_reset_hw(), tg3_setup_copper_phy(), tg3_setup_fiber_by_hand(), tg3_setup_fiber_hw_autoneg(), tg3_setup_fiber_mii_phy(), tg3_setup_fiber_phy(), tg3_stop_block(), tg3_wait_for_event_ack(), tg3_writephy(), TLan_FinishReset(), TLan_PhyFinishAutoNeg(), tlan_probe(), TLan_ResetAdapter(), update_cr6(), usleep(), velocity_autopoll_start(), velocity_autopoll_stop(), velocity_mii_read(), velocity_mii_write(), velocity_reload_eeprom(), velocity_reset(), vxsetlink(), and xm_phy_write().

                                    {

        /* Guard against use during early initialisation */
        if ( ! timer ) {
                DBGC ( &timer, "TIMER udelay() called before initialisation "
                       "from %p\n", __builtin_return_address ( 0 ) );
                return;
        }

        /* Use selected timer */
        timer->udelay ( usecs );
}
void mdelay ( unsigned long  msecs)

Delay for a fixed number of milliseconds.

Parameters:
msecsNumber of milliseconds for which to delay

Definition at line 78 of file timer.c.

References DBGC, and udelay().

Referenced by __mdio_cmd(), _wgetc(), acpi_poweroff(), amd8111e_wait_tx_ring(), arbel_cmd_wait(), arbel_reset(), ath5k_hw_attach(), ath5k_hw_nic_wakeup(), ath5k_hw_noise_floor_calibration(), ath5k_hw_radio_revision(), ath5k_hw_reset(), ath5k_hw_rf5110_calibrate(), ath5k_hw_rf5110_channel(), atl1e_down(), atl1e_get_permanent_address(), atl1e_phy_commit(), atl1e_phy_init(), atl1e_reset_hw(), atl1e_setup_pcicmd(), axge_probe(), bnx2_fw_sync(), bnx2_probe(), bnx2_reset_chip(), bnx2_set_power_state_0(), bnx2_transmit(), dmfe_init_dm910x(), efab_init_mac(), efi_usb_sync_transfer(), ehci_async_del(), ehci_legacy_claim(), ehci_periodic_del(), ehci_reset(), ehci_root_enable(), ehci_root_open(), ehci_stop(), ena_admin(), ena_reset(), falcon_fini_resources(), falcon_init_sram(), falcon_init_xmac(), falcon_reset(), falcon_tenxpress_phy_init(), golan_cmd_wait(), hermon_cmd_wait(), hermon_reset(), hub_enable(), hub_open(), hunt_clear_udp_tunnel_ports(), hv_wait_for_message(), icplus_read_eeprom(), icplus_reset(), ifec_net_open(), igbvf_close(), igbvf_configure_tx(), intel_disable_ring(), intel_init_eeprom(), intel_read_eeprom(), intel_reset(), intelvf_mbox_msg(), intelvf_mbox_wait(), intelx_reset(), intelxl_admin_command(), intelxl_context_dump(), intelxl_context_line(), intelxl_disable_ring(), intelxl_reset(), jme_disable_rx_engine(), jme_disable_tx_engine(), jme_reload_eeprom(), lan78xx_reset(), linda_trim_ib(), mdio_clause45_reset_mmd(), mdio_clause45_wait_reset_mmds(), mii_reset(), mlx_utils_delay_in_ms_priv(), myson_reload_config(), myson_soft_reset(), myson_wait_idle(), natsemi_reload_config(), natsemi_soft_reset(), netvsc_control(), nv_mgmt_acquire_sema(), nv_mgmt_get_version(), pci_vpd_read_dword(), pci_vpd_write_dword(), phantom_clp_wait(), phantom_init_cmdpeg(), phantom_init_rcvpeg(), phantom_read_test_mem_block(), phantom_wait_for_cmd(), phy_init(), phy_reset(), qib7322_reset(), realtek_reset(), register_usb(), register_usb_hub(), rhine_open(), rndis_wait(), rtc_entropy_check(), rtl818x_init_hw(), rtl8225_rf_init(), rtl8225_rf_set_channel(), rtl8225_rf_set_tx_power(), rtl8225_rf_stop(), rtl8225x_rf_init(), rtl8225z2_rf_init(), rtl8225z2_rf_set_tx_power(), sfe4001_init(), sis190_phy_task(), sis190_read_eeprom(), smc_phy_configure(), smsc75xx_reset(), smscusb_eeprom_wait(), smscusb_mii_wait(), smscusb_otp_power_up(), smscusb_otp_wait(), t509_enable(), tg3_get_eeprom_hw_cfg(), tg3_nvram_read_using_eeprom(), tg3_poll_fw(), threewire_write(), TLan_FinishReset(), TLan_PhyFinishAutoNeg(), TLan_PhyPowerDown(), TLan_PhyPowerUp(), TLan_PhyReset(), TLan_PhyStartLink(), txnic_bgx_spu_init(), txnic_disable_cq(), txnic_disable_rq(), txnic_disable_sq(), uart_transmit(), uhci_async_del(), uhci_periodic_del(), uhci_reset(), uhci_root_enable(), uhci_stop(), undinet_probe(), usb_control(), vpm_reset(), write_grf5101(), write_max2820(), write_sa2400(), xhci_abort(), xhci_command(), xhci_legacy_claim(), xhci_reset(), xhci_root_enable(), xhci_root_open(), and xhci_stop().

                                    {

        /* Guard against use during early initialisation */
        if ( ! timer ) {
                DBGC ( &timer, "TIMER mdelay() called before initialisation "
                       "from %p\n", __builtin_return_address ( 0 ) );
                return;
        }

        /* Delay for specified number of milliseconds */
        while ( msecs-- )
                udelay ( 1000 );
}
static unsigned int sleep_interruptible ( unsigned int  secs,
int(*)(void)  interrupted 
) [static]

Sleep (possibly interruptibly) for a fixed number of seconds.

Parameters:
secsNumber of seconds for which to delay
interruptedInterrupt checking method, or NULL
Return values:
secsNumber of seconds remaining, if interrupted

Definition at line 99 of file timer.c.

References cpu_nap(), currticks(), start, step(), and TICKS_PER_SEC.

Referenced by sleep(), and sleep_fixed().

                                                                           {
        unsigned long start = currticks();
        unsigned long now;

        for ( ; secs ; secs-- ) {
                while ( ( ( now = currticks() ) - start ) < TICKS_PER_SEC ) {
                        step();
                        if ( interrupted && interrupted() )
                                return secs;
                        cpu_nap();
                }
                start = now;
        }

        return 0;
}
static int keypress_interrupted ( void  ) [static]

Check if sleep has been interrupted by keypress.

Return values:
interruptedSleep has been interrupted

Definition at line 122 of file timer.c.

References CTRL_C, getchar(), and iskey().

Referenced by sleep().

                                         {

        return ( iskey() && ( getchar() == CTRL_C ) );
}
unsigned int sleep ( unsigned int  secs)

Sleep (interruptibly) for a fixed number of seconds.

Parameters:
secsNumber of seconds for which to delay
Return values:
secsNumber of seconds remaining, if interrupted

Definition at line 133 of file timer.c.

References keypress_interrupted(), and sleep_interruptible().

Referenced by sleep_exec(), and valert().

void sleep_fixed ( unsigned int  secs)

Sleep (uninterruptibly) for a fixed number of seconds.

Parameters:
secsNumber of seconds for which to delay

Definition at line 143 of file timer.c.

References NULL, and sleep_interruptible().

Referenced by sandev_command().

                                       {

        sleep_interruptible ( secs, NULL );
}
static void timer_probe ( void  ) [static]

Find a working timer.

Definition at line 152 of file timer.c.

References DBGC, for_each_table_entry, timer::name, NULL, timer::probe, rc, strerror(), and TIMERS.

                                 {
        int rc;

        /* Use first working timer */
        for_each_table_entry ( timer, TIMERS ) {
                if ( ( timer->probe == NULL ) ||
                     ( ( rc = timer->probe() ) == 0 ) ) {
                        DBGC ( &timer, "TIMER using %s\n", timer->name );
                        return;
                }
                DBGC ( &timer, "TIMER could not initialise %s: %s\n",
                       timer->name, strerror ( rc ) );
        }

        /* This is a fatal error */
        DBGC ( &timer, "TIMER found no working timers!\n" );
        while ( 1 ) {}
}
struct init_fn timer_init_fn __init_fn ( INIT_EARLY  ) [read]

Timer initialisation function.

REQUIRING_SYMBOL ( timer_init_fn  )
REQUIRE_OBJECT ( config_timer  )

Variable Documentation

struct timer* timer [static]

Current timer.

Definition at line 35 of file timer.c.

Referenced by _wgetc(), retry_poll(), and t515_probe().