spu_dcache.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void spu_dcache_fetch_unaligned (qword *dst, unsigned ea, unsigned size)
 Fetch between arbitrary number of bytes from an unaligned address.
void spu_dcache_mark_dirty (unsigned ea, unsigned size)
 Notify the cache that a range of main memory may have been modified.
void spu_dcache_report (void)
 Print cache utilization report.


Function Documentation

void spu_dcache_fetch_unaligned ( qword *  dst,
unsigned  ea,
unsigned  size 
)

Fetch between arbitrary number of bytes from an unaligned address.

Parameters:
dst Destination data buffer
ea Main memory effective address of source data
size Number of bytes to read
Warning:
As is hinted by the type of the dst pointer, this function writes multiples of 16-bytes.

Definition at line 63 of file spu_dcache.c.

References ASSERT, and ROUNDUP16.

00064 {
00065    const int shift = ea & 0x0f;
00066    const unsigned read_size = ROUNDUP16(size + shift);
00067    const unsigned last_read = ROUNDUP16(ea + size);
00068    const qword *const last_write = dst + (ROUNDUP16(size) / 16);
00069    unsigned i;
00070 
00071 
00072    if (shift == 0) {
00073       /* Data is already aligned.  Fetch directly into the destination buffer.
00074        */
00075       for (i = 0; i < size; i += 16) {
00076          *(dst++) = cache_rd(data, ea + i);
00077       }
00078    } else {
00079       qword hi;
00080 
00081 
00082       /* Please exercise extreme caution when modifying this code.  This code
00083        * must not read past the end of the page containing the source data,
00084        * and it must not write more than ((size + 15) / 16) qwords to the
00085        * destination buffer.
00086        */
00087       ea &= ~0x0f;
00088       hi = cache_rd(data, ea);
00089       for (i = 16; i < read_size; i += 16) {
00090          qword lo = cache_rd(data, ea + i);
00091 
00092          *(dst++) = si_or((qword) spu_slqwbyte(hi, shift),
00093                           (qword) spu_rlmaskqwbyte(lo, shift - 16));
00094          hi = lo;
00095       }
00096 
00097       if (dst != last_write) {
00098          *(dst++) = si_or((qword) spu_slqwbyte(hi, shift), si_il(0));
00099       }
00100    }
00101    
00102    ASSERT((ea + i) == last_read);
00103    ASSERT(dst == last_write);
00104 }

void spu_dcache_mark_dirty ( unsigned  ea,
unsigned  size 
)

Notify the cache that a range of main memory may have been modified.

Definition at line 111 of file spu_dcache.c.

References ALIGN_MASK, CACHE_NSETS, CACHE_NWAY, and LINE_SIZE.

00112 {
00113    unsigned i;
00114    const unsigned aligned_start = (ea & ALIGN_MASK);
00115    const unsigned aligned_end = (ea + size + (LINE_SIZE - 1)) 
00116        & ALIGN_MASK;
00117 
00118 
00119    for (i = 0; i < (CACHE_NWAY * CACHE_NSETS); i++) {
00120       const unsigned entry = __cache_dir[i];
00121       const unsigned addr = entry & ~0x0f;
00122 
00123       __cache_dir[i] = ((addr >= aligned_start) && (addr < aligned_end))
00124           ? (entry & ~CACHELINE_VALID) : entry;
00125    }
00126 }

void spu_dcache_report ( void   ) 

Print cache utilization report.

Definition at line 133 of file spu_dcache.c.

References cell_init_info::id, spu_global::init, and spu.

00134 {
00135 #ifdef CACHE_STATS
00136    if (spu.init.id == 0) {
00137       printf("SPU 0: Texture cache report:\n");
00138       cache_pr_stats(data);
00139    }
00140 #endif
00141 }


Generated on Tue Sep 29 06:25:32 2009 for Gallium3D by  doxygen 1.5.4