Commit graph

22529 commits

Author SHA1 Message Date
Alexander e9b7d58d10 Kernel/AHCI: Fix shift of 1
This makes the 1 in the shift unsigned.
This also changes the is_set_at parameter to be a u8.
2021-06-25 16:27:01 +02:00
Gunnar Beutner f17b4e561f Meta: Increase RAM amount for Bochs
Booting with 128 MB of RAM is kind of tough.
2021-06-25 15:19:09 +02:00
Gunnar Beutner c9747a3236 Kernel: Build the x86_64 kernel as an ELF32 executable
Multiboot only supports ELF32 executables. This changes the build
process to build an ELF32 executable which has a 32-bit entry point,
but consists of mostly 64-bit code.
2021-06-25 15:19:09 +02:00
Gunnar Beutner 04ba5cfcad Kernel: Ensure that the Multiboot header is placed into the first 8kB
The Multiboot header must be within the first 8kB of the executable
for it to be picked up by QEMU, GRUB and other multiboot-capable
boot loaders.
2021-06-25 15:19:09 +02:00
Gunnar Beutner 4c555684b7 Kernel: Set an appropriate GDT for 64-bit mode 2021-06-25 15:19:09 +02:00
Gunnar Beutner d84abe51f5 Kernel: Use PML4T for 64-bit mode 2021-06-25 15:19:09 +02:00
Gunnar Beutner 13e4093da4 Kernel: Move Multiboot header into a separate file 2021-06-25 15:19:09 +02:00
Gunnar Beutner 19c0498ccc Kernel: Update the x86_64 boot code to match i386's code 2021-06-25 15:19:09 +02:00
Gunnar Beutner 1979c7d185 Meta: Run 64-bit kernels with qemu-system-x86_64 2021-06-25 15:19:09 +02:00
Paul Irwin 5eb65286b6 LibWeb: Support :active pseudo-class for hyperlinks, :focus possibly
Adds support for the :active pseudo-class for hyperlinks (<a> tags
only).

Also, since it was very similar to :focus and an element having a
focused state was already implemented, I went ahead and implemented
that pseudo-class too, although I cannot come up with a working
example to validate it.
2021-06-25 01:02:29 +02:00
Aatos Majava 457edaa4d2 Browser: Add alternate shortcut F6 for focusing the location box 2021-06-25 01:01:37 +02:00
Aatos Majava d50ff2b422 LibGUI: Add alternate shortcut F5 to the "reload" common action 2021-06-25 01:01:37 +02:00
Aatos Majava 601dc8a128 LibGUI: Make Action::shortcut() return const&
Also do the same for Action::alternate_shortcut().
2021-06-25 01:01:37 +02:00
Aatos Majava b05078b610 LibGUI: Add a new constructor to Action
This constructor allows you to omit the modifier keys.

Instead of doing "{ 0, Key_F5 }" you can now just do "Key_F5"
2021-06-25 01:01:37 +02:00
Aatos Majava 3e6a5af32b LibGUI: Actually use the Action alternate shortcut
This adds the actual functionality to Window and Application.
2021-06-25 01:01:37 +02:00
Aatos Majava 21a193ed5a LibGUI: Add support for an alternate keyboard shortcut in Action
This patch adds the alternate_shortcut member to LibGUI::Action, which
enables one Action to have two keyboard shortcuts.

Note that the string used in menus and tooltips only shows the main
shortcut, which is the same behaviour as in Firefox and Chrome.
2021-06-25 01:01:37 +02:00
Spencer Dixon 5b79d53c89 LibGUI: Add update() when changing widget color or palette 2021-06-24 23:32:38 +02:00
Alexander a2a3f5228a WindowServer: Scale Mouse movements
This fixes a bug where if the current screen was using scaling, the
mouse would be twice as fast as normal.
2021-06-25 01:49:07 +04:30
Andreas Kling e59bf87374 Userland: Replace VERIFY(is<T>) with verify_cast<T>
Instead of doing a VERIFY(is<T>(x)) and *then* casting it to T, we can
just do the cast right away with verify_cast<T>. :^)
2021-06-24 21:13:09 +02:00
Andreas Kling 7fef8c5648 LibJS: Protect execution context variable environments from GC
At the moment these environments are always the same as the lexical
ones, so this didn't cause any trouble. Once we start separating them
we have to make sure both environments are protected.
2021-06-24 20:10:31 +02:00
Andreas Kling ee3a73ddbb AK: Rename downcast<T> => verify_cast<T>
This makes it much clearer what this cast actually does: it will
VERIFY that the thing we're casting is a T (using is<T>()).
2021-06-24 19:57:01 +02:00
Andreas Kling 6215a9c2cb LibJS: Rename ExecutionContext::callee => function
This matches what ECMAScript calls it. Also make it a JS::Function*
instead of a generic Value, since it will always either be a function
object or null.
2021-06-24 19:28:00 +02:00
Andreas Kling c2ad599783 LibJS: Rename CallFrame => ExecutionContext
This struct represents what the ECMAScript specification calls an
"execution context" so let's use the same terminology. :^)
2021-06-24 19:28:00 +02:00
Ali Mohammad Pur 7c88caf99f LibVT: Only resize the line after all rewrapping is done
Otherwise we would end up inserting empty cells into the wrapped lines.
Fixes #8227.
2021-06-24 18:50:45 +02:00
Daniel Bertalan ffb118265b Kernel: Remove superfluous alignas(T) from KResultOr<T>
Since `m_storage` is already guaranteed to be correctly aligned for the
type, we can forgo specifying it for the entire class.

