MI code should not compare bus_space_tag_t! Introduce tags_are_equal()

for "comparing" two bus_space_tag_t's.  It is always true.

Everywhere that com(4) compares two tags, it compares to I/O base
addresses, too; comparing the base addresses should suffice.

TBD Clean this up more thoroughly.
This commit is contained in:
dyoung 2010-03-22 23:00:08 +00:00
parent f576147073
commit 6b732a0da7

View File

@ -1,4 +1,4 @@
/* $NetBSD: com.c,v 1.295 2010/02/24 22:37:58 dyoung Exp $ */
/* $NetBSD: com.c,v 1.296 2010/03/22 23:00:08 dyoung Exp $ */
/*-
* Copyright (c) 1998, 1999, 2004, 2008 The NetBSD Foundation, Inc.
@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.295 2010/02/24 22:37:58 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.296 2010/03/22 23:00:08 dyoung Exp $");
#include "opt_com.h"
#include "opt_ddb.h"
@ -263,6 +263,13 @@ const bus_size_t com_std_map[16] = COM_REG_16550;
#define COM_BARRIER(r, f) \
bus_space_barrier((r)->cr_iot, (r)->cr_ioh, 0, (r)->cr_nports, (f))
/* XXX Comparing bus_space_tag_t's is not allowed! */
static bool
tags_are_equal(const bus_space_tag_t lt, const bus_space_tag_t rt)
{
return true;
}
/*ARGSUSED*/
int
comspeed(long speed, long frequency, int type)
@ -392,7 +399,7 @@ com_attach_subr(struct com_softc *sc)
CSR_WRITE_1(regsp, COM_REG_IER, sc->sc_ier);
if (regsp->cr_iot == comcons_info.regs.cr_iot &&
if (tags_are_equal(regsp->cr_iot, comcons_info.regs.cr_iot) &&
regsp->cr_iobase == comcons_info.regs.cr_iobase) {
comconsattached = 1;
@ -541,7 +548,7 @@ fifodone:
* exclusive use. If it's the console _and_ the
* kgdb device, it doesn't.
*/
if (regsp->cr_iot == comkgdbregs.cr_iot &&
if (tags_are_equal(regsp->cr_iot, comkgdbregs.cr_iot) &&
regsp->cr_iobase == comkgdbregs.cr_iobase) {
if (!ISSET(sc->sc_hwflags, COM_HW_CONSOLE)) {
com_kgdb_attached = 1;
@ -2302,7 +2309,7 @@ com_kgdb_attach1(struct com_regs *regsp, int rate, int frequency, int type,
{
int res;
if (regsp->cr_iot == comcons_info.regs.cr_iot &&
if (tags_are_equal(regsp->cr_iot, comcons_info.regs.cr_iot) &&
regsp->cr_iobase == comcons_info.regs.cr_iobase) {
#if !defined(DDB)
return (EBUSY); /* cannot share with console */
@ -2371,12 +2378,12 @@ com_is_console(bus_space_tag_t iot, bus_addr_t iobase, bus_space_handle_t *ioh)
bus_space_handle_t help;
if (!comconsattached &&
iot == comcons_info.regs.cr_iot &&
tags_are_equal(iot, comcons_info.regs.cr_iot) &&
iobase == comcons_info.regs.cr_iobase)
help = comcons_info.regs.cr_ioh;
#ifdef KGDB
else if (!com_kgdb_attached &&
iot == comkgdbregs.cr_iot && iobase == comkgdbregs.cr_iobase)
tags_are_equal(iot, comkgdbregs.cr_iot) && iobase == comkgdbregs.cr_iobase)
help = comkgdbregs.cr_ioh;
#endif
else