An interface adaptation method, device, equipment and readable storage medium

By calculating the unique identification value of the original data of the hardware interface, searching and adapting the target cache data after pre-format conversion in the cache, the resource consumption problem caused by frequent format conversion of the hardware interface is solved, and efficient hardware interface management and interaction are achieved.

CN115328677BActive Publication Date: 2025-07-22JINAN INSPUR DATA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210998352.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-19
Publication Date
2025-07-22
Estimated Expiration
2042-08-19

AI Technical Summary

Technical Problem

In the prior art, when managing hardware interfaces, multiple format conversions are required frequently, resulting in huge system resource consumption. How to improve the adaptation management efficiency of hardware interfaces and reduce resource consumption.

Method used

By calculating the unique identification value of the original data of the hardware interface, looking for the target cache data converted in the preformat in the cache, directly using the target cache data for adaptation, eliminating the multiple format conversions of the original data.

Benefits of technology

It improves the adaptation management efficiency of hardware interfaces, reduces system resource consumption, and improves the interaction efficiency of the underlying hardware interfaces.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115328677B_ABST
    Figure CN115328677B_ABST
Patent Text Reader

Abstract

The present application discloses an interface adaptation method, apparatus, device and readable storage medium. The method includes: receiving and parsing an adaptation request to determine a hardware interface to be adapted; reading underlying raw data from the hardware interface and calculating a unique identification value of the raw data; using the unique identification value as an input to search in a cache for target cache data corresponding to the adaptation request; where the target cache data is data obtained by performing several format conversions on the raw data in advance; and using the target cache data to adapt the hardware interface. In the present application, after determining that the raw data has not changed based on the unique identification value, directly adapting based on the data obtained by performing several format conversions on the raw data in advance can directly eliminate the operation of performing several format conversions on the raw data, improve the adaptation management efficiency of the hardware interface, reduce resource consumption, and enhance the interaction efficiency with the hardware underlying interface.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular, to an interface adaptation method, apparatus, device, and readable storage medium. Background Art

[0002] When management software manages physical devices such as storage, it often needs to adapt to read and write the underlying hardware interfaces. Taking the SES protocol as an example, in order to implement chassis management of the expansion enclosure, it is necessary to read information from the underlying interface of the SES protocol; in order to implement indicator operations on the expansion enclosure and hard disk lights, it is necessary to perform write operations on the underlying interface of the SES protocol.

[0003] Most of the hardware underlying interfaces interact in the form of bytecodes, that is, a combination of a string of hexadecimal bytes. And during the reading and writing processes, there are a large number of resource consumptions, including CPU and memory. Specifically, even if only one node needs to be modified, it is necessary to read and process all the information of the interface, and perform multiple format conversions. After modifying the required byte content, it is then converted into a specified format and written in. That is, operations of several kilobytes are involved. If the operations are frequent, the consumption of system resources will be extremely large.

[0004] In summary, how to effectively solve problems such as the adaptation management of hardware interfaces is a technical problem that those skilled in the art urgently need to solve at present. Summary of the Invention

[0005] The purpose of this application is to provide an interface adaptation method, apparatus, device, and readable storage medium, which improve the adaptation management efficiency of hardware interfaces and reduce the consumption of system resources.

[0006] To solve the above technical problems, this application provides the following technical solutions:

[0007] An interface adaptation method includes:

[0008] Receiving and parsing an adaptation request to determine the hardware interface to be adapted;

[0009] Reading the underlying raw data from the hardware interface and calculating the unique identifier value of the raw data;

[0010] Using the unique identifier value as an input to search in the cache for target cache data corresponding to the adaptation request; wherein the target cache data is data obtained by performing several format conversions on the raw data in advance;

[0011] Adapting the hardware interface by using the target cache data.

[0012] Preferably, using the unique identifier value as an input to search in the cache for target cache data corresponding to the adaptation request includes:

[0013] Using the unique identification value as input, search for the target cache data of unsigned int type in the cache.

[0014] Preferably, adapting the hardware interface using the target cache data includes:

[0015] If the adaptation request is a read request, perform an offset process on the target cache data;

