From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L8WAz-0005KH-3D for qemu-devel@nongnu.org; Fri, 05 Dec 2008 03:36:41 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L8WAy-0005K4-2q for qemu-devel@nongnu.org; Fri, 05 Dec 2008 03:36:40 -0500 Received: from [199.232.76.173] (port=39353 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L8WAx-0005K1-PB for qemu-devel@nongnu.org; Fri, 05 Dec 2008 03:36:39 -0500 Received: from office.neopsis.com ([78.46.209.98]:52107) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1L8WAw-0005xO-Iu for qemu-devel@nongnu.org; Fri, 05 Dec 2008 03:36:38 -0500 Message-ID: <4938E7C9.8090107@dbservice.com> Date: Fri, 05 Dec 2008 09:35:21 +0100 From: Tomas Carnecky MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------020300060506040205050005" Subject: [Qemu-devel] IRQ problems under qemu Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: coreboot@coreboot.org, qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------020300060506040205050005 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit When I tried to run coreboot under qemu, I was at first positively surprised how well the things worked. The BIOS + linux kernel payload booted in no time! But when I then tried to set up networking, I couldn't get that to work. Somehow the linux kernel couldn't locate the interrupts of the NIC. After some digging I found out that coreboot doesn't provide ACPI tables and instead uses PCI IRQ table (I had to extract this table from a running qemu system using the getpir utility and then copy it to coreboot, if you want that patch, I can send that too). Coreboot copies this table at runtime into memory at 0xf0000. Apparently 0xf0000-0xfffff is part of the ISA BIOS, and qemu marks this range as read-only. The attached patch for qemu fixes that and also cleans up some of the memory initialization. Instead of marking the ISA BIOS as read-only, it copies that part from the BIOS image into the appropriate place (at 0xf0000-0xfffff) and leaves the memory as read-write. tom --------------020300060506040205050005 Content-Type: text/plain; name="cleanup-bios-memory-mapping.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cleanup-bios-memory-mapping.patch" Index: hw/pc.c =================================================================== --- hw/pc.c (revision 5846) +++ hw/pc.c (working copy) @@ -806,39 +806,29 @@ vmport_init(); - /* allocate RAM */ - ram_addr = qemu_ram_alloc(0xa0000); + /* allocate first MB of RAM */ + ram_addr = qemu_ram_alloc(0x100000); cpu_register_physical_memory(0, 0xa0000, ram_addr); - /* Allocate, even though we won't register, so we don't break the - * phys_ram_base + PA assumption. This range includes vga (0xa0000 - 0xc0000), - * and some bios areas, which will be registered later - */ - ram_addr = qemu_ram_alloc(0x100000 - 0xa0000); - ram_addr = qemu_ram_alloc(below_4g_mem_size - 0x100000); - cpu_register_physical_memory(0x100000, - below_4g_mem_size - 0x100000, - ram_addr); + /* allocate all of the remaining RAM and register it with the CPU */ + cpu_register_physical_memory(0x100000, below_4g_mem_size - 0x100000, + qemu_ram_alloc(below_4g_mem_size - 0x100000)); - /* above 4giga memory allocation */ if (above_4g_mem_size > 0) { - ram_addr = qemu_ram_alloc(above_4g_mem_size); - cpu_register_physical_memory(0x100000000ULL, - above_4g_mem_size, - ram_addr); + cpu_register_physical_memory(0x100000000ULL, above_4g_mem_size, + qemu_ram_alloc(above_4g_mem_size)); } - /* allocate VGA RAM */ vga_ram_addr = qemu_ram_alloc(vga_ram_size); - /* BIOS load */ + /* BIOS: load it to memory, copy the ISA BIOS into the last 128k + * of the first MB, map the whole BIOS at the top of memory */ if (bios_name == NULL) bios_name = BIOS_FILENAME; snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name); bios_size = get_image_size(buf); - if (bios_size <= 0 || - (bios_size % 65536) != 0) { + if (bios_size <= 0 || (bios_size % 65536) != 0) { goto bios_error; } bios_offset = qemu_ram_alloc(bios_size); @@ -849,7 +839,20 @@ exit(1); } - /* VGA BIOS load */ + cpu_register_physical_memory((uint32_t)(-bios_size), + bios_size, bios_offset | IO_MEM_ROM); + + isa_bios_size = bios_size; + if (isa_bios_size > (128 * 1024)) + isa_bios_size = 128 * 1024; + + memcpy(phys_ram_base + 0x100000 - isa_bios_size, + phys_ram_base + ram_addr + 0x100000 - isa_bios_size, isa_bios_size); + cpu_register_physical_memory(0x100000 - isa_bios_size, isa_bios_size, + ram_addr + 0x100000 - isa_bios_size); + + /* VGA BIOS: load it directly into 0xc0000+0x10000, + * register the range with the CPU. */ if (cirrus_vga_enabled) { snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_CIRRUS_FILENAME); } else { @@ -858,27 +861,17 @@ vga_bios_size = get_image_size(buf); if (vga_bios_size <= 0 || vga_bios_size > 65536) goto vga_bios_error; - vga_bios_offset = qemu_ram_alloc(65536); - ret = load_image(buf, phys_ram_base + vga_bios_offset); + ret = load_image(buf, phys_ram_base + ram_addr + 0xc0000); if (ret != vga_bios_size) { vga_bios_error: fprintf(stderr, "qemu: could not load VGA BIOS '%s'\n", buf); exit(1); } - /* setup basic memory access */ cpu_register_physical_memory(0xc0000, 0x10000, - vga_bios_offset | IO_MEM_ROM); + vga_bios_offset | IO_MEM_ROM); - /* map the last 128KB of the BIOS in ISA space */ - 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); - { ram_addr_t option_rom_offset; int size, offset; @@ -916,10 +909,6 @@ } } - /* map all the bios at the top of memory */ - cpu_register_physical_memory((uint32_t)(-bios_size), - bios_size, bios_offset | IO_MEM_ROM); - bochs_bios_init(); cpu_irq = qemu_allocate_irqs(pic_irq_request, NULL, 1); --------------020300060506040205050005--