History log of /haiku/src/system/boot/loader/kernel_args.cpp
Revision Date Author Comments
# 4b5c7fe7 06-Nov-2021 Alexander von Gluck IV <kallisti5@unixzen.com>

system/boot: add optional alignment to kernel_args_malloc

* A few things need alignment, instead of forcing them all
to align themselves, support alignment of the kernel_args
* Default of 1 is "no alignment"

Change-Id: Iff05dcec8adaa963c8444d701464ea11616062f6
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4698
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>


# f1fa58bf 25-Jul-2021 X512 <danger_mail@list.ru>

haiku_loader.efi: update for riscv64

* Added MMU page table generation.
* Added optional FDT device detection and passing to kernel.
* Add platform address translation stubs to bios_ia32
to drop EFI ifdefs

Change-Id: I89257c93c84404fd988f621b29f927ed0df3c3b1
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4304
Reviewed-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>


# 05586741 11-Sep-2020 Alexander von Gluck IV <kallisti5@unixzen.com>

efi: fix pointer width on non-64-bit platforms

Change-Id: I041238af87df3e1e3a967216685413801fd49877
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2450
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>


# 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>


# 82dcc316 22-Oct-2014 Henry Harrington <henry.harrington@gmail.com>

bootloader: Translate kernel args before adding them to kernel_args_range.

Chunks may be physically contiguous, but virtually disjoint. Adding
physical addresses may cause ranges to be merged incorrectly.

Signed-off-by: Jessica Hamilton <jessica.l.hamilton@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).


# 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.


# 93cb9538 20-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Don't store a KMessage in kernel_args for the boot volume, only the buffer address/size.

Pointers in kernel_args are going to be changed to unconditionally use 64-bit
storage (to make kernel_args compatible with both the x86 and x86_64 kernels).
KMessage stores a pointer to its buffer, however since KMessage is used
outside of the boot code it is undesirable to change it to use 64-bit storage
for the pointer as it may add additional overhead on 32-bit builds. Therefore,
only store the buffer address and size and then construct a KMessage from
those in the kernel.


# 8a5b57ee 18-Jul-2010 Axel Dörfler <axeld@pinc-software.de>

* Enlarged chunk size to 64k - this fixes boot over the network.
* Fixed typos.


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


# 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


# 1d578e15 02-Jun-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Fixed more address types related issues. Mostly printf() or comparison
warnings, but also some oversights from earlier changes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37000 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


# 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


# ea2abd11 02-Aug-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Renamed the ROUNDOWN macro to ROUNDDOWN. Also changed the implementation of
ROUNDUP to use '*' and '/' -- the compiler will optimize that for powers of
two anyway and this implementation works for other numbers as well.
* The thread::fault_handler use in C[++] code was broken with gcc 4. At least
when other functions were invoked. Trying to trick the compiler wasn't a
particularly good idea anyway, since the next compiler version could break
the trick again. So the general policy is to use the fault handlers only in
assembly code where we have full control. Changed that for x86 (save for the
vm86 mode, which has a similar mechanism), but not for the other
architectures.
* Introduced fault_handler, fault_handler_stack_pointer, and fault_jump_buffer
fields in the cpu_ent structure, which must be used instead of
thread::fault_handler in the kernel debugger. Consequently user_memcpy() must
not be used in the kernel debugger either. Introduced a debug_memcpy()
instead.
* Introduced debug_call_with_fault_handler() function which calls a function
in a setjmp() and fault handler context. The architecture specific backend
arch_debug_call_with_fault_handler() has only been implemented for x86 yet.
* Introduced debug_is_kernel_memory_accessible() for use in the kernel
debugger. It determines whether a range of memory can be accessed in the
way specified. The architecture specific back end
arch_vm_translation_map_is_kernel_page_accessible() has only been implemented
for x86 yet.
* Added arch_debug_unset_current_thread() (only implemented for x86) to unset
the current thread pointer in the kernel debugger. When entering the kernel
debugger we do some basic sanity checks of the currently set thread structure
and unset it, if they fail. This allows certain commands (most importantly
the stack trace command) to avoid accessing the thread structure.
* x86: When handling a double fault, we do now install a special handler for
page faults. This allows us to gracefully catch faulting commands, even if
e.g. the thread structure is toast.

We are now in much better shape to deal with double faults. Hopefully avoiding
the triple faults that some people have been experiencing on their hardware
and ideally even allowing to use the kernel debugger normally.


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


# 4a47b14e 22-Sep-2008 Axel Dörfler <axeld@pinc-software.de>

* Enlarged a single kernel_args chunk to 32 KB (was 16 KB).
* Reduced the kernel_args array size from 32 to 16 (7 are used on a normal
build).
* Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27690 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


# 35d3421d 17-Nov-2006 Axel Dörfler <axeld@pinc-software.de>

