History log of /haiku/headers/private/kernel/boot/addr_range.h
Revision Date Author Comments
# d750211a 25-May-2020 Michael Lotz <mmlr@mlotz.ch>

bootloader: Split memory map handling into add/remove passes.

The memory map may be unordered and include overlapping ranges. To make
sure that nothing gets included as usable that should actually be
excluded, first scan for all usable ranges and add them, then remove
anything unusable from these ranges again.

To calculate the amount of unusable memory, count the total after the
first pass and then subtract the total after the second. This way, only
unusable ranges that actually overlap physical memory (and therefore
reduce the amount of usable memory) get excluded.

Note that the explicit ignore of the ACPI reclaim memory is subsumed by
the above. We still don't want to add this region to the usable memory
map, as that would allow the kernel to allocate pages into that region,
possibly corrupting ACPI tables before they were used. We also don't
want to add it as an allocated range, as it is not guaranteed that ACPI
is done with the tables before the unused bootloader ranges are freed in
the kernel.

Also add the missing unusable memory amount from ignoring the first MiB
of memory in the EFI loader.

May fix #16056 although it is not certain that graphics memory ranges
are actually included in the memory map.

Change-Id: Ie7991d2c4dcd988edac2995b3a7efc509fa0f4a3
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2814
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 17a33898 21-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Remove phys_addr_range, just use addr_range for both virtual and physical address ranges (as requested by Ingo).


# d8efc6ca 21-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Changes to kernel_args to make it identical for x86 and x86_64.

* Added a FixedWidthPointer template class which uses 64-bit storage to hold
a pointer. This is used in place of raw pointers in kernel_args.
* Added __attribute__((packed)) to kernel_args and all structures contained
within it. This is necessary due to different alignment behaviour for
32-bit and 64-bit compilation with GCC.
* With these changes, kernel_args will now come out the same size for both
the x86_64 kernel and the loader, excluding the preloaded_image structure
which has not yet been changed.
* Tested both an x86 GCC2 and GCC4 build, no problems caused by these changes.


# 192af9e0 20-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Changed addr_range to use uint64.

I've tested this change on x86, causing no issues. I've checked over the code
for all other platforms and made the necessary changes and to the best of my
knowledge they should also still work, but I haven't actually built and
tested them. Once I've completed the kernel_args changes the other platforms
will need testing.


# ff9151d1 23-Jun-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Added ignore_physical_memory_ranges_beyond_4gb() which removes the memory
beyond 4 GB from the physical memory ranges.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37224 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e5846dfa 27-May-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Added shared sort_[physical_]address_ranges() to avoid code duplication. Also
fixes the m68k build.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36951 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d73ddac5 27-May-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Introduced phys_addr_range type, an equivalent to addr_range for physical
address ranges, and a set of support functions working with it.
* Changed the type of the kernel_args physical address range arrays to
phys_addr_range and adjusted the code working with those.
* Removed a bunch of duplicated address range code in the PPC's mmu.cpp.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36947 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 863c623f 05-May-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Added is_address_range_covered(), returning whether the given address range
is fully covered by the ranges in the array.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36631 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f795376e 12-Mar-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

remove_addr_range() is actually called remove_address_range().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35824 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 73a72c42 10-Mar-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Added get_free_address_range() to get a free range in a given range array.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35801 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3e161fb6 07-Jan-2007 Axel Dörfler <axeld@pinc-software.de>

* Instead of its home-brewn solution, mmu_init() now uses the functions declared
in addr_range.h to add ranges to the arrays. This fixes the crashing bug reported
by Larry Baydak.
* Added some more exported functions to kernel_args.cpp (prototypes are in addr_range.h).
* TODO: let the PPC/OpenFirmware implementation use those as well.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19739 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 53ac60d4 19-Oct-2004 Axel Dörfler <axeld@pinc-software.de>

Added the prototype for insert_address_range() that can be used for the
various addr_range arrays in the kernel_args structure.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9412 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ca109e72 31-May-2004 Axel Dörfler <axeld@pinc-software.de>

Moved the addr_range struct out of kernel_args.h to a separate file.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7703 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 17a3389882cee19532ddc99bc1f9aa1efd296749 21-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Remove phys_addr_range, just use addr_range for both virtual and physical address ranges (as requested by Ingo).


# d8efc6caf6babe278c48e8aa3277376fb68ff455 21-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Changes to kernel_args to make it identical for x86 and x86_64.

* Added a FixedWidthPointer template class which uses 64-bit storage to hold
a pointer. This is used in place of raw pointers in kernel_args.
* Added __attribute__((packed)) to kernel_args and all structures contained
within it. This is necessary due to different alignment behaviour for
32-bit and 64-bit compilation with GCC.
* With these changes, kernel_args will now come out the same size for both
the x86_64 kernel and the loader, excluding the preloaded_image structure
which has not yet been changed.
* Tested both an x86 GCC2 and GCC4 build, no problems caused by these changes.


# 192af9e0afd2f3d0cbaf5c935480343a70c8ff53 20-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Changed addr_range to use uint64.

I've tested this change on x86, causing no issues. I've checked over the code
for all other platforms and made the necessary changes and to the best of my
knowledge they should also still work, but I haven't actually built and
tested them. Once I've completed the kernel_args changes the other platforms
will need testing.


# ff9151d11fe8c0e65a343e8fae80690a4b82103f 23-Jun-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Added ignore_physical_memory_ranges_beyond_4gb() which removes the memory
beyond 4 GB from the physical memory ranges.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37224 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e5846dfa616a8ddf80af0c5840991fca4d669031 27-May-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Added shared sort_[physical_]address_ranges() to avoid code duplication. Also
fixes the m68k build.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36951 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d73ddac5bfe4a2d7d1c7f602e475879832fbaa87 27-May-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Introduced phys_addr_range type, an equivalent to addr_range for physical
address ranges, and a set of support functions working with it.
* Changed the type of the kernel_args physical address range arrays to
phys_addr_range and adjusted the code working with those.
* Removed a bunch of duplicated address range code in the PPC's mmu.cpp.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36947 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 863c623f9ab2bb1cb942d4bfc42a9baf12b0e069 05-May-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Added is_address_range_covered(), returning whether the given address range
is fully covered by the ranges in the array.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36631 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f795376ec67748b26b289542f61773c587601618 12-Mar-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

remove_addr_range() is actually called remove_address_range().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35824 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 73a72c42e2be61a6ebd778343b345de3cc65ed00 10-Mar-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Added get_free_address_range() to get a free range in a given range array.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35801 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3e161fb661c1084b1667042e4ca9873e71a87ff6 07-Jan-2007 Axel Dörfler <axeld@pinc-software.de>

* Instead of its home-brewn solution, mmu_init() now uses the functions declared
in addr_range.h to add ranges to the arrays. This fixes the crashing bug reported
by Larry Baydak.
* Added some more exported functions to kernel_args.cpp (prototypes are in addr_range.h).
* TODO: let the PPC/OpenFirmware implementation use those as well.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19739 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 53ac60d4ea9dcc99198ad5a7fdd839c4a1afa0ed 19-Oct-2004 Axel Dörfler <axeld@pinc-software.de>

Added the prototype for insert_address_range() that can be used for the
various addr_range arrays in the kernel_args structure.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9412 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ca109e727d09e0cb0bf25fafa710c3207f11190c 31-May-2004 Axel Dörfler <axeld@pinc-software.de>

Moved the addr_range struct out of kernel_args.h to a separate file.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7703 a95241bf-73f2-0310-859d-f6bbb57e9c96