[0016] Perform bitwise formatting on the offset data to obtain the information to be viewed.

[0017] Preferably, adapting the hardware interface using the target cache data includes:

[0018] If the adaptation request is a write request, modify the target byte in the target cache data according to the write request;

[0019] After the modification is completed, convert the target cache data into String data;

[0020] Add a delimiter to the String data to obtain the data to be written;

[0021] Write the data to be written into the hardware interface.

[0022] Preferably, searching for the target cache data corresponding to the adaptation request in the cache with the unique identification value as input includes:

[0023] If the adaptation request is a write request, use the unique identification value as input and, when the cache is hit, determine the hit cache type;

[0024] If the cache type is a first-level cache, the target cache data is data of unsigned int type;

[0025] If the cache type is a second-level cache, the target cache data is the data to be written of the same operation type as the write request.

[0026] Preferably, adapting the hardware interface using the target cache data includes:

[0027] If the target cache data is the data to be written, directly write the target cache data into the hardware interface.

[0028] Preferably, calculating the unique identification value of the original data includes:

[0029] Calculate the unique identification value of the original data by using the SHA256 hash algorithm.

[0030] An interface adaptation device, comprising:

[0031] A request parsing module, configured to receive and parse an adaptation request, and determine a hardware interface to be adapted;

[0032] An identification calculation module, configured to read underlying original data from the hardware interface, and calculate a unique identification value of the original data;

[0033] A cache lookup module, configured to use the unique identification value as an input to look up target cache data corresponding to the adaptation request in a cache; wherein, the cache data in the cache is data obtained by performing several format conversions on the original data in advance;

[0034] An adaptation module, configured to adapt the hardware interface by using the target cache data.

[0035] An electronic device, comprising:

[0036] A memory, configured to store a computer program;

[0037] A processor, configured to implement the steps of the above interface adaptation method when executing the computer program.

[0038] A readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above interface adaptation method are implemented.

[0039] Apply the method provided by the embodiments of the present application, receive and parse an adaptation request, determine a hardware interface to be adapted; read underlying original data from the hardware interface, and calculate a unique identification value of the original data; use the unique identification value as an input to look up target cache data corresponding to the adaptation request in a cache; wherein, the target cache data is data obtained by performing several format conversions on the original data in advance; adapt the hardware interface by using the target cache data.

[0040] In this application, when it is necessary to adapt to read and write the underlying data of the hardware interface, after the original data at the underlying layer is read from the hardware interface, operations such as directly converting the format of the original data are not performed. Instead, the unique identification value of the original data is calculated, and with this unique identification value as the input, the corresponding target cache data is searched in the cache. Since the target cache data is the data obtained by performing several format conversions on the original data in advance, the hardware interface can be directly adapted based on the target cache data. It can be seen that for the underlying data of the hardware, as long as each hardware component works stably and normally, the data read at the underlying layer remains basically unchanged. Therefore, after it is determined in this application that the original data has not changed based on the unique identification value, directly adapting based on the data obtained by performing several format conversions on the original data in advance can directly eliminate the operation of performing several format conversions on the original data, improve the adaptation management efficiency of the hardware interface, reduce resource consumption, and enhance the interaction efficiency with the hardware underlying interface.

[0041] Correspondingly, the embodiment of the present application also provides an interface adaptation device, a device, and a readable storage medium corresponding to the above interface adaptation method, which have the above technical effects and will not be elaborated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following will briefly introduce the drawings required for use in the description of the embodiments or related technologies. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0043] Figure 1 It is a flowchart of the implementation of an interface adaptation method in an embodiment of the present application;

[0044] Figure 2 It is a schematic diagram of an interface data reading process;

[0045] Figure 3 It is a schematic diagram of an interface data writing process;

[0046] Figure 4 It is a schematic diagram of an interface data reading process in the present application;

[0047] Figure 5 It is a schematic diagram of an interface data writing process in the present application;

[0048] Figure 6 It is a schematic diagram of the calculation of a unique identification value in the present application;

[0049] Figure 7 It is a schematic diagram of the structure of an interface adaptation device in an embodiment of the present application;

[0050] Figure 8 This is a schematic structural diagram of an electronic device in an embodiment of the present application;

