Method and device for efficiently reading and writing system register in operating system kernel

By generating unique identification parameters of system registers and directly generating machine code, the cumbersome problem of system register reading and writing process under the ARMv8-AArch64 architecture is solved, and efficient system register management is achieved.

CN119556984APending Publication Date: 2025-03-04HUNAN ZETIAN ZHIHANG ELECTRONIC TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411601973.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-11
Publication Date
2025-03-04

AI Technical Summary

Technical Problem

The prior art under the ARMv8-AArch64 architecture, the reading and writing process of system registers is cumbersome and inefficient. It requires operation through MRS and MSR instructions, and the instruction conversion is complicated.

Method used

By obtaining system register information, the corresponding system register unique identification parameters are generated, and the machine code of the MRS or MSR instruction is directly generated based on this parameter, and the machine code is executed to achieve efficient reading and writing system registers.

Benefits of technology

It improves the read and write efficiency of system registers in the operating system kernel, reduces working time, and simplifies the instruction conversion process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119556984A_ABST
    Figure CN119556984A_ABST
Patent Text Reader

Abstract

The invention discloses a method and a device for efficiently reading and writing a system register in an operating system kernel. The method comprises the following steps: acquiring system register information; generating a unique identification parameter of a corresponding system register according to the obtained system register information; generating a machine code corresponding to the MRS instruction or the MSR instruction according to the unique identification parameter; and executing the machine code, and returning an executed result to the caller. According to the unique identification information of each system register, the machine code of the read-write operation of the system register is directly generated without the steps of instruction conversion and the like; and then the operating system kernel executes the machine code during running, so that the system register can be directly read and written, and the management of the CPU is completed, thereby improving the working efficiency of reading and writing the system register in the kernel and saving the working time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of register technology, and in particular discloses a method and a device for efficiently reading and writing system registers in an operating system kernel. Background Art

[0002] In the ARMv8-AArch64 architecture, registers are mainly divided into general registers, status registers, special registers, and system registers. System registers are used to control and manage key system functions such as the CPU's operating mode, privilege level, memory management, and interrupt processing. Reading and writing system registers are essential operations in the kernel. However, ordinary data processing or load / store assembly instructions cannot directly operate system registers. The contents of the system register must be read into the general register Xn, operated on, and then written back to the system register. This process requires the use of two instructions specifically used to access system registers, MRS (system register read instruction) and MSR (system register write instruction). When using MRS and MSR instructions, you need to attach the name of the system register you want to operate after it. The names of different registers are also different. In addition, MRS and MSR instructions are pseudo-instructions in the ARM assembly instruction set. They need to be converted into instructions by the compiler, and the instructions themselves must also be converted into machine code before they can be executed. Therefore, using the above conventional methods to read and write system registers in the kernel is very cumbersome and inefficient.

[0003] Therefore, the above defects existing in the existing system registers when reading and writing are technical problems that need to be solved urgently. Summary of the invention

[0004] The present invention provides a method and device for efficiently reading and writing system registers in an operating system kernel, aiming to solve at least one defect existing in the reading and writing of the above-mentioned existing system registers.

[0005] One aspect of the present invention relates to a method for efficiently reading and writing system registers in an operating system kernel, comprising the following steps:

[0006] Get system register information;

[0007] Generate a unique identification parameter of the corresponding system register according to the acquired system register information;

[0008] Generate machine code corresponding to the MRS instruction or MSR instruction based on the unique identification parameter;

[0009] Execute machine code and return the result to the caller.

[0010] Furthermore, obtaining system register information includes:

[0011] Consult the register architecture manual;

[0012] Get information about all system registers in the AArch64 architecture from the Register Architecture Manual.

[0013] Furthermore, the step of generating a unique identification parameter of a corresponding system register according to the acquired system register information includes:

[0014] According to the obtained system register information, determine the corresponding values ​​of the op0, op1, op2, CRn and CRm fields of any system register;

[0015] The corresponding values ​​of the op0, op1, op2, CRn and CRm fields are concatenated according to the corresponding offsets to generate a unique identifier for the corresponding system register.

[0016] Furthermore, the step of generating a machine code corresponding to the MRS instruction according to the unique identification parameter includes:

[0017] All general registers Xn are predefined by the read system register macro, and the general registers Xn are used to receive the unique identification parameter passed by the caller;

