Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalmiel committed Dec 4, 2023
1 parent de72576 commit 1f2de19
Show file tree
Hide file tree
Showing 40 changed files with 58 additions and 67 deletions.
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,17 @@ $(iso): $(kernel) $(grub_cfg) $(rust_shell)

$(disk): $(kernel) $(rust_shell) $(rust_init) $(cross_cpp)
#echo fake install_os
sudo disk_scripts/install_os.sh
sudo disk-scripts/install_os.sh

$(vdi): $(disk)
disk_scripts/make_vdi.sh
disk_scripts/attach_vdi.sh
disk-scripts/make_vdi.sh
disk-scripts/attach_vdi.sh

$(kernel): cargo $(rust_os) $(assembly_object_files) $(linker_script)
ld -n --whole-archive --gc-sections -T $(linker_script) -o $(kernel) $(assembly_object_files) $(rust_os)

usb: $(kernel)
sudo disk_scripts/install_usb.sh $(usb_dev)
sudo disk-scripts/install_usb.sh $(usb_dev)

cargo:
ifdef dev
Expand All @@ -102,7 +102,7 @@ toolchain: $(cross_cpp)
sysroot/build.sh check_build

fsck:
sudo disk_scripts/fsck_disk.sh
sudo disk-scripts/fsck_disk.sh

$(cross_cpp): toolchain

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ https://github.com/rafalmiel/cykusz-rs/assets/3881998/afa514a1-f435-4eeb-8c80-20

## Userspace

- [x] Basic shell
- [x] Bash shell
- [x] libc (mlibc port)
- [x] Exec/fork
- [x] Threads
Expand Down Expand Up @@ -92,7 +92,7 @@ rustup override set nightly
rustup component add rust-src
make

