/* Initialize the data cache. */ DCACHE * dcache_init (void) { int csize = sizeof (struct dcache_block) * DCACHE_SIZE; DCACHE *dcache; dcache = (DCACHE *) xmalloc (sizeof (*dcache)); dcache->the_cache = (struct dcache_block *) xmalloc (csize); memset (dcache->the_cache, 0, csize); dcache_invalidate (dcache); last_cache = dcache; return dcache; }
/* * Dキャッシュを開始 */ void dcache_enable(void) { uint32_t bits; CP15_CONTROL_READ(bits); /* すでにONならリターン */ if (bits & CP15_CONTROL_C_BIT){ return; } dcache_invalidate(); bits |= CP15_CONTROL_C_BIT; CP15_CONTROL_WRITE(bits); }
enum target_xfer_status dcache_read_memory_partial (struct target_ops *ops, DCACHE *dcache, CORE_ADDR memaddr, gdb_byte *myaddr, ULONGEST len, ULONGEST *xfered_len) { ULONGEST i; /* If this is a different inferior from what we've recorded, flush the cache. */ if (! ptid_equal (inferior_ptid, dcache->ptid)) { dcache_invalidate (dcache); dcache->ptid = inferior_ptid; } for (i = 0; i < len; i++) { if (!dcache_peek_byte (dcache, memaddr + i, myaddr + i)) { /* That failed. Discard its cache line so we don't have a partially read line. */ dcache_invalidate_line (dcache, memaddr + i); break; } } if (i == 0) { /* Even though reading the whole line failed, we may be able to read a piece starting where the caller wanted. */ return raw_memory_xfer_partial (ops, myaddr, NULL, memaddr, len, xfered_len); } else { *xfered_len = i; return TARGET_XFER_OK; } }