Hi,
the attached patch makes the i440bx emulation read the cmos registers of the bochs/qemu emulation that carry RAM size information instead of assuming 128MB.
Regards, Patrick
Signed-Off-By: Patrick Georgi patrick@georgi-clan.de
Index: northbridge/intel/i440bxemulation/domain =================================================================== --- northbridge/intel/i440bxemulation/domain (revision 689) +++ northbridge/intel/i440bxemulation/domain (working copy) @@ -19,6 +19,5 @@ */
{ - ramsize = "128"; device_operations = "i440bx_domain"; }; Index: northbridge/intel/i440bxemulation/i440bx.c =================================================================== --- northbridge/intel/i440bxemulation/i440bx.c (revision 689) +++ northbridge/intel/i440bxemulation/i440bx.c (working copy) @@ -37,25 +37,40 @@ * such modified SOFTWARE should be clearly marked, so as not to confuse * it with the version available from LANL. */ + /* dynamic qemu ram size detection + Copyright 2008 Patrick Georgi patrick@georgi-clan.de + Licensed under the terms of the GNU General Public License v2 or later + */
#include <types.h> #include <console.h> #include <device/device.h> #include <device/pci.h> #include <string.h> +#include <io.h> #include "i440bx.h" #include "statictree.h"
/* Here are the ops for 440BX as a PCI domain. */
+static int inb_cmos(int port) +{ + outb(port, 0x70); + return inb(0x71); +} + static void pci_domain_set_resources(struct device *dev) { struct device *mc_dev; u32 tolmk; /* Top of low mem, Kbytes. */ int idx; - struct northbridge_intel_i440bxemulation_domain_config *device_configuration = - dev->device_configuration; - tolmk = device_configuration->ramsize * 1024; + /* read large mem memory descriptor + for <16 MB read the more detailed small mem descriptor + all values in kbytes */ + tolmk = ((inb_cmos(0x35)<<8) |inb_cmos(0x34)) * 64; + if (tolmk <= 16 * 1024) { + tolmk = (inb_cmos(0x31)<<8) |inb_cmos(0x30); + } mc_dev = dev->link[0].children; if (mc_dev) { idx = 10;
On Fri, Jun 06, 2008 at 11:01:06PM +0200, Patrick Georgi wrote:
Index: northbridge/intel/i440bxemulation/domain
--- northbridge/intel/i440bxemulation/domain (revision 689) +++ northbridge/intel/i440bxemulation/domain (working copy) @@ -19,6 +19,5 @@ */
{
- ramsize = "128";
Is this parameter now used anywhere else?
device_operations = "i440bx_domain"; }; Index: northbridge/intel/i440bxemulation/i440bx.c =================================================================== --- northbridge/intel/i440bxemulation/i440bx.c (revision 689) +++ northbridge/intel/i440bxemulation/i440bx.c (working copy) @@ -37,25 +37,40 @@
- such modified SOFTWARE should be clearly marked, so as not to confuse
- it with the version available from LANL.
*/
- /* dynamic qemu ram size detection
- Copyright 2008 Patrick Georgi patrick@georgi-clan.de
- Licensed under the terms of the GNU General Public License v2 or later
- */
Maybe nicer to have the same style on all comments?
#include <types.h> #include <console.h> #include <device/device.h> #include <device/pci.h> #include <string.h> +#include <io.h> #include "i440bx.h" #include "statictree.h"
/* Here are the ops for 440BX as a PCI domain. */
+static int inb_cmos(int port) +{
- outb(port, 0x70);
- return inb(0x71);
+}
Is this available somewhere else? Should it be?
static void pci_domain_set_resources(struct device *dev) { struct device *mc_dev; u32 tolmk; /* Top of low mem, Kbytes. */ int idx;
- struct northbridge_intel_i440bxemulation_domain_config *device_configuration =
dev->device_configuration;
- tolmk = device_configuration->ramsize * 1024;
- /* read large mem memory descriptor
for <16 MB read the more detailed small mem descriptor
all values in kbytes */
- tolmk = ((inb_cmos(0x35)<<8) |inb_cmos(0x34)) * 64;
- if (tolmk <= 16 * 1024) {
tolmk = (inb_cmos(0x31)<<8) |inb_cmos(0x30);
- }
I like this.
//Peter
Peter Stuge schrieb:
On Fri, Jun 06, 2008 at 11:01:06PM +0200, Patrick Georgi wrote:
- ramsize = "128";
Is this parameter now used anywhere else?
The only other reference for "ramsize" I find is doc/design/newboot.lyx, which was wrong on this already (I don't see any way to change that value via kconfig). Unfortunately I don't have lyx, and I fear that mangling that file into compliance by hand will only break it. How to go on there?
Maybe nicer to have the same style on all comments?
Sorry, you're right. I added myself to the top header (which I didn't see before). I'll post a new patch when the other open issues are resolved.
+static int inb_cmos(int port) +{
- outb(port, 0x70);
- return inb(0x71);
+}
Is this available somewhere else? Should it be?
It seems to be an official interface that bochs/qemu adopted for their purpose (nvramtool uses these ports, too), but I can't see any other use in cbv3 except nvramtool, which is userland. It could (together with a write operation) be provided for future use. It might even be combined with nvramtool (but that's a different layer: boot code vs. userland, so I don't feel good with that).
In my opinion, moving them (two functions, read/write) as static functions to a header would be the best option. It's only drawn in when necessary, it's probably inlined anyway, and if they get used more regularily, we can still consider moving them to a separate source file in lib/. I'd look if that header could be used both for boot code and userland code, but not if that involves too many hacks.
Thanks for the review, Patrick