Commit graph

1420 commits

Author SHA1 Message Date
Andreas Kling 910fab564e LocalSocket: Make recvfrom() return 0 to signal EOF when peer is gone
Once the peer has disconnected, recvfrom() should always return 0 once
the socket buffer has been drained.
2019-08-17 11:04:45 +02:00
Andreas Kling 17670ae725 Meta: Fix up clean builds
This is kind of a mess, but because IPC client code depending on the
IPC protocol definition artifacts in the server code, we have to build
the IPC servers first. And their dependencies before that, etc.

One more drop in the "maybe we should switch to CMake" bucket..
2019-08-17 10:05:16 +02:00
Conrad Pankoff d0117744ab Meta: Rearrange makeall.sh for more consistent builds
makeall.sh used to build the AK tests and leave some binary objects laying
around that would get in the way of further incremental builds. There also
wasn't a lot of structure to the order things were built in. This patch
improves both of those things.
2019-08-17 09:31:35 +02:00
Jesse Buhagiar bc22456f89 Kernel: Added unmount ability to VFS
It is now possible to unmount file systems from the VFS via `umount`.
It works via looking up the `fsid` of the filesystem from the `Inode`'s
metatdata so I'm not sure how fragile it is. It seems to work for now
though as something to get us going.
2019-08-17 09:29:54 +02:00
Andreas Kling 6ad3efe067 Kernel+LibC: Add get_process_name() syscall
It does exactly what it sounds like:

    int get_process_name(char* buffer, int buffer_size);
2019-08-15 20:55:10 +02:00
Sergey Bugaev b4c607a8da Kernel: Add TmpFS
This is an FS that stores all of its contents directly in memory.
It's mounted on /tmp by default.
2019-08-15 19:20:51 +02:00
Andreas Kling 77737be7b3 Kernel: Stop eagerly loading entire executables
We were forced to do this because the page fault code would fall apart
when trying to generate a backtrace for a non-current thread.

This issue has been fixed for a while now, so let's go back to lazily
loading executable pages which should make everything a little better.
2019-08-15 10:29:44 +02:00
Sergey Bugaev cbdda91065 ProcessManager: Rename it to SystemMonitor
This is a more appropriate name now that it does a lot
more than just manage processes ^)
2019-08-14 14:28:45 +02:00
Conrad Pankoff ecde025375 Libraries: Add LibPCIDB for reading PCI device information from pci.ids 2019-08-14 13:12:54 +02:00
Conrad Pankoff 99ed4ce30c Userland: Implement simple lspci command 2019-08-14 06:28:53 +02:00
Conrad Pankoff 6fe18a0417 Kernel: Hide PCI logs behind a debug flag like other logs 2019-08-14 06:28:53 +02:00
Conrad Pankoff 833f0beeed Kernel: Reimplement /proc/pci as JSON, add some more fields 2019-08-14 06:28:53 +02:00
Conrad Pankoff dce003c7eb Kernel: Add more PCI configuration reading functions 2019-08-14 06:28:53 +02:00
Andreas Kling e8eadd19a5 Kernel: Show region access bits (R/W/X) in crash dump region lists
It's pretty helpful to be able to see the various access bits for each
region in a crash dump. :^)
2019-08-12 19:37:28 +02:00
Andreas Kling 7d6689055f Kernel+LibC+crash: Add mprotect() syscall
This patch adds the mprotect() syscall to allow changing the protection
flags for memory regions. We don't do any region splitting/merging yet,
so this only works on whole mmap() regions.

Added a "crash -r" flag to verify that we crash when you attempt to
write to read-only memory. :^)
2019-08-12 19:33:24 +02:00
Andreas Kling b24b111298 LibVT: Factor out terminal emulation from Terminal to make it reusable
Now that we're bringing back the in-kernel virtual console, we should
move towards having a single implementation of terminal emulation.

This patch rips out the emulation code from the Terminal application
and turns it into the beginnings of LibVT.

The basic design idea is that users of VT::Terminal will implement and
provide a VT::TerminalClient subclass to handle presentation-specific
things. We'll need to iterate on this, but it's a start. :^)
2019-08-12 17:34:48 +02:00
Conrad Pankoff 4b44962e03 Kernel: Use a CircularQueue for input rather than a DoubleBuffer
TTY::emit is called from an IRQ handler, and is used to push input data
into a buffer for later retrieval. Previously this was using DoubleBuffer,
but that class wants to take a lock. Our lock code wants to make sure
interrupts are enabled, but they're disabled while an IRQ handler is
running. This made the kernel sad, but this CircularQueue cheers it up by
avoiding the lock requirement completely.
2019-08-12 14:15:24 +02:00
Conrad Pankoff ce8387d1ed VirtualConsole: Only consume data from key-down events 2019-08-12 14:15:24 +02:00
Conrad Pankoff dffdd5545a Kernel: Restore alt+n hijacking for virtual console switching 2019-08-12 14:15:24 +02:00
Conrad Pankoff e4826276d1 Kernel: Don't forward hijacked keypresses in keyboard driver 2019-08-12 14:15:24 +02:00
Conrad Pankoff 67a4256a98 Server: Add TTYServer, a rudimentary text console manager
This should probably call out to a login program at some point. Right now
it just puts a root terminal on tty{1,2,3}.

