Browse Source

适配了macOS下的加速器

Liric Mechan 2 years ago
parent
commit
c76ccf2907
1 changed files with 11 additions and 11 deletions
  1. 11 11
      run.sh

+ 11 - 11
run.sh

@@ -9,24 +9,19 @@ IN_DOCKER=0
 
 # 第一个参数如果是--notbuild 那就不构建,直接运行
 if [ ! "$1" == "--nobuild" ]; then
-    if [ "$1" == "--nomake" ]; then
-        echo "将会跳过make过程直接构建镜像..."
-        echo "开始构建..."
-        GENERATE_ISO=1
-    elif [ "$1" == "--docker" ]; then
+    echo "开始构建..."
+    if [ "$1" == "--docker" ]; then
         echo "使用docker构建"
-        echo "开始构建..."
         sudo bash tools/build_in_docker.sh
         GENERATE_ISO=0
     elif [ "$1" == "--current_in_docker" ]; then
         echo "运行在docker内"
-        echo "开始构建..."
         IN_DOCKER=1
         make all -j 16
         make clean
         GENERATE_ISO=1
     else
-        echo "开始构建..."
+        
         make all -j 16
         make clean
         GENERATE_ISO=1
@@ -136,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
@@ -143,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 "不满足运行条件"