Commit Graph

89 Commits

Author SHA1 Message Date
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
Conrad Pankoff
072bf8cbb9 Kernel: Fix non-DMA writes to IDE drives
Our logic for using the ATA_CMD_CACHE_FLUSH functionality was a bit wrong,
and now it's better.

The ATA spec says these two things:

> The device shall enter the interrupt pending state when:
> 1) any command except a PIO data-in command reaches command completion
>    successfully;
> ...
> The device shall exit the interrupt pending state when:
> 1) the device is selected, BSY is cleared to zero, and the Status
>		 register is read;

This means that our sequence of actions was probably never going to work.
We were waiting in a loop checking the status register until it left the
busy state, _then_ waiting for an interrupt. Unfortunately by checking the
status register, we were _clearing_ the interrupt we were about to wait
for.

Now we just wait for the interrupt - we don't poll the status register at
all. This also means that once we get our `wait_for_irq` method sorted out
we'll spend a bunch less CPU time waiting for things to complete.
2019-08-12 13:25:59 +02:00
Conrad Pankoff
53ddbce0b3 Kernel: Use established device name and number for framebuffer
This is to prepare for other framebuffer implementations, for which it
would be inappropriate to use the /dev/bxvga device name.
2019-08-12 12:56:55 +02:00
Conrad Pankoff
e60577aab6 Kernel: Allow boot without mouse attached by checking for presence 2019-08-12 12:51:52 +02:00
Conrad Pankoff
2267b3bd72 Kernel: Clean up some PATA log messages 2019-08-11 08:25:11 +02:00
Conrad Pankoff
f6dd76b915 Kernel: Fix PATA reads without DMA
Apparently we need to poll the drive for its status after each sector we
read if we're not doing DMA. Previously we only did it at the start,
which resulted in every sector after the first in a batch having 12 bytes
of garbage on the end. This manifested as silent read corruption.
2019-08-11 08:25:11 +02:00
Andreas Kling
a4548a150f Kernel: Hack the default keymap to support UK pipe/backslash
Since this key number doesn't appear to collide with anything on the
US keymap, I was thinking we could get away with supporting a hybrid
US/UK keymap. :^)
2019-08-10 14:29:32 +02:00
Andreas Kling
6bdb81ad87 Kernel: Split VMObject into two classes: Anonymous- and InodeVMObject
InodeVMObject is a VMObject with an underlying Inode in the filesystem.
AnonymousVMObject has no Inode.

