Add i386_memio_compare() to compare two resources.

It's used by uart(4) in the future.
This commit is contained in:
nyan 2008-07-05 16:31:58 +00:00
parent 54ef085aee
commit b8ebcde152
2 changed files with 34 additions and 0 deletions

View File

@ -251,6 +251,15 @@ void i386_memio_free(bus_space_tag_t t, bus_space_handle_t bsh,
#define bus_space_free(t, h, s) \
i386_memio_free((t), (h), (s))
/*
* int bus_space_compare (bus_space_tag_t t1, bus_space_handle_t bsh1,
* bus_space_tag_t t2, bus_space_handle_t bsh2);
*
* Compare two resources.
*/
int i386_memio_compare(bus_space_tag_t t1, bus_space_handle_t bsh1,
bus_space_tag_t t2, bus_space_handle_t bsh2);
/*
* Access methods for bus resources and address space.
*/

View File

@ -279,3 +279,28 @@ i386_memio_subregion(bus_space_tag_t t, bus_space_handle_t pbsh,
*tbshp = bsh;
return error;
}
int
i386_memio_compare(bus_space_tag_t t1, bus_space_handle_t bsh1,
bus_space_tag_t t2, bus_space_handle_t bsh2)
{
int i;
if (t1->bs_tag != t2->bs_tag)
return (1);
if (bsh1->bsh_base != bsh2->bsh_base)
return (1);
if (bsh1->bsh_sz != bsh2->bsh_sz)
return (1);
if (bsh1->bsh_bam.bs_read_1 != bsh2->bsh_bam.bs_read_1) /* XXX */
return (1);
if (bsh1->bsh_iatsz != bsh2->bsh_iatsz)
return (1);
for (i = 0; i < bsh1->bsh_iatsz; i++) {
if (bsh1->bsh_iat[i] != bsh2->bsh_iat[i])
return (1);
}
return (0);
}