[0018] The splicing is completed according to the unified format preset by the MRS instruction, and the first machine code corresponding to the MRS instruction is directly generated; and the first machine code is inserted into the operating system kernel.

[0019] Furthermore, the step of generating a machine code corresponding to the MSR instruction according to the unique identification parameter includes:

[0020] All general registers Xn are predefined by writing system register macros, and general registers Xn are used to receive the unique identification parameter passed by the caller and the value parameter to be written by the kernel;

[0021] Write the kernel numerical parameter to be written into the general register Xn, and use the general register Xn as the target register;

[0022] The splicing is completed according to the unified format preset by the MSR instruction, and the second machine code corresponding to the MSR instruction is directly generated; and the second machine code is inserted into the operating system kernel.

[0023] Another aspect of the present invention relates to a device for efficiently reading and writing system registers in an operating system kernel, comprising:

[0024] Acquisition module, used to obtain system register information;

[0025] A first generating module, used to generate a unique identification parameter of a corresponding system register according to the acquired system register information;

[0026] A second generating module is used to generate a machine code corresponding to an MRS instruction or an MSR instruction according to a unique identification parameter;

[0027] The execution module is used to execute machine code and return the execution result to the caller.

[0028] Furthermore, the acquisition module includes:

[0029] A reference unit for referring to the register architecture manual;

[0030] The acquisition unit is used to obtain information about all system registers under the AArch64 architecture from the register architecture manual.

[0031] Furthermore, the first generation module includes:

[0032] A determination unit, used to determine corresponding values ​​of op0, op1, op2, CRn and CRm fields of any system register according to the acquired system register information;

[0033] The first generating unit is used to concatenate corresponding values ​​of the op0, op1, op2, CRn and CRm fields according to corresponding offsets to generate a unique identifier of a corresponding system register.

[0034] Furthermore, the second generation module includes:

[0035] The first receiving unit is used to predefine all general registers Xn by reading the system register macro, and use the general register Xn to receive the unique identification parameter passed by the caller;

[0036] The second generating unit is used to complete the splicing according to the unified format preset by the MRS instruction, directly generate the first machine code corresponding to the MRS instruction, and insert the first machine code into the operating system kernel.

[0037] Furthermore, the second generation module includes:

[0038] The second receiving unit is used to predefine all general registers Xn by writing a system register macro, and use the general register Xn to receive a unique identification parameter passed by the caller, and receive a value parameter to be written by the kernel;

[0039] A writing unit, used for writing the kernel numerical parameter to be written into the general register Xn, and using the general register Xn as the target register;

[0040] The third generating unit is used to complete the splicing according to the unified format preset by the MSR instruction, directly generate the second machine code corresponding to the MSR instruction, and insert the second machine code into the operating system kernel.

[0041] The beneficial effects achieved by the present invention are:

[0042] The present invention provides a method and device for efficiently reading and writing system registers in an operating system kernel, by acquiring system register information; generating a unique identification parameter of a corresponding system register according to the acquired system register information; generating a machine code of a corresponding MRS instruction or MSR instruction according to the unique identification parameter; executing the machine code, and returning the result after execution to the caller. The method and device for efficiently reading and writing system registers in an operating system kernel provided by the present invention directly generates a machine code for a system register read and write operation according to the unique identification information of each system register, without going through steps such as instruction conversion; then the operating system kernel executes the machine code at runtime, and can directly read and write the system register to complete the management of the CPU, thereby improving the work efficiency of reading and writing the system register in the kernel and saving work time. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] Figure 1 The present invention is a flowchart of an embodiment of a method for efficiently reading and writing system registers in an operating system kernel. DETAILED DESCRIPTION

[0044] In order to better understand the above technical solution, the above technical solution will be described in detail below in conjunction with the accompanying drawings and specific implementation methods.

[0045] like Figure 1 As shown, the first embodiment of the present invention provides a method for efficiently reading and writing system registers in an operating system kernel, comprising the following steps:

[0046] Step S100: Obtain system register information.

[0047] Refer to the register architecture manual officially provided by ARM to obtain information about all system registers under the AArch64 architecture.

[0048] Step S200: Generate a unique identification parameter of a corresponding system register according to the acquired system register information.

[0049] According to the obtained system register information, the corresponding values ​​of the system register fields are determined, and then the corresponding values ​​of the fields are concatenated according to the corresponding offsets. After the concatenation is completed, the unique identification parameter of the corresponding system register can be generated.

