summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2014-02-13 00:41:22 (GMT)
committerH. Peter Anvin <hpa@zytor.com>2014-02-13 00:41:22 (GMT)
commit0cbd73024ca60225fc293e82779479dddd24c3aa (patch)
treed39012beb37aa31fedecc46cc16a791ab6fb4c24
parentce3557225a4523c7081cadd22c5aee74e3836118 (diff)
downloadabc8000-0cbd73024ca60225fc293e82779479dddd24c3aa.zip
abc8000-0cbd73024ca60225fc293e82779479dddd24c3aa.tar.gz
abc8000-0cbd73024ca60225fc293e82779479dddd24c3aa.tar.bz2
abc8000-0cbd73024ca60225fc293e82779479dddd24c3aa.tar.xz
exec_file: use a normal function call
Launch the executed program using a normal function call. Throw in argc, argv, envp for good measure.
-rw-r--r--data/sysrom/exec.c18
-rw-r--r--data/sysrom/sysrom.h3
2 files changed, 9 insertions, 12 deletions
diff --git a/data/sysrom/exec.c b/data/sysrom/exec.c
index 5d6e9d8..aa25c1e 100644
--- a/data/sysrom/exec.c
+++ b/data/sysrom/exec.c
@@ -37,14 +37,15 @@ struct exec_header {
uint32_t nrelocs;
};
-int exec_file(const char *filename, void *addr)
+int exec_file(const char *filename, void *addr,
+ int argc, char **argv, char **envp)
{
FRESULT fr;
FIL file;
UINT bytesread;
struct exec_header hdr;
uint32_t nrel;
- register const char *start asm("a1");
+ int (*start)(int, char **, char **);
fr = f_open(&file, filename, FA_READ|FA_OPEN_EXISTING);
if (fr != FR_OK)
@@ -95,14 +96,9 @@ int exec_file(const char *filename, void *addr)
f_close(&file);
- start = (const char *)addr + hdr.entrypoint;
- asm volatile("jsr (%0)\n"
- : "+a" (start)
- :
- : "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
- "a0", "a2", "a3", "a4", "a5", "a6",
- "cc", "memory");
- return 0;
+ start = (int (*)(int, char **, char **))
+ ((const char *)addr + hdr.entrypoint);
+ return start(argc, argv, envp) & 0xff;
err:
f_close(&file);
@@ -124,6 +120,6 @@ void disk_boot(void)
f_mount(0, &sd_fs);
printf("Running boot file @ %p...\n", load_addr);
- if (exec_file(boot_filename, load_addr))
+ if (exec_file(boot_filename, load_addr, 0, NULL, NULL))
printf("Boot file execution failed!\n");
}
diff --git a/data/sysrom/sysrom.h b/data/sysrom/sysrom.h
index 7c44d66..c1ce3ce 100644
--- a/data/sysrom/sysrom.h
+++ b/data/sysrom/sysrom.h
@@ -23,7 +23,8 @@ void sdcard_timer_tick(void);
int sdcard_read_sectors(void *buf, uint32_t lba, int count);
int sdcard_write_sectors(const void *buf, uint32_t lba, int count);
-int exec_file(const char *filename, void *addr);
+int exec_file(const char *filename, void *addr,
+ int argc, char **argv, char **envp);
void disk_boot(void);
ssize_t syscon_write(int fd, const void *buf, size_t count);