diff --git a/sys/i386/isa/isa.c b/sys/i386/isa/isa.c index a62c658136f3..786de1a98e79 100644 --- a/sys/i386/isa/isa.c +++ b/sys/i386/isa/isa.c @@ -203,28 +203,9 @@ isa_alloc_resourcev(device_t child, int type, int *rid, int isa_load_resourcev(struct resource *re, bus_addr_t *res, bus_size_t count) { - bus_addr_t start; - bus_space_handle_t bh; - int i; - bh = rman_get_bushandle(re); - if (count > bh->bsh_maxiatsz) { - printf("isa_load_resourcev: map size too large\n"); - return EINVAL; - } - - start = rman_get_start(re); - for (i = 0; i < bh->bsh_maxiatsz; i++) { - if (i < count) - bh->bsh_iat[i] = start + res[i]; - else - bh->bsh_iat[i] = start; - } - - bh->bsh_iatsz = count; - bh->bsh_bam = rman_get_bustag(re)->bs_ra; /* relocate access */ - - return 0; + return bus_space_map_load(rman_get_bustag(re), rman_get_bushandle(re), + count, res, 0); } #endif /* PC98 */ diff --git a/sys/pc98/include/bus.h b/sys/pc98/include/bus.h index 39111f5620a4..07b7ea3489b7 100644 --- a/sys/pc98/include/bus.h +++ b/sys/pc98/include/bus.h @@ -92,7 +92,13 @@ #define BUS_SPACE_UNRESTRICTED (~0) +/* + * address relocation table + */ #define BUS_SPACE_IAT_MAXSIZE 33 +typedef bus_addr_t *bus_space_iat_t; + +#define BUS_SPACE_IAT_SZ(IOTARRAY) (sizeof(IOTARRAY)/sizeof(bus_addr_t)) /* * Access methods for bus resources and address space. @@ -223,6 +229,19 @@ void i386_memio_unmap(bus_space_tag_t t, bus_space_handle_t bsh, #define bus_space_unmap(t, h, s) \ i386_memio_unmap((t), (h), (s)) +/* + * int bus_space_map_load (bus_space_tag_t t, bus_space_handle_t bsh, + * bus_size_t size, bus_space_iat_t iat, u_int flags); + * + * Load I/O address table of bus space. + */ + +int i386_memio_map_load(bus_space_tag_t t, bus_space_handle_t bsh, + bus_size_t size, bus_space_iat_t iat, u_int flags); + +#define bus_space_map_load(t, h, s, iat, f) \ + i386_memio_map_load((t), (h), (s), (iat), (f)) + /* * int bus_space_subregion (bus_space_tag_t t, * bus_space_handle_t bsh, bus_size_t offset, bus_size_t size, @@ -260,6 +279,9 @@ void i386_memio_free(bus_space_tag_t t, bus_space_handle_t bsh, int i386_memio_compare(bus_space_tag_t t1, bus_space_handle_t bsh1, bus_space_tag_t t2, bus_space_handle_t bsh2); +#define bus_space_compare(t1, h1, t2, h2) \ + i386_memio_compare((t1), (h1), (t2), (h2)) + /* * Access methods for bus resources and address space. */ diff --git a/sys/pc98/pc98/busiosubr.c b/sys/pc98/pc98/busiosubr.c index 79b06cee1b17..dffe5fff7fe5 100644 --- a/sys/pc98/pc98/busiosubr.c +++ b/sys/pc98/pc98/busiosubr.c @@ -220,6 +220,31 @@ i386_memio_free(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t size) i386_memio_unmap(t, bsh, bsh->bsh_sz); } +int +i386_memio_map_load(bus_space_tag_t t, bus_space_handle_t bsh, + bus_size_t size, bus_space_iat_t iat, u_int flags __unused) +{ + int i; + + if (size > bsh->bsh_maxiatsz) { + printf("i386_memio_map_load: map size too large\n"); + return EINVAL; + } + + for (i = 0; i < bsh->bsh_maxiatsz; i++) { + if (i < size) + bsh->bsh_iat[i] = iat[i]; + else + bsh->bsh_iat[i] = 0; + bsh->bsh_iat[i] += bsh->bsh_base; + } + + bsh->bsh_iatsz = size; + bsh->bsh_bam = t->bs_ra; /* relocate access */ + + return 0; +} + int i386_memio_subregion(bus_space_tag_t t, bus_space_handle_t pbsh, bus_size_t offset, bus_size_t size,