Complete Linux kernel analysis --- math_emulate.c program

Source: Internet
Author: User
All functions in the math_emulatec program can be divided into three parts: the first class is the interface function math_emulate () of the exception handler that does not exist in the device, and the second class is the floating point instruction imitation.

All functions in the math_emulate.c program can be divided into three parts: the first class is the interface function math_emulate () of the exception handler that does not exist on the device, only this function; the second type is the main function do_emu () for floating point instruction simulation and processing, and there is only one function. In addition, all the functions are simulation-assisted functions, including the functions in other C language programs.

In a PC that does not contain a 80387 coprocessor chip, if the simulation Mark EM = 1 is set in CR0 during kernel initialization, when the CPU encounters a floating point instruction, it will cause the CPU to interrupt int 7 abnormally and call the math_emulate (long ___ false) function at Line 1 of the program during the interrupt processing.

In the math_emulate () function, if it is determined that the current process has not used the simulated co-processing operation, the simulation 80387 control Word, state Word and Tag Word will be used) initialize, set all 6 types of coprocessor exception tolerance characters in the control word, reset the status word and feature word, and then call the simulation processing main function do_emu (), the parameter used is the return address pointer of the math_emulate () function called during the interrupt processing of the info structure below, the info structure is actually a structure consisting of some data that is gradually imported into the stack after the int7 interrupt is generated from the CPU in the stack. Therefore, it is basically the same as the distribution of data in the kernel stack during system calls, for more information, see the "include/linux/math_emu.h" and "kernel/sys_call.s" sections.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.