History log of /haiku/src/system/boot/platform/bios_ia32/smp.cpp
Revision Date Author Comments
# 91ee0332 19-Jul-2022 David Karoly <karolyd577@gmail.com>

move acpi headers from x86 to non-arch

Change-Id: Ida6186af7a40fb7d91b4da92c36d25db30dadb33
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5484
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>


# 1f8a8d2b 02-Oct-2020 Jérôme Duval <jerome.duval@gmail.com>

boot/bios_ia32: basic support la57 aka 5-level paging for x86_64 kernels

la57 kernel support is required. we simply add a 5th level and enable the cr4
feature. the safemode option "256tb_memory_limit" is named after the 4gb one,
but the current support is limited to 512GB as before (this can be later extended).

Change-Id: I922774473c4a6112a0e4ff74162285ad58aa53af
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3552
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>


# 401fb209 04-Feb-2018 Jérôme Duval <jerome.duval@gmail.com>

kernel: use x2apic on hypervisor, or if already enabled.

* this can be disabled per safe mode setting.


# 9dd4d2dd 03-Jan-2018 Jérôme Duval <jerome.duval@gmail.com>

kernel: support for Intel SMAP and SMEP on x86_64.

SMAP will generated page faults when the kernel tries to access user pages unless overriden.
If SMAP is enabled, the override instructions are written where needed in memory with
binary "altcodepatches".
Support is enabled by default, might be disabled per safemode setting.

Change-Id: Ife26cd765056aeaf65b2ffa3cadd0dcf4e273a96


# 3e0e3be7 06-Dec-2013 Pawel Dziepak <pdziepak@quarnos.org>

boot, kernel: Replace MAX_BOOT_CPUS with SMP_MAX_CPUS


# 4110b730 01-Oct-2013 Pawel Dziepak <pdziepak@quarnos.org>

x86[_64]: Add support for CPUID sub-leaves

Some CPUID leaves may contain one or more sub-leaves accessed by setting
ECX to an appropriate value.


# 78777340 26-Aug-2013 Jérôme Duval <jerome.duval@gmail.com>

Added x2APIC support.

* Mostly useful for virtualization at the moment. Works in QEmu.
* Can be enabled by safemode settings/menu.
* Please note that x2APIC normally requires use of VT-d interrupt remapping feature
on real hardware, which we don't support yet.


# cdca279a 09-Sep-2012 Fredrik Holmqvist <fredrik.holmqvist@gmail.com>

Remove unused header hpet.h.


# e690e5ab 12-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Proper fix for GCC 2 compilation error that was fixed earlier, cause pointed out by Ingo.


# 6ba74ba5 11-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Fixed compilation of the boot loader on GCC 2.

Not sure why but GCC 2 seems to be ignoring the extern "C" in smp.h when
compiling smp_boot_other_cpus() resulting in undefined references. Fixed
by putting extern "C" on the definition too.


# 76a1175d 11-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Support for SMP on x86_64.

No major changes to the kernel: just compiled in arch_smp.cpp and fixed the
IDT load in arch_cpu_init_percpu to use the correct limit for x86_64 (uses
sizeof(interrupt_descriptor)). In the boot loader, changed smp_boot_other_cpus
to construct a temporary GDT and get the page directory address from CR3, as
what's in kernel_args will be 64-bit stuff and will not work to switch the
CPUs into 32-bit mode in the trampoline code. Refactored 64-bit kernel entry
code to not use the stack after disabling paging, as the secondary CPUs are
given a 32-bit virtual stack address by the SMP trampoline code which will
no longer work.


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


# 69a8b954 23-Jun-2012 Ingo Weinhold <ingo_weinhold@gmx.de>

FixedWidthPointer: Fix ==/!= operators, remove OtherType casts

* FixedWidthPointer:
- operators ==/!=: Change second operand type from void* to const
Type*. Also add non-const version to resolve ambiguity warning when
comparing with non-const pointer.
- Add Pointer() getter.
- Remove templatized cast operators. They are nice for casting the
pointer directly to another pointer type, but result in ambiguity.
* Make preloaded_image::debug_string_table non-const. Avoids clashes of
the const and non-coast FixedWidthPointer comparison operators. A
cleaner (but more verbose) solution would be to spezialize
FixedWidthPointer for const types.


# 3a2a3367 22-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Support static_cast on FixedWidthPointer.


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

Added an ELF64 version of preloaded_image.

* There is now 2 structures, preloaded_elf32_image and preloaded_elf64_image,
which both inherit from preloaded_image.
* For now I've just hardcoded in use of preloaded_elf32_image, but the
bootloader ELF code will shortly be converted to use templates which use
the appropriate structure. The kernel will be changed later when I add
ELF64 support to it.
* All kernel_args data is now compatible between 32-bit and 64-bit kernels.


# 62d36f98 22-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Removed the addr_t conversion operators from FixedWidthPointer which makes comparison against NULL work properly.


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

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

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


# a5c94bed 07-Nov-2011 Michael Lotz <mmlr@mlotz.ch>

* Verify the MP config table signature and add some more sanity checks.
* Also reset the local and IO APIC base physical addresses when configuration
failed.

Should fix #8102, but is otherwise untested for lack of old enough hardware.


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


