[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-discuss] How do i tell QEMU that memory i've have mapped is co
From: |
Peter Fillmore |
Subject: |
Re: [Qemu-discuss] How do i tell QEMU that memory i've have mapped is code? |
Date: |
Tue, 13 Jan 2015 11:27:57 +1100 |
Awesome!- that got it - i wasn’t aligned to the page so the emulator didn’t
recognise it of course.
Reason behind it being a that address is that the SoC contains embedded boot
code which is called by the firmware image - since i don’t have the full image
i needed to put some code to emulate a call to that address.
heres the code to copy a block of data into memory for others that may need it:
char iapcode[XXX] = {INSERT DATA HERE};
//array of data to copy
memory_region_init_ram(iap, NULL, "vivotech.iap", 0x2000,&error_abort); //init
iap memory (8k)
vmstate_register_ram_global(iap);
//register with the system
memory_region_add_subregion(sysmem, 0x7FFFF000, iap); //add
region to system memory at 0x7FFF F000, make sure your aligned to a page of
memory
char *ramptr = (char *)memory_region_get_ram_ptr(iap);
//get a pointer to the memory
if(ramptr != NULL)
memcpy(ramptr+0xFF0, iapcode, sizeof(iapcode));
//copy data into assigned memory
Thanks for the help again - saved me a ton of time.
-------------------------------------------------------
Peter Fillmore
Principle Consultant, CISSP
On 13 Jan 2015, at 10:48 am, Peter Maydell <address@hidden> wrote:
> On 12 January 2015 at 23:18, Peter Fillmore <address@hidden> wrote:
>> The setup code is <edited for brevity>:
>> MemoryRegion *sysmem = get_system_memory();
>> MemoryRegion *iap = g_new(MemoryRegion, 1);
>> //create pointer for region
>> memory_region_init_ram(iap, NULL, "vivotech.iap",
>> 0x1000,&error_abort); //init 0x1000 bytes of ram
>> vmstate_register_ram_global(iap);
>> //register with qemu
>> memory_region_add_subregion(sysmem, 0x7FFFFFF0, iap);
>> //add to the sysmem
>
> I'm confused; this doesn't look wrong, but it also doesn't seem
> to have anything at all to do with the code fragment you quoted
> in your previous email as being how you set up the memory.
>
> Also is it really 0x1000 bytes starting at 0x7ffffff0 ?? That
> sounds very weird -- usually memory is at some aligned address.
> In fact I think this is the problem: we require the whole page
> of the address space to be RAM to be able to execute out of it.
> We can't deal with executing from pages which are split between
> RAM and something else like the setup you have here. (Reading
> or writing from that sort of mixed-usage page is fine; it's just
> executing code that won't work.)
>
> -- PMM
signature.asc
Description: Message signed with OpenPGP using GPGMail