summaryrefslogtreecommitdiff
path: root/Kernel
AgeCommit message (Collapse)Author
2021-05-19Kernel: static vs non-static constexpr variablesLenny Maiorani
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-19Kernel: Use plain Function objects for the WorkQueueGunnar Beutner
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-19Kernel: Add statvfs & fstatvfs SyscallsJustin
These syscalls fill a statvfs struct with various data about the mount on the VFS.
2021-05-19Kernel: Expose FileSystem's fragment sizeJustin
This commit will add a fragment_size() function similar to the block_size() function.
2021-05-19Kernel: Ignore null parent custody without error in VFS::openMax Wipfli
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-18Kernel: Implement mprotect for multiple RegionsHendiadyoin1
2021-05-18Kernel: Don't update write_pos in DoubleBuffer if userspace copy failsSahan Fernando
2021-05-18Kernel: Acknowledge partial writes from TTYsSahan Fernando
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-18Kernel: Fix subtle race condition in sys$write implementationSahan Fernando
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-18Kernel: Add support for multiple serial ports per deviceIdan Horowitz
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-18Kernel: Avoid allocations when receiving network packetsGunnar Beutner
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-18BitmapView: Disable mutations of the underlying BitmapLenny Maiorani
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-17Kernel: Disable profile timer when the process exitsGunnar Beutner
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-17Kernel: Fix return value for {enable,disable}_profile_timer()Gunnar Beutner
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-17Kernel: Stop overriding built-in serial port with PCI serial portIdan Horowitz
On a second thought, theres nothing stopping us from allowing poeple to use both if they want to :^)
2021-05-17Kernel: Add support for QEMU's emulated pci serial (-pci-serial option)Idan Horowitz
2021-05-17Build: Stop using precompiled headers (PCH)Andreas Kling
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-17Kernel: Fix spelling mistake in HPETComparator::try_to_set_frequencyIdan Horowitz
2021-05-17Kernel: Set InterruptEnable on HPET Comparators when frequency is setIdan Horowitz
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-17Everywhere: Fix a bunch of typosLinus Groh
2021-05-17Revert "BitmapView: Disable mutations of the underlying Bitmap"Andreas Kling
This reverts commit f25209113fcd15df5778938c4accf13c5139d278.
2021-05-17LibVT: Fix newline handlingDaniel Bertalan
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-17BitmapView: Disable mutations of the underlying BitmapLenny Maiorani
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-17Kernel: Implement a PCI Serial Device driverIdan Horowitz
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-17Kernel: Use IOAddress instead of direct IO calls in SerialDeviceIdan Horowitz
2021-05-17Kernel: Add a put_char(char) method to SerialDeviceIdan Horowitz
This can be used to print a single char to the serial port the SerialDevice instance handles.
2021-05-17Kernel: Bit mask line control options in SerialDevice::set_line_controlIdan Horowitz
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-17Kernel: Swap baud rate divisor registers in SerialDevice::set_baudIdan Horowitz
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-17Kernel: Use unsigned instead of signed types in SerialDeviceIdan Horowitz
Addresses are unsigned by definition, and the conversion from signed to unsigned and back in SerialDevice looked a bit dubious.
2021-05-17Kernel: Initialize the PCI Bus earlier in the boot sequenceIdan Horowitz
We now initialize the PCI Bus as early as possible, to allow for early boot (PCI based) serial logging.
2021-05-17Kernel+Userspace: Implement the accept4() system callGunnar Beutner
Unlike accept() the new accept4() system call lets the caller specify flags for the newly accepted socket file descriptor, such as SOCK_CLOEXEC and SOCK_NONBLOCK.
2021-05-17Kernel+LibC: Support more `termios` settings in TTYDaniel Bertalan
This commit adds support for the various ECHO* lflags and fixes some POSIX conformance issues around newline handling. Also included are error messages when setting not implemented settings.
2021-05-17Kernel: Print failed attempt to shutdown the machineLiav A
Because we don't parse ACPI AML yet, If we are not able to shut down the machine with "hacky" emulation methods - halt and print this state to the users so they know they can shutdown the machine by themselves.
2021-05-17Kernel/Graphics: Be more consistent about arguments passingLiav A
This fixes a bug that was reported on this discord server by @ElectrodeYT - due to the confusion of passing arguments in different orders, we messed up and triggered a page fault due to faulty sizes.
2021-05-16Kernel/Graphics: Round size value when mapping real framebufferLiav A
2021-05-16Kernel/Graphics: Assign console to be from VGACompatibleAdapter alwaysLiav A
If we create a VGACompatibleAdapter object with a preset framebuffer, Always assign the console so we can use it. This is useful for modesetting done by a Multiboot loader, like GRUB.
2021-05-16Kernel/Graphics: Fix a method to be more accurate about its nameLiav A
2021-05-16Kernel: Move ConsoleDevice initialization just after kmalloc initLiav A
This will ensure we will get all the kernel log on the second tty.
2021-05-16Kernel: Print all logbuffer from ConsoleDevice to debug Virtual ConsoleLiav A
2021-05-16Kernel: Allow the user to specify the virtual console when bootingLiav A
2021-05-16Kernel: Print scheduler state to the display consoleLiav A
2021-05-16Kernel/Graphics + SystemServer: Support text mode properlyLiav A
As we removed the support of VBE modesetting that was done by GRUB early on boot, we need to determine if we can modeset the resolution with our drivers, and if not, we should enable text mode and ensure that SystemServer knows about it too. Also, SystemServer should first check if there's a framebuffer device node, which is an indication that text mode was not even if it was requested. Then, if it doesn't find it, it should check what boot_mode argument the user specified (in case it's self-test). This way if we try to use bochs-display device (which is not VGA compatible) and request a text mode, it will not honor the request and will continue with graphical mode. Also try to print critical messages with mininum memory allocations possible. In LibVT, We make the implementation flexible for kernel-specific methods that are implemented in ConsoleImpl class.
2021-05-16Kernel: Expand the kernel memory slot from 16 MiB to 32 MiBLiav A
Like in 8cd5477e54a19d5476e9a31d0677e58c9a4ce12d, we need to expand the kernel slot again to be able to boot again.
2021-05-16Kernel: Don't ref-count UsedMemoryRange during iterationLiav A
2021-05-16Kernel: Rename Console => ConsoleDeviceLiav A
This change will help to distinguish between the console device and the Console abstraction layer in the Graphics subsystem later.
2021-05-16Kernel/PCI: Add helper to determine if device can access IO spaceLiav A
2021-05-16Kernel: Drop support of GRUB VBE modesettingLiav A
We used GRUB to modeset the resolution for a long time, but for good reasons I see no point with keeping it supported in our kernel. We support bochs-display device on QEMU (both the VGA compatible and non-VGA compatible variants), so for QEMU we can still boot the system in graphical mode even without GRUB help. Also, we now have a native driver for Intel graphics and although it doesn't support most Intel graphics cards out there yet, it's a good starting point to support more cards. If a user wants to boot on bare-metal in graphical mode, all he needs to do is to add the removed flag back again, as the kernel still supports pre-set framebuffers.
2021-05-16Kernel/Graphics: Add basic support for Intel native acceleratorLiav A
We simply modeset the resolution after determining the preferred resolution after getting the EDID from the attached display.
2021-05-16Kernel: Introduce a new graphics subsystemLiav A
This new subsystem is replacing the old code that was used to create device nodes of framebuffer devices in /dev. This subsystem includes for now 3 roles: 1. GraphicsManagement singleton object that is used in the boot process to enumerate and initialize display devices. 2. GraphicsDevice(s) that are used to control the display adapter. 3. FramebufferDevice(s) that are used to control the device node in /dev. For now, we support the Bochs display adapter and any other generic VGA compatible adapter that was configured by the boot loader to a known and fixed resolution. Two improvements in the Bochs display adapter code are that we can support native bochs-display device (this device doesn't expose any VGA capabilities) and also that we use the MMIO region, to configure the device, instead of setting IO ports for such tasks.
2021-05-16Kernel: Support the bochs-display deviceLiav A
This device is a graphics display device that is not supporting VGA functionality. Therefore, it exposes a MMIO region to configure it, so we use that region to set the framebuffer resolution.