Commit graph

4578 commits

Author SHA1 Message Date
Brian Gianforcaro af2c3ab524 Kernel: Remove usage of adopt_own in KString 2021-05-29 09:04:05 +02:00
Brian Gianforcaro f4d7151c3c Kernel: Make KBuffer APIs OOM safe 2021-05-29 09:04:05 +02:00
Brian Gianforcaro 864b1a65e3 Kernel: Make ContiguousVMObject factory API OOM safe 2021-05-29 09:04:05 +02:00
Brian Gianforcaro cb45b2c001 Kernel: Make AnonymousVMObject::clone() API OOM safe
Propagate allocation failure of m_shared_committed_cow_pages,
and uncommit previously committed COW pages on failure.

This method needs a closer look in terms of error handling, as we
will eventually need to rollback all changes on allocation failure.
Alternatively we could allocate the anonymous object much earlier
and only initialize it once the other steps have succeeded.
2021-05-29 09:04:05 +02:00
Brian Gianforcaro 65d5f81afc Kernel: Make PrivateInodeVMObject factory APIs OOM safe 2021-05-29 09:04:05 +02:00
Gunnar Beutner 4fca9ee060 Kernel: Allow building the kernel with -O0
Unfortunately the kernel doesn't run with -O0 but at least it can be
successfully built with this change.
2021-05-28 19:52:22 +01:00
Gunnar Beutner 9adcfd5726 Kernel: Don't crash when writing a coredump with an unnamed region
Previously we'd try to call ByteBuffer::append(nullptr, 1) when we
came across a VM region that had no name.
2021-05-28 16:48:17 +02:00
Andreas Kling 9d801d2345 Kernel: Rename Custody::create() => try_create()
The try_ prefix indicates that this may fail. :^)
2021-05-28 11:23:00 +02:00
Andreas Kling 9a827ad3da Kernel: Use a KString for Custody::m_name 2021-05-28 11:21:00 +02:00
Andreas Kling fc9ce22981 Kernel: Use KString for Region names
Replace the AK::String used for Region::m_name with a KString.

This seems beneficial across the board, but as a specific data point,
it reduces time spent in sys$set_mmap_name() by ~50% on test-js. :^)
2021-05-28 09:37:09 +02:00
Andreas Kling a1944ec966 Kernel: Add missing AK/Format.h include in KResult.h 2021-05-28 09:37:09 +02:00
Andreas Kling 856f20f91f Kernel: Add try_copy_kstring_from_user()
This is a convenience function that works the same as our old
copy_string_from_user(), but this returns a KString (and can fail!)
2021-05-28 09:37:09 +02:00
Andreas Kling 279383a8f3 Kernel: Add KString, a single-owner string with OOM failure exposion
This is a simple string class for use in the kernel. It encapsulates
a length + character array in a single-allocation object.

Main differences from AK::String:

- Single-owner (no reference counting.)
- Allocation failures are exposed, not hidden.

