Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2961 → Rev 2962

/branches/dynload/uspace/app/iloader/main.c
41,61 → 41,8
#include <as.h>
 
#include "elf.h"
#include "pcb.h"
#include "elf_load.h"
 
unsigned int elf_load(int fd, elf_header_t *header);
 
typedef void (*entry_point_t)(void);
 
static int elf_load_file(char *file_name, elf_header_t *header)
{
int fd;
int rc;
 
printf("open and read '%s'...\n", file_name);
 
fd = open(file_name, 0);
if (fd < 0) {
printf("failed opening file\n");
return -1;
}
 
rc = elf_load(fd, header);
printf("elf_load() -> %d\n", rc);
 
close(fd);
 
return rc;
}
 
static void elf_run(elf_header_t *header)
{
entry_point_t entry_point;
 
entry_point = (entry_point_t)header->e_entry;
(*entry_point)();
 
/* not reached */
}
 
static int elf_create_pcb(elf_header_t *header)
{
pcb_t *pcb;
void *a;
 
pcb = (pcb_t *)PCB_ADDRESS;
 
a = as_area_create(pcb, sizeof(pcb_t), AS_AREA_READ | AS_AREA_WRITE);
if (a == (void *)(-1)) {
printf("elf_create_pcb: memory mapping failed\n");
return EE_MEMORY;
}
 
pcb->entry = (entry_point_t)header->e_entry;
 
return 0;
}
 
int main(int argc, char *argv[])
{
elf_header_t prog_header;