2 * QEMU ETRAX System Emulator
4 * Copyright (c) 2007 Edgar E. Iglesias, Axis Communications AB.
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
31 static void main_cpu_reset(void *opaque
)
33 CPUState
*env
= opaque
;
37 /* Init functions for different blocks. */
38 extern qemu_irq
*etraxfs_pic_init(CPUState
*env
, target_phys_addr_t base
);
39 void etraxfs_timer_init(CPUState
*env
, qemu_irq
*irqs
,
40 target_phys_addr_t base
);
41 void etraxfs_ser_init(CPUState
*env
, qemu_irq
*irqs
, target_phys_addr_t base
);
44 void bareetraxfs_init (int ram_size
, int vga_ram_size
,
45 const char *boot_device
, DisplayState
*ds
,
46 const char *kernel_filename
, const char *kernel_cmdline
,
47 const char *initrd_filename
, const char *cpu_model
)
52 int flash_size
= 0x800000;
54 ram_addr_t phys_flash
;
58 if (cpu_model
== NULL
) {
59 cpu_model
= "crisv32";
61 env
= cpu_init(cpu_model
);
62 /* register_savevm("cpu", 0, 3, cpu_save, cpu_load, env); */
63 qemu_register_reset(main_cpu_reset
, env
);
66 phys_ram
= qemu_ram_alloc(ram_size
);
67 cpu_register_physical_memory(0x40000000, ram_size
, phys_ram
| IO_MEM_RAM
);
68 /* Unached mapping. */
69 cpu_register_physical_memory(0xc0000000, ram_size
, phys_ram
| IO_MEM_RAM
);
71 phys_flash
= qemu_ram_alloc(flash_size
);
72 cpu_register_physical_memory(0,flash_size
, IO_MEM_ROM
);
73 cpu_register_physical_memory(0x80000000, flash_size
, IO_MEM_ROM
);
74 cpu_register_physical_memory(0x04000000, flash_size
, IO_MEM_ROM
);
75 cpu_register_physical_memory(0x84000000, flash_size
,
76 0x04000000 | IO_MEM_ROM
);
77 index
= drive_get_index(IF_PFLASH
, 0, 0);
78 pflash_cfi01_register(0x80000000, flash_size
,
79 drives_table
[index
].bdrv
, 65536, flash_size
>> 16,
80 4, 0x0000, 0x0000, 0x0000, 0x0000);
81 index
= drive_get_index(IF_PFLASH
, 0, 1);
82 pflash_cfi01_register(0x84000000, flash_size
,
83 drives_table
[index
].bdrv
, 65536, flash_size
>> 16,
84 4, 0x0000, 0x0000, 0x0000, 0x0000);
86 pic
= etraxfs_pic_init(env
, 0xb001c000);
88 etraxfs_timer_init(env
, pic
, 0xb001e000);
89 etraxfs_timer_init(env
, pic
, 0xb005e000);
91 etraxfs_ser_init(env
, pic
, 0xb0026000);
92 etraxfs_ser_init(env
, pic
, 0xb0028000);
93 etraxfs_ser_init(env
, pic
, 0xb002a000);
94 etraxfs_ser_init(env
, pic
, 0xb002c000);
96 kernel_size
= load_image(kernel_filename
, phys_ram_base
+ 0x4000);
98 env
->regs
[8] = 0x56902387;
99 env
->regs
[9] = 0x40004000 + kernel_size
;
100 env
->pc
= 0x40004000;
103 unsigned char *ptr
= phys_ram_base
+ 0x4000;
105 for (i
= 0; i
< 8; i
++)
107 printf ("%2.2x ", ptr
[i
]);
112 printf ("pc =%x\n", env
->pc
);
113 printf ("ram size =%d\n", ram_size
);
114 printf ("kernel name =%s\n", kernel_filename
);
115 printf ("kernel size =%d\n", kernel_size
);
116 printf ("cpu haltd =%d\n", env
->halted
);
123 QEMUMachine bareetraxfs_machine
= {
125 "Bare ETRAX FS board",