Commit Graph

2477 Commits

Author SHA1 Message Date
Andreas Kling
f008156dbf Socket: Fix missing kprintf() args in setsockopt(). 2019-05-20 19:45:27 +02:00
Andreas Kling
9df8d28542 WindowServer: Don't start window resize for MouseUp or MouseMove. 2019-05-20 11:06:10 +02:00
Andreas Kling
bcc6ddfb6b Kernel: Let PageDirectory own the associated RangeAllocator.
Since we transition to a new PageDirectory on exec(), we need a matching
RangeAllocator to go with the new directory. Instead of juggling this in
Process and MemoryManager, simply attach the RangeAllocator to the
PageDirectory instead.

Fixes #61.
2019-05-20 04:46:29 +02:00
Andreas Kling
d65114afd7 WindowServer: Convert some assertions into client did_misbehave()'s. 2019-05-20 04:29:07 +02:00
Andreas Kling
091448b8f3 WindowServer: Use blocking sockets for client connections. 2019-05-20 04:08:09 +02:00
Andreas Kling
5023464d95 LocalSocket: Make send() and sendto() work, too. 2019-05-20 03:59:30 +02:00
Andreas Kling
668bfaa2af LocalSocket: Bump internal buffer sizes to 16KB.
This gives us some leeway for WindowServer to queue up a bunch of messages
for one of its clients. Longer-term we should improve DoubleBuffer to be
able to grow dynamically in a way that gets billed to some reasonable place.
2019-05-20 03:57:25 +02:00
Andreas Kling
dc03b50f41 GEventLoop: Make the WindowServer connection use a blocking socket. 2019-05-20 03:47:50 +02:00
Andreas Kling
b3a1671f1a Kernel: Add support for recv() with MSG_DONTWAIT.
Passing this flag to recv() temporarily puts the file descriptor into
non-blocking mode.

Also implement LocalSocket::recv() as a simple forwarding to read().
2019-05-20 03:47:02 +02:00
Andreas Kling
0b850cf726 WindowServer: Allow sending up to 32 invalidation rects inline.
Oops, it looks like I left the max inline rects limit at 1 while debugging
this code.. We can fit 32 rects in a single WSAPI message without needing
a second "extra data" message, so let's use the space we have!
2019-05-20 03:18:43 +02:00
Robin Burchell
d791bce6af CEventLoop: Allow manually driving the event loop
Move the bulk of exec() into a new pump(). Since SDL wants to drive the
event loop itself, this is a requirement. We also add a WaitMode flag to
allow for immediately pumping events -- again, this is required because
SDL wants to be in full control of the event loop, and not let us wait.
2019-05-20 03:03:48 +02:00
Andreas Kling
85d2e85912 LocalSocket: Fix mismatch between can_write() and write() logic.
can_write() was saying yes in situations where write() would overflow the
internal buffer. This patch adds a has_attached_peer() helper to make it
easier to understand what's going on in these functions.
2019-05-20 02:54:52 +02:00
Andreas Kling
612e1c7023 Toolchain: Oops, let's unbreak UseIt.sh. 2019-05-20 02:06:41 +02:00
Robin Burchell
a8864dc590 Kernel: Report EAGAIN from read() on a non-blocking socket if the buffer is empty
This is not EOF, and never should have been so -- can trip up other code
when porting.

Also updates LibGUI and WindowServer which both relied on the old
behaviour (and didn't work without changes). There may be others, but I
didn't run into them with a quick inspection.
2019-05-20 01:31:28 +02:00
Robin Burchell
40a5eb4e6e Minesweeper: Make things a little more friendly at the start
Rather than having the first click hit a bomb, if the first click would
hit a bomb, instead, reset the game board.

This is a (sort of) feature of Windows minesweeper, and IMO makes
playing a bit more fun :-)
2019-05-19 21:33:50 +02:00
Andreas Kling
5b6e66195b LibC: Add an h_addr macro for old code that doesn't know about h_addr_list. 2019-05-19 19:55:49 +02:00
Andreas Kling
212a263f0a Kernel+LibC: Implement getsockname() syscall. 2019-05-19 19:55:27 +02:00
Andreas Kling
0eb788d641 LibC: Add stub for fsync(). 2019-05-19 19:54:20 +02:00
Andreas Kling
189b342e6f LibC: Add mmap_with_name() that names the allocation immediately.
This allows us to skip the separate call to set_mmap_name() in code that
we control, e.g malloc() and GraphicsBitmap.
2019-05-19 15:54:56 +02:00
Andreas Kling
5f26f83451 IDEDiskDevice: Add sysctl variable for turning DMA on/off. 2019-05-19 15:54:33 +02:00
Andreas Kling
29863d3815 LibC: unsetenv() should take a const char*, not a char*. 2019-05-19 15:19:48 +02:00
Robin Burchell
5f597d0cb2 WindowServer: Improve client write handling a little
* EPIPE now correctly deletes the client connection
* EAGAIN (which is now returned by the kernel if the write buffer fills)
  terminates the connection also