The basic idea is to allow better and more precise string management
in the kernel.
2021-05-28 09:37:09 +02:00
Gunnar Beutner 377b06c8ac Kernel: Ignore duplicate SYN packets
When receiving a SYN packet for a connection that's in the "SYN
received" state we should ignore the duplicate SYN packet instead of
closing the connection. This can happen when we didn't accept the
connection in time and our peer has sent us another SYN packet because
it thought that the initial SYN packet was lost.
2021-05-28 08:01:00 +02:00
Gunnar Beutner 3fc75088a2 Kernel: Release packet buffer in TCPSocket::send_tcp_packet
Previously we wouldn't release the buffer back to the network adapter
in all cases. While this didn't leak the buffer it would cause the
buffer to not be reused for other packets.
2021-05-28 08:00:45 +02:00
Liav A c1a4dfeffb Kernel/Graphics: Remove unnecessary derived FramebufferDevice classes
It seems like overly-specific classes were written for no good reason.
Instead of making each adapter to have its own unique FramebufferDevice
class, let's generalize everything to keep implementation more
consistent.
2021-05-27 22:39:13 +02:00
Tim Schumacher 58bc10b947
Kernel: Make dup2() return the fd even if old & new are the same (#7506) 2021-05-27 21:14:57 +02:00
Andrew Kaster 505f84daae Kernel+AK: Move UBSanitizer to AK, and to AK namespace
In preparation for copying UBSanitizer to userspace, move the header to
AK :^)
2021-05-27 15:18:03 +02:00
Andrew Kaster dda8afcb90 Kernel: Add ENABLE_EXTRA_KERNEL_DEBUG_SYMBOLS option to set Og and ggdb3
When debugging kernel code, it's necessary to set extra flags. Normal
advice is to set -ggdb3. Sometimes that still doesn't provide enough
debugging information for complex functions that still get optimized.
Compiling with -Og gives the best optimizations for debugging, but can
sometimes be broken by changes that are innocuous when the compiler gets
more of a chance to look at them. The new CMake option enables both
compile options for kernel code.
2021-05-27 10:21:30 +02:00
Andrew Kaster 7fb05c5c23 Kernel: Explicitly initialize bools in IOAPIC mapping
The compiler couldn't convince itself that these are always initialized
when compiling with Og. They are always initialized before use, because
the only branch where they weren't had VERIFY_NOT_REACHED.
2021-05-27 10:21:30 +02:00
Andrew Kaster 86e3010043 Kernel: Pass trampolines instead of lambdas to create_kernel_process
With -Og, all calls to create_kernel_process were triggering -Wnonnull
when creating these lambdas that get implicitly converted to function
pointers. A different design of create_kernel_process to use
AK::Function instead might avoid this awkward behavior.
2021-05-27 10:21:30 +02:00
Gunnar Beutner 1ce32ef675 Kernel: Let the user read/write more than one page from/to dev files
Previously reads and writes to /dev/zero, /dev/full, /dev/null and
/dev/random were limited to 4096 bytes.

This removes that restriction so that users can enjoy more zero bytes
in their buffers.
2021-05-27 09:30:19 +02:00
Gunnar Beutner 49dd4e5193 Kernel: Block when writing to TCP sockets when the send window is full
Previously we'd just dump those packets into the network adapter's
send queue and hope for the best. Instead we should wait until the peer
has sent TCP ACK packets.

Ideally this would parse the TCP window size option from the SYN or
SYN|ACK packet, but for now we just assume the window size is 64 kB.
2021-05-26 23:09:28 +02:00
Gunnar Beutner b436dd138b Kernel: Avoid allocations when sending IP packets
Previously we'd allocate buffers when sending packets. This patch
avoids these allocations by using the NetworkAdapter's packet queue.

At the same time this also avoids copying partially constructed
packets in order to prepend Ethernet and/or IPv4 headers. It also
properly truncates UDP and raw IP packets.
2021-05-26 23:09:28 +02:00
Gunnar Beutner f8310b7796 Kernel: Move packet allocation into helper methods 2021-05-26 23:09:28 +02:00
Brian Gianforcaro 2045782a6e Kernel: Switch VMObject to IntrusiveList from InlineLinkedList 2021-05-26 20:24:32 +02:00
Brian Gianforcaro e6f73d69a2 Kernel: Switch Region to IntrusiveList from InlineLinkedList 2021-05-26 20:24:32 +02:00
Brian Gianforcaro e0da61f9d6 Kernel: Switch LocalSocket to IntrusiveList from InlineLinkedList 2021-05-26 20:24:32 +02:00
Brian Gianforcaro 493d4d1cd7 Kernel: Switch Inode to IntrusiveList from InlineLinkedList 2021-05-26 20:24:32 +02:00
Gunnar Beutner c6299d1e5d Kernel: Don't try to send TCP packets larger than the MSS
Previously TCPSocket::send_tcp_packet() would try to send TCP packets
which matched whatever size the userspace program specified. We'd try to
break those packets up into smaller fragments, however a much better
approach is to limit TCP packets to the maximum segment size and
avoid fragmentation altogether.
2021-05-25 22:20:37 +02:00
Brian Gianforcaro 6830963321 Kernel: Validate we don't hold s_mm_lock during context switch
Since `s_mm_lock` is a RecursiveSpinlock, if a kernel thread gets
preempted while accidentally hold the lock during switch_context,
another thread running on the same processor could end up manipulating
the state of the memory manager even though they should not be able to.
It will just bump the recursion count and keep going.

This appears to be the root cause of weird bugs like: #7359
Where page protection magically appears to be wrong during execution.

