[PATCH] init_bootmem with physical memory start address

NIIBE Yutaka (gniibe@chroot.org)
Fri, 26 Nov 1999 11:07:52 +0900


Hello Ingo,

Around Nov. 5th, we discussed about the bootmem, and I've sent a patch.
It seems that it didn't got your attention (I know that you've been
working hard, never mind :-), so here I send it you again.

In the patch, I added a argument for init_bootmem so that bootmem can work
with machine with physical memory offset.

It seems that ARM architecure hide the physical memory offset in
phys_to_virt and virt_to_phys macro (with MMU tricks). For SuperH
architecture, we can't use such MMU tricks since kernel space
are translated with no TLB lookup (just mask).

Could you please look it and comment?

--- linux-2.3.29/include/linux/bootmem.h Thu Nov 25 22:16:01 1999
+++ linux-sh/include/linux/bootmem.h Thu Nov 25 23:48:19 1999
@@ -12,7 +12,7 @@

extern unsigned long max_low_pfn;

-extern unsigned long __init init_bootmem (unsigned long addr, unsigned long memend);
+extern unsigned long __init init_bootmem (unsigned long addr, unsigned long memend, unsigned long mem_start);
extern void __init reserve_bootmem (unsigned long addr, unsigned long size);
extern void __init free_bootmem (unsigned long addr, unsigned long size);
extern void * __init __alloc_bootmem (unsigned long size, unsigned long align, unsigned long goal);
--- linux-2.3.29/mm/bootmem.c Thu Nov 25 22:16:06 1999
+++ linux-sh/mm/bootmem.c Thu Nov 25 22:23:36 1999
@@ -27,15 +27,18 @@
unsigned long max_low_pfn;

static void * bootmem_map = NULL;
+static unsigned long phys_mem_start;

/*
* Called once to set up the allocator itself.
*/
-unsigned long __init init_bootmem (unsigned long start, unsigned long pages)
+unsigned long __init init_bootmem (unsigned long start, unsigned long pages,
+ unsigned long memory_start)
{
unsigned long mapsize = (pages+7)/8;

- bootmem_map = phys_to_virt(start << PAGE_SHIFT);
+ phys_mem_start = memory_start;
+ bootmem_map = phys_to_virt((start << PAGE_SHIFT) + phys_mem_start);
max_low_pfn = pages;

/*
@@ -176,11 +179,11 @@
areasize = 0;
// last_pos unchanged
last_offset = offset+size;
- ret = phys_to_virt(last_pos*PAGE_SIZE + offset);
+ ret = phys_to_virt(last_pos*PAGE_SIZE + offset + phys_mem_start);
} else {
remaining_size = size - remaining_size;
areasize = (remaining_size+PAGE_SIZE-1)/PAGE_SIZE;
- ret = phys_to_virt(last_pos*PAGE_SIZE + offset);
+ ret = phys_to_virt(last_pos*PAGE_SIZE + offset + phys_mem_start);
last_pos = start+areasize-1;
last_offset = remaining_size;
}
@@ -188,7 +191,7 @@
} else {
last_pos = start + areasize - 1;
last_offset = size & ~PAGE_MASK;
- ret = phys_to_virt(start * PAGE_SIZE);
+ ret = phys_to_virt(start * PAGE_SIZE + phys_mem_start);
}
/*
* Reserve the area now:
@@ -214,7 +217,7 @@
count++;
ClearPageReserved(page);
set_page_count(page, 1);
- if (i >= (virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT))
+ if (i >= ((virt_to_phys((char *)MAX_DMA_ADDRESS) - phys_mem_start) >> PAGE_SHIFT))
clear_bit(PG_DMA, &page->flags);
__free_page(page);
}

-- 
Niibe Yutaka

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/