History log of /haiku/src/system/kernel/arch/ppc/arch_cpu.cpp
Revision Date Author Comments
# 88c54b54 19-Jan-2014 Alexander von Gluck IV <kallisti5@unixzen.com>

kernel: Rework ppc (and m68k) atomic functions post-scheduler

* Make atomic function more like current x86
* Remove fake fallback atomic code for ppc as hardware spinlocks exist


# dc5a16bb 02-Jul-2012 Rene Gollent <anevilyak@gmail.com>

Add TODO note with respect to needed asm implementations.


# 6ec9dff3 30-May-2011 Jérôme Duval <korli@users.berlios.de>

ppc build fix


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


# 328029e1 30-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Patch by Alexander von Gluck (kallisti5) to get the PPC build going again
(mostly at least). Also disables -Werror for the binutils, but those should
be fixed eventually.


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


# 867bc161 20-May-2008 François Revol <revol@free.fr>

It should be eieio...


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


# 807cf76d 26-Apr-2008 François Revol <revol@free.fr>

memory barrier functions available for drivers.


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


# 962b0b88 01-Apr-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Added a wrapper function for the invocation of debugger commands. It
sets a fault handler, so that an invalid memory access while executing
the command (address typos always do the trick :-) won't result in
another KDL session on top of the current one, which wouldn't even be
"cont"able.

All pieces of code setting a fault handler do now save and reset the
previous one, so that e.g. a user_memcpy() in a debugger command doesn't
disturb the mechanism.


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


# badc7b67 18-Feb-2007 Travis Geiselbrecht <geist@foobox.com>

yet another fix for #1018, which has at this point blossomed into a reorg of how AP cpus are initialized.
the new cpuid stuff was apparently exacerbating an existing problem where various bits of low level
cpu code (specifically get_current_cpu) weren't really initialized before being used. Changed the
order to set up a fake set of threads to point each cpu at really early in boot to make sure that at
all points in code it can get the current 'thread' and thus the current cpu.
A probably better solution would be to have dr3 point to the current cpu which would then point to the
current thread, but that has a race condition that would require an int disable, etc.


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


# 7afc16f0 12-Jan-2006 Ingo Weinhold <ingo_weinhold@gmx.de>

* Fixed a bug regarding storing/restoring FPSCR in the interrupt
code. The stack pointer was not adjusted, hence we were
overwriting the previous register value. But it looks like I
missed to check in the arch_cpu.h with the iframe structure
including the floating point registers anyway.
* Backported the ELF PPC relocation code from the boot loader to
the kernel.
* Fixed the PPC version of arch_thread_switch_kstack_and_call().
Apparently the signature had changed, but the assembly
implementation was not adjusted accordingly.
* sc prints more registers now (LR, CR, CTR, XER,...).
* Fixed several occurences of not-working fault handlers.
Apparently the compiler realized, that the "error" label was
never jumped to (by the code it knew), and optimized the
respective code away. Now we use a trick to make it think the
error label might actually be jumped to. I wonder whether the
x86 version has the same problem when being compiled with GCC4.
* Adopted the x86 page fault handling interrupt code.



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


# b7ba8a18 11-Jan-2006 Ingo Weinhold <ingo_weinhold@gmx.de>

We enable the FPU now, store the non-volatile FPU registers on
context switches and all FPU registers in an iframe. We might want
to rethink this, though.
The kernel initialization runs to the end now. No boot volume is
found yet, but that is expected.


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


# d0648592 10-Jan-2006 Ingo Weinhold <ingo_weinhold@gmx.de>

It appears I misjudged the availability of the "tlbia" instruction. Put
the previous implementation of arch_cpu_global_TLB_invalidate() back in
place (as fallback).


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


# 6c678c57 09-Jan-2006 Ingo Weinhold <ingo_weinhold@gmx.de>

* The exception vector offset is now also part of the iframe.
* Cloned iframe stack management from x86.
* Reimplemented arch_thread_{get,set}_current_thread(). The
thread structure is stored in SPRG2. It is set to NULL in
arch_cpu_preboot_init(), now. A non-null current thread
causes all kinds of undesired behavior in early boot code.
* We establish the address space mappings we know from the
Open Firmware as areas. At least those in kernel address
space. The ones in userland address space are tougher.
Fortunately on my Mac mini there aren't any save the
boot_loader stack, which is not needed any longer anyway.
* Added stack trace support to the kernel debugger. Mostly
cloned and adjusted the x86 code. Some bits are still
missing, like stack traces for other threads.


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


# 8baf8813 07-Jan-2006 Ingo Weinhold <ingo_weinhold@gmx.de>

Added "shutdown" debugger command. Implemented arch_cpu_shutdown() for
PPC.


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


# 88c54b548550f298727c450f2330cdfd59533ad9 19-Jan-2014 Alexander von Gluck IV <kallisti5@unixzen.com>

kernel: Rework ppc (and m68k) atomic functions post-scheduler

