Commit Graph

67 Commits

Author SHA1 Message Date
Tom
bc107d0b33 Kernel: Add SMP IPI support
We can now properly initialize all processors without
crashing by sending SMP IPI messages to synchronize memory
between processors.

We now initialize the APs once we have the scheduler running.
This is so that we can process IPI messages from the other
cores.

Also rework interrupt handling a bit so that it's more of a
1:1 mapping. We need to allocate non-sharable interrupts for
IPIs.

This also fixes the occasional hang/crash because all
CPUs now synchronize memory with each other.
2020-07-06 17:07:44 +02:00
Andreas Kling
37598de582 Kernel: Remove DMI decoder from the kernel
As suggested by @supercomputer7, we can simply expose this as a blob
and decode it in userspace instead.

Fixes #2599.
2020-06-20 18:39:46 +02:00
Tom
0bc92c259d Kernel: Detect APs and boot them into protected mode
This isn't fully working, the APs pretend like they're
fully initialized and are just halted permanently for now.
2020-06-04 18:15:23 +02:00
Andreas Kling
b8af5cd8da Kernel: Simplify MP table parser a little bit more
Get rid of the ConfigurationTableEntryLength enum and just look at the
sizeof() for each entry type.
2020-05-23 15:25:43 +02:00
Andreas Kling
ba390f9b34 Kernel: Remove outdated FIXME's in the static ACPI parser
We no longer blindly use PAGE_SIZE here. :^)
2020-05-22 13:38:20 +02:00
Andreas Kling
4b847810bf Kernel: Simplify scanning BIOS/EBDA and MP parser initialization
Add a MappedROM::find_chunk_starting_with() helper since that's a very
common usage pattern in clients of this code.

Also convert MultiProcessorParser from a persistent singleton object
to a temporary object constructed via a failable factory function.
2020-05-22 13:36:57 +02:00
Andreas Kling
84b7bc5e14 Kernel: Add convenient ways to map whole BIOS and EBDA into memory
This patch adds a MappedROM abstraction to the Kernel VM subsystem.
It's basically the read-only byte buffer equivalent of a TypedMapping.

We use this in the ACPI and MP table parsers to scan for interesting
stuff in low memory instead of doing a bunch of address arithmetic.
2020-05-22 13:17:38 +02:00
Andreas Kling
6b5d2afd00 Kernel: Clean up and simplify MP table parsing
Use map_typed<T> to map physically addressed structs into kernel VM.
This is so much easier than doing address arithmetic everywhere. :^)
2020-05-22 12:01:01 +02:00
Andreas Kling
21d5f4ada1 Kernel: Absorb LibBareMetal back into the kernel
This was supposed to be the foundation for some kind of pre-kernel
environment, but nobody is working on it right now, so let's move
everything back into the kernel and remove all the confusion.
2020-05-16 12:00:04 +02:00
Andreas Kling
d92f62db43 Kernel: Remove ref-counting from interrupt override metadata
I don't see a reason for these to be reference-counted, and removing it
simplifies a bunch of surrounding data structures.
2020-05-08 21:12:16 +02:00
Liav A
4d44a3bdfe Kernel: Reorder bitwise operations when creating PCI interrupt overrides 2020-04-09 20:45:44 +02:00
Liav A
e4ad1b92fb MultiProcessor: Silence debug message spam 2020-04-09 20:45:44 +02:00
Liav A
fec8763c21 Interrupts: Make the MultiProcessorParser functional again 2020-04-09 19:59:53 +02:00
Andreas Kling
871d450b93 Kernel: Remove redundant "ACPI" from filenames in ACPI/ 2020-04-09 18:17:27 +02:00
Andreas Kling
1c865ee8d4 Kernel: Merge ACPI::StaticParser into ACPI::Parser
There's no need for StaticParser to be a separate thing from Parser.
2020-04-09 18:15:02 +02:00
Andreas Kling
a3ca745b5a Kernel: Use StringView for ACPI table signatures 2020-04-09 18:03:57 +02:00
Andreas Kling
f614f0e2cb Kernel: Add typed_map<T>(PhysicalAddress) and use it in ACPI parsing
There was a frequently occurring pattern of "map this physical address
into kernel VM, then read from it, then unmap it again".

This new typed_map() encapsulates that logic by giving you back a
typed pointer to the kind of structure you're interested in accessing.

It returns a TypedMapping<T> that can be used mostly like a pointer.
When destroyed, the TypedMapping object will unmap the memory. :^)
2020-04-09 17:19:11 +02:00
Andreas Kling
4644217094 Kernel: Remove "non-operational" ACPI parser state
If we don't support ACPI, just don't instantiate an ACPI parser.
This is way less confusing than having a special parser class whose
only purpose is to do nothing.

