For some context, write_bytes_locked used to simply bail out before
writing any data if there weren't enough blocks to cover the entire size
of an inode before 1bf7f99a.
We're not actually restoring that behavior here, since computing the
amount of blocks to be allocated would get exceedingly complex,
considering that there could always be holes in between already
allocated blocks.
Instead, this simply makes allocate_blocks() bail out properly if there
aren't any free blocks left.
Fixes#24980
Devicetree drivers are created by using the `DEVICETREE_DRIVER` macro.
That macro creates a new class deriving from `DeviceTree::Driver` and
inserts it into the driver init section.
The driver code then has to implement the `probe` member function, which
will be called if `DeviceTree::Management` finds a node with a
compatible property entry that was in the array passed as the second
argument to the `DEVICETREE_DRIVER` macro.
The `probe` function then will check if it supports the given node and
if so, registers a `DeviceTree::DeviceRecipe` at the appropriate
subsystem, which will then create a device from that recipe once it is
initialized.
The driver can store the necessary info it got from the devicetree,
such as the physical address and interrupt numbers, in the capture
list of the callback lambda stored in `DeviceRecipe::create_device`.
The `DeviceTree::DeviceRecipe`s are necessary, as the `probe` functions
might not be able to create an instance of the actual device class,
since doing so can depend on some subsystems being initialized first.
This commit reorganizes the BootInfo struct definition so it can be
shared for all architectures.
The existing free extern "C" boot info variables have been removed and
replaced with a global BootInfo struct, 'g_boot_info'.
On x86-64, the BootInfo is directly copied from the Prekernel-provided
struct.
On AArch64 and RISC-V, BootInfo is populated during pre_init.
For now we only support USB <3.0 devices, as we don't support streams.
We also don't leverage the benefits of UAS, as we pretend to have a
queue depth of 1, ie are single threaded.
To test this driver, you can use the following command:
```
SERENITY_BOOT_DRIVE=usb-uas Meta/serenity.sh run x86_64 Clang
```
I put the generic implementation in Assertions.cpp, since the
declaration is in Assertions.h.
The only change needed to make the x86-64 implementation generic was
replacing the cli with a Processor::disable_interrupts().
When using spice with `virt-viewer` the mouse rarely works on the first
initialization attempt. Simply retrying a few times makes it succeed
most of the time (although it can still fail, it's pretty rare now).
Fix incorrect casts of (e1000_rx_desc*) to (e1000_tx_desc*) in functions
related to frame receive path.
Previous code appears to work because only fields common to both the TX
and RX descriptor types are used in the affected code and happen to be
at the same offset inside the packed structs.
Do this by:
- Removing more instances of `LockRefPtr` and `NonnullLockRefPtr`.
- Using better names of construction methods (i.e. `create` instead of
`try_create`).
- Only returning `NonnullRefPtr` on the `Device::try_create_device`
method.
- Removing a version of the `Device::try_create_device` method that
called `DeviceType::try_create(forward<Args>(args)...)`, which was
only used in a construction point in a VirtIO driver which now doesn't
need this anymore.
This change has many improvements:
- We don't use `LockRefPtr` to hold instances of many base devices as
with the DeviceManagement class. Instead, we have a saner pattern of
holding them in a `NonnullRefPtr<T> const`, in a small-text footprint
class definition in the `Device.cpp` file.
- The awkwardness of using `::the()` each time we need to get references
to mostly-static objects (like the Event queue) in runtime is now gone
in the migration to using the `Device` class.
- Acquiring a device feel more obvious because we use now the Device
class for this method. The method name is improved as well.
Unifying with other structures, this introduces m_payload for all
relevant structures, except the TCP header (which has a different
concept of payload than the rest).
This allows us to return a pointer directly instead of doing pointer
arithmetic to point to the end of the structure.
According to ARP.h, address lengths default to size of their
underlying types (IPv4Address and MACAddress respectively). We never
modify those values, and in reality, ARP never carries anything else.
Hence, those checks resolved to comparing sizeof to itself, which
probably gets optimized out of the compiler anyways.
This change removes the checks that will never fail, plus changes the
function definition to pass adapter directly, matching other handlers.
This commit adds the minimum amount of code to make Serenity reply to
ICMPv6 ping packets. This includes basic Network Discovery Protocol
support, as well as a basic ICMPv6 Echo Request/Response handler.
This change also introduces a new debug flag, ICMPV6_DEBUG.
Co-Authored-By: kleines Filmröllchen <filmroellchen@serenityos.org>
This commit introduces the first bit of IPv6 support into
SerenityOS. An IPv6 packet header structure allows NetworkTask to
recognize and log correctly shaped IPv6 packets, but nothing is done
with those yet. A new logging flag, IPV6_DEBUG, allows debugging of
IPv6 internals.
Co-Authored-By: sdomi <ja@sdomi.pl>
Up until now, protocol handlers for IPv4 and ARP had to rediscover the
adapter based on trying to match the address to all interfaces. This
approach is relatively slow, introduces more code duplication, and
doesn't work with multiple IPs per interface (as is the case with
IPv6).
This change introduces directly passing the adapter to all handlers
that need it, cutting out the retrieval process. Furthermore, we
discard the packet much faster if the IP doesn't match.