History log of /haiku/src/system/boot/platform/bios_ia32/mmu.cpp
Revision Date Author Comments
# ef894353 16-Sep-2022 David Karoly <karolyd577@gmail.com>

boot/x86: unify KERNEL_LOAD_ADDRESS for BIOS and EFI

Change-Id: Ia3157c7c0908698da94c1aa85cb6366fb00fb7f1
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5670
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>


# 235aa994 17-Dec-2021 David Karoly <karolyd577@gmail.com>

boot: rework 32-bit/64-bit kernel load base selection

Change-Id: I0aed05c0ef2ff1a162581e4f988bf24ed1e521e0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4816
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@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>


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


# 4e7b05cc 02-Feb-2016 Alexander von Gluck IV <kallisti5@unixzen.com>

platform/bios_ia32: Fix regression introduced in hrev48326

* Reverts f3e381dd
* Details in #12633
* For some unknown reason, this change breaks an Intel Core 2
system from booting (Dell Optiplex 960, E8400)
* If anyone has any ideas on why, let me know :-)


# f3e381dd 15-Nov-2014 Jérôme Duval <jerome.duval@gmail.com>

bios_ia32: for correctness, add clobber memory for asm invlpg.

* generated code is the same for x86_gcc2 and x86_64.
* fixed TRACE build for mmu.cpp.


# 4ce1f197 26-Oct-2014 Ingo Weinhold <ingo_weinhold@gmx.de>

x86 boot loader: check gKernelArgs.arch_args.pgtables overflow


# e9922e77 22-Oct-2014 Michael Lotz <mmlr@mlotz.ch>

haiku_loader: Fix wrong size of gBootGDT on x86_64.

The BOOT_GDT_SEGMENT_COUNT was based on USER_DATA_SEGMENT on both
x86 and x86_64. However, on x86_64 the order of the segments is
different, leading to a too small gBootGDT array. Move the define to
the arch specific headers so they can be setup correctly in either case.
Also add a STATIC_ASSERT() to check that the descriptors fit into the
array.

Pointed out by CID 1210898.


# 527da4ca 27-Jan-2014 Pawel Dziepak <pdziepak@quarnos.org>

x86[_64]: Separate bootloader and kernel GDT and IDT logic

From now on bootloader sets up its own minimal valid GDT and IDT. Then
the kernel replaces them with its own tables.


# 611376fe 16-Dec-2013 Pawel Dziepak <pdziepak@quarnos.org>

x86: Let each CPU have its own GDT


# 32bd2ded 21-Feb-2013 François Revol <revol@free.fr>

bootloader: Fix an overlooked condition in mmu_allocate()

The size variable at this point is actually a page count.
The test should never be true anyway though. Maybe we should use a
pages variable for clarity?


# bc309348 09-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Changes suggested by Ingo: style fix, and a system_time optimization.


# cc248cf2 08-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

A couple of bug fixes.

* mmu_get_virtual_mapping() should check that the page directory entry is
present rather than assuming there's a page table there. This was resulting
in some invalid mappings being created in the 64-bit virtual address space.
* arch_vm_init_end() should clear from KERNEL_LOAD_BASE to virtual_end, not
from KERNEL_BASE. On x86_64 this was causing it to loop through ~512GB of
address space, which obviously was taking quite a while.


# 15feb603 06-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

A few improvements suggested by Ingo.


# 3403f23e 27-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Moved the common parts of arch_cpu.h between x86 and x86_64 to arch/common_x86/cpu.h.


# e5fc2bfc 26-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Implemented long mode setup/switch code, the bootloader can now start the 64-bit kernel!

The setup procedure is fairly simple: create a 64-bit GDT and 64-bit page
tables that include all kernel mappings from the 32-bit address space, but at
the correct 64-bit address, then go through kernel_args and changes all virtual
addresses to 64-bit addresses, and finally switch to long mode and jump to the
kernel.


# 6f6d78e8 25-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Cleaned up ELF64 address handling.

