Commit Graph

7083 Commits

Author SHA1 Message Date
Jesse Buhagiar
964f8fbf3a Kernel: Implement AVX XSAVE support
This adds some new buffers to the `FPUState` struct, which contains
enough space for the `xsave` instruction to run. This instruction writes
the upper part of the x86 SIMD registers (YMM0-15) to a seperate
256-byte area, as well as an "xsave header" describing the region.

If the underlying processor supports AVX, the `fxsave` instruction is no
longer used, as `xsave` itself implictly saves all of the SSE and x87
registers.

Co-authored-by: Leon Albrecht <leon.a@serenityos.org>
2022-05-15 12:25:23 +02:00
Timon Kruiper
18cad73b01 Kernel: Put code in the aarch64 init.cpp file into the Kernel namespace 2022-05-12 23:14:05 +02:00
Timon Kruiper
9282e0db16 Kernel: Move __assertion_failed to aarch64/Panic.cpp
This is for an upcoming change to add the Kernel namespace to the
init.cpp file.
2022-05-12 23:14:05 +02:00
Timon Kruiper
d451bdec6f Kernel: Remove PREKERNEL_SOURCES from aarch64 CMakeLists.txt 2022-05-12 23:14:05 +02:00
Timon Kruiper
4db44c09a4 Kernel: Use the Kernel UBSanitizer implementation in the aarch64 Kernel
Now we actually print useful information when an UBSAN fault is
detected. :^)
2022-05-12 23:14:05 +02:00
Timon Kruiper
1f3977b303 Kernel: Remove Prekernel namespace in the aarch64 Kernel
Now that we merged all the Prekernel files into the Kernel files, we can
get rid of the Prekernel namespace as well.
2022-05-12 23:14:05 +02:00
Timon Kruiper
c96a3f0c48 Kernel: Move the aarch64 boot.S out of the Prekernel directory 2022-05-12 23:14:05 +02:00
Timon Kruiper
e88cd338f1 Kernel: Move Prekernel{CPU, Exceptions}.cpp out of Prekernel directory
This lets us delete the Prekernel.h file, and gets us closer to deleting
the Prekernel from the aarch64 Kernel.
2022-05-12 23:14:05 +02:00
Timon Kruiper
e7c5fd978b Kernel: Move Prekernel assembly utils to aarch64/ASM_wrapper.h
By moving these functions to the ASM_wrapper.h file, we can get rid of
another Prekernel file.
2022-05-12 23:14:05 +02:00
Timon Kruiper
e80d8d697c Kernel: Replace Prekernel::halt with Processor::halt in aarch64 build
This allows us to get rid of one more Prekernel file.
2022-05-12 23:14:05 +02:00
Daniel Bertalan
fd3e3d5e28 LibC+Kernel: Prevent string functions from calling themselves
Most of the string.h and wchar.h functions are implemented quite naively
at the moment, and GCC's pattern recognition pass might realize what we
are trying to do, and transform them into libcalls. This is usually a
useful optimization, but not when we're implementing the functions
themselves :^)

Relevant discussion from the GCC Bugzilla:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102725

This prevents the infamous recursive `strlen`.

A more proper fix would be writing these functions in assembly. That
would likely give a small performance boost as well ;)
2022-05-12 13:12:37 +02:00
Daniel Bertalan
f157ad8a35 Kernel: Do not implement VERIFY_NOT_REACHED() as VERIFY(false)
If a switch case ends in VERIFY_NOT_REACHED(), gcc 12 thinks it might
fall through.
2022-05-12 13:12:37 +02:00
Timon Kruiper
b8854549f2 Kernel: Sort aarch64 CMake sources alphabetically 2022-05-09 21:12:56 +02:00
Timon Kruiper
c515e1341a Kernel: Add initial implementation of Processor in aarch64
Instead of storing the current Processor into a core local register, we
currently just store it into a global, since we don't support SMP for
aarch64 anyway. This simplifies the initial implementation.
2022-05-09 21:12:56 +02:00
Timon Kruiper
ed4bfaed12 Kernel: Call the constructors in the aarch64 init function
Now that we have separated the kmalloc.cpp constructors into a separate
library, we can actually call the constructors in the init function.
2022-05-09 21:12:56 +02:00
Timon Kruiper
2e49d6b001 Kernel: Separate kmalloc.cpp into a separate library similar to x86_64
This will allow the call the constructors of the kmalloc.cpp file
before calling the other constructors in the Kernel.
2022-05-09 21:12:56 +02:00
Timon Kruiper
d449fef606 Kernel: Reorder sections in aarch64 linker script to save space
By putting the NOLOAD sections (.bss and .super_pages) at the end of the
ELF file, objcopy does not have to insert a lot of zeros to make sure
that the .ksyms section is at the right place in memory. Now the .ksyms
section comes before the two NOLOAD sections. This shrinks the
kernel8.img with 6MB, from 8.3M to 2.3M. :^)
2022-05-09 21:12:56 +02:00
Timon Kruiper
a1b352fdc0 Kernel: Add some mission sections to the aarch64 linker script
The sections did end up in the ELF file, however they weren't
explicitely mentioned in the linker.ld script. In the future, we can add
the --orphan-handling=error flag to the linker options, which will
enforce that the sections used in the sources files also are mentioned
in the linker script.
2022-05-09 21:12:56 +02:00
Liav A
9bec9c2b78 Kernel: Force y offset 0 when switching between console & graphics modes
This fixes a weird bug that when sometimes a user tried to switch to
console mode, the screen was frozen on graphics mode. After a hour of
debugging this, it became apparent that the problem was that we left the
y offset of the bochs graphics device in an invalid state, so it was not
zero because the WindowServer changed it, and the framebuffer console
code is not aware of horizontal and vertical offsets of the framebuffer
screen, leading to the problem that the framebuffer console updates the
first framebuffer (y offset = 0), but hardware was indicated to show the
second framebuffer (y offset = first framebuffer height).