To avoid these cases lets guard this specific unfortunate case and make
sure it can never go unnoticed ever again.

The assert was Tom's idea to help debug this, so I am going to tag him
as co-author of this commit.

Co-Authored-By: Tom <tomut@yahoo.com>
2021-05-25 10:35:41 +02:00
Tom fe679de791 Kernel: Release the paging lock while reading from the disk
Because reading from the disk may preempt, we need to release the
paging lock.
2021-05-25 10:35:41 +02:00
Tom 1110c659ee Kernel: Add ScopedLockRelease to temporarily release a Lock 2021-05-25 10:35:41 +02:00
Daniel Bertalan 146bd794eb LibVT: Add Alternate Screen Buffer support
The Alternate Screen Buffer is used by full-screen terminal applications
(like `vim` and `nano`). Its data is stored separately from the normal
buffer, therefore after applications using it exit, everything looks
like it was before, the bottom of their interfaces isn't visible. An
interesting feature is that it does not support scrollback, so it
consumes less memory by not having to allocate lines for history.

Because of the need to save and restore state between the switches, some
correctness issues relating to it were also fixed in this commit.
2021-05-24 22:26:54 +04:30
Daniel Bertalan 875a2cbb71 LibVT+Kernel: Add support for setting cursor styles
This commit introduces support for 3 new escape sequences:
1. Stop blinking cursor mode
2. `DECTCEM` mode (enable/disable cursor)
3. `DECSCUSR` (set cursor style)

`TerminalWidget` now supports the following cursor types: block,
underline and vertical bar. Each of these can blink or be steady.
`VirtualConsole` ignores these (just as we were doing before).
2021-05-24 11:27:58 +02:00
Gunnar Beutner ad6587424f Kernel: Disable profiling if setting up the buffer or timer failed 2021-05-24 09:10:50 +02:00
Daniel Bertalan 06c835f857 Kernel: Signal EOF/EOL characters properly in TTY
I introduced a regression in #7184 where `TTY` would report 1 byte read
in canonical mode even if we had no more characters left. This was
caused by counting the '\0' that denotes EOF into the number of
characters that were read.

The fix was simple: exclude the EOF character from the number of bytes.

This still wouldn't be correct by itself, as the EOF and EOL control
characters could change between when the data was written to the TTY and
when it is read. We fix this by signaling out-of-band whether something
is a special character. End-of-file markers have a value of zero and
have their special bits set. Any other bytes with a special flag are
treated as line endings. This is possible, as POSIX doesn't allow
special characters to be 0.

Fixes #7419
2021-05-24 00:06:06 +01:00
Gunnar Beutner 0688e02339 Kernel: Make sure we only log profiling events when m_profiling is true
Previously the process' m_profiling flag was ignored for all event
types other than CPU samples.

The kfree tracing code relies on temporarily disabling tracing during
exec. This didn't work for per-process profiles and would instead
panic.