[0050] Step S300: Generate a machine code corresponding to the MRS instruction or the MSR instruction according to the unique identification parameter.

[0051] The read system register macro or the write system register macro receives the unique identification parameter passed by the caller and generates the machine code of the corresponding MRS instruction or MSR instruction in the kernel.

[0052] Step S400: execute the machine code and return the result of the execution to the caller.

[0053] The kernel executes the machine code corresponding to the MRS instruction or MSR instruction and returns the result to the caller.

[0054] Further, see Figure 1 , the method for efficiently reading and writing system registers in the operating system kernel proposed in this embodiment, step S100 includes:

[0055] Step S110: consult the register architecture manual.

[0056] Refer to the register architecture manual provided by ARM.

[0057] Step S120: Obtain information of all system registers under the AArch64 architecture from the register architecture manual.

[0058] According to the register architecture manual, obtain information about all system registers under the AArch64 architecture.

[0059] Preferably, see Figure 1 The method for efficiently reading and writing system registers in the operating system kernel proposed in this embodiment, step S200 includes:

[0060] Step S210: Determine corresponding values ​​of the op0, op1, op2, CRn and CRm fields of any system register according to the acquired system register information.

[0061] Based on the information of all system registers under the AArch64 architecture, the corresponding values ​​of the op0 (highest category of encoding space), op1 (lowest accessible privilege level), CRn (system register major category), CRm (system register minor category), and op2 (instruction form) fields of any system register are determined.

[0062] Step S220: Concatenate the corresponding values ​​of the op0, op1, op2, CRn and CRm fields according to the corresponding offsets to generate a unique identifier for the corresponding system register.

[0063] The corresponding values ​​of the op0, op1, op2, CRn and CRm fields are concatenated according to the corresponding offsets. The field concatenation is achieved through an OR operation. After the concatenation is completed, the unique identifier of the corresponding system register can be generated.

[0064] Furthermore, the method for efficiently reading and writing system registers in an operating system kernel proposed in this embodiment, step S300 includes:

[0065] Step S310: predefine all general registers Xn by reading the system register macro, and use the general registers Xn to receive the unique identification parameter passed by the caller.

[0066] The read system register macro predefines all general registers Xn, and the general register Xn receives the unique identification parameter passed by the caller.

[0067] Step S320, complete the splicing according to the unified format preset by the MRS instruction, directly generate the first machine code corresponding to the MRS instruction; and insert the first machine code into the operating system kernel.

[0068] The MRS instruction is used to copy the data of the system register to the target register. It consists of three parts: operation code, system register, and target register. The operation code is a fixed value and is used to confirm which instruction is currently being executed. Therefore, it is only necessary to splice the system register and the target register on its basis. The splicing method also uses the OR operation. The system register is the unique identifier generated before, and the target register usually uses the general register Xn.

[0069] The principle of reading the system register macro is to directly generate machine code based on the above MRS instruction composition and insert it into the kernel. First, define all the general registers Xn, receive the unique identification parameters passed in, and then complete the splicing according to the above unified format, directly generate the machine code corresponding to the MRS instruction, insert it into the system kernel through the .inst assembly instruction, execute the machine code when the kernel is running, and the result of the execution will be returned to the caller through the general register Xn.

[0070] Preferably, the method for efficiently reading and writing system registers in an operating system kernel proposed in this embodiment, step S300 includes:

[0071] Step S330: predefine all general registers Xn by writing the system register macro, and use the general registers Xn to receive the unique identification parameter passed by the caller, and receive the numerical parameter to be written by the kernel.

[0072] The write system register macro predefines all general registers Xn, and the general register Xn receives the unique identification parameter passed by the caller and the numerical parameter to be written by the kernel.

[0073] Step S340: Write the kernel numerical parameter to be written into the general register Xn, and use the general register Xn as the target register.

[0074] Compared with the read system register macro, the write system register macro also needs to receive the value to be written by the kernel. The value to be written by the kernel can be obtained in the form of parameters.

[0075] Step S350: complete the splicing according to the preset unified format of the MSR instruction, directly generate the second machine code corresponding to the MSR instruction; and insert the second machine code into the operating system kernel.

