Commit Graph

5950 Commits

Author SHA1 Message Date
Brian Gianforcaro
9d17070047 Kernel: Fix copy paste in VirtIO::RNG::class_name()
Ben noticed this copy paste error during code review.

Co-authored-by: Ben Wiederhake <BenWiederhake.GitHub@gmx.de>
2021-10-03 13:36:10 +02:00
Brian Gianforcaro
40a58f1fd4 Kernel: Remove unused partition name API
I was about to convert this to use KString, but then I realized it
wasn't actually used at all, so lets remove it until the day it is
needed.
2021-10-03 13:36:10 +02:00
Brian Gianforcaro
54a2aaaa6f Kernel: Remove now unused StorageDevice constructor 2021-10-03 13:36:10 +02:00
Brian Gianforcaro
70ad18fbcd Kernel: Remove most String usage from storage_name() API
This change is another minor step towards removing `AK::String` from
the Kernel. Instead of dynamically allocating the storage_name we can
instead allocate it via a KString in the factory for each device, and
then push the device name down into the StorageDevice base class.

We don't have a way of doing `AK::String::formatted(..)` with a KString
at the moment, so cleaning that up will be left for a later day.
2021-10-03 13:36:10 +02:00
Brian Gianforcaro
3a945051fc Kernel: Use operator ""sv in all purpose() implementations
Previously there was a mix of returning plain strings and returning
explicit string views using `operator ""sv`. This change switches them
all to standardized on `operator ""sv` as it avoids a call to strlen.
2021-10-03 13:36:10 +02:00
Brian Gianforcaro
5f1c98e576 Kernel: Use operator ""sv in all class_name() implementations
Previously there was a mix of returning plain strings and returning
explicit string views using `operator ""sv`. This change switches them
all to standardized on `operator ""sv` as it avoids a call to strlen.
2021-10-03 13:36:10 +02:00
Brian Gianforcaro
836c22ea13 Kernel: Remove AK::String usage from Storage/StorageManagement.cpp 2021-10-03 13:36:10 +02:00
Brian Gianforcaro
7f88d5058e Kernel: Remove AK::String usage from Storage/IDEChannel.cpp 2021-10-03 13:36:10 +02:00
Nico Weber
2c0d329bf6 Kernel: Make aarch64 UART::print_num() print u64s 2021-10-02 21:23:28 +01:00
Nico Weber
bc213ad7a2 Kernel: Add a Timer class for aarch64
For now, this can only query microseconds since boot.

Use this to print a timestamp every second. This busy-loops
until a second has passed. This might be a good first use of
interrupts soon.

qemu used to not implement this timer at some point, but
it seems to work fine even in qemu now (qemu v 5.2.0).
2021-10-02 21:23:28 +01:00
Brian Gianforcaro
92844a6af6 Kernel: Access Processor static methods statically
SonarCloud flagged this "Code Smell", where we are accessing these
static methods as if they are instance methods. While it is technically
possible, it is very confusing to read when you realize they are static
functions.
2021-10-02 18:16:15 +02:00
Brian Gianforcaro
0223faf6f4 Kernel: Access MemoryManager static functions statically
SonarCloud flagged this "Code Smell", where we are accessing these
static methods as if they are instance methods. While it is technically
possible, it is very confusing to read when you realize they are static
functions.
2021-10-02 18:16:15 +02:00
Nico Weber
6c4392bc50 Prekernel: Better datasheet link for RPi3 2021-10-02 02:01:07 +02:00
Brian Gianforcaro
b90cc1148a Kernel: Switch RTL8168NetworkAdapter::possible_device_name to StringView
There is no need to allocate a `AK::String` for the device name, when
the list of devices is entirely static.
2021-10-01 17:22:17 +00:00
Brian Gianforcaro
2770433d30 Kernel: Convert network adapter names to Kernel::KString
Another step of incremental progress of removing `AK::String` from the
kernel, to harden against OOM.
2021-10-01 17:22:17 +00:00
Liav A
4974727dbb Kernel: Move x86 IO instructions code into the x86 specific folder 2021-10-01 12:27:20 +02:00
Liav A
3e9dfd2e74 Kernel: Remove IO.h include from a bunch of places 2021-10-01 12:27:20 +02:00
Nico Weber
5a951d6258 Kernel: Fix a few typos 2021-10-01 00:51:49 +01:00
Andreas Kling
eeb4f2fa9b Kernel: Exclude userspace heap memory from coredumps by default
When a process with a large heap crashes (e.g WebContent), it gets very
cumbersome to dump out a huge amount of memory.