This updates the profiling code so that the m_profiling flag isn't
ignored.
2021-05-23 23:54:30 +01:00
Andreas Kling cefb321da4 Kernel: Print a message to debug log after writing a perfcore file 2021-05-22 22:23:52 +02:00
Liav A 8d0280ca09 Kernel/Net: Make interfaces to have persistent names
There's no good reason to distinguish between network interfaces based
on their model. It's probably a good idea to try keep the names more
persistent so scripts written for a specific network interface will be
useable after hotplug event (or after rebooting with new hardware
setup).
2021-05-22 11:19:50 +01:00
Mart G e16a50b586
Kernel: Remove an allocation from VFS::resolve_path_without_veil (#7287)
Use GenericLexer to replace a call to StringView::split() since that
returns its result in a heap-allocating Vector.
2021-05-22 00:12:32 +02:00
Liav A 5e81464245 Kernel/Commandline: Allow the user to specify an embedded string
This is by default left empty, so people won't run the kernel in a mode
which they didn't want to. The embedded string will override the
supplied commandline from the bootloader, which is good for debugging
sessions.

This change seemed important for me, because I debug the kernel on bare
metal with iPXE, and every change to the commandline meant that I needed
rewrite a new iPXE USB image with a modified iPXE script.
2021-05-21 22:38:26 +01:00
Liav A b8f0a9c974 Kernel/CPU: Fix awkward printing early on boot
This usage of the word "installing" seemed for me for a long time as
a wrong thing, so let's make it better now.
2021-05-21 22:38:26 +01:00
Liav A df84fdfd2c Kernel: Print commandline after initializing it 2021-05-21 22:38:26 +01:00
Liav A e9ef3b59d8 Kernel/VirtualConsole: Fix grammar error in comment 2021-05-21 22:38:26 +01:00
Gunnar Beutner 7cd49ba2a2 Kernel: Ignore interfaces without an IP address when routing packages
Let's not route packages through interfaces which don't have an address
yet unless we're explicitly asked to (e.g. by DHCPClient).
2021-05-21 21:55:52 +02:00
Gunnar Beutner eb1cecc03d Kernel: Make sure network adapters have unique names
Previously we'd just slap 0 onto the adapter's basename. This ensures
we actually end up with unique names.
2021-05-21 21:55:52 +02:00
Liav A 07474b4349 Kernel/PCI: Fix support of multiple PCI host controllers enumeration
First scan PCI bus 0. Find any device on that bus, and if it's a
PCI-to-PCI bridge, recursively scan it too.

Then try to handle Multiple PCI host bridges on slot 0, device 0.
If we happen to miss some PCI buses because they are not reachable
through recursive PCI-to-PCI bridges scanning starting from bus 0, we
might find them in this scanning.
2021-05-21 17:58:53 +01:00
Liav A c6ffee7f18 Kernel/Graphics: Indicate initialization failed if no device was found 2021-05-21 17:58:53 +01:00
Brian Gianforcaro 3d7cc471d6 Revert "Kernel: Avoid allocating under spinlock in ProcessGroup::find_or_create"
This reverts commit e95eb7a51d.

This is causing some sort of list corruption, as evident by #7313
I haven't been able to figure it out yet, so lets revert this change
until I can figure out what's going on.
2021-05-21 12:36:20 +02:00
Brian Gianforcaro 124a523199 Revert "Kernel: Fix regression, removing a ProcessGroup that not in the list"
This reverts commit bbe315d8c0.

This is un-needed when reverting the parent commit.
2021-05-21 12:36:20 +02:00
Liav A 09d09b79b6 Kernel: Fix type, dectivate_writes => deactivate_writes 2021-05-21 08:08:33 +02:00
Liav A db268efa69 Kernel/Graphics: Choose VMObject considering enabled state when mmaping
When mmaping a Framebuffer from userspace, we need to check whether the
framebuffer device is actually enabled (e.g. graphical mode is being
used) or a textual VirtualConsole is active.

Considering the above state, we mmap the right VMObject to ensure we
don't have graphical artifacts if we change the resolution from
DisplaySettings, changed to textual mode and after the resolution change
was reverted, we will see the Desktop reappearing even though we are
still in textual mode.
2021-05-21 08:08:33 +02:00
Liav A 87f8f892d8 Kernel: Fix framebuffer resolution modesetting after boot
If we tried to change the resolution before of this patch, we triggered
a kernel crash due to mmaping the framebuffer device again.
Therefore, on mmaping of the framebuffer device, we create an entire new
set of VMObjects and Regions for the new settings.

Then, when we change the resolution, the framebuffersconsole needs to be
updated with the new resolution and also to be refreshed with the new
settings. To ensure we handle both shrinking of the resolution and
growth of it, we only copy the right amount of available data from the
cells Region.
2021-05-21 08:08:33 +02:00
Liav A 5f718c6b05 Kernel/TTY: Don't flush dirty lines if VirtualConsole is not active 2021-05-21 08:08:33 +02:00
Liav A 38ccdb02ce Kernel: Process request to change virtual console from the IO Work queue
Instead of processing the input after receiving an IRQ, we shift the
responsibility to the io work queue to handle this for us, so if a page
fault occurs when trying to switch the VirtualConsole, the kernel can
handle that.
2021-05-21 08:08:33 +02:00
Tom 9dcc7a67e5 Kernel: Close a Thread tid lookup race
There is a window between dropping a thread's last reference and it
being removed from the list.

Found in #5541
2021-05-20 22:08:36 +02:00
Idan Horowitz df7d938808 Kernel: Stop allocating the PS2KeyboardDevice in the eternal heap
The PS2KeyboardDevice can be free'd in try_to_initialize if the
initialization failed, resulting in an assertion.
2021-05-20 18:40:02 +02:00
Ali Mohammad Pur c6b12841ee Meta: Make generate_state_machine() generate a proper target
And use GENERATED_SOURCES (or add_dependencies) to make LibVT depend on
that target.
Fixes a FIXME.
2021-05-20 12:11:27 +01:00
Brian Gianforcaro bbe315d8c0 Kernel: Fix regression, removing a ProcessGroup that not in the list
I introduced this bug in e95eb7a51, where it's possible that the
ProcessGroup is created, but we never add it to the list. Make sure we
check that we are in the list before removal. This only broke booting in
self-test mode oddly enough.

Reported-By: Andrew Kaster <andrewdkaster@gmail.com>
2021-05-20 09:41:52 +02:00
Gunnar Beutner 8495d6aeca Kernel: Use the Function class for smp_broadcast()/smp_unicast()
This avoids allocations for smp_broadcast() and smp_unicast() by
using the Function class.
2021-05-20 09:09:10 +02:00
Gunnar Beutner cac7a8ced9 Kernel: Use the Function class for deferred_call_queue()
This avoids allocations for deferred_call_queue().
2021-05-20 09:09:10 +02:00
Gunnar Beutner 7557f2db90 Kernel: Remove an allocation when blocking a thread
When blocking a thread with a timeout we would previously allocate
a Timer object. This removes the allocation for that Timer object.
2021-05-20 09:09:10 +02:00
Brian Gianforcaro e95eb7a51d Kernel: Avoid allocating under spinlock in ProcessGroup::find_or_create
Avoid allocating while holding the g_process_groups_lock spinlock, it's
a pattern that has a negative effect on performance and scalability,
especially given that it is a global lock, reachable by all processes.
2021-05-20 08:10:07 +02:00
Brian Gianforcaro bb91bed576 Kernel: Make ProcessGroup::find_or_create API OOM safe
Make ProcessGroup::find_or_create & ProcessGroup::create OOM safe, by
moving to adopt_ref_if_nonnull.
2021-05-20 08:10:07 +02:00
Brian Gianforcaro 7540f4268b Kernel: Remove s_processor_lock by making s_processors statically sized
Currently in SMP mode we hard code support for up to only 8 processors.
There is no reason for this to be a dynamic allocation that needs to be
guarded by a spinlock. Instead use a Array<T* with inline storage of 8,
allowing each processor to initialize it self in place, avoiding all
the need for locks.
2021-05-20 08:10:07 +02:00
Brian Gianforcaro 1415b2cfc3 Kernel: Do not allocate AnonymousVMObject's under spin lock
Spinlocks guard short regions, with hopefully no other locks being taken
in the process. Violating constraints usually had detrimental effects on
platform stability as well as performance and scalability. Allocating
memory takes it own locks, and can in some cases even allocate new
regions, and thus violates these tenants.

Move the AnonymousVMObject creation outside of the spinlock as
creation does not modify any shared state.
2021-05-20 08:10:07 +02:00
Brian Gianforcaro 83fc591cea Kernel: Generate page fault events from the kernel profiler
Hook the kernel page fault handler and capture page fault events when
the fault has a current thread attached in TLS. We capture the eip and
ebp so we can unwind the stack and locate which pieces of code are
generating the most page faults.

Co-authored-by: Gunnar Beutner <gbeutner@serenityos.org>
2021-05-19 22:51:42 +02:00
Gunnar Beutner 7dc77bd833 Kernel: Avoid an allocation in sys$poll 2021-05-19 22:51:42 +02:00
Gunnar Beutner 277f333b2b Kernel: Add support for profiling kmalloc()/kfree() 2021-05-19 22:51:42 +02:00
Gunnar Beutner 572bbf28cc Kernel+LibC: Add support for filtering profiling events
This adds the -t command-line argument for the profile tool. Using this
argument you can filter which event types you want in your profile.
2021-05-19 22:51:42 +02:00
Gunnar Beutner 8b2ace0326 Kernel: Track performance events for context switches 2021-05-19 22:51:42 +02:00
Lenny Maiorani 5751327195 Kernel: static vs non-static constexpr variables
Problem:
- `static` variables consume memory and sometimes are less
  optimizable.
- `static const` variables can be `constexpr`, usually.
- `static` function-local variables require an initialization check
  every time the function is run.

Solution:
- If a global `static` variable is only used in a single function then
  move it into the function and make it non-`static` and `constexpr`.
- Make all global `static` variables `constexpr` instead of `const`.
- Change function-local `static const[expr]` variables to be just
  `constexpr`.
2021-05-19 21:21:47 +01:00
Gunnar Beutner e9898a6031 Kernel: Use plain Function objects for the WorkQueue
The WorkQueue class previously had its own inline storage functionality
for function pointers. With the recent changes to the Function class
this is no longer necessary.
2021-05-19 21:36:57 +02:00
Justin 1c3badede3 Kernel: Add statvfs & fstatvfs Syscalls
These syscalls fill a statvfs struct with various data
about the mount on the VFS.
2021-05-19 21:33:29 +02:00
Justin 721a867c65 Kernel: Expose FileSystem's fragment size
This commit will add a fragment_size() function similar to the
block_size() function.
2021-05-19 21:33:29 +02:00
Max Wipfli 9cc201fb29 Kernel: Ignore null parent custody without error in VFS::open
This modifies the error checks in VFS::open after the call to
resolve_path to ignore a null parent custody if there is no error, as
this is expected when the path to resolve points to "/". Rather, a null
parent custody only constitutes an error if it is accompanied by ENOENT.
This behavior is documented in the VFS::resolve_path_without_veil
method.

To accompany this change, the order of the error checks have been
changed to more naturally fit the new logic.
2021-05-19 12:27:25 +02:00
Hendiadyoin1 ef425a02f7 Kernel: Implement mprotect for multiple Regions 2021-05-18 16:50:52 +02:00
Sahan Fernando 63a1be1406 Kernel: Don't update write_pos in DoubleBuffer if userspace copy fails 2021-05-18 16:47:26 +02:00
Sahan Fernando c3b670c092 Kernel: Acknowledge partial writes from TTYs
Fixes a bug where TTY::write will attempt to write into the underlying
device but will not acknowledge the result of that write, instead
assuming that the write fully completed.
2021-05-18 16:47:26 +02:00
Sahan Fernando d0f314b23c Kernel: Fix subtle race condition in sys$write implementation
There is a slight race condition in our implementation of write().
We call File::can_write() before attempting to write to it (blocking if
it returns false). If it returns true, we assume that we can write to
the file, and our code assumes that File::write() cannot possibly fail
by being blocked. There is, however, the rare case where another process
writes to the file and prevents further writes in between the call to
Files::can_write() and File::write() in the first process. This would
result in the first process calling File::write() when it cannot be
written to.

We fix this by adding a mechanism for File::can_write() to signal that
it was blocked, making it the responsibilty of File::write() to check
whether it can write and then finally making sys$write() check if the
write failed due to it being blocked.
2021-05-18 16:33:15 +02:00
Idan Horowitz 208cfcb0a5 Kernel: Add support for multiple serial ports per device
This commit adds support for initializing multiple serial ports per
PCI board, as well as initializing multiple different pci serial boards

Currently we just choose the first PCI serial port seen as the debug
port, but this should probably be made configurable some how in the
future.
2021-05-18 16:31:39 +02:00
Gunnar Beutner 093818de62 Kernel: Avoid allocations when receiving network packets
This avoids two allocations when receiving network packets. One for
inserting a PacketWithTimestamp into m_packet_queue and another one
when inserting buffers into the list of unused packet buffers.

With this fixed the only allocations in NetworkTask happen when
initially allocating the PacketWithTimestamp structs and when switching
contexts.
2021-05-18 16:06:27 +02:00
Lenny Maiorani ebb1d9740e BitmapView: Disable mutations of the underlying Bitmap
Problem:
- `BitmapView` permits changing the underlying `Bitmap`. This violates
  the idea of a "view" since views are simply overlays which can
  themselves change but do not change the underlying data.

Solution:
- Migrate all non-`const` member functions to Bitmap.
2021-05-18 08:10:45 +02:00
Gunnar Beutner 3cafdca868 Kernel: Disable profile timer when the process exits
When profiling a single process we didn't disable the profile timer.
enable_profile_timer()/disable_profiler_timer() support nested calls
so no special care has to be taken here to only disable the timer when
nobody else is using it.
2021-05-17 21:53:04 +02:00
Gunnar Beutner 52a4a1ec75 Kernel: Fix return value for {enable,disable}_profile_timer()
These functions should return success when being called when profiling
has been requested from multiple callers because enabling/disabling the
timer is a no-op in that case and thus didn't fail.
2021-05-17 21:53:04 +02:00
Idan Horowitz 79d3910145 Kernel: Stop overriding built-in serial port with PCI serial port
On a second thought, theres nothing stopping us from allowing poeple to
use both if they want to :^)
2021-05-17 19:45:35 +01:00
Idan Horowitz 51e9fdebea Kernel: Add support for QEMU's emulated pci serial (-pci-serial option) 2021-05-17 19:45:35 +01:00
Andreas Kling a15c7b7944 Build: Stop using precompiled headers (PCH)
This had very bad interactions with ccache, often leading to rebuilds
with 100% cache misses, etc. Ali says it wasn't that big of a speedup
in the end anyway, so let's not bother with it.

