Deleted Added
full compact
exca.c (115461) exca.c (115988)
1/* $FreeBSD: head/sys/dev/exca/exca.c 115461 2003-05-31 16:51:41Z phk $ */
1/* $FreeBSD: head/sys/dev/exca/exca.c 115988 2003-06-07 20:46:39Z imp $ */
2
3/*
4 * Copyright (c) 2002 M Warner Losh. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright

--- 41 unchanged lines hidden (view full) ---

51 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
52 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
53 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
54 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
55 */
56
57#include <sys/param.h>
58#include <sys/systm.h>
2
3/*
4 * Copyright (c) 2002 M Warner Losh. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright

--- 41 unchanged lines hidden (view full) ---

51 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
52 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
53 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
54 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
55 */
56
57#include <sys/param.h>
58#include <sys/systm.h>
59#include <sys/condvar.h>
59#include <sys/errno.h>
60#include <sys/kernel.h>
61#include <sys/malloc.h>
62#include <sys/queue.h>
63#include <sys/module.h>
60#include <sys/errno.h>
61#include <sys/kernel.h>
62#include <sys/malloc.h>
63#include <sys/queue.h>
64#include <sys/module.h>
65#include <sys/lock.h>
66#include <sys/mutex.h>
64#include <sys/conf.h>
65
66#include <sys/bus.h>
67#include <machine/bus.h>
68#include <sys/rman.h>
69#include <machine/resource.h>
70
71#include <dev/pccard/pccardreg.h>

--- 559 unchanged lines hidden (view full) ---

631/*
632 * Is this socket valid?
633 */
634static int
635exca_valid_slot(struct exca_softc *exca)
636{
637 uint8_t c;
638
67#include <sys/conf.h>
68
69#include <sys/bus.h>
70#include <machine/bus.h>
71#include <sys/rman.h>
72#include <machine/resource.h>
73
74#include <dev/pccard/pccardreg.h>

--- 559 unchanged lines hidden (view full) ---

634/*
635 * Is this socket valid?
636 */
637static int
638exca_valid_slot(struct exca_softc *exca)
639{
640 uint8_t c;
641
642 /* Assume the worst */
643 exca->chipset = EXCA_BOGUS;
644
639 /*
640 * see if there's a PCMCIA controller here
641 * Intel PCMCIA controllers use 0x82 and 0x83
642 * IBM clone chips use 0x88 and 0x89, apparently
643 */
644 c = exca_getb(exca, EXCA_IDENT);
645 if ((c & EXCA_IDENT_IFTYPE_MASK) != EXCA_IDENT_IFTYPE_MEM_AND_IO)
646 return (0);

--- 107 unchanged lines hidden (view full) ---

754 exca->getb = exca_io_getb;
755 exca->putb = exca_io_putb;
756 if (exca_valid_slot(&exca[i]))
757 err = 0;
758 }
759 return (err);
760}
761
645 /*
646 * see if there's a PCMCIA controller here
647 * Intel PCMCIA controllers use 0x82 and 0x83
648 * IBM clone chips use 0x88 and 0x89, apparently
649 */
650 c = exca_getb(exca, EXCA_IDENT);
651 if ((c & EXCA_IDENT_IFTYPE_MASK) != EXCA_IDENT_IFTYPE_MEM_AND_IO)
652 return (0);

--- 107 unchanged lines hidden (view full) ---

760 exca->getb = exca_io_getb;
761 exca->putb = exca_io_putb;
762 if (exca_valid_slot(&exca[i]))
763 err = 0;
764 }
765 return (err);
766}
767
768void
769exca_insert(struct exca_softc *exca)
770{
771 if (exca->pccarddev != NULL) {
772 if (CARD_ATTACH_CARD(exca->pccarddev) != 0)
773 device_printf(exca->dev,
774 "PC Card card activation failed\n");
775 } else {
776 device_printf(exca->dev,
777 "PC Card inserted, but no pccard bus.\n");
778 }
779}
780
781
782void
783exca_removal(struct exca_softc *exca)
784{
785 if (exca->pccarddev != NULL)
786 CARD_DETACH_CARD(exca->pccarddev);
787}
788
789int
790exca_activate_resource(struct exca_softc *exca, device_t child, int type,
791 int rid, struct resource *res)
792{
793 int err;
794 if (!(rman_get_flags(res) & RF_ACTIVE)) { /* not already activated */
795 switch (type) {
796 case SYS_RES_IOPORT:
797 err = exca_io_map(exca, 0, res);
798 break;
799 case SYS_RES_MEMORY:
800 err = exca_mem_map(exca, 0, res);
801 break;
802 default:
803 err = 0;
804 break;
805 }
806 if (err)
807 return (err);
808
809 }
810 return (BUS_ACTIVATE_RESOURCE(device_get_parent(exca->dev), child,
811 type, rid, res));
812}
813
814int
815exca_deactivate_resource(struct exca_softc *exca, device_t child, int type,
816 int rid, struct resource *res)
817{
818 if (rman_get_flags(res) & RF_ACTIVE) { /* if activated */
819 switch (type) {
820 case SYS_RES_IOPORT:
821 if (exca_io_unmap_res(exca, res))
822 return (ENOENT);
823 break;
824 case SYS_RES_MEMORY:
825 if (exca_mem_unmap_res(exca, res))
826 return (ENOENT);
827 break;
828 }
829 }
830 return (BUS_DEACTIVATE_RESOURCE(device_get_parent(exca->dev), child,
831 type, rid, res));
832}
833
762static int
763exca_modevent(module_t mod, int cmd, void *arg)
764{
765 return 0;
766}
767
768DEV_MODULE(exca, exca_modevent, NULL);
769MODULE_VERSION(exca, 1);
834static int
835exca_modevent(module_t mod, int cmd, void *arg)
836{
837 return 0;
838}
839
840DEV_MODULE(exca, exca_modevent, NULL);
841MODULE_VERSION(exca, 1);