mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-09 02:46:47 +00:00
🔧 完善了运行脚本,加入了一些检查功能
This commit is contained in:
parent
51e5a0ffb8
commit
c7cc246652
@ -5,5 +5,6 @@ set(CMAKE_ASM_NASM_LINK_EXECUTABLE "nasm <OBJECTS> -o <TARGET> <LINK_LIBRARIES>"
|
||||
enable_language(ASM_NASM)
|
||||
|
||||
#修改输出的路径
|
||||
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
|
||||
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin/bootloader)
|
||||
add_executable(boot.bin boot.asm)
|
||||
add_executable(loader.bin loader.asm)
|
@ -1,3 +1,61 @@
|
||||
# ==============检查文件是否齐全================
|
||||
if [ ! -x "bin/bootloader/boot.bin" ]; then
|
||||
echo "bin/bootloader/boot.bin 不存在!"
|
||||
exit
|
||||
fi
|
||||
if [ ! -x "bin/bootloader/loader.bin" ]; then
|
||||
echo "bin/bootloader/loader.bin 不存在!"
|
||||
exit
|
||||
fi
|
||||
if [ ! -x "bin/boot.img" ]; then
|
||||
echo "bin/boot.img 不存在!"
|
||||
exit
|
||||
fi
|
||||
# ===============文件检查完毕===================
|
||||
|
||||
|
||||
# 将引导程序写入boot.img
|
||||
dd if=bin/boot.bin of=bin/boot.img bs=512 count=1 conv=notrunc
|
||||
qemu-system-x86_64 -s -S -m 2048 -fda bin/boot.img
|
||||
dd if=bin/bootloader/boot.bin of=bin/boot.img bs=512 count=1 conv=notrunc
|
||||
|
||||
# 判断临时文件夹是否存在,若不存在则创建新的
|
||||
if [ ! -d "tmp/" ]; then
|
||||
mkdir tmp/
|
||||
echo "创建了tmp文件夹"
|
||||
fi
|
||||
|
||||
# 挂载boot.img到tmp/boot
|
||||
mkdir tmp/boot
|
||||
sudo mount bin/boot.img tmp/boot -t vfat -o loop
|
||||
|
||||
# 检查是否挂载成功
|
||||
if mountpoint -q tmp/boot
|
||||
then
|
||||
echo "成功挂载 boot.img 到 tmp/boot"
|
||||
# 把loader.bin复制到boot.img
|
||||
sudo cp bin/bootloader/loader.bin tmp/boot
|
||||
sync
|
||||
sudo umount tmp/boot
|
||||
else
|
||||
echo "挂载 boot.img 失败!"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# 运行结束后删除tmp文件夹
|
||||
sudo rm -rf tmp
|
||||
|
||||
# 进行启动前检查
|
||||
flag_can_run=0
|
||||
|
||||
if [ -d "tmp/" ]; then
|
||||
flag_can_run=0
|
||||
echo "tmp文件夹未删除!"
|
||||
else
|
||||
flag_can_run=1
|
||||
fi
|
||||
|
||||
if [ $flag_can_run -eq 1 ]; then
|
||||
qemu-system-x86_64 -s -S -m 2048 -fda bin/boot.img
|
||||
else
|
||||
echo "不满足运行条件"
|
||||
fi
|
Loading…
x
Reference in New Issue
Block a user