[0076] The MSR instruction copies the data in the target register to the system register. The composition of the MSR instruction is consistent with the MRS instruction. However, compared with the read system register macro, the write system register macro also needs to receive the value to be written by the kernel. The value to be written by the kernel can be obtained in the form of parameters. Specifically, the parameters are first written to the general register Xn, and then the general register Xn is used as the target register. The subsequent process is consistent with the read system register macro. By using inline assembly to define the above-mentioned read and write macros for system registers, the caller passes the defined system register unique identifier to the macro, and then generates the machine code for reading and writing the system register in the kernel, and efficiently reads and writes the system register through the machine code.

[0077] The present invention relates to a device for efficiently reading and writing system registers in an operating system kernel, comprising an acquisition module, a first generation module, a second generation module and an execution module, wherein the acquisition module is used to acquire system register information; the first generation module is used to generate a unique identification parameter of a corresponding system register according to the acquired system register information; the second generation module is used to generate a machine code of a corresponding MRS instruction or an MSR instruction according to the unique identification parameter; and the execution module is used to execute the machine code and return the result after execution to the caller.

[0078] The acquisition module refers to the register architecture manual officially provided by ARM to obtain information about all system registers under the AArch64 architecture.

[0079] The first generating module determines the corresponding values ​​of the system register fields according to the acquired system register information, and then concatenates the corresponding values ​​of the fields according to the corresponding offsets. After the concatenation is completed, the unique identification parameter of the corresponding system register can be generated.

[0080] The second generation module uses the read system register macro or the write system register macro to receive the unique identification parameter passed by the caller, and generates the machine code corresponding to the MRS instruction or the MSR instruction in the kernel.

[0081] The execution module executes the machine code corresponding to the MRS instruction or the MSR instruction through the kernel and returns the result of the execution to the caller.

[0082] Further, see Figure 1This embodiment provides a device for efficiently reading and writing system registers in an operating system kernel. The acquisition module includes a reference unit and an acquisition unit. The reference unit is used to refer to the register architecture manual; the acquisition unit is used to obtain information of all system registers under the AArch64 architecture from the register architecture manual.

[0083] Refer to the register architecture manual provided by ARM.

[0084] The acquisition unit obtains information of all system registers under the AArch64 architecture according to the register architecture manual.

[0085] Preferably, see Figure 1 , this embodiment provides a device for efficiently reading and writing system registers in an operating system kernel, wherein a first generation module includes a determination unit and a first generation unit, wherein the determination unit is used to determine the corresponding values ​​of the op0, op1, op2, CRn and CRm fields of any system register according to the acquired system register information; the first generation unit is used to splice the corresponding values ​​of the op0, op1, op2, CRn and CRm fields according to the corresponding offset to generate a unique identifier of the corresponding system register.

[0086] The determination unit determines the corresponding values ​​of the op0 (highest category in the encoding space), op1 (lowest accessible privilege level), CRn (system register major category), CRm (system register minor category), and op2 (instruction form) fields of any system register based on the information of all system registers under the AArch64 architecture.

[0087] The first generating unit concatenates the corresponding values ​​of the op0, op1, op2, CRn and CRm fields according to the corresponding offsets. The field concatenation is implemented by an OR operation. After the concatenation is completed, the unique identifier of the corresponding system register can be generated.

[0088] Further, see Figure 1 , this embodiment provides a device for efficiently reading and writing system registers in an operating system kernel, wherein the second generation module includes a first receiving unit and a second generating unit, wherein the first receiving unit is used to predefine all general registers Xn by the read system register macro, and use the general register Xn to receive the unique identification parameter passed by the caller; the second generating unit is used to complete the splicing according to the unified format preset by the MRS instruction, directly generate the first machine code corresponding to the MRS instruction, and insert the first machine code into the operating system kernel.

[0089] The first receiving unit predefines all general registers Xn by using the read system register macro, and the general register Xn receives the unique identification parameter passed by the caller.

[0090] In the second generation unit, the MRS instruction is used to copy the data of the system register to the target register. It consists of three parts: operation code, system register, and target register. The operation code is a fixed value and is used to confirm which instruction is currently being executed. Therefore, it is only necessary to splice the system register and the target register on its basis. The splicing method also uses the OR operation. The system register is the unique identifier generated before, and the target register usually uses the general register Xn.

