Line 165... |
Line 165... |
{
|
{
|
unsigned int size_mask = bit_mask (size);
|
unsigned int size_mask = bit_mask (size);
|
unsigned int addr_mask = ~size_mask;
|
unsigned int addr_mask = ~size_mask;
|
struct dev_memarea *mem;
|
struct dev_memarea *mem;
|
|
|
|
printf ("Reg mem area, addr = 0x%08lx, size_mask = 0x%08lx, "
|
|
"addr_mask = 0x%08lx\n", (unsigned long int) addr,
|
|
(unsigned long int) size_mask, (unsigned long int) addr_mask);
|
|
|
mem = register_memoryarea_mask (addr_mask, addr & addr_mask, size_mask + 1,
|
mem = register_memoryarea_mask (addr_mask, addr & addr_mask, size_mask + 1,
|
mc_dev);
|
mc_dev);
|
|
|
memcpy (&mem->ops, ops, sizeof (struct mem_ops));
|
memcpy (&mem->ops, ops, sizeof (struct mem_ops));
|
memcpy (&mem->direct_ops, ops, sizeof (struct mem_ops));
|
memcpy (&mem->direct_ops, ops, sizeof (struct mem_ops));
|
Line 241... |
Line 245... |
|
|
/* Check memory controller space first */
|
/* Check memory controller space first */
|
if (mc_area
|
if (mc_area
|
&& (addr & mc_area->addr_mask) ==
|
&& (addr & mc_area->addr_mask) ==
|
(mc_area->addr_compare & mc_area->addr_mask))
|
(mc_area->addr_compare & mc_area->addr_mask))
|
|
{
|
return cur_area = mc_area;
|
return cur_area = mc_area;
|
|
}
|
|
|
/* Check cached value */
|
/* Check cached value */
|
if (cur_area
|
if (cur_area
|
&& (addr & cur_area->addr_mask) ==
|
&& (addr & cur_area->addr_mask) ==
|
(cur_area->addr_compare & cur_area->addr_mask))
|
(cur_area->addr_compare & cur_area->addr_mask))
|
|
{
|
return cur_area;
|
return cur_area;
|
|
}
|
|
|
/* When mc is enabled, we must check valid also, otherwise we assume it is
|
/* When mc is enabled, we must check valid also, otherwise we assume it is
|
nonzero */
|
nonzero */
|
/* Check list of registered devices. */
|
/* Check list of registered devices. */
|
for (ptmp = dev_list; ptmp; ptmp = ptmp->next)
|
for (ptmp = dev_list; ptmp; ptmp = ptmp->next)
|
|
{
|
if ((addr & ptmp->addr_mask) == (ptmp->addr_compare & ptmp->addr_mask)
|
if ((addr & ptmp->addr_mask) == (ptmp->addr_compare & ptmp->addr_mask)
|
&& ptmp->valid)
|
&& ptmp->valid)
|
|
{
|
return cur_area = ptmp;
|
return cur_area = ptmp;
|
|
}
|
|
}
|
|
|
return cur_area = NULL;
|
return cur_area = NULL;
|
}
|
}
|
|
|
/* Sets the valid bit (Used only by memory controllers) */
|
/* Sets the valid bit (Used only by memory controllers) */
|
void
|
void
|