New generic powerpc bus_space framework.

This commit is contained in:
matt 2003-03-15 08:03:19 +00:00
parent e2765c0933
commit a0b2076415
2 changed files with 1447 additions and 0 deletions

View File

@ -0,0 +1,654 @@
/* $NetBSD: bus_space.c,v 1.1 2003/03/15 08:03:19 matt Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
* NASA Ames Research Center.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/device.h>
#include <sys/endian.h>
#include <sys/extent.h>
#include <sys/malloc.h>
#include <uvm/uvm_extern.h>
#define _POWERPC_BUS_SPACE_PRIVATE
#include <machine/bus.h>
#ifdef PPC_OEA
#include <powerpc/oea/bat.h>
#include <powerpc/oea/pte.h>
#endif
/* read_N */
u_int8_t bsr1(bus_space_tag_t, bus_space_handle_t, bus_size_t);
u_int16_t bsr2(bus_space_tag_t, bus_space_handle_t, bus_size_t);
u_int32_t bsr4(bus_space_tag_t, bus_space_handle_t, bus_size_t);
u_int64_t bsr8(bus_space_tag_t, bus_space_handle_t, bus_size_t);
/* write_N */
void bsw1(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int8_t);
void bsw2(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int16_t);
void bsw4(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t);
void bsw8(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int64_t);
static const struct powerpc_bus_space_scalar scalar_ops = {
bsr1, bsr2, bsr4, bsr8,
bsw1, bsw2, bsw4, bsw8
};
/* read_N byte reverse */
u_int16_t bsr2rb(bus_space_tag_t, bus_space_handle_t, bus_size_t);
u_int32_t bsr4rb(bus_space_tag_t, bus_space_handle_t, bus_size_t);
u_int64_t bsr8rb(bus_space_tag_t, bus_space_handle_t, bus_size_t);
/* write_N byte reverse */
void bsw2rb(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int16_t);
void bsw4rb(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t);
void bsw8rb(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int64_t);
static const struct powerpc_bus_space_scalar scalar_rb_ops = {
bsr1, bsr2rb, bsr4rb, bsr8rb,
bsw1, bsw2rb, bsw4rb, bsw8rb
};
/* read_multi_N */
void bsrm1(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int8_t *,
size_t);
void bsrm2(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int16_t *,
size_t);
void bsrm4(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t *,
size_t);
void bsrm8(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int64_t *,
size_t);
/* write_multi_N */
void bswm1(bus_space_tag_t, bus_space_handle_t, bus_size_t,
const u_int8_t *, size_t);
void bswm2(bus_space_tag_t, bus_space_handle_t, bus_size_t,
const u_int16_t *, size_t);
void bswm4(bus_space_tag_t, bus_space_handle_t, bus_size_t,
const u_int32_t *, size_t);
void bswm8(bus_space_tag_t, bus_space_handle_t, bus_size_t,
const u_int64_t *, size_t);
static const struct powerpc_bus_space_group multi_ops = {
bsrm1, bsrm2, bsrm4, bsrm8,
bswm1, bswm2, bswm4, bswm8
};
/* read_multi_N byte reversed */
void bsrm2rb(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int16_t *,
size_t);
void bsrm4rb(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t *,
size_t);
void bsrm8rb(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int64_t *,
size_t);
/* write_multi_N byte reversed */
void bswm2rb(bus_space_tag_t, bus_space_handle_t, bus_size_t,
const u_int16_t *, size_t);
void bswm4rb(bus_space_tag_t, bus_space_handle_t, bus_size_t,
const u_int32_t *, size_t);
void bswm8rb(bus_space_tag_t, bus_space_handle_t, bus_size_t,
const u_int64_t *, size_t);
static const struct powerpc_bus_space_group multi_rb_ops = {
bsrm1, bsrm2rb, bsrm4rb, bsrm8rb,
bswm1, bswm2rb, bswm4rb, bswm8rb
};
/* read_region_N */
void bsrr1(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int8_t *,
size_t);
void bsrr2(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int16_t *,
size_t);
void bsrr4(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t *,
size_t);
void bsrr8(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int64_t *,
size_t);
/* write_region_N */
void bswr1(bus_space_tag_t, bus_space_handle_t, bus_size_t,
const u_int8_t *, size_t);
void bswr2(bus_space_tag_t, bus_space_handle_t, bus_size_t,
const u_int16_t *, size_t);
void bswr4(bus_space_tag_t, bus_space_handle_t, bus_size_t,
const u_int32_t *, size_t);
void bswr8(bus_space_tag_t, bus_space_handle_t, bus_size_t,
const u_int64_t *, size_t);
static const struct powerpc_bus_space_group region_ops = {
bsrr1, bsrr2, bsrr4, bsrr8,
bswr1, bswr2, bswr4, bswr8
};
void bsrr2rb(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int16_t *,
size_t);
void bsrr4rb(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t *,
size_t);
void bsrr8rb(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int64_t *,
size_t);
void bswr2rb(bus_space_tag_t, bus_space_handle_t, bus_size_t,
const u_int16_t *, size_t);
void bswr4rb(bus_space_tag_t, bus_space_handle_t, bus_size_t,
const u_int32_t *, size_t);
void bswr8rb(bus_space_tag_t, bus_space_handle_t, bus_size_t,
const u_int64_t *, size_t);
static const struct powerpc_bus_space_group region_rb_ops = {
bsrr1, bsrr2rb, bsrr4rb, bsrr8rb,
bswr1, bswr2rb, bswr4rb, bswr8rb
};
/* set_region_n */
void bssr1(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int8_t,
size_t);
void bssr2(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int16_t,
size_t);
void bssr4(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t,
size_t);
void bssr8(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int64_t,
size_t);
static const struct powerpc_bus_space_set set_ops = {
bssr1, bssr2, bssr4, bssr8,
};
void bssr2rb(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int16_t,
size_t);
void bssr4rb(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t,
size_t);
void bssr8rb(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int64_t,
size_t);
static const struct powerpc_bus_space_set set_rb_ops = {
bssr1, bssr2rb, bssr4rb, bssr8rb,
};
/* copy_region_N */
void bscr1(bus_space_tag_t, bus_space_handle_t,
bus_size_t, bus_space_handle_t, bus_size_t, size_t);
void bscr2(bus_space_tag_t, bus_space_handle_t,
bus_size_t, bus_space_handle_t, bus_size_t, size_t);
void bscr4(bus_space_tag_t, bus_space_handle_t,
bus_size_t, bus_space_handle_t, bus_size_t, size_t);
void bscr8(bus_space_tag_t, bus_space_handle_t,
bus_size_t, bus_space_handle_t, bus_size_t, size_t);
static const struct powerpc_bus_space_copy copy_ops = {
bscr1, bscr2, bscr4, bscr8
};
/*
* Strided versions
*/
/* read_N */
u_int8_t bsr1_s(bus_space_tag_t, bus_space_handle_t, bus_size_t);
u_int16_t bsr2_s(bus_space_tag_t, bus_space_handle_t, bus_size_t);
u_int32_t bsr4_s(bus_space_tag_t, bus_space_handle_t, bus_size_t);
u_int64_t bsr8_s(bus_space_tag_t, bus_space_handle_t, bus_size_t);
/* write_N */
void bsw1_s(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int8_t);
void bsw2_s(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int16_t);
void bsw4_s(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t);
void bsw8_s(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int64_t);
static const struct powerpc_bus_space_scalar scalar_strided_ops = {
bsr1_s, bsr2_s, bsr4_s, bsr8_s,
bsw1_s, bsw2_s, bsw4_s, bsw8_s
};
/* read_N */
u_int16_t bsr2rb_s(bus_space_tag_t, bus_space_handle_t, bus_size_t);
u_int32_t bsr4rb_s(bus_space_tag_t, bus_space_handle_t, bus_size_t);
u_int64_t bsr8rb_s(bus_space_tag_t, bus_space_handle_t, bus_size_t);
/* write_N */
void bsw2rb_s(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int16_t);
void bsw4rb_s(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t);
void bsw8rb_s(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int64_t);
static const struct powerpc_bus_space_scalar scalar_rb_strided_ops = {
bsr1_s, bsr2rb_s, bsr4rb_s, bsr8rb_s,
bsw1_s, bsw2rb_s, bsw4rb_s, bsw8rb_s
};
/* read_multi_N */
void bsrm1_s(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int8_t *,
size_t);
void bsrm2_s(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int16_t *,
size_t);
void bsrm4_s(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t *,
size_t);
void bsrm8_s(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int64_t *,
size_t);
/* write_multi_N */
void bswm1_s(bus_space_tag_t, bus_space_handle_t, bus_size_t,
const u_int8_t *, size_t);
void bswm2_s(bus_space_tag_t, bus_space_handle_t, bus_size_t,
const u_int16_t *, size_t);
void bswm4_s(bus_space_tag_t, bus_space_handle_t, bus_size_t,
const u_int32_t *, size_t);
void bswm8_s(bus_space_tag_t, bus_space_handle_t, bus_size_t,
const u_int64_t *, size_t);
static const struct powerpc_bus_space_group multi_strided_ops = {
bsrm1_s, bsrm2_s, bsrm4_s, bsrm8_s,
bswm1_s, bswm2_s, bswm4_s, bswm8_s
};
/* read_multi_N */
void bsrm2rb_s(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int16_t *,
size_t);
void bsrm4rb_s(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t *,
size_t);
void bsrm8rb_s(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int64_t *,
size_t);
/* write_multi_N */
void bswm2rb_s(bus_space_tag_t, bus_space_handle_t, bus_size_t,
const u_int16_t *, size_t);
void bswm4rb_s(bus_space_tag_t, bus_space_handle_t, bus_size_t,
const u_int32_t *, size_t);
void bswm8rb_s(bus_space_tag_t, bus_space_handle_t, bus_size_t,
const u_int64_t *, size_t);
static const struct powerpc_bus_space_group multi_rb_strided_ops = {
bsrm1_s, bsrm2rb_s, bsrm4rb_s, bsrm8rb_s,
bswm1_s, bswm2rb_s, bswm4rb_s, bswm8rb_s
};
/* read_region_N */
void bsrr1_s(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int8_t *,
size_t);
void bsrr2_s(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int16_t *,
size_t);
void bsrr4_s(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t *,
size_t);
void bsrr8_s(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int64_t *,
size_t);
/* write_region_N */
void bswr1_s(bus_space_tag_t, bus_space_handle_t, bus_size_t,
const u_int8_t *, size_t);
void bswr2_s(bus_space_tag_t, bus_space_handle_t, bus_size_t,
const u_int16_t *, size_t);
void bswr4_s(bus_space_tag_t, bus_space_handle_t, bus_size_t,
const u_int32_t *, size_t);
void bswr8_s(bus_space_tag_t, bus_space_handle_t, bus_size_t,
const u_int64_t *, size_t);
static const struct powerpc_bus_space_group region_strided_ops = {
bsrr1_s, bsrr2_s, bsrr4_s, bsrr8_s,
bswr1_s, bswr2_s, bswr4_s, bswr8_s
};
/* read_region_N */
void bsrr2rb_s(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int16_t *,
size_t);
void bsrr4rb_s(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t *,
size_t);
void bsrr8rb_s(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int64_t *,
size_t);
/* write_region_N */
void bswr2rb_s(bus_space_tag_t, bus_space_handle_t, bus_size_t,
const u_int16_t *, size_t);
void bswr4rb_s(bus_space_tag_t, bus_space_handle_t, bus_size_t,
const u_int32_t *, size_t);
void bswr8rb_s(bus_space_tag_t, bus_space_handle_t, bus_size_t,
const u_int64_t *, size_t);
static const struct powerpc_bus_space_group region_rb_strided_ops = {
bsrr1_s, bsrr2rb_s, bsrr4rb_s, bsrr8rb_s,
bswr1_s, bswr2rb_s, bswr4rb_s, bswr8rb_s
};
/* set_region_N */
void bssr1_s(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int8_t,
size_t);
void bssr2_s(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int16_t,
size_t);
void bssr4_s(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t,
size_t);
void bssr8_s(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int64_t,
size_t);
static const struct powerpc_bus_space_set set_strided_ops = {
bssr1_s, bssr2_s, bssr4_s, bssr8_s,
};
/* set_region_N */
void bssr2rb_s(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int16_t,
size_t);
void bssr4rb_s(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t,
size_t);
void bssr8rb_s(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int64_t,
size_t);
static const struct powerpc_bus_space_set set_rb_strided_ops = {
bssr1_s, bssr2rb_s, bssr4rb_s, bssr8rb_s,
};
/* copy_region_N */
void bscr1_s(bus_space_tag_t, bus_space_handle_t, bus_size_t,
bus_space_handle_t, bus_size_t, size_t);
void bscr2_s(bus_space_tag_t, bus_space_handle_t, bus_size_t,
bus_space_handle_t, bus_size_t, size_t);
void bscr4_s(bus_space_tag_t, bus_space_handle_t, bus_size_t,
bus_space_handle_t, bus_size_t, size_t);
void bscr8_s(bus_space_tag_t, bus_space_handle_t, bus_size_t,
bus_space_handle_t, bus_size_t, size_t);
static const struct powerpc_bus_space_copy copy_strided_ops = {
bscr1_s, bscr2_s, bscr4_s, bscr8_s
};
static paddr_t memio_mmap(bus_space_tag_t, bus_addr_t, off_t, int, int);
static int memio_map(bus_space_tag_t, bus_addr_t, bus_size_t, int,
bus_space_handle_t *);
static int memio_subregion(bus_space_tag_t, bus_space_handle_t, bus_size_t,
bus_size_t, bus_space_handle_t *);
static void memio_unmap(bus_space_tag_t, bus_space_handle_t, bus_size_t);
static int memio_alloc(bus_space_tag_t, bus_addr_t, bus_addr_t, bus_size_t,
bus_size_t, bus_size_t, int, bus_addr_t *, bus_space_handle_t *);
static void memio_free(bus_space_tag_t, bus_space_handle_t, bus_size_t);
static int extent_flags;
int
bus_space_init(struct powerpc_bus_space *t, const char *extent_name,
caddr_t storage, size_t storage_size)
{
if (t->pbs_extent == NULL) {
t->pbs_extent = extent_create(extent_name, t->pbs_base,
t->pbs_limit-1, M_DEVBUF, storage, storage_size,
EX_NOCOALESCE|EX_NOWAIT);
if (t->pbs_extent == NULL)
return ENOMEM;
}
t->pbs_mmap = memio_mmap;
t->pbs_map = memio_map;
t->pbs_subregion = memio_subregion;
t->pbs_unmap = memio_unmap;
t->pbs_alloc = memio_alloc;
t->pbs_free = memio_free;
if (t->pbs_flags & _BUS_SPACE_STRIDE_MASK) {
t->pbs_scalar_stream = scalar_strided_ops;
t->pbs_multi_stream = &multi_strided_ops;
t->pbs_region_stream = &region_strided_ops;
t->pbs_set_stream = &set_strided_ops;
t->pbs_copy = &copy_strided_ops;
} else {
t->pbs_scalar_stream = scalar_ops;
t->pbs_multi_stream = &multi_ops;
t->pbs_region_stream = &region_ops;
t->pbs_set_stream = &set_ops;
t->pbs_copy = &copy_ops;
}
#if BYTE_ORDER == BIG_ENDIAN
if (t->pbs_flags & _BUS_SPACE_BIG_ENDIAN) {
if (t->pbs_flags & _BUS_SPACE_STRIDE_MASK) {
t->pbs_scalar = scalar_strided_ops;
t->pbs_multi = &multi_strided_ops;
t->pbs_region = &region_strided_ops;
t->pbs_set = &set_strided_ops;
} else {
t->pbs_scalar = scalar_ops;
t->pbs_multi = &multi_ops;
t->pbs_region = &region_ops;
t->pbs_set = &set_ops;
}
} else {
if (t->pbs_flags & _BUS_SPACE_STRIDE_MASK) {
t->pbs_scalar = scalar_rb_strided_ops;
t->pbs_multi = &multi_rb_strided_ops;
t->pbs_region = &region_rb_strided_ops;
t->pbs_set = &set_rb_strided_ops;
} else {
t->pbs_scalar = scalar_rb_ops;
t->pbs_multi = &multi_rb_ops;
t->pbs_region = &region_rb_ops;
t->pbs_set = &set_rb_ops;
}
}
#else
if (t->pbs_flags & _BUS_SPACE_LITTLE_ENDIAN) {
if (t->pbs_flags & _BUS_SPACE_STRIDE_MASK) {
t->pbs_scalar = scalar_strided_ops;
t->pbs_multi = &multi_strided_ops;
t->pbs_region = &region_strided_ops;
t->pbs_set = &set_strided_ops;
} else {
t->pbs_scalar = scalar_ops;
t->pbs_multi = &multi_ops;
t->pbs_region = &region_ops;
t->pbs_set = &set_ops;
}
} else {
if (t->pbs_flags & _BUS_SPACE_STRIDE_MASK) {
t->pbs_scalar = scalar_rb_strided_ops;
t->pbs_multi = &multi_rb_strided_ops;
t->pbs_region = &region_rb_strided_ops;
t->pbs_set = &set_rb_strided_ops;
} else {
t->pbs_scalar = scalar_rb_ops;
t->pbs_multi = &multi_rb_ops;
t->pbs_region = &region_rb_ops;
t->pbs_set = &set_rb_ops;
}
}
#endif
return 0;
}
void
bus_space_mallocok(void)
{
extent_flags = EX_MALLOCOK;
}
/* ARGSUSED */
paddr_t
memio_mmap(bus_space_tag_t t, bus_addr_t bpa, off_t offset, int prot, int flags)
{
return (trunc_page(bpa + offset));
}
int
memio_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size, int flags,
bus_space_handle_t *bshp)
{
int error;
paddr_t pa;
size = _BUS_SPACE_STRIDE(t, size);
if (bpa + size > t->pbs_limit)
return (EINVAL);
/*
* Can't map I/O space as linear.
*/
if ((flags & BUS_SPACE_MAP_LINEAR) &&
(t->pbs_flags & _BUS_SPACE_IO_TYPE))
return (EOPNOTSUPP);
/*
* Before we go any further, let's make sure that this
* region is available.
*/
error = extent_alloc_region(t->pbs_extent, bpa, size,
EX_NOWAIT | extent_flags);
if (error)
return (error);
pa = t->pbs_offset + bpa;
#ifdef PPC_OEA
{
/*
* Let's try to BAT map this address if possible
*/
register_t batu = battable[pa >> ADDR_SR_SHFT].batu;
if (BAT_VALID_P(batu, 0) && BAT_VA_MATCH_P(batu, pa) &&
BAT_VA_MATCH_P(batu, pa + size - 1)) {
*bshp = pa;
return (0);
}
}
#endif
if (extent_flags == 0) {
extent_free(t->pbs_extent, bpa, size, EX_NOWAIT);
return (ENOMEM);
}
/*
* Map this into the kernel pmap.
*/
*bshp = (bus_space_handle_t) mapiodev(pa, size);
if (*bshp == 0) {
extent_free(t->pbs_extent, bpa, size, EX_NOWAIT | extent_flags);
return (ENOMEM);
}
return (0);
}
int
memio_subregion(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t offset,
bus_size_t size, bus_space_handle_t *bshp)
{
*bshp = bsh + _BUS_SPACE_STRIDE(t, offset);
return (0);
}
void
memio_unmap(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t size)
{
bus_addr_t bpa;
vaddr_t va = bsh;
paddr_t pa;
size = _BUS_SPACE_STRIDE(t, size);
#ifdef PPC_OEA
{
register_t batu = battable[va >> ADDR_SR_SHFT].batu;
if (BAT_VALID_P(batu, 0) && BAT_VA_MATCH_P(batu, va) &&
BAT_VA_MATCH_P(batu, va + size - 1)) {
pa = va;
} else {
pmap_extract(pmap_kernel(), va, &pa);
}
}
#else
pmap_extract(pmap_kernel(), va, &pa);
#endif
bpa = pa - t->pbs_offset;
if (extent_free(t->pbs_extent, bpa, size, EX_NOWAIT | extent_flags)) {
printf("memio_unmap: %s 0x%lx, size 0x%lx\n",
(t->pbs_flags & _BUS_SPACE_IO_TYPE) ? "port" : "mem",
(unsigned long)bpa, (unsigned long)size);
printf("memio_unmap: can't free region\n");
}
}
int
memio_alloc(bus_space_tag_t t, bus_addr_t rstart, bus_addr_t rend,
bus_size_t size, bus_size_t alignment, bus_size_t boundary,
int flags, bus_addr_t *bpap, bus_space_handle_t *bshp)
{
u_long bpa;
paddr_t pa;
int error;
size = _BUS_SPACE_STRIDE(t, size);
if (rstart + size > t->pbs_limit)
return (EINVAL);
/*
* Can't map I/O space as linear.
*/
if ((flags & BUS_SPACE_MAP_LINEAR) &&
(t->pbs_flags & _BUS_SPACE_IO_TYPE))
return (EOPNOTSUPP);
if (rstart < t->pbs_extent->ex_start || rend > t->pbs_extent->ex_end)
panic("memio_alloc: bad region start/end");
error = extent_alloc_subregion(t->pbs_extent, rstart, rend, size,
alignment, boundary, EX_FAST | EX_NOWAIT | extent_flags, &bpa);
if (error)
return (error);
*bpap = bpa;
pa = t->pbs_offset + bpa;
#ifdef PPC_OEA
{
register_t batu = battable[pa >> ADDR_SR_SHFT].batu;
if (BAT_VALID_P(batu, 0) && BAT_VA_MATCH_P(batu, pa) &&
BAT_VA_MATCH_P(batu, pa + size - 1)) {
*bshp = pa;
return (0);
}
}
#endif
*bshp = (bus_space_handle_t) mapiodev(pa, size);
if (*bshp == 0) {
extent_free(t->pbs_extent, bpa, size, EX_NOWAIT | extent_flags);
return (ENOMEM);
}
return (0);
}
void
memio_free(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t size)
{
/* memio_unmap() does all that we need to do. */
memio_unmap(t, bsh, size);
}

