Skip to content

Commit

Permalink
feature enhancement parameter passing
Browse files Browse the repository at this point in the history
changes to enable parameter passing via qemu commandline see volumit/tricore_gcc940_linux_bins#10 (comment)
  • Loading branch information
volumit committed Jun 28, 2022
1 parent c6c7b2c commit 577b2fb
Show file tree
Hide file tree
Showing 5 changed files with 270 additions and 84 deletions.
61 changes: 60 additions & 1 deletion hw/tricore/tricore_testboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "qemu/units.h"
#include "qapi/error.h"
#include "cpu.h"
#include "disas/disas.h"
#include "net/net.h"
#include "hw/boards.h"
#include "hw/loader.h"
Expand All @@ -33,6 +34,63 @@

/* Board init. */

/*
static int symfind(const void *s0, const void *s1)
{
target_ulong addr = *(target_ulong *)s0;
struct elf_sym *sym = (struct elf_sym *)s1;
int result = 0;
if (addr < sym->st_value) {
result = -1;
} else if (addr >= sym->st_value + sym->st_size) {
result = 1;
}
return result;
}
*/
//static int addrfind(const void *s0, const void *s1)
//{
// const char *symname = (const char *)s0;
// struct elf_sym *sym = (struct elf_sym *)s1;
// int result = 1;
// if (strcmp(s->disas_strtab + sym->st_name,symname)==0) result=0;
// return result;
//}

static uint32_t lookup_addrxx(const char *symbol)
{

struct syminfo *s;
/* binary search */
int i;
for (s = syminfos; s; s = s->next)
{
struct elf32_sym *syms = s->disas_symtab.elf32;
for (i=0; i<s->disas_num_syms; i+=1)
{
if (strcmp(s->disas_strtab + syms[i].st_name,symbol)==0) return syms[i].st_value;
}
}
return 0;
}

//const char *lookup_symbol(target_ulong orig_addr)
//{
// const char *symbol = "";
// struct syminfo *s;
//
// for (s = syminfos; s; s = s->next) {
// symbol = s->lookup_symbol(s, orig_addr);
// if (symbol[0] != '\0') {
// break;
// }
// }
//
// return symbol;
//}



static struct tricore_boot_info tricoretb_binfo;

static void tricore_load_kernel(CPUTriCoreState *env)
Expand All @@ -50,7 +108,8 @@ static void tricore_load_kernel(CPUTriCoreState *env)
exit(1);
}
env->PC = entry;

env->main_addr_entry=lookup_addrxx("main");
env->kernel_filename=tricoretb_binfo.kernel_filename;
}

static void tricore_testboard_init(MachineState *machine, int board_id)
Expand Down
3 changes: 2 additions & 1 deletion semihosting/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ void semihosting_arg_fallback(const char *file, const char *cmd)
char *cmd_token;

/* argv[0] */
add_semihosting_arg(&semihosting, "arg", file, NULL);
// removed it, arg_fallback and standard is behaving different in terms of file name for first arg
// add_semihosting_arg(&semihosting, "arg", file, NULL);

/* split -append and initialize argv[1..n] */
cmd_token = strtok(g_strdup(cmd), " ");
Expand Down
4 changes: 4 additions & 0 deletions target/tricore/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ struct CPUTriCoreState {
const tricore_def_t *cpu_model;
void *irq[8];
struct QEMUTimer *timer; /* Internal timer */
uint32_t main_addr_entry;
uint32_t main_addr_next;
uint32_t main_sp_correction;
const char *kernel_filename;
};

/**
Expand Down
Loading

0 comments on commit 577b2fb

Please sign in to comment.