Compare commits
No commits in common. "f2397b775c7d485f6eb6a076523cc9e05d5b3a98" and "a312d75bb260e381a724fe995f691bff31f10fdc" have entirely different histories.
f2397b775c
...
a312d75bb2
|
@ -0,0 +1,3 @@
|
||||||
|
test.img
|
||||||
|
build/
|
||||||
|
installer/build/
|
|
@ -1,3 +1,18 @@
|
||||||
cmake_minimum_required(VERSION 3.26)
|
cmake_minimum_required(VERSION 3.26)
|
||||||
|
|
||||||
add_subdirectory(bios)
|
project(bootloader ASM)
|
||||||
|
|
||||||
|
set(BOOTLOADER_SOURCES
|
||||||
|
boot.S
|
||||||
|
command_line.S
|
||||||
|
disk.S
|
||||||
|
elf.S
|
||||||
|
ext2.S
|
||||||
|
framebuffer.S
|
||||||
|
memory_map.S
|
||||||
|
utils.S
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(bootloader ${BOOTLOADER_SOURCES})
|
||||||
|
target_link_options(bootloader PUBLIC LINKER:-T,${CMAKE_CURRENT_SOURCE_DIR}/linker.ld)
|
||||||
|
target_link_options(bootloader PUBLIC -nostdlib)
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
cmake_minimum_required(VERSION 3.26)
|
|
||||||
|
|
||||||
project(bootloader ASM)
|
|
||||||
|
|
||||||
set(BOOTLOADER_SOURCES
|
|
||||||
boot.S
|
|
||||||
command_line.S
|
|
||||||
disk.S
|
|
||||||
elf.S
|
|
||||||
ext2.S
|
|
||||||
framebuffer.S
|
|
||||||
memory_map.S
|
|
||||||
utils.S
|
|
||||||
)
|
|
||||||
|
|
||||||
add_executable(bootloader ${BOOTLOADER_SOURCES})
|
|
||||||
target_link_options(bootloader PRIVATE LINKER:-T,${CMAKE_CURRENT_SOURCE_DIR}/linker.ld)
|
|
||||||
target_link_options(bootloader PRIVATE -nostdlib)
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [[ -z $BANAN_DISK_IMAGE_PATH ]]; then
|
||||||
|
echo "You must set the BANAN_DISK_IMAGE_PATH environment variable" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z $BANAN_BUILD_DIR ]]; then
|
||||||
|
echo "You must set the BANAN_BUILD_DIR environment variable" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
ROOT_PARTITION_INDEX=2
|
||||||
|
ROOT_PARTITION_INFO=$(fdisk -x $BANAN_DISK_IMAGE_PATH | grep "^$BANAN_DISK_IMAGE_PATH" | head -$ROOT_PARTITION_INDEX | tail -1)
|
||||||
|
ROOT_PARTITION_GUID=$(echo $ROOT_PARTITION_INFO | cut -d' ' -f6)
|
||||||
|
|
||||||
|
INSTALLER_BUILD_DIR=$(dirname $(realpath $0))/installer/build
|
||||||
|
BOOTLOADER_ELF=$BANAN_BUILD_DIR/bootloader/bootloader
|
||||||
|
|
||||||
|
if ! [ -f $BOOTLOADER_ELF ]; then
|
||||||
|
echo "You must build the bootloader first" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! [ -d $INSTALLER_BUILD_DIR ]; then
|
||||||
|
mkdir -p $INSTALLER_BUILD_DIR
|
||||||
|
cd $INSTALLER_BUILD_DIR
|
||||||
|
cmake ..
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd $INSTALLER_BUILD_DIR
|
||||||
|
make
|
||||||
|
|
||||||
|
echo installing bootloader
|
||||||
|
$INSTALLER_BUILD_DIR/x86_64-banan_os-bootloader-installer $BOOTLOADER_ELF $BANAN_DISK_IMAGE_PATH $ROOT_PARTITION_GUID
|
|
@ -1 +0,0 @@
|
||||||
build/
|
|
|
@ -13,9 +13,6 @@ namespace Kernel
|
||||||
static BAN::ErrorOr<BAN::RefPtr<ProcPidInode>> create_new(Process&, TmpFileSystem&, mode_t, uid_t, gid_t);
|
static BAN::ErrorOr<BAN::RefPtr<ProcPidInode>> create_new(Process&, TmpFileSystem&, mode_t, uid_t, gid_t);
|
||||||
~ProcPidInode() = default;
|
~ProcPidInode() = default;
|
||||||
|
|
||||||
virtual uid_t uid() const override { return m_process.credentials().ruid(); }
|
|
||||||
virtual gid_t gid() const override { return m_process.credentials().rgid(); }
|
|
||||||
|
|
||||||
void cleanup();
|
void cleanup();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -34,9 +31,6 @@ namespace Kernel
|
||||||
static BAN::ErrorOr<BAN::RefPtr<ProcROInode>> create_new(Process&, size_t (Process::*callback)(off_t, BAN::ByteSpan) const, TmpFileSystem&, mode_t, uid_t, gid_t);
|
static BAN::ErrorOr<BAN::RefPtr<ProcROInode>> create_new(Process&, size_t (Process::*callback)(off_t, BAN::ByteSpan) const, TmpFileSystem&, mode_t, uid_t, gid_t);
|
||||||
~ProcROInode() = default;
|
~ProcROInode() = default;
|
||||||
|
|
||||||
virtual uid_t uid() const override { return m_process.credentials().ruid(); }
|
|
||||||
virtual gid_t gid() const override { return m_process.credentials().rgid(); }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual BAN::ErrorOr<size_t> read_impl(off_t, BAN::ByteSpan) override;
|
virtual BAN::ErrorOr<size_t> read_impl(off_t, BAN::ByteSpan) override;
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,8 @@ namespace Kernel
|
||||||
virtual ino_t ino() const override final { return m_ino; }
|
virtual ino_t ino() const override final { return m_ino; }
|
||||||
virtual Mode mode() const override final { return Mode(m_inode_info.mode); }
|
virtual Mode mode() const override final { return Mode(m_inode_info.mode); }
|
||||||
virtual nlink_t nlink() const override final { return m_inode_info.nlink; }
|
virtual nlink_t nlink() const override final { return m_inode_info.nlink; }
|
||||||
virtual uid_t uid() const override { return m_inode_info.uid; }
|
virtual uid_t uid() const override final { return m_inode_info.uid; }
|
||||||
virtual gid_t gid() const override { return m_inode_info.gid; }
|
virtual gid_t gid() const override final { return m_inode_info.gid; }
|
||||||
virtual off_t size() const override final { return m_inode_info.size; }
|
virtual off_t size() const override final { return m_inode_info.size; }
|
||||||
virtual timespec atime() const override final { return m_inode_info.atime; }
|
virtual timespec atime() const override final { return m_inode_info.atime; }
|
||||||
virtual timespec mtime() const override final { return m_inode_info.mtime; }
|
virtual timespec mtime() const override final { return m_inode_info.mtime; }
|
||||||
|
|
|
@ -39,10 +39,11 @@ build_toolchain () {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
$BANAN_TOOLCHAIN_DIR/build.sh
|
$BANAN_TOOLCHAIN_DIR/build.sh
|
||||||
|
build_target libc-install
|
||||||
|
$BANAN_TOOLCHAIN_DIR/build.sh libstdc++
|
||||||
}
|
}
|
||||||
|
|
||||||
create_image () {
|
create_image () {
|
||||||
build_target bootloader
|
|
||||||
build_target install-sysroot
|
build_target install-sysroot
|
||||||
$BANAN_SCRIPT_DIR/image.sh "$1"
|
$BANAN_SCRIPT_DIR/image.sh "$1"
|
||||||
}
|
}
|
||||||
|
@ -96,6 +97,12 @@ case $1 in
|
||||||
rm -f $FAKEROOT_FILE
|
rm -f $FAKEROOT_FILE
|
||||||
rm -rf $BANAN_SYSROOT
|
rm -rf $BANAN_SYSROOT
|
||||||
;;
|
;;
|
||||||
|
bootloader)
|
||||||
|
create_image
|
||||||
|
build_target bootloader
|
||||||
|
$BANAN_ROOT_DIR/bootloader/install.sh
|
||||||
|
$BANAN_SCRIPT_DIR/qemu.sh -serial stdio $QEMU_ACCEL
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
build_target $1
|
build_target $1
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -25,7 +25,3 @@ export BANAN_DISK_IMAGE_PATH=$BANAN_BUILD_DIR/banan-os.img
|
||||||
if [[ -z $BANAN_UEFI_BOOT ]]; then
|
if [[ -z $BANAN_UEFI_BOOT ]]; then
|
||||||
export BANAN_UEFI_BOOT=0
|
export BANAN_UEFI_BOOT=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z $BANAN_BOOTLOADER ]]; then
|
|
||||||
export BANAN_BOOTLOADER="BANAN"
|
|
||||||
fi
|
|
||||||
|
|
|
@ -15,11 +15,6 @@ if [[ -z $BANAN_TOOLCHAIN_PREFIX ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z $BANAN_BOOTLOADER ]]; then
|
|
||||||
echo "You must set the BANAN_BOOTLOADER environment variable" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -z $BANAN_ARCH ]]; then
|
if [[ -z $BANAN_ARCH ]]; then
|
||||||
echo "You must set the BANAN_ARCH environment variable" >&2
|
echo "You must set the BANAN_ARCH environment variable" >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -79,8 +74,7 @@ PARTITION2=${LOOP_DEV}p2
|
||||||
|
|
||||||
sudo mkfs.ext2 -b 1024 -q $PARTITION2
|
sudo mkfs.ext2 -b 1024 -q $PARTITION2
|
||||||
|
|
||||||
if [[ "$BANAN_BOOTLOADER" == "GRUB" ]]; then
|
if [[ "$BANAN_UEFI_BOOT" == "1" ]]; then
|
||||||
if [[ "$BANAN_UEFI_BOOT" == "1" ]]; then
|
|
||||||
sudo mkfs.fat $PARTITION1 > /dev/null
|
sudo mkfs.fat $PARTITION1 > /dev/null
|
||||||
sudo mount $PARTITION1 "$MOUNT_DIR"
|
sudo mount $PARTITION1 "$MOUNT_DIR"
|
||||||
sudo mkdir -p "$MOUNT_DIR/EFI/BOOT"
|
sudo mkdir -p "$MOUNT_DIR/EFI/BOOT"
|
||||||
|
@ -91,27 +85,12 @@ if [[ "$BANAN_BOOTLOADER" == "GRUB" ]]; then
|
||||||
sudo mkdir -p "$MOUNT_DIR/boot/grub"
|
sudo mkdir -p "$MOUNT_DIR/boot/grub"
|
||||||
sudo cp "$BANAN_TOOLCHAIN_DIR/grub-uefi.cfg" "$MOUNT_DIR/boot/grub/grub.cfg"
|
sudo cp "$BANAN_TOOLCHAIN_DIR/grub-uefi.cfg" "$MOUNT_DIR/boot/grub/grub.cfg"
|
||||||
sudo umount "$MOUNT_DIR"
|
sudo umount "$MOUNT_DIR"
|
||||||
else
|
else
|
||||||
sudo mount $PARTITION2 "$MOUNT_DIR"
|
sudo mount $PARTITION2 "$MOUNT_DIR"
|
||||||
sudo grub-install --no-floppy --target=i386-pc --modules="normal ext2 multiboot" --boot-directory="$MOUNT_DIR/boot" $LOOP_DEV
|
sudo grub-install --no-floppy --target=i386-pc --modules="normal ext2 multiboot" --boot-directory="$MOUNT_DIR/boot" $LOOP_DEV
|
||||||
sudo mkdir -p "$MOUNT_DIR/boot/grub"
|
sudo mkdir -p "$MOUNT_DIR/boot/grub"
|
||||||
sudo cp "$BANAN_TOOLCHAIN_DIR/grub-legacy-boot.cfg" "$MOUNT_DIR/boot/grub/grub.cfg"
|
sudo cp "$BANAN_TOOLCHAIN_DIR/grub-legacy-boot.cfg" "$MOUNT_DIR/boot/grub/grub.cfg"
|
||||||
sudo umount "$MOUNT_DIR"
|
sudo umount "$MOUNT_DIR"
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo losetup -d $LOOP_DEV
|
sudo losetup -d $LOOP_DEV
|
||||||
|
|
||||||
if [[ "$BANAN_BOOTLOADER" == "GRUB" ]]; then
|
|
||||||
echo > /dev/null
|
|
||||||
elif [[ "$BANAN_BOOTLOADER" == "BANAN" ]]; then
|
|
||||||
if [[ "$BANAN_UEFI_BOOT" == "1" ]]; then
|
|
||||||
echo "banan bootloader does not support UEFI" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
$BANAN_SCRIPT_DIR/install-bootloader.sh
|
|
||||||
else
|
|
||||||
echo "unrecognized bootloader $BANAN_BOOTLOADER" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,14 @@ fi
|
||||||
|
|
||||||
if [[ "$1" == "full" ]] || [[ ! -f $BANAN_DISK_IMAGE_PATH ]]; then
|
if [[ "$1" == "full" ]] || [[ ! -f $BANAN_DISK_IMAGE_PATH ]]; then
|
||||||
$BANAN_SCRIPT_DIR/image-create.sh
|
$BANAN_SCRIPT_DIR/image-create.sh
|
||||||
|
else
|
||||||
|
fdisk -l $BANAN_DISK_IMAGE_PATH | grep -q 'EFI System'; IMAGE_IS_UEFI=$?
|
||||||
|
[[ $BANAN_UEFI_BOOT == 1 ]]; CREATE_IS_UEFI=$?
|
||||||
|
|
||||||
|
if [[ $IMAGE_IS_UEFI -ne $CREATE_IS_UEFI ]]; then
|
||||||
|
echo Converting disk image to/from UEFI
|
||||||
|
$BANAN_SCRIPT_DIR/image-create.sh
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
LOOP_DEV=$(sudo losetup --show -f "$BANAN_DISK_IMAGE_PATH")
|
LOOP_DEV=$(sudo losetup --show -f "$BANAN_DISK_IMAGE_PATH")
|
||||||
|
|
|
@ -26,11 +26,6 @@ if [[ -z $BANAN_BUILD_DIR ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z $BANAN_SCRIPT_DIR ]]; then
|
|
||||||
echo "You must set the BANAN_SCRIPT_DIR environment variable" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -z $BANAN_TOOLCHAIN_DIR ]]; then
|
if [[ -z $BANAN_TOOLCHAIN_DIR ]]; then
|
||||||
echo "You must set the BANAN_TOOLCHAIN_DIR environment variable" >&2
|
echo "You must set the BANAN_TOOLCHAIN_DIR environment variable" >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -51,10 +46,6 @@ if [[ -z $BANAN_ARCH ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z ${MAKE_JOBS:x} ]]; then
|
|
||||||
MAKE_JOBS="-j$(nproc)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
enter_clean_build () {
|
enter_clean_build () {
|
||||||
rm -rf build
|
rm -rf build
|
||||||
mkdir build
|
mkdir build
|
||||||
|
@ -83,7 +74,7 @@ build_binutils () {
|
||||||
--disable-nls \
|
--disable-nls \
|
||||||
--disable-werror
|
--disable-werror
|
||||||
|
|
||||||
make $MAKE_JOBS
|
make
|
||||||
make install
|
make install
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,10 +100,9 @@ build_gcc () {
|
||||||
--disable-nls \
|
--disable-nls \
|
||||||
--enable-languages=c,c++
|
--enable-languages=c,c++
|
||||||
|
|
||||||
make $MAKE_JOBS all-gcc
|
make all-gcc
|
||||||
make $MAKE_JOBS all-target-libgcc CFLAGS_FOR_TARGET='-g -O2 -mcmodel=large -mno-red-zone'
|
make all-target-libgcc CFLAGS_FOR_TARGET='-g -O2 -mcmodel=large -mno-red-zone'
|
||||||
make install-gcc
|
make install-gcc install-target-libgcc
|
||||||
make install-target-libgcc
|
|
||||||
}
|
}
|
||||||
|
|
||||||
build_grub () {
|
build_grub () {
|
||||||
|
@ -137,7 +127,7 @@ build_grub () {
|
||||||
--with-platform="efi" \
|
--with-platform="efi" \
|
||||||
--disable-werror
|
--disable-werror
|
||||||
|
|
||||||
make $MAKE_JOBS
|
make
|
||||||
make install
|
make install
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,29 +138,38 @@ build_libstdcpp () {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd $BANAN_BUILD_DIR/toolchain/$GCC_VERSION/build
|
cd $BANAN_BUILD_DIR/toolchain/$GCC_VERSION/build
|
||||||
make $MAKE_JOBS all-target-libstdc++-v3 CFLAGS_FOR_TARGET='-g -O2 -mcmodel=large -mno-red-zone'
|
make all-target-libstdc++-v3
|
||||||
make install-target-libstdc++-v3
|
make install-target-libstdc++-v3
|
||||||
}
|
}
|
||||||
|
|
||||||
# delete everything but toolchain
|
if [[ $# -ge 1 ]]; then
|
||||||
find $BANAN_BUILD_DIR -mindepth 1 -maxdepth 1 ! -name toolchain -exec rm -r {} +
|
if [[ "$1" == "libstdc++" ]]; then
|
||||||
|
build_libstdcpp
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "unrecognized arguments $@"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# NOTE: we have to manually create initial sysroot with libc headers
|
# NOTE: we have to manually create initial sysroot with libc headers
|
||||||
# since cmake cannot be invoked yet
|
# since cmake cannot be invoked yet
|
||||||
echo "Creating dummy sysroot"
|
echo "Creating dummy sysroot"
|
||||||
|
rm -rf $BANAN_SYSROOT
|
||||||
mkdir -p $BANAN_SYSROOT/usr
|
mkdir -p $BANAN_SYSROOT/usr
|
||||||
cp -r $BANAN_ROOT_DIR/libc/include $BANAN_SYSROOT/usr/include
|
cp -r $BANAN_ROOT_DIR/libc/include $BANAN_SYSROOT/usr/include
|
||||||
|
|
||||||
|
|
||||||
# Cleanup all old files from toolchain prefix
|
# Cleanup all old files from toolchain prefix
|
||||||
rm -rf $BANAN_TOOLCHAIN_PREFIX
|
rm -rf $BANAN_TOOLCHAIN_PREFIX
|
||||||
|
|
||||||
|
if [[ -z ${MAKEFLAGS:x} ]]; then
|
||||||
|
export MAKEFLAGS="-j$(nproc)"
|
||||||
|
fi
|
||||||
|
|
||||||
mkdir -p $BANAN_BUILD_DIR/toolchain
|
mkdir -p $BANAN_BUILD_DIR/toolchain
|
||||||
build_binutils
|
build_binutils
|
||||||
build_gcc
|
build_gcc
|
||||||
build_grub
|
build_grub
|
||||||
|
|
||||||
# delete sysroot and install libc
|
rm -rf $BANAN_SYSROOT
|
||||||
rm -r $BANAN_SYSROOT
|
|
||||||
$BANAN_SCRIPT_DIR/build.sh libc-install
|
|
||||||
|
|
||||||
build_libstdcpp
|
|
||||||
|
|
Loading…
Reference in New Issue