printf("pcic_map_mem %p %lx %x %x %x\n", haddr, physaddr, start, len, flags);
printf("pcic_map_mem %p %x %x %x %x\n", haddr, physaddr, start, len, flags);
pcic_map_mem(link, memt, haddr, start, len, flags)	struct pcmcia_link *link;	bus_space_tag_t memt;	caddr_t		haddr;	u_int           start, len;	int		flags;{	vm_offset_t     physaddr;	struct pcic_softc *sc = link->adapter->adapter_softc;	struct slot    *slot;	if (link->slot >= sc->sc_adapter.nslots)		return ENXIO;	slot = &sc->slot[link->slot];	if (flags & PCMCIA_PHYSICAL_ADDR)		physaddr = (vm_offset_t) haddr;	else		physaddr = pmap_extract(pmap_kernel(), (vm_offset_t) haddr);	if (PDEBUG(PCDMEM))		printf("pcic_map_mem %p %lx %x %x %x\n", haddr, physaddr,		       start, len, flags);	(u_long) physaddr >>= 12;	start >>= 12;	len = (len - 1) >> 12;	if (!(flags & PCMCIA_UNMAP)) {		u_int           offs;		u_int           stop;		int             window;		int             winid;		if (flags & PCMCIA_LAST_WIN) {			window = MAX_MEMSECTION - 1;		} else if (flags & PCMCIA_FIRST_WIN) {			window = 0;		} else if (flags & PCMCIA_ANY_WIN) {			for (window = 0; window < MAX_MEMSECTION; window++) {				if (slot->mem_used[window] == 0)					break;				if (window >= MAX_MEMSECTION)					return EBUSY;			}		} else {			window = flags & 0xf;			if (window >= MAX_MEMSECTION)				return EINVAL;		}		slot->mem_used[window] = 1;		offs = (start - (u_long) physaddr) & 0x3fff;		if (PDEBUG(PCDMEM))			printf("mapmem 2:%x %lx %x\n", offs, physaddr + offs,			       start);		stop = (u_long) physaddr + len;		winid = window * 0x8 + 0x10;		pcic_wr(slot, winid | PCIC_START | PCIC_ADDR_LOW,			(u_long) physaddr & 0xff);		pcic_wr(slot, winid | PCIC_START | PCIC_ADDR_HIGH,			(((u_long) physaddr >> 8) & 0x3f) |		/* PCIC_ZEROWS| */			((flags & PCMCIA_MAP_16) ? PCIC_DATA16 : 0));		pcic_wr(slot, winid | PCIC_END | PCIC_ADDR_LOW,			stop & 0xff);		pcic_wr(slot, winid | PCIC_END | PCIC_ADDR_HIGH,			PCIC_MW1 | ((stop >> 8) & 0x3f));		pcic_wr(slot, winid | PCIC_MOFF | PCIC_ADDR_LOW,			offs & 0xff);		pcic_wr(slot, winid | PCIC_MOFF | PCIC_ADDR_HIGH,			((offs >> 8) & 0x3f) |			((flags & PCMCIA_MAP_ATTR) ? PCIC_REG : 0));		delay(1000);		pcic_wr(slot, PCIC_ADDRWINE,			slot->region_flag |= ((1 << window) | PCIC_MEMCS16));		slot->mem_caddr[window] = (caddr_t) physaddr;		slot->mem_haddr[window] = start;		slot->mem_len[window] = len;		delay(1000);		return 0;	} else {		int             window;		int             winid;		if (flags & PCMCIA_LAST_WIN) {			window = MAX_MEMSECTION - 1;		} else if (flags & PCMCIA_FIRST_WIN) {			window = 0;		} else if (flags & PCMCIA_ANY_WIN) {			for (window = 0; window < MAX_MEMSECTION; window++) {				if ((slot->mem_caddr[window] ==				     (caddr_t) physaddr) &&				    ((start == -1) ||				     (slot->mem_haddr[window] == start)) &&				    ((len == -1) ||				     (slot->mem_len[window] == len)))					break;			}			if (window >= MAX_MEMSECTION)				return EINVAL;		} else {			window = flags & 0xf;			if (window >= MAX_MEMSECTION)				return EINVAL;		}		winid = window * 0x8 + 0x10;		slot->region_flag &= (~(1 << window));		pcic_wr(slot, PCIC_ADDRWINE, slot->region_flag);		delay(1000);		pcic_wr(slot, winid | PCIC_START | PCIC_ADDR_LOW, 0);		pcic_wr(slot, winid | PCIC_START | PCIC_ADDR_HIGH, 0);		pcic_wr(slot, winid | PCIC_END | PCIC_ADDR_LOW, 0);		pcic_wr(slot, winid | PCIC_END | PCIC_ADDR_HIGH, 0);		pcic_wr(slot, winid | PCIC_MOFF | PCIC_ADDR_LOW, 0);		pcic_wr(slot, winid | PCIC_MOFF | PCIC_ADDR_HIGH, 0);		slot->mem_caddr[window] = 0;		slot->mem_haddr[window] = 0;		slot->mem_len[window] = 0;		slot->mem_used[window] = 0;		return 0;	}}