在qemu中运行magenta

来源:互联网 发布:mysql数据库的安装步骤 编辑:程序博客网 时间:2024/06/05 09:33

前面已经编译了magenta内核

并且准备好了qemu模拟器


进入magenta目录

看下脚本./scripts/run-magenta-x86-64

~/fuchsia/magenta$ cat ./scripts/run-magenta-x86-64 #!/bin/bash# Copyright 2016 The Fuchsia Authors## Use of this source code is governed by a MIT-style# license that can be found in the LICENSE file or at# https://opensource.org/licenses/MITDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"exec $DIR/run-magenta -a x86-64 "$@"

以参数-a x86-64执行run-magenta脚本

先看下帮助信息

~/fuchsia/magenta$ ./scripts/run-magenta -hhelp:-a <arch>           : arm32, arm64, or x86-64-b                  : build first-c                  : add item to kernel commandline-d                  : run with emulated disk-g                  : use graphical console-k                  : use KVM-m <memory in MB>   : default 512MB-n                  : run with emulated nic-N                  : run with emulated nic via tun/tap-o <dir>            : build directory-r                  : run release build-u                  : use uniprocessor-v                  : use vnc based display-x <bootfs>         : add eXtra bootfs-h for helpall arguments after -- are passed to qemu directly

脚本run-magenta主要是根据平台选择qemu及设置参数

执行./scripts/run-magenta-x86-64

可以看到脚本最终执行的命令

qemu-system-x86_64 -m 512 -nographic -machine q35 -kernel /home/jiang/fuchsia/magenta/build-magenta-pc-x86-64/magenta.bin -smp cores=2,threads=2,sockets=1 -cpu Haswell,+smap -append

打印一堆启动信息

