From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LQ24D-0007kd-E3 for qemu-devel@nongnu.org; Thu, 22 Jan 2009 11:06:05 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LQ24C-0007jE-Pe for qemu-devel@nongnu.org; Thu, 22 Jan 2009 11:06:04 -0500 Received: from [199.232.76.173] (port=57872 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LQ24C-0007in-4K for qemu-devel@nongnu.org; Thu, 22 Jan 2009 11:06:04 -0500 Received: from e2.ny.us.ibm.com ([32.97.182.142]:33351) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LQ24B-0006C1-IZ for qemu-devel@nongnu.org; Thu, 22 Jan 2009 11:06:03 -0500 Received: from d01relay02.pok.ibm.com (d01relay02.pok.ibm.com [9.56.227.234]) by e2.ny.us.ibm.com (8.13.1/8.13.1) with ESMTP id n0MG4QIC011606 for ; Thu, 22 Jan 2009 11:04:26 -0500 Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay02.pok.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id n0MG60f6173360 for ; Thu, 22 Jan 2009 11:06:00 -0500 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n0MG60Q7000733 for ; Thu, 22 Jan 2009 11:06:00 -0500 From: Hollis Blanchard In-Reply-To: <1232619256-18807-6-git-send-email-yu.liu@freescale.com> References: <1232619256-18807-1-git-send-email-yu.liu@freescale.com> <1232619256-18807-2-git-send-email-yu.liu@freescale.com> <1232619256-18807-3-git-send-email-yu.liu@freescale.com> <1232619256-18807-4-git-send-email-yu.liu@freescale.com> <1232619256-18807-5-git-send-email-yu.liu@freescale.com> <1232619256-18807-6-git-send-email-yu.liu@freescale.com> Content-Type: text/plain Date: Thu, 22 Jan 2009 10:05:51 -0600 Message-Id: <1232640351.23202.9.camel@slate.austin.ibm.com> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 5/6] kvm/powerpc: Add MPC85xx board support Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Liu Yu Cc: qemu-devel@nongnu.org, kvm-ppc@vger.kernel.org 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 ... > +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