kernel/elf.c
void load_bincode_from_host_elf(struct process *p) {
  arg_buf arg_bug_msg;

  // retrieve command line arguements
  size_t argc = parse_args(&arg_bug_msg);
  if (!argc) panic("You need to specify the application program!\n");

  sprint("Application: %s\n", arg_bug_msg.argv[0]);

  //elf loading
  elf_ctx elfloader;
  elf_info info;

  info.f = spike_file_open(arg_bug_msg.argv[0], O_RDONLY, 0);
  info.p = p;
  if (IS_ERR_VALUE(info.f)) panic("Fail on openning the input application program.\n");

  // init elfloader
  if (elf_init(&elfloader, &info) != EL_OK)
    panic("fail to init elfloader.\n");

  // load elf
  if (elf_load(&elfloader) != EL_OK) panic("Fail on loading elf.\n");

  // entry (virtual) address
  p->trapframe->epc = elfloader.ehdr.entry;

  // close host file
  spike_file_close( info.f );

  sprint("Application program entry point (virtual address): 0x%lx\n", p->trapframe->epc);
}
//
// load the elf of user application, by using the spike file interface.
//
load the elf of user application, by using the spike file interface.
load the elf of user application by using the spike file interface .
void load_bincode_from_host_elf(struct process *p) {
  arg_buf arg_bug_msg;
  size_t argc = parse_args(&arg_bug_msg);
  if (!argc) panic("You need to specify the application program!\n");
  sprint("Application: %s\n", arg_bug_msg.argv[0]);
  elf_ctx elfloader;
  elf_info info;
  info.f = spike_file_open(arg_bug_msg.argv[0], O_RDONLY, 0);
  info.p = p;
  if (IS_ERR_VALUE(info.f)) panic("Fail on openning the input application program.\n");
  if (elf_init(&elfloader, &info) != EL_OK)
    panic("fail to init elfloader.\n");
  if (elf_load(&elfloader) != EL_OK) panic("Fail on loading elf.\n");
  p->trapframe->epc = elfloader.ehdr.entry;
  spike_file_close( info.f );
  sprint("Application program entry point (virtual address): 0x%lx\n", p->trapframe->epc);
}
void load_bincode_from_host_elf ( struct process * p ) { arg_buf arg_bug_msg ; size_t argc = parse_args ( & arg_bug_msg ) ; if ( ! argc ) panic ( " \n " ) ; sprint ( " \n " , arg_bug_msg . argv [ 0 ] ) ; elf_ctx elfloader ; elf_info info ; info . f = spike_file_open ( arg_bug_msg . argv [ 0 ] , O_RDONLY , 0 ) ; info . p = p ; if ( IS_ERR_VALUE ( info . f ) ) panic ( " \n " ) ; if ( elf_init ( & elfloader , & info ) != EL_OK ) panic ( " \n " ) ; if ( elf_load ( & elfloader ) != EL_OK ) panic ( " \n " ) ; p -> trapframe -> epc = elfloader . ehdr . entry ; spike_file_close ( info . f ) ; sprint ( " \n " , p -> trapframe -> epc ) ; }
load the elf of user application, by using the spike file interface.
load the elf of user application by using the spike file interface .
// retrieve command line arguements //elf loading // init elfloader // load elf // entry (virtual) address // close host file