Skip to contentSkip to conversation

powerpc: Add OF address parsing code

PATCH New Benjamin Herrenschmidt 1 participant 1 message Nov 22, 2005 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc: Add OF address parsing code

Parsing addresses extracted from Open Firmware isn't a simple matter. We have various bits of code that try to do it in various place, including some heuristics in prom.c that pre-parse addresses at boot and fill device-nodes "addrs", but those are dodgy at best and I want to deprecate them. So this patch introduces a new set of routines that should be capable of parsing most types of addresses and translating them into CPU physical addresses. It currently works for things on PCI busses and ISA busses and should work on "standard" busses like the root bus or the MacIO bus that don't put funky flags in addresses. If you have other bus types that do use funky flags, you'll have to add new bus type translators, which is fairly easy.

---

This is not for 2.6.15. It's part of a series of patch which, when complete, will unify serial port detection and udbg, and remove completely "addrs" and the crappy heuristics from prom.c

arch/powerpc/kernel/Makefile +2 -1
Index: linux-serialfix/arch/powerpc/kernel/Makefile
===================================================================
@@ -12,7 +12,8 @@
 endif
 
 obj-y				:= semaphore.o cputable.o ptrace.o syscalls.o \
-				   irq.o align.o signal_32.o pmc.o vdso.o
+				   irq.o align.o signal_32.o pmc.o vdso.o \
+				   prom_parse.o
 obj-y				+= vdso32/
 obj-$(CONFIG_PPC64)		+= setup_64.o binfmt_elf32.o sys_ppc32.o \
 				   signal_64.o ptrace32.o systbl.o \
arch/powerpc/kernel/prom_parse.c new file +404 -0

404 lines not on this page · raw message

include/asm-powerpc/mmu.h +4 -0
Index: linux-serialfix/include/asm-powerpc/mmu.h
===================================================================
@@ -393,6 +393,10 @@
 #define VSID_SCRAMBLE(pvsid)	(((pvsid) * VSID_MULTIPLIER) % VSID_MODULUS)
 #define KERNEL_VSID(ea)		VSID_SCRAMBLE(GET_ESID(ea))
 
+/* Physical address used by some IO functions */
+typedef unsigned long phys_addr_t;
+
+
 #endif /* __ASSEMBLY */
 
 #endif /* CONFIG_PPC64 */
include/asm-powerpc/prom.h +9 -0
Index: linux-serialfix/include/asm-powerpc/prom.h
===================================================================
@@ -223,5 +223,14 @@
 				int index, const char* name_postfix);
 extern int release_OF_resource(struct device_node* node, int index);
 
+/*
+ * Address translation function(s)
+ */
+#define OF_BAD_ADDR	((u64)-1)
+extern u64 of_translate_address(struct device_node *np, u32 *addr);
+extern u32 *of_get_address(struct device_node *dev, int index, u64 *size);
+extern u32 *of_get_pci_addr(struct device_node *pd, int bar, u64 *out_size);
+
+
 #endif /* __KERNEL__ */
 #endif /* _POWERPC_PROM_H */
include/asm-ppc/prom.h +10 -0
Index: linux-serialfix/include/asm-ppc/prom.h
===================================================================
@@ -136,5 +136,15 @@
 #define PTRRELOC(x)	((typeof(x))add_reloc_offset((unsigned long)(x)))
 #define PTRUNRELOC(x)	((typeof(x))sub_reloc_offset((unsigned long)(x)))
 
+
+/*
+ * Address translation function(s)
+ */
+#define OF_BAD_ADDR	((u64)-1)
+extern u64 of_translate_address(struct device_node *np, u32 *addr);
+extern u32 *of_get_address(struct device_node *dev, int index, u64 *size);
+extern u32 *of_get_pci_addr(struct device_node *pd, int bar, u64 *out_size);
+
+
 #endif /* _PPC_PROM_H */
 #endif /* __KERNEL__ */