In the vast majority of cases, we're only interested in generating a
nice backtrace from the coredump, so let's have the kernel skip over
userspace heap regions when dumping memory for now.

This is not ideal, and almost a little bit ugly, but it does make
investigating 500 MiB WebContent crashes significantly easier for now.
2021-09-30 17:54:32 +02:00
Nico Weber
94d0562569 Kernel: Make UART::print_num(0) work on aarch64 2021-09-30 15:38:43 +01:00
Nico Weber
d0c1db5efc Kernel: Zero out .bss contents on aarch64
After building and running

     objcopy -O binary Build/aarch64/Kernel/Prekernel/Prekernel \
                       /media/sdcard/kernel8.img

things start booting on an actual RPi4 :^)

(Assuming the sdcard contains RPi firmware, an empty config.txt,
and no other kernel*.img files).
2021-09-30 15:38:43 +01:00
Rodrigo Tobar
d16131b100 Kernel: Implement getsockopt(SO_TYPE)
This is easy to implement, and is required by some applications like
python's ssl module.
2021-09-30 11:45:24 +02:00
Liav A
ef9b8ff0c7 Kernel/PCI: Remove all macros and replace them with enum classes 2021-09-29 11:24:33 +02:00
Liav A
9d9d57056e Kernel/PCI: Remove Address from enumeration callback
If we need that address, we can always get it from the DeviceIdentifier.
2021-09-29 11:24:33 +02:00
Liav A
a411a44fda Kernel/PCI: Cache interrupt line and interrupt pin of a device
This allows us to remove the PCI::get_interrupt_line API function. As a
result, this removes a bunch of not so great patterns that we used to
cache PCI interrupt line in many IRQHandler derived classes instead of
just using interrupt_number method of IRQHandler class.
2021-09-29 11:24:33 +02:00
Liav A
057f5a12c2 Kernel/PCI: Propagate usage of DeviceIdentifier everywhere
This allows us to remove a bunch of PCI API functions, and instead to
leverage the cached data from DeviceIdentifier object in many places.
2021-09-29 11:24:33 +02:00
Liav A
da327746a2 Kernel: Rename two PCI components
Rename ID => HardwareID, and PhysicalID => DeviceIdentifier.
This change merely does that to clarify what these objects really are.
2021-09-29 11:24:33 +02:00
Liav A
82bb08a15c Kernel/PCI: Cache more details about PCI devices when enumerating them
There's no good reason to fetch these values each time we need them.
2021-09-29 11:24:33 +02:00
Hendiadyoin1
683bf558e4 AK: Add missing AK/Types.h include to VirtIO/Protocol.h
How did this even work?
2021-09-28 03:13:54 +03:00
Liav A
acd44bdcad Kernel/Graphics: Modernize somewhat the code of BochsGraphicsAdapter
Reduce the amount of macros in favor to enum classes.
2021-09-27 16:15:04 +02:00
Liav A
38bddca378 Kernel/Graphics: Ensure we set BGR format of bochs-display if supported
Instead of blindly forcing BGR format on the bochs-display device, let's
ensure we do that only on QEMU bochs-display and not on VirtualBox
graphics adapter too.
2021-09-27 16:15:04 +02:00
Liav A
de1b649783 Kernel/Graphics: Force BGR format when modesetting the bochs-display
By default bochs-display uses the BGR format, but for future-proof
solution, let's force it explicitly to use that format.
2021-09-27 16:15:04 +02:00
Nico Weber
b0858b2a55 Kernel: Fix a typo in a comment 2021-09-27 10:17:52 +02:00
Nico Weber
4c876e88e0 Kernel: Adjust aarch64 linker script
- .text now starts at 0x80000, where an actual (non-qemu) RPi expects
- use magic section name ".text.first" to make sure the linker script
  puts the kernel entry point at the start of the .text section
