Commit 690b286f authored by Peter Maydell's avatar Peter Maydell
Browse files

Merge remote-tracking branch 'remotes/vivier-misc/tags/pull-muldiv64-20150925' into staging



Remove muldiv64() by using period instead of frequency

# gpg: Signature made Fri 25 Sep 2015 14:54:37 BST using RSA key ID 3F2FBE3C
# gpg: Good signature from "Laurent Vivier <lvivier@redhat.com>"
# gpg:                 aka "Laurent Vivier <laurent@vivier.eu>"
# gpg:                 aka "Laurent Vivier (Red Hat) <lvivier@redhat.com>"
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: CD2F 75DD C8E3 A4DC 2E4F  5173 F30C 38BD 3F2F BE3C

* remotes/vivier-misc/tags/pull-muldiv64-20150925:
  net: remove muldiv64()
  bt: remove muldiv64()
  hpet: remove muldiv64()
  arm: clarify the use of muldiv64()
  openrisc: remove muldiv64()
  mips: remove muldiv64()
  pcnet: remove muldiv64()
  rtl8139: remove muldiv64()
  i6300esb: remove muldiv64()

Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parents cdf98182 ab60b748
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -595,7 +595,7 @@ static void bt_hci_inquiry_result(struct bt_hci_s *hci,
static void bt_hci_mod_timer_1280ms(QEMUTimer *timer, int period)
{
    timer_mod(timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +
                   muldiv64(period << 7, get_ticks_per_sec(), 100));
                     (uint64_t)(period << 7) * 10000000);
}

static void bt_hci_inquiry_start(struct bt_hci_s *hci, int length)
@@ -1099,7 +1099,7 @@ static int bt_hci_mode_change(struct bt_hci_s *hci, uint16_t handle,
    bt_hci_event_status(hci, HCI_SUCCESS);

    timer_mod(link->acl_mode_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +
                   muldiv64(interval * 625, get_ticks_per_sec(), 1000000));
                                    ((uint64_t)interval * 625) * 1000);
    bt_hci_lmp_mode_change_master(hci, link->link, mode, interval);

    return 0;
+8 −11
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@
#include "qemu/timer.h"
#include "sysemu/kvm.h"

#define TIMER_FREQ	100 * 1000 * 1000
#define TIMER_PERIOD 10 /* 10 ns period for 100 Mhz frequency */

/* XXX: do not use a global */
uint32_t cpu_mips_get_random (CPUMIPSState *env)
@@ -57,9 +57,8 @@ static void cpu_mips_timer_update(CPUMIPSState *env)
    uint32_t wait;

    now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
    wait = env->CP0_Compare - env->CP0_Count -
	    (uint32_t)muldiv64(now, TIMER_FREQ, get_ticks_per_sec());
    next = now + muldiv64(wait, get_ticks_per_sec(), TIMER_FREQ);
    wait = env->CP0_Compare - env->CP0_Count - (uint32_t)(now / TIMER_PERIOD);
    next = now + (uint64_t)wait * TIMER_PERIOD;
    timer_mod(env->timer, next);
}

@@ -87,8 +86,7 @@ uint32_t cpu_mips_get_count (CPUMIPSState *env)
            cpu_mips_timer_expire(env);
        }

        return env->CP0_Count +
            (uint32_t)muldiv64(now, TIMER_FREQ, get_ticks_per_sec());
        return env->CP0_Count + (uint32_t)(now / TIMER_PERIOD);
    }
}

@@ -103,9 +101,8 @@ void cpu_mips_store_count (CPUMIPSState *env, uint32_t count)
        env->CP0_Count = count;
    else {
        /* Store new count register */
        env->CP0_Count =
            count - (uint32_t)muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL),
                                       TIMER_FREQ, get_ticks_per_sec());
        env->CP0_Count = count -
               (uint32_t)(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) / TIMER_PERIOD);
        /* Update timer timer */
        cpu_mips_timer_update(env);
    }
@@ -129,8 +126,8 @@ void cpu_mips_start_count(CPUMIPSState *env)
void cpu_mips_stop_count(CPUMIPSState *env)
{
    /* Store the current value */
    env->CP0_Count += (uint32_t)muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL),
                                         TIMER_FREQ, get_ticks_per_sec());
    env->CP0_Count += (uint32_t)(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) /
                                 TIMER_PERIOD);
}

