From owner-svn-src-user@FreeBSD.ORG Sun Jul 24 18:16:15 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 06D2E106566B; Sun, 24 Jul 2011 18:16:15 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EB1E68FC16; Sun, 24 Jul 2011 18:16:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6OIGEc4019181; Sun, 24 Jul 2011 18:16:14 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6OIGE8a019179; Sun, 24 Jul 2011 18:16:14 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201107241816.p6OIGE8a019179@svn.freebsd.org> From: Gabor Kovesdan Date: Sun, 24 Jul 2011 18:16:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224293 - user/gabor/tre-integration/contrib/tre/lib X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Jul 2011 18:16:15 -0000 Author: gabor Date: Sun Jul 24 18:16:14 2011 New Revision: 224293 URL: http://svn.freebsd.org/changeset/base/224293 Log: - Actually fix shifting Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Sun Jul 24 18:03:02 2011 (r224292) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Sun Jul 24 18:16:14 2011 (r224293) @@ -375,15 +375,15 @@ tre_fastexec(const fastmatch_t *fg, cons switch (type) { case STR_BYTE: - wc = btowc(((char *)startptr)[mismatch]); + wc = btowc(((char *)startptr)[mismatch + 1]); r = hashtable_get(fg->qsBc, &wc, &k); break; case STR_MBS: - tre_mbrtowc(&wc, &((char *)startptr)[mismatch], MB_CUR_MAX, NULL); + tre_mbrtowc(&wc, &((char *)startptr)[mismatch + 1], MB_CUR_MAX, NULL); r = hashtable_get(fg->qsBc, &wc, &k); break; case STR_WIDE: - r = hashtable_get(fg->qsBc, &((char *)startptr)[mismatch], &k); + r = hashtable_get(fg->qsBc, &((char *)startptr)[mismatch + 1], &k); break; default: /* XXX */ From owner-svn-src-user@FreeBSD.ORG Mon Jul 25 06:31:04 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8A9081065674; Mon, 25 Jul 2011 06:31:04 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7AEA68FC13; Mon, 25 Jul 2011 06:31:04 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6P6V4C2041319; Mon, 25 Jul 2011 06:31:04 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6P6V4EW041317; Mon, 25 Jul 2011 06:31:04 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201107250631.p6P6V4EW041317@svn.freebsd.org> From: Hiroki Sato Date: Mon, 25 Jul 2011 06:31:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224303 - user/hrs/ipv6/usr.sbin/rtadvd X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jul 2011 06:31:04 -0000 Author: hrs Date: Mon Jul 25 06:31:04 2011 New Revision: 224303 URL: http://svn.freebsd.org/changeset/base/224303 Log: Fix an abnormal termination caused by twice of "rtadvctl disable". Modified: user/hrs/ipv6/usr.sbin/rtadvd/control_server.c Modified: user/hrs/ipv6/usr.sbin/rtadvd/control_server.c ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvd/control_server.c Mon Jul 25 01:42:51 2011 (r224302) +++ user/hrs/ipv6/usr.sbin/rtadvd/control_server.c Mon Jul 25 06:31:04 2011 (r224303) @@ -51,6 +51,7 @@ #include "pathnames.h" #include "rtadvd.h" #include "if.h" +#include "config.h" #include "control.h" #include "control_server.h" #include "timer.h" @@ -611,7 +612,16 @@ cmsg_setprop_disable(struct ctrl_msg_pl return (1); } - ifi->ifi_persist = 0; + if (ifi->ifi_persist == 1) { + ifi->ifi_persist = 0; + rm_ifinfo(ifi); + + /* MC leaving needed here */ + sock_mc_leave(&sock, ifi->ifi_ifindex); + + set_do_reload_ifname(ifi->ifi_ifname); + set_do_reload(0); + } return (0); } From owner-svn-src-user@FreeBSD.ORG Mon Jul 25 06:31:31 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D77E9106566B; Mon, 25 Jul 2011 06:31:31 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AE7398FC16; Mon, 25 Jul 2011 06:31:31 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6P6VV8N041368; Mon, 25 Jul 2011 06:31:31 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6P6VV22041366; Mon, 25 Jul 2011 06:31:31 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201107250631.p6P6VV22041366@svn.freebsd.org> From: Hiroki Sato Date: Mon, 25 Jul 2011 06:31:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224304 - user/hrs/ipv6/usr.sbin/rtadvd X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jul 2011 06:31:31 -0000 Author: hrs Date: Mon Jul 25 06:31:31 2011 New Revision: 224304 URL: http://svn.freebsd.org/changeset/base/224304 Log: Use poll() to wait for the control message socket instead of a spin loop. Modified: user/hrs/ipv6/usr.sbin/rtadvd/control.c Modified: user/hrs/ipv6/usr.sbin/rtadvd/control.c ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvd/control.c Mon Jul 25 06:31:04 2011 (r224303) +++ user/hrs/ipv6/usr.sbin/rtadvd/control.c Mon Jul 25 06:31:31 2011 (r224304) @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -53,12 +54,16 @@ #include "pathnames.h" #include "control.h" +#define CMSG_RECV_TIMEOUT 30 + int cmsg_recv(int fd, char *buf) { int n; struct ctrl_msg_hdr *cm; char *msg; + struct pollfd pfds[1]; + int i; syslog(LOG_DEBUG, "<%s> enter, fd=%d", __func__, fd); @@ -66,14 +71,31 @@ cmsg_recv(int fd, char *buf) cm = (struct ctrl_msg_hdr *)buf; msg = (char *)buf + sizeof(*cm); + pfds[0].fd = fd; + pfds[0].events = POLLIN; + for (;;) { - n = read(fd, cm, sizeof(*cm)); - if (n < 0 && errno == EAGAIN) { - syslog(LOG_DEBUG, - "<%s> waiting...", __func__); + i = poll(pfds, sizeof(pfds)/sizeof(pfds[0]), + CMSG_RECV_TIMEOUT); + + if (i == 0) + continue; + + if (i < 0) { + syslog(LOG_ERR, "<%s> poll error: %s", + __func__, strerror(errno)); continue; } - break; + + if (pfds[0].revents & POLLIN) { + n = read(fd, cm, sizeof(*cm)); + if (n < 0 && errno == EAGAIN) { + syslog(LOG_DEBUG, + "<%s> waiting...", __func__); + continue; + } + break; + } } if (n != sizeof(*cm)) { @@ -109,12 +131,26 @@ cmsg_recv(int fd, char *buf) msglen); for (;;) { - n = read(fd, msg, msglen); - if (n < 0 && errno == EAGAIN) { - syslog(LOG_DEBUG, - "<%s> waiting...", __func__); + i = poll(pfds, sizeof(pfds)/sizeof(pfds[0]), + CMSG_RECV_TIMEOUT); + + if (i == 0) + continue; + + if (i < 0) { + syslog(LOG_ERR, "<%s> poll error: %s", + __func__, strerror(errno)); continue; } + + if (pfds[0].revents & POLLIN) { + n = read(fd, msg, msglen); + if (n < 0 && errno == EAGAIN) { + syslog(LOG_DEBUG, + "<%s> waiting...", __func__); + continue; + } + } break; } if (n != msglen) { From owner-svn-src-user@FreeBSD.ORG Mon Jul 25 07:14:59 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C01E9106566B; Mon, 25 Jul 2011 07:14:59 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B0B718FC14; Mon, 25 Jul 2011 07:14:59 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6P7Ex7l042792; Mon, 25 Jul 2011 07:14:59 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6P7ExoD042790; Mon, 25 Jul 2011 07:14:59 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201107250714.p6P7ExoD042790@svn.freebsd.org> From: Hiroki Sato Date: Mon, 25 Jul 2011 07:14:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224305 - user/hrs/ipv6/usr.sbin/rtadvctl X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jul 2011 07:14:59 -0000 Author: hrs Date: Mon Jul 25 07:14:59 2011 New Revision: 224305 URL: http://svn.freebsd.org/changeset/base/224305 Log: Add a closing '.El' tag (r224148). Modified: user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.8 Modified: user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.8 ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.8 Mon Jul 25 06:31:31 2011 (r224304) +++ user/hrs/ipv6/usr.sbin/rtadvctl/rtadvctl.8 Mon Jul 25 07:14:59 2011 (r224305) @@ -89,6 +89,7 @@ It will take at most nine seconds. .It show Op interfaces... Displays information on Router Advertisement messages being sent on each interface. +.El .Sh SEE ALSO .Xr rtadvd 8 , .Xr rtadvd.conf 5 From owner-svn-src-user@FreeBSD.ORG Mon Jul 25 16:45:48 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3A0111065679; Mon, 25 Jul 2011 16:45:48 +0000 (UTC) (envelope-from jchandra@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 287348FC1D; Mon, 25 Jul 2011 16:45:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6PGjmaY065579; Mon, 25 Jul 2011 16:45:48 GMT (envelope-from jchandra@svn.freebsd.org) Received: (from jchandra@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6PGjmOb065567; Mon, 25 Jul 2011 16:45:48 GMT (envelope-from jchandra@svn.freebsd.org) Message-Id: <201107251645.p6PGjmOb065567@svn.freebsd.org> From: "Jayachandran C." Date: Mon, 25 Jul 2011 16:45:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224333 - in user/jchandra/mips-xlp-support/sys/mips: conf nlm nlm/hal X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jul 2011 16:45:48 -0000 Author: jchandra Date: Mon Jul 25 16:45:47 2011 New Revision: 224333 URL: http://svn.freebsd.org/changeset/base/224333 Log: Add PCI and USB support for Netlogic XLP boards. Remove iodi.c Use the PCI code and some fixups to handle internal PCI like bus. Added: user/jchandra/mips-xlp-support/sys/mips/nlm/hal/pcibus.h user/jchandra/mips-xlp-support/sys/mips/nlm/hal/usb.h user/jchandra/mips-xlp-support/sys/mips/nlm/intern_dev.c user/jchandra/mips-xlp-support/sys/mips/nlm/uart_cpu_xlp.c - copied unchanged from r224008, user/jchandra/mips-xlp-support/sys/mips/nlm/uart_cpu_mips_xlp.c user/jchandra/mips-xlp-support/sys/mips/nlm/uart_pci_xlp.c user/jchandra/mips-xlp-support/sys/mips/nlm/usb_init.c user/jchandra/mips-xlp-support/sys/mips/nlm/xlp_pci.c Deleted: user/jchandra/mips-xlp-support/sys/mips/nlm/iodi.c user/jchandra/mips-xlp-support/sys/mips/nlm/uart_cpu_mips_xlp.c Modified: user/jchandra/mips-xlp-support/sys/mips/conf/XLP user/jchandra/mips-xlp-support/sys/mips/conf/XLP64 user/jchandra/mips-xlp-support/sys/mips/nlm/files.xlp user/jchandra/mips-xlp-support/sys/mips/nlm/hal/iomap.h Modified: user/jchandra/mips-xlp-support/sys/mips/conf/XLP ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/conf/XLP Mon Jul 25 16:45:12 2011 (r224332) +++ user/jchandra/mips-xlp-support/sys/mips/conf/XLP Mon Jul 25 16:45:47 2011 (r224333) @@ -86,8 +86,16 @@ device md device pty device bpf -# UART +# Needed devices device uart +device pci # Network device ether + +device da +device scbus + +device usb +device ehci +device umass Modified: user/jchandra/mips-xlp-support/sys/mips/conf/XLP64 ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/conf/XLP64 Mon Jul 25 16:45:12 2011 (r224332) +++ user/jchandra/mips-xlp-support/sys/mips/conf/XLP64 Mon Jul 25 16:45:47 2011 (r224333) @@ -90,6 +90,14 @@ device bpf # UART device uart +device pci # Network device ether + +device da +device scbus + +device usb +device ehci +device umass Modified: user/jchandra/mips-xlp-support/sys/mips/nlm/files.xlp ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/nlm/files.xlp Mon Jul 25 16:45:12 2011 (r224332) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/files.xlp Mon Jul 25 16:45:47 2011 (r224333) @@ -3,10 +3,12 @@ mips/nlm/hal/fmn.c standard mips/nlm/xlp_machdep.c standard mips/nlm/intr_machdep.c standard mips/nlm/tick.c standard -mips/nlm/iodi.c standard mips/nlm/board.c standard mips/nlm/cms.c standard -mips/nlm/bus_space_rmi.c standard +mips/nlm/bus_space_rmi.c standard mips/nlm/mpreset.S standard -mips/nlm/uart_bus_xlp_iodi.c optional uart -mips/nlm/uart_cpu_mips_xlp.c optional uart +mips/nlm/xlp_pci.c optional pci +mips/nlm/intern_dev.c optional pci +mips/nlm/uart_pci_xlp.c optional uart +mips/nlm/uart_cpu_xlp.c optional uart +mips/nlm/usb_init.c optional usb Modified: user/jchandra/mips-xlp-support/sys/mips/nlm/hal/iomap.h ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/nlm/hal/iomap.h Mon Jul 25 16:45:12 2011 (r224332) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/hal/iomap.h Mon Jul 25 16:45:47 2011 (r224333) @@ -12,11 +12,11 @@ * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. - * + * * THIS SOFTWARE IS PROVIDED BY Netlogic Microsystems ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS @@ -39,9 +39,9 @@ /* ---------------------------------- * XLP RESET Physical Address Map * ---------------------------------- - * PCI ECFG : 0x18000000 - 0x1bffffff - * PCI CFG : 0x1c000000 - 0x1cffffff - * FLASH : 0x1fc00000 - 0x1fffffff + * PCI ECFG : 0x18000000 - 0x1bffffff + * PCI CFG : 0x1c000000 - 0x1cffffff + * FLASH : 0x1fc00000 - 0x1fffffff * ---------------------------------- */ @@ -124,6 +124,27 @@ #define XLP_PCI_UCODEINFO_REG 0x3e #define XLP_PCI_SBB_WT_REG 0x3f + +#define PCI_VENDOR_NETLOGIC 0x184e +#define PCI_DEVICE_ID_NLM_ROOT 0x1001 +#define PCI_DEVICE_ID_NLM_ICI 0x1002 +#define PCI_DEVICE_ID_NLM_PIC 0x1003 +#define PCI_DEVICE_ID_NLM_PCIE 0x1004 +#define PCI_DEVICE_ID_NLM_EHCI 0x1007 +#define PCI_DEVICE_ID_NLM_ILK 0x1008 +#define PCI_DEVICE_ID_NLM_NAE 0x1009 +#define PCI_DEVICE_ID_NLM_POE 0x100A +#define PCI_DEVICE_ID_NLM_FMN 0x100B +#define PCI_DEVICE_ID_NLM_RAID 0x100D +#define PCI_DEVICE_ID_NLM_SAE 0x100D +#define PCI_DEVICE_ID_NLM_RSA 0x100E +#define PCI_DEVICE_ID_NLM_CMP 0x100F +#define PCI_DEVICE_ID_NLM_UART 0x1010 +#define PCI_DEVICE_ID_NLM_I2C 0x1011 +#define PCI_DEVICE_ID_NLM_NOR 0x1015 +#define PCI_DEVICE_ID_NLM_NAND 0x1016 +#define PCI_DEVICE_ID_NLM_MMC 0x1018 + #if !defined(LOCORE) && !defined(__ASSEMBLY__) #ifndef __NLM_NLMIO_H__ Added: user/jchandra/mips-xlp-support/sys/mips/nlm/hal/pcibus.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/hal/pcibus.h Mon Jul 25 16:45:47 2011 (r224333) @@ -0,0 +1,87 @@ +/*- + * Copyright 2003-2011 Netlogic Microsystems (Netlogic). All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY Netlogic Microsystems ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + * + * NETLOGIC_BSD */ + +#ifndef __XLP_PCIBUS_H__ +#define __XLP_PCIBUS_H__ + +#define MSI_MIPS_ADDR_BASE 0xfee00000 +/* MSI support */ +#define MSI_MIPS_ADDR_DEST 0x000ff000 +#define MSI_MIPS_ADDR_RH 0x00000008 +#define MSI_MIPS_ADDR_RH_OFF 0x00000000 +#define MSI_MIPS_ADDR_RH_ON 0x00000008 +#define MSI_MIPS_ADDR_DM 0x00000004 +#define MSI_MIPS_ADDR_DM_PHYSICAL 0x00000000 +#define MSI_MIPS_ADDR_DM_LOGICAL 0x00000004 + +/* Fields in data for Intel MSI messages. */ +#define MSI_MIPS_DATA_TRGRMOD 0x00008000 /* Trigger mode */ +#define MSI_MIPS_DATA_TRGREDG 0x00000000 /* edge */ +#define MSI_MIPS_DATA_TRGRLVL 0x00008000 /* level */ + +#define MSI_MIPS_DATA_LEVEL 0x00004000 /* Polarity. */ +#define MSI_MIPS_DATA_DEASSERT 0x00000000 +#define MSI_MIPS_DATA_ASSERT 0x00004000 + +#define MSI_MIPS_DATA_DELMOD 0x00000700 /* Delivery Mode */ +#define MSI_MIPS_DATA_DELFIXED 0x00000000 /* fixed */ +#define MSI_MIPS_DATA_DELLOPRI 0x00000100 /* lowest priority */ + +#define MSI_MIPS_DATA_INTVEC 0x000000ff + +/* + * Build Intel MSI message and data values from a source. AMD64 systems + * seem to be compatible, so we use the same function for both. + */ +#define MIPS_MSI_ADDR(cpu) \ + (MSI_MIPS_ADDR_BASE | (cpu) << 12 | \ + MSI_MIPS_ADDR_RH_OFF | MSI_MIPS_ADDR_DM_PHYSICAL) + +#define MIPS_MSI_DATA(irq) \ + (MSI_MIPS_DATA_TRGRLVL | MSI_MIPS_DATA_DELFIXED | \ + MSI_MIPS_DATA_ASSERT | (irq)) + +#define XLP_PCIE_BRIDGE_CMD_REG 0x1 +#define XLP_PCIE_BRIDGE_MSI_CAP_REG 0x14 +#define XLP_PCIE_BRIDGE_MSI_ADDRL_REG 0x15 +#define XLP_PCIE_BRIDGE_MSI_ADDRH_REG 0x16 +#define XLP_PCIE_BRIDGE_MSI_DATA_REG 0x17 + +/* XLP Global PCIE configuration space registers */ +#define XLP_PCIE_MSI_STATUS_REG 0x25A +#define XLP_PCIE_MSI_EN_REG 0x25B +#define XLP_PCIE_INT_EN0_REG 0x261 + +/* XLP_PCIE_MSI_EN_REG */ +#define PCIE_MSI_VECTOR_INT_EN 0xFFFFFFFF + +/* XLP_PCIE_INT_EN0_REG */ +#define PCIE_MSI_INT_EN (1 << 9) + +#endif /* __XLP_PCIBUS_H__ */ Added: user/jchandra/mips-xlp-support/sys/mips/nlm/hal/usb.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/hal/usb.h Mon Jul 25 16:45:47 2011 (r224333) @@ -0,0 +1,57 @@ +/*- + * Copyright 2003-2011 Netlogic Microsystems (Netlogic). All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY Netlogic Microsystems ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + * + * NETLOGIC_BSD */ + +#ifndef __NLM_USB_H__ +#define __NLM_USB_H__ + +#define XLP_USB_CTL0 0x41 +#define XLP_USB_PHY0 0x4A +#define USBPHYRESET 0x01 +#define USBPHYPORTRESET0 0x10 +#define USBPHYPORTRESET1 0x20 +#define USBCONTROLLERRESET 0x01 +#define XLP_USB_INT_STATUS 0x4E +#define XLP_USB_INT_EN 0x4F +#define USB_PHY_INTERRUPT_EN 0x01 +#define USB_OHCI_INTERRUPT_EN 0x02 +#define USB_OHCI_INTERRUPT1_EN 0x04 +#define USB_OHCI_INTERRUPT12_EN 0x08 +#define USB_CTRL_INTERRUPT_EN 0x10 + + +#if !defined(LOCORE) && !defined(__ASSEMBLY__) + +#define nlm_rdreg_usb(b, r) nlm_read_reg_kseg(b,r) +#define nlm_wreg_usb(b, r, v) nlm_write_reg_kseg(b,r,v) +#define nlm_pcibase_usb(node, inst) nlm_pcicfg_base(XLP_IO_USB_OFFSET(node, inst)) +#define nlm_base_usb_pcibar(node, inst) nlm_pcibar0_base_xkphys(nlm_pcibase_usb(node, inst)) +#define nlm_regbase_usb(node, inst) (nlm_pcibase_usb(node, inst)) + +#endif +#endif Added: user/jchandra/mips-xlp-support/sys/mips/nlm/intern_dev.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/intern_dev.c Mon Jul 25 16:45:47 2011 (r224333) @@ -0,0 +1,86 @@ +/*- + * Copyright (c) 2011 Netlogic Microsystems Inc. + * + * (based on pci/ignore_pci.c) + * Copyright (c) 2000 Michael Smith + * Copyright (c) 2000 BSDi + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +/* + * 'Ignore' driver - eats devices that show up errnoeously on PCI + * but shouldn't ever be listed or handled by a driver. + */ + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +static int nlm_soc_pci_probe(device_t dev); + +static device_method_t nlm_soc_pci_methods[] = { + DEVMETHOD(device_probe, nlm_soc_pci_probe), + DEVMETHOD(device_attach, bus_generic_attach), + { 0, 0 } +}; + +static driver_t nlm_soc_pci_driver = { + "nlm_soc_pci", + nlm_soc_pci_methods, + 0, +}; + +static devclass_t nlm_soc_pci_devclass; +DRIVER_MODULE(nlm_soc_pci, pci, nlm_soc_pci_driver, nlm_soc_pci_devclass, 0, 0); + +static int +nlm_soc_pci_probe(device_t dev) +{ + if (pci_get_vendor(dev) != PCI_VENDOR_NETLOGIC) + return(ENXIO); + + /* Ignore SoC internal devices */ + switch (pci_get_device(dev)) { + case PCI_DEVICE_ID_NLM_ICI: + case PCI_DEVICE_ID_NLM_PIC: + case PCI_DEVICE_ID_NLM_FMN: + device_set_desc(dev, "Netlogic Internal"); + device_quiet(dev); + return(-10000); + + default: + return(ENXIO); + } +} Copied: user/jchandra/mips-xlp-support/sys/mips/nlm/uart_cpu_xlp.c (from r224008, user/jchandra/mips-xlp-support/sys/mips/nlm/uart_cpu_mips_xlp.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/uart_cpu_xlp.c Mon Jul 25 16:45:47 2011 (r224333, copy of r224008, user/jchandra/mips-xlp-support/sys/mips/nlm/uart_cpu_mips_xlp.c) @@ -0,0 +1,89 @@ +/*- + * Copyright 2003-2011 Netlogic Microsystems (Netlogic). All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY Netlogic Microsystems ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + * + * NETLOGIC_BSD */ + +/* + * Skeleton of this file was based on respective code for ARM + * code written by Olivier Houchard. + */ +/* + * XLRMIPS: This file is hacked from arm/... + */ +#include "opt_uart.h" + +#include +__FBSDID("$FreeBSD: head/sys/mips/rmi/uart_cpu_mips_xlr.c 202175 2010-01-12 21:36:08Z imp $"); + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include + +bus_space_tag_t uart_bus_space_io; +bus_space_tag_t uart_bus_space_mem; + +int +uart_cpu_eqres(struct uart_bas *b1, struct uart_bas *b2) +{ + return ((b1->bsh == b2->bsh && b1->bst == b2->bst) ? 1 : 0); +} + + +int +uart_cpu_getdev(int devtype, struct uart_devinfo *di) +{ + di->ops = uart_getops(&uart_ns8250_class); + di->bas.chan = 0; + di->bas.bst = rmi_bus_space; + di->bas.bsh = nlm_regbase_uart(0, 0) + XLP_IO_PCI_HDRSZ; + + di->bas.regshft = 2; + /* divisor = rclk / (baudrate * 16); */ + di->bas.rclk = 133000000; + di->baudrate = 115200; + di->databits = 8; + di->stopbits = 1; + di->parity = UART_PARITY_NONE; + + uart_bus_space_io = NULL; + uart_bus_space_mem = rmi_bus_space; + return (0); +} Added: user/jchandra/mips-xlp-support/sys/mips/nlm/uart_pci_xlp.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/uart_pci_xlp.c Mon Jul 25 16:45:47 2011 (r224333) @@ -0,0 +1,86 @@ +/*- + * Copyright (c) 2011 Netlogic Microsystems Inc. + * + * (based on dev/uart/uart_bus_pci.c) + * Copyright (c) 2006 Marcel Moolenaar + * Copyright (c) 2001 M. Warner Losh + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include + +static int uart_soc_probe(device_t dev); + +static device_method_t uart_soc_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, uart_soc_probe), + DEVMETHOD(device_attach, uart_bus_attach), + DEVMETHOD(device_detach, uart_bus_detach), + { 0, 0 } +}; + +static driver_t uart_soc_driver = { + uart_driver_name, + uart_soc_methods, + sizeof(struct uart_softc), +}; + +static int +uart_soc_probe(device_t dev) +{ + struct uart_softc *sc; + uint64_t ubase; + + if (pci_get_vendor(dev) != PCI_VENDOR_NETLOGIC || + pci_get_device(dev) != PCI_DEVICE_ID_NLM_UART) + return (ENXIO); + + ubase = nlm_regbase_uart(0, 0); + nlm_pci_wreg(ubase, 0xf, 0x1ff); + sc = device_get_softc(dev); + sc->sc_class = &uart_ns8250_class; + device_set_desc(dev, "Netlogic SoC UART"); + return (uart_bus_probe(dev, 2, 133000000, 0, 0)); +} + +DRIVER_MODULE(soc_uart, pci, uart_soc_driver, uart_devclass, 0, 0); Added: user/jchandra/mips-xlp-support/sys/mips/nlm/usb_init.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/usb_init.c Mon Jul 25 16:45:47 2011 (r224333) @@ -0,0 +1,91 @@ +/*- + * Copyright 2003-2011 Netlogic Microsystems (Netlogic). All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY Netlogic Microsystems ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + * + * NETLOGIC_BSD */ + +#include +__FBSDID("$FreeBSD: head/sys/mips/rmi/fmn.c 213474 2010-10-06 08:09:39Z jchandra $"); +#include +#include +#include +#include + +#include +#include +#include + +#include + + +static void +nlm_usb_intr_en(int node, int port) +{ + uint32_t val; + uint64_t port_addr; + + port_addr = nlm_regbase_usb(node, port); + val = nlm_rdreg_usb(port_addr, XLP_USB_INT_EN); + val = USB_CTRL_INTERRUPT_EN | USB_OHCI_INTERRUPT_EN | + USB_OHCI_INTERRUPT1_EN | USB_CTRL_INTERRUPT_EN | + USB_OHCI_INTERRUPT_EN | USB_OHCI_INTERRUPT12_EN; + nlm_wreg_usb(port_addr, XLP_USB_INT_EN, val); +} + +static void +nlm_usb_hw_reset(int node, int port) +{ + uint64_t port_addr; + uint32_t val; + + /* reset USB phy */ + port_addr = nlm_regbase_usb(node, port); + val = nlm_rdreg_usb(port_addr, XLP_USB_PHY0); + val &= ~(USBPHYRESET | USBPHYPORTRESET0 | USBPHYPORTRESET1); + nlm_wreg_usb(port_addr, XLP_USB_PHY0, val); + + DELAY(100); + val = nlm_rdreg_usb(port_addr, XLP_USB_CTL0); + val &= ~(USBCONTROLLERRESET); + val |= 0x4; + nlm_wreg_usb(port_addr, XLP_USB_CTL0, val); +} + +static void +nlm_usb_init(void) +{ + /* XXX: should be checking if these are in Device mode here */ + printf("Initialize USB Interface\n"); + nlm_usb_hw_reset(0, 0); + nlm_usb_hw_reset(0, 3); + + /* Enable PHY interrupts */ + nlm_usb_intr_en(0, 0); + nlm_usb_intr_en(0, 3); +} + +SYSINIT(nlm_usb_init, SI_SUB_CPU, SI_ORDER_MIDDLE, + nlm_usb_init, NULL); Added: user/jchandra/mips-xlp-support/sys/mips/nlm/xlp_pci.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/xlp_pci.c Mon Jul 25 16:45:47 2011 (r224333) @@ -0,0 +1,656 @@ +/*- + * Copyright (c) 2003-2009 RMI Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of RMI Corporation, nor the names of its contributors, + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * NETLOGIC_BSD */ +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "pcib_if.h" + +struct xlp_pcib_softc { + bus_dma_tag_t sc_pci_dmat; /* PCI DMA tag pointer */ +}; + +static devclass_t pcib_devclass; +static struct rman irq_rman, port_rman, mem_rman, emul_rman; + +static void +xlp_pci_init_resources(void) +{ + + irq_rman.rm_start = 0; + irq_rman.rm_end = 255; + irq_rman.rm_type = RMAN_ARRAY; + irq_rman.rm_descr = "PCI Mapped Interrupts"; + if (rman_init(&irq_rman) + || rman_manage_region(&irq_rman, 0, 255)) + panic("pci_init_resources irq_rman"); + + port_rman.rm_start = 0; + port_rman.rm_end = ~0u; + port_rman.rm_type = RMAN_ARRAY; + port_rman.rm_descr = "I/O ports"; + if (rman_init(&port_rman) + || rman_manage_region(&port_rman, 0x14000000UL, 0x15ffffffUL)) + panic("pci_init_resources port_rman"); + + mem_rman.rm_start = 0; + mem_rman.rm_end = ~0u; + mem_rman.rm_type = RMAN_ARRAY; + mem_rman.rm_descr = "I/O memory"; + if (rman_init(&mem_rman) + || rman_manage_region(&mem_rman, 0xd0000000ULL, 0xdfffffffULL)) + panic("pci_init_resources mem_rman"); + + emul_rman.rm_start = 0; + emul_rman.rm_end = ~0u; + emul_rman.rm_type = RMAN_ARRAY; + emul_rman.rm_descr = "Emulated MEMIO"; + if (rman_init(&emul_rman) + || rman_manage_region(&emul_rman, 0x18000000ULL, 0x18ffffffULL)) + panic("pci_init_resources emul_rman"); + +} + +static int +xlp_pcib_probe(device_t dev) +{ + + device_set_desc(dev, "XLP PCI bus"); + + xlp_pci_init_resources(); + return (0); +} + +static int +xlp_pcib_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) +{ + + switch (which) { + case PCIB_IVAR_DOMAIN: + *result = 0; + return (0); + case PCIB_IVAR_BUS: + *result = 0; + return (0); + } + return (ENOENT); +} + +static int +xlp_pcib_write_ivar(device_t dev, device_t child, int which, uintptr_t result) +{ + switch (which) { + case PCIB_IVAR_DOMAIN: + return (EINVAL); + case PCIB_IVAR_BUS: + return (EINVAL); + } + return (ENOENT); +} + +static int +xlp_pcib_maxslots(device_t dev) +{ + + return (PCI_SLOTMAX); +} + +static u_int32_t +xlp_pcib_read_config(device_t dev, u_int b, u_int s, u_int f, + u_int reg, int width) +{ + uint32_t data = 0; + uint64_t cfgaddr; + int regindex = reg/sizeof(uint32_t); + + cfgaddr = nlm_pcicfg_base(XLP_HDR_OFFSET(0, b, s, f)); + if ((width == 2) && (reg & 1)) + return 0xFFFFFFFF; + else if ((width == 4) && (reg & 3)) + return 0xFFFFFFFF; + + data = nlm_pci_rdreg(cfgaddr, regindex); + + /* + * Fix up read data in some SoC devices + * to emulate complete PCIe header + */ + if (b == 0) { + int dev = s % 8; + + /* Fake intpin on config read for UART/I2C, USB, SD/Flash */ + if (regindex == 0xf && + (dev == 6 || dev == 2 || dev == 7)) + data |= 0x1 << 8; /* Fake int pin */ + } + + if (width == 1) + return ((data >> ((reg & 3) << 3)) & 0xff); + else if (width == 2) + return ((data >> ((reg & 3) << 3)) & 0xffff); + else + return (data); +} + +static void +xlp_pcib_write_config(device_t dev, u_int b, u_int s, u_int f, + u_int reg, u_int32_t val, int width) +{ + uint64_t cfgaddr; + uint32_t data = 0; + int regindex = reg / sizeof(uint32_t); + + cfgaddr = nlm_pcicfg_base(XLP_HDR_OFFSET(0, b, s, f)); + if ((width == 2) && (reg & 1)) + return; + else if ((width == 4) && (reg & 3)) + return; + + if (width == 1) { + data = nlm_pci_rdreg(cfgaddr, regindex); + data = (data & ~(0xff << ((reg & 3) << 3))) | + (val << ((reg & 3) << 3)); + } else if (width == 2) { + data = nlm_pci_rdreg(cfgaddr, regindex); + data = (data & ~(0xffff << ((reg & 3) << 3))) | + (val << ((reg & 3) << 3)); + } else { + data = val; + } + + nlm_pci_wreg(cfgaddr, regindex, data); + + return; +} + +static int +xlp_pcib_attach(device_t dev) +{ + struct xlp_pcib_softc *sc; + sc = device_get_softc(dev); + + device_add_child(dev, "pci", 0); + bus_generic_attach(dev); + + return (0); +} + +static void +xlp_pcib_identify(driver_t * driver, device_t parent) +{ + + BUS_ADD_CHILD(parent, 0, "pcib", 0); +} + +/* + * XLS PCIe can have upto 4 links, and each link has its on IRQ + * Find the link on which the device is on + */ +static int +xlp_pcie_link(device_t pcib, device_t dev) +{ + device_t parent, tmp; + + /* find the lane on which the slot is connected to */ + printf("xlp_pcie_link : bus %s dev %s\n", device_get_nameunit(pcib), + device_get_nameunit(dev)); + tmp = dev; + while (1) { + parent = device_get_parent(tmp); + if (parent == NULL || parent == pcib) { + device_printf(dev, "Cannot find parent bus\n"); + return (-1); + } + if (strcmp(device_get_nameunit(parent), "pci0") == 0) + break; + tmp = parent; + } + return (pci_get_function(tmp)); +} + +/* + * Find the IRQ for the link, each link has a different interrupt + * at the XLP pic + */ +static int +xlp_pcie_link_irt(int link) +{ + + if( (link < 0) || (link > 3)) + return (-1); + + return XLP_PIC_IRT_PCIE_LINK_INDEX(link); +} + +static int +xlp_alloc_msi(device_t pcib, device_t dev, int count, int maxcount, int *irqs) +{ + int i, link; + + /* + * Each link has 32 MSIs that can be allocated, but for now + * we only support one device per link. + * msi_alloc() equivalent is needed when we start supporting + * bridges on the PCIe link. + */ + link = xlp_pcie_link(pcib, dev); + if (link == -1) + return (ENXIO); + + /* + * encode the irq so that we know it is a MSI interrupt when we + * setup interrupts + */ + for (i = 0; i < count; i++) + irqs[i] = 64 + link * 32 + i; + + return (0); +} + +static int +xlp_release_msi(device_t pcib, device_t dev, int count, int *irqs) +{ + device_printf(dev, "%s: msi release %d\n", device_get_nameunit(pcib), + count); + return (0); +} + +static int +xlp_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr, + uint32_t *data) +{ + int msi, irt; + + if (irq >= 64) { + msi = irq - 64; + *addr = MIPS_MSI_ADDR(0); + + irt = xlp_pcie_link_irt(msi/32); + if (irt != -1) + *data = MIPS_MSI_DATA(xlp_irt_to_irq(irt)); + return (0); + } else { + device_printf(dev, "%s: map_msi for irq %d - ignored", + device_get_nameunit(pcib), irq); + return (ENXIO); + } +} + +static void +bridge_pcie_ack(int irq) +{ + uint32_t node,reg; + uint64_t base; + + node = nlm_nodeid(); + reg = XLP_PCIE_MSI_STATUS_REG; + + switch(irq) { + case XLP_PIC_IRT_PCIE0_IRQ: + base = nlm_pcicfg_base(XLP_IO_PCIE0_OFFSET(node)); + break; + case XLP_PIC_IRT_PCIE1_IRQ: + base = nlm_pcicfg_base(XLP_IO_PCIE1_OFFSET(node)); + break; + case XLP_PIC_IRT_PCIE2_IRQ: + base = nlm_pcicfg_base(XLP_IO_PCIE2_OFFSET(node)); + break; + case XLP_PIC_IRT_PCIE3_IRQ: + base = nlm_pcicfg_base(XLP_IO_PCIE3_OFFSET(node)); + break; + default: + return; + } + + nlm_pci_wreg(base, reg, 0xFFFFFFFF); + + return; +} + +static int +mips_platform_pci_setup_intr(device_t dev, device_t child, + struct resource *irq, int flags, driver_filter_t *filt, *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Mon Jul 25 21:47:56 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 968E7106564A; Mon, 25 Jul 2011 21:47:56 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 85BD78FC0A; Mon, 25 Jul 2011 21:47:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6PLlu91078482; Mon, 25 Jul 2011 21:47:56 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6PLluZq078479; Mon, 25 Jul 2011 21:47:56 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201107252147.p6PLluZq078479@svn.freebsd.org> From: Gabor Kovesdan Date: Mon, 25 Jul 2011 21:47:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224407 - user/gabor/tre-integration/contrib/tre/lib X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jul 2011 21:47:56 -0000 Author: gabor Date: Mon Jul 25 21:47:56 2011 New Revision: 224407 URL: http://svn.freebsd.org/changeset/base/224407 Log: - Save the pattern in SB/MB string form, as well, to speed up matching SB/MB input - Macroify repeating code to eliminate duplication Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c user/gabor/tre-integration/contrib/tre/lib/fastmatch.h Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Mon Jul 25 21:44:35 2011 (r224406) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Mon Jul 25 21:47:56 2011 (r224407) @@ -41,9 +41,10 @@ #include "tre-internal.h" #include "xmalloc.h" -static int fastcmp(const tre_char_t *, const void *, size_t, +static int fastcmp(const void *, const void *, size_t, tre_str_type_t); static void revstr(tre_char_t *, int); +static void revs(char *str, int len); #ifdef TRE_WCHAR #define TRE_CHAR(n) L##n @@ -56,15 +57,8 @@ static void revstr(tre_char_t *, int); switch (type) \ { \ case STR_BYTE: \ - startptr = str_byte + n; \ - break; \ case STR_MBS: \ - for (skip = j = 0; j < n; j++) \ - { \ - siz = mbrlen(str_byte + skip, MB_CUR_MAX, NULL); \ - skip += siz; \ - } \ - startptr = str_byte + skip; \ + startptr = str_byte + n; \ break; \ case STR_WIDE: \ startptr = str_wide + n; \ @@ -75,40 +69,145 @@ static void revstr(tre_char_t *, int); } \ } while (0); \ +#define STORE_MBS_PAT \ + do { \ + size_t siz; \ + \ + siz = wcstombs(NULL, fg->wpattern, 0); \ + if (siz == (size_t)-1) \ + return REG_BADPAT; \ + fg->len = siz; \ + fg->pattern = xmalloc(siz + 1); \ + if (fg->pattern == NULL) \ + return REG_ESPACE; \ + wcstombs(fg->pattern, fg->wpattern, siz); \ + fg->pattern[siz] = '\0'; \ + } while (0); \ + +#define COMPARE \ + do { \ + switch (type) \ + { \ + case STR_BYTE: \ + case STR_MBS: \ + mismatch = fastcmp(fg->pattern, startptr, fg->len, type); \ + break; \ + case STR_WIDE: \ + mismatch = fastcmp(fg->wpattern, startptr, fg->wlen, type); \ + default: \ + break; \ + } \ + } while (0); + +#ifdef TRE_WCHAR +#define IS_OUT_OF_BOUNDS \ + ((type == STR_WIDE) ? ((j + fg->wlen) > len) : ((j + fg->len) > len)) +#else +#define IS_OUT_OF_BOUNDS ((j + fg->len) > len) +#endif + +#define CHECKBOUNDS \ + if (IS_OUT_OF_BOUNDS) \ + break; \ + +#ifdef TRE_WCHAR +#define SHIFT \ + CHECKBOUNDS; \ + { \ + int k = 0, r = -1; \ + \ + switch (type) \ + { \ + case STR_BYTE: \ + case STR_MBS: \ + k = fg->qsBc[(unsigned char)((char *)startptr) \ + [mismatch + 1]]; \ + break; \ + case STR_WIDE: \ + r = hashtable_get(fg->qsBc_table, \ + &((wchar_t *)startptr)[mismatch + 1], &k); \ + k = (r == 0) ? k : fg->defBc; \ + break; \ + default: \ + /* XXX */ \ + break; \ + } \ + j += k; \ + } +#else +#define SHIFT \ + CHECKBOUNDS; \ + j += fg->qsBc[(unsigned char)((char *)startptr)[mismatch + 1]]; +#endif + +/* + * Normal Quick Search would require a shift based on the position the + * next character after the comparison is within the pattern. With + * wildcards, the position of the last dot effects the maximum shift + * distance. + * The closer to the end the wild card is the slower the search. A + * reverse version of this algorithm would be useful for wildcards near + * the end of the string. + * + * Examples: + * Pattern Max shift + * ------- --------- + * this 5 + * .his 4 + * t.is 3 + * th.s 2 + * thi. 1 + */ + +#ifdef TRE_WCHAR +#define FILL_QSBC \ + /* Adjust the shift based on location of the last dot ('.'). */ \ + fg->defBc = fg->wlen - hasDot; \ + \ + /* Preprocess pattern. */ \ + fg->qsBc_table = hashtable_init(fg->wlen, sizeof(tre_char_t), \ + sizeof(int)); \ + for (unsigned int i = hasDot + 1; i < fg->wlen; i++) \ + { \ + int k = fg->wlen - i; \ + hashtable_put(fg->qsBc_table, &fg->wpattern[i], &k); \ + } \ + \ + for (unsigned int i = 0; i <= UCHAR_MAX; i++) \ + fg->qsBc[i] = fg->len - hasDot; \ + for (int i = hasDot + 1; i < fg->len; i++) \ + fg->qsBc[(unsigned)fg->pattern[i]] = fg->len - i; +#else +#define FILL_QSBC \ + for (unsigned int i = 0; i <= UCHAR_MAX; i++) \ + fg->qsBc[i] = fg->wlen - hasDot; \ + for (int i = hasDot + 1; i < fg->wlen; i++) \ + fg->qsBc[(unsigned)fg->wpattern[i]] = fg->wlen - i; +#endif + + /* * Returns: REG_OK on success, error code otherwise */ int -tre_fastcomp_literal(fastmatch_t *fg, const tre_char_t *pat, size_t n) +tre_fastcomp_literal(fastmatch_t *fg, const tre_char_t *wpat, size_t n) { + int hasDot = 0; /* Initialize. */ memset(fg, 0, sizeof(*fg)); - fg->len = (n == 0) ? tre_strlen(pat) : n; - fg->pattern = xmalloc((fg->len + 1) * sizeof(tre_char_t)); - if (fg->pattern == NULL) + fg->wlen = (n == 0) ? tre_strlen(wpat) : n; + fg->wpattern = xmalloc((fg->wlen + 1) * sizeof(tre_char_t)); + if (fg->wpattern == NULL) return REG_ESPACE; - memcpy(fg->pattern, pat, fg->len * sizeof(tre_char_t)); - fg->pattern[fg->len] = TRE_CHAR('\0'); - - /* Preprocess pattern. */ + memcpy(fg->wpattern, wpat, fg->wlen * sizeof(tre_char_t)); + fg->wpattern[fg->wlen] = TRE_CHAR('\0'); #ifdef TRE_WCHAR - fg->defBc = fg->len; - fg->qsBc = hashtable_init(fg->len * 3, sizeof(tre_char_t), sizeof(int)); - if (fg->qsBc == NULL) - return REG_ESPACE; - for (unsigned int i = 1; i < fg->len; i++) - { - int k = fg->len - i; - hashtable_put(fg->qsBc, &fg->pattern[i], &k); - } -#else - for (i = 0; i <= UCHAR_MAX; i++) - fg->qsBc[i] = fg->len; - for (i = 1; i < fg->len; i++) - fg->qsBc[fg->pattern[i]] = fg->len - i; + STORE_MBS_PAT; #endif + FILL_QSBC; + return REG_OK; } @@ -116,7 +215,7 @@ tre_fastcomp_literal(fastmatch_t *fg, co * Returns: REG_OK on success, error code otherwise */ int -tre_fastcomp(fastmatch_t *fg, const tre_char_t *pat, size_t n) +tre_fastcomp(fastmatch_t *fg, const tre_char_t *wpat, size_t n) { int firstHalfDot = -1; int firstLastHalfDot = -1; @@ -125,55 +224,58 @@ tre_fastcomp(fastmatch_t *fg, const tre_ /* Initialize. */ memset(fg, 0, sizeof(*fg)); - fg->len = (n == 0) ? tre_strlen(pat) : n; + fg->wlen = (n == 0) ? tre_strlen(wpat) : n; /* Remove end-of-line character ('$'). */ - if ((fg->len > 0) && (pat[fg->len - 1] == TRE_CHAR('$'))) + if ((fg->wlen > 0) && (wpat[fg->wlen - 1] == TRE_CHAR('$'))) { fg->eol = true; - fg->len--; + fg->wlen--; } /* Remove beginning-of-line character ('^'). */ - if (pat[0] == TRE_CHAR('^')) + if (wpat[0] == TRE_CHAR('^')) { fg->bol = true; - fg->len--; - pat++; + fg->wlen--; + wpat++; } - if ((fg->len >= 14) && - (memcmp(pat, TRE_CHAR("[[:<:]]"), 7 * sizeof(tre_char_t)) == 0) && - (memcmp(pat + fg->len - 7, TRE_CHAR("[[:>:]]"), + if ((fg->wlen >= 14) && + (memcmp(wpat, TRE_CHAR("[[:<:]]"), 7 * sizeof(tre_char_t)) == 0) && + (memcmp(wpat + fg->wlen - 7, TRE_CHAR("[[:>:]]"), 7 * sizeof(tre_char_t)) == 0)) { - fg->len -= 14; - pat += 7; + fg->wlen -= 14; + wpat += 7; fg->word = true; } /* - * pat has been adjusted earlier to not include '^', '$' or + * wpat has been adjusted earlier to not include '^', '$' or * the word match character classes at the beginning and ending * of the string respectively. */ - fg->pattern = xmalloc((fg->len + 1) * sizeof(tre_char_t)); - if (fg->pattern == NULL) + fg->wpattern = xmalloc((fg->wlen + 1) * sizeof(tre_char_t)); + if (fg->wpattern == NULL) return REG_ESPACE; - memcpy(fg->pattern, pat, fg->len * sizeof(tre_char_t)); - fg->pattern[fg->len] = TRE_CHAR('\0'); + memcpy(fg->wpattern, wpat, fg->wlen * sizeof(tre_char_t)); + fg->wpattern[fg->wlen] = TRE_CHAR('\0'); +#ifdef TRE_WCHAR + STORE_MBS_PAT; +#endif /* Look for ways to cheat...er...avoid the full regex engine. */ - for (unsigned int i = 0; i < fg->len; i++) { + for (unsigned int i = 0; i < fg->wlen; i++) { /* Can still cheat? */ - if ((tre_isalnum(fg->pattern[i])) || tre_isspace(fg->pattern[i]) || - (fg->pattern[i] == TRE_CHAR('_')) || (fg->pattern[i] == TRE_CHAR(',')) || - (fg->pattern[i] == TRE_CHAR('=')) || (fg->pattern[i] == TRE_CHAR('-')) || - (fg->pattern[i] == TRE_CHAR(':')) || (fg->pattern[i] == TRE_CHAR('/'))) { + if ((tre_isalnum(fg->wpattern[i])) || tre_isspace(fg->wpattern[i]) || + (fg->wpattern[i] == TRE_CHAR('_')) || (fg->wpattern[i] == TRE_CHAR(',')) || + (fg->wpattern[i] == TRE_CHAR('=')) || (fg->wpattern[i] == TRE_CHAR('-')) || + (fg->wpattern[i] == TRE_CHAR(':')) || (fg->wpattern[i] == TRE_CHAR('/'))) { continue; - } else if (fg->pattern[i] == TRE_CHAR('.')) { + } else if (fg->wpattern[i] == TRE_CHAR('.')) { hasDot = i; - if (i < fg->len / 2) { + if (i < fg->wlen / 2) { if (firstHalfDot < 0) /* Closest dot to the beginning */ firstHalfDot = i; @@ -185,8 +287,12 @@ tre_fastcomp(fastmatch_t *fg, const tre_ } } else { /* Free memory and let others know this is empty. */ +#ifdef TRE_WCHAR free(fg->pattern); fg->pattern = NULL; +#endif + free(fg->wpattern); + fg->wpattern = NULL; return REG_BADPAT; } } @@ -197,58 +303,29 @@ tre_fastcomp(fastmatch_t *fg, const tre_ */ if ((!(fg->bol || fg->eol)) && (lastHalfDot && ((firstHalfDot < 0) || - ((fg->len - (lastHalfDot + 1)) < (size_t)firstHalfDot)))) { + ((fg->wlen - (lastHalfDot + 1)) < (size_t)firstHalfDot)))) { fg->reversed = true; - hasDot = fg->len - (firstHalfDot < 0 ? + hasDot = fg->wlen - (firstHalfDot < 0 ? firstLastHalfDot : firstHalfDot) - 1; - revstr(fg->pattern, fg->len); - } - - /* - * Normal Quick Search would require a shift based on the position the - * next character after the comparison is within the pattern. With - * wildcards, the position of the last dot effects the maximum shift - * distance. - * The closer to the end the wild card is the slower the search. A - * reverse version of this algorithm would be useful for wildcards near - * the end of the string. - * - * Examples: - * Pattern Max shift - * ------- --------- - * this 5 - * .his 4 - * t.is 3 - * th.s 2 - * thi. 1 - */ - + revstr(fg->wpattern, fg->wlen); #ifdef TRE_WCHAR - /* Adjust the shift based on location of the last dot ('.'). */ - fg->defBc = fg->len - hasDot; - - /* Preprocess pattern. */ - fg->qsBc = hashtable_init(fg->len, sizeof(tre_char_t), sizeof(int)); - for (unsigned int i = hasDot + 1; i < fg->len; i++) - { - int k = fg->len - i; - hashtable_put(fg->qsBc, &fg->pattern[i], &k); - } -#else - /* Preprocess pattern. */ - for (unsigned int i = 0; i <= (signed)UCHAR_MAX; i++) - fg->qsBc[i] = fg->len - hasDot; - for (unsigned int i = hasDot + 1; i < fg->len; i++) { - fg->qsBc[fg->pattern[i]] = fg->len - i; - } + revs(fg->pattern, fg->len); #endif + } + + FILL_QSBC; /* * Put pattern back to normal after pre-processing to allow for easy * comparisons later. */ if (fg->reversed) - revstr(fg->pattern, fg->len); + { + revstr(fg->wpattern, fg->wlen); +#ifdef TRE_WCHAR + revs(fg->pattern, fg->len); +#endif + } return REG_OK; } @@ -258,8 +335,8 @@ tre_fastexec(const fastmatch_t *fg, cons tre_str_type_t type, int nmatch, regmatch_t pmatch[]) { unsigned int j; - size_t siz, skip; int ret = REG_NOMATCH; + int mismatch; const char *str_byte = data; const void *startptr = NULL; #ifdef TRE_WCHAR @@ -294,7 +371,8 @@ tre_fastexec(const fastmatch_t *fg, cons /* Determine where in data to start search at. */ j = fg->eol ? len - fg->len : 0; SKIP_CHARS(j); - if (fastcmp(fg->pattern, startptr, fg->len, type) == REG_OK) { + COMPARE; + if (mismatch == REG_OK) { pmatch[0].rm_so = j; pmatch[0].rm_eo = j + fg->len; return REG_OK; @@ -304,10 +382,8 @@ tre_fastexec(const fastmatch_t *fg, cons /* Quick Search algorithm. */ j = len - fg->len; do { - int mismatch; - SKIP_CHARS(j); - mismatch = fastcmp(fg->pattern, startptr, fg->len, type); + COMPARE; if (mismatch == REG_OK) { pmatch[0].rm_so = j - fg->len; pmatch[0].rm_eo = j; @@ -315,47 +391,14 @@ tre_fastexec(const fastmatch_t *fg, cons } else if (mismatch > 0) return mismatch; mismatch = -mismatch - 1; - - /* Shift if within bounds, otherwise, we are done. */ - if (((long)len - (long)j) > fg->len) - break; -#ifdef TRE_WCHAR - { - int k, r = -1; - wint_t wc; - - switch (type) - { - case STR_BYTE: - wc = btowc(((char *)startptr)[mismatch]); - r = hashtable_get(fg->qsBc, &wc, &k); - break; - case STR_MBS: - tre_mbrtowc(&wc, &((char *)startptr)[mismatch], MB_CUR_MAX, NULL); - r = hashtable_get(fg->qsBc, &wc, &k); - break; - case STR_WIDE: - r = hashtable_get(fg->qsBc, &((char *)startptr)[mismatch], &k); - break; - default: - /* XXX */ - break; - } - k = (r == 0) ? k : fg->defBc; - j -= k; - } -#else - j -= fg->qsBc[((char *)startptr)[mismatch]]; -#endif - } while (j >= fg->len); + SHIFT; + } while (!IS_OUT_OF_BOUNDS); } else { /* Quick Search algorithm. */ j = 0; do { - int mismatch; - SKIP_CHARS(j); - mismatch = fastcmp(fg->pattern, startptr, fg->len, type); + COMPARE; if (mismatch == REG_OK) { pmatch[0].rm_so = j; pmatch[0].rm_eo = j + fg->len; @@ -363,39 +406,8 @@ tre_fastexec(const fastmatch_t *fg, cons } else if (mismatch > 0) return mismatch; mismatch = -mismatch - 1; - - /* Shift if within bounds, otherwise, we are done. */ - if ((j + fg->len) >= len) - break; -#ifdef TRE_WCHAR - { - int k, r = -1; - wint_t wc; - - switch (type) - { - case STR_BYTE: - wc = btowc(((char *)startptr)[mismatch + 1]); - r = hashtable_get(fg->qsBc, &wc, &k); - break; - case STR_MBS: - tre_mbrtowc(&wc, &((char *)startptr)[mismatch + 1], MB_CUR_MAX, NULL); - r = hashtable_get(fg->qsBc, &wc, &k); - break; - case STR_WIDE: - r = hashtable_get(fg->qsBc, &((char *)startptr)[mismatch + 1], &k); - break; - default: - /* XXX */ - break; - } - k = (r == 0) ? k : fg->defBc; - j += k; - } -#else - j += fg->qsBc[((char *)startptr)[mismatch]]; -#endif - } while (j <= (len - fg->len)); + SHIFT; + } while (!IS_OUT_OF_BOUNDS); } return ret; } @@ -405,9 +417,10 @@ tre_fastfree(fastmatch_t *fg) { #ifdef TRE_WCHAR - hashtable_free(fg->qsBc); -#endif + hashtable_free(fg->qsBc_table); free(fg->pattern); +#endif + free(fg->wpattern); } /* @@ -416,41 +429,29 @@ tre_fastfree(fastmatch_t *fg) * REG_OK on success */ static inline int -fastcmp(const tre_char_t *pat, const void *data, size_t len, +fastcmp(const void *pat, const void *data, size_t len, tre_str_type_t type) { const char *str_byte = data; - wchar_t *mbs_wide; + const char *pat_byte = pat; int ret = REG_OK; #ifdef TRE_WCHAR const wchar_t *str_wide = data; + const wchar_t *pat_wide = pat; #endif - if (type == STR_MBS) - { -#ifdef HAVE_ALLOCA - mbs_wide = alloca((len + 1) * sizeof(wint_t)); -#elif - mbs_wide = xmalloc((len + 1) * sizeof(wint_t)); - /* XXX */ - if (mbs_wide == NULL) - return REG_ESPACE; -#endif - mbstowcs(mbs_wide, str_byte, len); - type = STR_WIDE; - } - for (int i = len - 1; i >= 0; i--) { - if (pat[i] == TRE_CHAR('.')) + if (pat_wide[i] == TRE_CHAR('.')) continue; switch (type) { case STR_BYTE: - if (pat[i] == btowc(str_byte[i])) + case STR_MBS: + if (pat_byte[i] == str_byte[i]) continue; break; case STR_WIDE: - if (pat[i] == str_wide[i]) + if (pat_wide[i] == str_wide[i]) continue; break; default: @@ -460,10 +461,6 @@ fastcmp(const tre_char_t *pat, const voi ret = -(i + 1); break; } -#ifndef HAVE_ALLOCA - if (mbs_wide != NULL) - free(mbs_wide); -#endif return ret; } @@ -480,3 +477,19 @@ revstr(tre_char_t *str, int len) str[len - i - 1] = c; } } + +/* + * XXX: eliminate code duplication + */ +static inline void +revs(char *str, int len) +{ + char c; + + for (int i = 0; i < len / 2; i++) + { + c = str[i]; + str[i] = str[len - i - 1]; + str[len - i - 1] = c; + } +} Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.h ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.h Mon Jul 25 21:44:35 2011 (r224406) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.h Mon Jul 25 21:47:56 2011 (r224407) @@ -28,6 +28,7 @@ #ifndef FASTMATCH_H #define FASTMATCH_H 1 +#include #include #include "hashtable.h" @@ -35,14 +36,15 @@ #include "tre-internal.h" typedef struct { + size_t wlen; size_t len; - tre_char_t *pattern; + tre_char_t *wpattern; + char *pattern; #ifdef TRE_WCHAR int defBc; - hashtable *qsBc; -#else - int qsBc[UCHAR_MAX + 1]; + hashtable *qsBc_table; #endif + int qsBc[UCHAR_MAX + 1]; /* flags */ bool bol; bool eol; From owner-svn-src-user@FreeBSD.ORG Tue Jul 26 01:06:44 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 64E6A106564A; Tue, 26 Jul 2011 01:06:44 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 54B288FC0A; Tue, 26 Jul 2011 01:06:44 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6Q16il6084645; Tue, 26 Jul 2011 01:06:44 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6Q16itP084643; Tue, 26 Jul 2011 01:06:44 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201107260106.p6Q16itP084643@svn.freebsd.org> From: Gabor Kovesdan Date: Tue, 26 Jul 2011 01:06:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224412 - user/gabor/tre-integration/contrib/tre/lib X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jul 2011 01:06:44 -0000 Author: gabor Date: Tue Jul 26 01:06:44 2011 New Revision: 224412 URL: http://svn.freebsd.org/changeset/base/224412 Log: - Defer converting to MBS pattern until it is sure that the compilation will succeed. Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Mon Jul 25 23:01:08 2011 (r224411) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Tue Jul 26 01:06:44 2011 (r224412) @@ -261,9 +261,6 @@ tre_fastcomp(fastmatch_t *fg, const tre_ return REG_ESPACE; memcpy(fg->wpattern, wpat, fg->wlen * sizeof(tre_char_t)); fg->wpattern[fg->wlen] = TRE_CHAR('\0'); -#ifdef TRE_WCHAR - STORE_MBS_PAT; -#endif /* Look for ways to cheat...er...avoid the full regex engine. */ for (unsigned int i = 0; i < fg->wlen; i++) { @@ -287,16 +284,16 @@ tre_fastcomp(fastmatch_t *fg, const tre_ } } else { /* Free memory and let others know this is empty. */ -#ifdef TRE_WCHAR - free(fg->pattern); - fg->pattern = NULL; -#endif free(fg->wpattern); fg->wpattern = NULL; return REG_BADPAT; } } +#ifdef TRE_WCHAR + STORE_MBS_PAT; +#endif + /* * Determine if a reverse search would be faster based on the placement * of the dots. From owner-svn-src-user@FreeBSD.ORG Tue Jul 26 10:50:34 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 42353106564A; Tue, 26 Jul 2011 10:50:34 +0000 (UTC) (envelope-from jchandra@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 30CC08FC0A; Tue, 26 Jul 2011 10:50:34 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6QAoYrA004665; Tue, 26 Jul 2011 10:50:34 GMT (envelope-from jchandra@svn.freebsd.org) Received: (from jchandra@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6QAoYjL004660; Tue, 26 Jul 2011 10:50:34 GMT (envelope-from jchandra@svn.freebsd.org) Message-Id: <201107261050.p6QAoYjL004660@svn.freebsd.org> From: "Jayachandran C." Date: Tue, 26 Jul 2011 10:50:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224415 - in user/jchandra/mips-xlp-support/sys/mips: conf nlm X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jul 2011 10:50:34 -0000 Author: jchandra Date: Tue Jul 26 10:50:33 2011 New Revision: 224415 URL: http://svn.freebsd.org/changeset/base/224415 Log: PCI - Support PCIe devices Add swapping bus space for PCIe devices, update xlp_pci.c to use it for PCIe devices. Also minor clean up in xlp_pci.c Added: user/jchandra/mips-xlp-support/sys/mips/nlm/bus_space_rmi_pci.c Modified: user/jchandra/mips-xlp-support/sys/mips/conf/XLP64 user/jchandra/mips-xlp-support/sys/mips/nlm/files.xlp user/jchandra/mips-xlp-support/sys/mips/nlm/xlp_pci.c Modified: user/jchandra/mips-xlp-support/sys/mips/conf/XLP64 ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/conf/XLP64 Tue Jul 26 04:33:00 2011 (r224414) +++ user/jchandra/mips-xlp-support/sys/mips/conf/XLP64 Tue Jul 26 10:50:33 2011 (r224415) @@ -21,7 +21,7 @@ machine mips mips64eb ident XLP64 options ISA_MIPS64 -makeoptions ARCH_FLAGS="-march=mips64 -mabi=64" +makeoptions ARCH_FLAGS="-march=mips64r2 -mabi=64" makeoptions KERNLOADADDR=0xffffffff80100000 include "../nlm/std.xlp" @@ -93,7 +93,9 @@ device uart device pci # Network +device miibus device ether +device msk device da device scbus Added: user/jchandra/mips-xlp-support/sys/mips/nlm/bus_space_rmi_pci.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/bus_space_rmi_pci.c Tue Jul 26 10:50:33 2011 (r224415) @@ -0,0 +1,768 @@ +/*- + * Copyright 2003-2011 Netlogic Microsystems (Netlogic). All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY Netlogic Microsystems ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + * + * NETLOGIC_BSD */ + +#include +__FBSDID("$FreeBSD: head/sys/mips/rmi/bus_space_rmi_pci.c 204175 2010-02-21 17:27:20Z rrs $"); + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +static int +rmi_pci_bus_space_map(void *t, bus_addr_t addr, + bus_size_t size, int flags, + bus_space_handle_t * bshp); + +static void +rmi_pci_bus_space_unmap(void *t, bus_space_handle_t bsh, + bus_size_t size); + +static int +rmi_pci_bus_space_subregion(void *t, + bus_space_handle_t bsh, + bus_size_t offset, bus_size_t size, + bus_space_handle_t * nbshp); + +static u_int8_t +rmi_pci_bus_space_read_1(void *t, + bus_space_handle_t handle, + bus_size_t offset); + +static u_int16_t +rmi_pci_bus_space_read_2(void *t, + bus_space_handle_t handle, + bus_size_t offset); + +static u_int32_t +rmi_pci_bus_space_read_4(void *t, + bus_space_handle_t handle, + bus_size_t offset); + +static void +rmi_pci_bus_space_read_multi_1(void *t, + bus_space_handle_t handle, + bus_size_t offset, u_int8_t * addr, + size_t count); + +static void +rmi_pci_bus_space_read_multi_2(void *t, + bus_space_handle_t handle, + bus_size_t offset, u_int16_t * addr, + size_t count); + +static void +rmi_pci_bus_space_read_multi_4(void *t, + bus_space_handle_t handle, + bus_size_t offset, u_int32_t * addr, + size_t count); + +static void +rmi_pci_bus_space_read_region_1(void *t, + bus_space_handle_t bsh, + bus_size_t offset, u_int8_t * addr, + size_t count); + +static void +rmi_pci_bus_space_read_region_2(void *t, + bus_space_handle_t bsh, + bus_size_t offset, u_int16_t * addr, + size_t count); + +static void +rmi_pci_bus_space_read_region_4(void *t, + bus_space_handle_t bsh, + bus_size_t offset, u_int32_t * addr, + size_t count); + +static void +rmi_pci_bus_space_write_1(void *t, + bus_space_handle_t handle, + bus_size_t offset, u_int8_t value); + +static void +rmi_pci_bus_space_write_2(void *t, + bus_space_handle_t handle, + bus_size_t offset, u_int16_t value); + +static void +rmi_pci_bus_space_write_4(void *t, + bus_space_handle_t handle, + bus_size_t offset, u_int32_t value); + +static void +rmi_pci_bus_space_write_multi_1(void *t, + bus_space_handle_t handle, + bus_size_t offset, + const u_int8_t * addr, + size_t count); + +static void +rmi_pci_bus_space_write_multi_2(void *t, + bus_space_handle_t handle, + bus_size_t offset, + const u_int16_t * addr, + size_t count); + +static void +rmi_pci_bus_space_write_multi_4(void *t, + bus_space_handle_t handle, + bus_size_t offset, + const u_int32_t * addr, + size_t count); + +static void +rmi_pci_bus_space_write_region_2(void *t, + bus_space_handle_t bsh, + bus_size_t offset, + const u_int16_t * addr, + size_t count); + +static void +rmi_pci_bus_space_write_region_4(void *t, + bus_space_handle_t bsh, + bus_size_t offset, + const u_int32_t * addr, + size_t count); + + +static void +rmi_pci_bus_space_set_region_2(void *t, + bus_space_handle_t bsh, + bus_size_t offset, u_int16_t value, + size_t count); +static void +rmi_pci_bus_space_set_region_4(void *t, + bus_space_handle_t bsh, + bus_size_t offset, u_int32_t value, + size_t count); + +static void +rmi_pci_bus_space_barrier(void *tag __unused, bus_space_handle_t bsh __unused, + bus_size_t offset __unused, bus_size_t len __unused, int flags); + +static void +rmi_pci_bus_space_copy_region_2(void *t, + bus_space_handle_t bsh1, + bus_size_t off1, + bus_space_handle_t bsh2, + bus_size_t off2, size_t count); + +u_int8_t +rmi_pci_bus_space_read_stream_1(void *t, bus_space_handle_t handle, + bus_size_t offset); + +static u_int16_t +rmi_pci_bus_space_read_stream_2(void *t, bus_space_handle_t handle, + bus_size_t offset); + +static u_int32_t +rmi_pci_bus_space_read_stream_4(void *t, bus_space_handle_t handle, + bus_size_t offset); +static void +rmi_pci_bus_space_read_multi_stream_1(void *t, + bus_space_handle_t handle, + bus_size_t offset, u_int8_t * addr, + size_t count); + +static void +rmi_pci_bus_space_read_multi_stream_2(void *t, + bus_space_handle_t handle, + bus_size_t offset, u_int16_t * addr, + size_t count); + +static void +rmi_pci_bus_space_read_multi_stream_4(void *t, + bus_space_handle_t handle, + bus_size_t offset, u_int32_t * addr, + size_t count); + +void +rmi_pci_bus_space_write_stream_1(void *t, bus_space_handle_t bsh, + bus_size_t offset, u_int8_t value); +static void +rmi_pci_bus_space_write_stream_2(void *t, bus_space_handle_t handle, + bus_size_t offset, u_int16_t value); + +static void +rmi_pci_bus_space_write_stream_4(void *t, bus_space_handle_t handle, + bus_size_t offset, u_int32_t value); + +static void +rmi_pci_bus_space_write_multi_stream_1(void *t, + bus_space_handle_t handle, + bus_size_t offset, + const u_int8_t * addr, + size_t count); +static void +rmi_pci_bus_space_write_multi_stream_2(void *t, + bus_space_handle_t handle, + bus_size_t offset, + const u_int16_t * addr, + size_t count); + +static void +rmi_pci_bus_space_write_multi_stream_4(void *t, + bus_space_handle_t handle, + bus_size_t offset, + const u_int32_t * addr, + size_t count); + +#define TODO() printf("XLR memory bus space function '%s' unimplemented\n", __func__) + +static struct bus_space local_rmi_pci_bus_space = { + /* cookie */ + (void *)0, + + /* mapping/unmapping */ + rmi_pci_bus_space_map, + rmi_pci_bus_space_unmap, + rmi_pci_bus_space_subregion, + + /* allocation/deallocation */ + NULL, + NULL, + + /* barrier */ + rmi_pci_bus_space_barrier, + + /* read (single) */ + rmi_pci_bus_space_read_1, + rmi_pci_bus_space_read_2, + rmi_pci_bus_space_read_4, + NULL, + + /* read multiple */ + rmi_pci_bus_space_read_multi_1, + rmi_pci_bus_space_read_multi_2, + rmi_pci_bus_space_read_multi_4, + NULL, + + /* read region */ + rmi_pci_bus_space_read_region_1, + rmi_pci_bus_space_read_region_2, + rmi_pci_bus_space_read_region_4, + NULL, + + /* write (single) */ + rmi_pci_bus_space_write_1, + rmi_pci_bus_space_write_2, + rmi_pci_bus_space_write_4, + NULL, + + /* write multiple */ + rmi_pci_bus_space_write_multi_1, + rmi_pci_bus_space_write_multi_2, + rmi_pci_bus_space_write_multi_4, + NULL, + + /* write region */ + NULL, + rmi_pci_bus_space_write_region_2, + rmi_pci_bus_space_write_region_4, + NULL, + + /* set multiple */ + NULL, + NULL, + NULL, + NULL, + + /* set region */ + NULL, + rmi_pci_bus_space_set_region_2, + rmi_pci_bus_space_set_region_4, + NULL, + + /* copy */ + NULL, + rmi_pci_bus_space_copy_region_2, + NULL, + NULL, + + /* read (single) stream */ + rmi_pci_bus_space_read_stream_1, + rmi_pci_bus_space_read_stream_2, + rmi_pci_bus_space_read_stream_4, + NULL, + + /* read multiple stream */ + rmi_pci_bus_space_read_multi_stream_1, + rmi_pci_bus_space_read_multi_stream_2, + rmi_pci_bus_space_read_multi_stream_4, + NULL, + + /* read region stream */ + rmi_pci_bus_space_read_region_1, + rmi_pci_bus_space_read_region_2, + rmi_pci_bus_space_read_region_4, + NULL, + + /* write (single) stream */ + rmi_pci_bus_space_write_stream_1, + rmi_pci_bus_space_write_stream_2, + rmi_pci_bus_space_write_stream_4, + NULL, + + /* write multiple stream */ + rmi_pci_bus_space_write_multi_stream_1, + rmi_pci_bus_space_write_multi_stream_2, + rmi_pci_bus_space_write_multi_stream_4, + NULL, + + /* write region stream */ + NULL, + rmi_pci_bus_space_write_region_2, + rmi_pci_bus_space_write_region_4, + NULL, +}; + +/* generic bus_space tag */ +bus_space_tag_t rmi_pci_bus_space = &local_rmi_pci_bus_space; + +/* + * Map a region of device bus space into CPU virtual address space. + */ +static int +rmi_pci_bus_space_map(void *t __unused, bus_addr_t addr, + bus_size_t size __unused, int flags __unused, + bus_space_handle_t * bshp) +{ + *bshp = addr; + return (0); +} + +/* + * Unmap a region of device bus space. + */ +static void +rmi_pci_bus_space_unmap(void *t __unused, bus_space_handle_t bsh __unused, + bus_size_t size __unused) +{ +} + +/* + * Get a new handle for a subregion of an already-mapped area of bus space. + */ + +static int +rmi_pci_bus_space_subregion(void *t __unused, bus_space_handle_t bsh, + bus_size_t offset, bus_size_t size __unused, + bus_space_handle_t * nbshp) +{ + *nbshp = bsh + offset; + return (0); +} + +/* + * Read a 1, 2, 4, or 8 byte quantity from bus space + * described by tag/handle/offset. + */ + +static u_int8_t +rmi_pci_bus_space_read_1(void *tag, bus_space_handle_t handle, + bus_size_t offset) +{ + return (u_int8_t) (*(volatile u_int8_t *)(handle + offset)); +} + +static u_int16_t +rmi_pci_bus_space_read_2(void *tag, bus_space_handle_t handle, + bus_size_t offset) +{ + u_int16_t value; + + value = *(volatile u_int16_t *)(handle + offset); + return bswap16(value); +} + +static u_int32_t +rmi_pci_bus_space_read_4(void *tag, bus_space_handle_t handle, + bus_size_t offset) +{ + uint32_t value; + + value = *(volatile u_int32_t *)(handle + offset); + return bswap32(value); +} + +/* + * Read `count' 1, 2, 4, or 8 byte quantities from bus space + * described by tag/handle/offset and copy into buffer provided. + */ +static void +rmi_pci_bus_space_read_multi_1(void *tag, bus_space_handle_t handle, + bus_size_t offset, u_int8_t * addr, size_t count) +{ + while (count--) { + *addr = *(volatile u_int8_t *)(handle + offset); + addr++; + } +} + +static void +rmi_pci_bus_space_read_multi_2(void *tag, bus_space_handle_t handle, + bus_size_t offset, u_int16_t * addr, size_t count) +{ + + while (count--) { + *addr = *(volatile u_int16_t *)(handle + offset); + *addr = bswap16(*addr); + addr++; + } +} + +static void +rmi_pci_bus_space_read_multi_4(void *tag, bus_space_handle_t handle, + bus_size_t offset, u_int32_t * addr, size_t count) +{ + + while (count--) { + *addr = *(volatile u_int32_t *)(handle + offset); + *addr = bswap32(*addr); + addr++; + } +} + +/* + * Write the 1, 2, 4, or 8 byte value `value' to bus space + * described by tag/handle/offset. + */ + +static void +rmi_pci_bus_space_write_1(void *tag, bus_space_handle_t handle, + bus_size_t offset, u_int8_t value) +{ + mips_sync(); + *(volatile u_int8_t *)(handle + offset) = value; +} + +static void +rmi_pci_bus_space_write_2(void *tag, bus_space_handle_t handle, + bus_size_t offset, u_int16_t value) +{ + mips_sync(); + *(volatile u_int16_t *)(handle + offset) = bswap16(value); +} + + +static void +rmi_pci_bus_space_write_4(void *tag, bus_space_handle_t handle, + bus_size_t offset, u_int32_t value) +{ + mips_sync(); + *(volatile u_int32_t *)(handle + offset) = bswap32(value); +} + +/* + * Write `count' 1, 2, 4, or 8 byte quantities from the buffer + * provided to bus space described by tag/handle/offset. + */ + + +static void +rmi_pci_bus_space_write_multi_1(void *tag, bus_space_handle_t handle, + bus_size_t offset, const u_int8_t * addr, size_t count) +{ + mips_sync(); + while (count--) { + (*(volatile u_int8_t *)(handle + offset)) = *addr; + addr++; + } +} + +static void +rmi_pci_bus_space_write_multi_2(void *tag, bus_space_handle_t handle, + bus_size_t offset, const u_int16_t * addr, size_t count) +{ + mips_sync(); + while (count--) { + (*(volatile u_int16_t *)(handle + offset)) = bswap16(*addr); + addr++; + } +} + +static void +rmi_pci_bus_space_write_multi_4(void *tag, bus_space_handle_t handle, + bus_size_t offset, const u_int32_t * addr, size_t count) +{ + mips_sync(); + while (count--) { + (*(volatile u_int32_t *)(handle + offset)) = bswap32(*addr); + addr++; + } +} + +/* + * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described + * by tag/handle starting at `offset'. + */ + +static void +rmi_pci_bus_space_set_region_2(void *t, bus_space_handle_t bsh, + bus_size_t offset, u_int16_t value, size_t count) +{ + bus_addr_t addr = bsh + offset; + + for (; count != 0; count--, addr += 2) + (*(volatile u_int16_t *)(addr)) = value; +} + +static void +rmi_pci_bus_space_set_region_4(void *t, bus_space_handle_t bsh, + bus_size_t offset, u_int32_t value, size_t count) +{ + bus_addr_t addr = bsh + offset; + + for (; count != 0; count--, addr += 4) + (*(volatile u_int32_t *)(addr)) = value; +} + + +/* + * Copy `count' 1, 2, 4, or 8 byte values from bus space starting + * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2. + */ +static void +rmi_pci_bus_space_copy_region_2(void *t, bus_space_handle_t bsh1, + bus_size_t off1, bus_space_handle_t bsh2, + bus_size_t off2, size_t count) +{ + TODO(); +} + +/* + * Read `count' 1, 2, 4, or 8 byte quantities from bus space + * described by tag/handle/offset and copy into buffer provided. + */ + +u_int8_t +rmi_pci_bus_space_read_stream_1(void *t, bus_space_handle_t handle, + bus_size_t offset) +{ + + return *((volatile u_int8_t *)(handle + offset)); +} + + +static u_int16_t +rmi_pci_bus_space_read_stream_2(void *t, bus_space_handle_t handle, + bus_size_t offset) +{ + return *(volatile u_int16_t *)(handle + offset); +} + + +static u_int32_t +rmi_pci_bus_space_read_stream_4(void *t, bus_space_handle_t handle, + bus_size_t offset) +{ + return (*(volatile u_int32_t *)(handle + offset)); +} + + +static void +rmi_pci_bus_space_read_multi_stream_1(void *tag, bus_space_handle_t handle, + bus_size_t offset, u_int8_t * addr, size_t count) +{ + while (count--) { + *addr = (*(volatile u_int8_t *)(handle + offset)); + addr++; + } +} + +static void +rmi_pci_bus_space_read_multi_stream_2(void *tag, bus_space_handle_t handle, + bus_size_t offset, u_int16_t * addr, size_t count) +{ + while (count--) { + *addr = (*(volatile u_int16_t *)(handle + offset)); + addr++; + } +} + +static void +rmi_pci_bus_space_read_multi_stream_4(void *tag, bus_space_handle_t handle, + bus_size_t offset, u_int32_t * addr, size_t count) +{ + while (count--) { + *addr = (*(volatile u_int32_t *)(handle + offset)); + addr++; + } +} + + + +/* + * Read `count' 1, 2, 4, or 8 byte quantities from bus space + * described by tag/handle and starting at `offset' and copy into + * buffer provided. + */ +void +rmi_pci_bus_space_read_region_1(void *t, bus_space_handle_t bsh, + bus_size_t offset, u_int8_t * addr, size_t count) +{ + bus_addr_t baddr = bsh + offset; + + while (count--) { + *addr++ = (*(volatile u_int8_t *)(baddr)); + baddr += 1; + } +} + +void +rmi_pci_bus_space_read_region_2(void *t, bus_space_handle_t bsh, + bus_size_t offset, u_int16_t * addr, size_t count) +{ + bus_addr_t baddr = bsh + offset; + + while (count--) { + *addr++ = (*(volatile u_int16_t *)(baddr)); + baddr += 2; + } +} + +void +rmi_pci_bus_space_read_region_4(void *t, bus_space_handle_t bsh, + bus_size_t offset, u_int32_t * addr, size_t count) +{ + bus_addr_t baddr = bsh + offset; + + while (count--) { + *addr++ = (*(volatile u_int32_t *)(baddr)); + baddr += 4; + } +} + + +void +rmi_pci_bus_space_write_stream_1(void *t, bus_space_handle_t handle, + bus_size_t offset, u_int8_t value) +{ + mips_sync(); + *(volatile u_int8_t *)(handle + offset) = value; +} + +static void +rmi_pci_bus_space_write_stream_2(void *t, bus_space_handle_t handle, + bus_size_t offset, u_int16_t value) +{ + mips_sync(); + *(volatile u_int16_t *)(handle + offset) = value; +} + + +static void +rmi_pci_bus_space_write_stream_4(void *t, bus_space_handle_t handle, + bus_size_t offset, u_int32_t value) +{ + mips_sync(); + *(volatile u_int32_t *)(handle + offset) = value; +} + + +static void +rmi_pci_bus_space_write_multi_stream_1(void *tag, bus_space_handle_t handle, + bus_size_t offset, const u_int8_t * addr, size_t count) +{ + mips_sync(); + while (count--) { + (*(volatile u_int8_t *)(handle + offset)) = *addr; + addr++; + } +} + +static void +rmi_pci_bus_space_write_multi_stream_2(void *tag, bus_space_handle_t handle, + bus_size_t offset, const u_int16_t * addr, size_t count) +{ + mips_sync(); + while (count--) { + (*(volatile u_int16_t *)(handle + offset)) = *addr; + addr++; + } +} + +static void +rmi_pci_bus_space_write_multi_stream_4(void *tag, bus_space_handle_t handle, + bus_size_t offset, const u_int32_t * addr, size_t count) +{ + mips_sync(); + while (count--) { + (*(volatile u_int32_t *)(handle + offset)) = *addr; + addr++; + } +} + +void +rmi_pci_bus_space_write_region_2(void *t, + bus_space_handle_t bsh, + bus_size_t offset, + const u_int16_t * addr, + size_t count) +{ + bus_addr_t baddr = (bus_addr_t) bsh + offset; + + while (count--) { + (*(volatile u_int16_t *)(baddr)) = *addr; + addr++; + baddr += 2; + } +} + +void +rmi_pci_bus_space_write_region_4(void *t, bus_space_handle_t bsh, + bus_size_t offset, const u_int32_t * addr, size_t count) +{ + bus_addr_t baddr = bsh + offset; + + while (count--) { + (*(volatile u_int32_t *)(baddr)) = *addr; + addr++; + baddr += 4; + } +} + +static void +rmi_pci_bus_space_barrier(void *tag __unused, bus_space_handle_t bsh __unused, + bus_size_t offset __unused, bus_size_t len __unused, int flags) +{ + +} Modified: user/jchandra/mips-xlp-support/sys/mips/nlm/files.xlp ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/nlm/files.xlp Tue Jul 26 04:33:00 2011 (r224414) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/files.xlp Tue Jul 26 10:50:33 2011 (r224415) @@ -6,6 +6,7 @@ mips/nlm/tick.c standard mips/nlm/board.c standard mips/nlm/cms.c standard mips/nlm/bus_space_rmi.c standard +mips/nlm/bus_space_rmi_pci.c standard mips/nlm/mpreset.S standard mips/nlm/xlp_pci.c optional pci mips/nlm/intern_dev.c optional pci Modified: user/jchandra/mips-xlp-support/sys/mips/nlm/xlp_pci.c ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/nlm/xlp_pci.c Tue Jul 26 04:33:00 2011 (r224414) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/xlp_pci.c Tue Jul 26 10:50:33 2011 (r224415) @@ -84,7 +84,7 @@ xlp_pci_init_resources(void) panic("pci_init_resources irq_rman"); port_rman.rm_start = 0; - port_rman.rm_end = ~0u; + port_rman.rm_end = ~0ul; port_rman.rm_type = RMAN_ARRAY; port_rman.rm_descr = "I/O ports"; if (rman_init(&port_rman) @@ -92,7 +92,7 @@ xlp_pci_init_resources(void) panic("pci_init_resources port_rman"); mem_rman.rm_start = 0; - mem_rman.rm_end = ~0u; + mem_rman.rm_end = ~0ul; mem_rman.rm_type = RMAN_ARRAY; mem_rman.rm_descr = "I/O memory"; if (rman_init(&mem_rman) @@ -100,7 +100,7 @@ xlp_pci_init_resources(void) panic("pci_init_resources mem_rman"); emul_rman.rm_start = 0; - emul_rman.rm_end = ~0u; + emul_rman.rm_end = ~0ul; emul_rman.rm_type = RMAN_ARRAY; emul_rman.rm_descr = "Emulated MEMIO"; if (rman_init(&emul_rman) @@ -443,9 +443,7 @@ mips_platform_pci_setup_intr(device_t de xlp_establish_intr(device_get_name(child), filt, intr, arg, xlpirq, flags, cookiep, extra_ack); -// return (bus_generic_setup_intr(dev, child, irq, flags, filt, intr, -// arg, cookiep)); - return 0; + return (0); } static int @@ -459,15 +457,16 @@ mips_platform_pci_teardown_intr(device_t return (bus_generic_teardown_intr(dev, child, irq, cookie)); } -static vm_offset_t +static void assign_soc_resource(device_t child, int type, u_long *startp, u_long *endp, - u_long *countp) + u_long *countp, struct rman **rm, vm_offset_t *va) { int devid = pci_get_device(child); int inst = pci_get_function(child); int node = pci_get_slot(child) / 8; - vm_offset_t va = 0; + *rm = NULL; + *va = 0; switch (devid) { case PCI_DEVICE_ID_NLM_UART: switch (type) { @@ -476,9 +475,10 @@ assign_soc_resource(device_t child, int *countp = 1; break; case SYS_RES_MEMORY: - va = nlm_regbase_uart(node, inst) + XLP_IO_PCI_HDRSZ; + *va = nlm_regbase_uart(node, inst) + XLP_IO_PCI_HDRSZ; *startp = MIPS_KSEG1_TO_PHYS(va); *countp = 0x100; + *rm = &emul_rman; break; }; break; @@ -496,8 +496,6 @@ assign_soc_resource(device_t child, int } break; } - - return (va); } static struct resource * @@ -517,11 +515,9 @@ xlp_pci_alloc_resource(device_t bus, dev */ if (pci_get_bus(child) == 0 && pci_get_vendor(child) == PCI_VENDOR_NETLOGIC) - va = assign_soc_resource(child, type, &start, &end, - &count); - if (va) - rm = &emul_rman; - else + assign_soc_resource(child, type, &start, &end, + &count, &rm, &va); + if (rm == NULL) { switch (type) { case SYS_RES_IRQ: rm = &irq_rman; @@ -537,6 +533,7 @@ xlp_pci_alloc_resource(device_t bus, dev default: return (0); + } } rv = rman_reserve_resource(rm, start, end, count, flags, child); @@ -550,7 +547,12 @@ xlp_pci_alloc_resource(device_t bus, dev va = (vm_offset_t)pmap_mapdev(start, count); rman_set_bushandle(rv, va); rman_set_virtual(rv, (void *)va); - rman_set_bustag(rv, rmi_bus_space); + + /* SoC devices don't need swap */ + if (pci_get_bus(child) != 0) + rman_set_bustag(rv, rmi_pci_bus_space); + else + rman_set_bustag(rv, rmi_bus_space); } if (needactivate) { From owner-svn-src-user@FreeBSD.ORG Wed Jul 27 22:54:41 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 19B2F106566C; Wed, 27 Jul 2011 22:54:41 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 09B078FC18; Wed, 27 Jul 2011 22:54:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6RMseY5075630; Wed, 27 Jul 2011 22:54:40 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6RMse3A075626; Wed, 27 Jul 2011 22:54:40 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201107272254.p6RMse3A075626@svn.freebsd.org> From: Gabor Kovesdan Date: Wed, 27 Jul 2011 22:54:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224469 - user/gabor/tre-integration/contrib/tre/lib X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jul 2011 22:54:41 -0000 Author: gabor Date: Wed Jul 27 22:54:40 2011 New Revision: 224469 URL: http://svn.freebsd.org/changeset/base/224469 Log: - Add support for REG_ICASE - Eliminate code duplication by using macro Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c user/gabor/tre-integration/contrib/tre/lib/fastmatch.h user/gabor/tre-integration/contrib/tre/lib/tre-compile.c Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Wed Jul 27 11:21:50 2011 (r224468) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Wed Jul 27 22:54:40 2011 (r224469) @@ -42,7 +42,7 @@ #include "xmalloc.h" static int fastcmp(const void *, const void *, size_t, - tre_str_type_t); + tre_str_type_t, bool); static void revstr(tre_char_t *, int); static void revs(char *str, int len); @@ -90,10 +90,12 @@ static void revs(char *str, int len); { \ case STR_BYTE: \ case STR_MBS: \ - mismatch = fastcmp(fg->pattern, startptr, fg->len, type); \ + mismatch = fastcmp(fg->pattern, startptr, fg->len, type, \ + fg->icase); \ break; \ case STR_WIDE: \ - mismatch = fastcmp(fg->wpattern, startptr, fg->wlen, type); \ + mismatch = fastcmp(fg->wpattern, startptr, fg->wlen, type, \ + fg->icase); \ default: \ break; \ } \ @@ -171,31 +173,76 @@ static void revs(char *str, int len); { \ int k = fg->wlen - i; \ hashtable_put(fg->qsBc_table, &fg->wpattern[i], &k); \ + if (fg->icase) \ + { \ + wint_t wc = iswlower(fg->wpattern[i]) ? \ + towupper(fg->wpattern[i]) : towlower(fg->wpattern[i]); \ + hashtable_put(fg->qsBc_table, &wc, &k); \ + } \ } \ \ for (unsigned int i = 0; i <= UCHAR_MAX; i++) \ fg->qsBc[i] = fg->len - hasDot; \ for (int i = hasDot + 1; i < fg->len; i++) \ - fg->qsBc[(unsigned)fg->pattern[i]] = fg->len - i; + { \ + fg->qsBc[(unsigned)fg->pattern[i]] = fg->len - i; \ + if (fg->icase) \ + { \ + char c = islower(fg->pattern[i]) ? toupper(fg->pattern[i]) \ + : tolower(fg->pattern[i]); \ + fg->qsBc[(unsigned)c] = fg->len - i; \ + } \ + } #else #define FILL_QSBC \ for (unsigned int i = 0; i <= UCHAR_MAX; i++) \ fg->qsBc[i] = fg->wlen - hasDot; \ for (int i = hasDot + 1; i < fg->wlen; i++) \ - fg->qsBc[(unsigned)fg->wpattern[i]] = fg->wlen - i; + { \ + fg->qsBc[(unsigned)fg->wpattern[i]] = fg->wlen - i; \ + if (fg->icase) \ + { \ + char c = islower(fg->wpattern[i]) ? toupper(fg->wpattern[i]) \ + : tolower(fg->wpattern[i]); \ + fg->qsBc[(unsigned)c] = fg->len - i; \ + } \ + } #endif +#define REVFUNC(name, argtype) \ +static inline void \ +name(argtype *str, int len) \ +{ \ + argtype c; \ + \ + for (int i = 0; i < len / 2; i++) \ + { \ + c = str[i]; \ + str[i] = str[len - i - 1]; \ + str[len - i - 1] = c; \ + } \ +} + +REVFUNC(revstr, tre_char_t) +REVFUNC(revs, char) + /* * Returns: REG_OK on success, error code otherwise */ int -tre_fastcomp_literal(fastmatch_t *fg, const tre_char_t *wpat, size_t n) +tre_fastcomp_literal(fastmatch_t *fg, const tre_char_t *wpat, size_t n, + int cflags) { int hasDot = 0; /* Initialize. */ memset(fg, 0, sizeof(*fg)); + fg->icase = (cflags & REG_ICASE); + /* XXX */ + if (fg->icase && (MB_CUR_MAX > 1)) + return REG_BADPAT; + fg->wlen = (n == 0) ? tre_strlen(wpat) : n; fg->wpattern = xmalloc((fg->wlen + 1) * sizeof(tre_char_t)); if (fg->wpattern == NULL) @@ -215,7 +262,8 @@ tre_fastcomp_literal(fastmatch_t *fg, co * Returns: REG_OK on success, error code otherwise */ int -tre_fastcomp(fastmatch_t *fg, const tre_char_t *wpat, size_t n) +tre_fastcomp(fastmatch_t *fg, const tre_char_t *wpat, size_t n, + int cflags) { int firstHalfDot = -1; int firstLastHalfDot = -1; @@ -224,6 +272,11 @@ tre_fastcomp(fastmatch_t *fg, const tre_ /* Initialize. */ memset(fg, 0, sizeof(*fg)); + fg->icase = (cflags & REG_ICASE); + /* XXX */ + if (fg->icase && (MB_CUR_MAX > 1)) + return REG_BADPAT; + fg->wlen = (n == 0) ? tre_strlen(wpat) : n; /* Remove end-of-line character ('$'). */ @@ -427,7 +480,7 @@ tre_fastfree(fastmatch_t *fg) */ static inline int fastcmp(const void *pat, const void *data, size_t len, - tre_str_type_t type) + tre_str_type_t type, bool icase) { const char *str_byte = data; const char *pat_byte = pat; @@ -444,11 +497,13 @@ fastcmp(const void *pat, const void *dat { case STR_BYTE: case STR_MBS: - if (pat_byte[i] == str_byte[i]) + if (icase ? (tolower(pat_byte[i]) == tolower(str_byte[i])) + : (pat_byte[i] == str_byte[i])) continue; break; case STR_WIDE: - if (pat_wide[i] == str_wide[i]) + if (icase ? (towlower(pat_wide[i]) == towlower(str_wide[i])) + : (pat_wide[i] == str_wide[i])) continue; break; default: @@ -461,32 +516,3 @@ fastcmp(const void *pat, const void *dat return ret; } - -static inline void -revstr(tre_char_t *str, int len) -{ - tre_char_t c; - - for (int i = 0; i < len / 2; i++) - { - c = str[i]; - str[i] = str[len - i - 1]; - str[len - i - 1] = c; - } -} - -/* - * XXX: eliminate code duplication - */ -static inline void -revs(char *str, int len) -{ - char c; - - for (int i = 0; i < len / 2; i++) - { - c = str[i]; - str[i] = str[len - i - 1]; - str[len - i - 1] = c; - } -} Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.h ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.h Wed Jul 27 11:21:50 2011 (r224468) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.h Wed Jul 27 22:54:40 2011 (r224469) @@ -50,11 +50,12 @@ typedef struct { bool eol; bool reversed; bool word; + bool icase; } fastmatch_t; int tre_fastcomp_literal(fastmatch_t *preg, const tre_char_t *regex, - size_t); -int tre_fastcomp(fastmatch_t *preg, const tre_char_t *regex, size_t); + size_t, int); +int tre_fastcomp(fastmatch_t *preg, const tre_char_t *regex, size_t, int); int tre_fastexec(const fastmatch_t *fg, const void *data, size_t len, tre_str_type_t type, int nmatch, regmatch_t pmatch[]); void tre_fastfree(fastmatch_t *preg); Modified: user/gabor/tre-integration/contrib/tre/lib/tre-compile.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-compile.c Wed Jul 27 11:21:50 2011 (r224468) +++ user/gabor/tre-integration/contrib/tre/lib/tre-compile.c Wed Jul 27 22:54:40 2011 (r224469) @@ -1876,8 +1876,8 @@ tre_compile(regex_t *preg, const tre_cha if (!shortcut) return REG_ESPACE; ret = (cflags & REG_LITERAL) - ? tre_fastcomp_literal(shortcut, regex, n) - : tre_fastcomp(shortcut, regex, n); + ? tre_fastcomp_literal(shortcut, regex, n, cflags) + : tre_fastcomp(shortcut, regex, n, cflags); if (ret == REG_OK) { preg->shortcut = shortcut; From owner-svn-src-user@FreeBSD.ORG Thu Jul 28 03:11:13 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6C4FE1065679; Thu, 28 Jul 2011 03:11:13 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5CA9F8FC08; Thu, 28 Jul 2011 03:11:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6S3BDlL083278; Thu, 28 Jul 2011 03:11:13 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6S3BDN5083276; Thu, 28 Jul 2011 03:11:13 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201107280311.p6S3BDN5083276@svn.freebsd.org> From: Doug Barton Date: Thu, 28 Jul 2011 03:11:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224471 - user/dougb/portmaster X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jul 2011 03:11:13 -0000 Author: dougb Date: Thu Jul 28 03:11:12 2011 New Revision: 224471 URL: http://svn.freebsd.org/changeset/base/224471 Log: If a user has non-standard FETCH_ARGS it could circumvent the intent of --always-fetch, so forcibly unlink the file before proceeding to the fetch routine. Modified: user/dougb/portmaster/portmaster Modified: user/dougb/portmaster/portmaster ============================================================================== --- user/dougb/portmaster/portmaster Thu Jul 28 03:01:22 2011 (r224470) +++ user/dougb/portmaster/portmaster Thu Jul 28 03:11:12 2011 (r224471) @@ -3376,6 +3376,7 @@ fetch_package () { fi else do_fetch=do_fetch_always_fetch + pm_unlink_s ${ppd}/${1}.tbz fi if [ -n "$do_fetch" ]; then From owner-svn-src-user@FreeBSD.ORG Thu Jul 28 12:08:13 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B71BD1065673; Thu, 28 Jul 2011 12:08:13 +0000 (UTC) (envelope-from jchandra@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A73C28FC19; Thu, 28 Jul 2011 12:08:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6SC8Ddr002925; Thu, 28 Jul 2011 12:08:13 GMT (envelope-from jchandra@svn.freebsd.org) Received: (from jchandra@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6SC8DRm002920; Thu, 28 Jul 2011 12:08:13 GMT (envelope-from jchandra@svn.freebsd.org) Message-Id: <201107281208.p6SC8DRm002920@svn.freebsd.org> From: "Jayachandran C." Date: Thu, 28 Jul 2011 12:08:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224476 - user/jchandra/mips-xlp-support/sys/mips/nlm X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jul 2011 12:08:13 -0000 Author: jchandra Date: Thu Jul 28 12:08:13 2011 New Revision: 224476 URL: http://svn.freebsd.org/changeset/base/224476 Log: Create custom bus space for the SoC UART. The SoC uart needs to use 32bit access to its registers, use a custom bus space for this. Remove the hack in default bus space for this. Modified: user/jchandra/mips-xlp-support/sys/mips/nlm/bus_space_rmi.c user/jchandra/mips-xlp-support/sys/mips/nlm/uart_cpu_xlp.c user/jchandra/mips-xlp-support/sys/mips/nlm/uart_pci_xlp.c user/jchandra/mips-xlp-support/sys/mips/nlm/xlp_pci.c Modified: user/jchandra/mips-xlp-support/sys/mips/nlm/bus_space_rmi.c ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/nlm/bus_space_rmi.c Thu Jul 28 11:41:55 2011 (r224475) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/bus_space_rmi.c Thu Jul 28 12:08:13 2011 (r224476) @@ -401,14 +401,14 @@ static u_int8_t rmi_bus_space_read_1(void *tag, bus_space_handle_t handle, bus_size_t offset) { - return (u_int8_t) (*(volatile u_int32_t *)(handle + offset)); + return (u_int8_t) (*(volatile u_int8_t *)(handle + offset)); } static u_int16_t rmi_bus_space_read_2(void *tag, bus_space_handle_t handle, bus_size_t offset) { - return (u_int16_t)(*(volatile u_int32_t *)(handle + offset)); + return (u_int16_t)(*(volatile u_int16_t *)(handle + offset)); } static u_int32_t @@ -453,14 +453,14 @@ static void rmi_bus_space_write_1(void *tag, bus_space_handle_t handle, bus_size_t offset, u_int8_t value) { - *(volatile u_int32_t *)(handle + offset) = (u_int32_t)value; + *(volatile u_int8_t *)(handle + offset) = value; } static void rmi_bus_space_write_2(void *tag, bus_space_handle_t handle, bus_size_t offset, u_int16_t value) { - *(volatile u_int32_t *)(handle + offset) = (u_int32_t)value; + *(volatile u_int16_t *)(handle + offset) = value; } static void Modified: user/jchandra/mips-xlp-support/sys/mips/nlm/uart_cpu_xlp.c ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/nlm/uart_cpu_xlp.c Thu Jul 28 11:41:55 2011 (r224475) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/uart_cpu_xlp.c Thu Jul 28 12:08:13 2011 (r224476) @@ -60,19 +60,43 @@ __FBSDID("$FreeBSD: head/sys/mips/rmi/ua bus_space_tag_t uart_bus_space_io; bus_space_tag_t uart_bus_space_mem; +/* + * need a special bus space for this, because the Netlogic SoC + * UART allows only 32 bit access to its registers + */ +static struct bus_space nlm_uart_bussp; + +static u_int8_t +nlm_uart_bussp_read_1(void *tag, bus_space_handle_t handle, + bus_size_t offset) +{ + return (u_int8_t)(*(volatile u_int32_t *)(handle + offset)); +} + +static void +nlm_uart_bussp_write_1(void *tag, bus_space_handle_t handle, + bus_size_t offset, u_int8_t value) +{ + *(volatile u_int32_t *)(handle + offset) = value; +} + int uart_cpu_eqres(struct uart_bas *b1, struct uart_bas *b2) { return ((b1->bsh == b2->bsh && b1->bst == b2->bst) ? 1 : 0); } - int uart_cpu_getdev(int devtype, struct uart_devinfo *di) { + /* Create custom bus space */ + memcpy(&nlm_uart_bussp, rmi_bus_space, sizeof(nlm_uart_bussp)); + nlm_uart_bussp.bs_r_1 = nlm_uart_bussp_read_1; + nlm_uart_bussp.bs_w_1 = nlm_uart_bussp_write_1; + di->ops = uart_getops(&uart_ns8250_class); di->bas.chan = 0; - di->bas.bst = rmi_bus_space; + di->bas.bst = &nlm_uart_bussp; di->bas.bsh = nlm_regbase_uart(0, 0) + XLP_IO_PCI_HDRSZ; di->bas.regshft = 2; @@ -84,6 +108,6 @@ uart_cpu_getdev(int devtype, struct uart di->parity = UART_PARITY_NONE; uart_bus_space_io = NULL; - uart_bus_space_mem = rmi_bus_space; + uart_bus_space_mem = &nlm_uart_bussp; return (0); } Modified: user/jchandra/mips-xlp-support/sys/mips/nlm/uart_pci_xlp.c ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/nlm/uart_pci_xlp.c Thu Jul 28 11:41:55 2011 (r224475) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/uart_pci_xlp.c Thu Jul 28 12:08:13 2011 (r224476) @@ -76,11 +76,10 @@ uart_soc_probe(device_t dev) return (ENXIO); ubase = nlm_regbase_uart(0, 0); - nlm_pci_wreg(ubase, 0xf, 0x1ff); sc = device_get_softc(dev); sc->sc_class = &uart_ns8250_class; device_set_desc(dev, "Netlogic SoC UART"); return (uart_bus_probe(dev, 2, 133000000, 0, 0)); } -DRIVER_MODULE(soc_uart, pci, uart_soc_driver, uart_devclass, 0, 0); +DRIVER_MODULE(uart_soc, pci, uart_soc_driver, uart_devclass, 0, 0); Modified: user/jchandra/mips-xlp-support/sys/mips/nlm/xlp_pci.c ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/nlm/xlp_pci.c Thu Jul 28 11:41:55 2011 (r224475) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/xlp_pci.c Thu Jul 28 12:08:13 2011 (r224476) @@ -47,6 +47,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include +#include #include #include @@ -459,7 +462,7 @@ mips_platform_pci_teardown_intr(device_t static void assign_soc_resource(device_t child, int type, u_long *startp, u_long *endp, - u_long *countp, struct rman **rm, vm_offset_t *va) + u_long *countp, struct rman **rm, bus_space_tag_t *bst, vm_offset_t *va) { int devid = pci_get_device(child); int inst = pci_get_function(child); @@ -467,6 +470,7 @@ assign_soc_resource(device_t child, int *rm = NULL; *va = 0; + *bst = 0; switch (devid) { case PCI_DEVICE_ID_NLM_UART: switch (type) { @@ -475,10 +479,11 @@ assign_soc_resource(device_t child, int *countp = 1; break; case SYS_RES_MEMORY: - *va = nlm_regbase_uart(node, inst) + XLP_IO_PCI_HDRSZ; + *va = nlm_regbase_uart(node, inst) + XLP_IO_PCI_HDRSZ; *startp = MIPS_KSEG1_TO_PHYS(va); *countp = 0x100; *rm = &emul_rman; + *bst = uart_bus_space_mem; break; }; break; @@ -496,17 +501,21 @@ assign_soc_resource(device_t child, int } break; } + + /* default to rmi_bus_space for SoC resources */ + if (type == SYS_RES_MEMORY && *bst == 0) + *bst = rmi_bus_space; } static struct resource * xlp_pci_alloc_resource(device_t bus, device_t child, int type, int *rid, u_long start, u_long end, u_long count, u_int flags) { - struct rman *rm; + struct rman *rm = NULL; struct resource *rv; vm_offset_t va = 0; int needactivate = flags & RF_ACTIVE; - + bus_space_tag_t bst = 0; /* * For SoC PCI devices, we have to assign resources correctly @@ -516,7 +525,7 @@ xlp_pci_alloc_resource(device_t bus, dev if (pci_get_bus(child) == 0 && pci_get_vendor(child) == PCI_VENDOR_NETLOGIC) assign_soc_resource(child, type, &start, &end, - &count, &rm, &va); + &count, &rm, &bst, &va); if (rm == NULL) { switch (type) { case SYS_RES_IRQ: @@ -545,14 +554,12 @@ xlp_pci_alloc_resource(device_t bus, dev if (type == SYS_RES_MEMORY || type == SYS_RES_IOPORT) { if (va == 0) va = (vm_offset_t)pmap_mapdev(start, count); + if (bst == 0) + bst = rmi_pci_bus_space; + rman_set_bushandle(rv, va); rman_set_virtual(rv, (void *)va); - - /* SoC devices don't need swap */ - if (pci_get_bus(child) != 0) - rman_set_bustag(rv, rmi_pci_bus_space); - else - rman_set_bustag(rv, rmi_bus_space); + rman_set_bustag(rv, bst); } if (needactivate) { From owner-svn-src-user@FreeBSD.ORG Thu Jul 28 13:41:51 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4C03D106564A; Thu, 28 Jul 2011 13:41:51 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 23EC38FC0A; Thu, 28 Jul 2011 13:41:51 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6SDfpeN005821; Thu, 28 Jul 2011 13:41:51 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6SDfp3m005819; Thu, 28 Jul 2011 13:41:51 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201107281341.p6SDfp3m005819@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 28 Jul 2011 13:41:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224479 - user/gabor/tre-integration/contrib/tre/lib X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jul 2011 13:41:51 -0000 Author: gabor Date: Thu Jul 28 13:41:50 2011 New Revision: 224479 URL: http://svn.freebsd.org/changeset/base/224479 Log: - Eliminate more code duplication with macros Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Thu Jul 28 13:27:14 2011 (r224478) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Thu Jul 28 13:41:50 2011 (r224479) @@ -161,6 +161,21 @@ static void revs(char *str, int len); * thi. 1 */ +#define FILL_ARRAY(pat, plen) \ + for (unsigned int i = 0; i <= UCHAR_MAX; i++) \ + fg->qsBc[i] = plen - hasDot; \ + for (int i = hasDot + 1; i < plen; i++) \ + { \ + fg->qsBc[(unsigned)pat[i]] = plen - i; \ + if (fg->icase) \ + { \ + char c = islower(pat[i]) ? toupper(pat[i]) \ + : tolower(pat[i]); \ + fg->qsBc[(unsigned)c] = plen - i; \ + } \ + } + + #ifdef TRE_WCHAR #define FILL_QSBC \ /* Adjust the shift based on location of the last dot ('.'). */ \ @@ -181,32 +196,9 @@ static void revs(char *str, int len); } \ } \ \ - for (unsigned int i = 0; i <= UCHAR_MAX; i++) \ - fg->qsBc[i] = fg->len - hasDot; \ - for (int i = hasDot + 1; i < fg->len; i++) \ - { \ - fg->qsBc[(unsigned)fg->pattern[i]] = fg->len - i; \ - if (fg->icase) \ - { \ - char c = islower(fg->pattern[i]) ? toupper(fg->pattern[i]) \ - : tolower(fg->pattern[i]); \ - fg->qsBc[(unsigned)c] = fg->len - i; \ - } \ - } + FILL_ARRAY(fg->pattern, fg->len); #else -#define FILL_QSBC \ - for (unsigned int i = 0; i <= UCHAR_MAX; i++) \ - fg->qsBc[i] = fg->wlen - hasDot; \ - for (int i = hasDot + 1; i < fg->wlen; i++) \ - { \ - fg->qsBc[(unsigned)fg->wpattern[i]] = fg->wlen - i; \ - if (fg->icase) \ - { \ - char c = islower(fg->wpattern[i]) ? toupper(fg->wpattern[i]) \ - : tolower(fg->wpattern[i]); \ - fg->qsBc[(unsigned)c] = fg->len - i; \ - } \ - } +#define FILL_QSBC FILL_ARRAY(fg->wpattern, fg->wlen); #endif #define REVFUNC(name, argtype) \