From ee44a2007a828302e81b88a0d42ef8af617c32e4 Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Wed, 16 Sep 2009 16:24:56 +0300 Subject: [PATCH] Containers packed in single .elf file --- SConstruct.loader | 3 +-- loader/linker.lds | 24 +++++++++--------------- loader/main.c | 26 +++++++++++++++++--------- loader/pre-build.py | 35 ----------------------------------- 4 files changed, 27 insertions(+), 61 deletions(-) delete mode 100755 loader/pre-build.py diff --git a/SConstruct.loader b/SConstruct.loader index c762500..854b0fd 100644 --- a/SConstruct.loader +++ b/SConstruct.loader @@ -19,12 +19,11 @@ LIBC_PATH = 'loader/libs/c' LIBC_LIBPATH = LIBC_PATH LIBC_INCPATH = ['#' + join(LIBC_PATH, 'include'), \ '#' + join(LIBC_PATH, 'include/arch/' + arch)] -LIBC_CRT_PATH = '#' + join(LIBC_PATH, "crt/sys-baremetal/arch-" + arch + "/crt0.o") + LIBELF_PATH = 'loader/libs/elf' LIBELF_LIBPATH = LIBELF_PATH LIBELF_INCPATH = '#' + join(LIBELF_PATH, 'include') - env = Environment(CC = 'arm-none-eabi-gcc', # We don't use -nostdinc because sometimes we need standard headers, # such as stdarg.h e.g. for variable args, as in printk(). diff --git a/loader/linker.lds b/loader/linker.lds index c2b8a15..e0d07b9 100644 --- a/loader/linker.lds +++ b/loader/linker.lds @@ -1,7 +1,7 @@ /* - * Simple linker script for userspace or svc tasks. + * Linker script that packs all containers in loader image. * - * Copyright (C) 2007 Bahadir Balban + * Copyright (C) 2007-2009 B Labs Ltd. */ ENTRY(_start) @@ -13,23 +13,17 @@ SECTIONS .rodata1 : { *(.rodata1) } .data : { + *(.data) _start_kernel = .; *(.kernel) _end_kernel = .; - _start_bootdesc = .; - *(.bootdesc) - _end_bootdesc = .; - _start_mm0 = .; - *(.mm0) - _end_mm0 = .; - _start_fs0 = .; - *(.fs0) - _end_fs0 = .; - _start_test0 = .; - *(.test0) - _end_test0 = .; - *(.data) } + _start_containers = .; + + .cont.0 : { *(.cont.0) } + .cont.1 : { *(.cont.1) } + + _end_containers = .; .got : { *(.got) *(.got.plt) } .bss : { *(.bss) } } diff --git a/loader/main.c b/loader/main.c index 0282ebd..25255de 100644 --- a/loader/main.c +++ b/loader/main.c @@ -1,29 +1,37 @@ - #include #include #include #include "arch.h" -/* These symbols are defined by the linker scripts. */ +/* These symbols are defined by the linker script. */ extern char _start_kernel[]; extern char _end_kernel[]; -extern char _start_containers[]; -extern char _end_containers[]; /* This is a kernel symbol exported to loader's linker script from kernel build */ extern char bkpt_phys_to_virt[]; -int -main(void) +void load_container_images(unsigned long start, unsigned long end) { - void *kernel_entry = NULL; + struct elf_image *elf_img = (struct elf_image *)start; + int nsect_headers; + + // Find all section headers + +} + +int main(void) +{ + void *kernel_entry = 0; arch_init(); - printf("elf-loader:\tStarted\n"); + printf("ELF Loader: Started.\n"); printf("Loading the kernel...\n"); -// load_image(&kernel_entry, _start_kernel, _end_kernel); + load_elf_image(&kernel_entry, _start_kernel, _end_kernel); + + printf("Loading containers...\n"); + load_container_images(_start_containers, _end_containers) printf("elf-loader:\tkernel entry point is %p\n", kernel_entry); // arch_start_kernel(kernel_entry); diff --git a/loader/pre-build.py b/loader/pre-build.py deleted file mode 100755 index 27b167a..0000000 --- a/loader/pre-build.py +++ /dev/null @@ -1,35 +0,0 @@ -# -*- mode: python; coding: utf-8; -*- -# -# Codezero -- a microkernel for embedded systems. -# -# Copyright © 2009 B Labs Ltd - -import os, sys, shelve - -# Convert address from python literal to numeric value -def address_remove_literal(address): - value = hex(int(address, 16) - 0xf0000000) - if value[-1] in ['l', 'L']: - value = value[:-1] - return value - -ksym_header = \ -''' -/* - * %s autogenerated from %s. - * - * This file is included by the loader sources so that any - * kernel symbol address can be known in advance and stopped - * at by debuggers before virtual memory is enabled. - */ -''' - -symbol_section = \ -''' -.section .text -.align 4 -.global %s -.type %s, function -.equ %s, %s -''' -