$ find . -name "*.S" | wc -l
1235
可以看到在Linux kernel 3.1的内核中,有上千个.S文件。
这些文件多数分布在arch/下各个体系结构中。
如下是X86的.S文件:
./arch/x86/power/hibernate_asm_64.S
./arch/x86/power/hibernate_asm_32.S
./arch/x86/boot/compressed/head_32.S
./arch/x86/boot/compressed/vmlinux.lds.S
./arch/x86/boot/compressed/head_64.S
./arch/x86/boot/bioscall.S
./arch/x86/boot/header.S
./arch/x86/boot/pmjump.S
./arch/x86/boot/copy.S
./arch/x86/net/bpf_jit.S
./arch/x86/vdso/vdso-layout.lds.S
./arch/x86/vdso/vdso.S
./arch/x86/vdso/vdso32.S
./arch/x86/vdso/vdso.lds.S
./arch/x86/vdso/vdso-note.S
./arch/x86/vdso/vdso32/syscall.S
./arch/x86/vdso/vdso32/note.S
./arch/x86/vdso/vdso32/sysenter.S
./arch/x86/vdso/vdso32/sigreturn.S
./arch/x86/vdso/vdso32/vdso32.lds.S
./arch/x86/vdso/vdso32/int80.S
./arch/x86/math-emu/div_small.S
./arch/x86/math-emu/reg_u_mul.S
./arch/x86/math-emu/reg_u_sub.S
./arch/x86/math-emu/wm_sqrt.S
./arch/x86/math-emu/div_Xsig.S
./arch/x86/math-emu/shr_Xsig.S
./arch/x86/math-emu/polynom_Xsig.S
./arch/x86/math-emu/round_Xsig.S
./arch/x86/math-emu/reg_round.S
./arch/x86/math-emu/reg_u_add.S
./arch/x86/math-emu/mul_Xsig.S
./arch/x86/math-emu/reg_u_div.S
./arch/x86/math-emu/reg_norm.S
./arch/x86/math-emu/wm_shrx.S
./arch/x86/xen/xen-asm_32.S
./arch/x86/xen/xen-head.S
./arch/x86/xen/xen-asm.S
./arch/x86/xen/xen-asm_64.S
./arch/x86/lguest/i386_head.S
./arch/x86/crypto/aesni-intel_asm.S
./arch/x86/crypto/aes-i586-asm_32.S
./arch/x86/crypto/ghash-clmulni-intel_asm.S
./arch/x86/crypto/salsa20-x86_64-asm_64.S
./arch/x86/crypto/aes-x86_64-asm_64.S
./arch/x86/crypto/salsa20-i586-asm_32.S
./arch/x86/crypto/twofish-x86_64-asm_64.S
./arch/x86/crypto/twofish-i586-asm_32.S
./arch/x86/kernel/relocate_kernel_32.S
./arch/x86/kernel/head_32.S
./arch/x86/kernel/relocate_kernel_64.S
./arch/x86/kernel/reboot_32.S
./arch/x86/kernel/syscall_table_32.S
./arch/x86/kernel/vmlinux.lds.S
./arch/x86/kernel/trampoline_32.S
./arch/x86/kernel/trampoline_64.S
./arch/x86/kernel/entry_64.S
./arch/x86/kernel/vsyscall_emu_64.S
./arch/x86/kernel/head_64.S
./arch/x86/kernel/verify_cpu.S
./arch/x86/kernel/entry_32.S
./arch/x86/kernel/acpi/realmode/wakeup.lds.S
./arch/x86/kernel/acpi/realmode/bioscall.S
./arch/x86/kernel/acpi/realmode/wakeup.S
./arch/x86/kernel/acpi/realmode/copy.S
./arch/x86/kernel/acpi/wakeup_32.S
./arch/x86/kernel/acpi/wakeup_rm.S
./arch/x86/kernel/acpi/wakeup_64.S
./arch/x86/platform/olpc/xo1-wakeup.S
./arch/x86/platform/efi/efi_stub_32.S
./arch/x86/platform/efi/efi_stub_64.S
./arch/x86/lib/memcpy_64.S
./arch/x86/lib/cmpxchg8b_emu.S
./arch/x86/lib/rwlock.S
./arch/x86/lib/iomap_copy_64.S
./arch/x86/lib/atomic64_386_32.S
./arch/x86/lib/copy_page_64.S
./arch/x86/lib/memmove_64.S
./arch/x86/lib/thunk_32.S
./arch/x86/lib/copy_user_nocache_64.S
./arch/x86/lib/rwsem.S
./arch/x86/lib/cmpxchg16b_emu.S
./arch/x86/lib/clear_page_64.S
./arch/x86/lib/memset_64.S
./arch/x86/lib/msr-reg.S
./arch/x86/lib/atomic64_cx8_32.S
./arch/x86/lib/getuser.S
./arch/x86/lib/csum-copy_64.S
./arch/x86/lib/thunk_64.S
./arch/x86/lib/putuser.S
./arch/x86/lib/copy_user_64.S
./arch/x86/lib/checksum_32.S
./arch/x86/ia32/ia32entry.S
可以发现休眠、启动、数学运算、虚拟机支持、加密、锁机制、系统调用有关。
这些功能之所以使用汇编而非普通C语言,有两方面的原因
实现特权控制
加速