qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Hollis Blanchard <hollisb@us.ibm.com>
To: Liu Yu <yu.liu@freescale.com>
Cc: qemu-devel@nongnu.org, kvm-ppc@vger.kernel.org
Subject: [Qemu-devel] Re: [PATCH 5/6] kvm/powerpc: Add MPC85xx board support
Date: Thu, 22 Jan 2009 10:05:51 -0600	[thread overview]
Message-ID: <1232640351.23202.9.camel@slate.austin.ibm.com> (raw)
In-Reply-To: <1232619256-18807-6-git-send-email-yu.liu@freescale.com>

On Thu, 2009-01-22 at 18:14 +0800, Liu Yu wrote:
> All MPC85xx boards use E500v1/v2 core.
> This patch add emulation of a virtual MPC85xx board,
> so that any MPC85xx host could run this emulation.
> 
> Only tested it on MPC8544DS and MPC8572DS hosts,
> but it should work on other MPC85xx boards.
> 
> Signed-off-by: Liu Yu <yu.liu@freescale.com>
...

> +struct board {
> +    const char *model;
> +    const char *compatible;
> +};
> +
> +#define BOARD_DEF(_model, _compatible)   \
> +    {                                    \
> +        .model       = _model,           \
> +        .compatible  = _compatible,      \
> +    }
> +
> +/* Supported host boards */
> +static const struct board mpc85xx_table[] = {
> +    BOARD_DEF("MPC8544DS",        "MPC8544DS"),         /* MPC8544DS */
> +    BOARD_DEF("fsl,MPC8572DS",    "fsl,MPC8572DS"),     /* MPC8572DS */
> +    BOARD_DEF("fsl,mpc8536ds",    "fsl,mpc8536ds"),     /* MPC8536DS */
> +    BOARD_DEF("MPC8548CDS",       "MPC8548CDS"),        /* MPC8548CDS */
> +    BOARD_DEF("MPC8555CDS",       "MPC8555CDS"),        /* MPC8555CDS */
> +    BOARD_DEF("MPC8541CDS",       "MPC8541CDS"),        /* MPC8541CDS */
> +    BOARD_DEF("MPC8540ADS",       "MPC8540ADS"),        /* MPC8540ADS */
> +    BOARD_DEF("MPC8560ADS",       "MPC8560ADS"),        /* MPC8560ADS */
> +    BOARD_DEF("MPC8568EMDS",      "MPC8568EMDS"),       /* MPC8568EMDS */
> +};
> +
> +#define BOARDS_NUM       (sizeof(mpc85xx_table)/sizeof(struct board))
...
> +static void *mpc85xx_load_device_tree(void *addr,
> +                                     uint32_t ramsize,
> +                                     target_phys_addr_t initrd_base,
> +                                     target_phys_addr_t initrd_size,
> +                                     const char *kernel_cmdline)
> +{
...
> +    if (kvm_enabled()) {
> +	FILE *fp;
> +	char *model;
> +	char const *compatible = NULL;
> +	struct dirent *dirp;
> +	DIR *dp;
> +	int i;
> +	char buf[128];
> +
> +	if ((fp = fopen("/proc/cpuinfo", "r")) == NULL) {
> +	    printf("Can't open file /proc/cpuinfo\n");
> +	    goto out;
> +	}
> +	while (fgets(buf, 128, fp) != NULL) {
> +	    if (strncmp(buf, "model", 5) == 0) {
> +		model = buf + 9;
> +		break;
> +	    }
> +	}
> +	fclose(fp);
> +
> +	for (i = 0; i < BOARDS_NUM; i++) {
> +	    if (strncmp(model, mpc85xx_table[i].model,
> +			strlen(mpc85xx_table[i].model)) == 0) {
> +		compatible = mpc85xx_table[i].compatible;
> +	    }
> +	}
> +
> +	if (compatible == NULL) {
> +	    printf("Unknow host board!\n");
> +	    goto out;
> +	}
> +
> +	ret = qemu_devtree_setprop_string(fdt, "/", "compatible", compatible);
> +	if (ret < 0)
> +	    fprintf(stderr, "couldn't set /compatible = %s\n", compatible);
> +
> +	if ((dp = opendir("/proc/device-tree/cpus/")) == NULL) {
> +	    printf("Can't open directory /proc/device-tree/cpus/\n");
> +	    goto out;
> +	}
> +
> +	buf[0] = '\0';
> +	while ((dirp = readdir(dp)) != NULL) {
> +	    if (strncmp(dirp->d_name, "PowerPC", 7) == 0) {
> +		sprintf(buf, "/proc/device-tree/cpus/%s", dirp->d_name);
> +		break;
> +	    }
> +	}
> +	closedir(dp);
> +	if (buf[0] == '\0') {
> +	    printf("Unknow host!\n");
> +	    goto out;
> +	}
> +	path = buf + 17;

I don't think you should do this at all. As long as the core is "known",
it doesn't matter what the host board is. You *always* emulate the
MPC8544DS board (that's what your device tree says). You should be able
to emulate a MPC8544DS on *any* e500v2 host board or chip.

For comparison, on 440 we have tested with Sequoia (440EPx) and Bamboo
(440EP) hosts, but qemu always emulates a Bamboo guest. The chips aren't
the same, but that's irrelevant because the core is (440 x5).

The rest of this patch looks good.

-- 
Hollis Blanchard
IBM Linux Technology Center

  parent reply	other threads:[~2009-01-22 16:06 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-22 10:14 [Qemu-devel] [PATCH 0/6] kvm/powerpc: Add emulation for MPC85xx in KVM mode Liu Yu
2009-01-22 10:14 ` [Qemu-devel] [PATCH 1/6] kvm/powerpc: Enable MPIC for MPC85xx platform Liu Yu
2009-01-22 10:14   ` [Qemu-devel] [PATCH 2/6] kvm/powerpc: Add freescale pci controller's support Liu Yu
2009-01-22 10:14     ` [Qemu-devel] [PATCH 3/6] kvm/powerpc: Add irq support for E500 core Liu Yu
2009-01-22 10:14       ` [Qemu-devel] [PATCH 4/6] kvm/powerpc: extern one function for MPC85xx code use Liu Yu
2009-01-22 10:14         ` [Qemu-devel] [PATCH 5/6] kvm/powerpc: Add MPC85xx board support Liu Yu
2009-01-22 10:14           ` [Qemu-devel] [PATCH 6/6] kvm/powerpc: flat device tree files for MPC85xx Liu Yu
2009-01-22 15:54             ` [Qemu-devel] " Hollis Blanchard
2009-01-22 16:05           ` Hollis Blanchard [this message]
2009-01-24 16:36         ` [Qemu-devel] [PATCH 4/6] kvm/powerpc: extern one function for MPC85xx code use Aurelien Jarno
2009-01-24 16:32       ` [Qemu-devel] [PATCH 3/6] kvm/powerpc: Add irq support for E500 core Aurelien Jarno
2009-02-09  8:34         ` [Qemu-devel] [PATCH 3/6] kvm/powerpc: Add irq support for E500core Liu Yu-B13201
2009-01-24 16:02     ` [Qemu-devel] [PATCH 2/6] kvm/powerpc: Add freescale pci controller's support Aurelien Jarno
2009-02-09  8:33       ` [Qemu-devel] [PATCH 2/6] kvm/powerpc: Add freescale pcicontroller's support Liu Yu-B13201
2009-02-09 10:28         ` Aurelien Jarno
2009-01-22 16:13 ` [Qemu-devel] Re: [PATCH 0/6] kvm/powerpc: Add emulation for MPC85xx in KVM mode Hollis Blanchard
2009-01-27  7:38   ` [Qemu-devel] Regarding ARM11Mpcore MMC kernel panic sathish kumar

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=1232640351.23202.9.camel@slate.austin.ibm.com \
    --to=hollisb@us.ibm.com \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=qemu-devel@nongnu.org \
    --cc=yu.liu@freescale.com \
    /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).