#include <kdata.h>
#include <printf.h>
+/* FIXME: we need to put this back on boxes with a malloc but for now
+ lets keep it easy */
#define ARGBUF_SIZE 2048
struct binfmt_flat {
/* For now we load the binary in one block, including code/data/bss. We can
look at better formats, split binaries etc later maybe */
-static void relocate(struct binfmt_flat *bf, void *progbase, uint32_t size)
+static void relocate(struct binfmt_flat *bf, uint8_t *progbase, uint32_t size)
{
- uint32_t *rp = progbase + bf->reloc_start;
+ uint32_t *rp = (uint32_t *)(progbase + bf->reloc_start);
uint32_t n = bf->reloc_count;
while (n--) {
uint32_t v = *rp++;
struct s_argblk *abuf, *ebuf;
int argc;
uint32_t bin_size; /* Will need to be bigger on some cpus */
- void *progbase, *top;
+ uint8_t *progbase, *top;
uaddr_t go;
if (!(ino = n_open(name, NULLINOPTR)))
bin_size = binflat->bss_end + binflat->stack_size;
/* Gather the arguments, and put them in temporary buffers. */
- abuf = (struct s_argblk *) kmalloc(ARGBUF_SIZE);
- if (abuf == NULL) {
- udata.u_error = ENOMEM;
- goto nogood2;
- }
+ abuf = (struct s_argblk *) tmpbuf();
/* Put environment in another buffer. */
- ebuf = (struct s_argblk *) kmalloc(ARGBUF_SIZE);
- if (ebuf == NULL) {
- kfree(abuf);
- udata.u_error = ENOMEM;
- goto nogood2;
- }
+ ebuf = (struct s_argblk *) tmpbuf();
/* Read args and environment from process memory */
if (rargs(argv, abuf) || rargs(envp, ebuf))
uget((void *) ugetl(nargv, NULL), udata.u_name, 8);
memcpy(udata.u_ptab->p_name, udata.u_name, 8);
- kfree(abuf);
- kfree(ebuf);
+ brelse(abuf);
+ brelse(ebuf);
i_deref(ino);
/* Shove argc and the address of argv just below envp */
// tidy up in various failure modes:
nogood3:
- kfree(abuf);
- kfree(ebuf);
+ brelse(abuf);
+ brelse(ebuf);
nogood2:
brelse(buf);
nogood: