Exemple #1
0
static void seabios_setup_e820(void)
{
    struct seabios_info *info = (void *)BIOS_INFO_PHYSICAL_ADDRESS;
    struct e820entry *e820 = scratch_alloc(sizeof(struct e820entry)*16, 0);
    info->e820 = (uint32_t)e820;

    /* SeaBIOS reserves memory in e820 as necessary so no low reservation. */
    info->e820_nr = build_e820_table(e820, 0, 0x100000-sizeof(seabios));
    dump_e820_table(e820, info->e820_nr);
}
Exemple #2
0
static void seabios_setup_bios_info(void)
{
    struct seabios_info *info = (void *)BIOS_INFO_PHYSICAL_ADDRESS;

    memset(info, 0, sizeof(*info));

    memcpy(info->signature, "XenHVMSeaBIOS", sizeof(info->signature));
    info->length = sizeof(*info);

    info->tables = (uint32_t)scratch_alloc(MAX_TABLES*sizeof(uint32_t), 0);
}
Exemple #3
0
Fichier : gc.c Projet : CRogers/obc
/* page_setup -- make page table entries point to a given header */
static void page_setup(uchar *base, unsigned size, header *h) {
    uchar *p;

    ASSERT(size % GC_PAGESIZE == 0);

    for (p = base; p < base + size; p += GC_PAGESIZE) {
        /* Make sure lower index exists */
        if (page_table[top_part(p)] == empty_index)
            page_table[top_part(p)] =
                scratch_alloc(sizeof(page_index), FALSE);

        get_header(p) = h;
    }
}
Exemple #4
0
/* read_string -- input a null-terminated string, allocate space dynamically */
static char *read_string() {
     int n = 0;
     int c;
     char *p;
     char buf[256];
     
     do {
	  c = bingetc();
	  if (c == EOF) panic("*unexpected EOF");
	  buf[n++] = c;
     } while (c != '\0');

     p = (char *) scratch_alloc(n, TRUE);
     strcpy(p, buf);
     return p;
}
Exemple #5
0
Fichier : gc.c Projet : CRogers/obc
/* alloc_header -- create a block header */
static header *alloc_header(void) {
    header *h;

    if (hdr_free == NULL)
        h = scratch_alloc(sizeof(header), FALSE);
    else {
        h = hdr_free;
        hdr_free = h->h_next;
    }

    h->h_memory = NULL;
    h->h_size = 0;
    h->h_objsize = 0;
    h->h_epoch = 0;
    h->h_next = h->h_prev = NULL;
    return h;
}
Exemple #6
0
static void seabios_acpi_build_tables(void)
{
    uint32_t rsdp = (uint32_t)scratch_alloc(sizeof(struct acpi_20_rsdp), 0);
    struct acpi_config config = {
        .dsdt_anycpu = dsdt_anycpu_qemu_xen,
        .dsdt_anycpu_len = dsdt_anycpu_qemu_xen_len,
        .dsdt_15cpu = NULL,
        .dsdt_15cpu_len = 0,
    };

    acpi_build_tables(&config, rsdp);
    add_table(rsdp);
}

static void seabios_create_mp_tables(void)
{
    add_table(create_mp_tables(NULL));
}
Exemple #7
0
/*
 * The structure of these tables is described in
 * http://www.microsoft.com/taiwan/whdc/archive/pciirq.mspx
 */
