OpenBSD-2.6/arc
This commit is contained in:
parent
d33119108e
commit
87009692f7
88
sys/arch/arc/conf/IMP3
Normal file
88
sys/arch/arc/conf/IMP3
Normal file
@ -0,0 +1,88 @@
|
||||
# $OpenBSD: IMP3,v 1.2 1999/08/29 12:14:03 niklas Exp $
|
||||
#
|
||||
# Generic configuration file for MIPS R4x00 ARC Systems
|
||||
#
|
||||
|
||||
machine arc mips
|
||||
|
||||
include "../../../conf/GENERIC"
|
||||
|
||||
maxusers 32
|
||||
|
||||
# MD options
|
||||
option NATIVE_ELF # Arc systems uses ELF as native format
|
||||
|
||||
# Specify storage configuration (its a joke..)
|
||||
config bsd swap generic
|
||||
|
||||
#
|
||||
# Definition of system
|
||||
#
|
||||
mainbus0 at root
|
||||
cpu* at mainbus0
|
||||
|
||||
#### Main local buses
|
||||
|
||||
pica* at mainbus0 # ACER Pica systems local bus.
|
||||
isabr* at mainbus0 # ISA Bus bridge (std ISA bus).
|
||||
|
||||
#### PICA bus devices
|
||||
|
||||
clock0 at pica?
|
||||
pc0 at pica?
|
||||
pms0 at pica?
|
||||
com0 at pica?
|
||||
com1 at pica?
|
||||
lpt0 at pica?
|
||||
sn0 at pica?
|
||||
|
||||
fdc0 at pica?
|
||||
fd* at fdc? drive ?
|
||||
|
||||
asc0 at pica?
|
||||
scsibus* at asc?
|
||||
|
||||
#### ISA Bus.
|
||||
|
||||
isa* at isabr?
|
||||
|
||||
clock0 at isa? port 0x70 irq 0
|
||||
|
||||
pc0 at isa? port 0x60 irq 1 # generic PC console device
|
||||
com0 at isa? port 0x3f8 irq 4
|
||||
com1 at isa? port 0x2f8 irq 3
|
||||
com2 at isa? port 0x3e8 irq 4
|
||||
com3 at isa? port 0x2e8 irq 3
|
||||
ast0 at isa? port 0x1a0 irq 3 # AST 4-port serial cards
|
||||
com* at ast? slave ?
|
||||
lpt0 at isa? port 0x378 irq 7
|
||||
|
||||
# IDE controllers
|
||||
wdc0 at isa? port 0x1f0 irq 14 flags 0x00
|
||||
wdc1 at isa? port 0x170 irq 15 flags 0x00
|
||||
#wdc* at isapnp?
|
||||
|
||||
# IDE hard drives
|
||||
wd* at wdc? channel ? drive ? flags 0x0000
|
||||
|
||||
# ATAPI<->SCSI
|
||||
atapiscsi* at wdc? channel ?
|
||||
scsibus* at atapiscsi?
|
||||
|
||||
ep0 at isa? port ? irq ? # 3C509 ethernet cards
|
||||
we0 at isa? port 0x300 iomem 0xd0000 irq 5 # WD/SMC 80x3 ethernet
|
||||
ne0 at isa? port 0x300 irq 5 # NE[12]000 ethernet
|
||||
# iy0 at isa? port 0x300 irq 11 # Intel etherexpress pro/10+
|
||||
joy0 at isa? port 0x201
|
||||
|
||||
btl0 at isa? port 0x330 irq ? drq ?
|
||||
scsibus* at btl?
|
||||
|
||||
#### SCSI Bus devices
|
||||
|
||||
sd* at scsibus? target ? lun ?
|
||||
st* at scsibus? target ? lun ?
|
||||
cd* at scsibus? target ? lun ?
|
||||
ch* at scsibus? target ? lun ?
|
||||
ss* at scsibus? target ? lun ?
|
||||
uk* at scsibus? target ? lun ?
|
126
sys/arch/arc/conf/NFSROOT
Normal file
126
sys/arch/arc/conf/NFSROOT
Normal file
@ -0,0 +1,126 @@
|
||||
# $OpenBSD: NFSROOT,v 1.2 1999/08/29 12:14:03 niklas Exp $
|
||||
#
|
||||
# Generic configuration file for MIPS R4x00 ARC Systems
|
||||
#
|
||||
|
||||
machine arc mips
|
||||
|
||||
option SCSITERSE
|
||||
|
||||
maxusers 4
|
||||
option TIMEZONE=0 # time zone to adjust RTC time by
|
||||
option DST=0 # daylight savings time used by RTC
|
||||
|
||||
option SWAPPAGER # paging; REQUIRED
|
||||
option DEVPAGER # mmap() of devices
|
||||
|
||||
#makeoptions DEBUG="-g" # compile full symbol table
|
||||
|
||||
option FFS # UFS
|
||||
#option EXT2FS # Linux ext2fs
|
||||
|
||||
option NFSCLIENT # Network File System client
|
||||
|
||||
#option CD9660 # ISO 9660 + Rock Ridge file system
|
||||
option MSDOSFS # MS-DOS file system
|
||||
option FIFO # FIFOs; RECOMMENDED
|
||||
option KERNFS # /kern
|
||||
|
||||
option INET # IP + ICMP + TCP + UDP
|
||||
|
||||
option BOOT_CONFIG # boot-time kernel config
|
||||
#option DDB
|
||||
|
||||
# MD options
|
||||
option NATIVE_ELF # Arc systems uses ELF as native format
|
||||
|
||||
# Specify storage configuration (its a joke..)
|
||||
config bsd swap generic
|
||||
|
||||
#
|
||||
# Definition of system
|
||||
#
|
||||
mainbus0 at root
|
||||
cpu* at mainbus0
|
||||
|
||||
#### Main local buses
|
||||
|
||||
#pica* at mainbus0 # ACER Pica systems local bus.
|
||||
isabr* at mainbus0 # ISA Bus bridge (std ISA bus).
|
||||
|
||||
#### PICA bus devices
|
||||
|
||||
#clock0 at pica?
|
||||
#pc0 at pica?
|
||||
#pms0 at pica?
|
||||
#com0 at pica?
|
||||
#com1 at pica?
|
||||
#lpt0 at pica?
|
||||
#sn0 at pica?
|
||||
|
||||
#fdc0 at pica?
|
||||
#fd* at fdc? drive ?
|
||||
|
||||
#asc0 at pica?
|
||||
#scsibus* at asc?
|
||||
|
||||
#### ISA Bus.
|
||||
|
||||
isa* at isabr?
|
||||
|
||||
clock0 at isa? port 0x70 irq 0
|
||||
|
||||
pc0 at isa? port 0x60 irq 1 # generic PC console device
|
||||
com0 at isa? port 0x3f8 irq 4
|
||||
com1 at isa? port 0x2f8 irq 3
|
||||
com2 at isa? port 0x3e8 irq 4
|
||||
com3 at isa? port 0x2e8 irq 3
|
||||
ast0 at isa? port 0x1a0 irq 3 # AST 4-port serial cards
|
||||
com* at ast? slave ?
|
||||
lpt0 at isa? port 0x378 irq 7
|
||||
|
||||
# Joystick driver. Probe is a little strange; add only if you have one.
|
||||
# joy0 at isa? port 0x201
|
||||
|
||||
# IDE controllers
|
||||
wdc0 at isa? port 0x1f0 irq 14 flags 0x00
|
||||
wdc1 at isa? port 0x170 irq 15 flags 0x00
|
||||
#wdc* at pcmcia? function ?
|
||||
#wdc* at isapnp?
|
||||
|
||||
# IDE hard drives
|
||||
wd* at wdc? channel ? drive ? flags 0x0000
|
||||
|
||||
# ATAPI<->SCSI
|
||||
atapiscsi* at wdc? channel ?
|
||||
scsibus* at atapiscsi?
|
||||
|
||||
ep0 at isa? port ? irq ? # 3C509 ethernet cards
|
||||
we0 at isa? port 0x280 iomem 0xd0000 irq 9 # WD/SMC 80x3 ethernet
|
||||
we1 at isa? port 0x300 iomem 0xcc000 irq 10 #
|
||||
#we* at isapnp?
|
||||
ec0 at isa? port 0x250 iomem 0xd8000 irq 9 # 3C503 ethernet
|
||||
ne0 at isa? port 0x240 irq 9 # NE[12]000 ethernet
|
||||
ne1 at isa? port 0x300 irq 10 # NE[12]000 ethernet
|
||||
ne2 at isa? port 0x280 irq 9 # NE[12]000 ethernet
|
||||
#ne* at isapnp? # NE[12]000 PnP ether cards
|
||||
|
||||
btl0 at isa? port 0x330 irq ? drq ?
|
||||
scsibus* at btl?
|
||||
|
||||
#### SCSI Bus devices
|
||||
|
||||
sd* at scsibus? target ? lun ?
|
||||
st* at scsibus? target ? lun ?
|
||||
cd* at scsibus? target ? lun ?
|
||||
ch* at scsibus? target ? lun ?
|
||||
ss* at scsibus? target ? lun ?
|
||||
uk* at scsibus? target ? lun ?
|
||||
|
||||
pseudo-device loop 1 # network loopback
|
||||
#pseudo-device sl 1 # CSLIP
|
||||
#pseudo-device ppp 1 # PPP
|
||||
pseudo-device bpfilter 1 # packet filter
|
||||
pseudo-device pty 64 # pseudo-terminals
|
||||
pseudo-device vnd 4 # concatenated disk devices
|
||||
pseudo-device ksyms 1 # kernel symbols device
|
5
sys/arch/arc/include/db_machdep.h
Normal file
5
sys/arch/arc/include/db_machdep.h
Normal file
@ -0,0 +1,5 @@
|
||||
/* $OpenBSD: db_machdep.h,v 1.1 1998/03/16 09:38:44 pefo Exp $ */
|
||||
|
||||
/* Use Mips generic include file */
|
||||
|
||||
#include <mips/db_machdep.h>
|
23
sys/arch/arc/include/joystick.h
Normal file
23
sys/arch/arc/include/joystick.h
Normal file
@ -0,0 +1,23 @@
|
||||
/* $OpenBSD: joystick.h,v 1.1 1998/05/05 05:44:43 imp Exp $ */
|
||||
/* $NetBSD: joystick.h,v 1.1.1.1 2000/02/22 11:05:21 soda Exp $ */
|
||||
|
||||
#ifndef _JOY_IOCTL_H_
|
||||
#define _JOY_IOCTL_H_
|
||||
|
||||
#include <sys/ioccom.h>
|
||||
|
||||
struct joystick {
|
||||
int x;
|
||||
int y;
|
||||
int b1;
|
||||
int b2;
|
||||
};
|
||||
|
||||
#define JOY_SETTIMEOUT _IOW('J', 1, int) /* set timeout */
|
||||
#define JOY_GETTIMEOUT _IOR('J', 2, int) /* get timeout */
|
||||
#define JOY_SET_X_OFFSET _IOW('J', 3, int) /* set offset on X-axis */
|
||||
#define JOY_SET_Y_OFFSET _IOW('J', 4, int) /* set offset on X-axis */
|
||||
#define JOY_GET_X_OFFSET _IOR('J', 5, int) /* get offset on X-axis */
|
||||
#define JOY_GET_Y_OFFSET _IOR('J', 6, int) /* get offset on Y-axis */
|
||||
|
||||
#endif /* _JOY_IOCTL_H_ */
|
3
sys/arch/arc/include/spinlock.h
Normal file
3
sys/arch/arc/include/spinlock.h
Normal file
@ -0,0 +1,3 @@
|
||||
/* $OpenBSD: spinlock.h,v 1.2 1999/01/26 20:33:06 imp Exp $ */
|
||||
|
||||
#include <mips/spinlock.h>
|
153
sys/arch/arc/isa/isapnp_machdep.c
Normal file
153
sys/arch/arc/isa/isapnp_machdep.c
Normal file
@ -0,0 +1,153 @@
|
||||
/* $OpenBSD: isapnp_machdep.c,v 1.1 1997/12/27 12:13:11 niklas Exp $ */
|
||||
/* $NetBSD: isapnp_machdep.c,v 1.1.1.1 2000/02/22 11:05:23 soda Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996, 1997 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Christos Zoulas. All rights reserved.
|
||||
*
|
||||
* 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 Christos Zoulas.
|
||||
* 4. 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Machine-dependent portions of ISA PnP bus autoconfiguration.
|
||||
*
|
||||
* N.B. This file exists mostly to get around some lameness surrounding
|
||||
* the PnP spec. ISA PnP registers live where some `normal' ISA
|
||||
* devices do, but are e.g. write-only registers where the normal
|
||||
* device has a read-only register. This breaks in the presence of
|
||||
* i/o port accounting. This file takes care of mapping ISA PnP
|
||||
* registers without actually allocating them in extent maps.
|
||||
*
|
||||
* Since this is a machine-dependent file, we make all sorts of
|
||||
* assumptions about bus.h's guts. Beware!
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/malloc.h>
|
||||
|
||||
#include <machine/bus.h>
|
||||
|
||||
#include <dev/isa/isapnpreg.h>
|
||||
|
||||
#include <dev/isa/isavar.h>
|
||||
|
||||
/* isapnp_map():
|
||||
* Map I/O regions used by PnP
|
||||
*/
|
||||
int
|
||||
isapnp_map(sc)
|
||||
struct isapnp_softc *sc;
|
||||
{
|
||||
sc->sc_addr_ioh = sc->sc_iot->bus_base + ISAPNP_ADDR;
|
||||
sc->sc_wrdata_ioh = sc->sc_iot->bus_base + ISAPNP_WRDATA;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* isapnp_unmap():
|
||||
* Unmap I/O regions used by PnP
|
||||
*/
|
||||
void
|
||||
isapnp_unmap(sc)
|
||||
struct isapnp_softc *sc;
|
||||
{
|
||||
/* Do nothing. */
|
||||
}
|
||||
|
||||
/* isapnp_map_readport():
|
||||
* Called to map the PnP `read port', which is mapped independently
|
||||
* of the `write' and `addr' ports.
|
||||
*
|
||||
* NOTE: assumes the caller has filled in sc->sc_read_port!
|
||||
*/
|
||||
int
|
||||
isapnp_map_readport(sc)
|
||||
struct isapnp_softc *sc;
|
||||
{
|
||||
#ifdef _KERNEL
|
||||
int error;
|
||||
|
||||
/* Check if some other device has already claimed this port. */
|
||||
if ((error = bus_space_map(sc->sc_iot, sc->sc_read_port, 1, 0,
|
||||
&sc->sc_read_ioh)) != 0)
|
||||
return error;
|
||||
|
||||
/*
|
||||
* XXX: We unmap the port because it can and will be used by other
|
||||
* devices such as a joystick. We need a better port accounting
|
||||
* scheme with read and write ports.
|
||||
*/
|
||||
bus_space_unmap(sc->sc_iot, sc->sc_read_ioh, 1);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* isapnp_unmap_readport():
|
||||
* Pretend to unmap a previously mapped `read port'.
|
||||
*/
|
||||
void
|
||||
isapnp_unmap_readport(sc)
|
||||
struct isapnp_softc *sc;
|
||||
{
|
||||
/* Do nothing */
|
||||
}
|
76
sys/arch/arc/isa/isapnp_machdep.h
Normal file
76
sys/arch/arc/isa/isapnp_machdep.h
Normal file
@ -0,0 +1,76 @@
|
||||
/* $OpenBSD: isapnp_machdep.h,v 1.1 1997/12/27 12:13:12 niklas Exp $ */
|
||||
/* $NetBSD: isapnp_machdep.h,v 1.1.1.1 2000/02/22 11:05:23 soda Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996, 1997 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Christos Zoulas. All rights reserved.
|
||||
*
|
||||
* 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 Christos Zoulas.
|
||||
* 4. 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Functions provided to machine-independent ISA PnP code.
|
||||
*/
|
||||
int isapnp_map __P((struct isapnp_softc *));
|
||||
void isapnp_unmap __P((struct isapnp_softc *));
|
||||
int isapnp_map_readport __P((struct isapnp_softc *));
|
||||
void isapnp_unmap_readport __P((struct isapnp_softc *));
|
256
sys/arch/arc/isa/joy.c
Normal file
256
sys/arch/arc/isa/joy.c
Normal file
@ -0,0 +1,256 @@
|
||||
/* $NetBSD: joy.c,v 1.1.1.1 2000/02/22 11:05:24 soda Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1995 Jean-Marc Zucconi
|
||||
* All rights reserved.
|
||||
*
|
||||
* Ported to NetBSD by Matthieu Herrb <matthieu@laas.fr>
|
||||
*
|
||||
* 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
|
||||
* in this position and unchanged.
|
||||
* 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 withough 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/errno.h>
|
||||
|
||||
#include <machine/cpu.h>
|
||||
#include <machine/pio.h>
|
||||
#include <machine/joystick.h>
|
||||
|
||||
#include <dev/isa/isavar.h>
|
||||
#include <dev/isa/isareg.h>
|
||||
#include <arc/isa/timerreg.h>
|
||||
|
||||
/*
|
||||
* The game port can manage 4 buttons and 4 variable resistors (usually 2
|
||||
* joysticks, each with 2 buttons and 2 pots.) via the port at address 0x201.
|
||||
* Getting the state of the buttons is done by reading the game port;
|
||||
* buttons 1-4 correspond to bits 4-7 and resistors 1-4 (X1, Y1, X2, Y2)
|
||||
* to bits 0-3. If button 1 (resp 2, 3, 4) is pressed, the bit 4 (resp 5,
|
||||
* 6, 7) is set to 0 to get the value of a resistor, write the value 0xff
|
||||
* at port and wait until the corresponding bit returns to 0.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The formulae below only work if u is ``not too large''. See also
|
||||
* the discussion in microtime.s
|
||||
*/
|
||||
#define USEC2TICKS(u) (((u) * 19549) >> 14)
|
||||
#define TICKS2USEC(u) (((u) * 3433) >> 12)
|
||||
|
||||
|
||||
#define JOYPART(d) (minor(d) & 1)
|
||||
#define JOYUNIT(d) minor(d) >> 1 & 3
|
||||
|
||||
#ifndef JOY_TIMEOUT
|
||||
#define JOY_TIMEOUT 2000 /* 2 milliseconds */
|
||||
#endif
|
||||
|
||||
#define JOY_NPORTS 1
|
||||
|
||||
struct joy_softc {
|
||||
struct device sc_dev;
|
||||
int port;
|
||||
int x_off[2], y_off[2];
|
||||
int timeout[2];
|
||||
};
|
||||
|
||||
int joyprobe __P((struct device *, void *, void *));
|
||||
int joyread __P((dev_t dev, struct uio *uio, int flag));
|
||||
int joyioctl __P((dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p));
|
||||
void joyattach __P((struct device *, struct device *, void *));
|
||||
int joyopen __P((dev_t, int, int, struct proc *));
|
||||
int joyclose __P((dev_t, int, int, struct proc *));
|
||||
static int get_tick __P((void));
|
||||
|
||||
struct cfattach joy_ca = {
|
||||
sizeof(struct joy_softc), joyprobe, joyattach
|
||||
};
|
||||
|
||||
struct cfdriver joy_cd = {
|
||||
NULL, "joy", DV_DULL
|
||||
};
|
||||
|
||||
|
||||
int
|
||||
joyprobe(parent, match, aux)
|
||||
struct device *parent;
|
||||
void *match, *aux;
|
||||
{
|
||||
struct isa_attach_args *ia = aux;
|
||||
#ifdef WANT_JOYSTICK_CONNECTED
|
||||
int iobase = ia->ia_iobase;
|
||||
|
||||
isa_outb(iobase, 0xff);
|
||||
DELAY(10000); /* 10 ms delay */
|
||||
return (isa_inb(iobase) & 0x0f) != 0x0f;
|
||||
#else
|
||||
ia->ia_iosize = JOY_NPORTS;
|
||||
ia->ia_msize = 0;
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
joyattach(parent, self, aux)
|
||||
struct device *parent, *self;
|
||||
void *aux;
|
||||
{
|
||||
struct joy_softc *sc = (void *) self;
|
||||
struct isa_attach_args *ia = aux;
|
||||
int iobase = ia->ia_iobase;
|
||||
|
||||
sc->port = iobase;
|
||||
sc->timeout[0] = sc->timeout[1] = 0;
|
||||
isa_outb(iobase, 0xff);
|
||||
DELAY(10000); /* 10 ms delay */
|
||||
printf(": joystick%sconnected\n",
|
||||
(isa_inb(iobase) & 0x0f) == 0x0f ? " not " : " ");
|
||||
}
|
||||
|
||||
int
|
||||
joyopen(dev, flag, mode, p)
|
||||
dev_t dev;
|
||||
int flag, mode;
|
||||
struct proc *p;
|
||||
{
|
||||
int unit = JOYUNIT(dev);
|
||||
int i = JOYPART(dev);
|
||||
struct joy_softc *sc;
|
||||
|
||||
if (unit >= joy_cd.cd_ndevs)
|
||||
return (ENXIO);
|
||||
|
||||
sc = joy_cd.cd_devs[unit];
|
||||
|
||||
if (sc->timeout[i])
|
||||
return EBUSY;
|
||||
|
||||
sc->x_off[i] = sc->y_off[i] = 0;
|
||||
sc->timeout[i] = JOY_TIMEOUT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
joyclose(dev, flag, mode, p)
|
||||
dev_t dev;
|
||||
int flag, mode;
|
||||
struct proc *p;
|
||||
{
|
||||
int unit = JOYUNIT(dev);
|
||||
int i = JOYPART(dev);
|
||||
struct joy_softc *sc = joy_cd.cd_devs[unit];
|
||||
|
||||
sc->timeout[i] = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
joyread(dev_t dev, struct uio *uio, int flag)
|
||||
{
|
||||
int unit = JOYUNIT(dev);
|
||||
struct joy_softc *sc = joy_cd.cd_devs[unit];
|
||||
struct joystick c;
|
||||
int port = sc->port;
|
||||
int i, t0, t1;
|
||||
int state = 0, x = 0, y = 0;
|
||||
|
||||
/* disable_intr(); */ /* XXX BAD */
|
||||
isa_outb(port, 0xff);
|
||||
t0 = get_tick();
|
||||
t1 = t0;
|
||||
i = USEC2TICKS(sc->timeout[JOYPART(dev)]);
|
||||
while (t0 - t1 < i) {
|
||||
state = isa_inb(port);
|
||||
if (JOYPART(dev) == 1)
|
||||
state >>= 2;
|
||||
t1 = get_tick();
|
||||
if (t1 > t0)
|
||||
t1 -= TIMER_FREQ / hz;
|
||||
if (!x && !(state & 0x01))
|
||||
x = t1;
|
||||
if (!y && !(state & 0x02))
|
||||
y = t1;
|
||||
if (x && y)
|
||||
break;
|
||||
}
|
||||
/* enable_intr(); */ /* XXX BAD */
|
||||
c.x = x ? sc->x_off[JOYPART(dev)] + TICKS2USEC(t0 - x) : 0x80000000;
|
||||
c.y = y ? sc->y_off[JOYPART(dev)] + TICKS2USEC(t0 - y) : 0x80000000;
|
||||
state >>= 4;
|
||||
c.b1 = ~state & 1;
|
||||
c.b2 = ~(state >> 1) & 1;
|
||||
return uiomove((caddr_t) & c, sizeof(struct joystick), uio);
|
||||
}
|
||||
|
||||
int
|
||||
joyioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
|
||||
{
|
||||
int unit = JOYUNIT(dev);
|
||||
struct joy_softc *sc = joy_cd.cd_devs[unit];
|
||||
int i = JOYPART(dev);
|
||||
int x;
|
||||
|
||||
switch (cmd) {
|
||||
case JOY_SETTIMEOUT:
|
||||
x = *(int *) data;
|
||||
if (x < 1 || x > 10000) /* 10ms maximum! */
|
||||
return EINVAL;
|
||||
sc->timeout[i] = x;
|
||||
break;
|
||||
case JOY_GETTIMEOUT:
|
||||
*(int *) data = sc->timeout[i];
|
||||
break;
|
||||
case JOY_SET_X_OFFSET:
|
||||
sc->x_off[i] = *(int *) data;
|
||||
break;
|
||||
case JOY_SET_Y_OFFSET:
|
||||
sc->y_off[i] = *(int *) data;
|
||||
break;
|
||||
case JOY_GET_X_OFFSET:
|
||||
*(int *) data = sc->x_off[i];
|
||||
break;
|
||||
case JOY_GET_Y_OFFSET:
|
||||
*(int *) data = sc->y_off[i];
|
||||
break;
|
||||
default:
|
||||
return ENXIO;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
get_tick()
|
||||
{
|
||||
int low, high;
|
||||
|
||||
isa_outb(TIMER_MODE, TIMER_SEL0);
|
||||
low = isa_inb(TIMER_CNTR0);
|
||||
high = isa_inb(TIMER_CNTR0);
|
||||
|
||||
return (high << 8) | low;
|
||||
}
|
Loading…
Reference in New Issue
Block a user