vme_machdep.c revision 1.24
11.24Stsutsui/*	$NetBSD: vme_machdep.c,v 1.24 2022/06/26 05:16:22 tsutsui Exp $	*/
21.1Sleo
31.1Sleo/*-
41.1Sleo * Copyright (c) 1997 The NetBSD Foundation, Inc.
51.1Sleo * All rights reserved.
61.1Sleo *
71.1Sleo * Redistribution and use in source and binary forms, with or without
81.1Sleo * modification, are permitted provided that the following conditions
91.1Sleo * are met:
101.1Sleo * 1. Redistributions of source code must retain the above copyright
111.1Sleo *    notice, this list of conditions and the following disclaimer.
121.1Sleo * 2. Redistributions in binary form must reproduce the above copyright
131.1Sleo *    notice, this list of conditions and the following disclaimer in the
141.1Sleo *    documentation and/or other materials provided with the distribution.
151.1Sleo *
161.1Sleo * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
171.1Sleo * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
181.1Sleo * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
191.2Sjtc * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
201.2Sjtc * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
211.1Sleo * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
221.1Sleo * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
231.1Sleo * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
241.1Sleo * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
251.1Sleo * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
261.1Sleo * POSSIBILITY OF SUCH DAMAGE.
271.1Sleo */
281.12Slukem
291.12Slukem#include <sys/cdefs.h>
301.24Stsutsui__KERNEL_RCSID(0, "$NetBSD: vme_machdep.c,v 1.24 2022/06/26 05:16:22 tsutsui Exp $");
311.1Sleo
321.1Sleo#include <sys/types.h>
331.1Sleo#include <sys/param.h>
341.1Sleo#include <sys/time.h>
351.1Sleo#include <sys/systm.h>
361.1Sleo#include <sys/errno.h>
371.1Sleo#include <sys/device.h>
381.1Sleo
391.9Smrg#include <uvm/uvm_extern.h>
401.1Sleo
411.21Sdyoung#include <sys/bus.h>
421.1Sleo#include <machine/cpu.h>
431.1Sleo#include <machine/iomap.h>
441.1Sleo#include <machine/mfp.h>
451.1Sleo
461.1Sleo#include <atari/atari/device.h>
471.1Sleo#include <atari/vme/vmevar.h>
481.1Sleo
491.20Stsutsuistatic int	vmebusprint(void *, const char *);
501.20Stsutsuistatic int	vmebusmatch(device_t, cfdata_t, void *);
511.20Stsutsuistatic void	vmebusattach(device_t, device_t, void *);
521.1Sleo
531.20StsutsuiCFATTACH_DECL_NEW(avmebus, 0,
541.11Sthorpej    vmebusmatch, vmebusattach, NULL, NULL);
551.1Sleo
561.24Stsutsuistatic int vmebus_attached;
571.13Schs
581.24Stsutsuistatic int
591.20Stsutsuivmebusmatch(device_t parent, cfdata_t cf, void *aux)
601.1Sleo{
611.19Stsutsui
621.19Stsutsui	if (atari_realconfig == 0)
631.19Stsutsui		return 0;
641.20Stsutsui	if (strcmp((char *)aux, "avmebus") || vmebus_attached)
651.19Stsutsui		return 0;
661.24Stsutsui	return ((machineid & ATARI_FALCON) != 0) ? 0 : 1;
671.1Sleo}
681.1Sleo
691.24Stsutsuistatic void
701.20Stsutsuivmebusattach(device_t parent, device_t self, void *aux)
711.1Sleo{
721.24Stsutsui	struct vmebus_attach_args vba;
731.1Sleo
741.13Schs	vmebus_attached = 1;
751.13Schs
761.1Sleo	vba.vba_busname = "vme";
771.7Sleo	vba.vba_iot     = beb_alloc_bus_space_tag(NULL);
781.7Sleo	vba.vba_memt    = beb_alloc_bus_space_tag(NULL);
791.4Sleo	if ((vba.vba_iot == NULL) || (vba.vba_memt == NULL)) {
801.24Stsutsui		aprint_error("beb_alloc_bus_space_tag failed!\n");
811.4Sleo		return;
821.4Sleo	}
831.4Sleo
841.4Sleo	/*
851.4Sleo	 * XXX: Should we use zero or the actual (phys) start of VME memory.
861.4Sleo	 */
871.4Sleo	vba.vba_iot->base  = 0;
881.4Sleo	vba.vba_memt->base = 0;
891.1Sleo
901.24Stsutsui	aprint_normal("\n");
911.23Sthorpej	config_found(self, &vba, vmebusprint, CFARGS_NONE);
921.1Sleo}
931.1Sleo
941.24Stsutsuistatic int
951.20Stsutsuivmebusprint(void *aux, const char *name)
961.1Sleo{
971.19Stsutsui
981.19Stsutsui	if (name == NULL)
991.19Stsutsui		return UNCONF;
1001.19Stsutsui	return QUIET;
1011.1Sleo}
102