We can always bring it back in the future if it seems like a good idea.
2021-05-17 19:30:12 +02:00
Idan Horowitz a5603c35df Kernel: Fix spelling mistake in HPETComparator::try_to_set_frequency 2021-05-17 19:29:55 +02:00
Idan Horowitz 0ac3317764 Kernel: Set InterruptEnable on HPET Comparators when frequency is set
This fixes non-periodic comparators not receiving interrupts, as we
were never setting the InterruptEnable bit in their capabilities
register (unlike periodic comparators's bit, which was set as a side
effect of calling set_periodic on them to set their periodic bit).

This should help getting profiling work on bare-metal SerenityOS
installations, which were not guaranteed to have 2 periodic
comparators available.
2021-05-17 19:29:55 +02:00
Linus Groh 0aab774343 Everywhere: Fix a bunch of typos 2021-05-17 17:48:55 +01:00
Andreas Kling bebbeda726 Revert "BitmapView: Disable mutations of the underlying Bitmap"
This reverts commit f25209113f.
2021-05-17 18:29:47 +02:00
Daniel Bertalan 5d80debc1f LibVT: Fix newline handling
Before this commit, we would jump to the first column after receiving
the '\n' line feed character. This is not the correct behavior, as it
should only move the cursor now. Translating the typed Return key into
the correct CR LF ("\r\n") is the TTY's job, which was fixed in #7184.