[0051] Figure 9 This is a specific structural diagram of an electronic device in an embodiment of the present application. Detailed implementation manners

[0052] In order to enable those skilled in the art to better understand the solution of the present application, the present application will be further described in detail below with reference to the drawings and specific implementation manners. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without making creative efforts shall fall within the protection scope of the present application.

[0053] Please refer to Figure 1 , Figure 1 This is a flowchart of an interface adaptation method in an embodiment of the present application. This method can be applied to management software for managing physical devices such as storage. When the management software manages physical devices such as storage, it often needs to adapt to read and write the underlying hardware interfaces. Taking the SES (SCSI Enclosure Service, a standard for chassis management) protocol as an example below, the interface adaptation method will be described in detail. This method includes the following steps:

[0054] S101. Receive and parse an adaptation request to determine the hardware interface to be adapted.

[0055] Among them, the adaptation request is a request sent when it is necessary to adapt the hardware interface. The adaptation request may specifically include a read request and a write request.

[0056] After receiving the adaptation request, the adaptation request can be parsed first to determine the hardware interface to be adapted.

[0057] S102. Read the underlying raw data from the hardware interface and calculate the unique identification value of the raw data.

[0058] After determining the hardware interface, the underlying raw data can be directly read from the hardware interface. The raw data may specifically be hardware underlying protocol data, and the data is specifically presented as hexadecimal characters displayed in an irregular string.

[0059] After reading the raw data, the unique identification value of the raw data can be calculated. Specifically, a national cryptography algorithm, a hash algorithm, etc. can be used to calculate the unique identification value of the raw data. In the present application, there is no limitation on which specific algorithm is used to calculate the unique identification value of the raw data, as long as the algorithm used can determine the unique identification value of the raw data.

[0060] Since the hash algorithm can map binary values of any length to smaller binary values of a fixed length, this small binary value becomes the hash value. The hash value is a unique and extremely compact numerical representation of a piece of data. The hash values of any two pieces of hashed plaintext are different. Therefore, the hash value of the data can be used to verify the integrity of the data. Thus, in practical applications, the hash algorithm can be preferentially used to simplify the comparison of the underlying interface data. By recording the hash value of the data read each time, it can be compared whether the data is the same.

[0061] Please refer to Figure 6 , in a specific implementation manner of the present application, calculating the unique identification value of the original data in step S102 specifically includes using the SHA256 hash algorithm to calculate the unique identification value of the original data. Among them, SHA256 is a hash algorithm with a hash value length of 256 bits. Further, when reading the original data, the obtained data can be stored in a file instead of the original memory storage, which is convenient for the use of the hash algorithm; use the sha256sum command to perform hash calculation on the file, that is, use the awk command to split and obtain the result, and get the hash value, that is, the unique identification value. The awk command is the command used in AWK, and AWK is an excellent text processing tool.

[0062] It should be noted that in the subsequent caching mechanism, the hash value is used as the key for indexing, but the corresponding value is not the original data of the hash value, but the converted data required for the subsequent steps, so as to achieve the meaning of improving efficiency.

[0063] S103. Use the unique identification value as the input to search for the target cache data corresponding to the adaptation request in the cache.

[0064] Among them, the target cache data is the data obtained by performing several format conversions on the original data in advance.

[0065] In this embodiment, several format conversions can be performed on the original data in advance, and the converted data is stored in the cache.

[0066] Illustrative example: For several format conversions of the original data, please specifically refer to Figure 2 the shown conversion process, and the conversion process includes the following steps:

[0067] Step 1. Read the original data based on the underlying interface, that is, hexadecimal characters displayed as irregular strings;

[0068] Step 2. Convert the original data to the String type, that is, a long string consisting only of hexadecimal characters;

[0069] Step 3: Convert the String data into the unsigned int type for easier subsequent reading.

[0070] That is to say, the cached data can specifically be the unsigned int type data after the original data has been subjected to two format conversions.

