Commit Graph

15 Commits

Author SHA1 Message Date
Andreas Kling
93d98d4976 Kernel: Move Kernel/Memory/ code into Kernel::Memory namespace 2021-08-06 14:05:58 +02:00
Andreas Kling
a1d7ebf85a Kernel: Rename Kernel/VM/ to Kernel/Memory/
This directory isn't just about virtual memory, it's about all kinds
of memory management.
2021-08-06 14:05:58 +02:00
Liav A
6568bb47cb Kernel/PCI: Move the PCI components as a subfolder to the Bus directory 2021-07-02 13:16:12 +02:00
Liav A
b91df26d4a Kernel/Interrupts: Return boolean on whether we handled the interrupt
If we are in a shared interrupt handler, the called handlers might
indicate it was not their interrupt, so we should not increment the
call counter of these handlers.
2021-06-17 16:53:25 +02:00
Sahan Fernando
7cf34b5549 Kernel: Rename VirtIODevice::clear_status_bit to mask_status_bits 2021-05-15 23:29:03 +01:00
Sahan Fernando
ed0e7b53a5 Kernel: Move VirtIO code away from using a scatter gather list
Currently, when passing buffers into VirtIOQueues, we use scatter-gather
lists, which contain an internal vector of buffers. This vector is
allocated, filled and the destroy whenever we try to provide buffers
into a virtqueue, which would happen a lot in performance cricital code
(the main transport mechanism for certain paravirtualized devices).

This commit moves it over to using VirtIOQueueChains and building the
chain in place in the VirtIOQueue. Also included are a bunch of fixups
for the VirtIO Console device, making it use an internal VM::RingBuffer
instead.
2021-05-13 10:00:42 +02:00
Sahan Fernando
8131c0de8c Kernel: Move AHCIPort::ScatterList to VM::ScatterGatherList
We want to move this out of the AHCI subsystem into the VM system,
since other parts of the kernel may need to perform scatter-gather IO.

We rename the current VM::ScatterGatherList impl that's used in the
virtio subsystem to VM::ScatterGatherRefList, since its distinguishing
feature from the AHCI scatter-gather list is that it doesn't own its
buffers.
2021-05-13 10:00:42 +02:00
Gunnar Beutner
bf703ee553 Kernel: Move PCI vendor and device IDs into Kernel/PCI/IDs.h 2021-04-27 11:36:24 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
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-22 11:22:27 +02:00
Sahan Fernando
45f97c1096 Kernel: Make VirtIOConsole block when VirtIOQueue is full 2021-04-18 13:04:55 +02:00
Idan Horowitz
d1f7a2f9a5 Kernel: Finish base implementation of VirtQueues
This commit includes a lot of small changes and additions needed to
finalize the base implementation of VirtIOQueues and VirtDevices:
* The device specific driver implementation now has to handle setting
up the queues it needs before letting the base device class know it
finised initialization
* Supplying buffers to VirtQueues is now done via ScatterGatherLists
instead of arbitary buffer pointers - this ensures the pointers are
physical and allows us to follow the specification in regards to the
requirement that individual descriptors must point to physically
contiguous buffers. This can be further improved in the future by
implementating support for the Indirect-Descriptors feature (as
defined by the specification) to reduce descriptor usage for very
fragmented buffers.
* When supplying buffers to a VirtQueue the driver must supply a
(temporarily-)unique token (usually the supplied buffer's virtual
address) to ensure the driver can discern which buffer has finished
processing by the device in the case in which the device does not
offer the F_IN_ORDER feature.
* Device drivers now handle queue updates (supplied buffers being
returned from the device) by implementing a single pure virtual
method instead of setting a seperate callback for each queue
* Two new VirtQueue methods were added to allow the device driver
to either discard or get used/returned buffers from the device by
cleanly removing them off the descriptor chain (This also allows
the VirtQueue implementation to reuse those freed descriptors)

This also includes the necessary changes to the VirtIOConsole
implementation to match these interface changes.

Co-authored-by: Sahan <sahan.h.fernando@gmail.com>
2021-04-17 10:21:23 +02:00
Idan Horowitz
ecfa7cb824 Kernel: Implement a naive version of virtconsole by memcpying to physical page
This patch allocates a physical page for each of the virtqueues and
memcpys to it when receiving a buffer to get a physical, aligned
contiguous buffer as required by the virtio specification.

Co-authored-by: Sahan <sahan.h.fernando@gmail.com>
2021-04-17 10:21:23 +02:00
Idan Horowitz
42b1eb5af1 Kernel: Activate queues and enable interrutps in VirtIODevices
This patch actually enables virtio queues after configuring them
so the device can use them, it also enables interrupt handling in
VirtIODevice so they are not ignored.

Co-authored-by: Sahan <sahan.h.fernando@gmail.com>
2021-04-17 10:21:23 +02:00
Idan Horowitz
4a467c553a Kernel: Modernize use of pointers in VirtIO
Raw pointers were mostly replaced with smart pointers and references
where appropriate based on kling and smartcomputer7's suggestions :)

Co-authored-by: Sahan <sahan.h.fernando@gmail.com>
2021-04-17 10:21:23 +02:00
Idan Horowitz
62303d46d1 Kernel: Add base support for VirtIO devices
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-17 10:21:23 +02:00