Fixes #6820
Fixes #6960
2021-05-17 18:19:49 +02:00
Lenny Maiorani f25209113f BitmapView: Disable mutations of the underlying Bitmap
Problem:
- `BitmapView` permits changing the underlying `Bitmap`. This violates
  the idea of a "view" since views are simply overlays which can
  themselves change but do not change the underlying data.

Solution:
- Migrate all non-`const` member functions to Bitmap.
2021-05-17 18:16:35 +02:00
Idan Horowitz ba9b3dc656 Kernel: Implement a PCI Serial Device driver
This simple driver simply finds a device in a device definitions list
and then sets up a SerialDevice instance based on the definition.

The driver currently only supports "WCH CH382 2S" pci serial boards,
as that is the only device available for me to test with, but most
other pci serial devices should be as easily addable as adding a
board_definitions entry.
2021-05-17 18:15:25 +02:00
Idan Horowitz 62f69cc50f Kernel: Use IOAddress instead of direct IO calls in SerialDevice 2021-05-17 18:15:25 +02:00
Idan Horowitz a5699a141d Kernel: Add a put_char(char) method to SerialDevice
This can be used to print a single char to the serial port the
SerialDevice instance handles.
2021-05-17 18:15:25 +02:00
Idan Horowitz c75ca4ea8f Kernel: Bit mask line control options in SerialDevice::set_line_control
The line control option bits (parity, stop bits, word length) were
masked and then combined incorrectly, resulting in them not being set
when requested.
2021-05-17 18:15:25 +02:00
Idan Horowitz be57c424f3 Kernel: Swap baud rate divisor registers in SerialDevice::set_baud
These were accidentally the wrong way around (LSB part of the divisor
into the MSB register, MSB part of the divisor into the LSB register)
as can be seen in the specification (and in the comments themselves)
2021-05-17 18:15:25 +02:00