From owner-svn-src-head@FreeBSD.ORG Mon Jan 5 21:00:22 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 855E1106566C; Mon, 5 Jan 2009 21:00:22 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 741F68FC17; Mon, 5 Jan 2009 21:00:22 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n05L0MUH011138; Mon, 5 Jan 2009 21:00:22 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n05L0McF011137; Mon, 5 Jan 2009 21:00:22 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <200901052100.n05L0McF011137@svn.freebsd.org> From: Warner Losh Date: Mon, 5 Jan 2009 21:00:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186796 - head/sys/dev/exca X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Jan 2009 21:00:23 -0000 Author: imp Date: Mon Jan 5 21:00:22 2009 New Revision: 186796 URL: http://svn.freebsd.org/changeset/base/186796 Log: First cut at fixing memory mapping botch. Nobody must use the ray(4) driver since it couldn't have worked with NEWCARD w/o these fixes. This should allow selecting 16-bit memory width as well (which was what was broken). Modified: head/sys/dev/exca/exca.c Modified: head/sys/dev/exca/exca.c ============================================================================== --- head/sys/dev/exca/exca.c Mon Jan 5 20:58:41 2009 (r186795) +++ head/sys/dev/exca/exca.c Mon Jan 5 21:00:22 2009 (r186796) @@ -179,39 +179,38 @@ exca_do_mem_map(struct exca_softc *sc, i struct mem_map_index_st *map; struct pccard_mem_handle *mem; uint32_t offset; - int mem8 = 1 /* mem->kind == PCCARD_A_MEM_ATTR */; + uint32_t mem16; + uint32_t attrmem; map = &mem_map_index[win]; mem = &sc->mem[win]; + mem16 = (mem->kind & PCCARD_MEM_16BIT) ? + EXCA_SYSMEM_ADDRX_START_MSB_DATASIZE_16BIT : 0; + attrmem = (mem->kind & PCCARD_MEM_ATTR) ? + EXCA_CARDMEM_ADDRX_MSB_REGACTIVE_ATTR : 0; offset = ((mem->cardaddr >> EXCA_CARDMEM_ADDRX_SHIFT) - (mem->addr >> EXCA_SYSMEM_ADDRX_SHIFT)) & 0x3fff; exca_putb(sc, map->sysmem_start_lsb, - (mem->addr >> EXCA_SYSMEM_ADDRX_SHIFT) & 0xff); + mem->addr >> EXCA_SYSMEM_ADDRX_SHIFT); exca_putb(sc, map->sysmem_start_msb, ((mem->addr >> (EXCA_SYSMEM_ADDRX_SHIFT + 8)) & - EXCA_SYSMEM_ADDRX_START_MSB_ADDR_MASK) | - (mem8 ? 0 : EXCA_SYSMEM_ADDRX_START_MSB_DATASIZE_16BIT)); + EXCA_SYSMEM_ADDRX_START_MSB_ADDR_MASK) | mem16); exca_putb(sc, map->sysmem_stop_lsb, - ((mem->addr + mem->realsize - 1) >> - EXCA_SYSMEM_ADDRX_SHIFT) & 0xff); + (mem->addr + mem->realsize - 1) >> EXCA_SYSMEM_ADDRX_SHIFT); exca_putb(sc, map->sysmem_stop_msb, (((mem->addr + mem->realsize - 1) >> (EXCA_SYSMEM_ADDRX_SHIFT + 8)) & EXCA_SYSMEM_ADDRX_STOP_MSB_ADDR_MASK) | EXCA_SYSMEM_ADDRX_STOP_MSB_WAIT2); - - exca_putb(sc, map->sysmem_win, - (mem->addr >> EXCA_MEMREG_WIN_SHIFT) & 0xff); + exca_putb(sc, map->sysmem_win, mem->addr >> EXCA_MEMREG_WIN_SHIFT); exca_putb(sc, map->cardmem_lsb, offset & 0xff); - exca_putb(sc, map->cardmem_msb, (((offset >> 8) & 0xff) & - EXCA_CARDMEM_ADDRX_MSB_ADDR_MASK) | - ((mem->kind == PCCARD_A_MEM_ATTR) ? - EXCA_CARDMEM_ADDRX_MSB_REGACTIVE_ATTR : 0)); + exca_putb(sc, map->cardmem_msb, ((offset >> 8) & + EXCA_CARDMEM_ADDRX_MSB_ADDR_MASK) | attrmem); #ifdef EXCA_DEBUG - if (mem->kind == PCCARD_A_MEM_ATTR) + if (mem->kind & PCCARD_MEM_ATTR) printf("attribtue memory\n"); else printf("common memory\n"); @@ -342,7 +341,21 @@ exca_mem_set_flags(struct exca_softc *sc return (ENOENT); } - sc->mem[win].kind = flags; + switch (flags) + { + case PCCARD_A_MEM_ATTR: + sc->mem[win].kind |= PCCARD_MEM_ATTR; + break; + case PCCARD_A_MEM_COM: + sc->mem[win].kind &= ~PCCARD_MEM_ATTR; + break; + case PCCARD_A_MEM_16BIT: + sc->mem[win].kind |= PCCARD_MEM_16BIT; + break; + case PCCARD_A_MEM_8BIT: + sc->mem[win].kind &= ~PCCARD_MEM_16BIT; + break; + } exca_do_mem_map(sc, win); return (0); } @@ -801,7 +814,7 @@ exca_activate_resource(struct exca_softc err = exca_io_map(exca, PCCARD_WIDTH_AUTO, res); break; case SYS_RES_MEMORY: - err = exca_mem_map(exca, PCCARD_A_MEM_COM, res); + err = exca_mem_map(exca, 0, res); break; } if (err)