static void __init prom_init_mem(void){	phandle node;	char *path, type[64];	unsigned int plen;	cell_t *p, *endp;	struct prom_t *_prom = &RELOC(prom);	u32 rac, rsc;	/*	 * We iterate the memory nodes to find	 * 1) top of RMO (first node)	 * 2) top of memory	 */	rac = 2;	prom_getprop(_prom->root, "#address-cells", &rac, sizeof(rac));	rsc = 1;	prom_getprop(_prom->root, "#size-cells", &rsc, sizeof(rsc));	prom_debug("root_addr_cells: %x\n", (unsigned long) rac);	prom_debug("root_size_cells: %x\n", (unsigned long) rsc);	prom_debug("scanning memory:\n");	path = RELOC(prom_scratch);	for (node = 0; prom_next_node(&node); ) {		type[0] = 0;		prom_getprop(node, "device_type", type, sizeof(type));		if (strcmp(type, RELOC("memory")))			continue;			plen = prom_getprop(node, "reg", RELOC(regbuf), sizeof(regbuf));		if (plen > sizeof(regbuf)) {			prom_printf("memory node too large for buffer !\n");			plen = sizeof(regbuf);		}		p = RELOC(regbuf);		endp = p + (plen / sizeof(cell_t));#ifdef DEBUG_PROM		memset(path, 0, PROM_SCRATCH_SIZE);		call_prom("package-to-path", 3, 1, node, path, PROM_SCRATCH_SIZE-1);		prom_debug("  node %s :\n", path);#endif /* DEBUG_PROM */		while ((endp - p) >= (rac + rsc)) {			unsigned long base, size;			base = prom_next_cell(rac, &p);			size = prom_next_cell(rsc, &p);			if (size == 0)				continue;			prom_debug("    %x %x\n", base, size);			if (base == 0)				RELOC(rmo_top) = size;			if ((base + size) > RELOC(ram_top))				RELOC(ram_top) = base + size;		}	}	RELOC(alloc_bottom) = PAGE_ALIGN((unsigned long)&RELOC(_end) + 0x4000);	/* Check if we have an initrd after the kernel, if we do move our bottom	 * point to after it	 */	if (RELOC(prom_initrd_start)) {		if (RELOC(prom_initrd_end) > RELOC(alloc_bottom))			RELOC(alloc_bottom) = PAGE_ALIGN(RELOC(prom_initrd_end));	}	/*	 * If prom_memory_limit is set we reduce the upper limits *except* for	 * alloc_top_high. This must be the real top of RAM so we can put	 * TCE's up there.	 */	RELOC(alloc_top_high) = RELOC(ram_top);	if (RELOC(prom_memory_limit)) {		if (RELOC(prom_memory_limit) <= RELOC(alloc_bottom)) {			prom_printf("Ignoring mem=%x <= alloc_bottom.\n",				RELOC(prom_memory_limit));			RELOC(prom_memory_limit) = 0;		} else if (RELOC(prom_memory_limit) >= RELOC(ram_top)) {			prom_printf("Ignoring mem=%x >= ram_top.\n",				RELOC(prom_memory_limit));			RELOC(prom_memory_limit) = 0;		} else {			RELOC(ram_top) = RELOC(prom_memory_limit);			RELOC(rmo_top) = min(RELOC(rmo_top), RELOC(prom_memory_limit));		}	}	/*	 * Setup our top alloc point, that is top of RMO or top of	 * segment 0 when running non-LPAR.	 * Some RS64 machines have buggy firmware where claims up at	 * 1GB fail.  Cap at 768MB as a workaround.	 * Since 768MB is plenty of room, and we need to cap to something	 * reasonable on 32-bit, cap at 768MB on all machines.	 */	if (!RELOC(rmo_top))		RELOC(rmo_top) = RELOC(ram_top);	RELOC(rmo_top) = min(0x30000000ul, RELOC(rmo_top));	RELOC(alloc_top) = RELOC(rmo_top);	prom_printf("memory layout at init:\n");	prom_printf("  memory_limit : %x (16 MB aligned)\n", RELOC(prom_memory_limit));	prom_printf("  alloc_bottom : %x\n", RELOC(alloc_bottom));	prom_printf("  alloc_top    : %x\n", RELOC(alloc_top));	prom_printf("  alloc_top_hi : %x\n", RELOC(alloc_top_high));	prom_printf("  rmo_top      : %x\n", RELOC(rmo_top));	prom_printf("  ram_top      : %x\n", RELOC(ram_top));}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/c49888203d7a316cb947bb8a1cf2ae191f28bcd3/prom_init.c/buggy/arch/powerpc/kernel/prom_init.c