Commit Graph

204 Commits

Author SHA1 Message Date
b14ckcat
143339767b Kernel/USB: Move buffer allocation from USB transfer to USB pipe
Currently when allocating buffers for USB transfers, it is done
once for every transfer rather than once upon creation of the
USB device. This commit changes that by moving allocation of buffers
to the USB Pipe class where they can be reused.
2022-07-03 01:15:07 +02:00
b14ckcat
13445f5a43 Kernel/USB: Use proper error codes for UHCI transfers 2022-06-29 13:38:13 +01:00
Liav A
99bac4f34f Kernel/SysFS: Split bulky SysFSPCI file into separate files 2022-06-17 11:01:27 +02:00
Liav A
e488245234 Kernel/SysFS: Split bulky SysFSUSB file into two separate class files 2022-06-17 11:01:27 +02:00
Liav A
290eb53cb5 Kernel/SysFS: Stop cluttering the codebase with pieces of SysFS parts
Instead, start to put everything in one place to resemble the directory
structure of the SysFS when actually using it.
2022-06-17 11:01:27 +02:00
Brian Gianforcaro
6b85b358f8 Kernel: Unify Kernel task names for consistency
This change unifies the naming convention for kernel tasks.

The goal of this change is to:

- Make the task names more descriptive, so users can more
  easily understand their purpose in System Monitor.

- Unify the naming convention so they are consistent.
2022-06-05 14:09:44 +01:00
Jesse Buhagiar
a1ed9d3c60 Kernel/USB: Rename get_interfaces to something more sensible
This name was misleading, as it wasn't really "getting" anything. It has
hence been renamed to `enumerate_interfaces` to reflect what it's
actually doing.
2022-06-02 13:14:29 +02:00
Jesse Buhagiar
29f891bb54 Kernel/USB: Flesh out USB SysFS objects
Each USB object now contains the entire descriptor chain for the device
instead of just info from the device descriptor.
2022-06-02 13:14:29 +02:00
Jesse Buhagiar
ed657e3d2b Kernel/USB: Add interface descriptor accessor 2022-06-02 13:14:29 +02:00
Jesse Buhagiar
9002e837d3 Kernel/USB: Add configuration descriptor accessor 2022-06-02 13:14:29 +02:00
Jesse Buhagiar
cd8939f4a0 Kernel/USB: Make USBInterface endpoints accessible
These weren't accessible by an accessor, so let's fix that :^)
2022-06-02 13:14:29 +02:00
Jesse Buhagiar
361737650f Kernel/USB: Make USBConfiguration interfaces accessible
These weren't accessible by an accessor, so let's fix that :^)
2022-06-02 13:14:29 +02:00
b14ckcat
8a7876d65c Kernel/USB: Add support for bulk transfers 2022-05-21 22:12:05 +02:00
Liav A
340773ddb7 Kernel/Graphics: Implement basic support for VMWare SVGA adapter 2022-05-06 18:04:57 +02:00
b14ckcat
c65a6b6b22 Kernel: Use C++17 namespace style for nested PCI namespace
Adjust the nested namespace formatting in PCI files to use the nicer
and more consistent C++17 style.
2022-04-26 22:56:45 +02:00
b14ckcat
d8d7b5d82c Kernel: Put USB request constants in namespace
Moved constants in USBRequest.h from global scope to the Kernel::USB
namespace.
2022-04-26 22:56:45 +02:00
Jesse Buhagiar
48c3c01de4 Kernel/USB: Send correct data for Root Hub Configuration Descriptor
A request of `GET_DESCRIPTOR` should be sending the entire configuration
chain, and not just the configuration descriptor.
2022-04-22 15:16:56 +02:00
Jesse Buhagiar
300dcb6f5e Kernel/USB: Get all interface descriptors on enumeration
This creates all interfaces when the device is enumerated, with a link
to the configuration that it is a part of. As such, a new class,
`USBInterface` has been introduced to express this state.
2022-04-22 15:16:56 +02:00
Jesse Buhagiar
d313fa98ec Kernel/USB: Add new USBHIDDescriptor type 2022-04-22 15:16:56 +02:00
Jesse Buhagiar
a1df8a1896 Kernel/USB: Add control_transfer() function USB::Device
Some other parts of the USB stack may require us to perform a control
transfer. Instead of abusing `friend` to expose the default pipe, let's
just expose it via a function.
2022-04-22 15:16:56 +02:00
Jesse Buhagiar
dac26f89cb Kernel/USB: Fetch configuration descriptors on enumeration
This also introduces a new class, `USBConfiguration` that stores a
configuration. The device, when instructed, sets this configuration and
holds a pointer to it so we have a record of what configuration is
currently active.
2022-04-22 15:16:56 +02:00
Liav A
1462211ccf Kernel: Allow WorkQueue items allocation failures propagation
In most cases it's safe to abort the requested operation and go forward,
however, in some places it's not clear yet how to handle these failures,
therefore, we use the MUST() wrapper to force a kernel panic for now.
2022-04-20 19:47:18 +02:00
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Brian Gianforcaro
160c9b7631 Kernel: Zero initialize USBDevice::m_device_descriptor
Found by PVS-Studio.
2022-03-18 00:51:16 -07:00
Lenny Maiorani
190cf1507b Kernel: Use default constructors/destructors
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-03-17 00:51:36 -07:00
Liav A
428d4ae337 Kernel/PCI: Break early of controller iteration over devices in OOM case
This is mainly useful when adding an HostController but due to OOM
condition, we abort temporary Vector insertion of a DeviceIdentifier
and then exit the iteration loop to report back the error if occured.
2022-03-14 22:39:09 +01:00
Liav A
3fb289e27d Kernel/PCI: Don't hold spinlocks when doing fast device enumeration
Instead, hold the lock while we copy the contents to a stack-based
Vector then iterate on it without any locking.