* platform_allocate_elf_region() is removed, it is implemented in platform-
independent code now (ELF*Class::AllocateRegion). For ELF64 it is now
assumed that 64-bit addresses are mapped in the loader's 32-bit address space
as (address - KERNEL_BASE_64BIT + KERNEL_BASE).
* mapped_delta field from preloaded_*_image removed, now handled compile-time
using the ELF*Class::Map method.
* Also link the kernel with -z max-page-size=0x1000, removes the need for
2MB alignment on the data segment (not going to map the kernel with large
pages for the time being).


# 88461898 24-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Handle 64-bit load addresses for ELF64 images in the bootloader.

The ELF loader now uses a new platform function, platform_allocate_elf_region,
which returns 2 addresses: the real load address and an address where the
region is mapped in the loader's address space. All of the ELF loading code
has been changed to access the load region through the mapped address rather
than the addresses contained in the ELF image. The ELF64 version of
platform_allocate_elf_region on x86 uses the existing MMU code, which maps
everything at 0x80000000, but returns the correct 64-bit address. The long
mode switch code will just set up the 64-bit address space with everything
remapped at the correct address.


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


# d230708b 05-Sep-2011 Philippe Houdoin <philippe.houdoin@gmail.com>

* Expand kernel_args addresses ranges size, 8 is somewhat too small, leading
to a panic at boot.
* Make the panic message more explicit when there is no more room left.

This should hopefully fix #7869.


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


# b23ab34f 12-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

I accidentally committed r42122 and r42123 to the signals branch. Merged into
trunk. The interesting part of r42122 was already fixed in the trunk, though.


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


# 2e8aa19c 10-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

* The boot loader does now set up an IDT that allows it to catch processor
exceptions (page faults and the like). The handler dumps possibly interesting
information (registers, a (numerical) stack trace) to the serial output, and,
if possible, also to the screen. That should help debugging boot loader
crashes.
* For the IDT the boot loader sets up for the kernel the descriptors are set up
the same way, so until the kernel initializes the IDT itself (arch_init()) the
facility is still in place and can thus catch very early kernel boot crashes.
Unfortunately the on-screen output doesn't seem to work anymore at that point,
so the output only goes to the serial port...
* ... and to the debug syslog -- dprintf() does now append it there after
debug_cleanup() has been called. Seems to work fine in qemu, but when I tested
it on real hardware the debug syslog was gone.


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


# 5e36c12a 11-May-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

mmu_allocate_physical(): The wrong base argument was passed to
get_free_physical_address_range(). Fixes the debug syslog feature.


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


# c907ee75 26-Dec-2010 Michael Lotz <mmlr@mlotz.ch>

Undo the part of r34947 that changed the re-use check. It wasn't broken, since
the address variable is incremented in the loop above and at the end will be
equal to sNextVirtualAddress if the address space can be reused. Fixes early
boot resets due to wrongly reused virtual addresses (and them being freed while
still in use by the original user). Fixes #7026, thanks to Urias for testing.


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


# 84e9db7f 12-Jun-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

x86 mmu_init(): Sum up the physical memory we ignore for whatever reason --
stored in kernel_args::ignored_physical_memory.


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


# 977ffe52 11-Jun-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

No longer ignore the physical memory beyond 4 GB, if we have a 64 bit
phys_addr_t. IOW, if PAE is enabled, that memory should be put to use now.
Apparently we report an incorrect amount of total memory (also counting
memory gaps), which also suggests that we need another method to manage the
vm_page structures (currently a huge array with indexes proportional to
physical page addresses, i.e. wasting memory for the gaps).


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


# 8588e7fc 05-May-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Fixed broken mmu_allocate_physical():
* Now it checks whether the given physical range exists at all.
* Not only check whether any range of the given size is free, but also check
whether the given range is free.
* B_BAD_VALUE is not a particularly good return value for a function supposed
to return a bool

Fixes #5911. With only 64 MB RAM the usual debug syslog buffer location may
be outside the actually existing physical memory.


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


# c4697c01 03-May-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Patch by Andreas Faerber: Implemented fallbacks (e801 and 88) to get the
memory map in case e820 is not supported by the BIOS.


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


# bfb3b117 01-May-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

mmu_init(): In case we couldn't get a memory map from the BIOS the fixed
memory setup was 1 MiB larger than advertised.


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


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

