Background technique
Present electronic equipment is equipped with storage equipment for storing data, common storage equipment such as EEPROM,
FLASH etc. is driven by driver to realize the read-write operation of data and the storage of data.Therefore, it is being counted
When according to read-write operation, the controller of electronic equipment will write data into storage equipment by operation driver.
Since the various data of electronic equipment are required to be stored in storage equipment, but different data have different works
With, and partial data cannot be modified arbitrarily, such as delete, rewrite.For example, the data of electronic device system are that electronics is set
Standby core data, once the data of operating system are tampered, it is easy to lead to system crash or lead to data safety etc. to ask
Topic, therefore the data such as operating system are usually the data that cannot be modified.
However, such as user is stored in contact information, photo, song, third party software program in electronic equipment
Equal files, then can voluntarily be modified by user, therefore, the data that whens these data can be modified.
In order to ensure the safety and flexibility of electronic equipment storing data, present electronic equipment will usually store equipment
Be divided into multiple regions, as shown in Figure 1, storage equipment be divided into can not read and write region A1, readable not writeable region A2, can not
Writeable region A3 and read-write region A4 is read, in this way, electronic equipment will store data according to the type of data read-write operation
Into corresponding region.
For example, the core datas such as operating system of electronic equipment are the data that can only be read but cannot be modified, therefore
The data such as operating system are stored in readable not writeable region A2, in this way, user or third equation can not pass through drive
Dynamic program rewrites this partial data, so that it is guaranteed that the safety of core data.For in user oneself storage to electronic equipment
The files such as photo, song, then can be written into read-write region A4, can be convenient user so at any time to these data
The operation such as deleted, modified.
Since electronic equipment is written and read the subregion of permission to storage equipment, file management system is usually set to data
Storage is managed, that is, the read-write operation of data is controlled by file management system.As shown in Fig. 2, file management system
10 include application management module 11, limit power module 12 and read-write execution module 13, and driver is used to execute mould according to read-write
The instruction of block 13 carries out driving to storage equipment to realize the operation of data read with write-in.
It is well known that driver needs to obtain the three elements of data transmission when being written and read to storage equipment,
That is data source, data purpose and data length, data source are the places of the data being read or the data being written into storage,
The purpose of data is the place that is stored of data after data or write-in after reading, and data length is the length for the data being read
The length of data spent or be written into.After driver only obtains above-mentioned three elements, the read-write operation of data could be executed.
However, storage equipment subregion be arteface come out concept, for storing equipment it is not obvious how
Subregion manages the reading and writing data permission of each region of storage equipment often by limit power module 12 to realize subregion.Example
Such as, electronic equipment factory before, developer divides the region that data cannot be voluntarily written by user first, i.e., it is readable not
Then the core datas such as operating system are written to readable not writeable region A2 by writeable region A2, thus avoid user or
The data of third party's modification of program operating system.For another example, user needs that new data, such as photo are written to storage equipment, then
It can be stored in read-write region A4.
The request instruction for the read-write data manipulation that file management system 10 receives includes the subregion for reading and writing data manipulation
Data address offset information, data length information etc. after information, data to be read or write-in, wherein partition information is to continue
Subregion after access evidence or write-in where data.After application management module 11 receives these information, sentenced by limit power module 12
Disconnected subregion, which belongs to, can not read and write in region A1, readable not writeable region A2, unreadable writeable region A3 or read-write region A4
Which, further according to subregion access limit judge whether and request operation permission whether match, in the reading for judging subregion
In the case where write permission and the permission match of request operation, read-write execution module 13 will execute the read-write of data by driver
Operation data or writes data into specified address from reading in specified address.
Judge for example, the subregion of the data after write operation write-in in readable not writeable region A2, then limits power module 12
The permission of subregion and the operation of request mismatch, and refuse write operation.But developer is often reserved a large amount of superfluous to operating system
The memory space of 200M but has often been reserved if operating system often only has the data of 100M in remaining region to operating system, remaining
The storage region of 100M be redundant area, and the access limit of these memory spaces is readable not writeable, that is, is operated
Whole region where system is readable not writeable region A2.In this way, where needing write operation system if there is data
When the redundant area of storage region, the data after judgement write-in in readable not writeable region A2, are refused number by limit power module 12
According to write operation, leading to storage equipment, there are a large amount of redundant areas not to make full use of.
As it can be seen that existing data read-write control method cannot maximally utilise the redundant area of each region, but
Rights management directly carried out to storage equipment by file management system, that is, according to the operation of request of data from each region
The middle operation searched suitable memory space and carry out reading and writing data, often leads to the waste of storage space of storage equipment, is unfavorable for
Make full use of the memory space of storage equipment.
Summary of the invention
The main object of the present invention is to provide a kind of data read-write control side for improving storage device memory utilization rate
Method.
It is a further object of the present invention to provide a kind of data read-write control devices for making full use of storage device memory.
In order to realize above-mentioned main purpose, data read-write control method provided by the invention includes receiving read/write number
The target position of data read/write operation, subregion where shielding target position are obtained according to the instruction according to the request instruction of operation
Read/write authority judge operation, directly judge whether the read/write authority of target position matches with the operation of request, if it matches, then
Execute the instruction.
Optionally, judge that the step of whether read/write authority of target position matches with the operation of request includes: judgement target
Whether position is located at the redundant area of read-write restricted area, if so, determining the read/write authority of target position and the operation of request
Matching.
By above scheme as it can be seen that when executing read-write operation to data, file management system is got around to the read/write authority of subregion
Judgement operation, but directly judge the read/write authority of target position, especially limit positioned at reading and writing judging target position
Allow to execute the operation requested when the redundant area in region processed, the memory space of storage equipment can be made full use of in this way, especially
It is redundant area, avoids the waste of memory space.
One specific scheme is that when executing read operation, target position is the position for being read data;Execute write operation
When, target position is the position of data after write-in.
It can be seen that the target position of read-write operation is the start-stop position after the start-stop position being read and write-in, because
This manages storage it is only necessary to consider the access limit of corresponding data storage location without using file system in this way
The subregion of equipment and the read-write of data improve the storage space utilization of storage equipment.
Scheme optionally is the step of judging the read/write authority of target position: with obtaining the storage of target position
Location, and judge the read/write authority of the storage region where the storage address of target position.
Since the read/write authority of each storage region of storage equipment has been set when electronic equipment dispatches from the factory, pass through letter
The read/write authority of storage region can easily judge that can corresponding memory space meet where singly judging target position
The requirement of data read/write operation.
Further embodiment is to judge the read/write authority and request of the storage region where the storage address of target position
Operation matching when, allow to execute the instruction;The storage region where the storage address of target position is judged to read and write restricted area
When domain, whether the storage region where further judging the storage address of target position is the redundant area for reading and writing restricted area
Domain, if so, then determining that the access limit of target position is matched with the operation of request.
In this way, even if target position be located at read-write restricted area, but only need read-write restricted area redundant area
It is interior, the read/write operation of request can be still executed, redundant area is avoided to be wasted.
Further embodiment is that destination address includes target initial address and target termination address, is judging target
When beginning position is matched with the operation of request with the read/write authority of target termination position, allow to execute the instruction;Judging target
Any one read/write authority and the operation of request when mismatching of initial position and target termination position, limitation executes the behaviour of request
Make.
As it can be seen that only just allowing in the case where judging that target initial position is all satisfied operation requirement with target termination position
Corresponding operation is executed, so that it is guaranteed that data read/write operation can be gone on smoothly, and can not be executed down after avoiding data from storing
The case where secondary read/write operation.
To realize above-mentioned another object, data read-write control device provided by the invention includes that target position determines mould
Block, for according to the instruction, obtaining and determining data read/write operation when receiving the request instruction of read/write data operation
Target position;It further include permission control module, for the read/write authority judgement operation of subregion where shielding target position, judgement
Whether the read/write authority of target position matches with the operation of request;It further include read-write execution module, as judged target position
Whether read/write authority matches with the operation of request, executes the instruction.
Optionally, when judging that target position is located at the redundant area of read-write restricted area, determine the read/write power of target position
It limits and is matched with the operation of request.
It can be seen that first passing through the mesh that target position determining module determines data read/write when being written and read to data
Cursor position, then judge that the read/write authority of target position is to meet the requirement of read/write operation, it is executed in the case where meeting the requirements
Corresponding read/write operation.The subregion of storage equipment is managed in this way, electronic equipment has got around file management system, is only needed
Judge when destination address meets read/write operation requirement, especially destination address in the redundant area for reading and writing restricted area still
Think that its read/write authority is matched with the operation of request, corresponding memory space can be write data into this way, avoids storage empty
Between waste, improve storage equipment utilization rate.
Specific embodiment
Data read-write control method of the invention can apply such as smart phone, tablet computer, E-book reader,
In the electronic equipments such as desktop computer, the operation of reading and write-in for controlling data.Data read-write control device of the invention
It is to run on an electronic device for realizing the device of above-mentioned data read-write control method.
Referring to Fig. 3, data read-write control device is to establish system calling module 20 in existing file management system 10,
System calling module 20 and 10 concurrent working of file management system, system calling module 20 include target position determining module 21,
Permission control module 22, permission modified module 23, wherein target position determining module 21 is for obtaining and determining read/write operation
The destination address of data storage, destination address includes target initial position and target termination position.For example, executing read operation
When, target initial position is the initial memory address for the data being read, and target termination position is to be read the terminations of data to deposit
Store up address.Since data are usually Coutinuous store, the data being read should be consecutively stored in target starting point
In memory space between location and target termination address.When executing write operation, target initial position is the data after write-in
Initial memory address, target termination position are the termination storage address of the data after write-in.
For example, system calling module 20 obtains partition information, the address information of data to be read, number when executing read operation
It according to length information etc., and shields the judgement to the read/write authority of subregion and operates, that is to say the information for ignoring subregion, and not
Whether the subregion for judging data to be read or data to be written is read-write region or the judgement such as can not read and write region, only
Data address offset information, data length information after obtaining data to be read or being written.Target position determining module 21 obtains
The start memory location for being read data in storage equipment is taken, it is assumed that the initial address for the data being read is
At start in 0x50, i.e. Fig. 4.Also, target position determining module 21 also obtains the data length len being read, and is such as read
The data length taken is 40 bytes, then can calculate the storage address 0x90 of target termination position, that is, in Fig. 4
At satrt+len.In the same manner, when executing write operation, target position determining module 21 is also required to after obtaining and determining write-in
The initial address start of data, and the data length len of write-in is obtained, thus with calculating the termination of the data after write-in
Location satrt+len.
After target position determining module 21 obtains target initial position and target termination position, permission control module 22 is true
Set the goal the read/write authority of initial position and target termination position, for example, according to the storage address of target initial position
The read/write authority of storage region where the start and storage address satrt+len of target termination position determines that target originates
The read/write authority of position and target termination position.Due to the storage each storage region of equipment read/write authority when leaving the factory
Through determination, therefore, the read/write authority of the storage region where the storage address start of determining target initial position can be passed through
To judge the read/write authority of target initial position.In the same manner, permission control module 22 passes through the storage for determining target termination position
The read/write authority of storage region where the start+len of address judges the read/write authority of target termination position.
Also, permission control module 22 is in the read/write for judging the read/write authority of target initial position, target termination position
When permission is matched with the operation of request, then allow the operation requested, that is, allows to execute data read/write instruction, otherwise, limitation
Execute the operation of request.
In order to make full use of the redundant area of read-write restricted area, as there is the redundant area of 100M in readable not writeable region A2
Domain, if target initial position or target termination position judge mesh in the redundant area in readable not writeable region A2
Mark initial position or target termination position are matched with the operation of request, and the operation for allowing to request.
For example, the operation of request is the operation of reading data, and the source initial address of reading data, that is, target starting
Address is in read-write region, and the source termination address of reading data, that is, target termination address is also in read-write area
In domain.At this point it is possible to judge that target initial position is matched with the read/write operation permission of target termination position with the operation of request,
Then allow to execute the operation of reading data.
Certainly, if target initial address is in read-write region, but target termination address can not read and write in region or
In the unreadable writeable region of person, then further judge target termination address whether in the redundant area in unreadable writeable region or
Person is in the redundant area that can not read and write region, if judging target initial address and target termination not in redundant area
There is the operation of one and request to mismatch in address, limitation data read operation.If target initial address and target termination
Location is not to limit the operation of reading data in the redundant area that can not read and write region in unreadable region yet.
For example, the storage address from 0020 to 0100 of readable not writeable region A2, but actually store effective data
Address is only 0021 to 0039, therefore, can know that the redundant area of readable not writeable region A2 is to deposit in compilation process
Storing up address is the region between from 0040 to 0100.Assuming that target initial position start and target termination position start+len
Storage address is respectively 0040,0090, and storage address 0040 with storage address 0090 respectively in the superfluous of readable not writeable region
In remaining region, then permission control module 22 judges target initial position, the storage address of target termination position is read-write limitation
The redundant area in region then judges that target initial position, the read/write authority of target termination position are matched with the operation of request, permits
Perhaps the operation of request is executed.
As it can be seen that target initial position and target termination position and request are needed when can judgement execute the operation of request
Operation match just allow execute request operation, such as either one or two of target initial position and target termination position with request
Operation mismatches, then limits the operation for executing request.
For example, the operation of request is the operation of reading data, the target initial address of reading data is readable not writeable
In region, and the target termination address of reading data is in read-write region.At this point it is possible to judge target initial position and mesh
The read/write operation permission of mark final position is matched with the operation of request, then allows to execute the operation of reading data.
If the operation of request is data write operation, and data write-in target initial address in read-write region,
And the target termination address of data write-in is also in read-write region.At this point it is possible to judge that target initial position and target are whole
The read/write operation permission that stop bit is set is matched with the operation of request, then allows to execute the operation of data write-in.
If target initial address in read-write region, but target termination address can not read and write it is in region or readable
In not writeable region, and also not in the redundancy that can not read and write region or in the redundant area in readable not writeable region,
Then judge that the operation for having one and request in target initial address and target termination address mismatches, the write-in for limiting data is grasped
Make.If target initial address and target termination address are in not writeable region, and also not in the redundancy in not writeable region
In region, the also just directly operation of limitation data write-in.
Under normal conditions, target initial address and the read/write authority of target termination address are identical, then can be according to asking
The permission of action type, target initial address and the target termination address asked is divided into following a variety of situations: when data read operation,
If target initial address and target termination address are in read-write region, then allow data read operation;As target originates
Address and target termination address then allow data read operation in readable not writeable region;As target initial address with
Target termination address in unreadable writeable region, such as in redundant area, then allows data read operation, if not superfluous
In remaining region, then data read operation is limited;If target initial address and target termination address are in the region that can not be read and write,
Such as in redundant area, then allow data read operation, if in redundant area, then do not limited data read operation.Data are write
When entering to operate, if target initial address and target termination address are in read-write region, then allow data write operation;Such as
Target initial address and target termination address such as in redundant area, then allow data to write in readable not writeable region
Enter operation, if in redundant area, then do not limited data write operation;If target initial address and target termination address be not
In readable writeable region, then allow data write operation;As target initial address can not read and write with target termination address
Region in, such as in redundant area, then allow number write-in extract operations, such as not in redundant area, then limit data write-in grasp
Make.
Allow to execute the operation requested in permission control module 22, after data read operation or data write operation,
Corresponding operation is executed by the read-write execution module 13 of file management system 10, read-write execution module 13 will by driver
Data are written to specified storage address, or read data from specified storage address.
As it can be seen that the shielding of system calling module 20 is to where target position points when the application present invention realizes data read-write operation
The read/write authority in area judges operation, that is, the judgement of permission is not carried out to subregion, directly judges target initial address and target
The read/write authority of termination address, and the read/write of data is realized by calling the read-write operation module 13 of file management system 10
Operation.Namely system calling module 20 gets around the application management module 11 of file management system 10, limit power module 12 to realize
The read/write of data, application management module 11, the limit power module 12 of file management system 10 also just do not execute corresponding operation, into
And by target position determining module 21 and permission control module 22 come the reading to target initial position and target termination position/
The judgement of write permission.
Further, since judging target initial position, target termination position in the redundant area for reading and writing restricted area, if not
Read-write region, readable not writeable region, unreadable writeable region redundant area when, and judge target start bit
Set, the read/write authority of target termination position is matched with the operation of request, and allow execute request cause.In this way, can keep away
Exempt from mechanically to carry out zoning permissions management to storage equipment, so as to utilize the redundant area of read-write restricted area.
However, each storage region of storage equipment is not that cannot change completely, when read-write field capacity is insufficient
When, the size in the region of different access limits can be changed by the access limit between modification part storage address.For example,
A-quadrant is originally readable not writeable region, can be in the case where storing the read-write region memory space inadequate of equipment
The read/write authority of a-quadrant is revised as to read-write permission, the memory space in read-write region can be increased in this way.
However, the modification of the read/write authority of storage region can not allow user or third equation to execute, but by
The operating system developer of electronic equipment just allows to modify, and therefore, permission modified module 23 is arranged in read-write control device, so as to
The access limit of specific storage region is adjusted according to the needs of use in developer.In the read/write authority of adjustment storage region
Afterwards, permission control module 22 will determine whether to execute the operation requested according to access limit adjusted.
The read/writing control method of data is introduced below with reference to Fig. 5.Firstly, executing step S1, refer to receiving data read/write
After order, the target initial position and target termination position of data read/write operation are determined, if it is data read operation, data
Target initial position is the initial address for being read data, and target termination position is the termination address for being read data.If it is
Data write operation, the target initial position of data is the initial address of the data after write-in, after target termination position is write-in
Data termination address.
Then, step S2 is executed, judges the read/write authority of target initial position Yu target termination position, that is, judge
The read/write authority of storage region where target initial address and the read/write power for judging target termination address place storage region
Limit.Therefore, during reading and writing data, the read/write for the subregion for including in read/write requests instruction is weighed in the shielding of system calling module 20
The judgement of limit operates, that is, ignores the permission judgement not executed to subregion, but directly judges target initial position and target
The read/write authority of final position.
Then, execute step S3, judge target initial position and target termination position read/write authority whether with request
Operation matches, if operation of any one in the read/write authority of target initial position and target termination position with request
It mismatches, thens follow the steps S4, limit the operation of request, that is, do not allow to execute data read/write instruction.Judge that target originates
When the read/write authority of position and target termination position, on the one hand need to consider target initial position and target termination position place
The read/write authority in region, if in read-write restricted area, it is also necessary to judge whether in redundant area, if in read-write restricted area
The redundant area in domain then still judges that target initial position is matched with the read/write authority of target termination position with the operation of request, no
Then, judge to mismatch with the operation of request.
In step S3, judge the read/write authority of target initial position and target termination position with the operation of request
Match, then follow the steps S5, allow to execute data read/write instruction, and execute step S6, by read-write execution module 13 from specified
Address reading data or write data into specified address.
It certainly, can if developer needs the read/write authority of the part memory space to storage equipment to modify
It is modified with the read/write authority according to the actual situation to part memory space, when executing step S2, is needed according to after modification
The read/write authority of storage region determine the read/write authority of target initial position Yu target termination position.
By means of the present invention can to avoid use file management system to storage equipment each storage region carry out
Rights management improves the utilization rate of storage equipment to maximumlly utilize the redundant area in different access limit regions.