Browse Source

Merge pull request #22 from liricliu/master

run.sh脚本适配macOS,以及doc中关于建立开发环境章节的小修改
login 2 years ago
parent
commit
992fa27d9e
2 changed files with 20 additions and 3 deletions
  1. 12 0
      docs/introduction/build_system.md
  2. 8 3
      run.sh

+ 12 - 0
docs/introduction/build_system.md

@@ -30,6 +30,18 @@ sudo apt install -y qemu qemu-system qemu-kvm
 
   请留意,若您的Linux系统是在虚拟机中运行的,还请您在您的VMware/Virtual Box虚拟机的处理器设置选项卡中,开启Intel VT-x或AMD-V选项,否则,DragonOS将无法运行。
 
+*在某些Linux发行版的软件仓库中构建的Qemu可能存在不识别命令参数的问题,如果遇到这种问题,请卸载Qemu,并采用编译安装的方式重新安装Qemu*
+
+在该地址下载Qemu源代码: https://download.qemu.org/
+
+解压后进入源代码目录,然后执行下列命令:
+
+```shell
+./configure --enable-kvm
+make -j 8
+sudo make install
+```
+
 ### 下载DragonOS的源代码
 
   假设您的计算机上已经安装了git,您可以通过以下命令,获得DragonOS的最新的源代码:

+ 8 - 3
run.sh

@@ -131,6 +131,11 @@ allflags=$(qemu-system-x86_64 -cpu help | awk '/flags/ {y=1; getline}; y {print}
 # 调试usb的trace
 qemu_trace_usb=trace:usb_xhci_reset,trace:usb_xhci_run,trace:usb_xhci_stop,trace:usb_xhci_irq_msi,trace:usb_xhci_irq_msix,trace:usb_xhci_port_reset
 
+qemu_accel=kvm
+if [ "${OS}" == "Darwin" ]; then
+    qemu_accel=hvf
+fi
+
 if [ $flag_can_run -eq 1 ]; then
   if [ ${IA32_USE_QEMU} == 0 ]; then
         bochs -q -f ${bochsrc} -rc ./tools/bochsinit
@@ -138,13 +143,13 @@ if [ $flag_can_run -eq 1 ]; then
         qemu-system-x86_64 -d bin/disk.img -m 512M -smp 2,cores=2,threads=1,sockets=1 \
         -boot order=d   \
         -monitor stdio -d cpu_reset,guest_errors,trace:check_exception,exec,cpu,out_asm,in_asm,${qemu_trace_usb} \
-        -s -S -cpu "IvyBridge,+apic,+x2apic,+fpu,check,${allflags}" --enable-kvm -rtc clock=host,base=localtime -serial file:serial_opt.txt \
+        -s -S -cpu IvyBridge,apic,x2apic,+fpu,check,${allflags} -rtc clock=host,base=localtime -serial file:serial_opt.txt \
         -drive id=disk,file=bin/disk.img,if=none \
         -device ahci,id=ahci \
         -device ide-hd,drive=disk,bus=ahci.0    \
         -usb    \
-        -device qemu-xhci,id=xhci,p2=8,p3=4
-
+        -device qemu-xhci,id=xhci,p2=8,p3=4 \
+        -machine accel=${qemu_accel}
     fi
 else
   echo "不满足运行条件"