Commit Graph

132 Commits

Author SHA1 Message Date
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
Andreas Kling
b52d0afecf SB16: Map the DMA buffer in kernelspace so we can write to it
This broke with the >3GB paging overhaul. It's no longer possible to
write directly to physical addresses below the 8MB mark. Physical pages
need to be mapped into kernel VM by using a Region.

Fixes #1099.
2020-01-20 13:13:03 +01:00
Andreas Kling
94ca55cefd Meta: Add license header to source files
As suggested by Joshua, this commit adds the 2-clause BSD license as a
comment block to the top of every source file.

For the first pass, I've just added myself for simplicity. I encourage
everyone to add themselves as copyright holders of any file they've
added or modified in some significant way. If I've added myself in
error somewhere, feel free to replace it with the appropriate copyright
holder instead.

Going forward, all new source files should include a license header.
2020-01-18 09:45:54 +01:00
Andreas Kling
e362b56b4f Kernel: Move kernel above the 3GB virtual address mark
The kernel and its static data structures are no longer identity-mapped
in the bottom 8MB of the address space, but instead move above 3GB.

The first 8MB above 3GB are pseudo-identity-mapped to the bottom 8MB of
the physical address space. But things don't have to stay this way!

Thanks to Jesse who made an earlier attempt at this, it was really easy
to get device drivers working once the page tables were in place! :^)

Fixes #734.
2020-01-17 22:34:26 +01:00
Andreas Kling
017b34e1ad Kernel: Add "video" pledge for accessing framebuffer devices
WindowServer becomes the only user.
2020-01-12 02:18:30 +01:00
Andreas Kling
673d789c39 Kernel: Make some static keyboard data const
This moves it to the kernel's .rodata section which we write protect in
MemoryManager initialization.
2020-01-09 16:23:45 +01:00
Tibor Nagy
1bb98c6950 Kernel: Fix IRQ define in PS2MouseDevice 2020-01-05 10:45:30 +01:00
Andreas Kling
9026598999 Kernel: Add a more expressive API for getting random bytes
We now have these API's in <Kernel/Random.h>:

    - get_fast_random_bytes(u8* buffer, size_t buffer_size)
    - get_good_random_bytes(u8* buffer, size_t buffer_size)
    - get_fast_random<T>()
    - get_good_random<T>()

Internally they both use x86 RDRAND if available, otherwise they fall
back to the same LCG we had in RandomDevice all along.

The main purpose of this patch is to give kernel code a way to better
express its needs for random data.

Randomness is something that will require a lot more work, but this is
hopefully a step in the right direction.
2020-01-03 12:43:07 +01:00
Liav A
e5ffa960d7 Kernel: Create support for PCI ECAM
The new PCI subsystem is initialized during runtime.
PCI::Initializer is supposed to be called during early boot, to
perform a few tests, and initialize the proper configuration space
access mechanism. Kernel boot parameters can be specified by a user to
determine what tests will occur, to aid debugging on problematic
machines.
After that, PCI::Initializer should be dismissed.

PCI::IOAccess is a class that is derived from PCI::Access
class and implements PCI configuration space access mechanism via x86
IO ports.
PCI::MMIOAccess is a class that is derived from PCI::Access
and implements PCI configurtaion space access mechanism via memory
access.

