From: Alan Cox Date: Fri, 16 Jan 2015 13:36:58 +0000 (+0000) Subject: syscall_exec: handle R2L and L2R stacking compilers X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=54068d4c384f699fbadaffaa60256684046b792d;p=FUZIX.git syscall_exec: handle R2L and L2R stacking compilers --- diff --git a/Kernel/platform-tgl6502/config.h b/Kernel/platform-tgl6502/config.h index cabfc8c3..bac8e9d7 100644 --- a/Kernel/platform-tgl6502/config.h +++ b/Kernel/platform-tgl6502/config.h @@ -12,6 +12,8 @@ #undef CONFIG_SINGLETASK #define CONFIG_BANKS 2 +#define CONFIG_CALL_R2L /* Runtime stacks arguments backwards */ + /* For now used BANK_FIXED as we don't yet have sane swap with 16K maps */ #define CONFIG_BANK_FIXED #define MAX_MAPS 2 diff --git a/Kernel/syscall_exec.c b/Kernel/syscall_exec.c index d0b5f59d..79683866 100644 --- a/Kernel/syscall_exec.c +++ b/Kernel/syscall_exec.c @@ -54,7 +54,6 @@ int16_t _execve(void) { staticfast inoptr ino, emu_ino; staticfast unsigned char *buf; - staticfast blkno_t blk; char **nargv; /* In user space */ char **nenvp; /* In user space */ staticfast struct s_argblk *abuf, *ebuf; @@ -256,8 +255,13 @@ int16_t _execve(void) brelse(ebuf); // Shove argc and the address of argv just below envp +#ifdef CONFIG_CALL_R2L /* Arguments are stacked the 'wrong' way around */ uputw((uint16_t) nargv, nenvp - 1); uputw((uint16_t) argc, nenvp - 2); +#else + uputw((uint16_t) nargv, nenvp - 1); + uputw((uint16_t) argc, nenvp - 2); +#endif // Set stack pointer for the program udata.u_isp = nenvp - 2;