unsigned long create_pir_tables(void)
{
    int length = sizeof(struct pir_table)
        + sizeof(struct pir_slot) * NR_PIR_SLOTS;
    struct pir_table *pir = scratch_alloc(length, 0);
    int i, checksum;

    memset(pir, 0, length);

    memcpy(pir->signature, "$PIR", 4);
    pir->version = 0x0100;
    pir->length = length;

    pir->router_bus = 0;
    pir->router_devfn = PCI_ISA_DEVFN;
    pir->router_vid = 0x8086;
    pir->router_did = 0x122e;

    pir->pci_irqs = 0x0000;

    for ( i = 0 ; i < NR_PIR_SLOTS; i++ )
    {
        struct pir_slot *slot = &pir->slots[i];
        slot->slot = i;
        slot->bus = 0;
        slot->dev = i<<3;
        slot->link_a = 0x60 + (i+1)%4;
        slot->bitmap_a = PCI_ISA_IRQ_MASK;
        slot->link_b = 0x60 + (i+2)%4;
        slot->bitmap_b = PCI_ISA_IRQ_MASK;
        slot->link_c = 0x60 + (i+3)%4;
        slot->bitmap_c = PCI_ISA_IRQ_MASK;
        slot->link_d = 0x60 + (i+4)%4;
        slot->bitmap_d = PCI_ISA_IRQ_MASK;
    }

    checksum = 0;
    for ( i = 0; i < length; i++ )
        checksum += ((int8_t *)pir)[i];
    pir->checksum = -checksum;

    return (unsigned long)pir;
}
Exemple #8
0
/* load_file -- load a file of object code */
void load_file(FILE *bfp) {
     trailer t;
     int i, nread;

     int seglen[NSEGS];
     int start;

     /* Get trailer */
     fseek(bfp, -sizeof(trailer), SEEK_END);
     nread = fread(&t, 1, sizeof(trailer), bfp);

     /* Check magic numbers */
     if (strncmp((char *) t.magic, MAGIC, 4) != 0)
	  panic("bad magic number\n%s",
		"[The program you are running is not a valid"
		" Oberon bytecode file]");
     if (get_int(t.sig) != SIG)
	  panic("bad signature %#0.8x\n%s\n%s", get_int(t.sig),
		"[Although this appears to be an Oberon bytecode file,",
		"  it needs a different version of the runtime system]");
     if (prim_check != 0 && (unsigned) get_int(t.primsig) != prim_check)
	  panic("bad primitive checksum\n%s\n%s",
		"[This program uses a different set of primitives",
		"  from the ones built into the runtime system]");

     /* Decode the other data */
     for (i = 0; i < NSEGS; i++)
	  seglen[i] = get_int(t.segment[i]);

     code_size = seglen[S_CODE];
     stack_size = seglen[S_STACK];

     nmods = get_int(t.nmods); nprocs = get_int(t.nprocs); 
     nsyms = get_int(t.nsyms); start = get_int(t.start);

#ifdef DEBUG
     if (dflag) {
	  printf("csize = %d, dsize = %d, bss = %d, stk = %d\n", 
		 seglen[S_CODE], seglen[S_DATA], 
		 seglen[S_BSS], seglen[S_STACK]);
	  printf("nmods = %d, nprocs = %d, nsyms = %d\n",
		 nmods, nprocs, nsyms);
     }
#endif

     fseek(bfp, start, SEEK_END);
     binfp = bfp;

     /* Load the code */
     imem = (uchar *) scratch_alloc(seglen[S_CODE], TRUE);
     binread(imem, seglen[S_CODE]);

     /* Load and relocate the data */
     dmem = (uchar *) scratch_alloc(seglen[S_DATA]+seglen[S_BSS], FALSE);
     binread(dmem, seglen[S_DATA]);
     relocate(seglen[S_DATA]);
     memset(dmem+seglen[S_DATA], 0, seglen[S_BSS]);

     /* Allocate stack */
     stack = (uchar *) scratch_alloc(stack_size, FALSE);

     /* Save the entry point, pointer map and library path */
     entry = (value *) &dmem[get_int(t.entry)];
     gcmap = (value *) &dmem[get_int(t.gcmap)];
     if (get_int(t.libdir) != 0)
	  libpath = (char *) &dmem[get_int(t.libdir)];

     /* Read the symbols */
     if (nsyms > 0) read_symbols(seglen[S_DATA]);
}
Exemple #9
0
/* read_symbols -- read symbol table */
static void read_symbols(int dseg) {
     int kind; char *name; uchar *addr;
     int chksum, nlines;
     int nm = 0, np = 0, i;
     const char *kname;
	  
     modtab = (module *) scratch_alloc(nmods * sizeof(module), FALSE);
     proctab = (proc *) scratch_alloc(nprocs * sizeof(proc), FALSE);

     for (i = 0; i < nsyms; i++) {
	  kind = read_int();
	  name = read_string(); 

	  switch (kind) {
	  case X_MODULE:
	       kname = "Module";
	       addr = dmem + read_int(); 
	       chksum = read_int();
	       nlines = read_int();
	       modtab[nm++] = make_module(name, addr, chksum, nlines);
	       break;

	  case X_PROC:
	       kname = "Proc";
	       addr = dmem + read_int(); 
	       proctab[np++] = make_proc(name, addr);
	       break;
		    
	  case X_DATA:
	       kname = "Data";
	       addr = dmem + read_int(); 
	       make_symbol("data", name, addr);
	       break;

	  case X_LINE:
	       kname = "Line";
	       addr = imem + read_int();
	       make_symbol("line", name, addr);
	       break;

	  default:
	       kname = "Unknown"; addr = NULL;
	       panic("*bad symbol %s", name);
	  }

#ifdef DEBUG
	  if (dflag) printf("%s %s = %p\n", kname, name, addr);
#endif
     }

     if (nm != nmods || np != nprocs)
	  panic("*symbol counts don't match (mods %d/%d, procs %d/%d)\n",
		nm, nmods, np, nprocs);

     /* Calculate module lengths */
     addr = dmem + dseg;
     for (i = nmods-1; i >= 0; i--) {
	  modtab[i]->m_length = addr - modtab[i]->m_addr;
	  addr = modtab[i]->m_addr;
#ifdef DEBUG
	  if (dflag)
	       printf("Module %s has size %d\n", 
		      modtab[i]->m_name, modtab[i]->m_length);
#endif
     }
}
Exemple #10
0
static void seabios_create_smbios_tables(void)
{
    uint32_t ep = (uint32_t)scratch_alloc(sizeof(struct smbios_entry_point), 0);
    hvm_write_smbios_tables(ep, 0UL, 0UL);
    add_table(ep);
}