2009-04-10 18:14:26 +02:00
|
|
|
/* Freescale mc1322x support
|
|
|
|
*
|
|
|
|
* Copyright (c) 2009 Mariano Alvira
|
|
|
|
* Written by Mariano Alvira <mar@devl.org>
|
|
|
|
*
|
|
|
|
* This code is licenced under the GPL.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "hw.h"
|
|
|
|
#include "mc1322x.h"
|
|
|
|
#include "sysemu.h"
|
|
|
|
#include "boards.h"
|
|
|
|
#include "flash.h"
|
2009-04-11 00:00:25 +02:00
|
|
|
#include "block.h"
|
2009-04-10 18:14:26 +02:00
|
|
|
|
2009-04-11 15:08:38 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2009-04-10 18:14:26 +02:00
|
|
|
static const int sector_len = 128 * 1024;
|
|
|
|
|
|
|
|
/* Initialize a MC1322x (ARM7) */
|
|
|
|
struct mc1322x_state_s *mc1322x_init(void)
|
|
|
|
{
|
|
|
|
struct mc1322x_state_s *s;
|
|
|
|
int index;
|
2009-04-11 15:08:38 +02:00
|
|
|
FILE *ram, *rom;
|
|
|
|
ram_addr_t ramoff, romoff;
|
2009-04-10 18:14:26 +02:00
|
|
|
|
|
|
|
s = (struct mc1322x_state_s *) qemu_mallocz(sizeof(struct mc1322x_state_s));
|
|
|
|
|
|
|
|
s->env = cpu_init("mc1322x");
|
|
|
|
if (!s->env) {
|
|
|
|
fprintf(stderr, "Unable to find CPU definition\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
register_savevm("cpu", 0, ARM_CPU_SAVE_VERSION, cpu_save, cpu_load,
|
|
|
|
s->env);
|
|
|
|
|
2009-04-11 15:08:38 +02:00
|
|
|
/* should probably allocate memory for all the cpu registers also */
|
|
|
|
|
|
|
|
romoff = qemu_ram_alloc(MC1322X_ROMSIZE);
|
2009-04-10 18:14:26 +02:00
|
|
|
cpu_register_physical_memory(MC1322X_ROMBASE, MC1322X_ROMSIZE,
|
2009-04-11 15:08:38 +02:00
|
|
|
romoff | IO_MEM_RAM);
|
|
|
|
ramoff = qemu_ram_alloc(MC1322X_RAMSIZE);
|
2009-04-10 18:14:26 +02:00
|
|
|
cpu_register_physical_memory(MC1322X_RAMBASE, MC1322X_RAMSIZE,
|
2009-04-11 15:08:38 +02:00
|
|
|
ramoff | IO_MEM_RAM);
|
2009-04-10 18:14:26 +02:00
|
|
|
|
2009-04-11 15:08:38 +02:00
|
|
|
/* need to add a way to specify these images from the command line */
|
2009-04-11 01:19:44 +02:00
|
|
|
|
2009-04-11 15:08:38 +02:00
|
|
|
if(rom = fopen("rom.img", "r")) {
|
|
|
|
fread(phys_ram_base,1,MC1322X_ROMSIZE,rom);
|
2009-04-11 00:00:25 +02:00
|
|
|
}
|
|
|
|
|
2009-04-11 15:08:38 +02:00
|
|
|
if(ram = fopen("ram.img", "r")) {
|
|
|
|
fprintf(stderr, "loading ram image\n");
|
|
|
|
fread(phys_ram_base+ramoff,1,MC1322X_RAMSIZE,ram);
|
2009-04-10 18:14:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
s->env->regs[15] = 0x00400000;
|
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
QEMUMachine mc1322x_machine = {
|
|
|
|
"mc1322x",
|
|
|
|
"mc1322x board",
|
|
|
|
mc1322x_init,
|
|
|
|
};
|