[0091] Preferably, see Figure 1 , this embodiment provides a device for efficiently reading and writing system registers in an operating system kernel, wherein the second generation module includes a second receiving unit, a writing unit and a third generating unit, wherein the second receiving unit is used to predefine all general registers Xn by writing a system register macro, and use the general register Xn to receive a unique identification parameter passed by a caller, and receive a kernel numerical parameter to be written; the writing unit is used to write the kernel numerical parameter to be written into the general register Xn, and use the general register Xn as a target register; the third generating unit is used to complete splicing according to a unified format preset by an MSR instruction, directly generate a second machine code corresponding to the MSR instruction, and insert the second machine code into the operating system kernel.

[0092] In the second receiving unit, the system register macro is written to predefine all general registers Xn, and the general registers Xn receive the unique identification parameter passed by the caller and the numerical parameter to be written by the kernel.

[0093] In the writing unit, the writing system register macro is different from the reading system register macro and further needs to receive the value to be written by the kernel. The value to be written by the kernel can be obtained in the form of parameters.

[0094] In the third generation unit, the MSR instruction copies the data in the target register to the system register. The composition of the MSR instruction is consistent with the MRS instruction, but the write system register macro is different from the read system register macro. It also needs to receive the value to be written by the kernel. The value to be written by the kernel can be obtained in the form of parameters. Specifically, the parameters are first written to the general register Xn, and then the general register Xn is used as the target register. The subsequent process is consistent with the read system register macro. By using inline assembly to define the above-mentioned read and write macros for the system register, the caller passes the defined system register unique identifier to the macro, and then generates the machine code for reading and writing the system register in the kernel, and efficiently reads and writes the system register through the machine code.

[0095] The method and device for efficiently reading and writing system registers in the operating system kernel provided in this embodiment are specifically implemented by first forming a unique identifier based on the five fields of the system register, and the offset and mask of each field are as follows:

[0096] / *Highest category* /

[0097] const Op0_shift:usize=19;

[0098] const Op0_mask:usize=0x3;

[0099] / *Minimum privilege level that can be accessed* /

[0100] const Op1_shift:usize=16;

[0101] const Op1_mask:usize=0x7;

[0102] / *System register categories* /

[0103] const CRn_shift:usize=12;

[0104] const CRn_mask:usize=0xf;

[0105] / *System register subclass* /

[0106] const CRm_shift:usize=8;

[0107] const CRm_mask:usize=0xf;

[0108] / *Command format* /

[0109] const Op2_shift:usize=5;

[0110] const Op2_mask:usize=0x7;

[0111] According to the above field offset, you can define a function to uniformly generate the unique identifier of any system register. Next, you can call the system register unique identifier generation function and use the function result to define the system register that needs to be operated. The function definition is as follows:

[0112] const fn sys_reg(op0:usize, op1:usize, crn:usize, crm:u

[0113] size,op2:usize)->usize{

[0114] ((op0&Op0_mask)< <Op0_shift)

[0115] |((op1&Op1_mask)< <Op1_shift)

[0116] |((crn&CRn_mask)< <CRn_shift)

[0117] |((crm&CRm_mask)< <CRm_shift)

[0118] |((op2&Op2_mask)< <Op2_shift)

[0119] }

[0120] According to the composition of the two instructions MRS and MSR, we can define read and write macros for system registers by using embedded assembly. The parameter received by the read system register macro is the unique identifier of the system register, and the parameter received by the write system register macro is the unique identifier of the system register and the value to be written. The caller passes the defined unique identifier of the system register or the write parameter to the macro according to the unified parameter format required by the read and write macro, and the machine code for reading and writing the system register can be generated.

[0121] Compared with the prior art, the method and device for efficiently reading and writing system registers in the operating system kernel provided by the present embodiment obtains system register information; generates a unique identification parameter of the corresponding system register based on the obtained system register information; generates a machine code of the corresponding MRS instruction or MSR instruction based on the unique identification parameter; executes the machine code, and returns the result after execution to the caller. The method and device for efficiently reading and writing system registers in the operating system kernel provided by the present embodiment directly generates a machine code for the read and write operation of the system register based on the unique identification information of each system register, without going through steps such as instruction conversion; then the operating system kernel executes the machine code at runtime, and can directly read and write the system register to complete the management of the CPU, thereby improving the work efficiency of reading and writing the system registers in the kernel and saving working time.

[0122] Although preferred embodiments of the present invention have been described, additional changes and modifications may be made to these embodiments by those skilled in the art once the basic inventive concepts are known. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention. Obviously, those skilled in the art may make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.

Claims