Ignore physical memory ranges that are smaller than 64 KB. Those don't
contribute significantly to the usable memory, but possibly make the MTRR
setup impossible. Might improve #5550.


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


# 90bf6bef 11-Mar-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Added mmu_allocate_physical(), which allocates a specified physical memory
range.


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


# 5d1f3d53 10-Mar-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

get_next_physical_address(): Directly update the
gKernelArgs.physical_allocated_range array. This way it is always up to date
and we don't need to fix it in mmu_init_for_kernel().


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


# 6dacf050 03-Mar-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Ignore physical memory below 1 MB. This is a work-around for buggy BIOSes
providing incorrect memory types. It doesn't cost us anything, since the
kernel reserves all but the unusable range later anyway. Should fix #1925.


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


# d40a9355 02-Mar-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Boot loader (x86 mmu.cpp):
* Made the page table allocation more flexible. Got rid of sMaxVirtualAddress
and added new virtual_end address to the architecture specific kernel args.
* Increased the virtual space we reserve for the kernel to 16 MB. That
should suffice for quite a while. The previous 2 MB were too tight when
building the kernel with debug info.
* mmu_init(): The way we were translating the BIOS' extended memory map to
our physical ranges arrays was broken. Small gaps between usable memory
ranges would be ignored and instead marked allocated. This worked fine for
the boot loader and during the early kernel initialization, but after the
VM has been fully set up it frees all physical ranges that have not been
claimed otherwise. So those ranges could be entered into the free pages
list and would be used later. This could possibly cause all kinds of weird
problems, probably including ACPI issues. Now we add only the actually
usable ranges to our list.

Kernel:
* vm_page_init(): The pages of the ranges between the usable physical memory
ranges are now marked PAGE_STATE_UNUSED, the allocated ranges
PAGE_STATE_WIRED.
* unmap_and_free_physical_pages(): Don't free pages marked as unused.


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


# e82b595a 28-Feb-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* TRACE(()) -> TRACE()
* Fixed warnings with tracing enabled.
* Improved some debug output.


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


# 7f051b57 08-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Changed/fixed mmu_map_physical_memory() semantics: It does now always
allocate all pages the given range intersects with. When not page aligned
it could fail to allocate the last page.
* mmu_free():
- Adjusted semantics to be compatible with mmu_map_physical_memory().
- The validity check was broken, because page number and addresses were
mixed, and because KERNEL_BASE + kMaxKernelSize doesn't mark the end of
the allocated virtual ranges.
- The final check against sNextVirtualAddress was broken.


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


# 9592b510 02-Jan-2010 Stephan Aßmus <superstippi@gmx.de>

Patch by Andreas Faerber:
* Fixed typo in panic() message.

Thanks!


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


# 57f2b5a0 05-Aug-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Changed the meaning of the {KERNEL,USER}_STACK_SIZE macros to not
include the guard pages. Adjusted the kernel and boot loader code
accordingly -- the guard pages size is added/not removed respectively.
The stack size passed to _kern_spawn_thread() is now the actually usable
size, and it is no longer possible to specify a size smaller than or
equal to the guard pages size.
* vm_create_anonymous_area(): Precommit two pages maximum -- a stack with
only one page usable size obviously doesn't need two pages.


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


# ca978b6e 03-May-2008 Marcus Overhagen <marcusoverhagen@gmail.com>

make memory map printing independant of other mmu debug output


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


# 355914a2 05-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Enlarged maximum kernel size to 2 MB - this is the code the boot loader's
MMU code reserves for the kernel, and we hit that limit recently with the
addition of the boot splash code.
* This fixes the boot crash as triggered by Stippi's recent changes to the
splash image.
* Cleanup (doxygen comments, line length).


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


# 37502d0f 26-Dec-2007 Marcus Overhagen <marcusoverhagen@gmail.com>

added more debug output


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


# 3ae3b04b 26-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

* The boot loader (bios_ia32 only) now duplicates everything that goes to the
serial output, and puts it into the new kernel_args::debug_output field.
* syslog_init() will now check if there is anything in kernel_args::debug_output
and will put that into the syslog buffer.
* dump_block() now also prints an offset.
* Fixed warning in mmu.cpp.


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