[0071] When storing the data after several data conversions of the original data in the cache, use the unique identification value of the original data as the Key and the converted data as the Value. Therefore, when looking up the cache, the unique identification value can be used as the input to find the target cached data corresponding to the adaptation request in the cache. Specifically, first check whether the currently calculated unique identification value hits the Key in the cache. If it hits, directly read the Value corresponding to the Key, that is, read out the target cached data in the cache.

[0072] Of course, if the cache is not hit, perform format conversion on the original data. The conversion process can refer to Step 2 and Step 3 above. After the format conversion is completed, for easier subsequent data reading, the converted data can be cached. The caching form: use the unique identification value of the original data as the Key and the converted data as the Value.

[0073] In a specific implementation manner of the present application, Step S103 uses the unique identification value as the input to find the target cached data corresponding to the adaptation request in the cache, including: using the unique identification value as the input to find the target cached data of the unsigned int type in the cache. That is to say, using the unique identification value as the input, traverse the cache to find the corresponding Key, and then read the Value corresponding to the Key. The Value is specifically the target cached data of the unsigned int type.

[0074] S104: Use the target cached data to adapt the hardware interface.

[0075] After obtaining the target cached data, the hardware interface can be adapted.

[0076] Generally speaking, when adapting the hardware interface, there are mainly two different requirements: data reading and writing. For easier understanding, the following will provide detailed descriptions corresponding to reading and writing respectively.

[0077] For data reading, Step S104 uses the target cached data to adapt the hardware interface, including:

[0078] Step 1: If the adaptation request is a read request, perform offset processing on the target cached data;

[0079] Step 2: Perform bitwise formatting on the offset-processed data to obtain the information to be viewed.

[0080] For ease of description, the above two steps will be combined and described below.

[0081] When the adaptation request is specifically a read request, after obtaining the target cache data,

[0082] It is possible to offset a specified number of bytes according to a pre-defined rule to obtain different data; after obtaining the bytes, perform bitwise operations, such as bitwise formatting, so as to finally obtain the desired data, that is, the information to be viewed.

[0083] For writing data, step S104 uses the target cache data to adapt the hardware interface, including:

[0084] Step 1: If the adaptation request is a write request, modify the target byte in the target cache data according to the write request;

[0085] Step 2: After the modification is completed, convert the target cache data into String data;

[0086] Step 3: Add a delimiter to the String data to obtain the data to be written;

[0087] Step 4: Write the data to be written to the hardware interface.

[0088] For ease of description, the above four steps will be combined and described below.

[0089] Specifically, it is possible to offset a specified number of bytes in the target cache data according to a pre-defined rule to modify the number of the target byte. In practical applications, bitwise operations may also be involved to modify specified bits of the specified byte. After the modification is completed, convert the unsigned int data (target cache data) back into String data, and then split the String data according to the protocol requirements and add a delimiter, otherwise the underlying layer will not recognize it. Finally, the data is sent down to complete the writing to the hardware interface.

[0090] Applying the method provided by the embodiments of the present application, receive and parse the adaptation request, determine the hardware interface to be adapted; read the original data at the bottom layer from the hardware interface, and calculate the unique identification value of the original data; use the unique identification value as the input to search for the target cache data corresponding to the adaptation request in the cache; where the target cache data is the data obtained by performing several format conversions on the original data in advance; use the target cache data to adapt the hardware interface.

[0091] In this application, when it is necessary to perform adaptation, such as reading and writing the underlying data of a hardware interface, after the original data at the underlying layer is read from the hardware interface, operations such as directly converting the format of the original data are not performed. Instead, the unique identification value of the original data is calculated, and with this unique identification value as the input, the corresponding target cache data is searched for in the cache. Since the target cache data is the data obtained by performing several format conversions on the original data in advance, the hardware interface can be directly adapted based on this target cache data. It can be seen that for the underlying data of the hardware, as long as each hardware component works stably and normally, the data read at the underlying layer remains basically unchanged. Therefore, in this application, after it is determined that the original data has not changed based on the unique identification value, the adaptation is directly performed based on the data obtained by performing several format conversions on the original data in advance, which can directly eliminate the operation of performing several format conversions on the original data, improve the adaptation management efficiency of the hardware interface, reduce resource consumption, and enhance the interaction efficiency with the underlying hardware interface.

