Commit Graph

178 Commits

Author SHA1 Message Date
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
Andreas Kling
a356e48150 Kernel: Move all code into the Kernel namespace 2020-02-16 01:27:42 +01:00
Andreas Kling
6cbd72f54f AK: Remove bitrotted Traits::dump() mechanism
This was only used by HashTable::dump() which I used when doing the
first HashTable implementation. Removing this allows us to also remove
most includes of <AK/kstdio.h>.
2020-02-10 11:55:34 +01:00
Liav A
99ea80695e Kernel: Use VirtualAddress & PhysicalAddress classes from LibBareMetal 2020-02-09 19:38:17 +01:00
Liav A
e559af2008 Kernel: Apply changes to use LibBareMetal definitions 2020-02-09 19:38:17 +01:00
Conrad Pankoff
a189285658 Kernel: Support reading/writing PATADiskDevices directly via /dev/hdX 2020-02-09 12:58:45 +01:00
Andreas Kling
88ea152b24 Kernel: Merge unnecessary DiskDevice class into BlockDevice 2020-02-08 02:20:03 +01:00
Andreas Kling
083b81a566 Kernel: Allow PS2MouseDevice to read multiple packets
We were overwriting the start of the output buffer over and over when
reading multiple mouse packets.
2020-02-07 11:25:12 +01:00
Liav A
f6ce24eb48 Kernel: Move the VMWare helpers out of the IO namespace 2020-02-05 18:58:27 +01:00
Liav A
8e8f5c212b Kernel: Fix vmmouse detection method
Also, add debug messages in the VMWareBackdoor class.
2020-02-05 18:58:27 +01:00
Liav A
6070fe581b Kernel: Add support for high bandwidth IO communication with VMWare 2020-02-05 18:58:27 +01:00
Liav A
47978a5828 Kernel: Add support for vmmouse
We add this feature together with the VMWareBackdoor class.
VMWareBackdoor class is responsible for enabling the vmmouse, and then
controlling it from the PS2 mouse IRQ handler.
2020-02-04 19:11:52 +01:00
Sergey Bugaev
0334656e45 Kernel: Stub absolute mouse positioning support
This is not the real kernel patch, @supercomputer7 is doing that :^)
2020-02-04 19:11:52 +01:00
Liav A
81544dc5b4 Partition Table: Add support for Extended partitions
Now also MBR configurations with extended partitions are supported.
2020-02-02 00:20:41 +01:00
Liav A
8cde707931 Partition Table: Replace __attribute__((packed)) with [[gnu::packed]] 2020-02-02 00:20:41 +01:00
Liav A
a3113721d4 Partition Table: Replace __attribute__((packed)) with [[gnu::packed]] 2020-02-01 17:32:25 +01:00
Andreas Kling
1d2c9dbc3a BXVGA: Disallow resolutions higher than 4096x2160
There's no sense in allowing arbitrarily huge resolutions. Instead, we
now cap the screen size at 4K DCI resolution and will reject attempts
to go bigger with EINVAL.
2020-01-28 20:57:40 +01:00
Andreas Kling
c17f80e720 Kernel: AnonymousVMObject::create_for_physical_range() should fail more
Previously it was not possible for this function to fail. You could
exploit this by triggering the creation of a VMObject whose physical
memory range would wrap around the 32-bit limit.

It was quite easy to map kernel memory into userspace and read/write
whatever you wanted in it.

Test: Kernel/bxvga-mmap-kernel-into-userspace.cpp
2020-01-28 20:48:07 +01:00
Andreas Kling
e64c335e5a Revert "Kernel: Replace IRQHandler with the new InterruptHandler class"
This reverts commit 6c72736b26.

I am unable to boot on my home machine with this change in the tree.
2020-01-22 22:27:06 +01:00
Jesse Buhagiar
9cbce68b1d Meta: Change copyright holder of `FloppyDiskDevice.* 2020-01-22 14:37:44 +01:00
Liav A
6c72736b26 Kernel: Replace IRQHandler with the new InterruptHandler class
System components that need an IRQ handling are now inheriting the
InterruptHandler class.

In addition to that, the initialization process of PATAChannel was
changed to fit the changes.
PATAChannel, E1000NetworkAdapter and RTL8139NetworkAdapter are now
inheriting from PCI::Device instead of InterruptHandler directly.
2020-01-22 12:22:09 +01:00
Liav A
2a160faf98 Kernel: Run clang-format on KeyboardDevice.cpp 2020-01-22 12:22:09 +01:00
Andreas Kling
f38cfb3562 Kernel: Tidy up debug logging a little bit
When using dbg() in the kernel, the output is automatically prefixed
with [Process(PID:TID)]. This makes it a lot easier to understand which
thread is generating the output.

This patch also cleans up some common logging messages and removes the
now-unnecessary "dbg() << *current << ..." pattern.
2020-01-21 16:16:20 +01:00