History log of /haiku/src/system/boot/platform/openfirmware/arch/ppc/mmu.cpp
Revision Date Author Comments
# 56f9c760 24-May-2019 PulkoMandy <pulkomandy@pulkomandy.tk>

sparc: boot mmu support

Get enough of the mmu working to be able to allocate memory.

Unlike on PowerPC, we get both address and size as 64bit values. So
adjust of_region to allow this.

Also unlike the PPC port, we do not drive the hardware directly, instead we
rely on the openboot primitives to manage the translation table. This
allows staying independant of the hardware, which is a good idea at
least for the bootloader (we can do actual hardware things in the
kernel)

Change-Id: Ifa57619d3a09b8f707e1f8640d8b4f71bb717e2a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1482
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>


# 09b40d16 03-Dec-2019 Ynoga <ynoga@protonmail.com>

ppc: Minor tweaks to get the arch compile again (WIP)

- Factor in types changes (introduction of intptr_t)
- Align JamFiles syntax with in progress architectures (arm/sparc)
- Xorriso doesn't support much of the mkisofs options (anymore ?)
- (After a correct bootstrap) one should be able to build @minimum-raw and haiku-boot-cd again
Change-Id: I4f779ad8f2210389fa9b7f7c0a98c3652a64c257
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1983
Reviewed-by: François Revol <revol@free.fr>


# 3b60bc6b 13-Mar-2018 Alexander von Gluck IV <kallisti5@unixzen.com>

openfirmware/ppc: A few minor fixes and extra debugging

* Show old page table location and provide more feedback
* 16 int32 * 0x10000000 > sizeof(int32), fix to uint32

Change-Id: Ib68c34f5d3c6bfa1da53241e6586c07e4e494750


# 6b87898a 22-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Code style fixes.


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


# 40a5a5a0 26-Jul-2011 Alexander von Gluck IV <kallisti5@unixzen.com>

* Rename of_region type template as per Axel
* Rename of_support.h/cpp back to support.cpp as per Axel


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


# bf0e980d 26-Jul-2011 Alexander von Gluck IV <kallisti5@unixzen.com>

* Fix a few style issues as per Axel
* Rename a few variables to make more sense
* OF_FAILED is a signed int.. fix return of of_address_cells
* OF_FAILED is a signed int.. fix return of of_size_cells


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


# d24ddec4 25-Jul-2011 Alexander von Gluck IV <kallisti5@unixzen.com>

* Move platform support.cpp into less generic of_support.cpp
* Add header file to support of_support.cpp
* Add support functions to obtain address and size cell lengths
* Small style cleanups
* Add support for G5 PowerPC cpus...
* Refactor memory region code to be aware of 64-bit OF addresses.
As-is the boot loader wouldn't start on G5 systems because
OpenFirmware memory base addresses are stored as two 32-bit
unsigned int 'cells' vs one 32-bit unsigned int 'cell' on G3/G4.
I removed the static struct and replaced it with a template
and pass uint32 or uint64 depending on the address cell size.
Thanks for the idea DeadYak!


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


# a1a978ff 20-Jul-2011 Alexander von Gluck IV <kallisti5@unixzen.com>

* Clean up translation debug output
* Few small style cleanups
* No functional change


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


# 2e3b6c53 18-Jul-2011 Alexander von Gluck IV <kallisti5@unixzen.com>

* Clean up debugging of PowerPC mmu code to be consistent
* Clean up messge and error text
* Begin use B_PRI* macros


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


# cb49ed72 14-Nov-2010 Andreas Färber <andreas.faerber@web.de>

boot_loader_openfirmware: Fix trace output

Update the variable name.


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


# 884432c2 24-Aug-2010 Andreas Färber <andreas.faerber@web.de>

boot_loader_openfirmware: Fix style issues

Adjust initializers.
Respect 80-column limit and adjust copyright notice.
Reorder some header groups. Enforce line spacing.

No functional changes.


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


# 31bce167 20-Aug-2010 Andreas Färber <andreas.faerber@web.de>

ppc: Keep memory mappings set up by OpenFirmware

Revert r36886 and fix compilation of insert_virtual_range_to_keep().
The use of void* vs. addr_t matches the surrounding boot loader code
but should probably be revised in favour of addr_t.