[0092] It should be noted that based on the above embodiments, the embodiments of this application also provide corresponding improvement solutions. In the preferred / improved embodiments, the same steps or corresponding steps involved in the above embodiments can be referred to each other, and the corresponding beneficial effects can also be referred to each other, and will not be elaborated one by one in the preferred / improved embodiments of this article.

[0093] In a specific implementation manner of this application, step S103 takes the unique identification value as the input and searches for the target cache data corresponding to the adaptation request in the cache, including:

[0094] If the adaptation request is a write request, take the unique identification value as the input, and in the case of hitting the cache, determine the type of the hit cache;

[0095] If the cache type is the first-level cache, the target cache data is data of the unsigned int data type;

[0096] If the cache type is the second-level cache, the target cache data is the data to be written with the same operation type as the write request.

[0097] When the underlying data of the hardware, as long as each hardware component works stably and normally, the data read at the underlying layer remains basically unchanged, and when writing data, the data to be written is also relatively fixed, and the data writing process is relatively cumbersome, but the steps are relatively fixed. Therefore, for writes with the same operation, the finally written data is the same. Based on this, in this embodiment, a second-level cache mechanism is proposed. Specifically, for the same original data, two levels of caches are stored. The first-level cache corresponds to data of the unsigned int data type; the second-level cache corresponds to the data to be written for the write.

[0098] Accordingly, the process of searching for cached data is to traverse the cache with a unique identifier value, such as a hash value, as the input to query whether the key of the cache is hit;

[0099] If the cache is not found, the original process is still followed. Just after converting to the unsigned int type, use the hash value of the previous step as the key and the unsigned int type data as the value to store in the first-level cache; before issuing the command, use the String data with delimiters (the data to be finally written into the string, that is, the data to be written) as the value to store in the second-level cache;

[0100] If the cache is found, then judge the cache level. This judgment is based on the type at the previous write. If it is the same as the previous operation type (such as turning on or off the light, where the light refers to the hard disk indicator light, fault light, etc.), then directly use the second-level cache, that is, the string used when finally issuing the instruction, that is, the data to be written.

[0101] Specifically, the file cache method can be adopted instead of the memory cache to reduce unnecessary resource consumption and at the same time reduce the risk of cache loss. In addition, to meet the requirements of the above process, the fields of the cache can be as follows in the table:

[0102] Field Name Meaning key Cache key value, i.e., the hash value of the original data value Cache value (i.e., the primary key value), i.e., the converted data secondKey Cached secondary key value, used for write operations to identify the operation type secondValue Cached secondary cache value, used for write operations to identify the final data corresponding to the operation

[0103] For example: Implement the top-level interface KVCache<K, V>, where the key is the hash value calculated by each process according to the original data, and the value is the target data stream after each process is converted according to the rules. In the reading process, it is the unsigned int data that can directly read the data; in the writing process, it is the unsigned int data that can directly modify the bytes.

[0104] Implement the necessary interfaces, such as getters, setters, etc., to complete the reading and writing of the cache.

[0105] During the write operation, after matching the key value, it is also necessary to match the secondary key, which can more accurately hit the cache and further simplify the data conversion process.

[0106] Distinguish the write types to facilitate better use of the second-level cache values. Taking the SES protocol as an example, it can be divided into: the lighting operation for the expansion cabinet; the lighting operation for the drawer; the lighting operation for the hard disk.

[0107] Accordingly, the above step S104 adapts the hardware interface by using the target cache data, including: if the target cache data is data to be written, directly write the target cache data to the hardware interface. That is to say, when the secondary cache is hit, the intermediate steps can be directly skipped, and the target cache data can be directly written to the hardware interface.

[0108] In the case where the operations of querying and writing are basically the same, the read-write method of the cache can greatly improve the operation efficiency and prevent repeated read-write operations every time.

[0109] Even when encountering a situation with large changes in read-write operations, the resources consumed by the interface adaptation method provided by the embodiments of the present application are not much. Calculating the hash and storing it in the cache can be quickly completed, and the cache adopts the file cache method.

