Compare commits

..

34 Commits

Author SHA1 Message Date
ecfd20dba6
wind: Spawn a new client process after startup
All checks were successful
continuous-integration/drone/pr Build is passing
Also, create the socket after dropping privileges.
2023-08-07 22:54:07 +02:00
e748137209
apps: Add gclient 2023-08-07 22:54:06 +02:00
80390a3ecc
libos: Add os::LocalClient 2023-08-07 22:54:06 +02:00
34dcf7f75f
libui: Change 'into' to 'onto' 2023-08-07 22:54:05 +02:00
028e1f7ffb
libui: Document ui::Font 2023-08-07 22:54:05 +02:00
7a095d7a67
libui+wind: Move some static variables inside functions 2023-08-07 22:54:05 +02:00
23b0fa3451
wind: Generate random windows on keypresses 2023-08-07 22:54:04 +02:00
e9a27ef29a
wind: Make sure windows have a minimum size to fit the titlebar 2023-08-07 22:54:04 +02:00
8cc9d41f27
libui: Properly cut off the last drawn character if necessary 2023-08-07 22:54:03 +02:00
bccc1f062f
libui: Add Rect::contains(Rect) 2023-08-07 22:54:03 +02:00
1d0093b451
libui: Render font characters properly with no spacing, matching the width calculations 2023-08-07 22:54:03 +02:00
db50eb74a4
wind: Render an actual TGA mouse cursor 2023-08-07 22:54:02 +02:00
e8a445fc98
wind: Add a close button to windows using a TGA icon 2023-08-07 22:54:02 +02:00
481c757dac
libui: Add support for TGA image loading 2023-08-07 22:54:01 +02:00
7eaa076910
libui: Add an interface to fill a Canvas with an array of pixels 2023-08-07 22:54:01 +02:00
71754ea7fe
wind: Add window titlebars using ui::Font 2023-08-07 22:54:01 +02:00
70494733ee
libui: Add PSF font loading and rendering 2023-08-07 22:54:00 +02:00
dc0e0126fc
libui: Add Color::GRAY 2023-08-07 22:54:00 +02:00
91752f3c9d
libui: Rename Rect::absolute to normalized and add a new absolute function 2023-08-07 22:53:59 +02:00
4cb1709ae2
libluna: Add assignment operators to Buffer 2023-08-07 22:53:59 +02:00
06b792109a
wind: Reorder drag sequence 2023-08-07 22:53:58 +02:00
3da0a00b76
libui: Add Rect::relative 2023-08-07 22:53:58 +02:00
d0c5d5a565
libui: Remove redundant statement 2023-08-07 22:53:57 +02:00
cbd5b3a200
libui: Add getters for separate color values 2023-08-07 22:53:57 +02:00
e77418f259
libui: Remove unnecessary stuff 2023-08-07 22:53:56 +02:00
4c72015817
base: Remove startup items not necessary for GUI startup 2023-08-07 22:53:56 +02:00
9b8cc476e1
libui+wind: (Draggable) windows 2023-08-07 22:53:55 +02:00
1828a647fa
wind: Create a local server object 2023-08-07 22:53:55 +02:00
778b85417c
libos: Add a new LocalServer class for local domain sockets 2023-08-07 22:53:54 +02:00
e4ba7e121f
kernel: Support listening sockets in poll() 2023-08-07 22:53:54 +02:00
5e3647b7db
base: Start wind on startup instead of the shell 2023-08-07 22:53:53 +02:00
90c849a38c
wind: Add a simple display server skeleton using libui
No client functionality yet, but it's a start.
2023-08-07 22:53:53 +02:00
b4d02da12d
libui: Add a GUI and graphics library 2023-08-07 22:53:52 +02:00
82b058a2d3
kernel: Fix negative movement in the PS/2 mouse driver 2023-08-07 22:53:52 +02:00
9 changed files with 45 additions and 64 deletions

View File

