Commit Graph

2300 Commits

Author SHA1 Message Date
Travis Geiselbrecht
f1431b81d0 [bus][pci] Support for dynamically assigning BARs and bridges if needed
In the case of platforms where a bios or firmware has not already
assigned all the resources, do so. Requires the platform supply one or
more ranges of physical address space and IO that can be mapped into
BARs.

Handles iterating through bridges, computing the sizes of all the
peripherals downstream and rolling that up as well.
2022-02-06 19:46:39 -08:00
Travis Geiselbrecht
36e73e0fac [bus][pci] add routines to pass in PCI bus resources prior to starting the pci bus manager
Wire them up on arm and riscv which need them. x86-pc does not, so dont
call it.

Also fix a few miscellaneous bugs, notably PCI not detecting 64bit bars
properly due to an off by one bit error.
2022-02-06 19:46:39 -08:00
Travis Geiselbrecht
06ab680159 [lib][fdtwalk] add support to return the io/mmio pci aperture as well
FDT encodes the range of available mmio and io ports that the PCI bus
can use to map bars. Return this information out of the FDT walker
helper routines to feed into the PCI bus manager in the future.
2022-02-06 19:46:39 -08:00
Travis Geiselbrecht
d5f394859d [bus][pci] first stab at assigning bus numbers to unconfigured bridges
Had to rearrange the proble logic somewhat, but now the bus manager will
assign consequtive bus numbers as it finds bridges and recursively
drills down to discover the entire bus structure.

Does not assign resources yet, but need to do this in the first pass
to find all of the devices before can figure out how much space they
occupy.
2022-02-06 19:46:39 -08:00
Travis Geiselbrecht
ba21aa9236 [bus][pci] quick hack to not dive into bridges that appear unconfigured
This fixes an infinite recursion where it was stepped into bridge a
bridge that has the secondary bus set to 0, which caused it to start
over and probe bus 0 until it blew the stack.

Better fix is to actually assign busses.
2022-02-06 19:46:39 -08:00
Travis Geiselbrecht
07f847e38a [bus][pci] add accessors for bridge ranges and print on dump 2022-02-06 19:46:39 -08:00
Travis Geiselbrecht
95443413e8 [bus][pci] break the bus manager file into separate cpp files per object
No functional change aside from rearranging things.
2022-02-06 19:46:39 -08:00
Travis Geiselbrecht
5e92f0adf7 [bus][pci] move the bus manager code into a subdir 2022-02-06 19:46:39 -08:00
Travis Geiselbrecht
ef8d252a8a [bus][pci] load BARs for bridges as well
Dump them in the pci dump
2022-02-06 19:46:39 -08:00
Travis Geiselbrecht
ef67d619a5 [bus][pci] load bars for devices even if their address is 0
Probe the size first, and if that turns up anything, mark the bar as
valid, even if the address is set to 0. The address can be configured in
a later pass of the bus manager.

Also print the bars on boot.
2022-02-06 19:46:39 -08:00
Travis Geiselbrecht
2ab1af0bf3 [bus][pci] add a virtual module that references all the pci drivers
Not sure if this is the right way to go forward, but it at least keeps
from having to copy/paste the same module list in a few different
places.
2022-02-06 19:46:39 -08:00
Travis Geiselbrecht
91d5c67fc2 [platform][qemu-virt] make sure the PCI bus builds properly
Implement stubbed out versions of the msi allocation routines.

