Compare commits

..

58 Commits

Author SHA1 Message Date
945d838166
libui: Add Buttons
Some checks failed
continuous-integration/drone/pr Build is failing
2023-08-15 15:33:44 +02:00
742fb4d8a6
libui: Handle other mouse events 2023-08-15 15:10:13 +02:00
e115274cc4
libui: Add aligned items using Containers, ImageWidget 2023-08-15 14:42:21 +02:00
f71cb4ee09
libui: Add VerticalLayout 2023-08-15 13:01:41 +02:00
4c7828f0eb
wind+libui+taskbar: Add GetScreenRect IPC, non-decorated windows, taskbar 2023-08-15 12:56:55 +02:00
d78d76ad16
libui: Actually fill window backgrounds with the correct color 2023-08-15 12:30:53 +02:00
d0c4264608
libui: Add basic widget and layout system =D 2023-08-15 12:28:47 +02:00
0a39628bb1
ui+wind: Send mouse move events through IPC 2023-08-15 11:31:01 +02:00
02c72e15d5
wind+libui: Add protocol for window close requests 2023-08-15 11:20:17 +02:00
c99c2e4fe3
libos+libui+wind: Use uppercase for static struct IDs to avoid confusion with fields 2023-08-15 10:28:11 +02:00
57761df341
libui+gclient: Add basic OOP wrappers around the IPC protocol 2023-08-15 10:23:37 +02:00
60f9c0e5a3
wind+gclient: Add SetWindowTitle and support shm buffers
Some checks failed
continuous-integration/drone/pr Build is failing
2023-08-14 20:08:05 +02:00
397ed396d8
gclient: Create two example windows
Some checks failed
continuous-integration/drone/pr Build is failing
2023-08-14 18:15:38 +02:00
4bcea9b141
wind: Handle CreateWindow IPC messages 2023-08-14 18:15:29 +02:00
ac5dd05d2e
libui: Add CreateWindow IPC message definitions 2023-08-14 18:15:10 +02:00
a2fd838f5d
libos: Add basic IPC message framework 2023-08-14 18:14:35 +02:00
56269f5187
kernel: Fix poll syscall 2023-08-14 18:14:16 +02:00
2c2c6fbc2d
wind: Monitor data on client connections 2023-08-14 13:24:26 +02:00
753a56d14c
kernel: Add POLLHUP and store it when a polled socket's peer disconnects 2023-08-14 13:22:41 +02:00
b614fa04de
libui: Add copyright/author text 2023-08-14 12:34:27 +02:00
561d737f6c
libos: Add copyright/author comments to LocalServer and LocalClient 2023-08-14 12:31:09 +02:00
c0ca99bc7c
wind: Use init --user and pledge()
Some checks failed
continuous-integration/drone/pr Build is failing
2023-08-14 11:08:52 +02:00
e3c210b437
Update .gitignore 2023-08-14 11:08:51 +02:00
0f46868cce
libos: Remove some shared pointers and change them to owned/live on the stack 2023-08-14 11:08:51 +02:00
b53df986ca
wind: Spawn a new client process after startup
Also, create the socket after dropping privileges.
2023-08-14 11:08:51 +02:00
b2c5598ebd
apps: Add gclient 2023-08-14 11:08:51 +02:00
9722e9def8
libos: Add os::LocalClient 2023-08-14 11:08:51 +02:00
4382c3686b
libui: Change 'into' to 'onto' 2023-08-14 11:08:50 +02:00
ebd44b72ec
libui: Document ui::Font 2023-08-14 11:08:50 +02:00
c49b8e48f4
libui+wind: Move some static variables inside functions 2023-08-14 11:08:50 +02:00
853d0421a0
wind: Generate random windows on keypresses 2023-08-14 11:08:50 +02:00
2ed9e1aa93
wind: Make sure windows have a minimum size to fit the titlebar 2023-08-14 11:08:50 +02:00
16f058f4df
libui: Properly cut off the last drawn character if necessary 2023-08-14 11:08:49 +02:00
3509c93ef4
libui: Add Rect::contains(Rect) 2023-08-14 11:08:49 +02:00
742f5810c2
libui: Render font characters properly with no spacing, matching the width calculations 2023-08-14 11:08:49 +02:00
02ecdd65eb
wind: Render an actual TGA mouse cursor 2023-08-14 11:08:49 +02:00
8d97a83acf
wind: Add a close button to windows using a TGA icon 2023-08-14 11:08:48 +02:00
61636792cd
libui: Add support for TGA image loading 2023-08-14 11:08:48 +02:00
81a2d0a039
libui: Add an interface to fill a Canvas with an array of pixels 2023-08-14 11:08:48 +02:00
2533d39bd4
wind: Add window titlebars using ui::Font 2023-08-14 11:08:48 +02:00
f371db3049
libui: Add PSF font loading and rendering 2023-08-14 11:08:48 +02:00
1492c5be96
libui: Add Color::GRAY 2023-08-14 11:08:48 +02:00
85c045e16b
libui: Rename Rect::absolute to normalized and add a new absolute function 2023-08-14 11:08:47 +02:00
c8232b97d7
libluna: Add assignment operators to Buffer 2023-08-14 11:08:47 +02:00
7ed2bc83fe
wind: Reorder drag sequence 2023-08-14 11:08:47 +02:00
07e27d4d9c
libui: Add Rect::relative 2023-08-14 11:08:47 +02:00
e108d613cd
libui: Remove redundant statement 2023-08-14 11:08:47 +02:00
a8266f72cb
libui: Add getters for separate color values 2023-08-14 11:08:47 +02:00
2ea609df93
libui: Remove unnecessary stuff 2023-08-14 11:08:46 +02:00
25d0a4ad4c
base: Remove startup items not necessary for GUI startup 2023-08-14 11:08:46 +02:00
2f28ecd027
libui+wind: (Draggable) windows 2023-08-14 11:08:46 +02:00
fb5fdfc290
wind: Create a local server object 2023-08-14 11:08:46 +02:00
069525ecff
libos: Add a new LocalServer class for local domain sockets 2023-08-14 11:08:45 +02:00
c49ac8391e
kernel: Support listening sockets in poll() 2023-08-14 11:08:45 +02:00
e30acc855a
base: Start wind on startup instead of the shell 2023-08-14 11:08:45 +02:00
eba68703b2
wind: Add a simple display server skeleton using libui
No client functionality yet, but it's a start.
2023-08-14 11:08:45 +02:00
c219dc926a
libui: Add a GUI and graphics library 2023-08-14 11:08:45 +02:00
a1fcb87086
kernel: Fix negative movement in the PS/2 mouse driver 2023-08-14 11:08:44 +02:00
16 changed files with 32 additions and 199 deletions