./create_disk.sh
./disk-scripts/create_disk.sh
```

## Building Userspace
Expand Down
1 change: 0 additions & 1 deletion cleanup.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/bin/bash

cargo fix -p cykusz-rs -p user-alloc -p syscall-user -p syscall-defs --lib --allow-dirty --allow-staged
cargo fmt
7 changes: 0 additions & 7 deletions create_disk.sh

This file was deleted.

2 changes: 1 addition & 1 deletion create_vbox_vm.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

VBoxManage import cykusz.ova
VBoxManage import sysroot/cfg/cykusz.ova
6 changes: 3 additions & 3 deletions cykusz-rs/src/drivers/ps2/kbd/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ use crate::kernel::device::Device;
use crate::kernel::fs::inode::INode;
use crate::kernel::fs::poll::PollTable;
use crate::kernel::fs::vfs::FsError;
use crate::kernel::timer::current_ns;
use crate::kernel::utils::wait_queue::WaitQueueFlags;
use syscall_defs::events::{Event, EventType};
use syscall_defs::poll::PollEventFlags;
use syscall_defs::OpenFlags;
use syscall_defs::time::Timeval;
use crate::kernel::timer::current_ns;
use crate::kernel::utils::wait_queue::WaitQueueFlags;
use syscall_defs::OpenFlags;

use super::scancode;

Expand Down
14 changes: 7 additions & 7 deletions cykusz-rs/src/drivers/ps2/mouse/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ use crate::kernel::fs::vfs::FsError;
use crate::kernel::sync::Spin;
use crate::kernel::timer::current_ns;
use crate::kernel::utils::buffer::BufferQueue;
use crate::kernel::utils::wait_queue::WaitQueueFlags;
use alloc::string::String;
use alloc::sync::{Arc, Weak};
use bit_field::BitField;
use spin::Once;
use syscall_defs::events::{Event, EventType};
use syscall_defs::events::buttons::{ButtonCode, RelCode};
use syscall_defs::events::{Event, EventType};
use syscall_defs::poll::PollEventFlags;
use syscall_defs::OpenFlags;
use syscall_defs::time::Timeval;
use crate::kernel::utils::wait_queue::WaitQueueFlags;
use syscall_defs::OpenFlags;

struct MouseState {
state: Spin<State>,
Expand Down Expand Up @@ -60,7 +60,7 @@ impl<'a> StateIter<'a> {
0 => Some(ButtonCode::BTN_LEFT),
1 => Some(ButtonCode::BTN_RIGHT),
2 => Some(ButtonCode::BTN_MIDDLE),
_ => None
_ => None,
}
}

Expand Down Expand Up @@ -90,7 +90,7 @@ impl<'a> Iterator for StateIter<'a> {
typ: EventType::Key,
code: btn_code as u16,
val: if self.state.btn_state[idx] { 1 } else { 0 },
})
});
}
}

Expand All @@ -103,7 +103,7 @@ impl<'a> Iterator for StateIter<'a> {
typ: EventType::Rel,
code: RelCode::REL_X as u16,
val: rel_x,
})
});
}
}

Expand All @@ -116,7 +116,7 @@ impl<'a> Iterator for StateIter<'a> {
typ: EventType::Rel,
code: RelCode::REL_Y as u16,
val: rel_y,
})
});
}
}

Expand Down
9 changes: 6 additions & 3 deletions cykusz-rs/src/kernel/net/tcp/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -904,9 +904,12 @@ impl Socket {
}

fn read(&self, offset: usize, buf: &mut [u8], flags: MsgFlags) -> Result<usize> {
Ok(self
.in_buffer
.read_data_from(offset, buf, flags.contains(MsgFlags::MSG_PEEK), WaitQueueFlags::empty())?)
Ok(self.in_buffer.read_data_from(
offset,
buf,
flags.contains(MsgFlags::MSG_PEEK),
WaitQueueFlags::empty(),
)?)
}

fn update_window(&self) {
Expand Down
3 changes: 1 addition & 2 deletions cykusz-rs/src/kernel/utils/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ impl BufferQueue {
}

written

}

pub fn append_data(&self, data: &[u8]) -> crate::kernel::fs::vfs::Result<usize> {
Expand Down Expand Up @@ -175,7 +174,7 @@ impl BufferQueue {
offset: usize,
buf: &mut [u8],
transient: bool,
wg_flags: WaitQueueFlags
wg_flags: WaitQueueFlags,
) -> SignalResult<usize> {
if offset > 0 && !transient {
return Ok(0);
Expand Down
File renamed without changes.
10 changes: 10 additions & 0 deletions disk-scripts/create_disk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

user=$USER

SPATH=$(dirname $(readlink -f "$0"))
CYKUSZ_DIR=$(realpath $SPATH/..)

sudo $CYKUSZ_DIR/disk-scripts/make_disk.sh $user
sleep 1
sudo $CYKUSZ_DIR/disk-scripts/install_grub.sh
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion remove_trailing_whitespace.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

find ./src -type f -exec sed --in-place 's/[[:space:]]\+$//' {} \+
find ./cykusz-rs/src -type f -exec sed --in-place 's/[[:space:]]\+$//' {} \+
2 changes: 1 addition & 1 deletion syscall-defs/src/events/buttons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ pub enum ButtonCode {
pub enum RelCode {
REL_X = 0x00,
REL_Y = 0x01,
}
}
2 changes: 1 addition & 1 deletion syscall-defs/src/events/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::time::Timeval;

pub mod keys;
pub mod buttons;
pub mod keys;

#[repr(u16)]
#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion syscall-defs/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ impl Timeval {
pub fn to_nanoseconds(&self) -> usize {
self.secs as usize * 1000000000usize + self.usecs as usize * 1000usize
}
}
}
34 changes: 17 additions & 17 deletions sysroot/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -394,11 +394,11 @@ function _sysroot {
mkdir -p $BUILD_DIR

rm -rf $MLIBC_BUILD_DIR
meson setup --cross-file $SPATH/cross-file.ini --prefix /usr -Dlinux_kernel_headers=$SYSROOT/usr/include -Dheaders_only=true $MLIBC_BUILD_DIR $MLIBC_SRC_DIR
meson setup --cross-file $SPATH/cfg/cross-file.ini --prefix /usr -Dlinux_kernel_headers=$SYSROOT/usr/include -Dheaders_only=true $MLIBC_BUILD_DIR $MLIBC_SRC_DIR
meson install -C $MLIBC_BUILD_DIR --destdir=$SYSROOT

mkdir -p $SYSROOT/etc
cp $SPATH/resolv.conf $SYSROOT/etc/
cp $SPATH/cfg/resolv.conf $SYSROOT/etc/
}

function _binutils {
Expand Down Expand Up @@ -456,7 +456,7 @@ function _mlibc {
mkdir -p $BUILD_DIR

rm -rf $MLIBC_BUILD_DIR
meson setup --cross-file $SPATH/cross-file.ini --prefix /usr -Ddefault_library=both -Dlinux_kernel_headers=$SYSROOT/usr/include -Dheaders_only=false $MLIBC_BUILD_DIR $MLIBC_SRC_DIR
meson setup --cross-file $SPATH/cfg/cross-file.ini --prefix /usr -Ddefault_library=both -Dlinux_kernel_headers=$SYSROOT/usr/include -Dheaders_only=false $MLIBC_BUILD_DIR $MLIBC_SRC_DIR

ninja -C $MLIBC_BUILD_DIR
meson install -C $MLIBC_BUILD_DIR --destdir=$SYSROOT
Expand Down Expand Up @@ -847,7 +847,7 @@ function _cykusz_llvm {

export CYKUSZ_SYSROOT_DIR=$SYSROOT
export CYKUSZ_ROOT_DIR=$SPATH
cmake -DCMAKE_TOOLCHAIN_FILE=$SPATH/CMakeToolchain-x86_64-cykusz.txt -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld" -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DLLVM_LINK_LLVM_DYLIB=ON -DLLVM_ENABLE_RTTI=ON -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_TARGET_ARCH=x86_64 -DLLVM_DEFAULT_TARGET_TRIPLE=$TRIPLE -DLLVM_HOST_TRIPLE=$TRIPLE -Wno-dev $LLVM_SRC_DIR/llvm
cmake -DCMAKE_TOOLCHAIN_FILE=$SPATH/cfg/CMakeToolchain-x86_64-cykusz.txt -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld" -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DLLVM_LINK_LLVM_DYLIB=ON -DLLVM_ENABLE_RTTI=ON -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_TARGET_ARCH=x86_64 -DLLVM_DEFAULT_TARGET_TRIPLE=$TRIPLE -DLLVM_HOST_TRIPLE=$TRIPLE -Wno-dev $LLVM_SRC_DIR/llvm

VERBOSE=1 make -j12 DESTDIR=$SYSROOT
make DESTDIR=$SYSROOT install
Expand All @@ -864,7 +864,7 @@ function _cykusz_zstd {

cd $ZSTD_CYKUSZ_BUILD_DIR

cmake -DCMAKE_TOOLCHAIN_FILE=$SPATH/CMakeToolchain-x86_64-cykusz.txt -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release $ZSTD_SRC_DIR/build/cmake
cmake -DCMAKE_TOOLCHAIN_FILE=$SPATH/cfg/CMakeToolchain-x86_64-cykusz.txt -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release $ZSTD_SRC_DIR/build/cmake
make -j8
DESTDIR=$SYSROOT make install

Expand All @@ -882,7 +882,7 @@ function _cykusz_zlib {

export CYKUSZ_SYSROOT_DIR=$SYSROOT
export CYKUSZ_ROOT_DIR=$SPATH
cmake -DCMAKE_TOOLCHAIN_FILE=$SPATH/CMakeToolchain-x86_64-cykusz.txt -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release $ZLIB_SRC_DIR
cmake -DCMAKE_TOOLCHAIN_FILE=$SPATH/cfg/CMakeToolchain-x86_64-cykusz.txt -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release $ZLIB_SRC_DIR

VERBOSE=1 make -j12 DESTDIR=$SYSROOT
make DESTDIR=$SYSROOT install
Expand All @@ -901,7 +901,7 @@ function _cykusz_libressl {

export CYKUSZ_SYSROOT_DIR=$SYSROOT
export CYKUSZ_ROOT_DIR=$SPATH
cmake -DCMAKE_TOOLCHAIN_FILE=$SPATH/CMakeToolchain-x86_64-cykusz.txt -DBUILD_SHARED_LIBS=ON -DLIBRESSL_APPS=ON -DENABLE_NC=OFF -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release $LIBRESSL_SRC_DIR
cmake -DCMAKE_TOOLCHAIN_FILE=$SPATH/cfg/CMakeToolchain-x86_64-cykusz.txt -DBUILD_SHARED_LIBS=ON -DLIBRESSL_APPS=ON -DENABLE_NC=OFF -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release $LIBRESSL_SRC_DIR

VERBOSE=1 make -j12 DESTDIR=$SYSROOT
make DESTDIR=$SYSROOT install
Expand All @@ -917,7 +917,7 @@ function _cykusz_python {
mkdir -p $PYTHON_CYKUSZ_BUILD_DIR

cd $PYTHON_CYKUSZ_BUILD_DIR
export CONFIG_SITE=$SPATH/python-config-site
export CONFIG_SITE=$SPATH/cfg/python-config-site
export PKG_CONFIG_SYSROOT_DIR=$SYSROOT
export PKG_CONFIG_LIBDIR=$SYSROOT/usr/lib/pkgconfig:$SYSROOT/usr/share/pkgconfig
$PYTHON_SRC_DIR/configure --with-build-python=python3.11 --host=$TRIPLE --build=x86_64-linux-gnu --prefix=/usr --enable-shared --disable-ipv6 --without-static-libpython --without-ensurepip
Expand Down Expand Up @@ -948,15 +948,15 @@ function _cykusz_readline {
}

function _cykusz_apps {
$TRIPLE-gcc $SPATH/test.c -o $BUILD_DIR/test
$TRIPLE-gcc $SPATH/stack.c -o $BUILD_DIR/stack
$TRIPLE-g++ $SPATH/hello.cpp -o $BUILD_DIR/hello
$TRIPLE-g++ $SPATH/test.cpp -o $BUILD_DIR/testcpp
$TRIPLE-gcc $SPATH/ttytest.c -o $BUILD_DIR/ttytest
$TRIPLE-gcc $SPATH/fork.c -o $BUILD_DIR/fork
$TRIPLE-gcc $SPATH/forktest.c -o $BUILD_DIR/forktest
$TRIPLE-gcc $SPATH/poweroff.c -o $BUILD_DIR/poweroff
$TRIPLE-gcc $SPATH/stat.c -o $BUILD_DIR/stat
$TRIPLE-gcc $SRC_DIR/cykusz_apps/test.c -o $BUILD_DIR/test
$TRIPLE-gcc $SRC_DIR/cykusz_apps/stack.c -o $BUILD_DIR/stack
$TRIPLE-g++ $SRC_DIR/cykusz_apps/hello.cpp -o $BUILD_DIR/hello
$TRIPLE-g++ $SRC_DIR/cykusz_apps/test.cpp -o $BUILD_DIR/testcpp
$TRIPLE-gcc $SRC_DIR/cykusz_apps/ttytest.c -o $BUILD_DIR/ttytest
$TRIPLE-gcc $SRC_DIR/cykusz_apps/fork.c -o $BUILD_DIR/fork
$TRIPLE-gcc $SRC_DIR/cykusz_apps/forktest.c -o $BUILD_DIR/forktest
$TRIPLE-gcc $SRC_DIR/cykusz_apps/poweroff.c -o $BUILD_DIR/poweroff
$TRIPLE-gcc $SRC_DIR/cykusz_apps/stat.c -o $BUILD_DIR/stat
_cykusz_nyancat
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
list(APPEND CMAKE_MODULE_PATH "$ENV{CYKUSZ_ROOT_DIR}/cmake/Modules")
list(APPEND CMAKE_MODULE_PATH "$ENV{CYKUSZ_ROOT_DIR}/cfg/cmake/Modules")

set(CMAKE_SYSTEM_NAME cykusz)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion sysroot/make_docker_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
SPATH=$(dirname $(readlink -f "$0"))
CYKUSZ_DIR=$(realpath $SPATH/..)

docker buildx build -t cykusz-build $CYKUSZ_DIR/sysroot/docker
docker buildx build -t cykusz-build $CYKUSZ_DIR/sysroot/cfg/docker
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 0 additions & 13 deletions update_core_nightly.sh

This file was deleted.

0 comments on commit 1f2de19

Please sign in to comment.