Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 28 Apr 2003 22:44:21 -0700 (PDT)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 30030 for review
Message-ID:  <200304290544.h3T5iLpd075762@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=30030

Change 30030 by marcel@marcel_nfs on 2003/04/28 22:43:51

	RIFia64_epc (Reverse IF)

Affected files ...

.. //depot/projects/ia64/sys/dev/acpica/acpi_timer.c#11 integrate

Differences ...

==== //depot/projects/ia64/sys/dev/acpica/acpi_timer.c#11 (text+ko) ====

@@ -37,7 +37,6 @@
 #include <sys/time.h>
 #endif
 
-#include <machine/bus_pio.h>
 #include <machine/bus.h>
 #include <machine/resource.h>
 #include <sys/rman.h>
@@ -61,9 +60,6 @@
 
 static device_t	acpi_timer_dev;
 struct resource	*acpi_timer_reg;
-#define TIMER_READ	bus_space_read_4(rman_get_bustag(acpi_timer_reg),	\
-					 rman_get_bushandle(acpi_timer_reg),	\
-					 0)
 
 static u_int	acpi_timer_frequency = 14318182/4;
 
@@ -75,6 +71,9 @@
 static int	acpi_timer_sysctl_freq(SYSCTL_HANDLER_ARGS);
 static void	acpi_timer_test(void);
 
+static u_int32_t read_counter(void);
+static int test_counter(void);
+
 /*
  * Driver hung off ACPI.
  */
@@ -106,7 +105,20 @@
     "ACPI"
 };
 
-static int test_counter(void);
+
+static u_int32_t
+read_counter()
+{
+	bus_space_handle_t bsh;
+	bus_space_tag_t bst;
+	u_int32_t tv;
+
+	bsh = rman_get_bushandle(acpi_timer_reg);
+	bst = rman_get_bustag(acpi_timer_reg);
+	tv = bus_space_read_4(bst, bsh, 0);
+	bus_space_barrier(bst, bsh, 0, 4, BUS_SPACE_BARRIER_READ);
+	return (tv);
+}
 
 #define N 2000
 static int
@@ -117,9 +129,9 @@
 
 	min = 10000000;
 	max = 0;
-	last = TIMER_READ;
+	last = read_counter();
 	for (n = 0; n < N; n++) {
-		this = TIMER_READ;
+		this = read_counter();
 		delta = (this - last) & 0xffffff;
 		if (delta > max)
 			max = delta;
@@ -167,11 +179,11 @@
     acpi_timer_dev = dev;
 
     rid = 0;
-    rlen = 3 + AcpiGbl_FADT->TmrValExt;		/* 24 or 32 bit timers. */
+    rlen = AcpiGbl_FADT->PmTmLen;
     rtype = (AcpiGbl_FADT->XPmTmrBlk.AddressSpaceId)
       ? SYS_RES_IOPORT : SYS_RES_MEMORY;
     rstart = AcpiGbl_FADT->XPmTmrBlk.Address;
-    bus_set_resource(dev, rtype, rid, rstart, 4);
+    bus_set_resource(dev, rtype, rid, rstart, rlen);
     acpi_timer_reg = bus_alloc_resource(dev, rtype, &rid, 0, ~0, 1, RF_ACTIVE);
     if (acpi_timer_reg == NULL) {
 	device_printf(dev, "couldn't allocate I/O resource (%s 0x%lx)\n",
@@ -194,7 +206,8 @@
     }
     tc_init(&acpi_timer_timecounter);
 
-    sprintf(desc, "%d-bit timer at 3.579545MHz", (int)(rlen << 3));
+    sprintf(desc, "%d-bit timer at 3.579545MHz", (AcpiGbl_FADT->TmrValExt)
+      ? 32 : 24);
     device_set_desc_copy(dev, desc);
 
     return_VOID;
@@ -220,7 +233,7 @@
 static unsigned
 acpi_timer_get_timecount(struct timecounter *tc)
 {
-    return(TIMER_READ);
+    return (read_counter());
 }
 
 /*
@@ -232,12 +245,12 @@
 {
     unsigned u1, u2, u3;
 
-    u2 = TIMER_READ;
-    u3 = TIMER_READ;
+    u2 = read_counter();
+    u3 = read_counter();
     do {
 	u1 = u2;
 	u2 = u3;
-	u3 = TIMER_READ;
+	u3 = read_counter();
     } while (u1 > u2 || u2 > u3 || (u3 - u1) > 15);
     return (u2);
 }
@@ -274,9 +287,9 @@
 {
     u_int32_t	u1, u2, u3;
     
-    u1 = TIMER_READ;
-    u2 = TIMER_READ;
-    u3 = TIMER_READ;
+    u1 = read_counter();
+    u2 = read_counter();
+    u3 = read_counter();
     
     device_printf(acpi_timer_dev, "timer test in progress, reboot to quit.\n");
     for (;;) {
@@ -291,7 +304,7 @@
 	}
 	u1 = u2;
 	u2 = u3;
-	u3 = TIMER_READ;
+	u3 = read_counter();
     }
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200304290544.h3T5iLpd075762>