create_area() in the kernel wrongly assumed a RAM-backed address range,
which was destined to fail since ranges below the kernel address space
were ignored anyway. Use vm_map_physical_memory() instead.

This fixes a hang once the frame buffer and other resources used by OF
get unmapped. Closes ticket #5193 again.


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


# 3a5655a5 21-May-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Reverted r34863.
* Don't keep any memory mappings from the OF for the time being. We can't
keep mappings < 2 GB, since those aren't in the kernel address space and
we don't handle memory mapped registers or the like correctly either.
Ticket #5193.


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


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

Patch by Andreas Faerber with small changes by myself:
* Skip mappings to non-physical memory in the PPC MMU code. Gets the
PPC kernel booting a little further.

Thanks! Fixes ticket #5193.


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


# 4b8d0e68 03-Aug-2009 François Revol <revol@free.fr>

Some ppc fixes for #4115, patch by kallisti5 (without the #ifdef _BOOT_MODE):
- stubbed out arch_cpu_init_percpu(),
- make atomic ops declarations extern "C",
- move calls to [i]sync inside the asm code that needs it.


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


# bdee97bc 23-Jul-2009 Axel Dörfler <axeld@pinc-software.de>

* Applied slightly changed patch by Alexander von Gluck.
* Minor cleanup.


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


# 3b148e53 09-Nov-2008 François Revol <revol@free.fr>

This gets the bootloader further on, but it still breaks... OpenHackware seems worse than Pegasos OF :^)


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


# a268fbfe 25-Jan-2006 Axel Dörfler <axeld@pinc-software.de>

Added some hacks to get the boot loader to work on the Pegasos.
Doesn't come far yet, though.


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


# a1bcf2c8 01-Jan-2006 Ingo Weinhold <ingo_weinhold@gmx.de>

* The OF memory management callback is now set in arch_mmu_init().
According to the spec we need to set it before taking over the MMU,
but we can't call it before arch_mmu_init(), since we need the OF
to allocate the page table. So we do it after we have allocated
the new page table.
* Added PPC specific kernel_args: The virtual address ranges we want
to keep in the kernel. We fill that in with the translations we
find when initializing the MMU stuff. We remove the memory the
boot loader occupies from those. Besides the stack for the boot
loader only the OF stuff remains.
* arch_mmu_allocate() now starts to search at KERNEL_BASE for a free
virtual address when no particular address is requested. This saves
us further trouble in the kernel, since those allocations would
need to be remapped otherwise.


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


# 4c1fca76 30-Dec-2005 Ingo Weinhold <ingo_weinhold@gmx.de>

Maybe I miss something, but I don't see the reason for the PPC
arch_mmu_allocate() to set the "cache inhibited" flag. One negative
effect was that for such memory the lwarx instruction (used by the
atomic_*() functions) does "... cause the system data storage error
handle to be invoked...", as the architecture specification puts it.


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


# 957a1b17 30-Dec-2005 Ingo Weinhold <ingo_weinhold@gmx.de>

* Introduced new build system variables
{HAIKU,HOST,TARGET}_KERNEL_PIC_{CC,LINK}FLAGS which define the
compiler/linker flags specifying the kind of position independence
the kernel shall have. For x86 we had and still have -fno-pic, but the
PPC kernel has -fPIE (position independent executable) now, as we
need to relocate it.
* The boot loader relocates the kernel now. Mostly copied the relocation
code from the kernel ELF loader. Almost completely rewrote the PPC
specific relocation code, though. It's more correct and more complete now
(some things are still missing though).
* Added boot platform awareness to the kernel. Moved the generic
Open Firmware code (openfirmware.c/h) from the boot loader to the kernel.
* The kernel PPC serial debug output is sent to the console for the time
being.
* The PPC boot loader counts the CPUs now and allocates the kernel stacks
(made OF device iteration a bit more flexible on the way -- the search
can be restricted to subtree). Furthermore we really enter the kernel...
(Yay! :-) ... and crash in the first dprintf() (in the atomic_set()
called by acquire_spinlock()). kprintf() works, though.



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


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

arch_mmu_allocate() translated the protection flags incorrectly
(B_WRITE_AREA to read-only).


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


# 22a65222 27-Dec-2005 Ingo Weinhold <ingo_weinhold@gmx.de>

