2001-02-27 12:34:01 +00:00
|
|
|
/* $FreeBSD$ */
|
2001-07-14 00:38:51 +00:00
|
|
|
/* $NecBSD: ct_machdep.h,v 1.4.12.2 2001/06/20 06:13:34 honda Exp $ */
|
2001-02-27 12:34:01 +00:00
|
|
|
/* $NetBSD$ */
|
|
|
|
|
2005-01-06 01:43:34 +00:00
|
|
|
/*-
|
2001-02-27 12:34:01 +00:00
|
|
|
* [NetBSD for NEC PC-98 series]
|
2001-07-14 00:38:51 +00:00
|
|
|
* Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000, 2001
|
2001-02-27 12:34:01 +00:00
|
|
|
* NetBSD/pc98 porting staff. All rights reserved.
|
2001-07-14 00:38:51 +00:00
|
|
|
* Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000, 2001
|
2001-02-27 12:34:01 +00:00
|
|
|
* Naofumi HONDA. 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. 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _CT_MACHDEP_H_
|
|
|
|
#define _CT_MACHDEP_H_
|
|
|
|
|
2001-07-14 00:38:51 +00:00
|
|
|
#include "opt_ct.h"
|
|
|
|
|
2001-02-27 12:34:01 +00:00
|
|
|
/*
|
|
|
|
* Principal rules:
|
|
|
|
* 1) do not use bus_space_write/read_X directly in ct.c.
|
|
|
|
* 2) do not use port offset defs directly in ct.c.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* special weight if requried */
|
2001-07-14 00:38:51 +00:00
|
|
|
#ifdef CT_BUS_WEIGHT
|
|
|
|
#undef CT_BUS_WEIGHT
|
|
|
|
#define CT_BUS_WEIGHT(chp) \
|
|
|
|
{ \
|
|
|
|
if ((chp)->ch_bus_weight != NULL) \
|
|
|
|
(chp)->ch_bus_weight((chp)); \
|
|
|
|
}
|
|
|
|
#else /* !CT_BUS_WEIGHT */
|
|
|
|
#define CT_BUS_WEIGHT(chp)
|
|
|
|
#endif /* !CT_BUS_WEIGHT */
|
2001-02-27 12:34:01 +00:00
|
|
|
|
|
|
|
/* port offset */
|
2001-07-14 00:38:51 +00:00
|
|
|
#ifndef CT_USE_RELOCATE_OFFSET
|
2001-02-27 12:34:01 +00:00
|
|
|
#define addr_port 0
|
|
|
|
#define stat_port 0
|
|
|
|
#define ctrl_port 2
|
|
|
|
#define cmd_port 4
|
2001-07-14 00:38:51 +00:00
|
|
|
#else /* CT_USE_RELOCATE_OFFSET */
|
|
|
|
#define addr_port ((chp)->ch_offset[0])
|
|
|
|
#define stat_port ((chp)->ch_offset[1])
|
|
|
|
#define ctrl_port ((chp)->ch_offset[2])
|
|
|
|
#define cmd_port ((chp)->ch_offset[3])
|
|
|
|
#endif /* CT_USE_RELOCATE_OFFSET */
|
2001-02-27 12:34:01 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* All port accesses primitive methods
|
|
|
|
*/
|
2001-07-14 00:38:51 +00:00
|
|
|
static __inline u_int8_t ct_stat_read_1
|
2002-03-20 02:08:01 +00:00
|
|
|
(struct ct_bus_access_handle *);
|
2001-07-14 00:38:51 +00:00
|
|
|
static __inline u_int8_t ct_cmdp_read_1
|
2002-03-20 02:08:01 +00:00
|
|
|
(struct ct_bus_access_handle *);
|
2001-07-14 00:38:51 +00:00
|
|
|
static __inline void ct_cmdp_write_1
|
2002-03-20 02:08:01 +00:00
|
|
|
(struct ct_bus_access_handle *, u_int8_t);
|
2001-07-14 00:38:51 +00:00
|
|
|
static __inline u_int8_t ct_cr_read_1
|
2002-03-20 02:08:01 +00:00
|
|
|
(struct ct_bus_access_handle *, bus_addr_t);
|
2001-07-14 00:38:51 +00:00
|
|
|
static __inline void ct_cr_write_1
|
2002-03-20 02:08:01 +00:00
|
|
|
(struct ct_bus_access_handle *, bus_addr_t, u_int8_t);
|
2001-07-14 00:38:51 +00:00
|
|
|
static __inline void ct_write_cmds
|
2002-03-20 02:08:01 +00:00
|
|
|
(struct ct_bus_access_handle *, u_int8_t *, int);
|
2001-07-14 00:38:51 +00:00
|
|
|
static __inline u_int cthw_get_count
|
2002-03-20 02:08:01 +00:00
|
|
|
(struct ct_bus_access_handle *);
|
2001-07-14 00:38:51 +00:00
|
|
|
static __inline void cthw_set_count
|
2002-03-20 02:08:01 +00:00
|
|
|
(struct ct_bus_access_handle *, u_int);
|
2001-07-14 00:38:51 +00:00
|
|
|
|
|
|
|
static __inline u_int8_t
|
|
|
|
ct_stat_read_1(chp)
|
|
|
|
struct ct_bus_access_handle *chp;
|
|
|
|
{
|
|
|
|
u_int8_t regv;
|
2001-02-27 12:34:01 +00:00
|
|
|
|
2001-07-14 00:38:51 +00:00
|
|
|
regv = bus_space_read_1(chp->ch_iot, chp->ch_ioh, stat_port);
|
|
|
|
CT_BUS_WEIGHT(chp)
|
|
|
|
return regv;
|
|
|
|
}
|
2001-02-27 12:34:01 +00:00
|
|
|
|
|
|
|
static __inline void
|
2001-07-14 00:38:51 +00:00
|
|
|
cthw_set_count(chp, count)
|
|
|
|
struct ct_bus_access_handle *chp;
|
2001-02-27 12:34:01 +00:00
|
|
|
u_int count;
|
|
|
|
{
|
2001-07-14 00:38:51 +00:00
|
|
|
bus_space_tag_t bst = chp->ch_iot;
|
|
|
|
bus_space_handle_t bsh = chp->ch_ioh;
|
2001-02-27 12:34:01 +00:00
|
|
|
|
|
|
|
bus_space_write_1(bst, bsh, addr_port, wd3s_cnt);
|
2001-07-14 00:38:51 +00:00
|
|
|
CT_BUS_WEIGHT(chp)
|
2001-02-27 12:34:01 +00:00
|
|
|
bus_space_write_1(bst, bsh, ctrl_port, count >> 16);
|
2001-07-14 00:38:51 +00:00
|
|
|
CT_BUS_WEIGHT(chp)
|
2001-02-27 12:34:01 +00:00
|
|
|
bus_space_write_1(bst, bsh, ctrl_port, count >> 8);
|
2001-07-14 00:38:51 +00:00
|
|
|
CT_BUS_WEIGHT(chp)
|
2001-02-27 12:34:01 +00:00
|
|
|
bus_space_write_1(bst, bsh, ctrl_port, count);
|
2001-07-14 00:38:51 +00:00
|
|
|
CT_BUS_WEIGHT(chp)
|
2001-02-27 12:34:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline u_int
|
2001-07-14 00:38:51 +00:00
|
|
|
cthw_get_count(chp)
|
|
|
|
struct ct_bus_access_handle *chp;
|
2001-02-27 12:34:01 +00:00
|
|
|
{
|
2001-07-14 00:38:51 +00:00
|
|
|
bus_space_tag_t bst = chp->ch_iot;
|
|
|
|
bus_space_handle_t bsh = chp->ch_ioh;
|
2001-02-27 12:34:01 +00:00
|
|
|
u_int count;
|
|
|
|
|
|
|
|
bus_space_write_1(bst, bsh, addr_port, wd3s_cnt);
|
2001-07-14 00:38:51 +00:00
|
|
|
CT_BUS_WEIGHT(chp)
|
2001-02-27 12:34:01 +00:00
|
|
|
count = (((u_int) bus_space_read_1(bst, bsh, ctrl_port)) << 16);
|
2001-07-14 00:38:51 +00:00
|
|
|
CT_BUS_WEIGHT(chp)
|
2001-02-27 12:34:01 +00:00
|
|
|
count += (((u_int) bus_space_read_1(bst, bsh, ctrl_port)) << 8);
|
2001-07-14 00:38:51 +00:00
|
|
|
CT_BUS_WEIGHT(chp)
|
2001-02-27 12:34:01 +00:00
|
|
|
count += ((u_int) bus_space_read_1(bst, bsh, ctrl_port));
|
2001-07-14 00:38:51 +00:00
|
|
|
CT_BUS_WEIGHT(chp)
|
2001-02-27 12:34:01 +00:00
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
2001-07-14 00:38:51 +00:00
|
|
|
ct_write_cmds(chp, cmd, len)
|
|
|
|
struct ct_bus_access_handle *chp;
|
2001-02-27 12:34:01 +00:00
|
|
|
u_int8_t *cmd;
|
|
|
|
int len;
|
|
|
|
{
|
2001-07-14 00:38:51 +00:00
|
|
|
bus_space_tag_t bst = chp->ch_iot;
|
|
|
|
bus_space_handle_t bsh = chp->ch_ioh;
|
2001-02-27 12:34:01 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
bus_space_write_1(bst, bsh, addr_port, wd3s_cdb);
|
2001-07-14 00:38:51 +00:00
|
|
|
CT_BUS_WEIGHT(chp)
|
2001-02-27 12:34:01 +00:00
|
|
|
for (i = 0; i < len; i ++)
|
2001-07-14 00:38:51 +00:00
|
|
|
{
|
2001-02-27 12:34:01 +00:00
|
|
|
bus_space_write_1(bst, bsh, ctrl_port, cmd[i]);
|
2001-07-14 00:38:51 +00:00
|
|
|
CT_BUS_WEIGHT(chp)
|
|
|
|
}
|
2001-02-27 12:34:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline u_int8_t
|
2001-07-14 00:38:51 +00:00
|
|
|
ct_cr_read_1(chp, offs)
|
|
|
|
struct ct_bus_access_handle *chp;
|
2001-02-27 12:34:01 +00:00
|
|
|
bus_addr_t offs;
|
|
|
|
{
|
2001-07-14 00:38:51 +00:00
|
|
|
bus_space_tag_t bst = chp->ch_iot;
|
|
|
|
bus_space_handle_t bsh = chp->ch_ioh;
|
2001-02-27 12:34:01 +00:00
|
|
|
u_int8_t regv;
|
|
|
|
|
|
|
|
bus_space_write_1(bst, bsh, addr_port, offs);
|
2001-07-14 00:38:51 +00:00
|
|
|
CT_BUS_WEIGHT(chp)
|
2001-02-27 12:34:01 +00:00
|
|
|
regv = bus_space_read_1(bst, bsh, ctrl_port);
|
2001-07-14 00:38:51 +00:00
|
|
|
CT_BUS_WEIGHT(chp)
|
2001-02-27 12:34:01 +00:00
|
|
|
return regv;
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
2001-07-14 00:38:51 +00:00
|
|
|
ct_cr_write_1(chp, offs, val)
|
|
|
|
struct ct_bus_access_handle *chp;
|
2001-02-27 12:34:01 +00:00
|
|
|
bus_addr_t offs;
|
|
|
|
u_int8_t val;
|
|
|
|
{
|
2001-07-14 00:38:51 +00:00
|
|
|
bus_space_tag_t bst = chp->ch_iot;
|
|
|
|
bus_space_handle_t bsh = chp->ch_ioh;
|
2001-02-27 12:34:01 +00:00
|
|
|
|
|
|
|
bus_space_write_1(bst, bsh, addr_port, offs);
|
2001-07-14 00:38:51 +00:00
|
|
|
CT_BUS_WEIGHT(chp)
|
2001-02-27 12:34:01 +00:00
|
|
|
bus_space_write_1(bst, bsh, ctrl_port, val);
|
2001-07-14 00:38:51 +00:00
|
|
|
CT_BUS_WEIGHT(chp)
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline u_int8_t
|
|
|
|
ct_cmdp_read_1(chp)
|
|
|
|
struct ct_bus_access_handle *chp;
|
|
|
|
{
|
|
|
|
u_int8_t regv;
|
|
|
|
|
|
|
|
regv = bus_space_read_1(chp->ch_iot, chp->ch_ioh, cmd_port);
|
|
|
|
CT_BUS_WEIGHT(chp)
|
|
|
|
return regv;
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
|
|
|
ct_cmdp_write_1(chp, val)
|
|
|
|
struct ct_bus_access_handle *chp;
|
|
|
|
u_int8_t val;
|
|
|
|
{
|
|
|
|
|
|
|
|
bus_space_write_1(chp->ch_iot, chp->ch_ioh, cmd_port, val);
|
|
|
|
CT_BUS_WEIGHT(chp)
|
2001-02-27 12:34:01 +00:00
|
|
|
}
|
|
|
|
|
2002-06-01 08:29:12 +00:00
|
|
|
#if defined(__i386__) && 0
|
2001-02-27 12:34:01 +00:00
|
|
|
#define SOFT_INTR_REQUIRED(slp) (softintr((slp)->sl_irq))
|
2002-05-30 07:32:58 +00:00
|
|
|
#else /* !__i386__ */
|
2001-02-27 12:34:01 +00:00
|
|
|
#define SOFT_INTR_REQUIRED(slp)
|
2002-05-30 07:32:58 +00:00
|
|
|
#endif /* !__i386__ */
|
2001-02-27 12:34:01 +00:00
|
|
|
#endif /* !_CT_MACHDEP_H_ */
|