Changeset de6b301 in mainline for generic/src/main/kinit.c


Ignore:
Timestamp:
2006-03-12T18:27:33Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f972b89
Parents:
a82500ce
Message:

Basic support for loading ELF object files.
ia64, amd64, ia32 working.
mips32 requires some attention.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • generic/src/main/kinit.c

    ra82500ce rde6b301  
    4747#include <interrupt.h>
    4848#include <console/kconsole.h>
     49#include <elf.h>
    4950
    5051#ifdef CONFIG_SMP
     
    7273        as_t *as;
    7374        as_area_t *a;
    74         __address frame;
    75         count_t frames;
    76         int i;
     75        int rc;
    7776        task_t *u;
    7877
     
    151150                if (!as)
    152151                        panic("as_create\n");
    153                 u = task_create(as);
    154                 if (!u)
    155                         panic("task_create\n");
    156                 t = thread_create(uinit, NULL, u, THREAD_USER_STACK);
    157                 if (!t)
    158                         panic("thread_create\n");
     152
     153                rc = elf_load((elf_header_t *) config.init_addr, as);
     154                if (rc != EE_OK) {
     155                        printf("elf_load failed: %s\n", elf_error(rc));
     156                } else {
     157                        u = task_create(as);
     158                        if (!u)
     159                                panic("task_create\n");
     160                        t = thread_create(uinit, (void *)((elf_header_t *) config.init_addr)->e_entry, u, THREAD_USER_STACK);
     161                        if (!t)
     162                                panic("thread_create\n");
    159163               
    160                 /*
    161                  * Create the text as_area and initialize its mapping.
    162                  */
    163                
    164                 frame = config.init_addr;
    165                 if (IS_KA(frame))
    166                         frame = KA2PA(frame);
     164                        /*
     165                         * Create the data as_area.
     166                         */
     167                        a = as_area_create(as, AS_AREA_STACK, 1, USTACK_ADDRESS);
     168                        if (!a)
     169                                panic("as_area_create: stack\n");
    167170
    168                 frames = SIZE2FRAMES(config.init_size);
    169                
    170                 a = as_area_create(as, AS_AREA_TEXT, frames, UTEXT_ADDRESS);
    171                 if (!a)
    172                         panic("as_area_create: text\n");
    173 
    174                 for (i = 0; i < frames; i++)
    175                         as_set_mapping(as, UTEXT_ADDRESS + i * PAGE_SIZE, frame + i * FRAME_SIZE);
    176 
    177                 /*
    178                  * Create the data as_area.
    179                  */
    180                 a = as_area_create(as, AS_AREA_STACK, 1, USTACK_ADDRESS);
    181                 if (!a)
    182                         panic("as_area_create: stack\n");
    183 
    184                 thread_ready(t);
     171                        thread_ready(t);
     172                }
    185173        }
    186174
Note: See TracChangeset for help on using the changeset viewer.