The new PCI subsystem also supports determination of IO/MMIO space
needed by a device by checking a given BAR.
In addition, Every device or component that use the PCI subsystem has
changed to match the last changes.
2020-01-02 00:50:09 +01:00
Tibor Nagy
624116a8b1 Kernel: Implement AltGr key support 2019-12-31 19:31:42 +01:00
Andreas Kling
54d182f553 Kernel: Remove some unnecessary leaking of kernel pointers into dmesg
There's a lot more of this and we need to stop printing kernel pointers
anywhere but the debug console.
2019-12-31 01:22:00 +01:00
Conrad Pankoff
0b3a868729 Kernel: Simplify force_pio logic in PATA driver (#923) 2019-12-26 22:57:58 +01:00
Andreas Kling
b6ee8a2c8d Kernel: Rename vmo => vmobject everywhere 2019-12-19 19:15:27 +01:00
Andreas Kling
e9dda8d592 Kernel: Give PTY's *actually* unique major ID's
Okay, one "dunce hat" point for me. The new PTY majors conflicted with
PATAChannel. Now they are 200 for master and 201 for slave, not used
by anything else.. I hope!
2019-12-09 21:03:39 +01:00
Andreas Kling
2e38df7bd1 Kernel: Assert that device major/minor hasn't already been registered
It would be a bug to have multiple devices with the same major/minor
so let's have an assertion for that.
2019-12-09 15:51:10 +01:00
Andreas Kling
7126a42d4d Kernel: Use a WaitQueue in the SoundBlaster 16 driver
Instead of waking up to check for IRQ's regularly, use a WaitQueue and
wake it up in the IRQ handler.
2019-12-01 12:57:35 +01:00
Andreas Kling
8b129476b1 Kernel: Use a WaitQueue in PATAChannel
Instead of waking up repeatedly to check if a disk operation has
finished, use a WaitQueue and wake it up in the IRQ handler.

This simplifies the device driver a bit, and makes it more responsive
as well :^)
2019-12-01 12:54:38 +01:00
Hüseyin ASLITÜRK
794ca16cca Kernel: Implement the setkeymap() syscall. 2019-11-25 11:53:02 +01:00
Andreas Kling
9a157b5e81 Revert "Kernel: Move Kernel mapping to 0xc0000000"
This reverts commit bd33c66273.

This broke the network card drivers, since they depended on kmalloc
addresses being identity-mapped.
2019-11-23 17:27:09 +01:00
Jesse Buhagiar
bd33c66273 Kernel: Move Kernel mapping to 0xc0000000
The kernel is now no longer identity mapped to the bottom 8MiB of
memory, and is now mapped at the higher address of `0xc0000000`.

The lower ~1MiB of memory (from GRUB's mmap), however is still
identity mapped to provide an easy way for the kernel to get
physical pages for things such as DMA etc. These could later be
mapped to the higher address too, as I'm not too sure how to
go about doing this elegantly without a lot of address subtractions.
2019-11-22 16:23:23 +01:00
supercomputer7
4fe2ee0221 Kernel: Add a kernel boot parameter to force PIO mode
Also added an option in the run script to force PIO operation mode with
the IDE controller.
In addition, we're no longer limited to PIIX3 and PIIX4 chipsets for DMA
2019-11-13 18:30:25 +01:00
Sergey Bugaev
cfdbb712fb Kernel: Fix failing in can_read()/can_write()
Now that the SystemMonitor queries which open files can be read and written to,
having can_read()/can_write() unconditionally call ASSERT_NOT_REACHED() leads
to system crashes when inspecting the WindowServer.

Instead, just return true from can_read()/can_write() (indicating that the
read()/write() syscalls should not block) and return -EINVAL when trying to
actually read from or write to these devices.
2019-11-13 16:37:04 +01:00
Jesse Buhagiar
6c1a549057 PATAChannel: Alert user when no PCI device is found
This helps aid debugging of issues such as #695, where the bridge chip
that controls IDE is NOT a PIIX3/4 compatible controller. Instead of
just hanging when the DMA registers can't be accessed, the system will
inform the user that no valid IDE controller has been found. In this
case, the system will not attempt to initialise the DMA registers and
instead use PIO mode.
2019-11-04 15:15:48 +01:00
Andreas Kling
1b2ef8582c Kernel: Make File's can_read/can_write take a const FileDescription&
Asking a File if we could possibly read or write it will never mutate
the asking FileDescription&, so it should be const.
2019-11-04 14:03:14 +01:00
Jesse Buhagiar
c12d153894 Kernel: Fixed fdc read/write problem
Fixed an issue with operator precedence in calls to `send_byte()`, in
which a value of `1` was being sent to the function. This had the
nasty side-effect of selecting the slave drive if the value of
`head` was equal to one. A read/write would fail in the case, as
it would attempt to read from the slave drive (not good).

I've also added a seek to the top of the read/write code, which seems
to have fixed an issue with Linux not detecting the disk images after
they have been unmounted from Serenity. This isn't specified in the
datasheet, but a few other drivers have it so we should too :^)
2019-10-23 07:46:16 +02:00
Nufflee
7b6aba4284 KeyboardDevice: Rename 0xe0 flag for clarity. 2019-10-17 23:39:24 +02:00
Nufflee
0979f372a6 KeyboardDevice: Support whole numpad and Num Lock.
We now support all numpad keys and the Num Lock key.
2019-10-17 23:39:24 +02:00
Nufflee
9d5792b73d KeyboardDevice: Implement Caps Lock handling. 2019-10-17 23:39:24 +02:00
Andreas Kling
e4015ab7cc Kernel: Remove unused FileBackedDiskDevice class 2019-10-14 12:47:08 +02:00
supercomputer7
334e039294 PartitionTable: Removing unnecessary declarations from GPT & MBR classes 2019-10-07 11:32:42 +02:00
supercomputer7
de49714f36 PartitionTable: Initial GPT Support, Adding Block Limit
Also added a script to handle creation of GPT partitioned disk (with
GRUB config file). Block limit will be used to disallow potential access
to other partitions.
2019-10-07 10:11:39 +02:00
Andreas Kling
345086ab72 BXVGADevice: Log a debug message whenever the resolution changes
Fixes #618.
2019-10-02 17:16:46 +02:00
Andreas Kling
c5e057438c MBVGADevice: Log address/pitch/width/height when created 2019-09-30 15:04:16 +02:00
Andreas Kling
8f45a259fc ByteBuffer: Remove pointer() in favor of data()
We had two ways to get the data inside a ByteBuffer. That was silly.
2019-09-30 08:57:01 +02:00
Andreas Kling
73fdbba59c AK: Rename <AK/AKString.h> to <AK/String.h>
This was a workaround to be able to build on case-insensitive file
systems where it might get confused about <string.h> vs <String.h>.

