Commit Graph

600 Commits

Author SHA1 Message Date
Andreas Kling
ad3ae7e0e8 Kernel: Fix handful of remaining "return -EFOO" mistakes
Now that all KResult and KResultOr are used consistently throughout the
kernel, it's no longer necessary to return negative error codes.
However, we were still doing that in some places, so let's fix all those
(bugs) by removing the minuses. :^)
2021-08-06 00:37:47 +02:00
Andreas Kling
066d3281b5 Kernel: Make AsyncDeviceRequest::name() return StringView 2021-08-06 00:37:47 +02:00
Andreas Kling
26d7261347 Kernel: Make NullDevice (/dev/null) seekable 2021-08-03 10:36:48 +02:00
Patrick Meyer
d5fdb97a81 Kernel: Fix integer overflow in KCOV_SETBUFSIZE ioctl 2021-07-26 23:52:15 +02:00
Ali Mohammad Pur
e76af0fe16 Kernel: Make KCOVDevice::ioctl() return KResult
Recent ioctl() changes broke this, this commit fixes that
and the build.
2021-07-27 01:38:06 +04:30
Brian Gianforcaro
de9ff0af50 Kernel: Modify the IOCTL API to return KResult
The kernel has been gradually moving towards KResult from just bare
int's, this change migrates the IOCTL paths.
2021-07-27 01:23:37 +04:30
Brian Gianforcaro
9a04f53a0f Kernel: Utilize AK::Userspace<T> in the ioctl interface
It's easy to forget the responsibility of validating and safely copying
kernel parameters in code that is far away from syscalls. ioctl's are
one such example, and bugs there are just as dangerous as at the root
syscall level.

To avoid this case, utilize the AK::Userspace<T> template in the ioctl
kernel interface so that implementors have no choice but to properly
validate and copy ioctl pointer arguments.
2021-07-27 01:23:37 +04:30
Patrick Meyer
83f88df757 Kernel: Add option to build with coverage instrumentation and KCOV
GCC and Clang allow us to inject a call to a function named
__sanitizer_cov_trace_pc on every edge. This function has to be defined
by us. By noting down the caller in that function we can trace the code
we have encountered during execution. Such information is used by
coverage guided fuzzers like AFL and LibFuzzer to determine if a new
input resulted in a new code path. This makes fuzzing much more
effective.

Additionally this adds a basic KCOV implementation. KCOV is an API that
allows user space to request the kernel to start collecting coverage
information for a given user space thread. Furthermore KCOV then exposes
the collected program counters to user space via a BlockDevice which can
be mmaped from user space.

This work is required to add effective support for fuzzing SerenityOS to
the Syzkaller syscall fuzzer. :^) :^)
2021-07-26 17:40:28 +02:00
Andreas Kling
5217875f6a Kernel: Consolidate API for creating AnonymousVMObject with given pages
We don't need to have a dedicated API for creating a VMObject with a
single page, the multi-page API option works in all cases.

Also make the API take a Span<NonnullRefPtr<PhysicalPage>> instead of
a NonnullRefPtrVector<PhysicalPage>.
2021-07-22 09:17:02 +02:00
Andreas Kling
cee9528168 Kernel: Rename Lock to Mutex
Let's be explicit about what kind of lock this is meant to be.
2021-07-17 21:10:32 +02:00
Tom
82e9fe8d67 Kernel: Optionally dump scheduler state with stack traces
This will dump stack traces of all threads when pressing
Ctrl+Shift+Alt+F12
2021-07-15 23:46:37 +02:00
Brian Gianforcaro
425195e93f Kernel: Standardize the header include style to 'include <Kernel/...>'
This is the overwhelming standard in the project, but there were some
cases in the kernel which were not following it, lets fix those cases!
2021-07-11 21:37:38 +02:00
Brian Gianforcaro
ea238e7ac3 Kernel: Remove unused header includes in Devices subtree 2021-07-11 21:37:38 +02:00
Andreas Kling
88d490566f Kernel: Rename various *VMObject::create*() => try_create()
try_*() implies that it can fail (and they all return RefPtr with
nullptr signalling failure.)
2021-07-11 17:55:29 +02:00
Andreas Kling
c9f6786e8b Kernel: Make various T::class_name() and similar return StringView
Instead of returning char const*, we can also give you a StringView.
2021-07-11 01:46:59 +02:00
Edwin Hoksberg
99328e1038 Kernel+KeyboardSettings: Remove numlock syscall and implement ioctl 2021-07-07 10:44:20 +02:00
Edwin Hoksberg
385e2ccb66 Kernel: Add keyboard ioctl to get num/caps lock state 2021-07-07 10:44:20 +02:00
ForLoveOfCats
ce6658acc1 KeyboardSettings+Kernel: Setting to enable Num Lock on login 2021-07-05 06:19:59 +02:00
Liav A
3fae7ca113 Kernel: Clarify and make it easy to not use raw numbers
Let's put the PCI IDs as enums in the PCI namespace so they're free to
pollute that namespace, but it's also more easier to use them.
2021-07-03 16:28:49 +02:00
Daniel Bertalan
42d197cde7 Kernel: Fix miscellaneous warnings when building with Clang
These small changes fix the remaining warnings that come up during
kernel compilation with Clang. These specific fixes were for benign
things: unused lambda captures and braces around scalar initializers.
2021-07-03 01:56:31 +04:30
Daniel Bertalan
b97a00d4b1 Kernel: Add missing override specifiers
The `#pragma GCC diagnostic` part is needed because the class has
virtual methods with the same name but different arguments, and Clang
tries to warn us that we are not actually overriding anything with
these.

Weirdly enough, GCC does not seem to care.
2021-07-03 01:56:31 +04:30
Liav A
5073bf8e75 Kernel/USB: Move the USB components as a subfolder to the Bus directory 2021-07-02 13:16:12 +02:00
Liav A
6568bb47cb Kernel/PCI: Move the PCI components as a subfolder to the Bus directory 2021-07-02 13:16:12 +02:00
Andrew Kaster
e821b349b2 Kernel: Give Devices without a custody a less fake absoulte_path
This hack allows self-test mode run-tests-and-shutdown.sh to give
TestProcFs a stat(2)-able /proc/self/fd/0. For some reason, when
stdin is a SerialDevice, /proc/self/fd/0 will be a symlink to the device
as expected, but, calling realpath or stat on /proc/self/fd/0 will error
out. realpath will give the string from Device::absolute_path() which
would be something like "device:4,64 (SerialDevice)". When VFS is trying
to resolve_path so that we can stat the file, it would bail out on this
fake-y path.

Change the fake path (that doesn't show up when you ls a device, nor
when checking the devices tab in SystemMonitor) from the major/minor
device number and class_name() to /dev/device_name(). There's probably
a very hairy yak standing behind this issue that was only discovered due
to the ProcFS rework.
2021-06-30 12:07:57 +04:30
Andreas Kling
9766fccb88 Kernel: Remove some unnecessary JSON related includes 2021-06-29 22:11:10 +02:00
Liav A
12b6e69150 Kernel: Introduce the new ProcFS design
The new ProcFS design consists of two main parts:
1. The representative ProcFS class, which is derived from the FS class.
The ProcFS and its inodes are much more lean - merely 3 classes to
represent the common type of inodes - regular files, symbolic links and
directories. They're backed by a ProcFSExposedComponent object, which
is responsible for the functional operation behind the scenes.
2. The backend of the ProcFS - the ProcFSComponentsRegistrar class
and all derived classes from the ProcFSExposedComponent class. These
together form the entire backend and handle all the functions you can
expect from the ProcFS.

