summaryrefslogtreecommitdiff
path: root/Kernel/Firmware
AgeCommit message (Collapse)Author
2022-10-16Kernel/SysFS: Expose file size of ACPI tables in /sys/firmware/acpiLiav A
It costs us nothing, and some utilities (such as the known file utility) rely on the exposed file size (after doing lstat on it), to show anything useful besides saying the file is "empty".
2022-10-16Kernel: Initialize primitive class member of ACPISysFSComponent to zeroLiav A
2022-10-12Kernel: Make the ACPI DSDT table accessibleminus
Expose the DSDT table in ACPI::Parser and in /sys/firmware/acpi as a first little step toward interpreting the AML bytecode from ACPI.
2022-09-23Kernel: Introduce the IOWindow classLiav A
This class is intended to replace all IOAddress usages in the Kernel codebase altogether. The idea is to ensure IO can be done in arch-specific manner that is determined mostly in compile-time, but to still be able to use most of the Kernel code in non-x86 builds. Specific devices that rely on x86-specific IO instructions are already placed in the Arch/x86 directory and are omitted for non-x86 builds. The reason this works so well is the fact that x86 IO space acts in a similar fashion to the traditional memory space being available in most CPU architectures - the x86 IO space is essentially just an array of bytes like the physical memory address space, but requires x86 IO instructions to load and store data. Therefore, many devices allow host software to interact with the hardware registers in both ways, with a noticeable trend even in the modern x86 hardware to move away from the old x86 IO space to exclusively using memory-mapped IO. Therefore, the IOWindow class encapsulates both methods for x86 builds. The idea is to allow PCI devices to be used in either way in x86 builds, so when trying to map an IOWindow on a PCI BAR, the Kernel will try to find the proper method being declared with the PCI BAR flags. For old PCI hardware on non-x86 builds this might turn into a problem as we can't use port mapped IO, so the Kernel will gracefully fail with ENOTSUP error code if that's the case, as there's really nothing we can do within such case. For general IO, the read{8,16,32} and write{8,16,32} methods are available as a convenient API for other places in the Kernel. There are simply no direct 64-bit IO API methods yet, as it's not needed right now and is not considered to be Arch-agnostic too - the x86 IO space doesn't support generating 64 bit cycle on IO bus and instead requires two 2 32-bit accesses. If for whatever reason it appears to be necessary to do IO in such manner, it could probably be added with some neat tricks to do so. It is recommended to use Memory::TypedMapping struct if direct 64 bit IO is actually needed.
2022-09-20Kernel: Move x86-specific IRQ controller code to Arch/x86 directoryLiav A
The PIC and APIC code are specific to x86 platforms, so move them out of the general Interrupts directory to Arch/x86/common/Interrupts directory instead.
2022-09-20Kernel: Move VMWare backdoor communication code to the x86 directoryLiav A
The VMWare backdoor handling code involves many x86-specific instructions and therefore should be in the Arch/x86 directory. This ensures we can easily omit the code in compile-time for non-x86 builds.
2022-08-20Kernel: Make self-contained locking smart pointers their own classesAndreas Kling
Until now, our kernel has reimplemented a number of AK classes to provide automatic internal locking: - RefPtr - NonnullRefPtr - WeakPtr - Weakable This patch renames the Kernel classes so that they can coexist with the original AK classes: - RefPtr => LockRefPtr - NonnullRefPtr => NonnullLockRefPtr - WeakPtr => LockWeakPtr - Weakable => LockWeakable The goal here is to eventually get rid of the Lock* classes in favor of using external locking.
2022-08-20AK+Kernel: Add AK::AtomicRefCounted and use everywhere in the kernelAndreas Kling
Instead of having two separate implementations of AK::RefCounted, one for userspace and one for kernelspace, there is now RefCounted and AtomicRefCounted.
2022-07-15Kernel/SysFS: Mark SysFSDirectory traverse and lookup methods as finalLiav A
This enforces us to remove duplicated code across the SysFS code. This results in great simplification of how the SysFS works now, because we enforce one way to treat SysFSDirectory objects.
2022-07-12Everywhere: Add sv suffix to strings relying on StringView(char const*)sin-ack
Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.
2022-07-12Kernel: Annotate all `KBuffer` and `DoubleBuffer` with a custom nameTim Schumacher
2022-06-17Kerenl/Firmware: Add map_ebda and map_bios methods in the original placeLiav A
In a previous commit I moved everything into the new subdirectories in FileSystem/SysFS directory without trying to actually make changes in the code itself too much. Now it's time to split the code to make it more readable and understandable, hence this change occurs now.
2022-06-17Kernel/SysFS: Stop cluttering the codebase with pieces of SysFS partsLiav A
Instead, start to put everything in one place to resemble the directory structure of the SysFS when actually using it.
2022-06-02Kernel: Implement InterruptDisabler using generic Processor functionsTimon Kruiper
Now that the code does not use architectural specific code, it is moved to the generic Arch directory and the paths are modified accordingly.
2022-04-20Kernel: Move VMWareBackdoor to new directory in the Firmware directoryLiav A
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-04-01Kernel: Allow SysFS components to have non-zero sizeLiav A
This is important for dmidecode because it does an fstat on the DMI blobs, trying to figure out their size. Because we already know the size of the blobs when creating the SysFS components, there's no performance penalty whatsoever, and this allows dmidecode to not use the /dev/mem device as a fallback.
2022-04-01Kernel: Declare DMI SysFS BIOS classes as finalLiav A
2022-04-01Kernel: Declare blob sizes of SysFS BIOS classes as constLiav A
2022-04-01Kernel: Initialize primitive data members of SysFS BIOS classesLiav A
2022-02-09Kernel: Change static constexpr variables to constexpr where possibleLenny Maiorani
Function-local `static constexpr` variables can be `constexpr`. This can reduce memory consumption, binary size, and offer additional compiler optimizations. These changes result in a stripped x86_64 kernel binary size reduction of 592 bytes.
2022-01-21Kernel: Replace {String => KString}::formatted in ACPISysFSDirectoryIdan Horowitz
2022-01-21Kernel: Make ACPI reboot OOM-fallibleIdan Horowitz
2022-01-18Kernel: Don't populate the ACPI SysFS directory with a disabled ACPIIdan Horowitz
This would cause a nullptr dereference on ACPI::Parser::the().
2022-01-13Kernel: Make map_typed() & map_typed_writable() fallible using ErrorOrIdan Horowitz
This mostly just moved the problem, as a lot of the callers are not capable of propagating the errors themselves, but it's a step in the right direction.
2022-01-13Kernel: Make map_bios() and map_ebda() fallible using ErrorOrIdan Horowitz
2022-01-07Everywhere: Fix many spelling errorsmjz19910
2022-01-05Kernel: Use MUST + Vector::try_empend instead of Vector::empendBrian Gianforcaro
In preparation for making Vector::empend unavailable during compilation of the Kernel.
2022-01-05Kernel: Use MUST + Vector::try_append instead of Vector::appendBrian Gianforcaro
In preparation for making Vector::append unavailable during compilation of the Kernel.
2022-01-04Kernel: Scan ACPI memory ranges for the RSDP tableTom
On some systems the ACPI RSDP table may be located in ACPI reserved memory ranges rather than in the EBDA or BIOS areas.
2022-01-04Kernel: Fix determining EBDA sizeTom
The first byte of the EBDA structure contains the size of the EBDA in 1 KiB units. We were incorrectly using the word at offset 0x413 of the BDA which specifies the number of KiB before the EBDA structure.
2021-12-28Kernel: Propagate overflow errors from Memory::page_round_upGuilherme Goncalves
Fixes #11402.
2021-12-23Kernel: Move Multi Processor Parser code to a separate directoryLiav A
2021-12-14Kernel/SysFS: Don't allocate ACPISysFS components in constructorsLiav A
Instead defer it to a method to be called after the construction of ACPISysFSDirectory.
2021-12-14Kernel/SysFS: Make it clear that some components must be created in bootLiav A
Using the phrase "create" doesn't give information on whether the object must be allocated or a failure to do so can be handled gracefully. Therefore, we must use better phrase for such purpose, so "must_create" for the allocate-and-construct static methods is definitely good choice.
2021-12-14Kernel/SysFS: Prevent allocation for component name during constructionLiav A
Instead, allocate before constructing the object and pass NonnullOwnPtr of KString to the object if needed. Some classes can determine their names as they have a known attribute to look for or have a static name.
2021-12-11Everywhere: Fix -Winconsistent-missing-override warnings from ClangDaniel Bertalan
This option is already enabled when building Lagom, so let's enable it for the main build too. We will no longer be surprised by Lagom Clang CI builds failing while everything compiles locally. Furthermore, the stronger `-Wsuggest-override` warning is enabled in this commit, which enforces the use of the `override` keyword in all classes, not just those which already have some methods marked as `override`. This works with both GCC and Clang.
2021-12-09Kernel: Mark ACPI::Parser's empty destructor as defaultHendiadyoin1
2021-11-11Everywhere: Pass AK::StringView by valueAndreas Kling
2021-11-10AK+Everywhere: Stop including Vector.h from StringView.hAndreas Kling
Preparation for using Error.h from Vector.h. This required moving some things out of line.
2021-11-08Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T>Andreas Kling
We now use AK::Error and AK::ErrorOr<T> in both kernel and userspace! This was a slightly tedious refactoring that took a long time, so it's not unlikely that some bugs crept in. Nevertheless, it does pass basic functionality testing, and it's just real nice to finally see the same pattern in all contexts. :^)
2021-11-02Kernel: Switch BIOSSysFSComponent constructor to AK::StringViewBrian Gianforcaro
These are constants, they don't need to be dynamically allocated. Another minor step towards removing `AK::String` from the Kernel and improving OOM safety.
2021-10-09Kernel/SysFS: Provide a way to "truncate" and "set" mtime on inodesLiav A
Normally, trying to truncate a SysFSInode should result in EPERM error. However, as suggested by Ali (@alimpfard), we can allow the PowerState node to be "truncated" so one can open that file with O_TRUNC option. Likewise, we also need to provide a way to set modified time on SysFS inodes. For most inodes, we should return ENOTIMPL error, but for the power state switch, we ignore the modified time setting and just return KSuccess. These fixes allow to do "echo -n 1 > /sys/firmware/power_state" in Shell after gaining root permissions, to switch the power state.
2021-10-03Kernel: Use `operator ""sv` in all purpose() implementationsBrian Gianforcaro
Previously there was a mix of returning plain strings and returning explicit string views using `operator ""sv`. This change switches them all to standardized on `operator ""sv` as it avoids a call to strlen.
2021-10-01Kernel: Move x86 IO instructions code into the x86 specific folderLiav A
2021-09-12Kernel+Userland: Introduce a new way to reboot and poweroff the machineLiav A
This change removes the halt and reboot syscalls, and create a new mechanism to change the power state of the machine. Instead of how power state was changed until now, put a SysFS node as writable only for the superuser, that with a defined value, can result in either reboot or poweroff. In the future, a power group can be assigned to this node (which will be the GroupID responsible for power management). This opens an opportunity to permit to shutdown/reboot without superuser permissions, so in the future, a userspace daemon can take control of this node to perform power management operations without superuser permissions, if we enforce different UserID/GroupID on that node.
2021-09-12Kernel: Unify BIOS and ACPI components in the SysFS firmware directoryLiav A
Both should reside in the SysFS firmware directory which is normally located in /sys/firmware. Also, apply some OOM-safety patterns when creating the BIOS and ACPI directories.
2021-09-12Kernel: Move ACPI and BIOS code into the new Firmware directoryLiav A
This will somwhat help unify them also under the same SysFS directory in the commit. Also, it feels much more like this change reflects the reality that both ACPI and the BIOS are part of the firmware on x86 computers.