• Aucun résultat trouvé

Cache Control

Dans le document PowerPC 750™ PowerPC 740™ (Page 158-163)

Instruction and Data Cache Operation

3.4 Cache Control

The 750's L1 caches are controlled by programming specific bits in the HIDO special-purpose register and by issuing dedicated cache control instructions. Section 3.4.1,

"Cache Control Parameters in HIDO," describes the HIDO cache control bits, and Section 3.4.2, "Cache Control Instructions," describes the cache control instructions.

3.4.1 Cache Control Parameters in HIDO

The HIDO special-purpose register contains several bits that invalidate, disable, and lock the instruction and data caches. The following sections describe these facilities.

3.4.1.1 Data Cache Flash Invalidation

The data cache is automatically invalidated when the 750 is powered up and during a hard reset. However, a soft reset does not automatically invalidate the data cache. Software must use the HIDO data cache flash invalidate bit (HIDO[DCFI]) if data cache invalidation is desired after a soft reset. Once HIDO[DCFI] is set through an mtspr operation, the 750 automatically clears this bit in the next clock cycle (provided that the data cache is enabled in the HIDO register).

Note that some PowerPC microprocessors accomplish data cache flash invalidation by setting and clearing HIDO[DCFI] with two consecutive mtspr instructions (that is, the bit is not automatically cleared by the microprocessor). Software that has this sequence of operations does not need to be changed to run on the 750.

3.4.1.2 Data Cache Enabling/Disabling

The data cache may be enabled or disabled by using the data cache enable bit, HIDO[DCE].

HIDO[DCE] is cleared on power-up, disabling the data cache.

When the data cache is in the disabled state (HIDO[DCE] = 0), the cache tag state bits are ignored, and all accesses are propagated to the L2 cache or 60x bus as single-beat transactions. Note that the CI (cache inhibit) signal always reflects the state of the caching-inhibited memory/cache access attribute (the I bit) independent of the state of HIDO[DCE]. Also note that disabling the data cache does not affect the translation logic;

translation for data accesses is controlled by MSR[DR].

The setting of the DCE bit must be preceded by a syne instruction to prevent the cache from being enabled or disabled in the middle of a data access. In addition, the cache must be globally flushed before it is disabled to prevent coherency problems when it is re-enabled.

Snooping is not performed when the data cache is disabled.

The debz instruction will cause an alignment exception when the data cache is disabled.

The touch load (debt and debtst) instructions are no-ops when the data cache is disabled.

Other cache operations (caused by the debf, debst, and debi instructions) are not affected

by disabling the cache. This can potentially cause coherency errors. For example, a dcbf instruction that hits a modified cache block in the disabled cache will cause a copyback to memory of potentially stale data.

3.4.1.3 Data Cache Locking

The contents of the data cache can be locked by setting the data cache lock bit, HIDO[DLOCK]. A data access that hits in a locked data cache is serviced by the cache.

However, all accesses that miss in the locked cache are propagated to the L2 cache or 60x bus as single-beat transactions. Note that the CI signal always reflects the state of the caching-inhibited memory/cache access attribute (the I bit) independent of the state of HIDO[DLOCK].

The 750 treats snoop hits to a locked data cache the same as snoop hits to an unlocked data cache. However, any cache block invalidated by a snoop hit remains invalid until the cache is unlocked.

The setting of the DLOCK bit must be preceded by a sync instruction to prevent the data cache from being locked during a data access.

3.4.1.4 Instruction Cache Flash Invalidation

The instruction cache is automatically invalidated when the 750 is powered up and during a hard reset. However, a soft reset does not automatically invalidate the instruction cache.

Software must use the HIDO instruction cache flash invalidate bit (HIDO[ICFI]) if instruction cache invalidation is desired after a soft reset. Once HIDO[ICFI] is set through an mtspr operation, the 750 automatically clears this bit in the next clock cycle (provided that the instruction cache is enabled in the HIDO register).