* Renamed of_call_method() to of_call_client_function() and added
of_call_method() which is actually an implementation of the
"call-method" client function.
* of_interpret() announced one less return value than actually needed.
Seemed to work anyway, though.


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


# 7a3fa7d3 19-Dec-2005 Axel Dörfler <axeld@pinc-software.de>

* Followed Ingo's suggestion and removed the now superfluous "length" correction
in ConsoleHandle::WriteAt().
* Updated license.


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


# 6b87898af5966561770a79a17f13415c47c38aa0 22-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Code style fixes.


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


# 40a5a5a0ac071efdbd7cab48c642fc805fc420f4 26-Jul-2011 Alexander von Gluck IV <kallisti5@unixzen.com>

* Rename of_region type template as per Axel
* Rename of_support.h/cpp back to support.cpp as per Axel


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


# bf0e980dc49bf12b69fcb31f7183c45f81134bcd 26-Jul-2011 Alexander von Gluck IV <kallisti5@unixzen.com>

* Fix a few style issues as per Axel
* Rename a few variables to make more sense
* OF_FAILED is a signed int.. fix return of of_address_cells
* OF_FAILED is a signed int.. fix return of of_size_cells


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


# d24ddec4e4e5bb2fd466c1b3db7a4fa836fbd4ff 25-Jul-2011 Alexander von Gluck IV <kallisti5@unixzen.com>

* Move platform support.cpp into less generic of_support.cpp
* Add header file to support of_support.cpp
* Add support functions to obtain address and size cell lengths
* Small style cleanups
* Add support for G5 PowerPC cpus...
* Refactor memory region code to be aware of 64-bit OF addresses.
As-is the boot loader wouldn't start on G5 systems because
OpenFirmware memory base addresses are stored as two 32-bit
unsigned int 'cells' vs one 32-bit unsigned int 'cell' on G3/G4.
I removed the static struct and replaced it with a template
and pass uint32 or uint64 depending on the address cell size.
Thanks for the idea DeadYak!


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


# a1a978ff21c8d02ed202833e0fabd33b2f2d3254 20-Jul-2011 Alexander von Gluck IV <kallisti5@unixzen.com>

* Clean up translation debug output
* Few small style cleanups
* No functional change


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


# 2e3b6c53ad321a1d7dc38baab7d6a1b45c63cff9 18-Jul-2011 Alexander von Gluck IV <kallisti5@unixzen.com>

* Clean up debugging of PowerPC mmu code to be consistent
* Clean up messge and error text
* Begin use B_PRI* macros


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


# cb49ed72a6144002fcbc491038c1bb64c751fd11 14-Nov-2010 Andreas Färber <andreas.faerber@web.de>

boot_loader_openfirmware: Fix trace output

Update the variable name.


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


# 884432c2da9fbeb1f5e4e4a48ce271b8ad7ee204 24-Aug-2010 Andreas Färber <andreas.faerber@web.de>

boot_loader_openfirmware: Fix style issues

Adjust initializers.
Respect 80-column limit and adjust copyright notice.
Reorder some header groups. Enforce line spacing.

No functional changes.


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


# 31bce16715f6e0b0b60ff0f67b8ccc734f050933 20-Aug-2010 Andreas Färber <andreas.faerber@web.de>

ppc: Keep memory mappings set up by OpenFirmware

Revert r36886 and fix compilation of insert_virtual_range_to_keep().
The use of void* vs. addr_t matches the surrounding boot loader code
but should probably be revised in favour of addr_t.

create_area() in the kernel wrongly assumed a RAM-backed address range,
which was destined to fail since ranges below the kernel address space
were ignored anyway. Use vm_map_physical_memory() instead.

This fixes a hang once the frame buffer and other resources used by OF
get unmapped. Closes ticket #5193 again.


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


# 3a5655a50258fe19fdf452ed203bc38b85640959 21-May-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

* Reverted r34863.
* Don't keep any memory mappings from the OF for the time being. We can't
keep mappings < 2 GB, since those aren't in the kernel address space and
we don't handle memory mapped registers or the like correctly either.
Ticket #5193.


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


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

Patch by Andreas Faerber with small changes by myself:
* Skip mappings to non-physical memory in the PPC MMU code. Gets the
PPC kernel booting a little further.

Thanks! Fixes ticket #5193.


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


# 4b8d0e68569c871608f13fc5f5f5776a6846a2f2 03-Aug-2009 François Revol <revol@free.fr>