This fixes an error: previously, this would *force* the value type's
alignment on the entire class, which would try to make 1-byte aligned
ints with `KResultOr<bool>`. GCC somehow compiled this (probably just
ignored it), but this caused a build error with Clang.

Closes #8072
2021-06-24 17:35:49 +04:30
Daniel Bertalan 2d2747cb15 LibCore+AK: Use proper atomics in Singleton 2021-06-24 17:35:49 +04:30
Daniel Bertalan e364845456 LibGfx: Don't constexpr functions returning Strings
Since strings don't have a constexpr constructor, these won't have any
effect anyways. Furthermore, this is explicitly disallowed by the
standard, and makes Clang tools freak out.
2021-06-24 17:35:49 +04:30
Daniel Bertalan 221bd464a0 Kernel: Fix attribute ordering
Clang requires that attributes declared using the bracketed
`[[attr_name]]` syntax come before those with
`__attribute__((attr-name))`.

This fixes a Clang build error.
2021-06-24 17:35:49 +04:30
Daniel Bertalan eee44c85d4 AK: Use __attribute__((name)) for functions everywhere
Clang enforces the ordering that attributes specified with the
`[[attr_name]]` syntax must comes before those defines as
`__attribute__((attr_name))`. We don't want to deal with that, so we
should stick to a single syntax (for functions, at least).

This commit favors the latter, as it's used more widely in the code
(for declaring more "exotic" options), and changing those would be a
larger effort than modifying this single file.
2021-06-24 17:35:49 +04:30
Daniel Bertalan 74535628a8 Kernel: Use proper Atomic<T> types in CPU
This is needed because Clang's intrinsic atomic functions behave weirdly
if only one of their pointer arguments is volatile.
2021-06-24 17:35:49 +04:30
Daniel Bertalan f28f00c654 Userland: Disambiguate dependent types
Clang produced an error on these pieces of code without the `typename`
keyword.
2021-06-24 17:35:49 +04:30
Daniel Bertalan f820917a76 Everywhere: Use nothrow new with adopt_{ref,own}_if_nonnull
This commit converts naked `new`s to `AK::try_make` and `AK::try_create`
wherever possible. If the called constructor is private, this can not be
done, so we instead now use the standard-defined and compiler-agnostic
`new (nothrow)`.
2021-06-24 17:35:49 +04:30
Daniel Bertalan 00915e8948 AK: Add factory methods for creating smart pointers
These functions abstract away the need to call the proper new operator
("throwing" or "non-throwing") and manually adopt the resulting raw
pointer. Modelled after the existing `NonnullOwnPtr<T> make()`
functions, these forward their parameters to the object's constructor.

Note: These can't be used in the common "factory method" idiom, as
private constructors can't be called from a standalone function.

The naming is consistent with AK's and Shell's previous implementation
of these:
- `make` creates a `NonnullOwnPtr<T>` and aborts if the allocation could
  not be performed.
- `try_make` creates an `OwnPtr<T>`, which may be null if the allocation
  failed.
- `create` creates a `NonnullRefPtr<T>`, and aborts on allocation
  failure.
- `try_create` creates a `RefPtr<T>`, which may be null if the
  allocation was not successful.
2021-06-24 17:35:49 +04:30
Daniel Bertalan 5491e0cdcc AK+Kernel: Make fallible allocations compiler-agnostic
In standard C++, operators `new` and `new[]` are guaranteed to return a
valid (non-null) pointer and throw an exception if the allocation
couldn't be performed. Based on this, compilers did not check the
returned pointer before attempting to use them for object construction.

To avoid this, the allocator operators were changed to be `noexcept` in
PR #7026, which made GCC emit the desired null checks. Unfortunately,
this is a non-standard feature which meant that Clang would not accept
these function definitions, as it did not match its expected
declaration.

To make compiling using Clang possible, the special "nothrow" versions
of `new` are implemented in this commit. These take a tag type of
`std::nothrow_t` (used for disambiguating from placement new/etc.), and
are allowed by the standard to return null. There is a global variable,
`std::nothrow`, declared with this type, which is also exported into the
global namespace.

To perform fallible allocations, the following syntax should be used:

```cpp
auto ptr = new (nothrow) T;
```

As we don't support exceptions in the kernel, the only way of uphold the
"throwing" new's guarantee is to abort if the allocation couldn't be
performed. Once we have proper OOM handling in the kernel, this should
only be used for critical allocations, where we wouldn't be able to
recover from allocation failures anyway.
2021-06-24 17:35:49 +04:30
Daniel Bertalan d6138df490 AK: Specialize Atomic<Integral> for clang compatibility
While Clang claims to implement GCC's atomics libcall API, a small
incompatibility caused our builds to fail on Clang.

