exca.c (120872) | exca.c (133782) |
---|---|
1/* 2 * Copyright (c) 2002 M Warner Losh. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 39 unchanged lines hidden (view full) --- 48 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 49 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 50 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 51 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 52 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 53 */ 54 55#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 2002 M Warner Losh. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 39 unchanged lines hidden (view full) --- 48 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 49 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 50 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 51 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 52 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 53 */ 54 55#include <sys/cdefs.h> |
56__FBSDID("$FreeBSD: head/sys/dev/exca/exca.c 120872 2003-10-07 04:29:04Z imp $"); | 56__FBSDID("$FreeBSD: head/sys/dev/exca/exca.c 133782 2004-08-15 23:17:54Z imp $"); |
57 58#include <sys/param.h> 59#include <sys/systm.h> 60#include <sys/condvar.h> 61#include <sys/errno.h> 62#include <sys/kernel.h> 63#include <sys/malloc.h> 64#include <sys/queue.h> --- 8 unchanged lines hidden (view full) --- 73#include <machine/resource.h> 74 75#include <dev/pccard/pccardreg.h> 76#include <dev/pccard/pccardvar.h> 77 78#include <dev/exca/excareg.h> 79#include <dev/exca/excavar.h> 80 | 57 58#include <sys/param.h> 59#include <sys/systm.h> 60#include <sys/condvar.h> 61#include <sys/errno.h> 62#include <sys/kernel.h> 63#include <sys/malloc.h> 64#include <sys/queue.h> --- 8 unchanged lines hidden (view full) --- 73#include <machine/resource.h> 74 75#include <dev/pccard/pccardreg.h> 76#include <dev/pccard/pccardvar.h> 77 78#include <dev/exca/excareg.h> 79#include <dev/exca/excavar.h> 80 |
81#define EXCA_DEBUG |
|
81#ifdef EXCA_DEBUG 82#define DEVPRINTF(dev, fmt, args...) device_printf((dev), (fmt), ## args) 83#define DPRINTF(fmt, args...) printf(fmt, ## args) 84#else 85#define DEVPRINTF(dev, fmt, args...) 86#define DPRINTF(fmt, args...) 87#endif 88 --- 101 unchanged lines hidden (view full) --- 190 EXCA_SYSMEM_ADDRX_START_MSB_ADDR_MASK)); 191 192 exca_putb(sc, map->sysmem_stop_lsb, 193 ((mem->addr + mem->realsize - 1) >> 194 EXCA_SYSMEM_ADDRX_SHIFT) & 0xff); 195 exca_putb(sc, map->sysmem_stop_msb, 196 (((mem->addr + mem->realsize - 1) >> 197 (EXCA_SYSMEM_ADDRX_SHIFT + 8)) & | 82#ifdef EXCA_DEBUG 83#define DEVPRINTF(dev, fmt, args...) device_printf((dev), (fmt), ## args) 84#define DPRINTF(fmt, args...) printf(fmt, ## args) 85#else 86#define DEVPRINTF(dev, fmt, args...) 87#define DPRINTF(fmt, args...) 88#endif 89 --- 101 unchanged lines hidden (view full) --- 191 EXCA_SYSMEM_ADDRX_START_MSB_ADDR_MASK)); 192 193 exca_putb(sc, map->sysmem_stop_lsb, 194 ((mem->addr + mem->realsize - 1) >> 195 EXCA_SYSMEM_ADDRX_SHIFT) & 0xff); 196 exca_putb(sc, map->sysmem_stop_msb, 197 (((mem->addr + mem->realsize - 1) >> 198 (EXCA_SYSMEM_ADDRX_SHIFT + 8)) & |
198 EXCA_SYSMEM_ADDRX_STOP_MSB_ADDR_MASK)); | 199 EXCA_SYSMEM_ADDRX_STOP_MSB_ADDR_MASK) | 200 EXCA_SYSMEM_ADDRX_STOP_MSB_WAIT2); |
199 200 exca_putb(sc, map->sysmem_win, 201 (mem->addr >> EXCA_MEMREG_WIN_SHIFT) & 0xff); 202 203 exca_putb(sc, map->cardmem_lsb, 204 (mem->cardaddr >> EXCA_CARDMEM_ADDRX_SHIFT) & 0xff); 205 exca_putb(sc, map->cardmem_msb, 206 ((mem->cardaddr >> (EXCA_CARDMEM_ADDRX_SHIFT + 8)) & 207 EXCA_CARDMEM_ADDRX_MSB_ADDR_MASK) | 208 ((mem->kind == PCCARD_A_MEM_ATTR) ? 209 EXCA_CARDMEM_ADDRX_MSB_REGACTIVE_ATTR : 0)); 210 | 201 202 exca_putb(sc, map->sysmem_win, 203 (mem->addr >> EXCA_MEMREG_WIN_SHIFT) & 0xff); 204 205 exca_putb(sc, map->cardmem_lsb, 206 (mem->cardaddr >> EXCA_CARDMEM_ADDRX_SHIFT) & 0xff); 207 exca_putb(sc, map->cardmem_msb, 208 ((mem->cardaddr >> (EXCA_CARDMEM_ADDRX_SHIFT + 8)) & 209 EXCA_CARDMEM_ADDRX_MSB_ADDR_MASK) | 210 ((mem->kind == PCCARD_A_MEM_ATTR) ? 211 EXCA_CARDMEM_ADDRX_MSB_REGACTIVE_ATTR : 0)); 212 |
211 exca_setb(sc, EXCA_ADDRWIN_ENABLE, map->memenable); | |
212#ifdef EXCA_DEBUG 213 if (mem->kind == PCCARD_A_MEM_ATTR) 214 printf("attribtue memory\n"); 215 else 216 printf("common memory\n"); 217#endif | 213#ifdef EXCA_DEBUG 214 if (mem->kind == PCCARD_A_MEM_ATTR) 215 printf("attribtue memory\n"); 216 else 217 printf("common memory\n"); 218#endif |
218 exca_setb(sc, EXCA_ADDRWIN_ENABLE, EXCA_ADDRWIN_ENABLE_MEMCS16); | 219 exca_setb(sc, EXCA_ADDRWIN_ENABLE, map->memenable | 220 EXCA_ADDRWIN_ENABLE_MEMCS16); |
219 220 DELAY(100); 221#ifdef EXCA_DEBUG 222 { 223 int r1, r2, r3, r4, r5, r6, r7; 224 r1 = exca_getb(sc, map->sysmem_start_msb); 225 r2 = exca_getb(sc, map->sysmem_start_lsb); 226 r3 = exca_getb(sc, map->sysmem_stop_msb); 227 r4 = exca_getb(sc, map->sysmem_stop_lsb); 228 r5 = exca_getb(sc, map->cardmem_msb); 229 r6 = exca_getb(sc, map->cardmem_lsb); 230 r7 = exca_getb(sc, map->sysmem_win); | 221 222 DELAY(100); 223#ifdef EXCA_DEBUG 224 { 225 int r1, r2, r3, r4, r5, r6, r7; 226 r1 = exca_getb(sc, map->sysmem_start_msb); 227 r2 = exca_getb(sc, map->sysmem_start_lsb); 228 r3 = exca_getb(sc, map->sysmem_stop_msb); 229 r4 = exca_getb(sc, map->sysmem_stop_lsb); 230 r5 = exca_getb(sc, map->cardmem_msb); 231 r6 = exca_getb(sc, map->cardmem_lsb); 232 r7 = exca_getb(sc, map->sysmem_win); |
231 printf("exca_do_mem_map window %d: %02x%02x %02x%02x " 232 "%02x%02x %02x (%08x+%08x.%08x*%08x)\n", | 233 printf("exca_do_mem_map win %d: %02x%02x %02x%02x " 234 "%02x%02x %02x (%08x+%06x.%06x*%06x)\n", |
233 win, r1, r2, r3, r4, r5, r6, r7, 234 mem->addr, mem->size, mem->realsize, 235 mem->cardaddr); 236 } 237#endif 238} 239 240/* --- 578 unchanged lines hidden (view full) --- 819 return (ENOENT); 820 break; 821 } 822 } 823 return (BUS_DEACTIVATE_RESOURCE(device_get_parent(exca->dev), child, 824 type, rid, res)); 825} 826 | 235 win, r1, r2, r3, r4, r5, r6, r7, 236 mem->addr, mem->size, mem->realsize, 237 mem->cardaddr); 238 } 239#endif 240} 241 242/* --- 578 unchanged lines hidden (view full) --- 821 return (ENOENT); 822 break; 823 } 824 } 825 return (BUS_DEACTIVATE_RESOURCE(device_get_parent(exca->dev), child, 826 type, rid, res)); 827} 828 |
829#if 0 830static struct resource * 831exca_alloc_resource(struct exca_softc *sc, device_t child, int type, int *rid, 832 u_long start, u_long end, u_long count, uint flags) 833{ 834 struct resource *res = NULL; 835 int tmp; 836 837 switch (type) { 838 case SYS_RES_MEMORY: 839 if (start < cbb_start_mem) 840 start = cbb_start_mem; 841 if (end < start) 842 end = start; 843 flags = (flags & ~RF_ALIGNMENT_MASK) | 844 rman_make_alignment_flags(CBB_MEMALIGN); 845 break; 846 case SYS_RES_IOPORT: 847 if (start < cbb_start_16_io) 848 start = cbb_start_16_io; 849 if (end < start) 850 end = start; 851 break; 852 case SYS_RES_IRQ: 853 tmp = rman_get_start(sc->irq_res); 854 if (start > tmp || end < tmp || count != 1) { 855 device_printf(child, "requested interrupt %ld-%ld," 856 "count = %ld not supported by cbb\n", 857 start, end, count); 858 return (NULL); 859 } 860 flags |= RF_SHAREABLE; 861 start = end = rman_get_start(sc->irq_res); 862 break; 863 } 864 res = BUS_ALLOC_RESOURCE(up, child, type, rid, 865 start, end, count, flags & ~RF_ACTIVE); 866 if (res == NULL) 867 return (NULL); 868 cbb_insert_res(sc, res, type, *rid); 869 if (flags & RF_ACTIVE) { 870 if (bus_activate_resource(child, type, *rid, res) != 0) { 871 bus_release_resource(child, type, *rid, res); 872 return (NULL); 873 } 874 } 875 876 return (res); 877} 878 |
|
827static int | 879static int |
880exca_release_resource(struct exca_softc *sc, device_t child, int type, 881 int rid, struct resource *res) 882{ 883 int error; 884 885 if (rman_get_flags(res) & RF_ACTIVE) { 886 error = bus_deactivate_resource(child, type, rid, res); 887 if (error != 0) 888 return (error); 889 } 890 cbb_remove_res(sc, res); 891 return (BUS_RELEASE_RESOURCE(device_get_parent(brdev), child, 892 type, rid, res)); 893} 894#endif 895 896static int |
|
828exca_modevent(module_t mod, int cmd, void *arg) 829{ 830 return 0; 831} 832 833DEV_MODULE(exca, exca_modevent, NULL); 834MODULE_VERSION(exca, 1); | 897exca_modevent(module_t mod, int cmd, void *arg) 898{ 899 return 0; 900} 901 902DEV_MODULE(exca, exca_modevent, NULL); 903MODULE_VERSION(exca, 1); |