Add a stubbed out routine to allocate MSI vectors.
2022-02-06 19:46:05 -08:00
Travis Geiselbrecht
0679f91b9a [dev][net][e1000] only build with platforms with the VM enabled 2022-02-06 16:30:47 -08:00
Travis Geiselbrecht
2205aa54dc [dev][e1000] fail to start if the pci bars have not been configured 2022-02-06 15:58:28 -08:00
thomas
a7d2752b28 [kernel][vm] try the next arena if current is out of free pages 2022-01-26 12:16:53 -08:00
Travis Geiselbrecht
278c551821 [dev][pci] read and cache BAR sizes at probe time
Since probing the size of a BAR requires writing and reading back from
the address field, do it at probe time and cache the data instead of at
api time. This should avoid fouling up any mmio transactions in flight.
2022-01-11 01:24:17 -08:00
Travis Geiselbrecht
f3a337789c [dev][e1000] add an atomic counter to number the e1000s found 2022-01-11 00:15:10 -08:00
Travis Geiselbrecht
18330c5948 [arch][x86] start of cpu detection and feature detection 2022-01-09 18:20:14 -08:00
Travis Geiselbrecht
4d276a2406 [platform][pc] add a routine to read the cmos memory 2022-01-09 18:20:14 -08:00
Travis Geiselbrecht
9d94fac5e3 [minip][dhcp] convert the dhcp utility into a C++ class
Mostly jsut a consolidation of what was already an object oriented
piece of code.
2021-12-31 20:37:40 -08:00
Travis Geiselbrecht
9e80081ea6 [minip] fix warning in new changes
Building with -Werror locally.
2021-12-31 20:37:40 -08:00
Travis Geiselbrecht
35da2d1260 [minip][dhcp] spiff up the state machine to handle more edge cases
-Add TAP option to scripts/qemux86
2021-12-31 17:23:57 -08:00
Travis Geiselbrecht
0617d6c845 [scripts][do-qemux86] add ability to set the network driver 2021-12-27 22:24:31 -08:00
Travis Geiselbrecht
caafb3e2ad [dev][net][e1000] First stab at a working e1000 driver.
-Works against qemu's e1000 and e1000e driver.
-Untested on real hardware yet.
2021-12-27 22:24:31 -08:00
Travis Geiselbrecht
b5a9c2d8b2 [lib][minip] a few fixes
-Add C++ header guards around the public api.
-Fix a divide by zero bug in the test console routine.
-Add a new pktbuf api to assist with resetting a pktbuf back to default
values for reuse in an ethernet driver.
2021-12-27 22:24:31 -08:00
Travis Geiselbrecht
06105c5835 [lib][minip] fix a bug in the dhcp code
Minor bug where it would get the mac address out of sync with what the
hardware really has.
2021-12-27 22:24:31 -08:00
Travis Geiselbrecht
fb1e414a09 [dev][bus][pci] major refactor of the PCI bus driver
-Add a bus manager level, which is an object oriented walk of the pci
busses to build a per device object for later manipulation.
-Add features to enable MSI interrupts.
-Extend generic interrupt api to allow the platform to allocate vectors
for MSI interrupts.
-Rearrange a bit of the pc platform for the platform api changes.
-Add PC platform support for using the local apic to EOI MSI vectors.
-Fix up a few existing PCI drivers for small API changes.
-Add a few stubbed out routines for non PC platforms that use PCI.
2021-12-27 22:24:31 -08:00
Travis Geiselbrecht
522e62f648 [arch][x86][mmu] squelch an extraneous printf 2021-12-27 22:24:31 -08:00
Travis Geiselbrecht
be6169820d [kernel][vm] Move the VM postheap init hook back one step
This is a cheesy solution to adding another top level hook, which really
should be done.
2021-12-27 22:24:31 -08:00
Travis Geiselbrecht
b74a4e33d4 [lib][cpp] add a auto_call class
useful for calling routines at the exit of a function.
2021-12-27 19:49:14 -08:00
Travis Geiselbrecht
fa9a0a0683 [lib][cpp] add a type_traits header
mostly for std::move and friends.
2021-12-27 19:49:09 -08:00
Travis Geiselbrecht
dd438d2f1f [arch][test][mmu] add a simple test case to map a page and query the restult
Currently x86 fails the test but arm64 and riscv pass.
2021-12-05 23:24:04 -08:00
Travis Geiselbrecht
a01c181ea7 [arch][arm64] fix setting of UXN and PXN bits for NX permission
Previously would only set both UXN and PXN for no execute pages, but for
pages not marked no execute, neither bit was set. Change to mask out the
other privilege mode.
2021-12-05 23:22:54 -08:00
Travis Geiselbrecht
1a54b73e84 [arch][x86] don't set the G bit on inner page table entries
This is ignored on Intel cpus, but triggers a page fault on AMD cores.
2021-11-21 02:08:58 -08:00
Travis Geiselbrecht
a47cf76f14 [scripts][do-qemuarm] hard disable network if not selected
Turns out qemu was putting a e1000 nic on the PCI bus if no options were
selected. No reason to do so if the network is explicitly not called
for.
2021-11-20 17:42:41 -08:00
Travis Geiselbrecht
2bb32fe813 [libc][assert] add __PRINTFLIKE to assert_fail_msg()
Fix a warning as a result of this.

