code
stringlengths 3
1.05M
| repo_name
stringlengths 4
116
| path
stringlengths 3
942
| language
stringclasses 30
values | license
stringclasses 15
values | size
int32 3
1.05M
|
---|---|---|---|---|---|
/*******************************************************************************
* Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Based on org.eclipse.jdt.internal.ui.text.javadoc.JavaDocAutoIndentStrategy
*
* Contributors:
* IBM Corporation - initial API and implementation
* Red Hat, Inc - decoupling from jdt.ui
*******************************************************************************/
package org.eclipse.jdt.ls.core.internal.contentassist;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.ISourceRange;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.manipulation.CodeGeneration;
import org.eclipse.jdt.internal.core.manipulation.StubUtility;
import org.eclipse.jdt.internal.corext.util.MethodOverrideTester;
import org.eclipse.jdt.internal.corext.util.SuperTypeHierarchyCache;
import org.eclipse.jdt.ls.core.internal.JDTUtils;
import org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin;
import org.eclipse.jdt.ls.core.internal.handlers.CompletionResolveHandler;
import org.eclipse.jdt.ls.core.internal.handlers.JsonRpcHelpers;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.TextUtilities;
import org.eclipse.lsp4j.CompletionItem;
import org.eclipse.lsp4j.CompletionItemKind;
import org.eclipse.lsp4j.InsertTextFormat;
import org.eclipse.lsp4j.Range;
import org.eclipse.lsp4j.TextEdit;
public class JavadocCompletionProposal {
private static final String ASTERISK = "*";
private static final String WHITESPACES = " \t";
public static final String JAVA_DOC_COMMENT = "Javadoc comment";
public List<CompletionItem> getProposals(ICompilationUnit cu, int offset, CompletionProposalRequestor collector, IProgressMonitor monitor) throws JavaModelException {
if (cu == null) {
throw new IllegalArgumentException("Compilation unit must not be null"); //$NON-NLS-1$
}
List<CompletionItem> result = new ArrayList<>();
IDocument d = JsonRpcHelpers.toDocument(cu.getBuffer());
if (offset < 0 || d.getLength() == 0) {
return result;
}
try {
int p = (offset == d.getLength() ? offset - 1 : offset);
IRegion line = d.getLineInformationOfOffset(p);
String lineStr = d.get(line.getOffset(), line.getLength()).trim();
if (!lineStr.startsWith("/**")) {
return result;
}
if (!hasEndJavadoc(d, offset)) {
return result;
}
String text = collector.getContext().getToken() == null ? "" : new String(collector.getContext().getToken());
StringBuilder buf = new StringBuilder(text);
IRegion prefix = findPrefixRange(d, line);
String indentation = d.get(prefix.getOffset(), prefix.getLength());
int lengthToAdd = Math.min(offset - prefix.getOffset(), prefix.getLength());
buf.append(indentation.substring(0, lengthToAdd));
String lineDelimiter = TextUtilities.getDefaultLineDelimiter(d);
ICompilationUnit unit = cu;
try {
unit.reconcile(ICompilationUnit.NO_AST, false, null, null);
String string = createJavaDocTags(d, offset, indentation, lineDelimiter, unit);
if (string != null && !string.trim().equals(ASTERISK)) {
buf.append(string);
} else {
return result;
}
int nextNonWS = findEndOfWhiteSpace(d, offset, d.getLength());
if (!Character.isWhitespace(d.getChar(nextNonWS))) {
buf.append(lineDelimiter);
}
} catch (CoreException e) {
// ignore
}
final CompletionItem ci = new CompletionItem();
Range range = JDTUtils.toRange(unit, offset, 0);
boolean isSnippetSupported = JavaLanguageServerPlugin.getPreferencesManager().getClientPreferences().isCompletionSnippetsSupported();
String replacement = prepareTemplate(buf.toString(), lineDelimiter, isSnippetSupported);
ci.setTextEdit(new TextEdit(range, replacement));
ci.setFilterText(JAVA_DOC_COMMENT);
ci.setLabel(JAVA_DOC_COMMENT);
ci.setSortText(SortTextHelper.convertRelevance(0));
ci.setKind(CompletionItemKind.Snippet);
ci.setInsertTextFormat(isSnippetSupported ? InsertTextFormat.Snippet : InsertTextFormat.PlainText);
String documentation = prepareTemplate(buf.toString(), lineDelimiter, false);
if (documentation.indexOf(lineDelimiter) == 0) {
documentation = documentation.replaceFirst(lineDelimiter, "");
}
ci.setDocumentation(documentation);
Map<String, String> data = new HashMap<>(3);
data.put(CompletionResolveHandler.DATA_FIELD_URI, JDTUtils.toURI(cu));
data.put(CompletionResolveHandler.DATA_FIELD_REQUEST_ID, "0");
data.put(CompletionResolveHandler.DATA_FIELD_PROPOSAL_ID, "0");
ci.setData(data);
result.add(ci);
} catch (BadLocationException excp) {
// stop work
}
return result;
}
private String prepareTemplate(String text, String lineDelimiter, boolean addGap) {
boolean endWithLineDelimiter = text.endsWith(lineDelimiter);
String[] lines = text.split(lineDelimiter);
StringBuilder buf = new StringBuilder();
for (int i = 0; i < lines.length; i++) {
String line = lines[i];
if (addGap) {
String stripped = StringUtils.stripStart(line, WHITESPACES);
if (stripped.startsWith(ASTERISK)) {
if (!stripped.equals(ASTERISK)) {
int index = line.indexOf(ASTERISK);
buf.append(line.substring(0, index + 1));
buf.append(" ${0}");
buf.append(lineDelimiter);
}
addGap = false;
}
}
buf.append(StringUtils.stripEnd(line, WHITESPACES));
if (i < lines.length - 1 || endWithLineDelimiter) {
buf.append(lineDelimiter);
}
}
return buf.toString();
}
private IRegion findPrefixRange(IDocument document, IRegion line) throws BadLocationException {
int lineOffset = line.getOffset();
int lineEnd = lineOffset + line.getLength();
int indentEnd = findEndOfWhiteSpace(document, lineOffset, lineEnd);
if (indentEnd < lineEnd && document.getChar(indentEnd) == '*') {
indentEnd++;
while (indentEnd < lineEnd && document.getChar(indentEnd) == ' ') {
indentEnd++;
}
}
return new Region(lineOffset, indentEnd - lineOffset);
}
private int findEndOfWhiteSpace(IDocument document, int offset, int end) throws BadLocationException {
while (offset < end) {
char c = document.getChar(offset);
if (c != ' ' && c != '\t') {
return offset;
}
offset++;
}
return end;
}
private boolean hasEndJavadoc(IDocument document, int offset) throws BadLocationException {
int pos = -1;
while (offset < document.getLength()) {
char c = document.getChar(offset);
if (!Character.isWhitespace(c) && !(c == '*')) {
pos = offset;
break;
}
offset++;
}
if (document.getLength() >= pos + 2 && document.get(pos - 1, 2).equals("*/")) {
return true;
}
return false;
}
private String createJavaDocTags(IDocument document, int offset, String indentation, String lineDelimiter, ICompilationUnit unit) throws CoreException, BadLocationException {
IJavaElement element = unit.getElementAt(offset);
if (element == null) {
return null;
}
switch (element.getElementType()) {
case IJavaElement.TYPE:
return createTypeTags(document, offset, indentation, lineDelimiter, (IType) element);
case IJavaElement.METHOD:
return createMethodTags(document, offset, indentation, lineDelimiter, (IMethod) element);
default:
return null;
}
}
private String createTypeTags(IDocument document, int offset, String indentation, String lineDelimiter, IType type) throws CoreException, BadLocationException {
if (!accept(offset, type)) {
return null;
}
String[] typeParamNames = StubUtility.getTypeParameterNames(type.getTypeParameters());
String comment = CodeGeneration.getTypeComment(type.getCompilationUnit(), type.getTypeQualifiedName('.'), typeParamNames, lineDelimiter);
if (comment != null) {
return prepareTemplateComment(comment.trim(), indentation, type.getJavaProject(), lineDelimiter);
}
return null;
}
private boolean accept(int offset, IMember member) throws JavaModelException {
ISourceRange nameRange = member.getNameRange();
if (nameRange == null) {
return false;
}
int srcOffset = nameRange.getOffset();
return srcOffset > offset;
}
private String createMethodTags(IDocument document, int offset, String indentation, String lineDelimiter, IMethod method) throws CoreException, BadLocationException {
if (!accept(offset, method)) {
return null;
}
IMethod inheritedMethod = getInheritedMethod(method);
String comment = CodeGeneration.getMethodComment(method, inheritedMethod, lineDelimiter);
if (comment != null) {
comment = comment.trim();
boolean javadocComment = comment.startsWith("/**"); //$NON-NLS-1$
if (javadocComment) {
return prepareTemplateComment(comment, indentation, method.getJavaProject(), lineDelimiter);
}
}
return null;
}
private String prepareTemplateComment(String comment, String indentation, IJavaProject project, String lineDelimiter) {
// trim comment start and end if any
if (comment.endsWith("*/")) {
comment = comment.substring(0, comment.length() - 2);
}
comment = comment.trim();
if (comment.startsWith("/*")) { //$NON-NLS-1$
if (comment.length() > 2 && comment.charAt(2) == '*') {
comment = comment.substring(3); // remove '/**'
} else {
comment = comment.substring(2); // remove '/*'
}
}
// trim leading spaces, but not new lines
int nonSpace = 0;
int len = comment.length();
while (nonSpace < len && Character.getType(comment.charAt(nonSpace)) == Character.SPACE_SEPARATOR) {
nonSpace++;
}
comment = comment.substring(nonSpace);
return comment;
}
private IMethod getInheritedMethod(IMethod method) throws JavaModelException {
IType declaringType = method.getDeclaringType();
MethodOverrideTester tester = SuperTypeHierarchyCache.getMethodOverrideTester(declaringType);
return tester.findOverriddenMethod(method, true);
}
}
| gorkem/java-language-server | org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/contentassist/JavadocCompletionProposal.java | Java | epl-1.0 | 10,626 |
package mx.com.cinepolis.digital.booking.commons.exception;
/**
* Clase con los códigos de errores para las excepciones
* @author rgarcia
*
*/
public enum DigitalBookingExceptionCode
{
/** Error desconocido */
GENERIC_UNKNOWN_ERROR(0),
/***
* CATALOG NULO
*/
CATALOG_ISNULL(1),
/**
* Paging Request Nulo
*/
PAGING_REQUEST_ISNULL(2),
/**
* Errores de persistencia
*/
PERSISTENCE_ERROR_GENERIC(3),
PERSISTENCE_ERROR_NEW_OBJECT_FOUND_DURING_COMMIT(4),
PERSISTENCE_ERROR_CATALOG_ALREADY_REGISTERED(5),
PERSISTENCE_ERROR_CATALOG_NOT_FOUND(6),
PERSISTENCE_ERROR_CATALOG_ALREADY_REGISTERED_WITH_ID_VISTA(7),
PERSISTENCE_ERROR_WEEK_ALREADY_REGISTERED(8),
/**
* Errores de Administración de Catalogos
*/
THEATER_NUM_THEATER_ALREADY_EXISTS(9),
CANNOT_DELETE_REGION(10),
INEXISTENT_REGION(11),
INVALID_TERRITORY(12),
THEATER_IS_NULL(13),
THEATER_IS_NOT_IN_ANY_REGION(14),
THEATER_NOT_HAVE_SCREENS(15),
INEXISTENT_THEATER(16),
THEATER_IS_NOT_IN_ANY_CITY(17),
THEATER_IS_NOT_IN_ANY_STATE(18),
INVALID_SCREEN(19),
INVALID_MOVIE_FORMATS(20),
INVALID_SOUND_FORMATS(21),
FILE_NULL(22),
EVENT_MOVIE_NULL(23),
/**
* Errores de Administración de cines
*/
SCREEN_NUMBER_ALREADY_EXISTS(24),
SCREEN_NEEDS_AT_LEAST_ONE_SOUND_FORMAT(25),
SCREEN_NEEDS_AT_LEAST_ONE_MOVIE_FORMAT(26),
DISTRIBUTOR_IS_ASSOCIATED_WITH_AN_EXISTING_MOVIE(27),
CATEGORY_SOUND_FORMAT_IS_ASSOCIATED_WITH_AN_EXISTING_MOVIE(28),
CATEGORY_SOUND_FORMAT_IS_ASSOCIATED_WITH_AN_EXISTING_SCREEN(29),
CATEGORY_MOVIE_FORMAT_IS_ASSOCIATED_WITH_AN_EXISTING_MOVIE(30),
CATEGORY_MOVIE_FORMAT_IS_ASSOCIATED_WITH_AN_EXISTING_SCREEN(31),
CATEGORY_SCREEN_FORMAT_IS_ASSOCIATED_WITH_AN_EXISTING_SCREEN(39),
SCREEN_NEEDS_SCREEN_FORMAT(32),
MOVIE_NAME_BLANK(33),
MOVIE_DISTRIBUTOR_NULL(35),
MOVIE_COUNTRIES_EMPTY(36),
MOVIE_DETAIL_EMPTY(37),
MOVIE_IMAGE_NULL(38),
/**
* Booking errors
*/
BOOKING_PERSISTENCE_ERROR_STATUS_NOT_FOUND(40),
BOOKING_PERSISTENCE_ERROR_EVENT_NOT_FOUND(41),
BOOKING_PERSISTENCE_ERROR_THEATER_NOT_FOUND(42),
BOOKING_PERSISTENCE_ERROR_WEEK_NOT_FOUND(43),
BOOKING_PERSISTENCE_ERROR_BOOKING_NOT_FOUND(44),
BOOKING_PERSISTENCE_ERROR_USER_NOT_FOUND(45),
BOOKING_PERSISTENCE_ERROR_EVENT_TYPE_NOT_FOUND(46),
BOOKING_PERSISTENCE_ERROR_AT_CONSULT_BOOKINGS(221),
/**
* Week errors
*/
WEEK_PERSISTENCE_ERROR_NOT_FOUND(50),
/**
* Observation errors
*/
NEWS_FEED_OBSERVATION_NOT_FOUND(51),
BOOKING_OBSERVATION_NOT_FOUND2(52),
OBSERVATION_NOT_FOUND(53),
NEWS_FEED_OBSERVATION_ASSOCIATED_TO_ANOTHER_USER(103),
/**
* Email Errors
*/
EMAIL_DOES_NOT_COMPLIES_REGEX(54),
EMAIL_IS_REPEATED(55),
/**
* Configuration Errors
*/
CONFIGURATION_ID_IS_NULL(60),
CONFIGURATION_NAME_IS_NULL(61),
CONFIGURATION_PARAMETER_NOT_FOUND(62),
/**
* Email Errors
*/
ERROR_SENDING_EMAIL_NO_DATA(70),
ERROR_SENDING_EMAIL_NO_RECIPIENTS(71),
ERROR_SENDING_EMAIL_SUBJECT(72),
ERROR_SENDING_EMAIL_MESSAGE(73),
/**
* Booking errors
*/
BOOKING_IS_NULL(74),
BOOKING_COPIES_IS_NULL(75),
BOOKING_WEEK_NULL(76),
BOOKING_EVENT_NULL(77),
BOOKING_WRONG_STATUS_FOR_CANCELLATION(78),
BOOKING_WRONG_STATUS_FOR_TERMINATION(79),
BOOKING_THEATER_NEEDS_WEEK_ID(80),
BOOKING_THEATER_NEEDS_THEATER_ID(81),
BOOKING_NUMBER_COPIES_ZERO(82),
BOOKING_NUM_SCREENS_GREATER_NUM_COPIES(83),
BOOKING_CAN_NOT_BE_CANCELED(84),
BOOKING_CAN_NOT_BE_TERMINATED(85),
BOOKING_WRONG_STATUS_FOR_EDITION(86),
ERROR_THEATER_HAS_NO_EMAIL(87),
BOOKING_NUMBER_OF_COPIES_EXCEEDS_NUMBER_OF_SCREENS(88),
BOOKING_NON_EDITABLE_WEEK(89),
BOOKING_THEATER_REPEATED(90),
BOOKING_IS_WEEK_ONE(91),
BOOKING_THEATER_HAS_SCREEN_ZERO(92),
BOOKING_MAXIMUM_COPY(93),
BOOKING_NOT_SAVED_FOR_CANCELLATION(94),
BOOKING_NOT_SAVED_FOR_TERMINATION(194),
BOOKING_NOT_THEATERS_IN_REGION(196),
BOOKING_NUMBER_OF_COPIES_EXCEEDS_NUMBER_OF_SCREENS_WHIT_THIS_FORMAT(195),
BOOKING_NUM_SCREENS_GREATER_NUM_COPIES_NO_THEATER(95),
BOOKING_SENT_CAN_NOT_BE_CANCELED(96),
BOOKING_SENT_CAN_NOT_BE_TERMINATED(97),
BOOKING_WITH_FOLLOWING_WEEK_CAN_NOT_BE_CANCELED(98),
BOOKING_WITH_FOLLOWING_WEEK_CAN_NOT_BE_TERMINATED(99),
/**
* Report errors
*/
CREATE_XLSX_ERROR(100),
BOOKING_THEATER_IS_NOT_ASSIGNED_TO_ANY_SCREEN(101),
SEND_EMAIL_REGION_ERROR_CAN_ONLY_UPLOAD_UP_TO_TWO_FILES(102),
/**
* Security errors
*/
SECURITY_ERROR_USER_DOES_NOT_EXISTS(200),
SECURITY_ERROR_PASSWORD_INVALID(201),
SECURITY_ERROR_INVALID_USER(202),
MENU_EXCEPTION(203),
/**
* UserErrors
*/
USER_IS_NULL(204),
USER_USERNAME_IS_BLANK(205),
USER_NAME_IS_BLANK(206),
USER_LAST_NAME_IS_BLANK(207),
USER_ROLE_IS_NULL(208),
USER_EMAIL_IS_NULL(209),
USER_THE_USERNAME_IS_DUPLICATE(210),
USER_TRY_DELETE_OWN_USER(211),
/**
* Week errors
*/
WEEK_IS_NULL(212),
WEEK_INVALID_NUMBER(213),
WEEK_INVALID_YEAR(214),
WEEK_INVALID_FINAL_DAY(215),
/**
* EventMovie errors
*/
EVENT_CODE_DBS_NULL(216),
CATALOG_ALREADY_REGISTERED_WITH_DS_CODE_DBS(217),
CATALOG_ALREADY_REGISTERED_WITH_SHORT_NAME(218),
CANNOT_DELETE_WEEK(219),
CANNOT_REMOVE_EVENT_MOVIE(220),
/**
* Income errors
*/
INCOMES_COULD_NOT_OBTAIN_DATABASE_PROPERTIES(300),
INCOMES_DRIVER_ERROR(301),
INCOMES_CONNECTION_ERROR(302),
/**
* SynchronizeErrors
*/
CANNOT_CONNECT_TO_SERVICE(500),
/**
* Transaction timeout
*/
TRANSACTION_TIMEOUT(501),
/**
* INVALID PARAMETERS FOR BOOKING PRE RELEASE
*/
INVALID_COPIES_PARAMETER(600),
INVALID_DATES_PARAMETERS(601),
INVALID_SCREEN_PARAMETER_CASE_ONE(602),
INVALID_SCREEN_PARAMETER_CASE_TWO(603),
INVALID_DATES_BEFORE_TODAY_PARAMETERS(604),
INVALID_PRESALE_DATES_PARAMETERS(605),
/**
* VALIDATIONS FOR PRESALE IN BOOKING MOVIE
*/
ERROR_BOOKING_PRESALE_FOR_NO_PREMIERE(606),
ERROR_BOOKING_PRESALE_FOR_ZERO_SCREEN(607),
ERROR_BOOKING_PRESALE_NOT_ASSOCIATED_AT_BOOKING(608),
/**
* INVALID SELECTION OF PARAMETERS
* TO APPLY IN SPECIAL EVENT
*/
INVALID_STARTING_DATES(617),
INVALID_FINAL_DATES(618),
INVALID_STARTING_AND_RELREASE_DATES(619),
INVALID_THEATER_SELECTION(620),
INVALID_SCREEN_SELECTION(621),
BOOKING_THEATER_NULL(622),
BOOKING_TYPE_INVALID(623),
BOOKING_SPECIAL_EVENT_LIST_EMPTY(624),
/**
* Invalid datetime range for system log.
*/
LOG_FINAL_DATE_BEFORE_START_DATE(625),
LOG_INVALID_DATE_RANGE(626),
LOG_INVALID_TIME_RANGE(627),
/**
* Invavlid cityTO
*/
CITY_IS_NULL(628),
CITY_HAS_NO_NAME(629),
CITY_HAS_NO_COUNTRY(630),
CITY_INVALID_LIQUIDATION_ID(631),
PERSISTENCE_ERROR_CATALOG_ALREADY_REGISTERED_WITH_LIQUIDATION_ID(632)
;
/**
* Constructor interno
*
* @param id
*/
private DigitalBookingExceptionCode( int id )
{
this.id = id;
}
private int id;
/**
* @return the id
*/
public int getId()
{
return id;
}
}
| sidlors/digital-booking | digital-booking-commons/src/main/java/mx/com/cinepolis/digital/booking/commons/exception/DigitalBookingExceptionCode.java | Java | epl-1.0 | 7,193 |
package com.temenos.soa.plugin.uml2dsconverter.utils;
// General String utilities
public class StringUtils {
/**
* Turns the first character of a string in to an uppercase character
* @param source The source string
* @return String Resultant string
*/
public static String upperInitialCharacter(String source) {
final StringBuilder result = new StringBuilder(source.length());
result.append(Character.toUpperCase(source.charAt(0))).append(source.substring(1));
return result.toString();
}
/**
* Turns the first character of a string in to a lowercase character
* @param source The source string
* @return String Resultant string
*/
public static String lowerInitialCharacter(String source) {
final StringBuilder result = new StringBuilder(source.length());
result.append(Character.toLowerCase(source.charAt(0))).append(source.substring(1));
return result.toString();
}
}
| junejosheeraz/UML2DS | com.temenos.soa.plugin.uml2dsconverter/src/com/temenos/soa/plugin/uml2dsconverter/utils/StringUtils.java | Java | epl-1.0 | 938 |
# -*- coding: utf-8 -*-
#
# Phaser Editor documentation build configuration file, created by
# sphinx-quickstart on Thu May 25 08:35:14 2017.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
#'rinoh.frontend.sphinx'
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'Phaser Editor 2D'
copyright = u'2016-2020, Arian Fornaris'
author = u'Arian Fornaris'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = u'2.1.7'
# The full version, including alpha/beta/rc tags.
release = u'2.1.7'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
# The name of the Pygments (syntax highlighting) style to use.
# pygments_style = 'sphinx'
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
# -- Options for HTML output ----------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
#import sphinx_rtd_theme
html_theme = "phaser-editor"
# Uncomment for generate Eclipse Offline Help
#html_theme = "eclipse-help"
html_theme_path = ["_themes"]
html_show_sourcelink = False
html_show_sphinx = False
html_favicon = "logo.png"
html_title = "Phaser Editor Help"
html_show_copyright = True
print(html_theme_path)
#html_theme = 'classic'
highlight_language = 'javascript'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# -- Options for HTMLHelp output ------------------------------------------
# Output file base name for HTML help builder.
htmlhelp_basename = 'PhaserEditordoc'
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
'preamble': '',
# Latex figure (float) alignment
#
'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'PhaserEditor2D.tex', u'Phaser Editor 2D Documentation',
u'Arian Fornaris', 'manual'),
]
# -- Options for Texinfo output -------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'PhaserEditor2D', u'Phaser Editor 2D Documentation',
author, 'Arian', 'A friendly HTML5 game IDE.',
'Miscellaneous'),
]
| boniatillo-com/PhaserEditor | docs/v2/conf.py | Python | epl-1.0 | 4,869 |
/******************************************************************************
* Copyright (c) 2000-2015 Ericsson Telecom AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
******************************************************************************/
package org.eclipse.titan.designer.AST.TTCN3.values.expressions;
import java.util.List;
import org.eclipse.titan.designer.AST.ASTVisitor;
import org.eclipse.titan.designer.AST.INamedNode;
import org.eclipse.titan.designer.AST.IReferenceChain;
import org.eclipse.titan.designer.AST.IValue;
import org.eclipse.titan.designer.AST.ReferenceFinder;
import org.eclipse.titan.designer.AST.Scope;
import org.eclipse.titan.designer.AST.Value;
import org.eclipse.titan.designer.AST.IType.Type_type;
import org.eclipse.titan.designer.AST.ReferenceFinder.Hit;
import org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type;
import org.eclipse.titan.designer.AST.TTCN3.values.Expression_Value;
import org.eclipse.titan.designer.AST.TTCN3.values.Hexstring_Value;
import org.eclipse.titan.designer.AST.TTCN3.values.Octetstring_Value;
import org.eclipse.titan.designer.parsers.CompilationTimeStamp;
import org.eclipse.titan.designer.parsers.ttcn3parser.ReParseException;
import org.eclipse.titan.designer.parsers.ttcn3parser.TTCN3ReparseUpdater;
/**
* @author Kristof Szabados
* */
public final class Hex2OctExpression extends Expression_Value {
private static final String OPERANDERROR = "The operand of the `hex2oct' operation should be a hexstring value";
private final Value value;
public Hex2OctExpression(final Value value) {
this.value = value;
if (value != null) {
value.setFullNameParent(this);
}
}
@Override
public Operation_type getOperationType() {
return Operation_type.HEX2OCT_OPERATION;
}
@Override
public String createStringRepresentation() {
final StringBuilder builder = new StringBuilder();
builder.append("hex2oct(").append(value.createStringRepresentation()).append(')');
return builder.toString();
}
@Override
public void setMyScope(final Scope scope) {
super.setMyScope(scope);
if (value != null) {
value.setMyScope(scope);
}
}
@Override
public StringBuilder getFullName(final INamedNode child) {
final StringBuilder builder = super.getFullName(child);
if (value == child) {
return builder.append(OPERAND);
}
return builder;
}
@Override
public Type_type getExpressionReturntype(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue) {
return Type_type.TYPE_OCTETSTRING;
}
@Override
public boolean isUnfoldable(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue,
final IReferenceChain referenceChain) {
if (value == null) {
return true;
}
return value.isUnfoldable(timestamp, expectedValue, referenceChain);
}
/**
* Checks the parameters of the expression and if they are valid in
* their position in the expression or not.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param expectedValue
* the kind of value expected.
* @param referenceChain
* a reference chain to detect cyclic references.
* */
private void checkExpressionOperands(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue,
final IReferenceChain referenceChain) {
if (value == null) {
return;
}
value.setLoweridToReference(timestamp);
Type_type tempType = value.getExpressionReturntype(timestamp, expectedValue);
switch (tempType) {
case TYPE_HEXSTRING:
value.getValueRefdLast(timestamp, expectedValue, referenceChain);
return;
case TYPE_UNDEFINED:
setIsErroneous(true);
return;
default:
if (!isErroneous) {
location.reportSemanticError(OPERANDERROR);
setIsErroneous(true);
}
return;
}
}
@Override
public IValue evaluateValue(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue,
final IReferenceChain referenceChain) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return lastValue;
}
isErroneous = false;
lastTimeChecked = timestamp;
lastValue = this;
if (value == null) {
return lastValue;
}
checkExpressionOperands(timestamp, expectedValue, referenceChain);
if (getIsErroneous(timestamp)) {
return lastValue;
}
if (isUnfoldable(timestamp, referenceChain)) {
return lastValue;
}
IValue last = value.getValueRefdLast(timestamp, referenceChain);
if (last.getIsErroneous(timestamp)) {
setIsErroneous(true);
return lastValue;
}
switch (last.getValuetype()) {
case HEXSTRING_VALUE:
String temp = ((Hexstring_Value) last).getValue();
lastValue = new Octetstring_Value(hex2oct(temp));
lastValue.copyGeneralProperties(this);
break;
default:
setIsErroneous(true);
break;
}
return lastValue;
}
public static String hex2oct(final String hexString) {
if (hexString.length() % 2 == 0) {
return hexString;
}
return new StringBuilder(hexString.length() + 1).append('0').append(hexString).toString();
}
@Override
public void checkRecursions(final CompilationTimeStamp timestamp, final IReferenceChain referenceChain) {
if (referenceChain.add(this) && value != null) {
referenceChain.markState();
value.checkRecursions(timestamp, referenceChain);
referenceChain.previousState();
}
}
@Override
public void updateSyntax(final TTCN3ReparseUpdater reparser, final boolean isDamaged) throws ReParseException {
if (isDamaged) {
throw new ReParseException();
}
if (value != null) {
value.updateSyntax(reparser, false);
reparser.updateLocation(value.getLocation());
}
}
@Override
public void findReferences(final ReferenceFinder referenceFinder, final List<Hit> foundIdentifiers) {
if (value == null) {
return;
}
value.findReferences(referenceFinder, foundIdentifiers);
}
@Override
protected boolean memberAccept(final ASTVisitor v) {
if (value != null && !value.accept(v)) {
return false;
}
return true;
}
}
| alovassy/titan.EclipsePlug-ins | org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/values/expressions/Hex2OctExpression.java | Java | epl-1.0 | 6,252 |
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="copyright" content="(C) Copyright 2010" />
<meta name="DC.rights.owner" content="(C) Copyright 2010" />
<meta name="DC.Type" content="concept" />
<meta name="DC.Title" content="Selecting and Using a Font" />
<meta name="DC.Relation" scheme="URI" content="GUID-98B85D7F-7BD9-5056-A99F-0BC99D921B87.html" />
<meta name="DC.Relation" scheme="URI" content="GUID-72986B3C-047C-5411-8F15-BC9C65C3289C.html" />
<meta name="DC.Relation" scheme="URI" content="index.html" />
<meta name="DC.Relation" scheme="URI" content="GUID-32E29020-1956-461A-B79A-1492E06049E7.html" />
<meta name="DC.Relation" scheme="URI" content="GUID-1DCA2F4D-ABE6-52A0-AC4E-5AAC1AB5909D.html" />
<meta name="DC.Relation" scheme="URI" content="GUID-762A665F-43D0-53ED-B698-0CBD3AC46391.html" />
<meta name="DC.Relation" scheme="URI" content="GUID-98B85D7F-7BD9-5056-A99F-0BC99D921B87.html" />
<meta name="DC.Relation" scheme="URI" content="GUID-C1B080D9-9C6C-520B-B73E-4EB344B1FC5E.html" />
<meta name="DC.Relation" scheme="URI" content="GUID-90644B52-69D7-595C-95E3-D6F7A30C060D.html" />
<meta name="DC.Relation" scheme="URI" content="GUID-71DADA82-3ABC-52D2-8360-33FAEB2E5DE9.html" />
<meta name="DC.Relation" scheme="URI" content="GUID-416A3756-B5D5-5BCD-830E-2371C5F6B502.html" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="GUID-78FB26E2-AA60-5531-B2FE-4FA6C88F2D47" />
<meta name="DC.Language" content="en" />
<link rel="stylesheet" type="text/css" href="commonltr.css" />
<title>
Selecting and Using a Font
</title>
<link type="text/css" rel="stylesheet" href="css/common.css" media="screen"/>
<link type="text/css" rel="stylesheet" href="css/sdl.css" media="screen"/>
<!--[if IE]>
<link href="css/iefix.css" rel="stylesheet" type="text/css" media="screen" />
<![endif]-->
<link rel="stylesheet" type="text/css" href="nokiacxxref.css" />
</head>
<body id="GUID-78FB26E2-AA60-5531-B2FE-4FA6C88F2D47">
<a name="GUID-78FB26E2-AA60-5531-B2FE-4FA6C88F2D47">
<!-- -->
</a>
<?php include_once (CURRENT_SKIN_PATH.'/sdl_header.html'); ?>
<div id="sdl_container">
<div id="leftMenu">
<div id="expandcontractdiv">
<a id="collapseTree" href="javascript:tree.collapseAll()">
Collapse all
</a>
<a id="index" href="index.html">
Symbian^3 Application Developer Library
</a>
</div>
<iframe style="border:none" height="800" width="300" src="index-toc.html"></iframe>
<div id="treeDiv1">
 
</div>
<script type="text/javascript">
var currentIconMode = 0; window.name="id2470542 id2400118 id2400126 id2400140 ";
YAHOO.util.Event.onDOMReady(buildTree, this,true);
</script>
</div>
<div id="sdl_content">
<div class="breadcrumb">
<a href="index.html" title="Symbian^3 Application Developer Library">
Symbian^3 Application Developer Library
</a>
>
<a href="GUID-32E29020-1956-461A-B79A-1492E06049E7.html" title="The Symbian Guide describes the architecture and functionality of the platform, and provides guides on using its APIs.">
Symbian Guide
</a>
>
<a href="GUID-1DCA2F4D-ABE6-52A0-AC4E-5AAC1AB5909D.html">
Text and Localization Guide
</a>
>
<a href="GUID-762A665F-43D0-53ED-B698-0CBD3AC46391.html" title="The Font and Text Services Collection contains the Font Store and related plug-ins and the Text Rendering component. Application developers can select fonts from the Font Store. Device creators can create and add fonts.">
Font and Text Services Collection
</a>
>
<a href="GUID-98B85D7F-7BD9-5056-A99F-0BC99D921B87.html" title="You can use the Font and Text Services to select a font or typeface for your text.">
Font and Text Services Tutorials
</a>
>
</div>
<h1 class="topictitle1">
Selecting and Using a Font
</h1>
<div>
<p>
To select a font you must create a specification that defines the characteristics of the font that you require. The fonts available are specific to the current graphics device (normally the screen device). The graphics device uses the Font and Bitmap server to access the Font Store. The Font Store finds the best match from the fonts installed.
</p>
<p>
The current font is part of the current graphics context. Once the font system has selected a font to match your specification you must update the current context to use the new font.
</p>
<a name="GUID-78FB26E2-AA60-5531-B2FE-4FA6C88F2D47__GUID-C4671145-FEDE-5A82-8085-7E5802545DE9">
<!-- -->
</a>
<ol id="GUID-78FB26E2-AA60-5531-B2FE-4FA6C88F2D47__GUID-C4671145-FEDE-5A82-8085-7E5802545DE9">
<li id="GUID-78FB26E2-AA60-5531-B2FE-4FA6C88F2D47__GUID-66508D29-FC01-5B64-A043-759503EC04FF">
<a name="GUID-78FB26E2-AA60-5531-B2FE-4FA6C88F2D47__GUID-66508D29-FC01-5B64-A043-759503EC04FF">
<!-- -->
</a>
<p>
Set up a font specification (
<samp class="codeph">
TFontSpec
</samp>
).
</p>
</li>
<li id="GUID-78FB26E2-AA60-5531-B2FE-4FA6C88F2D47__GUID-E6F70C38-003C-5AFF-B73D-67244058FFCF">
<a name="GUID-78FB26E2-AA60-5531-B2FE-4FA6C88F2D47__GUID-E6F70C38-003C-5AFF-B73D-67244058FFCF">
<!-- -->
</a>
<p>
Create a
<samp class="codeph">
CFont
</samp>
pointer. The font itself will be allocated by FBServ on the shared heap. This pointer will not be used to allocate or free any memory.
</p>
</li>
<li id="GUID-78FB26E2-AA60-5531-B2FE-4FA6C88F2D47__GUID-93C743E0-2689-5AA3-8F24-937C38D7A7BB">
<a name="GUID-78FB26E2-AA60-5531-B2FE-4FA6C88F2D47__GUID-93C743E0-2689-5AA3-8F24-937C38D7A7BB">
<!-- -->
</a>
<p>
Use the font spec and the font pointer to obtain a font from the Font Store. This must be done through the screen device.
</p>
</li>
<li id="GUID-78FB26E2-AA60-5531-B2FE-4FA6C88F2D47__GUID-9DB15BD2-8014-59AC-94CA-30161E3DB553">
<a name="GUID-78FB26E2-AA60-5531-B2FE-4FA6C88F2D47__GUID-9DB15BD2-8014-59AC-94CA-30161E3DB553">
<!-- -->
</a>
<p>
Set the graphic context's current font to the
<samp class="codeph">
CFont
</samp>
obtained from the Font Store.
</p>
</li>
<li id="GUID-78FB26E2-AA60-5531-B2FE-4FA6C88F2D47__GUID-2F9586D4-5C1C-5ADC-A816-4AE7C29CA44A">
<a name="GUID-78FB26E2-AA60-5531-B2FE-4FA6C88F2D47__GUID-2F9586D4-5C1C-5ADC-A816-4AE7C29CA44A">
<!-- -->
</a>
<p>
Use the font.
</p>
</li>
<li id="GUID-78FB26E2-AA60-5531-B2FE-4FA6C88F2D47__GUID-DAB05CE0-1710-5B79-A921-41BFDEF8B1FD">
<a name="GUID-78FB26E2-AA60-5531-B2FE-4FA6C88F2D47__GUID-DAB05CE0-1710-5B79-A921-41BFDEF8B1FD">
<!-- -->
</a>
<p>
Tidy up by discarding the font from the graphics context and releasing it from the graphics device.
</p>
</li>
</ol>
<pre class="codeblock" id="GUID-78FB26E2-AA60-5531-B2FE-4FA6C88F2D47__GUID-D37CB9EF-CED1-59EB-95AE-D50E020D2FF8">
<a name="GUID-78FB26E2-AA60-5531-B2FE-4FA6C88F2D47__GUID-D37CB9EF-CED1-59EB-95AE-D50E020D2FF8">
<!-- -->
</a>
// Create a font specification
_LIT( KMyFontName,"Swiss") ;
const TInt KMyFontHeightInTwips = 240 ; // 12 point
TFontSpec myFontSpec( KMyFontName, KMyFontHeightInTwips ) ;
// Create a font pointer (the font itself is on the FBServ shared heap)
CFont* myFont ;
// Fonts are graphics device specific. In this case the graphics device is the screen
CGraphicsDevice* screenDevice = iCoeEnv->ScreenDevice() ;
// Get the font that most closely matches the font spec.
screenDevice->GetNearestFontToMaxHeightInTwips( myFont , myFontSpec ) ;
// Pass the font to the current graphics context
CWindowGc& gc = SystemGc() ;
gc.UseFont( myFont ) ;
// Use the gc to draw text. Use the most appropriate CGraphicsContext::DrawText() function.
TPoint textPos( 0, myFont->AscentInPixels() ) ; // left hand end of baseline.
_LIT( KMyText, "Some text to write" ) ;
gc.DrawText( KMyText, textPos ) ; // Uses current pen etc.
// Tidy up. Discard and release the font
gc.DiscardFont() ;
screenDevice->ReleaseFont( myFont ) ;
</pre>
<p>
There are a number of
<samp class="codeph">
DrawText()
</samp>
function in
<a href="GUID-DAD09DCF-3123-38B4-99E9-91FB24B92138.html">
<span class="apiname">
CGraphicsContext
</span>
</a>
that you can use for positioning text at a specified position or within a rectangle. The pen and brush are those in the current context.
</p>
<p>
You can query the metrics of the font using
<a href="GUID-2A12FE3B-47F2-3016-8161-A971CA506491.html">
<span class="apiname">
CFont
</span>
</a>
to ensure that your text is correctly located. You can also establish the size of individual characters and text strings.
</p>
<p>
<strong>
Note:
</strong>
<a href="GUID-2A12FE3B-47F2-3016-8161-A971CA506491.html">
<span class="apiname">
CFont
</span>
</a>
is an abstract base class. You can use it to query a font supplied by the font system but you cannot instantiate it.
</p>
<pre class="codeblock" id="GUID-78FB26E2-AA60-5531-B2FE-4FA6C88F2D47__GUID-996A661A-581B-50A4-B844-91DE4514F1EA">
<a name="GUID-78FB26E2-AA60-5531-B2FE-4FA6C88F2D47__GUID-996A661A-581B-50A4-B844-91DE4514F1EA">
<!-- -->
</a>
class CFont // CFont is an abstract class.
{
public:
TUid TypeUid() const;
TInt HeightInPixels() const;
TInt AscentInPixels() const;
TInt DescentInPixels() const;
TInt CharWidthInPixels(TChar aChar) const;
TInt TextWidthInPixels(const TDesC& aText) const;
TInt BaselineOffsetInPixels() const;
TInt TextCount(const TDesC& aText,TInt aWidthInPixels) const;
TInt TextCount(const TDesC& aText,TInt aWidthInPixels,
TInt& aExcessWidthInPixels) const;
TInt MaxCharWidthInPixels() const;
TInt MaxNormalCharWidthInPixels() const;
TFontSpec FontSpecInTwips() const;
TCharacterDataAvailability GetCharacterData(TUint aCode,
TOpenFontCharMetrics& aMetrics,
const TUint8*& aBitmap,
TSize& aBitmapSize) const;
TBool GetCharacterPosition(TPositionParam& aParam) const;
TInt WidthZeroInPixels() const;
TInt MeasureText(const TDesC& aText,
const TMeasureTextInput* aInput = NULL,
TMeasureTextOutput* aOutput = NULL) const;
static TBool CharactersJoin(TInt aLeftCharacter, TInt aRightCharacter);
TInt ExtendedFunction(TUid aFunctionId, TAny* aParam = NULL) const;
TBool GetCharacterPosition2(TPositionParam& aParam, RShapeInfo& aShapeInfo) const;
TInt TextWidthInPixels(const TDesC& aText,const TMeasureTextInput* aParam) const;
....
</pre>
</div>
<div>
<ul class="ullinks">
<li class="ulchildlink">
<strong>
<a href="GUID-72986B3C-047C-5411-8F15-BC9C65C3289C.html">
Using Typefaces
</a>
</strong>
<br />
</li>
</ul>
<div class="familylinks">
<div class="parentlink">
<strong>
Parent topic:
</strong>
<a href="GUID-98B85D7F-7BD9-5056-A99F-0BC99D921B87.html" title="You can use the Font and Text Services to select a font or typeface for your text.">
Font and Text Services Tutorials
</a>
</div>
</div>
<div class="relinfo relconcepts">
<strong>
Related concepts
</strong>
<br />
<div>
<a href="GUID-C1B080D9-9C6C-520B-B73E-4EB344B1FC5E.html" title="The Graphics Device Interface (GDI) collection is an important collection within the Graphics subsystem. It provides a suite of abstract base classes, interfaces and data structures. The suite represents and interacts with physical graphics hardware such as display screens, off-screen memory and printers.">
GDI Collection Overview
</a>
</div>
<div>
<a href="GUID-90644B52-69D7-595C-95E3-D6F7A30C060D.html" title="A font is a set of characters of matching size (height) and appearance. In order to be displayed each character must ultimately be drawn as a series of pixels (a bitmap). Symbian can store fonts in bitmap or vector form. A vector font (for example, an OpenType font) must be converted to bitmaps (or rasterized) before it can be drawn. Symbian caches and shares bitmaps for performance and memory efficiency.">
Font and Text Services Collection
Overview
</a>
</div>
<div>
<a href="GUID-71DADA82-3ABC-52D2-8360-33FAEB2E5DE9.html" title="The Font and Bitmap Server (FBServ) provides a memory efficient way of using bitmaps and fonts. It stores a single instance of each bitmap in either a shared heap or in eXecute In Place (XIP) ROM and provides clients with read and (when appropriate) write access.">
Font and Bitmap Server Component Overview
</a>
</div>
<div>
<a href="GUID-416A3756-B5D5-5BCD-830E-2371C5F6B502.html" title="The Font Store contains all of the fonts and typefaces on a phone. It is encapsulated by the Font and Bitmap server which provides a client-side class that applications use to find which fonts are available and to find fonts to match their requirements.">
Font Store Component Overview
</a>
</div>
</div>
</div>
<p class="copyright">Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).<br /> All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the <a href=" http://www.eclipse.org/legal/epl-v10.html"> Eclipse Public License
v1.0</a>.</p>
</div>
</div>
<?php include_once (CURRENT_SKIN_PATH.'/sdl_footer.html'); ?>
</body>
</html> | warlordh/fork_Symbian | sdk/GUID-78FB26E2-AA60-5531-B2FE-4FA6C88F2D47.html | HTML | epl-1.0 | 14,484 |
requirejs(['bmotion.config'], function() {
requirejs(['bms.integrated.root'], function() {});
});
| ladenberger/bmotion-frontend | app/js/bmotion.integrated.js | JavaScript | epl-1.0 | 100 |
/*
* Copyright (c) 2013 Red Hat, Inc. and/or its affiliates.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Brad Davis - [email protected] - Initial API and implementation
*/
package org.jboss.windup.interrogator.impl;
import java.io.File;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.windup.metadata.decoration.Summary;
import org.jboss.windup.metadata.decoration.AbstractDecoration.NotificationLevel;
import org.jboss.windup.metadata.type.FileMetadata;
import org.jboss.windup.metadata.type.XmlMetadata;
import org.jboss.windup.metadata.type.ZipEntryMetadata;
import org.w3c.dom.Document;
/**
* Interrogates XML files. Extracts the XML, and creates an XmlMetadata object, which is passed down
* the decorator pipeline.
*
* @author bdavis
*
*/
public class XmlInterrogator extends ExtensionInterrogator<XmlMetadata> {
private static final Log LOG = LogFactory.getLog(XmlInterrogator.class);
@Override
public void processMeta(XmlMetadata fileMeta) {
Document document = fileMeta.getParsedDocument();
if (document == null) {
if (LOG.isDebugEnabled()) {
LOG.debug("Document was null. Problem parsing: " + fileMeta.getFilePointer().getAbsolutePath());
}
// attach the bad file so we see it in the reports...
fileMeta.getArchiveMeta().getEntries().add(fileMeta);
return;
}
super.processMeta(fileMeta);
}
@Override
public boolean isOfInterest(XmlMetadata fileMeta) {
return true;
}
@Override
public XmlMetadata archiveEntryToMeta(ZipEntryMetadata archiveEntry) {
File file = archiveEntry.getFilePointer();
LOG.debug("Processing XML: " + file.getAbsolutePath());
FileMetadata meta = null;
if (file.length() > 1048576L * 1) {
LOG.warn("XML larger than 1 MB: " + file.getAbsolutePath() + "; Skipping processing.");
meta = new FileMetadata();
meta.setArchiveMeta(archiveEntry.getArchiveMeta());
meta.setFilePointer(file);
Summary sr = new Summary();
sr.setDescription("File is too large; skipped.");
sr.setLevel(NotificationLevel.WARNING);
meta.getDecorations().add(sr);
}
else {
XmlMetadata xmlMeta = new XmlMetadata();
xmlMeta.setArchiveMeta(archiveEntry.getArchiveMeta());
xmlMeta.setFilePointer(file);
meta = xmlMeta;
return xmlMeta;
}
return null;
}
@Override
public XmlMetadata fileEntryToMeta(FileMetadata entry) {
File file = entry.getFilePointer();
LOG.debug("Processing XML: " + file.getAbsolutePath());
FileMetadata meta = null;
if (file.length() > 1048576L * 1) {
LOG.warn("XML larger than 1 MB: " + file.getAbsolutePath() + "; Skipping processing.");
meta = new FileMetadata();
//meta.setArchiveMeta(archiveEntry.getArchiveMeta());
meta.setFilePointer(file);
meta.setArchiveMeta(entry.getArchiveMeta());
Summary sr = new Summary();
sr.setDescription("File is too large; skipped.");
sr.setLevel(NotificationLevel.WARNING);
meta.getDecorations().add(sr);
}
else {
XmlMetadata xmlMeta = new XmlMetadata();
xmlMeta.setArchiveMeta(entry.getArchiveMeta());
xmlMeta.setFilePointer(file);
meta = xmlMeta;
return xmlMeta;
}
return null;
}
}
| Maarc/windup-as-a-service | windup_0_7/windup-engine/src/main/java/org/jboss/windup/interrogator/impl/XmlInterrogator.java | Java | epl-1.0 | 3,422 |
package de.uks.beast.editor.util;
public enum Fonts
{
//@formatter:off
HADOOP_MASTER_TITEL ("Arial", 10, true, true),
HADOOP_SLAVE_TITEL ("Arial", 10, true, true),
NETWORK_TITEL ("Arial", 10, true, true),
CONTROL_CENTER_TITEL ("Arial", 10, true, true),
HADOOP_MASTER_PROPERTY ("Arial", 8, false, true),
HADOOP_SLAVE_PROPERTY ("Arial", 8, false, true),
NETWORK_PROPERTY ("Arial", 8, false, true),
CONTROL_CENTER_PROPERTY ("Arial", 8, false, true),
;//@formatter:on
private final String name;
private final int size;
private final boolean italic;
private final boolean bold;
private Fonts(final String name, final int size, final boolean italic, final boolean bold)
{
this.name = name;
this.size = size;
this.italic = italic;
this.bold = bold;
}
/**
* @return the name
*/
public String getName()
{
return name;
}
/**
* @return the size
*/
public int getSize()
{
return size;
}
/**
* @return the italic
*/
public boolean isItalic()
{
return italic;
}
/**
* @return the bold
*/
public boolean isBold()
{
return bold;
}
}
| fujaba/BeAST | de.uks.beast.editor/src/de/uks/beast/editor/util/Fonts.java | Java | epl-1.0 | 1,163 |
var page = require('webpage').create();
var url;
if (phantom.args) {
url = phantom.args[0];
} else {
url = require('system').args[1];
}
page.onConsoleMessage = function (message) {
console.log(message);
};
function exit(code) {
setTimeout(function(){ phantom.exit(code); }, 0);
phantom.onError = function(){};
}
console.log("Loading URL: " + url);
page.open(url, function (status) {
if (status != "success") {
console.log('Failed to open ' + url);
phantom.exit(1);
}
console.log("Running test.");
var result = page.evaluate(function() {
return chess_game.test_runner.runner();
});
if (result != 0) {
console.log("*** Test failed! ***");
exit(1);
}
else {
console.log("Test succeeded.");
exit(0);
}
});
| tmtwd/chess-om | env/test/js/unit-test.js | JavaScript | epl-1.0 | 765 |
#include "genfft.h"
/**
* NAME: cc1fft
*
* DESCRIPTION: complex to complex FFT
*
* USAGE:
* void cc1fft(complex *data, int n, int sign)
*
* INPUT: - *data: complex 1D input vector
* - n: number of samples in input vector data
* - sign: sign of the Fourier kernel
*
* OUTPUT: - *data: complex 1D output vector unscaled
*
* NOTES: Optimized system dependent FFT's implemented for:
* - inplace FFT from Mayer and SU (see file fft_mayer.c)
*
* AUTHOR:
* Jan Thorbecke ([email protected])
* The Netherlands
*
*
*----------------------------------------------------------------------
* REVISION HISTORY:
* VERSION AUTHOR DATE COMMENT
* 1.0 Jan Thorbecke Feb '94 Initial version (TU Delft)
* 1.1 Jan Thorbecke June '94 faster in-place FFT
* 2.0 Jan Thorbecke July '97 added Cray SGI calls
* 2.1 Alexander Koek June '98 updated SCS for use inside
* parallel loops
*
*
----------------------------------------------------------------------*/
#if defined(ACML440)
#if defined(DOUBLE)
#define acmlcc1fft zfft1dx
#else
#define acmlcc1fft cfft1dx
#endif
#endif
void cc1fft(complex *data, int n, int sign)
{
#if defined(HAVE_LIBSCS)
int ntable, nwork, zero=0;
static int isys, nprev[MAX_NUMTHREADS];
static float *work[MAX_NUMTHREADS], *table[MAX_NUMTHREADS], scale=1.0;
int pe, i;
#elif defined(ACML440)
static int nprev=0;
int nwork, zero=0, one=1, inpl=1, i;
static int isys;
static complex *work;
REAL scl;
complex *y;
#endif
#if defined(HAVE_LIBSCS)
pe = mp_my_threadnum();
assert ( pe <= MAX_NUMTHREADS );
if (n != nprev[pe]) {
isys = 0;
ntable = 2*n + 30;
nwork = 2*n;
/* allocate memory on each processor locally for speed */
if (work[pe]) free(work[pe]);
work[pe] = (float *)malloc(nwork*sizeof(float));
if (work[pe] == NULL)
fprintf(stderr,"cc1fft: memory allocation error\n");
if (table[pe]) free(table[pe]);
table[pe] = (float *)malloc(ntable*sizeof(float));
if (table[pe] == NULL)
fprintf(stderr,"cc1fft: memory allocation error\n");
ccfft_(&zero, &n, &scale, data, data, table[pe], work[pe], &isys);
nprev[pe] = n;
}
ccfft_(&sign, &n, &scale, data, data, table[pe], work[pe], &isys);
#elif defined(ACML440)
scl = 1.0;
if (n != nprev) {
isys = 0;
nwork = 5*n + 100;
if (work) free(work);
work = (complex *)malloc(nwork*sizeof(complex));
if (work == NULL) fprintf(stderr,"rc1fft: memory allocation error\n");
acmlcc1fft(zero, scl, inpl, n, data, 1, y, 1, work, &isys);
nprev = n;
}
acmlcc1fft(sign, scl, inpl, n, data, 1, y, 1, work, &isys);
#else
cc1_fft(data, n, sign);
#endif
return;
}
/****************** NO COMPLEX DEFINED ******************/
void Rcc1fft(float *data, int n, int sign)
{
cc1fft((complex *)data, n , sign);
return;
}
/****************** FORTRAN SHELL *****************/
void cc1fft_(complex *data, int *n, int *sign)
{
cc1fft(data, *n, *sign);
return;
}
| sun031/Jan | FFTlib/cc1fft.c | C | epl-1.0 | 3,110 |
#include "SimpleGameLogic.h"
#include "GameWorld.h"
#include "MonstersPlace.h"
void SimpleGameLogic::worldLoaded()
{
_physicsWorld = _world->getGameContent()->getPhysicsWorld();
_physicsWorld->setCollisionCallback(this);
_tank = static_cast<Tank*>(_world->getGameContent()->getObjectByName("Player"));
ControllerManager::getInstance()->registerListener(this);
std::vector<MonstersPlace*> monstersPlaces = _world->getGameContent()->getObjectsByTypeName<MonstersPlace>(GameObjectType::MONSTERS_PLACE);
for (auto monstersPlace : monstersPlaces)
{
MonstersPlaceHandler *handler = new MonstersPlaceHandler(_world, monstersPlace, _tank);
_handlers.push_back(handler);
}
}
void SimpleGameLogic::update(float delta)
{
_physicsWorld->update(delta);
for (auto handler : _handlers)
{
handler->update(delta);
}
}
void SimpleGameLogic::onKeyDown(EventKeyboard::KeyCode keyCode)
{
if (keyCode == EventKeyboard::KeyCode::KEY_LEFT_ARROW)
{
_tank->moveLeft();
}
else if (keyCode == EventKeyboard::KeyCode::KEY_RIGHT_ARROW)
{
_tank->moveRight();
}
else if (keyCode == EventKeyboard::KeyCode::KEY_UP_ARROW)
{
_tank->moveForward();
}
else if (keyCode == EventKeyboard::KeyCode::KEY_DOWN_ARROW)
{
_tank->moveBackward();
}
else if (keyCode == EventKeyboard::KeyCode::KEY_X)
{
_tank->fire();
}
}
void SimpleGameLogic::onKeyPress(EventKeyboard::KeyCode keyCode)
{
if (keyCode == EventKeyboard::KeyCode::KEY_Q)
{
_tank->prevWeapon();
} else if (keyCode == EventKeyboard::KeyCode::KEY_W)
{
_tank->nextWeapon();
}
}
void SimpleGameLogic::onKeyUp(EventKeyboard::KeyCode keyCode)
{
if (keyCode == EventKeyboard::KeyCode::KEY_LEFT_ARROW)
{
_tank->stopMoveLeft();
}
else if (keyCode == EventKeyboard::KeyCode::KEY_RIGHT_ARROW)
{
_tank->stopMoveRight();
}
else if (keyCode == EventKeyboard::KeyCode::KEY_UP_ARROW)
{
_tank->stopMoveBackward();
}
else if (keyCode == EventKeyboard::KeyCode::KEY_DOWN_ARROW)
{
_tank->stopMoveBackward();
}
}
void SimpleGameLogic::onPointsBeginContact(SimplePhysicsPoint* pointA, SimplePhysicsPoint* pointB)
{
BaseGameObject *gameObjectA = static_cast<BaseGameObject*>(pointA->getUserData());
BaseGameObject *gameObjectB = static_cast<BaseGameObject*>(pointB->getUserData());
//ToDo êàê-òî íàäî îáîéòè ýòó ïðîâåðêó
if (gameObjectA->getType() == GameObjectType::TANK && gameObjectB->getType() == GameObjectType::TANK_BULLET
|| gameObjectB->getType() == GameObjectType::TANK && gameObjectA->getType() == GameObjectType::TANK_BULLET)
{
return;
}
if (isMonster(gameObjectA) && isMonster(gameObjectB))
{
return;
}
DamageableObject *damageableObjectA = dynamic_cast<DamageableObject*>(gameObjectA);
DamageObject *damageObjectB = dynamic_cast<DamageObject*>(gameObjectB);
if (damageableObjectA && damageObjectB)
{
DamageInfo *damageInfo = damageObjectB->getDamageInfo();
damageableObjectA->damage(damageInfo);
damageObjectB->onAfterDamage(damageableObjectA);
delete damageInfo;
}
DamageableObject *damageableObjectB = dynamic_cast<DamageableObject*>(gameObjectB);
DamageObject *damageObjectA = dynamic_cast<DamageObject*>(gameObjectA);
if (damageableObjectB && damageObjectA)
{
DamageInfo *damageInfo = damageObjectA->getDamageInfo();
damageableObjectB->damage(damageInfo);
damageObjectA->onAfterDamage(damageableObjectB);
delete damageInfo;
}
}
void SimpleGameLogic::onPointReachedBorder(SimplePhysicsPoint* point)
{
BaseGameObject *gameObject = static_cast<BaseGameObject*>(point->getUserData());
if (gameObject)
{
if (gameObject->getType() == GameObjectType::TANK_BULLET)
{
scheduleOnce([=](float dt){
gameObject->detachFromWorld();
delete gameObject;
}, 0.0f, "DestroyGameObject");
}
}
}
bool SimpleGameLogic::isMonster(BaseGameObject *gameObject)
{
return gameObject->getType() == GameObjectType::MONSTER1
|| gameObject->getType() == GameObjectType::MONSTER2
|| gameObject->getType() == GameObjectType::MONSTER3;
}
| cjsbox-xx/tanchiks | Classes/SimpleGameLogic.cpp | C++ | epl-1.0 | 3,968 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (version 1.7.0_55) on Thu Jun 12 19:19:11 EDT 2014 -->
<title>Uses of Class com.runescape.revised.content.skill.combat.prayer.standard.UnstoppableForce</title>
<meta name="date" content="2014-06-12">
<link rel="stylesheet" type="text/css" href="../../../../../../../../../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Uses of Class com.runescape.revised.content.skill.combat.prayer.standard.UnstoppableForce";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!-- -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../../../../../overview-summary.html">Overview</a></li>
<li><a href="../package-summary.html">Package</a></li>
<li><a href="../../../../../../../../../com/runescape/revised/content/skill/combat/prayer/standard/UnstoppableForce.html" title="class in com.runescape.revised.content.skill.combat.prayer.standard">Class</a></li>
<li class="navBarCell1Rev">Use</li>
<li><a href="../package-tree.html">Tree</a></li>
<li><a href="../../../../../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../../../../../index-files/index-1.html">Index</a></li>
<li><a href="../../../../../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="../../../../../../../../../index.html?com/runescape/revised/content/skill/combat/prayer/standard/class-use/UnstoppableForce.html" target="_top">Frames</a></li>
<li><a href="UnstoppableForce.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip-navbar_top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="header">
<h2 title="Uses of Class com.runescape.revised.content.skill.combat.prayer.standard.UnstoppableForce" class="title">Uses of Class<br>com.runescape.revised.content.skill.combat.prayer.standard.UnstoppableForce</h2>
</div>
<div class="classUseContainer">No usage of com.runescape.revised.content.skill.combat.prayer.standard.UnstoppableForce</div>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!-- -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../../../../../overview-summary.html">Overview</a></li>
<li><a href="../package-summary.html">Package</a></li>
<li><a href="../../../../../../../../../com/runescape/revised/content/skill/combat/prayer/standard/UnstoppableForce.html" title="class in com.runescape.revised.content.skill.combat.prayer.standard">Class</a></li>
<li class="navBarCell1Rev">Use</li>
<li><a href="../package-tree.html">Tree</a></li>
<li><a href="../../../../../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../../../../../index-files/index-1.html">Index</a></li>
<li><a href="../../../../../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="../../../../../../../../../index.html?com/runescape/revised/content/skill/combat/prayer/standard/class-use/UnstoppableForce.html" target="_top">Frames</a></li>
<li><a href="UnstoppableForce.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip-navbar_bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>
| RodriguesJ/Atem | doc/com/runescape/revised/content/skill/combat/prayer/standard/class-use/UnstoppableForce.html | HTML | epl-1.0 | 4,750 |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.solr.client.solrj.request;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.response.SolrPingResponse;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.ModifiableSolrParams;
/**
* Verify that there is a working Solr core at the URL of a {@link org.apache.solr.client.solrj.SolrClient}.
* To use this class, the solrconfig.xml for the relevant core must include the
* request handler for <code>/admin/ping</code>.
*
* @since solr 1.3
*/
public class SolrPing extends SolrRequest<SolrPingResponse> {
/** serialVersionUID. */
private static final long serialVersionUID = 5828246236669090017L;
/** Request parameters. */
private ModifiableSolrParams params;
/**
* Create a new SolrPing object.
*/
public SolrPing() {
super(METHOD.GET, CommonParams.PING_HANDLER);
params = new ModifiableSolrParams();
}
@Override
protected SolrPingResponse createResponse(SolrClient client) {
return new SolrPingResponse();
}
@Override
public ModifiableSolrParams getParams() {
return params;
}
/**
* Remove the action parameter from this request. This will result in the same
* behavior as {@code SolrPing#setActionPing()}. For Solr server version 4.0
* and later.
*
* @return this
*/
public SolrPing removeAction() {
params.remove(CommonParams.ACTION);
return this;
}
/**
* Set the action parameter on this request to enable. This will delete the
* health-check file for the Solr core. For Solr server version 4.0 and later.
*
* @return this
*/
public SolrPing setActionDisable() {
params.set(CommonParams.ACTION, CommonParams.DISABLE);
return this;
}
/**
* Set the action parameter on this request to enable. This will create the
* health-check file for the Solr core. For Solr server version 4.0 and later.
*
* @return this
*/
public SolrPing setActionEnable() {
params.set(CommonParams.ACTION, CommonParams.ENABLE);
return this;
}
/**
* Set the action parameter on this request to ping. This is the same as not
* including the action at all. For Solr server version 4.0 and later.
*
* @return this
*/
public SolrPing setActionPing() {
params.set(CommonParams.ACTION, CommonParams.PING);
return this;
}
}
| DavidGutknecht/elexis-3-base | bundles/org.apache.solr/src/org/apache/solr/client/solrj/request/SolrPing.java | Java | epl-1.0 | 3,236 |
//
// Diese Datei wurde mit der JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802 generiert
// Siehe <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Änderungen an dieser Datei gehen bei einer Neukompilierung des Quellschemas verloren.
// Generiert: 2020.05.20 um 02:10:33 PM CEST
//
package ch.fd.invoice450.request;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
/**
* <p>Java-Klasse für xtraDrugType complex type.
*
* <p>Das folgende Schemafragment gibt den erwarteten Content an, der in dieser Klasse enthalten ist.
*
* <pre>
* <complexType name="xtraDrugType">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <attribute name="indicated" type="{http://www.w3.org/2001/XMLSchema}boolean" />
* <attribute name="iocm_category">
* <simpleType>
* <restriction base="{http://www.w3.org/2001/XMLSchema}NMTOKEN">
* <enumeration value="A"/>
* <enumeration value="B"/>
* <enumeration value="C"/>
* <enumeration value="D"/>
* <enumeration value="E"/>
* </restriction>
* </simpleType>
* </attribute>
* <attribute name="delivery" default="first">
* <simpleType>
* <restriction base="{http://www.w3.org/2001/XMLSchema}NMTOKEN">
* <enumeration value="first"/>
* <enumeration value="repeated"/>
* <enumeration value="permanent"/>
* </restriction>
* </simpleType>
* </attribute>
* <attribute name="regulation_attributes" type="{http://www.w3.org/2001/XMLSchema}unsignedInt" default="0" />
* <attribute name="limitation" type="{http://www.w3.org/2001/XMLSchema}boolean" />
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "xtraDrugType")
public class XtraDrugType {
@XmlAttribute(name = "indicated")
protected Boolean indicated;
@XmlAttribute(name = "iocm_category")
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
protected String iocmCategory;
@XmlAttribute(name = "delivery")
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
protected String delivery;
@XmlAttribute(name = "regulation_attributes")
@XmlSchemaType(name = "unsignedInt")
protected Long regulationAttributes;
@XmlAttribute(name = "limitation")
protected Boolean limitation;
/**
* Ruft den Wert der indicated-Eigenschaft ab.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public Boolean isIndicated() {
return indicated;
}
/**
* Legt den Wert der indicated-Eigenschaft fest.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setIndicated(Boolean value) {
this.indicated = value;
}
/**
* Ruft den Wert der iocmCategory-Eigenschaft ab.
*
* @return
* possible object is
* {@link String }
*
*/
public String getIocmCategory() {
return iocmCategory;
}
/**
* Legt den Wert der iocmCategory-Eigenschaft fest.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setIocmCategory(String value) {
this.iocmCategory = value;
}
/**
* Ruft den Wert der delivery-Eigenschaft ab.
*
* @return
* possible object is
* {@link String }
*
*/
public String getDelivery() {
if (delivery == null) {
return "first";
} else {
return delivery;
}
}
/**
* Legt den Wert der delivery-Eigenschaft fest.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setDelivery(String value) {
this.delivery = value;
}
/**
* Ruft den Wert der regulationAttributes-Eigenschaft ab.
*
* @return
* possible object is
* {@link Long }
*
*/
public long getRegulationAttributes() {
if (regulationAttributes == null) {
return 0L;
} else {
return regulationAttributes;
}
}
/**
* Legt den Wert der regulationAttributes-Eigenschaft fest.
*
* @param value
* allowed object is
* {@link Long }
*
*/
public void setRegulationAttributes(Long value) {
this.regulationAttributes = value;
}
/**
* Ruft den Wert der limitation-Eigenschaft ab.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public Boolean isLimitation() {
return limitation;
}
/**
* Legt den Wert der limitation-Eigenschaft fest.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setLimitation(Boolean value) {
this.limitation = value;
}
}
| DavidGutknecht/elexis-3-base | bundles/at.medevit.elexis.tarmed.model/src-gen/ch/fd/invoice450/request/XtraDrugType.java | Java | epl-1.0 | 5,592 |
/*******************************************************************************
* Copyright (c) 2001, 2005 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
* Jens Lukowski/Innoopract - initial renaming/restructuring
*
*******************************************************************************/
package org.eclipse.wst.xml.core.internal.contenttype;
import org.eclipse.wst.sse.core.internal.encoding.EncodingMemento;
import org.eclipse.wst.sse.core.internal.encoding.NonContentBasedEncodingRules;
/**
* This class can be used in place of an EncodingMemento (its super class),
* when there is not in fact ANY encoding information. For example, when a
* structuredDocument is created directly from a String
*/
public class NullMemento extends EncodingMemento {
/**
*
*/
public NullMemento() {
super();
String defaultCharset = NonContentBasedEncodingRules.useDefaultNameRules(null);
setJavaCharsetName(defaultCharset);
setAppropriateDefault(defaultCharset);
setDetectedCharsetName(null);
}
}
| ttimbul/eclipse.wst | bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/NullMemento.java | Java | epl-1.0 | 1,336 |
/*******************************************************************************
* Copyright (c) 2013-2015 UAH Space Research Group.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MICOBS SRG Team - Initial API and implementation
******************************************************************************/
package es.uah.aut.srg.micobs.mclev.library.mclevlibrary;
/**
* A representation of an MCLEV Library versioned item corresponding to the
* model of a regular component.
*
* <p>
* The following features are supported:
* <ul>
* <li>{@link es.uah.aut.srg.micobs.mclev.library.mclevlibrary.MMCLEVVersionedItemComponent#getSwPackageURI <em>Sw Package URI</em>}</li>
* <li>{@link es.uah.aut.srg.micobs.mclev.library.mclevlibrary.MMCLEVVersionedItemComponent#getSwPackageVersion <em>Sw Package Version</em>}</li>
* </ul>
* </p>
*
* @see es.uah.aut.srg.micobs.mclev.library.mclevlibrary.mclevlibraryPackage#getMMCLEVVersionedItemComponent()
* @model
* @generated
*/
public interface MMCLEVVersionedItemComponent extends MMCLEVPackageVersionedItem {
/**
* Returns the URI of the MESP software package that stores the
* implementation of the component or <code>null</code> if no software
* package is defined for the component.
* @return the URI of the attached MESP software package or
* <code>null</code> if no software package is defined for the component.
* @see #setSwPackageURI(String)
* @see es.uah.aut.srg.micobs.mclev.library.mclevlibrary.mclevlibraryPackage#getMMCLEVVersionedItemComponent_SwPackageURI()
* @model
* @generated
*/
String getSwPackageURI();
/**
* Sets the URI of the MESP software package that stores the
* implementation of the component.
* @param value the new URI of the attached MESP software package.
* @see #getSwPackageURI()
* @generated
*/
void setSwPackageURI(String value);
/**
* Returns the version of the MESP software package that stores the
* implementation of the component or <code>null</code> if no software
* package is defined for the component.
* @return the version of the attached MESP software package or
* <code>null</code> if no software package is defined for the component.
* @see #setSwPackageVersion(String)
* @see es.uah.aut.srg.micobs.mclev.library.mclevlibrary.mclevlibraryPackage#getMMCLEVVersionedItemComponent_SwPackageVersion()
* @model
* @generated
*/
String getSwPackageVersion();
/**
* Sets the version of the MESP software package that stores the
* implementation of the component.
* @param value the new version of the attached MESP software package.
* @see #getSwPackageVersion()
* @generated
*/
void setSwPackageVersion(String value);
/**
* Returns the value of the '<em><b>Sw Interface URI</b></em>' attribute.
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Sw Interface URI</em>' attribute isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
* @return the value of the '<em>Sw Interface URI</em>' attribute.
* @see #setSwInterfaceURI(String)
* @see es.uah.aut.srg.micobs.mclev.library.mclevlibrary.mclevlibraryPackage#getMMCLEVVersionedItemComponent_SwInterfaceURI()
* @model
* @generated
*/
String getSwInterfaceURI();
/**
* Sets the value of the '{@link es.uah.aut.srg.micobs.mclev.library.mclevlibrary.MMCLEVVersionedItemComponent#getSwInterfaceURI <em>Sw Interface URI</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Sw Interface URI</em>' attribute.
* @see #getSwInterfaceURI()
* @generated
*/
void setSwInterfaceURI(String value);
/**
* Returns the value of the '<em><b>Sw Interface Version</b></em>' attribute.
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Sw Interface Version</em>' attribute isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
* @return the value of the '<em>Sw Interface Version</em>' attribute.
* @see #setSwInterfaceVersion(String)
* @see es.uah.aut.srg.micobs.mclev.library.mclevlibrary.mclevlibraryPackage#getMMCLEVVersionedItemComponent_SwInterfaceVersion()
* @model
* @generated
*/
String getSwInterfaceVersion();
/**
* Sets the value of the '{@link es.uah.aut.srg.micobs.mclev.library.mclevlibrary.MMCLEVVersionedItemComponent#getSwInterfaceVersion <em>Sw Interface Version</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Sw Interface Version</em>' attribute.
* @see #getSwInterfaceVersion()
* @generated
*/
void setSwInterfaceVersion(String value);
} | parraman/micobs | mclev/es.uah.aut.srg.micobs.mclev/src/es/uah/aut/srg/micobs/mclev/library/mclevlibrary/MMCLEVVersionedItemComponent.java | Java | epl-1.0 | 4,916 |
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="copyright" content="(C) Copyright 2010" />
<meta name="DC.rights.owner" content="(C) Copyright 2010" />
<meta name="DC.Type" content="concept" />
<meta name="DC.Title" content="Commonly used controls" />
<meta name="DC.Relation" scheme="URI" content="Chunk654565996.html#GUID-5944FFF1-79C6-4F5E-95C8-F4833AFC64AB" />
<meta name="DC.Relation" scheme="URI" content="index.html" />
<meta name="DC.Relation" scheme="URI" content="GUID-32E29020-1956-461A-B79A-1492E06049E7.html" />
<meta name="DC.Relation" scheme="URI" content="GUID-94005A46-B4C6-4A30-A8E8-1B9C2D583D50.html" />
<meta name="DC.Relation" scheme="URI" content="GUID-29486886-CB54-4A83-AD6D-70F971A86DFC.html" />
<meta name="DC.Relation" scheme="URI" content="Chunk1219618379.html#GUID-0F593BE1-1220-4403-B04E-B8E8A9A49701" />
<meta name="DC.Relation" scheme="URI" content="Chunk654565996.html#GUID-5944FFF1-79C6-4F5E-95C8-F4833AFC64AB" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="GUID-F3262DF6-39CA-4E96-AD0E-C1FFDE9B0A61" />
<meta name="DC.Language" content="en" />
<link rel="stylesheet" type="text/css" href="commonltr.css" />
<title>
Commonly used controls
</title>
<link type="text/css" rel="stylesheet" href="css/common.css" media="screen"/>
<link type="text/css" rel="stylesheet" href="css/sdl.css" media="screen"/>
<!--[if IE]>
<link href="css/iefix.css" rel="stylesheet" type="text/css" media="screen" />
<![endif]-->
<link rel="stylesheet" type="text/css" href="nokiacxxref.css" />
</head>
<body id="GUID-F3262DF6-39CA-4E96-AD0E-C1FFDE9B0A61">
<a name="GUID-F3262DF6-39CA-4E96-AD0E-C1FFDE9B0A61">
<!-- -->
</a>
<?php include_once (CURRENT_SKIN_PATH.'/sdl_header.html'); ?>
<div id="sdl_container">
<div id="leftMenu">
<div id="expandcontractdiv">
<a id="collapseTree" href="javascript:tree.collapseAll()">
Collapse all
</a>
<a id="index" href="index.html">
Symbian^3 Application Developer Library
</a>
</div>
<iframe style="border:none" height="800" width="300" src="index-toc.html"></iframe>
<div id="treeDiv1">
 
</div>
<script type="text/javascript">
var currentIconMode = 0; window.name="id2470542 id2469732 id2469667 id2469361 id2469325 ";
YAHOO.util.Event.onDOMReady(buildTree, this,true);
</script>
</div>
<div id="sdl_content">
<div class="breadcrumb">
<a href="index.html" title="Symbian^3 Application Developer Library">
Symbian^3 Application Developer Library
</a>
>
<a href="GUID-32E29020-1956-461A-B79A-1492E06049E7.html" title="The Symbian Guide describes the architecture and functionality of the platform, and provides guides on using its APIs.">
Symbian Guide
</a>
>
<a href="GUID-94005A46-B4C6-4A30-A8E8-1B9C2D583D50.html">
Classic UI Guide
</a>
>
<a href="GUID-29486886-CB54-4A83-AD6D-70F971A86DFC.html">
Application and UI frameworks
</a>
>
<a href="Chunk1219618379.html#GUID-0F593BE1-1220-4403-B04E-B8E8A9A49701">
UI concepts
</a>
>
<a href="Chunk654565996.html#GUID-5944FFF1-79C6-4F5E-95C8-F4833AFC64AB">
Controls
</a>
>
</div>
<h1 class="topictitle1">
Commonly
used controls
</h1>
<div>
<p>
The Symbian platform provides AVKON controls, which are a convenient
set of UI components designed specifically for devices based on the Symbian
platform.
</p>
<p>
Commonly used AVKON controls include:
</p>
<ul>
<li>
<p>
<a href="specs/guides/Dialogs_API_Specification/Dialogs_API_Specification.html" target="_blank">
dialogs
</a>
</p>
</li>
<li>
<p>
<a href="specs/guides/Editors_API_Specification/Editors_API_Specification.html" target="_blank">
editors
</a>
</p>
</li>
<li>
<p>
<a href="specs/guides/Form_API_Specification/Form_API_Specification.html" target="_blank">
forms
</a>
</p>
</li>
<li>
<p>
<a href="specs/guides/Grids_API_Specification/Grids_API_Specification.html" target="_blank">
grids
</a>
</p>
</li>
<li>
<p>
<a href="specs/guides/Lists_API_Specification/Lists_API_Specification.html" target="_blank">
lists
</a>
</p>
</li>
<li>
<p>
<a href="specs/guides/Notes_API_Specification/Notes_API_Specification.html" target="_blank">
notes
</a>
</p>
</li>
<li>
<p>
<a href="specs/guides/Popups_API_Specification/Popups_API_Specification.html" target="_blank">
pop-up
lists
</a>
</p>
</li>
<li>
<p>
queries
</p>
</li>
<li>
<p>
<a href="specs/guides/Setting_Pages_API_Specification/Setting_Pages_API_Specification.html" target="_blank">
setting
pages
</a>
</p>
</li>
</ul>
<p>
All of the AVKON resources listed above, except dialogs, queries and
notes, are non-window-owning controls. This means that they cannot exist on
the screen without being inside another
<a href="Chunk654565996.html">
control
</a>
.
</p>
<div class="note">
<span class="notetitle">
Note:
</span>
<p>
Since AVKON UI resources scale automatically according to screen resolution
and orientation, it is recommended that you consider using AVKON or AVKON-derived
components in your application UI as they may require less implementation
effort. Custom
<a href="GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160.html">
<span class="apiname">
CCoeControl
</span>
</a>
-derived controls may require
additional efforts to support
<a href="Chunk1925002978.html">
scalability
</a>
and
<a href="Chunk1313030609.html">
themes
</a>
.
</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink">
<strong>
Parent topic:
</strong>
<a href="Chunk654565996.html#GUID-5944FFF1-79C6-4F5E-95C8-F4833AFC64AB">
Controls
</a>
</div>
</div>
</div>
<p class="copyright">Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).<br /> All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the <a href=" http://www.eclipse.org/legal/epl-v10.html"> Eclipse Public License
v1.0</a>.</p>
</div>
</div>
<?php include_once (CURRENT_SKIN_PATH.'/sdl_footer.html'); ?>
</body>
</html> | warlordh/fork_Symbian | sdk/Chunk2145327219.html | HTML | epl-1.0 | 7,064 |
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="copyright" content="(C) Copyright 2010" />
<meta name="DC.rights.owner" content="(C) Copyright 2010" />
<meta name="DC.Type" content="cxxClass" />
<meta name="DC.Title" content="CPtiKeyMapDataFactory" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="GUID-52D2FA0B-F2BB-336B-AAA3-53BAAB9CDC7C" />
<title>
CPtiKeyMapDataFactory
</title>
<link type="text/css" rel="stylesheet" href="css/common.css" media="screen"/>
<link type="text/css" rel="stylesheet" href="css/sdl.css" media="screen"/>
<!--[if IE]>
<link href="css/iefix.css" rel="stylesheet" type="text/css" media="screen" />
<![endif]-->
<meta name="keywords" content="api" />
<link rel="stylesheet" type="text/css" href="cxxref.css" />
</head>
<body class="cxxref" id="GUID-52D2FA0B-F2BB-336B-AAA3-53BAAB9CDC7C">
<a name="GUID-52D2FA0B-F2BB-336B-AAA3-53BAAB9CDC7C">
<!-- -->
</a>
<?php include_once (CURRENT_SKIN_PATH.'/sdl_header.html'); ?>
<div id="sdl_container">
<div id="leftMenu">
<div id="expandcontractdiv">
<a id="collapseTree" href="javascript:tree.collapseAll()">
Collapse all
</a>
<a id="index" href="index.html">
Symbian^3 Application Developer Library
</a>
</div>
<iframe style="border:none" height="800" width="300" src="index-toc.html"></iframe>
<div id="treeDiv1">
 
</div>
<script type="text/javascript">
var currentIconMode = 0; window.name="id2518338 id2518347 id2420140 id2406431 id2406544 id2406641 ";
YAHOO.util.Event.onDOMReady(buildTree, this,true);
</script>
</div>
<div id="sdl_content">
<div class="breadcrumb">
<a href="index.html" title="Symbian^3 Application Developer Library">
Symbian^3 Application Developer Library
</a>
>
</div>
<h1 class="topictitle1">
CPtiKeyMapDataFactory Class Reference
</h1>
<table class="signature">
<tr>
<td>
class CPtiKeyMapDataFactory : public CBase
</td>
</tr>
</table>
<div class="section">
<div>
<p>
Keymap data factory class.
</p>
</div>
</div>
<div class="section derivation">
<h2 class="sectiontitle">
Inherits from
</h2>
<ul class="derivation derivation-root">
<li class="derivation-depth-0 ">
CPtiKeyMapDataFactory
<ul class="derivation">
<li class="derivation-depth-1 ">
<a href="GUID-8F6FE089-E2A8-30F4-B67E-10F286347681.html">
CBase
</a>
</li>
</ul>
</li>
</ul>
</div>
<div class="section member-index">
<table border="0" class="member-index">
<thead>
<tr>
<th colspan="2">
Public Member Functions
</th>
</tr>
</thead>
<tbody>
<tr>
<td align="right" class="code">
</td>
<td>
<a href="#GUID-EF092D24-2B1E-3D23-81C3-31B1E73301C5">
~CPtiKeyMapDataFactory
</a>
()
</td>
</tr>
<tr class="bg">
<td align="right" class="code">
IMPORT_C
<a href="GUID-52D2FA0B-F2BB-336B-AAA3-53BAAB9CDC7C.html">
CPtiKeyMapDataFactory
</a>
*
</td>
<td>
<a href="#GUID-23419E77-D69E-3224-8B2E-4D89684DE60C">
CreateImplementationL
</a>
(const
<a href="GUID-530281E6-29FC-33F2-BC9B-610FBA389444.html">
TUid
</a>
)
</td>
</tr>
<tr>
<td align="right" class="code">
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
</td>
<td>
<a href="#GUID-5170B5FB-7C5F-3AFD-B002-F0327DD93DD5">
ImplementationUid
</a>
()
</td>
</tr>
<tr class="bg">
<td align="right" class="code">
<a href="GUID-670B1750-7C1F-3DB3-9635-C255F9D3E08D.html">
MPtiKeyMapData
</a>
*
</td>
<td>
<a href="#GUID-EC0769C2-FE34-3CFD-948C-D9EE5A799D00">
KeyMapDataForLanguageL
</a>
(
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
)
</td>
</tr>
<tr>
<td align="right" class="code">
IMPORT_C void
</td>
<td>
<a href="#GUID-A241E73E-A311-311C-B271-9DF46673CAFE">
ListImplementationsL
</a>
(
<a href="GUID-FAEBF321-6B08-3041-A01F-B1E7282D0707.html">
RArray
</a>
<
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
> &)
</td>
</tr>
<tr class="bg">
<td align="right" class="code">
void
</td>
<td>
<a href="#GUID-C4355AEF-68DD-34B9-A008-84BEB1C61696">
ListLanguagesL
</a>
(
<a href="GUID-FAEBF321-6B08-3041-A01F-B1E7282D0707.html">
RArray
</a>
<
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
> &)
</td>
</tr>
<tr>
<td align="right" class="code">
IMPORT_C void
</td>
<td>
<a href="#GUID-7BC9394A-F0A4-323A-B2F6-69AB5090A353">
Reserved_1
</a>
()
</td>
</tr>
<tr class="bg">
<td align="right" class="code">
IMPORT_C void
</td>
<td>
<a href="#GUID-84B9F5A6-20CE-3596-9BFC-FFD93679E105">
Reserved_2
</a>
()
</td>
</tr>
</tbody>
</table>
<table border="0" class="member-index">
<thead>
<tr>
<th colspan="2">
Private Member Functions
</th>
</tr>
</thead>
<tbody>
<tr>
<td align="right" class="code">
void
</td>
<td>
<a href="#GUID-EAB64EA6-597C-373C-9DCA-7F4D1ED721DA">
SetDestructorKeyId
</a>
(
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
)
</td>
</tr>
<tr class="bg">
<td align="right" class="code">
void
</td>
<td>
<a href="#GUID-B2A96013-7D7C-34F6-AA7A-0EF3A9FC4A87">
SetImplementationUid
</a>
(
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
)
</td>
</tr>
</tbody>
</table>
<table border="0" class="member-index">
<thead>
<tr>
<th colspan="2">
Inherited Functions
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
</td>
<td>
<a href="GUID-8F6FE089-E2A8-30F4-B67E-10F286347681.html">
CBase::CBase()
</a>
</td>
</tr>
<tr class="bg">
<td>
</td>
<td>
<a href="GUID-8F6FE089-E2A8-30F4-B67E-10F286347681.html">
CBase::Delete(CBase *)
</a>
</td>
</tr>
<tr>
<td>
</td>
<td>
<a href="GUID-8F6FE089-E2A8-30F4-B67E-10F286347681.html">
CBase::Extension_(TUint,TAny *&,TAny *)
</a>
</td>
</tr>
<tr class="bg">
<td>
</td>
<td>
<a href="GUID-8F6FE089-E2A8-30F4-B67E-10F286347681.html">
CBase::operator new(TUint)
</a>
</td>
</tr>
<tr>
<td>
</td>
<td>
<a href="GUID-8F6FE089-E2A8-30F4-B67E-10F286347681.html">
CBase::operator new(TUint,TAny *)
</a>
</td>
</tr>
<tr class="bg">
<td>
</td>
<td>
<a href="GUID-8F6FE089-E2A8-30F4-B67E-10F286347681.html">
CBase::operator new(TUint,TLeave)
</a>
</td>
</tr>
<tr>
<td>
</td>
<td>
<a href="GUID-8F6FE089-E2A8-30F4-B67E-10F286347681.html">
CBase::operator new(TUint,TLeave,TUint)
</a>
</td>
</tr>
<tr class="bg">
<td>
</td>
<td>
<a href="GUID-8F6FE089-E2A8-30F4-B67E-10F286347681.html">
CBase::operator new(TUint,TUint)
</a>
</td>
</tr>
<tr>
<td>
</td>
<td>
<a href="GUID-8F6FE089-E2A8-30F4-B67E-10F286347681.html">
CBase::~CBase()
</a>
</td>
</tr>
</tbody>
</table>
<table border="0" class="member-index">
<thead>
<tr>
<th colspan="2">
Private Attributes
</th>
</tr>
</thead>
<tbody>
<tr>
<td align="right" valign="top">
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
</td>
<td>
<a href="#GUID-248752D2-78D5-3D4C-9669-003664FE8370">
iDTorId
</a>
</td>
</tr>
<tr class="bg">
<td align="right" valign="top">
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
</td>
<td>
<a href="#GUID-918F3835-B3D0-34D8-A23C-EA33DCF87892">
iImplUid
</a>
</td>
</tr>
<tr>
<td align="right" valign="top">
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
</td>
<td>
<a href="#GUID-425BEFBE-639E-33F5-B1C3-83CFF34AE854">
iReserved
</a>
</td>
</tr>
</tbody>
</table>
</div>
<h1 class="pageHeading topictitle1">
Constructor & Destructor Documentation
</h1>
<div class="nested1" id="GUID-EF092D24-2B1E-3D23-81C3-31B1E73301C5">
<a name="GUID-EF092D24-2B1E-3D23-81C3-31B1E73301C5">
<!-- -->
</a>
<h2 class="topictitle2">
~CPtiKeyMapDataFactory()
</h2>
<table class="signature">
<tr>
<td>
IMPORT_C
</td>
<td>
~CPtiKeyMapDataFactory
</td>
<td>
(
</td>
<td>
)
</td>
<td>
</td>
</tr>
</table>
<div class="section">
</div>
</div>
<h1 class="pageHeading topictitle1">
Member Functions Documentation
</h1>
<div class="nested1" id="GUID-23419E77-D69E-3224-8B2E-4D89684DE60C">
<a name="GUID-23419E77-D69E-3224-8B2E-4D89684DE60C">
<!-- -->
</a>
<h2 class="topictitle2">
CreateImplementationL(const TUid)
</h2>
<table class="signature">
<tr>
<td>
IMPORT_C
<a href="GUID-52D2FA0B-F2BB-336B-AAA3-53BAAB9CDC7C.html">
CPtiKeyMapDataFactory
</a>
*
</td>
<td>
CreateImplementationL
</td>
<td>
(
</td>
<td>
const
<a href="GUID-530281E6-29FC-33F2-BC9B-610FBA389444.html">
TUid
</a>
</td>
<td>
aImplUid
</td>
<td>
)
</td>
<td>
[static]
</td>
</tr>
</table>
<div class="section">
<div>
<p>
Creates a key map data instance for given implementation uid.
</p>
<div class="p">
<dl class="since">
<dt class="dlterm">
Since
</dt>
<dd>
S60 V5.0
</dd>
</dl>
</div>
</div>
</div>
<div class="section parameters">
<h3 class="sectiontitle">
Parameters
</h3>
<table border="0" class="parameters">
<tr>
<td class="parameter">
const
<a href="GUID-530281E6-29FC-33F2-BC9B-610FBA389444.html">
TUid
</a>
aImplUid
</td>
<td>
An implemenation uid for key map data factory to be created.
</td>
</tr>
</table>
</div>
</div>
<div class="nested1" id="GUID-5170B5FB-7C5F-3AFD-B002-F0327DD93DD5">
<a name="GUID-5170B5FB-7C5F-3AFD-B002-F0327DD93DD5">
<!-- -->
</a>
<h2 class="topictitle2">
ImplementationUid()
</h2>
<table class="signature">
<tr>
<td>
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
</td>
<td>
ImplementationUid
</td>
<td>
(
</td>
<td>
)
</td>
<td>
const [inline]
</td>
</tr>
</table>
<div class="section">
</div>
</div>
<div class="nested1" id="GUID-EC0769C2-FE34-3CFD-948C-D9EE5A799D00">
<a name="GUID-EC0769C2-FE34-3CFD-948C-D9EE5A799D00">
<!-- -->
</a>
<h2 class="topictitle2">
KeyMapDataForLanguageL(TInt)
</h2>
<table class="signature">
<tr>
<td>
<a href="GUID-670B1750-7C1F-3DB3-9635-C255F9D3E08D.html">
MPtiKeyMapData
</a>
*
</td>
<td>
KeyMapDataForLanguageL
</td>
<td>
(
</td>
<td>
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
</td>
<td>
aLanguageCode
</td>
<td>
)
</td>
<td>
[pure virtual]
</td>
</tr>
</table>
<div class="section">
<div>
<p>
Returns keymap data object for given language.
</p>
<div class="p">
<dl class="since">
<dt class="dlterm">
Since
</dt>
<dd>
S60 5.0
</dd>
</dl>
</div>
</div>
</div>
<div class="section parameters">
<h3 class="sectiontitle">
Parameters
</h3>
<table border="0" class="parameters">
<tr>
<td class="parameter">
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
aLanguageCode
</td>
<td>
Languace code for requested data.
</td>
</tr>
</table>
</div>
</div>
<div class="nested1" id="GUID-A241E73E-A311-311C-B271-9DF46673CAFE">
<a name="GUID-A241E73E-A311-311C-B271-9DF46673CAFE">
<!-- -->
</a>
<h2 class="topictitle2">
ListImplementationsL(RArray< TInt > &)
</h2>
<table class="signature">
<tr>
<td>
IMPORT_C void
</td>
<td>
ListImplementationsL
</td>
<td>
(
</td>
<td>
<a href="GUID-FAEBF321-6B08-3041-A01F-B1E7282D0707.html">
RArray
</a>
<
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
> &
</td>
<td>
aResult
</td>
<td>
)
</td>
<td>
[static]
</td>
</tr>
</table>
<div class="section">
<div>
<p>
Fills given list with implementation uids of all found key map data factory implementations.
</p>
<div class="p">
<dl class="since">
<dt class="dlterm">
Since
</dt>
<dd>
S60 V5.0
</dd>
</dl>
</div>
</div>
</div>
<div class="section parameters">
<h3 class="sectiontitle">
Parameters
</h3>
<table border="0" class="parameters">
<tr>
<td class="parameter">
<a href="GUID-FAEBF321-6B08-3041-A01F-B1E7282D0707.html">
RArray
</a>
<
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
> & aResult
</td>
<td>
An array to be filled with uids.
</td>
</tr>
</table>
</div>
</div>
<div class="nested1" id="GUID-C4355AEF-68DD-34B9-A008-84BEB1C61696">
<a name="GUID-C4355AEF-68DD-34B9-A008-84BEB1C61696">
<!-- -->
</a>
<h2 class="topictitle2">
ListLanguagesL(RArray< TInt > &)
</h2>
<table class="signature">
<tr>
<td>
void
</td>
<td>
ListLanguagesL
</td>
<td>
(
</td>
<td>
<a href="GUID-FAEBF321-6B08-3041-A01F-B1E7282D0707.html">
RArray
</a>
<
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
> &
</td>
<td>
aResult
</td>
<td>
)
</td>
<td>
[pure virtual]
</td>
</tr>
</table>
<div class="section">
<div>
<p>
Lists all languages supported by this data factory.
</p>
<div class="p">
<dl class="since">
<dt class="dlterm">
Since
</dt>
<dd>
S60 5.0
</dd>
</dl>
</div>
</div>
</div>
<div class="section parameters">
<h3 class="sectiontitle">
Parameters
</h3>
<table border="0" class="parameters">
<tr>
<td class="parameter">
<a href="GUID-FAEBF321-6B08-3041-A01F-B1E7282D0707.html">
RArray
</a>
<
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
> & aResult
</td>
<td>
List instance for storing results.
</td>
</tr>
</table>
</div>
</div>
<div class="nested1" id="GUID-7BC9394A-F0A4-323A-B2F6-69AB5090A353">
<a name="GUID-7BC9394A-F0A4-323A-B2F6-69AB5090A353">
<!-- -->
</a>
<h2 class="topictitle2">
Reserved_1()
</h2>
<table class="signature">
<tr>
<td>
IMPORT_C void
</td>
<td>
Reserved_1
</td>
<td>
(
</td>
<td>
)
</td>
<td>
[virtual]
</td>
</tr>
</table>
<div class="section">
</div>
</div>
<div class="nested1" id="GUID-84B9F5A6-20CE-3596-9BFC-FFD93679E105">
<a name="GUID-84B9F5A6-20CE-3596-9BFC-FFD93679E105">
<!-- -->
</a>
<h2 class="topictitle2">
Reserved_2()
</h2>
<table class="signature">
<tr>
<td>
IMPORT_C void
</td>
<td>
Reserved_2
</td>
<td>
(
</td>
<td>
)
</td>
<td>
[virtual]
</td>
</tr>
</table>
<div class="section">
</div>
</div>
<div class="nested1" id="GUID-EAB64EA6-597C-373C-9DCA-7F4D1ED721DA">
<a name="GUID-EAB64EA6-597C-373C-9DCA-7F4D1ED721DA">
<!-- -->
</a>
<h2 class="topictitle2">
SetDestructorKeyId(TInt)
</h2>
<table class="signature">
<tr>
<td>
void
</td>
<td>
SetDestructorKeyId
</td>
<td>
(
</td>
<td>
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
</td>
<td>
aUid
</td>
<td>
)
</td>
<td>
[private, inline]
</td>
</tr>
</table>
<div class="section">
</div>
<div class="section parameters">
<h3 class="sectiontitle">
Parameters
</h3>
<table border="0" class="parameters">
<tr>
<td class="parameter">
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
aUid
</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<div class="nested1" id="GUID-B2A96013-7D7C-34F6-AA7A-0EF3A9FC4A87">
<a name="GUID-B2A96013-7D7C-34F6-AA7A-0EF3A9FC4A87">
<!-- -->
</a>
<h2 class="topictitle2">
SetImplementationUid(TInt)
</h2>
<table class="signature">
<tr>
<td>
void
</td>
<td>
SetImplementationUid
</td>
<td>
(
</td>
<td>
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
</td>
<td>
aUid
</td>
<td>
)
</td>
<td>
[private, inline]
</td>
</tr>
</table>
<div class="section">
</div>
<div class="section parameters">
<h3 class="sectiontitle">
Parameters
</h3>
<table border="0" class="parameters">
<tr>
<td class="parameter">
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
aUid
</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h1 class="pageHeading topictitle1">
Member Data Documentation
</h1>
<div class="nested1" id="GUID-248752D2-78D5-3D4C-9669-003664FE8370">
<a name="GUID-248752D2-78D5-3D4C-9669-003664FE8370">
<!-- -->
</a>
<h2 class="topictitle2">
TInt
iDTorId
</h2>
<table class="signature">
<tr>
<td>
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
</td>
<td>
iDTorId
</td>
<td>
[private]
</td>
</tr>
</table>
<div class="section">
</div>
</div>
<div class="nested1" id="GUID-918F3835-B3D0-34D8-A23C-EA33DCF87892">
<a name="GUID-918F3835-B3D0-34D8-A23C-EA33DCF87892">
<!-- -->
</a>
<h2 class="topictitle2">
TInt
iImplUid
</h2>
<table class="signature">
<tr>
<td>
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
</td>
<td>
iImplUid
</td>
<td>
[private]
</td>
</tr>
</table>
<div class="section">
</div>
</div>
<div class="nested1" id="GUID-425BEFBE-639E-33F5-B1C3-83CFF34AE854">
<a name="GUID-425BEFBE-639E-33F5-B1C3-83CFF34AE854">
<!-- -->
</a>
<h2 class="topictitle2">
TInt
iReserved
</h2>
<table class="signature">
<tr>
<td>
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
</td>
<td>
iReserved
</td>
<td>
[private]
</td>
</tr>
</table>
<div class="section">
</div>
</div>
<p class="copyright">Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).<br /> All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the <a href=" http://www.eclipse.org/legal/epl-v10.html"> Eclipse Public License
v1.0</a>.</p>
</div>
</div>
<?php include_once (CURRENT_SKIN_PATH.'/sdl_footer.html'); ?>
</body>
</html> | warlordh/fork_Symbian | sdk/GUID-52D2FA0B-F2BB-336B-AAA3-53BAAB9CDC7C.html | HTML | epl-1.0 | 23,488 |
package org.eclipse.scout.widgets.heatmap.client.ui.form.fields.heatmapfield;
import java.util.Collection;
import org.eclipse.scout.rt.client.ui.form.fields.IFormField;
public interface IHeatmapField extends IFormField {
String PROP_VIEW_PARAMETER = "viewParameter";
String PROP_HEAT_POINT_LIST = "heatPointList";
HeatmapViewParameter getViewParameter();
Collection<HeatPoint> getHeatPoints();
void handleClick(MapPoint point);
void addHeatPoint(HeatPoint heatPoint);
void addHeatPoints(Collection<HeatPoint> heatPoints);
void setHeatPoints(Collection<HeatPoint> heatPoints);
void setViewParameter(HeatmapViewParameter parameter);
IHeatmapFieldUIFacade getUIFacade();
void addHeatmapListener(IHeatmapListener listener);
void removeHeatmapListener(IHeatmapListener listener);
}
| BSI-Business-Systems-Integration-AG/org.thethingsnetwork.zrh.monitor | ttn_monitor/org.eclipse.scout.widgets.heatmap.client/src/main/java/org/eclipse/scout/widgets/heatmap/client/ui/form/fields/heatmapfield/IHeatmapField.java | Java | epl-1.0 | 817 |
/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
package org.opendaylight.protocol.bgp.linkstate.nlri;
import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeIpv4Address;
import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeIpv6Address;
import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeShort;
import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedShort;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev150210.NlriType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev150210.linkstate.destination.CLinkstateDestination;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev150210.linkstate.object.type.TeLspCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev150210.linkstate.object.type.TeLspCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev150210.linkstate.object.type.te.lsp._case.AddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev150210.linkstate.object.type.te.lsp._case.address.family.Ipv4Case;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev150210.linkstate.object.type.te.lsp._case.address.family.Ipv4CaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev150210.linkstate.object.type.te.lsp._case.address.family.Ipv6Case;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev150210.linkstate.object.type.te.lsp._case.address.family.Ipv6CaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.TunnelId;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
@VisibleForTesting
public final class TeLspNlriParser {
@VisibleForTesting
public static final YangInstanceIdentifier.NodeIdentifier LSP_ID = new YangInstanceIdentifier.NodeIdentifier(
QName.create(CLinkstateDestination.QNAME, "lsp-id").intern());
@VisibleForTesting
public static final YangInstanceIdentifier.NodeIdentifier TUNNEL_ID = new YangInstanceIdentifier.NodeIdentifier(
QName.create(CLinkstateDestination.QNAME, "tunnel-id").intern());
@VisibleForTesting
public static final YangInstanceIdentifier.NodeIdentifier IPV4_TUNNEL_SENDER_ADDRESS = new YangInstanceIdentifier.NodeIdentifier(
QName.create(CLinkstateDestination.QNAME, "ipv4-tunnel-sender-address").intern());
@VisibleForTesting
public static final YangInstanceIdentifier.NodeIdentifier IPV4_TUNNEL_ENDPOINT_ADDRESS = new YangInstanceIdentifier
.NodeIdentifier(QName.create(CLinkstateDestination.QNAME, "ipv4-tunnel-endpoint-address").intern());
@VisibleForTesting
public static final YangInstanceIdentifier.NodeIdentifier IPV6_TUNNEL_SENDER_ADDRESS = new YangInstanceIdentifier
.NodeIdentifier( QName.create(CLinkstateDestination.QNAME, "ipv6-tunnel-sender-address").intern());
@VisibleForTesting
public static final YangInstanceIdentifier.NodeIdentifier IPV6_TUNNEL_ENDPOINT_ADDRESS = new YangInstanceIdentifier
.NodeIdentifier(QName.create(CLinkstateDestination.QNAME, "ipv6-tunnel-endpoint-address").intern());
@VisibleForTesting
public static final YangInstanceIdentifier.NodeIdentifier IPV4_CASE = new YangInstanceIdentifier.NodeIdentifier(Ipv4Case.QNAME);
@VisibleForTesting
public static final YangInstanceIdentifier.NodeIdentifier IPV6_CASE = new YangInstanceIdentifier.NodeIdentifier(Ipv6Case.QNAME);
@VisibleForTesting
public static final YangInstanceIdentifier.NodeIdentifier ADDRESS_FAMILY = new YangInstanceIdentifier.NodeIdentifier(AddressFamily.QNAME);
private TeLspNlriParser() {
throw new UnsupportedOperationException();
}
public static NlriType serializeIpvTSA(final AddressFamily addressFamily, final ByteBuf body) {
if (addressFamily.equals(Ipv6Case.class)) {
final Ipv6Address ipv6 = ((Ipv6Case) addressFamily).getIpv6TunnelSenderAddress();
Preconditions.checkArgument(ipv6 != null, "Ipv6TunnelSenderAddress is mandatory.");
writeIpv6Address(ipv6, body);
return NlriType.Ipv6TeLsp;
}
final Ipv4Address ipv4 = ((Ipv4Case) addressFamily).getIpv4TunnelSenderAddress();
Preconditions.checkArgument(ipv4 != null, "Ipv4TunnelSenderAddress is mandatory.");
writeIpv4Address(ipv4, body);
return NlriType.Ipv4TeLsp;
}
public static void serializeTunnelID(final TunnelId tunnelID, final ByteBuf body) {
Preconditions.checkArgument(tunnelID != null, "TunnelId is mandatory.");
writeUnsignedShort(tunnelID.getValue(), body);
}
public static void serializeLspID(final LspId lspId, final ByteBuf body) {
Preconditions.checkArgument(lspId != null, "LspId is mandatory.");
writeShort(lspId.getValue().shortValue(), body);
}
public static void serializeTEA(final AddressFamily addressFamily, final ByteBuf body) {
if (addressFamily.equals(Ipv6Case.class)) {
final Ipv6Address ipv6 = ((Ipv6Case) addressFamily).getIpv6TunnelEndpointAddress();
Preconditions.checkArgument(ipv6 != null, "Ipv6TunnelEndpointAddress is mandatory.");
writeIpv6Address(ipv6, body);
return;
}
final Ipv4Address ipv4 = ((Ipv4Case) addressFamily).getIpv4TunnelEndpointAddress();
Preconditions.checkArgument(ipv4 != null, "Ipv4TunnelEndpointAddress is mandatory.");
Preconditions.checkArgument(ipv4 != null, "Ipv4TunnelEndpointAddress is mandatory.");
writeIpv4Address(ipv4, body);
}
public static TeLspCase serializeTeLsp(final ContainerNode containerNode) {
final TeLspCaseBuilder teLspCase = new TeLspCaseBuilder();
teLspCase.setLspId(new LspId((Long) containerNode.getChild(LSP_ID).get().getValue()));
teLspCase.setTunnelId(new TunnelId((Integer) containerNode.getChild(TUNNEL_ID).get().getValue()));
if(containerNode.getChild(ADDRESS_FAMILY).isPresent()) {
final ChoiceNode addressFamily = (ChoiceNode) containerNode.getChild(ADDRESS_FAMILY).get();
if(addressFamily.getChild(IPV4_CASE).isPresent()) {
teLspCase.setAddressFamily(serializeAddressFamily((ContainerNode) addressFamily.getChild(IPV4_CASE)
.get(), true));
}else{
teLspCase.setAddressFamily(serializeAddressFamily((ContainerNode) addressFamily.getChild(IPV6_CASE)
.get(), false));
}
}
return teLspCase.build();
}
private static AddressFamily serializeAddressFamily(final ContainerNode containerNode, final boolean ipv4Case) {
if(ipv4Case) {
return new Ipv4CaseBuilder()
.setIpv4TunnelSenderAddress(new Ipv4Address((String) containerNode.getChild(IPV4_TUNNEL_SENDER_ADDRESS).get().getValue()))
.setIpv4TunnelEndpointAddress(new Ipv4Address((String) containerNode.getChild(IPV4_TUNNEL_ENDPOINT_ADDRESS).get().getValue()))
.build();
}
return new Ipv6CaseBuilder()
.setIpv6TunnelSenderAddress(new Ipv6Address((String) containerNode.getChild(IPV6_TUNNEL_SENDER_ADDRESS).get().getValue()))
.setIpv6TunnelEndpointAddress(new Ipv6Address((String) containerNode.getChild(IPV6_TUNNEL_ENDPOINT_ADDRESS).get().getValue()))
.build();
}
}
| inocybe/odl-bgpcep | bgp/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/nlri/TeLspNlriParser.java | Java | epl-1.0 | 8,515 |
/**
*/
package WTSpec4M.presentation;
import org.eclipse.emf.common.ui.URIEditorInput;
import org.eclipse.emf.common.ui.action.WorkbenchWindowActionDelegate;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.edit.ui.action.LoadResourceAction;
import org.eclipse.emf.edit.ui.util.EditUIUtil;
import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;
import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IFolderLayout;
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPerspectiveFactory;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;
import org.eclipse.ui.application.IWorkbenchConfigurer;
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
import org.eclipse.ui.application.WorkbenchAdvisor;
import org.eclipse.ui.application.WorkbenchWindowAdvisor;
import org.mondo.collaboration.online.rap.widgets.CurrentUserView;
import org.mondo.collaboration.online.rap.widgets.DefaultPerspectiveAdvisor;
import org.mondo.collaboration.online.rap.widgets.ModelExplorer;
import org.mondo.collaboration.online.rap.widgets.ModelLogView;
import org.mondo.collaboration.online.rap.widgets.WhiteboardChatView;
/**
* Customized {@link WorkbenchAdvisor} for the RCP application.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public final class WTSpec4MEditorAdvisor extends WorkbenchAdvisor {
/**
* This looks up a string in the plugin's plugin.properties file.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
private static String getString(String key) {
return WTSpec4MEditorPlugin.INSTANCE.getString(key);
}
/**
* This looks up a string in plugin.properties, making a substitution.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
private static String getString(String key, Object s1) {
return WTSpec4M.presentation.WTSpec4MEditorPlugin.INSTANCE.getString(key, new Object [] { s1 });
}
/**
* RCP's application
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public static class Application implements IApplication {
/**
* @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext)
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Object start(IApplicationContext context) throws Exception {
WorkbenchAdvisor workbenchAdvisor = new WTSpec4MEditorAdvisor();
Display display = PlatformUI.createDisplay();
try {
int returnCode = PlatformUI.createAndRunWorkbench(display, workbenchAdvisor);
if (returnCode == PlatformUI.RETURN_RESTART) {
return IApplication.EXIT_RESTART;
}
else {
return IApplication.EXIT_OK;
}
}
finally {
display.dispose();
}
}
/**
* @see org.eclipse.equinox.app.IApplication#stop()
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void stop() {
// Do nothing.
}
}
/**
* RCP's perspective
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public static class Perspective implements IPerspectiveFactory {
/**
* Perspective ID
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public static final String ID_PERSPECTIVE = "WTSpec4M.presentation.WTSpec4MEditorAdvisorPerspective";
/**
* @see org.eclipse.ui.IPerspectiveFactory#createInitialLayout(org.eclipse.ui.IPageLayout)
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void createInitialLayout(IPageLayout layout) {
layout.setEditorAreaVisible(true);
layout.addPerspectiveShortcut(ID_PERSPECTIVE);
IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT, (float)0.33, layout.getEditorArea());
left.addView(ModelExplorer.ID);
IFolderLayout bottomLeft = layout.createFolder("bottomLeft", IPageLayout.BOTTOM, (float)0.90, "left");
bottomLeft.addView(CurrentUserView.ID);
IFolderLayout topRight = layout.createFolder("topRight", IPageLayout.RIGHT, (float)0.55, layout.getEditorArea());
topRight.addView(WhiteboardChatView.ID);
IFolderLayout right = layout.createFolder("right", IPageLayout.BOTTOM, (float)0.33, "topRight");
right.addView(ModelLogView.ID);
IFolderLayout bottomRight = layout.createFolder("bottomRight", IPageLayout.BOTTOM, (float)0.60, "right");
bottomRight.addView(IPageLayout.ID_PROP_SHEET);
}
}
/**
* RCP's window advisor
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public static class WindowAdvisor extends WorkbenchWindowAdvisor {
private Shell shell;
/**
* @see WorkbenchWindowAdvisor#WorkbenchWindowAdvisor(org.eclipse.ui.application.IWorkbenchWindowConfigurer)
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public WindowAdvisor(IWorkbenchWindowConfigurer configurer) {
super(configurer);
}
@Override
public void createWindowContents(Shell shell) {
super.createWindowContents(shell);
this.shell = shell;
}
@Override
public void postWindowOpen() {
super.postWindowOpen();
shell.setMaximized(true);
DefaultPerspectiveAdvisor.hideDefaultViews();
}
/**
* @see org.eclipse.ui.application.WorkbenchWindowAdvisor#preWindowOpen()
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void preWindowOpen() {
IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
// configurer.setInitialSize(new Point(600, 450));
configurer.setShowCoolBar(false);
configurer.setShowStatusLine(true);
configurer.setTitle(getString("_UI_Application_title"));
}
/**
* @see org.eclipse.ui.application.WorkbenchWindowAdvisor#createActionBarAdvisor(org.eclipse.ui.application.IActionBarConfigurer)
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) {
return new WindowActionBarAdvisor(configurer);
}
}
/**
* RCP's action bar advisor
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public static class WindowActionBarAdvisor extends ActionBarAdvisor {
/**
* @see ActionBarAdvisor#ActionBarAdvisor(org.eclipse.ui.application.IActionBarConfigurer)
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public WindowActionBarAdvisor(IActionBarConfigurer configurer) {
super(configurer);
}
/**
* @see org.eclipse.ui.application.ActionBarAdvisor#fillMenuBar(org.eclipse.jface.action.IMenuManager)
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected void fillMenuBar(IMenuManager menuBar) {
IWorkbenchWindow window = getActionBarConfigurer().getWindowConfigurer().getWindow();
menuBar.add(createFileMenu(window));
menuBar.add(createEditMenu(window));
menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
menuBar.add(createWindowMenu(window));
menuBar.add(createHelpMenu(window));
}
/**
* Creates the 'File' menu.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected IMenuManager createFileMenu(IWorkbenchWindow window) {
IMenuManager menu = new MenuManager(getString("_UI_Menu_File_label"),
IWorkbenchActionConstants.M_FILE);
menu.add(new GroupMarker(IWorkbenchActionConstants.FILE_START));
IMenuManager newMenu = new MenuManager(getString("_UI_Menu_New_label"), "new");
newMenu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
menu.add(newMenu);
menu.add(new Separator());
menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
menu.add(new Separator());
addToMenuAndRegister(menu, ActionFactory.CLOSE.create(window));
addToMenuAndRegister(menu, ActionFactory.CLOSE_ALL.create(window));
menu.add(new Separator());
addToMenuAndRegister(menu, ActionFactory.SAVE.create(window));
addToMenuAndRegister(menu, ActionFactory.SAVE_AS.create(window));
addToMenuAndRegister(menu, ActionFactory.SAVE_ALL.create(window));
menu.add(new Separator());
addToMenuAndRegister(menu, ActionFactory.QUIT.create(window));
menu.add(new GroupMarker(IWorkbenchActionConstants.FILE_END));
return menu;
}
/**
* Creates the 'Edit' menu.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected IMenuManager createEditMenu(IWorkbenchWindow window) {
IMenuManager menu = new MenuManager(getString("_UI_Menu_Edit_label"),
IWorkbenchActionConstants.M_EDIT);
menu.add(new GroupMarker(IWorkbenchActionConstants.EDIT_START));
addToMenuAndRegister(menu, ActionFactory.UNDO.create(window));
addToMenuAndRegister(menu, ActionFactory.REDO.create(window));
menu.add(new GroupMarker(IWorkbenchActionConstants.UNDO_EXT));
menu.add(new Separator());
addToMenuAndRegister(menu, ActionFactory.CUT.create(window));
addToMenuAndRegister(menu, ActionFactory.COPY.create(window));
addToMenuAndRegister(menu, ActionFactory.PASTE.create(window));
menu.add(new GroupMarker(IWorkbenchActionConstants.CUT_EXT));
menu.add(new Separator());
addToMenuAndRegister(menu, ActionFactory.DELETE.create(window));
addToMenuAndRegister(menu, ActionFactory.SELECT_ALL.create(window));
menu.add(new Separator());
menu.add(new GroupMarker(IWorkbenchActionConstants.ADD_EXT));
menu.add(new GroupMarker(IWorkbenchActionConstants.EDIT_END));
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
return menu;
}
/**
* Creates the 'Window' menu.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected IMenuManager createWindowMenu(IWorkbenchWindow window) {
IMenuManager menu = new MenuManager(getString("_UI_Menu_Window_label"),
IWorkbenchActionConstants.M_WINDOW);
addToMenuAndRegister(menu, ActionFactory.OPEN_NEW_WINDOW.create(window));
menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
return menu;
}
/**
* Creates the 'Help' menu.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected IMenuManager createHelpMenu(IWorkbenchWindow window) {
IMenuManager menu = new MenuManager(getString("_UI_Menu_Help_label"), IWorkbenchActionConstants.M_HELP);
// Welcome or intro page would go here
// Help contents would go here
// Tips and tricks page would go here
menu.add(new GroupMarker(IWorkbenchActionConstants.HELP_START));
menu.add(new GroupMarker(IWorkbenchActionConstants.HELP_END));
menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
return menu;
}
/**
* Adds the specified action to the given menu and also registers the action with the
* action bar configurer, in order to activate its key binding.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addToMenuAndRegister(IMenuManager menuManager, IAction action) {
menuManager.add(action);
getActionBarConfigurer().registerGlobalAction(action);
}
}
/**
* About action for the RCP application.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public static class AboutAction extends WorkbenchWindowActionDelegate {
/**
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void run(IAction action) {
MessageDialog.openInformation(getWindow().getShell(), getString("_UI_About_title"),
getString("_UI_About_text"));
}
}
/**
* Open URI action for the objects from the WTSpec4M model.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public static class OpenURIAction extends WorkbenchWindowActionDelegate {
/**
* Opens the editors for the files selected using the LoadResourceDialog.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void run(IAction action) {
LoadResourceAction.LoadResourceDialog loadResourceDialog = new LoadResourceAction.LoadResourceDialog(getWindow().getShell());
if (Window.OK == loadResourceDialog.open()) {
for (URI uri : loadResourceDialog.getURIs()) {
openEditor(getWindow().getWorkbench(), uri);
}
}
}
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public static boolean openEditor(IWorkbench workbench, URI uri) {
IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
IWorkbenchPage page = workbenchWindow.getActivePage();
IEditorDescriptor editorDescriptor = EditUIUtil.getDefaultEditor(uri, null);
if (editorDescriptor == null) {
MessageDialog.openError(
workbenchWindow.getShell(),
getString("_UI_Error_title"),
getString("_WARN_No_Editor", uri.lastSegment()));
return false;
}
else {
try {
page.openEditor(new URIEditorInput(uri), editorDescriptor.getId());
}
catch (PartInitException exception) {
MessageDialog.openError(
workbenchWindow.getShell(),
getString("_UI_OpenEditorError_label"),
exception.getMessage());
return false;
}
}
return true;
}
/**
* @see org.eclipse.ui.application.WorkbenchAdvisor#getInitialWindowPerspectiveId()
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String getInitialWindowPerspectiveId() {
return Perspective.ID_PERSPECTIVE;
}
/**
* @see org.eclipse.ui.application.WorkbenchAdvisor#initialize(org.eclipse.ui.application.IWorkbenchConfigurer)
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void initialize(IWorkbenchConfigurer configurer) {
super.initialize(configurer);
configurer.setSaveAndRestore(true);
}
/**
* @see org.eclipse.ui.application.WorkbenchAdvisor#createWorkbenchWindowAdvisor(org.eclipse.ui.application.IWorkbenchWindowConfigurer)
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
return new WindowAdvisor(configurer);
}
}
| mondo-project/mondo-demo-wt | MONDO-Collab/org.mondo.wt.cstudy.metamodel.online.editor/src/WTSpec4M/presentation/WTSpec4MEditorAdvisor.java | Java | epl-1.0 | 14,965 |
import java.sql.*;
public class ConnessioneDB {
static {
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Connection conn = null;
String url = "jdbc:mysql://localhost:3306/";
String dbName = "calcio";
String userName = "root";
String password = "";
/*
String url = "jdbc:mysql://127.11.139.2:3306/";
String dbName = "sirio";
String userName = "adminlL8hBfI";
String password = "HPZjQCQsnVG4";
*/
public Connection openConnection(){
try {
conn = DriverManager.getConnection(url+dbName,userName,password);
System.out.println("Connessione al DataBase stabilita!");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return conn;
}
public void closeConnection(Connection conn){
try {
conn.close();
System.out.println(" Chiusa connessione al DB!");
}
catch (SQLException e) {
e.printStackTrace();
}
}
}
| nicolediana/progetto | ServletExample/src/ConnessioneDB.java | Java | epl-1.0 | 1,248 |
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="copyright" content="(C) Copyright 2010"/>
<meta name="DC.rights.owner" content="(C) Copyright 2010"/>
<meta name="DC.Type" content="cxxStruct"/>
<meta name="DC.Title" content="NW_WBXML_DictEntry_s"/>
<meta name="DC.Format" content="XHTML"/>
<meta name="DC.Identifier" content="GUID-96500C2E-AB23-3B72-9F5C-B3CDB907B7A1"/>
<title>NW_WBXML_DictEntry_s</title>
<link type="text/css" rel="stylesheet" href="css/common.css" media="screen"/>
<link type="text/css" rel="stylesheet" href="css/sdl.css" media="screen"/>
<!--[if IE]>
<link href="css/iefix.css" rel="stylesheet" type="text/css" media="screen" />
<![endif]-->
<meta name="keywords" content="api"/><link rel="stylesheet" type="text/css" href="cxxref.css"/></head>
<body class="cxxref" id="GUID-96500C2E-AB23-3B72-9F5C-B3CDB907B7A1"><a name="GUID-96500C2E-AB23-3B72-9F5C-B3CDB907B7A1"><!-- --></a>
<?php include_once (CURRENT_SKIN_PATH.'/sdl_header.html'); ?>
<div id="sdl_container">
<div id="leftMenu">
<div id="expandcontractdiv">
<a id="collapseTree" href="javascript:tree.collapseAll()">Collapse all</a>
<a id="index" href="index.html">Symbian^3 Product Developer Library</a>
</div>
<iframe style="border:none" height="800" width="300" src="index-toc.html"></iframe>
<div id="treeDiv1"> </div>
<script type="text/javascript">
var currentIconMode = 0; window.name="id2437088 id2437096 id2366708 id2678541 id2678630 id2679019 ";
YAHOO.util.Event.onDOMReady(buildTree, this,true);
</script>
</div>
<div id="sdl_content">
<div class="breadcrumb"><a href="index.html" title="Symbian^3 Product Developer Library">Symbian^3 Product Developer Library</a> ></div>
<h1 class="topictitle1">NW_WBXML_DictEntry_s Struct Reference</h1>
<table class="signature"><tr><td>struct NW_WBXML_DictEntry_s</td></tr></table><div class="section"></div>
<div class="section member-index"><table border="0" class="member-index"><thead><tr><th colspan="2">Public Attributes</th></tr></thead><tbody><tr><td align="right" valign="top">
<a href="GUID-AB88C0D1-3074-390C-AB9C-6F2CAF37358B.html">NW_String_UCS2Buff_t</a> *</td><td><a href="#GUID-6CDDAA87-2706-3B2C-AB3D-B7CA71F9ED9A">name</a></td></tr><tr class="bg"><td align="right" valign="top">
<a href="GUID-F3173C6F-3297-31CF-B82A-11B084BDCD68.html">NW_Byte</a>
</td><td><a href="#GUID-EF10F77C-BABC-30AB-A33D-3488F3F2E9A1">token</a></td></tr></tbody></table></div><h1 class="pageHeading topictitle1">Member Data Documentation</h1><div class="nested1" id="GUID-6CDDAA87-2706-3B2C-AB3D-B7CA71F9ED9A"><a name="GUID-6CDDAA87-2706-3B2C-AB3D-B7CA71F9ED9A"><!-- --></a>
<h2 class="topictitle2">
NW_String_UCS2Buff_t * name</h2>
<table class="signature"><tr><td>
<a href="GUID-AB88C0D1-3074-390C-AB9C-6F2CAF37358B.html">NW_String_UCS2Buff_t</a> *</td><td>name</td></tr></table><div class="section"></div>
</div>
<div class="nested1" id="GUID-EF10F77C-BABC-30AB-A33D-3488F3F2E9A1"><a name="GUID-EF10F77C-BABC-30AB-A33D-3488F3F2E9A1"><!-- --></a>
<h2 class="topictitle2">
NW_Byte
token</h2>
<table class="signature"><tr><td>
<a href="GUID-F3173C6F-3297-31CF-B82A-11B084BDCD68.html">NW_Byte</a>
</td><td>token</td></tr></table><div class="section"></div>
</div>
<p class="copyright">Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).<br /> All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the <a href=" http://www.eclipse.org/legal/epl-v10.html"> Eclipse Public License
v1.0</a>.</p>
</div>
</div>
<?php include_once (CURRENT_SKIN_PATH.'/sdl_footer.html'); ?>
</body>
</html> | warlordh/fork_Symbian | pdk/GUID-96500C2E-AB23-3B72-9F5C-B3CDB907B7A1.html | HTML | epl-1.0 | 3,921 |
package com.huihuang.utils;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
public class BeanToMap<K, V> {
private BeanToMap() {
}
@SuppressWarnings("unchecked")
public static <K, V> Map<K, V> bean2Map(Object javaBean) {
Map<K, V> ret = new HashMap<K, V>();
try {
Method[] methods = javaBean.getClass().getDeclaredMethods();
for (Method method : methods) {
if (method.getName().startsWith("get")) {
String field = method.getName();
field = field.substring(field.indexOf("get") + 3);
field = field.toLowerCase().charAt(0) + field.substring(1);
Object value = method.invoke(javaBean, (Object[]) null);
ret.put((K) field, (V) (null == value ? "" : value));
}
}
} catch (Exception e) {
}
return ret;
}
}
| yc654084303/QuickConnQuickConnect | QuickConnectPay/src/com/huihuang/utils/BeanToMap.java | Java | epl-1.0 | 1,034 |
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="copyright" content="(C) Copyright 2010" />
<meta name="DC.rights.owner" content="(C) Copyright 2010" />
<meta name="DC.Type" content="cxxClass" />
<meta name="DC.Title" content="Den::Logging" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="GUID-62CBFC38-38A4-3834-8B96-59E616A9FF18" />
<title>
Den::Logging
</title>
<link type="text/css" rel="stylesheet" href="css/common.css" media="screen"/>
<link type="text/css" rel="stylesheet" href="css/sdl.css" media="screen"/>
<!--[if IE]>
<link href="css/iefix.css" rel="stylesheet" type="text/css" media="screen" />
<![endif]-->
<meta name="keywords" content="api" />
<link rel="stylesheet" type="text/css" href="cxxref.css" />
</head>
<body class="cxxref" id="GUID-62CBFC38-38A4-3834-8B96-59E616A9FF18">
<a name="GUID-62CBFC38-38A4-3834-8B96-59E616A9FF18">
<!-- -->
</a>
<?php include_once (CURRENT_SKIN_PATH.'/sdl_header.html'); ?>
<div id="sdl_container">
<div id="leftMenu">
<div id="expandcontractdiv">
<a id="collapseTree" href="javascript:tree.collapseAll()">
Collapse all
</a>
<a id="index" href="index.html">
Symbian^3 Application Developer Library
</a>
</div>
<iframe style="border:none" height="800" width="300" src="index-toc.html"></iframe>
<div id="treeDiv1">
 
</div>
<script type="text/javascript">
var currentIconMode = 0; window.name="id2518338 id2518347 id2858858 id2471677 id2472177 id2472182 ";
YAHOO.util.Event.onDOMReady(buildTree, this,true);
</script>
</div>
<div id="sdl_content">
<div class="breadcrumb">
<a href="index.html" title="Symbian^3 Application Developer Library">
Symbian^3 Application Developer Library
</a>
>
</div>
<h1 class="topictitle1">
Den::Logging Class Reference
</h1>
<table class="signature">
<tr>
<td>
class Den::Logging
</td>
</tr>
</table>
<div class="section">
</div>
<div class="section member-index">
<table border="0" class="member-index">
<thead>
<tr>
<th colspan="2">
Public Member Functions
</th>
</tr>
</thead>
<tbody>
<tr>
<td align="right" class="code">
const
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TText8
</a>
*
</td>
<td>
<a href="#GUID-9D26A5B2-8827-3A2A-8297-02615A780734">
IPCMessName
</a>
(
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
)
</td>
</tr>
<tr class="bg">
<td align="right" class="code">
void
</td>
<td>
<a href="#GUID-0CDEC017-26EF-3E47-A29C-BBC3CC307D46">
IPCMessName
</a>
(
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
,
<a href="GUID-445B19E5-E2EE-32E2-8D6C-C7D6A9B3C507.html">
TDes8
</a>
&)
</td>
</tr>
<tr>
<td align="right" class="code">
IMPORT_C void
</td>
<td>
<a href="#GUID-022B3C0F-054B-3306-A082-066D9373A9EA">
Printf
</a>
(
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
, const
<a href="GUID-FB97E0A3-352A-316F-97C6-69E4741A8120.html">
TDesC8
</a>
&,
<a href="GUID-5391E485-A019-358F-85D2-3B55BA439BD1.html">
TRefByValue
</a>
< const
<a href="GUID-FB97E0A3-352A-316F-97C6-69E4741A8120.html">
TDesC8
</a>
>, ...)
</td>
</tr>
<tr class="bg">
<td align="right" class="code">
IMPORT_C void
</td>
<td>
<a href="#GUID-B739C22A-A0CA-3D41-95FE-C1DC132F5BBB">
Printf
</a>
(
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
, const
<a href="GUID-FB97E0A3-352A-316F-97C6-69E4741A8120.html">
TDesC8
</a>
&,
<a href="GUID-62CBFC38-38A4-3834-8B96-59E616A9FF18.html">
TLogEntryType
</a>
,
<a href="GUID-5391E485-A019-358F-85D2-3B55BA439BD1.html">
TRefByValue
</a>
< const
<a href="GUID-FB97E0A3-352A-316F-97C6-69E4741A8120.html">
TDesC8
</a>
>, ...)
</td>
</tr>
<tr>
<td align="right" class="code">
IMPORT_C void
</td>
<td>
<a href="#GUID-FA46CFC5-2C60-3287-83BD-C0DEF15F26AA">
Printf
</a>
(
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
, const
<a href="GUID-FB97E0A3-352A-316F-97C6-69E4741A8120.html">
TDesC8
</a>
&,
<a href="GUID-62CBFC38-38A4-3834-8B96-59E616A9FF18.html">
TLogEntryType
</a>
,
<a href="GUID-5391E485-A019-358F-85D2-3B55BA439BD1.html">
TRefByValue
</a>
< const
<a href="GUID-FB97E0A3-352A-316F-97C6-69E4741A8120.html">
TDesC8
</a>
>,
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
VA_LIST
</a>
&)
</td>
</tr>
</tbody>
</table>
<table border="0" class="member-index">
<thead>
<tr>
<th colspan="2">
Public Member Enumerations
</th>
</tr>
</thead>
<tbody>
<tr>
<td align="right" valign="top">
enum
</td>
<td>
<a href="#GUID-C1C0A50C-1685-3AFF-A7AC-CF213DB13476">
TLogEntryType
</a>
{
<a href="#GUID-A7B9B329-76AC-3E75-A4EE-2F259ACC51DD">
ELogBinary
</a>
= KBinary,
<a href="#GUID-F61D6A71-E3BE-37A8-B6ED-BF67BDA59C8F">
ELogInfo
</a>
= KText,
<a href="#GUID-B51C9E5D-0FF7-3FE5-9A46-047A96C7BE4B">
ELogBlockStart
</a>
,
<a href="#GUID-463FA153-1DFA-3873-9001-1A1490F67807">
ELogBlockEnd
</a>
}
</td>
</tr>
</tbody>
</table>
<table border="0" class="member-index">
<thead>
<tr>
<th colspan="2">
Private Member Enumerations
</th>
</tr>
</thead>
<tbody>
<tr>
<td align="right" valign="top">
enum
</td>
<td>
<a href="#GUID-979B6102-8E82-33F8-B2E5-BC7CB6E23978">
anonymous
</a>
{
<a href="#GUID-5C26C36A-E4B1-3AE4-AAD5-53CD4895C00B">
KPrimaryFilter
</a>
= 194 }
</td>
</tr>
</tbody>
</table>
</div>
<h1 class="pageHeading topictitle1">
Member Functions Documentation
</h1>
<div class="nested1" id="GUID-9D26A5B2-8827-3A2A-8297-02615A780734">
<a name="GUID-9D26A5B2-8827-3A2A-8297-02615A780734">
<!-- -->
</a>
<h2 class="topictitle2">
IPCMessName(TInt)
</h2>
<table class="signature">
<tr>
<td>
const
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TText8
</a>
*
</td>
<td>
IPCMessName
</td>
<td>
(
</td>
<td>
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
</td>
<td>
aMess
</td>
<td>
)
</td>
<td>
[static]
</td>
</tr>
</table>
<div class="section">
</div>
<div class="section parameters">
<h3 class="sectiontitle">
Parameters
</h3>
<table border="0" class="parameters">
<tr>
<td class="parameter">
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
aMess
</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<div class="nested1" id="GUID-0CDEC017-26EF-3E47-A29C-BBC3CC307D46">
<a name="GUID-0CDEC017-26EF-3E47-A29C-BBC3CC307D46">
<!-- -->
</a>
<h2 class="topictitle2">
IPCMessName(TInt, TDes8 &)
</h2>
<table class="signature">
<tr>
<td>
void
</td>
<td>
IPCMessName
</td>
<td>
(
</td>
<td>
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
</td>
<td>
aMessNum,
</td>
</tr>
<tr>
<td colspan="3">
</td>
<td>
<a href="GUID-445B19E5-E2EE-32E2-8D6C-C7D6A9B3C507.html">
TDes8
</a>
&
</td>
<td>
aMessBuf
</td>
</tr>
<tr>
<td colspan="2">
</td>
<td>
)
</td>
<td colspan="2">
[static]
</td>
</tr>
</table>
<div class="section">
</div>
<div class="section parameters">
<h3 class="sectiontitle">
Parameters
</h3>
<table border="0" class="parameters">
<tr>
<td class="parameter">
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
aMessNum
</td>
<td>
</td>
</tr>
<tr class="bg">
<td class="parameter">
<a href="GUID-445B19E5-E2EE-32E2-8D6C-C7D6A9B3C507.html">
TDes8
</a>
& aMessBuf
</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<div class="nested1" id="GUID-022B3C0F-054B-3306-A082-066D9373A9EA">
<a name="GUID-022B3C0F-054B-3306-A082-066D9373A9EA">
<!-- -->
</a>
<h2 class="topictitle2">
Printf(TInt, const TDesC8 &, TRefByValue< const TDesC8 >, ...)
</h2>
<table class="signature">
<tr>
<td>
IMPORT_C void
</td>
<td>
Printf
</td>
<td>
(
</td>
<td>
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
</td>
<td>
aWorkerId,
</td>
</tr>
<tr>
<td colspan="3">
</td>
<td>
const
<a href="GUID-FB97E0A3-352A-316F-97C6-69E4741A8120.html">
TDesC8
</a>
&
</td>
<td>
aSubTag,
</td>
</tr>
<tr>
<td colspan="3">
</td>
<td>
<a href="GUID-5391E485-A019-358F-85D2-3B55BA439BD1.html">
TRefByValue
</a>
< const
<a href="GUID-FB97E0A3-352A-316F-97C6-69E4741A8120.html">
TDesC8
</a>
>
</td>
<td>
aFmt,
</td>
</tr>
<tr>
<td colspan="3">
</td>
<td>
...
</td>
<td>
</td>
</tr>
<tr>
<td colspan="2">
</td>
<td>
)
</td>
<td colspan="2">
[static]
</td>
</tr>
</table>
<div class="section">
</div>
<div class="section parameters">
<h3 class="sectiontitle">
Parameters
</h3>
<table border="0" class="parameters">
<tr>
<td class="parameter">
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
aWorkerId
</td>
<td>
</td>
</tr>
<tr class="bg">
<td class="parameter">
const
<a href="GUID-FB97E0A3-352A-316F-97C6-69E4741A8120.html">
TDesC8
</a>
& aSubTag
</td>
<td>
</td>
</tr>
<tr>
<td class="parameter">
<a href="GUID-5391E485-A019-358F-85D2-3B55BA439BD1.html">
TRefByValue
</a>
< const
<a href="GUID-FB97E0A3-352A-316F-97C6-69E4741A8120.html">
TDesC8
</a>
> aFmt
</td>
<td>
</td>
</tr>
<tr class="bg">
<td class="parameter">
...
</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<div class="nested1" id="GUID-B739C22A-A0CA-3D41-95FE-C1DC132F5BBB">
<a name="GUID-B739C22A-A0CA-3D41-95FE-C1DC132F5BBB">
<!-- -->
</a>
<h2 class="topictitle2">
Printf(TInt, const TDesC8 &, TLogEntryType, TRefByValue< const TDesC8 >, ...)
</h2>
<table class="signature">
<tr>
<td>
IMPORT_C void
</td>
<td>
Printf
</td>
<td>
(
</td>
<td>
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
</td>
<td>
aWorkerId,
</td>
</tr>
<tr>
<td colspan="3">
</td>
<td>
const
<a href="GUID-FB97E0A3-352A-316F-97C6-69E4741A8120.html">
TDesC8
</a>
&
</td>
<td>
aSubTag,
</td>
</tr>
<tr>
<td colspan="3">
</td>
<td>
<a href="GUID-62CBFC38-38A4-3834-8B96-59E616A9FF18.html">
TLogEntryType
</a>
</td>
<td>
aType,
</td>
</tr>
<tr>
<td colspan="3">
</td>
<td>
<a href="GUID-5391E485-A019-358F-85D2-3B55BA439BD1.html">
TRefByValue
</a>
< const
<a href="GUID-FB97E0A3-352A-316F-97C6-69E4741A8120.html">
TDesC8
</a>
>
</td>
<td>
aFmt,
</td>
</tr>
<tr>
<td colspan="3">
</td>
<td>
...
</td>
<td>
</td>
</tr>
<tr>
<td colspan="2">
</td>
<td>
)
</td>
<td colspan="2">
[static]
</td>
</tr>
</table>
<div class="section">
</div>
<div class="section parameters">
<h3 class="sectiontitle">
Parameters
</h3>
<table border="0" class="parameters">
<tr>
<td class="parameter">
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
aWorkerId
</td>
<td>
</td>
</tr>
<tr class="bg">
<td class="parameter">
const
<a href="GUID-FB97E0A3-352A-316F-97C6-69E4741A8120.html">
TDesC8
</a>
& aSubTag
</td>
<td>
</td>
</tr>
<tr>
<td class="parameter">
<a href="GUID-62CBFC38-38A4-3834-8B96-59E616A9FF18.html">
TLogEntryType
</a>
aType
</td>
<td>
</td>
</tr>
<tr class="bg">
<td class="parameter">
<a href="GUID-5391E485-A019-358F-85D2-3B55BA439BD1.html">
TRefByValue
</a>
< const
<a href="GUID-FB97E0A3-352A-316F-97C6-69E4741A8120.html">
TDesC8
</a>
> aFmt
</td>
<td>
</td>
</tr>
<tr>
<td class="parameter">
...
</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<div class="nested1" id="GUID-FA46CFC5-2C60-3287-83BD-C0DEF15F26AA">
<a name="GUID-FA46CFC5-2C60-3287-83BD-C0DEF15F26AA">
<!-- -->
</a>
<h2 class="topictitle2">
Printf(TInt, const TDesC8 &, TLogEntryType, TRefByValue< const TDesC8 >, VA_LIST &)
</h2>
<table class="signature">
<tr>
<td>
IMPORT_C void
</td>
<td>
Printf
</td>
<td>
(
</td>
<td>
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
</td>
<td>
aWorkerId,
</td>
</tr>
<tr>
<td colspan="3">
</td>
<td>
const
<a href="GUID-FB97E0A3-352A-316F-97C6-69E4741A8120.html">
TDesC8
</a>
&
</td>
<td>
aSubTag,
</td>
</tr>
<tr>
<td colspan="3">
</td>
<td>
<a href="GUID-62CBFC38-38A4-3834-8B96-59E616A9FF18.html">
TLogEntryType
</a>
</td>
<td>
aType,
</td>
</tr>
<tr>
<td colspan="3">
</td>
<td>
<a href="GUID-5391E485-A019-358F-85D2-3B55BA439BD1.html">
TRefByValue
</a>
< const
<a href="GUID-FB97E0A3-352A-316F-97C6-69E4741A8120.html">
TDesC8
</a>
>
</td>
<td>
aFmt,
</td>
</tr>
<tr>
<td colspan="3">
</td>
<td>
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
VA_LIST
</a>
&
</td>
<td>
aList
</td>
</tr>
<tr>
<td colspan="2">
</td>
<td>
)
</td>
<td colspan="2">
[static]
</td>
</tr>
</table>
<div class="section">
</div>
<div class="section parameters">
<h3 class="sectiontitle">
Parameters
</h3>
<table border="0" class="parameters">
<tr>
<td class="parameter">
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
aWorkerId
</td>
<td>
</td>
</tr>
<tr class="bg">
<td class="parameter">
const
<a href="GUID-FB97E0A3-352A-316F-97C6-69E4741A8120.html">
TDesC8
</a>
& aSubTag
</td>
<td>
</td>
</tr>
<tr>
<td class="parameter">
<a href="GUID-62CBFC38-38A4-3834-8B96-59E616A9FF18.html">
TLogEntryType
</a>
aType
</td>
<td>
</td>
</tr>
<tr class="bg">
<td class="parameter">
<a href="GUID-5391E485-A019-358F-85D2-3B55BA439BD1.html">
TRefByValue
</a>
< const
<a href="GUID-FB97E0A3-352A-316F-97C6-69E4741A8120.html">
TDesC8
</a>
> aFmt
</td>
<td>
</td>
</tr>
<tr>
<td class="parameter">
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
VA_LIST
</a>
& aList
</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h1 class="pageHeading topictitle1">
Member Enumerations Documentation
</h1>
<div class="nested1" id="GUID-979B6102-8E82-33F8-B2E5-BC7CB6E23978">
<a name="GUID-979B6102-8E82-33F8-B2E5-BC7CB6E23978">
<!-- -->
</a>
<h2 class="topictitle2">
Enum anonymous
</h2>
<div class="section">
</div>
<div class="section enumerators">
<h3 class="sectiontitle">
Enumerators
</h3>
<table border="0" class="enumerators">
<tr>
<td valign="top">
KPrimaryFilter = 194
</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<div class="nested1" id="GUID-C1C0A50C-1685-3AFF-A7AC-CF213DB13476">
<a name="GUID-C1C0A50C-1685-3AFF-A7AC-CF213DB13476">
<!-- -->
</a>
<h2 class="topictitle2">
Enum TLogEntryType
</h2>
<div class="section">
</div>
<div class="section enumerators">
<h3 class="sectiontitle">
Enumerators
</h3>
<table border="0" class="enumerators">
<tr>
<td valign="top">
ELogBinary = KBinary
</td>
<td>
</td>
</tr>
<tr class="bg">
<td valign="top">
ELogInfo = KText
</td>
<td>
</td>
</tr>
<tr>
<td valign="top">
ELogBlockStart
</td>
<td>
</td>
</tr>
<tr class="bg">
<td valign="top">
ELogBlockEnd
</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<p class="copyright">Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).<br /> All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the <a href=" http://www.eclipse.org/legal/epl-v10.html"> Eclipse Public License
v1.0</a>.</p>
</div>
</div>
<?php include_once (CURRENT_SKIN_PATH.'/sdl_footer.html'); ?>
</body>
</html> | warlordh/fork_Symbian | sdk/GUID-62CBFC38-38A4-3834-8B96-59E616A9FF18.html | HTML | epl-1.0 | 21,338 |
/**
* Copyright (c) 2015 SK holdings Co., Ltd. All rights reserved.
* This software is the confidential and proprietary information of SK holdings.
* You shall not disclose such confidential information and shall use it only in
* accordance with the terms of the license agreement you entered into with SK holdings.
* (http://www.eclipse.org/legal/epl-v10.html)
*/
package nexcore.alm.common.excel;
import nexcore.alm.common.exception.BaseException;
/**
* Excel import/export 과정에서 발생할 수 있는 예외상황
*
* @author indeday
*
*/
public class ExcelException extends BaseException {
/**
* serialVersionUID
*/
private static final long serialVersionUID = 5191191573910676820L;
/**
* @see BaseException#BaseException(String, String)
*/
public ExcelException(String message, String logType) {
super(message, logType);
}
/**
* @see BaseException#BaseException(String, Throwable, String)
*/
public ExcelException(Throwable cause, String message, String logType) {
super(message, cause, logType);
}
/**
* @see BaseException#BaseException(Throwable, String)
*/
public ExcelException(Throwable cause, String message) {
super(cause, message);
}
/**
* @see BaseException#BaseException(Throwable, boolean)
*/
public ExcelException(Throwable cause, boolean useLog) {
super(cause, useLog);
}
}
| SK-HOLDINGS-CC/NEXCORE-UML-Modeler | nexcore.alm.common/src/nexcore/alm/common/excel/ExcelException.java | Java | epl-1.0 | 1,457 |
/*******************************************************************************
* Copyright (c) 2009 Andrey Loskutov.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
* Contributor: Andrey Loskutov - initial API and implementation
*******************************************************************************/
package de.loskutov.anyedit.actions.replace;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringWriter;
import java.io.Writer;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.filebuffers.ITextFileBuffer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.handlers.HandlerUtil;
import de.loskutov.anyedit.AnyEditToolsPlugin;
import de.loskutov.anyedit.IAnyEditConstants;
import de.loskutov.anyedit.compare.ContentWrapper;
import de.loskutov.anyedit.ui.editor.AbstractEditor;
import de.loskutov.anyedit.util.EclipseUtils;
/**
* @author Andrey
*/
public abstract class ReplaceWithAction extends AbstractHandler implements IObjectActionDelegate {
protected ContentWrapper selectedContent;
protected AbstractEditor editor;
public ReplaceWithAction() {
super();
editor = new AbstractEditor(null);
}
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
Action dummyAction = new Action(){
@Override
public String getId() {
return event.getCommand().getId();
}
};
setActivePart(dummyAction, activePart);
ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
selectionChanged(dummyAction, currentSelection);
if(dummyAction.isEnabled()) {
run(dummyAction);
}
return null;
}
@Override
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
if (targetPart instanceof IEditorPart) {
editor = new AbstractEditor((IEditorPart) targetPart);
} else {
editor = new AbstractEditor(null);
}
}
@Override
public void run(IAction action) {
InputStream stream = createInputStream();
if (stream == null) {
return;
}
replace(stream);
}
private void replace(InputStream stream) {
if(selectedContent == null || !selectedContent.isModifiable()){
return;
}
IDocument document = editor.getDocument();
if (!editor.isDisposed() && document != null) {
// replace selection only
String text = getChangedCompareText(stream);
ITextSelection selection = editor.getSelection();
if (selection == null || selection.getLength() == 0) {
document.set(text);
} else {
try {
document.replace(selection.getOffset(), selection.getLength(), text);
} catch (BadLocationException e) {
AnyEditToolsPlugin.logError("Can't update text in editor", e);
}
}
return;
}
replace(selectedContent, stream);
}
private String getChangedCompareText(InputStream stream) {
StringWriter sw = new StringWriter();
copyStreamToWriter(stream, sw);
return sw.toString();
}
private void replace(ContentWrapper content, InputStream stream) {
IFile file = content.getIFile();
if (file == null || file.getLocation() == null) {
saveExternalFile(content, stream);
return;
}
try {
if (!file.exists()) {
file.create(stream, true, new NullProgressMonitor());
} else {
ITextFileBuffer buffer = EclipseUtils.getBuffer(file);
try {
if (AnyEditToolsPlugin.getDefault().getPreferenceStore().getBoolean(
IAnyEditConstants.SAVE_DIRTY_BUFFER)) {
if (buffer != null && buffer.isDirty()) {
buffer.commit(new NullProgressMonitor(), false);
}
}
if (buffer != null) {
buffer.validateState(new NullProgressMonitor(),
AnyEditToolsPlugin.getShell());
}
} finally {
EclipseUtils.disconnectBuffer(buffer);
}
file.setContents(stream, true, true, new NullProgressMonitor());
}
} catch (CoreException e) {
AnyEditToolsPlugin.errorDialog("Can't replace file content: " + file, e);
} finally {
try {
stream.close();
} catch (IOException e) {
AnyEditToolsPlugin.logError("Failed to close stream", e);
}
}
}
private void copyStreamToWriter(InputStream stream, Writer writer){
InputStreamReader in = null;
try {
in = new InputStreamReader(stream, editor.computeEncoding());
BufferedReader br = new BufferedReader(in);
int i;
while ((i = br.read()) != -1) {
writer.write(i);
}
writer.flush();
} catch (IOException e) {
AnyEditToolsPlugin.logError("Error during reading/writing streams", e);
} finally {
try {
if (writer != null) {
writer.close();
}
} catch (IOException e) {
AnyEditToolsPlugin.logError("Failed to close stream", e);
}
try {
if (in != null) {
in.close();
}
} catch (IOException e) {
AnyEditToolsPlugin.logError("Failed to close stream", e);
}
}
}
private void saveExternalFile(ContentWrapper content, InputStream stream) {
File file2 = null;
IFile iFile = content.getIFile();
if (iFile != null) {
file2 = new File(iFile.getFullPath().toOSString());
} else {
file2 = content.getFile();
}
if (!file2.exists()) {
try {
file2.createNewFile();
} catch (IOException e) {
AnyEditToolsPlugin.errorDialog("Can't create file: " + file2, e);
return;
}
}
boolean canWrite = file2.canWrite();
if (!canWrite) {
AnyEditToolsPlugin.errorDialog("File is read-only: " + file2);
return;
}
BufferedWriter bw = null;
try {
bw = new BufferedWriter(new FileWriter(file2));
copyStreamToWriter(stream, bw);
} catch (IOException e) {
AnyEditToolsPlugin.logError("Error on saving to file: " + file2, e);
return;
} finally {
try {
if(bw != null) {
bw.close();
}
} catch (IOException e) {
AnyEditToolsPlugin.logError("Error on saving to file: " + file2, e);
}
}
if (iFile != null) {
try {
iFile.refreshLocal(IResource.DEPTH_ONE, new NullProgressMonitor());
} catch (CoreException e) {
AnyEditToolsPlugin.logError("Failed to refresh file: " + iFile, e);
}
}
}
abstract protected InputStream createInputStream();
@Override
public void selectionChanged(IAction action, ISelection selection) {
if (!(selection instanceof IStructuredSelection) || selection.isEmpty()) {
if(!editor.isDisposed()){
selectedContent = ContentWrapper.create(editor);
}
action.setEnabled(selectedContent != null);
return;
}
IStructuredSelection sSelection = (IStructuredSelection) selection;
Object firstElement = sSelection.getFirstElement();
if(!editor.isDisposed()) {
selectedContent = ContentWrapper.create(editor);
} else {
selectedContent = ContentWrapper.create(firstElement);
}
action.setEnabled(selectedContent != null && sSelection.size() == 1);
}
}
| iloveeclipse/anyedittools | AnyEditTools/src/de/loskutov/anyedit/actions/replace/ReplaceWithAction.java | Java | epl-1.0 | 9,434 |
/*
* Copyright 2012 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Eclipse Public License version 1.0, available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.jboss.aesh.complete;
import org.jboss.aesh.console.AeshContext;
import org.jboss.aesh.parser.Parser;
import org.jboss.aesh.terminal.TerminalString;
import java.util.ArrayList;
import java.util.List;
/**
* A payload object to store completion data
*
* @author Ståle W. Pedersen <[email protected]>
*/
public class CompleteOperation {
private String buffer;
private int cursor;
private int offset;
private List<TerminalString> completionCandidates;
private boolean trimmed = false;
private boolean ignoreStartsWith = false;
private String nonTrimmedBuffer;
private AeshContext aeshContext;
private char separator = ' ';
private boolean appendSeparator = true;
private boolean ignoreOffset = false;
public CompleteOperation(AeshContext aeshContext, String buffer, int cursor) {
this.aeshContext = aeshContext;
setCursor(cursor);
setSeparator(' ');
doAppendSeparator(true);
completionCandidates = new ArrayList<>();
setBuffer(buffer);
}
public String getBuffer() {
return buffer;
}
private void setBuffer(String buffer) {
if(buffer != null && buffer.startsWith(" ")) {
trimmed = true;
this.buffer = Parser.trimInFront(buffer);
nonTrimmedBuffer = buffer;
setCursor(cursor - getTrimmedSize());
}
else
this.buffer = buffer;
}
public boolean isTrimmed() {
return trimmed;
}
public int getTrimmedSize() {
return nonTrimmedBuffer.length() - buffer.length();
}
public String getNonTrimmedBuffer() {
return nonTrimmedBuffer;
}
public int getCursor() {
return cursor;
}
private void setCursor(int cursor) {
if(cursor < 0)
this.cursor = 0;
else
this.cursor = cursor;
}
public int getOffset() {
return offset;
}
public void setOffset(int offset) {
this.offset = offset;
}
public void setIgnoreOffset(boolean ignoreOffset) {
this.ignoreOffset = ignoreOffset;
}
public boolean doIgnoreOffset() {
return ignoreOffset;
}
public AeshContext getAeshContext() {
return aeshContext;
}
/**
* Get the separator character, by default its space
*
* @return separator
*/
public char getSeparator() {
return separator;
}
/**
* By default the separator is one space char, but
* it can be overridden here.
*
* @param separator separator
*/
public void setSeparator(char separator) {
this.separator = separator;
}
/**
* Do this completion allow for appending a separator
* after completion? By default this is true.
*
* @return appendSeparator
*/
public boolean hasAppendSeparator() {
return appendSeparator;
}
/**
* Set if this CompletionOperation would allow an separator to
* be appended. By default this is true.
*
* @param appendSeparator appendSeparator
*/
public void doAppendSeparator(boolean appendSeparator) {
this.appendSeparator = appendSeparator;
}
public List<TerminalString> getCompletionCandidates() {
return completionCandidates;
}
public void setCompletionCandidates(List<String> completionCandidates) {
addCompletionCandidates(completionCandidates);
}
public void setCompletionCandidatesTerminalString(List<TerminalString> completionCandidates) {
this.completionCandidates = completionCandidates;
}
public void addCompletionCandidate(TerminalString completionCandidate) {
this.completionCandidates.add(completionCandidate);
}
public void addCompletionCandidate(String completionCandidate) {
addStringCandidate(completionCandidate);
}
public void addCompletionCandidates(List<String> completionCandidates) {
addStringCandidates(completionCandidates);
}
public void addCompletionCandidatesTerminalString(List<TerminalString> completionCandidates) {
this.completionCandidates.addAll(completionCandidates);
}
public void removeEscapedSpacesFromCompletionCandidates() {
Parser.switchEscapedSpacesToSpacesInTerminalStringList(getCompletionCandidates());
}
private void addStringCandidate(String completionCandidate) {
this.completionCandidates.add(new TerminalString(completionCandidate, true));
}
private void addStringCandidates(List<String> completionCandidates) {
for(String s : completionCandidates)
addStringCandidate(s);
}
public List<String> getFormattedCompletionCandidates() {
List<String> fixedCandidates = new ArrayList<String>(completionCandidates.size());
for(TerminalString c : completionCandidates) {
if(!ignoreOffset && offset < cursor) {
int pos = cursor - offset;
if(c.getCharacters().length() >= pos)
fixedCandidates.add(c.getCharacters().substring(pos));
else
fixedCandidates.add("");
}
else {
fixedCandidates.add(c.getCharacters());
}
}
return fixedCandidates;
}
public List<TerminalString> getFormattedCompletionCandidatesTerminalString() {
List<TerminalString> fixedCandidates = new ArrayList<TerminalString>(completionCandidates.size());
for(TerminalString c : completionCandidates) {
if(!ignoreOffset && offset < cursor) {
int pos = cursor - offset;
if(c.getCharacters().length() >= pos) {
TerminalString ts = c;
ts.setCharacters(c.getCharacters().substring(pos));
fixedCandidates.add(ts);
}
else
fixedCandidates.add(new TerminalString("", true));
}
else {
fixedCandidates.add(c);
}
}
return fixedCandidates;
}
public String getFormattedCompletion(String completion) {
if(offset < cursor) {
int pos = cursor - offset;
if(completion.length() > pos)
return completion.substring(pos);
else
return "";
}
else
return completion;
}
public boolean isIgnoreStartsWith() {
return ignoreStartsWith;
}
public void setIgnoreStartsWith(boolean ignoreStartsWith) {
this.ignoreStartsWith = ignoreStartsWith;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("Buffer: ").append(buffer)
.append(", Cursor:").append(cursor)
.append(", Offset:").append(offset)
.append(", IgnoreOffset:").append(ignoreOffset)
.append(", Append separator: ").append(appendSeparator)
.append(", Candidates:").append(completionCandidates);
return sb.toString();
}
}
| aslakknutsen/aesh | src/main/java/org/jboss/aesh/complete/CompleteOperation.java | Java | epl-1.0 | 7,366 |
package dao.inf;
// Generated 27/11/2014 02:39:51 AM by Hibernate Tools 3.4.0.CR1
import java.util.List;
import javax.naming.InitialContext;
import model.Query;
import model.QueryId;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Example;
/**
* Home object for domain model class Query.
* @see .Query
* @author Hibernate Tools
*/
public interface QueryDAO {
public boolean save(Query query);
public Integer lastId();
}
| mhersc1/SIGAE | src/main/java/dao/inf/QueryDAO.java | Java | epl-1.0 | 590 |
/**
* <copyright>
* </copyright>
*
* $Id$
*/
package klaper.expr.util;
import java.util.List;
import klaper.expr.Atom;
import klaper.expr.Binary;
import klaper.expr.Div;
import klaper.expr.Exp;
import klaper.expr.ExprPackage;
import klaper.expr.Expression;
import klaper.expr.Minus;
import klaper.expr.Mult;
import klaper.expr.Operator;
import klaper.expr.Plus;
import klaper.expr.Unary;
import klaper.expr.Variable;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
/**
* <!-- begin-user-doc -->
* The <b>Switch</b> for the model's inheritance hierarchy.
* It supports the call {@link #doSwitch(EObject) doSwitch(object)}
* to invoke the <code>caseXXX</code> method for each class of the model,
* starting with the actual class of the object
* and proceeding up the inheritance hierarchy
* until a non-null result is returned,
* which is the result of the switch.
* <!-- end-user-doc -->
* @see klaper.expr.ExprPackage
* @generated
*/
public class ExprSwitch<T> {
/**
* The cached model package
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected static ExprPackage modelPackage;
/**
* Creates an instance of the switch.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ExprSwitch() {
if (modelPackage == null) {
modelPackage = ExprPackage.eINSTANCE;
}
}
/**
* Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the first non-null result returned by a <code>caseXXX</code> call.
* @generated
*/
public T doSwitch(EObject theEObject) {
return doSwitch(theEObject.eClass(), theEObject);
}
/**
* Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the first non-null result returned by a <code>caseXXX</code> call.
* @generated
*/
protected T doSwitch(EClass theEClass, EObject theEObject) {
if (theEClass.eContainer() == modelPackage) {
return doSwitch(theEClass.getClassifierID(), theEObject);
}
else {
List<EClass> eSuperTypes = theEClass.getESuperTypes();
return
eSuperTypes.isEmpty() ?
defaultCase(theEObject) :
doSwitch(eSuperTypes.get(0), theEObject);
}
}
/**
* Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the first non-null result returned by a <code>caseXXX</code> call.
* @generated
*/
protected T doSwitch(int classifierID, EObject theEObject) {
switch (classifierID) {
case ExprPackage.EXPRESSION: {
Expression expression = (Expression)theEObject;
T result = caseExpression(expression);
if (result == null) result = defaultCase(theEObject);
return result;
}
case ExprPackage.ATOM: {
Atom atom = (Atom)theEObject;
T result = caseAtom(atom);
if (result == null) result = caseExpression(atom);
if (result == null) result = defaultCase(theEObject);
return result;
}
case ExprPackage.NUMBER: {
klaper.expr.Number number = (klaper.expr.Number)theEObject;
T result = caseNumber(number);
if (result == null) result = caseAtom(number);
if (result == null) result = caseExpression(number);
if (result == null) result = defaultCase(theEObject);
return result;
}
case ExprPackage.VARIABLE: {
Variable variable = (Variable)theEObject;
T result = caseVariable(variable);
if (result == null) result = caseAtom(variable);
if (result == null) result = caseExpression(variable);
if (result == null) result = defaultCase(theEObject);
return result;
}
case ExprPackage.INTEGER: {
klaper.expr.Integer integer = (klaper.expr.Integer)theEObject;
T result = caseInteger(integer);
if (result == null) result = caseNumber(integer);
if (result == null) result = caseAtom(integer);
if (result == null) result = caseExpression(integer);
if (result == null) result = defaultCase(theEObject);
return result;
}
case ExprPackage.DOUBLE: {
klaper.expr.Double double_ = (klaper.expr.Double)theEObject;
T result = caseDouble(double_);
if (result == null) result = caseNumber(double_);
if (result == null) result = caseAtom(double_);
if (result == null) result = caseExpression(double_);
if (result == null) result = defaultCase(theEObject);
return result;
}
case ExprPackage.UNARY: {
Unary unary = (Unary)theEObject;
T result = caseUnary(unary);
if (result == null) result = caseExpression(unary);
if (result == null) result = defaultCase(theEObject);
return result;
}
case ExprPackage.BINARY: {
Binary binary = (Binary)theEObject;
T result = caseBinary(binary);
if (result == null) result = caseExpression(binary);
if (result == null) result = defaultCase(theEObject);
return result;
}
case ExprPackage.OPERATOR: {
Operator operator = (Operator)theEObject;
T result = caseOperator(operator);
if (result == null) result = defaultCase(theEObject);
return result;
}
case ExprPackage.PLUS: {
Plus plus = (Plus)theEObject;
T result = casePlus(plus);
if (result == null) result = caseOperator(plus);
if (result == null) result = defaultCase(theEObject);
return result;
}
case ExprPackage.MINUS: {
Minus minus = (Minus)theEObject;
T result = caseMinus(minus);
if (result == null) result = caseOperator(minus);
if (result == null) result = defaultCase(theEObject);
return result;
}
case ExprPackage.MULT: {
Mult mult = (Mult)theEObject;
T result = caseMult(mult);
if (result == null) result = caseOperator(mult);
if (result == null) result = defaultCase(theEObject);
return result;
}
case ExprPackage.DIV: {
Div div = (Div)theEObject;
T result = caseDiv(div);
if (result == null) result = caseOperator(div);
if (result == null) result = defaultCase(theEObject);
return result;
}
case ExprPackage.EXP: {
Exp exp = (Exp)theEObject;
T result = caseExp(exp);
if (result == null) result = caseOperator(exp);
if (result == null) result = defaultCase(theEObject);
return result;
}
default: return defaultCase(theEObject);
}
}
/**
* Returns the result of interpreting the object as an instance of '<em>Expression</em>'.
* <!-- begin-user-doc -->
* This implementation returns null;
* returning a non-null result will terminate the switch.
* <!-- end-user-doc -->
* @param object the target of the switch.
* @return the result of interpreting the object as an instance of '<em>Expression</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseExpression(Expression object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Atom</em>'.
* <!-- begin-user-doc -->
* This implementation returns null;
* returning a non-null result will terminate the switch.
* <!-- end-user-doc -->
* @param object the target of the switch.
* @return the result of interpreting the object as an instance of '<em>Atom</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseAtom(Atom object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Number</em>'.
* <!-- begin-user-doc -->
* This implementation returns null;
* returning a non-null result will terminate the switch.
* <!-- end-user-doc -->
* @param object the target of the switch.
* @return the result of interpreting the object as an instance of '<em>Number</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseNumber(klaper.expr.Number object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Variable</em>'.
* <!-- begin-user-doc -->
* This implementation returns null;
* returning a non-null result will terminate the switch.
* <!-- end-user-doc -->
* @param object the target of the switch.
* @return the result of interpreting the object as an instance of '<em>Variable</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseVariable(Variable object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Integer</em>'.
* <!-- begin-user-doc -->
* This implementation returns null;
* returning a non-null result will terminate the switch.
* <!-- end-user-doc -->
* @param object the target of the switch.
* @return the result of interpreting the object as an instance of '<em>Integer</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseInteger(klaper.expr.Integer object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Double</em>'.
* <!-- begin-user-doc -->
* This implementation returns null;
* returning a non-null result will terminate the switch.
* <!-- end-user-doc -->
* @param object the target of the switch.
* @return the result of interpreting the object as an instance of '<em>Double</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseDouble(klaper.expr.Double object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Unary</em>'.
* <!-- begin-user-doc -->
* This implementation returns null;
* returning a non-null result will terminate the switch.
* <!-- end-user-doc -->
* @param object the target of the switch.
* @return the result of interpreting the object as an instance of '<em>Unary</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseUnary(Unary object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Binary</em>'.
* <!-- begin-user-doc -->
* This implementation returns null;
* returning a non-null result will terminate the switch.
* <!-- end-user-doc -->
* @param object the target of the switch.
* @return the result of interpreting the object as an instance of '<em>Binary</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseBinary(Binary object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Operator</em>'.
* <!-- begin-user-doc -->
* This implementation returns null;
* returning a non-null result will terminate the switch.
* <!-- end-user-doc -->
* @param object the target of the switch.
* @return the result of interpreting the object as an instance of '<em>Operator</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseOperator(Operator object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Plus</em>'.
* <!-- begin-user-doc -->
* This implementation returns null;
* returning a non-null result will terminate the switch.
* <!-- end-user-doc -->
* @param object the target of the switch.
* @return the result of interpreting the object as an instance of '<em>Plus</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T casePlus(Plus object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Minus</em>'.
* <!-- begin-user-doc -->
* This implementation returns null;
* returning a non-null result will terminate the switch.
* <!-- end-user-doc -->
* @param object the target of the switch.
* @return the result of interpreting the object as an instance of '<em>Minus</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseMinus(Minus object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Mult</em>'.
* <!-- begin-user-doc -->
* This implementation returns null;
* returning a non-null result will terminate the switch.
* <!-- end-user-doc -->
* @param object the target of the switch.
* @return the result of interpreting the object as an instance of '<em>Mult</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseMult(Mult object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Div</em>'.
* <!-- begin-user-doc -->
* This implementation returns null;
* returning a non-null result will terminate the switch.
* <!-- end-user-doc -->
* @param object the target of the switch.
* @return the result of interpreting the object as an instance of '<em>Div</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseDiv(Div object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Exp</em>'.
* <!-- begin-user-doc -->
* This implementation returns null;
* returning a non-null result will terminate the switch.
* <!-- end-user-doc -->
* @param object the target of the switch.
* @return the result of interpreting the object as an instance of '<em>Exp</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseExp(Exp object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>EObject</em>'.
* <!-- begin-user-doc -->
* This implementation returns null;
* returning a non-null result will terminate the switch, but this is the last case anyway.
* <!-- end-user-doc -->
* @param object the target of the switch.
* @return the result of interpreting the object as an instance of '<em>EObject</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject)
* @generated
*/
public T defaultCase(EObject object) {
return null;
}
} //ExprSwitch
| aciancone/klapersuite | klapersuite.metamodel.klaper/src/klaper/expr/util/ExprSwitch.java | Java | epl-1.0 | 14,296 |
package critterbot.actions;
public class XYThetaAction extends CritterbotAction {
private static final long serialVersionUID = -1434106060178637255L;
private static final int ActionValue = 30;
public static final CritterbotAction NoMove = new XYThetaAction(0, 0, 0);
public static final CritterbotAction TurnLeft = new XYThetaAction(ActionValue, ActionValue, ActionValue);
public static final CritterbotAction TurnRight = new XYThetaAction(ActionValue, ActionValue, -ActionValue);
public static final CritterbotAction Forward = new XYThetaAction(ActionValue, 0, 0);
public static final CritterbotAction Backward = new XYThetaAction(-ActionValue, 0, 0);
public static final CritterbotAction Left = new XYThetaAction(0, -ActionValue, 0);
public static final CritterbotAction Right = new XYThetaAction(0, ActionValue, 0);
public XYThetaAction(double x, double y, double theta) {
super(MotorMode.XYTHETA_SPACE, x, y, theta);
}
public XYThetaAction(double[] actions) {
super(MotorMode.XYTHETA_SPACE, actions);
}
static public CritterbotAction[] sevenActions() {
return new CritterbotAction[] { NoMove, TurnLeft, TurnRight, Forward, Backward, Left, Right };
}
} | amw8/rlpark | rlpark.plugin.critterbot/jvsrc/critterbot/actions/XYThetaAction.java | Java | epl-1.0 | 1,202 |
package mx.com.cinepolis.digital.booking.persistence.dao.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.interceptor.Interceptors;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Join;
import javax.persistence.criteria.Order;
import javax.persistence.criteria.Path;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import mx.com.cinepolis.digital.booking.commons.query.ModelQuery;
import mx.com.cinepolis.digital.booking.commons.query.ScreenQuery;
import mx.com.cinepolis.digital.booking.commons.query.SortOrder;
import mx.com.cinepolis.digital.booking.commons.to.CatalogTO;
import mx.com.cinepolis.digital.booking.commons.to.PagingRequestTO;
import mx.com.cinepolis.digital.booking.commons.to.PagingResponseTO;
import mx.com.cinepolis.digital.booking.commons.to.ScreenTO;
import mx.com.cinepolis.digital.booking.dao.util.CriteriaQueryBuilder;
import mx.com.cinepolis.digital.booking.dao.util.ExceptionHandlerDAOInterceptor;
import mx.com.cinepolis.digital.booking.dao.util.ScreenDOToScreenTOTransformer;
import mx.com.cinepolis.digital.booking.model.CategoryDO;
import mx.com.cinepolis.digital.booking.model.ScreenDO;
import mx.com.cinepolis.digital.booking.model.TheaterDO;
import mx.com.cinepolis.digital.booking.model.utils.AbstractEntityUtils;
import mx.com.cinepolis.digital.booking.persistence.base.dao.AbstractBaseDAO;
import mx.com.cinepolis.digital.booking.persistence.dao.CategoryDAO;
import mx.com.cinepolis.digital.booking.persistence.dao.ScreenDAO;
import org.apache.commons.collections.CollectionUtils;
/**
* Implementation of the interface {@link mx.com.cinepolis.digital.booking.persistence.dao.ScreenDAO}
*
* @author agustin.ramirez
* @since 0.0.1
*/
@Stateless
@Interceptors({ ExceptionHandlerDAOInterceptor.class })
public class ScreenDAOImpl extends AbstractBaseDAO<ScreenDO> implements ScreenDAO
{
/**
* Entity Manager
*/
@PersistenceContext(unitName = "DigitalBookingPU")
private EntityManager em;
@EJB
private CategoryDAO categoryDAO;
/**
* {@inheritDoc}
*/
@Override
protected EntityManager getEntityManager()
{
return em;
}
/**
* Constructor Default
*/
public ScreenDAOImpl()
{
super( ScreenDO.class );
}
/*
* (non-Javadoc)
* @see mx.com.cinepolis.digital.booking.persistence.dao.ScreenDAO#save(mx.com
* .cinepolis.digital.booking.model.to.ScreenTO)
*/
@Override
public void save( ScreenTO screenTO )
{
ScreenDO entity = new ScreenDO();
AbstractEntityUtils.applyElectronicSign( entity, screenTO );
entity.setIdTheater( new TheaterDO( screenTO.getIdTheater() ) );
entity.setIdVista( screenTO.getIdVista() );
entity.setNuCapacity( screenTO.getNuCapacity() );
entity.setNuScreen( screenTO.getNuScreen() );
entity.setCategoryDOList( new ArrayList<CategoryDO>() );
for( CatalogTO catalogTO : screenTO.getSoundFormats() )
{
CategoryDO categorySound = categoryDAO.find( catalogTO.getId().intValue() );
categorySound.getScreenDOList().add( entity );
entity.getCategoryDOList().add( categorySound );
}
for( CatalogTO catalogTO : screenTO.getMovieFormats() )
{
CategoryDO categoryMovieFormat = categoryDAO.find( catalogTO.getId().intValue() );
categoryMovieFormat.getScreenDOList().add( entity );
entity.getCategoryDOList().add( categoryMovieFormat );
}
if( screenTO.getScreenFormat() != null )
{
CategoryDO categoryMovieFormat = categoryDAO.find( screenTO.getScreenFormat().getId().intValue() );
categoryMovieFormat.getScreenDOList().add( entity );
entity.getCategoryDOList().add( categoryMovieFormat );
}
this.create( entity );
this.flush();
screenTO.setId( entity.getIdScreen().longValue() );
}
/*
* (non-Javadoc)
* @see mx.com.cinepolis.digital.booking.persistence.dao.ScreenDAO#update(mx.
* com.cinepolis.digital.booking.model.to.ScreenTO)
*/
@Override
public void update( ScreenTO screenTO )
{
ScreenDO entity = this.find( screenTO.getId().intValue() );
if( entity != null )
{
AbstractEntityUtils.applyElectronicSign( entity, screenTO );
entity.setNuCapacity( screenTO.getNuCapacity() );
entity.setNuScreen( screenTO.getNuScreen() );
entity.setIdVista( screenTO.getIdVista() );
updateCategories( screenTO, entity );
this.edit( entity );
}
}
private void updateCategories( ScreenTO screenTO, ScreenDO entity )
{
List<CatalogTO> categories = new ArrayList<CatalogTO>();
// Limpieza de categorías
for( CategoryDO categoryDO : entity.getCategoryDOList() )
{
categoryDO.getScreenDOList().remove( entity );
this.categoryDAO.edit( categoryDO );
}
entity.setCategoryDOList( new ArrayList<CategoryDO>() );
for( CatalogTO to : screenTO.getMovieFormats() )
{
categories.add( to );
}
for( CatalogTO to : screenTO.getSoundFormats() )
{
categories.add( to );
}
if( screenTO.getScreenFormat() != null )
{
categories.add( screenTO.getScreenFormat() );
}
for( CatalogTO catalogTO : categories )
{
CategoryDO category = this.categoryDAO.find( catalogTO.getId().intValue() );
category.getScreenDOList().add( entity );
entity.getCategoryDOList().add( category );
}
}
/*
* (non-Javadoc)
* @see mx.com.cinepolis.digital.booking.persistence.base.dao.AbstractBaseDAO #remove(java.lang.Object)
*/
@Override
public void remove( ScreenDO screenDO )
{
ScreenDO remove = super.find( screenDO.getIdScreen() );
if( remove != null )
{
AbstractEntityUtils.copyElectronicSign( remove, screenDO );
remove.setFgActive( false );
super.edit( remove );
}
}
/*
* (non-Javadoc)
* @see mx.com.cinepolis.digital.booking.persistence.dao.ScreenDAO#delete(mx.
* com.cinepolis.digital.booking.model.to.ScreenTO)
*/
@Override
public void delete( ScreenTO screenTO )
{
ScreenDO screenDO = new ScreenDO( screenTO.getId().intValue() );
AbstractEntityUtils.applyElectronicSign( screenDO, screenTO );
this.remove( screenDO );
}
/*
* (non-Javadoc)
* @see mx.com.cinepolis.digital.booking.persistence.dao.ScreenDAO#findAllByPaging
* (mx.com.cinepolis.digital.booking.model.to.PagingRequestTO)
*/
@SuppressWarnings("unchecked")
@Override
public PagingResponseTO<ScreenTO> findAllByPaging( PagingRequestTO pagingRequestTO )
{
List<ModelQuery> sortFields = pagingRequestTO.getSort();
SortOrder sortOrder = pagingRequestTO.getSortOrder();
Map<ModelQuery, Object> filters = getFilters( pagingRequestTO );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<ScreenDO> q = cb.createQuery( ScreenDO.class );
Root<ScreenDO> screenDO = q.from( ScreenDO.class );
Join<ScreenDO, TheaterDO> theatherDO = screenDO.join( "idTheater" );
q.select( screenDO );
applySorting( sortFields, sortOrder, cb, q, screenDO, theatherDO );
Predicate filterCondition = applyFilters( filters, cb, screenDO, theatherDO );
CriteriaQuery<Long> queryCountRecords = cb.createQuery( Long.class );
queryCountRecords.select( cb.count( screenDO ) );
if( filterCondition != null )
{
q.where( filterCondition );
queryCountRecords.where( filterCondition );
}
// pagination
TypedQuery<ScreenDO> tq = em.createQuery( q );
int count = em.createQuery( queryCountRecords ).getSingleResult().intValue();
if( pagingRequestTO.getNeedsPaging() )
{
int page = pagingRequestTO.getPage();
int pageSize = pagingRequestTO.getPageSize();
if( pageSize > 0 )
{
tq.setMaxResults( pageSize );
}
if( page >= 0 )
{
tq.setFirstResult( page * pageSize );
}
}
PagingResponseTO<ScreenTO> response = new PagingResponseTO<ScreenTO>();
response.setElements( (List<ScreenTO>) CollectionUtils.collect( tq.getResultList(),
new ScreenDOToScreenTOTransformer( pagingRequestTO.getLanguage() ) ) );
response.setTotalCount( count );
return response;
}
/**
* Aplicamos los filtros
*
* @param filters
* @param cb
* @param screenDO
* @param theaterDO
* @param categoryLanguage
* @return
*/
private Predicate applyFilters( Map<ModelQuery, Object> filters, CriteriaBuilder cb, Root<ScreenDO> screenDO,
Join<ScreenDO, TheaterDO> theaterDO )
{
Predicate filterCondition = null;
if( filters != null && !filters.isEmpty() )
{
filterCondition = cb.conjunction();
filterCondition = CriteriaQueryBuilder.<Integer> applyFilterRootEqual( filters, ScreenQuery.SCREEN_ID, screenDO,
cb, filterCondition );
filterCondition = CriteriaQueryBuilder.<Integer> applyFilterRootEqual( filters, ScreenQuery.SCREEN_NUMBER,
screenDO, cb, filterCondition );
filterCondition = CriteriaQueryBuilder.<Integer> applyFilterRootEqual( filters, ScreenQuery.SCREEN_CAPACITY,
screenDO, cb, filterCondition );
filterCondition = CriteriaQueryBuilder.<Integer> applyFilterJoinEqual( filters, ScreenQuery.SCREEN_THEATER_ID,
theaterDO, cb, filterCondition );
}
return filterCondition;
}
/**
* Metodo que aplica el campo por le cual se ordenaran
*
* @param sortField
* @param sortOrder
* @param cb
* @param q
* @param screenDO
* @param theather
*/
private void applySorting( List<ModelQuery> sortFields, SortOrder sortOrder, CriteriaBuilder cb,
CriteriaQuery<ScreenDO> q, Root<ScreenDO> screenDO, Join<ScreenDO, TheaterDO> theather )
{
if( sortOrder != null && CollectionUtils.isNotEmpty( sortFields ) )
{
List<Order> order = new ArrayList<Order>();
for( ModelQuery sortField : sortFields )
{
if( sortField instanceof ScreenQuery )
{
Path<?> path = null;
switch( (ScreenQuery) sortField )
{
case SCREEN_ID:
path = screenDO.get( sortField.getQuery() );
break;
case SCREEN_NUMBER:
path = screenDO.get( sortField.getQuery() );
break;
case SCREEN_CAPACITY:
path = screenDO.get( sortField.getQuery() );
break;
case SCREEN_THEATER_ID:
path = theather.get( sortField.getQuery() );
break;
default:
path = screenDO.get( ScreenQuery.SCREEN_ID.getQuery() );
}
if( sortOrder.equals( SortOrder.ASCENDING ) )
{
order.add( cb.asc( path ) );
}
else
{
order.add( cb.desc( path ) );
}
}
}
q.orderBy( order );
}
}
/**
* Obtiene los filtros y añade el lenguaje
*
* @param pagingRequestTO
* @return
*/
private Map<ModelQuery, Object> getFilters( PagingRequestTO pagingRequestTO )
{
Map<ModelQuery, Object> filters = pagingRequestTO.getFilters();
if( filters == null )
{
filters = new HashMap<ModelQuery, Object>();
}
return filters;
}
@SuppressWarnings("unchecked")
@Override
public List<ScreenDO> findAllActiveByIdCinema( Integer idTheater )
{
Query q = this.em.createNamedQuery( "ScreenDO.findAllActiveByIdCinema" );
q.setParameter( "idTheater", idTheater );
return q.getResultList();
}
@SuppressWarnings("unchecked")
@Override
public List<ScreenDO> findByIdVistaAndActive( String idVista )
{
Query q = this.em.createNamedQuery( "ScreenDO.findByIdVistaAndActive" );
q.setParameter( "idVista", idVista );
return q.getResultList();
}
}
| sidlors/digital-booking | digital-booking-persistence/src/main/java/mx/com/cinepolis/digital/booking/persistence/dao/impl/ScreenDAOImpl.java | Java | epl-1.0 | 12,056 |
// Compiled by ClojureScript 1.9.946 {}
goog.provide('eckersdorf.window.db');
goog.require('cljs.core');
goog.require('re_frame.core');
eckersdorf.window.db.window_state = new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword("window","height","window/height",1310154766),(0),new cljs.core.Keyword("window","width","window/width",-1138776901),(0)], null);
//# sourceMappingURL=db.js.map?rel=1510703504091
| ribelo/eckersdorf | resources/public/js/out/eckersdorf/window/db.js | JavaScript | epl-1.0 | 417 |
/**
*/
package TaxationWithRoot;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Tax Card</b></em>'.
* <!-- end-user-doc -->
*
* <p>
* The following features are supported:
* </p>
* <ul>
* <li>{@link TaxationWithRoot.Tax_Card#getCard_identifier <em>Card identifier</em>}</li>
* <li>{@link TaxationWithRoot.Tax_Card#getTax_office <em>Tax office</em>}</li>
* <li>{@link TaxationWithRoot.Tax_Card#getPercentage_of_witholding <em>Percentage of witholding</em>}</li>
* <li>{@link TaxationWithRoot.Tax_Card#getTax_payers_name_surname <em>Tax payers name surname</em>}</li>
* <li>{@link TaxationWithRoot.Tax_Card#getTax_payers_partner_name_surname <em>Tax payers partner name surname</em>}</li>
* <li>{@link TaxationWithRoot.Tax_Card#getTax_payers_address <em>Tax payers address</em>}</li>
* <li>{@link TaxationWithRoot.Tax_Card#getJobs_Employer_SSNo <em>Jobs Employer SS No</em>}</li>
* <li>{@link TaxationWithRoot.Tax_Card#getJobs_employers_name <em>Jobs employers name</em>}</li>
* <li>{@link TaxationWithRoot.Tax_Card#getJobs_activity_type <em>Jobs activity type</em>}</li>
* <li>{@link TaxationWithRoot.Tax_Card#getJobs_place_of_work <em>Jobs place of work</em>}</li>
* <li>{@link TaxationWithRoot.Tax_Card#getDeduction_FD_daily <em>Deduction FD daily</em>}</li>
* <li>{@link TaxationWithRoot.Tax_Card#getDeduction_FD_monthly <em>Deduction FD monthly</em>}</li>
* <li>{@link TaxationWithRoot.Tax_Card#getDeduction_AC_daily <em>Deduction AC daily</em>}</li>
* <li>{@link TaxationWithRoot.Tax_Card#getDeduction_AC_monthly <em>Deduction AC monthly</em>}</li>
* <li>{@link TaxationWithRoot.Tax_Card#getDeduction_AC_yearly <em>Deduction AC yearly</em>}</li>
* <li>{@link TaxationWithRoot.Tax_Card#getDeduction_CE_daily <em>Deduction CE daily</em>}</li>
* <li>{@link TaxationWithRoot.Tax_Card#getDeduction_CE_monthly <em>Deduction CE monthly</em>}</li>
* <li>{@link TaxationWithRoot.Tax_Card#getDeduction_CE_yearly <em>Deduction CE yearly</em>}</li>
* <li>{@link TaxationWithRoot.Tax_Card#getDeduction_DS_daily <em>Deduction DS daily</em>}</li>
* <li>{@link TaxationWithRoot.Tax_Card#getDeduction_DS_monthly <em>Deduction DS monthly</em>}</li>
* <li>{@link TaxationWithRoot.Tax_Card#getDeduction_FO_daily <em>Deduction FO daily</em>}</li>
* <li>{@link TaxationWithRoot.Tax_Card#getDeduction_FO_monthly <em>Deduction FO monthly</em>}</li>
* <li>{@link TaxationWithRoot.Tax_Card#getDeduction_FO_yearly <em>Deduction FO yearly</em>}</li>
* <li>{@link TaxationWithRoot.Tax_Card#getCredit_CIS_daily <em>Credit CIS daily</em>}</li>
* <li>{@link TaxationWithRoot.Tax_Card#getCredit_CIS_monthly <em>Credit CIS monthly</em>}</li>
* <li>{@link TaxationWithRoot.Tax_Card#getCredit_CIM_daily <em>Credit CIM daily</em>}</li>
* <li>{@link TaxationWithRoot.Tax_Card#isValidity <em>Validity</em>}</li>
* <li>{@link TaxationWithRoot.Tax_Card#getIncome_Tax_Credit <em>Income Tax Credit</em>}</li>
* <li>{@link TaxationWithRoot.Tax_Card#getPrevious <em>Previous</em>}</li>
* <li>{@link TaxationWithRoot.Tax_Card#getCurrent_tax_card <em>Current tax card</em>}</li>
* <li>{@link TaxationWithRoot.Tax_Card#getCredit_CIM_yearly <em>Credit CIM yearly</em>}</li>
* <li>{@link TaxationWithRoot.Tax_Card#getDeduction_DS_Alimony_yearly <em>Deduction DS Alimony yearly</em>}</li>
* <li>{@link TaxationWithRoot.Tax_Card#getDeduction_DS_Debt_yearly <em>Deduction DS Debt yearly</em>}</li>
* <li>{@link TaxationWithRoot.Tax_Card#getIncome <em>Income</em>}</li>
* </ul>
*
* @see TaxationWithRoot.TaxationWithRootPackage#getTax_Card()
* @model
* @generated
*/
public interface Tax_Card extends EObject {
/**
* Returns the value of the '<em><b>Card identifier</b></em>' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Card identifier</em>' attribute.
* @see #setCard_identifier(String)
* @see TaxationWithRoot.TaxationWithRootPackage#getTax_Card_Card_identifier()
* @model id="true"
* @generated
*/
String getCard_identifier();
/**
* Sets the value of the '{@link TaxationWithRoot.Tax_Card#getCard_identifier <em>Card identifier</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Card identifier</em>' attribute.
* @see #getCard_identifier()
* @generated
*/
void setCard_identifier(String value);
/**
* Returns the value of the '<em><b>Tax office</b></em>' attribute.
* The literals are from the enumeration {@link TaxationWithRoot.Tax_Office}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Tax office</em>' attribute.
* @see TaxationWithRoot.Tax_Office
* @see #setTax_office(Tax_Office)
* @see TaxationWithRoot.TaxationWithRootPackage#getTax_Card_Tax_office()
* @model required="true"
* @generated
*/
Tax_Office getTax_office();
/**
* Sets the value of the '{@link TaxationWithRoot.Tax_Card#getTax_office <em>Tax office</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Tax office</em>' attribute.
* @see TaxationWithRoot.Tax_Office
* @see #getTax_office()
* @generated
*/
void setTax_office(Tax_Office value);
/**
* Returns the value of the '<em><b>Percentage of witholding</b></em>' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Percentage of witholding</em>' attribute.
* @see #setPercentage_of_witholding(double)
* @see TaxationWithRoot.TaxationWithRootPackage#getTax_Card_Percentage_of_witholding()
* @model required="true"
* @generated
*/
double getPercentage_of_witholding();
/**
* Sets the value of the '{@link TaxationWithRoot.Tax_Card#getPercentage_of_witholding <em>Percentage of witholding</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Percentage of witholding</em>' attribute.
* @see #getPercentage_of_witholding()
* @generated
*/
void setPercentage_of_witholding(double value);
/**
* Returns the value of the '<em><b>Tax payers name surname</b></em>' attribute list.
* The list contents are of type {@link java.lang.String}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Tax payers name surname</em>' attribute list.
* @see TaxationWithRoot.TaxationWithRootPackage#getTax_Card_Tax_payers_name_surname()
* @model ordered="false"
* @generated
*/
EList<String> getTax_payers_name_surname();
/**
* Returns the value of the '<em><b>Tax payers partner name surname</b></em>' attribute list.
* The list contents are of type {@link java.lang.String}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Tax payers partner name surname</em>' attribute list.
* @see TaxationWithRoot.TaxationWithRootPackage#getTax_Card_Tax_payers_partner_name_surname()
* @model ordered="false"
* @generated
*/
EList<String> getTax_payers_partner_name_surname();
/**
* Returns the value of the '<em><b>Tax payers address</b></em>' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Tax payers address</em>' reference.
* @see #setTax_payers_address(Address)
* @see TaxationWithRoot.TaxationWithRootPackage#getTax_Card_Tax_payers_address()
* @model
* @generated
*/
Address getTax_payers_address();
/**
* Sets the value of the '{@link TaxationWithRoot.Tax_Card#getTax_payers_address <em>Tax payers address</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Tax payers address</em>' reference.
* @see #getTax_payers_address()
* @generated
*/
void setTax_payers_address(Address value);
/**
* Returns the value of the '<em><b>Jobs Employer SS No</b></em>' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Jobs Employer SS No</em>' attribute.
* @see #setJobs_Employer_SSNo(String)
* @see TaxationWithRoot.TaxationWithRootPackage#getTax_Card_Jobs_Employer_SSNo()
* @model unique="false" ordered="false"
* @generated
*/
String getJobs_Employer_SSNo();
/**
* Sets the value of the '{@link TaxationWithRoot.Tax_Card#getJobs_Employer_SSNo <em>Jobs Employer SS No</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Jobs Employer SS No</em>' attribute.
* @see #getJobs_Employer_SSNo()
* @generated
*/
void setJobs_Employer_SSNo(String value);
/**
* Returns the value of the '<em><b>Jobs employers name</b></em>' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Jobs employers name</em>' attribute.
* @see #setJobs_employers_name(String)
* @see TaxationWithRoot.TaxationWithRootPackage#getTax_Card_Jobs_employers_name()
* @model unique="false" ordered="false"
* @generated
*/
String getJobs_employers_name();
/**
* Sets the value of the '{@link TaxationWithRoot.Tax_Card#getJobs_employers_name <em>Jobs employers name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Jobs employers name</em>' attribute.
* @see #getJobs_employers_name()
* @generated
*/
void setJobs_employers_name(String value);
/**
* Returns the value of the '<em><b>Jobs activity type</b></em>' attribute.
* The literals are from the enumeration {@link TaxationWithRoot.Job_Activity}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Jobs activity type</em>' attribute.
* @see TaxationWithRoot.Job_Activity
* @see #setJobs_activity_type(Job_Activity)
* @see TaxationWithRoot.TaxationWithRootPackage#getTax_Card_Jobs_activity_type()
* @model required="true"
* @generated
*/
Job_Activity getJobs_activity_type();
/**
* Sets the value of the '{@link TaxationWithRoot.Tax_Card#getJobs_activity_type <em>Jobs activity type</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Jobs activity type</em>' attribute.
* @see TaxationWithRoot.Job_Activity
* @see #getJobs_activity_type()
* @generated
*/
void setJobs_activity_type(Job_Activity value);
/**
* Returns the value of the '<em><b>Jobs place of work</b></em>' attribute.
* The literals are from the enumeration {@link TaxationWithRoot.Town}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Jobs place of work</em>' attribute.
* @see TaxationWithRoot.Town
* @see #setJobs_place_of_work(Town)
* @see TaxationWithRoot.TaxationWithRootPackage#getTax_Card_Jobs_place_of_work()
* @model required="true"
* @generated
*/
Town getJobs_place_of_work();
/**
* Sets the value of the '{@link TaxationWithRoot.Tax_Card#getJobs_place_of_work <em>Jobs place of work</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Jobs place of work</em>' attribute.
* @see TaxationWithRoot.Town
* @see #getJobs_place_of_work()
* @generated
*/
void setJobs_place_of_work(Town value);
/**
* Returns the value of the '<em><b>Deduction FD daily</b></em>' attribute.
* The default value is <code>"0.0"</code>.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Deduction FD daily</em>' attribute.
* @see #setDeduction_FD_daily(double)
* @see TaxationWithRoot.TaxationWithRootPackage#getTax_Card_Deduction_FD_daily()
* @model default="0.0" unique="false" required="true" ordered="false"
* @generated
*/
double getDeduction_FD_daily();
/**
* Sets the value of the '{@link TaxationWithRoot.Tax_Card#getDeduction_FD_daily <em>Deduction FD daily</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Deduction FD daily</em>' attribute.
* @see #getDeduction_FD_daily()
* @generated
*/
void setDeduction_FD_daily(double value);
/**
* Returns the value of the '<em><b>Deduction FD monthly</b></em>' attribute.
* The default value is <code>"0.0"</code>.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Deduction FD monthly</em>' attribute.
* @see #setDeduction_FD_monthly(double)
* @see TaxationWithRoot.TaxationWithRootPackage#getTax_Card_Deduction_FD_monthly()
* @model default="0.0" unique="false" required="true" ordered="false"
* @generated
*/
double getDeduction_FD_monthly();
/**
* Sets the value of the '{@link TaxationWithRoot.Tax_Card#getDeduction_FD_monthly <em>Deduction FD monthly</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Deduction FD monthly</em>' attribute.
* @see #getDeduction_FD_monthly()
* @generated
*/
void setDeduction_FD_monthly(double value);
/**
* Returns the value of the '<em><b>Deduction AC daily</b></em>' attribute.
* The default value is <code>"0.0"</code>.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Deduction AC daily</em>' attribute.
* @see #setDeduction_AC_daily(double)
* @see TaxationWithRoot.TaxationWithRootPackage#getTax_Card_Deduction_AC_daily()
* @model default="0.0" unique="false" required="true"
* @generated
*/
double getDeduction_AC_daily();
/**
* Sets the value of the '{@link TaxationWithRoot.Tax_Card#getDeduction_AC_daily <em>Deduction AC daily</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Deduction AC daily</em>' attribute.
* @see #getDeduction_AC_daily()
* @generated
*/
void setDeduction_AC_daily(double value);
/**
* Returns the value of the '<em><b>Deduction AC monthly</b></em>' attribute.
* The default value is <code>"0.0"</code>.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Deduction AC monthly</em>' attribute.
* @see #setDeduction_AC_monthly(double)
* @see TaxationWithRoot.TaxationWithRootPackage#getTax_Card_Deduction_AC_monthly()
* @model default="0.0" unique="false" required="true"
* @generated
*/
double getDeduction_AC_monthly();
/**
* Sets the value of the '{@link TaxationWithRoot.Tax_Card#getDeduction_AC_monthly <em>Deduction AC monthly</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Deduction AC monthly</em>' attribute.
* @see #getDeduction_AC_monthly()
* @generated
*/
void setDeduction_AC_monthly(double value);
/**
* Returns the value of the '<em><b>Deduction AC yearly</b></em>' attribute.
* The default value is <code>"0.0"</code>.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Deduction AC yearly</em>' attribute.
* @see #setDeduction_AC_yearly(double)
* @see TaxationWithRoot.TaxationWithRootPackage#getTax_Card_Deduction_AC_yearly()
* @model default="0.0" unique="false" required="true"
* @generated
*/
double getDeduction_AC_yearly();
/**
* Sets the value of the '{@link TaxationWithRoot.Tax_Card#getDeduction_AC_yearly <em>Deduction AC yearly</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Deduction AC yearly</em>' attribute.
* @see #getDeduction_AC_yearly()
* @generated
*/
void setDeduction_AC_yearly(double value);
/**
* Returns the value of the '<em><b>Deduction CE daily</b></em>' attribute.
* The default value is <code>"0.0"</code>.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Deduction CE daily</em>' attribute.
* @see #setDeduction_CE_daily(double)
* @see TaxationWithRoot.TaxationWithRootPackage#getTax_Card_Deduction_CE_daily()
* @model default="0.0" unique="false" required="true"
* @generated
*/
double getDeduction_CE_daily();
/**
* Sets the value of the '{@link TaxationWithRoot.Tax_Card#getDeduction_CE_daily <em>Deduction CE daily</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Deduction CE daily</em>' attribute.
* @see #getDeduction_CE_daily()
* @generated
*/
void setDeduction_CE_daily(double value);
/**
* Returns the value of the '<em><b>Deduction CE monthly</b></em>' attribute.
* The default value is <code>"0.0"</code>.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Deduction CE monthly</em>' attribute.
* @see #setDeduction_CE_monthly(double)
* @see TaxationWithRoot.TaxationWithRootPackage#getTax_Card_Deduction_CE_monthly()
* @model default="0.0" unique="false" required="true"
* @generated
*/
double getDeduction_CE_monthly();
/**
* Sets the value of the '{@link TaxationWithRoot.Tax_Card#getDeduction_CE_monthly <em>Deduction CE monthly</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Deduction CE monthly</em>' attribute.
* @see #getDeduction_CE_monthly()
* @generated
*/
void setDeduction_CE_monthly(double value);
/**
* Returns the value of the '<em><b>Deduction CE yearly</b></em>' attribute.
* The default value is <code>"0.0"</code>.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Deduction CE yearly</em>' attribute.
* @see #setDeduction_CE_yearly(double)
* @see TaxationWithRoot.TaxationWithRootPackage#getTax_Card_Deduction_CE_yearly()
* @model default="0.0" unique="false" required="true"
* @generated
*/
double getDeduction_CE_yearly();
/**
* Sets the value of the '{@link TaxationWithRoot.Tax_Card#getDeduction_CE_yearly <em>Deduction CE yearly</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Deduction CE yearly</em>' attribute.
* @see #getDeduction_CE_yearly()
* @generated
*/
void setDeduction_CE_yearly(double value);
/**
* Returns the value of the '<em><b>Deduction DS daily</b></em>' attribute.
* The default value is <code>"0.0"</code>.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Deduction DS daily</em>' attribute.
* @see #setDeduction_DS_daily(double)
* @see TaxationWithRoot.TaxationWithRootPackage#getTax_Card_Deduction_DS_daily()
* @model default="0.0" unique="false" required="true"
* @generated
*/
double getDeduction_DS_daily();
/**
* Sets the value of the '{@link TaxationWithRoot.Tax_Card#getDeduction_DS_daily <em>Deduction DS daily</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Deduction DS daily</em>' attribute.
* @see #getDeduction_DS_daily()
* @generated
*/
void setDeduction_DS_daily(double value);
/**
* Returns the value of the '<em><b>Deduction DS monthly</b></em>' attribute.
* The default value is <code>"0.0"</code>.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Deduction DS monthly</em>' attribute.
* @see #setDeduction_DS_monthly(double)
* @see TaxationWithRoot.TaxationWithRootPackage#getTax_Card_Deduction_DS_monthly()
* @model default="0.0" required="true"
* @generated
*/
double getDeduction_DS_monthly();
/**
* Sets the value of the '{@link TaxationWithRoot.Tax_Card#getDeduction_DS_monthly <em>Deduction DS monthly</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Deduction DS monthly</em>' attribute.
* @see #getDeduction_DS_monthly()
* @generated
*/
void setDeduction_DS_monthly(double value);
/**
* Returns the value of the '<em><b>Deduction FO daily</b></em>' attribute.
* The default value is <code>"0.0"</code>.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Deduction FO daily</em>' attribute.
* @see #setDeduction_FO_daily(double)
* @see TaxationWithRoot.TaxationWithRootPackage#getTax_Card_Deduction_FO_daily()
* @model default="0.0" unique="false" required="true"
* @generated
*/
double getDeduction_FO_daily();
/**
* Sets the value of the '{@link TaxationWithRoot.Tax_Card#getDeduction_FO_daily <em>Deduction FO daily</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Deduction FO daily</em>' attribute.
* @see #getDeduction_FO_daily()
* @generated
*/
void setDeduction_FO_daily(double value);
/**
* Returns the value of the '<em><b>Deduction FO monthly</b></em>' attribute.
* The default value is <code>"0.0"</code>.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Deduction FO monthly</em>' attribute.
* @see #setDeduction_FO_monthly(double)
* @see TaxationWithRoot.TaxationWithRootPackage#getTax_Card_Deduction_FO_monthly()
* @model default="0.0" unique="false" required="true"
* @generated
*/
double getDeduction_FO_monthly();
/**
* Sets the value of the '{@link TaxationWithRoot.Tax_Card#getDeduction_FO_monthly <em>Deduction FO monthly</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Deduction FO monthly</em>' attribute.
* @see #getDeduction_FO_monthly()
* @generated
*/
void setDeduction_FO_monthly(double value);
/**
* Returns the value of the '<em><b>Deduction FO yearly</b></em>' attribute.
* The default value is <code>"0.0"</code>.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Deduction FO yearly</em>' attribute.
* @see #setDeduction_FO_yearly(double)
* @see TaxationWithRoot.TaxationWithRootPackage#getTax_Card_Deduction_FO_yearly()
* @model default="0.0" unique="false" required="true"
* @generated
*/
double getDeduction_FO_yearly();
/**
* Sets the value of the '{@link TaxationWithRoot.Tax_Card#getDeduction_FO_yearly <em>Deduction FO yearly</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Deduction FO yearly</em>' attribute.
* @see #getDeduction_FO_yearly()
* @generated
*/
void setDeduction_FO_yearly(double value);
/**
* Returns the value of the '<em><b>Credit CIS daily</b></em>' attribute.
* The default value is <code>"0.0"</code>.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Credit CIS daily</em>' attribute.
* @see #setCredit_CIS_daily(double)
* @see TaxationWithRoot.TaxationWithRootPackage#getTax_Card_Credit_CIS_daily()
* @model default="0.0" unique="false" required="true"
* @generated
*/
double getCredit_CIS_daily();
/**
* Sets the value of the '{@link TaxationWithRoot.Tax_Card#getCredit_CIS_daily <em>Credit CIS daily</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Credit CIS daily</em>' attribute.
* @see #getCredit_CIS_daily()
* @generated
*/
void setCredit_CIS_daily(double value);
/**
* Returns the value of the '<em><b>Credit CIS monthly</b></em>' attribute.
* The default value is <code>"0.0"</code>.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Credit CIS monthly</em>' attribute.
* @see #setCredit_CIS_monthly(double)
* @see TaxationWithRoot.TaxationWithRootPackage#getTax_Card_Credit_CIS_monthly()
* @model default="0.0" unique="false" required="true"
* @generated
*/
double getCredit_CIS_monthly();
/**
* Sets the value of the '{@link TaxationWithRoot.Tax_Card#getCredit_CIS_monthly <em>Credit CIS monthly</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Credit CIS monthly</em>' attribute.
* @see #getCredit_CIS_monthly()
* @generated
*/
void setCredit_CIS_monthly(double value);
/**
* Returns the value of the '<em><b>Credit CIM daily</b></em>' attribute.
* The default value is <code>"0.0"</code>.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Credit CIM daily</em>' attribute.
* @see #setCredit_CIM_daily(double)
* @see TaxationWithRoot.TaxationWithRootPackage#getTax_Card_Credit_CIM_daily()
* @model default="0.0" unique="false" required="true"
* @generated
*/
double getCredit_CIM_daily();
/**
* Sets the value of the '{@link TaxationWithRoot.Tax_Card#getCredit_CIM_daily <em>Credit CIM daily</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Credit CIM daily</em>' attribute.
* @see #getCredit_CIM_daily()
* @generated
*/
void setCredit_CIM_daily(double value);
/**
* Returns the value of the '<em><b>Validity</b></em>' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Validity</em>' attribute.
* @see #setValidity(boolean)
* @see TaxationWithRoot.TaxationWithRootPackage#getTax_Card_Validity()
* @model required="true"
* @generated
*/
boolean isValidity();
/**
* Sets the value of the '{@link TaxationWithRoot.Tax_Card#isValidity <em>Validity</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Validity</em>' attribute.
* @see #isValidity()
* @generated
*/
void setValidity(boolean value);
/**
* Returns the value of the '<em><b>Income Tax Credit</b></em>' reference list.
* The list contents are of type {@link TaxationWithRoot.Income_Tax_Credit}.
* It is bidirectional and its opposite is '{@link TaxationWithRoot.Income_Tax_Credit#getTaxation_Frame <em>Taxation Frame</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Income Tax Credit</em>' reference list.
* @see TaxationWithRoot.TaxationWithRootPackage#getTax_Card_Income_Tax_Credit()
* @see TaxationWithRoot.Income_Tax_Credit#getTaxation_Frame
* @model opposite="taxation_Frame" ordered="false"
* @generated
*/
EList<Income_Tax_Credit> getIncome_Tax_Credit();
/**
* Returns the value of the '<em><b>Previous</b></em>' reference.
* It is bidirectional and its opposite is '{@link TaxationWithRoot.Tax_Card#getCurrent_tax_card <em>Current tax card</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Previous</em>' reference.
* @see #setPrevious(Tax_Card)
* @see TaxationWithRoot.TaxationWithRootPackage#getTax_Card_Previous()
* @see TaxationWithRoot.Tax_Card#getCurrent_tax_card
* @model opposite="current_tax_card"
* @generated
*/
Tax_Card getPrevious();
/**
* Sets the value of the '{@link TaxationWithRoot.Tax_Card#getPrevious <em>Previous</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Previous</em>' reference.
* @see #getPrevious()
* @generated
*/
void setPrevious(Tax_Card value);
/**
* Returns the value of the '<em><b>Current tax card</b></em>' reference.
* It is bidirectional and its opposite is '{@link TaxationWithRoot.Tax_Card#getPrevious <em>Previous</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Current tax card</em>' reference.
* @see #setCurrent_tax_card(Tax_Card)
* @see TaxationWithRoot.TaxationWithRootPackage#getTax_Card_Current_tax_card()
* @see TaxationWithRoot.Tax_Card#getPrevious
* @model opposite="previous"
* @generated
*/
Tax_Card getCurrent_tax_card();
/**
* Sets the value of the '{@link TaxationWithRoot.Tax_Card#getCurrent_tax_card <em>Current tax card</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Current tax card</em>' reference.
* @see #getCurrent_tax_card()
* @generated
*/
void setCurrent_tax_card(Tax_Card value);
/**
* Returns the value of the '<em><b>Credit CIM yearly</b></em>' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Credit CIM yearly</em>' attribute.
* @see #setCredit_CIM_yearly(double)
* @see TaxationWithRoot.TaxationWithRootPackage#getTax_Card_Credit_CIM_yearly()
* @model required="true" ordered="false"
* @generated
*/
double getCredit_CIM_yearly();
/**
* Sets the value of the '{@link TaxationWithRoot.Tax_Card#getCredit_CIM_yearly <em>Credit CIM yearly</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Credit CIM yearly</em>' attribute.
* @see #getCredit_CIM_yearly()
* @generated
*/
void setCredit_CIM_yearly(double value);
/**
* Returns the value of the '<em><b>Deduction DS Alimony yearly</b></em>' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Deduction DS Alimony yearly</em>' attribute.
* @see #setDeduction_DS_Alimony_yearly(double)
* @see TaxationWithRoot.TaxationWithRootPackage#getTax_Card_Deduction_DS_Alimony_yearly()
* @model required="true" ordered="false"
* @generated
*/
double getDeduction_DS_Alimony_yearly();
/**
* Sets the value of the '{@link TaxationWithRoot.Tax_Card#getDeduction_DS_Alimony_yearly <em>Deduction DS Alimony yearly</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Deduction DS Alimony yearly</em>' attribute.
* @see #getDeduction_DS_Alimony_yearly()
* @generated
*/
void setDeduction_DS_Alimony_yearly(double value);
/**
* Returns the value of the '<em><b>Deduction DS Debt yearly</b></em>' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Deduction DS Debt yearly</em>' attribute.
* @see #setDeduction_DS_Debt_yearly(double)
* @see TaxationWithRoot.TaxationWithRootPackage#getTax_Card_Deduction_DS_Debt_yearly()
* @model required="true" ordered="false"
* @generated
*/
double getDeduction_DS_Debt_yearly();
/**
* Sets the value of the '{@link TaxationWithRoot.Tax_Card#getDeduction_DS_Debt_yearly <em>Deduction DS Debt yearly</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Deduction DS Debt yearly</em>' attribute.
* @see #getDeduction_DS_Debt_yearly()
* @generated
*/
void setDeduction_DS_Debt_yearly(double value);
/**
* Returns the value of the '<em><b>Income</b></em>' container reference.
* It is bidirectional and its opposite is '{@link TaxationWithRoot.Income#getTax_card <em>Tax card</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Income</em>' container reference.
* @see #setIncome(Income)
* @see TaxationWithRoot.TaxationWithRootPackage#getTax_Card_Income()
* @see TaxationWithRoot.Income#getTax_card
* @model opposite="tax_card" required="true" transient="false"
* @generated
*/
Income getIncome();
/**
* Sets the value of the '{@link TaxationWithRoot.Tax_Card#getIncome <em>Income</em>}' container reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Income</em>' container reference.
* @see #getIncome()
* @generated
*/
void setIncome(Income value);
} // Tax_Card
| viatra/VIATRA-Generator | Tests/MODELS2020-CaseStudies/models20.diversity-calculator/src/TaxationWithRoot/Tax_Card.java | Java | epl-1.0 | 32,297 |
/*
* Sonatype Nexus (TM) Open Source Version
* Copyright (c) 2008-present Sonatype, Inc.
* All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
*
* This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
* which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
*
* Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
* of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
* Eclipse Foundation. All other trademarks are the property of their respective owners.
*/
@FeatureFlag(name = ORIENT_ENABLED)
package org.sonatype.nexus.repository.maven.internal.orient;
import org.sonatype.nexus.common.app.FeatureFlag;
import static org.sonatype.nexus.common.app.FeatureFlags.ORIENT_ENABLED;
| sonatype/nexus-public | plugins/nexus-repository-maven/src/main/java/org/sonatype/nexus/repository/maven/internal/orient/package-info.java | Java | epl-1.0 | 1,002 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<title>Uses of Class org.apache.poi.ss.formula.functions.LogicalFunction (POI API Documentation)</title>
<link rel="stylesheet" type="text/css" href="../../../../../../../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Uses of Class org.apache.poi.ss.formula.functions.LogicalFunction (POI API Documentation)";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!-- -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../../../overview-summary.html">Overview</a></li>
<li><a href="../package-summary.html">Package</a></li>
<li><a href="../../../../../../../org/apache/poi/ss/formula/functions/LogicalFunction.html" title="class in org.apache.poi.ss.formula.functions">Class</a></li>
<li class="navBarCell1Rev">Use</li>
<li><a href="../package-tree.html">Tree</a></li>
<li><a href="../../../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="../../../../../../../index.html?org/apache/poi/ss/formula/functions/class-use/LogicalFunction.html" target="_top">Frames</a></li>
<li><a href="LogicalFunction.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip-navbar_top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="header">
<h2 title="Uses of Class org.apache.poi.ss.formula.functions.LogicalFunction" class="title">Uses of Class<br>org.apache.poi.ss.formula.functions.LogicalFunction</h2>
</div>
<div class="classUseContainer">No usage of org.apache.poi.ss.formula.functions.LogicalFunction</div>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!-- -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../../../overview-summary.html">Overview</a></li>
<li><a href="../package-summary.html">Package</a></li>
<li><a href="../../../../../../../org/apache/poi/ss/formula/functions/LogicalFunction.html" title="class in org.apache.poi.ss.formula.functions">Class</a></li>
<li class="navBarCell1Rev">Use</li>
<li><a href="../package-tree.html">Tree</a></li>
<li><a href="../../../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="../../../../../../../index.html?org/apache/poi/ss/formula/functions/class-use/LogicalFunction.html" target="_top">Frames</a></li>
<li><a href="LogicalFunction.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip-navbar_bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small>
<i>Copyright 2016 The Apache Software Foundation or
its licensors, as applicable.</i>
</small></p>
</body>
</html>
| tommylsh/test20170719 | Desktop/tool/poi-bin-3.15-20160924/poi-3.15/docs/apidocs/org/apache/poi/ss/formula/functions/class-use/LogicalFunction.html | HTML | epl-1.0 | 4,467 |
/*******************************************************************************
* Copyright (c) 2010, 2012 Tasktop Technologies
* Copyright (c) 2010, 2011 SpringSource, a division of VMware
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Tasktop Technologies - initial API and implementation
******************************************************************************/
package com.tasktop.c2c.server.profile.web.ui.client.place;
import java.util.Arrays;
import java.util.List;
import com.tasktop.c2c.server.common.profile.web.client.navigation.AbstractPlaceTokenizer;
import com.tasktop.c2c.server.common.profile.web.client.navigation.PageMapping;
import com.tasktop.c2c.server.common.profile.web.client.place.Breadcrumb;
import com.tasktop.c2c.server.common.profile.web.client.place.BreadcrumbPlace;
import com.tasktop.c2c.server.common.profile.web.client.place.HeadingPlace;
import com.tasktop.c2c.server.common.profile.web.client.place.LoggedInPlace;
import com.tasktop.c2c.server.common.profile.web.client.place.WindowTitlePlace;
import com.tasktop.c2c.server.common.profile.web.client.util.WindowTitleBuilder;
import com.tasktop.c2c.server.common.profile.web.shared.actions.GetSshPublicKeysAction;
import com.tasktop.c2c.server.common.profile.web.shared.actions.GetSshPublicKeysResult;
import com.tasktop.c2c.server.profile.domain.project.Profile;
import com.tasktop.c2c.server.profile.domain.project.SshPublicKey;
import com.tasktop.c2c.server.profile.web.ui.client.gin.AppGinjector;
public class UserAccountPlace extends LoggedInPlace implements HeadingPlace, WindowTitlePlace, BreadcrumbPlace {
public static PageMapping Account = new PageMapping(new UserAccountPlace.Tokenizer(), "account");
@Override
public String getHeading() {
return "Account Settings";
}
private static class Tokenizer extends AbstractPlaceTokenizer<UserAccountPlace> {
@Override
public UserAccountPlace getPlace(String token) {
return UserAccountPlace.createPlace();
}
}
private Profile profile;
private List<SshPublicKey> sshPublicKeys;
public static UserAccountPlace createPlace() {
return new UserAccountPlace();
}
private UserAccountPlace() {
}
public Profile getProfile() {
return profile;
}
public List<SshPublicKey> getSshPublicKeys() {
return sshPublicKeys;
}
@Override
public String getPrefix() {
return Account.getUrl();
}
@Override
protected void addActions() {
super.addActions();
addAction(new GetSshPublicKeysAction());
}
@Override
protected void handleBatchResults() {
super.handleBatchResults();
profile = AppGinjector.get.instance().getAppState().getCredentials().getProfile();
sshPublicKeys = getResult(GetSshPublicKeysResult.class).get();
onPlaceDataFetched();
}
@Override
public String getWindowTitle() {
return WindowTitleBuilder.createWindowTitle("Account Settings");
}
@Override
public List<Breadcrumb> getBreadcrumbs() {
return Arrays.asList(new Breadcrumb("", "Projects"), new Breadcrumb(getHref(), "Account"));
}
}
| Tasktop/code2cloud.server | com.tasktop.c2c.server/com.tasktop.c2c.server.profile.web.ui/src/main/java/com/tasktop/c2c/server/profile/web/ui/client/place/UserAccountPlace.java | Java | epl-1.0 | 3,244 |
package com.openMap1.mapper.converters;
import java.util.Iterator;
import org.eclipse.emf.common.util.EList;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import com.openMap1.mapper.ElementDef;
import com.openMap1.mapper.MappedStructure;
import com.openMap1.mapper.core.MapperException;
import com.openMap1.mapper.structures.MapperWrapper;
import com.openMap1.mapper.util.XMLUtil;
import com.openMap1.mapper.util.XSLOutputFile;
import com.openMap1.mapper.writer.TemplateFilter;
public class FACEWrapper extends AbstractMapperWrapper implements MapperWrapper{
public static String FACE_PREFIX = "face";
public static String FACE_URI = "http://schemas.facecode.com/webservices/2010/01/";
//----------------------------------------------------------------------------------------
// Constructor and initialisation from the Ecore model
//----------------------------------------------------------------------------------------
public FACEWrapper(MappedStructure ms, Object spare) throws MapperException
{
super(ms,spare);
}
/**
* @return the file extension of the outer document, with initial '*.'
*/
public String fileExtension() {return ("*.xml");}
/**
* @return the type of document transformed to and from;
* see static constants in class AbstractMapperWrapper.
*/
public int transformType() {return AbstractMapperWrapper.XML_TYPE;}
//----------------------------------------------------------------------------------------
// In-wrapper transform
//----------------------------------------------------------------------------------------
@Override
public Document transformIn(Object incoming) throws MapperException
{
if (!(incoming instanceof Element)) throw new MapperException("Document root is not an Element");
Element mappingRoot = (Element)incoming;
String mappingRootPath = "/GetIndicativeBudget";
inResultDoc = XMLUtil.makeOutDoc();
Element inRoot = scanDocument(mappingRoot, mappingRootPath, AbstractMapperWrapper.IN_TRANSFORM);
inResultDoc.appendChild(inRoot);
return inResultDoc;
}
/**
* default behaviour is a shallow copy - copying the element name, attributes,
* and text content only if the element has no child elements.
* to be overridden for specific paths in implementing classes
*/
protected Element inTransformNode(Element el, String path) throws MapperException
{
// copy the element with namespaces, prefixed tag name, attributes but no text or child Elements
Element copy = (Element)inResultDoc.importNode(el, false);
// convert <FaceCompletedItem> elements to specific types of item
if (XMLUtil.getLocalName(el).equals("FaceCompletedItem"))
{
String questionCode = getPathValue(el,"QuestionId");
String newName = "FaceCompletedItem_" + questionCode;
copy = renameElement(el, newName, true);
}
// if the source element has no child elements but has text, copy the text
String text = textOnly(el);
if (!text.equals("")) copy.appendChild(inResultDoc.createTextNode(text));
return copy;
}
//----------------------------------------------------------------------------------------
// Out-wrapper transform
//----------------------------------------------------------------------------------------
@Override
public Object transformOut(Element outgoing) throws MapperException
{
String mappingRootPath = "/Envelope";
outResultDoc = XMLUtil.makeOutDoc();
Element outRoot = scanDocument(outgoing, mappingRootPath, AbstractMapperWrapper.OUT_TRANSFORM);
outResultDoc.appendChild(outRoot);
return outResultDoc;
}
/**
* default behaviour is a shallow copy - copying the element name, attributes,
* and text content only if the element has no child elements.
* to be overridden for specific paths in implementing classes
*/
protected Element outTransformNode(Element el, String path) throws MapperException
{
// copy the element with namespaces, prefixed tag name, attributes but no text or child Elements
Element copy = (Element)outResultDoc.importNode(el, false);
// convert specific types of <FaceCompletedItem_XX> back to plain <FACECompletedItem>
if (XMLUtil.getLocalName(el).startsWith("FaceCompletedItem"))
{
copy = renameElement(el,"FaceCompletedItem",false);
}
// if the source element has no child elements but has text, copy the text
String text = textOnly(el);
if (!text.equals("")) copy.appendChild(outResultDoc.createTextNode(text));
return copy;
}
/**
* copy an element and all its attributes to the new document, renaming it
* and putting it in no namespace.
* @param el
* @param newName
* @param isIn true for the in-transform, false for the out-transform
* @return
* @throws MapperException
*/
protected Element renameElement(Element el, String newName, boolean isIn) throws MapperException
{
Element newEl = null;
if (isIn) newEl = inResultDoc.createElementNS(FACE_URI, newName);
else if (!isIn) newEl = outResultDoc.createElementNS(FACE_URI, newName);
// set all attributes of the constrained element, including namespace attributes
for (int a = 0; a < el.getAttributes().getLength();a++)
{
Attr at = (Attr)el.getAttributes().item(a);
newEl.setAttribute(at.getName(), at.getValue());
}
return newEl;
}
//--------------------------------------------------------------------------------------------------------------
// XSLT Wrapper Transforms
//--------------------------------------------------------------------------------------------------------------
/**
* @param xout XSLT output being made
* @param templateFilter a filter on the templates, implemented by XSLGeneratorImpl
* append the templates and variables to be included in the XSL
* to do the full transformation, to apply the wrapper transform in the 'in' direction.
* Templates must have mode = "inWrapper"
*/
public void addWrapperInTemplates(XSLOutputFile xout, TemplateFilter templateFilter) throws MapperException
{
// see class AbstractMapperWrapper - adds a plain identity template
super.addWrapperInTemplates(xout, templateFilter);
// add the FACE namespace
xout.topOut().setAttribute("xmlns:" + FACE_PREFIX, FACE_URI);
for (Iterator<ElementDef> it = findFACEItemsElementDefs(ms()).iterator();it.hasNext();)
{
ElementDef FACEItem = it.next();
String tagName = FACEItem.getName();
if (tagName.startsWith("FaceCompletedItem_"))
{
String questionId = tagName.substring("FaceCompletedItem_".length());
addInTemplate(xout,tagName,questionId);
}
}
}
/**
* @param xout XSLT output being made
* @param templateFilter a filter on the templates to be included, implemented by XSLGeneratorImpl
* append the templates and variables to be included in the XSL
* to do the full transformation, to apply the wrapper transform in the 'out' direction.
* Templates must have mode = "outWrapper"
* @throws MapperException
*/
public void addWrapperOutTemplates(XSLOutputFile xout, TemplateFilter templateFilter) throws MapperException
{
// see class AbstractMapperWrapper - adds a plain identity template
super.addWrapperOutTemplates(xout, templateFilter);
// add the FACE namespace
xout.topOut().setAttribute("xmlns:" + FACE_PREFIX, FACE_URI);
for (Iterator<ElementDef> it = findFACEItemsElementDefs(ms()).iterator();it.hasNext();)
{
ElementDef FACEItem = it.next();
String tagName = FACEItem.getName();
if (tagName.startsWith("FaceCompletedItem_"))
{
String questionId = tagName.substring("FaceCompletedItem_".length());
addOutTemplate(xout,tagName,questionId);
}
}
}
/**
* add an in-wrapper template of the form
<xsl:template match="face:FaceCompletedItem[face:QuestionId='F14_14_46_11_15_33T61_38']" mode="inWrapper">
<face:FaceCompletedItem_F14_14_46_11_15_33T61_38>
<xsl:copy-of select="@*"/>
<xsl:apply-templates mode="inWrapper"/>
</face:FaceCompletedItem_F14_14_46_11_15_33T61_38>
</xsl:template>
* @param xout
* @param tagName
* @param questionId
*/
private void addInTemplate(XSLOutputFile xout,String tagName,String questionId) throws MapperException
{
Element tempEl = xout.XSLElement("template");
tempEl.setAttribute("match", FACE_PREFIX + ":FaceCompletedItem[" + FACE_PREFIX + ":QuestionId='" + questionId + "']");
tempEl.setAttribute("mode", "inWrapper");
Element FACEEl = xout.NSElement(FACE_PREFIX, tagName, FACE_URI);
tempEl.appendChild(FACEEl);
addApplyChildren(xout,FACEEl,"inWrapper");
xout.topOut().appendChild(tempEl);
}
/**
* add an out-wrapper template of the form
<xsl:template match="face:FaceCompletedItem_F14_14_46_11_15_33T61_38" mode="outWrapper">
<face:FaceCompletedItem>
<xsl:copy-of select="@*"/>
<xsl:apply-templates mode="outWrapper"/>
</face:FaceCompletedItem>
</xsl:template>
* @param xout
* @param tagName
* @param questionId
*/
private void addOutTemplate(XSLOutputFile xout,String tagName,String questionId) throws MapperException
{
Element tempEl = xout.XSLElement("template");
tempEl.setAttribute("match", FACE_PREFIX + ":" + tagName);
tempEl.setAttribute("mode", "outWrapper");
Element FACEEl = xout.NSElement(FACE_PREFIX, "FaceCompletedItem", FACE_URI);
tempEl.appendChild(FACEEl);
addApplyChildren(xout,FACEEl,"outWrapper");
xout.topOut().appendChild(tempEl);
}
/**
* add two child nodes to a template to carry on copying down the tree
* @param xout
* @param FACEEl
* @param mode
* @throws MapperException
*/
private void addApplyChildren(XSLOutputFile xout,Element FACEEl, String mode) throws MapperException
{
Element copyOfEl = xout.XSLElement("copy-of");
copyOfEl.setAttribute("select", "@*");
FACEEl.appendChild(copyOfEl);
Element applyEl = xout.XSLElement("apply-templates");
applyEl.setAttribute("mode", mode);
FACEEl.appendChild(applyEl);
}
/**
*
* @param mappedStructure
* @return a lit of nodes in the mapping set which are children of the 'Items' node
* @throws MapperException
*/
public static EList<ElementDef> findFACEItemsElementDefs(MappedStructure mappedStructure) throws MapperException
{
ElementDef msRoot = mappedStructure.getRootElement();
if (msRoot == null) throw new MapperException("No root element in mapping set");
if (!msRoot.getName().equals("GetIndicativeBudget"))
throw new MapperException("Root Element of mapping set must be called 'GetIndicativeBudget'");
// there must be a chain of child ElementDefs with the names below; throw an exception if not
ElementDef payload = findChildElementDef(msRoot,"payload");
ElementDef items = findChildElementDef(payload,"Items");
return items.getChildElements();
}
/**
*
* @param parent
* @param childName
* @return the child ElementDef with given name
* @throws MapperException if it does not exist
*/
private static ElementDef findChildElementDef(ElementDef parent, String childName) throws MapperException
{
ElementDef child = parent.getNamedChildElement(childName);
if (child == null) throw new MapperException("Mapping set node '" + parent.getName() + "' has no child '" + childName + "'");
return child;
}
}
| openmapsoftware/mappingtools | openmap-mapper-lib/src/main/java/com/openMap1/mapper/converters/FACEWrapper.java | Java | epl-1.0 | 11,744 |
package org.matmaul.freeboxos.ftp;
import org.matmaul.freeboxos.internal.Response;
public class FtpResponse {
public static class FtpConfigResponse extends Response<FtpConfig> {}
}
| MatMaul/freeboxos-java | src/org/matmaul/freeboxos/ftp/FtpResponse.java | Java | epl-1.0 | 184 |
/* ==========================================
* JGraphT : a free Java graph-theory library
* ==========================================
*
* Project Info: http://jgrapht.sourceforge.net/
* Project Creator: Barak Naveh (http://sourceforge.net/users/barak_naveh)
*
* (C) Copyright 2003-2008, by Barak Naveh and Contributors.
*
* This program and the accompanying materials are dual-licensed under
* either
*
* (a) the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation, or (at your option) any
* later version.
*
* or (per the licensee's choosing)
*
* (b) the terms of the Eclipse Public License v1.0 as published by
* the Eclipse Foundation.
*/
/* -----------------
* Specifics.java
* -----------------
* (C) Copyright 2015-2015, by Barak Naveh and Contributors.
*
* Original Author: Barak Naveh
* Contributor(s):
*
* $Id$
*
* Changes
* -------
*/
package org.jgrapht.graph.specifics;
import java.io.Serializable;
import java.util.Set;
/**
* .
*
* @author Barak Naveh
*/
public abstract class Specifics<V, E>
implements Serializable
{
private static final long serialVersionUID = 785196247314761183L;
public abstract void addVertex(V vertex);
public abstract Set<V> getVertexSet();
/**
* .
*
* @param sourceVertex
* @param targetVertex
*
* @return
*/
public abstract Set<E> getAllEdges(V sourceVertex,
V targetVertex);
/**
* .
*
* @param sourceVertex
* @param targetVertex
*
* @return
*/
public abstract E getEdge(V sourceVertex, V targetVertex);
/**
* Adds the specified edge to the edge containers of its source and
* target vertices.
*
* @param e
*/
public abstract void addEdgeToTouchingVertices(E e);
/**
* .
*
* @param vertex
*
* @return
*/
public abstract int degreeOf(V vertex);
/**
* .
*
* @param vertex
*
* @return
*/
public abstract Set<E> edgesOf(V vertex);
/**
* .
*
* @param vertex
*
* @return
*/
public abstract int inDegreeOf(V vertex);
/**
* .
*
* @param vertex
*
* @return
*/
public abstract Set<E> incomingEdgesOf(V vertex);
/**
* .
*
* @param vertex
*
* @return
*/
public abstract int outDegreeOf(V vertex);
/**
* .
*
* @param vertex
*
* @return
*/
public abstract Set<E> outgoingEdgesOf(V vertex);
/**
* Removes the specified edge from the edge containers of its source and
* target vertices.
*
* @param e
*/
public abstract void removeEdgeFromTouchingVertices(E e);
}
| arcanefoam/jgrapht | jgrapht-core/src/main/java/org/jgrapht/graph/specifics/Specifics.java | Java | epl-1.0 | 2,800 |
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
public class FileLogger extends MyLoggerImpl {
private String fileName;
public FileLogger(String fileName) {
super();
this.fileName = fileName;
}
@Override
public void log(int level, String message) throws ErrorIntegerLevelException {
super.log(level, message);
try {
File file = new File(fileName);
FileWriter fw = new FileWriter(file.getAbsoluteFile(), true);
BufferedWriter bw = new BufferedWriter(fw);
if(file.length() > 0) {
bw.write("\n"+ getLogMessage());
} else {
bw.write(getLogMessage());
}
bw.close();
} catch (IOException e) {
System.err.println("This file doesn`t exist!");
}
}
public static void main(String[] argv) {
MyLogger consoleLogger = new FileLogger("test.txt");
try {
consoleLogger.log(1, "Hello world!");
consoleLogger.log(2, "The application`s digital signature has error!");
consoleLogger.log(3, "Checking file system on C!");
consoleLogger.log(4, "Error level!");
} catch (ErrorIntegerLevelException e) {
System.err.println("Error level! It must be 1, 2 or 3");
}
}
}
| irin4eto/HackBulgaria_JavaScript | Candidacy/SimpleLogger/src/FileLogger.java | Java | gpl-2.0 | 1,200 |
/**
* Created by Paul on 24/01/2015.
*/
var install_url = $("#install_url").val();
$("#updateCase").click(function () {
var case_id = $('#case_id').val();
var case_priority = $('#case_priority').val();
var case_status = $('#case_status').val();
var case_type = $('#case_type').val();
var assignedTo = $('#assignedTo').val();
var case_subject = $('#case_subject').val();
var case_description = $('#case_description').val();
var case_resolution = $('#case_resolution').val();
$.ajax({
url: install_url + '/web/front.php/tickets/update_case_ajax',
type: 'POST',
data: "id=" + case_id + "&case_priority=" + case_priority +
"&case_status=" + case_status + "&case_type=" + case_type + "&assignedTo=" + assignedTo + "&case_subject=" + case_subject
+ "&case_description=" + case_description + "&case_resolution=" + case_resolution,
dataType: 'json',
success: function (data) {
if (data.error == "no") {
toastr.options = {
"closeButton": true,
"showDuration": 3
};
toastr['success']('MyCRM', "Case updated");
} else {
toastr.options = {
"closeButton": true,
"showDuration": 3
};
toastr['error']('MyCRM', "Error while updating case");
}
},
error: function (data) {
toastr.options = {
"closeButton": true,
"showDuration": 3
};
toastr['error']('MyCRM', "Error while updating case : " + data);
}
});
}); | paulcoiffier/Mobissime-Liberta | src/MyCrm/Modules/LibertaTickets/Js/edit_case.js | JavaScript | gpl-2.0 | 1,698 |
<?php /* Smarty version 2.6.14, created on 2010-01-28 11:39:35
compiled from CRM/Contact/Form/Search.tpl */ ?>
<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('block', 'ts', 'CRM/Contact/Form/Search.tpl', 19, false),)), $this); ?>
<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "CRM/Contact/Form/Search/Intro.tpl", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
?>
<?php if ($this->_tpl_vars['context'] == 'smog'): ?>
<?php if ($this->_tpl_vars['rowsEmpty']): ?>
<?php $this->assign('showBlock', ""); ?>
<?php $this->assign('hideBlock', "'searchForm','searchForm_show'"); ?>
<?php else: ?>
<?php $this->assign('showBlock', "'searchForm_show'"); ?>
<?php $this->assign('hideBlock', "'searchForm'"); ?>
<?php endif; else: ?>
<?php $this->assign('showBlock', "'searchForm'"); ?>
<?php $this->assign('hideBlock', "'searchForm_show'"); endif; ?>
<div id="searchForm_show" class="form-item">
<a href="#" onclick="hide('searchForm_show'); show('searchForm'); return false;"><img src="<?php echo $this->_tpl_vars['config']->resourceBase; ?>
i/TreePlus.gif" class="action-icon" alt="<?php $this->_tag_stack[] = array('ts', array()); $_block_repeat=true;smarty_block_ts($this->_tag_stack[count($this->_tag_stack)-1][1], null, $this, $_block_repeat);while ($_block_repeat) { ob_start(); ?>open section<?php $_block_content = ob_get_contents(); ob_end_clean(); $_block_repeat=false;echo smarty_block_ts($this->_tag_stack[count($this->_tag_stack)-1][1], $_block_content, $this, $_block_repeat); } array_pop($this->_tag_stack); ?>" /></a>
<label>
<?php if ($this->_tpl_vars['context'] == 'smog'): $this->_tag_stack[] = array('ts', array()); $_block_repeat=true;smarty_block_ts($this->_tag_stack[count($this->_tag_stack)-1][1], null, $this, $_block_repeat);while ($_block_repeat) { ob_start(); ?>Find Members within this Group<?php $_block_content = ob_get_contents(); ob_end_clean(); $_block_repeat=false;echo smarty_block_ts($this->_tag_stack[count($this->_tag_stack)-1][1], $_block_content, $this, $_block_repeat); } array_pop($this->_tag_stack); ?>
<?php elseif ($this->_tpl_vars['context'] == 'amtg'): $this->_tag_stack[] = array('ts', array()); $_block_repeat=true;smarty_block_ts($this->_tag_stack[count($this->_tag_stack)-1][1], null, $this, $_block_repeat);while ($_block_repeat) { ob_start(); ?>Find Contacts to Add to this Group<?php $_block_content = ob_get_contents(); ob_end_clean(); $_block_repeat=false;echo smarty_block_ts($this->_tag_stack[count($this->_tag_stack)-1][1], $_block_content, $this, $_block_repeat); } array_pop($this->_tag_stack); ?>
<?php else: $this->_tag_stack[] = array('ts', array()); $_block_repeat=true;smarty_block_ts($this->_tag_stack[count($this->_tag_stack)-1][1], null, $this, $_block_repeat);while ($_block_repeat) { ob_start(); ?>Search Criteria<?php $_block_content = ob_get_contents(); ob_end_clean(); $_block_repeat=false;echo smarty_block_ts($this->_tag_stack[count($this->_tag_stack)-1][1], $_block_content, $this, $_block_repeat); } array_pop($this->_tag_stack); endif; ?>
</label>
</div>
<div id="searchForm">
<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "CRM/Contact/Form/Search/BasicCriteria.tpl", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
?>
</div>
<?php if ($this->_tpl_vars['rowsEmpty']): ?>
<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "CRM/Contact/Form/Search/EmptyResults.tpl", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
endif; ?>
<?php if ($this->_tpl_vars['rows']): ?>
<fieldset>
<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "CRM/Contact/Form/Search/ResultTasks.tpl", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
?>
<p></p>
<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "CRM/Contact/Form/Selector.tpl", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
?>
</fieldset>
<?php endif; ?>
<script type="text/javascript">
var showBlock = new Array(<?php echo $this->_tpl_vars['showBlock']; ?>
);
var hideBlock = new Array(<?php echo $this->_tpl_vars['hideBlock']; ?>
);
on_load_init_blocks( showBlock, hideBlock );
</script> | zakiya/Peoples-History | files/civicrm/templates_c/en_US/%%70^70A^70AFFDD6%%Search.tpl.php | PHP | gpl-2.0 | 4,792 |
// Copyright (c) 2009-2013 DotNetAge (http://www.dotnetage.com)
// Licensed under the GPLv2: http://dotnetage.codeplex.com/license
// Project owner : Ray Liang ([email protected])
using System;
using System.Collections.Generic;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
namespace DNA.Web.Data.Entity.ModelConfiguration
{
public class SqlContentListConfiguration : EntityTypeConfiguration<ContentList>
{
public SqlContentListConfiguration()
{
HasKey(c => c.ID).ToTable("dna_ContentLists");
Property(c => c.Description).HasMaxLength(2048);
Property(c => c.ItemType).HasMaxLength(2048);
Property(c => c.Name).HasMaxLength(255);
Property(c => c.Title).HasMaxLength(255);
Property(c => c.Owner).HasMaxLength(50);
Property(c => c.FieldsXml).HasColumnType("ntext");
Property(c => c.Moderators).HasColumnType("ntext");
Property(c => c.ImageUrl).HasColumnType("ntext");
//Property(c => c.ActivityDispTemplate).HasColumnType("ntext");
Property(c => c.BaseType).HasMaxLength(255);
Property(c => c.Master).HasMaxLength(255);
Property(c => c.Version).HasMaxLength(50);
Property(c => c.Locale).HasMaxLength(20);
Ignore(c => c.DetailForm);
Ignore(c => c.EditForm);
Ignore(c => c.NewForm);
Ignore(c => c.Roles);
HasMany(i => i.Items)
.WithRequired(i => i.Parent)
.HasForeignKey(i => i.ParentID);
HasMany(p => p.Views)
.WithRequired(v => v.Parent)
.HasForeignKey(v => v.ParentID);
HasMany(p => p.Forms)
.WithRequired(v => v.Parent)
.HasForeignKey(v => v.ParentID);
HasMany(p => p.Actions)
.WithRequired(v => v.Parent)
.HasForeignKey(v => v.ParentID);
//HasMany(c => c.Roles)
// .WithMany(r => r.Lists)
// .Map(cr =>
// {
// cr.MapLeftKey("ListID");
// cr.MapRightKey("RoleID");
// cr.ToTable("dna_ListsInRoles");
// });
HasMany(c => c.Followers)
.WithRequired(c => c.List)
.HasForeignKey(c => c.ListID);
}
}
}
| DotNetAge/dotnetage | src/Foundation/DNA.Mvc.Data.Entity/ModelConfiguration/SqlServer/SqlContentListConfiguration.cs | C# | gpl-2.0 | 2,496 |
/**
* 项目名: java-code-tutorials-tools
* 包名: net.fantesy84.common.util
* 文件名: IPUtils.java
* Copy Right © 2015 Andronicus Ge
* 时间: 2015年11月9日
*/
package net.fantesy84.common.util;
import java.net.InetAddress;
import java.net.UnknownHostException;
import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author Andronicus
* @since 2015年11月9日
*/
public abstract class IPUtils {
private static final Logger logger = LoggerFactory.getLogger(IPUtils.class);
private static String LOCALHOST_NAME;
static {
try {
LOCALHOST_NAME = InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e) {
logger.error(e.getMessage(), new IllegalStateException(e));
}
}
/**
* 获取本地网络适配器IP地址
* <P>有多个网卡时会有多个IP,一一对应
* @return 网卡地址列表
*/
public static String getLocalIPv4Address(){
String ip = null;
try {
InetAddress[] addresses = InetAddress.getAllByName(LOCALHOST_NAME);
if (!ArrayUtils.isEmpty(addresses)) {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < addresses.length; i++) {
if (addresses[i].getHostAddress().matches(RegularExpressions.IP_V4_REGEX)){
builder.append(",").append(addresses[i].getHostAddress());
}
}
ip = builder.toString().replaceFirst(",", "");
}
} catch (UnknownHostException e) {
logger.error(e.getMessage(), new IllegalStateException(e));
}
return ip;
}
/**
* 获取远程访问者IP地址
* <P> 关于代理请求,通过代理过滤进行查询.有多层代理时,第一个IP地址即为真实地址.
* @param request 网络请求
* @return 远程访问者IP地址
*/
public static String getRemoteIP(HttpServletRequest request, String regex){
String ip = null;
ip = request.getHeader("x-forwarded-for");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
if ("127.0.0.1".equals(ip) || "0:0:0:0:0:0:0:1".equals(ip)) {
ip = getLocalIPv4Address();
}
if (ip != null && ip.length() > 15) {
if (!StringUtils.isBlank(regex)) {
StringBuilder builder = new StringBuilder();
String[] addrs = ip.split(",");
for (String addr : addrs) {
if (addr.matches(regex)) {
builder.append(",").append(addr);
}
}
ip = builder.toString().replaceFirst(",", "");
}
if (ip.indexOf(",") > 0) {
ip = ip.substring(0, ip.indexOf(","));
}
}
if (ip == null) {
logger.error("未获取到任何IP地址!请检查网络配置!", new IllegalStateException());
}
return ip;
}
}
| fantesy84/java-code-tutorials | java-code-tutorials-tools/src/main/java/net/fantesy84/common/util/IPUtils.java | Java | gpl-2.0 | 2,924 |
vimrc CHANGELOG
===============
This file is used to list changes made in each version of the vimrc cookbook.
0.1.0
-----
- [your_name] - Initial release of vimrc
- - -
Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown.
The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown.
| 4md/chef-vimrc | CHANGELOG.md | Markdown | gpl-2.0 | 447 |
<?php
/**
* @package jCart
* @copyright Copyright (C) 2009 - 2012 softPHP,http://www.soft-php.com
* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
$_['text_sub_total'] = 'Sub-Total';
?> | jiangfanglu/grart | components/com_opencart/catalog/language/english/total/sub_total.php | PHP | gpl-2.0 | 272 |
/*
* This file contains pieces of the Linux TCP/IP stack needed for modular
* TOE support.
*
* Copyright (C) 2006-2009 Chelsio Communications. All rights reserved.
* See the corresponding files in the Linux tree for copyrights of the
* original Linux code a lot of this file is based on.
*
* Written by Dimitris Michailidis ([email protected])
*
* This program 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 LICENSE file included in this
* release for licensing terms and conditions.
*/
/* The following tags are used by the out-of-kernel Makefile to identify
* supported kernel versions if a module_support-<kver> file is not found.
* Do not remove these tags.
* $SUPPORTED KERNEL 2.6.23$
* $SUPPORTED KERNEL 2.6.24$
* $SUPPORTED KERNEL 2.6.25$
* $SUPPORTED KERNEL 2.6.26$
* $SUPPORTED KERNEL 2.6.27$
* $SUPPORTED KERNEL 2.6.28$
* $SUPPORTED KERNEL 2.6.29$
* $SUPPORTED KERNEL 2.6.30$
* $SUPPORTED KERNEL 2.6.31$
* $SUPPORTED KERNEL 2.6.32$
* $SUPPORTED KERNEL 2.6.33$
* $SUPPORTED KERNEL 2.6.34$
* $SUPPORTED KERNEL 2.6.35$
* $SUPPORTED KERNEL 2.6.36$
* $SUPPORTED KERNEL 2.6.37$
*/
#include <net/tcp.h>
#include <linux/pkt_sched.h>
#include <linux/kprobes.h>
#include "defs.h"
#include <asm/tlbflush.h>
#if defined(CONFIG_SMP) && !defined(PPC64_TLB_BATCH_NR)
static unsigned long (*kallsyms_lookup_name_p)(const char *name);
static void (*flush_tlb_mm_p)(struct mm_struct *mm);
static void (*flush_tlb_page_p)(struct vm_area_struct *vma,
unsigned long va);
void flush_tlb_mm_offload(struct mm_struct *mm);
#endif
void flush_tlb_page_offload(struct vm_area_struct *vma, unsigned long addr)
{
#if defined(CONFIG_SMP) && !defined(PPC64_TLB_BATCH_NR)
flush_tlb_page_p(vma, addr);
#endif
}
int sysctl_tcp_window_scaling = 1;
int sysctl_tcp_adv_win_scale = 2;
#define ECN_OR_COST(class) TC_PRIO_##class
const __u8 ip_tos2prio[16] = {
TC_PRIO_BESTEFFORT,
ECN_OR_COST(FILLER),
TC_PRIO_BESTEFFORT,
ECN_OR_COST(BESTEFFORT),
TC_PRIO_BULK,
ECN_OR_COST(BULK),
TC_PRIO_BULK,
ECN_OR_COST(BULK),
TC_PRIO_INTERACTIVE,
ECN_OR_COST(INTERACTIVE),
TC_PRIO_INTERACTIVE,
ECN_OR_COST(INTERACTIVE),
TC_PRIO_INTERACTIVE_BULK,
ECN_OR_COST(INTERACTIVE_BULK),
TC_PRIO_INTERACTIVE_BULK,
ECN_OR_COST(INTERACTIVE_BULK)
};
/*
* Adapted from tcp_minisocks.c
*/
void tcp_time_wait(struct sock *sk, int state, int timeo)
{
struct inet_timewait_sock *tw = NULL;
const struct inet_connection_sock *icsk = inet_csk(sk);
const struct tcp_sock *tp = tcp_sk(sk);
int recycle_ok = 0;
if (tcp_death_row.tw_count < tcp_death_row.sysctl_max_tw_buckets)
tw = inet_twsk_alloc(sk, state);
if (tw != NULL) {
struct tcp_timewait_sock *tcptw = tcp_twsk((struct sock *)tw);
const int rto = (icsk->icsk_rto << 2) - (icsk->icsk_rto >> 1);
tw->tw_rcv_wscale = tp->rx_opt.rcv_wscale;
tcptw->tw_rcv_nxt = tp->rcv_nxt;
tcptw->tw_snd_nxt = tp->snd_nxt;
tcptw->tw_rcv_wnd = tcp_receive_window(tp);
tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
/* Linkage updates. */
__inet_twsk_hashdance(tw, sk, &tcp_hashinfo);
/* Get the TIME_WAIT timeout firing. */
if (timeo < rto)
timeo = rto;
if (recycle_ok) {
tw->tw_timeout = rto;
} else {
tw->tw_timeout = TCP_TIMEWAIT_LEN;
if (state == TCP_TIME_WAIT)
timeo = TCP_TIMEWAIT_LEN;
}
inet_twsk_schedule(tw, &tcp_death_row, timeo,
TCP_TIMEWAIT_LEN);
inet_twsk_put(tw);
} else {
/* Sorry, if we're out of memory, just CLOSE this
* socket up. We've got bigger problems than
* non-graceful socket closings.
*/
if (net_ratelimit())
printk(KERN_INFO
"TCP: time wait bucket table overflow\n");
}
tcp_done(sk);
}
void flush_tlb_mm_offload(struct mm_struct *mm)
{
#if defined(CONFIG_SMP) && !defined(PPC64_TLB_BATCH_NR)
if (flush_tlb_mm_p)
flush_tlb_mm_p(mm);
#endif
}
#if defined(CONFIG_SMP) && !defined(PPC64_TLB_BATCH_NR)
static int find_kallsyms_lookup_name(void)
{
int err = 0;
#if defined(KPROBES_KALLSYMS)
struct kprobe kp;
memset(&kp, 0, sizeof kp);
kp.symbol_name = "kallsyms_lookup_name";
err = register_kprobe(&kp);
if (!err) {
kallsyms_lookup_name_p = (void *)kp.addr;
unregister_kprobe(&kp);
}
#else
kallsyms_lookup_name_p = (void *)KALLSYMS_LOOKUP;
#endif
if (!err)
err = kallsyms_lookup_name_p == NULL;
return err;
}
#endif
int prepare_tom_for_offload(void)
{
#if defined(CONFIG_SMP) && !defined(PPC64_TLB_BATCH_NR)
if (!kallsyms_lookup_name_p) {
int err = find_kallsyms_lookup_name();
if (err)
return err;
}
flush_tlb_mm_p = (void *)kallsyms_lookup_name_p("flush_tlb_mm");
if (!flush_tlb_mm_p) {
printk(KERN_ERR "Could not locate flush_tlb_mm");
return -1;
}
flush_tlb_page_p = (void *)kallsyms_lookup_name_p("flush_tlb_page");
if (!flush_tlb_page_p) {
printk(KERN_ERR "Could not locate flush_tlb_page");
return -1;
}
#endif
return 0;
}
| nal-epfl/line-sigcomm14 | PF_RING-5.6.2/drivers/PF_RING_aware/chelsio/cxgb3-2.0.0.1/src/t3_tom/module_support/module_support-tom-2.6.23.c | C | gpl-2.0 | 5,114 |
/**
Copyright 2011 Red Hat, Inc.
This software is licensed to you under the GNU General Public
License as published by the Free Software Foundation; either version
2 of the License (GPLv2) or (at your option) any later version.
There is NO WARRANTY for this software, express or implied,
including the implied warranties of MERCHANTABILITY,
NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
have received a copy of GPLv2 along with this software; if not, see
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*/
KT.panel.list.registerPage('gpg_keys', {
create : 'new_gpg_key',
extra_create_data : function(){
return { 'gpg_key[name]' : $('#gpg_key_name').val() };
}
});
$(document).ready(function(){
$('#upload_gpg_key').live('click', function(event){
KT.gpg_key.upload();
});
$('#upload_new_gpg_key').live('submit', function(e){
e.preventDefault();
KT.gpg_key.upload();
});
$('#update_upload_gpg_key').live('click', function(event){
KT.gpg_key.upload_update();
});
$('#gpg_key_content').live('input keyup paste', function(){
if( $(this).val() !== '' ){
$('#gpg_key_content_upload').attr('disabled', 'disabled');
$('#upload_gpg_key').attr('disabled', 'disabled');
$('#clear_gpg_key').removeAttr('disabled');
} else {
$('#gpg_key_content_upload').removeAttr('disabled');
$('#upload_gpg_key').removeAttr('disabled');
$('#clear_gpg_key').attr('disabled', 'disabled');
}
});
$('#gpg_key_content_upload').live('change', function(){
if( $(this).val() !== '' ){
$('#gpg_key_content').attr('disabled', 'disabled');
$('#save_gpg_key').attr('disabled', 'disabled');
$('#clear_upload_gpg_key').removeAttr('disabled');
} else {
$('#gpg_key_content').removeAttr('disabled');
$('#save_gpg_key').removeAttr('disabled');
$('#clear_upload_gpg_key').attr('disabled', 'disabled');
}
});
$('#clear_upload_gpg_key').live('click', function(){
$('#gpg_key_content_upload').val('');
$('#gpg_key_content').removeAttr('disabled');
$('#save_gpg_key').removeAttr('disabled');
$('#clear_upload_gpg_key').attr('disabled', 'disabled');
$('#clear_gpg_key').attr('disabled', 'disabled');
});
$('#clear_gpg_key').live('click', function(){
$('#gpg_key_content').val('');
$('#gpg_key_content_upload').removeAttr('disabled');
$('#upload_gpg_key').removeAttr('disabled');
$('#clear_upload_gpg_key').attr('disabled', 'disabled');
$('#clear_gpg_key').attr('disabled', 'disabled');
});
$('#gpg_key_content_upload_update').live('change', function(){
if( $(this).val() !== '' ){
$('#update_upload_gpg_key').removeAttr('disabled');
$('#clear_upload_gpg_key').removeAttr('disabled');
} else {
$('#update_upload_gpg_key').attr('disabled', 'disabled');
$('#clear_upload_gpg_key').attr('disabled', 'disabled');
}
});
$('#clear_upload_gpg_key').live('click', function(){
$('#update_upload_gpg_key').attr('disabled', 'disabled');
$('#clear_upload_gpg_key').attr('disabled', 'disabled');
$('#gpg_key_content_upload_update').val('');
});
});
KT.gpg_key = (function($){
var self = this,
get_buttons = function(){
return {
'gpg_key_save' : $('#save_gpg_key'),
'gpg_key_upload': $('#upload_gpg_key')
}
},
enable_buttons = function(){
var buttons = get_buttons();
buttons.gpg_key_save.removeAttr('disabled');
buttons.gpg_key_upload.removeAttr('disabled');
},
disable_buttons = function(){
var buttons = get_buttons();
buttons.gpg_key_save.attr('disabled', 'disabled');
buttons.gpg_key_upload.attr('disabled', 'disabled');
};
self.upload = function(){
var submit_data = { 'gpg_key[name]' : $('#gpg_key_name').val() };
disable_buttons();
$('#upload_new_gpg_key').ajaxSubmit({
url : KT.routes['gpg_keys_path'](),
type : 'POST',
data : submit_data,
iframe : true,
success : function(data, status, xhr){
var parsed_data = $(data);
if( parsed_data.get(0).tagName === 'PRE' ){
notices.displayNotice('error', parsed_data.html());
} else {
KT.panel.list.createSuccess(data);
}
enable_buttons();
},
error : function(){
enable_buttons();
notices.checkNotices();
}
});
};
self.upload_update = function(){
$('#update_upload_gpg_key').attr('disabled', 'disabled');
$('#clear_upload_gpg_key').attr('disabled', 'disabled');
$('#upload_gpg_key').ajaxSubmit({
url : $(this).data('url'),
type : 'POST',
iframe : true,
success : function(data, status, xhr){
if( !data.match(/notices/) ){
$('#gpg_key_content').html(data);
$('#upload_gpg_key').val('');
}
notices.checkNotices();
$('#update_upload_gpg_key').removeAttr('disabled');
$('#clear_upload_gpg_key').removeAttr('disabled');
},
error : function(){
$('#update_upload_gpg_key').removeAttr('disabled');
$('#clear_upload_gpg_key').removeAttr('disabled');
notices.checkNotices();
}
});
};
return self;
})(jQuery);
| iNecas/katello | src/public/javascripts/gpg_key.js | JavaScript | gpl-2.0 | 5,150 |
.pane-sliders > .panel {
border: none !important;
font-family:arial;
}
.pane-sliders >.panel > h3 {
background:url(../images/header-bg.gif) repeat-x!important;
height:37px;
line-height:37px;
padding:0;
}
.pane-sliders >.panel h3 span{
text-transform:uppercase;
color:#c16306;
}
.pane-toggler-down {
border-bottom:none!important;
}
.pane-toggler-down span {
background: url("../images/arrow-down.gif") no-repeat scroll 8px 50% transparent!important;
padding-left: 26px!important;
}
.pane-toggler span {
background: url("../images/arrow-up.gif") no-repeat scroll 10px 50% transparent!important;
padding-left: 26px!important;
}
.pane-sliders > .panel{
border:1px solid #cacaca!important;
border-top:1px solid #da710a!important;
border-radius:5px 5px 5px 5px;
padding:0 1px;
}
fieldset.panelform{
padding:10px!important;
}
fieldset.panelform li > label, fieldset.panelform div.paramrow label, fieldset.panelform span.faux-label {
max-width: 30% !important;
min-width: 30% !important;
}
#module-sliders .spacer h3{
padding-top:3px;
margin:0px;
background:#fff!important;
}
#module-sliders .adminform{
padding:0;
}
#module-sliders fieldset > ul > li > label {
color: #505050;
font-size: 11px;
line-height:18px;
font-weight: bold;
max-width: 30% !important;
min-width: 30% !important;
text-align: left;
}
#module-sliders fieldset > ul.adminformlist > li {
border-bottom: 1px dotted #c4c4c4;
min-height:35px;
padding:0px;
margin:5px;
}
#btss-dialog li{
list-style:none;
}
/* Fix chosen*/
#module-sliders .chzn-container ul.chzn-results{
min-width:95%;
}
#module-sliders .chzn-container-single .chzn-single div{
height:100%!important;
}
fieldset.adminform fieldset.radio, fieldset.panelform fieldset.radio, fieldset.adminform-legacy fieldset.radio {
border: 0 none;
float: left;
margin: 0 0 5px;
max-width: 68% !important;
min-width: 68% !important;
padding: 0;
}
#module-sliders input[type=text],#module-sliders textarea {
background:-moz-linear-gradient(center bottom , white 85%, #EEEEEE 99%) repeat scroll 0 0 transparent;
border: 1px solid #AAAAAA;
font-family: sans-serif;
font-size:11px;
margin: 1px 0;
outline: 0 none;
padding: 6px 20px 6px 5px;
border-radius: 4px 4px 4px 4px;
}
.bt-desc{
line-height:200%;
}
.bt-desc img{
margin-right:10px;
}
.bt-license{
border-top: 1px dotted #c4c4c4;
padding:10px 0px;
}
.bt-desc p a{
display: inline-block;
height: 28px;
margin-right: 7px;
text-indent: -999px;
width: 28px;
text-decoration:none;
margin-top:10px;
}
.social-f {
background: url("../images/icon_f.png") no-repeat scroll left top transparent;
}
.social-f:hover {
background: url("../images/icon_f_hover.png") no-repeat scroll left top transparent;
}
.social-t {
background: url("../images/icon_t.png") no-repeat scroll left top transparent;
}
.social-t:hover {
background: url("../images/icon_t_hover.png") no-repeat scroll left top transparent;
}
.social-rss {
background: url("../images/icon_rss.png") no-repeat scroll left top transparent;
}
.social-rss:hover {
background: url("../images/icon_rss_hover.png") no-repeat scroll left top transparent;
}
.social-g {
background: url("../images/icon_group.png") no-repeat scroll left top transparent;
}
.social-g:hover {
background: url("../images/icon_group_hover.png") no-repeat scroll left top transparent;
}
.switcher-yes,.switcher-no {
background: url("../images/switcher-yesno.png") no-repeat scroll 0 0 transparent;
cursor: pointer;
float: left;
height: 20px;
margin-top: 4px;
width: 64px;
}
.switcher-no {
background-position: 0 -20px;
}
.switcher-on,.switcher-off {
background: url("../images/switcher-onoff.png") no-repeat scroll 0 0 transparent;
cursor: pointer;
float: left;
height: 20px;
margin-top: 4px;
width: 64px;
}
.switcher-off {
background-position: 0 -20px;
}
#btnGetImages, #btnDeleteAll{
background: url(../images/button.png) no-repeat;
width: 110px;
height: 35px;
text-align: center;
line-height: 33px;
border: none;
color: #ffffff;
margin-top: 0px !important;
}
#layout-demo{
width: 88px; height: 18px;
background: url(../images/demo.png) no-repeat;
float: left;
margin: 5px 10px;
text-align: center;
}
#layout-demo a{
color: #ffffff;
font-family: arial; font-size: 11px;
line-height: 17px;
}
#jform_params_layout_chzn{
float:left;
}
div.colorpicker{
z-index:999;
}
div.colorpicker input[type="text"] {
height: auto!important;
width: auto!important;
padding:0;
margin:0;
background:none;
border:none;
}
#btss-dialog label{
width:120px;
display:inline-block;
} | asukademy/akblog | modules/mod_btslideshow_pro/admin/css/bt.css | CSS | gpl-2.0 | 4,756 |
/* UnknownTypeException.java -- Thrown by an unknown type.
Copyright (C) 2012 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 javax.lang.model.type;
/**
* Thrown when an unknown type is encountered,
* usually by a {@link TypeVisitor}.
*
* @author Andrew John Hughes ([email protected])
* @since 1.6
* @see TypeVisitor#visitUnknown(TypeMirror,P)
*/
public class UnknownTypeException
extends RuntimeException
{
private static final long serialVersionUID = 269L;
/**
* The unknown type.
*/
private TypeMirror type;
/**
* The additional parameter.
*/
private Object param;
/**
* Constructs a new {@code UnknownTypeException}
* for the specified type. An additional
* object may also be passed to give further context as
* to where the exception occurred, such as the additional parameter
* used by visitor classes.
*
* @param type the unknown type or {@code null}.
* @param param the additional parameter or {@code null}.
*/
public UnknownTypeException(TypeMirror type, Object param)
{
this.type = type;
this.param = param;
}
/**
* Returns the additional parameter or {@code null} if
* unavailable.
*
* @return the additional parameter.
*/
public Object getArgument()
{
return param;
}
/**
* Returns the unknown type or {@code null}
* if unavailable. The type may be {@code null} if
* the value is not {@link java.io.Serializable} but the
* exception has been serialized and read back in.
*
* @return the unknown type.
*/
public TypeMirror getUnknownType()
{
return type;
}
}
| penberg/classpath | javax/lang/model/type/UnknownTypeException.java | Java | gpl-2.0 | 3,277 |
/*
* Synopsys DesignWare I2C adapter driver (master only).
*
* Partly based on code of similar driver from U-Boot:
* Copyright (C) 2009 ST Micoelectronics
*
* and corresponding code from Linux Kernel
* Copyright (C) 2006 Texas Instruments.
* Copyright (C) 2007 MontaVista Software Inc.
* Copyright (C) 2009 Provigent Ltd.
*
* Copyright (C) 2015 Andrey Smirnov <[email protected]>
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program 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.
*
*/
#include <clock.h>
#include <common.h>
#include <driver.h>
#include <init.h>
#include <of.h>
#include <malloc.h>
#include <types.h>
#include <xfuncs.h>
#include <linux/clk.h>
#include <linux/err.h>
#include <linux/math64.h>
#include <io.h>
#include <i2c/i2c.h>
#define DW_I2C_BIT_RATE 100000
#define DW_IC_CON 0x0
#define DW_IC_CON_MASTER (1 << 0)
#define DW_IC_CON_SPEED_STD (1 << 1)
#define DW_IC_CON_SPEED_FAST (1 << 2)
#define DW_IC_CON_SLAVE_DISABLE (1 << 6)
#define DW_IC_TAR 0x4
#define DW_IC_DATA_CMD 0x10
#define DW_IC_DATA_CMD_CMD (1 << 8)
#define DW_IC_DATA_CMD_STOP (1 << 9)
#define DW_IC_SS_SCL_HCNT 0x14
#define DW_IC_SS_SCL_LCNT 0x18
#define DW_IC_FS_SCL_HCNT 0x1c
#define DW_IC_FS_SCL_LCNT 0x20
#define DW_IC_INTR_MASK 0x30
#define DW_IC_RAW_INTR_STAT 0x34
#define DW_IC_INTR_RX_UNDER (1 << 0)
#define DW_IC_INTR_RX_OVER (1 << 1)
#define DW_IC_INTR_RX_FULL (1 << 2)
#define DW_IC_INTR_TX_OVER (1 << 3)
#define DW_IC_INTR_TX_EMPTY (1 << 4)
#define DW_IC_INTR_RD_REQ (1 << 5)
#define DW_IC_INTR_TX_ABRT (1 << 6)
#define DW_IC_INTR_RX_DONE (1 << 7)
#define DW_IC_INTR_ACTIVITY (1 << 8)
#define DW_IC_INTR_STOP_DET (1 << 9)
#define DW_IC_INTR_START_DET (1 << 10)
#define DW_IC_INTR_GEN_CALL (1 << 11)
#define DW_IC_RX_TL 0x38
#define DW_IC_TX_TL 0x3c
#define DW_IC_CLR_INTR 0x40
#define DW_IC_CLR_TX_ABRT 0x54
#define DW_IC_SDA_HOLD 0x7c
#define DW_IC_ENABLE 0x6c
#define DW_IC_ENABLE_ENABLE (1 << 0)
#define DW_IC_STATUS 0x70
#define DW_IC_STATUS_TFNF (1 << 1)
#define DW_IC_STATUS_TFE (1 << 2)
#define DW_IC_STATUS_RFNE (1 << 3)
#define DW_IC_STATUS_MST_ACTIVITY (1 << 5)
#define DW_IC_TX_ABRT_SOURCE 0x80
#define DW_IC_ENABLE_STATUS 0x9c
#define DW_IC_ENABLE_STATUS_IC_EN (1 << 0)
#define DW_IC_COMP_VERSION 0xf8
#define DW_IC_SDA_HOLD_MIN_VERS 0x3131312A
#define DW_IC_COMP_TYPE 0xfc
#define DW_IC_COMP_TYPE_VALUE 0x44570140
#define MAX_T_POLL_COUNT 100
#define DW_TIMEOUT_IDLE (40 * MSECOND)
#define DW_TIMEOUT_TX (2 * MSECOND)
#define DW_TIMEOUT_RX (2 * MSECOND)
#define DW_IC_SDA_HOLD_RX_SHIFT 16
#define DW_IC_SDA_HOLD_RX_MASK GENMASK(23, DW_IC_SDA_HOLD_RX_SHIFT)
struct dw_i2c_dev {
void __iomem *base;
struct clk *clk;
struct i2c_adapter adapter;
u32 sda_hold_time;
};
static inline struct dw_i2c_dev *to_dw_i2c_dev(struct i2c_adapter *a)
{
return container_of(a, struct dw_i2c_dev, adapter);
}
static void i2c_dw_enable(struct dw_i2c_dev *dw, bool enable)
{
u32 reg = 0;
/*
* This subrotine is an implementation of an algorithm
* described in "Cyclone V Hard Processor System Technical
* Reference * Manual" p. 20-19, "Disabling the I2C Controller"
*/
int timeout = MAX_T_POLL_COUNT;
if (enable)
reg |= DW_IC_ENABLE_ENABLE;
do {
uint32_t ic_enable_status;
writel(reg, dw->base + DW_IC_ENABLE);
ic_enable_status = readl(dw->base + DW_IC_ENABLE_STATUS);
if ((ic_enable_status & DW_IC_ENABLE_STATUS_IC_EN) == enable)
return;
udelay(250);
} while (timeout--);
dev_warn(&dw->adapter.dev, "timeout in %sabling adapter\n",
enable ? "en" : "dis");
}
/*
* All of the code pertaining to tming calculation is taken from
* analogous driver in Linux kernel
*/
static uint32_t
i2c_dw_scl_hcnt(uint32_t ic_clk, uint32_t tSYMBOL, uint32_t tf, int cond,
int offset)
{
/*
* DesignWare I2C core doesn't seem to have solid strategy to meet
* the tHD;STA timing spec. Configuring _HCNT based on tHIGH spec
* will result in violation of the tHD;STA spec.
*/
if (cond)
/*
* Conditional expression:
*
* IC_[FS]S_SCL_HCNT + (1+4+3) >= IC_CLK * tHIGH
*
* This is based on the DW manuals, and represents an ideal
* configuration. The resulting I2C bus speed will be
* faster than any of the others.
*
* If your hardware is free from tHD;STA issue, try this one.
*/
return (ic_clk * tSYMBOL + 500000) / 1000000 - 8 + offset;
else
/*
* Conditional expression:
*
* IC_[FS]S_SCL_HCNT + 3 >= IC_CLK * (tHD;STA + tf)
*
* This is just experimental rule; the tHD;STA period turned
* out to be proportinal to (_HCNT + 3). With this setting,
* we could meet both tHIGH and tHD;STA timing specs.
*
* If unsure, you'd better to take this alternative.
*
* The reason why we need to take into account "tf" here,
* is the same as described in i2c_dw_scl_lcnt().
*/
return (ic_clk * (tSYMBOL + tf) + 500000) / 1000000
- 3 + offset;
}
static uint32_t
i2c_dw_scl_lcnt(uint32_t ic_clk, uint32_t tLOW, uint32_t tf, int offset)
{
/*
* Conditional expression:
*
* IC_[FS]S_SCL_LCNT + 1 >= IC_CLK * (tLOW + tf)
*
* DW I2C core starts counting the SCL CNTs for the LOW period
* of the SCL clock (tLOW) as soon as it pulls the SCL line.
* In order to meet the tLOW timing spec, we need to take into
* account the fall time of SCL signal (tf). Default tf value
* should be 0.3 us, for safety.
*/
return ((ic_clk * (tLOW + tf) + 500000) / 1000000) - 1 + offset;
}
static void i2c_dw_setup_timings(struct dw_i2c_dev *dw)
{
uint32_t hcnt, lcnt;
u32 reg;
const uint32_t sda_falling_time = 300; /* ns */
const uint32_t scl_falling_time = 300; /* ns */
const unsigned int input_clock_khz = clk_get_rate(dw->clk) / 1000;
/* Set SCL timing parameters for standard-mode */
hcnt = i2c_dw_scl_hcnt(input_clock_khz,
4000, /* tHD;STA = tHIGH = 4.0 us */
sda_falling_time,
0, /* 0: DW default, 1: Ideal */
0); /* No offset */
lcnt = i2c_dw_scl_lcnt(input_clock_khz,
4700, /* tLOW = 4.7 us */
scl_falling_time,
0); /* No offset */
writel(hcnt, dw->base + DW_IC_SS_SCL_HCNT);
writel(lcnt, dw->base + DW_IC_SS_SCL_LCNT);
hcnt = i2c_dw_scl_hcnt(input_clock_khz,
600, /* tHD;STA = tHIGH = 0.6 us */
sda_falling_time,
0, /* 0: DW default, 1: Ideal */
0); /* No offset */
lcnt = i2c_dw_scl_lcnt(input_clock_khz,
1300, /* tLOW = 1.3 us */
scl_falling_time,
0); /* No offset */
writel(hcnt, dw->base + DW_IC_FS_SCL_HCNT);
writel(lcnt, dw->base + DW_IC_FS_SCL_LCNT);
/* Configure SDA Hold Time if required */
reg = readl(dw->base + DW_IC_COMP_VERSION);
if (reg >= DW_IC_SDA_HOLD_MIN_VERS) {
u32 ht;
int ret;
ret = of_property_read_u32(dw->adapter.dev.device_node,
"i2c-sda-hold-time-ns", &ht);
if (ret) {
/* Keep previous hold time setting if no one set it */
dw->sda_hold_time = readl(dw->base + DW_IC_SDA_HOLD);
} else if (ht) {
dw->sda_hold_time = div_u64((u64)input_clock_khz * ht + 500000,
1000000);
}
/*
* Workaround for avoiding TX arbitration lost in case I2C
* slave pulls SDA down "too quickly" after falling egde of
* SCL by enabling non-zero SDA RX hold. Specification says it
* extends incoming SDA low to high transition while SCL is
* high but it apprears to help also above issue.
*/
if (!(dw->sda_hold_time & DW_IC_SDA_HOLD_RX_MASK))
dw->sda_hold_time |= 1 << DW_IC_SDA_HOLD_RX_SHIFT;
dev_dbg(&dw->adapter.dev, "adjust SDA hold time.\n");
writel(dw->sda_hold_time, dw->base + DW_IC_SDA_HOLD);
}
}
static int i2c_dw_wait_for_bits(struct dw_i2c_dev *dw, uint32_t offset,
uint32_t mask, uint32_t value, uint64_t timeout)
{
const uint64_t start = get_time_ns();
do {
const uint32_t reg = readl(dw->base + offset);
if ((reg & mask) == value)
return 0;
} while (!is_timeout(start, timeout));
return -ETIMEDOUT;
}
static int i2c_dw_wait_for_idle(struct dw_i2c_dev *dw)
{
const uint32_t mask = DW_IC_STATUS_MST_ACTIVITY | DW_IC_STATUS_TFE;
const uint32_t value = DW_IC_STATUS_TFE;
return i2c_dw_wait_for_bits(dw, DW_IC_STATUS, mask, value,
DW_TIMEOUT_IDLE);
}
static int i2c_dw_wait_for_tx_fifo_not_full(struct dw_i2c_dev *dw)
{
const uint32_t mask = DW_IC_STATUS_TFNF;
const uint32_t value = DW_IC_STATUS_TFNF;
return i2c_dw_wait_for_bits(dw, DW_IC_STATUS, mask, value,
DW_TIMEOUT_TX);
}
static int i2c_dw_wait_for_rx_fifo_not_empty(struct dw_i2c_dev *dw)
{
const uint32_t mask = DW_IC_STATUS_RFNE;
const uint32_t value = DW_IC_STATUS_RFNE;
return i2c_dw_wait_for_bits(dw, DW_IC_STATUS, mask, value,
DW_TIMEOUT_RX);
}
static void i2c_dw_reset(struct dw_i2c_dev *dw)
{
i2c_dw_enable(dw, false);
i2c_dw_enable(dw, true);
}
static void i2c_dw_abort_tx(struct dw_i2c_dev *dw)
{
i2c_dw_reset(dw);
}
static void i2c_dw_abort_rx(struct dw_i2c_dev *dw)
{
i2c_dw_reset(dw);
}
static int i2c_dw_read(struct dw_i2c_dev *dw,
const struct i2c_msg *msg)
{
int i;
for (i = 0; i < msg->len; i++) {
int ret;
const bool last_byte = i == msg->len - 1;
uint32_t ic_cmd_data = DW_IC_DATA_CMD_CMD;
if (last_byte)
ic_cmd_data |= DW_IC_DATA_CMD_STOP;
writel(ic_cmd_data, dw->base + DW_IC_DATA_CMD);
ret = i2c_dw_wait_for_rx_fifo_not_empty(dw);
if (ret < 0) {
i2c_dw_abort_rx(dw);
return ret;
}
msg->buf[i] = (uint8_t)readl(dw->base + DW_IC_DATA_CMD);
}
return msg->len;
}
static int i2c_dw_write(struct dw_i2c_dev *dw,
const struct i2c_msg *msg)
{
int i;
uint32_t ic_int_stat;
for (i = 0; i < msg->len; i++) {
int ret;
uint32_t ic_cmd_data;
const bool last_byte = i == msg->len - 1;
ic_int_stat = readl(dw->base + DW_IC_RAW_INTR_STAT);
if (ic_int_stat & DW_IC_INTR_TX_ABRT)
return -EIO;
ret = i2c_dw_wait_for_tx_fifo_not_full(dw);
if (ret < 0) {
i2c_dw_abort_tx(dw);
return ret;
}
ic_cmd_data = msg->buf[i];
if (last_byte)
ic_cmd_data |= DW_IC_DATA_CMD_STOP;
writel(ic_cmd_data, dw->base + DW_IC_DATA_CMD);
}
return msg->len;
}
static int i2c_dw_wait_for_stop(struct dw_i2c_dev *dw)
{
const uint32_t mask = DW_IC_INTR_STOP_DET;
const uint32_t value = DW_IC_INTR_STOP_DET;
return i2c_dw_wait_for_bits(dw, DW_IC_RAW_INTR_STAT, mask, value,
DW_TIMEOUT_IDLE);
}
static int i2c_dw_finish_xfer(struct dw_i2c_dev *dw)
{
int ret;
uint32_t ic_int_stat;
/*
* We expect the controller to signal STOP condition on the
* bus, so we are going to wait for that first.
*/
ret = i2c_dw_wait_for_stop(dw);
if (ret < 0)
return ret;
/*
* Now that we now that the stop condition has been signaled
* we need to wait for controller to go into IDLE state to
* make sure all of the possible error conditions on the bus
* have been propagated to apporpriate status
* registers. Experiment shows that not doing so often results
* in false positive "successful" transfers
*/
ret = i2c_dw_wait_for_idle(dw);
if (ret >= 0) {
ic_int_stat = readl(dw->base + DW_IC_RAW_INTR_STAT);
if (ic_int_stat & DW_IC_INTR_TX_ABRT)
return -EIO;
}
return ret;
}
static int i2c_dw_set_address(struct dw_i2c_dev *dw, uint8_t address)
{
int ret;
uint32_t ic_tar;
/*
* As per "Cyclone V Hard Processor System Technical Reference
* Manual" p. 20-19, we have to wait for controller to be in
* idle state in order to be able to set the address
* dynamically
*/
ret = i2c_dw_wait_for_idle(dw);
if (ret < 0)
return ret;
ic_tar = readl(dw->base + DW_IC_TAR);
ic_tar &= 0xfffffc00;
writel(ic_tar | address, dw->base + DW_IC_TAR);
return 0;
}
static int i2c_dw_xfer(struct i2c_adapter *adapter,
struct i2c_msg *msgs, int num)
{
int i, ret = 0;
struct dw_i2c_dev *dw = to_dw_i2c_dev(adapter);
for (i = 0; i < num; i++) {
if (msgs[i].flags & I2C_M_DATA_ONLY)
return -ENOTSUPP;
ret = i2c_dw_set_address(dw, msgs[i].addr);
if (ret < 0)
break;
if (msgs[i].flags & I2C_M_RD)
ret = i2c_dw_read(dw, &msgs[i]);
else
ret = i2c_dw_write(dw, &msgs[i]);
if (ret < 0)
break;
ret = i2c_dw_finish_xfer(dw);
if (ret < 0)
break;
}
if (ret == -EIO) {
/*
* If we got -EIO it means that transfer was for some
* reason aborted, so we should figure out the reason
* and take steps to clear that condition
*/
const uint32_t ic_tx_abrt_source =
readl(dw->base + DW_IC_TX_ABRT_SOURCE);
dev_dbg(&dw->adapter.dev,
"<%s> ic_tx_abrt_source: 0x%04x\n",
__func__, ic_tx_abrt_source);
readl(dw->base + DW_IC_CLR_TX_ABRT);
return ret;
}
if (ret < 0) {
i2c_dw_reset(dw);
return ret;
}
return num;
}
static int i2c_dw_probe(struct device_d *pdev)
{
struct resource *iores;
struct dw_i2c_dev *dw;
struct i2c_platform_data *pdata;
int ret, bitrate;
uint32_t ic_con, ic_comp_type_value;
pdata = pdev->platform_data;
dw = xzalloc(sizeof(*dw));
if (IS_ENABLED(CONFIG_COMMON_CLK)) {
dw->clk = clk_get(pdev, NULL);
if (IS_ERR(dw->clk)) {
ret = PTR_ERR(dw->clk);
goto fail;
}
}
dw->adapter.master_xfer = i2c_dw_xfer;
dw->adapter.nr = pdev->id;
dw->adapter.dev.parent = pdev;
dw->adapter.dev.device_node = pdev->device_node;
iores = dev_request_mem_resource(pdev, 0);
if (IS_ERR(iores)) {
ret = PTR_ERR(iores);
goto fail;
}
dw->base = IOMEM(iores->start);
ic_comp_type_value = readl(dw->base + DW_IC_COMP_TYPE);
if (ic_comp_type_value != DW_IC_COMP_TYPE_VALUE) {
dev_err(pdev,
"unknown DesignWare IP block 0x%08x",
ic_comp_type_value);
ret = -ENODEV;
goto fail;
}
i2c_dw_enable(dw, false);
if (IS_ENABLED(CONFIG_COMMON_CLK))
i2c_dw_setup_timings(dw);
bitrate = (pdata && pdata->bitrate) ? pdata->bitrate : DW_I2C_BIT_RATE;
/*
* We have to clear 'ic_10bitaddr_master' in 'ic_tar'
* register, otherwise 'ic_10bitaddr_master' in 'ic_con'
* wouldn't clear. We don't care about preserving the contents
* of that register so we set it to zero.
*/
writel(0, dw->base + DW_IC_TAR);
switch (bitrate) {
case 400000:
ic_con = DW_IC_CON_SPEED_FAST;
break;
default:
dev_warn(pdev, "requested bitrate (%d) is not supported."
" Falling back to 100kHz", bitrate);
case 100000: /* FALLTHROUGH */
ic_con = DW_IC_CON_SPEED_STD;
break;
}
ic_con |= DW_IC_CON_MASTER | DW_IC_CON_SLAVE_DISABLE;
writel(ic_con, dw->base + DW_IC_CON);
/*
* Since we will be working in polling mode set both
* thresholds to their minimum
*/
writel(0, dw->base + DW_IC_RX_TL);
writel(0, dw->base + DW_IC_TX_TL);
/* Disable and clear all interrrupts */
writel(0, dw->base + DW_IC_INTR_MASK);
readl(dw->base + DW_IC_CLR_INTR);
i2c_dw_enable(dw, true);
ret = i2c_add_numbered_adapter(&dw->adapter);
fail:
if (ret < 0)
kfree(dw);
return ret;
}
static __maybe_unused struct of_device_id i2c_dw_dt_ids[] = {
{ .compatible = "snps,designware-i2c", },
{ /* sentinel */ }
};
static struct driver_d i2c_dw_driver = {
.probe = i2c_dw_probe,
.name = "i2c-designware",
.of_compatible = DRV_OF_COMPAT(i2c_dw_dt_ids),
};
coredevice_platform_driver(i2c_dw_driver);
| masahir0y/barebox-yamada | drivers/i2c/busses/i2c-designware.c | C | gpl-2.0 | 15,486 |
/*---------------------------------------------------------------------------*\
## #### ###### |
## ## ## | Copyright: ICE Stroemungsfoschungs GmbH
## ## #### |
## ## ## | http://www.ice-sf.at
## #### ###### |
-------------------------------------------------------------------------------
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is based on OpenFOAM.
OpenFOAM 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 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::fvcSpreadFunctionPlugin
Description
SourceFiles
fvcSpreadPluginfunction.C
Contributors/Copyright:
2015-2017 Bernhard F.W. Gschaider <[email protected]>
SWAK Revision: $Id$
\*---------------------------------------------------------------------------*/
#ifndef fvcSpreadPluginfunction_H
#define fvcSpreadPluginfunction_H
#include "FieldValuePluginFunction.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class fvcSpreadPluginFunction Declaration
\*---------------------------------------------------------------------------*/
class fvcSpreadPluginFunction
:
public FieldValuePluginFunction
{
//- Disallow default bitwise assignment
void operator=(const fvcSpreadPluginFunction &);
fvcSpreadPluginFunction(const fvcSpreadPluginFunction &);
//- number of layers
label nLayers_;
//- difference of alpha
scalar alphaDiff_;
//- maximum of alpha
scalar alphaMax_;
//- minimum of alpha
scalar alphaMin_;
//- the field to be spreaded
autoPtr<volScalarField> field_;
//- the field to be spreaded with
autoPtr<volScalarField> alpha_;
public:
fvcSpreadPluginFunction(
const FieldValueExpressionDriver &parentDriver,
const word &name
);
virtual ~fvcSpreadPluginFunction() {}
TypeName("fvcSpreadPluginFunction");
void doEvaluation();
void setArgument(
label index,
const string &content,
const CommonValueExpressionDriver &driver
);
void setArgument(label index,const scalar &);
void setArgument(label index,const label &);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
| Unofficial-Extend-Project-Mirror/openfoam-extend-Breeder2.0-libraries-swak4Foam | Libraries/functionPlugins/swakFvcSchemesFunctionPlugin/fvcSpreadPluginFunction.H | C++ | gpl-2.0 | 3,532 |
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Shoot__n_Loot.Scenes;
namespace Shoot__n_Loot
{
/// <summary>
/// This is the main type for your game
/// </summary>
public class Game1 : Microsoft.Xna.Framework.Game
{
public static Point ScreenSize { get { return new Point(1200, 750); } }
public static Random random;
public static bool exit;
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
public Game1()
{
Window.Title = "Escape from Zombie Island";
graphics = new GraphicsDeviceManager(this);
graphics.PreferredBackBufferWidth = ScreenSize.X;
graphics.PreferredBackBufferHeight = ScreenSize.Y;
Content.RootDirectory = "Content";
IsMouseVisible = true;
}
/// <summary>
/// Allows the game to perform any initialization it needs to before starting to run.
/// This is where it can query for any required services and load any non-graphic
/// related content. Calling base.Initialize will enumerate through any components
/// and initialize them as well.
/// </summary>
protected override void Initialize()
{
Input.Initialize();
Camera.FollowSpeed = .3f;
Camera.Scale = 1;
Camera.Origin = new Vector2(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height) / (2 * Camera.Scale);
random = new Random();
Music music = new Music(Content.Load<Song>("track1"));
music.Initialize();
base.Initialize();
}
/// <summary>
/// LoadContent will be called once per game and is the place to load
/// all of your content.
/// </summary>
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
TextureManager.Load(Content);
SoundManager.Load(Content);
SceneManager.LoadAll();
}
/// <summary>
/// UnloadContent will be called once per game and is the place to unload
/// all content.
/// </summary>
protected override void UnloadContent()
{
}
/// <summary>
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Update(GameTime gameTime)
{
if (exit) Exit();
Input.Update();
SceneManager.CurrentScene.Update();
base.Update(gameTime);
}
/// <summary>
/// This is called when the game should draw itself.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(new Color(0, 3, 73));
spriteBatch.Begin(SpriteSortMode.BackToFront, null, null, null, null, null, Camera.Transform);
SceneManager.CurrentScene.Draw(spriteBatch);
spriteBatch.End();
base.Draw(gameTime);
}
}
}
| ShootnLootProgramerare/Shoot_n_Loot | Shoot 'n Loot/Shoot 'n Loot/Shoot 'n Loot/Game1.cs | C# | gpl-2.0 | 3,815 |
/* Name: usbdrv.c
* Project: AVR USB driver
* Author: Christian Starkjohann
* Creation Date: 2004-12-29
* Tabsize: 4
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
* License: GNU GPL v2 (see License.txt) or proprietary (CommercialLicense.txt)
* This Revision: $Id: usbdrv.c,v 1.1.1.1 2008-01-22 20:28:25 raph Exp $
*/
#include "iarcompat.h"
#ifndef __IAR_SYSTEMS_ICC__
# include <avr/io.h>
# include <avr/pgmspace.h>
#endif
#include "usbdrv.h"
#include "oddebug.h"
/*
General Description:
This module implements the C-part of the USB driver. See usbdrv.h for a
documentation of the entire driver.
*/
#ifndef IAR_SECTION
#define IAR_SECTION(arg)
#define __no_init
#endif
/* The macro IAR_SECTION is a hack to allow IAR-cc compatibility. On gcc, it
* is defined to nothing. __no_init is required on IAR.
*/
/* ------------------------------------------------------------------------- */
/* raw USB registers / interface to assembler code: */
uchar usbRxBuf[2*USB_BUFSIZE]; /* raw RX buffer: PID, 8 bytes data, 2 bytes CRC */
uchar usbInputBufOffset; /* offset in usbRxBuf used for low level receiving */
uchar usbDeviceAddr; /* assigned during enumeration, defaults to 0 */
uchar usbNewDeviceAddr; /* device ID which should be set after status phase */
uchar usbConfiguration; /* currently selected configuration. Administered by driver, but not used */
volatile schar usbRxLen; /* = 0; number of bytes in usbRxBuf; 0 means free, -1 for flow control */
uchar usbCurrentTok; /* last token received, if more than 1 rx endpoint: MSb=endpoint */
uchar usbRxToken; /* token for data we received; if more than 1 rx endpoint: MSb=endpoint */
uchar usbMsgLen = 0xff; /* remaining number of bytes, no msg to send if -1 (see usbMsgPtr) */
volatile uchar usbTxLen = USBPID_NAK; /* number of bytes to transmit with next IN token or handshake token */
uchar usbTxBuf[USB_BUFSIZE];/* data to transmit with next IN, free if usbTxLen contains handshake token */
# if USB_COUNT_SOF
volatile uchar usbSofCount; /* incremented by assembler module every SOF */
# endif
#if USB_CFG_HAVE_INTRIN_ENDPOINT
volatile uchar usbTxLen1 = USBPID_NAK; /* TX count for endpoint 1 */
uchar usbTxBuf1[USB_BUFSIZE]; /* TX data for endpoint 1 */
#if USB_CFG_HAVE_INTRIN_ENDPOINT3
volatile uchar usbTxLen3 = USBPID_NAK; /* TX count for endpoint 3 */
uchar usbTxBuf3[USB_BUFSIZE]; /* TX data for endpoint 3 */
#endif
#endif
/* USB status registers / not shared with asm code */
uchar *usbMsgPtr; /* data to transmit next -- ROM or RAM address */
static uchar usbMsgFlags; /* flag values see below */
#define USB_FLG_TX_PACKET (1<<0)
/* Leave free 6 bits after TX_PACKET. This way we can increment usbMsgFlags to toggle TX_PACKET */
#define USB_FLG_MSGPTR_IS_ROM (1<<6)
#define USB_FLG_USE_DEFAULT_RW (1<<7)
/*
optimizing hints:
- do not post/pre inc/dec integer values in operations
- assign value of PRG_RDB() to register variables and don't use side effects in arg
- use narrow scope for variables which should be in X/Y/Z register
- assign char sized expressions to variables to force 8 bit arithmetics
*/
/* ------------------------------------------------------------------------- */
#if USB_CFG_DESCR_PROPS_STRINGS == 0
#if USB_CFG_DESCR_PROPS_STRING_0 == 0
#undef USB_CFG_DESCR_PROPS_STRING_0
#define USB_CFG_DESCR_PROPS_STRING_0 sizeof(usbDescriptorString0)
PROGMEM const char usbDescriptorString0[] = { /* language descriptor */
4, /* sizeof(usbDescriptorString0): length of descriptor in bytes */
3, /* descriptor type */
0x09, 0x04, /* language index (0x0409 = US-English) */
};
#endif
#if USB_CFG_DESCR_PROPS_STRING_VENDOR == 0 && USB_CFG_VENDOR_NAME_LEN
#undef USB_CFG_DESCR_PROPS_STRING_VENDOR
#define USB_CFG_DESCR_PROPS_STRING_VENDOR sizeof(usbDescriptorStringVendor)
PROGMEM const int usbDescriptorStringVendor[] = {
USB_STRING_DESCRIPTOR_HEADER(USB_CFG_VENDOR_NAME_LEN),
USB_CFG_VENDOR_NAME
};
#endif
#if USB_CFG_DESCR_PROPS_STRING_PRODUCT == 0 && USB_CFG_DEVICE_NAME_LEN
#undef USB_CFG_DESCR_PROPS_STRING_PRODUCT
#define USB_CFG_DESCR_PROPS_STRING_PRODUCT sizeof(usbDescriptorStringDevice)
PROGMEM const int usbDescriptorStringDevice[] = {
USB_STRING_DESCRIPTOR_HEADER(USB_CFG_DEVICE_NAME_LEN),
USB_CFG_DEVICE_NAME
};
#endif
#if USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER == 0 && USB_CFG_SERIAL_NUMBER_LEN
#undef USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER
#define USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER sizeof(usbDescriptorStringSerialNumber)
PROGMEM int usbDescriptorStringSerialNumber[] = {
USB_STRING_DESCRIPTOR_HEADER(USB_CFG_SERIAL_NUMBER_LEN),
USB_CFG_SERIAL_NUMBER
};
#endif
#endif /* USB_CFG_DESCR_PROPS_STRINGS == 0 */
#if USB_CFG_DESCR_PROPS_DEVICE == 0
#undef USB_CFG_DESCR_PROPS_DEVICE
#define USB_CFG_DESCR_PROPS_DEVICE sizeof(usbDescriptorDevice)
PROGMEM char usbDescriptorDevice[] = { /* USB device descriptor */
18, /* sizeof(usbDescriptorDevice): length of descriptor in bytes */
USBDESCR_DEVICE, /* descriptor type */
0x10, 0x01, /* USB version supported */
USB_CFG_DEVICE_CLASS,
USB_CFG_DEVICE_SUBCLASS,
0, /* protocol */
8, /* max packet size */
USB_CFG_VENDOR_ID, /* 2 bytes */
USB_CFG_DEVICE_ID, /* 2 bytes */
USB_CFG_DEVICE_VERSION, /* 2 bytes */
USB_CFG_DESCR_PROPS_STRING_VENDOR != 0 ? 1 : 0, /* manufacturer string index */
USB_CFG_DESCR_PROPS_STRING_PRODUCT != 0 ? 2 : 0, /* product string index */
USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER != 0 ? 3 : 0, /* serial number string index */
1, /* number of configurations */
};
#endif
#if USB_CFG_DESCR_PROPS_HID_REPORT != 0 && USB_CFG_DESCR_PROPS_HID == 0
#undef USB_CFG_DESCR_PROPS_HID
#define USB_CFG_DESCR_PROPS_HID 9 /* length of HID descriptor in config descriptor below */
#endif
#if USB_CFG_DESCR_PROPS_CONFIGURATION == 0
#undef USB_CFG_DESCR_PROPS_CONFIGURATION
#define USB_CFG_DESCR_PROPS_CONFIGURATION sizeof(usbDescriptorConfiguration)
PROGMEM char usbDescriptorConfiguration[] = { /* USB configuration descriptor */
9, /* sizeof(usbDescriptorConfiguration): length of descriptor in bytes */
USBDESCR_CONFIG, /* descriptor type */
18 + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT + (USB_CFG_DESCR_PROPS_HID & 0xff), 0,
/* total length of data returned (including inlined descriptors) */
1, /* number of interfaces in this configuration */
1, /* index of this configuration */
0, /* configuration name string index */
#if USB_CFG_IS_SELF_POWERED
USBATTR_SELFPOWER, /* attributes */
#else
USBATTR_BUSPOWER, /* attributes */
#endif
USB_CFG_MAX_BUS_POWER/2, /* max USB current in 2mA units */
/* interface descriptor follows inline: */
9, /* sizeof(usbDescrInterface): length of descriptor in bytes */
USBDESCR_INTERFACE, /* descriptor type */
0, /* index of this interface */
0, /* alternate setting for this interface */
USB_CFG_HAVE_INTRIN_ENDPOINT, /* endpoints excl 0: number of endpoint descriptors to follow */
USB_CFG_INTERFACE_CLASS,
USB_CFG_INTERFACE_SUBCLASS,
USB_CFG_INTERFACE_PROTOCOL,
0, /* string index for interface */
#if (USB_CFG_DESCR_PROPS_HID & 0xff) /* HID descriptor */
9, /* sizeof(usbDescrHID): length of descriptor in bytes */
USBDESCR_HID, /* descriptor type: HID */
0x01, 0x01, /* BCD representation of HID version */
0x00, /* target country code */
0x01, /* number of HID Report (or other HID class) Descriptor infos to follow */
0x22, /* descriptor type: report */
USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH, 0, /* total length of report descriptor */
#endif
#if USB_CFG_HAVE_INTRIN_ENDPOINT /* endpoint descriptor for endpoint 1 */
7, /* sizeof(usbDescrEndpoint) */
USBDESCR_ENDPOINT, /* descriptor type = endpoint */
0x81, /* IN endpoint number 1 */
0x03, /* attrib: Interrupt endpoint */
8, 0, /* maximum packet size */
USB_CFG_INTR_POLL_INTERVAL, /* in ms */
#endif
};
#endif
/* We don't use prog_int or prog_int16_t for compatibility with various libc
* versions. Here's an other compatibility hack:
*/
#ifndef PRG_RDB
#define PRG_RDB(addr) pgm_read_byte(addr)
#endif
typedef union{
unsigned word;
uchar *ptr;
uchar bytes[2];
}converter_t;
/* We use this union to do type conversions. This is better optimized than
* type casts in gcc 3.4.3 and much better than using bit shifts to build
* ints from chars. Byte ordering is not a problem on an 8 bit platform.
*/
/* ------------------------------------------------------------------------- */
#if USB_CFG_HAVE_INTRIN_ENDPOINT
USB_PUBLIC void usbSetInterrupt(uchar *data, uchar len)
{
uchar *p, i;
#if USB_CFG_IMPLEMENT_HALT
if(usbTxLen1 == USBPID_STALL)
return;
#endif
#if 0 /* No runtime checks! Caller is responsible for valid data! */
if(len > 8) /* interrupt transfers are limited to 8 bytes */
len = 8;
#endif
if(usbTxLen1 & 0x10){ /* packet buffer was empty */
usbTxBuf1[0] ^= USBPID_DATA0 ^ USBPID_DATA1; /* toggle token */
}else{
usbTxLen1 = USBPID_NAK; /* avoid sending outdated (overwritten) interrupt data */
}
p = usbTxBuf1 + 1;
for(i=len;i--;)
*p++ = *data++;
usbCrc16Append(&usbTxBuf1[1], len);
usbTxLen1 = len + 4; /* len must be given including sync byte */
DBG2(0x21, usbTxBuf1, len + 3);
}
#endif
#if USB_CFG_HAVE_INTRIN_ENDPOINT3
USB_PUBLIC void usbSetInterrupt3(uchar *data, uchar len)
{
uchar *p, i;
if(usbTxLen3 & 0x10){ /* packet buffer was empty */
usbTxBuf3[0] ^= USBPID_DATA0 ^ USBPID_DATA1; /* toggle token */
}else{
usbTxLen3 = USBPID_NAK; /* avoid sending outdated (overwritten) interrupt data */
}
p = usbTxBuf3 + 1;
for(i=len;i--;)
*p++ = *data++;
usbCrc16Append(&usbTxBuf3[1], len);
usbTxLen3 = len + 4; /* len must be given including sync byte */
DBG2(0x23, usbTxBuf3, len + 3);
}
#endif
static uchar usbRead(uchar *data, uchar len)
{
#if USB_CFG_IMPLEMENT_FN_READ
if(usbMsgFlags & USB_FLG_USE_DEFAULT_RW){
#endif
uchar i = len, *r = usbMsgPtr;
if(usbMsgFlags & USB_FLG_MSGPTR_IS_ROM){ /* ROM data */
while(i--){
uchar c = PRG_RDB(r); /* assign to char size variable to enforce byte ops */
*data++ = c;
r++;
}
}else{ /* RAM data */
while(i--)
*data++ = *r++;
}
usbMsgPtr = r;
return len;
#if USB_CFG_IMPLEMENT_FN_READ
}else{
if(len != 0) /* don't bother app with 0 sized reads */
return usbFunctionRead(data, len);
return 0;
}
#endif
}
#define GET_DESCRIPTOR(cfgProp, staticName) \
if(cfgProp){ \
if((cfgProp) & USB_PROP_IS_RAM) \
flags &= ~USB_FLG_MSGPTR_IS_ROM; \
if((cfgProp) & USB_PROP_IS_DYNAMIC){ \
replyLen = usbFunctionDescriptor(rq); \
}else{ \
replyData = (uchar *)(staticName); \
SET_REPLY_LEN((cfgProp) & 0xff); \
} \
}
/* We use if() instead of #if in the macro above because #if can't be used
* in macros and the compiler optimizes constant conditions anyway.
*/
/* Don't make this function static to avoid inlining.
* The entire function would become too large and exceed the range of
* relative jumps.
* 2006-02-25: Either gcc 3.4.3 is better than the gcc used when the comment
* above was written, or other parts of the code have changed. We now get
* better results with an inlined function. Test condition: PowerSwitch code.
*/
static void usbProcessRx(uchar *data, uchar len)
{
usbRequest_t *rq = (void *)data;
uchar replyLen = 0, flags = USB_FLG_USE_DEFAULT_RW;
/* We use if() cascades because the compare is done byte-wise while switch()
* is int-based. The if() cascades are therefore more efficient.
*/
/* usbRxToken can be:
* 0x2d 00101101 (USBPID_SETUP for endpoint 0)
* 0xe1 11100001 (USBPID_OUT for endpoint 0)
* 0xff 11111111 (USBPID_OUT for endpoint 1)
*/
DBG2(0x10 + ((usbRxToken >> 1) & 3), data, len); /* SETUP0=12; OUT0=10; OUT1=13 */
#ifdef USB_RX_USER_HOOK
USB_RX_USER_HOOK(data, len)
#endif
#if USB_CFG_IMPLEMENT_FN_WRITEOUT
if(usbRxToken == 0xff){
usbFunctionWriteOut(data, len);
return; /* no reply expected, hence no usbMsgPtr, usbMsgFlags, usbMsgLen set */
}
#endif
if(usbRxToken == (uchar)USBPID_SETUP){
usbTxLen = USBPID_NAK; /* abort pending transmit */
if(len == 8){ /* Setup size must be always 8 bytes. Ignore otherwise. */
uchar type = rq->bmRequestType & USBRQ_TYPE_MASK;
if(type == USBRQ_TYPE_STANDARD){
#define SET_REPLY_LEN(len) replyLen = (len); usbMsgPtr = replyData
/* This macro ensures that replyLen and usbMsgPtr are always set in the same way.
* That allows optimization of common code in if() branches */
uchar *replyData = usbTxBuf + 9; /* there is 3 bytes free space at the end of the buffer */
replyData[0] = 0; /* common to USBRQ_GET_STATUS and USBRQ_GET_INTERFACE */
if(rq->bRequest == USBRQ_GET_STATUS){ /* 0 */
uchar __attribute__((__unused__)) recipient = rq->bmRequestType & USBRQ_RCPT_MASK; /* assign arith ops to variables to enforce byte size */
#if USB_CFG_IS_SELF_POWERED
if(recipient == USBRQ_RCPT_DEVICE)
replyData[0] = USB_CFG_IS_SELF_POWERED;
#endif
#if USB_CFG_HAVE_INTRIN_ENDPOINT && USB_CFG_IMPLEMENT_HALT
if(recipient == USBRQ_RCPT_ENDPOINT && rq->wIndex.bytes[0] == 0x81) /* request status for endpoint 1 */
replyData[0] = usbTxLen1 == USBPID_STALL;
#endif
replyData[1] = 0;
SET_REPLY_LEN(2);
}else if(rq->bRequest == USBRQ_SET_ADDRESS){ /* 5 */
usbNewDeviceAddr = rq->wValue.bytes[0];
}else if(rq->bRequest == USBRQ_GET_DESCRIPTOR){ /* 6 */
flags = USB_FLG_MSGPTR_IS_ROM | USB_FLG_USE_DEFAULT_RW;
if(rq->wValue.bytes[1] == USBDESCR_DEVICE){ /* 1 */
GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_DEVICE, usbDescriptorDevice)
}else if(rq->wValue.bytes[1] == USBDESCR_CONFIG){ /* 2 */
GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_CONFIGURATION, usbDescriptorConfiguration)
}else if(rq->wValue.bytes[1] == USBDESCR_STRING){ /* 3 */
#if USB_CFG_DESCR_PROPS_STRINGS & USB_PROP_IS_DYNAMIC
if(USB_CFG_DESCR_PROPS_STRINGS & USB_PROP_IS_RAM)
flags &= ~USB_FLG_MSGPTR_IS_ROM;
replyLen = usbFunctionDescriptor(rq);
#else /* USB_CFG_DESCR_PROPS_STRINGS & USB_PROP_IS_DYNAMIC */
if(rq->wValue.bytes[0] == 0){ /* descriptor index */
GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_STRING_0, usbDescriptorString0)
}else if(rq->wValue.bytes[0] == 1){
GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_STRING_VENDOR, usbDescriptorStringVendor)
}else if(rq->wValue.bytes[0] == 2){
GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_STRING_PRODUCT, usbDescriptorStringDevice)
}else if(rq->wValue.bytes[0] == 3){
GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER, usbDescriptorStringSerialNumber)
}else if(USB_CFG_DESCR_PROPS_UNKNOWN & USB_PROP_IS_DYNAMIC){
replyLen = usbFunctionDescriptor(rq);
}
#endif /* USB_CFG_DESCR_PROPS_STRINGS & USB_PROP_IS_DYNAMIC */
#if USB_CFG_DESCR_PROPS_HID_REPORT /* only support HID descriptors if enabled */
}else if(rq->wValue.bytes[1] == USBDESCR_HID){ /* 0x21 */
GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_HID, usbDescriptorConfiguration + 18)
}else if(rq->wValue.bytes[1] == USBDESCR_HID_REPORT){ /* 0x22 */
GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_HID_REPORT, usbDescriptorHidReport)
#endif /* USB_CFG_DESCR_PROPS_HID_REPORT */
}else if(USB_CFG_DESCR_PROPS_UNKNOWN & USB_PROP_IS_DYNAMIC){
replyLen = usbFunctionDescriptor(rq);
}
}else if(rq->bRequest == USBRQ_GET_CONFIGURATION){ /* 8 */
replyData = &usbConfiguration; /* send current configuration value */
SET_REPLY_LEN(1);
}else if(rq->bRequest == USBRQ_SET_CONFIGURATION){ /* 9 */
usbConfiguration = rq->wValue.bytes[0];
#if USB_CFG_IMPLEMENT_HALT
usbTxLen1 = USBPID_NAK;
#endif
}else if(rq->bRequest == USBRQ_GET_INTERFACE){ /* 10 */
SET_REPLY_LEN(1);
#if USB_CFG_HAVE_INTRIN_ENDPOINT
}else if(rq->bRequest == USBRQ_SET_INTERFACE){ /* 11 */
USB_SET_DATATOKEN1(USB_INITIAL_DATATOKEN); /* reset data toggling for interrupt endpoint */
# if USB_CFG_HAVE_INTRIN_ENDPOINT3
USB_SET_DATATOKEN3(USB_INITIAL_DATATOKEN); /* reset data toggling for interrupt endpoint */
# endif
# if USB_CFG_IMPLEMENT_HALT
usbTxLen1 = USBPID_NAK;
}else if(rq->bRequest == USBRQ_CLEAR_FEATURE || rq->bRequest == USBRQ_SET_FEATURE){ /* 1|3 */
if(rq->wValue.bytes[0] == 0 && rq->wIndex.bytes[0] == 0x81){ /* feature 0 == HALT for endpoint == 1 */
usbTxLen1 = rq->bRequest == USBRQ_CLEAR_FEATURE ? USBPID_NAK : USBPID_STALL;
USB_SET_DATATOKEN1(USB_INITIAL_DATATOKEN); /* reset data toggling for interrupt endpoint */
# if USB_CFG_HAVE_INTRIN_ENDPOINT3
USB_SET_DATATOKEN3(USB_INITIAL_DATATOKEN); /* reset data toggling for interrupt endpoint */
# endif
}
# endif
#endif
}else{
/* the following requests can be ignored, send default reply */
/* 1: CLEAR_FEATURE, 3: SET_FEATURE, 7: SET_DESCRIPTOR */
/* 12: SYNCH_FRAME */
}
#undef SET_REPLY_LEN
}else{ /* not a standard request -- must be vendor or class request */
replyLen = usbFunctionSetup(data);
}
#if USB_CFG_IMPLEMENT_FN_READ || USB_CFG_IMPLEMENT_FN_WRITE
if(replyLen == 0xff){ /* use user-supplied read/write function */
if((rq->bmRequestType & USBRQ_DIR_MASK) == USBRQ_DIR_DEVICE_TO_HOST){
replyLen = rq->wLength.bytes[0]; /* IN transfers only */
}
flags &= ~USB_FLG_USE_DEFAULT_RW; /* we have no valid msg, use user supplied read/write functions */
}else /* The 'else' prevents that we limit a replyLen of 0xff to the maximum transfer len. */
#endif
if(!rq->wLength.bytes[1] && replyLen > rq->wLength.bytes[0]) /* limit length to max */
replyLen = rq->wLength.bytes[0];
}
/* make sure that data packets which are sent as ACK to an OUT transfer are always zero sized */
}else{ /* DATA packet from out request */
#if USB_CFG_IMPLEMENT_FN_WRITE
if(!(usbMsgFlags & USB_FLG_USE_DEFAULT_RW)){
uchar rval = usbFunctionWrite(data, len);
replyLen = 0xff;
if(rval == 0xff){ /* an error occurred */
usbMsgLen = 0xff; /* cancel potentially pending data packet for ACK */
usbTxLen = USBPID_STALL;
}else if(rval != 0){ /* This was the final package */
replyLen = 0; /* answer with a zero-sized data packet */
}
flags = 0; /* start with a DATA1 package, stay with user supplied write() function */
}
#endif
}
usbMsgFlags = flags;
usbMsgLen = replyLen;
}
/* ------------------------------------------------------------------------- */
static void usbBuildTxBlock(void)
{
uchar wantLen, len, txLen, token;
wantLen = usbMsgLen;
if(wantLen > 8)
wantLen = 8;
usbMsgLen -= wantLen;
token = USBPID_DATA1;
if(usbMsgFlags & USB_FLG_TX_PACKET)
token = USBPID_DATA0;
usbMsgFlags++;
len = usbRead(usbTxBuf + 1, wantLen);
if(len <= 8){ /* valid data packet */
usbCrc16Append(&usbTxBuf[1], len);
txLen = len + 4; /* length including sync byte */
if(len < 8) /* a partial package identifies end of message */
usbMsgLen = 0xff;
}else{
txLen = USBPID_STALL; /* stall the endpoint */
usbMsgLen = 0xff;
}
usbTxBuf[0] = token;
usbTxLen = txLen;
DBG2(0x20, usbTxBuf, txLen-1);
}
static inline uchar isNotSE0(void)
{
uchar rval;
/* We want to do
* return (USBIN & USBMASK);
* here, but the compiler does int-expansion acrobatics.
* We can avoid this by assigning to a char-sized variable.
*/
rval = USBIN & USBMASK;
return rval;
}
/* ------------------------------------------------------------------------- */
USB_PUBLIC void usbPoll(void)
{
schar len;
uchar i;
if((len = usbRxLen) > 0){
/* We could check CRC16 here -- but ACK has already been sent anyway. If you
* need data integrity checks with this driver, check the CRC in your app
* code and report errors back to the host. Since the ACK was already sent,
* retries must be handled on application level.
* unsigned crc = usbCrc16(buffer + 1, usbRxLen - 3);
*/
usbProcessRx(usbRxBuf + USB_BUFSIZE + 1 - usbInputBufOffset, len - 3);
#if USB_CFG_HAVE_FLOWCONTROL
if(usbRxLen > 0) /* only mark as available if not inactivated */
usbRxLen = 0;
#else
usbRxLen = 0; /* mark rx buffer as available */
#endif
}
if(usbTxLen & 0x10){ /* transmit system idle */
if(usbMsgLen != 0xff){ /* transmit data pending? */
usbBuildTxBlock();
}
}
for(i = 10; i > 0; i--){
if(isNotSE0())
break;
}
if(i == 0){ /* RESET condition, called multiple times during reset */
usbNewDeviceAddr = 0;
usbDeviceAddr = 0;
#if USB_CFG_IMPLEMENT_HALT
usbTxLen1 = USBPID_NAK;
#if USB_CFG_HAVE_INTRIN_ENDPOINT3
usbTxLen3 = USBPID_NAK;
#endif
#endif
DBG1(0xff, 0, 0);
}
}
/* ------------------------------------------------------------------------- */
USB_PUBLIC void usbInit(void)
{
#if USB_INTR_CFG_SET != 0
USB_INTR_CFG |= USB_INTR_CFG_SET;
#endif
#if USB_INTR_CFG_CLR != 0
USB_INTR_CFG &= ~(USB_INTR_CFG_CLR);
#endif
USB_INTR_ENABLE |= (1 << USB_INTR_ENABLE_BIT);
#if USB_CFG_HAVE_INTRIN_ENDPOINT
USB_SET_DATATOKEN1(USB_INITIAL_DATATOKEN); /* reset data toggling for interrupt endpoint */
# if USB_CFG_HAVE_INTRIN_ENDPOINT3
USB_SET_DATATOKEN3(USB_INITIAL_DATATOKEN); /* reset data toggling for interrupt endpoint */
# endif
#endif
}
/* ------------------------------------------------------------------------- */
| sambrista/9-buttons-arcade-controller | usbdrv/usbdrv.c | C | gpl-2.0 | 23,890 |
package com.citypark.api.task;
import com.citypark.api.parser.CityParkStartPaymentParser;
import android.content.Context;
import android.os.AsyncTask;
import android.text.format.Time;
public class StopPaymentTask extends AsyncTask<Void, Void, Boolean> {
private Context context;
private String sessionId;
private String paymentProviderName;
private double latitude;
private double longitude;
private String operationStatus;
public StopPaymentTask(Context context,
String sessionId, String paymentProviderName, double latitude,
double longitude, String operationStatus) {
super();
this.context = context;
this.sessionId = sessionId;
this.paymentProviderName = paymentProviderName;
this.latitude = latitude;
this.longitude = longitude;
this.operationStatus = operationStatus;
}
@Override
protected Boolean doInBackground(Void... params) {
//update citypark through API on success or failure
CityParkStartPaymentParser parser = new CityParkStartPaymentParser(context, sessionId, paymentProviderName, latitude, longitude, operationStatus);
parser.parse();
return true;
}
}
| kruzel/citypark-android | src/com/citypark/api/task/StopPaymentTask.java | Java | gpl-2.0 | 1,144 |
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program 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
* of the License, or (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "graphics/fontman.h"
#include "backends/platform/tizen/form.h"
#include "backends/platform/tizen/system.h"
#include "backends/platform/tizen/graphics.h"
//
// TizenGraphicsManager
//
TizenGraphicsManager::TizenGraphicsManager(TizenAppForm *appForm) :
_appForm(appForm),
_eglDisplay(EGL_DEFAULT_DISPLAY),
_eglSurface(EGL_NO_SURFACE),
_eglConfig(NULL),
_eglContext(EGL_NO_CONTEXT),
_initState(true) {
assert(appForm != NULL);
_videoMode.fullscreen = true;
}
TizenGraphicsManager::~TizenGraphicsManager() {
logEntered();
if (_eglDisplay != EGL_NO_DISPLAY) {
eglMakeCurrent(_eglDisplay, NULL, NULL, NULL);
if (_eglContext != EGL_NO_CONTEXT) {
eglDestroyContext(_eglDisplay, _eglContext);
}
}
}
const Graphics::Font *TizenGraphicsManager::getFontOSD() {
return FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
}
bool TizenGraphicsManager::moveMouse(int16 &x, int16 &y) {
int16 currentX = _cursorState.x;
int16 currentY = _cursorState.y;
// save the current hardware coordinates
_cursorState.x = x;
_cursorState.y = y;
// return x/y as game coordinates
adjustMousePosition(x, y);
// convert current x/y to game coordinates
adjustMousePosition(currentX, currentY);
// return whether game coordinates have changed
return (currentX != x || currentY != y);
}
Common::List<Graphics::PixelFormat> TizenGraphicsManager::getSupportedFormats() const {
logEntered();
Common::List<Graphics::PixelFormat> res;
res.push_back(Graphics::PixelFormat(2, 4, 4, 4, 4, 12, 8, 4, 0));
res.push_back(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
res.push_back(Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0));
res.push_back(Graphics::PixelFormat::createFormatCLUT8());
return res;
}
bool TizenGraphicsManager::hasFeature(OSystem::Feature f) {
bool result = (f == OSystem::kFeatureFullscreenMode ||
f == OSystem::kFeatureVirtualKeyboard ||
OpenGLGraphicsManager::hasFeature(f));
return result;
}
void TizenGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) {
if (f == OSystem::kFeatureVirtualKeyboard && enable) {
_appForm->showKeypad();
} else {
OpenGLGraphicsManager::setFeatureState(f, enable);
}
}
void TizenGraphicsManager::setReady() {
_initState = false;
}
void TizenGraphicsManager::updateScreen() {
if (_transactionMode == kTransactionNone) {
internUpdateScreen();
}
}
bool TizenGraphicsManager::loadEgl() {
logEntered();
EGLint numConfigs = 1;
EGLint eglConfigList[] = {
EGL_RED_SIZE, 5,
EGL_GREEN_SIZE, 6,
EGL_BLUE_SIZE, 5,
EGL_ALPHA_SIZE, 0,
EGL_DEPTH_SIZE, 8,
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT,
EGL_NONE
};
EGLint eglContextList[] = {
EGL_CONTEXT_CLIENT_VERSION, 1,
EGL_NONE
};
eglBindAPI(EGL_OPENGL_ES_API);
if (_eglDisplay) {
unloadGFXMode();
}
_eglDisplay = eglGetDisplay((EGLNativeDisplayType) EGL_DEFAULT_DISPLAY);
if (EGL_NO_DISPLAY == _eglDisplay) {
systemError("eglGetDisplay() failed");
return false;
}
if (EGL_FALSE == eglInitialize(_eglDisplay, NULL, NULL) ||
EGL_SUCCESS != eglGetError()) {
systemError("eglInitialize() failed");
return false;
}
if (EGL_FALSE == eglChooseConfig(_eglDisplay, eglConfigList, &_eglConfig, 1, &numConfigs) ||
EGL_SUCCESS != eglGetError()) {
systemError("eglChooseConfig() failed");
return false;
}
if (!numConfigs) {
systemError("eglChooseConfig() failed. Matching config does not exist \n");
return false;
}
_eglSurface = eglCreateWindowSurface(_eglDisplay, _eglConfig, (EGLNativeWindowType)_appForm, NULL);
if (EGL_NO_SURFACE == _eglSurface || EGL_SUCCESS != eglGetError()) {
systemError("eglCreateWindowSurface() failed. EGL_NO_SURFACE");
return false;
}
_eglContext = eglCreateContext(_eglDisplay, _eglConfig, EGL_NO_CONTEXT, eglContextList);
if (EGL_NO_CONTEXT == _eglContext ||
EGL_SUCCESS != eglGetError()) {
systemError("eglCreateContext() failed");
return false;
}
if (false == eglMakeCurrent(_eglDisplay, _eglSurface, _eglSurface, _eglContext) ||
EGL_SUCCESS != eglGetError()) {
systemError("eglMakeCurrent() failed");
return false;
}
logLeaving();
return true;
}
bool TizenGraphicsManager::loadGFXMode() {
logEntered();
if (!loadEgl()) {
unloadGFXMode();
return false;
}
int x, y, width, height;
_appForm->GetBounds(x, y, width, height);
_videoMode.overlayWidth = _videoMode.hardwareWidth = width;
_videoMode.overlayHeight = _videoMode.hardwareHeight = height;
_videoMode.scaleFactor = 4; // for proportional sized cursor in the launcher
AppLog("screen size: %dx%d", _videoMode.hardwareWidth, _videoMode.hardwareHeight);
return OpenGLGraphicsManager::loadGFXMode();
}
void TizenGraphicsManager::loadTextures() {
logEntered();
OpenGLGraphicsManager::loadTextures();
}
void TizenGraphicsManager::internUpdateScreen() {
if (!_initState) {
OpenGLGraphicsManager::internUpdateScreen();
eglSwapBuffers(_eglDisplay, _eglSurface);
}
}
void TizenGraphicsManager::unloadGFXMode() {
logEntered();
if (_eglDisplay != EGL_NO_DISPLAY) {
eglMakeCurrent(_eglDisplay, NULL, NULL, NULL);
if (_eglContext != EGL_NO_CONTEXT) {
eglDestroyContext(_eglDisplay, _eglContext);
_eglContext = EGL_NO_CONTEXT;
}
if (_eglSurface != EGL_NO_SURFACE) {
eglDestroySurface(_eglDisplay, _eglSurface);
_eglSurface = EGL_NO_SURFACE;
}
eglTerminate(_eglDisplay);
_eglDisplay = EGL_NO_DISPLAY;
}
_eglConfig = NULL;
OpenGLGraphicsManager::unloadGFXMode();
logLeaving();
}
| nemomobile-apps/scummvm | backends/platform/tizen/graphics.cpp | C++ | gpl-2.0 | 6,444 |
# -*- coding: utf-8 -*-
"""
***************************************************************************
SplitRGBBands.py
---------------------
Date : August 2012
Copyright : (C) 2012 by Victor Olaya
Email : volayaf at gmail dot com
***************************************************************************
* *
* This program 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 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
from processing.tools.system import *
from processing.tools import dataobjects
from processing.saga.SagaUtils import SagaUtils
__author__ = 'Victor Olaya'
__date__ = 'August 2012'
__copyright__ = '(C) 2012, Victor Olaya'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from PyQt4 import QtGui
from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.parameters.ParameterRaster import ParameterRaster
from processing.outputs.OutputRaster import OutputRaster
import os
class SplitRGBBands(GeoAlgorithm):
INPUT = "INPUT"
R = "R"
G = "G"
B = "B"
def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/../images/saga.png")
def defineCharacteristics(self):
self.name = "Split RGB bands"
self.group = "Grid - Tools"
self.addParameter(ParameterRaster(SplitRGBBands.INPUT, "Input layer", False))
self.addOutput(OutputRaster(SplitRGBBands.R, "Output R band layer"))
self.addOutput(OutputRaster(SplitRGBBands.G, "Output G band layer"))
self.addOutput(OutputRaster(SplitRGBBands.B, "Output B band layer"))
def processAlgorithm(self, progress):
#TODO:check correct num of bands
input = self.getParameterValue(SplitRGBBands.INPUT)
temp = getTempFilename(None).replace('.','');
basename = os.path.basename(temp)
validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
safeBasename = ''.join(c for c in basename if c in validChars)
temp = os.path.join(os.path.dirname(temp), safeBasename)
r = self.getOutputValue(SplitRGBBands.R)
g = self.getOutputValue(SplitRGBBands.G)
b = self.getOutputValue(SplitRGBBands.B)
commands = []
if isWindows():
commands.append("io_gdal 0 -GRIDS \"" + temp + "\" -FILES \"" + input+"\"")
commands.append("io_gdal 1 -GRIDS \"" + temp + "_0001.sgrd\" -FORMAT 1 -TYPE 0 -FILE \"" + r + "\"");
commands.append("io_gdal 1 -GRIDS \"" + temp + "_0002.sgrd\" -FORMAT 1 -TYPE 0 -FILE \"" + g + "\"");
commands.append("io_gdal 1 -GRIDS \"" + temp + "_0003.sgrd\" -FORMAT 1 -TYPE 0 -FILE \"" + b + "\"");
else:
commands.append("libio_gdal 0 -GRIDS \"" + temp + "\" -FILES \"" + input + "\"")
commands.append("libio_gdal 1 -GRIDS \"" + temp + "_0001.sgrd\" -FORMAT 1 -TYPE 0 -FILE \"" + r + "\"");
commands.append("libio_gdal 1 -GRIDS \"" + temp + "_0002.sgrd\" -FORMAT 1 -TYPE 0 -FILE \"" + g + "\"");
commands.append("libio_gdal 1 -GRIDS \"" + temp + "_0003.sgrd\" -FORMAT 1 -TYPE 0 -FILE \"" + b + "\"");
SagaUtils.createSagaBatchJobFileFromSagaCommands(commands)
SagaUtils.executeSaga(progress);
| camptocamp/QGIS | python/plugins/processing/saga/SplitRGBBands.py | Python | gpl-2.0 | 3,715 |
# Copyright (C) 2016-2017 SUSE LLC
#
# This program 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 of the License, or
# (at your option) any later version.
#
# This program 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 this program; if not, see <http://www.gnu.org/licenses/>.
package OpenQA::WebAPI::Plugin::AMQP;
use strict;
use warnings;
use parent 'Mojolicious::Plugin';
use Cpanel::JSON::XS;
use Mojo::IOLoop;
use OpenQA::Utils;
use OpenQA::Jobs::Constants;
use OpenQA::Schema::Result::Jobs;
use Mojo::RabbitMQ::Client;
my @job_events = qw(job_create job_delete job_cancel job_duplicate job_restart job_update_result job_done);
my @comment_events = qw(comment_create comment_update comment_delete);
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
$self->{app} = undef;
$self->{config} = undef;
$self->{client} = undef;
$self->{channel} = undef;
$self->{reconnecting} = 0;
return $self;
}
sub register {
my $self = shift;
$self->{app} = shift;
$self->{config} = $self->{app}->config;
my $ioloop = Mojo::IOLoop->singleton;
$ioloop->next_tick(
sub {
$self->connect();
# register for events
for my $e (@job_events) {
$ioloop->on("openqa_$e" => sub { shift; $self->on_job_event(@_) });
}
for my $e (@comment_events) {
$ioloop->on("openqa_$e" => sub { shift; $self->on_comment_event(@_) });
}
});
}
sub reconnect {
my $self = shift;
return if $self->{reconnecting};
$self->{reconnecting} = 1;
OpenQA::Utils::log_info("AMQP reconnecting in $self->{config}->{amqp}{reconnect_timeout} seconds");
Mojo::IOLoop->timer(
$self->{config}->{amqp}{reconnect_timeout} => sub {
$self->{reconnecting} = 0;
$self->connect();
});
}
sub connect {
my $self = shift;
OpenQA::Utils::log_info("Connecting to AMQP server");
$self->{client} = Mojo::RabbitMQ::Client->new(url => $self->{config}->{amqp}{url});
$self->{client}->heartbeat_timeout($self->{config}->{amqp}{heartbeat_timeout} // 60);
$self->{client}->on(
open => sub {
OpenQA::Utils::log_info("AMQP connection established");
my ($client) = @_;
$self->{channel} = Mojo::RabbitMQ::Client::Channel->new();
$self->{channel}->catch(sub { OpenQA::Utils::log_warning("Error on AMQP channel received: " . $_[1]); });
$self->{channel}->on(
open => sub {
my ($channel) = @_;
$channel->declare_exchange(
exchange => $self->{config}->{amqp}{exchange},
type => 'topic',
passive => 1,
durable => 1
)->deliver();
});
$self->{channel}->on(
close => sub {
OpenQA::Utils::log_warning("AMQP channel closed");
});
$client->open_channel($self->{channel});
});
$self->{client}->on(
close => sub {
OpenQA::Utils::log_warning("AMQP connection closed");
$self->reconnect();
});
$self->{client}->on(
error => sub {
my ($client, $error) = @_;
OpenQA::Utils::log_warning("AMQP connection error: $error");
$self->reconnect();
});
$self->{client}->on(
disconnect => sub {
OpenQA::Utils::log_warning("AMQP connection closed");
$self->reconnect();
});
$self->{client}->on(
timeout => sub {
OpenQA::Utils::log_warning("AMQP connection closed");
$self->reconnect();
});
$self->{client}->connect();
}
sub log_event {
my ($self, $event, $event_data) = @_;
unless ($self->{channel} && $self->{channel}->is_open) {
OpenQA::Utils::log_warning("Error sending AMQP event: Channel is not open");
return;
}
# use dot separators
$event =~ s/_/\./;
$event =~ s/_/\./;
my $topic = $self->{config}->{amqp}{topic_prefix} . '.' . $event;
# convert data to JSON, with reliable key ordering (helps the tests)
$event_data = Cpanel::JSON::XS->new->canonical(1)->allow_blessed(1)->ascii(1)->encode($event_data);
OpenQA::Utils::log_debug("Sending AMQP event: $topic");
$self->{channel}->publish(
exchange => $self->{config}->{amqp}{exchange},
routing_key => $topic,
body => $event_data
)->deliver();
}
sub on_job_event {
my ($self, $args) = @_;
my ($user_id, $connection_id, $event, $event_data) = @$args;
# find count of pending jobs for the same build
# this is so we can tell when all tests for a build are done
my $job = $self->{app}->db->resultset('Jobs')->find({id => $event_data->{id}});
my $build = $job->BUILD;
$event_data->{group_id} = $job->group_id;
$event_data->{remaining} = $self->{app}->db->resultset('Jobs')->search(
{
'me.BUILD' => $build,
state => [OpenQA::Jobs::Constants::PENDING_STATES],
})->count;
# add various useful properties for consumers if not there already
for my $detail (qw(BUILD TEST ARCH MACHINE FLAVOR)) {
$event_data->{$detail} //= $job->$detail;
}
for my $detail (qw(ISO HDD_1)) {
$event_data->{$detail} //= $job->settings_hash->{$detail} if ($job->settings_hash->{$detail});
}
$self->log_event($event, $event_data);
}
sub on_comment_event {
my ($self, $args) = @_;
my ($comment_id, $connection_id, $event, $event_data) = @$args;
# find comment in database
my $comment = $self->{app}->db->resultset('Comments')->find($event_data->{id});
return unless $comment;
# just send the hash already used for JSON representation
my $hash = $comment->hash;
# also include comment id, job_id, and group_id
$hash->{id} = $comment->id;
$hash->{job_id} = $comment->job_id;
$hash->{group_id} = $comment->group_id;
$self->log_event($event, $hash);
}
1;
| mudler/openQA | lib/OpenQA/WebAPI/Plugin/AMQP.pm | Perl | gpl-2.0 | 6,591 |
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
*
* This program 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 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/// \addtogroup world The World
/// @{
/// \file
#ifndef __WORLD_H
#define __WORLD_H
#include "Common.h"
#include "Timer.h"
#include "Policies/Singleton.h"
#include "SharedDefines.h"
#include "ObjectLock.h"
#include "Util.h"
#include <map>
#include <set>
#include <list>
class Object;
class WorldPacket;
class WorldSession;
class Player;
class Weather;
class SqlResultQueue;
class QueryResult;
class WorldSocket;
// ServerMessages.dbc
enum ServerMessageType
{
SERVER_MSG_SHUTDOWN_TIME = 1,
SERVER_MSG_RESTART_TIME = 2,
SERVER_MSG_CUSTOM = 3,
SERVER_MSG_SHUTDOWN_CANCELLED = 4,
SERVER_MSG_RESTART_CANCELLED = 5,
SERVER_MSG_BG_SHUTDOWN_TIME = 6,
SERVER_MSG_BG_RESTART_TIME = 7,
SERVER_MSG_INSTANCE_SHUTDOWN_TIME = 8,
SERVER_MSG_INSTANCE_RESTART_TIME = 9,
};
enum ShutdownMask
{
SHUTDOWN_MASK_RESTART = 1,
SHUTDOWN_MASK_IDLE = 2,
};
enum ShutdownExitCode
{
SHUTDOWN_EXIT_CODE = 0,
ERROR_EXIT_CODE = 1,
RESTART_EXIT_CODE = 2,
};
/// Timers for different object refresh rates
enum WorldTimers
{
WUPDATE_AUCTIONS = 0,
WUPDATE_WEATHERS = 1,
WUPDATE_UPTIME = 2,
WUPDATE_CORPSES = 3,
WUPDATE_EVENTS = 4,
WUPDATE_DELETECHARS = 5,
WUPDATE_AHBOT = 6,
WUPDATE_AUTOBROADCAST = 7,
WUPDATE_WORLDSTATE = 8,
WUPDATE_COUNT = 9
};
/// Configuration elements
enum eConfigUInt32Values
{
CONFIG_UINT32_COMPRESSION = 0,
CONFIG_UINT32_INTERVAL_SAVE,
CONFIG_UINT32_INTERVAL_GRIDCLEAN,
CONFIG_UINT32_INTERVAL_MAPUPDATE,
CONFIG_UINT32_INTERVAL_CHANGEWEATHER,
CONFIG_UINT32_MAPUPDATE_MAXVISITORS,
CONFIG_UINT32_MAPUPDATE_MAXVISITS,
CONFIG_UINT32_PORT_WORLD,
CONFIG_UINT32_GAME_TYPE,
CONFIG_UINT32_REALM_ZONE,
CONFIG_UINT32_STRICT_PLAYER_NAMES,
CONFIG_UINT32_STRICT_CHARTER_NAMES,
CONFIG_UINT32_STRICT_PET_NAMES,
CONFIG_UINT32_MIN_PLAYER_NAME,
CONFIG_UINT32_MIN_CHARTER_NAME,
CONFIG_UINT32_MIN_PET_NAME,
CONFIG_UINT32_CHARACTERS_CREATING_DISABLED,
CONFIG_UINT32_CHARACTERS_PER_ACCOUNT,
CONFIG_UINT32_CHARACTERS_PER_REALM,
CONFIG_UINT32_HEROIC_CHARACTERS_PER_REALM,
CONFIG_UINT32_MIN_LEVEL_FOR_HEROIC_CHARACTER_CREATING,
CONFIG_UINT32_SKIP_CINEMATICS,
CONFIG_UINT32_MAX_PLAYER_LEVEL,
CONFIG_UINT32_START_PLAYER_LEVEL,
CONFIG_UINT32_START_HEROIC_PLAYER_LEVEL,
CONFIG_UINT32_START_PLAYER_MONEY,
CONFIG_UINT32_MAX_HONOR_POINTS,
CONFIG_UINT32_START_HONOR_POINTS,
CONFIG_UINT32_MAX_ARENA_POINTS,
CONFIG_UINT32_START_ARENA_POINTS,
CONFIG_UINT32_INSTANCE_RESET_TIME_HOUR,
CONFIG_UINT32_INSTANCE_UNLOAD_DELAY,
CONFIG_UINT32_MAX_SPELL_CASTS_IN_CHAIN,
CONFIG_UINT32_BIRTHDAY_TIME,
CONFIG_UINT32_MAX_PRIMARY_TRADE_SKILL,
CONFIG_UINT32_TRADE_SKILL_GMIGNORE_MAX_PRIMARY_COUNT,
CONFIG_UINT32_TRADE_SKILL_GMIGNORE_LEVEL,
CONFIG_UINT32_TRADE_SKILL_GMIGNORE_SKILL,
CONFIG_UINT32_MIN_PETITION_SIGNS,
CONFIG_UINT32_GM_LOGIN_STATE,
CONFIG_UINT32_GM_VISIBLE_STATE,
CONFIG_UINT32_GM_ACCEPT_TICKETS,
CONFIG_UINT32_GM_CHAT,
CONFIG_UINT32_GM_WISPERING_TO,
CONFIG_UINT32_GM_LEVEL_IN_GM_LIST,
CONFIG_UINT32_GM_LEVEL_IN_WHO_LIST,
CONFIG_UINT32_START_GM_LEVEL,
CONFIG_UINT32_GM_INVISIBLE_AURA,
CONFIG_UINT32_GROUP_VISIBILITY,
CONFIG_UINT32_MAIL_DELIVERY_DELAY,
CONFIG_UINT32_MASS_MAILER_SEND_PER_TICK,
CONFIG_UINT32_UPTIME_UPDATE,
CONFIG_UINT32_AUCTION_DEPOSIT_MIN,
CONFIG_UINT32_SKILL_CHANCE_ORANGE,
CONFIG_UINT32_SKILL_CHANCE_YELLOW,
CONFIG_UINT32_SKILL_CHANCE_GREEN,
CONFIG_UINT32_SKILL_CHANCE_GREY,
CONFIG_UINT32_SKILL_CHANCE_MINING_STEPS,
CONFIG_UINT32_SKILL_CHANCE_SKINNING_STEPS,
CONFIG_UINT32_SKILL_GAIN_CRAFTING,
CONFIG_UINT32_SKILL_GAIN_DEFENSE,
CONFIG_UINT32_SKILL_GAIN_GATHERING,
CONFIG_UINT32_SKILL_GAIN_WEAPON,
CONFIG_UINT32_MAX_OVERSPEED_PINGS,
CONFIG_UINT32_EXPANSION,
CONFIG_UINT32_CHATFLOOD_MESSAGE_COUNT,
CONFIG_UINT32_CHATFLOOD_MESSAGE_DELAY,
CONFIG_UINT32_CHATFLOOD_MUTE_TIME,
CONFIG_UINT32_CREATURE_FAMILY_ASSISTANCE_DELAY,
CONFIG_UINT32_CREATURE_FAMILY_FLEE_DELAY,
CONFIG_UINT32_WORLD_BOSS_LEVEL_DIFF,
CONFIG_UINT32_QUEST_DAILY_RESET_HOUR,
CONFIG_UINT32_QUEST_WEEKLY_RESET_WEEK_DAY,
CONFIG_UINT32_QUEST_WEEKLY_RESET_HOUR,
CONFIG_UINT32_CHAT_STRICT_LINK_CHECKING_SEVERITY,
CONFIG_UINT32_CHAT_STRICT_LINK_CHECKING_KICK,
CONFIG_UINT32_CORPSE_DECAY_NORMAL,
CONFIG_UINT32_CORPSE_DECAY_RARE,
CONFIG_UINT32_CORPSE_DECAY_ELITE,
CONFIG_UINT32_CORPSE_DECAY_RAREELITE,
CONFIG_UINT32_CORPSE_DECAY_WORLDBOSS,
CONFIG_UINT32_INSTANT_LOGOUT,
CONFIG_UINT32_BATTLEGROUND_INVITATION_TYPE,
CONFIG_UINT32_BATTLEGROUND_PREMATURE_FINISH_TIMER,
CONFIG_UINT32_BATTLEGROUND_PREMADE_GROUP_WAIT_FOR_MATCH,
CONFIG_UINT32_BATTLEGROUND_QUEUE_ANNOUNCER_JOIN,
CONFIG_UINT32_ARENA_MAX_RATING_DIFFERENCE,
CONFIG_UINT32_ARENA_RATING_DISCARD_TIMER,
CONFIG_UINT32_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS,
CONFIG_UINT32_CLIENTCACHE_VERSION,
CONFIG_UINT32_GUILD_EVENT_LOG_COUNT,
CONFIG_UINT32_GUILD_BANK_EVENT_LOG_COUNT,
CONFIG_UINT32_TIMERBAR_FATIGUE_GMLEVEL,
CONFIG_UINT32_TIMERBAR_FATIGUE_MAX,
CONFIG_UINT32_TIMERBAR_BREATH_GMLEVEL,
CONFIG_UINT32_TIMERBAR_BREATH_MAX,
CONFIG_UINT32_TIMERBAR_FIRE_GMLEVEL,
CONFIG_UINT32_TIMERBAR_FIRE_MAX,
CONFIG_UINT32_MIN_LEVEL_STAT_SAVE,
CONFIG_UINT32_CHARDELETE_KEEP_DAYS,
CONFIG_UINT32_CHARDELETE_METHOD,
CONFIG_UINT32_CHARDELETE_MIN_LEVEL,
CONFIG_UINT32_GUID_RESERVE_SIZE_CREATURE,
CONFIG_UINT32_GUID_RESERVE_SIZE_GAMEOBJECT,
CONFIG_UINT32_ANTICHEAT_GMLEVEL,
CONFIG_UINT32_ANTICHEAT_ACTION_DELAY,
CONFIG_UINT32_NUMTHREADS,
CONFIG_UINT32_RANDOM_BG_RESET_HOUR,
CONFIG_UINT32_LOSERNOCHANGE,
CONFIG_UINT32_LOSERHALFCHANGE,
CONFIG_UINT32_RAF_MAXGRANTLEVEL,
CONFIG_UINT32_RAF_MAXREFERALS,
CONFIG_UINT32_RAF_MAXREFERERS,
CONFIG_UINT32_LFG_MAXKICKS,
CONFIG_UINT32_MIN_LEVEL_FOR_RAID,
CONFIG_UINT32_PLAYERBOT_MAXBOTS,
CONFIG_UINT32_PLAYERBOT_RESTRICTLEVEL,
CONFIG_UINT32_PLAYERBOT_MINBOTLEVEL,
CONFIG_UINT32_GEAR_CALC_BASE,
CONFIG_UINT32_ARENA_AURAS_DURATION,
CONFIG_UINT32_VMSS_MAXTHREADBREAKS,
CONFIG_UINT32_VMSS_TBREMTIME,
CONFIG_UINT32_VMSS_MAPFREEMETHOD,
CONFIG_UINT32_VMSS_FREEZECHECKPERIOD,
CONFIG_UINT32_VMSS_FREEZEDETECTTIME,
CONFIG_UINT32_VMSS_FORCEUNLOADDELAY,
CONFIG_UINT32_WORLD_STATE_EXPIRETIME,
CONFIG_UINT32_VALUE_COUNT
};
/// Configuration elements
enum eConfigInt32Values
{
CONFIG_INT32_DEATH_SICKNESS_LEVEL = 0,
CONFIG_INT32_ARENA_STARTRATING,
CONFIG_INT32_ARENA_STARTPERSONALRATING,
CONFIG_INT32_QUEST_LOW_LEVEL_HIDE_DIFF,
CONFIG_INT32_QUEST_HIGH_LEVEL_HIDE_DIFF,
CONFIG_INT32_VALUE_COUNT
};
/// Server config
enum eConfigFloatValues
{
CONFIG_FLOAT_RATE_HEALTH = 0,
CONFIG_FLOAT_RATE_POWER_MANA,
CONFIG_FLOAT_RATE_POWER_RAGE_INCOME,
CONFIG_FLOAT_RATE_POWER_RAGE_LOSS,
CONFIG_FLOAT_RATE_POWER_RUNICPOWER_INCOME,
CONFIG_FLOAT_RATE_POWER_RUNICPOWER_LOSS,
CONFIG_FLOAT_RATE_POWER_FOCUS,
CONFIG_FLOAT_RATE_POWER_ENERGY,
CONFIG_FLOAT_RATE_SKILL_DISCOVERY,
CONFIG_FLOAT_RATE_DROP_ITEM_POOR,
CONFIG_FLOAT_RATE_DROP_ITEM_NORMAL,
CONFIG_FLOAT_RATE_DROP_ITEM_UNCOMMON,
CONFIG_FLOAT_RATE_DROP_ITEM_RARE,
CONFIG_FLOAT_RATE_DROP_ITEM_EPIC,
CONFIG_FLOAT_RATE_DROP_ITEM_LEGENDARY,
CONFIG_FLOAT_RATE_DROP_ITEM_ARTIFACT,
CONFIG_FLOAT_RATE_DROP_ITEM_REFERENCED,
CONFIG_FLOAT_RATE_DROP_MONEY,
CONFIG_FLOAT_RATE_XP_KILL,
CONFIG_FLOAT_RATE_XP_QUEST,
CONFIG_FLOAT_RATE_XP_EXPLORE,
CONFIG_FLOAT_RATE_RAF_XP,
CONFIG_FLOAT_RATE_RAF_LEVELPERLEVEL,
CONFIG_FLOAT_RATE_REPUTATION_GAIN,
CONFIG_FLOAT_RATE_REPUTATION_LOWLEVEL_KILL,
CONFIG_FLOAT_RATE_REPUTATION_LOWLEVEL_QUEST,
CONFIG_FLOAT_RATE_CREATURE_NORMAL_HP,
CONFIG_FLOAT_RATE_CREATURE_ELITE_ELITE_HP,
CONFIG_FLOAT_RATE_CREATURE_ELITE_RAREELITE_HP,
CONFIG_FLOAT_RATE_CREATURE_ELITE_WORLDBOSS_HP,
CONFIG_FLOAT_RATE_CREATURE_ELITE_RARE_HP,
CONFIG_FLOAT_RATE_CREATURE_NORMAL_DAMAGE,
CONFIG_FLOAT_RATE_CREATURE_ELITE_ELITE_DAMAGE,
CONFIG_FLOAT_RATE_CREATURE_ELITE_RAREELITE_DAMAGE,
CONFIG_FLOAT_RATE_CREATURE_ELITE_WORLDBOSS_DAMAGE,
CONFIG_FLOAT_RATE_CREATURE_ELITE_RARE_DAMAGE,
CONFIG_FLOAT_RATE_CREATURE_NORMAL_SPELLDAMAGE,
CONFIG_FLOAT_RATE_CREATURE_ELITE_ELITE_SPELLDAMAGE,
CONFIG_FLOAT_RATE_CREATURE_ELITE_RAREELITE_SPELLDAMAGE,
CONFIG_FLOAT_RATE_CREATURE_ELITE_WORLDBOSS_SPELLDAMAGE,
CONFIG_FLOAT_RATE_CREATURE_ELITE_RARE_SPELLDAMAGE,
CONFIG_FLOAT_RATE_CREATURE_AGGRO,
CONFIG_FLOAT_RATE_REST_INGAME,
CONFIG_FLOAT_RATE_REST_OFFLINE_IN_TAVERN_OR_CITY,
CONFIG_FLOAT_RATE_REST_OFFLINE_IN_WILDERNESS,
CONFIG_FLOAT_RATE_DAMAGE_FALL,
CONFIG_FLOAT_RATE_AUCTION_TIME,
CONFIG_FLOAT_RATE_AUCTION_DEPOSIT,
CONFIG_FLOAT_RATE_AUCTION_CUT,
CONFIG_FLOAT_RATE_HONOR,
CONFIG_FLOAT_RATE_MINING_AMOUNT,
CONFIG_FLOAT_RATE_MINING_NEXT,
CONFIG_FLOAT_RATE_TALENT,
CONFIG_FLOAT_RATE_CORPSE_DECAY_LOOTED,
CONFIG_FLOAT_RATE_INSTANCE_RESET_TIME,
CONFIG_FLOAT_RATE_TARGET_POS_RECALCULATION_RANGE,
CONFIG_FLOAT_RATE_DURABILITY_LOSS_DAMAGE,
CONFIG_FLOAT_RATE_DURABILITY_LOSS_PARRY,
CONFIG_FLOAT_RATE_DURABILITY_LOSS_ABSORB,
CONFIG_FLOAT_RATE_DURABILITY_LOSS_BLOCK,
CONFIG_FLOAT_SIGHT_GUARDER,
CONFIG_FLOAT_SIGHT_MONSTER,
CONFIG_FLOAT_LISTEN_RANGE_SAY,
CONFIG_FLOAT_LISTEN_RANGE_YELL,
CONFIG_FLOAT_LISTEN_RANGE_TEXTEMOTE,
CONFIG_FLOAT_CREATURE_FAMILY_FLEE_ASSISTANCE_RADIUS,
CONFIG_FLOAT_CREATURE_FAMILY_ASSISTANCE_RADIUS,
CONFIG_FLOAT_GROUP_XP_DISTANCE,
CONFIG_FLOAT_THREAT_RADIUS,
CONFIG_FLOAT_GHOST_RUN_SPEED_WORLD,
CONFIG_FLOAT_GHOST_RUN_SPEED_BG,
CONFIG_FLOAT_PLAYERBOT_MINDISTANCE,
CONFIG_FLOAT_PLAYERBOT_MAXDISTANCE,
CONFIG_FLOAT_CROWDCONTROL_HP_BASE,
CONFIG_FLOAT_LOADBALANCE_HIGHVALUE,
CONFIG_FLOAT_LOADBALANCE_LOWVALUE,
CONFIG_FLOAT_VALUE_COUNT
};
/// Configuration elements
enum eConfigBoolValues
{
CONFIG_BOOL_GRID_UNLOAD = 0,
CONFIG_BOOL_SAVE_RESPAWN_TIME_IMMEDIATELY,
CONFIG_BOOL_OFFHAND_CHECK_AT_TALENTS_RESET,
CONFIG_BOOL_ALLOW_TWO_SIDE_ACCOUNTS,
CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHAT,
CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHANNEL,
CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_GROUP,
CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_GUILD,
CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_AUCTION,
CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_MAIL,
CONFIG_BOOL_ALLOW_TWO_SIDE_WHO_LIST,
CONFIG_BOOL_ALLOW_TWO_SIDE_ADD_FRIEND,
CONFIG_BOOL_INSTANCE_IGNORE_LEVEL,
CONFIG_BOOL_INSTANCE_IGNORE_RAID,
CONFIG_BOOL_CAST_UNSTUCK,
CONFIG_BOOL_GM_LOG_TRADE,
CONFIG_BOOL_GM_LOWER_SECURITY,
CONFIG_BOOL_GM_ALLOW_ACHIEVEMENT_GAINS,
CONFIG_BOOL_GM_ANNOUNCE_BAN,
CONFIG_BOOL_SKILL_PROSPECTING,
CONFIG_BOOL_ALWAYS_MAX_SKILL_FOR_LEVEL,
CONFIG_BOOL_WEATHER,
CONFIG_BOOL_EVENT_ANNOUNCE,
CONFIG_BOOL_QUEST_IGNORE_RAID,
CONFIG_BOOL_DETECT_POS_COLLISION,
CONFIG_BOOL_RESTRICTED_LFG_CHANNEL,
CONFIG_BOOL_SILENTLY_GM_JOIN_TO_CHANNEL,
CONFIG_BOOL_TALENTS_INSPECTING,
CONFIG_BOOL_CHAT_FAKE_MESSAGE_PREVENTING,
CONFIG_BOOL_CHAT_STRICT_LINK_CHECKING_SEVERITY,
CONFIG_BOOL_CHAT_STRICT_LINK_CHECKING_KICK,
CONFIG_BOOL_ADDON_CHANNEL,
CONFIG_BOOL_CORPSE_EMPTY_LOOT_SHOW,
CONFIG_BOOL_DEATH_CORPSE_RECLAIM_DELAY_PVP,
CONFIG_BOOL_DEATH_CORPSE_RECLAIM_DELAY_PVE,
CONFIG_BOOL_DEATH_BONES_WORLD,
CONFIG_BOOL_DEATH_BONES_BG_OR_ARENA,
CONFIG_BOOL_ALL_TAXI_PATHS,
CONFIG_BOOL_DECLINED_NAMES_USED,
CONFIG_BOOL_SKILL_MILLING,
CONFIG_BOOL_SKILL_FAIL_LOOT_FISHING,
CONFIG_BOOL_SKILL_FAIL_GAIN_FISHING,
CONFIG_BOOL_SKILL_FAIL_POSSIBLE_FISHINGPOOL,
CONFIG_BOOL_BATTLEGROUND_CAST_DESERTER,
CONFIG_BOOL_BATTLEGROUND_QUEUE_ANNOUNCER_START,
CONFIG_BOOL_ARENA_AUTO_DISTRIBUTE_POINTS,
CONFIG_BOOL_ARENA_QUEUE_ANNOUNCER_JOIN,
CONFIG_BOOL_ARENA_QUEUE_ANNOUNCER_EXIT,
CONFIG_BOOL_ARENA_QUEUE_ANNOUNCER_START,
CONFIG_BOOL_OUTDOORPVP_SI_ENABLED,
CONFIG_BOOL_OUTDOORPVP_EP_ENABLED,
CONFIG_BOOL_OUTDOORPVP_HP_ENABLED,
CONFIG_BOOL_OUTDOORPVP_ZM_ENABLED,
CONFIG_BOOL_OUTDOORPVP_TF_ENABLED,
CONFIG_BOOL_OUTDOORPVP_NA_ENABLED,
CONFIG_BOOL_OUTDOORPVP_GH_ENABLED,
CONFIG_BOOL_OUTDOORPVP_WG_ENABLED,
CONFIG_BOOL_KICK_PLAYER_ON_BAD_PACKET,
CONFIG_BOOL_STATS_SAVE_ONLY_ON_LOGOUT,
CONFIG_BOOL_CLEAN_CHARACTER_DB,
CONFIG_BOOL_VMAP_INDOOR_CHECK,
CONFIG_BOOL_LOOT_CHESTS_IGNORE_DB,
CONFIG_BOOL_PET_UNSUMMON_AT_MOUNT,
CONFIG_BOOL_RAID_FLAGS_UNIQUE,
CONFIG_BOOL_ANTICHEAT_ENABLE,
CONFIG_BOOL_ANTICHEAT_WARDEN,
CONFIG_BOOL_ALLOW_FLIGHT_ON_OLD_MAPS,
CONFIG_BOOL_LFG_ENABLE,
CONFIG_BOOL_LFR_ENABLE,
CONFIG_BOOL_LFG_DEBUG_ENABLE,
CONFIG_BOOL_LFR_EXTEND,
CONFIG_BOOL_LFG_ONLYLASTENCOUNTER,
CONFIG_BOOL_PLAYERBOT_DISABLE,
CONFIG_BOOL_PLAYERBOT_DEBUGWHISPER,
CONFIG_BOOL_PLAYERBOT_SHAREDBOTS,
CONFIG_BOOL_ALLOW_CUSTOM_MAPS,
CONFIG_BOOL_ALLOW_HONOR_KILLS_TITLES,
CONFIG_BOOL_PET_SAVE_ALL,
CONFIG_BOOL_THREADS_DYNAMIC,
CONFIG_BOOL_VMSS_ENABLE,
CONFIG_BOOL_VMSS_TRYSKIPFIRST,
CONFIG_BOOL_PLAYERBOT_ALLOW_SUMMON_OPPOSITE_FACTION,
CONFIG_BOOL_PLAYERBOT_COLLECT_COMBAT,
CONFIG_BOOL_PLAYERBOT_COLLECT_QUESTS,
CONFIG_BOOL_PLAYERBOT_COLLECT_PROFESSION,
CONFIG_BOOL_PLAYERBOT_COLLECT_LOOT,
CONFIG_BOOL_PLAYERBOT_COLLECT_SKIN,
CONFIG_BOOL_PLAYERBOT_COLLECT_OBJECTS,
CONFIG_BOOL_PLAYERBOT_SELL_TRASH,
CONFIG_BOOL_MMAP_ENABLED,
CONFIG_BOOL_RESET_DUEL_AREA_ENABLED,
CONFIG_BOOL_PET_ADVANCED_AI,
CONFIG_BOOL_RESILENCE_ALTERNATIVE_CALCULATION,
CONFIG_BOOL_VALUE_COUNT
};
/// Can be used in SMSG_AUTH_RESPONSE packet
enum BillingPlanFlags
{
SESSION_NONE = 0x00,
SESSION_UNUSED = 0x01,
SESSION_RECURRING_BILL = 0x02,
SESSION_FREE_TRIAL = 0x04,
SESSION_IGR = 0x08,
SESSION_USAGE = 0x10,
SESSION_TIME_MIXTURE = 0x20,
SESSION_RESTRICTED = 0x40,
SESSION_ENABLE_CAIS = 0x80,
};
/// Type of server, this is values from second column of Cfg_Configs.dbc (1.12.1 have another numeration)
enum RealmType
{
REALM_TYPE_NORMAL = 0,
REALM_TYPE_PVP = 1,
REALM_TYPE_NORMAL2 = 4,
REALM_TYPE_RP = 6,
REALM_TYPE_RPPVP = 8,
REALM_TYPE_FFA_PVP = 16 // custom, free for all pvp mode like arena PvP in all zones except rest activated places and sanctuaries
// replaced by REALM_PVP in realm list
};
/// This is values from first column of Cfg_Categories.dbc (1.12.1 have another numeration)
enum RealmZone
{
REALM_ZONE_UNKNOWN = 0, // any language
REALM_ZONE_DEVELOPMENT = 1, // any language
REALM_ZONE_UNITED_STATES = 2, // extended-Latin
REALM_ZONE_OCEANIC = 3, // extended-Latin
REALM_ZONE_LATIN_AMERICA = 4, // extended-Latin
REALM_ZONE_TOURNAMENT_5 = 5, // basic-Latin at create, any at login
REALM_ZONE_KOREA = 6, // East-Asian
REALM_ZONE_TOURNAMENT_7 = 7, // basic-Latin at create, any at login
REALM_ZONE_ENGLISH = 8, // extended-Latin
REALM_ZONE_GERMAN = 9, // extended-Latin
REALM_ZONE_FRENCH = 10, // extended-Latin
REALM_ZONE_SPANISH = 11, // extended-Latin
REALM_ZONE_RUSSIAN = 12, // Cyrillic
REALM_ZONE_TOURNAMENT_13 = 13, // basic-Latin at create, any at login
REALM_ZONE_TAIWAN = 14, // East-Asian
REALM_ZONE_TOURNAMENT_15 = 15, // basic-Latin at create, any at login
REALM_ZONE_CHINA = 16, // East-Asian
REALM_ZONE_CN1 = 17, // basic-Latin at create, any at login
REALM_ZONE_CN2 = 18, // basic-Latin at create, any at login
REALM_ZONE_CN3 = 19, // basic-Latin at create, any at login
REALM_ZONE_CN4 = 20, // basic-Latin at create, any at login
REALM_ZONE_CN5 = 21, // basic-Latin at create, any at login
REALM_ZONE_CN6 = 22, // basic-Latin at create, any at login
REALM_ZONE_CN7 = 23, // basic-Latin at create, any at login
REALM_ZONE_CN8 = 24, // basic-Latin at create, any at login
REALM_ZONE_TOURNAMENT_25 = 25, // basic-Latin at create, any at login
REALM_ZONE_TEST_SERVER = 26, // any language
REALM_ZONE_TOURNAMENT_27 = 27, // basic-Latin at create, any at login
REALM_ZONE_QA_SERVER = 28, // any language
REALM_ZONE_CN9 = 29, // basic-Latin at create, any at login
REALM_ZONE_TEST_SERVER_2 = 30, // any language
// in 3.x
REALM_ZONE_CN10 = 31, // basic-Latin at create, any at login
REALM_ZONE_CTC = 32,
REALM_ZONE_CNC = 33,
REALM_ZONE_CN1_4 = 34, // basic-Latin at create, any at login
REALM_ZONE_CN2_6_9 = 35, // basic-Latin at create, any at login
REALM_ZONE_CN3_7 = 36, // basic-Latin at create, any at login
REALM_ZONE_CN5_8 = 37 // basic-Latin at create, any at login
};
/// Storage class for commands issued for delayed execution
struct CliCommandHolder
{
typedef void Print(void*, const char*);
typedef void CommandFinished(void*, bool success);
uint32 m_cliAccountId; // 0 for console and real account id for RA/soap
AccountTypes m_cliAccessLevel;
void* m_callbackArg;
char *m_command;
Print* m_print;
CommandFinished* m_commandFinished;
CliCommandHolder(uint32 accountId, AccountTypes cliAccessLevel, void* callbackArg, const char *command, Print* zprint, CommandFinished* commandFinished)
: m_cliAccountId(accountId), m_cliAccessLevel(cliAccessLevel), m_callbackArg(callbackArg), m_print(zprint), m_commandFinished(commandFinished)
{
size_t len = strlen(command)+1;
m_command = new char[len];
memcpy(m_command, command, len);
}
~CliCommandHolder() { delete[] m_command; }
};
/// The World
class World
{
public:
static volatile uint32 m_worldLoopCounter;
World();
~World();
WorldSession* FindSession(uint32 id) const;
void AddSession(WorldSession *s);
void SendBroadcast();
bool RemoveSession(uint32 id);
/// Get the number of current active sessions
void UpdateMaxSessionCounters();
uint32 GetActiveAndQueuedSessionCount() const { return m_sessions.size(); }
uint32 GetActiveSessionCount() const { return m_sessions.size() - m_QueuedSessions.size(); }
uint32 GetQueuedSessionCount() const { return m_QueuedSessions.size(); }
/// Get the maximum number of parallel sessions on the server since last reboot
uint32 GetMaxQueuedSessionCount() const { return m_maxQueuedSessionCount; }
uint32 GetMaxActiveSessionCount() const { return m_maxActiveSessionCount; }
Player* FindPlayerInZone(uint32 zone);
Weather* FindWeather(uint32 id) const;
Weather* AddWeather(uint32 zone_id);
void RemoveWeather(uint32 zone_id);
/// Get the active session server limit (or security level limitations)
uint32 GetPlayerAmountLimit() const { return m_playerLimit >= 0 ? m_playerLimit : 0; }
AccountTypes GetPlayerSecurityLimit() const { return m_playerLimit <= 0 ? AccountTypes(-m_playerLimit) : SEC_PLAYER; }
/// Set the active session server limit (or security level limitation)
void SetPlayerLimit(int32 limit, bool needUpdate = false);
//player Queue
typedef std::list<WorldSession*> Queue;
void AddQueuedSession(WorldSession*);
bool RemoveQueuedSession(WorldSession* session);
int32 GetQueuedSessionPos(WorldSession*);
/// \todo Actions on m_allowMovement still to be implemented
/// Is movement allowed?
bool getAllowMovement() const { return m_allowMovement; }
/// Allow/Disallow object movements
void SetAllowMovement(bool allow) { m_allowMovement = allow; }
/// Set a new Message of the Day
void SetMotd(const std::string& motd) { m_motd = motd; }
/// Get the current Message of the Day
const char* GetMotd() const { return m_motd.c_str(); }
LocaleConstant GetDefaultDbcLocale() const { return m_defaultDbcLocale; }
/// Get the path where data (dbc, maps) are stored on disk
std::string GetDataPath() const { return m_dataPath; }
/// When server started?
time_t const& GetStartTime() const { return m_startTime; }
/// What time is it?
time_t const& GetGameTime() const { return m_gameTime; }
/// Uptime (in secs)
uint32 GetUptime() const { return uint32(m_gameTime - m_startTime); }
/// Update time
uint32 GetUpdateTime() const { return m_updateTime; }
/// Next daily quests reset time
time_t GetNextDailyQuestsResetTime() const { return m_NextDailyQuestReset; }
time_t GetNextWeeklyQuestsResetTime() const { return m_NextWeeklyQuestReset; }
time_t GetNextRandomBGResetTime() const { return m_NextRandomBGReset; }
/// Get the maximum skill level a player can reach
uint16 GetConfigMaxSkillValue() const
{
uint32 lvl = getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL);
return lvl > 60 ? 300 + ((lvl - 60) * 75) / 10 : lvl*5;
}
void SetInitialWorldSettings();
void LoadConfigSettings(bool reload = false);
void SendWorldText(int32 string_id, ...);
void SendWorldTextWithSecurity(AccountTypes security, int32 string_id, ...);
void SendGlobalMessage(WorldPacket* packet, WorldSession* self = NULL, Team team = TEAM_NONE, AccountTypes security = SEC_PLAYER);
void SendZoneMessage(uint32 zone, WorldPacket* packet, WorldSession* self = NULL, Team team = TEAM_NONE);
void SendZoneText(uint32 zone, const char* text, WorldSession* self = NULL, Team team = TEAM_NONE);
void SendServerMessage(ServerMessageType type, const char* text = "", Player* player = NULL);
void SendZoneUnderAttackMessage(uint32 zoneId, Team team);
void SendDefenseMessage(uint32 zoneId, int32 textId);
/// Are we in the middle of a shutdown?
bool IsShutdowning() const { return m_ShutdownTimer > 0; }
void ShutdownServ(uint32 time, uint32 options, uint8 exitcode);
void ShutdownCancel();
void ShutdownMsg(bool show = false, Player* player = NULL);
static uint8 GetExitCode() { return m_ExitCode; }
static void StopNow(uint8 exitcode) { m_stopEvent = true; m_ExitCode = exitcode; }
static bool IsStopped() { return m_stopEvent; }
void Update(uint32 diff);
void UpdateSessions( uint32 diff );
/// Get a server configuration element (see #eConfigFloatValues)
void setConfig(eConfigFloatValues index,float value) { m_configFloatValues[index]=value; }
/// Get a server configuration element (see #eConfigFloatValues)
float getConfig(eConfigFloatValues rate) const { return m_configFloatValues[rate]; }
/// Set a server configuration element (see #eConfigUInt32Values)
void setConfig(eConfigUInt32Values index, uint32 value) { m_configUint32Values[index]=value; }
/// Get a server configuration element (see #eConfigUInt32Values)
uint32 getConfig(eConfigUInt32Values index) const { return m_configUint32Values[index]; }
/// Set a server configuration element (see #eConfigInt32Values)
void setConfig(eConfigInt32Values index, int32 value) { m_configInt32Values[index]=value; }
/// Get a server configuration element (see #eConfigInt32Values)
int32 getConfig(eConfigInt32Values index) const { return m_configInt32Values[index]; }
/// Set a server configuration element (see #eConfigBoolValues)
void setConfig(eConfigBoolValues index, bool value) { m_configBoolValues[index]=value; }
/// Get a server configuration element (see #eConfigBoolValues)
bool getConfig(eConfigBoolValues index) const { return m_configBoolValues[index]; }
/// Are we on a "Player versus Player" server?
bool IsPvPRealm() { return (getConfig(CONFIG_UINT32_GAME_TYPE) == REALM_TYPE_PVP || getConfig(CONFIG_UINT32_GAME_TYPE) == REALM_TYPE_RPPVP || getConfig(CONFIG_UINT32_GAME_TYPE) == REALM_TYPE_FFA_PVP); }
bool IsFFAPvPRealm() { return getConfig(CONFIG_UINT32_GAME_TYPE) == REALM_TYPE_FFA_PVP; }
void KickAll();
void KickAllLess(AccountTypes sec);
BanReturn BanAccount(BanMode mode, std::string nameOrIP, uint32 duration_secs, std::string reason, std::string author);
bool RemoveBanAccount(BanMode mode, std::string nameOrIP);
// for max speed access
static float GetMaxVisibleDistanceOnContinents() { return m_MaxVisibleDistanceOnContinents; }
static float GetMaxVisibleDistanceInInstances() { return m_MaxVisibleDistanceInInstances; }
static float GetMaxVisibleDistanceInBGArenas() { return m_MaxVisibleDistanceInBGArenas; }
static float GetMaxVisibleDistanceInFlight() { return m_MaxVisibleDistanceInFlight; }
static float GetVisibleUnitGreyDistance() { return m_VisibleUnitGreyDistance; }
static float GetVisibleObjectGreyDistance() { return m_VisibleObjectGreyDistance; }
static float GetRelocationLowerLimitSq() { return m_relocation_lower_limit_sq; }
static uint32 GetRelocationAINotifyDelay() { return m_relocation_ai_notify_delay; }
void ProcessCliCommands();
void QueueCliCommand(CliCommandHolder* commandHolder) { cliCmdQueue.add(commandHolder); }
void UpdateResultQueue();
void InitResultQueue();
LocaleConstant GetAvailableDbcLocale(LocaleConstant locale) const { if(m_availableDbcLocaleMask & (1 << locale)) return locale; else return m_defaultDbcLocale; }
//used World DB version
void LoadDBVersion();
char const* GetDBVersion() { return m_DBVersion.c_str(); }
char const* GetCreatureEventAIVersion() { return m_CreatureEventAIVersion.c_str(); }
// multithread locking (World locking used only if object map == NULL)
ObjectLockType& GetLock(MapLockType _locktype = MAP_LOCK_TYPE_DEFAULT) { return i_lock[_locktype]; }
// reset duel system
void setDuelResetEnableAreaIds(const char* areas);
bool IsAreaIdEnabledDuelReset(uint32 areaId);
protected:
void _UpdateGameTime();
void InitDailyQuestResetTime();
void InitWeeklyQuestResetTime();
void SetMonthlyQuestResetTime(bool initialize = true);
void ResetDailyQuests();
void ResetWeeklyQuests();
void ResetMonthlyQuests();
void InitRandomBGResetTime();
void ResetRandomBG();
private:
void setConfig(eConfigUInt32Values index, char const* fieldname, uint32 defvalue);
void setConfig(eConfigInt32Values index, char const* fieldname, int32 defvalue);
void setConfig(eConfigFloatValues index, char const* fieldname, float defvalue);
void setConfig(eConfigBoolValues index, char const* fieldname, bool defvalue);
void setConfigPos(eConfigFloatValues index, char const* fieldname, float defvalue);
void setConfigMin(eConfigUInt32Values index, char const* fieldname, uint32 defvalue, uint32 minvalue);
void setConfigMin(eConfigInt32Values index, char const* fieldname, int32 defvalue, int32 minvalue);
void setConfigMin(eConfigFloatValues index, char const* fieldname, float defvalue, float minvalue);
void setConfigMinMax(eConfigUInt32Values index, char const* fieldname, uint32 defvalue, uint32 minvalue, uint32 maxvalue);
void setConfigMinMax(eConfigInt32Values index, char const* fieldname, int32 defvalue, int32 minvalue, int32 maxvalue);
void setConfigMinMax(eConfigFloatValues index, char const* fieldname, float defvalue, float minvalue, float maxvalue);
bool configNoReload(bool reload, eConfigUInt32Values index, char const* fieldname, uint32 defvalue);
bool configNoReload(bool reload, eConfigInt32Values index, char const* fieldname, int32 defvalue);
bool configNoReload(bool reload, eConfigFloatValues index, char const* fieldname, float defvalue);
bool configNoReload(bool reload, eConfigBoolValues index, char const* fieldname, bool defvalue);
static volatile bool m_stopEvent;
static uint8 m_ExitCode;
uint32 m_ShutdownTimer;
uint32 m_ShutdownMask;
time_t m_startTime;
time_t m_gameTime;
IntervalTimer m_timers[WUPDATE_COUNT];
uint32 mail_timer;
uint32 mail_timer_expires;
uint32 m_updateTime;
typedef UNORDERED_MAP<uint32, Weather*> WeatherMap;
WeatherMap m_weathers;
typedef UNORDERED_MAP<uint32, WorldSession*> SessionMap;
SessionMap m_sessions;
uint32 m_maxActiveSessionCount;
uint32 m_maxQueuedSessionCount;
uint32 m_configUint32Values[CONFIG_UINT32_VALUE_COUNT];
int32 m_configInt32Values[CONFIG_INT32_VALUE_COUNT];
float m_configFloatValues[CONFIG_FLOAT_VALUE_COUNT];
bool m_configBoolValues[CONFIG_BOOL_VALUE_COUNT];
int32 m_playerLimit;
LocaleConstant m_defaultDbcLocale; // from config for one from loaded DBC locales
uint32 m_availableDbcLocaleMask; // by loaded DBC
void DetectDBCLang();
bool m_allowMovement;
std::string m_motd;
std::string m_dataPath;
// for max speed access
static float m_MaxVisibleDistanceOnContinents;
static float m_MaxVisibleDistanceInInstances;
static float m_MaxVisibleDistanceInBGArenas;
static float m_MaxVisibleDistanceInFlight;
static float m_VisibleUnitGreyDistance;
static float m_VisibleObjectGreyDistance;
static float m_relocation_lower_limit_sq;
static uint32 m_relocation_ai_notify_delay;
// CLI command holder to be thread safe
ACE_Based::LockedQueue<CliCommandHolder*,ACE_Thread_Mutex> cliCmdQueue;
// next daily quests reset time
time_t m_NextDailyQuestReset;
time_t m_NextWeeklyQuestReset;
time_t m_NextMonthlyQuestReset;
time_t m_NextRandomBGReset;
//Player Queue
Queue m_QueuedSessions;
//sessions that are added async
void AddSession_(WorldSession* s);
ACE_Based::LockedQueue<WorldSession*, ACE_Thread_Mutex> addSessQueue;
//used versions
std::string m_DBVersion;
std::string m_CreatureEventAIVersion;
// World locking for global (not-in-map) objects.
mutable ObjectLockType i_lock[MAP_LOCK_TYPE_MAX];
// reset duel system
std::set<uint32> areaEnabledIds; //set of areaIds where is enabled the Duel reset system
};
extern uint32 realmID;
#define sWorld MaNGOS::Singleton<World>::Instance()
#endif
/// @}
| Remix99/MaNGOS | src/game/World.h | C | gpl-2.0 | 33,187 |
<!DOCTYPE html>
<html>
<!-- Mirrored from www.w3schools.com/html/tryhtml_images_map.htm by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 08:08:51 GMT -->
<body>
<p>Click on the sun or on one of the planets to watch it closer:</p>
<img src="planets.gif" alt="Planets" usemap="#planetmap" style="width:145px;height:126px">
<map name="planetmap">
<area shape="rect" coords="0,0,82,126" alt="Sun" href="sun.html">
<area shape="circle" coords="90,58,3" alt="Mercury" href="mercur.html">
<area shape="circle" coords="124,58,8" alt="Venus" href="venus.html">
</map>
</body>
<!-- Mirrored from www.w3schools.com/html/tryhtml_images_map.htm by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 08:08:51 GMT -->
</html> | platinhom/ManualHom | Coding/W3School/W3Schools_Offline_2015/www.w3schools.com/html/tryhtml_images_map.html | HTML | gpl-2.0 | 741 |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<meta name="categories" content="docking">
<meta name="profile" content="!Elements">
<meta name="product" content="Glide">
<title>Glide — Edit Feature Dialog Box</title>
<link rel="stylesheet" type="text/css" href="../support/help.css">
</head>
<script type="text/javascript">
function setTitle()
{
top.document.title = document.title + " - " + parent.parent.WINDOW_TITLE;
}
</script>
<body onload="setTitle();">
<table border=0 cellspacing=0 bgcolor=#dcdcdc width=100%>
<tr><td>
<p><img src="../support/schrodinger_logo.gif" border=0 alt="" align="left" vspace=5 hspace=5 /></p>
</td></tr>
<tr><td>
<h1 class=title><span class="glide">Glide — Edit Feature Dialog Box</span></h1>
</td></tr>
</table>
<ul>
<li><a href="#summary">Summary</a></li>
<li><a href="#opening">Opening the <span class="GUI">Edit Feature</span> Dialog
Box</a></li>
<li><a href="#using">Using the <span class="GUI">Edit Feature</span> Dialog
Box</a></li>
<li><a href="#features"><span class="GUI">Edit Feature</span> Dialog Box
Features</a></li>
<li><a href="#links">Related Topics</a></li>
</ul>
<a name="summary"></a>
<h2>Summary</h2>
<p>The <span class="GUI">Edit Features</span> dialog box allows you to
edit the features that the ligand must match. Features are defined in terms of
SMARTS patterns. You can add patterns, edit and delete custom patterns, and you can
exclude patterns in a feature definition.</p>
<a name="opening"></a>
<h2>Opening the Edit Feature Dialog Box</h2>
<p>To open the <span class="GUI">Edit Feature</span> dialog box</p>
<ul>
<li><p>Click <span class="GUI">Edit Feature</span> in the <span
class="GUI">Constraints</span> tab of the Glide
<span class="GUI">Ligand Docking</span> panel.</p></li>
</ul>
<a name="using"></a>
<h2>Using the Edit Feature Dialog Box</h2>
<h3>Loading and Saving Feature Sets</h3>
<p>Built-in feature sets are stored with the distribution.
<p>You can import a feature set for the selected constraint from a file by
clicking <span class="GUI">Import</span>, and navigating to the
feature file. When you import a feature set, the definitions of all features
are replaced, not just the selected feature. The feature definitions are
replaced only for the selected constraint, but are replaced
for that constraint in all groups.
<p>Feature sets can be saved to a file by clicking <span class="GUI">Export</span>, and specifying the file
location in the file selector that is displayed. </p>
<p>The patterns that define a feature are displayed in the
<span class="GUI">Pattern list</span> table when you choose the feature
from the <span class="GUI">Feature</span> option menu.</p>
<h3>Adding, Editing, and Deleting Patterns</h3>
<p>If the patterns in a given feature definition do not cover all the functional groups
that you want to include in the feature, you can add extra patterns. To add a
new SMARTS pattern, click the table row above which you want the pattern to be
inserted, then click <span class="GUI">New</span>. In the
<a href="new_pattern.html"><span class="GUI">New Pattern</span>
dialog box</a>, you can enter a SMARTS pattern and enter the atom numbers
in the pattern that must satisfy the constraint.</p>
<p>To edit a pattern, select the table row for the pattern, then click
<span class="GUI">Edit</span>. In the
<a href="edit_pattern.html"><span class="GUI">Edit
Pattern</span> dialog box</a>, you can modify the SMARTS pattern and the atoms in the
pattern that must match.</p>
<p>To delete a pattern, select the table row for the pattern, then click <span class="GUI">Delete</span>.</p>
<h3>Setting the Status of Patterns</h3>
<p>Matching of patterns to ligand structures is done in the order specified in the
<span class="GUI">Pattern list</span> table. You cannot change the
order of the patterns once they are in the table, so you must add new patterns
in the appropriate place. If you want to move patterns, you must delete them then
add them back in the appropriate place. Excluded patterns are processed first,
regardless of their position in the table.</p>
<p>If you want to ensure that certain functional groups are not matched, you can select
the check box in the <span class="GUI">Exclude</span> column for the
pattern for that group. For example, you might want to exclude a carboxylic acid
group from being considered as a hydrogen bond donor, because it will be ionized
under physiological conditions.</p>
<h3>Visualizing Patterns</h3>
<p>If you want to see a pattern for a given ligand or group of ligands, you
can select the check box in the <span class="GUI">Mark</span> column
for the pattern. Any occurrences of the pattern are marked in the Workspace.</p>
<p>You can display markers for more than one pattern, but the markers do not
distinguish between patterns. If you want to see the atoms and bonds as well as
the markers, select <span class="GUI">Apply marker offset</span>.</p>
<a name="features"></a>
<h2>Edit Feature Dialog Box Features</h2>
<ul>
<li><a href="#feature1"><span class="GUI">Feature</span> controls</a></li>
<li><a href="#feature2"><span class="GUI">Pattern list</span> table</a></li>
<li><a href="#feature3">Pattern editing buttons</a></li>
</ul>
<a name="feature1"></a>
<h3>Feature Controls</h3>
<p>This section has three controls:</p>
<dl>
<dt><span class="GUI">Feature</span> option menu</dt>
<dd><p>Select a feature type. The selected feature type is assigned to the
constraint and appears in the <span class="GUI">Available constraints</span>
table of the <span class="GUI">Constraints</span> tab. The patterns
that define the selected feature type are listed in the
<span class="GUI">Pattern list</span> table.
You must select a feature type to edit its definition.
</p></dd>
<dt><span class="GUI">Import</span> button</dt>
<dd><p>Opens a file selector in which you can browse for feature files.
</p></dd>
<dt><span class="GUI">Export</span> button</dt>
<dd><p>Opens a file selector in which you can browse to a location to write a feature file.
</p></dd>
</dl>
<a name="feature2"></a>
<h3>Pattern list table</h3>
<p>The <span class="GUI">Pattern list</span> table lists all the patterns
that are used to define the feature. You can only select one row
at a time in the table, and the text fields are not editable. The table columns
are described below.
</p>
<dl>
<a name="feature2.1"></a>
<dt><span class="GUI">Mark</span></dt>
<dd><p>Column of check boxes. Selecting a check box marks the pattern on any
structures that are displayed in the Workspace.
</p></dd>
<a name="feature2.2"></a>
<dt><span class="GUI">Pattern</span></dt>
<dd><p>Pattern definition. The definitions are SMARTS strings.
</p></dd>
<a name="feature2.5"></a>
<dt><span class="GUI">Atoms</span></dt>
<dd><p>The list of atoms that must satisfy the constraint, numbered
according to the SMARTS string.
</p></dd>
<a name="feature2.6"></a>
<dt><span class="GUI">Exclude</span></dt>
<dd><p>Column of check boxes. If a check box is selected, atoms in a ligand are matched
by other patterns only if they do not match this pattern. This is essentially a NOT
operator. Excluded patterns are processed before other patterns.
</p></dd>
</dl>
<a name="feature3"></a>
<h3>Pattern Editing Buttons</h3>
<dl>
<a name="feature3.1"></a>
<dt><span class="GUI">New</span> button</dt>
<dd><p>Opens the <a href="new_pattern.html"><span class="GUI">New
Pattern</span> dialog box</a>, in which you can enter a SMARTS pattern and
choose the atoms that are used to match the ligand feature.
</p></dd>
<a name="feature3.2"></a>
<dt><span class="GUI">Edit</span> button</dt>
<dd><p>Opens the <a href="edit_pattern.html"><span class="GUI">Edit
Pattern</span> dialog box</a>, in which you can edit the selected
pattern.
</p></dd>
<a name="feature3.3"></a>
<dt><span class="GUI">Delete</span> button</dt>
<dd><p>Deletes the selected pattern.
</p></dd>
</dl>
<a name="links"></a>
<h2>Related Topics</h2>
<ul>
<li><a href="dock_constraints.html">Glide Docking Constraints Tab</a></li>
<li><a href="new_pattern.html">Glide New Pattern Dialog Box</a></li>
<li><a href="edit_pattern.html">Glide Edit Pattern Dialog Box</a></li>
</ul>
<hr />
<table width="100%">
<td><p class="small"><a href="../support/legal_notice.html" target="LegalNoticeWindow">Legal Notice</a></p></td>
<td>
<table align="right">
<td><p class="small">
File: glide/edit_feature.html<br />
Last updated: 10 Jan 2012
</p></td>
</table>
</td>
</table>
</body>
</html>
| platinhom/ManualHom | Schrodinger/Schrodinger_2012_docs/maestro/help_BioLuminate/glide/edit_feature.html | HTML | gpl-2.0 | 8,573 |
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="style/style.css">
<link rel="stylesheet" type="text/css" media="only screen and (min-device-width: 360px)" href="style-compact.css">
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-74917613-1', 'auto');
ga('send', 'pageview');
</script>
</head>
<body>
<div class="dungeonBackgroundContainer">
<img class="dungeonFrame" src="dungeon_battle_collection/baseDungeonFrame.png" />
<img class="dungeonImage" src="dungeon_battle_collection/dungeon_battle_80007.jpg" />
</div>
<div class="dialogueContainer">
<div class="facePortrait">
<img class="facePortraitFrame" src="navi_chara_collection/characterFrame.png" />
<img class="facePortraitImg" src="navi_chara_collection/navi_chara80038_3.png" />
</div>
<div class="speakerName"><a href="http://i.imgur.com/ZLwSPY7.png">Avani</a></div>
<div class="speakerMessage">This place looks...different from when I last came here. </div>
</div>
<br>
<div class="dialogueContainer">
<div class="facePortrait">
<img class="facePortraitFrame" src="navi_chara_collection/characterFrame.png" />
<img class="facePortraitImg" src="navi_chara_collection/navi_chara80038_3.png" />
</div>
<div class="speakerName">Avani</div>
<div class="speakerMessage">It seems like even sacred places like this one aren’t spared from Azurai’s reign…</div>
</div>
<br>
<div class="dialogueContainer">
<div class="facePortrait">
<img class="facePortraitFrame" src="navi_chara_collection/characterFrame.png" />
<img class="facePortraitImg" src="navi_chara_collection/navi_chara80038_3.png" />
</div>
<div class="speakerName">Avani</div>
<div class="speakerMessage">And where could Allanon be? Although I would rather not see him, we need his help now more than ever.</div>
</div>
<br>
<div class="dialogueContainer">
<div class="facePortrait">
<img class="facePortraitFrame" src="navi_chara_collection/characterFrame.png" />
<img class="facePortraitImg" src="navi_chara_collection/navi_chara80041_1.png" />
</div>
<div class="speakerName"><a href="http://i.imgur.com/4uoeaL0.png">Nyami</a></div>
<div class="speakerMessage"><div style="display:inline;font-size:12px">He...must have found...something fun.</div></div>
</div>
<br>
<div class="dialogueContainer">
<div class="facePortrait">
<img class="facePortraitFrame" src="navi_chara_collection/characterFrame.png" />
<img class="facePortraitImg" src="navi_chara_collection/navi_chara80038_0.png" />
</div>
<div class="speakerName">Avani</div>
<div class="speakerMessage">I’m pretty sure he’s found more than just something fun. </div>
</div>
<br>
<div class="dialogueContainer">
<div class="facePortrait">
<img class="facePortraitFrame" src="navi_chara_collection/characterFrame.png" />
<img class="facePortraitImg" src="navi_chara_collection/navi_chara80038_0.png" />
</div>
<div class="speakerName">Avani</div>
<div class="speakerMessage">An entire Morokai city without anyone to stop him...it must be like a giant playground for him. </div>
</div>
<br>
<div class="dialogueContainer">
<div class="facePortrait">
<img class="facePortraitFrame" src="navi_chara_collection/characterFrame.png" />
<img class="facePortraitImg" src="navi_chara_collection/navi_chara80038_3.png" />
</div>
<div class="speakerName">Avani</div>
<div class="speakerMessage">He’d better not forget the reason we’re here in the first place…</div>
</div>
<br>
<div class="dialogueSeparator" >
<img src="navi_chara_collection/dialogueSeparator.png" align="middle" />
</div>
<div class="dialogueContainer">
<div class="facePortrait">
<img class="facePortraitFrame" src="navi_chara_collection/characterFrame.png" />
<img class="facePortraitImg" src="navi_chara_collection/blank.png" />
</div>
<div class="speakerName">Mysterious Voice</div>
<div class="speakerMessage">Hahaha… Why am I not surprised?</div>
</div>
<br>
<div class="dialogueContainer">
<div class="facePortrait">
<img class="facePortraitFrame" src="navi_chara_collection/characterFrame.png" />
<img class="facePortraitImg" src="navi_chara_collection/blank.png" />
</div>
<div class="speakerName">Mysterious Voice</div>
<div class="speakerMessage">Even after all these years that fool hasn’t changed one bit.</div>
</div>
<br>
<div class="dialogueContainer">
<div class="facePortrait">
<img class="facePortraitFrame" src="navi_chara_collection/characterFrame.png" />
<img class="facePortraitImg" src="navi_chara_collection/navi_chara80038_2.png" />
</div>
<div class="speakerName">Avani</div>
<div class="speakerMessage">The voice from within the sandstorm…</div>
</div>
<br>
<div class="dialogueContainer">
<div class="facePortrait">
<img class="facePortraitFrame" src="navi_chara_collection/characterFrame.png" />
<img class="facePortraitImg" src="navi_chara_collection/navi_chara80038_2.png" />
</div>
<div class="speakerName">Avani</div>
<div class="speakerMessage">Where is Ezra! <div style="display:inline;font-size:15px">SHOW YOURSELF!</div></div>
</div>
<br>
<div class="dialogueContainer">
<div class="facePortrait">
<img class="facePortraitFrame" src="navi_chara_collection/characterFrame.png" />
<img class="facePortraitImg" src="navi_chara_collection/navi_chara80038_2.png" />
</div>
<div class="speakerName">Avani</div>
<div class="speakerMessage"><div style="display:inline;font-size:15px">You will pay for what you have done!</div></div>
</div>
<br>
<div class="dialogueContainer">
<div class="facePortrait">
<img class="facePortraitFrame" src="navi_chara_collection/characterFrame.png" />
<img class="facePortraitImg" src="navi_chara_collection/navi_chara80041_2.png" />
</div>
<div class="speakerName">Nyami</div>
<div class="speakerMessage">*Hissss*!!!</div>
</div>
<br>
<div class="dialogueContainer">
<div class="facePortrait">
<img class="facePortraitFrame" src="navi_chara_collection/characterFrame.png" />
<img class="facePortraitImg" src="navi_chara_collection/blank.png" />
</div>
<div class="speakerName">Mysterious Voice</div>
<div class="speakerMessage">Foolish child… </div>
</div>
<br>
<div class="dialogueContainer">
<div class="facePortrait">
<img class="facePortraitFrame" src="navi_chara_collection/characterFrame.png" />
<img class="facePortraitImg" src="navi_chara_collection/blank.png" />
</div>
<div class="speakerName">Mysterious Voice</div>
<div class="speakerMessage">very well then. </div>
</div>
<br>
<div class="dialogueContainer">
<div class="facePortrait">
<img class="facePortraitFrame" src="navi_chara_collection/characterFrame.png" />
<img class="facePortraitImg" src="navi_chara_collection/navi_chara80047.png" />
</div>
<div class="speakerName"><a href="http://i.imgur.com/pm6hOA7.png">Aranvis</a></div>
<div class="speakerMessage">Allow me to introduce myself.</div>
</div>
<br>
<div class="dialogueContainer">
<div class="facePortrait">
<img class="facePortraitFrame" src="navi_chara_collection/characterFrame.png" />
<img class="facePortraitImg" src="navi_chara_collection/navi_chara80047.png" />
</div>
<div class="speakerName">Aranvis</div>
<div class="speakerMessage">High Inquisitor Aranvis, at your service. </div>
</div>
<br>
<div class="dialogueContainer">
<div class="facePortrait">
<img class="facePortraitFrame" src="navi_chara_collection/characterFrame.png" />
<img class="facePortraitImg" src="navi_chara_collection/navi_chara80047.png" />
</div>
<div class="speakerName">Aranvis</div>
<div class="speakerMessage">I hope you can entertain me. </div>
</div>
<br>
<div class="dialogueContainer">
<div class="facePortrait">
<img class="facePortraitFrame" src="navi_chara_collection/characterFrame.png" />
<img class="facePortraitImg" src="navi_chara_collection/navi_chara80047.png" />
</div>
<div class="speakerName">Aranvis</div>
<div class="speakerMessage">Now let me see what you’re capable of!</div>
</div>
<br>
<div class="dialogueSeparator" >
<img src="navi_chara_collection/dialogueSeparator.png" align="middle" />
</div>
</body>
</html>
<!-- contact me at reddit /u/blackrobe199 -->
| Blackrobe/blackrobe.github.io | BFStoryArchive/BFStoryArchive/GQX2_02.html | HTML | gpl-2.0 | 8,357 |
/***************************************************************************
FluxIntegral.cpp - Integrates Lx dx
L (x1, x2) = int^x2_x1 dx Lx
-------------------
begin : December 2006
copyright : (C) 2006 by Maurice Leutenegger
email : [email protected]
***************************************************************************/
/* This program 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 of the License, or
(at your option) any later version.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "FluxIntegral.h"
#include <iostream>
using namespace std;
FluxIntegral::FluxIntegral (Lx* lx)
: Integral (), itsLx (lx), itsXKink (itsLx->getXKink ()),
itsXOcc (itsLx->getXOcc ())
{
return;
}
FluxIntegral::~FluxIntegral ()
{
return;
}
double FluxIntegral::integrand (double x)
{
return itsLx->getLx (x);
}
/*
Integrates Lx over [y,x].
Will mostly be called with y < x, but if not, it swaps them.
Note: is there code somewhere else to deal with an unresolved profile?
(The code below only deals with the case where it's known to be
completely unresolved in advance.)
*/
Real FluxIntegral::getFlux (Real x, Real y)
{
if (compare (y, x) == 1) {
Real temp = x;
x = y;
y = temp;
}
bool xInRange = (compare (fabs(x), 1.) == -1);
bool yInRange = (compare (fabs(y), 1.) == -1);
if (!xInRange && !yInRange) return 0.;
if (!xInRange) x = 1.;
if (!yInRange) y = -1.;
if ((compare (itsXKink, y) == 1) && (compare (itsXKink, x) == -1)) {
return (qag (y, itsXKink) + qag (itsXKink, x));
}
if ((compare (itsXOcc, y) == 1) && (compare (itsXOcc, x) == -1)) {
return (qag (y, itsXOcc) + qag (itsXOcc, x));
}
return qag (y, x);
/*
The kink coordinate gives the point at which many profiles have a kink at
negative x on the blue side of the profile. This kink occurs at the x
where the cutoff u0 starts to become important. (At zero optical depth,
the profile becomes flat at this point).
The "occ" coordinate gives the point in x where occultation begins to
become important. I choose to place this not at p = 1 but at p = 1 + e,
to avoid edge effects.
*/
/*
if (xInRange && yInRange) {
return qag (y, x);
} else if (xInRange && !yInRange) {
return qag (-1., x);
} else if (!xInRange && yInRange) {
return qag (y, 1.);
} else {
return 0.;
}
*/
}
// Integrate on x in [-1:1]
Real FluxIntegral::getFlux ()
{
return (qag (-1., itsXKink) + qag (itsXKink, itsXOcc) + qag (itsXOcc, 1.));
}
| mauriceleutenegger/windprofile | FluxIntegral.cpp | C++ | gpl-2.0 | 3,166 |
<?php session_start(); ?>
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<title>Somali Taekwondo - About us</title>
<?php include('inc/metatags.inc') ?>
</head>
<body>
<!--[if lt IE 7]>
<p class="chromeframe">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a> to improve your experience.</p>
<![endif]-->
<header>
<div class="navbar-wrapper">
<!-- Wrap the .navbar in .container to center it within the absolutely positioned parent. -->
<div class="container">
<div class="navbar navbar-inverse">
<div class="navbar-inner">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="/home"><img src="img/logo.png" alt="gotkd" width="150" /></a>
<?php include('inc/nav.inc') ?>
</div>
</div>
</div>
</div>
</header>
<section id="container" class="container aboutus">
<br />
<br />
<br />
<div class="page-header">
<h1>About us</h1>
</div>
<div class="row-fluid media">
<div class="span7">
<p>Having its headquarters in Switzerland, Somali Taekwondo was established in 2012 and is responsible for all aspects of Somali National Team around the world helping athletes achieve their full potential, and preparing them for major competition, as well as selecting athlete to compete at African Championship, World Championships, and of course the Olympic Games.</p>
<p>After emerging from decades of civil war and social upheaval, Somali Taekwondo use the sport to promote a better image of Somali and helping the country climb out of poverty.</p>
<p>Somali Taekwondo use funds provided from donations of people from all around the world to promote Somali image, giving an assistance to the sport, focusing on improving opportunities for the somalian athletes participate in many tournament, giving a hope for the country.</p>
<p>Every donation will be indented for the developing of each somalian athlete giving the oportunity to participate to every tournement recognized by the World Taekwondo Federation and the Somali Olympic Committee. Donations that will be more than needed will be given to an ONG that helps against the somali poverty.</p>
</div>
<div class="span5 thumbnail">
<img src="https://fbcdn-sphotos-a-a.akamaihd.net/hphotos-ak-ash3/942859_162735743901850_517590466_n.jpg" alt="" />
</div>
</div>
<?php include('inc/footer.inc') ?>
</section> <!-- /container -->
<?php include('inc/js.inc') ?>
</body>
</html>
| somalitaekwondo/site | novo/about-us.php | PHP | gpl-2.0 | 3,667 |
<?php
namespace Drush\Boot;
use Consolidation\AnnotatedCommand\AnnotationData;
use Drush\Log\DrushLog;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Drupal\Core\DrupalKernel;
use Drush\Drush;
use Drush\Drupal\DrushServiceModifier;
use Drush\Log\LogLevel;
class DrupalBoot8 extends DrupalBoot implements AutoloaderAwareInterface
{
use AutoloaderAwareTrait;
/**
* @var \Drupal\Core\DrupalKernelInterface
*/
protected $kernel;
/**
* @var \Symfony\Component\HttpFoundation\Request
*/
protected $request;
/**
* @return \Symfony\Component\HttpFoundation\Request
*/
public function getRequest()
{
return $this->request;
}
/**
* @param \Symfony\Component\HttpFoundation\Request $request
*/
public function setRequest($request)
{
$this->request = $request;
}
/**
* @return \Drupal\Core\DrupalKernelInterface
*/
public function getKernel()
{
return $this->kernel;
}
public function validRoot($path)
{
if (!empty($path) && is_dir($path) && file_exists($path . '/autoload.php')) {
// Additional check for the presence of core/composer.json to
// grant it is not a Drupal 7 site with a base folder named "core".
$candidate = 'core/includes/common.inc';
if (file_exists($path . '/' . $candidate) && file_exists($path . '/core/core.services.yml')) {
if (file_exists($path . '/core/misc/drupal.js') || file_exists($path . '/core/assets/js/drupal.js')) {
return $candidate;
}
}
}
}
public function getVersion($drupal_root)
{
// Are the class constants available?
if (!$this->hasAutoloader()) {
throw new \Exception('Cannot access Drupal 8 class constants - Drupal autoloader not loaded yet.');
}
// Drush depends on bootstrap being loaded at this point.
require_once $drupal_root .'/core/includes/bootstrap.inc';
if (defined('\Drupal::VERSION')) {
return \Drupal::VERSION;
}
}
public function confPath($require_settings = true, $reset = false)
{
if (\Drupal::hasService('kernel')) {
$site_path = \Drupal::service('kernel')->getSitePath();
}
if (!isset($site_path) || empty($site_path)) {
$site_path = DrupalKernel::findSitePath($this->getRequest(), $require_settings);
}
return $site_path;
}
public function addLogger()
{
// Provide a logger which sends
// output to drush_log(). This should catch every message logged through every
// channel.
$container = \Drupal::getContainer();
$parser = $container->get('logger.log_message_parser');
$drushLogger = Drush::logger();
$logger = new DrushLog($parser, $drushLogger);
$container->get('logger.factory')->addLogger($logger);
}
public function bootstrapDrupalCore($drupal_root)
{
$core = DRUPAL_ROOT . '/core';
return $core;
}
public function bootstrapDrupalSiteValidate()
{
parent::bootstrapDrupalSiteValidate();
// Normalize URI.
$uri = rtrim($this->uri, '/') . '/';
$parsed_url = parse_url($uri);
// Account for users who omit the http:// prefix.
if (empty($parsed_url['scheme'])) {
$this->uri = 'http://' . $this->uri;
$parsed_url = parse_url($this->uri);
}
$server = [
'SCRIPT_FILENAME' => getcwd() . '/index.php',
'SCRIPT_NAME' => isset($parsed_url['path']) ? $parsed_url['path'] . 'index.php' : '/index.php',
];
$request = Request::create($this->uri, 'GET', [], [], [], $server);
$this->setRequest($request);
$confPath = drush_bootstrap_value('confPath', $this->confPath(true, true));
drush_bootstrap_value('site', $request->getHttpHost());
return true;
}
public function bootstrapDrupalConfigurationValidate()
{
$conf_file = $this->confPath() . '/settings.php';
if (!file_exists($conf_file)) {
$msg = dt("Could not find a Drupal settings.php file at !file.", ['!file' => $conf_file]);
$this->logger->debug($msg);
// Cant do this because site:install deliberately bootstraps to configure without a settings.php file.
// return drush_set_error($msg);
}
return true;
}
public function bootstrapDrupalDatabaseValidate()
{
return parent::bootstrapDrupalDatabaseValidate() && $this->bootstrapDrupalDatabaseHasTable('key_value');
}
public function bootstrapDrupalDatabase()
{
// D8 omits this bootstrap level as nothing special needs to be done.
parent::bootstrapDrupalDatabase();
}
public function bootstrapDrupalConfiguration(AnnotationData $annotationData = null)
{
// Default to the standard kernel.
$kernel = Kernels::DRUPAL;
if (!empty($annotationData)) {
$kernel = $annotationData->get('kernel', Kernels::DRUPAL);
}
$classloader = $this->autoloader();
$request = $this->getRequest();
$kernel_factory = Kernels::getKernelFactory($kernel);
$allow_dumping = $kernel !== Kernels::UPDATE;
/** @var \Drupal\Core\DrupalKernelInterface kernel */
$this->kernel = $kernel_factory($request, $classloader, 'prod', $allow_dumping);
// Include Drush services in the container.
// @see Drush\Drupal\DrupalKernel::addServiceModifier()
$this->kernel->addServiceModifier(new DrushServiceModifier());
// Unset drupal error handler and restore Drush's one.
restore_error_handler();
// Disable automated cron if the module is enabled.
$GLOBALS['config']['automated_cron.settings']['interval'] = 0;
parent::bootstrapDrupalConfiguration();
}
public function bootstrapDrupalFull()
{
$this->logger->debug(dt('Start bootstrap of the Drupal Kernel.'));
$this->kernel->boot();
$this->kernel->prepareLegacyRequest($this->getRequest());
$this->logger->debug(dt('Finished bootstrap of the Drupal Kernel.'));
parent::bootstrapDrupalFull();
$this->addLogger();
// Get a list of the modules to ignore
$ignored_modules = drush_get_option_list('ignored-modules', []);
$application = Drush::getApplication();
$runner = Drush::runner();
// We have to get the service command list from the container, because
// it is constructed in an indirect way during the container initialization.
// The upshot is that the list of console commands is not available
// until after $kernel->boot() is called.
$container = \Drupal::getContainer();
// Set the command info alterers.
if ($container->has(DrushServiceModifier::DRUSH_COMMAND_INFO_ALTERER_SERVICES)) {
$serviceCommandInfoAltererlist = $container->get(DrushServiceModifier::DRUSH_COMMAND_INFO_ALTERER_SERVICES);
$commandFactory = Drush::commandFactory();
foreach ($serviceCommandInfoAltererlist->getCommandList() as $altererHandler) {
$commandFactory->addCommandInfoAlterer($altererHandler);
$this->logger->debug(dt('Commands are potentially altered in !class.', ['!class' => get_class($altererHandler)]));
}
}
$serviceCommandlist = $container->get(DrushServiceModifier::DRUSH_CONSOLE_SERVICES);
if ($container->has(DrushServiceModifier::DRUSH_CONSOLE_SERVICES)) {
foreach ($serviceCommandlist->getCommandList() as $command) {
if (!$this->commandIgnored($command, $ignored_modules)) {
$this->inflect($command);
$this->logger->log(LogLevel::DEBUG_NOTIFY, dt('Add a command: !name', ['!name' => $command->getName()]));
$application->add($command);
}
}
}
// Do the same thing with the annotation commands.
if ($container->has(DrushServiceModifier::DRUSH_COMMAND_SERVICES)) {
$serviceCommandlist = $container->get(DrushServiceModifier::DRUSH_COMMAND_SERVICES);
foreach ($serviceCommandlist->getCommandList() as $commandHandler) {
if (!$this->commandIgnored($commandHandler, $ignored_modules)) {
$this->inflect($commandHandler);
$this->logger->log(LogLevel::DEBUG_NOTIFY, dt('Add a commandfile class: !name', ['!name' => get_class($commandHandler)]));
$runner->registerCommandClass($application, $commandHandler);
}
}
}
}
public function commandIgnored($command, $ignored_modules)
{
if (empty($ignored_modules)) {
return false;
}
$ignored_regex = '#\\\\(' . implode('|', $ignored_modules) . ')\\\\#';
$class = new \ReflectionClass($command);
$commandNamespace = $class->getNamespaceName();
return preg_match($ignored_regex, $commandNamespace);
}
/**
* {@inheritdoc}
*/
public function terminate()
{
parent::terminate();
if ($this->kernel) {
$response = Response::create('');
$this->kernel->terminate($this->getRequest(), $response);
}
}
}
| eigentor/tommiblog | vendor/drush/drush/src/Boot/DrupalBoot8.php | PHP | gpl-2.0 | 9,577 |
/*
** rq_xml_util.h
**
** Written by Brett Hutley - [email protected]
**
** Copyright (C) 2009 Brett Hutley
**
** This file is part of the Risk Quantify Library
**
** Risk Quantify is free software; you can redistribute it and/or
** modify it under the terms of the GNU Library General Public
** License as published by the Free Software Foundation; either
** version 2 of the License, or (at your option) any later version.
**
** Risk Quantify 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
** Library General Public License for more details.
**
** You should have received a copy of the GNU Library General Public
** License along with Risk Quantify; if not, write to the Free
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef rq_xml_util_h
#define rq_xml_util_h
#ifdef __cplusplus
extern "C" {
#if 0
} // purely to not screw up my indenting...
#endif
#endif
#include "rq_stream.h"
/** Get the start and end position of a valid piece of XML. */
RQ_EXPORT rq_error_code rq_xml_util_get_start_end_pos(rq_stream_t stream, const char *tag, long *start_pos, long *end_pos);
#ifdef __cplusplus
#if 0
{ // purely to not screw up my indenting...
#endif
};
#endif
#endif
| stimuli/riskquantify | src/rq/rq_xml_util.h | C | gpl-2.0 | 1,346 |
<!DOCTYPE html>
<html class="">
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" href="/css/styles.css?0" media="all" />
<link rel="stylesheet" href="/css/demo.css?0" media="all" />
<!-- Begin Pattern Lab (Required for Pattern Lab to run properly) -->
<!-- never cache patterns -->
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
<link rel="stylesheet" href="../../styleguide/css/styleguide.min.css?0" media="all">
<link rel="stylesheet" href="../../styleguide/css/prism-typeahead.min.css?0" media="all" />
<!-- End Pattern Lab -->
<link rel="stylesheet" href="/css/styleguide.css?0" media="all" />
</head>
<body class="">
<a class="button is-secondary is-light " href="#">Knap titel</a>
<!--DO NOT REMOVE-->
<script type="text/json" id="sg-pattern-data-footer" class="sg-pattern-data">
{"cssEnabled":false,"lineage":[],"lineageR":[],"patternBreadcrumb":{"patternType":"elements","patternSubtype":"buttons"},"patternDesc":"","patternExtension":"twig","patternName":"button secondary light","patternPartial":"elements-button-secondary-light","patternState":"","extraOutput":[]}
</script>
<script>
/*!
* scriptLoader - v0.1
*
* Copyright (c) 2014 Dave Olsen, http://dmolsen.com
* Licensed under the MIT license
*
*/
var scriptLoader = {
run: function(js,cb,target) {
var s = document.getElementById(target+'-'+cb);
for (var i = 0; i < js.length; i++) {
var src = (typeof js[i] != 'string') ? js[i].src : js[i];
var c = document.createElement('script');
c.src = '../../'+src+'?'+cb;
if (typeof js[i] != 'string') {
if (js[i].dep !== undefined) {
c.onload = function(dep,cb,target) {
return function() {
scriptLoader.run(dep,cb,target);
}
}(js[i].dep,cb,target);
}
}
s.parentNode.insertBefore(c,s);
}
}
}
</script>
<script id="pl-js-polyfill-insert-0">
(function() {
if (self != top) {
var cb = '0';
var js = [];
if (typeof document !== 'undefined' && !('classList' in document.documentElement)) {
js.push('styleguide/bower_components/classList.min.js');
}
scriptLoader.run(js,cb,'pl-js-polyfill-insert');
}
})();
</script>
<script id="pl-js-insert-0">
(function() {
if (self != top) {
var cb = '0';
var js = [ { 'src': 'styleguide/bower_components/jwerty.min.js', 'dep': [ 'styleguide/js/patternlab-pattern.min.js' ] } ];
scriptLoader.run(js,cb,'pl-js-insert');
}
})();
</script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="/assets/js/hamburger-menu.js"></script>
<script src="/assets/js/menu.js"></script>
<script src="/assets/js/filters.js"></script>
<script src="/assets/js/delete-activity.js"></script>
<script src="/assets/js/floating-help.js"></script>
<script src="/assets/js/image-upload.js"></script>
</body>
</html> | aakb/genlydaarhus | styleguide/patterns/00-elements-buttons-button-secondary-light/00-elements-buttons-button-secondary-light.html | HTML | gpl-2.0 | 3,319 |
// _________ __ __
// / _____// |_____________ _/ |______ ____ __ __ ______
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
// \/ \/ \//_____/ \/
// ______________________ ______________________
// T H E W A R B E G I N S
// Stratagus - A free fantasy real time strategy game engine
//
/**@name mainscr.cpp - The main screen. */
//
// (c) Copyright 1998-2007 by Lutz Sammer, Valery Shchedrin, and
// Jimmy Salmon
//
// This program 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; only version 2 of the License.
//
// This program 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 this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
//@{
/*----------------------------------------------------------------------------
-- Includes
----------------------------------------------------------------------------*/
#include "stratagus.h"
#include "action/action_built.h"
#include "action/action_research.h"
#include "action/action_train.h"
#include "action/action_upgradeto.h"
#include "font.h"
#include "icons.h"
#include "interface.h"
#include "map.h"
#include "menus.h"
#include "network.h"
#include "player.h"
#include "settings.h"
#include "sound.h"
#include "spells.h"
#include "translate.h"
#include "trigger.h"
#include "ui/contenttype.h"
#include "ui.h"
#include "unit.h"
#include "unitsound.h"
#include "unittype.h"
#include "upgrade.h"
#include "video.h"
#ifdef DEBUG
#include "../ai/ai_local.h"
#endif
#include <sstream>
/*----------------------------------------------------------------------------
-- UI BUTTONS
----------------------------------------------------------------------------*/
static void DrawMenuButtonArea_noNetwork()
{
if (UI.MenuButton.X != -1) {
DrawUIButton(UI.MenuButton.Style,
(ButtonAreaUnderCursor == ButtonAreaMenu
&& ButtonUnderCursor == ButtonUnderMenu ? MI_FLAGS_ACTIVE : 0) |
(GameMenuButtonClicked ? MI_FLAGS_CLICKED : 0),
UI.MenuButton.X, UI.MenuButton.Y,
UI.MenuButton.Text);
}
}
static void DrawMenuButtonArea_Network()
{
if (UI.NetworkMenuButton.X != -1) {
DrawUIButton(UI.NetworkMenuButton.Style,
(ButtonAreaUnderCursor == ButtonAreaMenu
&& ButtonUnderCursor == ButtonUnderNetworkMenu ? MI_FLAGS_ACTIVE : 0) |
(GameMenuButtonClicked ? MI_FLAGS_CLICKED : 0),
UI.NetworkMenuButton.X, UI.NetworkMenuButton.Y,
UI.NetworkMenuButton.Text);
}
if (UI.NetworkDiplomacyButton.X != -1) {
DrawUIButton(UI.NetworkDiplomacyButton.Style,
(ButtonAreaUnderCursor == ButtonAreaMenu
&& ButtonUnderCursor == ButtonUnderNetworkDiplomacy ? MI_FLAGS_ACTIVE : 0) |
(GameDiplomacyButtonClicked ? MI_FLAGS_CLICKED : 0),
UI.NetworkDiplomacyButton.X, UI.NetworkDiplomacyButton.Y,
UI.NetworkDiplomacyButton.Text);
}
}
/**
** Draw menu button area.
*/
void DrawMenuButtonArea()
{
if (!IsNetworkGame()) {
DrawMenuButtonArea_noNetwork();
} else {
DrawMenuButtonArea_Network();
}
}
void DrawUserDefinedButtons()
{
for (size_t i = 0; i < UI.UserButtons.size(); ++i) {
const CUIUserButton &button = UI.UserButtons[i];
if (button.Button.X != -1) {
DrawUIButton(button.Button.Style,
(ButtonAreaUnderCursor == ButtonAreaUser
&& size_t(ButtonUnderCursor) == i ? MI_FLAGS_ACTIVE : 0) |
(button.Clicked ? MI_FLAGS_CLICKED : 0),
button.Button.X, button.Button.Y,
button.Button.Text);
}
}
}
/*----------------------------------------------------------------------------
-- Icons
----------------------------------------------------------------------------*/
/**
** Draw life bar of a unit at x,y.
** Placed under icons on top-panel.
**
** @param unit Pointer to unit.
** @param x Screen X position of icon
** @param y Screen Y position of icon
*/
static void UiDrawLifeBar(const CUnit &unit, int x, int y)
{
// FIXME: add icon borders
int hBar, hAll;
if (Preference.IconsShift) {
hBar = 6;
hAll = 10;
} else {
hBar = 5;
hAll = 7;
}
y += unit.Type->Icon.Icon->G->Height;
Video.FillRectangleClip(ColorBlack, x - 4, y + 2,
unit.Type->Icon.Icon->G->Width + 8, hAll);
if (unit.Variable[HP_INDEX].Value) {
Uint32 color;
int f = (100 * unit.Variable[HP_INDEX].Value) / unit.Variable[HP_INDEX].Max;
if (f > 75) {
color = ColorDarkGreen;
} else if (f > 50) {
color = ColorYellow;
} else if (f > 25) {
color = ColorOrange;
} else {
color = ColorRed;
}
f = (f * (unit.Type->Icon.Icon->G->Width + 6)) / 100;
Video.FillRectangleClip(color, x - 2, y + 4,
f > 1 ? f - 2 : 0, hBar);
}
}
/**
** Draw mana bar of a unit at x,y.
** Placed under icons on top-panel.
**
** @param unit Pointer to unit.
** @param x Screen X position of icon
** @param y Screen Y position of icon
*/
static void UiDrawManaBar(const CUnit &unit, int x, int y)
{
// FIXME: add icon borders
y += unit.Type->Icon.Icon->G->Height;
Video.FillRectangleClip(ColorBlack, x, y + 3, unit.Type->Icon.Icon->G->Width, 4);
if (unit.Stats->Variables[MANA_INDEX].Max) {
int f = (100 * unit.Variable[MANA_INDEX].Value) / unit.Variable[MANA_INDEX].Max;
f = (f * (unit.Type->Icon.Icon->G->Width)) / 100;
Video.FillRectangleClip(ColorBlue, x + 1, y + 3 + 1, f, 2);
}
}
/**
** Tell if we can show the content.
** verify each sub condition for that.
**
** @param condition condition to verify.
** @param unit unit that certain condition can refer.
**
** @return 0 if we can't show the content, else 1.
*/
static bool CanShowContent(const ConditionPanel *condition, const CUnit &unit)
{
if (!condition) {
return true;
}
if ((condition->ShowOnlySelected && !unit.Selected)
|| (unit.Player->Type == PlayerNeutral && condition->HideNeutral)
|| (ThisPlayer->IsEnemy(unit) && !condition->ShowOpponent)
|| (ThisPlayer->IsAllied(unit) && (unit.Player != ThisPlayer) && condition->HideAllied)) {
return false;
}
if (condition->BoolFlags && !unit.Type->CheckUserBoolFlags(condition->BoolFlags)) {
return false;
}
if (condition->Variables) {
for (unsigned int i = 0; i < UnitTypeVar.GetNumberVariable(); ++i) {
if (condition->Variables[i] != CONDITION_TRUE) {
if ((condition->Variables[i] == CONDITION_ONLY) ^ unit.Variable[i].Enable) {
return false;
}
}
}
}
return true;
}
enum UStrIntType {
USTRINT_STR, USTRINT_INT
};
struct UStrInt {
union {const char *s; int i;};
UStrIntType type;
};
/**
** Return the value corresponding.
**
** @param unit Unit.
** @param index Index of the variable.
** @param e Component of the variable.
** @param t Which var use (0:unit, 1:Type, 2:Stats)
**
** @return Value corresponding
*/
UStrInt GetComponent(const CUnit &unit, int index, EnumVariable e, int t)
{
UStrInt val;
CVariable *var;
Assert((unsigned int) index < UnitTypeVar.GetNumberVariable());
switch (t) {
case 0: // Unit:
var = &unit.Variable[index];
break;
case 1: // Type:
var = &unit.Type->DefaultStat.Variables[index];
break;
case 2: // Stats:
var = &unit.Stats->Variables[index];
break;
default:
DebugPrint("Bad value for GetComponent: t = %d" _C_ t);
var = &unit.Variable[index];
break;
}
switch (e) {
case VariableValue:
val.type = USTRINT_INT;
val.i = var->Value;
break;
case VariableMax:
val.type = USTRINT_INT;
val.i = var->Max;
break;
case VariableIncrease:
val.type = USTRINT_INT;
val.i = var->Increase;
break;
case VariableDiff:
val.type = USTRINT_INT;
val.i = var->Max - var->Value;
break;
case VariablePercent:
Assert(unit.Variable[index].Max != 0);
val.type = USTRINT_INT;
val.i = 100 * var->Value / var->Max;
break;
case VariableName:
if (index == GIVERESOURCE_INDEX) {
val.type = USTRINT_STR;
val.i = unit.Type->GivesResource;
val.s = DefaultResourceNames[unit.Type->GivesResource].c_str();
} else if (index == CARRYRESOURCE_INDEX) {
val.type = USTRINT_STR;
val.i = unit.CurrentResource;
val.s = DefaultResourceNames[unit.CurrentResource].c_str();
} else {
val.type = USTRINT_STR;
val.i = index;
val.s = UnitTypeVar.VariableNameLookup[index];
}
break;
}
return val;
}
UStrInt GetComponent(const CUnitType &type, int index, EnumVariable e, int t)
{
UStrInt val;
CVariable *var;
Assert((unsigned int) index < UnitTypeVar.GetNumberVariable());
switch (t) {
case 0: // Unit:
var = &type.Stats[ThisPlayer->Index].Variables[index];;
break;
case 1: // Type:
var = &type.DefaultStat.Variables[index];
break;
case 2: // Stats:
var = &type.Stats[ThisPlayer->Index].Variables[index];
break;
default:
DebugPrint("Bad value for GetComponent: t = %d" _C_ t);
var = &type.Stats[ThisPlayer->Index].Variables[index];
break;
}
switch (e) {
case VariableValue:
val.type = USTRINT_INT;
val.i = var->Value;
break;
case VariableMax:
val.type = USTRINT_INT;
val.i = var->Max;
break;
case VariableIncrease:
val.type = USTRINT_INT;
val.i = var->Increase;
break;
case VariableDiff:
val.type = USTRINT_INT;
val.i = var->Max - var->Value;
break;
case VariablePercent:
Assert(type.Stats[ThisPlayer->Index].Variables[index].Max != 0);
val.type = USTRINT_INT;
val.i = 100 * var->Value / var->Max;
break;
case VariableName:
if (index == GIVERESOURCE_INDEX) {
val.type = USTRINT_STR;
val.i = type.GivesResource;
val.s = DefaultResourceNames[type.GivesResource].c_str();
} else {
val.type = USTRINT_STR;
val.i = index;
val.s = UnitTypeVar.VariableNameLookup[index];
}
break;
}
return val;
}
static void DrawUnitInfo_Training(const CUnit &unit)
{
if (unit.Orders.size() == 1 || unit.Orders[1]->Action != UnitActionTrain) {
if (!UI.SingleTrainingText.empty()) {
CLabel label(*UI.SingleTrainingFont);
label.Draw(UI.SingleTrainingTextX, UI.SingleTrainingTextY, UI.SingleTrainingText);
}
if (UI.SingleTrainingButton) {
const COrder_Train &order = *static_cast<COrder_Train *>(unit.CurrentOrder());
CIcon &icon = *order.GetUnitType().Icon.Icon;
const unsigned int flags = (ButtonAreaUnderCursor == ButtonAreaTraining && ButtonUnderCursor == 0) ?
(IconActive | (MouseButtons & LeftButton)) : 0;
const PixelPos pos(UI.SingleTrainingButton->X, UI.SingleTrainingButton->Y);
icon.DrawUnitIcon(*UI.SingleTrainingButton->Style, flags, pos, "", unit.RescuedFrom
? GameSettings.Presets[unit.RescuedFrom->Index].PlayerColor
: GameSettings.Presets[unit.Player->Index].PlayerColor);
}
} else {
if (!UI.TrainingText.empty()) {
CLabel label(*UI.TrainingFont);
label.Draw(UI.TrainingTextX, UI.TrainingTextY, UI.TrainingText);
}
if (!UI.TrainingButtons.empty()) {
for (size_t i = 0; i < unit.Orders.size()
&& i < UI.TrainingButtons.size(); ++i) {
if (unit.Orders[i]->Action == UnitActionTrain) {
const COrder_Train &order = *static_cast<COrder_Train *>(unit.Orders[i]);
CIcon &icon = *order.GetUnitType().Icon.Icon;
const int flag = (ButtonAreaUnderCursor == ButtonAreaTraining
&& static_cast<size_t>(ButtonUnderCursor) == i) ?
(IconActive | (MouseButtons & LeftButton)) : 0;
const PixelPos pos(UI.TrainingButtons[i].X, UI.TrainingButtons[i].Y);
icon.DrawUnitIcon(*UI.TrainingButtons[i].Style, flag, pos, "", unit.RescuedFrom
? GameSettings.Presets[unit.RescuedFrom->Index].PlayerColor
: GameSettings.Presets[unit.Player->Index].PlayerColor);
}
}
}
}
}
static void DrawUnitInfo_portrait(const CUnit &unit)
{
const CUnitType &type = *unit.Type;
#ifdef USE_MNG
if (type.Portrait.Num) {
type.Portrait.Mngs[type.Portrait.CurrMng]->Draw(
UI.SingleSelectedButton->X, UI.SingleSelectedButton->Y);
if (type.Portrait.Mngs[type.Portrait.CurrMng]->iteration == type.Portrait.NumIterations) {
type.Portrait.Mngs[type.Portrait.CurrMng]->Reset();
// FIXME: should be configurable
if (type.Portrait.CurrMng == 0) {
type.Portrait.CurrMng = (SyncRand() % (type.Portrait.Num - 1)) + 1;
type.Portrait.NumIterations = 1;
} else {
type.Portrait.CurrMng = 0;
type.Portrait.NumIterations = SyncRand() % 16 + 1;
}
}
return;
}
#endif
if (UI.SingleSelectedButton) {
const PixelPos pos(UI.SingleSelectedButton->X, UI.SingleSelectedButton->Y);
const int flag = (ButtonAreaUnderCursor == ButtonAreaSelected && ButtonUnderCursor == 0) ?
(IconActive | (MouseButtons & LeftButton)) : 0;
type.Icon.Icon->DrawUnitIcon(*UI.SingleSelectedButton->Style, flag, pos, "", unit.RescuedFrom
? GameSettings.Presets[unit.RescuedFrom->Index].PlayerColor
: GameSettings.Presets[unit.Player->Index].PlayerColor);
}
}
static bool DrawUnitInfo_single_selection(const CUnit &unit)
{
switch (unit.CurrentAction()) {
case UnitActionTrain: { // Building training units.
DrawUnitInfo_Training(unit);
return true;
}
case UnitActionUpgradeTo: { // Building upgrading to better type.
if (UI.UpgradingButton) {
const COrder_UpgradeTo &order = *static_cast<COrder_UpgradeTo *>(unit.CurrentOrder());
CIcon &icon = *order.GetUnitType().Icon.Icon;
unsigned int flag = (ButtonAreaUnderCursor == ButtonAreaUpgrading
&& ButtonUnderCursor == 0) ?
(IconActive | (MouseButtons & LeftButton)) : 0;
const PixelPos pos(UI.UpgradingButton->X, UI.UpgradingButton->Y);
icon.DrawUnitIcon(*UI.UpgradingButton->Style, flag, pos, "", unit.RescuedFrom
? GameSettings.Presets[unit.RescuedFrom->Index].PlayerColor
: GameSettings.Presets[unit.Player->Index].PlayerColor);
}
return true;
}
case UnitActionResearch: { // Building research new technology.
if (UI.ResearchingButton) {
COrder_Research &order = *static_cast<COrder_Research *>(unit.CurrentOrder());
CIcon &icon = *order.GetUpgrade().Icon;
int flag = (ButtonAreaUnderCursor == ButtonAreaResearching
&& ButtonUnderCursor == 0) ?
(IconActive | (MouseButtons & LeftButton)) : 0;
PixelPos pos(UI.ResearchingButton->X, UI.ResearchingButton->Y);
icon.DrawUnitIcon(*UI.ResearchingButton->Style, flag, pos, "", unit.RescuedFrom
? GameSettings.Presets[unit.RescuedFrom->Index].PlayerColor
: GameSettings.Presets[unit.Player->Index].PlayerColor);
}
return true;
}
default:
return false;
}
}
static void DrawUnitInfo_transporter(CUnit &unit)
{
CUnit *uins = unit.UnitInside;
size_t j = 0;
for (int i = 0; i < unit.InsideCount; ++i, uins = uins->NextContained) {
if (!uins->Boarded || j >= UI.TransportingButtons.size()) {
continue;
}
CIcon &icon = *uins->Type->Icon.Icon;
int flag = (ButtonAreaUnderCursor == ButtonAreaTransporting && static_cast<size_t>(ButtonUnderCursor) == j) ?
(IconActive | (MouseButtons & LeftButton)) : 0;
const PixelPos pos(UI.TransportingButtons[j].X, UI.TransportingButtons[j].Y);
icon.DrawUnitIcon(*UI.TransportingButtons[j].Style, flag, pos, "", unit.RescuedFrom
? GameSettings.Presets[unit.RescuedFrom->Index].PlayerColor
: GameSettings.Presets[unit.Player->Index].PlayerColor);
UiDrawLifeBar(*uins, pos.x, pos.y);
if (uins->Type->CanCastSpell && uins->Variable[MANA_INDEX].Max) {
UiDrawManaBar(*uins, pos.x, pos.y);
}
if (ButtonAreaUnderCursor == ButtonAreaTransporting
&& static_cast<size_t>(ButtonUnderCursor) == j) {
UI.StatusLine.Set(uins->Type->Name);
}
++j;
}
}
/**
** Draw the unit info into top-panel.
**
** @param unit Pointer to unit.
*/
static void DrawUnitInfo(CUnit &unit)
{
UpdateUnitVariables(unit);
for (size_t i = 0; i != UI.InfoPanelContents.size(); ++i) {
if (CanShowContent(UI.InfoPanelContents[i]->Condition, unit)) {
for (std::vector<CContentType *>::const_iterator content = UI.InfoPanelContents[i]->Contents.begin();
content != UI.InfoPanelContents[i]->Contents.end(); ++content) {
if (CanShowContent((*content)->Condition, unit)) {
(*content)->Draw(unit, UI.InfoPanelContents[i]->DefaultFont);
}
}
}
}
const CUnitType &type = *unit.Type;
Assert(&type);
// Draw IconUnit
DrawUnitInfo_portrait(unit);
if (unit.Player != ThisPlayer && !ThisPlayer->IsAllied(*unit.Player)) {
return;
}
// Show progress if they are selected.
if (IsOnlySelected(unit)) {
if (DrawUnitInfo_single_selection(unit)) {
return;
}
}
// Transporting units.
if (type.CanTransport() && unit.BoardCount && CurrentButtonLevel == unit.Type->ButtonLevelForTransporter) {
DrawUnitInfo_transporter(unit);
return;
}
}
/*----------------------------------------------------------------------------
-- RESOURCES
----------------------------------------------------------------------------*/
/**
** Draw the player resource in top line.
**
** @todo FIXME : make DrawResources more configurable (format, font).
*/
void DrawResources()
{
CLabel label(GetGameFont());
// Draw all icons of resource.
for (int i = 0; i <= FreeWorkersCount; ++i) {
if (UI.Resources[i].G) {
UI.Resources[i].G->DrawFrameClip(UI.Resources[i].IconFrame,
UI.Resources[i].IconX, UI.Resources[i].IconY);
}
}
for (int i = 0; i < MaxCosts; ++i) {
if (UI.Resources[i].TextX != -1) {
const int resourceAmount = ThisPlayer->Resources[i];
if (ThisPlayer->MaxResources[i] != -1) {
const int resAmount = ThisPlayer->StoredResources[i] + ThisPlayer->Resources[i];
char tmp[256];
snprintf(tmp, sizeof(tmp), "%d (%d)", resAmount, ThisPlayer->MaxResources[i] - ThisPlayer->StoredResources[i]);
label.SetFont(GetSmallFont());
label.Draw(UI.Resources[i].TextX, UI.Resources[i].TextY + 3, tmp);
} else {
label.SetFont(resourceAmount > 99999 ? GetSmallFont() : GetGameFont());
label.Draw(UI.Resources[i].TextX, UI.Resources[i].TextY + (resourceAmount > 99999) * 3, resourceAmount);
}
}
}
if (UI.Resources[FoodCost].TextX != -1) {
char tmp[256];
snprintf(tmp, sizeof(tmp), "%d/%d", ThisPlayer->Demand, ThisPlayer->Supply);
label.SetFont(GetGameFont());
if (ThisPlayer->Supply < ThisPlayer->Demand) {
label.DrawReverse(UI.Resources[FoodCost].TextX, UI.Resources[FoodCost].TextY, tmp);
} else {
label.Draw(UI.Resources[FoodCost].TextX, UI.Resources[FoodCost].TextY, tmp);
}
}
if (UI.Resources[ScoreCost].TextX != -1) {
const int score = ThisPlayer->Score;
label.SetFont(score > 99999 ? GetSmallFont() : GetGameFont());
label.Draw(UI.Resources[ScoreCost].TextX, UI.Resources[ScoreCost].TextY + (score > 99999) * 3, score);
}
if (UI.Resources[FreeWorkersCount].TextX != -1) {
const int workers = ThisPlayer->FreeWorkers.size();
label.SetFont(GetGameFont());
label.Draw(UI.Resources[FreeWorkersCount].TextX, UI.Resources[FreeWorkersCount].TextY, workers);
}
}
/*----------------------------------------------------------------------------
-- MESSAGE
----------------------------------------------------------------------------*/
#define MESSAGES_MAX 10 /// How many can be displayed
static char MessagesEvent[MESSAGES_MAX][256]; /// Array of event messages
static Vec2i MessagesEventPos[MESSAGES_MAX]; /// coordinate of event
static int MessagesEventCount; /// Number of event messages
static int MessagesEventIndex; /// FIXME: docu
class MessagesDisplay
{
public:
MessagesDisplay() : show(true)
{
#ifdef DEBUG
showBuilList = false;
#endif
CleanMessages();
}
void UpdateMessages();
void AddUniqueMessage(const char *s);
void DrawMessages();
void CleanMessages();
void ToggleShowMessages() { show = !show; }
#ifdef DEBUG
void ToggleShowBuilListMessages() { showBuilList = !showBuilList; }
#endif
protected:
void ShiftMessages();
void AddMessage(const char *msg);
bool CheckRepeatMessage(const char *msg);
private:
char Messages[MESSAGES_MAX][256]; /// Array of messages
int MessagesCount; /// Number of messages
int MessagesSameCount; /// Counts same message repeats
int MessagesScrollY;
unsigned long MessagesFrameTimeout; /// Frame to expire message
bool show;
#ifdef DEBUG
bool showBuilList;
#endif
};
/**
** Shift messages array by one.
*/
void MessagesDisplay::ShiftMessages()
{
if (MessagesCount) {
--MessagesCount;
for (int z = 0; z < MessagesCount; ++z) {
strcpy_s(Messages[z], sizeof(Messages[z]), Messages[z + 1]);
}
}
}
/**
** Update messages
**
** @todo FIXME: make scroll speed configurable.
*/
void MessagesDisplay::UpdateMessages()
{
if (!MessagesCount) {
return;
}
// Scroll/remove old message line
const unsigned long ticks = GetTicks();
if (MessagesFrameTimeout < ticks) {
++MessagesScrollY;
if (MessagesScrollY == UI.MessageFont->Height() + 1) {
MessagesFrameTimeout = ticks + UI.MessageScrollSpeed * 1000;
MessagesScrollY = 0;
ShiftMessages();
}
}
}
/**
** Draw message(s).
**
** @todo FIXME: make message font configurable.
*/
void MessagesDisplay::DrawMessages()
{
if (show && Preference.ShowMessages) {
CLabel label(*UI.MessageFont);
#ifdef DEBUG
if (showBuilList && ThisPlayer->Ai) {
char buffer[256];
int count = ThisPlayer->Ai->UnitTypeBuilt.size();
// Draw message line(s)
for (int z = 0; z < count; ++z) {
if (z == 0) {
PushClipping();
SetClipping(UI.MapArea.X + 8, UI.MapArea.Y + 8,
Video.Width - 1, Video.Height - 1);
}
snprintf(buffer, 256, "%s (%d/%d) Wait %lu [%d,%d]",
ThisPlayer->Ai->UnitTypeBuilt[z].Type->Name.c_str(),
ThisPlayer->Ai->UnitTypeBuilt[z].Made,
ThisPlayer->Ai->UnitTypeBuilt[z].Want,
ThisPlayer->Ai->UnitTypeBuilt[z].Wait,
ThisPlayer->Ai->UnitTypeBuilt[z].Pos.x,
ThisPlayer->Ai->UnitTypeBuilt[z].Pos.y);
label.DrawClip(UI.MapArea.X + 8,
UI.MapArea.Y + 8 + z * (UI.MessageFont->Height() + 1),
buffer);
if (z == 0) {
PopClipping();
}
}
} else {
#endif
// background so the text is easier to read
if (MessagesCount) {
int textHeight = MessagesCount * (UI.MessageFont->Height() + 1);
Uint32 color = Video.MapRGB(TheScreen->format, 38, 38, 78);
Video.FillTransRectangleClip(color, UI.MapArea.X + 7, UI.MapArea.Y + 7,
UI.MapArea.EndX - UI.MapArea.X - 16,
textHeight - MessagesScrollY + 1, 0x80);
Video.DrawRectangle(color, UI.MapArea.X + 6, UI.MapArea.Y + 6,
UI.MapArea.EndX - UI.MapArea.X - 15,
textHeight - MessagesScrollY + 2);
}
// Draw message line(s)
for (int z = 0; z < MessagesCount; ++z) {
if (z == 0) {
PushClipping();
SetClipping(UI.MapArea.X + 8, UI.MapArea.Y + 8, Video.Width - 1,
Video.Height - 1);
}
/*
* Due parallel drawing we have to force message copy due temp
* std::string(Messages[z]) creation because
* char * pointer may change during text drawing.
*/
label.DrawClip(UI.MapArea.X + 8,
UI.MapArea.Y + 8 +
z * (UI.MessageFont->Height() + 1) - MessagesScrollY,
std::string(Messages[z]));
if (z == 0) {
PopClipping();
}
}
if (MessagesCount < 1) {
MessagesSameCount = 0;
}
#ifdef DEBUG
}
#endif
}
}
/**
** Adds message to the stack
**
** @param msg Message to add.
*/
void MessagesDisplay::AddMessage(const char *msg)
{
unsigned long ticks = GetTicks();
if (!MessagesCount) {
MessagesFrameTimeout = ticks + UI.MessageScrollSpeed * 1000;
}
if (MessagesCount == MESSAGES_MAX) {
// Out of space to store messages, can't scroll smoothly
ShiftMessages();
MessagesFrameTimeout = ticks + UI.MessageScrollSpeed * 1000;
MessagesScrollY = 0;
}
char *ptr;
char *next;
char *message = Messages[MessagesCount];
// Split long message into lines
if (strlen(msg) >= sizeof(Messages[0])) {
strncpy(message, msg, sizeof(Messages[0]) - 1);
ptr = message + sizeof(Messages[0]) - 1;
*ptr-- = '\0';
next = ptr + 1;
while (ptr >= message) {
if (*ptr == ' ') {
*ptr = '\0';
next = ptr + 1;
break;
}
--ptr;
}
if (ptr < message) {
ptr = next - 1;
}
} else {
strcpy_s(message, sizeof(Messages[MessagesCount]), msg);
next = ptr = message + strlen(message);
}
while (UI.MessageFont->Width(message) + 8 >= UI.MapArea.EndX - UI.MapArea.X) {
while (1) {
--ptr;
if (*ptr == ' ') {
*ptr = '\0';
next = ptr + 1;
break;
} else if (ptr == message) {
break;
}
}
// No space found, wrap in the middle of a word
if (ptr == message) {
ptr = next - 1;
while (UI.MessageFont->Width(message) + 8 >= UI.MapArea.EndX - UI.MapArea.X) {
*--ptr = '\0';
}
next = ptr + 1;
break;
}
}
++MessagesCount;
if (strlen(msg) != (size_t)(ptr - message)) {
AddMessage(msg + (next - message));
}
}
/**
** Check if this message repeats
**
** @param msg Message to check.
**
** @return true to skip this message
*/
bool MessagesDisplay::CheckRepeatMessage(const char *msg)
{
if (MessagesCount < 1) {
return false;
}
if (!strcmp(msg, Messages[MessagesCount - 1])) {
++MessagesSameCount;
return true;
}
if (MessagesSameCount > 0) {
char temp[256];
int n = MessagesSameCount;
MessagesSameCount = 0;
// NOTE: vladi: yep it's a tricky one, but should work fine prbably :)
snprintf(temp, sizeof(temp), _("Last message repeated ~<%d~> times"), n + 1);
AddMessage(temp);
}
return false;
}
/**
** Add a new message to display only if it differs from the preceding one.
*/
void MessagesDisplay::AddUniqueMessage(const char *s)
{
if (!CheckRepeatMessage(s)) {
AddMessage(s);
}
}
/**
** Clean up messages.
*/
void MessagesDisplay::CleanMessages()
{
MessagesCount = 0;
MessagesSameCount = 0;
MessagesScrollY = 0;
MessagesFrameTimeout = 0;
MessagesEventCount = 0;
MessagesEventIndex = 0;
}
static MessagesDisplay allmessages;
/**
** Update messages
*/
void UpdateMessages()
{
allmessages.UpdateMessages();
}
/**
** Clean messages
*/
void CleanMessages()
{
allmessages.CleanMessages();
}
/**
** Draw messages
*/
void DrawMessages()
{
allmessages.DrawMessages();
}
/**
** Set message to display.
**
** @param fmt To be displayed in text overlay.
*/
void SetMessage(const char *fmt, ...)
{
char temp[512];
va_list va;
va_start(va, fmt);
vsnprintf(temp, sizeof(temp) - 1, fmt, va);
temp[sizeof(temp) - 1] = '\0';
va_end(va);
allmessages.AddUniqueMessage(temp);
}
/**
** Shift messages events array by one.
*/
void ShiftMessagesEvent()
{
if (MessagesEventCount) {
--MessagesEventCount;
for (int z = 0; z < MessagesEventCount; ++z) {
MessagesEventPos[z] = MessagesEventPos[z + 1];
strcpy_s(MessagesEvent[z], sizeof(MessagesEvent[z]), MessagesEvent[z + 1]);
}
}
}
/**
** Set message to display.
**
** @param pos Message pos map origin.
** @param fmt To be displayed in text overlay.
**
** @note FIXME: vladi: I know this can be just separated func w/o msg but
** it is handy to stick all in one call, someone?
*/
void SetMessageEvent(const Vec2i &pos, const char *fmt, ...)
{
Assert(Map.Info.IsPointOnMap(pos));
char temp[256];
va_list va;
va_start(va, fmt);
vsnprintf(temp, sizeof(temp) - 1, fmt, va);
temp[sizeof(temp) - 1] = '\0';
va_end(va);
allmessages.AddUniqueMessage(temp);
if (MessagesEventCount == MESSAGES_MAX) {
ShiftMessagesEvent();
}
strcpy_s(MessagesEvent[MessagesEventCount], sizeof(MessagesEvent[MessagesEventCount]), temp);
MessagesEventPos[MessagesEventCount] = pos;
MessagesEventIndex = MessagesEventCount;
++MessagesEventCount;
}
/**
** Goto message origin.
*/
void CenterOnMessage()
{
if (MessagesEventIndex >= MessagesEventCount) {
MessagesEventIndex = 0;
}
if (MessagesEventCount == 0) {
return;
}
const Vec2i &pos(MessagesEventPos[MessagesEventIndex]);
UI.SelectedViewport->Center(Map.TilePosToMapPixelPos_Center(pos));
SetMessage(_("~<Event: %s~>"), MessagesEvent[MessagesEventIndex]);
++MessagesEventIndex;
}
void ToggleShowMessages()
{
allmessages.ToggleShowMessages();
}
#ifdef DEBUG
void ToggleShowBuilListMessages()
{
allmessages.ToggleShowBuilListMessages();
}
#endif
/*----------------------------------------------------------------------------
-- INFO PANEL
----------------------------------------------------------------------------*/
/**
** Draw info panel background.
**
** @param frame frame nr. of the info panel background.
*/
static void DrawInfoPanelBackground(unsigned frame)
{
if (UI.InfoPanel.G) {
UI.InfoPanel.G->DrawFrame(frame, UI.InfoPanel.X, UI.InfoPanel.Y);
}
}
static void InfoPanel_draw_no_selection()
{
DrawInfoPanelBackground(0);
if (UnitUnderCursor && UnitUnderCursor->IsVisible(*ThisPlayer)
&& !UnitUnderCursor->Type->BoolFlag[ISNOTSELECTABLE_INDEX].value) {
// FIXME: not correct for enemies units
DrawUnitInfo(*UnitUnderCursor);
} else {
// FIXME: need some cool ideas for this.
int x = UI.InfoPanel.X + 16;
int y = UI.InfoPanel.Y + 8;
CLabel label(GetGameFont());
label.Draw(x, y, "Stratagus");
y += 16;
label.Draw(x, y, _("Cycle:"));
label.Draw(x + 48, y, GameCycle);
label.Draw(x + 110, y, CYCLES_PER_SECOND * VideoSyncSpeed / 100);
y += 20;
std::string nc;
std::string rc;
GetDefaultTextColors(nc, rc);
for (int i = 0; i < PlayerMax - 1; ++i) {
if (Players[i].Type != PlayerNobody) {
if (ThisPlayer->IsAllied(Players[i])) {
label.SetNormalColor(FontGreen);
} else if (ThisPlayer->IsEnemy(Players[i])) {
label.SetNormalColor(FontRed);
} else {
label.SetNormalColor(nc);
}
label.Draw(x + 15, y, i);
Video.DrawRectangleClip(ColorWhite, x, y, 12, 12);
Video.FillRectangleClip(PlayerColors[GameSettings.Presets[i].PlayerColor][0], x + 1, y + 1, 10, 10);
label.Draw(x + 27, y, Players[i].Name);
label.Draw(x + 117, y, Players[i].Score);
y += 14;
}
}
}
}
static void InfoPanel_draw_single_selection(CUnit *selUnit)
{
CUnit &unit = (selUnit ? *selUnit : *Selected[0]);
int panelIndex;
// FIXME: not correct for enemy's units
if (unit.Player == ThisPlayer
|| ThisPlayer->IsTeamed(unit)
|| ThisPlayer->IsAllied(unit)
|| ReplayRevealMap) {
if (unit.Orders[0]->Action == UnitActionBuilt
|| unit.Orders[0]->Action == UnitActionResearch
|| unit.Orders[0]->Action == UnitActionUpgradeTo
|| unit.Orders[0]->Action == UnitActionTrain) {
panelIndex = 3;
} else if (unit.Stats->Variables[MANA_INDEX].Max) {
panelIndex = 2;
} else {
panelIndex = 1;
}
} else {
panelIndex = 0;
}
DrawInfoPanelBackground(panelIndex);
DrawUnitInfo(unit);
if (ButtonAreaUnderCursor == ButtonAreaSelected && ButtonUnderCursor == 0) {
UI.StatusLine.Set(unit.Type->Name);
}
}
static void InfoPanel_draw_multiple_selection()
{
// If there are more units selected draw their pictures and a health bar
DrawInfoPanelBackground(0);
for (size_t i = 0; i != std::min(Selected.size(), UI.SelectedButtons.size()); ++i) {
const CIcon &icon = *Selected[i]->Type->Icon.Icon;
const PixelPos pos(UI.SelectedButtons[i].X, UI.SelectedButtons[i].Y);
icon.DrawUnitIcon(*UI.SelectedButtons[i].Style,
(ButtonAreaUnderCursor == ButtonAreaSelected && ButtonUnderCursor == (int)i) ?
(IconActive | (MouseButtons & LeftButton)) : 0,
pos, "", Selected[i]->RescuedFrom
? GameSettings.Presets[Selected[i]->RescuedFrom->Index].PlayerColor
: GameSettings.Presets[Selected[i]->Player->Index].PlayerColor);
UiDrawLifeBar(*Selected[i], UI.SelectedButtons[i].X, UI.SelectedButtons[i].Y);
if (ButtonAreaUnderCursor == ButtonAreaSelected && ButtonUnderCursor == (int) i) {
UI.StatusLine.Set(Selected[i]->Type->Name);
}
}
if (Selected.size() > UI.SelectedButtons.size()) {
char buf[5];
sprintf(buf, "+%lu", (long unsigned int)(Selected.size() - UI.SelectedButtons.size()));
CLabel(*UI.MaxSelectedFont).Draw(UI.MaxSelectedTextX, UI.MaxSelectedTextY, buf);
}
}
/**
** Draw info panel.
**
** Panel:
** neutral - neutral or opponent
** normal - not 1,3,4
** magic unit - magic units
** construction - under construction
*/
void CInfoPanel::Draw()
{
if (UnitUnderCursor && Selected.empty() && !UnitUnderCursor->Type->IsNotSelectable
&& (ReplayRevealMap || UnitUnderCursor->IsVisible(*ThisPlayer))) {
InfoPanel_draw_single_selection(UnitUnderCursor);
} else {
switch (Selected.size()) {
case 0: { InfoPanel_draw_no_selection(); break; }
case 1: { InfoPanel_draw_single_selection(NULL); break; }
default: { InfoPanel_draw_multiple_selection(); break; }
}
}
}
/*----------------------------------------------------------------------------
-- TIMER
----------------------------------------------------------------------------*/
/**
** Draw the timer
**
** @todo FIXME : make DrawTimer more configurable (Pos, format).
*/
void DrawTimer()
{
if (!GameTimer.Init) {
return;
}
int sec = GameTimer.Cycles / CYCLES_PER_SECOND;
UI.Timer.Draw(sec);
}
/**
** Update the timer
*/
void UpdateTimer()
{
if (GameTimer.Running) {
if (GameTimer.Increasing) {
GameTimer.Cycles += GameCycle - GameTimer.LastUpdate;
} else {
GameTimer.Cycles -= GameCycle - GameTimer.LastUpdate;
GameTimer.Cycles = std::max(GameTimer.Cycles, 0l);
}
GameTimer.LastUpdate = GameCycle;
}
}
//@}
| Stratagus/Stratagus | src/ui/mainscr.cpp | C++ | gpl-2.0 | 33,991 |
function isPrime(n) {
if (n === 2) {
return true;
}
if (n % 2 === 0 || n === 1) {
return false;
}
for (var i = 3; i <= Math.sqrt(n); i += 2) {
if (n % i === 0) {
return false;
}
}
return true;
}
function nthPrimeNumber(n) {
if (n <= 0) {
throw new Error('Must be an integer >= 1');
}
var numPrime = 1;
var i = 1;
if (n === 1) {
return 2;
}
while (numPrime < n) {
i += 2;
if (isPrime(i)) {
numPrime++;
}
}
return i;
}
console.log(nthPrimeNumber(10001));
| pbjr23/project-euler-js | pr7.js | JavaScript | gpl-2.0 | 536 |
<?php
/**
* glFusion CMS
*
* UTF-8 Language File for Calendar Plugin
*
* @license GNU General Public License version 2 or later
* http://www.opensource.org/licenses/gpl-license.php
*
* Copyright (C) 2008-2018 by the following authors:
* Mark R. Evans mark AT glfusion DOT org
*
* Based on prior work Copyright (C) 2001-2005 by the following authors:
* Tony Bibbs - tony AT tonybibbs DOT com
* Trinity Bays - trinity93 AT gmail DOT com
*
*/
if (!defined ('GVERSION')) {
die ('This file cannot be used on its own.');
}
global $LANG32;
###############################################################################
# Array Format:
# $LANGXX[YY]: $LANG - variable name
# XX - file id number
# YY - phrase id number
###############################################################################
# index.php
$LANG_CAL_1 = array(
1 => 'Tapahtumakalenteri',
2 => 'Ei tapahtumia.',
3 => 'Milloin',
4 => 'Juuri',
5 => 'Kuvaus',
6 => 'Lisää tapahtuma',
7 => 'Tulevat tapahtumat',
8 => 'Lisäämällä tämän taphtuman kalenteriisi, näet nopeasti ne tapahtumat jotka sinua kiinnostaa klikkaamalla "Oma Kalenteri" käyttäjän toiminnot alueella.',
9 => 'Lisää minun jalenteriin',
10 => 'Poista minun kalenterista',
11 => 'Lisätään tapahtuma %s\'s Kalenteriin',
12 => 'Tapahtuma',
13 => 'Alkaa',
14 => 'Loppuu',
15 => 'Takaisin kalenteriin',
16 => 'Kalenteri',
17 => 'Aloituspäivä',
18 => 'Lopetuspäivä',
19 => 'kalenteriin lähetetyt',
20 => 'Otsikko',
21 => 'Alkamis päivä',
22 => 'URL',
23 => 'Sinun tapahtumat',
24 => 'Sivuston tapahtumat',
25 => 'Ei tulevia tapahtumia',
26 => 'Lähetä tapahtuma',
27 => "Lähetetään tapahtuma {$_CONF['site_name']} laitaa tapahtuman pääkalenteriin josta käyttäjät voi lisätä heidän omaan kalenteriin. Tämä toiminto <b>EI</b> ole tarkoitettu henkilökohtaisiin tapahtumiin kuten syntymäpäivät yms tapahtumat.<br><br>Kun olet lähettänyt tapahtumasi, se lähetetään ylläpitoon ja jos se hyväksytään, tapahtumasai ilmestyy pääkalenteriin.",
28 => 'Otsikko',
29 => 'Päättymis aika',
30 => 'Alamis aika',
31 => 'Kokopäivän tapahtuma',
32 => 'Osoiterivi 1',
33 => 'Osoiterivi 2',
34 => 'Kaupunki',
35 => 'Osavaltio',
36 => 'Postinumero',
37 => 'Tapahtuman tyyppi',
38 => 'Muokkaa tapahtuma tyyppejä',
39 => 'Sijainti',
40 => 'Lisää tapahtuma kohteeseen',
41 => 'Pääkalenteri',
42 => 'Henkilökohtainen kalenteri',
43 => 'Linkki',
44 => 'HTML koodit eivät ole sallittu',
45 => 'Lähetä',
46 => 'Tapahtumat systeemissä',
47 => 'Top kymmenen tapahtumat',
48 => 'Lukukertoja',
49 => 'Näyttää siltä että tällä sivustolla ei ole tapahtumia, tai kukaan ei ole klikannut niitä.',
50 => 'Tapahtumat',
51 => 'Poista',
52 => 'Lähetti',
53 => 'Calendar View',
);
$_LANG_CAL_SEARCH = array(
'results' => 'Kalenteri tulokset',
'title' => 'Otsikko',
'date_time' => 'Päivä & Aika',
'location' => 'Sijainti',
'description' => 'Kuvaus'
);
###############################################################################
# calendar.php ($LANG30)
$LANG_CAL_2 = array(
8 => 'Lisää oma tapahtuma',
9 => '%s Tapahtuma',
10 => 'Tapahtumat ',
11 => 'Pääkalenteri',
12 => 'Oma kalenteri',
25 => 'Takaisin ',
26 => 'Koko päivän',
27 => 'Viikko',
28 => 'Oma kalenteri kohteelle',
29 => ' Julkinen kalenteri',
30 => 'poista tapahtuma',
31 => 'Lisää',
32 => 'Tapahtuma',
33 => 'Päivä',
34 => 'Aika',
35 => 'Nopea lisäys',
36 => 'Lähetä',
37 => 'Oma kalenteri toiminto ei ole käytössä',
38 => 'Oma tapahtuma muokkaus',
39 => 'Päivä',
40 => 'Viikko',
41 => 'Kuukausi',
42 => 'Lisää päätapahtuma',
43 => 'Lähetetyt tapahtumat'
);
###############################################################################
# admin/plugins/calendar/index.php, formerly admin/event.php ($LANG22)
$LANG_CAL_ADMIN = array(
1 => 'Tapahtuma Muokkaus',
2 => 'Virhe',
3 => 'Viestin muoto',
4 => 'Tapahtuman URL',
5 => 'Tapahtuman alkamispäivä',
6 => 'Tapahtuman päättymispäivä',
7 => 'Tapahtuman sijainti',
8 => 'Kuvaus tapahtumasta',
9 => '(mukaanlukien http://)',
10 => 'Sinun täytyy antaa päivä/aika, tapahtuman otsikko, ja kuvaus tapahtumasta',
11 => 'Kalenteri hallinta',
12 => 'Muokataksesi tai poistaaksesi tapahtuman, klikkaa tapahtuman edit ikonia alhaalla. Uuden tapahtuman luodaksesi klikkaa "Luo uusi" ylhäältä. Klikkaa kopioi ikonia kopioidaksesi olemassaolevan tapahtuman.',
13 => 'Omistaja',
14 => 'Alkamispäivä',
15 => 'Päättymispäivä',
16 => '',
17 => "Yrität päästä tapahtumaan johon sinulla ei ole pääsy oikeutta. Tämä yrtitys kirjattiin. <a href=\"{$_CONF['site_admin_url']}/plugins/calendar/index.php\">mene takaisin tapahtuman hallintaan</a>.",
18 => '',
19 => '',
20 => 'tallenna',
21 => 'peruuta',
22 => 'poista',
23 => 'Epäkelpo Alkamis Päivä.',
24 => 'Epäkelpo päättymis Päivä.',
25 => 'Päättymispäivä On Aikaisemmin Kuin Alkamispäivä.',
26 => 'Batch Event Manager',
27 => 'Tässä ovat kaikki tapahtumat jotka ovat vanhempia kuin ',
28 => ' kuukautta. Päivitä aikaväli halutuksi, ja klikkaa Päivitä Lista. valitse yksi tai useampia tapahtumia tuloksista, ja klikkaa poista Ikonia alla poistaaksesi nämä tapahtumat. Vain tapahtumat jotka näkyy tällä sivulla ja on listattu, poistetaan.',
29 => '',
30 => 'Päivitä Lista',
31 => 'Oletko varma että haluat poistaa kaikki valitut käyttäjät?',
32 => 'Listaa kaikki',
33 => 'Yhtään tapahtumaa ei valittu poistettavaksi',
34 => 'Tapahtuman ID',
35 => 'ei voitu poistaa',
36 => 'Poistettu',
37 => 'Moderoi Tapahtumaa',
38 => 'Batch tapahtuma Admin',
39 => 'Tapahtuman Admin',
40 => 'Event List',
41 => 'This screen allows you to edit / create events. Edit the fields below and save.',
);
$LANG_CAL_AUTOTAG = array(
'desc_calendar' => 'Link: to a Calendar event on this site; link_text defaults to event title: [calendar:<i>event_id</i> {link_text}]',
);
$LANG_CAL_MESSAGE = array(
'save' => 'tapahtuma Tallennettu.',
'delete' => 'Tapahtuma Poistettu.',
'private' => 'Tapahtuma Tallennettu Kalenteriisi',
'login' => 'Kalenteriasi ei voi avata ennenkuin olet kirjautunut',
'removed' => 'tapahtuma poistettu kalenteristasi',
'noprivate' => 'Valitamme, mutta henkilökohtaiset kalenterit ei ole sallittu tällä hetkellä',
'unauth' => 'Sinulla ei ole oikeuksia tapahtuman ylläpito sivulle. Kaikki yritykset kirjataan',
'delete_confirm' => 'Oletko varma että haluat poistaa tämän tapahtuman?'
);
$PLG_calendar_MESSAGE4 = "Kiitos lähettämistä tapahtuman {$_CONF['site_name']}. On toimitettu henkilökuntamme hyväksyttäväksi. Jos hyväksytään, tapahtuma nähdään täällä, meidän <a href=\"{$_CONF['site_url']}/calendar/index.php\">kalenteri</a> jaksossa.";
$PLG_calendar_MESSAGE17 = 'Tapahtuma Tallennettu.';
$PLG_calendar_MESSAGE18 = 'Tapahtuma Poistettu.';
$PLG_calendar_MESSAGE24 = 'Tapahtuma Tallennettu Kalenteriisi.';
$PLG_calendar_MESSAGE26 = 'Tapahtuma Poistettu.';
// Messages for the plugin upgrade
$PLG_calendar_MESSAGE3001 = 'Plugin päivitys ei tueta.';
$PLG_calendar_MESSAGE3002 = $LANG32[9];
// Localization of the Admin Configuration UI
$LANG_configsections['calendar'] = array(
'label' => 'Kalenteri',
'title' => 'Kalenteri Asetukset'
);
$LANG_confignames['calendar'] = array(
'calendarloginrequired' => 'Kalenteri Kirjautuminen Vaaditaan',
'hidecalendarmenu' => 'Piiloita Kalenteri Valikossa',
'personalcalendars' => 'Salli Henkilökohtaiset Kalenterit',
'eventsubmission' => 'Ota Käyttöön Lähetys Jono',
'showupcomingevents' => 'Näytä Tulevat Tapahtumat',
'upcomingeventsrange' => 'Tulevien Tapahtumien Aikaväli',
'event_types' => 'Tapahtuma Tyypit',
'hour_mode' => 'Tunti Moodi',
'notification' => 'Sähköposti Ilmoitus',
'delete_event' => 'Poista Tapahtumalta Omistaja',
'aftersave' => 'Tapahtuman Tallennuksen Jälkeen',
'default_permissions' => 'Tapahtuman Oletus Oikeudet',
'only_admin_submit' => 'Salli Vain Admineitten Lähettää',
'displayblocks' => 'Näytä glFusion Lohkot',
);
$LANG_configsubgroups['calendar'] = array(
'sg_main' => 'Pää Asetukset'
);
$LANG_fs['calendar'] = array(
'fs_main' => 'Yleiset Kalenteri Asetukset',
'fs_permissions' => 'Oletus Oikeudet'
);
$LANG_configSelect['calendar'] = array(
0 => array(1=> 'True', 0 => 'False'),
1 => array(true => 'True', false => 'False'),
6 => array(12 => '12', 24 => '24'),
9 => array('item'=>'Forward to Event', 'list'=>'Display Admin List', 'plugin'=>'Display Calendar', 'home'=>'Display Home', 'admin'=>'Display Admin'),
12 => array(0=>'No access', 2=>'Vain luku', 3=>'Read-Write'),
13 => array(0=>'Left Blocks', 1=>'Right Blocks', 2=>'Left & Right Blocks', 3=>'Ei yhtään')
);
?>
| glFusion/glfusion | private/plugins/calendar/language/finnish_utf-8.php | PHP | gpl-2.0 | 9,331 |
/*****************************************************************************
* xa.c : xa file demux module for vlc
*****************************************************************************
* Copyright (C) 2005 Rémi Denis-Courmont
* $Id$
*
* Authors: Rémi Denis-Courmont <rem # videolan.org>
*
* This program 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 program 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 program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <assert.h>
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_demux.h>
/*****************************************************************************
* Module descriptor
*****************************************************************************/
static int Open ( vlc_object_t * );
static void Close( vlc_object_t * );
vlc_module_begin ()
set_description( N_("XA demuxer") )
set_category( CAT_INPUT )
set_subcategory( SUBCAT_INPUT_DEMUX )
set_capability( "demux", 10 )
set_callbacks( Open, Close )
vlc_module_end ()
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static int Demux ( demux_t * );
static int Control( demux_t *, int i_query, va_list args );
struct demux_sys_t
{
es_out_id_t *p_es;
int64_t i_data_offset;
unsigned int i_data_size;
unsigned int i_block_frames;
unsigned int i_frame_size;
unsigned int i_bitrate;
date_t pts;
};
typedef struct xa_header_t
{
char xa_id[4];
uint32_t iSize;
uint16_t wFormatTag;
uint16_t nChannels;
uint32_t nSamplesPerSec;
uint32_t nAvgBytesPerSec;
uint16_t nBlockAlign;
uint16_t wBitsPerSample;
} xa_header_t;
static_assert(offsetof(xa_header_t, wBitsPerSample) == 22, "Bad padding");
#define FRAME_LENGTH 28 /* samples per frame */
/*****************************************************************************
* Open: check file and initializes structures
*****************************************************************************/
static int Open( vlc_object_t * p_this )
{
demux_t *p_demux = (demux_t*)p_this;
const uint8_t *peek;
/* XA file heuristic */
if( vlc_stream_Peek( p_demux->s, &peek, 10 ) < 10 )
return VLC_EGENERIC;
if( memcmp( peek, "XAI", 4 ) && memcmp( peek, "XAJ", 4 ) )
return VLC_EGENERIC;
if( GetWLE( peek + 8 ) != 1 ) /* format tag */
return VLC_EGENERIC;
demux_sys_t *p_sys = malloc( sizeof( demux_sys_t ) );
if( unlikely( p_sys == NULL ) )
return VLC_ENOMEM;
/* read XA header*/
xa_header_t xa;
if( vlc_stream_Read( p_demux->s, &xa, 24 ) < 24 )
{
free( p_sys );
return VLC_EGENERIC;
}
es_format_t fmt;
es_format_Init( &fmt, AUDIO_ES, VLC_FOURCC('X','A','J',0) );
msg_Dbg( p_demux, "assuming EA ADPCM audio codec" );
fmt.audio.i_rate = GetDWLE( &xa.nSamplesPerSec );
fmt.audio.i_bytes_per_frame = 15 * GetWLE( &xa.nChannels );
fmt.audio.i_frame_length = FRAME_LENGTH;
fmt.audio.i_channels = GetWLE ( &xa.nChannels );
fmt.audio.i_blockalign = fmt.audio.i_bytes_per_frame;
fmt.audio.i_bitspersample = GetWLE( &xa.wBitsPerSample );
fmt.i_bitrate = (fmt.audio.i_rate * fmt.audio.i_bytes_per_frame * 8)
/ fmt.audio.i_frame_length;
p_sys->i_data_offset = vlc_stream_Tell( p_demux->s );
/* FIXME: better computation */
p_sys->i_data_size = xa.iSize * 15 / 56;
/* How many frames per block (1:1 is too CPU intensive) */
p_sys->i_block_frames = fmt.audio.i_rate / (FRAME_LENGTH * 20) + 1;
p_sys->i_frame_size = fmt.audio.i_bytes_per_frame;
p_sys->i_bitrate = fmt.i_bitrate;
msg_Dbg( p_demux, "fourcc: %4.4s, channels: %d, "
"freq: %d Hz, bitrate: %dKo/s, blockalign: %d",
(char *)&fmt.i_codec, fmt.audio.i_channels, fmt.audio.i_rate,
fmt.i_bitrate / 8192, fmt.audio.i_blockalign );
if( fmt.audio.i_rate == 0 || fmt.audio.i_channels == 0
|| fmt.audio.i_bitspersample != 16 )
{
free( p_sys );
return VLC_EGENERIC;
}
p_sys->p_es = es_out_Add( p_demux->out, &fmt );
date_Init( &p_sys->pts, fmt.audio.i_rate, 1 );
date_Set( &p_sys->pts, VLC_TS_0 );
p_demux->pf_demux = Demux;
p_demux->pf_control = Control;
p_demux->p_sys = p_sys;
return VLC_SUCCESS;
}
/*****************************************************************************
* Demux: read packet and send them to decoders
*****************************************************************************
* Returns -1 in case of error, 0 in case of EOF, 1 otherwise
*****************************************************************************/
static int Demux( demux_t *p_demux )
{
demux_sys_t *p_sys = p_demux->p_sys;
block_t *p_block;
int64_t i_offset;
unsigned i_frames = p_sys->i_block_frames;
i_offset = vlc_stream_Tell( p_demux->s );
if( p_sys->i_data_size > 0 &&
i_offset >= p_sys->i_data_offset + p_sys->i_data_size )
{
/* EOF */
return 0;
}
p_block = vlc_stream_Block( p_demux->s, p_sys->i_frame_size * i_frames );
if( p_block == NULL )
{
msg_Warn( p_demux, "cannot read data" );
return 0;
}
i_frames = p_block->i_buffer / p_sys->i_frame_size;
p_block->i_dts = p_block->i_pts = date_Get( &p_sys->pts );
es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_block->i_pts );
es_out_Send( p_demux->out, p_sys->p_es, p_block );
date_Increment( &p_sys->pts, i_frames * FRAME_LENGTH );
return 1;
}
/*****************************************************************************
* Close: frees unused data
*****************************************************************************/
static void Close ( vlc_object_t * p_this )
{
demux_sys_t *p_sys = ((demux_t *)p_this)->p_sys;
free( p_sys );
}
/*****************************************************************************
* Control:
*****************************************************************************/
static int Control( demux_t *p_demux, int i_query, va_list args )
{
demux_sys_t *p_sys = p_demux->p_sys;
return demux_vaControlHelper( p_demux->s, p_sys->i_data_offset,
p_sys->i_data_size ? p_sys->i_data_offset
+ p_sys->i_data_size : -1,
p_sys->i_bitrate, p_sys->i_frame_size,
i_query, args );
}
| r1k/vlc | modules/demux/xa.c | C | gpl-2.0 | 7,523 |
body{
font-size:12px;
font-family:tahoma;
color:#6d6d6d;
padding:0px;
margin:0px;
}
table,td,tr,th,input,select,div,span,textarea{
font-family:tahoma;
font-size:12px;
}
input{
text-align:center;
}
input[type=text],input[type=password]{
width:200px;
}
form{
padding:0px;
margin:0px;
}
a:link{
font-size:11px;
font-family:tahoma;
color:#744;
text-decoration:none;
}
a:visited{
font-size:11px;
font-family:tahoma;
color:#744;
text-decoration:none;
}
a:hover{
font-size:11px;
font-family:tahoma;
color:orange;
text-decoration:none;
}
.tx0{
font-family: tahoma;
font-size:10px;
}
.tx1{
font-family: tahoma;
font-size:11px;
}
.tx2{
font-family: tahoma;
font-size:12px;
}
.er0{
font-family: tahoma;
font-size:10px;
color:red;
}
.er1{
font-family: tahoma;
font-size:11px;
color:red;
}
.er2{
font-family: tahoma;
font-size:12px;
color:red;
}
.submit0{
background-image:url('../templates/Default/admin/bg1.jpg');
font-size:10px;
font-family:tahoma;
border-color:#cccccc;
border-width:1px;
background-color:white;
color:#555555;
}
.submit1{
background-image:url('../templates/Default/admin/bg1.jpg');
font-size:11px;
font-family:tahoma;
border-color:#cccccc;
border-width:1px;
background-color:white;
color:#555555;
}
.submit2{
background-image:url('../templates/Default/admin/bg1.jpg');
font-size:12px;
font-family:tahoma;
border-color:#cccccc;
border-width:1px;
background-color:white;
color:#555555;
}
.input0{
text-align:justify;
font-family: tahoma;
font-size:10px;
}
.input1{
text-align:;
font-family: tahoma;
font-size:11px;
}
.input2{
text-align:;
font-family: tahoma;
font-size:12px;
}
.select0{
text-align:justify;
font-family: tahoma;
font-size:10px;
}
.select1{
text-align:;
font-family: tahoma;
font-size:11px;
}
.select2{
text-align:;
font-family: tahoma;
font-size:12px;
}
#dhtmltooltip{
position: absolute;
left: -300px;
width: 150px;
border: 1px solid black;
padding: 2px;
background-color: lightyellow;
visibility: hidden;
z-index: 100;
/*Remove below line to remove shadow. Below line should always appear last within this CSS*/
filter: progid:DXImageTransform.Microsoft.Shadow(color=gray,direction=135);
}
#dhtmlpointer{
position:absolute;
left: -300px;
z-index: 101;
visibility: hidden;
}
| sbazzaza/tournama | src/web/root/styles/main.css | CSS | gpl-2.0 | 2,447 |
/*
* Copyright (C) 2008-2010 Surevine Limited.
*
* Although intended for deployment and use alongside Alfresco this module should
* be considered 'Not a Contribution' as defined in Alfresco'sstandard contribution agreement, see
* http://www.alfresco.org/resource/AlfrescoContributionAgreementv2.pdf
*
* This program 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
* of the License, or (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
// Get the change password url
model.changePasswordUrlNode = companyhome.childByNamePath('Data Dictionary/SV Theme/Configuration/Header/url_change_password.txt');
//Get the security label header
model.securityLabelHeaderNode = companyhome.childByNamePath('Data Dictionary/SV Theme/Configuration/Header/security_label.txt');
//Get the help url
model.helpLinkNode = companyhome.childByNamePath('Data Dictionary/SV Theme/Configuration/Header/url_help.txt');
model.launchChatUrlNode = companyhome.childByNamePath('Data Dictionary/SV Theme/Configuration/Chat Dashlet/url_launch_chat.txt');
//Get the logo node
model.appLogoNode = companyhome.childByNamePath('Data Dictionary/SV Theme/Configuration/Header/app_logo');
model.surevineLinkUrlNode = companyhome.childByNamePath('Data Dictionary/SV Theme/Configuration/Footer/url_surevine_link.txt');
cache.neverCache=false;
cache.isPublic=false;
cache.maxAge=36000; //10 hours
cache.mustRevalidate=false;
cache.ETag = 100;
| surevine/alfresco-repository-client-customisations | config/alfresco/webscripts/com/surevine/svTheme/configuration/configuration.get.js | JavaScript | gpl-2.0 | 2,004 |
/*
* Copyright 2001-2009 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.
*
* 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.
*
*/
// Sparse remembered set for a heap region (the "owning" region). Maps
// indices of other regions to short sequences of cards in the other region
// that might contain pointers into the owner region.
// These tables only expand while they are accessed in parallel --
// deletions may be done in single-threaded code. This allows us to allow
// unsynchronized reads/iterations, as long as expansions caused by
// insertions only enqueue old versions for deletions, but do not delete
// old versions synchronously.
class SparsePRTEntry: public CHeapObj {
public:
enum SomePublicConstants {
CardsPerEntry = 4,
NullEntry = -1
};
private:
RegionIdx_t _region_ind;
int _next_index;
CardIdx_t _cards[CardsPerEntry];
public:
// Set the region_ind to the given value, and delete all cards.
inline void init(RegionIdx_t region_ind);
RegionIdx_t r_ind() const { return _region_ind; }
bool valid_entry() const { return r_ind() >= 0; }
void set_r_ind(RegionIdx_t rind) { _region_ind = rind; }
int next_index() const { return _next_index; }
int* next_index_addr() { return &_next_index; }
void set_next_index(int ni) { _next_index = ni; }
// Returns "true" iff the entry contains the given card index.
inline bool contains_card(CardIdx_t card_index) const;
// Returns the number of non-NULL card entries.
inline int num_valid_cards() const;
// Requires that the entry not contain the given card index. If there is
// space available, add the given card index to the entry and return
// "true"; otherwise, return "false" to indicate that the entry is full.
enum AddCardResult {
overflow,
found,
added
};
inline AddCardResult add_card(CardIdx_t card_index);
// Copy the current entry's cards into "cards".
inline void copy_cards(CardIdx_t* cards) const;
// Copy the current entry's cards into the "_card" array of "e."
inline void copy_cards(SparsePRTEntry* e) const;
inline CardIdx_t card(int i) const { return _cards[i]; }
};
class RSHashTable : public CHeapObj {
friend class RSHashTableIter;
enum SomePrivateConstants {
NullEntry = -1
};
size_t _capacity;
size_t _capacity_mask;
size_t _occupied_entries;
size_t _occupied_cards;
SparsePRTEntry* _entries;
int* _buckets;
int _free_region;
int _free_list;
// Requires that the caller hold a lock preventing parallel modifying
// operations, and that the the table be less than completely full. If
// an entry for "region_ind" is already in the table, finds it and
// returns its address; otherwise returns "NULL."
SparsePRTEntry* entry_for_region_ind(RegionIdx_t region_ind) const;
// Requires that the caller hold a lock preventing parallel modifying
// operations, and that the the table be less than completely full. If
// an entry for "region_ind" is already in the table, finds it and
// returns its address; otherwise allocates, initializes, inserts and
// returns a new entry for "region_ind".
SparsePRTEntry* entry_for_region_ind_create(RegionIdx_t region_ind);
// Returns the index of the next free entry in "_entries".
int alloc_entry();
// Declares the entry "fi" to be free. (It must have already been
// deleted from any bucket lists.
void free_entry(int fi);
public:
RSHashTable(size_t capacity);
~RSHashTable();
// Attempts to ensure that the given card_index in the given region is in
// the sparse table. If successful (because the card was already
// present, or because it was successfullly added) returns "true".
// Otherwise, returns "false" to indicate that the addition would
// overflow the entry for the region. The caller must transfer these
// entries to a larger-capacity representation.
bool add_card(RegionIdx_t region_id, CardIdx_t card_index);
bool get_cards(RegionIdx_t region_id, CardIdx_t* cards);
bool delete_entry(RegionIdx_t region_id);
bool contains_card(RegionIdx_t region_id, CardIdx_t card_index) const;
void add_entry(SparsePRTEntry* e);
void clear();
size_t capacity() const { return _capacity; }
size_t capacity_mask() const { return _capacity_mask; }
size_t occupied_entries() const { return _occupied_entries; }
size_t occupied_cards() const { return _occupied_cards; }
size_t mem_size() const;
SparsePRTEntry* entry(int i) const { return &_entries[i]; }
void print();
};
// ValueObj because will be embedded in HRRS iterator.
class RSHashTableIter VALUE_OBJ_CLASS_SPEC {
int _tbl_ind; // [-1, 0.._rsht->_capacity)
int _bl_ind; // [-1, 0.._rsht->_capacity)
short _card_ind; // [0..CardsPerEntry)
RSHashTable* _rsht;
size_t _heap_bot_card_ind;
// If the bucket list pointed to by _bl_ind contains a card, sets
// _bl_ind to the index of that entry, and returns the card.
// Otherwise, returns SparseEntry::NullEntry.
CardIdx_t find_first_card_in_list();
// Computes the proper card index for the card whose offset in the
// current region (as indicated by _bl_ind) is "ci".
// This is subject to errors when there is iteration concurrent with
// modification, but these errors should be benign.
size_t compute_card_ind(CardIdx_t ci);
public:
RSHashTableIter(size_t heap_bot_card_ind) :
_tbl_ind(RSHashTable::NullEntry),
_bl_ind(RSHashTable::NullEntry),
_card_ind((SparsePRTEntry::CardsPerEntry-1)),
_rsht(NULL),
_heap_bot_card_ind(heap_bot_card_ind)
{}
void init(RSHashTable* rsht) {
_rsht = rsht;
_tbl_ind = -1; // So that first increment gets to 0.
_bl_ind = RSHashTable::NullEntry;
_card_ind = (SparsePRTEntry::CardsPerEntry-1);
}
bool has_next(size_t& card_index);
};
// Concurrent accesss to a SparsePRT must be serialized by some external
// mutex.
class SparsePRTIter;
class SparsePRT VALUE_OBJ_CLASS_SPEC {
// Iterations are done on the _cur hash table, since they only need to
// see entries visible at the start of a collection pause.
// All other operations are done using the _next hash table.
RSHashTable* _cur;
RSHashTable* _next;
HeapRegion* _hr;
enum SomeAdditionalPrivateConstants {
InitialCapacity = 16
};
void expand();
bool _expanded;
bool expanded() { return _expanded; }
void set_expanded(bool b) { _expanded = b; }
SparsePRT* _next_expanded;
SparsePRT* next_expanded() { return _next_expanded; }
void set_next_expanded(SparsePRT* nxt) { _next_expanded = nxt; }
static SparsePRT* _head_expanded_list;
public:
SparsePRT(HeapRegion* hr);
~SparsePRT();
size_t occupied() const { return _next->occupied_cards(); }
size_t mem_size() const;
// Attempts to ensure that the given card_index in the given region is in
// the sparse table. If successful (because the card was already
// present, or because it was successfullly added) returns "true".
// Otherwise, returns "false" to indicate that the addition would
// overflow the entry for the region. The caller must transfer these
// entries to a larger-capacity representation.
bool add_card(RegionIdx_t region_id, CardIdx_t card_index);
// If the table hold an entry for "region_ind", Copies its
// cards into "cards", which must be an array of length at least
// "CardsPerEntry", and returns "true"; otherwise, returns "false".
bool get_cards(RegionIdx_t region_ind, CardIdx_t* cards);
// If there is an entry for "region_ind", removes it and return "true";
// otherwise returns "false."
bool delete_entry(RegionIdx_t region_ind);
// Clear the table, and reinitialize to initial capacity.
void clear();
// Ensure that "_cur" and "_next" point to the same table.
void cleanup();
// Clean up all tables on the expanded list. Called single threaded.
static void cleanup_all();
RSHashTable* cur() const { return _cur; }
void init_iterator(SparsePRTIter* sprt_iter);
static void add_to_expanded_list(SparsePRT* sprt);
static SparsePRT* get_from_expanded_list();
bool contains_card(RegionIdx_t region_id, CardIdx_t card_index) const {
return _next->contains_card(region_id, card_index);
}
#if 0
void verify_is_cleared();
void print();
#endif
};
class SparsePRTIter: public /* RSHashTable:: */RSHashTableIter {
public:
SparsePRTIter(size_t heap_bot_card_ind) :
/* RSHashTable:: */RSHashTableIter(heap_bot_card_ind)
{}
void init(const SparsePRT* sprt) {
RSHashTableIter::init(sprt->cur());
}
bool has_next(size_t& card_index) {
return RSHashTableIter::has_next(card_index);
}
};
| TheTypoMaster/Scaper | openjdk/hotspot/src/share/vm/gc_implementation/g1/sparsePRT.hpp | C++ | gpl-2.0 | 9,597 |
<?php
$widget = $vars["entity"];
// get widget settings
$count = (int) $widget->wire_count;
$filter = $widget->filter;
if ($count < 1) {
$count = 8;
}
$options = array(
"type" => "object",
"subtype" => "thewire",
"limit" => $count,
"full_view" => false,
"pagination" => false,
"view_type_toggle" => false
);
if (!empty($filter)) {
$filters = string_to_tag_array($filter);
$filters = array_map("sanitise_string", $filters);
$options["joins"] = array("JOIN " . elgg_get_config("dbprefix") . "objects_entity oe ON oe.guid = e.guid");
$options["wheres"] = array("(oe.description LIKE '%" . implode("%' OR oe.description LIKE '%", $filters) . "%')");
}
$content = elgg_list_entities($options);
if (!empty($content)) {
echo $content;
echo "<span class='elgg-widget-more'>" . elgg_view("output/url", array("href" => "thewire/all","text" => elgg_echo("thewire:moreposts"))) . "</span>";
} else {
echo elgg_echo("thewire_tools:no_result");
}
| 3lywa/gcconnex | mod/thewire_tools/views/default/widgets/index_thewire/content.php | PHP | gpl-2.0 | 955 |
<?php
/*
* Template Name: Blog
*/
get_header(); ?>
<?php while ( have_posts() ) : the_post(); ?>
<div id="blog">
<?php get_template_part( 'content', 'introtext' ); ?>
<section class="features">
<div class="container" role="main">
<div class="row">
<div class="span9">
<?php get_template_part( 'content', get_post_format() ); ?>
</div>
<div class="span3 sidebar">
<div class="blognav">
<?php get_sidebar(); ?>
</div>
</div>
</div>
</div>
</section>
</div>
<?php endwhile; // end of the loop. ?>
<?php get_footer(); ?> | thinkluke/retailexpress | wp-content/themes/retailexpress/single.php | PHP | gpl-2.0 | 677 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (version 1.7.0_04) on Wed Jul 02 15:54:03 IDT 2014 -->
<title>com.codename1.payment Class Hierarchy (Codename One API)</title>
<meta name="date" content="2014-07-02">
<link rel="stylesheet" type="text/css" href="../../../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="com.codename1.payment Class Hierarchy (Codename One API)";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!-- -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li>Class</li>
<li class="navBarCell1Rev">Tree</li>
<li><a href="../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../index-all.html">Index</a></li>
<li><a href="../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../com/codename1/messaging/package-tree.html">Prev</a></li>
<li><a href="../../../com/codename1/processing/package-tree.html">Next</a></li>
</ul>
<ul class="navList">
<li><a href="../../../index.html?com/codename1/payment/package-tree.html" target="_top">Frames</a></li>
<li><a href="package-tree.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip-navbar_top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="header">
<h1 class="title">Hierarchy For Package com.codename1.payment</h1>
<span class="strong">Package Hierarchies:</span>
<ul class="horizontal">
<li><a href="../../../overview-tree.html">All Packages</a></li>
</ul>
</div>
<div class="contentContainer">
<h2 title="Class Hierarchy">Class Hierarchy</h2>
<ul>
<li type="circle">java.lang.<a href="../../../java/lang/Object.html" title="class in java.lang"><span class="strong">Object</span></a>
<ul>
<li type="circle">com.codename1.payment.<a href="../../../com/codename1/payment/Product.html" title="class in com.codename1.payment"><span class="strong">Product</span></a></li>
<li type="circle">com.codename1.payment.<a href="../../../com/codename1/payment/Purchase.html" title="class in com.codename1.payment"><span class="strong">Purchase</span></a></li>
</ul>
</li>
</ul>
<h2 title="Interface Hierarchy">Interface Hierarchy</h2>
<ul>
<li type="circle">com.codename1.payment.<a href="../../../com/codename1/payment/PurchaseCallback.html" title="interface in com.codename1.payment"><span class="strong">PurchaseCallback</span></a></li>
</ul>
</div>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!-- -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li>Class</li>
<li class="navBarCell1Rev">Tree</li>
<li><a href="../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../index-all.html">Index</a></li>
<li><a href="../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../com/codename1/messaging/package-tree.html">Prev</a></li>
<li><a href="../../../com/codename1/processing/package-tree.html">Next</a></li>
</ul>
<ul class="navList">
<li><a href="../../../index.html?com/codename1/payment/package-tree.html" target="_top">Frames</a></li>
<li><a href="package-tree.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip-navbar_bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>
| skyHALud/codenameone | CodenameOne/javadoc/com/codename1/payment/package-tree.html | HTML | gpl-2.0 | 4,831 |
<?php
function uwpf_delete_plugin() {
delete_option('uwpf_options');
}
function uwpf_init(){
register_setting( 'uwpf_plugin_options', 'uwpf_options', 'uwpf_validate' );
}
function requires_wordpress_version() {
global $wp_version;
$plugin = plugin_basename( __FILE__ );
$plugin_data = get_plugin_data( __FILE__, false );
if ( version_compare($wp_version, "2.9", "<" ) ) {
if( is_plugin_active($plugin) ) {
deactivate_plugins( $plugin );
wp_die( "'".$plugin_data['Name']."' requires WordPress 2.9 or higher, and has been deactivated! Please upgrade WordPress and try again.<br /><br />Back to <a href='".admin_url()."'>WordPress admin</a>." );
}
}
}
?> | maewna/food-sawasdee | wp-content/plugins/ultimate-wp-filter/uwpf_functions.php | PHP | gpl-2.0 | 714 |
<?php
if ( !class_exists( 'RWMB_Field ' ) )
{
class RWMB_Field
{
/**
* Add actions
*
* @return void
*/
static function add_actions() {}
/**
* Enqueue scripts and styles
*
* @return void
*/
static function admin_enqueue_scripts() {}
/**
* Show field HTML
*
* @param array $field
* @param bool $saved
*
* @return string
*/
static function show( $field, $saved )
{
global $post;
$field_class = RW_Meta_Box::get_class_name( $field );
$meta = call_user_func( array( $field_class, 'meta' ), $post->ID, $saved, $field );
$group = ''; // Empty the clone-group field
$type = $field['type'];
$id = $field['id'];
$begin = call_user_func( array( $field_class, 'begin_html' ), $meta, $field );
// Apply filter to field begin HTML
// 1st filter applies to all fields
// 2nd filter applies to all fields with the same type
// 3rd filter applies to current field only
$begin = apply_filters( 'rwmb_begin_html', $begin, $field, $meta );
$begin = apply_filters( "rwmb_{$type}_begin_html", $begin, $field, $meta );
$begin = apply_filters( "rwmb_{$id}_begin_html", $begin, $field, $meta );
// Separate code for cloneable and non-cloneable fields to make easy to maintain
// Cloneable fields
if ( $field['clone'] )
{
if ( isset( $field['clone-group'] ) )
$group = " clone-group='{$field['clone-group']}'";
$meta = (array) $meta;
$field_html = '';
foreach ( $meta as $index => $sub_meta )
{
$sub_field = $field;
$sub_field['field_name'] = $field['field_name'] . "[{$index}]";
if ($index>0) {
if (isset( $sub_field['address_field'] ))
$sub_field['address_field'] = $field['address_field'] . "_{$index}";
$sub_field['id'] = $field['id'] . "_{$index}";
}
if ( $field['multiple'] )
$sub_field['field_name'] .= '[]';
// Wrap field HTML in a div with class="rwmb-clone" if needed
$input_html = '<div class="rwmb-clone">';
// Call separated methods for displaying each type of field
//$input_html .= call_user_func( array( $field_class, 'html' ), $sub_meta, $sub_field );
// Apply filter to field HTML
// 1st filter applies to all fields with the same type
// 2nd filter applies to current field only
$input_html = apply_filters( "rwmb_{$type}_html", $input_html, $field, $sub_meta );
$input_html = apply_filters( "rwmb_{$id}_html", $input_html, $field, $sub_meta );
// Add clone button
$input_html .= self::clone_button();
$input_html .= '</div>';
$field_html .= $input_html;
}
}
// Non-cloneable fields
else
{
// Call separated methods for displaying each type of field
$field_html = call_user_func( array( $field_class, 'html' ), $meta, $field );
// Apply filter to field HTML
// 1st filter applies to all fields with the same type
// 2nd filter applies to current field only
$field_html = apply_filters( "rwmb_{$type}_html", $field_html, $field, $meta );
$field_html = apply_filters( "rwmb_{$id}_html", $field_html, $field, $meta );
}
$end = call_user_func( array( $field_class, 'end_html' ), $meta, $field );
// Apply filter to field end HTML
// 1st filter applies to all fields
// 2nd filter applies to all fields with the same type
// 3rd filter applies to current field only
$end = apply_filters( 'rwmb_end_html', $end, $field, $meta );
$end = apply_filters( "rwmb_{$type}_end_html", $end, $field, $meta );
$end = apply_filters( "rwmb_{$id}_end_html", $end, $field, $meta );
// Apply filter to field wrapper
// This allow users to change whole HTML markup of the field wrapper (i.e. table row)
// 1st filter applies to all fields with the same type
// 2nd filter applies to current field only
//$html = apply_filters( "rwmb_{$type}_wrapper_html", "{$begin}{$field_html}{$end}", $field, $meta );
$html = apply_filters( "rwmb_{$type}_wrapper_html", "{$field_html}", $field, $meta );
$html = apply_filters( "rwmb_{$id}_wrapper_html", $html, $field, $meta );
// Display label and input in DIV and allow user-defined classes to be appended
$classes = array( 'rwmb-field', "rwmb-{$type}-wrapper" );
if ( 'hidden' === $field['type'] )
$classes[] = 'hidden';
if ( !empty( $field['required'] ) )
$classes[] = 'required';
if ( !empty( $field['class'] ) )
$classes[] = $field['class'];
printf(
$field['before'] . '<div class="%s"%s>%s</div>' . $field['after'],
implode( ' ', $classes ),
$group,
$html
);
}
/**
* Get field HTML
*
* @param mixed $meta
* @param array $field
*
* @return string
*/
static function html( $meta, $field )
{
return '';
}
/**
* Show begin HTML markup for fields
*
* @param mixed $meta
* @param array $field
*
* @return string
*/
static function begin_html( $meta, $field )
{
if ( empty( $field['name'] ) )
return '<div class="rwmb-input">';
return sprintf(
'<div class="rwmb-label">
<label for="%s">%s</label>
</div>
<div class="rwmb-input">',
$field['id'],
$field['name']
);
}
/**
* Show end HTML markup for fields
*
* @param mixed $meta
* @param array $field
*
* @return string
*/
static function end_html( $meta, $field )
{
$id = $field['id'];
$button = '';
if ( $field['clone'] )
$button = '<a href="#" class="rwmb-button button-primary add-clone">' . __( '+', 'rwmb' ) . '</a>';
$desc = !empty( $field['desc'] ) ? "<p id='{$id}_description' class='description'>{$field['desc']}</p>" : '';
// Closes the container
$html = "{$button}{$desc}</div>";
return $html;
}
/**
* Add clone button
*
* @return string $html
*/
static function clone_button()
{
return '<a href="#" class="rwmb-button button remove-clone">' . __( '–', 'rwmb' ) . '</a>';
}
/**
* Get meta value
*
* @param int $post_id
* @param bool $saved
* @param array $field
*
* @return mixed
*/
static function meta( $post_id, $saved, $field )
{
$meta = get_post_meta( $post_id, $field['id'], !$field['multiple'] );
// Use $field['std'] only when the meta box hasn't been saved (i.e. the first time we run)
$meta = ( !$saved && '' === $meta || array() === $meta ) ? $field['std'] : $meta;
// Escape attributes for non-wysiwyg fields
if ( 'wysiwyg' !== $field['type'] )
$meta = is_array( $meta ) ? array_map( 'esc_attr', $meta ) : esc_attr( $meta );
$meta = apply_filters( "rwmb_{$field['type']}_meta", $meta );
$meta = apply_filters( "rwmb_{$field['id']}_meta", $meta );
return $meta;
}
/**
* Set value of meta before saving into database
*
* @param mixed $new
* @param mixed $old
* @param int $post_id
* @param array $field
*
* @return int
*/
static function value( $new, $old, $post_id, $field )
{
return $new;
}
/**
* Save meta value
*
* @param $new
* @param $old
* @param $post_id
* @param $field
*/
static function save( $new, $old, $post_id, $field )
{
$name = $field['id'];
if ( '' === $new || array() === $new )
{
delete_post_meta( $post_id, $name );
return;
}
if ( $field['multiple'] )
{
foreach ( $new as $new_value )
{
if ( !in_array( $new_value, $old ) )
add_post_meta( $post_id, $name, $new_value, false );
}
foreach ( $old as $old_value )
{
if ( !in_array( $old_value, $new ) )
delete_post_meta( $post_id, $name, $old_value );
}
}
else
{
if ( $field['clone'] )
{
$new = (array) $new;
foreach ( $new as $k => $v )
{
if ( '' === $v )
unset( $new[$k] );
}
}
update_post_meta( $post_id, $name, $new );
}
}
/**
* Normalize parameters for field
*
* @param array $field
*
* @return array
*/
static function normalize_field( $field )
{
return $field;
}
}
} | marcosalm/digiwall | public/wp-content/plugins/meta-box-master/inc/field.php | PHP | gpl-2.0 | 8,037 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (version 1.7.0_45) on Wed Jan 07 20:17:28 CST 2015 -->
<title>Uses of Class gnu.getopt.Getopt</title>
<meta name="date" content="2015-01-07">
<link rel="stylesheet" type="text/css" href="../../../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Uses of Class gnu.getopt.Getopt";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!-- -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../overview-summary.html">Overview</a></li>
<li><a href="../package-summary.html">Package</a></li>
<li><a href="../../../gnu/getopt/Getopt.html" title="class in gnu.getopt">Class</a></li>
<li class="navBarCell1Rev">Use</li>
<li><a href="../package-tree.html">Tree</a></li>
<li><a href="../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../index-files/index-1.html">Index</a></li>
<li><a href="../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="../../../index.html?gnu/getopt/class-use/Getopt.html" target="_top">Frames</a></li>
<li><a href="Getopt.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip-navbar_top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="header">
<h2 title="Uses of Class gnu.getopt.Getopt" class="title">Uses of Class<br>gnu.getopt.Getopt</h2>
</div>
<div class="classUseContainer">No usage of gnu.getopt.Getopt</div>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!-- -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../overview-summary.html">Overview</a></li>
<li><a href="../package-summary.html">Package</a></li>
<li><a href="../../../gnu/getopt/Getopt.html" title="class in gnu.getopt">Class</a></li>
<li class="navBarCell1Rev">Use</li>
<li><a href="../package-tree.html">Tree</a></li>
<li><a href="../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../index-files/index-1.html">Index</a></li>
<li><a href="../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="../../../index.html?gnu/getopt/class-use/Getopt.html" target="_top">Frames</a></li>
<li><a href="Getopt.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip-navbar_bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>
| hrsky/PIOT | src/Hermit/doc/gnu/getopt/class-use/Getopt.html | HTML | gpl-2.0 | 3,842 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.3.1"/>
<title>Taobao Cpp/Qt SDK: InventoryQueryResponse Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
$(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">Taobao Cpp/Qt SDK
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.3.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="pages.html"><span>Related Pages</span></a></li>
<li class="current"><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li>
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="annotated.html"><span>Class List</span></a></li>
<li><a href="classes.html"><span>Class Index</span></a></li>
<li><a href="inherits.html"><span>Class Hierarchy</span></a></li>
<li><a href="functions.html"><span>Class Members</span></a></li>
</ul>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Pages</a></div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#pub-methods">Public Member Functions</a> |
<a href="#pri-attribs">Private Attributes</a> |
<a href="classInventoryQueryResponse-members.html">List of all members</a> </div>
<div class="headertitle">
<div class="title">InventoryQueryResponse Class Reference</div> </div>
</div><!--header-->
<div class="contents">
<p>TOP RESPONSE API: 商家查询商品总体库存信息
<a href="classInventoryQueryResponse.html#details">More...</a></p>
<p><code>#include <<a class="el" href="InventoryQueryResponse_8h_source.html">InventoryQueryResponse.h</a>></code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a48bce1584e6a9faf79f459247ea947d1"><td class="memItemLeft" align="right" valign="top">virtual </td><td class="memItemRight" valign="bottom"><a class="el" href="classInventoryQueryResponse.html#a48bce1584e6a9faf79f459247ea947d1">~InventoryQueryResponse</a> ()</td></tr>
<tr class="separator:a48bce1584e6a9faf79f459247ea947d1"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:aace94d1c58f6b1047ce81e4dd3dac523"><td class="memItemLeft" align="right" valign="top">QList< <a class="el" href="classInventorySum.html">InventorySum</a> > </td><td class="memItemRight" valign="bottom"><a class="el" href="classInventoryQueryResponse.html#aace94d1c58f6b1047ce81e4dd3dac523">getItemInventorys</a> () const </td></tr>
<tr class="separator:aace94d1c58f6b1047ce81e4dd3dac523"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a206abc6dfdd8d92dbe29a49f56cb9c6b"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classInventoryQueryResponse.html#a206abc6dfdd8d92dbe29a49f56cb9c6b">setItemInventorys</a> (QList< <a class="el" href="classInventorySum.html">InventorySum</a> > <a class="el" href="classInventoryQueryResponse.html#ac0b78a3b2865cdc867d838fc5e334743">itemInventorys</a>)</td></tr>
<tr class="separator:a206abc6dfdd8d92dbe29a49f56cb9c6b"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a518f3cb5830e479c2d3e900ab81b930e"><td class="memItemLeft" align="right" valign="top">QList< <a class="el" href="classTipInfo.html">TipInfo</a> > </td><td class="memItemRight" valign="bottom"><a class="el" href="classInventoryQueryResponse.html#a518f3cb5830e479c2d3e900ab81b930e">getTipInfos</a> () const </td></tr>
<tr class="separator:a518f3cb5830e479c2d3e900ab81b930e"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a20f666a61155f6c7fbfcf0099302d954"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classInventoryQueryResponse.html#a20f666a61155f6c7fbfcf0099302d954">setTipInfos</a> (QList< <a class="el" href="classTipInfo.html">TipInfo</a> > <a class="el" href="classInventoryQueryResponse.html#ad148f3a3b176267ccf705e8440390c38">tipInfos</a>)</td></tr>
<tr class="separator:a20f666a61155f6c7fbfcf0099302d954"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a617055db438ee63849d2ede92b906f32"><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><a class="el" href="classInventoryQueryResponse.html#a617055db438ee63849d2ede92b906f32">parseNormalResponse</a> ()</td></tr>
<tr class="separator:a617055db438ee63849d2ede92b906f32"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="inherit_header pub_methods_classTaoResponse"><td colspan="2" onclick="javascript:toggleInherit('pub_methods_classTaoResponse')"><img src="closed.png" alt="-"/> Public Member Functions inherited from <a class="el" href="classTaoResponse.html">TaoResponse</a></td></tr>
<tr class="memitem:a2e4420f5671664de8a1360866977d28b inherit pub_methods_classTaoResponse"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classTaoResponse.html#a2e4420f5671664de8a1360866977d28b">TaoResponse</a> ()</td></tr>
<tr class="separator:a2e4420f5671664de8a1360866977d28b inherit pub_methods_classTaoResponse"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a32ef9c53545a593316521cb1daab3e1a inherit pub_methods_classTaoResponse"><td class="memItemLeft" align="right" valign="top">virtual </td><td class="memItemRight" valign="bottom"><a class="el" href="classTaoResponse.html#a32ef9c53545a593316521cb1daab3e1a">~TaoResponse</a> ()</td></tr>
<tr class="separator:a32ef9c53545a593316521cb1daab3e1a inherit pub_methods_classTaoResponse"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:af5a077aab153edf6247200587ee855ee inherit pub_methods_classTaoResponse"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classTaoResponse.html#af5a077aab153edf6247200587ee855ee">parseResponse</a> ()</td></tr>
<tr class="separator:af5a077aab153edf6247200587ee855ee inherit pub_methods_classTaoResponse"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a174dc083a44795514cfe7a9f14a3731a inherit pub_methods_classTaoResponse"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classTaoResponse.html#a174dc083a44795514cfe7a9f14a3731a">setParser</a> (<a class="el" href="classParser.html">Parser</a> *parser)</td></tr>
<tr class="separator:a174dc083a44795514cfe7a9f14a3731a inherit pub_methods_classTaoResponse"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a854c6fdaef0abbeab21b5a43f65233ea inherit pub_methods_classTaoResponse"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classTaoResponse.html#a854c6fdaef0abbeab21b5a43f65233ea">parseError</a> ()</td></tr>
<tr class="separator:a854c6fdaef0abbeab21b5a43f65233ea inherit pub_methods_classTaoResponse"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ae8f183ea55d76bf813f038aae7022db4 inherit pub_methods_classTaoResponse"><td class="memItemLeft" align="right" valign="top">QString </td><td class="memItemRight" valign="bottom"><a class="el" href="classTaoResponse.html#ae8f183ea55d76bf813f038aae7022db4">getErrorCode</a> () const </td></tr>
<tr class="separator:ae8f183ea55d76bf813f038aae7022db4 inherit pub_methods_classTaoResponse"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a2468d6e3ad0939ba2f4b12efd1b00413 inherit pub_methods_classTaoResponse"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classTaoResponse.html#a2468d6e3ad0939ba2f4b12efd1b00413">setErrorCode</a> (const QString &<a class="el" href="classTaoResponse.html#ac54f11b3b22a4f93c8587c1f4c3899d7">errorCode</a>)</td></tr>
<tr class="separator:a2468d6e3ad0939ba2f4b12efd1b00413 inherit pub_methods_classTaoResponse"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:adf75dc6bcbb550c8edb64d33939345ed inherit pub_methods_classTaoResponse"><td class="memItemLeft" align="right" valign="top">QString </td><td class="memItemRight" valign="bottom"><a class="el" href="classTaoResponse.html#adf75dc6bcbb550c8edb64d33939345ed">getMsg</a> () const </td></tr>
<tr class="separator:adf75dc6bcbb550c8edb64d33939345ed inherit pub_methods_classTaoResponse"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a76b9304897ecfc563d8f706d32c01b59 inherit pub_methods_classTaoResponse"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classTaoResponse.html#a76b9304897ecfc563d8f706d32c01b59">setMsg</a> (const QString &<a class="el" href="classTaoResponse.html#adc5e9252ac61126ac2936ab2f6b9a0c6">msg</a>)</td></tr>
<tr class="separator:a76b9304897ecfc563d8f706d32c01b59 inherit pub_methods_classTaoResponse"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a35fd73600c578a0d5fe9cbe1e1750689 inherit pub_methods_classTaoResponse"><td class="memItemLeft" align="right" valign="top">QString </td><td class="memItemRight" valign="bottom"><a class="el" href="classTaoResponse.html#a35fd73600c578a0d5fe9cbe1e1750689">getSubCode</a> () const </td></tr>
<tr class="separator:a35fd73600c578a0d5fe9cbe1e1750689 inherit pub_methods_classTaoResponse"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a3c6346680f5209b3b9cd7fa0277222e6 inherit pub_methods_classTaoResponse"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classTaoResponse.html#a3c6346680f5209b3b9cd7fa0277222e6">setSubCode</a> (const QString &<a class="el" href="classTaoResponse.html#a5c6f8d740932e6453e7e3a2590fd3e6f">subCode</a>)</td></tr>
<tr class="separator:a3c6346680f5209b3b9cd7fa0277222e6 inherit pub_methods_classTaoResponse"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a7a0c8be833060f35437f741af784dd69 inherit pub_methods_classTaoResponse"><td class="memItemLeft" align="right" valign="top">QString </td><td class="memItemRight" valign="bottom"><a class="el" href="classTaoResponse.html#a7a0c8be833060f35437f741af784dd69">getSubMsg</a> () const </td></tr>
<tr class="separator:a7a0c8be833060f35437f741af784dd69 inherit pub_methods_classTaoResponse"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a4eac44413ea5445d5cee1e8aac077194 inherit pub_methods_classTaoResponse"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classTaoResponse.html#a4eac44413ea5445d5cee1e8aac077194">setSubMsg</a> (const QString &<a class="el" href="classTaoResponse.html#a13f08fbbfd176df1e06c9dbf579d06f4">subMsg</a>)</td></tr>
<tr class="separator:a4eac44413ea5445d5cee1e8aac077194 inherit pub_methods_classTaoResponse"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:aff41254c8d0cf4454d663876569379d2 inherit pub_methods_classTaoResponse"><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classTaoResponse.html#aff41254c8d0cf4454d663876569379d2">isSuccess</a> ()</td></tr>
<tr class="separator:aff41254c8d0cf4454d663876569379d2 inherit pub_methods_classTaoResponse"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a92f81ae42b484c9b2258b508e4023068 inherit pub_methods_classTaoResponse"><td class="memItemLeft" align="right" valign="top">QString </td><td class="memItemRight" valign="bottom"><a class="el" href="classTaoResponse.html#a92f81ae42b484c9b2258b508e4023068">getTopForbiddenFields</a> () const </td></tr>
<tr class="separator:a92f81ae42b484c9b2258b508e4023068 inherit pub_methods_classTaoResponse"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a475fb70a1c5657f8a947c3d1e3f5262d inherit pub_methods_classTaoResponse"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classTaoResponse.html#a475fb70a1c5657f8a947c3d1e3f5262d">setTopForbiddenFields</a> (const QString &<a class="el" href="classTaoResponse.html#a4ff01826fe5b531e2427c7df23d4cc18">topForbiddenFields</a>)</td></tr>
<tr class="separator:a475fb70a1c5657f8a947c3d1e3f5262d inherit pub_methods_classTaoResponse"><td class="memSeparator" colspan="2"> </td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pri-attribs"></a>
Private Attributes</h2></td></tr>
<tr class="memitem:ac0b78a3b2865cdc867d838fc5e334743"><td class="memItemLeft" align="right" valign="top">QList< <a class="el" href="classInventorySum.html">InventorySum</a> > </td><td class="memItemRight" valign="bottom"><a class="el" href="classInventoryQueryResponse.html#ac0b78a3b2865cdc867d838fc5e334743">itemInventorys</a></td></tr>
<tr class="memdesc:ac0b78a3b2865cdc867d838fc5e334743"><td class="mdescLeft"> </td><td class="mdescRight">商品总体库存信息 <a href="#ac0b78a3b2865cdc867d838fc5e334743">More...</a><br/></td></tr>
<tr class="separator:ac0b78a3b2865cdc867d838fc5e334743"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ad148f3a3b176267ccf705e8440390c38"><td class="memItemLeft" align="right" valign="top">QList< <a class="el" href="classTipInfo.html">TipInfo</a> > </td><td class="memItemRight" valign="bottom"><a class="el" href="classInventoryQueryResponse.html#ad148f3a3b176267ccf705e8440390c38">tipInfos</a></td></tr>
<tr class="memdesc:ad148f3a3b176267ccf705e8440390c38"><td class="mdescLeft"> </td><td class="mdescRight">提示信息,提示不存在的后端商品 <a href="#ad148f3a3b176267ccf705e8440390c38">More...</a><br/></td></tr>
<tr class="separator:ad148f3a3b176267ccf705e8440390c38"><td class="memSeparator" colspan="2"> </td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="inherited"></a>
Additional Inherited Members</h2></td></tr>
<tr class="inherit_header pub_attribs_classTaoResponse"><td colspan="2" onclick="javascript:toggleInherit('pub_attribs_classTaoResponse')"><img src="closed.png" alt="-"/> Public Attributes inherited from <a class="el" href="classTaoResponse.html">TaoResponse</a></td></tr>
<tr class="memitem:a49272f40b67d4bbb9c63f3f7b1ae7386 inherit pub_attribs_classTaoResponse"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classParser.html">Parser</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="classTaoResponse.html#a49272f40b67d4bbb9c63f3f7b1ae7386">responseParser</a></td></tr>
<tr class="separator:a49272f40b67d4bbb9c63f3f7b1ae7386 inherit pub_attribs_classTaoResponse"><td class="memSeparator" colspan="2"> </td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>TOP RESPONSE API: 商家查询商品总体库存信息 </p>
<dl class="section author"><dt>Author</dt><dd>sd44 <a href="#" onclick="location.href='mai'+'lto:'+'sd4'+'4s'+'dd4'+'4@'+'yea'+'h.'+'net'; return false;">sd44s<span style="display: none;">.nosp@m.</span>dd44<span style="display: none;">.nosp@m.</span>@yeah<span style="display: none;">.nosp@m.</span>.net</a> </dd></dl>
</div><h2 class="groupheader">Constructor & Destructor Documentation</h2>
<a class="anchor" id="a48bce1584e6a9faf79f459247ea947d1"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">virtual InventoryQueryResponse::~InventoryQueryResponse </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">virtual</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="aace94d1c58f6b1047ce81e4dd3dac523"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">QList< <a class="el" href="classInventorySum.html">InventorySum</a> > InventoryQueryResponse::getItemInventorys </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const</td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<a class="anchor" id="a518f3cb5830e479c2d3e900ab81b930e"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">QList< <a class="el" href="classTipInfo.html">TipInfo</a> > InventoryQueryResponse::getTipInfos </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const</td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<a class="anchor" id="a617055db438ee63849d2ede92b906f32"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">void InventoryQueryResponse::parseNormalResponse </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Implements <a class="el" href="classTaoResponse.html#a726f09ea73fc5f7e1560c097d03b9838">TaoResponse</a>.</p>
</div>
</div>
<a class="anchor" id="a206abc6dfdd8d92dbe29a49f56cb9c6b"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void InventoryQueryResponse::setItemInventorys </td>
<td>(</td>
<td class="paramtype">QList< <a class="el" href="classInventorySum.html">InventorySum</a> > </td>
<td class="paramname"><em>itemInventorys</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<a class="anchor" id="a20f666a61155f6c7fbfcf0099302d954"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void InventoryQueryResponse::setTipInfos </td>
<td>(</td>
<td class="paramtype">QList< <a class="el" href="classTipInfo.html">TipInfo</a> > </td>
<td class="paramname"><em>tipInfos</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<h2 class="groupheader">Member Data Documentation</h2>
<a class="anchor" id="ac0b78a3b2865cdc867d838fc5e334743"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">QList<<a class="el" href="classInventorySum.html">InventorySum</a>> InventoryQueryResponse::itemInventorys</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">private</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>商品总体库存信息 </p>
</div>
</div>
<a class="anchor" id="ad148f3a3b176267ccf705e8440390c38"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">QList<<a class="el" href="classTipInfo.html">TipInfo</a>> InventoryQueryResponse::tipInfos</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">private</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>提示信息,提示不存在的后端商品 </p>
</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>TaoApiCpp/response/<a class="el" href="InventoryQueryResponse_8h_source.html">InventoryQueryResponse.h</a></li>
<li>TaoApiCpp/response/<a class="el" href="InventoryQueryResponse_8cpp.html">InventoryQueryResponse.cpp</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Sun Apr 14 2013 16:25:39 for Taobao Cpp/Qt SDK by  <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.3.1
</small></address>
</body>
</html>
| sd44/TaobaoCppQtSDK | doc/classInventoryQueryResponse.html | HTML | gpl-2.0 | 24,265 |
/***************************************************************************
ofxdump.cpp
-------------------
copyright : (C) 2002 by Benoit Grégoire
email : [email protected]
***************************************************************************/
/**@file
* \brief Code for ofxdump utility. C++ example code
*
* ofxdump prints to stdout, in human readable form, everything the library
understands about a particular ofx response file, and sends errors to
stderr. To know exactly what the library understands about of a particular
ofx response file, just call ofxdump on that file.
*
* ofxdump is meant as both a C++ code example and a developper/debuging
tool. It uses every function and every structure of the LibOFX API. By
default, WARNING, INFO, ERROR and STATUS messages are enabled. You can
change these defaults at the top of ofxdump.cpp
*
* usage: ofxdump path_to_ofx_file/ofx_filename
*/
/***************************************************************************
* *
* This program 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 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <iostream>
#include <iomanip>
#include <string>
#include "libofx.h"
#include <stdio.h> /* for printf() */
#include <config.h> /* Include config constants, e.g., VERSION TF */
#include <errno.h>
#include "cmdline.h" /* Gengetopt generated parser */
using namespace std;
int ofx_proc_security_cb(struct OfxSecurityData data, void * security_data)
{
char dest_string[255];
cout<<"ofx_proc_security():\n";
if(data.unique_id_valid==true){
cout<<" Unique ID of the security being traded: "<<data.unique_id<<"\n";
}
if(data.unique_id_type_valid==true){
cout<<" Format of the Unique ID: "<<data.unique_id_type<<"\n";
}
if(data.secname_valid==true){
cout<<" Name of the security: "<<data.secname<<"\n";
}
if(data.ticker_valid==true){
cout<<" Ticker symbol: "<<data.ticker<<"\n";
}
if(data.unitprice_valid==true){
cout<<" Price of each unit of the security: "<<data.unitprice<<"\n";
}
if(data.date_unitprice_valid==true){
strftime(dest_string,sizeof(dest_string),"%c %Z",localtime(&(data.date_unitprice)));
cout<<" Date as of which the unitprice is valid: "<<dest_string<<"\n";
}
if(data.currency_valid==true){
cout<<" Currency of the unitprice: "<<data.currency<<"\n";
}
if(data.memo_valid==true){
cout<<" Extra transaction information (memo): "<<data.memo<<"\n";
}
cout<<"\n";
return 0;
}
int ofx_proc_transaction_cb(struct OfxTransactionData data, void * transaction_data)
{
char dest_string[255];
cout<<"ofx_proc_transaction():\n";
if(data.account_id_valid==true){
cout<<" Account ID : "<<data.account_id<<"\n";
}
if(data.transactiontype_valid==true)
{
if(data.transactiontype==OFX_CREDIT)
strncpy(dest_string, "CREDIT: Generic credit", sizeof(dest_string));
else if (data.transactiontype==OFX_DEBIT)
strncpy(dest_string, "DEBIT: Generic debit", sizeof(dest_string));
else if (data.transactiontype==OFX_INT)
strncpy(dest_string, "INT: Interest earned or paid (Note: Depends on signage of amount)", sizeof(dest_string));
else if (data.transactiontype==OFX_DIV)
strncpy(dest_string, "DIV: Dividend", sizeof(dest_string));
else if (data.transactiontype==OFX_FEE)
strncpy(dest_string, "FEE: FI fee", sizeof(dest_string));
else if (data.transactiontype==OFX_SRVCHG)
strncpy(dest_string, "SRVCHG: Service charge", sizeof(dest_string));
else if (data.transactiontype==OFX_DEP)
strncpy(dest_string, "DEP: Deposit", sizeof(dest_string));
else if (data.transactiontype==OFX_ATM)
strncpy(dest_string, "ATM: ATM debit or credit (Note: Depends on signage of amount)", sizeof(dest_string));
else if (data.transactiontype==OFX_POS)
strncpy(dest_string, "POS: Point of sale debit or credit (Note: Depends on signage of amount)", sizeof(dest_string));
else if (data.transactiontype==OFX_XFER)
strncpy(dest_string, "XFER: Transfer", sizeof(dest_string));
else if (data.transactiontype==OFX_CHECK)
strncpy(dest_string, "CHECK: Check", sizeof(dest_string));
else if (data.transactiontype==OFX_PAYMENT)
strncpy(dest_string, "PAYMENT: Electronic payment", sizeof(dest_string));
else if (data.transactiontype==OFX_CASH)
strncpy(dest_string, "CASH: Cash withdrawal", sizeof(dest_string));
else if (data.transactiontype==OFX_DIRECTDEP)
strncpy(dest_string, "DIRECTDEP: Direct deposit", sizeof(dest_string));
else if (data.transactiontype==OFX_DIRECTDEBIT)
strncpy(dest_string, "DIRECTDEBIT: Merchant initiated debit", sizeof(dest_string));
else if (data.transactiontype==OFX_REPEATPMT)
strncpy(dest_string, "REPEATPMT: Repeating payment/standing order", sizeof(dest_string));
else if (data.transactiontype==OFX_OTHER)
strncpy(dest_string, "OTHER: Other", sizeof(dest_string));
else
strncpy(dest_string, "Unknown transaction type", sizeof(dest_string));
cout<<" Transaction type: "<<dest_string<<"\n";
}
if(data.date_initiated_valid==true){
strftime(dest_string,sizeof(dest_string),"%c %Z",localtime(&(data.date_initiated)));
cout<<" Date initiated: "<<dest_string<<"\n";
}
if(data.date_posted_valid==true){
strftime(dest_string,sizeof(dest_string),"%c %Z",localtime(&(data.date_posted)));
cout<<" Date posted: "<<dest_string<<"\n";
}
if(data.date_funds_available_valid==true){
strftime(dest_string,sizeof(dest_string),"%c %Z",localtime(&(data.date_funds_available)));
cout<<" Date funds are available: "<<dest_string<<"\n";
}
if(data.amount_valid==true){
cout<<" Total money amount: "<<setiosflags(ios::fixed)<<setiosflags(ios::showpoint)<<setprecision(2)<<data.amount<<"\n";
}
if(data.units_valid==true){
cout<<" # of units: "<<setiosflags(ios::fixed)<<setiosflags(ios::showpoint)<<setprecision(2)<<data.units<<"\n";
}
if(data.oldunits_valid==true){
cout<<" # of units before split: "<<setiosflags(ios::fixed)<<setiosflags(ios::showpoint)<<setprecision(2)<<data.oldunits<<"\n";
}
if(data.newunits_valid==true){
cout<<" # of units after split: "<<setiosflags(ios::fixed)<<setiosflags(ios::showpoint)<<setprecision(2)<<data.newunits<<"\n";
}
if(data.unitprice_valid==true){
cout<<" Unit price: "<<setiosflags(ios::fixed)<<setiosflags(ios::showpoint)<<setprecision(2)<<data.unitprice<<"\n";
}
if(data.fees_valid==true){
cout<<" Fees: "<<setiosflags(ios::fixed)<<setiosflags(ios::showpoint)<<setprecision(2)<<data.fees<<"\n";
}
if(data.commission_valid==true){
cout<<" Commission: "<<setiosflags(ios::fixed)<<setiosflags(ios::showpoint)<<setprecision(2)<<data.commission<<"\n";
}
if(data.fi_id_valid==true){
cout<<" Financial institution's ID for this transaction: "<<data.fi_id<<"\n";
}
if(data.fi_id_corrected_valid==true){
cout<<" Financial institution ID replaced or corrected by this transaction: "<<data.fi_id_corrected<<"\n";
}
if(data.fi_id_correction_action_valid==true){
cout<<" Action to take on the corrected transaction: ";
if (data.fi_id_correction_action==DELETE)
cout<<"DELETE\n";
else if (data.fi_id_correction_action==REPLACE)
cout<<"REPLACE\n";
else
cout<<"ofx_proc_transaction(): This should not happen!\n";
}
if(data.invtransactiontype_valid==true){
cout<<" Investment transaction type: ";
if (data.invtransactiontype==OFX_BUYDEBT)
strncpy(dest_string, "BUYDEBT (Buy debt security)", sizeof(dest_string));
else if (data.invtransactiontype==OFX_BUYMF)
strncpy(dest_string, "BUYMF (Buy mutual fund)", sizeof(dest_string));
else if (data.invtransactiontype==OFX_BUYOPT)
strncpy(dest_string, "BUYOPT (Buy option)", sizeof(dest_string));
else if (data.invtransactiontype==OFX_BUYOTHER)
strncpy(dest_string, "BUYOTHER (Buy other security type)", sizeof(dest_string));
else if (data.invtransactiontype==OFX_BUYSTOCK)
strncpy(dest_string, "BUYSTOCK (Buy stock))", sizeof(dest_string));
else if (data.invtransactiontype==OFX_CLOSUREOPT)
strncpy(dest_string, "CLOSUREOPT (Close a position for an option)", sizeof(dest_string));
else if (data.invtransactiontype==OFX_INCOME)
strncpy(dest_string, "INCOME (Investment income is realized as cash into the investment account)", sizeof(dest_string));
else if (data.invtransactiontype==OFX_INVEXPENSE)
strncpy(dest_string, "INVEXPENSE (Misc investment expense that is associated with a specific security)", sizeof(dest_string));
else if (data.invtransactiontype==OFX_JRNLFUND)
strncpy(dest_string, "JRNLFUND (Journaling cash holdings between subaccounts within the same investment account)", sizeof(dest_string));
else if (data.invtransactiontype==OFX_MARGININTEREST)
strncpy(dest_string, "MARGININTEREST (Margin interest expense)", sizeof(dest_string));
else if (data.invtransactiontype==OFX_REINVEST)
strncpy(dest_string, "REINVEST (Reinvestment of income)", sizeof(dest_string));
else if (data.invtransactiontype==OFX_RETOFCAP)
strncpy(dest_string, "RETOFCAP (Return of capital)", sizeof(dest_string));
else if (data.invtransactiontype==OFX_SELLDEBT)
strncpy(dest_string, "SELLDEBT (Sell debt security. Used when debt is sold, called, or reached maturity)", sizeof(dest_string));
else if (data.invtransactiontype==OFX_SELLMF)
strncpy(dest_string, "SELLMF (Sell mutual fund)", sizeof(dest_string));
else if (data.invtransactiontype==OFX_SELLOPT)
strncpy(dest_string, "SELLOPT (Sell option)", sizeof(dest_string));
else if (data.invtransactiontype==OFX_SELLOTHER)
strncpy(dest_string, "SELLOTHER (Sell other type of security)", sizeof(dest_string));
else if (data.invtransactiontype==OFX_SELLSTOCK)
strncpy(dest_string, "SELLSTOCK (Sell stock)", sizeof(dest_string));
else if (data.invtransactiontype==OFX_SPLIT)
strncpy(dest_string, "SPLIT (Stock or mutial fund split)", sizeof(dest_string));
else if (data.invtransactiontype==OFX_TRANSFER)
strncpy(dest_string, "TRANSFER (Transfer holdings in and out of the investment account)", sizeof(dest_string));
else
strncpy(dest_string, "ERROR, this investment transaction type is unknown. This is a bug in ofxdump", sizeof(dest_string));
cout<<dest_string<<"\n";
}
if(data.unique_id_valid==true){
cout<<" Unique ID of the security being traded: "<<data.unique_id<<"\n";
}
if(data.unique_id_type_valid==true){
cout<<" Format of the Unique ID: "<<data.unique_id_type<<"\n";
}
if(data.security_data_valid==true){
ofx_proc_security_cb(*(data.security_data_ptr), NULL );
}
if(data.server_transaction_id_valid==true){
cout<<" Server's transaction ID (confirmation number): "<<data.server_transaction_id<<"\n";
}
if(data.check_number_valid==true){
cout<<" Check number: "<<data.check_number<<"\n";
}
if(data.reference_number_valid==true){
cout<<" Reference number: "<<data.reference_number<<"\n";
}
if(data.standard_industrial_code_valid==true){
cout<<" Standard Industrial Code: "<<data.standard_industrial_code<<"\n";
}
if(data.payee_id_valid==true){
cout<<" Payee_id: "<<data.payee_id<<"\n";
}
if(data.name_valid==true){
cout<<" Name of payee or transaction description: "<<data.name<<"\n";
}
if(data.memo_valid==true){
cout<<" Extra transaction information (memo): "<<data.memo<<"\n";
}
cout<<"\n";
return 0;
}//end ofx_proc_transaction()
int ofx_proc_statement_cb(struct OfxStatementData data, void * statement_data)
{
char dest_string[255];
cout<<"ofx_proc_statement():\n";
if(data.currency_valid==true){
cout<<" Currency: "<<data.currency<<"\n";
}
if(data.account_id_valid==true){
cout<<" Account ID: "<<data.account_id<<"\n";
}
if(data.date_start_valid==true){
strftime(dest_string,sizeof(dest_string),"%c %Z",localtime(&(data.date_start)));
cout<<" Start date of this statement: "<<dest_string<<"\n";
}
if(data.date_end_valid==true){
strftime(dest_string,sizeof(dest_string),"%c %Z",localtime(&(data.date_end)));
cout<<" End date of this statement: "<<dest_string<<"\n";
}
if(data.ledger_balance_valid==true){
cout<<" Ledger balance: "<<setiosflags(ios::fixed)<<setiosflags(ios::showpoint)<<setprecision(2)<<data.ledger_balance<<"\n";
}
if(data.ledger_balance_date_valid==true){
strftime(dest_string,sizeof(dest_string),"%c %Z",localtime(&(data.ledger_balance_date)));
cout<<" Ledger balance date: "<<dest_string<<"\n";
}
if(data.available_balance_valid==true){
cout<<" Available balance: "<<setiosflags(ios::fixed)<<setiosflags(ios::showpoint)<<setprecision(2)<<data.available_balance<<"\n";
}
if(data.available_balance_date_valid==true){
strftime(dest_string,sizeof(dest_string),"%c %Z",localtime(&(data.available_balance_date)));
cout<<" Ledger balance date: "<<dest_string<<"\n";
}
if(data.marketing_info_valid==true){
cout<<" Marketing information: "<<data.marketing_info<<"\n";
}
cout<<"\n";
return 0;
}//end ofx_proc_statement()
int ofx_proc_account_cb(struct OfxAccountData data, void * account_data)
{
cout<<"ofx_proc_account():\n";
if(data.account_id_valid==true){
cout<<" Account ID: "<<data.account_id<<"\n";
cout<<" Account name: "<<data.account_name<<"\n";
}
if(data.account_type_valid==true){
cout<<" Account type: ";
switch(data.account_type){
case OfxAccountData::OFX_CHECKING : cout<<"CHECKING\n";
break;
case OfxAccountData::OFX_SAVINGS : cout<<"SAVINGS\n";
break;
case OfxAccountData::OFX_MONEYMRKT : cout<<"MONEYMRKT\n";
break;
case OfxAccountData::OFX_CREDITLINE : cout<<"CREDITLINE\n";
break;
case OfxAccountData::OFX_CMA : cout<<"CMA\n";
break;
case OfxAccountData::OFX_CREDITCARD : cout<<"CREDITCARD\n";
break;
case OfxAccountData::OFX_INVESTMENT : cout<<"INVESTMENT\n";
break;
default: cout<<"ofx_proc_account() WRITEME: This is an unknown account type!";
}
}
if(data.currency_valid==true){
cout<<" Currency: "<<data.currency<<"\n";
}
if (data.bank_id_valid)
cout<<" Bank ID: "<<data.bank_id << endl;;
if (data.branch_id_valid)
cout<<" Branch ID: "<<data.branch_id << endl;
if (data.account_number_valid)
cout<<" Account #: "<<data.account_number << endl;
cout<<"\n";
return 0;
}//end ofx_proc_account()
int ofx_proc_status_cb(struct OfxStatusData data, void * status_data)
{
cout<<"ofx_proc_status():\n";
if(data.ofx_element_name_valid==true){
cout<<" Ofx entity this status is relevent to: "<< data.ofx_element_name<<" \n";
}
if(data.severity_valid==true){
cout<<" Severity: ";
switch(data.severity){
case OfxStatusData::INFO : cout<<"INFO\n";
break;
case OfxStatusData::WARN : cout<<"WARN\n";
break;
case OfxStatusData::ERROR : cout<<"ERROR\n";
break;
default: cout<<"WRITEME: Unknown status severity!\n";
}
}
if(data.code_valid==true){
cout<<" Code: "<<data.code<<", name: "<<data.name<<"\n Description: "<<data.description<<"\n";
}
if(data.server_message_valid==true){
cout<<" Server Message: "<<data.server_message<<"\n";
}
cout<<"\n";
return 0;
}
int main (int argc, char *argv[])
{
/** Tell ofxdump what you want it to send to stderr. See messages.cpp for more details */
extern int ofx_PARSER_msg;
extern int ofx_DEBUG_msg;
extern int ofx_WARNING_msg;
extern int ofx_ERROR_msg;
extern int ofx_INFO_msg;
extern int ofx_STATUS_msg;
gengetopt_args_info args_info;
/* let's call our cmdline parser */
if (cmdline_parser (argc, argv, &args_info) != 0)
exit(1) ;
// if (args_info.msg_parser_given)
// cout << "The msg_parser option was given!" << endl;
// cout << "The flag is " << ( args_info.msg_parser_flag ? "on" : "off" ) <<
// "." << endl ;
args_info.msg_parser_flag ? ofx_PARSER_msg = true : ofx_PARSER_msg = false;
args_info.msg_debug_flag ? ofx_DEBUG_msg = true : ofx_DEBUG_msg = false;
args_info.msg_warning_flag ? ofx_WARNING_msg = true : ofx_WARNING_msg = false;
args_info.msg_error_flag ? ofx_ERROR_msg = true : ofx_ERROR_msg = false;
args_info.msg_info_flag ? ofx_INFO_msg = true : ofx_INFO_msg = false;
args_info.msg_status_flag ? ofx_STATUS_msg = true : ofx_STATUS_msg;
bool skiphelp = false;
if(args_info.list_import_formats_given)
{
skiphelp = true;
cout <<"The supported file formats for the 'input-file-format' argument are:"<<endl;
for(int i=0; LibofxImportFormatList[i].format!=LAST; i++)
{
cout <<" "<<LibofxImportFormatList[i].description<<endl;
}
}
LibofxContextPtr libofx_context = libofx_get_new_context();
//char **inputs ; /* unamed options */
//unsigned inputs_num ; /* unamed options number */
if (args_info.inputs_num > 0)
{
const char* filename = args_info.inputs[0];
ofx_set_statement_cb(libofx_context, ofx_proc_statement_cb, 0);
ofx_set_account_cb(libofx_context, ofx_proc_account_cb, 0);
ofx_set_transaction_cb(libofx_context, ofx_proc_transaction_cb, 0);
ofx_set_security_cb(libofx_context, ofx_proc_security_cb, 0);
ofx_set_status_cb(libofx_context, ofx_proc_status_cb, 0);
enum LibofxFileFormat file_format = libofx_get_file_format_from_str(LibofxImportFormatList, args_info.import_format_arg);
/** @todo currently, only the first file is processed as the library can't deal with more right now.*/
if(args_info.inputs_num > 1)
{
cout << "Sorry, currently, only the first file is processed as the library can't deal with more right now. The following files were ignored:"<<endl;
for ( unsigned i = 1 ; i < args_info.inputs_num ; ++i )
{
cout << "file: " << args_info.inputs[i] << endl ;
}
}
libofx_proc_file(libofx_context, args_info.inputs[0], file_format);
}
else
{
if ( !skiphelp )
cmdline_parser_print_help();
}
return 0;
}
| tectronics/cashbox | libofx/libofx-0.8.2/ofxdump/ofxdump.cpp | C++ | gpl-2.0 | 18,771 |
//
// DO NOT EDIT - generated by simspec!
//
#ifndef ___ARHOST1X_UCLASS_H_INC_
#define ___ARHOST1X_UCLASS_H_INC_
// --------------------------------------------------------------------------
//
// Copyright (c) 2004-2012, NVIDIA Corp.
// All Rights Reserved.
//
// This is UNPUBLISHED PROPRIETARY SOURCE CODE of NVIDIA Corp.;
// the contents of this file may not be disclosed to third parties, copied or
// duplicated in any form, in whole or in part, without the prior written
// permission of NVIDIA Corp.
//
// RESTRICTED RIGHTS LEGEND:
// Use, duplication or disclosure by the Government is subject to restrictions
// as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
// and Computer Software clause at DFARS 252.227-7013, and/or in similar or
// successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
// rights reserved under the Copyright Laws of the United States.
//
// --------------------------------------------------------------------------
//
// --------------------------------------------------------------------------
//
// Copyright (c) 2004, NVIDIA Corp.
// All Rights Reserved.
//
// This is UNPUBLISHED PROPRIETARY SOURCE CODE of NVIDIA Corp.;
// the contents of this file may not be disclosed to third parties, copied or
// duplicated in any form, in whole or in part, without the prior written
// permission of NVIDIA Corp.
//
// RESTRICTED RIGHTS LEGEND:
// Use, duplication or disclosure by the Government is subject to restrictions
// as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
// and Computer Software clause at DFARS 252.227-7013, and/or in similar or
// successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
// rights reserved under the Copyright Laws of the United States.
//
// --------------------------------------------------------------------------
//
// Channel IDs
// class offsets are always relative to the class (based at 0)
// All Classes have the INCR_SYNCPT method
// For host, this method, immediately increments
// SYNCPT[indx], irrespective of the cond.
// Note that INCR_SYNCPT_CNTRL and INCR_SYNCPT_ERROR
// are included for consistency with host clients,
// but writes to INCR_SYNCPT_CNTRL have no effect
// on the operation of host1x, and because there
// are no condition fifos to overflow,
// INCR_SYNCPT_ERROR will never be set.
// --------------------------------------------------------------------------
//
// Copyright (c) 2004, NVIDIA Corp.
// All Rights Reserved.
//
// This is UNPUBLISHED PROPRIETARY SOURCE CODE of NVIDIA Corp.;
// the contents of this file may not be disclosed to third parties, copied or
// duplicated in any form, in whole or in part, without the prior written
// permission of NVIDIA Corp.
//
// RESTRICTED RIGHTS LEGEND:
// Use, duplication or disclosure by the Government is subject to restrictions
// as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
// and Computer Software clause at DFARS 252.227-7013, and/or in similar or
// successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
// rights reserved under the Copyright Laws of the United States.
//
// --------------------------------------------------------------------------
//
// Register NV_CLASS_HOST_INCR_SYNCPT_0
#define NV_CLASS_HOST_INCR_SYNCPT_0 _MK_ADDR_CONST(0x0)
#define NV_CLASS_HOST_INCR_SYNCPT_0_SECURE 0x0
#define NV_CLASS_HOST_INCR_SYNCPT_0_WORD_COUNT 0x1
#define NV_CLASS_HOST_INCR_SYNCPT_0_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INCR_SYNCPT_0_RESET_MASK _MK_MASK_CONST(0xffff)
#define NV_CLASS_HOST_INCR_SYNCPT_0_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INCR_SYNCPT_0_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INCR_SYNCPT_0_READ_MASK _MK_MASK_CONST(0xffff)
#define NV_CLASS_HOST_INCR_SYNCPT_0_WRITE_MASK _MK_MASK_CONST(0xffff)
// Condition mapped from raise/wait
#define NV_CLASS_HOST_INCR_SYNCPT_0_COND_SHIFT _MK_SHIFT_CONST(8)
#define NV_CLASS_HOST_INCR_SYNCPT_0_COND_FIELD (_MK_MASK_CONST(0xff) << NV_CLASS_HOST_INCR_SYNCPT_0_COND_SHIFT)
#define NV_CLASS_HOST_INCR_SYNCPT_0_COND_RANGE 15:8
#define NV_CLASS_HOST_INCR_SYNCPT_0_COND_WOFFSET 0x0
#define NV_CLASS_HOST_INCR_SYNCPT_0_COND_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INCR_SYNCPT_0_COND_DEFAULT_MASK _MK_MASK_CONST(0xff)
#define NV_CLASS_HOST_INCR_SYNCPT_0_COND_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INCR_SYNCPT_0_COND_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INCR_SYNCPT_0_COND_IMMEDIATE _MK_ENUM_CONST(0)
#define NV_CLASS_HOST_INCR_SYNCPT_0_COND_OP_DONE _MK_ENUM_CONST(1)
#define NV_CLASS_HOST_INCR_SYNCPT_0_COND_RD_DONE _MK_ENUM_CONST(2)
#define NV_CLASS_HOST_INCR_SYNCPT_0_COND_REG_WR_SAFE _MK_ENUM_CONST(3)
#define NV_CLASS_HOST_INCR_SYNCPT_0_COND_COND_4 _MK_ENUM_CONST(4)
#define NV_CLASS_HOST_INCR_SYNCPT_0_COND_COND_5 _MK_ENUM_CONST(5)
#define NV_CLASS_HOST_INCR_SYNCPT_0_COND_COND_6 _MK_ENUM_CONST(6)
#define NV_CLASS_HOST_INCR_SYNCPT_0_COND_COND_7 _MK_ENUM_CONST(7)
#define NV_CLASS_HOST_INCR_SYNCPT_0_COND_COND_8 _MK_ENUM_CONST(8)
#define NV_CLASS_HOST_INCR_SYNCPT_0_COND_COND_9 _MK_ENUM_CONST(9)
#define NV_CLASS_HOST_INCR_SYNCPT_0_COND_COND_10 _MK_ENUM_CONST(10)
#define NV_CLASS_HOST_INCR_SYNCPT_0_COND_COND_11 _MK_ENUM_CONST(11)
#define NV_CLASS_HOST_INCR_SYNCPT_0_COND_COND_12 _MK_ENUM_CONST(12)
#define NV_CLASS_HOST_INCR_SYNCPT_0_COND_COND_13 _MK_ENUM_CONST(13)
#define NV_CLASS_HOST_INCR_SYNCPT_0_COND_COND_14 _MK_ENUM_CONST(14)
#define NV_CLASS_HOST_INCR_SYNCPT_0_COND_COND_15 _MK_ENUM_CONST(15)
// syncpt index value
#define NV_CLASS_HOST_INCR_SYNCPT_0_INDX_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INCR_SYNCPT_0_INDX_FIELD (_MK_MASK_CONST(0xff) << NV_CLASS_HOST_INCR_SYNCPT_0_INDX_SHIFT)
#define NV_CLASS_HOST_INCR_SYNCPT_0_INDX_RANGE 7:0
#define NV_CLASS_HOST_INCR_SYNCPT_0_INDX_WOFFSET 0x0
#define NV_CLASS_HOST_INCR_SYNCPT_0_INDX_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INCR_SYNCPT_0_INDX_DEFAULT_MASK _MK_MASK_CONST(0xff)
#define NV_CLASS_HOST_INCR_SYNCPT_0_INDX_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INCR_SYNCPT_0_INDX_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Register NV_CLASS_HOST_INCR_SYNCPT_CNTRL_0
#define NV_CLASS_HOST_INCR_SYNCPT_CNTRL_0 _MK_ADDR_CONST(0x1)
#define NV_CLASS_HOST_INCR_SYNCPT_CNTRL_0_SECURE 0x0
#define NV_CLASS_HOST_INCR_SYNCPT_CNTRL_0_WORD_COUNT 0x1
#define NV_CLASS_HOST_INCR_SYNCPT_CNTRL_0_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INCR_SYNCPT_CNTRL_0_RESET_MASK _MK_MASK_CONST(0x101)
#define NV_CLASS_HOST_INCR_SYNCPT_CNTRL_0_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INCR_SYNCPT_CNTRL_0_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INCR_SYNCPT_CNTRL_0_READ_MASK _MK_MASK_CONST(0x101)
#define NV_CLASS_HOST_INCR_SYNCPT_CNTRL_0_WRITE_MASK _MK_MASK_CONST(0x101)
// If NO_STALL is 1, then when fifos are full,
// INCR_SYNCPT methods will be dropped and the
// INCR_SYNCPT_ERROR[COND] bit will be set.
// If NO_STALL is 0, then when fifos are full,
// the client host interface will be stalled.
#define NV_CLASS_HOST_INCR_SYNCPT_CNTRL_0_INCR_SYNCPT_NO_STALL_SHIFT _MK_SHIFT_CONST(8)
#define NV_CLASS_HOST_INCR_SYNCPT_CNTRL_0_INCR_SYNCPT_NO_STALL_FIELD (_MK_MASK_CONST(0x1) << NV_CLASS_HOST_INCR_SYNCPT_CNTRL_0_INCR_SYNCPT_NO_STALL_SHIFT)
#define NV_CLASS_HOST_INCR_SYNCPT_CNTRL_0_INCR_SYNCPT_NO_STALL_RANGE 8:8
#define NV_CLASS_HOST_INCR_SYNCPT_CNTRL_0_INCR_SYNCPT_NO_STALL_WOFFSET 0x0
#define NV_CLASS_HOST_INCR_SYNCPT_CNTRL_0_INCR_SYNCPT_NO_STALL_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INCR_SYNCPT_CNTRL_0_INCR_SYNCPT_NO_STALL_DEFAULT_MASK _MK_MASK_CONST(0x1)
#define NV_CLASS_HOST_INCR_SYNCPT_CNTRL_0_INCR_SYNCPT_NO_STALL_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INCR_SYNCPT_CNTRL_0_INCR_SYNCPT_NO_STALL_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// If SOFT_RESET is set, then all internal state
// of the client syncpt block will be reset.
// To do soft reset, first set SOFT_RESET of
// all host1x clients affected, then clear all
// SOFT_RESETs.
#define NV_CLASS_HOST_INCR_SYNCPT_CNTRL_0_INCR_SYNCPT_SOFT_RESET_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INCR_SYNCPT_CNTRL_0_INCR_SYNCPT_SOFT_RESET_FIELD (_MK_MASK_CONST(0x1) << NV_CLASS_HOST_INCR_SYNCPT_CNTRL_0_INCR_SYNCPT_SOFT_RESET_SHIFT)
#define NV_CLASS_HOST_INCR_SYNCPT_CNTRL_0_INCR_SYNCPT_SOFT_RESET_RANGE 0:0
#define NV_CLASS_HOST_INCR_SYNCPT_CNTRL_0_INCR_SYNCPT_SOFT_RESET_WOFFSET 0x0
#define NV_CLASS_HOST_INCR_SYNCPT_CNTRL_0_INCR_SYNCPT_SOFT_RESET_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INCR_SYNCPT_CNTRL_0_INCR_SYNCPT_SOFT_RESET_DEFAULT_MASK _MK_MASK_CONST(0x1)
#define NV_CLASS_HOST_INCR_SYNCPT_CNTRL_0_INCR_SYNCPT_SOFT_RESET_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INCR_SYNCPT_CNTRL_0_INCR_SYNCPT_SOFT_RESET_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Register NV_CLASS_HOST_INCR_SYNCPT_ERROR_0
#define NV_CLASS_HOST_INCR_SYNCPT_ERROR_0 _MK_ADDR_CONST(0x2)
#define NV_CLASS_HOST_INCR_SYNCPT_ERROR_0_SECURE 0x0
#define NV_CLASS_HOST_INCR_SYNCPT_ERROR_0_WORD_COUNT 0x1
#define NV_CLASS_HOST_INCR_SYNCPT_ERROR_0_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INCR_SYNCPT_ERROR_0_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INCR_SYNCPT_ERROR_0_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INCR_SYNCPT_ERROR_0_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INCR_SYNCPT_ERROR_0_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INCR_SYNCPT_ERROR_0_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// COND_STATUS[COND] is set if the fifo for COND overflows.
// This bit is sticky and will remain set until cleared.
// Cleared by writing 1.
#define NV_CLASS_HOST_INCR_SYNCPT_ERROR_0_COND_STATUS_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INCR_SYNCPT_ERROR_0_COND_STATUS_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_INCR_SYNCPT_ERROR_0_COND_STATUS_SHIFT)
#define NV_CLASS_HOST_INCR_SYNCPT_ERROR_0_COND_STATUS_RANGE 31:0
#define NV_CLASS_HOST_INCR_SYNCPT_ERROR_0_COND_STATUS_WOFFSET 0x0
#define NV_CLASS_HOST_INCR_SYNCPT_ERROR_0_COND_STATUS_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INCR_SYNCPT_ERROR_0_COND_STATUS_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INCR_SYNCPT_ERROR_0_COND_STATUS_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INCR_SYNCPT_ERROR_0_COND_STATUS_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// reserve locations for future expansion
// Reserved address 3 [0x3]
// Reserved address 4 [0x4]
// Reserved address 5 [0x5]
// Reserved address 6 [0x6]
// Reserved address 7 [0x7]
// just in case names were redefined using macros
// Wait on syncpt method
// Command dispatch will stall until
// SYNCPT[indx][NV_HOST1X_SYNCPT_THRESH_WIDTH-1:0] >= threshold[NV_HOST1X_SYNCPT_THRESH_WIDTH-1:0]
// The comparison takes into account the possibility of wrapping.
// Note that more bits are allocated for indx and threshold than may be used in an implementation
// Use NV_HOST1X_SYNCPT_NB_PTS for the number of syncpts, and
// NV_HOST1X_SYNCPT_THESH_WIDTH for the number of bits used by the comparison
// Register NV_CLASS_HOST_WAIT_SYNCPT_0
#define NV_CLASS_HOST_WAIT_SYNCPT_0 _MK_ADDR_CONST(0x8)
#define NV_CLASS_HOST_WAIT_SYNCPT_0_SECURE 0x0
#define NV_CLASS_HOST_WAIT_SYNCPT_0_WORD_COUNT 0x1
#define NV_CLASS_HOST_WAIT_SYNCPT_0_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_SYNCPT_0_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_SYNCPT_0_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_SYNCPT_0_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_SYNCPT_0_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_WAIT_SYNCPT_0_WRITE_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_WAIT_SYNCPT_0_INDX_SHIFT _MK_SHIFT_CONST(24)
#define NV_CLASS_HOST_WAIT_SYNCPT_0_INDX_FIELD (_MK_MASK_CONST(0xff) << NV_CLASS_HOST_WAIT_SYNCPT_0_INDX_SHIFT)
#define NV_CLASS_HOST_WAIT_SYNCPT_0_INDX_RANGE 31:24
#define NV_CLASS_HOST_WAIT_SYNCPT_0_INDX_WOFFSET 0x0
#define NV_CLASS_HOST_WAIT_SYNCPT_0_INDX_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_SYNCPT_0_INDX_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_SYNCPT_0_INDX_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_SYNCPT_0_INDX_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_SYNCPT_0_THRESH_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_WAIT_SYNCPT_0_THRESH_FIELD (_MK_MASK_CONST(0xffffff) << NV_CLASS_HOST_WAIT_SYNCPT_0_THRESH_SHIFT)
#define NV_CLASS_HOST_WAIT_SYNCPT_0_THRESH_RANGE 23:0
#define NV_CLASS_HOST_WAIT_SYNCPT_0_THRESH_WOFFSET 0x0
#define NV_CLASS_HOST_WAIT_SYNCPT_0_THRESH_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_SYNCPT_0_THRESH_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_SYNCPT_0_THRESH_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_SYNCPT_0_THRESH_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Wait on syncpt method using base register
// Command dispatch will stall until
// SYNCPT[indx][NV_HOST1X_SYNCPT_THRESH_WIDTH-1:0] >= (SYNCPT_BASE[base_indx]+offset)
// The comparison takes into account the possibility of wrapping.
// Note that more bits are allocated for indx and base_indx than may be used in an implementation.
// Use NV_HOST1X_SYNCPT_NB_PTS for the number of syncpts,
// Use NV_HOST1X_SYNCPT_NB_BASES for the number of syncpt_bases, and
// NV_HOST1X_SYNCPT_THESH_WIDTH for the number of bits used by the comparison
// If NV_HOST1X_SYNCPT_THESH_WIDTH is greater than 16, offset is sign-extended before it is added to SYNCPT_BASE.
// Register NV_CLASS_HOST_WAIT_SYNCPT_BASE_0
#define NV_CLASS_HOST_WAIT_SYNCPT_BASE_0 _MK_ADDR_CONST(0x9)
#define NV_CLASS_HOST_WAIT_SYNCPT_BASE_0_SECURE 0x0
#define NV_CLASS_HOST_WAIT_SYNCPT_BASE_0_WORD_COUNT 0x1
#define NV_CLASS_HOST_WAIT_SYNCPT_BASE_0_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_SYNCPT_BASE_0_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_SYNCPT_BASE_0_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_SYNCPT_BASE_0_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_SYNCPT_BASE_0_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_WAIT_SYNCPT_BASE_0_WRITE_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_WAIT_SYNCPT_BASE_0_INDX_SHIFT _MK_SHIFT_CONST(24)
#define NV_CLASS_HOST_WAIT_SYNCPT_BASE_0_INDX_FIELD (_MK_MASK_CONST(0xff) << NV_CLASS_HOST_WAIT_SYNCPT_BASE_0_INDX_SHIFT)
#define NV_CLASS_HOST_WAIT_SYNCPT_BASE_0_INDX_RANGE 31:24
#define NV_CLASS_HOST_WAIT_SYNCPT_BASE_0_INDX_WOFFSET 0x0
#define NV_CLASS_HOST_WAIT_SYNCPT_BASE_0_INDX_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_SYNCPT_BASE_0_INDX_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_SYNCPT_BASE_0_INDX_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_SYNCPT_BASE_0_INDX_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_SYNCPT_BASE_0_BASE_INDX_SHIFT _MK_SHIFT_CONST(16)
#define NV_CLASS_HOST_WAIT_SYNCPT_BASE_0_BASE_INDX_FIELD (_MK_MASK_CONST(0xff) << NV_CLASS_HOST_WAIT_SYNCPT_BASE_0_BASE_INDX_SHIFT)
#define NV_CLASS_HOST_WAIT_SYNCPT_BASE_0_BASE_INDX_RANGE 23:16
#define NV_CLASS_HOST_WAIT_SYNCPT_BASE_0_BASE_INDX_WOFFSET 0x0
#define NV_CLASS_HOST_WAIT_SYNCPT_BASE_0_BASE_INDX_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_SYNCPT_BASE_0_BASE_INDX_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_SYNCPT_BASE_0_BASE_INDX_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_SYNCPT_BASE_0_BASE_INDX_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_SYNCPT_BASE_0_OFFSET_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_WAIT_SYNCPT_BASE_0_OFFSET_FIELD (_MK_MASK_CONST(0xffff) << NV_CLASS_HOST_WAIT_SYNCPT_BASE_0_OFFSET_SHIFT)
#define NV_CLASS_HOST_WAIT_SYNCPT_BASE_0_OFFSET_RANGE 15:0
#define NV_CLASS_HOST_WAIT_SYNCPT_BASE_0_OFFSET_WOFFSET 0x0
#define NV_CLASS_HOST_WAIT_SYNCPT_BASE_0_OFFSET_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_SYNCPT_BASE_0_OFFSET_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_SYNCPT_BASE_0_OFFSET_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_SYNCPT_BASE_0_OFFSET_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Wait on syncpt increment method
// Command dispatch will stall until the next time that SYNCPT[indx] is incremented.
// Note that more bits are allocated for indx than may be used in an implementation.
// Use NV_HOST1X_SYNCPT_NB_PTS for the number of syncpts.
// Register NV_CLASS_HOST_WAIT_SYNCPT_INCR_0
#define NV_CLASS_HOST_WAIT_SYNCPT_INCR_0 _MK_ADDR_CONST(0xa)
#define NV_CLASS_HOST_WAIT_SYNCPT_INCR_0_SECURE 0x0
#define NV_CLASS_HOST_WAIT_SYNCPT_INCR_0_WORD_COUNT 0x1
#define NV_CLASS_HOST_WAIT_SYNCPT_INCR_0_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_SYNCPT_INCR_0_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_SYNCPT_INCR_0_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_SYNCPT_INCR_0_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_SYNCPT_INCR_0_READ_MASK _MK_MASK_CONST(0xff000000)
#define NV_CLASS_HOST_WAIT_SYNCPT_INCR_0_WRITE_MASK _MK_MASK_CONST(0xff000000)
#define NV_CLASS_HOST_WAIT_SYNCPT_INCR_0_INDX_SHIFT _MK_SHIFT_CONST(24)
#define NV_CLASS_HOST_WAIT_SYNCPT_INCR_0_INDX_FIELD (_MK_MASK_CONST(0xff) << NV_CLASS_HOST_WAIT_SYNCPT_INCR_0_INDX_SHIFT)
#define NV_CLASS_HOST_WAIT_SYNCPT_INCR_0_INDX_RANGE 31:24
#define NV_CLASS_HOST_WAIT_SYNCPT_INCR_0_INDX_WOFFSET 0x0
#define NV_CLASS_HOST_WAIT_SYNCPT_INCR_0_INDX_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_SYNCPT_INCR_0_INDX_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_SYNCPT_INCR_0_INDX_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_SYNCPT_INCR_0_INDX_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Load syncpt base method
// SYNCPT_BASE[indx] = value
// Register NV_CLASS_HOST_LOAD_SYNCPT_BASE_0
#define NV_CLASS_HOST_LOAD_SYNCPT_BASE_0 _MK_ADDR_CONST(0xb)
#define NV_CLASS_HOST_LOAD_SYNCPT_BASE_0_SECURE 0x0
#define NV_CLASS_HOST_LOAD_SYNCPT_BASE_0_WORD_COUNT 0x1
#define NV_CLASS_HOST_LOAD_SYNCPT_BASE_0_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_LOAD_SYNCPT_BASE_0_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_LOAD_SYNCPT_BASE_0_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_LOAD_SYNCPT_BASE_0_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_LOAD_SYNCPT_BASE_0_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_LOAD_SYNCPT_BASE_0_WRITE_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_LOAD_SYNCPT_BASE_0_BASE_INDX_SHIFT _MK_SHIFT_CONST(24)
#define NV_CLASS_HOST_LOAD_SYNCPT_BASE_0_BASE_INDX_FIELD (_MK_MASK_CONST(0xff) << NV_CLASS_HOST_LOAD_SYNCPT_BASE_0_BASE_INDX_SHIFT)
#define NV_CLASS_HOST_LOAD_SYNCPT_BASE_0_BASE_INDX_RANGE 31:24
#define NV_CLASS_HOST_LOAD_SYNCPT_BASE_0_BASE_INDX_WOFFSET 0x0
#define NV_CLASS_HOST_LOAD_SYNCPT_BASE_0_BASE_INDX_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_LOAD_SYNCPT_BASE_0_BASE_INDX_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_LOAD_SYNCPT_BASE_0_BASE_INDX_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_LOAD_SYNCPT_BASE_0_BASE_INDX_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_LOAD_SYNCPT_BASE_0_VALUE_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_LOAD_SYNCPT_BASE_0_VALUE_FIELD (_MK_MASK_CONST(0xffffff) << NV_CLASS_HOST_LOAD_SYNCPT_BASE_0_VALUE_SHIFT)
#define NV_CLASS_HOST_LOAD_SYNCPT_BASE_0_VALUE_RANGE 23:0
#define NV_CLASS_HOST_LOAD_SYNCPT_BASE_0_VALUE_WOFFSET 0x0
#define NV_CLASS_HOST_LOAD_SYNCPT_BASE_0_VALUE_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_LOAD_SYNCPT_BASE_0_VALUE_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_LOAD_SYNCPT_BASE_0_VALUE_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_LOAD_SYNCPT_BASE_0_VALUE_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Increment syncpt base method
// SYNCPT_BASE[indx] += offset
// Register NV_CLASS_HOST_INCR_SYNCPT_BASE_0
#define NV_CLASS_HOST_INCR_SYNCPT_BASE_0 _MK_ADDR_CONST(0xc)
#define NV_CLASS_HOST_INCR_SYNCPT_BASE_0_SECURE 0x0
#define NV_CLASS_HOST_INCR_SYNCPT_BASE_0_WORD_COUNT 0x1
#define NV_CLASS_HOST_INCR_SYNCPT_BASE_0_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INCR_SYNCPT_BASE_0_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INCR_SYNCPT_BASE_0_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INCR_SYNCPT_BASE_0_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INCR_SYNCPT_BASE_0_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INCR_SYNCPT_BASE_0_WRITE_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INCR_SYNCPT_BASE_0_BASE_INDX_SHIFT _MK_SHIFT_CONST(24)
#define NV_CLASS_HOST_INCR_SYNCPT_BASE_0_BASE_INDX_FIELD (_MK_MASK_CONST(0xff) << NV_CLASS_HOST_INCR_SYNCPT_BASE_0_BASE_INDX_SHIFT)
#define NV_CLASS_HOST_INCR_SYNCPT_BASE_0_BASE_INDX_RANGE 31:24
#define NV_CLASS_HOST_INCR_SYNCPT_BASE_0_BASE_INDX_WOFFSET 0x0
#define NV_CLASS_HOST_INCR_SYNCPT_BASE_0_BASE_INDX_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INCR_SYNCPT_BASE_0_BASE_INDX_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INCR_SYNCPT_BASE_0_BASE_INDX_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INCR_SYNCPT_BASE_0_BASE_INDX_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INCR_SYNCPT_BASE_0_OFFSET_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INCR_SYNCPT_BASE_0_OFFSET_FIELD (_MK_MASK_CONST(0xffffff) << NV_CLASS_HOST_INCR_SYNCPT_BASE_0_OFFSET_SHIFT)
#define NV_CLASS_HOST_INCR_SYNCPT_BASE_0_OFFSET_RANGE 23:0
#define NV_CLASS_HOST_INCR_SYNCPT_BASE_0_OFFSET_WOFFSET 0x0
#define NV_CLASS_HOST_INCR_SYNCPT_BASE_0_OFFSET_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INCR_SYNCPT_BASE_0_OFFSET_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INCR_SYNCPT_BASE_0_OFFSET_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INCR_SYNCPT_BASE_0_OFFSET_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Clear method. Any bits set in VECTOR will be cleared in the channel's RAISE
// vector.
// Register NV_CLASS_HOST_CLEAR_0
#define NV_CLASS_HOST_CLEAR_0 _MK_ADDR_CONST(0xd)
#define NV_CLASS_HOST_CLEAR_0_SECURE 0x0
#define NV_CLASS_HOST_CLEAR_0_WORD_COUNT 0x1
#define NV_CLASS_HOST_CLEAR_0_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_CLEAR_0_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_CLEAR_0_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_CLEAR_0_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_CLEAR_0_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_CLEAR_0_WRITE_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_CLEAR_0_VECTOR_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_CLEAR_0_VECTOR_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_CLEAR_0_VECTOR_SHIFT)
#define NV_CLASS_HOST_CLEAR_0_VECTOR_RANGE 31:0
#define NV_CLASS_HOST_CLEAR_0_VECTOR_WOFFSET 0x0
#define NV_CLASS_HOST_CLEAR_0_VECTOR_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_CLEAR_0_VECTOR_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_CLEAR_0_VECTOR_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_CLEAR_0_VECTOR_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Wait method. Command dispatch will stall until any of the bits set in
// VECTOR become set in the channel's RAISE vector.
// Register NV_CLASS_HOST_WAIT_0
#define NV_CLASS_HOST_WAIT_0 _MK_ADDR_CONST(0xe)
#define NV_CLASS_HOST_WAIT_0_SECURE 0x0
#define NV_CLASS_HOST_WAIT_0_WORD_COUNT 0x1
#define NV_CLASS_HOST_WAIT_0_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_0_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_0_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_0_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_0_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_WAIT_0_WRITE_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_WAIT_0_VECTOR_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_WAIT_0_VECTOR_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_WAIT_0_VECTOR_SHIFT)
#define NV_CLASS_HOST_WAIT_0_VECTOR_RANGE 31:0
#define NV_CLASS_HOST_WAIT_0_VECTOR_WOFFSET 0x0
#define NV_CLASS_HOST_WAIT_0_VECTOR_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_0_VECTOR_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_0_VECTOR_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_0_VECTOR_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Wait w/ interrupt method. Identical to the WAIT method except an interrupt
// will be triggered when the WAIT requirement is satisfied.
// Register NV_CLASS_HOST_WAIT_WITH_INTR_0
#define NV_CLASS_HOST_WAIT_WITH_INTR_0 _MK_ADDR_CONST(0xf)
#define NV_CLASS_HOST_WAIT_WITH_INTR_0_SECURE 0x0
#define NV_CLASS_HOST_WAIT_WITH_INTR_0_WORD_COUNT 0x1
#define NV_CLASS_HOST_WAIT_WITH_INTR_0_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_WITH_INTR_0_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_WITH_INTR_0_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_WITH_INTR_0_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_WITH_INTR_0_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_WAIT_WITH_INTR_0_WRITE_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_WAIT_WITH_INTR_0_VECTOR_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_WAIT_WITH_INTR_0_VECTOR_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_WAIT_WITH_INTR_0_VECTOR_SHIFT)
#define NV_CLASS_HOST_WAIT_WITH_INTR_0_VECTOR_RANGE 31:0
#define NV_CLASS_HOST_WAIT_WITH_INTR_0_VECTOR_WOFFSET 0x0
#define NV_CLASS_HOST_WAIT_WITH_INTR_0_VECTOR_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_WITH_INTR_0_VECTOR_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_WITH_INTR_0_VECTOR_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_WAIT_WITH_INTR_0_VECTOR_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Delay number of microseconds. Command dispatch will stall until the number
// of microseconds indicated in NUSEC has passed. The timing of microseconds
// is controlled by the USEC_CLK register.
// Register NV_CLASS_HOST_DELAY_USEC_0
#define NV_CLASS_HOST_DELAY_USEC_0 _MK_ADDR_CONST(0x10)
#define NV_CLASS_HOST_DELAY_USEC_0_SECURE 0x0
#define NV_CLASS_HOST_DELAY_USEC_0_WORD_COUNT 0x1
#define NV_CLASS_HOST_DELAY_USEC_0_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_DELAY_USEC_0_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_DELAY_USEC_0_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_DELAY_USEC_0_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_DELAY_USEC_0_READ_MASK _MK_MASK_CONST(0xfffff)
#define NV_CLASS_HOST_DELAY_USEC_0_WRITE_MASK _MK_MASK_CONST(0xfffff)
// Enough for 1.05 seconds
#define NV_CLASS_HOST_DELAY_USEC_0_NUSEC_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_DELAY_USEC_0_NUSEC_FIELD (_MK_MASK_CONST(0xfffff) << NV_CLASS_HOST_DELAY_USEC_0_NUSEC_SHIFT)
#define NV_CLASS_HOST_DELAY_USEC_0_NUSEC_RANGE 19:0
#define NV_CLASS_HOST_DELAY_USEC_0_NUSEC_WOFFSET 0x0
#define NV_CLASS_HOST_DELAY_USEC_0_NUSEC_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_DELAY_USEC_0_NUSEC_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_DELAY_USEC_0_NUSEC_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_DELAY_USEC_0_NUSEC_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// This register value will initialize the high 32 bits of
// tick count value in the host clock counter
// Register NV_CLASS_HOST_TICKCOUNT_HI_0
#define NV_CLASS_HOST_TICKCOUNT_HI_0 _MK_ADDR_CONST(0x11)
#define NV_CLASS_HOST_TICKCOUNT_HI_0_SECURE 0x0
#define NV_CLASS_HOST_TICKCOUNT_HI_0_WORD_COUNT 0x1
#define NV_CLASS_HOST_TICKCOUNT_HI_0_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_TICKCOUNT_HI_0_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_TICKCOUNT_HI_0_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_TICKCOUNT_HI_0_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_TICKCOUNT_HI_0_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_TICKCOUNT_HI_0_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// read or write tick count
#define NV_CLASS_HOST_TICKCOUNT_HI_0_TICKS_HI_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_TICKCOUNT_HI_0_TICKS_HI_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_TICKCOUNT_HI_0_TICKS_HI_SHIFT)
#define NV_CLASS_HOST_TICKCOUNT_HI_0_TICKS_HI_RANGE 31:0
#define NV_CLASS_HOST_TICKCOUNT_HI_0_TICKS_HI_WOFFSET 0x0
#define NV_CLASS_HOST_TICKCOUNT_HI_0_TICKS_HI_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_TICKCOUNT_HI_0_TICKS_HI_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_TICKCOUNT_HI_0_TICKS_HI_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_TICKCOUNT_HI_0_TICKS_HI_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// This register value will initialize the low 32 bits of
// tick count value in the host clock counter
// Register NV_CLASS_HOST_TICKCOUNT_LO_0
#define NV_CLASS_HOST_TICKCOUNT_LO_0 _MK_ADDR_CONST(0x12)
#define NV_CLASS_HOST_TICKCOUNT_LO_0_SECURE 0x0
#define NV_CLASS_HOST_TICKCOUNT_LO_0_WORD_COUNT 0x1
#define NV_CLASS_HOST_TICKCOUNT_LO_0_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_TICKCOUNT_LO_0_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_TICKCOUNT_LO_0_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_TICKCOUNT_LO_0_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_TICKCOUNT_LO_0_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_TICKCOUNT_LO_0_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// read or write tick count
#define NV_CLASS_HOST_TICKCOUNT_LO_0_TICKS_LO_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_TICKCOUNT_LO_0_TICKS_LO_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_TICKCOUNT_LO_0_TICKS_LO_SHIFT)
#define NV_CLASS_HOST_TICKCOUNT_LO_0_TICKS_LO_RANGE 31:0
#define NV_CLASS_HOST_TICKCOUNT_LO_0_TICKS_LO_WOFFSET 0x0
#define NV_CLASS_HOST_TICKCOUNT_LO_0_TICKS_LO_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_TICKCOUNT_LO_0_TICKS_LO_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_TICKCOUNT_LO_0_TICKS_LO_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_TICKCOUNT_LO_0_TICKS_LO_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// This register write enables the tick counter on the host clock to start counting
// Register NV_CLASS_HOST_TICKCTRL_0
#define NV_CLASS_HOST_TICKCTRL_0 _MK_ADDR_CONST(0x13)
#define NV_CLASS_HOST_TICKCTRL_0_SECURE 0x0
#define NV_CLASS_HOST_TICKCTRL_0_WORD_COUNT 0x1
#define NV_CLASS_HOST_TICKCTRL_0_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_TICKCTRL_0_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_TICKCTRL_0_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_TICKCTRL_0_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_TICKCTRL_0_READ_MASK _MK_MASK_CONST(0x1)
#define NV_CLASS_HOST_TICKCTRL_0_WRITE_MASK _MK_MASK_CONST(0x1)
// Enable or Disable tick counter
#define NV_CLASS_HOST_TICKCTRL_0_TICKCNT_ENABLE_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_TICKCTRL_0_TICKCNT_ENABLE_FIELD (_MK_MASK_CONST(0x1) << NV_CLASS_HOST_TICKCTRL_0_TICKCNT_ENABLE_SHIFT)
#define NV_CLASS_HOST_TICKCTRL_0_TICKCNT_ENABLE_RANGE 0:0
#define NV_CLASS_HOST_TICKCTRL_0_TICKCNT_ENABLE_WOFFSET 0x0
#define NV_CLASS_HOST_TICKCTRL_0_TICKCNT_ENABLE_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_TICKCTRL_0_TICKCNT_ENABLE_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_TICKCTRL_0_TICKCNT_ENABLE_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_TICKCTRL_0_TICKCNT_ENABLE_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_TICKCTRL_0_TICKCNT_ENABLE_DISABLE _MK_ENUM_CONST(0)
#define NV_CLASS_HOST_TICKCTRL_0_TICKCNT_ENABLE_ENABLE _MK_ENUM_CONST(1)
// Reserved address 20 [0x14]
// Reserved address 21 [0x15]
// Reserved address 22 [0x16]
// Reserved address 23 [0x17]
// Reserved address 24 [0x18]
// Reserved address 25 [0x19]
// Reserved address 26 [0x1a]
// Reserved address 27 [0x1b]
// Reserved address 28 [0x1c]
// Reserved address 29 [0x1d]
// Reserved address 30 [0x1e]
// Reserved address 31 [0x1f]
// Reserved address 32 [0x20]
// Reserved address 33 [0x21]
// Reserved address 34 [0x22]
// Reserved address 35 [0x23]
// Reserved address 36 [0x24]
// Reserved address 37 [0x25]
// Reserved address 38 [0x26]
// Reserved address 39 [0x27]
// Reserved address 40 [0x28]
// Reserved address 41 [0x29]
// Reserved address 42 [0x2a]
// Indirect addressing
// These registers (along with INDDATA) are used to indirectly read/write either
// register or memory. Host registers are not accessible using this interface.
// If AUTOINC is set, INDOFFSET increments by 4 on every access of INDDATA.
//
// Either INDCTRL/INDOFF2 or INDOFF can be used, but INDOFF may not be able to
// address all memory in chips with large memory maps. The rundundant bits in
// INDCTRL and INDOFF are shared, so writing either offset sets those bits.
//
// NOTE: due to a HW bug (bug #343175) the following restrictions apply to the
// use of indirect memory writes:
// (1) at initialization time, do a dummy indirect write (with all byte enables set to zero), and
// (2) dedicate an MLOCK for indirect memory writes, then before a channel issues
// a set of indirect memory writes it must acquire this MLOCK; after the writes
// have been issued, the MLOCK is released -- this will restrict the use of
// indirect memory writes to a single channel at a time.
// Register NV_CLASS_HOST_INDCTRL_0
#define NV_CLASS_HOST_INDCTRL_0 _MK_ADDR_CONST(0x2b)
#define NV_CLASS_HOST_INDCTRL_0_SECURE 0x0
#define NV_CLASS_HOST_INDCTRL_0_WORD_COUNT 0x1
#define NV_CLASS_HOST_INDCTRL_0_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDCTRL_0_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDCTRL_0_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDCTRL_0_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDCTRL_0_READ_MASK _MK_MASK_CONST(0xfc000003)
#define NV_CLASS_HOST_INDCTRL_0_WRITE_MASK _MK_MASK_CONST(0xfc000003)
// Byte enables. Will apply to all subsequent data transactions. Not applicable for reads.
#define NV_CLASS_HOST_INDCTRL_0_INDBE_SHIFT _MK_SHIFT_CONST(28)
#define NV_CLASS_HOST_INDCTRL_0_INDBE_FIELD (_MK_MASK_CONST(0xf) << NV_CLASS_HOST_INDCTRL_0_INDBE_SHIFT)
#define NV_CLASS_HOST_INDCTRL_0_INDBE_RANGE 31:28
#define NV_CLASS_HOST_INDCTRL_0_INDBE_WOFFSET 0x0
#define NV_CLASS_HOST_INDCTRL_0_INDBE_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDCTRL_0_INDBE_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDCTRL_0_INDBE_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDCTRL_0_INDBE_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Auto increment of read/write address
#define NV_CLASS_HOST_INDCTRL_0_AUTOINC_SHIFT _MK_SHIFT_CONST(27)
#define NV_CLASS_HOST_INDCTRL_0_AUTOINC_FIELD (_MK_MASK_CONST(0x1) << NV_CLASS_HOST_INDCTRL_0_AUTOINC_SHIFT)
#define NV_CLASS_HOST_INDCTRL_0_AUTOINC_RANGE 27:27
#define NV_CLASS_HOST_INDCTRL_0_AUTOINC_WOFFSET 0x0
#define NV_CLASS_HOST_INDCTRL_0_AUTOINC_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDCTRL_0_AUTOINC_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDCTRL_0_AUTOINC_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDCTRL_0_AUTOINC_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDCTRL_0_AUTOINC_DISABLE _MK_ENUM_CONST(0)
#define NV_CLASS_HOST_INDCTRL_0_AUTOINC_ENABLE _MK_ENUM_CONST(1)
// Route return data to spool FIFO, only applicable to reads
#define NV_CLASS_HOST_INDCTRL_0_SPOOL_SHIFT _MK_SHIFT_CONST(26)
#define NV_CLASS_HOST_INDCTRL_0_SPOOL_FIELD (_MK_MASK_CONST(0x1) << NV_CLASS_HOST_INDCTRL_0_SPOOL_SHIFT)
#define NV_CLASS_HOST_INDCTRL_0_SPOOL_RANGE 26:26
#define NV_CLASS_HOST_INDCTRL_0_SPOOL_WOFFSET 0x0
#define NV_CLASS_HOST_INDCTRL_0_SPOOL_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDCTRL_0_SPOOL_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDCTRL_0_SPOOL_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDCTRL_0_SPOOL_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDCTRL_0_SPOOL_DISABLE _MK_ENUM_CONST(0)
#define NV_CLASS_HOST_INDCTRL_0_SPOOL_ENABLE _MK_ENUM_CONST(1)
// Access type: indirect register or indirect framebuffer
#define NV_CLASS_HOST_INDCTRL_0_ACCTYPE_SHIFT _MK_SHIFT_CONST(1)
#define NV_CLASS_HOST_INDCTRL_0_ACCTYPE_FIELD (_MK_MASK_CONST(0x1) << NV_CLASS_HOST_INDCTRL_0_ACCTYPE_SHIFT)
#define NV_CLASS_HOST_INDCTRL_0_ACCTYPE_RANGE 1:1
#define NV_CLASS_HOST_INDCTRL_0_ACCTYPE_WOFFSET 0x0
#define NV_CLASS_HOST_INDCTRL_0_ACCTYPE_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDCTRL_0_ACCTYPE_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDCTRL_0_ACCTYPE_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDCTRL_0_ACCTYPE_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDCTRL_0_ACCTYPE_REG _MK_ENUM_CONST(0)
#define NV_CLASS_HOST_INDCTRL_0_ACCTYPE_FB _MK_ENUM_CONST(1)
// Read/write
#define NV_CLASS_HOST_INDCTRL_0_RWN_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INDCTRL_0_RWN_FIELD (_MK_MASK_CONST(0x1) << NV_CLASS_HOST_INDCTRL_0_RWN_SHIFT)
#define NV_CLASS_HOST_INDCTRL_0_RWN_RANGE 0:0
#define NV_CLASS_HOST_INDCTRL_0_RWN_WOFFSET 0x0
#define NV_CLASS_HOST_INDCTRL_0_RWN_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDCTRL_0_RWN_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDCTRL_0_RWN_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDCTRL_0_RWN_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDCTRL_0_RWN_WRITE _MK_ENUM_CONST(0)
#define NV_CLASS_HOST_INDCTRL_0_RWN_READ _MK_ENUM_CONST(1)
// Register NV_CLASS_HOST_INDOFF2_0
#define NV_CLASS_HOST_INDOFF2_0 _MK_ADDR_CONST(0x2c)
#define NV_CLASS_HOST_INDOFF2_0_SECURE 0x0
#define NV_CLASS_HOST_INDOFF2_0_WORD_COUNT 0x1
#define NV_CLASS_HOST_INDOFF2_0_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF2_0_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF2_0_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF2_0_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF2_0_READ_MASK _MK_MASK_CONST(0xfffffffc)
#define NV_CLASS_HOST_INDOFF2_0_WRITE_MASK _MK_MASK_CONST(0xfffffffc)
// ACCTYPE=FB: framebuffer address
#define NV_CLASS_HOST_INDOFF2_0_INDOFFSET_SHIFT _MK_SHIFT_CONST(2)
#define NV_CLASS_HOST_INDOFF2_0_INDOFFSET_FIELD (_MK_MASK_CONST(0x3fffffff) << NV_CLASS_HOST_INDOFF2_0_INDOFFSET_SHIFT)
#define NV_CLASS_HOST_INDOFF2_0_INDOFFSET_RANGE 31:2
#define NV_CLASS_HOST_INDOFF2_0_INDOFFSET_WOFFSET 0x0
#define NV_CLASS_HOST_INDOFF2_0_INDOFFSET_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF2_0_INDOFFSET_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF2_0_INDOFFSET_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF2_0_INDOFFSET_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// ACCTYPE=REG: register module ID
#define NV_CLASS_HOST_INDOFF2_0_INDMODID_SHIFT _MK_SHIFT_CONST(18)
#define NV_CLASS_HOST_INDOFF2_0_INDMODID_FIELD (_MK_MASK_CONST(0xff) << NV_CLASS_HOST_INDOFF2_0_INDMODID_SHIFT)
#define NV_CLASS_HOST_INDOFF2_0_INDMODID_RANGE 25:18
#define NV_CLASS_HOST_INDOFF2_0_INDMODID_WOFFSET 0x0
#define NV_CLASS_HOST_INDOFF2_0_INDMODID_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF2_0_INDMODID_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF2_0_INDMODID_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF2_0_INDMODID_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF2_0_INDMODID_HOST1X _MK_ENUM_CONST(0)
#define NV_CLASS_HOST_INDOFF2_0_INDMODID_MPE _MK_ENUM_CONST(1)
#define NV_CLASS_HOST_INDOFF2_0_INDMODID_VI _MK_ENUM_CONST(2)
#define NV_CLASS_HOST_INDOFF2_0_INDMODID_EPP _MK_ENUM_CONST(3)
#define NV_CLASS_HOST_INDOFF2_0_INDMODID_ISP _MK_ENUM_CONST(4)
#define NV_CLASS_HOST_INDOFF2_0_INDMODID_GR2D _MK_ENUM_CONST(5)
#define NV_CLASS_HOST_INDOFF2_0_INDMODID_GR3D _MK_ENUM_CONST(6)
#define NV_CLASS_HOST_INDOFF2_0_INDMODID_DISPLAY _MK_ENUM_CONST(8)
#define NV_CLASS_HOST_INDOFF2_0_INDMODID_TVO _MK_ENUM_CONST(11)
#define NV_CLASS_HOST_INDOFF2_0_INDMODID_DISPLAYB _MK_ENUM_CONST(9)
#define NV_CLASS_HOST_INDOFF2_0_INDMODID_DSI _MK_ENUM_CONST(12)
#define NV_CLASS_HOST_INDOFF2_0_INDMODID_HDMI _MK_ENUM_CONST(10)
// ACCTYPE=REG: register offset ([15:0])
#define NV_CLASS_HOST_INDOFF2_0_INDROFFSET_SHIFT _MK_SHIFT_CONST(2)
#define NV_CLASS_HOST_INDOFF2_0_INDROFFSET_FIELD (_MK_MASK_CONST(0xffff) << NV_CLASS_HOST_INDOFF2_0_INDROFFSET_SHIFT)
#define NV_CLASS_HOST_INDOFF2_0_INDROFFSET_RANGE 17:2
#define NV_CLASS_HOST_INDOFF2_0_INDROFFSET_WOFFSET 0x0
#define NV_CLASS_HOST_INDOFF2_0_INDROFFSET_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF2_0_INDROFFSET_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF2_0_INDROFFSET_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF2_0_INDROFFSET_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Register NV_CLASS_HOST_INDOFF_0
#define NV_CLASS_HOST_INDOFF_0 _MK_ADDR_CONST(0x2d)
#define NV_CLASS_HOST_INDOFF_0_SECURE 0x0
#define NV_CLASS_HOST_INDOFF_0_WORD_COUNT 0x1
#define NV_CLASS_HOST_INDOFF_0_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF_0_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF_0_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF_0_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF_0_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INDOFF_0_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// Byte enables. Will apply to all subsequent data transactions. Not applicable for reads.
#define NV_CLASS_HOST_INDOFF_0_INDBE_SHIFT _MK_SHIFT_CONST(28)
#define NV_CLASS_HOST_INDOFF_0_INDBE_FIELD (_MK_MASK_CONST(0xf) << NV_CLASS_HOST_INDOFF_0_INDBE_SHIFT)
#define NV_CLASS_HOST_INDOFF_0_INDBE_RANGE 31:28
#define NV_CLASS_HOST_INDOFF_0_INDBE_WOFFSET 0x0
#define NV_CLASS_HOST_INDOFF_0_INDBE_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF_0_INDBE_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF_0_INDBE_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF_0_INDBE_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Auto increment of read/write address
#define NV_CLASS_HOST_INDOFF_0_AUTOINC_SHIFT _MK_SHIFT_CONST(27)
#define NV_CLASS_HOST_INDOFF_0_AUTOINC_FIELD (_MK_MASK_CONST(0x1) << NV_CLASS_HOST_INDOFF_0_AUTOINC_SHIFT)
#define NV_CLASS_HOST_INDOFF_0_AUTOINC_RANGE 27:27
#define NV_CLASS_HOST_INDOFF_0_AUTOINC_WOFFSET 0x0
#define NV_CLASS_HOST_INDOFF_0_AUTOINC_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF_0_AUTOINC_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF_0_AUTOINC_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF_0_AUTOINC_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF_0_AUTOINC_DISABLE _MK_ENUM_CONST(0)
#define NV_CLASS_HOST_INDOFF_0_AUTOINC_ENABLE _MK_ENUM_CONST(1)
// Route return data to spool FIFO, only applicable to reads
#define NV_CLASS_HOST_INDOFF_0_SPOOL_SHIFT _MK_SHIFT_CONST(26)
#define NV_CLASS_HOST_INDOFF_0_SPOOL_FIELD (_MK_MASK_CONST(0x1) << NV_CLASS_HOST_INDOFF_0_SPOOL_SHIFT)
#define NV_CLASS_HOST_INDOFF_0_SPOOL_RANGE 26:26
#define NV_CLASS_HOST_INDOFF_0_SPOOL_WOFFSET 0x0
#define NV_CLASS_HOST_INDOFF_0_SPOOL_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF_0_SPOOL_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF_0_SPOOL_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF_0_SPOOL_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF_0_SPOOL_DISABLE _MK_ENUM_CONST(0)
#define NV_CLASS_HOST_INDOFF_0_SPOOL_ENABLE _MK_ENUM_CONST(1)
// ACCTYPE=FB: framebuffer address
#define NV_CLASS_HOST_INDOFF_0_INDOFFSET_SHIFT _MK_SHIFT_CONST(2)
#define NV_CLASS_HOST_INDOFF_0_INDOFFSET_FIELD (_MK_MASK_CONST(0xffffff) << NV_CLASS_HOST_INDOFF_0_INDOFFSET_SHIFT)
#define NV_CLASS_HOST_INDOFF_0_INDOFFSET_RANGE 25:2
#define NV_CLASS_HOST_INDOFF_0_INDOFFSET_WOFFSET 0x0
#define NV_CLASS_HOST_INDOFF_0_INDOFFSET_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF_0_INDOFFSET_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF_0_INDOFFSET_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF_0_INDOFFSET_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// ACCTYPE=REG: register module ID
#define NV_CLASS_HOST_INDOFF_0_INDMODID_SHIFT _MK_SHIFT_CONST(18)
#define NV_CLASS_HOST_INDOFF_0_INDMODID_FIELD (_MK_MASK_CONST(0xff) << NV_CLASS_HOST_INDOFF_0_INDMODID_SHIFT)
#define NV_CLASS_HOST_INDOFF_0_INDMODID_RANGE 25:18
#define NV_CLASS_HOST_INDOFF_0_INDMODID_WOFFSET 0x0
#define NV_CLASS_HOST_INDOFF_0_INDMODID_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF_0_INDMODID_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF_0_INDMODID_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF_0_INDMODID_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF_0_INDMODID_HOST1X _MK_ENUM_CONST(0)
#define NV_CLASS_HOST_INDOFF_0_INDMODID_MPE _MK_ENUM_CONST(1)
#define NV_CLASS_HOST_INDOFF_0_INDMODID_VI _MK_ENUM_CONST(2)
#define NV_CLASS_HOST_INDOFF_0_INDMODID_EPP _MK_ENUM_CONST(3)
#define NV_CLASS_HOST_INDOFF_0_INDMODID_ISP _MK_ENUM_CONST(4)
#define NV_CLASS_HOST_INDOFF_0_INDMODID_GR2D _MK_ENUM_CONST(5)
#define NV_CLASS_HOST_INDOFF_0_INDMODID_GR3D _MK_ENUM_CONST(6)
#define NV_CLASS_HOST_INDOFF_0_INDMODID_DISPLAY _MK_ENUM_CONST(8)
#define NV_CLASS_HOST_INDOFF_0_INDMODID_TVO _MK_ENUM_CONST(11)
#define NV_CLASS_HOST_INDOFF_0_INDMODID_DISPLAYB _MK_ENUM_CONST(9)
#define NV_CLASS_HOST_INDOFF_0_INDMODID_DSI _MK_ENUM_CONST(12)
#define NV_CLASS_HOST_INDOFF_0_INDMODID_HDMI _MK_ENUM_CONST(10)
// ACCTYPE=REG: register offset ([15:0])
#define NV_CLASS_HOST_INDOFF_0_INDROFFSET_SHIFT _MK_SHIFT_CONST(2)
#define NV_CLASS_HOST_INDOFF_0_INDROFFSET_FIELD (_MK_MASK_CONST(0xffff) << NV_CLASS_HOST_INDOFF_0_INDROFFSET_SHIFT)
#define NV_CLASS_HOST_INDOFF_0_INDROFFSET_RANGE 17:2
#define NV_CLASS_HOST_INDOFF_0_INDROFFSET_WOFFSET 0x0
#define NV_CLASS_HOST_INDOFF_0_INDROFFSET_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF_0_INDROFFSET_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF_0_INDROFFSET_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF_0_INDROFFSET_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Access type: indirect register or indirect framebuffer
#define NV_CLASS_HOST_INDOFF_0_ACCTYPE_SHIFT _MK_SHIFT_CONST(1)
#define NV_CLASS_HOST_INDOFF_0_ACCTYPE_FIELD (_MK_MASK_CONST(0x1) << NV_CLASS_HOST_INDOFF_0_ACCTYPE_SHIFT)
#define NV_CLASS_HOST_INDOFF_0_ACCTYPE_RANGE 1:1
#define NV_CLASS_HOST_INDOFF_0_ACCTYPE_WOFFSET 0x0
#define NV_CLASS_HOST_INDOFF_0_ACCTYPE_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF_0_ACCTYPE_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF_0_ACCTYPE_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF_0_ACCTYPE_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF_0_ACCTYPE_REG _MK_ENUM_CONST(0)
#define NV_CLASS_HOST_INDOFF_0_ACCTYPE_FB _MK_ENUM_CONST(1)
// Read/write
#define NV_CLASS_HOST_INDOFF_0_RWN_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INDOFF_0_RWN_FIELD (_MK_MASK_CONST(0x1) << NV_CLASS_HOST_INDOFF_0_RWN_SHIFT)
#define NV_CLASS_HOST_INDOFF_0_RWN_RANGE 0:0
#define NV_CLASS_HOST_INDOFF_0_RWN_WOFFSET 0x0
#define NV_CLASS_HOST_INDOFF_0_RWN_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF_0_RWN_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF_0_RWN_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF_0_RWN_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDOFF_0_RWN_WRITE _MK_ENUM_CONST(0)
#define NV_CLASS_HOST_INDOFF_0_RWN_READ _MK_ENUM_CONST(1)
// These registers, when written, either writes to the data to the INDOFFSET in
// INDOFF or triggers a read of the offset at INDOFFSET.
// Register NV_CLASS_HOST_INDDATA_0
#define NV_CLASS_HOST_INDDATA_0 _MK_ADDR_CONST(0x2e)
#define NV_CLASS_HOST_INDDATA_0_SECURE 0x0
#define NV_CLASS_HOST_INDDATA_0_WORD_COUNT 0x1
#define NV_CLASS_HOST_INDDATA_0_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_0_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_0_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_0_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_0_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INDDATA_0_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// read or write data
#define NV_CLASS_HOST_INDDATA_0_INDDATA_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INDDATA_0_INDDATA_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_INDDATA_0_INDDATA_SHIFT)
#define NV_CLASS_HOST_INDDATA_0_INDDATA_RANGE 31:0
#define NV_CLASS_HOST_INDDATA_0_INDDATA_WOFFSET 0x0
#define NV_CLASS_HOST_INDDATA_0_INDDATA_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_0_INDDATA_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_0_INDDATA_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_0_INDDATA_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Register NV_CLASS_HOST_INDDATA
#define NV_CLASS_HOST_INDDATA _MK_ADDR_CONST(0x2e)
#define NV_CLASS_HOST_INDDATA_SECURE 0x0
#define NV_CLASS_HOST_INDDATA_WORD_COUNT 0x1
#define NV_CLASS_HOST_INDDATA_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INDDATA_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// read or write data
#define NV_CLASS_HOST_INDDATA_INDDATA_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INDDATA_INDDATA_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_INDDATA_INDDATA_SHIFT)
#define NV_CLASS_HOST_INDDATA_INDDATA_RANGE 31:0
#define NV_CLASS_HOST_INDDATA_INDDATA_WOFFSET 0x0
#define NV_CLASS_HOST_INDDATA_INDDATA_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_INDDATA_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_INDDATA_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_INDDATA_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Register NV_CLASS_HOST_INDDATA_1
#define NV_CLASS_HOST_INDDATA_1 _MK_ADDR_CONST(0x2f)
#define NV_CLASS_HOST_INDDATA_1_SECURE 0x0
#define NV_CLASS_HOST_INDDATA_1_WORD_COUNT 0x1
#define NV_CLASS_HOST_INDDATA_1_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_1_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_1_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_1_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_1_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INDDATA_1_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// read or write data
#define NV_CLASS_HOST_INDDATA_1_INDDATA_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INDDATA_1_INDDATA_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_INDDATA_1_INDDATA_SHIFT)
#define NV_CLASS_HOST_INDDATA_1_INDDATA_RANGE 31:0
#define NV_CLASS_HOST_INDDATA_1_INDDATA_WOFFSET 0x0
#define NV_CLASS_HOST_INDDATA_1_INDDATA_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_1_INDDATA_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_1_INDDATA_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_1_INDDATA_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Register NV_CLASS_HOST_INDDATA_2
#define NV_CLASS_HOST_INDDATA_2 _MK_ADDR_CONST(0x30)
#define NV_CLASS_HOST_INDDATA_2_SECURE 0x0
#define NV_CLASS_HOST_INDDATA_2_WORD_COUNT 0x1
#define NV_CLASS_HOST_INDDATA_2_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_2_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_2_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_2_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_2_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INDDATA_2_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// read or write data
#define NV_CLASS_HOST_INDDATA_2_INDDATA_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INDDATA_2_INDDATA_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_INDDATA_2_INDDATA_SHIFT)
#define NV_CLASS_HOST_INDDATA_2_INDDATA_RANGE 31:0
#define NV_CLASS_HOST_INDDATA_2_INDDATA_WOFFSET 0x0
#define NV_CLASS_HOST_INDDATA_2_INDDATA_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_2_INDDATA_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_2_INDDATA_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_2_INDDATA_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Register NV_CLASS_HOST_INDDATA_3
#define NV_CLASS_HOST_INDDATA_3 _MK_ADDR_CONST(0x31)
#define NV_CLASS_HOST_INDDATA_3_SECURE 0x0
#define NV_CLASS_HOST_INDDATA_3_WORD_COUNT 0x1
#define NV_CLASS_HOST_INDDATA_3_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_3_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_3_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_3_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_3_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INDDATA_3_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// read or write data
#define NV_CLASS_HOST_INDDATA_3_INDDATA_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INDDATA_3_INDDATA_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_INDDATA_3_INDDATA_SHIFT)
#define NV_CLASS_HOST_INDDATA_3_INDDATA_RANGE 31:0
#define NV_CLASS_HOST_INDDATA_3_INDDATA_WOFFSET 0x0
#define NV_CLASS_HOST_INDDATA_3_INDDATA_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_3_INDDATA_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_3_INDDATA_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_3_INDDATA_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Register NV_CLASS_HOST_INDDATA_4
#define NV_CLASS_HOST_INDDATA_4 _MK_ADDR_CONST(0x32)
#define NV_CLASS_HOST_INDDATA_4_SECURE 0x0
#define NV_CLASS_HOST_INDDATA_4_WORD_COUNT 0x1
#define NV_CLASS_HOST_INDDATA_4_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_4_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_4_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_4_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_4_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INDDATA_4_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// read or write data
#define NV_CLASS_HOST_INDDATA_4_INDDATA_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INDDATA_4_INDDATA_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_INDDATA_4_INDDATA_SHIFT)
#define NV_CLASS_HOST_INDDATA_4_INDDATA_RANGE 31:0
#define NV_CLASS_HOST_INDDATA_4_INDDATA_WOFFSET 0x0
#define NV_CLASS_HOST_INDDATA_4_INDDATA_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_4_INDDATA_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_4_INDDATA_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_4_INDDATA_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Register NV_CLASS_HOST_INDDATA_5
#define NV_CLASS_HOST_INDDATA_5 _MK_ADDR_CONST(0x33)
#define NV_CLASS_HOST_INDDATA_5_SECURE 0x0
#define NV_CLASS_HOST_INDDATA_5_WORD_COUNT 0x1
#define NV_CLASS_HOST_INDDATA_5_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_5_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_5_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_5_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_5_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INDDATA_5_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// read or write data
#define NV_CLASS_HOST_INDDATA_5_INDDATA_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INDDATA_5_INDDATA_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_INDDATA_5_INDDATA_SHIFT)
#define NV_CLASS_HOST_INDDATA_5_INDDATA_RANGE 31:0
#define NV_CLASS_HOST_INDDATA_5_INDDATA_WOFFSET 0x0
#define NV_CLASS_HOST_INDDATA_5_INDDATA_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_5_INDDATA_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_5_INDDATA_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_5_INDDATA_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Register NV_CLASS_HOST_INDDATA_6
#define NV_CLASS_HOST_INDDATA_6 _MK_ADDR_CONST(0x34)
#define NV_CLASS_HOST_INDDATA_6_SECURE 0x0
#define NV_CLASS_HOST_INDDATA_6_WORD_COUNT 0x1
#define NV_CLASS_HOST_INDDATA_6_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_6_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_6_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_6_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_6_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INDDATA_6_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// read or write data
#define NV_CLASS_HOST_INDDATA_6_INDDATA_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INDDATA_6_INDDATA_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_INDDATA_6_INDDATA_SHIFT)
#define NV_CLASS_HOST_INDDATA_6_INDDATA_RANGE 31:0
#define NV_CLASS_HOST_INDDATA_6_INDDATA_WOFFSET 0x0
#define NV_CLASS_HOST_INDDATA_6_INDDATA_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_6_INDDATA_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_6_INDDATA_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_6_INDDATA_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Register NV_CLASS_HOST_INDDATA_7
#define NV_CLASS_HOST_INDDATA_7 _MK_ADDR_CONST(0x35)
#define NV_CLASS_HOST_INDDATA_7_SECURE 0x0
#define NV_CLASS_HOST_INDDATA_7_WORD_COUNT 0x1
#define NV_CLASS_HOST_INDDATA_7_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_7_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_7_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_7_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_7_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INDDATA_7_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// read or write data
#define NV_CLASS_HOST_INDDATA_7_INDDATA_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INDDATA_7_INDDATA_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_INDDATA_7_INDDATA_SHIFT)
#define NV_CLASS_HOST_INDDATA_7_INDDATA_RANGE 31:0
#define NV_CLASS_HOST_INDDATA_7_INDDATA_WOFFSET 0x0
#define NV_CLASS_HOST_INDDATA_7_INDDATA_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_7_INDDATA_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_7_INDDATA_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_7_INDDATA_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Register NV_CLASS_HOST_INDDATA_8
#define NV_CLASS_HOST_INDDATA_8 _MK_ADDR_CONST(0x36)
#define NV_CLASS_HOST_INDDATA_8_SECURE 0x0
#define NV_CLASS_HOST_INDDATA_8_WORD_COUNT 0x1
#define NV_CLASS_HOST_INDDATA_8_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_8_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_8_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_8_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_8_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INDDATA_8_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// read or write data
#define NV_CLASS_HOST_INDDATA_8_INDDATA_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INDDATA_8_INDDATA_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_INDDATA_8_INDDATA_SHIFT)
#define NV_CLASS_HOST_INDDATA_8_INDDATA_RANGE 31:0
#define NV_CLASS_HOST_INDDATA_8_INDDATA_WOFFSET 0x0
#define NV_CLASS_HOST_INDDATA_8_INDDATA_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_8_INDDATA_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_8_INDDATA_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_8_INDDATA_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Register NV_CLASS_HOST_INDDATA_9
#define NV_CLASS_HOST_INDDATA_9 _MK_ADDR_CONST(0x37)
#define NV_CLASS_HOST_INDDATA_9_SECURE 0x0
#define NV_CLASS_HOST_INDDATA_9_WORD_COUNT 0x1
#define NV_CLASS_HOST_INDDATA_9_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_9_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_9_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_9_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_9_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INDDATA_9_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// read or write data
#define NV_CLASS_HOST_INDDATA_9_INDDATA_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INDDATA_9_INDDATA_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_INDDATA_9_INDDATA_SHIFT)
#define NV_CLASS_HOST_INDDATA_9_INDDATA_RANGE 31:0
#define NV_CLASS_HOST_INDDATA_9_INDDATA_WOFFSET 0x0
#define NV_CLASS_HOST_INDDATA_9_INDDATA_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_9_INDDATA_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_9_INDDATA_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_9_INDDATA_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Register NV_CLASS_HOST_INDDATA_10
#define NV_CLASS_HOST_INDDATA_10 _MK_ADDR_CONST(0x38)
#define NV_CLASS_HOST_INDDATA_10_SECURE 0x0
#define NV_CLASS_HOST_INDDATA_10_WORD_COUNT 0x1
#define NV_CLASS_HOST_INDDATA_10_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_10_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_10_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_10_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_10_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INDDATA_10_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// read or write data
#define NV_CLASS_HOST_INDDATA_10_INDDATA_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INDDATA_10_INDDATA_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_INDDATA_10_INDDATA_SHIFT)
#define NV_CLASS_HOST_INDDATA_10_INDDATA_RANGE 31:0
#define NV_CLASS_HOST_INDDATA_10_INDDATA_WOFFSET 0x0
#define NV_CLASS_HOST_INDDATA_10_INDDATA_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_10_INDDATA_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_10_INDDATA_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_10_INDDATA_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Register NV_CLASS_HOST_INDDATA_11
#define NV_CLASS_HOST_INDDATA_11 _MK_ADDR_CONST(0x39)
#define NV_CLASS_HOST_INDDATA_11_SECURE 0x0
#define NV_CLASS_HOST_INDDATA_11_WORD_COUNT 0x1
#define NV_CLASS_HOST_INDDATA_11_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_11_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_11_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_11_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_11_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INDDATA_11_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// read or write data
#define NV_CLASS_HOST_INDDATA_11_INDDATA_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INDDATA_11_INDDATA_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_INDDATA_11_INDDATA_SHIFT)
#define NV_CLASS_HOST_INDDATA_11_INDDATA_RANGE 31:0
#define NV_CLASS_HOST_INDDATA_11_INDDATA_WOFFSET 0x0
#define NV_CLASS_HOST_INDDATA_11_INDDATA_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_11_INDDATA_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_11_INDDATA_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_11_INDDATA_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Register NV_CLASS_HOST_INDDATA_12
#define NV_CLASS_HOST_INDDATA_12 _MK_ADDR_CONST(0x3a)
#define NV_CLASS_HOST_INDDATA_12_SECURE 0x0
#define NV_CLASS_HOST_INDDATA_12_WORD_COUNT 0x1
#define NV_CLASS_HOST_INDDATA_12_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_12_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_12_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_12_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_12_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INDDATA_12_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// read or write data
#define NV_CLASS_HOST_INDDATA_12_INDDATA_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INDDATA_12_INDDATA_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_INDDATA_12_INDDATA_SHIFT)
#define NV_CLASS_HOST_INDDATA_12_INDDATA_RANGE 31:0
#define NV_CLASS_HOST_INDDATA_12_INDDATA_WOFFSET 0x0
#define NV_CLASS_HOST_INDDATA_12_INDDATA_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_12_INDDATA_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_12_INDDATA_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_12_INDDATA_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Register NV_CLASS_HOST_INDDATA_13
#define NV_CLASS_HOST_INDDATA_13 _MK_ADDR_CONST(0x3b)
#define NV_CLASS_HOST_INDDATA_13_SECURE 0x0
#define NV_CLASS_HOST_INDDATA_13_WORD_COUNT 0x1
#define NV_CLASS_HOST_INDDATA_13_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_13_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_13_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_13_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_13_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INDDATA_13_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// read or write data
#define NV_CLASS_HOST_INDDATA_13_INDDATA_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INDDATA_13_INDDATA_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_INDDATA_13_INDDATA_SHIFT)
#define NV_CLASS_HOST_INDDATA_13_INDDATA_RANGE 31:0
#define NV_CLASS_HOST_INDDATA_13_INDDATA_WOFFSET 0x0
#define NV_CLASS_HOST_INDDATA_13_INDDATA_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_13_INDDATA_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_13_INDDATA_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_13_INDDATA_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Register NV_CLASS_HOST_INDDATA_14
#define NV_CLASS_HOST_INDDATA_14 _MK_ADDR_CONST(0x3c)
#define NV_CLASS_HOST_INDDATA_14_SECURE 0x0
#define NV_CLASS_HOST_INDDATA_14_WORD_COUNT 0x1
#define NV_CLASS_HOST_INDDATA_14_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_14_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_14_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_14_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_14_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INDDATA_14_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// read or write data
#define NV_CLASS_HOST_INDDATA_14_INDDATA_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INDDATA_14_INDDATA_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_INDDATA_14_INDDATA_SHIFT)
#define NV_CLASS_HOST_INDDATA_14_INDDATA_RANGE 31:0
#define NV_CLASS_HOST_INDDATA_14_INDDATA_WOFFSET 0x0
#define NV_CLASS_HOST_INDDATA_14_INDDATA_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_14_INDDATA_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_14_INDDATA_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_14_INDDATA_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Register NV_CLASS_HOST_INDDATA_15
#define NV_CLASS_HOST_INDDATA_15 _MK_ADDR_CONST(0x3d)
#define NV_CLASS_HOST_INDDATA_15_SECURE 0x0
#define NV_CLASS_HOST_INDDATA_15_WORD_COUNT 0x1
#define NV_CLASS_HOST_INDDATA_15_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_15_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_15_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_15_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_15_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INDDATA_15_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// read or write data
#define NV_CLASS_HOST_INDDATA_15_INDDATA_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INDDATA_15_INDDATA_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_INDDATA_15_INDDATA_SHIFT)
#define NV_CLASS_HOST_INDDATA_15_INDDATA_RANGE 31:0
#define NV_CLASS_HOST_INDDATA_15_INDDATA_WOFFSET 0x0
#define NV_CLASS_HOST_INDDATA_15_INDDATA_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_15_INDDATA_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_15_INDDATA_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_15_INDDATA_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Register NV_CLASS_HOST_INDDATA_16
#define NV_CLASS_HOST_INDDATA_16 _MK_ADDR_CONST(0x3e)
#define NV_CLASS_HOST_INDDATA_16_SECURE 0x0
#define NV_CLASS_HOST_INDDATA_16_WORD_COUNT 0x1
#define NV_CLASS_HOST_INDDATA_16_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_16_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_16_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_16_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_16_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INDDATA_16_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// read or write data
#define NV_CLASS_HOST_INDDATA_16_INDDATA_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INDDATA_16_INDDATA_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_INDDATA_16_INDDATA_SHIFT)
#define NV_CLASS_HOST_INDDATA_16_INDDATA_RANGE 31:0
#define NV_CLASS_HOST_INDDATA_16_INDDATA_WOFFSET 0x0
#define NV_CLASS_HOST_INDDATA_16_INDDATA_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_16_INDDATA_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_16_INDDATA_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_16_INDDATA_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Register NV_CLASS_HOST_INDDATA_17
#define NV_CLASS_HOST_INDDATA_17 _MK_ADDR_CONST(0x3f)
#define NV_CLASS_HOST_INDDATA_17_SECURE 0x0
#define NV_CLASS_HOST_INDDATA_17_WORD_COUNT 0x1
#define NV_CLASS_HOST_INDDATA_17_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_17_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_17_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_17_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_17_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INDDATA_17_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// read or write data
#define NV_CLASS_HOST_INDDATA_17_INDDATA_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INDDATA_17_INDDATA_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_INDDATA_17_INDDATA_SHIFT)
#define NV_CLASS_HOST_INDDATA_17_INDDATA_RANGE 31:0
#define NV_CLASS_HOST_INDDATA_17_INDDATA_WOFFSET 0x0
#define NV_CLASS_HOST_INDDATA_17_INDDATA_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_17_INDDATA_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_17_INDDATA_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_17_INDDATA_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Register NV_CLASS_HOST_INDDATA_18
#define NV_CLASS_HOST_INDDATA_18 _MK_ADDR_CONST(0x40)
#define NV_CLASS_HOST_INDDATA_18_SECURE 0x0
#define NV_CLASS_HOST_INDDATA_18_WORD_COUNT 0x1
#define NV_CLASS_HOST_INDDATA_18_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_18_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_18_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_18_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_18_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INDDATA_18_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// read or write data
#define NV_CLASS_HOST_INDDATA_18_INDDATA_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INDDATA_18_INDDATA_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_INDDATA_18_INDDATA_SHIFT)
#define NV_CLASS_HOST_INDDATA_18_INDDATA_RANGE 31:0
#define NV_CLASS_HOST_INDDATA_18_INDDATA_WOFFSET 0x0
#define NV_CLASS_HOST_INDDATA_18_INDDATA_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_18_INDDATA_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_18_INDDATA_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_18_INDDATA_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Register NV_CLASS_HOST_INDDATA_19
#define NV_CLASS_HOST_INDDATA_19 _MK_ADDR_CONST(0x41)
#define NV_CLASS_HOST_INDDATA_19_SECURE 0x0
#define NV_CLASS_HOST_INDDATA_19_WORD_COUNT 0x1
#define NV_CLASS_HOST_INDDATA_19_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_19_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_19_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_19_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_19_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INDDATA_19_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// read or write data
#define NV_CLASS_HOST_INDDATA_19_INDDATA_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INDDATA_19_INDDATA_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_INDDATA_19_INDDATA_SHIFT)
#define NV_CLASS_HOST_INDDATA_19_INDDATA_RANGE 31:0
#define NV_CLASS_HOST_INDDATA_19_INDDATA_WOFFSET 0x0
#define NV_CLASS_HOST_INDDATA_19_INDDATA_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_19_INDDATA_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_19_INDDATA_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_19_INDDATA_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Register NV_CLASS_HOST_INDDATA_20
#define NV_CLASS_HOST_INDDATA_20 _MK_ADDR_CONST(0x42)
#define NV_CLASS_HOST_INDDATA_20_SECURE 0x0
#define NV_CLASS_HOST_INDDATA_20_WORD_COUNT 0x1
#define NV_CLASS_HOST_INDDATA_20_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_20_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_20_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_20_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_20_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INDDATA_20_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// read or write data
#define NV_CLASS_HOST_INDDATA_20_INDDATA_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INDDATA_20_INDDATA_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_INDDATA_20_INDDATA_SHIFT)
#define NV_CLASS_HOST_INDDATA_20_INDDATA_RANGE 31:0
#define NV_CLASS_HOST_INDDATA_20_INDDATA_WOFFSET 0x0
#define NV_CLASS_HOST_INDDATA_20_INDDATA_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_20_INDDATA_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_20_INDDATA_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_20_INDDATA_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Register NV_CLASS_HOST_INDDATA_21
#define NV_CLASS_HOST_INDDATA_21 _MK_ADDR_CONST(0x43)
#define NV_CLASS_HOST_INDDATA_21_SECURE 0x0
#define NV_CLASS_HOST_INDDATA_21_WORD_COUNT 0x1
#define NV_CLASS_HOST_INDDATA_21_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_21_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_21_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_21_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_21_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INDDATA_21_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// read or write data
#define NV_CLASS_HOST_INDDATA_21_INDDATA_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INDDATA_21_INDDATA_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_INDDATA_21_INDDATA_SHIFT)
#define NV_CLASS_HOST_INDDATA_21_INDDATA_RANGE 31:0
#define NV_CLASS_HOST_INDDATA_21_INDDATA_WOFFSET 0x0
#define NV_CLASS_HOST_INDDATA_21_INDDATA_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_21_INDDATA_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_21_INDDATA_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_21_INDDATA_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Register NV_CLASS_HOST_INDDATA_22
#define NV_CLASS_HOST_INDDATA_22 _MK_ADDR_CONST(0x44)
#define NV_CLASS_HOST_INDDATA_22_SECURE 0x0
#define NV_CLASS_HOST_INDDATA_22_WORD_COUNT 0x1
#define NV_CLASS_HOST_INDDATA_22_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_22_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_22_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_22_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_22_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INDDATA_22_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// read or write data
#define NV_CLASS_HOST_INDDATA_22_INDDATA_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INDDATA_22_INDDATA_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_INDDATA_22_INDDATA_SHIFT)
#define NV_CLASS_HOST_INDDATA_22_INDDATA_RANGE 31:0
#define NV_CLASS_HOST_INDDATA_22_INDDATA_WOFFSET 0x0
#define NV_CLASS_HOST_INDDATA_22_INDDATA_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_22_INDDATA_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_22_INDDATA_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_22_INDDATA_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Register NV_CLASS_HOST_INDDATA_23
#define NV_CLASS_HOST_INDDATA_23 _MK_ADDR_CONST(0x45)
#define NV_CLASS_HOST_INDDATA_23_SECURE 0x0
#define NV_CLASS_HOST_INDDATA_23_WORD_COUNT 0x1
#define NV_CLASS_HOST_INDDATA_23_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_23_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_23_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_23_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_23_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INDDATA_23_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// read or write data
#define NV_CLASS_HOST_INDDATA_23_INDDATA_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INDDATA_23_INDDATA_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_INDDATA_23_INDDATA_SHIFT)
#define NV_CLASS_HOST_INDDATA_23_INDDATA_RANGE 31:0
#define NV_CLASS_HOST_INDDATA_23_INDDATA_WOFFSET 0x0
#define NV_CLASS_HOST_INDDATA_23_INDDATA_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_23_INDDATA_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_23_INDDATA_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_23_INDDATA_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Register NV_CLASS_HOST_INDDATA_24
#define NV_CLASS_HOST_INDDATA_24 _MK_ADDR_CONST(0x46)
#define NV_CLASS_HOST_INDDATA_24_SECURE 0x0
#define NV_CLASS_HOST_INDDATA_24_WORD_COUNT 0x1
#define NV_CLASS_HOST_INDDATA_24_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_24_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_24_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_24_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_24_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INDDATA_24_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// read or write data
#define NV_CLASS_HOST_INDDATA_24_INDDATA_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INDDATA_24_INDDATA_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_INDDATA_24_INDDATA_SHIFT)
#define NV_CLASS_HOST_INDDATA_24_INDDATA_RANGE 31:0
#define NV_CLASS_HOST_INDDATA_24_INDDATA_WOFFSET 0x0
#define NV_CLASS_HOST_INDDATA_24_INDDATA_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_24_INDDATA_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_24_INDDATA_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_24_INDDATA_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Register NV_CLASS_HOST_INDDATA_25
#define NV_CLASS_HOST_INDDATA_25 _MK_ADDR_CONST(0x47)
#define NV_CLASS_HOST_INDDATA_25_SECURE 0x0
#define NV_CLASS_HOST_INDDATA_25_WORD_COUNT 0x1
#define NV_CLASS_HOST_INDDATA_25_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_25_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_25_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_25_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_25_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INDDATA_25_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// read or write data
#define NV_CLASS_HOST_INDDATA_25_INDDATA_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INDDATA_25_INDDATA_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_INDDATA_25_INDDATA_SHIFT)
#define NV_CLASS_HOST_INDDATA_25_INDDATA_RANGE 31:0
#define NV_CLASS_HOST_INDDATA_25_INDDATA_WOFFSET 0x0
#define NV_CLASS_HOST_INDDATA_25_INDDATA_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_25_INDDATA_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_25_INDDATA_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_25_INDDATA_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Register NV_CLASS_HOST_INDDATA_26
#define NV_CLASS_HOST_INDDATA_26 _MK_ADDR_CONST(0x48)
#define NV_CLASS_HOST_INDDATA_26_SECURE 0x0
#define NV_CLASS_HOST_INDDATA_26_WORD_COUNT 0x1
#define NV_CLASS_HOST_INDDATA_26_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_26_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_26_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_26_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_26_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INDDATA_26_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// read or write data
#define NV_CLASS_HOST_INDDATA_26_INDDATA_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INDDATA_26_INDDATA_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_INDDATA_26_INDDATA_SHIFT)
#define NV_CLASS_HOST_INDDATA_26_INDDATA_RANGE 31:0
#define NV_CLASS_HOST_INDDATA_26_INDDATA_WOFFSET 0x0
#define NV_CLASS_HOST_INDDATA_26_INDDATA_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_26_INDDATA_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_26_INDDATA_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_26_INDDATA_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Register NV_CLASS_HOST_INDDATA_27
#define NV_CLASS_HOST_INDDATA_27 _MK_ADDR_CONST(0x49)
#define NV_CLASS_HOST_INDDATA_27_SECURE 0x0
#define NV_CLASS_HOST_INDDATA_27_WORD_COUNT 0x1
#define NV_CLASS_HOST_INDDATA_27_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_27_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_27_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_27_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_27_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INDDATA_27_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// read or write data
#define NV_CLASS_HOST_INDDATA_27_INDDATA_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INDDATA_27_INDDATA_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_INDDATA_27_INDDATA_SHIFT)
#define NV_CLASS_HOST_INDDATA_27_INDDATA_RANGE 31:0
#define NV_CLASS_HOST_INDDATA_27_INDDATA_WOFFSET 0x0
#define NV_CLASS_HOST_INDDATA_27_INDDATA_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_27_INDDATA_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_27_INDDATA_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_27_INDDATA_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Register NV_CLASS_HOST_INDDATA_28
#define NV_CLASS_HOST_INDDATA_28 _MK_ADDR_CONST(0x4a)
#define NV_CLASS_HOST_INDDATA_28_SECURE 0x0
#define NV_CLASS_HOST_INDDATA_28_WORD_COUNT 0x1
#define NV_CLASS_HOST_INDDATA_28_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_28_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_28_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_28_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_28_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INDDATA_28_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// read or write data
#define NV_CLASS_HOST_INDDATA_28_INDDATA_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INDDATA_28_INDDATA_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_INDDATA_28_INDDATA_SHIFT)
#define NV_CLASS_HOST_INDDATA_28_INDDATA_RANGE 31:0
#define NV_CLASS_HOST_INDDATA_28_INDDATA_WOFFSET 0x0
#define NV_CLASS_HOST_INDDATA_28_INDDATA_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_28_INDDATA_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_28_INDDATA_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_28_INDDATA_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Register NV_CLASS_HOST_INDDATA_29
#define NV_CLASS_HOST_INDDATA_29 _MK_ADDR_CONST(0x4b)
#define NV_CLASS_HOST_INDDATA_29_SECURE 0x0
#define NV_CLASS_HOST_INDDATA_29_WORD_COUNT 0x1
#define NV_CLASS_HOST_INDDATA_29_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_29_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_29_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_29_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_29_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INDDATA_29_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// read or write data
#define NV_CLASS_HOST_INDDATA_29_INDDATA_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INDDATA_29_INDDATA_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_INDDATA_29_INDDATA_SHIFT)
#define NV_CLASS_HOST_INDDATA_29_INDDATA_RANGE 31:0
#define NV_CLASS_HOST_INDDATA_29_INDDATA_WOFFSET 0x0
#define NV_CLASS_HOST_INDDATA_29_INDDATA_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_29_INDDATA_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_29_INDDATA_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_29_INDDATA_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Register NV_CLASS_HOST_INDDATA_30
#define NV_CLASS_HOST_INDDATA_30 _MK_ADDR_CONST(0x4c)
#define NV_CLASS_HOST_INDDATA_30_SECURE 0x0
#define NV_CLASS_HOST_INDDATA_30_WORD_COUNT 0x1
#define NV_CLASS_HOST_INDDATA_30_RESET_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_30_RESET_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_30_SW_DEFAULT_VAL _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_30_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_30_READ_MASK _MK_MASK_CONST(0xffffffff)
#define NV_CLASS_HOST_INDDATA_30_WRITE_MASK _MK_MASK_CONST(0xffffffff)
// read or write data
#define NV_CLASS_HOST_INDDATA_30_INDDATA_SHIFT _MK_SHIFT_CONST(0)
#define NV_CLASS_HOST_INDDATA_30_INDDATA_FIELD (_MK_MASK_CONST(0xffffffff) << NV_CLASS_HOST_INDDATA_30_INDDATA_SHIFT)
#define NV_CLASS_HOST_INDDATA_30_INDDATA_RANGE 31:0
#define NV_CLASS_HOST_INDDATA_30_INDDATA_WOFFSET 0x0
#define NV_CLASS_HOST_INDDATA_30_INDDATA_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_30_INDDATA_DEFAULT_MASK _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_30_INDDATA_SW_DEFAULT _MK_MASK_CONST(0x0)
#define NV_CLASS_HOST_INDDATA_30_INDDATA_SW_DEFAULT_MASK _MK_MASK_CONST(0x0)
// Reserved address 77 [0x4d]
//
// REGISTER LIST
//
#define LIST_ARHOST1X_UCLASS_REGS(_op_) \
_op_(NV_CLASS_HOST_INCR_SYNCPT_0) \
_op_(NV_CLASS_HOST_INCR_SYNCPT_CNTRL_0) \
_op_(NV_CLASS_HOST_INCR_SYNCPT_ERROR_0) \
_op_(NV_CLASS_HOST_WAIT_SYNCPT_0) \
_op_(NV_CLASS_HOST_WAIT_SYNCPT_BASE_0) \
_op_(NV_CLASS_HOST_WAIT_SYNCPT_INCR_0) \
_op_(NV_CLASS_HOST_LOAD_SYNCPT_BASE_0) \
_op_(NV_CLASS_HOST_INCR_SYNCPT_BASE_0) \
_op_(NV_CLASS_HOST_CLEAR_0) \
_op_(NV_CLASS_HOST_WAIT_0) \
_op_(NV_CLASS_HOST_WAIT_WITH_INTR_0) \
_op_(NV_CLASS_HOST_DELAY_USEC_0) \
_op_(NV_CLASS_HOST_TICKCOUNT_HI_0) \
_op_(NV_CLASS_HOST_TICKCOUNT_LO_0) \
_op_(NV_CLASS_HOST_TICKCTRL_0) \
_op_(NV_CLASS_HOST_INDCTRL_0) \
_op_(NV_CLASS_HOST_INDOFF2_0) \
_op_(NV_CLASS_HOST_INDOFF_0) \
_op_(NV_CLASS_HOST_INDDATA_0) \
_op_(NV_CLASS_HOST_INDDATA) \
_op_(NV_CLASS_HOST_INDDATA_1) \
_op_(NV_CLASS_HOST_INDDATA_2) \
_op_(NV_CLASS_HOST_INDDATA_3) \
_op_(NV_CLASS_HOST_INDDATA_4) \
_op_(NV_CLASS_HOST_INDDATA_5) \
_op_(NV_CLASS_HOST_INDDATA_6) \
_op_(NV_CLASS_HOST_INDDATA_7) \
_op_(NV_CLASS_HOST_INDDATA_8) \
_op_(NV_CLASS_HOST_INDDATA_9) \
_op_(NV_CLASS_HOST_INDDATA_10) \
_op_(NV_CLASS_HOST_INDDATA_11) \
_op_(NV_CLASS_HOST_INDDATA_12) \
_op_(NV_CLASS_HOST_INDDATA_13) \
_op_(NV_CLASS_HOST_INDDATA_14) \
_op_(NV_CLASS_HOST_INDDATA_15) \
_op_(NV_CLASS_HOST_INDDATA_16) \
_op_(NV_CLASS_HOST_INDDATA_17) \
_op_(NV_CLASS_HOST_INDDATA_18) \
_op_(NV_CLASS_HOST_INDDATA_19) \
_op_(NV_CLASS_HOST_INDDATA_20) \
_op_(NV_CLASS_HOST_INDDATA_21) \
_op_(NV_CLASS_HOST_INDDATA_22) \
_op_(NV_CLASS_HOST_INDDATA_23) \
_op_(NV_CLASS_HOST_INDDATA_24) \
_op_(NV_CLASS_HOST_INDDATA_25) \
_op_(NV_CLASS_HOST_INDDATA_26) \
_op_(NV_CLASS_HOST_INDDATA_27) \
_op_(NV_CLASS_HOST_INDDATA_28) \
_op_(NV_CLASS_HOST_INDDATA_29) \
_op_(NV_CLASS_HOST_INDDATA_30)
//
// ADDRESS SPACES
//
#define BASE_ADDRESS_NV_CLASS_HOST 0x00000000
//
// ARHOST1X_UCLASS REGISTER BANKS
//
#define NV_CLASS_HOST0_FIRST_REG 0x0000 // NV_CLASS_HOST_INCR_SYNCPT_0
#define NV_CLASS_HOST0_LAST_REG 0x0002 // NV_CLASS_HOST_INCR_SYNCPT_ERROR_0
#define NV_CLASS_HOST1_FIRST_REG 0x0008 // NV_CLASS_HOST_WAIT_SYNCPT_0
#define NV_CLASS_HOST1_LAST_REG 0x0013 // NV_CLASS_HOST_TICKCTRL_0
#define NV_CLASS_HOST2_FIRST_REG 0x002b // NV_CLASS_HOST_INDCTRL_0
#define NV_CLASS_HOST2_LAST_REG 0x004c // NV_CLASS_HOST_INDDATA_30
#ifndef _MK_SHIFT_CONST
#define _MK_SHIFT_CONST(_constant_) _constant_
#endif
#ifndef _MK_MASK_CONST
#define _MK_MASK_CONST(_constant_) _constant_
#endif
#ifndef _MK_ENUM_CONST
#define _MK_ENUM_CONST(_constant_) (_constant_ ## UL)
#endif
#ifndef _MK_ADDR_CONST
#define _MK_ADDR_CONST(_constant_) _constant_
#endif
#endif // ifndef ___ARHOST1X_UCLASS_H_INC_
| DmitryADP/diff_qc750 | vendor/nvidia/tegra/core/drivers/hwinc/ap20/arhost1x_uclass.h | C | gpl-2.0 | 109,070 |
<?php
namespace Drupal\dct_user\EventSubscriber;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\KernelEvents;
/**
* Class NotAuthenticatedEventSubscriber.
*
* @package Drupal\dct_user\EventSubscriber
*/
class NotAuthenticatedEventSubscriber implements EventSubscriberInterface {
/**
* The current user.
*
* @var \Drupal\Core\Session\AccountInterface
*/
protected $currentUser;
/**
* The current request.
*
* @var \Symfony\Component\HttpFoundation\Request
*/
protected $request;
/**
* The current route match.
*
* @var \Drupal\Core\Routing\RouteMatchInterface
*/
protected $routeMatch;
/**
* The routes this subscriber should act on.
*/
const ROUTES = [
'dct_commerce.ticket_redemption_code',
'entity.commerce_product.canonical',
];
/**
* Constructs a new event subscriber.
*
* @param \Drupal\Core\Session\AccountInterface $current_user
* The current user.
* @param \Symfony\Component\HttpFoundation\RequestStack $requestStack
* The current request stack.
* @param \Drupal\Core\Routing\RouteMatchInterface $routeMatch
* The current routeMatch.
*/
public function __construct(AccountInterface $current_user, RequestStack $requestStack, RouteMatchInterface $routeMatch) {
$this->request = $requestStack->getCurrentRequest();
$this->currentUser = $current_user;
$this->routeMatch = $routeMatch;
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[KernelEvents::EXCEPTION][] = ['onKernelException'];
return $events;
}
/**
* Redirects on 403 Access Denied kernel exceptions.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
* The Event to process.
*/
public function onKernelException(GetResponseEvent $event) {
$exception = $event->getException();
if ($exception instanceof AccessDeniedHttpException && $this->currentUser->isAnonymous() && in_array($this->routeMatch->getRouteName(), static::ROUTES)) {
$destination = [];
if (!empty($this->request->getRequestUri())) {
$destination = ['destination' => $this->request->getRequestUri()];
}
$url = Url::fromRoute('dct_user.error_page', $destination);
$response = new RedirectResponse($url->toString(TRUE)->getGeneratedUrl());
$event->setResponse($response);
}
}
}
| drupaltransylvania/drupal-camp | docroot/modules/custom/dct_user/src/EventSubscriber/NotAuthenticatedEventSubscriber.php | PHP | gpl-2.0 | 2,780 |
using System;
using Server.Engines.Craft;
namespace Server.Items
{
[Alterable(typeof(DefBlacksmithy), typeof(DualShortAxes))]
[FlipableAttribute(0x1443, 0x1442)]
public class TwoHandedAxe : BaseAxe
{
[Constructable]
public TwoHandedAxe()
: base(0x1443)
{
this.Weight = 8.0;
}
public TwoHandedAxe(Serial serial)
: base(serial)
{
}
public override WeaponAbility PrimaryAbility
{
get
{
return WeaponAbility.DoubleStrike;
}
}
public override WeaponAbility SecondaryAbility
{
get
{
return WeaponAbility.ShadowStrike;
}
}
public override int AosStrengthReq
{
get
{
return 40;
}
}
public override int AosMinDamage
{
get
{
return 16;
}
}
public override int AosMaxDamage
{
get
{
return 19;
}
}
public override int AosSpeed
{
get
{
return 31;
}
}
public override float MlSpeed
{
get
{
return 3.50f;
}
}
public override int InitMinHits
{
get
{
return 31;
}
}
public override int InitMaxHits
{
get
{
return 90;
}
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
}
| kevin-10/ServUO | Scripts/Items/Equipment/Weapons/TwoHandedAxe.cs | C# | gpl-2.0 | 2,045 |
class ChangeRoleForUsers < ActiveRecord::Migration
def change
remove_column :users, :role, :string
add_column :users, :role, :string, :default=>'user'
end
end
| cronon/fanfiction | db/migrate/20130831030543_change_role_for_users.rb | Ruby | gpl-2.0 | 169 |
#include <string.h>
#include <stdlib.h>
#include "libterm.h"
#include "cursor.h"
#include "screen.h"
#include "bitarr.h"
int cursor_visibility(int tid, int sid, char visibility) {
if(SCR(tid, sid).curs_invisible != !visibility) {
SCR(tid, sid).curs_invisible = !visibility;
if(!record_update(tid, sid, visibility ? UPD_CURS : UPD_CURS_INVIS)) {
if(ltm_curerr.err_no == ESRCH) return 0;
else return -1;
}
}
return 0;
}
int cursor_abs_move(int tid, int sid, enum axis axis, ushort num) {
int ret = 0;
uint old;
SCR(tid, sid).curs_prev_not_set = 0;
switch(axis) {
case X:
old = SCR(tid, sid).cursor.x;
if(num < SCR(tid, sid).cols)
SCR(tid, sid).cursor.x = num;
else
SCR(tid, sid).cursor.x = SCR(tid, sid).cols-1;
if(old == SCR(tid, sid).cursor.x)
return 0;
break;
case Y:
old = SCR(tid, sid).cursor.y;
if(num < SCR(tid, sid).lines)
SCR(tid, sid).cursor.y = num;
else
SCR(tid, sid).cursor.y = SCR(tid, sid).lines-1;
if(old == SCR(tid, sid).cursor.y)
return 0;
break;
default:
LTM_ERR(EINVAL, "Invalid axis", error);
}
if(!record_update(tid, sid, UPD_CURS)) {
if(ltm_curerr.err_no == ESRCH) return 0;
else return -1;
}
error:
return ret;
}
int cursor_rel_move(int tid, int sid, enum direction direction, ushort num) {
int ret = 0;
if(!num) return 0;
switch(direction) {
case UP:
return cursor_abs_move(tid, sid, Y, num <= SCR(tid, sid).cursor.y ? SCR(tid, sid).cursor.y - num : 0);
case DOWN:
return cursor_abs_move(tid, sid, Y, SCR(tid, sid).cursor.y + num);
case LEFT:
return cursor_abs_move(tid, sid, X, num <= SCR(tid, sid).cursor.x ? SCR(tid, sid).cursor.x - num : 0);
case RIGHT:
return cursor_abs_move(tid, sid, X, SCR(tid, sid).cursor.x + num);
default:
LTM_ERR(EINVAL, "Invalid direction", error);
}
error:
return ret;
}
int cursor_horiz_tab(int tid, int sid) {
/* don't hardcode 8 here in the future? */
char dist = 8 - (SCR(tid, sid).cursor.x % 8);
return cursor_rel_move(tid, sid, RIGHT, dist);
}
int cursor_down(int tid, int sid) {
if(SCR(tid, sid).cursor.y == SCR(tid, sid).lines-1 && SCR(tid, sid).autoscroll)
return screen_scroll(tid, sid);
else
return cursor_rel_move(tid, sid, DOWN, 1);
}
int cursor_vertical_tab(int tid, int sid) {
if(cursor_down(tid, sid) == -1) return -1;
bitarr_unset_index(SCR(tid, sid).wrapped, SCR(tid, sid).cursor.y);
return 0;
}
int cursor_line_break(int tid, int sid) {
if(cursor_vertical_tab(tid, sid) == -1) return -1;
if(cursor_abs_move(tid, sid, X, 0) == -1) return -1;
return 0;
}
int cursor_wrap(int tid, int sid) {
if(cursor_down(tid, sid) == -1) return -1;
bitarr_set_index(SCR(tid, sid).wrapped, SCR(tid, sid).cursor.y);
if(cursor_abs_move(tid, sid, X, 0) == -1) return -1;
return 0;
}
int cursor_advance(int tid, int sid) {
if(SCR(tid, sid).cursor.x == SCR(tid, sid).cols-1) {
if(!SCR(tid, sid).curs_prev_not_set) {
SCR(tid, sid).curs_prev_not_set = 1;
return 0;
}
return cursor_wrap(tid, sid);
} else
return cursor_rel_move(tid, sid, RIGHT, 1);
}
| atrigent/libterm | src/cursor.c | C | gpl-2.0 | 3,083 |
# Find the native LLVM includes and libraries
#
# Defines the following variables
# LLVM_INCLUDE_DIR - where to find llvm include files
# LLVM_LIBRARY_DIR - where to find llvm libs
# LLVM_CFLAGS - llvm compiler flags
# LLVM_LFLAGS - llvm linker flags
# LLVM_MODULE_LIBS - list of llvm libs for working with modules.
# LLVM_FOUND - True if llvm found.
# LLVM_VERSION - Version string ("llvm-config --version")
#
# This module reads hints about search locations from variables
# LLVM_ROOT - Preferred LLVM installation prefix (containing bin/, lib/, ...)
#
# Note: One may specify these as environment variables if they are not specified as
# CMake variables or cache entries.
#=============================================================================
# Copyright 2014 Kevin Funk <[email protected]>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
if (NOT LLVM_ROOT AND DEFINED ENV{LLVM_ROOT})
file(TO_CMAKE_PATH "$ENV{LLVM_ROOT}" LLVM_ROOT)
endif()
# if the user specified LLVM_ROOT, use that and fail otherwise
if (LLVM_ROOT)
find_program(LLVM_CONFIG_EXECUTABLE NAMES llvm-config HINTS ${LLVM_ROOT}/bin DOC "llvm-config executable" NO_DEFAULT_PATH)
else()
# find llvm-config, prefer the one with a version suffix, e.g. llvm-config-3.3
# note: on some distributions, only 'llvm-config' is shipped, so let's always try to fallback on that
find_program(LLVM_CONFIG_EXECUTABLE NAMES llvm-config-${LLVM_FIND_VERSION} llvm-config DOC "llvm-config executable")
# other distributions don't ship llvm-config, but only some llvm-config-VERSION binary
# try to deduce installed LLVM version by looking up llvm-nm in PATH and *then* find llvm-config-VERSION via that
if (NOT LLVM_CONFIG_EXECUTABLE)
find_program(_llvmNmExecutable llvm-nm)
if (_llvmNmExecutable)
execute_process(COMMAND ${_llvmNmExecutable} --version OUTPUT_VARIABLE _out)
string(REGEX REPLACE ".*LLVM version ([^ \n]+).*" "\\1" _versionString "${_out}")
find_program(LLVM_CONFIG_EXECUTABLE NAMES llvm-config-${_versionString} DOC "llvm-config executable")
endif()
endif()
endif()
set(LLVM_FOUND FALSE)
if (LLVM_CONFIG_EXECUTABLE)
# verify that we've found the correct version of llvm-config
execute_process(COMMAND ${LLVM_CONFIG_EXECUTABLE} --version
OUTPUT_VARIABLE LLVM_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (NOT LLVM_VERSION)
set(_LLVM_ERROR_MESSAGE "Failed to parse version from llvm-config")
elseif (LLVM_FIND_VERSION VERSION_GREATER LLVM_VERSION)
set(_LLVM_ERROR_MESSAGE "LLVM version too old: ${LLVM_VERSION}")
else()
message(STATUS "Found LLVM (version: ${LLVM_VERSION}): (using ${LLVM_CONFIG_EXECUTABLE})")
set(LLVM_FOUND TRUE)
endif()
else()
set(_LLVM_ERROR_MESSAGE "Could NOT find 'llvm-config' executable")
endif()
if (LLVM_FOUND)
execute_process(
COMMAND ${LLVM_CONFIG_EXECUTABLE} --includedir
OUTPUT_VARIABLE LLVM_INCLUDE_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND ${LLVM_CONFIG_EXECUTABLE} --libdir
OUTPUT_VARIABLE LLVM_LIBRARY_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND ${LLVM_CONFIG_EXECUTABLE} --cppflags
OUTPUT_VARIABLE LLVM_CFLAGS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND ${LLVM_CONFIG_EXECUTABLE} --ldflags
OUTPUT_VARIABLE LLVM_LFLAGS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND ${LLVM_CONFIG_EXECUTABLE} --libs core bitreader asmparser analysis
OUTPUT_VARIABLE LLVM_MODULE_LIBS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
if (LLVM_FIND_REQUIRED AND NOT LLVM_FOUND)
message(FATAL_ERROR "Could not find LLVM: ${_LLVM_ERROR_MESSAGE}")
elseif(_LLVM_ERROR_MESSAGE)
message(STATUS "Could not find LLVM: ${_LLVM_ERROR_MESSAGE}")
endif()
| nicolas17/my-clang-tools | cmake/FindLLVM.cmake | CMake | gpl-2.0 | 4,150 |
<?php
/*
Template Name: Full Width
*/
?>
<?php get_header(); ?>
<div class="row">
<div class="sixteen columns">
<div class="single-page" role="main">
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<article <?php post_class(); ?>>
<?php /*if(!is_front_page()) { WE DONT WANT THIS ?>
<h1 id="post-<?php the_ID(); ?>" class="article-title">
<?php the_title(); ?>
</h1>
<?php } */?>
<section class="post-content">
<?php the_content(); ?>
</section><!-- .post-content -->
</article>
<?php endwhile; ?>
<?php comments_template(); ?>
<?php else : ?>
<h2 class="center"><?php esc_attr_e('Nothing is Here - Page Not Found', ''); ?></h2>
<div class="entry-content">
<p><?php esc_attr_e( 'Sorry, but we couldn\'t find what you we\'re looking for.', '' ); ?></p>
</div><!-- .entry-content -->
<?php endif; ?>
</div><!--End Single Article-->
</div>
</div>
<?php get_footer(); ?>
| RPI-Sage-Hillel/Website | wp-content/themes/bartleby-child/fullwidth-page.php | PHP | gpl-2.0 | 916 |
/*
* INET An implementation of the TCP/IP protocol suite for the LINUX
* operating system. INET is implemented using the BSD Socket
* interface as the means of communication with the user level.
*
* Implementation of the Transmission Control Protocol(TCP).
*
* Authors: Ross Biro
* Fred N. van Kempen, <[email protected]>
* Mark Evans, <[email protected]>
* Corey Minyard <[email protected]>
* Florian La Roche, <[email protected]>
* Charles Hedrick, <[email protected]>
* Linus Torvalds, <[email protected]>
* Alan Cox, <[email protected]>
* Matthew Dillon, <[email protected]>
* Arnt Gulbrandsen, <[email protected]>
* Jorge Cwik, <[email protected]>
*/
/*
* Changes: Pedro Roque : Retransmit queue handled by TCP.
* : Fragmentation on mtu decrease
* : Segment collapse on retransmit
* : AF independence
*
* Linus Torvalds : send_delayed_ack
* David S. Miller : Charge memory using the right skb
* during syn/ack processing.
* David S. Miller : Output engine completely rewritten.
* Andrea Arcangeli: SYNACK carry ts_recent in tsecr.
* Cacophonix Gaul : draft-minshall-nagle-01
* J Hadi Salim : ECN support
*
*/
#define pr_fmt(fmt) "TCP: " fmt
#include <net/mptcp.h>
#include <net/ipv6.h>
#include <net/tcp.h>
#include <linux/compiler.h>
#include <linux/gfp.h>
#include <linux/module.h>
/* People can turn this off for buggy TCP's found in printers etc. */
int sysctl_tcp_retrans_collapse __read_mostly = 1;
/* People can turn this on to work with those rare, broken TCPs that
* interpret the window field as a signed quantity.
*/
int sysctl_tcp_workaround_signed_windows __read_mostly = 0;
/* Default TSQ limit of two TSO segments */
int sysctl_tcp_limit_output_bytes __read_mostly = 131072;
/* This limits the percentage of the congestion window which we
* will allow a single TSO frame to consume. Building TSO frames
* which are too large can cause TCP streams to be bursty.
*/
int sysctl_tcp_tso_win_divisor __read_mostly = 3;
int sysctl_tcp_mtu_probing __read_mostly = 0;
int sysctl_tcp_base_mss __read_mostly = TCP_BASE_MSS;
int cnt = 0;
/* By default, RFC2861 behavior. */
int sysctl_tcp_slow_start_after_idle __read_mostly = 1;
static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle,
int push_one, gfp_t gfp);
/* Account for new data that has been sent to the network. */
void tcp_event_new_data_sent(struct sock *sk, const struct sk_buff *skb)
{
struct inet_connection_sock *icsk = inet_csk(sk);
struct tcp_sock *tp = tcp_sk(sk);
unsigned int prior_packets = tp->packets_out;
tcp_advance_send_head(sk, skb);
tp->snd_nxt = TCP_SKB_CB(skb)->end_seq;
tp->packets_out += tcp_skb_pcount(skb);
if (!prior_packets || icsk->icsk_pending == ICSK_TIME_EARLY_RETRANS ||
icsk->icsk_pending == ICSK_TIME_LOSS_PROBE) {
tcp_rearm_rto(sk);
}
}
/* SND.NXT, if window was not shrunk.
* If window has been shrunk, what should we make? It is not clear at all.
* Using SND.UNA we will fail to open window, SND.NXT is out of window. :-(
* Anything in between SND.UNA...SND.UNA+SND.WND also can be already
* invalid. OK, let's make this for now:
*/
static inline __u32 tcp_acceptable_seq(const struct sock *sk)
{
const struct tcp_sock *tp = tcp_sk(sk);
if (!before(tcp_wnd_end(tp), tp->snd_nxt))
return tp->snd_nxt;
else
return tcp_wnd_end(tp);
}
/* Calculate mss to advertise in SYN segment.
* RFC1122, RFC1063, draft-ietf-tcpimpl-pmtud-01 state that:
*
* 1. It is independent of path mtu.
* 2. Ideally, it is maximal possible segment size i.e. 65535-40.
* 3. For IPv4 it is reasonable to calculate it from maximal MTU of
* attached devices, because some buggy hosts are confused by
* large MSS.
* 4. We do not make 3, we advertise MSS, calculated from first
* hop device mtu, but allow to raise it to ip_rt_min_advmss.
* This may be overridden via information stored in routing table.
* 5. Value 65535 for MSS is valid in IPv6 and means "as large as possible,
* probably even Jumbo".
*/
static __u16 tcp_advertise_mss(struct sock *sk)
{
struct tcp_sock *tp = tcp_sk(sk);
const struct dst_entry *dst = __sk_dst_get(sk);
int mss = tp->advmss;
if (dst) {
unsigned int metric = dst_metric_advmss(dst);
if (metric < mss) {
mss = metric;
tp->advmss = mss;
}
}
return (__u16)mss;
}
/* RFC2861. Reset CWND after idle period longer RTO to "restart window".
* This is the first part of cwnd validation mechanism. */
static void tcp_cwnd_restart(struct sock *sk, const struct dst_entry *dst)
{
struct tcp_sock *tp = tcp_sk(sk);
s32 delta = tcp_time_stamp - tp->lsndtime;
u32 restart_cwnd = tcp_init_cwnd(tp, dst);
u32 cwnd = tp->snd_cwnd;
tcp_ca_event(sk, CA_EVENT_CWND_RESTART);
tp->snd_ssthresh = tcp_current_ssthresh(sk);
restart_cwnd = min(restart_cwnd, cwnd);
while ((delta -= inet_csk(sk)->icsk_rto) > 0 && cwnd > restart_cwnd)
cwnd >>= 1;
tp->snd_cwnd = max(cwnd, restart_cwnd);
tp->snd_cwnd_stamp = tcp_time_stamp;
tp->snd_cwnd_used = 0;
}
/* Congestion state accounting after a packet has been sent. */
static void tcp_event_data_sent(struct tcp_sock *tp,
struct sock *sk)
{
struct inet_connection_sock *icsk = inet_csk(sk);
const u32 now = tcp_time_stamp;
const struct dst_entry *dst = __sk_dst_get(sk);
if (sysctl_tcp_slow_start_after_idle &&
(!tp->packets_out && (s32)(now - tp->lsndtime) > icsk->icsk_rto))
tcp_cwnd_restart(sk, __sk_dst_get(sk));
tp->lsndtime = now;
/* If it is a reply for ato after last received
* packet, enter pingpong mode.
*/
if ((u32)(now - icsk->icsk_ack.lrcvtime) < icsk->icsk_ack.ato &&
(!dst || !dst_metric(dst, RTAX_QUICKACK)))
icsk->icsk_ack.pingpong = 1;
}
/* Account for an ACK we sent. */
static inline void tcp_event_ack_sent(struct sock *sk, unsigned int pkts)
{
tcp_dec_quickack_mode(sk, pkts);
inet_csk_clear_xmit_timer(sk, ICSK_TIME_DACK);
}
u32 tcp_default_init_rwnd(u32 mss)
{
/* Initial receive window should be twice of TCP_INIT_CWND to
* enable proper sending of new unsent data during fast recovery
* (RFC 3517, Section 4, NextSeg() rule (2)). Further place a
* limit when mss is larger than 1460.
*/
u32 init_rwnd = TCP_INIT_CWND * 2;
if (mss > 1460)
init_rwnd = max((1460 * init_rwnd) / mss, 2U);
return init_rwnd;
}
/* Determine a window scaling and initial window to offer.
* Based on the assumption that the given amount of space
* will be offered. Store the results in the tp structure.
* NOTE: for smooth operation initial space offering should
* be a multiple of mss if possible. We assume here that mss >= 1.
* This MUST be enforced by all callers.
*/
void tcp_select_initial_window(int __space, __u32 mss,
__u32 *rcv_wnd, __u32 *window_clamp,
int wscale_ok, __u8 *rcv_wscale,
__u32 init_rcv_wnd, const struct sock *sk)
{
unsigned int space;
if (tcp_sk(sk)->mpc)
mptcp_select_initial_window(&__space, window_clamp, sk);
space = (__space < 0 ? 0 : __space);
/* If no clamp set the clamp to the max possible scaled window */
if (*window_clamp == 0)
(*window_clamp) = (65535 << 14);
space = min(*window_clamp, space);
/* Quantize space offering to a multiple of mss if possible. */
if (space > mss)
space = (space / mss) * mss;
/* NOTE: offering an initial window larger than 32767
* will break some buggy TCP stacks. If the admin tells us
* it is likely we could be speaking with such a buggy stack
* we will truncate our initial window offering to 32K-1
* unless the remote has sent us a window scaling option,
* which we interpret as a sign the remote TCP is not
* misinterpreting the window field as a signed quantity.
*/
if (sysctl_tcp_workaround_signed_windows)
(*rcv_wnd) = min(space, MAX_TCP_WINDOW);
else
(*rcv_wnd) = space;
(*rcv_wscale) = 0;
if (wscale_ok) {
/* Set window scaling on max possible window
* See RFC1323 for an explanation of the limit to 14
*/
space = max_t(u32, sysctl_tcp_rmem[2], sysctl_rmem_max);
space = min_t(u32, space, *window_clamp);
while (space > 65535 && (*rcv_wscale) < 14) {
space >>= 1;
(*rcv_wscale)++;
}
}
if (mss > (1 << *rcv_wscale)) {
if (!init_rcv_wnd) /* Use default unless specified otherwise */
init_rcv_wnd = tcp_default_init_rwnd(mss);
*rcv_wnd = min(*rcv_wnd, init_rcv_wnd * mss);
}
/* Set the clamp no higher than max representable value */
(*window_clamp) = min(65535U << (*rcv_wscale), *window_clamp);
}
EXPORT_SYMBOL(tcp_select_initial_window);
/* Chose a new window to advertise, update state in tcp_sock for the
* socket, and return result with RFC1323 scaling applied. The return
* value can be stuffed directly into th->window for an outgoing
* frame.
*/
static u16 tcp_select_window(struct sock *sk)
{
struct tcp_sock *tp = tcp_sk(sk);
/* The window must never shrink at the meta-level. At the subflow we
* have to allow this. Otherwise we may announce a window too large
* for the current meta-level sk_rcvbuf.
*/
u32 cur_win = tcp_receive_window(tp->mpc ? tcp_sk(mptcp_meta_sk(sk)) : tp);
u32 new_win = __tcp_select_window(sk);
/* Never shrink the offered window */
if (new_win < cur_win) {
/* Danger Will Robinson!
* Don't update rcv_wup/rcv_wnd here or else
* we will not be able to advertise a zero
* window in time. --DaveM
*
* Relax Will Robinson.
*/
new_win = ALIGN(cur_win, 1 << tp->rx_opt.rcv_wscale);
}
if (tp->mpc) {
mptcp_meta_tp(tp)->rcv_wnd = new_win;
mptcp_meta_tp(tp)->rcv_wup = mptcp_meta_tp(tp)->rcv_nxt;
}
tp->rcv_wnd = new_win;
tp->rcv_wup = tp->rcv_nxt;
/* Make sure we do not exceed the maximum possible
* scaled window.
*/
if (!tp->rx_opt.rcv_wscale && sysctl_tcp_workaround_signed_windows)
new_win = min(new_win, MAX_TCP_WINDOW);
else
new_win = min(new_win, (65535U << tp->rx_opt.rcv_wscale));
/* RFC1323 scaling applied */
new_win >>= tp->rx_opt.rcv_wscale;
/* If we advertise zero window, disable fast path. */
if (new_win == 0)
tp->pred_flags = 0;
return new_win;
}
/* Packet ECN state for a SYN-ACK */
static inline void TCP_ECN_send_synack(const struct tcp_sock *tp, struct sk_buff *skb)
{
TCP_SKB_CB(skb)->tcp_flags &= ~TCPHDR_CWR;
if (!(tp->ecn_flags & TCP_ECN_OK))
TCP_SKB_CB(skb)->tcp_flags &= ~TCPHDR_ECE;
}
/* Packet ECN state for a SYN. */
static inline void TCP_ECN_send_syn(struct sock *sk, struct sk_buff *skb)
{
struct tcp_sock *tp = tcp_sk(sk);
tp->ecn_flags = 0;
if (sock_net(sk)->ipv4.sysctl_tcp_ecn == 1) {
TCP_SKB_CB(skb)->tcp_flags |= TCPHDR_ECE | TCPHDR_CWR;
tp->ecn_flags = TCP_ECN_OK;
}
}
static __inline__ void
TCP_ECN_make_synack(const struct request_sock *req, struct tcphdr *th)
{
if (inet_rsk(req)->ecn_ok)
th->ece = 1;
}
/* Set up ECN state for a packet on a ESTABLISHED socket that is about to
* be sent.
*/
static inline void TCP_ECN_send(struct sock *sk, struct sk_buff *skb,
int tcp_header_len)
{
struct tcp_sock *tp = tcp_sk(sk);
if (tp->ecn_flags & TCP_ECN_OK) {
/* Not-retransmitted data segment: set ECT and inject CWR. */
if (skb->len != tcp_header_len &&
!before(TCP_SKB_CB(skb)->seq, tp->snd_nxt)) {
INET_ECN_xmit(sk);
if (tp->ecn_flags & TCP_ECN_QUEUE_CWR) {
tp->ecn_flags &= ~TCP_ECN_QUEUE_CWR;
tcp_hdr(skb)->cwr = 1;
skb_shinfo(skb)->gso_type |= SKB_GSO_TCP_ECN;
}
} else {
/* ACK or retransmitted segment: clear ECT|CE */
INET_ECN_dontxmit(sk);
}
if (tp->ecn_flags & TCP_ECN_DEMAND_CWR)
tcp_hdr(skb)->ece = 1;
}
}
/* Constructs common control bits of non-data skb. If SYN/FIN is present,
* auto increment end seqno.
*/
void tcp_init_nondata_skb(struct sk_buff *skb, u32 seq, u8 flags)
{
skb->ip_summed = CHECKSUM_PARTIAL;
skb->csum = 0;
TCP_SKB_CB(skb)->tcp_flags = flags;
TCP_SKB_CB(skb)->sacked = 0;
skb_shinfo(skb)->gso_segs = 1;
skb_shinfo(skb)->gso_size = 0;
skb_shinfo(skb)->gso_type = 0;
TCP_SKB_CB(skb)->seq = seq;
if (flags & (TCPHDR_SYN | TCPHDR_FIN))
seq++;
TCP_SKB_CB(skb)->end_seq = seq;
}
bool tcp_urg_mode(const struct tcp_sock *tp)
{
return tp->snd_una != tp->snd_up;
}
#define OPTION_SACK_ADVERTISE (1 << 0)
#define OPTION_TS (1 << 1)
#define OPTION_MD5 (1 << 2)
#define OPTION_WSCALE (1 << 3)
#define OPTION_FAST_OPEN_COOKIE (1 << 8)
/* Before adding here - take a look at OPTION_MPTCP in include/net/mptcp.h */
/* Write previously computed TCP options to the packet.
*
* Beware: Something in the Internet is very sensitive to the ordering of
* TCP options, we learned this through the hard way, so be careful here.
* Luckily we can at least blame others for their non-compliance but from
* inter-operatibility perspective it seems that we're somewhat stuck with
* the ordering which we have been using if we want to keep working with
* those broken things (not that it currently hurts anybody as there isn't
* particular reason why the ordering would need to be changed).
*
* At least SACK_PERM as the first option is known to lead to a disaster
* (but it may well be that other scenarios fail similarly).
*/
static void tcp_options_write(__be32 *ptr, struct tcp_sock *tp,
struct tcp_out_options *opts, struct sk_buff *skb)
{
u16 options = opts->options; /* mungable copy */
if (unlikely(OPTION_MD5 & options)) {
*ptr++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) |
(TCPOPT_MD5SIG << 8) | TCPOLEN_MD5SIG);
/* overload cookie hash location */
opts->hash_location = (__u8 *)ptr;
ptr += 4;
}
if (unlikely(opts->mss)) {
*ptr++ = htonl((TCPOPT_MSS << 24) |
(TCPOLEN_MSS << 16) |
opts->mss);
}
if (likely(OPTION_TS & options)) {
if (unlikely(OPTION_SACK_ADVERTISE & options)) {
*ptr++ = htonl((TCPOPT_SACK_PERM << 24) |
(TCPOLEN_SACK_PERM << 16) |
(TCPOPT_TIMESTAMP << 8) |
TCPOLEN_TIMESTAMP);
options &= ~OPTION_SACK_ADVERTISE;
} else {
*ptr++ = htonl((TCPOPT_NOP << 24) |
(TCPOPT_NOP << 16) |
(TCPOPT_TIMESTAMP << 8) |
TCPOLEN_TIMESTAMP);
}
*ptr++ = htonl(opts->tsval);
*ptr++ = htonl(opts->tsecr);
}
if (unlikely(OPTION_SACK_ADVERTISE & options)) {
*ptr++ = htonl((TCPOPT_NOP << 24) |
(TCPOPT_NOP << 16) |
(TCPOPT_SACK_PERM << 8) |
TCPOLEN_SACK_PERM);
}
if (unlikely(OPTION_WSCALE & options)) {
*ptr++ = htonl((TCPOPT_NOP << 24) |
(TCPOPT_WINDOW << 16) |
(TCPOLEN_WINDOW << 8) |
opts->ws);
}
if (unlikely(opts->num_sack_blocks)) {
struct tcp_sack_block *sp = tp->rx_opt.dsack ?
tp->duplicate_sack : tp->selective_acks;
int this_sack;
*ptr++ = htonl((TCPOPT_NOP << 24) |
(TCPOPT_NOP << 16) |
(TCPOPT_SACK << 8) |
(TCPOLEN_SACK_BASE + (opts->num_sack_blocks *
TCPOLEN_SACK_PERBLOCK)));
for (this_sack = 0; this_sack < opts->num_sack_blocks;
++this_sack) {
*ptr++ = htonl(sp[this_sack].start_seq);
*ptr++ = htonl(sp[this_sack].end_seq);
}
tp->rx_opt.dsack = 0;
}
if (unlikely(OPTION_FAST_OPEN_COOKIE & options)) {
struct tcp_fastopen_cookie *foc = opts->fastopen_cookie;
*ptr++ = htonl((TCPOPT_EXP << 24) |
((TCPOLEN_EXP_FASTOPEN_BASE + foc->len) << 16) |
TCPOPT_FASTOPEN_MAGIC);
memcpy(ptr, foc->val, foc->len);
if ((foc->len & 3) == 2) {
u8 *align = ((u8 *)ptr) + foc->len;
align[0] = align[1] = TCPOPT_NOP;
}
ptr += (foc->len + 3) >> 2;
}
if (unlikely(OPTION_MPTCP & opts->options))
mptcp_options_write(ptr, tp, opts, skb);
}
/* Compute TCP options for SYN packets. This is not the final
* network wire format yet.
*/
static unsigned int tcp_syn_options(struct sock *sk, struct sk_buff *skb,
struct tcp_out_options *opts,
struct tcp_md5sig_key **md5)
{
struct tcp_sock *tp = tcp_sk(sk);
unsigned int remaining = MAX_TCP_OPTION_SPACE;
struct tcp_fastopen_request *fastopen = tp->fastopen_req;
#ifdef CONFIG_TCP_MD5SIG
*md5 = tp->af_specific->md5_lookup(sk, sk);
if (*md5) {
opts->options |= OPTION_MD5;
remaining -= TCPOLEN_MD5SIG_ALIGNED;
}
#else
*md5 = NULL;
#endif
/* We always get an MSS option. The option bytes which will be seen in
* normal data packets should timestamps be used, must be in the MSS
* advertised. But we subtract them from tp->mss_cache so that
* calculations in tcp_sendmsg are simpler etc. So account for this
* fact here if necessary. If we don't do this correctly, as a
* receiver we won't recognize data packets as being full sized when we
* should, and thus we won't abide by the delayed ACK rules correctly.
* SACKs don't matter, we never delay an ACK when we have any of those
* going out. */
opts->mss = tcp_advertise_mss(sk);
remaining -= TCPOLEN_MSS_ALIGNED;
if (likely(sysctl_tcp_timestamps && *md5 == NULL)) {
opts->options |= OPTION_TS;
opts->tsval = TCP_SKB_CB(skb)->when + tp->tsoffset;
opts->tsecr = tp->rx_opt.ts_recent;
remaining -= TCPOLEN_TSTAMP_ALIGNED;
}
if (likely(sysctl_tcp_window_scaling)) {
opts->ws = tp->rx_opt.rcv_wscale;
opts->options |= OPTION_WSCALE;
remaining -= TCPOLEN_WSCALE_ALIGNED;
}
if (likely(sysctl_tcp_sack)) {
opts->options |= OPTION_SACK_ADVERTISE;
if (unlikely(!(OPTION_TS & opts->options)))
remaining -= TCPOLEN_SACKPERM_ALIGNED;
}
if (tp->request_mptcp || tp->mpc)
mptcp_syn_options(sk, opts, &remaining);
if (fastopen && fastopen->cookie.len >= 0) {
u32 need = TCPOLEN_EXP_FASTOPEN_BASE + fastopen->cookie.len;
need = (need + 3) & ~3U; /* Align to 32 bits */
if (remaining >= need) {
opts->options |= OPTION_FAST_OPEN_COOKIE;
opts->fastopen_cookie = &fastopen->cookie;
remaining -= need;
tp->syn_fastopen = 1;
}
}
return MAX_TCP_OPTION_SPACE - remaining;
}
/* Set up TCP options for SYN-ACKs. */
static unsigned int tcp_synack_options(struct sock *sk,
struct request_sock *req,
unsigned int mss, struct sk_buff *skb,
struct tcp_out_options *opts,
struct tcp_md5sig_key **md5,
struct tcp_fastopen_cookie *foc)
{
struct inet_request_sock *ireq = inet_rsk(req);
unsigned int remaining = MAX_TCP_OPTION_SPACE;
#ifdef CONFIG_TCP_MD5SIG
*md5 = tcp_rsk(req)->af_specific->md5_lookup(sk, req);
if (*md5) {
opts->options |= OPTION_MD5;
remaining -= TCPOLEN_MD5SIG_ALIGNED;
/* We can't fit any SACK blocks in a packet with MD5 + TS
* options. There was discussion about disabling SACK
* rather than TS in order to fit in better with old,
* buggy kernels, but that was deemed to be unnecessary.
*/
ireq->tstamp_ok &= !ireq->sack_ok;
}
#else
*md5 = NULL;
#endif
/* We always send an MSS option. */
opts->mss = mss;
remaining -= TCPOLEN_MSS_ALIGNED;
if (likely(ireq->wscale_ok)) {
opts->ws = ireq->rcv_wscale;
opts->options |= OPTION_WSCALE;
remaining -= TCPOLEN_WSCALE_ALIGNED;
}
if (likely(ireq->tstamp_ok)) {
opts->options |= OPTION_TS;
opts->tsval = TCP_SKB_CB(skb)->when;
opts->tsecr = req->ts_recent;
remaining -= TCPOLEN_TSTAMP_ALIGNED;
}
if (likely(ireq->sack_ok)) {
opts->options |= OPTION_SACK_ADVERTISE;
if (unlikely(!ireq->tstamp_ok))
remaining -= TCPOLEN_SACKPERM_ALIGNED;
}
if (foc != NULL) {
u32 need = TCPOLEN_EXP_FASTOPEN_BASE + foc->len;
need = (need + 3) & ~3U; /* Align to 32 bits */
if (remaining >= need) {
opts->options |= OPTION_FAST_OPEN_COOKIE;
opts->fastopen_cookie = foc;
remaining -= need;
}
}
if (tcp_rsk(req)->saw_mpc)
mptcp_synack_options(req, opts, &remaining);
return MAX_TCP_OPTION_SPACE - remaining;
}
/* Compute TCP options for ESTABLISHED sockets. This is not the
* final wire format yet.
*/
static unsigned int tcp_established_options(struct sock *sk, struct sk_buff *skb,
struct tcp_out_options *opts,
struct tcp_md5sig_key **md5)
{
struct tcp_skb_cb *tcb = skb ? TCP_SKB_CB(skb) : NULL;
struct tcp_sock *tp = tcp_sk(sk);
unsigned int size = 0;
unsigned int eff_sacks;
#ifdef CONFIG_TCP_MD5SIG
*md5 = tp->af_specific->md5_lookup(sk, sk);
if (unlikely(*md5)) {
opts->options |= OPTION_MD5;
size += TCPOLEN_MD5SIG_ALIGNED;
}
#else
*md5 = NULL;
#endif
if (likely(tp->rx_opt.tstamp_ok)) {
opts->options |= OPTION_TS;
opts->tsval = tcb ? tcb->when + tp->tsoffset : 0;
opts->tsecr = tp->rx_opt.ts_recent;
size += TCPOLEN_TSTAMP_ALIGNED;
}
if (tp->mpc)
mptcp_established_options(sk, skb, opts, &size);
eff_sacks = tp->rx_opt.num_sacks + tp->rx_opt.dsack;
if (unlikely(eff_sacks)) {
const unsigned remaining = MAX_TCP_OPTION_SPACE - size;
if (remaining < TCPOLEN_SACK_BASE_ALIGNED)
opts->num_sack_blocks = 0;
else
opts->num_sack_blocks =
min_t(unsigned int, eff_sacks,
(remaining - TCPOLEN_SACK_BASE_ALIGNED) /
TCPOLEN_SACK_PERBLOCK);
if (opts->num_sack_blocks)
size += TCPOLEN_SACK_BASE_ALIGNED +
opts->num_sack_blocks * TCPOLEN_SACK_PERBLOCK;
}
return size;
}
/* TCP SMALL QUEUES (TSQ)
*
* TSQ goal is to keep small amount of skbs per tcp flow in tx queues (qdisc+dev)
* to reduce RTT and bufferbloat.
* We do this using a special skb destructor (tcp_wfree).
*
* Its important tcp_wfree() can be replaced by sock_wfree() in the event skb
* needs to be reallocated in a driver.
* The invariant being skb->truesize substracted from sk->sk_wmem_alloc
*
* Since transmit from skb destructor is forbidden, we use a tasklet
* to process all sockets that eventually need to send more skbs.
* We use one tasklet per cpu, with its own queue of sockets.
*/
struct tsq_tasklet {
struct tasklet_struct tasklet;
struct list_head head; /* queue of tcp sockets */
};
static DEFINE_PER_CPU(struct tsq_tasklet, tsq_tasklet);
static void tcp_tsq_handler(struct sock *sk)
{
if ((1 << sk->sk_state) &
(TCPF_ESTABLISHED | TCPF_FIN_WAIT1 | TCPF_CLOSING |
TCPF_CLOSE_WAIT | TCPF_LAST_ACK))
tcp_write_xmit(sk, tcp_current_mss(sk), 0, 0, GFP_ATOMIC);
}
/*
* One tasklest per cpu tries to send more skbs.
* We run in tasklet context but need to disable irqs when
* transfering tsq->head because tcp_wfree() might
* interrupt us (non NAPI drivers)
*/
static void tcp_tasklet_func(unsigned long data)
{
struct tsq_tasklet *tsq = (struct tsq_tasklet *)data;
LIST_HEAD(list);
unsigned long flags;
struct list_head *q, *n;
struct tcp_sock *tp;
struct sock *sk, *meta_sk;
local_irq_save(flags);
list_splice_init(&tsq->head, &list);
local_irq_restore(flags);
list_for_each_safe(q, n, &list) {
tp = list_entry(q, struct tcp_sock, tsq_node);
list_del(&tp->tsq_node);
sk = (struct sock *)tp;
meta_sk = tp->mpc ? mptcp_meta_sk(sk) : sk;
bh_lock_sock(meta_sk);
if (!sock_owned_by_user(meta_sk)) {
tcp_tsq_handler(sk);
if (tp->mpc)
tcp_tsq_handler(meta_sk);
} else {
/* defer the work to tcp_release_cb() */
set_bit(TCP_TSQ_DEFERRED, &tp->tsq_flags);
/* For MPTCP, we set the tsq-bit on the meta, and the
* subflow as we don't know if the limitation happened
* while inside mptcp_write_xmit or during tcp_write_xmit.
*/
if (tp->mpc) {
set_bit(TCP_TSQ_DEFERRED, &tcp_sk(meta_sk)->tsq_flags);
mptcp_tsq_flags(sk);
}
}
bh_unlock_sock(meta_sk);
clear_bit(TSQ_QUEUED, &tp->tsq_flags);
sk_free(sk);
}
}
#define TCP_DEFERRED_ALL ((1UL << TCP_TSQ_DEFERRED) | \
(1UL << TCP_WRITE_TIMER_DEFERRED) | \
(1UL << TCP_DELACK_TIMER_DEFERRED) | \
(1UL << TCP_MTU_REDUCED_DEFERRED) | \
(1UL << MPTCP_PATH_MANAGER) | \
(1UL << MPTCP_SUB_DEFERRED))
/**
* tcp_release_cb - tcp release_sock() callback
* @sk: socket
*
* called from release_sock() to perform protocol dependent
* actions before socket release.
*/
void tcp_release_cb(struct sock *sk)
{
struct tcp_sock *tp = tcp_sk(sk);
unsigned long flags, nflags;
/* perform an atomic operation only if at least one flag is set */
do {
flags = tp->tsq_flags;
if (!(flags & TCP_DEFERRED_ALL))
return;
nflags = flags & ~TCP_DEFERRED_ALL;
} while (cmpxchg(&tp->tsq_flags, flags, nflags) != flags);
if (flags & (1UL << TCP_TSQ_DEFERRED))
tcp_tsq_handler(sk);
if (flags & (1UL << TCP_WRITE_TIMER_DEFERRED)) {
tcp_write_timer_handler(sk);
__sock_put(sk);
}
if (flags & (1UL << TCP_DELACK_TIMER_DEFERRED)) {
tcp_delack_timer_handler(sk);
__sock_put(sk);
}
if (flags & (1UL << TCP_MTU_REDUCED_DEFERRED)) {
sk->sk_prot->mtu_reduced(sk);
__sock_put(sk);
}
if (flags & (1UL << MPTCP_PATH_MANAGER)) {
if (tcp_sk(sk)->mpcb->pm_ops->release_sock)
tcp_sk(sk)->mpcb->pm_ops->release_sock(sk);
__sock_put(sk);
}
if (flags & (1UL << MPTCP_SUB_DEFERRED))
mptcp_tsq_sub_deferred(sk);
}
EXPORT_SYMBOL(tcp_release_cb);
void __init tcp_tasklet_init(void)
{
int i;
for_each_possible_cpu(i) {
struct tsq_tasklet *tsq = &per_cpu(tsq_tasklet, i);
INIT_LIST_HEAD(&tsq->head);
tasklet_init(&tsq->tasklet,
tcp_tasklet_func,
(unsigned long)tsq);
}
}
/*
* Write buffer destructor automatically called from kfree_skb.
* We cant xmit new skbs from this context, as we might already
* hold qdisc lock.
*/
void tcp_wfree(struct sk_buff *skb)
{
struct sock *sk = skb->sk;
struct tcp_sock *tp = tcp_sk(sk);
if (test_and_clear_bit(TSQ_THROTTLED, &tp->tsq_flags) &&
!test_and_set_bit(TSQ_QUEUED, &tp->tsq_flags)) {
unsigned long flags;
struct tsq_tasklet *tsq;
/* Keep a ref on socket.
* This last ref will be released in tcp_tasklet_func()
*/
atomic_sub(skb->truesize - 1, &sk->sk_wmem_alloc);
/* queue this socket to tasklet queue */
local_irq_save(flags);
tsq = &__get_cpu_var(tsq_tasklet);
list_add(&tp->tsq_node, &tsq->head);
tasklet_schedule(&tsq->tasklet);
local_irq_restore(flags);
} else {
sock_wfree(skb);
}
}
/* This routine actually transmits TCP packets queued in by
* tcp_do_sendmsg(). This is used by both the initial
* transmission and possible later retransmissions.
* All SKB's seen here are completely headerless. It is our
* job to build the TCP header, and pass the packet down to
* IP so it can do the same plus pass the packet off to the
* device.
*
* We are working here with either a clone of the original
* SKB, or a fresh unique copy made by the retransmit engine.
*/
int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
gfp_t gfp_mask)
{
const struct inet_connection_sock *icsk = inet_csk(sk);
struct inet_sock *inet;
struct tcp_sock *tp;
struct tcp_skb_cb *tcb;
struct tcp_out_options opts;
unsigned int tcp_options_size, tcp_header_size;
struct tcp_md5sig_key *md5;
struct tcphdr *th;
int err;
BUG_ON(!skb || !tcp_skb_pcount(skb));
/* If congestion control is doing timestamping, we must
* take such a timestamp before we potentially clone/copy.
*/
if (icsk->icsk_ca_ops->flags & TCP_CONG_RTT_STAMP)
__net_timestamp(skb);
if (likely(clone_it)) {
const struct sk_buff *fclone = skb + 1;
if (unlikely(skb->fclone == SKB_FCLONE_ORIG &&
fclone->fclone == SKB_FCLONE_CLONE))
NET_INC_STATS_BH(sock_net(sk),
LINUX_MIB_TCPSPURIOUS_RTX_HOSTQUEUES);
if (unlikely(skb_cloned(skb))) {
struct sk_buff *newskb;
if (mptcp_is_data_seq(skb))
skb_push(skb, MPTCP_SUB_LEN_DSS_ALIGN +
MPTCP_SUB_LEN_ACK_ALIGN +
MPTCP_SUB_LEN_SEQ_ALIGN);
newskb = pskb_copy(skb, gfp_mask);
if (mptcp_is_data_seq(skb)) {
skb_pull(skb, MPTCP_SUB_LEN_DSS_ALIGN +
MPTCP_SUB_LEN_ACK_ALIGN +
MPTCP_SUB_LEN_SEQ_ALIGN);
if (newskb)
skb_pull(newskb, MPTCP_SUB_LEN_DSS_ALIGN +
MPTCP_SUB_LEN_ACK_ALIGN +
MPTCP_SUB_LEN_SEQ_ALIGN);
}
skb = newskb;
} else {
skb = skb_clone(skb, gfp_mask);
}
if (unlikely(!skb))
return -ENOBUFS;
}
inet = inet_sk(sk);
tp = tcp_sk(sk);
tcb = TCP_SKB_CB(skb);
memset(&opts, 0, sizeof(opts));
if (unlikely(tcb->tcp_flags & TCPHDR_SYN))
tcp_options_size = tcp_syn_options(sk, skb, &opts, &md5);
else
tcp_options_size = tcp_established_options(sk, skb, &opts,
&md5);
tcp_header_size = tcp_options_size + sizeof(struct tcphdr);
if (tcp_packets_in_flight(tp) == 0)
tcp_ca_event(sk, CA_EVENT_TX_START);
/* if no packet is in qdisc/device queue, then allow XPS to select
* another queue.
*/
skb->ooo_okay = sk_wmem_alloc_get(sk) == 0;
skb_push(skb, tcp_header_size);
skb_reset_transport_header(skb);
skb_orphan(skb);
skb->sk = sk;
skb->destructor = (sysctl_tcp_limit_output_bytes > 0) ?
tcp_wfree : sock_wfree;
atomic_add(skb->truesize, &sk->sk_wmem_alloc);
/* Build TCP header and checksum it. */
th = tcp_hdr(skb);
th->source = inet->inet_sport;
th->dest = inet->inet_dport;
//printf("[transmit:]%5u, %5u\n", ntohs(inet->inet_sport), ntohs(inet->inet_dport));
th->seq = htonl(tcb->seq);
th->ack_seq = htonl(tp->rcv_nxt);
*(((__be16 *)th) + 6) = htons(((tcp_header_size >> 2) << 12) |
tcb->tcp_flags);
if (unlikely(tcb->tcp_flags & TCPHDR_SYN)) {
/* RFC1323: The window in SYN & SYN/ACK segments
* is never scaled.
*/
th->window = htons(min(tp->rcv_wnd, 65535U));
} else {
th->window = htons(tcp_select_window(sk));
}
th->check = 0;
th->urg_ptr = 0;
/* The urg_mode check is necessary during a below snd_una win probe */
if (unlikely(tcp_urg_mode(tp) && before(tcb->seq, tp->snd_up))) {
if (before(tp->snd_up, tcb->seq + 0x10000)) {
th->urg_ptr = htons(tp->snd_up - tcb->seq);
th->urg = 1;
} else if (after(tcb->seq + 0xFFFF, tp->snd_nxt)) {
th->urg_ptr = htons(0xFFFF);
th->urg = 1;
}
}
tcp_options_write((__be32 *)(th + 1), tp, &opts, skb);
if (likely((tcb->tcp_flags & TCPHDR_SYN) == 0))
TCP_ECN_send(sk, skb, tcp_header_size);
#ifdef CONFIG_TCP_MD5SIG
/* Calculate the MD5 hash, as we have all we need now */
if (md5) {
sk_nocaps_add(sk, NETIF_F_GSO_MASK);
tp->af_specific->calc_md5_hash(opts.hash_location,
md5, sk, NULL, skb);
}
#endif
icsk->icsk_af_ops->send_check(sk, skb);
if (likely(tcb->tcp_flags & TCPHDR_ACK))
tcp_event_ack_sent(sk, tcp_skb_pcount(skb));
if (skb->len != tcp_header_size)
tcp_event_data_sent(tp, sk);
if (after(tcb->end_seq, tp->snd_nxt) || tcb->seq == tcb->end_seq)
TCP_ADD_STATS(sock_net(sk), TCP_MIB_OUTSEGS,
tcp_skb_pcount(skb));
/*
if(sk->__sk_common.lane_info == 0)
printf("[transmit_skb]lane:%d, is_path:%d, %d, %d\n", sk->__sk_common.lane_info, sk->__sk_common.is_path, sk->__sk_common.skc_daddr, sk->__sk_common.skc_rcv_saddr);
*/
if(sk->__sk_common.is_path == 1){
//printf("[transmit_skb]lane:%d, is_path:%d, %d, %d\n", sk->__sk_common.lane_info, sk->__sk_common.is_path, sk->__sk_common.skc_daddr, sk->__sk_common.skc_rcv_saddr);
if(sk->__sk_common.lane_info == 0){
tcp_sk(sk)->snd_cwnd = 0;
}
//printf("hit!:%d\n", tcp_sk(sk)->snd_cwnd);
}
else{
if(sk->__sk_common.lane_info == 1){
tcp_sk(sk)->snd_cwnd = 2;
}
}
err = icsk->icsk_af_ops->queue_xmit(skb, &inet->cork.fl);
if (likely(err <= 0))
return err;
tcp_enter_cwr(sk, 1);
return net_xmit_eval(err);
}
/* This routine just queues the buffer for sending.
*
* NOTE: probe0 timer is not checked, do not forget tcp_push_pending_frames,
* otherwise socket can stall.
*/
void tcp_queue_skb(struct sock *sk, struct sk_buff *skb)
{
struct tcp_sock *tp = tcp_sk(sk);
/* Advance write_seq and place onto the write_queue. */
tp->write_seq = TCP_SKB_CB(skb)->end_seq;
skb_header_release(skb);
tcp_add_write_queue_tail(sk, skb);
sk->sk_wmem_queued += skb->truesize;
sk_mem_charge(sk, skb->truesize);
}
/* Initialize TSO segments for a packet. */
void tcp_set_skb_tso_segs(const struct sock *sk, struct sk_buff *skb,
unsigned int mss_now)
{
if (skb->len <= mss_now || (is_meta_sk(sk) && !mptcp_sk_can_gso(sk)) ||
(!is_meta_sk(sk) && !sk_can_gso(sk)) || skb->ip_summed == CHECKSUM_NONE) {
/* Avoid the costly divide in the normal
* non-TSO case.
*/
skb_shinfo(skb)->gso_segs = 1;
skb_shinfo(skb)->gso_size = 0;
skb_shinfo(skb)->gso_type = 0;
} else {
skb_shinfo(skb)->gso_segs = DIV_ROUND_UP(skb->len, mss_now);
skb_shinfo(skb)->gso_size = mss_now;
skb_shinfo(skb)->gso_type = sk->sk_gso_type;
}
}
/* When a modification to fackets out becomes necessary, we need to check
* skb is counted to fackets_out or not.
*/
static void tcp_adjust_fackets_out(struct sock *sk, const struct sk_buff *skb,
int decr)
{
struct tcp_sock *tp = tcp_sk(sk);
if (!tp->sacked_out || tcp_is_reno(tp))
return;
if (after(tcp_highest_sack_seq(tp), TCP_SKB_CB(skb)->seq))
tp->fackets_out -= decr;
}
/* Pcount in the middle of the write queue got changed, we need to do various
* tweaks to fix counters
*/
void tcp_adjust_pcount(struct sock *sk, const struct sk_buff *skb, int decr)
{
struct tcp_sock *tp = tcp_sk(sk);
tp->packets_out -= decr;
if (TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_ACKED)
tp->sacked_out -= decr;
if (TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_RETRANS)
tp->retrans_out -= decr;
if (TCP_SKB_CB(skb)->sacked & TCPCB_LOST)
tp->lost_out -= decr;
/* Reno case is special. Sigh... */
if (tcp_is_reno(tp) && decr > 0)
tp->sacked_out -= min_t(u32, tp->sacked_out, decr);
tcp_adjust_fackets_out(sk, skb, decr);
if (tp->lost_skb_hint &&
before(TCP_SKB_CB(skb)->seq, TCP_SKB_CB(tp->lost_skb_hint)->seq) &&
(tcp_is_fack(tp) || (TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_ACKED)))
tp->lost_cnt_hint -= decr;
tcp_verify_left_out(tp);
}
/* Function to create two new TCP segments. Shrinks the given segment
* to the specified size and appends a new segment with the rest of the
* packet to the list. This won't be called frequently, I hope.
* Remember, these are still headerless SKBs at this point.
*/
int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len,
unsigned int mss_now)
{
struct tcp_sock *tp = tcp_sk(sk);
struct sk_buff *buff;
int nsize, old_factor;
int nlen;
u8 flags;
if (tcp_sk(sk)->mpc && mptcp_is_data_seq(skb))
mptcp_fragment(sk, skb, len, mss_now, 0);
if (WARN_ON(len > skb->len))
return -EINVAL;
nsize = skb_headlen(skb) - len;
if (nsize < 0)
nsize = 0;
if (skb_cloned(skb) &&
skb_is_nonlinear(skb) &&
pskb_expand_head(skb, 0, 0, GFP_ATOMIC))
return -ENOMEM;
/* Get a new skb... force flag on. */
buff = sk_stream_alloc_skb(sk, nsize, GFP_ATOMIC);
if (buff == NULL)
return -ENOMEM; /* We'll just try again later. */
sk->sk_wmem_queued += buff->truesize;
sk_mem_charge(sk, buff->truesize);
nlen = skb->len - len - nsize;
buff->truesize += nlen;
skb->truesize -= nlen;
/* Correct the sequence numbers. */
TCP_SKB_CB(buff)->seq = TCP_SKB_CB(skb)->seq + len;
TCP_SKB_CB(buff)->end_seq = TCP_SKB_CB(skb)->end_seq;
TCP_SKB_CB(skb)->end_seq = TCP_SKB_CB(buff)->seq;
/* PSH and FIN should only be set in the second packet. */
flags = TCP_SKB_CB(skb)->tcp_flags;
TCP_SKB_CB(skb)->tcp_flags = flags & ~(TCPHDR_FIN | TCPHDR_PSH);
TCP_SKB_CB(buff)->tcp_flags = flags;
TCP_SKB_CB(buff)->sacked = TCP_SKB_CB(skb)->sacked;
if (!skb_shinfo(skb)->nr_frags && skb->ip_summed != CHECKSUM_PARTIAL) {
/* Copy and checksum data tail into the new buffer. */
buff->csum = csum_partial_copy_nocheck(skb->data + len,
skb_put(buff, nsize),
nsize, 0);
skb_trim(skb, len);
skb->csum = csum_block_sub(skb->csum, buff->csum, len);
} else {
skb->ip_summed = CHECKSUM_PARTIAL;
skb_split(skb, buff, len);
}
buff->ip_summed = skb->ip_summed;
/* Looks stupid, but our code really uses when of
* skbs, which it never sent before. --ANK
*/
TCP_SKB_CB(buff)->when = TCP_SKB_CB(skb)->when;
buff->tstamp = skb->tstamp;
old_factor = tcp_skb_pcount(skb);
/* Fix up tso_factor for both original and new SKB. */
tcp_set_skb_tso_segs(sk, skb, mss_now);
tcp_set_skb_tso_segs(sk, buff, mss_now);
/* If this packet has been sent out already, we must
* adjust the various packet counters.
*/
if (!before(tp->snd_nxt, TCP_SKB_CB(buff)->end_seq)) {
int diff = old_factor - tcp_skb_pcount(skb) -
tcp_skb_pcount(buff);
if (diff)
tcp_adjust_pcount(sk, skb, diff);
}
/* Link BUFF into the send queue. */
skb_header_release(buff);
tcp_insert_write_queue_after(skb, buff, sk);
return 0;
}
/* This is similar to __pskb_pull_head() (it will go to core/skbuff.c
* eventually). The difference is that pulled data not copied, but
* immediately discarded.
*/
void __pskb_trim_head(struct sk_buff *skb, int len)
{
int i, k, eat;
eat = min_t(int, len, skb_headlen(skb));
if (eat) {
__skb_pull(skb, eat);
len -= eat;
if (!len)
return;
}
eat = len;
k = 0;
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
int size = skb_frag_size(&skb_shinfo(skb)->frags[i]);
if (size <= eat) {
skb_frag_unref(skb, i);
eat -= size;
} else {
skb_shinfo(skb)->frags[k] = skb_shinfo(skb)->frags[i];
if (eat) {
skb_shinfo(skb)->frags[k].page_offset += eat;
skb_frag_size_sub(&skb_shinfo(skb)->frags[k], eat);
eat = 0;
}
k++;
}
}
skb_shinfo(skb)->nr_frags = k;
skb_reset_tail_pointer(skb);
skb->data_len -= len;
skb->len = skb->data_len;
}
/* Remove acked data from a packet in the transmit queue. */
int tcp_trim_head(struct sock *sk, struct sk_buff *skb, u32 len)
{
if (tcp_sk(sk)->mpc && !is_meta_sk(sk) && mptcp_is_data_seq(skb))
return mptcp_trim_head(sk, skb, len);
if (skb_unclone(skb, GFP_ATOMIC))
return -ENOMEM;
__pskb_trim_head(skb, len);
TCP_SKB_CB(skb)->seq += len;
skb->ip_summed = CHECKSUM_PARTIAL;
skb->truesize -= len;
sk->sk_wmem_queued -= len;
sk_mem_uncharge(sk, len);
sock_set_flag(sk, SOCK_QUEUE_SHRUNK);
/* Any change of skb->len requires recalculation of tso factor. */
if (tcp_skb_pcount(skb) > 1)
tcp_set_skb_tso_segs(sk, skb, tcp_skb_mss(skb));
#ifdef CONFIG_MPTCP
/* Some data got acked - we assume that the seq-number reached the dest.
* Anyway, our MPTCP-option has been trimmed above - we lost it here.
* Only remove the SEQ if the call does not come from a meta retransmit.
*/
if (tcp_sk(sk)->mpc && !is_meta_sk(sk))
TCP_SKB_CB(skb)->mptcp_flags &= ~MPTCPHDR_SEQ;
#endif
return 0;
}
/* Calculate MSS not accounting any TCP options. */
static inline int __tcp_mtu_to_mss(struct sock *sk, int pmtu)
{
const struct tcp_sock *tp = tcp_sk(sk);
const struct inet_connection_sock *icsk = inet_csk(sk);
int mss_now;
/* Calculate base mss without TCP options:
It is MMS_S - sizeof(tcphdr) of rfc1122
*/
mss_now = pmtu - icsk->icsk_af_ops->net_header_len - sizeof(struct tcphdr);
/* IPv6 adds a frag_hdr in case RTAX_FEATURE_ALLFRAG is set */
if (icsk->icsk_af_ops->net_frag_header_len) {
const struct dst_entry *dst = __sk_dst_get(sk);
if (dst && dst_allfrag(dst))
mss_now -= icsk->icsk_af_ops->net_frag_header_len;
}
/* Clamp it (mss_clamp does not include tcp options) */
if (mss_now > tp->rx_opt.mss_clamp)
mss_now = tp->rx_opt.mss_clamp;
/* Now subtract optional transport overhead */
mss_now -= icsk->icsk_ext_hdr_len;
/* Then reserve room for full set of TCP options and 8 bytes of data */
if (mss_now < 48)
mss_now = 48;
return mss_now;
}
/* Calculate MSS. Not accounting for SACKs here. */
int tcp_mtu_to_mss(struct sock *sk, int pmtu)
{
/* Subtract TCP options size, not including SACKs */
return __tcp_mtu_to_mss(sk, pmtu) -
(tcp_sk(sk)->tcp_header_len - sizeof(struct tcphdr));
}
/* Inverse of above */
int tcp_mss_to_mtu(struct sock *sk, int mss)
{
const struct tcp_sock *tp = tcp_sk(sk);
const struct inet_connection_sock *icsk = inet_csk(sk);
int mtu;
mtu = mss +
tp->tcp_header_len +
icsk->icsk_ext_hdr_len +
icsk->icsk_af_ops->net_header_len;
/* IPv6 adds a frag_hdr in case RTAX_FEATURE_ALLFRAG is set */
if (icsk->icsk_af_ops->net_frag_header_len) {
const struct dst_entry *dst = __sk_dst_get(sk);
if (dst && dst_allfrag(dst))
mtu += icsk->icsk_af_ops->net_frag_header_len;
}
return mtu;
}
/* MTU probing init per socket */
void tcp_mtup_init(struct sock *sk)
{
struct tcp_sock *tp = tcp_sk(sk);
struct inet_connection_sock *icsk = inet_csk(sk);
icsk->icsk_mtup.enabled = sysctl_tcp_mtu_probing > 1;
icsk->icsk_mtup.search_high = tp->rx_opt.mss_clamp + sizeof(struct tcphdr) +
icsk->icsk_af_ops->net_header_len;
icsk->icsk_mtup.search_low = tcp_mss_to_mtu(sk, sysctl_tcp_base_mss);
icsk->icsk_mtup.probe_size = 0;
}
EXPORT_SYMBOL(tcp_mtup_init);
/* This function synchronize snd mss to current pmtu/exthdr set.
tp->rx_opt.user_mss is mss set by user by TCP_MAXSEG. It does NOT counts
for TCP options, but includes only bare TCP header.
tp->rx_opt.mss_clamp is mss negotiated at connection setup.
It is minimum of user_mss and mss received with SYN.
It also does not include TCP options.
inet_csk(sk)->icsk_pmtu_cookie is last pmtu, seen by this function.
tp->mss_cache is current effective sending mss, including
all tcp options except for SACKs. It is evaluated,
taking into account current pmtu, but never exceeds
tp->rx_opt.mss_clamp.
NOTE1. rfc1122 clearly states that advertised MSS
DOES NOT include either tcp or ip options.
NOTE2. inet_csk(sk)->icsk_pmtu_cookie and tp->mss_cache
are READ ONLY outside this function. --ANK (980731)
*/
unsigned int tcp_sync_mss(struct sock *sk, u32 pmtu)
{
struct tcp_sock *tp = tcp_sk(sk);
struct inet_connection_sock *icsk = inet_csk(sk);
int mss_now;
if (icsk->icsk_mtup.search_high > pmtu)
icsk->icsk_mtup.search_high = pmtu;
mss_now = tcp_mtu_to_mss(sk, pmtu);
mss_now = tcp_bound_to_half_wnd(tp, mss_now);
/* And store cached results */
icsk->icsk_pmtu_cookie = pmtu;
if (icsk->icsk_mtup.enabled)
mss_now = min(mss_now, tcp_mtu_to_mss(sk, icsk->icsk_mtup.search_low));
tp->mss_cache = mss_now;
return mss_now;
}
EXPORT_SYMBOL(tcp_sync_mss);
/* Compute the current effective MSS, taking SACKs and IP options,
* and even PMTU discovery events into account.
*/
unsigned int tcp_current_mss(struct sock *sk)
{
const struct tcp_sock *tp = tcp_sk(sk);
const struct dst_entry *dst = __sk_dst_get(sk);
u32 mss_now;
unsigned int header_len;
struct tcp_out_options opts;
struct tcp_md5sig_key *md5;
mss_now = tp->mss_cache;
if (dst) {
u32 mtu = dst_mtu(dst);
if (mtu != inet_csk(sk)->icsk_pmtu_cookie)
mss_now = tcp_sync_mss(sk, mtu);
}
header_len = tcp_established_options(sk, NULL, &opts, &md5) +
sizeof(struct tcphdr);
/* The mss_cache is sized based on tp->tcp_header_len, which assumes
* some common options. If this is an odd packet (because we have SACK
* blocks etc) then our calculated header_len will be different, and
* we have to adjust mss_now correspondingly */
if (header_len != tp->tcp_header_len) {
int delta = (int) header_len - tp->tcp_header_len;
mss_now -= delta;
}
return mss_now;
}
/* Congestion window validation. (RFC2861) */
void tcp_cwnd_validate(struct sock *sk)
{
struct tcp_sock *tp = tcp_sk(sk);
if (tp->packets_out >= tp->snd_cwnd) {
/* Network is feed fully. */
tp->snd_cwnd_used = 0;
tp->snd_cwnd_stamp = tcp_time_stamp;
} else {
/* Network starves. */
if (tp->packets_out > tp->snd_cwnd_used)
tp->snd_cwnd_used = tp->packets_out;
if (sysctl_tcp_slow_start_after_idle &&
(s32)(tcp_time_stamp - tp->snd_cwnd_stamp) >= inet_csk(sk)->icsk_rto)
tcp_cwnd_application_limited(sk);
}
}
/* Returns the portion of skb which can be sent right away without
* introducing MSS oddities to segment boundaries. In rare cases where
* mss_now != mss_cache, we will request caller to create a small skb
* per input skb which could be mostly avoided here (if desired).
*
* We explicitly want to create a request for splitting write queue tail
* to a small skb for Nagle purposes while avoiding unnecessary modulos,
* thus all the complexity (cwnd_len is always MSS multiple which we
* return whenever allowed by the other factors). Basically we need the
* modulo only when the receiver window alone is the limiting factor or
* when we would be allowed to send the split-due-to-Nagle skb fully.
*/
unsigned int tcp_mss_split_point(const struct sock *sk, const struct sk_buff *skb,
unsigned int mss_now, unsigned int max_segs)
{
const struct tcp_sock *tp = tcp_sk(sk);
const struct sock *meta_sk = tp->mpc ? mptcp_meta_sk(sk) : sk;
u32 needed, window, max_len;
if (!tp->mpc)
window = tcp_wnd_end(tp) - TCP_SKB_CB(skb)->seq;
else
/* We need to evaluate the available space in the sending window
* at the subflow level. However, the subflow seq has not yet
* been set. Nevertheless we know that the caller will set it to
* write_seq.
*/
window = tcp_wnd_end(tp) - tp->write_seq;
max_len = mss_now * max_segs;
if (likely(max_len <= window && skb != tcp_write_queue_tail(meta_sk)))
return max_len;
needed = min(skb->len, window);
if (max_len <= needed)
return max_len;
return needed - needed % mss_now;
}
/* Can at least one segment of SKB be sent right now, according to the
* congestion window rules? If so, return how many segments are allowed.
*/
unsigned int tcp_cwnd_test(const struct tcp_sock *tp,
const struct sk_buff *skb)
{
u32 in_flight, cwnd;
/* Don't be strict about the congestion window for the final FIN. */
if (skb &&
((TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN) || mptcp_is_data_fin(skb)) &&
tcp_skb_pcount(skb) == 1)
return 1;
in_flight = tcp_packets_in_flight(tp);
cwnd = tp->snd_cwnd;
if (in_flight < cwnd)
return (cwnd - in_flight);
return 0;
}
/* Initialize TSO state of a skb.
* This must be invoked the first time we consider transmitting
* SKB onto the wire.
*/
int tcp_init_tso_segs(const struct sock *sk, struct sk_buff *skb,
unsigned int mss_now)
{
int tso_segs = tcp_skb_pcount(skb);
if (!tso_segs || (tso_segs > 1 && tcp_skb_mss(skb) != mss_now)) {
tcp_set_skb_tso_segs(sk, skb, mss_now);
tso_segs = tcp_skb_pcount(skb);
}
return tso_segs;
}
/* Minshall's variant of the Nagle send check. */
static inline bool tcp_minshall_check(const struct tcp_sock *tp)
{
return after(tp->snd_sml, tp->snd_una) &&
!after(tp->snd_sml, tp->snd_nxt);
}
/* Return false, if packet can be sent now without violation Nagle's rules:
* 1. It is full sized.
* 2. Or it contains FIN. (already checked by caller)
* 3. Or TCP_CORK is not set, and TCP_NODELAY is set.
* 4. Or TCP_CORK is not set, and all sent packets are ACKed.
* With Minshall's modification: all sent small packets are ACKed.
*/
static inline bool tcp_nagle_check(const struct tcp_sock *tp,
const struct sk_buff *skb,
unsigned int mss_now, int nonagle)
{
return skb->len < mss_now &&
((nonagle & TCP_NAGLE_CORK) ||
(!nonagle && tp->packets_out && tcp_minshall_check(tp)));
}
/* Return true if the Nagle test allows this packet to be
* sent now.
*/
bool tcp_nagle_test(const struct tcp_sock *tp, const struct sk_buff *skb,
unsigned int cur_mss, int nonagle)
{
/* Nagle rule does not apply to frames, which sit in the middle of the
* write_queue (they have no chances to get new data).
*
* This is implemented in the callers, where they modify the 'nonagle'
* argument based upon the location of SKB in the send queue.
*/
if (nonagle & TCP_NAGLE_PUSH)
return true;
/* Don't use the nagle rule for urgent data (or for the final FIN). */
if (tcp_urg_mode(tp) || (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN) ||
mptcp_is_data_fin(skb))
return true;
if (!tcp_nagle_check(tp, skb, cur_mss, nonagle))
return true;
return false;
}
/* Does at least the first segment of SKB fit into the send window? */
bool tcp_snd_wnd_test(const struct tcp_sock *tp, const struct sk_buff *skb,
unsigned int cur_mss)
{
u32 end_seq = TCP_SKB_CB(skb)->end_seq;
if (skb->len > cur_mss)
end_seq = TCP_SKB_CB(skb)->seq + cur_mss;
return !after(end_seq, tcp_wnd_end(tp));
}
/* This checks if the data bearing packet SKB (usually tcp_send_head(sk))
* should be put on the wire right now. If so, it returns the number of
* packets allowed by the congestion window.
*/
static unsigned int tcp_snd_test(const struct sock *sk, struct sk_buff *skb,
unsigned int cur_mss, int nonagle)
{
const struct tcp_sock *tp = tcp_sk(sk);
unsigned int cwnd_quota;
tcp_init_tso_segs(sk, skb, cur_mss);
if (!tcp_nagle_test(tp, skb, cur_mss, nonagle))
return 0;
cwnd_quota = tcp_cwnd_test(tp, skb);
if (cwnd_quota && !tcp_snd_wnd_test(tp, skb, cur_mss))
cwnd_quota = 0;
return cwnd_quota;
}
/* Test if sending is allowed right now. */
bool tcp_may_send_now(struct sock *sk)
{
const struct tcp_sock *tp = tcp_sk(sk);
struct sk_buff *skb = tcp_send_head(sk);
return skb &&
tcp_snd_test(sk, skb, tcp_current_mss(sk),
(tcp_skb_is_last(sk, skb) ?
tp->nonagle : TCP_NAGLE_PUSH));
}
/* Trim TSO SKB to LEN bytes, put the remaining data into a new packet
* which is put after SKB on the list. It is very much like
* tcp_fragment() except that it may make several kinds of assumptions
* in order to speed up the splitting operation. In particular, we
* know that all the data is in scatter-gather pages, and that the
* packet has never been sent out before (and thus is not cloned).
*/
static int tso_fragment(struct sock *sk, struct sk_buff *skb, unsigned int len,
unsigned int mss_now, gfp_t gfp)
{
struct sk_buff *buff;
int nlen = skb->len - len;
u8 flags;
if (tcp_sk(sk)->mpc && mptcp_is_data_seq(skb))
mptso_fragment(sk, skb, len, mss_now, gfp, 0);
/* All of a TSO frame must be composed of paged data. */
if (skb->len != skb->data_len)
return tcp_fragment(sk, skb, len, mss_now);
buff = sk_stream_alloc_skb(sk, 0, gfp);
if (unlikely(buff == NULL))
return -ENOMEM;
sk->sk_wmem_queued += buff->truesize;
sk_mem_charge(sk, buff->truesize);
buff->truesize += nlen;
skb->truesize -= nlen;
/* Correct the sequence numbers. */
TCP_SKB_CB(buff)->seq = TCP_SKB_CB(skb)->seq + len;
TCP_SKB_CB(buff)->end_seq = TCP_SKB_CB(skb)->end_seq;
TCP_SKB_CB(skb)->end_seq = TCP_SKB_CB(buff)->seq;
/* PSH and FIN should only be set in the second packet. */
flags = TCP_SKB_CB(skb)->tcp_flags;
TCP_SKB_CB(skb)->tcp_flags = flags & ~(TCPHDR_FIN | TCPHDR_PSH);
TCP_SKB_CB(buff)->tcp_flags = flags;
/* This packet was never sent out yet, so no SACK bits. */
TCP_SKB_CB(buff)->sacked = 0;
buff->ip_summed = skb->ip_summed = CHECKSUM_PARTIAL;
skb_split(skb, buff, len);
/* Fix up tso_factor for both original and new SKB. */
tcp_set_skb_tso_segs(sk, skb, mss_now);
tcp_set_skb_tso_segs(sk, buff, mss_now);
/* Link BUFF into the send queue. */
skb_header_release(buff);
tcp_insert_write_queue_after(skb, buff, sk);
return 0;
}
/* Try to defer sending, if possible, in order to minimize the amount
* of TSO splitting we do. View it as a kind of TSO Nagle test.
*
* This algorithm is from John Heffner.
*/
bool tcp_tso_should_defer(struct sock *sk, struct sk_buff *skb)
{
struct tcp_sock *tp = tcp_sk(sk);
struct sock *meta_sk = tp->mpc ? mptcp_meta_sk(sk) : sk;
struct tcp_sock *meta_tp = tcp_sk(meta_sk);
const struct inet_connection_sock *icsk = inet_csk(sk);
u32 send_win, cong_win, limit, in_flight;
int win_divisor;
if ((TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN) || mptcp_is_data_fin(skb))
goto send_now;
if (icsk->icsk_ca_state != TCP_CA_Open)
goto send_now;
/* Defer for less than two clock ticks. */
if (meta_tp->tso_deferred &&
(((u32)jiffies << 1) >> 1) - (meta_tp->tso_deferred >> 1) > 1)
goto send_now;
in_flight = tcp_packets_in_flight(tp);
BUG_ON(tcp_skb_pcount(skb) <= 1 || (tp->snd_cwnd <= in_flight));
if (!tp->mpc)
send_win = tcp_wnd_end(tp) - TCP_SKB_CB(skb)->seq;
else
/* We need to evaluate the available space in the sending window
* at the subflow level. However, the subflow seq has not yet
* been set. Nevertheless we know that the caller will set it to
* write_seq.
*/
send_win = tcp_wnd_end(tp) - tp->write_seq;
/* From in_flight test above, we know that cwnd > in_flight. */
cong_win = (tp->snd_cwnd - in_flight) * tp->mss_cache;
limit = min(send_win, cong_win);
/* If a full-sized TSO skb can be sent, do it. */
if (limit >= min_t(unsigned int, sk->sk_gso_max_size,
sk->sk_gso_max_segs * tp->mss_cache))
goto send_now;
/* Middle in queue won't get any more data, full sendable already? */
if ((skb != tcp_write_queue_tail(meta_sk)) && (limit >= skb->len))
goto send_now;
win_divisor = ACCESS_ONCE(sysctl_tcp_tso_win_divisor);
if (win_divisor) {
u32 chunk = min(tp->snd_wnd, tp->snd_cwnd * tp->mss_cache);
/* If at least some fraction of a window is available,
* just use it.
*/
chunk /= win_divisor;
if (limit >= chunk)
goto send_now;
} else {
/* Different approach, try not to defer past a single
* ACK. Receiver should ACK every other full sized
* frame, so if we have space for more than 3 frames
* then send now.
*/
if (limit > tcp_max_tso_deferred_mss(tp) * tp->mss_cache)
goto send_now;
}
/* Ok, it looks like it is advisable to defer.
* Do not rearm the timer if already set to not break TCP ACK clocking.
*/
if (!meta_tp->tso_deferred)
meta_tp->tso_deferred = 1 | (jiffies << 1);
return true;
send_now:
meta_tp->tso_deferred = 0;
return false;
}
/* Create a new MTU probe if we are ready.
* MTU probe is regularly attempting to increase the path MTU by
* deliberately sending larger packets. This discovers routing
* changes resulting in larger path MTUs.
*
* Returns 0 if we should wait to probe (no cwnd available),
* 1 if a probe was sent,
* -1 otherwise
*/
int tcp_mtu_probe(struct sock *sk)
{
struct tcp_sock *tp = tcp_sk(sk);
struct inet_connection_sock *icsk = inet_csk(sk);
struct sk_buff *skb, *nskb, *next;
int len;
int probe_size;
int size_needed;
int copy;
int mss_now;
/* Not currently probing/verifying,
* not in recovery,
* have enough cwnd, and
* not SACKing (the variable headers throw things off) */
if (!icsk->icsk_mtup.enabled ||
icsk->icsk_mtup.probe_size ||
inet_csk(sk)->icsk_ca_state != TCP_CA_Open ||
tp->snd_cwnd < 11 ||
tp->rx_opt.num_sacks || tp->rx_opt.dsack)
return -1;
/* Very simple search strategy: just double the MSS. */
mss_now = tcp_current_mss(sk);
probe_size = 2 * tp->mss_cache;
size_needed = probe_size + (tp->reordering + 1) * tp->mss_cache;
if (probe_size > tcp_mtu_to_mss(sk, icsk->icsk_mtup.search_high)) {
/* TODO: set timer for probe_converge_event */
return -1;
}
/* Have enough data in the send queue to probe? */
if (tp->write_seq - tp->snd_nxt < size_needed)
return -1;
if (tp->snd_wnd < size_needed)
return -1;
if (after(tp->snd_nxt + size_needed, tcp_wnd_end(tp)))
return 0;
/* Do we need to wait to drain cwnd? With none in flight, don't stall */
if (tcp_packets_in_flight(tp) + 2 > tp->snd_cwnd) {
if (!tcp_packets_in_flight(tp))
return -1;
else
return 0;
}
/* We're allowed to probe. Build it now. */
if ((nskb = sk_stream_alloc_skb(sk, probe_size, GFP_ATOMIC)) == NULL)
return -1;
sk->sk_wmem_queued += nskb->truesize;
sk_mem_charge(sk, nskb->truesize);
skb = tcp_send_head(sk);
TCP_SKB_CB(nskb)->seq = TCP_SKB_CB(skb)->seq;
TCP_SKB_CB(nskb)->end_seq = TCP_SKB_CB(skb)->seq + probe_size;
TCP_SKB_CB(nskb)->tcp_flags = TCPHDR_ACK;
TCP_SKB_CB(nskb)->sacked = 0;
nskb->csum = 0;
nskb->ip_summed = skb->ip_summed;
tcp_insert_write_queue_before(nskb, skb, sk);
len = 0;
tcp_for_write_queue_from_safe(skb, next, sk) {
copy = min_t(int, skb->len, probe_size - len);
if (nskb->ip_summed)
skb_copy_bits(skb, 0, skb_put(nskb, copy), copy);
else
nskb->csum = skb_copy_and_csum_bits(skb, 0,
skb_put(nskb, copy),
copy, nskb->csum);
if (skb->len <= copy) {
/* We've eaten all the data from this skb.
* Throw it away. */
TCP_SKB_CB(nskb)->tcp_flags |= TCP_SKB_CB(skb)->tcp_flags;
tcp_unlink_write_queue(skb, sk);
sk_wmem_free_skb(sk, skb);
} else {
TCP_SKB_CB(nskb)->tcp_flags |= TCP_SKB_CB(skb)->tcp_flags &
~(TCPHDR_FIN|TCPHDR_PSH);
if (!skb_shinfo(skb)->nr_frags) {
skb_pull(skb, copy);
if (skb->ip_summed != CHECKSUM_PARTIAL)
skb->csum = csum_partial(skb->data,
skb->len, 0);
} else {
__pskb_trim_head(skb, copy);
tcp_set_skb_tso_segs(sk, skb, mss_now);
}
TCP_SKB_CB(skb)->seq += copy;
}
len += copy;
if (len >= probe_size)
break;
}
tcp_init_tso_segs(sk, nskb, nskb->len);
/* We're ready to send. If this fails, the probe will
* be resegmented into mss-sized pieces by tcp_write_xmit(). */
TCP_SKB_CB(nskb)->when = tcp_time_stamp;
if (!tcp_transmit_skb(sk, nskb, 1, GFP_ATOMIC)) {
/* Decrement cwnd here because we are sending
* effectively two packets. */
tp->snd_cwnd--;
tcp_event_new_data_sent(sk, nskb);
icsk->icsk_mtup.probe_size = tcp_mss_to_mtu(sk, nskb->len);
tp->mtu_probe.probe_seq_start = TCP_SKB_CB(nskb)->seq;
tp->mtu_probe.probe_seq_end = TCP_SKB_CB(nskb)->end_seq;
return 1;
}
return -1;
}
/* This routine writes packets to the network. It advances the
* send_head. This happens as incoming acks open up the remote
* window for us.
*
* LARGESEND note: !tcp_urg_mode is overkill, only frames between
* snd_up-64k-mss .. snd_up cannot be large. However, taking into
* account rare use of URG, this is not a big flaw.
*
* Send at most one packet when push_one > 0. Temporarily ignore
* cwnd limit to force at most one packet out when push_one == 2.
* Returns true, if no segments are in flight and we have queued segments,
* but cannot send anything now because of SWS or another problem.
*/
static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle,
int push_one, gfp_t gfp)
{
struct tcp_sock *tp = tcp_sk(sk);
struct sk_buff *skb;
unsigned int tso_segs, sent_pkts;
int cwnd_quota;
int result;
//printf("mptcp?::%d, %d\n", sk->__sk_common.skc_daddr, sk->__sk_common.skc_rcv_saddr);
if (is_meta_sk(sk))
return mptcp_write_xmit(sk, mss_now, nonagle, push_one, gfp);
sent_pkts = 0;
if (!push_one) {
/* Do MTU probing. */
result = tcp_mtu_probe(sk);
if (!result) {
return false;
} else if (result > 0) {
sent_pkts = 1;
}
}
while ((skb = tcp_send_head(sk))) {
unsigned int limit;
tso_segs = tcp_init_tso_segs(sk, skb, mss_now);
BUG_ON(!tso_segs);
if (unlikely(tp->repair) && tp->repair_queue == TCP_SEND_QUEUE)
goto repair; /* Skip network transmission */
cwnd_quota = tcp_cwnd_test(tp, skb);
if (!cwnd_quota) {
if (push_one == 2)
/* Force out a loss probe pkt. */
cwnd_quota = 1;
else
break;
}
if (unlikely(!tcp_snd_wnd_test(tp, skb, mss_now)))
break;
if (tso_segs == 1) {
if (unlikely(!tcp_nagle_test(tp, skb, mss_now,
(tcp_skb_is_last(sk, skb) ?
nonagle : TCP_NAGLE_PUSH))))
break;
} else {
if (!push_one && tcp_tso_should_defer(sk, skb))
break;
}
/* TSQ : sk_wmem_alloc accounts skb truesize,
* including skb overhead. But thats OK.
*/
if (atomic_read(&sk->sk_wmem_alloc) >= sysctl_tcp_limit_output_bytes) {
set_bit(TSQ_THROTTLED, &tp->tsq_flags);
break;
}
limit = mss_now;
if (tso_segs > 1 && !tcp_urg_mode(tp))
limit = tcp_mss_split_point(sk, skb, mss_now,
min_t(unsigned int,
cwnd_quota,
sk->sk_gso_max_segs));
if (skb->len > limit &&
unlikely(tso_fragment(sk, skb, limit, mss_now, gfp)))
break;
TCP_SKB_CB(skb)->when = tcp_time_stamp;
if (unlikely(tcp_transmit_skb(sk, skb, 1, gfp)))
break;
repair:
/* Advance the send_head. This one is sent out.
* This call will increment packets_out.
*/
tcp_event_new_data_sent(sk, skb);
tcp_minshall_update(tp, mss_now, skb);
sent_pkts += tcp_skb_pcount(skb);
if (push_one)
break;
}
if (likely(sent_pkts)) {
if (tcp_in_cwnd_reduction(sk))
tp->prr_out += sent_pkts;
/* Send one loss probe per tail loss episode. */
if (push_one != 2)
tcp_schedule_loss_probe(sk);
tcp_cwnd_validate(sk);
return false;
}
return (push_one == 2) || (!tp->packets_out && tcp_send_head(sk));
}
bool tcp_schedule_loss_probe(struct sock *sk)
{
struct inet_connection_sock *icsk = inet_csk(sk);
struct tcp_sock *tp = tcp_sk(sk);
u32 timeout, tlp_time_stamp, rto_time_stamp;
u32 rtt = tp->srtt >> 3;
if (WARN_ON(icsk->icsk_pending == ICSK_TIME_EARLY_RETRANS))
return false;
/* No consecutive loss probes. */
if (WARN_ON(icsk->icsk_pending == ICSK_TIME_LOSS_PROBE)) {
tcp_rearm_rto(sk);
return false;
}
/* Don't do any loss probe on a Fast Open connection before 3WHS
* finishes.
*/
if (sk->sk_state == TCP_SYN_RECV)
return false;
/* TLP is only scheduled when next timer event is RTO. */
if (icsk->icsk_pending != ICSK_TIME_RETRANS)
return false;
/* Schedule a loss probe in 2*RTT for SACK capable connections
* in Open state, that are either limited by cwnd or application.
*/
if (sysctl_tcp_early_retrans < 3 || !rtt || !tp->packets_out ||
!tcp_is_sack(tp) || inet_csk(sk)->icsk_ca_state != TCP_CA_Open)
return false;
if ((tp->snd_cwnd > tcp_packets_in_flight(tp)) &&
tcp_send_head(sk))
return false;
/* Probe timeout is at least 1.5*rtt + TCP_DELACK_MAX to account
* for delayed ack when there's one outstanding packet.
*/
timeout = rtt << 1;
if (tp->packets_out == 1)
timeout = max_t(u32, timeout,
(rtt + (rtt >> 1) + TCP_DELACK_MAX));
timeout = max_t(u32, timeout, msecs_to_jiffies(10));
/* If RTO is shorter, just schedule TLP in its place. */
tlp_time_stamp = tcp_time_stamp + timeout;
rto_time_stamp = (u32)inet_csk(sk)->icsk_timeout;
if ((s32)(tlp_time_stamp - rto_time_stamp) > 0) {
s32 delta = rto_time_stamp - tcp_time_stamp;
if (delta > 0)
timeout = delta;
}
inet_csk_reset_xmit_timer(sk, ICSK_TIME_LOSS_PROBE, timeout,
TCP_RTO_MAX);
return true;
}
/* When probe timeout (PTO) fires, send a new segment if one exists, else
* retransmit the last segment.
*/
void tcp_send_loss_probe(struct sock *sk)
{
struct tcp_sock *tp = tcp_sk(sk);
struct sk_buff *skb;
int pcount;
int mss = tcp_current_mss(sk);
int err = -1;
if (tcp_send_head(sk) != NULL) {
err = tcp_write_xmit(sk, mss, TCP_NAGLE_OFF, 2, GFP_ATOMIC);
goto rearm_timer;
}
/* At most one outstanding TLP retransmission. */
if (tp->tlp_high_seq)
goto rearm_timer;
/* Retransmit last segment. */
skb = tcp_write_queue_tail(sk);
if (WARN_ON(!skb))
goto rearm_timer;
pcount = tcp_skb_pcount(skb);
if (WARN_ON(!pcount))
goto rearm_timer;
if ((pcount > 1) && (skb->len > (pcount - 1) * mss)) {
if (unlikely(tcp_fragment(sk, skb, (pcount - 1) * mss, mss)))
goto rearm_timer;
skb = tcp_write_queue_tail(sk);
}
if (WARN_ON(!skb || !tcp_skb_pcount(skb)))
goto rearm_timer;
/* Probe with zero data doesn't trigger fast recovery. */
if (skb->len > 0)
err = __tcp_retransmit_skb(sk, skb);
/* Record snd_nxt for loss detection. */
if (likely(!err))
tp->tlp_high_seq = tp->snd_nxt;
rearm_timer:
inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS,
inet_csk(sk)->icsk_rto,
TCP_RTO_MAX);
if (likely(!err))
NET_INC_STATS_BH(sock_net(sk),
LINUX_MIB_TCPLOSSPROBES);
return;
}
/* Push out any pending frames which were held back due to
* TCP_CORK or attempt at coalescing tiny packets.
* The socket must be locked by the caller.
*/
void __tcp_push_pending_frames(struct sock *sk, unsigned int cur_mss,
int nonagle)
{
/* If we are closed, the bytes will have to remain here.
* In time closedown will finish, we empty the write queue and
* all will be happy.
*/
if (unlikely(sk->sk_state == TCP_CLOSE))
return;
if (tcp_write_xmit(sk, cur_mss, nonagle, 0,
sk_gfp_atomic(sk, GFP_ATOMIC)))
tcp_check_probe_timer(sk);
}
/* Send _single_ skb sitting at the send head. This function requires
* true push pending frames to setup probe timer etc.
*/
void tcp_push_one(struct sock *sk, unsigned int mss_now)
{
struct sk_buff *skb = tcp_send_head(sk);
BUG_ON(!skb || skb->len < mss_now);
tcp_write_xmit(sk, mss_now, TCP_NAGLE_PUSH, 1, sk->sk_allocation);
}
/* This function returns the amount that we can raise the
* usable window based on the following constraints
*
* 1. The window can never be shrunk once it is offered (RFC 793)
* 2. We limit memory per socket
*
* RFC 1122:
* "the suggested [SWS] avoidance algorithm for the receiver is to keep
* RECV.NEXT + RCV.WIN fixed until:
* RCV.BUFF - RCV.USER - RCV.WINDOW >= min(1/2 RCV.BUFF, MSS)"
*
* i.e. don't raise the right edge of the window until you can raise
* it at least MSS bytes.
*
* Unfortunately, the recommended algorithm breaks header prediction,
* since header prediction assumes th->window stays fixed.
*
* Strictly speaking, keeping th->window fixed violates the receiver
* side SWS prevention criteria. The problem is that under this rule
* a stream of single byte packets will cause the right side of the
* window to always advance by a single byte.
*
* Of course, if the sender implements sender side SWS prevention
* then this will not be a problem.
*
* BSD seems to make the following compromise:
*
* If the free space is less than the 1/4 of the maximum
* space available and the free space is less than 1/2 mss,
* then set the window to 0.
* [ Actually, bsd uses MSS and 1/4 of maximal _window_ ]
* Otherwise, just prevent the window from shrinking
* and from being larger than the largest representable value.
*
* This prevents incremental opening of the window in the regime
* where TCP is limited by the speed of the reader side taking
* data out of the TCP receive queue. It does nothing about
* those cases where the window is constrained on the sender side
* because the pipeline is full.
*
* BSD also seems to "accidentally" limit itself to windows that are a
* multiple of MSS, at least until the free space gets quite small.
* This would appear to be a side effect of the mbuf implementation.
* Combining these two algorithms results in the observed behavior
* of having a fixed window size at almost all times.
*
* Below we obtain similar behavior by forcing the offered window to
* a multiple of the mss when it is feasible to do so.
*
* Note, we don't "adjust" for TIMESTAMP or SACK option bytes.
* Regular options like TIMESTAMP are taken into account.
*/
u32 __tcp_select_window(struct sock *sk)
{
struct inet_connection_sock *icsk = inet_csk(sk);
struct tcp_sock *tp = tcp_sk(sk);
/* MSS for the peer's data. Previous versions used mss_clamp
* here. I don't know if the value based on our guesses
* of peer's MSS is better for the performance. It's more correct
* but may be worse for the performance because of rcv_mss
* fluctuations. --SAW 1998/11/1
*/
int mss = icsk->icsk_ack.rcv_mss;
int free_space = tcp_space(sk);
int full_space = min_t(int, tp->window_clamp, tcp_full_space(sk));
int window;
if (tp->mpc)
return __mptcp_select_window(sk);
if (mss > full_space)
mss = full_space;
if (free_space < (full_space >> 1)) {
icsk->icsk_ack.quick = 0;
if (sk_under_memory_pressure(sk))
tp->rcv_ssthresh = min(tp->rcv_ssthresh,
4U * tp->advmss);
if (free_space < mss)
return 0;
}
if (free_space > tp->rcv_ssthresh)
free_space = tp->rcv_ssthresh;
/* Don't do rounding if we are using window scaling, since the
* scaled window will not line up with the MSS boundary anyway.
*/
window = tp->rcv_wnd;
if (tp->rx_opt.rcv_wscale) {
window = free_space;
/* Advertise enough space so that it won't get scaled away.
* Import case: prevent zero window announcement if
* 1<<rcv_wscale > mss.
*/
if (((window >> tp->rx_opt.rcv_wscale) << tp->rx_opt.rcv_wscale) != window)
window = (((window >> tp->rx_opt.rcv_wscale) + 1)
<< tp->rx_opt.rcv_wscale);
} else {
/* Get the largest window that is a nice multiple of mss.
* Window clamp already applied above.
* If our current window offering is within 1 mss of the
* free space we just keep it. This prevents the divide
* and multiply from happening most of the time.
* We also don't do any window rounding when the free space
* is too small.
*/
if (window <= free_space - mss || window > free_space)
window = (free_space / mss) * mss;
else if (mss == full_space &&
free_space > window + (full_space >> 1))
window = free_space;
}
return window;
}
/* Collapses two adjacent SKB's during retransmission. */
static void tcp_collapse_retrans(struct sock *sk, struct sk_buff *skb)
{
struct tcp_sock *tp = tcp_sk(sk);
struct sk_buff *next_skb = tcp_write_queue_next(sk, skb);
int skb_size, next_skb_size;
skb_size = skb->len;
next_skb_size = next_skb->len;
BUG_ON(tcp_skb_pcount(skb) != 1 || tcp_skb_pcount(next_skb) != 1);
tcp_highest_sack_combine(sk, next_skb, skb);
tcp_unlink_write_queue(next_skb, sk);
skb_copy_from_linear_data(next_skb, skb_put(skb, next_skb_size),
next_skb_size);
if (next_skb->ip_summed == CHECKSUM_PARTIAL)
skb->ip_summed = CHECKSUM_PARTIAL;
if (skb->ip_summed != CHECKSUM_PARTIAL)
skb->csum = csum_block_add(skb->csum, next_skb->csum, skb_size);
/* Update sequence range on original skb. */
TCP_SKB_CB(skb)->end_seq = TCP_SKB_CB(next_skb)->end_seq;
/* Merge over control information. This moves PSH/FIN etc. over */
TCP_SKB_CB(skb)->tcp_flags |= TCP_SKB_CB(next_skb)->tcp_flags;
/* All done, get rid of second SKB and account for it so
* packet counting does not break.
*/
TCP_SKB_CB(skb)->sacked |= TCP_SKB_CB(next_skb)->sacked & TCPCB_EVER_RETRANS;
/* changed transmit queue under us so clear hints */
tcp_clear_retrans_hints_partial(tp);
if (next_skb == tp->retransmit_skb_hint)
tp->retransmit_skb_hint = skb;
tcp_adjust_pcount(sk, next_skb, tcp_skb_pcount(next_skb));
sk_wmem_free_skb(sk, next_skb);
}
/* Check if coalescing SKBs is legal. */
static bool tcp_can_collapse(const struct sock *sk, const struct sk_buff *skb)
{
if (tcp_skb_pcount(skb) > 1)
return false;
/* TODO: SACK collapsing could be used to remove this condition */
if (skb_shinfo(skb)->nr_frags != 0)
return false;
if (skb_cloned(skb))
return false;
if (skb == tcp_send_head(sk))
return false;
/* Some heurestics for collapsing over SACK'd could be invented */
if (TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_ACKED)
return false;
return true;
}
/* Collapse packets in the retransmit queue to make to create
* less packets on the wire. This is only done on retransmission.
*/
static void tcp_retrans_try_collapse(struct sock *sk, struct sk_buff *to,
int space)
{
struct tcp_sock *tp = tcp_sk(sk);
struct sk_buff *skb = to, *tmp;
bool first = true;
if (!sysctl_tcp_retrans_collapse)
return;
if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_SYN)
return;
/* Currently not supported for MPTCP - but it should be possible */
if (tp->mpc)
return;
tcp_for_write_queue_from_safe(skb, tmp, sk) {
if (!tcp_can_collapse(sk, skb))
break;
space -= skb->len;
if (first) {
first = false;
continue;
}
if (space < 0)
break;
/* Punt if not enough space exists in the first SKB for
* the data in the second
*/
if (skb->len > skb_availroom(to))
break;
if (after(TCP_SKB_CB(skb)->end_seq, tcp_wnd_end(tp)))
break;
tcp_collapse_retrans(sk, to);
}
}
/* This retransmits one SKB. Policy decisions and retransmit queue
* state updates are done by the caller. Returns non-zero if an
* error occurred which prevented the send.
*/
int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
{
struct tcp_sock *tp = tcp_sk(sk);
struct inet_connection_sock *icsk = inet_csk(sk);
unsigned int cur_mss;
/* Inconslusive MTU probe */
if (icsk->icsk_mtup.probe_size) {
icsk->icsk_mtup.probe_size = 0;
}
/* Do not sent more than we queued. 1/4 is reserved for possible
* copying overhead: fragmentation, tunneling, mangling etc.
*/
if (atomic_read(&sk->sk_wmem_alloc) >
min(sk->sk_wmem_queued + (sk->sk_wmem_queued >> 2), sk->sk_sndbuf))
return -EAGAIN;
if (before(TCP_SKB_CB(skb)->seq, tp->snd_una)) {
if (before(TCP_SKB_CB(skb)->end_seq, tp->snd_una))
BUG();
if (tcp_trim_head(sk, skb, tp->snd_una - TCP_SKB_CB(skb)->seq))
return -ENOMEM;
}
if (inet_csk(sk)->icsk_af_ops->rebuild_header(sk))
return -EHOSTUNREACH; /* Routing failure or similar. */
cur_mss = tcp_current_mss(sk);
/* If receiver has shrunk his window, and skb is out of
* new window, do not retransmit it. The exception is the
* case, when window is shrunk to zero. In this case
* our retransmit serves as a zero window probe.
*/
if (!before(TCP_SKB_CB(skb)->seq, tcp_wnd_end(tp)) &&
TCP_SKB_CB(skb)->seq != tp->snd_una)
return -EAGAIN;
if (skb->len > cur_mss) {
if (tcp_fragment(sk, skb, cur_mss, cur_mss))
return -ENOMEM; /* We'll try again later. */
} else {
int oldpcount = tcp_skb_pcount(skb);
if (unlikely(oldpcount > 1)) {
tcp_init_tso_segs(sk, skb, cur_mss);
tcp_adjust_pcount(sk, skb, oldpcount - tcp_skb_pcount(skb));
}
}
tcp_retrans_try_collapse(sk, skb, cur_mss);
/* Some Solaris stacks overoptimize and ignore the FIN on a
* retransmit when old data is attached. So strip it off
* since it is cheap to do so and saves bytes on the network.
*/
if (skb->len > 0 &&
(TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN) &&
tp->snd_una == (TCP_SKB_CB(skb)->end_seq - 1)) {
if (!pskb_trim(skb, 0)) {
/* Reuse, even though it does some unnecessary work */
tcp_init_nondata_skb(skb, TCP_SKB_CB(skb)->end_seq - 1,
TCP_SKB_CB(skb)->tcp_flags);
skb->ip_summed = CHECKSUM_NONE;
}
}
/* Make a copy, if the first transmission SKB clone we made
* is still in somebody's hands, else make a clone.
*/
TCP_SKB_CB(skb)->when = tcp_time_stamp;
/* make sure skb->data is aligned on arches that require it
* and check if ack-trimming & collapsing extended the headroom
* beyond what csum_start can cover.
*/
if (unlikely((NET_IP_ALIGN && ((unsigned long)skb->data & 3)) ||
skb_headroom(skb) >= 0xFFFF)) {
struct sk_buff *nskb;
if (mptcp_is_data_seq(skb))
skb_push(skb, MPTCP_SUB_LEN_DSS_ALIGN +
MPTCP_SUB_LEN_ACK_ALIGN +
MPTCP_SUB_LEN_SEQ_ALIGN);
nskb = __pskb_copy(skb, MAX_TCP_HEADER, GFP_ATOMIC);
if (mptcp_is_data_seq(skb)) {
skb_pull(skb, MPTCP_SUB_LEN_DSS_ALIGN +
MPTCP_SUB_LEN_ACK_ALIGN +
MPTCP_SUB_LEN_SEQ_ALIGN);
if (nskb)
skb_pull(nskb, MPTCP_SUB_LEN_DSS_ALIGN +
MPTCP_SUB_LEN_ACK_ALIGN +
MPTCP_SUB_LEN_SEQ_ALIGN);
}
return nskb ? tcp_transmit_skb(sk, nskb, 0, GFP_ATOMIC) :
-ENOBUFS;
} else {
return tcp_transmit_skb(sk, skb, 1, GFP_ATOMIC);
}
}
int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
{
struct tcp_sock *tp = tcp_sk(sk);
int err = __tcp_retransmit_skb(sk, skb);
if (err == 0) {
/* Update global TCP statistics. */
TCP_INC_STATS(sock_net(sk), TCP_MIB_RETRANSSEGS);
tp->total_retrans++;
#if FASTRETRANS_DEBUG > 0
if (TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_RETRANS) {
net_dbg_ratelimited("retrans_out leaked\n");
}
#endif
if (!tp->retrans_out)
tp->lost_retrans_low = tp->snd_nxt;
TCP_SKB_CB(skb)->sacked |= TCPCB_RETRANS;
tp->retrans_out += tcp_skb_pcount(skb);
/* Save stamp of the first retransmit. */
if (!tp->retrans_stamp)
tp->retrans_stamp = TCP_SKB_CB(skb)->when;
tp->undo_retrans += tcp_skb_pcount(skb);
/* snd_nxt is stored to detect loss of retransmitted segment,
* see tcp_input.c tcp_sacktag_write_queue().
*/
TCP_SKB_CB(skb)->ack_seq = tp->snd_nxt;
} else {
NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPRETRANSFAIL);
}
return err;
}
/* Check if we forward retransmits are possible in the current
* window/congestion state.
*/
static bool tcp_can_forward_retransmit(struct sock *sk)
{
const struct inet_connection_sock *icsk = inet_csk(sk);
const struct tcp_sock *tp = tcp_sk(sk);
/* Forward retransmissions are possible only during Recovery. */
if (icsk->icsk_ca_state != TCP_CA_Recovery)
return false;
/* No forward retransmissions in Reno are possible. */
if (tcp_is_reno(tp))
return false;
/* Yeah, we have to make difficult choice between forward transmission
* and retransmission... Both ways have their merits...
*
* For now we do not retransmit anything, while we have some new
* segments to send. In the other cases, follow rule 3 for
* NextSeg() specified in RFC3517.
*/
if (tcp_may_send_now(sk))
return false;
return true;
}
/* This gets called after a retransmit timeout, and the initially
* retransmitted data is acknowledged. It tries to continue
* resending the rest of the retransmit queue, until either
* we've sent it all or the congestion window limit is reached.
* If doing SACK, the first ACK which comes back for a timeout
* based retransmit packet might feed us FACK information again.
* If so, we use it to avoid unnecessarily retransmissions.
*/
void tcp_xmit_retransmit_queue(struct sock *sk)
{
const struct inet_connection_sock *icsk = inet_csk(sk);
struct tcp_sock *tp = tcp_sk(sk);
struct sk_buff *skb;
struct sk_buff *hole = NULL;
u32 last_lost;
int mib_idx;
int fwd_rexmitting = 0;
if (!tp->packets_out)
return;
if (!tp->lost_out)
tp->retransmit_high = tp->snd_una;
if (tp->retransmit_skb_hint) {
skb = tp->retransmit_skb_hint;
last_lost = TCP_SKB_CB(skb)->end_seq;
if (after(last_lost, tp->retransmit_high))
last_lost = tp->retransmit_high;
} else {
skb = tcp_write_queue_head(sk);
last_lost = tp->snd_una;
}
tcp_for_write_queue_from(skb, sk) {
__u8 sacked = TCP_SKB_CB(skb)->sacked;
if (skb == tcp_send_head(sk))
break;
/* we could do better than to assign each time */
if (hole == NULL)
tp->retransmit_skb_hint = skb;
/* Assume this retransmit will generate
* only one packet for congestion window
* calculation purposes. This works because
* tcp_retransmit_skb() will chop up the
* packet to be MSS sized and all the
* packet counting works out.
*/
if (tcp_packets_in_flight(tp) >= tp->snd_cwnd)
return;
if (fwd_rexmitting) {
begin_fwd:
if (!before(TCP_SKB_CB(skb)->seq, tcp_highest_sack_seq(tp)))
break;
mib_idx = LINUX_MIB_TCPFORWARDRETRANS;
} else if (!before(TCP_SKB_CB(skb)->seq, tp->retransmit_high)) {
tp->retransmit_high = last_lost;
if (!tcp_can_forward_retransmit(sk))
break;
/* Backtrack if necessary to non-L'ed skb */
if (hole != NULL) {
skb = hole;
hole = NULL;
}
fwd_rexmitting = 1;
goto begin_fwd;
} else if (!(sacked & TCPCB_LOST)) {
if (hole == NULL && !(sacked & (TCPCB_SACKED_RETRANS|TCPCB_SACKED_ACKED)))
hole = skb;
continue;
} else {
last_lost = TCP_SKB_CB(skb)->end_seq;
if (icsk->icsk_ca_state != TCP_CA_Loss)
mib_idx = LINUX_MIB_TCPFASTRETRANS;
else
mib_idx = LINUX_MIB_TCPSLOWSTARTRETRANS;
}
if (sacked & (TCPCB_SACKED_ACKED|TCPCB_SACKED_RETRANS))
continue;
if (tcp_retransmit_skb(sk, skb))
return;
NET_INC_STATS_BH(sock_net(sk), mib_idx);
if (tcp_in_cwnd_reduction(sk))
tp->prr_out += tcp_skb_pcount(skb);
if (skb == tcp_write_queue_head(sk))
inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS,
inet_csk(sk)->icsk_rto,
TCP_RTO_MAX);
}
}
/* Send a fin. The caller locks the socket for us. This cannot be
* allowed to fail queueing a FIN frame under any circumstances.
*/
void tcp_send_fin(struct sock *sk)
{
struct tcp_sock *tp = tcp_sk(sk);
struct sk_buff *skb = tcp_write_queue_tail(sk);
int mss_now;
/* Optimization, tack on the FIN if we have a queue of
* unsent frames. But be careful about outgoing SACKS
* and IP options.
*/
mss_now = tcp_current_mss(sk);
if (tcp_send_head(sk) != NULL) {
TCP_SKB_CB(skb)->tcp_flags |= TCPHDR_FIN;
TCP_SKB_CB(skb)->end_seq++;
tp->write_seq++;
} else {
/* Socket is locked, keep trying until memory is available. */
for (;;) {
skb = alloc_skb_fclone(MAX_TCP_HEADER,
sk->sk_allocation);
if (skb)
break;
yield();
}
/* Reserve space for headers and prepare control bits. */
skb_reserve(skb, MAX_TCP_HEADER);
/* FIN eats a sequence byte, write_seq advanced by tcp_queue_skb(). */
tcp_init_nondata_skb(skb, tp->write_seq,
TCPHDR_ACK | TCPHDR_FIN);
tcp_queue_skb(sk, skb);
}
__tcp_push_pending_frames(sk, mss_now, TCP_NAGLE_OFF);
}
/* We get here when a process closes a file descriptor (either due to
* an explicit close() or as a byproduct of exit()'ing) and there
* was unread data in the receive queue. This behavior is recommended
* by RFC 2525, section 2.17. -DaveM
*/
void tcp_send_active_reset(struct sock *sk, gfp_t priority)
{
struct sk_buff *skb;
if (is_meta_sk(sk)) {
mptcp_send_active_reset(sk, priority);
return;
}
/* NOTE: No TCP options attached and we never retransmit this. */
skb = alloc_skb(MAX_TCP_HEADER, priority);
if (!skb) {
NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTFAILED);
return;
}
/* Reserve space for headers and prepare control bits. */
skb_reserve(skb, MAX_TCP_HEADER);
tcp_init_nondata_skb(skb, tcp_acceptable_seq(sk),
TCPHDR_ACK | TCPHDR_RST);
/* Send it off. */
TCP_SKB_CB(skb)->when = tcp_time_stamp;
if (tcp_transmit_skb(sk, skb, 0, priority))
NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTFAILED);
TCP_INC_STATS(sock_net(sk), TCP_MIB_OUTRSTS);
}
/* Send a crossed SYN-ACK during socket establishment.
* WARNING: This routine must only be called when we have already sent
* a SYN packet that crossed the incoming SYN that caused this routine
* to get called. If this assumption fails then the initial rcv_wnd
* and rcv_wscale values will not be correct.
*/
int tcp_send_synack(struct sock *sk)
{
struct sk_buff *skb;
skb = tcp_write_queue_head(sk);
if (skb == NULL || !(TCP_SKB_CB(skb)->tcp_flags & TCPHDR_SYN)) {
pr_debug("%s: wrong queue state\n", __func__);
return -EFAULT;
}
if (!(TCP_SKB_CB(skb)->tcp_flags & TCPHDR_ACK)) {
if (skb_cloned(skb)) {
struct sk_buff *nskb = skb_copy(skb, GFP_ATOMIC);
if (nskb == NULL)
return -ENOMEM;
tcp_unlink_write_queue(skb, sk);
skb_header_release(nskb);
__tcp_add_write_queue_head(sk, nskb);
sk_wmem_free_skb(sk, skb);
sk->sk_wmem_queued += nskb->truesize;
sk_mem_charge(sk, nskb->truesize);
skb = nskb;
}
TCP_SKB_CB(skb)->tcp_flags |= TCPHDR_ACK;
TCP_ECN_send_synack(tcp_sk(sk), skb);
}
TCP_SKB_CB(skb)->when = tcp_time_stamp;
return tcp_transmit_skb(sk, skb, 1, GFP_ATOMIC);
}
/**
* tcp_make_synack - Prepare a SYN-ACK.
* sk: listener socket
* dst: dst entry attached to the SYNACK
* req: request_sock pointer
*
* Allocate one skb and build a SYNACK packet.
* @dst is consumed : Caller should not use it again.
*/
struct sk_buff *tcp_make_synack(struct sock *sk, struct dst_entry *dst,
struct request_sock *req,
struct tcp_fastopen_cookie *foc)
{
struct tcp_out_options opts;
struct inet_request_sock *ireq = inet_rsk(req);
struct tcp_sock *tp = tcp_sk(sk);
struct tcphdr *th;
struct sk_buff *skb;
struct tcp_md5sig_key *md5;
int tcp_header_size;
int mss;
skb = sock_wmalloc(sk, MAX_TCP_HEADER + 15, 1, GFP_ATOMIC);
if (unlikely(!skb)) {
dst_release(dst);
return NULL;
}
/* Reserve space for headers. */
skb_reserve(skb, MAX_TCP_HEADER);
skb_dst_set(skb, dst);
security_skb_owned_by(skb, sk);
mss = dst_metric_advmss(dst);
if (tp->rx_opt.user_mss && tp->rx_opt.user_mss < mss)
mss = tp->rx_opt.user_mss;
if (req->rcv_wnd == 0) { /* ignored for retransmitted syns */
__u8 rcv_wscale;
/* Set this up on the first call only */
req->window_clamp = tp->window_clamp ? : dst_metric(dst, RTAX_WINDOW);
/* limit the window selection if the user enforce a smaller rx buffer */
if (sk->sk_userlocks & SOCK_RCVBUF_LOCK &&
(req->window_clamp > tcp_full_space(sk) || req->window_clamp == 0))
req->window_clamp = tcp_full_space(sk);
tcp_select_initial_window(tcp_full_space(sk),
mss - (ireq->tstamp_ok ? TCPOLEN_TSTAMP_ALIGNED : 0) -
(tcp_rsk(req)->saw_mpc ? MPTCP_SUB_LEN_DSM_ALIGN : 0),
&req->rcv_wnd,
&req->window_clamp,
ireq->wscale_ok,
&rcv_wscale,
dst_metric(dst, RTAX_INITRWND), sk);
ireq->rcv_wscale = rcv_wscale;
}
memset(&opts, 0, sizeof(opts));
#ifdef CONFIG_SYN_COOKIES
if (unlikely(req->cookie_ts))
TCP_SKB_CB(skb)->when = cookie_init_timestamp(req);
else
#endif
TCP_SKB_CB(skb)->when = tcp_time_stamp;
tcp_header_size = tcp_synack_options(sk, req, mss, skb, &opts, &md5,
foc) + sizeof(*th);
skb_push(skb, tcp_header_size);
skb_reset_transport_header(skb);
th = tcp_hdr(skb);
memset(th, 0, sizeof(struct tcphdr));
th->syn = 1;
th->ack = 1;
TCP_ECN_make_synack(req, th);
th->source = ireq->loc_port;
th->dest = ireq->rmt_port;
/* Setting of flags are superfluous here for callers (and ECE is
* not even correctly set)
*/
tcp_init_nondata_skb(skb, tcp_rsk(req)->snt_isn,
TCPHDR_SYN | TCPHDR_ACK);
th->seq = htonl(TCP_SKB_CB(skb)->seq);
/* XXX data is queued and acked as is. No buffer/window check */
th->ack_seq = htonl(tcp_rsk(req)->rcv_nxt);
/* RFC1323: The window in SYN & SYN/ACK segments is never scaled. */
th->window = htons(min(req->rcv_wnd, 65535U));
tcp_options_write((__be32 *)(th + 1), tp, &opts, skb);
th->doff = (tcp_header_size >> 2);
TCP_ADD_STATS(sock_net(sk), TCP_MIB_OUTSEGS, tcp_skb_pcount(skb));
#ifdef CONFIG_TCP_MD5SIG
/* Okay, we have all we need - do the md5 hash if needed */
if (md5) {
tcp_rsk(req)->af_specific->calc_md5_hash(opts.hash_location,
md5, NULL, req, skb);
}
#endif
return skb;
}
EXPORT_SYMBOL(tcp_make_synack);
/* Do all connect socket setups that can be done AF independent. */
void tcp_connect_init(struct sock *sk)
{
const struct dst_entry *dst = __sk_dst_get(sk);
struct tcp_sock *tp = tcp_sk(sk);
__u8 rcv_wscale;
/* We'll fix this up when we get a response from the other end.
* See tcp_input.c:tcp_rcv_state_process case TCP_SYN_SENT.
*/
tp->tcp_header_len = sizeof(struct tcphdr) +
(sysctl_tcp_timestamps ? TCPOLEN_TSTAMP_ALIGNED : 0);
#ifdef CONFIG_TCP_MD5SIG
if (tp->af_specific->md5_lookup(sk, sk) != NULL)
tp->tcp_header_len += TCPOLEN_MD5SIG_ALIGNED;
#endif
/* If user gave his TCP_MAXSEG, record it to clamp */
if (tp->rx_opt.user_mss)
tp->rx_opt.mss_clamp = tp->rx_opt.user_mss;
tp->max_window = 0;
tcp_mtup_init(sk);
tcp_sync_mss(sk, dst_mtu(dst));
if (!tp->window_clamp)
tp->window_clamp = dst_metric(dst, RTAX_WINDOW);
tp->advmss = dst_metric_advmss(dst);
if (tp->rx_opt.user_mss && tp->rx_opt.user_mss < tp->advmss)
tp->advmss = tp->rx_opt.user_mss;
tcp_initialize_rcv_mss(sk);
/* limit the window selection if the user enforce a smaller rx buffer */
if (sk->sk_userlocks & SOCK_RCVBUF_LOCK &&
(tp->window_clamp > tcp_full_space(sk) || tp->window_clamp == 0))
tp->window_clamp = tcp_full_space(sk);
tcp_select_initial_window(tcp_full_space(sk),
tp->advmss - (tp->rx_opt.ts_recent_stamp ? tp->tcp_header_len - sizeof(struct tcphdr) : 0),
&tp->rcv_wnd,
&tp->window_clamp,
sysctl_tcp_window_scaling,
&rcv_wscale,
dst_metric(dst, RTAX_INITRWND), sk);
tp->rx_opt.rcv_wscale = rcv_wscale;
tp->rcv_ssthresh = tp->rcv_wnd;
sk->sk_err = 0;
sock_reset_flag(sk, SOCK_DONE);
tp->snd_wnd = 0;
tcp_init_wl(tp, 0);
tp->snd_una = tp->write_seq;
tp->snd_sml = tp->write_seq;
tp->snd_up = tp->write_seq;
tp->snd_nxt = tp->write_seq;
if (likely(!tp->repair))
tp->rcv_nxt = 0;
else
tp->rcv_tstamp = tcp_time_stamp;
tp->rcv_wup = tp->rcv_nxt;
tp->copied_seq = tp->rcv_nxt;
inet_csk(sk)->icsk_rto = TCP_TIMEOUT_INIT;
inet_csk(sk)->icsk_retransmits = 0;
tcp_clear_retrans(tp);
#ifdef CONFIG_MPTCP
if (sysctl_mptcp_enabled && mptcp_doit(sk)) {
if (is_master_tp(tp)) {
tp->request_mptcp = 1;
mptcp_connect_init(sk);
} else if (tp->mptcp) {
tp->mptcp->snt_isn = tp->write_seq;
tp->mptcp->init_rcv_wnd = tp->rcv_wnd;
}
}
#endif
}
static void tcp_connect_queue_skb(struct sock *sk, struct sk_buff *skb)
{
struct tcp_sock *tp = tcp_sk(sk);
struct tcp_skb_cb *tcb = TCP_SKB_CB(skb);
tcb->end_seq += skb->len;
skb_header_release(skb);
__tcp_add_write_queue_tail(sk, skb);
sk->sk_wmem_queued += skb->truesize;
sk_mem_charge(sk, skb->truesize);
tp->write_seq = tcb->end_seq;
tp->packets_out += tcp_skb_pcount(skb);
}
/* Build and send a SYN with data and (cached) Fast Open cookie. However,
* queue a data-only packet after the regular SYN, such that regular SYNs
* are retransmitted on timeouts. Also if the remote SYN-ACK acknowledges
* only the SYN sequence, the data are retransmitted in the first ACK.
* If cookie is not cached or other error occurs, falls back to send a
* regular SYN with Fast Open cookie request option.
*/
static int tcp_send_syn_data(struct sock *sk, struct sk_buff *syn)
{
struct tcp_sock *tp = tcp_sk(sk);
struct tcp_fastopen_request *fo = tp->fastopen_req;
int syn_loss = 0, space, i, err = 0, iovlen = fo->data->msg_iovlen;
struct sk_buff *syn_data = NULL, *data;
unsigned long last_syn_loss = 0;
tp->rx_opt.mss_clamp = tp->advmss; /* If MSS is not cached */
tcp_fastopen_cache_get(sk, &tp->rx_opt.mss_clamp, &fo->cookie,
&syn_loss, &last_syn_loss);
/* Recurring FO SYN losses: revert to regular handshake temporarily */
if (syn_loss > 1 &&
time_before(jiffies, last_syn_loss + (60*HZ << syn_loss))) {
fo->cookie.len = -1;
goto fallback;
}
if (sysctl_tcp_fastopen & TFO_CLIENT_NO_COOKIE)
fo->cookie.len = -1;
else if (fo->cookie.len <= 0)
goto fallback;
/* MSS for SYN-data is based on cached MSS and bounded by PMTU and
* user-MSS. Reserve maximum option space for middleboxes that add
* private TCP options. The cost is reduced data space in SYN :(
*/
if (tp->rx_opt.user_mss && tp->rx_opt.user_mss < tp->rx_opt.mss_clamp)
tp->rx_opt.mss_clamp = tp->rx_opt.user_mss;
space = __tcp_mtu_to_mss(sk, inet_csk(sk)->icsk_pmtu_cookie) -
MAX_TCP_OPTION_SPACE;
syn_data = skb_copy_expand(syn, skb_headroom(syn), space,
sk->sk_allocation);
if (syn_data == NULL)
goto fallback;
for (i = 0; i < iovlen && syn_data->len < space; ++i) {
struct iovec *iov = &fo->data->msg_iov[i];
unsigned char __user *from = iov->iov_base;
int len = iov->iov_len;
if (syn_data->len + len > space)
len = space - syn_data->len;
else if (i + 1 == iovlen)
/* No more data pending in inet_wait_for_connect() */
fo->data = NULL;
if (skb_add_data(syn_data, from, len))
goto fallback;
}
/* Queue a data-only packet after the regular SYN for retransmission */
data = pskb_copy(syn_data, sk->sk_allocation);
if (data == NULL)
goto fallback;
TCP_SKB_CB(data)->seq++;
TCP_SKB_CB(data)->tcp_flags &= ~TCPHDR_SYN;
TCP_SKB_CB(data)->tcp_flags = (TCPHDR_ACK|TCPHDR_PSH);
tcp_connect_queue_skb(sk, data);
fo->copied = data->len;
if (tcp_transmit_skb(sk, syn_data, 0, sk->sk_allocation) == 0) {
tp->syn_data = (fo->copied > 0);
NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPFASTOPENACTIVE);
goto done;
}
syn_data = NULL;
fallback:
/* Send a regular SYN with Fast Open cookie request option */
if (fo->cookie.len > 0)
fo->cookie.len = 0;
err = tcp_transmit_skb(sk, syn, 1, sk->sk_allocation);
if (err)
tp->syn_fastopen = 0;
kfree_skb(syn_data);
done:
fo->cookie.len = -1; /* Exclude Fast Open option for SYN retries */
return err;
}
/* Build a SYN and send it off. */
int tcp_connect(struct sock *sk)
{
struct tcp_sock *tp = tcp_sk(sk);
struct sk_buff *buff;
int err;
//printf("cwnd_init:%d\n", tcp_sk(sk)->snd_cwnd);
tcp_connect_init(sk);
if (unlikely(tp->repair)) {
tcp_finish_connect(sk, NULL);
return 0;
}
buff = alloc_skb_fclone(MAX_TCP_HEADER + 15, sk->sk_allocation);
if (unlikely(buff == NULL))
return -ENOBUFS;
/* Reserve space for headers. */
skb_reserve(buff, MAX_TCP_HEADER);
tcp_init_nondata_skb(buff, tp->write_seq++, TCPHDR_SYN);
tp->retrans_stamp = TCP_SKB_CB(buff)->when = tcp_time_stamp;
tcp_connect_queue_skb(sk, buff);
TCP_ECN_send_syn(sk, buff);
//tcp_sk(sk)->snd_cwnd = 0;
//printf("cwnd_init:%d\n", tcp_sk(sk)->snd_cwnd);
/* Send off SYN; include data in Fast Open. */
err = tp->fastopen_req ? tcp_send_syn_data(sk, buff) :
tcp_transmit_skb(sk, buff, 1, sk->sk_allocation);
if (err == -ECONNREFUSED)
return err;
/* We change tp->snd_nxt after the tcp_transmit_skb() call
* in order to make this packet get counted in tcpOutSegs.
*/
tp->snd_nxt = tp->write_seq;
tp->pushed_seq = tp->write_seq;
TCP_INC_STATS(sock_net(sk), TCP_MIB_ACTIVEOPENS);
/* Timer for repeating the SYN until an answer. */
inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS,
inet_csk(sk)->icsk_rto, TCP_RTO_MAX);
return 0;
}
EXPORT_SYMBOL(tcp_connect);
/* Send out a delayed ack, the caller does the policy checking
* to see if we should even be here. See tcp_input.c:tcp_ack_snd_check()
* for details.
*/
void tcp_send_delayed_ack(struct sock *sk)
{
struct inet_connection_sock *icsk = inet_csk(sk);
int ato = icsk->icsk_ack.ato;
unsigned long timeout;
if (ato > TCP_DELACK_MIN) {
const struct tcp_sock *tp = tcp_sk(sk);
int max_ato = HZ / 2;
if (icsk->icsk_ack.pingpong ||
(icsk->icsk_ack.pending & ICSK_ACK_PUSHED))
max_ato = TCP_DELACK_MAX;
/* Slow path, intersegment interval is "high". */
/* If some rtt estimate is known, use it to bound delayed ack.
* Do not use inet_csk(sk)->icsk_rto here, use results of rtt measurements
* directly.
*/
if (tp->srtt) {
int rtt = max(tp->srtt >> 3, TCP_DELACK_MIN);
if (rtt < max_ato)
max_ato = rtt;
}
ato = min(ato, max_ato);
}
/* Stay within the limit we were given */
timeout = jiffies + ato;
/* Use new timeout only if there wasn't a older one earlier. */
if (icsk->icsk_ack.pending & ICSK_ACK_TIMER) {
/* If delack timer was blocked or is about to expire,
* send ACK now.
*/
if (icsk->icsk_ack.blocked ||
time_before_eq(icsk->icsk_ack.timeout, jiffies + (ato >> 2))) {
tcp_send_ack(sk);
return;
}
if (!time_before(timeout, icsk->icsk_ack.timeout))
timeout = icsk->icsk_ack.timeout;
}
icsk->icsk_ack.pending |= ICSK_ACK_SCHED | ICSK_ACK_TIMER;
icsk->icsk_ack.timeout = timeout;
sk_reset_timer(sk, &icsk->icsk_delack_timer, timeout);
}
/* This routine sends an ack and also updates the window. */
void tcp_send_ack(struct sock *sk)
{
struct sk_buff *buff;
/* If we have been reset, we may not send again. */
if (sk->sk_state == TCP_CLOSE)
return;
/* We are not putting this on the write queue, so
* tcp_transmit_skb() will set the ownership to this
* sock.
*/
buff = alloc_skb(MAX_TCP_HEADER, sk_gfp_atomic(sk, GFP_ATOMIC));
if (buff == NULL) {
inet_csk_schedule_ack(sk);
inet_csk(sk)->icsk_ack.ato = TCP_ATO_MIN;
inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK,
TCP_DELACK_MAX, TCP_RTO_MAX);
return;
}
/* Reserve space for headers and prepare control bits. */
skb_reserve(buff, MAX_TCP_HEADER);
tcp_init_nondata_skb(buff, tcp_acceptable_seq(sk), TCPHDR_ACK);
/* Send it off, this clears delayed acks for us. */
TCP_SKB_CB(buff)->when = tcp_time_stamp;
tcp_transmit_skb(sk, buff, 0, sk_gfp_atomic(sk, GFP_ATOMIC));
}
EXPORT_SYMBOL(tcp_send_ack);
/* This routine sends a packet with an out of date sequence
* number. It assumes the other end will try to ack it.
*
* Question: what should we make while urgent mode?
* 4.4BSD forces sending single byte of data. We cannot send
* out of window data, because we have SND.NXT==SND.MAX...
*
* Current solution: to send TWO zero-length segments in urgent mode:
* one is with SEG.SEQ=SND.UNA to deliver urgent pointer, another is
* out-of-date with SND.UNA-1 to probe window.
*/
int tcp_xmit_probe_skb(struct sock *sk, int urgent)
{
struct tcp_sock *tp = tcp_sk(sk);
struct sk_buff *skb;
/* We don't queue it, tcp_transmit_skb() sets ownership. */
skb = alloc_skb(MAX_TCP_HEADER, sk_gfp_atomic(sk, GFP_ATOMIC));
if (skb == NULL)
return -1;
/* Reserve space for headers and set control bits. */
skb_reserve(skb, MAX_TCP_HEADER);
/* Use a previous sequence. This should cause the other
* end to send an ack. Don't queue or clone SKB, just
* send it.
*/
tcp_init_nondata_skb(skb, tp->snd_una - !urgent, TCPHDR_ACK);
TCP_SKB_CB(skb)->when = tcp_time_stamp;
return tcp_transmit_skb(sk, skb, 0, GFP_ATOMIC);
}
void tcp_send_window_probe(struct sock *sk)
{
if (sk->sk_state == TCP_ESTABLISHED) {
tcp_sk(sk)->snd_wl1 = tcp_sk(sk)->rcv_nxt - 1;
tcp_sk(sk)->snd_nxt = tcp_sk(sk)->write_seq;
tcp_xmit_probe_skb(sk, 0);
}
}
/* Initiate keepalive or window probe from timer. */
int tcp_write_wakeup(struct sock *sk)
{
struct tcp_sock *tp = tcp_sk(sk);
struct sk_buff *skb;
if (sk->sk_state == TCP_CLOSE)
return -1;
if (is_meta_sk(sk))
return mptcp_write_wakeup(sk);
if ((skb = tcp_send_head(sk)) != NULL &&
before(TCP_SKB_CB(skb)->seq, tcp_wnd_end(tp))) {
int err;
unsigned int mss = tcp_current_mss(sk);
unsigned int seg_size = tcp_wnd_end(tp) - TCP_SKB_CB(skb)->seq;
if (before(tp->pushed_seq, TCP_SKB_CB(skb)->end_seq))
tp->pushed_seq = TCP_SKB_CB(skb)->end_seq;
/* We are probing the opening of a window
* but the window size is != 0
* must have been a result SWS avoidance ( sender )
*/
if (seg_size < TCP_SKB_CB(skb)->end_seq - TCP_SKB_CB(skb)->seq ||
skb->len > mss) {
seg_size = min(seg_size, mss);
TCP_SKB_CB(skb)->tcp_flags |= TCPHDR_PSH;
if (tcp_fragment(sk, skb, seg_size, mss))
return -1;
} else if (!tcp_skb_pcount(skb))
tcp_set_skb_tso_segs(sk, skb, mss);
TCP_SKB_CB(skb)->tcp_flags |= TCPHDR_PSH;
TCP_SKB_CB(skb)->when = tcp_time_stamp;
err = tcp_transmit_skb(sk, skb, 1, GFP_ATOMIC);
if (!err)
tcp_event_new_data_sent(sk, skb);
return err;
} else {
if (between(tp->snd_up, tp->snd_una + 1, tp->snd_una + 0xFFFF))
tcp_xmit_probe_skb(sk, 1);
return tcp_xmit_probe_skb(sk, 0);
}
}
/* A window probe timeout has occurred. If window is not closed send
* a partial packet else a zero probe.
*/
void tcp_send_probe0(struct sock *sk)
{
struct inet_connection_sock *icsk = inet_csk(sk);
struct tcp_sock *tp = tcp_sk(sk);
int err;
err = tcp_write_wakeup(sk);
if (tp->packets_out || !tcp_send_head(sk)) {
/* Cancel probe timer, if it is not required. */
icsk->icsk_probes_out = 0;
icsk->icsk_backoff = 0;
return;
}
if (err <= 0) {
if (icsk->icsk_backoff < sysctl_tcp_retries2)
icsk->icsk_backoff++;
icsk->icsk_probes_out++;
inet_csk_reset_xmit_timer(sk, ICSK_TIME_PROBE0,
min(icsk->icsk_rto << icsk->icsk_backoff, TCP_RTO_MAX),
TCP_RTO_MAX);
} else {
/* If packet was not sent due to local congestion,
* do not backoff and do not remember icsk_probes_out.
* Let local senders to fight for local resources.
*
* Use accumulated backoff yet.
*/
if (!icsk->icsk_probes_out)
icsk->icsk_probes_out = 1;
inet_csk_reset_xmit_timer(sk, ICSK_TIME_PROBE0,
min(icsk->icsk_rto << icsk->icsk_backoff,
TCP_RESOURCE_PROBE_INTERVAL),
TCP_RTO_MAX);
}
}
| ShogoFujii/PS-MPTCP | net/ipv4/tcp_output.c | C | gpl-2.0 | 99,138 |
/* Copyright (C) 2005-2006 Jean-Marc Valin
File: fftwrap.c
Wrapper for various FFTs
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
/*#define USE_SMALLFT*/
#define USE_KISS_FFT
#include "misc.h"
#define MAX_FFT_SIZE 2048
#ifdef FIXED_POINT
static int maximize_range(spx_word16_t *in, spx_word16_t *out, spx_word16_t bound, int len)
{
int i, shift;
spx_word16_t max_val = 0;
for (i=0;i<len;i++)
{
if (in[i]>max_val)
max_val = in[i];
if (-in[i]>max_val)
max_val = -in[i];
}
shift=0;
while (max_val <= (bound>>1) && max_val != 0)
{
max_val <<= 1;
shift++;
}
for (i=0;i<len;i++)
{
out[i] = in[i] << shift;
}
return shift;
}
static void renorm_range(spx_word16_t *in, spx_word16_t *out, int shift, int len)
{
int i;
for (i=0;i<len;i++)
{
out[i] = (in[i] + (1<<(shift-1))) >> shift;
}
}
#endif
#ifdef USE_SMALLFT
#include "smallft.h"
#include <math.h>
void *spx_fft_init(int size)
{
struct drft_lookup *table;
table = speex_alloc(sizeof(struct drft_lookup));
spx_drft_init((struct drft_lookup *)table, size);
return (void*)table;
}
void spx_fft_destroy(void *table)
{
spx_drft_clear(table);
speex_free(table);
}
void spx_fft(void *table, float *in, float *out)
{
if (in==out)
{
int i;
speex_warning("FFT should not be done in-place");
float scale = 1./((struct drft_lookup *)table)->n;
for (i=0;i<((struct drft_lookup *)table)->n;i++)
out[i] = scale*in[i];
} else {
int i;
float scale = 1./((struct drft_lookup *)table)->n;
for (i=0;i<((struct drft_lookup *)table)->n;i++)
out[i] = scale*in[i];
}
spx_drft_forward((struct drft_lookup *)table, out);
}
void spx_ifft(void *table, float *in, float *out)
{
if (in==out)
{
int i;
speex_warning("FFT should not be done in-place");
} else {
int i;
for (i=0;i<((struct drft_lookup *)table)->n;i++)
out[i] = in[i];
}
spx_drft_backward((struct drft_lookup *)table, out);
}
#elif defined(USE_KISS_FFT)
#include "kiss_fftr.h"
#include "kiss_fft.h"
struct kiss_config {
kiss_fftr_cfg forward;
kiss_fftr_cfg backward;
kiss_fft_cpx *freq_data;
int N;
};
void *spx_fft_init(int size)
{
struct kiss_config *table;
table = (struct kiss_config*)speex_alloc(sizeof(struct kiss_config));
table->freq_data = (kiss_fft_cpx*)speex_alloc(sizeof(kiss_fft_cpx)*((size>>1)+1));
table->forward = kiss_fftr_alloc(size,0,NULL,NULL);
table->backward = kiss_fftr_alloc(size,1,NULL,NULL);
table->N = size;
return table;
}
void spx_fft_destroy(void *table)
{
struct kiss_config *t = (struct kiss_config *)table;
kiss_fftr_free(t->forward);
kiss_fftr_free(t->backward);
speex_free(t->freq_data);
speex_free(table);
}
#ifdef FIXED_POINT
void spx_fft(void *table, spx_word16_t *in, spx_word16_t *out)
{
int i;
int shift;
struct kiss_config *t = (struct kiss_config *)table;
shift = maximize_range(in, in, 32000, t->N);
kiss_fftr(t->forward, in, t->freq_data);
out[0] = t->freq_data[0].r;
for (i=1;i<t->N>>1;i++)
{
out[(i<<1)-1] = t->freq_data[i].r;
out[(i<<1)] = t->freq_data[i].i;
}
out[(i<<1)-1] = t->freq_data[i].r;
renorm_range(in, in, shift, t->N);
renorm_range(out, out, shift, t->N);
}
#else
void spx_fft(void *table, spx_word16_t *in, spx_word16_t *out)
{
int i;
float scale;
struct kiss_config *t = (struct kiss_config *)table;
scale = 1./t->N;
kiss_fftr(t->forward, in, t->freq_data);
out[0] = scale*t->freq_data[0].r;
for (i=1;i<t->N>>1;i++)
{
out[(i<<1)-1] = scale*t->freq_data[i].r;
out[(i<<1)] = scale*t->freq_data[i].i;
}
out[(i<<1)-1] = scale*t->freq_data[i].r;
}
#endif
void spx_ifft(void *table, spx_word16_t *in, spx_word16_t *out)
{
int i;
struct kiss_config *t = (struct kiss_config *)table;
t->freq_data[0].r = in[0];
t->freq_data[0].i = 0;
for (i=1;i<t->N>>1;i++)
{
t->freq_data[i].r = in[(i<<1)-1];
t->freq_data[i].i = in[(i<<1)];
}
t->freq_data[i].r = in[(i<<1)-1];
t->freq_data[i].i = 0;
kiss_fftri(t->backward, t->freq_data, out);
}
#else
#error No other FFT implemented
#endif
#ifdef FIXED_POINT
/*#include "smallft.h"*/
void spx_fft_float(void *table, float *in, float *out)
{
int i;
#ifdef USE_SMALLFT
int N = ((struct drft_lookup *)table)->n;
#elif defined(USE_KISS_FFT)
int N = ((struct kiss_config *)table)->N;
#else
#endif
#ifdef VAR_ARRAYS
spx_word16_t _in[N];
spx_word16_t _out[N];
#else
spx_word16_t _in[MAX_FFT_SIZE];
spx_word16_t _out[MAX_FFT_SIZE];
#endif
for (i=0;i<N;i++)
_in[i] = (int)floor(.5+in[i]);
spx_fft(table, _in, _out);
for (i=0;i<N;i++)
out[i] = _out[i];
#if 0
if (!fixed_point)
{
float scale;
struct drft_lookup t;
spx_drft_init(&t, ((struct kiss_config *)table)->N);
scale = 1./((struct kiss_config *)table)->N;
for (i=0;i<((struct kiss_config *)table)->N;i++)
out[i] = scale*in[i];
spx_drft_forward(&t, out);
spx_drft_clear(&t);
}
#endif
}
void spx_ifft_float(void *table, float *in, float *out)
{
int i;
#ifdef USE_SMALLFT
int N = ((struct drft_lookup *)table)->n;
#elif defined(USE_KISS_FFT)
int N = ((struct kiss_config *)table)->N;
#else
#endif
#ifdef VAR_ARRAYS
spx_word16_t _in[N];
spx_word16_t _out[N];
#else
spx_word16_t _in[MAX_FFT_SIZE];
spx_word16_t _out[MAX_FFT_SIZE];
#endif
for (i=0;i<N;i++)
_in[i] = (int)floor(.5+in[i]);
spx_ifft(table, _in, _out);
for (i=0;i<N;i++)
out[i] = _out[i];
#if 0
if (!fixed_point)
{
int i;
struct drft_lookup t;
spx_drft_init(&t, ((struct kiss_config *)table)->N);
for (i=0;i<((struct kiss_config *)table)->N;i++)
out[i] = in[i];
spx_drft_backward(&t, out);
spx_drft_clear(&t);
}
#endif
}
#else
void spx_fft_float(void *table, float *in, float *out)
{
spx_fft(table, in, out);
}
void spx_ifft_float(void *table, float *in, float *out)
{
spx_ifft(table, in, out);
}
#endif
| gabrieldelsaint/uol-messenger | src/libuolfone/wengophone-ng/current/wifo/phapi/speex/libspeex/fftwrap.c | C | gpl-2.0 | 7,664 |
#!/usr/bin/python2.3
# This is the short name of the plugin, used as the menu item
# for the plugin.
# If not specified, the name of the file will be used.
shortname = "Moment Curve layout (Cohen et al. 1995)"
# This is the long name of the plugin, used as the menu note
# for the plugin.
# If not specified, the short name will be used.
name = "Moment Curve layout, O(n^3)"
DEBUG = False
def run(context, UI):
"""
Run this plugin.
"""
if len(context.graph.vertices) < 1:
generate = True
else:
res = UI.prYesNo("Use current graph?",
"Would you like to apply the layout to the current graph? If not, a complete graph will be generated and the current graph cleared.")
if res:
generate = False
# Go through and eliminate any existing bend points
from graph import DummyVertex
for v in [x for x in context.graph.vertices if isinstance(x, DummyVertex)]:
context.graph.removeVertex(v)
else:
generate = True
if generate:
N = UI.prType("Number of Vertices", "Input number of vertices to generate complete graph:", int, 4)
if N == None:
return True
while N < 0:
N = UI.prType("Number of Vertices",
"Please input positive value.\n\nInput number of vertices to generate complete graph:", int,
N)
if N == None:
return True
context.graph.clear()
# Generate a complete graph
k_n(context, N)
res = UI.prYesNo("Use mod-p layout?",
"Would you like to use the mod-p compact layout (O(n^3) volume)? If not, the O(n^6) uncompacted layout will be used.")
# Lay it out according to the 1bend layout
moment(context, compact=res)
context.camera.lookAtGraph(context.graph, context.graph.centerOfMass(), offset=context.graph.viewpoint())
return True
def k_n(C, n):
"""
k_n (C, n) -> void
Create a complete graph on n vertices in context C.
"""
from graph import Vertex, DummyVertex
G = C.graph
G.clear()
# Add n vertices
for i in range(n):
G.addVertex(Vertex(id='%d' % i, name='v%d' % i))
# For every pair of vertices (u, v):
for u in G.vertices:
for v in G.vertices:
# ignoring duplicates and u==v
if (u, v) not in G.edges and (v, u) not in G.edges and u != v:
# add an edge between u and v
G.addEdge((u, v))
def moment(C, compact=False):
"""
Run moment curve layout (Cohen, Eades, Lin, Ruskey 1995).
"""
G = C.graph
from math import sqrt, ceil, floor
from graph import DummyVertex, GraphError
import colorsys
vertices = [x for x in G.vertices if not isinstance(x, DummyVertex)]
n = len(vertices)
# Choose a prime p with n < p <= 2n
for p in range(n + 1, 2 * n + 1):
for div in range(2, p / 2):
if p % div == 0:
# print "%d is not a prime (div by %d)" % (p, div)
break
else:
# We did not find a divisor
# print "%d is a prime!" % p
break
else:
# Can't happen!
raise Exception, "Can't find a prime between %d and %d!" % (n + 1, 2 * n)
# Position each vertex
if compact:
for i in range(n):
G.modVertex(vertices[i]).pos = (i * 10, ((i * i) % p) * 10, ((i * i * i) % p) * 10)
else:
for i in range(n):
G.modVertex(vertices[i]).pos = (i, (i * i), (i * i * i))
return
| ulethHCI/GLuskap | plugins/moment_curve.py | Python | gpl-2.0 | 3,644 |
/*
* IPv6 Address [auto]configuration
* Linux INET6 implementation
*
* Authors:
* Pedro Roque <[email protected]>
* Alexey Kuznetsov <[email protected]>
*
* This program 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 of the License, or (at your option) any later version.
*/
/*
* Changes:
*
* Janos Farkas : delete timer on ifdown
* <[email protected]>
* Andi Kleen : kill double kfree on module
* unload.
* Maciej W. Rozycki : FDDI support
* sekiya@USAGI : Don't send too many RS
* packets.
* yoshfuji@USAGI : Fixed interval between DAD
* packets.
* YOSHIFUJI Hideaki @USAGI : improved accuracy of
* address validation timer.
* YOSHIFUJI Hideaki @USAGI : Privacy Extensions (RFC3041)
* support.
* Yuji SEKIYA @USAGI : Don't assign a same IPv6
* address on a same interface.
* YOSHIFUJI Hideaki @USAGI : ARCnet support
* YOSHIFUJI Hideaki @USAGI : convert /proc/net/if_inet6 to
* seq_file.
* YOSHIFUJI Hideaki @USAGI : improved source address
* selection; consider scope,
* status etc.
* Harout S. Hedeshian : procfs flag to toggle automatic
* addition of prefix route
*/
#include <linux/errno.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/socket.h>
#include <linux/sockios.h>
#include <linux/net.h>
#include <linux/in6.h>
#include <linux/netdevice.h>
#include <linux/if_addr.h>
#include <linux/if_arp.h>
#include <linux/if_arcnet.h>
#include <linux/if_infiniband.h>
#include <linux/route.h>
#include <linux/inetdevice.h>
#include <linux/init.h>
#include <linux/slab.h>
#ifdef CONFIG_SYSCTL
#include <linux/sysctl.h>
#endif
#include <linux/capability.h>
#include <linux/delay.h>
#include <linux/notifier.h>
#include <linux/string.h>
#include <net/net_namespace.h>
#include <net/sock.h>
#include <net/snmp.h>
#include <net/ipv6.h>
#include <net/protocol.h>
#include <net/ndisc.h>
#include <net/ip6_route.h>
#include <net/addrconf.h>
#include <net/tcp.h>
#include <net/ip.h>
#include <net/netlink.h>
#include <net/pkt_sched.h>
#include <linux/if_tunnel.h>
#include <linux/rtnetlink.h>
#ifdef CONFIG_IPV6_PRIVACY
#include <linux/random.h>
#endif
#include <linux/uaccess.h>
#include <asm/unaligned.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/export.h>
/* Set to 3 to get tracing... */
//
//#define ACONF_DEBUG 2 // The original value.
#define ACONF_DEBUG 2 // To debug...
// LGE_CHANGE_E, [LGE_DATA][LGP_DATA_TCPIP_SLAAC_IPV6_ALLOCATION_BOOSTER], [email protected], 2013-05-21
#if ACONF_DEBUG >= 3
#define ADBG(x) printk x
#else
#define ADBG(x)
#endif
#define INFINITY_LIFE_TIME 0xFFFFFFFF
//
//The value of global scope is 1.
//The value of link-local scope is 33.
#ifdef CONFIG_LGP_DATA_TCPIP_SLAAC_IPV6_ALLOCATION_BOOSTER
#define LGE_DATA_GLOBAL_SCOPE 1
#define LGE_DATA_LINK_LOCAL_SCOPE 33
//The value which is 100 equals 1 second.
//So value which is 5 equals 50 milli-seconds.
//The 50 milli-seconds is requirements of LGU+.
#define LGE_DATA_WAITING_TIME_FOR_DAD_OF_LGU 5
#endif
//
static inline u32 cstamp_delta(unsigned long cstamp)
{
return (cstamp - INITIAL_JIFFIES) * 100UL / HZ;
}
#define ADDRCONF_TIMER_FUZZ_MINUS (HZ > 50 ? HZ/50 : 1)
#define ADDRCONF_TIMER_FUZZ (HZ / 4)
#define ADDRCONF_TIMER_FUZZ_MAX (HZ)
#ifdef CONFIG_SYSCTL
static void addrconf_sysctl_register(struct inet6_dev *idev);
static void addrconf_sysctl_unregister(struct inet6_dev *idev);
#else
static inline void addrconf_sysctl_register(struct inet6_dev *idev)
{
}
static inline void addrconf_sysctl_unregister(struct inet6_dev *idev)
{
}
#endif
#ifdef CONFIG_IPV6_PRIVACY
static int __ipv6_regen_rndid(struct inet6_dev *idev);
static int __ipv6_try_regen_rndid(struct inet6_dev *idev, struct in6_addr *tmpaddr);
static void ipv6_regen_rndid(unsigned long data);
#endif
static int ipv6_generate_eui64(u8 *eui, struct net_device *dev);
static int ipv6_count_addresses(struct inet6_dev *idev);
/*
* Configured unicast address hash table
*/
static struct hlist_head inet6_addr_lst[IN6_ADDR_HSIZE];
static DEFINE_SPINLOCK(addrconf_hash_lock);
static void addrconf_verify(unsigned long);
static DEFINE_TIMER(addr_chk_timer, addrconf_verify, 0, 0);
static DEFINE_SPINLOCK(addrconf_verify_lock);
static void addrconf_join_anycast(struct inet6_ifaddr *ifp);
static void addrconf_leave_anycast(struct inet6_ifaddr *ifp);
static void addrconf_type_change(struct net_device *dev,
unsigned long event);
static int addrconf_ifdown(struct net_device *dev, int how);
static void addrconf_dad_start(struct inet6_ifaddr *ifp, u32 flags);
static void addrconf_dad_timer(unsigned long data);
static void addrconf_dad_completed(struct inet6_ifaddr *ifp);
static void addrconf_dad_run(struct inet6_dev *idev);
static void addrconf_rs_timer(unsigned long data);
static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifa);
static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifa);
static void inet6_prefix_notify(int event, struct inet6_dev *idev,
struct prefix_info *pinfo);
static bool ipv6_chk_same_addr(struct net *net, const struct in6_addr *addr,
struct net_device *dev);
static ATOMIC_NOTIFIER_HEAD(inet6addr_chain);
static struct ipv6_devconf ipv6_devconf __read_mostly = {
.forwarding = 0,
.hop_limit = IPV6_DEFAULT_HOPLIMIT,
.mtu6 = IPV6_MIN_MTU,
.accept_ra = 1,
.accept_redirects = 1,
.autoconf = 1,
.force_mld_version = 0,
.dad_transmits = 1,
.rtr_solicits = MAX_RTR_SOLICITATIONS,
.rtr_solicit_interval = RTR_SOLICITATION_INTERVAL,
.rtr_solicit_delay = MAX_RTR_SOLICITATION_DELAY,
#ifdef CONFIG_IPV6_PRIVACY
.use_tempaddr = 0,
.temp_valid_lft = TEMP_VALID_LIFETIME,
.temp_prefered_lft = TEMP_PREFERRED_LIFETIME,
.regen_max_retry = REGEN_MAX_RETRY,
.max_desync_factor = MAX_DESYNC_FACTOR,
#endif
.max_addresses = IPV6_MAX_ADDRESSES,
.accept_ra_defrtr = 1,
.accept_ra_pinfo = 1,
#ifdef CONFIG_LGE_DHCPV6_WIFI
.ra_info_flag = 0,
#endif
#ifdef CONFIG_IPV6_ROUTER_PREF
.accept_ra_rtr_pref = 1,
.rtr_probe_interval = 60 * HZ,
#ifdef CONFIG_IPV6_ROUTE_INFO
.accept_ra_rt_info_max_plen = 0,
#endif
#endif
.accept_ra_rt_table = 0,
.proxy_ndp = 0,
.accept_source_route = 0, /* we do not accept RH0 by default. */
.disable_ipv6 = 0,
.accept_dad = 1,
.accept_ra_prefix_route = 1,
};
static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = {
.forwarding = 0,
.hop_limit = IPV6_DEFAULT_HOPLIMIT,
.mtu6 = IPV6_MIN_MTU,
.accept_ra = 1,
.accept_redirects = 1,
.autoconf = 1,
.dad_transmits = 1,
.rtr_solicits = MAX_RTR_SOLICITATIONS,
.rtr_solicit_interval = RTR_SOLICITATION_INTERVAL,
.rtr_solicit_delay = MAX_RTR_SOLICITATION_DELAY,
#ifdef CONFIG_IPV6_PRIVACY
.use_tempaddr = 0,
.temp_valid_lft = TEMP_VALID_LIFETIME,
.temp_prefered_lft = TEMP_PREFERRED_LIFETIME,
.regen_max_retry = REGEN_MAX_RETRY,
.max_desync_factor = MAX_DESYNC_FACTOR,
#endif
.max_addresses = IPV6_MAX_ADDRESSES,
.accept_ra_defrtr = 1,
.accept_ra_pinfo = 1,
#ifdef CONFIG_LGE_DHCPV6_WIFI
.ra_info_flag = 0,
#endif
#ifdef CONFIG_IPV6_ROUTER_PREF
.accept_ra_rtr_pref = 1,
.rtr_probe_interval = 60 * HZ,
#ifdef CONFIG_IPV6_ROUTE_INFO
.accept_ra_rt_info_max_plen = 0,
#endif
#endif
.accept_ra_rt_table = 0,
.proxy_ndp = 0,
.accept_source_route = 0, /* we do not accept RH0 by default. */
.disable_ipv6 = 0,
.accept_dad = 1,
.accept_ra_prefix_route = 1,
};
/* IPv6 Wildcard Address and Loopback Address defined by RFC2553 */
const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;
const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT;
const struct in6_addr in6addr_linklocal_allnodes = IN6ADDR_LINKLOCAL_ALLNODES_INIT;
const struct in6_addr in6addr_linklocal_allrouters = IN6ADDR_LINKLOCAL_ALLROUTERS_INIT;
/* Check if a valid qdisc is available */
static inline bool addrconf_qdisc_ok(const struct net_device *dev)
{
return !qdisc_tx_is_noop(dev);
}
/* Check if a route is valid prefix route */
static inline int addrconf_is_prefix_route(const struct rt6_info *rt)
{
return (rt->rt6i_flags & (RTF_GATEWAY | RTF_DEFAULT)) == 0;
}
static void addrconf_del_timer(struct inet6_ifaddr *ifp)
{
if (del_timer(&ifp->timer))
__in6_ifa_put(ifp);
}
enum addrconf_timer_t {
AC_NONE,
AC_DAD,
AC_RS,
};
static void addrconf_mod_timer(struct inet6_ifaddr *ifp,
enum addrconf_timer_t what,
unsigned long when)
{
if (!del_timer(&ifp->timer))
in6_ifa_hold(ifp);
switch (what) {
case AC_DAD:
ifp->timer.function = addrconf_dad_timer;
break;
case AC_RS:
ifp->timer.function = addrconf_rs_timer;
break;
default:
break;
}
ifp->timer.expires = jiffies + when;
add_timer(&ifp->timer);
}
static int snmp6_alloc_dev(struct inet6_dev *idev)
{
if (snmp_mib_init((void __percpu **)idev->stats.ipv6,
sizeof(struct ipstats_mib),
__alignof__(struct ipstats_mib)) < 0)
goto err_ip;
idev->stats.icmpv6dev = kzalloc(sizeof(struct icmpv6_mib_device),
GFP_KERNEL);
if (!idev->stats.icmpv6dev)
goto err_icmp;
idev->stats.icmpv6msgdev = kzalloc(sizeof(struct icmpv6msg_mib_device),
GFP_KERNEL);
if (!idev->stats.icmpv6msgdev)
goto err_icmpmsg;
return 0;
err_icmpmsg:
kfree(idev->stats.icmpv6dev);
err_icmp:
snmp_mib_free((void __percpu **)idev->stats.ipv6);
err_ip:
return -ENOMEM;
}
static void snmp6_free_dev(struct inet6_dev *idev)
{
kfree(idev->stats.icmpv6msgdev);
kfree(idev->stats.icmpv6dev);
snmp_mib_free((void __percpu **)idev->stats.ipv6);
}
/* Nobody refers to this device, we may destroy it. */
void in6_dev_finish_destroy(struct inet6_dev *idev)
{
struct net_device *dev = idev->dev;
WARN_ON(!list_empty(&idev->addr_list));
WARN_ON(idev->mc_list != NULL);
#ifdef NET_REFCNT_DEBUG
printk(KERN_DEBUG "in6_dev_finish_destroy: %s\n", dev ? dev->name : "NIL");
#endif
dev_put(dev);
if (!idev->dead) {
pr_warning("Freeing alive inet6 device %p\n", idev);
return;
}
snmp6_free_dev(idev);
kfree_rcu(idev, rcu);
}
EXPORT_SYMBOL(in6_dev_finish_destroy);
static struct inet6_dev * ipv6_add_dev(struct net_device *dev)
{
struct inet6_dev *ndev;
ASSERT_RTNL();
if (dev->mtu < IPV6_MIN_MTU)
return NULL;
ndev = kzalloc(sizeof(struct inet6_dev), GFP_KERNEL);
if (ndev == NULL)
return NULL;
rwlock_init(&ndev->lock);
ndev->dev = dev;
INIT_LIST_HEAD(&ndev->addr_list);
memcpy(&ndev->cnf, dev_net(dev)->ipv6.devconf_dflt, sizeof(ndev->cnf));
ndev->cnf.mtu6 = dev->mtu;
ndev->cnf.sysctl = NULL;
ndev->nd_parms = neigh_parms_alloc(dev, &nd_tbl);
if (ndev->nd_parms == NULL) {
kfree(ndev);
return NULL;
}
if (ndev->cnf.forwarding)
dev_disable_lro(dev);
/* We refer to the device */
dev_hold(dev);
if (snmp6_alloc_dev(ndev) < 0) {
ADBG((KERN_WARNING
"%s(): cannot allocate memory for statistics; dev=%s.\n",
__func__, dev->name));
neigh_parms_release(&nd_tbl, ndev->nd_parms);
dev_put(dev);
kfree(ndev);
return NULL;
}
if (snmp6_register_dev(ndev) < 0) {
ADBG((KERN_WARNING
"%s(): cannot create /proc/net/dev_snmp6/%s\n",
__func__, dev->name));
neigh_parms_release(&nd_tbl, ndev->nd_parms);
ndev->dead = 1;
in6_dev_finish_destroy(ndev);
return NULL;
}
/* One reference from device. We must do this before
* we invoke __ipv6_regen_rndid().
*/
in6_dev_hold(ndev);
if (dev->flags & (IFF_NOARP | IFF_LOOPBACK))
ndev->cnf.accept_dad = -1;
#if defined(CONFIG_IPV6_SIT) || defined(CONFIG_IPV6_SIT_MODULE)
if (dev->type == ARPHRD_SIT && (dev->priv_flags & IFF_ISATAP)) {
printk(KERN_INFO
"%s: Disabled Multicast RS\n",
dev->name);
ndev->cnf.rtr_solicits = 0;
}
#endif
#ifdef CONFIG_IPV6_PRIVACY
INIT_LIST_HEAD(&ndev->tempaddr_list);
setup_timer(&ndev->regen_timer, ipv6_regen_rndid, (unsigned long)ndev);
if ((dev->flags&IFF_LOOPBACK) ||
dev->type == ARPHRD_TUNNEL ||
dev->type == ARPHRD_TUNNEL6 ||
dev->type == ARPHRD_SIT ||
dev->type == ARPHRD_NONE) {
ndev->cnf.use_tempaddr = -1;
} else {
in6_dev_hold(ndev);
ipv6_regen_rndid((unsigned long) ndev);
}
#endif
if (netif_running(dev) && addrconf_qdisc_ok(dev))
ndev->if_flags |= IF_READY;
ipv6_mc_init_dev(ndev);
ndev->tstamp = jiffies;
addrconf_sysctl_register(ndev);
/* protected by rtnl_lock */
rcu_assign_pointer(dev->ip6_ptr, ndev);
/* Join all-node multicast group */
ipv6_dev_mc_inc(dev, &in6addr_linklocal_allnodes);
/* Join all-router multicast group if forwarding is set */
if (ndev->cnf.forwarding && (dev->flags & IFF_MULTICAST))
ipv6_dev_mc_inc(dev, &in6addr_linklocal_allrouters);
return ndev;
}
static struct inet6_dev * ipv6_find_idev(struct net_device *dev)
{
struct inet6_dev *idev;
ASSERT_RTNL();
idev = __in6_dev_get(dev);
if (!idev) {
idev = ipv6_add_dev(dev);
if (!idev)
return NULL;
}
if (dev->flags&IFF_UP)
ipv6_mc_up(idev);
return idev;
}
#ifdef CONFIG_SYSCTL
static void dev_forward_change(struct inet6_dev *idev)
{
struct net_device *dev;
struct inet6_ifaddr *ifa;
if (!idev)
return;
dev = idev->dev;
if (idev->cnf.forwarding)
dev_disable_lro(dev);
if (dev && (dev->flags & IFF_MULTICAST)) {
if (idev->cnf.forwarding)
ipv6_dev_mc_inc(dev, &in6addr_linklocal_allrouters);
else
ipv6_dev_mc_dec(dev, &in6addr_linklocal_allrouters);
}
list_for_each_entry(ifa, &idev->addr_list, if_list) {
if (ifa->flags&IFA_F_TENTATIVE)
continue;
if (idev->cnf.forwarding)
addrconf_join_anycast(ifa);
else
addrconf_leave_anycast(ifa);
}
}
static void addrconf_forward_change(struct net *net, __s32 newf)
{
struct net_device *dev;
struct inet6_dev *idev;
for_each_netdev(net, dev) {
idev = __in6_dev_get(dev);
if (idev) {
int changed = (!idev->cnf.forwarding) ^ (!newf);
idev->cnf.forwarding = newf;
if (changed)
dev_forward_change(idev);
}
}
}
static int addrconf_fixup_forwarding(struct ctl_table *table, int *p, int newf)
{
struct net *net;
int old;
if (!rtnl_trylock())
return restart_syscall();
net = (struct net *)table->extra2;
old = *p;
*p = newf;
if (p == &net->ipv6.devconf_dflt->forwarding) {
rtnl_unlock();
return 0;
}
if (p == &net->ipv6.devconf_all->forwarding) {
net->ipv6.devconf_dflt->forwarding = newf;
addrconf_forward_change(net, newf);
} else if ((!newf) ^ (!old))
dev_forward_change((struct inet6_dev *)table->extra1);
rtnl_unlock();
if (newf)
rt6_purge_dflt_routers(net);
return 1;
}
#endif
/* Nobody refers to this ifaddr, destroy it */
void inet6_ifa_finish_destroy(struct inet6_ifaddr *ifp)
{
WARN_ON(!hlist_unhashed(&ifp->addr_lst));
#ifdef NET_REFCNT_DEBUG
printk(KERN_DEBUG "inet6_ifa_finish_destroy\n");
#endif
in6_dev_put(ifp->idev);
if (del_timer(&ifp->timer))
pr_notice("Timer is still running, when freeing ifa=%p\n", ifp);
if (ifp->state != INET6_IFADDR_STATE_DEAD) {
pr_warning("Freeing alive inet6 address %p\n", ifp);
return;
}
dst_release(&ifp->rt->dst);
kfree_rcu(ifp, rcu);
}
static void
ipv6_link_dev_addr(struct inet6_dev *idev, struct inet6_ifaddr *ifp)
{
struct list_head *p;
int ifp_scope = ipv6_addr_src_scope(&ifp->addr);
/*
* Each device address list is sorted in order of scope -
* global before linklocal.
*/
list_for_each(p, &idev->addr_list) {
struct inet6_ifaddr *ifa
= list_entry(p, struct inet6_ifaddr, if_list);
if (ifp_scope >= ipv6_addr_src_scope(&ifa->addr))
break;
}
list_add_tail(&ifp->if_list, p);
}
static u32 ipv6_addr_hash(const struct in6_addr *addr)
{
/*
* We perform the hash function over the last 64 bits of the address
* This will include the IEEE address token on links that support it.
*/
return jhash_2words((__force u32)addr->s6_addr32[2],
(__force u32)addr->s6_addr32[3], 0)
& (IN6_ADDR_HSIZE - 1);
}
/* On success it returns ifp with increased reference count */
static struct inet6_ifaddr *
ipv6_add_addr(struct inet6_dev *idev, const struct in6_addr *addr, int pfxlen,
int scope, u32 flags)
{
struct inet6_ifaddr *ifa = NULL;
struct rt6_info *rt;
unsigned int hash;
int err = 0;
int addr_type = ipv6_addr_type(addr);
if (addr_type == IPV6_ADDR_ANY ||
addr_type & IPV6_ADDR_MULTICAST ||
(!(idev->dev->flags & IFF_LOOPBACK) &&
addr_type & IPV6_ADDR_LOOPBACK))
return ERR_PTR(-EADDRNOTAVAIL);
rcu_read_lock_bh();
if (idev->dead) {
err = -ENODEV; /*XXX*/
goto out2;
}
if (idev->cnf.disable_ipv6) {
err = -EACCES;
goto out2;
}
spin_lock(&addrconf_hash_lock);
/* Ignore adding duplicate addresses on an interface */
if (ipv6_chk_same_addr(dev_net(idev->dev), addr, idev->dev)) {
ADBG(("ipv6_add_addr: already assigned\n"));
err = -EEXIST;
goto out;
}
ifa = kzalloc(sizeof(struct inet6_ifaddr), GFP_ATOMIC);
if (ifa == NULL) {
ADBG(("ipv6_add_addr: malloc failed\n"));
err = -ENOBUFS;
goto out;
}
rt = addrconf_dst_alloc(idev, addr, false);
if (IS_ERR(rt)) {
err = PTR_ERR(rt);
goto out;
}
ifa->addr = *addr;
spin_lock_init(&ifa->lock);
spin_lock_init(&ifa->state_lock);
init_timer(&ifa->timer);
INIT_HLIST_NODE(&ifa->addr_lst);
ifa->timer.data = (unsigned long) ifa;
ifa->scope = scope;
ifa->prefix_len = pfxlen;
ifa->flags = flags | IFA_F_TENTATIVE;
ifa->cstamp = ifa->tstamp = jiffies;
ifa->rt = rt;
ifa->idev = idev;
in6_dev_hold(idev);
/* For caller */
in6_ifa_hold(ifa);
/* Add to big hash table */
hash = ipv6_addr_hash(addr);
hlist_add_head_rcu(&ifa->addr_lst, &inet6_addr_lst[hash]);
write_lock(&idev->lock);
/* Add to inet6_dev unicast addr list. */
ipv6_link_dev_addr(idev, ifa);
#ifdef CONFIG_IPV6_PRIVACY
if (ifa->flags&IFA_F_TEMPORARY) {
list_add(&ifa->tmp_list, &idev->tempaddr_list);
in6_ifa_hold(ifa);
}
#endif
in6_ifa_hold(ifa);
write_unlock(&idev->lock);
spin_unlock(&addrconf_hash_lock);
out2:
rcu_read_unlock_bh();
if (likely(err == 0))
atomic_notifier_call_chain(&inet6addr_chain, NETDEV_UP, ifa);
else {
kfree(ifa);
ifa = ERR_PTR(err);
}
return ifa;
out:
spin_unlock(&addrconf_hash_lock);
goto out2;
}
/* This function wants to get referenced ifp and releases it before return */
static void ipv6_del_addr(struct inet6_ifaddr *ifp)
{
struct inet6_ifaddr *ifa, *ifn;
struct inet6_dev *idev = ifp->idev;
int state;
int deleted = 0, onlink = 0;
unsigned long expires = jiffies;
spin_lock_bh(&ifp->state_lock);
state = ifp->state;
ifp->state = INET6_IFADDR_STATE_DEAD;
spin_unlock_bh(&ifp->state_lock);
if (state == INET6_IFADDR_STATE_DEAD)
goto out;
spin_lock_bh(&addrconf_hash_lock);
hlist_del_init_rcu(&ifp->addr_lst);
write_lock_bh(&idev->lock);
#ifdef CONFIG_IPV6_PRIVACY
if (ifp->flags&IFA_F_TEMPORARY) {
list_del(&ifp->tmp_list);
if (ifp->ifpub) {
in6_ifa_put(ifp->ifpub);
ifp->ifpub = NULL;
}
__in6_ifa_put(ifp);
}
#endif
list_for_each_entry_safe(ifa, ifn, &idev->addr_list, if_list) {
if (ifa == ifp) {
list_del_init(&ifp->if_list);
__in6_ifa_put(ifp);
if (!(ifp->flags & IFA_F_PERMANENT) || onlink > 0)
break;
deleted = 1;
continue;
} else if (ifp->flags & IFA_F_PERMANENT) {
if (ipv6_prefix_equal(&ifa->addr, &ifp->addr,
ifp->prefix_len)) {
if (ifa->flags & IFA_F_PERMANENT) {
onlink = 1;
if (deleted)
break;
} else {
unsigned long lifetime;
if (!onlink)
onlink = -1;
spin_lock(&ifa->lock);
lifetime = addrconf_timeout_fixup(ifa->valid_lft, HZ);
/*
* Note: Because this address is
* not permanent, lifetime <
* LONG_MAX / HZ here.
*/
if (time_before(expires,
ifa->tstamp + lifetime * HZ))
expires = ifa->tstamp + lifetime * HZ;
spin_unlock(&ifa->lock);
}
}
}
}
write_unlock_bh(&idev->lock);
spin_unlock_bh(&addrconf_hash_lock);
addrconf_del_timer(ifp);
ipv6_ifa_notify(RTM_DELADDR, ifp);
atomic_notifier_call_chain(&inet6addr_chain, NETDEV_DOWN, ifp);
/*
* Purge or update corresponding prefix
*
* 1) we don't purge prefix here if address was not permanent.
* prefix is managed by its own lifetime.
* 2) if there're no addresses, delete prefix.
* 3) if there're still other permanent address(es),
* corresponding prefix is still permanent.
* 4) otherwise, update prefix lifetime to the
* longest valid lifetime among the corresponding
* addresses on the device.
* Note: subsequent RA will update lifetime.
*
* --yoshfuji
*/
if ((ifp->flags & IFA_F_PERMANENT) && onlink < 1) {
struct in6_addr prefix;
struct rt6_info *rt;
struct net *net = dev_net(ifp->idev->dev);
struct flowi6 fl6 = {};
ipv6_addr_prefix(&prefix, &ifp->addr, ifp->prefix_len);
fl6.flowi6_oif = ifp->idev->dev->ifindex;
fl6.daddr = prefix;
rt = (struct rt6_info *)ip6_route_lookup(net, &fl6,
RT6_LOOKUP_F_IFACE);
if (rt != net->ipv6.ip6_null_entry &&
addrconf_is_prefix_route(rt)) {
if (onlink == 0) {
ip6_del_rt(rt);
rt = NULL;
} else if (!(rt->rt6i_flags & RTF_EXPIRES)) {
rt6_set_expires(rt, expires);
}
}
dst_release(&rt->dst);
}
/* clean up prefsrc entries */
rt6_remove_prefsrc(ifp);
out:
in6_ifa_put(ifp);
}
#ifdef CONFIG_IPV6_PRIVACY
static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp, struct inet6_ifaddr *ift)
{
struct inet6_dev *idev = ifp->idev;
struct in6_addr addr, *tmpaddr;
unsigned long tmp_prefered_lft, tmp_valid_lft, tmp_tstamp, age;
unsigned long regen_advance;
int tmp_plen;
int ret = 0;
int max_addresses;
u32 addr_flags;
unsigned long now = jiffies;
write_lock(&idev->lock);
if (ift) {
spin_lock_bh(&ift->lock);
memcpy(&addr.s6_addr[8], &ift->addr.s6_addr[8], 8);
spin_unlock_bh(&ift->lock);
tmpaddr = &addr;
} else {
tmpaddr = NULL;
}
retry:
in6_dev_hold(idev);
if (idev->cnf.use_tempaddr <= 0) {
write_unlock(&idev->lock);
printk(KERN_INFO
"ipv6_create_tempaddr(): use_tempaddr is disabled.\n");
in6_dev_put(idev);
ret = -1;
goto out;
}
spin_lock_bh(&ifp->lock);
if (ifp->regen_count++ >= idev->cnf.regen_max_retry) {
idev->cnf.use_tempaddr = -1; /*XXX*/
spin_unlock_bh(&ifp->lock);
write_unlock(&idev->lock);
printk(KERN_WARNING
"ipv6_create_tempaddr(): regeneration time exceeded. disabled temporary address support.\n");
in6_dev_put(idev);
ret = -1;
goto out;
}
in6_ifa_hold(ifp);
memcpy(addr.s6_addr, ifp->addr.s6_addr, 8);
if (__ipv6_try_regen_rndid(idev, tmpaddr) < 0) {
spin_unlock_bh(&ifp->lock);
write_unlock(&idev->lock);
printk(KERN_WARNING
"ipv6_create_tempaddr(): regeneration of randomized interface id failed.\n");
in6_ifa_put(ifp);
in6_dev_put(idev);
ret = -1;
goto out;
}
memcpy(&addr.s6_addr[8], idev->rndid, 8);
age = (now - ifp->tstamp) / HZ;
tmp_valid_lft = min_t(__u32,
ifp->valid_lft,
idev->cnf.temp_valid_lft + age);
tmp_prefered_lft = min_t(__u32,
ifp->prefered_lft,
idev->cnf.temp_prefered_lft + age -
idev->cnf.max_desync_factor);
tmp_plen = ifp->prefix_len;
max_addresses = idev->cnf.max_addresses;
tmp_tstamp = ifp->tstamp;
spin_unlock_bh(&ifp->lock);
regen_advance = idev->cnf.regen_max_retry *
idev->cnf.dad_transmits *
idev->nd_parms->retrans_time / HZ;
write_unlock(&idev->lock);
/* A temporary address is created only if this calculated Preferred
* Lifetime is greater than REGEN_ADVANCE time units. In particular,
* an implementation must not create a temporary address with a zero
* Preferred Lifetime.
* Use age calculation as in addrconf_verify to avoid unnecessary
* temporary addresses being generated.
*/
age = (now - tmp_tstamp + ADDRCONF_TIMER_FUZZ_MINUS) / HZ;
if (tmp_prefered_lft <= regen_advance + age) {
in6_ifa_put(ifp);
in6_dev_put(idev);
ret = -1;
goto out;
}
addr_flags = IFA_F_TEMPORARY;
/* set in addrconf_prefix_rcv() */
if (ifp->flags & IFA_F_OPTIMISTIC)
addr_flags |= IFA_F_OPTIMISTIC;
ift = ipv6_add_addr(idev, &addr, tmp_plen,
ipv6_addr_type(&addr)&IPV6_ADDR_SCOPE_MASK,
addr_flags);
if (IS_ERR(ift)) {
in6_ifa_put(ifp);
in6_dev_put(idev);
printk(KERN_INFO
"ipv6_create_tempaddr(): retry temporary address regeneration.\n");
tmpaddr = &addr;
write_lock(&idev->lock);
goto retry;
}
spin_lock_bh(&ift->lock);
ift->ifpub = ifp;
ift->valid_lft = tmp_valid_lft;
ift->prefered_lft = tmp_prefered_lft;
ift->cstamp = now;
ift->tstamp = tmp_tstamp;
spin_unlock_bh(&ift->lock);
addrconf_dad_start(ift, 0);
in6_ifa_put(ift);
in6_dev_put(idev);
out:
return ret;
}
#endif
/*
* Choose an appropriate source address (RFC3484)
*/
enum {
IPV6_SADDR_RULE_INIT = 0,
IPV6_SADDR_RULE_LOCAL,
IPV6_SADDR_RULE_SCOPE,
IPV6_SADDR_RULE_PREFERRED,
#ifdef CONFIG_IPV6_MIP6
IPV6_SADDR_RULE_HOA,
#endif
IPV6_SADDR_RULE_OIF,
IPV6_SADDR_RULE_LABEL,
#ifdef CONFIG_IPV6_PRIVACY
IPV6_SADDR_RULE_PRIVACY,
#endif
IPV6_SADDR_RULE_ORCHID,
IPV6_SADDR_RULE_PREFIX,
#ifdef CONFIG_IPV6_OPTIMISTIC_DAD
IPV6_SADDR_RULE_NOT_OPTIMISTIC,
#endif
IPV6_SADDR_RULE_MAX
};
struct ipv6_saddr_score {
int rule;
int addr_type;
struct inet6_ifaddr *ifa;
DECLARE_BITMAP(scorebits, IPV6_SADDR_RULE_MAX);
int scopedist;
int matchlen;
};
struct ipv6_saddr_dst {
const struct in6_addr *addr;
int ifindex;
int scope;
int label;
unsigned int prefs;
};
static inline int ipv6_saddr_preferred(int type)
{
if (type & (IPV6_ADDR_MAPPED|IPV6_ADDR_COMPATv4|IPV6_ADDR_LOOPBACK))
return 1;
return 0;
}
static inline bool ipv6_use_optimistic_addr(struct inet6_dev *idev)
{
#ifdef CONFIG_IPV6_OPTIMISTIC_DAD
return idev && idev->cnf.optimistic_dad && idev->cnf.use_optimistic;
#else
return false;
#endif
}
static int ipv6_get_saddr_eval(struct net *net,
struct ipv6_saddr_score *score,
struct ipv6_saddr_dst *dst,
int i)
{
int ret;
if (i <= score->rule) {
switch (i) {
case IPV6_SADDR_RULE_SCOPE:
ret = score->scopedist;
break;
case IPV6_SADDR_RULE_PREFIX:
ret = score->matchlen;
break;
default:
ret = !!test_bit(i, score->scorebits);
}
goto out;
}
switch (i) {
case IPV6_SADDR_RULE_INIT:
/* Rule 0: remember if hiscore is not ready yet */
ret = !!score->ifa;
break;
case IPV6_SADDR_RULE_LOCAL:
/* Rule 1: Prefer same address */
ret = ipv6_addr_equal(&score->ifa->addr, dst->addr);
break;
case IPV6_SADDR_RULE_SCOPE:
/* Rule 2: Prefer appropriate scope
*
* ret
* ^
* -1 | d 15
* ---+--+-+---> scope
* |
* | d is scope of the destination.
* B-d | \
* | \ <- smaller scope is better if
* B-15 | \ if scope is enough for destinaion.
* | ret = B - scope (-1 <= scope >= d <= 15).
* d-C-1 | /
* |/ <- greater is better
* -C / if scope is not enough for destination.
* /| ret = scope - C (-1 <= d < scope <= 15).
*
* d - C - 1 < B -15 (for all -1 <= d <= 15).
* C > d + 14 - B >= 15 + 14 - B = 29 - B.
* Assume B = 0 and we get C > 29.
*/
ret = __ipv6_addr_src_scope(score->addr_type);
if (ret >= dst->scope)
ret = -ret;
else
ret -= 128; /* 30 is enough */
score->scopedist = ret;
break;
case IPV6_SADDR_RULE_PREFERRED:
{
/* Rule 3: Avoid deprecated and optimistic addresses */
u8 avoid = IFA_F_DEPRECATED;
if (!ipv6_use_optimistic_addr(score->ifa->idev))
avoid |= IFA_F_OPTIMISTIC;
ret = ipv6_saddr_preferred(score->addr_type) ||
!(score->ifa->flags & avoid);
break;
}
#ifdef CONFIG_IPV6_MIP6
case IPV6_SADDR_RULE_HOA:
{
/* Rule 4: Prefer home address */
int prefhome = !(dst->prefs & IPV6_PREFER_SRC_COA);
ret = !(score->ifa->flags & IFA_F_HOMEADDRESS) ^ prefhome;
break;
}
#endif
case IPV6_SADDR_RULE_OIF:
/* Rule 5: Prefer outgoing interface */
ret = (!dst->ifindex ||
dst->ifindex == score->ifa->idev->dev->ifindex);
break;
case IPV6_SADDR_RULE_LABEL:
/* Rule 6: Prefer matching label */
ret = ipv6_addr_label(net,
&score->ifa->addr, score->addr_type,
score->ifa->idev->dev->ifindex) == dst->label;
break;
#ifdef CONFIG_IPV6_PRIVACY
case IPV6_SADDR_RULE_PRIVACY:
{
/* Rule 7: Prefer public address
* Note: prefer temporary address if use_tempaddr >= 2
*/
int preftmp = dst->prefs & (IPV6_PREFER_SRC_PUBLIC|IPV6_PREFER_SRC_TMP) ?
!!(dst->prefs & IPV6_PREFER_SRC_TMP) :
score->ifa->idev->cnf.use_tempaddr >= 2;
ret = (!(score->ifa->flags & IFA_F_TEMPORARY)) ^ preftmp;
break;
}
#endif
case IPV6_SADDR_RULE_ORCHID:
/* Rule 8-: Prefer ORCHID vs ORCHID or
* non-ORCHID vs non-ORCHID
*/
ret = !(ipv6_addr_orchid(&score->ifa->addr) ^
ipv6_addr_orchid(dst->addr));
break;
case IPV6_SADDR_RULE_PREFIX:
/* Rule 8: Use longest matching prefix */
score->matchlen = ret = ipv6_addr_diff(&score->ifa->addr,
dst->addr);
break;
#ifdef CONFIG_IPV6_OPTIMISTIC_DAD
case IPV6_SADDR_RULE_NOT_OPTIMISTIC:
/* Optimistic addresses still have lower precedence than other
* preferred addresses.
*/
ret = !(score->ifa->flags & IFA_F_OPTIMISTIC);
break;
#endif
default:
ret = 0;
}
if (ret)
__set_bit(i, score->scorebits);
score->rule = i;
out:
return ret;
}
int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
const struct in6_addr *daddr, unsigned int prefs,
struct in6_addr *saddr)
{
struct ipv6_saddr_score scores[2],
*score = &scores[0], *hiscore = &scores[1];
struct ipv6_saddr_dst dst;
struct net_device *dev;
int dst_type;
dst_type = __ipv6_addr_type(daddr);
dst.addr = daddr;
dst.ifindex = dst_dev ? dst_dev->ifindex : 0;
dst.scope = __ipv6_addr_src_scope(dst_type);
dst.label = ipv6_addr_label(net, daddr, dst_type, dst.ifindex);
dst.prefs = prefs;
hiscore->rule = -1;
hiscore->ifa = NULL;
rcu_read_lock();
for_each_netdev_rcu(net, dev) {
struct inet6_dev *idev;
/* Candidate Source Address (section 4)
* - multicast and link-local destination address,
* the set of candidate source address MUST only
* include addresses assigned to interfaces
* belonging to the same link as the outgoing
* interface.
* (- For site-local destination addresses, the
* set of candidate source addresses MUST only
* include addresses assigned to interfaces
* belonging to the same site as the outgoing
* interface.)
*/
if (((dst_type & IPV6_ADDR_MULTICAST) ||
dst.scope <= IPV6_ADDR_SCOPE_LINKLOCAL) &&
dst.ifindex && dev->ifindex != dst.ifindex)
continue;
idev = __in6_dev_get(dev);
if (!idev)
continue;
read_lock_bh(&idev->lock);
list_for_each_entry(score->ifa, &idev->addr_list, if_list) {
int i;
/*
* - Tentative Address (RFC2462 section 5.4)
* - A tentative address is not considered
* "assigned to an interface" in the traditional
* sense, unless it is also flagged as optimistic.
* - Candidate Source Address (section 4)
* - In any case, anycast addresses, multicast
* addresses, and the unspecified address MUST
* NOT be included in a candidate set.
*/
if ((score->ifa->flags & IFA_F_TENTATIVE) &&
(!(score->ifa->flags & IFA_F_OPTIMISTIC)))
continue;
score->addr_type = __ipv6_addr_type(&score->ifa->addr);
if (unlikely(score->addr_type == IPV6_ADDR_ANY ||
score->addr_type & IPV6_ADDR_MULTICAST)) {
LIMIT_NETDEBUG(KERN_DEBUG
"ADDRCONF: unspecified / multicast address "
"assigned as unicast address on %s",
dev->name);
continue;
}
score->rule = -1;
bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
for (i = 0; i < IPV6_SADDR_RULE_MAX; i++) {
int minihiscore, miniscore;
minihiscore = ipv6_get_saddr_eval(net, hiscore, &dst, i);
miniscore = ipv6_get_saddr_eval(net, score, &dst, i);
if (minihiscore > miniscore) {
if (i == IPV6_SADDR_RULE_SCOPE &&
score->scopedist > 0) {
/*
* special case:
* each remaining entry
* has too small (not enough)
* scope, because ifa entries
* are sorted by their scope
* values.
*/
goto try_nextdev;
}
break;
} else if (minihiscore < miniscore) {
if (hiscore->ifa)
in6_ifa_put(hiscore->ifa);
in6_ifa_hold(score->ifa);
swap(hiscore, score);
/* restore our iterator */
score->ifa = hiscore->ifa;
break;
}
}
}
try_nextdev:
read_unlock_bh(&idev->lock);
}
rcu_read_unlock();
if (!hiscore->ifa)
return -EADDRNOTAVAIL;
*saddr = hiscore->ifa->addr;
in6_ifa_put(hiscore->ifa);
return 0;
}
EXPORT_SYMBOL(ipv6_dev_get_saddr);
int __ipv6_get_lladdr(struct inet6_dev *idev, struct in6_addr *addr,
unsigned char banned_flags)
{
struct inet6_ifaddr *ifp;
int err = -EADDRNOTAVAIL;
list_for_each_entry(ifp, &idev->addr_list, if_list) {
if (ifp->scope == IFA_LINK &&
!(ifp->flags & banned_flags)) {
*addr = ifp->addr;
err = 0;
break;
}
}
return err;
}
int ipv6_get_lladdr(struct net_device *dev, struct in6_addr *addr,
unsigned char banned_flags)
{
struct inet6_dev *idev;
int err = -EADDRNOTAVAIL;
rcu_read_lock();
idev = __in6_dev_get(dev);
if (idev) {
read_lock_bh(&idev->lock);
err = __ipv6_get_lladdr(idev, addr, banned_flags);
read_unlock_bh(&idev->lock);
}
rcu_read_unlock();
return err;
}
static int ipv6_count_addresses(struct inet6_dev *idev)
{
int cnt = 0;
struct inet6_ifaddr *ifp;
read_lock_bh(&idev->lock);
list_for_each_entry(ifp, &idev->addr_list, if_list)
cnt++;
read_unlock_bh(&idev->lock);
return cnt;
}
int ipv6_chk_addr(struct net *net, const struct in6_addr *addr,
const struct net_device *dev, int strict)
{
struct inet6_ifaddr *ifp;
struct hlist_node *node;
unsigned int hash = ipv6_addr_hash(addr);
rcu_read_lock_bh();
hlist_for_each_entry_rcu(ifp, node, &inet6_addr_lst[hash], addr_lst) {
if (!net_eq(dev_net(ifp->idev->dev), net))
continue;
if (ipv6_addr_equal(&ifp->addr, addr) &&
(!(ifp->flags&IFA_F_TENTATIVE) ||
(ipv6_use_optimistic_addr(ifp->idev) &&
ifp->flags&IFA_F_OPTIMISTIC)) &&
(dev == NULL || ifp->idev->dev == dev ||
!(ifp->scope&(IFA_LINK|IFA_HOST) || strict))) {
rcu_read_unlock_bh();
return 1;
}
}
rcu_read_unlock_bh();
return 0;
}
EXPORT_SYMBOL(ipv6_chk_addr);
static bool ipv6_chk_same_addr(struct net *net, const struct in6_addr *addr,
struct net_device *dev)
{
unsigned int hash = ipv6_addr_hash(addr);
struct inet6_ifaddr *ifp;
struct hlist_node *node;
hlist_for_each_entry(ifp, node, &inet6_addr_lst[hash], addr_lst) {
if (!net_eq(dev_net(ifp->idev->dev), net))
continue;
if (ipv6_addr_equal(&ifp->addr, addr)) {
if (dev == NULL || ifp->idev->dev == dev)
return true;
}
}
return false;
}
int ipv6_chk_prefix(const struct in6_addr *addr, struct net_device *dev)
{
struct inet6_dev *idev;
struct inet6_ifaddr *ifa;
int onlink;
onlink = 0;
rcu_read_lock();
idev = __in6_dev_get(dev);
if (idev) {
read_lock_bh(&idev->lock);
list_for_each_entry(ifa, &idev->addr_list, if_list) {
onlink = ipv6_prefix_equal(addr, &ifa->addr,
ifa->prefix_len);
if (onlink)
break;
}
read_unlock_bh(&idev->lock);
}
rcu_read_unlock();
return onlink;
}
EXPORT_SYMBOL(ipv6_chk_prefix);
struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net, const struct in6_addr *addr,
struct net_device *dev, int strict)
{
struct inet6_ifaddr *ifp, *result = NULL;
unsigned int hash = ipv6_addr_hash(addr);
struct hlist_node *node;
rcu_read_lock_bh();
hlist_for_each_entry_rcu_bh(ifp, node, &inet6_addr_lst[hash], addr_lst) {
if (!net_eq(dev_net(ifp->idev->dev), net))
continue;
if (ipv6_addr_equal(&ifp->addr, addr)) {
if (dev == NULL || ifp->idev->dev == dev ||
!(ifp->scope&(IFA_LINK|IFA_HOST) || strict)) {
result = ifp;
in6_ifa_hold(ifp);
break;
}
}
}
rcu_read_unlock_bh();
return result;
}
/* Gets referenced address, destroys ifaddr */
static void addrconf_dad_stop(struct inet6_ifaddr *ifp, int dad_failed)
{
if (ifp->flags&IFA_F_PERMANENT) {
spin_lock_bh(&ifp->lock);
addrconf_del_timer(ifp);
ifp->flags |= IFA_F_TENTATIVE;
if (dad_failed)
ifp->flags |= IFA_F_DADFAILED;
spin_unlock_bh(&ifp->lock);
if (dad_failed)
ipv6_ifa_notify(0, ifp);
in6_ifa_put(ifp);
#ifdef CONFIG_IPV6_PRIVACY
} else if (ifp->flags&IFA_F_TEMPORARY) {
struct inet6_ifaddr *ifpub;
spin_lock_bh(&ifp->lock);
ifpub = ifp->ifpub;
if (ifpub) {
in6_ifa_hold(ifpub);
spin_unlock_bh(&ifp->lock);
ipv6_create_tempaddr(ifpub, ifp);
in6_ifa_put(ifpub);
} else {
spin_unlock_bh(&ifp->lock);
}
ipv6_del_addr(ifp);
#endif
} else
ipv6_del_addr(ifp);
}
static int addrconf_dad_end(struct inet6_ifaddr *ifp)
{
int err = -ENOENT;
spin_lock(&ifp->state_lock);
if (ifp->state == INET6_IFADDR_STATE_DAD) {
ifp->state = INET6_IFADDR_STATE_POSTDAD;
err = 0;
}
spin_unlock(&ifp->state_lock);
return err;
}
void addrconf_dad_failure(struct inet6_ifaddr *ifp)
{
struct inet6_dev *idev = ifp->idev;
if (addrconf_dad_end(ifp)) {
in6_ifa_put(ifp);
return;
}
if (net_ratelimit())
printk(KERN_INFO "%s: IPv6 duplicate address %pI6c detected!\n",
ifp->idev->dev->name, &ifp->addr);
if (idev->cnf.accept_dad > 1 && !idev->cnf.disable_ipv6) {
struct in6_addr addr;
addr.s6_addr32[0] = htonl(0xfe800000);
addr.s6_addr32[1] = 0;
if (!ipv6_generate_eui64(addr.s6_addr + 8, idev->dev) &&
ipv6_addr_equal(&ifp->addr, &addr)) {
/* DAD failed for link-local based on MAC address */
idev->cnf.disable_ipv6 = 1;
printk(KERN_INFO "%s: IPv6 being disabled!\n",
ifp->idev->dev->name);
}
}
addrconf_dad_stop(ifp, 1);
}
/* Join to solicited addr multicast group. */
void addrconf_join_solict(struct net_device *dev, const struct in6_addr *addr)
{
struct in6_addr maddr;
if (dev->flags&(IFF_LOOPBACK|IFF_NOARP))
return;
addrconf_addr_solict_mult(addr, &maddr);
ipv6_dev_mc_inc(dev, &maddr);
}
void addrconf_leave_solict(struct inet6_dev *idev, const struct in6_addr *addr)
{
struct in6_addr maddr;
if (idev->dev->flags&(IFF_LOOPBACK|IFF_NOARP))
return;
addrconf_addr_solict_mult(addr, &maddr);
__ipv6_dev_mc_dec(idev, &maddr);
}
static void addrconf_join_anycast(struct inet6_ifaddr *ifp)
{
struct in6_addr addr;
if (ifp->prefix_len == 127) /* RFC 6164 */
return;
ipv6_addr_prefix(&addr, &ifp->addr, ifp->prefix_len);
if (ipv6_addr_any(&addr))
return;
ipv6_dev_ac_inc(ifp->idev->dev, &addr);
}
static void addrconf_leave_anycast(struct inet6_ifaddr *ifp)
{
struct in6_addr addr;
if (ifp->prefix_len == 127) /* RFC 6164 */
return;
ipv6_addr_prefix(&addr, &ifp->addr, ifp->prefix_len);
if (ipv6_addr_any(&addr))
return;
__ipv6_dev_ac_dec(ifp->idev, &addr);
}
static int addrconf_ifid_eui48(u8 *eui, struct net_device *dev)
{
if (dev->addr_len != ETH_ALEN)
return -1;
memcpy(eui, dev->dev_addr, 3);
memcpy(eui + 5, dev->dev_addr + 3, 3);
/*
* The zSeries OSA network cards can be shared among various
* OS instances, but the OSA cards have only one MAC address.
* This leads to duplicate address conflicts in conjunction
* with IPv6 if more than one instance uses the same card.
*
* The driver for these cards can deliver a unique 16-bit
* identifier for each instance sharing the same card. It is
* placed instead of 0xFFFE in the interface identifier. The
* "u" bit of the interface identifier is not inverted in this
* case. Hence the resulting interface identifier has local
* scope according to RFC2373.
*/
if (dev->dev_id) {
eui[3] = (dev->dev_id >> 8) & 0xFF;
eui[4] = dev->dev_id & 0xFF;
} else {
eui[3] = 0xFF;
eui[4] = 0xFE;
eui[0] ^= 2;
}
return 0;
}
static int addrconf_ifid_arcnet(u8 *eui, struct net_device *dev)
{
/* XXX: inherit EUI-64 from other interface -- yoshfuji */
if (dev->addr_len != ARCNET_ALEN)
return -1;
memset(eui, 0, 7);
eui[7] = *(u8*)dev->dev_addr;
return 0;
}
static int addrconf_ifid_infiniband(u8 *eui, struct net_device *dev)
{
if (dev->addr_len != INFINIBAND_ALEN)
return -1;
memcpy(eui, dev->dev_addr + 12, 8);
eui[0] |= 2;
return 0;
}
static int __ipv6_isatap_ifid(u8 *eui, __be32 addr)
{
if (addr == 0)
return -1;
eui[0] = (ipv4_is_zeronet(addr) || ipv4_is_private_10(addr) ||
ipv4_is_loopback(addr) || ipv4_is_linklocal_169(addr) ||
ipv4_is_private_172(addr) || ipv4_is_test_192(addr) ||
ipv4_is_anycast_6to4(addr) || ipv4_is_private_192(addr) ||
ipv4_is_test_198(addr) || ipv4_is_multicast(addr) ||
ipv4_is_lbcast(addr)) ? 0x00 : 0x02;
eui[1] = 0;
eui[2] = 0x5E;
eui[3] = 0xFE;
memcpy(eui + 4, &addr, 4);
return 0;
}
static int addrconf_ifid_sit(u8 *eui, struct net_device *dev)
{
if (dev->priv_flags & IFF_ISATAP)
return __ipv6_isatap_ifid(eui, *(__be32 *)dev->dev_addr);
return -1;
}
static int addrconf_ifid_gre(u8 *eui, struct net_device *dev)
{
return __ipv6_isatap_ifid(eui, *(__be32 *)dev->dev_addr);
}
static int ipv6_generate_eui64(u8 *eui, struct net_device *dev)
{
switch (dev->type) {
case ARPHRD_ETHER:
case ARPHRD_FDDI:
case ARPHRD_IEEE802_TR:
return addrconf_ifid_eui48(eui, dev);
case ARPHRD_ARCNET:
return addrconf_ifid_arcnet(eui, dev);
case ARPHRD_INFINIBAND:
return addrconf_ifid_infiniband(eui, dev);
case ARPHRD_SIT:
return addrconf_ifid_sit(eui, dev);
case ARPHRD_IPGRE:
return addrconf_ifid_gre(eui, dev);
case ARPHRD_RAWIP: {
struct in6_addr lladdr;
if (ipv6_get_lladdr(dev, &lladdr, IFA_F_TENTATIVE))
get_random_bytes(eui, 8);
else
memcpy(eui, lladdr.s6_addr + 8, 8);
return 0;
}
}
return -1;
}
static int ipv6_inherit_eui64(u8 *eui, struct inet6_dev *idev)
{
int err = -1;
struct inet6_ifaddr *ifp;
read_lock_bh(&idev->lock);
list_for_each_entry(ifp, &idev->addr_list, if_list) {
if (ifp->scope == IFA_LINK && !(ifp->flags&IFA_F_TENTATIVE)) {
memcpy(eui, ifp->addr.s6_addr+8, 8);
err = 0;
break;
}
}
read_unlock_bh(&idev->lock);
return err;
}
#ifdef CONFIG_IPV6_PRIVACY
/* (re)generation of randomized interface identifier (RFC 3041 3.2, 3.5) */
static int __ipv6_regen_rndid(struct inet6_dev *idev)
{
regen:
get_random_bytes(idev->rndid, sizeof(idev->rndid));
idev->rndid[0] &= ~0x02;
/*
* <draft-ietf-ipngwg-temp-addresses-v2-00.txt>:
* check if generated address is not inappropriate
*
* - Reserved subnet anycast (RFC 2526)
* 11111101 11....11 1xxxxxxx
* - ISATAP (RFC4214) 6.1
* 00-00-5E-FE-xx-xx-xx-xx
* - value 0
* - XXX: already assigned to an address on the device
*/
if (idev->rndid[0] == 0xfd &&
(idev->rndid[1]&idev->rndid[2]&idev->rndid[3]&idev->rndid[4]&idev->rndid[5]&idev->rndid[6]) == 0xff &&
(idev->rndid[7]&0x80))
goto regen;
if ((idev->rndid[0]|idev->rndid[1]) == 0) {
if (idev->rndid[2] == 0x5e && idev->rndid[3] == 0xfe)
goto regen;
if ((idev->rndid[2]|idev->rndid[3]|idev->rndid[4]|idev->rndid[5]|idev->rndid[6]|idev->rndid[7]) == 0x00)
goto regen;
}
return 0;
}
static void ipv6_regen_rndid(unsigned long data)
{
struct inet6_dev *idev = (struct inet6_dev *) data;
unsigned long expires;
rcu_read_lock_bh();
write_lock_bh(&idev->lock);
if (idev->dead)
goto out;
if (__ipv6_regen_rndid(idev) < 0)
goto out;
expires = jiffies +
idev->cnf.temp_prefered_lft * HZ -
idev->cnf.regen_max_retry * idev->cnf.dad_transmits * idev->nd_parms->retrans_time -
idev->cnf.max_desync_factor * HZ;
if (time_before(expires, jiffies)) {
printk(KERN_WARNING
"ipv6_regen_rndid(): too short regeneration interval; timer disabled for %s.\n",
idev->dev->name);
goto out;
}
if (!mod_timer(&idev->regen_timer, expires))
in6_dev_hold(idev);
out:
write_unlock_bh(&idev->lock);
rcu_read_unlock_bh();
in6_dev_put(idev);
}
static int __ipv6_try_regen_rndid(struct inet6_dev *idev, struct in6_addr *tmpaddr) {
int ret = 0;
if (tmpaddr && memcmp(idev->rndid, &tmpaddr->s6_addr[8], 8) == 0)
ret = __ipv6_regen_rndid(idev);
return ret;
}
#endif
u32 addrconf_rt_table(const struct net_device *dev, u32 default_table) {
/* Determines into what table to put autoconf PIO/RIO/default routes
* learned on this device.
*
* - If 0, use the same table for every device. This puts routes into
* one of RT_TABLE_{PREFIX,INFO,DFLT} depending on the type of route
* (but note that these three are currently all equal to
* RT6_TABLE_MAIN).
* - If > 0, use the specified table.
* - If < 0, put routes into table dev->ifindex + (-rt_table).
*/
struct inet6_dev *idev = in6_dev_get(dev);
u32 table;
int sysctl = idev->cnf.accept_ra_rt_table;
if (sysctl == 0) {
table = default_table;
} else if (sysctl > 0) {
table = (u32) sysctl;
} else {
table = (unsigned) dev->ifindex + (-sysctl);
}
in6_dev_put(idev);
return table;
}
/*
* Add prefix route.
*/
static void
addrconf_prefix_route(struct in6_addr *pfx, int plen, struct net_device *dev,
unsigned long expires, u32 flags)
{
struct fib6_config cfg = {
.fc_table = addrconf_rt_table(dev, RT6_TABLE_PREFIX),
.fc_metric = IP6_RT_PRIO_ADDRCONF,
.fc_ifindex = dev->ifindex,
.fc_expires = expires,
.fc_dst_len = plen,
.fc_flags = RTF_UP | flags,
.fc_nlinfo.nl_net = dev_net(dev),
.fc_protocol = RTPROT_KERNEL,
};
cfg.fc_dst = *pfx;
/* Prevent useless cloning on PtP SIT.
This thing is done here expecting that the whole
class of non-broadcast devices need not cloning.
*/
#if defined(CONFIG_IPV6_SIT) || defined(CONFIG_IPV6_SIT_MODULE)
if (dev->type == ARPHRD_SIT && (dev->flags & IFF_POINTOPOINT))
cfg.fc_flags |= RTF_NONEXTHOP;
#endif
ip6_route_add(&cfg);
}
static struct rt6_info *addrconf_get_prefix_route(const struct in6_addr *pfx,
int plen,
const struct net_device *dev,
u32 flags, u32 noflags)
{
struct fib6_node *fn;
struct rt6_info *rt = NULL;
struct fib6_table *table;
table = fib6_get_table(dev_net(dev),
addrconf_rt_table(dev, RT6_TABLE_PREFIX));
if (table == NULL)
return NULL;
write_lock_bh(&table->tb6_lock);
fn = fib6_locate(&table->tb6_root, pfx, plen, NULL, 0);
if (!fn)
goto out;
for (rt = fn->leaf; rt; rt = rt->dst.rt6_next) {
if (rt->dst.dev->ifindex != dev->ifindex)
continue;
if ((rt->rt6i_flags & flags) != flags)
continue;
if ((rt->rt6i_flags & noflags) != 0)
continue;
dst_hold(&rt->dst);
break;
}
out:
write_unlock_bh(&table->tb6_lock);
return rt;
}
/* Create "default" multicast route to the interface */
static void addrconf_add_mroute(struct net_device *dev)
{
struct fib6_config cfg = {
.fc_table = RT6_TABLE_LOCAL,
.fc_metric = IP6_RT_PRIO_ADDRCONF,
.fc_ifindex = dev->ifindex,
.fc_dst_len = 8,
.fc_flags = RTF_UP,
.fc_nlinfo.nl_net = dev_net(dev),
};
ipv6_addr_set(&cfg.fc_dst, htonl(0xFF000000), 0, 0, 0);
ip6_route_add(&cfg);
}
#if defined(CONFIG_IPV6_SIT) || defined(CONFIG_IPV6_SIT_MODULE)
static void sit_route_add(struct net_device *dev)
{
struct fib6_config cfg = {
.fc_table = RT6_TABLE_MAIN,
.fc_metric = IP6_RT_PRIO_ADDRCONF,
.fc_ifindex = dev->ifindex,
.fc_dst_len = 96,
.fc_flags = RTF_UP | RTF_NONEXTHOP,
.fc_nlinfo.nl_net = dev_net(dev),
};
/* prefix length - 96 bits "::d.d.d.d" */
ip6_route_add(&cfg);
}
#endif
static void addrconf_add_lroute(struct net_device *dev)
{
struct in6_addr addr;
ipv6_addr_set(&addr, htonl(0xFE800000), 0, 0, 0);
addrconf_prefix_route(&addr, 64, dev, 0, 0);
}
static struct inet6_dev *addrconf_add_dev(struct net_device *dev)
{
struct inet6_dev *idev;
ASSERT_RTNL();
idev = ipv6_find_idev(dev);
if (!idev)
return ERR_PTR(-ENOBUFS);
if (idev->cnf.disable_ipv6)
return ERR_PTR(-EACCES);
/* Add default multicast route */
if (!(dev->flags & IFF_LOOPBACK))
addrconf_add_mroute(dev);
/* Add link local route */
addrconf_add_lroute(dev);
return idev;
}
void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len, bool sllao)
{
struct prefix_info *pinfo;
__u32 valid_lft;
__u32 prefered_lft;
int addr_type;
struct inet6_dev *in6_dev;
struct net *net = dev_net(dev);
//
#ifdef CONFIG_LGP_DATA_TCPIP_SLAAC_IPV6_ALLOCATION_BOOSTER
printk(KERN_DEBUG "[LGE_DATA][%s()] The prefix is received now !", __func__);
#endif
//
pinfo = (struct prefix_info *) opt;
if (len < sizeof(struct prefix_info)) {
ADBG(("addrconf: prefix option too short\n"));
return;
}
/*
* Validation checks ([ADDRCONF], page 19)
*/
addr_type = ipv6_addr_type(&pinfo->prefix);
if (addr_type & (IPV6_ADDR_MULTICAST|IPV6_ADDR_LINKLOCAL))
return;
valid_lft = ntohl(pinfo->valid);
prefered_lft = ntohl(pinfo->prefered);
if (prefered_lft > valid_lft) {
if (net_ratelimit())
printk(KERN_WARNING "addrconf: prefix option has invalid lifetime\n");
return;
}
in6_dev = in6_dev_get(dev);
if (in6_dev == NULL) {
if (net_ratelimit())
printk(KERN_DEBUG "addrconf: device %s not configured\n", dev->name);
return;
}
/*
* Two things going on here:
* 1) Add routes for on-link prefixes
* 2) Configure prefixes with the auto flag set
*/
if (pinfo->onlink) {
struct rt6_info *rt;
unsigned long rt_expires;
/* Avoid arithmetic overflow. Really, we could
* save rt_expires in seconds, likely valid_lft,
* but it would require division in fib gc, that it
* not good.
*/
if (HZ > USER_HZ)
rt_expires = addrconf_timeout_fixup(valid_lft, HZ);
else
rt_expires = addrconf_timeout_fixup(valid_lft, USER_HZ);
if (addrconf_finite_timeout(rt_expires))
rt_expires *= HZ;
rt = addrconf_get_prefix_route(&pinfo->prefix,
pinfo->prefix_len,
dev,
RTF_ADDRCONF | RTF_PREFIX_RT,
RTF_GATEWAY | RTF_DEFAULT);
if (rt) {
/* Autoconf prefix route */
if (valid_lft == 0) {
ip6_del_rt(rt);
rt = NULL;
} else if (addrconf_finite_timeout(rt_expires)) {
/* not infinity */
rt6_set_expires(rt, jiffies + rt_expires);
} else {
rt6_clean_expires(rt);
}
} else if (valid_lft) {
clock_t expires = 0;
int flags = RTF_ADDRCONF | RTF_PREFIX_RT;
if (addrconf_finite_timeout(rt_expires)) {
/* not infinity */
flags |= RTF_EXPIRES;
expires = jiffies_to_clock_t(rt_expires);
}
if (dev->ip6_ptr->cnf.accept_ra_prefix_route) {
addrconf_prefix_route(&pinfo->prefix,
pinfo->prefix_len, dev, expires, flags);
}
}
if (rt)
dst_release(&rt->dst);
}
/* Try to figure out our local address for this prefix */
if (pinfo->autoconf && in6_dev->cnf.autoconf) {
struct inet6_ifaddr * ifp;
struct in6_addr addr;
int create = 0, update_lft = 0;
if (pinfo->prefix_len == 64) {
memcpy(&addr, &pinfo->prefix, 8);
if (ipv6_generate_eui64(addr.s6_addr + 8, dev) &&
ipv6_inherit_eui64(addr.s6_addr + 8, in6_dev)) {
in6_dev_put(in6_dev);
return;
}
goto ok;
}
if (net_ratelimit())
printk(KERN_DEBUG "IPv6 addrconf: prefix with wrong length %d\n",
pinfo->prefix_len);
in6_dev_put(in6_dev);
return;
ok:
ifp = ipv6_get_ifaddr(net, &addr, dev, 1);
if (ifp == NULL && valid_lft) {
int max_addresses = in6_dev->cnf.max_addresses;
u32 addr_flags = 0;
#ifdef CONFIG_IPV6_OPTIMISTIC_DAD
if (in6_dev->cnf.optimistic_dad &&
!net->ipv6.devconf_all->forwarding && sllao)
addr_flags = IFA_F_OPTIMISTIC;
#endif
/* Do not allow to create too much of autoconfigured
* addresses; this would be too easy way to crash kernel.
*/
if (!max_addresses ||
ipv6_count_addresses(in6_dev) < max_addresses)
ifp = ipv6_add_addr(in6_dev, &addr, pinfo->prefix_len,
addr_type&IPV6_ADDR_SCOPE_MASK,
addr_flags);
if (!ifp || IS_ERR(ifp)) {
in6_dev_put(in6_dev);
return;
}
update_lft = create = 1;
ifp->cstamp = jiffies;
addrconf_dad_start(ifp, RTF_ADDRCONF|RTF_PREFIX_RT);
}
if (ifp) {
int flags;
unsigned long now;
#ifdef CONFIG_IPV6_PRIVACY
struct inet6_ifaddr *ift;
#endif
u32 stored_lft;
/* update lifetime (RFC2462 5.5.3 e) */
spin_lock(&ifp->lock);
now = jiffies;
if (ifp->valid_lft > (now - ifp->tstamp) / HZ)
stored_lft = ifp->valid_lft - (now - ifp->tstamp) / HZ;
else
stored_lft = 0;
if (!update_lft && stored_lft) {
if (valid_lft > MIN_VALID_LIFETIME ||
valid_lft > stored_lft)
update_lft = 1;
else if (stored_lft <= MIN_VALID_LIFETIME) {
/* valid_lft <= stored_lft is always true */
/*
* RFC 4862 Section 5.5.3e:
* "Note that the preferred lifetime of
* the corresponding address is always
* reset to the Preferred Lifetime in
* the received Prefix Information
* option, regardless of whether the
* valid lifetime is also reset or
* ignored."
*
* So if the preferred lifetime in
* this advertisement is different
* than what we have stored, but the
* valid lifetime is invalid, just
* reset prefered_lft.
*
* We must set the valid lifetime
* to the stored lifetime since we'll
* be updating the timestamp below,
* else we'll set it back to the
* minimum.
*/
if (prefered_lft != ifp->prefered_lft) {
valid_lft = stored_lft;
update_lft = 1;
}
} else {
valid_lft = MIN_VALID_LIFETIME;
if (valid_lft < prefered_lft)
prefered_lft = valid_lft;
update_lft = 1;
}
}
if (update_lft) {
ifp->valid_lft = valid_lft;
ifp->prefered_lft = prefered_lft;
ifp->tstamp = now;
flags = ifp->flags;
ifp->flags &= ~IFA_F_DEPRECATED;
spin_unlock(&ifp->lock);
if (!(flags&IFA_F_TENTATIVE))
ipv6_ifa_notify(0, ifp);
} else
spin_unlock(&ifp->lock);
#ifdef CONFIG_IPV6_PRIVACY
read_lock_bh(&in6_dev->lock);
/* update all temporary addresses in the list */
list_for_each_entry(ift, &in6_dev->tempaddr_list,
tmp_list) {
int age, max_valid, max_prefered;
if (ifp != ift->ifpub)
continue;
/*
* RFC 4941 section 3.3:
* If a received option will extend the lifetime
* of a public address, the lifetimes of
* temporary addresses should be extended,
* subject to the overall constraint that no
* temporary addresses should ever remain
* "valid" or "preferred" for a time longer than
* (TEMP_VALID_LIFETIME) or
* (TEMP_PREFERRED_LIFETIME - DESYNC_FACTOR),
* respectively.
*/
age = (now - ift->cstamp) / HZ;
max_valid = in6_dev->cnf.temp_valid_lft - age;
if (max_valid < 0)
max_valid = 0;
max_prefered = in6_dev->cnf.temp_prefered_lft -
in6_dev->cnf.max_desync_factor -
age;
if (max_prefered < 0)
max_prefered = 0;
if (valid_lft > max_valid)
valid_lft = max_valid;
if (prefered_lft > max_prefered)
prefered_lft = max_prefered;
spin_lock(&ift->lock);
flags = ift->flags;
ift->valid_lft = valid_lft;
ift->prefered_lft = prefered_lft;
ift->tstamp = now;
if (prefered_lft > 0)
ift->flags &= ~IFA_F_DEPRECATED;
spin_unlock(&ift->lock);
if (!(flags&IFA_F_TENTATIVE))
ipv6_ifa_notify(0, ift);
}
if ((create || list_empty(&in6_dev->tempaddr_list)) && in6_dev->cnf.use_tempaddr > 0) {
/*
* When a new public address is created as
* described in [ADDRCONF], also create a new
* temporary address. Also create a temporary
* address if it's enabled but no temporary
* address currently exists.
*/
read_unlock_bh(&in6_dev->lock);
ipv6_create_tempaddr(ifp, NULL);
} else {
read_unlock_bh(&in6_dev->lock);
}
#endif
in6_ifa_put(ifp);
addrconf_verify(0);
}
}
inet6_prefix_notify(RTM_NEWPREFIX, in6_dev, pinfo);
in6_dev_put(in6_dev);
}
/*
* Set destination address.
* Special case for SIT interfaces where we create a new "virtual"
* device.
*/
int addrconf_set_dstaddr(struct net *net, void __user *arg)
{
struct in6_ifreq ireq;
struct net_device *dev;
int err = -EINVAL;
rtnl_lock();
err = -EFAULT;
if (copy_from_user(&ireq, arg, sizeof(struct in6_ifreq)))
goto err_exit;
dev = __dev_get_by_index(net, ireq.ifr6_ifindex);
err = -ENODEV;
if (dev == NULL)
goto err_exit;
#if defined(CONFIG_IPV6_SIT) || defined(CONFIG_IPV6_SIT_MODULE)
if (dev->type == ARPHRD_SIT) {
const struct net_device_ops *ops = dev->netdev_ops;
struct ifreq ifr;
struct ip_tunnel_parm p;
err = -EADDRNOTAVAIL;
if (!(ipv6_addr_type(&ireq.ifr6_addr) & IPV6_ADDR_COMPATv4))
goto err_exit;
memset(&p, 0, sizeof(p));
p.iph.daddr = ireq.ifr6_addr.s6_addr32[3];
p.iph.saddr = 0;
p.iph.version = 4;
p.iph.ihl = 5;
p.iph.protocol = IPPROTO_IPV6;
p.iph.ttl = 64;
ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
if (ops->ndo_do_ioctl) {
mm_segment_t oldfs = get_fs();
set_fs(KERNEL_DS);
err = ops->ndo_do_ioctl(dev, &ifr, SIOCADDTUNNEL);
set_fs(oldfs);
} else
err = -EOPNOTSUPP;
if (err == 0) {
err = -ENOBUFS;
dev = __dev_get_by_name(net, p.name);
if (!dev)
goto err_exit;
err = dev_open(dev);
}
}
#endif
err_exit:
rtnl_unlock();
return err;
}
/*
* Manual configuration of address on an interface
*/
static int inet6_addr_add(struct net *net, int ifindex, const struct in6_addr *pfx,
unsigned int plen, __u8 ifa_flags, __u32 prefered_lft,
__u32 valid_lft)
{
struct inet6_ifaddr *ifp;
struct inet6_dev *idev;
struct net_device *dev;
int scope;
u32 flags;
clock_t expires;
unsigned long timeout;
ASSERT_RTNL();
if (plen > 128)
return -EINVAL;
/* check the lifetime */
if (!valid_lft || prefered_lft > valid_lft)
return -EINVAL;
dev = __dev_get_by_index(net, ifindex);
if (!dev)
return -ENODEV;
idev = addrconf_add_dev(dev);
if (IS_ERR(idev))
return PTR_ERR(idev);
scope = ipv6_addr_scope(pfx);
timeout = addrconf_timeout_fixup(valid_lft, HZ);
if (addrconf_finite_timeout(timeout)) {
expires = jiffies_to_clock_t(timeout * HZ);
valid_lft = timeout;
flags = RTF_EXPIRES;
} else {
expires = 0;
flags = 0;
ifa_flags |= IFA_F_PERMANENT;
}
timeout = addrconf_timeout_fixup(prefered_lft, HZ);
if (addrconf_finite_timeout(timeout)) {
if (timeout == 0)
ifa_flags |= IFA_F_DEPRECATED;
prefered_lft = timeout;
}
ifp = ipv6_add_addr(idev, pfx, plen, scope, ifa_flags);
if (!IS_ERR(ifp)) {
spin_lock_bh(&ifp->lock);
ifp->valid_lft = valid_lft;
ifp->prefered_lft = prefered_lft;
ifp->tstamp = jiffies;
spin_unlock_bh(&ifp->lock);
addrconf_prefix_route(&ifp->addr, ifp->prefix_len, dev,
expires, flags);
/*
* Note that section 3.1 of RFC 4429 indicates
* that the Optimistic flag should not be set for
* manually configured addresses
*/
addrconf_dad_start(ifp, 0);
in6_ifa_put(ifp);
addrconf_verify(0);
return 0;
}
return PTR_ERR(ifp);
}
static int inet6_addr_del(struct net *net, int ifindex, const struct in6_addr *pfx,
unsigned int plen)
{
struct inet6_ifaddr *ifp;
struct inet6_dev *idev;
struct net_device *dev;
if (plen > 128)
return -EINVAL;
dev = __dev_get_by_index(net, ifindex);
if (!dev)
return -ENODEV;
if ((idev = __in6_dev_get(dev)) == NULL)
return -ENXIO;
read_lock_bh(&idev->lock);
list_for_each_entry(ifp, &idev->addr_list, if_list) {
if (ifp->prefix_len == plen &&
ipv6_addr_equal(pfx, &ifp->addr)) {
in6_ifa_hold(ifp);
read_unlock_bh(&idev->lock);
ipv6_del_addr(ifp);
/* If the last address is deleted administratively,
disable IPv6 on this interface.
*/
if (list_empty(&idev->addr_list))
addrconf_ifdown(idev->dev, 1);
return 0;
}
}
read_unlock_bh(&idev->lock);
return -EADDRNOTAVAIL;
}
int addrconf_add_ifaddr(struct net *net, void __user *arg)
{
struct in6_ifreq ireq;
int err;
if (!capable(CAP_NET_ADMIN))
return -EPERM;
if (copy_from_user(&ireq, arg, sizeof(struct in6_ifreq)))
return -EFAULT;
rtnl_lock();
err = inet6_addr_add(net, ireq.ifr6_ifindex, &ireq.ifr6_addr,
ireq.ifr6_prefixlen, IFA_F_PERMANENT,
INFINITY_LIFE_TIME, INFINITY_LIFE_TIME);
rtnl_unlock();
return err;
}
int addrconf_del_ifaddr(struct net *net, void __user *arg)
{
struct in6_ifreq ireq;
int err;
if (!capable(CAP_NET_ADMIN))
return -EPERM;
if (copy_from_user(&ireq, arg, sizeof(struct in6_ifreq)))
return -EFAULT;
rtnl_lock();
err = inet6_addr_del(net, ireq.ifr6_ifindex, &ireq.ifr6_addr,
ireq.ifr6_prefixlen);
rtnl_unlock();
return err;
}
static void add_addr(struct inet6_dev *idev, const struct in6_addr *addr,
int plen, int scope)
{
struct inet6_ifaddr *ifp;
ifp = ipv6_add_addr(idev, addr, plen, scope, IFA_F_PERMANENT);
if (!IS_ERR(ifp)) {
spin_lock_bh(&ifp->lock);
ifp->flags &= ~IFA_F_TENTATIVE;
spin_unlock_bh(&ifp->lock);
ipv6_ifa_notify(RTM_NEWADDR, ifp);
in6_ifa_put(ifp);
}
}
#if defined(CONFIG_IPV6_SIT) || defined(CONFIG_IPV6_SIT_MODULE)
static void sit_add_v4_addrs(struct inet6_dev *idev)
{
struct in6_addr addr;
struct net_device *dev;
struct net *net = dev_net(idev->dev);
int scope;
ASSERT_RTNL();
memset(&addr, 0, sizeof(struct in6_addr));
memcpy(&addr.s6_addr32[3], idev->dev->dev_addr, 4);
if (idev->dev->flags&IFF_POINTOPOINT) {
addr.s6_addr32[0] = htonl(0xfe800000);
scope = IFA_LINK;
} else {
scope = IPV6_ADDR_COMPATv4;
}
if (addr.s6_addr32[3]) {
add_addr(idev, &addr, 128, scope);
return;
}
for_each_netdev(net, dev) {
struct in_device * in_dev = __in_dev_get_rtnl(dev);
if (in_dev && (dev->flags & IFF_UP)) {
struct in_ifaddr * ifa;
int flag = scope;
for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
int plen;
addr.s6_addr32[3] = ifa->ifa_local;
if (ifa->ifa_scope == RT_SCOPE_LINK)
continue;
if (ifa->ifa_scope >= RT_SCOPE_HOST) {
if (idev->dev->flags&IFF_POINTOPOINT)
continue;
flag |= IFA_HOST;
}
if (idev->dev->flags&IFF_POINTOPOINT)
plen = 64;
else
plen = 96;
add_addr(idev, &addr, plen, flag);
}
}
}
}
#endif
static void init_loopback(struct net_device *dev)
{
struct inet6_dev *idev;
struct net_device *sp_dev;
struct inet6_ifaddr *sp_ifa;
struct rt6_info *sp_rt;
/* ::1 */
ASSERT_RTNL();
if ((idev = ipv6_find_idev(dev)) == NULL) {
printk(KERN_DEBUG "init loopback: add_dev failed\n");
return;
}
add_addr(idev, &in6addr_loopback, 128, IFA_HOST);
/* Add routes to other interface's IPv6 addresses */
for_each_netdev(dev_net(dev), sp_dev) {
if (!strcmp(sp_dev->name, dev->name))
continue;
idev = __in6_dev_get(sp_dev);
if (!idev)
continue;
read_lock_bh(&idev->lock);
list_for_each_entry(sp_ifa, &idev->addr_list, if_list) {
if (sp_ifa->flags & (IFA_F_DADFAILED | IFA_F_TENTATIVE))
continue;
if (sp_ifa->rt) {
/* This dst has been added to garbage list when
* lo device down, release this obsolete dst and
* reallocate a new router for ifa.
*/
if (sp_ifa->rt->dst.obsolete > 0) {
dst_release(&sp_ifa->rt->dst);
sp_ifa->rt = NULL;
} else {
continue;
}
}
sp_rt = addrconf_dst_alloc(idev, &sp_ifa->addr, 0);
/* Failure cases are ignored */
if (!IS_ERR(sp_rt)) {
sp_ifa->rt = sp_rt;
ip6_ins_rt(sp_rt);
}
}
read_unlock_bh(&idev->lock);
}
}
static void addrconf_add_linklocal(struct inet6_dev *idev, const struct in6_addr *addr)
{
struct inet6_ifaddr * ifp;
u32 addr_flags = IFA_F_PERMANENT;
#ifdef CONFIG_IPV6_OPTIMISTIC_DAD
if (idev->cnf.optimistic_dad &&
!dev_net(idev->dev)->ipv6.devconf_all->forwarding)
addr_flags |= IFA_F_OPTIMISTIC;
#endif
ifp = ipv6_add_addr(idev, addr, 64, IFA_LINK, addr_flags);
if (!IS_ERR(ifp)) {
addrconf_prefix_route(&ifp->addr, ifp->prefix_len, idev->dev, 0, 0);
addrconf_dad_start(ifp, 0);
in6_ifa_put(ifp);
}
}
static void addrconf_dev_config(struct net_device *dev)
{
struct in6_addr addr;
struct inet6_dev * idev;
ASSERT_RTNL();
if ((dev->type != ARPHRD_ETHER) &&
(dev->type != ARPHRD_FDDI) &&
(dev->type != ARPHRD_IEEE802_TR) &&
(dev->type != ARPHRD_ARCNET) &&
(dev->type != ARPHRD_RAWIP) &&
(dev->type != ARPHRD_INFINIBAND)) {
/* Alas, we support only Ethernet autoconfiguration. */
return;
}
idev = addrconf_add_dev(dev);
if (IS_ERR(idev))
return;
memset(&addr, 0, sizeof(struct in6_addr));
addr.s6_addr32[0] = htonl(0xFE800000);
if (ipv6_generate_eui64(addr.s6_addr + 8, dev) == 0)
addrconf_add_linklocal(idev, &addr);
}
#if defined(CONFIG_IPV6_SIT) || defined(CONFIG_IPV6_SIT_MODULE)
static void addrconf_sit_config(struct net_device *dev)
{
struct inet6_dev *idev;
ASSERT_RTNL();
/*
* Configure the tunnel with one of our IPv4
* addresses... we should configure all of
* our v4 addrs in the tunnel
*/
if ((idev = ipv6_find_idev(dev)) == NULL) {
printk(KERN_DEBUG "init sit: add_dev failed\n");
return;
}
if (dev->priv_flags & IFF_ISATAP) {
struct in6_addr addr;
ipv6_addr_set(&addr, htonl(0xFE800000), 0, 0, 0);
addrconf_prefix_route(&addr, 64, dev, 0, 0);
if (!ipv6_generate_eui64(addr.s6_addr + 8, dev))
addrconf_add_linklocal(idev, &addr);
return;
}
sit_add_v4_addrs(idev);
if (dev->flags&IFF_POINTOPOINT) {
addrconf_add_mroute(dev);
addrconf_add_lroute(dev);
} else
sit_route_add(dev);
}
#endif
#if defined(CONFIG_NET_IPGRE) || defined(CONFIG_NET_IPGRE_MODULE)
static void addrconf_gre_config(struct net_device *dev)
{
struct inet6_dev *idev;
struct in6_addr addr;
pr_info("ipv6: addrconf_gre_config(%s)\n", dev->name);
ASSERT_RTNL();
if ((idev = ipv6_find_idev(dev)) == NULL) {
printk(KERN_DEBUG "init gre: add_dev failed\n");
return;
}
ipv6_addr_set(&addr, htonl(0xFE800000), 0, 0, 0);
addrconf_prefix_route(&addr, 64, dev, 0, 0);
if (!ipv6_generate_eui64(addr.s6_addr + 8, dev))
addrconf_add_linklocal(idev, &addr);
}
#endif
static inline int
ipv6_inherit_linklocal(struct inet6_dev *idev, struct net_device *link_dev)
{
struct in6_addr lladdr;
if (!ipv6_get_lladdr(link_dev, &lladdr, IFA_F_TENTATIVE)) {
addrconf_add_linklocal(idev, &lladdr);
return 0;
}
return -1;
}
static void ip6_tnl_add_linklocal(struct inet6_dev *idev)
{
struct net_device *link_dev;
struct net *net = dev_net(idev->dev);
/* first try to inherit the link-local address from the link device */
if (idev->dev->iflink &&
(link_dev = __dev_get_by_index(net, idev->dev->iflink))) {
if (!ipv6_inherit_linklocal(idev, link_dev))
return;
}
/* then try to inherit it from any device */
for_each_netdev(net, link_dev) {
if (!ipv6_inherit_linklocal(idev, link_dev))
return;
}
printk(KERN_DEBUG "init ip6-ip6: add_linklocal failed\n");
}
/*
* Autoconfigure tunnel with a link-local address so routing protocols,
* DHCPv6, MLD etc. can be run over the virtual link
*/
static void addrconf_ip6_tnl_config(struct net_device *dev)
{
struct inet6_dev *idev;
ASSERT_RTNL();
idev = addrconf_add_dev(dev);
if (IS_ERR(idev)) {
printk(KERN_DEBUG "init ip6-ip6: add_dev failed\n");
return;
}
ip6_tnl_add_linklocal(idev);
}
static int addrconf_notify(struct notifier_block *this, unsigned long event,
void * data)
{
struct net_device *dev = (struct net_device *) data;
struct inet6_dev *idev = __in6_dev_get(dev);
int run_pending = 0;
int err;
switch (event) {
case NETDEV_REGISTER:
if (!idev && dev->mtu >= IPV6_MIN_MTU) {
idev = ipv6_add_dev(dev);
if (!idev)
return notifier_from_errno(-ENOMEM);
}
break;
case NETDEV_UP:
case NETDEV_CHANGE:
if (dev->flags & IFF_SLAVE)
break;
if (event == NETDEV_UP) {
if (!addrconf_qdisc_ok(dev)) {
/* device is not ready yet. */
printk(KERN_INFO
"ADDRCONF(NETDEV_UP): %s: "
"link is not ready\n",
dev->name);
break;
}
if (!idev && dev->mtu >= IPV6_MIN_MTU)
idev = ipv6_add_dev(dev);
if (idev) {
idev->if_flags |= IF_READY;
run_pending = 1;
}
} else {
if (!addrconf_qdisc_ok(dev)) {
/* device is still not ready. */
break;
}
if (idev) {
if (idev->if_flags & IF_READY)
/* device is already configured. */
break;
idev->if_flags |= IF_READY;
}
printk(KERN_INFO
"ADDRCONF(NETDEV_CHANGE): %s: "
"link becomes ready\n",
dev->name);
run_pending = 1;
}
switch (dev->type) {
#if defined(CONFIG_IPV6_SIT) || defined(CONFIG_IPV6_SIT_MODULE)
case ARPHRD_SIT:
addrconf_sit_config(dev);
break;
#endif
#if defined(CONFIG_NET_IPGRE) || defined(CONFIG_NET_IPGRE_MODULE)
case ARPHRD_IPGRE:
addrconf_gre_config(dev);
break;
#endif
case ARPHRD_TUNNEL6:
addrconf_ip6_tnl_config(dev);
break;
case ARPHRD_LOOPBACK:
init_loopback(dev);
break;
default:
addrconf_dev_config(dev);
break;
}
if (idev) {
if (run_pending)
addrconf_dad_run(idev);
/*
* If the MTU changed during the interface down,
* when the interface up, the changed MTU must be
* reflected in the idev as well as routers.
*/
if (idev->cnf.mtu6 != dev->mtu &&
dev->mtu >= IPV6_MIN_MTU) {
rt6_mtu_change(dev, dev->mtu);
idev->cnf.mtu6 = dev->mtu;
}
idev->tstamp = jiffies;
inet6_ifinfo_notify(RTM_NEWLINK, idev);
/*
* If the changed mtu during down is lower than
* IPV6_MIN_MTU stop IPv6 on this interface.
*/
if (dev->mtu < IPV6_MIN_MTU)
addrconf_ifdown(dev, 1);
}
break;
case NETDEV_CHANGEMTU:
if (idev && dev->mtu >= IPV6_MIN_MTU) {
rt6_mtu_change(dev, dev->mtu);
idev->cnf.mtu6 = dev->mtu;
break;
}
if (!idev && dev->mtu >= IPV6_MIN_MTU) {
idev = ipv6_add_dev(dev);
if (idev)
break;
}
/*
* MTU falled under IPV6_MIN_MTU.
* Stop IPv6 on this interface.
*/
case NETDEV_DOWN:
case NETDEV_UNREGISTER:
/*
* Remove all addresses from this interface.
*/
addrconf_ifdown(dev, event != NETDEV_DOWN);
break;
case NETDEV_CHANGENAME:
if (idev) {
snmp6_unregister_dev(idev);
addrconf_sysctl_unregister(idev);
addrconf_sysctl_register(idev);
err = snmp6_register_dev(idev);
if (err)
return notifier_from_errno(err);
}
break;
case NETDEV_PRE_TYPE_CHANGE:
case NETDEV_POST_TYPE_CHANGE:
addrconf_type_change(dev, event);
break;
}
return NOTIFY_OK;
}
/*
* addrconf module should be notified of a device going up
*/
static struct notifier_block ipv6_dev_notf = {
.notifier_call = addrconf_notify,
};
static void addrconf_type_change(struct net_device *dev, unsigned long event)
{
struct inet6_dev *idev;
ASSERT_RTNL();
idev = __in6_dev_get(dev);
if (event == NETDEV_POST_TYPE_CHANGE)
ipv6_mc_remap(idev);
else if (event == NETDEV_PRE_TYPE_CHANGE)
ipv6_mc_unmap(idev);
}
static int addrconf_ifdown(struct net_device *dev, int how)
{
struct net *net = dev_net(dev);
struct inet6_dev *idev;
struct inet6_ifaddr *ifa;
int state, i;
ASSERT_RTNL();
rt6_ifdown(net, dev);
neigh_ifdown(&nd_tbl, dev);
idev = __in6_dev_get(dev);
if (idev == NULL)
return -ENODEV;
/*
* Step 1: remove reference to ipv6 device from parent device.
* Do not dev_put!
*/
if (how) {
idev->dead = 1;
/* protected by rtnl_lock */
RCU_INIT_POINTER(dev->ip6_ptr, NULL);
/* Step 1.5: remove snmp6 entry */
snmp6_unregister_dev(idev);
}
/* Step 2: clear hash table */
spin_lock_bh(&addrconf_hash_lock);
for (i = 0; i < IN6_ADDR_HSIZE; i++) {
struct hlist_head *h = &inet6_addr_lst[i];
struct hlist_node *n;
restart:
hlist_for_each_entry_rcu(ifa, n, h, addr_lst) {
if (ifa->idev == idev) {
hlist_del_init_rcu(&ifa->addr_lst);
addrconf_del_timer(ifa);
goto restart;
}
}
}
write_lock_bh(&idev->lock);
/* Step 2: clear flags for stateless addrconf */
if (!how)
idev->if_flags &= ~(IF_RS_SENT|IF_RA_RCVD|IF_READY);
#ifdef CONFIG_IPV6_PRIVACY
if (how && del_timer(&idev->regen_timer))
in6_dev_put(idev);
/* Step 3: clear tempaddr list */
while (!list_empty(&idev->tempaddr_list)) {
ifa = list_first_entry(&idev->tempaddr_list,
struct inet6_ifaddr, tmp_list);
list_del(&ifa->tmp_list);
write_unlock_bh(&idev->lock);
spin_lock_bh(&ifa->lock);
if (ifa->ifpub) {
in6_ifa_put(ifa->ifpub);
ifa->ifpub = NULL;
}
spin_unlock_bh(&ifa->lock);
in6_ifa_put(ifa);
write_lock_bh(&idev->lock);
}
#endif
while (!list_empty(&idev->addr_list)) {
ifa = list_first_entry(&idev->addr_list,
struct inet6_ifaddr, if_list);
addrconf_del_timer(ifa);
list_del(&ifa->if_list);
write_unlock_bh(&idev->lock);
spin_lock_bh(&ifa->state_lock);
state = ifa->state;
ifa->state = INET6_IFADDR_STATE_DEAD;
spin_unlock_bh(&ifa->state_lock);
if (state != INET6_IFADDR_STATE_DEAD) {
__ipv6_ifa_notify(RTM_DELADDR, ifa);
atomic_notifier_call_chain(&inet6addr_chain, NETDEV_DOWN, ifa);
}
in6_ifa_put(ifa);
write_lock_bh(&idev->lock);
}
write_unlock_bh(&idev->lock);
spin_unlock_bh(&addrconf_hash_lock);
/* Step 5: Discard anycast and multicast list */
if (how) {
ipv6_ac_destroy_dev(idev);
ipv6_mc_destroy_dev(idev);
} else {
ipv6_mc_down(idev);
}
idev->tstamp = jiffies;
/* Last: Shot the device (if unregistered) */
if (how) {
addrconf_sysctl_unregister(idev);
neigh_parms_release(&nd_tbl, idev->nd_parms);
neigh_ifdown(&nd_tbl, dev);
in6_dev_put(idev);
}
return 0;
}
static void addrconf_rs_timer(unsigned long data)
{
struct inet6_ifaddr *ifp = (struct inet6_ifaddr *) data;
struct inet6_dev *idev = ifp->idev;
read_lock(&idev->lock);
if (idev->dead || !(idev->if_flags & IF_READY))
goto out;
if (idev->cnf.forwarding)
goto out;
/* Announcement received after solicitation was sent */
//
if (idev->if_flags & IF_RA_RCVD){
#ifdef CONFIG_LGP_DATA_TCPIP_SLAAC_IPV6_ALLOCATION_BOOSTER
printk(KERN_DEBUG "[LGE_DATA][%s()] The RA msg had been received!", __func__);
#endif
goto out;
}
//
spin_lock(&ifp->lock);
if (ifp->probes++ < idev->cnf.rtr_solicits) {
/* The wait after the last probe can be shorter */
addrconf_mod_timer(ifp, AC_RS,
(ifp->probes == idev->cnf.rtr_solicits) ?
idev->cnf.rtr_solicit_delay :
idev->cnf.rtr_solicit_interval);
spin_unlock(&ifp->lock);
//
#ifdef CONFIG_LGP_DATA_TCPIP_SLAAC_IPV6_ALLOCATION_BOOSTER
printk(KERN_DEBUG "[LGE_DATA][%s()][stage 2] rs is sent now!", __func__);
#endif
//
ndisc_send_rs(idev->dev, &ifp->addr, &in6addr_linklocal_allrouters);
} else {
spin_unlock(&ifp->lock);
/*
* Note: we do not support deprecated "all on-link"
* assumption any longer.
*/
printk(KERN_DEBUG "%s: no IPv6 routers present\n",
idev->dev->name);
}
out:
read_unlock(&idev->lock);
in6_ifa_put(ifp);
}
/*
* Duplicate Address Detection
*/
static void addrconf_dad_kick(struct inet6_ifaddr *ifp)
{
unsigned long rand_num;
struct inet6_dev *idev = ifp->idev;
if (ifp->flags & IFA_F_OPTIMISTIC)
rand_num = 0;
else
rand_num = net_random() % (idev->cnf.rtr_solicit_delay ? : 1);
ifp->probes = idev->cnf.dad_transmits;
//
#ifdef CONFIG_LGP_DATA_TCPIP_SLAAC_IPV6_ALLOCATION_BOOSTER
printk(KERN_DEBUG "[LGE_DATA][%s()] dad_transmits == %d, ramd_num == %lu", __func__, idev->cnf.dad_transmits, rand_num);
#endif
//
addrconf_mod_timer(ifp, AC_DAD, rand_num);
}
static void addrconf_dad_start(struct inet6_ifaddr *ifp, u32 flags)
{
struct inet6_dev *idev = ifp->idev;
struct net_device *dev = idev->dev;
//
#ifdef CONFIG_LGP_DATA_TCPIP_SLAAC_IPV6_ALLOCATION_BOOSTER
int ipv6AddrType = 0; //initializing
const char InterfaceNameToApply[6]="rmnet";
char CurrentInterfaceName[6]={0};//initializing
ipv6AddrType = ipv6_addr_type(&ifp->addr);
printk(KERN_DEBUG "[LGE_DATA][%s()] dad_start! dev_name == %s", __func__, dev->name);
printk(KERN_DEBUG "[LGE_DATA][%s()] ipv6_addr_type == %d", __func__, ipv6AddrType);
strncpy(CurrentInterfaceName,dev->name,5);
if(CurrentInterfaceName == NULL){
printk(KERN_DEBUG "[LGE_DATA] CurrentInterfaceName is NULL !\n");
return;
}
#endif
//
addrconf_join_solict(dev, &ifp->addr);
net_srandom(ifp->addr.s6_addr32[3]);
read_lock_bh(&idev->lock);
spin_lock(&ifp->lock);
if (ifp->state == INET6_IFADDR_STATE_DEAD)
goto out;
//
#ifdef CONFIG_LGP_DATA_TCPIP_SLAAC_IPV6_ALLOCATION_BOOSTER
if (((strcmp(InterfaceNameToApply, CurrentInterfaceName) == 0) && (ipv6AddrType == LGE_DATA_GLOBAL_SCOPE))
|| (dev->flags&(IFF_NOARP|IFF_LOOPBACK) ||
idev->cnf.accept_dad < 1 ||
!(ifp->flags&IFA_F_TENTATIVE) ||
ifp->flags & IFA_F_NODAD))
#else
// Kernel Original implemenatation START
if (dev->flags&(IFF_NOARP|IFF_LOOPBACK) ||
idev->cnf.accept_dad < 1 ||
!(ifp->flags&IFA_F_TENTATIVE) ||
ifp->flags & IFA_F_NODAD)
// Kernel Original implemenatation END
#endif
//
{
ifp->flags &= ~(IFA_F_TENTATIVE|IFA_F_OPTIMISTIC|IFA_F_DADFAILED);
spin_unlock(&ifp->lock);
read_unlock_bh(&idev->lock);
//
#ifdef CONFIG_LGP_DATA_TCPIP_SLAAC_IPV6_ALLOCATION_BOOSTER
printk(KERN_DEBUG "[LGE_DATA][%s()] ipv6_addr_type == %d, Because the IPv6 type is Global Scope, we will immediately finish the DAD process for Global Scope.", __func__, ipv6AddrType);
#endif
//
addrconf_dad_completed(ifp);
return;
}
if (!(idev->if_flags & IF_READY)) {
spin_unlock(&ifp->lock);
read_unlock_bh(&idev->lock);
/*
* If the device is not ready:
* - keep it tentative if it is a permanent address.
* - otherwise, kill it.
*/
in6_ifa_hold(ifp);
addrconf_dad_stop(ifp, 0);
return;
}
/*
* Optimistic nodes can start receiving
* Frames right away
*/
if (ifp->flags & IFA_F_OPTIMISTIC) {
ip6_ins_rt(ifp->rt);
if (ipv6_use_optimistic_addr(idev)) {
/* Because optimistic nodes can use this address,
* notify listeners. If DAD fails, RTM_DELADDR is sent.
*/
ipv6_ifa_notify(RTM_NEWADDR, ifp);
}
}
addrconf_dad_kick(ifp);
out:
spin_unlock(&ifp->lock);
read_unlock_bh(&idev->lock);
}
static void addrconf_dad_timer(unsigned long data)
{
struct inet6_ifaddr *ifp = (struct inet6_ifaddr *) data;
struct inet6_dev *idev = ifp->idev;
struct in6_addr mcaddr;
//
#ifdef CONFIG_LGP_DATA_TCPIP_SLAAC_IPV6_ALLOCATION_BOOSTER
struct net_device *dev = idev->dev;
const char InterfaceNameToApply[6]="rmnet";
char CurrentInterfaceName[6]={0};//initializing
#endif
//
if (!ifp->probes && addrconf_dad_end(ifp))
goto out;
read_lock(&idev->lock);
if (idev->dead || !(idev->if_flags & IF_READY)) {
read_unlock(&idev->lock);
goto out;
}
spin_lock(&ifp->lock);
if (ifp->state == INET6_IFADDR_STATE_DEAD) {
spin_unlock(&ifp->lock);
read_unlock(&idev->lock);
goto out;
}
if (ifp->probes == 0) {
/*
* DAD was successful
*/
//
#ifdef CONFIG_LGP_DATA_TCPIP_SLAAC_IPV6_ALLOCATION_BOOSTER
printk(KERN_DEBUG "[LGE_DATA][%s()] DAD was successful!", __func__);
#endif
//
ifp->flags &= ~(IFA_F_TENTATIVE|IFA_F_OPTIMISTIC|IFA_F_DADFAILED);
spin_unlock(&ifp->lock);
read_unlock(&idev->lock);
addrconf_dad_completed(ifp);
goto out;
}
ifp->probes--;
//
#ifdef CONFIG_LGP_DATA_TCPIP_SLAAC_IPV6_ALLOCATION_BOOSTER
printk(KERN_DEBUG "[LGE_DATA][%s()], ifp->idev->nd_parms->retrans_time == %d", __func__, ifp->idev->nd_parms->retrans_time);
printk(KERN_DEBUG "[LGE_DATA][%s()] dev_name == %s", __func__, dev->name);
strncpy(CurrentInterfaceName,dev->name,5);
if(CurrentInterfaceName == NULL){
spin_unlock(&ifp->lock);
read_unlock(&idev->lock);
printk(KERN_DEBUG "[LGE_DATA] CurrentInterfaceName is NULL !\n");
goto out;
}
printk(KERN_DEBUG "[LGE_DATA][%s()] CopyInterfaceName == %s, CurrentInterfaceName == %s", __func__, InterfaceNameToApply, CurrentInterfaceName);
if(strcmp(InterfaceNameToApply, CurrentInterfaceName) == 0){//In case of rmnet, this patch will be applied bacause We should not impact to the Wi-Fi and so on.
addrconf_mod_timer(ifp, AC_DAD, LGE_DATA_WAITING_TIME_FOR_DAD_OF_LGU);
printk(KERN_DEBUG "[LGE_DATA][%s()] The waiting time for link-local DAD is set as [%d] milli-seconds in case of only rmnet interface !", __func__, LGE_DATA_WAITING_TIME_FOR_DAD_OF_LGU*10);
}else{
//kernel original code -- START
addrconf_mod_timer(ifp, AC_DAD, ifp->idev->nd_parms->retrans_time);
//kernel original code -- END
}
#else
addrconf_mod_timer(ifp, AC_DAD, ifp->idev->nd_parms->retrans_time);
#endif
//
spin_unlock(&ifp->lock);
read_unlock(&idev->lock);
/* send a neighbour solicitation for our addr */
//
#ifdef CONFIG_LGP_DATA_TCPIP_SLAAC_IPV6_ALLOCATION_BOOSTER
printk(KERN_DEBUG "[LGE_DATA][%s()] send a neighbour solicitation for our addr !", __func__);
#endif
//
addrconf_addr_solict_mult(&ifp->addr, &mcaddr);
ndisc_send_ns(ifp->idev->dev, NULL, &ifp->addr, &mcaddr, &in6addr_any);
out:
in6_ifa_put(ifp);
}
static void addrconf_dad_completed(struct inet6_ifaddr *ifp)
{
struct net_device *dev = ifp->idev->dev;
/*
* Configure the address for reception. Now it is valid.
*/
ipv6_ifa_notify(RTM_NEWADDR, ifp);
//
#ifdef CONFIG_LGP_DATA_TCPIP_SLAAC_IPV6_ALLOCATION_BOOSTER
printk(KERN_DEBUG "[LGE_DATA][%s()] dad_is_completed!", __func__);
#endif
//
/* If added prefix is link local and we are prepared to process
router advertisements, start sending router solicitations.
*/
if (((ifp->idev->cnf.accept_ra == 1 && !ifp->idev->cnf.forwarding) ||
ifp->idev->cnf.accept_ra == 2) &&
ifp->idev->cnf.rtr_solicits > 0 &&
(dev->flags&IFF_LOOPBACK) == 0 &&
(ipv6_addr_type(&ifp->addr) & IPV6_ADDR_LINKLOCAL)) {
/*
* If a host as already performed a random delay
* [...] as part of DAD [...] there is no need
* to delay again before sending the first RS
*/
//
#ifdef CONFIG_LGP_DATA_TCPIP_SLAAC_IPV6_ALLOCATION_BOOSTER
printk(KERN_DEBUG "[LGE_DATA][%s()][stage 1] rs is sent now!", __func__);
#endif
//
ndisc_send_rs(ifp->idev->dev, &ifp->addr, &in6addr_linklocal_allrouters);
spin_lock_bh(&ifp->lock);
ifp->probes = 1;
ifp->idev->if_flags |= IF_RS_SENT;
addrconf_mod_timer(ifp, AC_RS, ifp->idev->cnf.rtr_solicit_interval);
spin_unlock_bh(&ifp->lock);
}
}
static void addrconf_dad_run(struct inet6_dev *idev)
{
struct inet6_ifaddr *ifp;
read_lock_bh(&idev->lock);
list_for_each_entry(ifp, &idev->addr_list, if_list) {
spin_lock(&ifp->lock);
if (ifp->flags & IFA_F_TENTATIVE &&
ifp->state == INET6_IFADDR_STATE_DAD)
addrconf_dad_kick(ifp);
spin_unlock(&ifp->lock);
}
read_unlock_bh(&idev->lock);
}
#ifdef CONFIG_PROC_FS
struct if6_iter_state {
struct seq_net_private p;
int bucket;
int offset;
};
static struct inet6_ifaddr *if6_get_first(struct seq_file *seq, loff_t pos)
{
struct inet6_ifaddr *ifa = NULL;
struct if6_iter_state *state = seq->private;
struct net *net = seq_file_net(seq);
int p = 0;
/* initial bucket if pos is 0 */
if (pos == 0) {
state->bucket = 0;
state->offset = 0;
}
for (; state->bucket < IN6_ADDR_HSIZE; ++state->bucket) {
struct hlist_node *n;
hlist_for_each_entry_rcu_bh(ifa, n, &inet6_addr_lst[state->bucket],
addr_lst) {
if (!net_eq(dev_net(ifa->idev->dev), net))
continue;
/* sync with offset */
if (p < state->offset) {
p++;
continue;
}
state->offset++;
return ifa;
}
/* prepare for next bucket */
state->offset = 0;
p = 0;
}
return NULL;
}
static struct inet6_ifaddr *if6_get_next(struct seq_file *seq,
struct inet6_ifaddr *ifa)
{
struct if6_iter_state *state = seq->private;
struct net *net = seq_file_net(seq);
struct hlist_node *n = &ifa->addr_lst;
hlist_for_each_entry_continue_rcu_bh(ifa, n, addr_lst) {
if (!net_eq(dev_net(ifa->idev->dev), net))
continue;
state->offset++;
return ifa;
}
while (++state->bucket < IN6_ADDR_HSIZE) {
state->offset = 0;
hlist_for_each_entry_rcu_bh(ifa, n,
&inet6_addr_lst[state->bucket], addr_lst) {
if (!net_eq(dev_net(ifa->idev->dev), net))
continue;
state->offset++;
return ifa;
}
}
return NULL;
}
static void *if6_seq_start(struct seq_file *seq, loff_t *pos)
__acquires(rcu_bh)
{
rcu_read_lock_bh();
return if6_get_first(seq, *pos);
}
static void *if6_seq_next(struct seq_file *seq, void *v, loff_t *pos)
{
struct inet6_ifaddr *ifa;
ifa = if6_get_next(seq, v);
++*pos;
return ifa;
}
static void if6_seq_stop(struct seq_file *seq, void *v)
__releases(rcu_bh)
{
rcu_read_unlock_bh();
}
static int if6_seq_show(struct seq_file *seq, void *v)
{
struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
&ifp->addr,
ifp->idev->dev->ifindex,
ifp->prefix_len,
ifp->scope,
ifp->flags,
ifp->idev->dev->name);
return 0;
}
static const struct seq_operations if6_seq_ops = {
.start = if6_seq_start,
.next = if6_seq_next,
.show = if6_seq_show,
.stop = if6_seq_stop,
};
static int if6_seq_open(struct inode *inode, struct file *file)
{
return seq_open_net(inode, file, &if6_seq_ops,
sizeof(struct if6_iter_state));
}
static const struct file_operations if6_fops = {
.owner = THIS_MODULE,
.open = if6_seq_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release_net,
};
static int __net_init if6_proc_net_init(struct net *net)
{
if (!proc_net_fops_create(net, "if_inet6", S_IRUGO, &if6_fops))
return -ENOMEM;
return 0;
}
static void __net_exit if6_proc_net_exit(struct net *net)
{
proc_net_remove(net, "if_inet6");
}
static struct pernet_operations if6_proc_net_ops = {
.init = if6_proc_net_init,
.exit = if6_proc_net_exit,
};
int __init if6_proc_init(void)
{
return register_pernet_subsys(&if6_proc_net_ops);
}
void if6_proc_exit(void)
{
unregister_pernet_subsys(&if6_proc_net_ops);
}
#endif /* CONFIG_PROC_FS */
#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
/* Check if address is a home address configured on any interface. */
int ipv6_chk_home_addr(struct net *net, const struct in6_addr *addr)
{
int ret = 0;
struct inet6_ifaddr *ifp = NULL;
struct hlist_node *n;
unsigned int hash = ipv6_addr_hash(addr);
rcu_read_lock_bh();
hlist_for_each_entry_rcu_bh(ifp, n, &inet6_addr_lst[hash], addr_lst) {
if (!net_eq(dev_net(ifp->idev->dev), net))
continue;
if (ipv6_addr_equal(&ifp->addr, addr) &&
(ifp->flags & IFA_F_HOMEADDRESS)) {
ret = 1;
break;
}
}
rcu_read_unlock_bh();
return ret;
}
#endif
/*
* Periodic address status verification
*/
static void addrconf_verify(unsigned long foo)
{
unsigned long now, next, next_sec, next_sched;
struct inet6_ifaddr *ifp;
struct hlist_node *node;
int i;
rcu_read_lock_bh();
spin_lock(&addrconf_verify_lock);
now = jiffies;
next = round_jiffies_up(now + ADDR_CHECK_FREQUENCY);
del_timer(&addr_chk_timer);
for (i = 0; i < IN6_ADDR_HSIZE; i++) {
restart:
hlist_for_each_entry_rcu_bh(ifp, node,
&inet6_addr_lst[i], addr_lst) {
unsigned long age;
if (ifp->flags & IFA_F_PERMANENT)
continue;
spin_lock(&ifp->lock);
/* We try to batch several events at once. */
age = (now - ifp->tstamp + ADDRCONF_TIMER_FUZZ_MINUS) / HZ;
if (ifp->valid_lft != INFINITY_LIFE_TIME &&
age >= ifp->valid_lft) {
spin_unlock(&ifp->lock);
in6_ifa_hold(ifp);
ipv6_del_addr(ifp);
goto restart;
} else if (ifp->prefered_lft == INFINITY_LIFE_TIME) {
spin_unlock(&ifp->lock);
continue;
} else if (age >= ifp->prefered_lft) {
/* jiffies - ifp->tstamp > age >= ifp->prefered_lft */
int deprecate = 0;
if (!(ifp->flags&IFA_F_DEPRECATED)) {
deprecate = 1;
ifp->flags |= IFA_F_DEPRECATED;
}
if (time_before(ifp->tstamp + ifp->valid_lft * HZ, next))
next = ifp->tstamp + ifp->valid_lft * HZ;
spin_unlock(&ifp->lock);
if (deprecate) {
in6_ifa_hold(ifp);
ipv6_ifa_notify(0, ifp);
in6_ifa_put(ifp);
goto restart;
}
#ifdef CONFIG_IPV6_PRIVACY
} else if ((ifp->flags&IFA_F_TEMPORARY) &&
!(ifp->flags&IFA_F_TENTATIVE)) {
unsigned long regen_advance = ifp->idev->cnf.regen_max_retry *
ifp->idev->cnf.dad_transmits *
ifp->idev->nd_parms->retrans_time / HZ;
if (age >= ifp->prefered_lft - regen_advance) {
struct inet6_ifaddr *ifpub = ifp->ifpub;
if (time_before(ifp->tstamp + ifp->prefered_lft * HZ, next))
next = ifp->tstamp + ifp->prefered_lft * HZ;
if (!ifp->regen_count && ifpub) {
ifp->regen_count++;
in6_ifa_hold(ifp);
in6_ifa_hold(ifpub);
spin_unlock(&ifp->lock);
spin_lock(&ifpub->lock);
ifpub->regen_count = 0;
spin_unlock(&ifpub->lock);
ipv6_create_tempaddr(ifpub, ifp);
in6_ifa_put(ifpub);
in6_ifa_put(ifp);
goto restart;
}
} else if (time_before(ifp->tstamp + ifp->prefered_lft * HZ - regen_advance * HZ, next))
next = ifp->tstamp + ifp->prefered_lft * HZ - regen_advance * HZ;
spin_unlock(&ifp->lock);
#endif
} else {
/* ifp->prefered_lft <= ifp->valid_lft */
if (time_before(ifp->tstamp + ifp->prefered_lft * HZ, next))
next = ifp->tstamp + ifp->prefered_lft * HZ;
spin_unlock(&ifp->lock);
}
}
}
next_sec = round_jiffies_up(next);
next_sched = next;
/* If rounded timeout is accurate enough, accept it. */
if (time_before(next_sec, next + ADDRCONF_TIMER_FUZZ))
next_sched = next_sec;
/* And minimum interval is ADDRCONF_TIMER_FUZZ_MAX. */
if (time_before(next_sched, jiffies + ADDRCONF_TIMER_FUZZ_MAX))
next_sched = jiffies + ADDRCONF_TIMER_FUZZ_MAX;
pr_debug("now = %lu, schedule = %lu, rounded schedule = %lu => %lu\n",
now, next, next_sec, next_sched);
addr_chk_timer.expires = next_sched;
add_timer(&addr_chk_timer);
spin_unlock(&addrconf_verify_lock);
rcu_read_unlock_bh();
}
static struct in6_addr *extract_addr(struct nlattr *addr, struct nlattr *local)
{
struct in6_addr *pfx = NULL;
if (addr)
pfx = nla_data(addr);
if (local) {
if (pfx && nla_memcmp(local, pfx, sizeof(*pfx)))
pfx = NULL;
else
pfx = nla_data(local);
}
return pfx;
}
static const struct nla_policy ifa_ipv6_policy[IFA_MAX+1] = {
[IFA_ADDRESS] = { .len = sizeof(struct in6_addr) },
[IFA_LOCAL] = { .len = sizeof(struct in6_addr) },
[IFA_CACHEINFO] = { .len = sizeof(struct ifa_cacheinfo) },
};
static int
inet6_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
{
struct net *net = sock_net(skb->sk);
struct ifaddrmsg *ifm;
struct nlattr *tb[IFA_MAX+1];
struct in6_addr *pfx;
int err;
err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFA_MAX, ifa_ipv6_policy);
if (err < 0)
return err;
ifm = nlmsg_data(nlh);
pfx = extract_addr(tb[IFA_ADDRESS], tb[IFA_LOCAL]);
if (pfx == NULL)
return -EINVAL;
return inet6_addr_del(net, ifm->ifa_index, pfx, ifm->ifa_prefixlen);
}
static int inet6_addr_modify(struct inet6_ifaddr *ifp, u8 ifa_flags,
u32 prefered_lft, u32 valid_lft)
{
u32 flags;
clock_t expires;
unsigned long timeout;
if (!valid_lft || (prefered_lft > valid_lft))
return -EINVAL;
timeout = addrconf_timeout_fixup(valid_lft, HZ);
if (addrconf_finite_timeout(timeout)) {
expires = jiffies_to_clock_t(timeout * HZ);
valid_lft = timeout;
flags = RTF_EXPIRES;
} else {
expires = 0;
flags = 0;
ifa_flags |= IFA_F_PERMANENT;
}
timeout = addrconf_timeout_fixup(prefered_lft, HZ);
if (addrconf_finite_timeout(timeout)) {
if (timeout == 0)
ifa_flags |= IFA_F_DEPRECATED;
prefered_lft = timeout;
}
spin_lock_bh(&ifp->lock);
ifp->flags = (ifp->flags & ~(IFA_F_DEPRECATED | IFA_F_PERMANENT | IFA_F_NODAD | IFA_F_HOMEADDRESS)) | ifa_flags;
ifp->tstamp = jiffies;
ifp->valid_lft = valid_lft;
ifp->prefered_lft = prefered_lft;
spin_unlock_bh(&ifp->lock);
if (!(ifp->flags&IFA_F_TENTATIVE))
ipv6_ifa_notify(0, ifp);
addrconf_prefix_route(&ifp->addr, ifp->prefix_len, ifp->idev->dev,
expires, flags);
addrconf_verify(0);
return 0;
}
static int
inet6_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
{
struct net *net = sock_net(skb->sk);
struct ifaddrmsg *ifm;
struct nlattr *tb[IFA_MAX+1];
struct in6_addr *pfx;
struct inet6_ifaddr *ifa;
struct net_device *dev;
u32 valid_lft = INFINITY_LIFE_TIME, preferred_lft = INFINITY_LIFE_TIME;
u8 ifa_flags;
int err;
err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFA_MAX, ifa_ipv6_policy);
if (err < 0)
return err;
ifm = nlmsg_data(nlh);
pfx = extract_addr(tb[IFA_ADDRESS], tb[IFA_LOCAL]);
if (pfx == NULL)
return -EINVAL;
if (tb[IFA_CACHEINFO]) {
struct ifa_cacheinfo *ci;
ci = nla_data(tb[IFA_CACHEINFO]);
valid_lft = ci->ifa_valid;
preferred_lft = ci->ifa_prefered;
} else {
preferred_lft = INFINITY_LIFE_TIME;
valid_lft = INFINITY_LIFE_TIME;
}
dev = __dev_get_by_index(net, ifm->ifa_index);
if (dev == NULL)
return -ENODEV;
/* We ignore other flags so far. */
ifa_flags = ifm->ifa_flags & (IFA_F_NODAD | IFA_F_HOMEADDRESS);
ifa = ipv6_get_ifaddr(net, pfx, dev, 1);
if (ifa == NULL) {
/*
* It would be best to check for !NLM_F_CREATE here but
* userspace alreay relies on not having to provide this.
*/
return inet6_addr_add(net, ifm->ifa_index, pfx,
ifm->ifa_prefixlen, ifa_flags,
preferred_lft, valid_lft);
}
if (nlh->nlmsg_flags & NLM_F_EXCL ||
!(nlh->nlmsg_flags & NLM_F_REPLACE))
err = -EEXIST;
else
err = inet6_addr_modify(ifa, ifa_flags, preferred_lft, valid_lft);
in6_ifa_put(ifa);
return err;
}
static void put_ifaddrmsg(struct nlmsghdr *nlh, u8 prefixlen, u8 flags,
u8 scope, int ifindex)
{
struct ifaddrmsg *ifm;
ifm = nlmsg_data(nlh);
ifm->ifa_family = AF_INET6;
ifm->ifa_prefixlen = prefixlen;
ifm->ifa_flags = flags;
ifm->ifa_scope = scope;
ifm->ifa_index = ifindex;
}
static int put_cacheinfo(struct sk_buff *skb, unsigned long cstamp,
unsigned long tstamp, u32 preferred, u32 valid)
{
struct ifa_cacheinfo ci;
ci.cstamp = cstamp_delta(cstamp);
ci.tstamp = cstamp_delta(tstamp);
ci.ifa_prefered = preferred;
ci.ifa_valid = valid;
return nla_put(skb, IFA_CACHEINFO, sizeof(ci), &ci);
}
static inline int rt_scope(int ifa_scope)
{
if (ifa_scope & IFA_HOST)
return RT_SCOPE_HOST;
else if (ifa_scope & IFA_LINK)
return RT_SCOPE_LINK;
else if (ifa_scope & IFA_SITE)
return RT_SCOPE_SITE;
else
return RT_SCOPE_UNIVERSE;
}
static inline int inet6_ifaddr_msgsize(void)
{
return NLMSG_ALIGN(sizeof(struct ifaddrmsg))
+ nla_total_size(16) /* IFA_ADDRESS */
+ nla_total_size(sizeof(struct ifa_cacheinfo));
}
static int inet6_fill_ifaddr(struct sk_buff *skb, struct inet6_ifaddr *ifa,
u32 pid, u32 seq, int event, unsigned int flags)
{
struct nlmsghdr *nlh;
u32 preferred, valid;
nlh = nlmsg_put(skb, pid, seq, event, sizeof(struct ifaddrmsg), flags);
if (nlh == NULL)
return -EMSGSIZE;
put_ifaddrmsg(nlh, ifa->prefix_len, ifa->flags, rt_scope(ifa->scope),
ifa->idev->dev->ifindex);
if (!(ifa->flags&IFA_F_PERMANENT)) {
preferred = ifa->prefered_lft;
valid = ifa->valid_lft;
if (preferred != INFINITY_LIFE_TIME) {
long tval = (jiffies - ifa->tstamp)/HZ;
if (preferred > tval)
preferred -= tval;
else
preferred = 0;
if (valid != INFINITY_LIFE_TIME) {
if (valid > tval)
valid -= tval;
else
valid = 0;
}
}
} else {
preferred = INFINITY_LIFE_TIME;
valid = INFINITY_LIFE_TIME;
}
if (nla_put(skb, IFA_ADDRESS, 16, &ifa->addr) < 0 ||
put_cacheinfo(skb, ifa->cstamp, ifa->tstamp, preferred, valid) < 0) {
nlmsg_cancel(skb, nlh);
return -EMSGSIZE;
}
return nlmsg_end(skb, nlh);
}
static int inet6_fill_ifmcaddr(struct sk_buff *skb, struct ifmcaddr6 *ifmca,
u32 pid, u32 seq, int event, u16 flags)
{
struct nlmsghdr *nlh;
u8 scope = RT_SCOPE_UNIVERSE;
int ifindex = ifmca->idev->dev->ifindex;
if (ipv6_addr_scope(&ifmca->mca_addr) & IFA_SITE)
scope = RT_SCOPE_SITE;
nlh = nlmsg_put(skb, pid, seq, event, sizeof(struct ifaddrmsg), flags);
if (nlh == NULL)
return -EMSGSIZE;
put_ifaddrmsg(nlh, 128, IFA_F_PERMANENT, scope, ifindex);
if (nla_put(skb, IFA_MULTICAST, 16, &ifmca->mca_addr) < 0 ||
put_cacheinfo(skb, ifmca->mca_cstamp, ifmca->mca_tstamp,
INFINITY_LIFE_TIME, INFINITY_LIFE_TIME) < 0) {
nlmsg_cancel(skb, nlh);
return -EMSGSIZE;
}
return nlmsg_end(skb, nlh);
}
static int inet6_fill_ifacaddr(struct sk_buff *skb, struct ifacaddr6 *ifaca,
u32 pid, u32 seq, int event, unsigned int flags)
{
struct nlmsghdr *nlh;
u8 scope = RT_SCOPE_UNIVERSE;
int ifindex = ifaca->aca_idev->dev->ifindex;
if (ipv6_addr_scope(&ifaca->aca_addr) & IFA_SITE)
scope = RT_SCOPE_SITE;
nlh = nlmsg_put(skb, pid, seq, event, sizeof(struct ifaddrmsg), flags);
if (nlh == NULL)
return -EMSGSIZE;
put_ifaddrmsg(nlh, 128, IFA_F_PERMANENT, scope, ifindex);
if (nla_put(skb, IFA_ANYCAST, 16, &ifaca->aca_addr) < 0 ||
put_cacheinfo(skb, ifaca->aca_cstamp, ifaca->aca_tstamp,
INFINITY_LIFE_TIME, INFINITY_LIFE_TIME) < 0) {
nlmsg_cancel(skb, nlh);
return -EMSGSIZE;
}
return nlmsg_end(skb, nlh);
}
enum addr_type_t {
UNICAST_ADDR,
MULTICAST_ADDR,
ANYCAST_ADDR,
};
/* called with rcu_read_lock() */
static int in6_dump_addrs(struct inet6_dev *idev, struct sk_buff *skb,
struct netlink_callback *cb, enum addr_type_t type,
int s_ip_idx, int *p_ip_idx)
{
struct ifmcaddr6 *ifmca;
struct ifacaddr6 *ifaca;
int err = 1;
int ip_idx = *p_ip_idx;
read_lock_bh(&idev->lock);
switch (type) {
case UNICAST_ADDR: {
struct inet6_ifaddr *ifa;
/* unicast address incl. temp addr */
list_for_each_entry(ifa, &idev->addr_list, if_list) {
if (++ip_idx < s_ip_idx)
continue;
err = inet6_fill_ifaddr(skb, ifa,
NETLINK_CB(cb->skb).pid,
cb->nlh->nlmsg_seq,
RTM_NEWADDR,
NLM_F_MULTI);
if (err <= 0)
break;
}
break;
}
case MULTICAST_ADDR:
/* multicast address */
for (ifmca = idev->mc_list; ifmca;
ifmca = ifmca->next, ip_idx++) {
if (ip_idx < s_ip_idx)
continue;
err = inet6_fill_ifmcaddr(skb, ifmca,
NETLINK_CB(cb->skb).pid,
cb->nlh->nlmsg_seq,
RTM_GETMULTICAST,
NLM_F_MULTI);
if (err <= 0)
break;
}
break;
case ANYCAST_ADDR:
/* anycast address */
for (ifaca = idev->ac_list; ifaca;
ifaca = ifaca->aca_next, ip_idx++) {
if (ip_idx < s_ip_idx)
continue;
err = inet6_fill_ifacaddr(skb, ifaca,
NETLINK_CB(cb->skb).pid,
cb->nlh->nlmsg_seq,
RTM_GETANYCAST,
NLM_F_MULTI);
if (err <= 0)
break;
}
break;
default:
break;
}
read_unlock_bh(&idev->lock);
*p_ip_idx = ip_idx;
return err;
}
static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
enum addr_type_t type)
{
struct net *net = sock_net(skb->sk);
int h, s_h;
int idx, ip_idx;
int s_idx, s_ip_idx;
struct net_device *dev;
struct inet6_dev *idev;
struct hlist_head *head;
struct hlist_node *node;
s_h = cb->args[0];
s_idx = idx = cb->args[1];
s_ip_idx = ip_idx = cb->args[2];
rcu_read_lock();
for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
idx = 0;
head = &net->dev_index_head[h];
hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
if (idx < s_idx)
goto cont;
if (h > s_h || idx > s_idx)
s_ip_idx = 0;
ip_idx = 0;
idev = __in6_dev_get(dev);
if (!idev)
goto cont;
if (in6_dump_addrs(idev, skb, cb, type,
s_ip_idx, &ip_idx) <= 0)
goto done;
cont:
idx++;
}
}
done:
rcu_read_unlock();
cb->args[0] = h;
cb->args[1] = idx;
cb->args[2] = ip_idx;
return skb->len;
}
static int inet6_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
{
enum addr_type_t type = UNICAST_ADDR;
return inet6_dump_addr(skb, cb, type);
}
static int inet6_dump_ifmcaddr(struct sk_buff *skb, struct netlink_callback *cb)
{
enum addr_type_t type = MULTICAST_ADDR;
return inet6_dump_addr(skb, cb, type);
}
static int inet6_dump_ifacaddr(struct sk_buff *skb, struct netlink_callback *cb)
{
enum addr_type_t type = ANYCAST_ADDR;
return inet6_dump_addr(skb, cb, type);
}
static int inet6_rtm_getaddr(struct sk_buff *in_skb, struct nlmsghdr* nlh,
void *arg)
{
struct net *net = sock_net(in_skb->sk);
struct ifaddrmsg *ifm;
struct nlattr *tb[IFA_MAX+1];
struct in6_addr *addr = NULL;
struct net_device *dev = NULL;
struct inet6_ifaddr *ifa;
struct sk_buff *skb;
int err;
err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFA_MAX, ifa_ipv6_policy);
if (err < 0)
goto errout;
addr = extract_addr(tb[IFA_ADDRESS], tb[IFA_LOCAL]);
if (addr == NULL) {
err = -EINVAL;
goto errout;
}
ifm = nlmsg_data(nlh);
if (ifm->ifa_index)
dev = __dev_get_by_index(net, ifm->ifa_index);
ifa = ipv6_get_ifaddr(net, addr, dev, 1);
if (!ifa) {
err = -EADDRNOTAVAIL;
goto errout;
}
skb = nlmsg_new(inet6_ifaddr_msgsize(), GFP_KERNEL);
if (!skb) {
err = -ENOBUFS;
goto errout_ifa;
}
err = inet6_fill_ifaddr(skb, ifa, NETLINK_CB(in_skb).pid,
nlh->nlmsg_seq, RTM_NEWADDR, 0);
if (err < 0) {
/* -EMSGSIZE implies BUG in inet6_ifaddr_msgsize() */
WARN_ON(err == -EMSGSIZE);
kfree_skb(skb);
goto errout_ifa;
}
err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).pid);
errout_ifa:
in6_ifa_put(ifa);
errout:
return err;
}
static void inet6_ifa_notify(int event, struct inet6_ifaddr *ifa)
{
struct sk_buff *skb;
struct net *net = dev_net(ifa->idev->dev);
int err = -ENOBUFS;
skb = nlmsg_new(inet6_ifaddr_msgsize(), GFP_ATOMIC);
if (skb == NULL)
goto errout;
err = inet6_fill_ifaddr(skb, ifa, 0, 0, event, 0);
if (err < 0) {
/* -EMSGSIZE implies BUG in inet6_ifaddr_msgsize() */
WARN_ON(err == -EMSGSIZE);
kfree_skb(skb);
goto errout;
}
rtnl_notify(skb, net, 0, RTNLGRP_IPV6_IFADDR, NULL, GFP_ATOMIC);
return;
errout:
if (err < 0)
rtnl_set_sk_err(net, RTNLGRP_IPV6_IFADDR, err);
}
static inline void ipv6_store_devconf(struct ipv6_devconf *cnf,
__s32 *array, int bytes)
{
BUG_ON(bytes < (DEVCONF_MAX * 4));
memset(array, 0, bytes);
array[DEVCONF_FORWARDING] = cnf->forwarding;
array[DEVCONF_HOPLIMIT] = cnf->hop_limit;
array[DEVCONF_MTU6] = cnf->mtu6;
array[DEVCONF_ACCEPT_RA] = cnf->accept_ra;
array[DEVCONF_ACCEPT_REDIRECTS] = cnf->accept_redirects;
array[DEVCONF_AUTOCONF] = cnf->autoconf;
array[DEVCONF_DAD_TRANSMITS] = cnf->dad_transmits;
array[DEVCONF_RTR_SOLICITS] = cnf->rtr_solicits;
array[DEVCONF_RTR_SOLICIT_INTERVAL] =
jiffies_to_msecs(cnf->rtr_solicit_interval);
array[DEVCONF_RTR_SOLICIT_DELAY] =
jiffies_to_msecs(cnf->rtr_solicit_delay);
array[DEVCONF_FORCE_MLD_VERSION] = cnf->force_mld_version;
#ifdef CONFIG_IPV6_PRIVACY
array[DEVCONF_USE_TEMPADDR] = cnf->use_tempaddr;
array[DEVCONF_TEMP_VALID_LFT] = cnf->temp_valid_lft;
array[DEVCONF_TEMP_PREFERED_LFT] = cnf->temp_prefered_lft;
array[DEVCONF_REGEN_MAX_RETRY] = cnf->regen_max_retry;
array[DEVCONF_MAX_DESYNC_FACTOR] = cnf->max_desync_factor;
#endif
array[DEVCONF_MAX_ADDRESSES] = cnf->max_addresses;
array[DEVCONF_ACCEPT_RA_DEFRTR] = cnf->accept_ra_defrtr;
array[DEVCONF_ACCEPT_RA_PINFO] = cnf->accept_ra_pinfo;
#ifdef CONFIG_IPV6_ROUTER_PREF
array[DEVCONF_ACCEPT_RA_RTR_PREF] = cnf->accept_ra_rtr_pref;
array[DEVCONF_RTR_PROBE_INTERVAL] =
jiffies_to_msecs(cnf->rtr_probe_interval);
#ifdef CONFIG_IPV6_ROUTE_INFO
array[DEVCONF_ACCEPT_RA_RT_INFO_MAX_PLEN] = cnf->accept_ra_rt_info_max_plen;
#endif
#endif
array[DEVCONF_ACCEPT_RA_RT_TABLE] = cnf->accept_ra_rt_table;
array[DEVCONF_PROXY_NDP] = cnf->proxy_ndp;
array[DEVCONF_ACCEPT_SOURCE_ROUTE] = cnf->accept_source_route;
#ifdef CONFIG_IPV6_OPTIMISTIC_DAD
array[DEVCONF_OPTIMISTIC_DAD] = cnf->optimistic_dad;
array[DEVCONF_USE_OPTIMISTIC] = cnf->use_optimistic;
#endif
#ifdef CONFIG_IPV6_MROUTE
array[DEVCONF_MC_FORWARDING] = cnf->mc_forwarding;
#endif
array[DEVCONF_DISABLE_IPV6] = cnf->disable_ipv6;
array[DEVCONF_ACCEPT_DAD] = cnf->accept_dad;
array[DEVCONF_FORCE_TLLAO] = cnf->force_tllao;
#ifdef CONFIG_LGE_DHCPV6_WIFI
array[DEVCONF_RA_INFO_FLAG] = cnf->ra_info_flag;
#endif
}
static inline size_t inet6_ifla6_size(void)
{
return nla_total_size(4) /* IFLA_INET6_FLAGS */
+ nla_total_size(sizeof(struct ifla_cacheinfo))
+ nla_total_size(DEVCONF_MAX * 4) /* IFLA_INET6_CONF */
+ nla_total_size(IPSTATS_MIB_MAX * 8) /* IFLA_INET6_STATS */
+ nla_total_size(ICMP6_MIB_MAX * 8); /* IFLA_INET6_ICMP6STATS */
}
static inline size_t inet6_if_nlmsg_size(void)
{
return NLMSG_ALIGN(sizeof(struct ifinfomsg))
+ nla_total_size(IFNAMSIZ) /* IFLA_IFNAME */
+ nla_total_size(MAX_ADDR_LEN) /* IFLA_ADDRESS */
+ nla_total_size(4) /* IFLA_MTU */
+ nla_total_size(4) /* IFLA_LINK */
+ nla_total_size(inet6_ifla6_size()); /* IFLA_PROTINFO */
}
static inline void __snmp6_fill_statsdev(u64 *stats, atomic_long_t *mib,
int items, int bytes)
{
int i;
int pad = bytes - sizeof(u64) * items;
BUG_ON(pad < 0);
/* Use put_unaligned() because stats may not be aligned for u64. */
put_unaligned(items, &stats[0]);
for (i = 1; i < items; i++)
put_unaligned(atomic_long_read(&mib[i]), &stats[i]);
memset(&stats[items], 0, pad);
}
static inline void __snmp6_fill_stats64(u64 *stats, void __percpu **mib,
int items, int bytes, size_t syncpoff)
{
int i;
int pad = bytes - sizeof(u64) * items;
BUG_ON(pad < 0);
/* Use put_unaligned() because stats may not be aligned for u64. */
put_unaligned(items, &stats[0]);
for (i = 1; i < items; i++)
put_unaligned(snmp_fold_field64(mib, i, syncpoff), &stats[i]);
memset(&stats[items], 0, pad);
}
static void snmp6_fill_stats(u64 *stats, struct inet6_dev *idev, int attrtype,
int bytes)
{
switch (attrtype) {
case IFLA_INET6_STATS:
__snmp6_fill_stats64(stats, (void __percpu **)idev->stats.ipv6,
IPSTATS_MIB_MAX, bytes, offsetof(struct ipstats_mib, syncp));
break;
case IFLA_INET6_ICMP6STATS:
__snmp6_fill_statsdev(stats, idev->stats.icmpv6dev->mibs, ICMP6_MIB_MAX, bytes);
break;
}
}
static int inet6_fill_ifla6_attrs(struct sk_buff *skb, struct inet6_dev *idev)
{
struct nlattr *nla;
struct ifla_cacheinfo ci;
NLA_PUT_U32(skb, IFLA_INET6_FLAGS, idev->if_flags);
ci.max_reasm_len = IPV6_MAXPLEN;
ci.tstamp = cstamp_delta(idev->tstamp);
ci.reachable_time = jiffies_to_msecs(idev->nd_parms->reachable_time);
ci.retrans_time = jiffies_to_msecs(idev->nd_parms->retrans_time);
NLA_PUT(skb, IFLA_INET6_CACHEINFO, sizeof(ci), &ci);
nla = nla_reserve(skb, IFLA_INET6_CONF, DEVCONF_MAX * sizeof(s32));
if (nla == NULL)
goto nla_put_failure;
ipv6_store_devconf(&idev->cnf, nla_data(nla), nla_len(nla));
/* XXX - MC not implemented */
nla = nla_reserve(skb, IFLA_INET6_STATS, IPSTATS_MIB_MAX * sizeof(u64));
if (nla == NULL)
goto nla_put_failure;
snmp6_fill_stats(nla_data(nla), idev, IFLA_INET6_STATS, nla_len(nla));
nla = nla_reserve(skb, IFLA_INET6_ICMP6STATS, ICMP6_MIB_MAX * sizeof(u64));
if (nla == NULL)
goto nla_put_failure;
snmp6_fill_stats(nla_data(nla), idev, IFLA_INET6_ICMP6STATS, nla_len(nla));
return 0;
nla_put_failure:
return -EMSGSIZE;
}
static size_t inet6_get_link_af_size(const struct net_device *dev)
{
if (!__in6_dev_get(dev))
return 0;
return inet6_ifla6_size();
}
static int inet6_fill_link_af(struct sk_buff *skb, const struct net_device *dev)
{
struct inet6_dev *idev = __in6_dev_get(dev);
if (!idev)
return -ENODATA;
if (inet6_fill_ifla6_attrs(skb, idev) < 0)
return -EMSGSIZE;
return 0;
}
static int inet6_fill_ifinfo(struct sk_buff *skb, struct inet6_dev *idev,
u32 pid, u32 seq, int event, unsigned int flags)
{
struct net_device *dev = idev->dev;
struct ifinfomsg *hdr;
struct nlmsghdr *nlh;
void *protoinfo;
nlh = nlmsg_put(skb, pid, seq, event, sizeof(*hdr), flags);
if (nlh == NULL)
return -EMSGSIZE;
hdr = nlmsg_data(nlh);
hdr->ifi_family = AF_INET6;
hdr->__ifi_pad = 0;
hdr->ifi_type = dev->type;
hdr->ifi_index = dev->ifindex;
hdr->ifi_flags = dev_get_flags(dev);
hdr->ifi_change = 0;
NLA_PUT_STRING(skb, IFLA_IFNAME, dev->name);
if (dev->addr_len)
NLA_PUT(skb, IFLA_ADDRESS, dev->addr_len, dev->dev_addr);
NLA_PUT_U32(skb, IFLA_MTU, dev->mtu);
if (dev->ifindex != dev->iflink)
NLA_PUT_U32(skb, IFLA_LINK, dev->iflink);
protoinfo = nla_nest_start(skb, IFLA_PROTINFO);
if (protoinfo == NULL)
goto nla_put_failure;
if (inet6_fill_ifla6_attrs(skb, idev) < 0)
goto nla_put_failure;
nla_nest_end(skb, protoinfo);
return nlmsg_end(skb, nlh);
nla_put_failure:
nlmsg_cancel(skb, nlh);
return -EMSGSIZE;
}
static int inet6_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
{
struct net *net = sock_net(skb->sk);
int h, s_h;
int idx = 0, s_idx;
struct net_device *dev;
struct inet6_dev *idev;
struct hlist_head *head;
struct hlist_node *node;
s_h = cb->args[0];
s_idx = cb->args[1];
rcu_read_lock();
for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
idx = 0;
head = &net->dev_index_head[h];
hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
if (idx < s_idx)
goto cont;
idev = __in6_dev_get(dev);
if (!idev)
goto cont;
if (inet6_fill_ifinfo(skb, idev,
NETLINK_CB(cb->skb).pid,
cb->nlh->nlmsg_seq,
RTM_NEWLINK, NLM_F_MULTI) <= 0)
goto out;
cont:
idx++;
}
}
out:
rcu_read_unlock();
cb->args[1] = idx;
cb->args[0] = h;
return skb->len;
}
void inet6_ifinfo_notify(int event, struct inet6_dev *idev)
{
struct sk_buff *skb;
struct net *net = dev_net(idev->dev);
int err = -ENOBUFS;
skb = nlmsg_new(inet6_if_nlmsg_size(), GFP_ATOMIC);
if (skb == NULL)
goto errout;
err = inet6_fill_ifinfo(skb, idev, 0, 0, event, 0);
if (err < 0) {
/* -EMSGSIZE implies BUG in inet6_if_nlmsg_size() */
WARN_ON(err == -EMSGSIZE);
kfree_skb(skb);
goto errout;
}
rtnl_notify(skb, net, 0, RTNLGRP_IPV6_IFINFO, NULL, GFP_ATOMIC);
return;
errout:
if (err < 0)
rtnl_set_sk_err(net, RTNLGRP_IPV6_IFINFO, err);
}
static inline size_t inet6_prefix_nlmsg_size(void)
{
return NLMSG_ALIGN(sizeof(struct prefixmsg))
+ nla_total_size(sizeof(struct in6_addr))
+ nla_total_size(sizeof(struct prefix_cacheinfo));
}
static int inet6_fill_prefix(struct sk_buff *skb, struct inet6_dev *idev,
struct prefix_info *pinfo, u32 pid, u32 seq,
int event, unsigned int flags)
{
struct prefixmsg *pmsg;
struct nlmsghdr *nlh;
struct prefix_cacheinfo ci;
nlh = nlmsg_put(skb, pid, seq, event, sizeof(*pmsg), flags);
if (nlh == NULL)
return -EMSGSIZE;
pmsg = nlmsg_data(nlh);
pmsg->prefix_family = AF_INET6;
pmsg->prefix_pad1 = 0;
pmsg->prefix_pad2 = 0;
pmsg->prefix_ifindex = idev->dev->ifindex;
pmsg->prefix_len = pinfo->prefix_len;
pmsg->prefix_type = pinfo->type;
pmsg->prefix_pad3 = 0;
pmsg->prefix_flags = 0;
if (pinfo->onlink)
pmsg->prefix_flags |= IF_PREFIX_ONLINK;
if (pinfo->autoconf)
pmsg->prefix_flags |= IF_PREFIX_AUTOCONF;
NLA_PUT(skb, PREFIX_ADDRESS, sizeof(pinfo->prefix), &pinfo->prefix);
ci.preferred_time = ntohl(pinfo->prefered);
ci.valid_time = ntohl(pinfo->valid);
NLA_PUT(skb, PREFIX_CACHEINFO, sizeof(ci), &ci);
return nlmsg_end(skb, nlh);
nla_put_failure:
nlmsg_cancel(skb, nlh);
return -EMSGSIZE;
}
static void inet6_prefix_notify(int event, struct inet6_dev *idev,
struct prefix_info *pinfo)
{
struct sk_buff *skb;
struct net *net = dev_net(idev->dev);
int err = -ENOBUFS;
skb = nlmsg_new(inet6_prefix_nlmsg_size(), GFP_ATOMIC);
if (skb == NULL)
goto errout;
err = inet6_fill_prefix(skb, idev, pinfo, 0, 0, event, 0);
if (err < 0) {
/* -EMSGSIZE implies BUG in inet6_prefix_nlmsg_size() */
WARN_ON(err == -EMSGSIZE);
kfree_skb(skb);
goto errout;
}
rtnl_notify(skb, net, 0, RTNLGRP_IPV6_PREFIX, NULL, GFP_ATOMIC);
return;
errout:
if (err < 0)
rtnl_set_sk_err(net, RTNLGRP_IPV6_PREFIX, err);
}
static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
{
inet6_ifa_notify(event ? : RTM_NEWADDR, ifp);
switch (event) {
case RTM_NEWADDR:
/*
* If the address was optimistic
* we inserted the route at the start of
* our DAD process, so we don't need
* to do it again
*/
if (!(ifp->rt->rt6i_node))
ip6_ins_rt(ifp->rt);
if (ifp->idev->cnf.forwarding)
addrconf_join_anycast(ifp);
break;
case RTM_DELADDR:
if (ifp->idev->cnf.forwarding)
addrconf_leave_anycast(ifp);
addrconf_leave_solict(ifp->idev, &ifp->addr);
dst_hold(&ifp->rt->dst);
if (ip6_del_rt(ifp->rt))
dst_free(&ifp->rt->dst);
break;
}
}
static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
{
rcu_read_lock_bh();
if (likely(ifp->idev->dead == 0))
__ipv6_ifa_notify(event, ifp);
rcu_read_unlock_bh();
}
#ifdef CONFIG_SYSCTL
static
int addrconf_sysctl_forward(ctl_table *ctl, int write,
void __user *buffer, size_t *lenp, loff_t *ppos)
{
int *valp = ctl->data;
int val = *valp;
loff_t pos = *ppos;
ctl_table lctl;
int ret;
/*
* ctl->data points to idev->cnf.forwarding, we should
* not modify it until we get the rtnl lock.
*/
lctl = *ctl;
lctl.data = &val;
ret = proc_dointvec(&lctl, write, buffer, lenp, ppos);
if (write)
ret = addrconf_fixup_forwarding(ctl, valp, val);
if (ret)
*ppos = pos;
return ret;
}
static void dev_disable_change(struct inet6_dev *idev)
{
if (!idev || !idev->dev)
return;
if (idev->cnf.disable_ipv6)
addrconf_notify(NULL, NETDEV_DOWN, idev->dev);
else
addrconf_notify(NULL, NETDEV_UP, idev->dev);
}
static void addrconf_disable_change(struct net *net, __s32 newf)
{
struct net_device *dev;
struct inet6_dev *idev;
rcu_read_lock();
for_each_netdev_rcu(net, dev) {
idev = __in6_dev_get(dev);
if (idev) {
int changed = (!idev->cnf.disable_ipv6) ^ (!newf);
idev->cnf.disable_ipv6 = newf;
if (changed)
dev_disable_change(idev);
}
}
rcu_read_unlock();
}
static int addrconf_disable_ipv6(struct ctl_table *table, int *p, int newf)
{
struct net *net;
int old;
if (!rtnl_trylock())
return restart_syscall();
net = (struct net *)table->extra2;
old = *p;
*p = newf;
if (p == &net->ipv6.devconf_dflt->disable_ipv6) {
rtnl_unlock();
return 0;
}
if (p == &net->ipv6.devconf_all->disable_ipv6) {
net->ipv6.devconf_dflt->disable_ipv6 = newf;
addrconf_disable_change(net, newf);
} else if ((!newf) ^ (!old))
dev_disable_change((struct inet6_dev *)table->extra1);
rtnl_unlock();
return 0;
}
static
int addrconf_sysctl_disable(ctl_table *ctl, int write,
void __user *buffer, size_t *lenp, loff_t *ppos)
{
int *valp = ctl->data;
int val = *valp;
loff_t pos = *ppos;
ctl_table lctl;
int ret;
/*
* ctl->data points to idev->cnf.disable_ipv6, we should
* not modify it until we get the rtnl lock.
*/
lctl = *ctl;
lctl.data = &val;
ret = proc_dointvec(&lctl, write, buffer, lenp, ppos);
if (write)
ret = addrconf_disable_ipv6(ctl, valp, val);
if (ret)
*ppos = pos;
return ret;
}
static struct addrconf_sysctl_table
{
struct ctl_table_header *sysctl_header;
ctl_table addrconf_vars[DEVCONF_MAX+1];
char *dev_name;
} addrconf_sysctl __read_mostly = {
.sysctl_header = NULL,
.addrconf_vars = {
{
.procname = "forwarding",
.data = &ipv6_devconf.forwarding,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = addrconf_sysctl_forward,
},
{
.procname = "hop_limit",
.data = &ipv6_devconf.hop_limit,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec,
},
{
.procname = "mtu",
.data = &ipv6_devconf.mtu6,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec,
},
{
.procname = "accept_ra",
.data = &ipv6_devconf.accept_ra,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec,
},
{
.procname = "accept_redirects",
.data = &ipv6_devconf.accept_redirects,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec,
},
{
.procname = "autoconf",
.data = &ipv6_devconf.autoconf,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec,
},
{
.procname = "dad_transmits",
.data = &ipv6_devconf.dad_transmits,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec,
},
{
.procname = "router_solicitations",
.data = &ipv6_devconf.rtr_solicits,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec,
},
{
.procname = "router_solicitation_interval",
.data = &ipv6_devconf.rtr_solicit_interval,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec_jiffies,
},
{
.procname = "router_solicitation_delay",
.data = &ipv6_devconf.rtr_solicit_delay,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec_jiffies,
},
{
.procname = "force_mld_version",
.data = &ipv6_devconf.force_mld_version,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec,
},
#ifdef CONFIG_IPV6_PRIVACY
{
.procname = "use_tempaddr",
.data = &ipv6_devconf.use_tempaddr,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec,
},
{
.procname = "temp_valid_lft",
.data = &ipv6_devconf.temp_valid_lft,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec,
},
{
.procname = "temp_prefered_lft",
.data = &ipv6_devconf.temp_prefered_lft,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec,
},
{
.procname = "regen_max_retry",
.data = &ipv6_devconf.regen_max_retry,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec,
},
{
.procname = "max_desync_factor",
.data = &ipv6_devconf.max_desync_factor,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec,
},
#endif
{
.procname = "max_addresses",
.data = &ipv6_devconf.max_addresses,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec,
},
{
.procname = "accept_ra_defrtr",
.data = &ipv6_devconf.accept_ra_defrtr,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec,
},
{
.procname = "accept_ra_pinfo",
.data = &ipv6_devconf.accept_ra_pinfo,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec,
},
#ifdef CONFIG_IPV6_ROUTER_PREF
{
.procname = "accept_ra_rtr_pref",
.data = &ipv6_devconf.accept_ra_rtr_pref,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec,
},
{
.procname = "router_probe_interval",
.data = &ipv6_devconf.rtr_probe_interval,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec_jiffies,
},
#ifdef CONFIG_IPV6_ROUTE_INFO
{
.procname = "accept_ra_rt_info_max_plen",
.data = &ipv6_devconf.accept_ra_rt_info_max_plen,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec,
},
#endif
#endif
{
.procname = "accept_ra_rt_table",
.data = &ipv6_devconf.accept_ra_rt_table,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec,
},
{
.procname = "proxy_ndp",
.data = &ipv6_devconf.proxy_ndp,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec,
},
{
.procname = "accept_source_route",
.data = &ipv6_devconf.accept_source_route,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec,
},
#ifdef CONFIG_IPV6_OPTIMISTIC_DAD
{
.procname = "optimistic_dad",
.data = &ipv6_devconf.optimistic_dad,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec,
},
{
.procname = "use_optimistic",
.data = &ipv6_devconf.use_optimistic,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec,
},
#endif
#ifdef CONFIG_IPV6_MROUTE
{
.procname = "mc_forwarding",
.data = &ipv6_devconf.mc_forwarding,
.maxlen = sizeof(int),
.mode = 0444,
.proc_handler = proc_dointvec,
},
#endif
{
.procname = "disable_ipv6",
.data = &ipv6_devconf.disable_ipv6,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = addrconf_sysctl_disable,
},
{
.procname = "accept_dad",
.data = &ipv6_devconf.accept_dad,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec,
},
{
.procname = "force_tllao",
.data = &ipv6_devconf.force_tllao,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec
},
{
.procname = "accept_ra_prefix_route",
.data = &ipv6_devconf.accept_ra_prefix_route,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec,
},
#ifdef CONFIG_LGE_DHCPV6_WIFI
{
.procname = "ra_info_flag",
.data = &ipv6_devconf.ra_info_flag,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec
},
#endif
{
/* sentinel */
}
},
};
static int __addrconf_sysctl_register(struct net *net, char *dev_name,
struct inet6_dev *idev, struct ipv6_devconf *p)
{
int i;
struct addrconf_sysctl_table *t;
#define ADDRCONF_CTL_PATH_DEV 3
struct ctl_path addrconf_ctl_path[] = {
{ .procname = "net", },
{ .procname = "ipv6", },
{ .procname = "conf", },
{ /* to be set */ },
{ },
};
t = kmemdup(&addrconf_sysctl, sizeof(*t), GFP_KERNEL);
if (t == NULL)
goto out;
for (i = 0; t->addrconf_vars[i].data; i++) {
t->addrconf_vars[i].data += (char *)p - (char *)&ipv6_devconf;
t->addrconf_vars[i].extra1 = idev; /* embedded; no ref */
t->addrconf_vars[i].extra2 = net;
}
/*
* Make a copy of dev_name, because '.procname' is regarded as const
* by sysctl and we wouldn't want anyone to change it under our feet
* (see SIOCSIFNAME).
*/
t->dev_name = kstrdup(dev_name, GFP_KERNEL);
if (!t->dev_name)
goto free;
addrconf_ctl_path[ADDRCONF_CTL_PATH_DEV].procname = t->dev_name;
t->sysctl_header = register_net_sysctl_table(net, addrconf_ctl_path,
t->addrconf_vars);
if (t->sysctl_header == NULL)
goto free_procname;
p->sysctl = t;
return 0;
free_procname:
kfree(t->dev_name);
free:
kfree(t);
out:
return -ENOBUFS;
}
static void __addrconf_sysctl_unregister(struct ipv6_devconf *p)
{
struct addrconf_sysctl_table *t;
if (p->sysctl == NULL)
return;
t = p->sysctl;
p->sysctl = NULL;
unregister_net_sysctl_table(t->sysctl_header);
kfree(t->dev_name);
kfree(t);
}
static void addrconf_sysctl_register(struct inet6_dev *idev)
{
neigh_sysctl_register(idev->dev, idev->nd_parms, "ipv6",
&ndisc_ifinfo_sysctl_change);
__addrconf_sysctl_register(dev_net(idev->dev), idev->dev->name,
idev, &idev->cnf);
}
static void addrconf_sysctl_unregister(struct inet6_dev *idev)
{
__addrconf_sysctl_unregister(&idev->cnf);
neigh_sysctl_unregister(idev->nd_parms);
}
#endif
static int __net_init addrconf_init_net(struct net *net)
{
int err = -ENOMEM;
struct ipv6_devconf *all, *dflt;
all = kmemdup(&ipv6_devconf, sizeof(ipv6_devconf), GFP_KERNEL);
if (all == NULL)
goto err_alloc_all;
dflt = kmemdup(&ipv6_devconf_dflt, sizeof(ipv6_devconf_dflt), GFP_KERNEL);
if (dflt == NULL)
goto err_alloc_dflt;
/* these will be inherited by all namespaces */
dflt->autoconf = ipv6_defaults.autoconf;
dflt->disable_ipv6 = ipv6_defaults.disable_ipv6;
net->ipv6.devconf_all = all;
net->ipv6.devconf_dflt = dflt;
#ifdef CONFIG_SYSCTL
err = __addrconf_sysctl_register(net, "all", NULL, all);
if (err < 0)
goto err_reg_all;
err = __addrconf_sysctl_register(net, "default", NULL, dflt);
if (err < 0)
goto err_reg_dflt;
#endif
return 0;
#ifdef CONFIG_SYSCTL
err_reg_dflt:
__addrconf_sysctl_unregister(all);
err_reg_all:
kfree(dflt);
#endif
err_alloc_dflt:
kfree(all);
err_alloc_all:
return err;
}
static void __net_exit addrconf_exit_net(struct net *net)
{
#ifdef CONFIG_SYSCTL
__addrconf_sysctl_unregister(net->ipv6.devconf_dflt);
__addrconf_sysctl_unregister(net->ipv6.devconf_all);
#endif
if (!net_eq(net, &init_net)) {
kfree(net->ipv6.devconf_dflt);
kfree(net->ipv6.devconf_all);
}
}
static struct pernet_operations addrconf_ops = {
.init = addrconf_init_net,
.exit = addrconf_exit_net,
};
/*
* Device notifier
*/
int register_inet6addr_notifier(struct notifier_block *nb)
{
return atomic_notifier_chain_register(&inet6addr_chain, nb);
}
EXPORT_SYMBOL(register_inet6addr_notifier);
int unregister_inet6addr_notifier(struct notifier_block *nb)
{
return atomic_notifier_chain_unregister(&inet6addr_chain, nb);
}
EXPORT_SYMBOL(unregister_inet6addr_notifier);
static struct rtnl_af_ops inet6_ops = {
.family = AF_INET6,
.fill_link_af = inet6_fill_link_af,
.get_link_af_size = inet6_get_link_af_size,
};
/*
* Init / cleanup code
*/
int __init addrconf_init(void)
{
int i, err;
err = ipv6_addr_label_init();
if (err < 0) {
printk(KERN_CRIT "IPv6 Addrconf:"
" cannot initialize default policy table: %d.\n", err);
goto out;
}
err = register_pernet_subsys(&addrconf_ops);
if (err < 0)
goto out_addrlabel;
/* The addrconf netdev notifier requires that loopback_dev
* has it's ipv6 private information allocated and setup
* before it can bring up and give link-local addresses
* to other devices which are up.
*
* Unfortunately, loopback_dev is not necessarily the first
* entry in the global dev_base list of net devices. In fact,
* it is likely to be the very last entry on that list.
* So this causes the notifier registry below to try and
* give link-local addresses to all devices besides loopback_dev
* first, then loopback_dev, which cases all the non-loopback_dev
* devices to fail to get a link-local address.
*
* So, as a temporary fix, allocate the ipv6 structure for
* loopback_dev first by hand.
* Longer term, all of the dependencies ipv6 has upon the loopback
* device and it being up should be removed.
*/
rtnl_lock();
if (!ipv6_add_dev(init_net.loopback_dev))
err = -ENOMEM;
rtnl_unlock();
if (err)
goto errlo;
for (i = 0; i < IN6_ADDR_HSIZE; i++)
INIT_HLIST_HEAD(&inet6_addr_lst[i]);
register_netdevice_notifier(&ipv6_dev_notf);
addrconf_verify(0);
err = rtnl_af_register(&inet6_ops);
if (err < 0)
goto errout_af;
err = __rtnl_register(PF_INET6, RTM_GETLINK, NULL, inet6_dump_ifinfo,
NULL);
if (err < 0)
goto errout;
/* Only the first call to __rtnl_register can fail */
__rtnl_register(PF_INET6, RTM_NEWADDR, inet6_rtm_newaddr, NULL, NULL);
__rtnl_register(PF_INET6, RTM_DELADDR, inet6_rtm_deladdr, NULL, NULL);
__rtnl_register(PF_INET6, RTM_GETADDR, inet6_rtm_getaddr,
inet6_dump_ifaddr, NULL);
__rtnl_register(PF_INET6, RTM_GETMULTICAST, NULL,
inet6_dump_ifmcaddr, NULL);
__rtnl_register(PF_INET6, RTM_GETANYCAST, NULL,
inet6_dump_ifacaddr, NULL);
ipv6_addr_label_rtnl_register();
return 0;
errout:
rtnl_af_unregister(&inet6_ops);
errout_af:
unregister_netdevice_notifier(&ipv6_dev_notf);
errlo:
unregister_pernet_subsys(&addrconf_ops);
out_addrlabel:
ipv6_addr_label_cleanup();
out:
return err;
}
void addrconf_cleanup(void)
{
struct net_device *dev;
int i;
unregister_netdevice_notifier(&ipv6_dev_notf);
unregister_pernet_subsys(&addrconf_ops);
ipv6_addr_label_cleanup();
rtnl_lock();
__rtnl_af_unregister(&inet6_ops);
/* clean dev list */
for_each_netdev(&init_net, dev) {
if (__in6_dev_get(dev) == NULL)
continue;
addrconf_ifdown(dev, 1);
}
addrconf_ifdown(init_net.loopback_dev, 2);
/*
* Check hash table.
*/
spin_lock_bh(&addrconf_hash_lock);
for (i = 0; i < IN6_ADDR_HSIZE; i++)
WARN_ON(!hlist_empty(&inet6_addr_lst[i]));
spin_unlock_bh(&addrconf_hash_lock);
del_timer(&addr_chk_timer);
rtnl_unlock();
}
| lawnn/Dorimanx-LG-G2-D802-Kernel | net/ipv6/addrconf.c | C | gpl-2.0 | 130,583 |
<?php
namespace Thru\ActiveRecord\Test\Models;
use Thru\ActiveRecord\ActiveRecord;
/**
* Class TestModel
* @var $test_model_id integer
* @var $integer_field integer
* @var $text_field text
* @var $date_field date
*/
class TestModel extends ActiveRecord
{
protected $_table = "test_models";
public $test_model_id;
public $integer_field;
public $text_field;
public $date_field;
}
| Thruio/ActiveRecord | tests/Models/TestModel.php | PHP | gpl-2.0 | 409 |
java -Djava.ext.dirs=reggie-libs -Djava.util.logging.config.file=config/logging.properties -jar reggie-libs/start.jar config/start-reggie.config
| paawak/blog | code/jini/unsecure/jini-services/start-reggie.sh | Shell | gpl-2.0 | 145 |
//
// This file is part of Gambit
// Copyright (c) 1994-2016, The Gambit Project (http://www.gambit-project.org)
//
// FILE: src/libgambit/dvector.h
// Doubly-partitioned vector class
//
// This program 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 of the License, or
// (at your option) any later version.
//
// This program 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 this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
#ifndef LIBGAMBIT_DVECTOR_H
#define LIBGAMBIT_DVECTOR_H
#include "pvector.h"
namespace Gambit {
template <class T> class DVector : public PVector<T> {
private:
int sum(int part, const PVector<int> &v) const;
void setindex(void);
bool Check(const DVector<T> &) const;
protected:
T ***dvptr;
Array<int> dvlen, dvidx;
public:
DVector(void);
DVector(const PVector<int> &sig);
DVector(const Vector<T> &val, const PVector<int> &sig);
DVector(const DVector<T> &v);
virtual ~DVector();
T &operator()(int a, int b, int c);
const T &operator()(int a, int b, int c) const;
// extract a subvector
void CopySubRow(int row, int col, const DVector<T> &v);
DVector<T> &operator=(const DVector<T> &v);
DVector<T> &operator=(const PVector<T> &v);
DVector<T> &operator=(const Vector<T> &v);
DVector<T> &operator=(T c);
DVector<T> operator+(const DVector<T> &v) const;
DVector<T> &operator+=(const DVector<T> &v);
DVector<T> operator-(void) const;
DVector<T> operator-(const DVector<T> &v) const;
DVector<T> &operator-=(const DVector<T> &v);
T operator*(const DVector<T> &v) const;
DVector<T> &operator*=(const T &c);
DVector<T> operator/(const T &c) const;
bool operator==(const DVector<T> &v) const;
bool operator!=(const DVector<T> &v) const;
const Array<int> &DPLengths(void) const;
};
} // end namespace Gambit
#endif // LIBGAMBIT_DVECTOR_H
| robert-7/gambit | library/include/gambit/dvector.h | C | gpl-2.0 | 2,312 |
/* Copyright (c) 2010-2012, Code Aurora Forum. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program 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.
*
*/
/* #define DEBUG */
#define DEV_DBG_PREFIX "HDMI: "
/* #define REG_DUMP */
#define CEC_MSG_PRINT
#define TOGGLE_CEC_HARDWARE_FSM
#include <linux/types.h>
#include <linux/bitops.h>
#include <linux/clk.h>
#include <linux/mutex.h>
#include <mach/msm_hdmi_audio.h>
#include <mach/clk.h>
#include <mach/msm_iomap.h>
#include <mach/socinfo.h>
#include "msm_fb.h"
#include "hdmi_msm.h"
/* Supported HDMI Audio channels */
#define MSM_HDMI_AUDIO_CHANNEL_2 0
#define MSM_HDMI_AUDIO_CHANNEL_4 1
#define MSM_HDMI_AUDIO_CHANNEL_6 2
#define MSM_HDMI_AUDIO_CHANNEL_8 3
#define MSM_HDMI_AUDIO_CHANNEL_MAX 4
#define MSM_HDMI_AUDIO_CHANNEL_FORCE_32BIT 0x7FFFFFFF
/* Supported HDMI Audio sample rates */
#define MSM_HDMI_SAMPLE_RATE_32KHZ 0
#define MSM_HDMI_SAMPLE_RATE_44_1KHZ 1
#define MSM_HDMI_SAMPLE_RATE_48KHZ 2
#define MSM_HDMI_SAMPLE_RATE_88_2KHZ 3
#define MSM_HDMI_SAMPLE_RATE_96KHZ 4
#define MSM_HDMI_SAMPLE_RATE_176_4KHZ 5
#define MSM_HDMI_SAMPLE_RATE_192KHZ 6
#define MSM_HDMI_SAMPLE_RATE_MAX 7
#define MSM_HDMI_SAMPLE_RATE_FORCE_32BIT 0x7FFFFFFF
static int msm_hdmi_sample_rate = MSM_HDMI_SAMPLE_RATE_48KHZ;
/* HDMI/HDCP Registers */
#define HDCP_DDC_STATUS 0x0128
#define HDCP_DDC_CTRL_0 0x0120
#define HDCP_DDC_CTRL_1 0x0124
#define HDMI_DDC_CTRL 0x020C
#define HPD_EVENT_OFFLINE 0
#define HPD_EVENT_ONLINE 1
#define SWITCH_SET_HDMI_AUDIO(d, force) \
do {\
if (!hdmi_msm_is_dvi_mode() &&\
((force) ||\
(external_common_state->audio_sdev.state != (d)))) {\
switch_set_state(&external_common_state->audio_sdev,\
(d));\
DEV_INFO("%s: hdmi_audio state switched to %d\n",\
__func__,\
external_common_state->audio_sdev.state);\
} \
} while (0)
struct workqueue_struct *hdmi_work_queue;
struct hdmi_msm_state_type *hdmi_msm_state;
/* Enable HDCP by default */
static bool hdcp_feature_on = true;
DEFINE_MUTEX(hdmi_msm_state_mutex);
EXPORT_SYMBOL(hdmi_msm_state_mutex);
static DEFINE_MUTEX(hdcp_auth_state_mutex);
static void hdmi_msm_dump_regs(const char *prefix);
static void hdmi_msm_hdcp_enable(void);
static void hdmi_msm_turn_on(void);
static int hdmi_msm_audio_off(void);
static int hdmi_msm_read_edid(void);
static void hdmi_msm_hpd_off(void);
static boolean hdmi_msm_is_dvi_mode(void);
#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT
static void hdmi_msm_cec_line_latch_detect(void);
#ifdef TOGGLE_CEC_HARDWARE_FSM
static boolean msg_send_complete = TRUE;
static boolean msg_recv_complete = TRUE;
#endif
#define HDMI_MSM_CEC_REFTIMER_REFTIMER_ENABLE BIT(16)
#define HDMI_MSM_CEC_REFTIMER_REFTIMER(___t) (((___t)&0xFFFF) << 0)
#define HDMI_MSM_CEC_TIME_SIGNAL_FREE_TIME(___t) (((___t)&0x1FF) << 7)
#define HDMI_MSM_CEC_TIME_ENABLE BIT(0)
#define HDMI_MSM_CEC_ADDR_LOGICAL_ADDR(___la) (((___la)&0xFF) << 0)
#define HDMI_MSM_CEC_CTRL_LINE_OE BIT(9)
#define HDMI_MSM_CEC_CTRL_FRAME_SIZE(___sz) (((___sz)&0x1F) << 4)
#define HDMI_MSM_CEC_CTRL_SOFT_RESET BIT(2)
#define HDMI_MSM_CEC_CTRL_SEND_TRIG BIT(1)
#define HDMI_MSM_CEC_CTRL_ENABLE BIT(0)
#define HDMI_MSM_CEC_INT_FRAME_RD_DONE_MASK BIT(7)
#define HDMI_MSM_CEC_INT_FRAME_RD_DONE_ACK BIT(6)
#define HDMI_MSM_CEC_INT_FRAME_RD_DONE_INT BIT(6)
#define HDMI_MSM_CEC_INT_MONITOR_MASK BIT(5)
#define HDMI_MSM_CEC_INT_MONITOR_ACK BIT(4)
#define HDMI_MSM_CEC_INT_MONITOR_INT BIT(4)
#define HDMI_MSM_CEC_INT_FRAME_ERROR_MASK BIT(3)
#define HDMI_MSM_CEC_INT_FRAME_ERROR_ACK BIT(2)
#define HDMI_MSM_CEC_INT_FRAME_ERROR_INT BIT(2)
#define HDMI_MSM_CEC_INT_FRAME_WR_DONE_MASK BIT(1)
#define HDMI_MSM_CEC_INT_FRAME_WR_DONE_ACK BIT(0)
#define HDMI_MSM_CEC_INT_FRAME_WR_DONE_INT BIT(0)
#define HDMI_MSM_CEC_FRAME_WR_SUCCESS(___st) (((___st)&0xB) ==\
(HDMI_MSM_CEC_INT_FRAME_WR_DONE_INT |\
HDMI_MSM_CEC_INT_FRAME_WR_DONE_MASK |\
HDMI_MSM_CEC_INT_FRAME_ERROR_MASK))
#define HDMI_MSM_CEC_RETRANSMIT_NUM(___num) (((___num)&0xF) << 4)
#define HDMI_MSM_CEC_RETRANSMIT_ENABLE BIT(0)
#define HDMI_MSM_CEC_WR_DATA_DATA(___d) (((___d)&0xFF) << 8)
void hdmi_msm_cec_init(void)
{
/* 0x02A8 CEC_REFTIMER */
HDMI_OUTP(0x02A8,
HDMI_MSM_CEC_REFTIMER_REFTIMER_ENABLE
| HDMI_MSM_CEC_REFTIMER_REFTIMER(27 * 50)
);
/*
* 0x02A0 CEC_ADDR
* Starting with a default address of 4
*/
HDMI_OUTP(0x02A0, HDMI_MSM_CEC_ADDR_LOGICAL_ADDR(4));
hdmi_msm_state->first_monitor = 0;
hdmi_msm_state->fsm_reset_done = false;
/* 0x029C CEC_INT */
/* Enable CEC interrupts */
HDMI_OUTP(0x029C, \
HDMI_MSM_CEC_INT_FRAME_WR_DONE_MASK \
| HDMI_MSM_CEC_INT_FRAME_ERROR_MASK \
| HDMI_MSM_CEC_INT_MONITOR_MASK \
| HDMI_MSM_CEC_INT_FRAME_RD_DONE_MASK);
HDMI_OUTP(0x02B0, 0x7FF << 4 | 1);
/*
* Slight adjustment to logic 1 low periods on read,
* CEC Test 8.2-3 was failing, 8 for the
* BIT_1_ERR_RANGE_HI = 8 => 750us, the test used 775us,
* so increased this to 9 which => 800us.
*/
/*
* CEC latch up issue - To fire monitor interrupt
* for every start of message
*/
HDMI_OUTP(0x02E0, 0x880000);
/*
* Slight adjustment to logic 0 low period on write
*/
HDMI_OUTP(0x02DC, 0x8888A888);
/*
* Enable Signal Free Time counter and set to 7 bit periods
*/
HDMI_OUTP(0x02A4, 0x1 | (7 * 0x30) << 7);
/* 0x028C CEC_CTRL */
HDMI_OUTP(0x028C, HDMI_MSM_CEC_CTRL_ENABLE);
}
void hdmi_msm_cec_write_logical_addr(int addr)
{
/* 0x02A0 CEC_ADDR
* LOGICAL_ADDR 7:0 NUM
*/
HDMI_OUTP(0x02A0, addr & 0xFF);
}
void hdmi_msm_dump_cec_msg(struct hdmi_msm_cec_msg *msg)
{
#ifdef CEC_MSG_PRINT
int i;
DEV_DBG("sender_id : %d", msg->sender_id);
DEV_DBG("recvr_id : %d", msg->recvr_id);
if (msg->frame_size < 2) {
DEV_DBG("polling message");
return;
}
DEV_DBG("opcode : %02x", msg->opcode);
for (i = 0; i < msg->frame_size - 2; i++)
DEV_DBG("operand(%2d) : %02x", i + 1, msg->operand[i]);
#endif /* CEC_MSG_PRINT */
}
void hdmi_msm_cec_msg_send(struct hdmi_msm_cec_msg *msg)
{
int i;
uint32 timeout_count = 1;
int retry = 10;
boolean frameType = (msg->recvr_id == 15 ? BIT(0) : 0);
mutex_lock(&hdmi_msm_state_mutex);
hdmi_msm_state->fsm_reset_done = false;
mutex_unlock(&hdmi_msm_state_mutex);
#ifdef TOGGLE_CEC_HARDWARE_FSM
msg_send_complete = FALSE;
#endif
INIT_COMPLETION(hdmi_msm_state->cec_frame_wr_done);
hdmi_msm_state->cec_frame_wr_status = 0;
/* 0x0294 HDMI_MSM_CEC_RETRANSMIT */
HDMI_OUTP(0x0294,
#ifdef DRVR_ONLY_CECT_NO_DAEMON
HDMI_MSM_CEC_RETRANSMIT_NUM(msg->retransmit)
| (msg->retransmit > 0) ? HDMI_MSM_CEC_RETRANSMIT_ENABLE : 0);
#else
HDMI_MSM_CEC_RETRANSMIT_NUM(0) |
HDMI_MSM_CEC_RETRANSMIT_ENABLE);
#endif
/* 0x028C CEC_CTRL */
HDMI_OUTP(0x028C, 0x1 | msg->frame_size << 4);
/* 0x0290 CEC_WR_DATA */
/* header block */
HDMI_OUTP(0x0290,
HDMI_MSM_CEC_WR_DATA_DATA(msg->sender_id << 4 | msg->recvr_id)
| frameType);
/* data block 0 : opcode */
HDMI_OUTP(0x0290,
HDMI_MSM_CEC_WR_DATA_DATA(msg->frame_size < 2 ? 0 : msg->opcode)
| frameType);
/* data block 1-14 : operand 0-13 */
for (i = 0; i < msg->frame_size - 1; i++)
HDMI_OUTP(0x0290,
HDMI_MSM_CEC_WR_DATA_DATA(msg->operand[i])
| (msg->recvr_id == 15 ? BIT(0) : 0));
for (; i < 14; i++)
HDMI_OUTP(0x0290,
HDMI_MSM_CEC_WR_DATA_DATA(0)
| (msg->recvr_id == 15 ? BIT(0) : 0));
while ((HDMI_INP(0x0298) & 1) && retry--) {
DEV_DBG("CEC line is busy(%d)\n", retry);
schedule();
}
/* 0x028C CEC_CTRL */
HDMI_OUTP(0x028C,
HDMI_MSM_CEC_CTRL_LINE_OE
| HDMI_MSM_CEC_CTRL_FRAME_SIZE(msg->frame_size)
| HDMI_MSM_CEC_CTRL_SEND_TRIG
| HDMI_MSM_CEC_CTRL_ENABLE);
timeout_count = wait_for_completion_interruptible_timeout(
&hdmi_msm_state->cec_frame_wr_done, HZ);
if (!timeout_count) {
hdmi_msm_state->cec_frame_wr_status |= CEC_STATUS_WR_TMOUT;
DEV_ERR("%s: timedout", __func__);
hdmi_msm_dump_cec_msg(msg);
} else {
DEV_DBG("CEC write frame done (frame len=%d)",
msg->frame_size);
hdmi_msm_dump_cec_msg(msg);
}
#ifdef TOGGLE_CEC_HARDWARE_FSM
if (!msg_recv_complete) {
/* Toggle CEC hardware FSM */
HDMI_OUTP(0x028C, 0x0);
HDMI_OUTP(0x028C, HDMI_MSM_CEC_CTRL_ENABLE);
msg_recv_complete = TRUE;
}
msg_send_complete = TRUE;
#else
HDMI_OUTP(0x028C, 0x0);
HDMI_OUTP(0x028C, HDMI_MSM_CEC_CTRL_ENABLE);
#endif
}
void hdmi_msm_cec_line_latch_detect(void)
{
/*
* CECT 9-5-1
* The timer period needs to be changed to appropriate value
*/
/*
* Timedout without RD_DONE, WR_DONE or ERR_INT
* Toggle CEC hardware FSM
*/
mutex_lock(&hdmi_msm_state_mutex);
if (hdmi_msm_state->first_monitor == 1) {
DEV_WARN("CEC line is probably latched up - CECT 9-5-1");
if (!msg_recv_complete)
hdmi_msm_state->fsm_reset_done = true;
HDMI_OUTP(0x028C, 0x0);
HDMI_OUTP(0x028C, HDMI_MSM_CEC_CTRL_ENABLE);
hdmi_msm_state->first_monitor = 0;
}
mutex_unlock(&hdmi_msm_state_mutex);
}
void hdmi_msm_cec_msg_recv(void)
{
uint32 data;
int i;
#ifdef DRVR_ONLY_CECT_NO_DAEMON
struct hdmi_msm_cec_msg temp_msg;
#endif
mutex_lock(&hdmi_msm_state_mutex);
if (hdmi_msm_state->cec_queue_wr == hdmi_msm_state->cec_queue_rd
&& hdmi_msm_state->cec_queue_full) {
mutex_unlock(&hdmi_msm_state_mutex);
DEV_ERR("CEC message queue is overflowing\n");
#ifdef DRVR_ONLY_CECT_NO_DAEMON
/*
* Without CEC daemon:
* Compliance tests fail once the queue gets filled up.
* so reset the pointers to the start of the queue.
*/
hdmi_msm_state->cec_queue_wr = hdmi_msm_state->cec_queue_start;
hdmi_msm_state->cec_queue_rd = hdmi_msm_state->cec_queue_start;
hdmi_msm_state->cec_queue_full = false;
#else
return;
#endif
}
if (hdmi_msm_state->cec_queue_wr == NULL) {
DEV_ERR("%s: wp is NULL\n", __func__);
return;
}
mutex_unlock(&hdmi_msm_state_mutex);
/* 0x02AC CEC_RD_DATA */
data = HDMI_INP(0x02AC);
hdmi_msm_state->cec_queue_wr->sender_id = (data & 0xF0) >> 4;
hdmi_msm_state->cec_queue_wr->recvr_id = (data & 0x0F);
hdmi_msm_state->cec_queue_wr->frame_size = (data & 0x1F00) >> 8;
DEV_DBG("Recvd init=[%u] dest=[%u] size=[%u]\n",
hdmi_msm_state->cec_queue_wr->sender_id,
hdmi_msm_state->cec_queue_wr->recvr_id,
hdmi_msm_state->cec_queue_wr->frame_size);
if (hdmi_msm_state->cec_queue_wr->frame_size < 1) {
DEV_ERR("%s: invalid message (frame length = %d)",
__func__, hdmi_msm_state->cec_queue_wr->frame_size);
return;
} else if (hdmi_msm_state->cec_queue_wr->frame_size == 1) {
DEV_DBG("%s: polling message (dest[%x] <- init[%x])",
__func__,
hdmi_msm_state->cec_queue_wr->recvr_id,
hdmi_msm_state->cec_queue_wr->sender_id);
return;
}
/* data block 0 : opcode */
data = HDMI_INP(0x02AC);
hdmi_msm_state->cec_queue_wr->opcode = data & 0xFF;
/* data block 1-14 : operand 0-13 */
for (i = 0; i < hdmi_msm_state->cec_queue_wr->frame_size - 2; i++) {
data = HDMI_INP(0x02AC);
hdmi_msm_state->cec_queue_wr->operand[i] = data & 0xFF;
}
for (; i < 14; i++)
hdmi_msm_state->cec_queue_wr->operand[i] = 0;
DEV_DBG("CEC read frame done\n");
DEV_DBG("=======================================\n");
hdmi_msm_dump_cec_msg(hdmi_msm_state->cec_queue_wr);
DEV_DBG("=======================================\n");
#ifdef DRVR_ONLY_CECT_NO_DAEMON
switch (hdmi_msm_state->cec_queue_wr->opcode) {
case 0x64:
/* Set OSD String */
DEV_INFO("Recvd OSD Str=[%x]\n",\
hdmi_msm_state->cec_queue_wr->operand[3]);
break;
case 0x83:
/* Give Phy Addr */
DEV_INFO("Recvd a Give Phy Addr cmd\n");
memset(&temp_msg, 0x00, sizeof(struct hdmi_msm_cec_msg));
/* Setup a frame for sending out phy addr */
temp_msg.sender_id = 0x4;
/* Broadcast */
temp_msg.recvr_id = 0xf;
temp_msg.opcode = 0x84;
i = 0;
temp_msg.operand[i++] = 0x10;
temp_msg.operand[i++] = 0x00;
temp_msg.operand[i++] = 0x04;
temp_msg.frame_size = i + 2;
hdmi_msm_cec_msg_send(&temp_msg);
break;
case 0xFF:
/* Abort */
DEV_INFO("Recvd an abort cmd 0xFF\n");
memset(&temp_msg, 0x00, sizeof(struct hdmi_msm_cec_msg));
temp_msg.sender_id = 0x4;
temp_msg.recvr_id = hdmi_msm_state->cec_queue_wr->sender_id;
i = 0;
/*feature abort */
temp_msg.opcode = 0x00;
temp_msg.operand[i++] =
hdmi_msm_state->cec_queue_wr->opcode;
/*reason for abort = "Refused" */
temp_msg.operand[i++] = 0x04;
temp_msg.frame_size = i + 2;
hdmi_msm_dump_cec_msg(&temp_msg);
hdmi_msm_cec_msg_send(&temp_msg);
break;
case 0x046:
/* Give OSD name */
DEV_INFO("Recvd cmd 0x046\n");
memset(&temp_msg, 0x00, sizeof(struct hdmi_msm_cec_msg));
temp_msg.sender_id = 0x4;
temp_msg.recvr_id = hdmi_msm_state->cec_queue_wr->sender_id;
i = 0;
/* OSD Name */
temp_msg.opcode = 0x47;
/* Display control byte */
temp_msg.operand[i++] = 0x00;
temp_msg.operand[i++] = 'H';
temp_msg.operand[i++] = 'e';
temp_msg.operand[i++] = 'l';
temp_msg.operand[i++] = 'l';
temp_msg.operand[i++] = 'o';
temp_msg.operand[i++] = ' ';
temp_msg.operand[i++] = 'W';
temp_msg.operand[i++] = 'o';
temp_msg.operand[i++] = 'r';
temp_msg.operand[i++] = 'l';
temp_msg.operand[i++] = 'd';
temp_msg.frame_size = i + 2;
hdmi_msm_cec_msg_send(&temp_msg);
break;
case 0x08F:
/* Give Device Power status */
DEV_INFO("Recvd a Power status message\n");
memset(&temp_msg, 0x00, sizeof(struct hdmi_msm_cec_msg));
temp_msg.sender_id = 0x4;
temp_msg.recvr_id = hdmi_msm_state->cec_queue_wr->sender_id;
i = 0;
/* OSD String */
temp_msg.opcode = 0x90;
temp_msg.operand[i++] = 'H';
temp_msg.operand[i++] = 'e';
temp_msg.operand[i++] = 'l';
temp_msg.operand[i++] = 'l';
temp_msg.operand[i++] = 'o';
temp_msg.operand[i++] = ' ';
temp_msg.operand[i++] = 'W';
temp_msg.operand[i++] = 'o';
temp_msg.operand[i++] = 'r';
temp_msg.operand[i++] = 'l';
temp_msg.operand[i++] = 'd';
temp_msg.frame_size = i + 2;
hdmi_msm_cec_msg_send(&temp_msg);
break;
case 0x080:
/* Routing Change cmd */
case 0x086:
/* Set Stream Path */
DEV_INFO("Recvd Set Stream\n");
memset(&temp_msg, 0x00, sizeof(struct hdmi_msm_cec_msg));
temp_msg.sender_id = 0x4;
/*Broadcast this message*/
temp_msg.recvr_id = 0xf;
i = 0;
temp_msg.opcode = 0x82; /* Active Source */
temp_msg.operand[i++] = 0x10;
temp_msg.operand[i++] = 0x00;
temp_msg.frame_size = i + 2;
hdmi_msm_cec_msg_send(&temp_msg);
/*
* sending <Image View On> message
*/
memset(&temp_msg, 0x00, sizeof(struct hdmi_msm_cec_msg));
temp_msg.sender_id = 0x4;
temp_msg.recvr_id = hdmi_msm_state->cec_queue_wr->sender_id;
i = 0;
/* opcode for Image View On */
temp_msg.opcode = 0x04;
temp_msg.frame_size = i + 2;
hdmi_msm_cec_msg_send(&temp_msg);
break;
case 0x44:
/* User Control Pressed */
DEV_INFO("User Control Pressed\n");
break;
case 0x45:
/* User Control Released */
DEV_INFO("User Control Released\n");
break;
default:
DEV_INFO("Recvd an unknown cmd = [%u]\n",
hdmi_msm_state->cec_queue_wr->opcode);
#ifdef __SEND_ABORT__
memset(&temp_msg, 0x00, sizeof(struct hdmi_msm_cec_msg));
temp_msg.sender_id = 0x4;
temp_msg.recvr_id = hdmi_msm_state->cec_queue_wr->sender_id;
i = 0;
/* opcode for feature abort */
temp_msg.opcode = 0x00;
temp_msg.operand[i++] =
hdmi_msm_state->cec_queue_wr->opcode;
/*reason for abort = "Unrecognized opcode" */
temp_msg.operand[i++] = 0x00;
temp_msg.frame_size = i + 2;
hdmi_msm_cec_msg_send(&temp_msg);
break;
#else
memset(&temp_msg, 0x00, sizeof(struct hdmi_msm_cec_msg));
temp_msg.sender_id = 0x4;
temp_msg.recvr_id = hdmi_msm_state->cec_queue_wr->sender_id;
i = 0;
/* OSD String */
temp_msg.opcode = 0x64;
temp_msg.operand[i++] = 0x0;
temp_msg.operand[i++] = 'H';
temp_msg.operand[i++] = 'e';
temp_msg.operand[i++] = 'l';
temp_msg.operand[i++] = 'l';
temp_msg.operand[i++] = 'o';
temp_msg.operand[i++] = ' ';
temp_msg.operand[i++] = 'W';
temp_msg.operand[i++] = 'o';
temp_msg.operand[i++] = 'r';
temp_msg.operand[i++] = 'l';
temp_msg.operand[i++] = 'd';
temp_msg.frame_size = i + 2;
hdmi_msm_cec_msg_send(&temp_msg);
break;
#endif /* __SEND_ABORT__ */
}
#endif /* DRVR_ONLY_CECT_NO_DAEMON */
mutex_lock(&hdmi_msm_state_mutex);
hdmi_msm_state->cec_queue_wr++;
if (hdmi_msm_state->cec_queue_wr == CEC_QUEUE_END)
hdmi_msm_state->cec_queue_wr = hdmi_msm_state->cec_queue_start;
if (hdmi_msm_state->cec_queue_wr == hdmi_msm_state->cec_queue_rd)
hdmi_msm_state->cec_queue_full = true;
mutex_unlock(&hdmi_msm_state_mutex);
DEV_DBG("Exiting %s()\n", __func__);
}
void hdmi_msm_cec_one_touch_play(void)
{
struct hdmi_msm_cec_msg temp_msg;
uint32 i = 0;
memset(&temp_msg, 0x00, sizeof(struct hdmi_msm_cec_msg));
temp_msg.sender_id = 0x4;
/*
* Broadcast this message
*/
temp_msg.recvr_id = 0xf;
i = 0;
/* Active Source */
temp_msg.opcode = 0x82;
temp_msg.operand[i++] = 0x10;
temp_msg.operand[i++] = 0x00;
/*temp_msg.operand[i++] = 0x04;*/
temp_msg.frame_size = i + 2;
hdmi_msm_cec_msg_send(&temp_msg);
/*
* sending <Image View On> message
*/
memset(&temp_msg, 0x00, sizeof(struct hdmi_msm_cec_msg));
temp_msg.sender_id = 0x4;
temp_msg.recvr_id = hdmi_msm_state->cec_queue_wr->sender_id;
i = 0;
/* Image View On */
temp_msg.opcode = 0x04;
temp_msg.frame_size = i + 2;
hdmi_msm_cec_msg_send(&temp_msg);
}
#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT */
uint32 hdmi_msm_get_io_base(void)
{
return (uint32)MSM_HDMI_BASE;
}
EXPORT_SYMBOL(hdmi_msm_get_io_base);
/* Table indicating the video format supported by the HDMI TX Core v1.0 */
/* Valid Pixel-Clock rates: 25.2MHz, 27MHz, 27.03MHz, 74.25MHz, 148.5MHz */
static void hdmi_msm_setup_video_mode_lut(void)
{
HDMI_SETUP_LUT(640x480p60_4_3);
HDMI_SETUP_LUT(720x480p60_4_3);
HDMI_SETUP_LUT(720x480p60_16_9);
HDMI_SETUP_LUT(1280x720p60_16_9);
HDMI_SETUP_LUT(1920x1080i60_16_9);
HDMI_SETUP_LUT(1440x480i60_4_3);
HDMI_SETUP_LUT(1440x480i60_16_9);
HDMI_SETUP_LUT(1920x1080p60_16_9);
HDMI_SETUP_LUT(720x576p50_4_3);
HDMI_SETUP_LUT(720x576p50_16_9);
HDMI_SETUP_LUT(1280x720p50_16_9);
HDMI_SETUP_LUT(1440x576i50_4_3);
HDMI_SETUP_LUT(1440x576i50_16_9);
HDMI_SETUP_LUT(1920x1080p50_16_9);
HDMI_SETUP_LUT(1920x1080p24_16_9);
HDMI_SETUP_LUT(1920x1080p25_16_9);
HDMI_SETUP_LUT(1920x1080p30_16_9);
}
#ifdef PORT_DEBUG
const char *hdmi_msm_name(uint32 offset)
{
switch (offset) {
case 0x0000: return "CTRL";
case 0x0020: return "AUDIO_PKT_CTRL1";
case 0x0024: return "ACR_PKT_CTRL";
case 0x0028: return "VBI_PKT_CTRL";
case 0x002C: return "INFOFRAME_CTRL0";
#ifdef CONFIG_FB_MSM_HDMI_3D
case 0x0034: return "GEN_PKT_CTRL";
#endif
case 0x003C: return "ACP";
case 0x0040: return "GC";
case 0x0044: return "AUDIO_PKT_CTRL2";
case 0x0048: return "ISRC1_0";
case 0x004C: return "ISRC1_1";
case 0x0050: return "ISRC1_2";
case 0x0054: return "ISRC1_3";
case 0x0058: return "ISRC1_4";
case 0x005C: return "ISRC2_0";
case 0x0060: return "ISRC2_1";
case 0x0064: return "ISRC2_2";
case 0x0068: return "ISRC2_3";
case 0x006C: return "AVI_INFO0";
case 0x0070: return "AVI_INFO1";
case 0x0074: return "AVI_INFO2";
case 0x0078: return "AVI_INFO3";
#ifdef CONFIG_FB_MSM_HDMI_3D
case 0x0084: return "GENERIC0_HDR";
case 0x0088: return "GENERIC0_0";
case 0x008C: return "GENERIC0_1";
#endif
case 0x00C4: return "ACR_32_0";
case 0x00C8: return "ACR_32_1";
case 0x00CC: return "ACR_44_0";
case 0x00D0: return "ACR_44_1";
case 0x00D4: return "ACR_48_0";
case 0x00D8: return "ACR_48_1";
case 0x00E4: return "AUDIO_INFO0";
case 0x00E8: return "AUDIO_INFO1";
case 0x0110: return "HDCP_CTRL";
case 0x0114: return "HDCP_DEBUG_CTRL";
case 0x0118: return "HDCP_INT_CTRL";
case 0x011C: return "HDCP_LINK0_STATUS";
case 0x012C: return "HDCP_ENTROPY_CTRL0";
case 0x0130: return "HDCP_RESET";
case 0x0134: return "HDCP_RCVPORT_DATA0";
case 0x0138: return "HDCP_RCVPORT_DATA1";
case 0x013C: return "HDCP_RCVPORT_DATA2";
case 0x0144: return "HDCP_RCVPORT_DATA3";
case 0x0148: return "HDCP_RCVPORT_DATA4";
case 0x014C: return "HDCP_RCVPORT_DATA5";
case 0x0150: return "HDCP_RCVPORT_DATA6";
case 0x0168: return "HDCP_RCVPORT_DATA12";
case 0x01D0: return "AUDIO_CFG";
case 0x0208: return "USEC_REFTIMER";
case 0x020C: return "DDC_CTRL";
case 0x0214: return "DDC_INT_CTRL";
case 0x0218: return "DDC_SW_STATUS";
case 0x021C: return "DDC_HW_STATUS";
case 0x0220: return "DDC_SPEED";
case 0x0224: return "DDC_SETUP";
case 0x0228: return "DDC_TRANS0";
case 0x022C: return "DDC_TRANS1";
case 0x0238: return "DDC_DATA";
case 0x0250: return "HPD_INT_STATUS";
case 0x0254: return "HPD_INT_CTRL";
case 0x0258: return "HPD_CTRL";
case 0x025C: return "HDCP_ENTROPY_CTRL1";
case 0x027C: return "DDC_REF";
case 0x0284: return "HDCP_SW_UPPER_AKSV";
case 0x0288: return "HDCP_SW_LOWER_AKSV";
case 0x02B4: return "ACTIVE_H";
case 0x02B8: return "ACTIVE_V";
case 0x02BC: return "ACTIVE_V_F2";
case 0x02C0: return "TOTAL";
case 0x02C4: return "V_TOTAL_F2";
case 0x02C8: return "FRAME_CTRL";
case 0x02CC: return "AUD_INT";
case 0x0300: return "PHY_REG0";
case 0x0304: return "PHY_REG1";
case 0x0308: return "PHY_REG2";
case 0x030C: return "PHY_REG3";
case 0x0310: return "PHY_REG4";
case 0x0314: return "PHY_REG5";
case 0x0318: return "PHY_REG6";
case 0x031C: return "PHY_REG7";
case 0x0320: return "PHY_REG8";
case 0x0324: return "PHY_REG9";
case 0x0328: return "PHY_REG10";
case 0x032C: return "PHY_REG11";
case 0x0330: return "PHY_REG12";
default: return "???";
}
}
void hdmi_outp(uint32 offset, uint32 value)
{
uint32 in_val;
outpdw(MSM_HDMI_BASE+offset, value);
in_val = inpdw(MSM_HDMI_BASE+offset);
DEV_DBG("HDMI[%04x] => %08x [%08x] %s\n",
offset, value, in_val, hdmi_msm_name(offset));
}
uint32 hdmi_inp(uint32 offset)
{
uint32 value = inpdw(MSM_HDMI_BASE+offset);
DEV_DBG("HDMI[%04x] <= %08x %s\n",
offset, value, hdmi_msm_name(offset));
return value;
}
#endif /* DEBUG */
static void hdmi_msm_turn_on(void);
static int hdmi_msm_audio_off(void);
static int hdmi_msm_read_edid(void);
static void hdmi_msm_hpd_off(void);
static bool hdmi_ready(void)
{
return MSM_HDMI_BASE &&
hdmi_msm_state &&
hdmi_msm_state->hdmi_app_clk &&
hdmi_msm_state->hpd_initialized;
}
static void hdmi_msm_send_event(boolean on)
{
char *envp[2];
/* QDSP OFF preceding the HPD event notification */
envp[0] = "HDCP_STATE=FAIL";
envp[1] = NULL;
DEV_ERR("hdmi: HDMI HPD: QDSP OFF\n");
kobject_uevent_env(external_common_state->uevent_kobj,
KOBJ_CHANGE, envp);
if (on) {
/* Build EDID table */
hdmi_msm_read_edid();
switch_set_state(&external_common_state->sdev, 1);
DEV_INFO("%s: hdmi state switched to %d\n", __func__,
external_common_state->sdev.state);
DEV_INFO("HDMI HPD: CONNECTED: send ONLINE\n");
kobject_uevent(external_common_state->uevent_kobj, KOBJ_ONLINE);
if (!hdmi_msm_state->hdcp_enable) {
/* Send Audio for HDMI Compliance Cases*/
envp[0] = "HDCP_STATE=PASS";
envp[1] = NULL;
DEV_INFO("HDMI HPD: sense : send HDCP_PASS\n");
kobject_uevent_env(external_common_state->uevent_kobj,
KOBJ_CHANGE, envp);
}
} else {
switch_set_state(&external_common_state->sdev, 0);
DEV_INFO("%s: hdmi state switch to %d\n", __func__,
external_common_state->sdev.state);
DEV_INFO("hdmi: HDMI HPD: sense DISCONNECTED: send OFFLINE\n");
kobject_uevent(external_common_state->uevent_kobj,
KOBJ_OFFLINE);
}
/*[ECID:000000] ZTEBSP wanghaifei start 20130221, add qcom new patch for HDP resume wait*/
// if (!completion_done(&hdmi_msm_state->hpd_event_processed))
// complete(&hdmi_msm_state->hpd_event_processed);
/*[ECID:000000] ZTEBSP wanghaifei end 20130221, add qcom new patch for HDP resume wait*/
}
static void hdmi_msm_hpd_state_work(struct work_struct *work)
{
if (!hdmi_ready()) {
DEV_ERR("hdmi: %s: ignored, probe failed\n", __func__);
return;
}
hdmi_msm_send_event(external_common_state->hpd_state);
}
#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT
static void hdmi_msm_cec_latch_work(struct work_struct *work)
{
hdmi_msm_cec_line_latch_detect();
}
#endif
static void hdcp_deauthenticate(void);
static void hdmi_msm_hdcp_reauth_work(struct work_struct *work)
{
if (!hdmi_msm_state->hdcp_enable) {
DEV_DBG("%s: HDCP not enabled\n", __func__);
return;
}
/* Don't process recursive actions */
mutex_lock(&hdmi_msm_state_mutex);
if (hdmi_msm_state->hdcp_activating) {
mutex_unlock(&hdmi_msm_state_mutex);
return;
}
mutex_unlock(&hdmi_msm_state_mutex);
/*
* Reauth=>deauth, hdcp_auth
* hdcp_auth=>turn_on() which calls
* HDMI Core reset without informing the Audio QDSP
* this can do bad things to video playback on the HDTV
* Therefore, as surprising as it may sound do reauth
* only if the device is HDCP-capable
*/
hdcp_deauthenticate();
mutex_lock(&hdcp_auth_state_mutex);
hdmi_msm_state->reauth = TRUE;
mutex_unlock(&hdcp_auth_state_mutex);
mod_timer(&hdmi_msm_state->hdcp_timer, jiffies + HZ/2);
}
static void hdmi_msm_hdcp_work(struct work_struct *work)
{
if (!hdmi_msm_state->hdcp_enable) {
DEV_DBG("%s: HDCP not enabled\n", __func__);
return;
}
/* Only re-enable if cable still connected */
mutex_lock(&external_common_state_hpd_mutex);
if (external_common_state->hpd_state &&
!(hdmi_msm_state->full_auth_done)) {
mutex_unlock(&external_common_state_hpd_mutex);
if (hdmi_msm_state->reauth == TRUE) {
DEV_DBG("%s: Starting HDCP re-authentication\n",
__func__);
hdmi_msm_turn_on();
} else {
DEV_DBG("%s: Starting HDCP authentication\n", __func__);
hdmi_msm_hdcp_enable();
}
} else {
mutex_unlock(&external_common_state_hpd_mutex);
DEV_DBG("%s: HDMI not connected or HDCP already active\n",
__func__);
hdmi_msm_state->reauth = FALSE;
}
}
int hdmi_msm_process_hdcp_interrupts(void)
{
int rc = -1;
uint32 hdcp_int_val;
char *envp[2];
if (!hdmi_msm_state->hdcp_enable) {
DEV_DBG("%s: HDCP not enabled\n", __func__);
return -EINVAL;
}
/* HDCP_INT_CTRL[0x0118]
* [0] AUTH_SUCCESS_INT [R] HDCP Authentication Success
* interrupt status
* [1] AUTH_SUCCESS_ACK [W] Acknowledge bit for HDCP
* Authentication Success bit - write 1 to clear
* [2] AUTH_SUCCESS_MASK [R/W] Mask bit for HDCP Authentication
* Success interrupt - set to 1 to enable interrupt */
hdcp_int_val = HDMI_INP_ND(0x0118);
if ((hdcp_int_val & (1 << 2)) && (hdcp_int_val & (1 << 0))) {
/* AUTH_SUCCESS_INT */
HDMI_OUTP(0x0118, (hdcp_int_val | (1 << 1)) & ~(1 << 0));
DEV_INFO("HDCP: AUTH_SUCCESS_INT received\n");
complete_all(&hdmi_msm_state->hdcp_success_done);
return 0;
}
/* [4] AUTH_FAIL_INT [R] HDCP Authentication Lost
* interrupt Status
* [5] AUTH_FAIL_ACK [W] Acknowledge bit for HDCP
* Authentication Lost bit - write 1 to clear
* [6] AUTH_FAIL_MASK [R/W] Mask bit fo HDCP Authentication
* Lost interrupt set to 1 to enable interrupt
* [7] AUTH_FAIL_INFO_ACK [W] Acknowledge bit for HDCP
* Authentication Failure Info field - write 1 to clear */
if ((hdcp_int_val & (1 << 6)) && (hdcp_int_val & (1 << 4))) {
/* AUTH_FAIL_INT */
/* Clear and Disable */
uint32 link_status = HDMI_INP_ND(0x011C);
HDMI_OUTP(0x0118, (hdcp_int_val | (1 << 5))
& ~((1 << 6) | (1 << 4)));
DEV_INFO("HDCP: AUTH_FAIL_INT received, LINK0_STATUS=0x%08x\n",
link_status);
if (hdmi_msm_state->full_auth_done) {
SWITCH_SET_HDMI_AUDIO(0, 0);
envp[0] = "HDCP_STATE=FAIL";
envp[1] = NULL;
DEV_INFO("HDMI HPD:QDSP OFF\n");
kobject_uevent_env(external_common_state->uevent_kobj,
KOBJ_CHANGE, envp);
mutex_lock(&hdcp_auth_state_mutex);
hdmi_msm_state->full_auth_done = FALSE;
mutex_unlock(&hdcp_auth_state_mutex);
/* Calling reauth only when authentication
* is sucessful or else we always go into
* the reauth loop. Also, No need to reauthenticate
* if authentication failed because of cable disconnect
*/
if (((link_status & 0xF0) >> 4) != 0x7) {
DEV_DBG("Reauthenticate From %s HDCP FAIL INT ",
__func__);
queue_work(hdmi_work_queue,
&hdmi_msm_state->hdcp_reauth_work);
} else {
DEV_INFO("HDCP: HDMI cable disconnected\n");
}
}
/* Clear AUTH_FAIL_INFO as well */
HDMI_OUTP(0x0118, (hdcp_int_val | (1 << 7)));
return 0;
}
/* [8] DDC_XFER_REQ_INT [R] HDCP DDC Transfer Request
* interrupt status
* [9] DDC_XFER_REQ_ACK [W] Acknowledge bit for HDCP DDC
* Transfer Request bit - write 1 to clear
* [10] DDC_XFER_REQ_MASK [R/W] Mask bit for HDCP DDC Transfer
* Request interrupt - set to 1 to enable interrupt */
if ((hdcp_int_val & (1 << 10)) && (hdcp_int_val & (1 << 8))) {
/* DDC_XFER_REQ_INT */
HDMI_OUTP_ND(0x0118, (hdcp_int_val | (1 << 9)) & ~(1 << 8));
if (!(hdcp_int_val & (1 << 12)))
return 0;
}
/* [12] DDC_XFER_DONE_INT [R] HDCP DDC Transfer done interrupt
* status
* [13] DDC_XFER_DONE_ACK [W] Acknowledge bit for HDCP DDC
* Transfer done bit - write 1 to clear
* [14] DDC_XFER_DONE_MASK [R/W] Mask bit for HDCP DDC Transfer
* done interrupt - set to 1 to enable interrupt */
if ((hdcp_int_val & (1 << 14)) && (hdcp_int_val & (1 << 12))) {
/* DDC_XFER_DONE_INT */
HDMI_OUTP_ND(0x0118, (hdcp_int_val | (1 << 13)) & ~(1 << 12));
DEV_INFO("HDCP: DDC_XFER_DONE received\n");
return 0;
}
return rc;
}
static irqreturn_t hdmi_msm_isr(int irq, void *dev_id)
{
uint32 hpd_int_status;
uint32 hpd_int_ctrl;
#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT
uint32 cec_intr_status;
#endif
uint32 ddc_int_ctrl;
uint32 audio_int_val;
static uint32 fifo_urun_int_occurred;
static uint32 sample_drop_int_occurred;
const uint32 occurrence_limit = 5;
if (!hdmi_ready()) {
DEV_DBG("ISR ignored, probe failed\n");
return IRQ_HANDLED;
}
/* Process HPD Interrupt */
/* HDMI_HPD_INT_STATUS[0x0250] */
hpd_int_status = HDMI_INP_ND(0x0250);
/* HDMI_HPD_INT_CTRL[0x0254] */
hpd_int_ctrl = HDMI_INP_ND(0x0254);
if ((hpd_int_ctrl & (1 << 2)) && (hpd_int_status & (1 << 0))) {
/*
* Got HPD interrupt. Ack the interrupt and disable any
* further HPD interrupts until we process this interrupt.
*/
HDMI_OUTP(0x0254, ((hpd_int_ctrl | (BIT(0))) & ~BIT(2)));
external_common_state->hpd_state =
(HDMI_INP(0x0250) & BIT(1)) >> 1;
DEV_DBG("%s: Queuing work to handle HPD %s event\n", __func__,
external_common_state->hpd_state ? "connect" :
"disconnect");
queue_work(hdmi_work_queue, &hdmi_msm_state->hpd_state_work);
return IRQ_HANDLED;
}
/* Process DDC Interrupts */
/* HDMI_DDC_INT_CTRL[0x0214] */
ddc_int_ctrl = HDMI_INP_ND(0x0214);
if ((ddc_int_ctrl & (1 << 2)) && (ddc_int_ctrl & (1 << 0))) {
/* SW_DONE INT occured, clr it */
HDMI_OUTP_ND(0x0214, ddc_int_ctrl | (1 << 1));
complete(&hdmi_msm_state->ddc_sw_done);
return IRQ_HANDLED;
}
/* FIFO Underrun Int is enabled */
/* HDMI_AUD_INT[0x02CC]
* [3] AUD_SAM_DROP_MASK [R/W]
* [2] AUD_SAM_DROP_ACK [W], AUD_SAM_DROP_INT [R]
* [1] AUD_FIFO_URUN_MASK [R/W]
* [0] AUD_FIFO_URUN_ACK [W], AUD_FIFO_URUN_INT [R] */
audio_int_val = HDMI_INP_ND(0x02CC);
if ((audio_int_val & (1 << 1)) && (audio_int_val & (1 << 0))) {
/* FIFO Underrun occured, clr it */
HDMI_OUTP(0x02CC, audio_int_val | (1 << 0));
++fifo_urun_int_occurred;
DEV_INFO("HDMI AUD_FIFO_URUN: %d\n", fifo_urun_int_occurred);
if (fifo_urun_int_occurred >= occurrence_limit) {
HDMI_OUTP(0x02CC, HDMI_INP(0x02CC) & ~(1 << 1));
DEV_INFO("HDMI AUD_FIFO_URUN: INT has been disabled "
"by the ISR after %d occurences...\n",
fifo_urun_int_occurred);
}
return IRQ_HANDLED;
}
/* Audio Sample Drop int is enabled */
if ((audio_int_val & (1 << 3)) && (audio_int_val & (1 << 2))) {
/* Audio Sample Drop occured, clr it */
HDMI_OUTP(0x02CC, audio_int_val | (1 << 2));
DEV_DBG("%s: AUD_SAM_DROP", __func__);
++sample_drop_int_occurred;
if (sample_drop_int_occurred >= occurrence_limit) {
HDMI_OUTP(0x02CC, HDMI_INP(0x02CC) & ~(1 << 3));
DEV_INFO("HDMI AUD_SAM_DROP: INT has been disabled "
"by the ISR after %d occurences...\n",
sample_drop_int_occurred);
}
return IRQ_HANDLED;
}
if (!hdmi_msm_process_hdcp_interrupts())
return IRQ_HANDLED;
#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT
/* Process CEC Interrupt */
/* HDMI_MSM_CEC_INT[0x029C] */
cec_intr_status = HDMI_INP_ND(0x029C);
DEV_DBG("cec interrupt status is [%u]\n", cec_intr_status);
if (HDMI_MSM_CEC_FRAME_WR_SUCCESS(cec_intr_status)) {
DEV_DBG("CEC_IRQ_FRAME_WR_DONE\n");
HDMI_OUTP(0x029C, cec_intr_status |
HDMI_MSM_CEC_INT_FRAME_WR_DONE_ACK);
mutex_lock(&hdmi_msm_state_mutex);
hdmi_msm_state->cec_frame_wr_status |= CEC_STATUS_WR_DONE;
hdmi_msm_state->first_monitor = 0;
del_timer(&hdmi_msm_state->cec_read_timer);
mutex_unlock(&hdmi_msm_state_mutex);
complete(&hdmi_msm_state->cec_frame_wr_done);
return IRQ_HANDLED;
}
if ((cec_intr_status & (1 << 2)) && (cec_intr_status & (1 << 3))) {
DEV_DBG("CEC_IRQ_FRAME_ERROR\n");
#ifdef TOGGLE_CEC_HARDWARE_FSM
/* Toggle CEC hardware FSM */
HDMI_OUTP(0x028C, 0x0);
HDMI_OUTP(0x028C, HDMI_MSM_CEC_CTRL_ENABLE);
#endif
HDMI_OUTP(0x029C, cec_intr_status);
mutex_lock(&hdmi_msm_state_mutex);
hdmi_msm_state->first_monitor = 0;
del_timer(&hdmi_msm_state->cec_read_timer);
hdmi_msm_state->cec_frame_wr_status |= CEC_STATUS_WR_ERROR;
mutex_unlock(&hdmi_msm_state_mutex);
complete(&hdmi_msm_state->cec_frame_wr_done);
return IRQ_HANDLED;
}
if ((cec_intr_status & (1 << 4)) && (cec_intr_status & (1 << 5))) {
DEV_DBG("CEC_IRQ_MONITOR\n");
HDMI_OUTP(0x029C, cec_intr_status |
HDMI_MSM_CEC_INT_MONITOR_ACK);
/*
* CECT 9-5-1
* On the first occassion start a timer
* for few hundred ms, if it expires then
* reset the CEC block else go on with
* frame transactions as usual.
* Below adds hdmi_msm_cec_msg_recv() as an
* item into the work queue instead of running in
* interrupt context
*/
mutex_lock(&hdmi_msm_state_mutex);
if (hdmi_msm_state->first_monitor == 0) {
/* This timer might have to be changed
* worst case theoritical =
* 16 bytes * 8 * 2.7msec = 346 msec
*/
mod_timer(&hdmi_msm_state->cec_read_timer,
jiffies + HZ/2);
hdmi_msm_state->first_monitor = 1;
}
mutex_unlock(&hdmi_msm_state_mutex);
return IRQ_HANDLED;
}
if ((cec_intr_status & (1 << 6)) && (cec_intr_status & (1 << 7))) {
DEV_DBG("CEC_IRQ_FRAME_RD_DONE\n");
mutex_lock(&hdmi_msm_state_mutex);
hdmi_msm_state->first_monitor = 0;
del_timer(&hdmi_msm_state->cec_read_timer);
mutex_unlock(&hdmi_msm_state_mutex);
HDMI_OUTP(0x029C, cec_intr_status |
HDMI_MSM_CEC_INT_FRAME_RD_DONE_ACK);
hdmi_msm_cec_msg_recv();
#ifdef TOGGLE_CEC_HARDWARE_FSM
if (!msg_send_complete)
msg_recv_complete = FALSE;
else {
/* Toggle CEC hardware FSM */
HDMI_OUTP(0x028C, 0x0);
HDMI_OUTP(0x028C, HDMI_MSM_CEC_CTRL_ENABLE);
}
#else
HDMI_OUTP(0x028C, 0x0);
HDMI_OUTP(0x028C, HDMI_MSM_CEC_CTRL_ENABLE);
#endif
return IRQ_HANDLED;
}
#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT */
DEV_DBG("%s: HPD<Ctrl=%04x, State=%04x>, ddc_int_ctrl=%04x, "
"aud_int=%04x, cec_intr_status=%04x\n", __func__, hpd_int_ctrl,
hpd_int_status, ddc_int_ctrl, audio_int_val,
HDMI_INP_ND(0x029C));
return IRQ_HANDLED;
}
static int check_hdmi_features(void)
{
/* RAW_FEAT_CONFIG_ROW0_LSB */
uint32 val = inpdw(QFPROM_BASE + 0x0238);
/* HDMI_DISABLE */
boolean hdmi_disabled = (val & 0x00200000) >> 21;
/* HDCP_DISABLE */
boolean hdcp_disabled = (val & 0x00400000) >> 22;
DEV_DBG("Features <val:0x%08x, HDMI:%s, HDCP:%s>\n", val,
hdmi_disabled ? "OFF" : "ON", hdcp_disabled ? "OFF" : "ON");
if (hdmi_disabled) {
DEV_ERR("ERROR: HDMI disabled\n");
return -ENODEV;
}
if (hdcp_disabled)
DEV_WARN("WARNING: HDCP disabled\n");
return 0;
}
static boolean hdmi_msm_has_hdcp(void)
{
/* RAW_FEAT_CONFIG_ROW0_LSB, HDCP_DISABLE */
return (inpdw(QFPROM_BASE + 0x0238) & 0x00400000) ? FALSE : TRUE;
}
static boolean hdmi_msm_is_power_on(void)
{
/* HDMI_CTRL, ENABLE */
return (HDMI_INP_ND(0x0000) & 0x00000001) ? TRUE : FALSE;
}
/* 1.2.1.2.1 DVI Operation
* HDMI compliance requires the HDMI core to support DVI as well. The
* HDMI core also supports DVI. In DVI operation there are no preambles
* and guardbands transmitted. THe TMDS encoding of video data remains
* the same as HDMI. There are no VBI or audio packets transmitted. In
* order to enable DVI mode in HDMI core, HDMI_DVI_SEL field of
* HDMI_CTRL register needs to be programmed to 0. */
static boolean hdmi_msm_is_dvi_mode(void)
{
/* HDMI_CTRL, HDMI_DVI_SEL */
return (HDMI_INP_ND(0x0000) & 0x00000002) ? FALSE : TRUE;
}
void hdmi_msm_set_mode(boolean power_on)
{
uint32 reg_val = 0;
if (power_on) {
/* ENABLE */
reg_val |= 0x00000001; /* Enable the block */
if (external_common_state->hdmi_sink == 0) {
/* HDMI_DVI_SEL */
reg_val |= 0x00000002;
if (hdmi_msm_state->hdcp_enable)
/* HDMI Encryption */
reg_val |= 0x00000004;
/* HDMI_CTRL */
HDMI_OUTP(0x0000, reg_val);
/* HDMI_DVI_SEL */
reg_val &= ~0x00000002;
} else {
if (hdmi_msm_state->hdcp_enable)
/* HDMI_Encryption_ON */
reg_val |= 0x00000006;
else
reg_val |= 0x00000002;
}
} else
reg_val = 0x00000002;
/* HDMI_CTRL */
HDMI_OUTP(0x0000, reg_val);
DEV_DBG("HDMI Core: %s, HDMI_CTRL=0x%08x\n",
power_on ? "Enable" : "Disable", reg_val);
}
static void msm_hdmi_init_ddc(void)
{
/* 0x0220 HDMI_DDC_SPEED
[31:16] PRESCALE prescale = (m * xtal_frequency) /
(desired_i2c_speed), where m is multiply
factor, default: m = 1
[1:0] THRESHOLD Select threshold to use to determine whether value
sampled on SDA is a 1 or 0. Specified in terms of the ratio
between the number of sampled ones and the total number of times
SDA is sampled.
* 0x0: >0
* 0x1: 1/4 of total samples
* 0x2: 1/2 of total samples
* 0x3: 3/4 of total samples */
/* Configure the Pre-Scale multiplier
* Configure the Threshold */
HDMI_OUTP_ND(0x0220, (10 << 16) | (2 << 0));
/*
* 0x0224 HDMI_DDC_SETUP
* Setting 31:24 bits : Time units to wait before timeout
* when clock is being stalled by external sink device
*/
HDMI_OUTP_ND(0x0224, 0xff000000);
/* 0x027C HDMI_DDC_REF
[6] REFTIMER_ENABLE Enable the timer
* 0: Disable
* 1: Enable
[15:0] REFTIMER Value to set the register in order to generate
DDC strobe. This register counts on HDCP application clock */
/* Enable reference timer
* 27 micro-seconds */
HDMI_OUTP_ND(0x027C, (1 << 16) | (27 << 0));
}
static int hdmi_msm_ddc_clear_irq(const char *what)
{
const uint32 time_out = 0xFFFF;
uint32 time_out_count, reg_val;
/* clear pending and enable interrupt */
time_out_count = time_out;
do {
--time_out_count;
/* HDMI_DDC_INT_CTRL[0x0214]
[2] SW_DONE_MK Mask bit for SW_DONE_INT. Set to 1 to enable
interrupt.
[1] SW_DONE_ACK WRITE ONLY. Acknowledge bit for SW_DONE_INT.
Write 1 to clear interrupt.
[0] SW_DONE_INT READ ONLY. SW_DONE interrupt status */
/* Clear and Enable DDC interrupt */
/* Write */
HDMI_OUTP_ND(0x0214, (1 << 2) | (1 << 1));
/* Read back */
reg_val = HDMI_INP_ND(0x0214);
} while ((reg_val & 0x1) && time_out_count);
if (!time_out_count) {
DEV_ERR("%s[%s]: timedout\n", __func__, what);
return -ETIMEDOUT;
}
return 0;
}
static int hdmi_msm_ddc_write(uint32 dev_addr, uint32 offset,
const uint8 *data_buf, uint32 data_len, const char *what)
{
uint32 reg_val, ndx;
int status = 0, retry = 10;
uint32 time_out_count;
if (NULL == data_buf) {
status = -EINVAL;
DEV_ERR("%s[%s]: invalid input paramter\n", __func__, what);
goto error;
}
again:
status = hdmi_msm_ddc_clear_irq(what);
if (status)
goto error;
/* Ensure Device Address has LSB set to 0 to indicate Slave addr read */
dev_addr &= 0xFE;
/* 0x0238 HDMI_DDC_DATA
[31] INDEX_WRITE WRITE ONLY. To write index field, set this bit to
1 while writing HDMI_DDC_DATA.
[23:16] INDEX Use to set index into DDC buffer for next read or
current write, or to read index of current read or next write.
Writable only when INDEX_WRITE=1.
[15:8] DATA Use to fill or read the DDC buffer
[0] DATA_RW Select whether buffer access will be a read or write.
For writes, address auto-increments on write to HDMI_DDC_DATA.
For reads, address autoincrements on reads to HDMI_DDC_DATA.
* 0: Write
* 1: Read */
/* 1. Write to HDMI_I2C_DATA with the following fields set in order to
* handle portion #1
* DATA_RW = 0x1 (write)
* DATA = linkAddress (primary link address and writing)
* INDEX = 0x0 (initial offset into buffer)
* INDEX_WRITE = 0x1 (setting initial offset) */
HDMI_OUTP_ND(0x0238, (0x1UL << 31) | (dev_addr << 8));
/* 2. Write to HDMI_I2C_DATA with the following fields set in order to
* handle portion #2
* DATA_RW = 0x0 (write)
* DATA = offsetAddress
* INDEX = 0x0
* INDEX_WRITE = 0x0 (auto-increment by hardware) */
HDMI_OUTP_ND(0x0238, offset << 8);
/* 3. Write to HDMI_I2C_DATA with the following fields set in order to
* handle portion #3
* DATA_RW = 0x0 (write)
* DATA = data_buf[ndx]
* INDEX = 0x0
* INDEX_WRITE = 0x0 (auto-increment by hardware) */
for (ndx = 0; ndx < data_len; ++ndx)
HDMI_OUTP_ND(0x0238, ((uint32)data_buf[ndx]) << 8);
/* Data setup is complete, now setup the transaction characteristics */
/* 0x0228 HDMI_DDC_TRANS0
[23:16] CNT0 Byte count for first transaction (excluding the first
byte, which is usually the address).
[13] STOP0 Determines whether a stop bit will be sent after the first
transaction
* 0: NO STOP
* 1: STOP
[12] START0 Determines whether a start bit will be sent before the
first transaction
* 0: NO START
* 1: START
[8] STOP_ON_NACK0 Determines whether the current transfer will stop
if a NACK is received during the first transaction (current
transaction always stops).
* 0: STOP CURRENT TRANSACTION, GO TO NEXT TRANSACTION
* 1: STOP ALL TRANSACTIONS, SEND STOP BIT
[0] RW0 Read/write indicator for first transaction - set to 0 for
write, 1 for read. This bit only controls HDMI_DDC behaviour -
the R/W bit in the transaction is programmed into the DDC buffer
as the LSB of the address byte.
* 0: WRITE
* 1: READ */
/* 4. Write to HDMI_I2C_TRANSACTION0 with the following fields set in
order to handle characteristics of portion #1 and portion #2
* RW0 = 0x0 (write)
* START0 = 0x1 (insert START bit)
* STOP0 = 0x0 (do NOT insert STOP bit)
* CNT0 = 0x1 (single byte transaction excluding address) */
HDMI_OUTP_ND(0x0228, (1 << 12) | (1 << 16));
/* 0x022C HDMI_DDC_TRANS1
[23:16] CNT1 Byte count for second transaction (excluding the first
byte, which is usually the address).
[13] STOP1 Determines whether a stop bit will be sent after the second
transaction
* 0: NO STOP
* 1: STOP
[12] START1 Determines whether a start bit will be sent before the
second transaction
* 0: NO START
* 1: START
[8] STOP_ON_NACK1 Determines whether the current transfer will stop if
a NACK is received during the second transaction (current
transaction always stops).
* 0: STOP CURRENT TRANSACTION, GO TO NEXT TRANSACTION
* 1: STOP ALL TRANSACTIONS, SEND STOP BIT
[0] RW1 Read/write indicator for second transaction - set to 0 for
write, 1 for read. This bit only controls HDMI_DDC behaviour -
the R/W bit in the transaction is programmed into the DDC buffer
as the LSB of the address byte.
* 0: WRITE
* 1: READ */
/* 5. Write to HDMI_I2C_TRANSACTION1 with the following fields set in
order to handle characteristics of portion #3
* RW1 = 0x1 (read)
* START1 = 0x1 (insert START bit)
* STOP1 = 0x1 (insert STOP bit)
* CNT1 = data_len (0xN (write N bytes of data))
* Byte count for second transition (excluding the first
* Byte which is usually the address) */
HDMI_OUTP_ND(0x022C, (1 << 13) | ((data_len-1) << 16));
/* Trigger the I2C transfer */
/* 0x020C HDMI_DDC_CTRL
[21:20] TRANSACTION_CNT
Number of transactions to be done in current transfer.
* 0x0: transaction0 only
* 0x1: transaction0, transaction1
* 0x2: transaction0, transaction1, transaction2
* 0x3: transaction0, transaction1, transaction2, transaction3
[3] SW_STATUS_RESET
Write 1 to reset HDMI_DDC_SW_STATUS flags, will reset SW_DONE,
ABORTED, TIMEOUT, SW_INTERRUPTED, BUFFER_OVERFLOW,
STOPPED_ON_NACK, NACK0, NACK1, NACK2, NACK3
[2] SEND_RESET Set to 1 to send reset sequence (9 clocks with no
data) at start of transfer. This sequence is sent after GO is
written to 1, before the first transaction only.
[1] SOFT_RESET Write 1 to reset DDC controller
[0] GO WRITE ONLY. Write 1 to start DDC transfer. */
/* 6. Write to HDMI_I2C_CONTROL to kick off the hardware.
* Note that NOTHING has been transmitted on the DDC lines up to this
* point.
* TRANSACTION_CNT = 0x1 (execute transaction0 followed by
* transaction1)
* GO = 0x1 (kicks off hardware) */
INIT_COMPLETION(hdmi_msm_state->ddc_sw_done);
HDMI_OUTP_ND(0x020C, (1 << 0) | (1 << 20));
time_out_count = wait_for_completion_interruptible_timeout(
&hdmi_msm_state->ddc_sw_done, HZ/2);
HDMI_OUTP_ND(0x0214, 0x2);
if (!time_out_count) {
if (retry-- > 0) {
DEV_INFO("%s[%s]: failed timout, retry=%d\n", __func__,
what, retry);
goto again;
}
status = -ETIMEDOUT;
DEV_ERR("%s[%s]: timedout, DDC SW Status=%08x, HW "
"Status=%08x, Int Ctrl=%08x\n", __func__, what,
HDMI_INP_ND(0x0218), HDMI_INP_ND(0x021C),
HDMI_INP_ND(0x0214));
goto error;
}
/* Read DDC status */
reg_val = HDMI_INP_ND(0x0218);
reg_val &= 0x00001000 | 0x00002000 | 0x00004000 | 0x00008000;
/* Check if any NACK occurred */
if (reg_val) {
if (retry > 1)
HDMI_OUTP_ND(0x020C, BIT(3)); /* SW_STATUS_RESET */
else
HDMI_OUTP_ND(0x020C, BIT(1)); /* SOFT_RESET */
if (retry-- > 0) {
DEV_DBG("%s[%s]: failed NACK=%08x, retry=%d\n",
__func__, what, reg_val, retry);
msleep(100);
goto again;
}
status = -EIO;
DEV_ERR("%s[%s]: failed NACK: %08x\n", __func__, what, reg_val);
goto error;
}
DEV_DBG("%s[%s] success\n", __func__, what);
error:
return status;
}
static int hdmi_msm_ddc_read_retry(uint32 dev_addr, uint32 offset,
uint8 *data_buf, uint32 data_len, uint32 request_len, int retry,
const char *what)
{
uint32 reg_val, ndx;
int status = 0;
uint32 time_out_count;
int log_retry_fail = retry != 1;
if (NULL == data_buf) {
status = -EINVAL;
DEV_ERR("%s: invalid input paramter\n", __func__);
goto error;
}
again:
status = hdmi_msm_ddc_clear_irq(what);
if (status)
goto error;
/* Ensure Device Address has LSB set to 0 to indicate Slave addr read */
dev_addr &= 0xFE;
/* 0x0238 HDMI_DDC_DATA
[31] INDEX_WRITE WRITE ONLY. To write index field, set this bit to
1 while writing HDMI_DDC_DATA.
[23:16] INDEX Use to set index into DDC buffer for next read or
current write, or to read index of current read or next write.
Writable only when INDEX_WRITE=1.
[15:8] DATA Use to fill or read the DDC buffer
[0] DATA_RW Select whether buffer access will be a read or write.
For writes, address auto-increments on write to HDMI_DDC_DATA.
For reads, address autoincrements on reads to HDMI_DDC_DATA.
* 0: Write
* 1: Read */
/* 1. Write to HDMI_I2C_DATA with the following fields set in order to
* handle portion #1
* DATA_RW = 0x0 (write)
* DATA = linkAddress (primary link address and writing)
* INDEX = 0x0 (initial offset into buffer)
* INDEX_WRITE = 0x1 (setting initial offset) */
HDMI_OUTP_ND(0x0238, (0x1UL << 31) | (dev_addr << 8));
/* 2. Write to HDMI_I2C_DATA with the following fields set in order to
* handle portion #2
* DATA_RW = 0x0 (write)
* DATA = offsetAddress
* INDEX = 0x0
* INDEX_WRITE = 0x0 (auto-increment by hardware) */
HDMI_OUTP_ND(0x0238, offset << 8);
/* 3. Write to HDMI_I2C_DATA with the following fields set in order to
* handle portion #3
* DATA_RW = 0x0 (write)
* DATA = linkAddress + 1 (primary link address 0x74 and reading)
* INDEX = 0x0
* INDEX_WRITE = 0x0 (auto-increment by hardware) */
HDMI_OUTP_ND(0x0238, (dev_addr | 1) << 8);
/* Data setup is complete, now setup the transaction characteristics */
/* 0x0228 HDMI_DDC_TRANS0
[23:16] CNT0 Byte count for first transaction (excluding the first
byte, which is usually the address).
[13] STOP0 Determines whether a stop bit will be sent after the first
transaction
* 0: NO STOP
* 1: STOP
[12] START0 Determines whether a start bit will be sent before the
first transaction
* 0: NO START
* 1: START
[8] STOP_ON_NACK0 Determines whether the current transfer will stop
if a NACK is received during the first transaction (current
transaction always stops).
* 0: STOP CURRENT TRANSACTION, GO TO NEXT TRANSACTION
* 1: STOP ALL TRANSACTIONS, SEND STOP BIT
[0] RW0 Read/write indicator for first transaction - set to 0 for
write, 1 for read. This bit only controls HDMI_DDC behaviour -
the R/W bit in the transaction is programmed into the DDC buffer
as the LSB of the address byte.
* 0: WRITE
* 1: READ */
/* 4. Write to HDMI_I2C_TRANSACTION0 with the following fields set in
order to handle characteristics of portion #1 and portion #2
* RW0 = 0x0 (write)
* START0 = 0x1 (insert START bit)
* STOP0 = 0x0 (do NOT insert STOP bit)
* CNT0 = 0x1 (single byte transaction excluding address) */
HDMI_OUTP_ND(0x0228, (1 << 12) | (1 << 16));
/* 0x022C HDMI_DDC_TRANS1
[23:16] CNT1 Byte count for second transaction (excluding the first
byte, which is usually the address).
[13] STOP1 Determines whether a stop bit will be sent after the second
transaction
* 0: NO STOP
* 1: STOP
[12] START1 Determines whether a start bit will be sent before the
second transaction
* 0: NO START
* 1: START
[8] STOP_ON_NACK1 Determines whether the current transfer will stop if
a NACK is received during the second transaction (current
transaction always stops).
* 0: STOP CURRENT TRANSACTION, GO TO NEXT TRANSACTION
* 1: STOP ALL TRANSACTIONS, SEND STOP BIT
[0] RW1 Read/write indicator for second transaction - set to 0 for
write, 1 for read. This bit only controls HDMI_DDC behaviour -
the R/W bit in the transaction is programmed into the DDC buffer
as the LSB of the address byte.
* 0: WRITE
* 1: READ */
/* 5. Write to HDMI_I2C_TRANSACTION1 with the following fields set in
order to handle characteristics of portion #3
* RW1 = 0x1 (read)
* START1 = 0x1 (insert START bit)
* STOP1 = 0x1 (insert STOP bit)
* CNT1 = data_len (it's 128 (0x80) for a blk read) */
HDMI_OUTP_ND(0x022C, 1 | (1 << 12) | (1 << 13) | (request_len << 16));
/* Trigger the I2C transfer */
/* 0x020C HDMI_DDC_CTRL
[21:20] TRANSACTION_CNT
Number of transactions to be done in current transfer.
* 0x0: transaction0 only
* 0x1: transaction0, transaction1
* 0x2: transaction0, transaction1, transaction2
* 0x3: transaction0, transaction1, transaction2, transaction3
[3] SW_STATUS_RESET
Write 1 to reset HDMI_DDC_SW_STATUS flags, will reset SW_DONE,
ABORTED, TIMEOUT, SW_INTERRUPTED, BUFFER_OVERFLOW,
STOPPED_ON_NACK, NACK0, NACK1, NACK2, NACK3
[2] SEND_RESET Set to 1 to send reset sequence (9 clocks with no
data) at start of transfer. This sequence is sent after GO is
written to 1, before the first transaction only.
[1] SOFT_RESET Write 1 to reset DDC controller
[0] GO WRITE ONLY. Write 1 to start DDC transfer. */
/* 6. Write to HDMI_I2C_CONTROL to kick off the hardware.
* Note that NOTHING has been transmitted on the DDC lines up to this
* point.
* TRANSACTION_CNT = 0x1 (execute transaction0 followed by
* transaction1)
* SEND_RESET = Set to 1 to send reset sequence
* GO = 0x1 (kicks off hardware) */
INIT_COMPLETION(hdmi_msm_state->ddc_sw_done);
HDMI_OUTP_ND(0x020C, (1 << 0) | (1 << 20));
time_out_count = wait_for_completion_interruptible_timeout(
&hdmi_msm_state->ddc_sw_done, HZ/2);
HDMI_OUTP_ND(0x0214, 0x2);
if (!time_out_count) {
if (retry-- > 0) {
DEV_INFO("%s: failed timout, retry=%d\n", __func__,
retry);
goto again;
}
status = -ETIMEDOUT;
DEV_ERR("%s: timedout(7), DDC SW Status=%08x, HW "
"Status=%08x, Int Ctrl=%08x\n", __func__,
HDMI_INP(0x0218), HDMI_INP(0x021C), HDMI_INP(0x0214));
goto error;
}
/* Read DDC status */
reg_val = HDMI_INP_ND(0x0218);
reg_val &= 0x00001000 | 0x00002000 | 0x00004000 | 0x00008000;
/* Check if any NACK occurred */
if (reg_val) {
HDMI_OUTP_ND(0x020C, BIT(3)); /* SW_STATUS_RESET */
if (retry == 1)
HDMI_OUTP_ND(0x020C, BIT(1)); /* SOFT_RESET */
if (retry-- > 0) {
DEV_DBG("%s(%s): failed NACK=0x%08x, retry=%d, "
"dev-addr=0x%02x, offset=0x%02x, "
"length=%d\n", __func__, what,
reg_val, retry, dev_addr,
offset, data_len);
goto again;
}
status = -EIO;
if (log_retry_fail)
DEV_ERR("%s(%s): failed NACK=0x%08x, dev-addr=0x%02x, "
"offset=0x%02x, length=%d\n", __func__, what,
reg_val, dev_addr, offset, data_len);
goto error;
}
/* 0x0238 HDMI_DDC_DATA
[31] INDEX_WRITE WRITE ONLY. To write index field, set this bit to 1
while writing HDMI_DDC_DATA.
[23:16] INDEX Use to set index into DDC buffer for next read or
current write, or to read index of current read or next write.
Writable only when INDEX_WRITE=1.
[15:8] DATA Use to fill or read the DDC buffer
[0] DATA_RW Select whether buffer access will be a read or write.
For writes, address auto-increments on write to HDMI_DDC_DATA.
For reads, address autoincrements on reads to HDMI_DDC_DATA.
* 0: Write
* 1: Read */
/* 8. ALL data is now available and waiting in the DDC buffer.
* Read HDMI_I2C_DATA with the following fields set
* RW = 0x1 (read)
* DATA = BCAPS (this is field where data is pulled from)
* INDEX = 0x3 (where the data has been placed in buffer by hardware)
* INDEX_WRITE = 0x1 (explicitly define offset) */
/* Write this data to DDC buffer */
HDMI_OUTP_ND(0x0238, 0x1 | (3 << 16) | (1 << 31));
/* Discard first byte */
HDMI_INP_ND(0x0238);
for (ndx = 0; ndx < data_len; ++ndx) {
reg_val = HDMI_INP_ND(0x0238);
data_buf[ndx] = (uint8) ((reg_val & 0x0000FF00) >> 8);
}
DEV_DBG("%s[%s] success\n", __func__, what);
error:
return status;
}
static int hdmi_msm_ddc_read_edid_seg(uint32 dev_addr, uint32 offset,
uint8 *data_buf, uint32 data_len, uint32 request_len, int retry,
const char *what)
{
uint32 reg_val, ndx;
int status = 0;
uint32 time_out_count;
int log_retry_fail = retry != 1;
int seg_addr = 0x60, seg_num = 0x01;
if (NULL == data_buf) {
status = -EINVAL;
DEV_ERR("%s: invalid input paramter\n", __func__);
goto error;
}
again:
status = hdmi_msm_ddc_clear_irq(what);
if (status)
goto error;
/* Ensure Device Address has LSB set to 0 to indicate Slave addr read */
dev_addr &= 0xFE;
/* 0x0238 HDMI_DDC_DATA
[31] INDEX_WRITE WRITE ONLY. To write index field, set this bit to
1 while writing HDMI_DDC_DATA.
[23:16] INDEX Use to set index into DDC buffer for next read or
current write, or to read index of current read or next write.
Writable only when INDEX_WRITE=1.
[15:8] DATA Use to fill or read the DDC buffer
[0] DATA_RW Select whether buffer access will be a read or write.
For writes, address auto-increments on write to HDMI_DDC_DATA.
For reads, address autoincrements on reads to HDMI_DDC_DATA.
* 0: Write
* 1: Read */
/* 1. Write to HDMI_I2C_DATA with the following fields set in order to
* handle portion #1
* DATA_RW = 0x0 (write)
* DATA = linkAddress (primary link address and writing)
* INDEX = 0x0 (initial offset into buffer)
* INDEX_WRITE = 0x1 (setting initial offset) */
HDMI_OUTP_ND(0x0238, (0x1UL << 31) | (seg_addr << 8));
/* 2. Write to HDMI_I2C_DATA with the following fields set in order to
* handle portion #2
* DATA_RW = 0x0 (write)
* DATA = offsetAddress
* INDEX = 0x0
* INDEX_WRITE = 0x0 (auto-increment by hardware) */
HDMI_OUTP_ND(0x0238, seg_num << 8);
/* 3. Write to HDMI_I2C_DATA with the following fields set in order to
* handle portion #3
* DATA_RW = 0x0 (write)
* DATA = linkAddress + 1 (primary link address 0x74 and reading)
* INDEX = 0x0
* INDEX_WRITE = 0x0 (auto-increment by hardware) */
HDMI_OUTP_ND(0x0238, dev_addr << 8);
HDMI_OUTP_ND(0x0238, offset << 8);
HDMI_OUTP_ND(0x0238, (dev_addr | 1) << 8);
/* Data setup is complete, now setup the transaction characteristics */
/* 0x0228 HDMI_DDC_TRANS0
[23:16] CNT0 Byte count for first transaction (excluding the first
byte, which is usually the address).
[13] STOP0 Determines whether a stop bit will be sent after the first
transaction
* 0: NO STOP
* 1: STOP
[12] START0 Determines whether a start bit will be sent before the
first transaction
* 0: NO START
* 1: START
[8] STOP_ON_NACK0 Determines whether the current transfer will stop
if a NACK is received during the first transaction (current
transaction always stops).
* 0: STOP CURRENT TRANSACTION, GO TO NEXT TRANSACTION
* 1: STOP ALL TRANSACTIONS, SEND STOP BIT
[0] RW0 Read/write indicator for first transaction - set to 0 for
write, 1 for read. This bit only controls HDMI_DDC behaviour -
the R/W bit in the transaction is programmed into the DDC buffer
as the LSB of the address byte.
* 0: WRITE
* 1: READ */
/* 4. Write to HDMI_I2C_TRANSACTION0 with the following fields set in
order to handle characteristics of portion #1 and portion #2
* RW0 = 0x0 (write)
* START0 = 0x1 (insert START bit)
* STOP0 = 0x0 (do NOT insert STOP bit)
* CNT0 = 0x1 (single byte transaction excluding address) */
HDMI_OUTP_ND(0x0228, (1 << 12) | (1 << 16));
/* 0x022C HDMI_DDC_TRANS1
[23:16] CNT1 Byte count for second transaction (excluding the first
byte, which is usually the address).
[13] STOP1 Determines whether a stop bit will be sent after the second
transaction
* 0: NO STOP
* 1: STOP
[12] START1 Determines whether a start bit will be sent before the
second transaction
* 0: NO START
* 1: START
[8] STOP_ON_NACK1 Determines whether the current transfer will stop if
a NACK is received during the second transaction (current
transaction always stops).
* 0: STOP CURRENT TRANSACTION, GO TO NEXT TRANSACTION
* 1: STOP ALL TRANSACTIONS, SEND STOP BIT
[0] RW1 Read/write indicator for second transaction - set to 0 for
write, 1 for read. This bit only controls HDMI_DDC behaviour -
the R/W bit in the transaction is programmed into the DDC buffer
as the LSB of the address byte.
* 0: WRITE
* 1: READ */
/* 5. Write to HDMI_I2C_TRANSACTION1 with the following fields set in
order to handle characteristics of portion #3
* RW1 = 0x1 (read)
* START1 = 0x1 (insert START bit)
* STOP1 = 0x1 (insert STOP bit)
* CNT1 = data_len (it's 128 (0x80) for a blk read) */
HDMI_OUTP_ND(0x022C, (1 << 12) | (1 << 16));
/* 0x022C HDMI_DDC_TRANS2
[23:16] CNT1 Byte count for second transaction (excluding the first
byte, which is usually the address).
[13] STOP1 Determines whether a stop bit will be sent after the second
transaction
* 0: NO STOP
* 1: STOP
[12] START1 Determines whether a start bit will be sent before the
second transaction
* 0: NO START
* 1: START
[8] STOP_ON_NACK1 Determines whether the current transfer will stop if
a NACK is received during the second transaction (current
transaction always stops).
* 0: STOP CURRENT TRANSACTION, GO TO NEXT TRANSACTION
* 1: STOP ALL TRANSACTIONS, SEND STOP BIT
[0] RW1 Read/write indicator for second transaction - set to 0 for
write, 1 for read. This bit only controls HDMI_DDC behaviour -
the R/W bit in the transaction is programmed into the DDC buffer
as the LSB of the address byte.
* 0: WRITE
* 1: READ */
/* 5. Write to HDMI_I2C_TRANSACTION1 with the following fields set in
order to handle characteristics of portion #3
* RW1 = 0x1 (read)
* START1 = 0x1 (insert START bit)
* STOP1 = 0x1 (insert STOP bit)
* CNT1 = data_len (it's 128 (0x80) for a blk read) */
HDMI_OUTP_ND(0x0230, 1 | (1 << 12) | (1 << 13) | (request_len << 16));
/* Trigger the I2C transfer */
/* 0x020C HDMI_DDC_CTRL
[21:20] TRANSACTION_CNT
Number of transactions to be done in current transfer.
* 0x0: transaction0 only
* 0x1: transaction0, transaction1
* 0x2: transaction0, transaction1, transaction2
* 0x3: transaction0, transaction1, transaction2, transaction3
[3] SW_STATUS_RESET
Write 1 to reset HDMI_DDC_SW_STATUS flags, will reset SW_DONE,
ABORTED, TIMEOUT, SW_INTERRUPTED, BUFFER_OVERFLOW,
STOPPED_ON_NACK, NACK0, NACK1, NACK2, NACK3
[2] SEND_RESET Set to 1 to send reset sequence (9 clocks with no
data) at start of transfer. This sequence is sent after GO is
written to 1, before the first transaction only.
[1] SOFT_RESET Write 1 to reset DDC controller
[0] GO WRITE ONLY. Write 1 to start DDC transfer. */
/* 6. Write to HDMI_I2C_CONTROL to kick off the hardware.
* Note that NOTHING has been transmitted on the DDC lines up to this
* point.
* TRANSACTION_CNT = 0x2 (execute transaction0 followed by
* transaction1)
* GO = 0x1 (kicks off hardware) */
INIT_COMPLETION(hdmi_msm_state->ddc_sw_done);
HDMI_OUTP_ND(0x020C, (1 << 0) | (2 << 20));
time_out_count = wait_for_completion_interruptible_timeout(
&hdmi_msm_state->ddc_sw_done, HZ/2);
HDMI_OUTP_ND(0x0214, 0x2);
if (!time_out_count) {
if (retry-- > 0) {
DEV_INFO("%s: failed timout, retry=%d\n", __func__,
retry);
goto again;
}
status = -ETIMEDOUT;
DEV_ERR("%s: timedout(7), DDC SW Status=%08x, HW "
"Status=%08x, Int Ctrl=%08x\n", __func__,
HDMI_INP(0x0218), HDMI_INP(0x021C), HDMI_INP(0x0214));
goto error;
}
/* Read DDC status */
reg_val = HDMI_INP_ND(0x0218);
reg_val &= 0x00001000 | 0x00002000 | 0x00004000 | 0x00008000;
/* Check if any NACK occurred */
if (reg_val) {
HDMI_OUTP_ND(0x020C, BIT(3)); /* SW_STATUS_RESET */
if (retry == 1)
HDMI_OUTP_ND(0x020C, BIT(1)); /* SOFT_RESET */
if (retry-- > 0) {
DEV_DBG("%s(%s): failed NACK=0x%08x, retry=%d, "
"dev-addr=0x%02x, offset=0x%02x, "
"length=%d\n", __func__, what,
reg_val, retry, dev_addr,
offset, data_len);
goto again;
}
status = -EIO;
if (log_retry_fail)
DEV_ERR("%s(%s): failed NACK=0x%08x, dev-addr=0x%02x, "
"offset=0x%02x, length=%d\n", __func__, what,
reg_val, dev_addr, offset, data_len);
goto error;
}
/* 0x0238 HDMI_DDC_DATA
[31] INDEX_WRITE WRITE ONLY. To write index field, set this bit to 1
while writing HDMI_DDC_DATA.
[23:16] INDEX Use to set index into DDC buffer for next read or
current write, or to read index of current read or next write.
Writable only when INDEX_WRITE=1.
[15:8] DATA Use to fill or read the DDC buffer
[0] DATA_RW Select whether buffer access will be a read or write.
For writes, address auto-increments on write to HDMI_DDC_DATA.
For reads, address autoincrements on reads to HDMI_DDC_DATA.
* 0: Write
* 1: Read */
/* 8. ALL data is now available and waiting in the DDC buffer.
* Read HDMI_I2C_DATA with the following fields set
* RW = 0x1 (read)
* DATA = BCAPS (this is field where data is pulled from)
* INDEX = 0x5 (where the data has been placed in buffer by hardware)
* INDEX_WRITE = 0x1 (explicitly define offset) */
/* Write this data to DDC buffer */
HDMI_OUTP_ND(0x0238, 0x1 | (5 << 16) | (1 << 31));
/* Discard first byte */
HDMI_INP_ND(0x0238);
for (ndx = 0; ndx < data_len; ++ndx) {
reg_val = HDMI_INP_ND(0x0238);
data_buf[ndx] = (uint8) ((reg_val & 0x0000FF00) >> 8);
}
DEV_DBG("%s[%s] success\n", __func__, what);
error:
return status;
}
static int hdmi_msm_ddc_read(uint32 dev_addr, uint32 offset, uint8 *data_buf,
uint32 data_len, int retry, const char *what, boolean no_align)
{
int ret = hdmi_msm_ddc_read_retry(dev_addr, offset, data_buf, data_len,
data_len, retry, what);
if (!ret)
return 0;
if (no_align) {
return hdmi_msm_ddc_read_retry(dev_addr, offset, data_buf,
data_len, data_len, retry, what);
} else {
return hdmi_msm_ddc_read_retry(dev_addr, offset, data_buf,
data_len, 32 * ((data_len + 31) / 32), retry, what);
}
}
static int hdmi_msm_read_edid_block(int block, uint8 *edid_buf)
{
int i, rc = 0;
int block_size = 0x80;
do {
DEV_DBG("EDID: reading block(%d) with block-size=%d\n",
block, block_size);
for (i = 0; i < 0x80; i += block_size) {
/*Read EDID twice with 32bit alighnment too */
if (block < 2) {
rc = hdmi_msm_ddc_read(0xA0, block*0x80 + i,
edid_buf+i, block_size, 1,
"EDID", FALSE);
} else {
rc = hdmi_msm_ddc_read_edid_seg(0xA0,
block*0x80 + i, edid_buf+i, block_size,
block_size, 1, "EDID");
}
if (rc)
break;
}
block_size /= 2;
} while (rc && (block_size >= 16));
return rc;
}
static int hdmi_msm_read_edid(void)
{
int status;
msm_hdmi_init_ddc();
/* Looks like we need to turn on HDMI engine before any
* DDC transaction */
if (!hdmi_msm_is_power_on()) {
DEV_ERR("%s: failed: HDMI power is off", __func__);
status = -ENXIO;
goto error;
}
external_common_state->read_edid_block = hdmi_msm_read_edid_block;
status = hdmi_common_read_edid();
if (!status)
DEV_DBG("EDID: successfully read\n");
error:
return status;
}
static void hdcp_auth_info(uint32 auth_info)
{
if (!hdmi_msm_state->hdcp_enable) {
DEV_DBG("%s: HDCP not enabled\n", __func__);
return;
}
switch (auth_info) {
case 0:
DEV_INFO("%s: None", __func__);
break;
case 1:
DEV_INFO("%s: Software Disabled Authentication", __func__);
break;
case 2:
DEV_INFO("%s: An Written", __func__);
break;
case 3:
DEV_INFO("%s: Invalid Aksv", __func__);
break;
case 4:
DEV_INFO("%s: Invalid Bksv", __func__);
break;
case 5:
DEV_INFO("%s: RI Mismatch (including RO)", __func__);
break;
case 6:
DEV_INFO("%s: consecutive Pj Mismatches", __func__);
break;
case 7:
DEV_INFO("%s: HPD Disconnect", __func__);
break;
case 8:
default:
DEV_INFO("%s: Reserved", __func__);
break;
}
}
static void hdcp_key_state(uint32 key_state)
{
if (!hdmi_msm_state->hdcp_enable) {
DEV_DBG("%s: HDCP not enabled\n", __func__);
return;
}
switch (key_state) {
case 0:
DEV_WARN("%s: No HDCP Keys", __func__);
break;
case 1:
DEV_WARN("%s: Not Checked", __func__);
break;
case 2:
DEV_DBG("%s: Checking", __func__);
break;
case 3:
DEV_DBG("%s: HDCP Keys Valid", __func__);
break;
case 4:
DEV_WARN("%s: AKSV not valid", __func__);
break;
case 5:
DEV_WARN("%s: Checksum Mismatch", __func__);
break;
case 6:
DEV_DBG("%s: Production AKSV"
"with ENABLE_USER_DEFINED_AN=1", __func__);
break;
case 7:
default:
DEV_INFO("%s: Reserved", __func__);
break;
}
}
static int hdmi_msm_count_one(uint8 *array, uint8 len)
{
int i, j, count = 0;
for (i = 0; i < len; i++)
for (j = 0; j < 8; j++)
count += (((array[i] >> j) & 0x1) ? 1 : 0);
return count;
}
static void hdcp_deauthenticate(void)
{
int hdcp_link_status = HDMI_INP(0x011C);
if (!hdmi_msm_state->hdcp_enable) {
DEV_DBG("%s: HDCP not enabled\n", __func__);
return;
}
/* Disable HDCP interrupts */
HDMI_OUTP(0x0118, 0x0);
mutex_lock(&hdcp_auth_state_mutex);
external_common_state->hdcp_active = FALSE;
mutex_unlock(&hdcp_auth_state_mutex);
/* 0x0130 HDCP_RESET
[0] LINK0_DEAUTHENTICATE */
HDMI_OUTP(0x0130, 0x1);
/* 0x0110 HDCP_CTRL
[8] ENCRYPTION_ENABLE
[0] ENABLE */
/* encryption_enable = 0 | hdcp block enable = 1 */
HDMI_OUTP(0x0110, 0x0);
if (hdcp_link_status & 0x00000004)
hdcp_auth_info((hdcp_link_status & 0x000000F0) >> 4);
}
static void check_and_clear_HDCP_DDC_Failure(void)
{
int hdcp_ddc_ctrl1_reg;
int hdcp_ddc_status;
int failure;
int nack0;
if (!hdmi_msm_state->hdcp_enable) {
DEV_DBG("%s: HDCP not enabled\n", __func__);
return;
}
/*
* Check for any DDC transfer failures
* 0x0128 HDCP_DDC_STATUS
* [16] FAILED Indicates that the last HDCP HW DDC transer
* failed. This occurs when a transfer is
* attempted with HDCP DDC disabled
* (HDCP_DDC_DISABLE=1) or the number of retries
* match HDCP_DDC_RETRY_CNT
*
* [14] NACK0 Indicates that the last HDCP HW DDC transfer
* was aborted due to a NACK on the first
* transaction - cleared by writing 0 to GO bit
*/
hdcp_ddc_status = HDMI_INP(HDCP_DDC_STATUS);
failure = (hdcp_ddc_status >> 16) & 0x1;
nack0 = (hdcp_ddc_status >> 14) & 0x1;
DEV_DBG("%s: On Entry: HDCP_DDC_STATUS = 0x%x, FAILURE = %d,"
"NACK0 = %d\n", __func__ , hdcp_ddc_status, failure, nack0);
if (failure == 0x1) {
/*
* Indicates that the last HDCP HW DDC transfer failed.
* This occurs when a transfer is attempted with HDCP DDC
* disabled (HDCP_DDC_DISABLE=1) or the number of retries
* matches HDCP_DDC_RETRY_CNT.
* Failure occured, let's clear it.
*/
DEV_INFO("%s: DDC failure detected. HDCP_DDC_STATUS=0x%08x\n",
__func__, hdcp_ddc_status);
/*
* First, Disable DDC
* 0x0120 HDCP_DDC_CTRL_0
* [0] DDC_DISABLE Determines whether HDCP Ri and Pj reads
* are done unassisted by hardware or by
* software via HDMI_DDC (HDCP provides
* interrupts to request software
* transfers)
* 0 : Use Hardware DDC
* 1 : Use Software DDC
*/
HDMI_OUTP(HDCP_DDC_CTRL_0, 0x1);
/*
* ACK the Failure to Clear it
* 0x0124 HDCP_DDC_CTRL_1
* [0] DDC_FAILED_ACK Write 1 to clear
* HDCP_STATUS.HDCP_DDC_FAILED
*/
hdcp_ddc_ctrl1_reg = HDMI_INP(HDCP_DDC_CTRL_1);
HDMI_OUTP(HDCP_DDC_CTRL_1, hdcp_ddc_ctrl1_reg | 0x1);
/* Check if the FAILURE got Cleared */
hdcp_ddc_status = HDMI_INP(HDCP_DDC_STATUS);
hdcp_ddc_status = (hdcp_ddc_status >> 16) & 0x1;
if (hdcp_ddc_status == 0x0) {
DEV_INFO("%s: HDCP DDC Failure has been cleared\n",
__func__);
} else {
DEV_WARN("%s: Error: HDCP DDC Failure DID NOT get"
"cleared\n", __func__);
}
/* Re-Enable HDCP DDC */
HDMI_OUTP(HDCP_DDC_CTRL_0, 0x0);
}
if (nack0 == 0x1) {
/*
* 0x020C HDMI_DDC_CTRL
* [3] SW_STATUS_RESET Write 1 to reset HDMI_DDC_SW_STATUS
* flags, will reset SW_DONE, ABORTED,
* TIMEOUT, SW_INTERRUPTED,
* BUFFER_OVERFLOW, STOPPED_ON_NACK, NACK0,
* NACK1, NACK2, NACK3
*/
HDMI_OUTP_ND(HDMI_DDC_CTRL,
HDMI_INP(HDMI_DDC_CTRL) | (0x1 << 3));
msleep(20);
HDMI_OUTP_ND(HDMI_DDC_CTRL,
HDMI_INP(HDMI_DDC_CTRL) & ~(0x1 << 3));
}
hdcp_ddc_status = HDMI_INP(HDCP_DDC_STATUS);
failure = (hdcp_ddc_status >> 16) & 0x1;
nack0 = (hdcp_ddc_status >> 14) & 0x1;
DEV_DBG("%s: On Exit: HDCP_DDC_STATUS = 0x%x, FAILURE = %d,"
"NACK0 = %d\n", __func__ , hdcp_ddc_status, failure, nack0);
}
static int hdcp_authentication_part1(void)
{
int ret = 0;
boolean is_match;
boolean is_part1_done = FALSE;
uint32 timeout_count;
uint8 bcaps;
uint8 aksv[5];
uint32 qfprom_aksv_0, qfprom_aksv_1, link0_aksv_0, link0_aksv_1;
uint8 bksv[5];
uint32 link0_bksv_0, link0_bksv_1;
uint8 an[8];
uint32 link0_an_0, link0_an_1;
uint32 hpd_int_status, hpd_int_ctrl;
static uint8 buf[0xFF];
memset(buf, 0, sizeof(buf));
if (!hdmi_msm_state->hdcp_enable) {
DEV_DBG("%s: HDCP not enabled\n", __func__);
return 0;
}
if (!is_part1_done) {
is_part1_done = TRUE;
/* Fetch aksv from QFprom, this info should be public. */
qfprom_aksv_0 = inpdw(QFPROM_BASE + 0x000060D8);
qfprom_aksv_1 = inpdw(QFPROM_BASE + 0x000060DC);
/* copy an and aksv to byte arrays for transmission */
aksv[0] = qfprom_aksv_0 & 0xFF;
aksv[1] = (qfprom_aksv_0 >> 8) & 0xFF;
aksv[2] = (qfprom_aksv_0 >> 16) & 0xFF;
aksv[3] = (qfprom_aksv_0 >> 24) & 0xFF;
aksv[4] = qfprom_aksv_1 & 0xFF;
/* check there are 20 ones in AKSV */
if (hdmi_msm_count_one(aksv, 5) != 20) {
DEV_ERR("HDCP: AKSV read from QFPROM doesn't have "
"20 1's and 20 0's, FAIL (AKSV=%02x%08x)\n",
qfprom_aksv_1, qfprom_aksv_0);
ret = -EINVAL;
goto error;
}
DEV_DBG("HDCP: AKSV=%02x%08x\n", qfprom_aksv_1, qfprom_aksv_0);
/* 0x0288 HDCP_SW_LOWER_AKSV
[31:0] LOWER_AKSV */
/* 0x0284 HDCP_SW_UPPER_AKSV
[7:0] UPPER_AKSV */
/* This is the lower 32 bits of the SW
* injected AKSV value(AKSV[31:0]) read
* from the EFUSE. It is needed for HDCP
* authentication and must be written
* before enabling HDCP. */
HDMI_OUTP(0x0288, qfprom_aksv_0);
HDMI_OUTP(0x0284, qfprom_aksv_1);
msm_hdmi_init_ddc();
/* read Bcaps at 0x40 in HDCP Port */
ret = hdmi_msm_ddc_read(0x74, 0x40, &bcaps, 1, 5, "Bcaps",
TRUE);
if (ret) {
DEV_ERR("%s(%d): Read Bcaps failed", __func__,
__LINE__);
goto error;
}
DEV_DBG("HDCP: Bcaps=%02x\n", bcaps);
/* HDCP setup prior to HDCP enabled */
/* 0x0148 HDCP_RCVPORT_DATA4
[15:8] LINK0_AINFO
[7:0] LINK0_AKSV_1 */
/* LINK0_AINFO = 0x2 FEATURE 1.1 on.
* = 0x0 FEATURE 1.1 off*/
HDMI_OUTP(0x0148, 0x0);
/* 0x012C HDCP_ENTROPY_CTRL0
[31:0] BITS_OF_INFLUENCE_0 */
/* 0x025C HDCP_ENTROPY_CTRL1
[31:0] BITS_OF_INFLUENCE_1 */
HDMI_OUTP(0x012C, 0xB1FFB0FF);
HDMI_OUTP(0x025C, 0xF00DFACE);
/* 0x0114 HDCP_DEBUG_CTRL
[2] DEBUG_RNG_CIPHER
else default 0 */
HDMI_OUTP(0x0114, HDMI_INP(0x0114) & 0xFFFFFFFB);
/* 0x0110 HDCP_CTRL
[8] ENCRYPTION_ENABLE
[0] ENABLE */
/* Enable HDCP. Encryption should be enabled after reading R0 */
HDMI_OUTP(0x0110, BIT(0));
/*
* Check to see if a HDCP DDC Failure is indicated in
* HDCP_DDC_STATUS. If yes, clear it.
*/
check_and_clear_HDCP_DDC_Failure();
/* 0x0118 HDCP_INT_CTRL
* [2] AUTH_SUCCESS_MASK [R/W] Mask bit for\
* HDCP Authentication
* Success interrupt - set to 1 to enable interrupt
*
* [6] AUTH_FAIL_MASK [R/W] Mask bit for HDCP
* Authentication
* Lost interrupt set to 1 to enable interrupt
*
* [7] AUTH_FAIL_INFO_ACK [W] Acknwledge bit for HDCP
* Auth Failure Info field - write 1 to clear
*
* [10] DDC_XFER_REQ_MASK [R/W] Mask bit for HDCP\
* DDC Transfer
* Request interrupt - set to 1 to enable interrupt
*
* [14] DDC_XFER_DONE_MASK [R/W] Mask bit for HDCP\
* DDC Transfer
* done interrupt - set to 1 to enable interrupt */
/* enable all HDCP ints */
HDMI_OUTP(0x0118, (1 << 2) | (1 << 6) | (1 << 7));
/* 0x011C HDCP_LINK0_STATUS
[8] AN_0_READY
[9] AN_1_READY */
/* wait for an0 and an1 ready bits to be set in LINK0_STATUS */
mutex_lock(&hdcp_auth_state_mutex);
timeout_count = 100;
while (((HDMI_INP_ND(0x011C) & (0x3 << 8)) != (0x3 << 8))
&& timeout_count--)
msleep(20);
if (!timeout_count) {
ret = -ETIMEDOUT;
DEV_ERR("%s(%d): timedout, An0=%d, An1=%d\n",
__func__, __LINE__,
(HDMI_INP_ND(0x011C) & BIT(8)) >> 8,
(HDMI_INP_ND(0x011C) & BIT(9)) >> 9);
mutex_unlock(&hdcp_auth_state_mutex);
goto error;
}
/* 0x0168 HDCP_RCVPORT_DATA12
[23:8] BSTATUS
[7:0] BCAPS */
HDMI_OUTP(0x0168, bcaps);
/* 0x014C HDCP_RCVPORT_DATA5
[31:0] LINK0_AN_0 */
/* read an0 calculation */
link0_an_0 = HDMI_INP(0x014C);
/* 0x0150 HDCP_RCVPORT_DATA6
[31:0] LINK0_AN_1 */
/* read an1 calculation */
link0_an_1 = HDMI_INP(0x0150);
mutex_unlock(&hdcp_auth_state_mutex);
/* three bits 28..30 */
hdcp_key_state((HDMI_INP(0x011C) >> 28) & 0x7);
/* 0x0144 HDCP_RCVPORT_DATA3
[31:0] LINK0_AKSV_0 public key
0x0148 HDCP_RCVPORT_DATA4
[15:8] LINK0_AINFO
[7:0] LINK0_AKSV_1 public key */
link0_aksv_0 = HDMI_INP(0x0144);
link0_aksv_1 = HDMI_INP(0x0148);
/* copy an and aksv to byte arrays for transmission */
aksv[0] = link0_aksv_0 & 0xFF;
aksv[1] = (link0_aksv_0 >> 8) & 0xFF;
aksv[2] = (link0_aksv_0 >> 16) & 0xFF;
aksv[3] = (link0_aksv_0 >> 24) & 0xFF;
aksv[4] = link0_aksv_1 & 0xFF;
an[0] = link0_an_0 & 0xFF;
an[1] = (link0_an_0 >> 8) & 0xFF;
an[2] = (link0_an_0 >> 16) & 0xFF;
an[3] = (link0_an_0 >> 24) & 0xFF;
an[4] = link0_an_1 & 0xFF;
an[5] = (link0_an_1 >> 8) & 0xFF;
an[6] = (link0_an_1 >> 16) & 0xFF;
an[7] = (link0_an_1 >> 24) & 0xFF;
/* Write An 8 bytes to offset 0x18 */
ret = hdmi_msm_ddc_write(0x74, 0x18, an, 8, "An");
if (ret) {
DEV_ERR("%s(%d): Write An failed", __func__, __LINE__);
goto error;
}
/* Write Aksv 5 bytes to offset 0x10 */
ret = hdmi_msm_ddc_write(0x74, 0x10, aksv, 5, "Aksv");
if (ret) {
DEV_ERR("%s(%d): Write Aksv failed", __func__,
__LINE__);
goto error;
}
DEV_DBG("HDCP: Link0-AKSV=%02x%08x\n",
link0_aksv_1 & 0xFF, link0_aksv_0);
/* Read Bksv 5 bytes at 0x00 in HDCP port */
ret = hdmi_msm_ddc_read(0x74, 0x00, bksv, 5, 5, "Bksv", TRUE);
if (ret) {
DEV_ERR("%s(%d): Read BKSV failed", __func__, __LINE__);
goto error;
}
/* check there are 20 ones in BKSV */
if (hdmi_msm_count_one(bksv, 5) != 20) {
DEV_ERR("HDCP: BKSV read from Sink doesn't have "
"20 1's and 20 0's, FAIL (BKSV="
"%02x%02x%02x%02x%02x)\n",
bksv[4], bksv[3], bksv[2], bksv[1], bksv[0]);
ret = -EINVAL;
goto error;
}
link0_bksv_0 = bksv[3];
link0_bksv_0 = (link0_bksv_0 << 8) | bksv[2];
link0_bksv_0 = (link0_bksv_0 << 8) | bksv[1];
link0_bksv_0 = (link0_bksv_0 << 8) | bksv[0];
link0_bksv_1 = bksv[4];
DEV_DBG("HDCP: BKSV=%02x%08x\n", link0_bksv_1, link0_bksv_0);
/* 0x0134 HDCP_RCVPORT_DATA0
[31:0] LINK0_BKSV_0 */
HDMI_OUTP(0x0134, link0_bksv_0);
/* 0x0138 HDCP_RCVPORT_DATA1
[31:0] LINK0_BKSV_1 */
HDMI_OUTP(0x0138, link0_bksv_1);
DEV_DBG("HDCP: Link0-BKSV=%02x%08x\n", link0_bksv_1,
link0_bksv_0);
/* HDMI_HPD_INT_STATUS[0x0250] */
hpd_int_status = HDMI_INP_ND(0x0250);
/* HDMI_HPD_INT_CTRL[0x0254] */
hpd_int_ctrl = HDMI_INP_ND(0x0254);
DEV_DBG("[SR-DEUG]: HPD_INTR_CTRL=[%u] HPD_INTR_STATUS=[%u] "
"before reading R0'\n", hpd_int_ctrl, hpd_int_status);
/*
* HDCP Compliace Test case 1B-01:
* Wait here until all the ksv bytes have been
* read from the KSV FIFO register.
*/
msleep(125);
/* Reading R0' 2 bytes at offset 0x08 */
ret = hdmi_msm_ddc_read(0x74, 0x08, buf, 2, 5, "RO'", TRUE);
if (ret) {
DEV_ERR("%s(%d): Read RO's failed", __func__,
__LINE__);
goto error;
}
DEV_DBG("HDCP: R0'=%02x%02x\n", buf[1], buf[0]);
INIT_COMPLETION(hdmi_msm_state->hdcp_success_done);
/* 0x013C HDCP_RCVPORT_DATA2_0
[15:0] LINK0_RI */
HDMI_OUTP(0x013C, (((uint32)buf[1]) << 8) | buf[0]);
timeout_count = wait_for_completion_interruptible_timeout(
&hdmi_msm_state->hdcp_success_done, HZ*2);
if (!timeout_count) {
ret = -ETIMEDOUT;
is_match = HDMI_INP(0x011C) & BIT(12);
DEV_ERR("%s(%d): timedout, Link0=<%s>\n", __func__,
__LINE__,
is_match ? "RI_MATCH" : "No RI Match INTR in time");
if (!is_match)
goto error;
}
/* 0x011C HDCP_LINK0_STATUS
[12] RI_MATCHES [0] MISMATCH, [1] MATCH
[0] AUTH_SUCCESS */
/* Checking for RI, R0 Match */
/* RI_MATCHES */
if ((HDMI_INP(0x011C) & BIT(12)) != BIT(12)) {
ret = -EINVAL;
DEV_ERR("%s: HDCP_LINK0_STATUS[RI_MATCHES]: MISMATCH\n",
__func__);
goto error;
}
/* Enable HDCP Encryption */
HDMI_OUTP(0x0110, BIT(0) | BIT(8));
DEV_INFO("HDCP: authentication part I, successful\n");
is_part1_done = FALSE;
return 0;
error:
DEV_ERR("[%s]: HDCP Reauthentication\n", __func__);
is_part1_done = FALSE;
return ret;
} else {
return 1;
}
}
static int hdmi_msm_transfer_v_h(void)
{
/* Read V'.HO 4 Byte at offset 0x20 */
char what[20];
int ret;
uint8 buf[4];
if (!hdmi_msm_state->hdcp_enable) {
DEV_DBG("%s: HDCP not enabled\n", __func__);
return 0;
}
snprintf(what, sizeof(what), "V' H0");
ret = hdmi_msm_ddc_read(0x74, 0x20, buf, 4, 5, what, TRUE);
if (ret) {
DEV_ERR("%s: Read %s failed", __func__, what);
return ret;
}
DEV_DBG("buf[0]= %x , buf[1] = %x , buf[2] = %x , buf[3] = %x\n ",
buf[0] , buf[1] , buf[2] , buf[3]);
/* 0x0154 HDCP_RCVPORT_DATA7
[31:0] V_HO */
HDMI_OUTP(0x0154 ,
(buf[3] << 24 | buf[2] << 16 | buf[1] << 8 | buf[0]));
snprintf(what, sizeof(what), "V' H1");
ret = hdmi_msm_ddc_read(0x74, 0x24, buf, 4, 5, what, TRUE);
if (ret) {
DEV_ERR("%s: Read %s failed", __func__, what);
return ret;
}
DEV_DBG("buf[0]= %x , buf[1] = %x , buf[2] = %x , buf[3] = %x\n ",
buf[0] , buf[1] , buf[2] , buf[3]);
/* 0x0158 HDCP_RCVPORT_ DATA8
[31:0] V_H1 */
HDMI_OUTP(0x0158,
(buf[3] << 24 | buf[2] << 16 | buf[1] << 8 | buf[0]));
snprintf(what, sizeof(what), "V' H2");
ret = hdmi_msm_ddc_read(0x74, 0x28, buf, 4, 5, what, TRUE);
if (ret) {
DEV_ERR("%s: Read %s failed", __func__, what);
return ret;
}
DEV_DBG("buf[0]= %x , buf[1] = %x , buf[2] = %x , buf[3] = %x\n ",
buf[0] , buf[1] , buf[2] , buf[3]);
/* 0x015c HDCP_RCVPORT_DATA9
[31:0] V_H2 */
HDMI_OUTP(0x015c ,
(buf[3] << 24 | buf[2] << 16 | buf[1] << 8 | buf[0]));
snprintf(what, sizeof(what), "V' H3");
ret = hdmi_msm_ddc_read(0x74, 0x2c, buf, 4, 5, what, TRUE);
if (ret) {
DEV_ERR("%s: Read %s failed", __func__, what);
return ret;
}
DEV_DBG("buf[0]= %x , buf[1] = %x , buf[2] = %x , buf[3] = %x\n ",
buf[0] , buf[1] , buf[2] , buf[3]);
/* 0x0160 HDCP_RCVPORT_DATA10
[31:0] V_H3 */
HDMI_OUTP(0x0160,
(buf[3] << 24 | buf[2] << 16 | buf[1] << 8 | buf[0]));
snprintf(what, sizeof(what), "V' H4");
ret = hdmi_msm_ddc_read(0x74, 0x30, buf, 4, 5, what, TRUE);
if (ret) {
DEV_ERR("%s: Read %s failed", __func__, what);
return ret;
}
DEV_DBG("buf[0]= %x , buf[1] = %x , buf[2] = %x , buf[3] = %x\n ",
buf[0] , buf[1] , buf[2] , buf[3]);
/* 0x0164 HDCP_RCVPORT_DATA11
[31:0] V_H4 */
HDMI_OUTP(0x0164,
(buf[3] << 24 | buf[2] << 16 | buf[1] << 8 | buf[0]));
return 0;
}
static int hdcp_authentication_part2(void)
{
int ret = 0;
uint32 timeout_count;
int i = 0;
int cnt = 0;
uint bstatus;
uint8 bcaps;
uint32 down_stream_devices;
uint32 ksv_bytes;
static uint8 buf[0xFF];
static uint8 kvs_fifo[5 * 127];
boolean max_devs_exceeded = 0;
boolean max_cascade_exceeded = 0;
boolean ksv_done = FALSE;
if (!hdmi_msm_state->hdcp_enable) {
DEV_DBG("%s: HDCP not enabled\n", __func__);
return 0;
}
memset(buf, 0, sizeof(buf));
memset(kvs_fifo, 0, sizeof(kvs_fifo));
/* wait until READY bit is set in bcaps */
timeout_count = 50;
do {
timeout_count--;
/* read bcaps 1 Byte at offset 0x40 */
ret = hdmi_msm_ddc_read(0x74, 0x40, &bcaps, 1, 1,
"Bcaps", FALSE);
if (ret) {
DEV_ERR("%s(%d): Read Bcaps failed", __func__,
__LINE__);
goto error;
}
msleep(100);
} while ((0 == (bcaps & 0x20)) && timeout_count); /* READY (Bit 5) */
if (!timeout_count) {
ret = -ETIMEDOUT;
DEV_ERR("%s:timedout(1)", __func__);
goto error;
}
/* read bstatus 2 bytes at offset 0x41 */
ret = hdmi_msm_ddc_read(0x74, 0x41, buf, 2, 5, "Bstatus", FALSE);
if (ret) {
DEV_ERR("%s(%d): Read Bstatus failed", __func__, __LINE__);
goto error;
}
bstatus = buf[1];
bstatus = (bstatus << 8) | buf[0];
/* 0x0168 DCP_RCVPORT_DATA12
[7:0] BCAPS
[23:8 BSTATUS */
HDMI_OUTP(0x0168, bcaps | (bstatus << 8));
/* BSTATUS [6:0] DEVICE_COUNT Number of HDMI device attached to repeater
* - see HDCP spec */
down_stream_devices = bstatus & 0x7F;
if (down_stream_devices == 0x0) {
/* There isn't any devices attaced to the Repeater */
DEV_ERR("%s: there isn't any devices attached to the "
"Repeater\n", __func__);
ret = -EINVAL;
goto error;
}
/*
* HDCP Compliance 1B-05:
* Check if no. of devices connected to repeater
* exceed max_devices_connected from bit 7 of Bstatus.
*/
max_devs_exceeded = (bstatus & 0x80) >> 7;
if (max_devs_exceeded == 0x01) {
DEV_ERR("%s: Number of devs connected to repeater "
"exceeds max_devs\n", __func__);
ret = -EINVAL;
goto hdcp_error;
}
/*
* HDCP Compliance 1B-06:
* Check if no. of cascade connected to repeater
* exceed max_cascade_connected from bit 11 of Bstatus.
*/
max_cascade_exceeded = (bstatus & 0x800) >> 11;
if (max_cascade_exceeded == 0x01) {
DEV_ERR("%s: Number of cascade connected to repeater "
"exceeds max_cascade\n", __func__);
ret = -EINVAL;
goto hdcp_error;
}
/* Read KSV FIFO over DDC
* Key Slection vector FIFO
* Used to pull downstream KSVs from HDCP Repeaters.
* All bytes (DEVICE_COUNT * 5) must be read in a single,
* auto incrementing access.
* All bytes read as 0x00 for HDCP Receivers that are not
* HDCP Repeaters (REPEATER == 0). */
ksv_bytes = 5 * down_stream_devices;
/* Reading KSV FIFO / KSV FIFO */
ksv_done = FALSE;
ret = hdmi_msm_ddc_read(0x74, 0x43, kvs_fifo, ksv_bytes, 5,
"KSV FIFO", TRUE);
do {
if (ret) {
DEV_ERR("%s(%d): Read KSV FIFO failed",
__func__, __LINE__);
/*
* HDCP Compliace Test case 1B-01:
* Wait here until all the ksv bytes have been
* read from the KSV FIFO register.
*/
msleep(25);
} else {
ksv_done = TRUE;
}
cnt++;
} while (!ksv_done && cnt != 20);
if (ksv_done == FALSE)
goto error;
ret = hdmi_msm_transfer_v_h();
if (ret)
goto error;
/* Next: Write KSV FIFO to HDCP_SHA_DATA.
* This is done 1 byte at time starting with the LSB.
* On the very last byte write,
* the HDCP_SHA_DATA_DONE bit[0]
*/
/* 0x023C HDCP_SHA_CTRL
[0] RESET [0] Enable, [1] Reset
[4] SELECT [0] DIGA_HDCP, [1] DIGB_HDCP */
/* reset SHA engine */
HDMI_OUTP(0x023C, 1);
/* enable SHA engine, SEL=DIGA_HDCP */
HDMI_OUTP(0x023C, 0);
for (i = 0; i < ksv_bytes - 1; i++) {
/* Write KSV byte and do not set DONE bit[0] */
HDMI_OUTP_ND(0x0244, kvs_fifo[i] << 16);
/* Once 64 bytes have been written, we need to poll for
* HDCP_SHA_BLOCK_DONE before writing any further
*/
if (i && !((i+1)%64)) {
timeout_count = 100;
while (!(HDMI_INP_ND(0x0240) & 0x1)
&& (--timeout_count)) {
DEV_DBG("HDCP Auth Part II: Waiting for the "
"computation of the current 64 byte to "
"complete. HDCP_SHA_STATUS=%08x. "
"timeout_count=%d\n",
HDMI_INP_ND(0x0240), timeout_count);
msleep(20);
}
if (!timeout_count) {
ret = -ETIMEDOUT;
DEV_ERR("%s(%d): timedout", __func__, __LINE__);
goto error;
}
}
}
/* Write l to DONE bit[0] */
HDMI_OUTP_ND(0x0244, (kvs_fifo[ksv_bytes - 1] << 16) | 0x1);
/* 0x0240 HDCP_SHA_STATUS
[4] COMP_DONE */
/* Now wait for HDCP_SHA_COMP_DONE */
timeout_count = 100;
while ((0x10 != (HDMI_INP_ND(0x0240) & 0xFFFFFF10)) && --timeout_count)
msleep(20);
if (!timeout_count) {
ret = -ETIMEDOUT;
DEV_ERR("%s(%d): timedout", __func__, __LINE__);
goto error;
}
/* 0x011C HDCP_LINK0_STATUS
[20] V_MATCHES */
timeout_count = 100;
while (((HDMI_INP_ND(0x011C) & (1 << 20)) != (1 << 20))
&& --timeout_count) {
msleep(20);
}
if (!timeout_count) {
ret = -ETIMEDOUT;
DEV_ERR("%s(%d): timedout", __func__, __LINE__);
goto error;
}
DEV_INFO("HDCP: authentication part II, successful\n");
hdcp_error:
error:
return ret;
}
static int hdcp_authentication_part3(uint32 found_repeater)
{
int ret = 0;
int poll = 3000;
if (!hdmi_msm_state->hdcp_enable) {
DEV_DBG("%s: HDCP not enabled\n", __func__);
return 0;
}
while (poll) {
/* 0x011C HDCP_LINK0_STATUS
[30:28] KEYS_STATE = 3 = "Valid"
[24] RO_COMPUTATION_DONE [0] Not Done, [1] Done
[20] V_MATCHES [0] Mismtach, [1] Match
[12] RI_MATCHES [0] Mismatch, [1] Match
[0] AUTH_SUCCESS */
if (HDMI_INP_ND(0x011C) != (0x31001001 |
(found_repeater << 20))) {
DEV_ERR("HDCP: autentication part III, FAILED, "
"Link Status=%08x\n", HDMI_INP(0x011C));
ret = -EINVAL;
goto error;
}
poll--;
}
DEV_INFO("HDCP: authentication part III, successful\n");
error:
return ret;
}
static void hdmi_msm_hdcp_enable(void)
{
int ret = 0;
uint8 bcaps;
uint32 found_repeater = 0x0;
char *envp[2];
if (!hdmi_msm_state->hdcp_enable) {
DEV_INFO("%s: HDCP NOT ENABLED\n", __func__);
return;
}
mutex_lock(&hdmi_msm_state_mutex);
hdmi_msm_state->hdcp_activating = TRUE;
mutex_unlock(&hdmi_msm_state_mutex);
fill_black_screen();
mutex_lock(&hdcp_auth_state_mutex);
/* This flag prevents other threads from re-authenticating
* after we've just authenticated (i.e., finished part3)
* We probably need to protect this in a mutex lock */
hdmi_msm_state->full_auth_done = FALSE;
mutex_unlock(&hdcp_auth_state_mutex);
/* Disable HDCP before we start part1 */
HDMI_OUTP(0x0110, 0x0);
/* PART I Authentication*/
ret = hdcp_authentication_part1();
if (ret)
goto error;
/* PART II Authentication*/
/* read Bcaps at 0x40 in HDCP Port */
ret = hdmi_msm_ddc_read(0x74, 0x40, &bcaps, 1, 5, "Bcaps", FALSE);
if (ret) {
DEV_ERR("%s(%d): Read Bcaps failed\n", __func__, __LINE__);
goto error;
}
DEV_DBG("HDCP: Bcaps=0x%02x (%s)\n", bcaps,
(bcaps & BIT(6)) ? "repeater" : "no repeater");
/* if REPEATER (Bit 6), perform Part2 Authentication */
if (bcaps & BIT(6)) {
found_repeater = 0x1;
ret = hdcp_authentication_part2();
if (ret)
goto error;
} else
DEV_INFO("HDCP: authentication part II skipped, no repeater\n");
/* PART III Authentication*/
ret = hdcp_authentication_part3(found_repeater);
if (ret)
goto error;
unfill_black_screen();
mutex_lock(&hdmi_msm_state_mutex);
hdmi_msm_state->hdcp_activating = FALSE;
mutex_unlock(&hdmi_msm_state_mutex);
mutex_lock(&hdcp_auth_state_mutex);
/*
* This flag prevents other threads from re-authenticating
* after we've just authenticated (i.e., finished part3)
*/
hdmi_msm_state->full_auth_done = TRUE;
external_common_state->hdcp_active = TRUE;
mutex_unlock(&hdcp_auth_state_mutex);
if (!hdmi_msm_is_dvi_mode()) {
DEV_INFO("HDMI HPD: sense : send HDCP_PASS\n");
envp[0] = "HDCP_STATE=PASS";
envp[1] = NULL;
kobject_uevent_env(external_common_state->uevent_kobj,
KOBJ_CHANGE, envp);
SWITCH_SET_HDMI_AUDIO(1, 0);
}
return;
error:
if (hdmi_msm_state->hpd_during_auth) {
DEV_WARN("Calling Deauthentication: HPD occured during "
"authentication from [%s]\n", __func__);
hdcp_deauthenticate();
mutex_lock(&hdcp_auth_state_mutex);
hdmi_msm_state->hpd_during_auth = FALSE;
mutex_unlock(&hdcp_auth_state_mutex);
} else {
DEV_WARN("[DEV_DBG]: Calling reauth from [%s]\n", __func__);
if (hdmi_msm_state->panel_power_on)
queue_work(hdmi_work_queue,
&hdmi_msm_state->hdcp_reauth_work);
}
mutex_lock(&hdmi_msm_state_mutex);
hdmi_msm_state->hdcp_activating = FALSE;
mutex_unlock(&hdmi_msm_state_mutex);
}
static void hdmi_msm_video_setup(int video_format)
{
uint32 total_v = 0;
uint32 total_h = 0;
uint32 start_h = 0;
uint32 end_h = 0;
uint32 start_v = 0;
uint32 end_v = 0;
const struct hdmi_disp_mode_timing_type *timing =
hdmi_common_get_supported_mode(video_format);
/* timing register setup */
if (timing == NULL) {
DEV_ERR("video format not supported: %d\n", video_format);
return;
}
/* Hsync Total and Vsync Total */
total_h = timing->active_h + timing->front_porch_h
+ timing->back_porch_h + timing->pulse_width_h - 1;
total_v = timing->active_v + timing->front_porch_v
+ timing->back_porch_v + timing->pulse_width_v - 1;
/* 0x02C0 HDMI_TOTAL
[27:16] V_TOTAL Vertical Total
[11:0] H_TOTAL Horizontal Total */
HDMI_OUTP(0x02C0, ((total_v << 16) & 0x0FFF0000)
| ((total_h << 0) & 0x00000FFF));
/* Hsync Start and Hsync End */
start_h = timing->back_porch_h + timing->pulse_width_h;
end_h = (total_h + 1) - timing->front_porch_h;
/* 0x02B4 HDMI_ACTIVE_H
[27:16] END Horizontal end
[11:0] START Horizontal start */
HDMI_OUTP(0x02B4, ((end_h << 16) & 0x0FFF0000)
| ((start_h << 0) & 0x00000FFF));
start_v = timing->back_porch_v + timing->pulse_width_v - 1;
end_v = total_v - timing->front_porch_v;
/* 0x02B8 HDMI_ACTIVE_V
[27:16] END Vertical end
[11:0] START Vertical start */
HDMI_OUTP(0x02B8, ((end_v << 16) & 0x0FFF0000)
| ((start_v << 0) & 0x00000FFF));
if (timing->interlaced) {
/* 0x02C4 HDMI_V_TOTAL_F2
[11:0] V_TOTAL_F2 Vertical total for field2 */
HDMI_OUTP(0x02C4, ((total_v + 1) << 0) & 0x00000FFF);
/* 0x02BC HDMI_ACTIVE_V_F2
[27:16] END_F2 Vertical end for field2
[11:0] START_F2 Vertical start for Field2 */
HDMI_OUTP(0x02BC,
(((start_v + 1) << 0) & 0x00000FFF)
| (((end_v + 1) << 16) & 0x0FFF0000));
} else {
/* HDMI_V_TOTAL_F2 */
HDMI_OUTP(0x02C4, 0);
/* HDMI_ACTIVE_V_F2 */
HDMI_OUTP(0x02BC, 0);
}
hdmi_frame_ctrl_cfg(timing);
}
struct hdmi_msm_audio_acr {
uint32 n; /* N parameter for clock regeneration */
uint32 cts; /* CTS parameter for clock regeneration */
};
struct hdmi_msm_audio_arcs {
uint32 pclk;
struct hdmi_msm_audio_acr lut[MSM_HDMI_SAMPLE_RATE_MAX];
};
#define HDMI_MSM_AUDIO_ARCS(pclk, ...) { pclk, __VA_ARGS__ }
/* Audio constants lookup table for hdmi_msm_audio_acr_setup */
/* Valid Pixel-Clock rates: 25.2MHz, 27MHz, 27.03MHz, 74.25MHz, 148.5MHz */
static const struct hdmi_msm_audio_arcs hdmi_msm_audio_acr_lut[] = {
/* 25.200MHz */
HDMI_MSM_AUDIO_ARCS(25200, {
{4096, 25200}, {6272, 28000}, {6144, 25200}, {12544, 28000},
{12288, 25200}, {25088, 28000}, {24576, 25200} }),
/* 27.000MHz */
HDMI_MSM_AUDIO_ARCS(27000, {
{4096, 27000}, {6272, 30000}, {6144, 27000}, {12544, 30000},
{12288, 27000}, {25088, 30000}, {24576, 27000} }),
/* 27.027MHz */
HDMI_MSM_AUDIO_ARCS(27030, {
{4096, 27027}, {6272, 30030}, {6144, 27027}, {12544, 30030},
{12288, 27027}, {25088, 30030}, {24576, 27027} }),
/* 74.250MHz */
HDMI_MSM_AUDIO_ARCS(74250, {
{4096, 74250}, {6272, 82500}, {6144, 74250}, {12544, 82500},
{12288, 74250}, {25088, 82500}, {24576, 74250} }),
/* 148.500MHz */
HDMI_MSM_AUDIO_ARCS(148500, {
{4096, 148500}, {6272, 165000}, {6144, 148500}, {12544, 165000},
{12288, 148500}, {25088, 165000}, {24576, 148500} }),
};
static void hdmi_msm_audio_acr_setup(boolean enabled, int video_format,
int audio_sample_rate, int num_of_channels)
{
/* Read first before writing */
/* HDMI_ACR_PKT_CTRL[0x0024] */
uint32 acr_pck_ctrl_reg = HDMI_INP(0x0024);
if (enabled) {
const struct hdmi_disp_mode_timing_type *timing =
hdmi_common_get_supported_mode(video_format);
const struct hdmi_msm_audio_arcs *audio_arc =
&hdmi_msm_audio_acr_lut[0];
const int lut_size = sizeof(hdmi_msm_audio_acr_lut)
/sizeof(*hdmi_msm_audio_acr_lut);
uint32 i, n, cts, layout, multiplier, aud_pck_ctrl_2_reg;
if (timing == NULL) {
DEV_WARN("%s: video format %d not supported\n",
__func__, video_format);
return;
}
for (i = 0; i < lut_size;
audio_arc = &hdmi_msm_audio_acr_lut[++i]) {
if (audio_arc->pclk == timing->pixel_freq)
break;
}
if (i >= lut_size) {
DEV_WARN("%s: pixel clock %d not supported\n", __func__,
timing->pixel_freq);
return;
}
n = audio_arc->lut[audio_sample_rate].n;
cts = audio_arc->lut[audio_sample_rate].cts;
layout = (MSM_HDMI_AUDIO_CHANNEL_2 == num_of_channels) ? 0 : 1;
if ((MSM_HDMI_SAMPLE_RATE_192KHZ == audio_sample_rate) ||
(MSM_HDMI_SAMPLE_RATE_176_4KHZ == audio_sample_rate)) {
multiplier = 4;
n >>= 2; /* divide N by 4 and use multiplier */
} else if ((MSM_HDMI_SAMPLE_RATE_96KHZ == audio_sample_rate) ||
(MSM_HDMI_SAMPLE_RATE_88_2KHZ == audio_sample_rate)) {
multiplier = 2;
n >>= 1; /* divide N by 2 and use multiplier */
} else {
multiplier = 1;
}
DEV_DBG("%s: n=%u, cts=%u, layout=%u\n", __func__, n, cts,
layout);
/* AUDIO_PRIORITY | SOURCE */
acr_pck_ctrl_reg |= 0x80000100;
/* N_MULTIPLE(multiplier) */
acr_pck_ctrl_reg |= (multiplier & 7) << 16;
if ((MSM_HDMI_SAMPLE_RATE_48KHZ == audio_sample_rate) ||
(MSM_HDMI_SAMPLE_RATE_96KHZ == audio_sample_rate) ||
(MSM_HDMI_SAMPLE_RATE_192KHZ == audio_sample_rate)) {
/* SELECT(3) */
acr_pck_ctrl_reg |= 3 << 4;
/* CTS_48 */
cts <<= 12;
/* CTS: need to determine how many fractional bits */
/* HDMI_ACR_48_0 */
HDMI_OUTP(0x00D4, cts);
/* N */
/* HDMI_ACR_48_1 */
HDMI_OUTP(0x00D8, n);
} else if ((MSM_HDMI_SAMPLE_RATE_44_1KHZ == audio_sample_rate)
|| (MSM_HDMI_SAMPLE_RATE_88_2KHZ ==
audio_sample_rate)
|| (MSM_HDMI_SAMPLE_RATE_176_4KHZ ==
audio_sample_rate)) {
/* SELECT(2) */
acr_pck_ctrl_reg |= 2 << 4;
/* CTS_44 */
cts <<= 12;
/* CTS: need to determine how many fractional bits */
/* HDMI_ACR_44_0 */
HDMI_OUTP(0x00CC, cts);
/* N */
/* HDMI_ACR_44_1 */
HDMI_OUTP(0x00D0, n);
} else { /* default to 32k */
/* SELECT(1) */
acr_pck_ctrl_reg |= 1 << 4;
/* CTS_32 */
cts <<= 12;
/* CTS: need to determine how many fractional bits */
/* HDMI_ACR_32_0 */
HDMI_OUTP(0x00C4, cts);
/* N */
/* HDMI_ACR_32_1 */
HDMI_OUTP(0x00C8, n);
}
/* Payload layout depends on number of audio channels */
/* LAYOUT_SEL(layout) */
aud_pck_ctrl_2_reg = 1 | (layout << 1);
/* override | layout */
/* HDMI_AUDIO_PKT_CTRL2[0x00044] */
HDMI_OUTP(0x00044, aud_pck_ctrl_2_reg);
/* SEND | CONT */
acr_pck_ctrl_reg |= 0x00000003;
} else {
/* ~(SEND | CONT) */
acr_pck_ctrl_reg &= ~0x00000003;
}
/* HDMI_ACR_PKT_CTRL[0x0024] */
HDMI_OUTP(0x0024, acr_pck_ctrl_reg);
}
static void hdmi_msm_outpdw_chk(uint32 offset, uint32 data)
{
uint32 check, i = 0;
#ifdef DEBUG
HDMI_OUTP(offset, data);
#endif
do {
outpdw(MSM_HDMI_BASE+offset, data);
check = inpdw(MSM_HDMI_BASE+offset);
} while (check != data && i++ < 10);
if (check != data)
DEV_ERR("%s: failed addr=%08x, data=%x, check=%x",
__func__, offset, data, check);
}
static void hdmi_msm_rmw32or(uint32 offset, uint32 data)
{
uint32 reg_data;
reg_data = inpdw(MSM_HDMI_BASE+offset);
reg_data = inpdw(MSM_HDMI_BASE+offset);
hdmi_msm_outpdw_chk(offset, reg_data | data);
}
#define HDMI_AUDIO_CFG 0x01D0
#define HDMI_AUDIO_ENGINE_ENABLE 1
#define HDMI_AUDIO_FIFO_MASK 0x000000F0
#define HDMI_AUDIO_FIFO_WATERMARK_SHIFT 4
#define HDMI_AUDIO_FIFO_MAX_WATER_MARK 8
int hdmi_audio_enable(bool on , u32 fifo_water_mark)
{
u32 hdmi_audio_config;
hdmi_audio_config = HDMI_INP(HDMI_AUDIO_CFG);
if (on) {
if (fifo_water_mark > HDMI_AUDIO_FIFO_MAX_WATER_MARK) {
pr_err("%s : HDMI audio fifo water mark can not be more"
" than %u\n", __func__,
HDMI_AUDIO_FIFO_MAX_WATER_MARK);
return -EINVAL;
}
/*
* Enable HDMI Audio engine.
* MUST be enabled after Audio DMA is enabled.
*/
hdmi_audio_config &= ~(HDMI_AUDIO_FIFO_MASK);
hdmi_audio_config |= (HDMI_AUDIO_ENGINE_ENABLE |
(fifo_water_mark << HDMI_AUDIO_FIFO_WATERMARK_SHIFT));
} else
hdmi_audio_config &= ~(HDMI_AUDIO_ENGINE_ENABLE);
HDMI_OUTP(HDMI_AUDIO_CFG, hdmi_audio_config);
mb();
pr_info("%s :HDMI_AUDIO_CFG 0x%08x\n", __func__,
HDMI_INP(HDMI_AUDIO_CFG));
return 0;
}
EXPORT_SYMBOL(hdmi_audio_enable);
#define HDMI_AUDIO_PKT_CTRL 0x0020
#define HDMI_AUDIO_SAMPLE_SEND_ENABLE 1
int hdmi_audio_packet_enable(bool on)
{
u32 hdmi_audio_pkt_ctrl;
hdmi_audio_pkt_ctrl = HDMI_INP(HDMI_AUDIO_PKT_CTRL);
if (on)
hdmi_audio_pkt_ctrl |= HDMI_AUDIO_SAMPLE_SEND_ENABLE;
else
hdmi_audio_pkt_ctrl &= ~(HDMI_AUDIO_SAMPLE_SEND_ENABLE);
HDMI_OUTP(HDMI_AUDIO_PKT_CTRL, hdmi_audio_pkt_ctrl);
mb();
pr_info("%s : HDMI_AUDIO_PKT_CTRL 0x%08x\n", __func__,
HDMI_INP(HDMI_AUDIO_PKT_CTRL));
return 0;
}
EXPORT_SYMBOL(hdmi_audio_packet_enable);
/* TO-DO: return -EINVAL when num_of_channels and channel_allocation
* does not match CEA 861-D spec.
*/
int hdmi_msm_audio_info_setup(bool enabled, u32 num_of_channels,
u32 channel_allocation, u32 level_shift, bool down_mix)
{
uint32 channel_count = 1; /* Default to 2 channels
-> See Table 17 in CEA-D spec */
uint32 check_sum, audio_info_0_reg, audio_info_1_reg;
uint32 audio_info_ctrl_reg;
u32 aud_pck_ctrl_2_reg;
u32 layout;
layout = (MSM_HDMI_AUDIO_CHANNEL_2 == num_of_channels) ? 0 : 1;
aud_pck_ctrl_2_reg = 1 | (layout << 1);
HDMI_OUTP(0x00044, aud_pck_ctrl_2_reg);
/* Please see table 20 Audio InfoFrame in HDMI spec
FL = front left
FC = front Center
FR = front right
FLC = front left center
FRC = front right center
RL = rear left
RC = rear center
RR = rear right
RLC = rear left center
RRC = rear right center
LFE = low frequency effect
*/
/* Read first then write because it is bundled with other controls */
/* HDMI_INFOFRAME_CTRL0[0x002C] */
audio_info_ctrl_reg = HDMI_INP(0x002C);
if (enabled) {
switch (num_of_channels) {
case MSM_HDMI_AUDIO_CHANNEL_2:
channel_allocation = 0; /* Default to FR,FL */
break;
case MSM_HDMI_AUDIO_CHANNEL_4:
channel_count = 3;
/* FC,LFE,FR,FL */
channel_allocation = 0x3;
break;
case MSM_HDMI_AUDIO_CHANNEL_6:
channel_count = 5;
/* RR,RL,FC,LFE,FR,FL */
channel_allocation = 0xB;
break;
case MSM_HDMI_AUDIO_CHANNEL_8:
channel_count = 7;
/* FRC,FLC,RR,RL,FC,LFE,FR,FL */
channel_allocation = 0x1f;
break;
default:
pr_err("%s(): Unsupported num_of_channels = %u\n",
__func__, num_of_channels);
return -EINVAL;
break;
}
/* Program the Channel-Speaker allocation */
audio_info_1_reg = 0;
/* CA(channel_allocation) */
audio_info_1_reg |= channel_allocation & 0xff;
/* Program the Level shifter */
/* LSV(level_shift) */
audio_info_1_reg |= (level_shift << 11) & 0x00007800;
/* Program the Down-mix Inhibit Flag */
/* DM_INH(down_mix) */
audio_info_1_reg |= (down_mix << 15) & 0x00008000;
/* HDMI_AUDIO_INFO1[0x00E8] */
HDMI_OUTP(0x00E8, audio_info_1_reg);
/* Calculate CheckSum
Sum of all the bytes in the Audio Info Packet bytes
(See table 8.4 in HDMI spec) */
check_sum = 0;
/* HDMI_AUDIO_INFO_FRAME_PACKET_HEADER_TYPE[0x84] */
check_sum += 0x84;
/* HDMI_AUDIO_INFO_FRAME_PACKET_HEADER_VERSION[0x01] */
check_sum += 1;
/* HDMI_AUDIO_INFO_FRAME_PACKET_LENGTH[0x0A] */
check_sum += 0x0A;
check_sum += channel_count;
check_sum += channel_allocation;
/* See Table 8.5 in HDMI spec */
check_sum += (level_shift & 0xF) << 3 | (down_mix & 0x1) << 7;
check_sum &= 0xFF;
check_sum = (uint8) (256 - check_sum);
audio_info_0_reg = 0;
/* CHECKSUM(check_sum) */
audio_info_0_reg |= check_sum & 0xff;
/* CC(channel_count) */
audio_info_0_reg |= (channel_count << 8) & 0x00000700;
/* HDMI_AUDIO_INFO0[0x00E4] */
HDMI_OUTP(0x00E4, audio_info_0_reg);
/* Set these flags */
/* AUDIO_INFO_UPDATE | AUDIO_INFO_SOURCE | AUDIO_INFO_CONT
| AUDIO_INFO_SEND */
audio_info_ctrl_reg |= 0x000000F0;
} else {
/* Clear these flags */
/* ~(AUDIO_INFO_UPDATE | AUDIO_INFO_SOURCE | AUDIO_INFO_CONT
| AUDIO_INFO_SEND) */
audio_info_ctrl_reg &= ~0x000000F0;
}
/* HDMI_INFOFRAME_CTRL0[0x002C] */
HDMI_OUTP(0x002C, audio_info_ctrl_reg);
hdmi_msm_dump_regs("HDMI-AUDIO-ON: ");
return 0;
}
EXPORT_SYMBOL(hdmi_msm_audio_info_setup);
static void hdmi_msm_en_gc_packet(boolean av_mute_is_requested)
{
/* HDMI_GC[0x0040] */
HDMI_OUTP(0x0040, av_mute_is_requested ? 1 : 0);
/* GC packet enable (every frame) */
/* HDMI_VBI_PKT_CTRL[0x0028] */
hdmi_msm_rmw32or(0x0028, 3 << 4);
}
#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL_ISRC_ACP_SUPPORT
static void hdmi_msm_en_isrc_packet(boolean isrc_is_continued)
{
static const char isrc_psuedo_data[] =
"ISRC1:0123456789isrc2=ABCDEFGHIJ";
const uint32 * isrc_data = (const uint32 *) isrc_psuedo_data;
/* ISRC_STATUS =0b010 | ISRC_CONTINUE | ISRC_VALID */
/* HDMI_ISRC1_0[0x00048] */
HDMI_OUTP(0x00048, 2 | (isrc_is_continued ? 1 : 0) << 6 | 0 << 7);
/* HDMI_ISRC1_1[0x004C] */
HDMI_OUTP(0x004C, *isrc_data++);
/* HDMI_ISRC1_2[0x0050] */
HDMI_OUTP(0x0050, *isrc_data++);
/* HDMI_ISRC1_3[0x0054] */
HDMI_OUTP(0x0054, *isrc_data++);
/* HDMI_ISRC1_4[0x0058] */
HDMI_OUTP(0x0058, *isrc_data++);
/* HDMI_ISRC2_0[0x005C] */
HDMI_OUTP(0x005C, *isrc_data++);
/* HDMI_ISRC2_1[0x0060] */
HDMI_OUTP(0x0060, *isrc_data++);
/* HDMI_ISRC2_2[0x0064] */
HDMI_OUTP(0x0064, *isrc_data++);
/* HDMI_ISRC2_3[0x0068] */
HDMI_OUTP(0x0068, *isrc_data);
/* HDMI_VBI_PKT_CTRL[0x0028] */
/* ISRC Send + Continuous */
hdmi_msm_rmw32or(0x0028, 3 << 8);
}
#else
static void hdmi_msm_en_isrc_packet(boolean isrc_is_continued)
{
/*
* Until end-to-end support for various audio packets
*/
}
#endif
#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL_ISRC_ACP_SUPPORT
static void hdmi_msm_en_acp_packet(uint32 byte1)
{
/* HDMI_ACP[0x003C] */
HDMI_OUTP(0x003C, 2 | 1 << 8 | byte1 << 16);
/* HDMI_VBI_PKT_CTRL[0x0028] */
/* ACP send, s/w source */
hdmi_msm_rmw32or(0x0028, 3 << 12);
}
#else
static void hdmi_msm_en_acp_packet(uint32 byte1)
{
/*
* Until end-to-end support for various audio packets
*/
}
#endif
int hdmi_msm_audio_get_sample_rate(void)
{
return msm_hdmi_sample_rate;
}
EXPORT_SYMBOL(hdmi_msm_audio_get_sample_rate);
void hdmi_msm_audio_sample_rate_reset(int rate)
{
msm_hdmi_sample_rate = rate;
if (hdmi_msm_state->hdcp_enable)
hdcp_deauthenticate();
else
hdmi_msm_turn_on();
}
EXPORT_SYMBOL(hdmi_msm_audio_sample_rate_reset);
static void hdmi_msm_audio_setup(void)
{
const int channels = MSM_HDMI_AUDIO_CHANNEL_2;
/* (0) for clr_avmute, (1) for set_avmute */
hdmi_msm_en_gc_packet(0);
/* (0) for isrc1 only, (1) for isrc1 and isrc2 */
hdmi_msm_en_isrc_packet(1);
/* arbitrary bit pattern for byte1 */
hdmi_msm_en_acp_packet(0x5a);
DEV_DBG("Not setting ACP, ISRC1, ISRC2 packets\n");
hdmi_msm_audio_acr_setup(TRUE,
external_common_state->video_resolution,
msm_hdmi_sample_rate, channels);
hdmi_msm_audio_info_setup(TRUE, channels, 0, 0, FALSE);
/* Turn on Audio FIFO and SAM DROP ISR */
HDMI_OUTP(0x02CC, HDMI_INP(0x02CC) | BIT(1) | BIT(3));
DEV_INFO("HDMI Audio: Enabled\n");
}
static int hdmi_msm_audio_off(void)
{
uint32 audio_cfg;
int i, timeout_val = 50;
for (i = 0; (i < timeout_val) &&
((audio_cfg = HDMI_INP_ND(0x01D0)) & BIT(0)); i++) {
DEV_DBG("%s: %d times: AUDIO CFG is %08xi\n", __func__,
i+1, audio_cfg);
if (!((i+1) % 10)) {
DEV_ERR("%s: audio still on after %d sec. try again\n",
__func__, (i+1)/10);
SWITCH_SET_HDMI_AUDIO(0, 1);
}
msleep(100);
}
if (i == timeout_val)
DEV_ERR("%s: Error: cannot turn off audio engine\n", __func__);
hdmi_msm_audio_info_setup(FALSE, 0, 0, 0, FALSE);
hdmi_msm_audio_acr_setup(FALSE, 0, 0, 0);
DEV_INFO("HDMI Audio: Disabled\n");
return 0;
}
static uint8 hdmi_msm_avi_iframe_lut[][16] = {
/* 480p60 480i60 576p50 576i50 720p60 720p50 1080p60 1080i60 1080p50
1080i50 1080p24 1080p30 1080p25 640x480p 480p60_16_9 576p50_4_3 */
{0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10}, /*00*/
{0x18, 0x18, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28,
0x28, 0x28, 0x28, 0x28, 0x18, 0x28, 0x18}, /*01*/
{0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x04, 0x04, 0x04, 0x04, 0x88, 0x00, 0x04}, /*02*/
{0x02, 0x06, 0x11, 0x15, 0x04, 0x13, 0x10, 0x05, 0x1F,
0x14, 0x20, 0x22, 0x21, 0x01, 0x03, 0x11}, /*03*/
{0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*04*/
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*05*/
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*06*/
{0xE1, 0xE1, 0x41, 0x41, 0xD1, 0xd1, 0x39, 0x39, 0x39,
0x39, 0x39, 0x39, 0x39, 0xe1, 0xE1, 0x41}, /*07*/
{0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x04, 0x04, 0x04,
0x04, 0x04, 0x04, 0x04, 0x01, 0x01, 0x02}, /*08*/
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*09*/
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*10*/
{0xD1, 0xD1, 0xD1, 0xD1, 0x01, 0x01, 0x81, 0x81, 0x81,
0x81, 0x81, 0x81, 0x81, 0x81, 0xD1, 0xD1}, /*11*/
{0x02, 0x02, 0x02, 0x02, 0x05, 0x05, 0x07, 0x07, 0x07,
0x07, 0x07, 0x07, 0x07, 0x02, 0x02, 0x02} /*12*/
};
static void hdmi_msm_avi_info_frame(void)
{
/* two header + length + 13 data */
uint8 aviInfoFrame[16];
uint8 checksum;
uint32 sum;
uint32 regVal;
int i;
int mode = 0;
boolean use_ce_scan_info = TRUE;
switch (external_common_state->video_resolution) {
case HDMI_VFRMT_720x480p60_4_3:
mode = 0;
break;
case HDMI_VFRMT_720x480i60_16_9:
mode = 1;
break;
case HDMI_VFRMT_720x576p50_16_9:
mode = 2;
break;
case HDMI_VFRMT_720x576i50_16_9:
mode = 3;
break;
case HDMI_VFRMT_1280x720p60_16_9:
mode = 4;
break;
case HDMI_VFRMT_1280x720p50_16_9:
mode = 5;
break;
case HDMI_VFRMT_1920x1080p60_16_9:
mode = 6;
break;
case HDMI_VFRMT_1920x1080i60_16_9:
mode = 7;
break;
case HDMI_VFRMT_1920x1080p50_16_9:
mode = 8;
break;
case HDMI_VFRMT_1920x1080i50_16_9:
mode = 9;
break;
case HDMI_VFRMT_1920x1080p24_16_9:
mode = 10;
break;
case HDMI_VFRMT_1920x1080p30_16_9:
mode = 11;
break;
case HDMI_VFRMT_1920x1080p25_16_9:
mode = 12;
break;
case HDMI_VFRMT_640x480p60_4_3:
mode = 13;
break;
case HDMI_VFRMT_720x480p60_16_9:
mode = 14;
break;
case HDMI_VFRMT_720x576p50_4_3:
mode = 15;
break;
default:
DEV_INFO("%s: mode %d not supported\n", __func__,
external_common_state->video_resolution);
return;
}
/* InfoFrame Type = 82 */
aviInfoFrame[0] = 0x82;
/* Version = 2 */
aviInfoFrame[1] = 2;
/* Length of AVI InfoFrame = 13 */
aviInfoFrame[2] = 13;
/* Data Byte 01: 0 Y1 Y0 A0 B1 B0 S1 S0 */
aviInfoFrame[3] = hdmi_msm_avi_iframe_lut[0][mode];
/*
* If the sink specified support for both underscan/overscan
* then, by default, set the underscan bit.
* Only checking underscan support for preferred format and cea formats
*/
if ((external_common_state->video_resolution ==
external_common_state->preferred_video_format)) {
use_ce_scan_info = FALSE;
switch (external_common_state->pt_scan_info) {
case 0:
/*
* Need to use the info specified for the corresponding
* IT or CE format
*/
DEV_DBG("%s: No underscan information specified for the"
" preferred video format\n", __func__);
use_ce_scan_info = TRUE;
break;
case 3:
DEV_DBG("%s: Setting underscan bit for the preferred"
" video format\n", __func__);
aviInfoFrame[3] |= 0x02;
break;
default:
DEV_DBG("%s: Underscan information not set for the"
" preferred video format\n", __func__);
break;
}
}
if (use_ce_scan_info) {
if (3 == external_common_state->ce_scan_info) {
DEV_DBG("%s: Setting underscan bit for the CE video"
" format\n", __func__);
aviInfoFrame[3] |= 0x02;
} else {
DEV_DBG("%s: Not setting underscan bit for the CE video"
" format\n", __func__);
}
}
/* Data Byte 02: C1 C0 M1 M0 R3 R2 R1 R0 */
aviInfoFrame[4] = hdmi_msm_avi_iframe_lut[1][mode];
/* Data Byte 03: ITC EC2 EC1 EC0 Q1 Q0 SC1 SC0 */
aviInfoFrame[5] = hdmi_msm_avi_iframe_lut[2][mode];
/* Data Byte 04: 0 VIC6 VIC5 VIC4 VIC3 VIC2 VIC1 VIC0 */
aviInfoFrame[6] = hdmi_msm_avi_iframe_lut[3][mode];
/* Data Byte 05: 0 0 0 0 PR3 PR2 PR1 PR0 */
aviInfoFrame[7] = hdmi_msm_avi_iframe_lut[4][mode];
/* Data Byte 06: LSB Line No of End of Top Bar */
aviInfoFrame[8] = hdmi_msm_avi_iframe_lut[5][mode];
/* Data Byte 07: MSB Line No of End of Top Bar */
aviInfoFrame[9] = hdmi_msm_avi_iframe_lut[6][mode];
/* Data Byte 08: LSB Line No of Start of Bottom Bar */
aviInfoFrame[10] = hdmi_msm_avi_iframe_lut[7][mode];
/* Data Byte 09: MSB Line No of Start of Bottom Bar */
aviInfoFrame[11] = hdmi_msm_avi_iframe_lut[8][mode];
/* Data Byte 10: LSB Pixel Number of End of Left Bar */
aviInfoFrame[12] = hdmi_msm_avi_iframe_lut[9][mode];
/* Data Byte 11: MSB Pixel Number of End of Left Bar */
aviInfoFrame[13] = hdmi_msm_avi_iframe_lut[10][mode];
/* Data Byte 12: LSB Pixel Number of Start of Right Bar */
aviInfoFrame[14] = hdmi_msm_avi_iframe_lut[11][mode];
/* Data Byte 13: MSB Pixel Number of Start of Right Bar */
aviInfoFrame[15] = hdmi_msm_avi_iframe_lut[12][mode];
sum = 0;
for (i = 0; i < 16; i++)
sum += aviInfoFrame[i];
sum &= 0xFF;
sum = 256 - sum;
checksum = (uint8) sum;
regVal = aviInfoFrame[5];
regVal = regVal << 8 | aviInfoFrame[4];
regVal = regVal << 8 | aviInfoFrame[3];
regVal = regVal << 8 | checksum;
HDMI_OUTP(0x006C, regVal);
regVal = aviInfoFrame[9];
regVal = regVal << 8 | aviInfoFrame[8];
regVal = regVal << 8 | aviInfoFrame[7];
regVal = regVal << 8 | aviInfoFrame[6];
HDMI_OUTP(0x0070, regVal);
regVal = aviInfoFrame[13];
regVal = regVal << 8 | aviInfoFrame[12];
regVal = regVal << 8 | aviInfoFrame[11];
regVal = regVal << 8 | aviInfoFrame[10];
HDMI_OUTP(0x0074, regVal);
regVal = aviInfoFrame[1];
regVal = regVal << 16 | aviInfoFrame[15];
regVal = regVal << 8 | aviInfoFrame[14];
HDMI_OUTP(0x0078, regVal);
/* INFOFRAME_CTRL0[0x002C] */
/* 0x3 for AVI InfFrame enable (every frame) */
HDMI_OUTP(0x002C, HDMI_INP(0x002C) | 0x00000003L);
}
#ifdef CONFIG_FB_MSM_HDMI_3D
static void hdmi_msm_vendor_infoframe_packetsetup(void)
{
uint32 packet_header = 0;
uint32 check_sum = 0;
uint32 packet_payload = 0;
if (!external_common_state->format_3d) {
HDMI_OUTP(0x0034, 0);
return;
}
/* 0x0084 GENERIC0_HDR
* HB0 7:0 NUM
* HB1 15:8 NUM
* HB2 23:16 NUM */
/* Setup Packet header and payload */
/* 0x81 VS_INFO_FRAME_ID
0x01 VS_INFO_FRAME_VERSION
0x1B VS_INFO_FRAME_PAYLOAD_LENGTH */
packet_header = 0x81 | (0x01 << 8) | (0x1B << 16);
HDMI_OUTP(0x0084, packet_header);
check_sum = packet_header & 0xff;
check_sum += (packet_header >> 8) & 0xff;
check_sum += (packet_header >> 16) & 0xff;
/* 0x008C GENERIC0_1
* BYTE4 7:0 NUM
* BYTE5 15:8 NUM
* BYTE6 23:16 NUM
* BYTE7 31:24 NUM */
/* 0x02 VS_INFO_FRAME_3D_PRESENT */
packet_payload = 0x02 << 5;
switch (external_common_state->format_3d) {
case 1:
/* 0b1000 VIDEO_3D_FORMAT_SIDE_BY_SIDE_HALF */
packet_payload |= (0x08 << 8) << 4;
break;
case 2:
/* 0b0110 VIDEO_3D_FORMAT_TOP_AND_BOTTOM_HALF */
packet_payload |= (0x06 << 8) << 4;
break;
}
HDMI_OUTP(0x008C, packet_payload);
check_sum += packet_payload & 0xff;
check_sum += (packet_payload >> 8) & 0xff;
#define IEEE_REGISTRATION_ID 0xC03
/* Next 3 bytes are IEEE Registration Identifcation */
/* 0x0088 GENERIC0_0
* BYTE0 7:0 NUM (checksum)
* BYTE1 15:8 NUM
* BYTE2 23:16 NUM
* BYTE3 31:24 NUM */
check_sum += IEEE_REGISTRATION_ID & 0xff;
check_sum += (IEEE_REGISTRATION_ID >> 8) & 0xff;
check_sum += (IEEE_REGISTRATION_ID >> 16) & 0xff;
HDMI_OUTP(0x0088, (0x100 - (0xff & check_sum))
| ((IEEE_REGISTRATION_ID & 0xff) << 8)
| (((IEEE_REGISTRATION_ID >> 8) & 0xff) << 16)
| (((IEEE_REGISTRATION_ID >> 16) & 0xff) << 24));
/* 0x0034 GEN_PKT_CTRL
* GENERIC0_SEND 0 0 = Disable Generic0 Packet Transmission
* 1 = Enable Generic0 Packet Transmission
* GENERIC0_CONT 1 0 = Send Generic0 Packet on next frame only
* 1 = Send Generic0 Packet on every frame
* GENERIC0_UPDATE 2 NUM
* GENERIC1_SEND 4 0 = Disable Generic1 Packet Transmission
* 1 = Enable Generic1 Packet Transmission
* GENERIC1_CONT 5 0 = Send Generic1 Packet on next frame only
* 1 = Send Generic1 Packet on every frame
* GENERIC0_LINE 21:16 NUM
* GENERIC1_LINE 29:24 NUM
*/
/* GENERIC0_LINE | GENERIC0_UPDATE | GENERIC0_CONT | GENERIC0_SEND
* Setup HDMI TX generic packet control
* Enable this packet to transmit every frame
* Enable this packet to transmit every frame
* Enable HDMI TX engine to transmit Generic packet 0 */
HDMI_OUTP(0x0034, (1 << 16) | (1 << 2) | BIT(1) | BIT(0));
}
static void hdmi_msm_switch_3d(boolean on)
{
mutex_lock(&external_common_state_hpd_mutex);
if (external_common_state->hpd_state)
hdmi_msm_vendor_infoframe_packetsetup();
mutex_unlock(&external_common_state_hpd_mutex);
}
#endif
#define IFRAME_CHECKSUM_32(d) \
((d & 0xff) + ((d >> 8) & 0xff) + \
((d >> 16) & 0xff) + ((d >> 24) & 0xff))
static void hdmi_msm_spd_infoframe_packetsetup(void)
{
uint32 packet_header = 0;
uint32 check_sum = 0;
uint32 packet_payload = 0;
uint32 packet_control = 0;
uint8 *vendor_name = external_common_state->spd_vendor_name;
uint8 *product_description =
external_common_state->spd_product_description;
/* 0x00A4 GENERIC1_HDR
* HB0 7:0 NUM
* HB1 15:8 NUM
* HB2 23:16 NUM */
/* Setup Packet header and payload */
/* 0x83 InfoFrame Type Code
0x01 InfoFrame Version Number
0x19 Length of Source Product Description InfoFrame
*/
packet_header = 0x83 | (0x01 << 8) | (0x19 << 16);
HDMI_OUTP(0x00A4, packet_header);
check_sum += IFRAME_CHECKSUM_32(packet_header);
/* 0x00AC GENERIC1_1
* BYTE4 7:0 VENDOR_NAME[3]
* BYTE5 15:8 VENDOR_NAME[4]
* BYTE6 23:16 VENDOR_NAME[5]
* BYTE7 31:24 VENDOR_NAME[6] */
packet_payload = (vendor_name[3] & 0x7f)
| ((vendor_name[4] & 0x7f) << 8)
| ((vendor_name[5] & 0x7f) << 16)
| ((vendor_name[6] & 0x7f) << 24);
HDMI_OUTP(0x00AC, packet_payload);
check_sum += IFRAME_CHECKSUM_32(packet_payload);
/* Product Description (7-bit ASCII code) */
/* 0x00B0 GENERIC1_2
* BYTE8 7:0 VENDOR_NAME[7]
* BYTE9 15:8 PRODUCT_NAME[ 0]
* BYTE10 23:16 PRODUCT_NAME[ 1]
* BYTE11 31:24 PRODUCT_NAME[ 2] */
packet_payload = (vendor_name[7] & 0x7f)
| ((product_description[0] & 0x7f) << 8)
| ((product_description[1] & 0x7f) << 16)
| ((product_description[2] & 0x7f) << 24);
HDMI_OUTP(0x00B0, packet_payload);
check_sum += IFRAME_CHECKSUM_32(packet_payload);
/* 0x00B4 GENERIC1_3
* BYTE12 7:0 PRODUCT_NAME[ 3]
* BYTE13 15:8 PRODUCT_NAME[ 4]
* BYTE14 23:16 PRODUCT_NAME[ 5]
* BYTE15 31:24 PRODUCT_NAME[ 6] */
packet_payload = (product_description[3] & 0x7f)
| ((product_description[4] & 0x7f) << 8)
| ((product_description[5] & 0x7f) << 16)
| ((product_description[6] & 0x7f) << 24);
HDMI_OUTP(0x00B4, packet_payload);
check_sum += IFRAME_CHECKSUM_32(packet_payload);
/* 0x00B8 GENERIC1_4
* BYTE16 7:0 PRODUCT_NAME[ 7]
* BYTE17 15:8 PRODUCT_NAME[ 8]
* BYTE18 23:16 PRODUCT_NAME[ 9]
* BYTE19 31:24 PRODUCT_NAME[10] */
packet_payload = (product_description[7] & 0x7f)
| ((product_description[8] & 0x7f) << 8)
| ((product_description[9] & 0x7f) << 16)
| ((product_description[10] & 0x7f) << 24);
HDMI_OUTP(0x00B8, packet_payload);
check_sum += IFRAME_CHECKSUM_32(packet_payload);
/* 0x00BC GENERIC1_5
* BYTE20 7:0 PRODUCT_NAME[11]
* BYTE21 15:8 PRODUCT_NAME[12]
* BYTE22 23:16 PRODUCT_NAME[13]
* BYTE23 31:24 PRODUCT_NAME[14] */
packet_payload = (product_description[11] & 0x7f)
| ((product_description[12] & 0x7f) << 8)
| ((product_description[13] & 0x7f) << 16)
| ((product_description[14] & 0x7f) << 24);
HDMI_OUTP(0x00BC, packet_payload);
check_sum += IFRAME_CHECKSUM_32(packet_payload);
/* 0x00C0 GENERIC1_6
* BYTE24 7:0 PRODUCT_NAME[15]
* BYTE25 15:8 Source Device Information
* BYTE26 23:16 NUM
* BYTE27 31:24 NUM */
/* Source Device Information
* 00h unknown
* 01h Digital STB
* 02h DVD
* 03h D-VHS
* 04h HDD Video
* 05h DVC
* 06h DSC
* 07h Video CD
* 08h Game
* 09h PC general */
packet_payload = (product_description[15] & 0x7f) | 0x00 << 8;
HDMI_OUTP(0x00C0, packet_payload);
check_sum += IFRAME_CHECKSUM_32(packet_payload);
/* Vendor Name (7bit ASCII code) */
/* 0x00A8 GENERIC1_0
* BYTE0 7:0 CheckSum
* BYTE1 15:8 VENDOR_NAME[0]
* BYTE2 23:16 VENDOR_NAME[1]
* BYTE3 31:24 VENDOR_NAME[2] */
packet_payload = ((vendor_name[0] & 0x7f) << 8)
| ((vendor_name[1] & 0x7f) << 16)
| ((vendor_name[2] & 0x7f) << 24);
check_sum += IFRAME_CHECKSUM_32(packet_payload);
packet_payload |= ((0x100 - (0xff & check_sum)) & 0xff);
HDMI_OUTP(0x00A8, packet_payload);
/* GENERIC1_LINE | GENERIC1_CONT | GENERIC1_SEND
* Setup HDMI TX generic packet control
* Enable this packet to transmit every frame
* Enable HDMI TX engine to transmit Generic packet 1 */
packet_control = HDMI_INP_ND(0x0034);
packet_control |= ((0x1 << 24) | (1 << 5) | (1 << 4));
HDMI_OUTP(0x0034, packet_control);
}
int hdmi_msm_clk(int on)
{
int rc;
DEV_DBG("HDMI Clk: %s\n", on ? "Enable" : "Disable");
if (on) {
rc = clk_prepare_enable(hdmi_msm_state->hdmi_app_clk);
if (rc) {
DEV_ERR("'hdmi_app_clk' clock enable failed, rc=%d\n",
rc);
return rc;
}
rc = clk_prepare_enable(hdmi_msm_state->hdmi_m_pclk);
if (rc) {
DEV_ERR("'hdmi_m_pclk' clock enable failed, rc=%d\n",
rc);
return rc;
}
rc = clk_prepare_enable(hdmi_msm_state->hdmi_s_pclk);
if (rc) {
DEV_ERR("'hdmi_s_pclk' clock enable failed, rc=%d\n",
rc);
return rc;
}
} else {
clk_disable_unprepare(hdmi_msm_state->hdmi_app_clk);
clk_disable_unprepare(hdmi_msm_state->hdmi_m_pclk);
clk_disable_unprepare(hdmi_msm_state->hdmi_s_pclk);
}
return 0;
}
static void hdmi_msm_turn_on(void)
{
uint32 audio_pkt_ctrl, audio_cfg;
/*
* Number of wait iterations for QDSP to disable Audio Engine
* before resetting HDMI core
*/
int i = 10;
audio_pkt_ctrl = HDMI_INP_ND(0x0020);
audio_cfg = HDMI_INP_ND(0x01D0);
/*
* Checking BIT[0] of AUDIO PACKET CONTROL and
* AUDIO CONFIGURATION register
*/
while (((audio_pkt_ctrl & 0x00000001) || (audio_cfg & 0x00000001))
&& (i--)) {
audio_pkt_ctrl = HDMI_INP_ND(0x0020);
audio_cfg = HDMI_INP_ND(0x01D0);
DEV_DBG("%d times :: HDMI AUDIO PACKET is %08x and "
"AUDIO CFG is %08x", i, audio_pkt_ctrl, audio_cfg);
msleep(20);
}
hdmi_msm_set_mode(FALSE);
mutex_lock(&hdcp_auth_state_mutex);
hdmi_msm_reset_core();
mutex_unlock(&hdcp_auth_state_mutex);
hdmi_msm_init_phy(external_common_state->video_resolution);
/* HDMI_USEC_REFTIMER[0x0208] */
HDMI_OUTP(0x0208, 0x0001001B);
hdmi_msm_set_mode(TRUE);
hdmi_msm_video_setup(external_common_state->video_resolution);
if (!hdmi_msm_is_dvi_mode()) {
hdmi_msm_audio_setup();
/*
* Send the audio switch device notification if HDCP is
* not enabled. Otherwise, the notification would be
* sent after HDCP authentication is successful.
*/
if (!hdmi_msm_state->hdcp_enable)
SWITCH_SET_HDMI_AUDIO(1, 0);
}
hdmi_msm_avi_info_frame();
#ifdef CONFIG_FB_MSM_HDMI_3D
hdmi_msm_vendor_infoframe_packetsetup();
#endif
hdmi_msm_spd_infoframe_packetsetup();
if (hdmi_msm_state->hdcp_enable && hdmi_msm_state->reauth) {
hdmi_msm_hdcp_enable();
hdmi_msm_state->reauth = FALSE ;
}
#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT
/* re-initialize CEC if enabled */
mutex_lock(&hdmi_msm_state_mutex);
if (hdmi_msm_state->cec_enabled == true) {
hdmi_msm_cec_init();
hdmi_msm_cec_write_logical_addr(
hdmi_msm_state->cec_logical_addr);
}
mutex_unlock(&hdmi_msm_state_mutex);
#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT */
DEV_INFO("HDMI Core: Initialized\n");
}
static void hdmi_msm_hdcp_timer(unsigned long data)
{
if (!hdmi_msm_state->hdcp_enable) {
DEV_DBG("%s: HDCP not enabled\n", __func__);
return;
}
queue_work(hdmi_work_queue, &hdmi_msm_state->hdcp_work);
}
#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT
static void hdmi_msm_cec_read_timer_func(unsigned long data)
{
queue_work(hdmi_work_queue, &hdmi_msm_state->cec_latch_detect_work);
}
#endif
static void hdmi_msm_hpd_polarity_setup(void)
{
u32 cable_sense;
bool polarity = !external_common_state->hpd_state;
bool trigger = false;
if (polarity)
HDMI_OUTP(0x0254, BIT(2) | BIT(1));
else
HDMI_OUTP(0x0254, BIT(2));
cable_sense = (HDMI_INP(0x0250) & BIT(1)) >> 1;
if (cable_sense == polarity)
trigger = true;
DEV_DBG("%s: listen=%s, sense=%s, trigger=%s\n", __func__,
polarity ? "connect" : "disconnect",
cable_sense ? "connect" : "disconnect",
trigger ? "Yes" : "No");
if (trigger) {
u32 reg_val = HDMI_INP(0x0258);
/* Toggle HPD circuit to trigger HPD sense */
HDMI_OUTP(0x0258, reg_val & ~BIT(28));
HDMI_OUTP(0x0258, reg_val | BIT(28));
}
}
static void hdmi_msm_hpd_off(void)
{
int rc = 0;
if (!hdmi_msm_state->hpd_initialized) {
DEV_DBG("%s: HPD is already OFF, returning\n", __func__);
return;
}
DEV_DBG("%s: (timer, 5V, IRQ off)\n", __func__);
disable_irq(hdmi_msm_state->irq);
/* Disable HPD interrupt */
HDMI_OUTP(0x0254, 0);
DEV_DBG("%s: Disabling HPD_CTRLd\n", __func__);
hdmi_msm_set_mode(FALSE);
hdmi_msm_state->pd->enable_5v(0);
hdmi_msm_clk(0);
rc = hdmi_msm_state->pd->gpio_config(0);
if (rc != 0)
DEV_INFO("%s: Failed to disable GPIOs. Error=%d\n",
__func__, rc);
hdmi_msm_state->hpd_initialized = FALSE;
}
static void hdmi_msm_dump_regs(const char *prefix)
{
#ifdef REG_DUMP
print_hex_dump(KERN_INFO, prefix, DUMP_PREFIX_OFFSET, 32, 4,
(void *)MSM_HDMI_BASE, 0x0334, false);
#endif
}
static int hdmi_msm_hpd_on(void)
{
static int phy_reset_done;
uint32 hpd_ctrl;
int rc = 0;
if (hdmi_msm_state->hpd_initialized) {
DEV_DBG("%s: HPD is already ON\n", __func__);
} else {
rc = hdmi_msm_state->pd->gpio_config(1);
if (rc) {
DEV_ERR("%s: Failed to enable GPIOs. Error=%d\n",
__func__, rc);
goto error1;
}
rc = hdmi_msm_clk(1);
if (rc) {
DEV_ERR("%s: Failed to enable clocks. Error=%d\n",
__func__, rc);
goto error2;
}
rc = hdmi_msm_state->pd->enable_5v(1);
if (rc) {
DEV_ERR("%s: Failed to enable 5V regulator. Error=%d\n",
__func__, rc);
goto error3;
}
hdmi_msm_dump_regs("HDMI-INIT: ");
hdmi_msm_set_mode(FALSE);
if (!phy_reset_done) {
hdmi_phy_reset();
phy_reset_done = 1;
}
hdmi_msm_set_mode(TRUE);
/* HDMI_USEC_REFTIMER[0x0208] */
HDMI_OUTP(0x0208, 0x0001001B);
/* Set up HPD state variables */
mutex_lock(&external_common_state_hpd_mutex);
external_common_state->hpd_state = 0;
mutex_unlock(&external_common_state_hpd_mutex);
mutex_lock(&hdmi_msm_state_mutex);
mutex_unlock(&hdmi_msm_state_mutex);
enable_irq(hdmi_msm_state->irq);
hdmi_msm_state->hpd_initialized = TRUE;
/* set timeout to 4.1ms (max) for hardware debounce */
hpd_ctrl = HDMI_INP(0x0258) | 0x1FFF;
/* Turn on HPD HW circuit */
HDMI_OUTP(0x0258, hpd_ctrl | BIT(28));
/* Set HPD cable sense polarity */
hdmi_msm_hpd_polarity_setup();
}
DEV_DBG("%s: (IRQ, 5V on)\n", __func__);
return 0;
error3:
hdmi_msm_clk(0);
error2:
hdmi_msm_state->pd->gpio_config(0);
error1:
return rc;
}
static int hdmi_msm_power_ctrl(boolean enable)
{
int rc = 0;
if (enable) {
/*
* Enable HPD only if the UI option is on or if
* HDMI is configured as the primary display
*/
if (hdmi_prim_display ||
external_common_state->hpd_feature_on) {
DEV_DBG("%s: Turning HPD ciruitry on\n", __func__);
/*[ECID:000000] ZTEBSP wanghaifei start 20130221, add qcom new patch for HDP resume wait*/
if (external_common_state->pre_suspend_hpd_state) {
external_common_state->pre_suspend_hpd_state =
false;
hdmi_msm_send_event(HPD_EVENT_OFFLINE);
}
/*[ECID:000000] ZTEBSP wanghaifei end 20130221, add qcom new patch for HDP resume wait*/
rc = hdmi_msm_hpd_on();
if (rc) {
DEV_ERR("%s: HPD ON FAILED\n", __func__);
return rc;
}
/*[ECID:000000] ZTEBSP wanghaifei start 20130221, add qcom new patch for HDP resume wait*/
#if 0
/* Wait for HPD initialization to complete */
INIT_COMPLETION(hdmi_msm_state->hpd_event_processed);
time = wait_for_completion_interruptible_timeout(
&hdmi_msm_state->hpd_event_processed, HZ);
if (!time && !external_common_state->hpd_state) {
DEV_DBG("%s: cable not detected\n", __func__);
queue_work(hdmi_work_queue,
&hdmi_msm_state->hpd_state_work);
}
#endif
/*[ECID:000000] ZTEBSP wanghaifei end 20130221, add qcom new patch for HDP resume wait*/
}
} else {
DEV_DBG("%s: Turning HPD ciruitry off\n", __func__);
/*[ECID:000000] ZTEBSP wanghaifei start 20130221, add qcom new patch for HDP resume wait*/
external_common_state->pre_suspend_hpd_state =
external_common_state->hpd_state;
/*[ECID:000000] ZTEBSP wanghaifei end 20130221, add qcom new patch for HDP resume wait*/
hdmi_msm_hpd_off();
}
return rc;
}
static int hdmi_msm_power_on(struct platform_device *pdev)
{
struct msm_fb_data_type *mfd = platform_get_drvdata(pdev);
int ret = 0;
bool changed;
if (!hdmi_ready()) {
DEV_ERR("%s: HDMI/HPD not initialized\n", __func__);
return ret;
}
if (!external_common_state->hpd_state) {
DEV_DBG("%s:HDMI cable not connected\n", __func__);
goto error;
}
/* Only start transmission with supported resolution */
changed = hdmi_common_get_video_format_from_drv_data(mfd);
if (changed || external_common_state->default_res_supported) {
mutex_lock(&external_common_state_hpd_mutex);
if (external_common_state->hpd_state &&
hdmi_msm_is_power_on()) {
mutex_unlock(&external_common_state_hpd_mutex);
DEV_INFO("HDMI cable connected %s(%dx%d, %d)\n",
__func__, mfd->var_xres, mfd->var_yres,
mfd->var_pixclock);
hdmi_msm_turn_on();
hdmi_msm_state->panel_power_on = TRUE;
if (hdmi_msm_state->hdcp_enable) {
/* Kick off HDCP Authentication */
mutex_lock(&hdcp_auth_state_mutex);
hdmi_msm_state->reauth = FALSE;
hdmi_msm_state->full_auth_done = FALSE;
mutex_unlock(&hdcp_auth_state_mutex);
mod_timer(&hdmi_msm_state->hdcp_timer,
jiffies + HZ/2);
}
} else {
mutex_unlock(&external_common_state_hpd_mutex);
}
hdmi_msm_dump_regs("HDMI-ON: ");
DEV_INFO("power=%s DVI= %s\n",
hdmi_msm_is_power_on() ? "ON" : "OFF" ,
hdmi_msm_is_dvi_mode() ? "ON" : "OFF");
} else {
DEV_ERR("%s: Video fmt %d not supp. Returning\n",
__func__,
external_common_state->video_resolution);
}
error:
/* Set HPD cable sense polarity */
hdmi_msm_hpd_polarity_setup();
return ret;
}
void mhl_connect_api(boolean on)
{
char *envp[2];
/* Simulating a HPD event based on MHL event */
if (on) {
hdmi_msm_read_edid();
hdmi_msm_state->reauth = FALSE ;
/* Build EDID table */
hdmi_msm_turn_on();
DEV_INFO("HDMI HPD: CONNECTED: send ONLINE\n");
kobject_uevent(external_common_state->uevent_kobj,
KOBJ_ONLINE);
envp[0] = 0;
if (!hdmi_msm_state->hdcp_enable) {
/* Send Audio for HDMI Compliance Cases*/
envp[0] = "HDCP_STATE=PASS";
envp[1] = NULL;
DEV_INFO("HDMI HPD: sense : send HDCP_PASS\n");
kobject_uevent_env(external_common_state->uevent_kobj,
KOBJ_CHANGE, envp);
switch_set_state(&external_common_state->sdev, 1);
DEV_INFO("%s: hdmi state switched to %d\n",
__func__, external_common_state->sdev.state);
} else {
hdmi_msm_hdcp_enable();
}
} else {
DEV_INFO("HDMI HPD: DISCONNECTED: send OFFLINE\n");
kobject_uevent(external_common_state->uevent_kobj,
KOBJ_OFFLINE);
switch_set_state(&external_common_state->sdev, 0);
DEV_INFO("%s: hdmi state switched to %d\n", __func__,
external_common_state->sdev.state);
}
}
EXPORT_SYMBOL(mhl_connect_api);
/* Note that power-off will also be called when the cable-remove event is
* processed on the user-space and as a result the framebuffer is powered
* down. However, we are still required to be able to detect a cable-insert
* event; so for now leave the HDMI engine running; so that the HPD IRQ is
* still being processed.
*/
static int hdmi_msm_power_off(struct platform_device *pdev)
{
int ret = 0;
if (!hdmi_ready()) {
DEV_ERR("%s: HDMI/HPD not initialized\n", __func__);
return ret;
}
if (!hdmi_msm_state->panel_power_on) {
DEV_DBG("%s: panel not ON\n", __func__);
goto error;
}
if (hdmi_msm_state->hdcp_enable) {
if (hdmi_msm_state->hdcp_activating) {
/*
* Let the HDCP work know that we got an HPD
* disconnect so that it can stop the
* reauthentication loop.
*/
mutex_lock(&hdcp_auth_state_mutex);
hdmi_msm_state->hpd_during_auth = TRUE;
mutex_unlock(&hdcp_auth_state_mutex);
}
/*
* Cancel any pending reauth attempts.
* If one is ongoing, wait for it to finish
*/
cancel_work_sync(&hdmi_msm_state->hdcp_reauth_work);
cancel_work_sync(&hdmi_msm_state->hdcp_work);
del_timer_sync(&hdmi_msm_state->hdcp_timer);
hdcp_deauthenticate();
}
SWITCH_SET_HDMI_AUDIO(0, 0);
if (!hdmi_msm_is_dvi_mode())
hdmi_msm_audio_off();
hdmi_msm_powerdown_phy();
hdmi_msm_state->panel_power_on = FALSE;
DEV_INFO("power: OFF (audio off)\n");
if (!completion_done(&hdmi_msm_state->hpd_event_processed))
complete(&hdmi_msm_state->hpd_event_processed);
error:
/* Set HPD cable sense polarity */
hdmi_msm_hpd_polarity_setup();
return ret;
}
void hdmi_msm_config_hdcp_feature(void)
{
if (hdcp_feature_on && hdmi_msm_has_hdcp()) {
init_timer(&hdmi_msm_state->hdcp_timer);
hdmi_msm_state->hdcp_timer.function = hdmi_msm_hdcp_timer;
hdmi_msm_state->hdcp_timer.data = (uint32)NULL;
hdmi_msm_state->hdcp_timer.expires = 0xffffffffL;
init_completion(&hdmi_msm_state->hdcp_success_done);
INIT_WORK(&hdmi_msm_state->hdcp_reauth_work,
hdmi_msm_hdcp_reauth_work);
INIT_WORK(&hdmi_msm_state->hdcp_work, hdmi_msm_hdcp_work);
hdmi_msm_state->hdcp_enable = TRUE;
} else {
del_timer(&hdmi_msm_state->hdcp_timer);
hdmi_msm_state->hdcp_enable = FALSE;
}
external_common_state->present_hdcp = hdmi_msm_state->hdcp_enable;
DEV_INFO("%s: HDCP Feature: %s\n", __func__,
hdmi_msm_state->hdcp_enable ? "Enabled" : "Disabled");
}
static int __devinit hdmi_msm_probe(struct platform_device *pdev)
{
int rc;
struct platform_device *fb_dev;
if (!hdmi_msm_state) {
pr_err("%s: hdmi_msm_state is NULL\n", __func__);
return -ENOMEM;
}
external_common_state->dev = &pdev->dev;
DEV_DBG("probe\n");
if (pdev->id == 0) {
struct resource *res;
#define GET_RES(name, mode) do { \
res = platform_get_resource_byname(pdev, mode, name); \
if (!res) { \
DEV_ERR("'" name "' resource not found\n"); \
rc = -ENODEV; \
goto error; \
} \
} while (0)
#define IO_REMAP(var, name) do { \
GET_RES(name, IORESOURCE_MEM); \
var = ioremap(res->start, resource_size(res)); \
if (!var) { \
DEV_ERR("'" name "' ioremap failed\n"); \
rc = -ENOMEM; \
goto error; \
} \
} while (0)
#define GET_IRQ(var, name) do { \
GET_RES(name, IORESOURCE_IRQ); \
var = res->start; \
} while (0)
IO_REMAP(hdmi_msm_state->qfprom_io, "hdmi_msm_qfprom_addr");
hdmi_msm_state->hdmi_io = MSM_HDMI_BASE;
GET_IRQ(hdmi_msm_state->irq, "hdmi_msm_irq");
hdmi_msm_state->pd = pdev->dev.platform_data;
#undef GET_RES
#undef IO_REMAP
#undef GET_IRQ
return 0;
}
hdmi_msm_state->hdmi_app_clk = clk_get(&pdev->dev, "core_clk");
if (IS_ERR(hdmi_msm_state->hdmi_app_clk)) {
DEV_ERR("'core_clk' clk not found\n");
rc = IS_ERR(hdmi_msm_state->hdmi_app_clk);
goto error;
}
hdmi_msm_state->hdmi_m_pclk = clk_get(&pdev->dev, "master_iface_clk");
if (IS_ERR(hdmi_msm_state->hdmi_m_pclk)) {
DEV_ERR("'master_iface_clk' clk not found\n");
rc = IS_ERR(hdmi_msm_state->hdmi_m_pclk);
goto error;
}
hdmi_msm_state->hdmi_s_pclk = clk_get(&pdev->dev, "slave_iface_clk");
if (IS_ERR(hdmi_msm_state->hdmi_s_pclk)) {
DEV_ERR("'slave_iface_clk' clk not found\n");
rc = IS_ERR(hdmi_msm_state->hdmi_s_pclk);
goto error;
}
hdmi_msm_state->is_mhl_enabled = hdmi_msm_state->pd->is_mhl_enabled;
rc = check_hdmi_features();
if (rc) {
DEV_ERR("Init FAILED: check_hdmi_features rc=%d\n", rc);
goto error;
}
if (!hdmi_msm_state->pd->core_power) {
DEV_ERR("Init FAILED: core_power function missing\n");
rc = -ENODEV;
goto error;
}
if (!hdmi_msm_state->pd->enable_5v) {
DEV_ERR("Init FAILED: enable_5v function missing\n");
rc = -ENODEV;
goto error;
}
if (!hdmi_msm_state->pd->cec_power) {
DEV_ERR("Init FAILED: cec_power function missing\n");
rc = -ENODEV;
goto error;
}
rc = request_threaded_irq(hdmi_msm_state->irq, NULL, &hdmi_msm_isr,
IRQF_TRIGGER_HIGH | IRQF_ONESHOT, "hdmi_msm_isr", NULL);
if (rc) {
DEV_ERR("Init FAILED: IRQ request, rc=%d\n", rc);
goto error;
}
disable_irq(hdmi_msm_state->irq);
#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT
init_timer(&hdmi_msm_state->cec_read_timer);
hdmi_msm_state->cec_read_timer.function =
hdmi_msm_cec_read_timer_func;
hdmi_msm_state->cec_read_timer.data = (uint32)NULL;
hdmi_msm_state->cec_read_timer.expires = 0xffffffffL;
#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT */
fb_dev = msm_fb_add_device(pdev);
if (fb_dev) {
rc = external_common_state_create(fb_dev);
if (rc) {
DEV_ERR("Init FAILED: hdmi_msm_state_create, rc=%d\n",
rc);
goto error;
}
} else
DEV_ERR("Init FAILED: failed to add fb device\n");
if (hdmi_prim_display) {
rc = hdmi_msm_hpd_on();
if (rc)
goto error;
}
hdmi_msm_config_hdcp_feature();
/* Initialize hdmi node and register with switch driver */
if (hdmi_prim_display)
external_common_state->sdev.name = "hdmi_as_primary";
else
external_common_state->sdev.name = "hdmi";
if (switch_dev_register(&external_common_state->sdev) < 0) {
DEV_ERR("Hdmi switch registration failed\n");
rc = -ENODEV;
goto error;
}
external_common_state->audio_sdev.name = "hdmi_audio";
if (switch_dev_register(&external_common_state->audio_sdev) < 0) {
DEV_ERR("Hdmi audio switch registration failed\n");
switch_dev_unregister(&external_common_state->sdev);
rc = -ENODEV;
goto error;
}
return 0;
error:
if (hdmi_msm_state->qfprom_io)
iounmap(hdmi_msm_state->qfprom_io);
hdmi_msm_state->qfprom_io = NULL;
if (hdmi_msm_state->hdmi_io)
iounmap(hdmi_msm_state->hdmi_io);
hdmi_msm_state->hdmi_io = NULL;
external_common_state_remove();
if (hdmi_msm_state->hdmi_app_clk)
clk_put(hdmi_msm_state->hdmi_app_clk);
if (hdmi_msm_state->hdmi_m_pclk)
clk_put(hdmi_msm_state->hdmi_m_pclk);
if (hdmi_msm_state->hdmi_s_pclk)
clk_put(hdmi_msm_state->hdmi_s_pclk);
hdmi_msm_state->hdmi_app_clk = NULL;
hdmi_msm_state->hdmi_m_pclk = NULL;
hdmi_msm_state->hdmi_s_pclk = NULL;
return rc;
}
static int __devexit hdmi_msm_remove(struct platform_device *pdev)
{
DEV_INFO("HDMI device: remove\n");
DEV_INFO("HDMI HPD: OFF\n");
/* Unregister hdmi node from switch driver */
switch_dev_unregister(&external_common_state->sdev);
switch_dev_unregister(&external_common_state->audio_sdev);
hdmi_msm_hpd_off();
free_irq(hdmi_msm_state->irq, NULL);
if (hdmi_msm_state->qfprom_io)
iounmap(hdmi_msm_state->qfprom_io);
hdmi_msm_state->qfprom_io = NULL;
if (hdmi_msm_state->hdmi_io)
iounmap(hdmi_msm_state->hdmi_io);
hdmi_msm_state->hdmi_io = NULL;
external_common_state_remove();
if (hdmi_msm_state->hdmi_app_clk)
clk_put(hdmi_msm_state->hdmi_app_clk);
if (hdmi_msm_state->hdmi_m_pclk)
clk_put(hdmi_msm_state->hdmi_m_pclk);
if (hdmi_msm_state->hdmi_s_pclk)
clk_put(hdmi_msm_state->hdmi_s_pclk);
hdmi_msm_state->hdmi_app_clk = NULL;
hdmi_msm_state->hdmi_m_pclk = NULL;
hdmi_msm_state->hdmi_s_pclk = NULL;
kfree(hdmi_msm_state);
hdmi_msm_state = NULL;
return 0;
}
static int hdmi_msm_hpd_feature(int on)
{
int rc = 0;
DEV_INFO("%s: %d\n", __func__, on);
if (on) {
rc = hdmi_msm_hpd_on();
} else {
if (external_common_state->hpd_state) {
external_common_state->hpd_state = 0;
/* Send offline event to switch OFF HDMI and HAL FD */
hdmi_msm_send_event(HPD_EVENT_OFFLINE);
/* Wait for HDMI and FD to close */
INIT_COMPLETION(hdmi_msm_state->hpd_event_processed);
wait_for_completion_interruptible_timeout(
&hdmi_msm_state->hpd_event_processed, HZ);
}
hdmi_msm_hpd_off();
/* Set HDMI switch node to 0 on HPD feature disable */
switch_set_state(&external_common_state->sdev, 0);
DEV_INFO("%s: hdmi state switched to %d\n", __func__,
external_common_state->sdev.state);
}
return rc;
}
static struct platform_driver this_driver = {
.probe = hdmi_msm_probe,
.remove = hdmi_msm_remove,
.driver.name = "hdmi_msm",
};
static struct msm_fb_panel_data hdmi_msm_panel_data = {
.on = hdmi_msm_power_on,
.off = hdmi_msm_power_off,
.power_ctrl = hdmi_msm_power_ctrl,
};
static struct platform_device this_device = {
.name = "hdmi_msm",
.id = 1,
.dev.platform_data = &hdmi_msm_panel_data,
};
static int __init hdmi_msm_init(void)
{
int rc;
if (msm_fb_detect_client("hdmi_msm"))
return 0;
#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
hdmi_prim_display = 1;
#endif
hdmi_msm_setup_video_mode_lut();
hdmi_msm_state = kzalloc(sizeof(*hdmi_msm_state), GFP_KERNEL);
if (!hdmi_msm_state) {
pr_err("hdmi_msm_init FAILED: out of memory\n");
rc = -ENOMEM;
goto init_exit;
}
external_common_state = &hdmi_msm_state->common;
if (hdmi_prim_display && hdmi_prim_resolution)
external_common_state->video_resolution =
hdmi_prim_resolution - 1;
else
external_common_state->video_resolution =
HDMI_VFRMT_1920x1080p60_16_9;
#ifdef CONFIG_FB_MSM_HDMI_3D
external_common_state->switch_3d = hdmi_msm_switch_3d;
#endif
memset(external_common_state->spd_vendor_name, 0,
sizeof(external_common_state->spd_vendor_name));
memset(external_common_state->spd_product_description, 0,
sizeof(external_common_state->spd_product_description));
#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT
hdmi_msm_state->cec_queue_start =
kzalloc(sizeof(struct hdmi_msm_cec_msg)*CEC_QUEUE_SIZE,
GFP_KERNEL);
if (!hdmi_msm_state->cec_queue_start) {
pr_err("hdmi_msm_init FAILED: CEC queue out of memory\n");
rc = -ENOMEM;
goto init_exit;
}
hdmi_msm_state->cec_queue_wr = hdmi_msm_state->cec_queue_start;
hdmi_msm_state->cec_queue_rd = hdmi_msm_state->cec_queue_start;
hdmi_msm_state->cec_queue_full = false;
#endif
/*
* Create your work queue
* allocs and returns ptr
*/
hdmi_work_queue = create_workqueue("hdmi_hdcp");
external_common_state->hpd_feature = hdmi_msm_hpd_feature;
rc = platform_driver_register(&this_driver);
if (rc) {
pr_err("hdmi_msm_init FAILED: platform_driver_register rc=%d\n",
rc);
goto init_exit;
}
hdmi_common_init_panel_info(&hdmi_msm_panel_data.panel_info);
init_completion(&hdmi_msm_state->ddc_sw_done);
init_completion(&hdmi_msm_state->hpd_event_processed);
INIT_WORK(&hdmi_msm_state->hpd_state_work, hdmi_msm_hpd_state_work);
#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT
INIT_WORK(&hdmi_msm_state->cec_latch_detect_work,
hdmi_msm_cec_latch_work);
init_completion(&hdmi_msm_state->cec_frame_wr_done);
init_completion(&hdmi_msm_state->cec_line_latch_wait);
#endif
rc = platform_device_register(&this_device);
if (rc) {
pr_err("hdmi_msm_init FAILED: platform_device_register rc=%d\n",
rc);
platform_driver_unregister(&this_driver);
goto init_exit;
}
pr_debug("%s: success:"
#ifdef DEBUG
" DEBUG"
#else
" RELEASE"
#endif
" AUDIO EDID HPD HDCP"
" DVI"
#ifndef CONFIG_FB_MSM_HDMI_MSM_PANEL_DVI_SUPPORT
":0"
#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL_DVI_SUPPORT */
"\n", __func__);
return 0;
init_exit:
kfree(hdmi_msm_state);
hdmi_msm_state = NULL;
return rc;
}
static void __exit hdmi_msm_exit(void)
{
platform_device_unregister(&this_device);
platform_driver_unregister(&this_driver);
}
static int set_hdcp_feature_on(const char *val, const struct kernel_param *kp)
{
int rv = param_set_bool(val, kp);
if (rv)
return rv;
pr_debug("%s: HDCP feature = %d\n", __func__, hdcp_feature_on);
if (hdmi_msm_state) {
if ((HDMI_INP(0x0250) & 0x2)) {
pr_err("%s: Unable to set HDCP feature", __func__);
pr_err("%s: HDMI panel is currently turned on",
__func__);
} else if (hdcp_feature_on != hdmi_msm_state->hdcp_enable) {
hdmi_msm_config_hdcp_feature();
}
}
return 0;
}
static struct kernel_param_ops hdcp_feature_on_param_ops = {
.set = set_hdcp_feature_on,
.get = param_get_bool,
};
module_param_cb(hdcp, &hdcp_feature_on_param_ops, &hdcp_feature_on,
S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(hdcp, "Enable or Disable HDCP");
module_init(hdmi_msm_init);
module_exit(hdmi_msm_exit);
MODULE_LICENSE("GPL v2");
MODULE_VERSION("0.3");
MODULE_AUTHOR("Qualcomm Innovation Center, Inc.");
MODULE_DESCRIPTION("HDMI MSM TX driver");
| Gaojiquan/android_kernel_zte_digger | drivers/video/msm/hdmi_msm.c | C | gpl-2.0 | 145,025 |
package newpackage;
public class DaneWejsciowe {
float wartosc;
String argument;
public DaneWejsciowe( String argument,float wartosc) {
this.wartosc = wartosc;
this.argument = argument;
}
}
| Zajcew/SystemEkspertowy | System Ekspertowy/src/newpackage/DaneWejsciowe.java | Java | gpl-2.0 | 213 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.