extern void *memset(void *, int, size_t);
extern size_t strlen(const char *);
+#define EMAGIC 0x4C /* Header of executable (JMP) */
+
#define staticfast static
/* FIXME: need to add 64bit helper/struct magic for this compiler */
extern irqflags_t di(void);
extern void irqrestore(irqflags_t f);
+#define EMAGIC 0x0E /* Header of executable (JMP) */
extern void *memcpy(void *, void *, size_t);
extern void *memset(void *, int, size_t);
extern irqflags_t di(void);
extern void irqrestore(irqflags_t f);
+/* Z80 binaries start with a JP */
+#define EMAGIC 0xc3 /* Header of executable */
+
/* compiler provides optimised versions of these: */
#if defined(__SDCC_z80) || defined(__SDCC_z180) || defined(__SDCC_r2k) || defined(__SDCC_r3ka)
#define memcpy(dst, src, n) __builtin_memcpy(dst, src, n)
#define NSIGS 32 /* Number of signals <= 32 */
#define ROOTINODE 1 /* Inode # of / for all mounted filesystems. */
-#define EMAGIC 0xc3 /* Header of executable */
#define CMAGIC 24721 /* Random number for cinode c_magic */
#define SMOUNTED 12742 /* Magic number to specify mounted filesystem */
/* Read in the first block of the new program */
buf = bread(ino->c_dev, bmap(ino, 0, 1), 0);
- /****************************************
- * Get magic number into var magic
- * C3 : executable file no C/D sep.
- * 00FF : " " with C/D sep. (not supported in FUZIX)
- * other : maybe shell script (nogood2)
- ****************************************/
+ /* Magic numbers
+ 0xC3 xx xx - Z80 with 0x100 entry
+ 0x4C xx xx - 6502
+ 0x0E xx xx - 6809
+
+ others TBD
+
+ FIXME: need to modify header design to include base addr page
+ */
if ((*buf & 0xff) != EMAGIC) {
udata.u_error = ENOEXEC;
goto nogood2;
}
/* Binary doesn't fit */
- if (top < ino->c_node.i_size + 1024) {
+ if (top - PROGBASE < ino->c_node.i_size + 1024) {
udata.u_error = ENOMEM;
goto nogood2;
}
goto nogood3; /* SN */
/* This must be the last test as it makes changes if it works */
- if (pagemap_realloc(top))
+ if (pagemap_realloc(top - PROGBASE))
goto nogood3;
/* From this point on we are commmited to the exec() completing */