From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lc3Xh-0003hp-Pk for qemu-devel@nongnu.org; Tue, 24 Feb 2009 15:06:14 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lc3Xf-0003hF-TF for qemu-devel@nongnu.org; Tue, 24 Feb 2009 15:06:13 -0500 Received: from [199.232.76.173] (port=56736 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lc3Xf-0003h7-Nq for qemu-devel@nongnu.org; Tue, 24 Feb 2009 15:06:11 -0500 Received: from mail-fx0-f161.google.com ([209.85.220.161]:41432) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Lc3Xe-0000rX-MJ for qemu-devel@nongnu.org; Tue, 24 Feb 2009 15:06:11 -0500 Received: by fxm5 with SMTP id 5so3007999fxm.10 for ; Tue, 24 Feb 2009 12:06:08 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <87hc2lhw46.fsf@pike.pond.sub.org> References: <87iqnh6kyv.fsf@pike.pond.sub.org> <87hc2lhw46.fsf@pike.pond.sub.org> Date: Tue, 24 Feb 2009 22:06:08 +0200 Message-ID: Subject: Re: [Qemu-devel] Machine description as data prototype, take 4 (was: [RFC] Machine description as data) From: Blue Swirl Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org On 2/23/09, Markus Armbruster wrote: > Fourth iteration of the prototype. I'm not asking to consider a merge > at this time. > +static dt_prop_spec dt_cpus_props[] = { > + DT_PROP_SPEC_INIT("model", dt_device_cpus, model, string), > + DT_PROP_SPEC_INIT("num", dt_device_cpus, num, int), > +}; Please use "const". > +static void dt_memrng_rom(dt_device_memrng *rng, > + target_phys_addr_t phys_addr, ram_addr_t maxsz, > + const char *dir, const char *image, int top) > +{ > + char buf[1024]; > + int size; > + > + snprintf(buf, sizeof(buf), "%s/%s", dir, image); > + size = get_image_size(buf); > + if (size < 0 || size > maxsz) > + goto error; > + if (top) > + phys_addr = phys_addr + maxsz - size; > + dt_memrng(rng, phys_addr, size, qemu_ram_alloc(size), IO_MEM_ROM); > + if (load_image(buf, phys_ram_base + rng->host_offs) != size) > + goto error; > + return; > + > +error: > + fprintf(stderr, "qemu: could not load image '%s'\n", buf); > + exit(1); > +} If this is going to be the generic ROM loader, it should also handle ELF format images. But for the PC this is enough. > +static dt_prop_spec dt_memory_props[] = { > + DT_PROP_SPEC_INIT("ram", dt_device_memory, ram_size, ram_addr_t), > +}; "const" > +static dt_prop_spec dt_pc_misc_props[] = { > + DT_PROP_SPEC_INIT("boot-device", dt_device_pc_misc, boot_device, > + string), > +}; "const" > +static dt_driver_vga dt_driver_vga_table[] = { > + { "cirrus", VGABIOS_CIRRUS_FILENAME, pci_cirrus_vga_init }, > + { "vms", VGABIOS_FILENAME, pci_vmsvga_init_ }, > + { "std", VGABIOS_FILENAME, pci_vga_init_ }, > + { NULL, NULL, NULL } > +}; "const" > +static dt_prop_spec dt_vga_props[] = { > + DT_PROP_SPEC_INIT("model", dt_device_vga, model, string), > + DT_PROP_SPEC_INIT("ram", dt_device_vga, ram_size, ram_addr_t), > +}; "const" > +static dt_prop_spec dt_nic_props[] = { > + DT_PROP_SPEC_INIT("model", dt_device_nic, nd.model, string), > + DT_PROP_SPEC_INIT("mac", dt_device_nic, nd.macaddr, macaddr), > + DT_PROP_SPEC_INIT("name", dt_device_nic, nd.name, string), > +}; "const" > +static dt_driver dt_driver_table[] = { > + { "", 0, NULL, NULL }, > + { "cpus", sizeof(dt_device_cpus), dt_cpus_props, > + NULL, dt_cpus_init, NULL }, > + { "memory", sizeof(dt_device_memory), dt_memory_props, > + dt_memory_config, dt_memory_init, NULL }, > + { "pc-misc", sizeof(dt_device_pc_misc), dt_pc_misc_props, > + dt_pc_misc_config, dt_pc_misc_init, dt_pc_misc_start }, > + { "pci", sizeof(dt_device_pci), NULL, > + dt_pci_config, dt_pci_init, dt_pci_start }, > + { "piix3", sizeof(dt_device_piix3), NULL, > + dt_piix3_config, dt_piix3_init, NULL }, > + { "vga", sizeof(dt_device_vga), dt_vga_props, > + dt_vga_config, dt_vga_init, NULL }, > + { "nic", sizeof(dt_device_nic), dt_nic_props, > + dt_nic_config, dt_nic_init, NULL }, > + { NULL, 0, NULL, NULL, NULL } > +}; "const" > void register_machines(void) > { > + extern QEMUMachine pcdt_machine; Put this into hw/boards.h. > +tree *tree_new_kid(tree *parent, const char *name, void *user) The OF term for "kid" is "child". > +tree *tree_sibling(const tree *node) Here the OF word is "peer".