We now search for the RSDP in ACPI::initialize() instead of letting
the parser constructor do it. This allows us to defer the decision
to create a parser until we're sure we can make a useful one.
2020-04-09 17:19:11 +02:00
Andreas Kling
e983c745f7 Kernel: Simplify ACPI initialization a bit
Construct the parser, no matter which kind, in ACPI::initialize().
2020-04-09 14:10:44 +02:00
Andreas Kling
95e44a33c1 Kernel: Move ACPI initialization from init.cpp to ACPI::initialize() 2020-04-09 13:39:10 +02:00
Andreas Kling
7d862dd5fc AK: Reduce header dependency graph of String.h
String.h no longer pulls in StringView.h. We do this by moving a bunch
of String functions out-of-line.
2020-03-23 13:48:44 +01:00
Shannon Booth
d7133ea326 Kernel: Fix compilation error with ACPI_DEBUG enabled 2020-03-22 08:51:40 +01:00
Shannon Booth
81adefef27 Kernel: Run clang-format on files
Let's rip off the band-aid
2020-03-22 01:22:32 +01:00
Liav A
53d6fe8141 ACPI: Delete irrelevant HPET definitions
Also, the definition of the HPET ACPI table is correct now, in
accordance to the HPET specification, revision 1.0a, October 2004.
2020-03-19 15:48:00 +01:00
Liav A
e880fe0765 Kernel: Use a const reference to RegisterState in IRQ handling 2020-03-19 15:48:00 +01:00
Liav A
b13417ddb4 ACPI: Examine bit width in Generic address structure before asserting
Also, the switch-case flow is simplified for IO access within a Generic
address strucuture's handling.
2020-03-12 12:36:38 +01:00
Liav A
5d7855adea ACPI: Keep common flags in structures for later usage 2020-03-12 12:36:38 +01:00
Liav A
0f45a1b5e7 Kernel: Allow to reboot in ACPI via PCI or MMIO access
Also, we determine if ACPI reboot is supported by checking the FADT
flags' field.
2020-03-09 10:53:13 +01:00
Liav A
032ce1948e LibBareMetal: Return FlatPtr from PhysicalAddress::offset_in_page() 2020-03-09 10:53:13 +01:00
Ben Wiederhake
0edae63cc0 Kernel: Fix inconsistent inclusion style
This also makes it easier to automatically parse the dependency tree.
Thankfully, this is the only place where a change was necessary.
2020-03-08 14:09:08 +01:00
Andreas Kling
b1058b33fb AK: Add global FlatPtr typedef. It's u32 or u64, based on sizeof(void*)
Use this instead of uintptr_t throughout the codebase. This makes it
possible to pass a FlatPtr to something that has u32 and u64 overloads.
2020-03-08 13:06:51 +01:00
Liav A
5cbde297ec Meta: Claim copyright on ACPI files 2020-03-06 15:56:51 +01:00
Andreas Kling
c6693f9b3a Kernel: Simplify a bunch of dbg() and klog() calls
LogStream can handle VirtualAddress and PhysicalAddress directly.
2020-03-06 15:00:44 +01:00
Liav A
773afefe7c Kernel: Change HandlerPurpose to HandlerType
Also, GenericInterruptHandler class requires to implement two new
methods.
2020-03-06 11:19:51 +01:00
Liav A
d9d792d37f Kernel: Print MultiProcessor features 2020-03-06 10:32:32 +01:00
Liav A
85eb1d26d5 Kernel: Run clang-format on Process.cpp & ACPIDynamicParser.h 2020-03-05 19:04:04 +01:00
Liav A
1b8cd6db7b Kernel: Call ACPI reboot method first if possible
Now we call ACPI reboot method first if possible, and if ACPI reboot is
not available, we attempt to reboot via the keyboard controller.
2020-03-05 19:04:04 +01:00
Liav A
0fc60e41dd Kernel: Use klog() instead of kprintf()
Also, duplicate data in dbg() and klog() calls were removed.
In addition, leakage of virtual address to kernel log is prevented.
This is done by replacing kprintf() calls to dbg() calls with the
leaked data instead.
Also, other kprintf() calls were replaced with klog().
2020-03-02 22:23:39 +01:00
Liav A
b9c65ea746 ACPI: Adopt the changes in the definitions file
Also, the functions for StaticParsing namespace were added.
Therefore, some early access functionality is being used also
in ACPI::StaticParser class.
2020-02-29 00:12:46 +01:00
Liav A
bf55d83c1f ACPI: Reorganize the definitions file
More namespaces have been added to organize the declarations
in a more sensible way.
Also, a namespace StaticParsing has been added to allow early
access to ACPI tables.
2020-02-29 00:12:46 +01:00
Liav A
efec7448c9 ACPIStaticParser: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
4432bf41f6 DMIDecoder: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
16a5b6f7fb Kernel: Run clang-format on DMIDecoder header file 2020-02-27 13:05:12 +01:00
Liav A
fd893f834c Kernel: Don't use references or pointers to physical addresses
Now the DMIDecoder code is more safer, because we don't use raw pointers
or references to objects or data that are located in the physical
address space, so an accidental dereference cannon happen easily.
Instead, we use the PhysicalAddress class to represent those addresses.

Also, the initializer_parser() method is simplified.
2020-02-27 13:05:12 +01:00
Liav A
5ce6215af7 ACPI: Don't set Smart Pointers to be nullptr
Instead of setting the smart pointers to be nullptr in the
initializer list, it's done automatically by OwnPtr.
2020-02-24 11:27:03 +01:00
Liav A
85307dd26e Kernel: Don't use references or pointers to physical addresses
Now the ACPI & PCI code is more safer, because we don't use raw pointers
or references to objects or data that are located in the physical
address space, so an accidental dereference cannot happen easily.
Instead, we use the PhysicalAddress class to represent those addresses.
2020-02-24 11:27:03 +01:00
Liav A
740534cd67 Kernel: Update system components to use the new IRQHandler class 2020-02-24 11:27:03 +01:00
Liav A
a46120b4a8 ACPI: Run clang-format on the definitions file 2020-02-24 11:27:03 +01:00
Liav A
ebe30ed11e ACPI: Adding definitions for HPET
Also, definitions were added for MADT entries, like IOAPIC and GSI
overriding information.
2020-02-24 11:27:03 +01:00
Liav A
35f27231b3 Kernel: Fix a wrong debug message in ACPIStaticParser 2020-02-24 11:27:03 +01:00