Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/evbmips/mipssim Use CPU frequencies defined in QEMU...



details:   https://anonhg.NetBSD.org/src/rev/d4098e76ee37
branches:  trunk
changeset: 1026277:d4098e76ee37
user:      simonb <simonb%NetBSD.org@localhost>
date:      Tue Nov 16 06:44:40 2021 +0000

description:
Use CPU frequencies defined in QEMU for mipssim - 6 MHz for 64-bit
guests and 12 MHz for 32-bit guests.

diffstat:

 sys/arch/evbmips/mipssim/machdep.c |  25 ++++++++++++++++---------
 1 files changed, 16 insertions(+), 9 deletions(-)

diffs (65 lines):

diff -r 87cd634aff03 -r d4098e76ee37 sys/arch/evbmips/mipssim/machdep.c
--- a/sys/arch/evbmips/mipssim/machdep.c        Tue Nov 16 06:15:48 2021 +0000
+++ b/sys/arch/evbmips/mipssim/machdep.c        Tue Nov 16 06:44:40 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.2 2021/02/15 22:39:46 reinoud Exp $ */
+/* $NetBSD: machdep.c,v 1.3 2021/11/16 06:44:40 simonb Exp $ */
 
 /*-
  * Copyright (c) 2001,2021 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.2 2021/02/15 22:39:46 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.3 2021/11/16 06:44:40 simonb Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -73,6 +73,16 @@
 #define        COMCNRATE       115200          /* not important, emulated device */
 #define        COM_FREQ        1843200         /* not important, emulated device */
 
+/*
+ * QEMU/mipssim sets the CPU frequency to 6 MHz for 64-bit guests and
+ * 12 MHz for 32-bit guests.
+ */
+#ifdef _LP64
+#define        CPU_FREQ        6       /* MHz */
+#else
+#define        CPU_FREQ        12      /* MHz */
+#endif
+
 /* XXX move phys map decl to a general mips location */
 /* Maps for VM objects. */
 struct vm_map *phys_map = NULL;
@@ -113,11 +123,7 @@
 {
        uint32_t cntfreq;
 
-       /*
-        * Qemu seems to default to 200 MHz; wall clock looks the right speed
-        * but we don't have an RTC to check.
-        */
-       cntfreq = curcpu()->ci_cpu_freq = 200 * 1000 * 1000;
+       cntfreq = curcpu()->ci_cpu_freq = CPU_FREQ * 1000 * 1000;
 
        if (mips_options.mips_cpu_flags & CPU_MIPS_DOUBLE_COUNT)
                cntfreq /= 2;
@@ -147,13 +153,14 @@
        /* enough of a console for printf() to work */
        cn_tab = &early_console;
 
-       cal_timer();
-
        /* set CPU model info for sysctl_hw */
        cpu_setmodel("MIPSSIM");
 
        mips_vector_init(NULL, false);
 
+       /* must be after CPU is identified in mips_vector_init() */
+       cal_timer();
+
        uvm_md_init();
 
        /*



Home | Main Index | Thread Index | Old Index