Therefore, when doing a switch between these modes, always set the y
offset to be zero.
2022-05-06 18:05:14 +02:00
Liav A
cd08c4a5aa Kernel/HID: Take a spinlock when calling KeyboardClient::on_key_pressed
The KeyboardClient class member could be updated due to TTY switch, so
we must ensure we always use a valid pointer.
2022-05-06 18:05:14 +02:00
Liav A
b8493bf70f Kernel/Graphics: Protect the list of display connectors with a Spinlock
This list could be updated in runtime if an hotplug event occurs, so we
must protect it with a spin lock to avoid corruption of the list.
2022-05-06 18:05:14 +02:00
Liav A
340773ddb7 Kernel/Graphics: Implement basic support for VMWare SVGA adapter 2022-05-06 18:04:57 +02:00
Liav A
a0a1ac0656 Kernel/Graphics: Use boot console if the subsystem is disabled
This lets us actually to initialize VirtualConsoles later on.
2022-05-06 12:28:19 +02:00
Liav A
0d784de3a6 Kernel/Graphics: Implement basic cursor for FramebufferConsole 2022-05-06 12:28:02 +02:00
MacDue
d951e2ca97 Kernel: Add /proc/{pid}/children to ProcFS
This exposes the child processes for a process as a directory
of symlinks to the respective /proc entries for each child.

