Changeset bd41ac52 in mainline for uspace/drv/nic


Ignore:
Timestamp:
2018-08-25T22:21:25Z (7 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
cca80a2
Parents:
e2625b1a
Message:

Get rid of sys/time.h

This commit moves the POSIX-like time functionality from libc's
sys/time.h to libposix and introduces C11-like or HelenOS-specific
interfaces to libc.

Specifically, use of sys/time.h, struct timeval, suseconds_t and
gettimeofday is replaced by time.h (C11), struct timespec (C11), usec_t
(HelenOS) and getuptime / getrealtime (HelenOS).

Also attempt to fix the implementation of clock() to return microseconds
(clocks) rather than processor cycles and move it to libc.

Location:
uspace/drv/nic
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/nic/e1k/e1k.c

    re2625b1a rbd41ac52  
    327327}
    328328
    329 static uint16_t e1000_calculate_itr_interval_from_usecs(suseconds_t useconds)
     329static uint16_t e1000_calculate_itr_interval_from_usecs(usec_t useconds)
    330330{
    331331        return useconds * 4;
     
    12991299}
    13001300
    1301 /** Calculates ITR register interrupt from timeval structure
     1301/** Calculates ITR register interrupt from timespec structure
    13021302 *
    13031303 * @param period Period
    13041304 *
    13051305 */
    1306 static uint16_t e1000_calculate_itr_interval(const struct timeval *period)
     1306static uint16_t e1000_calculate_itr_interval(const struct timespec *period)
    13071307{
    13081308        // TODO: use also tv_sec
    1309         return e1000_calculate_itr_interval_from_usecs(period->tv_usec);
     1309        return e1000_calculate_itr_interval_from_usecs(NSEC2USEC(period->tv_nsec));
    13101310}
    13111311
     
    13211321 */
    13221322static errno_t e1000_poll_mode_change(nic_t *nic, nic_poll_mode_t mode,
    1323     const struct timeval *period)
     1323    const struct timespec *period)
    13241324{
    13251325        assert(nic);
     
    21822182                goto err_rx_structure;
    21832183
    2184         struct timeval period;
     2184        struct timespec period;
    21852185        period.tv_sec = 0;
    2186         period.tv_usec = E1000_DEFAULT_INTERRUPT_INTERVAL_USEC;
     2186        period.tv_nsec = USEC2NSEC(E1000_DEFAULT_INTERRUPT_INTERVAL_USEC);
    21872187        rc = nic_report_poll_mode(nic, NIC_POLL_PERIODIC, &period);
    21882188        if (rc != EOK)
  • uspace/drv/nic/rtl8139/driver.c

    re2625b1a rbd41ac52  
    313313
    314314static errno_t rtl8139_poll_mode_change(nic_t *nic_data, nic_poll_mode_t mode,
    315     const struct timeval *period);
     315    const struct timespec *period);
    316316static void rtl8139_poll(nic_t *nic_data);
    317317
     
    20682068 */
    20692069static errno_t rtl8139_poll_mode_change(nic_t *nic_data, nic_poll_mode_t mode,
    2070     const struct timeval *period)
     2070    const struct timespec *period)
    20712071{
    20722072        assert(nic_data);
  • uspace/drv/nic/rtl8139/general.c

    re2625b1a rbd41ac52  
    8585 */
    8686errno_t rtl8139_timer_act_init(rtl8139_timer_act_t *ta, uint32_t timer_freq,
    87     const struct timeval *time)
     87    const struct timespec *time)
    8888{
    8989        if (!ta || timer_freq == 0 || !time)
     
    9595        ta->full_val = seconds_in_reg * tics_per_ms * 1000;
    9696
    97         struct timeval remains = *time;
     97        struct timespec remains = *time;
    9898        ta->full_skips = remains.tv_sec / seconds_in_reg;
    9999        remains.tv_sec = remains.tv_sec % seconds_in_reg;
    100100
    101         if (remains.tv_usec > RTL8139_USEC_IN_SEC) {
    102                 remains.tv_sec += remains.tv_usec / RTL8139_USEC_IN_SEC;
    103                 remains.tv_usec = remains.tv_usec % RTL8139_USEC_IN_SEC;
     101        if (NSEC2USEC(remains.tv_nsec) > RTL8139_USEC_IN_SEC) {
     102                remains.tv_sec += NSEC2USEC(remains.tv_nsec) / RTL8139_USEC_IN_SEC;
     103                remains.tv_nsec = NSEC2USEC(remains.tv_nsec) % RTL8139_USEC_IN_SEC;
    104104
    105105                /* it can be increased above seconds_in_reg again */
     
    108108        }
    109109
    110         ta->last_val = remains.tv_sec * 1000 + remains.tv_usec / 1000;
     110        ta->last_val = SEC2MSEC(remains.tv_sec) + NSEC2MSEC(remains.tv_nsec);
    111111        ta->last_val *= tics_per_ms;
    112112
  • uspace/drv/nic/rtl8139/general.h

    re2625b1a rbd41ac52  
    3636
    3737#include <stddef.h>
     38#include <stdint.h>
    3839#include <time.h>
    3940
     
    6263    size_t);
    6364extern errno_t rtl8139_timer_act_init(rtl8139_timer_act_t *, uint32_t,
    64     const struct timeval *);
     65    const struct timespec *);
    6566extern int rtl8139_timer_act_step(rtl8139_timer_act_t *, uint32_t *);
    6667
Note: See TracChangeset for help on using the changeset viewer.