You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(97) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(127) |
Feb
(34) |
Mar
(16) |
Apr
(26) |
May
(55) |
Jun
(107) |
Jul
(36) |
Aug
(72) |
Sep
(90) |
Oct
(41) |
Nov
(27) |
Dec
(13) |
| 2008 |
Jan
(37) |
Feb
(39) |
Mar
(98) |
Apr
(115) |
May
(134) |
Jun
(120) |
Jul
(86) |
Aug
(149) |
Sep
(68) |
Oct
(66) |
Nov
(104) |
Dec
(49) |
| 2009 |
Jan
(131) |
Feb
(132) |
Mar
(125) |
Apr
(172) |
May
(161) |
Jun
(43) |
Jul
(47) |
Aug
(38) |
Sep
(18) |
Oct
(6) |
Nov
(1) |
Dec
(15) |
| 2010 |
Jan
(21) |
Feb
(8) |
Mar
(10) |
Apr
(4) |
May
(9) |
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
(4) |
| 2011 |
Jan
(23) |
Feb
(10) |
Mar
(13) |
Apr
(3) |
May
|
Jun
(19) |
Jul
(11) |
Aug
(22) |
Sep
|
Oct
(4) |
Nov
(2) |
Dec
(12) |
| 2012 |
Jan
(3) |
Feb
(4) |
Mar
(7) |
Apr
(3) |
May
|
Jun
(1) |
Jul
(1) |
Aug
(30) |
Sep
(3) |
Oct
(2) |
Nov
|
Dec
(8) |
| 2013 |
Jan
(3) |
Feb
(40) |
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(12) |
Dec
|
| 2021 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
|
From: <ls...@us...> - 2007-05-13 17:03:22
|
Revision: 3194
http://jnode.svn.sourceforge.net/jnode/?rev=3194&view=rev
Author: lsantha
Date: 2007-05-13 10:03:10 -0700 (Sun, 13 May 2007)
Log Message:
-----------
First merges of OpenJDK.
Added Paths:
-----------
trunk/core/src/openjdk/java/java/text/
trunk/core/src/openjdk/java/java/text/Normalizer.java
Added: trunk/core/src/openjdk/java/java/text/Normalizer.java
===================================================================
--- trunk/core/src/openjdk/java/java/text/Normalizer.java (rev 0)
+++ trunk/core/src/openjdk/java/java/text/Normalizer.java 2007-05-13 17:03:10 UTC (rev 3194)
@@ -0,0 +1,183 @@
+/*
+ * Portions Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ *******************************************************************************
+ * (C) Copyright IBM Corp. 1996-2005 - All Rights Reserved *
+ * *
+ * The original version of this source code and documentation is copyrighted *
+ * and owned by IBM, These materials are provided under terms of a License *
+ * Agreement between IBM and Sun. This technology is protected by multiple *
+ * US and International patents. This notice and attribution to IBM may not *
+ * to removed. *
+ *******************************************************************************
+ */
+
+package java.text;
+
+import sun.text.normalizer.NormalizerBase;
+import sun.text.normalizer.NormalizerImpl;
+
+/**
+ * This class provides the method <code>normalize</code> which transforms Unicode
+ * text into an equivalent composed or decomposed form, allowing for easier
+ * sorting and searching of text.
+ * The <code>normalize</code> method supports the standard normalization forms
+ * described in
+ * <a href="http://www.unicode.org/unicode/reports/tr15/tr15-23.html">
+ * Unicode Standard Annex #15 — Unicode Normalization Forms</a>.
+ * <p>
+ * Characters with accents or other adornments can be encoded in
+ * several different ways in Unicode. For example, take the character A-acute.
+ * In Unicode, this can be encoded as a single character (the "composed" form):
+ *
+ * <p><pre>
+ * U+00C1 LATIN CAPITAL LETTER A WITH ACUTE</pre>
+ * </p>
+ *
+ * or as two separate characters (the "decomposed" form):
+ *
+ * <p><pre>
+ * U+0041 LATIN CAPITAL LETTER A
+ * U+0301 COMBINING ACUTE ACCENT</pre>
+ * </p>
+ *
+ * To a user of your program, however, both of these sequences should be
+ * treated as the same "user-level" character "A with acute accent". When you
+ * are searching or comparing text, you must ensure that these two sequences are
+ * treated as equivalent. In addition, you must handle characters with more than
+ * one accent. Sometimes the order of a character's combining accents is
+ * significant, while in other cases accent sequences in different orders are
+ * really equivalent.
+ * <p>
+ * Similarly, the string "ffi" can be encoded as three separate letters:
+ *
+ * <p><pre>
+ * U+0066 LATIN SMALL LETTER F
+ * U+0066 LATIN SMALL LETTER F
+ * U+0069 LATIN SMALL LETTER I</pre>
+ * </p>
+ *
+ * or as the single character
+ *
+ * <p><pre>
+ * U+FB03 LATIN SMALL LIGATURE FFI</pre>
+ * </p>
+ *
+ * The ffi ligature is not a distinct semantic character, and strictly speaking
+ * it shouldn't be in Unicode at all, but it was included for compatibility
+ * with existing character sets that already provided it. The Unicode standard
+ * identifies such characters by giving them "compatibility" decompositions
+ * into the corresponding semantic characters. When sorting and searching, you
+ * will often want to use these mappings.
+ * <p>
+ * The <code>normalize</code> method helps solve these problems by transforming
+ * text into the canonical composed and decomposed forms as shown in the first
+ * example above. In addition, you can have it perform compatibility
+ * decompositions so that you can treat compatibility characters the same as
+ * their equivalents.
+ * Finally, the <code>normalize</code> method rearranges accents into the
+ * proper canonical order, so that you do not have to worry about accent
+ * rearrangement on your own.
+ * <p>
+ * The W3C generally recommends to exchange texts in NFC.
+ * Note also that most legacy character encodings use only precomposed forms and
+ * often do not encode any combining marks by themselves. For conversion to such
+ * character encodings the Unicode text needs to be normalized to NFC.
+ * For more usage examples, see the Unicode Standard Annex.
+ *
+ * @since 1.6
+ */
+public final class Normalizer {
+
+ private Normalizer() {};
+
+ /**
+ * This enum provides constants of the four Unicode normalization forms
+ * that are described in
+ * <a href="http://www.unicode.org/unicode/reports/tr15/tr15-23.html">
+ * Unicode Standard Annex #15 — Unicode Normalization Forms</a>
+ * and two methods to access them.
+ *
+ * @since 1.6
+ */
+ public static enum Form {
+
+ /**
+ * Canonical decomposition.
+ */
+ NFD,
+
+ /**
+ * Canonical decomposition, followed by canonical composition.
+ */
+ NFC,
+
+ /**
+ * Compatibility decomposition.
+ */
+ NFKD,
+
+ /**
+ * Compatibility decomposition, followed by canonical composition.
+ */
+ NFKC
+ }
+
+ /**
+ * Normalize a sequence of char values.
+ * The sequence will be normalized according to the specified normalization
+ * from.
+ * @param src The sequence of char values to normalize.
+ * @param form The normalization form; one of
+ * {@link java.text.Normalizer.Form#NFC},
+ * {@link java.text.Normalizer.Form#NFD},
+ * {@link java.text.Normalizer.Form#NFKC},
+ * {@link java.text.Normalizer.Form#NFKD}
+ * @return The normalized String
+ * @throws NullPointerException If <code>src</code> or <code>form</code>
+ * is null.
+ */
+ public static String normalize(CharSequence src, Form form) {
+ return NormalizerBase.normalize(src.toString(), form);
+ }
+
+ /**
+ * Determines if the given sequence of char values is normalized.
+ * @param src The sequence of char values to be checked.
+ * @param form The normalization form; one of
+ * {@link java.text.Normalizer.Form#NFC},
+ * {@link java.text.Normalizer.Form#NFD},
+ * {@link java.text.Normalizer.Form#NFKC},
+ * {@link java.text.Normalizer.Form#NFKD}
+ * @return true if the sequence of char values is normalized;
+ * false otherwise.
+ * @throws NullPointerException If <code>src</code> or <code>form</code>
+ * is null.
+ */
+ public static boolean isNormalized(CharSequence src, Form form) {
+ return NormalizerBase.isNormalized(src.toString(), form);
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2007-05-13 17:02:24
|
Revision: 3193
http://jnode.svn.sourceforge.net/jnode/?rev=3193&view=rev
Author: lsantha
Date: 2007-05-13 10:02:22 -0700 (Sun, 13 May 2007)
Log Message:
-----------
First merges of OpenJDK.
Added Paths:
-----------
trunk/core/src/openjdk/
trunk/core/src/openjdk/java/
trunk/core/src/openjdk/java/java/
trunk/core/src/openjdk/java/java/lang/
trunk/core/src/openjdk/java/java/lang/Double.java
Added: trunk/core/src/openjdk/java/java/lang/Double.java
===================================================================
--- trunk/core/src/openjdk/java/java/lang/Double.java (rev 0)
+++ trunk/core/src/openjdk/java/java/lang/Double.java 2007-05-13 17:02:22 UTC (rev 3193)
@@ -0,0 +1,975 @@
+/*
+ * Copyright 1994-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package java.lang;
+
+import sun.misc.FloatingDecimal;
+import sun.misc.FpUtils;
+import sun.misc.DoubleConsts;
+
+/**
+ * The {@code Double} class wraps a value of the primitive type
+ * {@code double} in an object. An object of type
+ * {@code Double} contains a single field whose type is
+ * {@code double}.
+ *
+ * <p>In addition, this class provides several methods for converting a
+ * {@code double} to a {@code String} and a
+ * {@code String} to a {@code double}, as well as other
+ * constants and methods useful when dealing with a
+ * {@code double}.
+ *
+ * @author Lee Boynton
+ * @author Arthur van Hoff
+ * @author Joseph D. Darcy
+ * @version 1.107, 05/05/07
+ * @since JDK1.0
+ */
+public final class Double extends Number implements Comparable<Double> {
+ /**
+ * A constant holding the positive infinity of type
+ * {@code double}. It is equal to the value returned by
+ * {@code Double.longBitsToDouble(0x7ff0000000000000L)}.
+ */
+ public static final double POSITIVE_INFINITY = 1.0 / 0.0;
+
+ /**
+ * A constant holding the negative infinity of type
+ * {@code double}. It is equal to the value returned by
+ * {@code Double.longBitsToDouble(0xfff0000000000000L)}.
+ */
+ public static final double NEGATIVE_INFINITY = -1.0 / 0.0;
+
+ /**
+ * A constant holding a Not-a-Number (NaN) value of type
+ * {@code double}. It is equivalent to the value returned by
+ * {@code Double.longBitsToDouble(0x7ff8000000000000L)}.
+ */
+ public static final double NaN = 0.0d / 0.0;
+
+ /**
+ * A constant holding the largest positive finite value of type
+ * {@code double},
+ * (2-2<sup>-52</sup>)·2<sup>1023</sup>. It is equal to
+ * the hexadecimal floating-point literal
+ * {@code 0x1.fffffffffffffP+1023} and also equal to
+ * {@code Double.longBitsToDouble(0x7fefffffffffffffL)}.
+ */
+ public static final double MAX_VALUE = 0x1.fffffffffffffP+1023; // 1.7976931348623157e+308
+
+ /**
+ * A constant holding the smallest positive normal value of type
+ * {@code double}, 2<sup>-1022</sup>. It is equal to the
+ * hexadecimal floating-point literal {@code 0x1.0p-1022} and also
+ * equal to {@code Double.longBitsToDouble(0x0010000000000000L)}.
+ *
+ * @since 1.6
+ */
+ public static final double MIN_NORMAL = 0x1.0p-1022; // 2.2250738585072014E-308
+
+ /**
+ * A constant holding the smallest positive nonzero value of type
+ * {@code double}, 2<sup>-1074</sup>. It is equal to the
+ * hexadecimal floating-point literal
+ * {@code 0x0.0000000000001P-1022} and also equal to
+ * {@code Double.longBitsToDouble(0x1L)}.
+ */
+ public static final double MIN_VALUE = 0x0.0000000000001P-1022; // 4.9e-324
+
+ /**
+ * Maximum exponent a finite {@code double} variable may have.
+ * It is equal to the value returned by
+ * {@code Math.getExponent(Double.MAX_VALUE)}.
+ *
+ * @since 1.6
+ */
+ public static final int MAX_EXPONENT = 1023;
+
+ /**
+ * Minimum exponent a normalized {@code double} variable may
+ * have. It is equal to the value returned by
+ * {@code Math.getExponent(Double.MIN_NORMAL)}.
+ *
+ * @since 1.6
+ */
+ public static final int MIN_EXPONENT = -1022;
+
+ /**
+ * The number of bits used to represent a {@code double} value.
+ *
+ * @since 1.5
+ */
+ public static final int SIZE = 64;
+
+ /**
+ * The {@code Class} instance representing the primitive type
+ * {@code double}.
+ *
+ * @since JDK1.1
+ */
+ public static final Class<Double> TYPE = (Class<Double>) Class.getPrimitiveClass("double");
+
+ /**
+ * Returns a string representation of the {@code double}
+ * argument. All characters mentioned below are ASCII characters.
+ * <ul>
+ * <li>If the argument is NaN, the result is the string
+ * "{@code NaN}".
+ * <li>Otherwise, the result is a string that represents the sign and
+ * magnitude (absolute value) of the argument. If the sign is negative,
+ * the first character of the result is '{@code -}'
+ * (<code>'\u002D'</code>); if the sign is positive, no sign character
+ * appears in the result. As for the magnitude <i>m</i>:
+ * <ul>
+ * <li>If <i>m</i> is infinity, it is represented by the characters
+ * {@code "Infinity"}; thus, positive infinity produces the result
+ * {@code "Infinity"} and negative infinity produces the result
+ * {@code "-Infinity"}.
+ *
+ * <li>If <i>m</i> is zero, it is represented by the characters
+ * {@code "0.0"}; thus, negative zero produces the result
+ * {@code "-0.0"} and positive zero produces the result
+ * {@code "0.0"}.
+ *
+ * <li>If <i>m</i> is greater than or equal to 10<sup>-3</sup> but less
+ * than 10<sup>7</sup>, then it is represented as the integer part of
+ * <i>m</i>, in decimal form with no leading zeroes, followed by
+ * '{@code .}' (<code>'\u002E'</code>), followed by one or
+ * more decimal digits representing the fractional part of <i>m</i>.
+ *
+ * <li>If <i>m</i> is less than 10<sup>-3</sup> or greater than or
+ * equal to 10<sup>7</sup>, then it is represented in so-called
+ * "computerized scientific notation." Let <i>n</i> be the unique
+ * integer such that 10<sup><i>n</i></sup> ≤ <i>m</i> {@literal <}
+ * 10<sup><i>n</i>+1</sup>; then let <i>a</i> be the
+ * mathematically exact quotient of <i>m</i> and
+ * 10<sup><i>n</i></sup> so that 1 ≤ <i>a</i> {@literal <} 10. The
+ * magnitude is then represented as the integer part of <i>a</i>,
+ * as a single decimal digit, followed by '{@code .}'
+ * (<code>'\u002E'</code>), followed by decimal digits
+ * representing the fractional part of <i>a</i>, followed by the
+ * letter '{@code E}' (<code>'\u0045'</code>), followed
+ * by a representation of <i>n</i> as a decimal integer, as
+ * produced by the method {@link Integer#toString(int)}.
+ * </ul>
+ * </ul>
+ * How many digits must be printed for the fractional part of
+ * <i>m</i> or <i>a</i>? There must be at least one digit to represent
+ * the fractional part, and beyond that as many, but only as many, more
+ * digits as are needed to uniquely distinguish the argument value from
+ * adjacent values of type {@code double}. That is, suppose that
+ * <i>x</i> is the exact mathematical value represented by the decimal
+ * representation produced by this method for a finite nonzero argument
+ * <i>d</i>. Then <i>d</i> must be the {@code double} value nearest
+ * to <i>x</i>; or if two {@code double} values are equally close
+ * to <i>x</i>, then <i>d</i> must be one of them and the least
+ * significant bit of the significand of <i>d</i> must be {@code 0}.
+ *
+ * <p>To create localized string representations of a floating-point
+ * value, use subclasses of {@link java.text.NumberFormat}.
+ *
+ * @param d the {@code double} to be converted.
+ * @return a string representation of the argument.
+ */
+ public static String toString(double d) {
+ return new FloatingDecimal(d).toJavaFormatString();
+ }
+
+ /**
+ * Returns a hexadecimal string representation of the
+ * {@code double} argument. All characters mentioned below
+ * are ASCII characters.
+ *
+ * <ul>
+ * <li>If the argument is NaN, the result is the string
+ * "{@code NaN}".
+ * <li>Otherwise, the result is a string that represents the sign
+ * and magnitude of the argument. If the sign is negative, the
+ * first character of the result is '{@code -}'
+ * (<code>'\u002D'</code>); if the sign is positive, no sign
+ * character appears in the result. As for the magnitude <i>m</i>:
+ *
+ * <ul>
+ * <li>If <i>m</i> is infinity, it is represented by the string
+ * {@code "Infinity"}; thus, positive infinity produces the
+ * result {@code "Infinity"} and negative infinity produces
+ * the result {@code "-Infinity"}.
+ *
+ * <li>If <i>m</i> is zero, it is represented by the string
+ * {@code "0x0.0p0"}; thus, negative zero produces the result
+ * {@code "-0x0.0p0"} and positive zero produces the result
+ * {@code "0x0.0p0"}.
+ *
+ * <li>If <i>m</i> is a {@code double} value with a
+ * normalized representation, substrings are used to represent the
+ * significand and exponent fields. The significand is
+ * represented by the characters {@code "0x1."}
+ * followed by a lowercase hexadecimal representation of the rest
+ * of the significand as a fraction. Trailing zeros in the
+ * hexadecimal representation are removed unless all the digits
+ * are zero, in which case a single zero is used. Next, the
+ * exponent is represented by {@code "p"} followed
+ * by a decimal string of the unbiased exponent as if produced by
+ * a call to {@link Integer#toString(int) Integer.toString} on the
+ * exponent value.
+ *
+ * <li>If <i>m</i> is a {@code double} value with a subnormal
+ * representation, the significand is represented by the
+ * characters {@code "0x0."} followed by a
+ * hexadecimal representation of the rest of the significand as a
+ * fraction. Trailing zeros in the hexadecimal representation are
+ * removed. Next, the exponent is represented by
+ * {@code "p-1022"}. Note that there must be at
+ * least one nonzero digit in a subnormal significand.
+ *
+ * </ul>
+ *
+ * </ul>
+ *
+ * <table border>
+ * <caption><h3>Examples</h3></caption>
+ * <tr><th>Floating-point Value</th><th>Hexadecimal String</th>
+ * <tr><td>{@code 1.0}</td> <td>{@code 0x1.0p0}</td>
+ * <tr><td>{@code -1.0}</td> <td>{@code -0x1.0p0}</td>
+ * <tr><td>{@code 2.0}</td> <td>{@code 0x1.0p1}</td>
+ * <tr><td>{@code 3.0}</td> <td>{@code 0x1.8p1}</td>
+ * <tr><td>{@code 0.5}</td> <td>{@code 0x1.0p-1}</td>
+ * <tr><td>{@code 0.25}</td> <td>{@code 0x1.0p-2}</td>
+ * <tr><td>{@code Double.MAX_VALUE}</td>
+ * <td>{@code 0x1.fffffffffffffp1023}</td>
+ * <tr><td>{@code Minimum Normal Value}</td>
+ * <td>{@code 0x1.0p-1022}</td>
+ * <tr><td>{@code Maximum Subnormal Value}</td>
+ * <td>{@code 0x0.fffffffffffffp-1022}</td>
+ * <tr><td>{@code Double.MIN_VALUE}</td>
+ * <td>{@code 0x0.0000000000001p-1022}</td>
+ * </table>
+ * @param d the {@code double} to be converted.
+ * @return a hex string representation of the argument.
+ * @since 1.5
+ * @author Joseph D. Darcy
+ */
+ public static String toHexString(double d) {
+ /*
+ * Modeled after the "a" conversion specifier in C99, section
+ * 7.19.6.1; however, the output of this method is more
+ * tightly specified.
+ */
+ if (!FpUtils.isFinite(d) )
+ // For infinity and NaN, use the decimal output.
+ return Double.toString(d);
+ else {
+ // Initialized to maximum size of output.
+ StringBuffer answer = new StringBuffer(24);
+
+ if (FpUtils.rawCopySign(1.0, d) == -1.0) // value is negative,
+ answer.append("-"); // so append sign info
+
+ answer.append("0x");
+
+ d = Math.abs(d);
+
+ if(d == 0.0) {
+ answer.append("0.0p0");
+ }
+ else {
+ boolean subnormal = (d < DoubleConsts.MIN_NORMAL);
+
+ // Isolate significand bits and OR in a high-order bit
+ // so that the string representation has a known
+ // length.
+ long signifBits = (Double.doubleToLongBits(d)
+ & DoubleConsts.SIGNIF_BIT_MASK) |
+ 0x1000000000000000L;
+
+ // Subnormal values have a 0 implicit bit; normal
+ // values have a 1 implicit bit.
+ answer.append(subnormal ? "0." : "1.");
+
+ // Isolate the low-order 13 digits of the hex
+ // representation. If all the digits are zero,
+ // replace with a single 0; otherwise, remove all
+ // trailing zeros.
+ String signif = Long.toHexString(signifBits).substring(3,16);
+ answer.append(signif.equals("0000000000000") ? // 13 zeros
+ "0":
+ signif.replaceFirst("0{1,12}$", ""));
+
+ // If the value is subnormal, use the E_min exponent
+ // value for double; otherwise, extract and report d's
+ // exponent (the representation of a subnormal uses
+ // E_min -1).
+ answer.append("p" + (subnormal ?
+ DoubleConsts.MIN_EXPONENT:
+ FpUtils.getExponent(d) ));
+ }
+ return answer.toString();
+ }
+ }
+
+ /**
+ * Returns a {@code Double} object holding the
+ * {@code double} value represented by the argument string
+ * {@code s}.
+ *
+ * <p>If {@code s} is {@code null}, then a
+ * {@code NullPointerException} is thrown.
+ *
+ * <p>Leading and trailing whitespace characters in {@code s}
+ * are ignored. Whitespace is removed as if by the {@link
+ * String#trim} method; that is, both ASCII space and control
+ * characters are removed. The rest of {@code s} should
+ * constitute a <i>FloatValue</i> as described by the lexical
+ * syntax rules:
+ *
+ * <blockquote>
+ * <dl>
+ * <dt><i>FloatValue:</i>
+ * <dd><i>Sign<sub>opt</sub></i> {@code NaN}
+ * <dd><i>Sign<sub>opt</sub></i> {@code Infinity}
+ * <dd><i>Sign<sub>opt</sub> FloatingPointLiteral</i>
+ * <dd><i>Sign<sub>opt</sub> HexFloatingPointLiteral</i>
+ * <dd><i>SignedInteger</i>
+ * </dl>
+ *
+ * <p>
+ *
+ * <dl>
+ * <dt><i>HexFloatingPointLiteral</i>:
+ * <dd> <i>HexSignificand BinaryExponent FloatTypeSuffix<sub>opt</sub></i>
+ * </dl>
+ *
+ * <p>
+ *
+ * <dl>
+ * <dt><i>HexSignificand:</i>
+ * <dd><i>HexNumeral</i>
+ * <dd><i>HexNumeral</i> {@code .}
+ * <dd>{@code 0x} <i>HexDigits<sub>opt</sub>
+ * </i>{@code .}<i> HexDigits</i>
+ * <dd>{@code 0X}<i> HexDigits<sub>opt</sub>
+ * </i>{@code .} <i>HexDigits</i>
+ * </dl>
+ *
+ * <p>
+ *
+ * <dl>
+ * <dt><i>BinaryExponent:</i>
+ * <dd><i>BinaryExponentIndicator SignedInteger</i>
+ * </dl>
+ *
+ * <p>
+ *
+ * <dl>
+ * <dt><i>BinaryExponentIndicator:</i>
+ * <dd>{@code p}
+ * <dd>{@code P}
+ * </dl>
+ *
+ * </blockquote>
+ *
+ * where <i>Sign</i>, <i>FloatingPointLiteral</i>,
+ * <i>HexNumeral</i>, <i>HexDigits</i>, <i>SignedInteger</i> and
+ * <i>FloatTypeSuffix</i> are as defined in the lexical structure
+ * sections of the of the <a
+ * href="http://java.sun.com/docs/books/jls/html/">Java Language
+ * Specification</a>. If {@code s} does not have the form of
+ * a <i>FloatValue</i>, then a {@code NumberFormatException}
+ * is thrown. Otherwise, {@code s} is regarded as
+ * representing an exact decimal value in the usual
+ * "computerized scientific notation" or as an exact
+ * hexadecimal value; this exact numerical value is then
+ * conceptually converted to an "infinitely precise"
+ * binary value that is then rounded to type {@code double}
+ * by the usual round-to-nearest rule of IEEE 754 floating-point
+ * arithmetic, which includes preserving the sign of a zero
+ * value. Finally, a {@code Double} object representing this
+ * {@code double} value is returned.
+ *
+ * <p> To interpret localized string representations of a
+ * floating-point value, use subclasses of {@link
+ * java.text.NumberFormat}.
+ *
+ * <p>Note that trailing format specifiers, specifiers that
+ * determine the type of a floating-point literal
+ * ({@code 1.0f} is a {@code float} value;
+ * {@code 1.0d} is a {@code double} value), do
+ * <em>not</em> influence the results of this method. In other
+ * words, the numerical value of the input string is converted
+ * directly to the target floating-point type. The two-step
+ * sequence of conversions, string to {@code float} followed
+ * by {@code float} to {@code double}, is <em>not</em>
+ * equivalent to converting a string directly to
+ * {@code double}. For example, the {@code float}
+ * literal {@code 0.1f} is equal to the {@code double}
+ * value {@code 0.10000000149011612}; the {@code float}
+ * literal {@code 0.1f} represents a different numerical
+ * value than the {@code double} literal
+ * {@code 0.1}. (The numerical value 0.1 cannot be exactly
+ * represented in a binary floating-point number.)
+ *
+ * <p>To avoid calling this method on an invalid string and having
+ * a {@code NumberFormatException} be thrown, the regular
+ * expression below can be used to screen the input string:
+ *
+ * <code>
+ * <pre>
+ * final String Digits = "(\\p{Digit}+)";
+ * final String HexDigits = "(\\p{XDigit}+)";
+ * // an exponent is 'e' or 'E' followed by an optionally
+ * // signed decimal integer.
+ * final String Exp = "[eE][+-]?"+Digits;
+ * final String fpRegex =
+ * ("[\\x00-\\x20]*"+ // Optional leading "whitespace"
+ * "[+-]?(" + // Optional sign character
+ * "NaN|" + // "NaN" string
+ * "Infinity|" + // "Infinity" string
+ *
+ * // A decimal floating-point string representing a finite positive
+ * // number without a leading sign has at most five basic pieces:
+ * // Digits . Digits ExponentPart FloatTypeSuffix
+ * //
+ * // Since this method allows integer-only strings as input
+ * // in addition to strings of floating-point literals, the
+ * // two sub-patterns below are simplifications of the grammar
+ * // productions from the Java Language Specification, 2nd
+ * // edition, section 3.10.2.
+ *
+ * // Digits ._opt Digits_opt ExponentPart_opt FloatTypeSuffix_opt
+ * "((("+Digits+"(\\.)?("+Digits+"?)("+Exp+")?)|"+
+ *
+ * // . Digits ExponentPart_opt FloatTypeSuffix_opt
+ * "(\\.("+Digits+")("+Exp+")?)|"+
+ *
+ * // Hexadecimal strings
+ * "((" +
+ * // 0[xX] HexDigits ._opt BinaryExponent FloatTypeSuffix_opt
+ * "(0[xX]" + HexDigits + "(\\.)?)|" +
+ *
+ * // 0[xX] HexDigits_opt . HexDigits BinaryExponent FloatTypeSuffix_opt
+ * "(0[xX]" + HexDigits + "?(\\.)" + HexDigits + ")" +
+ *
+ * ")[pP][+-]?" + Digits + "))" +
+ * "[fFdD]?))" +
+ * "[\\x00-\\x20]*");// Optional trailing "whitespace"
+ *
+ * if (Pattern.matches(fpRegex, myString))
+ * Double.valueOf(myString); // Will not throw NumberFormatException
+ * else {
+ * // Perform suitable alternative action
+ * }
+ * </pre>
+ * </code>
+ *
+ * @param s the string to be parsed.
+ * @return a {@code Double} object holding the value
+ * represented by the {@code String} argument.
+ * @throws NumberFormatException if the string does not contain a
+ * parsable number.
+ */
+ public static Double valueOf(String s) throws NumberFormatException {
+ return new Double(FloatingDecimal.readJavaFormatString(s).doubleValue());
+ }
+
+ /**
+ * Returns a {@code Double} instance representing the specified
+ * {@code double} value.
+ * If a new {@code Double} instance is not required, this method
+ * should generally be used in preference to the constructor
+ * {@link #Double(double)}, as this method is likely to yield
+ * significantly better space and time performance by caching
+ * frequently requested values.
+ *
+ * @param d a double value.
+ * @return a {@code Double} instance representing {@code d}.
+ * @since 1.5
+ */
+ public static Double valueOf(double d) {
+ return new Double(d);
+ }
+
+ /**
+ * Returns a new {@code double} initialized to the value
+ * represented by the specified {@code String}, as performed
+ * by the {@code valueOf} method of class
+ * {@code Double}.
+ *
+ * @param s the string to be parsed.
+ * @return the {@code double} value represented by the string
+ * argument.
+ * @throws NumberFormatException if the string does not contain
+ * a parsable {@code double}.
+ * @see java.lang.Double#valueOf(String)
+ * @since 1.2
+ */
+ public static double parseDouble(String s) throws NumberFormatException {
+ return FloatingDecimal.readJavaFormatString(s).doubleValue();
+ }
+
+ /**
+ * Returns {@code true} if the specified number is a
+ * Not-a-Number (NaN) value, {@code false} otherwise.
+ *
+ * @param v the value to be tested.
+ * @return {@code true} if the value of the argument is NaN;
+ * {@code false} otherwise.
+ */
+ static public boolean isNaN(double v) {
+ return (v != v);
+ }
+
+ /**
+ * Returns {@code true} if the specified number is infinitely
+ * large in magnitude, {@code false} otherwise.
+ *
+ * @param v the value to be tested.
+ * @return {@code true} if the value of the argument is positive
+ * infinity or negative infinity; {@code false} otherwise.
+ */
+ static public boolean isInfinite(double v) {
+ return (v == POSITIVE_INFINITY) || (v == NEGATIVE_INFINITY);
+ }
+
+ /**
+ * The value of the Double.
+ *
+ * @serial
+ */
+ private final double value;
+
+ /**
+ * Constructs a newly allocated {@code Double} object that
+ * represents the primitive {@code double} argument.
+ *
+ * @param value the value to be represented by the {@code Double}.
+ */
+ public Double(double value) {
+ this.value = value;
+ }
+
+ /**
+ * Constructs a newly allocated {@code Double} object that
+ * represents the floating-point value of type {@code double}
+ * represented by the string. The string is converted to a
+ * {@code double} value as if by the {@code valueOf} method.
+ *
+ * @param s a string to be converted to a {@code Double}.
+ * @throws NumberFormatException if the string does not contain a
+ * parsable number.
+ * @see java.lang.Double#valueOf(java.lang.String)
+ */
+ public Double(String s) throws NumberFormatException {
+ // REMIND: this is inefficient
+ this(valueOf(s).doubleValue());
+ }
+
+ /**
+ * Returns {@code true} if this {@code Double} value is
+ * a Not-a-Number (NaN), {@code false} otherwise.
+ *
+ * @return {@code true} if the value represented by this object is
+ * NaN; {@code false} otherwise.
+ */
+ public boolean isNaN() {
+ return isNaN(value);
+ }
+
+ /**
+ * Returns {@code true} if this {@code Double} value is
+ * infinitely large in magnitude, {@code false} otherwise.
+ *
+ * @return {@code true} if the value represented by this object is
+ * positive infinity or negative infinity;
+ * {@code false} otherwise.
+ */
+ public boolean isInfinite() {
+ return isInfinite(value);
+ }
+
+ /**
+ * Returns a string representation of this {@code Double} object.
+ * The primitive {@code double} value represented by this
+ * object is converted to a string exactly as if by the method
+ * {@code toString} of one argument.
+ *
+ * @return a {@code String} representation of this object.
+ * @see java.lang.Double#toString(double)
+ */
+ public String toString() {
+ return String.valueOf(value);
+ }
+
+ /**
+ * Returns the value of this {@code Double} as a {@code byte} (by
+ * casting to a {@code byte}).
+ *
+ * @return the {@code double} value represented by this object
+ * converted to type {@code byte}
+ * @since JDK1.1
+ */
+ public byte byteValue() {
+ return (byte)value;
+ }
+
+ /**
+ * Returns the value of this {@code Double} as a
+ * {@code short} (by casting to a {@code short}).
+ *
+ * @return the {@code double} value represented by this object
+ * converted to type {@code short}
+ * @since JDK1.1
+ */
+ public short shortValue() {
+ return (short)value;
+ }
+
+ /**
+ * Returns the value of this {@code Double} as an
+ * {@code int} (by casting to type {@code int}).
+ *
+ * @return the {@code double} value represented by this object
+ * converted to type {@code int}
+ */
+ public int intValue() {
+ return (int)value;
+ }
+
+ /**
+ * Returns the value of this {@code Double} as a
+ * {@code long} (by casting to type {@code long}).
+ *
+ * @return the {@code double} value represented by this object
+ * converted to type {@code long}
+ */
+ public long longValue() {
+ return (long)value;
+ }
+
+ /**
+ * Returns the {@code float} value of this
+ * {@code Double} object.
+ *
+ * @return the {@code double} value represented by this object
+ * converted to type {@code float}
+ * @since JDK1.0
+ */
+ public float floatValue() {
+ return (float)value;
+ }
+
+ /**
+ * Returns the {@code double} value of this
+ * {@code Double} object.
+ *
+ * @return the {@code double} value represented by this object
+ */
+ public double doubleValue() {
+ return (double)value;
+ }
+
+ /**
+ * Returns a hash code for this {@code Double} object. The
+ * result is the exclusive OR of the two halves of the
+ * {@code long} integer bit representation, exactly as
+ * produced by the method {@link #doubleToLongBits(double)}, of
+ * the primitive {@code double} value represented by this
+ * {@code Double} object. That is, the hash code is the value
+ * of the expression:
+ *
+ * <blockquote>
+ * {@code (int)(v^(v>>>32))}
+ * </blockquote>
+ *
+ * where {@code v} is defined by:
+ *
+ * <blockquote>
+ * {@code long v = Double.doubleToLongBits(this.doubleValue());}
+ * </blockquote>
+ *
+ * @return a {@code hash code} value for this object.
+ */
+ public int hashCode() {
+ long bits = doubleToLongBits(value);
+ return (int)(bits ^ (bits >>> 32));
+ }
+
+ /**
+ * Compares this object against the specified object. The result
+ * is {@code true} if and only if the argument is not
+ * {@code null} and is a {@code Double} object that
+ * represents a {@code double} that has the same value as the
+ * {@code double} represented by this object. For this
+ * purpose, two {@code double} values are considered to be
+ * the same if and only if the method {@link
+ * #doubleToLongBits(double)} returns the identical
+ * {@code long} value when applied to each.
+ *
+ * <p>Note that in most cases, for two instances of class
+ * {@code Double}, {@code d1} and {@code d2}, the
+ * value of {@code d1.equals(d2)} is {@code true} if and
+ * only if
+ *
+ * <blockquote>
+ * {@code d1.doubleValue() == d2.doubleValue()}
+ * </blockquote>
+ *
+ * <p>also has the value {@code true}. However, there are two
+ * exceptions:
+ * <ul>
+ * <li>If {@code d1} and {@code d2} both represent
+ * {@code Double.NaN}, then the {@code equals} method
+ * returns {@code true}, even though
+ * {@code Double.NaN==Double.NaN} has the value
+ * {@code false}.
+ * <li>If {@code d1} represents {@code +0.0} while
+ * {@code d2} represents {@code -0.0}, or vice versa,
+ * the {@code equal} test has the value {@code false},
+ * even though {@code +0.0==-0.0} has the value {@code true}.
+ * </ul>
+ * This definition allows hash tables to operate properly.
+ * @param obj the object to compare with.
+ * @return {@code true} if the objects are the same;
+ * {@code false} otherwise.
+ * @see java.lang.Double#doubleToLongBits(double)
+ */
+ public boolean equals(Object obj) {
+ return (obj instanceof Double)
+ && (doubleToLongBits(((Double)obj).value) ==
+ doubleToLongBits(value));
+ }
+
+ /**
+ * Returns a representation of the specified floating-point value
+ * according to the IEEE 754 floating-point "double
+ * format" bit layout.
+ *
+ * <p>Bit 63 (the bit that is selected by the mask
+ * {@code 0x8000000000000000L}) represents the sign of the
+ * floating-point number. Bits
+ * 62-52 (the bits that are selected by the mask
+ * {@code 0x7ff0000000000000L}) represent the exponent. Bits 51-0
+ * (the bits that are selected by the mask
+ * {@code 0x000fffffffffffffL}) represent the significand
+ * (sometimes called the mantissa) of the floating-point number.
+ *
+ * <p>If the argument is positive infinity, the result is
+ * {@code 0x7ff0000000000000L}.
+ *
+ * <p>If the argument is negative infinity, the result is
+ * {@code 0xfff0000000000000L}.
+ *
+ * <p>If the argument is NaN, the result is
+ * {@code 0x7ff8000000000000L}.
+ *
+ * <p>In all cases, the result is a {@code long} integer that, when
+ * given to the {@link #longBitsToDouble(long)} method, will produce a
+ * floating-point value the same as the argument to
+ * {@code doubleToLongBits} (except all NaN values are
+ * collapsed to a single "canonical" NaN value).
+ *
+ * @param value a {@code double} precision floating-point number.
+ * @return the bits that represent the floating-point number.
+ */
+ public static long doubleToLongBits(double value) {
+ long result = doubleToRawLongBits(value);
+ // Check for NaN based on values of bit fields, maximum
+ // exponent and nonzero significand.
+ if ( ((result & DoubleConsts.EXP_BIT_MASK) ==
+ DoubleConsts.EXP_BIT_MASK) &&
+ (result & DoubleConsts.SIGNIF_BIT_MASK) != 0L)
+ result = 0x7ff8000000000000L;
+ return result;
+ }
+
+ /**
+ * Returns a representation of the specified floating-point value
+ * according to the IEEE 754 floating-point "double
+ * format" bit layout, preserving Not-a-Number (NaN) values.
+ *
+ * <p>Bit 63 (the bit that is selected by the mask
+ * {@code 0x8000000000000000L}) represents the sign of the
+ * floating-point number. Bits
+ * 62-52 (the bits that are selected by the mask
+ * {@code 0x7ff0000000000000L}) represent the exponent. Bits 51-0
+ * (the bits that are selected by the mask
+ * {@code 0x000fffffffffffffL}) represent the significand
+ * (sometimes called the mantissa) of the floating-point number.
+ *
+ * <p>If the argument is positive infinity, the result is
+ * {@code 0x7ff0000000000000L}.
+ *
+ * <p>If the argument is negative infinity, the result is
+ * {@code 0xfff0000000000000L}.
+ *
+ * <p>If the argument is NaN, the result is the {@code long}
+ * integer representing the actual NaN value. Unlike the
+ * {@code doubleToLongBits} method,
+ * {@code doubleToRawLongBits} does not collapse all the bit
+ * patterns encoding a NaN to a single "canonical" NaN
+ * value.
+ *
+ * <p>In all cases, the result is a {@code long} integer that,
+ * when given to the {@link #longBitsToDouble(long)} method, will
+ * produce a floating-point value the same as the argument to
+ * {@code doubleToRawLongBits}.
+ *
+ * @param value a {@code double} precision floating-point number.
+ * @return the bits that represent the floating-point number.
+ * @since 1.3
+ */
+ public static native long doubleToRawLongBits(double value);
+
+ /**
+ * Returns the {@code double} value corresponding to a given
+ * bit representation.
+ * The argument is considered to be a representation of a
+ * floating-point value according to the IEEE 754 floating-point
+ * "double format" bit layout.
+ *
+ * <p>If the argument is {@code 0x7ff0000000000000L}, the result
+ * is positive infinity.
+ *
+ * <p>If the argument is {@code 0xfff0000000000000L}, the result
+ * is negative infinity.
+ *
+ * <p>If the argument is any value in the range
+ * {@code 0x7ff0000000000001L} through
+ * {@code 0x7fffffffffffffffL} or in the range
+ * {@code 0xfff0000000000001L} through
+ * {@code 0xffffffffffffffffL}, the result is a NaN. No IEEE
+ * 754 floating-point operation provided by Java can distinguish
+ * between two NaN values of the same type with different bit
+ * patterns. Distinct values of NaN are only distinguishable by
+ * use of the {@code Double.doubleToRawLongBits} method.
+ *
+ * <p>In all other cases, let <i>s</i>, <i>e</i>, and <i>m</i> be three
+ * values that can be computed from the argument:
+ *
+ * <blockquote><pre>
+ * int s = ((bits >> 63) == 0) ? 1 : -1;
+ * int e = (int)((bits >> 52) & 0x7ffL);
+ * long m = (e == 0) ?
+ * (bits & 0xfffffffffffffL) << 1 :
+ * (bits & 0xfffffffffffffL) | 0x10000000000000L;
+ * </pre></blockquote>
+ *
+ * Then the floating-point result equals the value of the mathematical
+ * expression <i>s</i>·<i>m</i>·2<sup><i>e</i>-1075</sup>.
+ *
+ * <p>Note that this method may not be able to return a
+ * {@code double} NaN with exactly same bit pattern as the
+ * {@code long} argument. IEEE 754 distinguishes between two
+ * kinds of NaNs, quiet NaNs and <i>signaling NaNs</i>. The
+ * differences between the two kinds of NaN are generally not
+ * visible in Java. Arithmetic operations on signaling NaNs turn
+ * them into quiet NaNs with a different, but often similar, bit
+ * pattern. However, on some processors merely copying a
+ * signaling NaN also performs that conversion. In particular,
+ * copying a signaling NaN to return it to the calling method
+ * may perform this conversion. So {@code longBitsToDouble}
+ * may not be able to return a {@code double} with a
+ * signaling NaN bit pattern. Consequently, for some
+ * {@code long} values,
+ * {@code doubleToRawLongBits(longBitsToDouble(start))} may
+ * <i>not</i> equal {@code start}. Moreover, which
+ * particular bit patterns represent signaling NaNs is platform
+ * dependent; although all NaN bit patterns, quiet or signaling,
+ * must be in the NaN range identified above.
+ *
+ * @param bits any {@code long} integer.
+ * @return the {@code double} floating-point value with the same
+ * bit pattern.
+ */
+ public static native double longBitsToDouble(long bits);
+
+ /**
+ * Compares two {@code Double} objects numerically. There
+ * are two ways in which comparisons performed by this method
+ * differ from those performed by the Java language numerical
+ * comparison operators ({@code <, <=, ==, >=, >})
+ * when applied to primitive {@code double} values:
+ * <ul><li>
+ * {@code Double.NaN} is considered by this method
+ * to be equal to itself and greater than all other
+ * {@code double} values (including
+ * {@code Double.POSITIVE_INFINITY}).
+ * <li>
+ * {@code 0.0d} is considered by this method to be greater
+ * than {@code -0.0d}.
+ * </ul>
+ * This ensures that the <i>natural ordering</i> of
+ * {@code Double} objects imposed by this method is <i>consistent
+ * with equals</i>.
+ *
+ * @param anotherDouble the {@code Double} to be compared.
+ * @return the value {@code 0} if {@code anotherDouble} is
+ * numerically equal to this {@code Double}; a value
+ * less than {@code 0} if this {@code Double}
+ * is numerically less than {@code anotherDouble};
+ * and a value greater than {@code 0} if this
+ * {@code Double} is numerically greater than
+ * {@code anotherDouble}.
+ *
+ * @since 1.2
+ */
+ public int compareTo(Double anotherDouble) {
+ return Double.compare(value, anotherDouble.value);
+ }
+
+ /**
+ * Compares the two specified {@code double} values. The sign
+ * of the integer value returned is the same as that of the
+ * integer that would be returned by the call:
+ * <pre>
+ * new Double(d1).compareTo(new Double(d2))
+ * </pre>
+ *
+ * @param d1 the first {@code double} to compare
+ * @param d2 the second {@code double} to compare
+ * @return the value {@code 0} if {@code d1} is
+ * numerically equal to {@code d2}; a value less than
+ * {@code 0} if {@code d1} is numerically less than
+ * {@code d2}; and a value greater than {@code 0}
+ * if {@code d1} is numerically greater than
+ * {@code d2}.
+ * @since 1.4
+ */
+ public static int compare(double d1, double d2) {
+ if (d1 < d2)
+ return -1; // Neither val is NaN, thisVal is smaller
+ if (d1 > d2)
+ return 1; // Neither val is NaN, thisVal is larger
+
+ long thisBits = Double.doubleToLongBits(d1);
+ long anotherBits = Double.doubleToLongBits(d2);
+
+ return (thisBits == anotherBits ? 0 : // Values are equal
+ (thisBits < anotherBits ? -1 : // (-0.0, 0.0) or (!NaN, NaN)
+ 1)); // (0.0, -0.0) or (NaN, !NaN)
+ }
+
+ /** use serialVersionUID from JDK 1.0.2 for interoperability */
+ private static final long serialVersionUID = -9172774392245257468L;
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2007-05-13 17:01:28
|
Revision: 3192
http://jnode.svn.sourceforge.net/jnode/?rev=3192&view=rev
Author: lsantha
Date: 2007-05-13 10:01:27 -0700 (Sun, 13 May 2007)
Log Message:
-----------
First merges of OpenJDK.
Modified Paths:
--------------
trunk/core/build.xml
Modified: trunk/core/build.xml
===================================================================
--- trunk/core/build.xml 2007-05-13 16:54:14 UTC (rev 3191)
+++ trunk/core/build.xml 2007-05-13 17:01:27 UTC (rev 3192)
@@ -26,6 +26,9 @@
<pathelement location="${my-src.dir}/classpath/ext"/>
<pathelement location="${my-src.dir}/classpath/vm"/>
<pathelement location="${my-src.dir}/classpath/tools"/>
+ <pathelement location="${my-src.dir}/openjdk/java"/>
+ <pathelement location="${my-src.dir}/openjdk/javax"/>
+ <pathelement location="${my-src.dir}/openjdk/sun"/>
</path>
<path id="my-sources1">
<path refid="classpath-sources"/>
@@ -92,6 +95,9 @@
<fileset dir="${my-src.dir}/classpath/java" includes="**/*.properties"/>
<fileset dir="${my-src.dir}/classpath/vm" includes="**/*.security"/>
<fileset dir="${my-src.dir}/classpath/tools" includes="**/*.jav"/>
+ <fileset dir="${my-src.dir}/openjdk/java" includes="**/*.jav"/>
+ <fileset dir="${my-src.dir}/openjdk/javax" includes="**/*.jav"/>
+ <fileset dir="${my-src.dir}/openjdk/sun" includes="**/*.jav"/>
</copy>
<ExpandTest classname="PrimitiveIntTest" type="int"/>
<ExpandTest classname="PrimitiveLongTest" type="long"/>
@@ -118,6 +124,9 @@
<fileset dir="${my-src.dir}/classpath/ext" excludes="${my-non-resources}"/>
<fileset dir="${my-src.dir}/classpath/vm" excludes="${my-non-resources}"/>
<fileset dir="${my-src.dir}/classpath/tools" excludes="${my-non-resources}"/>
+ <fileset dir="${my-src.dir}/openjdk/java" excludes="${my-non-resources}"/>
+ <fileset dir="${my-src.dir}/openjdk/javax" excludes="${my-non-resources}"/>
+ <fileset dir="${my-src.dir}/openjdk/sun" excludes="${my-non-resources}"/>
<fileset dir="${my-src.dir}/core" excludes="${my-non-resources}"/>
<fileset dir="${my-src.dir}/nanoxml" excludes="${my-non-resources}"/>
<fileset dir="${my-src.dir}/vmmagic" excludes="${my-non-resources}"/>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2007-05-13 16:54:16
|
Revision: 3191
http://jnode.svn.sourceforge.net/jnode/?rev=3191&view=rev
Author: lsantha
Date: 2007-05-13 09:54:14 -0700 (Sun, 13 May 2007)
Log Message:
-----------
First portions of OpenJDK.
Removed Paths:
-------------
trunk/core/src/classpath/java/java/util/regex/MatchResult.java
trunk/core/src/classpath/java/java/util/regex/Matcher.java
trunk/core/src/classpath/java/java/util/regex/Pattern.java
trunk/core/src/classpath/java/java/util/regex/PatternSyntaxException.java
trunk/core/src/classpath/java/java/util/regex/package.html
Deleted: trunk/core/src/classpath/java/java/util/regex/MatchResult.java
===================================================================
--- trunk/core/src/classpath/java/java/util/regex/MatchResult.java 2007-05-13 16:52:35 UTC (rev 3190)
+++ trunk/core/src/classpath/java/java/util/regex/MatchResult.java 2007-05-13 16:54:14 UTC (rev 3191)
@@ -1,81 +0,0 @@
-/* MatchResult.java -- Result of a regular expression match.
- Copyright (C) 2006 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package java.util.regex;
-
-/**
- * This interface represents the result of a regular expression match.
- * It can be used to query the contents of the match, but not to modify
- * them.
- * @since 1.5
- */
-public interface MatchResult
-{
- /** Returns the index just after the last matched character. */
- int end();
-
- /**
- * Returns the index just after the last matched character of the
- * given sub-match group.
- * @param group the sub-match group
- */
- int end(int group);
-
- /** Returns the substring of the input which was matched. */
- String group();
-
- /**
- * Returns the substring of the input which was matched by the
- * given sub-match group.
- * @param group the sub-match group
- */
- String group(int group);
-
- /** Returns the number of sub-match groups in the matching pattern. */
- int groupCount();
-
- /** Returns the index of the first character of the match. */
- int start();
-
- /**
- * Returns the index of the first character of the given sub-match
- * group.
- * @param group the sub-match group
- */
- int start(int group);
-}
Deleted: trunk/core/src/classpath/java/java/util/regex/Matcher.java
===================================================================
--- trunk/core/src/classpath/java/java/util/regex/Matcher.java 2007-05-13 16:52:35 UTC (rev 3190)
+++ trunk/core/src/classpath/java/java/util/regex/Matcher.java 2007-05-13 16:54:14 UTC (rev 3191)
@@ -1,339 +0,0 @@
-/* Matcher.java -- Instance of a regular expression applied to a char sequence.
- Copyright (C) 2002, 2004, 2006 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package java.util.regex;
-
-import gnu.java.util.regex.CharIndexed;
-import gnu.java.util.regex.RE;
-import gnu.java.util.regex.REMatch;
-
-/**
- * Instance of a regular expression applied to a char sequence.
- *
- * @since 1.4
- */
-public final class Matcher implements MatchResult
-{
- private Pattern pattern;
- private CharSequence input;
- // We use CharIndexed as an input object to the getMatch method in order
- // that /\G/ (the end of the previous match) may work. The information
- // of the previous match is stored in the CharIndexed object.
- private CharIndexed inputCharIndexed;
- private int position;
- private int appendPosition;
- private REMatch match;
-
- Matcher(Pattern pattern, CharSequence input)
- {
- this.pattern = pattern;
- this.input = input;
- this.inputCharIndexed = RE.makeCharIndexed(input, 0);
- }
-
- /**
- * @param sb The target string buffer
- * @param replacement The replacement string
- *
- * @exception IllegalStateException If no match has yet been attempted,
- * or if the previous match operation failed
- * @exception IndexOutOfBoundsException If the replacement string refers
- * to a capturing group that does not exist in the pattern
- */
- public Matcher appendReplacement (StringBuffer sb, String replacement)
- throws IllegalStateException
- {
- assertMatchOp();
- sb.append(input.subSequence(appendPosition,
- match.getStartIndex()).toString());
- sb.append(RE.getReplacement(replacement, match,
- RE.REG_REPLACE_USE_BACKSLASHESCAPE));
- appendPosition = match.getEndIndex();
- return this;
- }
-
- /**
- * @param sb The target string buffer
- */
- public StringBuffer appendTail (StringBuffer sb)
- {
- sb.append(input.subSequence(appendPosition, input.length()).toString());
- return sb;
- }
-
- /**
- * @exception IllegalStateException If no match has yet been attempted,
- * or if the previous match operation failed
- */
- public int end ()
- throws IllegalStateException
- {
- assertMatchOp();
- return match.getEndIndex();
- }
-
- /**
- * @param group The index of a capturing group in this matcher's pattern
- *
- * @exception IllegalStateException If no match has yet been attempted,
- * or if the previous match operation failed
- * @exception IndexOutOfBoundsException If the replacement string refers
- * to a capturing group that does not exist in the pattern
- */
- public int end (int group)
- throws IllegalStateException
- {
- assertMatchOp();
- return match.getEndIndex(group);
- }
-
- public boolean find ()
- {
- boolean first = (match == null);
- match = pattern.getRE().getMatch(inputCharIndexed, position);
- if (match != null)
- {
- int endIndex = match.getEndIndex();
- // Are we stuck at the same position?
- if (!first && endIndex == position)
- {
- match = null;
- // Not at the end of the input yet?
- if (position < input.length() - 1)
- {
- position++;
- return find(position);
- }
- else
- return false;
- }
- position = endIndex;
- return true;
- }
- return false;
- }
-
- /**
- * @param start The index to start the new pattern matching
- *
- * @exception IndexOutOfBoundsException If the replacement string refers
- * to a capturing group that does not exist in the pattern
- */
- public boolean find (int start)
- {
- match = pattern.getRE().getMatch(inputCharIndexed, start);
- if (match != null)
- {
- position = match.getEndIndex();
- return true;
- }
- return false;
- }
-
- /**
- * @exception IllegalStateException If no match has yet been attempted,
- * or if the previous match operation failed
- */
- public String group ()
- {
- assertMatchOp();
- return match.toString();
- }
-
- /**
- * @param group The index of a capturing group in this matcher's pattern
- *
- * @exception IllegalStateException If no match has yet been attempted,
- * or if the previous match operation failed
- * @exception IndexOutOfBoundsException If the replacement string refers
- * to a capturing group that does not exist in the pattern
- */
- public String group (int group)
- throws IllegalStateException
- {
- assertMatchOp();
- return match.toString(group);
- }
-
- /**
- * @param replacement The replacement string
- */
- public String replaceFirst (String replacement)
- {
- reset();
- // Semantics might not quite match
- return pattern.getRE().substitute(input, replacement, position,
- RE.REG_REPLACE_USE_BACKSLASHESCAPE);
- }
-
- /**
- * @param replacement The replacement string
- */
- public String replaceAll (String replacement)
- {
- reset();
- return pattern.getRE().substituteAll(input, replacement, position,
- RE.REG_REPLACE_USE_BACKSLASHESCAPE);
- }
-
- public int groupCount ()
- {
- return pattern.getRE().getNumSubs();
- }
-
- public boolean lookingAt ()
- {
- match = pattern.getRE().getMatch(inputCharIndexed, 0, RE.REG_FIX_STARTING_POSITION, null);
- if (match != null)
- {
- if (match.getStartIndex() == 0)
- {
- position = match.getEndIndex();
- return true;
- }
- match = null;
- }
- return false;
- }
-
- /**
- * Attempts to match the entire input sequence against the pattern.
- *
- * If the match succeeds then more information can be obtained via the
- * start, end, and group methods.
- *
- * @see #start()
- * @see #end()
- * @see #group()
- */
- public boolean matches ()
- {
- match = pattern.getRE().getMatch(inputCharIndexed, 0, RE.REG_TRY_ENTIRE_MATCH|RE.REG_FIX_STARTING_POSITION, null);
- if (match != null)
- {
- if (match.getStartIndex() == 0)
- {
- position = match.getEndIndex();
- if (position == input.length())
- return true;
- }
- match = null;
- }
- return false;
- }
-
- /**
- * Returns the Pattern that is interpreted by this Matcher
- */
- public Pattern pattern ()
- {
- return pattern;
- }
-
- public Matcher reset ()
- {
- position = 0;
- match = null;
- return this;
- }
-
- /**
- * @param input The new input character sequence
- */
- public Matcher reset (CharSequence input)
- {
- this.input = input;
- this.inputCharIndexed = RE.makeCharIndexed(input, 0);
- return reset();
- }
-
- /**
- * @returns the index of a capturing group in this matcher's pattern
- *
- * @exception IllegalStateException If no match has yet been attempted,
- * or if the previous match operation failed
- */
- public int start ()
- throws IllegalStateException
- {
- assertMatchOp();
- return match.getStartIndex();
- }
-
- /**
- * @param group The index of a capturing group in this matcher's pattern
- *
- * @exception IllegalStateException If no match has yet been attempted,
- * or if the previous match operation failed
- * @exception IndexOutOfBoundsException If the replacement string refers
- * to a capturing group that does not exist in the pattern
- */
- public int start (int group)
- throws IllegalStateException
- {
- assertMatchOp();
- return match.getStartIndex(group);
- }
-
- /**
- * @return True if and only if the matcher hit the end of input.
- */
- public boolean hitEnd()
- {
- return inputCharIndexed.hitEnd();
- }
-
- /**
- * @return A string expression of this matcher.
- */
- public String toString()
- {
- StringBuilder sb = new StringBuilder();
- sb.append(this.getClass().getName())
- .append("[pattern=").append(pattern.pattern())
- .append(" region=").append("0").append(",").append(input.length())
- .append(" lastmatch=").append(match == null ? "" : match.toString())
- .append("]");
- return sb.toString();
- }
-
- private void assertMatchOp()
- {
- if (match == null) throw new IllegalStateException();
- }
-}
Deleted: trunk/core/src/classpath/java/java/util/regex/Pattern.java
===================================================================
--- trunk/core/src/classpath/java/java/util/regex/Pattern.java 2007-05-13 16:52:35 UTC (rev 3190)
+++ trunk/core/src/classpath/java/java/util/regex/Pattern.java 2007-05-13 16:54:14 UTC (rev 3191)
@@ -1,263 +0,0 @@
-/* Pattern.java -- Compiled regular expression ready to be applied.
- Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-package java.util.regex;
-
-import gnu.java.util.regex.RE;
-import gnu.java.util.regex.REException;
-import gnu.java.util.regex.RESyntax;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-
-
-/**
- * Compiled regular expression ready to be applied.
- *
- * @since 1.4
- */
-public final class Pattern implements Serializable
-{
- private static final long serialVersionUID = 5073258162644648461L;
-
- public static final int CANON_EQ = 128;
- public static final int CASE_INSENSITIVE = 2;
- public static final int COMMENTS = 4;
- public static final int DOTALL = 32;
- public static final int MULTILINE = 8;
- public static final int UNICODE_CASE = 64;
- public static final int UNIX_LINES = 1;
-
- private final String regex;
- private final int flags;
-
- private final RE re;
-
- private Pattern (String regex, int flags)
- throws PatternSyntaxException
- {
- this.regex = regex;
- this.flags = flags;
-
- RESyntax syntax = RESyntax.RE_SYNTAX_JAVA_1_4;
- int gnuFlags = 0;
- gnuFlags |= RE.REG_ICASE_USASCII;
- if ((flags & CASE_INSENSITIVE) != 0)
- gnuFlags |= RE.REG_ICASE;
- if ((flags & MULTILINE) != 0)
- {
- gnuFlags |= RE.REG_MULTILINE;
- syntax = new RESyntax(syntax);
- syntax.setLineSeparator(null);
- }
- if ((flags & DOTALL) != 0)
- gnuFlags |= RE.REG_DOT_NEWLINE;
- if ((flags & UNICODE_CASE) != 0)
- gnuFlags &= ~RE.REG_ICASE_USASCII;
- // not yet supported:
- // if ((flags & CANON_EQ) != 0) gnuFlags =
-
- if ((flags & UNIX_LINES) != 0)
- {
- // Use a syntax set with \n for linefeeds?
- syntax = new RESyntax(syntax);
- syntax.setLineSeparator("\n");
- }
-
- if ((flags & COMMENTS) != 0)
- {
- gnuFlags |= RE.REG_X_COMMENTS;
- }
-
- try
- {
- this.re = new RE(regex, gnuFlags, syntax);
- }
- catch (REException e)
- {
- PatternSyntaxException pse;
- pse = new PatternSyntaxException(e.getMessage(),
- regex, e.getPosition());
- pse.initCause(e);
- throw pse;
- }
- }
-
- // package private accessor method
- RE getRE()
- {
- return re;
- }
-
- /**
- * @param regex The regular expression
- *
- * @exception PatternSyntaxException If the expression's syntax is invalid
- */
- public static Pattern compile (String regex)
- throws PatternSyntaxException
- {
- return compile(regex, 0);
- }
-
- /**
- * @param regex The regular expression
- * @param flags The match flags, a bit mask
- *
- * @exception PatternSyntaxException If the expression's syntax is invalid
- * @exception IllegalArgumentException If bit values other than those
- * corresponding to the defined match flags are set in flags
- */
- public static Pattern compile (String regex, int flags)
- throws PatternSyntaxException
- {
- // FIXME: check which flags are really accepted
- if ((flags & ~0xEF) != 0)
- throw new IllegalArgumentException ();
-
- return new Pattern (regex, flags);
- }
-
- public int flags ()
- {
- return this.flags;
- }
-
- /**
- * @param regex The regular expression
- * @param input The character sequence to be matched
- *
- * @exception PatternSyntaxException If the expression's syntax is invalid
- */
- public static boolean matches (String regex, CharSequence input)
- {
- return compile(regex).matcher(input).matches();
- }
-
- /**
- * @param input The character sequence to be matched
- */
- public Matcher matcher (CharSequence input)
- {
- return new Matcher(this, input);
- }
-
- /**
- * @param input The character sequence to be matched
- */
- public String[] split (CharSequence input)
- {
- return split(input, 0);
- }
-
- /**
- * @param input The character sequence to be matched
- * @param limit The result threshold
- */
- public String[] split (CharSequence input, int limit)
- {
- Matcher matcher = new Matcher(this, input);
- ArrayList list = new ArrayList();
- int empties = 0;
- int count = 0;
- int start = 0;
- int end;
- boolean matched = matcher.find();
-
- while (matched && (limit <= 0 || count < limit - 1))
- {
- ++count;
- end = matcher.start();
- if (start == end)
- empties++;
- else
- {
- while (empties > 0)
- {
- list.add("");
- empties--;
- }
-
- String text = input.subSequence(start, end).toString();
- list.add(text);
- }
- start = matcher.end();
- matched = matcher.find();
- }
-
- // We matched nothing.
- if (!matched && count == 0)
- return new String[] { input.toString() };
-
- // Is the last token empty?
- boolean emptyLast = (start == input.length());
-
- // Can/Must we add empties or an extra last token at the end?
- if (list.size() < limit || limit < 0 || (limit == 0 && !emptyLast))
- {
- if (limit > list.size())
- {
- int max = limit - list.size();
- empties = (empties > max) ? max : empties;
- }
- while (empties > 0)
- {
- list.add("");
- empties--;
- }
- }
-
- // last token at end
- if (limit != 0 || (limit == 0 && !emptyLast))
- {
- String t = input.subSequence(start, input.length()).toString();
- if ("".equals(t) && limit == 0)
- { /* Don't add. */ }
- else
- list.add(t);
- }
-
- String[] output = new String [list.size()];
- list.toArray(output);
- return output;
- }
-
- public String pattern ()
- {
- return regex;
- }
-}
Deleted: trunk/core/src/classpath/java/java/util/regex/PatternSyntaxException.java
===================================================================
--- trunk/core/src/classpath/java/java/util/regex/PatternSyntaxException.java 2007-05-13 16:52:35 UTC (rev 3190)
+++ trunk/core/src/classpath/java/java/util/regex/PatternSyntaxException.java 2007-05-13 16:54:14 UTC (rev 3191)
@@ -1,133 +0,0 @@
-/* PatternSyntaxException - Indicates illegal pattern for regular expression.
- Copyright (C) 2002 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-package java.util.regex;
-
-/**
- * Indicates illegal pattern for regular expression.
- * Includes state to inspect the pattern and what and where the expression
- * was not valid regular expression.
- * @since 1.4
- */
-public class PatternSyntaxException extends IllegalArgumentException
-{
- private static final long serialVersionUID = -3864639126226059218L;
-
- /**
- * Human readable escription of the syntax error.
- */
- private final String desc;
-
- /**
- * The original pattern that contained the syntax error.
- */
- private final String pattern;
-
- /**
- * Index of the first character in the String that was probably invalid,
- * or -1 when unknown.
- */
- private final int index;
-
- /**
- * Creates a new PatternSyntaxException.
- *
- * @param description Human readable escription of the syntax error.
- * @param pattern The original pattern that contained the syntax error.
- * @param index Index of the first character in the String that was
- * probably invalid, or -1 when unknown.
- */
- public PatternSyntaxException(String description,
- String pattern,
- int index)
- {
- super(description);
- this.desc = description;
- this.pattern = pattern;
- this.index = index;
- }
-
- /**
- * Returns a human readable escription of the syntax error.
- */
- public String getDescription()
- {
- return desc;
- }
-
- /**
- * Returns the original pattern that contained the syntax error.
- */
- public String getPattern()
- {
- return pattern;
- }
-
- /**
- * Returns the index of the first character in the String that was probably
- * invalid, or -1 when unknown.
- */
- public int getIndex()
- {
- return index;
- }
-
- /**
- * Returns a string containing a line with the description, a line with
- * the original pattern and a line indicating with a ^ which character is
- * probably the first invalid character in the pattern if the index is not
- * negative.
- */
- public String getMessage()
- {
- String lineSep = System.getProperty("line.separator");
- StringBuffer sb = new StringBuffer(desc);
- sb.append(lineSep);
- sb.append('\t');
- sb.append(pattern);
- if (index != -1)
- {
- sb.append(lineSep);
- sb.append('\t');
- for (int i=0; i<index; i++)
- sb.append(' ');
- sb.append('^');
- }
- return sb.toString();
- }
-
-}
Deleted: trunk/core/src/classpath/java/java/util/regex/package.html
===================================================================
--- trunk/core/src/classpath/java/java/util/regex/package.html 2007-05-13 16:52:35 UTC (rev 3190)
+++ trunk/core/src/classpath/java/java/util/regex/package.html 2007-05-13 16:54:14 UTC (rev 3191)
@@ -1,46 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<!-- package.html - describes classes in java.util.regex package.
- Copyright (C) 2002 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. -->
-
-<html>
-<head><title>GNU Classpath - java.util.regex</title></head>
-
-<body>
-<p>Regular expression patterns and matchers.</p>
-
-</body>
-</html>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2007-05-13 16:52:36
|
Revision: 3190
http://jnode.svn.sourceforge.net/jnode/?rev=3190&view=rev
Author: lsantha
Date: 2007-05-13 09:52:35 -0700 (Sun, 13 May 2007)
Log Message:
-----------
First portions of OpenJDK.
Modified Paths:
--------------
trunk/core/src/classpath/vm/java/lang/Class.java
Added Paths:
-----------
trunk/core/src/classpath/vm/java/lang/NativeDouble.java
Modified: trunk/core/src/classpath/vm/java/lang/Class.java
===================================================================
--- trunk/core/src/classpath/vm/java/lang/Class.java 2007-05-13 16:51:36 UTC (rev 3189)
+++ trunk/core/src/classpath/vm/java/lang/Class.java 2007-05-13 16:52:35 UTC (rev 3190)
@@ -1039,6 +1039,36 @@
}
/**
+ * Gets a primitive class of a given type.
+ *
+ * @param type
+ * @return
+ * @see VmType#getPrimitiveClass(char)
+ */
+ static Class getPrimitiveClass(String type) {
+ if(type.equals("double"))
+ return getPrimitiveClass('D');
+ else if(type.equals("float"))
+ return getPrimitiveClass('F');
+ else if(type.equals("boolean"))
+ return getPrimitiveClass('Z');
+ else if(type.equals("byte"))
+ return getPrimitiveClass('B');
+ else if(type.equals("char"))
+ return getPrimitiveClass('C');
+ else if(type.equals("short"))
+ return getPrimitiveClass('S');
+ else if(type.equals("int"))
+ return getPrimitiveClass('I');
+ else if(type.equals("long"))
+ return getPrimitiveClass('J');
+ else if(type.equals("void"))
+ return getPrimitiveClass('V');
+ else
+ throw new IllegalArgumentException("Unknown type " + type);
+ }
+
+ /**
* Returns the enumeration constants of this class, or null if this class is
* not an <code>Enum</code>.
*
Added: trunk/core/src/classpath/vm/java/lang/NativeDouble.java
===================================================================
--- trunk/core/src/classpath/vm/java/lang/NativeDouble.java (rev 0)
+++ trunk/core/src/classpath/vm/java/lang/NativeDouble.java 2007-05-13 16:52:35 UTC (rev 3190)
@@ -0,0 +1,47 @@
+/*
+ * $Id$
+ */
+package java.lang;
+
+import org.jnode.vm.VmMagic;
+
+/**
+ * @author Levente S\xE1ntha
+ */
+public class NativeDouble {
+ /**
+ * Convert the double to the IEEE 754 floating-point "double format" bit
+ * layout. Bit 63 (the most significant) is the sign bit, bits 62-52 (masked
+ * by 0x7ff0000000000000L) represent the exponent, and bits 51-0 (masked by
+ * 0x000fffffffffffffL) are the mantissa. This function leaves NaN alone,
+ * rather than collapsing to a canonical value. The result of this function
+ * can be used as the argument to <code>Double.longBitsToDouble(long)</code>
+ * to obtain the original <code>double</code> value.
+ *
+ * @param value
+ * the <code>double</code> to convert
+ * @return the bits of the <code>double</code>
+ * @see java.lang.Double#longBitsToDouble(long)
+ */
+ public static long doubleToRawLongBits(double value) {
+ return VmMagic.doubleToRawLongBits(value);
+ }
+
+ /**
+ * Convert the argument in IEEE 754 floating-point "double format" bit
+ * layout to the corresponding float. Bit 63 (the most significant) is the
+ * sign bit, bits 62-52 (masked by 0x7ff0000000000000L) represent the
+ * exponent, and bits 51-0 (masked by 0x000fffffffffffffL) are the mantissa.
+ * This function leaves NaN alone, so that you can recover the bit pattern
+ * with <code>Double.doubleToRawLongBits(double)</code>.
+ *
+ * @param bits
+ * the bits to convert
+ * @return the <code>double</code> represented by the bits
+ * @see java.lang.Double#doubleToLongBits(double)
+ * @see #doubleToRawLongBits(double)
+ */
+ public static double longBitsToDouble(long bits) {
+ return VmMagic.longBitsToDouble(bits);
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2007-05-13 16:51:38
|
Revision: 3189
http://jnode.svn.sourceforge.net/jnode/?rev=3189&view=rev
Author: lsantha
Date: 2007-05-13 09:51:36 -0700 (Sun, 13 May 2007)
Log Message:
-----------
First portions of OpenJDK.
Removed Paths:
-------------
trunk/core/src/classpath/java/java/lang/Double.java
Deleted: trunk/core/src/classpath/java/java/lang/Double.java
===================================================================
--- trunk/core/src/classpath/java/java/lang/Double.java 2007-05-12 10:29:55 UTC (rev 3188)
+++ trunk/core/src/classpath/java/java/lang/Double.java 2007-05-13 16:51:36 UTC (rev 3189)
@@ -1,602 +0,0 @@
-/* Double.java -- object wrapper for double
- Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
- Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-package java.lang;
-
-
-/**
- * Instances of class <code>Double</code> represent primitive
- * <code>double</code> values.
- *
- * Additionally, this class provides various helper functions and variables
- * related to doubles.
- *
- * @author Paul Fisher
- * @author Andrew Haley (ap...@cy...)
- * @author Eric Blake (eb...@em...)
- * @author Tom Tromey (tr...@re...)
- * @author Andrew John Hughes (gnu...@me...)
- * @since 1.0
- * @status partly updated to 1.5
- */
-public final class Double extends Number implements Comparable<Double>
-{
- /**
- * Compatible with JDK 1.0+.
- */
- private static final long serialVersionUID = -9172774392245257468L;
-
- /**
- * The maximum positive value a <code>double</code> may represent
- * is 1.7976931348623157e+308.
- */
- public static final double MAX_VALUE = 1.7976931348623157e+308;
-
- /**
- * The minimum positive value a <code>double</code> may represent
- * is 5e-324.
- */
- public static final double MIN_VALUE = 5e-324;
-
- /**
- * The value of a double representation -1.0/0.0, negative
- * infinity.
- */
- public static final double NEGATIVE_INFINITY = -1.0 / 0.0;
-
- /**
- * The value of a double representing 1.0/0.0, positive infinity.
- */
- public static final double POSITIVE_INFINITY = 1.0 / 0.0;
-
- /**
- * All IEEE 754 values of NaN have the same value in Java.
- */
- public static final double NaN = 0.0 / 0.0;
-
- /**
- * The number of bits needed to represent a <code>double</code>.
- * @since 1.5
- */
- public static final int SIZE = 64;
-
- /**
- * The primitive type <code>double</code> is represented by this
- * <code>Class</code> object.
- * @since 1.1
- */
- public static final Class<Double> TYPE = (Class<Double>) VMClassLoader.getPrimitiveClass('D');
-
- /**
- * The immutable value of this Double.
- *
- * @serial the wrapped double
- */
- private final double value;
-
- /**
- * Create a <code>Double</code> from the primitive <code>double</code>
- * specified.
- *
- * @param value the <code>double</code> argument
- */
- public Double(double value)
- {
- this.value = value;
- }
-
- /**
- * Create a <code>Double</code> from the specified <code>String</code>.
- * This method calls <code>Double.parseDouble()</code>.
- *
- * @param s the <code>String</code> to convert
- * @throws NumberFormatException if <code>s</code> cannot be parsed as a
- * <code>double</code>
- * @throws NullPointerException if <code>s</code> is null
- * @see #parseDouble(String)
- */
- public Double(String s)
- {
- value = parseDouble(s);
- }
-
- /**
- * Convert the <code>double</code> to a <code>String</code>.
- * Floating-point string representation is fairly complex: here is a
- * rundown of the possible values. "<code>[-]</code>" indicates that a
- * negative sign will be printed if the value (or exponent) is negative.
- * "<code><number></code>" means a string of digits ('0' to '9').
- * "<code><digit></code>" means a single digit ('0' to '9').<br>
- *
- * <table border=1>
- * <tr><th>Value of Double</th><th>String Representation</th></tr>
- * <tr><td>[+-] 0</td> <td><code>[-]0.0</code></td></tr>
- * <tr><td>Between [+-] 10<sup>-3</sup> and 10<sup>7</sup>, exclusive</td>
- * <td><code>[-]number.number</code></td></tr>
- * <tr><td>Other numeric value</td>
- * <td><code>[-]<digit>.<number>
- * E[-]<number></code></td></tr>
- * <tr><td>[+-] infinity</td> <td><code>[-]Infinity</code></td></tr>
- * <tr><td>NaN</td> <td><code>NaN</code></td></tr>
- * </table>
- *
- * Yes, negative zero <em>is</em> a possible value. Note that there is
- * <em>always</em> a <code>.</code> and at least one digit printed after
- * it: even if the number is 3, it will be printed as <code>3.0</code>.
- * After the ".", all digits will be printed except trailing zeros. The
- * result is rounded to the shortest decimal number which will parse back
- * to the same double.
- *
- * <p>To create other output formats, use {@link java.text.NumberFormat}.
- *
- * @XXX specify where we are not in accord with the spec.
- *
- * @param d the <code>double</code> to convert
- * @return the <code>String</code> representing the <code>double</code>
- */
- public static String toString(double d)
- {
- return VMDouble.toString(d, false);
- }
-
- /**
- * Convert a double value to a hexadecimal string. This converts as
- * follows:
- * <ul>
- * <li> A NaN value is converted to the string "NaN".
- * <li> Positive infinity is converted to the string "Infinity".
- * <li> Negative infinity is converted to the string "-Infinity".
- * <li> For all other values, the first character of the result is '-'
- * if the value is negative. This is followed by '0x1.' if the
- * value is normal, and '0x0.' if the value is denormal. This is
- * then followed by a (lower-case) hexadecimal representation of the
- * mantissa, with leading zeros as required for denormal values.
- * The next character is a 'p', and this is followed by a decimal
- * representation of the unbiased exponent.
- * </ul>
- * @param d the double value
- * @return the hexadecimal string representation
- * @since 1.5
- */
- public static String toHexString(double d)
- {
- if (isNaN(d))
- return "NaN";
- if (isInfinite(d))
- return d < 0 ? "-Infinity" : "Infinity";
-
- long bits = doubleToLongBits(d);
- StringBuilder result = new StringBuilder();
-
- if (bits < 0)
- result.append('-');
- result.append("0x");
-
- final int mantissaBits = 52;
- final int exponentBits = 11;
- long mantMask = (1L << mantissaBits) - 1;
- long mantissa = bits & mantMask;
- long expMask = (1L << exponentBits) - 1;
- long exponent = (bits >>> mantissaBits) & expMask;
-
- result.append(exponent == 0 ? '0' : '1');
- result.append('.');
- result.append(Long.toHexString(mantissa));
- if (exponent == 0 && mantissa != 0)
- {
- // Treat denormal specially by inserting '0's to make
- // the length come out right. The constants here are
- // to account for things like the '0x'.
- int offset = 4 + ((bits < 0) ? 1 : 0);
- // The silly +3 is here to keep the code the same between
- // the Float and Double cases. In Float the value is
- // not a multiple of 4.
- int desiredLength = offset + (mantissaBits + 3) / 4;
- while (result.length() < desiredLength)
- result.insert(offset, '0');
- }
- result.append('p');
- if (exponent == 0 && mantissa == 0)
- {
- // Zero, so do nothing special.
- }
- else
- {
- // Apply bias.
- boolean denormal = exponent == 0;
- exponent -= (1 << (exponentBits - 1)) - 1;
- // Handle denormal.
- if (denormal)
- ++exponent;
- }
-
- result.append(Long.toString(exponent));
- return result.toString();
- }
-
- /**
- * Returns a <code>Double</code> object wrapping the value.
- * In contrast to the <code>Double</code> constructor, this method
- * may cache some values. It is used by boxing conversion.
- *
- * @param val the value to wrap
- * @return the <code>Double</code>
- * @since 1.5
- */
- public static Double valueOf(double val)
- {
- // We don't actually cache, but we could.
- return new Double(val);
- }
-
- /**
- * Create a new <code>Double</code> object using the <code>String</code>.
- *
- * @param s the <code>String</code> to convert
- * @return the new <code>Double</code>
- * @throws NumberFormatException if <code>s</code> cannot be parsed as a
- * <code>double</code>
- * @throws NullPointerException if <code>s</code> is null.
- * @see #parseDouble(String)
- */
- public static Double valueOf(String s)
- {
- return new Double(parseDouble(s));
- }
-
- /**
- * Parse the specified <code>String</code> as a <code>double</code>. The
- * extended BNF grammar is as follows:<br>
- * <pre>
- * <em>DecodableString</em>:
- * ( [ <code>-</code> | <code>+</code> ] <code>NaN</code> )
- * | ( [ <code>-</code> | <code>+</code> ] <code>Infinity</code> )
- * | ( [ <code>-</code> | <code>+</code> ] <em>FloatingPoint</em>
- * [ <code>f</code> | <code>F</code> | <code>d</code>
- * | <code>D</code>] )
- * <em>FloatingPoint</em>:
- * ( { <em>Digit</em> }+ [ <code>.</code> { <em>Digit</em> } ]
- * [ <em>Exponent</em> ] )
- * | ( <code>.</code> { <em>Digit</em> }+ [ <em>Exponent</em> ] )
- * <em>Exponent</em>:
- * ( ( <code>e</code> | <code>E</code> )
- * [ <code>-</code> | <code>+</code> ] { <em>Digit</em> }+ )
- * <em>Digit</em>: <em><code>'0'</code> through <code>'9'</code></em>
- * </pre>
- *
- * <p>NaN and infinity are special cases, to allow parsing of the output
- * of toString. Otherwise, the result is determined by calculating
- * <em>n * 10<sup>exponent</sup></em> to infinite precision, then rounding
- * to the nearest double. Remember that many numbers cannot be precisely
- * represented in floating point. In case of overflow, infinity is used,
- * and in case of underflow, signed zero is used. Unlike Integer.parseInt,
- * this does not accept Unicode digits outside the ASCII range.
- *
- * <p>If an unexpected character is found in the <code>String</code>, a
- * <code>NumberFormatException</code> will be thrown. Leading and trailing
- * 'whitespace' is ignored via <code>String.trim()</code>, but spaces
- * internal to the actual number are not allowed.
- *
- * <p>To parse numbers according to another format, consider using
- * {@link java.text.NumberFormat}.
- *
- * @XXX specify where/how we are not in accord with the spec.
- *
- * @param str the <code>String</code> to convert
- * @return the <code>double</code> value of <code>s</code>
- * @throws NumberFormatException if <code>s</code> cannot be parsed as a
- * <code>double</code>
- * @throws NullPointerException if <code>s</code> is null
- * @see #MIN_VALUE
- * @see #MAX_VALUE
- * @see #POSITIVE_INFINITY
- * @see #NEGATIVE_INFINITY
- * @since 1.2
- */
- public static double parseDouble(String str)
- {
- return VMDouble.parseDouble(str);
- }
-
- /**
- * Return <code>true</code> if the <code>double</code> has the same
- * value as <code>NaN</code>, otherwise return <code>false</code>.
- *
- * @param v the <code>double</code> to compare
- * @return whether the argument is <code>NaN</code>.
- */
- public static boolean isNaN(double v)
- {
- // This works since NaN != NaN is the only reflexive inequality
- // comparison which returns true.
- return v != v;
- }
-
- /**
- * Return <code>true</code> if the <code>double</code> has a value
- * equal to either <code>NEGATIVE_INFINITY</code> or
- * <code>POSITIVE_INFINITY</code>, otherwise return <code>false</code>.
- *
- * @param v the <code>double</code> to compare
- * @return whether the argument is (-/+) infinity.
- */
- public static boolean isInfinite(double v)
- {
- return v == POSITIVE_INFINITY || v == NEGATIVE_INFINITY;
- }
-
- /**
- * Return <code>true</code> if the value of this <code>Double</code>
- * is the same as <code>NaN</code>, otherwise return <code>false</code>.
- *
- * @return whether this <code>Double</code> is <code>NaN</code>
- */
- public boolean isNaN()
- {
- return isNaN(value);
- }
-
- /**
- * Return <code>true</code> if the value of this <code>Double</code>
- * is the same as <code>NEGATIVE_INFINITY</code> or
- * <code>POSITIVE_INFINITY</code>, otherwise return <code>false</code>.
- *
- * @return whether this <code>Double</code> is (-/+) infinity
- */
- public boolean isInfinite()
- {
- return isInfinite(value);
- }
-
- /**
- * Convert the <code>double</code> value of this <code>Double</code>
- * to a <code>String</code>. This method calls
- * <code>Double.toString(double)</code> to do its dirty work.
- *
- * @return the <code>String</code> representation
- * @see #toString(double)
- */
- public String toString()
- {
- return toString(value);
- }
-
- /**
- * Return the value of this <code>Double</code> as a <code>byte</code>.
- *
- * @return the byte value
- * @since 1.1
- */
- public byte byteValue()
- {
- return (byte) value;
- }
-
- /**
- * Return the value of this <code>Double</code> as a <code>short</code>.
- *
- * @return the short value
- * @since 1.1
- */
- public short shortValue()
- {
- return (short) value;
- }
-
- /**
- * Return the value of this <code>Double</code> as an <code>int</code>.
- *
- * @return the int value
- */
- public int intValue()
- {
- return (int) value;
- }
-
- /**
- * Return the value of this <code>Double</code> as a <code>long</code>.
- *
- * @return the long value
- */
- public long longValue()
- {
- return (long) value;
- }
-
- /**
- * Return the value of this <code>Double</code> as a <code>float</code>.
- *
- * @return the float value
- */
- public float floatValue()
- {
- return (float) value;
- }
-
- /**
- * Return the value of this <code>Double</code>.
- *
- * @return the double value
- */
- public double doubleValue()
- {
- return value;
- }
-
- /**
- * Return a hashcode representing this Object. <code>Double</code>'s hash
- * code is calculated by:<br>
- * <code>long v = Double.doubleToLongBits(doubleValue());<br>
- * int hash = (int)(v^(v>>32))</code>.
- *
- * @return this Object's hash code
- * @see #doubleToLongBits(double)
- */
- public int hashCode()
- {
- long v = doubleToLongBits(value);
- return (int) (v ^ (v >>> 32));
- }
-
- /**
- * Returns <code>true</code> if <code>obj</code> is an instance of
- * <code>Double</code> and represents the same double value. Unlike comparing
- * two doubles with <code>==</code>, this treats two instances of
- * <code>Double.NaN</code> as equal, but treats <code>0.0</code> and
- * <code>-0.0</code> as unequal.
- *
- * <p>Note that <code>d1.equals(d2)</code> is identical to
- * <code>doubleToLongBits(d1.doubleValue()) ==
- * doubleToLongBits(d2.doubleValue())</code>.
- *
- * @param obj the object to compare
- * @return whether the objects are semantically equal
- */
- public boolean equals(Object obj)
- {
- if (! (obj instanceof Double))
- return false;
-
- double d = ((Double) obj).value;
-
- // Avoid call to native method. However, some implementations, like gcj,
- // are better off using floatToIntBits(value) == floatToIntBits(f).
- // Check common case first, then check NaN and 0.
- if (value == d)
- return (value != 0) || (1 / value == 1 / d);
- return isNaN(value) && isNaN(d);
- }
-
- /**
- * Convert the double to the IEEE 754 floating-point "double format" bit
- * layout. Bit 63 (the most significant) is the sign bit, bits 62-52
- * (masked by 0x7ff0000000000000L) represent the exponent, and bits 51-0
- * (masked by 0x000fffffffffffffL) are the mantissa. This function
- * collapses all versions of NaN to 0x7ff8000000000000L. The result of this
- * function can be used as the argument to
- * <code>Double.longBitsToDouble(long)</code> to obtain the original
- * <code>double</code> value.
- *
- * @param value the <code>double</code> to convert
- * @return the bits of the <code>double</code>
- * @see #longBitsToDouble(long)
- */
- public static long doubleToLongBits(double value)
- {
- return VMDouble.doubleToLongBits(value);
- }
-
- /**
- * Convert the double to the IEEE 754 floating-point "double format" bit
- * layout. Bit 63 (the most significant) is the sign bit, bits 62-52
- * (masked by 0x7ff0000000000000L) represent the exponent, and bits 51-0
- * (masked by 0x000fffffffffffffL) are the mantissa. This function
- * leaves NaN alone, rather than collapsing to a canonical value. The
- * result of this function can be used as the argument to
- * <code>Double.longBitsToDouble(long)</code> to obtain the original
- * <code>double</code> value.
- *
- * @param value the <code>double</code> to convert
- * @return the bits of the <code>double</code>
- * @see #longBitsToDouble(long)
- */
- public static long doubleToRawLongBits(double value)
- {
- return VMDouble.doubleToRawLongBits(value);
- }
-
- /**
- * Convert the argument in IEEE 754 floating-point "double format" bit
- * layout to the corresponding float. Bit 63 (the most significant) is the
- * sign bit, bits 62-52 (masked by 0x7ff0000000000000L) represent the
- * exponent, and bits 51-0 (masked by 0x000fffffffffffffL) are the mantissa.
- * This function leaves NaN alone, so that you can recover the bit pattern
- * with <code>Double.doubleToRawLongBits(double)</code>.
- *
- * @param bits the bits to convert
- * @return the <code>double</code> represented by the bits
- * @see #doubleToLongBits(double)
- * @see #doubleToRawLongBits(double)
- */
- public static double longBitsToDouble(long bits)
- {
- return VMDouble.longBitsToDouble(bits);
- }
-
- /**
- * Compare two Doubles numerically by comparing their <code>double</code>
- * values. The result is positive if the first is greater, negative if the
- * second is greater, and 0 if the two are equal. However, this special
- * cases NaN and signed zero as follows: NaN is considered greater than
- * all other doubles, including <code>POSITIVE_INFINITY</code>, and positive
- * zero is considered greater than negative zero.
- *
- * @param d the Double to compare
- * @return the comparison
- * @since 1.2
- */
- public int compareTo(Double d)
- {
- return compare(value, d.value);
- }
-
- /**
- * Behaves like <code>new Double(x).compareTo(new Double(y))</code>; in
- * other words this compares two doubles, special casing NaN and zero,
- * without the overhead of objects.
- *
- * @param x the first double to compare
- * @param y the second double to compare
- * @return the comparison
- * @since 1.4
- */
- public static int compare(double x, double y)
- {
- if (isNaN(x))
- return isNaN(y) ? 0 : 1;
- if (isNaN(y))
- return -1;
- // recall that 0.0 == -0.0, so we convert to infinites and try again
- if (x == 0 && y == 0)
- return (int) (1 / x - 1 / y);
- if (x == y)
- return 0;
-
- return x > y ? 1 : -1;
- }
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2007-05-12 10:29:56
|
Revision: 3188
http://jnode.svn.sourceforge.net/jnode/?rev=3188&view=rev
Author: lsantha
Date: 2007-05-12 03:29:55 -0700 (Sat, 12 May 2007)
Log Message:
-----------
First working GRUB installer.
Added Paths:
-----------
trunk/fs/src/fs/org/jnode/fs/jfat/command/GrubJFatFormatter.java
trunk/fs/src/fs/org/jnode/fs/jfat/command/JGrubInstallCommand.java
Added: trunk/fs/src/fs/org/jnode/fs/jfat/command/GrubJFatFormatter.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jfat/command/GrubJFatFormatter.java (rev 0)
+++ trunk/fs/src/fs/org/jnode/fs/jfat/command/GrubJFatFormatter.java 2007-05-12 10:29:55 UTC (rev 3188)
@@ -0,0 +1,107 @@
+/*
+ * $Id: GrubJFatFormatter.java Tanmoy $
+ *
+ * JNode.org
+ * Copyright (C) 2007 JNode.org
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+package org.jnode.fs.jfat.command;
+
+import java.io.*;
+import org.apache.log4j.Logger;
+import org.jnode.fs.FileSystemException;
+
+
+/**
+ * File :GrubFatFormatter.java
+ * <p/>
+ * The very important file for the Grub Installation. Here the
+ * methods for setting the Stage2 to the partition is kept.
+ *
+ * @author Tango Devian
+ */
+public class GrubJFatFormatter {
+ private static final Logger log = Logger.getLogger(GrubJFatFormatter.class);
+ private static final String GRUB_STAGE_2 = "/devices/sg0/boot/grub/grub.s2";
+ private static final String GRUB_MENU_LST = "/devices/sg0/boot/grub/menu.lst";
+
+ /**
+ * @throws org.jnode.fs.FileSystemException
+ *
+ * @throws org.jnode.fs.FileSystemException
+ *
+ * @throws org.jnode.fs.FileSystemException
+ *
+ * @throws java.io.IOException
+ * @throws java.io.IOException
+ * @see org.jnode.fs.fat.FatFormatter#format(org.jnode.driver.block.BlockDeviceAPI)
+ */
+ public void format(String path) throws FileSystemException, IOException {
+ // writting of the stage2 and menu.LST
+ try {
+ File destDir = new File(path + "/boot/grub/");
+ if(!destDir.exists()){
+ System.out.print("Creating directory: " + destDir.getAbsolutePath() + " ... ");
+ destDir.mkdirs();
+ System.out.println("done.");
+ }
+
+ System.out.print("Writing stage 2 ... ");
+ copyFAT(GRUB_STAGE_2, destDir.getAbsolutePath(), "stage2");
+ System.out.println("done.");
+
+ System.out.print("Writing menu.lst ... ");
+ copyFAT(GRUB_MENU_LST, destDir.getAbsolutePath(), "menu.lst");
+ System.out.println("done.");
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private static void copyFile(File srcFile, File destFile) throws IOException {
+
+ InputStream in = new FileInputStream(srcFile);
+ OutputStream out = new FileOutputStream(destFile);
+
+ byte[] buffer = new byte[1024];
+ int bytesRead;
+ while ((bytesRead = in.read(buffer)) >= 0) {
+ out.write(buffer, 0, bytesRead);
+ }
+ out.close();
+ in.close();
+
+ }
+
+ private static void copyFAT(String srcFileCopy, String destFileCopy, String destFileName) throws IOException {
+
+ // make sure the source file is indeed a readable file
+ File srcFile = new File(srcFileCopy);
+ if (!srcFile.isFile() || !srcFile.canRead()) {
+ throw new IllegalArgumentException("Not a readable file: " + srcFile.getName());
+ }
+
+ // make sure the second argument is a directory
+ File destDir = new File(destFileCopy);
+
+ // create File object for destination file
+ File destFile = new File(destDir, destFileName);
+
+ // copy file, optionally creating a checksum
+ copyFile(srcFile, destFile);
+ }
+}
Added: trunk/fs/src/fs/org/jnode/fs/jfat/command/JGrubInstallCommand.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jfat/command/JGrubInstallCommand.java (rev 0)
+++ trunk/fs/src/fs/org/jnode/fs/jfat/command/JGrubInstallCommand.java 2007-05-12 10:29:55 UTC (rev 3188)
@@ -0,0 +1,99 @@
+/*
+ * $Id: FatConstants.java 2224 Tanmoy $
+ *
+ * JNode.org
+ * Copyright (C) 2003-2006 JNode.org
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+
+package org.jnode.fs.jfat.command;
+
+import java.io.*;
+import javax.naming.NameNotFoundException;
+import org.jnode.driver.Device;
+import org.jnode.driver.DeviceManager;
+import org.jnode.driver.DeviceNotFoundException;
+import org.jnode.driver.DriverException;
+import org.jnode.naming.InitialNaming;
+import org.jnode.shell.Command;
+import org.jnode.shell.CommandLine;
+import org.jnode.shell.help.Help;
+import org.jnode.shell.help.Parameter;
+import org.jnode.shell.help.ParsedArguments;
+import org.jnode.shell.help.argument.DeviceArgument;
+import org.jnode.shell.help.argument.FileArgument;
+
+/**
+ * <p/>
+ * The Grub Installer command for the JNODE.
+ * jnode/>grub hdb /devices/hdb0
+ *
+ * @HDA_TARGET /dev/hda0 or /dev/fd0
+ * <p/>
+ * TODO: Adding more options for supporting JGRUB with user specified File
+ * System wise.
+ * Adding more command support for grub insallation.
+ * @author Tango Devian
+ */
+public class JGrubInstallCommand implements Command {
+ static final DeviceArgument ARG_DEVICE = new DeviceArgument("device", "device where grub will be installed");
+ static final FileArgument ARG_DIR = new FileArgument("directory", "the directory for stage2 and menu.lst");
+ static final Help.Info HELP_INFO = new Help.Info("grub", "Install GRUB to the specified location.",
+ new Parameter(ARG_DEVICE, Parameter.MANDATORY),
+ new Parameter(ARG_DIR, Parameter.MANDATORY));
+
+ /**
+ * @param args
+ * @throws Exception
+ */
+ public static void main(String[] args) throws Exception {
+ new JGrubInstallCommand().execute(new CommandLine(args), System.in, System.out, System.err);
+ }
+
+ /**
+ *
+ */
+ public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err) throws Exception {
+ try {
+ ParsedArguments cmdLine = HELP_INFO.parse(commandLine.toStringArray());
+ String device = ARG_DEVICE.getValue(cmdLine);
+ File destDir = ARG_DIR.getFile(cmdLine);
+ DeviceManager dm = InitialNaming.lookup(DeviceManager.NAME);
+ Device dev = dm.getDevice(device);
+ String destDirName = destDir.getAbsolutePath();
+ out.println("Installing GRUB to: " + device + ", " + destDirName);
+ try {
+ new MBRFormatter().format(dev);
+ new GrubJFatFormatter().format(destDirName);
+ out.println("Restarting device: " + device);
+ dm.stop(dev);
+ dm.start(dev);
+ out.println("GRUB has been successflly installed to " + device + ".");
+ } catch (FileNotFoundException e) {
+ err.println("File not found: " + e.getMessage());
+ } catch (IOException e) {
+ err.println("I/O exception: " + e.getMessage());
+ }
+ } catch (NameNotFoundException e) {
+ err.println("Name not found: " + e.getMessage());
+ } catch (DeviceNotFoundException e) {
+ err.println("Device not found: " + e.getMessage());
+ } catch (DriverException e) {
+ err.println("The DriverException Occuered ..." + e.getMessage());
+ }
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2007-05-12 10:29:03
|
Revision: 3187
http://jnode.svn.sourceforge.net/jnode/?rev=3187&view=rev
Author: lsantha
Date: 2007-05-12 03:28:59 -0700 (Sat, 12 May 2007)
Log Message:
-----------
First working GRUB installer.
Added Paths:
-----------
trunk/fs/src/fs/org/jnode/fs/jfat/command/MBRFormatter.java
Removed Paths:
-------------
trunk/fs/src/fs/org/jnode/fs/jfat/command/GrubJFatBootSector.java
trunk/fs/src/fs/org/jnode/fs/jfat/command/GrubJFatFormatter.java
trunk/fs/src/fs/org/jnode/fs/jfat/command/JGrubInstallCommand.java
Deleted: trunk/fs/src/fs/org/jnode/fs/jfat/command/GrubJFatBootSector.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jfat/command/GrubJFatBootSector.java 2007-05-12 10:25:44 UTC (rev 3186)
+++ trunk/fs/src/fs/org/jnode/fs/jfat/command/GrubJFatBootSector.java 2007-05-12 10:28:59 UTC (rev 3187)
@@ -1,47 +0,0 @@
-package org.jnode.fs.jfat.command;
-
-import org.jnode.fs.jfat.BootSector;
-
-/**
- *
- * @author Tango Devian
- *
- */
-/**
- * This file will contain the differetn value se
- *
- */
-
-
-class GrubJFatBootSector extends BootSector{
-
- public GrubJFatBootSector(byte[] sector) {
- super(sector);
- }
- /**
- * Constructor for GrubBootSector.
- * @param size
- */
- public GrubJFatBootSector(int size) {
- super(size);
- }
- /**
- * Gets the first sector of stage1_5
- * @return long
- */
- public long getStage1_5Sector() {
- return get32(0x44);
- }
-
- /**
- * Sets the first sector of stage1_5
- */
- public void setStage1_5Sector(long v) {
- set32(0x44, v);
- }
-
-
-
-
-
-}
Deleted: trunk/fs/src/fs/org/jnode/fs/jfat/command/GrubJFatFormatter.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jfat/command/GrubJFatFormatter.java 2007-05-12 10:25:44 UTC (rev 3186)
+++ trunk/fs/src/fs/org/jnode/fs/jfat/command/GrubJFatFormatter.java 2007-05-12 10:28:59 UTC (rev 3187)
@@ -1,267 +0,0 @@
-package org.jnode.fs.jfat.command;
-
-
-import java.io.*;
-import java.nio.ByteBuffer;
-import java.util.zip.CRC32;
-import org.apache.log4j.Logger;
-import org.jnode.driver.ApiNotFoundException;
-import org.jnode.driver.Device;
-import org.jnode.driver.block.BlockDeviceAPI;
-import org.jnode.fs.FileSystemException;
-import org.jnode.fs.jfat.BootSector;
-import org.jnode.util.FileUtils;
-import org.jnode.util.LittleEndian;
-
-/**
- * File :GrubFatFormatter.java
- * <p/>
- * The very important file for the Grub Installation. Here the methods for write
- * to the MBR and the setting the Stage2 are kept.
- *
- * @author Tango Devian
- */
-class GrubJFatFormatter {
- private static final Logger log = Logger.getLogger(GrubJFatFormatter.class);
-
- // The variables parameters declaration
- byte[] stage1;
-
- byte[] stage1_5;
- /**
- * The Source path for the Grub in CD://devices/sg0/boot/grub/STAGE1.
- * Because the grub can installed from the Live Boot CD.
- */
- final String stageResourceName1 = "//devices/sg0/BOOT/GRUB/STAGE1.";
-
- final String stageResourceName1_5 = "//devices/sg0/BOOT/GRUB/FAT1_5.";
-
- private static int installPartition = 0xFFFFFFFF;
-
- private String configFile;
-
- private int bootSectorOffset;
- private static boolean clock = true;
- private static boolean verify = true;
-
- /**
- * Create the actual bootsector.
- */
- private BootSector createBootSector(String stage1Name, String stage1_5Name,
- BlockDeviceAPI devApi) throws Exception {
- System.out.println("The createbootsector entered.");
- if (stage1Name == null) {
- System.out.println("hi i am in createbotsector....");
- stage1Name = "//devices/sg0/BOOT/GRUB/STAGE1.";
- }
- if (stage1_5Name == null) {
- stage1_5Name = "//devices/sg0/BOOT/GRUB/FAT1_5.";
- }
- try {
- stage1 = getStage1(stage1Name);
- stage1_5 = getStage1_5(stage1_5Name);
- return new GrubJFatBootSector(getStage1(stageResourceName1));
- } catch (IOException ex) {
- throw new RuntimeException(ex);
- }
-
- }
-
- /**
- * Reading the Grub stages from the device
- *
- * @param stage1ResourceName
- * @return
- * @throws IOException
- */
- public byte[] getStage1(String stage1ResourceName) throws IOException {
- if (stage1 == null) {
- File file = new File(stage1ResourceName);
- InputStream is = new FileInputStream(file);
- byte[] buf = new byte[512];
- FileUtils.copy(is, buf);
- is.close();
- stage1 = buf;
- }
- return stage1;
- }
-
- public byte[] getStage1_5(String stage1_5ResourceName) throws IOException {
- if (stage1_5 == null) {
- File file = new File(stage1_5ResourceName);
- InputStream in = new FileInputStream(file);
- byte[] buf = new byte[(int) file.length()];
- FileUtils.copy(in, buf);
- in.close();
- stage1_5 = buf;
- }
- return stage1_5;
-
- }
-
- /**
- * The method that will write the stage1.5 for the fat specific to the
- * Boot-sector to the block device.
- */
- public final static void writeStage1_5(long stage1_5_start, byte[] stage1_5,
- BlockDeviceAPI devApi) {
- try {
- devApi.write(stage1_5_start, ByteBuffer.wrap(stage1_5));
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- /**
- * @throws FileSystemException
- * @throws FileSystemException
- * @throws FileSystemException
- * @throws IOException
- * @throws IOException
- * @see org.jnode.fs.fat.FatFormatter#format(BlockDeviceAPI)
- */
- public final void format(Device device, String path) throws FileSystemException, IOException {
-
- System.out.println("The format(device) entered.");
- BlockDeviceAPI devApi;
- try {
-
- devApi = device.getAPI(BlockDeviceAPI.class);
- System.out.println("The devAPI initialization successfully....");
- } catch (ApiNotFoundException e) {
- throw new FileSystemException("Device is not a partition!", e);
- }
- System.out.println("The GrubJFatBootSector starting now......");
- try {
- GrubJFatBootSector bs = (GrubJFatBootSector) createBootSector(
- stageResourceName1, stageResourceName1_5, devApi);
-
- try {
- bs.write(devApi);
- // write the GRUB's stage1 to the MBR
- // Writing Stage1
- devApi.flush();
-
- System.out.println("The stage1 is written successfully...");
-
- stage1_5 = getStage1_5(stageResourceName1_5);
-
- System.out.println("The stage1_5 buffer is created successfully....");
- // writting the stage1.5;Here it is FatStage1_5
- LittleEndian.setInt32(stage1_5, 512 - 8, bootSectorOffset + 2);
- /* Fixup the install partition */
- LittleEndian.setInt32(stage1_5, 512 + 0x08, installPartition);
-
- setConfigFile("/boot/grub/menu.lst");
- /* Fixup the config file */
- if (configFile != null) {
- int ofs = 512 + 0x12;
- while (stage1_5[ofs] != 0) {
- ofs++;
- }
- ofs++; /* Skip '\0' */
- for (int i = 0; i < configFile.length(); i++) {
- stage1_5[ofs++] = (byte) configFile.charAt(i);
- }
- stage1_5[ofs] = 0;
- }
- System.out.println("grub version [");
- int i;
- for (i = 512 + 0x12; stage1_5[i] != 0; i++) {
- System.out.print((char) stage1_5[i]);
- }
- System.out.println("[ config ]");
- i++;
- for (; stage1_5[i] != 0; i++) {
- System.out.println((char) stage1_5[i]);
- }
- // writting the stage1.5
- System.out.println("the stage1_5 is writing now...pls wait...");
-
- writeStage1_5(bs.getBytesPerSector(), stage1_5, devApi);
- } catch (IOException e) {
- System.out.println("The Bootsector Failed....");
- }
- } catch (Exception e) {
- System.out.println("The exception at format()");
- }
-
- System.out.println("Thanks...The stage1_5 is written successfully.....");
-
- // writting of the stage2 and menu.LST
- System.out.println("The Stage2 is now writing....");
- copyFAT("//devices/sg0/BOOT/GRUB/STAGE2_E.", path + "/boot/grub/");
- System.out.println("The Menu.LSt is now writting....");
- copyFAT("//devices/sg0/BOOT/GRUB/MENU.LST", path + "/boot/grub/");
- System.out.println("The Stage2 is successfully created....");
- }
-
- public String getConfigFile() {
- return configFile;
- }
-
- private void setConfigFile(String configFile) {
- this.configFile = configFile;
- }
-
- public int getInstallPartition() {
- return installPartition;
- }
-
- public static void setInstallPartition(int installPartition1) {
- installPartition = installPartition1;
- }
-
- public static Long copyFile(File srcFile, File destFile) throws IOException {
-
- InputStream in = new FileInputStream(srcFile);
- OutputStream out = new FileOutputStream(destFile);
- long millis = System.currentTimeMillis();
- CRC32 checksum = null;
- if (verify) {
- checksum = new CRC32();
- checksum.reset();
- }
- byte[] buffer = new byte[1024];
- int bytesRead;
- while ((bytesRead = in.read(buffer)) >= 0) {
- if (verify) {
- checksum.update(buffer, 0, bytesRead);
- }
- out.write(buffer, 0, bytesRead);
- }
- out.close();
- in.close();
- if (clock) {
- millis = System.currentTimeMillis() - millis;
- System.out.println("Second(s): " + (millis / 1000L));
- }
- if (verify) {
- return new Long(checksum.getValue());
- } else {
- return null;
- }
- }
-
- public static void copyFAT(String srcFileCopy, String destFileCopy) throws IOException {
-
- // make sure the source file is indeed a readable file
- File srcFile = new File(srcFileCopy);
- if (!srcFile.isFile() || !srcFile.canRead()) {
- System.err.println("Not a readable file: " + srcFile.getName());
- System.exit(1);
- }
- // make sure the second argument is a directory
- File destDir = new File(destFileCopy);
- if (!destDir.exists()) {
- destDir.mkdirs();
- System.out.println("The BOOT/GRUB/ Directory is created...");
- }
- // create File object for destination file
- File destFile = new File(destDir, srcFile.getName());
-
- // copy file, optionally creating a checksum
- Long checksumSrc = copyFile(srcFile, destFile);
- }
-}
Deleted: trunk/fs/src/fs/org/jnode/fs/jfat/command/JGrubInstallCommand.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jfat/command/JGrubInstallCommand.java 2007-05-12 10:25:44 UTC (rev 3186)
+++ trunk/fs/src/fs/org/jnode/fs/jfat/command/JGrubInstallCommand.java 2007-05-12 10:28:59 UTC (rev 3187)
@@ -1,105 +0,0 @@
-package org.jnode.fs.jfat.command;
-
-import java.io.File;
-import java.io.InputStream;
-import java.io.PrintStream;
-import java.io.IOException;
-import java.io.FileNotFoundException;
-
-import javax.naming.NameNotFoundException;
-
-import org.jnode.driver.Device;
-import org.jnode.driver.DeviceManager;
-import org.jnode.driver.DeviceNotFoundException;
-import org.jnode.driver.DriverException;
-import org.jnode.naming.InitialNaming;
-import org.jnode.shell.Command;
-import org.jnode.shell.CommandLine;
-import org.jnode.shell.help.Help;
-import org.jnode.shell.help.Parameter;
-import org.jnode.shell.help.ParsedArguments;
-import org.jnode.shell.help.argument.DeviceArgument;
-import org.jnode.shell.help.argument.FileArgument;
-
-/**
- * The Grub Installer command for the JNODE.
- * jnode/>jgrub HDA_TARGET
- * HDA_TARGET /dev/hda0 or /dev/fd0
- *
- * @author Tango Devian
- */
-public class JGrubInstallCommand implements Command {
-
- static final DeviceArgument ARG_DEVICE = new DeviceArgument("device", "device to where the Grub will install");
-
- static final FileArgument ARG_DIR = new FileArgument("directory", "the directory where you set the Stage2 and Menu.Lst");
-
- static final Help.Info HELP_INFO = new Help.Info("grub", "Install the grub to the specified location.", new Parameter[]{
- new Parameter(ARG_DEVICE, Parameter.MANDATORY),
- new Parameter(ARG_DIR, Parameter.MANDATORY)});
-
- //static final Parameter PARAM_DEVICE = new Parameter(ARG_DEVICE,
- //Parameter.MANDATORY);
- /**
- * @param args
- * @throws Exception
- */
- public static void main(String[] args) throws Exception {
- new JGrubInstallCommand().execute(new CommandLine(args), System.in, System.out, System.err);
- }
-
- /**
- *
- */
- public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err) throws Exception {
- try {
- ParsedArguments cmdLine = HELP_INFO.parse(commandLine.toStringArray());
- String device = ARG_DEVICE.getValue(cmdLine);
- //i am not sure yet
- File destDir = ARG_DIR.getFile(cmdLine);
-
- out.println("grub The dm is now initialized.");
- DeviceManager dm = InitialNaming.lookup(DeviceManager.NAME);
-
- out.println("The getdevice() method invoking now.");
- Device dev = dm.getDevice(device);
-
- out.println("The device is successfully initialized.");
- out.println("The Grub Installer is started......wait");
- try {
- try {
- new GrubJFatFormatter().format(dev, destDir.getAbsolutePath());
- } catch (FileNotFoundException e) {
- err.println("The ERROR at GRUB FAT FORMAT method.");
- }
- } catch (IOException e) {
- err.println("The ERROR at the FAT FORMAT method...");
- }
- //restart the device
- dm.stop(dev);
- out.println("The device is stopped....");
- dm.start(dev);
- out.println("The Grub successflly installed.");
- } catch (NameNotFoundException e) {
- out.println("The NameNotFoundException occured...");
- } catch (DeviceNotFoundException e) {
- err.println("The Device Not Found...");
- } catch (DriverException e) {
- out.println("The DriverException Occuered......");
- }
- }
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Added: trunk/fs/src/fs/org/jnode/fs/jfat/command/MBRFormatter.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jfat/command/MBRFormatter.java (rev 0)
+++ trunk/fs/src/fs/org/jnode/fs/jfat/command/MBRFormatter.java 2007-05-12 10:28:59 UTC (rev 3187)
@@ -0,0 +1,510 @@
+/*
+ * $Id: MBRFormatter.java 7-5-2007 Tanmoy $
+ *
+ * JNode.org
+ * Copyright (C) 2003-2006 JNode.org
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+
+
+
+package org.jnode.fs.jfat.command;
+
+/**
+ * The MBRFormatter is the main class for writing the stage1 and stage1.5
+ * to the MBR.
+ */
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+
+import org.apache.log4j.Logger;
+import org.jnode.driver.ApiNotFoundException;
+import org.jnode.driver.Device;
+import org.jnode.driver.block.BlockDeviceAPI;
+import org.jnode.driver.bus.ide.IDEConstants;
+import org.jnode.fs.FileSystemException;
+import org.jnode.partitions.ibm.IBMPartitionTable;
+import org.jnode.partitions.ibm.IBMPartitionTableEntry;
+import org.jnode.util.FileUtils;
+import org.jnode.util.LittleEndian;
+
+/**
+ * @author tango
+ */
+
+public class MBRFormatter {
+ private static final Logger log = Logger.getLogger(MBRFormatter.class);
+ IBMPartitionTableEntry oldEntry;
+ byte[] stage1;
+ byte[] stage1_5;
+ /**
+ * The Source path for the Grub in CD://devices/sg0/boot/grub/STAGE1.
+ * Because the grub can installed from the Live Boot CD.
+ */
+ final String stageResourceName1 = "/devices/sg0/boot/grub/grub.s1";
+ final String stageResourceName2 = "/devices/sg0/boot/grub/fat.s15";
+ private static int installPartition = 0xFFFFFF;
+ private String configFile;
+
+ /**
+ *
+ * The reading of the OLD MBR
+ * @throws java.io.IOException
+ *
+ */
+ private void checkMBR(ByteBuffer MBR) throws IOException
+ {
+ if (!IBMPartitionTable.containsPartitionTable(MBR.array()))
+ throw new IOException("This device doesn't contain a valid MBR, use --initmbr.");
+ }
+
+ /**
+ * Reading the Grub stages from the Rescue Device.
+ *
+ * @param stage1ResourceName
+ * @return
+ * @throws java.io.IOException
+ */
+ public byte[] getStage1(String stage1ResourceName) throws IOException {
+ if (stage1 == null) {
+ File file = new File(stage1ResourceName);
+ InputStream is = new FileInputStream(file);
+ byte[] buf = new byte[512];
+ FileUtils.copy(is, buf);
+ is.close();
+ stage1 = buf;
+ }
+ return stage1;
+ }
+
+ /**
+ * The Method for reading the stage1.5 from the Rescue Disk.
+ * @param stage2ResourceName
+ * @return
+ * @throws java.io.IOException
+ */
+ public byte[] getStage1_5(String stage2ResourceName) throws IOException {
+ if (stage1_5 == null) {
+ File file = new File(stage2ResourceName);
+ InputStream is = new FileInputStream(file);
+ byte[] buf = new byte[(int)file.length()];
+ FileUtils.copy(is, buf);
+ is.close();
+ stage1_5 = buf;
+ }
+ return stage1_5;
+
+ }
+
+ /**
+ * The method that will write the stage1.5 for the File System
+ * specific to the Boot-sector to the block device.
+ *
+ *
+ */
+ public final static void writeStage1_5(long stage1_5_start,
+ ByteBuffer stage1_5,
+ BlockDeviceAPI devApi) {
+ try {
+ devApi.write(stage1_5_start,(stage1_5));
+ }catch (IOException e) {
+ e.printStackTrace();
+
+ }
+ }
+
+ /**
+ * @throws org.jnode.fs.FileSystemException
+ * @throws org.jnode.fs.FileSystemException
+ * @throws org.jnode.fs.FileSystemException
+ * @throws java.io.IOException
+ * @throws java.io.IOException
+ * @see org.jnode.fs.fat.FatFormatter#format(org.jnode.driver.block.BlockDeviceAPI)
+ */
+ public void format(Device device) throws FileSystemException, IOException {
+ BlockDeviceAPI devApi;
+ try {
+ devApi = device.getAPI(BlockDeviceAPI.class);
+ } catch (ApiNotFoundException e) {
+ throw new FileSystemException("Device is not a partition!", e);
+ }
+
+ log.info("The MBR Old is checked successfully.");
+ ByteBuffer MBR=ByteBuffer.allocate(IDEConstants.SECTOR_SIZE);
+ devApi.read(0, MBR);
+ checkMBR(MBR);
+ log.info("The MBR Old is read successfully.");
+
+ /*int add=LittleEndian.getInt32(MBR.array(),0x44);
+ System.out.println("The value at the position 0x44 is-> " +Integer.toHexString(add));*/
+ byte[] partition=getPartitionTable(0x1be,64,MBR);
+
+ if(!isaValidBootSector(MBR.array())){
+ log.error("The OLD Boot Sector is not valid.");
+ }
+
+ stage1=getStage1(stageResourceName1);
+ /**
+ * The BPB stands for the Bios Parameter Block.As the BPB of
+ * a disk is fixed and it is written to the disk during the
+ * partitioning of the disk. The BPB is present between the
+ * position of 0x3 to 0x48 position.
+ *
+ * NOTE:
+ * 1) Here need to make the BPB more independently(ie without
+ * array of the BPB using it in MBR)
+ *
+ * 2)The next Inportant matter is here that in the MBR's
+ * <b> 0x44 th</b> position we setting the position of the
+ * stage1.5 or Stage2.here as i used the Stage1.5 at the Sector
+ * 1(second sector) so The Value is set here as 01 00 00 00
+ *
+ * 3)In the Position of the 0x40:
+ * The boot drive. If it is 0xFF, use a drive passed by BIOS.
+ * The value is 0x80 for HDD.I kept it default here.
+ *
+ * 4)0x42: The starting address of Stage 2 or Stage1.5.
+ * As here i used the Stage1.5;hence the value i set here 0x2000
+ * If it is Stage2 then it will be 0x8000.
+ *
+ * 5)0x48: The starting segment of Stage 2 or Stage1.5.
+ * Here for stage1.5 i used the value 0x20
+ * For stage2 it will be 0x80.
+ *
+ * TODO: In this portion we need to use dynamically the BPB values.
+ * And, that time at the stage1 buffer the EMBEDDED variables need to
+ * set here individually.
+ *
+ * BUGs REPORT: Using statically the value of the BPB.and setted
+ * the EMBEDDED variables in that array statically.It is not good.
+ * ;-)
+ *
+ */
+ setBPB(BPB,stage1);
+ /**
+ * The Partition table is the cruisal part of the HDD formatted with
+ * different FS.For the grub disk the Stage1 is kept upto the first
+ * 446bytes to the MBR.Then after the 64 bytes are kept for Setting
+ * the PArtition table.
+ *
+ * N.B. : The grub will be written actually always after the
+ * Partition Table written to the HDD.IT is very IMPORTANT.
+ *
+ */
+ setPartitionTable(0x1be,64,partition,stage1);
+
+ /**
+ * Checking the BootSector is Valid or not.
+ * Actually here need to check the Sector Signature.
+ * 0x55AA --->
+ *
+ */
+ if(!isaValidBootSector(stage1)){
+ log.error("The New Boot Sector Is Not Valid.");
+ }
+
+ try {
+ /**
+ * write the GRUB's stage1 to the MBR
+ */
+ System.out.print("Writing stage 1 ... ");
+ devApi.write(0,ByteBuffer.wrap(stage1));
+ devApi.flush();
+ System.out.println("done.");
+
+
+
+
+ System.out.println("The Stage1.5 is now embedding.");
+ stage1_5 = getStage1_5(stageResourceName2);
+ int size=stage1_5.length/IDEConstants.SECTOR_SIZE;
+ log.info("The Size of the stage1_5 is : "+size);
+
+
+
+ /**
+ * The most important stage of the GRUB BOOTING. THE stage1.5.
+ *
+ * The Embedded variables for the grub setting into
+ * the JNode's grub stage1.5
+ */
+
+
+ /**
+ * The Blocklists for JNode grub installer is setting to
+ * the (512-4)th position of the Sector1 of the Stage1.5.
+ * Blocklists is the size of the stage1.5 in the sectors unit.
+ *
+ **/
+ LittleEndian.setInt16(stage1_5,512-4 ,size);
+
+
+ /** Fixup the install partition */
+ LittleEndian.setInt32(stage1_5, 512 + 0x08, installPartition);
+
+
+ setConfigFile("/boot/grub/menu.lst");
+
+ /** The Saved Entry Number **/
+ LittleEndian.setInt32(stage1_5,512+0xc,0xe);
+
+ /**
+ * The most important section of the Grub
+ * The path of the stage2 in the stage1.5
+ *
+ * NOTE: Here at the ox19 offset of the second
+ * Sector of the stage1.5. the value of the Drive Path
+ * is kept where the stage2 is kept.
+ * Ex: as here the /dev/hd0 is used (ie the partition where
+ * the FATfs is kept and where the stage2 will keep.
+ * So here the value set as 0x00.
+ *
+ * The path of the stage2 is very important.Otherwise it will can
+ * create ERROR 17.
+ *
+ * Suppose (hd0,1)/boot/grub/stage2--
+ * (hd0,1) corresponds to linux partition /dev/hda2
+ * (or /dev/sda2, depending on bios).So hd0 is the first hard disk found by bios.
+ * The "1" stands for partition number starting from "0".
+ * Under linux partition numbers start with 1. Therefore,
+ * the number differs.When this path
+ * is patched into stage1.5 at position 512+0x12+5, then the device specification
+ * (hd0,1) is converted to binary, e.g. 0x8001ffff
+ * (0x80 first hard disk, 0x01 first partition, 0xffff
+ * only for BSD partition).The directory /boot/grub/stage2 is relative to the
+ * partition, so if you have a /boot partition, then the path would be just /grub/stage2.
+ * Normally grub should detect the mapping of unix partition to its own
+ * partition numbering scheme automatically. In some cases this does
+ * not work, e.g. if you have multiple hard disks, the numbering of your
+ * BIOS is hard to predict. Grub uses a file device.map where you can change
+ * the numbering manually.
+ *
+ *
+ * <b>BUGS:</b>1) As currently it is only statically written here the
+ * value of the 0x00; so the stage2 is need to only kept at
+ * the /devices/hdb0.For supporting it in the any partition
+ * here need to change once little bit logic.
+ *
+ * 2)Need to support the Device.map for MUltiple Disk supporting in
+ * the JNODE.
+ *
+ **/
+ LittleEndian.setInt8(stage1_5,512+0x19,0x00);
+
+ /**
+ * Fixup the config file
+ * TODO: here to be change that the Config File
+ * will write after skipping the /boot/grub/stage2
+ *
+ */
+ if (configFile != null) {
+ int ofs = 512 + 0x27;
+ while (stage1_5[ofs] != 0) {
+ ofs++;
+ }
+ ofs++; /* Skip '\0' */
+ for (int i = 0; i < configFile.length(); i++) {
+ stage1_5[ofs++] = (byte) configFile.charAt(i);
+ }
+ stage1_5[ofs] = 0;
+ }
+
+
+ /**
+ * The Method for writing the Stage1.5 to
+ * the Sector 1 actually to the second sector.
+ *
+ *
+ */
+ writeStage1_5(IDEConstants.SECTOR_SIZE, ByteBuffer.wrap(stage1_5), devApi);
+
+
+ } catch (IOException e) {
+ System.out.println("The Bootsector Failed....");
+ }
+
+
+ System.out.println("Writing stage 1 and stage 1.5 has been completed.");
+
+
+
+}
+
+ /**
+ * The Writing the BPB to the MBR to its Correct Position.
+ * @param bpb2
+ * @param stage12
+ */
+ private void setBPB(byte[] bpb2, byte[] stage12) {
+ System.arraycopy (bpb2 ,0, stage12, 0x3, bpb2.length );
+ }
+ /**
+ * The Reading the Partition Table.
+ * @param offset
+ * @param len
+ * @param MBR
+ * @return
+ */
+ protected byte[] getPartitionTable ( int offset, int len ,ByteBuffer MBR) {
+ byte[] v = new byte[len];
+ System.arraycopy (MBR.array() ,offset, v, 0, len );
+ return v;
+ }
+ /**
+ * The writting method of the Partition table to the MBR to
+ * 446bytes position to the (446+64) bytes position.
+ * @param offset
+ * @param len
+ * @param value
+ * @param MBR
+ */
+ protected void setPartitionTable ( int offset, int len, byte[] value,byte[] MBR ) {
+ System.arraycopy ( value, 0, MBR, offset, len );
+ }
+ /**
+ * The reading methof of the Configuration File.
+ * @return
+ */
+ public String getConfigFile() {
+ return configFile;
+ }
+ /**
+ * The writting method of the Configuration file to the disk.
+ * @param configFile
+ */
+ private void setConfigFile(String configFile) {
+ this.configFile = configFile;
+ }
+ /**
+ * Reading the InstallPartition.
+ * @return
+ */
+ public int getInstallPartition() {
+ return installPartition;
+ }
+ /**
+ * The Writtting of the InstallPartition.
+ * @param installPartition1
+ */
+ public static void setInstallPartition(int installPartition1) {
+ installPartition = installPartition1;
+ }
+ /**
+ *
+ * The mathod for Checking that the Currrent Boot Sector is OK or
+ * Not.The Checking method is simple.Because to the BootSector's
+ * last two bytes if have 0xaa and 0x55; Then the Sector is OK.
+ * @param MBR
+ * @return
+ */
+ public boolean isaValidBootSector(byte[] MBR) {
+ if ( MBR.length >= 512 )
+ return
+ ( MBR[510] & 0xFF ) == 0x55 &&
+ ( MBR[511] & 0xFF ) == 0xAA;
+ else
+ return
+ false;
+ }
+
+ /**
+ * The BPB-Bios Parameter Block is kept here.
+ * I am Confusing yet with That.I will Change it soon.
+ *
+ */
+ private static final byte[] BPB={
+ //D0 BC 00 7C FB 50 07 50 1F FC BE 1B 7C
+ (byte)0xD0,
+ (byte)0xBC,
+ (byte)0x00,
+ (byte)0x7C,
+ (byte)0xFB,
+ (byte)0x50,
+ (byte)0x07,
+ (byte)0x50,
+ (byte)0x1F,
+ (byte)0xFC,
+ (byte)0xBE,
+ (byte)0x1B,
+ (byte)0x7C,
+ //BF 1B 06 50 57 B9 E5 01 F3 A4 CB BE BE 07 B1 04
+ (byte)0xBF,
+ (byte)0x1B,
+ (byte)0x06,
+ (byte)0x50,
+ (byte)0x57,
+ (byte)0xB9,
+ (byte)0xE5,
+ (byte)0x01,
+ (byte)0xF3,
+ (byte)0xA4,
+ (byte)0xCB,
+ (byte)0xBE,
+ (byte)0xBE,
+ (byte)0x07,
+ (byte)0xB1,
+ (byte)0x04,
+ //38 2C 7C 09 75 15 83 C6 10 E2 F5 CD 18 8B 14 8B
+ (byte)0x38,
+ (byte)0x2C,
+ (byte)0x7C,
+ (byte)0x09,
+ (byte)0x75,
+ (byte)0x15,
+ (byte)0x83,
+ (byte)0xC6,
+ (byte)0x10,
+ (byte)0xE2,
+ (byte)0xF5,
+ (byte)0xCD,
+ (byte)0x18,
+ (byte)0x8B,
+ (byte)0x14,
+ (byte)0x8B,
+ //EE 83 C6 10 49 74 16 38 2C 74 F6 BE 10 07 03 02
+ (byte)0xEE,
+ (byte)0x83,
+ (byte)0xC6,
+ (byte)0x10,
+ (byte)0x49,
+ (byte)0x74,
+ (byte)0x16,
+ (byte)0x38,
+ (byte)0x2C,
+ (byte)0x74,
+ (byte)0xF6,
+ (byte)0xBE,
+ (byte)0x10,
+ (byte)0x07,
+ (byte)0x03,
+ (byte)0x02,
+ //ff 00 00 20 01 00 00 00 02
+ (byte)0xff,
+ (byte)0x00,
+ (byte)0x00,
+ (byte)0x20,
+ (byte)0x01,
+ (byte)0x00,
+ (byte)0x00,
+ (byte)0x00,
+ (byte)0x00,
+ (byte)0x02
+ };
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2007-05-12 10:25:45
|
Revision: 3186
http://jnode.svn.sourceforge.net/jnode/?rev=3186&view=rev
Author: lsantha
Date: 2007-05-12 03:25:44 -0700 (Sat, 12 May 2007)
Log Message:
-----------
Added GRUB files need for grub installation.
Modified Paths:
--------------
trunk/all/build-x86.xml
Modified: trunk/all/build-x86.xml
===================================================================
--- trunk/all/build-x86.xml 2007-05-12 10:24:24 UTC (rev 3185)
+++ trunk/all/build-x86.xml 2007-05-12 10:25:44 UTC (rev 3186)
@@ -255,10 +255,13 @@
<copy todir="@{dir}">
<fileset dir="${initjars.dir}" />
</copy>
- <copy file="${my-lib.dir}/stage2_eltorito" todir="@{dir}/boot/grub" />
- <copy file="${grub.menu.cdrom}" tofile="@{dir}/boot/grub/menu.lst" />
- <exec executable="mkisofs">
- <arg line="-o @{destfile} -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table @{dir}" />
+ <copy file="${my-lib.dir}/eltorito.s2" todir="@{dir}/boot/grub" />
+ <copy file="${my-lib.dir}/fat.s15" todir="@{dir}/boot/grub" />
+ <copy file="${my-lib.dir}/grub.s1" todir="@{dir}/boot/grub" />
+ <copy file="${my-lib.dir}/grub.s2" todir="@{dir}/boot/grub" />
+ <copy file="${grub.menu.cdrom}" tofile="@{dir}/boot/grub/menu.lst" />
+ <exec executable="mkisofs">
+ <arg line="-o @{destfile} -R -b boot/grub/eltorito.s2 -no-emul-boot -boot-load-size 4 -boot-info-table @{dir}" />
</exec>
</sequential>
</macrodef>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2007-05-12 10:24:27
|
Revision: 3185
http://jnode.svn.sourceforge.net/jnode/?rev=3185&view=rev
Author: lsantha
Date: 2007-05-12 03:24:24 -0700 (Sat, 12 May 2007)
Log Message:
-----------
Added GRUB files need for grub installation.
Added Paths:
-----------
trunk/all/lib/x86/eltorito.s2
trunk/all/lib/x86/fat.s15
trunk/all/lib/x86/grub.s1
trunk/all/lib/x86/grub.s2
Removed Paths:
-------------
trunk/all/lib/x86/stage2_eltorito
Copied: trunk/all/lib/x86/eltorito.s2 (from rev 3181, trunk/all/lib/x86/stage2_eltorito)
===================================================================
(Binary files differ)
Property changes on: trunk/all/lib/x86/eltorito.s2
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/all/lib/x86/fat.s15
===================================================================
(Binary files differ)
Property changes on: trunk/all/lib/x86/fat.s15
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/all/lib/x86/grub.s1
===================================================================
(Binary files differ)
Property changes on: trunk/all/lib/x86/grub.s1
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/all/lib/x86/grub.s2
===================================================================
(Binary files differ)
Property changes on: trunk/all/lib/x86/grub.s2
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: trunk/all/lib/x86/stage2_eltorito
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2007-05-09 20:06:03
|
Revision: 3184
http://jnode.svn.sourceforge.net/jnode/?rev=3184&view=rev
Author: lsantha
Date: 2007-05-09 13:06:00 -0700 (Wed, 09 May 2007)
Log Message:
-----------
Command test renamed to utest.
Modified Paths:
--------------
trunk/shell/descriptors/org.jnode.shell.command.test.xml
Modified: trunk/shell/descriptors/org.jnode.shell.command.test.xml
===================================================================
--- trunk/shell/descriptors/org.jnode.shell.command.test.xml 2007-05-09 20:05:12 UTC (rev 3183)
+++ trunk/shell/descriptors/org.jnode.shell.command.test.xml 2007-05-09 20:06:00 UTC (rev 3184)
@@ -20,7 +20,7 @@
</runtime>
<extension point="org.jnode.shell.aliases">
- <alias name="test" class="org.jnode.shell.command.test.TestCommand"/>
+ <alias name="utest" class="org.jnode.shell.command.test.TestCommand"/>
<alias name="suite" class="org.jnode.shell.command.test.SuiteCommand"/>
</extension>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2007-05-09 20:05:13
|
Revision: 3183
http://jnode.svn.sourceforge.net/jnode/?rev=3183&view=rev
Author: lsantha
Date: 2007-05-09 13:05:12 -0700 (Wed, 09 May 2007)
Log Message:
-----------
Command test renamed to utest.
Modified Paths:
--------------
trunk/shell/src/shell/org/jnode/shell/command/test/TestCommand.java
Modified: trunk/shell/src/shell/org/jnode/shell/command/test/TestCommand.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/command/test/TestCommand.java 2007-05-05 20:51:01 UTC (rev 3182)
+++ trunk/shell/src/shell/org/jnode/shell/command/test/TestCommand.java 2007-05-09 20:05:12 UTC (rev 3183)
@@ -43,7 +43,7 @@
// static final Argument ARG_ARGS = new Argument("arg", "the argument(s) to
// pass to the testcase", Argument.MULTI);
- public static Help.Info HELP_INFO = new Help.Info("test",
+ public static Help.Info HELP_INFO = new Help.Info("utest",
"Run a JUnit testcase", new Parameter[] { new Parameter(ARG_CLASS,
Parameter.MANDATORY)
// new Parameter(ARG_ARGS, Parameter.OPTIONAL)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2007-05-05 20:51:08
|
Revision: 3182
http://jnode.svn.sourceforge.net/jnode/?rev=3182&view=rev
Author: lsantha
Date: 2007-05-05 13:51:01 -0700 (Sat, 05 May 2007)
Log Message:
-----------
VIA Rhine code restructuring. Simple things are working.
Modified Paths:
--------------
trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineConstants.java
trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineCore.java
trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineFlags.java
Added Paths:
-----------
trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineDesc.java
trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineRing.java
trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineRxRing.java
trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineTxRing.java
Removed Paths:
-------------
trunk/net/src/driver/org/jnode/driver/net/via_rhine/RxDesc.java
trunk/net/src/driver/org/jnode/driver/net/via_rhine/RxRing.java
trunk/net/src/driver/org/jnode/driver/net/via_rhine/TxDesc.java
trunk/net/src/driver/org/jnode/driver/net/via_rhine/TxRing.java
Deleted: trunk/net/src/driver/org/jnode/driver/net/via_rhine/RxDesc.java
===================================================================
--- trunk/net/src/driver/org/jnode/driver/net/via_rhine/RxDesc.java 2007-05-03 06:30:23 UTC (rev 3181)
+++ trunk/net/src/driver/org/jnode/driver/net/via_rhine/RxDesc.java 2007-05-05 20:51:01 UTC (rev 3182)
@@ -1,81 +0,0 @@
-/*
- * $Id$
- */
-package org.jnode.driver.net.via_rhine;
-
-import org.jnode.system.ResourceManager;
-import org.jnode.system.MemoryResource;
-import org.jnode.net.SocketBuffer;
-import org.apache.log4j.Logger;
-import static org.jnode.driver.net.via_rhine.ViaRhineConstants.*;
-import org.vmmagic.unboxed.Address;
-
-
-/**
- * @author Levente S\xE1ntha
- */
-public class RxDesc {
- protected final Logger log = Logger.getLogger(getClass());
- byte[] desc;
- int descOffs;
- MemoryResource descMr;
- byte[] data;
- int dataOffs;
- MemoryResource dataMr;
- int descAddr;
- RxDesc(ResourceManager rm){
- desc = new byte[16 + 32];
- descMr = rm.asMemoryResource(desc);
- Address memAddr = descMr.getAddress();
-
- int addr = memAddr.toInt();
- descOffs = 0;
- // Align on 32-byte boundary
- while ((addr & 31) != 0) {
- addr++;
- descOffs++;
- }
- descAddr = memAddr.add(descOffs).toInt();
-
- descMr.setInt(descOffs, 0x80000000);
- descMr.setInt(descOffs + 4, PKT_BUF_SZ);
-
- data = new byte[PKT_BUF_SZ + 32];
- dataMr = rm.asMemoryResource(data);
-
- memAddr = dataMr.getAddress();
- addr = memAddr.toInt();
- dataOffs = 0;
- // Align on 32-byte boundary
- while ((addr & 31) != 0) {
- addr++;
- dataOffs++;
- }
-
- descMr.setInt(descOffs + 8, memAddr.add(dataOffs).toInt());
- }
-
- void setOwnBit(){
- descMr.setInt(descOffs, descMr.getInt(descOffs) | 0x80000000);
- }
-
- boolean isOwnBit(){
- return (descMr.getInt(descOffs) & 0x80000000) != 0;
- }
-
- void setNextDescAddr(int addr){
- descMr.setInt(descOffs + 12, addr);
- }
-
- int frameLength(){
- return descMr.getChar(descOffs + 2) & 0x000007FF;
- }
-
- SocketBuffer getPacket(){
- int ln = frameLength();
- log.debug("packetlength: " + ln);
- byte[] buf = new byte[ln];
- System.arraycopy(data, dataOffs, buf, 0, ln);
- return new SocketBuffer(buf, 0, ln);
- }
-}
Deleted: trunk/net/src/driver/org/jnode/driver/net/via_rhine/RxRing.java
===================================================================
--- trunk/net/src/driver/org/jnode/driver/net/via_rhine/RxRing.java 2007-05-03 06:30:23 UTC (rev 3181)
+++ trunk/net/src/driver/org/jnode/driver/net/via_rhine/RxRing.java 2007-05-05 20:51:01 UTC (rev 3182)
@@ -1,43 +0,0 @@
-/*
- * $Id$
- */
-package org.jnode.driver.net.via_rhine;
-
-import static org.jnode.driver.net.via_rhine.ViaRhineConstants.*;
-import org.jnode.system.ResourceManager;
-import org.jnode.net.SocketBuffer;
-
-/**
- * @author Levente S\xE1ntha
- */
-public class RxRing {
- RxDesc[] ring;
- int ringAddr;
- int current;
- RxRing(ResourceManager rm){
- ring = new RxDesc[RX_RING_SIZE];
- for(int i = 0; i < RX_RING_SIZE; i++){
- ring[i] = new RxDesc(rm);
- if(i == 0)
- ringAddr = ring[0].descAddr;
- else
- ring[i - 1].setNextDescAddr(ring[i].descAddr);
-
-
- }
- ring[RX_RING_SIZE - 1].setNextDescAddr(ringAddr);
- }
-
-
- SocketBuffer getPacket(){
- return ring[current].getPacket();
- }
-
- RxDesc currentDesc(){
- return ring[current];
- }
-
- void next(){
- current = (current + 1) % RX_RING_SIZE;
- }
-}
Deleted: trunk/net/src/driver/org/jnode/driver/net/via_rhine/TxDesc.java
===================================================================
--- trunk/net/src/driver/org/jnode/driver/net/via_rhine/TxDesc.java 2007-05-03 06:30:23 UTC (rev 3181)
+++ trunk/net/src/driver/org/jnode/driver/net/via_rhine/TxDesc.java 2007-05-05 20:51:01 UTC (rev 3182)
@@ -1,86 +0,0 @@
-/*
- * $Id$
- */
-package org.jnode.driver.net.via_rhine;
-
-import org.apache.log4j.Logger;
-import org.jnode.system.MemoryResource;
-import org.jnode.system.ResourceManager;
-import org.jnode.net.SocketBuffer;
-import static org.jnode.net.ethernet.EthernetConstants.*;
-import org.vmmagic.unboxed.Address;
-import java.util.Arrays;
-
-
-/**
- * @author Levente S\xE1ntha
- */
-public class TxDesc {
- protected final Logger log = Logger.getLogger(getClass());
- byte[] desc;
- int descOffs;
- MemoryResource descMr;
- byte[] data;
- int dataOffs;
- MemoryResource dataMr;
- int descAddr;
- TxDesc(ResourceManager rm){
- desc = new byte[16 + 32];
- descMr = rm.asMemoryResource(desc);
- Address memAddr = descMr.getAddress();
-
- int addr = memAddr.toInt();
- descOffs = 0;
- // Align on 32-byte boundary
- while ((addr & 31) != 0) {
- addr++;
- descOffs++;
- }
- descAddr = memAddr.add(descOffs).toInt();
-
- descMr.setInt(descOffs, 0x80000000);
- descMr.setInt(descOffs + 4, ViaRhineConstants.PKT_BUF_SZ);
-
- data = new byte[ViaRhineConstants.PKT_BUF_SZ + 32];
- dataMr = rm.asMemoryResource(data);
-
- memAddr = dataMr.getAddress();
- addr = memAddr.toInt();
- dataOffs = 0;
- // Align on 32-byte boundary
- while ((addr & 31) != 0) {
- addr++;
- dataOffs++;
- }
-
- descMr.setInt(descOffs + 8, memAddr.add(dataOffs).toInt());
- }
-
- void setOwnBit(){
- descMr.setInt(descOffs, descMr.getInt(descOffs) | 0x80000000);
- }
-
- boolean isOwnBit(){
- return (descMr.getInt(descOffs) & 0x80000000) != 0;
- }
-
- void setNextDescAddr(int addr){
- descMr.setInt(descOffs + 12, addr);
- }
-
- void setFrameLength(int size){
- descMr.setInt(descOffs + 4, ((descMr.getInt(descOffs + 4) & ~0x000007FF) | (size & 0x000007FF)));
- }
-
- void setPacket(SocketBuffer sb){
- int ln = sb.getSize();
- log.debug("packetlength: " + ln);
- sb.get(data, dataOffs, 0, ln);
-
- if(ln < ETH_ZLEN + 10){
- Arrays.fill(data, dataOffs + ln, dataOffs + ETH_ZLEN + 10, (byte)0);
- setFrameLength(ETH_ZLEN + 10);
- }
-
- }
-}
Deleted: trunk/net/src/driver/org/jnode/driver/net/via_rhine/TxRing.java
===================================================================
--- trunk/net/src/driver/org/jnode/driver/net/via_rhine/TxRing.java 2007-05-03 06:30:23 UTC (rev 3181)
+++ trunk/net/src/driver/org/jnode/driver/net/via_rhine/TxRing.java 2007-05-05 20:51:01 UTC (rev 3182)
@@ -1,38 +0,0 @@
-/*
- * $Id$
- */
-package org.jnode.driver.net.via_rhine;
-
-import org.jnode.system.ResourceManager;
-import org.jnode.net.SocketBuffer;
-
-/**
- * @author Levente S\xE1ntha
- */
-public class TxRing {
- TxDesc[] ring;
- int ringAddr;
- int current;
- TxRing(ResourceManager rm){
- ring = new TxDesc[ViaRhineConstants.TX_RING_SIZE];
- for(int i = 0; i < ViaRhineConstants.TX_RING_SIZE; i++){
- ring[i] = new TxDesc(rm);
- if(i == 0)
- ringAddr = ring[0].descAddr;
- else
- ring[i - 1].setNextDescAddr(ring[i].descAddr);
-
-
- }
- ring[ViaRhineConstants.TX_RING_SIZE - 1].setNextDescAddr(ringAddr);
- }
-
-
- TxDesc currentDesc(){
- return ring[current];
- }
-
- void next(){
- current = (current + 1) % ViaRhineConstants.TX_RING_SIZE;
- }
-}
Modified: trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineConstants.java
===================================================================
--- trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineConstants.java 2007-05-03 06:30:23 UTC (rev 3181)
+++ trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineConstants.java 2007-05-05 20:51:01 UTC (rev 3182)
@@ -6,72 +6,71 @@
/**
* @author Levente S\xE1ntha
*/
-public interface ViaRhineConstants {
- byte ioaddr = 0;
- byte byPAR0 = ioaddr;
- byte byRCR = ioaddr + 6;
- byte byTCR = ioaddr + 7;
- byte byCR0 = ioaddr + 8;
- byte byCR1 = ioaddr + 9;
- byte byISR0 = ioaddr + 0x0c;
- byte byISR1 = ioaddr + 0x0d;
- byte byIMR0 = ioaddr + 0x0e;
- byte byIMR1 = ioaddr + 0x0f;
- byte byMAR0 = ioaddr + 0x10;
- byte byMAR1 = ioaddr + 0x11;
- byte byMAR2 = ioaddr + 0x12;
- byte byMAR3 = ioaddr + 0x13;
- byte byMAR4 = ioaddr + 0x14;
- byte byMAR5 = ioaddr + 0x15;
- byte byMAR6 = ioaddr + 0x16;
- byte byMAR7 = ioaddr + 0x17;
- int dwCurrentRxDescAddr = ioaddr + 0x18;
- int dwCurrentTxDescAddr = ioaddr + 0x1c;
- int dwCurrentRDSE0 = ioaddr + 0x20;
- int dwCurrentRDSE1 = ioaddr + 0x24;
- int dwCurrentRDSE2 = ioaddr + 0x28;
- int dwCurrentRDSE3 = ioaddr + 0x2c;
- int dwNextRDSE0 = ioaddr + 0x30;
- int dwNextRDSE1 = ioaddr + 0x34;
- int dwNextRDSE2 = ioaddr + 0x38;
- int dwNextRDSE3 = ioaddr + 0x3c;
- int dwCurrentTDSE0 = ioaddr + 0x40;
- int dwCurrentTDSE1 = ioaddr + 0x44;
- int dwCurrentTDSE2 = ioaddr + 0x48;
- int dwCurrentTDSE3 = ioaddr + 0x4c;
- int dwNextTDSE0 = ioaddr + 0x50;
- int dwNextTDSE1 = ioaddr + 0x54;
- int dwNextTDSE2 = ioaddr + 0x58;
- int dwNextTDSE3 = ioaddr + 0x5c;
- int dwCurrRxDMAPtr = ioaddr + 0x60;
- int dwCurrTxDMAPtr = ioaddr + 0x64;
- int byMPHY = ioaddr + 0x6c;
- int byMIISR = ioaddr + 0x6d;
- int byBCR0 = ioaddr + 0x6e;
- int byBCR1 = ioaddr + 0x6f;
- int byMIICR = ioaddr + 0x70;
- int byMIIAD = ioaddr + 0x71;
- int wMIIDATA = ioaddr + 0x72;
- int byEECSR = ioaddr + 0x74;
- int byTEST = ioaddr + 0x75;
- int byGPIO = ioaddr + 0x76;
- int byCFGA = ioaddr + 0x78;
- int byCFGB = ioaddr + 0x79;
- int byCFGC = ioaddr + 0x7a;
- int byCFGD = ioaddr + 0x7b;
- int wTallyCntMPA = ioaddr + 0x7c;
- int wTallyCntCRC = ioaddr + 0x7d;
- int bySTICKHW = ioaddr + 0x83;
- int byWOLcrClr = ioaddr + 0xA4;
- int byWOLcgClr = ioaddr + 0xA7;
- int byPwrcsrClr = ioaddr + 0xAC;
+interface ViaRhineConstants {
+ int byPAR0 = 0;
+ int byRCR = 6;
+ int byTCR = 7;
+ int byCR0 = 8;
+ int byCR1 = 9;
+ int byISR0 = 0x0c;
+ int byISR1 = 0x0d;
+ int byIMR0 = 0x0e;
+ int byIMR1 = 0x0f;
+ int byMAR0 = 0x10;
+ int byMAR1 = 0x11;
+ int byMAR2 = 0x12;
+ int byMAR3 = 0x13;
+ int byMAR4 = 0x14;
+ int byMAR5 = 0x15;
+ int byMAR6 = 0x16;
+ int byMAR7 = 0x17;
+ int dwCurrentRxDescAddr = 0x18;
+ int dwCurrentTxDescAddr = 0x1c;
+ int dwCurrentRDSE0 = 0x20;
+ int dwCurrentRDSE1 = 0x24;
+ int dwCurrentRDSE2 = 0x28;
+ int dwCurrentRDSE3 = 0x2c;
+ int dwNextRDSE0 = 0x30;
+ int dwNextRDSE1 = 0x34;
+ int dwNextRDSE2 = 0x38;
+ int dwNextRDSE3 = 0x3c;
+ int dwCurrentTDSE0 = 0x40;
+ int dwCurrentTDSE1 = 0x44;
+ int dwCurrentTDSE2 = 0x48;
+ int dwCurrentTDSE3 = 0x4c;
+ int dwNextTDSE0 = 0x50;
+ int dwNextTDSE1 = 0x54;
+ int dwNextTDSE2 = 0x58;
+ int dwNextTDSE3 = 0x5c;
+ int dwCurrRxDMAPtr = 0x60;
+ int dwCurrTxDMAPtr = 0x64;
+ int byMPHY = 0x6c;
+ int byMIISR = 0x6d;
+ int byBCR0 = 0x6e;
+ int byBCR1 = 0x6f;
+ int byMIICR = 0x70;
+ int byMIIAD = 0x71;
+ int wMIIDATA = 0x72;
+ int byEECSR = 0x74;
+ int byTEST = 0x75;
+ int byGPIO = 0x76;
+ int byCFGA = 0x78;
+ int byCFGB = 0x79;
+ int byCFGC = 0x7a;
+ int byCFGD = 0x7b;
+ int wTallyCntMPA = 0x7c;
+ int wTallyCntCRC = 0x7d;
+ int bySTICKHW = 0x83;
+ int byWOLcrClr = 0xA4;
+ int byWOLcgClr = 0xA7;
+ int byPwrcsrClr = 0xAC;
+
/*--------------------- Exioaddr Definitions -------------------------*/
-/*
- * Bits in the RCR register
- */
-
+ /*
+ * Bits in the RCR register
+ */
int RCR_RRFT2 = 0x80;
int RCR_RRFT1 = 0x40;
int RCR_RRFT0 = 0x20;
@@ -81,10 +80,9 @@
int RCR_AR = 0x02;
int RCR_SEP = 0x01;
-/*
- * Bits in the TCR register
- */
-
+ /*
+ * Bits in the TCR register
+ */
int TCR_RTSF = 0x80;
int TCR_RTFT1 = 0x40;
int TCR_RTFT0 = 0x20;
@@ -92,10 +90,9 @@
int TCR_LB1 = 0x04; /* loopback[1] */
int TCR_LB0 = 0x02; /* loopback[0] */
-/*
- * Bits in the CR0 register
- */
-
+ /*
+ * Bits in the CR0 register
+ */
int CR0_RDMD = 0x40; /* rx descriptor polling demand */
int CR0_TDMD = 0x20; /* tx descriptor polling demand */
int CR0_TXON = 0x10;
@@ -104,10 +101,9 @@
int CR0_STRT = 0x02; /* start NIC */
int CR0_INIT = 0x01; /* start init process */
-/*
-* Bits in the CR1 register
-*/
-
+ /*
+ * Bits in the CR1 register
+ */
int CR1_SFRST = 0x80 /* software reset */;
int CR1_RDMD1 = 0x40 /* RDMD1 */;
int CR1_TDMD1 = 0x20 /* TDMD1 */;
@@ -117,10 +113,9 @@
int CR1_ETEN = 0x02 /* early tx mode */;
int CR1_EREN = 0x01 /* early rx mode */;
-/*
- * Bits in the CR register
- */
-
+ /*
+ * Bits in the CR register
+ */
int CR_RDMD = 0x0040 /* rx descriptor polling demand */;
int CR_TDMD = 0x0020 /* tx descriptor polling demand */;
int CR_TXON = 0x0010;
@@ -137,10 +132,9 @@
int CR_ETEN = 0x0200 /* early tx mode */;
int CR_EREN = 0x0100 /* early rx mode */;
-/*
- * Bits in the IMR0 register
- */
-
+ /*
+ * Bits in the IMR0 register
+ */
int IMR0_CNTM = 0x80;
int IMR0_BEM = 0x40;
int IMR0_RUM = 0x20;
@@ -150,14 +144,12 @@
int IMR0_PTXM = 0x02;
int IMR0_PRXM = 0x01;
-/* define imrshadow */
-
+ /* define imrshadow */
int IMRShadow = 0x5AFF;
-/*
- * Bits in the IMR1 register
- */
-
+ /*
+ * Bits in the IMR1 register
+ */
int IMR1_INITM = 0x80;
int IMR1_SRCM = 0x40;
int IMR1_NBFM = 0x10;
@@ -166,10 +158,9 @@
int IMR1_ETM = 0x02;
int IMR1_ERM = 0x01;
-/*
- * Bits in the ISR register
- */
-
+ /*
+ * Bits in the ISR register
+ */
int ISR_INITI = 0x8000;
int ISR_SRCI = 0x4000;
int ISR_ABTI = 0x2000;
@@ -187,10 +178,9 @@
int ISR_PTX = 0x0002;
int ISR_PRX = 0x0001;
-/*
- * Bits in the ISR0 register;
- */
-
+ /*
+ * Bits in the ISR0 register;
+ */
int ISR0_CNT = 0x80;
int ISR0_BE = 0x40;
int ISR0_RU = 0x20;
@@ -200,10 +190,9 @@
int ISR0_PTX = 0x02;
int ISR0_PRX = 0x01;
-/*
- * Bits in the ISR1 register
- */
-
+ /*
+ * Bits in the ISR1 register
+ */
int ISR1_INITI = 0x80;
int ISR1_SRCI = 0x40;
int ISR1_NORBF = 0x10;
@@ -211,23 +200,20 @@
int ISR1_ETI = 0x02;
int ISR1_ERI = 0x01;
-/* ISR ABNORMAL CONDITION */
-
+ /* ISR ABNORMAL CONDITION */
int ISR_ABNORMAL = ISR_BE + ISR_RU + ISR_TU + ISR_CNT + ISR_NORBF + ISR_PKTRA;
-/*
- * Bits in the MIISR register;
- */
-
+ /*
+ * Bits in the MIISR register;
+ */
int MIISR_MIIERR = 0x08;
int MIISR_MRERR = 0x04;
int MIISR_LNKFL = 0x02;
int MIISR_SPEED = 0x01;
-/*
- * Bits in the MIICR register;
- */
-
+ /*
+ * Bits in the MIICR register;
+ */
int MIICR_MAUTO = 0x80;
int MIICR_RCMD = 0x40;
int MIICR_WCMD = 0x20;
@@ -237,10 +223,9 @@
int MIICR_MDI = 0x02;
int MIICR_MDC = 0x01;
-/*
- * Bits in the EECSR register;
- */
-
+ /*
+ * Bits in the EECSR register;
+ */
int EECSR_EEPR = 0x80 /* eeprom programed status, 73h means programed */;
int EECSR_EMBP = 0x40 /* eeprom embeded programming */;
int EECSR_AUTOLD = 0x20 /* eeprom content reload */;
@@ -373,102 +358,47 @@
int PCI_REG_MODE3 = 0x53;
int MODE3_MIION = 0x04; /* in PCI_REG_MOD3 OF PCI space */
-/* Offsets to the device registers. */
- /*
-enum register_offsets {
- StationAddr=0x00, RxConfig=0x06, TxConfig=0x07, ChipCmd=0x08,
- IntrStatus=0x0C, IntrEnable=0x0E,
- MulticastFilter0=0x10, MulticastFilter1=0x14,
- RxRingPtr=0x18, TxRingPtr=0x1C, GFIFOTest=0x54,
- MIIPhyAddr=0x6C, MIIStatus=0x6D, PCIBusConfig=0x6E,
- MIICmd=0x70, MIIRegAddr=0x71, MIIData=0x72, MACRegEEcsr=0x74,
- ConfigA=0x78, ConfigB=0x79, ConfigC=0x7A, ConfigD=0x7B,
- RxMissed=0x7C, RxCRCErrs=0x7E, MiscCmd=0x81,
- StickyHW=0x83, IntrStatus2=0x84, WOLcrClr=0xA4, WOLcgClr=0xA7,
- PwrcsrClr=0xAC,
-};
-*/
+ /* Offsets to the device registers. */
+ int StationAddr = 0x00, RxConfig = 0x06, TxConfig = 0x07, ChipCmd = 0x08,
+ IntrStatus = 0x0C, IntrEnable = 0x0E,
+ MulticastFilter0 = 0x10, MulticastFilter1 = 0x14,
+ RxRingPtr = 0x18, TxRingPtr = 0x1C, GFIFOTest = 0x54,
+ MIIPhyAddr = 0x6C, MIIStatus = 0x6D, PCIBusConfig = 0x6E,
+ MIICmd = 0x70, MIIRegAddr = 0x71, MIIData = 0x72, MACRegEEcsr = 0x74,
+ ConfigA = 0x78, ConfigB = 0x79, ConfigC = 0x7A, ConfigD = 0x7B,
+ RxMissed = 0x7C, RxCRCErrs = 0x7E, MiscCmd = 0x81,
+ StickyHW = 0x83, IntrStatus2 = 0x84, WOLcrClr = 0xA4, WOLcgClr = 0xA7,
+ PwrcsrClr = 0xAC;
-/* Offsets to the device registers. */
- int StationAddr=0x00, RxConfig=0x06, TxConfig=0x07, ChipCmd=0x08,
- IntrStatus=0x0C, IntrEnable=0x0E,
- MulticastFilter0=0x10, MulticastFilter1=0x14,
- RxRingPtr=0x18, TxRingPtr=0x1C, GFIFOTest=0x54,
- MIIPhyAddr=0x6C, MIIStatus=0x6D, PCIBusConfig=0x6E,
- MIICmd=0x70, MIIRegAddr=0x71, MIIData=0x72, MACRegEEcsr=0x74,
- ConfigA=0x78, ConfigB=0x79, ConfigC=0x7A, ConfigD=0x7B,
- RxMissed=0x7C, RxCRCErrs=0x7E, MiscCmd=0x81,
- StickyHW=0x83, IntrStatus2=0x84, WOLcrClr=0xA4, WOLcgClr=0xA7,
- PwrcsrClr=0xAC;
+ /* Bits in the interrupt status/mask registers. */
+ int IntrRxDone = 0x0001, IntrRxErr = 0x0004, IntrRxEmpty = 0x0020,
+ IntrTxDone = 0x0002, IntrTxError = 0x0008, IntrTxUnderrun = 0x0210,
+ IntrPCIErr = 0x0040,
+ IntrStatsMax = 0x0080, IntrRxEarly = 0x0100,
+ IntrRxOverflow = 0x0400, IntrRxDropped = 0x0800, IntrRxNoBuf = 0x1000,
+ IntrTxAborted = 0x2000, IntrLinkChange = 0x4000,
+ IntrRxWakeUp = 0x8000,
+ IntrNormalSummary = 0x0003, IntrAbnormalSummary = 0xC260,
+ IntrTxDescRace = 0x080000, // mapped from IntrStatus2
+ IntrTxErrSummary = 0x082218;
-/* Bits in the interrupt status/mask registers. */
- /*
-enum intr_status_bits {
- IntrRxDone=0x0001, IntrRxErr=0x0004, IntrRxEmpty=0x0020,
- IntrTxDone=0x0002, IntrTxError=0x0008, IntrTxUnderrun=0x0210,
- IntrPCIErr=0x0040,
- IntrStatsMax=0x0080, IntrRxEarly=0x0100,
- IntrRxOverflow=0x0400, IntrRxDropped=0x0800, IntrRxNoBuf=0x1000,
- IntrTxAborted=0x2000, IntrLinkChange=0x4000,
- IntrRxWakeUp=0x8000,
- IntrNormalSummary=0x0003, IntrAbnormalSummary=0xC260,
- IntrTxDescRace=0x080000, // mapped from IntrStatus2
- IntrTxErrSummary=0x082218,
-};
-/* Bits in the interrupt status/mask registers. */
+ int DEFAULT_INTR = IntrRxDone | IntrRxErr | IntrRxEmpty |
+ IntrRxOverflow | IntrRxDropped | IntrRxNoBuf;
- int IntrRxDone=0x0001, IntrRxErr=0x0004, IntrRxEmpty=0x0020,
- IntrTxDone=0x0002, IntrTxError=0x0008, IntrTxUnderrun=0x0210,
- IntrPCIErr=0x0040,
- IntrStatsMax=0x0080, IntrRxEarly=0x0100,
- IntrRxOverflow=0x0400, IntrRxDropped=0x0800, IntrRxNoBuf=0x1000,
- IntrTxAborted=0x2000, IntrLinkChange=0x4000,
- IntrRxWakeUp=0x8000,
- IntrNormalSummary=0x0003, IntrAbnormalSummary=0xC260,
- IntrTxDescRace=0x080000, // mapped from IntrStatus2
- IntrTxErrSummary=0x082218;
-
-
-
-//#define DEFAULT_INTR (IntrRxDone | IntrRxErr | IntrRxEmpty| IntrRxOverflow | \
-// IntrRxDropped | IntrRxNoBuf)
-
- int DEFAULT_INTR = IntrRxDone | IntrRxErr | IntrRxEmpty|
- IntrRxOverflow | IntrRxDropped | IntrRxNoBuf;
-
-//enum rhine_revs {
-// int VT86C100A = 0x00;
-// int VTunknown0 = 0x20;
-// int VT6102 = 0x40;
-// int VT8231 = 0x50; /* Integrated MAC */
-// int VT8233 = 0x60; /* Integrated MAC */
-// int VT8235 = 0x74; /* Integrated MAC */
-// int VT8237 = 0x78; /* Integrated MAC */
-// int VTunknown1 = 0x7C;
-// int VT6105 = 0x80;
-// int VT6105_B0 = 0x83;
-// int VT6105L = 0x8A;
-// int VT6107 = 0x8C;
-// int VTunknown2 = 0x8E;
-// int VT6105M = 0x90;
-//};
-
-//enum rhine_revs {
- int VT86C100A = 0x00;
- int VTunknown0 = 0x20;
- int VT6102 = 0x40;
- int VT8231 = 0x50; /* Integrated MAC */
- int VT8233 = 0x60; /* Integrated MAC */
- int VT8235 = 0x74; /* Integrated MAC */
- int VT8237 = 0x78; /* Integrated MAC */
- int VTunknown1 = 0x7C;
- int VT6105 = 0x80;
- int VT6105_B0 = 0x83;
- int VT6105L = 0x8A;
- int VT6107 = 0x8C;
- int VTunknown2 = 0x8E;
- int VT6105M = 0x90;
-//};
-
+ //enum rhine_revs
+ int VT86C100A = 0x00;
+ int VTunknown0 = 0x20;
+ int VT6102 = 0x40;
+ int VT8231 = 0x50; /* Integrated MAC */
+ int VT8233 = 0x60; /* Integrated MAC */
+ int VT8235 = 0x74; /* Integrated MAC */
+ int VT8237 = 0x78; /* Integrated MAC */
+ int VTunknown1 = 0x7C;
+ int VT6105 = 0x80;
+ int VT6105_B0 = 0x83;
+ int VT6105L = 0x8A;
+ int VT6107 = 0x8C;
+ int VTunknown2 = 0x8E;
+ int VT6105M = 0x90;
}
\ No newline at end of file
Modified: trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineCore.java
===================================================================
--- trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineCore.java 2007-05-03 06:30:23 UTC (rev 3181)
+++ trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineCore.java 2007-05-05 20:51:01 UTC (rev 3182)
@@ -21,47 +21,33 @@
import static org.jnode.net.ethernet.EthernetConstants.*;
import static org.jnode.driver.net.via_rhine.ViaRhineConstants.*;
import org.jnode.driver.net.ethernet.spi.Flags;
-import org.jnode.shell.CommandLine;
-import org.jnode.shell.help.ParsedArguments;
import java.io.*;
-import java.net.URL;
/**
* @author Levente S\xE1ntha
*/
-public class ViaRhineCore extends AbstractDeviceCore implements IRQHandler {
+class ViaRhineCore extends AbstractDeviceCore implements IRQHandler {
private final int ioBase;
private final IOResource io;
private final IRQResource irq;
private EthernetAddress hwAddress;
private ViaRhineDriver driver;
+ private ViaRhineRxRing rxRing;
+ private ViaRhineTxRing txRing;
- /*
- char devname[8]; // Used only for kernel debugging.
- const char *product_name;
- struct rhine_rx_desc *rx_ring;
- struct rhine_tx_desc *tx_ring;
- char *rx_buffs[RX_RING_SIZE];
- char *tx_buffs[TX_RING_SIZE];
+ /*
// temporary Rx buffers.
int chip_id;
int chip_revision;
- unsigned short ioaddr;
- unsigned int cur_rx, cur_tx; // The next free and used entries
+
unsigned int dirty_rx, dirty_tx;
// The saved address of a sent-in-place packet/buffer, for skfree().
struct sk_buff *tx_skbuff[TX_RING_SIZE];
unsigned char mc_filter[8]; // Current multicast filter.
char phys[4]; // MII device addresses.
- unsigned int tx_full:1; // The Tx queue is full.
- unsigned int full_duplex:1; // Full-duplex operation requested.
- unsigned int default_port:4; // Last dev->if_port value.
- unsigned int media2:4; // Secondary monitored media port.
- unsigned int medialock:1; // Don't sense media type.
- unsigned int mediasense:1; // Media sensing in progress.
*/
@@ -86,9 +72,6 @@
int medialock = 1; // Don't sense media type.
int mediasense = 1; // Media sensing in progress.
- RxRing rxRing;
- TxRing txRing;
-
public ViaRhineCore(ViaRhineDriver driver, Device device, ResourceOwner owner, Flags flags)
throws DriverException, ResourceNotFreeException{
this.driver = driver;
@@ -164,7 +147,7 @@
Thread.sleep(50);
if(!rxRing.currentDesc().isOwnBit()){
- SocketBuffer packet = rxRing.getPacket();
+ SocketBuffer packet = rxRing.currentDesc().getPacket();
driver.onReceive(packet);
log.debug("New packet");
log.debug(packet.getLinkLayerHeader().getSourceAddress());
@@ -203,22 +186,9 @@
setIRQEnabled(true);
}
- int my_INTR = IntrTxDone | IntrTxError | IntrTxUnderrun;
+ private static final int my_INTR = IntrTxDone | IntrTxError | IntrTxUnderrun;
private void printIntrStatus(){
- /*
- int IntrRxDone=0x0001, IntrRxErr=0x0004, IntrRxEmpty=0x0020,
- IntrTxDone=0x0002, IntrTxError=0x0008, IntrTxUnderrun=0x0210,
- IntrPCIErr=0x0040,
- IntrStatsMax=0x0080, IntrRxEarly=0x0100,
- IntrRxOverflow=0x0400, IntrRxDropped=0x0800, IntrRxNoBuf=0x1000,
- IntrTxAborted=0x2000, IntrLinkChange=0x4000,
- IntrRxWakeUp=0x8000,
- IntrNormalSummary=0x0003, IntrAbnormalSummary=0xC260,
- IntrTxDescRace=0x080000, // mapped from IntrStatus2
- IntrTxErrSummary=0x082218;
- */
-
int intr_status = getIntrStatus();
log.debug("Interrupt status word: 0x" + NumberUtils.hex(intr_status));
@@ -299,7 +269,6 @@
}
public HardwareAddress getHwAddress() {
- log.debug("getHwAddress");
return hwAddress;
}
@@ -311,16 +280,13 @@
public void disable() {
log.debug("disable()");
- /* merge reset and disable */
- //rhine_reset(nic);
+ // merge reset and disable
reset();
- /* Switch to loopback mode to avoid hardware races. */
- //writeb(0x60 | 0x01, byTCR);
+ // Switch to loopback mode to avoid hardware races.
setReg8(byTCR, 0x60 | 0x01);
- /* Stop the chip's Tx and Rx processes. */
- //writew(CR_STOP, byCR0);
+ // Stop the chip's Tx and Rx processes.
setReg16(byCR0, CR_STOP);
}
@@ -330,15 +296,8 @@
MIIDelay();
//init ring
- try {
- final ResourceManager rm = InitialNaming.lookup(ResourceManager.NAME);
- rxRing = new RxRing(rm);
- log.debug("Rx ring initialised");
- txRing = new TxRing(rm);
- log.debug("Tx ring initialised");
- } catch (NameNotFoundException ex) {
- throw new RuntimeException("Cannot find ResourceManager");
- }
+ initRing();
+
/*write TD RD Descriptor to MAC */
setReg32(dwCurrentRxDescAddr, rxRing.ringAddr);
@@ -398,60 +357,24 @@
setReg8(byRCR, 0x60 | rx_mode);
}
- private void reloadEEPROM()
- {
- //int i;
- //outb(0x20, byEECSR);
+ private void reloadEEPROM() {
setReg8(byEECSR, 0x20);
-
/* Typically 2 cycles to reload. */
- //for (i = 0; i < 150; i++)
- // if (! (inb(byEECSR) & 0x20))
- // break;
-
for (int i = 0; i < 150; i++)
if ( (getReg8(byEECSR) & 0x20) == 0)
break;
}
-
void initRing () {
- int i;
- tx_full = 0;
- cur_rx = cur_tx = 0;
- dirty_rx = dirty_tx = 0;
-
- for (i = 0; i < RX_RING_SIZE; i++) {
-
-// rx_ring[i].rxStatus_bits.own_bit = 1;
-// rx_ring[i].rxControl_bits.rx_buf_size = 1536;
-
- //--rx_ring[i].buf_addr_1 = virt_to_bus (tp->rx_buffs[i]);
- //--rx_ring[i].buf_addr_2 = virt_to_bus (&tp->rx_ring[i + 1]);
-
- /* printf("[%d]buf1=%hX,buf2=%hX",i,tp->rx_ring[i].buf_addr_1,tp->rx_ring[i].buf_addr_2); */
+ try {
+ final ResourceManager rm = InitialNaming.lookup(ResourceManager.NAME);
+ rxRing = new ViaRhineRxRing(rm);
+ log.debug("Rx ring initialised");
+ txRing = new ViaRhineTxRing(rm);
+ log.debug("Tx ring initialised");
+ } catch (NameNotFoundException ex) {
+ throw new RuntimeException("Cannot find ResourceManager");
}
- /* Mark the last entry as wrapping the ring. */
- /* tp->rx_ring[i-1].rx_ctrl.bits.rx_buf_size =1518; */
-
- //--rx_ring[i - 1].buf_addr_2 = virt_to_bus (&tp->rx_ring[0]);
-
- /*printf("[%d]buf1=%hX,buf2=%hX",i-1,tp->rx_ring[i-1].buf_addr_1,tp->rx_ring[i-1].buf_addr_2); */
-
- /* The Tx buffer descriptor is filled in as needed, but we
- do need to clear the ownership bit. */
-
- for (i = 0; i < TX_RING_SIZE; i++) {
-
-// tx_ring[i].txStatus_lw = 0;
-// tx_ring[i].txControl_lw = 0x00e08000;
- //--tx_ring[i].buf_addr_1 = virt_to_bus (tp->tx_buffs[i]);
- //--tx_ring[i].buf_addr_2 = virt_to_bus (&tp->tx_ring[i + 1]);
- /* printf("[%d]buf1=%hX,buf2=%hX",i,tp->tx_ring[i].buf_addr_1,tp->tx_ring[i].buf_addr_2); */
- }
-
- //--tx_ring[i - 1].buf_addr_2 = virt_to_bus (&tp->tx_ring[0]);
- /* printf("[%d]buf1=%hX,buf2=%hX",i,tp->tx_ring[i-1].buf_addr_1,tp->tx_ring[i-1].buf_addr_2); */
}
private int queryAuto () {
@@ -684,7 +607,6 @@
// destination.writeTo(buf, 0);
// hwAddress.writeTo(buf, 6);
txRing.currentDesc().setOwnBit();
- txRing.currentDesc().setFrameLength(buf.getSize());
txRing.currentDesc().setPacket(buf);
log.debug("\n" + hexDump(buf.toByteArray()) + "\n");
Added: trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineDesc.java
===================================================================
--- trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineDesc.java (rev 0)
+++ trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineDesc.java 2007-05-05 20:51:01 UTC (rev 3182)
@@ -0,0 +1,67 @@
+/*
+ * $Id$
+ */
+package org.jnode.driver.net.via_rhine;
+
+import org.jnode.system.MemoryResource;
+import org.jnode.system.ResourceManager;
+import static org.jnode.driver.net.via_rhine.ViaRhineConstants.PKT_BUF_SZ;
+import org.apache.log4j.Logger;
+import org.vmmagic.unboxed.Address;
+
+/**
+ * @author Levente S\xE1ntha
+ */
+class ViaRhineDesc {
+ private static final int OWN_BIT_MASK = 0x80000000;
+ protected final Logger log = Logger.getLogger(getClass());
+ byte[] desc;
+ int descOffs;
+ MemoryResource descMr;
+ byte[] data;
+ int dataOffs;
+ MemoryResource dataMr;
+ int descAddr;
+
+ public ViaRhineDesc(ResourceManager rm) {
+ desc = new byte[16 + 32];
+ descMr = rm.asMemoryResource(desc);
+ Address descma = descMr.getAddress();
+ descOffs = align32(descma);
+ descAddr = descma.add(descOffs).toInt();
+ data = new byte[PKT_BUF_SZ + 32];
+ dataMr = rm.asMemoryResource(data);
+ Address datma = dataMr.getAddress();
+ dataOffs = align32(datma);
+ descMr.setInt(descOffs + 8, datma.add(dataOffs).toInt());
+ }
+
+ void setOwnBit(){
+ descMr.setInt(descOffs, descMr.getInt(descOffs) | OWN_BIT_MASK);
+ }
+
+ boolean isOwnBit(){
+ return (descMr.getInt(descOffs) & OWN_BIT_MASK) != 0;
+ }
+
+ void setNextDescAddr(int addr){
+ descMr.setInt(descOffs + 12, addr);
+ }
+
+ /**
+ * Align an addres on 32-byte boundary.
+ * @param addr the address
+ * @return the the aligned address offset relative to addr
+ */
+ private int align32(Address addr){
+ int i_addr = addr.toInt();
+ int offs = 0;
+
+ while ((i_addr & 31) != 0) {
+ i_addr++;
+ offs++;
+ }
+
+ return offs;
+ }
+}
Modified: trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineFlags.java
===================================================================
--- trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineFlags.java 2007-05-03 06:30:23 UTC (rev 3181)
+++ trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineFlags.java 2007-05-05 20:51:01 UTC (rev 3182)
@@ -9,7 +9,7 @@
/**
* @author Levente S\xE1ntha
*/
-public class ViaRhineFlags implements Flags {
+class ViaRhineFlags implements Flags {
private final String name;
public ViaRhineFlags(ConfigurationElement config) {
Added: trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineRing.java
===================================================================
--- trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineRing.java (rev 0)
+++ trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineRing.java 2007-05-05 20:51:01 UTC (rev 3182)
@@ -0,0 +1,42 @@
+/*
+ * $Id$
+ */
+package org.jnode.driver.net.via_rhine;
+
+import org.jnode.system.ResourceManager;
+import java.util.Arrays;
+
+/**
+ * @author Levente S\xE1ntha
+ */
+abstract class ViaRhineRing<T extends ViaRhineDesc> {
+ final int RING_SIZE;
+ ViaRhineDesc[] ring;
+ int ringAddr;
+ int current;
+
+ ViaRhineRing(ResourceManager rm, int size){
+ this.RING_SIZE = size;
+ ring = new ViaRhineDesc[RING_SIZE];
+ for(int i = 0; i < RING_SIZE; i++){
+ ring[i] = createDescr(rm);
+ if(i == 0)
+ ringAddr = ring[0].descAddr;
+ else
+ ring[i - 1].setNextDescAddr(ring[i].descAddr);
+
+
+ }
+ ring[RING_SIZE - 1].setNextDescAddr(ringAddr);
+ }
+
+ abstract ViaRhineDesc createDescr(ResourceManager rm);
+
+ T currentDesc(){
+ return (T) ring[current];
+ }
+
+ void next(){
+ current = (current + 1) % RING_SIZE;
+ }
+}
Copied: trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineRxRing.java (from rev 3178, trunk/net/src/driver/org/jnode/driver/net/via_rhine/RxRing.java)
===================================================================
--- trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineRxRing.java (rev 0)
+++ trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineRxRing.java 2007-05-05 20:51:01 UTC (rev 3182)
@@ -0,0 +1,45 @@
+/*
+ * $Id$
+ */
+package org.jnode.driver.net.via_rhine;
+
+import static org.jnode.driver.net.via_rhine.ViaRhineConstants.*;
+import org.jnode.system.ResourceManager;
+import org.jnode.net.SocketBuffer;
+
+/**
+ * @author Levente S\xE1ntha
+ */
+class ViaRhineRxRing extends ViaRhineRing<ViaRhineRxRing.RxDesc> {
+ ViaRhineRxRing(ResourceManager rm){
+ super(rm, RX_RING_SIZE);
+ }
+
+ RxDesc createDescr(ResourceManager rm) {
+ return new RxDesc(rm);
+ }
+
+ static class RxDesc extends ViaRhineDesc{
+ RxDesc(ResourceManager rm){
+ super(rm);
+ setOwnBit();
+ setDataBufferSize(PKT_BUF_SZ);
+ }
+
+ private void setDataBufferSize(int size) {
+ descMr.setInt(descOffs + 4, size);
+ }
+
+ int getFrameLength(){
+ return descMr.getChar(descOffs + 2) & 0x000007FF;
+ }
+
+ SocketBuffer getPacket(){
+ int ln = getFrameLength();
+ log.debug("packetlength: " + ln);
+ byte[] buf = new byte[ln];
+ System.arraycopy(data, dataOffs, buf, 0, ln);
+ return new SocketBuffer(buf, 0, ln);
+ }
+ }
+}
Copied: trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineTxRing.java (from rev 3178, trunk/net/src/driver/org/jnode/driver/net/via_rhine/TxRing.java)
===================================================================
--- trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineTxRing.java (rev 0)
+++ trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineTxRing.java 2007-05-05 20:51:01 UTC (rev 3182)
@@ -0,0 +1,52 @@
+/*
+ * $Id$
+ */
+package org.jnode.driver.net.via_rhine;
+
+import java.util.Arrays;
+import static org.jnode.driver.net.via_rhine.ViaRhineConstants.PKT_BUF_SZ;
+import static org.jnode.driver.net.via_rhine.ViaRhineConstants.TX_RING_SIZE;
+import org.jnode.net.SocketBuffer;
+import static org.jnode.net.ethernet.EthernetConstants.ETH_ZLEN;
+import org.jnode.system.ResourceManager;
+
+/**
+ * @author Levente S\xE1ntha
+ */
+class ViaRhineTxRing extends ViaRhineRing<ViaRhineTxRing.TxDesc> {
+ ViaRhineTxRing(ResourceManager rm) {
+ super(rm, TX_RING_SIZE);
+ }
+
+ TxDesc createDescr(ResourceManager rm) {
+ return new TxDesc(rm);
+ }
+
+ static class TxDesc extends ViaRhineDesc {
+ TxDesc(ResourceManager rm) {
+ super(rm);
+ setControlStatus();
+ }
+
+ private void setControlStatus() {
+ descMr.setInt(descOffs + 4, descMr.getInt(descOffs + 4) | 0x00e08000);
+ }
+
+ void setFrameLength(int size) {
+ descMr.setInt(descOffs + 4, ((descMr.getInt(descOffs + 4) & ~0x000007FF) | (size & 0x000007FF)));
+ }
+
+ void setPacket(SocketBuffer sb) {
+ int size = sb.getSize();
+ log.debug("packetlength: " + size);
+ sb.get(data, dataOffs, 0, size);
+
+ if (size < ETH_ZLEN) {
+ Arrays.fill(data, dataOffs + size, dataOffs + ETH_ZLEN, (byte) 0);
+ setFrameLength(ETH_ZLEN);
+ } else {
+ setFrameLength(size);
+ }
+ }
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2007-05-03 06:30:26
|
Revision: 3181
http://jnode.svn.sourceforge.net/jnode/?rev=3181&view=rev
Author: lsantha
Date: 2007-05-02 23:30:23 -0700 (Wed, 02 May 2007)
Log Message:
-----------
Generified.
Modified Paths:
--------------
trunk/core/src/core/org/jnode/util/AccessControllerUtils.java
Modified: trunk/core/src/core/org/jnode/util/AccessControllerUtils.java
===================================================================
--- trunk/core/src/core/org/jnode/util/AccessControllerUtils.java 2007-05-02 20:47:08 UTC (rev 3180)
+++ trunk/core/src/core/org/jnode/util/AccessControllerUtils.java 2007-05-03 06:30:23 UTC (rev 3181)
@@ -38,8 +38,7 @@
* @return
* @throws Exception
*/
- public static Object doPrivileged(PrivilegedExceptionAction action)
- throws Exception {
+ public static <T> T doPrivileged(PrivilegedExceptionAction<T> action) throws Exception {
try {
return AccessController.doPrivileged(action);
} catch (PrivilegedActionException ex) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2007-05-02 20:47:11
|
Revision: 3180
http://jnode.svn.sourceforge.net/jnode/?rev=3180&view=rev
Author: lsantha
Date: 2007-05-02 13:47:08 -0700 (Wed, 02 May 2007)
Log Message:
-----------
via-rhine nic driver, initial commit.
Added Paths:
-----------
trunk/net/descriptors/org.jnode.driver.net.via_rhine.xml
Added: trunk/net/descriptors/org.jnode.driver.net.via_rhine.xml
===================================================================
--- trunk/net/descriptors/org.jnode.driver.net.via_rhine.xml (rev 0)
+++ trunk/net/descriptors/org.jnode.driver.net.via_rhine.xml 2007-05-02 20:47:08 UTC (rev 3180)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plugin SYSTEM "jnode.dtd">
+
+<plugin id="org.jnode.driver.net.via_rhine"
+ name="JNode VIA Rhine driver"
+ version="@VERSION@"
+ license-name="lgpl"
+ provider-name="JNode.org">
+
+ <requires>
+ <import plugin="org.jnode.driver.bus.pci"/>
+ <import plugin="org.jnode.driver.net.ethernet"/>
+ <import plugin="org.jnode.net"/>
+ </requires>
+
+ <runtime>
+ <library name="jnode-net.jar">
+ <export name="org.jnode.driver.net.via_rhine.*"/>
+ </library>
+ </runtime>
+
+ <extension point="org.jnode.driver.mappers">
+ <mapper id="1106:3065" name="VT6102" driver-class="org.jnode.driver.net.via_rhine.ViaRhineDriver" class="org.jnode.driver.bus.pci.PCIDeviceToDriverMapper"/>
+ </extension>
+
+ <extension point="org.jnode.security.permissions">
+ <permission class="org.jnode.system.ResourcePermission" name="ioports"/>
+ <permission class="org.jnode.system.ResourcePermission" name="irq"/>
+ </extension>
+
+</plugin>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2007-05-02 20:46:24
|
Revision: 3179
http://jnode.svn.sourceforge.net/jnode/?rev=3179&view=rev
Author: lsantha
Date: 2007-05-02 13:46:19 -0700 (Wed, 02 May 2007)
Log Message:
-----------
via-rhine nic driver, initial commit.
Modified Paths:
--------------
trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineCore.java
Modified: trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineCore.java
===================================================================
--- trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineCore.java 2007-05-02 20:44:01 UTC (rev 3178)
+++ trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineCore.java 2007-05-02 20:46:19 UTC (rev 3179)
@@ -65,8 +65,8 @@
*/
- ViaRhineRxDescriptor[] rx_ring = new ViaRhineRxDescriptor[RX_RING_SIZE];
- ViaRhineTxDescriptor[] tx_ring = new ViaRhineTxDescriptor[TX_RING_SIZE];
+ //ViaRhineRxDescriptor[] rx_ring = new ViaRhineRxDescriptor[RX_RING_SIZE];
+ //ViaRhineTxDescriptor[] tx_ring = new ViaRhineTxDescriptor[TX_RING_SIZE];
byte[] rx_buffs = new byte[RX_RING_SIZE];
byte[] tx_buffs = new byte[TX_RING_SIZE];
@@ -423,8 +423,8 @@
for (i = 0; i < RX_RING_SIZE; i++) {
- rx_ring[i].rxStatus_bits.own_bit = 1;
- rx_ring[i].rxControl_bits.rx_buf_size = 1536;
+// rx_ring[i].rxStatus_bits.own_bit = 1;
+// rx_ring[i].rxControl_bits.rx_buf_size = 1536;
//--rx_ring[i].buf_addr_1 = virt_to_bus (tp->rx_buffs[i]);
//--rx_ring[i].buf_addr_2 = virt_to_bus (&tp->rx_ring[i + 1]);
@@ -443,8 +443,8 @@
for (i = 0; i < TX_RING_SIZE; i++) {
- tx_ring[i].txStatus_lw = 0;
- tx_ring[i].txControl_lw = 0x00e08000;
+// tx_ring[i].txStatus_lw = 0;
+// tx_ring[i].txControl_lw = 0x00e08000;
//--tx_ring[i].buf_addr_1 = virt_to_bus (tp->tx_buffs[i]);
//--tx_ring[i].buf_addr_2 = virt_to_bus (&tp->tx_ring[i + 1]);
/* printf("[%d]buf1=%hX,buf2=%hX",i,tp->tx_ring[i].buf_addr_1,tp->tx_ring[i].buf_addr_2); */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2007-05-02 20:44:15
|
Revision: 3178
http://jnode.svn.sourceforge.net/jnode/?rev=3178&view=rev
Author: lsantha
Date: 2007-05-02 13:44:01 -0700 (Wed, 02 May 2007)
Log Message:
-----------
via-rhine nic driver, initial commit.
Added Paths:
-----------
trunk/net/src/driver/org/jnode/driver/net/via_rhine/RxDesc.java
trunk/net/src/driver/org/jnode/driver/net/via_rhine/RxRing.java
trunk/net/src/driver/org/jnode/driver/net/via_rhine/TxDesc.java
trunk/net/src/driver/org/jnode/driver/net/via_rhine/TxRing.java
trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineCore.java
trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineDriver.java
trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineFlags.java
Added: trunk/net/src/driver/org/jnode/driver/net/via_rhine/RxDesc.java
===================================================================
--- trunk/net/src/driver/org/jnode/driver/net/via_rhine/RxDesc.java (rev 0)
+++ trunk/net/src/driver/org/jnode/driver/net/via_rhine/RxDesc.java 2007-05-02 20:44:01 UTC (rev 3178)
@@ -0,0 +1,81 @@
+/*
+ * $Id$
+ */
+package org.jnode.driver.net.via_rhine;
+
+import org.jnode.system.ResourceManager;
+import org.jnode.system.MemoryResource;
+import org.jnode.net.SocketBuffer;
+import org.apache.log4j.Logger;
+import static org.jnode.driver.net.via_rhine.ViaRhineConstants.*;
+import org.vmmagic.unboxed.Address;
+
+
+/**
+ * @author Levente S\xE1ntha
+ */
+public class RxDesc {
+ protected final Logger log = Logger.getLogger(getClass());
+ byte[] desc;
+ int descOffs;
+ MemoryResource descMr;
+ byte[] data;
+ int dataOffs;
+ MemoryResource dataMr;
+ int descAddr;
+ RxDesc(ResourceManager rm){
+ desc = new byte[16 + 32];
+ descMr = rm.asMemoryResource(desc);
+ Address memAddr = descMr.getAddress();
+
+ int addr = memAddr.toInt();
+ descOffs = 0;
+ // Align on 32-byte boundary
+ while ((addr & 31) != 0) {
+ addr++;
+ descOffs++;
+ }
+ descAddr = memAddr.add(descOffs).toInt();
+
+ descMr.setInt(descOffs, 0x80000000);
+ descMr.setInt(descOffs + 4, PKT_BUF_SZ);
+
+ data = new byte[PKT_BUF_SZ + 32];
+ dataMr = rm.asMemoryResource(data);
+
+ memAddr = dataMr.getAddress();
+ addr = memAddr.toInt();
+ dataOffs = 0;
+ // Align on 32-byte boundary
+ while ((addr & 31) != 0) {
+ addr++;
+ dataOffs++;
+ }
+
+ descMr.setInt(descOffs + 8, memAddr.add(dataOffs).toInt());
+ }
+
+ void setOwnBit(){
+ descMr.setInt(descOffs, descMr.getInt(descOffs) | 0x80000000);
+ }
+
+ boolean isOwnBit(){
+ return (descMr.getInt(descOffs) & 0x80000000) != 0;
+ }
+
+ void setNextDescAddr(int addr){
+ descMr.setInt(descOffs + 12, addr);
+ }
+
+ int frameLength(){
+ return descMr.getChar(descOffs + 2) & 0x000007FF;
+ }
+
+ SocketBuffer getPacket(){
+ int ln = frameLength();
+ log.debug("packetlength: " + ln);
+ byte[] buf = new byte[ln];
+ System.arraycopy(data, dataOffs, buf, 0, ln);
+ return new SocketBuffer(buf, 0, ln);
+ }
+}
Added: trunk/net/src/driver/org/jnode/driver/net/via_rhine/RxRing.java
===================================================================
--- trunk/net/src/driver/org/jnode/driver/net/via_rhine/RxRing.java (rev 0)
+++ trunk/net/src/driver/org/jnode/driver/net/via_rhine/RxRing.java 2007-05-02 20:44:01 UTC (rev 3178)
@@ -0,0 +1,43 @@
+/*
+ * $Id$
+ */
+package org.jnode.driver.net.via_rhine;
+
+import static org.jnode.driver.net.via_rhine.ViaRhineConstants.*;
+import org.jnode.system.ResourceManager;
+import org.jnode.net.SocketBuffer;
+
+/**
+ * @author Levente S\xE1ntha
+ */
+public class RxRing {
+ RxDesc[] ring;
+ int ringAddr;
+ int current;
+ RxRing(ResourceManager rm){
+ ring = new RxDesc[RX_RING_SIZE];
+ for(int i = 0; i < RX_RING_SIZE; i++){
+ ring[i] = new RxDesc(rm);
+ if(i == 0)
+ ringAddr = ring[0].descAddr;
+ else
+ ring[i - 1].setNextDescAddr(ring[i].descAddr);
+
+
+ }
+ ring[RX_RING_SIZE - 1].setNextDescAddr(ringAddr);
+ }
+
+
+ SocketBuffer getPacket(){
+ return ring[current].getPacket();
+ }
+
+ RxDesc currentDesc(){
+ return ring[current];
+ }
+
+ void next(){
+ current = (current + 1) % RX_RING_SIZE;
+ }
+}
Added: trunk/net/src/driver/org/jnode/driver/net/via_rhine/TxDesc.java
===================================================================
--- trunk/net/src/driver/org/jnode/driver/net/via_rhine/TxDesc.java (rev 0)
+++ trunk/net/src/driver/org/jnode/driver/net/via_rhine/TxDesc.java 2007-05-02 20:44:01 UTC (rev 3178)
@@ -0,0 +1,86 @@
+/*
+ * $Id$
+ */
+package org.jnode.driver.net.via_rhine;
+
+import org.apache.log4j.Logger;
+import org.jnode.system.MemoryResource;
+import org.jnode.system.ResourceManager;
+import org.jnode.net.SocketBuffer;
+import static org.jnode.net.ethernet.EthernetConstants.*;
+import org.vmmagic.unboxed.Address;
+import java.util.Arrays;
+
+
+/**
+ * @author Levente S\xE1ntha
+ */
+public class TxDesc {
+ protected final Logger log = Logger.getLogger(getClass());
+ byte[] desc;
+ int descOffs;
+ MemoryResource descMr;
+ byte[] data;
+ int dataOffs;
+ MemoryResource dataMr;
+ int descAddr;
+ TxDesc(ResourceManager rm){
+ desc = new byte[16 + 32];
+ descMr = rm.asMemoryResource(desc);
+ Address memAddr = descMr.getAddress();
+
+ int addr = memAddr.toInt();
+ descOffs = 0;
+ // Align on 32-byte boundary
+ while ((addr & 31) != 0) {
+ addr++;
+ descOffs++;
+ }
+ descAddr = memAddr.add(descOffs).toInt();
+
+ descMr.setInt(descOffs, 0x80000000);
+ descMr.setInt(descOffs + 4, ViaRhineConstants.PKT_BUF_SZ);
+
+ data = new byte[ViaRhineConstants.PKT_BUF_SZ + 32];
+ dataMr = rm.asMemoryResource(data);
+
+ memAddr = dataMr.getAddress();
+ addr = memAddr.toInt();
+ dataOffs = 0;
+ // Align on 32-byte boundary
+ while ((addr & 31) != 0) {
+ addr++;
+ dataOffs++;
+ }
+
+ descMr.setInt(descOffs + 8, memAddr.add(dataOffs).toInt());
+ }
+
+ void setOwnBit(){
+ descMr.setInt(descOffs, descMr.getInt(descOffs) | 0x80000000);
+ }
+
+ boolean isOwnBit(){
+ return (descMr.getInt(descOffs) & 0x80000000) != 0;
+ }
+
+ void setNextDescAddr(int addr){
+ descMr.setInt(descOffs + 12, addr);
+ }
+
+ void setFrameLength(int size){
+ descMr.setInt(descOffs + 4, ((descMr.getInt(descOffs + 4) & ~0x000007FF) | (size & 0x000007FF)));
+ }
+
+ void setPacket(SocketBuffer sb){
+ int ln = sb.getSize();
+ log.debug("packetlength: " + ln);
+ sb.get(data, dataOffs, 0, ln);
+
+ if(ln < ETH_ZLEN + 10){
+ Arrays.fill(data, dataOffs + ln, dataOffs + ETH_ZLEN + 10, (byte)0);
+ setFrameLength(ETH_ZLEN + 10);
+ }
+
+ }
+}
Added: trunk/net/src/driver/org/jnode/driver/net/via_rhine/TxRing.java
===================================================================
--- trunk/net/src/driver/org/jnode/driver/net/via_rhine/TxRing.java (rev 0)
+++ trunk/net/src/driver/org/jnode/driver/net/via_rhine/TxRing.java 2007-05-02 20:44:01 UTC (rev 3178)
@@ -0,0 +1,38 @@
+/*
+ * $Id$
+ */
+package org.jnode.driver.net.via_rhine;
+
+import org.jnode.system.ResourceManager;
+import org.jnode.net.SocketBuffer;
+
+/**
+ * @author Levente S\xE1ntha
+ */
+public class TxRing {
+ TxDesc[] ring;
+ int ringAddr;
+ int current;
+ TxRing(ResourceManager rm){
+ ring = new TxDesc[ViaRhineConstants.TX_RING_SIZE];
+ for(int i = 0; i < ViaRhineConstants.TX_RING_SIZE; i++){
+ ring[i] = new TxDesc(rm);
+ if(i == 0)
+ ringAddr = ring[0].descAddr;
+ else
+ ring[i - 1].setNextDescAddr(ring[i].descAddr);
+
+
+ }
+ ring[ViaRhineConstants.TX_RING_SIZE - 1].setNextDescAddr(ringAddr);
+ }
+
+
+ TxDesc currentDesc(){
+ return ring[current];
+ }
+
+ void next(){
+ current = (current + 1) % ViaRhineConstants.TX_RING_SIZE;
+ }
+}
Added: trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineCore.java
===================================================================
--- trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineCore.java (rev 0)
+++ trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineCore.java 2007-05-02 20:44:01 UTC (rev 3178)
@@ -0,0 +1,815 @@
+/*
+ * $Id$
+ */
+package org.jnode.driver.net.via_rhine;
+
+import org.jnode.driver.net.spi.AbstractDeviceCore;
+import org.jnode.driver.DriverException;
+import org.jnode.driver.Device;
+import org.jnode.driver.bus.pci.PCIHeaderType0;
+import org.jnode.driver.bus.pci.PCIDevice;
+import org.jnode.driver.bus.pci.PCIBaseAddress;
+import org.jnode.net.HardwareAddress;
+import org.jnode.net.SocketBuffer;
+import org.jnode.net.ethernet.EthernetAddress;
+import org.jnode.util.TimeoutException;
+import org.jnode.util.NumberUtils;
+import org.jnode.system.*;
+import org.jnode.naming.InitialNaming;
+import javax.naming.NameNotFoundException;
+
+import static org.jnode.net.ethernet.EthernetConstants.*;
+import static org.jnode.driver.net.via_rhine.ViaRhineConstants.*;
+import org.jnode.driver.net.ethernet.spi.Flags;
+import org.jnode.shell.CommandLine;
+import org.jnode.shell.help.ParsedArguments;
+import java.io.*;
+import java.net.URL;
+
+/**
+ * @author Levente S\xE1ntha
+ */
+public class ViaRhineCore extends AbstractDeviceCore implements IRQHandler {
+ private final int ioBase;
+ private final IOResource io;
+ private final IRQResource irq;
+ private EthernetAddress hwAddress;
+ private ViaRhineDriver driver;
+
+
+ /*
+ char devname[8]; // Used only for kernel debugging.
+ const char *product_name;
+ struct rhine_rx_desc *rx_ring;
+ struct rhine_tx_desc *tx_ring;
+ char *rx_buffs[RX_RING_SIZE];
+ char *tx_buffs[TX_RING_SIZE];
+
+ // temporary Rx buffers.
+
+ int chip_id;
+ int chip_revision;
+ unsigned short ioaddr;
+ unsigned int cur_rx, cur_tx; // The next free and used entries
+ unsigned int dirty_rx, dirty_tx;
+ // The saved address of a sent-in-place packet/buffer, for skfree().
+ struct sk_buff *tx_skbuff[TX_RING_SIZE];
+ unsigned char mc_filter[8]; // Current multicast filter.
+ char phys[4]; // MII device addresses.
+ unsigned int tx_full:1; // The Tx queue is full.
+ unsigned int full_duplex:1; // Full-duplex operation requested.
+ unsigned int default_port:4; // Last dev->if_port value.
+ unsigned int media2:4; // Secondary monitored media port.
+ unsigned int medialock:1; // Don't sense media type.
+ unsigned int mediasense:1; // Media sensing in progress.
+
+ */
+
+ ViaRhineRxDescriptor[] rx_ring = new ViaRhineRxDescriptor[RX_RING_SIZE];
+ ViaRhineTxDescriptor[] tx_ring = new ViaRhineTxDescriptor[TX_RING_SIZE];
+ byte[] rx_buffs = new byte[RX_RING_SIZE];
+ byte[] tx_buffs = new byte[TX_RING_SIZE];
+
+ int chip_id;
+ int chip_revision;
+ short ioaddr;
+ int cur_rx, cur_tx; // The next free and used entries
+ int dirty_rx, dirty_tx;
+ // The saved address of a sent-in-place packet/buffer, for skfree().
+ SocketBuffer[] tx_skbuff = new SocketBuffer[TX_RING_SIZE];
+ char[] mc_filter = new char[8]; // Current multicast filter.
+ char[] phys = new char[4]; // MII device addresses.
+ int tx_full =1; // The Tx queue is full.
+ int full_duplex = 1; // Full-duplex operation requested.
+ int default_port = 4; // Last dev->if_port value.
+ int media2 = 4; // Secondary monitored media port.
+ int medialock = 1; // Don't sense media type.
+ int mediasense = 1; // Media sensing in progress.
+
+ RxRing rxRing;
+ TxRing txRing;
+
+ public ViaRhineCore(ViaRhineDriver driver, Device device, ResourceOwner owner, Flags flags)
+ throws DriverException, ResourceNotFreeException{
+ this.driver = driver;
+ final int irq_nr = getIRQ(device, flags);
+ PCIBaseAddress addr = getIOBaseAddress(device, flags);
+ this.ioBase = addr.getIOBase();
+ int io_length = addr.getSize();
+ final ResourceManager rm;
+
+ try {
+ rm = InitialNaming.lookup(ResourceManager.NAME);
+ } catch (NameNotFoundException ex) {
+ throw new DriverException("Cannot find ResourceManager");
+ }
+
+ this.irq = rm.claimIRQ(owner, irq_nr, this, true);
+
+ try {
+ io = rm.claimIOResource(owner, ioBase, io_length);
+ } catch (ResourceNotFreeException ex) {
+ this.irq.release();
+ throw ex;
+ }
+
+ final byte[] hwAddrArr = new byte[ETH_ALEN];
+ for (int i = 0; i < ETH_ALEN; i++)
+ hwAddrArr[i] = (byte) getReg8(byPAR0 + i);
+
+ this.hwAddress = new EthernetAddress(hwAddrArr, 0);
+
+ log.debug("Found " + flags.getName() + " IRQ = " + irq.getIRQ()
+ + ", IO Base = 0x" + NumberUtils.hex(ioBase)
+ + ", IO Length = " + io_length
+ + ", MAC Address = "+ hwAddress);
+ }
+
+ protected PCIBaseAddress getIOBaseAddress(Device device, Flags flags)
+ throws DriverException {
+ final PCIHeaderType0 config = ((PCIDevice)device).getConfig().asHeaderType0();
+ final PCIBaseAddress[] addrs = config.getBaseAddresses();
+ if (addrs.length < 1) {
+ throw new DriverException("Cannot find iobase: not base addresses");
+ }
+ if (!addrs[0].isIOSpace()) {
+ throw new DriverException("Cannot find iobase: first address is not I/O");
+ }
+ return addrs[0];
+ }
+
+ /**
+ * Gets the IRQ used by the given device
+ * @param device
+ * @param flags
+ */
+ protected int getIRQ(Device device, Flags flags) throws DriverException {
+ final PCIHeaderType0 config = ((PCIDevice)device).getConfig().asHeaderType0();
+ return config.getInterruptLine();
+ }
+
+ public void handleInterrupt(int irq) {
+ log.debug("handleInterrupt()");
+
+ printIntrStatus();
+ setIRQEnabled(false);
+
+ int intr_status = getIntrStatus();
+ if((intr_status & (IntrRxDone | IntrRxNoBuf | IntrRxOverflow |
+ IntrRxDropped | IntrRxEarly | IntrRxEmpty | IntrRxErr | IntrRxWakeUp)) != 0){
+ /* Acknowledge all of the current interrupt sources ASAP. */
+ //outw(DEFAULT_INTR & ~IntrRxDone, nic->ioaddr + IntrStatus);
+ //IOSYNC;
+ try {
+
+ Thread.sleep(50);
+ if(!rxRing.currentDesc().isOwnBit()){
+ SocketBuffer packet = rxRing.getPacket();
+ driver.onReceive(packet);
+ log.debug("New packet");
+ log.debug(packet.getLinkLayerHeader().getSourceAddress());
+ log.debug(packet.getLinkLayerHeader().getDestinationAddress());
+ log.debug("\n" + hexDump(packet.toByteArray()) + "\n");
+ rxRing.currentDesc().setOwnBit();
+ rxRing.next();
+ }
+
+ } catch(Exception e ){
+ log.error("error in irq handler", e);
+ }
+ //setReg16(IntrStatus, DEFAULT_INTR & ~IntrRxDone);
+ setReg16(IntrStatus, DEFAULT_INTR);
+ }
+
+ if((intr_status & (IntrTxDone | IntrTxAborted | IntrTxDescRace |
+ IntrTxError | IntrTxErrSummary | IntrTxUnderrun)) != 0) {
+ try {
+
+ if((intr_status & IntrTxError) != 0){
+ reset();
+ return;
+ }
+
+ Thread.sleep(50);
+ } catch(Exception e ){
+ log.error("error in irq handler", e);
+ }
+
+ setReg16(IntrStatus, DEFAULT_INTR | my_INTR);
+
+ }
+
+
+ setIRQEnabled(true);
+ }
+
+ int my_INTR = IntrTxDone | IntrTxError | IntrTxUnderrun;
+
+ private void printIntrStatus(){
+ /*
+ int IntrRxDone=0x0001, IntrRxErr=0x0004, IntrRxEmpty=0x0020,
+ IntrTxDone=0x0002, IntrTxError=0x0008, IntrTxUnderrun=0x0210,
+ IntrPCIErr=0x0040,
+ IntrStatsMax=0x0080, IntrRxEarly=0x0100,
+ IntrRxOverflow=0x0400, IntrRxDropped=0x0800, IntrRxNoBuf=0x1000,
+ IntrTxAborted=0x2000, IntrLinkChange=0x4000,
+ IntrRxWakeUp=0x8000,
+ IntrNormalSummary=0x0003, IntrAbnormalSummary=0xC260,
+ IntrTxDescRace=0x080000, // mapped from IntrStatus2
+ IntrTxErrSummary=0x082218;
+ */
+
+ int intr_status = getIntrStatus();
+
+ log.debug("Interrupt status word: 0x" + NumberUtils.hex(intr_status));
+
+ if((intr_status & IntrRxDone) != 0)
+ log.debug("Interrupt status: " + "IntrRxDone");
+
+ if((intr_status & IntrRxErr) != 0)
+ log.debug("Interrupt status: " + "IntrRxErr");
+
+ if((intr_status & IntrRxEmpty) != 0)
+ log.debug("Interrupt status: " + "IntrRxEmpty");
+
+ if((intr_status & IntrTxDone) != 0)
+ log.debug("Interrupt status: " + "IntrTxDone");
+
+ if((intr_status & IntrTxError) != 0)
+ log.debug("Interrupt status: " + "IntrTxError");
+
+ if((intr_status & IntrTxUnderrun) != 0)
+ log.debug("Interrupt status: " + "IntrTxUnderrun");
+
+ if((intr_status & IntrPCIErr) != 0)
+ log.debug("Interrupt status: " + "IntrPCIErr");
+
+ if((intr_status & IntrStatsMax) != 0)
+ log.debug("Interrupt status: " + "IntrStatsMax");
+
+ if((intr_status & IntrRxEarly) != 0)
+ log.debug("Interrupt status: " + "IntrRxEarly");
+
+ if((intr_status & IntrRxOverflow) != 0)
+ log.debug("Interrupt status: " + "IntrRxOverflow");
+
+ if((intr_status & IntrRxDropped) != 0)
+ log.debug("Interrupt status: " + "IntrRxDropped");
+
+ if((intr_status & IntrRxNoBuf) != 0)
+ log.debug("Interrupt status: " + "IntrRxNoBuf");
+
+ if((intr_status & IntrTxAborted) != 0)
+ log.debug("Interrupt status: " + "IntrTxAborted");
+
+ if((intr_status & IntrLinkChange) != 0)
+ log.debug("Interrupt status: " + "IntrLinkChange");
+
+ if((intr_status & IntrRxWakeUp) != 0)
+ log.debug("Interrupt status: " + "IntrRxWakeUp");
+
+ if((intr_status & IntrTxDescRace) != 0)
+ log.debug("Interrupt status: " + "IntrTxDescRace");
+
+ }
+
+ private void setIRQEnabled(boolean enable){
+ int intr_status = getIntrStatus();
+
+ if (enable)
+ intr_status = intr_status | DEFAULT_INTR | my_INTR;
+ else
+ intr_status = (intr_status & ~(DEFAULT_INTR | my_INTR));
+
+ setReg16(IntrEnable, intr_status);
+ }
+
+ private int getIntrStatus() {
+ int intr_status = getReg16(IntrStatus);
+ /* On Rhine-II, Bit 3 indicates Tx descriptor write-back race. */
+
+ /* added comment by guard */
+ /* For supporting VT6107, please use revision id to recognize different chips in driver */
+ // if (tp->chip_id == 0x3065)
+
+ //if( tp->chip_revision < 0x80 && tp->chip_revision >=0x40 )
+ intr_status |= getReg8(IntrStatus2) << 16;
+
+ return intr_status;
+ }
+
+ public HardwareAddress getHwAddress() {
+ log.debug("getHwAddress");
+ return hwAddress;
+ }
+
+ public void initialize() throws DriverException {
+ log.debug("initialize()");
+ probe();
+ reset();
+ }
+
+ public void disable() {
+ log.debug("disable()");
+ /* merge reset and disable */
+ //rhine_reset(nic);
+ reset();
+
+ /* Switch to loopback mode to avoid hardware races. */
+ //writeb(0x60 | 0x01, byTCR);
+ setReg8(byTCR, 0x60 | 0x01);
+
+ /* Stop the chip's Tx and Rx processes. */
+ //writew(CR_STOP, byCR0);
+ setReg16(byCR0, CR_STOP);
+ }
+
+ private void reset(){
+ /* software reset */
+ setReg8(byCR1, CR1_SFRST);
+ MIIDelay();
+
+ //init ring
+ try {
+ final ResourceManager rm = InitialNaming.lookup(ResourceManager.NAME);
+ rxRing = new RxRing(rm);
+ log.debug("Rx ring initialised");
+ txRing = new TxRing(rm);
+ log.debug("Tx ring initialised");
+ } catch (NameNotFoundException ex) {
+ throw new RuntimeException("Cannot find ResourceManager");
+ }
+
+ /*write TD RD Descriptor to MAC */
+ setReg32(dwCurrentRxDescAddr, rxRing.ringAddr);
+ setReg32(dwCurrentTxDescAddr, txRing.ringAddr);
+
+ /* close IMR */
+ setReg16 (byIMR0, 0x0000);
+
+ /* Setup Multicast */
+ //set_rx_mode(nic);
+ setRxMode();
+
+ /* set TCR RCR threshold to store and forward*/
+ //outb (0x3e, byBCR0);
+ //outb (0x38, byBCR1);
+ //outb (0x2c, byRCR);
+ //outb (0x60, byTCR);
+ setReg8(byBCR0, 0x3e);
+ setReg8(byBCR1, 0x38);
+ setReg8(byRCR, 0x2c);
+ setReg8(byTCR, 0x60);
+
+ /* Set Fulldupex */
+ int FDXFlag = queryAuto ();
+ if (FDXFlag == 1) {
+ setReg8(byCFGD, CFGD_CFDX);
+ setReg16(byCR0, CR_FDX);
+ }
+
+ /* KICK NIC to WORK */
+ //CRbak = inw (byCR0);
+ //CRbak = CRbak & 0xFFFB; /* not CR_STOP */
+ //outw ((CRbak | CR_STRT | CR_TXON | CR_RXON | CR_DPOLL), byCR0);
+ int cr = getReg8(byCR0);
+ cr = cr & 0xFFFB;
+ setReg16(byCR0, cr | CR_STRT | CR_TXON | CR_RXON | CR_DPOLL);
+
+ /* disable all known interrupt */
+ //outw (0, byIMR0);
+ //setReg16(byIMR0, 0);
+
+
+ //--------------------
+ //outw (IMRShadow, byIMR0);
+ setReg16(byIMR0, IMRShadow);
+ }
+
+ private void setRxMode(){
+ /* ! IFF_PROMISC */
+ //outl(0xffffffff, byMAR0);
+ //outl(0xffffffff, byMAR4);
+ //rx_mode = 0x0C;
+ //outb(0x60 /* thresh */ | rx_mode, byRCR );
+ setReg32(byMAR0, 0xffffffff);
+ setReg32(byMAR4, 0xffffffff);
+ int rx_mode = 0x0C;
+ setReg8(byRCR, 0x60 | rx_mode);
+ }
+
+ private void reloadEEPROM()
+ {
+ //int i;
+ //outb(0x20, byEECSR);
+ setReg8(byEECSR, 0x20);
+
+ /* Typically 2 cycles to reload. */
+ //for (i = 0; i < 150; i++)
+ // if (! (inb(byEECSR) & 0x20))
+ // break;
+
+ for (int i = 0; i < 150; i++)
+ if ( (getReg8(byEECSR) & 0x20) == 0)
+ break;
+ }
+
+
+ void initRing () {
+ int i;
+ tx_full = 0;
+ cur_rx = cur_tx = 0;
+ dirty_rx = dirty_tx = 0;
+
+ for (i = 0; i < RX_RING_SIZE; i++) {
+
+ rx_ring[i].rxStatus_bits.own_bit = 1;
+ rx_ring[i].rxControl_bits.rx_buf_size = 1536;
+
+ //--rx_ring[i].buf_addr_1 = virt_to_bus (tp->rx_buffs[i]);
+ //--rx_ring[i].buf_addr_2 = virt_to_bus (&tp->rx_ring[i + 1]);
+
+ /* printf("[%d]buf1=%hX,buf2=%hX",i,tp->rx_ring[i].buf_addr_1,tp->rx_ring[i].buf_addr_2); */
+ }
+ /* Mark the last entry as wrapping the ring. */
+ /* tp->rx_ring[i-1].rx_ctrl.bits.rx_buf_size =1518; */
+
+ //--rx_ring[i - 1].buf_addr_2 = virt_to_bus (&tp->rx_ring[0]);
+
+ /*printf("[%d]buf1=%hX,buf2=%hX",i-1,tp->rx_ring[i-1].buf_addr_1,tp->rx_ring[i-1].buf_addr_2); */
+
+ /* The Tx buffer descriptor is filled in as needed, but we
+ do need to clear the ownership bit. */
+
+ for (i = 0; i < TX_RING_SIZE; i++) {
+
+ tx_ring[i].txStatus_lw = 0;
+ tx_ring[i].txControl_lw = 0x00e08000;
+ //--tx_ring[i].buf_addr_1 = virt_to_bus (tp->tx_buffs[i]);
+ //--tx_ring[i].buf_addr_2 = virt_to_bus (&tp->tx_ring[i + 1]);
+ /* printf("[%d]buf1=%hX,buf2=%hX",i,tp->tx_ring[i].buf_addr_1,tp->tx_ring[i].buf_addr_2); */
+ }
+
+ //--tx_ring[i - 1].buf_addr_2 = virt_to_bus (&tp->tx_ring[0]);
+ /* printf("[%d]buf1=%hX,buf2=%hX",i,tp->tx_ring[i-1].buf_addr_1,tp->tx_ring[i-1].buf_addr_2); */
+ }
+
+ private int queryAuto () {
+ int byMIIIndex;
+ int MIIReturn;
+
+ int advertising,mii_reg5;
+ int negociated;
+
+ byMIIIndex = 0x04;
+ MIIReturn = ReadMII (byMIIIndex);
+ advertising=MIIReturn;
+
+ byMIIIndex = 0x05;
+ MIIReturn = ReadMII (byMIIIndex);
+ mii_reg5=MIIReturn;
+
+ negociated=mii_reg5 & advertising;
+
+ if ( (negociated & 0x100) != 0 || (negociated & 0x1C0) == 0x40 )
+ return 1;
+ else
+ return 0;
+
+ }
+
+ private int ReadMII(int byMIIIndex) {
+ int ReturnMII;
+ int byMIIAdrbak;
+ int byMIICRbak;
+ int byMIItemp;
+
+ byMIIAdrbak = getReg8(byMIIAD);
+ byMIICRbak = getReg8(byMIICR);
+ setReg8 (byMIICR, byMIICRbak & 0x7f);
+ MIIDelay ();
+
+ setReg8(byMIIAD, byMIIIndex);
+ MIIDelay ();
+
+ setReg8(byMIICR, getReg8(byMIICR) | 0x40);
+
+ byMIItemp = getReg8(byMIICR);
+ byMIItemp = byMIItemp & 0x40;
+
+ while (byMIItemp != 0) {
+ byMIItemp = getReg8(byMIICR);
+ byMIItemp = byMIItemp & 0x40;
+ }
+ MIIDelay ();
+
+ ReturnMII = getReg16(wMIIDATA);
+
+ setReg8(byMIIAD, byMIIAdrbak);
+ setReg8(byMIICR, byMIICRbak);
+ MIIDelay ();
+
+ return (ReturnMII);
+ }
+
+ void WriteMII (int byMIISetByte, int byMIISetBit, int byMIIOP) {
+ int ReadMIItmp;
+ int MIIMask;
+ int byMIIAdrbak;
+ int byMIICRbak;
+ int byMIItemp;
+
+
+ byMIIAdrbak = getReg8(byMIIAD);
+
+ byMIICRbak = getReg8(byMIICR);
+ setReg8(byMIICR, byMIICRbak & 0x7f);
+ MIIDelay ();
+ setReg8(byMIIAD, byMIISetByte);
+ MIIDelay ();
+
+ setReg8(byMIICR, getReg8(byMIICR) | 0x40);
+
+ byMIItemp = getReg8(byMIICR);
+ byMIItemp = byMIItemp & 0x40;
+
+ while (byMIItemp != 0) {
+ byMIItemp = getReg8(byMIICR);
+ byMIItemp = byMIItemp & 0x40;
+ }
+ MIIDelay ();
+
+ ReadMIItmp = getReg16(wMIIDATA);
+ MIIMask = 0x0001;
+ MIIMask = MIIMask << byMIISetBit;
+
+
+ if (byMIIOP == 0) {
+ MIIMask = ~MIIMask;
+ ReadMIItmp = ReadMIItmp & MIIMask;
+ } else {
+ ReadMIItmp = ReadMIItmp | MIIMask;
+ }
+
+ setReg16(wMIIDATA, ReadMIItmp);
+ MIIDelay ();
+
+ setReg8(byMIICR, getReg8(byMIICR) | 0x20);
+ byMIItemp = getReg8(byMIICR);
+ byMIItemp = byMIItemp & 0x20;
+
+ while (byMIItemp != 0) {
+ byMIItemp = getReg8(byMIICR);
+ byMIItemp = byMIItemp & 0x20;
+ }
+
+ MIIDelay ();
+
+ setReg8(byMIIAD, byMIIAdrbak & 0x7f);
+ setReg8(byMIICR, byMIICRbak);
+ MIIDelay ();
+
+ }
+
+ private void MIIDelay (){
+ for (int i = 0; i < 0x7fff; i++) {
+ getReg8(0x61);
+ getReg8(0x61);
+ getReg8(0x61);
+ getReg8(0x61);
+ }
+ }
+
+ void probe() {
+ int options = -1;
+ int did_version = 0; /* Already printed version info. */
+ int i;
+ int timeout;
+ int FDXFlag;
+ int byMIIvalue, LineSpeed, MIICRbak;
+
+ //if (rhine_debug > 0 && did_version++ == 0)
+ // printf (version);
+ reloadEEPROM();
+ /* Perhaps this should be read from the EEPROM? */
+ //--for (i = 0; i < ETH_ALEN; i++)
+ //--nic->node_addr[i] = inb (byPAR0 + i);
+ //--printf ("IO address %hX Ethernet Address: %!\n", ioaddr, nic->node_addr);
+
+ /* restart MII auto-negotiation */
+ WriteMII (0, 9, 1);
+ log.info ("Analyzing Media type,this will take several seconds........");
+ for (i = 0; i < 5; i++) {
+
+ /* need to wait 1 millisecond - we will round it up to 50-100ms */
+ try {
+ Thread.sleep(70);
+ } catch(InterruptedException x){
+ //ignore
+ }
+
+ if ((ReadMII(1) & 0x0020) != 0)
+ break;
+ }
+ log.info("OK\n");
+
+ /*
+ #if 0
+ //* JJM : for Debug
+ printf("MII : Address %hhX ",inb(ioaddr+0x6c));
+ {
+ unsigned char st1,st2,adv1,adv2,l1,l2;
+
+ st1=ReadMII(1,ioaddr)>>8;
+ st2=ReadMII(1,ioaddr)&0xFF;
+ adv1=ReadMII(4,ioaddr)>>8;
+ adv2=ReadMII(4,ioaddr)&0xFF;
+ l1=ReadMII(5,ioaddr)>>8;
+ l2=ReadMII(5,ioaddr)&0xFF;
+ printf(" status 0x%hhX%hhX, advertising 0x%hhX%hhX, link 0x%hhX%hhX\n", st1,st2,adv1,adv2,l1,l2);
+ }
+ #endif
+ */
+ /* query MII to know LineSpeed,duplex mode */
+ byMIIvalue = getReg8(0x6d);
+ LineSpeed = byMIIvalue & MIISR_SPEED;
+ if (LineSpeed != 0){ //JJM
+ log.info("Linespeed=10Mbs");
+ } else {
+ log.info("Linespeed=100Mbs");
+ }
+
+ FDXFlag = queryAuto();
+ if (FDXFlag == 1) {
+ log.info(" Fullduplex\n");
+ setReg16(byCR0, CR_FDX);
+ } else {
+ log.info(" Halfduplex\n");
+ }
+
+
+ /* set MII 10 FULL ON */
+ WriteMII (17, 1, 1);
+
+ /* turn on MII link change */
+ MIICRbak = getReg8(byMIICR);
+ setReg8(byMIICR, MIICRbak & 0x7F);
+ MIIDelay ();
+ setReg8(byMIIAD, 0x41);
+ MIIDelay ();
+
+ /* while((inb(byMIIAD)&0x20)==0) ; */
+ setReg8(byMIICR, MIICRbak | 0x80);
+
+
+ /* The lower four bits are the media type. */
+ if (options > 0) {
+ full_duplex = (options & 16) != 0 ? 1 : 0;
+ default_port = options & 15;
+ if (default_port != 0)
+ medialock = 1;
+ }
+ }
+
+ public void release() {
+ log.debug("release()");
+ io.release();
+ log.debug("irq.release");
+ irq.release();
+ log.debug("end of release");
+ }
+
+ public void transmit(SocketBuffer buf, HardwareAddress destination, long timeout) throws InterruptedException, TimeoutException {
+ log.debug("transmit(): to " + destination);
+// destination.writeTo(buf, 0);
+// hwAddress.writeTo(buf, 6);
+ txRing.currentDesc().setOwnBit();
+ txRing.currentDesc().setFrameLength(buf.getSize());
+ txRing.currentDesc().setPacket(buf);
+ log.debug("\n" + hexDump(buf.toByteArray()) + "\n");
+
+ int CR1bak = getReg8(byCR1);
+
+ CR1bak = CR1bak | CR1_TDMD1;
+ setReg8(byCR1, CR1bak);
+
+// do {
+
+ int i = 0;
+ while(txRing.currentDesc().isOwnBit()) {
+ try{
+ Thread.sleep(10);
+ } catch(InterruptedException x){
+ //
+ }
+ if(i++ > 5) break;
+ }
+
+// if(tp->tx_ring[entry].tx_status.bits.terr == 0)
+// break;
+
+// if(tp->tx_ring[entry].tx_status.bits.abt == 1)
+// {
+// // turn on TX
+// int CR0bak = getReg8(byCR0);
+// CR0bak = CR0bak | CR_TXON;
+// setReg8(byCR0, CR0bak);
+// }
+ // } while(true);
+ txRing.next();
+ }
+
+ private int getReg8(int reg) {
+ return io.inPortByte(ioBase + reg);
+ }
+
+ private int getReg16(int reg) {
+ return io.inPortWord(ioBase + reg);
+ }
+
+ private int getReg32(int reg) {
+ return io.inPortDword(ioBase + reg);
+ }
+
+ private void setReg8(int reg, int value) {
+ io.outPortByte(ioBase + reg, value);
+ }
+
+ private void setReg16(int reg, int value) {
+ io.outPortWord(ioBase + reg, value);
+ }
+
+ private void setReg32(int reg, int value) {
+ io.outPortDword(ioBase + reg, value);
+ }
+
+
+
+ String hexDump(byte[] data){
+ try {
+ InputStream is = new ByteArrayInputStream(data);
+ StringWriter swriter = new StringWriter();
+ PrintWriter out = new PrintWriter(swriter);
+
+ final int rowlen = 16;
+ int prt = 0;
+ int len;
+
+ final byte[] buf = new byte[1024];
+ StringBuilder sb = new StringBuilder();
+ while ((len = is.read(buf)) > 0) {
+ int left = len;
+ int ofs = 0;
+ //
+ while (left > 0) {
+ sb.setLength(0);
+ int sz = Math.min(rowlen, left);
+
+ sb.append(NumberUtils.hex(prt, 8)).append(" ");
+
+ for (int i = 0; i < rowlen; i++) {
+ if (ofs + i < len)
+ sb.append(NumberUtils.hex(buf[ofs + i], 2));
+ else
+ sb.append(" ");
+ if ((i + 1) < rowlen)
+ sb.append(" ");
+ if ((i + 1) == rowlen / 2)
+ sb.append(" ");
+ }
+
+ sb.append(" |");
+
+ for (int i = 0; i < rowlen; i++) {
+ if (ofs + i < len) {
+ char c = (char) buf[ofs + i];
+ if ((c >= ' ') && (c < (char) 0x7f))
+ sb.append(c);
+ else
+ sb.append(".");
+ } else
+ sb.append(" ");
+ }
+
+ sb.append("|");
+
+ left -= sz;
+ ofs += sz;
+ prt += sz;
+
+ out.println(sb.toString());
+ out.flush();
+ }
+ }
+
+ out.flush();
+ out.close();
+ is.close();
+
+
+ return swriter.toString();
+ } catch(Exception e){
+ throw new RuntimeException(e);
+ }
+ }
+}
Added: trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineDriver.java
===================================================================
--- trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineDriver.java (rev 0)
+++ trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineDriver.java 2007-05-02 20:44:01 UTC (rev 3178)
@@ -0,0 +1,50 @@
+/*
+ * $Id$
+ */
+package org.jnode.driver.net.via_rhine;
+
+import org.jnode.driver.net.ethernet.spi.BasicEthernetDriver;
+import org.jnode.driver.net.ethernet.spi.Flags;
+import org.jnode.driver.DriverException;
+import org.jnode.driver.Device;
+import org.jnode.plugin.ConfigurationElement;
+import org.jnode.system.ResourceNotFreeException;
+import org.jnode.util.AccessControllerUtils;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * @author Levente S\xE1ntha
+ */
+public class ViaRhineDriver extends BasicEthernetDriver {
+ /**
+ * Create a new instance
+ * @param config configuartion desc
+ */
+ public ViaRhineDriver(ConfigurationElement config) {
+ this(new ViaRhineFlags(config));
+ }
+
+ public ViaRhineDriver(ViaRhineFlags flags) {
+ this.flags = flags;
+ }
+
+ /**
+ * Create a new ViaRhineCore instance
+ */
+ protected ViaRhineCore newCore(final Device device, final Flags flags)
+ throws DriverException, ResourceNotFreeException {
+ try {
+ return AccessControllerUtils.doPrivileged(new PrivilegedExceptionAction<ViaRhineCore>(){
+ public ViaRhineCore run() throws Exception {
+ return new ViaRhineCore(ViaRhineDriver.this, device, device, flags);
+ }
+ });
+ } catch (DriverException ex) {
+ throw ex;
+ } catch (ResourceNotFreeException ex) {
+ throw ex;
+ } catch (Exception ex) {
+ throw new DriverException(ex);
+ }
+ }
+}
Added: trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineFlags.java
===================================================================
--- trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineFlags.java (rev 0)
+++ trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineFlags.java 2007-05-02 20:44:01 UTC (rev 3178)
@@ -0,0 +1,30 @@
+/*
+ * $Id$
+ */
+package org.jnode.driver.net.via_rhine;
+
+import org.jnode.driver.net.ethernet.spi.Flags;
+import org.jnode.plugin.ConfigurationElement;
+
+/**
+ * @author Levente S\xE1ntha
+ */
+public class ViaRhineFlags implements Flags {
+ private final String name;
+
+ public ViaRhineFlags(ConfigurationElement config) {
+ this(config.getAttribute("name"));
+ }
+
+ /**
+ * Create a new instance
+ * @param name
+ */
+ public ViaRhineFlags(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2007-05-02 20:43:28
|
Revision: 3177
http://jnode.svn.sourceforge.net/jnode/?rev=3177&view=rev
Author: lsantha
Date: 2007-05-02 13:43:25 -0700 (Wed, 02 May 2007)
Log Message:
-----------
via-rhine nic driver, initial commit.
Added Paths:
-----------
trunk/net/src/driver/org/jnode/driver/net/via_rhine/
trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineConstants.java
Added: trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineConstants.java
===================================================================
--- trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineConstants.java (rev 0)
+++ trunk/net/src/driver/org/jnode/driver/net/via_rhine/ViaRhineConstants.java 2007-05-02 20:43:25 UTC (rev 3177)
@@ -0,0 +1,474 @@
+/*
+ * $Id$
+ */
+package org.jnode.driver.net.via_rhine;
+
+/**
+ * @author Levente S\xE1ntha
+ */
+public interface ViaRhineConstants {
+ byte ioaddr = 0;
+ byte byPAR0 = ioaddr;
+ byte byRCR = ioaddr + 6;
+ byte byTCR = ioaddr + 7;
+ byte byCR0 = ioaddr + 8;
+ byte byCR1 = ioaddr + 9;
+ byte byISR0 = ioaddr + 0x0c;
+ byte byISR1 = ioaddr + 0x0d;
+ byte byIMR0 = ioaddr + 0x0e;
+ byte byIMR1 = ioaddr + 0x0f;
+ byte byMAR0 = ioaddr + 0x10;
+ byte byMAR1 = ioaddr + 0x11;
+ byte byMAR2 = ioaddr + 0x12;
+ byte byMAR3 = ioaddr + 0x13;
+ byte byMAR4 = ioaddr + 0x14;
+ byte byMAR5 = ioaddr + 0x15;
+ byte byMAR6 = ioaddr + 0x16;
+ byte byMAR7 = ioaddr + 0x17;
+ int dwCurrentRxDescAddr = ioaddr + 0x18;
+ int dwCurrentTxDescAddr = ioaddr + 0x1c;
+ int dwCurrentRDSE0 = ioaddr + 0x20;
+ int dwCurrentRDSE1 = ioaddr + 0x24;
+ int dwCurrentRDSE2 = ioaddr + 0x28;
+ int dwCurrentRDSE3 = ioaddr + 0x2c;
+ int dwNextRDSE0 = ioaddr + 0x30;
+ int dwNextRDSE1 = ioaddr + 0x34;
+ int dwNextRDSE2 = ioaddr + 0x38;
+ int dwNextRDSE3 = ioaddr + 0x3c;
+ int dwCurrentTDSE0 = ioaddr + 0x40;
+ int dwCurrentTDSE1 = ioaddr + 0x44;
+ int dwCurrentTDSE2 = ioaddr + 0x48;
+ int dwCurrentTDSE3 = ioaddr + 0x4c;
+ int dwNextTDSE0 = ioaddr + 0x50;
+ int dwNextTDSE1 = ioaddr + 0x54;
+ int dwNextTDSE2 = ioaddr + 0x58;
+ int dwNextTDSE3 = ioaddr + 0x5c;
+ int dwCurrRxDMAPtr = ioaddr + 0x60;
+ int dwCurrTxDMAPtr = ioaddr + 0x64;
+ int byMPHY = ioaddr + 0x6c;
+ int byMIISR = ioaddr + 0x6d;
+ int byBCR0 = ioaddr + 0x6e;
+ int byBCR1 = ioaddr + 0x6f;
+ int byMIICR = ioaddr + 0x70;
+ int byMIIAD = ioaddr + 0x71;
+ int wMIIDATA = ioaddr + 0x72;
+ int byEECSR = ioaddr + 0x74;
+ int byTEST = ioaddr + 0x75;
+ int byGPIO = ioaddr + 0x76;
+ int byCFGA = ioaddr + 0x78;
+ int byCFGB = ioaddr + 0x79;
+ int byCFGC = ioaddr + 0x7a;
+ int byCFGD = ioaddr + 0x7b;
+ int wTallyCntMPA = ioaddr + 0x7c;
+ int wTallyCntCRC = ioaddr + 0x7d;
+ int bySTICKHW = ioaddr + 0x83;
+ int byWOLcrClr = ioaddr + 0xA4;
+ int byWOLcgClr = ioaddr + 0xA7;
+ int byPwrcsrClr = ioaddr + 0xAC;
+
+/*--------------------- Exioaddr Definitions -------------------------*/
+
+/*
+ * Bits in the RCR register
+ */
+
+ int RCR_RRFT2 = 0x80;
+ int RCR_RRFT1 = 0x40;
+ int RCR_RRFT0 = 0x20;
+ int RCR_PROM = 0x10;
+ int RCR_AB = 0x08;
+ int RCR_AM = 0x04;
+ int RCR_AR = 0x02;
+ int RCR_SEP = 0x01;
+
+/*
+ * Bits in the TCR register
+ */
+
+ int TCR_RTSF = 0x80;
+ int TCR_RTFT1 = 0x40;
+ int TCR_RTFT0 = 0x20;
+ int TCR_OFSET = 0x08;
+ int TCR_LB1 = 0x04; /* loopback[1] */
+ int TCR_LB0 = 0x02; /* loopback[0] */
+
+/*
+ * Bits in the CR0 register
+ */
+
+ int CR0_RDMD = 0x40; /* rx descriptor polling demand */
+ int CR0_TDMD = 0x20; /* tx descriptor polling demand */
+ int CR0_TXON = 0x10;
+ int CR0_RXON = 0x08;
+ int CR0_STOP = 0x04; /* stop NIC, default = 1 */
+ int CR0_STRT = 0x02; /* start NIC */
+ int CR0_INIT = 0x01; /* start init process */
+
+/*
+* Bits in the CR1 register
+*/
+
+ int CR1_SFRST = 0x80 /* software reset */;
+ int CR1_RDMD1 = 0x40 /* RDMD1 */;
+ int CR1_TDMD1 = 0x20 /* TDMD1 */;
+ int CR1_KEYPAG = 0x10 /* turn on par/key */;
+ int CR1_DPOLL = 0x08 /* disable rx/tx auto polling */;
+ int CR1_FDX = 0x04 /* full duplex mode */;
+ int CR1_ETEN = 0x02 /* early tx mode */;
+ int CR1_EREN = 0x01 /* early rx mode */;
+
+/*
+ * Bits in the CR register
+ */
+
+ int CR_RDMD = 0x0040 /* rx descriptor polling demand */;
+ int CR_TDMD = 0x0020 /* tx descriptor polling demand */;
+ int CR_TXON = 0x0010;
+ int CR_RXON = 0x0008;
+ int CR_STOP = 0x0004 /* stop NIC, default = 1 */;
+ int CR_STRT = 0x0002 /* start NIC */;
+ int CR_INIT = 0x0001 /* start init process */;
+ int CR_SFRST = 0x8000 /* software reset */;
+ int CR_RDMD1 = 0x4000 /* RDMD1 */;
+ int CR_TDMD1 = 0x2000 /* TDMD1 */;
+ int CR_KEYPAG = 0x1000 /* turn on par/key */;
+ int CR_DPOLL = 0x0800 /* disable rx/tx auto polling */;
+ int CR_FDX = 0x0400 /* full duplex mode */;
+ int CR_ETEN = 0x0200 /* early tx mode */;
+ int CR_EREN = 0x0100 /* early rx mode */;
+
+/*
+ * Bits in the IMR0 register
+ */
+
+ int IMR0_CNTM = 0x80;
+ int IMR0_BEM = 0x40;
+ int IMR0_RUM = 0x20;
+ int IMR0_TUM = 0x10;
+ int IMR0_TXEM = 0x08;
+ int IMR0_RXEM = 0x04;
+ int IMR0_PTXM = 0x02;
+ int IMR0_PRXM = 0x01;
+
+/* define imrshadow */
+
+ int IMRShadow = 0x5AFF;
+
+/*
+ * Bits in the IMR1 register
+ */
+
+ int IMR1_INITM = 0x80;
+ int IMR1_SRCM = 0x40;
+ int IMR1_NBFM = 0x10;
+ int IMR1_PRAIM = 0x08;
+ int IMR1_RES0M = 0x04;
+ int IMR1_ETM = 0x02;
+ int IMR1_ERM = 0x01;
+
+/*
+ * Bits in the ISR register
+ */
+
+ int ISR_INITI = 0x8000;
+ int ISR_SRCI = 0x4000;
+ int ISR_ABTI = 0x2000;
+ int ISR_NORBF = 0x1000;
+ int ISR_PKTRA = 0x0800;
+ int ISR_RES0 = 0x0400;
+ int ISR_ETI = 0x0200;
+ int ISR_ERI = 0x0100;
+ int ISR_CNT = 0x0080;
+ int ISR_BE = 0x0040;
+ int ISR_RU = 0x0020;
+ int ISR_TU = 0x0010;
+ int ISR_TXE = 0x0008;
+ int ISR_RXE = 0x0004;
+ int ISR_PTX = 0x0002;
+ int ISR_PRX = 0x0001;
+
+/*
+ * Bits in the ISR0 register;
+ */
+
+ int ISR0_CNT = 0x80;
+ int ISR0_BE = 0x40;
+ int ISR0_RU = 0x20;
+ int ISR0_TU = 0x10;
+ int ISR0_TXE = 0x08;
+ int ISR0_RXE = 0x04;
+ int ISR0_PTX = 0x02;
+ int ISR0_PRX = 0x01;
+
+/*
+ * Bits in the ISR1 register
+ */
+
+ int ISR1_INITI = 0x80;
+ int ISR1_SRCI = 0x40;
+ int ISR1_NORBF = 0x10;
+ int ISR1_PKTRA = 0x08;
+ int ISR1_ETI = 0x02;
+ int ISR1_ERI = 0x01;
+
+/* ISR ABNORMAL CONDITION */
+
+ int ISR_ABNORMAL = ISR_BE + ISR_RU + ISR_TU + ISR_CNT + ISR_NORBF + ISR_PKTRA;
+
+/*
+ * Bits in the MIISR register;
+ */
+
+ int MIISR_MIIERR = 0x08;
+ int MIISR_MRERR = 0x04;
+ int MIISR_LNKFL = 0x02;
+ int MIISR_SPEED = 0x01;
+
+/*
+ * Bits in the MIICR register;
+ */
+
+ int MIICR_MAUTO = 0x80;
+ int MIICR_RCMD = 0x40;
+ int MIICR_WCMD = 0x20;
+ int MIICR_MDPM = 0x10;
+ int MIICR_MOUT = 0x08;
+ int MIICR_MDO = 0x04;
+ int MIICR_MDI = 0x02;
+ int MIICR_MDC = 0x01;
+
+/*
+ * Bits in the EECSR register;
+ */
+
+ int EECSR_EEPR = 0x80 /* eeprom programed status, 73h means programed */;
+ int EECSR_EMBP = 0x40 /* eeprom embeded programming */;
+ int EECSR_AUTOLD = 0x20 /* eeprom content reload */;
+ int EECSR_DPM = 0x10 /* eeprom direct programming */;
+ int EECSR_CS = 0x08 /* eeprom CS pin */;
+ int EECSR_SK = 0x04 /* eeprom SK pin */;
+ int EECSR_DI = 0x02 /* eeprom DI pin */;
+ int EECSR_DO = 0x01 /* eeprom DO pin */;
+
+/*
+ * Bits in the BCR0 register;
+ */
+
+ int BCR0_CRFT2 = 0x20;
+ int BCR0_CRFT1 = 0x10;
+ int BCR0_CRFT0 = 0x08;
+ int BCR0_DMAL2 = 0x04;
+ int BCR0_DMAL1 = 0x02;
+ int BCR0_DMAL0 = 0x01;
+
+ /*
+ * Bits in the BCR1 register;
+ */
+ int BCR1_CTSF = 0x20;
+ int BCR1_CTFT1 = 0x10;
+ int BCR1_CTFT0 = 0x08;
+ int BCR1_POT2 = 0x04;
+ int BCR1_POT1 = 0x02;
+ int BCR1_POT0 = 0x01;
+
+ /*
+ * Bits in the CFGA register;
+ */
+ int CFGA_EELOAD = 0x80 /* enable eeprom embeded and direct programming */;
+ int CFGA_JUMPER = 0x40;
+ int CFGA_MTGPIO = 0x08;
+ int CFGA_T10EN = 0x02;
+ int CFGA_AUTO = 0x01;
+
+ /*
+ * Bits in the CFGB register;
+ */
+ int CFGB_PD = 0x80;
+ int CFGB_POLEN = 0x02;
+ int CFGB_LNKEN = 0x01;
+
+ /*
+ * Bits in the CFGC register;
+ */
+ int CFGC_M10TIO = 0x80;
+ int CFGC_M10POL = 0x40;
+ int CFGC_PHY1 = 0x20;
+ int CFGC_PHY0 = 0x10;
+ int CFGC_BTSEL = 0x08;
+ int CFGC_BPS2 = 0x04 /* bootrom select[2] */;
+ int CFGC_BPS1 = 0x02 /* bootrom select[1] */;
+ int CFGC_BPS0 = 0x01 /* bootrom select[0] */;
+
+ /*
+ * Bits in the CFGD register;
+ */
+ int CFGD_GPIOEN = 0x80;
+ int CFGD_DIAG = 0x40;
+ int CFGD_MAGIC = 0x10;
+ int CFGD_RANDOM = 0x08;
+ int CFGD_CFDX = 0x04;
+ int CFGD_CEREN = 0x02;
+ int CFGD_CETEN = 0x01;
+
+ /* Bits in RSR */
+ int RSR_RERR = 0x00000001;
+ int RSR_CRC = 0x00000002;
+ int RSR_FAE = 0x00000004;
+ int RSR_FOV = 0x00000008;
+ int RSR_LONG = 0x00000010;
+ int RSR_RUNT = 0x00000020;
+ int RSR_SERR = 0x00000040;
+ int RSR_BUFF = 0x00000080;
+ int RSR_EDP = 0x00000100;
+ int RSR_STP = 0x00000200;
+ int RSR_CHN = 0x00000400;
+ int RSR_PHY = 0x00000800;
+ int RSR_BAR = 0x00001000;
+ int RSR_MAR = 0x00002000;
+ int RSR_RXOK = 0x00008000;
+ int RSR_ABNORMAL = RSR_RERR + RSR_LONG + RSR_RUNT;
+
+ /* Bits in TSR */
+ int TSR_NCR0 = 0x00000001;
+ int TSR_NCR1 = 0x00000002;
+ int TSR_NCR2 = 0x00000004;
+ int TSR_NCR3 = 0x00000008;
+ int TSR_COLS = 0x00000010;
+ int TSR_CDH = 0x00000080;
+ int TSR_ABT = 0x00000100;
+ int TSR_OWC = 0x00000200;
+ int TSR_CRS = 0x00000400;
+ int TSR_UDF = 0x00000800;
+ int TSR_TBUFF = 0x00001000;
+ int TSR_SERR = 0x00002000;
+ int TSR_JAB = 0x00004000;
+ int TSR_TERR = 0x00008000;
+ int TSR_ABNORMAL = TSR_TERR + TSR_OWC + TSR_ABT + TSR_JAB + TSR_CRS;
+ int TSR_OWN_BIT = 0x80000000;
+
+ int CB_DELAY_LOOP_WAIT = 10; /* 10ms */
+
+ /* enabled mask value of irq */
+ int W_IMR_MASK_VALUE = 0x1BFF; /* initial value of IMR */
+
+ /* Ethernet address filter type */
+ int PKT_TYPE_DIRECTED = 0x0001; /* obsolete, directed address is always accepted */
+ int PKT_TYPE_MULTICAST = 0x0002;
+ int PKT_TYPE_ALL_MULTICAST = 0x0004;
+ int PKT_TYPE_BROADCAST = 0x0008;
+ int PKT_TYPE_PROMISCUOUS = 0x0020;
+ int PKT_TYPE_LONG = 0x2000;
+ int PKT_TYPE_RUNT = 0x4000;
+ int PKT_TYPE_ERROR = 0x8000; /* accept error packets, e.g. CRC error */
+
+ /* Loopback mode */
+ int NIC_LB_NONE = 0x00;
+ int NIC_LB_INTERNAL = 0x01;
+ int NIC_LB_PHY = 0x02; /* MII or Internal-10BaseT loopback */
+
+ int TX_RING_SIZE = 2;
+ int RX_RING_SIZE = 2;
+ int PKT_BUF_SZ = 1536; /* Size of each temporary Rx buffer. */
+
+ int PCI_REG_MODE3 = 0x53;
+ int MODE3_MIION = 0x04; /* in PCI_REG_MOD3 OF PCI space */
+
+/* Offsets to the device registers. */
+ /*
+enum register_offsets {
+ StationAddr=0x00, RxConfig=0x06, TxConfig=0x07, ChipCmd=0x08,
+ IntrStatus=0x0C, IntrEnable=0x0E,
+ MulticastFilter0=0x10, MulticastFilter1=0x14,
+ RxRingPtr=0x18, TxRingPtr=0x1C, GFIFOTest=0x54,
+ MIIPhyAddr=0x6C, MIIStatus=0x6D, PCIBusConfig=0x6E,
+ MIICmd=0x70, MIIRegAddr=0x71, MIIData=0x72, MACRegEEcsr=0x74,
+ ConfigA=0x78, ConfigB=0x79, ConfigC=0x7A, ConfigD=0x7B,
+ RxMissed=0x7C, RxCRCErrs=0x7E, MiscCmd=0x81,
+ StickyHW=0x83, IntrStatus2=0x84, WOLcrClr=0xA4, WOLcgClr=0xA7,
+ PwrcsrClr=0xAC,
+};
+*/
+
+/* Offsets to the device registers. */
+ int StationAddr=0x00, RxConfig=0x06, TxConfig=0x07, ChipCmd=0x08,
+ IntrStatus=0x0C, IntrEnable=0x0E,
+ MulticastFilter0=0x10, MulticastFilter1=0x14,
+ RxRingPtr=0x18, TxRingPtr=0x1C, GFIFOTest=0x54,
+ MIIPhyAddr=0x6C, MIIStatus=0x6D, PCIBusConfig=0x6E,
+ MIICmd=0x70, MIIRegAddr=0x71, MIIData=0x72, MACRegEEcsr=0x74,
+ ConfigA=0x78, ConfigB=0x79, ConfigC=0x7A, ConfigD=0x7B,
+ RxMissed=0x7C, RxCRCErrs=0x7E, MiscCmd=0x81,
+ StickyHW=0x83, IntrStatus2=0x84, WOLcrClr=0xA4, WOLcgClr=0xA7,
+ PwrcsrClr=0xAC;
+
+
+/* Bits in the interrupt status/mask registers. */
+ /*
+enum intr_status_bits {
+ IntrRxDone=0x0001, IntrRxErr=0x0004, IntrRxEmpty=0x0020,
+ IntrTxDone=0x0002, IntrTxError=0x0008, IntrTxUnderrun=0x0210,
+ IntrPCIErr=0x0040,
+ IntrStatsMax=0x0080, IntrRxEarly=0x0100,
+ IntrRxOverflow=0x0400, IntrRxDropped=0x0800, IntrRxNoBuf=0x1000,
+ IntrTxAborted=0x2000, IntrLinkChange=0x4000,
+ IntrRxWakeUp=0x8000,
+ IntrNormalSummary=0x0003, IntrAbnormalSummary=0xC260,
+ IntrTxDescRace=0x080000, // mapped from IntrStatus2
+ IntrTxErrSummary=0x082218,
+};
+/* Bits in the interrupt status/mask registers. */
+
+ int IntrRxDone=0x0001, IntrRxErr=0x0004, IntrRxEmpty=0x0020,
+ IntrTxDone=0x0002, IntrTxError=0x0008, IntrTxUnderrun=0x0210,
+ IntrPCIErr=0x0040,
+ IntrStatsMax=0x0080, IntrRxEarly=0x0100,
+ IntrRxOverflow=0x0400, IntrRxDropped=0x0800, IntrRxNoBuf=0x1000,
+ IntrTxAborted=0x2000, IntrLinkChange=0x4000,
+ IntrRxWakeUp=0x8000,
+ IntrNormalSummary=0x0003, IntrAbnormalSummary=0xC260,
+ IntrTxDescRace=0x080000, // mapped from IntrStatus2
+ IntrTxErrSummary=0x082218;
+
+
+
+//#define DEFAULT_INTR (IntrRxDone | IntrRxErr | IntrRxEmpty| IntrRxOverflow | \
+// IntrRxDropped | IntrRxNoBuf)
+
+ int DEFAULT_INTR = IntrRxDone | IntrRxErr | IntrRxEmpty|
+ IntrRxOverflow | IntrRxDropped | IntrRxNoBuf;
+
+//enum rhine_revs {
+// int VT86C100A = 0x00;
+// int VTunknown0 = 0x20;
+// int VT6102 = 0x40;
+// int VT8231 = 0x50; /* Integrated MAC */
+// int VT8233 = 0x60; /* Integrated MAC */
+// int VT8235 = 0x74; /* Integrated MAC */
+// int VT8237 = 0x78; /* Integrated MAC */
+// int VTunknown1 = 0x7C;
+// int VT6105 = 0x80;
+// int VT6105_B0 = 0x83;
+// int VT6105L = 0x8A;
+// int VT6107 = 0x8C;
+// int VTunknown2 = 0x8E;
+// int VT6105M = 0x90;
+//};
+
+//enum rhine_revs {
+ int VT86C100A = 0x00;
+ int VTunknown0 = 0x20;
+ int VT6102 = 0x40;
+ int VT8231 = 0x50; /* Integrated MAC */
+ int VT8233 = 0x60; /* Integrated MAC */
+ int VT8235 = 0x74; /* Integrated MAC */
+ int VT8237 = 0x78; /* Integrated MAC */
+ int VTunknown1 = 0x7C;
+ int VT6105 = 0x80;
+ int VT6105_B0 = 0x83;
+ int VT6105L = 0x8A;
+ int VT6107 = 0x8C;
+ int VTunknown2 = 0x8E;
+ int VT6105M = 0x90;
+//};
+
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2007-04-22 20:15:58
|
Revision: 3176
http://jnode.svn.sourceforge.net/jnode/?rev=3176&view=rev
Author: lsantha
Date: 2007-04-22 13:15:57 -0700 (Sun, 22 Apr 2007)
Log Message:
-----------
Added device IDs
Modified Paths:
--------------
trunk/gui/descriptors/org.jnode.driver.video.ati.radeon.xml
Modified: trunk/gui/descriptors/org.jnode.driver.video.ati.radeon.xml
===================================================================
--- trunk/gui/descriptors/org.jnode.driver.video.ati.radeon.xml 2007-04-22 20:14:47 UTC (rev 3175)
+++ trunk/gui/descriptors/org.jnode.driver.video.ati.radeon.xml 2007-04-22 20:15:57 UTC (rev 3176)
@@ -27,6 +27,10 @@
<extension point="org.jnode.driver.mappers">
<mapper id="1002:5159" architecture="RV100" name="RV100 QY" driver-class="org.jnode.driver.video.ati.radeon.RadeonDriver" class="org.jnode.driver.bus.pci.PCIDeviceToDriverMapper"/>
<mapper id="1002:4c57" architecture="M7" name="M7 LW" driver-class="org.jnode.driver.video.ati.radeon.RadeonDriver" class="org.jnode.driver.bus.pci.PCIDeviceToDriverMapper"/>
+ <!-- todo support this
+ <mapper id="1002:5b60" architecture="RV250" name="X300 RV370 5B60" driver-class="org.jnode.driver.video.ati.radeon.RadeonDriver" class="org.jnode.driver.bus.pci.PCIDeviceToDriverMapper"/>
+ <mapper id="1002:5b70" architecture="RV250" name="X300 RV370" driver-class="org.jnode.driver.video.ati.radeon.RadeonDriver" class="org.jnode.driver.bus.pci.PCIDeviceToDriverMapper"/>
+ -->
</extension>
</plugin>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2007-04-22 20:14:49
|
Revision: 3175
http://jnode.svn.sourceforge.net/jnode/?rev=3175&view=rev
Author: lsantha
Date: 2007-04-22 13:14:47 -0700 (Sun, 22 Apr 2007)
Log Message:
-----------
More detailed exception reporting.
Modified Paths:
--------------
trunk/core/src/driver/org/jnode/driver/bus/pci/AbstractPCIDeviceToDriverMapper.java
Modified: trunk/core/src/driver/org/jnode/driver/bus/pci/AbstractPCIDeviceToDriverMapper.java
===================================================================
--- trunk/core/src/driver/org/jnode/driver/bus/pci/AbstractPCIDeviceToDriverMapper.java 2007-04-22 20:11:08 UTC (rev 3174)
+++ trunk/core/src/driver/org/jnode/driver/bus/pci/AbstractPCIDeviceToDriverMapper.java 2007-04-22 20:14:47 UTC (rev 3175)
@@ -88,7 +88,7 @@
} catch (ClassNotFoundException ex) {
log.error("Cannot find driver class " + driverClass);
} catch (InstantiationException ex) {
- log.error("Cannot instantiate driver class " + driverClass);
+ log.error("Cannot instantiate driver class " + driverClass, ex);
} catch (IllegalAccessException ex) {
log.error("Cannot access driver class " + driverClass);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2007-04-22 20:11:10
|
Revision: 3174
http://jnode.svn.sourceforge.net/jnode/?rev=3174&view=rev
Author: lsantha
Date: 2007-04-22 13:11:08 -0700 (Sun, 22 Apr 2007)
Log Message:
-----------
Handling NV11 and NV11DDR deviceses.
Modified Paths:
--------------
trunk/gui/src/driver/org/jnode/driver/video/nvidia/NVidiaDriver.java
Modified: trunk/gui/src/driver/org/jnode/driver/video/nvidia/NVidiaDriver.java
===================================================================
--- trunk/gui/src/driver/org/jnode/driver/video/nvidia/NVidiaDriver.java 2007-04-22 14:28:58 UTC (rev 3173)
+++ trunk/gui/src/driver/org/jnode/driver/video/nvidia/NVidiaDriver.java 2007-04-22 20:11:08 UTC (rev 3174)
@@ -158,6 +158,10 @@
return NV04A;
} else if (arch.equals("NV10A")) {
return NV10A;
+ } else if (arch.equals("NV11")) {
+ return NV10A;
+ } else if (arch.equals("NV11DDR")) {
+ return NV10A;
} else if (arch.equals("NV20A")) {
return NV20A;
} else if (arch.equals("NV28M")) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2007-04-22 14:29:09
|
Revision: 3173
http://jnode.svn.sourceforge.net/jnode/?rev=3173&view=rev
Author: lsantha
Date: 2007-04-22 07:28:58 -0700 (Sun, 22 Apr 2007)
Log Message:
-----------
Added PXE boot ROM for VIA Rhine NIC.
Added Paths:
-----------
trunk/all/lib/x86/pxegrub-via_rhine
Added: trunk/all/lib/x86/pxegrub-via_rhine
===================================================================
(Binary files differ)
Property changes on: trunk/all/lib/x86/pxegrub-via_rhine
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2007-04-21 13:17:52
|
Revision: 3172
http://jnode.svn.sourceforge.net/jnode/?rev=3172&view=rev
Author: lsantha
Date: 2007-04-21 06:17:50 -0700 (Sat, 21 Apr 2007)
Log Message:
-----------
Factored out the code related to emulation.
Modified Paths:
--------------
trunk/distr/build.xml
Modified: trunk/distr/build.xml
===================================================================
--- trunk/distr/build.xml 2007-04-21 13:11:19 UTC (rev 3171)
+++ trunk/distr/build.xml 2007-04-21 13:17:50 UTC (rev 3172)
@@ -36,6 +36,7 @@
<target name="compile" depends="prepare">
<jnode.compile>
<src path="${my-src.dir}/apps"/>
+ <src path="${my-src.dir}/emu"/>
<src path="${my-src.dir}/install"/>
<classpath refid="my-cp"/>
</jnode.compile>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2007-04-21 13:11:21
|
Revision: 3171
http://jnode.svn.sourceforge.net/jnode/?rev=3171&view=rev
Author: lsantha
Date: 2007-04-21 06:11:19 -0700 (Sat, 21 Apr 2007)
Log Message:
-----------
Factored out the code related to emulation.
Modified Paths:
--------------
trunk/distr/src/apps/org/jnode/apps/jpartition/JPartition.java
Added Paths:
-----------
trunk/distr/src/emu/
trunk/distr/src/emu/org/
trunk/distr/src/emu/org/jnode/
trunk/distr/src/emu/org/jnode/emu/
trunk/distr/src/emu/org/jnode/emu/DeviceManager.java
trunk/distr/src/emu/org/jnode/emu/DummyExtensionPoint.java
trunk/distr/src/emu/org/jnode/emu/EditEmu.java
trunk/distr/src/emu/org/jnode/emu/Emu.java
trunk/distr/src/emu/org/jnode/emu/ShellEmu.java
Removed Paths:
-------------
trunk/distr/src/apps/org/jnode/apps/console/ShellEmu.java
trunk/distr/src/apps/org/jnode/apps/editor/EditEmu.java
Deleted: trunk/distr/src/apps/org/jnode/apps/console/ShellEmu.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/console/ShellEmu.java 2007-04-15 21:49:12 UTC (rev 3170)
+++ trunk/distr/src/apps/org/jnode/apps/console/ShellEmu.java 2007-04-21 13:11:19 UTC (rev 3171)
@@ -1,21 +0,0 @@
-package org.jnode.apps.console;
-
-import org.jnode.test.gui.Emu;
-import org.jnode.driver.console.swing.SwingTextScreenConsoleManager;
-import org.jnode.driver.console.TextConsole;
-import org.jnode.driver.console.ConsoleManager;
-import org.jnode.shell.CommandShell;
-
-/**
- * @author Levente S\u00e1ntha
- */
-public class ShellEmu extends Emu {
-
- public static void main(String[] argv) throws Exception {
- initEnv();
- SwingTextScreenConsoleManager cm = new SwingTextScreenConsoleManager();
- new Thread(new CommandShell((TextConsole) cm.createConsole("Console 1",
- ConsoleManager.CreateOptions.TEXT | ConsoleManager.CreateOptions.SCROLLABLE))).
- start();
- }
-}
Deleted: trunk/distr/src/apps/org/jnode/apps/editor/EditEmu.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/editor/EditEmu.java 2007-04-15 21:49:12 UTC (rev 3170)
+++ trunk/distr/src/apps/org/jnode/apps/editor/EditEmu.java 2007-04-21 13:11:19 UTC (rev 3171)
@@ -1,31 +0,0 @@
-package org.jnode.apps.editor;
-
-import org.jnode.driver.console.ConsoleManager;
-import org.jnode.driver.console.swing.SwingTextScreenConsoleManager;
-import org.jnode.driver.console.textscreen.TextScreenConsole;
-import org.jnode.test.gui.Emu;
-
-import java.io.File;
-
-/**
- * @author Levente S\u00e1ntha
- */
-public class EditEmu extends Emu {
- public static void main(String[] argv) throws Exception{
- initEnv();
-
-
- if(argv.length == 0){
- System.out.println("No file specified");
- return;
- }
-
- SwingTextScreenConsoleManager cm = new SwingTextScreenConsoleManager();
- final TextScreenConsole console = cm.createConsole(null,
- ConsoleManager.CreateOptions.TEXT | ConsoleManager.CreateOptions.NO_SYSTEM_OUT_ERR_IN);
-
- TextEditor te = new TextEditor(console);
- File f = new File(argv[0]);
- te.loadFile(f);
- }
-}
Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/JPartition.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/jpartition/JPartition.java 2007-04-15 21:49:12 UTC (rev 3170)
+++ trunk/distr/src/apps/org/jnode/apps/jpartition/JPartition.java 2007-04-21 13:11:19 UTC (rev 3171)
@@ -7,11 +7,11 @@
import org.jnode.naming.InitialNaming;
import org.jnode.naming.NameSpace;
import org.jnode.test.fs.driver.stubs.StubDeviceManager;
-import org.jnode.test.gui.Emu;
import org.jnode.util.OsUtils;
+import org.jnode.emu.Emu;
+import org.jnode.driver.DeviceManager;
-public class JPartition extends Emu
-{
+public class JPartition extends Emu {
private static final Logger log = Logger.getLogger(JPartition.class);
public static void main(String[] args) throws Throwable
Added: trunk/distr/src/emu/org/jnode/emu/DeviceManager.java
===================================================================
--- trunk/distr/src/emu/org/jnode/emu/DeviceManager.java (rev 0)
+++ trunk/distr/src/emu/org/jnode/emu/DeviceManager.java 2007-04-21 13:11:19 UTC (rev 3171)
@@ -0,0 +1,101 @@
+/*
+ * $Id$
+ */
+package org.jnode.emu;
+
+import org.jnode.driver.*;
+import org.apache.log4j.Logger;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Collections;
+
+/**
+ * @author Levente S\xE1ntha
+*/
+public class DeviceManager extends AbstractDeviceManager {
+ public static final Logger log = Logger.getLogger(DeviceManager.class);
+
+ public static final DeviceManager INSTANCE = new DeviceManager();
+
+ private List<DeviceFinder> finders = new ArrayList<DeviceFinder>();
+
+ private List<DeviceToDriverMapper> mappers = new ArrayList<DeviceToDriverMapper>();
+
+ private DeviceManager() {
+ }
+
+ public void removeAll() {
+ finders.clear();
+ mappers.clear();
+
+ for (Device device : getDevices()) {
+ try {
+ unregister(device);
+ } catch (DriverException e) {
+ log.error("can't unregister " + device);
+ }
+ }
+ }
+
+ public void add(DeviceFinder finder, DeviceToDriverMapper mapper) {
+ boolean doStart = false;
+
+ if (!finders.contains(finder)) {
+ finders.add(finder);
+ doStart = true;
+ }
+
+ if (!mappers.contains(mapper)) {
+ mappers.add(mapper);
+ doStart = true;
+ }
+
+ if (doStart) {
+ start();
+ }
+ }
+
+ /**
+ * Start this manager
+ */
+ final public void start() {
+ // Thread thread = new Thread()
+ // {
+ // public void run()
+ // {
+ log.debug("Loading extensions ...");
+ loadExtensions();
+ log.debug("Extensions loaded !");
+ // }
+ // };
+ // thread.start();
+
+ try {
+ // must be called before findDeviceDrivers
+ log.debug("findDevices ...");
+ findDevices();
+
+ log.debug("findDeviceDrivers ...");
+ findDeviceDrivers();
+
+ log.debug("StubDeviceManager initialized !");
+ } catch (InterruptedException e) {
+ log.fatal("can't find devices", e);
+ }
+ }
+
+ protected final void refreshFinders(List<DeviceFinder> finders) {
+ log.info("refreshFinders");
+ finders.clear();
+ finders.addAll(this.finders);
+ }
+
+ protected final void refreshMappers(List<DeviceToDriverMapper> mappers) {
+ log.info("refreshMappers");
+ mappers.clear();
+ mappers.addAll(this.mappers);
+
+ // Now sort them
+ Collections.sort(mappers, MapperComparator.INSTANCE);
+ }
+}
Added: trunk/distr/src/emu/org/jnode/emu/DummyExtensionPoint.java
===================================================================
--- trunk/distr/src/emu/org/jnode/emu/DummyExtensionPoint.java (rev 0)
+++ trunk/distr/src/emu/org/jnode/emu/DummyExtensionPoint.java 2007-04-21 13:11:19 UTC (rev 3171)
@@ -0,0 +1,43 @@
+/*
+ * $Id$
+ */
+package org.jnode.emu;
+
+import org.jnode.plugin.ExtensionPoint;
+import org.jnode.plugin.Extension;
+import org.jnode.plugin.ExtensionPointListener;
+import org.jnode.plugin.PluginDescriptor;
+
+/**
+ * @author Levente S\xE1ntha
+*/
+class DummyExtensionPoint implements ExtensionPoint {
+ public String getSimpleIdentifier() {
+ return "A";
+ }
+
+ public String getUniqueIdentifier() {
+ return "aaa";
+ }
+
+ public String getName() {
+ return "B";
+ }
+
+ public Extension[] getExtensions() {
+ return new Extension[0];
+ }
+
+ public void addListener(ExtensionPointListener listener) {
+ }
+
+ public void addPriorityListener(ExtensionPointListener listener) {
+ }
+
+ public void removeListener(ExtensionPointListener listener) {
+ }
+
+ public PluginDescriptor getDeclaringPluginDescriptor() {
+ return null;
+ }
+}
Added: trunk/distr/src/emu/org/jnode/emu/EditEmu.java
===================================================================
--- trunk/distr/src/emu/org/jnode/emu/EditEmu.java (rev 0)
+++ trunk/distr/src/emu/org/jnode/emu/EditEmu.java 2007-04-21 13:11:19 UTC (rev 3171)
@@ -0,0 +1,31 @@
+package org.jnode.emu;
+
+import org.jnode.driver.console.ConsoleManager;
+import org.jnode.driver.console.swing.SwingTextScreenConsoleManager;
+import org.jnode.driver.console.textscreen.TextScreenConsole;
+import org.jnode.apps.editor.TextEditor;
+
+import java.io.File;
+
+/**
+ * @author Levente S\u00e1ntha
+ */
+public class EditEmu extends Emu {
+ public static void main(String[] argv) throws Exception{
+ initEnv();
+
+
+ if(argv.length == 0){
+ System.out.println("No file specified");
+ return;
+ }
+
+ SwingTextScreenConsoleManager cm = new SwingTextScreenConsoleManager();
+ final TextScreenConsole console = cm.createConsole(null,
+ ConsoleManager.CreateOptions.TEXT | ConsoleManager.CreateOptions.NO_SYSTEM_OUT_ERR_IN);
+
+ TextEditor te = new TextEditor(console);
+ File f = new File(argv[0]);
+ te.loadFile(f);
+ }
+}
Added: trunk/distr/src/emu/org/jnode/emu/Emu.java
===================================================================
--- trunk/distr/src/emu/org/jnode/emu/Emu.java (rev 0)
+++ trunk/distr/src/emu/org/jnode/emu/Emu.java 2007-04-21 13:11:19 UTC (rev 3171)
@@ -0,0 +1,61 @@
+package org.jnode.emu;
+
+import org.jnode.naming.InitialNaming;
+import org.jnode.naming.NameSpace;
+import org.jnode.shell.alias.AliasManager;
+import org.jnode.shell.alias.def.DefaultAliasManager;
+import org.jnode.shell.ShellManager;
+import org.jnode.shell.help.Help;
+import org.jnode.shell.help.def.DefaultHelp;
+import org.jnode.shell.def.DefaultShellManager;
+
+import javax.naming.NamingException;
+import javax.naming.NameAlreadyBoundException;
+import javax.naming.NameNotFoundException;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Set;
+
+/**
+ * @author Levente S\u00e1ntha
+ */
+public class Emu {
+ protected static void initEnv() throws NamingException {
+ if(true){
+ InitialNaming.setNameSpace(new NameSpace() {
+ private Map<Class<?>, Object> space = new HashMap<Class<?>, Object>();
+
+ public <T> void bind(Class<T> name, T service) throws NamingException, NameAlreadyBoundException {
+ if (space.get(name) != null) throw new NameAlreadyBoundException();
+ space.put(name, service);
+ }
+
+ public void unbind(Class<?> name) {
+ space.remove(name);
+ }
+
+ public <T> T lookup(Class<T> name) throws NameNotFoundException {
+ T obj = (T) space.get(name);
+ if (obj == null) throw new NameNotFoundException(name.getName());
+ return obj;
+ }
+
+ public Set<Class<?>> nameSet() {
+ return space.keySet();
+ }
+ });
+ InitialNaming.bind(DeviceManager.NAME, DeviceManager.INSTANCE);
+ AliasManager alias_mgr = new DefaultAliasManager(new DummyExtensionPoint()).createAliasManager();
+ alias_mgr.add("console", "org.jnode.shell.command.driver.console.ConsoleCommand");
+ alias_mgr.add("help", "org.jnode.shell.command.HelpCommand");
+ alias_mgr.add("alias", "org.jnode.shell.command.AliasCommand");
+ alias_mgr.add("exit", "org.jnode.shell.command.ExitCommand");
+ alias_mgr.add("edit", "org.jnode.apps.edit.EditCommand");
+ alias_mgr.add("leed", "org.jnode.apps.editor.LeedCommand");
+ alias_mgr.add("sconsole", "org.jnode.apps.console.SwingConsole");
+ InitialNaming.bind(AliasManager.NAME, alias_mgr);
+ InitialNaming.bind(ShellManager.NAME, new DefaultShellManager());
+ InitialNaming.bind(Help.NAME, new DefaultHelp());
+ }
+ }
+}
Added: trunk/distr/src/emu/org/jnode/emu/ShellEmu.java
===================================================================
--- trunk/distr/src/emu/org/jnode/emu/ShellEmu.java (rev 0)
+++ trunk/distr/src/emu/org/jnode/emu/ShellEmu.java 2007-04-21 13:11:19 UTC (rev 3171)
@@ -0,0 +1,19 @@
+package org.jnode.emu;
+
+import org.jnode.driver.console.swing.SwingTextScreenConsoleManager;
+import org.jnode.driver.console.ConsoleManager;
+import org.jnode.shell.CommandShell;
+
+/**
+ * @author Levente S\u00e1ntha
+ */
+public class ShellEmu extends Emu {
+
+ public static void main(String[] argv) throws Exception {
+ initEnv();
+ SwingTextScreenConsoleManager cm = new SwingTextScreenConsoleManager();
+ new Thread(new CommandShell(cm.createConsole("Console 1",
+ ConsoleManager.CreateOptions.TEXT | ConsoleManager.CreateOptions.SCROLLABLE))).
+ start();
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fd...@us...> - 2007-04-15 21:49:18
|
Revision: 3170
http://jnode.svn.sourceforge.net/jnode/?rev=3170&view=rev
Author: fduminy
Date: 2007-04-15 14:49:12 -0700 (Sun, 15 Apr 2007)
Log Message:
-----------
minor code cleanup
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/service/def/FileHandleManager.java
Modified: trunk/fs/src/fs/org/jnode/fs/service/def/FileHandleManager.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/service/def/FileHandleManager.java 2007-04-15 21:46:06 UTC (rev 3169)
+++ trunk/fs/src/fs/org/jnode/fs/service/def/FileHandleManager.java 2007-04-15 21:49:12 UTC (rev 3170)
@@ -50,12 +50,10 @@
FileData fd = openFiles.get(file);
if (fd == null) {
fd = new FileData(file);
- final FileHandleImpl handle = fd.open(mode);
openFiles.put(file, fd);
- return handle;
- } else {
- return fd.open(mode);
}
+
+ return fd.open(mode);
}
/**
@@ -143,7 +141,7 @@
handles.add(newHandle);
return newHandle;
} else {
- throw new IOException("FileHandle is not known in FileData.close!!");
+ throw new IOException("FileHandle is not known in FileData.dup!!");
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|