Let's just not support building that way, so String.h can have an
objectively nicer name. :^)
2019-09-06 15:36:54 +02:00
Andreas Kling
e5500e2a22 Kernel: Fix wrong I/O ports for the ATA alternate status registers
The alternate status register is not part of the same set of registers
as all the other stuff.

Also rename wait_400ns() to io_delay() since we had no guarantee that
it was waiting for 400ns..
2019-09-04 11:11:03 +02:00
Andreas Kling
8cbb38a237 Kernel: Remove unused gunk from PATADiskDevice 2019-09-04 11:06:10 +02:00
Jesse Buhagiar
1112899a63 Kernel: Fixed FDC motor_enable()
Motor Enable now selects the correct drive. The ternary
operations were backwards. QEMU doesn't care (obviously) but
on a real PC, the drive doesn't actually ever get selected...
2019-08-29 10:18:39 +02:00
Andreas Kling
e29fd3cd20 Kernel: Display virtual addresses as V%p instead of L%x
The L was a leftover from when these were called linear addresses.
2019-08-26 11:31:58 +02:00
Andreas Kling
5de483cfbb Kernel: Move DiskDevice::block_size() up to BlockDevice
All block devices should have a block size, after all. This defaults to
PAGE_SIZE if no size is specified.
2019-08-21 16:48:59 +02:00
Sergey Bugaev
acccf9ccda Kernel: Move device lookup to Device class itself
Previously, VFS stored a list of all devices, and devices had to
register and unregister themselves with it. This cleans up things
a bit.
2019-08-18 15:59:59 +02:00
Conrad Pankoff
b957c61e6f Kernel: Implement generic VGA device using multiboot info
This implements a very basic VGA device using the information provided
to us by the bootloader in the multiboot header. This allows Serenity to
boot to the desktop on basically any halfway modern system.
2019-08-18 07:40:53 +02:00
Conrad Pankoff
3932dfbb04 Kernel: Implement generic framebuffer ioctls in BXVGA
This also hides some functions that were previously public, since that
same functionality is now exposed via ioctl functions.
2019-08-18 07:40:02 +02:00
Jesse
ad909e7c3f FloppyDiskDevice: Fixed hang on wait_for_irq() (#458)
It turns out that the `SenseInterrupt` command is actually
very important! The system hangs if it's not there! Whoops...!
2019-08-17 16:26:53 +02:00
Sergey Bugaev
fde8f7f538 Kernel: Expose info about source devices of mounts in /proc/df 2019-08-17 12:07:55 +02:00
Sergey Bugaev
37cc80fb96 ProcFS: Do not assume there is one of it
The complication is around /proc/sys/ variables, which were attached
to inodes. Now they're their own thing, and the corresponding inodes
are lazily created (as all other ProcFS inodes are) and simply refer
to them by index.
2019-08-17 12:07:55 +02:00
Conrad Pankoff
e4826276d1 Kernel: Don't forward hijacked keypresses in keyboard driver 2019-08-12 14:15:24 +02:00