View File

@ -6,7 +6,6 @@
#include "fs/MBR.h" #include "fs/MBR.h"
#include "memory/MemoryManager.h" #include "memory/MemoryManager.h"
#include <luna/Alignment.h> #include <luna/Alignment.h>
#include <luna/Buffer.h>
#include <luna/CType.h> #include <luna/CType.h>
#include <luna/SafeArithmetic.h> #include <luna/SafeArithmetic.h>
#include <luna/Vector.h> #include <luna/Vector.h>
@ -759,7 +758,9 @@ Result<u64> ATADevice::read(u8* buf, usize offset, usize size) const
ScopedKMutexLock<100> lock(m_drive->channel()->lock()); ScopedKMutexLock<100> lock(m_drive->channel()->lock());
Buffer temp; // FIXME: Don't always allocate this if we don't need it.
auto* temp = (u8*)TRY(malloc_impl(block_size));
auto guard = make_scope_guard([temp] { free_impl(temp); });
if (offset % block_size) if (offset % block_size)
{ {
@ -768,10 +769,8 @@ Result<u64> ATADevice::read(u8* buf, usize offset, usize size) const
// Maybe we don't even want enough to get to the next block? // Maybe we don't even want enough to get to the next block?
if (extra_size > size) extra_size = size; if (extra_size > size) extra_size = size;
TRY(temp.try_resize(block_size)); TRY(m_drive->read_lba(offset / block_size, temp, 1));
memcpy(buf, temp + (offset % block_size), extra_size);
TRY(m_drive->read_lba(offset / block_size, temp.data(), 1));
memcpy(buf, temp.data() + (offset % block_size), extra_size);
offset += extra_size; offset += extra_size;
size -= extra_size; size -= extra_size;
buf += extra_size; buf += extra_size;
@ -795,9 +794,8 @@ Result<u64> ATADevice::read(u8* buf, usize offset, usize size) const
if (size) if (size)
{ {
TRY(temp.try_resize(block_size)); TRY(m_drive->read_lba(offset / block_size, temp, 1));
TRY(m_drive->read_lba(offset / block_size, temp.data(), 1)); memcpy(buf, temp, size);
memcpy(buf, temp.data(), size);
} }
return length; return length;

View File

@ -66,9 +66,6 @@ namespace GPT
{ {
header.checksum = 0; header.checksum = 0;
CRC32 crc; return CRC32::checksum((u8*)&header, 0x5c);
crc.append((u8*)&header, 0x5c);
return crc.digest();
} }
} }

