inline uint8_t
__BS(read_stream_1)(void *v, bus_space_handle_t h, bus_size_t off)
{
#if CHIP_ACCESS_SIZE > 1
	volatile CHIP_TYPE *ptr;
#else	/* CHIP_ACCESS_SIZE > 1 */
	volatile uint8_t *ptr;
#endif	/* CHIP_ACCESS_SIZE > 1 */

	ptr = (void *)(h + CHIP_OFF8(off));
	return *ptr & 0xff;
}
inline void
__BS(write_1)(void *v, bus_space_handle_t h, bus_size_t off, uint8_t val)
{
#if CHIP_ACCESS_SIZE > 1
	volatile CHIP_TYPE *ptr;
#else	/* CHIP_ACCESS_SIZE > 1 */
	volatile uint8_t *ptr;
#endif	/* CHIP_ACCESS_SIZE > 1 */

	ptr = (void *)(h + CHIP_OFF8(off));
	*ptr = val;
}
static uint8_t
__BS(read_stream_1)(void *v, bus_space_handle_t h, bus_size_t off)
{
	h += CHIP_OFF8(off);

#if CHIP_ACCESS_SIZE == 8
	return (uint8_t)mips3_ld(h);
#elif CHIP_ACCESS_SIZE == 4
	return (uint8_t)mips_lwu(h);
#elif CHIP_ACCESS_SIZE == 2
	return (uint8_t)mips_lhu(h);
#else
	return mips_lbu(h);
#endif
}
static void
__BS(write_1)(void *v, bus_space_handle_t h, bus_size_t off, uint8_t val)
{
	h += CHIP_OFF8(off);

#if CHIP_ACCESS_SIZE == 1
	mips_sb(h, val);
#else
	const int shift = (h & (CHIP_ACCESS_SIZE - 1)) * 8;
	h &= ~((bus_space_handle_t)(CHIP_ACCESS_SIZE - 1));
	CHIP_TYPE cval = CHIP_SWAP_ACCESS(((CHIP_TYPE)val) << shift);
# if CHIP_ACCESS_SIZE == 8
	mips3_sd(h, cval);
# elif CHIP_ACCESS_SIZE == 4
	mips_sw(h, cval);
# else
	mips_sh(h, cval);
# endif
#endif
}
static uint8_t
__BS(read_1)(void *v, bus_space_handle_t h, bus_size_t off)
{
	h += CHIP_OFF8(off);

	const int shift = (h & (CHIP_ACCESS_SIZE - 1)) * 8;
	h &= ~((bus_space_handle_t)(CHIP_ACCESS_SIZE - 1));
#if CHIP_ACCESS_SIZE == 8
	const CHIP_TYPE val = mips3_ld(h);
#elif CHIP_ACCESS_SIZE == 4
	const CHIP_TYPE val = mips_lwu(h);
#elif CHIP_ACCESS_SIZE == 2
	const CHIP_TYPE val = mips_lhu(h);
#else
	const uint8_t val = mips_lbu(h);
#endif
	const uint8_t r = (uint8_t)(CHIP_SWAP_ACCESS(val) >> shift);

	return r;
}