qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC PATCH v4 1/3] use image_file_reset to reload initr


From: Yin Olivia-R63875
Subject: Re: [Qemu-devel] [RFC PATCH v4 1/3] use image_file_reset to reload initrd image
Date: Fri, 16 Nov 2012 05:50:50 +0000

Hi Stuart,

I want to keep the Memory Region of rom which will be inserted to the queue 
roms.
And then we can use "info roms" command to check the rom information.

ROM images must be loaded at startup, so rom_add_* functions could be called 
only
one time before all the reset handlers.

Exactly all the memory malloced to rom->data will be free when rom_reset() no 
matter
it is rom (rom->isrom = 1) or ram (rom->isrom =0).
@@ -708,11 +739,8 @@ static void rom_reset(void *unused)
             continue;
         }
         cpu_physical_memory_write_rom(rom->addr, rom->data, rom->romsize);
-        if (rom->isrom) {
-            /* rom needs to be written only once */
-            g_free(rom->data);
-            rom->data = NULL;
-        }
+        g_free(rom->data);
+        rom->data = NULL;
     }
 }

For example, to load initrd image, both reset handlers (rom_reset() and 
image_file_reset() 
will write the image into the same physical address. So it will not malloc more 
memory.
        cpu_physical_memory_write_rom(rom->addr, rom->data, rom->romsize);
        cpu_physical_memory_write(image->addr, (uint8_t *)content, size);

The uImage is another case, I'll explain in the reply of patch 2/3.

Best Regards,
Olivia

> -----Original Message-----
> From: Stuart Yoder [mailto:address@hidden
> Sent: Friday, November 16, 2012 3:52 AM
> To: Yin Olivia-R63875
> Cc: address@hidden; address@hidden
> Subject: Re: [Qemu-devel] [RFC PATCH v4 1/3] use image_file_reset to
> reload initrd image
> 
> >  /* read()-like version */
> >  ssize_t read_targphys(const char *name,
> >                        int fd, hwaddr dst_addr, size_t nbytes) @@
> > -113,6 +146,12 @@ int load_image_targphys(const char *filename,
> >      }
> >      if (size > 0) {
> >          rom_add_file_fixed(filename, addr, -1);
> > +        ImageFile *image;
> > +        image = g_malloc0(sizeof(*image));
> > +        image->name = g_strdup(filename);
> > +        image->addr = addr;
> > +
> > +        qemu_register_reset(image_file_reset, image);
> 
> You need to remove the call to rom_add_file_fixed(), no?
> 
> Stuart





reply via email to

[Prev in Thread] Current Thread [Next in Thread]