Commit Graph

164 Commits

Author SHA1 Message Date
Pedro Falcato
3b4dade91f [bus][pci] Disable IO and mem decoding around BAR enumeration
Disable IO and mem decoding around BAR enumation as described in the PCI
Local Bus specification. This behavior should be safer when messing
around BARs for BAR lengths.
2023-01-15 18:35:49 -08:00
Travis Geiselbrecht
b990ad7999 [dev][net][e1000] just added a few comments with device ids
Was fiddling with making it work on i219 based e1000s, which was not
easily fruitful. However, may as well check in some comments with some
ids.
2022-11-02 00:28:36 -07:00
Travis Geiselbrecht
2367686854 [make] add a way for a module to opt into additional warnings
Move -Wmissing-declarations and -Wmissing-prototypes into this bucket.
Opt in most of the core top level modules in the system. More to follow.
2022-10-23 23:16:48 -07:00
Travis Geiselbrecht
611bd1cba0 [bus][pci] ask for 4MB alignment when mapping the ecam
This helps any architecture that might have a better chance with using
large pages.
2022-10-21 23:47:47 -07:00
Travis Geiselbrecht
96231b132f [bus][pci] make the pci bus dump on bootup use a little less horizontal space
Should fit better on an 80 column display
2022-10-19 00:24:10 -07:00
Travis Geiselbrecht
3a6c4aed8f [bus][pci] do not automatically initialize the bus manager in pci_init_legacy
This lets the caller do any last minute resource set up before starting
the bus manager. Is consistent with the way pci_init_ecam() works.
2022-10-18 23:58:18 -07:00
Michael Bishop
f4b2fa9a6b [dev][power][psci] refactor out of the qemu-virt-arm module 2022-09-25 18:14:50 -07:00
Wencheng Yang
853bce759d [dev][bus][pci] fixed type1_read_byte API bug
It should invoke type1_read_byte() rather than type1_read_half.
2022-08-11 23:33:15 -07:00
Travis Geiselbrecht
62e2e7dba0 [platform][pc] move the multiboot header into generic space
Share the header with arch/x86 code
Clean up the use of the boot flags
Add code to print the framebuffer information, if present
2022-08-07 23:04:23 -07:00
Travis Geiselbrecht
914c9c2a2f [dev][virtio-blk] update to newer version of the device
Nothing fundamentally changed, just update to new feature bits and print
them at device detection time.
Try to negotiate the guest feature set as well, though nothing
fundamentally changes at this time.
2022-04-26 00:40:03 -07:00
Travis Geiselbrecht
b834181637 [dev][virtio-block] fix bug when not using paging
In the non VM path the existing routine wouldn't subtract from len, so
the function would (properly) return bytes transferred instead of zero.

The wrapping code was written to assume 0 and not bytes transferred,
which seemed like a workaround for broken code. Change the inner routine
to always return bytes transferred and adjust wrapper routines
accordingly.
2022-04-25 23:37:39 -07:00
Travis Geiselbrecht
6ad3643165 [lib][minip] add an arg to the ethernet transmit callback
Already had the registration hook for it, but was never used.
2022-03-19 15:06:57 -07:00
Travis Geiselbrecht
fe28bd8a95 [lib][minip] add a mechanism to wait for the stack to be configured
Configured in this case means an ip address assigned and a nic
installed.
2022-03-19 14:46:01 -07:00
Travis Geiselbrecht
e555db5bda [bus][pci] at least register that MSIX is available
Doesn't yet have support for it, but set the bool and remember it was
present when scanning devices.
2022-02-27 19:36:59 -08:00
Travis Geiselbrecht
979cebecf2 [bus][pci] Make sure there's a fallback range in release mode 2022-02-06 20:50:24 -08:00
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
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
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
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
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
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
0257ac8c1f [dev][pcnet32] get the pcnet32 driver building and working again
Not enabled by default since it uses the experimental driver api and
depends on lwip. But, builds and works if selected.
2021-11-09 00:44:55 -08:00
Travis Geiselbrecht
a2b41c11d2 [dev][pci] move the pci console commands into the pci bus driver
Remove app/pcitests since it was just the console commands.
2021-11-09 00:19:53 -08:00
Travis Geiselbrecht
fcb65c9a88 [dev/lib][warnings] fix -Wmissing-declarations warnings in dev/ and lib/ 2021-10-21 23:16:20 -07:00
Travis Geiselbrecht
699842fad2 [dev][usb] fix a few unchecked mallocs and add some comments
A few routines had unchecked mallocs. One was unused, so remove it but
add fallback code for the rest of them.
2021-10-20 22:12:05 -07:00
Travis Geiselbrecht
01f9a97dc1 [arch][openrisc] fix up and get the OpenRISC port working again
Previous to now it had always relied on a custom patched gcc
and a custom sim. In the interim since the initial port went in
some time in 2015 GCC and QEMU have both officially picked up support
for the architecture and the machine that was emulated in the previous
emultor.

