From owner-svn-src-user@FreeBSD.ORG Sun Sep 27 22:31:28 2009 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 26E671065693; Sun, 27 Sep 2009 22:31:28 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F0AFD8FC15; Sun, 27 Sep 2009 22:31:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8RMVRaE036350; Sun, 27 Sep 2009 22:31:27 GMT (envelope-from rpaulo@svn.freebsd.org) Received: (from rpaulo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8RMVRtM036349; Sun, 27 Sep 2009 22:31:27 GMT (envelope-from rpaulo@svn.freebsd.org) Message-Id: <200909272231.n8RMVRtM036349@svn.freebsd.org> From: Rui Paulo Date: Sun, 27 Sep 2009 22:31:27 +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: r197546 - user/rpaulo/armpmc 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, 27 Sep 2009 22:31:28 -0000 Author: rpaulo Date: Sun Sep 27 22:31:27 2009 New Revision: 197546 URL: http://svn.freebsd.org/changeset/base/197546 Log: Workdir for ARM Performance Counters. Added: user/rpaulo/armpmc/ From owner-svn-src-user@FreeBSD.ORG Sun Sep 27 22:45:15 2009 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 71BC21065693; Sun, 27 Sep 2009 22:45:15 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5EB258FC26; Sun, 27 Sep 2009 22:45:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8RMjFsh036726; Sun, 27 Sep 2009 22:45:15 GMT (envelope-from rpaulo@svn.freebsd.org) Received: (from rpaulo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8RMjF6G036722; Sun, 27 Sep 2009 22:45:15 GMT (envelope-from rpaulo@svn.freebsd.org) Message-Id: <200909272245.n8RMjF6G036722@svn.freebsd.org> From: Rui Paulo Date: Sun, 27 Sep 2009 22:45:15 +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: r197547 - in user/rpaulo/armpmc: arm arm/include dev dev/hwpmc sys 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, 27 Sep 2009 22:45:15 -0000 Author: rpaulo Date: Sun Sep 27 22:45:15 2009 New Revision: 197547 URL: http://svn.freebsd.org/changeset/base/197547 Log: Populate from HEAD. Added: user/rpaulo/armpmc/arm/ user/rpaulo/armpmc/arm/include/ user/rpaulo/armpmc/arm/include/pmc_mdep.h - copied unchanged from r197546, head/sys/arm/include/pmc_mdep.h user/rpaulo/armpmc/dev/ user/rpaulo/armpmc/dev/hwpmc/ user/rpaulo/armpmc/dev/hwpmc/hwpmc_arm.c - copied unchanged from r197546, head/sys/dev/hwpmc/hwpmc_arm.c user/rpaulo/armpmc/sys/ user/rpaulo/armpmc/sys/pmc.h - copied unchanged from r197546, head/sys/sys/pmc.h Copied: user/rpaulo/armpmc/arm/include/pmc_mdep.h (from r197546, head/sys/arm/include/pmc_mdep.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/rpaulo/armpmc/arm/include/pmc_mdep.h Sun Sep 27 22:45:15 2009 (r197547, copy of r197546, head/sys/arm/include/pmc_mdep.h) @@ -0,0 +1,28 @@ +/*- + * This file is in the public domain. + * + * $FreeBSD$ + */ + +#ifndef _MACHINE_PMC_MDEP_H_ +#define _MACHINE_PMC_MDEP_H_ + +union pmc_md_op_pmcallocate { + uint64_t __pad[4]; +}; + +/* Logging */ +#define PMCLOG_READADDR PMCLOG_READ32 +#define PMCLOG_EMITADDR PMCLOG_EMIT32 + +#if _KERNEL +union pmc_md_pmc { +}; + +#define PMC_TRAPFRAME_TO_PC(TF) (0) /* Stubs */ +#define PMC_TRAPFRAME_TO_FP(TF) (0) +#define PMC_TRAPFRAME_TO_SP(TF) (0) + +#endif + +#endif /* !_MACHINE_PMC_MDEP_H_ */ Copied: user/rpaulo/armpmc/dev/hwpmc/hwpmc_arm.c (from r197546, head/sys/dev/hwpmc/hwpmc_arm.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/rpaulo/armpmc/dev/hwpmc/hwpmc_arm.c Sun Sep 27 22:45:15 2009 (r197547, copy of r197546, head/sys/dev/hwpmc/hwpmc_arm.c) @@ -0,0 +1,66 @@ +/*- + * Copyright (c) 2005, Joseph Koshy + * 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$"); + +#include +#include + +#include + +struct pmc_mdep * +pmc_md_initialize() +{ + return NULL; +} + +void +pmc_md_finalize(struct pmc_mdep *md) +{ + (void) md; +} + +int +pmc_save_kernel_callchain(uintptr_t *cc, int maxsamples, + struct trapframe *tf) +{ + (void) cc; + (void) maxsamples; + (void) tf; + return (0); +} + +int +pmc_save_user_callchain(uintptr_t *cc, int maxsamples, + struct trapframe *tf) +{ + (void) cc; + (void) maxsamples; + (void) tf; + return (0); +} Copied: user/rpaulo/armpmc/sys/pmc.h (from r197546, head/sys/sys/pmc.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/rpaulo/armpmc/sys/pmc.h Sun Sep 27 22:45:15 2009 (r197547, copy of r197546, head/sys/sys/pmc.h) @@ -0,0 +1,1056 @@ +/*- + * Copyright (c) 2003-2008, Joseph Koshy + * Copyright (c) 2007 The FreeBSD Foundation + * All rights reserved. + * + * Portions of this software were developed by A. Joseph Koshy under + * sponsorship from the FreeBSD Foundation and Google, Inc. + * + * 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. + * + * $FreeBSD$ + */ + +#ifndef _SYS_PMC_H_ +#define _SYS_PMC_H_ + +#include + +#include +#include + +#define PMC_MODULE_NAME "hwpmc" +#define PMC_NAME_MAX 16 /* HW counter name size */ +#define PMC_CLASS_MAX 4 /* max #classes of PMCs per-system */ + +/* + * Kernel<->userland API version number [MMmmpppp] + * + * Major numbers are to be incremented when an incompatible change to + * the ABI occurs that older clients will not be able to handle. + * + * Minor numbers are incremented when a backwards compatible change + * occurs that allows older correct programs to run unchanged. For + * example, when support for a new PMC type is added. + * + * The patch version is incremented for every bug fix. + */ +#define PMC_VERSION_MAJOR 0x03 +#define PMC_VERSION_MINOR 0x01 +#define PMC_VERSION_PATCH 0x0000 + +#define PMC_VERSION (PMC_VERSION_MAJOR << 24 | \ + PMC_VERSION_MINOR << 16 | PMC_VERSION_PATCH) + +/* + * Kinds of CPUs known. + * + * We keep track of CPU variants that need to be distinguished in + * some way for PMC operations. CPU names are grouped by manufacturer + * and numbered sparsely in order to minimize changes to the ABI involved + * when new CPUs are added. + */ + +#define __PMC_CPUS() \ + __PMC_CPU(AMD_K7, 0x00, "AMD K7") \ + __PMC_CPU(AMD_K8, 0x01, "AMD K8") \ + __PMC_CPU(INTEL_P5, 0x80, "Intel Pentium") \ + __PMC_CPU(INTEL_P6, 0x81, "Intel Pentium Pro") \ + __PMC_CPU(INTEL_CL, 0x82, "Intel Celeron") \ + __PMC_CPU(INTEL_PII, 0x83, "Intel Pentium II") \ + __PMC_CPU(INTEL_PIII, 0x84, "Intel Pentium III") \ + __PMC_CPU(INTEL_PM, 0x85, "Intel Pentium M") \ + __PMC_CPU(INTEL_PIV, 0x86, "Intel Pentium IV") \ + __PMC_CPU(INTEL_CORE, 0x87, "Intel Core Solo/Duo") \ + __PMC_CPU(INTEL_CORE2, 0x88, "Intel Core2") \ + __PMC_CPU(INTEL_CORE2EXTREME, 0x89, "Intel Core2 Extreme") \ + __PMC_CPU(INTEL_ATOM, 0x8A, "Intel Atom") \ + __PMC_CPU(INTEL_COREI7, 0x8B, "Intel Core i7") + +enum pmc_cputype { +#undef __PMC_CPU +#define __PMC_CPU(S,V,D) PMC_CPU_##S = V, + __PMC_CPUS() +}; + +#define PMC_CPU_FIRST PMC_CPU_AMD_K7 +#define PMC_CPU_LAST PMC_CPU_INTEL_COREI7 + +/* + * Classes of PMCs + */ + +#define __PMC_CLASSES() \ + __PMC_CLASS(TSC) /* CPU Timestamp counter */ \ + __PMC_CLASS(K7) /* AMD K7 performance counters */ \ + __PMC_CLASS(K8) /* AMD K8 performance counters */ \ + __PMC_CLASS(P5) /* Intel Pentium counters */ \ + __PMC_CLASS(P6) /* Intel Pentium Pro counters */ \ + __PMC_CLASS(P4) /* Intel Pentium-IV counters */ \ + __PMC_CLASS(IAF) /* Intel Core2/Atom, fixed function */ \ + __PMC_CLASS(IAP) /* Intel Core...Atom, programmable */ + +enum pmc_class { +#undef __PMC_CLASS +#define __PMC_CLASS(N) PMC_CLASS_##N , + __PMC_CLASSES() +}; + +#define PMC_CLASS_FIRST PMC_CLASS_TSC +#define PMC_CLASS_LAST PMC_CLASS_IAP + +/* + * A PMC can be in the following states: + * + * Hardware states: + * DISABLED -- administratively prohibited from being used. + * FREE -- HW available for use + * Software states: + * ALLOCATED -- allocated + * STOPPED -- allocated, but not counting events + * RUNNING -- allocated, and in operation; 'pm_runcount' + * holds the number of CPUs using this PMC at + * a given instant + * DELETED -- being destroyed + */ + +#define __PMC_HWSTATES() \ + __PMC_STATE(DISABLED) \ + __PMC_STATE(FREE) + +#define __PMC_SWSTATES() \ + __PMC_STATE(ALLOCATED) \ + __PMC_STATE(STOPPED) \ + __PMC_STATE(RUNNING) \ + __PMC_STATE(DELETED) + +#define __PMC_STATES() \ + __PMC_HWSTATES() \ + __PMC_SWSTATES() + +enum pmc_state { +#undef __PMC_STATE +#define __PMC_STATE(S) PMC_STATE_##S, + __PMC_STATES() + __PMC_STATE(MAX) +}; + +#define PMC_STATE_FIRST PMC_STATE_DISABLED +#define PMC_STATE_LAST PMC_STATE_DELETED + +/* + * An allocated PMC may used as a 'global' counter or as a + * 'thread-private' one. Each such mode of use can be in either + * statistical sampling mode or in counting mode. Thus a PMC in use + * + * SS i.e., SYSTEM STATISTICAL -- system-wide statistical profiling + * SC i.e., SYSTEM COUNTER -- system-wide counting mode + * TS i.e., THREAD STATISTICAL -- thread virtual, statistical profiling + * TC i.e., THREAD COUNTER -- thread virtual, counting mode + * + * Statistical profiling modes rely on the PMC periodically delivering + * a interrupt to the CPU (when the configured number of events have + * been measured), so the PMC must have the ability to generate + * interrupts. + * + * In counting modes, the PMC counts its configured events, with the + * value of the PMC being read whenever needed by its owner process. + * + * The thread specific modes "virtualize" the PMCs -- the PMCs appear + * to be thread private and count events only when the profiled thread + * actually executes on the CPU. + * + * The system-wide "global" modes keep the PMCs running all the time + * and are used to measure the behaviour of the whole system. + */ + +#define __PMC_MODES() \ + __PMC_MODE(SS, 0) \ + __PMC_MODE(SC, 1) \ + __PMC_MODE(TS, 2) \ + __PMC_MODE(TC, 3) + +enum pmc_mode { +#undef __PMC_MODE +#define __PMC_MODE(M,N) PMC_MODE_##M = N, + __PMC_MODES() +}; + +#define PMC_MODE_FIRST PMC_MODE_SS +#define PMC_MODE_LAST PMC_MODE_TC + +#define PMC_IS_COUNTING_MODE(mode) \ + ((mode) == PMC_MODE_SC || (mode) == PMC_MODE_TC) +#define PMC_IS_SYSTEM_MODE(mode) \ + ((mode) == PMC_MODE_SS || (mode) == PMC_MODE_SC) +#define PMC_IS_SAMPLING_MODE(mode) \ + ((mode) == PMC_MODE_SS || (mode) == PMC_MODE_TS) +#define PMC_IS_VIRTUAL_MODE(mode) \ + ((mode) == PMC_MODE_TS || (mode) == PMC_MODE_TC) + +/* + * PMC row disposition + */ + +#define __PMC_DISPOSITIONS(N) \ + __PMC_DISP(STANDALONE) /* global/disabled counters */ \ + __PMC_DISP(FREE) /* free/available */ \ + __PMC_DISP(THREAD) /* thread-virtual PMCs */ \ + __PMC_DISP(UNKNOWN) /* sentinel */ + +enum pmc_disp { +#undef __PMC_DISP +#define __PMC_DISP(D) PMC_DISP_##D , + __PMC_DISPOSITIONS() +}; + +#define PMC_DISP_FIRST PMC_DISP_STANDALONE +#define PMC_DISP_LAST PMC_DISP_THREAD + +/* + * Counter capabilities + * + * __PMC_CAPS(NAME, VALUE, DESCRIPTION) + */ + +#define __PMC_CAPS() \ + __PMC_CAP(INTERRUPT, 0, "generate interrupts") \ + __PMC_CAP(USER, 1, "count user-mode events") \ + __PMC_CAP(SYSTEM, 2, "count system-mode events") \ + __PMC_CAP(EDGE, 3, "do edge detection of events") \ + __PMC_CAP(THRESHOLD, 4, "ignore events below a threshold") \ + __PMC_CAP(READ, 5, "read PMC counter") \ + __PMC_CAP(WRITE, 6, "reprogram PMC counter") \ + __PMC_CAP(INVERT, 7, "invert comparision sense") \ + __PMC_CAP(QUALIFIER, 8, "further qualify monitored events") \ + __PMC_CAP(PRECISE, 9, "perform precise sampling") \ + __PMC_CAP(TAGGING, 10, "tag upstream events") \ + __PMC_CAP(CASCADE, 11, "cascade counters") + +enum pmc_caps +{ +#undef __PMC_CAP +#define __PMC_CAP(NAME, VALUE, DESCR) PMC_CAP_##NAME = (1 << VALUE) , + __PMC_CAPS() +}; + +#define PMC_CAP_FIRST PMC_CAP_INTERRUPT +#define PMC_CAP_LAST PMC_CAP_CASCADE + +/* + * PMC Event Numbers + * + * These are generated from the definitions in "dev/hwpmc/pmc_events.h". + */ + +enum pmc_event { +#undef __PMC_EV +#undef __PMC_EV_BLOCK +#define __PMC_EV_BLOCK(C,V) PMC_EV_ ## C ## __BLOCK_START = (V) - 1 , +#define __PMC_EV(C,N) PMC_EV_ ## C ## _ ## N , + __PMC_EVENTS() +}; + +/* + * PMC SYSCALL INTERFACE + */ + +/* + * "PMC_OPS" -- these are the commands recognized by the kernel + * module, and are used when performing a system call from userland. + */ +#define __PMC_OPS() \ + __PMC_OP(CONFIGURELOG, "Set log file") \ + __PMC_OP(FLUSHLOG, "Flush log file") \ + __PMC_OP(GETCPUINFO, "Get system CPU information") \ + __PMC_OP(GETDRIVERSTATS, "Get driver statistics") \ + __PMC_OP(GETMODULEVERSION, "Get module version") \ + __PMC_OP(GETPMCINFO, "Get per-cpu PMC information") \ + __PMC_OP(PMCADMIN, "Set PMC state") \ + __PMC_OP(PMCALLOCATE, "Allocate and configure a PMC") \ + __PMC_OP(PMCATTACH, "Attach a PMC to a process") \ + __PMC_OP(PMCDETACH, "Detach a PMC from a process") \ + __PMC_OP(PMCGETMSR, "Get a PMC's hardware address") \ + __PMC_OP(PMCRELEASE, "Release a PMC") \ + __PMC_OP(PMCRW, "Read/Set a PMC") \ + __PMC_OP(PMCSETCOUNT, "Set initial count/sampling rate") \ + __PMC_OP(PMCSTART, "Start a PMC") \ + __PMC_OP(PMCSTOP, "Start a PMC") \ + __PMC_OP(WRITELOG, "Write a cookie to the log file") + + +enum pmc_ops { +#undef __PMC_OP +#define __PMC_OP(N, D) PMC_OP_##N, + __PMC_OPS() +}; + + +/* + * Flags used in operations on PMCs. + */ + +#define PMC_F_FORCE 0x00000001 /*OP ADMIN force operation */ +#define PMC_F_DESCENDANTS 0x00000002 /*OP ALLOCATE track descendants */ +#define PMC_F_LOG_PROCCSW 0x00000004 /*OP ALLOCATE track ctx switches */ +#define PMC_F_LOG_PROCEXIT 0x00000008 /*OP ALLOCATE log proc exits */ +#define PMC_F_NEWVALUE 0x00000010 /*OP RW write new value */ +#define PMC_F_OLDVALUE 0x00000020 /*OP RW get old value */ +#define PMC_F_KGMON 0x00000040 /*OP ALLOCATE kgmon(8) profiling */ +/* V2 API */ +#define PMC_F_CALLCHAIN 0x00000080 /*OP ALLOCATE capture callchains */ + +/* internal flags */ +#define PMC_F_ATTACHED_TO_OWNER 0x00010000 /*attached to owner*/ +#define PMC_F_NEEDS_LOGFILE 0x00020000 /*needs log file */ +#define PMC_F_ATTACH_DONE 0x00040000 /*attached at least once */ + +#define PMC_CALLCHAIN_DEPTH_MAX 32 +#define PMC_CC_F_USERSPACE 0x01 /*userspace callchain*/ + +/* + * Cookies used to denote allocated PMCs, and the values of PMCs. + */ + +typedef uint32_t pmc_id_t; +typedef uint64_t pmc_value_t; + +#define PMC_ID_INVALID (~ (pmc_id_t) 0) + +/* + * PMC IDs have the following format: + * + * +--------+----------+-----------+-----------+ + * | CPU | PMC MODE | PMC CLASS | ROW INDEX | + * +--------+----------+-----------+-----------+ + * + * where each field is 8 bits wide. Field 'CPU' is set to the + * requested CPU for system-wide PMCs or PMC_CPU_ANY for process-mode + * PMCs. Field 'PMC MODE' is the allocated PMC mode. Field 'PMC + * CLASS' is the class of the PMC. Field 'ROW INDEX' is the row index + * for the PMC. + * + * The 'ROW INDEX' ranges over 0..NWPMCS where NHWPMCS is the total + * number of hardware PMCs on this cpu. + */ + + +#define PMC_ID_TO_ROWINDEX(ID) ((ID) & 0xFF) +#define PMC_ID_TO_CLASS(ID) (((ID) & 0xFF00) >> 8) +#define PMC_ID_TO_MODE(ID) (((ID) & 0xFF0000) >> 16) +#define PMC_ID_TO_CPU(ID) (((ID) & 0xFF000000) >> 24) +#define PMC_ID_MAKE_ID(CPU,MODE,CLASS,ROWINDEX) \ + ((((CPU) & 0xFF) << 24) | (((MODE) & 0xFF) << 16) | \ + (((CLASS) & 0xFF) << 8) | ((ROWINDEX) & 0xFF)) + +/* + * Data structures for system calls supported by the pmc driver. + */ + +/* + * OP PMCALLOCATE + * + * Allocate a PMC on the named CPU. + */ + +#define PMC_CPU_ANY ~0 + +struct pmc_op_pmcallocate { + uint32_t pm_caps; /* PMC_CAP_* */ + uint32_t pm_cpu; /* CPU number or PMC_CPU_ANY */ + enum pmc_class pm_class; /* class of PMC desired */ + enum pmc_event pm_ev; /* [enum pmc_event] desired */ + uint32_t pm_flags; /* additional modifiers PMC_F_* */ + enum pmc_mode pm_mode; /* desired mode */ + pmc_id_t pm_pmcid; /* [return] process pmc id */ + + union pmc_md_op_pmcallocate pm_md; /* MD layer extensions */ +}; + +/* + * OP PMCADMIN + * + * Set the administrative state (i.e., whether enabled or disabled) of + * a PMC 'pm_pmc' on CPU 'pm_cpu'. Note that 'pm_pmc' specifies an + * absolute PMC number and need not have been first allocated by the + * calling process. + */ + +struct pmc_op_pmcadmin { + int pm_cpu; /* CPU# */ + uint32_t pm_flags; /* flags */ + int pm_pmc; /* PMC# */ + enum pmc_state pm_state; /* desired state */ +}; + +/* + * OP PMCATTACH / OP PMCDETACH + * + * Attach/detach a PMC and a process. + */ + +struct pmc_op_pmcattach { + pmc_id_t pm_pmc; /* PMC to attach to */ + pid_t pm_pid; /* target process */ +}; + +/* + * OP PMCSETCOUNT + * + * Set the sampling rate (i.e., the reload count) for statistical counters. + * 'pm_pmcid' need to have been previously allocated using PMCALLOCATE. + */ + +struct pmc_op_pmcsetcount { + pmc_value_t pm_count; /* initial/sample count */ + pmc_id_t pm_pmcid; /* PMC id to set */ +}; + + +/* + * OP PMCRW + * + * Read the value of a PMC named by 'pm_pmcid'. 'pm_pmcid' needs + * to have been previously allocated using PMCALLOCATE. + */ + + +struct pmc_op_pmcrw { + uint32_t pm_flags; /* PMC_F_{OLD,NEW}VALUE*/ + pmc_id_t pm_pmcid; /* pmc id */ + pmc_value_t pm_value; /* new&returned value */ +}; + + +/* + * OP GETPMCINFO + * + * retrieve PMC state for a named CPU. The caller is expected to + * allocate 'npmc' * 'struct pmc_info' bytes of space for the return + * values. + */ + +struct pmc_info { + char pm_name[PMC_NAME_MAX]; /* pmc name */ + enum pmc_class pm_class; /* enum pmc_class */ + int pm_enabled; /* whether enabled */ + enum pmc_disp pm_rowdisp; /* FREE, THREAD or STANDLONE */ + pid_t pm_ownerpid; /* owner, or -1 */ + enum pmc_mode pm_mode; /* current mode [enum pmc_mode] */ + enum pmc_event pm_event; /* current event */ + uint32_t pm_flags; /* current flags */ + pmc_value_t pm_reloadcount; /* sampling counters only */ +}; + +struct pmc_op_getpmcinfo { + int32_t pm_cpu; /* 0 <= cpu < mp_maxid */ + struct pmc_info pm_pmcs[]; /* space for 'npmc' structures */ +}; + + +/* + * OP GETCPUINFO + * + * Retrieve system CPU information. + */ + +struct pmc_classinfo { + enum pmc_class pm_class; /* class id */ + uint32_t pm_caps; /* counter capabilities */ + uint32_t pm_width; /* width of the PMC */ + uint32_t pm_num; /* number of PMCs in class */ +}; + +struct pmc_op_getcpuinfo { + enum pmc_cputype pm_cputype; /* what kind of CPU */ + uint32_t pm_ncpu; /* max CPU number */ + uint32_t pm_npmc; /* #PMCs per CPU */ + uint32_t pm_nclass; /* #classes of PMCs */ + struct pmc_classinfo pm_classes[PMC_CLASS_MAX]; +}; + +/* + * OP CONFIGURELOG + * + * Configure a log file for writing system-wide statistics to. + */ + +struct pmc_op_configurelog { + int pm_flags; + int pm_logfd; /* logfile fd (or -1) */ +}; + +/* + * OP GETDRIVERSTATS + * + * Retrieve pmc(4) driver-wide statistics. + */ + +struct pmc_op_getdriverstats { + int pm_intr_ignored; /* #interrupts ignored */ + int pm_intr_processed; /* #interrupts processed */ + int pm_intr_bufferfull; /* #interrupts with ENOSPC */ + int pm_syscalls; /* #syscalls */ + int pm_syscall_errors; /* #syscalls with errors */ + int pm_buffer_requests; /* #buffer requests */ + int pm_buffer_requests_failed; /* #failed buffer requests */ + int pm_log_sweeps; /* #sample buffer processing passes */ +}; + +/* + * OP RELEASE / OP START / OP STOP + * + * Simple operations on a PMC id. + */ + +struct pmc_op_simple { + pmc_id_t pm_pmcid; +}; + +/* + * OP WRITELOG + * + * Flush the current log buffer and write 4 bytes of user data to it. + */ + +struct pmc_op_writelog { + uint32_t pm_userdata; +}; + +/* + * OP GETMSR + * + * Retrieve the machine specific address assoicated with the allocated + * PMC. This number can be used subsequently with a read-performance-counter + * instruction. + */ + +struct pmc_op_getmsr { + uint32_t pm_msr; /* machine specific address */ + pmc_id_t pm_pmcid; /* allocated pmc id */ +}; + +#ifdef _KERNEL + +#include +#include + +#include + +#define PMC_HASH_SIZE 16 +#define PMC_MTXPOOL_SIZE 32 +#define PMC_LOG_BUFFER_SIZE 4 +#define PMC_NLOGBUFFERS 16 +#define PMC_NSAMPLES 32 +#define PMC_CALLCHAIN_DEPTH 8 + +#define PMC_SYSCTL_NAME_PREFIX "kern." PMC_MODULE_NAME "." + +/* + * Locking keys + * + * (b) - pmc_bufferlist_mtx (spin lock) + * (k) - pmc_kthread_mtx (sleep lock) + * (o) - po->po_mtx (spin lock) + */ + +/* + * PMC commands + */ + +struct pmc_syscall_args { + uint32_t pmop_code; /* one of PMC_OP_* */ + void *pmop_data; /* syscall parameter */ +}; + +/* + * Interface to processor specific s1tuff + */ + +/* + * struct pmc_descr + * + * Machine independent (i.e., the common parts) of a human readable + * PMC description. + */ + +struct pmc_descr { + char pd_name[PMC_NAME_MAX]; /* name */ + uint32_t pd_caps; /* capabilities */ + enum pmc_class pd_class; /* class of the PMC */ + uint32_t pd_width; /* width in bits */ +}; + +/* + * struct pmc_target + * + * This structure records all the target processes associated with a + * PMC. + */ + +struct pmc_target { + LIST_ENTRY(pmc_target) pt_next; + struct pmc_process *pt_process; /* target descriptor */ +}; + +/* + * struct pmc + * + * Describes each allocated PMC. + * + * Each PMC has precisely one owner, namely the process that allocated + * the PMC. + * + * A PMC may be attached to multiple target processes. The + * 'pm_targets' field links all the target processes being monitored + * by this PMC. + * + * The 'pm_savedvalue' field is protected by a mutex. + * + * On a multi-cpu machine, multiple target threads associated with a + * process-virtual PMC could be concurrently executing on different + * CPUs. The 'pm_runcount' field is atomically incremented every time + * the PMC gets scheduled on a CPU and atomically decremented when it + * get descheduled. Deletion of a PMC is only permitted when this + * field is '0'. + * + */ + +struct pmc { + LIST_HEAD(,pmc_target) pm_targets; /* list of target processes */ + LIST_ENTRY(pmc) pm_next; /* owner's list */ + + /* + * System-wide PMCs are allocated on a CPU and are not moved + * around. For system-wide PMCs we record the CPU the PMC was + * allocated on in the 'CPU' field of the pmc ID. + * + * Virtual PMCs run on whichever CPU is currently executing + * their targets' threads. For these PMCs we need to save + * their current PMC counter values when they are taken off + * CPU. + */ + + union { + pmc_value_t pm_savedvalue; /* Virtual PMCS */ + } pm_gv; + + /* + * For sampling mode PMCs, we keep track of the PMC's "reload + * count", which is the counter value to be loaded in when + * arming the PMC for the next counting session. For counting + * modes on PMCs that are read-only (e.g., the x86 TSC), we + * keep track of the initial value at the start of + * counting-mode operation. + */ + + union { + pmc_value_t pm_reloadcount; /* sampling PMC modes */ + pmc_value_t pm_initial; /* counting PMC modes */ + } pm_sc; + + uint32_t pm_stalled; /* marks stalled sampling PMCs */ + uint32_t pm_caps; /* PMC capabilities */ + enum pmc_event pm_event; /* event being measured */ + uint32_t pm_flags; /* additional flags PMC_F_... */ + struct pmc_owner *pm_owner; /* owner thread state */ + uint32_t pm_runcount; /* #cpus currently on */ + enum pmc_state pm_state; /* current PMC state */ + + /* + * The PMC ID field encodes the row-index for the PMC, its + * mode, class and the CPU# associated with the PMC. + */ + + pmc_id_t pm_id; /* allocated PMC id */ + + /* md extensions */ + union pmc_md_pmc pm_md; +}; + +/* + * Accessor macros for 'struct pmc' + */ + +#define PMC_TO_MODE(P) PMC_ID_TO_MODE((P)->pm_id) +#define PMC_TO_CLASS(P) PMC_ID_TO_CLASS((P)->pm_id) +#define PMC_TO_ROWINDEX(P) PMC_ID_TO_ROWINDEX((P)->pm_id) +#define PMC_TO_CPU(P) PMC_ID_TO_CPU((P)->pm_id) + + +/* + * struct pmc_process + * + * Record a 'target' process being profiled. + * + * The target process being profiled could be different from the owner + * process which allocated the PMCs. Each target process descriptor + * is associated with NHWPMC 'struct pmc *' pointers. Each PMC at a + * given hardware row-index 'n' will use slot 'n' of the 'pp_pmcs[]' + * array. The size of this structure is thus PMC architecture + * dependent. + * + */ + +struct pmc_targetstate { + struct pmc *pp_pmc; /* target PMC */ + pmc_value_t pp_pmcval; /* per-process value */ +}; + +struct pmc_process { + LIST_ENTRY(pmc_process) pp_next; /* hash chain */ + int pp_refcnt; /* reference count */ + uint32_t pp_flags; /* flags PMC_PP_* */ + struct proc *pp_proc; /* target thread */ + struct pmc_targetstate pp_pmcs[]; /* NHWPMCs */ +}; + +#define PMC_PP_ENABLE_MSR_ACCESS 0x00000001 + +/* + * struct pmc_owner + * + * We associate a PMC with an 'owner' process. + * + * A process can be associated with 0..NCPUS*NHWPMC PMCs during its + * lifetime, where NCPUS is the numbers of CPUS in the system and + * NHWPMC is the number of hardware PMCs per CPU. These are + * maintained in the list headed by the 'po_pmcs' to save on space. + * + */ + +struct pmc_owner { + LIST_ENTRY(pmc_owner) po_next; /* hash chain */ + LIST_ENTRY(pmc_owner) po_ssnext; /* list of SS PMC owners */ + LIST_HEAD(, pmc) po_pmcs; /* owned PMC list */ + TAILQ_HEAD(, pmclog_buffer) po_logbuffers; /* (o) logbuffer list */ + struct mtx po_mtx; /* spin lock for (o) */ + struct proc *po_owner; /* owner proc */ + uint32_t po_flags; /* (k) flags PMC_PO_* */ + struct proc *po_kthread; /* (k) helper kthread */ + struct pmclog_buffer *po_curbuf; /* current log buffer */ + struct file *po_file; /* file reference */ + int po_error; /* recorded error */ + int po_sscount; /* # SS PMCs owned */ +}; + +#define PMC_PO_OWNS_LOGFILE 0x00000001 /* has a log file */ +#define PMC_PO_IN_FLUSH 0x00000010 /* in the middle of a flush */ +#define PMC_PO_INITIAL_MAPPINGS_DONE 0x00000020 + +/* + * struct pmc_hw -- describe the state of the PMC hardware + * + * When in use, a HW PMC is associated with one allocated 'struct pmc' + * pointed to by field 'phw_pmc'. When inactive, this field is NULL. + * + * On an SMP box, one or more HW PMC's in process virtual mode with + * the same 'phw_pmc' could be executing on different CPUs. In order + * to handle this case correctly, we need to ensure that only + * incremental counts get added to the saved value in the associated + * 'struct pmc'. The 'phw_save' field is used to keep the saved PMC + * value at the time the hardware is started during this context + * switch (i.e., the difference between the new (hardware) count and + * the saved count is atomically added to the count field in 'struct + * pmc' at context switch time). + * + */ + +struct pmc_hw { + uint32_t phw_state; /* see PHW_* macros below */ + struct pmc *phw_pmc; /* current thread PMC */ +}; + +#define PMC_PHW_RI_MASK 0x000000FF +#define PMC_PHW_CPU_SHIFT 8 +#define PMC_PHW_CPU_MASK 0x0000FF00 +#define PMC_PHW_FLAGS_SHIFT 16 +#define PMC_PHW_FLAGS_MASK 0xFFFF0000 + +#define PMC_PHW_INDEX_TO_STATE(ri) ((ri) & PMC_PHW_RI_MASK) +#define PMC_PHW_STATE_TO_INDEX(state) ((state) & PMC_PHW_RI_MASK) +#define PMC_PHW_CPU_TO_STATE(cpu) (((cpu) << PMC_PHW_CPU_SHIFT) & \ + PMC_PHW_CPU_MASK) +#define PMC_PHW_STATE_TO_CPU(state) (((state) & PMC_PHW_CPU_MASK) >> \ + PMC_PHW_CPU_SHIFT) +#define PMC_PHW_FLAGS_TO_STATE(flags) (((flags) << PMC_PHW_FLAGS_SHIFT) & \ + PMC_PHW_FLAGS_MASK) +#define PMC_PHW_STATE_TO_FLAGS(state) (((state) & PMC_PHW_FLAGS_MASK) >> \ + PMC_PHW_FLAGS_SHIFT) +#define PMC_PHW_FLAG_IS_ENABLED (PMC_PHW_FLAGS_TO_STATE(0x01)) +#define PMC_PHW_FLAG_IS_SHAREABLE (PMC_PHW_FLAGS_TO_STATE(0x02)) + +/* + * struct pmc_sample + * + * Space for N (tunable) PC samples and associated control data. + */ + +struct pmc_sample { + uint16_t ps_nsamples; /* callchain depth */ + uint8_t ps_cpu; /* cpu number */ + uint8_t ps_flags; /* other flags */ + pid_t ps_pid; /* process PID or -1 */ + struct thread *ps_td; /* which thread */ + struct pmc *ps_pmc; /* interrupting PMC */ + uintptr_t *ps_pc; /* (const) callchain start */ +}; + +#define PMC_SAMPLE_FREE ((uint16_t) 0) +#define PMC_SAMPLE_INUSE ((uint16_t) 0xFFFF) + +struct pmc_samplebuffer { + struct pmc_sample * volatile ps_read; /* read pointer */ + struct pmc_sample * volatile ps_write; /* write pointer */ + uintptr_t *ps_callchains; /* all saved call chains */ + struct pmc_sample *ps_fence; /* one beyond ps_samples[] */ + struct pmc_sample ps_samples[]; /* array of sample entries */ +}; + + +/* + * struct pmc_cpustate + * + * A CPU is modelled as a collection of HW PMCs with space for additional + * flags. + */ + +struct pmc_cpu { + uint32_t pc_state; /* physical cpu number + flags */ + struct pmc_samplebuffer *pc_sb; /* space for samples */ + struct pmc_hw *pc_hwpmcs[]; /* 'npmc' pointers */ +}; + +#define PMC_PCPU_CPU_MASK 0x000000FF +#define PMC_PCPU_FLAGS_MASK 0xFFFFFF00 +#define PMC_PCPU_FLAGS_SHIFT 8 +#define PMC_PCPU_STATE_TO_CPU(S) ((S) & PMC_PCPU_CPU_MASK) +#define PMC_PCPU_STATE_TO_FLAGS(S) (((S) & PMC_PCPU_FLAGS_MASK) >> PMC_PCPU_FLAGS_SHIFT) +#define PMC_PCPU_FLAGS_TO_STATE(F) (((F) << PMC_PCPU_FLAGS_SHIFT) & PMC_PCPU_FLAGS_MASK) +#define PMC_PCPU_CPU_TO_STATE(C) ((C) & PMC_PCPU_CPU_MASK) +#define PMC_PCPU_FLAG_HTT (PMC_PCPU_FLAGS_TO_STATE(0x1)) + +/* + * struct pmc_binding + * + * CPU binding information. + */ + +struct pmc_binding { + int pb_bound; /* is bound? */ + int pb_cpu; /* if so, to which CPU */ +}; + + +struct pmc_mdep; + +/* + * struct pmc_classdep + * + * PMC class-dependent operations. + */ +struct pmc_classdep { + uint32_t pcd_caps; /* class capabilities */ + enum pmc_class pcd_class; /* class id */ + int pcd_num; /* number of PMCs */ + int pcd_ri; /* row index of the first PMC in class */ + int pcd_width; /* width of the PMC */ + + /* configuring/reading/writing the hardware PMCs */ + int (*pcd_config_pmc)(int _cpu, int _ri, struct pmc *_pm); + int (*pcd_get_config)(int _cpu, int _ri, struct pmc **_ppm); + int (*pcd_read_pmc)(int _cpu, int _ri, pmc_value_t *_value); + int (*pcd_write_pmc)(int _cpu, int _ri, pmc_value_t _value); + + /* pmc allocation/release */ + int (*pcd_allocate_pmc)(int _cpu, int _ri, struct pmc *_t, + const struct pmc_op_pmcallocate *_a); + int (*pcd_release_pmc)(int _cpu, int _ri, struct pmc *_pm); + + /* starting and stopping PMCs */ + int (*pcd_start_pmc)(int _cpu, int _ri); + int (*pcd_stop_pmc)(int _cpu, int _ri); + + /* description */ + int (*pcd_describe)(int _cpu, int _ri, struct pmc_info *_pi, + struct pmc **_ppmc); + + /* class-dependent initialization & finalization */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Sun Sep 27 22:49:30 2009 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 0746B1065670; Sun, 27 Sep 2009 22:49:30 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E9A2F8FC17; Sun, 27 Sep 2009 22:49:29 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8RMnTeG036837; Sun, 27 Sep 2009 22:49:29 GMT (envelope-from rpaulo@svn.freebsd.org) Received: (from rpaulo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8RMnT9I036833; Sun, 27 Sep 2009 22:49:29 GMT (envelope-from rpaulo@svn.freebsd.org) Message-Id: <200909272249.n8RMnT9I036833@svn.freebsd.org> From: Rui Paulo Date: Sun, 27 Sep 2009 22:49:29 +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: r197548 - in user/rpaulo/armpmc: arm/include dev/hwpmc 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, 27 Sep 2009 22:49:30 -0000 Author: rpaulo Date: Sun Sep 27 22:49:29 2009 New Revision: 197548 URL: http://svn.freebsd.org/changeset/base/197548 Log: Add initial changes. Cooked mostly during EuroBSDCon 09. Added: user/rpaulo/armpmc/dev/hwpmc/hwpmc_xscale.c (contents, props changed) Modified: user/rpaulo/armpmc/arm/include/pmc_mdep.h user/rpaulo/armpmc/dev/hwpmc/hwpmc_arm.c Modified: user/rpaulo/armpmc/arm/include/pmc_mdep.h ============================================================================== --- user/rpaulo/armpmc/arm/include/pmc_mdep.h Sun Sep 27 22:45:15 2009 (r197547) +++ user/rpaulo/armpmc/arm/include/pmc_mdep.h Sun Sep 27 22:49:29 2009 (r197548) @@ -15,14 +15,20 @@ union pmc_md_op_pmcallocate { #define PMCLOG_READADDR PMCLOG_READ32 #define PMCLOG_EMITADDR PMCLOG_EMIT32 -#if _KERNEL +#ifdef _KERNEL union pmc_md_pmc { + struct pmc_md_xscale_pmc pm_xscale; }; -#define PMC_TRAPFRAME_TO_PC(TF) (0) /* Stubs */ -#define PMC_TRAPFRAME_TO_FP(TF) (0) -#define PMC_TRAPFRAME_TO_SP(TF) (0) +#define PMC_TRAPFRAME_TO_PC(TF) ((TF)->tf_pc) +#define PMC_TRAPFRAME_TO_FP(TF) ((TF)->tf_usr_lr) +#define PMC_TRAPFRAME_TO_SP(TF) ((TF)->tf_usr_sp) -#endif +/* + * Prototypes + */ +struct pmc_mdep *pmc_xscale_initialize(void); +void pmc_xscale_finalize(struct pmc_mdep *_md); +#endif /* _KERNEL */ #endif /* !_MACHINE_PMC_MDEP_H_ */ Modified: user/rpaulo/armpmc/dev/hwpmc/hwpmc_arm.c ============================================================================== --- user/rpaulo/armpmc/dev/hwpmc/hwpmc_arm.c Sun Sep 27 22:45:15 2009 (r197547) +++ user/rpaulo/armpmc/dev/hwpmc/hwpmc_arm.c Sun Sep 27 22:49:29 2009 (r197548) @@ -36,13 +36,20 @@ __FBSDID("$FreeBSD$"); struct pmc_mdep * pmc_md_initialize() { - return NULL; + if (cpu_class == CPU_CLASS_XSCALE) + return pmc_xscale_initialize(); + else + return NULL; } void pmc_md_finalize(struct pmc_mdep *md) { - (void) md; + if (cpu_class == CPU_CLASS_XSCALE) + return pmc_xscale_finalize(); + else + KASSERT(0, ("[arm,%d] Unknown CPU Class 0x%x", __LINE__, + cpu_class)); } int Added: user/rpaulo/armpmc/dev/hwpmc/hwpmc_xscale.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/rpaulo/armpmc/dev/hwpmc/hwpmc_xscale.c Sun Sep 27 22:49:29 2009 (r197548) @@ -0,0 +1,54 @@ +/*- + * Copyright (c) 2009 Rui Paulo + * 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$"); + +/* Support for the Intel XScale network processors */ + +#include +#include + +#include + +struct xscale_event_code_map { + enum pmc_event pe_ev; + uint8_t pe_code; + uint8_t pe_mask; +}; + +struct pmc_mdep * +pmc_xscale_initialize() +{ + return NULL; +} + +void +pmc_xscale_finalize(struct pmc_mdep *md) +{ + (void) md; +} From owner-svn-src-user@FreeBSD.ORG Sun Sep 27 22:50:18 2009 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 44B40106568B; Sun, 27 Sep 2009 22:50:18 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 33B1E8FC12; Sun, 27 Sep 2009 22:50:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8RMoIr4036893; Sun, 27 Sep 2009 22:50:18 GMT (envelope-from rpaulo@svn.freebsd.org) Received: (from rpaulo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8RMoIFJ036891; Sun, 27 Sep 2009 22:50:18 GMT (envelope-from rpaulo@svn.freebsd.org) Message-Id: <200909272250.n8RMoIFJ036891@svn.freebsd.org> From: Rui Paulo Date: Sun, 27 Sep 2009 22:50:18 +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: r197549 - user/rpaulo/armpmc/sys 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, 27 Sep 2009 22:50:18 -0000 Author: rpaulo Date: Sun Sep 27 22:50:17 2009 New Revision: 197549 URL: http://svn.freebsd.org/changeset/base/197549 Log: add xscale Modified: user/rpaulo/armpmc/sys/pmc.h Modified: user/rpaulo/armpmc/sys/pmc.h ============================================================================== --- user/rpaulo/armpmc/sys/pmc.h Sun Sep 27 22:49:29 2009 (r197548) +++ user/rpaulo/armpmc/sys/pmc.h Sun Sep 27 22:50:17 2009 (r197549) @@ -84,7 +84,8 @@ __PMC_CPU(INTEL_CORE2, 0x88, "Intel Core2") \ __PMC_CPU(INTEL_CORE2EXTREME, 0x89, "Intel Core2 Extreme") \ __PMC_CPU(INTEL_ATOM, 0x8A, "Intel Atom") \ - __PMC_CPU(INTEL_COREI7, 0x8B, "Intel Core i7") + __PMC_CPU(INTEL_COREI7, 0x8B, "Intel Core i7") \ + __PMC_CPU(INTEL_XSCALE, 0x8C, "Intel XScale") enum pmc_cputype { #undef __PMC_CPU @@ -93,7 +94,7 @@ enum pmc_cputype { }; #define PMC_CPU_FIRST PMC_CPU_AMD_K7 -#define PMC_CPU_LAST PMC_CPU_INTEL_COREI7 +#define PMC_CPU_LAST PMC_CPU_INTEL_XSCALE /* * Classes of PMCs @@ -107,7 +108,8 @@ enum pmc_cputype { __PMC_CLASS(P6) /* Intel Pentium Pro counters */ \ __PMC_CLASS(P4) /* Intel Pentium-IV counters */ \ __PMC_CLASS(IAF) /* Intel Core2/Atom, fixed function */ \ - __PMC_CLASS(IAP) /* Intel Core...Atom, programmable */ + __PMC_CLASS(IAP) /* Intel Core...Atom, programmable */ \ + __PMC_CLASS(XSCALE) /* Intel XScale counters */ enum pmc_class { #undef __PMC_CLASS @@ -116,7 +118,7 @@ enum pmc_class { }; #define PMC_CLASS_FIRST PMC_CLASS_TSC -#define PMC_CLASS_LAST PMC_CLASS_IAP +#define PMC_CLASS_LAST PMC_CLASS_XSCALE /* * A PMC can be in the following states: From owner-svn-src-user@FreeBSD.ORG Sun Sep 27 22:57:02 2009 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 958771065672; Sun, 27 Sep 2009 22:57:02 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 849BF8FC17; Sun, 27 Sep 2009 22:57:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8RMv223037039; Sun, 27 Sep 2009 22:57:02 GMT (envelope-from rpaulo@svn.freebsd.org) Received: (from rpaulo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8RMv274037037; Sun, 27 Sep 2009 22:57:02 GMT (envelope-from rpaulo@svn.freebsd.org) Message-Id: <200909272257.n8RMv274037037@svn.freebsd.org> From: Rui Paulo Date: Sun, 27 Sep 2009 22:57:02 +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: r197550 - user/rpaulo/armpmc/dev/hwpmc 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, 27 Sep 2009 22:57:02 -0000 Author: rpaulo Date: Sun Sep 27 22:57:02 2009 New Revision: 197550 URL: http://svn.freebsd.org/changeset/base/197550 Log: Add likely needed function placeholders. Modified: user/rpaulo/armpmc/dev/hwpmc/hwpmc_xscale.c Modified: user/rpaulo/armpmc/dev/hwpmc/hwpmc_xscale.c ============================================================================== --- user/rpaulo/armpmc/dev/hwpmc/hwpmc_xscale.c Sun Sep 27 22:50:17 2009 (r197549) +++ user/rpaulo/armpmc/dev/hwpmc/hwpmc_xscale.c Sun Sep 27 22:57:02 2009 (r197550) @@ -41,6 +41,42 @@ struct xscale_event_code_map { uint8_t pe_mask; }; + +static int +xscale_read_pmc(int cpu, int ri, pmc_value_t *v) +{ +} + +static int +xscale_write_pmc(int cpu, int ri, pmc_value_t v) +{ +} + +static int +xscale_config_pmc(int cpu, int ri, struct pmc *pm) +{ +} + +static int +xscale_start_pmc(int cpu, int ri) +{ +} + +static int +xscale_stop_pmc(int cpu, int ri) +{ +} + +static int +xscale_intr(int cpu, struct trapframe *tf) +{ +} + +static int +xscale_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc) +{ +} + struct pmc_mdep * pmc_xscale_initialize() { From owner-svn-src-user@FreeBSD.ORG Sun Sep 27 23:01:18 2009 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 6A0491065741; Sun, 27 Sep 2009 23:01:18 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3F7868FC18; Sun, 27 Sep 2009 23:01:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8RN1IJ2037172; Sun, 27 Sep 2009 23:01:18 GMT (envelope-from rpaulo@svn.freebsd.org) Received: (from rpaulo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8RN1IuD037171; Sun, 27 Sep 2009 23:01:18 GMT (envelope-from rpaulo@svn.freebsd.org) Message-Id: <200909272301.n8RN1IuD037171@svn.freebsd.org> From: Rui Paulo Date: Sun, 27 Sep 2009 23:01:18 +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: r197551 - user/rpaulo/armpmc/dev/hwpmc 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, 27 Sep 2009 23:01:18 -0000 Author: rpaulo Date: Sun Sep 27 23:01:17 2009 New Revision: 197551 URL: http://svn.freebsd.org/changeset/base/197551 Log: Add initial definitions. Added: user/rpaulo/armpmc/dev/hwpmc/hwpmc_xscale.h (contents, props changed) Added: user/rpaulo/armpmc/dev/hwpmc/hwpmc_xscale.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/rpaulo/armpmc/dev/hwpmc/hwpmc_xscale.h Sun Sep 27 23:01:17 2009 (r197551) @@ -0,0 +1,41 @@ +/*- + * Copyright (c) 2009 Rui Paulo + * 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. + * + * $FreeBSD$ + */ + +#ifndef _DEV_HWPMC_XSCALE_H_ +#define _DEV_HWPMC_XSCALE_H_ + +#define XSCALE_NPMCS 2 + +#define XSCALE_PMC_CAPS (PMC_CAP_INTERRUPT | PMC_CAP_USER | \ + PMC_CAP_SYSTEM | PMC_CAP_EDGE | \ + PMC_CAP_THRESHOLD | PMC_CAP_READ | \ + PMC_CAP_WRITE | PMC_CAP_INVERT | \ + PMC_CAP_QUALIFIER) + + +#endif /* _DEV_HWPMC_XSCALE_H_ */ From owner-svn-src-user@FreeBSD.ORG Tue Sep 29 07:56:10 2009 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 92039106566C; Tue, 29 Sep 2009 07:56:10 +0000 (UTC) (envelope-from edwin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 80B528FC1F; Tue, 29 Sep 2009 07:56:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8T7uAdB078798; Tue, 29 Sep 2009 07:56:10 GMT (envelope-from edwin@svn.freebsd.org) Received: (from edwin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8T7uAQJ078792; Tue, 29 Sep 2009 07:56:10 GMT (envelope-from edwin@svn.freebsd.org) Message-Id: <200909290756.n8T7uAQJ078792@svn.freebsd.org> From: Edwin Groothuis Date: Tue, 29 Sep 2009 07:56:10 +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: r197609 - in user/edwin/locale/share: . colldef monetdef msgdef numericdef timedef 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, 29 Sep 2009 07:56:10 -0000 Author: edwin Date: Tue Sep 29 07:56:09 2009 New Revision: 197609 URL: http://svn.freebsd.org/changeset/base/197609 Log: Remove fields which are refering directly to me and my machine, they're now part of /etc/make.conf. Modified: user/edwin/locale/share/Makefile.def.inc user/edwin/locale/share/colldef/Makefile user/edwin/locale/share/monetdef/Makefile user/edwin/locale/share/msgdef/Makefile user/edwin/locale/share/numericdef/Makefile user/edwin/locale/share/timedef/Makefile Modified: user/edwin/locale/share/Makefile.def.inc ============================================================================== --- user/edwin/locale/share/Makefile.def.inc Mon Sep 28 23:52:47 2009 (r197608) +++ user/edwin/locale/share/Makefile.def.inc Tue Sep 29 07:56:09 2009 (r197609) @@ -1,5 +1,15 @@ # $FreeBSD: user/edwin/locale/share/msgdef/Makefile 196760 2009-09-02 10:12:13Z edwin $ +.if defined(LOCALE_DESTDIR) +DESTDIR= ${LOCALE_DESTDIR} +.endif +.if defined(LOCALE_SHAREOWN) +SHAREOWN= ${LOCALE_SHAREOWN} +.endif +.if defined(LOCALE_SHAREGRP) +SHAREGRP= ${LOCALE_SHAREGRP} +.endif + # # Predefined variables - Not for "end-users" to look at. # @@ -56,8 +66,8 @@ FILESDIR_${ccln}.${cm}.out= ${LOCALEDIR} FILES= ${ALLFILES:S/$/.out/} CLEANFILES= ${ALLFILES:S/$/.out/} -.if defined(FULL) -CLEANFILES+= ${CCLN:S/$/.src/} +.if defined(FULL) && ${TARGET} == "TARGET_CHARACTERMAP" +CLEANFILES= ${ALLFILES:S/$/.src/} .endif FILESNAME= ${LCTYPE} @@ -291,9 +301,9 @@ _TRANSLATIONAFTER_${cm}+= | awk '{ gsub # Normal makes don't need to convert from .unicode to .src . if defined(FULL) ${ccln}.UTF-8.src: ${ccln}.unicode - ../../cldr/tools/unicode2src.pl \ - --cldr=/home/edwin/unicode/cldr/1.7.1 \ - --unidata=/home/edwin/unicode/UNIDATA/5.1.0/ \ + ${TOOLSDIR}/unicode2src.pl \ + --cldr=${CLDRDIR} \ + --unidata=${UNIDATADIR} \ --input=${.ALLSRC} \ --output=${.TARGET} @@ -304,6 +314,7 @@ ${ccln}.UTF-8.out: ${ccln}.UTF-8.src . if defined(CMS_${ccln}) . for cms in ${CMS_${ccln}} +. if defined(FULL) ${ccln}.${cms}.src: ${ccln}.UTF-8.src cat ${.ALLSRC} \ @@ -314,6 +325,7 @@ ${ccln}.${cms}.src: ${ccln}.UTF-8.src ${_TRANSLATIONAFTER_${cms}} \ > ${.TARGET} \ || rm ${.TARGET} && exit 0 +. endif ${ccln}.${cms}.out: ${ccln}.${cms}.src grep -v '^#' < ${.ALLSRC} > ${.TARGET} Modified: user/edwin/locale/share/colldef/Makefile ============================================================================== --- user/edwin/locale/share/colldef/Makefile Mon Sep 28 23:52:47 2009 (r197608) +++ user/edwin/locale/share/colldef/Makefile Tue Sep 29 07:56:09 2009 (r197609) @@ -74,11 +74,6 @@ LEGLINK_la_LN.US-ASCII+= zh_CN.eucCN zh_ LCTYPE= LC_COLLATE LOCALEDIR= /usr/share/locale -# For testing only -DESTDIR= /home/edwin/locale/new/ -SHAREOWN= edwin -SHAREGRP= edwin - # DONE # # All variables Modified: user/edwin/locale/share/monetdef/Makefile ============================================================================== --- user/edwin/locale/share/monetdef/Makefile Mon Sep 28 23:52:47 2009 (r197608) +++ user/edwin/locale/share/monetdef/Makefile Tue Sep 29 07:56:09 2009 (r197609) @@ -101,11 +101,6 @@ LOCALEDIR= /usr/share/locale #ICONV_pt_PT.ISO8859-1= bsdiconv #ICONV_ko_KR.eucKR= bsdiconv -# For testing only -DESTDIR= /home/edwin/locale/new/ -SHAREOWN= edwin -SHAREGRP= edwin - # # All variables # Modified: user/edwin/locale/share/msgdef/Makefile ============================================================================== --- user/edwin/locale/share/msgdef/Makefile Mon Sep 28 23:52:47 2009 (r197608) +++ user/edwin/locale/share/msgdef/Makefile Tue Sep 29 07:56:09 2009 (r197609) @@ -92,11 +92,6 @@ LEGLINK_sr_Latn_RS.ISO8859-2= sr_YU.ISO8 LCTYPE= LC_MESSAGES LOCALEDIR= /usr/share/locale -# For testing only -DESTDIR= /home/edwin/locale/new/ -SHAREOWN= edwin -SHAREGRP= edwin - # # All variables # Modified: user/edwin/locale/share/numericdef/Makefile ============================================================================== --- user/edwin/locale/share/numericdef/Makefile Mon Sep 28 23:52:47 2009 (r197608) +++ user/edwin/locale/share/numericdef/Makefile Tue Sep 29 07:56:09 2009 (r197609) @@ -88,11 +88,6 @@ LEGLINK_zh_Hans_CN.GBK2312= zh_CN.GBK LCTYPE= LC_NUMERIC LOCALEDIR= /usr/share/locale -# For testing only -DESTDIR= /home/edwin/locale/new/ -SHAREOWN= edwin -SHAREGRP= edwin - # # All variables # Modified: user/edwin/locale/share/timedef/Makefile ============================================================================== --- user/edwin/locale/share/timedef/Makefile Mon Sep 28 23:52:47 2009 (r197608) +++ user/edwin/locale/share/timedef/Makefile Tue Sep 29 07:56:09 2009 (r197609) @@ -111,11 +111,6 @@ LEGLINK_zh_Hans_CN.GBK2312= zh_CN.GBK LCTYPE= LC_TIME LOCALEDIR= /usr/share/locale -# For testing only -DESTDIR= /home/edwin/locale/new/ -SHAREOWN= edwin -SHAREGRP= edwin - # # All variables # From owner-svn-src-user@FreeBSD.ORG Tue Sep 29 08:00:45 2009 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 987381065672; Tue, 29 Sep 2009 08:00:45 +0000 (UTC) (envelope-from edwin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 874FB8FC16; Tue, 29 Sep 2009 08:00:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8T80j8c078945; Tue, 29 Sep 2009 08:00:45 GMT (envelope-from edwin@svn.freebsd.org) Received: (from edwin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8T80jAq078943; Tue, 29 Sep 2009 08:00:45 GMT (envelope-from edwin@svn.freebsd.org) Message-Id: <200909290800.n8T80jAq078943@svn.freebsd.org> From: Edwin Groothuis Date: Tue, 29 Sep 2009 08:00:45 +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: r197610 - user/edwin/locale 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, 29 Sep 2009 08:00:45 -0000 Author: edwin Date: Tue Sep 29 08:00:45 2009 New Revision: 197610 URL: http://svn.freebsd.org/changeset/base/197610 Log: This is kind of progress report / manual / background etc. Should go in the Wiki too. Added: user/edwin/locale/README.locale Added: user/edwin/locale/README.locale ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/edwin/locale/README.locale Tue Sep 29 08:00:45 2009 (r197610) @@ -0,0 +1,188 @@ +New approach to the FreeBSD locale database +=========================================== + +Background +---------- +Over the years the FreeBSD locale database (share/colldef, +share/monetdef, share/msgdef, share/numericdef, share/timedef) has +accumulated a total of 165 definitions (language - country-code - +character-set triplets). The contents of the files is for Western +European languages often low-ASCII but for Eastern European and +Asian languages partly or fully high-ASCII. Without knowing how to +display or interpret the character-sets, it is difficult to make +sure by the general audience that the local languages (language - +country-code) definitions is displayed properly in various +character-sets. + + +Solution +-------- +With a per definition (language - country-code) low-ASCII file with +the definitions of the characters for the fields, it would be +possible to generate the various character-sets for that language. + + +What do we need +--------------- +- A database with all character encoding definitions. The Unicode + Project defines these. +- An intermittent format which can be used to convert these encodings + into unique characters. The UTF-8 character-set supports this. +- A tool to convert from the intermittent format into the various + character-sets. Libiconv (GPL) and bsdiconv (BSDL) can do this. +- A Makefile which glues everything together. + + +Gotchas +------- +- Some countries do not only have multiple languages (nl_BE and + fr_BE for example), but some of them have also different font + families: sr_Cyrl_RS and sr_Latn_RS. +- Duplicate detection has always been a manual thing and is tricky + to do initially. Right now this keeps being the job of the + maintainers of the locale data in the SCM repository. + + +Examples +-------- + +The word for the last day of the week in the en_US language - country +code would be in Unicode format: + + + +Converted into UTF-8 this will be: + Sunday +Converted into ISO-8859 this will be: + Sunday + +The word for the last day of the week in the ru_RU language - +country code would be in Unicode format: + + + + +Converted into UTF-8 this will be: + <81><83><82> +Converted into KOI8-R this will be: + + + +Careful! +-------- +- In the timedef definitions, do not convert the %A into Unicode + format because the %A is a low-ASCII input for strftime(). Also + don't put the md_order in Unicode format because that is a low-ASCII + definition. +- libiconv doesn't understand ISCII-DEV, bsdiconv calls it macdevanaga. +- Backwards compatibility: There are a bunch of old or obsolete + names in the FreeBSD locale definitions (sr_YU -> sr_Cyrl_RS and + sr_Latn_RS, zh_HK -> zh_Hant_HK, zh_CN -> zh_Hans_CN) which still + might be needed. + + +Current status +-------------- + +Finished: +- Conversion of the current locale data into the Unicode format for + share/monetdef, share/msgdef, share/numericdef, share/timedef. +- Conversion of the current Makefiles to support the new approach. + It also adds the file src/share/Makefile.def.inc which does do + the magic between the definitions in the Makefile and the FreeBSD + bsd.*.mk. Done for share/colldef, share/monetdef, share/msgdef, + share/numericdef, share/timedef. +- Regression check. +- Conversion of the Unicode definitions to the UTF-8 character-set. + +Pending: +- Checking of the data with the CLDR (Common Locale Data Repository) + for completeness of the current data. +- Conversion of Makefiles for share/mklocale. +- Conversion of the Unicode definitions to the UTF-8 character-set + in a C program or AWK script to make it self-hosting. This is + right now a Perl script so it can't be part of the base OS build + yet. This tool for now lives in src/tools/tools/locale/. +- Import of the file UTF-8.cm (from the CLDR project) and the file + UnicodeData.txt (from the Unicode project) into the base operating + system. These files for now live in src/tools/tools/locale/ + +Pending third parties: +- bsdiconv in the main system. + + +SCM +--- + +(Currently the SCM contains all the definitions (language - country-code +- character-set) in low and high-ASCII. To keep the SCM history, we +will once move them to their .unicode extension and then overwrite +them with the Unicode encoding definitions) + +The .unicode files are stored in SCM and will be, in the long term, +be the only source in SCM. Right now due to lack of bsdiconv in the +base operating system we will have to store also the character-map +sources (.src) files into the SCM. Once bsdiconv is in the base +system these files can be removed and the whole database can be +made self-hosted. + + +Testing (before move to src/tools/tools/locale) +----------------------------------------------- + +To test the current system, you need the following data: + +- A copy of the CLDR, available from http://cldr.unicode.org/. + Currently version 1.7.1 is used. We only use the file posix/UTF-8.cm + from it. +- A copy of the Unicode database, available from http://www.unicode.org/. + Currently version is 5.1.0. We only use the file UnicodeData.txt from it. +- A copy of svn://svn.freebsd.org/base/user/edwin/locale/. +- A copy of bsdiconv from p4:///depot/gabor/something. + +Local configuration: + +- Add to /etc/make.conf (make sure they match your directory layout) + CLDRDIR= /home/edwin/unicode/cldr/1.7.1 + UNIDATADIR= /home/edwin/unicode/UNIDATA/5.1.0 + TOOLSDIR= /home/edwin/svn/edwin/locale/cldr/tools/ + LOCALE_DESTDIR= /home/edwin/locale/new + LOCALE_SHAREOWN=edwin + LOCALE_SHAREGRP=edwin + +Test it out: + +- Go to the SVN directory /user/edwin/locale/share. The Makefile + there only includes the locale directories, so there is no need to + be worried about the other . + +- Run "FULL=1 make clean" to get rid of all generated files, even + the ones in the SCM. You should only have the *.unicode and the + Makefiles now. + +- Run "FULL=1 make" to recreate everything. + +- Run "make clean" to get rid of all data not in the SCM. + +- Run "make" to recreate the data not in the SCM. + +# +# All targets for TARGET_CHARACTERMAP +# +# .unicode -> .utf-8.src -> .utf-8.out +# \__ .iso8859-1.src -> .iso8859-1.out +# <----1---><--2---><------3--------><----4-----> +# +# 1. The files .unicode are stored in the SCM and are the source +# for the whole further system +# 2. The Perl script converts the .unicode files and the Unicode +# CLDR database into UTF-8 code +# 3. The UTF-8 gets converted by libiconv or bsdiconv in the specific +# character-map. +# 4. Get rid of the comments. +# +# As long as there is no bsdiconv, the files with the extension +# .unicode and .src must be stored in the SCM and will not be +# generated as part of the build process. +# + From owner-svn-src-user@FreeBSD.ORG Tue Sep 29 12:59:31 2009 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 C22471065692; Tue, 29 Sep 2009 12:59:31 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 979758FC28; Tue, 29 Sep 2009 12:59:31 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8TCxVj0085920; Tue, 29 Sep 2009 12:59:31 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8TCxVrK085918; Tue, 29 Sep 2009 12:59:31 GMT (envelope-from des@svn.freebsd.org) Message-Id: <200909291259.n8TCxVrK085918@svn.freebsd.org> From: Dag-Erling Smorgrav Date: Tue, 29 Sep 2009 12:59: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: r197616 - user/des/fmerge 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, 29 Sep 2009 12:59:31 -0000 Author: des Date: Tue Sep 29 12:59:31 2009 New Revision: 197616 URL: http://svn.freebsd.org/changeset/base/197616 Log: Further reduction of source / target confusion. Special-case head. Modified: user/des/fmerge/fmerge.pl Modified: user/des/fmerge/fmerge.pl ============================================================================== --- user/des/fmerge/fmerge.pl Tue Sep 29 12:20:10 2009 (r197615) +++ user/des/fmerge/fmerge.pl Tue Sep 29 12:59:31 2009 (r197616) @@ -36,19 +36,18 @@ our $debug; our $pretend; our $src_branch = "head"; # where we merge from -our $src_path; +our $src_path; # path relative to source branch our $src_url; # source URL our $tgt_branch; # where we merge to -our $tgt_path; +our $tgt_path; # path relative to target branch our $tgt_dir = "."; # target directory +our $tgt_url; # target URL our %revs = (0 => 0); our @ranges; -our $svn_path; -our $svn_url; -our $svn_root; -our $svn_branch; +our $svn_path; # path relative to branch +our $svn_root; # Repository root sub info(@) { print(STDERR join(' ', @_), "\n"); @@ -113,14 +112,14 @@ sub examine() { if ($key eq 'Path') { svn_check($value eq $tgt_dir, "path mismatch: $value != $tgt_dir"); } elsif ($key eq 'URL') { - $svn_url = $value; + $tgt_url = $value; } elsif ($key eq 'Repository Root') { $svn_root = $value; } } close($fh); - svn_check($svn_url =~ m@^\Q$svn_root\E(/.*)$@, "invalid svn URL: $svn_url"); + svn_check($tgt_url =~ m@^\Q$svn_root\E(/.*)$@, "invalid svn URL: $tgt_url"); $svn_path = $1; debug("guessing merge source / target directory"); @@ -133,20 +132,20 @@ sub examine() { debug("'$svn_path' =~ m\@^((?:/[\\w.-]+)+)\Q$subdir\E\$\@"); next unless $svn_path =~ m@^((?:/[\w.-]+)+)\Q$subdir\E$@; $svn_path = $subdir; - $svn_branch = $1; + $tgt_branch = $1; last; } close($fh); - if (!$svn_branch) { + if (!$tgt_branch) { # try to guess a stable / releng / release branch - debug("guessing source branch"); + debug("guessing target branch"); debug("'$svn_path' =~ s\@^/([\\w+.-]/\\d+(?:\\.\\d+)*)/?\@\@"); - $svn_path =~ s@^/(\w+/\d+(?:\.\d+)*)/?@@; - $svn_branch = $1; + $svn_path =~ s@^/(head|\w+/\d+(?:\.\d+)*)/?@@; + $tgt_branch = $1; } - svn_check($svn_branch, "unable to figure out source branch"); - debug("svn_branch = '$svn_branch'"); + svn_check($tgt_branch, "unable to figure out source branch"); + debug("tgt_branch = '$tgt_branch'"); debug("svn_path = '$svn_path'"); } From owner-svn-src-user@FreeBSD.ORG Fri Oct 2 11:17:51 2009 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 A2655106566B; Fri, 2 Oct 2009 11:17:51 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 92A9D8FC0A; Fri, 2 Oct 2009 11:17:51 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n92BHpgK099478; Fri, 2 Oct 2009 11:17:51 GMT (envelope-from rpaulo@svn.freebsd.org) Received: (from rpaulo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n92BHpUR099476; Fri, 2 Oct 2009 11:17:51 GMT (envelope-from rpaulo@svn.freebsd.org) Message-Id: <200910021117.n92BHpUR099476@svn.freebsd.org> From: Rui Paulo Date: Fri, 2 Oct 2009 11:17: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: r197707 - user/rpaulo/armpmc/sys 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: Fri, 02 Oct 2009 11:17:51 -0000 Author: rpaulo Date: Fri Oct 2 11:17:51 2009 New Revision: 197707 URL: http://svn.freebsd.org/changeset/base/197707 Log: merge from head Modified: user/rpaulo/armpmc/sys/pmc.h Modified: user/rpaulo/armpmc/sys/pmc.h ============================================================================== --- user/rpaulo/armpmc/sys/pmc.h Fri Oct 2 11:14:12 2009 (r197706) +++ user/rpaulo/armpmc/sys/pmc.h Fri Oct 2 11:17:51 2009 (r197707) @@ -85,7 +85,7 @@ __PMC_CPU(INTEL_CORE2EXTREME, 0x89, "Intel Core2 Extreme") \ __PMC_CPU(INTEL_ATOM, 0x8A, "Intel Atom") \ __PMC_CPU(INTEL_COREI7, 0x8B, "Intel Core i7") \ - __PMC_CPU(INTEL_XSCALE, 0x8C, "Intel XScale") + __PMC_CPU(INTEL_XSCALE, 0x100, "Intel XScale") enum pmc_cputype { #undef __PMC_CPU From owner-svn-src-user@FreeBSD.ORG Fri Oct 2 11:46:01 2009 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 8D3B51065692; Fri, 2 Oct 2009 11:46:01 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7C6558FC29; Fri, 2 Oct 2009 11:46:01 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n92Bk15S000178; Fri, 2 Oct 2009 11:46:01 GMT (envelope-from rpaulo@svn.freebsd.org) Received: (from rpaulo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n92Bk1XP000173; Fri, 2 Oct 2009 11:46:01 GMT (envelope-from rpaulo@svn.freebsd.org) Message-Id: <200910021146.n92Bk1XP000173@svn.freebsd.org> From: Rui Paulo Date: Fri, 2 Oct 2009 11:46:01 +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: r197708 - in user/rpaulo/armpmc: arm/include dev/hwpmc 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: Fri, 02 Oct 2009 11:46:01 -0000 Author: rpaulo Date: Fri Oct 2 11:46:01 2009 New Revision: 197708 URL: http://svn.freebsd.org/changeset/base/197708 Log: Build fixes. Modified: user/rpaulo/armpmc/arm/include/pmc_mdep.h user/rpaulo/armpmc/dev/hwpmc/hwpmc_arm.c user/rpaulo/armpmc/dev/hwpmc/hwpmc_xscale.c user/rpaulo/armpmc/dev/hwpmc/hwpmc_xscale.h Modified: user/rpaulo/armpmc/arm/include/pmc_mdep.h ============================================================================== --- user/rpaulo/armpmc/arm/include/pmc_mdep.h Fri Oct 2 11:17:51 2009 (r197707) +++ user/rpaulo/armpmc/arm/include/pmc_mdep.h Fri Oct 2 11:46:01 2009 (r197708) @@ -1,5 +1,27 @@ /*- - * This file is in the public domain. + * Copyright (c) 2009 Rui Paulo + * 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. * * $FreeBSD$ */ @@ -7,6 +29,13 @@ #ifndef _MACHINE_PMC_MDEP_H_ #define _MACHINE_PMC_MDEP_H_ +/* + * On the ARM platform we support the following PMCs. + * + * XSCALE Intel XScale processors + */ +#include + union pmc_md_op_pmcallocate { uint64_t __pad[4]; }; Modified: user/rpaulo/armpmc/dev/hwpmc/hwpmc_arm.c ============================================================================== --- user/rpaulo/armpmc/dev/hwpmc/hwpmc_arm.c Fri Oct 2 11:17:51 2009 (r197707) +++ user/rpaulo/armpmc/dev/hwpmc/hwpmc_arm.c Fri Oct 2 11:46:01 2009 (r197708) @@ -30,8 +30,10 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include +#include struct pmc_mdep * pmc_md_initialize() @@ -46,7 +48,7 @@ void pmc_md_finalize(struct pmc_mdep *md) { if (cpu_class == CPU_CLASS_XSCALE) - return pmc_xscale_finalize(); + pmc_xscale_finalize(md); else KASSERT(0, ("[arm,%d] Unknown CPU Class 0x%x", __LINE__, cpu_class)); Modified: user/rpaulo/armpmc/dev/hwpmc/hwpmc_xscale.c ============================================================================== --- user/rpaulo/armpmc/dev/hwpmc/hwpmc_xscale.c Fri Oct 2 11:17:51 2009 (r197707) +++ user/rpaulo/armpmc/dev/hwpmc/hwpmc_xscale.c Fri Oct 2 11:46:01 2009 (r197708) @@ -80,11 +80,37 @@ xscale_describe(int cpu, int ri, struct struct pmc_mdep * pmc_xscale_initialize() { - return NULL; + struct pmc_mdep *pmc_mdep; + + pmc_mdep = malloc(sizeof(struct pmc_mdep) + sizeof(struct pmc_classdep), + M_PMC, M_WAITOK|M_ZERO); + pmc_mdep->pmd_cputype = PMC_CPU_INTEL_XSCALE; + pmc_mdep->pmd_nclass = 1; + + pcd = &pmc_mdep->pmd_classdep[0]; + pcd->pcd_caps = XSCALE_PMC_CAPS; + pcd->pcd_num = XSCALE_NPMCS; + pcd->pcd_ri = pmc_mdep->pmd_npmc; + pcd->pcd_width = 48; /* XXX */ + + pcd->pcd_allocate_pmc = xscale_allocate_pmc; + pcd->pcd_config_pmc = xscale_config_pmc; + pcd->pcd_describe = xscale_describe; + pcd->pcd_get_config = xscale_get_config; + pcd->pcd_read_pmc = xscale_read_pmc; + pcd->pcd_release_pmc = xscale_release_pmc; + pcd->pcd_start_pmc = xscale_start_pmc; + pcd->pcd_stop_pmc = xscale_stop_pmc; + pcd->pcd_write_pmc = xscale_write_pmc; + + pmc_mdep->pmd_intr = xscale_intr; + pmc_mdep->pmd_switch_in = xscale_switch_in; + pmc_mdep->pmd_switch_out = xscale_switch_out; + + return (pmc_mdep); } void pmc_xscale_finalize(struct pmc_mdep *md) { - (void) md; } Modified: user/rpaulo/armpmc/dev/hwpmc/hwpmc_xscale.h ============================================================================== --- user/rpaulo/armpmc/dev/hwpmc/hwpmc_xscale.h Fri Oct 2 11:17:51 2009 (r197707) +++ user/rpaulo/armpmc/dev/hwpmc/hwpmc_xscale.h Fri Oct 2 11:46:01 2009 (r197708) @@ -37,5 +37,9 @@ PMC_CAP_WRITE | PMC_CAP_INVERT | \ PMC_CAP_QUALIFIER) - +#ifdef _KERNEL +/* MD extension for 'struct pmc' */ +struct pmc_md_xscale_pmc { +}; +#endif /* _KERNEL */ #endif /* _DEV_HWPMC_XSCALE_H_ */ From owner-svn-src-user@FreeBSD.ORG Fri Oct 2 20:15:48 2009 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 5DB7B1065697; Fri, 2 Oct 2009 20:15:48 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4BF928FC15; Fri, 2 Oct 2009 20:15:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n92KFmSK012058; Fri, 2 Oct 2009 20:15:48 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n92KFm0m012048; Fri, 2 Oct 2009 20:15:48 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200910022015.n92KFm0m012048@svn.freebsd.org> From: Kip Macy Date: Fri, 2 Oct 2009 20:15: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: r197718 - in user/kmacy/releng_8_fcs/sys: kern sys 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: Fri, 02 Oct 2009 20:15:48 -0000 Author: kmacy Date: Fri Oct 2 20:15:47 2009 New Revision: 197718 URL: http://svn.freebsd.org/changeset/base/197718 Log: Add background sendfile for asynchrounous completion of non-blocking requests. Disable by default. Modified: user/kmacy/releng_8_fcs/sys/kern/uipc_sockbuf.c user/kmacy/releng_8_fcs/sys/kern/uipc_socket.c user/kmacy/releng_8_fcs/sys/kern/uipc_syscalls.c user/kmacy/releng_8_fcs/sys/sys/file.h user/kmacy/releng_8_fcs/sys/sys/sockbuf.h user/kmacy/releng_8_fcs/sys/sys/socket.h user/kmacy/releng_8_fcs/sys/sys/socketvar.h user/kmacy/releng_8_fcs/sys/sys/sockstate.h user/kmacy/releng_8_fcs/sys/sys/syscallsubr.h Modified: user/kmacy/releng_8_fcs/sys/kern/uipc_sockbuf.c ============================================================================== --- user/kmacy/releng_8_fcs/sys/kern/uipc_sockbuf.c Fri Oct 2 19:51:03 2009 (r197717) +++ user/kmacy/releng_8_fcs/sys/kern/uipc_sockbuf.c Fri Oct 2 20:15:47 2009 (r197718) @@ -133,7 +133,7 @@ sbwait(struct sockbuf *sb) } int -sblock(struct sockbuf *sb, int flags) +_sblock(struct sockbuf *sb, int flags, const char *file, int line) { KASSERT((flags & SBL_VALID) == flags, @@ -142,12 +142,12 @@ sblock(struct sockbuf *sb, int flags) if (flags & SBL_WAIT) { if ((sb->sb_flags & SB_NOINTR) || (flags & SBL_NOINTR)) { - sx_xlock(&sb->sb_sx); + _sx_xlock(&sb->sb_sx, 0, file, line); return (0); } - return (sx_xlock_sig(&sb->sb_sx)); + return (_sx_xlock(&sb->sb_sx, SX_INTERRUPTIBLE, file, line)); } else { - if (sx_try_xlock(&sb->sb_sx) == 0) + if (_sx_try_xlock(&sb->sb_sx, file, line) == 0) return (EWOULDBLOCK); return (0); } @@ -178,7 +178,10 @@ sowakeup(struct socket *so, struct sockb int ret; SOCKBUF_LOCK_ASSERT(sb); - + if (sb->sb_flags & SB_SENDING) { + SOCKBUF_UNLOCK(sb); + return; + } selwakeuppri(&sb->sb_sel, PSOCK); if (!SEL_WAITING(&sb->sb_sel)) sb->sb_flags &= ~SB_SEL; @@ -906,6 +909,8 @@ sbdrop_locked(struct sockbuf *sb, int le SOCKBUF_LOCK_ASSERT(sb); sbdrop_internal(sb, len); + if (sb->sb_flags & SB_SENDING) + sosendingwakeup(sb); } void Modified: user/kmacy/releng_8_fcs/sys/kern/uipc_socket.c ============================================================================== --- user/kmacy/releng_8_fcs/sys/kern/uipc_socket.c Fri Oct 2 19:51:03 2009 (r197717) +++ user/kmacy/releng_8_fcs/sys/kern/uipc_socket.c Fri Oct 2 20:15:47 2009 (r197718) @@ -124,10 +124,15 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include +#include #include +#include +#include #include +#include #include #include @@ -3329,6 +3334,345 @@ soisdisconnected(struct socket *so) wakeup(&so->so_timeo); } +struct socketref { + struct proc *sr_proc; + struct ucred *sr_ucred; + struct file *sr_sock_fp; + struct file *sr_fp; + struct socket *sr_so; + struct sendfile_args sr_uap; + struct uio sr_hdr_uio; + struct uio sr_trl_uio; + short sr_compat; + int sr_magic; + off_t sr_vnp_size; + struct task sr_task; + TAILQ_ENTRY(socketref) entry; + +}; +TAILQ_HEAD(srq, socketref); + +struct srq *sendfile_bg_queue; +struct mtx sendfile_bg_lock; +struct callout *sendfile_callout; +struct taskqueue *sendfile_tq; +extern int getsock(struct filedesc *fdp, int fd, + struct file **fpp, u_int *fflagp); +static void sendfile_task_func(void *context, int pending __unused); +static int srsendingwakeup(struct socketref *sr); + +MALLOC_DEFINE(M_SOCKREF, "sockref", "socket reference memory"); + +#define SOCKBUF_LOCK_COND(sb, lockflag) do { \ + if ((lockflag)) \ + SOCKBUF_LOCK((sb)); \ +} while (0) + +#define SOCKBUF_UNLOCK_COND(sb, lockflag) do { \ + if ((lockflag)) \ + SOCKBUF_UNLOCK((sb)); \ +} while (0) + + +static void +socketref_free(struct socketref *sr) +{ + struct file *fp = sr->sr_fp; + struct file *sock_fp = sr->sr_sock_fp; + struct proc *p = sr->sr_proc; + struct ucred *cred = sr->sr_ucred; + + if (cred != NULL) + crfree(cred); + vrele(fp->f_vnode); + fdrop(fp, NULL); + fdrop(sock_fp, NULL); + PRELE(p); +#ifdef INVARIANTS + bzero(sr, sizeof(*sr)); +#endif + free(sr, M_SOCKREF); +} + +void +soissending(struct socket *so, struct thread *td, + struct sendfile_args *uap, struct uio *hdr_uio, + struct uio *trl_uio, int compat, off_t sbytes, + off_t vnp_size) +{ + struct socketref *ref; + int error; + struct socket *refso; + struct vnode *vp; + + SOCKBUF_LOCK_ASSERT(&so->so_snd); + ref = malloc(sizeof(struct socketref), + M_SOCKREF, M_NOWAIT|M_ZERO); + if (ref == NULL) + return; + /* + * Obtain reference to socket :-/ + * drop when done sending + */ + so->so_snd.sb_flags |= SB_SENDING; + PROC_LOCK(td->td_proc); + td->td_proc->p_lock++; + PROC_UNLOCK(td->td_proc); + + ref->sr_proc = td->td_proc; + + if ((error = getsock(td->td_proc->p_fd, uap->s, &ref->sr_sock_fp, + NULL)) != 0) { + goto error; + } + if (ref->sr_sock_fp->f_type != DTYPE_SOCKET) { + printf("socket descriptor s=%d is not socket", uap->s); + goto error; + } + + refso = ref->sr_sock_fp->f_data; + if (refso != so) { + printf("socket mismatch between refso: %p so: %p\n", + refso, so); + goto error_sock_fp; + } + ref->sr_so = refso; + + if ((error = fget(td, uap->fd, &ref->sr_fp)) != 0) { + goto error_sock_fp; + } else if (ref->sr_fp->f_vnode != NULL) { + vp = ref->sr_fp->f_vnode; + vref(vp); + } else { + goto error_fp; + } + + bcopy(uap, &ref->sr_uap, sizeof(*uap)); + ref->sr_uap.sbytes = NULL; + ref->sr_sock_fp->f_sfbytes = 0; + CTR4(KTR_SPARE1, "sock %p off %ld sbytes %ld total_sbytes %ld", + so, ref->sr_uap.offset, sbytes, ref->sr_fp->f_sfbytes); + ref->sr_uap.offset += sbytes; + if (uap->nbytes) + ref->sr_uap.nbytes -= sbytes; + /* + * XXX + * We have to malloc memory for the uio data + */ + if (hdr_uio != NULL) + bcopy(hdr_uio, &ref->sr_hdr_uio, + sizeof(*hdr_uio)); + if (trl_uio != NULL) + bcopy(trl_uio, &ref->sr_trl_uio, + sizeof(*trl_uio)); + ref->sr_compat = compat; + ref->sr_magic = 0xCAFEBABE; + ref->sr_vnp_size = vnp_size; + TASK_INIT(&ref->sr_task, 0, sendfile_task_func, ref); + + CTR3(KTR_SPARE2, "enqueueing socket %p sock_fp %p s %d", so, ref->sr_sock_fp, uap->s); + mtx_lock(&sendfile_bg_lock); + TAILQ_INSERT_TAIL(sendfile_bg_queue, ref, entry); + mtx_unlock(&sendfile_bg_lock); + return; +error_fp: + fdrop(ref->sr_fp, td); +error_sock_fp: + fdrop(ref->sr_sock_fp, td); +error: + free(ref, M_DEVBUF); +} + +static void +sendfile_task_func(void *context, int pending __unused) +{ + struct socketref *sr; + struct socket *so; + struct sockbuf *sb; + struct file *sock_fp, *fp; + int error = EAGAIN; + struct uio *hdr_uio = NULL, *trl_uio = NULL; + off_t sbytes = 0; + + sr = context; + CTR0(KTR_SPARE2, "task_func running"); + if (sr->sr_magic != 0xCAFEBABE) { + printf("bad magic! 0x%x\n", sr->sr_magic); + /* XXX memory leak */ + return; + } + + sock_fp = sr->sr_sock_fp; + fp = sr->sr_fp; + CTR2(KTR_SPARE2, "processing sr %p sock_fp %p", sr, sock_fp); + if (sock_fp->f_type != DTYPE_SOCKET) + goto done; + + so = sock_fp->f_data; + CTR1(KTR_SPARE2, "task processing socket %p", so); + + if ((so->so_state & SS_ISCONNECTED) == 0) + goto done; + + if (sr->sr_ucred == NULL && + (sr->sr_ucred = crdup(sr->sr_proc->p_ucred)) == NULL) + goto done; + + sb = &so->so_snd; + SOCKBUF_UNLOCK_ASSERT(sb); + SOCKBUF_LOCK(sb); + sb->sb_flags &= ~SB_SENDING; + if (sb->sb_state & SBS_CANTSENDMORE) { + CTR1(KTR_SPARE2, "SBS_CANTSENDMORE - socket %p", so); + sowwakeup_locked(so); + goto done; + } else if (sowriteable(so)) { + sb->sb_flags |= SB_SENDING; + SOCKBUF_UNLOCK(sb); + if (sr->sr_hdr_uio.uio_td != NULL) + hdr_uio = &sr->sr_hdr_uio; + if (sr->sr_trl_uio.uio_td != NULL) + trl_uio = &sr->sr_trl_uio; + + sr->sr_uap.sbytes = &sbytes; + sr->sr_uap.flags |= SF_TASKQ; + CTR1(KTR_SPARE2, "task sending on socket %p", so); + + error = kern_sendfile(curthread, &sr->sr_uap, + hdr_uio, trl_uio, + sr->sr_compat, fp, so, sr->sr_ucred); + CTR4(KTR_SPARE1, "sock %p off %ld sbytes %ld total_sbytes %ld", + so, sr->sr_uap.offset, sbytes, fp->f_sfbytes); + atomic_add_long(&fp->f_sfbytes, sbytes); + sr->sr_uap.offset += sbytes; + if (sr->sr_uap.nbytes) + sr->sr_uap.nbytes -= sbytes; + if (error == EAGAIN && + (sr->sr_uap.offset + sbytes == sr->sr_vnp_size)) { + CTR0(KTR_SPARE1, "EAGAIN on full send"); + error = 0; + } + SOCKBUF_LOCK(sb); + } +#ifdef KTR + else + CTR2(KTR_SPARE1, "sock %p off %ld - not writeable in task_func", + so, sr->sr_uap.offset); +#endif + if (error == EAGAIN && srsendingwakeup(sr) != ENOTCONN) { + SOCKBUF_UNLOCK(sb); + return; + } +#ifdef KTR + if (error && error != EAGAIN && error != EPIPE) + CTR1(KTR_SPARE1, "error %d", error); +#endif + + sb->sb_flags &= ~SB_SENDING; + sowwakeup_locked(so); +done: + SOCKBUF_UNLOCK_ASSERT(sb); + socketref_free(sr); +} + +static int +srsendingwakeup(struct socketref *sr) +{ + struct socket *so; + struct file *fp; + struct sockbuf *sb; + + if (sr->sr_magic != 0xCAFEBABE) { + printf("bad magic! sr: %p magic : 0x%x in %s\n", + sr, sr->sr_magic, __FUNCTION__); + /* + * XXX leak - should be assert perhaps + * + */ + return (0); + } + + fp = sr->sr_sock_fp; + CTR2(KTR_SPARE2, "processing s %d sock_fp %p", sr->sr_uap.s, fp); + if (fp->f_type != DTYPE_SOCKET) { + CTR1(KTR_SPARE1, "not socket - type %d", fp->f_type); + goto error; + } + so = fp->f_data; + if ((so->so_state & SS_ISCONNECTED) == 0) { + CTR1(KTR_SPARE1, "not connected %p", so); + goto error; + } + + CTR1(KTR_SPARE2, "processing socket %p", so); + sb = &so->so_snd; + SOCKBUF_LOCK_ASSERT(sb); + sb->sb_flags &= ~SB_SENDING; + if (sb->sb_state & SBS_CANTSENDMORE) { + CTR1(KTR_SPARE1, "SBS_CANTSENDMORE %p", so); + } else if (sowriteable(so)) { + CTR2(KTR_SPARE2, "enqueue socket to task %p sr %p", so, sr); + sb->sb_flags |= SB_SENDING; + taskqueue_enqueue(sendfile_tq, &sr->sr_task); + } else { + CTR2(KTR_SPARE1, "sock %p off %ld - not writeable in srsendingwakeup", + so, sr->sr_uap.offset); + sb->sb_flags |= SB_SENDING; + mtx_lock(&sendfile_bg_lock); + TAILQ_INSERT_TAIL(sendfile_bg_queue, sr, entry); + mtx_unlock(&sendfile_bg_lock); + } + return (0); +error: + return (ENOTCONN); +} + +void +sosendingwakeup(struct sockbuf *sb) +{ + struct socketref *sr = NULL; + + SOCKBUF_LOCK_ASSERT(sb); + mtx_lock(&sendfile_bg_lock); + if (!TAILQ_EMPTY(sendfile_bg_queue)) { + TAILQ_FOREACH(sr, sendfile_bg_queue, entry) { + if (sb == &sr->sr_so->so_snd) { + sb->sb_flags &= ~SB_SENDING; + TAILQ_REMOVE(sendfile_bg_queue, sr, entry); + break; + } + } + + } + mtx_unlock(&sendfile_bg_lock); + + /* + * Buffer in flight + */ + if (sr != NULL && srsendingwakeup(sr) == ENOTCONN) { + CTR2(KTR_SPARE2, "freeing expired socket %p ref %p", + sr->sr_so, sr); + socketref_free(sr); + } +} + +static void +init_bgsend(void *unused __unused) +{ + + sendfile_tq = taskqueue_create("sendfile background taskq", M_NOWAIT, + taskqueue_thread_enqueue, &sendfile_tq); + taskqueue_start_threads(&sendfile_tq, mp_ncpus, PI_SOFT, + "sendfile background taskq"); + + mtx_init(&sendfile_bg_lock, "sendfile bg", NULL, MTX_DEF); + sendfile_bg_queue = malloc(sizeof(struct srq), + M_DEVBUF, M_NOWAIT); + TAILQ_INIT(sendfile_bg_queue); +} + +SYSINIT(init_bgsend, SI_SUB_SMP, SI_ORDER_ANY, init_bgsend, NULL); + /* * Make a copy of a sockaddr in a malloced buffer of type M_SONAME. */ Modified: user/kmacy/releng_8_fcs/sys/kern/uipc_syscalls.c ============================================================================== --- user/kmacy/releng_8_fcs/sys/kern/uipc_syscalls.c Fri Oct 2 19:51:03 2009 (r197717) +++ user/kmacy/releng_8_fcs/sys/kern/uipc_syscalls.c Fri Oct 2 20:15:47 2009 (r197718) @@ -112,6 +112,14 @@ SYSCTL_INT(_kern_ipc, OID_AUTO, nsfbufsp SYSCTL_INT(_kern_ipc, OID_AUTO, nsfbufsused, CTLFLAG_RD, &nsfbufsused, 0, "Number of sendfile(2) sf_bufs in use"); + +/* XXX move to header */ +int getsock(struct filedesc *fdp, int fd, struct file **fpp, u_int *fflagp); + +static int bg_sendfile_enable = 0; +SYSCTL_INT(_kern_ipc, OID_AUTO, bg_sendfile_enable, CTLFLAG_RW, + &bg_sendfile_enable, 0, "Enable background sendfile"); + /* * Convert a user file descriptor to a kernel file entry. A reference on the * file entry is held upon returning. This is lighter weight than @@ -120,7 +128,7 @@ SYSCTL_INT(_kern_ipc, OID_AUTO, nsfbufsu * associated with the additional reference count. If requested, return the * open file flags. */ -static int +int getsock(struct filedesc *fdp, int fd, struct file **fpp, u_int *fflagp) { struct file *fp; @@ -1774,7 +1782,8 @@ do_sendfile(struct thread *td, struct se } } - error = kern_sendfile(td, uap, hdr_uio, trl_uio, compat); + error = kern_sendfile(td, uap, hdr_uio, trl_uio, compat, + NULL, NULL, NULL); out: if (hdr_uio) free(hdr_uio, M_IOV); @@ -1803,20 +1812,27 @@ freebsd4_sendfile(struct thread *td, str int kern_sendfile(struct thread *td, struct sendfile_args *uap, - struct uio *hdr_uio, struct uio *trl_uio, int compat) + struct uio *hdr_uio, struct uio *trl_uio, int compat, + struct file *bgfp, struct socket *bgso, struct ucred *bgcred) { - struct file *sock_fp; - struct vnode *vp; + struct file *sock_fp, *fp = NULL; + struct vnode *vp = NULL; struct vm_object *obj = NULL; struct socket *so = NULL; struct mbuf *m = NULL; struct sf_buf *sf; struct vm_page *pg; - off_t off, xfsize, fsbytes = 0, sbytes = 0, rem = 0; + struct ucred *cred; + off_t off, xfsize, fsbytes = 0, sbytes = 0, rem = 0, vnp_size = 0; int error, hdrlen = 0, mnw = 0; int vfslocked; struct sendfile_sync *sfs = NULL; + if (bgcred != NULL) + cred = bgcred; + else + cred = td->td_ucred; + /* * The file descriptor must be a regular file and have a * backing VM object. @@ -1824,8 +1840,23 @@ kern_sendfile(struct thread *td, struct * we send only the header/trailer and no payload data. */ AUDIT_ARG_FD(uap->fd); - if ((error = fgetvp_read(td, uap->fd, &vp)) != 0) - goto out; + if ((uap->flags & SF_TASKQ) == 0) { + if ((error = fget_read(td, uap->fd, &fp)) != 0) + goto out; + else { + if (fp->f_vnode == NULL) { + fdrop(fp, td); + error = EINVAL; + goto out; + } else { + vp = fp->f_vnode; + vref(vp); + } + } + } else { + vp = bgfp->f_vnode; + } + vfslocked = VFS_LOCK_GIANT(vp->v_mount); vn_lock(vp, LK_SHARED | LK_RETRY); if (vp->v_type == VREG) { @@ -1858,22 +1889,39 @@ kern_sendfile(struct thread *td, struct goto out; } - /* - * The socket must be a stream socket and connected. - * Remember if it a blocking or non-blocking socket. - */ - if ((error = getsock(td->td_proc->p_fd, uap->s, &sock_fp, - NULL)) != 0) - goto out; - so = sock_fp->f_data; - if (so->so_type != SOCK_STREAM) { - error = EINVAL; - goto out; + if ((uap->flags & SF_TASKQ) == 0) { + /* + * The socket must be a stream socket and connected. + * Remember if it a blocking or non-blocking socket. + */ + if ((error = getsock(td->td_proc->p_fd, uap->s, &sock_fp, + NULL)) != 0) + goto out; + so = sock_fp->f_data; + if (so->so_type != SOCK_STREAM) { + error = EINVAL; + goto out; + } + if ((so->so_state & SS_ISCONNECTED) == 0) { + error = ENOTCONN; + goto out; + } + } else { + so = bgso; } - if ((so->so_state & SS_ISCONNECTED) == 0) { - error = ENOTCONN; + + if ((uap->flags & SF_TASKQ) == 0 && + sock_fp->f_sfbytes != 0) { + SOCKBUF_UNLOCK(&so->so_snd); + if (uap->sbytes != NULL) { + copyout(&sbytes, uap->sbytes, sizeof(off_t)); + sock_fp->f_sfbytes = 0; + } + error = 0; goto out; } + + /* * Do not wait on memory allocations but return ENOMEM for * caller to retry later. @@ -1890,7 +1938,7 @@ kern_sendfile(struct thread *td, struct } #ifdef MAC - error = mac_socket_check_send(td->td_ucred, so); + error = mac_socket_check_send(cred, so); if (error) goto out; #endif @@ -1980,6 +2028,9 @@ retry_space: (space <= 0 || space < so->so_snd.sb_lowat)) { if (so->so_state & SS_NBIO) { + if (bg_sendfile_enable && + (so->so_snd.sb_flags & SB_SENDING) == 0) + soissending(so, td, uap, hdr_uio, trl_uio, compat, sbytes, vnp_size); SOCKBUF_UNLOCK(&so->so_snd); error = EAGAIN; goto done; @@ -2041,6 +2092,7 @@ retry_space: done = 1; /* all data sent */ break; } + vnp_size = obj->un_pager.vnp.vnp_size; /* * Don't overflow the send buffer. * Stop here and send out what we've @@ -2098,7 +2150,7 @@ retry_space: error = vn_rdwr(UIO_READ, vp, NULL, MAXBSIZE, trunc_page(off), UIO_NOCOPY, IO_NODELOCKED | IO_VMIO | ((MAXBSIZE / bsize) << IO_SEQSHIFT), - td->td_ucred, NOCRED, &resid, td); + cred, NOCRED, &resid, td); VOP_UNLOCK(vp, 0); VFS_UNLOCK_GIANT(vfslocked); VM_OBJECT_LOCK(obj); @@ -2245,17 +2297,24 @@ out: td->td_retval[0] = 0; } if (uap->sbytes != NULL) { - copyout(&sbytes, uap->sbytes, sizeof(off_t)); + if ((uap->flags & SF_TASKQ) == 0) + copyout(&sbytes, uap->sbytes, sizeof(off_t)); + else + *(uap->sbytes) = sbytes; } if (obj != NULL) vm_object_deallocate(obj); - if (vp != NULL) { - vfslocked = VFS_LOCK_GIANT(vp->v_mount); - vrele(vp); - VFS_UNLOCK_GIANT(vfslocked); + if ((uap->flags & SF_TASKQ) == 0) { + if (vp != NULL) { + vfslocked = VFS_LOCK_GIANT(vp->v_mount); + vrele(vp); + VFS_UNLOCK_GIANT(vfslocked); + } + if (so) + fdrop(sock_fp, td); + if (fp) + fdrop(fp, td); } - if (so) - fdrop(sock_fp, td); if (m) m_freem(m); Modified: user/kmacy/releng_8_fcs/sys/sys/file.h ============================================================================== --- user/kmacy/releng_8_fcs/sys/sys/file.h Fri Oct 2 19:51:03 2009 (r197717) +++ user/kmacy/releng_8_fcs/sys/sys/file.h Fri Oct 2 20:15:47 2009 (r197718) @@ -132,6 +132,7 @@ struct file { * DFLAG_SEEKABLE specific fields */ off_t f_offset; + off_t f_sfbytes; /* * Mandatory Access control information. */ Modified: user/kmacy/releng_8_fcs/sys/sys/sockbuf.h ============================================================================== --- user/kmacy/releng_8_fcs/sys/sys/sockbuf.h Fri Oct 2 19:51:03 2009 (r197717) +++ user/kmacy/releng_8_fcs/sys/sys/sockbuf.h Fri Oct 2 20:15:47 2009 (r197718) @@ -52,6 +52,7 @@ #define SB_NOCOALESCE 0x200 /* don't coalesce new data into existing mbufs */ #define SB_IN_TOE 0x400 /* socket buffer is in the middle of an operation */ #define SB_AUTOSIZE 0x800 /* automatically size socket buffer */ +#define SB_SENDING 0x1000 /* socket is owned by sendfile thread */ #define SBS_CANTSENDMORE 0x0010 /* can't send more data to peer */ #define SBS_CANTRCVMORE 0x0020 /* can't receive more data from peer */ @@ -155,9 +156,12 @@ struct mbuf * sbsndptr(struct sockbuf *sb, u_int off, u_int len, u_int *moff); void sbtoxsockbuf(struct sockbuf *sb, struct xsockbuf *xsb); int sbwait(struct sockbuf *sb); -int sblock(struct sockbuf *sb, int flags); +int _sblock(struct sockbuf *sb, int flags, const char *file, int line); void sbunlock(struct sockbuf *sb); +#define sblock(sb, flags) \ + _sblock((sb), (flags), __FILE__, __LINE__) + /* * How much space is there in a socket buffer (so->so_snd or so->so_rcv)? * This is problematical if the fields are unsigned, as the space might Modified: user/kmacy/releng_8_fcs/sys/sys/socket.h ============================================================================== --- user/kmacy/releng_8_fcs/sys/sys/socket.h Fri Oct 2 19:51:03 2009 (r197717) +++ user/kmacy/releng_8_fcs/sys/sys/socket.h Fri Oct 2 20:15:47 2009 (r197718) @@ -617,6 +617,7 @@ struct sf_hdtr { #define SF_NODISKIO 0x00000001 #define SF_MNOWAIT 0x00000002 #define SF_SYNC 0x00000004 +#define SF_TASKQ 0x00000008 #endif #ifndef _KERNEL Modified: user/kmacy/releng_8_fcs/sys/sys/socketvar.h ============================================================================== --- user/kmacy/releng_8_fcs/sys/sys/socketvar.h Fri Oct 2 19:51:03 2009 (r197717) +++ user/kmacy/releng_8_fcs/sys/sys/socketvar.h Fri Oct 2 20:15:47 2009 (r197718) @@ -206,7 +206,8 @@ struct xsocket { /* can we write something to so? */ #define sowriteable(so) \ ((sbspace(&(so)->so_snd) >= (so)->so_snd.sb_lowat && \ - (((so)->so_state&SS_ISCONNECTED) || \ + !((so)->so_snd.sb_flags & SB_SENDING) && \ + (((so)->so_state&SS_ISCONNECTED) || \ ((so)->so_proto->pr_flags&PR_CONNREQUIRED)==0)) || \ ((so)->so_snd.sb_state & SBS_CANTSENDMORE) || \ (so)->so_error) Modified: user/kmacy/releng_8_fcs/sys/sys/sockstate.h ============================================================================== --- user/kmacy/releng_8_fcs/sys/sys/sockstate.h Fri Oct 2 19:51:03 2009 (r197717) +++ user/kmacy/releng_8_fcs/sys/sys/sockstate.h Fri Oct 2 20:15:47 2009 (r197718) @@ -71,11 +71,18 @@ #define SBS_RCVATMARK 0x0040 /* at mark on input */ struct socket; +struct sendfile_args; +struct uio; void soisconnected(struct socket *so); void soisconnecting(struct socket *so); void soisdisconnected(struct socket *so); void soisdisconnecting(struct socket *so); +void soissending(struct socket *so, + struct thread *td, struct sendfile_args *uap, + struct uio *hdr_uio, struct uio *trl_uio, + int compat, off_t sbytes, off_t vnp_size); +void sosendingwakeup(struct sockbuf *sb); void socantrcvmore(struct socket *so); void socantrcvmore_locked(struct socket *so); void socantsendmore(struct socket *so); Modified: user/kmacy/releng_8_fcs/sys/sys/syscallsubr.h ============================================================================== --- user/kmacy/releng_8_fcs/sys/sys/syscallsubr.h Fri Oct 2 19:51:03 2009 (r197717) +++ user/kmacy/releng_8_fcs/sys/sys/syscallsubr.h Fri Oct 2 20:15:47 2009 (r197718) @@ -172,7 +172,8 @@ int kern_semctl(struct thread *td, int s int kern_select(struct thread *td, int nd, fd_set *fd_in, fd_set *fd_ou, fd_set *fd_ex, struct timeval *tvp, int abi_nfdbits); int kern_sendfile(struct thread *td, struct sendfile_args *uap, - struct uio *hdr_uio, struct uio *trl_uio, int compat); + struct uio *hdr_uio, struct uio *trl_uio, int compat, + struct file *bgfp, struct socket *bgso, struct ucred *bgcred); int kern_sendit(struct thread *td, int s, struct msghdr *mp, int flags, struct mbuf *control, enum uio_seg segflg); int kern_setgroups(struct thread *td, u_int ngrp, gid_t *groups); From owner-svn-src-user@FreeBSD.ORG Fri Oct 2 23:18:41 2009 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 037171065694; Fri, 2 Oct 2009 23:18:41 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E77118FC14; Fri, 2 Oct 2009 23:18:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n92NIePN016754; Fri, 2 Oct 2009 23:18:40 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n92NIejc016753; Fri, 2 Oct 2009 23:18:40 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200910022318.n92NIejc016753@svn.freebsd.org> From: Kip Macy Date: Fri, 2 Oct 2009 23:18: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: r197722 - user/kmacy/releng_8_fcs/sys/compat/freebsd32 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: Fri, 02 Oct 2009 23:18:41 -0000 Author: kmacy Date: Fri Oct 2 23:18:40 2009 New Revision: 197722 URL: http://svn.freebsd.org/changeset/base/197722 Log: fix interface compatibility Modified: user/kmacy/releng_8_fcs/sys/compat/freebsd32/freebsd32_misc.c Modified: user/kmacy/releng_8_fcs/sys/compat/freebsd32/freebsd32_misc.c ============================================================================== --- user/kmacy/releng_8_fcs/sys/compat/freebsd32/freebsd32_misc.c Fri Oct 2 22:30:44 2009 (r197721) +++ user/kmacy/releng_8_fcs/sys/compat/freebsd32/freebsd32_misc.c Fri Oct 2 23:18:40 2009 (r197722) @@ -2137,7 +2137,8 @@ freebsd32_do_sendfile(struct thread *td, } } - error = kern_sendfile(td, &ap, hdr_uio, trl_uio, compat); + error = kern_sendfile(td, &ap, hdr_uio, trl_uio, compat, + NULL, NULL, NULL); out: if (hdr_uio) free(hdr_uio, M_IOV); From owner-svn-src-user@FreeBSD.ORG Sat Oct 3 12:51:28 2009 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 B9DB4106568B; Sat, 3 Oct 2009 12:51:28 +0000 (UTC) (envelope-from edwin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A7A9D8FC13; Sat, 3 Oct 2009 12:51:28 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n93CpSuL041136; Sat, 3 Oct 2009 12:51:28 GMT (envelope-from edwin@svn.freebsd.org) Received: (from edwin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n93CpSwk041131; Sat, 3 Oct 2009 12:51:28 GMT (envelope-from edwin@svn.freebsd.org) Message-Id: <200910031251.n93CpSwk041131@svn.freebsd.org> From: Edwin Groothuis Date: Sat, 3 Oct 2009 12:51:28 +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: r197731 - in user/edwin/locale: . share usr.bin usr.bin/unicode2utf8 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: Sat, 03 Oct 2009 12:51:28 -0000 Author: edwin Date: Sat Oct 3 12:51:28 2009 New Revision: 197731 URL: http://svn.freebsd.org/changeset/base/197731 Log: Add C version of unicode2utf8. Perl version: 45 seconds for 92 conversions. Initial C version: 25 seconds for 92 conversions. Current C version: 12 seconds for 92 conversions. Added: user/edwin/locale/usr.bin/ user/edwin/locale/usr.bin/unicode2utf8/ user/edwin/locale/usr.bin/unicode2utf8/Makefile user/edwin/locale/usr.bin/unicode2utf8/unicode2utf8.c Modified: user/edwin/locale/README.locale user/edwin/locale/share/Makefile.def.inc Modified: user/edwin/locale/README.locale ============================================================================== --- user/edwin/locale/README.locale Sat Oct 3 12:22:12 2009 (r197730) +++ user/edwin/locale/README.locale Sat Oct 3 12:51:28 2009 (r197731) @@ -94,15 +94,13 @@ Finished: share/numericdef, share/timedef. - Regression check. - Conversion of the Unicode definitions to the UTF-8 character-set. + It is residing in usr.bin/unicode2utf8 and requires the file + posix/UTF-8.cm from the CLDR distribution. Pending: - Checking of the data with the CLDR (Common Locale Data Repository) for completeness of the current data. - Conversion of Makefiles for share/mklocale. -- Conversion of the Unicode definitions to the UTF-8 character-set - in a C program or AWK script to make it self-hosting. This is - right now a Perl script so it can't be part of the base OS build - yet. This tool for now lives in src/tools/tools/locale/. - Import of the file UTF-8.cm (from the CLDR project) and the file UnicodeData.txt (from the Unicode project) into the base operating system. These files for now live in src/tools/tools/locale/ @@ -145,7 +143,6 @@ Local configuration: - Add to /etc/make.conf (make sure they match your directory layout) CLDRDIR= /home/edwin/unicode/cldr/1.7.1 UNIDATADIR= /home/edwin/unicode/UNIDATA/5.1.0 - TOOLSDIR= /home/edwin/svn/edwin/locale/cldr/tools/ LOCALE_DESTDIR= /home/edwin/locale/new LOCALE_SHAREOWN=edwin LOCALE_SHAREGRP=edwin Modified: user/edwin/locale/share/Makefile.def.inc ============================================================================== --- user/edwin/locale/share/Makefile.def.inc Sat Oct 3 12:22:12 2009 (r197730) +++ user/edwin/locale/share/Makefile.def.inc Sat Oct 3 12:51:28 2009 (r197731) @@ -301,9 +301,8 @@ _TRANSLATIONAFTER_${cm}+= | awk '{ gsub # Normal makes don't need to convert from .unicode to .src . if defined(FULL) ${ccln}.UTF-8.src: ${ccln}.unicode - ${TOOLSDIR}/unicode2src.pl \ + ../../usr.bin/unicode2utf8/unicode2utf8 \ --cldr=${CLDRDIR} \ - --unidata=${UNIDATADIR} \ --input=${.ALLSRC} \ --output=${.TARGET} Added: user/edwin/locale/usr.bin/unicode2utf8/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/edwin/locale/usr.bin/unicode2utf8/Makefile Sat Oct 3 12:51:28 2009 (r197731) @@ -0,0 +1,15 @@ + +# $NetBSD: Makefile,v 1.6 2009/04/20 16:05:30 drochner Exp $ + +PROG= unicode2utf8 +SRCS= unicode2utf8.c +NO_MAN= yes +WARNS?= 6 + +test: + ./unicode2utf8 \ + --cldr=/home/edwin/unicode/cldr/1.7.1/ \ + --input=nl_NL.unicode \ + --output=nl_NL.UTF-8.src + +.include Added: user/edwin/locale/usr.bin/unicode2utf8/unicode2utf8.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/edwin/locale/usr.bin/unicode2utf8/unicode2utf8.c Sat Oct 3 12:51:28 2009 (r197731) @@ -0,0 +1,217 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAXBUF 512 + +struct utf8map { + char *uniname; + char *utf8char; + int utf8len; + struct utf8map *next; +}; + +struct utf8map *utf8map_head[256]; + +void usage(void); +struct utf8map *get_utf8map(char *dir); +struct utf8map *find_utf8map(char *unidata); +void translate(char *file_in, char *file_out); + +int +main(int argc, char **argv) { + char *cldr = NULL, *file_in = NULL, *file_out = NULL; + char ch; + + /* options descriptor */ + static struct option longopts[] = { + { "cldr", required_argument, NULL, 1 }, + { "input", required_argument, NULL, 3 }, + { "output", required_argument, NULL, 4 }, + { NULL, 0, NULL, 0 } + }; + + while ((ch = getopt_long_only(argc, argv, "", longopts, NULL)) != -1) { + switch (ch) { + case 1: + cldr = optarg; + break; + case 3: + file_in = optarg; + break; + case 4: + file_out = optarg; + break; + break; + default: + usage(); + } + } + argc -= optind; + argv += optind; + + get_utf8map(cldr); + translate(file_in, file_out); +} + +void +translate(char *file_in, char *file_out) { + FILE *fin, *fout; + char line[MAXBUF]; + char *p, *q1, *q2; + struct utf8map *map; + + if ((fin = fopen(file_in, "r")) == NULL) + errx(EX_DATAERR, "Cannot open %s for reading.", file_in); + if ((fout = fopen(file_out, "w")) == NULL) + errx(EX_DATAERR, "Cannot open %s for writing.", file_out); + + while (!feof(fin)) { + if (fgets(line, sizeof(line), fin) != NULL) { + if (line[0] == '#') { + fprintf(fout, "%s", line); + continue; + } + + p = line; + while (*p != '\0') { + if (*p != '<') { + fputc(*p, fout); + p++; + continue; + } + q1 = strchr(p + 1, '>'); + q2 = strchr(p + 1, '<'); + if (q2 != NULL && q2 < q1) + errx(EX_DATAERR, + "Unexpected < in line %s after %s", + line, p); + *q1 = '\0'; + if ((map = find_utf8map(p + 1)) ==NULL) + errx(EX_DATAERR, + "Cannot find translation for '%s'", + p + 1); + + *q1 = '>'; + p = q1 + 1; + fwrite(map->utf8char, map->utf8len, 1, fout); + } + + } + } + + fclose(fin); + fclose(fout); +} + +struct utf8map * +find_utf8map(char *uniname) { + struct utf8map *p; + int hashindex = uniname[strlen(uniname) - 1]; + + p = utf8map_head[hashindex]; + while (p != NULL) { + if (strcmp(p->uniname, uniname) == 0) + return p; + // printf("'%s' - '%s'\n", p->uniname, uniname); + p = p->next; + } + + return NULL; +} + +struct utf8map * +get_utf8map(char *dir) { + FILE *fin; + char filename[MAXPATHLEN]; + char uniname[MAXBUF], utf8char[MAXBUF]; + char *p; + int len, i; + struct utf8map *new; + int hashindex; + + sprintf(filename, "%s/posix/UTF-8.cm", dir); + + if ((fin = fopen(filename, "r")) == NULL) + errx(EX_DATAERR, "Cannot open UTF-8 in %s/posix", filename); + + while (!feof(fin)) { + if (fgets(uniname, sizeof(uniname), fin) != NULL) + if (strncmp(uniname, "CHARMAP", 7) == 0) + break; + } + if (feof(fin)) + errx(EX_DATAERR, "Didn't find initial CHARMAP magic cookie.\n"); + + while (!feof(fin)) { + if (fscanf(fin, "%s %s", uniname, utf8char) == 2) { + /* ^END CHARMAP$ */ + if (strcmp(uniname, "END") == 0 + && strcmp(utf8char, "CHARMAP") == 0) + break; + + /* Get rid of the _'s in the name */ + while ((p = strchr(uniname, '_')) != NULL) + *p = ' '; + if ((p = strchr(uniname, '>')) == NULL) + errx(EX_DATAERR, "No trailing '>' for %s", + uniname); + hashindex = p[-1]; + *p = '\0'; + if (uniname[0] != '<') + errx(EX_DATAERR, "No leading '<' for %s", + uniname); + + /* Translate hex strings into ascii-strings */ + len = strlen(utf8char); + if (len % 4 != 0) + errx(EX_DATAERR, "Wrong length: '%s'", + utf8char); + len /= 4; + for (i = 0; i < len; i++) { + /* + * Not setting will produce wrong results for + * the unicode string NULL + */ + errno = 0; + + /* "\xAA" -> "AA" -> chr(hextodec("AA")) */ + utf8char[i] = strtol(utf8char + 4 * i + 2, NULL, + 16); + if (utf8char[i] == 0 && errno != 0) + errx(errno, + "'%s' isn't a hex digit (%d)", + utf8char + 4 * i + 2, errno); + utf8char[len] = 0; + } + + // printf("-%s-%s-\n", uniname, utf8char); + new = (struct utf8map *)malloc(sizeof(struct utf8map)); + new->next = utf8map_head[hashindex]; + new->uniname = strdup(uniname + 1); + new->utf8char = strdup(utf8char); + new->utf8len = len; + utf8map_head[hashindex] = new; + } + } + + if (feof(fin)) + errx(EX_DATAERR, "Didn't find final CHARMAP magic cookie.\n"); + + fclose(fin); + + return NULL; +} + +void +usage(void) { + + printf("Usage: unicode2utf8 --cldr=. --input=. --output=.\n"); + exit(EX_USAGE); +} + From owner-svn-src-user@FreeBSD.ORG Sat Oct 3 13:17:21 2009 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 D2C6B106566B; Sat, 3 Oct 2009 13:17:21 +0000 (UTC) (envelope-from edwin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C26858FC22; Sat, 3 Oct 2009 13:17:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n93DHLEt041696; Sat, 3 Oct 2009 13:17:21 GMT (envelope-from edwin@svn.freebsd.org) Received: (from edwin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n93DHLui041694; Sat, 3 Oct 2009 13:17:21 GMT (envelope-from edwin@svn.freebsd.org) Message-Id: <200910031317.n93DHLui041694@svn.freebsd.org> From: Edwin Groothuis Date: Sat, 3 Oct 2009 13:17:21 +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: r197732 - user/edwin/locale 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: Sat, 03 Oct 2009 13:17:21 -0000 Author: edwin Date: Sat Oct 3 13:17:21 2009 New Revision: 197732 URL: http://svn.freebsd.org/changeset/base/197732 Log: Remove obsolete instructions. Modified: user/edwin/locale/README.locale Modified: user/edwin/locale/README.locale ============================================================================== --- user/edwin/locale/README.locale Sat Oct 3 12:51:28 2009 (r197731) +++ user/edwin/locale/README.locale Sat Oct 3 13:17:21 2009 (r197732) @@ -133,8 +133,6 @@ To test the current system, you need the - A copy of the CLDR, available from http://cldr.unicode.org/. Currently version 1.7.1 is used. We only use the file posix/UTF-8.cm from it. -- A copy of the Unicode database, available from http://www.unicode.org/. - Currently version is 5.1.0. We only use the file UnicodeData.txt from it. - A copy of svn://svn.freebsd.org/base/user/edwin/locale/. - A copy of bsdiconv from p4:///depot/gabor/something. @@ -142,7 +140,6 @@ Local configuration: - Add to /etc/make.conf (make sure they match your directory layout) CLDRDIR= /home/edwin/unicode/cldr/1.7.1 - UNIDATADIR= /home/edwin/unicode/UNIDATA/5.1.0 LOCALE_DESTDIR= /home/edwin/locale/new LOCALE_SHAREOWN=edwin LOCALE_SHAREGRP=edwin From owner-svn-src-user@FreeBSD.ORG Sat Oct 3 17:49:44 2009 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 D6A491065676; Sat, 3 Oct 2009 17:49:44 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AC35D8FC0C; Sat, 3 Oct 2009 17:49:44 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n93Hnikm047365; Sat, 3 Oct 2009 17:49:44 GMT (envelope-from rpaulo@svn.freebsd.org) Received: (from rpaulo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n93Hnilv047363; Sat, 3 Oct 2009 17:49:44 GMT (envelope-from rpaulo@svn.freebsd.org) Message-Id: <200910031749.n93Hnilv047363@svn.freebsd.org> From: Rui Paulo Date: Sat, 3 Oct 2009 17:49: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: r197737 - user/rpaulo/armpmc/dev/hwpmc 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: Sat, 03 Oct 2009 17:49:44 -0000 Author: rpaulo Date: Sat Oct 3 17:49:44 2009 New Revision: 197737 URL: http://svn.freebsd.org/changeset/base/197737 Log: Checkpoint code. It no longer panics. Modified: user/rpaulo/armpmc/dev/hwpmc/hwpmc_xscale.c Modified: user/rpaulo/armpmc/dev/hwpmc/hwpmc_xscale.c ============================================================================== --- user/rpaulo/armpmc/dev/hwpmc/hwpmc_xscale.c Sat Oct 3 16:13:56 2009 (r197736) +++ user/rpaulo/armpmc/dev/hwpmc/hwpmc_xscale.c Sat Oct 3 17:49:44 2009 (r197737) @@ -45,47 +45,68 @@ struct xscale_event_code_map { static int xscale_read_pmc(int cpu, int ri, pmc_value_t *v) { + return 0; } static int xscale_write_pmc(int cpu, int ri, pmc_value_t v) { + return 0; } static int xscale_config_pmc(int cpu, int ri, struct pmc *pm) { + return 0; } static int xscale_start_pmc(int cpu, int ri) { + return 0; } static int xscale_stop_pmc(int cpu, int ri) { + return 0; } static int xscale_intr(int cpu, struct trapframe *tf) { + return 0; } static int xscale_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc) { + return 0; +} + +static int +xscale_pcpu_init(struct pmc_mdep *md, int cpu) +{ + return 0; +} + +static int +xscale_pcpu_fini(struct pmc_mdep *md, int cpu) +{ + return 0; } struct pmc_mdep * pmc_xscale_initialize() { struct pmc_mdep *pmc_mdep; + struct pmc_classdep *pcd; pmc_mdep = malloc(sizeof(struct pmc_mdep) + sizeof(struct pmc_classdep), M_PMC, M_WAITOK|M_ZERO); pmc_mdep->pmd_cputype = PMC_CPU_INTEL_XSCALE; pmc_mdep->pmd_nclass = 1; + pmc_mdep->pmd_npmc = XSCALE_NPMCS; pcd = &pmc_mdep->pmd_classdep[0]; pcd->pcd_caps = XSCALE_PMC_CAPS; @@ -93,19 +114,21 @@ pmc_xscale_initialize() pcd->pcd_ri = pmc_mdep->pmd_npmc; pcd->pcd_width = 48; /* XXX */ - pcd->pcd_allocate_pmc = xscale_allocate_pmc; + //pcd->pcd_allocate_pmc = xscale_allocate_pmc; pcd->pcd_config_pmc = xscale_config_pmc; + pcd->pcd_pcpu_fini = xscale_pcpu_fini; + pcd->pcd_pcpu_init = xscale_pcpu_init; pcd->pcd_describe = xscale_describe; - pcd->pcd_get_config = xscale_get_config; + //pcd->pcd_get_config = xscale_get_config; pcd->pcd_read_pmc = xscale_read_pmc; - pcd->pcd_release_pmc = xscale_release_pmc; + //pcd->pcd_release_pmc = xscale_release_pmc; pcd->pcd_start_pmc = xscale_start_pmc; pcd->pcd_stop_pmc = xscale_stop_pmc; pcd->pcd_write_pmc = xscale_write_pmc; pmc_mdep->pmd_intr = xscale_intr; - pmc_mdep->pmd_switch_in = xscale_switch_in; - pmc_mdep->pmd_switch_out = xscale_switch_out; + //pmc_mdep->pmd_switch_in = xscale_switch_in; + //pmc_mdep->pmd_switch_out = xscale_switch_out; return (pmc_mdep); }