Port-hpcmips archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

hpcboot -- loading kernels @ ELF physaddr vs. ELF vaddr?



Currently, hpcboot loads all ELF files @ the virtual address from the ELF
program headers... however, at least on ARM (and I believe on SH and MIPS
too) the kernel is actually loaded into physical memory.

Is there any reason not to load the kernels at the physaddr given in the
ELF header vs. the vaddr as we do now?  That way, we could load kernels
like the following and not have to redesign the VM layout when the HW
memory layout changes.

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x008000 0xc0200000 0xa0200000 0x1d3a94 0x1d3a94 R E 0x8000
  LOAD           0x1e0000 0xc03d8000 0xa03d8000 0x05f48 0x4d9c0 RW  0x8000

Patch below.

--rafal

Index: load_elf.cpp
===================================================================
RCS file: /cvsroot/src/sys/arch/hpc/stand/hpcboot/load_elf.cpp,v
retrieving revision 1.17
diff -u -p -r1.17 load_elf.cpp
--- load_elf.cpp        5 Mar 2006 04:04:13 -0000       1.17
+++ load_elf.cpp        10 Mar 2008 19:16:22 -0000
@@ -166,9 +166,9 @@ ElfLoader::load()
                if (ph->p_type == PT_LOAD) {
                        size_t filesz = ph->p_filesz;
                        size_t memsz = ph->p_memsz;
-                       kv = ph->p_vaddr;
+                       kv = ph->p_paddr;
                        off_t fileofs = ph->p_offset;
-                       DPRINTF((TEXT("seg[%d] vaddr 0x%08x file size 0x%x mem s
ize 0x%x\n"),
+                       DPRINTF((TEXT("seg[%d] paddr 0x%08x file size 0x%x mem s
ize 0x%x\n"),
                            i, kv, filesz, memsz));
                        _load_segment(kv, memsz, fileofs, filesz);
                        kv += ROUND4(memsz);

-- 
  Time is an illusion; lunchtime, doubly so.     |/\/\|           Rafal Boni
                   -- Ford Prefect               |\/\/|      
rafal%pobox.com@localhost


Home | Main Index | Thread Index | Old Index