- remove a few things from the x86 linker script that aren't needed
  for aarch64 (yet?)
2021-09-27 10:17:52 +02:00
Nico Weber
cbdf4b575d Kernel: Move prekernel linker.ld into Arch subdirectories
This moves Kernel/Prekernel/linker.ld unchanged to
Kernel/Prekernel/Arch/aarch64 and Kernel/Prekernel/Arch/x86.
The aarch64 will change in a future commit.

No behavior change.
2021-09-27 10:17:52 +02:00
Nico Weber
54aabb07f9 Kernel: Add UART class for aarch64 2021-09-26 23:14:01 +00:00
Nico Weber
44c787e88b Kernel: Add Mailbox::set_clock_rate() 2021-09-26 23:14:01 +00:00
Nico Weber
fdc86ddae5 Kernel: Add a GPIO class for aarch64
This allows configuring the alternate pin functions and pin
pull up/down states, which is needed for using the UART.
2021-09-26 11:55:51 +02:00
Jelle Raaijmakers
9a6283c524 Kernel: Define PT_READ_I and PT_READ_D
Looking at how these two constants are commonly used in other systems,
we should be able to mimic their behavior using our PT_PEEK constant.

For example, see:
https://man.netbsd.org/NetBSD-6.0.1/i386/ptrace.2
2021-09-23 18:51:21 +02:00
Eric Seifert
8924b1f532 Kernel: Allow PROT_NONE in mmap and mprotect for stack regions
To allow for userspace guard pages (ruby uses this).
Redundant since serenity creates them automatically,
but should be allowed anyway.
2021-09-23 04:14:41 +00:00
Ben Wiederhake
12247fe9b4 Kernel: Use AK::Variant default initialization where appropriate 2021-09-21 04:22:52 +04:30
Ben Wiederhake
de15a6a657 Kernel: Clean up PCI::Device namespace formatting 2021-09-20 16:00:43 +03:00
Idan Horowitz
574a1c522d Kernel: Store device class name as member of VirtIO devices
This ensures we dont try to hold the PCI Access mutex under IRQ when
printing VirtIO debug logs (which is not allowed and results in an
assertion). This is also relatively free, as it requires no allocations
(we're just storing a pointer to the rodata section).
2021-09-19 21:51:03 +02:00
Idan Horowitz
53cf28c47c Kernel: Use StringView literals in VirtIO::determine_device_class()
Since the return type is StringView we can just create them at compile
time and avoid the run-time construction.
2021-09-19 21:51:03 +02:00
Nico Weber
697e6ccb89 Kernel: Add a Mailbox class for aarch64
As a demo, query the firmware version. `Meta/serenity.sh gdb aarch64`
can be used to observe that qemu puts 0x548E1 in x0 in response
to this mailbox message.
2021-09-19 17:45:59 +02:00
Nico Weber
d0b9c7a20b Kernel: Add a MMIO class for aarch64
It doesn't do anything yet except figure out the peripheral base
address.

Very likely belongs in Kernel, not Prekernel, eventually.
2021-09-19 17:45:59 +02:00
Nico Weber
3a24eb323f Kernel: Use new halt() for all our halting needs in aarch64 Prekernel 2021-09-19 17:45:59 +02:00
Nico Weber
0319aa315a Kernel: Add __stack_chk_fail to aarch64 Prekernel init
This is needed for some functions with local variables. We'll grow
such a function soon.
2021-09-19 17:45:59 +02:00
Eric Seifert
edbc5489a8 Kernel: Add support for O_NONBLOCK in pipe syscall
While working on a port, I saw a pipe creation fail due to missing
nonblock support in pipe syscall.
2021-09-19 12:20:16 +02:00
Sahan Fernando
2e079c6d69 Kernel/VirtIO: Remove lazy allocation of VirtIO::Device BAR regions
This fixes a Kernel Panic where the lazy allocation triggers inside an
ISR and grabs a mutex, which isn't allowed when interrupts are
disabled. This also fixes a bug where the mapping for VirtIO device
BARs is never allocated. #9876
2021-09-19 11:46:09 +03:00