@ -33,40 +33,38 @@ void reap_thread()
[[noreturn]] void init()
{
{
kinfoln("Starting Moon %s %s", MOON_VERSION, MOON_RELEASE);
kinfoln("Starting Moon %s %s", MOON_VERSION, MOON_RELEASE);
// Default hostname if nobody from userspace changes it
set_host_name("moon"_sv);
// Default hostname if nobody from userspace changes it
set_host_name("moon"_sv);
kinfoln("Current platform: %s", CPU::platform_string().chars());
kinfoln("Current processor: %s", CPU::identify().value_or("(unknown)"_sv).chars());
kinfoln("Current platform: %s", CPU::platform_string().chars());
kinfoln("Current processor: %s", CPU::identify().value_or("(unknown)"_sv).chars());
auto root = mark_critical(TmpFS::FileSystem::create(), "Failed to create initial ramfs");
mark_critical(VFS::mount_root(root), "Failed to mount the initial ramfs as the root filesystem");
mark_critical(InitRD::populate_vfs(), "Failed to load files from the initial ramdisk");
mark_critical(DeviceRegistry::init(), "Failed to register initial devices");
auto root = mark_critical(TmpFS::FileSystem::create(), "Failed to create initial ramfs");
mark_critical(VFS::mount_root(root), "Failed to mount the initial ramfs as the root filesystem");
mark_critical(InitRD::populate_vfs(), "Failed to load files from the initial ramdisk");
mark_critical(DeviceRegistry::init(), "Failed to register initial devices");
mark_critical(BinaryFormat::init(), "Failed to register initial binary formats");
mark_critical(BinaryFormat::init(), "Failed to register initial binary formats");
auto init =
mark_critical(VFS::resolve_path("/bin/preinit", Credentials {}), "Can't find init in the initial ramfs!");
auto init_thread = mark_critical(Scheduler::new_userspace_thread(init, "/bin/preinit"),
"Failed to create PID 1 process for init");
auto init =
mark_critical(VFS::resolve_path("/bin/preinit", Credentials {}), "Can't find init in the initial ramfs!");
auto init_thread =
mark_critical(Scheduler::new_userspace_thread(init, "/bin/preinit"), "Failed to create PID 1 process for init");
auto reap = mark_critical(Scheduler::new_kernel_thread(reap_thread, "[reap]"),
"Failed to create the process reaper kernel thread");
Scheduler::set_reap_thread(reap);
auto reap = mark_critical(Scheduler::new_kernel_thread(reap_thread, "[reap]"),
"Failed to create the process reaper kernel thread");
Scheduler::set_reap_thread(reap);
#ifdef ARCH_X86_64
ATA::Controller::scan();
ATA::Controller::scan();
#endif
// Disable console logging before transferring control to userspace.
setup_log(log_debug_enabled(), log_serial_enabled(), false);
// Disable console logging before transferring control to userspace.
setup_log(log_debug_enabled(), log_serial_enabled(), false);
init_thread->wake_up();
}
init_thread->wake_up();
kernel_exit();
}

View File

@ -508,7 +508,7 @@ namespace MemoryManager
{
TRY(result.try_append(*(char*)address));
address++;
if ((address % ARCH_PAGE_SIZE) == 0)
if (address % ARCH_PAGE_SIZE)
{
if (!validate_page_access(address, MMU::User)) return err(EFAULT);
}

View File

@ -143,12 +143,9 @@ Result<void> UnixSocket::connect(Registers* regs, int flags, struct sockaddr* ad
m_blocked_thread = nullptr;
if (current->interrupted)
{
if (current->will_ignore_pending_signal())
{
current->process_pending_signals(regs);
continue;
}
return err(EINTR);
if (current->will_invoke_signal_handler()) return err(EINTR);
current->process_pending_signals(regs);
continue;
}
break;
}
@ -185,12 +182,9 @@ Result<SharedPtr<OpenFileDescription>> UnixSocket::accept(Registers* regs, int f
m_blocked_thread = nullptr;
if (current->interrupted)
{
if (current->will_ignore_pending_signal())
{
current->process_pending_signals(regs);
continue;
}
return err(EINTR);
if (current->will_invoke_signal_handler()) return err(EINTR);
current->process_pending_signals(regs);
continue;
}
}

View File

@ -35,12 +35,8 @@ Result<u64> sys_read(Registers* regs, SyscallArgs args)
if (current->interrupted)
{
kdbgln("signal: read interrupted by signal");
if (current->will_ignore_pending_signal())
{
current->process_pending_signals(regs);
continue;
}
return err(EINTR);
if (current->will_invoke_signal_handler()) return err(EINTR);
current->process_pending_signals(regs);
}
}