View File

@ -0,0 +1,793 @@
/* $NetBSD: pio_subr.S,v 1.1 2003/03/15 08:03:19 matt Exp $ */
/*
* Copyright (c) 2003 Matt Thomas
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
/*
* Assembly note:
* We use rotlw instead of slw because rotlw ignores bit 26 and slw
* doesn't. However, this may make the high bits of the offset rotate
* in the low bits but if that happens then the offset was too large
* to being with.
*/
#ifdef DEBUG
#define DBGSYNC sync
#else
#define DBGSYNC /* nothing */
#endif
/* LINTSTUB: include <sys/param.h> */
/* LINTSTUB: include <sys/types.h> */
/* LINTSTUB: include <machine/bus.h> */
/* LINTSTUB: Func: void out8(volatile u_int8_t *a, u_int8_t v) */
ENTRY_NOPROFILE(out8)
stbx 4,0,3
eieio /* memory barrier (reorder protection) */
DBGSYNC /* force exceptions */
blr /* return */
/* LINTSTUB: Func: void bsw1_s(bus_space_tag_t t, bus_addr_t h, bus_size_t o, u_int8_t v) */
/* LINTSTUB: Func: void bsw1(bus_space_tag_t t, bus_addr_t h, bus_size_t o, u_int8_t v) */
ENTRY_NOPROFILE(bsw1_s)
lwz 0,0(3) /* get log2(stride) */
rotlw 5,5,0 /* shift offset */
ENTRY_NOPROFILE(bsw1)
stbx 6,4,5 /* store value */
eieio /* memory barrier (reorder protection) */
DBGSYNC /* force exceptions */
blr /* return */
/* LINTSTUB: Func: void out16(volatile u_int16_t *a, u_int16_t v) */
ENTRY_NOPROFILE(out16)
sth 4,0(3)
eieio /* memory barrier (reorder protection) */
DBGSYNC /* force exceptions */
blr /* return */
/* LINTSTUB: Func: void bsw2_s(bus_space_tag_t t, bus_addr_t h, bus_size_t o, u_int16_t v) */
/* LINTSTUB: Func: void bsw2(bus_space_tag_t t, bus_addr_t h, bus_size_t o, u_int16_t v) */
ENTRY_NOPROFILE(bsw2_s)
lwz 0,0(3) /* get log2(stride) */
rotlw 5,5,0 /* shift offset */
ENTRY_NOPROFILE(bsw2)
sthx 6,4,5 /* store value */
eieio /* memory barrier (reorder protection) */
DBGSYNC /* force exceptions */
blr /* return */
/* LINTSTUB: Func: void out32(volatile u_int32_t *a, u_int32_t v) */
ENTRY_NOPROFILE(out32)
stw 4,0(3)
eieio /* memory barrier (reorder protection) */
DBGSYNC /* force exceptions */
blr /* return */
/* LINTSTUB: Func: void bsw4_s(bus_space_tag_t t, bus_addr_t h, bus_size_t o, u_int32_t v) */
/* LINTSTUB: Func: void bsw4(bus_space_tag_t t, bus_addr_t h, bus_size_t o, u_int32_t v) */
ENTRY_NOPROFILE(bsw4_s)
lwz 0,0(3) /* get log2(stride) */
rotlw 5,5,0 /* shift offset */
ENTRY_NOPROFILE(bsw4)
stwx 6,4,5 /* store value */
eieio /* memory barrier (reorder protection) */
DBGSYNC /* force exceptions */
blr /* return */
/* LINTSTUB: Func: void bsw8_s(bus_space_tag_t t, bus_addr_t h, bus_size_t o, u_int64_t v) */
/* LINTSTUB: Func: void bsw8(bus_space_tag_t t, bus_addr_t h, bus_size_t o, u_int64_t v) */
ENTRY_NOPROFILE(bsw8_s)
lwz 0,0(3) /* get log2(stride) */
rotlw 5,5,0 /* shift offset */
ENTRY_NOPROFILE(bsw8)
#ifdef __ARCH64__
stdx 6,4,5 /* store value */
#else
trap /* die */
#endif
eieio /* memory barrier (reorder protection) */
DBGSYNC /* force exceptions */
blr /* return */
/* LINTSTUB: Func: void out16rb(volatile u_int16_t *a, u_int16_t v) */
ENTRY_NOPROFILE(out16rb)
sthbrx 4,0,3
eieio /* memory barrier (reorder protection) */
DBGSYNC /* force exceptions */
blr /* return */
/* LINTSTUB: Func: void bsw2rb_s(bus_space_tag_t t, bus_addr_t h, bus_size_t o, u_int16_t v) */
/* LINTSTUB: Func: void bsw2rb(bus_space_tag_t t, bus_addr_t h, bus_size_t o, u_int16_t v) */
ENTRY_NOPROFILE(bsw2rb_s)
lwz 0,0(3) /* get log2(stride) */
rotlw 5,5,0 /* shift offset */
ENTRY_NOPROFILE(bsw2rb)
sthbrx 6,4,5 /* store value */
eieio /* memory barrier (reorder protection) */
DBGSYNC /* force exceptions */
blr /* return */
/* LINTSTUB: Func: void out32rb(volatile u_int32_t *a, u_int32_t v) */
ENTRY_NOPROFILE(out32rb)
stwbrx 4,0,3
eieio /* memory barrier (reorder protection) */
DBGSYNC /* force exceptions */
blr /* return */
/* LINTSTUB: Func: void bsw4rb_s(bus_space_tag_t t, bus_addr_t h, bus_size_t o, u_int32_t v) */
/* LINTSTUB: Func: void bsw4rb(bus_space_tag_t t, bus_addr_t h, bus_size_t o, u_int32_t v) */
ENTRY_NOPROFILE(bsw4rb_s)
lwz 0,0(3) /* get log2(stride) */
rotlw 5,5,0 /* shift offset */
ENTRY_NOPROFILE(bsw4rb)
stwbrx 6,4,5 /* store value */
eieio /* memory barrier (reorder protection) */
DBGSYNC /* force exceptions */
blr /* return */
/* LINTSTUB: Func: void bsw8rb_s(bus_space_tag_t t, bus_addr_t h, bus_size_t o, u_int32_t v) */
/* LINTSTUB: Func: void bsw8rb(bus_space_tag_t t, bus_addr_t h, bus_size_t o, u_int32_t v) */
ENTRY_NOPROFILE(bsw8rb_s)
lwz 0,0(3) /* get log2(stride) */
rotlw 5,5,0 /* shift offset */
ENTRY_NOPROFILE(bsw8rb)
#ifdef __ARCH64__
stdbrx 6,4,5 /* store value */
#else
trap /* die */
#endif
eieio /* memory barrier (reorder protection) */
DBGSYNC /* force exceptions */
blr /* return */
/* LINTSTUB: Func: int in8(const volatile u_int8_t *a) */
ENTRY_NOPROFILE(in8)
lbz 3,0(3)
eieio /* memory barrier (reorder protection) */
DBGSYNC /* force exceptions */
blr /* return */
/* LINTSTUB: Func: int bsr1_s(bus_space_tag_t t, bus_addr_t h, bus_size_t o) */
/* LINTSTUB: Func: int bsr1(bus_space_tag_t t, bus_addr_t h, bus_size_t o) */
ENTRY_NOPROFILE(bsr1_s)
lwz 0,0(3) /* get log2(stride) */
rotlw 5,5,0 /* shift offset */
ENTRY_NOPROFILE(bsr1)
lbzx 3,4,5 /* load value */
eieio /* memory barrier (reorder protection) */
DBGSYNC /* force exceptions */
blr /* return */
/* LINTSTUB: Func: int in16(const volatile u_int16_t *a) */
ENTRY_NOPROFILE(in16)
lhz 3,0(3)
eieio /* memory barrier (reorder protection) */
DBGSYNC /* force exceptions */
blr /* return */
/* LINTSTUB: Func: int bsr2_s(bus_space_tag_t t, bus_addr_t h, bus_size_t o) */
/* LINTSTUB: Func: int bsr2(bus_space_tag_t t, bus_addr_t h, bus_size_t o) */
ENTRY_NOPROFILE(bsr2_s)
lwz 0,0(3) /* get log2(stride) */
rotlw 5,5,0 /* shift offset */
ENTRY_NOPROFILE(bsr2)
lhzx 3,4,5 /* load value */
eieio /* memory barrier (reorder protection) */
DBGSYNC /* force exceptions */
blr /* return */
/* LINTSTUB: Func: int in32(const volatile u_int32_t *a) */
ENTRY_NOPROFILE(in32)
lwz 3,0(3)
eieio /* memory barrier (reorder protection) */
DBGSYNC /* force exceptions */
blr /* return */
/* LINTSTUB: Func: int bsr4_s(bus_space_tag_t t, bus_addr_t h, bus_size_t o) */
/* LINTSTUB: Func: int bsr4(bus_space_tag_t t, bus_addr_t h, bus_size_t o) */
ENTRY_NOPROFILE(bsr4_s)
lwz 0,0(3) /* get log2(stride) */
rotlw 5,5,0 /* shift offset */
ENTRY_NOPROFILE(bsr4)
lwzx 3,4,5 /* load value */
eieio /* memory barrier (reorder protection) */
DBGSYNC /* force exceptions */
blr /* return */
/* LINTSTUB: Func: int bsr8_s(bus_space_tag_t t, bus_addr_t h, bus_size_t o) */
/* LINTSTUB: Func: int bsr8(bus_space_tag_t t, bus_addr_t h, bus_size_t o) */
ENTRY_NOPROFILE(bsr8_s)
lwz 0,0(3) /* get log2(stride) */
rotlw 5,5,0 /* shift offset */
ENTRY_NOPROFILE(bsr8)
#ifdef __ARCH64__
lwdx 3,4,5 /* load value */
#else
trap
#endif
eieio /* memory barrier (reorder protection) */
DBGSYNC /* force exceptions */
blr /* return */
/* LINTSTUB: Func: int in16rb(const volatile u_int16_t *a) */
ENTRY_NOPROFILE(in16rb)
lhbrx 3,0,3
eieio /* memory barrier (reorder protection) */
DBGSYNC /* force exceptions */
blr /* return */
/* LINTSTUB: Func: int bsr2rb_s(bus_space_tag_t t, bus_addr_t h, bus_size_t o) */
/* LINTSTUB: Func: int bsr2rb(bus_space_tag_t t, bus_addr_t h, bus_size_t o) */
ENTRY_NOPROFILE(bsr2rb_s)
lwz 0,0(3) /* get log2(stride) */
rotlw 5,5,0 /* shift offset */
ENTRY_NOPROFILE(bsr2rb)
lhbrx 3,4,5 /* load value */
eieio /* memory barrier (reorder protection) */
DBGSYNC /* force exceptions */
blr /* return */
/* LINTSTUB: Func: int in32rb(const volatile u_int32_t *a) */
ENTRY_NOPROFILE(in32rb)
lwbrx 3,0,3
eieio /* memory barrier (reorder protection) */
DBGSYNC /* force exceptions */
blr /* return */
/* LINTSTUB: Func: int bsr4rb_s(bus_space_tag_t t, bus_addr_t h, bus_size_t o) */
/* LINTSTUB: Func: int bsr4rb(bus_space_tag_t t, bus_addr_t h, bus_size_t o) */
ENTRY_NOPROFILE(bsr4rb_s)
lwz 0,0(3) /* get log2(stride) */
rotlw 5,5,0 /* shift offset */
ENTRY_NOPROFILE(bsr4rb)
lwbrx 3,4,5 /* load value */
eieio /* memory barrier (reorder protection) */
DBGSYNC /* force exceptions */
blr /* return */
/* LINTSTUB: Func: int bsr8rb_s(bus_space_tag_t t, bus_addr_t h, bus_size_t o) */
/* LINTSTUB: Func: int bsr8rb(bus_space_tag_t t, bus_addr_t h, bus_size_t o) */
ENTRY_NOPROFILE(bsr8rb_s)
lwz 0,0(3) /* get log2(stride) */
rotlw 5,5,0 /* shift offset */
ENTRY_NOPROFILE(bsr8rb)
#ifdef __ARCH64__
ldbrx 3,4,5 /* load value */
#else
trap
#endif
eieio /* memory barrier (reorder protection) */
DBGSYNC /* force exceptions */
blr /* return */
/* LINTSTUB: Func: void bswm1_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int8_t *addr, size_t len) */
/* LINTSTUB: Func: void bswm1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int8_t *addr, size_t len) */
/* LINTSTUB: Func: void outs8(volatile u_int8_t *dst, const u_int8_t *src, size_t len) */
ENTRY_NOPROFILE(bswm1_s)
lwz 0,0(3) /* get log2(stride) */
rotlw 5,5,0 /* shift offset */
ENTRY_NOPROFILE(bswm1)
add 3,4,5 /* add offset to handle & place in argument 0 */
mr 4,6 /* move addr to argument 1 register */
mr 5,7 /* move count to argument 2 register */
ENTRY_NOPROFILE(outs8)
cmpwi 5,0 /* len == 0? */
beqlr- /* return if len == 0 */
addi 5,5,-1 /* len -= 1 */
addi 5,5,4 /* len += src */
addi 4,4,-1 /* pre-decrement */
1: lbzu 0,1(4) /* load and increment */
stb 0,0(3) /* store */
cmpl 0,4,5 /* at the end? */
bne+ 1b /* nope, do another pass */
eieio /* memory barrier (reorder protection) */
DBGSYNC /* force exceptions */
blr /* return */
/* LINTSTUB: Func: void bswm2_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int16_t *addr, size_t len) */
/* LINTSTUB: Func: void bswm2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int16_t *addr, size_t len) */
/* LINTSTUB: Func: void outs16(volatile u_int16_t *dst, const u_int16_t *src, size_t len) */
ENTRY_NOPROFILE(bswm2_s)
lwz 0,0(3) /* get log2(stride) */
rotlw 5,5,0 /* shift offset */
ENTRY_NOPROFILE(bswm2)
add 3,4,5 /* add offset to handle & place in argument 0 */
mr 4,6 /* move addr to argument 1 register */
mr 5,7 /* move count to argument 2 register */
ENTRY_NOPROFILE(outs16)
cmpwi 5,0 /* len == 0? */
beqlr- /* return if len == 0 */
addi 5,5,-1 /* len -= 1 */
slwi 5,5,1 /* len *= 2 */
addi 5,5,4 /* len += src */
addi 4,4,-2 /* pre-decrement */
1: lhzu 0,2(4) /* load and increment */
sth 0,0(3) /* store */
cmpl 0,4,5 /* at the end? */
bne+ 1b /* nope, do another pass */
eieio /* memory barrier (reorder protection) */
DBGSYNC /* force exceptions */
blr /* return */
/* LINTSTUB: Func: void bswm4_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int32_t *addr, size_t len) */
/* LINTSTUB: Func: void bswm4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int32_t *addr, size_t len) */
/* LINTSTUB: Func: void outs32(volatile u_int32_t *dst, const u_int32_t *src, size_t len) */
ENTRY_NOPROFILE(bswm4_s)
lwz 0,0(3) /* get log2(stride) */
rotlw 5,5,0 /* shift offset */
ENTRY_NOPROFILE(bswm4)
add 3,4,5 /* add offset to handle & place in argument 0 */
mr 4,6 /* move addr to argument 1 register */
mr 5,7 /* move count to argument 2 register */
ENTRY_NOPROFILE(outs32)
cmpwi 5,0 /* len == 0? */
beqlr- /* return if len == 0 */
addi 5,5,-1 /* len -= 1 */
slwi 5,5,2 /* len *= 4 */
addi 5,5,4 /* len += src */
addi 4,4,-4 /* pre-decrement */
1: lwzu 0,4(4) /* load and increment */
stw 0,0(3) /* store */
cmpl 0,4,5 /* at the end? */
bne+ 1b /* nope, do another pass */
eieio /* memory barrier (reorder protection) */
DBGSYNC /* force exceptions */
blr /* return */
/* LINTSTUB: Func: void bswm8_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int64_t *addr, size_t len) */
/* LINTSTUB: Func: void bswm8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int64_t *addr, size_t len) */
#ifdef _LP64
ENTRY_NOPROFILE(bswm8_s)
ld 0,0(3) /* get log2(stride) */
rotld 5,5,0 /* shift offset */
ENTRY_NOPROFILE(bswm8)
add 3,4,5 /* add offset to handle & place in argument 0 */
mr 4,6 /* move addr to argument 1 register */
mr 5,7 /* move count to argument 2 register */
ENTRY_NOPROFILE(outs32)
cmpdi 5,0 /* len == 0? */
beqlr- /* return if len == 0 */
addi 5,5,-1 /* len -= 1 */
sldi 5,5,2 /* len *= 4 */
addi 5,5,4 /* len += src */
addi 4,4,-4 /* pre-decrement */
1: ldzu 0,4(4) /* load and increment */
std 0,0(3) /* store */
cmpl 0,4,5 /* at the end? */
bne+ 1b /* nope, do another pass */
eieio /* memory barrier (reorder protection) */
DBGSYNC /* force exceptions */
blr /* return */
#else
ENTRY_NOPROFILE(bswm8_s)
ENTRY_NOPROFILE(bswm8)
trap /* die */
#endif
/* LINTSTUB: Func: void bswm2rb_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int16_t *addr, size_t len) */
/* LINTSTUB: Func: void bswm2rb(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int16_t *addr, size_t len) */
/* LINTSTUB: Func: void outs16rb(volatile u_int16_t *dst, const u_int16_t *src, size_t len) */
ENTRY_NOPROFILE(bswm2rb_s)
lwz 0,0(3) /* get log2(stride) */
rotlw 5,5,0 /* shift offset */
ENTRY_NOPROFILE(bswm2rb)
add 3,4,5 /* add offset to handle & place in argument 0 */
mr 4,6 /* move addr to argument 1 register */
mr 5,7 /* move count to argument 2 register */
ENTRY_NOPROFILE(outs16rb)
cmpwi 5,0 /* len == 0? */
beqlr- /* return if len == 0 */
addi 5,5,-1 /* len -= 1 */
slwi 5,5,1 /* len *= 2 */
addi 5,5,4 /* len += src */
addi 4,4,-2 /* pre-decrement */
1: lwzu 0,2(4) /* load and increment */
sthbrx 0,0,3 /* store (byte-reversed) */
cmpl 0,4,5 /* at the end? */
bne+ 1b /* nope, do another pass */
eieio /* memory barrier (reorder protection) */
DBGSYNC /* force exceptions */
blr /* return */
/* LINTSTUB: Func: void bswm4rb_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int32_t *addr, size_t len) */
/* LINTSTUB: Func: void bswm4rb(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int32_t *addr, size_t len) */
/* LINTSTUB: Func: void outs32rb(volatile u_int32_t *dst, const u_int32_t *src, size_t len) */
ENTRY_NOPROFILE(bswm4rb_s)
lwz 0,0(3) /* get log2(stride) */
rotlw 5,5,0 /* shift offset */
ENTRY_NOPROFILE(bswm4rb)
add 3,4,5 /* add offset to handle & place in argument 0 */
mr 4,6 /* move addr to argument 1 register */
mr 5,7 /* move count to argument 2 register */
ENTRY_NOPROFILE(outs32rb)
cmpwi 5,0 /* len == 0? */
beqlr- /* return if len == 0 */
addi 5,5,-1 /* len -= 1 */
slwi 5,5,2 /* len *= 4 */
addi 5,5,4 /* len += src */
addi 4,4,-4 /* pre-decrement */
1: lwzu 0,4(4) /* load and increment */
stwbrx 0,0,3 /* store (byte-reversed) */
cmpl 0,4,5 /* at the end? */
bne+ 1b /* nope, do another pass */
eieio /* memory barrier (reorder protection) */
DBGSYNC /* force exceptions */
blr /* return */
/* LINTSTUB: Func: void bswm8rb_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int32_t *addr, size_t len) */
/* LINTSTUB: Func: void bswm8rb(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int32_t *addr, size_t len) */
ENTRY_NOPROFILE(bswm8rb_s)
ENTRY_NOPROFILE(bswm8rb)
trap
/* LINTSTUB: Func: void bsrm1_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, u_int8_t *addr, size_t len) */
/* LINTSTUB: Func: void bsrm1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, u_int8_t *addr, size_t len) */
/* LINTSTUB: Func: void ins8(const volatile u_int8_t *src, u_int8_t *dst, size_t len) */
ENTRY_NOPROFILE(bsrm1_s)
lwz 0,0(3) /* get log2(stride) */
rotlw 5,5,0 /* shift offset */
ENTRY_NOPROFILE(bsrm1)
add 3,4,5 /* add offset to handle & place in argument 0 */
mr 4,6 /* move addr to argument 1 register */
mr 5,7 /* move count to argument 2 register */
ENTRY_NOPROFILE(ins8)
cmpwi 5,0 /* len == 0? */
beqlr- /* return if len == 0 */
addi 5,5,-1 /* len -= 1 */
addi 5,5,4 /* len += src */
addi 4,4,-1 /* pre-decrement */
1: lbz 0,0(3) /* load value */
stbu 0,1(4) /* store and increment */
cmpl 0,4,5 /* at the end? */
bne+ 1b /* nope, do another pass */
eieio /* memory barrier (reorder protection) */
DBGSYNC /* force exceptions */
blr /* return */
/* LINTSTUB: Func: void bsrm2_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, u_int16_t *addr, size_t len) */
/* LINTSTUB: Func: void bsrm2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, u_int16_t *addr, size_t len) */
/* LINTSTUB: Func: void ins16(const volatile u_int16_t *src, u_int16_t *dst, size_t len) */
ENTRY_NOPROFILE(bsrm2_s)
lwz 0,0(3) /* get log2(stride) */
rotlw 5,5,0 /* shift offset */
ENTRY_NOPROFILE(bsrm2)
add 3,4,5 /* add offset to handle & place in argument 0 */
mr 4,6 /* move addr to argument 1 register */
mr 5,7 /* move count to argument 2 register */
ENTRY_NOPROFILE(ins16)
cmpwi 5,0 /* len == 0? */
beqlr- /* return if len == 0 */
addi 5,5,-1 /* len -= 1 */
slwi 5,5,1 /* len *= 2 */
addi 5,5,4 /* len += src */
addi 4,4,-2 /* pre-decrement */
1: lhz 0,0(3) /* load value */
sthu 0,2(4) /* store and increment */
cmpl 0,4,5 /* at the end? */
bne+ 1b /* nope, do another pass */
eieio /* memory barrier (reorder protection) */
DBGSYNC /* force exceptions */
blr /* return */
/* LINTSTUB: Func: void bsrm4_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, u_int32_t *addr, size_t len) */
/* LINTSTUB: Func: void bsrm4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, u_int32_t *addr, size_t len) */
/* LINTSTUB: Func: void ins32(const volatile u_int32_t *src, u_int32_t *dst, size_t len) */
ENTRY_NOPROFILE(bsrm4_s)
lwz 0,0(3) /* get log2(stride) */
rotlw 5,5,0 /* shift offset */
ENTRY_NOPROFILE(bsrm4)
add 3,4,5 /* add offset to handle & place in argument 0 */
mr 4,6 /* move addr to argument 1 register */
mr 5,7 /* move count to argument 2 register */
ENTRY_NOPROFILE(ins32)
cmpwi 5,0 /* len == 0? */
beqlr- /* return if len == 0 */
addi 5,5,-1 /* len -= 1 */
slwi 5,5,2 /* len *= 4 */
addi 5,5,4 /* len += src */
addi 4,4,-4 /* pre-decrement */
1: lwz 0,0(3) /* load value */
stwu 0,4(4) /* store and increment */
cmpl 0,4,5 /* at the end? */
bne+ 1b /* nope, do another pass */
eieio /* memory barrier (reorder protection) */
DBGSYNC /* force exceptions */
blr /* return */
/* LINTSTUB: Func: void bsrm8_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, u_int64_t *addr, size_t len) */
/* LINTSTUB: Func: void bsrm8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, u_int64_t *addr, size_t len) */
ENTRY_NOPROFILE(bsrm8_s)
ENTRY_NOPROFILE(bsrm8)
trap
/* LINTSTUB: Func: void bsrm2rb(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, u_int16_t *addr, size_t len) */
/* LINTSTUB: Func: void ins16rb(const volatile u_int16_t *src, u_int16_t *dst, size_t len) */
ENTRY_NOPROFILE(bsrm2rb_s)
lwz 0,0(3) /* get log2(stride) */
rotlw 5,5,0 /* shift offset */
ENTRY_NOPROFILE(bsrm2rb)
add 3,4,5 /* add offset to handle & place in argument 0 */
mr 4,6 /* move addr to argument 1 register */
mr 5,7 /* move count to argument 2 register */
ENTRY_NOPROFILE(ins16rb)
cmpwi 5,0 /* len == 0? */
beqlr- /* return if len == 0 */
addi 5,5,-1 /* len -= 1 */
slwi 5,5,1 /* len *= 2 */
addi 5,5,4 /* len += src */
addi 4,4,-2 /* pre-decrement */
1: lhbrx 0,0,3 /* load value (byte reversed) */
sthu 0,2(4) /* store and increment */
cmpl 0,4,5 /* at the end? */
bne+ 1b /* nope, do another pass */
eieio /* memory barrier (reorder protection) */
DBGSYNC /* force exceptions */
blr /* return */
/* LINTSTUB: Func: void bsrm4rb_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, u_int32_t *addr, size_t len) */
/* LINTSTUB: Func: void bsrm4rb(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, u_int32_t *addr, size_t len) */
/* LINTSTUB: Func: void ins32rb(const volatile u_int32_t *src, u_int32_t *dst, size_t len) */
ENTRY_NOPROFILE(bsrm4rb_s)
lwz 0,0(3) /* get log2(stride) */
rotlw 5,5,0 /* shift offset */
ENTRY_NOPROFILE(bsrm4rb)
add 3,4,5 /* add offset to handle & place in argument 0 */
mr 4,6 /* move addr to argument 1 register */
mr 5,7 /* move count to argument 2 register */
ENTRY_NOPROFILE(ins32rb)
cmpwi 5,0 /* len == 0? */
beqlr- /* return if len == 0 */
addi 5,5,-1 /* len -= 1 */
slwi 5,5,2 /* len *= 4 */
addi 5,5,4 /* len += src */
addi 4,4,-4 /* pre-decrement */
1: lwbrx 0,0,3 /* load value (byte reversed) */
stwu 0,4(4) /* store and increment */
cmpl 0,4,5 /* at the end? */
bne+ 1b /* nope, do another pass */
eieio /* memory barrier (reorder protection) */
DBGSYNC /* force exceptions */
blr /* return */
/* LINTSTUB: Func: void bsrm8rb_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, u_int64_t *addr, size_t len) */
/* LINTSTUB: Func: void bsrm8rb(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, u_int64_t *addr, size_t len) */
ENTRY_NOPROFILE(bsrm8rb_s)
ENTRY_NOPROFILE(bsrm8rb)
trap
/* LINTSTUB: Func: void bswr1_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int8_t *a, size_t c); */
/* LINTSTUB: Func: void bswr1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int8_t *a, size_t c); */
/* LINTSTUB: Func: void bswr1rb_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int8_t *a, size_t c); */
/* LINTSTUB: Func: void bswr1rb(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int8_t *a, size_t c); */
ENTRY_NOPROFILE(bswr1_s)
ENTRY_NOPROFILE(bswr1rb_s)
lwz 0,0(3)
rotlw 5,5,0
ENTRY_NOPROFILE(bswr1)
ENTRY_NOPROFILE(bswr1rb)
trap
/* LINTSTUB: Func: void bswr2_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int16_t *a, size_t c); */
/* LINTSTUB: Func: void bswr2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int16_t *a, size_t c); */
/* LINTSTUB: Func: void bswr2rb_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int16_t *a, size_t c); */
/* LINTSTUB: Func: void bswr2rb(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int16_t *a, size_t c); */
ENTRY_NOPROFILE(bswr2_s)
ENTRY_NOPROFILE(bswr2rb_s)
lwz 0,0(3)
rotlw 5,5,0
ENTRY_NOPROFILE(bswr2)
ENTRY_NOPROFILE(bswr2rb)
trap
/* LINTSTUB: Func: void bswr4_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int32_t *a, size_t c); */
/* LINTSTUB: Func: void bswr4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int32_t *a, size_t c); */
/* LINTSTUB: Func: void bswr4rb_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int32_t *a, size_t c); */
/* LINTSTUB: Func: void bswr4rb(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int32_t *a, size_t c); */
ENTRY_NOPROFILE(bswr4_s)
ENTRY_NOPROFILE(bswr4rb_s)
lwz 0,0(3)
rotlw 5,5,0
ENTRY_NOPROFILE(bswr4)
ENTRY_NOPROFILE(bswr4rb)
trap
/* LINTSTUB: Func: void bswr8_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int64_t *a, size_t c); */
/* LINTSTUB: Func: void bswr8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int64_t *a, size_t c); */
/* LINTSTUB: Func: void bswr8rb_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int64_t *a, size_t c); */
/* LINTSTUB: Func: void bswr8rb(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int64_t *a, size_t c); */
ENTRY_NOPROFILE(bswr8_s)
ENTRY_NOPROFILE(bswr8rb_s)
lwz 0,0(3)
rotlw 5,5,0
ENTRY_NOPROFILE(bswr8)
ENTRY_NOPROFILE(bswr8rb)
trap
/* LINTSTUB: Func: void bsrr1_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, u_int8_t *a, size_t c); */
/* LINTSTUB: Func: void bsrr1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, u_int8_t *a, size_t c); */
/* LINTSTUB: Func: void bsrr1rb_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, u_int8_t *a, size_t c); */
/* LINTSTUB: Func: void bsrr1rb(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, u_int8_t *a, size_t c); */
ENTRY_NOPROFILE(bsrr1_s)
ENTRY_NOPROFILE(bsrr1rb_s)
lwz 0,0(3)
rotlw 5,5,0
ENTRY_NOPROFILE(bsrr1)
ENTRY_NOPROFILE(bsrr1rb)
trap
/* LINTSTUB: Func: void bsrr2_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, u_int16_t *a, size_t c); */
/* LINTSTUB: Func: void bsrr2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, u_int16_t *a, size_t c); */
/* LINTSTUB: Func: void bsrr2rb_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, u_int16_t *a, size_t c); */
/* LINTSTUB: Func: void bsrr2rb(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, u_int16_t *a, size_t c); */
ENTRY_NOPROFILE(bsrr2_s)
ENTRY_NOPROFILE(bsrr2rb_s)
lwz 0,0(3)
rotlw 5,5,0
ENTRY_NOPROFILE(bsrr2)
ENTRY_NOPROFILE(bsrr2rb)
trap
/* LINTSTUB: Func: void bsrr4_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, u_int32_t *a, size_t c); */
/* LINTSTUB: Func: void bsrr4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, u_int32_t *a, size_t c); */
/* LINTSTUB: Func: void bsrr4rb_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, u_int32_t *a, size_t c); */
/* LINTSTUB: Func: void bsrr4rb(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, u_int32_t *a, size_t c); */
ENTRY_NOPROFILE(bsrr4_s)
ENTRY_NOPROFILE(bsrr4rb_s)
lwz 0,0(3)
rotlw 5,5,0
ENTRY_NOPROFILE(bsrr4)
ENTRY_NOPROFILE(bsrr4rb)
trap
/* LINTSTUB: Func: void bsrr8_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, u_int64_t *a, size_t c); */
/* LINTSTUB: Func: void bsrr8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, u_int64_t *a, size_t c); */
/* LINTSTUB: Func: void bsrr8rb_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, u_int64_t *a, size_t c); */
/* LINTSTUB: Func: void bsrr8rb(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, u_int64_t *a, size_t c); */
ENTRY_NOPROFILE(bsrr8_s)
ENTRY_NOPROFILE(bsrr8rb_s)
lwz 0,0(3)
rotlw 5,5,0
ENTRY_NOPROFILE(bsrr8)
ENTRY_NOPROFILE(bsrr8rb)
trap
/* LINTSTUB: Func: void bssr1_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, u_int8_t v); */
/* LINTSTUB: Func: void bssr1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, u_int8_t v); */
/* LINTSTUB: Func: void bssr1rb_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, u_int8_t v); */
/* LINTSTUB: Func: void bssr1rb(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, u_int8_t v); */
ENTRY_NOPROFILE(bssr1_s)
ENTRY_NOPROFILE(bssr1rb_s)
lwz 0,0(3)
rotlw 5,5,0
ENTRY_NOPROFILE(bssr1)
ENTRY_NOPROFILE(bssr1rb)
trap
/* LINTSTUB: Func: void bssr2_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int16_t v); */
/* LINTSTUB: Func: void bssr2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int16_t v); */
/* LINTSTUB: Func: void bssr2rb_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int16_t v); */
/* LINTSTUB: Func: void bssr2rb(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int16_t v); */
ENTRY_NOPROFILE(bssr2_s)
ENTRY_NOPROFILE(bssr2rb_s)
lwz 0,0(3)
rotlw 5,5,0
ENTRY_NOPROFILE(bssr2)
ENTRY_NOPROFILE(bssr2rb)
trap
/* LINTSTUB: Func: void bssr4_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int32_t v); */
/* LINTSTUB: Func: void bssr4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int32_t v); */
/* LINTSTUB: Func: void bssr4rb_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int32_t v); */
/* LINTSTUB: Func: void bssr4rb(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int32_t v); */
ENTRY_NOPROFILE(bssr4_s)
ENTRY_NOPROFILE(bssr4rb_s)
lwz 0,0(3)
rotlw 5,5,0
ENTRY_NOPROFILE(bssr4)
ENTRY_NOPROFILE(bssr4rb)
trap
/* LINTSTUB: Func: void bssr8_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int64_t v); */
/* LINTSTUB: Func: void bssr8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int64_t v); */
/* LINTSTUB: Func: void bssr8rb_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int64_t v); */
/* LINTSTUB: Func: void bssr8rb(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, const u_int64_t v); */
ENTRY_NOPROFILE(bssr8_s)
ENTRY_NOPROFILE(bssr8rb_s)
lwz 0,0(3)
rotlw 5,5,0
ENTRY_NOPROFILE(bssr8)
ENTRY_NOPROFILE(bssr8rb)
trap
/* LINTSTUB: Func: void bscr1_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, bus_space_handle_t h2, bus_size_t o2, size_t len); */
/* LINTSTUB: Func: void bscr1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, bus_space_handle_t h2, bus_size_t o2, size_t len); */
ENTRY_NOPROFILE(bscr1_s)
lwz 0,0(3)
rotlw 5,5,0
ENTRY_NOPROFILE(bscr1)
trap
/* LINTSTUB: Func: void bscr2_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, bus_space_handle_t h2, bus_size_t o2, size_t len); */
/* LINTSTUB: Func: void bscr2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, bus_space_handle_t h2, bus_size_t o2, size_t len); */
ENTRY_NOPROFILE(bscr2_s)
lwz 0,0(3)
rotlw 5,5,0
ENTRY_NOPROFILE(bscr2)
trap
/* LINTSTUB: Func: void bscr4_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, bus_space_handle_t h2, bus_size_t o2, size_t len); */
/* LINTSTUB: Func: void bscr4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, bus_space_handle_t h2, bus_size_t o2, size_t len); */
ENTRY_NOPROFILE(bscr4_s)
lwz 0,0(3)
rotlw 5,5,0
ENTRY_NOPROFILE(bscr4)
trap
/* LINTSTUB: Func: void bscr8_s(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, bus_space_handle_t h2, bus_size_t o2, size_t len); */
/* LINTSTUB: Func: void bscr8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, bus_space_handle_t h2, bus_size_t o2, size_t len); */
ENTRY_NOPROFILE(bscr8_s)
lwz 0,0(3)
rotlw 5,5,0
ENTRY_NOPROFILE(bscr8)
trap