[0110] To facilitate those skilled in the art to better understand the interface adaptation method provided by the embodiments of the present application, the interface adaptation method will be described in detail below through a specific application scenario as an example.

[0111] Taking the SES protocol underlying interface as an example, when the interface adaptation method provided by the embodiments of the present application is not applied, its reading process is as Figure 2 shown, and the specific implementation steps include:

[0112] Step 1: Read the original data based on the underlying interface;

[0113] Step 2: Convert the original data to the String type, that is, a long string of only hexadecimal characters;

[0114] Step 3: Convert the String data to the unsigned int type for easy reading later;

[0115] Step 4: Offset the specified number of bytes according to the pre-defined rules to obtain different data;

[0116] Step 5: After obtaining the bytes, there is generally a bit operation to finally obtain the desired data.

[0117] Taking the SES protocol underlying interface as an example, when the interface adaptation method provided by the embodiments of the present application is not applied, its reading process is as Figure 3 shown, and the specific implementation steps include:

[0118] Step 1: Read the original data based on the underlying interface;

[0119] Step 2: Convert the original data to the String type, that is, a long string of only hexadecimal characters;

[0120] Step 3: Convert the String data into the unsigned int type for easier subsequent operations

[0121] Step 4: Modify the target number of bytes by offsetting the specified number of bytes according to the pre - defined rules. Generally, bit operations are also involved to modify the specified bits of the specified byte;

[0122] Step 5: Convert the unsigned int back to String data;

[0123] Step 6: Split the String data according to the protocol requirements and add delimiters, otherwise the underlying layer will not recognize it;

[0124] Step 7: Send down the data to complete the writing.

[0125] It can be seen that before using the interface adaptation method provided by the embodiments of the present application, during the reading and writing processes, multiple conversions are involved, and each time a large amount of resources are consumed, including CPU and memory resources. Moreover, during the reading and writing processes, all bytes of the interface need to be read. Even if only one byte needs to be read or written, all bytes need to be read and written. In most cases, it is several thousand bytes, resulting in low efficiency.

[0126] Step 1: Read the original data based on the underlying interface, that is, the hexadecimal characters displayed as an irregular string;

[0127] Step 2: Calculate the hash value with the original data as the input;

[0128] Step 3: Traverse the cache with the hash value as the input to query whether the key of the cache is hit;

[0129] Step 4: If the cache is not found, still proceed according to the original process. Just after converting to unsigned int, use the previous hash value as the key and the unsigned int data as the value to store in the cache;

[0130] Step 5: If the cache is found, directly read out the cache value as the unsigned int data;

[0131] Step 6: Obtain different data by offsetting the specified number of bytes according to the pre - defined rules;

[0132] Step 7: After obtaining the bytes, generally there will be bit operations to finally get the desired data.

[0133] Taking the SES protocol underlying interface as an example, after applying the interface adaptation method provided by the embodiments of the present application, its writing process is as Figure 5 shown, and the specific implementation steps include:

[0134] Step 1: Read the original data based on the underlying interface, i.e., hexadecimal characters displayed as irregular strings;

[0135] Step 2: Calculate the hash value with the original data as the input;

[0136] Step 3: Traverse the cache with the hash value as the input to query whether the key of the cache is hit;

[0137] Step 4: If the cache is not found, the original process still proceeds. Just after converting to the unsigned int type, use the previous hash value as the key and the unsigned int type data as the value to store in the first-level cache; before issuing the command, use the String data with delimiters (the string to be finally written) as the value to store in the second-level cache;

[0138] Step 5: If the cache is found, determine the cache level. This determination is based on the type at the last write. If it is the same as the previous operation type, directly use the second-level cache, i.e., the string used when finally issuing the instruction; if different, use the string before modifying the bytes.

[0139] Step 6: Issue the data to complete the writing.

[0140] It can be seen that in the case where the query and write operations are basically the same, applying the interface adaptation method provided by the embodiments of the present application can greatly improve the operation efficiency and prevent repeated reading and writing each time; even when encountering a situation with large changes in reading and writing, the resources consumed are not much, and calculating the hash and storing in the cache can be quickly completed, and the cache adopts the file cache method.

