Commit Graph

51 Commits

Author SHA1 Message Date
Andreas Kling
03eb0e5638 Kernel: Let's say that IO::delay(N) delays for N microseconds
Supposedly that's how much delay you get when doing I/O on port 0x80.
2020-05-16 10:55:54 +02:00
Shannon Booth
113a95e9e1 Kernel: Annotate UnhandledInterruptHandler::eoi with [[noreturn]] 2020-05-16 09:51:31 +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
0fa50b6405 Interrupts: Simplify initialization a bit more 2020-04-09 20:45:44 +02:00
Liav A
6b38befd91 Interrupts: Remove irrelevant FIXME comment 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
Liav A
8139688ef1 Kernel: Simplify the Interrupt management initialization 2020-04-09 19:59:53 +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
Liav A
5f579904c1 Interrupts: Handle spurious IRQs from eoi() method 2020-03-24 16:15:33 +01:00
Liav A
8d9b6c57b5 Interrupts: Use Optional container in IOAPIC
We return the Optional container in find_redirection_entry_by_vector()
method instead of a raw integer. This makes the code more readable and
correct.
2020-03-24 16:15:33 +01:00
Liav A
0b7fc525e1 Interrupts: Simplify IRQ disabling & enabling in IRQController(s)
Instead of blindly setting masks, if we want to disable an IRQ and it's
already masked, we just return. The same happens if we want to enable an
IRQ and it's unmasked.
2020-03-24 16:15:33 +01:00
Liav A
3f98a67d75 Interrupts: Remove unused methods 2020-03-24 16:15:33 +01:00
Liav A
8b38be3072 Kernel: Simplify disable_irq() and enable_irq() methods in IRQHandler
Setting the m_enabled variable to true or false can help
with monitoring the IRQHandler object(s) later, and there's no good
reason to have an if-else statement in those methods anyway.
2020-03-24 16:15:33 +01:00
Liav A
cb676f1211 Interrupts: Do a specific EOI when using the PIC
Before this change, we did a non-specific EOI, which could lead to
problems with other IRQs that are handled in the PIC. Since the original
8259A datasheet permits such functionality and we are not losing any
functionality, this change is acceptable even though we don't experience
problems with the EOI currently.
2020-03-24 16:15:33 +01:00
Liav A
dbc536e917 Interrupts: Assert if trying to install an handler on syscall vector
Installing an interrupt handler on the syscall IDT vector can lead to
fatal results, so we must assert if that happens.
2020-03-24 16:15:33 +01:00
Liav A
f86be46c98 Kernel: Abstract IRQ controller handling from Interrupt handlers
Now we don't send raw numbers, but we let the IRQController object to
figure out the correct IRQ number.
This helps in a situation when we have 2 or more IOAPICs, so if IOAPIC
1 is assigned for IRQs 0-23 and IOAPIC 2 is assigned for IRQs 24-47,
if an IRQHandler of IRQ 25 invokes disable() for example, it will call
his responsible IRQController (IOAPIC 2), and the IRQController will
subtract the IRQ number with his assigned offset, and the result is that
the second redirection entry in IOAPIC 2 will be masked.
2020-03-24 16:15:33 +01:00
Liav A
666990fbcb Kernel: Correct Spurious Interrupt handlers' controller model() method
We don't return blindly the IRQ controller's model(), if the Spurious
IRQ handler is installed in IOAPIC environment, it's misleading to
return "IOAPIC" string since IOAPIC doesn't really handle Spurious
IRQs, therefore we return a "" string.
2020-03-24 16:15:33 +01:00
Liav A
4cc96a7aa9 Kernel: Create an interface for conversion between IRQs and interrupts 2020-03-24 16:15:33 +01:00
Liav A
c2c0e9fb04 Kernel: Ensure that we don't use a hard-disabled IRQController 2020-03-24 16:15:33 +01:00
Liav A
7c859efa85 Kernel: Change the Spurious Interrupt Handler offset in the APIC
The Spurious Interrupt Handler number that is written to
APIC_REG_SIV is correct now.
2020-03-24 16:15:33 +01: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
81adefef27 Kernel: Run clang-format on files
Let's rip off the band-aid
2020-03-22 01:22:32 +01:00
Liav A
a0a7204915 Interrupts: Add an interface to determine if SMP is enabled 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
032ce1948e LibBareMetal: Return FlatPtr from PhysicalAddress::offset_in_page() 2020-03-09 10:53:13 +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
e2889e665f Kernel: Shorten the model name of i8529 PIC class 2020-03-06 11:19:51 +01:00
Liav A
7ef5d222f1 Kernel: Change data in /proc/interrupts to be more richer
Also, during interrupt handlers' enumeration, we call all interrupts
handlers that are not UnhandledInterruptHandler.
2020-03-06 11:19:51 +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
c335c94242 Kernel: Simplify APIC::enable()
We install a SpuriousInterruptHandler when calling APIC::enable(),
and we don't enable local interrupts for now.
2020-03-06 10:32:32 +01:00
Liav A
30fc78bfaf Kernel: Acquire ISA interrupt overrides from Interrupt Management
Also, InterruptDisabler were added to prevent critical function from
being interrupted. In addition, the interrupt numbers are abstracted
from IDT offsets, thus, allowing to create a better routing scheme
when using IOAPICs for interrupt redirection.
2020-03-06 10:32:32 +01:00
Liav A
f0ca29eb4b Kernel: Run clang-format on various files 2020-03-02 22:23:39 +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
6f914ed0a4 Kernel: Simplify interrupt management
The IRQController object is RefCounted, and is shared between the
InterruptManagement class & IRQ handlers' classes.

