WO2022155952A1 - Address mapping method and apparatus - Google Patents

Address mapping method and apparatus Download PDF

Info

Publication number
WO2022155952A1
WO2022155952A1 PCT/CN2021/073571 CN2021073571W WO2022155952A1 WO 2022155952 A1 WO2022155952 A1 WO 2022155952A1 CN 2021073571 W CN2021073571 W CN 2021073571W WO 2022155952 A1 WO2022155952 A1 WO 2022155952A1
Authority
WO
WIPO (PCT)
Prior art keywords
mapping
static
mode
quasi
target
Prior art date
Application number
PCT/CN2021/073571
Other languages
French (fr)
Chinese (zh)
Inventor
沈桂旭
刘延昭
董岚
Original Assignee
深圳市大疆创新科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳市大疆创新科技有限公司 filed Critical 深圳市大疆创新科技有限公司
Priority to PCT/CN2021/073571 priority Critical patent/WO2022155952A1/en
Publication of WO2022155952A1 publication Critical patent/WO2022155952A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation

Definitions

  • the present application relates to the technical field of chip design, and in particular, to an address mapping method and apparatus.
  • address mapping is required when the chip accesses the memory space beyond its address bus bit width.
  • the chip can perform address mapping in a static mapping manner or a dynamic mapping manner.
  • the static mapping method means that the mapping is established by hard coding when the chip is booted (Boot), and continues until the chip is turned off, which can better avoid memory trampling and protect the security of data and programs.
  • the memory utilization rate is low and flexible.
  • the dynamic mapping method means that the mapping is established on demand during the process of the program running, and continues until the demand is reached. Its memory utilization and flexibility are higher than the static mapping method, but the security is poor, and the frequent establishment and destruction of the mapping has a negative impact on performance. will have an impact.
  • Embodiments of the present application provide an address mapping method and apparatus, which are used to solve the problem that the address mapping method in the prior art cannot meet application requirements.
  • an embodiment of the present application provides an address mapping method, which is applied to a chip, where the chip can access memory by means of address mapping, and the method includes:
  • mapping relationship corresponding to the physical address is determined, the chip uses at least two mapping methods for address mapping, and the attributes of the mapping relationship are the at least two mapping methods one of the
  • the virtual address mapped to the physical address is determined.
  • an embodiment of the present application provides an address mapping apparatus, which is applied to a chip, where the chip can access a memory by means of address mapping, and the apparatus includes: a memory and a processor;
  • the memory for storing program codes
  • the processor calls the program code, and when the program code is executed, is configured to perform the following operations:
  • mapping relationship corresponding to the physical address is determined, the chip uses at least two mapping methods for address mapping, and the attributes of the mapping relationship are the at least two mapping methods one of the
  • the virtual address mapped to the physical address is determined.
  • embodiments of the present application provide a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, and the computer program includes at least one piece of code, and the at least one piece of code can be executed by a computer to control all
  • the computer executes the method described in any one of the above first aspects
  • an embodiment of the present application provides a computer program, which, when the computer program is executed by a computer, is used to implement the method described in any one of the foregoing first aspects.
  • the embodiments of the present application provide an address mapping method and device.
  • a mapping relationship corresponding to the physical address is determined, and a virtual address mapped to the physical address is determined according to the physical address and the mapping relationship, wherein , the chip uses at least two mapping methods for address mapping, and the attribute of the mapping relationship corresponding to the physical address is one of the at least two mapping methods. Due to the different timings of establishing and destroying the mapping relationship in different mapping methods, different establishment The security, memory utilization, memory flexibility and performance brought by the timing of destroying the mapping relationship have their own advantages. Therefore, the chip adopts at least two mapping methods for address mapping, so that the address mapping performed by the chip can be It has the advantages of different mapping methods to meet application needs.
  • FIG. 1 is a schematic diagram of an application scenario of an address mapping method provided by an embodiment of the present application
  • FIG. 2 is a schematic diagram of a mapping relationship provided by an embodiment of the present application.
  • FIG. 3 is a schematic flowchart of an address mapping method provided by an embodiment of the present application.
  • FIG. 4 is a schematic diagram of a comparison of timings for establishing and destroying a mapping relationship under different mapping modes provided by an embodiment of the present application;
  • FIG. 5 is a schematic diagram of a mapping relationship provided by another embodiment of the present application.
  • FIG. 6 is a schematic flowchart of an address mapping method provided by another embodiment of the present application.
  • FIG. 7 is a schematic flowchart of an address mapping method provided by another embodiment of the present application.
  • FIG. 8 is a schematic diagram of a division mapping table provided by an embodiment of the present application.
  • FIG. 9 is a schematic structural diagram of an address mapping apparatus provided by an embodiment of the present application.
  • the application scenario may include a chip 11 and a memory 12 , wherein the chip 11 can access the memory 12 by means of address mapping.
  • the chip 11 may be, for example, a digital signal processing (Digital Signal Processing, DSP) chip, a central processing unit (Central Processing Unit, CPU) chip, or a chip capable of running a program and accessing the memory by means of address mapping.
  • the memory 12 may be, for example, a double-rate synchronous dynamic random access memory (Double Data Rate Synchronous Dynamic Random Access Memory, DDR SDRAM) or the like.
  • the methods provided in the embodiments of the present application may be executed by the chip 11 .
  • the memory address space from the perspective of chip 11 is 0x00000000 to oxFFFFFF, and the corresponding memory size is 4GB.
  • 4GB can be divided into 16 memory blocks, which are 0 ⁇ 256MB-1B, 256MB-1B ⁇ 512MB-1B, ... ..., 3.75GB ⁇ 4GB-1B.
  • the real memory address space is 0x0000000000 to ox43FFFFFFFF, the corresponding memory size is 17GB, 17GB can be divided into 68 memory blocks, 0 ⁇ 256MB-1B, 256MB-1B ⁇ 512MB-1B, ..., 16.75GB ⁇ 17GB -1B.
  • the 1GB memory of the address space 0x00000000 to 0x3FFFFFFF from the perspective of chip 11 can be recorded as the real 0-1GB of the chip, and can be accessed directly without address mapping.
  • the 3GB memory of the address space 0x40000000 to 0xFFFFFFFF from the perspective of the chip 11 uses the address mapping method to access the memory 12 .
  • the 1GB memory of the memory address space 0x40000000 to 0x7FFFFFFF from the perspective of the chip 11 can be recorded as the chip virtual 1-2GB, for example, it can be mapped to the real memory address space 0x03C0000000 to 0x03FFFFFFFF.
  • the 1GB memory of the memory address space 0x80000000 to 0xBFFFFFFF from the perspective of the chip 11 can be recorded as the chip virtual 2-3GB, for example, the real memory address space 0x0040000000 to 0x007FFFFFFF can be accessed through address mapping.
  • the 1GB memory of the memory address space 0xC0000000 to 0xFFFFFFFF from the perspective of the chip 11 can be recorded as the chip virtual 3-4GB, for example, it can be mapped to the real memory address space 0x0400000000 to 0x043FFFFFFF.
  • mapping relationship shown in FIG. 2 is only an example.
  • FIG. 3 is a schematic flowchart of an address mapping method provided by an embodiment of the present application.
  • the execution body of this embodiment may be a chip 11 , and the chip can access memory by means of address mapping.
  • the method of this embodiment may include:
  • Step 31 when the physical address of the memory needs to be accessed, determine the mapping relationship corresponding to the physical address, the chip uses at least two mapping methods to perform address mapping, and the attributes of the mapping relationship are the at least two mapping methods. one of the mapping methods.
  • mapping manners can be flexibly implemented according to actual requirements.
  • the at least two mapping manners may include at least two of static mapping manners, quasi-static mapping manners or dynamic mapping manners.
  • the static mapping method is a mapping method in which a mapping relationship is established and destroyed in a hard-coded manner.
  • the static mapping manner may include a first static mapping manner and/or a second static mapping manner.
  • the first static mapping manner may be a mapping manner in which the mapping relationship is established and destroyed in a hard-coded manner in units of chips.
  • the second static mapping manner may be a mapping manner in which one or more operators are used as a unit to establish and destroy a mapping relationship in a hard-coded manner.
  • the dynamic mapping method is a mapping method in which a mapping relationship is established and destroyed according to requirements.
  • the quasi-static mapping method is a mapping method in which a mapping relationship is established according to requirements, and the mapping relationship is destroyed in units of one or more operators.
  • FIG. 4 A comparison of the timing of establishing and destroying the mapping relationship among the first static mapping method, the second static mapping method, the dynamic mapping method, and the quasi-static mapping method can be shown in FIG. 4 .
  • the mapping relationship a with the attribute of the first static mapping method can be established at time 1 when the chip is started, and the mapping relationship a can be destroyed at time 7 when the chip is turned off.
  • the mapping relationship b with the attribute of the second static mapping mode can be established at time 2 when an operator starts executing, and the mapping relationship b can be destroyed at time 6 when the operator execution is completed.
  • the mapping relationship c of the quasi-static mapping method can be established at the moment 3 during the execution of a certain operator according to the requirements, and the mapping relationship c can be destroyed at the moment 6 when the execution of the operator is finished.
  • the attributes established according to the requirements at the moment 4 during the execution of an operator can be the mapping relationship d in the dynamic mapping method, and the mapping relationship d can be destroyed at the moment 5 when the requirements are made.
  • the second static mapping mode and the quasi-static mapping mode are taken as an example in the unit of one operator.
  • the attribute established when the first operator of the plurality of operators starts to execute is the mapping relationship of the second static mapping mode, and the attribute established according to the requirements during the execution of the plurality of operators is a quasi-static mapping mode.
  • the mapping relationship can continue until the execution of the last operator among the multiple operators is completed.
  • the security, memory utilization, memory flexibility and performance brought by different timings of establishing and destroying the mapping relationship have their own advantages, such as the security of static mapping methods. and performance is better than dynamic mapping, the memory utilization and flexibility of dynamic mapping are better than static mapping, the security and performance of quasi-static mapping are better than dynamic mapping, and the memory utilization and flexibility are better than static mapping Therefore, the chip uses at least two mapping methods to perform address mapping, so that the address mapping performed by the chip can have the advantages of different mapping methods, thereby meeting application requirements.
  • FIG. 5 a schematic diagram of the mapping from the memory virtual space of the chip to the real memory address space can be shown in Figure 5.
  • Page 1 to Page N can indicate that the memory virtual space from the chip perspective is divided into N virtual memory blocks
  • Block1 to Block N can indicate N real memory blocks
  • the arrow direction can indicate the virtual memory block to the real memory block.
  • the mapping relationship represented by the solid line arrows may be the mapping relationship established by one mapping method
  • the mapping relationship represented by the dotted line arrows may represent the mapping relationship established by using another mapping method. It can be seen that the mapping relationship established by using the two mapping methods can exist at the same time, so that the address mapping performed by the chip can have the advantages of the two mapping methods respectively.
  • mapping relationship shown in FIG. 5 is only an example.
  • N mapping tables may exist, and the N mapping tables are in one-to-one correspondence with the N virtual memory blocks, and are used to record the mapping relationship of the corresponding memory virtual blocks.
  • the N mapping tables can be recorded as Map 1 to Map N, for example, where Map 1 can be used to record the mapping relationship between the virtual memory block Page 1 and a certain real memory block, and Map 2 can be used to record the virtual memory block Page 2
  • Map 1 can be used to record the mapping relationship between the virtual memory block Page 1 and a certain real memory block
  • Map 2 can be used to record the virtual memory block Page 2
  • Map N can be used to record the mapping relationship between the virtual memory block Page N and a real memory block.
  • mapping relationship can be "004" in hexadecimal.
  • Step 32 Determine a virtual address mapped to the physical address according to the physical address and the mapping relationship.
  • the physical address is 0x0040000000 in the address space shown in FIG. 2
  • the mapping relationship corresponding to the physical address is that the memory address space 0x80000000 to 0x8FFFFFFF from the perspective of the chip 11 is mapped to the real memory address space 0x0040000000 to 0x004FFFFFF, it can be determined that the virtual address mapped to the physical address is 0x80000000.
  • the physical address of the memory may be accessed using the virtual address, for example, data may be written to the physical address, or data may be retrieved from the physical address. Read data from the physical address.
  • the virtual address may be subjected to offset processing, for example, the virtual address is +1, and the virtual address after the offset processing is used to access the memory.
  • the mapping relationship corresponding to the physical address is determined, and the virtual address mapped to the physical address is determined according to the physical address and the mapping relationship, wherein the chip is At least two mapping methods are used for address mapping, and the attribute of the mapping relationship corresponding to the physical address is one of the at least two mapping methods. Due to the different timings for establishing and destroying the mapping relationship in different mapping methods, different mapping methods are established and destroyed. The security, memory utilization, memory flexibility and performance brought by the timing of the relationship have their own advantages. Therefore, the chip uses at least two mapping methods for address mapping, so that the address mapping performed by the chip can have different mappings. The advantages of the method can meet the application requirements.
  • FIG. 6 is a schematic flowchart of an address mapping method provided by another embodiment of the present application. Based on the embodiment shown in FIG. 3 , this embodiment mainly describes that the at least two mapping modes include a first mapping mode and a third mapping mode. In the case of two mapping modes, the specific mode of the mapping relationship corresponding to the physical address is determined. As shown in FIG. 6 , the method provided by this embodiment may include:
  • Step 61 when the physical address of the memory needs to be accessed, and in the case of an existing mapping relationship whose attribute is the first mapping mode, determine whether there is a mapping relationship matching the physical address.
  • mapping relationship matching the physical address may be determined by querying the mapping table.
  • the first mapping manner may include a static mapping manner
  • the second mapping manner may include a quasi-static mapping manner, so that the chip can further use a quasi-static mapping manner on the basis that the static mapping manner has been used for address mapping.
  • Static mapping is used for address mapping.
  • the first mapping manner may include a static mapping manner
  • the second mapping manner may include a dynamic mapping manner, so that on the basis of the address mapping performed by the static mapping manner, the chip may further employ a dynamic mapping manner.
  • the mapping method is used for address mapping.
  • the first mapping manner may include a quasi-static mapping manner
  • the second mapping manner may include a dynamic mapping manner, so that the chip can further perform address mapping based on the quasi-static mapping manner.
  • a quasi-static mapping method is used for address mapping.
  • the method further includes: establishing the attribute as the static mapping mode. of the target mapping relationship.
  • At least two mapping tables may exist in the chip for recording the mapping relationship of the corresponding attributes.
  • the mapping table in the chip can be divided into three categories, namely, the static mapping table corresponding to the static mapping mode, The quasi-static mapping table corresponding to the quasi-static mapping mode and the dynamic mapping table corresponding to the dynamic mapping mode.
  • the establishing the target mapping relationship whose attribute is the static mapping mode may specifically include: recording the target mapping relationship in a static mapping table corresponding to the static mapping mode, and enabling the target mapping relationship to be stored in the static mapping mode.
  • the first register of the static mapping table may further include: setting the static mapping table to a locked state.
  • the static mapping table When the static mapping table is in a locked state, it may indicate that modification of the mapping relationship recorded in the static mapping table is prohibited. By setting the static mapping table to a locked state, it is possible to avoid erroneous modification of the static mapping table, which is beneficial to improve the security of the static mapping table.
  • mapping relationship recorded in the static mapping table may further include: when it is determined that the mapping relationship recorded in the static mapping table needs to be modified, setting the static mapping table to an unlocked state. , and disable the first register. Therefore, the mapping relationship recorded in the static mapping table can be updated according to the requirements, which is beneficial to improve flexibility. It should be noted that, in the embodiments of the present application, the mapping relationships whose attributes are in the static mapping mode are all established, destroyed and modified in a hard-coded manner.
  • the number of static mapping tables corresponding to the static mapping mode may be a fixed value, or the number of static mapping tables corresponding to the static mapping mode may be a variable value configured according to usage requirements.
  • the number of static mapping tables corresponding to the static mapping method is a variable value configured according to usage requirements, so that the number of static mapping tables can be flexibly configured according to usage requirements, which is beneficial to improve flexibility.
  • Step 62 if there is, the mapping relationship matching the physical address is the mapping relationship corresponding to the physical address.
  • step 64 is performed.
  • Step 63 if it does not exist, establish a target mapping relationship whose attribute is the second mapping mode, the target mapping relationship is a mapping relationship between the target virtual address range and the target physical address range, and the target physical address range includes the physical address, and the target mapping relationship is the mapping relationship corresponding to the physical address.
  • the mapping relationships in which the attribute is a non-static mapping manner are established according to requirements.
  • the difference between the quasi-static mapping method and the dynamic mapping method, which are non-static mapping methods, is mainly in the timing of destroying the mapping relationship between the two.
  • the quasi-static mapping method can be destroyed when one or more operators are executed, and the dynamic mapping method can be destroyed when the requirements are met.
  • the establishing the target mapping relationship whose attribute is the second mapping mode may specifically include: establishing all the attributes whose attributes are the dynamic mapping mode. Describe the target mapping relationship.
  • the establishing the target mapping relationship whose attribute is the dynamic mapping mode may specifically include: recording the target mapping relationship in a dynamic mapping table corresponding to the dynamic mapping mode, and enabling the target mapping relationship to be stored in the dynamic mapping mode.
  • the second register of the dynamic mapping table Afterwards, when the requirement for triggering the creation of the target mapping relationship is fulfilled, the second register may be disabled. By disabling the second register, the target mapping relationship can be destroyed, so that the dynamic mapping table can be destroyed when the requirement is met.
  • the number of dynamic mapping tables corresponding to the dynamic mapping mode may be a fixed value, or the number of dynamic mapping tables corresponding to the dynamic mapping mode may be a variable value configured according to usage requirements.
  • the number of dynamic mapping tables corresponding to the dynamic mapping method is a variable value configured according to usage requirements, so that the number of dynamic mapping tables can be flexibly configured according to usage requirements, which is beneficial to improve flexibility.
  • the establishing the target mapping relationship whose attribute is the second mapping mode may specifically include: establishing an attribute as the quasi-static mapping The target mapping relationship of the mode.
  • the establishment of the target mapping relationship whose attribute is the quasi-static mapping mode may specifically include: determining whether there is a quasi-static mapping table in an unlocked state; if so, recording the target mapping relationship in an unlocked state.
  • the quasi-static mapping table In the quasi-static mapping table, the quasi-static mapping table is set to a locked state, and the third register for storing the dynamic mapping table is enabled.
  • the static mapping table When the static mapping table is in a locked state, it may indicate that modification of the mapping relationship recorded in the static mapping table is prohibited.
  • By setting the static mapping table to a locked state it can be avoided that the static mapping table is incorrectly modified before the execution of one or more operators is completed, which is beneficial to improve the security of the static mapping table.
  • the target mapping relationship whose attribute is a dynamic mapping mode can be established.
  • the quasi-static mapping table after setting the quasi-static mapping table to a locked state, it may further include: in the case that the execution of one or more operators is completed, setting the quasi-static mapping table to an unlocked state, and The third register is disabled.
  • the target mapping relationship By setting the static mapping table to an unlocked state and disabling the third register, the target mapping relationship can be destroyed, so that the static mapping table can be destroyed in units of one or more operators.
  • the number of quasi-static mapping tables corresponding to the quasi-static mapping mode may be a fixed value, or the number of quasi-static mapping tables corresponding to the quasi-static mapping mode may be a variable value configured according to usage requirements.
  • the number of quasi-static mapping tables corresponding to the quasi-static mapping method is a variable value configured according to usage requirements, so that the number of quasi-static mapping tables can be flexibly configured according to usage requirements, which is beneficial to improve flexibility.
  • the establishing the target mapping relationship whose attribute is the second mapping mode may specifically include: determining a plurality of the first mapping modes. The second mapping mode of the target in the two mapping modes is established, and the target mapping relationship whose attribute is the target mapping mode is established. Therefore, it is possible to flexibly select one of the multiple second mapping manners according to requirements to establish the target mapping relationship.
  • the plurality of second mapping modes may include the quasi-static mapping mode and the dynamic mapping mode
  • the target second mapping mode may be the quasi-static mapping mode and the dynamic mapping mode.
  • the determining the target second mapping mode among the plurality of second mapping modes includes: determining whether there is a quasi-static mapping table in an unlocked state; if so, the quasi-static mapping mode is the target second mapping mode. Mapping mode, if not, the dynamic mapping mode is the target second mapping mode. Therefore, it is possible to establish a mapping relationship in a quasi-static mapping manner of attributes preferentially.
  • the characteristics of the static mapping table, the quasi-static mapping table and the dynamic mapping table are compared as shown in Table 1 below.
  • the characteristics of the static mapping table can be: the mapping relationship recorded in the static mapping table is created in a hard-coded manner, the static mapping table supports locking and unlocking, and the unlocking is based on Hard-coded, the number of static mapping tables can be configured, and the static mapping tables are destroyed separately.
  • the characteristics of the quasi-static mapping table may be: the mapping relationship recorded in the quasi-static mapping table is created according to the requirements, the quasi-static mapping table supports locking, the number of the quasi-static mapping table is configurable, and the quasi-static mapping table is destroyed as a whole.
  • the characteristics of the dynamic mapping table can be: the mapping relationship recorded in the dynamic mapping table is created and modified according to the requirements, the dynamic mapping table does not support locking, the number of dynamic mapping tables can be configured, and the dynamic mapping table can be destroyed as a whole.
  • the overall destruction of the quasi-static mapping table may refer to destroying all the mapping relationships currently recorded in the quasi-static mapping table when the execution of the operator is completed, and the dynamic mapping table is completely destroyed.
  • the overall destruction may refer to destroying all the mapping relationships currently recorded in the dynamic mapping table when the execution of the operator is completed.
  • the establishment attribute in step 63 is the target mapping relationship of the second mapping mode.
  • the target mapping relationship may specifically include: determining whether there is a quasi-static mapping table in an unlocked state; and, if not, establishing the target mapping relationship whose attribute is a dynamic mapping manner. Further, if there is a quasi-static mapping table in an unlocked state, the target mapping relationship can be recorded in a quasi-static mapping table in an unlocked state, the quasi-static mapping table is set to a locked state, and the A third register that can be used to store the dynamic mapping table. It should be noted that, for a specific manner of establishing a target mapping relationship whose attribute is a dynamic mapping manner or a static mapping manner, reference may be made to the foregoing description, which will not be repeated here.
  • Step 64 Determine the virtual address mapped to the physical address according to the physical address and the mapping relationship.
  • step 64 is similar to step 32, and details are not repeated here.
  • the address mapping method provided in this embodiment determines whether there is a mapping relationship that matches the physical address when there is a mapping relationship whose attribute is the first mapping mode. If there is, the mapping relationship that can match the physical address is the same as If the mapping relationship corresponding to the physical address does not exist, the target mapping relationship with the attribute as the second mapping mode can be established, so that on the basis of the existing mapping relationship with the attribute as the first mapping mode, the attribute as the second mapping mode can be further established. The mapping relationship of the mode, thus meeting the requirements for the mapping relationship of different mapping modes.
  • mapping modes including static mapping mode, dynamic mapping mode and quasi-static mapping mode as an example
  • FIG. 7 the process of performing address mapping on a chip is illustrated by an example.
  • Step 71 Configure the respective numbers of the static mapping table, the dynamic mapping table and the quasi-static mapping table.
  • the number of mapping tables can be configured by calling void config_map(size_t static_map, size_t qstatic_map, size_t dynamic_map).
  • static_map can be used as the number of static mapping tables
  • qstatic_map can be used as the number of quasi-static mapping tables
  • dynamic_map can be used as the number of dynamic mapping tables.
  • the sum of the static mapping table, the quasi-static mapping table and the dynamic mapping table can also be restricted to be smaller than the total number of mapping tables (for example, N).
  • Map 1 to Map 4 can be, for example, static mapping tables
  • Map 5 to Map 8 can be, for example, a quasi-static mapping table
  • Map 9 to Map N can be, for example, a dynamic mapping table.
  • the N Maps correspond one-to-one with the N Pages shown in FIG. 5
  • Map i corresponds to Page i.
  • Step 72 establishing a mapping relationship in which the attribute is a static mapping mode.
  • mapping table whose attribute is static mapping can be established, where X can correspond to a static mapping table Map X, and Map X can be one of Map 1 to Map 4.
  • physical_addr can represent a physical address.
  • config_lock_mapX the mapping relationship between PageX and the physical memory block represented by uint64_t physical_addr can be recorded in Map X, set Map X to the locked state, and enable the register used to store Map X.
  • void release_mapX () to destroy the mapping table whose attributes are static mapping, where X can correspond to a static mapping table Map X.
  • Map X can be set to the unlocked state and the registers used to store Map X are disabled.
  • config_lock_mapX can be further called to establish the mapping relationship, so as to realize the updating of the mapping relationship in the static mapping table.
  • Step 73 in the process of executing a certain operator, when it is necessary to access a certain physical address of the memory, determine whether there is a mapping relationship matching the physical address.
  • step 77 may be executed, and it can be understood that the mapping relationship matching the physical address is the mapping relationship corresponding to the physical address. If there is no mapping relationship matching the physical address, step 74 may be performed.
  • Step 74 determine whether there is a quasi-static mapping table in an unlocked state.
  • step 75 may be performed. If there is no quasi-static mapping table in the unlocked state, step 76 may be performed.
  • Step 75 Record the target mapping relationship in a quasi-static mapping table in an unlocked state, set the quasi-static mapping table to a locked state, and enable a register for storing the quasi-static mapping table.
  • step 75 is performed, step 77 is further performed.
  • Step 76 Record the target mapping relationship in a dynamic mapping table, and enable a register for storing the dynamic mapping table.
  • step 77 is further performed. It can be understood that the target mapping relationship is the mapping relationship corresponding to the physical address.
  • Step 77 Determine the virtual address mapped to the physical address according to the mapping relationship corresponding to the physical address.
  • step 78 the address space corresponding to the physical address in the memory is accessed using the virtual address mapped to the physical address.
  • step 78 the memory access using the virtual address mapped to the physical address is used as an example.
  • Step 79 if the target mapping relationship is recorded in the dynamic mapping table, destroy the dynamic mapping table when the requirement is met.
  • step 710 if the target mapping relationship is recorded in the quasi-static mapping table, in the case that the execution of the operator is completed, destroy the quasi-static mapping table.
  • the quasi-static mapping of attributes can be destroyed by calling void release_qstatic_map().
  • release_qstatic_map all static mapping tables can be set to an unlocked state, and the registers used to store each static mapping table are prohibited.
  • the physical address corresponding to a certain virtual address needs to be determined, for example, it can be implemented by calling uint64_t get_physical_address(uint32_t virtual_addr), where virtual_addr represents a virtual address.
  • get_physical_address the physical address to which the logical address is mapped may be determined based on the logical address and the corresponding mapping relationship.
  • FIG. 9 is a schematic structural diagram of an address mapping apparatus provided by an embodiment of the present application.
  • the apparatus is applied to a chip, and the chip can access memory by means of address mapping.
  • the apparatus 90 may include: a processor 91 and memory 92.
  • the memory 92 is used to store program codes
  • the processor 91 calls the program code, and when the program code is executed, is configured to perform the following operations:
  • mapping relationship corresponding to the physical address is determined, the chip uses at least two mapping methods for address mapping, and the attributes of the mapping relationship are the at least two mapping methods one of the
  • the virtual address mapped to the physical address is determined.
  • the address mapping apparatus provided in this embodiment can be used to implement the technical solutions of the foregoing method embodiments, and the implementation principles and technical effects thereof are similar to those of the method embodiments, which will not be repeated here.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Executing Machine-Instructions (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

Provided are an address mapping method and apparatus. The method comprises: when the physical address of a memory needs to be accessed, determining a mapping relationship corresponding to the physical address, a chip implementing address mapping in at least two mapping modes, and the attribute of the mapping relationship being one of the at least two mapping modes (31); and determining a virtual address mapped to the physical address according to the physical address and the mapping relationship (32). According to the method, address mapping performed by a chip has the advantage of having different mapping modes, so that the application requirements can be satisfied.

Description

地址映射方法及装置Address mapping method and device 技术领域technical field
本申请涉及芯片设计技术领域,尤其涉及一种地址映射方法及装置。The present application relates to the technical field of chip design, and in particular, to an address mapping method and apparatus.
背景技术Background technique
受限于芯片的地址总线,在芯片访问超出其地址总线位宽范围的存储空间时,需要进行地址映射。Restricted by the address bus of the chip, address mapping is required when the chip accesses the memory space beyond its address bus bit width.
目前,芯片可以采用静态映射方式或动态映射方式进行地址映射。其中,静态映射方式是指在芯片启动(Boot)时通过硬编码方式建立映射,并持续至芯片关闭,其能够较好的避免内存踩踏,保护数据和程序的安全,然而内存利用率低且灵活性差。动态映射方式是指在程序运行的过程中按需建立映射,并持续至需求达成,其内存利用率和灵活性较静态映射方式要高,然而安全性较差且频繁建立与销毁映射对性能也会带来影响。At present, the chip can perform address mapping in a static mapping manner or a dynamic mapping manner. Among them, the static mapping method means that the mapping is established by hard coding when the chip is booted (Boot), and continues until the chip is turned off, which can better avoid memory trampling and protect the security of data and programs. However, the memory utilization rate is low and flexible. Bad sex. The dynamic mapping method means that the mapping is established on demand during the process of the program running, and continues until the demand is reached. Its memory utilization and flexibility are higher than the static mapping method, but the security is poor, and the frequent establishment and destruction of the mapping has a negative impact on performance. will have an impact.
因此,现有技术中的地址映射方式,存在无法满足应用需求的问题。Therefore, there is a problem that the address mapping method in the prior art cannot meet application requirements.
发明内容SUMMARY OF THE INVENTION
本申请实施例提供一种地址映射方法及装置,用以解决现有技术中的地址映射方式,无法满足应用需求的问题。Embodiments of the present application provide an address mapping method and apparatus, which are used to solve the problem that the address mapping method in the prior art cannot meet application requirements.
第一方面,本申请实施例提供一种地址映射方法,应用于芯片,所述芯片能够采用地址映射的方式访问内存,所述方法包括:In a first aspect, an embodiment of the present application provides an address mapping method, which is applied to a chip, where the chip can access memory by means of address mapping, and the method includes:
在需要访问所述内存的物理地址时,确定与所述物理地址对应的映射关系,所述芯片是采用至少两种映射方式进行地址映射,所述映射关系的属性为所述至少两种映射方式中的一种;When the physical address of the memory needs to be accessed, a mapping relationship corresponding to the physical address is determined, the chip uses at least two mapping methods for address mapping, and the attributes of the mapping relationship are the at least two mapping methods one of the
根据所述物理地址以及所述映射关系,确定映射到所述物理地址的虚拟 地址。According to the physical address and the mapping relationship, the virtual address mapped to the physical address is determined.
第二方面,本申请实施例提供一种地址映射装置,应用于芯片,所述芯片能够采用地址映射的方式访问内存,所述装置包括:存储器和处理器;In a second aspect, an embodiment of the present application provides an address mapping apparatus, which is applied to a chip, where the chip can access a memory by means of address mapping, and the apparatus includes: a memory and a processor;
所述存储器,用于存储程序代码;the memory for storing program codes;
所述处理器,调用所述程序代码,当程序代码被执行时,用于执行以下操作:The processor calls the program code, and when the program code is executed, is configured to perform the following operations:
在需要访问所述内存的物理地址时,确定与所述物理地址对应的映射关系,所述芯片是采用至少两种映射方式进行地址映射,所述映射关系的属性为所述至少两种映射方式中的一种;When the physical address of the memory needs to be accessed, a mapping relationship corresponding to the physical address is determined, the chip uses at least two mapping methods for address mapping, and the attributes of the mapping relationship are the at least two mapping methods one of the
根据所述物理地址以及所述映射关系,确定映射到所述物理地址的虚拟地址。According to the physical address and the mapping relationship, the virtual address mapped to the physical address is determined.
第三方面,本申请实施例提供一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序包含至少一段代码,所述至少一段代码可由计算机执行,以控制所述计算机执行上述第一方面任一项所述的方法In a third aspect, embodiments of the present application provide a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, and the computer program includes at least one piece of code, and the at least one piece of code can be executed by a computer to control all The computer executes the method described in any one of the above first aspects
第四方面,本申请实施例提供一种计算机程序,当所述计算机程序被计算机执行时,用于实现上述第一方面任一项所述的方法。In a fourth aspect, an embodiment of the present application provides a computer program, which, when the computer program is executed by a computer, is used to implement the method described in any one of the foregoing first aspects.
本申请实施例提供一种地址映射方法及装置,通过芯片在需要访问内存的物理地址时,确定与物理地址对应的映射关系,根据物理地址以及映射关系,确定映射到物理地址的虚拟地址,其中,芯片是采用至少两种映射方式进行地址映射,与物理地址对应的映射关系的属性为至少两种映射方式中的一种,由于不同映射方式建立和销毁映射关系的时机不同,而不同的建立和销毁映射关系的时机所带来的安全性、内存利用率、内存灵活性以及性能各有优势,因此通过所述芯片是采用至少两种映射方式进行地址映射,使得芯片所进行的地址映射能够具备不同映射方式的优势,从而能够满足应用需求。The embodiments of the present application provide an address mapping method and device. When a physical address of a memory needs to be accessed by a chip, a mapping relationship corresponding to the physical address is determined, and a virtual address mapped to the physical address is determined according to the physical address and the mapping relationship, wherein , the chip uses at least two mapping methods for address mapping, and the attribute of the mapping relationship corresponding to the physical address is one of the at least two mapping methods. Due to the different timings of establishing and destroying the mapping relationship in different mapping methods, different establishment The security, memory utilization, memory flexibility and performance brought by the timing of destroying the mapping relationship have their own advantages. Therefore, the chip adopts at least two mapping methods for address mapping, so that the address mapping performed by the chip can be It has the advantages of different mapping methods to meet application needs.
附图说明Description of drawings
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作一简单地介绍,显而易见地,下面描述中的附图是本申请的一些实施例,对于本领域普通技术人员来讲,在 不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following will briefly introduce the accompanying drawings used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description These are some embodiments of the present application. For those of ordinary skill in the art, other drawings can also be obtained based on these drawings without any creative effort.
图1为本申请实施例提供的地址映射方法的应用场景示意图;1 is a schematic diagram of an application scenario of an address mapping method provided by an embodiment of the present application;
图2为本申请一实施例提供的映射关系的示意图;FIG. 2 is a schematic diagram of a mapping relationship provided by an embodiment of the present application;
图3为本申请一实施例提供的地址映射方法的流程示意图;3 is a schematic flowchart of an address mapping method provided by an embodiment of the present application;
图4为本申请一实施例提供的不同映射方式下建立和销毁映射关系的时机对比的示意图;4 is a schematic diagram of a comparison of timings for establishing and destroying a mapping relationship under different mapping modes provided by an embodiment of the present application;
图5为本申请另一实施例提供的映射关系的示意图;5 is a schematic diagram of a mapping relationship provided by another embodiment of the present application;
图6为本申请另一实施例提供的地址映射方法的流程示意图;6 is a schematic flowchart of an address mapping method provided by another embodiment of the present application;
图7为本申请又一实施例提供的地址映射方法的流程示意图;7 is a schematic flowchart of an address mapping method provided by another embodiment of the present application;
图8为本申请一实施例提供的划分映射表的示意图;FIG. 8 is a schematic diagram of a division mapping table provided by an embodiment of the present application;
图9为本申请一实施例提供的地址映射装置的结构示意图。FIG. 9 is a schematic structural diagram of an address mapping apparatus provided by an embodiment of the present application.
具体实施方式Detailed ways
为使本申请实施例的目的、技术方案和优点更加清楚,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。In order to make the purposes, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments It is a part of the embodiments of the present application, but not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the protection scope of the present application.
本申请实施例提供的地址映射方法可以应用于如图1所示的应用场景中。如图1所示,该应用场景中可以包括芯片11和内存12,其中芯片11能够采用地址映射的方式访问内存12。芯片11例如可以为数字信号处理(Digital Signal Processing,DSP)芯片、中央处理器(Central Processing Unit,CPU)芯片等能够运行程序够并采用地址映射的方式访问内存的芯片。内存12例如可以为双倍速率同步动态随机存储器(Double Data Rate Synchronous Dynamic Random Access Memory,DDR SDRAM)等。本申请实施例提供的方法可以由芯片11执行。The address mapping method provided in this embodiment of the present application may be applied to the application scenario shown in FIG. 1 . As shown in FIG. 1 , the application scenario may include a chip 11 and a memory 12 , wherein the chip 11 can access the memory 12 by means of address mapping. The chip 11 may be, for example, a digital signal processing (Digital Signal Processing, DSP) chip, a central processing unit (Central Processing Unit, CPU) chip, or a chip capable of running a program and accessing the memory by means of address mapping. The memory 12 may be, for example, a double-rate synchronous dynamic random access memory (Double Data Rate Synchronous Dynamic Random Access Memory, DDR SDRAM) or the like. The methods provided in the embodiments of the present application may be executed by the chip 11 .
以芯片11的地址总线为32位宽为例,32位宽可以寻址4GB的内存空间,假设芯片11需要访问的内存大小为17GB,由于4GB小于17GB,因此芯片11需要采用地址映射的方式访问内存。Taking the address bus of chip 11 as an example of 32 bits wide, 32 bits can address 4GB of memory space. Suppose the memory size that chip 11 needs to access is 17GB. Since 4GB is less than 17GB, chip 11 needs to use address mapping to access it. Memory.
参考图2,芯片11视角的内存地址空间为0x00000000至oxFFFFFFFF,对 应的内存大小为4GB,4GB可以被划分为16个内存块,分别为0~256MB-1B、256MB-1B~512MB-1B、……、3.75GB~4GB-1B。真实的内存地址空间为0x0000000000至ox43FFFFFFFF,对应的内存大小为17GB,17GB可以被划分为68个内存块,分别为0~256MB-1B、256MB-1B~512MB-1B、……、16.75GB~17GB-1B。Referring to Figure 2, the memory address space from the perspective of chip 11 is 0x00000000 to oxFFFFFFFF, and the corresponding memory size is 4GB. 4GB can be divided into 16 memory blocks, which are 0~256MB-1B, 256MB-1B~512MB-1B, … ..., 3.75GB~4GB-1B. The real memory address space is 0x0000000000 to ox43FFFFFFFF, the corresponding memory size is 17GB, 17GB can be divided into 68 memory blocks, 0~256MB-1B, 256MB-1B~512MB-1B, ..., 16.75GB~17GB -1B.
假设17GB中有1GB是位于芯片11中,其余16GB是位于内存12中,则芯片11视角的地址空间0x00000000至0x3FFFFFFF的1GB内存,可以记为芯片真实0~1GB,无需地址映射可以直接访问。芯片11视角的地址空间0x40000000至0xFFFFFFFF的3GB内存,使用地址映射的方式访问内存12。Assuming that 1GB of the 17GB is located in chip 11, and the remaining 16GB is located in memory 12, the 1GB memory of the address space 0x00000000 to 0x3FFFFFFF from the perspective of chip 11 can be recorded as the real 0-1GB of the chip, and can be accessed directly without address mapping. The 3GB memory of the address space 0x40000000 to 0xFFFFFFFF from the perspective of the chip 11 uses the address mapping method to access the memory 12 .
其中,芯片11视角的内存地址空间0x40000000至0x7FFFFFFF的1GB内存,可以记为芯片虚拟1~2GB,例如可以映射到真实的内存地址空间0x03C0000000至0x03FFFFFFFF。芯片11视角的内存地址空间0x80000000至0xBFFFFFFF的1GB内存,可以记为芯片虚拟2~3GB,例如可以通过地址映射的方式访问真实的内存地址空间0x0040000000至0x007FFFFFFF。芯片11视角的内存地址空间0xC0000000至0xFFFFFFFF的1GB内存,可以记为芯片虚拟3~4GB,例如可以映射到真实的内存地址空间0x0400000000至0x043FFFFFFF。Among them, the 1GB memory of the memory address space 0x40000000 to 0x7FFFFFFF from the perspective of the chip 11 can be recorded as the chip virtual 1-2GB, for example, it can be mapped to the real memory address space 0x03C0000000 to 0x03FFFFFFFF. The 1GB memory of the memory address space 0x80000000 to 0xBFFFFFFF from the perspective of the chip 11 can be recorded as the chip virtual 2-3GB, for example, the real memory address space 0x0040000000 to 0x007FFFFFFF can be accessed through address mapping. The 1GB memory of the memory address space 0xC0000000 to 0xFFFFFFFF from the perspective of the chip 11 can be recorded as the chip virtual 3-4GB, for example, it can be mapped to the real memory address space 0x0400000000 to 0x043FFFFFFF.
需要说明的是,图2所示的映射关系仅为举例。It should be noted that the mapping relationship shown in FIG. 2 is only an example.
下面结合附图,对本申请的一些实施方式作详细说明。在不冲突的情况下,下述的实施例及实施例中的特征可以相互组合。Some embodiments of the present application will be described in detail below with reference to the accompanying drawings. The embodiments described below and features in the embodiments may be combined with each other without conflict.
图3为本申请一实施例提供的地址映射方法的流程示意图,本实施例的执行主体可以为芯片11,所述芯片能够采用地址映射的方式访问内存。如图3所示,本实施例的方法可以包括:FIG. 3 is a schematic flowchart of an address mapping method provided by an embodiment of the present application. The execution body of this embodiment may be a chip 11 , and the chip can access memory by means of address mapping. As shown in FIG. 3, the method of this embodiment may include:
步骤31,在需要访问所述内存的物理地址时,确定与所述物理地址对应的映射关系,所述芯片是采用至少两种映射方式进行地址映射,所述映射关系的属性为所述至少两种映射方式中的一种。 Step 31, when the physical address of the memory needs to be accessed, determine the mapping relationship corresponding to the physical address, the chip uses at least two mapping methods to perform address mapping, and the attributes of the mapping relationship are the at least two mapping methods. one of the mapping methods.
本步骤中,所述至少两种映射方式中不同映射方式建立和销毁映射关系的时机不同。所述至少两种映射方式可以根据实际需求灵活实现。一个实施例中,所述至少两种映射方式可以包括静态映射方式、准静态映射方式或动态映射方式中的至少两种。In this step, different mapping modes among the at least two mapping modes have different timings for establishing and destroying the mapping relationship. The at least two mapping manners can be flexibly implemented according to actual requirements. In one embodiment, the at least two mapping manners may include at least two of static mapping manners, quasi-static mapping manners or dynamic mapping manners.
其中,所述静态映射方式是采用硬编码方式建立并销毁映射关系的映射方式。一个实施例中,根据静态映射的单位不同,所述静态映射方式可以包 括第一静态映射方式和/或第二静态映射方式。所述第一静态映射方式可以是以芯片为单位,采用硬编码方式建立并销毁映射关系的映射方式。所述第二静态映射方式可以是以一个或多个算子为单位,采用硬编码方式建立并销毁映射关系的映射方式。Wherein, the static mapping method is a mapping method in which a mapping relationship is established and destroyed in a hard-coded manner. In one embodiment, according to different units of static mapping, the static mapping manner may include a first static mapping manner and/or a second static mapping manner. The first static mapping manner may be a mapping manner in which the mapping relationship is established and destroyed in a hard-coded manner in units of chips. The second static mapping manner may be a mapping manner in which one or more operators are used as a unit to establish and destroy a mapping relationship in a hard-coded manner.
一个实施例中,所述动态映射方式是根据需求建立并销毁映射关系的映射方式。所述准静态映射方式是根据需求建立映射关系,并以一个或多个算子为单位销毁映射关系的映射方式。In one embodiment, the dynamic mapping method is a mapping method in which a mapping relationship is established and destroyed according to requirements. The quasi-static mapping method is a mapping method in which a mapping relationship is established according to requirements, and the mapping relationship is destroyed in units of one or more operators.
第一静态映射方式、第二静态映射方式、动态映射方式以及准静态映射方式四者的建立和销毁映射关系的时机对比可以如图4所示。参考图4,采用第一静态映射方式,可以在芯片启动时的时刻1建立属性为第一静态映射方式的映射关系a,并可以在芯片关闭时的时刻7销毁映射关系a。采用第二静态映射方式,可以在某一算子开始执行时的时刻2建立属性为第二静态映射方式的映射关系b,并可以在算子执行完成时的时刻6销毁映射关系b。采用准静态映射方式,可以在某一算子执行的过程中的时刻3根据需求建立的属性为准静态映射方式的映射关系c,并可以在该算子结束执行时的时刻6销毁映射关系c。采用动态映射方式,可以在某一算子执行的过程中的时刻4根据需求建立的属性为动态映射方式的映射关系d,并可以在需求打成时的时刻5销毁映射关系d。需要说明的是,图4中是以第二静态映射方式和准静态映射方式是以一个算子为单位为例,可以理解的是,在以多个算子为单位时,采用硬编码方式在该多个算子中第一个算子开始执行时所建立的属性为第二静态映射方式的映射关系,以及在该多个算子执行的过程中根据需求建立的属性为准静态映射方式的映射关系,均可以持续至该多个算子中的最后一个算子执行完成。A comparison of the timing of establishing and destroying the mapping relationship among the first static mapping method, the second static mapping method, the dynamic mapping method, and the quasi-static mapping method can be shown in FIG. 4 . Referring to FIG. 4 , using the first static mapping method, the mapping relationship a with the attribute of the first static mapping method can be established at time 1 when the chip is started, and the mapping relationship a can be destroyed at time 7 when the chip is turned off. Using the second static mapping mode, the mapping relationship b with the attribute of the second static mapping mode can be established at time 2 when an operator starts executing, and the mapping relationship b can be destroyed at time 6 when the operator execution is completed. Using the quasi-static mapping method, the mapping relationship c of the quasi-static mapping method can be established at the moment 3 during the execution of a certain operator according to the requirements, and the mapping relationship c can be destroyed at the moment 6 when the execution of the operator is finished. . Using the dynamic mapping method, the attributes established according to the requirements at the moment 4 during the execution of an operator can be the mapping relationship d in the dynamic mapping method, and the mapping relationship d can be destroyed at the moment 5 when the requirements are made. It should be noted that in FIG. 4, the second static mapping mode and the quasi-static mapping mode are taken as an example in the unit of one operator. It can be understood that when multiple operators are used as the unit, the The attribute established when the first operator of the plurality of operators starts to execute is the mapping relationship of the second static mapping mode, and the attribute established according to the requirements during the execution of the plurality of operators is a quasi-static mapping mode. The mapping relationship can continue until the execution of the last operator among the multiple operators is completed.
由于不同映射方式建立和销毁映射关系的时机不同,而不同的建立和销毁映射关系的时机所带来的安全性、内存利用率、内存灵活性以及性能各有优势,例如静态映射方式的安全性和性能优于动态映射方式,动态映射方式的内存利用率和灵活性优于静态映射方式,准静态映射方式的安全性和性能优于动态映射,且内存利用率及灵活性优于静态映射方式,因此通过所述芯片是采用至少两种映射方式进行地址映射,使得芯片所进行的地址映射能够具备不同映射方式的优势,从而能够满足应用需求。Due to the different timings of establishing and destroying the mapping relationship in different mapping methods, the security, memory utilization, memory flexibility and performance brought by different timings of establishing and destroying the mapping relationship have their own advantages, such as the security of static mapping methods. and performance is better than dynamic mapping, the memory utilization and flexibility of dynamic mapping are better than static mapping, the security and performance of quasi-static mapping are better than dynamic mapping, and the memory utilization and flexibility are better than static mapping Therefore, the chip uses at least two mapping methods to perform address mapping, so that the address mapping performed by the chip can have the advantages of different mapping methods, thereby meeting application requirements.
以所述芯片是采用两种映射方式进行地址映射为例,芯片视角的内存虚 拟空间到真实的内存地址空间的映射示意图可以如图5所示。图5中,Page 1至Page N可以表示芯片视角的内存虚拟空间被划分为N个虚拟内存块,Block1至Block N可以表示N个真实内存块,箭头方向可以表示虚拟内存块至真实内存块之间的映射关系,实线箭头所表示的映射关系可以是采用一种映射方式所建立的映射关系,虚线箭头所表示的映射关系可以表示采用另一种映射方式所建立的映射关系。可以看出,采用两种映射方式所建立的映射关系可以同时存在,从而使得芯片所进行的地址映射能够具备两种映射方式分别的优势。Taking the chip that uses two mapping methods to perform address mapping as an example, a schematic diagram of the mapping from the memory virtual space of the chip to the real memory address space can be shown in Figure 5. In Figure 5, Page 1 to Page N can indicate that the memory virtual space from the chip perspective is divided into N virtual memory blocks, Block1 to Block N can indicate N real memory blocks, and the arrow direction can indicate the virtual memory block to the real memory block. The mapping relationship represented by the solid line arrows may be the mapping relationship established by one mapping method, and the mapping relationship represented by the dotted line arrows may represent the mapping relationship established by using another mapping method. It can be seen that the mapping relationship established by using the two mapping methods can exist at the same time, so that the address mapping performed by the chip can have the advantages of the two mapping methods respectively.
需要说明的是,图5所示的映射关系仅为举例。It should be noted that the mapping relationship shown in FIG. 5 is only an example.
可以理解的是,对于N个虚拟内存块,可以存在N个映射表,N个映射表与N个虚拟内存块一一对应,用于记录对应内存虚拟块的映射关系。其中,N个映射表例如可以记为Map 1至Map N,其中,Map 1可以用于记录虚拟内存块Page 1到某一真实内存块的映射关系,Map 2可以用于记录虚拟内存块Page 2到某一真实内存块的映射关系,……,Map N可以用于记录虚拟内存块Page N到某一真实内存块的映射关系。It can be understood that, for N virtual memory blocks, N mapping tables may exist, and the N mapping tables are in one-to-one correspondence with the N virtual memory blocks, and are used to record the mapping relationship of the corresponding memory virtual blocks. Among them, the N mapping tables can be recorded as Map 1 to Map N, for example, where Map 1 can be used to record the mapping relationship between the virtual memory block Page 1 and a certain real memory block, and Map 2 can be used to record the virtual memory block Page 2 The mapping relationship to a real memory block, ..., Map N can be used to record the mapping relationship between the virtual memory block Page N and a real memory block.
假设所述物理地址为图2所示地址空间中的0x0040000000,且芯片11视角的内存地址空间0x80000000至0x8FFFFFFF映射到真实的内存地址空间0x0040000000至0x004FFFFFFF,则虚拟内存块0x80000000至0x8FFFFFFF对应Map中所记录的映射关系可以为十六进制的“004”。Assuming that the physical address is 0x0040000000 in the address space shown in Figure 2, and the memory address space 0x80000000 to 0x8FFFFFFF from the perspective of chip 11 is mapped to the real memory address space 0x0040000000 to 0x004FFFFFFF, then the virtual memory blocks 0x80000000 to 0x8FFFFFFF correspond to those recorded in the Map The mapping relationship can be "004" in hexadecimal.
步骤32,根据所述物理地址以及所述映射关系,确定映射到所述物理地址的虚拟地址。Step 32: Determine a virtual address mapped to the physical address according to the physical address and the mapping relationship.
本步骤中,假设所述物理地址为图2所示地址空间中的0x0040000000,且与所述物理地址对应的映射关系为芯片11视角的内存地址空间0x80000000至0x8FFFFFFF映射到真实的内存地址空间0x0040000000至0x004FFFFFFF,则可以确定映射到所述物理地址的虚拟地址为0x80000000。In this step, it is assumed that the physical address is 0x0040000000 in the address space shown in FIG. 2 , and the mapping relationship corresponding to the physical address is that the memory address space 0x80000000 to 0x8FFFFFFF from the perspective of the chip 11 is mapped to the real memory address space 0x0040000000 to 0x004FFFFFFFF, it can be determined that the virtual address mapped to the physical address is 0x80000000.
示例性的,在确定映射到所述物理地址的虚拟地址之后,可以使用所述虚拟地址访问所述内存的所述物理地址,例如可以向所述物理地址中写入数据,或者可以从所述物理地址中读取数据。Exemplarily, after determining the virtual address mapped to the physical address, the physical address of the memory may be accessed using the virtual address, for example, data may be written to the physical address, or data may be retrieved from the physical address. Read data from the physical address.
示例性的,在确定映射到所述物理地址的虚拟地址之后,可以对所述虚拟地址进行偏移处理,例如将虚拟地址+1,并使用偏移处理后的虚拟地址访问所述内存。Exemplarily, after the virtual address mapped to the physical address is determined, the virtual address may be subjected to offset processing, for example, the virtual address is +1, and the virtual address after the offset processing is used to access the memory.
本申请实施例提供的地址映射方式,通过芯片在需要访问内存的物理地址时,确定与物理地址对应的映射关系,根据物理地址以及映射关系,确定映射到物理地址的虚拟地址,其中,芯片是采用至少两种映射方式进行地址映射,与物理地址对应的映射关系的属性为至少两种映射方式中的一种,由于不同映射方式建立和销毁映射关系的时机不同,而不同的建立和销毁映射关系的时机所带来的安全性、内存利用率、内存灵活性以及性能各有优势,因此通过所述芯片是采用至少两种映射方式进行地址映射,使得芯片所进行的地址映射能够具备不同映射方式的优势,从而能够满足应用需求。In the address mapping method provided by the embodiment of the present application, when the chip needs to access the physical address of the memory, the mapping relationship corresponding to the physical address is determined, and the virtual address mapped to the physical address is determined according to the physical address and the mapping relationship, wherein the chip is At least two mapping methods are used for address mapping, and the attribute of the mapping relationship corresponding to the physical address is one of the at least two mapping methods. Due to the different timings for establishing and destroying the mapping relationship in different mapping methods, different mapping methods are established and destroyed. The security, memory utilization, memory flexibility and performance brought by the timing of the relationship have their own advantages. Therefore, the chip uses at least two mapping methods for address mapping, so that the address mapping performed by the chip can have different mappings. The advantages of the method can meet the application requirements.
图6为本申请另一实施例提供的地址映射方法的流程示意图,本实施例在图3所示实施例的基础上,主要描述了在所述至少两种映射方式包括第一映射方式和第二映射方式的情况下,确定与所述物理地址对应的映射关系的具体方式。如图6所示,本实施例提供的方法可以包括:FIG. 6 is a schematic flowchart of an address mapping method provided by another embodiment of the present application. Based on the embodiment shown in FIG. 3 , this embodiment mainly describes that the at least two mapping modes include a first mapping mode and a third mapping mode. In the case of two mapping modes, the specific mode of the mapping relationship corresponding to the physical address is determined. As shown in FIG. 6 , the method provided by this embodiment may include:
步骤61,在需要访问所述内存的物理地址时,在已存在属性为所述第一映射方式的映射关系情况下,确定是否存在与所述物理地址匹配的映射关系。 Step 61 , when the physical address of the memory needs to be accessed, and in the case of an existing mapping relationship whose attribute is the first mapping mode, determine whether there is a mapping relationship matching the physical address.
本步骤中,可以通过查询映射表的方式,确定是否存在与所述物理地址匹配的映射关系。In this step, whether there is a mapping relationship matching the physical address may be determined by querying the mapping table.
一个实施例中,所述第一映射方式可以包括静态映射方式,所述第二映射方式可以包括准静态映射方式,从而实现芯片在已采用静态映射方式进行地址映射的基础上,进一步可以采用准静态映射方式进行地址映射。另一个实施例中,所述第一映射方式可以包括静态映射方式,所述第二映射方式可以包括动态映射方式,从而实现芯片在已采用静态映射方式进行地址映射的基础上,进一步可以采用动态映射方式进行地址映射。又一个实施例中,所述第一映射方式可以包括准静态映射方式,所述第二映射方式可以包括动态映射方式,从而实现芯片在已采用准静态映射方式进行地址映射的基础上,进一步可以采用准静态映射方式进行地址映射。In one embodiment, the first mapping manner may include a static mapping manner, and the second mapping manner may include a quasi-static mapping manner, so that the chip can further use a quasi-static mapping manner on the basis that the static mapping manner has been used for address mapping. Static mapping is used for address mapping. In another embodiment, the first mapping manner may include a static mapping manner, and the second mapping manner may include a dynamic mapping manner, so that on the basis of the address mapping performed by the static mapping manner, the chip may further employ a dynamic mapping manner. The mapping method is used for address mapping. In yet another embodiment, the first mapping manner may include a quasi-static mapping manner, and the second mapping manner may include a dynamic mapping manner, so that the chip can further perform address mapping based on the quasi-static mapping manner. A quasi-static mapping method is used for address mapping.
一个实施例中,在与所述物理地址对应的映射关系的属性为静态映射方式的情况下,所述确定与所述物理地址对应的映射关系之前,还包括:建立属性为所述静态映射方式的所述目标映射关系。In one embodiment, when the attribute of the mapping relationship corresponding to the physical address is a static mapping mode, before determining the mapping relationship corresponding to the physical address, the method further includes: establishing the attribute as the static mapping mode. of the target mapping relationship.
本申请实施例中,对应于所述至少两种映射方式,所述芯片中可以存在至少两种映射表,用于记录对应属性的映射关系。假设所述至少两种映射方式包括静态映射方式、准静态映射方式和动态映射方式三种,则所述芯片中 的映射表可以分为三类,分别为对应于静态映射方式的静态映射表、对应于准静态映射方式的准静态映射表和对应于动态映射方式的动态映射表。In the embodiment of the present application, corresponding to the at least two mapping manners, at least two mapping tables may exist in the chip for recording the mapping relationship of the corresponding attributes. Assuming that the at least two mapping modes include static mapping mode, quasi-static mapping mode and dynamic mapping mode, the mapping table in the chip can be divided into three categories, namely, the static mapping table corresponding to the static mapping mode, The quasi-static mapping table corresponding to the quasi-static mapping mode and the dynamic mapping table corresponding to the dynamic mapping mode.
所述建立属性为所述静态映射方式的所述目标映射关系,具体可以包括:将所述目标映射关系记录在所述静态映射方式对应的一静态映射表中,并使能用于存储所述静态映射表的第一寄存器。可选的,所述将所述目标映射关系记录在所述静态映射方式对应的一静态映射表中之后,还可以包括:将所述静态映射表设置为加锁状态。在所述静态映射表处于加锁状态时可以表示禁止对所述静态映射表中所记录的映射关系进行修改。通过将所述静态映射表设置为加锁状态,可以避免出现对静态映射表的误修改,有利于提高静态映射表的安全性。The establishing the target mapping relationship whose attribute is the static mapping mode may specifically include: recording the target mapping relationship in a static mapping table corresponding to the static mapping mode, and enabling the target mapping relationship to be stored in the static mapping mode. The first register of the static mapping table. Optionally, after recording the target mapping relationship in a static mapping table corresponding to the static mapping mode, the method may further include: setting the static mapping table to a locked state. When the static mapping table is in a locked state, it may indicate that modification of the mapping relationship recorded in the static mapping table is prohibited. By setting the static mapping table to a locked state, it is possible to avoid erroneous modification of the static mapping table, which is beneficial to improve the security of the static mapping table.
可选的,所述将所述静态映射表设置为加锁状态之后,还可以包括:在确定需要修改所述静态映射表中所记录的映射关系时,将所述静态映射表设置为解锁状态,并禁止所述第一寄存器。从而能够实现根据需求对静态映射表中所记录的映射关系进行更新,有利于提高灵活性。需要说明的是,本申请实施例中属性为静态映射方式的映射关系均是采用硬编码的方式进行建立、销毁和修改。Optionally, after setting the static mapping table to a locked state, it may further include: when it is determined that the mapping relationship recorded in the static mapping table needs to be modified, setting the static mapping table to an unlocked state. , and disable the first register. Therefore, the mapping relationship recorded in the static mapping table can be updated according to the requirements, which is beneficial to improve flexibility. It should be noted that, in the embodiments of the present application, the mapping relationships whose attributes are in the static mapping mode are all established, destroyed and modified in a hard-coded manner.
可选的,所述静态映射方式对应静态映射表的数量可以是固定值,或者,所述静态映射方式对应静态映射表的数量可以是根据使用需求配置的可变值。通过所述静态映射方式对应静态映射表的数量是根据使用需求配置的可变值,使得能够根据使用需求灵活配置静态映射表的数量,有利于提高灵活性。Optionally, the number of static mapping tables corresponding to the static mapping mode may be a fixed value, or the number of static mapping tables corresponding to the static mapping mode may be a variable value configured according to usage requirements. The number of static mapping tables corresponding to the static mapping method is a variable value configured according to usage requirements, so that the number of static mapping tables can be flexibly configured according to usage requirements, which is beneficial to improve flexibility.
步骤62,如果存在,所述与所述物理地址匹配的映射关系即为与所述物理地址对应的映射关系。Step 62, if there is, the mapping relationship matching the physical address is the mapping relationship corresponding to the physical address.
需要说明的是,步骤62执行完之后执行步骤64。It should be noted that, after step 62 is performed, step 64 is performed.
步骤63,如果不存在,建立属性为所述第二映射方式的目标映射关系,所述目标映射关系是目标虚拟地址范围映射到目标物理地址范围的映射关系,所述目标物理地址范围包括所述物理地址,所述目标映射关系即为与所述物理地址对应的映射关系。 Step 63, if it does not exist, establish a target mapping relationship whose attribute is the second mapping mode, the target mapping relationship is a mapping relationship between the target virtual address range and the target physical address range, and the target physical address range includes the physical address, and the target mapping relationship is the mapping relationship corresponding to the physical address.
需要说明的是,本申请实施例中属性为非静态映射方式的映射关系均根据需求建立。属于非静态映射方式的准静态映射方式和动态映射方式的区别主要在于两者销毁映射关系的时机不同。具体的,准静态映射方式可以是在 一个或多个算子执行完成的情况下销毁,动态映射方式可以是在需求达成的情况下销毁。It should be noted that, in the embodiments of the present application, the mapping relationships in which the attribute is a non-static mapping manner are established according to requirements. The difference between the quasi-static mapping method and the dynamic mapping method, which are non-static mapping methods, is mainly in the timing of destroying the mapping relationship between the two. Specifically, the quasi-static mapping method can be destroyed when one or more operators are executed, and the dynamic mapping method can be destroyed when the requirements are met.
一个实施例中,在所述第二映射方式包括动态映射方式时,所述建立属性为所述第二映射方式的所述目标映射关系,具体可以包括:建立属性为所述动态映射方式的所述目标映射关系。In an embodiment, when the second mapping mode includes a dynamic mapping mode, the establishing the target mapping relationship whose attribute is the second mapping mode may specifically include: establishing all the attributes whose attributes are the dynamic mapping mode. Describe the target mapping relationship.
所述建立属性为所述动态映射方式的所述目标映射关系,具体可以包括:将所述目标映射关系记录在所述动态映射方式对应的一动态映射表中,并使能用于存储所述动态映射表的第二寄存器。之后,在用于触发创建所述目标映射关系的需求达成的情况下,可以禁止所述第二寄存器。通过禁止所述第二寄存器,可以实现所述目标映射关系的销毁,从而能够实现在需求达成的情况下对动态映射表进行销毁。The establishing the target mapping relationship whose attribute is the dynamic mapping mode may specifically include: recording the target mapping relationship in a dynamic mapping table corresponding to the dynamic mapping mode, and enabling the target mapping relationship to be stored in the dynamic mapping mode. The second register of the dynamic mapping table. Afterwards, when the requirement for triggering the creation of the target mapping relationship is fulfilled, the second register may be disabled. By disabling the second register, the target mapping relationship can be destroyed, so that the dynamic mapping table can be destroyed when the requirement is met.
可选的,所述动态映射方式对应动态映射表的数量可以是固定值,或者,所述动态映射方式对应动态映射表的数量可以是根据使用需求配置的可变值。通过所述动态映射方式对应动态映射表的数量是根据使用需求配置的可变值,使得能够根据使用需求灵活配置动态映射表的数量,有利于提高灵活性。Optionally, the number of dynamic mapping tables corresponding to the dynamic mapping mode may be a fixed value, or the number of dynamic mapping tables corresponding to the dynamic mapping mode may be a variable value configured according to usage requirements. The number of dynamic mapping tables corresponding to the dynamic mapping method is a variable value configured according to usage requirements, so that the number of dynamic mapping tables can be flexibly configured according to usage requirements, which is beneficial to improve flexibility.
另一个实施例中,在所述第二映射方式包括准静态映射方式时,所述建立属性为所述第二映射方式的所述目标映射关系,具体可以包括:建立属性为所述准静态映射方式的所述目标映射关系。In another embodiment, when the second mapping mode includes a quasi-static mapping mode, the establishing the target mapping relationship whose attribute is the second mapping mode may specifically include: establishing an attribute as the quasi-static mapping The target mapping relationship of the mode.
所述建立属性为所述准静态映射方式的所述目标映射关系,具体可以包括:确定是否存在处于解锁状态的准静态映射表;如果是,则将所述目标映射关系记录处于解锁状态的一准静态映射表中,并将所述准静态映射表设置为加锁状态,并使能用于存储所述动态映射表的第三寄存器。在所述静态映射表处于加锁状态时可以表示禁止对所述静态映射表中所记录的映射关系进行修改。通过将所述静态映射表设置为加锁状态,可以避免在一个或多个算子执行完成之前,对静态映射表进行误修改,有利于提高静态映射表的安全性。The establishment of the target mapping relationship whose attribute is the quasi-static mapping mode may specifically include: determining whether there is a quasi-static mapping table in an unlocked state; if so, recording the target mapping relationship in an unlocked state. In the quasi-static mapping table, the quasi-static mapping table is set to a locked state, and the third register for storing the dynamic mapping table is enabled. When the static mapping table is in a locked state, it may indicate that modification of the mapping relationship recorded in the static mapping table is prohibited. By setting the static mapping table to a locked state, it can be avoided that the static mapping table is incorrectly modified before the execution of one or more operators is completed, which is beneficial to improve the security of the static mapping table.
进一步可选的,如果确定不存在处于解锁状态的准静态映射表,则可以建立属性为动态映射方式的所述目标映射关系。Further optionally, if it is determined that there is no quasi-static mapping table in the unlocked state, the target mapping relationship whose attribute is a dynamic mapping mode can be established.
可选的,所述将所述准静态映射表设置为加锁状态之后,还可以包括:在一个或多个算子执行完成的情况下,将所述准静态映射表设置为解锁状态, 并禁止所述第三寄存器。通过将所述静态映射表设置为解锁状态并禁止所述第三寄存器,可以实现所述目标映射关系的销毁,从而能够实现以一个或多个算子为单位对准静态映射表进行销毁。Optionally, after setting the quasi-static mapping table to a locked state, it may further include: in the case that the execution of one or more operators is completed, setting the quasi-static mapping table to an unlocked state, and The third register is disabled. By setting the static mapping table to an unlocked state and disabling the third register, the target mapping relationship can be destroyed, so that the static mapping table can be destroyed in units of one or more operators.
可选的,所述准静态映射方式对应准静态映射表的数量可以是固定值,或者,所述准静态映射方式对应准静态映射表的数量可以是根据使用需求配置的可变值。通过所述准静态映射方式对应准静态映射表的数量是根据使用需求配置的可变值,使得能够根据使用需求灵活配置准静态映射表的数量,有利于提高灵活性。Optionally, the number of quasi-static mapping tables corresponding to the quasi-static mapping mode may be a fixed value, or the number of quasi-static mapping tables corresponding to the quasi-static mapping mode may be a variable value configured according to usage requirements. The number of quasi-static mapping tables corresponding to the quasi-static mapping method is a variable value configured according to usage requirements, so that the number of quasi-static mapping tables can be flexibly configured according to usage requirements, which is beneficial to improve flexibility.
又一个实施例中,在所述第二映射方式的数量为多个的情况下,所述建立属性为所述第二映射方式的所述目标映射关系,具体可以包括:确定多个所述第二映射方式中的目标第二映射方式,并建立属性为所述目标映射方式的所述目标映射关系。从而能够实现根据需求灵活选择多个第二映射方式中的一个来进行目标映射关系的建立。In yet another embodiment, in the case that the number of the second mapping modes is multiple, the establishing the target mapping relationship whose attribute is the second mapping mode may specifically include: determining a plurality of the first mapping modes. The second mapping mode of the target in the two mapping modes is established, and the target mapping relationship whose attribute is the target mapping mode is established. Therefore, it is possible to flexibly select one of the multiple second mapping manners according to requirements to establish the target mapping relationship.
示例性的,所述多个所述第二映射方式可以包括所述准静态映射方式和所述动态映射方式,所述目标第二映射方式可以为所述准静态映射方式和所述动态映射方式中的一者。可选的,所述确定多个所述第二映射方式中的目标第二映射方式,包括:确定是否存在处于解锁状态的准静态映射表;如果是,所述准静态映射方式为目标第二映射方式,如果否,则所述动态映射方式为目标第二映射方式。从而能够实现优先建立属性为准静态映射方式的映射关系。Exemplarily, the plurality of second mapping modes may include the quasi-static mapping mode and the dynamic mapping mode, and the target second mapping mode may be the quasi-static mapping mode and the dynamic mapping mode. one of the. Optionally, the determining the target second mapping mode among the plurality of second mapping modes includes: determining whether there is a quasi-static mapping table in an unlocked state; if so, the quasi-static mapping mode is the target second mapping mode. Mapping mode, if not, the dynamic mapping mode is the target second mapping mode. Therefore, it is possible to establish a mapping relationship in a quasi-static mapping manner of attributes preferentially.
一个实施例中,静态映射表、准静态映射表和动态映射表三者的特点对比如下表1所示。In one embodiment, the characteristics of the static mapping table, the quasi-static mapping table and the dynamic mapping table are compared as shown in Table 1 below.
表1Table 1
   静态映射表static mapping table 准静态映射表Quasi-static mapping table 动态映射表dynamic mapping table
根据需求创建Create on demand NN YY YY
根据需求修改Modify as needed NN NN YY
加锁lock YY YY NN
硬编码方式创建Hardcoded to create YY NN NN
硬编码方式修改hard-coded modification YY NN NN
硬编码方式解锁Hardcoded to unlock YY NN NN
整体销毁total destruction NN YY YY
数量可配Quantity available YY YY YY
注,“N”表示否,“Y”表示是。Note, "N" means no, "Y" means yes.
结合表1可以看出,本申请一实施例中,静态映射表的特点可以为:静态映射表中所记录的映射关系是采用硬编码方式创建、静态映射表支持加锁和解锁且解锁是以硬编码方式进行,静态映射表的数量可配置,且静态映射表是单独销毁。准静态映射表的特点可以为:准静态映射表所记录的映射关系是根据需求创建,准静态映射表支持加锁,准静态映射表的数量可配置,且准静态映射表是整体销毁。动态映射表的特点可以为:动态映射表所记录的映射关系是根据需求创建并根据需求修改,动态映射表不支持加锁,动态映射表的数量可配置,且动态映射表可以整体销毁。其中,以一个算子为单位为例,准静态映射表的整体销毁可以是指在该算子执行完成的情况下,将准静态映射表中当前所记录的映射关系全部销毁,动态映射表的整体销毁可以是指在该算子执行完成的情况下,将动态映射表中当前所记录的映射关系全部销毁。As can be seen in conjunction with Table 1, in an embodiment of the present application, the characteristics of the static mapping table can be: the mapping relationship recorded in the static mapping table is created in a hard-coded manner, the static mapping table supports locking and unlocking, and the unlocking is based on Hard-coded, the number of static mapping tables can be configured, and the static mapping tables are destroyed separately. The characteristics of the quasi-static mapping table may be: the mapping relationship recorded in the quasi-static mapping table is created according to the requirements, the quasi-static mapping table supports locking, the number of the quasi-static mapping table is configurable, and the quasi-static mapping table is destroyed as a whole. The characteristics of the dynamic mapping table can be: the mapping relationship recorded in the dynamic mapping table is created and modified according to the requirements, the dynamic mapping table does not support locking, the number of dynamic mapping tables can be configured, and the dynamic mapping table can be destroyed as a whole. Among them, taking an operator as an example, the overall destruction of the quasi-static mapping table may refer to destroying all the mapping relationships currently recorded in the quasi-static mapping table when the execution of the operator is completed, and the dynamic mapping table is completely destroyed. The overall destruction may refer to destroying all the mapping relationships currently recorded in the dynamic mapping table when the execution of the operator is completed.
一个实施例中,在所述第一映射方式包括准静态映射方式、所述第二静态映射方式包括动态映射方式时,所述步骤63中的建立属性为所述第二映射方式的目标映射关系,具体可以包括:确定是否存在处于解锁状态的准静态映射表;以及,如果否,则可以建立属性为动态映射方式的所述目标映射关系。进一步的,如果存在处于解锁状态的准静态映射表,则可以将所述目标映射关系记录在处于解锁状态的一准静态映射表中,将所述准静态映射表设置为加锁状态,并使能用于存储所述动态映射表的第三寄存器。需要说明的是,关于建立属性为动态映射方式或静态映射方式的目标映射关系的具体方式,可以参见前述描述,在此不再赘述。In one embodiment, when the first mapping mode includes a quasi-static mapping mode and the second static mapping mode includes a dynamic mapping mode, the establishment attribute in step 63 is the target mapping relationship of the second mapping mode. , which may specifically include: determining whether there is a quasi-static mapping table in an unlocked state; and, if not, establishing the target mapping relationship whose attribute is a dynamic mapping manner. Further, if there is a quasi-static mapping table in an unlocked state, the target mapping relationship can be recorded in a quasi-static mapping table in an unlocked state, the quasi-static mapping table is set to a locked state, and the A third register that can be used to store the dynamic mapping table. It should be noted that, for a specific manner of establishing a target mapping relationship whose attribute is a dynamic mapping manner or a static mapping manner, reference may be made to the foregoing description, which will not be repeated here.
步骤64,根据所述物理地址以及所述映射关系,确定映射到所述物理地址的虚拟地址。Step 64: Determine the virtual address mapped to the physical address according to the physical address and the mapping relationship.
需要说明的是,步骤64与步骤32类似,在此不再赘述。It should be noted that step 64 is similar to step 32, and details are not repeated here.
本实施例提供的地址映射方法,通过在已存在属性为第一映射方式的映射关系情况下,确定是否存在与物理地址匹配的映射关系,如果存在则可以与物理地址匹配的映射关系即为与物理地址对应的映射关系,如果不存在则可以建立属性为第二映射方式的目标映射关系,实现了在已存在属性为第一映射方式的映射关系的基础上,进一步可以建立属性为第二映射方式的映射关系,从而满足了对于不同映射方式的映射关系的需求。The address mapping method provided in this embodiment determines whether there is a mapping relationship that matches the physical address when there is a mapping relationship whose attribute is the first mapping mode. If there is, the mapping relationship that can match the physical address is the same as If the mapping relationship corresponding to the physical address does not exist, the target mapping relationship with the attribute as the second mapping mode can be established, so that on the basis of the existing mapping relationship with the attribute as the first mapping mode, the attribute as the second mapping mode can be further established. The mapping relationship of the mode, thus meeting the requirements for the mapping relationship of different mapping modes.
以所述至少两种映射方式包括静态映射方式、动态映射方式和准静态映 射方式为例,如图7所示,对芯片进行地址映射的过程进行举例说明。Taking the at least two mapping modes including static mapping mode, dynamic mapping mode and quasi-static mapping mode as an example, as shown in FIG. 7 , the process of performing address mapping on a chip is illustrated by an example.
步骤71,配置静态映射表、动态映射表和准静态映射表三者分别的数量。Step 71: Configure the respective numbers of the static mapping table, the dynamic mapping table and the quasi-static mapping table.
例如,可以通过调用void config_map(size_t static_map,size_t qstatic_map,size_t dynamic_map)来配置映射表数量。在config_map中可以将static_map作为静态映射表的数量,将qstatic_map作为准静态映射表的数量,将dynamic_map作为动态映射表的数量。在config_map中还可以限制静态映射表、准静态映射表和动态映射表三者之和小于映射表总数(例如N)。For example, the number of mapping tables can be configured by calling void config_map(size_t static_map, size_t qstatic_map, size_t dynamic_map). In config_map, static_map can be used as the number of static mapping tables, qstatic_map can be used as the number of quasi-static mapping tables, and dynamic_map can be used as the number of dynamic mapping tables. In config_map, the sum of the static mapping table, the quasi-static mapping table and the dynamic mapping table can also be restricted to be smaller than the total number of mapping tables (for example, N).
这里,可以假设静态映射表和准静态映射表的数量均为4,动态映射表的数量为N-8,如图8所示,Map 1至Map 4例如可以是静态映射表、Map 5至Map 8例如可以是准静态映射表,Map 9至Map N例如可以是动态映射表,N个Map与图5所示的N个Page一一对应,且Map i对应Page i。Here, it can be assumed that the number of static mapping tables and quasi-static mapping tables is 4, and the number of dynamic mapping tables is N-8, as shown in FIG. 8 , Map 1 to Map 4 can be, for example, static mapping tables, Map 5 to Map 8 can be, for example, a quasi-static mapping table, and Map 9 to Map N can be, for example, a dynamic mapping table. The N Maps correspond one-to-one with the N Pages shown in FIG. 5 , and Map i corresponds to Page i.
步骤72,建立属性为静态映射方式的映射关系。 Step 72, establishing a mapping relationship in which the attribute is a static mapping mode.
例如,可以通过调用int32_t config_lock_mapX(uint64_t physical_addr),来建立属性为静态映射方式的映射表,其中,X可以对应某一静态映射表Map X,Map X具体可以为Map 1至Map 4中的某一个,physical_addr可以表示某一物理地址。在config_lock_mapX中可以将PageX映射到uint64_t physical_addr所代表的物理内存块的映射关系记录在Map X中,将Map X设置为加锁状态,并使能(Enable)用于存储Map X的寄存器。For example, by calling int32_t config_lock_mapX(uint64_t physical_addr), a mapping table whose attribute is static mapping can be established, where X can correspond to a static mapping table Map X, and Map X can be one of Map 1 to Map 4. , physical_addr can represent a physical address. In config_lock_mapX, the mapping relationship between PageX and the physical memory block represented by uint64_t physical_addr can be recorded in Map X, set Map X to the locked state, and enable the register used to store Map X.
之后,在需要修改某一静态映射表中所记录的映射关系时,还可以调用void release_mapX()来销毁所建立的属性为静态映射方式的映射表,其中,X可以对应某一静态映射表Map X。在release_mapX中可以将Map X设置为解锁状态,并禁止用于存储Map X的寄存器。之后,可以进一步调用config_lock_mapX来建立映射关系,以实现该静态映射表中映射关系的更新。After that, when you need to modify the mapping relationship recorded in a static mapping table, you can also call void release_mapX() to destroy the mapping table whose attributes are static mapping, where X can correspond to a static mapping table Map X. In release_mapX, Map X can be set to the unlocked state and the registers used to store Map X are disabled. After that, config_lock_mapX can be further called to establish the mapping relationship, so as to realize the updating of the mapping relationship in the static mapping table.
步骤73,执行某一算子的过程中,在需要访问内存的某一物理地址时,确定是否存在与该物理地址匹配的映射关系。 Step 73 , in the process of executing a certain operator, when it is necessary to access a certain physical address of the memory, determine whether there is a mapping relationship matching the physical address.
如果存在与该物理地址匹配的映射关系,则可以执行步骤77,可以理解的是与该物理地址匹配的映射关系即为与该物理地址对应的映射关系。如果不存在与物理地址匹配的映射关系,则可以执行步骤74。If there is a mapping relationship matching the physical address, step 77 may be executed, and it can be understood that the mapping relationship matching the physical address is the mapping relationship corresponding to the physical address. If there is no mapping relationship matching the physical address, step 74 may be performed.
步骤74,确定是否存在处于解锁状态的准静态映射表。 Step 74, determine whether there is a quasi-static mapping table in an unlocked state.
如果存在处于解锁状态的准静态映射表,则可以执行步骤75。如果不存在处于解锁状态的准静态映射表,则可以执行步骤76。If there is a quasi-static mapping table in an unlocked state, step 75 may be performed. If there is no quasi-static mapping table in the unlocked state, step 76 may be performed.
步骤75,将目标映射关系记录在处于解锁状态的一准静态映射表中,将该准静态映射表设置为加锁状态,并使能用于存储该准静态映射表的寄存器。Step 75: Record the target mapping relationship in a quasi-static mapping table in an unlocked state, set the quasi-static mapping table to a locked state, and enable a register for storing the quasi-static mapping table.
需要说明的是,执行完步骤75之后进一步执行步骤77。It should be noted that, after step 75 is performed, step 77 is further performed.
步骤76,将目标映射关系记录在一动态映射表中,并使能用于存储该动态映射表的寄存器。Step 76: Record the target mapping relationship in a dynamic mapping table, and enable a register for storing the dynamic mapping table.
需要说明的是,在执行完步骤76之后进一步执行步骤77。可以理解的是,目标映射关系即为与该物理地址对应的映射关系。It should be noted that after step 76 is performed, step 77 is further performed. It can be understood that the target mapping relationship is the mapping relationship corresponding to the physical address.
步骤77,根据与该物理地址对应的映射关系,确定映射到该物理地址的虚拟地址。Step 77: Determine the virtual address mapped to the physical address according to the mapping relationship corresponding to the physical address.
步骤78中,使用映射到该物理地址的虚拟地址,访问内存中该物理地址对应的地址空间。In step 78, the address space corresponding to the physical address in the memory is accessed using the virtual address mapped to the physical address.
需要说明的是,步骤78中是以使用映射到该物理地址的虚拟地址进行内存访问为例。It should be noted that, in step 78, the memory access using the virtual address mapped to the physical address is used as an example.
步骤79,如果该目标映射关系是记录在该动态映射表中,则在需求达成的情况下销毁该动态映射表。 Step 79, if the target mapping relationship is recorded in the dynamic mapping table, destroy the dynamic mapping table when the requirement is met.
例如,可以通过调用void release_dynamic_map()来销毁属性为动态映射方式的映射关系。在release_dynamic_map中可以禁止用于存储该动态映射表的寄存器。For example, you can call void release_dynamic_map() to destroy the mapping relationship whose attributes are in dynamic mapping mode. Registers used to store the dynamic mapping table can be disabled in release_dynamic_map.
步骤710,如果目标映射关系是记录在该准静态映射表中,则在该算子执行完成的情况下,销毁该准静态映射表。In step 710, if the target mapping relationship is recorded in the quasi-static mapping table, in the case that the execution of the operator is completed, destroy the quasi-static mapping table.
例如,可以通过调用void release_qstatic_map()来销毁属性为准静态映射方式的映射关系。在release_qstatic_map中可以将所有静态映射表均设置为解锁状态,并禁止用于存储各静态映射表的寄存器。For example, the quasi-static mapping of attributes can be destroyed by calling void release_qstatic_map(). In release_qstatic_map, all static mapping tables can be set to an unlocked state, and the registers used to store each static mapping table are prohibited.
可选的,在需要确定某一虚拟地址对应的物理地址时,例如可以通过调用uint64_t get_physical_address(uint32_t virtual_addr)实现,其中,virtual_addr表示一虚拟地址。在get_physical_address中可以基于根据该逻辑地址以及对应的映射关系,确定该逻辑地址映射到的物理地址。Optionally, when the physical address corresponding to a certain virtual address needs to be determined, for example, it can be implemented by calling uint64_t get_physical_address(uint32_t virtual_addr), where virtual_addr represents a virtual address. In get_physical_address, the physical address to which the logical address is mapped may be determined based on the logical address and the corresponding mapping relationship.
图9为本申请一实施例提供的地址映射装置的结构示意图,该装置应用于芯片,所述芯片能够采用地址映射的方式访问内存,如图9所示,该装置90可以包括:处理器91和存储器92。FIG. 9 is a schematic structural diagram of an address mapping apparatus provided by an embodiment of the present application. The apparatus is applied to a chip, and the chip can access memory by means of address mapping. As shown in FIG. 9 , the apparatus 90 may include: a processor 91 and memory 92.
所述存储器92,用于存储程序代码;The memory 92 is used to store program codes;
所述处理器91,调用所述程序代码,当程序代码被执行时,用于执行以下操作:The processor 91 calls the program code, and when the program code is executed, is configured to perform the following operations:
在需要访问所述内存的物理地址时,确定与所述物理地址对应的映射关系,所述芯片是采用至少两种映射方式进行地址映射,所述映射关系的属性为所述至少两种映射方式中的一种;When the physical address of the memory needs to be accessed, a mapping relationship corresponding to the physical address is determined, the chip uses at least two mapping methods for address mapping, and the attributes of the mapping relationship are the at least two mapping methods one of the
根据所述物理地址以及所述映射关系,确定映射到所述物理地址的虚拟地址。According to the physical address and the mapping relationship, the virtual address mapped to the physical address is determined.
本实施例提供的地址映射装置,可以用于执行前述方法实施例的技术方案,其实现原理和技术效果与方法实施例类似,在此不再赘述。The address mapping apparatus provided in this embodiment can be used to implement the technical solutions of the foregoing method embodiments, and the implementation principles and technical effects thereof are similar to those of the method embodiments, which will not be repeated here.
本领域普通技术人员可以理解:实现上述各方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成。前述的程序可以存储于一计算机可读取存储介质中。该程序在执行时,执行包括上述各方法实施例的步骤;而前述的存储介质包括:ROM、RAM、磁碟或者光盘等各种可以存储程序代码的介质。Those of ordinary skill in the art can understand that all or part of the steps of implementing the above method embodiments may be completed by program instructions related to hardware. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps including the above method embodiments are executed; and the foregoing storage medium includes: ROM, RAM, magnetic disk or optical disk and other media that can store program codes.
最后应说明的是:以上各实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述各实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分或者全部技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的范围。Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, but not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: The technical solutions described in the foregoing embodiments can still be modified, or some or all of the technical features thereof can be equivalently replaced; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the technical solutions of the embodiments of the present application. scope.

Claims (54)

  1. 一种地址映射方法,应用于芯片,所述芯片能够采用地址映射的方式访问内存,其特征在于,所述方法包括:An address mapping method, applied to a chip, wherein the chip can access memory by means of address mapping, wherein the method comprises:
    在需要访问所述内存的物理地址时,确定与所述物理地址对应的映射关系,所述芯片是采用至少两种映射方式进行地址映射,所述映射关系的属性为所述至少两种映射方式中的一种;When the physical address of the memory needs to be accessed, a mapping relationship corresponding to the physical address is determined, the chip uses at least two mapping methods for address mapping, and the attributes of the mapping relationship are the at least two mapping methods one of the
    根据所述物理地址以及所述映射关系,确定映射到所述物理地址的虚拟地址。According to the physical address and the mapping relationship, the virtual address mapped to the physical address is determined.
  2. 根据权利要求1所述的方法,其特征在于,所述至少两种映射方式包括第一映射方式和第二映射方式,所述确定与所述物理地址对应的映射关系,包括:The method according to claim 1, wherein the at least two mapping modes include a first mapping mode and a second mapping mode, and the determining the mapping relationship corresponding to the physical address includes:
    在已存在属性为第一映射方式的映射关系情况下,确定是否存在与所述物理地址匹配的映射关系;In the case of an existing mapping relationship whose attribute is the first mapping mode, determine whether there is a mapping relationship matching the physical address;
    如果存在,所述与所述物理地址匹配的映射关系即为与所述物理地址对应的映射关系;If there is, the mapping relationship matching the physical address is the mapping relationship corresponding to the physical address;
    如果不存在,建立属性为所述第二映射方式的目标映射关系,所述目标映射关系是目标虚拟地址范围映射到目标物理地址范围的映射关系,所述目标物理地址范围包括所述物理地址,所述目标映射关系即为与所述物理地址对应的映射关系。If it does not exist, establish a target mapping relationship whose attribute is the second mapping mode, where the target mapping relationship is a mapping relationship in which the target virtual address range is mapped to the target physical address range, and the target physical address range includes the physical address, The target mapping relationship is the mapping relationship corresponding to the physical address.
  3. 根据权利要求2所述的方法,其特征在于,所述第一映射方式包括静态映射方式,所述静态映射方式是采用硬编码方式建立并销毁映射关系的映射方式。The method according to claim 2, wherein the first mapping manner includes a static mapping manner, and the static mapping manner is a mapping manner in which a mapping relationship is established and destroyed in a hard-coded manner.
  4. 根据权利要求3所述的方法,其特征在于,所述静态映射方式包括第一静态映射方式,所述第一静态映射方式是以芯片为单位,采用硬编码方式建立并销毁映射关系的映射方式。The method according to claim 3, wherein the static mapping method includes a first static mapping method, and the first static mapping method is a mapping method in which a mapping relationship is established and destroyed by hard coding in a chip unit. .
  5. 根据权利要求3所述的方法,其特征在于,所述静态映射方式包括第二静态映射方式,所述第二静态映射方式是以一个或多个算子为单位,采用硬编码方式建立并销毁映射关系的映射方式。The method according to claim 3, wherein the static mapping method includes a second static mapping method, and the second static mapping method is established and destroyed in a hard-coded manner in units of one or more operators. The mapping method of the mapping relationship.
  6. 根据权利要求3所述的方法,其特征在于,在与所述物理地址对应的映射关系的属性为静态映射方式的情况下,所述确定与所述物理地址对应的映射关系之前,还包括:建立属性为所述静态映射方式的所述目标映射关系。The method according to claim 3, wherein, when the attribute of the mapping relationship corresponding to the physical address is a static mapping mode, before the determining the mapping relationship corresponding to the physical address, the method further comprises: The target mapping relationship whose attribute is the static mapping mode is established.
  7. 根据权利要求6所述的方法,其特征在于,所述建立属性为所述静态映射方式的所述目标映射关系,包括:将所述目标映射关系记录在所述静态映射方式对应的一静态映射表中,并使能用于存储所述静态映射表的第一寄存器。The method according to claim 6, wherein the establishing the target mapping relationship whose attribute is the static mapping mode comprises: recording the target mapping relationship in a static mapping corresponding to the static mapping mode table and enable the first register for storing the static mapping table.
  8. 根据权利要求7所述的方法,其特征在于,所述将所述目标映射关系记录在所述静态映射方式对应的一静态映射表中之后,还包括:将所述静态映射表设置为加锁状态。The method according to claim 7, wherein after recording the target mapping relationship in a static mapping table corresponding to the static mapping mode, the method further comprises: setting the static mapping table to be locked state.
  9. 根据权利要求8所述的方法,其特征在于,所述将所述静态映射表设置为加锁状态之后,还包括:在需要修改所述静态映射表中所记录的映射关系时,将所述静态映射表设置为解锁状态,并禁止所述第一寄存器。The method according to claim 8, wherein after setting the static mapping table to a locked state, the method further comprises: when a mapping relationship recorded in the static mapping table needs to be modified, The static mapping table is set to an unlocked state and the first register is disabled.
  10. 根据权利要求7所述的方法,其特征在于,所述静态映射方式对应静态映射表的数量是固定值。The method according to claim 7, wherein the number of static mapping tables corresponding to the static mapping mode is a fixed value.
  11. 根据权利要求7所述的方法,其特征在于,所述静态映射方式对应静态映射表的数量是根据使用需求配置的可变值。The method according to claim 7, wherein the number of static mapping tables corresponding to the static mapping mode is a variable value configured according to usage requirements.
  12. 根据权利要求3-11任一项所述的方法,其特征在于,所述第二映射方式包括:动态映射方式;所述动态映射方式是根据需求建立并销毁映射关系的映射方式;The method according to any one of claims 3-11, wherein the second mapping mode comprises: a dynamic mapping mode; the dynamic mapping mode is a mapping mode in which a mapping relationship is established and destroyed according to requirements;
    所述建立属性为所述第二映射方式的所述目标映射关系,包括:建立属性为所述动态映射方式的所述目标映射关系。The establishing the target mapping relationship whose attribute is the second mapping mode includes: establishing the target mapping relationship whose attribute is the dynamic mapping mode.
  13. 根据权利要求12所述的方法,其特征在于,所述建立属性为所述动态映射方式的所述目标映射关系,包括:将所述目标映射关系记录在所述动态映射方式对应的一动态映射表中,并使能用于存储所述动态映射表的第二寄存器。The method according to claim 12, wherein the establishing the target mapping relationship whose attribute is the dynamic mapping mode comprises: recording the target mapping relationship in a dynamic mapping corresponding to the dynamic mapping mode table and enable a second register for storing the dynamic mapping table.
  14. 根据权利要求13所述的方法,其特征在于,所述方法还包括:在需求达成的情况下,禁止所述第二寄存器。The method according to claim 13, wherein the method further comprises: disabling the second register when the requirement is met.
  15. 根据权利要求13所述的方法,其特征在于,所述动态映射方式对应动态映射表的数量是固定值。The method according to claim 13, wherein the number of dynamic mapping tables corresponding to the dynamic mapping mode is a fixed value.
  16. 根据权利要求13所述的方法,其特征在于,所述动态映射方式对应动态映射表的数量是根据使用需求配置的可变值。The method according to claim 13, wherein the number of the dynamic mapping table corresponding to the dynamic mapping mode is a variable value configured according to usage requirements.
  17. 根据权利要求2或12所述的方法,其特征在于,所述第二映射方式包括准静态映射方式;所述准静态映射方式是根据需求建立映射关系,并以 一个或多个算子为单位销毁映射关系的映射方式;The method according to claim 2 or 12, wherein the second mapping method includes a quasi-static mapping method; the quasi-static mapping method is to establish a mapping relationship according to requirements, and use one or more operators as a unit Destroy the mapping method of the mapping relationship;
    所述建立属性为所述第二映射方式的所述目标映射关系,包括:建立属性为所述准静态映射方式的所述目标映射关系。The establishing the target mapping relationship whose attribute is the second mapping mode includes: establishing the target mapping relationship whose attribute is the quasi-static mapping mode.
  18. 根据权利要求17所述的方法,其特征在于,所述建立属性为所述准静态映射方式的所述目标映射关系,包括:The method according to claim 17, wherein the establishing the target mapping relationship whose attribute is the quasi-static mapping method comprises:
    确定是否存在处于解锁状态的准静态映射表;Determine if there is a quasi-static mapping table in the unlocked state;
    如果是,则将所述目标映射关系记录在处于解锁状态的一准静态映射表中,将所述准静态映射表设置为加锁状态,并使能用于存储所述动态映射表的第三寄存器。If so, record the target mapping relationship in a quasi-static mapping table in an unlocked state, set the quasi-static mapping table to a locked state, and enable a third mapping table for storing the dynamic mapping table register.
  19. 根据权利要求18所述的方法,其特征在于,所述将所述准静态映射表设置为加锁状态之后,还包括:在一个或多个算子执行完成的情况下,将所述准静态映射表设置为解锁状态,并禁止所述第三寄存器。The method according to claim 18, wherein after setting the quasi-static mapping table to a locked state, the method further comprises: in the case that the execution of one or more operators is completed, setting the quasi-static mapping table to a locked state. The mapping table is set to an unlocked state and the third register is disabled.
  20. 根据权利要求18所述的方法,其特征在于,所述方法还包括:如果确定不存在处于解锁状态的准静态映射表,则建立属性为动态映射方式的所述目标映射关系。The method according to claim 18, wherein the method further comprises: if it is determined that there is no quasi-static mapping table in an unlocked state, establishing the target mapping relationship whose attribute is a dynamic mapping mode.
  21. 根据权利要求18所述的方法,其特征在于,所述准静态映射方式对应的准静态映射表的数量是固定值。The method according to claim 18, wherein the number of quasi-static mapping tables corresponding to the quasi-static mapping mode is a fixed value.
  22. 根据权利要求18所述的方法,其特征在于,所述准静态映射方式对应的准静态映射表的数量是根据使用需求配置的可变值。The method according to claim 18, wherein the number of quasi-static mapping tables corresponding to the quasi-static mapping mode is a variable value configured according to usage requirements.
  23. 根据权利要求2所述的方法,其特征在于,在所述第二映射方式的数量为多个的情况下,所述建立属性为所述第二映射方式的所述目标映射关系,包括:The method according to claim 2, wherein, when the number of the second mapping modes is multiple, the establishing the target mapping relationship whose attribute is the second mapping mode comprises:
    确定多个所述第二映射方式中的目标映射方式,并建立属性为所述目标映射方式的所述目标映射关系。A plurality of target mapping modes in the second mapping modes are determined, and the target mapping relationship whose attribute is the target mapping mode is established.
  24. 根据权利要求2所述的方法,其特征在于,所述第一映射方式包括准静态映射方式,所述第二映射方式包括动态映射方式;其中,所述准静态映射方式是根据需求建立映射关系,并以一个或多个算子为单位销毁映射关系的映射方式;所述动态映射方式是根据需求建立并销毁映射关系的映射方式。The method according to claim 2, wherein the first mapping mode includes a quasi-static mapping mode, and the second mapping mode includes a dynamic mapping mode; wherein, the quasi-static mapping mode is to establish a mapping relationship according to requirements , and destroy the mapping method of the mapping relationship with one or more operators as a unit; the dynamic mapping method is a mapping method of establishing and destroying the mapping relationship according to the requirements.
  25. 根据权利要求24所述的方法,其特征在于,所述建立属性为所述第二映射方式的目标映射关系,包括:The method according to claim 24, wherein the establishing a target mapping relationship whose attribute is the second mapping mode comprises:
    确定是否存在处于解锁状态的准静态映射表;Determine if there is a quasi-static mapping table in the unlocked state;
    如果否,则建立属性为动态映射方式的所述目标映射关系。If not, establish the target mapping relationship whose attribute is the dynamic mapping mode.
  26. 根据权利要求25所述的方法,其特征在于,所述方法还包括:The method of claim 25, wherein the method further comprises:
    如果存在处于解锁状态的准静态映射表,则将所述目标映射关系记录在处于解锁状态的一准静态映射表中,将所述准静态映射表设置为加锁状态,并使能用于存储所述动态映射表的第三寄存器。If there is a quasi-static mapping table in an unlocked state, record the target mapping relationship in a quasi-static mapping table in an unlocked state, set the quasi-static mapping table in a locked state, and enable the quasi-static mapping table to be used for storage the third register of the dynamic mapping table.
  27. 一种地址映射装置,应用于芯片,所述芯片能够采用地址映射的方式访问内存,其特征在于,所述装置包括:存储器和处理器;An address mapping device, applied to a chip, wherein the chip can access memory by means of address mapping, characterized in that the device comprises: a memory and a processor;
    所述存储器,用于存储程序代码;the memory for storing program codes;
    所述处理器,调用所述程序代码,当程序代码被执行时,用于执行以下操作:The processor calls the program code, and when the program code is executed, is configured to perform the following operations:
    在需要访问所述内存的物理地址时,确定与所述物理地址对应的映射关系,所述芯片是采用至少两种映射方式进行地址映射,所述映射关系的属性为所述至少两种映射方式中的一种;When the physical address of the memory needs to be accessed, a mapping relationship corresponding to the physical address is determined, the chip uses at least two mapping methods for address mapping, and the attributes of the mapping relationship are the at least two mapping methods one of the
    根据所述物理地址以及所述映射关系,确定映射到所述物理地址的虚拟地址。According to the physical address and the mapping relationship, the virtual address mapped to the physical address is determined.
  28. 根据权利要求27所述的装置,其特征在于,所述至少两种映射方式包括第一映射方式和第二映射方式,所述处理器用于确定与所述物理地址对应的映射关系,具体包括:The apparatus according to claim 27, wherein the at least two mapping modes include a first mapping mode and a second mapping mode, and the processor is configured to determine the mapping relationship corresponding to the physical address, specifically including:
    在已存在属性为第一映射方式的映射关系情况下,确定是否存在与所述物理地址匹配的映射关系;In the case of an existing mapping relationship whose attribute is the first mapping mode, determine whether there is a mapping relationship matching the physical address;
    如果存在,所述与所述物理地址匹配的映射关系即为与所述物理地址对应的映射关系;If there is, the mapping relationship matching the physical address is the mapping relationship corresponding to the physical address;
    如果不存在,建立属性为所述第二映射方式的目标映射关系,所述目标映射关系是目标虚拟地址范围映射到目标物理地址范围的映射关系,所述目标物理地址范围包括所述物理地址,所述目标映射关系即为与所述物理地址对应的映射关系。If it does not exist, establish a target mapping relationship whose attribute is the second mapping mode, where the target mapping relationship is a mapping relationship in which the target virtual address range is mapped to the target physical address range, and the target physical address range includes the physical address, The target mapping relationship is the mapping relationship corresponding to the physical address.
  29. 根据权利要求28所述的装置,其特征在于,所述第一映射方式包括静态映射方式,所述静态映射方式是采用硬编码方式建立并销毁映射关系的映射方式。The apparatus according to claim 28, wherein the first mapping mode includes a static mapping mode, and the static mapping mode is a mapping mode in which a mapping relationship is established and destroyed in a hard-coded manner.
  30. 根据权利要求29所述的装置,其特征在于,所述静态映射方式包括 第一静态映射方式,所述第一静态映射方式是以芯片为单位,采用硬编码方式建立并销毁映射关系的映射方式。The device according to claim 29, wherein the static mapping method includes a first static mapping method, and the first static mapping method is a mapping method in which the mapping relationship is established and destroyed by hard coding in a chip unit. .
  31. 根据权利要求29所述的装置,其特征在于,所述静态映射方式包括第二静态映射方式,所述第二静态映射方式是以一个或多个算子为单位,采用硬编码方式建立并销毁映射关系的映射方式。The apparatus according to claim 29, wherein the static mapping method includes a second static mapping method, and the second static mapping method is established and destroyed in a hard-coded manner in units of one or more operators. The mapping method of the mapping relationship.
  32. 根据权利要求29所述的装置,其特征在于,在与所述物理地址对应的映射关系的属性为静态映射方式的情况下,所述处理器还用于:建立属性为所述静态映射方式的所述目标映射关系。The apparatus according to claim 29, wherein, in a case where the attribute of the mapping relationship corresponding to the physical address is in a static mapping manner, the processor is further configured to: establish an attribute whose attribute is in the static mapping manner the target mapping relationship.
  33. 根据权利要求32所述的装置,其特征在于,所述处理器用于建立属性为所述静态映射方式的所述目标映射关系,具体包括:将所述目标映射关系记录在所述静态映射方式对应的一静态映射表中,并使能用于存储所述静态映射表的第一寄存器。The apparatus according to claim 32, wherein the processor is configured to establish the target mapping relationship whose attribute is the static mapping mode, specifically comprising: recording the target mapping relationship in the corresponding static mapping mode in a static mapping table, and enable the first register for storing the static mapping table.
  34. 根据权利要求33所述的装置,其特征在于,所述处理器还用于:将所述静态映射表设置为加锁状态。The apparatus according to claim 33, wherein the processor is further configured to: set the static mapping table to a locked state.
  35. 根据权利要求34所述的装置,其特征在于,所述处理器还用于:在需要修改所述静态映射表中所记录的映射关系之前,将所述静态映射表设置为解锁状态,并禁止所述第一寄存器。The apparatus according to claim 34, wherein the processor is further configured to: before the mapping relationship recorded in the static mapping table needs to be modified, set the static mapping table to an unlocked state, and disable the the first register.
  36. 根据权利要求33所述的装置,其特征在于,所述静态映射方式对应静态映射表的数量是固定值。The apparatus according to claim 33, wherein the number of static mapping tables corresponding to the static mapping mode is a fixed value.
  37. 根据权利要求33所述的装置,其特征在于,所述静态映射方式对应静态映射表的数量是根据使用需求配置的可变值。The apparatus according to claim 33, wherein the number of static mapping tables corresponding to the static mapping mode is a variable value configured according to usage requirements.
  38. 根据权利要求29-37任一项所述的装置,其特征在于,所述第二映射方式包括:动态映射方式;所述动态映射方式是根据需求建立并销毁映射关系的映射方式;The device according to any one of claims 29-37, wherein the second mapping mode comprises: a dynamic mapping mode; the dynamic mapping mode is a mapping mode in which a mapping relationship is established and destroyed according to requirements;
    所述处理用于建立属性为所述第二映射方式的所述目标映射关系,具体包括:建立属性为所述动态映射方式的所述目标映射关系。The processing is used to establish the target mapping relationship whose attribute is the second mapping mode, and specifically includes: establishing the target mapping relationship whose attribute is the dynamic mapping mode.
  39. 根据权利要求38所述的装置,其特征在于,所述处理器用于建立属性为所述动态映射方式的所述目标映射关系,具体包括:将所述目标映射关系记录在所述动态映射方式对应的一动态映射表中,并使能用于存储所述动态映射表的第二寄存器。The apparatus according to claim 38, wherein the processor is configured to establish the target mapping relationship whose attribute is the dynamic mapping mode, specifically comprising: recording the target mapping relationship in the dynamic mapping mode corresponding to the in a dynamic mapping table, and enable a second register for storing the dynamic mapping table.
  40. 根据权利要求39所述的装置,其特征在于,所述处理器还用于:在 需求达成的情况下,禁止所述第二寄存器。The apparatus of claim 39, wherein the processor is further configured to disable the second register if the requirement is met.
  41. 根据权利要求39所述的装置,其特征在于,所述动态映射方式对应动态映射表的数量是固定值。The apparatus according to claim 39, wherein the number of dynamic mapping tables corresponding to the dynamic mapping mode is a fixed value.
  42. 根据权利要求39所述的装置,其特征在于,所述动态映射方式对应动态映射表的数量是根据使用需求配置的可变值。The device according to claim 39, wherein the number of dynamic mapping tables corresponding to the dynamic mapping mode is a variable value configured according to usage requirements.
  43. 根据权利要求28或38所述的装置,其特征在于,所述第二映射方式包括准静态映射方式;所述准静态映射方式是根据需求建立映射关系,并以一个或多个算子为单位销毁映射关系的映射方式;The apparatus according to claim 28 or 38, wherein the second mapping mode includes a quasi-static mapping mode; the quasi-static mapping mode is to establish a mapping relationship according to requirements, and use one or more operators as a unit Destroy the mapping method of the mapping relationship;
    所述处理器用于建立属性为所述第二映射方式的所述目标映射关系,具体包括:建立属性为所述准静态映射方式的所述目标映射关系。The processor is configured to establish the target mapping relationship whose attribute is the second mapping mode, and specifically includes: establishing the target mapping relationship whose attribute is the quasi-static mapping mode.
  44. 根据权利要求43所述的装置,其特征在于,所述处理器用于建立属性为所述准静态映射方式的所述目标映射关系,具体包括:The apparatus according to claim 43, wherein the processor is configured to establish the target mapping relationship whose attribute is the quasi-static mapping mode, and specifically includes:
    确定是否存在处于解锁状态的准静态映射表;Determine if there is a quasi-static mapping table in the unlocked state;
    如果是,则将所述目标映射关系记录在处于解锁状态的一准静态映射表中,将所述准静态映射表设置为加锁状态,并使能用于存储所述动态映射表的第三寄存器。If so, record the target mapping relationship in a quasi-static mapping table in an unlocked state, set the quasi-static mapping table to a locked state, and enable a third mapping table for storing the dynamic mapping table register.
  45. 根据权利要求44所述的装置,其特征在于,所述处理器还用于:在一个或多个算子执行完成的情况下,将所述准静态映射表设置为解锁状态,并禁止所述第三寄存器。The apparatus according to claim 44, wherein the processor is further configured to: set the quasi-static mapping table to an unlocked state and disable the third register.
  46. 根据权利要求44所述的装置,其特征在于,所述处理器还用于:如果确定不存在处于解锁状态的准静态映射表,则建立属性为动态映射方式的所述目标映射关系。The apparatus according to claim 44, wherein the processor is further configured to: if it is determined that there is no quasi-static mapping table in an unlocked state, establish the target mapping relationship whose attribute is a dynamic mapping mode.
  47. 根据权利要求44所述的装置,其特征在于,所述准静态映射方式对应的准静态映射表的数量是固定值。The apparatus according to claim 44, wherein the number of quasi-static mapping tables corresponding to the quasi-static mapping mode is a fixed value.
  48. 根据权利要求44所述的装置,其特征在于,所述准静态映射方式对应的准静态映射表的数量是根据使用需求配置的可变值。The apparatus according to claim 44, wherein the number of quasi-static mapping tables corresponding to the quasi-static mapping mode is a variable value configured according to usage requirements.
  49. 根据权利要求28所述的装置,其特征在于,在所述第二映射方式的数量为多个的情况下,所述处理器用于建立属性为所述第二映射方式的所述目标映射关系,具体包括:The apparatus according to claim 28, wherein when the number of the second mapping modes is multiple, the processor is configured to establish the target mapping relationship whose attribute is the second mapping mode, Specifically include:
    确定多个所述第二映射方式中的目标映射方式,并建立属性为所述目标映射方式的所述目标映射关系。A plurality of target mapping modes in the second mapping modes are determined, and the target mapping relationship whose attribute is the target mapping mode is established.
  50. 根据权利要求28所述的装置,其特征在于,所述第一映射方式包括准静态映射方式,所述第二映射方式包括动态映射方式;其中,所述准静态映射方式是根据需求建立映射关系,并以一个或多个算子为单位销毁映射关系的映射方式;所述动态映射方式是根据需求建立并销毁映射关系的映射方式。The apparatus according to claim 28, wherein the first mapping manner includes a quasi-static mapping manner, and the second mapping manner includes a dynamic mapping manner; wherein, the quasi-static mapping manner is to establish a mapping relationship according to requirements , and destroy the mapping method of the mapping relationship in units of one or more operators; the dynamic mapping method is the mapping method of establishing and destroying the mapping relationship according to the requirements.
  51. 根据权利要求50所述的装置,其特征在于,所述处理器用于建立属性为所述第二映射方式的目标映射关系,包括:The apparatus according to claim 50, wherein the processor is configured to establish a target mapping relationship whose attribute is the second mapping mode, comprising:
    确定是否存在处于解锁状态的准静态映射表;Determine if there is a quasi-static mapping table in the unlocked state;
    如果否,则建立属性为动态映射方式的所述目标映射关系。If not, establish the target mapping relationship whose attribute is the dynamic mapping mode.
  52. 根据权利要求51所述的装置,其特征在于,所述处理器还用于:The apparatus of claim 51, wherein the processor is further configured to:
    如果存在处于解锁状态的准静态映射表,则将所述目标映射关系记录在处于解锁状态的一准静态映射表中,将所述准静态映射表设置为加锁状态,并使能用于存储所述动态映射表的第三寄存器。If there is a quasi-static mapping table in an unlocked state, record the target mapping relationship in a quasi-static mapping table in an unlocked state, set the quasi-static mapping table to a locked state, and enable the quasi-static mapping table to be used for storage the third register of the dynamic mapping table.
  53. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质存储有计算机程序,所述计算机程序包含至少一段代码,所述至少一段代码可由计算机执行,以控制所述计算机执行如权利要求1-26任一项所述的方法。A computer-readable storage medium, characterized in that, the computer-readable storage medium stores a computer program, and the computer program includes at least one piece of code, and the at least one piece of code can be executed by a computer, so as to control the computer to execute as claimed in the claim. The method of any one of claims 1-26.
  54. 一种计算机程序,其特征在于,当所述计算机程序被计算机执行时,用于实现如权利要求1-26任一项所述的方法。A computer program, characterized in that, when the computer program is executed by a computer, it is used to implement the method according to any one of claims 1-26.
PCT/CN2021/073571 2021-01-25 2021-01-25 Address mapping method and apparatus WO2022155952A1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
PCT/CN2021/073571 WO2022155952A1 (en) 2021-01-25 2021-01-25 Address mapping method and apparatus

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2021/073571 WO2022155952A1 (en) 2021-01-25 2021-01-25 Address mapping method and apparatus

Publications (1)

Publication Number Publication Date
WO2022155952A1 true WO2022155952A1 (en) 2022-07-28

Family

ID=82548378

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/073571 WO2022155952A1 (en) 2021-01-25 2021-01-25 Address mapping method and apparatus

Country Status (1)

Country Link
WO (1) WO2022155952A1 (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103309819A (en) * 2013-05-30 2013-09-18 苏州亮智科技有限公司 Embedded system and safety managing method for internal storage thereof
US20150019830A1 (en) * 2013-07-15 2015-01-15 Seagate Technology Llc Dynamic address mapping for finish in the field
CN107341115A (en) * 2017-06-30 2017-11-10 联想(北京)有限公司 Virutal machine memory access method, system and electronic equipment
CN112052100A (en) * 2019-06-06 2020-12-08 华为技术有限公司 Virtual machine communication method and equipment based on shared memory
US20200409946A1 (en) * 2019-06-28 2020-12-31 Informatica Llc Method, apparatus, and computer-readable medium for dynamic hierarchical data flow mapping

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103309819A (en) * 2013-05-30 2013-09-18 苏州亮智科技有限公司 Embedded system and safety managing method for internal storage thereof
US20150019830A1 (en) * 2013-07-15 2015-01-15 Seagate Technology Llc Dynamic address mapping for finish in the field
CN107341115A (en) * 2017-06-30 2017-11-10 联想(北京)有限公司 Virutal machine memory access method, system and electronic equipment
CN112052100A (en) * 2019-06-06 2020-12-08 华为技术有限公司 Virtual machine communication method and equipment based on shared memory
US20200409946A1 (en) * 2019-06-28 2020-12-31 Informatica Llc Method, apparatus, and computer-readable medium for dynamic hierarchical data flow mapping

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
KANGYINGKUI: "Linux driver virtual address and physical address mapping", 23 May 2012 (2012-05-23), pages 1 - 2, XP055953103, Retrieved from the Internet <URL:https://web.archive.org/web/20120523184332/http://blog.chinaunix.net/uid-20792373-id-2979673.html> [retrieved on 20210401] *

Similar Documents

Publication Publication Date Title
US11755748B2 (en) Trusted local memory management in a virtualized GPU
US9972375B2 (en) Sanitize-aware DRAM controller
US10255191B2 (en) Logical memory address regions
US11762827B2 (en) B-plus tree access method and apparatus, and computer-readable storage medium
TWI591533B (en) Data storage method and data recovery method for data storage device, and data storage device using the same methods
TW201723850A (en) Flash memory and accessing method thereof
KR102580484B1 (en) Dynamic metadata relocation in memory
US20170300255A1 (en) Method and Apparatus for Detecting Transaction Conflict and Computer System
US9330016B2 (en) Systems and methods for managing read-only memory
WO2022155952A1 (en) Address mapping method and apparatus
US20230281113A1 (en) Adaptive memory metadata allocation
WO2016127807A1 (en) Method for writing multiple copies into storage device, and storage device
US20230071555A1 (en) Memory system for data encryption
CN114490449B (en) Memory access method and device and processor
US11360912B2 (en) Method for performing adaptive locking range management, associated data storage device and controller thereof
US11783042B2 (en) Access control system and method for isolating mutually distrusting security domains
TWI684865B (en) Method for performing adaptive locking range management, and associated data storage device and controller thereof
US20220327245A1 (en) Data storage device and method of access
US11748272B2 (en) Shared keys for no PCBA cartridges
TWI715992B (en) Memory device, memory system and method of reading from memory device
US20230141936A1 (en) Secure processor, operating method thereof, and storage device including same
US10592437B2 (en) Memory matching key capability
CN114356876A (en) File system implementation method and system
TW202232329A (en) Data arrangement method and memory storage system using persistent memory
TW202321927A (en) Flash memory data protection

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21920345

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21920345

Country of ref document: EP

Kind code of ref document: A1