Some ppc fixes for #4115, patch by kallisti5 (without the #ifdef _BOOT_MODE):
- stubbed out arch_cpu_init_percpu(),
- make atomic ops declarations extern "C",
- move calls to [i]sync inside the asm code that needs it.


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


# bdee97bc3a8f88417e48dcd47a4bb75d1a548912 23-Jul-2009 Axel Dörfler <axeld@pinc-software.de>

* Applied slightly changed patch by Alexander von Gluck.
* Minor cleanup.


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


# 3b148e533fab72476f500ab3c31fc9e8282ee8c5 09-Nov-2008 François Revol <revol@free.fr>

This gets the bootloader further on, but it still breaks... OpenHackware seems worse than Pegasos OF :^)


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


# a268fbfe48afe5c26fe3079b86d62bd570bd8281 25-Jan-2006 Axel Dörfler <axeld@pinc-software.de>

Added some hacks to get the boot loader to work on the Pegasos.
Doesn't come far yet, though.


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


# a1bcf2c880834a1b344a4f8586335063e4975282 01-Jan-2006 Ingo Weinhold <ingo_weinhold@gmx.de>

* The OF memory management callback is now set in arch_mmu_init().
According to the spec we need to set it before taking over the MMU,
but we can't call it before arch_mmu_init(), since we need the OF
to allocate the page table. So we do it after we have allocated
the new page table.
* Added PPC specific kernel_args: The virtual address ranges we want
to keep in the kernel. We fill that in with the translations we
find when initializing the MMU stuff. We remove the memory the
boot loader occupies from those. Besides the stack for the boot
loader only the OF stuff remains.
* arch_mmu_allocate() now starts to search at KERNEL_BASE for a free
virtual address when no particular address is requested. This saves
us further trouble in the kernel, since those allocations would
need to be remapped otherwise.


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


# 4c1fca768d6d3d32eb4d4c0108e062e041682583 30-Dec-2005 Ingo Weinhold <ingo_weinhold@gmx.de>

Maybe I miss something, but I don't see the reason for the PPC
arch_mmu_allocate() to set the "cache inhibited" flag. One negative
effect was that for such memory the lwarx instruction (used by the
atomic_*() functions) does "... cause the system data storage error
handle to be invoked...", as the architecture specification puts it.


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


# 957a1b17eb9d13d6dbf164145e82997e16742549 30-Dec-2005 Ingo Weinhold <ingo_weinhold@gmx.de>

* Introduced new build system variables
{HAIKU,HOST,TARGET}_KERNEL_PIC_{CC,LINK}FLAGS which define the
compiler/linker flags specifying the kind of position independence
the kernel shall have. For x86 we had and still have -fno-pic, but the
PPC kernel has -fPIE (position independent executable) now, as we
need to relocate it.
* The boot loader relocates the kernel now. Mostly copied the relocation
code from the kernel ELF loader. Almost completely rewrote the PPC
specific relocation code, though. It's more correct and more complete now
(some things are still missing though).
* Added boot platform awareness to the kernel. Moved the generic
Open Firmware code (openfirmware.c/h) from the boot loader to the kernel.
* The kernel PPC serial debug output is sent to the console for the time
being.
* The PPC boot loader counts the CPUs now and allocates the kernel stacks
(made OF device iteration a bit more flexible on the way -- the search
can be restricted to subtree). Furthermore we really enter the kernel...
(Yay! :-) ... and crash in the first dprintf() (in the atomic_set()
called by acquire_spinlock()). kprintf() works, though.



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


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

arch_mmu_allocate() translated the protection flags incorrectly
(B_WRITE_AREA to read-only).


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


# 22a6522245e9f8a2e9208472f7feee3c9b4b678d 27-Dec-2005 Ingo Weinhold <ingo_weinhold@gmx.de>

* Renamed of_call_method() to of_call_client_function() and added
of_call_method() which is actually an implementation of the
"call-method" client function.
* of_interpret() announced one less return value than actually needed.
Seemed to work anyway, though.


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


# 7a3fa7d368448440e485ce03db59e25625b08c9c 19-Dec-2005 Axel Dörfler <axeld@pinc-software.de>

* Followed Ingo's suggestion and removed the now superfluous "length" correction
in ConsoleHandle::WriteAt().
* Updated license.


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