[uClinux-dev] Re: init_mem_alloc and PAGE_OFFSET

Miles Bader miles at lsi.nec.co.jp
Tue Mar 11 20:48:18 EST 2003

"John Willlams" <jwilliams at itee.uq.edu.au> writes:
> I don't remember precisely (I'm @ home at the moment), but it's one of the
> early init_XX functions called in start_kernel() - init_mem perhaps, or
> something similar.  The code in question actually lives in
> /arch/microblaze/kernel, which I pilfered from Miles Bader's excellent v850
> code.

Actually if you're using something similar to my code, you'll note that
in `init_bootmem_alloc,' it will look for symbols called _kram_start
and _kram_end, and if found, reserve that memory.  Here's the relevant
bits chopped out of the v850 port:

   /* `kram' is only used if the kernel uses part of normal user RAM.  */
   extern char _kram_start __attribute__ ((__weak__));
   extern char _kram_end __attribute__ ((__weak__));
   static void __init
   init_bootmem_alloc (unsigned long ram_start, unsigned long ram_len)
           /* The part of the kernel that's in the same managed RAM space
              used for general allocation.  */
           unsigned long kram_start = (unsigned long)&_kram_start;
           unsigned long kram_end = (unsigned long)&_kram_end;
           if (kram_end > kram_start)
                   /* Reserve the RAM part of the kernel's address space, so it
                      doesn't get allocated.  */
                   reserve_bootmem (kram_start, kram_end - kram_start);

I always define _kram_start and _kram_end in the linker script. 

[init_bootmem_alloc also reserves some other areas such as the
interrupt vectors (if ram starts at 0), and the bootmem bitmap itself,
and if then if `mach_reserve_bootmem' is defined, calls that as well to
reserve platform-specific areas]

"I distrust a research person who is always obviously busy on a task."
   --Robert Frosch, VP, GM Research

More information about the uClinux-dev mailing list