IRQHandler, SharedIRQHandler & SpuriousInterruptHandler classes
use a responsible IRQ controller directly instead of calling
InterruptManagement for disable(), enable() or eoi().

Also, the initialization process of InterruptManagement is
simplified, so it doesn't rely on an ACPI parser to be initialized.
2020-02-29 00:12:46 +01:00
Liav A
976562307a Kernel: Initialize Spurious IRQ handlers in switch_to_pic_mode() 2020-02-29 00:12:46 +01:00
Liav A
800a46ace9 Kernel: Delete unnecessary register & unregister calls 2020-02-29 00:12:46 +01:00
Liav A
b2e5425426 Kernel: Add SpuriousInterruptHandler class
This type of interrupt handler should handle spurious IRQs.
2020-02-29 00:12:46 +01:00
Liav A
e22ab33a4d Kernel: Add SpuriousInterruptHandler type into HandlerPurpose 2020-02-29 00:12:46 +01:00
Liav A
946d9b8c24 IOAPIC: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +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
fe664965c2 Kernel: Change get_sharing_devices_count() in GenericInterruptHandler
The new method' name is sharing_devices_count().
The Serenity Coding Style tends to not accept the word "get" in
methods' names if possible.
2020-02-24 11:27:03 +01:00
Liav A
9e66eb160c Kernel: Add the new APIC namespace
Also, the enable() function is now correct and will use the right
registers and values. In addition to that, write_register() and
read_registers() are not relying on identity mapping anymore.
2020-02-24 11:27:03 +01:00
Liav A
12dbb7ca49 Kernel: Add MSIHandler class
This is a stub for now, since we don't support Message Signaled
Interrupts yet.
2020-02-24 11:27:03 +01:00
Liav A
9d281b4b15 Kernel: Add UnhandledInterruptHandler class
This class will be used to represent an IRQ vector handler that wasn't
assigned to any IRQ Handler.
2020-02-24 11:27:03 +01:00
Liav A
9587f2d3ee Kernel: Add SharedIRQHandler class
This class represents a shared interrupt handler. This class will not be
created automatically but only if two IRQ Handlers are sharing the same
IRQ number.
2020-02-24 11:27:03 +01:00
Liav A
dd7522bdb2 Kernel: Add new IRQHandler class
This class will replace the old IRQHandler class later.
2020-02-24 11:27:03 +01:00
Liav A
b201b23363 Kernel: Add Interrupt Management and Generic Interrupt Handler
The GenericInterruptHandler class will be used to represent
an abstract interrupt handler. The InterruptManagement class will
represent a centralized component to manage interrupts.
2020-02-24 11:27:03 +01:00
Liav A
e760ebcacb Kernel: Add the IOAPIC class
This class inherits from IRQController class, and represents
the 82093AA IOAPIC chip.
2020-02-24 11:27:03 +01:00
Liav A
7d59a67504 Kernel: Add the PIC class
This class inherits from IRQController class, and represents
the common Intel 8259 PIC chip.
2020-02-24 11:27:03 +01:00