1 1.17 mrg /* $NetBSD: cardslotvar.h,v 1.17 2021/04/17 01:19:48 mrg Exp $ */ 2 1.1 haya 3 1.1 haya /* 4 1.1 haya * Copyright (c) 1999 5 1.1 haya * HAYAKAWA Koichi. All rights reserved. 6 1.1 haya * 7 1.1 haya * Redistribution and use in source and binary forms, with or without 8 1.1 haya * modification, are permitted provided that the following conditions 9 1.1 haya * are met: 10 1.1 haya * 1. Redistributions of source code must retain the above copyright 11 1.1 haya * notice, this list of conditions and the following disclaimer. 12 1.1 haya * 2. Redistributions in binary form must reproduce the above copyright 13 1.1 haya * notice, this list of conditions and the following disclaimer in the 14 1.1 haya * documentation and/or other materials provided with the distribution. 15 1.1 haya * 16 1.1 haya * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 1.1 haya * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 1.1 haya * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 1.1 haya * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 20 1.1 haya * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 1.1 haya * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 1.1 haya * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 1.1 haya * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 1.1 haya * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 25 1.1 haya * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 1.1 haya * POSSIBILITY OF SUCH DAMAGE. 27 1.1 haya */ 28 1.1 haya 29 1.4 kleink #ifndef _DEV_CARDBUS_CARDSLOTVAR_H_ 30 1.4 kleink #define _DEV_CARDBUS_CARDSLOTVAR_H_ 31 1.1 haya 32 1.1 haya /* require sys/device.h */ 33 1.1 haya /* require sys/queue.h */ 34 1.1 haya 35 1.1 haya struct cardslot_event; 36 1.1 haya 37 1.1 haya /* 38 1.1 haya * The data structure cardslot_attach_args is the attach argument for 39 1.1 haya * PCMCIA (including CardBus and 16-bit card) slot. 40 1.1 haya */ 41 1.1 haya struct cardslot_attach_args { 42 1.6 haya /* for cardbus... */ 43 1.6 haya struct cbslot_attach_args *caa_cb_attach; 44 1.1 haya 45 1.6 haya /* for 16-bit pcmcia */ 46 1.6 haya struct pcmciabus_attach_args *caa_16_attach; 47 1.1 haya }; 48 1.1 haya 49 1.1 haya 50 1.1 haya /* 51 1.1 haya * The data structure cardslot_attach_args is the attach argument for 52 1.1 haya * PCMCIA (including CardBus and 16-bit card) slot. 53 1.1 haya */ 54 1.1 haya struct cardslot_softc { 55 1.13 drochner device_t sc_dev; 56 1.1 haya 57 1.6 haya int sc_status; /* the status of slot */ 58 1.1 haya 59 1.6 haya struct cardbus_softc *sc_cb_softc; 60 1.15 drochner device_t sc_16_softc; 61 1.1 haya 62 1.11 ad struct lwp *sc_event_thread; 63 1.6 haya int sc_th_enable; /* true if the thread is enabled */ 64 1.1 haya 65 1.6 haya /* An event queue for the thread which processes slot state events. */ 66 1.1 haya 67 1.6 haya SIMPLEQ_HEAD(, cardslot_event) sc_events; 68 1.17 mrg 69 1.17 mrg /* Safely handle detach. */ 70 1.17 mrg kmutex_t sc_event_lock; 71 1.17 mrg kcondvar_t sc_event_cv; 72 1.1 haya }; 73 1.1 haya 74 1.1 haya #define CARDSLOT_STATUS_CARD_MASK 0x07 75 1.1 haya #define CARDSLOT_STATUS_CARD_NONE 0x00 /* NO card inserted */ 76 1.1 haya #define CARDSLOT_STATUS_CARD_16 0x01 /* 16-bit pcmcia card inserted */ 77 1.1 haya #define CARDSLOT_STATUS_CARD_CB 0x02 /* CardBus pcmcia card inserted */ 78 1.1 haya #define CARDSLOT_STATUS_UNKNOWN 0x07 /* Unknown card inserted */ 79 1.1 haya 80 1.1 haya #define CARDSLOT_CARDTYPE(x) ((x) & CARDSLOT_STATUS_CARD_MASK) 81 1.1 haya #define CARDSLOT_SET_CARDTYPE(x, type) \ 82 1.1 haya do {(x) &= ~CARDSLOT_STATUS_CARD_MASK;\ 83 1.1 haya (x) |= (CARDSLOT_STATUS_CARD_MASK & (type));} while(0) 84 1.1 haya 85 1.1 haya #define CARDSLOT_STATUS_WORK_MASK 0x08 86 1.1 haya #define CARDSLOT_STATUS_WORKING 0x08 /* at least one function works */ 87 1.1 haya #define CARDSLOT_STATUS_NOTWORK 0x00 /* no functions are working */ 88 1.3 haya 89 1.3 haya #define CARDSLOT_WORK(x) ((x) & CARDSLOT_STATUS_WORK_MASK) 90 1.3 haya #define CARDSLOT_SET_WORK(x, type) \ 91 1.3 haya do {(x) &= ~CARDSLOT_STATUS_WORK_MASK;\ 92 1.3 haya (x) |= (CARDSLOT_STATUS_WORK_MASK & (type));} while(0) 93 1.1 haya 94 1.1 haya 95 1.1 haya struct cardslot_event { 96 1.6 haya SIMPLEQ_ENTRY(cardslot_event) ce_q; 97 1.1 haya 98 1.6 haya int ce_type; 99 1.1 haya }; 100 1.1 haya 101 1.1 haya /* ce_type */ 102 1.1 haya #define CARDSLOT_EVENT_INSERTION_16 0 103 1.1 haya #define CARDSLOT_EVENT_REMOVAL_16 1 104 1.1 haya 105 1.1 haya #define CARDSLOT_EVENT_INSERTION_CB 2 106 1.1 haya #define CARDSLOT_EVENT_REMOVAL_CB 3 107 1.1 haya 108 1.1 haya #define IS_CARDSLOT_INSERT_REMOVE_EV(x) (0 <= (x) && (x) <= 3) 109 1.1 haya 110 1.13 drochner void cardslot_event_throw(struct cardslot_softc *, int); 111 1.1 haya 112 1.4 kleink #endif /* !_DEV_CARDBUS_CARDSLOTVAR_H_ */ 113