* Make atomic function more like current x86
* Remove fake fallback atomic code for ppc as hardware spinlocks exist


# dc5a16bb70c95c64b1203682acf5a67e19b2b882 02-Jul-2012 Rene Gollent <anevilyak@gmail.com>

Add TODO note with respect to needed asm implementations.


# 6ec9dff3f30460f216b67b81d4934496725e3076 30-May-2011 Jérôme Duval <korli@users.berlios.de>

ppc build fix


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


# 328029e178152c8eceebd40d14ff80ccf2039970 30-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Patch by Alexander von Gluck (kallisti5) to get the PPC build going again
(mostly at least). Also disables -Werror for the binutils, but those should
be fixed eventually.


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


# 867bc161495e04b2f62f6dc977858d046d12acfb 20-May-2008 François Revol <revol@free.fr>

It should be eieio...


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


# 807cf76df012895d6de2cea198c9c3b0558948b1 26-Apr-2008 François Revol <revol@free.fr>

memory barrier functions available for drivers.


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


# 962b0b887d830b7f7bfd47de10112609302bbd82 01-Apr-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Added a wrapper function for the invocation of debugger commands. It
sets a fault handler, so that an invalid memory access while executing
the command (address typos always do the trick :-) won't result in
another KDL session on top of the current one, which wouldn't even be
"cont"able.

All pieces of code setting a fault handler do now save and reset the
previous one, so that e.g. a user_memcpy() in a debugger command doesn't
disturb the mechanism.


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


# badc7b674eca3e33d1c5f865a626966110790f8f 18-Feb-2007 Travis Geiselbrecht <geist@foobox.com>

yet another fix for #1018, which has at this point blossomed into a reorg of how AP cpus are initialized.
the new cpuid stuff was apparently exacerbating an existing problem where various bits of low level
cpu code (specifically get_current_cpu) weren't really initialized before being used. Changed the
order to set up a fake set of threads to point each cpu at really early in boot to make sure that at
all points in code it can get the current 'thread' and thus the current cpu.
A probably better solution would be to have dr3 point to the current cpu which would then point to the
current thread, but that has a race condition that would require an int disable, etc.


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


# 7afc16f05918c55f8e6aae8c2b4bd15789d32116 12-Jan-2006 Ingo Weinhold <ingo_weinhold@gmx.de>

* Fixed a bug regarding storing/restoring FPSCR in the interrupt
code. The stack pointer was not adjusted, hence we were
overwriting the previous register value. But it looks like I
missed to check in the arch_cpu.h with the iframe structure
including the floating point registers anyway.
* Backported the ELF PPC relocation code from the boot loader to
the kernel.
* Fixed the PPC version of arch_thread_switch_kstack_and_call().
Apparently the signature had changed, but the assembly
implementation was not adjusted accordingly.
* sc prints more registers now (LR, CR, CTR, XER,...).
* Fixed several occurences of not-working fault handlers.
Apparently the compiler realized, that the "error" label was
never jumped to (by the code it knew), and optimized the
respective code away. Now we use a trick to make it think the
error label might actually be jumped to. I wonder whether the
x86 version has the same problem when being compiled with GCC4.
* Adopted the x86 page fault handling interrupt code.



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


# b7ba8a182f8aab6e295cfec30807f2df8d393d18 11-Jan-2006 Ingo Weinhold <ingo_weinhold@gmx.de>

We enable the FPU now, store the non-volatile FPU registers on
context switches and all FPU registers in an iframe. We might want
to rethink this, though.
The kernel initialization runs to the end now. No boot volume is
found yet, but that is expected.


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


# d0648592cae51dcbbbe37c413eab7279793bc99e 10-Jan-2006 Ingo Weinhold <ingo_weinhold@gmx.de>

It appears I misjudged the availability of the "tlbia" instruction. Put
the previous implementation of arch_cpu_global_TLB_invalidate() back in
place (as fallback).


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


# 6c678c57c736f4688c9bab047bed3fe00fd27a13 09-Jan-2006 Ingo Weinhold <ingo_weinhold@gmx.de>

* The exception vector offset is now also part of the iframe.
* Cloned iframe stack management from x86.
* Reimplemented arch_thread_{get,set}_current_thread(). The
thread structure is stored in SPRG2. It is set to NULL in
arch_cpu_preboot_init(), now. A non-null current thread
causes all kinds of undesired behavior in early boot code.
* We establish the address space mappings we know from the
Open Firmware as areas. At least those in kernel address
space. The ones in userland address space are tougher.
Fortunately on my Mac mini there aren't any save the
boot_loader stack, which is not needed any longer anyway.
* Added stack trace support to the kernel debugger. Mostly
cloned and adjusted the x86 code. Some bits are still
missing, like stack traces for other threads.


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


# 8baf8813c0562df49a23b32f42b95c544af1a20b 07-Jan-2006 Ingo Weinhold <ingo_weinhold@gmx.de>

Added "shutdown" debugger command. Implemented arch_cpu_shutdown() for
PPC.


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