Annotation of qemu/hw/dummy_m68k.c, revision 1.1.1.7

1.1       root        1: /*
                      2:  * Dummy board with just RAM and CPU for use as an ISS.
                      3:  *
                      4:  * Copyright (c) 2007 CodeSourcery.
                      5:  *
1.1.1.6   root        6:  * This code is licensed under the GPL
1.1       root        7:  */
                      8: 
                      9: #include "hw.h"
                     10: #include "boards.h"
1.1.1.4   root       11: #include "loader.h"
                     12: #include "elf.h"
1.1.1.7 ! root       13: #include "exec-memory.h"
1.1       root       14: 
                     15: #define KERNEL_LOAD_ADDR 0x10000
                     16: 
                     17: /* Board init.  */
                     18: 
1.1.1.3   root       19: static void dummy_m68k_init(ram_addr_t ram_size,
1.1.1.2   root       20:                      const char *boot_device,
1.1       root       21:                      const char *kernel_filename, const char *kernel_cmdline,
                     22:                      const char *initrd_filename, const char *cpu_model)
                     23: {
                     24:     CPUState *env;
1.1.1.7 ! root       25:     MemoryRegion *address_space_mem =  get_system_memory();
        !            26:     MemoryRegion *ram = g_new(MemoryRegion, 1);
1.1       root       27:     int kernel_size;
                     28:     uint64_t elf_entry;
1.1.1.4   root       29:     target_phys_addr_t entry;
1.1       root       30: 
                     31:     if (!cpu_model)
                     32:         cpu_model = "cfv4e";
                     33:     env = cpu_init(cpu_model);
                     34:     if (!env) {
                     35:         fprintf(stderr, "Unable to find m68k CPU definition\n");
                     36:         exit(1);
                     37:     }
                     38: 
                     39:     /* Initialize CPU registers.  */
                     40:     env->vbr = 0;
                     41: 
                     42:     /* RAM at address zero */
1.1.1.7 ! root       43:     memory_region_init_ram(ram, NULL, "dummy_m68k.ram", ram_size);
        !            44:     memory_region_add_subregion(address_space_mem, 0, ram);
1.1       root       45: 
                     46:     /* Load kernel.  */
                     47:     if (kernel_filename) {
1.1.1.5   root       48:         kernel_size = load_elf(kernel_filename, NULL, NULL, &elf_entry,
                     49:                                NULL, NULL, 1, ELF_MACHINE, 0);
1.1       root       50:         entry = elf_entry;
                     51:         if (kernel_size < 0) {
1.1.1.2   root       52:             kernel_size = load_uimage(kernel_filename, &entry, NULL, NULL);
1.1       root       53:         }
                     54:         if (kernel_size < 0) {
1.1.1.3   root       55:             kernel_size = load_image_targphys(kernel_filename,
                     56:                                               KERNEL_LOAD_ADDR,
                     57:                                               ram_size - KERNEL_LOAD_ADDR);
1.1       root       58:             entry = KERNEL_LOAD_ADDR;
                     59:         }
                     60:         if (kernel_size < 0) {
                     61:             fprintf(stderr, "qemu: could not load kernel '%s'\n",
                     62:                     kernel_filename);
                     63:             exit(1);
                     64:         }
                     65:     } else {
                     66:         entry = 0;
                     67:     }
                     68:     env->pc = entry;
                     69: }
                     70: 
1.1.1.3   root       71: static QEMUMachine dummy_m68k_machine = {
1.1.1.2   root       72:     .name = "dummy",
                     73:     .desc = "Dummy board",
                     74:     .init = dummy_m68k_init,
1.1       root       75: };
1.1.1.3   root       76: 
                     77: static void dummy_m68k_machine_init(void)
                     78: {
                     79:     qemu_register_machine(&dummy_m68k_machine);
                     80: }
                     81: 
                     82: machine_init(dummy_m68k_machine_init);

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.