The ProcFSExposedComponent derived classes split to 3 types in the
manner of lifetime in the kernel:
1. Persistent objects - this category includes all basic objects, like
the root folder, /proc/bus folder, main blob files in the root folders,
etc. These objects are persistent and cannot die ever.
2. Semi-persistent objects - this category includes all PID folders,
and subdirectories to the PID folders. It also includes exposed objects
like the unveil JSON'ed blob. These object are persistent as long as the
the responsible process they represent is still alive.
3. Dynamic objects - this category includes files in the subdirectories
of a PID folder, like /proc/PID/fd/* or /proc/PID/stacks/*. Essentially,
these objects are always created dynamically and when no longer in need
after being used, they're deallocated.
Nevertheless, the new allocated backend objects and inodes try to use
the same InodeIndex if possible - this might change only when a thread
dies and a new thread is born with a new thread stack, or when a file
descriptor is closed and a new one within the same file descriptor
number is opened. This is needed to actually be able to do something
useful with these objects.

The new design assures that many ProcFS instances can be used at once,
with one backend for usage for all instances.
2021-06-29 20:53:59 +02:00
Daniel Bertalan
2a5d9a6944 Kernel: Fix adopt_ref_if_nonnull(new T).release_nonnull() pattern
This does the exact thing as `adopt_ref`, which is a recent addition to
AK.

Note that pointers returned by a bare new (without `nothrow`) are
guaranteed not to return null, so they can safely be converted into
references.
2021-06-29 22:57:52 +04:30
Sahan Fernando
ae5d961d97 Kernel: Pass TTY-switch keyboard combo to userspace 2021-06-25 19:26:30 +02:00
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
Hendiadyoin1
62f9377656 Kernel: Move special sections into Sections.h
This also removes a lot of CPU.h includes infavor for Sections.h
2021-06-24 00:38:23 +02:00
Hendiadyoin1
7ca3d413f7 Kernel: Pull apart CPU.h
This does not add any functional changes
2021-06-24 00:38:23 +02:00
Liav A
29f9a38f76 Kernel: Don't use naked new statements in init process
Instead, try to create the device objects in separate static methods,
and if we fail for some odd reason to allocate memory for such devices,
just panic with that reason.
2021-06-19 09:30:43 +02:00
Jesse Buhagiar
71c9572e74 USB: Store device descriptor on enumeration
We now store the device descriptor obtained from the device
during enumeration in the device's object in memory instead
of exposing all of the different members contained within it.
2021-06-18 17:04:57 +04:30
Jesse Buhagiar
7b42146f33 USB: Store devices in globally accessible array
USB Devices are now stored so that they may be later retrieved and
operated on (i.e, fetching their assigned device address via
ProcFS)
2021-06-18 17:04:57 +04:30
Gunnar Beutner
9b14a8605a Kernel: Add a VERIFY() to make sure our DMA address is valid
This checks whether the address we're trying to use for DMA is low
enough so as not to overflow the I/O register.
2021-06-17 19:52:13 +02:00
Liav A
b91df26d4a Kernel/Interrupts: Return boolean on whether we handled the interrupt
If we are in a shared interrupt handler, the called handlers might
indicate it was not their interrupt, so we should not increment the
call counter of these handlers.
2021-06-17 16:53:25 +02:00
Liav A
c802b1a363 Kernel/Interrupts: Add sensible purposes to VirtIO and USB devices
When we enumerate the interrupt handlers, it's a good idea to show a
meaningful name to the user instead of "IRQ Handler".
2021-06-17 16:53:25 +02:00
Gunnar Beutner
bc3076f894 Kernel: Remove various other uses of ssize_t 2021-06-16 21:29:36 +02:00
Jesse Buhagiar
06f1edb516 USB: Further Implement USB Structures
These are the actual structures that allow USB to work (i.e the ones
actually defined in the specification). This should provide us enough
of a baseline implementation that we can build on to support
different types of USB device.
2021-06-12 18:17:25 +04:30
Brian Gianforcaro
f124affc8e Kernel: Mark PCISerialDevice::detect() as UNMAP_AFTER_INIT 2021-06-09 10:57:51 +02:00
Sebastian Zaha
77044dd383
Kernel: Fix crash when switching to console 5 & 6
The changes in commit 20743e8 removed the s_max_virtual_consoles
constant and hardcoded the number of consoles to 4. But in
PS2KeyboardDevice the keyboard shortcuts for switching to consoles were
hardcoded to 6.

I reintroduced the constant and added it in both places.
2021-05-31 17:42:21 +01: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
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
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
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
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
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
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
Idan Horowitz
0e5aba16ef Kernel: Use unsigned instead of signed types in SerialDevice
Addresses are unsigned by definition, and the conversion from signed
to unsigned and back in SerialDevice looked a bit dubious.
2021-05-17 18:15:25 +02:00
Liav A
99eab4667a Kernel: Print scheduler state to the display console 2021-05-16 19:58:33 +02:00
Liav A
20743e8aed Kernel/Graphics + SystemServer: Support text mode properly
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-16 19:58:33 +02:00
Liav A
6a728e2d76 Kernel: Introduce a new graphics subsystem
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-16 19:58:33 +02:00
Liav A
86be477da0 Kernel: Support the bochs-display device
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.
2021-05-16 19:58:33 +02:00
Sahan Fernando
e4f61c6f28 Kernel: Fix return values of BXVGADevice::read/write 2021-05-15 17:43:45 +01:00
Brian Gianforcaro
d76dedb381 Kernel: Fix UHCIController singleton startup null-deref race condition.
The following KUBSAN crash on startup was reported on discord:

```
UHCI: Started
KUBSAN: reference binding to null pointer of type struct UHCIController
KUBSAN: at ../../Kernel/Devices/USB/UHCIController.cpp, line 67
```

After inspecting the code, it became clear that there's a window of time
where the kernel task which monitors the UHCI port can startup and start
executing before the UHCIController constructor completes. This leaves
the singleton pointing to nullptr, thus in the duration of this race
window the "UHCI port proc" thread will go an and de-reference the null
pointer when trying to read for status changes on the UHCI root ports.

Reported-by: @stelar7
Reported-by: @bcoles

Fixes: #6154
2021-05-15 09:46:41 +02:00
Brian Gianforcaro
a324d4d6a3 Kernel: Make AnonymousVMObject physical page APIs OOM safe
AnonymousVMObject::create_with_physical_page(s) can't be NonnullRefPtr
as it allocates internally. Fixing the API then surfaced an issue in
ScatterGatherList, where the code was attempting to create an
AnonymousVMObject in the constructor which will not be observable
during OOM.

Fix all of these issues and start propagating errors at the callers
of the AnonymousVMObject and ScatterGatherList APis.
2021-05-15 09:01:32 +02:00
Andreas Kling
e46343bf9a Kernel: Make UserOrKernelBuffer R/W helpers return KResultOr<size_t>
This makes error propagation less cumbersome (and also exposed some
places where we were not doing it.)
2021-05-13 23:28:40 +02:00
Liav A
f7b5352af0 Kernel/HID: Don't assume that ACPI is initialized 2021-05-08 19:15:54 +02:00
Spencer Dixon
0f89e47a1a
Kernel: Allow remapping Caps Lock to Control (#6883)
We use a global setting to determine if Caps Lock should be remapped to
Control because we don't care how keyboard events come in, just that they
should be massaged into different scan codes.

The `proc` filesystem is able to manipulate this global variable using
the `sysctl` utility like so:

```
# sysctl caps_lock_to_ctrl=1
```
2021-05-05 23:10:56 +02:00
Brian Gianforcaro
4bf9b399f7 Kernel: Remove unused header includes from various files.
Found while browsing code with CLion.
2021-05-03 16:03:17 +02:00
Brian Gianforcaro
65138171f9 Kernel: Mark AsyncBlockDeviceRequest + AnonymousVMObject as final
Mark final to aid in de-virtualization since they are not currently
derived from.
2021-05-03 16:03:17 +02:00
Gunnar Beutner
6cf59b6ae9 Everywhere: Turn #if *_DEBUG into dbgln_if/if constexpr 2021-05-01 21:25:06 +02:00
Idan Horowitz
8293b22361 Kernel: Handle both shift keys being pressed and then released
Our current implementation does not work in the special case in which
both shift keys are pressed, and then only one of the keys is released,
as this would result in writing lower case letters, instead of the
expected upper case letters.

This commit fixes that by keeping track of the amount of shift keys
that are pressed (instead of if any are at all), and only switching to
the unshifted keymap once all of them are released.
2021-05-01 21:08:23 +02:00
Valtteri Koskivuori
370231c05c Kernel: Expose minor device numbers for keyboard and mouse
A fix for two FIXMEs, and paving the way for multi-keyboard/mouse
support, I guess.
2021-05-01 20:07:11 +02:00
Linus Groh
649d2faeab Everywhere: Use "the SerenityOS developers." in copyright headers
We had some inconsistencies before:

- Sometimes "The", sometimes "the"
- Sometimes trailing ".", sometimes no trailing "."

I picked the most common one (lowecase "the", trailing ".") and applied
it to all copyright headers.

By using the exact same string everywhere we can ensure nothing gets
missed during a global search (and replace), and that these
inconsistencies are not spread any further (as copyright headers are
commonly copied to new files).
2021-04-29 00:59:26 +02:00
Linus Groh
dbe72fd962 Everywhere: Remove empty line after function body opening curly brace 2021-04-25 20:20:00 +02:00
Andreas Kling
b91c49364d AK: Rename adopt() to adopt_ref()
This makes it more symmetrical with adopt_own() (which is used to
create a NonnullOwnPtr from the result of a naked new.)
2021-04-23 16:46:57 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Brian Gianforcaro
ce5a308f24 Kernel: Annotate more AsyncDeviceRequest API's with [[nodiscard]] 2021-04-21 19:31:49 +02:00
Brian Gianforcaro
033b287635 Kernel: Make AsyncDeviceRequest sub-req management alloc free
The previous implementation could allocate on insertion into the completed / pending
sub request vectors. There's no reason these can't be intrusive lists instead.

This is a very minor step towards improving the ability to handle OOM, as tracked by #6369
It might also help improve performance on the IO path in certain situations.
I'll benchmark that later.
2021-04-21 19:31:49 +02:00
Andreas Kling
24dcd99e4b Kernel: Add magic key combo (Alt+Shift+F12) to dump scheduler state
Pressing this combo will dump a list of all threads and their state
to the debug console.

This might be useful to figure out why the system is not responding.
2021-04-18 20:00:10 +02:00
Luke
c84107a1ab Kernel: Add boot argument to disable the UHCI Controller
Helps with bare metal debugging, as we can't be sure our implementation
will work with a given machine.

As reported by someone on Discord, their machine hangs when we attempt
the dummy transfer.
2021-04-18 17:01:22 +02:00
Liav A
a0be30f655 Kernel: Introduce two new boot arguments to assist with bare metal debug
The first one is for disabling the PS2 controller, the other one is for
disabling physical storage enumeration.
We can't be sure any machine will work with our implementation,
therefore this will help us to test more machines.
2021-04-08 22:17:13 +02:00
Andreas Kling
a6ec6b831b Kernel: Remove unused UHCI_ENABLED flag 2021-04-07 22:47:22 +02:00
Liav A
8e3e3a71cb Kernel: Introduce a new HID subsystem
The end goal of this commit is to allow to boot on bare metal with no
PS/2 device connected to the system. It turned out that the original
code relied on the existence of the PS/2 keyboard, so VirtualConsole
called it even though ACPI indicated the there's no i8042 controller on
my real machine because I didn't plug any PS/2 device.
The code is much more flexible, so adding HID support for other type of
hardware (e.g. USB HID) could be much simpler.

Briefly describing the change, we have a new singleton called
HIDManagement, which is responsible to initialize the i8042 controller
if exists, and to enumerate its devices. I also abstracted a bit
things, so now every Human interface device is represented with the
HIDDevice class. Then, there are 2 types of it - the MouseDevice and
KeyboardDevice classes; both are responsible to handle the interface in
the DevFS.

PS2KeyboardDevice, PS2MouseDevice and VMWareMouseDevice classes are
responsible for handling the hardware-specific interface they are
assigned to. Therefore, they are inheriting from the IRQHandler class.
2021-04-03 11:57:23 +02:00
Tom
20cccda731 Kernel: Add simplistic work queues
We can't use deferred functions for anything that may require preemption,
such as copying from/to user or accessing the disk. For those purposes
we should use a work queue, which is essentially a kernel thread that
may be preempted or blocked.
2021-03-21 13:41:09 +01:00
Hendiadyoin1
0d934fc991 Kernel::CPU: Move headers into common directory
Alot of code is shared between i386/i686/x86 and x86_64
and a lot probably will be used for compatability modes.
So we start by moving the headers into one Directory.
We will probalby be able to move some cpp files aswell.
2021-03-21 09:35:23 +01:00
Hendiadyoin1
0b04363b01 Kernel: Renable UHCIController on 64-bit processors 2021-03-21 09:35:23 +01:00
Jean-Baptiste Boric
6698fd84ff Kernel: Refactor storage stack with u64 as mmap offset 2021-03-19 09:15:19 +01:00
Jean-Baptiste Boric
b05b4d4b24 Kernel: Refactor storage stack with u64 as file operations offset 2021-03-17 23:22:42 +01:00
Jean-Baptiste Boric
999c57ef2d Kernel: Refactor storage stack with u64 as block index 2021-03-17 23:22:42 +01:00
Tom
5ccc3637e3 Kernel: Fix race conditions processing async device requests 2021-03-15 09:06:41 +01:00
Andreas Kling
ef1e5db1d0 Everywhere: Remove klog(), dbg() and purge all LogStream usage :^)
Good-bye LogStream. Long live AK::Format!
2021-03-12 17:29:37 +01:00
Andreas Kling
4c7f486f39 Kernel: Convert klog() => AK::Format in UHCIController 2021-03-12 15:22:35 +01:00
Andreas Kling
f432f104fc Kernel: Convert klog() => AK::Format in SB16 2021-03-12 15:22:35 +01:00
Andreas Kling
201d35e70f Kernel: Convert klog() => dbgln() in BXVGADevice 2021-03-12 11:40:41 +01:00
Andreas Kling
38f11cc1ba Everywhere: Rename "logo" key to "super" key
This seems to be the most common way to refer to this key, so let's
call it what people actually call it.
2021-03-11 18:55:16 +01:00
Andreas Kling
a906670d1c Kernel: Convert klog() => dmesgln() in VMWareBackdoor 2021-03-09 22:10:41 +01:00
Andreas Kling
5fd3006db2 Kernel: Convert klog() => dmesgln() in PS2MouseDevice 2021-03-09 22:10:41 +01:00
Andreas Kling
adb2e6be5f Kernel: Make the kernel compile & link for x86_64
It's now possible to build the whole kernel with an x86_64 toolchain.
There's no bootstrap code so it doesn't work yet (obviously.)
2021-03-04 18:25:01 +01:00
Brendan Coles
953f4f7e60 Kernel: Create /dev/full with mode 0666 2021-03-04 09:19:38 +01:00
Brian Gianforcaro
84a399de5d Kernel: Move Kernel CommandLine parsing to strongly typed API.
Previously all of the CommandLine parsing was spread out around the
Kernel. Instead move it all into the Kernel CommandLine class, and
expose a strongly typed API for querying the state of options.
2021-03-03 11:05:16 +01:00
Ben Wiederhake
2b6546c40a Kernel: Make Thread use AK::Time internally
This commit is very invasive, because Thread likes to take a pointer and write
to it. This means that translating between timespec/timeval/Time would have been
more difficult than just changing everything that hands a raw pointer to Thread,
in bulk.
2021-03-02 08:36:08 +01:00
Tom
b4c1b96d96 Kernel: Fix scrolling up in VMware
The mouse wheel delta is provided as a signed 8 bit value.
2021-03-01 11:10:10 +01:00
Ben Wiederhake
860a3bbce3 Kernel: Use default con/de-structors
This may seem like a no-op change, however it shrinks down the Kernel by a bit:
.text -432
.unmap_after_init -60
.data -480
.debug_info -673
.debug_aranges 8
.debug_ranges -232
.debug_line -558
.debug_str -308
.debug_frame -40

With '= default', the compiler can do more inlining, hence the savings.
I intentionally omitted some opportunities for '= default', because they
would increase the Kernel size.
2021-02-28 18:09:12 +01:00
Andreas Kling
5d180d1f99 Everywhere: Rename ASSERT => VERIFY
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)

Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.

We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
2021-02-23 20:56:54 +01:00
Andreas Kling
cc0f5917d3 Kernel: Slap a handful more things with UNMAP_AFTER_INIT 2021-02-20 00:00:19 +01:00
Andreas Kling
2b2828ae52 Kernel: Slap UNMAP_AFTER_INIT on a bunch more functions
We're now able to unmap 100 KiB of kernel text after init. :^)
2021-02-19 21:42:18 +01:00
Andreas Kling
fdf03852c9 Kernel: Slap UNMAP_AFTER_INIT on a whole bunch of functions
There's no real system here, I just added it to various functions
that I don't believe we ever want to call after initialization
has finished.

With these changes, we're able to unmap 60 KiB of kernel text
after init. :^)
2021-02-19 20:23:05 +01:00
Andreas Kling
40e5210036 Kernel: Convert dbgprintf()/klog() => dbgln()/dmesgln() in UHCI code 2021-02-17 16:30:55 +01:00
Jean-Baptiste Boric
0d22ec9d32 Kernel: Handle 'Menu' key on PS/2 keyboard 2021-02-15 19:37:14 +01:00
Brian Gianforcaro
a8a834782c Kernel: Ignore unobserved BlockResult from Thread::Sleep
Suppress these in preparation for making BlockResult [[nodiscard]].
2021-02-15 08:28:57 +01:00
Brian Gianforcaro
ddd79fe2cf Kernel: Add WaitQueue::wait_forever and it use it for all infinite waits.
In preparation for marking BlockingResult [[nodiscard]], there are a few
places that perform infinite waits, which we never observe the result of
the wait. Instead of suppressing them, add an alternate function which
returns void when performing and infinite wait.
2021-02-15 08:28:57 +01:00
Andreas Kling
09b1b09c19 Kernel: Assert if rounding-up-to-page-size would wrap around to 0
If we try to align a number above 0xfffff000 to the next multiple of
the page size (4 KiB), it would wrap around to 0. This is most likely
never what we want, so let's assert if that happens.
2021-02-14 10:01:50 +01:00
Andreas Kling
f1b5def8fd Kernel: Factor address space management out of the Process class
This patch adds Space, a class representing a process's address space.

- Each Process has a Space.
- The Space owns the PageDirectory and all Regions in the Process.

This allows us to reorganize sys$execve() so that it constructs and
populates a new Space fully before committing to it.

Previously, we would construct the new address space while still
running in the old one, and encountering an error meant we had to do
tedious and error-prone rollback.

Those problems are now gone, replaced by what's hopefully a set of much
smaller problems and missing cleanups. :^)
2021-02-08 18:27:28 +01:00
AnotherTest
09a43969ba Everywhere: Replace dbgln<flag>(...) with dbgln_if(flag, ...)
Replacement made by `find Kernel Userland -name '*.h' -o -name '*.cpp' | sed -i -Ee 's/dbgln\b<(\w+)>\(/dbgln_if(\1, /g'`
2021-02-08 18:08:55 +01:00
Liav A
f2faf11d61 Kernel: Try to detect Sound Blaster 16 before creating an instance
We shouldn't create a SB16 instance without checking if the Sound
Blaster 16 card is actually installed in the system.
2021-02-05 08:54:02 +01:00
Linus Groh
ee41d6e154 Base: Rename some keymaps to use xx-xx format where appropriate
- en.json -> en-us.json
- gb.json -> en-gb.json
- ptbr.json -> pt-br.json
- ptpt.json -> pt-pt.json
2021-02-02 16:53:11 +01:00
Liav A
5ab1864497 Kernel: Introduce the MemoryDevice
This is a character device that is being used by the dmidecode utility.
We only allow to map the BIOS ROM area to userspace with this device.
2021-02-01 17:13:23 +01:00
Ben Wiederhake
272df54a3e Kernel+LibKeyboard: Define the default keymap only in one place
Because it was 'static const' and also shared with userland programs,
the default keymap was defined in multiple places. This commit should
save several kilobytes! :^)
2021-02-01 09:54:32 +01:00
Ben Wiederhake
0e3408d4d6 LibKeyboard: Don't assert on failure 2021-02-01 09:54:32 +01:00
Ben Wiederhake
dd4e670f72 LibKeyboard+keymap: Support querying the keymap via commandline 2021-02-01 09:54:32 +01:00
Ben Wiederhake
a2c21a55e1 Kernel+LibKeyboard: Enable querying the current keymap 2021-02-01 09:54:32 +01:00
Peter Elliott
985ce3b701 BXVGADevice+MBVGADevice: Correctly check page-aligned mmaps
In ab14b0ac64, mmap was changed so that
the size of the region is aligned before it was passed to the device
driver. The previous logic would assert when the framebuffer size was
not a multiple of the page size. I've also taken the liberty of
returning an error on mmap failure rather than asserting.
2021-01-28 08:14:04 +01:00
asynts
7cf0c7cc0d Meta: Split debug defines into multiple headers.
The following script was used to make these changes:

    #!/bin/bash
    set -e

    tmp=$(mktemp -d)

    echo "tmp=$tmp"

    find Kernel \( -name '*.cpp' -o -name '*.h' \) | sort > $tmp/Kernel.files
    find . \( -path ./Toolchain -prune -o -path ./Build -prune -o -path ./Kernel -prune \) -o \( -name '*.cpp' -o -name '*.h' \) -print | sort > $tmp/EverythingExceptKernel.files

    cat $tmp/Kernel.files | xargs grep -Eho '[A-Z0-9_]+_DEBUG' | sort | uniq > $tmp/Kernel.macros
    cat $tmp/EverythingExceptKernel.files | xargs grep -Eho '[A-Z0-9_]+_DEBUG' | sort | uniq > $tmp/EverythingExceptKernel.macros

    comm -23 $tmp/Kernel.macros $tmp/EverythingExceptKernel.macros > $tmp/Kernel.unique
    comm -1 $tmp/Kernel.macros $tmp/EverythingExceptKernel.macros > $tmp/EverythingExceptKernel.unique

    cat $tmp/Kernel.unique | awk '{ print "#cmakedefine01 "$1 }' > $tmp/Kernel.header
    cat $tmp/EverythingExceptKernel.unique | awk '{ print "#cmakedefine01 "$1 }' > $tmp/EverythingExceptKernel.header

    for macro in $(cat $tmp/Kernel.unique)
    do
        cat $tmp/Kernel.files | xargs grep -l $macro >> $tmp/Kernel.new-includes ||:
    done
    cat $tmp/Kernel.new-includes | sort > $tmp/Kernel.new-includes.sorted

    for macro in $(cat $tmp/EverythingExceptKernel.unique)
    do
        cat $tmp/Kernel.files | xargs grep -l $macro >> $tmp/Kernel.old-includes ||:
    done
    cat $tmp/Kernel.old-includes | sort > $tmp/Kernel.old-includes.sorted

    comm -23 $tmp/Kernel.new-includes.sorted $tmp/Kernel.old-includes.sorted > $tmp/Kernel.includes.new
    comm -13 $tmp/Kernel.new-includes.sorted $tmp/Kernel.old-includes.sorted > $tmp/Kernel.includes.old
    comm -12 $tmp/Kernel.new-includes.sorted $tmp/Kernel.old-includes.sorted > $tmp/Kernel.includes.mixed

    for file in $(cat $tmp/Kernel.includes.new)
    do
        sed -i -E 's/#include <AK\/Debug\.h>/#include <Kernel\/Debug\.h>/' $file
    done

    for file in $(cat $tmp/Kernel.includes.mixed)
    do
        echo "mixed include in $file, requires manual editing."
    done
2021-01-26 21:20:00 +01:00
Andreas Kling
ab14b0ac64 Kernel: Hoist VM range allocation up to sys$mmap() itself
Instead of letting each File subclass do range allocation in their
mmap() override, do it up front in sys$mmap().

This makes us honor alignment requests for file-backed memory mappings
and simplifies the code somwhat.
2021-01-25 18:57:06 +01:00
asynts
eea72b9b5c Everywhere: Hook up remaining debug macros to Debug.h. 2021-01-25 09:47:36 +01:00
asynts
8465683dcf Everywhere: Debug macros instead of constexpr.
This was done with the following script:

    find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/dbgln<debug_([a-z_]+)>/dbgln<\U\1_DEBUG>/' {} \;

    find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/if constexpr \(debug_([a-z0-9_]+)/if constexpr \(\U\1_DEBUG/' {} \;
2021-01-25 09:47:36 +01:00
asynts
acdcf59a33 Everywhere: Remove unnecessary debug comments.
It would be tempting to uncomment these statements, but that won't work
with the new changes.

This was done with the following commands:

    find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec awk -i inplace '$0 !~ /\/\/#define/ { if (!toggle) { print; } else { toggle = !toggle } } ; $0 ~/\/\/#define/ { toggle = 1 }' {} \;

    find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec awk -i inplace '$0 !~ /\/\/ #define/ { if (!toggle) { print; } else { toggle = !toggle } } ; $0 ~/\/\/ #define/ { toggle = 1 }' {} \;
2021-01-25 09:47:36 +01:00
asynts
1a3a0836c0 Everywhere: Use CMake to generate AK/Debug.h.
This was done with the help of several scripts, I dump them here to
easily find them later:

    awk '/#ifdef/ { print "#cmakedefine01 "$2 }' AK/Debug.h.in

    for debug_macro in $(awk '/#ifdef/ { print $2 }' AK/Debug.h.in)
    do
        find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/#ifdef '$debug_macro'/#if '$debug_macro'/' {} \;
    done

    # Remember to remove WRAPPER_GERNERATOR_DEBUG from the list.
    awk '/#cmake/ { print "set("$2" ON)" }' AK/Debug.h.in
2021-01-25 09:47:36 +01:00
Jean-Baptiste Boric
f64e287b82 Kernel: Make device generate their own names
Besides removing the monolithic DevFSDeviceInode::determine_name()
method, being able to determine a device's name inside the /dev
hierarchy outside of DevFS has its uses.
2021-01-22 22:17:39 +01:00
asynts
67583bc424 Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-22 22:14:30 +01:00
asynts
78b2be5a2a Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-22 22:14:30 +01:00
Andreas Kling
19d3f8cab7 Kernel+LibC: Turn errno codes into a strongly typed enum
..and allow implicit creation of KResult and KResultOr from ErrnoCode.
This means that kernel functions that return those types can finally
do "return EINVAL;" and it will just work.

There's a handful of functions that still deal with signed integers
that should be converted to return KResults.
2021-01-20 23:20:02 +01:00
Andreas Kling
64b0d89335 Kernel: Make Process::allocate_region*() return KResultOr<Region*>
This allows region allocation to return specific errors and we don't
have to assume every failure is an ENOMEM.
2021-01-15 19:10:30 +01:00
Lenny Maiorani
e6f907a155 AK: Simplify constructors and conversions from nullptr_t
Problem:
- Many constructors are defined as `{}` rather than using the ` =
  default` compiler-provided constructor.
- Some types provide an implicit conversion operator from `nullptr_t`
  instead of requiring the caller to default construct. This violates
  the C++ Core Guidelines suggestion to declare single-argument
  constructors explicit
  (https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c46-by-default-declare-single-argument-constructors-explicit).

Solution:
- Change default constructors to use the compiler-provided default
  constructor.
- Remove implicit conversion operators from `nullptr_t` and change
  usage to enforce type consistency without conversion.
2021-01-12 09:11:45 +01:00
Andreas Kling
7c4ddecacb Kernel: Convert a bunch of String::format() => String::formatted() 2021-01-11 22:07:01 +01:00
Lenny Maiorani
1b2364846f SinglyLinkedList: Implement find in terms of AK::find
Problem:
- The implementation of `find` is coupled to the implementation of
  `SinglyLinkedList`.

Solution:
- Decouple the implementation of `find` from the class by using a
  generic `find` algorithm.
2021-01-11 19:45:05 +01:00
Lenny Maiorani
853cb8af5c DoublyLinkedList: Implement find in terms of AK::find
Problem:
- The implementation of `find` is coupled to the implementation of
  `DoublyLinkedList`.
- `append` and `prepend` are implemented multiple times so that
  r-value references can be moved from into the new node. This is
  probably not called very often because a pr-value or x-value needs
  to be used here.

Solution:
- Decouple the implementation of `find` from the class by using a
  generic `find` algorithm.
- Make `append` and `prepend` be function templates so that they can
  have binding references which can be forwarded.
2021-01-11 19:45:05 +01:00
asynts
872f2a3b90 Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.Everything:
2021-01-11 11:55:47 +01:00
asynts
11d651d447 Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.Everything:
2021-01-11 11:55:47 +01:00
asynts
938e5c7719 Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.Everything:

The modifications in this commit were automatically made using the
following command:

    find . -name '*.cpp' -exec sed -i -E 's/dbg\(\) << ("[^"{]*");/dbgln\(\1\);/' {} \;
2021-01-09 21:11:09 +01:00
Andreas Kling
4714b04d32 Kernel: Don't put gratuitous cursing in kernel log 2021-01-09 14:03:06 +01:00
Jesse Buhagiar
6df15aca7e Kernel/USB: Implement test transfer
We can now test a _very_ basic transaction via `do_debug_transfer()`.
This function merely attaches some TDs to the LSCTRL queue head
and points some input and output buffers. We then sense an interrupt
with USBSTS value of 1, meaning Interrupt On Completion
(of the transaction). At this point, the input buffer is filled with
some data.
2021-01-09 13:48:15 +01:00
Jesse Buhagiar
3fb7e98e42 Kernel/USB: Simplify schedule
It seems like Haiku and Grub do this, so let's not bother
with any fancy timing stuff for now (to at least get
_something_ working...)
2021-01-09 13:48:15 +01:00
Jesse Buhagiar
ff4afe17be Kernel/USB: Ignore shared IRQs
According the USB spec/UHCI datasheet (as well as the Linux and
BSD source code), if we receive an IRQ and USBSTS is 0, then
the IRQ does not belong to us and we should immediately jump
out of the handler.
2021-01-09 13:48:15 +01:00
Jesse Buhagiar
770a729e59 Kernel/USB: Add basic root port detection/management
We can now read/write to the two root ports exposed to the
UHCI controller, and detect when a device is plugged in or
out via a kernel process that constantly scans the port
for any changes. This is very basic, but is a bit of fun to see
the kernel detecting hardware on the fly :^)
2021-01-09 13:48:15 +01:00
Jesse Buhagiar
a5f895d251 Kernel/USB: Implement UHCI Data structures
Implemented both Queue Heads and Transfer Descriptors. These
are required to actually perform USB transactions. The UHCI
driver sets up a pool of these that can be allocated when we
need them. It seems some drivers have these statically
allocated, so it might be worth looking into that, but
for now, the simple way seems to be to allocate them on
the fly as we need them, and then release them.
2021-01-09 13:48:15 +01:00
Jesse Buhagiar
375d269b21 Kernel/USB: Prevent system crash via correct UHCI inititilisation
It seems that not setting the framelist address register
was causing the entire system to lock up as it generated an insane
interrupt storm in the IRQ handler for the UHCI controller.
We now allocate a 4KiB aligned page via
`MemoryManager::allocate_supervisor_physical_page()` and set every
value to 1. In effect, this creates a framelist with each entry
being a "TERMINATE" entry in which the controller stalls until its'
1mS time slice is up.

Some more registers have also been set for consistency, though it
seems like this don't need to be set explicitly in software.
2021-01-09 13:48:15 +01:00
Jesse Buhagiar
33d73c600c Kernel/USB: Move USB classes into USB namespace
The entire USB spec involves more than just UHCI, so
let's put everything into it's own nice namespace :^)
2021-01-09 13:48:15 +01:00
Jesse Buhagiar
0dbb9361b8 Kernel/USB: Move USB related files to into specific directory
As the USB/UHCI driver grows in size, it'll be much cleaner to have
all of the USB related files in one folder where they can be easily
accessed :^)
2021-01-09 13:48:15 +01:00
Andreas Kling
5dae85afe7 Kernel: Pass "shared" flag to Region constructor
Before this change, we would sometimes map a region into the address
space with !is_shared(), and then moments later call set_shared(true).

I found this very confusing while debugging, so this patch makes us pass
the initial shared flag to the Region constructor, ensuring that it's in
the correct state by the time we first map the region.
2021-01-02 16:57:31 +01:00
Luke
0f66589007 Everywhere: Fix more typos 2020-12-31 01:47:41 +01:00
Liav A
3a19e18d1e Kernel: Move Partition code files to the Storage folder
This folder is more appropriate for these files.
2020-12-27 23:07:44 +01:00
Liav A
18e77aa285 Kernel: Add a method to determine the desired permissions of a Device
This method will be used later in DevFS, to set the appropriate
permissions for each device node.
2020-12-27 23:07:44 +01:00
Andreas Kling
cb2c8f71f4 AK: Remove custom %b format string specifier
This was a non-standard specifier alias for %02x. This patch replaces
all uses of it with new-style formatting functions instead.
2020-12-25 17:04:28 +01:00
Liav A
0a2b00a1bf Kernel: Introduce the new Storage subsystem
This new subsystem is somewhat replacing the IDE disk code we had with a
new flexible design.

StorageDevice is a generic class that represent a generic storage
device. It is meant that specific storage hardware will override the
interface. StorageController is a generic class that represent
a storage controller that can be found in a machine.

The IDEController class governs two IDEChannels. An IDEChannel is
responsible to manage the master & slave devices of the channel,
therefore an IDEChannel is an IRQHandler.
2020-12-21 00:19:21 +01:00
Liav A
f36feb42bd Kernel: Return a correct name string of async write request 2020-12-17 19:36:56 +01:00
Tom
da5cc34ebb Kernel: Fix some issues related to fixes and block conditions
Fix some problems with join blocks where the joining thread block
condition was added twice, which lead to a crash when trying to
unblock that condition a second time.

Deferred block condition evaluation by File objects were also not
properly keeping the File object alive, which lead to some random
crashes and corruption problems.

Other problems were caused by the fact that the Queued state didn't
handle signals/interruptions consistently. To solve these issues we
remove this state entirely, along with Thread::wait_on and change
the WaitQueue into a BlockCondition instead.

Also, deliver signals even if there isn't going to be a context switch
to another thread.

Fixes #4336 and #4330
2020-12-12 21:28:12 +01:00
Tom
046d6855f5 Kernel: Move block condition evaluation out of the Scheduler
This makes the Scheduler a lot leaner by not having to evaluate
block conditions every time it is invoked. Instead evaluate them as
the states change, and unblock threads at that point.

This also implements some more waitid/waitpid/wait features and
behavior. For example, WUNTRACED and WNOWAIT are now supported. And
wait will now not return EINTR when SIGCHLD is delivered at the
same time.
2020-11-30 13:17:02 +01:00
Tom
6cb640eeba Kernel: Move some time related code from Scheduler into TimeManagement
Use the TimerQueue to expire blocking operations, which is one less thing
the Scheduler needs to check on every iteration.

Also, add a BlockTimeout class that will automatically handle relative or
absolute timeouts as well as overriding timeouts (e.g. socket timeouts)
more consistently.

Also, rework the TimerQueue class to be able to fire events from
any processor, which requires Timer to be RefCounted. Also allow
creating id-less timers for use by blocking operations.
2020-11-30 13:17:02 +01:00
Tom
53cffb5ad9 Kernel: Fix mouse lag when VMWareBackdoor absolute mode is enabled
We won't be receiving full PS/2 mouse packets when the VMWareBackdoor
absolute mouse mode is enabled. So, read just one byte every time
and retrieve the latest mouse packet from VMWareBackdoor immediately.

Fixes #4086
2020-11-14 22:09:48 +01:00
Tom
13383f3267 Revert "Kernel: Keep reading from i8042 until the buffer is empty"
This reverts commit 467f6c74a4.
2020-11-14 22:09:48 +01:00
Andreas Kling
467f6c74a4 Kernel: Keep reading from i8042 until the buffer is empty
Otherwise we might not drain the mouse buffer until the next IRQ.
2020-11-14 17:20:17 +01:00
Tom
e445ff670d Kernel: Implement an asynchronous device request stack
This allows issuing asynchronous requests for devices and waiting
on the completion of the request. The requests can cascade into
multiple sub-requests.

Since IRQs may complete at any time, if the current process is no
longer the same that started the process, we need to swich the
paging context before accessing user buffers.

Change the PATA driver to use this model.
2020-11-12 18:04:30 +01:00
Tom
91db31880f Kernel: Add I8042Controller to detect and manage PS/2 devices
Rework the PS/2 keyboard and mouse drivers to use a common 8042
controller driver. Also, reset and reconfigure the 8042 controller
as they are not guaranteed to be in the state that we expect.
2020-11-12 18:04:16 +01:00
Andreas Kling
501cef2bd7 Revert "Kernel: Implement an asynchronous device request stack"
This reverts commit 2fd5ce1eb0.

This broke booting without SMP. (PR was #3921)
2020-11-04 21:25:26 +01:00
Tom
2fd5ce1eb0 Kernel: Implement an asynchronous device request stack
This allows issuing asynchronous requests for devices and waiting
on the completion of the request. The requests can cascade into
multiple sub-requests.

Since IRQs may complete at any time, if the current process is no
longer the same that started the process, we need to swich the
paging context before accessing user buffers.

Change the PATA driver to use this model.
2020-11-04 21:21:37 +01:00
Tom
96081010dc Kernel: Remove dead code from BlockDevice 2020-11-04 21:21:37 +01:00
Linus Groh
bcfc6f0c57 Everywhere: Fix more typos 2020-10-03 12:36:49 +02:00
Ben Wiederhake
64cc3f51d0 Meta+Kernel: Make clang-format-10 clean 2020-09-25 21:18:17 +02:00
Liav A
d9863e0b6c Kernel: Remove unnecessary class member in UHCIController
The m_address member is not needed, since PCI::Device already has one.
2020-09-19 18:39:09 +02:00
Luke
68b361bd21 Kernel: Return ENOMEM in more places
There are plenty of places in the kernel that aren't
checking if they actually got their allocation.

This fixes some of them, but definitely not all.

Fixes #3390
Fixes #3391

Also, let's make find_one_free_page() return nullptr
if it doesn't get a free index. This stops the kernel
crashing when out of memory and allows memory purging
to take place again.

Fixes #3487
2020-09-16 20:38:19 +02:00
Tom
c8d9f1b9c9 Kernel: Make copy_to/from_user safe and remove unnecessary checks
Since the CPU already does almost all necessary validation steps
for us, we don't really need to attempt to do this. Doing it
ourselves doesn't really work very reliably, because we'd have to
account for other processors modifying virtual memory, and we'd
have to account for e.g. pages not being able to be allocated
due to insufficient resources.

So change the copy_to/from_user (and associated helper functions)
to use the new safe_memcpy, which will return whether it succeeded
or not. The only manual validation step needed (which the CPU
can't perform for us) is making sure the pointers provided by user
mode aren't pointing to kernel mappings.

To make it easier to read/write from/to either kernel or user mode
data add the UserOrKernelBuffer helper class, which will internally
either use copy_from/to_user or directly memcpy, or pass the data
through directly using a temporary buffer on the stack.

Last but not least we need to keep syscall params trivial as we
need to copy them from/to user mode using copy_from/to_user.
2020-09-13 21:19:15 +02:00
Andreas Kling
802f541184 Kernel/USB: Disable autodetection of UHCI controllers for now
Until this thing becomes stable, let's not bother everyone with it.
2020-09-05 15:42:54 +02:00
Andreas Kling
3f36903201 Kernel/USB: Start the UHCI controller after resetting it 2020-09-05 15:42:54 +02:00
Andreas Kling
02b3cb8123 Kernel: Add a missing "#pragma once" 2020-09-04 23:51:50 +02:00
Andreas Kling
eb74f62201 Kernel/USB: Add a simple UHCIController::stop()
This stops the controller and waits for it to complete.
2020-09-04 21:21:46 +02:00
Andreas Kling
1254447bd7 Kernel/USB: Add some constants for the USBCMD and USBSTS bits 2020-09-04 21:21:46 +02:00
Andreas Kling
e834c24eea Kernel/USB: Start fleshing out a basic UHCI controller driver :^)
Let's see if we can talk to some USB devices. We will now detect
a UHCI controller if present on the PCI bus.
2020-09-04 21:21:41 +02:00
Ben Wiederhake
081bb29626 Kernel: Unbreak building with extra debug macros, part 2 2020-08-30 09:43:49 +02:00
Ben Wiederhake
eac3bbdcee Kernel: Unbreak building with extra debug macros, part 1 2020-08-30 09:43:49 +02:00
Tom
d89582880e Kernel: Switch singletons to use new Singleton class
MemoryManager cannot use the Singleton class because
MemoryManager::initialize is called before the global constructors
are run. That caused the Singleton to be re-initialized, causing
it to create another MemoryManager instance.

Fixes #3226
2020-08-25 09:48:48 +02:00
Luke
b58ca7cf3d Kernel: Scroll wheel amount on Intellimouse is 4 bits instead of 8
When trying to scroll up on virtualizers that don't use the VMware
backdoor and instead use PS2MouseDevice, it would actually scroll
down rapidly.

Looking into it, the mouse delta for scrolling down was 1 and 15
for scrolling up. 15 is suspiciously -1 for a nibble.

According to https://isdaman.com/alsos/hardware/mouse/ps2interface.htm
the Z is actually 4 bits for Intellimouse.

This fixes scrolling up on virtualizers such as VirtualBox.
2020-08-25 09:43:51 +02:00
Andreas Kling
2fd9e72264 Revert "Kernel: Switch singletons to use new Singleton class"
This reverts commit f48feae0b2.
2020-08-22 18:01:59 +02:00
Andreas Kling
8925ad3fa0 Revert "Kernel: Move Singleton class to AK"
This reverts commit f0906250a1.
2020-08-22 16:34:49 +02:00
Andreas Kling
68580d5a8d Revert "AK: Get rid of make_singleton function"
This reverts commit 5a98e329d1.
2020-08-22 16:34:14 +02:00
Tom
5a98e329d1 AK: Get rid of make_singleton function
Just default the InitFunction template argument.
2020-08-22 10:46:24 +02:00
Tom
f0906250a1 Kernel: Move Singleton class to AK 2020-08-22 10:46:24 +02:00
Tom
f48feae0b2 Kernel: Switch singletons to use new Singleton class
Fixes #3226
2020-08-21 11:47:35 +02:00
Valtteri Koskivuori
00a0e525e6 Kernel+LibKeyboard: Store the keymap name when setting system keymap
This way we can query the kernel to see which keymap is currently in use.
2020-08-06 17:45:06 +02:00
Andreas Kling
7a3ab6c517 Kernel: Make File::write() and File::read() return KResultOr<size_t>
Instead of returning a ssize_t where negative values mean error,
we now return KResultOr<size_t> and use the error state to report
errors exclusively.
2020-08-04 18:17:16 +02:00
Andreas Kling
292cd53192 Kernel: Remove SmapDisabler in sys$ioctl()
Use copy_{to,from}_user() in the various File::ioctl() implementations
instead of disabling SMAP wholesale in sys$ioctl().

This patch does not port IPv4Socket::ioctl() to those API's since that
will be more involved. That function now creates a local SmapDisabler.
2020-07-31 00:17:25 +02:00
Florian Angermeier
c969b8390d Kernel: Make all 6 VirtualConsoles available via shortcut
Add all 6 shortcuts even if the switch between VirtualConsoles is
currently not available in the graphical console.

Also make the case statement more compact.
2020-07-17 00:36:50 +02:00
Tom
788b2d64c6 Kernel: Require a reason to be passed to Thread::wait_on
The Lock class still permits no reason, but for everything else
require a reason to be passed to Thread::wait_on. This makes it
easier to diagnose why a Thread is in Queued state.
2020-07-06 10:00:24 +02:00
Andreas Kling
11c4a28660 Kernel: Move headers intended for userspace use into Kernel/API/ 2020-07-04 17:22:23 +02:00
Tom
5674a77bd6 PATA: Ignore interrupts that weren't generated by the disk 2020-07-01 12:07:01 +02:00
Tom
a2fd824dff PATA: LBA48 uses 16 bit features register 2020-07-01 12:07:01 +02:00
Tom
16783bd14d Kernel: Turn Thread::current and Process::current into functions
This allows us to query the current thread and process on a
per processor basis
2020-07-01 12:07:01 +02:00
Tom
d98edb3171 Kernel: List all CPUs in /proc/cpuinfo 2020-07-01 12:07:01 +02:00
Tom
10407061d2 PATA: Avoid double-preparing for irq 2020-07-01 12:07:01 +02:00
Peter Elliott
af0b2d1d86 Kernel: Harvest randomness from various drivers
Random now gets entropy from the following drivers:
- KeyboardDevice
- PATAChannel
- PS2MouseDevice
- E1000NetworkAdapter
- RTL8139NetworkAdapter

Of these devices,  PS2MouseDevice and PATAChannel provide the vast
majority of the entropy.
2020-06-25 21:05:40 +02:00
Hüseyin ASLITÜRK
174987f930 Kernel: Replace char and u8 data types to u32 for code point
Remove character property from event and add code_point property.
2020-06-16 13:15:17 +02:00
Hüseyin ASLITÜRK
b4577ffcf3 Kernel: KeyboardDevice, remove char mapping logic
Remove char mapping logic and constant character map.
2020-06-13 12:36:30 +02:00
Hüseyin ASLITÜRK
46b92fa173 Kernel: Add scancode value to KeyEvent 2020-06-03 21:52:40 +02:00
Andreas Kling
ab40cc60d1 Kernel: Fix glitched audio output in SB16 driver
We were not setting the DMA transfer mode correctly. I have absolutely
no clue how this could ever have worked, but it did work for months
until it suddenly didn't.

Anyways, this fixes that. The sound is still a little bit glitchy and
that could probably be fixed by using the SB16's auto-initialized mode.
2020-05-31 03:40:58 +02:00
Emanuele Torre
937d0be762 Meta: Add a script check the presence of "#pragma once" in header files
.. and make travis run it.

I renamed check-license-headers.sh to check-style.sh and expanded it so
that it now also checks for the presence of "#pragma once" in .h files.

It also checks the presence of a (single) blank line above and below the
"#pragma once" line.

I also added "#pragma once" to all the files that need it: even the ones
we are not check.
I also added/removed blank lines in order to make the script not fail.

I also ran clang-format on the files I modified.
2020-05-29 07:59:45 +02:00
Andreas Kling
dd924b730a Kernel+LibC: Fix various build issues introduced by ssize_t
Now that ssize_t is derived from size_t, we have to
2020-05-23 15:27:33 +02:00
Andreas Kling
b3736c1b1e Kernel: Use a FlatPtr for the "argument" to ioctl()
Since it's often used to pass pointers, it should really be a FlatPtr.
2020-05-23 15:25:43 +02:00
Andreas Kling
21d5f4ada1 Kernel: Absorb LibBareMetal back into the kernel
This was supposed to be the foundation for some kind of pre-kernel
environment, but nobody is working on it right now, so let's move
everything back into the kernel and remove all the confusion.
2020-05-16 12:00:04 +02:00
Andreas Kling
03eb0e5638 Kernel: Let's say that IO::delay(N) delays for N microseconds
Supposedly that's how much delay you get when doing I/O on port 0x80.
2020-05-16 10:55:54 +02:00
Sergey Bugaev
450a2a0f9c Build: Switch to CMake :^)
Closes https://github.com/SerenityOS/serenity/issues/2080
2020-05-14 20:15:18 +02:00
Andreas Kling
c5882d3a18 Kernel: Detect 5-button PS/2 mouse if present :^)
The detection works very similarly to how we detect a mouse wheel, just
another magical sequence of "set sample rate" requests to the mouse
followed by an ID check.
2020-05-02 22:06:17 +02:00
Andreas Kling
385dacce05 Kernel: Fix integer overflow in framebuffer resolution handling
This made it possible to map the E1000 MMIO range into userspace and
mess with the registers.

Thanks to @grigoritchy for finding this!

Fixes #2015.
2020-04-29 09:37:36 +02:00
Andreas Kling
9c856811b2 Kernel: Add Region helpers for accessing underlying physical pages
Since a Region is basically a view into a potentially larger VMObject,
it was always necessary to include the Region starting offset when
accessing its underlying physical pages.

Until now, you had to do that manually, but this patch adds a simple
Region::physical_page() for read-only access and a physical_page_slot()
when you want a mutable reference to the RefPtr<PhysicalPage> itself.

A lot of code is simplified by making use of this.
2020-04-28 17:05:14 +02:00
Andreas Kling
fa40b725f9 Kernel: Refuse to set overflowy resolution values in BXVGADevice 2020-04-15 17:15:40 +02:00
Liav A
d6318f2cc6 Kernel: Ensure that we receive IRQs in PIO mode when IOAPIC is enabled
The IOAPIC manual states that "Interrupt Mask-R/W. When this bit is 1,
the interrupt signal is masked. Edge-sensitive interrupts signaled on
a masked interrupt pin are ignored." - Therefore we have to ensure that
we disable interrupts globally with cli(), but also to ensure that we
invoke enable_irq() before sending the hardware command that generates
an IRQ almost immediately.
2020-04-15 16:40:16 +02:00
Liav A
f5090ab810 Kernel: Restore ATA PIO functionality
First, before this change, specifying 'force_pio' in the kernel
commandline was meaningless because we nevertheless set the DMA flag to
be enabled.

Also, we had a problem in which we used IO::repeated_out16() in PIO
write method. This might work on buggy emulators, but I suspect that on
real hardware this code will fail.

The most difficult problem was to restore the PIO read operation.
Apparently, it seems that we can't use IO::repeated_in16() here because
it will read zeroed data. Currently we rely on a simple loop that
invokes IO::in16() to a buffer. Also, the interrupt handling stage in
the PIO read method is moved to be handled inside the loop of reading
the requested sectors.
2020-04-15 12:35:10 +02:00
Liav A
65f939b55c Kernel: Keep records of PCI::Address & PCI::ID pairs for enumeration 2020-04-11 10:02:31 +02:00
Liav A
688dd9ea66 Kernel: Simplify a message in PATAChannel::create() 2020-04-11 10:02:31 +02:00
Liav A
e9df6189f4 Kernel: Assert if we try to initialize VMWareBackdoor more than once 2020-04-11 10:02:31 +02:00
Conrad Pankoff
a3edeb5868 Kernel: Add explicit offset parameter to File::read etc 2020-04-10 11:59:30 +02:00
Liav A
1570e67881 Kernel: Allow again to boot with partitioned disk
This change ensures that we don't return a zero value blindly
from DiskPartition write/read methods.

Fixes #1719.
2020-04-09 23:43:30 +02:00
Andreas Kling
5cc09b0245 Kernel: Simplify VMWareBackdoor somewhat
- If there is no VMWare backdoor, don't allocate memory for it.
- Remove the "unsupported" state, instead just don't instantiate.
- Move the command-line parsing from init to the driver.
- Move mouse packet reception from PS2MouseDevice to VMWareBackdoor.
2020-04-08 17:19:46 +02:00
Andreas Kling
bb2be4bb99 Kernel: Make VMWareBackdoor eternal (since it's never freed) 2020-04-08 17:19:46 +02:00
Andreas Kling
befe4c6709 Kernel: Remove DebugLogDevice
This was a cute idea but ultimately it's just not useful since we
already have the dbgputch() and dbgputstr() syscalls.
2020-04-08 17:19:46 +02:00
Andreas Kling
c50fbf6da0 Kernel: Remove the floppy driver
Nobody was using this code, and it was not actively worked on, so let's
just not have it. Press F.
2020-03-28 10:09:48 +01:00
Andreas Kling
7d862dd5fc AK: Reduce header dependency graph of String.h
String.h no longer pulls in StringView.h. We do this by moving a bunch
of String functions out-of-line.
2020-03-23 13:48:44 +01:00
Liav A
4fcc10c6c3 Kernel: Delete unnecessary files 2020-03-19 15:48:00 +01:00
Liav A
9db291d885 Kernel: Introduce the new Time management subsystem
This new subsystem includes better abstractions of how time will be
handled in the OS. We take advantage of the existing RTC timer to aid
in keeping time synchronized. This is standing in contrast to how we
handled time-keeping in the kernel, where the PIT was responsible for
that function in addition to update the scheduler about ticks.
With that new advantage, we can easily change the ticking dynamically
and still keep the time synchronized.

In the process context, we no longer use a fixed declaration of
TICKS_PER_SECOND, but we call the TimeManagement singleton class to
provide us the right value. This allows us to use dynamic ticking in
the future, a feature known as tickless kernel.

The scheduler no longer does by himself the calculation of real time
(Unix time), and just calls the TimeManagment singleton class to provide
the value.

Also, we can use 2 new boot arguments:
- the "time" boot argument accpets either the value "modern", or
  "legacy". If "modern" is specified, the time management subsystem will
  try to setup HPET. Otherwise, for "legacy" value, the time subsystem
  will revert to use the PIT & RTC, leaving HPET disabled.
  If this boot argument is not specified, the default pattern is to try
  to setup HPET.
- the "hpet" boot argumet accepts either the value "periodic" or
  "nonperiodic". If "periodic" is specified, the HPET will scan for
  periodic timers, and will assert if none are found. If only one is
  found, that timer will be assigned for the time-keeping task. If more
  than one is found, both time-keeping task & scheduler-ticking task
  will be assigned to periodic timers.
  If this boot argument is not specified, the default pattern is to try
  to scan for HPET periodic timers. This boot argument has no effect if
  HPET is disabled.

In hardware context, PIT & RealTimeClock classes are merely inheriting
from the HardwareTimer class, and they allow to use the old i8254 (PIT)
and RTC devices, managing them via IO ports. By default, the RTC will be
programmed to a frequency of 1024Hz. The PIT will be programmed to a
frequency close to 1000Hz.

About HPET, depending if we need to scan for periodic timers or not,
we try to set a frequency close to 1000Hz for the time-keeping timer
and scheduler-ticking timer. Also, if possible, we try to enable the
Legacy replacement feature of the HPET. This feature if exists,
instructs the chipset to disconnect both i8254 (PIT) and RTC.
This behavior is observable on QEMU, and was verified against the source
code:
ce967e2f33

The HPETComparator class is inheriting from HardwareTimer class, and is
responsible for an individual HPET comparator, which is essentially a
timer. Therefore, it needs to call the singleton HPET class to perform
HPET-related operations.

The new abstraction of Hardware timers brings an opportunity of more new
features in the foreseeable future. For example, we can change the
callback function of each hardware timer, thus it makes it possible to
swap missions between hardware timers, or to allow to use a hardware
timer for other temporary missions (e.g. calibrating the LAPIC timer,
measuring the CPU frequency, etc).
2020-03-19 15:48:00 +01:00
Liav A
e880fe0765 Kernel: Use a const reference to RegisterState in IRQ handling 2020-03-19 15:48:00 +01:00
Liav A
aa43314e8b Kernel: Remove unnecessary include from PATAChannel.cpp 2020-03-19 15:48:00 +01:00
Andreas Kling
fa9fba6901 Kernel: Add missing #includes now that <AK/StdLibExtras.h> is smaller 2020-03-08 13:06:51 +01:00
Tibor Nagy
30152b6c88 Kernel: Fix syntax errors in PS2MOUSE_DEBUG
Found with Cppcheck.
2020-03-06 22:20:53 +01:00
Andreas Kling
c6693f9b3a Kernel: Simplify a bunch of dbg() and klog() calls
LogStream can handle VirtualAddress and PhysicalAddress directly.
2020-03-06 15:00:44 +01:00
Liav A
773afefe7c Kernel: Change HandlerPurpose to HandlerType
Also, GenericInterruptHandler class requires to implement two new
methods.
2020-03-06 11:19:51 +01:00
Liav A
a3fa40fc07 Kernel: Enable IRQs before sending commands to devices
Without this fix, a very fast IRQ can preempt the enable_irq() call,
leaving that IRQ being unhandled.
2020-03-06 10:32:32 +01:00
Liav A
0fc60e41dd Kernel: Use klog() instead of kprintf()
Also, duplicate data in dbg() and klog() calls were removed.
In addition, leakage of virtual address to kernel log is prevented.
This is done by replacing kprintf() calls to dbg() calls with the
leaked data instead.
Also, other kprintf() calls were replaced with klog().
2020-03-02 22:23:39 +01:00
Liav A
19aa53e1f9 Kernel: Use IOAddress class in PATAChannel class
This change make the code a bit more readable. Also, kprintf() calls
are replaced with klog() calls.
2020-03-02 22:23:39 +01:00
Andreas Kling
8fbdda5a2d Kernel: Implement basic support for sys$mmap() with MAP_PRIVATE
You can now mmap a file as private and writable, and the changes you
make will only be visible to you.

This works because internally a MAP_PRIVATE region is backed by a
unique PrivateInodeVMObject instead of using the globally shared
SharedInodeVMObject like we always did before. :^)

Fixes #1045.
2020-02-28 23:25:00 +01:00
Liav A
8dbd1cb9fb Kernel: Validate changed framebuffer resolution
Now we check before we set a FBResolution if the BXVGA device is capable
of setting the requested resolution.
If not, we revert the resolution to the previous one and return an error
to userspace.

Fixes #451.
2020-02-28 12:16:05 +01:00
Liav A
9ee6d00b57 VMWareBackdoor: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
5cd58adfa9 PS2MouseDevice: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
bb9fba1fdd KeyboardDevice: Use dbg() instead of dbgprintf() 2020-02-27 13:05:12 +01:00
Liav A
a7d7c0e60c Kernel: Change get_pci_address() to pci_address() in PCI::Device class
The Serenity Coding Style tends to not accept the word "get" in
methods' names if possible.
2020-02-24 11:27:03 +01:00
Liav A
c51a57fb32 Kernel: Update SB16 driver to use the new IRQHandler class
Also, add methods to allow changing of IRQ line in the SB16 card.
2020-02-24 11:27:03 +01:00
Liav A
895e874eb4 Kernel: Include the new PIT class in system components 2020-02-24 11:27:03 +01:00
Liav A
b3c132ffb7 Kernel: Update PATAChannel implementation to use the PIT class
Also, update the class implementation to use PCI::Device class
accordingly.
The create() helper will now search for an IDE controller in the
PCI bus, allowing to simplify the initialize() method.
2020-02-24 11:27:03 +01:00
Liav A
83aa868c17 Kernel: Update PATAChannel class to use the PCI::Device class
PATAChannel class will inherit from the PCI::Device class, thus,
can still implement IRQ handling.
2020-02-24 11:27:03 +01:00
Liav A
740534cd67 Kernel: Update system components to use the new IRQHandler class 2020-02-24 11:27:03 +01:00
Liav A
16055de978 Kernel: Introduce the PIT class
The PIT class inherits from HardwareTimer class, and is replacing
the PIT namespace.
2020-02-24 11:27:03 +01:00
Liav A
ea1251d465 Kernel: Add HardwareTimer class
This is an abstraction layer for future hardware timers
that will be implemented.
2020-02-24 11:27:03 +01:00
Andreas Kling
48f7c28a5c Kernel: Replace "current" with Thread::current and Process::current
Suggested by Sergey. The currently running Thread and Process are now
Thread::current and Process::current respectively. :^)
2020-02-17 15:04:27 +01:00
Andreas Kling
e28809a996 Kernel: Add forward declaration header 2020-02-16 01:50:32 +01:00