patch-2.4.0-test9 linux/include/asm-arm/arch-sa1100/mmzone.h

Next file: linux/include/asm-arm/arch-sa1100/system.h
Previous file: linux/include/asm-arm/arch-sa1100/memory.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test8/linux/include/asm-arm/arch-sa1100/mmzone.h linux/include/asm-arm/arch-sa1100/mmzone.h
@@ -11,6 +11,14 @@
  *
  * Of course, all this isn't mandatory for SA1100 implementations with only
  * one used memory bank.  For those, simply undefine CONFIG_DISCONTIGMEM.
+ *
+ * The nodes are matched with the physical memory bank addresses which are 
+ * incidentally the same as virtual addresses.
+ * 
+ * 	node 0:  0xc0000000 - 0xc7ffffff
+ * 	node 1:  0xc8000000 - 0xcfffffff
+ * 	node 2:  0xd0000000 - 0xd7ffffff
+ * 	node 3:  0xd8000000 - 0xdfffffff
  */
 
 
@@ -20,18 +28,6 @@
 extern pg_data_t sa1100_node_data[];
 
 /*
- * 32MB max in each bank, must fit with __virt_to_phys() & __phys_to_virt()
- */
-#define NODE_MAX_MEM_SHIFT	25
-#define NODE_MAX_MEM_SIZE	(1<<NODE_MAX_MEM_SHIFT)
-
-/*
- * Given a kernel address, find the home node of the underlying memory.
- */
-#define KVADDR_TO_NID(addr) \
-		(((unsigned long)(addr) - PAGE_OFFSET) >> NODE_MAX_MEM_SHIFT)
-
-/*
  * Return a pointer to the node data for node n.
  */
 #define NODE_DATA(nid)	(&sa1100_node_data[nid])
@@ -42,11 +38,10 @@
 #define NODE_MEM_MAP(nid)	(NODE_DATA(nid)->node_mem_map)
 
 /*
- * Given a mem_map_t, LOCAL_MAP_BASE finds the owning node for the
- * physical page and returns the kaddr for the mem_map of that node.
+ * Given a kernel address, find the home node of the underlying memory.
  */
-#define LOCAL_MAP_BASE(page) \
-			NODE_MEM_MAP(KVADDR_TO_NID((unsigned long)(page)))
+#define KVADDR_TO_NID(addr) \
+		(((unsigned long)(addr) & 0x18000000) >> 27)
 
 /*
  * Given a kaddr, ADDR_TO_MAPBASE finds the owning node of the memory
@@ -56,28 +51,22 @@
 			NODE_MEM_MAP(KVADDR_TO_NID((unsigned long)(kaddr)))
 
 /*
- * Given a kaddr, LOCAL_BASE_ADDR finds the owning node of the memory
- * and returns the kaddr corresponding to first physical page in the
- * node's mem_map.
- */
-#define LOCAL_BASE_ADDR(kaddr)	((unsigned long)(kaddr) & ~(NODE_MAX_MEM_SIZE-1))
-
-/*
  * Given a kaddr, LOCAL_MEM_MAP finds the owning node of the memory
  * and returns the index corresponding to the appropriate page in the
  * node's mem_map.
  */
 #define LOCAL_MAP_NR(kvaddr) \
-	(((unsigned long)(kvaddr)-LOCAL_BASE_ADDR((kvaddr))) >> PAGE_SHIFT)
+	(((unsigned long)(kvaddr) & 0x07ffffff) >> PAGE_SHIFT)
 
-/* 
- * With discontigmem, the conceptual mem_map array starts from PAGE_OFFSET.
- * Given a kaddr, MAP_NR returns the appropriate global mem_map index so 
- * it matches the corresponding node's local mem_map.
- */
-#define MAP_NR(kaddr)	(LOCAL_MAP_NR((kaddr)) + \
-		(((unsigned long)ADDR_TO_MAPBASE((kaddr)) - PAGE_OFFSET) / \
-		sizeof(mem_map_t)))
+/*
+ * Given a kaddr, virt_to_page returns a pointer to the corresponding 
+ * mem_map entry.
+ */
+#define virt_to_page(kaddr) \
+	(ADDR_TO_MAPBASE(kaddr) + LOCAL_MAP_NR(kaddr))
+
+/*
+ * Didn't find the best way to validate a page pointer yet...
+ */
 
-#define virt_to_page(kaddr)	(mem_map + MAP_NR(kaddr))
-#define VALID_PAGE(page)	((page - mem_map) < max_mapnr)
+#define VALID_PAGE(page)	(1)

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)