# 018cf363 14-Jul-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Clear out/initialize IDT and GDT using their virtual addresses after
they have been mapped. The previous method relied on their physical
pages living in the identity mapped region, which they wouldn't, when
the boot loader allocated enough memory before.


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


# 32e2879f 08-Jan-2007 Axel Dörfler <axeld@pinc-software.de>

We now ignore all memory beyond the 4 GB barrier in 32-bit mode.


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


# 97ad772a 06-Jan-2007 Axel Dörfler <axeld@pinc-software.de>

* Moved PXE page directory and page tables below the 1 MB limit.
* Minor cleanup.


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


# 326862c2 25-Oct-2006 Marcus Overhagen <marcusoverhagen@gmail.com>

removed usage of the 0x8d000 to 0x9ffff memory range, as its needed by PXE UNDI.


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


# 7a09488d 24-Oct-2005 Axel Dörfler <axeld@pinc-software.de>

Could overwrite the memory that the SMP code is using for the trampoline
code/stack with page tables.


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


# ceb76936 14-Oct-2005 Axel Dörfler <axeld@pinc-software.de>

Got rid of the now unused sPageTable variable.


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


# 4cc5dde4 13-Oct-2005 Axel Dörfler <axeld@pinc-software.de>

Updated memory layout comment.


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


# 0eecdd83 13-Oct-2005 Axel Dörfler <axeld@pinc-software.de>

