Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 6 May 2014 13:46:36 +0000 (UTC)
From:      Ian Lepore <ian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r265441 - head/sys/arm/arm
Message-ID:  <201405061346.s46Dka0O021517@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ian
Date: Tue May  6 13:46:36 2014
New Revision: 265441
URL: http://svnweb.freebsd.org/changeset/base/265441

Log:
  Break out the code that figures out the L2 cache geometry to its own
  routine, so that it can be called from multiple places in upcoming changes.

Modified:
  head/sys/arm/arm/pl310.c

Modified: head/sys/arm/arm/pl310.c
==============================================================================
--- head/sys/arm/arm/pl310.c	Tue May  6 13:38:34 2014	(r265440)
+++ head/sys/arm/arm/pl310.c	Tue May  6 13:46:36 2014	(r265441)
@@ -320,6 +320,23 @@ pl310_inv_range(vm_paddr_t start, vm_siz
 	PL310_UNLOCK(pl310_softc);
 }
 
+static void
+pl310_set_way_sizes(struct pl310_softc *sc)
+{
+	uint32_t aux_value;
+
+	aux_value = pl310_read4(sc, PL310_AUX_CTRL);
+	g_way_size = (aux_value & AUX_CTRL_WAY_SIZE_MASK) >>
+	    AUX_CTRL_WAY_SIZE_SHIFT;
+	g_way_size = 1 << (g_way_size + 13);
+	if (aux_value & (1 << AUX_CTRL_ASSOCIATIVITY_SHIFT))
+		g_ways_assoc = 16;
+	else
+		g_ways_assoc = 8;
+	g_l2cache_way_mask = (1 << g_ways_assoc) - 1;
+	g_l2cache_size = g_way_size * g_ways_assoc;
+}
+
 static int
 pl310_probe(device_t dev)
 {
@@ -371,16 +388,9 @@ pl310_attach(device_t dev)
 	device_printf(dev, "Part number: 0x%x, release: 0x%x\n",
 	    (cache_id >> CACHE_ID_PARTNUM_SHIFT) & CACHE_ID_PARTNUM_MASK,
 	    (cache_id >> CACHE_ID_RELEASE_SHIFT) & CACHE_ID_RELEASE_MASK);
-	aux_value = pl310_read4(sc, PL310_AUX_CTRL);
-	g_way_size = (aux_value & AUX_CTRL_WAY_SIZE_MASK) >>
-	    AUX_CTRL_WAY_SIZE_SHIFT;
-	g_way_size = 1 << (g_way_size + 13);
-	if (aux_value & (1 << AUX_CTRL_ASSOCIATIVITY_SHIFT))
-		g_ways_assoc = 16;
-	else
-		g_ways_assoc = 8;
-	g_l2cache_way_mask = (1 << g_ways_assoc) - 1;
-	g_l2cache_size = g_way_size * g_ways_assoc;
+
+	pl310_set_way_sizes();
+
 	/* Print the information */
 	device_printf(dev, "L2 Cache: %uKB/%dB %d ways\n", (g_l2cache_size / 1024),
 	       g_l2cache_line_size, g_ways_assoc);



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