A kind of through the method for expansion SD/MMC agreement realization digital equipment to storage card control
Technical field
The present invention relates to SD/MMC storage card field, particularly a kind of through the method for expansion SD/MMC agreement realization digital equipment to storage card control.
Background technology
Present storage cards such as SD/MMC only possess simple memory function, and its all behaviors all are to be controlled by main frame (HOST).Storage card just is used for storing data, and its major function is exactly the storage of data and reads, and main frame sends write order; Storage card carries out write operation according to the address, and main frame sends read command, and storage card is according to address reading data and send main frame to; In addition, storage card does not have characteristics and advantage again.
The disk structure of storage card is as shown in Figure 1, comprises MBS, partition boot sector, FAT table, root directory area, data field, and the major function of each subregion is following:
MBS: MBR (MBR) and hard disk partition table (DPT);
Partition boot sector: partition boot record;
FAT table: file allocation table, be used for the form of log file position, be that the FAT file system is used for recording disc data field bunch chain structure;
Root directory area: deposit the attribute of the file (catalogue) under the root directory, file system is the distribution that unit carries out shared bunch of file directory with 32 bytes, and these 32 bytes define the attribute of the file (or file) under this catalogue with the skew of confirming;
Data field: store files folder and file.
The structure of root directory area is as shown in Figure 2; When some files are operated, according to FAT table search this document place bunch, thereby find the storage address of file data; But these processes of searching are all accomplished by main frame (HOST); It is direct address function that order sends to storage card, is that what file is being operated so storage card can't be known main frame, does not also know it is bunch address upgrading which file when upgrading the FAT table.Main frame (HOST) need upgrade FAT table, directory area and data field in written document; Though what storage card can be judged renewal is any zone; But do not know the data updated content, if there is application need that the data content is dealt with, storage card is just not competent.
Command transfer between main frame and the SD/MMC card such as Fig. 3, shown in Figure 4, main frame (HOST) sends order through cmd signal alignment SD/MMC card, and the SD/MMC cartoon is crossed the cmd signal line the previous order that main frame (HOST) sends is responded.Need the data of transmission to transmit through the DAT signal wire, send the STOP order up to main frame (HOST), the SD/MMC card stops to transmit data.Main frame (HOST) can send a plurality of write orders and a plurality of STOP order when writing a file, storage card can't judge that current STOP orders the end of writing the end of a certain blocks of data or writing whole file.When that is to say when needs carry out true-time operation to a certain file, when for example loading the function of watermark in real time, storage card just can't know when begin executable operations (beginning to add watermark), end operation (stopping to add watermark).
In sum, there is following shortcoming in traditional SD/MMC storage card:
(1) can only be passive accept read write command, the address function data of sending according to main frame;
(2) can't differentiate the data content of operation;
(3) can not carry out special parsing to the order that main frame sends, can only accomplish the function of standard agreement definition;
(4) memory card function is single, can only use as memory device.
Summary of the invention
The objective of the invention is to solve present SD/MMC card can only follow standard agreement and carry out single reading and writing operation; And can not realize the shortcoming of the function of user Geng Gao demand; Provide a kind of and realize digital equipment to the method that the SD/MMC storage card carries out special control, make other special, complicated demand that can realize in this way except that the reading and writing function through expansion SD/MMC agreement.
Technical scheme of the present invention is following: a kind of through the method for expansion SD/MMC agreement realization digital equipment to storage card control; This method utilizes explosion command to come control store to stick into the special operational of row except that single reading and writing data function the identification marking of the high-order position among the address bit Argument of the reading and writing order of SD/MMC agreement defined as explosion command.
Further, realize in digital equipment method to storage card control through expansion SD/MMC agreement that above-mentioned high-order position among the described address bit Argument is meant the address bit that surpasses the storage card max cap..
Aforesaid through the method for expansion SD/MMC agreement realization digital equipment to storage card control; Wherein, To the expansion write order; The high-order position that the definition main frame sends among the address bit Argument of write order of storage card be the identification marking of explosion command, and the parameter of definition explosion command is with the respective extension function of definition storage card execution, after storage card receives write order in the data block that sends storage card with aft engine to; At first judge it is the expansion write order through the high-order position of Argument; Resolve the parameter that is sent to the explosion command in the data block of storage card with aft engine then, and carry out corresponding explosion command according to the parameter of explosion command, the result who executes waits for that main frame reads with the expansion read command.
Aforesaid through the method for expansion SD/MMC agreement realization digital equipment to storage card control; Wherein, to the expansion read command, the high-order position that the definition main frame sends among the address bit Argument of read command of storage card is the identification marking of expansion read command; After storage card receives read command; At first judge it is the expansion read command, leave the execution result of a last explosion command in the data block of returning in then that main frame is fetched this data block through the high-order position of Argument; Data to are wherein resolved, and obtain the execution result of storage card.
Beneficial effect of the present invention is following: this method uses high-order the order that realizes specific function that does not have at present in the address bit to use to expand on the basis that strictly observes the SD/MMC protocol specification; Very simple; Make digital equipment to carry out the specific function except that the reading and writing data, thereby satisfy the user in use to various special, the complicated requirement of storage card through Extended Protocol control store card.
Description of drawings
Fig. 1 is the disk structure synoptic diagram of storage card;
Fig. 2 is the root directory area structural representation of storage card;
Fig. 3 is for writing the transmission course synoptic diagram between main frame and the SD/MMC card;
Fig. 4 is for reading the transmission course synoptic diagram between main frame and the SD/MMC card;
Fig. 5 is the CMD command format of SD/MMC;
Fig. 6 is an argument address parameter synoptic diagram;
Fig. 7 distinguishes the process flow diagram of ordinary instruction and extended instruction for the SD/MMC card.
Embodiment
Below in conjunction with accompanying drawing and specific embodiment the present invention is carried out detailed description.
The CMD command format of SD/MMC is as shown in Figure 5, specifies as follows:
● Start bit: start bit is worth and is ' 0 ';
● Transmission bit: the direction host=' 1 ' of expression transmission beginning;
● Command index: command index (the CMD17 monolithic is read, the CMD18 polylith is read, and the CMD24 monolithic is write, the CMD25 polylith is write, and most of main frame HOST are to use CMD18 and CMD25);
● Argument: some order needs argument, and like the reading and writing order, what deposit among this argument is the address;
● the CRC check position of CRC7:7bit;
● End bit: stop bit is worth and is ' 1 '.
The data block size that writes is read in definition at every turn in the CSD of SD/MMC card register, and the computational data block size is by formula 2
READ_BL_LEN, drawing, the span of READ_BL_LEN is 0-15, promptly the data block size is 1Byte-16kByte, 2
15For EXT_CSD uses, according to the agreement regulation of SD/MMC, all cards all must be supported and give tacit consent to and support that operational size is the data block of 512Byte.Main frame (HOST) is when sending out the reading and writing order, and the data block transmitted size is at least 512Byte.
The SD/MMC storage card all is that main frame (HOST) transmission read write command is accomplished when reading and writing data; The read write command form that sends is as shown in Figure 5; Read and write data the address that will operate all transmit with the argument parameter, be 0x00019000 like the argument parameter, to need the address of read-write be 0x00019000 to main frame (HOST) so; Just (it is 102400 that 16 systems 19000 are scaled 10 systems, 102400/512=200) in the 200th sector.
The address of the 32bit of Argument can be to 2
32The disk space of=4G is operated, and if any the needs of Extended Protocol, just expands high-order the identification marking that is used as explosion command that does not have in 32 bit address to use and uses.If the max cap. of storage card is 1G, in to the data manipulation of storage card, only need to use 30 address space (2 so
30=therefore 1G), (bit31 is bit32) as the identification marking of explosion command can to utilize the high 2bit that do not use.The read write command agreement of expansion SD/MMC is actual to be exactly to utilize high-order that not have in the address bit of command transfer to use; The address bit that promptly surpasses the storage card max cap. is used as the identification marking of explosion command, and main frame (HOST) utilizes explosion command to come control store to stick into some special operations of row.These special operations can define arbitrarily as required, and are unfixing.As shown in Figure 7, storage card judges whether it is explosion command through high-order position after receiving the order that main frame sends, if not then according to normal read write command flow processing, if then according to the flow processing of explosion command.
To the expansion write order; The high-order position that does not have to use that at first utilizes the argument in the write order is as the identification marking of expanding write order, and for example, the max cap. of storage card is 1G; The address argument of the write order that transmits is defined as 0x40000200; Expansion bit30 is 1, is defined as the expansion write order, and the concrete explosion command parameter of definition data block of utilizing main frame (HOST) to send storage card to then defines concrete explosion command and carries out corresponding expanded function with the notice storage card.Receive when storage card that at first to judge behind the write order of this address be the expansion write order, and parse the command parameter in the data block of receiving subsequently, carry out corresponding explosion command according to command parameter then.Storage card is not carried out write order in fact veritably after receiving above-mentioned write order, but carries out expanded function according to the explosion command of definition, and the result who executes waits for that main frame (HOST) gets with the expansion read command.Above-mentioned concrete explosion command parameter and explosion command can define arbitrarily as required, and main frame and storage card are followed corresponding definition just can realize the expanded function except that read-write operation.
Operation to the expansion read command; Utilize the identification marking of the high-order position of the argument in the read command as the expansion read command; For example the address argument in the read command is defined as 0x40000200, and expansion bit30 is 1, is defined as the execution result of fetching an explosion command., storage card at first judges it is the expansion read command when receiving the read command of this address; Leave the execution result of a last explosion command in the data block of returning in then; Main frame (HOST) is fetched this data block, and data are wherein resolved, and obtains the execution result of storage card.
For example: accomplish the safety certification between main frame and the storage card when a certain application need powers on; If authentication not through could not carry out read-write operation to card; The Argument value that defines write order so is the identification marking of 0x40000200 as explosion command; And send at main frame that definition explosion command parameter is authentication command in the data block of storage card to; After being stuck in the CMD that receives the main frame transmission, at first judge it is the expansion write order, judge it is authentication command according to the explosion command parameter in the data block then through Argument; Then storage card just jumps to the treatment scheme execution main frame of authentication command and the authentication operation between the storage card, and main frame is fetched the execution result of authentication command through the expansion read command then.Authentication between main frame and the storage card is operated through just carrying out normal read-write between aft engine and the storage card, otherwise can not carry out normal read-write operation.Common read write command is to carry out such specific function, has only the explosion command of use to accomplish.
Consider the description of this invention disclosed herein and special embodiment, other embodiment of the present invention are conspicuous for a person skilled in the art.These explanations and embodiment only consider as an example that they all belong to by within the indicated protection scope of the present invention and spirit of accompanying claims.