View File

@ -6,7 +6,7 @@
#include "thread/Scheduler.h"
#include <bits/poll.h>
Result<u64> sys_poll(Registers*, SyscallArgs args)
Result<u64> sys_poll(Registers* regs, SyscallArgs args)
{
struct pollfd* fds = (struct pollfd*)args[0];
nfds_t nfds = (nfds_t)args[1];
@ -74,6 +74,8 @@ Result<u64> sys_poll(Registers*, SyscallArgs args)
{
guard.deactivate();
free_impl(kfds);
if (current->will_invoke_signal_handler()) return err(EINTR);
current->process_pending_signals(regs);
return err(EINTR);
}
continue;

View File

@ -27,12 +27,9 @@ Result<u64> sys_waitpid(Registers* regs, SyscallArgs args)
if (current->interrupted)
{
kdbgln("signal: waitpid interrupted by signal");
if (current->will_ignore_pending_signal())
{
current->process_pending_signals(regs);
goto wait_for_child;
}
return err(EINTR);
if (current->will_invoke_signal_handler()) return err(EINTR);
current->process_pending_signals(regs);
goto wait_for_child;
}
check(thread->state == ThreadState::Exited);
@ -51,12 +48,9 @@ Result<u64> sys_waitpid(Registers* regs, SyscallArgs args)
if (current->interrupted)
{
kdbgln("signal: waitpid interrupted by signal");
if (current->will_ignore_pending_signal())
{
current->process_pending_signals(regs);
goto wait_for_any_child;
}
return err(EINTR);
if (current->will_invoke_signal_handler()) return err(EINTR);
current->process_pending_signals(regs);
goto wait_for_any_child;
}
check(current->child_being_waited_for.value_or(-1) != -1);

View File

@ -186,19 +186,18 @@ void Thread::process_pending_signals(Registers* current_regs)
}
}
bool Thread::will_ignore_pending_signal()
bool Thread::will_invoke_signal_handler()
{
for (int i = 0; i < NSIG; i++)
{
if (pending_signals & (1 << i))
{
int signo = i + 1;
if (signo == SIGKILL || signo == SIGSTOP) return false;
if (signal_mask & (1 << i)) continue;
if (signo != SIGKILL && signo != SIGSTOP && signal_mask & (1 << i)) continue;
auto handler = signal_handlers[i];
if (handler.sa_handler == SIG_IGN) return true;
if (handler.sa_handler == SIG_DFL && default_actions[i] == DefaultSignalAction::Ignore) return true;
return false;
if (handler.sa_handler == SIG_IGN || handler.sa_handler == SIG_DFL) return false;
if (signo == SIGKILL || signo == SIGSTOP) return false;
return true;
}
}
return false;

View File

@ -159,7 +159,7 @@ struct Thread : public LinkedListNode<Thread>
void process_pending_signals(Registers* current_regs);
bool will_ignore_pending_signal();
bool will_invoke_signal_handler();
bool deliver_signal(int signo, Registers* current_regs);
void sigreturn(Registers* current_regs);

View File

@ -135,8 +135,6 @@ static ssize_t read_data_into_buffer(FILE* stream)
stream->_buf.index = 0;
ssize_t nread = read(stream->_fd, stream->_buf.buffer, stream->_buf.capacity);
if (nread >= 0) stream->_buf.size = nread;
else
stream->_buf.size = 0;
stream->_buf.status |= FileStatusFlags::LastRead;
return nread;
}