This makes for an easier and possibly more efficient way
to find and count a process's children. Previously the only
method was to parse the entire /proc/all JSON file.
2022-05-06 02:12:51 +04:30
MacDue
222079cd80 Kernel: Expose .length() of KBufferBuilder 2022-05-06 02:12:51 +04:30
Liav A
969e5fa163 Kernel/Console: Use 8x16 character font bitmap instead of old 8x8 bitmap
This in turn makes the built-in kernel console much more nicer to look
into, so let's remove the support for 8x8 bitmap and instead add 8x16
font bitmap.
2022-05-05 21:51:57 +02:00
Liav A
b96b2fb9be Kernel/Graphics: Simplify the GenericGraphicsAdapter class
The old methods are already can be considered deprecated, and now after
we removed framebuffer devices entirely, we can safely remove these
methods too, which simplfies the GenericGraphicsAdapter class a lot.
2022-05-05 20:55:57 +02:00
Liav A
d49a35df31 Kernel/Graphics: Simplify the feature level of the Graphics subsystem
Instead of letting the user to determine whether framebuffer devices
will be created (which is useless because they are gone by now), let's
simplify the flow by allowing the user to choose between full, limited
or disabled functionality. The determination happens only once, so, if
the user decided to disable graphics support, the initialize method
exits immediately. If limited functionality is chosen, then a generic
DisplayConnector is initialized with the preset framebuffer resolution,
if present, and then the initialize method exits. As a default, the code
proceeds to initialize all drivers as usual.
2022-05-05 20:55:57 +02:00
Liav A
e301af8352 Everywhere: Purge all support and usage of framebuffer devices
Long live the DisplayConnector object!
2022-05-05 20:55:57 +02:00
Liav A
aad968cc5e Everywhere: Rename fb prefix function names => graphics_connector 2022-05-05 20:55:57 +02:00
Liav A
10adc27eda Everywhere: Rename FB prefix structure names => Graphics 2022-05-05 20:55:57 +02:00
Liav A
d2e93ec50a Everywhere: Rename FB prefix name ioctls => GRAPHICS 2022-05-05 20:55:57 +02:00
Liav A
f15b93c9a1 Kernel/Graphics: Use DisplayConnector design with generic framebuffers 2022-05-05 20:55:57 +02:00
Liav A
c27c414ed1 Kernel/Graphics: Apply DisplayConnector design on the VirtIO driver 2022-05-05 20:55:57 +02:00
Liav A
4ff6150f1b WindowServer: Use FB_IOCTL_FLUSH_HEAD to flush a framebuffer if possible
This ioctl is more appropriate when the hardware supports flushing of
the entire framebuffer, so we use that instead of the previous default
FB_IOCTL_FLUSH_HEAD_BUFFERS ioctl.
2022-05-05 20:55:57 +02:00
Liav A
41283a2de6 Kernel/Graphics: Use VirtIO GPU3DDevice constructor indirectly
We shouldn't expose the VirtIO GPU3DDevice constructor as public method,
so instead, let's use the usual pattern of a static construction method
that uses the constructor within the method.
2022-05-05 20:55:57 +02:00
Liav A
728358c599 Kernel/Graphics: Migrate Intel driver to use the DisplayConnector design 2022-05-05 20:55:57 +02:00
Liav A
e9a74cbefb Kernel/Graphics: Use DisplayConnector design for the Bochs driver 2022-05-05 20:55:57 +02:00
Liav A
6d7e2596e0 WindowServer: Implement mechanism to restore safe mode setting
Such mechanism will be used by the Intel Graphics driver, because we
lack support of changing the resolution on this driver currently, so,
when WindowServer will try to mode-set the display then it will fail,
and will use the safe mode-setting call instead to be able to show
something on screen.
2022-05-05 20:55:57 +02:00
Liav A
d9a2706079 DisplaySettings+WindowServer: Add support for display connector devices 2022-05-05 20:55:57 +02:00
Liav A
e6ebf9e5c1 Kernel/Memory: Add TypedMapping base_address method
This method will be used to ease usage with the structure when we need
to do virtual pointer arithmetics.
2022-05-05 20:55:57 +02:00
Liav A
9f0b5b04ff Kernel/Graphics: Export Bochs definitions to a header file
These definitions will be used later when applying the DisplayConnector
design on the Bochs driver.
2022-05-05 20:55:57 +02:00
Liav A
912b8ab965 Kernel/Graphics: Introduce the DisplayConnector class
The DisplayConnector class is meant to replace the FramebufferDevice
class. The advantage of this class over the FramebufferDevice class is:
1. It removes the mmap interface entirely. This interface is unsafe, as
multiple processes could try to use it, and when switching to and from
text console mode, there's no "good" way to revoke a memory mapping from
this interface, let alone when there are multiple processes that call
this interface. Therefore, in the DisplayConnector class there's no
implementation for this method at all.
2. The class uses a new real-world structure called ModeSetting, which
takes into account the fact that real hardware requires more than width,
height and pitch settings to mode-set the display resolution.
3. The class assumes all instances should supply some sort of EDID,
so it facilitates such mechanism to do so. Even if a given driver does
not know what is the actual EDID, it will ask to create default-generic
EDID blob.
3. This class shifts the responsibilies of switching between console
mode and graphical mode from a GraphicsAdapter to the DisplayConnector
class, so when doing the switch, the GraphicsManagement code actually
asks each DisplayConnector object to do the switch and doesn't rely on
the GraphicsAdapter objects at all.
2022-05-05 20:55:57 +02:00
Liav A
ebf7225728 Kernel/Graphics: Declare BochsGraphicsAdapter::get_edid private method 2022-05-05 20:55:57 +02:00
Tim Schumacher
0ce43fae9c Kernel: Add IPv4 network class masks 2022-05-05 20:47:38 +02:00
Tim Schumacher
7dd4648565 Kernel: Add IPsec ESP and AH protocol numbers 2022-05-05 20:47:38 +02:00
Tim Schumacher
098af0f846 Kernel: Properly define IOV_MAX 2022-05-05 20:47:38 +02:00
Tim Schumacher
6d59d4d3d9 Kernel: Add the remaining POSIX MADV_* constants 2022-05-05 20:47:38 +02:00
Tim Schumacher
94ab75d3df Kernel: Add O_SYNC into fcntl.h 2022-05-05 20:47:38 +02:00