I'm happy that InodeVMObject::inode() can now return Inode& instead of
VMObject::inode() return Inode*. :^)
2019-08-07 18:09:32 +02:00
Andreas Kling
bebe7c4cff DiskDevice: Add missing override and remove unnecessary class_name()
This class needs to be fixed up to not hide the read()/write() virtuals
at some point.
2019-08-07 07:21:28 +02:00
Jesse
401c87a0cc Kernel: mount system call (#396)
It is now possible to mount ext2 `DiskDevice` devices under Serenity on
any folder in the root filesystem. Currently any user can do this with
any permissions. There's a fair amount of assumptions made here too,
that might not be too good, but can be worked on in the future. This is
a good start to allow more dynamic operation under the OS itself.

It is also currently impossible to unmount and such, and devices will
fail to mount in Linux as the FS 'needs to be cleaned'. I'll work on
getting `umount` done ASAP to rectify this (as well as working on less
assumption-making in the mount syscall. We don't want to just be able
to mount DiskDevices!). This could probably be fixed with some `-t`
flag or something similar.
2019-08-02 15:18:47 +02:00
Jesse
59e122f8ba Kernel: Expand PATA driver to support multiple hard drives (#365)
The previous implementation of the PIIX3/4 PATA/IDE channel driver only
supported a single drive, as the object model was wrong (the channel
inherits the IRQ, not the disk drive itself). This fixes it by 'attaching'
two `PATADiskDevices` to a `PATAChannel`, which makes more sense.

The reading/writing code is presented as is, which violates the spec
outlined by Seagate in the linked datasheet. That spec is rather old,
so it might not be 100% up to date, though may cause issues on real
hardware, so until we can actually test it, this will suffice.
2019-07-28 15:44:01 +02:00
Robin Burchell
833d444cd8 Thread: Return a result from block() indicating why the block terminated
And use this to return EINTR in various places; some of which we were
not handling properly before.

This might expose a few bugs in userspace, but should be more compatible
with other POSIX systems, and is certainly a little cleaner.
2019-07-20 12:15:24 +02:00
Robin Burchell
762333ba95 Kernel: Restore state strings for block states
"Blocking" is not terribly informative, but now that everything is
ported over, we can force the blocker to provide us with a reason.

This does mean that to_string(State) needed to become a member, but
that's OK.
2019-07-19 11:03:22 +02:00
Andreas Kling
bf8d72f5a4 Kernel: Remove unnecessary use of LibDraw.
BXVGADevice was using a Size object for its framebuffer size. We shouldn't
be pulling in userspace code in the kernel like this, even if it's just
headers. :^)
2019-07-18 10:36:26 +02:00
Andreas Kling
1c0669f010 LibDraw: Introduce (formerly known as SharedGraphics.)
Instead of LibGUI and WindowServer building their own copies of the drawing
and graphics code, let's it in a separate LibDraw library.

This avoids building the code twice, and will encourage better separation
of concerns. :^)
2019-07-18 10:18:16 +02:00
Jesse
10ffaf019f Kernel: Initial FDC Device Driver (#315)
A basic Floppy Disk Controller device driver for any system later than (and including) the IBM AT. The driver is based on the documentation supplied by QEMU, which is the datasheet for the Intel 82078 Floppy Disk controller (found here: https://wiki.qemu.org/images/f/f0/29047403.pdf)

Naturally, floppy disks are a _very_ outdated storage medium, however, as Serenity is a throwback to aesthetic 90s computing, it's a definite must have. Not to mention that there are still a lot of floppy disks around, with countless petabytes of software on them, so it would be nice if people could create images of said disks with serenity.

The code for this is mostly clean. however there are a LOT of values specified in the datasheet, so some of them might be wrong, not to mention that the actual specification itself is rather dirt and seemingly hacked together.

I'm also only supporting 3.5" floppy disks, without PIO polling (DMA only), so if you want anything more/less than 1.44MB HD Floppys, you'll have to do it yourself.
2019-07-17 15:51:51 +02:00
Andreas Kling
3dac1f8ac5 Kernel: Remove use of [[gnu::pure]].
I was messing around with this to tell the compiler that these functions
always return the same value no matter how many times you call them.

It doesn't really seem to improve code generation and it looks weird so
let's just get rid of it.
2019-07-16 13:44:41 +02:00
Andreas Kling
89c6064141 IDEDiskDevice: Remove superstitious memory_barrier(). 2019-07-16 13:41:21 +02:00
Andreas Kling
e78097d140 SB16: Set "m_interrupted" to false before enabling IRQ's.
Otherwise, we might get interrupted before entering wait_for_irq() and then
resetting the flag again.
2019-07-14 15:02:02 +02:00
Andreas Kling
b2e502e533 Kernel: Add Thread::block_until(Condition).
Replace the class-based snooze alarm mechanism with a per-thread callback.
This makes it easy to block the current thread on an arbitrary condition:

    void SomeDevice::wait_for_irq() {
        m_interrupted = false;
        current->block_until([this] { return m_interrupted; });
    }
    void SomeDevice::handle_irq() {
        m_interrupted = true;
    }

Use this in the SB16 driver, and in NetworkTask :^)
2019-07-14 14:54:54 +02:00
Andreas Kling
983245113a SB16: Write the correct DMA buffer offset for 16-bit samples.
Also switch to using single-cycle mode for now. It would be nice to add
support for auto-initialized mode but this works okay at the moment.
2019-07-13 21:28:35 +02:00
Andreas Kling
02c3c737f6 SB16: IRQ handler should send 0xd5 to pause 16-bit playback.
We were sending 0xd0 to pause 8-bit playback. Not sure if this actually
makes any difference but it seems like the correct thing to do.
Also update 'm_interrupted' *after* handling things.
2019-07-13 20:43:38 +02:00
Andreas Kling
dcfa93e71f SB16: Use a snooze alarm to block the current thread while playing. 2019-07-13 20:15:17 +02:00
Andreas Kling
b51f0f7bfa SB16: Put debug spam behind SB16_DEBUG. 2019-07-13 17:55:48 +02:00
Andreas Kling
48bde0393e SB16: Use Stereo samples by default. 2019-07-13 17:51:36 +02:00
Andreas Kling
d63b6e624e SB16: Send (sample count, less 1) to the DSP, not the number of bytes.
This worked fine when we were using 8-bit samples but broke on 16-bit.
2019-07-13 17:47:57 +02:00
Andreas Kling
781a28f3ed SB16: Switch to signed 16-bit 44100 Hz Mono by default.
We should switch to Stereo but I'm having some trouble with that locally..
Since we intend to mix everything through SoundServer, let's just put the
card into 16-bit mode right away.
2019-07-13 17:12:33 +02:00
Robin Burchell
6c4024c04a Kernel: First cut of a sb16 driver
Also add an AudioServer that (right now) doesn't do much.
It tries to open, parse, and play a wav file. In the future, it can do more.

My general thinking here here is that /dev/audio will be "owned" by AudioServer,
and we'll do mixing in software before passing buffers off to the kernel
to play, but we have to start somewhere.
2019-07-13 08:00:24 +02:00
Andreas Kling
5254a320d8 Kernel: Remove use of copy_ref() in favor of regular RefPtr copies.
This is obviously more readable. If we ever run into a situation where
ref count churn is actually causing trouble in the future, we can deal with
it then. For now, let's keep it simple. :^)
2019-07-11 15:40:04 +02:00
Andreas Kling
149fd7e045 Kernel: Move PhysicalAddress.h into VM/ 2019-07-09 15:04:45 +02:00
Andreas Kling
eca5c2bdf8 Kernel: Move VirtualAddress.h into VM/ 2019-07-09 15:04:45 +02:00
Andreas Kling
f4cec2f110 Kernel: Move File.{cpp,h} into FileSystem/
Also tweak the kernel's Makefile to use -nostdinc and -nostdinc++.
This prevents us from picking up random headers from ../Root, which may
include older versions of kernel headers.

Since we still need <initializer_list> for Vector, we specifically include
the necessary GCC path. This is a bit hackish but it works for now.
2019-07-09 15:04:45 +02:00
Andreas Kling
9fdcede491 Kernel: Move PIC.cpp into Arch/i386/ 2019-07-09 15:04:43 +02:00
Andreas Kling
34709a2c24 IDEDiskDevice: Fix build after merging slave device changes. 2019-07-08 08:20:12 +02:00
Jesse
ab90d2e251 Kernel: Extended IDE interface to allow slave device usage (#283)
The IDE Disk Controller driver has been extended to allow the secondary device on the channel to be initialised and used. A test as to whether this is working (for anyone interested) is to modify `init.cpp:87` to `auto dev_hd0 = IDEDiskDevice::create(IdeDiskDevice::DeviceType::SLAVE);`. The kernel will fail to boot, as there is no disk attached to CHANNEL 1's slave. This was born out of the fact that my FAT driver can't be tested as easily without creating a partition on `hda`.
2019-07-08 08:16:52 +02:00
Andreas Kling
27f699ef0c AK: Rename the common integer typedefs to make it obvious what they are.
These types can be picked up by including <AK/Types.h>:

* u8, u16, u32, u64 (unsigned)
* i8, i16, i32, i64 (signed)
2019-07-03 21:20:13 +02:00
Andreas Kling
d343fb2429 AK: Rename Retainable.h => RefCounted.h. 2019-06-21 18:58:45 +02:00
Andreas Kling
550b0b062b AK: Rename RetainPtr.h => RefPtr.h, Retained.h => NonnullRefPtr.h. 2019-06-21 18:45:59 +02:00
Andreas Kling
90b1354688 AK: Rename RetainPtr => RefPtr and Retained => NonnullRefPtr. 2019-06-21 18:37:47 +02:00
Andreas Kling
77b9fa89dd AK: Rename Retainable => RefCounted.
(And various related renames that go along with it.)
2019-06-21 15:30:03 +02:00
Conrad Pankoff
8b1154f5f2 Kernel: Implement serial port driver
This implements a basic 8250 UART serial port driver. It does not
currently handle (or enable) interrupts, nor any runtime configuration.
2019-06-08 18:12:20 +02:00
Conrad Pankoff
842bf96e2c Kernel: Fix booting from "inactive" MBR partitions
Apparently you can boot from any MBR partition, not just the one labeled
as "bootable" or "active". The only ones you don't want to boot from are
the ones that don't exist.
2019-06-08 17:59:17 +02:00
Andreas Kling
736092a087 Kernel: Move i386.{cpp,h} => Arch/i386/CPU.{cpp,h}
There's a ton of work that would need to be done before we could spin up on
another architecture, but let's at least try to separate things out a bit.
2019-06-07 20:02:01 +02:00
Andreas Kling
e42c3b4fd7 Kernel: Rename LinearAddress => VirtualAddress. 2019-06-07 12:56:50 +02:00