1. A method for efficiently reading and writing system registers in an operating system kernel, characterized in that: The following steps are involved: Get system register information; Generate a unique identification parameter of a corresponding system register according to the acquired system register information; Generate a machine code corresponding to the MRS instruction or the MSR instruction according to the unique identification parameter; Execute the machine code and return the result to the caller.

2. The method for efficiently reading and writing system registers in an operating system kernel as claimed in claim 1, characterized in that: Obtaining system register information includes: Consult the register architecture manual; Get information about all system registers in the AArch64 architecture from the register architecture manual.

3. The method for efficiently reading and writing system registers in an operating system kernel as claimed in claim 1, characterized in that: The step of generating a unique identification parameter of a corresponding system register according to the acquired system register information comprises: Determine corresponding values ​​of the op0, op1, op2, CRn and CRm fields of any system register according to the obtained system register information; The corresponding values ​​of the op0, op1, op2, CRn and CRm fields are concatenated according to the corresponding offsets to generate a unique identifier for the corresponding system register.

4. The method for efficiently reading and writing system registers in an operating system kernel according to claim 1, characterized in that: The step of generating a machine code corresponding to the MRS instruction according to the unique identification parameter includes: All general registers Xn are predefined by the read system register macro, and the general registers Xn are used to receive the unique identification parameter passed by the caller; The splicing is completed according to the unified format preset by the MRS instruction, and the first machine code corresponding to the MRS instruction is directly generated; and the first machine code is inserted into the operating system kernel.

5. The method for efficiently reading and writing system registers in an operating system kernel according to claim 1, characterized in that: The step of generating a machine code corresponding to the MSR instruction according to the unique identification parameter comprises: All general registers Xn are predefined by writing system register macros, and general registers Xn are used to receive the unique identification parameter passed by the caller and the value parameter to be written by the kernel; Writing the kernel numerical parameter to be written into the general register Xn, and using the general register Xn as the target register; The splicing is completed according to the unified format preset by the MSR instruction, and the second machine code corresponding to the MSR instruction is directly generated; and the second machine code is inserted into the operating system kernel.

6. A device for efficiently reading and writing system registers in an operating system kernel, characterized in that: include: Acquisition module, used to obtain system register information; A first generating module, used to generate a unique identification parameter of a corresponding system register according to the acquired system register information; A second generating module, used for generating a machine code corresponding to an MRS instruction or an MSR instruction according to the unique identification parameter; The execution module is used to execute the machine code and return the result after execution to the caller.

7. The device for efficiently reading and writing system registers in an operating system kernel according to claim 6, characterized in that: The acquisition module comprises: A reference unit for referring to the register architecture manual; The acquisition unit is used to obtain information of all system registers under the AArch64 architecture from the register architecture manual.

8. The device for efficiently reading and writing system registers in an operating system kernel according to claim 6, characterized in that: The first generation module comprises: a determination unit, configured to determine corresponding values ​​of the op0, op1, op2, CRn and CRm fields of any system register according to the acquired system register information; The first generating unit is used to concatenate corresponding values ​​of the op0, op1, op2, CRn and CRm fields according to corresponding offsets to generate a unique identifier of a corresponding system register.

9. The device for efficiently reading and writing system registers in an operating system kernel according to claim 6, characterized in that: The second generation module comprises: The first receiving unit is used to predefine all general registers Xn by reading the system register macro, and use the general register Xn to receive the unique identification parameter passed by the caller; The second generating unit is used to complete the splicing according to the unified format preset by the MRS instruction, directly generate the first machine code corresponding to the MRS instruction, and insert the first machine code into the operating system kernel.

10. The device for efficiently reading and writing system registers in an operating system kernel according to claim 6, characterized in that: The second generation module comprises: The second receiving unit is used to predefine all general registers Xn by writing a system register macro, and use the general register Xn to receive a unique identification parameter passed by the caller, and receive a value parameter to be written by the kernel; A writing unit, used for writing the kernel numerical parameter to be written into a general register Xn, and using the general register Xn as a target register; The third generating unit is used to complete the splicing according to the unified format preset by the MSR instruction, directly generate the second machine code corresponding to the MSR instruction, and insert the second machine code into the operating system kernel.

Citation Information

Patent Citations

  • Microprocessor that makes 64-bit general purpose registers available in MSR address space while operating in non-64-bit mode

    US20130305013A1