Clang requires requires the operands to its fixed-size functions to be
integer types, while GCC will take any type with the same size and
alignment as the various integer primitives. This was problematic, as
atomic `enum class`es would not compile.

Furthermore, Clang does not like if only one operand pointer is marked
volatile. Because it only affects the standalone atomic functions, that
will be fixed in a later commit.

As an added benefit, the code is more type-safe, as it won't let us
perform arithmetic on non-integer types. Types with overloaded
arithmetic types won't cause unexpected behavior anymore.

The constructors for the various atomic types can now be used in
constant expressions.
2021-06-24 17:35:49 +04:30
Daniel Bertalan 985adcca38 AK: Make C++ concepts support mandatory for compilers
The latest GCC and Clang versions both support this, so we can freely
use these in our code.
2021-06-24 17:35:49 +04:30
brapru 4c0c4f3102 Utilities: Validate user with Core::Account in userdel
Previously the remove home directory option never actually removed the
user's home directory because it was not properly unveiled. By
validating the user with Core::Account, we can identify the user's home
directory earlier in the program and unveil as necessary.

Additionally, by identifying if the user does not exist much earlier in
the program, this elimates depending on getpwent to validate the user
and creating unneccessary temp files.
2021-06-24 17:33:14 +04:30
Andreas Kling bc1930e0e0 LibJS: Fix clang-tidy warnings in AST.h
- Add/remove `move()` as suggested.
- Add missing `explicit` on single-parameter constructors.
2021-06-24 13:38:21 +02:00
Andreas Kling 0eeb7f67a7 LibJS: Don't use m_ prefix for argument name in ScriptFunction 2021-06-24 13:29:25 +02:00
Andreas Kling ce2747692d LibJS: Remove unused DeclarativeEnvironmentRecord::type()
Nothing was using this, and we now have separate classes for the
different types of environment records instead.
2021-06-24 13:28:15 +02:00
Andreas Kling 0cd65b55bd LibJS: Add ObjectEnvironmentRecord.[[IsWithEnvironment]] field
This is true for environments created by `with` statements, and false
for other (global) object environments.

Also add the WithBaseObject abstract operation while we're here.
2021-06-24 13:26:00 +02:00
Jamie Mansfield 3f8857cd21 Games: Add Spider
Scoring is designed to mimic Microsoft's implementation - starting at
500, decreasing by 1 every move, and increasing by 100 for every full
stack.

Fixes GH-5319.
2021-06-24 10:32:53 +02:00
Jamie Mansfield b7e806e15e LibCards: Support non-alternating colour patience games
This introduces a new MovementType concept to LibCards, starting the
process to allow other patience games to be implemented using it - that
differ more substantially from Klondike in logic.

This is currently used for two purposes: 1. to verify that the
'grabbed' stack of cards is valid* (sequential and correct colours) and
2. to allow 'grabbed' stacks to be pushed onto same-colour,
either-colour, or alternating-colour stacks

* Klondike doesn't need this logic, as per how the game works any
  'grabbed' selection is guaranteed to be valid.
2021-06-24 10:32:53 +02:00
Max Wipfli 84c0f98fb2 Kernel: Reimplement the dbgputch and dbgputstr syscalls
This rewrites the dbgputch and dbgputstr system calls as wrappers of
kstdio.h.

This fixes a bug where only the Kernel's debug output was also sent to
a serial debugger, while the userspace's debug output was only sent to
the Bochs debugger.

This also fixes a bug where debug output from one process would
sometimes "interrupt" the debug output from another process in the
middle of a line.
2021-06-24 10:29:09 +02:00
Max Wipfli 67067904f5 Kernel: Add dbgputch() to kstdio.h
This adds a dbgputch() alongside dbgputstr() in kstdio.h. The function
already existed as the static function debugger_out(). It has now been
exposed to users of kstdio.h.
2021-06-24 10:29:09 +02:00
Gunnar Beutner 441d6dcdf9 Kernel: Fix compiling TmpFSInode::write_bytes on x86_64 2021-06-24 09:27:13 +02:00
Gunnar Beutner 15e25a8c1f AK: Fix building Ptr32 on x86_64 2021-06-24 09:27:13 +02:00
Gunnar Beutner 1ae7d68885 LibSymbolication: Fix incorrect argument type for symbolicate() 2021-06-24 09:27:13 +02:00
Gunnar Beutner 38fca26f54 Kernel: Add stubs for missing x86_64 functionality
This adds just enough stubs to make the kernel compile on x86_64. Obviously
it won't do anything useful - in fact it won't even attempt to boot because
Multiboot doesn't support ELF64 binaries - but it gets those compiler errors
out of the way so more progress can be made getting all the missing
functionality in place.
2021-06-24 09:27:13 +02:00
Gunnar Beutner f2eb759901 Profiler: Use u32 when constructing InstructionData
When constructing values of the InstructionData type we assume that
the event_count field is a size_t while it actually is a u32. On x86_64
this fails because those are different types.
2021-06-24 09:27:13 +02:00