qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: Avi Kivity <avi@redhat.com>
Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org
Subject: Re: [Qemu-devel] [PATCH 18/23] pc: convert pc_memory_init() to memory API
Date: Mon, 25 Jul 2011 14:23:32 -0500	[thread overview]
Message-ID: <4E2DC2B4.3070205@codemonkey.ws> (raw)
In-Reply-To: <1311602584-23409-19-git-send-email-avi@redhat.com>

On 07/25/2011 09:02 AM, Avi Kivity wrote:
> Signed-off-by: Avi Kivity<avi@redhat.com>

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>

Regards,

Anthony Liguori

> ---
>   hw/pc.c |   59 ++++++++++++++++++++++++++++++++++++++++-------------------
>   hw/pc.h |    1 +
>   2 files changed, 41 insertions(+), 19 deletions(-)
>
> diff --git a/hw/pc.c b/hw/pc.c
> index 369566a..1c9d89a 100644
> --- a/hw/pc.c
> +++ b/hw/pc.c
> @@ -41,6 +41,7 @@
>   #include "sysemu.h"
>   #include "blockdev.h"
>   #include "ui/qemu-spice.h"
> +#include "memory.h"
>
>   /* output Bochs bios info messages */
>   //#define DEBUG_BIOS
> @@ -966,22 +967,30 @@ void pc_memory_init(MemoryRegion *system_memory,
>   {
>       char *filename;
>       int ret, linux_boot, i;
> -    ram_addr_t ram_addr, bios_offset, option_rom_offset;
> +    MemoryRegion *ram, *bios, *isa_bios, *option_rom_mr;
> +    MemoryRegion *ram_below_4g, *ram_above_4g;
>       int bios_size, isa_bios_size;
>       void *fw_cfg;
>
>       linux_boot = (kernel_filename != NULL);
>
> -    /* allocate RAM */
> -    ram_addr = qemu_ram_alloc(NULL, "pc.ram",
> -                              below_4g_mem_size + above_4g_mem_size);
> -    cpu_register_physical_memory(0, 0xa0000, ram_addr);
> -    cpu_register_physical_memory(0x100000,
> -                 below_4g_mem_size - 0x100000,
> -                 ram_addr + 0x100000);
> +    /* Allocate RAM.  We allocate it as a single memory region and use
> +     * aliases to address portions of it, mostly for backwards compatiblity
> +     * with older qemus that used qemu_ram_alloc().
> +     */
> +    ram = qemu_malloc(sizeof(*ram));
> +    memory_region_init_ram(ram, NULL, "pc.ram",
> +                           below_4g_mem_size + above_4g_mem_size);
> +    ram_below_4g = qemu_malloc(sizeof(*ram_below_4g));
> +    memory_region_init_alias(ram_below_4g, "ram-below-4g", ram,
> +                             0, below_4g_mem_size);
> +    memory_region_add_subregion(system_memory, 0, ram_below_4g);
>       if (above_4g_mem_size>  0) {
> -        cpu_register_physical_memory(0x100000000ULL, above_4g_mem_size,
> -                                     ram_addr + below_4g_mem_size);
> +        ram_above_4g = qemu_malloc(sizeof(*ram_above_4g));
> +        memory_region_init_alias(ram_above_4g, "ram-above-4g", ram,
> +                                 below_4g_mem_size, above_4g_mem_size);
> +        memory_region_add_subregion(system_memory, 0x100000000ULL,
> +                                    ram_above_4g);
>       }
>
>       /* BIOS load */
> @@ -997,7 +1006,9 @@ void pc_memory_init(MemoryRegion *system_memory,
>           (bios_size % 65536) != 0) {
>           goto bios_error;
>       }
> -    bios_offset = qemu_ram_alloc(NULL, "pc.bios", bios_size);
> +    bios = qemu_malloc(sizeof(*bios));
> +    memory_region_init_ram(bios, NULL, "pc.bios", bios_size);
> +    memory_region_set_readonly(bios, true);
>       ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1);
>       if (ret != 0) {
>       bios_error:
> @@ -1011,16 +1022,26 @@ void pc_memory_init(MemoryRegion *system_memory,
>       isa_bios_size = bios_size;
>       if (isa_bios_size>  (128 * 1024))
>           isa_bios_size = 128 * 1024;
> -    cpu_register_physical_memory(0x100000 - isa_bios_size,
> -                                 isa_bios_size,
> -                                 (bios_offset + bios_size - isa_bios_size) | IO_MEM_ROM);
> -
> -    option_rom_offset = qemu_ram_alloc(NULL, "pc.rom", PC_ROM_SIZE);
> -    cpu_register_physical_memory(PC_ROM_MIN_VGA, PC_ROM_SIZE, option_rom_offset);
> +    isa_bios = qemu_malloc(sizeof(*isa_bios));
> +    memory_region_init_alias(isa_bios, "isa-bios", bios,
> +                             bios_size - isa_bios_size, isa_bios_size);
> +    memory_region_add_subregion_overlap(system_memory,
> +                                        0x100000 - isa_bios_size,
> +                                        isa_bios,
> +                                        1);
> +    memory_region_set_readonly(isa_bios, true);
> +
> +    option_rom_mr = qemu_malloc(sizeof(*option_rom_mr));
> +    memory_region_init_ram(option_rom_mr, NULL, "pc.rom", PC_ROM_SIZE);
> +    memory_region_add_subregion_overlap(system_memory,
> +                                        PC_ROM_MIN_VGA,
> +                                        option_rom_mr,
> +                                        1);
>
>       /* map all the bios at the top of memory */
> -    cpu_register_physical_memory((uint32_t)(-bios_size),
> -                                 bios_size, bios_offset | IO_MEM_ROM);
> +    memory_region_add_subregion(system_memory,
> +                                (uint32_t)(-bios_size),
> +                                bios);
>
>       fw_cfg = bochs_bios_init();
>       rom_set_fw(fw_cfg);
> diff --git a/hw/pc.h b/hw/pc.h
> index fa57583..40684f4 100644
> --- a/hw/pc.h
> +++ b/hw/pc.h
> @@ -2,6 +2,7 @@
>   #define HW_PC_H
>
>   #include "qemu-common.h"
> +#include "memory.h"
>   #include "ioport.h"
>   #include "isa.h"
>   #include "fdc.h"

  reply	other threads:[~2011-07-25 19:23 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-25 14:02 [Qemu-devel] [PATCH 00/23] Memory API, batch 1 Avi Kivity
2011-07-25 14:02 ` [Qemu-devel] [PATCH 01/23] Hierarchical memory region API Avi Kivity
2011-07-25 18:41   ` Anthony Liguori
2011-07-26  9:35     ` Avi Kivity
2011-07-25 14:02 ` [Qemu-devel] [PATCH 02/23] memory: implement dirty tracking Avi Kivity
2011-07-25 18:43   ` Anthony Liguori
2011-07-25 14:02 ` [Qemu-devel] [PATCH 03/23] memory: merge adjacent segments of a single memory region Avi Kivity
2011-07-25 18:48   ` Anthony Liguori
2011-07-26  9:55     ` Avi Kivity
2011-07-25 14:02 ` [Qemu-devel] [PATCH 04/23] Internal interfaces for memory API Avi Kivity
2011-07-25 18:49   ` Anthony Liguori
2011-07-25 14:02 ` [Qemu-devel] [PATCH 05/23] memory: abstract address space operations Avi Kivity
2011-07-25 18:51   ` Anthony Liguori
2011-07-25 14:02 ` [Qemu-devel] [PATCH 06/23] memory: rename MemoryRegion::has_ram_addr to ::terminates Avi Kivity
2011-07-25 18:56   ` Anthony Liguori
2011-07-26  9:59     ` Avi Kivity
2011-07-25 14:02 ` [Qemu-devel] [PATCH 07/23] memory: late initialization of ram_addr Avi Kivity
2011-07-25 14:02 ` [Qemu-devel] [PATCH 08/23] memory: I/O address space support Avi Kivity
2011-07-25 19:00   ` Anthony Liguori
2011-07-25 14:02 ` [Qemu-devel] [PATCH 09/23] memory: add backward compatibility for old portio registration Avi Kivity
2011-07-25 19:01   ` Anthony Liguori
2011-07-25 14:02 ` [Qemu-devel] [PATCH 10/23] memory: add backward compatibility for old mmio registration Avi Kivity
2011-07-25 19:02   ` Anthony Liguori
2011-07-25 14:02 ` [Qemu-devel] [PATCH 11/23] memory: add ioeventfd support Avi Kivity
2011-07-25 15:16   ` malc
2011-07-25 15:17     ` Avi Kivity
2011-07-25 15:22       ` malc
2011-07-25 15:28         ` Avi Kivity
2011-07-25 15:38           ` malc
2011-07-25 15:43             ` Avi Kivity
2011-07-25 19:08   ` Anthony Liguori
2011-07-26 10:08     ` Avi Kivity
2011-07-25 14:02 ` [Qemu-devel] [PATCH 12/23] memory: separate building the final memory map into two steps Avi Kivity
2011-07-25 19:12   ` Anthony Liguori
2011-07-26 10:43     ` Avi Kivity
2011-07-25 14:02 ` [Qemu-devel] [PATCH 13/23] memory: document the memory API Avi Kivity
2011-07-25 19:15   ` Anthony Liguori
2011-07-26 10:44     ` Avi Kivity
2011-07-25 14:02 ` [Qemu-devel] [PATCH 14/23] memory: transaction API Avi Kivity
2011-07-25 19:16   ` Anthony Liguori
2011-07-26 10:48     ` Avi Kivity
2011-07-26 11:39       ` Avi Kivity
2011-07-25 14:02 ` [Qemu-devel] [PATCH 15/23] exec.c: initialize memory map Avi Kivity
2011-07-25 19:17   ` Anthony Liguori
2011-07-26 10:55     ` Avi Kivity
2011-07-25 14:02 ` [Qemu-devel] [PATCH 16/23] ioport: register ranges by byte aligned addresses always Avi Kivity
2011-07-25 19:20   ` Anthony Liguori
2011-07-26 10:59     ` Avi Kivity
2011-07-25 14:02 ` [Qemu-devel] [PATCH 17/23] pc: grab system_memory Avi Kivity
2011-07-25 19:22   ` Anthony Liguori
2011-07-25 14:02 ` [Qemu-devel] [PATCH 18/23] pc: convert pc_memory_init() to memory API Avi Kivity
2011-07-25 19:23   ` Anthony Liguori [this message]
2011-07-25 14:03 ` [Qemu-devel] [PATCH 19/23] pc: move global memory map out of pc_init1() and into its callers Avi Kivity
2011-07-25 20:02   ` Anthony Liguori
2011-07-26 11:02     ` Avi Kivity
2011-07-25 14:03 ` [Qemu-devel] [PATCH 20/23] pci: pass address space to pci bus when created Avi Kivity
2011-07-25 20:03   ` Anthony Liguori
2011-07-25 14:03 ` [Qemu-devel] [PATCH 21/23] pci: add MemoryRegion based BAR management API Avi Kivity
2011-07-25 20:20   ` Anthony Liguori
2011-07-26 11:06     ` Avi Kivity
2011-07-25 14:03 ` [Qemu-devel] [PATCH 22/23] sysbus: add MemoryRegion based memory " Avi Kivity
2011-07-25 20:21   ` Anthony Liguori
2011-07-25 14:03 ` [Qemu-devel] [PATCH 23/23] usb-ohci: convert to MemoryRegion Avi Kivity
2011-07-25 20:22   ` Anthony Liguori
2011-07-25 20:23 ` [Qemu-devel] [PATCH 00/23] Memory API, batch 1 Anthony Liguori
2011-07-26 11:32   ` Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E2DC2B4.3070205@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).