Remember not to leave your Serenity workstation unattended!
2019-08-12 13:52:20 +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
Sergey Bugaev b9223e4f04 ProcFS: Expose local sockets in /proc/net/local 2019-08-11 16:30:43 +02:00
Sergey Bugaev dadf6337ef Kernel: Customize absolute_path() for more file types 2019-08-11 16:30:43 +02:00
Sergey Bugaev 1d03391488 Net: Store an acceptor PID alongside the origin PID in a socket
* The origin PID is the PID of the process that created this socket,
  either explicitly by calling socket(), or implicitly by accepting
  a TCP connection. Note that accepting a local socket connection
  does not create a new socket, it reuses the one connect() was
  called on, so for accepted local sockets the origin PID points
  to the connecting process.

* The acceptor PID is the PID of the process that accept()ed this
  socket. For accepted TCP sockets, this is the same as origin PID.
2019-08-11 16:30:43 +02:00
Sergey Bugaev 66e5d0bdf3 Net: Store all the LocalSockets in an InlineLinkedList 2019-08-11 16:30:43 +02:00
Sergey Bugaev a30930465e Net: Add LocalSocket::socket_path()
This is a little utility function to safely extract the path without
manually dealing with sun_path and null-termination.
2019-08-11 16:30:43 +02:00
Sergey Bugaev 8a975ff630 Net: Override LocalSocket::class_name() 2019-08-11 16:30:43 +02:00
Sergey Bugaev 908068d19d Net: Fix initializing sockaddr_un.sun_path copy buffers
The whole point of allocating an extra byte for the null terminator
is to initialize it to zero.
2019-08-11 16:30:43 +02:00
Sergey Bugaev 43ce6c5474 Kernel: Move socket role tracking to the Socket class itself
This is more logical and allows us to solve the problem of
non-blocking TCP sockets getting stuck in SocketRole::None.

The only complication is that a single LocalSocket may be shared
between two file descriptions (on the connect and accept sides),
and should have two different roles depending from which side
you look at it. To deal with it, Socket::role() is made a
virtual method that accepts a file description, and LocalSocket
internally tracks which FileDescription is the which one and
returns a correct role.
2019-08-11 16:30:43 +02:00
Sergey Bugaev d46c3b0b5b Net: Simplify how LocalSocket tracks open fds
Now that there can't be multiple clones of the same fd,
we only need to track whether or not an fd exists on each
side. Also there's no point in tracking connecting fds.
2019-08-11 16:30:43 +02:00
Sergey Bugaev 1606261c58 Kernel: Fix cloning file descriptions on fork
After a fork, the parent and the child are supposed to share
the same file description. For example, modifying the current
offset of a file description is visible in both of them.
2019-08-11 16:30:43 +02:00
Sergey Bugaev 2396b2ed70 Kernel: Add strncmp() 2019-08-11 16:30:43 +02:00
Andreas Kling c246f2db4a ProcFS: Add "readonly" and "block_size" fields to /proc/df 2019-08-11 10:10:17 +02:00
Andreas Kling c0bfea1b5c FileSystem: Move block_size() from DiskBackedFS to FS
Let's just say that all filesystems have a block size, to keep things
nice and simple.
2019-08-11 10:09:36 +02:00
Andreas Kling 752de9cd27 FileDescription: Disallow construction with a null File
It's not valid for a FileDescription to not have a file, so let's
disallow it by taking a File& (or FIFO&) in the constructor.
2019-08-11 09:33:31 +02:00
Andreas Kling 0dc05a33c1 Kernel: Remove an unused VFS function declaration 2019-08-11 09:27:04 +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
Conrad Pankoff d1a7316799 Kernel: Print out PCI devices during boot
This will make boot logs much more useful on real hardware, by showing
exactly what Serenity is trying to boot on.
2019-08-11 08:23:16 +02:00
Conrad Pankoff 3026c37d5d Kernel: Add serial_debug cmdline parameter
serial_debug will output all the kprintf and dbgprintf data to COM1 at
8-N-1 57600 baud. this is particularly useful for debugging the boot
process on live hardware.

Note: it must be the first parameter in the boot cmdline.
2019-08-11 08:22:42 +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
Conrad Pankoff fc3667c026 Kernel: Detect some outgoing TCP connection failures 2019-08-10 09:07:11 +02:00
Conrad Pankoff bd6d2c0819 Kernel: Use a more detailed state machine for socket setup 2019-08-10 09:07:11 +02:00
Conrad Pankoff 638008da13 Kernel: Move TCP state logging into TCPSocket 2019-08-10 09:07:11 +02:00
Conrad Pankoff 5308e310a0 Kernel: Make accept() fill address with peer name rather than local name 2019-08-10 08:50:44 +02:00
Conrad Pankoff 5c0f1f9834 Kernel: Fix get{sock,peer}name port endianness 2019-08-10 08:49:31 +02:00
Sergey Bugaev ccb482d1a7 Calculator: Add a simple calculator app
Closes https://github.com/SerenityOS/serenity/issues/319
2019-08-10 08:46:22 +02:00