Compare commits
5 Commits
865061b492
...
8e624ca85a
Author | SHA1 | Date |
---|---|---|
Bananymous | 8e624ca85a | |
Bananymous | c7afd46016 | |
Bananymous | 3573656244 | |
Bananymous | 1de6de975a | |
Bananymous | 15c55b8c7d |
|
@ -83,5 +83,5 @@ command_line_enter_msg:
|
|||
command_line:
|
||||
# 100 character command line
|
||||
command_line_buffer:
|
||||
.ascii "root=UUID=9C87D2AF-566A-4517-971A-57BA86EEA88D"
|
||||
.ascii "root=/dev/sda2"
|
||||
.skip 100 - (. - command_line_buffer)
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <kernel/Storage/Partition.h>
|
||||
#include <kernel/Timer/Timer.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
namespace Kernel
|
||||
|
@ -28,8 +29,10 @@ namespace Kernel
|
|||
if (!static_cast<Device*>(inode.ptr())->is_partition())
|
||||
return BAN::Iteration::Continue;
|
||||
auto* partition = static_cast<Partition*>(inode.ptr());
|
||||
if (partition->uuid() != uuid)
|
||||
return BAN::Iteration::Continue;
|
||||
ASSERT(partition->uuid().size() == uuid.size());
|
||||
for (size_t i = 0; i < uuid.size(); i++)
|
||||
if (tolower(uuid[i]) != tolower(partition->uuid()[i]))
|
||||
return BAN::Iteration::Continue;
|
||||
result = partition;
|
||||
return BAN::Iteration::Break;
|
||||
}
|
||||
|
@ -59,14 +62,14 @@ namespace Kernel
|
|||
BAN::StringView entry;
|
||||
RootType type;
|
||||
|
||||
if (root_path.size() >= 5 && root_path.substring(0, 5) == "UUID="_sv)
|
||||
if (root_path.starts_with("PARTUUID="_sv))
|
||||
{
|
||||
entry = root_path.substring(5);
|
||||
entry = root_path.substring(9);
|
||||
if (entry.size() != 36)
|
||||
panic("Invalid UUID '{}'", entry);
|
||||
type = RootType::PartitionUUID;
|
||||
}
|
||||
else if (root_path.size() >= 5 && root_path.substring(0, 5) == "/dev/"_sv)
|
||||
else if (root_path.starts_with("/dev/"_sv))
|
||||
{
|
||||
entry = root_path.substring(5);
|
||||
if (entry.empty() || entry.contains('/'))
|
||||
|
|
|
@ -381,9 +381,7 @@ namespace Kernel
|
|||
|
||||
Thread::current().save_sse();
|
||||
|
||||
if (!InterruptController::get().is_in_service(irq))
|
||||
dprintln("spurious irq 0x{2H}", irq);
|
||||
else
|
||||
if (InterruptController::get().is_in_service(irq))
|
||||
{
|
||||
InterruptController::get().eoi(irq);
|
||||
if (auto* handler = s_interruptables[irq])
|
||||
|
|
|
@ -82,8 +82,10 @@ namespace Kernel
|
|||
{
|
||||
if (is & (1 << i))
|
||||
{
|
||||
ASSERT(m_devices[i]);
|
||||
m_devices[i]->handle_irq();
|
||||
if (m_devices[i])
|
||||
m_devices[i]->handle_irq();
|
||||
else
|
||||
dwarnln("ignoring interrupt to device {}", i);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,5 +33,3 @@ if [[ -z $BANAN_BOOTLOADER ]]; then
|
|||
fi
|
||||
|
||||
export BANAN_CMAKE=$BANAN_TOOLCHAIN_PREFIX/bin/cmake
|
||||
|
||||
export BANAN_ROOT_PART_UUID='9C87D2AF-566A-4517-971A-57BA86EEA88D'
|
||||
|
|
|
@ -46,15 +46,6 @@ else
|
|||
mkpart root ext2 2M 100%
|
||||
fi
|
||||
|
||||
fdisk "$BANAN_DISK_IMAGE_PATH" >/dev/null << EOF
|
||||
x
|
||||
u
|
||||
2
|
||||
$BANAN_ROOT_PART_UUID
|
||||
r
|
||||
w
|
||||
EOF
|
||||
|
||||
# create loop device
|
||||
LOOP_DEV=$(sudo losetup --show -fP "$BANAN_DISK_IMAGE_PATH" || exit 1 )
|
||||
PARTITION1=${LOOP_DEV}p1
|
||||
|
|
|
@ -32,58 +32,58 @@ fi
|
|||
|
||||
set -u
|
||||
|
||||
MOUNT_DIR="$BANAN_BUILD_DIR/mount"
|
||||
mkdir -p $MOUNT_DIR
|
||||
mount_dir="$BANAN_BUILD_DIR/mount"
|
||||
mkdir -p $mount_dir
|
||||
|
||||
install_grub_legacy() {
|
||||
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 mkdir -p "$MOUNT_DIR/boot/grub"
|
||||
sed "s/<ROOT>/UUID=$BANAN_ROOT_PART_UUID/" "$BANAN_TOOLCHAIN_DIR/grub-legacy-boot.cfg" | sudo tee "$MOUNT_DIR/boot/grub/grub.cfg" >/dev/null
|
||||
sudo umount "$MOUNT_DIR"
|
||||
--boot-directory="$mount_dir/boot" \
|
||||
$loop_dev
|
||||
sudo mkdir -p "$mount_dir/boot/grub"
|
||||
sudo cp "$BANAN_BUILD_DIR/grub-legacy-boot.cfg" "$mount_dir/boot/grub/grub.cfg"
|
||||
sudo umount "$mount_dir"
|
||||
}
|
||||
|
||||
install_grub_uefi() {
|
||||
sudo mkfs.fat $PARTITION1 > /dev/null
|
||||
sudo mount $PARTITION1 "$MOUNT_DIR"
|
||||
sudo mkdir -p "$MOUNT_DIR/EFI/BOOT"
|
||||
sudo "$BANAN_TOOLCHAIN_PREFIX/bin/grub-mkstandalone" -O "$BANAN_ARCH-efi" -o "$MOUNT_DIR/EFI/BOOT/BOOTX64.EFI" "boot/grub/grub.cfg=$BANAN_TOOLCHAIN_DIR/grub-memdisk.cfg"
|
||||
sudo umount "$MOUNT_DIR"
|
||||
sudo mkfs.fat $partition1 > /dev/null
|
||||
sudo mount $partition1 "$mount_dir"
|
||||
sudo mkdir -p "$mount_dir/EFI/BOOT"
|
||||
sudo "$BANAN_TOOLCHAIN_PREFIX/bin/grub-mkstandalone" -O "$BANAN_ARCH-efi" -o "$mount_dir/EFI/BOOT/BOOTX64.EFI" "boot/grub/grub.cfg=$BANAN_BUILD_DIR/grub-memdisk.cfg"
|
||||
sudo umount "$mount_dir"
|
||||
|
||||
sudo mount $PARTITION2 "$MOUNT_DIR"
|
||||
sudo mkdir -p "$MOUNT_DIR/boot/grub"
|
||||
sed "s/<ROOT>/UUID=$BANAN_ROOT_PART_UUID/" "$BANAN_TOOLCHAIN_DIR/grub-uefi.cfg" | sudo tee "$MOUNT_DIR/boot/grub/grub.cfg" >/dev/null
|
||||
sudo umount "$MOUNT_DIR"
|
||||
sudo mount $partition2 "$mount_dir"
|
||||
sudo mkdir -p "$mount_dir/boot/grub"
|
||||
sudo cp "$BANAN_BUILD_DIR/grub-uefi.cfg" "$mount_dir/boot/grub/grub.cfg"
|
||||
sudo umount "$mount_dir"
|
||||
}
|
||||
|
||||
install_banan_legacy() {
|
||||
ROOT_DISK_INFO=$(fdisk -x "$BANAN_DISK_IMAGE_PATH" | tr -s ' ')
|
||||
ROOT_PART_GUID=$(echo "$ROOT_DISK_INFO" | grep "^$BANAN_DISK_IMAGE_PATH" | head -2 | tail -1 | cut -d' ' -f6)
|
||||
root_disk_info=$(fdisk -x "$BANAN_DISK_IMAGE_PATH" | tr -s ' ')
|
||||
root_part_guid=$(echo "$root_disk_info" | grep "^$BANAN_DISK_IMAGE_PATH" | head -2 | tail -1 | cut -d' ' -f6)
|
||||
|
||||
INSTALLER_BUILD_DIR=$BANAN_ROOT_DIR/bootloader/installer/build/$BANAN_ARCH
|
||||
BOOTLOADER_ELF=$BANAN_BUILD_DIR/bootloader/bios/bootloader
|
||||
installer_build_dir=$BANAN_ROOT_DIR/bootloader/installer/build/$BANAN_ARCH
|
||||
bootloader_elf=$BANAN_BUILD_DIR/bootloader/bios/bootloader
|
||||
|
||||
if [ ! -f $BOOTLOADER_ELF ]; then
|
||||
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
|
||||
if [ ! -d $installer_build_dir ]; then
|
||||
mkdir -p $installer_build_dir
|
||||
cd $installer_build_dir
|
||||
$BANAN_CMAKE -G Ninja ../..
|
||||
fi
|
||||
|
||||
cd $INSTALLER_BUILD_DIR
|
||||
cd $installer_build_dir
|
||||
ninja
|
||||
|
||||
echo installing bootloader
|
||||
$INSTALLER_BUILD_DIR/banan_os-bootloader-installer "$BOOTLOADER_ELF" "$BANAN_DISK_IMAGE_PATH" "$ROOT_PART_GUID"
|
||||
$installer_build_dir/banan_os-bootloader-installer "$bootloader_elf" "$BANAN_DISK_IMAGE_PATH" "$root_part_guid"
|
||||
}
|
||||
|
||||
install_banan_uefi() {
|
||||
|
@ -92,23 +92,34 @@ install_banan_uefi() {
|
|||
}
|
||||
|
||||
if [ $BANAN_BOOTLOADER = "GRUB" ]; then
|
||||
|
||||
LOOP_DEV=$(sudo losetup --show -fP $BANAN_DISK_IMAGE_PATH || exit 1)
|
||||
PARTITION1=${LOOP_DEV}p1
|
||||
PARTITION2=${LOOP_DEV}p2
|
||||
if [ ! -b $PARTITION1 ] || [ ! -b $PARTITION2 ]; then
|
||||
loop_dev=$(sudo losetup --show -fP $BANAN_DISK_IMAGE_PATH || exit 1)
|
||||
partition1=${loop_dev}p1
|
||||
partition2=${loop_dev}p2
|
||||
if [ ! -b $partition1 ] || [ ! -b $partition2 ]; then
|
||||
echo "Failed to probe partitions for banan disk image." >&2
|
||||
sudo losetup -d $LOOP_DEV
|
||||
sudo losetup -d $loop_dev
|
||||
exit 1
|
||||
fi
|
||||
|
||||
root_part_info=$(sudo blkid $partition2)
|
||||
|
||||
root_fs_uuid=$(grep -Pwo 'UUID=".*?"' <<< "$root_part_info")
|
||||
root_fs_uuid=${root_fs_uuid:6:36}
|
||||
|
||||
root_part_uuid=$(grep -Pwo 'PARTUUID=".*?"' <<< "$root_part_info")
|
||||
root_part_uuid=${root_part_uuid:10:36}
|
||||
|
||||
cp "$BANAN_TOOLCHAIN_DIR"/grub-*.cfg "$BANAN_BUILD_DIR/"
|
||||
sed -i "s/<ROOT>/PARTUUID=$root_part_uuid/" "$BANAN_BUILD_DIR"/grub-*.cfg
|
||||
sed -i "s/<ROOT_FS>/$root_fs_uuid/" "$BANAN_BUILD_DIR"/grub-*.cfg
|
||||
|
||||
if (($BANAN_UEFI_BOOT)); then
|
||||
install_grub_uefi
|
||||
else
|
||||
install_grub_legacy
|
||||
fi
|
||||
|
||||
sudo losetup -d $LOOP_DEV
|
||||
sudo losetup -d $loop_dev
|
||||
|
||||
elif [ $BANAN_BOOTLOADER = "BANAN" ]; then
|
||||
if (($BANAN_UEFI_BOOT)); then
|
||||
|
|
|
@ -1,2 +1,5 @@
|
|||
insmod part_gpt
|
||||
configfile (hd0,gpt2)/boot/grub/grub.cfg
|
||||
insmod search_fs_uuid
|
||||
|
||||
search --no-floppy --fs-uuid --set=root <ROOT_FS>
|
||||
configfile /boot/grub/grub.cfg
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
insmod part_gpt
|
||||
set root=(hd0,gpt2)
|
||||
insmod search_fs_uuid
|
||||
|
||||
search --no-floppy --fs-uuid --set=root <ROOT_FS>
|
||||
|
||||
insmod all_video
|
||||
|
||||
|
|
Loading…
Reference in New Issue