mirror of
https://github.com/drasko/codezero.git
synced 2026-01-12 02:43:15 +01:00
Fixed a fault with posix tasks not getting their LMA correctly
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
# -*- mode: python; coding: utf-8; -*-
|
||||
import os, sys, shelve, shutil, re
|
||||
from projpaths import *
|
||||
from lib import *
|
||||
|
||||
class Container:
|
||||
def __init__(self, id):
|
||||
@@ -152,17 +153,19 @@ class configuration:
|
||||
# Make sure elements in order for indexed accessing
|
||||
self.containers.sort(self.compare_containers)
|
||||
|
||||
def container_print(self, c):
|
||||
print '\nContainer %d' % c.id
|
||||
print 'Container type: %s' % c.type
|
||||
print 'Container Name: %s' % c.name
|
||||
print 'Container Pager lma: %s' % conv_hex(c.pager_lma)
|
||||
print 'Container Pager vma: %s' % conv_hex(c.pager_vma)
|
||||
print 'Container Pager size: %s' % conv_hex(c.pager_size)
|
||||
print 'Container Virtual regions: %s' % c.virt_regions
|
||||
print 'Container Physical regions: %s' % c.phys_regions
|
||||
|
||||
def containers_print(self, containers):
|
||||
for c in containers:
|
||||
print '\nContainer %d' % c.id
|
||||
print 'Container type: %s' % c.type
|
||||
print 'Container Name: %s' % c.name
|
||||
print 'Container Pager lma: %s' % hex(c.pager_lma)
|
||||
print 'Container Pager vma: %s' % hex(c.pager_vma)
|
||||
print 'Container Pager size: %s' % hex(c.pager_size)
|
||||
print 'Container Virtual regions: %s' % c.virt_regions
|
||||
print 'Container Physical regions: %s' % c.phys_regions
|
||||
self.container_print(self, c)
|
||||
|
||||
def config_print(self):
|
||||
print 'Configuration\n'
|
||||
|
||||
@@ -24,6 +24,7 @@ def generate_lma_lds(target, source, env):
|
||||
with open(source[0].path, 'r') as lds_in:
|
||||
with open(target[0].path, 'w+') as lds_out:
|
||||
linker_script = lds_in.read()
|
||||
assert container.pager_lma != 0
|
||||
lds_out.write(linker_script % conv_hex(container.pager_lma))
|
||||
|
||||
lma_lds = Command('include/linker.lds', 'include/linker.lds.in', generate_lma_lds)
|
||||
|
||||
@@ -48,8 +48,9 @@ env.Append(LINKFLAGS = ['-T' + lma_lds[0].path, '-u_start'])
|
||||
env.Append(CPPFLAGS = ' -D__USERSPACE__')
|
||||
objs = env.Object(src + test_exec_asm)
|
||||
test0 = env.Program('test0.elf', objs)
|
||||
|
||||
Depends(test0, objs)
|
||||
Depends(test0, lma_lds)
|
||||
Depends(lma_lds, previmage)
|
||||
env.Depends(test0, test_exec)
|
||||
|
||||
Return('test0')
|
||||
|
||||
@@ -350,6 +350,11 @@ elf_loadFile(void *elfFile, bool phys)
|
||||
//printf("Number of program headers: %d\n", num_pheaders);
|
||||
//printf("Program header offset of first header from file beginning: 0x%p\n",pheader_offset);
|
||||
|
||||
/*
|
||||
* FIXME:
|
||||
* This should have a linked list of mapped ranges so that it can check
|
||||
* at run-time whether any images are overlapping in their LMA and refuse to load.
|
||||
*/
|
||||
for(i=0; i < num_pheaders; i++) {
|
||||
/* Load that section */
|
||||
uint64_t dest, src;
|
||||
@@ -357,11 +362,11 @@ elf_loadFile(void *elfFile, bool phys)
|
||||
size_t len;
|
||||
if (phys) {
|
||||
dest = elf_getProgramHeaderPaddr(elfFile, i);
|
||||
// printf("Elf file pheader physical: %p\n", dest);
|
||||
// printf("Elf file pheader virtual: %p\n",
|
||||
// elf_getProgramHeaderVaddr(elfFile,i));
|
||||
// printf("Elf file pheader physical: 0x%x\n", (unsigned int)dest);
|
||||
// printf("Elf file pheader virtual: 0x%x\n",
|
||||
// (unsigned int)elf_getProgramHeaderVaddr(elfFile,i));
|
||||
} else {
|
||||
// printf("Elf file pheader virtual: %p\n", dest);
|
||||
// printf("Elf file pheader virtual: 0x%x\n", (unsigned int)dest);
|
||||
dest = elf_getProgramHeaderVaddr(elfFile, i);
|
||||
}
|
||||
len = elf_getProgramHeaderFileSize(elfFile, i);
|
||||
@@ -370,14 +375,19 @@ elf_loadFile(void *elfFile, bool phys)
|
||||
// printf("Elf program header offset: %p\n", src);
|
||||
pheader_type = elf_getProgramHeaderType(elfFile, i);
|
||||
// printf("Elf program header type: %p\n", pheader_type);
|
||||
// printf("Copying from %x to %x of size: %p\n", (unsigned int)src, (unsigned int)dest, len);
|
||||
|
||||
/* Enable this one
|
||||
printf("Copying to range from 0x%x to 0x%x of size: 0x%x\n", (unsigned int)dest, (unsigned int)dest + (unsigned int)len, (unsigned int)len);
|
||||
*/
|
||||
memcpy((void*) (uintptr_t) dest, (void*) (uintptr_t) src, len);
|
||||
dest += len;
|
||||
clrsize = elf_getProgramHeaderMemorySize(elfFile, i) - len;
|
||||
// printf("Clearing memory... starting from %x, size: %x\n", (unsigned int)dest, clrsize);
|
||||
// printf("Clearing memory... starting from %x, size: %x\n", (unsigned int)dest, (unsigned int)clrsize);
|
||||
memset((void*) (uintptr_t) dest, 0, clrsize);
|
||||
// printf("Memory cleared.\n");
|
||||
// printf("Memory cleared.\n");
|
||||
}
|
||||
// And this one
|
||||
// printf("\n");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -121,9 +121,9 @@ int main(void)
|
||||
printf("elf-loader:\tkernel entry point is %lx\n", *kernel_entry);
|
||||
arch_start_kernel(kernel_entry);
|
||||
|
||||
printf("elf-loader:\tKernel start failed!\n");
|
||||
printf("elf-loader:\tKernel start failed! Looping endless.\n");
|
||||
while (1)
|
||||
printf("Endless loop.\n");
|
||||
;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -28,8 +28,9 @@ def next_available_lma(srcfile):
|
||||
p_align = x.p_align
|
||||
if paddr > paddr_max:
|
||||
paddr_max = paddr
|
||||
|
||||
paddr_aligned = paddr_max & ~(p_align.value - 1)
|
||||
#print "paddr_max %s " % hex(paddr_max)
|
||||
#print "paddr_aligned %s " % hex(paddr_aligned)
|
||||
if paddr_max & (p_align.value - 1):
|
||||
paddr_aligned += p_align.value
|
||||
return conv_hex(paddr_aligned)
|
||||
|
||||
Reference in New Issue
Block a user