[0141] Corresponding to the above method embodiment, the embodiments of the present application also provide an interface adaptation device, and the interface adaptation device described below can be correspondingly referred to with the interface adaptation method described above.

[0142] See Figure 7 As shown, the device includes the following modules:

[0143] A request parsing module 101, configured to receive and parse an adaptation request to determine the hardware interface to be adapted;

[0144] An identification calculation module 102, configured to read the underlying original data from the hardware interface and calculate the unique identification value of the original data;

[0145] A cache lookup module 103, configured to look up the target cache data corresponding to the adaptation request in the cache with the unique identification value as the input; wherein, the cache data in the cache is data obtained by performing several format conversions on the original data in advance;

[0146] An adaptation module 104 for adapting a hardware interface by using target cache data.

[0147] Applying the device provided by the embodiment of the present application, receiving and parsing an adaptation request, determining a hardware interface to be adapted; reading underlying raw data from the hardware interface, and calculating a unique identification value of the raw data; using the unique identification value as an input to search for target cache data corresponding to the adaptation request in a cache; wherein the target cache data is data obtained by performing several format conversions on the raw data in advance; and adapting the hardware interface by using the target cache data.

[0148] In the present application, when it is necessary to perform adaptation, such as when reading and writing the underlying data of a hardware interface, after reading the underlying raw data from the hardware interface, format conversion and other operations are not directly performed on the raw data. Instead, the unique identification value of the raw data is calculated, and using this unique identification value as an input, the corresponding target cache data is searched for in the cache. Since the target cache data is data obtained by performing several format conversions on the raw data in advance, the hardware interface can be directly adapted based on the target cache data. It can be seen that for the underlying data of the hardware, as long as each hardware component works stably and normally, the data read from the underlying layer basically remains unchanged. Therefore, after determining that the raw data has not changed based on the unique identification value in the present application, directly adapting based on the data obtained by performing several format conversions on the raw data in advance can directly eliminate the operation of performing several format conversions on the raw data, improve the adaptation management efficiency of the hardware interface, reduce resource consumption, and enhance the interaction efficiency with the hardware underlying interface.

[0149] In a specific implementation manner of the present application, the cache search module 103 is specifically configured to use the unique identification value as an input to search for target cache data of unsigned int type in the cache.

[0150] In a specific implementation manner of the present application, the adaptation module 104 is specifically configured to, if the adaptation request is a read request, perform an offset process on the target cache data;

[0151] Perform bitwise formatting on the offset-processed data to obtain information to be viewed.

[0152] In a specific implementation manner of the present application, the adaptation module 104 is specifically configured to, if the adaptation request is a write request, modify target bytes in the target cache data according to the write request;

[0153] After the modification is completed, convert the target cache data into String data;

[0154] Add a delimiter to the String data to obtain data to be written;

[0155] Write the data to be written to the hardware interface.

[0156] In a specific embodiment of the present application, the cache lookup module 103 is specifically configured to, if the adaptation request is a write request, use the unique identifier value as the input, and determine the type of the hit cache when the cache is hit.

[0157] If the cache type is the first-level cache, the target cache data is data of the unsigned int type.

[0158] If the cache type is the second-level cache, the target cache data is the data to be written with the same operation type as the write request.

[0159] In a specific embodiment of the present application, the adaptation module 104 is specifically configured to adapt the hardware interface by using the target cache data, including:

[0160] If the target cache data is the data to be written, directly write the target cache data to the hardware interface.

[0161] In a specific embodiment of the present application, the identification calculation module 102 is specifically configured to calculate the unique identifier value of the original data by using the SHA256 hash algorithm.

[0162] Corresponding to the above method embodiment, an embodiment of the present application further provides an electronic device. The following-described electronic device can be correspondingly referred to with the above-described interface adaptation method.

[0163] See Figure 8 As shown, the electronic device includes:

[0164] A memory 332 for storing a computer program;

[0165] A processor 322 for implementing the steps of the interface adaptation method in the above method embodiment when executing the computer program.