warning: TCG doesn't support requested feature: CPUID.01H:EDX.vme [bit 1]warning: TCG doesn't support requested feature: CPUID.01H:ECX.fma [bit 12]warning: TCG doesn't support requested feature: CPUID.01H:ECX.pcid [bit 17]warning: TCG doesn't support requested feature: CPUID.01H:ECX.x2apic [bit 21]warning: TCG doesn't support requested feature: CPUID.01H:ECX.tsc-deadline [bit 24]warning: TCG doesn't support requested feature: CPUID.01H:ECX.xsave [bit 26]warning: TCG doesn't support requested feature: CPUID.01H:ECX.avx [bit 28]warning: TCG doesn't support requested feature: CPUID.01H:ECX.f16c [bit 29]warning: TCG doesn't support requested feature: CPUID.01H:ECX.rdrand [bit 30]warning: TCG doesn't support requested feature: CPUID.07H:EBX.fsgsbase [bit 0]warning: TCG doesn't support requested feature: CPUID.07H:EBX.hle [bit 4]warning: TCG doesn't support requested feature: CPUID.07H:EBX.avx2 [bit 5]warning: TCG doesn't support requested feature: CPUID.07H:EBX.erms [bit 9]warning: TCG doesn't support requested feature: CPUID.07H:EBX.invpcid [bit 10]warning: TCG doesn't support requested feature: CPUID.07H:EBX.rtm [bit 11]warning: TCG doesn't support requested feature: CPUID.0DH:EAX.xsaveopt [bit 0]warning: TCG doesn't support requested feature: CPUID.01H:EDX.vme [bit 1]warning: TCG doesn't support requested feature: CPUID.01H:ECX.fma [bit 12]warning: TCG doesn't support requested feature: CPUID.01H:ECX.pcid [bit 17]warning: TCG doesn't support requested feature: CPUID.01H:ECX.x2apic [bit 21]warning: TCG doesn't support requested feature: CPUID.01H:ECX.tsc-deadline [bit 24]warning: TCG doesn't support requested feature: CPUID.01H:ECX.xsave [bit 26]warning: TCG doesn't support requested feature: CPUID.01H:ECX.avx [bit 28]warning: TCG doesn't support requested feature: CPUID.01H:ECX.f16c [bit 29]warning: TCG doesn't support requested feature: CPUID.01H:ECX.rdrand [bit 30]warning: TCG doesn't support requested feature: CPUID.07H:EBX.fsgsbase [bit 0]warning: TCG doesn't support requested feature: CPUID.07H:EBX.hle [bit 4]warning: TCG doesn't support requested feature: CPUID.07H:EBX.avx2 [bit 5]warning: TCG doesn't support requested feature: CPUID.07H:EBX.erms [bit 9]warning: TCG doesn't support requested feature: CPUID.07H:EBX.invpcid [bit 10]warning: TCG doesn't support requested feature: CPUID.07H:EBX.rtm [bit 11]warning: TCG doesn't support requested feature: CPUID.0DH:EAX.xsaveopt [bit 0]warning: TCG doesn't support requested feature: CPUID.01H:EDX.vme [bit 1]warning: TCG doesn't support requested feature: CPUID.01H:ECX.fma [bit 12]warning: TCG doesn't support requested feature: CPUID.01H:ECX.pcid [bit 17]warning: TCG doesn't support requested feature: CPUID.01H:ECX.x2apic [bit 21]warning: TCG doesn't support requested feature: CPUID.01H:ECX.tsc-deadline [bit 24]warning: TCG doesn't support requested feature: CPUID.01H:ECX.xsave [bit 26]warning: TCG doesn't support requested feature: CPUID.01H:ECX.avx [bit 28]warning: TCG doesn't support requested feature: CPUID.01H:ECX.f16c [bit 29]warning: TCG doesn't support requested feature: CPUID.01H:ECX.rdrand [bit 30]warning: TCG doesn't support requested feature: CPUID.07H:EBX.fsgsbase [bit 0]warning: TCG doesn't support requested feature: CPUID.07H:EBX.hle [bit 4]warning: TCG doesn't support requested feature: CPUID.07H:EBX.avx2 [bit 5]warning: TCG doesn't support requested feature: CPUID.07H:EBX.erms [bit 9]warning: TCG doesn't support requested feature: CPUID.07H:EBX.invpcid [bit 10]warning: TCG doesn't support requested feature: CPUID.07H:EBX.rtm [bit 11]warning: TCG doesn't support requested feature: CPUID.0DH:EAX.xsaveopt [bit 0]warning: TCG doesn't support requested feature: CPUID.01H:EDX.vme [bit 1]warning: TCG doesn't support requested feature: CPUID.01H:ECX.fma [bit 12]warning: TCG doesn't support requested feature: CPUID.01H:ECX.pcid [bit 17]warning: TCG doesn't support requested feature: CPUID.01H:ECX.x2apic [bit 21]warning: TCG doesn't support requested feature: CPUID.01H:ECX.tsc-deadline [bit 24]warning: TCG doesn't support requested feature: CPUID.01H:ECX.xsave [bit 26]warning: TCG doesn't support requested feature: CPUID.01H:ECX.avx [bit 28]warning: TCG doesn't support requested feature: CPUID.01H:ECX.f16c [bit 29]warning: TCG doesn't support requested feature: CPUID.01H:ECX.rdrand [bit 30]warning: TCG doesn't support requested feature: CPUID.07H:EBX.fsgsbase [bit 0]warning: TCG doesn't support requested feature: CPUID.07H:EBX.hle [bit 4]warning: TCG doesn't support requested feature: CPUID.07H:EBX.avx2 [bit 5]warning: TCG doesn't support requested feature: CPUID.07H:EBX.erms [bit 9]warning: TCG doesn't support requested feature: CPUID.07H:EBX.invpcid [bit 10]warning: TCG doesn't support requested feature: CPUID.07H:EBX.rtm [bit 11]warning: TCG doesn't support requested feature: CPUID.0DH:EAX.xsaveopt [bit 0]Features: fpu sse sse2 sse3 ssse3 sse4.1 sse4.2 mmx fxsr aesni smep smap syscall nx rdtscpwelcome to lk/MPboot args 0x1 0x80 0x0 0x0INIT: cpu 0, calling hook 0xffffffff801306e4 (version) at level 0x3ffff, flags 0x1version:        arch:     X86        platform: PC        target:   PC_X86        project:  MAGENTA_PC_X86_64        buildid:  _LOCALINIT: cpu 0, calling hook 0xffffffff8014f29c (vm_preheap) at level 0x3ffff, flags 0x1initializing heapcalling constructorsINIT: cpu 0, calling hook 0xffffffff8014f2e4 (vm_post_ctors) at level 0x40000, flags 0x1INIT: cpu 0, calling hook 0xffffffff8014f2ec (vm) at level 0x50000, flags 0x1INIT: cpu 0, calling hook 0xffffffff801009e0 (acpi_tables) at level 0x50001, flags 0x1INIT: cpu 0, calling hook 0xffffffff801047d0 (display_memtype) at level 0x50001, flags 0x1INIT: cpu 0, calling hook 0xffffffff80103658 (hpet) at level 0x50002, flags 0x1INIT: cpu 0, calling hook 0xffffffff801037c0 (apic) at level 0x50002, flags 0x1INIT: cpu 0, calling hook 0xffffffff801050cc (timer) at level 0x50003, flags 0x1calibrate_apic_timer:231: Calibrating APIC with HPETinitializing mpinitializing threadsinitializing timersinitializing portsINIT: cpu 0, calling hook 0xffffffff8011c7c8 (intel_hda_init) at level 0x60000, flags 0x1INIT: cpu 0, calling hook 0xffffffff8012568c (debuglog) at level 0x6ffff, flags 0x1creating bootstrap completion thread[00000.003] K top of bootstrap2()[00000.003] K INIT: cpu 0, calling hook 0xffffffff80157bd0 (global_prng) at level 0x70000, flags 0x1[00000.004] K WARNING: System has no entropy source.  It is completely unsafe to use this system for any cryptographic applications.[00000.004] K INIT: cpu 0, calling hook 0xffffffff8015fd30 (magenta) at level 0x70000, flags 0x1[00000.008] K INIT: cpu 0, calling hook 0xffffffff801d2014 (dpc) at level 0x70000, flags 0x1[00000.016] K initializing platform[00000.018] K Found 4 cpus[00000.019] K creating idle thread for cpu 1[00000.022] K creating idle thread for cpu 2[00000.023] K creating idle thread for cpu 3running final init tasks on cpu 2entering scheduler on cpu 2running final init tasks on cpu 3entering scheduler on cpu 3running final init tasks on cpu 1entering scheduler on cpu 1[00001.533] K acpi_ec_init:98: Failed to find EC: 0[00001.579] K initializing target[00001.581] K calling apps_init()[00001.581] K INIT: cpu 0, calling hook 0xffffffff801003a8 (pixel2_quirks) at level 0xa000a, flags 0x1[00001.583] K INIT: cpu 0, calling hook 0xffffffff8012fc00 (userboot) at level 0xaffff, flags 0x1[00001.583] K userboot: console init[00001.584] K userboot: bootfs          2289664 @ 0xffffffff8023d000[00001.595] K userboot: userboot-rodata       0 @ [0x1000000,0x1002000)[00001.596] K userboot: userboot-code    0x2000 @ [0x1002000,0x1004000)[00001.596] K userboot: vdso-rodata           0 @ [0x1004000,0x1006000)[00001.596] K userboot: vdso-code        0x2000 @ [0x1006000,0x1007000)[00001.599] K userboot: entry point             @ 0x10026e0[00001.619] U userboot: searching bootfs for "bin/devmgr"[00001.625] U userboot: bin/devmgr has PT_INTERP "lib/ld.so.1"[00001.627] U userboot: searching bootfs for "lib/ld.so.1"[00001.656] U Loaded at [0x11ac000,0x11e5000): <application>[00001.657] U Loaded at [0x1000000,0x10a8000): libc.so[00001.660] U devmgr: main()[00001.664] U devmgr: vfs init[00001.669] U devmgr: bootfs #0 contains 69 files[00001.683] U devmgr: load drivers[00001.683] U console_init()[00001.692] U debug_reader()[00001.717] U devmgr: remote(0x171fd40) for 'devhost:pci#1:1234:1111'[00001.720] U devmgr: launch: devhost:pci#1:1234:1111 pci=1 0x11de000[00002.042] U devmgr: remote(0x1720140) for 'devhost:pci#2:8086:100e'[00002.044] U devmgr: launch: devhost:pci#2:8086:100e pci=2 0x11de140[00002.083] U devhost: pci host 1[00002.286] U devmgr: remote(0x1720e20) for 'devhost:pci#4:8086:2922'[00002.289] U devmgr: launch: devhost:pci#4:8086:2922 pci=4 0x11de320[00002.318] U devhost: pci host 2[00002.485] U devfs: vn 0x1721020 destroyed[00002.497] U devmgr: shell startup[00002.515] U eth: using legacy irq mode[00002.523] U eth: mac: 52:54:00:12:34:56[00002.531] U eth: iomem @0x1208000 (phys fb7000)[00002.540] U devmgr: launch /boot/bin/mxsh on /dev/console[00002.550] U devhost: pci host 4[00002.550] U initialized vc on display bochs_vbe, width=1024 height=768 stride=1024 format=1[00002.585] U vc: input thread started for /dev/class/input/000[00002.782] U devmgr: launch /boot/bin/netsvc on /dev/console[00002.847] U dlsvc: debug: Loaded at [0x11ac000,0x11b3000): /boot/bin/mxsh[00002.847] U dlsvc: debug: Loaded at [0x11b3000,0x11c0000): libmxio.so[00002.848] U dlsvc: debug: Loaded at [0x11c0000,0x11c7000): liblaunchpad.so[00002.848] U dlsvc: debug: Loaded at [0x11c7000,0x11ca000): libmagenta.so[00002.850] U dlsvc: debug: Loaded at [0x1000000,0x10a8000): libc.soMXCONSOLE...> [00002.923] U devmgr: launch /boot/bin/mxsh on debuglog[00003.002] U dlsvc: debug: Loaded at [0x11ac000,0x11b1000): /boot/bin/netsvc[00003.005] U dlsvc: debug: Loaded at [0x11b1000,0x11be000): libmxio.so[00003.005] U dlsvc: debug: Loaded at [0x11be000,0x11c5000): liblaunchpad.so[00003.005] U dlsvc: debug: Loaded at [0x11c5000,0x11c8000): libmagenta.so[00003.006] U dlsvc: debug: Loaded at [0x1000000,0x10a8000): libc.sonetsvc: main()[00003.081] U devmgr: vc startup[00003.147] U devmgr: launch /boot/bin/mxsh on /dev/class/console/vc[00003.158] U dlsvc: debug: Loaded at [0x11ac000,0x11b3000): /boot/bin/mxsh[00003.158] U dlsvc: debug: Loaded at [0x11b3000,0x11c0000): libmxio.so[00003.158] U dlsvc: debug: Loaded at [0x11c0000,0x11c7000): liblaunchpad.so[00003.158] U dlsvc: debug: Loaded at [0x11c7000,0x11ca000): libmagenta.so[00003.159] U dlsvc: debug: Loaded at [0x1000000,0x10a8000): libc.so[00003.162] U cannot open '/boot/autorun'macaddr: 52:54:00:12:34:56ip6addr: fe80::5054:ff:fe12:3456snmaddr: ff02::1:ff12:3456netsvc: start[00003.279] U devmgr: launch /boot/bin/mxsh on /dev/class/console/vc[00003.293] U dlsvc: debug: Loaded at [0x11ac000,0x11b3000): /boot/bin/mxsh[00003.294] U dlsvc: debug: Loaded at [0x11b3000,0x11c0000): libmxio.so[00003.295] U dlsvc: debug: Loaded at [0x11c0000,0x11c7000): liblaunchpad.so[00003.297] U dlsvc: debug: Loaded at [0x11c7000,0x11ca000): libmagenta.so[00003.299] U dlsvc: debug: Loaded at [0x1000000,0x10a8000): libc.so[00003.397] U devmgr: launch /boot/bin/mxsh on /dev/class/console/vc[00003.419] U dlsvc: debug: Loaded at [0x11ac000,0x11b3000): /boot/bin/mxsh[00003.420] U dlsvc: debug: Loaded at [0x11b3000,0x11c0000): libmxio.so[00003.420] U dlsvc: debug: Loaded at [0x11c0000,0x11c7000): liblaunchpad.so[00003.421] U dlsvc: debug: Loaded at [0x11c7000,0x11ca000): libmagenta.so[00003.422] U dlsvc: debug: Loaded at [0x1000000,0x10a8000): libc.so[00003.540] U dlsvc: debug: Loaded at [0x11ac000,0x11b3000): /boot/bin/mxsh[00003.540] U dlsvc: debug: Loaded at [0x11b3000,0x11c0000): libmxio.so[00003.541] U dlsvc: debug: Loaded at [0x11c0000,0x11c7000): liblaunchpad.so[00003.542] U dlsvc: debug: Loaded at [0x11c7000,0x11ca000): libmagenta.so[00003.543] U dlsvc: debug: Loaded at [0x1000000,0x10a8000): libc.so

