[haiku-commits] Re: BRANCH xyzzy-github.x86_64 - src/system/boot/platform/bios_ia32 src/system/kernel/arch/x86_64 headers/private/kernel/arch/x86_64 src/system/kernel/arch/x86

  • From: "Ingo Weinhold" <ingo_weinhold@xxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 27 Jun 2012 21:02:17 +0200

Axel Dörfler wrote:
> On 27.06.2012 16:58, Alex Smith wrote:
> > On 27 June 2012 15:08, Ingo Weinhold <ingo_weinhold@xxxxxx
> > <mailto:ingo_weinhold@xxxxxx>> wrote:
> > > I wonder, if all FixedWidthPointers need to be adjusted, why not
> > > just let the
> > > class do that automatically, i.e. in 64 bit mode just shift the pointer
> > > address on return?
> > I thought it would be better to handle it there rather than having
> > FixedWidthPointer do it because it's specific to x86_64. Perhaps at some
> > point in the future Haiku may get support for a 64-bit only architecture
> > where the bootloader would work completely with 64-bit addresses and
> > such fixups would not be necessary. I suppose that could be detected
> > with some ifdefs or something, though.
> 
> Either that, or have the architecture dependent code set a static offset 
> that applies to all FixedWidthPointers. That would have the surprising 
> element that you'd have to set it twice, in the boot loader, and the 
> kernel, as the static code changes in between, though.

I don't quite understand what you mean. What I had in mind was to change the 
implementation of FixedWidthPointer::Pointer() to something like:

  return (Type*)(addr_t)(fValue + BOOT_LOADER_KERNEL_OFFSET);

Probably similar in Get(), if the method would still be needed at all. 
BOOT_LOADER_KERNEL_OFFSET would resolve to 0 in the boot loader, and to 
(KERNEL_BASE_64BIT - KERNEL_BASE) in the kernel, if there is a bitness change 
between boot loader and kernel. The macro can even be defined generically, like:

#if defined(_BOOT_MODE) && defined(KERNEL_BASE_64BIT)
# define BOOT_LOADER_KERNEL_OFFSET (KERNEL_BASE_64BIT - KERNEL_BASE)
#else
# define BOOT_LOADER_KERNEL_OFFSET 0
#endif

> Besides that, it's almost certain that there will be other 64 bit 
> architectures in the future, indeed :-)

Sure. I expect a 32 bit boot loader and 64 bit kernel to be the exception, 
though.

CU, Ingo

Other related posts: