/* This function calls callback against all memory range of "System RAM" which are marked as IORESOURCE_MEM and IORESOUCE_BUSY. Now, this function is only for "System RAM".  */
int walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, void *arg, int(*func)(unsigned long, unsigned long, void *))
/* This function calls callback against all memory range of "System RAM" which are marked as IORESOURCE_MEM and IORESOUCE_BUSY. Now, this function is only for "System RAM".  */
int walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, void *arg, int(*func)(unsigned long, unsigned long, void *))
{
	struct resource res;
	unsigned long pfn, len;
	u64 orig_end;
	int ret = -1;
	res.start = (u64) start_pfn << PAGE_SHIFT;
	res.end = ((u64)(start_pfn + nr_pages) << PAGE_SHIFT) - 1;
	res.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
	orig_end = res.end;
	while ((res.start < res.end) &&
		(find_next_system_ram(&res, "System RAM") >= 0)) {
		pfn = (unsigned long)(res.start >> PAGE_SHIFT);
		len = (unsigned long)((res.end + 1 - res.start) >> PAGE_SHIFT);
		ret = (*func)(pfn, len, arg);
		if (ret)
			break;
		res.start = res.end + 1;
		res.end = orig_end;
	}
	return ret;
}