+++ /dev/null
-
-typedef struct Exec
-{
- long magic; /* magic number */
- long text; /* size of text segment */
- long data; /* size of initialized data */
- long bss; /* size of uninitialized data */
- long syms; /* size of symbol table */
- long entry; /* entry point */
- long spsz; /* size of pc/sp offset table */
- long pcsz; /* size of pc/line number table */
-} Exec;
-
-#define _MAGIC(b) ((((4*b)+0)*b)+7)
-#define A_MAGIC _MAGIC(8) /* 68020 */
-#define I_MAGIC _MAGIC(11) /* intel 386 */
-#define J_MAGIC _MAGIC(12) /* intel 960 (retired) */
-#define K_MAGIC _MAGIC(13) /* sparc */
-#define V_MAGIC _MAGIC(16) /* mips 3000 BE */
-#define X_MAGIC _MAGIC(17) /* att dsp 3210 (retired) */
-#define M_MAGIC _MAGIC(18) /* mips 4000 BE */
-#define D_MAGIC _MAGIC(19) /* amd 29000 (retired) */
-#define E_MAGIC _MAGIC(20) /* arm */
-#define Q_MAGIC _MAGIC(21) /* powerpc */
-#define N_MAGIC _MAGIC(22) /* mips 4000 LE */
-#define L_MAGIC _MAGIC(23) /* dec alpha */
-#define P_MAGIC _MAGIC(24) /* mips 3000 LE */
-#define U_MAGIC _MAGIC(25) /* sparc64 */
-#define S_MAGIC _MAGIC(26) /* amd64 */
-
#include <xenctrl.h>
#include "xc_elf.h"
-#include "xc_aout9.h"
#include <stdlib.h>
#include <unistd.h>
#include <inttypes.h>
#define round_pgup(_p) (((_p)+(PAGE_SIZE-1))&PAGE_MASK)
#define round_pgdown(_p) ((_p)&PAGE_MASK)
-#ifdef __ia64__
-#define probe_aout9(image,image_size,load_funcs) 1
-#endif
-
struct initrd_info {
enum { INITRD_none, INITRD_file, INITRD_mem } type;
unsigned long len;
struct load_funcs *load_funcs)
{
if ( probe_elf(image, image_size, load_funcs) &&
- probe_bin(image, image_size, load_funcs) &&
- probe_aout9(image, image_size, load_funcs) )
+ probe_bin(image, image_size, load_funcs) )
{
ERROR( "Unrecognized image format" );
return -EINVAL;
+++ /dev/null
-
-#include "xg_private.h"
-#include "xc_aout9.h"
-
-#if defined(__i386__)
- #define A9_MAGIC I_MAGIC
-#elif defined(__x86_64__)
- #define A9_MAGIC S_MAGIC
-#elif defined(__ia64__)
- #define A9_MAGIC 0
-#else
-#error "Unsupported architecture"
-#endif
-
-#define round_pgup(_p) (((_p)+(PAGE_SIZE-1))&PAGE_MASK)
-#define KZERO 0x80000000
-#define KOFFSET(_p) ((_p)&~KZERO)
-
-static int parseaout9image(const char *, unsigned long, struct domain_setup_info *);
-static int loadaout9image(const char *, unsigned long, int, uint32_t, xen_pfn_t *, struct domain_setup_info *);
-static void copyout(int, uint32_t, unsigned long *, unsigned long, const char *, int);
-struct Exec *get_header(const char *, unsigned long, struct Exec *);
-
-
-int
-probe_aout9(
- const char *image,
- unsigned long image_size,
- struct load_funcs *load_funcs)
-{
- struct Exec ehdr;
-
- if (!get_header(image, image_size, &ehdr)) {
- ERROR("Kernel image does not have a a.out9 header.");
- return -EINVAL;
- }
-
- load_funcs->parseimage = parseaout9image;
- load_funcs->loadimage = loadaout9image;
- return 0;
-}
-
-static int
-parseaout9image(
- const char *image,
- unsigned long image_size,
- struct domain_setup_info *dsi)
-{
- struct Exec ehdr;
- unsigned long start, dstart, end;
-
- if (!get_header(image, image_size, &ehdr)) {
- ERROR("Kernel image does not have a a.out9 header.");
- return -EINVAL;
- }
-
- if (sizeof ehdr + ehdr.text + ehdr.data > image_size) {
- ERROR("a.out program extends past end of image.");
- return -EINVAL;
- }
-
- start = ehdr.entry;
- dstart = round_pgup(start + ehdr.text);
- end = dstart + ehdr.data + ehdr.bss;
-
- dsi->v_start = KZERO;
- dsi->v_kernstart = start;
- dsi->v_kernend = end;
- dsi->v_kernentry = ehdr.entry;
- dsi->v_end = end;
-
- /* XXX load symbols */
-
- return 0;
-}
-
-static int
-loadaout9image(
- const char *image,
- unsigned long image_size,
- int xch, uint32_t dom,
- xen_pfn_t *parray,
- struct domain_setup_info *dsi)
-{
- struct Exec ehdr;
- unsigned long start, dstart;
-
- if (!get_header(image, image_size, &ehdr)) {
- ERROR("Kernel image does not have a a.out9 header.");
- return -EINVAL;
- }
-
- start = ehdr.entry;
- dstart = round_pgup(start + ehdr.text);
- copyout(xch, dom, parray, start, image + sizeof ehdr, ehdr.text);
- copyout(xch, dom, parray, dstart,
- image + sizeof ehdr + ehdr.text, ehdr.data);
-
- /* XXX load symbols */
-
- return 0;
-}
-
-/*
- * copyout data to the domain given an offset to the start
- * of its memory region described by parray.
- */
-static void
-copyout(
- int xch, uint32_t dom,
- unsigned long *parray,
- unsigned long addr,
- const char *buf,
- int sz)
-{
- unsigned long pgoff, chunksz, off;
- void *pg;
-
- off = KOFFSET(addr);
- while (sz > 0) {
- pgoff = off & (PAGE_SIZE-1);
- chunksz = sz;
- if(chunksz > PAGE_SIZE - pgoff)
- chunksz = PAGE_SIZE - pgoff;
-
- pg = xc_map_foreign_range(xch, dom, PAGE_SIZE, PROT_WRITE,
- parray[off>>PAGE_SHIFT]);
- memcpy(pg + pgoff, buf, chunksz);
- munmap(pg, PAGE_SIZE);
-
- off += chunksz;
- buf += chunksz;
- sz -= chunksz;
- }
-}
-
-#define swap16(_v) ((((uint16_t)(_v)>>8)&0xff)|(((uint16_t)(_v)&0xff)<<8))
-#define swap32(_v) (((uint32_t)swap16((uint16_t)(_v))<<16)|(uint32_t)swap16((uint32_t)((_v)>>16)))
-
-/*
- * Decode the header from the start of image and return it.
- */
-struct Exec *
-get_header(
- const char *image,
- unsigned long image_size,
- struct Exec *ehdr)
-{
- uint32_t *v, x;
- int i;
-
- if (A9_MAGIC == 0)
- return 0;
-
- if (image_size < sizeof ehdr)
- return 0;
-
- /* ... all big endian words */
- v = (uint32_t *)ehdr;
- for (i = 0; i < sizeof(*ehdr); i += 4) {
- x = *(uint32_t *)&image[i];
- v[i/4] = swap32(x);
- }
-
- if(ehdr->magic != A9_MAGIC)
- return 0;
- return ehdr;
-}
-
-/*
- * Local variables:
- * mode: C
- * c-set-style: "BSD"
- * c-basic-offset: 4
- * tab-width: 4
- * indent-tabs-mode: nil
- * End:
- */