The guard method of CPU external bus and device
Technical field:
The present invention relates to a kind of guard method and device of CPU external bus.
Background technology:
CPU (central processing unit) adopts the mode of memory bus interface to carry out to the control of peripheral hardware veneer basically, or PCI local bus interface such as (peripheral controller interfaces).But PCI (peripheral controller interface) implements the comparison difficulty with respect to memory interface, and complexity increases greatly, and performance is limited again simultaneously.Therefore in the veneer control mode system of embedded system, still based on memory interface, the application of PCI is more limited.
As shown in Figure 1, the external address control bus not only comprises address bus, also comprise the chip selection signal line that is used for gating external unit veneer, when the major function of veneer is CPU (central processing unit) when finishing, so whole veneer also resets together if CPU (central processing unit) crashes.But the major function of veneer is not that CPU (central processing unit) finishes sometimes, CPU (central processing unit) is just auxiliary to be calculated, and the execution configuration effort, CPU (central processing unit) crashes so should not influence the operate as normal of the main ASIC of this plate (special IC) controller when resetting.Such situation is such as the cross board of SDH (formatted data processing), cross matrix information in CPU (central processing unit) inner preservation of cross chips when resetting also keeps, CPU (central processing unit) also keeps the state machine information before crashing in NVRAM (non-volatile random access memory), therefore CPU (central processing unit) can't influence its interleaving function after resetting, only influence cross-over configuration during this period of time.But CPU (central processing unit) might send chaotic sequential on bus when deadlock resets, distribute data arbituarily, this just might influence the safety of outside important ASIC (special IC) controller internal data, therefore be necessary to be provided with a kind of security mechanism, when bus writes without basis data, influence the data of outside important ASIC (special IC) controller inside when preventing the CPU program fleet.
At the problems referred to above, general a kind of way is now, utilize an important sheet of trigger control to translate the output of sign indicating number selectively, when need be before important ASIC (special IC) controller reads and writes data, at first write the control trigger, order control trigger is turned to the state of ON, passes through with regard to the chip selection signal that allows this ASIC (special IC) controller like this.When the reading and writing data of ASIC (special IC) controller is finished, write the control trigger again, make its state that is turned into OFF, the sheet choosing output of this ASIC (special IC) controller is turn-offed.Such control mode has improved the security of ASIC (special IC) controller internal data greatly, has prevented data tampering unintentionally.But it also has a tangible leak, after CPU (central processing unit) has opened the control trigger, if the data to ASIC (special IC) controller do not have to have read and write under the situation about just crashing the state that the control trigger will be held open always.The no sequential signal that occurs on the bus when resetting as CPU (central processing unit) just might cause fatal infringement to the internal data of ASIC (special IC) controller like this, thereby has also reduced the reliability of total system.
Summary of the invention:
At the existing problem and shortage of guard method of above-mentioned CPU (central processing unit) external bus, the purpose of this invention is to provide the guard method and the device of a kind of more effective CPU (central processing unit) external bus.
The present invention is achieved in that the guard method of a kind of CPU (central processing unit) external bus, may further comprise the steps:
CPU (central processing unit) judges the size of desiring to read and write data, and judge in view of the above controlling the corresponding access time of veneer, and the corresponding initial value that counter is set, described counter from counting begin to the time of overflowing greater than the access time of CPU (central processing unit) to described control veneer;
Described counter begins counting, and output level overturns simultaneously, and selects OE (output starts) to open the sheet of the control chip on the described control veneer;
CPU (central processing unit) sends read write command to described control chip, and control chip is carried out this read write command;
Described rolling counters forward finishes, and output level upset selects OE (output starts) to close the sheet of the control chip on the described control veneer;
Further, said method is further comprising the steps of:
After described counter was once counted and finished, whether CPU (central processing unit) judgment data was read and write and is finished, if do not finish, reset the initial value of described counter, this initial value to the time of overflowing greater than overflowing the time last time.
Further, described counter is up counter or down counter.
The protective device of a kind of CPU (central processing unit) external bus, include the control veneer that is connected with CPU (central processing unit), comprise control chip in this control veneer, this control chip is connected with CPU (central processing unit) by CPU (central processing unit) external bus, and the CPU of described control chip (central processing unit) interface is provided with counter; The initial value of counter is set by CPU (central processing unit), count down to time of overflowing corresponding access time greater than control chip from initial value; When control chip was received the read write command of CPU (central processing unit), counter began counting, output level upset simultaneously, and the sheet of control chip selects OE (output starts) to open, and control chip is carried out read write command; After counter overflowed, output level overturn once more, and the sheet of control chip selects OE (output starts) to keep closing.
Further, described counter is up counter or down counter.
Further, the CPU of described control chip (central processing unit) interface is provided with counter, and the output of this counter is connected with the OE (output starts) of the sheet of described control chip choosing.
The present invention is by being provided with counter on CPU (central processing unit) interface of the control chip of controlling veneer, at CPU (central processing unit) when control chip sends read write command, judge the length that this desires to read and write data simultaneously, and calculate CPU (central processing unit) and normally read and write the time that these data need spend, and counter set corresponding initial value, this initial value specifically is to set like this: counter begins slightly to be longer than CPU (central processing unit) to the time of overflowing from counting and has has normally read and write the time that these data need spend; Counter begins counting after being set initial value, and output level is turned to ON simultaneously, and selects OE (output starts) to open the sheet of control chip, and CPU (central processing unit) sends read write command simultaneously, and control chip is carried out this read write command; Counter overflows the back output level and is turned to OFF, selects OE (output starts) to close the sheet of described control chip; Whether CPU (central processing unit) judgment data is read and write and is finished, if do not finish, reset the initial value of described counter, make this initial value to the time of overflowing greater than overflowing the time last time, counter restarts counting, and CPU (central processing unit) reads and writes these data again.Like this, can protect the internal data of the control veneer that is connected by bus with CPU (central processing unit) effectively, even on bus, send chaotic sequential when resetting or distribute data arbituarily in CPU (central processing unit) deadlock suddenly, because counting after CPU (central processing unit) handles the read write command of controlling veneer, counter overflows, and the sheet that will control the control chip of veneer selects OE (output starts) to close, chaotic sequential and the data of distributing arbituarily can not have influence on the data with existing in the control chip, control chip is by existing data fill order, like this, whole one-tenth system is just more stable; Even CPU (central processing unit) is not is not reading and writing just deadlock of data, because the initial value that counter is composed is less relatively to overflow value, overflow at the cpu reset hour counter, and the sheet of control chip has been selected OE (output starts) to close, do not affect the internal data of control chip equally; This has promoted the security performance of system greatly.
Description of drawings:
Below in conjunction with accompanying drawing, the present invention is made detailed description.
Fig. 1 is the CPU control structure synoptic diagram of prior art;
Fig. 2 is an of the present invention choosing output control principle;
Fig. 3 counter works schematic diagram of the present invention.
Embodiment:
The present invention is achieved in that CPU (central processing unit) judges the size of desiring to read and write data, and judge in view of the above controlling the corresponding access time of veneer, and the corresponding initial value that counter is set, counter from counting begin to the time of overflowing greater than the access time of CPU (central processing unit) to the control veneer; Counter begins counting, output level upset simultaneously, and the sheet that will control the control chip on the veneer selects OE (output starts) unlatching; CPU (central processing unit) sends read write command to control chip, and control chip is carried out this read write command; Rolling counters forward finishes, and the output level upset selects OE (output starts) to close the sheet of controlling the control chip on the veneer;
After counter was once counted and finished, whether CPU (central processing unit) judgment data was read and write and is finished, if do not finish, reset the initial value of counter, this initial value to the time of overflowing greater than overflowing the time last time.
Realization the inventive system comprises the control veneer that is connected with CPU (central processing unit), comprise control chip in this control veneer, this control chip is connected with CPU (central processing unit) by CPU (central processing unit) external bus, and the CPU of control chip (central processing unit) interface is provided with counter; The initial value of counter is set by CPU (central processing unit), count down to time of overflowing corresponding access time greater than control chip from initial value; When control chip was received the read write command of CPU (central processing unit), counter began counting, output level upset simultaneously, and the sheet of control chip selects OE (output starts) to open, and control chip is carried out read write command; After counter overflowed, output level overturn once more, and the sheet of control chip selects OE (output starts) to keep closing.
The Core Feature of control veneer is that asic chip is finished by certain configurable control chip, and this asic chip inside has a large amount of configuration registers to control the business of this asic chip, and this asic chip does not need the participation of CPU during operate as normal.When traffic profile change, CPU carries out business configuration by the cpu i/f of this asic chip to asic chip, and the method for configuration is to revise the content of configuration register.As shown in Figure 2, after CPU judges the size desire to read and write data, set the initial value of control counter, this initial value to the time of overflowing should be greater than CPU to controlling the access time of veneer; Because the configuration amount to asic chip might be bigger, therefore the maximum count time of setting counter is 2 milliseconds, its counting principle as shown in Figure 3, CPU can only could carry out read-write operation to asic chip when the counting low level, be above-mentioned to the asic chip business configuration, when the counter output low level, i.e. sheet choosing with asic chip has had pressure reduction, also promptly is equivalent to select OE to open the sheet of asic chip; Counter is just exported high level after counting is finished, and the sheet that promptly has been equivalent to close asic chip selects OE, and CPU just can not operate it, like this, has just protected the asic chip internal data not influenced by CPU effectively.Even CPU crashes suddenly in the rolling counters forward process, but when CPU was restarted, counter was counted already and is finished, and promptly the sheet of asic chip selects OE to close already, even invalid data is arranged, also can not have influence on asic chip.
When the maximum count time of setting was not enough, when promptly not finishing the business configuration to asic chip, CPU can prolong the read-write permission time by the counting initial value of resetting, and finishes up to configuration.
Here, counter is up counter or down counter.