Note that some PowerPC microprocessors accomplish instruction cache flash invalidation by setting and clearing HIDO[ICFI] with two consecutive mtspr instructions (that is, the bit is not automatically cleared by the microprocessor). Software that has this sequence of operations does not need to be changed to run on the 750.

3.4.1.5 Instruction Cache Enabling/Disabling

The instruction cache may be enabled or disabled through the use of the instruction cache enable bit, HIDO[ICE]. HIDO[ICE] is cleared on power-up, disabling the instruction cache.

When the instruction cache is in the disabled state (HID[ICE]

=

0), the cache tag state bits are ignored, and all instruction fetches are propagated to the L2 cache or 60x bus as single-beat transactions. Note that the CI signal always reflects the state of the caching-inhibited memory/cache access attribute (the I bit) independent of the state of HIDO[ICE]. Also note that disabling the instruction cache does not affect the translation logic; translation for instruction accesses is controlled by MSR[IR].

3-14 IBM PowerPC 740 I PowerPC 750 RISC Microprocessor User's Manual

The setting of the ICE bit must be preceded by an isyne instruction to prevent the cache from being enabled or disabled in the middle of an instruction fetch. In addition, the cache must be globally flushed before it is disabled to prevent coherency problems when it is re-enabled. The icbi instruction is not affected by disabling the instruction cache.

3.4.1.6 Instruction Cache Locking

The contents of the instruction cache can be locked by setting the instruction cache lock bit, HIDO[ILOCK]. An instruction fetch that hits in a locked instruction cache is serviced by the cache. However, all accesses that miss in the locked cache are propagated to the L2 cache or 60x bus as single-beat transactions. Note that the CI signal always reflects the state of the caching-inhibited memory/cache access attribute (the I bit) independent of the state of HIDO[ILOCK].

The setting of the ILOCK bit must be preceded by an isyne instruction to prevent the instruction cache from being locked during an instruction fetch.

3.4.2 Cache Control Instructions

The PowerPC architecture defines instructions for controlling both the instruction and data caches (when they exist). The cache control instructions, debt, debtst, debz, debst, debf, debi, and iebi, are intended for the management of the local Ll and L2 caches. The 750 interprets the cache control instructions as if they pertain only to its own Ll or L2 caches.

These instructions are not intended for managing other caches in the system (except to the extent necessary to maintain coherency).

The 750 does not snoop cache control instruction broadcasts, except for debz when M = 1.

The debz instruction is the only cache control instruction that causes a broadcast on the 60x bus (when M = 1) to maintain coherency. All other data cache control instructions (debi, debf, debst and debz) are not broadcast, unless broadcast is enabled through the HIDO[ABE] configuration bit. Note that debi, debf, debst and debz do broadcast to the 750's L2 cache, regardless of HIDO[ABE]. The iebi instruction is never broadcast.

3.4.2.1 Data Cache Block Touch (dcbt) and

Data Cache Block Touch for Store (dcbtst)

The Data Cache Block Touch (debt) and Data Cache Block Touch for Store (debtst) instructions provide potential system performance improvement through the use of software-initiated prefetch hints. The 750 treats these instructions identically (that is, a debtst instruction behaves exactly the same as a debt instruction on the 750). Note that PowerPC implementations are not required to take any action based on the execution of these instructions, but they may choose to prefetch the cache block corresponding to the effective address into their cache.

The 750 loads the data into the cache when the address hits in the TLB or the BAT, is permitted load access from the addressed page, is not directed to a direct-store segment, and is directed at a cacheable page. Otherwise, the 750 treats these instructions as no-ops. The data brought into the cache as a result of this instruction is validated in the same manner

that a load instruction would be (that is, it is marked as exclusive). The memory reference of a debt (or debtst) instruction causes the reference bit to be set. Note also that the successful execution of the debt (or debtst) instruction affects the state of the TLB and cache LRU bits as defined by the PLRU algorithm.

3.4.2.2 Data Cache Block Zero (dcbz)