static void mips_timer_cb (void *opaque)
+1 −2
Original line number Diff line number Diff line
@@ -670,8 +670,7 @@ static inline hwaddr pcnet_rdra_addr(PCNetState *s, int idx)
static inline int64_t pcnet_get_next_poll_time(PCNetState *s, int64_t current_time)
{
    int64_t next_time = current_time +
        muldiv64(65536 - (CSR_SPND(s) ? 0 : CSR_POLL(s)),
                 get_ticks_per_sec(), 33000000L);
                        (65536 - (CSR_SPND(s) ? 0 : CSR_POLL(s))) * 30;
    if (next_time <= current_time)
        next_time = current_time + 1;
    return next_time;
+6 −8
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@
/* debug RTL8139 card */
//#define DEBUG_RTL8139 1

#define PCI_FREQUENCY 33000000L
#define PCI_PERIOD 30    /* 30 ns period = 33.333333 Mhz frequency */

#define SET_MASKED(input, mask, curr) \
    ( ( (input) & ~(mask) ) | ( (curr) & (mask) ) )
@@ -2834,8 +2834,7 @@ static void rtl8139_io_writew(void *opaque, uint8_t addr, uint32_t val)

static void rtl8139_set_next_tctr_time(RTL8139State *s)
{
    const uint64_t ns_per_period =
        muldiv64(0x100000000LL, get_ticks_per_sec(), PCI_FREQUENCY);
    const uint64_t ns_per_period = (uint64_t)PCI_PERIOD << 32;

    DPRINTF("entered rtl8139_set_next_tctr_time\n");

@@ -2853,7 +2852,7 @@ static void rtl8139_set_next_tctr_time(RTL8139State *s)
    if (!s->TimerInt) {
        timer_del(s->timer);
    } else {
        uint64_t delta = muldiv64(s->TimerInt, get_ticks_per_sec(), PCI_FREQUENCY);
        uint64_t delta = (uint64_t)s->TimerInt * PCI_PERIOD;
        if (s->TCTR_base + delta <= qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)) {
            delta += ns_per_period;
        }
@@ -3127,8 +3126,8 @@ static uint32_t rtl8139_io_readl(void *opaque, uint8_t addr)
            break;

        case Timer:
            ret = muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) - s->TCTR_base,
                           PCI_FREQUENCY, get_ticks_per_sec());
            ret = (qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) - s->TCTR_base) /
                  PCI_PERIOD;
            DPRINTF("TCTR Timer read val=0x%08x\n", ret);
            break;

@@ -3222,8 +3221,7 @@ static void rtl8139_pre_save(void *opaque)
    int64_t current_time = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);

    /* for migration to older versions */
    s->TCTR = muldiv64(current_time - s->TCTR_base, PCI_FREQUENCY,
                       get_ticks_per_sec());
    s->TCTR = (current_time - s->TCTR_base) / PCI_PERIOD;
    s->rtl8139_mmio_io_addr_dummy = 0;
}

+3 −4
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@
#include "hw/hw.h"
#include "qemu/timer.h"

#define TIMER_FREQ    (20 * 1000 * 1000)    /* 20MHz */
#define TIMER_PERIOD 50 /* 50 ns period for 20 MHz timer */

/* The time when TTCR changes */
static uint64_t last_clk;
@@ -36,8 +36,7 @@ void cpu_openrisc_count_update(OpenRISCCPU *cpu)
        return;
    }
    now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
    cpu->env.ttcr += (uint32_t)muldiv64(now - last_clk, TIMER_FREQ,
                                        get_ticks_per_sec());
    cpu->env.ttcr += (uint32_t)((now - last_clk) / TIMER_PERIOD);
    last_clk = now;
}

@@ -59,7 +58,7 @@ void cpu_openrisc_timer_update(OpenRISCCPU *cpu)
    } else {
        wait = (cpu->env.ttmr & TTMR_TP) - (cpu->env.ttcr & TTMR_TP);
    }
    next = now + muldiv64(wait, get_ticks_per_sec(), TIMER_FREQ);
    next = now + (uint64_t)wait * TIMER_PERIOD;
    timer_mod(cpu->env.timer, next);
}

Loading