fixes issue #302
2021-11-12 22:07:14 -08:00
Travis Geiselbrecht
c9eae714db [platform][qemu-virt-riscv] pick the PCIE ecam out of FDT and initialize PCI bus 2021-11-12 21:23:09 -08:00
Travis Geiselbrecht
3d95143d27 [platform][qemu-virt-arm] bootstrap pci from the FDT
Look up the ECAM information out of the device tree and bootstrap the
pci bus with it.
2021-11-12 21:08:35 -08:00
Travis Geiselbrecht
a23282cc30 [platform][pc] print some ACPI table information at boot 2021-11-12 21:07:53 -08:00
Travis Geiselbrecht
b01f7083eb [lib][fdtwalk] add a callback hook to pass back pci-express information
At the moment only picks out the ECAM aperture and start/end bus
information, but enough to bootstrap the pci bus.
2021-11-12 21:05:40 -08:00
Travis Geiselbrecht
0c27d8fe45 [bus][pci] first stab at PCI-e ECAM support 2021-11-12 20:44:47 -08:00
Travis Geiselbrecht
7285a2d1fd [bus][pci] convert the pci driver's back end to simple C++ objects
It was already rolling a vtable so go ahead and just implement it as
actual c++ objects.
2021-11-12 20:44:47 -08:00
Travis Geiselbrecht
0aba1b73cc [bus][pci] trivially switch the PCI bus driver to c++
Just minimum to get it to build and work.
2021-11-12 20:44:47 -08:00
Travis Geiselbrecht
5b1041748e [libc] flesh out inttypes.h a bit more 2021-11-12 20:44:47 -08:00
Michael Bishop
4e54f0fedc [timer] make periodic timers more accurate 2021-11-12 19:31:27 -08:00
Travis Geiselbrecht
ff0f09ae4d [lib][acpi_lite] add definition of MCFG table
MCFG describes the PCIe memory configuration region. Add support for
this table and print the information on boot on PC.
2021-11-11 01:00:18 -08:00
Travis Geiselbrecht
0cf8b5b3c6 [platform][pc] add acpi_lite to the build
Probe ACPI after threads are up and running. Does nothing at the moment
except probe.
2021-11-11 00:16:40 -08:00
Travis Geiselbrecht
9de18e0828 [lib][acpi_lite] get acpi_lite building and working
Didn't require much work to port to LK, since the zircon kernel is
fairly close.

Issue #310
2021-11-11 00:16:40 -08:00
Travis Geiselbrecht
7d95b64e7e [lib][acpi_lite] import from fuchsia repository
Import verbatim at fuchsia repository at commit 645dbffdfbf52f72491187a1c59af1a677e3dd00
which is the initial commit before it was more excessively converted to
fuchsia style C++.

Issue #310
2021-11-11 00:08:33 -08:00
Travis Geiselbrecht
1550939102 [libc][inittypes] add entry for PRIxPTR 2021-11-11 00:03:39 -08:00