Hi Christian,

Thanks for looking into this! I've been meaning clean up this code a bit, but never really got around to do it properly. I have been hacking [1] the code slightly to get 32-bit kernels to load in KVM, but never got around to push the cleanups that resulted from that.

My impression of the current code is that it is pretty Linux-specific, so a proper multiboot compliant loader would definitely be a nice addition. IIRC, 32-bit Linux kernels currently don't work in simulated gem5 CPUs because of missing legacy interrupt support, which I believe is the reason the CPU is booted in long mode.

You can't parameterize initState since that's a part of the SimObject specification. I would suggest that you split functionality into three different classes along these lines:

* Make a base class (BaseX86System) that contains utility functions to set up segments etc. You probably want utility functions to enter protected mode, unit map memory, and to enter long mode here. This class should be purely virtual. * Make a multiboot system class (MultibootX86System) that sets up a 32-bit multi-boot compliant environment.
 * Move the current 64-bit Linux loading to a separate LinuxX86System.

//Andreas

[1] https://github.com/andysan/gem5/commits/hacks

On 10/21/2013 01:18 PM, Christian Menard wrote:
Hi

I wrote some code that initializes a x86 system as if it was booted by a
Multiboot compliant bootloader, but I'm not sure how to put it into gem5
without messing with existing code. A nice way to do it would be to add a new
class MultibootX86System which inherits from X86System. In it's initState()
method it should call X86System::initState() and then do all the Multiboot
specific stuff (this is how it is down with Linux).
But as it appears the code in X86System::initState is already very specific. It
initializes the system in long mode using long mode segments and enables
paging. But the Multiboot specification says that the kernel has to be loaded
in protected mode with paging disabled. The kernel's bootstrapper then
initializes the system as needed by the kernel.
So what would be the best way to do this? As it appears to me I could move the
biggest part of the code to LinuxX86System::initState() or I could try to
parameterize X86System::initState() for instance like this:
X86System::initState(mode, bool pagingEnabled)

Thanks
Christian
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to