/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Gordon W. Ross.
*
* 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.
*
* 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.
*/
/*
* Standalone functions specific to the Sun3.
*/
#define _SUN3_ XXX
/*
* We need to get the sun3 NBSG definition, even if we're
* building this with a different sun68k target.
*/
#include <arch/sun3/include/pmap3.h>
va = pgva = sun3_devmap;
do {
sun3_set_pte(pgva, pte);
pgva += NBPG;
pte += 1;
length -= NBPG;
} while (length > 0);
sun3_devmap = pgva;
va += (physaddr & PGOFSET);
#ifdef DEBUG_PROM
if (debug)
printf("dev3_mapin: va=0x%x pte=0x%x\n",
va, sun3_get_pte(va));
#endif
return ((char*)va);
}
/*****************************************************************
* DVMA support
*/
/*
* The easiest way to deal with the need for DVMA mappings is to
* create a DVMA alias mapping of the entire address range used by
* the boot program. That way, dvma_mapin can just compute the
* DVMA alias address, and dvma_mapout does nothing.
*
* Note that this assumes that standalone programs will do I/O
* operations only within range (SA_MIN_VA .. SA_MAX_VA) checked.
*/
static void
sun3_set_pte(vaddr_t va, u_int pte)
{
va = CONTROL_ADDR_BUILD(PGMAP_BASE, va);
set_control_word(va, pte);
}
static int
sun3_get_segmap(vaddr_t va)
{
va = CONTROL_ADDR_BUILD(SEGMAP_BASE, va);
return (get_control_byte(va));
}
static void
sun3_set_segmap(vaddr_t va, int sme)
{
va = CONTROL_ADDR_BUILD(SEGMAP_BASE, va);
set_control_byte(va, sme);
}
/*
* Copy the IDPROM contents into the passed buffer.
* The caller (idprom.c) will do the checksum.
*/
void
sun3_getidprom(u_char *dst)
{
vaddr_t src; /* control space address */
int len, x;
src = IDPROM_BASE;
len = sizeof(struct idprom);
do {
x = get_control_byte(src++);
*dst++ = x;
} while (--len > 0);
}
/*****************************************************************
* Init our function pointers, etc.
*/
void
sun3_init(void)
{
/* Set the function pointers. */
dev_mapin_p = dev3_mapin;
dvma_alloc_p = dvma3_alloc;
dvma_free_p = dvma3_free;
dvma_mapin_p = dvma3_mapin;
dvma_mapout_p = dvma3_mapout;