load memory with images directly. emulation runs correctly now.
This commit is contained in:
parent
7881c8945e
commit
2ea5f005ee
@ -8,12 +8,13 @@ Build qemu
|
|||||||
|
|
||||||
Run with
|
Run with
|
||||||
arm-softmmu/qemu-system-arm -S -M mc1322x -nographic \
|
arm-softmmu/qemu-system-arm -S -M mc1322x -nographic \
|
||||||
-pflash ~/mc1322x-tests/tests/blink-red.bin \
|
foo
|
||||||
-mtdblock ~/mcmc1322x-tests/doc/mc13224v.img
|
|
||||||
|
|
||||||
which will load mc13224v.img at 0x00000000 and blink-red.bin at
|
which will load rom.img at 0x00000000 and ram.img at
|
||||||
0x00400000 --- execution will start at 0x00400000 (type c).
|
0x00400000 --- execution will start at 0x00400000 (type c).
|
||||||
|
|
||||||
|
I'll be adding command line options for those images soon.
|
||||||
|
|
||||||
Debug with gdb:
|
Debug with gdb:
|
||||||
|
|
||||||
Build gdb for an arm target:
|
Build gdb for an arm target:
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
#include "flash.h"
|
#include "flash.h"
|
||||||
#include "block.h"
|
#include "block.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
static const int sector_len = 128 * 1024;
|
static const int sector_len = 128 * 1024;
|
||||||
|
|
||||||
/* Initialize a MC1322x (ARM7) */
|
/* Initialize a MC1322x (ARM7) */
|
||||||
@ -20,6 +22,8 @@ struct mc1322x_state_s *mc1322x_init(void)
|
|||||||
{
|
{
|
||||||
struct mc1322x_state_s *s;
|
struct mc1322x_state_s *s;
|
||||||
int index;
|
int index;
|
||||||
|
FILE *ram, *rom;
|
||||||
|
ram_addr_t ramoff, romoff;
|
||||||
|
|
||||||
s = (struct mc1322x_state_s *) qemu_mallocz(sizeof(struct mc1322x_state_s));
|
s = (struct mc1322x_state_s *) qemu_mallocz(sizeof(struct mc1322x_state_s));
|
||||||
|
|
||||||
@ -31,29 +35,24 @@ struct mc1322x_state_s *mc1322x_init(void)
|
|||||||
register_savevm("cpu", 0, ARM_CPU_SAVE_VERSION, cpu_save, cpu_load,
|
register_savevm("cpu", 0, ARM_CPU_SAVE_VERSION, cpu_save, cpu_load,
|
||||||
s->env);
|
s->env);
|
||||||
|
|
||||||
/* SDRAM & Internal Memory Storage */
|
/* should probably allocate memory for all the cpu registers also */
|
||||||
/* should probably allocate memory for all the cpu registers... I think that is where the emulation might be bombing */
|
|
||||||
|
romoff = qemu_ram_alloc(MC1322X_ROMSIZE);
|
||||||
cpu_register_physical_memory(MC1322X_ROMBASE, MC1322X_ROMSIZE,
|
cpu_register_physical_memory(MC1322X_ROMBASE, MC1322X_ROMSIZE,
|
||||||
qemu_ram_alloc(MC1322X_ROMSIZE) | IO_MEM_RAM);
|
romoff | IO_MEM_RAM);
|
||||||
|
ramoff = qemu_ram_alloc(MC1322X_RAMSIZE);
|
||||||
cpu_register_physical_memory(MC1322X_RAMBASE, MC1322X_RAMSIZE,
|
cpu_register_physical_memory(MC1322X_RAMBASE, MC1322X_RAMSIZE,
|
||||||
qemu_ram_alloc(MC1322X_RAMSIZE) | IO_MEM_RAM);
|
ramoff | IO_MEM_RAM);
|
||||||
|
|
||||||
/* shouldn't load the images in this way */
|
/* need to add a way to specify these images from the command line */
|
||||||
/* should make a commandline arg for this and just load the file to ram */
|
|
||||||
/* directly. */
|
|
||||||
/* this may be possible with snapshots or something...*/
|
|
||||||
|
|
||||||
index = drive_get_index(IF_MTD, 0, 0);
|
if(rom = fopen("rom.img", "r")) {
|
||||||
if(0<bdrv_read(drives_table[index].bdrv,0,phys_ram_base+MC1322X_ROMBASE,MC1322X_ROMSIZE/512)) {
|
fread(phys_ram_base,1,MC1322X_ROMSIZE,rom);
|
||||||
fprintf(stderr, "qemu: Error registering rom memory.\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
index = drive_get_index(IF_PFLASH, 0, 0);
|
if(ram = fopen("ram.img", "r")) {
|
||||||
if (!pflash_cfi01_register(0x00400000, qemu_ram_alloc(MC1322X_RAMSIZE),
|
fprintf(stderr, "loading ram image\n");
|
||||||
drives_table[index].bdrv, sector_len, MC1322X_RAMSIZE / sector_len,
|
fread(phys_ram_base+ramoff,1,MC1322X_RAMSIZE,ram);
|
||||||
2, 0, 0, 0, 0)) {
|
|
||||||
fprintf(stderr, "qemu: Error registering flash memory.\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
s->env->regs[15] = 0x00400000;
|
s->env->regs[15] = 0x00400000;
|
||||||
|
Loading…
Reference in New Issue
Block a user