Because we rely on heap allocations, we need to propagate errors back
in case of OOM condition, therefore, both PCI::enumerate API function
and PCI::Access::add_host_controller_and_enumerate_attached_devices use
now a ErrorOr<void> return value to propagate errors. OOM Error can only
occur when enumerating the m_device_identifiers vector under a spinlock
and trying to expand the temporary Vector which will be used locklessly
to actually iterate over the PCI::DeviceIdentifiers objects.
2022-03-14 22:39:09 +01:00
Liav A
f8df21c7e7 Kernel: Expose PCI BAR addresses in sysfs
Regardless of whether we use those BARs or not, expose them so userland
can use these values for its usage.
2022-03-08 21:52:10 +01:00
Liav A
b849e4f907 Kernel/PCI: Don't create /proc/pci if PCI is disabled
Reading from /proc/pci assumes we have PCI enabled and also enumerated.
However, if PCI is disabled for some reason, we can't allow the user to
read from it as there's no valuable data we can supply.
2022-03-02 18:41:54 +01:00
Liav A
2272d93215 Kernel/PCI: Unify disable checks under PCI::Access::is_disabled method
To declare that we don't have a PCI bus in the system we do two things:
1. Probe IO ports before enabling access -
In case we are using the QEMU ISA-PC machine type, IO probing results in
floating bus condition (returning 0xFF values), thus, we know we don't
have PCI bus on the system.
2. Allow the user to specify to not use the PCI bus at all in the kernel
commandline.
2022-03-02 18:41:54 +01:00
Liav A
f6e635938f Kernel: Change PCI access commandline option to also represent no access
This change allow the user to request the kernel to not use any PCI
resources/devices at all.

Also, don't try to initialize devices that rely on PCI if disabled.
2022-03-02 18:41:54 +01:00
Idan Horowitz
feb00b7105 Everywhere: Make JSON serialization fallible
This allows us to eliminate a major source of infallible allocation in
the Kernel, as well as lay down the groundwork for OOM fallibility in
userland.
2022-02-27 20:37:57 +01:00
Sviatoslav Peleshko
073f472c51 Kernel: Init receive buffer for dynamically created VirtIO console port
We already init receive buffer if we have singleport console, but if
we have multiport console that dynamically allocates ports we never
initted their receive buffers.
2022-02-20 20:32:22 -08:00
Idan Horowitz
871a53db76 AK: Make Bitmap construction OOM-fallible 2022-02-11 17:49:46 +02:00
Idan Horowitz
2dc91865a4 Kernel: Stop allocating VirtIO configuration structs on the heap
These are trivially-copyable 12-byte structs, so there's no point in
allocating them on the heap.
2022-02-03 23:33:20 +01:00
Andreas Kling
64254b5df8 Kernel: Protect PCI access with spinlock instead of mutex 2022-02-03 16:11:26 +01:00
Idan Horowitz
c131e69748 Kernel: Make UHCIController::spawn_port_process OOM-fallible 2022-01-28 19:05:52 +02:00
Idan Horowitz
ad7d4d9be1 Kernel: Rename UHCIController::{spawn_port_proc => spawn_port_process}
There's no need to use this non-standard shorthand mnemonic.
(This commit also removes the unimplemented do_debug_transfer while
we're here.)
2022-01-28 19:05:52 +02:00
Idan Horowitz
ac4583660b Kernel: Make VirtIO::ConsolePort construction OOM-fallible 2022-01-26 22:07:01 +00:00
Idan Horowitz
664ca58746 Kernel: Use u64 instead of size_t for File::can_write offset
This ensures offsets will not be truncated on large files on i686.
2022-01-25 22:41:17 +02:00
Idan Horowitz
9ce537d703 Kernel: Use u64 instead of size_t for File::can_read offset
This ensures offsets will not be truncated on large files on i686.
2022-01-25 22:41:17 +02:00
Liav A
eb9c8f3895 Kernel/PCI: Add basic support for the VMD PCI bridge device 2022-01-23 01:12:55 +01:00
Liav A
cecfd42916 Kernel/PCI: Verify Access is not initialized before initializing it
There's no valid case where we should try to initialize the Access
singleton multiple times, therefore just assert if it ever happens.
2022-01-21 19:09:16 +02:00
Idan Horowitz
c3099382b8 Kernel: Make VirtIO::Queue construction fallible 2022-01-21 16:27:21 +01:00
Idan Horowitz
17584d8a84 Kernel: Stop adopting non-heap memory into OwnPtrs in VirtIO::Queues 2022-01-21 16:27:21 +01:00
Idan Horowitz
d65347d39d Kernel: Make Memory::RingBuffer construction fallible 2022-01-21 16:27:21 +01:00
Liav A
c1d3b557d5 Kernel/PCI: Don't try to enumerate 255 functions on the host bridge
There can only be a limited number of functions (only 8).
Also, consider the start bus of the PCI domain when trying to enumerate
other host bridges on bus 0, device 0, functions 1-7 (function 0 is the
main host bridge).
2022-01-19 21:54:41 +02:00
Liav A
518473846a Kernel/PCI: Start enumeration in specified start bus of the PCI domain
Some devices, like the Intel Volume Management Device, might have bus
numbering restrictions (so numbers can be from 224 to 225, for example).
2022-01-19 21:54:41 +02:00
Liav A
0833ae0b36 Kernel/PCI: Don't hardcode Address domain to 0 when enumerating devices 2022-01-19 21:54:41 +02:00
Liav A
667a009cd7 Kernel/PCI: Don't cast a domain number to u16
Found by Tom (tomuta) during a debug session of these changes.
2022-01-19 21:54:41 +02:00