[0166] Specifically, please refer to Figure 9 , Figure 9A schematic diagram of the specific structure of an electronic device provided in this embodiment. The electronic device may vary greatly due to different configurations or performances, and may include one or more central processing units (CPUs) 322 (for example, one or more processors) and a memory 332. The memory 332 stores one or more computer application programs 342 or data 344. Among them, the memory 332 can be short-term storage or persistent storage. The programs stored in the memory 332 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the data processing device. Further, the central processing unit 322 can be set to communicate with the memory 332 and execute a series of instruction operations in the memory 332 on the electronic device 301.

[0167] The electronic device 301 may further include one or more power supplies 326, one or more wired or wireless network interfaces 350, one or more input / output interfaces 358, and / or one or more operating systems 341.

[0168] The steps in the interface adaptation method described above can be implemented by the structure of the electronic device.

[0169] Corresponding to the above method embodiment, the present application embodiment also provides a readable storage medium. The following described readable storage medium can be correspondingly referred to the above-described interface adaptation method.

[0170] A readable storage medium stores a computer program. When the computer program is executed by a processor, the steps of the interface adaptation method in the above method embodiment are implemented.

[0171] The readable storage medium can specifically be various readable storage media such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disc that can store program codes.

[0172] Those skilled in the art can further realize that the units and algorithm steps of each example described in combination with the embodiments disclosed in this article can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the components and steps of each example have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application.

Claims

1. An interface adaptation method, characterized in that, including: Receiving and parsing an adaptation request to determine a hardware interface to be adapted; Reading underlying raw data from the hardware interface and calculating a unique identification value of the raw data; Using the unique identification value as an input to look up target cache data corresponding to the adaptation request in a cache; wherein the target cache data is data obtained by performing several format conversions on the raw data in advance; Using the target cache data to adapt the hardware interface.

2. The interface adaptation method according to claim 1, wherein Using the unique identification value as an input to look up target cache data corresponding to the adaptation request in a cache, including: Using the unique identification value as an input to look up the target cache data of unsigned int type in the cache.

3. The interface adaptation method according to claim 2, wherein Using the target cache data to adapt the hardware interface, including: If the adaptation request is a read request, performing an offset process on the target cache data; Performing bitwise formatting on the offset-processed data to obtain information to be viewed.

4. The interface adaptation method according to claim 2, wherein Using the target cache data to adapt the hardware interface, including: If the adaptation request is a write request, modifying target bytes in the target cache data according to the write request; After the modification is completed, converting the target cache data into String data; Adding a delimiter to the String data to obtain data to be written; Writing the data to be written to the hardware interface.

5. The interface adaptation method according to claim 1, characterized in that Using the unique identification value as an input to look up target cache data corresponding to the adaptation request in a cache, including: If the adaptation request is a write request, using the unique identification value as an input and, when hitting the cache, determining the hit cache type; If the cache type is a first-level cache, the target cache data is data of unsigned int type; If the cache type is a second-level cache, the target cache data is data to be written of the same operation type as the write request.

6. The interface adaptation method according to claim 5, wherein Using the target cache data to adapt the hardware interface, including: If the target cache data is the data to be written, directly writing the target cache data to the hardware interface.

7. The interface adaptation method according to any one of claims 1 to 6, characterized in that Calculating the unique identification value of the raw data, including: Using the SHA256 hash algorithm to calculate the unique identification value of the raw data.

8. An interface adaptation device, characterized in that, including: A request parsing module for receiving and parsing an adaptation request to determine a hardware interface to be adapted; An identification calculation module for reading underlying raw data from the hardware interface and calculating a unique identification value of the raw data; A cache lookup module for using the unique identification value as an input to look up target cache data corresponding to the adaptation request in a cache; wherein the cache data in the cache is data obtained by performing several format conversions on the raw data in advance; An adaptation module for using the target cache data to adapt the hardware interface.

9. An electronic device, characterized in that, including: A memory for storing a computer program; A processor for implementing the steps of the interface adaptation method according to any one of claims 1 to 7 when executing the computer program.

10. A readable storage medium, characterized in that, A computer program is stored on the readable storage medium, and when the computer program is executed by a processor, the steps of the interface adaptation method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • TPM initialization method and related device

    CN109992317A

  • System and server for docking hardware security module

    CN114282235A