2019-05-19 14:13:49 +02:00
Robin Burchell
d8b74c8c86 Kernel: Check can_write for blocking write
This way the socket write buffer sizes are respected, and things that
exceed them get sent EAGAIN.
2019-05-19 14:13:49 +02:00
Robin Burchell
635eb20289 Kernel: Add the ability to debug poll/select independently of read/write 2019-05-19 14:13:49 +02:00
Andreas Kling
c7d8aa6969 IDEDiskDevice: Support reading multiple sectors at a time with DMA.
This is another sizable improvement to GCC compile times.
2019-05-19 04:40:30 +02:00
Andreas Kling
ed79116e94 IDEDiskDevice: Use wait_for_irq() when waiting for DMA transfers.
Also make sure we return any device errors to caller.
2019-05-19 03:56:06 +02:00
Andreas Kling
c818773983 IDEDiskDevice: Add support for DMA reads.
I've only tested this with the PIIX3 chipset QEMU emulates, but it works
pretty well here. GCC compile times are cut roughly in half :^)
2019-05-19 03:46:50 +02:00
Andreas Kling
1fd90b09f8 Kernel: Remove an unused ELFLoader member. 2019-05-19 02:03:56 +02:00
Andreas Kling
6e305bf838 AK: Simplify quick_sort() and improve Vector iterators a bit. 2019-05-19 01:53:51 +02:00
Andreas Kling
853597200e Kernel: Remove relocation-related code since it's not used by the kernel.
If/when we need this in the future, we can bring it back. Right now it's
just sitting there making the ELF code look huge when it's not.
2019-05-19 01:14:32 +02:00
Andreas Kling
75866438b5 Kernel: Don't page in entire file immediately on mmap().
If we just don't do anything, the page fault handler will load the file
incrementally as-needed instead. :^)
2019-05-18 22:30:55 +02:00
Andreas Kling
f5234660f6 malloc: Use a Vector with inline capacity for the big block recyclers. 2019-05-18 22:26:01 +02:00
Andreas Kling
959c8f287c FileDescriptor: It's actually okay to seek past the end of a file. :^) 2019-05-18 21:54:31 +02:00
Andreas Kling
7900da9667 Kernel: Make sure we never put the colonel thread in the runnable list.
This would cause it to get scheduled unnecessarily.
2019-05-18 20:28:04 +02:00
Andreas Kling
64a4f3df69 Kernel: Add a Thread::set_thread_list() helper to keep logic in one place. 2019-05-18 20:28:04 +02:00
Andreas Kling
8c7d5abdc4 Kernel: Refactor thread scheduling a bit, breaking it into multiple lists.
There are now two thread lists, one for runnable threads and one for non-
runnable threads. Thread::set_state() is responsible for moving threads
between the lists.

Each thread also has a back-pointer to the list it's currently in.
2019-05-18 20:28:04 +02:00
Robin Burchell
99dd60611f Kernel: Fix select with a 0 timeout
select essentially has 3 modes (which is presumably why we're finding it
so hard to get this right in a reliable way :)).

1. NULL timeout -- no timeout on blocking
2. non-NULL timeout that is not zero'd -- timeout on blocking
3. non-NULL but zero timeout -- no blocking at all (immediate poll)

For cases 1 and 2, we want to block the thread. We have a timeout set
only for case 2, though.

Case 3 should not block the thread, and does not have a timeout set.
2019-05-18 19:01:08 +02:00
Andreas Kling
d2c3749cf3 Kernel: Don't allow dump_backtrace() to call dump_backtrace().
That was not a very graceful looking loop to be stuck in.
2019-05-18 17:33:05 +02:00
Robin Burchell
ec0d598934 WSWindowManager: Add double click to maximize/restore 2019-05-18 15:54:10 +02:00
Andreas Kling
316fb624f7 Kernel: Fail a bit more gracefully when we don't have userspace symbols. 2019-05-18 14:49:49 +02:00
Andreas Kling
a4e48dce77 Kernel: SharedMemory should implement mmap(). 2019-05-18 04:17:53 +02:00
Andreas Kling
237628a7a6 Kernel: Tidy up FileDescriptor members a bit. 2019-05-18 04:14:22 +02:00
Robin Burchell
123283d840 Kernel: Fix poll() with timeout 2019-05-18 04:03:28 +02:00
Andreas Kling
b33cc7f772 Kernel: Remove some RangeAllocator debug spam. 2019-05-18 03:59:16 +02:00
Andreas Kling
cdaf8cd656 Kernel: select() was transferring the readfds into the exceptfds vector.
Just a mistake I spotted while reading the code. We don't actually detect
exceptional descriptor events yet.
2019-05-18 03:09:37 +02:00
Andreas Kling
14c896ec58 Kernel: Pass ELF program header locations from multiboot to kernel.
Patch contributed by "pd"
2019-05-18 03:08:29 +02:00
Robin Burchell
ba92c07a75 Kernel: Make sure to clear FD sets when preparing for a select
NULL sets can happen, and we don't want to incorrectly return FDs which
aren't in the set too.
2019-05-18 02:57:38 +02:00
Robin Burchell
95893b0d53 Toolchain: Add some required options to the default CMake options. 2019-05-18 02:57:38 +02:00
Robin Burchell
df74a9222f Kernel: Fix timeout support in select
The scheduler expects m_select_timeout to act as a deadline. That is, it
should contain the time that a task should wake at -- but we were
directly copying the time from userspace, which meant that it always
returned virtually immediately.

At the same time, fix CEventLoop to not rely on the broken select behavior
by subtracting the current time from the time of the nearest timer.
2019-05-18 02:57:38 +02:00
Andreas Kling
8f3022b5c1 NetworkTask: Don't crash on startup if there's no E1000 NIC present. 2019-05-18 00:22:08 +02:00