The effective address is computed, translated, and checked for protection violations as defined in the PowerPC architecture. The debz instruction is treated as a store to the addressed byte with respect to address translation and protection.

If the block containing the byte addressed by the EA is in the data cache, all bytes are cleared, and the tag is marked as modified (M). If the block containing the byte addressed by the EA is not in the data cache and the corresponding page is caching-allowed, the block is established in the data cache without fetching the block from main memory, and all bytes of the block are cleared, and the tag is marked as modified (M).

If the contents of the cache block are from a page marked memory coherence required (M = 1), an address-only bus transaction is run prior to clearing the cache block. The debz instruction is the only cache control instruction that causes a broadcast on the 60x bus (when M = 1) to maintain coherency. The other cache control instructions are not broadcast unless broadcasting is specifically enabled through the HIDO[ABE] configuration bit.

The debz instruction executes regardless of whether the cache is locked, but if the cache is disabled, an alignment exception is generated. If the page containing the byte addressed by the EA is caching-inhibited or write-through, then the system alignment exception handler is invoked. BAT and TLB protection violations generate DSI exceptions.

3.4.2.3 Data Cache Block Store (dcbst)

The effective address is computed, translated, and checked for protection violations as defined in the PowerPC architecture. This instruction is treated as a load with respect to address translation and memory protection.

If the address hits in the cache and the cache block is in the exclusive (E) state, no action is taken. If the address hits in the cache and the cache block is in the modified (M) state, the modified block is written back to memory and the cache block is placed in the exclusive (E) state.

The execution of a debst instruction does not broadcast on the 60x bus unless broadcast is enabled through the HIDO[ABE] bit. The function of this instruction is independent of the WIMG bit settings of the block containing the effective address. The debst instruction executes regardless of whether the cache is disabled or locked; however, a BAT or TLB protection violation generates a DSI exception.

3-16 IBM PowerPC 740 I PowerPC 750 RISC Microprocessor User's Manual

3.4.2.4 Data Cache Block Flush (dcbt)

The effective address is computed, translated, and checked for protection violations as defined in the PowerPC architecture. This instruction is treated as a load with respect to address translation and memory protection.

If the address hits in the cache, and the block is in the modified (M) state, the modified block is written back to memory and the cache block is placed in the invalid (I) state. If the address hits in the cache, and the cache block is in the exclusive (E) state, the cache block is placed in the invalid (1) state. If the address misses in the cache, no action is taken.

The execution of debf does not broadcast on the 60x bus unless broadcast is enabled through the HIDO[ABE] bit. The function of this instruction is independent of the WIMG bit settings of the block containing the effective address. The debf instruction executes regardless of whether the cache is disabled or locked; however, a BAT or TLB protection violation generates a DSI exception.

3.4.2.5 Data Cache Block Invalidate (dcbi)

The effective address is computed, translated, and checked for protection violations as defined in the PowerPC architecture. This instruction is treated as a store with respect to address translation and memory protection.

If the address hits in the cache, the cache block is placed in the invalid (I) state, regardless of whether the data is modified. Because this instruction may effectively destroy modified data, it is privileged (that is, debi is available to programs at the supervisor privilege level, MSR[PR] = 0).

The execution of debi does not broadcast on the 60x bus unless broadcast is enabled through the HIDO[ABE] bit. The function of this instruction is independent of the WIMG bit settings of the block containing the effective address. The debi instruction executes regardless of whether the cache is disabled or locked; however, a BAT or TLB protection violation generates a DSI exception.

3.4.2.6 Instruction Cache Block Invalidate (icbi)

For the iebi instruction, the effective address is not computed or translated, so it cannot generate a protection violation or exception. This instruction performs a virtual lookup into the instruction cache (index only). All ways of the selected instruction cache set are invalidated.

The icbi instruction is not broadcast on the 60x bus. The icbi instruction invalidates the cache blocks independent of whether the cache is disabled or locked.

Dans le document PowerPC 750™ PowerPC 740™ (Page 158-163)