这样便启动了magenta内核

执行一下help命令

> helpcd        change directorycp        copy a filedump      display a file in hexadecimalecho      print its argumentshelp      list built-in shell commandsdm        send command to device managerlist      display a text file with line numbersls        list directory contentsrm        delete a fileruntests  run all test programsmsleep    pause for milliseconds<program> run <program>`command  send command to kernel console

ls

> lsd        0 devd        0 bootd        0 tmpd        0 data> > ls /devd        0 classc        0 consolec        0 i8042-keyboardc        0 rtcd        0 pcic        0 nullc        0 dmctl> > ls /bootd        0 bind        0 docsd        0 libd        0 srcd        0 test> > > ls /boot/bin-     5608 bad-kernel-access-test-crashes-     5536 blktest-     5608 clock-   178600 core-tests-     5920 crasher-   230168 devmgr-     5536 dlog-     5608 dump1-     9704 evil-tests-     9632 gpt-    13960 hid-     9704 i2c-    18320 kilo-     9704 launch-     9632 lsblk-     5536 msd-test-    22456 mxsh-    13952 netsvc-     5536 reply-handle-helper-     5608 rng-trials-     5536 run-vc-     9848 strerror-   119712 test-driver-     9704 thread-depth-test-     5608 tpmctl> 

可以尝试着执行一些/boot/bin目录下的一些命令

比如

> crasher[00518.489] U dlsvc: debug: Loaded at [0x11ac000,0x11af000): /boot/bin/crasher[00518.489] U dlsvc: debug: Loaded at [0x11af000,0x11bc000): libmxio.so=@0518.489] U dlsvc: debug: Loaded at [0x1000000,0x10a8000): libc.so crasher @= U dlsvc: debug: Loaded at [0x11bc000,0x11bf000): libmagenta.sodefault to write0  (use 'help' for more options).[00518.501] K KERN: fatal page fault in magenta thread '/boot/bin/crasher:main' in process '/boot/bin/crasher' at IP 0x11ac6f0[00518.501] K <PAGE FAULT> Instruction Pointer   = 0x33:0x11ac6f0[00518.501] K <PAGE FAULT> Stack Pointer         = 0x2b:0x11aae48[00518.501] K <PAGE FAULT> Fault Linear Address  = 0x0[00518.501] K <PAGE FAULT> Error Code Value      = 0x6[00518.501] K <PAGE FAULT> Error Code Type       = user write data, page not present[00518.501] K  CS:                0x33 RIP:          0x11ac6f0 EFL:              0x246 CR2:                  0[00518.501] K  RAX:                  0 RBX:                0x1 RCX:                  0 RDX:          0x10a7628[00518.501] K  RSI:                0x1 RDI:                  0 RBP:          0x11aae70 RSP:          0x11aae48[00518.501] K   R8: 0xffffff9000086bc0  R9: 0xffffff80008bd398 R10:                  0 R11:          0x11aae78[00518.501] K  R12:          0x11aaeb0 R13:          0x11aae80 R14:                0x1 R15:          0x11ac600[00518.501] K errc:                0x6[00518.501] K bottom of user stack at 0x11aae48:[00518.501] K 0x011aae48: 011ac6e3 00000000 011aae70 00000000 |........p.......|[00518.501] K 0x011aae58: 011aafd0 00000000 011aaeb0 00000000 |................|[00518.501] K 0x011aae68: 0101df0f 00000000 011aaf20 00000000 |........ .......|[00518.501] K 0x011aae78: 00000000 00000000 011aaf32 00000000 |........2.......|[00518.501] K 0x011aae88: 00000000 00000000 00000000 00000000 |................|[00518.501] K 0x011aae98: 00000000 00000000 011aaf78 00000000 |........x.......|[00518.501] K 0x011aaea8: 00000030 00000000 00000000 568c989d |0..............V|[00518.501] K 0x011aaeb8: 00000000 00000000 568c95d5 00000000 |...........V....|[00518.501] K 0x011aaec8: 568c97f5 00000000 568c99c5 00000000 |...V.......V....|[00518.501] K 0x011aaed8: 00000000 00000000 4150585d 00001000 |........]XPA....|[00518.501] K 0x011aaee8: 0000001c 00000040 00000001 00000052 |....@.......R...|[00518.501] K 0x011aaef8: 00000001 00000000 00000002 00000000 |................|[00518.501] K 0x011aaf08: 00000000 00000000 00000000 00000000 |................|[00518.501] K 0x011aaf18: 00000000 00000000 6f6f622f 69622f74 |......../boot/bi|[00518.501] K 0x011aaf28: 72632f6e 65687361 444c0072 4245445f |n/crasher.LD_DEB|[00518.501] K 0x011aaf38: 313d4755 00000000 00000018 00000000 |UG=1............|[process(73290ced): status: -1]

最后按Ctrl +a    x  退出模拟器



0 0