# 71b9d8cf 16-Jun-2011 Michael Lotz <mmlr@mlotz.ch>

Check for the (local) APIC feature on the CPU before moving on to SMP config and
APIC enumeration. As the local APIC is the basis for inter-CPU communication, we
can't do SMP when it's absent.
Fixes #7692, but indeed it makes no real sense for QEMU to provide the APIC info
in the MP and ACPI tables (and actually emulate the hardware) when it disables
the APIC support flag at the same time.


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


# 5cea8298 09-Jun-2011 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Missing default case


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


# f599932f 23-May-2011 Michael Lotz <mmlr@mlotz.ch>

* Simplify APIC writes.
* Add explicit volatile keyword.
* Minor variable name cleanup.


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


# 9c1714ec 16-May-2011 Michael Lotz <mmlr@mlotz.ch>

Enable IO-APICs by default. It's been tested on a broad spectrum of hardware and
all reports so far have been positive. We fall back to legacy mode in the cases
where we can't figure out the correct routing.


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


# 192bc027 14-May-2011 Michael Lotz <mmlr@mlotz.ch>

Disabling the local APIC also means disabling SMP, as the APIC is the base for
all inter-CPU messaging. The previously described timekeeping is just an extra
function of local APICs. Before, if you'd select "disable local APIC" it would
still blindly write to invalid memory (targetting the non-mapped local APIC) and
then just hang waiting for the other CPUs (that were obviously not responding
to the init sequence that wasn't programmed).


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


# ba0c232a 14-May-2011 Michael Lotz <mmlr@mlotz.ch>

Fix typo that caused the (first) IO-APIC address not to be set anymore when
configuring SMP via MP tables. We don't support that method anyhow, but it
should still report correctly.


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


# 8908aef9 13-May-2011 Michael Lotz <mmlr@mlotz.ch>

* Don't map the IO-APIC within the bootloader. We don't need it to set up SMP
at all and, since there can be multiple IO-APICs, we need to do the
enumeration again in the kernel anyway. Also only set ioapic_phys the first
time we encounter an IO-APIC object as it looks cleaner when we arrive at the
first IO-APIC default address.
* Therefore we don't have to worry about already mapped IO-APICs when
enumerating them in the kernel.
* Also remove the mapping function that is now not used anymore.
* We still use the ioapic_phys field of the kernel args to determine whether
there is an IO-APIC at all to avoid needlessly doing the enumeration again.

This fixes multi IO-APIC configurations, because before we would indeed map
the last IO-APIC listed in the MADT, but then in the kernel assumed we mapped
the first one. We'd end up with mapping the last listed IO-APIC twice and the
first IO-APIC never, always programming the last one when we actually targetted
the first one.


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


# 56b5ad07 07-May-2011 Michael Lotz <mmlr@mlotz.ch>

Added a temporary opt-in option "enable_ioapic" to the boot menu. This way the
IO-APIC can be easily enabled to test it on various configurations. Note that
the previous default opt-out didn't work because the safemode options would not
be touched at all when not actually entering the boot menu.
Once IO-APIC is more broadly tested this can be removed again and the opt-out
option reenabled.


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


# 36c80d70 25-Jun-2010 Axel Dörfler <axeld@pinc-software.de>

* Fixed warnings.


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


# 9623c482 11-Jun-2010 Travis Geiselbrecht <geist@foobox.com>

SMP: remove the tracking of apic id -> cpu id. Don't pass between bootloader and kernel.

Kernel doesn't use it, and it could be regenerated in the kernel if it did need it.

This also unlocks the apic range the bios can use. Previously the apic ids would have
to fit within 0..MAX_CPUS or it'd reject the cpu. Some boxes (mine in particular)
seem to sparsely populate the apic id so that the range is pretty large.

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


# 53d74726 16-May-2010 Travis Geiselbrecht <geist@foobox.com>

BOOT SMP: allow systems with a large number of cpus and/or sparse apic ids to actually boot

The old mechanism to route an apic id back to a cpu id is faulty, built with the assumption that
the bios will 'pack' the apic ids from 0-num_cpus. In systems that dont do that, the code would
randomly corrupt the bootloader. Fatal in this case.

This quick fix simply rejects all apic ids >= MAX_CPUS (8). No way it would have worked before
if you had a box that started with >= 8 or anything, so it shouldn't regress any existing system.

Better solution is to allow any apic id to exist (0-255).

On this particular box the ids (from lunix dmesg):
SRAT: PXM 0 -> APIC 0 -> Node 0
SRAT: PXM 1 -> APIC 16 -> Node 1
SRAT: PXM 0 -> APIC 2 -> Node 0
SRAT: PXM 0 -> APIC 4 -> Node 0
SRAT: PXM 0 -> APIC 6 -> Node 0
SRAT: PXM 1 -> APIC 18 -> Node 1
SRAT: PXM 1 -> APIC 20 -> Node 1
SRAT: PXM 1 -> APIC 22 -> Node 1
SRAT: PXM 0 -> APIC 1 -> Node 0
SRAT: PXM 0 -> APIC 3 -> Node 0
SRAT: PXM 0 -> APIC 5 -> Node 0
SRAT: PXM 0 -> APIC 7 -> Node 0
SRAT: PXM 1 -> APIC 17 -> Node 1
SRAT: PXM 1 -> APIC 19 -> Node 1
SRAT: PXM 1 -> APIC 21 -> Node 1
SRAT: PXM 1 -> APIC 23 -> Node 1



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


# fba2ee25 15-Apr-2010 Axel Dörfler <axeld@pinc-software.de>

* We should check for the I/O APIC before mapping it (since we panic if mapping
it failed...).
* Moved IRQ table reading much earlier (before starting to program the I/O
APIC), though it currently fails, possibly because the device manager isn't
up yet, and there is no embedded controller driver.
* The kernel now enables I/O APICs by default, but the boot loader disables
them - you can now enable them using the safe mode menu, but it currently
won't have any (positive) effect.


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


# 3d310bd5 12-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

* Fix build, the APIC definitions are used in the bootloader too.
* Automatic whitespace cleanup.


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


# 08876f2b 03-Mar-2010 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Move the code which checks for disabled apic earlier (in the boot loader).


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


# 1d958a30 28-Sep-2009 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Moved the "disable APIC" menu(s) to smp.cpp.
Also only enable them if there's an APIC.


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


# 89294b50 26-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* Added option for enabling serial debug output.
* Moved device_manager/settings.cpp to debug/safemode_settings.cpp.
* Removed the somewhat hacky concatenation of kernel settings and safemode
settings in the boot loader. Instead, get_safemode_option() will now fall
back to the kernel settings, if it couldn't spot a setting in the safemode
settings. This allows for more control, and also makes enabling serial
debug output actually work (ie. overriding the kernel settings via safemode
options).
* Adjusted debug_init_post_vm(), and smp_init_other_cpus() to use
get_safemode_boolean().
* Therefore, I added safemode_settings.cpp to the boot loader as well.


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


# e17f8de8 26-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* Cleanup, no functional change.


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


# 532a47a9 15-Feb-2009 Philippe Houdoin <philippe.houdoin@gmail.com>

Fixed broken style I've introduced.


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


# 4c0255d7 15-Feb-2009 Philippe Houdoin <philippe.houdoin@gmail.com>

Refactor the code, computing next entry earlier and use continue as suggested by Jerome.


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


# 7f0b0165 15-Feb-2009 Philippe Houdoin <philippe.houdoin@gmail.com>

Fixed the patch: on disabled processor entry, next entry pointer wasn't computed,
leading to an infinite loop...


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


# 63c851a1 15-Feb-2009 Philippe Houdoin <philippe.houdoin@gmail.com>

Applied patch supplied by jkeeping in #3445: smp_do_mp_config wasn't checking
MPS table CPU entries for the enabled flag.
This caused Haiku to fail to boot under KVM on Linux.

Thanks you, jkeeping.



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


# 17d39c90 22-Aug-2008 Stefano Ceccherini <stefano.ceccherini@gmail.com>

code for initializing hpet in the bootloader. Moved around some hpet definitions. HPET initialization is commented out, at the moment

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


# 85f26688 21-Jul-2008 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Patch by Dustin Howett (GSOC): Move ACPI probing out of the
bootloader's smp init and into its own unit.
ACPI tables can now generally be found with acpi_find_table(signature).


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


# 69dddbde 18-Jul-2008 Michael Lotz <mmlr@mlotz.ch>

Initial work towards supporting IO APICs. This cannot work for PCI interrupts
though until we use ACPI for proper PCI IRQ routing through the IO APIC.
Therefore the IO APIC code path is not yet enabled and the IO APIC isn't used.
ISA interrupts would work though, as would PCI interrupts if you'd hardcode
them for your specific configuration.
Note that this change also modifies some parts in the bootloader and in the PIC
setup to make local APICs available even on non-SMP systems. This causes APIC
timers to be used instead the normal PIT if it is available (also on non-SMP
configurations).
Also fixes some general errors in SMP and PIC code as well as some code cleanup.

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


# eb0a51d2 30-Jun-2008 Philippe Houdoin <philippe.houdoin@gmail.com>

Applied patch by David Powell: fix missing and existing bootloader options menu items help texts.


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


# 3fa048c0 31-Jan-2008 Michael Lotz <mmlr@mlotz.ch>

When starting the other CPUs from the bootloader we did not wait for any
confirmation after sending off the startup IPIs. We simply moved on and setup
the temporary stack address for the next CPU to be started. With this it was
possible that the trampoline code did not manage to load the address before
we overwrote it. So for configurations with more than two CPUs it was possible
that two CPUs were setup to the same kernel stack which could have caused all
sorts of things - most likely a tripple fault and a reboot. On real hardware
this seems very unlikely but it was easily reproducible with QEMU and -smp >2.
We now use the shared trampoline stack to implement a notification mechanism.
The trampoline code will clear the stack location variable once it has loaded
everything it needs from the trampoline stack. On the other side
smp_boot_other_cpus() will wait for this variable to be cleared after it sent
the startup IPIs so that it knows when it can safely move on and overwrite the
area to boot the next CPU.

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


# e812c77e 01-Jan-2008 Michael Lotz <mmlr@mlotz.ch>

* Delay initializing SMP stuff like APICs and kstacks of non-boot CPUs until after the boot menu
* When disabling SMP initialization of those parts is avoided so it works more cleanly
* Moved smp_find_mp_config() into smp_init() and moved MPS specific parts into smp_do_mp_config()
* Removed the global floating struct, if found it is now passed into smp_do_mp_config() like it is done for ACPI
* Made the file a bit more C++, applied coding style to some variable names and unified/improved some of the debug output

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


# b938008f 18-Dec-2007 Michael Lotz <mmlr@mlotz.ch>

* Update the PAUSE macro from "rep; nop;" to "pause;" which is the same bytecode wise but more readable
* Insert the pause op in all spin wait loops (as macro for platform independent sources or as inline assembly on x86 only files)
* Fix some warnings with tracing on and extended some output
* Minor cleanups here and there

The pause instruction is implemented since P4 systems but is fully backwards compatible (it's a no-op prior to P4). According to Intel specs it reduces performance penalties as memory order violations can be avoided. Also power consumption is reduced. Most of all this will be beneficial to hyper-threading systems as it frees resources to the other logical processor when one logical processor executes a fast spinning loop.

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


# fd098640 12-Dec-2007 Michael Lotz <mmlr@mlotz.ch>

Ignore disabled local APICs.

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


# d5f56f7d 11-Dec-2007 Michael Lotz <mmlr@mlotz.ch>

Remove 2 CPU limit from ACPI MP detection in the bootloader.

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


# f6c512f8 10-Dec-2007 Michael Lotz <mmlr@mlotz.ch>

Avoid adding more CPUs than the kernel args can hold (and therefore overwriting other kernel args stuff). Doesn't fix my problems though as the current maximum is 4 CPUs.

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


# d4cecb17 09-Dec-2007 Michael Lotz <mmlr@mlotz.ch>

Removed wrong and now unnecessary condition to add safemode option.

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


# f108445b 09-Dec-2007 Michael Lotz <mmlr@mlotz.ch>

* Initial support for ACPI tables to detect multiprocessor configurations
* ACPI is evaluated first as it also handles things like multi core or hyper threading setups
* Removed other (disabled) hyper threading code per the notes in the corresponding ToDo
* Limit the detected CPU count to 2 for now as I wasn't able to get it working in either emulation nor real hardware with more than 2 CPUs
* Added a reserved byte to the mp_config_table struct, it worked only by luck as the compiler did padding there to get to the same size

I can now boot my Core 2 Quad with two out of four processors active :-)

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


# dceaa556 03-Jan-2007 Marcus Overhagen <marcusoverhagen@gmail.com>

updated comment to account for PXE memory ranges


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


# 5fd605e2 24-Dec-2006 Marcus Overhagen <marcusoverhagen@gmail.com>

prettify formatting


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


# 82029bda 16-Sep-2006 Marcus Overhagen <marcusoverhagen@gmail.com>

added missing nothrow parameter


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


# 758b1d0e 12-Nov-2005 Ingo Weinhold <ingo_weinhold@gmx.de>

Fixes that make Haiku build with gcc 4. Mainly out of the following
categories:
* Missing includes (like <stdlib.h> and <string.h>).
* Linking against $(TARGET_LIBSTDC++) instead of libstdc++.r4.so.
* Local variables shadowing parameters.
* Default parameters in function definitions (as opposed to function
declarations).
* All C++ stuff (nothrow, map, set, vector, min, max,...) must be imported
explicitly from the std:: namespace now.
* "new (sometype)[...]" must read "new sometype[...]", even if sometype is
something like "const char *".
* __FUNCTION__ is no longer a string literal (but a string expression), i.e.
'printf(__FUNCTION__ ": ...\n")' is invalid code.
* A type cast results in a non-lvalue. E.g. "(char *)buffer += bytes"
is an invalid expression.
* "friend class SomeClass" only works when SomeClass is known before.
Otherwise the an inner class with that name is considered as friend.
gcc 4 is much pickier about scopes.
* gcc 4 is generally stricter with respect to type conversions in C.



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


# 8fcd6b8e 26-Oct-2005 Axel Dörfler <axeld@pinc-software.de>

* renamed smp_boot.c to smp.cpp
* there is now a "Disable Hyper-Threading" safemode in the boot loader
* the SMP & HT menu items are now added in smp.cpp - and are only added
if the system supports one of them.
* more cleanup to smp_apic.h
* removed cpuid() from the boot loader's support.S - instead, it will now
use the one from the kernel.
* added a very weak HT detection: if the MP config only listed one CPU,
and this CPU supports HT, we enable the other logic processor manually -
as this currently doesn't work, it's disabled, though.


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


# 3e0e3be7604ed12ab61b58789c44bc6d7333f48b 06-Dec-2013 Pawel Dziepak <pdziepak@quarnos.org>

boot, kernel: Replace MAX_BOOT_CPUS with SMP_MAX_CPUS


# 4110b730dbee59f5515a0bf9997b6cd167965080 01-Oct-2013 Pawel Dziepak <pdziepak@quarnos.org>

x86[_64]: Add support for CPUID sub-leaves

Some CPUID leaves may contain one or more sub-leaves accessed by setting
ECX to an appropriate value.


# 787773400ce9ee4ce71d9255e1be8fac66584615 26-Aug-2013 Jérôme Duval <jerome.duval@gmail.com>

Added x2APIC support.

* Mostly useful for virtualization at the moment. Works in QEmu.
* Can be enabled by safemode settings/menu.
* Please note that x2APIC normally requires use of VT-d interrupt remapping feature
on real hardware, which we don't support yet.


# cdca279abd37a7580e88de9c42cafcf962fcf5a9 09-Sep-2012 Fredrik Holmqvist <fredrik.holmqvist@gmail.com>

Remove unused header hpet.h.


# e690e5ab3b4adc583b94a27400b7fd12da80ce51 12-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Proper fix for GCC 2 compilation error that was fixed earlier, cause pointed out by Ingo.


# 6ba74ba51c14e84609239758cb01f674ffa335e8 11-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Fixed compilation of the boot loader on GCC 2.

Not sure why but GCC 2 seems to be ignoring the extern "C" in smp.h when
compiling smp_boot_other_cpus() resulting in undefined references. Fixed
by putting extern "C" on the definition too.


# 76a1175dbe1a314563ca18c0b7fb82695a9730cd 11-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Support for SMP on x86_64.

No major changes to the kernel: just compiled in arch_smp.cpp and fixed the
IDT load in arch_cpu_init_percpu to use the correct limit for x86_64 (uses
sizeof(interrupt_descriptor)). In the boot loader, changed smp_boot_other_cpus
to construct a temporary GDT and get the page directory address from CR3, as
what's in kernel_args will be 64-bit stuff and will not work to switch the
CPUs into 32-bit mode in the trampoline code. Refactored 64-bit kernel entry
code to not use the stack after disabling paging, as the secondary CPUs are
given a 32-bit virtual stack address by the SMP trampoline code which will
no longer work.


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


# 69a8b95491c160f03a5b0dab0fa8d1899fe42d4b 23-Jun-2012 Ingo Weinhold <ingo_weinhold@gmx.de>

FixedWidthPointer: Fix ==/!= operators, remove OtherType casts

* FixedWidthPointer:
- operators ==/!=: Change second operand type from void* to const
Type*. Also add non-const version to resolve ambiguity warning when
comparing with non-const pointer.
- Add Pointer() getter.
- Remove templatized cast operators. They are nice for casting the
pointer directly to another pointer type, but result in ambiguity.
* Make preloaded_image::debug_string_table non-const. Avoids clashes of
the const and non-coast FixedWidthPointer comparison operators. A
cleaner (but more verbose) solution would be to spezialize
FixedWidthPointer for const types.


# 3a2a3367dc9bec2a5fbcd4ac849da6ac65e74e79 22-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Support static_cast on FixedWidthPointer.


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

Added an ELF64 version of preloaded_image.

* There is now 2 structures, preloaded_elf32_image and preloaded_elf64_image,
which both inherit from preloaded_image.
* For now I've just hardcoded in use of preloaded_elf32_image, but the
bootloader ELF code will shortly be converted to use templates which use
the appropriate structure. The kernel will be changed later when I add
ELF64 support to it.
* All kernel_args data is now compatible between 32-bit and 64-bit kernels.


# 62d36f98331067e472188f6c020c2ccd808f48cf 22-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Removed the addr_t conversion operators from FixedWidthPointer which makes comparison against NULL work properly.


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

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

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


# a5c94bedb68cd84e4f12cc6420e4ab0d31bcd30d 07-Nov-2011 Michael Lotz <mmlr@mlotz.ch>

* Verify the MP config table signature and add some more sanity checks.
* Also reset the local and IO APIC base physical addresses when configuration
failed.

Should fix #8102, but is otherwise untested for lack of old enough hardware.


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


# 71b9d8cf3ba0cec43cf2e32bd04db826e9cd95f4 16-Jun-2011 Michael Lotz <mmlr@mlotz.ch>

Check for the (local) APIC feature on the CPU before moving on to SMP config and
APIC enumeration. As the local APIC is the basis for inter-CPU communication, we
can't do SMP when it's absent.
Fixes #7692, but indeed it makes no real sense for QEMU to provide the APIC info
in the MP and ACPI tables (and actually emulate the hardware) when it disables
the APIC support flag at the same time.


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


# 5cea82988c0e5124a951ad56939dcaf42ebf4131 09-Jun-2011 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Missing default case


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


# f599932f82e4a1023d87352ea842381a9ef667bd 23-May-2011 Michael Lotz <mmlr@mlotz.ch>

* Simplify APIC writes.
* Add explicit volatile keyword.
* Minor variable name cleanup.


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


# 9c1714ec1a3c8c4769198af90694450c170da007 16-May-2011 Michael Lotz <mmlr@mlotz.ch>

Enable IO-APICs by default. It's been tested on a broad spectrum of hardware and
all reports so far have been positive. We fall back to legacy mode in the cases
where we can't figure out the correct routing.


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


# 192bc027eaa41081e99ae42641866871cfc1a649 14-May-2011 Michael Lotz <mmlr@mlotz.ch>

Disabling the local APIC also means disabling SMP, as the APIC is the base for
all inter-CPU messaging. The previously described timekeeping is just an extra
function of local APICs. Before, if you'd select "disable local APIC" it would
still blindly write to invalid memory (targetting the non-mapped local APIC) and
then just hang waiting for the other CPUs (that were obviously not responding
to the init sequence that wasn't programmed).


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


# ba0c232abb23b49eb02c77251c312448084fe499 14-May-2011 Michael Lotz <mmlr@mlotz.ch>

Fix typo that caused the (first) IO-APIC address not to be set anymore when
configuring SMP via MP tables. We don't support that method anyhow, but it
should still report correctly.


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


# 8908aef9c2c62225bce2d8216e81397c872316e8 13-May-2011 Michael Lotz <mmlr@mlotz.ch>

* Don't map the IO-APIC within the bootloader. We don't need it to set up SMP
at all and, since there can be multiple IO-APICs, we need to do the
enumeration again in the kernel anyway. Also only set ioapic_phys the first
time we encounter an IO-APIC object as it looks cleaner when we arrive at the
first IO-APIC default address.
* Therefore we don't have to worry about already mapped IO-APICs when
enumerating them in the kernel.
* Also remove the mapping function that is now not used anymore.
* We still use the ioapic_phys field of the kernel args to determine whether
there is an IO-APIC at all to avoid needlessly doing the enumeration again.

This fixes multi IO-APIC configurations, because before we would indeed map
the last IO-APIC listed in the MADT, but then in the kernel assumed we mapped
the first one. We'd end up with mapping the last listed IO-APIC twice and the
first IO-APIC never, always programming the last one when we actually targetted
the first one.


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


# 56b5ad07811e608372b159831a6151598edefd48 07-May-2011 Michael Lotz <mmlr@mlotz.ch>

Added a temporary opt-in option "enable_ioapic" to the boot menu. This way the
IO-APIC can be easily enabled to test it on various configurations. Note that
the previous default opt-out didn't work because the safemode options would not
be touched at all when not actually entering the boot menu.
Once IO-APIC is more broadly tested this can be removed again and the opt-out
option reenabled.


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


# 36c80d700277377b7d6ebe204e8f7a4fb94078ad 25-Jun-2010 Axel Dörfler <axeld@pinc-software.de>

* Fixed warnings.


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


# 9623c48284a184ff5ef9de6d614a1525ffa79e77 11-Jun-2010 Travis Geiselbrecht <geist@foobox.com>

SMP: remove the tracking of apic id -> cpu id. Don't pass between bootloader and kernel.

Kernel doesn't use it, and it could be regenerated in the kernel if it did need it.

This also unlocks the apic range the bios can use. Previously the apic ids would have
to fit within 0..MAX_CPUS or it'd reject the cpu. Some boxes (mine in particular)
seem to sparsely populate the apic id so that the range is pretty large.

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


# 53d7472637e44e7b6f73c1afce96e230a3e3e144 16-May-2010 Travis Geiselbrecht <geist@foobox.com>

BOOT SMP: allow systems with a large number of cpus and/or sparse apic ids to actually boot

The old mechanism to route an apic id back to a cpu id is faulty, built with the assumption that
the bios will 'pack' the apic ids from 0-num_cpus. In systems that dont do that, the code would
randomly corrupt the bootloader. Fatal in this case.

This quick fix simply rejects all apic ids >= MAX_CPUS (8). No way it would have worked before
if you had a box that started with >= 8 or anything, so it shouldn't regress any existing system.

Better solution is to allow any apic id to exist (0-255).

On this particular box the ids (from lunix dmesg):
SRAT: PXM 0 -> APIC 0 -> Node 0
SRAT: PXM 1 -> APIC 16 -> Node 1
SRAT: PXM 0 -> APIC 2 -> Node 0
SRAT: PXM 0 -> APIC 4 -> Node 0
SRAT: PXM 0 -> APIC 6 -> Node 0
SRAT: PXM 1 -> APIC 18 -> Node 1
SRAT: PXM 1 -> APIC 20 -> Node 1
SRAT: PXM 1 -> APIC 22 -> Node 1
SRAT: PXM 0 -> APIC 1 -> Node 0
SRAT: PXM 0 -> APIC 3 -> Node 0
SRAT: PXM 0 -> APIC 5 -> Node 0
SRAT: PXM 0 -> APIC 7 -> Node 0
SRAT: PXM 1 -> APIC 17 -> Node 1
SRAT: PXM 1 -> APIC 19 -> Node 1
SRAT: PXM 1 -> APIC 21 -> Node 1
SRAT: PXM 1 -> APIC 23 -> Node 1



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


# fba2ee2527563001dbab46b4aa15570bf47c00bc 15-Apr-2010 Axel Dörfler <axeld@pinc-software.de>

* We should check for the I/O APIC before mapping it (since we panic if mapping
it failed...).
* Moved IRQ table reading much earlier (before starting to program the I/O
APIC), though it currently fails, possibly because the device manager isn't
up yet, and there is no embedded controller driver.
* The kernel now enables I/O APICs by default, but the boot loader disables
them - you can now enable them using the safe mode menu, but it currently
won't have any (positive) effect.


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


# 3d310bd5f405d6d336222111bc2a09018c28f0f2 12-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

* Fix build, the APIC definitions are used in the bootloader too.
* Automatic whitespace cleanup.


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


# 08876f2b9668da3140c7f868c47a5d599337d6c1 03-Mar-2010 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Move the code which checks for disabled apic earlier (in the boot loader).


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


# 1d958a301eb6860ac2b3a6ce6749a8163408a80e 28-Sep-2009 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Moved the "disable APIC" menu(s) to smp.cpp.
Also only enable them if there's an APIC.


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


# 89294b508428bd4575a67bd179bceabce7619c08 26-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* Added option for enabling serial debug output.
* Moved device_manager/settings.cpp to debug/safemode_settings.cpp.
* Removed the somewhat hacky concatenation of kernel settings and safemode
settings in the boot loader. Instead, get_safemode_option() will now fall
back to the kernel settings, if it couldn't spot a setting in the safemode
settings. This allows for more control, and also makes enabling serial
debug output actually work (ie. overriding the kernel settings via safemode
options).
* Adjusted debug_init_post_vm(), and smp_init_other_cpus() to use
get_safemode_boolean().
* Therefore, I added safemode_settings.cpp to the boot loader as well.


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


# e17f8de82dfafa478858f9435158f3ded5a76e07 26-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* Cleanup, no functional change.


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


# 532a47a9f0377418912aee177bda9f85d03eb9c2 15-Feb-2009 Philippe Houdoin <philippe.houdoin@gmail.com>

Fixed broken style I've introduced.


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


# 4c0255d7959edadddc3be40d00d2cd9982e030b2 15-Feb-2009 Philippe Houdoin <philippe.houdoin@gmail.com>

Refactor the code, computing next entry earlier and use continue as suggested by Jerome.


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


# 7f0b01654de17494dace8670e8974e41e66c0b56 15-Feb-2009 Philippe Houdoin <philippe.houdoin@gmail.com>

Fixed the patch: on disabled processor entry, next entry pointer wasn't computed,
leading to an infinite loop...


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


# 63c851a15d4a72a56e2edfa0124cb4a840b0dcd5 15-Feb-2009 Philippe Houdoin <philippe.houdoin@gmail.com>

Applied patch supplied by jkeeping in #3445: smp_do_mp_config wasn't checking
MPS table CPU entries for the enabled flag.
This caused Haiku to fail to boot under KVM on Linux.

Thanks you, jkeeping.



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


# 17d39c90b11ea65e6d8991d12f178f9f880d9d06 22-Aug-2008 Stefano Ceccherini <stefano.ceccherini@gmail.com>

code for initializing hpet in the bootloader. Moved around some hpet definitions. HPET initialization is commented out, at the moment

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


# 85f2668898ba1eb50bf1ea6271b4fe28123f58e5 21-Jul-2008 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Patch by Dustin Howett (GSOC): Move ACPI probing out of the
bootloader's smp init and into its own unit.
ACPI tables can now generally be found with acpi_find_table(signature).


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


# 69dddbdea163b79cfb464b4a1bc18e6533ab06ff 18-Jul-2008 Michael Lotz <mmlr@mlotz.ch>

Initial work towards supporting IO APICs. This cannot work for PCI interrupts
though until we use ACPI for proper PCI IRQ routing through the IO APIC.
Therefore the IO APIC code path is not yet enabled and the IO APIC isn't used.
ISA interrupts would work though, as would PCI interrupts if you'd hardcode
them for your specific configuration.
Note that this change also modifies some parts in the bootloader and in the PIC
setup to make local APICs available even on non-SMP systems. This causes APIC
timers to be used instead the normal PIT if it is available (also on non-SMP
configurations).
Also fixes some general errors in SMP and PIC code as well as some code cleanup.

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


# eb0a51d2f292f1774948f165f68735f9c12edc77 30-Jun-2008 Philippe Houdoin <philippe.houdoin@gmail.com>

Applied patch by David Powell: fix missing and existing bootloader options menu items help texts.


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


# 3fa048c0a641db7b58d69c9629cb714de60d221c 31-Jan-2008 Michael Lotz <mmlr@mlotz.ch>

When starting the other CPUs from the bootloader we did not wait for any
confirmation after sending off the startup IPIs. We simply moved on and setup
the temporary stack address for the next CPU to be started. With this it was
possible that the trampoline code did not manage to load the address before
we overwrote it. So for configurations with more than two CPUs it was possible
that two CPUs were setup to the same kernel stack which could have caused all
sorts of things - most likely a tripple fault and a reboot. On real hardware
this seems very unlikely but it was easily reproducible with QEMU and -smp >2.
We now use the shared trampoline stack to implement a notification mechanism.
The trampoline code will clear the stack location variable once it has loaded
everything it needs from the trampoline stack. On the other side
smp_boot_other_cpus() will wait for this variable to be cleared after it sent
the startup IPIs so that it knows when it can safely move on and overwrite the
area to boot the next CPU.

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


# e812c77e4a8a2f5d923cd3a903ab3d4d38187488 01-Jan-2008 Michael Lotz <mmlr@mlotz.ch>

* Delay initializing SMP stuff like APICs and kstacks of non-boot CPUs until after the boot menu
* When disabling SMP initialization of those parts is avoided so it works more cleanly
* Moved smp_find_mp_config() into smp_init() and moved MPS specific parts into smp_do_mp_config()
* Removed the global floating struct, if found it is now passed into smp_do_mp_config() like it is done for ACPI
* Made the file a bit more C++, applied coding style to some variable names and unified/improved some of the debug output

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


# b938008fe1d84dd8595dcfff4b7cedb0f3088bb7 18-Dec-2007 Michael Lotz <mmlr@mlotz.ch>

* Update the PAUSE macro from "rep; nop;" to "pause;" which is the same bytecode wise but more readable
* Insert the pause op in all spin wait loops (as macro for platform independent sources or as inline assembly on x86 only files)
* Fix some warnings with tracing on and extended some output
* Minor cleanups here and there

The pause instruction is implemented since P4 systems but is fully backwards compatible (it's a no-op prior to P4). According to Intel specs it reduces performance penalties as memory order violations can be avoided. Also power consumption is reduced. Most of all this will be beneficial to hyper-threading systems as it frees resources to the other logical processor when one logical processor executes a fast spinning loop.

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


# fd0986401e8f77bce13de187194a227a5f092768 12-Dec-2007 Michael Lotz <mmlr@mlotz.ch>

Ignore disabled local APICs.

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


# d5f56f7d69b4ae5315a09859faa6f341810e5742 11-Dec-2007 Michael Lotz <mmlr@mlotz.ch>

Remove 2 CPU limit from ACPI MP detection in the bootloader.

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


# f6c512f8e39d597f29448c2a00c5d545d064a3a2 10-Dec-2007 Michael Lotz <mmlr@mlotz.ch>

Avoid adding more CPUs than the kernel args can hold (and therefore overwriting other kernel args stuff). Doesn't fix my problems though as the current maximum is 4 CPUs.

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


# d4cecb1787aae4c729ba0a42bfb4d158b1534d88 09-Dec-2007 Michael Lotz <mmlr@mlotz.ch>

Removed wrong and now unnecessary condition to add safemode option.

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


# f108445b5e53eb20b19f85f7c0311fb5a2db769a 09-Dec-2007 Michael Lotz <mmlr@mlotz.ch>

* Initial support for ACPI tables to detect multiprocessor configurations
* ACPI is evaluated first as it also handles things like multi core or hyper threading setups
* Removed other (disabled) hyper threading code per the notes in the corresponding ToDo
* Limit the detected CPU count to 2 for now as I wasn't able to get it working in either emulation nor real hardware with more than 2 CPUs
* Added a reserved byte to the mp_config_table struct, it worked only by luck as the compiler did padding there to get to the same size

I can now boot my Core 2 Quad with two out of four processors active :-)

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


# dceaa55687fdc848886ab2c20dff9aba01e0a021 03-Jan-2007 Marcus Overhagen <marcusoverhagen@gmail.com>

updated comment to account for PXE memory ranges


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


# 5fd605e278ea6dfcceadfbdfac3545c67c4c73f0 24-Dec-2006 Marcus Overhagen <marcusoverhagen@gmail.com>

prettify formatting


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


# 82029bdae870b0e257a54929116ddfb6da9efdca 16-Sep-2006 Marcus Overhagen <marcusoverhagen@gmail.com>

added missing nothrow parameter


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


# 758b1d0e05fe1042cce6e00d194a147802d4f9be 12-Nov-2005 Ingo Weinhold <ingo_weinhold@gmx.de>

Fixes that make Haiku build with gcc 4. Mainly out of the following
categories:
* Missing includes (like <stdlib.h> and <string.h>).
* Linking against $(TARGET_LIBSTDC++) instead of libstdc++.r4.so.
* Local variables shadowing parameters.
* Default parameters in function definitions (as opposed to function
declarations).
* All C++ stuff (nothrow, map, set, vector, min, max,...) must be imported
explicitly from the std:: namespace now.
* "new (sometype)[...]" must read "new sometype[...]", even if sometype is
something like "const char *".
* __FUNCTION__ is no longer a string literal (but a string expression), i.e.
'printf(__FUNCTION__ ": ...\n")' is invalid code.
* A type cast results in a non-lvalue. E.g. "(char *)buffer += bytes"
is an invalid expression.
* "friend class SomeClass" only works when SomeClass is known before.
Otherwise the an inner class with that name is considered as friend.
gcc 4 is much pickier about scopes.
* gcc 4 is generally stricter with respect to type conversions in C.



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


# 8fcd6b8e61e367a9f832f7e9fe60f8d7c6868313 26-Oct-2005 Axel Dörfler <axeld@pinc-software.de>

* renamed smp_boot.c to smp.cpp
* there is now a "Disable Hyper-Threading" safemode in the boot loader
* the SMP & HT menu items are now added in smp.cpp - and are only added
if the system supports one of them.
* more cleanup to smp_apic.h
* removed cpuid() from the boot loader's support.S - instead, it will now
use the one from the kernel.
* added a very weak HT detection: if the MP config only listed one CPU,
and this CPU supports HT, we enable the other logic processor manually -
as this currently doesn't work, it's disabled, though.


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