summaryrefslogtreecommitdiff
path: root/Kernel/PCI
AgeCommit message (Collapse)Author
2021-07-02Kernel/PCI: Move the PCI components as a subfolder to the Bus directoryLiav A
2021-06-30Kernel/PCI: Keep track of the currently mapped bus in MMIO modeLuke
There is a check in map_bus_region to make sure we don't pointlessly remap the bus region if the previous mapping was for the same bus. This is tracked with `m_mapped_bus`. However, nothing was actually updating `m_mapped_bus`, and it is initialised to 0. This means that if we start with a device on bus 0, the read in data will be valid. If we map say bus 1 then bus 0 again, the map for bus 0 will now be ignored and invalid data will be read in. Fixed by updating `m_mapped_bus` with the currently mapped bus.
2021-06-30Kernel/PCI: Don't unmap determine_memory_mapped_bus_region after initLuke
This can be accessed after init via lspci.
2021-06-29Kernel/SysFS: Add PCI exposed folderLiav A
2021-06-25Kernel: Add VirtIOGPU graphics deviceSahan Fernando
2021-06-24Kernel: Move special sections into Sections.hHendiadyoin1
This also removes a lot of CPU.h includes infavor for Sections.h
2021-06-24Kernel: Pull apart CPU.hHendiadyoin1
This does not add any functional changes
2021-06-20Kernel: Allow VGA-capable graphics adapters to exist with legacy VGATom
If we have a VGA-capable graphics adapter that we support, we should prefer it over any legacy VGA because we wouldn't use it in legacy VGA mode in this case. This solves the problem where we would only use the legacy VGA card when both a legacy VGA card as well as a VGA-mode capable adapter is present.
2021-06-10Kernel: Add driver for RTL8168 & RTL8111 NICsIdan Horowitz
These are pretty common on older LGA1366 & LGA1150 motherboards. NOTE: Since the registers datasheets for all versions of the chip besides versions 1 - 3 are still under NDAs i had to collect several "magical vendor constants" from the *BSD driver and the linux driver that i was not able to name verbosely, and as such these are labeled with the comment "vendor magic values".
2021-06-09Kernel/PCI: Remove UNMAP_AFTER_INIT from a few methodsLiav A
This fixes #7942. We can't unmap these methods because they can be called after the boot process from lspci(8) utility, or by using the SystemMonitor program (and looking into the "PCI devices" tab).
2021-06-09Kernel: Mark MMIOAccess detection function as UNMAP_AFTER_INITBrian Gianforcaro
2021-06-09Kernel: Mark PCI Access enumeration functions as UNMAP_AFTER_INITBrian Gianforcaro
2021-05-21Kernel/PCI: Fix support of multiple PCI host controllers enumerationLiav A
First scan PCI bus 0. Find any device on that bus, and if it's a PCI-to-PCI bridge, recursively scan it too. Then try to handle Multiple PCI host bridges on slot 0, device 0. If we happen to miss some PCI buses because they are not reachable through recursive PCI-to-PCI bridges scanning starting from bus 0, we might find them in this scanning.
2021-05-17Kernel: Add support for QEMU's emulated pci serial (-pci-serial option)Idan Horowitz
2021-05-17Kernel: Implement a PCI Serial Device driverIdan Horowitz
This simple driver simply finds a device in a device definitions list and then sets up a SerialDevice instance based on the definition. The driver currently only supports "WCH CH382 2S" pci serial boards, as that is the only device available for me to test with, but most other pci serial devices should be as easily addable as adding a board_definitions entry.
2021-05-16Kernel/PCI: Add helper to determine if device can access IO spaceLiav A
2021-05-01Everywhere: Turn #if *_DEBUG into dbgln_if/if constexprGunnar Beutner
2021-04-27Kernel: Move PCI vendor and device IDs into Kernel/PCI/IDs.hGunnar Beutner
2021-04-26Kernel/PCI: Add helpers to enable IO and memory accessesLiav A
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-17Kernel: Add base support for VirtIO devicesIdan Horowitz
Based on pull #3236 by tomuta, this adds helper methods for generic device initialization, and partily-broken virtqueue helper methods Co-authored-by: Tom <tomut@yahoo.com> Co-authored-by: Sahan <sahan.h.fernando@gmail.com>
2021-04-17Kernel: Add PCI::get_BAR convenience methodIdan Horowitz
Based on pull #3236 by tomuta Co-authored-by: Tom <tomut@yahoo.com>
2021-04-17Kernel: Convert PCI Capability struct to class with convenience methodsIdan Horowitz
Based on pull #3236 by tomuta Co-authored-by: Tom <tomut@yahoo.com>
2021-04-15Everything: Add `-Wnon-virtual-dtor` flagNicholas-Baron
This flag warns on classes which have `virtual` functions but do not have a `virtual` destructor. This patch adds both the flag and missing destructors. The access level of the destructors was determined by a two rules of thumb: 1. A destructor should have a similar or lower access level to that of a constructor. 2. Having a `private` destructor implicitly deletes the default constructor, which is probably undesirable for "interface" types (classes with only virtual functions and no data). In short, most of the added destructors are `protected`, unless the compiler complained about access.
2021-04-06Kernel/PCI + CPU: Allow to access unaligned dataLiav A
2021-04-06Kernel/PCI: Don't expose virtual addresses on the kernel logLiav A
2021-04-03Kernel/PCI: Introduce a new ECAM access mechanismLiav A
Now the kernel supports 2 ECAM access methods. MMIOAccess was renamed to WindowedMMIOAccess and is what we had until now - each device that is detected on boot is assigned to a memory-mapped window, so IO operations on multiple devices can occur simultaneously due to creating multiple virtual mappings, hence the name is a memory-mapped window. This commit adds a new class called MMIOAccess (not to be confused with the old MMIOAccess class). This class creates one memory-mapped window. On each IO operation on a configuration space of a device, it maps the requested PCI bus region to that window. Therefore it holds a SpinLock during the operation to ensure that no other PCI bus region was mapped during the call. A user can choose to either use PCI ECAM with memory-mapped window for each device, or for an entire bus. By default, the kernel prefers to map the entire PCI bus region.
2021-04-03Kernel: Enable PCI ECAM method again if availableLiav A
Apparently we don't enable PCI ECAM (MMIO access to the PCI configuration space) even if we can. This is a regression, as it was enabled in the past and in unknown time it was regressed. The CommandLine::is_mmio_enabled method was renamed to CommandLine::is_pci_ecam_enabled to better represent the meaning of this method and what it determines. Also, an UNMAP_AFTER_INIT macro was removed from a method in the MMIOAccess class as it halted the system when the kernel tried to access devices after the boot process.
2021-04-03Revert "Kernel/PCI: Allow to set the PCI IRQ line of a device"Liav A
This reverts commit 36a82188a88c95315e03f6fcede237bc66831702. This register is write-only for the firmware (BIOS), and read-only for us so we shouldn't set the PCI IRQ line never. The firmware figured out the IRQ routing to the PIC for us, so changing it won't affect anything. I was mistaken when I thought that changing the value of this register will allow us to change its interrupt line, like when changing a PCI BAR to relocate device resources as desired with the requirements of the OS.
2021-03-21Kernel/PCI: Allow to set the PCI IRQ line of a deviceLiav A
This will be used later by the AHCI code to set the IRQ line to be 11, if hardware by mistake changed the value to be something we can't deal with.
2021-03-12Everywhere: Remove klog(), dbg() and purge all LogStream usage :^)Andreas Kling
Good-bye LogStream. Long live AK::Format!
2021-03-12Kernel: Convert klog() => AK::Format in PCIAndreas Kling
2021-03-04Everywhere: Remove unnecessary `clang-format off`sWilliam McPherson
Mostly due to the fact that clang-format allows aligned comments via AlignTrailingComments. We could also use raw string literals in inline asm, which clang-format deals with properly (and would be nicer in a lot of places).
2021-03-03Kernel: Move Kernel CommandLine parsing to strongly typed API.Brian Gianforcaro
Previously all of the CommandLine parsing was spread out around the Kernel. Instead move it all into the Kernel CommandLine class, and expose a strongly typed API for querying the state of options.
2021-02-28Kernel: Use default con/de-structorsBen Wiederhake
This may seem like a no-op change, however it shrinks down the Kernel by a bit: .text -432 .unmap_after_init -60 .data -480 .debug_info -673 .debug_aranges 8 .debug_ranges -232 .debug_line -558 .debug_str -308 .debug_frame -40 With '= default', the compiler can do more inlining, hence the savings. I intentionally omitted some opportunities for '= default', because they would increase the Kernel size.
2021-02-23Everywhere: Rename ASSERT => VERIFYAndreas Kling
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED) Since all of these checks are done in release builds as well, let's rename them to VERIFY to prevent confusion, as everyone is used to assertions being compiled out in release. We can introduce a new ASSERT macro that is specifically for debug checks, but I'm doing this wholesale conversion first since we've accumulated thousands of these already, and it's not immediately obvious which ones are suitable for ASSERT.
2021-02-19Kernel: Slap UNMAP_AFTER_INIT on a bunch more functionsAndreas Kling
We're now able to unmap 100 KiB of kernel text after init. :^)
2021-02-17Kernel: Convert dbgprintf()/klog() => dbgln()/dmesgln() in UHCI codeAndreas Kling
2021-02-14Kernel: Assert if rounding-up-to-page-size would wrap around to 0Andreas Kling
If we try to align a number above 0xfffff000 to the next multiple of the page size (4 KiB), it would wrap around to 0. This is most likely never what we want, so let's assert if that happens.
2021-02-14Kernel: Use PANIC() in a bunch of places :^)Andreas Kling
2021-02-08Everywhere: Replace dbgln<flag>(...) with dbgln_if(flag, ...)AnotherTest
Replacement made by `find Kernel Userland -name '*.h' -o -name '*.cpp' | sed -i -Ee 's/dbgln\b<(\w+)>\(/dbgln_if(\1, /g'`
2021-01-31Kernel: Fix PCI bridge enumerationJean-Baptiste Boric
The enumeration code is already enumerating all buses, recursively enumerating bridges (which are buses) makes devices on bridges being enumerated multiple times. Also, the PCI code was incorrectly mixing up terminology; let's settle down on bus, device and function because ever since PCIe came along "slots" isn't really a thing anymore.
2021-01-26Meta: Split debug defines into multiple headers.asynts
The following script was used to make these changes: #!/bin/bash set -e tmp=$(mktemp -d) echo "tmp=$tmp" find Kernel \( -name '*.cpp' -o -name '*.h' \) | sort > $tmp/Kernel.files find . \( -path ./Toolchain -prune -o -path ./Build -prune -o -path ./Kernel -prune \) -o \( -name '*.cpp' -o -name '*.h' \) -print | sort > $tmp/EverythingExceptKernel.files cat $tmp/Kernel.files | xargs grep -Eho '[A-Z0-9_]+_DEBUG' | sort | uniq > $tmp/Kernel.macros cat $tmp/EverythingExceptKernel.files | xargs grep -Eho '[A-Z0-9_]+_DEBUG' | sort | uniq > $tmp/EverythingExceptKernel.macros comm -23 $tmp/Kernel.macros $tmp/EverythingExceptKernel.macros > $tmp/Kernel.unique comm -1 $tmp/Kernel.macros $tmp/EverythingExceptKernel.macros > $tmp/EverythingExceptKernel.unique cat $tmp/Kernel.unique | awk '{ print "#cmakedefine01 "$1 }' > $tmp/Kernel.header cat $tmp/EverythingExceptKernel.unique | awk '{ print "#cmakedefine01 "$1 }' > $tmp/EverythingExceptKernel.header for macro in $(cat $tmp/Kernel.unique) do cat $tmp/Kernel.files | xargs grep -l $macro >> $tmp/Kernel.new-includes ||: done cat $tmp/Kernel.new-includes | sort > $tmp/Kernel.new-includes.sorted for macro in $(cat $tmp/EverythingExceptKernel.unique) do cat $tmp/Kernel.files | xargs grep -l $macro >> $tmp/Kernel.old-includes ||: done cat $tmp/Kernel.old-includes | sort > $tmp/Kernel.old-includes.sorted comm -23 $tmp/Kernel.new-includes.sorted $tmp/Kernel.old-includes.sorted > $tmp/Kernel.includes.new comm -13 $tmp/Kernel.new-includes.sorted $tmp/Kernel.old-includes.sorted > $tmp/Kernel.includes.old comm -12 $tmp/Kernel.new-includes.sorted $tmp/Kernel.old-includes.sorted > $tmp/Kernel.includes.mixed for file in $(cat $tmp/Kernel.includes.new) do sed -i -E 's/#include <AK\/Debug\.h>/#include <Kernel\/Debug\.h>/' $file done for file in $(cat $tmp/Kernel.includes.mixed) do echo "mixed include in $file, requires manual editing." done
2021-01-25Everywhere: Debug macros instead of constexpr.asynts
This was done with the following script: find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/dbgln<debug_([a-z_]+)>/dbgln<\U\1_DEBUG>/' {} \; find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/if constexpr \(debug_([a-z0-9_]+)/if constexpr \(\U\1_DEBUG/' {} \;
2021-01-25Everywhere: Remove unnecessary debug comments.asynts
It would be tempting to uncomment these statements, but that won't work with the new changes. This was done with the following commands: find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec awk -i inplace '$0 !~ /\/\/#define/ { if (!toggle) { print; } else { toggle = !toggle } } ; $0 ~/\/\/#define/ { toggle = 1 }' {} \; find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec awk -i inplace '$0 !~ /\/\/ #define/ { if (!toggle) { print; } else { toggle = !toggle } } ; $0 ~/\/\/ #define/ { toggle = 1 }' {} \;
2021-01-25Everywhere: Use CMake to generate AK/Debug.h.asynts
This was done with the help of several scripts, I dump them here to easily find them later: awk '/#ifdef/ { print "#cmakedefine01 "$2 }' AK/Debug.h.in for debug_macro in $(awk '/#ifdef/ { print $2 }' AK/Debug.h.in) do find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/#ifdef '$debug_macro'/#if '$debug_macro'/' {} \; done # Remember to remove WRAPPER_GERNERATOR_DEBUG from the list. awk '/#cmake/ { print "set("$2" ON)" }' AK/Debug.h.in
2021-01-22Everywhere: Replace a bundle of dbg with dbgln.asynts
These changes are arbitrarily divided into multiple commits to make it easier to find potentially introduced bugs with git bisect.
2021-01-22Everywhere: Replace a bundle of dbg with dbgln.asynts
These changes are arbitrarily divided into multiple commits to make it easier to find potentially introduced bugs with git bisect.
2021-01-09Everywhere: Replace a bundle of dbg with dbgln.asynts
These changes are arbitrarily divided into multiple commits to make it easier to find potentially introduced bugs with git bisect.Everything: The modifications in this commit were automatically made using the following command: find . -name '*.cpp' -exec sed -i -E 's/dbg\(\) << ("[^"{]*");/dbgln\(\1\);/' {} \;
2021-01-09Everywhere: Replace a bundle of dbg with dbgln.asynts
These changes are arbitrarily divided into multiple commits to make it easier to find potentially introduced bugs with git bisect.