View File

@ -44,11 +44,7 @@ Result<usize> Pipe::read(u8* buf, usize, usize length)
Result<usize> Pipe::write(const u8* buf, usize, usize length) Result<usize> Pipe::write(const u8* buf, usize, usize length)
{ {
if (!m_reader) if (!m_reader) return length;
{
Scheduler::current()->send_signal(SIGPIPE);
return err(EPIPE);
}
u8* slice = TRY(m_data_buffer.slice_at_end(length)); u8* slice = TRY(m_data_buffer.slice_at_end(length));
memcpy(slice, buf, length); memcpy(slice, buf, length);

View File

@ -63,7 +63,7 @@ namespace Ext2
#ifdef EXT2_DEBUG #ifdef EXT2_DEBUG
kdbgln("ext2: Read inode %lu with mode %#x (%#x + %#o), size %lu", inum, inode->m_raw_inode.mode, kdbgln("ext2: Read inode %lu with mode %#x (%#x + %#o), size %lu", inum, inode->m_raw_inode.mode,
inode->m_raw_inode.mode & 0xf000, inode->metadata().mode, inode->metadata().size); inode->m_raw_inode.mode & 0xf000, inode->mode(), inode->size());
#endif #endif
m_inode_cache.try_set(inum, inode); m_inode_cache.try_set(inum, inode);

View File

@ -91,18 +91,19 @@ namespace Ext2
const usize inode_size = m_metadata.size; const usize inode_size = m_metadata.size;
const usize block_size = m_fs->m_block_size; const usize block_size = m_fs->m_block_size;
auto buf = TRY(Buffer::create_sized(block_size)); u8* const buf = (u8*)TRY(calloc_impl(block_size, 1));
auto guard = make_scope_guard([buf] { free_impl(buf); });
m_entries.clear(); m_entries.clear();
for (usize offset = 0; offset < inode_size; offset += block_size) for (usize offset = 0; offset < inode_size; offset += block_size)
{ {
TRY(read(buf.data(), offset, block_size)); TRY(read(buf, offset, block_size));
usize dir_offset = 0; usize dir_offset = 0;
while (dir_offset < block_size) while (dir_offset < block_size)
{ {
auto& entry = *(Ext2::RawDirectoryEntry*)&buf.data()[dir_offset]; auto& entry = *(Ext2::RawDirectoryEntry*)&buf[dir_offset];
if (entry.inum != 0) if (entry.inum != 0)
{ {

View File

@ -182,7 +182,7 @@ Result<u64> sys_fork(Registers* regs, SyscallArgs)
Scheduler::add_thread(thread); Scheduler::add_thread(thread);
#ifdef FORK_DEBUG #ifdef FORK_DEBUG
kdbgln("fork: thread %d forked into child %d", current->id, thread->id); kdbgln("fork: thread %lu forked into child %lu", current->id, thread->id);
#endif #endif
return thread->id; return thread->id;

View File

@ -183,7 +183,7 @@ namespace Scheduler
CPU::disable_interrupts(); CPU::disable_interrupts();
#ifdef REAP_DEBUG #ifdef REAP_DEBUG
kdbgln("reap: reaping thread with id %d", thread->id); kdbgln("reap: reaping thread with id %zu", thread->id);
#endif #endif
if (thread->is_kernel) if (thread->is_kernel)

View File

@ -27,7 +27,6 @@ typedef struct
int mode; // The buffering mode. int mode; // The buffering mode.
} _buf; } _buf;
int _flags; // The file access mode with which the file was opened. int _flags; // The file access mode with which the file was opened.
pid_t _pid; // For popen(3) files, the pid of the child process.
} FILE; } FILE;
#define EOF -1 #define EOF -1
@ -53,7 +52,6 @@ extern "C"
{ {
#endif #endif
/* Flush a stream's buffers. */
int fflush(FILE*); int fflush(FILE*);
/* Open a file and bind a stream to it. */ /* Open a file and bind a stream to it. */
@ -203,9 +201,6 @@ extern "C"
/* Move a file's location across a file system. */ /* Move a file's location across a file system. */
int rename(const char* oldpath, const char* newpath); int rename(const char* oldpath, const char* newpath);
/* Pipe a stream to or from a process. */
FILE* popen(const char* command, const char* type);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -6,7 +6,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/syscall.h> #include <sys/syscall.h>
#include <sys/wait.h>
#include <unistd.h> #include <unistd.h>
FILE* stdin = nullptr; FILE* stdin = nullptr;
@ -762,87 +761,4 @@ extern "C"
unlink(oldpath); unlink(oldpath);
return 0; return 0;
} }
FILE* popen(const char* command, const char* type)
{
int pfds[2];
if (pipe(pfds) < 0) return nullptr;
if (*type != 'r' && *type != 'w')
{
errno = EINVAL;
return nullptr;
}
pid_t child = fork();
if (child < 0)
{
close(pfds[0]);
close(pfds[1]);
return nullptr;
}
if (child == 0)
{
if (*type == 'r')
{
close(pfds[0]);
dup2(pfds[1], STDOUT_FILENO);
}
else
{
close(pfds[1]);
dup2(pfds[0], STDIN_FILENO);
}
execl("/bin/sh", "sh", "-c", command, nullptr);
_exit(127);
}
int fd;
if (*type == 'r')
{
close(pfds[1]);
fd = pfds[0];
}
else
{
close(pfds[0]);
fd = pfds[1];
}
int err = errno;
FILE* f = (FILE*)malloc(sizeof(FILE));
if (!f)
{
errno = err;
close(fd);
return nullptr;
}
f->_fd = fd;
f->_pid = child;
clearerr(f);
f->_flags = *type == 'r' ? O_RDONLY : O_WRONLY;
f->_buf.status = 0;
f->_buf.mode = _IOFBF;
f->_buf.size = f->_buf.index = 0;
f->_buf.buffer = nullptr;
setvbuf(f, NULL, f->_buf.mode, 0);
s_open_files[fd] = f;
return f;
}
int pclose(FILE* stream)
{
pid_t pid = stream->_pid;
fclose(stream);
int status;
if (waitpid(pid, &status, 0) < 0) return -1;
return status;
}
} }

View File

@ -1,13 +1,7 @@
#pragma once #pragma once
#include <luna/Types.h> #include <luna/Types.h>
class CRC32 namespace CRC32
{ {
public: u32 checksum(const u8* data, usize size);
void append(const u8* data, usize size); }
u32 digest();
private:
u32 m_checksum = 0xffffffffu;
};

View File

@ -33,16 +33,18 @@ static const u32 crc_table[] = {
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
}; };
void CRC32::append(const u8* data, usize size) namespace CRC32
{ {
for (usize i = 0; i < size; i++) u32 checksum(const u8* data, usize size)
{ {
const u32 index = (m_checksum & 0xff) ^ data[i]; u32 crc = 0xffffffffu;
m_checksum = (m_checksum >> 8) ^ (crc_table[index]);
for (usize i = 0; i < size; i++)
{
const u32 index = (crc & 0xff) ^ data[i];
crc = (crc >> 8) ^ (crc_table[index]);
}
return ~crc;
} }
} }
u32 CRC32::digest()
{
return ~m_checksum;
}

View File

@ -5,7 +5,7 @@ export LUNA_BASE=${LUNA_BASE:-$LUNA_ROOT/base}
[ -f "$LUNA_ROOT/env-local.sh" ] && source $LUNA_ROOT/env-local.sh [ -f "$LUNA_ROOT/env-local.sh" ] && source $LUNA_ROOT/env-local.sh
export LUNA_ARCH=${LUNA_ARCH:-x86_64} export LUNA_ARCH=${LUNA_ARCH:-x86_64}
export PATH=$LUNA_ROOT/toolchain/$LUNA_ARCH-luna/bin:$LUNA_ROOT/toolchain/dist:$LUNA_ROOT/toolchain/bin:$LUNA_ROOT/tools/exec/:$PATH export PATH=$LUNA_ROOT/toolchain/$LUNA_ARCH-luna/bin:$LUNA_ROOT/toolchain/dist:$LUNA_ROOT/tools/exec/:$PATH
if [ "$USE_MAKE" = "1" ] if [ "$USE_MAKE" = "1" ]
then then

View File

@ -1,40 +0,0 @@
#!/usr/bin/env bash
set -e
source $(dirname $0)/setup-env.sh
cd $LUNA_ROOT
# libstdc++ needs autoconf (precisely version 2.69) so if the user has an older/more recent version, we must build autoconf from source.
export AUTOCONF_VERSION=2.69
mkdir -p toolchain/tarballs
mkdir -p toolchain/build
if [ ! -f toolchain/tarballs/autoconf-$AUTOCONF_VERSION.tar.gz ]; then
echo "Downloading autoconf (precisely version 2.69)..."
wget -Otoolchain/tarballs/autoconf-$AUTOCONF_VERSION.tar.gz https://ftp.gnu.org/gnu/autoconf/autoconf-$AUTOCONF_VERSION.tar.gz
fi
rm -rf toolchain/build/build-autoconf
rm -rf toolchain/build/autoconf-$AUTOCONF_VERSION
echo "Extracting autoconf (precisely version 2.69)..."
tar xf toolchain/tarballs/autoconf-$AUTOCONF_VERSION.tar.gz -C toolchain/build/
mkdir -p toolchain/build/build-autoconf
cd toolchain/build/build-autoconf
unset CC
unset CXX
unset LD
unset AR
echo "Building autoconf (precisely version 2.69)..."
../autoconf-$AUTOCONF_VERSION/configure --prefix=$LUNA_ROOT/toolchain
make
make install

View File

@ -36,10 +36,6 @@ patch -u -i $LUNA_ROOT/tools/gcc.patch -p 1 -d build
cd - cd -
cd toolchain/build/gcc-$LUNA_GCC_VERSION_REQUIRED/libstdc++-v3
autoconf
cd -
echo Configuring GCC... echo Configuring GCC...
mkdir -p toolchain/build/gcc-$LUNA_ARCH mkdir -p toolchain/build/gcc-$LUNA_ARCH

View File

@ -9,12 +9,6 @@ fi
if ! $(dirname $0)/test-gcc.sh if ! $(dirname $0)/test-gcc.sh
then then
if ! $(dirname $0)/test-autoconf.sh
then
echo Building autoconf...
$(dirname $0)/setup-autoconf.sh
fi
echo Building GCC.. echo Building GCC..
$(dirname $0)/setup-gcc.sh $(dirname $0)/setup-gcc.sh
fi fi

View File

@ -1,16 +0,0 @@
#!/usr/bin/env bash
set -e
source $(dirname $0)/setup-env.sh
if [ -x "$(command -v autoconf)" ]
then
if [ "$(autoconf --version | head -n 1 | awk '{ print $4 }')" == "2.69" ]
then
exit 0
else
echo "You have autoconf installed, but it is not version 2.69, which is required by libstdc++. Thus, we must build autoconf from source."
exit 1
fi
else
exit 1
fi