Using gcc 10.2 fix up the build and get it basically working. Timers
seem to not be working right but it's probably fairly easy to fix.
2020-10-21 02:34:50 -07:00
Travis Geiselbrecht
1272d037aa [dev][virtio] remove some extraneous __PACKED attributes
From working with -Wpacked its clear that some of the virtio
structures are overly packed and result in bad codegen on particular
architectures such as riscv. Roll back from using packed but
statically assert that the sizes are correct for some future arch
where things naturally pack differently.
2020-07-25 20:04:21 -07:00
Travis Geiselbrecht
4edb93adde [lib][console] rename some console command types to be prefixed with console_
Some of the structures, notably 'cmd', in the lib console stuff are a
little too generically named and have collided with some other code
so prefix the names a bit more cleanly with console_

The change is largely mechanical, and folks with out of tree code can
easily switch by renaming:
cmd -> console_cmd
cmd_args -> console_cmd_args
cmd_block -> console_cmd_block
console_cmd -> console_cmd_func

Apologies if this breaks you but it should be pretty easy to fix.
2020-07-25 15:59:58 -07:00
Travis Geiselbrecht
7544ff39b5 [dev] move the device/driver class api to __start __stop style symbols 2020-05-15 00:11:14 -07:00
Travis Geiselbrecht
b54f5f2b0f [dev][bus][pci] add simple type 1 (IO port based) access mode 2020-03-07 19:40:41 -08:00
Travis Geiselbrecht
389965328f [dev][bus][pci] split the bios32 routines out into a separate file
Disable bios32 mechanism based on architecture (x86-32 only) for now.
2020-03-07 18:39:35 -08:00
Travis Geiselbrecht
a44bc7863d [dev][bus][pci] move the pci driver out of platform/pc into generic space
No functional change.
2020-03-07 18:17:36 -08:00
Travis Geiselbrecht
0ec24d0b29 [dev][virtio] add no kernel VM workaround
Also add stride to the mmio detect routine. Not all virtio apertures are
tightly packed as they are on arm.
2020-01-19 16:15:58 -08:00
Travis Geiselbrecht
6cb02526b7 [include][console] split lib/console.h into two
TL;DR most uses of lib/console.h -> lk/console_cmd.h

Move the part that lets a piece of code somewhere in the system to
define a console command from the actual lib/console api to start an
instance of the console. Move in almost every place the user of the
console command definition to the new header, lk/console_cmd.h which is
always in the include path.

Also remove most uses of testing for WITH_LIB_CONSOLE since you can
almost always just safely define it and then let the linker remove it.
2019-07-13 16:56:33 -07:00
Travis Geiselbrecht
35a8d555a3 [include] move almost all of the remainder of top level includes into a subdir
Examples are include/platform.h -> platform/include/platform.h
include/target.h -> target/include/target.h

The old model generally considered these to be Always There includes,
but they're starting to stick out more and more so may as well actually
follow the model that most of the rest of the system follows.
2019-07-13 16:09:27 -07:00
Travis Geiselbrecht
cba9e47987 [license] replace the longer full MIT license with a shorter one
Used scripts/replacelic. Everything seems to build fine.
2019-07-05 17:22:23 -07:00