More Related Content
Similar to x86 CPUにejectコマンドを組み込みたい!
Similar to x86 CPUにejectコマンドを組み込みたい! (9)
More from furandon_pig (9)
x86 CPUにejectコマンドを組み込みたい!
- 6. が...(pushaの置き換えでは)ダメっ...!
$ objdump -d /netbsd
c010c758 <i8259_stubs>:
c010c758: 40 inc %eax
...
c010c7a8: 60 pusha
c010c7a9: 1f pop %ds
c010c7aa: 10 c0 adc %al,%al
c010c7ac: 60 pusha
上手いこと他とぶつからない命令にしないと...。
- 7. CPUID命令(eject用)(1/2)
cpuid命令にejectを組み込むのが良さそう。
diff -ur qemu-2.1.3.orig/target-i386/cpu.c qemu-2.1.3/target-i386/cpu.c
--- qemu-2.1.3.orig/target-i386/cpu.c 2015-01-23 01:19:06.000000000 +0900
+++ qemu-2.1.3/target-i386/cpu.c 2015-02-14 18:17:34.000000000 +0900
@@ -2192,7 +2192,7 @@
}
}
} else {
- if (index > env->cpuid_level)
+ if (index > env->cpuid_level && index != 0x25252)
index = env->cpuid_level;
}
@@ -2375,6 +2375,9 @@
}
break;
}
+ case 0x25252:
+ system("eject /dev/cd0a");
+ break;
case 0x80000000:
*eax = env->cpuid_xlevel;
*ebx = env->cpuid_vendor1;
- 8. CPUID命令(eject用)(2/2)
EAXレジスタのパラメータに0x25252を指定することでejectを実
行する。
# gcc -nostdlib -g -o eject_instruction eject_instruction.s
.section ".note.netbsd.ident", "a"
.int 7
.int 4
.int 0x01
.ascii "NetBSD00"
.int 0x23b419a0
.section ".text"
.balign 4
.globl _start
.type _start, @function
_start:
# execute eject command.
movl $0x25252, %eax
cpuid
# exit(EXIT_SUCCESS)
movl $0x0, (%esp)
movl $0x1, %eax
int $0x80
ret