mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-09 02:46:47 +00:00
🔧 更改为使用bochs虚拟机(qemu暂时没法正常显示画面)
This commit is contained in:
parent
f479f32102
commit
3d37bf9c3a
5
bochsrc
5
bochsrc
@ -1,13 +1,13 @@
|
||||
# configuration file generated by Bochs
|
||||
plugin_ctrl: unmapped=1, biosdev=1, speaker=1, extfpuirq=1, parallel=1, serial=1, iodebug=1
|
||||
config_interface: textconfig
|
||||
display_library: sdl
|
||||
# display_library: x11
|
||||
#memory: host=2048, guest=2048
|
||||
romimage: file="/usr/local/share/bochs/BIOS-bochs-latest"
|
||||
vgaromimage: file="/usr/local/share/bochs/VGABIOS-lgpl-latest"
|
||||
boot: floppy
|
||||
floppy_bootsig_check: disabled=0
|
||||
floppya: type=1_44, 1_44="./bin/boot.img", status=inserted, write_protected=0
|
||||
floppya: type=1_44, 1_44="bin/boot.img", status=inserted, write_protected=0
|
||||
# no floppyb
|
||||
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
|
||||
ata0-master: type=none
|
||||
@ -51,3 +51,4 @@ com4: enabled=0
|
||||
|
||||
megs: 2048
|
||||
|
||||
# gdbstub: enabled=1, port=1234, text_base=0, data_base=0, bss_base=0;
|
@ -4,7 +4,7 @@ boot.bin: boot.asm
|
||||
nasm boot.asm -o ../bin/bootloader/boot.bin
|
||||
|
||||
loader.bin: loader.asm
|
||||
nasm loader.asm -o ../bin/bootloader/lodaer.bin
|
||||
nasm loader.asm -o ../bin/bootloader/loader.bin
|
||||
|
||||
|
||||
clean:
|
||||
|
@ -1,8 +1,41 @@
|
||||
//
|
||||
// Created by longjin on 2022/1/20.
|
||||
//
|
||||
int *address = (int *)0xffff800000a00000; //帧缓存区的地址
|
||||
|
||||
void show_color_band(int width, int height, char a, char b, char c, char d)
|
||||
{
|
||||
/** 向帧缓冲区写入像素值
|
||||
* @param address: 帧缓存区的地址
|
||||
* @param val:像素值
|
||||
*/
|
||||
|
||||
for (int i = 0; i < width * height; ++i)
|
||||
{
|
||||
|
||||
*((char *)address + 0) = d;
|
||||
*((char *)address + 1) = c;
|
||||
*((char *)address + 2) = b;
|
||||
*((char *)address + 3) = a;
|
||||
++address;
|
||||
}
|
||||
}
|
||||
|
||||
//操作系统内核从这里开始执行
|
||||
void Start_Kernel(void)
|
||||
{
|
||||
while(1);
|
||||
|
||||
|
||||
|
||||
|
||||
show_color_band(1440, 20, 0x00, 0xff, 0x00, 0x00);
|
||||
|
||||
show_color_band(1440, 20, 0x00, 0x00, 0xff, 0x00);
|
||||
|
||||
show_color_band(1440, 20, 0x00, 0x00, 0x00, 0xff);
|
||||
|
||||
show_color_band(1440, 20, 0x00, 0xff, 0xff, 0xff);
|
||||
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
79
run_in_bochs.sh
Normal file
79
run_in_bochs.sh
Normal file
@ -0,0 +1,79 @@
|
||||
# ======检查是否以sudo运行=================
|
||||
uid=`id -u`
|
||||
if [ ! $uid == "0" ];then
|
||||
echo "请以sudo权限运行"
|
||||
exit
|
||||
fi
|
||||
|
||||
# 第一个参数如果是--notbuild 那就不构建,直接运行
|
||||
if [ ! "$1" == "--nobuild" ]; then
|
||||
echo "开始构建..."
|
||||
make all
|
||||
make clean
|
||||
fi
|
||||
|
||||
# ==============检查文件是否齐全================
|
||||
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/bootloader/boot.bin of=bin/boot.img bs=512 count=1 conv=notrunc
|
||||
|
||||
# =========创建临时文件夹==================
|
||||
# 判断临时文件夹是否存在,若不存在则创建新的
|
||||
if [ ! -d "tmp/" ]; then
|
||||
mkdir tmp/
|
||||
echo "创建了tmp文件夹"
|
||||
fi
|
||||
|
||||
# ==============挂载boot.img=============
|
||||
mkdir tmp/boot
|
||||
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==========
|
||||
cp bin/bootloader/loader.bin tmp/boot
|
||||
# ========把内核程序复制到boot.img======
|
||||
cp bin/kernel/kernel.bin tmp/boot
|
||||
sync
|
||||
# 卸载磁盘
|
||||
umount tmp/boot
|
||||
else
|
||||
echo "挂载 boot.img 失败!"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# 运行结束后删除tmp文件夹
|
||||
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
|
||||
bochs -f ./bochsrc -q
|
||||
else
|
||||
echo "不满足运行条件"
|
||||
fi
|
@ -6,7 +6,7 @@ if [ ! $uid == "0" ];then
|
||||
fi
|
||||
|
||||
# 第一个参数如果是--notbuild 那就不构建,直接运行
|
||||
if [ ! "$1" == "--notbuild" ]; then
|
||||
if [ ! "$1" == "--nobuild" ]; then
|
||||
echo "开始构建..."
|
||||
make all
|
||||
make clean
|
||||
|
Loading…
x
Reference in New Issue
Block a user