Greatly enlarged the number of possible kernel_arg ranges as we were already
pretty close, and the number of loaded modules have a direct influence on
this (even though we're currently loading the symbols by default).


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


# c83d9dad 28-Dec-2005 Ingo Weinhold <ingo_weinhold@gmx.de>

* platform_allocate_region() has a new boolean parameter "exactAddress"
specifying whether only the exact supplied address is acceptable. If
false, the address is considered a hint only. It will be picked, if
available, otherwise a greater address is tried to be acquired, and
as last resort any address. This feature is only implemented for PPC.
It is needed since the preferred kernel text base address 0x80000000
might not be available (and actually isn't on my Mac mini).
* Fixed a bug in the PPC memory management code:
is_{virtual,physical}_allocated() were checking whether the given
range was completely contained by an existing range instead of
checking for intersection. As a consequence we could (and did) allocate
a range intersecting with already allocated ranges. The kernel segment
thus overwrote OF memory for instance.
* The ELF loader makes sure that it got both text and data segment of
the image to be loaded.

The PPC boot loader successfully loads kernel and modules now. Next
comes the hard part, I'm afraid.



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


# 5af32e75 13-Apr-2005 Axel Dörfler <axeld@pinc-software.de>

Renamed src/kernel to src/system.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12359 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).


# 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.


# 93cb9538be54a2dd4ab6097453ac7d521a9a0b6c 20-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Don't store a KMessage in kernel_args for the boot volume, only the buffer address/size.

Pointers in kernel_args are going to be changed to unconditionally use 64-bit
storage (to make kernel_args compatible with both the x86 and x86_64 kernels).
KMessage stores a pointer to its buffer, however since KMessage is used
outside of the boot code it is undesirable to change it to use 64-bit storage
for the pointer as it may add additional overhead on 32-bit builds. Therefore,
only store the buffer address and size and then construct a KMessage from
those in the kernel.


# 8a5b57ee470ec0e0b5a6b2b7a2579efd8fc0d778 18-Jul-2010 Axel Dörfler <axeld@pinc-software.de>

* Enlarged chunk size to 64k - this fixes boot over the network.
* Fixed typos.


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


# 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


# 1d578e15fe5b5c3ff62866ae81aef529d00d7762 02-Jun-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Fixed more address types related issues. Mostly printf() or comparison
warnings, but also some oversights from earlier changes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37000 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


# 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


# ea2abd110bd6a4518a954477562e2dd94a5fef9d 02-Aug-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Renamed the ROUNDOWN macro to ROUNDDOWN. Also changed the implementation of
ROUNDUP to use '*' and '/' -- the compiler will optimize that for powers of
two anyway and this implementation works for other numbers as well.
* The thread::fault_handler use in C[++] code was broken with gcc 4. At least
when other functions were invoked. Trying to trick the compiler wasn't a
particularly good idea anyway, since the next compiler version could break
the trick again. So the general policy is to use the fault handlers only in
assembly code where we have full control. Changed that for x86 (save for the
vm86 mode, which has a similar mechanism), but not for the other
architectures.
* Introduced fault_handler, fault_handler_stack_pointer, and fault_jump_buffer
fields in the cpu_ent structure, which must be used instead of
thread::fault_handler in the kernel debugger. Consequently user_memcpy() must
not be used in the kernel debugger either. Introduced a debug_memcpy()
instead.
* Introduced debug_call_with_fault_handler() function which calls a function
in a setjmp() and fault handler context. The architecture specific backend
arch_debug_call_with_fault_handler() has only been implemented for x86 yet.
* Introduced debug_is_kernel_memory_accessible() for use in the kernel
debugger. It determines whether a range of memory can be accessed in the
way specified. The architecture specific back end
arch_vm_translation_map_is_kernel_page_accessible() has only been implemented
for x86 yet.
* Added arch_debug_unset_current_thread() (only implemented for x86) to unset
the current thread pointer in the kernel debugger. When entering the kernel
debugger we do some basic sanity checks of the currently set thread structure
and unset it, if they fail. This allows certain commands (most importantly
the stack trace command) to avoid accessing the thread structure.
* x86: When handling a double fault, we do now install a special handler for
page faults. This allows us to gracefully catch faulting commands, even if
e.g. the thread structure is toast.

We are now in much better shape to deal with double faults. Hopefully avoiding
the triple faults that some people have been experiencing on their hardware
and ideally even allowing to use the kernel debugger normally.


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


# 4a47b14ea4354bb62f7bf1d3e83bda0c75cbdd9c 22-Sep-2008 Axel Dörfler <axeld@pinc-software.de>

* Enlarged a single kernel_args chunk to 32 KB (was 16 KB).
* Reduced the kernel_args array size from 32 to 16 (7 are used on a normal
build).
* Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27690 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


# 35d3421dc5886faaf8eeaa7fa888f7d5ed416236 17-Nov-2006 Axel Dörfler <axeld@pinc-software.de>

Greatly enlarged the number of possible kernel_arg ranges as we were already
pretty close, and the number of loaded modules have a direct influence on
this (even though we're currently loading the symbols by default).


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


# c83d9dad1c3cb1b0910f5db8c3f4645d3a206171 28-Dec-2005 Ingo Weinhold <ingo_weinhold@gmx.de>

* platform_allocate_region() has a new boolean parameter "exactAddress"
specifying whether only the exact supplied address is acceptable. If
false, the address is considered a hint only. It will be picked, if
available, otherwise a greater address is tried to be acquired, and
as last resort any address. This feature is only implemented for PPC.
It is needed since the preferred kernel text base address 0x80000000
might not be available (and actually isn't on my Mac mini).
* Fixed a bug in the PPC memory management code:
is_{virtual,physical}_allocated() were checking whether the given
range was completely contained by an existing range instead of
checking for intersection. As a consequence we could (and did) allocate
a range intersecting with already allocated ranges. The kernel segment
thus overwrote OF memory for instance.
* The ELF loader makes sure that it got both text and data segment of
the image to be loaded.

The PPC boot loader successfully loads kernel and modules now. Next
comes the hard part, I'm afraid.



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


# 5af32e752606778be5dd7379f319fe43cb3f6b8c 13-Apr-2005 Axel Dörfler <axeld@pinc-software.de>

Renamed src/kernel to src/system.


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