Made the page table allocation/filling mechanism a bit more flexible and less error prone.
Also, freeing regions is now supported (but still only the last allocated region can be
freed, as that's currently good enough).


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


# f3e381dd0cf6a08c2e20c8c24f5ff8b78ac04032 15-Nov-2014 Jérôme Duval <jerome.duval@gmail.com>

bios_ia32: for correctness, add clobber memory for asm invlpg.

* generated code is the same for x86_gcc2 and x86_64.
* fixed TRACE build for mmu.cpp.


# 4ce1f197fa00403fd786e391ae0c3ed71d9c5954 26-Oct-2014 Ingo Weinhold <ingo_weinhold@gmx.de>

x86 boot loader: check gKernelArgs.arch_args.pgtables overflow


# e9922e775f2fbbffa4847ae797e5349542948f25 22-Oct-2014 Michael Lotz <mmlr@mlotz.ch>

haiku_loader: Fix wrong size of gBootGDT on x86_64.

The BOOT_GDT_SEGMENT_COUNT was based on USER_DATA_SEGMENT on both
x86 and x86_64. However, on x86_64 the order of the segments is
different, leading to a too small gBootGDT array. Move the define to
the arch specific headers so they can be setup correctly in either case.
Also add a STATIC_ASSERT() to check that the descriptors fit into the
array.

Pointed out by CID 1210898.


# 527da4ca8a4c008b58da456c01a49dcf16a98fbc 27-Jan-2014 Pawel Dziepak <pdziepak@quarnos.org>

x86[_64]: Separate bootloader and kernel GDT and IDT logic

From now on bootloader sets up its own minimal valid GDT and IDT. Then
the kernel replaces them with its own tables.


# 611376fef7e00967fb65342802ba668a807348d5 16-Dec-2013 Pawel Dziepak <pdziepak@quarnos.org>

x86: Let each CPU have its own GDT


# 32bd2dedd92c994efb538bec7fbc31f5dd5b6122 21-Feb-2013 François Revol <revol@free.fr>

bootloader: Fix an overlooked condition in mmu_allocate()

The size variable at this point is actually a page count.
The test should never be true anyway though. Maybe we should use a
pages variable for clarity?


# bc3093488f72315d8474d45b3dfe34cdc15ef4d6 09-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Changes suggested by Ingo: style fix, and a system_time optimization.


# cc248cf2b37b96f8f86d652e0121be105b23d192 08-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

A couple of bug fixes.

* mmu_get_virtual_mapping() should check that the page directory entry is
present rather than assuming there's a page table there. This was resulting
in some invalid mappings being created in the 64-bit virtual address space.
* arch_vm_init_end() should clear from KERNEL_LOAD_BASE to virtual_end, not
from KERNEL_BASE. On x86_64 this was causing it to loop through ~512GB of
address space, which obviously was taking quite a while.


# 15feb60325be086823e80a3468f7aab2bfbc9f7d 06-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

A few improvements suggested by Ingo.


# 3403f23e81b7bd6e50c459d01ae7238c1f3f5984 27-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Moved the common parts of arch_cpu.h between x86 and x86_64 to arch/common_x86/cpu.h.


# e5fc2bfcab8c15a3ff7d33c358f9aa82ed73c823 26-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Implemented long mode setup/switch code, the bootloader can now start the 64-bit kernel!

The setup procedure is fairly simple: create a 64-bit GDT and 64-bit page
tables that include all kernel mappings from the 32-bit address space, but at
the correct 64-bit address, then go through kernel_args and changes all virtual
addresses to 64-bit addresses, and finally switch to long mode and jump to the
kernel.


# 6f6d78e877c1a485d98de60395854a6d6de61c0d 25-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Cleaned up ELF64 address handling.

* platform_allocate_elf_region() is removed, it is implemented in platform-
independent code now (ELF*Class::AllocateRegion). For ELF64 it is now
assumed that 64-bit addresses are mapped in the loader's 32-bit address space
as (address - KERNEL_BASE_64BIT + KERNEL_BASE).
* mapped_delta field from preloaded_*_image removed, now handled compile-time
using the ELF*Class::Map method.
* Also link the kernel with -z max-page-size=0x1000, removes the need for
2MB alignment on the data segment (not going to map the kernel with large
pages for the time being).


# 8846189866301c85683151a54ec88e809333ca7a 24-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Handle 64-bit load addresses for ELF64 images in the bootloader.

The ELF loader now uses a new platform function, platform_allocate_elf_region,
which returns 2 addresses: the real load address and an address where the
region is mapped in the loader's address space. All of the ELF loading code
has been changed to access the load region through the mapped address rather
than the addresses contained in the ELF image. The ELF64 version of
platform_allocate_elf_region on x86 uses the existing MMU code, which maps
everything at 0x80000000, but returns the correct 64-bit address. The long
mode switch code will just set up the 64-bit address space with everything
remapped at the correct address.


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


# d230708bcfbe50b9fb09fb510b96586e1d7f8046 05-Sep-2011 Philippe Houdoin <philippe.houdoin@gmail.com>

* Expand kernel_args addresses ranges size, 8 is somewhat too small, leading
to a panic at boot.
* Make the panic message more explicit when there is no more room left.

This should hopefully fix #7869.


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


# b23ab34f668e68368a07895db422c6bfca099b88 12-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

I accidentally committed r42122 and r42123 to the signals branch. Merged into
trunk. The interesting part of r42122 was already fixed in the trunk, though.


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


# 2e8aa19c638e27939fd6aaa4e2570b2411e15368 10-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

* The boot loader does now set up an IDT that allows it to catch processor
exceptions (page faults and the like). The handler dumps possibly interesting
information (registers, a (numerical) stack trace) to the serial output, and,
if possible, also to the screen. That should help debugging boot loader
crashes.
* For the IDT the boot loader sets up for the kernel the descriptors are set up
the same way, so until the kernel initializes the IDT itself (arch_init()) the
facility is still in place and can thus catch very early kernel boot crashes.
Unfortunately the on-screen output doesn't seem to work anymore at that point,
so the output only goes to the serial port...
* ... and to the debug syslog -- dprintf() does now append it there after
debug_cleanup() has been called. Seems to work fine in qemu, but when I tested
it on real hardware the debug syslog was gone.


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


# 5e36c12a42e9910734f26acbe5aaccb0776f8478 11-May-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

mmu_allocate_physical(): The wrong base argument was passed to
get_free_physical_address_range(). Fixes the debug syslog feature.


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


# c907ee755ae8a94bee7f5f8da6c1210a0f1957ca 26-Dec-2010 Michael Lotz <mmlr@mlotz.ch>

Undo the part of r34947 that changed the re-use check. It wasn't broken, since
the address variable is incremented in the loop above and at the end will be
equal to sNextVirtualAddress if the address space can be reused. Fixes early
boot resets due to wrongly reused virtual addresses (and them being freed while
still in use by the original user). Fixes #7026, thanks to Urias for testing.


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


# 84e9db7fb7fe41dca80582ce8ed5e676bb51ceb4 12-Jun-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

x86 mmu_init(): Sum up the physical memory we ignore for whatever reason --
stored in kernel_args::ignored_physical_memory.


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


# 977ffe5233849151bb042889780cc69babd7e899 11-Jun-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

No longer ignore the physical memory beyond 4 GB, if we have a 64 bit
phys_addr_t. IOW, if PAE is enabled, that memory should be put to use now.
Apparently we report an incorrect amount of total memory (also counting
memory gaps), which also suggests that we need another method to manage the
vm_page structures (currently a huge array with indexes proportional to
physical page addresses, i.e. wasting memory for the gaps).


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


# 8588e7fc6fbde8afd9d81ae3dca6a19d20fdb9dd 05-May-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Fixed broken mmu_allocate_physical():
* Now it checks whether the given physical range exists at all.
* Not only check whether any range of the given size is free, but also check
whether the given range is free.
* B_BAD_VALUE is not a particularly good return value for a function supposed
to return a bool

Fixes #5911. With only 64 MB RAM the usual debug syslog buffer location may
be outside the actually existing physical memory.


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


# c4697c01a93ee3e61e9edd4f6358199835c2a762 03-May-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Patch by Andreas Faerber: Implemented fallbacks (e801 and 88) to get the
memory map in case e820 is not supported by the BIOS.


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


# bfb3b117eb9c6da0cc2e712cab1321d96f70f9e1 01-May-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

mmu_init(): In case we couldn't get a memory map from the BIOS the fixed
memory setup was 1 MiB larger than advertised.


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


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

Ignore physical memory ranges that are smaller than 64 KB. Those don't
contribute significantly to the usable memory, but possibly make the MTRR
setup impossible. Might improve #5550.


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


# 90bf6bef34e10276c20265c387a2a5f5507a157a 11-Mar-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Added mmu_allocate_physical(), which allocates a specified physical memory
range.


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


# 5d1f3d53e2e05d27b8ed9af6daf5de888b7b25f0 10-Mar-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

get_next_physical_address(): Directly update the
gKernelArgs.physical_allocated_range array. This way it is always up to date
and we don't need to fix it in mmu_init_for_kernel().


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


# 6dacf0502db8609688097742f5de6454f16d1f45 03-Mar-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Ignore physical memory below 1 MB. This is a work-around for buggy BIOSes
providing incorrect memory types. It doesn't cost us anything, since the
kernel reserves all but the unusable range later anyway. Should fix #1925.


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


# d40a9355605dff41924273711f9dc9df6da496d2 02-Mar-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Boot loader (x86 mmu.cpp):
* Made the page table allocation more flexible. Got rid of sMaxVirtualAddress
and added new virtual_end address to the architecture specific kernel args.
* Increased the virtual space we reserve for the kernel to 16 MB. That
should suffice for quite a while. The previous 2 MB were too tight when
building the kernel with debug info.
* mmu_init(): The way we were translating the BIOS' extended memory map to
our physical ranges arrays was broken. Small gaps between usable memory
ranges would be ignored and instead marked allocated. This worked fine for
the boot loader and during the early kernel initialization, but after the
VM has been fully set up it frees all physical ranges that have not been
claimed otherwise. So those ranges could be entered into the free pages
list and would be used later. This could possibly cause all kinds of weird
problems, probably including ACPI issues. Now we add only the actually
usable ranges to our list.

Kernel:
* vm_page_init(): The pages of the ranges between the usable physical memory
ranges are now marked PAGE_STATE_UNUSED, the allocated ranges
PAGE_STATE_WIRED.
* unmap_and_free_physical_pages(): Don't free pages marked as unused.


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


# e82b595ac6cf49027afef387f1e13a64fb2a3a87 28-Feb-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* TRACE(()) -> TRACE()
* Fixed warnings with tracing enabled.
* Improved some debug output.


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


# 7f051b57101beeb657ff4a3578b9423369861772 08-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Changed/fixed mmu_map_physical_memory() semantics: It does now always
allocate all pages the given range intersects with. When not page aligned
it could fail to allocate the last page.
* mmu_free():
- Adjusted semantics to be compatible with mmu_map_physical_memory().
- The validity check was broken, because page number and addresses were
mixed, and because KERNEL_BASE + kMaxKernelSize doesn't mark the end of
the allocated virtual ranges.
- The final check against sNextVirtualAddress was broken.


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


# 9592b510c5f9c5647f7472357449a398d3db90c1 02-Jan-2010 Stephan Aßmus <superstippi@gmx.de>

Patch by Andreas Faerber:
* Fixed typo in panic() message.

Thanks!


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


# 57f2b5a0137be29081ab719ae33ebabddc95b78b 05-Aug-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Changed the meaning of the {KERNEL,USER}_STACK_SIZE macros to not
include the guard pages. Adjusted the kernel and boot loader code
accordingly -- the guard pages size is added/not removed respectively.
The stack size passed to _kern_spawn_thread() is now the actually usable
size, and it is no longer possible to specify a size smaller than or
equal to the guard pages size.
* vm_create_anonymous_area(): Precommit two pages maximum -- a stack with
only one page usable size obviously doesn't need two pages.


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


# ca978b6ed8de1199ca376bf3f007d30723b5468f 03-May-2008 Marcus Overhagen <marcusoverhagen@gmail.com>

make memory map printing independant of other mmu debug output


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


# 355914a2cd138102ed9f7089f9ef98657cc57a46 05-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Enlarged maximum kernel size to 2 MB - this is the code the boot loader's
MMU code reserves for the kernel, and we hit that limit recently with the
addition of the boot splash code.
* This fixes the boot crash as triggered by Stippi's recent changes to the
splash image.
* Cleanup (doxygen comments, line length).


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


# 37502d0f9f15de87cacbf8a521408fdb7ead251b 26-Dec-2007 Marcus Overhagen <marcusoverhagen@gmail.com>

added more debug output


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


# 3ae3b04bce8c481442bd3ff42c6d57d1417374c6 26-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

* The boot loader (bios_ia32 only) now duplicates everything that goes to the
serial output, and puts it into the new kernel_args::debug_output field.
* syslog_init() will now check if there is anything in kernel_args::debug_output
and will put that into the syslog buffer.
* dump_block() now also prints an offset.
* Fixed warning in mmu.cpp.


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


# 018cf363963ed34781cb49b261f14664eae7b38a 14-Jul-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Clear out/initialize IDT and GDT using their virtual addresses after
they have been mapped. The previous method relied on their physical
pages living in the identity mapped region, which they wouldn't, when
the boot loader allocated enough memory before.


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


# 32e2879f100dfefd143781b9f40db126ade38be0 08-Jan-2007 Axel Dörfler <axeld@pinc-software.de>

We now ignore all memory beyond the 4 GB barrier in 32-bit mode.


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


# 97ad772ada4480f710ffafee79b0f9c1f7e3c61d 06-Jan-2007 Axel Dörfler <axeld@pinc-software.de>

* Moved PXE page directory and page tables below the 1 MB limit.
* Minor cleanup.


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


# 326862c203a6f923e515743732104df956b95907 25-Oct-2006 Marcus Overhagen <marcusoverhagen@gmail.com>

removed usage of the 0x8d000 to 0x9ffff memory range, as its needed by PXE UNDI.


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


# 7a09488d8e0584dd21e105e6ffb2c4906126e36c 24-Oct-2005 Axel Dörfler <axeld@pinc-software.de>

Could overwrite the memory that the SMP code is using for the trampoline
code/stack with page tables.


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


# ceb769360d99ddd6a749f1f73714c2688bec840b 14-Oct-2005 Axel Dörfler <axeld@pinc-software.de>

Got rid of the now unused sPageTable variable.


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


# 4cc5dde4a73e81b4d1e13300faa6d32a4388284e 13-Oct-2005 Axel Dörfler <axeld@pinc-software.de>

Updated memory layout comment.


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


# 0eecdd833446324f3c9931d04ef0da2f02e94ac1 13-Oct-2005 Axel Dörfler <axeld@pinc-software.de>

Made the page table allocation/filling mechanism a bit more flexible and less error prone.
Also, freeing regions is now supported (but still only the last allocated region can be
freed, as that's currently good enough).


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