code stringlengths 3 1.01M | repo_name stringlengths 5 116 | path stringlengths 3 311 | language stringclasses 30 values | license stringclasses 15 values | size int64 3 1.01M |
|---|---|---|---|---|---|
<?php
/**
*
* Set the descriptions for a product
*
* @package VirtueMart
* @subpackage Product
* @author RolandD
* @link http://www.virtuemart.net
* @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* @version $Id: product_edit_description.php 6046 2012-05-24 12:43:43Z alatak $
*/
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');?>
<fieldset>
<legend><?php echo JText::_('COM_VIRTUEMART_PRODUCT_FORM_S_DESC') ?></legend>
<textarea class="inputbox" name="product_s_desc" id="product_s_desc" cols="65" rows="3" ><?php echo $this->product->product_s_desc; ?></textarea>
</fieldset>
<fieldset>
<legend><?php echo JText::_('COM_VIRTUEMART_PRODUCT_FORM_DESCRIPTION') ?></legend>
<?php echo $this->editor->display('product_desc', $this->product->product_desc, '100%;', '550', '75', '20', array('pagebreak', 'readmore') ) ; ?>
</fieldset>
<fieldset>
<legend><?php echo JText::_('COM_VIRTUEMART_METAINFO') ?></legend>
<?php echo shopFunctions::renderMetaEdit($this->product); ?>
</fieldset>
| seobrand/twit2pay_dev | backup_23sep/administrator/components/com_virtuemart/views/product/tmpl/product_edit_description.php | PHP | gpl-2.0 | 1,418 |
<?php
/**
* All AJAX calls go here.
*/
function wpcf_ajax_embedded() {
if ( isset( $_REQUEST['_typesnonce'] ) ) {
if ( !wp_verify_nonce( $_REQUEST['_typesnonce'], '_typesnonce' ) ) {
die( 'Verification failed' );
}
} else {
if ( !isset( $_REQUEST['_wpnonce'] )
|| !wp_verify_nonce( $_REQUEST['_wpnonce'],
$_REQUEST['wpcf_action'] ) ) {
die( 'Verification failed' );
}
}
global $wpcf;
switch ( $_REQUEST['wpcf_action'] ) {
case 'editor_insert_date':
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields/date.php';
wpcf_fields_date_editor_form();
break;
case 'insert_skype_button':
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields/skype.php';
wpcf_fields_skype_meta_box_ajax();
break;
case 'editor_callback':
// Determine Field type and context
$views_usermeta = false;
if ( isset( $_GET['field_type'] ) && $_GET['field_type'] == 'usermeta' ) {
// Group filter
wp_enqueue_script( 'suggest' );
$field = types_get_field( $_GET['field_id'], 'usermeta' );
$meta_type = 'usermeta';
}
elseif ( isset( $_GET['field_type'] ) && $_GET['field_type'] == 'views-usermeta' ){
$field = types_get_field( $_GET['field_id'], 'usermeta' );
$meta_type = 'usermeta';
$views_usermeta = true;
}else {
$field = types_get_field( $_GET['field_id'] );
$meta_type = 'postmeta';
}
$post_id = isset( $_GET['post_id'] ) ? intval( $_GET['post_id'] ) : null;
$shortcode = isset( $_GET['shortcode'] ) ? urldecode( $_GET['shortcode'] ) : null;
$callback = isset( $_GET['callback'] ) ? $_GET['callback'] : false;
if ( !empty( $field ) ) {
// Editor
WPCF_Loader::loadClass( 'editor' );
$editor = new WPCF_Editor();
$editor->frame( $field, $meta_type, $post_id, $shortcode,
$callback, $views_usermeta );
}
break;
case 'dismiss_message':
if ( isset( $_GET['id'] ) ) {
$messages = get_option( 'wpcf_dismissed_messages', array() );
$messages[] = $_GET['id'];
update_option( 'wpcf_dismissed_messages', $messages );
}
break;
case '_dismiss_message':
if ( isset( $_GET['id'] ) ) {
$messages = get_option( '_wpcf_dismissed_messages', array() );
$messages[strval( $_GET['id'] )] = strval( $_GET['id'] );
update_option( '_wpcf_dismissed_messages', $messages );
}
break;
case 'pr_add_child_post':
$output = 'Passed wrong parameters';
if ( isset( $_GET['post_id'] )
&& isset( $_GET['post_type_child'] )
&& isset( $_GET['post_type_parent'] ) ) {
$relationships = get_option( 'wpcf_post_relationship', array() );
$post = get_post( intval( $_GET['post_id'] ) );
if ( !empty( $post->ID ) ) {
$post_type = strval( $_GET['post_type_child'] );
$parent_post_type = strval( $_GET['post_type_parent'] );
$data = $relationships[$parent_post_type][$post_type];
/*
* Since Types 1.1.5
*
* We save new post
* CHECKPOINT
*/
$id = $wpcf->relationship->add_new_child( $post->ID,
$post_type );
if ( is_wp_error( $id ) ) {
$output = $id->get_error_message();
} else {
/*
* Here we set Relationship
* CHECKPOINT
*/
$parent = get_post( intval( $_GET['post_id'] ) );
$child = get_post( $id );
if ( !empty( $parent->ID ) && !empty( $child->ID ) ) {
// Set post
$wpcf->post = $child;
// Set relationship :)
$wpcf->relationship->_set( $parent, $child, $data );
// Render new row
$output = $wpcf->relationship->child_row( $post->ID,
$id, $data );
} else {
$output = __( 'Error creating post relationship',
'wpcf' );
}
}
} else {
$output = __( 'Error getting parent post', 'wpcf' );
}
}
if ( !defined( 'WPTOOLSET_FORMS_VERSION' ) ) {
echo json_encode( array(
'output' => $output . wpcf_form_render_js_validation( '#post',
false ),
) );
} else {
echo json_encode( array(
'output' => $output,
'conditionals' => array('#post' => wptoolset_form_get_conditional_data( 'post' )),
) );
}
break;
case 'pr_save_all':
$output = '';
if ( isset( $_POST['post_id'] ) ) {
$parent_id = intval( $_POST['post_id'] );
if ( isset( $_POST['wpcf_post_relationship'][$parent_id] ) ) {
$wpcf->relationship->save_children( $parent_id,
(array) $_POST['wpcf_post_relationship'][$parent_id] );
$output = $wpcf->relationship->child_meta_form(
$parent_id, strval( $_POST['post_type'] )
);
}
}
if ( !defined( 'WPTOOLSET_FORMS_VERSION' ) ) {
// TODO Move to conditional
$output .= '<script type="text/javascript">wpcfConditionalInit();</script>';
}
if ( !defined( 'WPTOOLSET_FORMS_VERSION' ) ) {
echo json_encode( array(
'output' => $output,
) );
} else {
echo json_encode( array(
'output' => $output,
'conditionals' => array('#post' => wptoolset_form_get_conditional_data( 'post' )),
) );
}
break;
case 'pr_save_child_post':
ob_start(); // Try to catch any errors
$output = '';
if ( isset( $_GET['post_id'] )
&& isset( $_GET['parent_id'] )
&& isset( $_GET['post_type_parent'] )
&& isset( $_GET['post_type_child'] )
&& isset( $_POST['wpcf_post_relationship'] ) ) {
$parent_id = intval( $_GET['parent_id'] );
$child_id = intval( $_GET['post_id'] );
$parent_post_type = strval( $_GET['post_type_parent'] );
$child_post_type = strval( $_GET['post_type_child'] );
if ( isset( $_POST['wpcf_post_relationship'][$parent_id][$child_id] ) ) {
$fields = (array) $_POST['wpcf_post_relationship'][$parent_id][$child_id];
$wpcf->relationship->save_child( $parent_id, $child_id,
$fields );
$output = $wpcf->relationship->child_row( $parent_id,
$child_id,
$wpcf->relationship->settings( $parent_post_type,
$child_post_type ) );
if ( !defined( 'WPTOOLSET_FORMS_VERSION' ) ) {
// TODO Move to conditional
$output .= '<script type="text/javascript">wpcfConditionalInit(\'#types-child-row-'
. $child_id . '\');</script>';
}
}
}
$errors = ob_get_clean();
if ( !defined( 'WPTOOLSET_FORMS_VERSION' ) ) {
echo json_encode( array(
'output' => $output,
'errors' => $errors
) );
} else {
echo json_encode( array(
'output' => $output,
'errors' => $errors,
'conditionals' => array('#post' => wptoolset_form_get_conditional_data( 'post' )),
) );
}
break;
case 'pr_delete_child_post':
require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
$output = 'Passed wrong parameters';
if ( isset( $_GET['post_id'] ) ) {
$output = wpcf_pr_admin_delete_child_item( intval( $_GET['post_id'] ) );
}
echo json_encode( array(
'output' => $output,
) );
break;
case 'pr-update-belongs':
require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
$output = 'Passed wrong parameters';
if ( isset( $_POST['post_id'] ) && isset( $_POST['wpcf_pr_belongs'][$_POST['post_id']] ) ) {
$post_id = intval( $_POST['post_id'] );
$updated = wpcf_pr_admin_update_belongs( $post_id,
$_POST['wpcf_pr_belongs'][$post_id] );
$output = is_wp_error( $updated ) ? $updated->get_error_message() : $updated;
}
if ( !defined( 'WPTOOLSET_FORMS_VERSION' ) ) {
echo json_encode( array(
'output' => $output,
) );
} else {
echo json_encode( array(
'output' => $output,
'conditionals' => array('#post' => wptoolset_form_get_conditional_data( 'post' )),
) );
}
break;
case 'pr_pagination':
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
$output = 'Passed wrong parameters';
if ( isset( $_GET['post_id'] ) && isset( $_GET['post_type'] ) ) {
global $wpcf;
$parent = get_post( esc_attr( $_GET['post_id'] ) );
$child_post_type = esc_attr( $_GET['post_type'] );
if ( !empty( $parent->ID ) ) {
// Set post in loop
$wpcf->post = $parent;
// Save items_per_page
$wpcf->relationship->save_items_per_page(
$parent->post_type, $child_post_type,
intval( $_GET[$wpcf->relationship->items_per_page_option_name] )
);
$output = $wpcf->relationship->child_meta_form(
$parent->ID, $child_post_type
);
}
}
if ( !defined( 'WPTOOLSET_FORMS_VERSION' ) ) {
echo json_encode( array(
'output' => $output,
) );
} else {
echo json_encode( array(
'output' => $output,
'conditionals' => array('#post' => wptoolset_form_get_conditional_data( 'post' )),
) );
}
break;
case 'pr_sort':
$output = 'Passed wrong parameters';
if ( isset( $_GET['field'] ) && isset( $_GET['sort'] ) && isset( $_GET['post_id'] ) && isset( $_GET['post_type'] ) ) {
$output = $wpcf->relationship->child_meta_form(
intval( $_GET['post_id'] ), strval( $_GET['post_type'] )
);
}
if ( !defined( 'WPTOOLSET_FORMS_VERSION' ) ) {
echo json_encode( array(
'output' => $output,
) );
} else {
echo json_encode( array(
'output' => $output,
'conditionals' => array('#post' => wptoolset_form_get_conditional_data( 'post' )),
) );
}
break;
case 'pr_sort_parent':
$output = 'Passed wrong parameters';
if ( isset( $_GET['field'] ) && isset( $_GET['sort'] ) && isset( $_GET['post_id'] ) && isset( $_GET['post_type'] ) ) {
$output = $wpcf->relationship->child_meta_form(
intval( $_GET['post_id'] ), strval( $_GET['post_type'] )
);
}
if ( !defined( 'WPTOOLSET_FORMS_VERSION' ) ) {
echo json_encode( array(
'output' => $output,
) );
} else {
echo json_encode( array(
'output' => $output,
'conditionals' => array('#post' => wptoolset_form_get_conditional_data( 'post' )),
) );
}
break;
/* Usermeta */
case 'um_repetitive_add':
if ( isset( $_GET['field_id'] ) ) {
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
require_once WPCF_EMBEDDED_INC_ABSPATH . '/usermeta-post.php';
$field = wpcf_admin_fields_get_field( $_GET['field_id'], false,
false, false, 'wpcf-usermeta' );
if ( isset( $_GET['user_id'] ) ) {
$user_id = $_GET['user_id'];
} else {
$user_id = wpcf_usermeta_get_user();
}
global $wpcf;
$wpcf->usermeta_repeater->set( $user_id, $field );
/*
*
* Force empty values!
*/
$wpcf->usermeta_repeater->cf['value'] = null;
$wpcf->usermeta_repeater->meta = null;
$form = $wpcf->usermeta_repeater->get_field_form( null, true );
echo json_encode( array(
'output' => wpcf_form_simple( $form )
. wpcf_form_render_js_validation( '#your-profile', false ),
) );
} else {
echo json_encode( array(
'output' => 'params missing',
) );
}
break;
case 'um_repetitive_delete':
if ( isset( $_POST['user_id'] ) && isset( $_POST['field_id'] ) ) {
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
$user_id = $_POST['user_id'];
$field = wpcf_admin_fields_get_field( $_POST['field_id'], false,
false, false, 'wpcf-usermeta' );
$meta_id = $_POST['meta_id'];
if ( !empty( $field ) && !empty( $user_id ) && !empty( $meta_id ) ) {
/*
*
*
* Changed.
* Since Types 1.2
*/
global $wpcf;
$wpcf->usermeta_repeater->set( $user_id, $field );
$wpcf->usermeta_repeater->delete( $meta_id );
echo json_encode( array(
'output' => 'deleted',
) );
} else {
echo json_encode( array(
'output' => 'field or post not found',
) );
}
} else {
echo json_encode( array(
'output' => 'params missing',
) );
}
break;
/* End Usermeta */
case 'repetitive_add':
if ( isset( $_GET['field_id'] ) ) {
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
$field = wpcf_admin_fields_get_field( $_GET['field_id'] );
$post_id = intval( $_GET['post_id'] );
/*
* When post is new - post_id is 0
* We can safely set post_id to 1 cause
* values compared are filtered anyway.
*/
if ( $post_id == 0 ) {
$post_id = 1;
}
$post = get_post( $post_id );
global $wpcf;
$wpcf->repeater->set( $post, $field );
/*
*
* Force empty values!
*/
$wpcf->repeater->cf['value'] = null;
$wpcf->repeater->meta = null;
$form = $wpcf->repeater->get_field_form( null, true );
echo json_encode( array(
'output' => wpcf_form_simple( $form )
. wpcf_form_render_js_validation( '#post', false ),
) );
} else {
echo json_encode( array(
'output' => 'params missing',
) );
}
break;
case 'repetitive_delete':
if ( isset( $_POST['post_id'] ) && isset( $_POST['field_id'] ) ) {
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
$post = get_post( $_POST['post_id'] );
$field = wpcf_admin_fields_get_field( $_POST['field_id'] );
$meta_id = $_POST['meta_id'];
if ( !empty( $field ) && !empty( $post->ID ) && !empty( $meta_id ) ) {
/*
*
*
* Changed.
* Since Types 1.2
*/
global $wpcf;
$wpcf->repeater->set( $post, $field );
$wpcf->repeater->delete( $meta_id );
echo json_encode( array(
'output' => 'deleted',
) );
} else {
echo json_encode( array(
'output' => 'field or post not found',
) );
}
} else {
echo json_encode( array(
'output' => 'params missing',
) );
}
break;
case 'cd_verify':
if ( empty( $_POST['wpcf'] ) && empty( $_POST['wpcf_post_relationship'] ) ) {
die();
}
WPCF_Loader::loadClass( 'helper.ajax' );
$js_execute = WPCF_Helper_Ajax::conditionalVerify( $_POST );
// Render JSON
if ( !empty( $js_execute ) ) {
echo json_encode( array(
'output' => '',
'execute' => $js_execute,
'wpcf_nonce_ajax_callback' => wp_create_nonce( 'execute' ),
) );
}
die();
break;
case 'cd_group_verify':
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
require_once WPCF_EMBEDDED_INC_ABSPATH . '/conditional-display.php';
$group = wpcf_admin_fields_get_group( $_POST['group_id'] );
if ( empty( $group ) ) {
echo json_encode( array(
'output' => ''
) );
die();
}
$execute = '';
$group['conditional_display'] = get_post_meta( $group['id'],
'_wpcf_conditional_display', true );
// Filter meta values (switch them with $_POST values)
add_filter( 'get_post_metadata',
'wpcf_cd_meta_ajax_validation_filter', 10, 4 );
$post = false;
if ( isset( $_SERVER['HTTP_REFERER'] ) ) {
$split = explode( '?', $_SERVER['HTTP_REFERER'] );
if ( isset( $split[1] ) ) {
parse_str( $split[1], $vars );
if ( isset( $vars['post'] ) ) {
$post = get_post( $vars['post'] );
}
}
}
// Dummy post
if ( !$post ) {
$post = new stdClass();
$post->ID = 1;
}
if ( !empty( $group['conditional_display']['conditions'] ) ) {
$result = wpcf_cd_post_groups_filter( array(0 => $group), $post,
'group' );
if ( !empty( $result ) ) {
$result = array_shift( $result );
$passed = $result['_conditional_display'] == 'passed' ? true : false;
} else {
$passed = false;
}
if ( !$passed ) {
$execute = 'jQuery("#wpcf-group-' . $group['slug']
. '").slideUp().find(".wpcf-cd-group")'
. '.addClass(\'wpcf-cd-group-failed\')'
. '.removeClass(\'wpcf-cd-group-passed\').hide();';
} else {
$execute = 'jQuery("#wpcf-group-' . $group['slug']
. '").show().find(".wpcf-cd-group")'
. '.addClass(\'wpcf-cd-group-passed\')'
. '.removeClass(\'wpcf-cd-group-failed\').slideDown();';
}
}
// Remove filter meta values (switch them with $_POST values)
remove_filter( 'get_post_metadata',
'wpcf_cd_meta_ajax_validation_filter', 10, 4 );
echo json_encode( array(
'output' => '',
'execute' => $execute,
'wpcf_nonce_ajax_callback' => wp_create_nonce( 'execute' ),
) );
break;
default:
break;
}
if ( function_exists( 'wpcf_ajax' ) ) {
wpcf_ajax();
}
die();
}
| naipeCriminal/philadelphia | wp-content/plugins/types/embedded/includes/ajax.php | PHP | gpl-2.0 | 22,498 |
/***************************************************************************
qgsfeatureexpressionvaluesgatherer - QgsFeatureExpressionValuesGatherer
---------------------
begin : 10.3.2017
copyright : (C) 2017 by Matthias Kuhn
email : matthias@opengis.ch
***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#ifndef QGSFEATUREEXPRESSIONVALUESGATHERER_H
#define QGSFEATUREEXPRESSIONVALUESGATHERER_H
#include <QThread>
#include <QMutex>
#include "qgsapplication.h"
#include "qgslogger.h"
#include "qgsvectorlayer.h"
#include "qgsvectorlayerfeatureiterator.h"
#define SIP_NO_FILE
// just internal guff - definitely not for exposing to public API!
///@cond PRIVATE
/**
* \class QgsFieldExpressionValuesGatherer
* Gathers features with substring matching on an expression.
*
* \since QGIS 3.14
*/
class QgsFeatureExpressionValuesGatherer: public QThread
{
Q_OBJECT
public:
/**
* Constructor
* \param layer the vector layer
* \param displayExpression if empty, the display expression is taken from the layer definition
* \param request the request to perform
* \param identifierFields an optional list of fields name to be save in a variant list for an easier reuse
*/
QgsFeatureExpressionValuesGatherer( QgsVectorLayer *layer,
const QString &displayExpression = QString(),
const QgsFeatureRequest &request = QgsFeatureRequest(),
const QStringList &identifierFields = QStringList() )
: mSource( new QgsVectorLayerFeatureSource( layer ) )
, mDisplayExpression( displayExpression.isEmpty() ? layer->displayExpression() : displayExpression )
, mRequest( request )
, mIdentifierFields( identifierFields )
{
}
struct Entry
{
Entry() = default;
Entry( const QVariantList &_identifierFields, const QString &_value, const QgsFeature &_feature )
: identifierFields( _identifierFields )
, featureId( _feature.isValid() ? _feature.id() : FID_NULL )
, value( _value )
, feature( _feature )
{}
Entry( const QgsFeatureId &_featureId, const QString &_value, const QgsVectorLayer *layer )
: featureId( _featureId )
, value( _value )
, feature( QgsFeature( layer->fields() ) )
{}
QVariantList identifierFields;
QgsFeatureId featureId;
QString value;
QgsFeature feature;
bool operator()( const Entry &lhs, const Entry &rhs ) const;
};
static Entry nullEntry( QgsVectorLayer *layer )
{
return Entry( QVariantList(), QgsApplication::nullRepresentation(), QgsFeature( layer->fields() ) );
}
void run() override
{
mWasCanceled = false;
QgsFeatureIterator iterator = mSource->getFeatures( mRequest );
mDisplayExpression.prepare( &mExpressionContext );
QgsFeature feature;
QList<int> attributeIndexes;
for ( const QString &fieldName : qgis::as_const( mIdentifierFields ) )
attributeIndexes << mSource->fields().indexOf( fieldName );
while ( iterator.nextFeature( feature ) )
{
mExpressionContext.setFeature( feature );
QVariantList attributes;
for ( const int idx : attributeIndexes )
attributes << feature.attribute( idx );
const QString expressionValue = mDisplayExpression.evaluate( &mExpressionContext ).toString();
mEntries.append( Entry( attributes, expressionValue, feature ) );
QMutexLocker locker( &mCancelMutex );
if ( mWasCanceled )
return;
}
}
//! Informs the gatherer to immediately stop collecting values
void stop()
{
QMutexLocker locker( &mCancelMutex );
mWasCanceled = true;
}
//! Returns TRUE if collection was canceled before completion
bool wasCanceled() const
{
QMutexLocker locker( &mCancelMutex );
return mWasCanceled;
}
QVector<Entry> entries() const
{
return mEntries;
}
QgsFeatureRequest request() const
{
return mRequest;
}
/**
* Internal data, use for whatever you want.
*/
QVariant data() const
{
return mData;
}
/**
* Internal data, use for whatever you want.
*/
void setData( const QVariant &data )
{
mData = data;
}
protected:
QVector<Entry> mEntries;
private:
std::unique_ptr<QgsVectorLayerFeatureSource> mSource;
QgsExpression mDisplayExpression;
QgsExpressionContext mExpressionContext;
QgsFeatureRequest mRequest;
bool mWasCanceled = false;
mutable QMutex mCancelMutex;
QStringList mIdentifierFields;
QVariant mData;
};
///@endcond
#endif // QGSFEATUREEXPRESSIONVALUESGATHERER_H
| SrNetoChan/QGIS | src/core/qgsfeatureexpressionvaluesgatherer.h | C | gpl-2.0 | 5,432 |
<?php
/**
* @package EasySocial
* @copyright Copyright (C) 2010 - 2014 Stack Ideas Sdn Bhd. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* EasySocial is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
defined( '_JEXEC' ) or die( 'Unauthorized Access' );
// Include main model file.
FD::import( 'admin:/includes/model' );
class EasySocialModelReports extends EasySocialModel
{
private $data = null;
public function __construct( $config = array() )
{
parent::__construct( 'reports' , $config );
}
public function deleteSimilarReports( $extension , $uid , $type )
{
$db = FD::db();
$sql = $db->sql();
$sql->delete( '#__social_reports' );
$sql->where( 'extension' , $extension );
$sql->where( 'uid' , $uid );
$sql->where( 'type' , $type );
echo $sql->debug();exit;
}
/**
* Retrieves a list of reporters for a specific report.
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function getReporters( $extension , $uid , $type )
{
$db = FD::db();
$sql = $db->sql();
$sql->select( '#__social_reports' );
$sql->where( 'extension' , $extension );
$sql->where( 'uid' , $uid );
$sql->where( 'type' , $type );
$db->setQuery( $sql );
$rows = $db->loadObjectList();
if( !$rows )
{
return false;
}
$reports = array();
foreach( $rows as $item )
{
$report = FD::table( 'Report' );
$report->bind( $item );
$reports[] = $report;
}
return $reports;
}
/**
* Returns the total number of reports made.
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function getCount( $options = array() )
{
static $_cache = array();
$db = FD::db();
$sql = $db->sql();
$userId = isset( $options[ 'created_by' ] ) ? $options[ 'created_by' ] : '';
if (!isset($_cache[$userId])) {
$sql->select( '#__social_reports' );
$sql->column( 'COUNT(1)' , 'total' );
if( $userId )
{
$sql->where( 'created_by' , $userId );
}
$db->setQuery( $sql );
$total = $db->loadResult();
$_cache[$userId] = $total;
}
return $_cache[$userId];
}
/**
* Retrieves the list of reports
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function getReports()
{
$db = FD::db();
$sql = $db->sql();
$sql->select( '#__social_reports' );
$sql->column( '*' );
$sql->column( 'COUNT(1)', 'total' );
// We need to group up the items to ensure the unique-ness
$sql->group( 'extension' , 'uid' , 'type' );
// Determines if we need to search for something
$search = $this->getState( 'search' );
if( $search )
{
$sql->where( 'title' , '%' . $search . '%' , 'LIKE' , 'OR' );
$sql->where( 'message' , '%' . $search . '%' , 'LIKE' , 'OR' );
}
// Set the total objects
$this->setTotal( $sql->getTotalSql() );
// Set the ordering
$ordering = $this->getState( 'ordering' );
if( $ordering )
{
$direction = $this->getState( 'direction' );
$sql->order( $ordering , $direction );
}
// Get the real data now
$result = parent::getData( $sql->getSql() );
if( !$result )
{
return false;
}
$reports = array();
foreach( $result as $item )
{
$report = FD::table( 'Report' );
$report->bind( $item );
// Inject the total reports
$report->total = $item->total;
$reports[] = $report;
}
return $reports;
}
/**
* Purges all reports from the site
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function purge()
{
$db = FD::db();
$sql = $db->sql();
$sql->delete( '#__social_reports' );
$db->setQuery( $sql );
$db->Query();
return true;
}
/**
* Retrieves the total number of reported stream from the site
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function getReportCount()
{
$db = FD::db();
$sql = $db->sql();
$query = 'select count(1)';
$query .= ' from `#__social_reports`';
$sql->raw($query);
$db->setQuery($sql);
$total = (int) $db->loadResult();
return $total;
}
}
| BetterBetterBetter/WheresWalden | administrator/components/com_easysocial/models/reports.php | PHP | gpl-2.0 | 4,323 |
<?php
/**
* Single Reply
*
* @package supreme
* @subpackage Theme
*/
get_header(); // Loads the header.php template. ?>
<?php do_atomic( 'before_content' ); // supreme_before_content ?>
<?php bbp_breadcrumb( array( 'before' => '<div class="breadcrumb">', 'after' => '</div>', 'sep' => '<span class="sep">»</span>' ) ); ?>
<div id="content">
<?php do_atomic( 'open_content' ); // supreme_open_content ?>
<div class="hfeed">
<?php get_sidebar( 'before-content' ); // Loads the sidebar-before-content.php template. ?>
<?php do_action( 'bbp_template_notices' ); ?>
<?php while ( have_posts() ) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" class="<?php hybrid_entry_class(); ?>">
<?php do_atomic( 'open_entry' ); // supreme_open_entry ?>
<h1 class="entry-title"><?php bbp_reply_title(); ?></h1>
<div class="byline">
<span class="bbp-reply-date"><?php printf( __( '%1$s at %2$s', 'bbpress' ), get_the_date(), esc_attr( get_the_time() ) ); ?></span>
<?php bbp_reply_author_link( array( 'type' => 'name' ) ); ?>
<span class="bbp-reply-permalink"><a href="<?php bbp_reply_url(); ?>" title="<?php bbp_reply_title(); ?>">#</a></span>
</div><!-- .byline -->
<div class="entry-content">
<?php bbp_reply_content(); ?>
<?php if( is_user_logged_in() ) { ?>
<?php bbp_reply_admin_links( array( 'sep' => '   ' ) ); ?>
<?php } ?>
</div>
<?php do_atomic( 'close_entry' ); // supreme_close_entry ?>
</div><!-- .hentry -->
<?php endwhile; ?>
<?php get_sidebar( 'after-content' ); // Loads the sidebar-after-content.php template. ?>
</div><!-- .hfeed -->
<?php do_atomic( 'close_content' ); // supreme_close_content ?>
</div><!-- #content -->
<?php do_atomic( 'after_content' ); // supreme_after_content ?>
<?php get_footer(); // Loads the footer.php template. ?>
| imshashank/osuevents | wp-content/themes/supreme/single-reply.php | PHP | gpl-2.0 | 1,924 |
/***************************************************************************
qgspaperitem.cpp
-------------------
begin : September 2008
copyright : (C) 2008 by Marco Hugentobler
email : marco dot hugentobler at karto dot baug dot ethz dot ch
***************************************************************************/
/***************************************************************************
* *
* 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 "qgspaperitem.h"
#include "qgscomposition.h"
#include "qgsstyle.h"
#include "qgslogger.h"
#include "qgsmapsettings.h"
#include "qgscomposerutils.h"
#include <QGraphicsRectItem>
#include <QGraphicsView>
#include <QPainter>
//QgsPaperGrid
QgsPaperGrid::QgsPaperGrid( double x, double y, double width, double height, QgsComposition *composition ): QGraphicsRectItem( 0, 0, width, height ), mComposition( composition )
{
setFlag( QGraphicsItem::ItemIsSelectable, false );
setFlag( QGraphicsItem::ItemIsMovable, false );
setZValue( 1000 );
setPos( x, y );
}
void QgsPaperGrid::paint( QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget )
{
Q_UNUSED( itemStyle );
Q_UNUSED( pWidget );
//draw grid
if ( mComposition )
{
if ( mComposition->gridVisible() && mComposition->plotStyle() == QgsComposition::Preview
&& mComposition->snapGridResolution() > 0 )
{
int gridMultiplyX = static_cast< int >( mComposition->snapGridOffsetX() / mComposition->snapGridResolution() );
int gridMultiplyY = static_cast< int >( mComposition->snapGridOffsetY() / mComposition->snapGridResolution() );
double currentXCoord = mComposition->snapGridOffsetX() - gridMultiplyX * mComposition->snapGridResolution();
double currentYCoord;
double minYCoord = mComposition->snapGridOffsetY() - gridMultiplyY * mComposition->snapGridResolution();
painter->save();
//turn of antialiasing so grid is nice and sharp
painter->setRenderHint( QPainter::Antialiasing, false );
if ( mComposition->gridStyle() == QgsComposition::Solid )
{
painter->setPen( mComposition->gridPen() );
//draw vertical lines
for ( ; currentXCoord <= rect().width(); currentXCoord += mComposition->snapGridResolution() )
{
painter->drawLine( QPointF( currentXCoord, 0 ), QPointF( currentXCoord, rect().height() ) );
}
//draw horizontal lines
currentYCoord = minYCoord;
for ( ; currentYCoord <= rect().height(); currentYCoord += mComposition->snapGridResolution() )
{
painter->drawLine( QPointF( 0, currentYCoord ), QPointF( rect().width(), currentYCoord ) );
}
}
else //'Dots' or 'Crosses'
{
QPen gridPen = mComposition->gridPen();
painter->setPen( gridPen );
painter->setBrush( QBrush( gridPen.color() ) );
double halfCrossLength = 1;
if ( mComposition->gridStyle() == QgsComposition::Dots )
{
//dots are actually drawn as tiny crosses a few pixels across
//check QGraphicsView to get current transform
if ( scene() )
{
QList<QGraphicsView *> viewList = scene()->views();
if ( !viewList.isEmpty() )
{
QGraphicsView *currentView = viewList.at( 0 );
if ( currentView->isVisible() )
{
//set halfCrossLength to equivalent of 1 pixel
halfCrossLength = 1 / currentView->transform().m11();
}
}
}
}
else if ( mComposition->gridStyle() == QgsComposition::Crosses )
{
halfCrossLength = mComposition->snapGridResolution() / 6;
}
for ( ; currentXCoord <= rect().width(); currentXCoord += mComposition->snapGridResolution() )
{
currentYCoord = minYCoord;
for ( ; currentYCoord <= rect().height(); currentYCoord += mComposition->snapGridResolution() )
{
painter->drawLine( QPointF( currentXCoord - halfCrossLength, currentYCoord ), QPointF( currentXCoord + halfCrossLength, currentYCoord ) );
painter->drawLine( QPointF( currentXCoord, currentYCoord - halfCrossLength ), QPointF( currentXCoord, currentYCoord + halfCrossLength ) );
}
}
}
painter->restore();
}
}
}
//QgsPaperItem
QgsPaperItem::QgsPaperItem( QgsComposition *c )
: QgsComposerItem( c, false )
{
initialize();
}
QgsPaperItem::QgsPaperItem( qreal x, qreal y, qreal width, qreal height, QgsComposition *composition )
: QgsComposerItem( x, y, width, height, composition, false )
{
initialize();
}
QgsPaperItem::QgsPaperItem()
: QgsComposerItem( nullptr, false )
{
initialize();
}
QgsPaperItem::~QgsPaperItem()
{
delete mPageGrid;
}
void QgsPaperItem::paint( QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget )
{
Q_UNUSED( itemStyle );
Q_UNUSED( pWidget );
if ( !painter || !mComposition || !mComposition->pagesVisible() )
{
return;
}
//setup painter scaling to dots so that raster symbology is drawn to scale
double dotsPerMM = painter->device()->logicalDpiX() / 25.4;
//setup render context
QgsRenderContext context = QgsComposerUtils::createRenderContextForComposition( mComposition, painter );
context.setForceVectorOutput( true );
QgsExpressionContext expressionContext = createExpressionContext();
context.setExpressionContext( expressionContext );
painter->save();
if ( mComposition->plotStyle() == QgsComposition::Preview )
{
//if in preview mode, draw page border and shadow so that it's
//still possible to tell where pages with a transparent style begin and end
painter->setRenderHint( QPainter::Antialiasing, false );
//shadow
painter->setBrush( QBrush( QColor( 150, 150, 150 ) ) );
painter->setPen( Qt::NoPen );
painter->drawRect( QRectF( 1, 1, rect().width() + 1, rect().height() + 1 ) );
//page area
painter->setBrush( QColor( 215, 215, 215 ) );
QPen pagePen = QPen( QColor( 100, 100, 100 ), 0 );
pagePen.setCosmetic( true );
painter->setPen( pagePen );
painter->drawRect( QRectF( 0, 0, rect().width(), rect().height() ) );
}
painter->scale( 1 / dotsPerMM, 1 / dotsPerMM ); // scale painter from mm to dots
painter->setRenderHint( QPainter::Antialiasing );
mComposition->pageStyleSymbol()->startRender( context );
calculatePageMargin();
QPolygonF pagePolygon = QPolygonF( QRectF( mPageMargin * dotsPerMM, mPageMargin * dotsPerMM,
( rect().width() - 2 * mPageMargin ) * dotsPerMM, ( rect().height() - 2 * mPageMargin ) * dotsPerMM ) );
QList<QPolygonF> rings; //empty list
mComposition->pageStyleSymbol()->renderPolygon( pagePolygon, &rings, nullptr, context );
mComposition->pageStyleSymbol()->stopRender( context );
painter->restore();
}
void QgsPaperItem::calculatePageMargin()
{
//get max bleed from symbol
QgsRenderContext rc = QgsComposerUtils::createRenderContextForMap( mComposition->referenceMap(), nullptr, mComposition->printResolution() );
double maxBleedPixels = QgsSymbolLayerUtils::estimateMaxSymbolBleed( mComposition->pageStyleSymbol(), rc );
//Now subtract 1 pixel to prevent semi-transparent borders at edge of solid page caused by
//anti-aliased painting. This may cause a pixel to be cropped from certain edge lines/symbols,
//but that can be counteracted by adding a dummy transparent line symbol layer with a wider line width
maxBleedPixels--;
double maxBleedMm = ( 25.4 / mComposition->printResolution() ) * maxBleedPixels;
mPageMargin = maxBleedMm;
}
bool QgsPaperItem::writeXml( QDomElement &elem, QDomDocument &doc ) const
{
Q_UNUSED( elem );
Q_UNUSED( doc );
return true;
}
bool QgsPaperItem::readXml( const QDomElement &itemElem, const QDomDocument &doc )
{
Q_UNUSED( itemElem );
Q_UNUSED( doc );
return true;
}
void QgsPaperItem::setSceneRect( const QRectF &rectangle )
{
QgsComposerItem::setSceneRect( rectangle );
//update size and position of attached QgsPaperGrid to reflect new page size and position
mPageGrid->setRect( 0, 0, rect().width(), rect().height() );
mPageGrid->setPos( pos().x(), pos().y() );
}
void QgsPaperItem::initialize()
{
setFlag( QGraphicsItem::ItemIsSelectable, false );
setFlag( QGraphicsItem::ItemIsMovable, false );
setZValue( 0 );
//even though we aren't going to use it to draw the page, set the pen width as 4
//so that the page border and shadow is fully rendered within its scene rect
//(QGraphicsRectItem considers the pen width when calculating an item's scene rect)
setPen( QPen( QBrush( Qt::NoBrush ), 4 ) );
if ( mComposition )
{
//create a new QgsPaperGrid for this page, and add it to the composition
mPageGrid = new QgsPaperGrid( pos().x(), pos().y(), rect().width(), rect().height(), mComposition );
mComposition->addItem( mPageGrid );
//connect to atlas feature changes
//to update symbol style (in case of data-defined symbology)
connect( &mComposition->atlasComposition(), &QgsAtlasComposition::featureChanged, this, &QgsComposerItem::repaint );
}
}
| spaceof7/QGIS | src/core/composer/qgspaperitem.cpp | C++ | gpl-2.0 | 9,794 |
"..\tool\Jssor.Compress.exe" -HTML:Js -HTML:Css -HTML:Comment -HTML:Blank -JSSORONLY -AWRAP -OVERWRITE -ENCOUT:UTF-8 "responsive-slider-full-width.source.html" -OUT "responsive-slider-full-width.html"
| Rmalnoult/slider-wp | wp-content/plugins/slider-wp/jssor/themes-no-jquery/responsive-slider-full-width.compress.bat | Batchfile | gpl-2.0 | 201 |
<?php
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @since 3.5.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Http\Middleware;
use Cake\Http\Response;
use Cake\Http\ServerRequest;
use Cake\I18n\Time;
use Cake\Network\Exception\InvalidCsrfTokenException;
use Cake\Utility\Hash;
use Cake\Utility\Security;
/**
* Provides CSRF protection & validation.
*
* This middleware adds a CSRF token to a cookie. The cookie value is compared to
* request data, or the X-CSRF-Token header on each PATCH, POST,
* PUT, or DELETE request.
*
* If the request data is missing or does not match the cookie data,
* an InvalidCsrfTokenException will be raised.
*
* This middleware integrates with the FormHelper automatically and when
* used together your forms will have CSRF tokens automatically added
* when `$this->Form->create(...)` is used in a view.
*/
class CsrfProtectionMiddleware
{
/**
* Default config for the CSRF handling.
*
* - `cookieName` = The name of the cookie to send.
* - `expiry` = How long the CSRF token should last. Defaults to browser session.
* - `secure` = Whether or not the cookie will be set with the Secure flag. Defaults to false.
* - `httpOnly` = Whether or not the cookie will be set with the HttpOnly flag. Defaults to false.
* - `field` = The form field to check. Changing this will also require configuring
* FormHelper.
*
* @var array
*/
protected $_defaultConfig = [
'cookieName' => 'csrfToken',
'expiry' => 0,
'secure' => false,
'httpOnly' => false,
'field' => '_csrfToken',
];
/**
* Configuration
*
* @var array
*/
protected $_config = [];
/**
* Constructor
*
* @param array $config Config options. See $_defaultConfig for valid keys.
*/
public function __construct(array $config = [])
{
$this->_config = $config + $this->_defaultConfig;
}
/**
* Checks and sets the CSRF token depending on the HTTP verb.
*
* @param \Cake\Http\ServerRequest $request The request.
* @param \Cake\Http\Response $response The response.
* @param callable $next Callback to invoke the next middleware.
* @return \Cake\Http\Response A response
*/
public function __invoke(ServerRequest $request, Response $response, $next)
{
$cookies = $request->getCookieParams();
$cookieData = Hash::get($cookies, $this->_config['cookieName']);
if (strlen($cookieData) > 0) {
$params = $request->getAttribute('params');
$params['_csrfToken'] = $cookieData;
$request = $request->withAttribute('params', $params);
}
$method = $request->getMethod();
if ($method === 'GET' && $cookieData === null) {
$token = $this->_createToken();
$request = $this->_addTokenToRequest($token, $request);
$response = $this->_addTokenCookie($token, $request, $response);
return $next($request, $response);
}
$request = $this->_validateAndUnsetTokenField($request);
return $next($request, $response);
}
/**
* Checks if the request is POST, PUT, DELETE or PATCH and validates the CSRF token
*
* @param \Cake\Http\ServerRequest $request The request object.
* @return \Cake\Http\ServerRequest
*/
protected function _validateAndUnsetTokenField(ServerRequest $request)
{
if (in_array($request->getMethod(), ['PUT', 'POST', 'DELETE', 'PATCH']) || $request->getData()) {
$this->_validateToken($request);
$body = $request->getParsedBody();
if (is_array($body)) {
unset($body[$this->_config['field']]);
$request = $request->withParsedBody($body);
}
}
return $request;
}
/**
* Create a new token to be used for CSRF protection
*
* @return string
*/
protected function _createToken()
{
return hash('sha512', Security::randomBytes(16), false);
}
/**
* Add a CSRF token to the request parameters.
*
* @param string $token The token to add.
* @param \Cake\Http\ServerRequest $request The request to augment
* @return \Cake\Http\ServerRequest Modified request
*/
protected function _addTokenToRequest($token, ServerRequest $request)
{
$params = $request->getAttribute('params');
$params['_csrfToken'] = $token;
return $request->withAttribute('params', $params);
}
/**
* Add a CSRF token to the response cookies.
*
* @param string $token The token to add.
* @param \Cake\Http\ServerRequest $request The request to validate against.
* @param \Cake\Http\Response $response The response.
* @return @param \Cake\Http\Response $response Modified response.
*/
protected function _addTokenCookie($token, ServerRequest $request, Response $response)
{
$expiry = new Time($this->_config['expiry']);
return $response->withCookie($this->_config['cookieName'], [
'value' => $token,
'expire' => $expiry->format('U'),
'path' => $request->getAttribute('webroot'),
'secure' => $this->_config['secure'],
'httpOnly' => $this->_config['httpOnly'],
]);
}
/**
* Validate the request data against the cookie token.
*
* @param \Cake\Http\ServerRequest $request The request to validate against.
* @return void
* @throws \Cake\Network\Exception\InvalidCsrfTokenException When the CSRF token is invalid or missing.
*/
protected function _validateToken(ServerRequest $request)
{
$cookies = $request->getCookieParams();
$cookie = Hash::get($cookies, $this->_config['cookieName']);
$post = Hash::get($request->getParsedBody(), $this->_config['field']);
$header = $request->getHeaderLine('X-CSRF-Token');
if (!$cookie) {
throw new InvalidCsrfTokenException(__d('cake', 'Missing CSRF token cookie'));
}
if ($post !== $cookie && $header !== $cookie) {
throw new InvalidCsrfTokenException(__d('cake', 'CSRF token mismatch.'));
}
}
}
| bsteph/FFLLogbook | vendor/cakephp/cakephp/src/Http/Middleware/CsrfProtectionMiddleware.php | PHP | gpl-2.0 | 6,793 |
#pragma once
/*
* Copyright (C) 2005-2012 Team XBMC
* http://www.xbmc.org
*
* 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, 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 XBMC; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*
*/
#include <map>
#include <vector>
#include "StdString.h"
#define HTTPHEADER_CONTENT_TYPE "Content-Type"
typedef std::map<CStdString, CStdString> HeaderParams;
typedef std::map<CStdString, CStdString>::iterator HeaderParamsIter;
class CHttpHeader
{
public:
CHttpHeader();
~CHttpHeader();
void Parse(CStdString strData);
CStdString GetValue(CStdString strParam) const;
void GetHeader(CStdString& strHeader) const;
CStdString GetMimeType() { return GetValue(HTTPHEADER_CONTENT_TYPE); }
CStdString GetProtoLine() { return m_protoLine; }
void Clear();
/* PLEX */
CStdString GetHeaders() { return m_headers; }
/* END PLEX */
protected:
HeaderParams m_params;
CStdString m_protoLine;
/* PLEX */
CStdString m_headers;
/* END PLEX */
};
| RasPlex/OpenPHT | xbmc/utils/HttpHeader.h | C | gpl-2.0 | 1,529 |
/**********************************************************************
*
* Filename: circbuf.h
*
* Description: An easy-to-use circular buffer class.
*
* Notes:
*
*
* Copyright (c) 1998 by Michael Barr. This software is placed into
* the public domain and may be used for any purpose. However, this
* notice must not be changed or removed and no warranty is either
* expressed or implied by its publication or distribution.
**********************************************************************/
#include <stdio.h>
#ifndef _CIRCBUF_H
#define _CIRCBUF_H
typedef unsigned char item;
class CircBuf
{
public:
CircBuf(int nItems);
~CircBuf(); //destructor
//consideramos que el tail apunta siempre a una posicion vacia
void add(item);
void display_buffer();
void display_sin_htc();
item remove();
void flush();
int isEmpty();
int isFull();
private:
item * array; //permite guardar los eltos del buffer circular
int size; //contiene el tamanio del buffer
int head; //apunta al primer elto del buffer
int tail; //apunta al ultimo elto. del buffer
int count; //guarda la cantidad de eltos. que actualmente posee el buffer
};
#endif /* _CIRCBUF_H */
| zrafa/pselab | trabajo_final_freertos/FA-BG/arduino_promini/circbuf.h | C | gpl-2.0 | 1,380 |
<?php
/*
* Textpattern Content Management System
* http://textpattern.com
*
* Copyright (C) 2015 The Textpattern Development Team
*
* This file is part of Textpattern.
*
* Textpattern 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, version 2.
*
* Textpattern 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 Textpattern. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Used for tag builder.
*
* Populates the tag selector.
*
* @ignore
*/
$article_tags = array(
'permlink',
'posted',
'title',
'body',
'excerpt',
'section',
'category1',
'category2',
'article_image',
'comments_invite',
'author',
);
$link_tags = array(
'link',
'linkdesctitle',
'link_name',
'link_description',
'link_category',
'link_date',
);
$comment_tags = array(
'comments',
'comments_form',
'comments_preview',
);
$comment_details_tags = array(
'comment_permlink',
'comment_name',
'comment_email',
'comment_web',
'comment_time',
'comment_message',
);
$comment_form_tags = array(
'comment_name_input',
'comment_email_input',
'comment_web_input',
'comment_message_input',
'comment_remember',
'comment_preview',
'comment_submit',
);
$search_result_tags = array(
'search_result_title',
'search_result_excerpt',
'search_result_date',
'search_result_url',
);
$file_download_tags = array(
'file_download_link',
'file_download_name',
'file_download_description',
'file_download_category',
'file_download_created',
'file_download_modified',
'file_download_size',
'file_download_downloads',
);
$category_tags = array(
'category',
'if_category',
);
$section_tags = array(
'section',
'if_section',
);
$page_article_tags = array(
'article',
'article_custom',
);
$page_article_nav_tags = array(
'prev_title',
'next_title',
'link_to_prev',
'link_to_next',
'older',
'newer',
);
$page_nav_tags = array(
'link_to_home',
'section_list',
'category_list',
'popup',
'recent_articles',
'recent_comments',
'related_articles',
'search_input',
);
$page_xml_tags = array(
'feed_link',
'link_feed_link',
);
$page_misc_tags = array(
'page_title',
'css',
'site_name',
'site_slogan',
'breadcrumb',
'search_input',
'email',
'linklist',
'password_protect',
'output_form',
'lang',
);
$page_file_tags = array(
'file_download_list',
'file_download',
'file_download_link',
);
| rwetzlmayr/textpattern | textpattern/lib/taglib.php | PHP | gpl-2.0 | 2,950 |
/*
* Button mixin- creates 3d-ish button effect with correct
* highlights/shadows, based on a base color.
*/
html {
background: #f1f1f1; }
/* Links */
a {
color: #0074a2; }
a:hover, a:active, a:focus {
color: #0099d5; }
#media-upload a.del-link:hover, div.dashboard-widget-submit input:hover, .subsubsub a:hover, .subsubsub a.current:hover {
color: #0099d5; }
/* Forms */
input[type=checkbox]:checked:before {
color: #523f6d; }
input[type=radio]:checked:before {
background: #523f6d; }
.wp-core-ui input[type="reset"]:hover, .wp-core-ui input[type="reset"]:active {
color: #0099d5; }
/* Core UI */
.wp-core-ui .button-primary {
background: #a3b745;
border-color: #829237;
color: white;
-webkit-box-shadow: inset 0 1px 0 #bfcd7b, 0 1px 0 rgba(0, 0, 0, 0.15);
box-shadow: inset 0 1px 0 #bfcd7b, 0 1px 0 rgba(0, 0, 0, 0.15); }
.wp-core-ui .button-primary:hover, .wp-core-ui .button-primary:focus {
background: #93a43e;
border-color: #727f30;
color: white;
-webkit-box-shadow: inset 0 1px 0 #b6c669;
box-shadow: inset 0 1px 0 #b6c669; }
.wp-core-ui .button-primary:focus {
-webkit-box-shadow: inset 0 1px 0 #b6c669, 0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30, 140, 190, 0.8);
box-shadow: inset 0 1px 0 #b6c669, 0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30, 140, 190, 0.8); }
.wp-core-ui .button-primary:active {
background: #829237;
border-color: #727f30;
color: white;
-webkit-box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5), 0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30, 140, 190, 0.8);
box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5), 0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30, 140, 190, 0.8); }
.wp-core-ui .button-primary[disabled], .wp-core-ui .button-primary:disabled, .wp-core-ui .button-primary.button-primary-disabled, .wp-core-ui .button-primary.disabled {
color: #cfd1c7 !important;
background: #89993a !important;
border-color: #727f30 !important;
text-shadow: none !important; }
.wp-core-ui .wp-ui-primary {
color: #fff;
background-color: #523f6d; }
.wp-core-ui .wp-ui-text-primary {
color: #523f6d; }
.wp-core-ui .wp-ui-highlight {
color: #fff;
background-color: #a3b745; }
.wp-core-ui .wp-ui-text-highlight {
color: #a3b745; }
.wp-core-ui .wp-ui-notification {
color: #fff;
background-color: #d46f15; }
.wp-core-ui .wp-ui-text-notification {
color: #d46f15; }
.wp-core-ui .wp-ui-text-icon {
color: #ece6f6; }
/* List tables */
.wrap .add-new-h2:hover, #add-new-comment a:hover, .tablenav .tablenav-pages a:hover, .tablenav .tablenav-pages a:focus {
color: #fff;
background-color: #523f6d; }
.view-switch a.current:before {
color: #523f6d; }
.view-switch a:hover:before {
color: #d46f15; }
.post-com-count:hover:after {
border-top-color: #523f6d; }
.post-com-count:hover span {
color: #fff;
background-color: #523f6d; }
strong .post-com-count:after {
border-top-color: #d46f15; }
strong .post-com-count span {
background-color: #d46f15; }
/* Admin Menu */
#adminmenuback, #adminmenuwrap, #adminmenu {
background: #523f6d; }
#adminmenu a {
color: #fff; }
#adminmenu div.wp-menu-image:before {
color: #ece6f6; }
#adminmenu a:hover, #adminmenu li.menu-top:hover, #adminmenu li.opensub > a.menu-top, #adminmenu li > a.menu-top:focus {
color: #fff;
background-color: #a3b745; }
#adminmenu li.menu-top:hover div.wp-menu-image:before, #adminmenu li.opensub > a.menu-top div.wp-menu-image:before {
color: #fff; }
/* Active tabs use a bottom border color that matches the page background color. */
.about-wrap h2 .nav-tab-active, .nav-tab-active, .nav-tab-active:hover {
background-color: #f1f1f1;
border-bottom-color: #f1f1f1; }
/* Admin Menu: submenu */
#adminmenu .wp-submenu, #adminmenu .wp-has-current-submenu .wp-submenu, #adminmenu .wp-has-current-submenu.opensub .wp-submenu, .folded #adminmenu .wp-has-current-submenu .wp-submenu, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu {
background: #413256; }
#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after {
border-left-color: #413256; }
#adminmenu .wp-submenu .wp-submenu-head {
color: #cbc5d3; }
#adminmenu .wp-submenu a, #adminmenu .wp-has-current-submenu .wp-submenu a, .folded #adminmenu .wp-has-current-submenu .wp-submenu a, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu a, #adminmenu .wp-has-current-submenu.opensub .wp-submenu a {
color: #cbc5d3; }
#adminmenu .wp-submenu a:focus, #adminmenu .wp-submenu a:hover, #adminmenu .wp-has-current-submenu .wp-submenu a:focus, #adminmenu .wp-has-current-submenu .wp-submenu a:hover, .folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus, .folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:focus, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:hover, #adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus, #adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover {
color: #a3b745; }
/* Admin Menu: current */
#adminmenu .wp-submenu li.current a, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a, #adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a {
color: #fff; }
#adminmenu .wp-submenu li.current a:hover, #adminmenu .wp-submenu li.current a:focus, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:hover, #adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:focus, #adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover, #adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus {
color: #a3b745; }
ul#adminmenu a.wp-has-current-submenu:after, ul#adminmenu > li.current > a.current:after {
border-left-color: #f1f1f1; }
#adminmenu li.current a.menu-top, #adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, #adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head, .folded #adminmenu li.current.menu-top {
color: #fff;
background: #a3b745; }
#adminmenu li.wp-has-current-submenu div.wp-menu-image:before {
color: #fff; }
/* Admin Menu: bubble */
#adminmenu .awaiting-mod, #adminmenu .update-plugins {
color: #fff;
background: #d46f15; }
#adminmenu li.current a .awaiting-mod, #adminmenu li a.wp-has-current-submenu .update-plugins, #adminmenu li:hover a .awaiting-mod, #adminmenu li.menu-top:hover > a .update-plugins {
color: #fff;
background: #413256; }
/* Admin Menu: collapse button */
#collapse-menu {
color: #ece6f6; }
#collapse-menu:hover {
color: #fff; }
#collapse-button div:after {
color: #ece6f6; }
#collapse-menu:hover #collapse-button div:after {
color: #fff; }
/* Admin Bar */
#wpadminbar {
color: #fff;
background: #523f6d; }
#wpadminbar .ab-item, #wpadminbar a.ab-item, #wpadminbar > #wp-toolbar span.ab-label, #wpadminbar > #wp-toolbar span.noticon {
color: #fff; }
#wpadminbar .ab-icon, #wpadminbar .ab-icon:before, #wpadminbar .ab-item:before, #wpadminbar .ab-item:after {
color: #ece6f6; }
#wpadminbar .ab-top-menu > li:hover > .ab-item, #wpadminbar .ab-top-menu > li.hover > .ab-item, #wpadminbar .ab-top-menu > li > .ab-item:focus, #wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, #wpadminbar-nojs .ab-top-menu > li.menupop:hover > .ab-item, #wpadminbar .ab-top-menu > li.menupop.hover > .ab-item {
color: #a3b745;
background: #413256; }
#wpadminbar > #wp-toolbar li:hover span.ab-label, #wpadminbar > #wp-toolbar li.hover span.ab-label, #wpadminbar > #wp-toolbar a:focus span.ab-label {
color: #a3b745; }
#wpadminbar li:hover .ab-icon:before, #wpadminbar li:hover .ab-item:before, #wpadminbar li:hover .ab-item:after, #wpadminbar li:hover #adminbarsearch:before {
color: #fff; }
/* Admin Bar: submenu */
#wpadminbar .menupop .ab-sub-wrapper {
background: #413256; }
#wpadminbar .quicklinks .menupop ul.ab-sub-secondary, #wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu {
background: #64537c; }
#wpadminbar .ab-submenu .ab-item, #wpadminbar .quicklinks .menupop ul li a, #wpadminbar .quicklinks .menupop.hover ul li a, #wpadminbar-nojs .quicklinks .menupop:hover ul li a {
color: #cbc5d3; }
#wpadminbar .quicklinks li .blavatar, #wpadminbar .menupop .menupop > .ab-item:before {
color: #ece6f6; }
#wpadminbar .quicklinks .menupop ul li a:hover, #wpadminbar .quicklinks .menupop ul li a:focus, #wpadminbar .quicklinks .menupop ul li a:hover strong, #wpadminbar .quicklinks .menupop ul li a:focus strong, #wpadminbar .quicklinks .menupop.hover ul li a:hover, #wpadminbar .quicklinks .menupop.hover ul li a:focus, #wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover, #wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus, #wpadminbar li:hover .ab-icon:before, #wpadminbar li:hover .ab-item:before, #wpadminbar li a:focus .ab-icon:before, #wpadminbar li .ab-item:focus:before, #wpadminbar li.hover .ab-icon:before, #wpadminbar li.hover .ab-item:before, #wpadminbar li:hover .ab-item:after, #wpadminbar li.hover .ab-item:after, #wpadminbar li:hover #adminbarsearch:before {
color: #a3b745; }
#wpadminbar .quicklinks li a:hover .blavatar, #wpadminbar .menupop .menupop > .ab-item:hover:before {
color: #a3b745; }
/* Admin Bar: search */
#wpadminbar #adminbarsearch:before {
color: #ece6f6; }
#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input:focus {
color: #fff;
background: #634c84; }
#wpadminbar #adminbarsearch .adminbar-input::-webkit-input-placeholder {
color: #fff;
opacity: 0.7; }
#wpadminbar #adminbarsearch .adminbar-input:-moz-placeholder {
color: #fff;
opacity: 0.7; }
#wpadminbar #adminbarsearch .adminbar-input::-moz-placeholder {
color: #fff;
opacity: 0.7; }
#wpadminbar #adminbarsearch .adminbar-input:-ms-input-placeholder {
color: #fff;
opacity: 0.7; }
/* Admin Bar: my account */
#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar > a img {
border-color: #634c84;
background-color: #634c84; }
#wpadminbar #wp-admin-bar-user-info .display-name {
color: #fff; }
#wpadminbar #wp-admin-bar-user-info a:hover .display-name {
color: #a3b745; }
#wpadminbar #wp-admin-bar-user-info .username {
color: #cbc5d3; }
/* Pointers */
.wp-pointer .wp-pointer-content h3 {
background-color: #a3b745;
border-color: #93a43e; }
.wp-pointer .wp-pointer-content h3:before {
color: #a3b745; }
.wp-pointer.wp-pointer-top .wp-pointer-arrow, .wp-pointer.wp-pointer-top .wp-pointer-arrow-inner, .wp-pointer.wp-pointer-undefined .wp-pointer-arrow, .wp-pointer.wp-pointer-undefined .wp-pointer-arrow-inner {
border-bottom-color: #a3b745; }
/* Media */
.media-item .bar, .media-progress-bar div {
background-color: #a3b745; }
.details.attachment {
-webkit-box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 7px #a3b745;
box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 7px #a3b745; }
.attachment.details .check {
background-color: #a3b745;
-webkit-box-shadow: 0 0 0 1px #fff, 0 0 0 2px #a3b745;
box-shadow: 0 0 0 1px #fff, 0 0 0 2px #a3b745; }
.media-selection .attachment.selection.details .thumbnail {
-webkit-box-shadow: 0px 0px 0px 1px #fff, 0px 0px 0px 3px #a3b745;
box-shadow: 0px 0px 0px 1px #fff, 0px 0px 0px 3px #a3b745; }
/* Themes */
.theme-browser .theme.active .theme-name, .theme-browser .theme.add-new-theme:hover:after {
background: #a3b745; }
.theme-browser .theme.add-new-theme:hover span:after {
color: #a3b745; }
.theme-section.current, .theme-filter.current {
border-bottom-color: #523f6d; }
body.more-filters-opened .more-filters {
color: #fff;
background-color: #523f6d; }
body.more-filters-opened .more-filters:before {
color: #fff; }
body.more-filters-opened .more-filters:hover, body.more-filters-opened .more-filters:focus {
background-color: #a3b745;
color: #fff; }
body.more-filters-opened .more-filters:hover:before, body.more-filters-opened .more-filters:focus:before {
color: #fff; }
/* Widgets */
.widgets-chooser li.widgets-chooser-selected {
background-color: #a3b745;
color: #fff; }
.widgets-chooser li.widgets-chooser-selected:before, .widgets-chooser li.widgets-chooser-selected:focus:before {
color: #fff; }
/* Customize */
#customize-theme-controls .widget-area-select .selected {
background-color: #a3b745;
color: #fff; }
/* jQuery UI Slider */
.wp-slider .ui-slider-handle, .wp-slider .ui-slider-handle.ui-state-hover, .wp-slider .ui-slider-handle.focus {
background: #a3b745;
border-color: #829237;
-webkit-box-shadow: inset 0 1px 0 #bfcd7b, 0 1px 0 rgba(0, 0, 0, 0.15);
box-shadow: inset 0 1px 0 #bfcd7b, 0 1px 0 rgba(0, 0, 0, 0.15); }
/* Thickbox: Plugin information */
#sidemenu a.current {
background: #f1f1f1;
border-bottom-color: #f1f1f1; }
#plugin-information .action-button {
background: #a3b745; }
/* Responsive Component */
div#wp-responsive-toggle a:before {
color: #ece6f6; }
.wp-responsive-open div#wp-responsive-toggle a {
border-color: transparent;
background: #a3b745; }
.star-rating .star {
color: #a3b745; }
.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a {
background: #413256; }
| shazadmaved/vizblog | wp-admin/css/colors/ectoplasm/colors-rtl.css | CSS | gpl-2.0 | 13,501 |
/*****************************************************************************/
// Copyright 2006-2008 Adobe Systems Incorporated
// All Rights Reserved.
//
// NOTICE: Adobe permits you to use, modify, and distribute this file in
// accordance with the terms of the Adobe license agreement accompanying it.
/*****************************************************************************/
/* $Id: //mondo/dng_sdk_1_3/dng_sdk/source/dng_pixel_buffer.cpp#1 $ */
/* $DateTime: 2009/06/22 05:04:49 $ */
/* $Change: 578634 $ */
/* $Author: tknoll $ */
/*****************************************************************************/
#include "dng_pixel_buffer.h"
#include "dng_bottlenecks.h"
#include "dng_exceptions.h"
#include "dng_flags.h"
#include "dng_tag_types.h"
#include "dng_utils.h"
/*****************************************************************************/
void OptimizeOrder (const void *&sPtr,
void *&dPtr,
uint32 sPixelSize,
uint32 dPixelSize,
uint32 &count0,
uint32 &count1,
uint32 &count2,
int32 &sStep0,
int32 &sStep1,
int32 &sStep2,
int32 &dStep0,
int32 &dStep1,
int32 &dStep2)
{
uint32 step0;
uint32 step1;
uint32 step2;
// Optimize the order for the data that is most spread out.
uint32 sRange = Abs_int32 (sStep0) * (count0 - 1) +
Abs_int32 (sStep1) * (count1 - 1) +
Abs_int32 (sStep2) * (count2 - 1);
uint32 dRange = Abs_int32 (dStep0) * (count0 - 1) +
Abs_int32 (dStep1) * (count1 - 1) +
Abs_int32 (dStep2) * (count2 - 1);
if (dRange >= sRange)
{
if (dStep0 < 0)
{
sPtr = (const void *)
(((const uint8 *) sPtr) + (int32)(count0 - 1) * sStep0 * (int32)sPixelSize);
dPtr = (void *)
(((uint8 *) dPtr) + (int32)(count0 - 1) * dStep0 * (int32)dPixelSize);
sStep0 = -sStep0;
dStep0 = -dStep0;
}
if (dStep1 < 0)
{
sPtr = (const void *)
(((const uint8 *) sPtr) + (int32)(count1 - 1) * sStep1 * (int32)sPixelSize);
dPtr = (void *)
(((uint8 *) dPtr) + (int32)(count1 - 1) * dStep1 * (int32)dPixelSize);
sStep1 = -sStep1;
dStep1 = -dStep1;
}
if (dStep2 < 0)
{
sPtr = (const void *)
(((const uint8 *) sPtr) + (int32)(count2 - 1) * sStep2 * (int32)sPixelSize);
dPtr = (void *)
(((uint8 *) dPtr) + (int32)(count2 - 1) * dStep2 * (int32)dPixelSize);
sStep2 = -sStep2;
dStep2 = -dStep2;
}
step0 = (uint32) dStep0;
step1 = (uint32) dStep1;
step2 = (uint32) dStep2;
}
else
{
if (sStep0 < 0)
{
sPtr = (const void *)
(((const uint8 *) sPtr) + (int32)(count0 - 1) * sStep0 * (int32)sPixelSize);
dPtr = (void *)
(((uint8 *) dPtr) + (int32)(count0 - 1) * dStep0 * (int32)dPixelSize);
sStep0 = -sStep0;
dStep0 = -dStep0;
}
if (sStep1 < 0)
{
sPtr = (const void *)
(((const uint8 *) sPtr) + (int32)(count1 - 1) * sStep1 * (int32)sPixelSize);
dPtr = (void *)
(((uint8 *) dPtr) + (int32)(count1 - 1) * dStep1 * (int32)dPixelSize);
sStep1 = -sStep1;
dStep1 = -dStep1;
}
if (sStep2 < 0)
{
sPtr = (const void *)
(((const uint8 *) sPtr) + (int32)(count2 - 1) * sStep2 * (int32)sPixelSize);
dPtr = (void *)
(((uint8 *) dPtr) + (int32)(count2 - 1) * dStep2 * (int32)dPixelSize);
sStep2 = -sStep2;
dStep2 = -dStep2;
}
step0 = (uint32) sStep0;
step1 = (uint32) sStep1;
step2 = (uint32) sStep2;
}
if (count0 == 1) step0 = 0xFFFFFFFF;
if (count1 == 1) step1 = 0xFFFFFFFF;
if (count2 == 1) step2 = 0xFFFFFFFF;
uint32 index0;
uint32 index1;
uint32 index2;
if (step0 >= step1)
{
if (step1 >= step2)
{
index0 = 0;
index1 = 1;
index2 = 2;
}
else if (step2 >= step0)
{
index0 = 2;
index1 = 0;
index2 = 1;
}
else
{
index0 = 0;
index1 = 2;
index2 = 1;
}
}
else
{
if (step0 >= step2)
{
index0 = 1;
index1 = 0;
index2 = 2;
}
else if (step2 >= step1)
{
index0 = 2;
index1 = 1;
index2 = 0;
}
else
{
index0 = 1;
index1 = 2;
index2 = 0;
}
}
uint32 count [3];
count [0] = count0;
count [1] = count1;
count [2] = count2;
count0 = count [index0];
count1 = count [index1];
count2 = count [index2];
int32 step [3];
step [0] = sStep0;
step [1] = sStep1;
step [2] = sStep2;
sStep0 = step [index0];
sStep1 = step [index1];
sStep2 = step [index2];
step [0] = dStep0;
step [1] = dStep1;
step [2] = dStep2;
dStep0 = step [index0];
dStep1 = step [index1];
dStep2 = step [index2];
if (sStep0 == ((int32) count1) * sStep1 &&
dStep0 == ((int32) count1) * dStep1)
{
count1 *= count0;
count0 = 1;
}
if (sStep1 == ((int32) count2) * sStep2 &&
dStep1 == ((int32) count2) * dStep2)
{
count2 *= count1;
count1 = 1;
}
}
/*****************************************************************************/
void OptimizeOrder (const void *&sPtr,
uint32 sPixelSize,
uint32 &count0,
uint32 &count1,
uint32 &count2,
int32 &sStep0,
int32 &sStep1,
int32 &sStep2)
{
void *dPtr = NULL;
int32 dStep0 = sStep0;
int32 dStep1 = sStep1;
int32 dStep2 = sStep2;
OptimizeOrder (sPtr,
dPtr,
sPixelSize,
sPixelSize,
count0,
count1,
count2,
sStep0,
sStep1,
sStep2,
dStep0,
dStep1,
dStep2);
}
/*****************************************************************************/
void OptimizeOrder (void *&dPtr,
uint32 dPixelSize,
uint32 &count0,
uint32 &count1,
uint32 &count2,
int32 &dStep0,
int32 &dStep1,
int32 &dStep2)
{
const void *sPtr = NULL;
int32 sStep0 = dStep0;
int32 sStep1 = dStep1;
int32 sStep2 = dStep2;
OptimizeOrder (sPtr,
dPtr,
dPixelSize,
dPixelSize,
count0,
count1,
count2,
sStep0,
sStep1,
sStep2,
dStep0,
dStep1,
dStep2);
}
/*****************************************************************************/
dng_pixel_buffer::dng_pixel_buffer ()
: fArea ()
, fPlane (0)
, fPlanes (1)
, fRowStep (1)
, fColStep (1)
, fPlaneStep (1)
, fPixelType (ttUndefined)
, fPixelSize (0)
, fData (NULL)
, fDirty (true)
{
}
/*****************************************************************************/
dng_pixel_buffer::dng_pixel_buffer (const dng_pixel_buffer &buffer)
: fArea (buffer.fArea)
, fPlane (buffer.fPlane)
, fPlanes (buffer.fPlanes)
, fRowStep (buffer.fRowStep)
, fColStep (buffer.fColStep)
, fPlaneStep (buffer.fPlaneStep)
, fPixelType (buffer.fPixelType)
, fPixelSize (buffer.fPixelSize)
, fData (buffer.fData)
, fDirty (buffer.fDirty)
{
}
/*****************************************************************************/
dng_pixel_buffer & dng_pixel_buffer::operator= (const dng_pixel_buffer &buffer)
{
fArea = buffer.fArea;
fPlane = buffer.fPlane;
fPlanes = buffer.fPlanes;
fRowStep = buffer.fRowStep;
fColStep = buffer.fColStep;
fPlaneStep = buffer.fPlaneStep;
fPixelType = buffer.fPixelType;
fPixelSize = buffer.fPixelSize;
fPixelType = buffer.fPixelType;
fData = buffer.fData;
fDirty = buffer.fDirty;
return *this;
}
/*****************************************************************************/
dng_pixel_buffer::~dng_pixel_buffer ()
{
}
/*****************************************************************************/
#if qDebugPixelType
void dng_pixel_buffer::CheckPixelType (uint32 pixelType) const
{
if (fPixelType != pixelType)
{
DNG_REPORT ("Pixel type access mismatch");
}
}
#endif
/*****************************************************************************/
uint32 dng_pixel_buffer::PixelRange () const
{
switch (fPixelType)
{
case ttByte:
case ttSByte:
{
return 0x0FF;
}
case ttShort:
case ttSShort:
{
return 0x0FFFF;
}
case ttLong:
case ttSLong:
{
return 0xFFFFFFFF;
}
default:
break;
}
return 0;
}
/*****************************************************************************/
void dng_pixel_buffer::SetConstant (const dng_rect &area,
uint32 plane,
uint32 planes,
uint32 value)
{
uint32 rows = area.H ();
uint32 cols = area.W ();
void *dPtr = DirtyPixel (area.t,
area.l,
plane);
int32 dRowStep = fRowStep;
int32 dColStep = fColStep;
int32 dPlaneStep = fPlaneStep;
OptimizeOrder (dPtr,
fPixelSize,
rows,
cols,
planes,
dRowStep,
dColStep,
dPlaneStep);
switch (fPixelSize)
{
case 1:
{
if (rows == 1 && cols == 1 && dPlaneStep == 1 && value == 0)
{
DoZeroBytes (dPtr, planes);
}
else
{
DoSetArea8 ((uint8 *) dPtr,
(uint8) value,
rows,
cols,
planes,
dRowStep,
dColStep,
dPlaneStep);
}
break;
}
case 2:
{
if (rows == 1 && cols == 1 && dPlaneStep == 1 && value == 0)
{
DoZeroBytes (dPtr, planes << 1);
}
else
{
DoSetArea16 ((uint16 *) dPtr,
(uint16) value,
rows,
cols,
planes,
dRowStep,
dColStep,
dPlaneStep);
}
break;
}
case 4:
{
if (rows == 1 && cols == 1 && dPlaneStep == 1 && value == 0)
{
DoZeroBytes (dPtr, planes << 2);
}
else
{
DoSetArea32 ((uint32 *) dPtr,
value,
rows,
cols,
planes,
dRowStep,
dColStep,
dPlaneStep);
}
break;
}
default:
{
ThrowNotYetImplemented ();
break;
}
}
}
/*****************************************************************************/
void dng_pixel_buffer::SetZero (const dng_rect &area,
uint32 plane,
uint32 planes)
{
uint32 value = 0;
switch (fPixelType)
{
case ttByte:
case ttShort:
case ttLong:
case ttFloat:
{
break;
}
case ttSShort:
{
value = 0x8000;
break;
}
default:
{
ThrowNotYetImplemented ();
break;
}
}
SetConstant (area,
plane,
planes,
value);
}
/*****************************************************************************/
void dng_pixel_buffer::CopyArea (const dng_pixel_buffer &src,
const dng_rect &area,
uint32 srcPlane,
uint32 dstPlane,
uint32 planes)
{
uint32 rows = area.H ();
uint32 cols = area.W ();
const void *sPtr = src.ConstPixel (area.t,
area.l,
srcPlane);
void *dPtr = DirtyPixel (area.t,
area.l,
dstPlane);
int32 sRowStep = src.fRowStep;
int32 sColStep = src.fColStep;
int32 sPlaneStep = src.fPlaneStep;
int32 dRowStep = fRowStep;
int32 dColStep = fColStep;
int32 dPlaneStep = fPlaneStep;
OptimizeOrder (sPtr,
dPtr,
src.fPixelSize,
fPixelSize,
rows,
cols,
planes,
sRowStep,
sColStep,
sPlaneStep,
dRowStep,
dColStep,
dPlaneStep);
if (fPixelType == src.fPixelType)
{
if (rows == 1 && cols == 1 && sPlaneStep == 1 && dPlaneStep == 1)
{
DoCopyBytes (sPtr,
dPtr,
planes * fPixelSize);
}
else switch (fPixelSize)
{
case 1:
{
DoCopyArea8 ((const uint8 *) sPtr,
(uint8 *) dPtr,
rows,
cols,
planes,
sRowStep,
sColStep,
sPlaneStep,
dRowStep,
dColStep,
dPlaneStep);
break;
}
case 2:
{
DoCopyArea16 ((const uint16 *) sPtr,
(uint16 *) dPtr,
rows,
cols,
planes,
sRowStep,
sColStep,
sPlaneStep,
dRowStep,
dColStep,
dPlaneStep);
break;
}
case 4:
{
DoCopyArea32 ((const uint32 *) sPtr,
(uint32 *) dPtr,
rows,
cols,
planes,
sRowStep,
sColStep,
sPlaneStep,
dRowStep,
dColStep,
dPlaneStep);
break;
}
default:
{
ThrowNotYetImplemented ();
break;
}
}
}
else if (src.fPixelType == ttByte)
{
switch (fPixelType)
{
case ttShort:
{
DoCopyArea8_16 ((const uint8 *) sPtr,
(uint16 *) dPtr,
rows,
cols,
planes,
sRowStep,
sColStep,
sPlaneStep,
dRowStep,
dColStep,
dPlaneStep);
break;
}
case ttSShort:
{
DoCopyArea8_S16 ((const uint8 *) sPtr,
(int16 *) dPtr,
rows,
cols,
planes,
sRowStep,
sColStep,
sPlaneStep,
dRowStep,
dColStep,
dPlaneStep);
break;
}
case ttLong:
{
DoCopyArea8_32 ((const uint8 *) sPtr,
(uint32 *) dPtr,
rows,
cols,
planes,
sRowStep,
sColStep,
sPlaneStep,
dRowStep,
dColStep,
dPlaneStep);
break;
}
case ttFloat:
{
DoCopyArea8_R32 ((const uint8 *) sPtr,
(real32 *) dPtr,
rows,
cols,
planes,
sRowStep,
sColStep,
sPlaneStep,
dRowStep,
dColStep,
dPlaneStep,
src.PixelRange ());
break;
}
default:
{
ThrowNotYetImplemented ();
break;
}
}
}
else if (src.fPixelType == ttShort)
{
switch (fPixelType)
{
case ttByte:
{
DoCopyArea8 (((const uint8 *) sPtr) + (qDNGBigEndian ? 1 : 0),
(uint8 *) dPtr,
rows,
cols,
planes,
sRowStep << 1,
sColStep << 1,
sPlaneStep << 1,
dRowStep,
dColStep,
dPlaneStep);
break;
}
case ttSShort:
{
DoCopyArea16_S16 ((const uint16 *) sPtr,
(int16 *) dPtr,
rows,
cols,
planes,
sRowStep,
sColStep,
sPlaneStep,
dRowStep,
dColStep,
dPlaneStep);
break;
}
case ttLong:
{
DoCopyArea16_32 ((const uint16 *) sPtr,
(uint32 *) dPtr,
rows,
cols,
planes,
sRowStep,
sColStep,
sPlaneStep,
dRowStep,
dColStep,
dPlaneStep);
break;
}
case ttFloat:
{
DoCopyArea16_R32 ((const uint16 *) sPtr,
(real32 *) dPtr,
rows,
cols,
planes,
sRowStep,
sColStep,
sPlaneStep,
dRowStep,
dColStep,
dPlaneStep,
src.PixelRange ());
break;
}
default:
{
ThrowNotYetImplemented ();
break;
}
}
}
else if (src.fPixelType == ttSShort)
{
switch (fPixelType)
{
case ttByte:
{
DoCopyArea8 (((const uint8 *) sPtr) + (qDNGBigEndian ? 1 : 0),
(uint8 *) dPtr,
rows,
cols,
planes,
sRowStep << 1,
sColStep << 1,
sPlaneStep << 1,
dRowStep,
dColStep,
dPlaneStep);
break;
}
case ttShort:
{
// Moving between signed 16 bit values and unsigned 16
// bit values just requires toggling the sign bit. So
// we can use the "backwards" bottleneck.
DoCopyArea16_S16 ((const uint16 *) sPtr,
(int16 *) dPtr,
rows,
cols,
planes,
sRowStep,
sColStep,
sPlaneStep,
dRowStep,
dColStep,
dPlaneStep);
break;
}
case ttFloat:
{
DoCopyAreaS16_R32 ((const int16 *) sPtr,
(real32 *) dPtr,
rows,
cols,
planes,
sRowStep,
sColStep,
sPlaneStep,
dRowStep,
dColStep,
dPlaneStep,
src.PixelRange ());
break;
}
default:
{
ThrowNotYetImplemented ();
break;
}
}
}
else if (src.fPixelType == ttLong)
{
switch (fPixelType)
{
case ttByte:
{
DoCopyArea8 (((const uint8 *) sPtr) + (qDNGBigEndian ? 3 : 0),
(uint8 *) dPtr,
rows,
cols,
planes,
sRowStep << 2,
sColStep << 2,
sPlaneStep << 2,
dRowStep,
dColStep,
dPlaneStep);
break;
}
case ttShort:
{
DoCopyArea16 (((const uint16 *) sPtr) + (qDNGBigEndian ? 1 : 0),
(uint16 *) dPtr,
rows,
cols,
planes,
sRowStep << 1,
sColStep << 1,
sPlaneStep << 1,
dRowStep,
dColStep,
dPlaneStep);
break;
}
default:
{
ThrowNotYetImplemented ();
break;
}
}
}
else if (src.fPixelType == ttFloat)
{
switch (fPixelType)
{
case ttByte:
{
DoCopyAreaR32_8 ((const real32 *) sPtr,
(uint8 *) dPtr,
rows,
cols,
planes,
sRowStep,
sColStep,
sPlaneStep,
dRowStep,
dColStep,
dPlaneStep,
PixelRange ());
break;
}
case ttShort:
{
DoCopyAreaR32_16 ((const real32 *) sPtr,
(uint16 *) dPtr,
rows,
cols,
planes,
sRowStep,
sColStep,
sPlaneStep,
dRowStep,
dColStep,
dPlaneStep,
PixelRange ());
break;
}
case ttSShort:
{
DoCopyAreaR32_S16 ((const real32 *) sPtr,
(int16 *) dPtr,
rows,
cols,
planes,
sRowStep,
sColStep,
sPlaneStep,
dRowStep,
dColStep,
dPlaneStep,
PixelRange ());
break;
}
default:
{
ThrowNotYetImplemented ();
break;
}
}
}
else
{
ThrowNotYetImplemented ();
}
}
/*****************************************************************************/
dng_point dng_pixel_buffer::RepeatPhase (const dng_rect &srcArea,
const dng_rect &dstArea)
{
int32 repeatV = srcArea.H ();
int32 repeatH = srcArea.W ();
int32 phaseV;
int32 phaseH;
if (srcArea.t >= dstArea.t)
{
phaseV = (repeatV - ((srcArea.t - dstArea.t) % repeatV)) % repeatV;
}
else
{
phaseV = (dstArea.t - srcArea.t) % repeatV;
}
if (srcArea.l >= dstArea.l)
{
phaseH = (repeatH - ((srcArea.l - dstArea.l) % repeatH)) % repeatH;
}
else
{
phaseH = (dstArea.l - srcArea.l) % repeatH;
}
return dng_point (phaseV, phaseH);
}
/*****************************************************************************/
void dng_pixel_buffer::RepeatArea (const dng_rect &srcArea,
const dng_rect &dstArea)
{
dng_point repeat = srcArea.Size ();
dng_point phase = RepeatPhase (srcArea,
dstArea);
const void *sPtr = ConstPixel (srcArea.t,
srcArea.l,
fPlane);
void *dPtr = DirtyPixel (dstArea.t,
dstArea.l,
fPlane);
uint32 rows = dstArea.H ();
uint32 cols = dstArea.W ();
switch (fPixelSize)
{
case 1:
{
DoRepeatArea8 ((const uint8 *) sPtr,
(uint8 *) dPtr,
rows,
cols,
fPlanes,
fRowStep,
fColStep,
fPlaneStep,
repeat.v,
repeat.h,
phase.v,
phase.h);
break;
}
case 2:
{
DoRepeatArea16 ((const uint16 *) sPtr,
(uint16 *) dPtr,
rows,
cols,
fPlanes,
fRowStep,
fColStep,
fPlaneStep,
repeat.v,
repeat.h,
phase.v,
phase.h);
break;
}
case 4:
{
DoRepeatArea32 ((const uint32 *) sPtr,
(uint32 *) dPtr,
rows,
cols,
fPlanes,
fRowStep,
fColStep,
fPlaneStep,
repeat.v,
repeat.h,
phase.v,
phase.h);
break;
}
default:
{
ThrowNotYetImplemented ();
break;
}
}
}
/*****************************************************************************/
void dng_pixel_buffer::RepeatSubArea (const dng_rect subArea,
uint32 repeatV,
uint32 repeatH)
{
if (fArea.t < subArea.t)
{
RepeatArea (dng_rect (subArea.t , fArea.l,
subArea.t + repeatV, fArea.r),
dng_rect (fArea.t , fArea.l,
subArea.t , fArea.r));
}
if (fArea.b > subArea.b)
{
RepeatArea (dng_rect (subArea.b - repeatV, fArea.l,
subArea.b , fArea.r),
dng_rect (subArea.b , fArea.l,
fArea.b , fArea.r));
}
if (fArea.l < subArea.l)
{
RepeatArea (dng_rect (fArea.t, subArea.l ,
fArea.b, subArea.l + repeatH),
dng_rect (fArea.t, fArea.l ,
fArea.b, subArea.l ));
}
if (fArea.r > subArea.r)
{
RepeatArea (dng_rect (fArea.t, subArea.r - repeatH,
fArea.b, subArea.r ),
dng_rect (fArea.t, subArea.r ,
fArea.b, fArea.r ));
}
}
/*****************************************************************************/
void dng_pixel_buffer::ShiftRight (uint32 shift)
{
if (fPixelType != ttShort)
{
ThrowNotYetImplemented ();
}
uint32 rows = fArea.H ();
uint32 cols = fArea.W ();
uint32 planes = fPlanes;
void *dPtr = DirtyPixel (fArea.t,
fArea.l,
fPlane);
const void *sPtr = dPtr;
int32 sRowStep = fRowStep;
int32 sColStep = fColStep;
int32 sPlaneStep = fPlaneStep;
int32 dRowStep = fRowStep;
int32 dColStep = fColStep;
int32 dPlaneStep = fPlaneStep;
OptimizeOrder (sPtr,
dPtr,
fPixelSize,
fPixelSize,
rows,
cols,
planes,
sRowStep,
sColStep,
sPlaneStep,
dRowStep,
dColStep,
dPlaneStep);
DoShiftRight16 ((uint16 *) dPtr,
rows,
cols,
planes,
dRowStep,
dColStep,
dPlaneStep,
shift);
}
/*****************************************************************************/
void dng_pixel_buffer::FlipH ()
{
fData = InternalPixel (fArea.t, fArea.r - 1);
fColStep = -fColStep;
}
/*****************************************************************************/
void dng_pixel_buffer::FlipV ()
{
fData = InternalPixel (fArea.b - 1, fArea.l);
fRowStep = -fRowStep;
}
/*****************************************************************************/
void dng_pixel_buffer::FlipZ ()
{
fData = InternalPixel (fArea.t, fArea.l, fPlanes - 1);
fPlaneStep = -fPlaneStep;
}
/*****************************************************************************/
bool dng_pixel_buffer::EqualArea (const dng_pixel_buffer &src,
const dng_rect &area,
uint32 plane,
uint32 planes) const
{
uint32 rows = area.H ();
uint32 cols = area.W ();
const void *sPtr = src.ConstPixel (area.t,
area.l,
plane);
const void *dPtr = ConstPixel (area.t,
area.l,
plane);
int32 sRowStep = src.fRowStep;
int32 sColStep = src.fColStep;
int32 sPlaneStep = src.fPlaneStep;
int32 dRowStep = fRowStep;
int32 dColStep = fColStep;
int32 dPlaneStep = fPlaneStep;
if (fPixelType == src.fPixelType)
{
if (rows == 1 && cols == 1 && sPlaneStep == 1 && dPlaneStep == 1)
{
return DoEqualBytes (sPtr,
dPtr,
planes * fPixelSize);
}
else switch (fPixelSize)
{
case 1:
{
return DoEqualArea8 ((const uint8 *) sPtr,
(const uint8 *) dPtr,
rows,
cols,
planes,
sRowStep,
sColStep,
sPlaneStep,
dRowStep,
dColStep,
dPlaneStep);
break;
}
case 2:
{
return DoEqualArea16 ((const uint16 *) sPtr,
(const uint16 *) dPtr,
rows,
cols,
planes,
sRowStep,
sColStep,
sPlaneStep,
dRowStep,
dColStep,
dPlaneStep);
break;
}
case 4:
{
return DoEqualArea32 ((const uint32 *) sPtr,
(const uint32 *) dPtr,
rows,
cols,
planes,
sRowStep,
sColStep,
sPlaneStep,
dRowStep,
dColStep,
dPlaneStep);
break;
}
default:
{
ThrowNotYetImplemented ();
return false;
}
}
}
else
return false;
}
/*****************************************************************************/
namespace
{
template <typename T>
real64 MaxDiff (const T *src1,
int32 s1RowStep,
int32 s1PlaneStep,
const T *src2,
int32 s2RowStep,
int32 s2PlaneStep,
uint32 rows,
uint32 cols,
uint32 planes)
{
real64 result = 0.0;
for (uint32 plane = 0; plane < planes; plane++)
{
const T *src1Save = src1;
const T *src2Save = src2;
for (uint32 row = 0; row < rows; row++)
{
for (uint32 col = 0; col < cols; col++)
{
real64 diff = fabs ((real64)src1 [col] - src2 [col]);
if (diff > result)
result = diff;
}
src1 += s1RowStep;
src2 += s2RowStep;
}
src1 = src1Save + s1PlaneStep;
src2 = src2Save + s2PlaneStep;
}
return result;
}
template <typename T>
real64 MaxDiff (const T *src1,
int32 s1ColStep,
int32 s1RowStep,
int32 s1PlaneStep,
const T *src2,
int32 s2ColStep,
int32 s2RowStep,
int32 s2PlaneStep,
uint32 rows,
uint32 cols,
uint32 planes)
{
if (s1ColStep == s2ColStep &&
s1ColStep == 1)
return MaxDiff (src1,
s1RowStep,
s1PlaneStep,
src2,
s2RowStep,
s2PlaneStep,
rows,
cols,
planes);
real64 result = 0.0;
for (uint32 plane = 0; plane < planes; plane++)
{
const T *src1Save = src1;
const T *src2Save = src2;
for (uint32 row = 0; row < rows; row++)
{
for (uint32 col = 0; col < cols; col++)
{
real64 diff = fabs ((real64)src1 [col * s1ColStep] - src2 [col * s2ColStep]);
if (diff > result)
result = diff;
}
src1 += s1RowStep;
src2 += s2RowStep;
}
src1 = src1Save + s1PlaneStep;
src2 = src2Save + s2PlaneStep;
}
return result;
}
};
real64 dng_pixel_buffer::MaximumDifference (const dng_pixel_buffer &rhs,
const dng_rect &area,
uint32 plane,
uint32 planes) const
{
uint32 rows = area.H ();
uint32 cols = area.W ();
const void *s1Ptr = rhs.ConstPixel (area.t,
area.l,
plane);
const void *s2Ptr = ConstPixel (area.t,
area.l,
plane);
int32 s1RowStep = rhs.fRowStep;
int32 s1ColStep = rhs.fColStep;
int32 s1PlaneStep = rhs.fPlaneStep;
int32 s2RowStep = fRowStep;
int32 s2ColStep = fColStep;
int32 s2PlaneStep = fPlaneStep;
if (fPixelType == rhs.fPixelType)
{
switch (fPixelType)
{
case ttByte:
return MaxDiff ((const uint8 *)s1Ptr,
s1ColStep,
s1RowStep,
s1PlaneStep,
(const uint8 *)s2Ptr,
s2ColStep,
s2RowStep,
s2PlaneStep,
rows,
cols,
planes);
break;
case ttShort:
return MaxDiff ((const uint16 *)s1Ptr,
s1ColStep,
s1RowStep,
s1PlaneStep,
(const uint16 *)s2Ptr,
s2ColStep,
s2RowStep,
s2PlaneStep,
rows,
cols,
planes);
break;
case ttLong:
return MaxDiff ((const uint32 *)s1Ptr,
s1ColStep,
s1RowStep,
s1PlaneStep,
(const uint32 *)s2Ptr,
s2ColStep,
s2RowStep,
s2PlaneStep,
rows,
cols,
planes);
break;
case ttSByte:
return MaxDiff ((const int8 *)s1Ptr,
s1ColStep,
s1RowStep,
s1PlaneStep,
(const int8 *)s2Ptr,
s2ColStep,
s2RowStep,
s2PlaneStep,
rows,
cols,
planes);
break;
case ttSShort:
return MaxDiff ((const int16 *)s1Ptr,
s1ColStep,
s1RowStep,
s1PlaneStep,
(const int16 *)s2Ptr,
s2ColStep,
s2RowStep,
s2PlaneStep,
rows,
cols,
planes);
break;
case ttSLong:
return MaxDiff ((const int32 *)s1Ptr,
s1ColStep,
s1RowStep,
s1PlaneStep,
(const int32 *)s2Ptr,
s2ColStep,
s2RowStep,
s2PlaneStep,
rows,
cols,
planes);
break;
case ttFloat:
return MaxDiff ((const real32 *)s1Ptr,
s1ColStep,
s1RowStep,
s1PlaneStep,
(const real32 *)s2Ptr,
s2ColStep,
s2RowStep,
s2PlaneStep,
rows,
cols,
planes);
break;
case ttDouble:
return MaxDiff ((const real64 *)s1Ptr,
s1ColStep,
s1RowStep,
s1PlaneStep,
(const real64 *)s2Ptr,
s2ColStep,
s2RowStep,
s2PlaneStep,
rows,
cols,
planes);
break;
default:
{
ThrowNotYetImplemented ();
return 0.0;
}
}
}
else
ThrowProgramError ("attempt to difference pixel buffers of different formats.");
return 0.0;
}
/*****************************************************************************/
| centic9/digikam-ppa | extra/kipi-plugins/dngconverter/dngwriter/extra/dng_sdk/dng_pixel_buffer.cpp | C++ | gpl-2.0 | 31,094 |
#
# \brief Makefile for building the Qt4 tools
# \author Christian Prochaska
# \author Norman Feske
# \date 2009-05-15
#
REP_DIR := $(realpath ..)
include $(REP_DIR)/lib/mk/qt_version.inc
#
# Compound rule for building the tools in the right order
#
all: qmake/qmake moc/moc rcc/rcc uic/uic
#
# Determine qmakespec to be passed to the sub makefiles
#
HOST_ARCH := $(shell uname -m)
ifneq ($(HOST_ARCH),x86_64)
HOST_ARCH=x86
endif
QMAKESPEC = $(REP_DIR)/contrib/$(QT4)/mkspecs/qws/linux-$(HOST_ARCH)-g++
#
# Build qmake
#
qmake/qmake:
QMAKESPEC=$(QMAKESPEC) make -C qmake
#
# Build the other tools using qmake
#
vpath bootstrap.pro $(REP_DIR)/contrib/$(QT4)/src/tools/bootstrap
vpath moc.pro $(REP_DIR)/contrib/$(QT4)/src/tools/moc
vpath rcc.pro $(REP_DIR)/contrib/$(QT4)/src/tools/rcc
vpath uic.pro $(REP_DIR)/contrib/$(QT4)/src/tools/uic
bootstrap/libbootstrap.a: bootstrap/Makefile
make -C bootstrap
moc/moc: moc/Makefile bootstrap/libbootstrap.a
make -C moc
rcc/rcc: rcc/Makefile bootstrap/libbootstrap.a
make -C rcc
uic/uic: uic/Makefile bootstrap/libbootstrap.a
make -C uic
#
# Rule to generate tool Makefiles from the respective pro files via qmake
#
# The second include path is required to resolve the Genode-specific
# 'gconfig.cpp' file. Even though this is a 'cpp' file, it is used via
# '#include'. So we have to make its location known to the 'INCLUDEPATH'.
#
%/Makefile: %.pro
mkdir -p $*
QMAKESPEC=$(QMAKESPEC) qmake/qmake -o $*/Makefile \
QT_BUILD_TREE=$(REP_DIR)/contrib/$(QT4) \
INCLUDEPATH+=$(REP_DIR)/include/qt4 \
INCLUDEPATH+=$(REP_DIR)/include/qt4/QtCore \
INCLUDEPATH+=$(REP_DIR)/src/lib/qt4/src/corelib/global \
-after DESTDIR= \
-after LIBS+=-L../bootstrap\
$^
#
# Clean rule
#
clean:
make -C qmake clean
rm -rf bootstrap moc rcc uic
distclean: clean
| mohammadhamad/mhhgen | repos/qt4/tool/Makefile | Makefile | gpl-2.0 | 1,836 |
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Zend Gdata API Documentation</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta><link rel="stylesheet" href="css/black-tie/jquery-ui-1.8.2.custom.css" type="text/css"></link><link rel="stylesheet" href="css/jquery.treeview.css" type="text/css"></link><link rel="stylesheet" href="css/theme.css" type="text/css"></link><script type="text/javascript" src="js/jquery-1.4.2.min.js"></script><script type="text/javascript" src="js/jquery-ui-1.8.2.custom.min.js"></script><script type="text/javascript" src="js/jquery.cookie.js"></script><script type="text/javascript" src="js/jquery.treeview.js"></script><script type="text/javascript">
$(document).ready(function() {
$(".filetree").treeview({
collapsed: true,
persist: "cookie"
});
$("#accordion").accordion({
collapsible: true,
autoHeight: false,
fillSpace: true
});
$(".tabs").tabs();
});
</script></head><body><div xmlns="" class="content">
<div class="sub-page-main-header-api-documentation"><h2>API Documentation</h2></div>
<div class="dotted-line"></div>
</div>
<div xmlns="" id="content">
<script type="text/javascript" src="js/menu.js"></script><script>
$(document).ready(function() {
$('a.gripper').click(function() {
$(this).nextAll('div.code-tabs').slideToggle();
$(this).children('img').toggle();
return false;
});
$('div.code-tabs').hide();
$('a.gripper').show();
$('div.file-nav').show();
});
</script><h1 class="file">Gdata/Photos/AlbumQuery.php</h1>
<div class="file-nav"><ul id="file-nav">
<li><a href="#top">Global</a></li>
<li>
<a href="#classes"><img src="images/icons/class.png" height="14">
Classes
</a><ul><li><a href="#%5CZend_Gdata_Photos_AlbumQuery">\Zend_Gdata_Photos_AlbumQuery</a></li></ul>
</li>
</ul></div>
<a name="top"></a><div id="file-description">
<p class="short-description">Zend Framework</p>
<div class="long-description"><p>LICENSE</p>
<p>This source file is subject to the new BSD license that is bundled
with this package in the file LICENSE.txt.
It is also available through the world-wide-web at this URL:
http://framework.zend.com/license/new-bsd
If you did not receive a copy of the license and are unable to
obtain it through the world-wide-web, please send an email
to license@zend.com so we can send you a copy immediately.</p>
</div>
</div>
<dl class="file-info">
<dt>category</dt>
<dd>Zend
</dd>
<dt>copyright</dt>
<dd>Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
</dd>
<dt>license</dt>
<dd>
<a href="http://framework.zend.com/license/new-bsd">New BSD License</a>
</dd>
<dt>package</dt>
<dd>Zend_Gdata
</dd>
<dt>subpackage</dt>
<dd>Photos
</dd>
<dt>version</dt>
<dd>$Id: AlbumQuery.php 23775 2011-03-01 17:25:24Z ralph $
</dd>
</dl>
<a name="classes"></a><a id="\Zend_Gdata_Photos_AlbumQuery"></a><h2 class="class">\Zend_Gdata_Photos_AlbumQuery<div class="to-top"><a href="#top">jump to top</a></div>
</h2>
<div class="class">
<p class="short-description">Assists in constructing album queries for various entries.</p>
<div class="long-description"><p>Instances of this class can be provided in many places where a URL is
required.</p>
<p>For information on submitting queries to a server, see the service
class, Zend_Gdata_Photos.</p>
</div>
<dl class="class-info">
<dt>Extends from</dt>
<dd><a href="db_Gdata_Photos_UserQuery.html#%5CZend_Gdata_Photos_UserQuery">\Zend_Gdata_Photos_UserQuery</a></dd>
<dt>category</dt>
<dd>Zend
</dd>
<dt>copyright</dt>
<dd>Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
</dd>
<dt>license</dt>
<dd>
<a href="http://framework.zend.com/license/new-bsd">New BSD License</a>
</dd>
<dt>package</dt>
<dd>Zend_Gdata
</dd>
<dt>subpackage</dt>
<dd>Photos
</dd>
</dl>
<h3>Properties</h3>
<div>
<a id="\Zend_Gdata_Photos_AlbumQuery::$_albumId"></a><div class="property">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/property.png" alt="Property"><img src="images/icons/visibility_protected.png" style="margin-right: 5px" alt="protected">string
<span class="highlight">$_albumId</span>= 'null'
</code><div class="description">
<p class="short-description">The ID of the album to query for. Mutually exclusive with AlbumName.</p></div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Default value</strong><code>null</code><strong>Details</strong><dl class="property-info">
<dt>Type</dt>
<dd>string</dd>
</dl>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::$_albumName"></a><div class="property">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/property.png" alt="Property"><img src="images/icons/visibility_protected.png" style="margin-right: 5px" alt="protected">string
<span class="highlight">$_albumName</span>= 'null'
</code><div class="description">
<p class="short-description">The name of the album to query for. Mutually exclusive with AlbumId.</p></div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Default value</strong><code>null</code><strong>Details</strong><dl class="property-info">
<dt>Type</dt>
<dd>string</dd>
</dl>
</div>
<div class="clear"></div>
</div>
</div>
<h3>Methods</h3>
<div>
<a id="\Zend_Gdata_Photos_AlbumQuery::__construct()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">__construct</span><span class="nb-faded-text">(
)
</span>
:
void</code><div class="description">
<p class="short_description">Create a new Query object with default values.</p>
<small>Inherited from:
<a href="db_Gdata_Photos_UserQuery.html#%5CZend_Gdata_Photos_UserQuery::__construct()">\Zend_Gdata_Photos_UserQuery::__construct()</a></small>
</div>
<div class="code-tabs"><div class="long-description">
</div></div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::__get()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">__get</span><span class="nb-faded-text">(
$name
)
</span>
:
void</code><div class="description">
<p class="short_description"></p>
<small>Inherited from:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query::__get()">\Zend_Gdata_Query::__get()</a></small>
</div>
<div class="code-tabs">
<strong>Parameters</strong><table class="argument-info">
<thead><tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<th>$name</th>
<td></td>
<td><em></em></td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::__set()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">__set</span><span class="nb-faded-text">(
$name, $val
)
</span>
:
void</code><div class="description">
<p class="short_description"></p>
<small>Inherited from:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query::__set()">\Zend_Gdata_Query::__set()</a></small>
</div>
<div class="code-tabs">
<strong>Parameters</strong><table class="argument-info">
<thead><tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<th>$name</th>
<td></td>
<td><em></em></td>
</tr>
<tr>
<th>$val</th>
<td></td>
<td><em></em></td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::getAccess()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">getAccess</span><span class="nb-faded-text">(
)
</span>
:
string</code><div class="description">
<p class="short_description">Get the visibility filter for entries returned.</p>
<small>Inherited from:
<a href="db_Gdata_Photos_UserQuery.html#%5CZend_Gdata_Photos_UserQuery::getAccess()">\Zend_Gdata_Photos_UserQuery::getAccess()</a></small>
</div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td>string</td>
<td>The visibility to filter by, or null for the default user.</td>
</tr>
</table>
<strong>Details</strong><dl class="function-info">
<dt>see</dt>
<dd>\setAccess
</dd>
</dl>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::getAlbumId()"></a><div class="method">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">getAlbumId</span><span class="nb-faded-text">(
)
</span>
:
string</code><div class="description"><p class="short_description">Get the album ID which is to be returned.</p></div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td>string</td>
<td>The ID of the album to retrieve.</td>
</tr>
</table>
<strong>Details</strong><dl class="function-info">
<dt>see</dt>
<dd>\setAlbum
</dd>
</dl>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::getAlbumName()"></a><div class="method">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">getAlbumName</span><span class="nb-faded-text">(
)
</span>
:
string</code><div class="description"><p class="short_description">Get the album name which is to be returned.</p></div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td>string</td>
<td>The name of the album to retrieve.</td>
</tr>
</table>
<strong>Details</strong><dl class="function-info">
<dt>see</dt>
<dd>\setAlbumName
</dd>
</dl>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::getAlt()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">getAlt</span><span class="nb-faded-text">(
)
</span>
:
string</code><div class="description">
<p class="short_description"></p>
<small>Inherited from:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query::getAlt()">\Zend_Gdata_Query::getAlt()</a></small>
</div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td>string</td>
<td>rss or atom</td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::getAuthor()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">getAuthor</span><span class="nb-faded-text">(
)
</span>
:
string</code><div class="description">
<p class="short_description"></p>
<small>Inherited from:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query::getAuthor()">\Zend_Gdata_Query::getAuthor()</a></small>
</div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td>string</td>
<td>author</td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::getCategory()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">getCategory</span><span class="nb-faded-text">(
)
</span>
:
void</code><div class="description">
<p class="short_description"></p>
<small>Inherited from:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query::getCategory()">\Zend_Gdata_Query::getCategory()</a></small>
</div>
<div class="code-tabs"></div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::getImgMax()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">getImgMax</span><span class="nb-faded-text">(
)
</span>
:
string</code><div class="description">
<p class="short_description">Get the maximum image size filter for entries returned.</p>
<small>Inherited from:
<a href="db_Gdata_Photos_UserQuery.html#%5CZend_Gdata_Photos_UserQuery::getImgMax()">\Zend_Gdata_Photos_UserQuery::getImgMax()</a></small>
</div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td>string</td>
<td>The image size size to filter by, or null if no filter is to be applied.</td>
</tr>
</table>
<strong>Details</strong><dl class="function-info">
<dt>see</dt>
<dd>\setImgMax
</dd>
</dl>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::getKind()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">getKind</span><span class="nb-faded-text">(
)
</span>
:
string</code><div class="description">
<p class="short_description">Get the kind of entries to be returned.</p>
<small>Inherited from:
<a href="db_Gdata_Photos_UserQuery.html#%5CZend_Gdata_Photos_UserQuery::getKind()">\Zend_Gdata_Photos_UserQuery::getKind()</a></small>
</div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td>string</td>
<td>The kind to filter by, or null if no filter is to be applied.</td>
</tr>
</table>
<strong>Details</strong><dl class="function-info">
<dt>see</dt>
<dd>\setKind
</dd>
</dl>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::getMaxResults()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">getMaxResults</span><span class="nb-faded-text">(
)
</span>
:
int</code><div class="description">
<p class="short_description"></p>
<small>Inherited from:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query::getMaxResults()">\Zend_Gdata_Query::getMaxResults()</a></small>
</div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td>int</td>
<td>maxResults</td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::getParam()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">getParam</span><span class="nb-faded-text">(
string $name
)
</span>
:
void</code><div class="description">
<p class="short_description"></p>
<small>Inherited from:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query::getParam()">\Zend_Gdata_Query::getParam()</a></small>
</div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Parameters</strong><table class="argument-info">
<thead><tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<th>$name</th>
<td>string</td>
<td><em></em></td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::getProjection()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">getProjection</span><span class="nb-faded-text">(
)
</span>
:
string</code><div class="description">
<p class="short_description">Gets the format of data in returned in Atom feeds.</p>
<small>Inherited from:
<a href="db_Gdata_Photos_UserQuery.html#%5CZend_Gdata_Photos_UserQuery::getProjection()">\Zend_Gdata_Photos_UserQuery::getProjection()</a></small>
</div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td>string</td>
<td>projection</td>
</tr>
</table>
<strong>Details</strong><dl class="function-info">
<dt>see</dt>
<dd>\setProjection
</dd>
</dl>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::getPublishedMax()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">getPublishedMax</span><span class="nb-faded-text">(
)
</span>
:
string</code><div class="description">
<p class="short_description"></p>
<small>Inherited from:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query::getPublishedMax()">\Zend_Gdata_Query::getPublishedMax()</a></small>
</div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td>string</td>
<td>publishedMax</td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::getPublishedMin()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">getPublishedMin</span><span class="nb-faded-text">(
)
</span>
:
string</code><div class="description">
<p class="short_description"></p>
<small>Inherited from:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query::getPublishedMin()">\Zend_Gdata_Query::getPublishedMin()</a></small>
</div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td>string</td>
<td>publishedMin</td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::getQuery()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">getQuery</span><span class="nb-faded-text">(
)
</span>
:
string</code><div class="description">
<p class="short_description"></p>
<small>Inherited from:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query::getQuery()">\Zend_Gdata_Query::getQuery()</a></small>
</div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td>string</td>
<td>query</td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::getQueryString()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">getQueryString</span><span class="nb-faded-text">(
)
</span>
:
string</code><div class="description">
<p class="short_description"></p>
<small>Inherited from:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query::getQueryString()">\Zend_Gdata_Query::getQueryString()</a></small>
</div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td>string</td>
<td>querystring</td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::getQueryUrl()"></a><div class="method">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">getQueryUrl</span><span class="nb-faded-text">(
$incomingUri
)
</span>
:
string</code><div class="description"><p class="short_description">Returns the URL generated for this query, based on it's current
parameters.</p></div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Parameters</strong><table class="argument-info">
<thead><tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<th>$incomingUri</th>
<td></td>
<td><em></em></td>
</tr>
</table>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td>string</td>
<td>A URL generated based on the state of this query.</td>
</tr>
</table>
<strong>Throws</strong><table class="argument-info">
<thead><tr>
<th>Exception</th>
<th>Description</th>
</tr></thead>
<tr>
<td><a href="db_Gdata_App_InvalidArgumentException.html#%5CZend_Gdata_App_InvalidArgumentException">\Zend_Gdata_App_InvalidArgumentException</a></td>
<td><em></em></td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::getStartIndex()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">getStartIndex</span><span class="nb-faded-text">(
)
</span>
:
int</code><div class="description">
<p class="short_description"></p>
<small>Inherited from:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query::getStartIndex()">\Zend_Gdata_Query::getStartIndex()</a></small>
</div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td>int</td>
<td>startIndex</td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::getTag()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">getTag</span><span class="nb-faded-text">(
)
</span>
:
string</code><div class="description">
<p class="short_description">Get the tag filter for entries returned.</p>
<small>Inherited from:
<a href="db_Gdata_Photos_UserQuery.html#%5CZend_Gdata_Photos_UserQuery::getTag()">\Zend_Gdata_Photos_UserQuery::getTag()</a></small>
</div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td>string</td>
<td>The tag to filter by, or null if no filter is to be applied.</td>
</tr>
</table>
<strong>Details</strong><dl class="function-info">
<dt>see</dt>
<dd>\setTag
</dd>
</dl>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::getThumbsize()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">getThumbsize</span><span class="nb-faded-text">(
)
</span>
:
string</code><div class="description">
<p class="short_description">Get the thumbnail size filter for entries returned.</p>
<small>Inherited from:
<a href="db_Gdata_Photos_UserQuery.html#%5CZend_Gdata_Photos_UserQuery::getThumbsize()">\Zend_Gdata_Photos_UserQuery::getThumbsize()</a></small>
</div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td>string</td>
<td>The thumbnail size to filter by, or null if no filter is to be applied.</td>
</tr>
</table>
<strong>Details</strong><dl class="function-info">
<dt>see</dt>
<dd>\setThumbsize
</dd>
</dl>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::getType()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">getType</span><span class="nb-faded-text">(
)
</span>
:
string</code><div class="description">
<p class="short_description">Gets the type of data in returned in queries.</p>
<small>Inherited from:
<a href="db_Gdata_Photos_UserQuery.html#%5CZend_Gdata_Photos_UserQuery::getType()">\Zend_Gdata_Photos_UserQuery::getType()</a></small>
</div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td>string</td>
<td>type</td>
</tr>
</table>
<strong>Details</strong><dl class="function-info">
<dt>see</dt>
<dd>\setType
</dd>
</dl>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::getUpdatedMax()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">getUpdatedMax</span><span class="nb-faded-text">(
)
</span>
:
string</code><div class="description">
<p class="short_description"></p>
<small>Inherited from:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query::getUpdatedMax()">\Zend_Gdata_Query::getUpdatedMax()</a></small>
</div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td>string</td>
<td>updatedMax</td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::getUpdatedMin()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">getUpdatedMin</span><span class="nb-faded-text">(
)
</span>
:
string</code><div class="description">
<p class="short_description"></p>
<small>Inherited from:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query::getUpdatedMin()">\Zend_Gdata_Query::getUpdatedMin()</a></small>
</div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td>string</td>
<td>updatedMin</td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::getUser()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">getUser</span><span class="nb-faded-text">(
)
</span>
:
string</code><div class="description">
<p class="short_description">Get the user which is to be returned.</p>
<small>Inherited from:
<a href="db_Gdata_Photos_UserQuery.html#%5CZend_Gdata_Photos_UserQuery::getUser()">\Zend_Gdata_Photos_UserQuery::getUser()</a></small>
</div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td>string</td>
<td>The visibility to retrieve.</td>
</tr>
</table>
<strong>Details</strong><dl class="function-info">
<dt>see</dt>
<dd>\setUser
</dd>
</dl>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::resetParameters()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">resetParameters</span><span class="nb-faded-text">(
)
</span>
:
void</code><div class="description">
<p class="short_description"></p>
<small>Inherited from:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query::resetParameters()">\Zend_Gdata_Query::resetParameters()</a></small>
</div>
<div class="code-tabs"><div class="long-description">
</div></div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::setAccess()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">setAccess</span><span class="nb-faded-text">(
string $value
)
</span>
:
void</code><div class="description">
<p class="short_description">Set the visibility filter for entries returned. Only entries which
match this value will be returned. If null or unset, the default
value will be used instead.</p>
<small>Inherited from:
<a href="db_Gdata_Photos_UserQuery.html#%5CZend_Gdata_Photos_UserQuery::setAccess()">\Zend_Gdata_Photos_UserQuery::setAccess()</a></small>
</div>
<div class="code-tabs">
<div class="long-description"><p>Valid values are 'all' (default), 'public', and 'private'.</p>
</div>
<strong>Parameters</strong><table class="argument-info">
<thead><tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<th>$value</th>
<td>string</td>
<td><em>The visibility to filter by, or null to use the default value.</em></td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::setAlbumId()"></a><div class="method">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">setAlbumId</span><span class="nb-faded-text">(
string $value
)
</span>
:
<a href="db_Gdata_Photos_AlbumQuery.html#%5CZend_Gdata_Photos_AlbumQuery">\Zend_Gdata_Photos_AlbumQuery</a></code><div class="description"><p class="short_description">Set the album ID to query for. When set, this album's photographs
be returned. If not set or null, the default user's feed will be
returned instead.</p></div>
<div class="code-tabs">
<div class="long-description"><p>NOTE: Album and AlbumId are mutually exclusive. Setting one will
automatically set the other to null.</p>
</div>
<strong>Parameters</strong><table class="argument-info">
<thead><tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<th>$value</th>
<td>string</td>
<td><em>The ID of the album to retrieve, or null to clear.</em></td>
</tr>
</table>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td><a href="db_Gdata_Photos_AlbumQuery.html#%5CZend_Gdata_Photos_AlbumQuery">\Zend_Gdata_Photos_AlbumQuery</a></td>
<td>The query object.</td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::setAlbumName()"></a><div class="method">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">setAlbumName</span><span class="nb-faded-text">(
string $value
)
</span>
:
<a href="db_Gdata_Photos_AlbumQuery.html#%5CZend_Gdata_Photos_AlbumQuery">\Zend_Gdata_Photos_AlbumQuery</a></code><div class="description"><p class="short_description">Set the album name to query for. When set, this album's photographs
be returned. If not set or null, the default user's feed will be
returned instead.</p></div>
<div class="code-tabs">
<div class="long-description"><p>NOTE: AlbumName and AlbumId are mutually exclusive. Setting one will
automatically set the other to null.</p>
</div>
<strong>Parameters</strong><table class="argument-info">
<thead><tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<th>$value</th>
<td>string</td>
<td><em>The name of the album to retrieve, or null to clear.</em></td>
</tr>
</table>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td><a href="db_Gdata_Photos_AlbumQuery.html#%5CZend_Gdata_Photos_AlbumQuery">\Zend_Gdata_Photos_AlbumQuery</a></td>
<td>The query object.</td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::setAlt()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">setAlt</span><span class="nb-faded-text">(
string $value
)
</span>
:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query">\Zend_Gdata_Query</a></code><div class="description">
<p class="short_description"></p>
<small>Inherited from:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query::setAlt()">\Zend_Gdata_Query::setAlt()</a></small>
</div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Parameters</strong><table class="argument-info">
<thead><tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<th>$value</th>
<td>string</td>
<td><em></em></td>
</tr>
</table>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td><a href="db_Gdata_Query.html#%5CZend_Gdata_Query">\Zend_Gdata_Query</a></td>
<td>Provides a fluent interface</td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::setAuthor()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">setAuthor</span><span class="nb-faded-text">(
string $value
)
</span>
:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query">\Zend_Gdata_Query</a></code><div class="description">
<p class="short_description"></p>
<small>Inherited from:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query::setAuthor()">\Zend_Gdata_Query::setAuthor()</a></small>
</div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Parameters</strong><table class="argument-info">
<thead><tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<th>$value</th>
<td>string</td>
<td><em></em></td>
</tr>
</table>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td><a href="db_Gdata_Query.html#%5CZend_Gdata_Query">\Zend_Gdata_Query</a></td>
<td>Provides a fluent interface</td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::setCategory()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">setCategory</span><span class="nb-faded-text">(
string $value
)
</span>
:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query">\Zend_Gdata_Query</a></code><div class="description">
<p class="short_description"></p>
<small>Inherited from:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query::setCategory()">\Zend_Gdata_Query::setCategory()</a></small>
</div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Parameters</strong><table class="argument-info">
<thead><tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<th>$value</th>
<td>string</td>
<td><em></em></td>
</tr>
</table>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td><a href="db_Gdata_Query.html#%5CZend_Gdata_Query">\Zend_Gdata_Query</a></td>
<td>Provides a fluent interface</td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::setImgMax()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">setImgMax</span><span class="nb-faded-text">(
string $value
)
</span>
:
void</code><div class="description">
<p class="short_description">Set the maximum image size for entries returned. Only entries which
match this value will be returned. If null or unset, this filter will
not be applied.</p>
<small>Inherited from:
<a href="db_Gdata_Photos_UserQuery.html#%5CZend_Gdata_Photos_UserQuery::setImgMax()">\Zend_Gdata_Photos_UserQuery::setImgMax()</a></small>
</div>
<div class="code-tabs">
<div class="long-description"><p>See http://code.google.com/apis/picasaweb/reference.html#Parameters
for a list of valid values.</p>
</div>
<strong>Parameters</strong><table class="argument-info">
<thead><tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<th>$value</th>
<td>string</td>
<td><em>The image size to filter by, or null if no filter is to be applied.</em></td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::setKind()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">setKind</span><span class="nb-faded-text">(
string $value
)
</span>
:
void</code><div class="description">
<p class="short_description">Set the kind of entries that are returned. Only entries which
match this value will be returned. If null or unset, this filter will
not be applied.</p>
<small>Inherited from:
<a href="db_Gdata_Photos_UserQuery.html#%5CZend_Gdata_Photos_UserQuery::setKind()">\Zend_Gdata_Photos_UserQuery::setKind()</a></small>
</div>
<div class="code-tabs">
<div class="long-description"><p>See http://code.google.com/apis/picasaweb/reference.html#Parameters
for a list of valid values.</p>
</div>
<strong>Parameters</strong><table class="argument-info">
<thead><tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<th>$value</th>
<td>string</td>
<td><em>The kind to filter by, or null if no filter is to be applied.</em></td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::setMaxResults()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">setMaxResults</span><span class="nb-faded-text">(
int $value
)
</span>
:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query">\Zend_Gdata_Query</a></code><div class="description">
<p class="short_description"></p>
<small>Inherited from:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query::setMaxResults()">\Zend_Gdata_Query::setMaxResults()</a></small>
</div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Parameters</strong><table class="argument-info">
<thead><tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<th>$value</th>
<td>int</td>
<td><em></em></td>
</tr>
</table>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td><a href="db_Gdata_Query.html#%5CZend_Gdata_Query">\Zend_Gdata_Query</a></td>
<td>Provides a fluent interface</td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::setParam()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">setParam</span><span class="nb-faded-text">(
string $name, string $value
)
</span>
:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query">\Zend_Gdata_Query</a></code><div class="description">
<p class="short_description"></p>
<small>Inherited from:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query::setParam()">\Zend_Gdata_Query::setParam()</a></small>
</div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Parameters</strong><table class="argument-info">
<thead><tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<th>$name</th>
<td>string</td>
<td><em></em></td>
</tr>
<tr>
<th>$value</th>
<td>string</td>
<td><em></em></td>
</tr>
</table>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td><a href="db_Gdata_Query.html#%5CZend_Gdata_Query">\Zend_Gdata_Query</a></td>
<td>Provides a fluent interface</td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::setProjection()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">setProjection</span><span class="nb-faded-text">(
string $value
)
</span>
:
<a href="db_Gdata_Photos_UserQuery.html#%5CZend_Gdata_Photos_UserQuery">\Zend_Gdata_Photos_UserQuery</a></code><div class="description">
<p class="short_description">Set's the format of data returned in Atom feeds. Can be either
'api' or 'base'. Normally, 'api' will be desired. Default is 'api'.</p>
<small>Inherited from:
<a href="db_Gdata_Photos_UserQuery.html#%5CZend_Gdata_Photos_UserQuery::setProjection()">\Zend_Gdata_Photos_UserQuery::setProjection()</a></small>
</div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Parameters</strong><table class="argument-info">
<thead><tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<th>$value</th>
<td>string</td>
<td><em></em></td>
</tr>
</table>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td><a href="db_Gdata_Photos_UserQuery.html#%5CZend_Gdata_Photos_UserQuery">\Zend_Gdata_Photos_UserQuery</a></td>
<td>Provides a fluent interface</td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::setPublishedMax()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">setPublishedMax</span><span class="nb-faded-text">(
string $value
)
</span>
:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query">\Zend_Gdata_Query</a></code><div class="description">
<p class="short_description"></p>
<small>Inherited from:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query::setPublishedMax()">\Zend_Gdata_Query::setPublishedMax()</a></small>
</div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Parameters</strong><table class="argument-info">
<thead><tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<th>$value</th>
<td>string</td>
<td><em></em></td>
</tr>
</table>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td><a href="db_Gdata_Query.html#%5CZend_Gdata_Query">\Zend_Gdata_Query</a></td>
<td>Provides a fluent interface</td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::setPublishedMin()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">setPublishedMin</span><span class="nb-faded-text">(
string $value
)
</span>
:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query">\Zend_Gdata_Query</a></code><div class="description">
<p class="short_description"></p>
<small>Inherited from:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query::setPublishedMin()">\Zend_Gdata_Query::setPublishedMin()</a></small>
</div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Parameters</strong><table class="argument-info">
<thead><tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<th>$value</th>
<td>string</td>
<td><em></em></td>
</tr>
</table>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td><a href="db_Gdata_Query.html#%5CZend_Gdata_Query">\Zend_Gdata_Query</a></td>
<td>Provides a fluent interface</td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::setQuery()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">setQuery</span><span class="nb-faded-text">(
string $value
)
</span>
:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query">\Zend_Gdata_Query</a></code><div class="description">
<p class="short_description"></p>
<small>Inherited from:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query::setQuery()">\Zend_Gdata_Query::setQuery()</a></small>
</div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Parameters</strong><table class="argument-info">
<thead><tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<th>$value</th>
<td>string</td>
<td><em></em></td>
</tr>
</table>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td><a href="db_Gdata_Query.html#%5CZend_Gdata_Query">\Zend_Gdata_Query</a></td>
<td>Provides a fluent interface</td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::setStartIndex()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">setStartIndex</span><span class="nb-faded-text">(
int $value
)
</span>
:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query">\Zend_Gdata_Query</a></code><div class="description">
<p class="short_description"></p>
<small>Inherited from:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query::setStartIndex()">\Zend_Gdata_Query::setStartIndex()</a></small>
</div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Parameters</strong><table class="argument-info">
<thead><tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<th>$value</th>
<td>int</td>
<td><em></em></td>
</tr>
</table>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td><a href="db_Gdata_Query.html#%5CZend_Gdata_Query">\Zend_Gdata_Query</a></td>
<td>Provides a fluent interface</td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::setTag()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">setTag</span><span class="nb-faded-text">(
string $value
)
</span>
:
void</code><div class="description">
<p class="short_description">Set the tag for entries that are returned. Only entries which
match this value will be returned. If null or unset, this filter will
not be applied.</p>
<small>Inherited from:
<a href="db_Gdata_Photos_UserQuery.html#%5CZend_Gdata_Photos_UserQuery::setTag()">\Zend_Gdata_Photos_UserQuery::setTag()</a></small>
</div>
<div class="code-tabs">
<div class="long-description"><p>See http://code.google.com/apis/picasaweb/reference.html#Parameters
for a list of valid values.</p>
</div>
<strong>Parameters</strong><table class="argument-info">
<thead><tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<th>$value</th>
<td>string</td>
<td><em>The tag to filter by, or null if no filter is to be applied.</em></td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::setThumbsize()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">setThumbsize</span><span class="nb-faded-text">(
string $value
)
</span>
:
void</code><div class="description">
<p class="short_description">Set the thumbnail size filter for entries returned. Only entries which
match this value will be returned. If null or unset, this filter will
not be applied.</p>
<small>Inherited from:
<a href="db_Gdata_Photos_UserQuery.html#%5CZend_Gdata_Photos_UserQuery::setThumbsize()">\Zend_Gdata_Photos_UserQuery::setThumbsize()</a></small>
</div>
<div class="code-tabs">
<div class="long-description"><p>See http://code.google.com/apis/picasaweb/reference.html#Parameters
for a list of valid values.</p>
</div>
<strong>Parameters</strong><table class="argument-info">
<thead><tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<th>$value</th>
<td>string</td>
<td><em>The thumbnail size to filter by, or null if no filter is to be applied.</em></td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::setType()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">setType</span><span class="nb-faded-text">(
string $value
)
</span>
:
<a href="db_Gdata_Photos_UserQuery.html#%5CZend_Gdata_Photos_UserQuery">\Zend_Gdata_Photos_UserQuery</a></code><div class="description">
<p class="short_description">Set's the type of data returned in queries. Can be either
'feed' or 'entry'. Normally, 'feed' will be desired. Default is 'feed'.</p>
<small>Inherited from:
<a href="db_Gdata_Photos_UserQuery.html#%5CZend_Gdata_Photos_UserQuery::setType()">\Zend_Gdata_Photos_UserQuery::setType()</a></small>
</div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Parameters</strong><table class="argument-info">
<thead><tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<th>$value</th>
<td>string</td>
<td><em></em></td>
</tr>
</table>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td><a href="db_Gdata_Photos_UserQuery.html#%5CZend_Gdata_Photos_UserQuery">\Zend_Gdata_Photos_UserQuery</a></td>
<td>Provides a fluent interface</td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::setUpdatedMax()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">setUpdatedMax</span><span class="nb-faded-text">(
string $value
)
</span>
:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query">\Zend_Gdata_Query</a></code><div class="description">
<p class="short_description"></p>
<small>Inherited from:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query::setUpdatedMax()">\Zend_Gdata_Query::setUpdatedMax()</a></small>
</div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Parameters</strong><table class="argument-info">
<thead><tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<th>$value</th>
<td>string</td>
<td><em></em></td>
</tr>
</table>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td><a href="db_Gdata_Query.html#%5CZend_Gdata_Query">\Zend_Gdata_Query</a></td>
<td>Provides a fluent interface</td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::setUpdatedMin()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">setUpdatedMin</span><span class="nb-faded-text">(
string $value
)
</span>
:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query">\Zend_Gdata_Query</a></code><div class="description">
<p class="short_description"></p>
<small>Inherited from:
<a href="db_Gdata_Query.html#%5CZend_Gdata_Query::setUpdatedMin()">\Zend_Gdata_Query::setUpdatedMin()</a></small>
</div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Parameters</strong><table class="argument-info">
<thead><tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<th>$value</th>
<td>string</td>
<td><em></em></td>
</tr>
</table>
<strong>Returns</strong><table class="argument-info">
<thead><tr>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<td><a href="db_Gdata_Query.html#%5CZend_Gdata_Query">\Zend_Gdata_Query</a></td>
<td>Provides a fluent interface</td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
<a id="\Zend_Gdata_Photos_AlbumQuery::setUser()"></a><div class="method inherited_from ">
<a href="#" class="gripper"><img src="images/icons/arrow_right.png"><img src="images/icons/arrow_down.png" style="display: none;"></a><code><img src="images/icons/method.png" alt="method"><img src="images/icons/visibility_public.png" style="margin-right: 5px" alt="public"><span class="highlight">setUser</span><span class="nb-faded-text">(
string $value
)
</span>
:
void</code><div class="description">
<p class="short_description">Set the user to query for. When set, this user's feed will be
returned. If not set or null, the default user's feed will be returned
instead.</p>
<small>Inherited from:
<a href="db_Gdata_Photos_UserQuery.html#%5CZend_Gdata_Photos_UserQuery::setUser()">\Zend_Gdata_Photos_UserQuery::setUser()</a></small>
</div>
<div class="code-tabs">
<div class="long-description">
</div>
<strong>Parameters</strong><table class="argument-info">
<thead><tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr></thead>
<tr>
<th>$value</th>
<td>string</td>
<td><em>The user to retrieve, or null for the default user.</em></td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
</div>
</div>
</div>
<small xmlns="" class="footer">Documentation was generated by <a href="http://docblox-project.org">DocBlox 0.13.3</a>.
</small></body></html>
| spurge/google-docs-backend | external/ZendGdata-1.11.11/documentation/api/core/db_Gdata_Photos_AlbumQuery.html | HTML | gpl-2.0 | 64,600 |
#! /bin/sh
# Copyright (C) 2010-2015 Free Software Foundation, Inc.
#
# 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, 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/>.
# Check for more complex usage of wildcards in EXTRA_DIST.
# Suggested by observations from Braden McDaniel.
required=GNUmake
. test-init.sh
echo AC_OUTPUT >> configure.ac
cat > Makefile.am <<'END'
AUTOMAKE_OPTIONS = -Wno-portability
EXTRA_DIST = $(wildcard [!c-z].t d.t [ab].dir foo.* *zardoz*)
.PHONY: prereq
prereq:
echo a > a.t
echo b > b.t
echo c > c.t
echo d > d.t
echo m > m.t
echo z > z.t
mkdir a.dir b.dir c.dir
echo a1 > a.dir/f1
echo a2 > a.dir/f2
echo bb > b.dir/f
echo cc > c.dir/x
echo 0 > foo
echo 1 > foo.x
echo 2 > foo.bar
echo foo > _zardoz_
.PHONY: test
test: distdir
ls -l $(distdir) $(distdir)/*.dir ;: For debugging.
diff a.t $(distdir)/a.t
diff b.t $(distdir)/b.t
test ! -r $(distdir)/c.t
diff d.t $(distdir)/d.t
test ! -r $(distdir)/m.t
test ! -r $(distdir)/z.t
diff a.dir/f1 $(distdir)/a.dir/f1
diff a.dir/f2 $(distdir)/a.dir/f2
diff b.dir/f $(distdir)/b.dir/f
test ! -r $(distdir)/c.dir
diff foo.x $(distdir)/foo.x
diff foo.bar $(distdir)/foo.bar
test ! -r $(distdir)/foo
diff _zardoz_ $(distdir)/_zardoz_
check-local:
ls -l . *.dir ;: For debugging.
test -f $(srcdir)/a.t
test -f $(srcdir)/b.t
test ! -r $(srcdir)/c.t
test -f $(srcdir)/d.t
test ! -r $(srcdir)/m.t
test ! -r $(srcdir)/z.t
test -f $(srcdir)/a.dir/f1
test -f $(srcdir)/a.dir/f2
test -f $(srcdir)/b.dir/f
test ! -r $(srcdir)/c.dir
test -f $(srcdir)/foo.x
test -f $(srcdir)/foo.bar
test ! -r $(srcdir)/foo
test -f $(srcdir)/_zardoz_
END
$ACLOCAL
$AUTOMAKE
$AUTOCONF
./configure
$MAKE prereq
ls -l . *.dir # For debugging.
$MAKE test
$MAKE distcheck
:
| evaautomation/automake | t/extra-dist-wildcards-gnu.sh | Shell | gpl-2.0 | 2,284 |
<div class="container" id="mainContent">
<div id="topOfPage">
</div>
<h1>
Instructor Home
</h1>
<br>
<div class="well well-plain">
<div class="row">
<div class="col-md-12">
<form action="/page/instructorSearchPage?user=CHomeUiT.instructor.tmms" method="get" name="search_form">
<div class="input-group">
<input class="form-control" data-original-title="Search for student's information, e.g. name, email" data-placement="top" data-toggle="tooltip" id="searchbox" name="searchkey" placeholder="e.g. Charles Shultz, charles@gmail.com" title="" type="text">
<span class="input-group-btn">
<button class="btn btn-default" id="buttonSearch" type="submit" value="Search">
Search
</button>
</span>
</div>
<input name="searchstudents" type="hidden" value="true">
<input name="searchcommentforstudents" type="hidden" value="false">
<input name="searchcommentforresponses" type="hidden" value="false">
<input name="user" type="hidden" value="CHomeUiT.instructor.tmms">
</form>
</div>
</div>
</div>
<br>
<div id="statusMessagesToUser" style="display: none;">
</div>
<div aria-hidden="true" aria-labelledby="remindModal" class="modal fade" id="remindModal" role="dialog" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<form action="/page/instructorFeedbackRemindParticularStudents?next=%2Fpage%2FinstructorHomePage" method="post" name="form_remind_list" role="form">
<div class="modal-header">
<button aria-hidden="true" class="close" data-dismiss="modal" type="button">
×
</button>
<h4 class="modal-title">
Remind Particular Students
<small>
(Select the student(s) you want to remind)
</small>
</h4>
</div>
<div class="modal-body">
<div class="form-group" id="studentList">
</div>
</div>
<div class="modal-footer">
<button class="btn btn-default" data-dismiss="modal" type="button">
Cancel
</button>
<input class="btn btn-primary" type="submit" value="Remind">
<input name="user" type="hidden" value="CHomeUiT.instructor.tmms">
</div>
</form>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-2">
<a class="btn btn-primary btn-md" href="/page/instructorCoursesPage?user=CHomeUiT.instructor.tmms" id="addNewCourse">
Add New Course
</a>
</div>
<div class="col-xs-10">
<div class="pull-right">
<h5 class="inline-block">
<strong>
Sort By:
</strong>
</h5>
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-default" data="id" id="sortById" name="sortby">
<input type="radio">
Course ID
</label>
<label class="btn btn-default" data="name" id="sortByName" name="sortby">
<input name="sortby" type="radio" value="name">
Course Name
</label>
<label class="btn btn-default active" data="createdAt" id="sortByDate" name="sortby">
<input type="radio">
Creation Date
</label>
</div>
</div>
</div>
</div>
<br>
<div class="panel panel-primary" id="course-0">
<div class="panel-heading">
<div class="row">
<div class="col-sm-6">
<strong>
[CHomeUiT.CS1101] : Programming Methodology
</strong>
</div>
<div class="mobile-margin-top-10px col-sm-6">
<span class="mobile-no-pull pull-right">
<div class="dropdown courses-table-dropdown">
<button class="btn btn-primary btn-xs dropdown-toggle" data-toggle="dropdown" type="button">
Students
<span class="caret">
</span>
</button>
<ul class="dropdown-menu">
<li>
<a class="btn-tm-actions course-enroll-for-test" data-original-title="Enroll student into the course" data-placement="left" data-toggle="tooltip" href="/page/instructorCourseEnrollPage?courseid=CHomeUiT.CS1101&user=CHomeUiT.instructor.tmms" title="">
Enroll
</a>
</li>
<li>
<a class="btn-tm-actions course-view-for-test" data-original-title="View, edit and send invitation emails to the students in the course" data-placement="left" data-toggle="tooltip" href="/page/instructorCourseDetailsPage?courseid=CHomeUiT.CS1101&user=CHomeUiT.instructor.tmms" title="">
View / Edit
</a>
</li>
</ul>
</div>
<div class="dropdown courses-table-dropdown">
<button class="btn btn-primary btn-xs dropdown-toggle" data-toggle="dropdown" type="button">
Instructors
<span class="caret">
</span>
</button>
<ul class="dropdown-menu">
<li>
<a class="btn-tm-actions course-edit-for-test" data-original-title="Edit Course information and instructor list" data-placement="left" data-toggle="tooltip" href="/page/instructorCourseEditPage?courseid=CHomeUiT.CS1101&user=CHomeUiT.instructor.tmms" title="">
View / Edit
</a>
</li>
</ul>
</div>
<div class="dropdown courses-table-dropdown">
<button class="btn btn-primary btn-xs dropdown-toggle" data-toggle="dropdown" type="button">
Sessions
<span class="caret">
</span>
</button>
<ul class="dropdown-menu">
<li>
<a class="btn-tm-actions course-add-eval-for-test" data-original-title="Add a feedback session for the course" data-placement="left" data-toggle="tooltip" href="/page/instructorFeedbacksPage?user=CHomeUiT.instructor.tmms&courseid=CHomeUiT.CS1101" title="">
Add
</a>
</li>
</ul>
</div>
<div class="dropdown courses-table-dropdown">
<button class="btn btn-primary btn-xs dropdown-toggle" data-toggle="dropdown" type="button">
Course
<span class="caret">
</span>
</button>
<ul class="dropdown-menu">
<li>
<a class="btn-tm-actions course-archive-for-test" data-course-id="CHomeUiT.CS1101" data-original-title="Archive the course so that it will not be shown in the home page any more (you can still access it from the 'Courses' tab)" data-placement="left" data-toggle="tooltip" href="/page/instructorCourseArchive?courseid=CHomeUiT.CS1101&archive=true&next=%2Fpage%2FinstructorHomePage&user=CHomeUiT.instructor.tmms" title="">
Archive
</a>
</li>
<li>
<a class="btn-tm-actions course-delete-for-test course-delete-link" data-course-id="CHomeUiT.CS1101" data-original-title="Delete the course and its corresponding students and sessions" data-placement="left" data-toggle="tooltip" href="/page/instructorCourseDelete?courseid=CHomeUiT.CS1101&next=%2Fpage%2FinstructorHomePage&user=CHomeUiT.instructor.tmms" title="">
Delete
</a>
</li>
</ul>
</div>
</span>
</div>
</div>
</div>
<table class="table-responsive table table-striped table-bordered">
<thead>
<tr>
<th class="button_sortname button-sort-none" onclick="toggleSort(this);">
Session Name
<span class="icon-sort unsorted">
</span>
</th>
<th class="button_sortstartdate button-sort-none" onclick="toggleSort(this,instructorHomeDateComparator);">
Start Date
<span class="icon-sort unsorted">
</span>
</th>
<th class="button_sortenddate button-sort-none" onclick="toggleSort(this,instructorHomeDateComparator);">
End Date
<span class="icon-sort unsorted">
</span>
</th>
<th>
Status
</th>
<th>
<span class="text-nowrap tool-tip-decorate" data-original-title="Number of students submitted / Class size" data-placement="top" data-toggle="tooltip" title="">
Response Rate
</span>
</th>
<th class="no-print">
Action(s)
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<span class="text-muted">
This course does not have any sessions yet.
</span>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
</tbody>
</table>
</div>
<div class="panel panel-primary" id="course-1">
<div class="panel-heading">
<div class="row">
<div class="col-sm-6">
<strong>
[CHomeUiT.CS2104] : Programming Language Concepts
</strong>
</div>
<div class="mobile-margin-top-10px col-sm-6">
<span class="mobile-no-pull pull-right">
<div class="dropdown courses-table-dropdown">
<button class="btn btn-primary btn-xs dropdown-toggle" data-toggle="dropdown" type="button">
Students
<span class="caret">
</span>
</button>
<ul class="dropdown-menu">
<li>
<a class="btn-tm-actions course-enroll-for-test" data-original-title="Enroll student into the course" data-placement="left" data-toggle="tooltip" href="/page/instructorCourseEnrollPage?courseid=CHomeUiT.CS2104&user=CHomeUiT.instructor.tmms" title="">
Enroll
</a>
</li>
<li>
<a class="btn-tm-actions course-view-for-test" data-original-title="View, edit and send invitation emails to the students in the course" data-placement="left" data-toggle="tooltip" href="/page/instructorCourseDetailsPage?courseid=CHomeUiT.CS2104&user=CHomeUiT.instructor.tmms" title="">
View / Edit
</a>
</li>
</ul>
</div>
<div class="dropdown courses-table-dropdown">
<button class="btn btn-primary btn-xs dropdown-toggle" data-toggle="dropdown" type="button">
Instructors
<span class="caret">
</span>
</button>
<ul class="dropdown-menu">
<li>
<a class="btn-tm-actions course-edit-for-test" data-original-title="Edit Course information and instructor list" data-placement="left" data-toggle="tooltip" href="/page/instructorCourseEditPage?courseid=CHomeUiT.CS2104&user=CHomeUiT.instructor.tmms" title="">
View / Edit
</a>
</li>
</ul>
</div>
<div class="dropdown courses-table-dropdown">
<button class="btn btn-primary btn-xs dropdown-toggle" data-toggle="dropdown" type="button">
Sessions
<span class="caret">
</span>
</button>
<ul class="dropdown-menu">
<li>
<a class="btn-tm-actions course-add-eval-for-test" data-original-title="Add a feedback session for the course" data-placement="left" data-toggle="tooltip" href="/page/instructorFeedbacksPage?user=CHomeUiT.instructor.tmms&courseid=CHomeUiT.CS2104" title="">
Add
</a>
</li>
</ul>
</div>
<div class="dropdown courses-table-dropdown">
<button class="btn btn-primary btn-xs dropdown-toggle" data-toggle="dropdown" type="button">
Course
<span class="caret">
</span>
</button>
<ul class="dropdown-menu">
<li>
<a class="btn-tm-actions course-archive-for-test" data-course-id="CHomeUiT.CS2104" data-original-title="Archive the course so that it will not be shown in the home page any more (you can still access it from the 'Courses' tab)" data-placement="left" data-toggle="tooltip" href="/page/instructorCourseArchive?courseid=CHomeUiT.CS2104&archive=true&next=%2Fpage%2FinstructorHomePage&user=CHomeUiT.instructor.tmms" title="">
Archive
</a>
</li>
<li>
<a class="btn-tm-actions course-delete-for-test course-delete-link" data-course-id="CHomeUiT.CS2104" data-original-title="Delete the course and its corresponding students and sessions" data-placement="left" data-toggle="tooltip" href="/page/instructorCourseDelete?courseid=CHomeUiT.CS2104&next=%2Fpage%2FinstructorHomePage&user=CHomeUiT.instructor.tmms" title="">
Delete
</a>
</li>
</ul>
</div>
</span>
</div>
</div>
</div>
<table class="table-responsive table table-striped table-bordered">
<thead>
<tr>
<th class="button_sortname button-sort-none" onclick="toggleSort(this);">
Session Name
<span class="icon-sort unsorted">
</span>
</th>
<th class="button_sortstartdate button-sort-none" onclick="toggleSort(this,instructorHomeDateComparator);">
Start Date
<span class="icon-sort unsorted">
</span>
</th>
<th class="button_sortenddate button-sort-none" onclick="toggleSort(this,instructorHomeDateComparator);">
End Date
<span class="icon-sort unsorted">
</span>
</th>
<th>
Status
</th>
<th>
<span class="text-nowrap tool-tip-decorate" data-original-title="Number of students submitted / Class size" data-placement="top" data-toggle="tooltip" title="">
Response Rate
</span>
</th>
<th class="no-print">
Action(s)
</th>
</tr>
</thead>
<tbody>
<tr id="session0">
<td>
First Feedback Session
</td>
<td class="text-nowrap">
<span class="tool-tip-decorate" data-original-title="Sun, 01 Apr 2012, 11:59 PM" data-toggle="tooltip" title="">
1 Apr 11:59 PM
</span>
</td>
<td class="text-nowrap">
<span class="tool-tip-decorate" data-original-title="Fri, 30 Apr 2027, 11:59 PM" data-toggle="tooltip" title="">
30 Apr 11:59 PM
</span>
</td>
<td>
<span class="tool-tip-decorate" data-original-title="The feedback session has been created, is visible, and is open for submissions." data-placement="top" data-toggle="tooltip" title="">
Open
</span>
</td>
<td class="session-response-for-test">
<a href="/page/feedbackSessionStatsPage?courseid=CHomeUiT.CS2104&fsname=First+Feedback+Session&user=CHomeUiT.instructor.tmms" oncontextmenu="return false;">
Show
</a>
</td>
<td class="no-print text-nowrap padding-right-25px">
<a class="btn btn-default btn-xs btn-tm-actions session-view-for-test margin-bottom-7px" data-original-title="View the submitted responses for this feedback session" data-placement="top" data-toggle="tooltip" href="/page/instructorFeedbackResultsPage?courseid=CHomeUiT.CS2104&fsname=First+Feedback+Session&user=CHomeUiT.instructor.tmms" title="">
View Results
</a>
<a class="btn btn-default btn-xs btn-tm-actions session-edit-for-test margin-bottom-7px" data-original-title="Edit feedback session details" data-placement="top" data-toggle="tooltip" href="/page/instructorFeedbackEditPage?courseid=CHomeUiT.CS2104&fsname=First+Feedback+Session&user=CHomeUiT.instructor.tmms" title="">
Edit
</a>
<a class="btn btn-default btn-xs btn-tm-actions session-delete-for-test margin-bottom-7px" data-courseid="CHomeUiT.CS2104" data-fsname="First Feedback Session" data-original-title="Delete the feedback session" data-placement="top" data-toggle="tooltip" href="/page/instructorFeedbackDelete?courseid=CHomeUiT.CS2104&fsname=First+Feedback+Session&next=%2Fpage%2FinstructorHomePage&user=CHomeUiT.instructor.tmms" title="">
Delete
</a>
<a class="btn btn-default btn-xs btn-tm-actions session-copy-for-test margin-bottom-7px" data-actionlink="/page/instructorFeedbackEditCopyPage?user=CHomeUiT.instructor.tmms" data-courseid="CHomeUiT.CS2104" data-fsname="First Feedback Session" data-placement="top" data-target="#fsCopyModal" data-toggle="modal" href="#" id="button_fscopy-CHomeUiT.CS2104-First Feedback Session" title="Copy feedback session details">
Copy
</a>
<div data-original-title="Start submitting feedback" data-placement="top" data-toggle="tooltip" style="display: inline-block; padding-right: 5px;" title="">
<a class="btn btn-default btn-xs btn-tm-actions session-submit-for-test margin-bottom-7px" href="/page/instructorFeedbackSubmissionEditPage?courseid=CHomeUiT.CS2104&fsname=First+Feedback+Session&user=CHomeUiT.instructor.tmms">
Submit
</a>
</div>
<div data-original-title="Send e-mails to remind students and instructors who have not submitted their feedbacks to do so" data-placement="top" data-toggle="tooltip" style="display: inline-block; padding-right: 5px;" title="">
<div class="btn-group margin-bottom-7px">
<a class="btn btn-default btn-xs btn-tm-actions session-remind-for-test" data-fsname="First Feedback Session" href="/page/instructorFeedbackRemind?courseid=CHomeUiT.CS2104&fsname=First+Feedback+Session&next=%2Fpage%2FinstructorHomePage&user=CHomeUiT.instructor.tmms">
Remind
</a>
<button aria-expanded="false" class="btn btn-default btn-xs btn-tm-actions dropdown-toggle session-remind-options-for-test" data-toggle="dropdown" type="button">
<span class="caret">
</span>
</button>
<ul class="dropdown-menu" role="menu">
<li>
<a class="session-remind-inner-for-test" data-fsname="First Feedback Session" href="/page/instructorFeedbackRemind?courseid=CHomeUiT.CS2104&fsname=First+Feedback+Session&next=%2Fpage%2FinstructorHomePage&user=CHomeUiT.instructor.tmms">
Remind all students
</a>
</li>
<li>
<a class="session-remind-particular-for-test" data-actionlink="/page/instructorFeedbackRemindParticularStudentsPage?courseid=CHomeUiT.CS2104&fsname=First+Feedback+Session&user=CHomeUiT.instructor.tmms" data-courseid="CHomeUiT.CS2104" data-fsname="First Feedback Session" data-target="#remindModal" data-toggle="modal" href="#">
Remind particular students
</a>
</li>
</ul>
</div>
</div>
<a class="btn btn-default btn-xs margin-bottom-7px btn-tm-actions session-publish-for-test" data-fsname="First Feedback Session" data-original-title="Make session responses available for viewing" data-placement="top" data-sending-published-email="true" data-toggle="tooltip" href="/page/instructorFeedbackPublish?courseid=CHomeUiT.CS2104&fsname=First+Feedback+Session&next=%2Fpage%2FinstructorHomePage&user=CHomeUiT.instructor.tmms" title="">
Publish Results
</a>
</td>
</tr>
<tr id="session1">
<td>
Second Feedback Session
</td>
<td class="text-nowrap">
<span class="tool-tip-decorate" data-original-title="Mon, 29 Mar 2027, 10:59 PM" data-toggle="tooltip" title="">
29 Mar 10:59 PM
</span>
</td>
<td class="text-nowrap">
<span class="tool-tip-decorate" data-original-title="Fri, 30 Apr 2027, 10:59 PM" data-toggle="tooltip" title="">
30 Apr 10:59 PM
</span>
</td>
<td>
<span class="tool-tip-decorate" data-original-title="The feedback session has been created, is visible, and is waiting to open." data-placement="top" data-toggle="tooltip" title="">
Awaiting
</span>
</td>
<td class="session-response-for-test">
<a href="/page/feedbackSessionStatsPage?courseid=CHomeUiT.CS2104&fsname=Second+Feedback+Session&user=CHomeUiT.instructor.tmms" oncontextmenu="return false;">
Show
</a>
</td>
<td class="no-print text-nowrap padding-right-25px">
<a class="btn btn-default btn-xs btn-tm-actions session-view-for-test margin-bottom-7px" data-original-title="View the submitted responses for this feedback session" data-placement="top" data-toggle="tooltip" href="/page/instructorFeedbackResultsPage?courseid=CHomeUiT.CS2104&fsname=Second+Feedback+Session&user=CHomeUiT.instructor.tmms" title="">
View Results
</a>
<a class="btn btn-default btn-xs btn-tm-actions session-edit-for-test margin-bottom-7px" data-original-title="Edit feedback session details" data-placement="top" data-toggle="tooltip" href="/page/instructorFeedbackEditPage?courseid=CHomeUiT.CS2104&fsname=Second+Feedback+Session&user=CHomeUiT.instructor.tmms" title="">
Edit
</a>
<a class="btn btn-default btn-xs btn-tm-actions session-delete-for-test margin-bottom-7px" data-courseid="CHomeUiT.CS2104" data-fsname="Second Feedback Session" data-original-title="Delete the feedback session" data-placement="top" data-toggle="tooltip" href="/page/instructorFeedbackDelete?courseid=CHomeUiT.CS2104&fsname=Second+Feedback+Session&next=%2Fpage%2FinstructorHomePage&user=CHomeUiT.instructor.tmms" title="">
Delete
</a>
<a class="btn btn-default btn-xs btn-tm-actions session-copy-for-test margin-bottom-7px" data-actionlink="/page/instructorFeedbackEditCopyPage?user=CHomeUiT.instructor.tmms" data-courseid="CHomeUiT.CS2104" data-fsname="Second Feedback Session" data-placement="top" data-target="#fsCopyModal" data-toggle="modal" href="#" id="button_fscopy-CHomeUiT.CS2104-Second Feedback Session" title="Copy feedback session details">
Copy
</a>
<div data-original-title="Start submitting feedback" data-placement="top" data-toggle="tooltip" style="display: inline-block; padding-right: 5px;" title="">
<a class="btn btn-default btn-xs btn-tm-actions session-submit-for-test margin-bottom-7px" href="/page/instructorFeedbackSubmissionEditPage?courseid=CHomeUiT.CS2104&fsname=Second+Feedback+Session&user=CHomeUiT.instructor.tmms">
Submit
</a>
</div>
<div data-original-title="Send e-mails to remind students and instructors who have not submitted their feedbacks to do so" data-placement="top" data-toggle="tooltip" style="display: inline-block; padding-right: 5px;" title="">
<div class="btn-group margin-bottom-7px">
<a class="btn btn-default btn-xs btn-tm-actions session-remind-for-test" data-fsname="Second Feedback Session" disabled="" href="/page/instructorFeedbackRemind?courseid=CHomeUiT.CS2104&fsname=Second+Feedback+Session&next=%2Fpage%2FinstructorHomePage&user=CHomeUiT.instructor.tmms">
Remind
</a>
<button aria-expanded="false" class="btn btn-default btn-xs btn-tm-actions dropdown-toggle session-remind-options-for-test" data-toggle="dropdown" disabled="" type="button">
<span class="caret">
</span>
</button>
<ul class="dropdown-menu" role="menu">
<li>
<a class="session-remind-inner-for-test" data-fsname="Second Feedback Session" disabled="" href="/page/instructorFeedbackRemind?courseid=CHomeUiT.CS2104&fsname=Second+Feedback+Session&next=%2Fpage%2FinstructorHomePage&user=CHomeUiT.instructor.tmms">
Remind all students
</a>
</li>
<li>
<a class="session-remind-particular-for-test" data-actionlink="/page/instructorFeedbackRemindParticularStudentsPage?courseid=CHomeUiT.CS2104&fsname=Second+Feedback+Session&user=CHomeUiT.instructor.tmms" data-courseid="CHomeUiT.CS2104" data-fsname="Second Feedback Session" data-target="#remindModal" data-toggle="modal" disabled="" href="#">
Remind particular students
</a>
</li>
</ul>
</div>
</div>
<a class="btn btn-default btn-xs margin-bottom-7px btn-tm-actions session-publish-for-test" data-fsname="Second Feedback Session" data-original-title="This session is not yet opened" data-placement="top" data-sending-published-email="true" data-toggle="tooltip" disabled="" href="/page/instructorFeedbackPublish?courseid=CHomeUiT.CS2104&fsname=Second+Feedback+Session&next=%2Fpage%2FinstructorHomePage&user=CHomeUiT.instructor.tmms" title="">
Publish Results
</a>
</td>
</tr>
<tr id="session2">
<td>
Third Feedback Session
</td>
<td class="text-nowrap">
<span class="tool-tip-decorate" data-original-title="Tue, 10 Apr 2012, 11:59 PM" data-toggle="tooltip" title="">
10 Apr 11:59 PM
</span>
</td>
<td class="text-nowrap">
<span class="tool-tip-decorate" data-original-title="Mon, 30 Apr 2012, 11:59 PM" data-toggle="tooltip" title="">
30 Apr 11:59 PM
</span>
</td>
<td>
<span class="tool-tip-decorate" data-original-title="The feedback session has been created, is visible, and has ended." data-placement="top" data-toggle="tooltip" title="">
Closed
</span>
</td>
<td class="session-response-for-test">
<a href="/page/feedbackSessionStatsPage?courseid=CHomeUiT.CS2104&fsname=Third+Feedback+Session&user=CHomeUiT.instructor.tmms" oncontextmenu="return false;">
Show
</a>
</td>
<td class="no-print text-nowrap padding-right-25px">
<a class="btn btn-default btn-xs btn-tm-actions session-view-for-test margin-bottom-7px" data-original-title="View the submitted responses for this feedback session" data-placement="top" data-toggle="tooltip" href="/page/instructorFeedbackResultsPage?courseid=CHomeUiT.CS2104&fsname=Third+Feedback+Session&user=CHomeUiT.instructor.tmms" title="">
View Results
</a>
<a class="btn btn-default btn-xs btn-tm-actions session-edit-for-test margin-bottom-7px" data-original-title="Edit feedback session details" data-placement="top" data-toggle="tooltip" href="/page/instructorFeedbackEditPage?courseid=CHomeUiT.CS2104&fsname=Third+Feedback+Session&user=CHomeUiT.instructor.tmms" title="">
Edit
</a>
<a class="btn btn-default btn-xs btn-tm-actions session-delete-for-test margin-bottom-7px" data-courseid="CHomeUiT.CS2104" data-fsname="Third Feedback Session" data-original-title="Delete the feedback session" data-placement="top" data-toggle="tooltip" href="/page/instructorFeedbackDelete?courseid=CHomeUiT.CS2104&fsname=Third+Feedback+Session&next=%2Fpage%2FinstructorHomePage&user=CHomeUiT.instructor.tmms" title="">
Delete
</a>
<a class="btn btn-default btn-xs btn-tm-actions session-copy-for-test margin-bottom-7px" data-actionlink="/page/instructorFeedbackEditCopyPage?user=CHomeUiT.instructor.tmms" data-courseid="CHomeUiT.CS2104" data-fsname="Third Feedback Session" data-placement="top" data-target="#fsCopyModal" data-toggle="modal" href="#" id="button_fscopy-CHomeUiT.CS2104-Third Feedback Session" title="Copy feedback session details">
Copy
</a>
<div data-original-title="Start submitting feedback" data-placement="top" data-toggle="tooltip" style="display: inline-block; padding-right: 5px;" title="">
<a class="btn btn-default btn-xs btn-tm-actions session-submit-for-test margin-bottom-7px" href="/page/instructorFeedbackSubmissionEditPage?courseid=CHomeUiT.CS2104&fsname=Third+Feedback+Session&user=CHomeUiT.instructor.tmms">
Submit
</a>
</div>
<div data-original-title="Send e-mails to remind students and instructors who have not submitted their feedbacks to do so" data-placement="top" data-toggle="tooltip" style="display: inline-block; padding-right: 5px;" title="">
<div class="btn-group margin-bottom-7px">
<a class="btn btn-default btn-xs btn-tm-actions session-remind-for-test" data-fsname="Third Feedback Session" disabled="" href="/page/instructorFeedbackRemind?courseid=CHomeUiT.CS2104&fsname=Third+Feedback+Session&next=%2Fpage%2FinstructorHomePage&user=CHomeUiT.instructor.tmms">
Remind
</a>
<button aria-expanded="false" class="btn btn-default btn-xs btn-tm-actions dropdown-toggle session-remind-options-for-test" data-toggle="dropdown" disabled="" type="button">
<span class="caret">
</span>
</button>
<ul class="dropdown-menu" role="menu">
<li>
<a class="session-remind-inner-for-test" data-fsname="Third Feedback Session" disabled="" href="/page/instructorFeedbackRemind?courseid=CHomeUiT.CS2104&fsname=Third+Feedback+Session&next=%2Fpage%2FinstructorHomePage&user=CHomeUiT.instructor.tmms">
Remind all students
</a>
</li>
<li>
<a class="session-remind-particular-for-test" data-actionlink="/page/instructorFeedbackRemindParticularStudentsPage?courseid=CHomeUiT.CS2104&fsname=Third+Feedback+Session&user=CHomeUiT.instructor.tmms" data-courseid="CHomeUiT.CS2104" data-fsname="Third Feedback Session" data-target="#remindModal" data-toggle="modal" disabled="" href="#">
Remind particular students
</a>
</li>
</ul>
</div>
</div>
<a class="btn btn-default btn-xs margin-bottom-7px btn-tm-actions session-publish-for-test" data-fsname="Third Feedback Session" data-original-title="Make session responses available for viewing" data-placement="top" data-sending-published-email="true" data-toggle="tooltip" href="/page/instructorFeedbackPublish?courseid=CHomeUiT.CS2104&fsname=Third+Feedback+Session&next=%2Fpage%2FinstructorHomePage&user=CHomeUiT.instructor.tmms" title="">
Publish Results
</a>
</td>
</tr>
<tr id="session3">
<td>
Fourth Feedback Session
</td>
<td class="text-nowrap">
<span class="tool-tip-decorate" data-original-title="Thu, 05 Apr 2012, 11:59 AM" data-toggle="tooltip" title="">
5 Apr 11:59 AM
</span>
</td>
<td class="text-nowrap">
<span class="tool-tip-decorate" data-original-title="Fri, 20 Apr 2012, 11:59 AM" data-toggle="tooltip" title="">
20 Apr 11:59 AM
</span>
</td>
<td>
<span class="tool-tip-decorate" data-original-title="The feedback session has been created, is visible, and has ended.<br>The responses for this session are visible." data-placement="top" data-toggle="tooltip" title="">
Published
</span>
</td>
<td class="session-response-for-test">
0 / 0
</td>
<td class="no-print text-nowrap padding-right-25px">
<a class="btn btn-default btn-xs btn-tm-actions session-view-for-test margin-bottom-7px" data-original-title="View the submitted responses for this feedback session" data-placement="top" data-toggle="tooltip" href="/page/instructorFeedbackResultsPage?courseid=CHomeUiT.CS2104&fsname=Fourth+Feedback+Session&user=CHomeUiT.instructor.tmms" title="">
View Results
</a>
<a class="btn btn-default btn-xs btn-tm-actions session-edit-for-test margin-bottom-7px" data-original-title="Edit feedback session details" data-placement="top" data-toggle="tooltip" href="/page/instructorFeedbackEditPage?courseid=CHomeUiT.CS2104&fsname=Fourth+Feedback+Session&user=CHomeUiT.instructor.tmms" title="">
Edit
</a>
<a class="btn btn-default btn-xs btn-tm-actions session-delete-for-test margin-bottom-7px" data-courseid="CHomeUiT.CS2104" data-fsname="Fourth Feedback Session" data-original-title="Delete the feedback session" data-placement="top" data-toggle="tooltip" href="/page/instructorFeedbackDelete?courseid=CHomeUiT.CS2104&fsname=Fourth+Feedback+Session&next=%2Fpage%2FinstructorHomePage&user=CHomeUiT.instructor.tmms" title="">
Delete
</a>
<a class="btn btn-default btn-xs btn-tm-actions session-copy-for-test margin-bottom-7px" data-actionlink="/page/instructorFeedbackEditCopyPage?user=CHomeUiT.instructor.tmms" data-courseid="CHomeUiT.CS2104" data-fsname="Fourth Feedback Session" data-placement="top" data-target="#fsCopyModal" data-toggle="modal" href="#" id="button_fscopy-CHomeUiT.CS2104-Fourth Feedback Session" title="Copy feedback session details">
Copy
</a>
<div data-original-title="Start submitting feedback" data-placement="top" data-toggle="tooltip" style="display: inline-block; padding-right: 5px;" title="">
<a class="btn btn-default btn-xs btn-tm-actions session-submit-for-test margin-bottom-7px" href="/page/instructorFeedbackSubmissionEditPage?courseid=CHomeUiT.CS2104&fsname=Fourth+Feedback+Session&user=CHomeUiT.instructor.tmms">
Submit
</a>
</div>
<div data-original-title="Send e-mails to remind students and instructors who have not submitted their feedbacks to do so" data-placement="top" data-toggle="tooltip" style="display: inline-block; padding-right: 5px;" title="">
<div class="btn-group margin-bottom-7px">
<a class="btn btn-default btn-xs btn-tm-actions session-remind-for-test" data-fsname="Fourth Feedback Session" disabled="" href="/page/instructorFeedbackRemind?courseid=CHomeUiT.CS2104&fsname=Fourth+Feedback+Session&next=%2Fpage%2FinstructorHomePage&user=CHomeUiT.instructor.tmms">
Remind
</a>
<button aria-expanded="false" class="btn btn-default btn-xs btn-tm-actions dropdown-toggle session-remind-options-for-test" data-toggle="dropdown" disabled="" type="button">
<span class="caret">
</span>
</button>
<ul class="dropdown-menu" role="menu">
<li>
<a class="session-remind-inner-for-test" data-fsname="Fourth Feedback Session" disabled="" href="/page/instructorFeedbackRemind?courseid=CHomeUiT.CS2104&fsname=Fourth+Feedback+Session&next=%2Fpage%2FinstructorHomePage&user=CHomeUiT.instructor.tmms">
Remind all students
</a>
</li>
<li>
<a class="session-remind-particular-for-test" data-actionlink="/page/instructorFeedbackRemindParticularStudentsPage?courseid=CHomeUiT.CS2104&fsname=Fourth+Feedback+Session&user=CHomeUiT.instructor.tmms" data-courseid="CHomeUiT.CS2104" data-fsname="Fourth Feedback Session" data-target="#remindModal" data-toggle="modal" disabled="" href="#">
Remind particular students
</a>
</li>
</ul>
</div>
</div>
<a class="btn btn-default btn-xs margin-bottom-7px btn-tm-actions session-unpublish-for-test" data-fsname="Fourth Feedback Session" data-original-title="Make responses no longer visible" data-placement="top" data-sending-published-email="true" data-toggle="tooltip" href="/page/instructorFeedbackUnpublish?courseid=CHomeUiT.CS2104&fsname=Fourth+Feedback+Session&next=%2Fpage%2FinstructorHomePage&user=CHomeUiT.instructor.tmms" title="">
Unpublish Results
</a>
</td>
</tr>
</tbody>
</table>
</div>
<div aria-hidden="true" aria-labelledby="fsCopyModal" class="modal fade" id="fsCopyModal" role="dialog" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<form action="/page/instructorFeedbackEditCopy?next=%2Fpage%2FinstructorHomePage" id="instructorCopyModalForm" method="post" role="form">
<div class="modal-header">
<button aria-hidden="true" class="close" data-dismiss="modal" type="button">
×
</button>
<h4 class="modal-title">
Copy this feedback session to other courses
<br>
<small>
(Select the course(s) you want to copy this feedback session to)
</small>
</h4>
</div>
<div class="modal-body">
<div class="form-group" id="courseList">
</div>
</div>
<div class="modal-footer">
<button class="btn btn-default" data-dismiss="modal" type="button">
Cancel
</button>
<input class="btn btn-primary" id="fscopy_submit" type="submit" value="Copy">
<input name="user" type="hidden" value="CHomeUiT.instructor.tmms">
</div>
</form>
</div>
</div>
</div>
</div>
| karthikaacharya/teammates | src/test/resources/pages/instructorHomeHTMLResponseRatePass.html | HTML | gpl-2.0 | 39,004 |
/*
* Copyright (C) 2010,Imagis Technology Co. Ltd. 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 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.
*
*/
#include <linux/i2c.h>
#include <linux/delay.h>
#include <linux/slab.h>
#include <linux/firmware.h>
#include <linux/stat.h>
#include "ist30xxb.h"
#include "ist30xxb_update.h"
#include "ist30xxb_misc.h"
#include "ist30xxb_cmcs.h"
#if IST30XX_INTERNAL_CMCS_BIN
#include "ist30xxb_cmcs_bin.h"
#endif
#define CMCS_PARSING_DEBUG (0)
#define CMCS_READY (0)
#define CMCS_NOT_READY (-1)
#define TSP_CH_UNUSED (0)
#define TSP_CH_SCREEN (1)
#define TSP_CH_KEY (2)
#define TSP_CH_UNKNOWN (-1)
extern struct ist30xx_data *ts_data;
int cmcs_ready = CMCS_READY;
u8 *ts_cmcs_bin = NULL;
u32 ts_cmcs_bin_size = 0;
CMCS_BIN_INFO ist30xx_cmcs_bin;
CMCS_BIN_INFO *ts_cmcs = (CMCS_BIN_INFO *)&ist30xx_cmcs_bin;
CMCS_BUF ist30xx_cmcs_buf;
CMCS_BUF *ts_cmcs_buf = (CMCS_BUF *)&ist30xx_cmcs_buf;
int ist30xx_parse_cmcs_bin(const u8 *buf, const u32 size)
{
int ret = -EPERM;
CMCS_INFO *cmcs = (CMCS_INFO *)&ts_cmcs->cmcs;
memcpy(ts_cmcs->magic1, buf, sizeof(ts_cmcs->magic1));
memcpy(ts_cmcs->magic2, &buf[size - sizeof(ts_cmcs->magic2)],
sizeof(ts_cmcs->magic2));
memcpy(cmcs, &buf[sizeof(ts_cmcs->magic1)], sizeof(ts_cmcs->cmcs));
if (!strncmp(ts_cmcs->magic1, IST30XX_CMCS_MAGIC, sizeof(ts_cmcs->magic1))
&& !strncmp(ts_cmcs->magic2, IST30XX_CMCS_MAGIC, sizeof(ts_cmcs->magic2))) {
int idx;
idx = sizeof(ts_cmcs->magic1) + sizeof(ts_cmcs->cmcs);
ts_cmcs->buf_cmcs = (u8 *)&buf[idx];
idx += cmcs->cmd.cmcs_size;
ts_cmcs->buf_sensor = (u32 *)&buf[idx];
idx += (cmcs->sensor1_size + cmcs->sensor2_size + cmcs->sensor3_size);
ts_cmcs->buf_node = (u16 *)&buf[idx];
ret = 0;
}
tsp_verb("Magic1: %s, Magic2: %s\n", ts_cmcs->magic1, ts_cmcs->magic2);
tsp_verb(" mode: 0x%x, base(screen: %d, key: %d)\n",
cmcs->cmd.mode, cmcs->cmd.base_screen, cmcs->cmd.base_key);
tsp_verb(" start_cp (cm: %d, cs: %d), vcmp (cm: %d, cs: %d)\n",
cmcs->cmd.start_cp_cm, cmcs->cmd.start_cp_cs,
cmcs->cmd.vcmp_cm, cmcs->cmd.vcmp_cs);
tsp_verb(" timeout: %d\n", cmcs->timeout);
tsp_verb(" baseline scrn: 0x%08x, key: 0x%08x\n",
cmcs->addr.base_screen, cmcs->addr.base_key);
tsp_verb(" start_cp: 0x%08x, vcmp: 0x%08x\n",
cmcs->addr.start_cp, cmcs->addr.vcmp);
tsp_verb(" sensor 1: 0x%08x, 2: 0x%08x, 3: 0x%08x\n",
cmcs->addr.sensor1, cmcs->addr.sensor2, cmcs->addr.sensor3);
tsp_verb(" tx: %d, rx:%d, key rx: %d, num(%d, %d, %d, %d, %d)\n",
cmcs->ch.tx_num, cmcs->ch.rx_num, cmcs->ch.key_rx, cmcs->ch.key1,
cmcs->ch.key2, cmcs->ch.key3, cmcs->ch.key4, cmcs->ch.key5);
tsp_verb(" cr: screen(%4d, %4d), key(%4d, %4d)\n",
cmcs->spec_cr.screen_min, cmcs->spec_cr.screen_max,
cmcs->spec_cr.key_min, cmcs->spec_cr.key_max);
tsp_verb(" cm: screen(%4d, %4d), key(%4d, %4d)\n",
cmcs->spec_cm.screen_min, cmcs->spec_cm.screen_max,
cmcs->spec_cm.key_min, cmcs->spec_cm.key_max);
tsp_verb(" cs: screen(%4d, %4d), key(%4d, %4d)\n",
cmcs->spec_cs.screen_min, cmcs->spec_cs.screen_max,
cmcs->spec_cs.key_min, cmcs->spec_cs.key_max);
tsp_verb(" slope - x(%d, %d), y(%d, %d)\n",
cmcs->slope.x_min, cmcs->slope.x_max,
cmcs->slope.y_min, cmcs->slope.y_max);
tsp_verb(" size - cmcs(%d), sensor(%d, %d, %d)\n",
cmcs->cmd.cmcs_size, cmcs->sensor1_size,
cmcs->sensor2_size, cmcs->sensor3_size);
tsp_verb(" checksum - cmcs: 0x%08x, sensor: 0x%08x\n",
cmcs->cmcs_chksum, cmcs->sensor_chksum);
tsp_verb(" cmcs: %x, %x, %x, %x\n", ts_cmcs->buf_cmcs[0],
ts_cmcs->buf_cmcs[1], ts_cmcs->buf_cmcs[2], ts_cmcs->buf_cmcs[3]);
tsp_verb(" sensor: %x, %x, %x, %x\n",
ts_cmcs->buf_sensor[0], ts_cmcs->buf_sensor[1],
ts_cmcs->buf_sensor[2], ts_cmcs->buf_sensor[3]);
tsp_verb(" node: %x, %x, %x, %x\n",
ts_cmcs->buf_node[0], ts_cmcs->buf_node[1],
ts_cmcs->buf_node[2], ts_cmcs->buf_node[3]);
return ret;
}
int ist30xx_get_cmcs_info(const u8 *buf, const u32 size)
{
int ret;
cmcs_ready = CMCS_NOT_READY;
ret = ist30xx_parse_cmcs_bin(buf, size);
if (unlikely(ret != TAGS_PARSE_OK))
tsp_warn("Cannot find tags of CMCS, make a bin by 'cmcs2bin.exe'\n");
return ret;
}
int ist30xx_set_cmcs_sensor(struct i2c_client *client, CMCS_INFO *cmcs, u32 *buf32)
{
int i, ret;
int len;
u32 waddr;
u32 *tmp32;
tsp_verb("%08x %08x %08x %08x\n", buf32[0], buf32[1], buf32[2], buf32[3]);
waddr = cmcs->addr.sensor1;
len = cmcs->sensor1_size / IST30XX_DATA_LEN;
for (i = 0; i < len; i++) {
ret = ist30xx_write_cmd(client, waddr, *buf32++);
if (ret) return ret;
waddr += IST30XX_DATA_LEN;
}
tmp32 = buf32;
tsp_verb("%08x %08x %08x %08x\n", tmp32[0], tmp32[1], tmp32[2], tmp32[3]);
waddr = cmcs->addr.sensor2;
len = (cmcs->sensor2_size - 0x10) / IST30XX_DATA_LEN;
for (i = 0; i < len; i++) {
ret = ist30xx_write_cmd(client, waddr, *buf32++);
if (ret) return ret;
waddr += IST30XX_DATA_LEN;
}
buf32 += (0x10 / IST30XX_DATA_LEN);
tmp32 = buf32;
tsp_verb("%08x %08x %08x %08x\n", tmp32[0], tmp32[1], tmp32[2], tmp32[3]);
waddr = cmcs->addr.sensor3;
len = cmcs->sensor3_size / IST30XX_DATA_LEN;
for (i = 0; i < len; i++) {
ret = ist30xx_write_cmd(client, waddr, *buf32++);
if (ret) return ret;
waddr += IST30XX_DATA_LEN;
}
return 0;
}
int ist30xx_set_cmcs_cmd(struct i2c_client *client, CMCS_INFO *cmcs)
{
int ret;
u32 val;
val = (u32)(cmcs->cmd.base_screen | (cmcs->cmd.mode << 16));
ret = ist30xx_write_cmd(client, cmcs->addr.base_screen, val);
if (ret) return ret;
tsp_verb("Baseline screen(0x%08x): 0x%08x\n", cmcs->addr.base_screen, val);
val = (u32)cmcs->cmd.base_key;
ret = ist30xx_write_cmd(client, cmcs->addr.base_key, val);
if (ret) return ret;
tsp_verb("Baseline key(0x%08x): 0x%08x\n", cmcs->addr.base_key, val);
val = cmcs->cmd.start_cp_cm | (cmcs->cmd.start_cp_cs << 16);
ret = ist30xx_write_cmd(client, cmcs->addr.start_cp, val);
if (ret) return ret;
tsp_verb("StartCP(0x%08x): 0x%08x\n", cmcs->addr.start_cp, val);
val = cmcs->cmd.vcmp_cm | (cmcs->cmd.vcmp_cs << 16);
ret = ist30xx_write_cmd(client, cmcs->addr.vcmp, val);
if (ret) return ret;
tsp_verb("VCMP(0x%08x): 0x%08x\n", cmcs->addr.vcmp, val);
return 0;
}
int ist30xx_parse_cmcs_buf(CMCS_INFO *cmcs, s16 *buf, int len)
{
int i, j;
int ch_num = cmcs->ch.tx_num * cmcs->ch.rx_num;
tsp_info("len: %d, ch_num : %d\n", len, ch_num);
if (ch_num > len)
ch_num = len;
tsp_info(" %d * %d\n", cmcs->ch.tx_num, cmcs->ch.rx_num);
for (i = 0; i < cmcs->ch.tx_num; i++) {
tsp_info(" ");
for (j = 0; j < cmcs->ch.rx_num; j++)
printk("%5d ", buf[i * cmcs->ch.rx_num + j]);
printk("\n");
}
return 0;
}
int ist30xx_apply_cmcs_slope(CMCS_INFO *cmcs, CMCS_BUF *cmcs_buf)
{
int i, j;
int idx1, idx2;
int ch_num = cmcs->ch.tx_num * cmcs->ch.rx_num;
int width = cmcs->ch.rx_num;
int height = cmcs->ch.tx_num;
s16 *pcm = (s16 *)cmcs_buf->cm;
s16 *pspec = (s16 *)cmcs_buf->spec;
s16 *pslope0 = (s16 *)cmcs_buf->slope0;
s16 *pslope1 = (s16 *)cmcs_buf->slope1;
if (cmcs->ch.key_rx)
width -= 1;
else
height -= 1;
memset(cmcs_buf->slope0, 0, sizeof(cmcs_buf->slope0));
memset(cmcs_buf->slope1, 0, sizeof(cmcs_buf->slope1));
memcpy(cmcs_buf->spec, ts_cmcs->buf_node, (ch_num * sizeof(u16)));
idx1 = 0;
#if CMCS_PARSING_DEBUG
tsp_info("# Node specific\n");
for (i = 0; i < cmcs->ch.tx_num; i++) {
tsp_info(" ");
for (j = 0; j < cmcs->ch.rx_num; j++)
printk("%5d ", cmcs_buf->spec[idx1++]);
printk("\n");
}
#endif
tsp_verb("# Apply slope0_x\n");
for (i = 0; i < height; i++) {
for (j = 0; j < width - 1; j++) {
idx1 = (i * cmcs->ch.rx_num) + j;
idx2 = idx1 + 1;
pslope0[idx1] = (pcm[idx2] - pcm[idx1]);
pslope0[idx1] += (pspec[idx1] - pspec[idx2]);
}
}
tsp_verb("# Apply slope1_y\n");
for (i = 0; i < height - 1; i++) {
for (j = 0; j < width; j++) {
idx1 = (i * cmcs->ch.rx_num) + j;
idx2 = idx1 + cmcs->ch.rx_num;
pslope1[idx1] = (pcm[idx2] - pcm[idx1]);
pslope1[idx1] += (pspec[idx1] - pspec[idx2]);
}
}
#if CMCS_PARSING_DEBUG
tsp_info("# slope0_x\n");
for (i = 0; i < height; i++) {
tsp_info(" ");
for (j = 0; j < width; j++) {
idx1 = (i * cmcs->ch.rx_num) + j;
printk("%5d ", pslope0[idx1]);
}
printk("\n");
}
tsp_info("# slope1_y\n");
for (i = 0; i < height; i++) {
tsp_info(" ");
for (j = 0; j < width; j++) {
idx1 = (i * cmcs->ch.rx_num) + j;
printk("%5d ", pslope1[idx1]);
}
printk("\n");
}
#endif
return 0;
}
int ist30xx_get_cmcs_buf(struct i2c_client *client, CMCS_INFO *cmcs, s16 *buf)
{
int ret;
u16 len = (IST30XX_CMCS_BUF_SIZE * sizeof(buf[0])) / IST30XX_DATA_LEN;
ret = ist30xx_read_buf(client, CMD_DEFAULT, (u32 *)buf, len);
if (ret) return ret;
#if CMCS_PARSING_DEBUG
ret = ist30xx_parse_cmcs_buf(cmcs, buf, IST30XX_CMCS_BUF_SIZE);
#endif
return ret;
}
extern int ist30xx_calib_wait(void);
#define cmcs_next_step(ret) { if (unlikely(ret)) goto end; msleep(10); }
int ist30xx_cmcs_test(const u8 *buf, int size)
{
int ret;
int len;
u32 chksum = 0;
u32 *buf32;
struct i2c_client *client = (struct i2c_client *)ts_data->client;
CMCS_INFO *cmcs = (CMCS_INFO *)&ts_cmcs->cmcs;
tsp_info("*** CM/CS test ***\n");
tsp_info(" mode: 0x%x, baseline(screen: %d, key: %d)\n",
cmcs->cmd.mode, cmcs->cmd.base_screen, cmcs->cmd.base_key);
tsp_info(" start_cp (cm: %d, cs: %d), vcmp (cm: %d, cs: %d)\n",
cmcs->cmd.start_cp_cm, cmcs->cmd.start_cp_cs,
cmcs->cmd.vcmp_cm, cmcs->cmd.vcmp_cs);
ist30xx_disable_irq(ts_data);
ret = ist30xx_cmd_run_device(client, true);
cmcs_next_step(ret);
ret = ist30xx_cmd_reg(client, CMD_ENTER_REG_ACCESS);
cmcs_next_step(ret);
/* Set sensor register */
buf32 = ts_cmcs->buf_sensor;
ret = ist30xx_set_cmcs_sensor(client, cmcs, buf32);
cmcs_next_step(ret);
/* Set command */
ret = ist30xx_set_cmcs_cmd(client, cmcs);
cmcs_next_step(ret);
ret = ist30xx_cmd_reg(client, CMD_EXIT_REG_ACCESS);
cmcs_next_step(ret);
/* Load cmcs test code */
ret = ist30xx_write_cmd(client, CMD_EXEC_MEM_CODE, 0);
cmcs_next_step(ret);
buf32 = (u32 *)ts_cmcs->buf_cmcs;
len = cmcs->cmd.cmcs_size / IST30XX_DATA_LEN;
tsp_verb("%08x %08x %08x %08x\n", buf32[0], buf32[1], buf32[2], buf32[3]);
ret = ist30xx_write_buf(client, len, buf32, len);
cmcs_next_step(ret);
/* Check checksum */
ret = ist30xx_read_cmd(client, CMD_DEFAULT, &chksum);
cmcs_next_step(ret);
if (chksum != IST30XX_CMCS_LOAD_END)
goto end;
tsp_info("CM/CS code ready!!\n");
/* Check checksum */
ret = ist30xx_read_cmd(client, CMD_DEFAULT, &chksum);
cmcs_next_step(ret);
tsp_info("CM/CS code chksum: %08x, %08x\n", chksum, cmcs->cmcs_chksum);
ist30xx_enable_irq(ts_data);
/* Wait CMCS test result */
if (ist30xx_calib_wait() == 1)
tsp_info("CM/CS test OK.\n");
else
tsp_info("CM/CS test fail.\n");
ist30xx_disable_irq(ts_data);
/* Read CM/CS data*/
if (ENABLE_CM_MODE(cmcs->cmd.mode)) {
/* Read CM data */
memset(ts_cmcs_buf->cm, 0, sizeof(ts_cmcs_buf->cm));
ret = ist30xx_get_cmcs_buf(client, cmcs, ts_cmcs_buf->cm);
cmcs_next_step(ret);
ret = ist30xx_apply_cmcs_slope(cmcs, ts_cmcs_buf);
}
if (ENABLE_CS_MODE(cmcs->cmd.mode)) {
/* Read CS0 data */
memset(ts_cmcs_buf->cs0, 0, sizeof(ts_cmcs_buf->cs0));
memset(ts_cmcs_buf->cs1, 0, sizeof(ts_cmcs_buf->cs1));
ret = ist30xx_get_cmcs_buf(client, cmcs, ts_cmcs_buf->cs0);
cmcs_next_step(ret);
/* Read CS1 data */
ret = ist30xx_get_cmcs_buf(client, cmcs, ts_cmcs_buf->cs1);
cmcs_next_step(ret);
}
ret = ist30xx_cmd_run_device(client, true);
cmcs_next_step(ret);
ist30xx_start(ts_data);
cmcs_ready = CMCS_READY;
end:
if (unlikely(ret)) {
tsp_warn("CM/CS test Fail!, ret=%d\n", ret);
} else if (unlikely(chksum != cmcs->cmcs_chksum)) {
tsp_warn("Error CheckSum: %x(%x)\n", chksum, cmcs->cmcs_chksum);
ret = -ENOEXEC;
}
ist30xx_enable_irq(ts_data);
return ret;
}
int check_tsp_type(int tx, int rx)
{
struct CMCS_CH_INFO *ch = (struct CMCS_CH_INFO *)&ts_cmcs->cmcs.ch;
int last_rx_ch = (int)ch->rx_num - 1;
int last_tx_ch = (int)ch->tx_num - 1;
if ((rx > last_rx_ch) || (rx < 0) || (tx > last_tx_ch) || (tx < 0)) {
tsp_warn("TSP channel is not correct!! (%d * %d)\n", tx, rx);
return TSP_CH_UNKNOWN;
}
if (ch->key_rx) { // Key on RX channel
if (rx == last_rx_ch) {
if ((tx == ch->key1) || (tx == ch->key2) || (tx == ch->key3) ||
(tx == ch->key4) || (tx == ch->key5))
return TSP_CH_KEY;
else
return TSP_CH_UNUSED;
}
} // Key on TX channel
else {
if (tx == last_tx_ch) {
if ((rx == ch->key1) || (rx == ch->key2) || (rx == ch->key3) ||
(rx == ch->key4) || (rx == ch->key5))
return TSP_CH_KEY;
else
return TSP_CH_UNUSED;
}
}
return TSP_CH_SCREEN;
}
int print_cmcs(s16 *buf16, char *buf)
{
int i, j;
int idx;
int count = 0;
char msg[128];
CMCS_INFO *cmcs = (CMCS_INFO *)&ts_cmcs->cmcs;
int tx_num = cmcs->ch.tx_num;
int rx_num = cmcs->ch.rx_num;
for (i = 0; i < tx_num; i++) {
for (j = 0; j < rx_num; j++) {
idx = (i * cmcs->ch.rx_num) + j;
count += sprintf(msg, "%5d ", buf16[idx]);
strcat(buf, msg);
}
count += sprintf(msg, "\n");
strcat(buf, msg);
}
return count;
}
int print_line_cmcs(int mode, s16 *buf16, char *buf)
{
int i, j;
int idx;
int type;
int count = 0;
int key_index[5] = { 0, };
int key_cnt = 0;
char msg[128];
CMCS_INFO *cmcs = (CMCS_INFO *)&ts_cmcs->cmcs;
int tx_num = cmcs->ch.tx_num;
int rx_num = cmcs->ch.rx_num;
if ((mode == CMCS_FLAG_CM_SLOPE0) || (mode == CMCS_FLAG_CM_SLOPE1)) {
if (cmcs->ch.key_rx)
rx_num--;
else
tx_num--;
}
for (i = 0; i < tx_num; i++) {
for (j = 0; j < rx_num; j++) {
type = check_tsp_type(i, j);
if ((type == TSP_CH_UNKNOWN) || (type == TSP_CH_UNUSED))
continue; // Ignore
if ((mode == CMCS_FLAG_CM_SLOPE0) && (j == (rx_num - 1)))
continue;
else if ((mode == CMCS_FLAG_CM_SLOPE1) && (i == (tx_num - 1)))
continue;
idx = (i * cmcs->ch.rx_num) + j;
if (type == TSP_CH_KEY) {
key_index[key_cnt++] = idx;
continue;
}
count += sprintf(msg, "%5d ", buf16[idx]);
strcat(buf, msg);
}
}
tsp_info("key cnt: %d\n", key_cnt);
if ((mode != CMCS_FLAG_CM_SLOPE0) && (mode != CMCS_FLAG_CM_SLOPE1)) {
tsp_info("key cnt: %d\n", key_cnt);
for (i = 0; i < key_cnt; i++) {
count += sprintf(msg, "%5d ", buf16[key_index[i]]);
strcat(buf, msg);
}
}
count += sprintf(msg, "\n");
strcat(buf, msg);
return count;
}
/* sysfs: /sys/class/touch/cmcs/info */
ssize_t ist30xx_cmcs_info_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
int count;
char msg[128];
CMCS_INFO *cmcs = (CMCS_INFO *)&ts_cmcs->cmcs;
if (cmcs_ready == CMCS_NOT_READY)
return sprintf(buf, "CMCS test is not work!!\n");
if (cmcs == NULL)
return sprintf(buf, "Unknown cmcs bin\n");
/* Mode */
count = sprintf(msg, "%d ", cmcs->cmd.mode);
strcat(buf, msg);
/* Channel */
count += sprintf(msg, "%d %d %d %d %d %d %d %d ",
cmcs->ch.tx_num, cmcs->ch.rx_num, cmcs->ch.key_rx, cmcs->ch.key1,
cmcs->ch.key2, cmcs->ch.key3, cmcs->ch.key4, cmcs->ch.key5);
strcat(buf, msg);
/* Slope */
count += sprintf(msg, "%d %d %d %d ",
cmcs->slope.x_min, cmcs->slope.x_max,
cmcs->slope.y_min, cmcs->slope.y_max);
strcat(buf, msg);
/* CM */
count += sprintf(msg, "%d %d %d %d ",
cmcs->spec_cm.screen_min, cmcs->spec_cm.screen_max,
cmcs->spec_cm.key_min, cmcs->spec_cm.key_max);
strcat(buf, msg);
/* CS */
count += sprintf(msg, "%d %d %d %d ",
cmcs->spec_cs.screen_min, cmcs->spec_cs.screen_max,
cmcs->spec_cs.key_min, cmcs->spec_cs.key_max);
strcat(buf, msg);
/* CR */
count += sprintf(msg, "%d %d %d %d ",
cmcs->spec_cr.screen_min, cmcs->spec_cr.screen_max,
cmcs->spec_cr.key_min, cmcs->spec_cr.key_max);
strcat(buf, msg);
tsp_verb("%s\n", buf);
return count;
}
/* sysfs: /sys/class/touch/cmcs/cmcs_binary */
ssize_t ist30xx_cmcs_binary_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
int ret;
if ((ts_cmcs_bin == NULL) || (ts_cmcs_bin_size == 0))
return sprintf(buf, "Binary is not correct(%d)\n", ts_cmcs_bin_size);
ist30xx_get_cmcs_info(ts_cmcs_bin, ts_cmcs_bin_size);
mutex_lock(&ist30xx_mutex);
ret = ist30xx_cmcs_test(ts_cmcs_bin, ts_cmcs_bin_size);
mutex_unlock(&ist30xx_mutex);
return sprintf(buf, (ret == 0 ? "OK\n" : "Fail\n"));
}
/* sysfs: /sys/class/touch/cmcs/cmcs_custom */
ssize_t ist30xx_cmcs_custom_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
int ret;
int bin_size = 0;
u8 *bin = NULL;
const struct firmware *req_bin = NULL;
ret = request_firmware(&req_bin, IST30XXB_CMCS_NAME, &ts_data->client->dev);
if (ret)
return sprintf(buf, "File not found, %s\n", IST30XXB_CMCS_NAME);
bin = (u8 *)req_bin->data;
bin_size = (u32)req_bin->size;
ist30xx_get_cmcs_info(bin, bin_size);
mutex_lock(&ist30xx_mutex);
ret = ist30xx_cmcs_test(bin, bin_size);
mutex_unlock(&ist30xx_mutex);
release_firmware(req_bin);
tsp_info("size: %d\n", sprintf(buf, (ret == 0 ? "OK\n" : "Fail\n")));
return sprintf(buf, (ret == 0 ? "OK\n" : "Fail\n"));
}
/* sysfs: /sys/class/touch/cmcs/cm */
ssize_t ist30xx_cm_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
CMCS_INFO *cmcs = (CMCS_INFO *)&ts_cmcs->cmcs;
if (cmcs_ready == CMCS_NOT_READY)
return sprintf(buf, "CMCS test is not work!!\n");
if ((cmcs->cmd.mode) && !(cmcs->cmd.mode & FLAG_ENABLE_CM))
return 0;
tsp_verb("CM (%d * %d)\n", cmcs->ch.tx_num, cmcs->ch.rx_num);
return print_cmcs(ts_cmcs_buf->cm, buf);
}
/* sysfs: /sys/class/touch/cmcs/cm_spec */
ssize_t ist30xx_cm_spec_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
CMCS_INFO *cmcs = (CMCS_INFO *)&ts_cmcs->cmcs;
if (cmcs_ready == CMCS_NOT_READY)
return sprintf(buf, "CMCS test is not work!!\n");
if ((cmcs->cmd.mode) && !(cmcs->cmd.mode & FLAG_ENABLE_CM))
return 0;
tsp_verb("CM Spec (%d * %d)\n", cmcs->ch.tx_num, cmcs->ch.rx_num);
return print_cmcs(ts_cmcs_buf->spec, buf);
}
/* sysfs: /sys/class/touch/cmcs/cm_slope0 */
ssize_t ist30xx_cm_slope0_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
CMCS_INFO *cmcs = (CMCS_INFO *)&ts_cmcs->cmcs;
if (cmcs_ready == CMCS_NOT_READY)
return sprintf(buf, "CMCS test is not work!!\n");
if ((cmcs->cmd.mode) && !(cmcs->cmd.mode & FLAG_ENABLE_CM))
return 0;
tsp_verb("CM Slope0_X (%d * %d)\n", cmcs->ch.tx_num, cmcs->ch.rx_num);
return print_cmcs(ts_cmcs_buf->slope0, buf);
}
/* sysfs: /sys/class/touch/cmcs/cm_slope1 */
ssize_t ist30xx_cm_slope1_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
CMCS_INFO *cmcs = (CMCS_INFO *)&ts_cmcs->cmcs;
if (cmcs_ready == CMCS_NOT_READY)
return sprintf(buf, "CMCS test is not work!!\n");
if ((cmcs->cmd.mode) && !(cmcs->cmd.mode & FLAG_ENABLE_CM))
return 0;
tsp_verb("CM Slope1_Y (%d * %d)\n",
ts_cmcs->cmcs.ch.tx_num, ts_cmcs->cmcs.ch.rx_num);
return print_cmcs(ts_cmcs_buf->slope1, buf);
}
/* sysfs: /sys/class/touch/cmcs/cs0 */
ssize_t ist30xx_cs0_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
CMCS_INFO *cmcs = (CMCS_INFO *)&ts_cmcs->cmcs;
if (cmcs_ready == CMCS_NOT_READY)
return sprintf(buf, "CMCS test is not work!!\n");
if ((cmcs->cmd.mode) && !(cmcs->cmd.mode & FLAG_ENABLE_CS))
return 0;
tsp_verb("CS0 (%d * %d)\n", cmcs->ch.tx_num, cmcs->ch.rx_num);
return print_cmcs(ts_cmcs_buf->cs0, buf);
}
/* sysfs: /sys/class/touch/cmcs/cs1 */
ssize_t ist30xx_cs1_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
CMCS_INFO *cmcs = (CMCS_INFO *)&ts_cmcs->cmcs;
if (cmcs_ready == CMCS_NOT_READY)
return sprintf(buf, "CMCS test is not work!!\n");
if ((cmcs->cmd.mode) && !(cmcs->cmd.mode & FLAG_ENABLE_CS))
return 0;
tsp_verb("CS1 (%d * %d)\n", cmcs->ch.tx_num, cmcs->ch.rx_num);
return print_cmcs(ts_cmcs_buf->cs1, buf);
}
int print_cm_slope_result(u8 flag, s16 *buf16, char *buf)
{
int i, j;
int type, idx;
int count = 0, err_cnt = 0;
int min_spec, max_spec;
char msg[128];
CMCS_INFO *cmcs = (CMCS_INFO *)&ts_cmcs->cmcs;
struct CMCS_SLOPE_INFO *spec = (struct CMCS_SLOPE_INFO *)&cmcs->slope;
if (flag == CMCS_FLAG_CM_SLOPE0) {
min_spec = spec->x_min;
max_spec = spec->x_max;
} else if (flag == CMCS_FLAG_CM_SLOPE1) {
min_spec = spec->y_min;
max_spec = spec->y_max;
} else {
count = sprintf(msg, "Unknown flag: %d\n", flag);
strcat(buf, msg);
return count;
}
min_spec *= -1;
count = sprintf(msg, "Spec: %d ~ %d\n", min_spec, max_spec);
strcat(buf, msg);
for (i = 0; i < cmcs->ch.tx_num; i++) {
for (j = 0; j < cmcs->ch.rx_num; j++) {
idx = (i * cmcs->ch.rx_num) + j;
type = check_tsp_type(i, j);
if ((type == TSP_CH_UNKNOWN) || (type == TSP_CH_UNUSED))
continue; // Ignore
if ((buf16[idx] > min_spec) && (buf16[idx] < max_spec))
continue; // OK
count += sprintf(msg, "%2d,%2d:%4d\n", i, j, buf16[idx]);
strcat(buf, msg);
err_cnt++;
}
}
/* Check error count */
if (err_cnt == 0)
count += sprintf(msg, "OK\n");
else
count += sprintf(msg, "Fail, node count: %d\n", err_cnt);
strcat(buf, msg);
return count;
}
int print_cs_result(s16 *buf16, char *buf)
{
int i, j;
int type, idx;
int count = 0, err_cnt = 0;
int min_spec, max_spec;
char msg[128];
CMCS_INFO *cmcs = (CMCS_INFO *)&ts_cmcs->cmcs;
struct CMCS_SPEC_INFO *spec = (struct CMCS_SPEC_INFO *)&cmcs->spec_cs;
count = sprintf(msg, "Spec: screen(%d~%d), key(%d~%d)\n",
spec->screen_min, spec->screen_max, spec->key_min, spec->key_max);
strcat(buf, msg);
for (i = 0; i < cmcs->ch.tx_num; i++) {
for (j = 0; j < cmcs->ch.rx_num; j++) {
idx = (i * cmcs->ch.rx_num) + j;
type = check_tsp_type(i, j);
if ((type == TSP_CH_UNKNOWN) || (type == TSP_CH_UNUSED))
continue; // Ignore
if (type == TSP_CH_SCREEN) {
min_spec = spec->screen_min;
max_spec = spec->screen_max;
} else { // TSP_CH_KEY
min_spec = spec->key_min;
max_spec = spec->key_max;
}
if ((buf16[idx] > min_spec) && (buf16[idx] < max_spec))
continue; // OK
count += sprintf(msg, "%2d,%2d:%4d\n", i, j, buf16[idx]);
strcat(buf, msg);
err_cnt++;
}
}
/* Check error count */
if (err_cnt == 0)
count += sprintf(msg, "OK\n");
else
count += sprintf(msg, "Fail, node count: %d\n", err_cnt);
strcat(buf, msg);
return count;
}
/* sysfs: /sys/class/touch/cmcs/cm_result */
ssize_t ist30xx_cm_result_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
int i, j;
int type, idx, err_cnt = 0;
int min_spec, max_spec;
int count = 0;
short cm;
char msg[128];
CMCS_INFO *cmcs = (CMCS_INFO *)&ts_cmcs->cmcs;
if (cmcs_ready == CMCS_NOT_READY)
return sprintf(buf, "CMCS test is not work!!\n");
if ((cmcs->cmd.mode) && !(cmcs->cmd.mode & FLAG_ENABLE_CM))
return 0;
for (i = 0; i < cmcs->ch.tx_num; i++) {
for (j = 0; j < cmcs->ch.rx_num; j++) {
idx = (i * cmcs->ch.rx_num) + j;
type = check_tsp_type(i, j);
if ((type == TSP_CH_UNKNOWN) || (type == TSP_CH_UNUSED))
continue;
min_spec = max_spec = ts_cmcs_buf->spec[idx];
if (type == TSP_CH_SCREEN) {
min_spec -= (min_spec * cmcs->spec_cm.screen_min / 100);
max_spec += (min_spec * cmcs->spec_cm.screen_max / 100);
} else { // TSP_CH_KEY
min_spec -= (min_spec * cmcs->spec_cm.key_min / 100);
max_spec += (min_spec * cmcs->spec_cm.key_max / 100);
}
cm = ts_cmcs_buf->cm[idx];
if ((cm > min_spec) && (cm < max_spec))
continue; // OK
count += sprintf(msg, "%2d,%2d:%4d (%4d~%4d)\n",
i, j, cm, min_spec, max_spec);
strcat(buf, msg);
err_cnt++;
}
}
/* Check error count */
if (err_cnt == 0)
count += sprintf(msg, "OK\n");
else
count += sprintf(msg, "Fail, node count: %d\n", err_cnt);
strcat(buf, msg);
return count;
}
/* sysfs: /sys/class/touch/cmcs/cm_slope0_result */
ssize_t ist30xx_cm_slope0_result_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
CMCS_INFO *cmcs = (CMCS_INFO *)&ts_cmcs->cmcs;
if (cmcs_ready == CMCS_NOT_READY)
return sprintf(buf, "CMCS test is not work!!\n");
if ((cmcs->cmd.mode) && !(cmcs->cmd.mode & FLAG_ENABLE_CM))
return 0;
return print_cm_slope_result(CMCS_FLAG_CM_SLOPE0,
ts_cmcs_buf->slope0, buf);
}
/* sysfs: /sys/class/touch/cmcs/cm_slope1_result */
ssize_t ist30xx_cm_slope1_result_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
CMCS_INFO *cmcs = (CMCS_INFO *)&ts_cmcs->cmcs;
if (cmcs_ready == CMCS_NOT_READY)
return sprintf(buf, "CMCS test is not work!!\n");
if ((cmcs->cmd.mode) && !(cmcs->cmd.mode & FLAG_ENABLE_CM))
return 0;
return print_cm_slope_result(CMCS_FLAG_CM_SLOPE1,
ts_cmcs_buf->slope1, buf);
}
/* sysfs: /sys/class/touch/cmcs/cs0_result */
ssize_t ist30xx_cs0_result_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
CMCS_INFO *cmcs = (CMCS_INFO *)&ts_cmcs->cmcs;
if (cmcs_ready == CMCS_NOT_READY)
return sprintf(buf, "CMCS test is not work!!\n");
if ((cmcs->cmd.mode) && !(cmcs->cmd.mode & FLAG_ENABLE_CS))
return 0;
return print_cs_result(ts_cmcs_buf->cs0, buf);
}
/* sysfs: /sys/class/touch/cmcs/cs1_result */
ssize_t ist30xx_cs1_result_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
CMCS_INFO *cmcs = (CMCS_INFO *)&ts_cmcs->cmcs;
if (cmcs_ready == CMCS_NOT_READY)
return sprintf(buf, "CMCS test is not work!!\n");
if ((cmcs->cmd.mode) && !(cmcs->cmd.mode & FLAG_ENABLE_CS))
return 0;
return print_cs_result(ts_cmcs_buf->cs1, buf);
}
/* sysfs: /sys/class/touch/cmcs/line_cm */
ssize_t ist30xx_line_cm_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
CMCS_INFO *cmcs = (CMCS_INFO *)&ts_cmcs->cmcs;
if (cmcs_ready == CMCS_NOT_READY)
return sprintf(buf, "CMCS test is not work!!\n");
if ((cmcs->cmd.mode) && !(cmcs->cmd.mode & FLAG_ENABLE_CM))
return 0;
return print_line_cmcs(CMCS_FLAG_CM, ts_cmcs_buf->cm, buf);
}
/* sysfs: /sys/class/touch/cmcs/line_cm_slope0 */
ssize_t ist30xx_line_cm_slope0_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
CMCS_INFO *cmcs = (CMCS_INFO *)&ts_cmcs->cmcs;
if (cmcs_ready == CMCS_NOT_READY)
return sprintf(buf, "CMCS test is not work!!\n");
if ((cmcs->cmd.mode) && !(cmcs->cmd.mode & FLAG_ENABLE_CM))
return 0;
return print_line_cmcs(CMCS_FLAG_CM_SLOPE0, ts_cmcs_buf->slope0, buf);
}
/* sysfs: /sys/class/touch/cmcs/line_cm_slope1 */
ssize_t ist30xx_line_cm_slope1_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
CMCS_INFO *cmcs = (CMCS_INFO *)&ts_cmcs->cmcs;
if (cmcs_ready == CMCS_NOT_READY)
return sprintf(buf, "CMCS test is not work!!\n");
if ((cmcs->cmd.mode) && !(cmcs->cmd.mode & FLAG_ENABLE_CM))
return 0;
return print_line_cmcs(CMCS_FLAG_CM_SLOPE1, ts_cmcs_buf->slope1, buf);
}
/* sysfs: /sys/class/touch/cmcs/line_cs0 */
ssize_t ist30xx_line_cs0_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
CMCS_INFO *cmcs = (CMCS_INFO *)&ts_cmcs->cmcs;
if (cmcs_ready == CMCS_NOT_READY)
return sprintf(buf, "CMCS test is not work!!\n");
if ((cmcs->cmd.mode) && !(cmcs->cmd.mode & FLAG_ENABLE_CS))
return 0;
return print_line_cmcs(CMCS_FLAG_CS0, ts_cmcs_buf->cs0, buf);
}
/* sysfs: /sys/class/touch/cmcs/line_cs1 */
ssize_t ist30xx_line_cs1_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
CMCS_INFO *cmcs = (CMCS_INFO *)&ts_cmcs->cmcs;
if (cmcs_ready == CMCS_NOT_READY)
return sprintf(buf, "CMCS test is not work!!\n");
if ((cmcs->cmd.mode) && !(cmcs->cmd.mode & FLAG_ENABLE_CS))
return 0;
return print_line_cmcs(CMCS_FLAG_CS1, ts_cmcs_buf->cs1, buf);
}
/* sysfs : cmcs */
static DEVICE_ATTR(info, S_IRUGO, ist30xx_cmcs_info_show, NULL);
static DEVICE_ATTR(cmcs_binary, S_IRUGO, ist30xx_cmcs_binary_show, NULL);
static DEVICE_ATTR(cmcs_custom, S_IRUGO, ist30xx_cmcs_custom_show, NULL);
static DEVICE_ATTR(cm, S_IRUGO, ist30xx_cm_show, NULL);
static DEVICE_ATTR(cm_spec, S_IRUGO, ist30xx_cm_spec_show, NULL);
static DEVICE_ATTR(cm_slope0, S_IRUGO, ist30xx_cm_slope0_show, NULL);
static DEVICE_ATTR(cm_slope1, S_IRUGO, ist30xx_cm_slope1_show, NULL);
static DEVICE_ATTR(cs0, S_IRUGO, ist30xx_cs0_show, NULL);
static DEVICE_ATTR(cs1, S_IRUGO, ist30xx_cs1_show, NULL);
static DEVICE_ATTR(cm_result, S_IRUGO, ist30xx_cm_result_show, NULL);
static DEVICE_ATTR(cm_slope0_result, S_IRUGO, ist30xx_cm_slope0_result_show, NULL);
static DEVICE_ATTR(cm_slope1_result, S_IRUGO, ist30xx_cm_slope1_result_show, NULL);
static DEVICE_ATTR(cs0_result, S_IRUGO, ist30xx_cs0_result_show, NULL);
static DEVICE_ATTR(cs1_result, S_IRUGO, ist30xx_cs1_result_show, NULL);
static DEVICE_ATTR(line_cm, S_IRUGO, ist30xx_line_cm_show, NULL);
static DEVICE_ATTR(line_cm_slope0, S_IRUGO, ist30xx_line_cm_slope0_show, NULL);
static DEVICE_ATTR(line_cm_slope1, S_IRUGO, ist30xx_line_cm_slope1_show, NULL);
static DEVICE_ATTR(line_cs0, S_IRUGO, ist30xx_line_cs0_show, NULL);
static DEVICE_ATTR(line_cs1, S_IRUGO, ist30xx_line_cs1_show, NULL);
static struct attribute *cmcs_attributes[] = {
&dev_attr_info.attr,
&dev_attr_cmcs_binary.attr,
&dev_attr_cmcs_custom.attr,
&dev_attr_cm.attr,
&dev_attr_cm_spec.attr,
&dev_attr_cm_slope0.attr,
&dev_attr_cm_slope1.attr,
&dev_attr_cs0.attr,
&dev_attr_cs1.attr,
&dev_attr_cm_result.attr,
&dev_attr_cm_slope0_result.attr,
&dev_attr_cm_slope1_result.attr,
&dev_attr_cs0_result.attr,
&dev_attr_cs1_result.attr,
&dev_attr_line_cm.attr,
&dev_attr_line_cm_slope0.attr,
&dev_attr_line_cm_slope1.attr,
&dev_attr_line_cs0.attr,
&dev_attr_line_cs1.attr,
NULL,
};
static struct attribute_group cmcs_attr_group = {
.attrs = cmcs_attributes,
};
extern struct class *ist30xx_class;
struct device *ist30xx_cmcs_dev;
int ist30xx_init_cmcs_sysfs(void)
{
/* /sys/class/touch/cmcs */
ist30xx_cmcs_dev = device_create(ist30xx_class, NULL, 0, NULL, "cmcs");
/* /sys/class/touch/cmcs/... */
if (unlikely(sysfs_create_group(&ist30xx_cmcs_dev->kobj,
&cmcs_attr_group)))
tsp_err("Failed to create sysfs group(%s)!\n", "cmcs");
#if IST30XX_INTERNAL_CMCS_BIN
ts_cmcs_bin = (u8 *)ist30xxb_cmcs;
ts_cmcs_bin_size = sizeof(ist30xxb_cmcs);
ist30xx_get_cmcs_info(ts_cmcs_bin, ts_cmcs_bin_size);
#endif
return 0;
}
| Jackeagle/kernel_samsung | drivers/input/touchscreen/imagis_ist30xxb/ist30xxb_cmcs.c | C | gpl-2.0 | 30,874 |
/**
* Copyright (c) 2008-2012 Indivica Inc.
*
* This software is made available under the terms of the
* GNU General Public License, Version 2, 1991 (GPLv2).
* License details are available via "indivica.ca/gplv2"
* and "gnu.org/licenses/gpl-2.0.html".
*/
package oscar.dms.data;
import org.apache.struts.action.ActionForm;
public class AddDocumentTypeForm extends ActionForm {
private String function = "";
private String docType = "";
public AddDocumentTypeForm() {
}
public String getFunction() {
return function;
}
public String getDocType() {
return docType;
}
public void setFunction(String function) {
this.function = function;
}
public void setDocType(String docType) {
this.docType = docType;
}
}
| hexbinary/landing | src/main/java/oscar/dms/data/AddDocumentTypeForm.java | Java | gpl-2.0 | 801 |
package org.dolphinemu.dolphinemu.activities;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.Uri;
import android.os.Bundle;
import androidx.fragment.app.FragmentActivity;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import android.util.Log;
import android.widget.Toast;
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.model.GameFile;
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization;
import org.dolphinemu.dolphinemu.services.GameFileCacheService;
import org.dolphinemu.dolphinemu.ui.main.TvMainActivity;
import org.dolphinemu.dolphinemu.utils.AppLinkHelper;
import org.dolphinemu.dolphinemu.utils.DirectoryStateReceiver;
/**
* Linker between leanback homescreen and app
*/
public class AppLinkActivity extends FragmentActivity
{
private static final String TAG = "AppLinkActivity";
private AppLinkHelper.PlayAction playAction;
private DirectoryStateReceiver directoryStateReceiver;
private BroadcastReceiver gameFileCacheReceiver;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Intent intent = getIntent();
Uri uri = intent.getData();
Log.v(TAG, uri.toString());
if (uri.getPathSegments().isEmpty())
{
Log.e(TAG, "Invalid uri " + uri);
finish();
return;
}
AppLinkHelper.AppLinkAction action = AppLinkHelper.extractAction(uri);
switch (action.getAction())
{
case AppLinkHelper.PLAY:
playAction = (AppLinkHelper.PlayAction) action;
initResources();
break;
case AppLinkHelper.BROWSE:
browse();
break;
default:
throw new IllegalArgumentException("Invalid Action " + action);
}
}
/**
* Need to init these since they usually occur in the main activity.
*/
private void initResources()
{
IntentFilter directoryStateIntentFilter = new IntentFilter(
DirectoryInitialization.BROADCAST_ACTION);
IntentFilter gameFileCacheIntentFilter = new IntentFilter(
GameFileCacheService.BROADCAST_ACTION);
directoryStateReceiver =
new DirectoryStateReceiver(directoryInitializationState ->
{
if (directoryInitializationState ==
DirectoryInitialization.DirectoryInitializationState.DOLPHIN_DIRECTORIES_INITIALIZED)
{
tryPlay(playAction);
}
else if (directoryInitializationState ==
DirectoryInitialization.DirectoryInitializationState.EXTERNAL_STORAGE_PERMISSION_NEEDED)
{
Toast.makeText(this, R.string.write_permission_needed, Toast.LENGTH_SHORT)
.show();
}
else if (directoryInitializationState ==
DirectoryInitialization.DirectoryInitializationState.CANT_FIND_EXTERNAL_STORAGE)
{
Toast.makeText(this, R.string.external_storage_not_mounted, Toast.LENGTH_SHORT)
.show();
}
});
gameFileCacheReceiver =
new BroadcastReceiver()
{
@Override
public void onReceive(Context context, Intent intent)
{
if (DirectoryInitialization.areDolphinDirectoriesReady())
{
tryPlay(playAction);
}
}
};
LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(this);
broadcastManager.registerReceiver(directoryStateReceiver, directoryStateIntentFilter);
broadcastManager.registerReceiver(gameFileCacheReceiver, gameFileCacheIntentFilter);
DirectoryInitialization.start(this);
GameFileCacheService.startLoad(this);
}
/**
* Action if channel icon is selected
*/
private void browse()
{
Intent openApp = new Intent(this, TvMainActivity.class);
startActivity(openApp);
finish();
}
private void tryPlay(AppLinkHelper.PlayAction action)
{
// TODO: This approach of getting the game from the game file cache without rescanning
// the library means that we can fail to launch games if the cache file has been deleted.
GameFile game = GameFileCacheService.getGameFileByGameId(action.getGameId());
// If game == null and the load isn't done, wait for the next GameFileCacheService broadcast.
// If game == null and the load is done, call play with a null game, making us exit in failure.
if (game != null || GameFileCacheService.hasLoadedCache())
{
play(action, game);
}
}
/**
* Action if program(game) is selected
*/
private void play(AppLinkHelper.PlayAction action, GameFile game)
{
Log.d(TAG, "Playing game "
+ action.getGameId()
+ " from channel "
+ action.getChannelId());
if (game == null)
Log.e(TAG, "Invalid Game: " + action.getGameId());
else
startGame(game);
finish();
}
private void startGame(GameFile game)
{
if (directoryStateReceiver != null)
{
LocalBroadcastManager.getInstance(this).unregisterReceiver(directoryStateReceiver);
directoryStateReceiver = null;
}
EmulationActivity.launch(this, game);
}
}
| JonnyH/dolphin | Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/AppLinkActivity.java | Java | gpl-2.0 | 5,415 |
/*
* Copyright (c) 2008, 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4530474
* @summary Tests if background-color CSS attribute in HTML font tag in class attribute
* @author Denis Sharypov
* @run main bug4530474
*/
import java.awt.*;
import javax.swing.*;
import java.io.*;
public class bug4530474 {
private static final Color TEST_COLOR = Color.BLUE;
private static JEditorPane jep;
public static void main(String args[]) throws Exception {
final Robot robot = new Robot();
robot.setAutoDelay(50);
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
createAndShowGUI();
}
});
robot.waitForIdle();
robot.delay(500);
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
boolean passed = false;
Point p = jep.getLocationOnScreen();
Dimension d = jep.getSize();
int x0 = p.x;
int y = p.y + d.height / 3;
StringBuilder builder = new StringBuilder("Test color: ");
builder.append(TEST_COLOR.toString());
builder.append(" resut colors: ");
for (int x = x0; x < x0 + d.width; x++) {
Color color = robot.getPixelColor(x, y);
builder.append(color);
if (TEST_COLOR.equals(color)) {
passed = true;
break;
}
}
if (!passed) {
throw new RuntimeException("Test Fail. " + builder.toString());
}
}
});
}
private static void createAndShowGUI() {
JFrame mainFrame = new JFrame("bug4530474");
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jep = new JEditorPane();
try {
File file = new File(System.getProperty("test.src", "."), "test.html");
jep.setPage(file.toURL());
} catch (Exception e) {
throw new RuntimeException(e);
}
mainFrame.getContentPane().add(jep);
mainFrame.pack();
mainFrame.setVisible(true);
}
}
| Taichi-SHINDO/jdk9-jdk | test/javax/swing/text/html/CSS/4530474/bug4530474.java | Java | gpl-2.0 | 3,313 |
.size 8000
.text@48
jp lstatint
.text@100
jp lbegin
.data@143
80
.text@150
lbegin:
ld c, 41
ld b, 02
ld d, 03
lbegin_waitm2:
ldff a, (c)
and a, d
cmp a, b
jrnz lbegin_waitm2
ld a, 08
ldff(c), a
xor a, a
ldff(0f), a
ld a, 02
ldff(ff), a
ei
ld c, 0f
.text@1000
lstatint:
ld a, 48
ldff(41), a
ldff a, (44)
inc a
ldff(45), a
.text@1058
xor a, a
ldff(c), a
nop
nop
nop
nop
nop
ld a, 08
ldff(41), a
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
ldff a, (c)
and a, 03
jp lprint_a
.text@7000
lprint_a:
push af
ld b, 91
call lwaitly_b
xor a, a
ldff(40), a
pop af
ld(9800), a
ld bc, 7a00
ld hl, 8000
ld d, a0
lprint_copytiles:
ld a, (bc)
inc bc
ld(hl++), a
dec d
jrnz lprint_copytiles
ld a, c0
ldff(47), a
ld a, 80
ldff(68), a
ld a, ff
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
xor a, a
ldff(69), a
ldff(69), a
ldff(43), a
ld a, 91
ldff(40), a
lprint_limbo:
jr lprint_limbo
.text@7400
lwaitly_b:
ld c, 44
lwaitly_b_loop:
ldff a, (c)
cmp a, b
jrnz lwaitly_b_loop
ret
.data@7a00
00 00 7f 7f 41 41 41 41
41 41 41 41 41 41 7f 7f
00 00 08 08 08 08 08 08
08 08 08 08 08 08 08 08
00 00 7f 7f 01 01 01 01
7f 7f 40 40 40 40 7f 7f
00 00 7f 7f 01 01 01 01
3f 3f 01 01 01 01 7f 7f
00 00 41 41 41 41 41 41
7f 7f 01 01 01 01 01 01
00 00 7f 7f 40 40 40 40
7e 7e 01 01 01 01 7e 7e
00 00 7f 7f 40 40 40 40
7f 7f 41 41 41 41 7f 7f
00 00 7f 7f 01 01 02 02
04 04 08 08 10 10 10 10
00 00 3e 3e 41 41 41 41
3e 3e 41 41 41 41 3e 3e
00 00 7f 7f 41 41 41 41
7f 7f 01 01 01 01 7f 7f
| bentley/gambatte | testrunner/hwtests/m0enable/lycdisable_ff41_1_dmg08_cgb_out2.asm | Assembly | gpl-2.0 | 1,599 |
/* -*- c++ -*- ----------------------------------------------------------
*
* *** Smooth Mach Dynamics ***
*
* This file is part of the USER-SMD package for LAMMPS.
* Copyright (2014) Georg C. Ganzenmueller, georg.ganzenmueller@emi.fhg.de
* Fraunhofer Ernst-Mach Institute for High-Speed Dynamics, EMI,
* Eckerstrasse 4, D-79104 Freiburg i.Br, Germany.
*
* ----------------------------------------------------------------------- */
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#ifndef SMD_MATERIAL_MODELS_H
#define SMD_MATERIAL_MODELS_H
#include <Eigen/Eigen>
/*
* EOS models
*/
void LinearEOS(double lambda, double pInitial, double d, double dt, double &pFinal, double &p_rate);
void ShockEOS(double rho, double rho0, double e, double e0, double c0, double S, double Gamma, double pInitial, double dt,
double &pFinal, double &p_rate);
void polynomialEOS(double rho, double rho0, double e, double C0, double C1, double C2, double C3, double C4, double C5, double C6,
double pInitial, double dt, double &pFinal, double &p_rate);
void TaitEOS_density(const double exponent, const double c0_reference, const double rho_reference, const double rho_current,
double &pressure, double &sound_speed);
void PerfectGasEOS(const double gamma, const double vol, const double mass, const double energy, double &pFinal__, double &c0);
/*
* Material strength models
*/
void LinearStrength(const double mu, const Eigen::Matrix3d sigmaInitial_dev, const Eigen::Matrix3d d_dev, const double dt,
Eigen::Matrix3d &sigmaFinal_dev__, Eigen::Matrix3d &sigma_dev_rate__);
void LinearPlasticStrength(const double G, const double yieldStress, const Eigen::Matrix3d sigmaInitial_dev, const Eigen::Matrix3d d_dev,
const double dt, Eigen::Matrix3d &sigmaFinal_dev__, Eigen::Matrix3d &sigma_dev_rate__, double &plastic_strain_increment);
void JohnsonCookStrength(const double G, const double cp, const double espec, const double A, const double B, const double a,
const double C, const double epdot0, const double T0, const double Tmelt, const double M, const double dt, const double ep,
const double epdot, const Eigen::Matrix3d sigmaInitial_dev, const Eigen::Matrix3d d_dev, Eigen::Matrix3d &sigmaFinal_dev__,
Eigen::Matrix3d &sigma_dev_rate__, double &plastic_strain_increment);
/*
* Damage models
*/
bool IsotropicMaxStrainDamage(const Eigen::Matrix3d E, const double maxStrain);
bool IsotropicMaxStressDamage(const Eigen::Matrix3d E, const double maxStrain);
double JohnsonCookFailureStrain(const double p, const Eigen::Matrix3d Sdev, const double d1, const double d2, const double d3,
const double d4, const double epdot0, const double epdot);
#endif /* SMD_MATERIAL_MODELS_H_ */
| Pakketeretet2/lammps | src/USER-SMD/smd_material_models.h | C | gpl-2.0 | 3,411 |
/* Copyright (C) 1998-2006, 2010 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <assert.h>
#include <errno.h>
#include <mntent.h>
#include <paths.h>
#include <stdbool.h>
#include <stdio_ext.h>
#include <string.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/statfs.h>
#include <sys/statvfs.h>
#include "linux_fsinfo.h"
#include "kernel-features.h"
/* Special internal-only bit value. */
#define ST_VALID 0x0020
#ifndef STATFS
# define STATFS statfs
# define STATVFS statvfs
# define INTERNAL_STATVFS __internal_statvfs
# ifndef __ASSUME_STATFS_F_FLAGS
int
__statvfs_getflags (const char *name, int fstype, struct stat64 *st)
{
if (st == NULL)
return 0;
const char *fsname = NULL;
const char *fsname2 = NULL;
const char *fsname3 = NULL;
/* Map the filesystem type we got from the statfs call to a string. */
switch (fstype)
{
case EXT2_SUPER_MAGIC:
fsname = "ext4";
fsname2 = "ext3";
fsname3 = "ext2";
break;
case DEVPTS_SUPER_MAGIC:
fsname= "devpts";
break;
case SHMFS_SUPER_MAGIC:
fsname = "tmpfs";
break;
case PROC_SUPER_MAGIC:
fsname = "proc";
break;
case USBDEVFS_SUPER_MAGIC:
fsname = "usbdevfs";
break;
case AUTOFS_SUPER_MAGIC:
fsname = "autofs";
break;
case NFS_SUPER_MAGIC:
fsname = "nfs";
break;
case SYSFS_MAGIC:
fsname = "sysfs";
break;
case REISERFS_SUPER_MAGIC:
fsname = "reiserfs";
break;
case XFS_SUPER_MAGIC:
fsname = "xfs";
break;
case JFS_SUPER_MAGIC:
fsname = "jfs";
break;
case HPFS_SUPER_MAGIC:
fsname = "hpfs";
break;
case DEVFS_SUPER_MAGIC:
fsname = "devfs";
break;
case ISOFS_SUPER_MAGIC:
fsname = "iso9660";
break;
case MSDOS_SUPER_MAGIC:
fsname = "msdos";
break;
case NTFS_SUPER_MAGIC:
fsname = "ntfs";
break;
case LOGFS_MAGIC_U32:
fsname = "logfs";
break;
case BTRFS_SUPER_MAGIC:
fsname = "btrfs";
break;
case CGROUP_SUPER_MAGIC:
fsname = "cgroup";
break;
}
FILE *mtab = __setmntent ("/proc/mounts", "r");
if (mtab == NULL)
mtab = __setmntent (_PATH_MOUNTED, "r");
int result = 0;
if (mtab != NULL)
{
bool success = false;
struct mntent mntbuf;
char tmpbuf[1024];
/* No locking needed. */
(void) __fsetlocking (mtab, FSETLOCKING_BYCALLER);
again:
while (__getmntent_r (mtab, &mntbuf, tmpbuf, sizeof (tmpbuf)))
{
/* In a first round we look for a given mount point, if
we have a name. */
if (name != NULL && strcmp (name, mntbuf.mnt_dir) != 0)
continue;
/* We need to look at the entry only if the filesystem
name matches. If we have a filesystem name. */
else if (fsname != NULL
&& strcmp (fsname, mntbuf.mnt_type) != 0
&& (fsname2 == NULL
|| strcmp (fsname2, mntbuf.mnt_type) != 0)
&& (fsname3 == NULL
|| strcmp (fsname3, mntbuf.mnt_type) != 0))
continue;
/* Find out about the device the current entry is for. */
struct stat64 fsst;
if (stat64 (mntbuf.mnt_dir, &fsst) >= 0
&& st->st_dev == fsst.st_dev)
{
/* Bingo, we found the entry for the device FD is on.
Now interpret the option string. */
char *cp = mntbuf.mnt_opts;
char *opt;
while ((opt = strsep (&cp, ",")) != NULL)
if (strcmp (opt, "ro") == 0)
result |= ST_RDONLY;
else if (strcmp (opt, "nosuid") == 0)
result |= ST_NOSUID;
else if (strcmp (opt, "noexec") == 0)
result |= ST_NOEXEC;
else if (strcmp (opt, "nodev") == 0)
result |= ST_NODEV;
else if (strcmp (opt, "sync") == 0)
result |= ST_SYNCHRONOUS;
else if (strcmp (opt, "mand") == 0)
result |= ST_MANDLOCK;
else if (strcmp (opt, "noatime") == 0)
result |= ST_NOATIME;
else if (strcmp (opt, "nodiratime") == 0)
result |= ST_NODIRATIME;
else if (strcmp (opt, "relatime") == 0)
result |= ST_RELATIME;
/* We can stop looking for more entries. */
success = true;
break;
}
}
/* Maybe the kernel names for the filesystems changed or the
statvfs call got a name which was not the mount point. Check
again, this time without checking for name matches first. */
if (! success && (name != NULL || fsname != NULL))
{
if (name != NULL)
/* Try without a mount point name. */
name = NULL;
else
{
/* Try without a filesystem name. */
assert (fsname != NULL);
fsname = fsname2 = fsname3 = NULL;
}
/* It is not strictly allowed to use rewind here. But
this code is part of the implementation so it is
acceptable. */
rewind (mtab);
goto again;
}
/* Close the file. */
__endmntent (mtab);
}
return result;
}
# endif
#else
extern int __statvfs_getflags (const char *name, int fstype,
struct stat64 *st);
#endif
void
INTERNAL_STATVFS (const char *name, struct STATVFS *buf,
struct STATFS *fsbuf, struct stat64 *st)
{
/* Now fill in the fields we have information for. */
buf->f_bsize = fsbuf->f_bsize;
/* Linux has the f_frsize size only in later version of the kernel.
If the value is not filled in use f_bsize. */
buf->f_frsize = fsbuf->f_frsize ?: fsbuf->f_bsize;
buf->f_blocks = fsbuf->f_blocks;
buf->f_bfree = fsbuf->f_bfree;
buf->f_bavail = fsbuf->f_bavail;
buf->f_files = fsbuf->f_files;
buf->f_ffree = fsbuf->f_ffree;
if (sizeof (buf->f_fsid) == sizeof (fsbuf->f_fsid))
buf->f_fsid = ((fsbuf->f_fsid.__val[0]
& ((1UL << (8 * sizeof (fsbuf->f_fsid.__val[0]))) - 1))
| ((unsigned long int) fsbuf->f_fsid.__val[1]
<< (8 * (sizeof (buf->f_fsid)
- sizeof (fsbuf->f_fsid.__val[0])))));
else
/* We cannot help here. The statvfs element is not large enough to
contain both words of the statfs f_fsid field. */
buf->f_fsid = fsbuf->f_fsid.__val[0];
#ifdef _STATVFSBUF_F_UNUSED
buf->__f_unused = 0;
#endif
buf->f_namemax = fsbuf->f_namelen;
memset (buf->__f_spare, '\0', sizeof (buf->__f_spare));
/* What remains to do is to fill the fields f_favail and f_flag. */
/* XXX I have no idea how to compute f_favail. Any idea??? */
buf->f_favail = buf->f_ffree;
#ifndef __ASSUME_STATFS_F_FLAGS
if ((fsbuf->f_flags & ST_VALID) == 0)
/* Determining the flags is tricky. We have to read /proc/mounts or
the /etc/mtab file and search for the entry which matches the given
file. The way we can test for matching filesystem is using the
device number. */
buf->f_flag = __statvfs_getflags (name, fsbuf->f_type, st);
else
#endif
buf->f_flag = fsbuf->f_flags ^ ST_VALID;
}
| cdepillabout/glibc | sysdeps/unix/sysv/linux/internal_statvfs.c | C | gpl-2.0 | 7,634 |
/* GemRB - Infinity Engine Emulator
* Copyright (C) 2003 The GemRB Project
*
* 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.
*
*
*/
#ifndef BIFIMPORTER_H
#define BIFIMPORTER_H
#include "IndexedArchive.h"
#include "globals.h"
#include "System/DataStream.h"
namespace GemRB {
struct FileEntry {
ieDword resLocator;
ieDword dataOffset;
ieDword fileSize;
ieWord type;
ieWord u1; //Unknown Field
};
struct TileEntry {
ieDword resLocator;
ieDword dataOffset;
ieDword tilesCount;
ieDword tileSize; //named tilesize so it isn't confused
ieWord type;
ieWord u1; //Unknown Field
};
class BIFImporter : public IndexedArchive {
private:
FileEntry* fentries;
TileEntry* tentries;
ieDword fentcount, tentcount;
DataStream* stream;
public:
BIFImporter(void);
~BIFImporter(void);
int OpenArchive(const char* filename);
DataStream* GetStream(unsigned long Resource, unsigned long Type);
private:
static DataStream* DecompressBIF(DataStream* compressed, const char* path);
static DataStream* DecompressBIFC(DataStream* compressed, const char* path);
void ReadBIF(void);
};
}
#endif
| Tomsod/gemrb | gemrb/plugins/BIFImporter/BIFImporter.h | C | gpl-2.0 | 1,771 |
#include "../vidhrdw/atetris.cpp"
/***************************************************************************
Atari Tetris Memory Map (preliminary)
driver by Zsolt Vasvari
0000-0fff RAM
1000-1fff Video RAM
2000-20ff Palette RAM
2400-25ff EEPROM
4000-7fff Paged ROM (Slapstic controlled)
8000-ffff ROM
I/O
Read
2800-280f Pokey #1
2800-281f Pokey #2
Write
2800-280f Pokey #1
2810-281f Pokey #2
3000 Watchdog
3400 EEPROM enable
3800 ???
3c00 ???
***************************************************************************/
#include "driver.h"
#include "vidhrdw/generic.h"
void atetris_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
READ_HANDLER( atetris_slapstic_r );
static unsigned char *nvram;
static size_t nvram_size;
static void nvram_handler(void *file,int read_or_write)
{
if (read_or_write)
osd_fwrite(file,nvram,nvram_size);
else
{
if (file)
osd_fread(file,nvram,nvram_size);
else
memset(nvram,0xff,nvram_size);
}
}
static struct MemoryReadAddress readmem[] =
{
{ 0x0000, 0x20ff, MRA_RAM },
{ 0x2400, 0x25ff, MRA_RAM },
{ 0x2800, 0x280f, pokey1_r },
{ 0x2810, 0x281f, pokey2_r },
{ 0x4000, 0x7fff, atetris_slapstic_r },
{ 0x8000, 0xffff, MRA_ROM },
{ -1 } /* end of table */
};
static struct MemoryWriteAddress writemem[] =
{
{ 0x0000, 0x0fff, MWA_RAM },
{ 0x1000, 0x1fff, videoram_w, &videoram, &videoram_size },
{ 0x2000, 0x20ff, paletteram_RRRGGGBB_w, &paletteram },
{ 0x2400, 0x25ff, MWA_RAM, &nvram, &nvram_size },
{ 0x2800, 0x280f, pokey1_w },
{ 0x2810, 0x281f, pokey2_w },
{ 0x3000, 0x3000, watchdog_reset_w },
{ 0x3400, 0x3400, MWA_NOP }, // EEPROM enable
{ 0x3800, 0x3800, MWA_NOP }, // ???
{ 0x3c00, 0x3c00, MWA_NOP }, // ???
{ 0x4000, 0xffff, MWA_ROM },
{ -1 } /* end of table */
};
INPUT_PORTS_START( atetris )
// These ports are read via the Pokeys
PORT_START /* IN0 */
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN2 )
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN1 )
PORT_DIPNAME( 0x04, 0x00, "Freeze" )
PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x04, DEF_STR( On ) )
PORT_BITX(0x08, IP_ACTIVE_HIGH, IPT_SERVICE, "Freeze Step", KEYCODE_F1, IP_JOY_NONE )
PORT_BIT( 0x30, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_VBLANK )
PORT_SERVICE( 0x80, IP_ACTIVE_HIGH )
PORT_START /* IN1 */
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 | IPF_PLAYER1)
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN | IPF_PLAYER1 | IPF_8WAY )
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_PLAYER1 | IPF_8WAY )
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_PLAYER1 | IPF_8WAY )
PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 | IPF_PLAYER2)
PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN | IPF_PLAYER2 | IPF_8WAY )
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_PLAYER2 | IPF_8WAY )
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_PLAYER2 | IPF_8WAY )
INPUT_PORTS_END
// Same as the regular one except they added a Flip Controls switch
INPUT_PORTS_START( atetcktl )
// These ports are read via the Pokeys
PORT_START /* IN0 */
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN2 )
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN1 )
PORT_DIPNAME( 0x04, 0x00, "Freeze" )
PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x04, DEF_STR( On ) )
PORT_BITX(0x08, IP_ACTIVE_HIGH, IPT_SERVICE, "Freeze Step", KEYCODE_F1, IP_JOY_NONE )
PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_DIPNAME( 0x20, 0x00, "Flip Controls" )
PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x20, DEF_STR( On ) )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_VBLANK )
PORT_SERVICE( 0x80, IP_ACTIVE_HIGH )
PORT_START /* IN1 */
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 | IPF_PLAYER1)
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN | IPF_PLAYER1 | IPF_8WAY )
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_PLAYER1 | IPF_8WAY )
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_PLAYER1 | IPF_8WAY )
PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 | IPF_PLAYER2)
PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN | IPF_PLAYER2 | IPF_8WAY )
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_PLAYER2 | IPF_8WAY )
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_PLAYER2 | IPF_8WAY )
INPUT_PORTS_END
static struct GfxLayout charlayout =
{
8,8, /* 8*8 chars */
2048, /* 2048 characters */
4, /* 4 bits per pixel */
{ 0,1,2,3 }, // The 4 planes are packed together
{ 0*4, 1*4, 2*4, 3*4, 4*4, 5*4, 6*4, 7*4},
{ 0*4*8, 1*4*8, 2*4*8, 3*4*8, 4*4*8, 5*4*8, 6*4*8, 7*4*8},
8*8*4 /* every char takes 32 consecutive bytes */
};
static struct GfxDecodeInfo gfxdecodeinfo[] =
{
{ REGION_GFX1, 0x0000, &charlayout, 0, 16 },
{ -1 } /* end of array */
};
static struct POKEYinterface pokey_interface =
{
2, /* 2 chips */
1789790, /* ? */
{ 50, 50 },
/* The 8 pot handlers */
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
/* The allpot handler */
{ input_port_0_r, input_port_1_r }
};
static struct MachineDriver machine_driver_atetris =
{
/* basic machine hardware */
{
{
CPU_M6502,
1750000, /* 1.75 MHz??? */
readmem,writemem,0,0,
interrupt,4
}
},
60, DEFAULT_REAL_60HZ_VBLANK_DURATION, /* frames per second, vblank duration */
1, /* single CPU, no need for interleaving */
0,
/* video hardware */
42*8, 32*8, { 0*8, 42*8-1, 0*8, 30*8-1 },
gfxdecodeinfo,
256, 256,
0,
VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,
0,
generic_vh_start,
generic_vh_stop,
atetris_vh_screenrefresh,
/* sound hardware */
0,0,0,0,
{
{
SOUND_POKEY,
&pokey_interface
}
},
nvram_handler
};
/***************************************************************************
Game driver(s)
***************************************************************************/
ROM_START( atetris )
ROM_REGION( 0x14000, REGION_CPU1 ) /* 80k for code */
ROM_LOAD( "1100.45f", 0x0000, 0x10000, 0x2acbdb09 )
ROM_REGION( 0x10000, REGION_GFX1 | REGIONFLAG_DISPOSE )
ROM_LOAD( "1101.35a", 0x0000, 0x10000, 0x84a1939f )
ROM_END
ROM_START( atetrisa )
ROM_REGION( 0x14000, REGION_CPU1 ) /* 80k for code */
ROM_LOAD( "d1", 0x0000, 0x10000, 0x2bcab107 )
ROM_REGION( 0x10000, REGION_GFX1 | REGIONFLAG_DISPOSE )
ROM_LOAD( "1101.35a", 0x0000, 0x10000, 0x84a1939f )
ROM_END
ROM_START( atetrisb )
ROM_REGION( 0x14000, REGION_CPU1 ) /* 80k for code */
ROM_LOAD( "tetris.01", 0x0000, 0x10000, 0x944d15f6 )
ROM_REGION( 0x10000, REGION_GFX1 | REGIONFLAG_DISPOSE )
ROM_LOAD( "tetris.02", 0x0000, 0x10000, 0x5c4e7258 )
/* there's an extra EEPROM, maybe used for protection crack, which */
/* however doesn't seem to be required to run the game in this driver. */
ROM_REGION( 0x0800, REGION_USER1 )
ROM_LOAD( "tetris.03", 0x0000, 0x0800, 0x26618c0b )
ROM_END
ROM_START( atetcktl )
ROM_REGION( 0x14000, REGION_CPU1 ) /* 80k for code */
ROM_LOAD( "tetcktl1.rom", 0x0000, 0x10000, 0x9afd1f4a )
ROM_REGION( 0x10000, REGION_GFX1 | REGIONFLAG_DISPOSE )
ROM_LOAD( "1103.35a", 0x0000, 0x10000, 0xec2a7f93 )
ROM_END
ROM_START( atetckt2 )
ROM_REGION( 0x14000, REGION_CPU1 ) /* 80k for code */
ROM_LOAD( "1102.45f", 0x0000, 0x10000, 0x1bd28902 )
ROM_REGION( 0x10000, REGION_GFX1 | REGIONFLAG_DISPOSE )
ROM_LOAD( "1103.35a", 0x0000, 0x10000, 0xec2a7f93 )
ROM_END
static void init_atetris(void)
{
unsigned char *RAM = memory_region(REGION_CPU1);
// Move the lower 16k to 0x10000
memcpy(&RAM[0x10000], &RAM[0x00000], 0x4000);
memset(&RAM[0x00000], 0, 0x4000);
}
GAME( 1988, atetris, 0, atetris, atetris, atetris, ROT0, "Atari Games", "Tetris (set 1)" )
GAME( 1988, atetrisa, atetris, atetris, atetris, atetris, ROT0, "Atari Games", "Tetris (set 2)" )
GAME( 1988, atetrisb, atetris, atetris, atetris, atetris, ROT0, "bootleg", "Tetris (bootleg)" )
GAME( 1989, atetcktl, atetris, atetris, atetcktl, atetris, ROT270, "Atari Games", "Tetris (Cocktail set 1)" )
GAME( 1989, atetckt2, atetris, atetris, atetcktl, atetris, ROT270, "Atari Games", "Tetris (Cocktail set 2)" )
| skeezix/compo4all | stevem/mame4all/src/drivers/atetris.cpp | C++ | gpl-2.0 | 8,545 |
<?php
/**
* DmSentMail filter form base class.
*
* @package retest
* @subpackage filter
* @author Your name here
* @version SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 24171 2009-11-19 16:37:50Z Kris.Wallsmith $
*/
abstract class BaseDmSentMailFormFilter extends BaseFormFilterDoctrine
{
public function setup()
{
if($this->needsWidget('id')){
$this->setWidget('id', new sfWidgetFormDmFilterInput());
$this->setValidator('id', new sfValidatorDoctrineChoice(array('required' => false, 'model' => 'DmSentMail', 'column' => 'id')));
}
if($this->needsWidget('subject')){
$this->setWidget('subject', new sfWidgetFormDmFilterInput());
$this->setValidator('subject', new sfValidatorSchemaFilter('text', new sfValidatorString(array('required' => false))));
}
if($this->needsWidget('body')){
$this->setWidget('body', new sfWidgetFormDmFilterInput());
$this->setValidator('body', new sfValidatorSchemaFilter('text', new sfValidatorString(array('required' => false))));
}
if($this->needsWidget('from_email')){
$this->setWidget('from_email', new sfWidgetFormDmFilterInput());
$this->setValidator('from_email', new sfValidatorSchemaFilter('text', new sfValidatorString(array('required' => false))));
}
if($this->needsWidget('to_email')){
$this->setWidget('to_email', new sfWidgetFormDmFilterInput());
$this->setValidator('to_email', new sfValidatorSchemaFilter('text', new sfValidatorString(array('required' => false))));
}
if($this->needsWidget('cc_email')){
$this->setWidget('cc_email', new sfWidgetFormDmFilterInput());
$this->setValidator('cc_email', new sfValidatorSchemaFilter('text', new sfValidatorString(array('required' => false))));
}
if($this->needsWidget('bcc_email')){
$this->setWidget('bcc_email', new sfWidgetFormDmFilterInput());
$this->setValidator('bcc_email', new sfValidatorSchemaFilter('text', new sfValidatorString(array('required' => false))));
}
if($this->needsWidget('reply_to_email')){
$this->setWidget('reply_to_email', new sfWidgetFormDmFilterInput());
$this->setValidator('reply_to_email', new sfValidatorSchemaFilter('text', new sfValidatorString(array('required' => false))));
}
if($this->needsWidget('sender_email')){
$this->setWidget('sender_email', new sfWidgetFormDmFilterInput());
$this->setValidator('sender_email', new sfValidatorSchemaFilter('text', new sfValidatorString(array('required' => false))));
}
if($this->needsWidget('strategy')){
$this->setWidget('strategy', new sfWidgetFormDmFilterInput());
$this->setValidator('strategy', new sfValidatorSchemaFilter('text', new sfValidatorString(array('required' => false))));
}
if($this->needsWidget('transport')){
$this->setWidget('transport', new sfWidgetFormDmFilterInput());
$this->setValidator('transport', new sfValidatorSchemaFilter('text', new sfValidatorString(array('required' => false))));
}
if($this->needsWidget('culture')){
$this->setWidget('culture', new sfWidgetFormDmFilterInput());
$this->setValidator('culture', new sfValidatorSchemaFilter('text', new sfValidatorString(array('required' => false))));
}
if($this->needsWidget('debug_string')){
$this->setWidget('debug_string', new sfWidgetFormDmFilterInput());
$this->setValidator('debug_string', new sfValidatorSchemaFilter('text', new sfValidatorString(array('required' => false))));
}
if($this->needsWidget('created_at')){
$this->setWidget('created_at', new sfWidgetFormChoice(array('choices' => array(
'' => '',
'today' => $this->getI18n()->__('Today'),
'week' => $this->getI18n()->__('Past %number% days', array('%number%' => 7)),
'month' => $this->getI18n()->__('This month'),
'year' => $this->getI18n()->__('This year')
))));
$this->setValidator('created_at', new sfValidatorChoice(array('required' => false, 'choices' => array_keys($this->widgetSchema['created_at']->getOption('choices')))));
}
if($this->needsWidget('template_list')){
$this->setWidget('template_list', new sfWidgetFormDoctrineChoice(array('multiple' => false, 'model' => 'DmMailTemplate', 'expanded' => false)));
$this->setValidator('template_list', new sfValidatorDoctrineChoice(array('multiple' => false, 'model' => 'DmMailTemplate', 'required' => true)));
}
$this->widgetSchema->setNameFormat('dm_sent_mail_filters[%s]');
$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
$this->setupInheritance();
parent::setup();
}
public function getModelName()
{
return 'DmSentMail';
}
public function getFields()
{
return array(
'id' => 'Number',
'dm_mail_template_id' => 'ForeignKey',
'subject' => 'Text',
'body' => 'Text',
'from_email' => 'Text',
'to_email' => 'Text',
'cc_email' => 'Text',
'bcc_email' => 'Text',
'reply_to_email' => 'Text',
'sender_email' => 'Text',
'strategy' => 'Text',
'transport' => 'Text',
'culture' => 'Text',
'debug_string' => 'Text',
'created_at' => 'Date',
);
}
}
| Teplitsa/bquest.ru | lib/vendor/diem/dmCorePlugin/test/project/lib/filter/doctrine/dmCorePlugin/base/BaseDmSentMailFormFilter.class.php | PHP | gpl-2.0 | 5,256 |
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Persistence;
using ServiceStack;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace MediaBrowser.Api.Music
{
[Route("/Albums/{Id}/Similar", "GET", Summary = "Finds albums similar to a given album.")]
public class GetSimilarAlbums : BaseGetSimilarItemsFromItem
{
}
[Route("/Artists/{Id}/Similar", "GET", Summary = "Finds albums similar to a given album.")]
public class GetSimilarArtists : BaseGetSimilarItemsFromItem
{
}
[Authenticated]
public class AlbumsService : BaseApiService
{
/// <summary>
/// The _user manager
/// </summary>
private readonly IUserManager _userManager;
/// <summary>
/// The _user data repository
/// </summary>
private readonly IUserDataManager _userDataRepository;
/// <summary>
/// The _library manager
/// </summary>
private readonly ILibraryManager _libraryManager;
private readonly IItemRepository _itemRepo;
private readonly IDtoService _dtoService;
public AlbumsService(IUserManager userManager, IUserDataManager userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo, IDtoService dtoService)
{
_userManager = userManager;
_userDataRepository = userDataRepository;
_libraryManager = libraryManager;
_itemRepo = itemRepo;
_dtoService = dtoService;
}
public async Task<object> Get(GetSimilarArtists request)
{
var dtoOptions = GetDtoOptions(request);
var result = await SimilarItemsHelper.GetSimilarItemsResult(dtoOptions, _userManager,
_itemRepo,
_libraryManager,
_userDataRepository,
_dtoService,
Logger,
request, new[] { typeof(MusicArtist) },
SimilarItemsHelper.GetSimiliarityScore).ConfigureAwait(false);
return ToOptimizedSerializedResultUsingCache(result);
}
/// <summary>
/// Gets the specified request.
/// </summary>
/// <param name="request">The request.</param>
/// <returns>System.Object.</returns>
public async Task<object> Get(GetSimilarAlbums request)
{
var dtoOptions = GetDtoOptions(request);
var result = await SimilarItemsHelper.GetSimilarItemsResult(dtoOptions, _userManager,
_itemRepo,
_libraryManager,
_userDataRepository,
_dtoService,
Logger,
request, new[] { typeof(MusicAlbum) },
GetAlbumSimilarityScore).ConfigureAwait(false);
return ToOptimizedSerializedResultUsingCache(result);
}
/// <summary>
/// Gets the album similarity score.
/// </summary>
/// <param name="item1">The item1.</param>
/// <param name="item1People">The item1 people.</param>
/// <param name="allPeople">All people.</param>
/// <param name="item2">The item2.</param>
/// <returns>System.Int32.</returns>
private int GetAlbumSimilarityScore(BaseItem item1, List<PersonInfo> item1People, List<PersonInfo> allPeople, BaseItem item2)
{
var points = SimilarItemsHelper.GetSimiliarityScore(item1, item1People, allPeople, item2);
var album1 = (MusicAlbum)item1;
var album2 = (MusicAlbum)item2;
var artists1 = album1
.AllArtists
.DistinctNames()
.ToList();
var artists2 = album2
.AllArtists
.DistinctNames()
.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase);
return points + artists1.Where(artists2.ContainsKey).Sum(i => 5);
}
}
}
| softworkz/Emby | MediaBrowser.Api/Music/AlbumsService.cs | C# | gpl-2.0 | 4,181 |
//--------------------------------------------------------------------------
// Copyright (C) 2014-2015 Cisco and/or its affiliates. All rights reserved.
// Copyright (C) 2002-2013 Sourcefire, Inc.
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License Version 2 as published
// by the Free Software Foundation. You may not use, modify or distribute
// this program under any other version of the GNU General Public 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.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//--------------------------------------------------------------------------
#include "port_group.h"
#include <stdlib.h>
void PortGroup::add_rule()
{
rule_count++;
}
/*
**
** DESCRIPTION
** Adds a RULE_NODE to a PortGroup. This particular
** function is specific in that it adds "no content" rules.
** A "no content" rule is a snort rule that has no "content"
** or "uri" flag, and hence does not need to be pattern
** matched.
**
** Each RULE_NODE in a PortGroup is given a RULE_NODE
** ID. This allows us to track particulars as to what
** rules have been alerted upon, and allows other neat
** things like correlating events on different streams.
** The RULE_NODE IDs may not be consecutive, because
** we can add RULE_NODES into "content", "uri", and
** "no content" lists.
**
** FORMAL INPUTS
** PortGroup* - PortGroup to add the rule to.
** void* - ptr to the user information
**
** FORMAL OUTPUT
** int - 0 is successful, 1 is failure
**
*/
bool PortGroup::add_nfp_rule(void* rd)
{
if ( !nfp_head )
{
nfp_head = (RULE_NODE*)calloc(1,sizeof(RULE_NODE) );
if ( !nfp_head )
return false;
nfp_tail = nfp_head;
nfp_head->rnNext = 0;
nfp_head->rnRuleData = rd;
}
else
{
nfp_tail->rnNext = (RULE_NODE*)calloc(1,sizeof(RULE_NODE) );
if (!nfp_tail->rnNext)
return false;
nfp_tail = nfp_tail->rnNext;
nfp_tail->rnNext = 0;
nfp_tail->rnRuleData = rd;
}
/*
** Set RULE_NODE ID to unique identifier
*/
nfp_tail->iRuleNodeID = rule_count;
nfp_rule_count++;
rule_count++;
return true;
}
void PortGroup::delete_nfp_rules()
{
RULE_NODE* rn = nfp_head;
while (rn)
{
RULE_NODE* tmpRn = rn->rnNext;
free(rn);
rn = tmpRn;
}
nfp_head = nullptr;
}
| gavares/snort3 | src/ports/port_group.cc | C++ | gpl-2.0 | 2,900 |
/*
* This file is part of the Chelsio T4 Ethernet driver for Linux.
*
* Copyright (c) 2003-2014 Chelsio Communications, Inc. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
* General Public License (GPL) Version 2, available from the file
* COPYING in the main directory of this source tree, or the
* OpenIB.org BSD license below:
*
* 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.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/bitmap.h>
#include <linux/crc32.h>
#include <linux/ctype.h>
#include <linux/debugfs.h>
#include <linux/err.h>
#include <linux/etherdevice.h>
#include <linux/firmware.h>
#include <linux/if.h>
#include <linux/if_vlan.h>
#include <linux/init.h>
#include <linux/log2.h>
#include <linux/mdio.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/mutex.h>
#include <linux/netdevice.h>
#include <linux/pci.h>
#include <linux/aer.h>
#include <linux/rtnetlink.h>
#include <linux/sched.h>
#include <linux/seq_file.h>
#include <linux/sockios.h>
#include <linux/vmalloc.h>
#include <linux/workqueue.h>
#include <net/neighbour.h>
#include <net/netevent.h>
#include <net/addrconf.h>
#include <asm/uaccess.h>
#include "cxgb4.h"
#include "t4_regs.h"
#include "t4_msg.h"
#include "t4fw_api.h"
#include "cxgb4_dcb.h"
#include "l2t.h"
#include <../drivers/net/bonding/bonding.h>
#ifdef DRV_VERSION
#undef DRV_VERSION
#endif
#define DRV_VERSION "2.0.0-ko"
#define DRV_DESC "Chelsio T4/T5 Network Driver"
/*
* Max interrupt hold-off timer value in us. Queues fall back to this value
* under extreme memory pressure so it's largish to give the system time to
* recover.
*/
#define MAX_SGE_TIMERVAL 200U
enum {
/*
* Physical Function provisioning constants.
*/
PFRES_NVI = 4, /* # of Virtual Interfaces */
PFRES_NETHCTRL = 128, /* # of EQs used for ETH or CTRL Qs */
PFRES_NIQFLINT = 128, /* # of ingress Qs/w Free List(s)/intr
*/
PFRES_NEQ = 256, /* # of egress queues */
PFRES_NIQ = 0, /* # of ingress queues */
PFRES_TC = 0, /* PCI-E traffic class */
PFRES_NEXACTF = 128, /* # of exact MPS filters */
PFRES_R_CAPS = FW_CMD_CAP_PF,
PFRES_WX_CAPS = FW_CMD_CAP_PF,
#ifdef CONFIG_PCI_IOV
/*
* Virtual Function provisioning constants. We need two extra Ingress
* Queues with Interrupt capability to serve as the VF's Firmware
* Event Queue and Forwarded Interrupt Queue (when using MSI mode) --
* neither will have Free Lists associated with them). For each
* Ethernet/Control Egress Queue and for each Free List, we need an
* Egress Context.
*/
VFRES_NPORTS = 1, /* # of "ports" per VF */
VFRES_NQSETS = 2, /* # of "Queue Sets" per VF */
VFRES_NVI = VFRES_NPORTS, /* # of Virtual Interfaces */
VFRES_NETHCTRL = VFRES_NQSETS, /* # of EQs used for ETH or CTRL Qs */
VFRES_NIQFLINT = VFRES_NQSETS+2,/* # of ingress Qs/w Free List(s)/intr */
VFRES_NEQ = VFRES_NQSETS*2, /* # of egress queues */
VFRES_NIQ = 0, /* # of non-fl/int ingress queues */
VFRES_TC = 0, /* PCI-E traffic class */
VFRES_NEXACTF = 16, /* # of exact MPS filters */
VFRES_R_CAPS = FW_CMD_CAP_DMAQ|FW_CMD_CAP_VF|FW_CMD_CAP_PORT,
VFRES_WX_CAPS = FW_CMD_CAP_DMAQ|FW_CMD_CAP_VF,
#endif
};
/*
* Provide a Port Access Rights Mask for the specified PF/VF. This is very
* static and likely not to be useful in the long run. We really need to
* implement some form of persistent configuration which the firmware
* controls.
*/
static unsigned int pfvfres_pmask(struct adapter *adapter,
unsigned int pf, unsigned int vf)
{
unsigned int portn, portvec;
/*
* Give PF's access to all of the ports.
*/
if (vf == 0)
return FW_PFVF_CMD_PMASK_MASK;
/*
* For VFs, we'll assign them access to the ports based purely on the
* PF. We assign active ports in order, wrapping around if there are
* fewer active ports than PFs: e.g. active port[pf % nports].
* Unfortunately the adapter's port_info structs haven't been
* initialized yet so we have to compute this.
*/
if (adapter->params.nports == 0)
return 0;
portn = pf % adapter->params.nports;
portvec = adapter->params.portvec;
for (;;) {
/*
* Isolate the lowest set bit in the port vector. If we're at
* the port number that we want, return that as the pmask.
* otherwise mask that bit out of the port vector and
* decrement our port number ...
*/
unsigned int pmask = portvec ^ (portvec & (portvec-1));
if (portn == 0)
return pmask;
portn--;
portvec &= ~pmask;
}
/*NOTREACHED*/
}
enum {
MAX_TXQ_ENTRIES = 16384,
MAX_CTRL_TXQ_ENTRIES = 1024,
MAX_RSPQ_ENTRIES = 16384,
MAX_RX_BUFFERS = 16384,
MIN_TXQ_ENTRIES = 32,
MIN_CTRL_TXQ_ENTRIES = 32,
MIN_RSPQ_ENTRIES = 128,
MIN_FL_ENTRIES = 16
};
/* Host shadow copy of ingress filter entry. This is in host native format
* and doesn't match the ordering or bit order, etc. of the hardware of the
* firmware command. The use of bit-field structure elements is purely to
* remind ourselves of the field size limitations and save memory in the case
* where the filter table is large.
*/
struct filter_entry {
/* Administrative fields for filter.
*/
u32 valid:1; /* filter allocated and valid */
u32 locked:1; /* filter is administratively locked */
u32 pending:1; /* filter action is pending firmware reply */
u32 smtidx:8; /* Source MAC Table index for smac */
struct l2t_entry *l2t; /* Layer Two Table entry for dmac */
/* The filter itself. Most of this is a straight copy of information
* provided by the extended ioctl(). Some fields are translated to
* internal forms -- for instance the Ingress Queue ID passed in from
* the ioctl() is translated into the Absolute Ingress Queue ID.
*/
struct ch_filter_specification fs;
};
#define DFLT_MSG_ENABLE (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK | \
NETIF_MSG_TIMER | NETIF_MSG_IFDOWN | NETIF_MSG_IFUP |\
NETIF_MSG_RX_ERR | NETIF_MSG_TX_ERR)
#define CH_DEVICE(devid, data) { PCI_VDEVICE(CHELSIO, devid), (data) }
static const struct pci_device_id cxgb4_pci_tbl[] = {
CH_DEVICE(0xa000, 0), /* PE10K */
CH_DEVICE(0x4001, -1),
CH_DEVICE(0x4002, -1),
CH_DEVICE(0x4003, -1),
CH_DEVICE(0x4004, -1),
CH_DEVICE(0x4005, -1),
CH_DEVICE(0x4006, -1),
CH_DEVICE(0x4007, -1),
CH_DEVICE(0x4008, -1),
CH_DEVICE(0x4009, -1),
CH_DEVICE(0x400a, -1),
CH_DEVICE(0x400d, -1),
CH_DEVICE(0x400e, -1),
CH_DEVICE(0x4080, -1),
CH_DEVICE(0x4081, -1),
CH_DEVICE(0x4082, -1),
CH_DEVICE(0x4083, -1),
CH_DEVICE(0x4084, -1),
CH_DEVICE(0x4085, -1),
CH_DEVICE(0x4086, -1),
CH_DEVICE(0x4087, -1),
CH_DEVICE(0x4088, -1),
CH_DEVICE(0x4401, 4),
CH_DEVICE(0x4402, 4),
CH_DEVICE(0x4403, 4),
CH_DEVICE(0x4404, 4),
CH_DEVICE(0x4405, 4),
CH_DEVICE(0x4406, 4),
CH_DEVICE(0x4407, 4),
CH_DEVICE(0x4408, 4),
CH_DEVICE(0x4409, 4),
CH_DEVICE(0x440a, 4),
CH_DEVICE(0x440d, 4),
CH_DEVICE(0x440e, 4),
CH_DEVICE(0x4480, 4),
CH_DEVICE(0x4481, 4),
CH_DEVICE(0x4482, 4),
CH_DEVICE(0x4483, 4),
CH_DEVICE(0x4484, 4),
CH_DEVICE(0x4485, 4),
CH_DEVICE(0x4486, 4),
CH_DEVICE(0x4487, 4),
CH_DEVICE(0x4488, 4),
CH_DEVICE(0x5001, 4),
CH_DEVICE(0x5002, 4),
CH_DEVICE(0x5003, 4),
CH_DEVICE(0x5004, 4),
CH_DEVICE(0x5005, 4),
CH_DEVICE(0x5006, 4),
CH_DEVICE(0x5007, 4),
CH_DEVICE(0x5008, 4),
CH_DEVICE(0x5009, 4),
CH_DEVICE(0x500A, 4),
CH_DEVICE(0x500B, 4),
CH_DEVICE(0x500C, 4),
CH_DEVICE(0x500D, 4),
CH_DEVICE(0x500E, 4),
CH_DEVICE(0x500F, 4),
CH_DEVICE(0x5010, 4),
CH_DEVICE(0x5011, 4),
CH_DEVICE(0x5012, 4),
CH_DEVICE(0x5013, 4),
CH_DEVICE(0x5014, 4),
CH_DEVICE(0x5015, 4),
CH_DEVICE(0x5080, 4),
CH_DEVICE(0x5081, 4),
CH_DEVICE(0x5082, 4),
CH_DEVICE(0x5083, 4),
CH_DEVICE(0x5084, 4),
CH_DEVICE(0x5085, 4),
CH_DEVICE(0x5401, 4),
CH_DEVICE(0x5402, 4),
CH_DEVICE(0x5403, 4),
CH_DEVICE(0x5404, 4),
CH_DEVICE(0x5405, 4),
CH_DEVICE(0x5406, 4),
CH_DEVICE(0x5407, 4),
CH_DEVICE(0x5408, 4),
CH_DEVICE(0x5409, 4),
CH_DEVICE(0x540A, 4),
CH_DEVICE(0x540B, 4),
CH_DEVICE(0x540C, 4),
CH_DEVICE(0x540D, 4),
CH_DEVICE(0x540E, 4),
CH_DEVICE(0x540F, 4),
CH_DEVICE(0x5410, 4),
CH_DEVICE(0x5411, 4),
CH_DEVICE(0x5412, 4),
CH_DEVICE(0x5413, 4),
CH_DEVICE(0x5414, 4),
CH_DEVICE(0x5415, 4),
CH_DEVICE(0x5480, 4),
CH_DEVICE(0x5481, 4),
CH_DEVICE(0x5482, 4),
CH_DEVICE(0x5483, 4),
CH_DEVICE(0x5484, 4),
CH_DEVICE(0x5485, 4),
{ 0, }
};
#define FW4_FNAME "cxgb4/t4fw.bin"
#define FW5_FNAME "cxgb4/t5fw.bin"
#define FW4_CFNAME "cxgb4/t4-config.txt"
#define FW5_CFNAME "cxgb4/t5-config.txt"
MODULE_DESCRIPTION(DRV_DESC);
MODULE_AUTHOR("Chelsio Communications");
MODULE_LICENSE("Dual BSD/GPL");
MODULE_VERSION(DRV_VERSION);
MODULE_DEVICE_TABLE(pci, cxgb4_pci_tbl);
MODULE_FIRMWARE(FW4_FNAME);
MODULE_FIRMWARE(FW5_FNAME);
/*
* Normally we're willing to become the firmware's Master PF but will be happy
* if another PF has already become the Master and initialized the adapter.
* Setting "force_init" will cause this driver to forcibly establish itself as
* the Master PF and initialize the adapter.
*/
static uint force_init;
module_param(force_init, uint, 0644);
MODULE_PARM_DESC(force_init, "Forcibly become Master PF and initialize adapter");
/*
* Normally if the firmware we connect to has Configuration File support, we
* use that and only fall back to the old Driver-based initialization if the
* Configuration File fails for some reason. If force_old_init is set, then
* we'll always use the old Driver-based initialization sequence.
*/
static uint force_old_init;
module_param(force_old_init, uint, 0644);
MODULE_PARM_DESC(force_old_init, "Force old initialization sequence");
static int dflt_msg_enable = DFLT_MSG_ENABLE;
module_param(dflt_msg_enable, int, 0644);
MODULE_PARM_DESC(dflt_msg_enable, "Chelsio T4 default message enable bitmap");
/*
* The driver uses the best interrupt scheme available on a platform in the
* order MSI-X, MSI, legacy INTx interrupts. This parameter determines which
* of these schemes the driver may consider as follows:
*
* msi = 2: choose from among all three options
* msi = 1: only consider MSI and INTx interrupts
* msi = 0: force INTx interrupts
*/
static int msi = 2;
module_param(msi, int, 0644);
MODULE_PARM_DESC(msi, "whether to use INTx (0), MSI (1) or MSI-X (2)");
/*
* Queue interrupt hold-off timer values. Queues default to the first of these
* upon creation.
*/
static unsigned int intr_holdoff[SGE_NTIMERS - 1] = { 5, 10, 20, 50, 100 };
module_param_array(intr_holdoff, uint, NULL, 0644);
MODULE_PARM_DESC(intr_holdoff, "values for queue interrupt hold-off timers "
"0..4 in microseconds");
static unsigned int intr_cnt[SGE_NCOUNTERS - 1] = { 4, 8, 16 };
module_param_array(intr_cnt, uint, NULL, 0644);
MODULE_PARM_DESC(intr_cnt,
"thresholds 1..3 for queue interrupt packet counters");
/*
* Normally we tell the chip to deliver Ingress Packets into our DMA buffers
* offset by 2 bytes in order to have the IP headers line up on 4-byte
* boundaries. This is a requirement for many architectures which will throw
* a machine check fault if an attempt is made to access one of the 4-byte IP
* header fields on a non-4-byte boundary. And it's a major performance issue
* even on some architectures which allow it like some implementations of the
* x86 ISA. However, some architectures don't mind this and for some very
* edge-case performance sensitive applications (like forwarding large volumes
* of small packets), setting this DMA offset to 0 will decrease the number of
* PCI-E Bus transfers enough to measurably affect performance.
*/
static int rx_dma_offset = 2;
static bool vf_acls;
#ifdef CONFIG_PCI_IOV
module_param(vf_acls, bool, 0644);
MODULE_PARM_DESC(vf_acls, "if set enable virtualization L2 ACL enforcement");
/* Configure the number of PCI-E Virtual Function which are to be instantiated
* on SR-IOV Capable Physical Functions.
*/
static unsigned int num_vf[NUM_OF_PF_WITH_SRIOV];
module_param_array(num_vf, uint, NULL, 0644);
MODULE_PARM_DESC(num_vf, "number of VFs for each of PFs 0-3");
#endif
/* TX Queue select used to determine what algorithm to use for selecting TX
* queue. Select between the kernel provided function (select_queue=0) or user
* cxgb_select_queue function (select_queue=1)
*
* Default: select_queue=0
*/
static int select_queue;
module_param(select_queue, int, 0644);
MODULE_PARM_DESC(select_queue,
"Select between kernel provided method of selecting or driver method of selecting TX queue. Default is kernel method.");
/*
* The filter TCAM has a fixed portion and a variable portion. The fixed
* portion can match on source/destination IP IPv4/IPv6 addresses and TCP/UDP
* ports. The variable portion is 36 bits which can include things like Exact
* Match MAC Index (9 bits), Ether Type (16 bits), IP Protocol (8 bits),
* [Inner] VLAN Tag (17 bits), etc. which, if all were somehow selected, would
* far exceed the 36-bit budget for this "compressed" header portion of the
* filter. Thus, we have a scarce resource which must be carefully managed.
*
* By default we set this up to mostly match the set of filter matching
* capabilities of T3 but with accommodations for some of T4's more
* interesting features:
*
* { IP Fragment (1), MPS Match Type (3), IP Protocol (8),
* [Inner] VLAN (17), Port (3), FCoE (1) }
*/
enum {
TP_VLAN_PRI_MAP_DEFAULT = HW_TPL_FR_MT_PR_IV_P_FC,
TP_VLAN_PRI_MAP_FIRST = FCOE_SHIFT,
TP_VLAN_PRI_MAP_LAST = FRAGMENTATION_SHIFT,
};
static unsigned int tp_vlan_pri_map = TP_VLAN_PRI_MAP_DEFAULT;
module_param(tp_vlan_pri_map, uint, 0644);
MODULE_PARM_DESC(tp_vlan_pri_map, "global compressed filter configuration");
static struct dentry *cxgb4_debugfs_root;
static LIST_HEAD(adapter_list);
static DEFINE_MUTEX(uld_mutex);
/* Adapter list to be accessed from atomic context */
static LIST_HEAD(adap_rcu_list);
static DEFINE_SPINLOCK(adap_rcu_lock);
static struct cxgb4_uld_info ulds[CXGB4_ULD_MAX];
static const char *uld_str[] = { "RDMA", "iSCSI" };
static void link_report(struct net_device *dev)
{
if (!netif_carrier_ok(dev))
netdev_info(dev, "link down\n");
else {
static const char *fc[] = { "no", "Rx", "Tx", "Tx/Rx" };
const char *s = "10Mbps";
const struct port_info *p = netdev_priv(dev);
switch (p->link_cfg.speed) {
case 10000:
s = "10Gbps";
break;
case 1000:
s = "1000Mbps";
break;
case 100:
s = "100Mbps";
break;
case 40000:
s = "40Gbps";
break;
}
netdev_info(dev, "link up, %s, full-duplex, %s PAUSE\n", s,
fc[p->link_cfg.fc]);
}
}
#ifdef CONFIG_CHELSIO_T4_DCB
/* Set up/tear down Data Center Bridging Priority mapping for a net device. */
static void dcb_tx_queue_prio_enable(struct net_device *dev, int enable)
{
struct port_info *pi = netdev_priv(dev);
struct adapter *adap = pi->adapter;
struct sge_eth_txq *txq = &adap->sge.ethtxq[pi->first_qset];
int i;
/* We use a simple mapping of Port TX Queue Index to DCB
* Priority when we're enabling DCB.
*/
for (i = 0; i < pi->nqsets; i++, txq++) {
u32 name, value;
int err;
name = (FW_PARAMS_MNEM(FW_PARAMS_MNEM_DMAQ) |
FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DMAQ_EQ_DCBPRIO_ETH) |
FW_PARAMS_PARAM_YZ(txq->q.cntxt_id));
value = enable ? i : 0xffffffff;
/* Since we can be called while atomic (from "interrupt
* level") we need to issue the Set Parameters Commannd
* without sleeping (timeout < 0).
*/
err = t4_set_params_nosleep(adap, adap->mbox, adap->fn, 0, 1,
&name, &value);
if (err)
dev_err(adap->pdev_dev,
"Can't %s DCB Priority on port %d, TX Queue %d: err=%d\n",
enable ? "set" : "unset", pi->port_id, i, -err);
else
txq->dcb_prio = value;
}
}
#endif /* CONFIG_CHELSIO_T4_DCB */
void t4_os_link_changed(struct adapter *adapter, int port_id, int link_stat)
{
struct net_device *dev = adapter->port[port_id];
/* Skip changes from disabled ports. */
if (netif_running(dev) && link_stat != netif_carrier_ok(dev)) {
if (link_stat)
netif_carrier_on(dev);
else {
#ifdef CONFIG_CHELSIO_T4_DCB
cxgb4_dcb_state_init(dev);
dcb_tx_queue_prio_enable(dev, false);
#endif /* CONFIG_CHELSIO_T4_DCB */
netif_carrier_off(dev);
}
link_report(dev);
}
}
void t4_os_portmod_changed(const struct adapter *adap, int port_id)
{
static const char *mod_str[] = {
NULL, "LR", "SR", "ER", "passive DA", "active DA", "LRM"
};
const struct net_device *dev = adap->port[port_id];
const struct port_info *pi = netdev_priv(dev);
if (pi->mod_type == FW_PORT_MOD_TYPE_NONE)
netdev_info(dev, "port module unplugged\n");
else if (pi->mod_type < ARRAY_SIZE(mod_str))
netdev_info(dev, "%s module inserted\n", mod_str[pi->mod_type]);
}
/*
* Configure the exact and hash address filters to handle a port's multicast
* and secondary unicast MAC addresses.
*/
static int set_addr_filters(const struct net_device *dev, bool sleep)
{
u64 mhash = 0;
u64 uhash = 0;
bool free = true;
u16 filt_idx[7];
const u8 *addr[7];
int ret, naddr = 0;
const struct netdev_hw_addr *ha;
int uc_cnt = netdev_uc_count(dev);
int mc_cnt = netdev_mc_count(dev);
const struct port_info *pi = netdev_priv(dev);
unsigned int mb = pi->adapter->fn;
/* first do the secondary unicast addresses */
netdev_for_each_uc_addr(ha, dev) {
addr[naddr++] = ha->addr;
if (--uc_cnt == 0 || naddr >= ARRAY_SIZE(addr)) {
ret = t4_alloc_mac_filt(pi->adapter, mb, pi->viid, free,
naddr, addr, filt_idx, &uhash, sleep);
if (ret < 0)
return ret;
free = false;
naddr = 0;
}
}
/* next set up the multicast addresses */
netdev_for_each_mc_addr(ha, dev) {
addr[naddr++] = ha->addr;
if (--mc_cnt == 0 || naddr >= ARRAY_SIZE(addr)) {
ret = t4_alloc_mac_filt(pi->adapter, mb, pi->viid, free,
naddr, addr, filt_idx, &mhash, sleep);
if (ret < 0)
return ret;
free = false;
naddr = 0;
}
}
return t4_set_addr_hash(pi->adapter, mb, pi->viid, uhash != 0,
uhash | mhash, sleep);
}
int dbfifo_int_thresh = 10; /* 10 == 640 entry threshold */
module_param(dbfifo_int_thresh, int, 0644);
MODULE_PARM_DESC(dbfifo_int_thresh, "doorbell fifo interrupt threshold");
/*
* usecs to sleep while draining the dbfifo
*/
static int dbfifo_drain_delay = 1000;
module_param(dbfifo_drain_delay, int, 0644);
MODULE_PARM_DESC(dbfifo_drain_delay,
"usecs to sleep while draining the dbfifo");
/*
* Set Rx properties of a port, such as promiscruity, address filters, and MTU.
* If @mtu is -1 it is left unchanged.
*/
static int set_rxmode(struct net_device *dev, int mtu, bool sleep_ok)
{
int ret;
struct port_info *pi = netdev_priv(dev);
ret = set_addr_filters(dev, sleep_ok);
if (ret == 0)
ret = t4_set_rxmode(pi->adapter, pi->adapter->fn, pi->viid, mtu,
(dev->flags & IFF_PROMISC) ? 1 : 0,
(dev->flags & IFF_ALLMULTI) ? 1 : 0, 1, -1,
sleep_ok);
return ret;
}
/**
* link_start - enable a port
* @dev: the port to enable
*
* Performs the MAC and PHY actions needed to enable a port.
*/
static int link_start(struct net_device *dev)
{
int ret;
struct port_info *pi = netdev_priv(dev);
unsigned int mb = pi->adapter->fn;
/*
* We do not set address filters and promiscuity here, the stack does
* that step explicitly.
*/
ret = t4_set_rxmode(pi->adapter, mb, pi->viid, dev->mtu, -1, -1, -1,
!!(dev->features & NETIF_F_HW_VLAN_CTAG_RX), true);
if (ret == 0) {
ret = t4_change_mac(pi->adapter, mb, pi->viid,
pi->xact_addr_filt, dev->dev_addr, true,
true);
if (ret >= 0) {
pi->xact_addr_filt = ret;
ret = 0;
}
}
if (ret == 0)
ret = t4_link_start(pi->adapter, mb, pi->tx_chan,
&pi->link_cfg);
if (ret == 0) {
local_bh_disable();
ret = t4_enable_vi_params(pi->adapter, mb, pi->viid, true,
true, CXGB4_DCB_ENABLED);
local_bh_enable();
}
return ret;
}
int cxgb4_dcb_enabled(const struct net_device *dev)
{
#ifdef CONFIG_CHELSIO_T4_DCB
struct port_info *pi = netdev_priv(dev);
if (!pi->dcb.enabled)
return 0;
return ((pi->dcb.state == CXGB4_DCB_STATE_FW_ALLSYNCED) ||
(pi->dcb.state == CXGB4_DCB_STATE_HOST));
#else
return 0;
#endif
}
EXPORT_SYMBOL(cxgb4_dcb_enabled);
#ifdef CONFIG_CHELSIO_T4_DCB
/* Handle a Data Center Bridging update message from the firmware. */
static void dcb_rpl(struct adapter *adap, const struct fw_port_cmd *pcmd)
{
int port = FW_PORT_CMD_PORTID_GET(ntohl(pcmd->op_to_portid));
struct net_device *dev = adap->port[port];
int old_dcb_enabled = cxgb4_dcb_enabled(dev);
int new_dcb_enabled;
cxgb4_dcb_handle_fw_update(adap, pcmd);
new_dcb_enabled = cxgb4_dcb_enabled(dev);
/* If the DCB has become enabled or disabled on the port then we're
* going to need to set up/tear down DCB Priority parameters for the
* TX Queues associated with the port.
*/
if (new_dcb_enabled != old_dcb_enabled)
dcb_tx_queue_prio_enable(dev, new_dcb_enabled);
}
#endif /* CONFIG_CHELSIO_T4_DCB */
/* Clear a filter and release any of its resources that we own. This also
* clears the filter's "pending" status.
*/
static void clear_filter(struct adapter *adap, struct filter_entry *f)
{
/* If the new or old filter have loopback rewriteing rules then we'll
* need to free any existing Layer Two Table (L2T) entries of the old
* filter rule. The firmware will handle freeing up any Source MAC
* Table (SMT) entries used for rewriting Source MAC Addresses in
* loopback rules.
*/
if (f->l2t)
cxgb4_l2t_release(f->l2t);
/* The zeroing of the filter rule below clears the filter valid,
* pending, locked flags, l2t pointer, etc. so it's all we need for
* this operation.
*/
memset(f, 0, sizeof(*f));
}
/* Handle a filter write/deletion reply.
*/
static void filter_rpl(struct adapter *adap, const struct cpl_set_tcb_rpl *rpl)
{
unsigned int idx = GET_TID(rpl);
unsigned int nidx = idx - adap->tids.ftid_base;
unsigned int ret;
struct filter_entry *f;
if (idx >= adap->tids.ftid_base && nidx <
(adap->tids.nftids + adap->tids.nsftids)) {
idx = nidx;
ret = GET_TCB_COOKIE(rpl->cookie);
f = &adap->tids.ftid_tab[idx];
if (ret == FW_FILTER_WR_FLT_DELETED) {
/* Clear the filter when we get confirmation from the
* hardware that the filter has been deleted.
*/
clear_filter(adap, f);
} else if (ret == FW_FILTER_WR_SMT_TBL_FULL) {
dev_err(adap->pdev_dev, "filter %u setup failed due to full SMT\n",
idx);
clear_filter(adap, f);
} else if (ret == FW_FILTER_WR_FLT_ADDED) {
f->smtidx = (be64_to_cpu(rpl->oldval) >> 24) & 0xff;
f->pending = 0; /* asynchronous setup completed */
f->valid = 1;
} else {
/* Something went wrong. Issue a warning about the
* problem and clear everything out.
*/
dev_err(adap->pdev_dev, "filter %u setup failed with error %u\n",
idx, ret);
clear_filter(adap, f);
}
}
}
/* Response queue handler for the FW event queue.
*/
static int fwevtq_handler(struct sge_rspq *q, const __be64 *rsp,
const struct pkt_gl *gl)
{
u8 opcode = ((const struct rss_header *)rsp)->opcode;
rsp++; /* skip RSS header */
/* FW can send EGR_UPDATEs encapsulated in a CPL_FW4_MSG.
*/
if (unlikely(opcode == CPL_FW4_MSG &&
((const struct cpl_fw4_msg *)rsp)->type == FW_TYPE_RSSCPL)) {
rsp++;
opcode = ((const struct rss_header *)rsp)->opcode;
rsp++;
if (opcode != CPL_SGE_EGR_UPDATE) {
dev_err(q->adap->pdev_dev, "unexpected FW4/CPL %#x on FW event queue\n"
, opcode);
goto out;
}
}
if (likely(opcode == CPL_SGE_EGR_UPDATE)) {
const struct cpl_sge_egr_update *p = (void *)rsp;
unsigned int qid = EGR_QID(ntohl(p->opcode_qid));
struct sge_txq *txq;
txq = q->adap->sge.egr_map[qid - q->adap->sge.egr_start];
txq->restarts++;
if ((u8 *)txq < (u8 *)q->adap->sge.ofldtxq) {
struct sge_eth_txq *eq;
eq = container_of(txq, struct sge_eth_txq, q);
netif_tx_wake_queue(eq->txq);
} else {
struct sge_ofld_txq *oq;
oq = container_of(txq, struct sge_ofld_txq, q);
tasklet_schedule(&oq->qresume_tsk);
}
} else if (opcode == CPL_FW6_MSG || opcode == CPL_FW4_MSG) {
const struct cpl_fw6_msg *p = (void *)rsp;
#ifdef CONFIG_CHELSIO_T4_DCB
const struct fw_port_cmd *pcmd = (const void *)p->data;
unsigned int cmd = FW_CMD_OP_GET(ntohl(pcmd->op_to_portid));
unsigned int action =
FW_PORT_CMD_ACTION_GET(ntohl(pcmd->action_to_len16));
if (cmd == FW_PORT_CMD &&
action == FW_PORT_ACTION_GET_PORT_INFO) {
int port = FW_PORT_CMD_PORTID_GET(
be32_to_cpu(pcmd->op_to_portid));
struct net_device *dev = q->adap->port[port];
int state_input = ((pcmd->u.info.dcbxdis_pkd &
FW_PORT_CMD_DCBXDIS)
? CXGB4_DCB_INPUT_FW_DISABLED
: CXGB4_DCB_INPUT_FW_ENABLED);
cxgb4_dcb_state_fsm(dev, state_input);
}
if (cmd == FW_PORT_CMD &&
action == FW_PORT_ACTION_L2_DCB_CFG)
dcb_rpl(q->adap, pcmd);
else
#endif
if (p->type == 0)
t4_handle_fw_rpl(q->adap, p->data);
} else if (opcode == CPL_L2T_WRITE_RPL) {
const struct cpl_l2t_write_rpl *p = (void *)rsp;
do_l2t_write_rpl(q->adap, p);
} else if (opcode == CPL_SET_TCB_RPL) {
const struct cpl_set_tcb_rpl *p = (void *)rsp;
filter_rpl(q->adap, p);
} else
dev_err(q->adap->pdev_dev,
"unexpected CPL %#x on FW event queue\n", opcode);
out:
return 0;
}
/**
* uldrx_handler - response queue handler for ULD queues
* @q: the response queue that received the packet
* @rsp: the response queue descriptor holding the offload message
* @gl: the gather list of packet fragments
*
* Deliver an ingress offload packet to a ULD. All processing is done by
* the ULD, we just maintain statistics.
*/
static int uldrx_handler(struct sge_rspq *q, const __be64 *rsp,
const struct pkt_gl *gl)
{
struct sge_ofld_rxq *rxq = container_of(q, struct sge_ofld_rxq, rspq);
/* FW can send CPLs encapsulated in a CPL_FW4_MSG.
*/
if (((const struct rss_header *)rsp)->opcode == CPL_FW4_MSG &&
((const struct cpl_fw4_msg *)(rsp + 1))->type == FW_TYPE_RSSCPL)
rsp += 2;
if (ulds[q->uld].rx_handler(q->adap->uld_handle[q->uld], rsp, gl)) {
rxq->stats.nomem++;
return -1;
}
if (gl == NULL)
rxq->stats.imm++;
else if (gl == CXGB4_MSG_AN)
rxq->stats.an++;
else
rxq->stats.pkts++;
return 0;
}
static void disable_msi(struct adapter *adapter)
{
if (adapter->flags & USING_MSIX) {
pci_disable_msix(adapter->pdev);
adapter->flags &= ~USING_MSIX;
} else if (adapter->flags & USING_MSI) {
pci_disable_msi(adapter->pdev);
adapter->flags &= ~USING_MSI;
}
}
/*
* Interrupt handler for non-data events used with MSI-X.
*/
static irqreturn_t t4_nondata_intr(int irq, void *cookie)
{
struct adapter *adap = cookie;
u32 v = t4_read_reg(adap, MYPF_REG(PL_PF_INT_CAUSE));
if (v & PFSW) {
adap->swintr = 1;
t4_write_reg(adap, MYPF_REG(PL_PF_INT_CAUSE), v);
}
t4_slow_intr_handler(adap);
return IRQ_HANDLED;
}
/*
* Name the MSI-X interrupts.
*/
static void name_msix_vecs(struct adapter *adap)
{
int i, j, msi_idx = 2, n = sizeof(adap->msix_info[0].desc);
/* non-data interrupts */
snprintf(adap->msix_info[0].desc, n, "%s", adap->port[0]->name);
/* FW events */
snprintf(adap->msix_info[1].desc, n, "%s-FWeventq",
adap->port[0]->name);
/* Ethernet queues */
for_each_port(adap, j) {
struct net_device *d = adap->port[j];
const struct port_info *pi = netdev_priv(d);
for (i = 0; i < pi->nqsets; i++, msi_idx++)
snprintf(adap->msix_info[msi_idx].desc, n, "%s-Rx%d",
d->name, i);
}
/* offload queues */
for_each_ofldrxq(&adap->sge, i)
snprintf(adap->msix_info[msi_idx++].desc, n, "%s-ofld%d",
adap->port[0]->name, i);
for_each_rdmarxq(&adap->sge, i)
snprintf(adap->msix_info[msi_idx++].desc, n, "%s-rdma%d",
adap->port[0]->name, i);
for_each_rdmaciq(&adap->sge, i)
snprintf(adap->msix_info[msi_idx++].desc, n, "%s-rdma-ciq%d",
adap->port[0]->name, i);
}
static int request_msix_queue_irqs(struct adapter *adap)
{
struct sge *s = &adap->sge;
int err, ethqidx, ofldqidx = 0, rdmaqidx = 0, rdmaciqqidx = 0;
int msi_index = 2;
err = request_irq(adap->msix_info[1].vec, t4_sge_intr_msix, 0,
adap->msix_info[1].desc, &s->fw_evtq);
if (err)
return err;
for_each_ethrxq(s, ethqidx) {
err = request_irq(adap->msix_info[msi_index].vec,
t4_sge_intr_msix, 0,
adap->msix_info[msi_index].desc,
&s->ethrxq[ethqidx].rspq);
if (err)
goto unwind;
msi_index++;
}
for_each_ofldrxq(s, ofldqidx) {
err = request_irq(adap->msix_info[msi_index].vec,
t4_sge_intr_msix, 0,
adap->msix_info[msi_index].desc,
&s->ofldrxq[ofldqidx].rspq);
if (err)
goto unwind;
msi_index++;
}
for_each_rdmarxq(s, rdmaqidx) {
err = request_irq(adap->msix_info[msi_index].vec,
t4_sge_intr_msix, 0,
adap->msix_info[msi_index].desc,
&s->rdmarxq[rdmaqidx].rspq);
if (err)
goto unwind;
msi_index++;
}
for_each_rdmaciq(s, rdmaciqqidx) {
err = request_irq(adap->msix_info[msi_index].vec,
t4_sge_intr_msix, 0,
adap->msix_info[msi_index].desc,
&s->rdmaciq[rdmaciqqidx].rspq);
if (err)
goto unwind;
msi_index++;
}
return 0;
unwind:
while (--rdmaciqqidx >= 0)
free_irq(adap->msix_info[--msi_index].vec,
&s->rdmaciq[rdmaciqqidx].rspq);
while (--rdmaqidx >= 0)
free_irq(adap->msix_info[--msi_index].vec,
&s->rdmarxq[rdmaqidx].rspq);
while (--ofldqidx >= 0)
free_irq(adap->msix_info[--msi_index].vec,
&s->ofldrxq[ofldqidx].rspq);
while (--ethqidx >= 0)
free_irq(adap->msix_info[--msi_index].vec,
&s->ethrxq[ethqidx].rspq);
free_irq(adap->msix_info[1].vec, &s->fw_evtq);
return err;
}
static void free_msix_queue_irqs(struct adapter *adap)
{
int i, msi_index = 2;
struct sge *s = &adap->sge;
free_irq(adap->msix_info[1].vec, &s->fw_evtq);
for_each_ethrxq(s, i)
free_irq(adap->msix_info[msi_index++].vec, &s->ethrxq[i].rspq);
for_each_ofldrxq(s, i)
free_irq(adap->msix_info[msi_index++].vec, &s->ofldrxq[i].rspq);
for_each_rdmarxq(s, i)
free_irq(adap->msix_info[msi_index++].vec, &s->rdmarxq[i].rspq);
for_each_rdmaciq(s, i)
free_irq(adap->msix_info[msi_index++].vec, &s->rdmaciq[i].rspq);
}
/**
* write_rss - write the RSS table for a given port
* @pi: the port
* @queues: array of queue indices for RSS
*
* Sets up the portion of the HW RSS table for the port's VI to distribute
* packets to the Rx queues in @queues.
*/
static int write_rss(const struct port_info *pi, const u16 *queues)
{
u16 *rss;
int i, err;
const struct sge_eth_rxq *q = &pi->adapter->sge.ethrxq[pi->first_qset];
rss = kmalloc(pi->rss_size * sizeof(u16), GFP_KERNEL);
if (!rss)
return -ENOMEM;
/* map the queue indices to queue ids */
for (i = 0; i < pi->rss_size; i++, queues++)
rss[i] = q[*queues].rspq.abs_id;
err = t4_config_rss_range(pi->adapter, pi->adapter->fn, pi->viid, 0,
pi->rss_size, rss, pi->rss_size);
kfree(rss);
return err;
}
/**
* setup_rss - configure RSS
* @adap: the adapter
*
* Sets up RSS for each port.
*/
static int setup_rss(struct adapter *adap)
{
int i, err;
for_each_port(adap, i) {
const struct port_info *pi = adap2pinfo(adap, i);
err = write_rss(pi, pi->rss);
if (err)
return err;
}
return 0;
}
/*
* Return the channel of the ingress queue with the given qid.
*/
static unsigned int rxq_to_chan(const struct sge *p, unsigned int qid)
{
qid -= p->ingr_start;
return netdev2pinfo(p->ingr_map[qid]->netdev)->tx_chan;
}
/*
* Wait until all NAPI handlers are descheduled.
*/
static void quiesce_rx(struct adapter *adap)
{
int i;
for (i = 0; i < ARRAY_SIZE(adap->sge.ingr_map); i++) {
struct sge_rspq *q = adap->sge.ingr_map[i];
if (q && q->handler)
napi_disable(&q->napi);
}
}
/*
* Enable NAPI scheduling and interrupt generation for all Rx queues.
*/
static void enable_rx(struct adapter *adap)
{
int i;
for (i = 0; i < ARRAY_SIZE(adap->sge.ingr_map); i++) {
struct sge_rspq *q = adap->sge.ingr_map[i];
if (!q)
continue;
if (q->handler)
napi_enable(&q->napi);
/* 0-increment GTS to start the timer and enable interrupts */
t4_write_reg(adap, MYPF_REG(SGE_PF_GTS),
SEINTARM(q->intr_params) |
INGRESSQID(q->cntxt_id));
}
}
/**
* setup_sge_queues - configure SGE Tx/Rx/response queues
* @adap: the adapter
*
* Determines how many sets of SGE queues to use and initializes them.
* We support multiple queue sets per port if we have MSI-X, otherwise
* just one queue set per port.
*/
static int setup_sge_queues(struct adapter *adap)
{
int err, msi_idx, i, j;
struct sge *s = &adap->sge;
bitmap_zero(s->starving_fl, MAX_EGRQ);
bitmap_zero(s->txq_maperr, MAX_EGRQ);
if (adap->flags & USING_MSIX)
msi_idx = 1; /* vector 0 is for non-queue interrupts */
else {
err = t4_sge_alloc_rxq(adap, &s->intrq, false, adap->port[0], 0,
NULL, NULL);
if (err)
return err;
msi_idx = -((int)s->intrq.abs_id + 1);
}
err = t4_sge_alloc_rxq(adap, &s->fw_evtq, true, adap->port[0],
msi_idx, NULL, fwevtq_handler);
if (err) {
freeout: t4_free_sge_resources(adap);
return err;
}
for_each_port(adap, i) {
struct net_device *dev = adap->port[i];
struct port_info *pi = netdev_priv(dev);
struct sge_eth_rxq *q = &s->ethrxq[pi->first_qset];
struct sge_eth_txq *t = &s->ethtxq[pi->first_qset];
for (j = 0; j < pi->nqsets; j++, q++) {
if (msi_idx > 0)
msi_idx++;
err = t4_sge_alloc_rxq(adap, &q->rspq, false, dev,
msi_idx, &q->fl,
t4_ethrx_handler);
if (err)
goto freeout;
q->rspq.idx = j;
memset(&q->stats, 0, sizeof(q->stats));
}
for (j = 0; j < pi->nqsets; j++, t++) {
err = t4_sge_alloc_eth_txq(adap, t, dev,
netdev_get_tx_queue(dev, j),
s->fw_evtq.cntxt_id);
if (err)
goto freeout;
}
}
j = s->ofldqsets / adap->params.nports; /* ofld queues per channel */
for_each_ofldrxq(s, i) {
struct sge_ofld_rxq *q = &s->ofldrxq[i];
struct net_device *dev = adap->port[i / j];
if (msi_idx > 0)
msi_idx++;
err = t4_sge_alloc_rxq(adap, &q->rspq, false, dev, msi_idx,
q->fl.size ? &q->fl : NULL,
uldrx_handler);
if (err)
goto freeout;
memset(&q->stats, 0, sizeof(q->stats));
s->ofld_rxq[i] = q->rspq.abs_id;
err = t4_sge_alloc_ofld_txq(adap, &s->ofldtxq[i], dev,
s->fw_evtq.cntxt_id);
if (err)
goto freeout;
}
for_each_rdmarxq(s, i) {
struct sge_ofld_rxq *q = &s->rdmarxq[i];
if (msi_idx > 0)
msi_idx++;
err = t4_sge_alloc_rxq(adap, &q->rspq, false, adap->port[i],
msi_idx, q->fl.size ? &q->fl : NULL,
uldrx_handler);
if (err)
goto freeout;
memset(&q->stats, 0, sizeof(q->stats));
s->rdma_rxq[i] = q->rspq.abs_id;
}
for_each_rdmaciq(s, i) {
struct sge_ofld_rxq *q = &s->rdmaciq[i];
if (msi_idx > 0)
msi_idx++;
err = t4_sge_alloc_rxq(adap, &q->rspq, false, adap->port[i],
msi_idx, q->fl.size ? &q->fl : NULL,
uldrx_handler);
if (err)
goto freeout;
memset(&q->stats, 0, sizeof(q->stats));
s->rdma_ciq[i] = q->rspq.abs_id;
}
for_each_port(adap, i) {
/*
* Note that ->rdmarxq[i].rspq.cntxt_id below is 0 if we don't
* have RDMA queues, and that's the right value.
*/
err = t4_sge_alloc_ctrl_txq(adap, &s->ctrlq[i], adap->port[i],
s->fw_evtq.cntxt_id,
s->rdmarxq[i].rspq.cntxt_id);
if (err)
goto freeout;
}
t4_write_reg(adap, is_t4(adap->params.chip) ?
MPS_TRC_RSS_CONTROL :
MPS_T5_TRC_RSS_CONTROL,
RSSCONTROL(netdev2pinfo(adap->port[0])->tx_chan) |
QUEUENUMBER(s->ethrxq[0].rspq.abs_id));
return 0;
}
/*
* Allocate a chunk of memory using kmalloc or, if that fails, vmalloc.
* The allocated memory is cleared.
*/
void *t4_alloc_mem(size_t size)
{
void *p = kzalloc(size, GFP_KERNEL | __GFP_NOWARN);
if (!p)
p = vzalloc(size);
return p;
}
/*
* Free memory allocated through alloc_mem().
*/
static void t4_free_mem(void *addr)
{
if (is_vmalloc_addr(addr))
vfree(addr);
else
kfree(addr);
}
/* Send a Work Request to write the filter at a specified index. We construct
* a Firmware Filter Work Request to have the work done and put the indicated
* filter into "pending" mode which will prevent any further actions against
* it till we get a reply from the firmware on the completion status of the
* request.
*/
static int set_filter_wr(struct adapter *adapter, int fidx)
{
struct filter_entry *f = &adapter->tids.ftid_tab[fidx];
struct sk_buff *skb;
struct fw_filter_wr *fwr;
unsigned int ftid;
/* If the new filter requires loopback Destination MAC and/or VLAN
* rewriting then we need to allocate a Layer 2 Table (L2T) entry for
* the filter.
*/
if (f->fs.newdmac || f->fs.newvlan) {
/* allocate L2T entry for new filter */
f->l2t = t4_l2t_alloc_switching(adapter->l2t);
if (f->l2t == NULL)
return -EAGAIN;
if (t4_l2t_set_switching(adapter, f->l2t, f->fs.vlan,
f->fs.eport, f->fs.dmac)) {
cxgb4_l2t_release(f->l2t);
f->l2t = NULL;
return -ENOMEM;
}
}
ftid = adapter->tids.ftid_base + fidx;
skb = alloc_skb(sizeof(*fwr), GFP_KERNEL | __GFP_NOFAIL);
fwr = (struct fw_filter_wr *)__skb_put(skb, sizeof(*fwr));
memset(fwr, 0, sizeof(*fwr));
/* It would be nice to put most of the following in t4_hw.c but most
* of the work is translating the cxgbtool ch_filter_specification
* into the Work Request and the definition of that structure is
* currently in cxgbtool.h which isn't appropriate to pull into the
* common code. We may eventually try to come up with a more neutral
* filter specification structure but for now it's easiest to simply
* put this fairly direct code in line ...
*/
fwr->op_pkd = htonl(FW_WR_OP(FW_FILTER_WR));
fwr->len16_pkd = htonl(FW_WR_LEN16(sizeof(*fwr)/16));
fwr->tid_to_iq =
htonl(V_FW_FILTER_WR_TID(ftid) |
V_FW_FILTER_WR_RQTYPE(f->fs.type) |
V_FW_FILTER_WR_NOREPLY(0) |
V_FW_FILTER_WR_IQ(f->fs.iq));
fwr->del_filter_to_l2tix =
htonl(V_FW_FILTER_WR_RPTTID(f->fs.rpttid) |
V_FW_FILTER_WR_DROP(f->fs.action == FILTER_DROP) |
V_FW_FILTER_WR_DIRSTEER(f->fs.dirsteer) |
V_FW_FILTER_WR_MASKHASH(f->fs.maskhash) |
V_FW_FILTER_WR_DIRSTEERHASH(f->fs.dirsteerhash) |
V_FW_FILTER_WR_LPBK(f->fs.action == FILTER_SWITCH) |
V_FW_FILTER_WR_DMAC(f->fs.newdmac) |
V_FW_FILTER_WR_SMAC(f->fs.newsmac) |
V_FW_FILTER_WR_INSVLAN(f->fs.newvlan == VLAN_INSERT ||
f->fs.newvlan == VLAN_REWRITE) |
V_FW_FILTER_WR_RMVLAN(f->fs.newvlan == VLAN_REMOVE ||
f->fs.newvlan == VLAN_REWRITE) |
V_FW_FILTER_WR_HITCNTS(f->fs.hitcnts) |
V_FW_FILTER_WR_TXCHAN(f->fs.eport) |
V_FW_FILTER_WR_PRIO(f->fs.prio) |
V_FW_FILTER_WR_L2TIX(f->l2t ? f->l2t->idx : 0));
fwr->ethtype = htons(f->fs.val.ethtype);
fwr->ethtypem = htons(f->fs.mask.ethtype);
fwr->frag_to_ovlan_vldm =
(V_FW_FILTER_WR_FRAG(f->fs.val.frag) |
V_FW_FILTER_WR_FRAGM(f->fs.mask.frag) |
V_FW_FILTER_WR_IVLAN_VLD(f->fs.val.ivlan_vld) |
V_FW_FILTER_WR_OVLAN_VLD(f->fs.val.ovlan_vld) |
V_FW_FILTER_WR_IVLAN_VLDM(f->fs.mask.ivlan_vld) |
V_FW_FILTER_WR_OVLAN_VLDM(f->fs.mask.ovlan_vld));
fwr->smac_sel = 0;
fwr->rx_chan_rx_rpl_iq =
htons(V_FW_FILTER_WR_RX_CHAN(0) |
V_FW_FILTER_WR_RX_RPL_IQ(adapter->sge.fw_evtq.abs_id));
fwr->maci_to_matchtypem =
htonl(V_FW_FILTER_WR_MACI(f->fs.val.macidx) |
V_FW_FILTER_WR_MACIM(f->fs.mask.macidx) |
V_FW_FILTER_WR_FCOE(f->fs.val.fcoe) |
V_FW_FILTER_WR_FCOEM(f->fs.mask.fcoe) |
V_FW_FILTER_WR_PORT(f->fs.val.iport) |
V_FW_FILTER_WR_PORTM(f->fs.mask.iport) |
V_FW_FILTER_WR_MATCHTYPE(f->fs.val.matchtype) |
V_FW_FILTER_WR_MATCHTYPEM(f->fs.mask.matchtype));
fwr->ptcl = f->fs.val.proto;
fwr->ptclm = f->fs.mask.proto;
fwr->ttyp = f->fs.val.tos;
fwr->ttypm = f->fs.mask.tos;
fwr->ivlan = htons(f->fs.val.ivlan);
fwr->ivlanm = htons(f->fs.mask.ivlan);
fwr->ovlan = htons(f->fs.val.ovlan);
fwr->ovlanm = htons(f->fs.mask.ovlan);
memcpy(fwr->lip, f->fs.val.lip, sizeof(fwr->lip));
memcpy(fwr->lipm, f->fs.mask.lip, sizeof(fwr->lipm));
memcpy(fwr->fip, f->fs.val.fip, sizeof(fwr->fip));
memcpy(fwr->fipm, f->fs.mask.fip, sizeof(fwr->fipm));
fwr->lp = htons(f->fs.val.lport);
fwr->lpm = htons(f->fs.mask.lport);
fwr->fp = htons(f->fs.val.fport);
fwr->fpm = htons(f->fs.mask.fport);
if (f->fs.newsmac)
memcpy(fwr->sma, f->fs.smac, sizeof(fwr->sma));
/* Mark the filter as "pending" and ship off the Filter Work Request.
* When we get the Work Request Reply we'll clear the pending status.
*/
f->pending = 1;
set_wr_txq(skb, CPL_PRIORITY_CONTROL, f->fs.val.iport & 0x3);
t4_ofld_send(adapter, skb);
return 0;
}
/* Delete the filter at a specified index.
*/
static int del_filter_wr(struct adapter *adapter, int fidx)
{
struct filter_entry *f = &adapter->tids.ftid_tab[fidx];
struct sk_buff *skb;
struct fw_filter_wr *fwr;
unsigned int len, ftid;
len = sizeof(*fwr);
ftid = adapter->tids.ftid_base + fidx;
skb = alloc_skb(len, GFP_KERNEL | __GFP_NOFAIL);
fwr = (struct fw_filter_wr *)__skb_put(skb, len);
t4_mk_filtdelwr(ftid, fwr, adapter->sge.fw_evtq.abs_id);
/* Mark the filter as "pending" and ship off the Filter Work Request.
* When we get the Work Request Reply we'll clear the pending status.
*/
f->pending = 1;
t4_mgmt_tx(adapter, skb);
return 0;
}
static u16 cxgb_select_queue(struct net_device *dev, struct sk_buff *skb,
void *accel_priv, select_queue_fallback_t fallback)
{
int txq;
#ifdef CONFIG_CHELSIO_T4_DCB
/* If a Data Center Bridging has been successfully negotiated on this
* link then we'll use the skb's priority to map it to a TX Queue.
* The skb's priority is determined via the VLAN Tag Priority Code
* Point field.
*/
if (cxgb4_dcb_enabled(dev)) {
u16 vlan_tci;
int err;
err = vlan_get_tag(skb, &vlan_tci);
if (unlikely(err)) {
if (net_ratelimit())
netdev_warn(dev,
"TX Packet without VLAN Tag on DCB Link\n");
txq = 0;
} else {
txq = (vlan_tci & VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT;
}
return txq;
}
#endif /* CONFIG_CHELSIO_T4_DCB */
if (select_queue) {
txq = (skb_rx_queue_recorded(skb)
? skb_get_rx_queue(skb)
: smp_processor_id());
while (unlikely(txq >= dev->real_num_tx_queues))
txq -= dev->real_num_tx_queues;
return txq;
}
return fallback(dev, skb) % dev->real_num_tx_queues;
}
static inline int is_offload(const struct adapter *adap)
{
return adap->params.offload;
}
/*
* Implementation of ethtool operations.
*/
static u32 get_msglevel(struct net_device *dev)
{
return netdev2adap(dev)->msg_enable;
}
static void set_msglevel(struct net_device *dev, u32 val)
{
netdev2adap(dev)->msg_enable = val;
}
static char stats_strings[][ETH_GSTRING_LEN] = {
"TxOctetsOK ",
"TxFramesOK ",
"TxBroadcastFrames ",
"TxMulticastFrames ",
"TxUnicastFrames ",
"TxErrorFrames ",
"TxFrames64 ",
"TxFrames65To127 ",
"TxFrames128To255 ",
"TxFrames256To511 ",
"TxFrames512To1023 ",
"TxFrames1024To1518 ",
"TxFrames1519ToMax ",
"TxFramesDropped ",
"TxPauseFrames ",
"TxPPP0Frames ",
"TxPPP1Frames ",
"TxPPP2Frames ",
"TxPPP3Frames ",
"TxPPP4Frames ",
"TxPPP5Frames ",
"TxPPP6Frames ",
"TxPPP7Frames ",
"RxOctetsOK ",
"RxFramesOK ",
"RxBroadcastFrames ",
"RxMulticastFrames ",
"RxUnicastFrames ",
"RxFramesTooLong ",
"RxJabberErrors ",
"RxFCSErrors ",
"RxLengthErrors ",
"RxSymbolErrors ",
"RxRuntFrames ",
"RxFrames64 ",
"RxFrames65To127 ",
"RxFrames128To255 ",
"RxFrames256To511 ",
"RxFrames512To1023 ",
"RxFrames1024To1518 ",
"RxFrames1519ToMax ",
"RxPauseFrames ",
"RxPPP0Frames ",
"RxPPP1Frames ",
"RxPPP2Frames ",
"RxPPP3Frames ",
"RxPPP4Frames ",
"RxPPP5Frames ",
"RxPPP6Frames ",
"RxPPP7Frames ",
"RxBG0FramesDropped ",
"RxBG1FramesDropped ",
"RxBG2FramesDropped ",
"RxBG3FramesDropped ",
"RxBG0FramesTrunc ",
"RxBG1FramesTrunc ",
"RxBG2FramesTrunc ",
"RxBG3FramesTrunc ",
"TSO ",
"TxCsumOffload ",
"RxCsumGood ",
"VLANextractions ",
"VLANinsertions ",
"GROpackets ",
"GROmerged ",
"WriteCoalSuccess ",
"WriteCoalFail ",
};
static int get_sset_count(struct net_device *dev, int sset)
{
switch (sset) {
case ETH_SS_STATS:
return ARRAY_SIZE(stats_strings);
default:
return -EOPNOTSUPP;
}
}
#define T4_REGMAP_SIZE (160 * 1024)
#define T5_REGMAP_SIZE (332 * 1024)
static int get_regs_len(struct net_device *dev)
{
struct adapter *adap = netdev2adap(dev);
if (is_t4(adap->params.chip))
return T4_REGMAP_SIZE;
else
return T5_REGMAP_SIZE;
}
static int get_eeprom_len(struct net_device *dev)
{
return EEPROMSIZE;
}
static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
{
struct adapter *adapter = netdev2adap(dev);
strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
strlcpy(info->version, DRV_VERSION, sizeof(info->version));
strlcpy(info->bus_info, pci_name(adapter->pdev),
sizeof(info->bus_info));
if (adapter->params.fw_vers)
snprintf(info->fw_version, sizeof(info->fw_version),
"%u.%u.%u.%u, TP %u.%u.%u.%u",
FW_HDR_FW_VER_MAJOR_GET(adapter->params.fw_vers),
FW_HDR_FW_VER_MINOR_GET(adapter->params.fw_vers),
FW_HDR_FW_VER_MICRO_GET(adapter->params.fw_vers),
FW_HDR_FW_VER_BUILD_GET(adapter->params.fw_vers),
FW_HDR_FW_VER_MAJOR_GET(adapter->params.tp_vers),
FW_HDR_FW_VER_MINOR_GET(adapter->params.tp_vers),
FW_HDR_FW_VER_MICRO_GET(adapter->params.tp_vers),
FW_HDR_FW_VER_BUILD_GET(adapter->params.tp_vers));
}
static void get_strings(struct net_device *dev, u32 stringset, u8 *data)
{
if (stringset == ETH_SS_STATS)
memcpy(data, stats_strings, sizeof(stats_strings));
}
/*
* port stats maintained per queue of the port. They should be in the same
* order as in stats_strings above.
*/
struct queue_port_stats {
u64 tso;
u64 tx_csum;
u64 rx_csum;
u64 vlan_ex;
u64 vlan_ins;
u64 gro_pkts;
u64 gro_merged;
};
static void collect_sge_port_stats(const struct adapter *adap,
const struct port_info *p, struct queue_port_stats *s)
{
int i;
const struct sge_eth_txq *tx = &adap->sge.ethtxq[p->first_qset];
const struct sge_eth_rxq *rx = &adap->sge.ethrxq[p->first_qset];
memset(s, 0, sizeof(*s));
for (i = 0; i < p->nqsets; i++, rx++, tx++) {
s->tso += tx->tso;
s->tx_csum += tx->tx_cso;
s->rx_csum += rx->stats.rx_cso;
s->vlan_ex += rx->stats.vlan_ex;
s->vlan_ins += tx->vlan_ins;
s->gro_pkts += rx->stats.lro_pkts;
s->gro_merged += rx->stats.lro_merged;
}
}
static void get_stats(struct net_device *dev, struct ethtool_stats *stats,
u64 *data)
{
struct port_info *pi = netdev_priv(dev);
struct adapter *adapter = pi->adapter;
u32 val1, val2;
t4_get_port_stats(adapter, pi->tx_chan, (struct port_stats *)data);
data += sizeof(struct port_stats) / sizeof(u64);
collect_sge_port_stats(adapter, pi, (struct queue_port_stats *)data);
data += sizeof(struct queue_port_stats) / sizeof(u64);
if (!is_t4(adapter->params.chip)) {
t4_write_reg(adapter, SGE_STAT_CFG, STATSOURCE_T5(7));
val1 = t4_read_reg(adapter, SGE_STAT_TOTAL);
val2 = t4_read_reg(adapter, SGE_STAT_MATCH);
*data = val1 - val2;
data++;
*data = val2;
data++;
} else {
memset(data, 0, 2 * sizeof(u64));
*data += 2;
}
}
/*
* Return a version number to identify the type of adapter. The scheme is:
* - bits 0..9: chip version
* - bits 10..15: chip revision
* - bits 16..23: register dump version
*/
static inline unsigned int mk_adap_vers(const struct adapter *ap)
{
return CHELSIO_CHIP_VERSION(ap->params.chip) |
(CHELSIO_CHIP_RELEASE(ap->params.chip) << 10) | (1 << 16);
}
static void reg_block_dump(struct adapter *ap, void *buf, unsigned int start,
unsigned int end)
{
u32 *p = buf + start;
for ( ; start <= end; start += sizeof(u32))
*p++ = t4_read_reg(ap, start);
}
static void get_regs(struct net_device *dev, struct ethtool_regs *regs,
void *buf)
{
static const unsigned int t4_reg_ranges[] = {
0x1008, 0x1108,
0x1180, 0x11b4,
0x11fc, 0x123c,
0x1300, 0x173c,
0x1800, 0x18fc,
0x3000, 0x30d8,
0x30e0, 0x5924,
0x5960, 0x59d4,
0x5a00, 0x5af8,
0x6000, 0x6098,
0x6100, 0x6150,
0x6200, 0x6208,
0x6240, 0x6248,
0x6280, 0x6338,
0x6370, 0x638c,
0x6400, 0x643c,
0x6500, 0x6524,
0x6a00, 0x6a38,
0x6a60, 0x6a78,
0x6b00, 0x6b84,
0x6bf0, 0x6c84,
0x6cf0, 0x6d84,
0x6df0, 0x6e84,
0x6ef0, 0x6f84,
0x6ff0, 0x7084,
0x70f0, 0x7184,
0x71f0, 0x7284,
0x72f0, 0x7384,
0x73f0, 0x7450,
0x7500, 0x7530,
0x7600, 0x761c,
0x7680, 0x76cc,
0x7700, 0x7798,
0x77c0, 0x77fc,
0x7900, 0x79fc,
0x7b00, 0x7c38,
0x7d00, 0x7efc,
0x8dc0, 0x8e1c,
0x8e30, 0x8e78,
0x8ea0, 0x8f6c,
0x8fc0, 0x9074,
0x90fc, 0x90fc,
0x9400, 0x9458,
0x9600, 0x96bc,
0x9800, 0x9808,
0x9820, 0x983c,
0x9850, 0x9864,
0x9c00, 0x9c6c,
0x9c80, 0x9cec,
0x9d00, 0x9d6c,
0x9d80, 0x9dec,
0x9e00, 0x9e6c,
0x9e80, 0x9eec,
0x9f00, 0x9f6c,
0x9f80, 0x9fec,
0xd004, 0xd03c,
0xdfc0, 0xdfe0,
0xe000, 0xea7c,
0xf000, 0x11110,
0x11118, 0x11190,
0x19040, 0x1906c,
0x19078, 0x19080,
0x1908c, 0x19124,
0x19150, 0x191b0,
0x191d0, 0x191e8,
0x19238, 0x1924c,
0x193f8, 0x19474,
0x19490, 0x194f8,
0x19800, 0x19f30,
0x1a000, 0x1a06c,
0x1a0b0, 0x1a120,
0x1a128, 0x1a138,
0x1a190, 0x1a1c4,
0x1a1fc, 0x1a1fc,
0x1e040, 0x1e04c,
0x1e284, 0x1e28c,
0x1e2c0, 0x1e2c0,
0x1e2e0, 0x1e2e0,
0x1e300, 0x1e384,
0x1e3c0, 0x1e3c8,
0x1e440, 0x1e44c,
0x1e684, 0x1e68c,
0x1e6c0, 0x1e6c0,
0x1e6e0, 0x1e6e0,
0x1e700, 0x1e784,
0x1e7c0, 0x1e7c8,
0x1e840, 0x1e84c,
0x1ea84, 0x1ea8c,
0x1eac0, 0x1eac0,
0x1eae0, 0x1eae0,
0x1eb00, 0x1eb84,
0x1ebc0, 0x1ebc8,
0x1ec40, 0x1ec4c,
0x1ee84, 0x1ee8c,
0x1eec0, 0x1eec0,
0x1eee0, 0x1eee0,
0x1ef00, 0x1ef84,
0x1efc0, 0x1efc8,
0x1f040, 0x1f04c,
0x1f284, 0x1f28c,
0x1f2c0, 0x1f2c0,
0x1f2e0, 0x1f2e0,
0x1f300, 0x1f384,
0x1f3c0, 0x1f3c8,
0x1f440, 0x1f44c,
0x1f684, 0x1f68c,
0x1f6c0, 0x1f6c0,
0x1f6e0, 0x1f6e0,
0x1f700, 0x1f784,
0x1f7c0, 0x1f7c8,
0x1f840, 0x1f84c,
0x1fa84, 0x1fa8c,
0x1fac0, 0x1fac0,
0x1fae0, 0x1fae0,
0x1fb00, 0x1fb84,
0x1fbc0, 0x1fbc8,
0x1fc40, 0x1fc4c,
0x1fe84, 0x1fe8c,
0x1fec0, 0x1fec0,
0x1fee0, 0x1fee0,
0x1ff00, 0x1ff84,
0x1ffc0, 0x1ffc8,
0x20000, 0x2002c,
0x20100, 0x2013c,
0x20190, 0x201c8,
0x20200, 0x20318,
0x20400, 0x20528,
0x20540, 0x20614,
0x21000, 0x21040,
0x2104c, 0x21060,
0x210c0, 0x210ec,
0x21200, 0x21268,
0x21270, 0x21284,
0x212fc, 0x21388,
0x21400, 0x21404,
0x21500, 0x21518,
0x2152c, 0x2153c,
0x21550, 0x21554,
0x21600, 0x21600,
0x21608, 0x21628,
0x21630, 0x2163c,
0x21700, 0x2171c,
0x21780, 0x2178c,
0x21800, 0x21c38,
0x21c80, 0x21d7c,
0x21e00, 0x21e04,
0x22000, 0x2202c,
0x22100, 0x2213c,
0x22190, 0x221c8,
0x22200, 0x22318,
0x22400, 0x22528,
0x22540, 0x22614,
0x23000, 0x23040,
0x2304c, 0x23060,
0x230c0, 0x230ec,
0x23200, 0x23268,
0x23270, 0x23284,
0x232fc, 0x23388,
0x23400, 0x23404,
0x23500, 0x23518,
0x2352c, 0x2353c,
0x23550, 0x23554,
0x23600, 0x23600,
0x23608, 0x23628,
0x23630, 0x2363c,
0x23700, 0x2371c,
0x23780, 0x2378c,
0x23800, 0x23c38,
0x23c80, 0x23d7c,
0x23e00, 0x23e04,
0x24000, 0x2402c,
0x24100, 0x2413c,
0x24190, 0x241c8,
0x24200, 0x24318,
0x24400, 0x24528,
0x24540, 0x24614,
0x25000, 0x25040,
0x2504c, 0x25060,
0x250c0, 0x250ec,
0x25200, 0x25268,
0x25270, 0x25284,
0x252fc, 0x25388,
0x25400, 0x25404,
0x25500, 0x25518,
0x2552c, 0x2553c,
0x25550, 0x25554,
0x25600, 0x25600,
0x25608, 0x25628,
0x25630, 0x2563c,
0x25700, 0x2571c,
0x25780, 0x2578c,
0x25800, 0x25c38,
0x25c80, 0x25d7c,
0x25e00, 0x25e04,
0x26000, 0x2602c,
0x26100, 0x2613c,
0x26190, 0x261c8,
0x26200, 0x26318,
0x26400, 0x26528,
0x26540, 0x26614,
0x27000, 0x27040,
0x2704c, 0x27060,
0x270c0, 0x270ec,
0x27200, 0x27268,
0x27270, 0x27284,
0x272fc, 0x27388,
0x27400, 0x27404,
0x27500, 0x27518,
0x2752c, 0x2753c,
0x27550, 0x27554,
0x27600, 0x27600,
0x27608, 0x27628,
0x27630, 0x2763c,
0x27700, 0x2771c,
0x27780, 0x2778c,
0x27800, 0x27c38,
0x27c80, 0x27d7c,
0x27e00, 0x27e04
};
static const unsigned int t5_reg_ranges[] = {
0x1008, 0x1148,
0x1180, 0x11b4,
0x11fc, 0x123c,
0x1280, 0x173c,
0x1800, 0x18fc,
0x3000, 0x3028,
0x3060, 0x30d8,
0x30e0, 0x30fc,
0x3140, 0x357c,
0x35a8, 0x35cc,
0x35ec, 0x35ec,
0x3600, 0x5624,
0x56cc, 0x575c,
0x580c, 0x5814,
0x5890, 0x58bc,
0x5940, 0x59dc,
0x59fc, 0x5a18,
0x5a60, 0x5a9c,
0x5b9c, 0x5bfc,
0x6000, 0x6040,
0x6058, 0x614c,
0x7700, 0x7798,
0x77c0, 0x78fc,
0x7b00, 0x7c54,
0x7d00, 0x7efc,
0x8dc0, 0x8de0,
0x8df8, 0x8e84,
0x8ea0, 0x8f84,
0x8fc0, 0x90f8,
0x9400, 0x9470,
0x9600, 0x96f4,
0x9800, 0x9808,
0x9820, 0x983c,
0x9850, 0x9864,
0x9c00, 0x9c6c,
0x9c80, 0x9cec,
0x9d00, 0x9d6c,
0x9d80, 0x9dec,
0x9e00, 0x9e6c,
0x9e80, 0x9eec,
0x9f00, 0x9f6c,
0x9f80, 0xa020,
0xd004, 0xd03c,
0xdfc0, 0xdfe0,
0xe000, 0x11088,
0x1109c, 0x11110,
0x11118, 0x1117c,
0x11190, 0x11204,
0x19040, 0x1906c,
0x19078, 0x19080,
0x1908c, 0x19124,
0x19150, 0x191b0,
0x191d0, 0x191e8,
0x19238, 0x19290,
0x193f8, 0x19474,
0x19490, 0x194cc,
0x194f0, 0x194f8,
0x19c00, 0x19c60,
0x19c94, 0x19e10,
0x19e50, 0x19f34,
0x19f40, 0x19f50,
0x19f90, 0x19fe4,
0x1a000, 0x1a06c,
0x1a0b0, 0x1a120,
0x1a128, 0x1a138,
0x1a190, 0x1a1c4,
0x1a1fc, 0x1a1fc,
0x1e008, 0x1e00c,
0x1e040, 0x1e04c,
0x1e284, 0x1e290,
0x1e2c0, 0x1e2c0,
0x1e2e0, 0x1e2e0,
0x1e300, 0x1e384,
0x1e3c0, 0x1e3c8,
0x1e408, 0x1e40c,
0x1e440, 0x1e44c,
0x1e684, 0x1e690,
0x1e6c0, 0x1e6c0,
0x1e6e0, 0x1e6e0,
0x1e700, 0x1e784,
0x1e7c0, 0x1e7c8,
0x1e808, 0x1e80c,
0x1e840, 0x1e84c,
0x1ea84, 0x1ea90,
0x1eac0, 0x1eac0,
0x1eae0, 0x1eae0,
0x1eb00, 0x1eb84,
0x1ebc0, 0x1ebc8,
0x1ec08, 0x1ec0c,
0x1ec40, 0x1ec4c,
0x1ee84, 0x1ee90,
0x1eec0, 0x1eec0,
0x1eee0, 0x1eee0,
0x1ef00, 0x1ef84,
0x1efc0, 0x1efc8,
0x1f008, 0x1f00c,
0x1f040, 0x1f04c,
0x1f284, 0x1f290,
0x1f2c0, 0x1f2c0,
0x1f2e0, 0x1f2e0,
0x1f300, 0x1f384,
0x1f3c0, 0x1f3c8,
0x1f408, 0x1f40c,
0x1f440, 0x1f44c,
0x1f684, 0x1f690,
0x1f6c0, 0x1f6c0,
0x1f6e0, 0x1f6e0,
0x1f700, 0x1f784,
0x1f7c0, 0x1f7c8,
0x1f808, 0x1f80c,
0x1f840, 0x1f84c,
0x1fa84, 0x1fa90,
0x1fac0, 0x1fac0,
0x1fae0, 0x1fae0,
0x1fb00, 0x1fb84,
0x1fbc0, 0x1fbc8,
0x1fc08, 0x1fc0c,
0x1fc40, 0x1fc4c,
0x1fe84, 0x1fe90,
0x1fec0, 0x1fec0,
0x1fee0, 0x1fee0,
0x1ff00, 0x1ff84,
0x1ffc0, 0x1ffc8,
0x30000, 0x30030,
0x30100, 0x30144,
0x30190, 0x301d0,
0x30200, 0x30318,
0x30400, 0x3052c,
0x30540, 0x3061c,
0x30800, 0x30834,
0x308c0, 0x30908,
0x30910, 0x309ac,
0x30a00, 0x30a04,
0x30a0c, 0x30a2c,
0x30a44, 0x30a50,
0x30a74, 0x30c24,
0x30d08, 0x30d14,
0x30d1c, 0x30d20,
0x30d3c, 0x30d50,
0x31200, 0x3120c,
0x31220, 0x31220,
0x31240, 0x31240,
0x31600, 0x31600,
0x31608, 0x3160c,
0x31a00, 0x31a1c,
0x31e04, 0x31e20,
0x31e38, 0x31e3c,
0x31e80, 0x31e80,
0x31e88, 0x31ea8,
0x31eb0, 0x31eb4,
0x31ec8, 0x31ed4,
0x31fb8, 0x32004,
0x32208, 0x3223c,
0x32600, 0x32630,
0x32a00, 0x32abc,
0x32b00, 0x32b70,
0x33000, 0x33048,
0x33060, 0x3309c,
0x330f0, 0x33148,
0x33160, 0x3319c,
0x331f0, 0x332e4,
0x332f8, 0x333e4,
0x333f8, 0x33448,
0x33460, 0x3349c,
0x334f0, 0x33548,
0x33560, 0x3359c,
0x335f0, 0x336e4,
0x336f8, 0x337e4,
0x337f8, 0x337fc,
0x33814, 0x33814,
0x3382c, 0x3382c,
0x33880, 0x3388c,
0x338e8, 0x338ec,
0x33900, 0x33948,
0x33960, 0x3399c,
0x339f0, 0x33ae4,
0x33af8, 0x33b10,
0x33b28, 0x33b28,
0x33b3c, 0x33b50,
0x33bf0, 0x33c10,
0x33c28, 0x33c28,
0x33c3c, 0x33c50,
0x33cf0, 0x33cfc,
0x34000, 0x34030,
0x34100, 0x34144,
0x34190, 0x341d0,
0x34200, 0x34318,
0x34400, 0x3452c,
0x34540, 0x3461c,
0x34800, 0x34834,
0x348c0, 0x34908,
0x34910, 0x349ac,
0x34a00, 0x34a04,
0x34a0c, 0x34a2c,
0x34a44, 0x34a50,
0x34a74, 0x34c24,
0x34d08, 0x34d14,
0x34d1c, 0x34d20,
0x34d3c, 0x34d50,
0x35200, 0x3520c,
0x35220, 0x35220,
0x35240, 0x35240,
0x35600, 0x35600,
0x35608, 0x3560c,
0x35a00, 0x35a1c,
0x35e04, 0x35e20,
0x35e38, 0x35e3c,
0x35e80, 0x35e80,
0x35e88, 0x35ea8,
0x35eb0, 0x35eb4,
0x35ec8, 0x35ed4,
0x35fb8, 0x36004,
0x36208, 0x3623c,
0x36600, 0x36630,
0x36a00, 0x36abc,
0x36b00, 0x36b70,
0x37000, 0x37048,
0x37060, 0x3709c,
0x370f0, 0x37148,
0x37160, 0x3719c,
0x371f0, 0x372e4,
0x372f8, 0x373e4,
0x373f8, 0x37448,
0x37460, 0x3749c,
0x374f0, 0x37548,
0x37560, 0x3759c,
0x375f0, 0x376e4,
0x376f8, 0x377e4,
0x377f8, 0x377fc,
0x37814, 0x37814,
0x3782c, 0x3782c,
0x37880, 0x3788c,
0x378e8, 0x378ec,
0x37900, 0x37948,
0x37960, 0x3799c,
0x379f0, 0x37ae4,
0x37af8, 0x37b10,
0x37b28, 0x37b28,
0x37b3c, 0x37b50,
0x37bf0, 0x37c10,
0x37c28, 0x37c28,
0x37c3c, 0x37c50,
0x37cf0, 0x37cfc,
0x38000, 0x38030,
0x38100, 0x38144,
0x38190, 0x381d0,
0x38200, 0x38318,
0x38400, 0x3852c,
0x38540, 0x3861c,
0x38800, 0x38834,
0x388c0, 0x38908,
0x38910, 0x389ac,
0x38a00, 0x38a04,
0x38a0c, 0x38a2c,
0x38a44, 0x38a50,
0x38a74, 0x38c24,
0x38d08, 0x38d14,
0x38d1c, 0x38d20,
0x38d3c, 0x38d50,
0x39200, 0x3920c,
0x39220, 0x39220,
0x39240, 0x39240,
0x39600, 0x39600,
0x39608, 0x3960c,
0x39a00, 0x39a1c,
0x39e04, 0x39e20,
0x39e38, 0x39e3c,
0x39e80, 0x39e80,
0x39e88, 0x39ea8,
0x39eb0, 0x39eb4,
0x39ec8, 0x39ed4,
0x39fb8, 0x3a004,
0x3a208, 0x3a23c,
0x3a600, 0x3a630,
0x3aa00, 0x3aabc,
0x3ab00, 0x3ab70,
0x3b000, 0x3b048,
0x3b060, 0x3b09c,
0x3b0f0, 0x3b148,
0x3b160, 0x3b19c,
0x3b1f0, 0x3b2e4,
0x3b2f8, 0x3b3e4,
0x3b3f8, 0x3b448,
0x3b460, 0x3b49c,
0x3b4f0, 0x3b548,
0x3b560, 0x3b59c,
0x3b5f0, 0x3b6e4,
0x3b6f8, 0x3b7e4,
0x3b7f8, 0x3b7fc,
0x3b814, 0x3b814,
0x3b82c, 0x3b82c,
0x3b880, 0x3b88c,
0x3b8e8, 0x3b8ec,
0x3b900, 0x3b948,
0x3b960, 0x3b99c,
0x3b9f0, 0x3bae4,
0x3baf8, 0x3bb10,
0x3bb28, 0x3bb28,
0x3bb3c, 0x3bb50,
0x3bbf0, 0x3bc10,
0x3bc28, 0x3bc28,
0x3bc3c, 0x3bc50,
0x3bcf0, 0x3bcfc,
0x3c000, 0x3c030,
0x3c100, 0x3c144,
0x3c190, 0x3c1d0,
0x3c200, 0x3c318,
0x3c400, 0x3c52c,
0x3c540, 0x3c61c,
0x3c800, 0x3c834,
0x3c8c0, 0x3c908,
0x3c910, 0x3c9ac,
0x3ca00, 0x3ca04,
0x3ca0c, 0x3ca2c,
0x3ca44, 0x3ca50,
0x3ca74, 0x3cc24,
0x3cd08, 0x3cd14,
0x3cd1c, 0x3cd20,
0x3cd3c, 0x3cd50,
0x3d200, 0x3d20c,
0x3d220, 0x3d220,
0x3d240, 0x3d240,
0x3d600, 0x3d600,
0x3d608, 0x3d60c,
0x3da00, 0x3da1c,
0x3de04, 0x3de20,
0x3de38, 0x3de3c,
0x3de80, 0x3de80,
0x3de88, 0x3dea8,
0x3deb0, 0x3deb4,
0x3dec8, 0x3ded4,
0x3dfb8, 0x3e004,
0x3e208, 0x3e23c,
0x3e600, 0x3e630,
0x3ea00, 0x3eabc,
0x3eb00, 0x3eb70,
0x3f000, 0x3f048,
0x3f060, 0x3f09c,
0x3f0f0, 0x3f148,
0x3f160, 0x3f19c,
0x3f1f0, 0x3f2e4,
0x3f2f8, 0x3f3e4,
0x3f3f8, 0x3f448,
0x3f460, 0x3f49c,
0x3f4f0, 0x3f548,
0x3f560, 0x3f59c,
0x3f5f0, 0x3f6e4,
0x3f6f8, 0x3f7e4,
0x3f7f8, 0x3f7fc,
0x3f814, 0x3f814,
0x3f82c, 0x3f82c,
0x3f880, 0x3f88c,
0x3f8e8, 0x3f8ec,
0x3f900, 0x3f948,
0x3f960, 0x3f99c,
0x3f9f0, 0x3fae4,
0x3faf8, 0x3fb10,
0x3fb28, 0x3fb28,
0x3fb3c, 0x3fb50,
0x3fbf0, 0x3fc10,
0x3fc28, 0x3fc28,
0x3fc3c, 0x3fc50,
0x3fcf0, 0x3fcfc,
0x40000, 0x4000c,
0x40040, 0x40068,
0x40080, 0x40144,
0x40180, 0x4018c,
0x40200, 0x40298,
0x402ac, 0x4033c,
0x403f8, 0x403fc,
0x41304, 0x413c4,
0x41400, 0x4141c,
0x41480, 0x414d0,
0x44000, 0x44078,
0x440c0, 0x44278,
0x442c0, 0x44478,
0x444c0, 0x44678,
0x446c0, 0x44878,
0x448c0, 0x449fc,
0x45000, 0x45068,
0x45080, 0x45084,
0x450a0, 0x450b0,
0x45200, 0x45268,
0x45280, 0x45284,
0x452a0, 0x452b0,
0x460c0, 0x460e4,
0x47000, 0x4708c,
0x47200, 0x47250,
0x47400, 0x47420,
0x47600, 0x47618,
0x47800, 0x47814,
0x48000, 0x4800c,
0x48040, 0x48068,
0x48080, 0x48144,
0x48180, 0x4818c,
0x48200, 0x48298,
0x482ac, 0x4833c,
0x483f8, 0x483fc,
0x49304, 0x493c4,
0x49400, 0x4941c,
0x49480, 0x494d0,
0x4c000, 0x4c078,
0x4c0c0, 0x4c278,
0x4c2c0, 0x4c478,
0x4c4c0, 0x4c678,
0x4c6c0, 0x4c878,
0x4c8c0, 0x4c9fc,
0x4d000, 0x4d068,
0x4d080, 0x4d084,
0x4d0a0, 0x4d0b0,
0x4d200, 0x4d268,
0x4d280, 0x4d284,
0x4d2a0, 0x4d2b0,
0x4e0c0, 0x4e0e4,
0x4f000, 0x4f08c,
0x4f200, 0x4f250,
0x4f400, 0x4f420,
0x4f600, 0x4f618,
0x4f800, 0x4f814,
0x50000, 0x500cc,
0x50400, 0x50400,
0x50800, 0x508cc,
0x50c00, 0x50c00,
0x51000, 0x5101c,
0x51300, 0x51308,
};
int i;
struct adapter *ap = netdev2adap(dev);
static const unsigned int *reg_ranges;
int arr_size = 0, buf_size = 0;
if (is_t4(ap->params.chip)) {
reg_ranges = &t4_reg_ranges[0];
arr_size = ARRAY_SIZE(t4_reg_ranges);
buf_size = T4_REGMAP_SIZE;
} else {
reg_ranges = &t5_reg_ranges[0];
arr_size = ARRAY_SIZE(t5_reg_ranges);
buf_size = T5_REGMAP_SIZE;
}
regs->version = mk_adap_vers(ap);
memset(buf, 0, buf_size);
for (i = 0; i < arr_size; i += 2)
reg_block_dump(ap, buf, reg_ranges[i], reg_ranges[i + 1]);
}
static int restart_autoneg(struct net_device *dev)
{
struct port_info *p = netdev_priv(dev);
if (!netif_running(dev))
return -EAGAIN;
if (p->link_cfg.autoneg != AUTONEG_ENABLE)
return -EINVAL;
t4_restart_aneg(p->adapter, p->adapter->fn, p->tx_chan);
return 0;
}
static int identify_port(struct net_device *dev,
enum ethtool_phys_id_state state)
{
unsigned int val;
struct adapter *adap = netdev2adap(dev);
if (state == ETHTOOL_ID_ACTIVE)
val = 0xffff;
else if (state == ETHTOOL_ID_INACTIVE)
val = 0;
else
return -EINVAL;
return t4_identify_port(adap, adap->fn, netdev2pinfo(dev)->viid, val);
}
static unsigned int from_fw_linkcaps(unsigned int type, unsigned int caps)
{
unsigned int v = 0;
if (type == FW_PORT_TYPE_BT_SGMII || type == FW_PORT_TYPE_BT_XFI ||
type == FW_PORT_TYPE_BT_XAUI) {
v |= SUPPORTED_TP;
if (caps & FW_PORT_CAP_SPEED_100M)
v |= SUPPORTED_100baseT_Full;
if (caps & FW_PORT_CAP_SPEED_1G)
v |= SUPPORTED_1000baseT_Full;
if (caps & FW_PORT_CAP_SPEED_10G)
v |= SUPPORTED_10000baseT_Full;
} else if (type == FW_PORT_TYPE_KX4 || type == FW_PORT_TYPE_KX) {
v |= SUPPORTED_Backplane;
if (caps & FW_PORT_CAP_SPEED_1G)
v |= SUPPORTED_1000baseKX_Full;
if (caps & FW_PORT_CAP_SPEED_10G)
v |= SUPPORTED_10000baseKX4_Full;
} else if (type == FW_PORT_TYPE_KR)
v |= SUPPORTED_Backplane | SUPPORTED_10000baseKR_Full;
else if (type == FW_PORT_TYPE_BP_AP)
v |= SUPPORTED_Backplane | SUPPORTED_10000baseR_FEC |
SUPPORTED_10000baseKR_Full | SUPPORTED_1000baseKX_Full;
else if (type == FW_PORT_TYPE_BP4_AP)
v |= SUPPORTED_Backplane | SUPPORTED_10000baseR_FEC |
SUPPORTED_10000baseKR_Full | SUPPORTED_1000baseKX_Full |
SUPPORTED_10000baseKX4_Full;
else if (type == FW_PORT_TYPE_FIBER_XFI ||
type == FW_PORT_TYPE_FIBER_XAUI || type == FW_PORT_TYPE_SFP)
v |= SUPPORTED_FIBRE;
else if (type == FW_PORT_TYPE_BP40_BA)
v |= SUPPORTED_40000baseSR4_Full;
if (caps & FW_PORT_CAP_ANEG)
v |= SUPPORTED_Autoneg;
return v;
}
static unsigned int to_fw_linkcaps(unsigned int caps)
{
unsigned int v = 0;
if (caps & ADVERTISED_100baseT_Full)
v |= FW_PORT_CAP_SPEED_100M;
if (caps & ADVERTISED_1000baseT_Full)
v |= FW_PORT_CAP_SPEED_1G;
if (caps & ADVERTISED_10000baseT_Full)
v |= FW_PORT_CAP_SPEED_10G;
if (caps & ADVERTISED_40000baseSR4_Full)
v |= FW_PORT_CAP_SPEED_40G;
return v;
}
static int get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{
const struct port_info *p = netdev_priv(dev);
if (p->port_type == FW_PORT_TYPE_BT_SGMII ||
p->port_type == FW_PORT_TYPE_BT_XFI ||
p->port_type == FW_PORT_TYPE_BT_XAUI)
cmd->port = PORT_TP;
else if (p->port_type == FW_PORT_TYPE_FIBER_XFI ||
p->port_type == FW_PORT_TYPE_FIBER_XAUI)
cmd->port = PORT_FIBRE;
else if (p->port_type == FW_PORT_TYPE_SFP ||
p->port_type == FW_PORT_TYPE_QSFP_10G ||
p->port_type == FW_PORT_TYPE_QSFP) {
if (p->mod_type == FW_PORT_MOD_TYPE_LR ||
p->mod_type == FW_PORT_MOD_TYPE_SR ||
p->mod_type == FW_PORT_MOD_TYPE_ER ||
p->mod_type == FW_PORT_MOD_TYPE_LRM)
cmd->port = PORT_FIBRE;
else if (p->mod_type == FW_PORT_MOD_TYPE_TWINAX_PASSIVE ||
p->mod_type == FW_PORT_MOD_TYPE_TWINAX_ACTIVE)
cmd->port = PORT_DA;
else
cmd->port = PORT_OTHER;
} else
cmd->port = PORT_OTHER;
if (p->mdio_addr >= 0) {
cmd->phy_address = p->mdio_addr;
cmd->transceiver = XCVR_EXTERNAL;
cmd->mdio_support = p->port_type == FW_PORT_TYPE_BT_SGMII ?
MDIO_SUPPORTS_C22 : MDIO_SUPPORTS_C45;
} else {
cmd->phy_address = 0; /* not really, but no better option */
cmd->transceiver = XCVR_INTERNAL;
cmd->mdio_support = 0;
}
cmd->supported = from_fw_linkcaps(p->port_type, p->link_cfg.supported);
cmd->advertising = from_fw_linkcaps(p->port_type,
p->link_cfg.advertising);
ethtool_cmd_speed_set(cmd,
netif_carrier_ok(dev) ? p->link_cfg.speed : 0);
cmd->duplex = DUPLEX_FULL;
cmd->autoneg = p->link_cfg.autoneg;
cmd->maxtxpkt = 0;
cmd->maxrxpkt = 0;
return 0;
}
static unsigned int speed_to_caps(int speed)
{
if (speed == 100)
return FW_PORT_CAP_SPEED_100M;
if (speed == 1000)
return FW_PORT_CAP_SPEED_1G;
if (speed == 10000)
return FW_PORT_CAP_SPEED_10G;
if (speed == 40000)
return FW_PORT_CAP_SPEED_40G;
return 0;
}
static int set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{
unsigned int cap;
struct port_info *p = netdev_priv(dev);
struct link_config *lc = &p->link_cfg;
u32 speed = ethtool_cmd_speed(cmd);
if (cmd->duplex != DUPLEX_FULL) /* only full-duplex supported */
return -EINVAL;
if (!(lc->supported & FW_PORT_CAP_ANEG)) {
/*
* PHY offers a single speed. See if that's what's
* being requested.
*/
if (cmd->autoneg == AUTONEG_DISABLE &&
(lc->supported & speed_to_caps(speed)))
return 0;
return -EINVAL;
}
if (cmd->autoneg == AUTONEG_DISABLE) {
cap = speed_to_caps(speed);
if (!(lc->supported & cap) ||
(speed == 1000) ||
(speed == 10000) ||
(speed == 40000))
return -EINVAL;
lc->requested_speed = cap;
lc->advertising = 0;
} else {
cap = to_fw_linkcaps(cmd->advertising);
if (!(lc->supported & cap))
return -EINVAL;
lc->requested_speed = 0;
lc->advertising = cap | FW_PORT_CAP_ANEG;
}
lc->autoneg = cmd->autoneg;
if (netif_running(dev))
return t4_link_start(p->adapter, p->adapter->fn, p->tx_chan,
lc);
return 0;
}
static void get_pauseparam(struct net_device *dev,
struct ethtool_pauseparam *epause)
{
struct port_info *p = netdev_priv(dev);
epause->autoneg = (p->link_cfg.requested_fc & PAUSE_AUTONEG) != 0;
epause->rx_pause = (p->link_cfg.fc & PAUSE_RX) != 0;
epause->tx_pause = (p->link_cfg.fc & PAUSE_TX) != 0;
}
static int set_pauseparam(struct net_device *dev,
struct ethtool_pauseparam *epause)
{
struct port_info *p = netdev_priv(dev);
struct link_config *lc = &p->link_cfg;
if (epause->autoneg == AUTONEG_DISABLE)
lc->requested_fc = 0;
else if (lc->supported & FW_PORT_CAP_ANEG)
lc->requested_fc = PAUSE_AUTONEG;
else
return -EINVAL;
if (epause->rx_pause)
lc->requested_fc |= PAUSE_RX;
if (epause->tx_pause)
lc->requested_fc |= PAUSE_TX;
if (netif_running(dev))
return t4_link_start(p->adapter, p->adapter->fn, p->tx_chan,
lc);
return 0;
}
static void get_sge_param(struct net_device *dev, struct ethtool_ringparam *e)
{
const struct port_info *pi = netdev_priv(dev);
const struct sge *s = &pi->adapter->sge;
e->rx_max_pending = MAX_RX_BUFFERS;
e->rx_mini_max_pending = MAX_RSPQ_ENTRIES;
e->rx_jumbo_max_pending = 0;
e->tx_max_pending = MAX_TXQ_ENTRIES;
e->rx_pending = s->ethrxq[pi->first_qset].fl.size - 8;
e->rx_mini_pending = s->ethrxq[pi->first_qset].rspq.size;
e->rx_jumbo_pending = 0;
e->tx_pending = s->ethtxq[pi->first_qset].q.size;
}
static int set_sge_param(struct net_device *dev, struct ethtool_ringparam *e)
{
int i;
const struct port_info *pi = netdev_priv(dev);
struct adapter *adapter = pi->adapter;
struct sge *s = &adapter->sge;
if (e->rx_pending > MAX_RX_BUFFERS || e->rx_jumbo_pending ||
e->tx_pending > MAX_TXQ_ENTRIES ||
e->rx_mini_pending > MAX_RSPQ_ENTRIES ||
e->rx_mini_pending < MIN_RSPQ_ENTRIES ||
e->rx_pending < MIN_FL_ENTRIES || e->tx_pending < MIN_TXQ_ENTRIES)
return -EINVAL;
if (adapter->flags & FULL_INIT_DONE)
return -EBUSY;
for (i = 0; i < pi->nqsets; ++i) {
s->ethtxq[pi->first_qset + i].q.size = e->tx_pending;
s->ethrxq[pi->first_qset + i].fl.size = e->rx_pending + 8;
s->ethrxq[pi->first_qset + i].rspq.size = e->rx_mini_pending;
}
return 0;
}
static int closest_timer(const struct sge *s, int time)
{
int i, delta, match = 0, min_delta = INT_MAX;
for (i = 0; i < ARRAY_SIZE(s->timer_val); i++) {
delta = time - s->timer_val[i];
if (delta < 0)
delta = -delta;
if (delta < min_delta) {
min_delta = delta;
match = i;
}
}
return match;
}
static int closest_thres(const struct sge *s, int thres)
{
int i, delta, match = 0, min_delta = INT_MAX;
for (i = 0; i < ARRAY_SIZE(s->counter_val); i++) {
delta = thres - s->counter_val[i];
if (delta < 0)
delta = -delta;
if (delta < min_delta) {
min_delta = delta;
match = i;
}
}
return match;
}
/*
* Return a queue's interrupt hold-off time in us. 0 means no timer.
*/
static unsigned int qtimer_val(const struct adapter *adap,
const struct sge_rspq *q)
{
unsigned int idx = q->intr_params >> 1;
return idx < SGE_NTIMERS ? adap->sge.timer_val[idx] : 0;
}
/**
* set_rspq_intr_params - set a queue's interrupt holdoff parameters
* @q: the Rx queue
* @us: the hold-off time in us, or 0 to disable timer
* @cnt: the hold-off packet count, or 0 to disable counter
*
* Sets an Rx queue's interrupt hold-off time and packet count. At least
* one of the two needs to be enabled for the queue to generate interrupts.
*/
static int set_rspq_intr_params(struct sge_rspq *q,
unsigned int us, unsigned int cnt)
{
struct adapter *adap = q->adap;
if ((us | cnt) == 0)
cnt = 1;
if (cnt) {
int err;
u32 v, new_idx;
new_idx = closest_thres(&adap->sge, cnt);
if (q->desc && q->pktcnt_idx != new_idx) {
/* the queue has already been created, update it */
v = FW_PARAMS_MNEM(FW_PARAMS_MNEM_DMAQ) |
FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DMAQ_IQ_INTCNTTHRESH) |
FW_PARAMS_PARAM_YZ(q->cntxt_id);
err = t4_set_params(adap, adap->fn, adap->fn, 0, 1, &v,
&new_idx);
if (err)
return err;
}
q->pktcnt_idx = new_idx;
}
us = us == 0 ? 6 : closest_timer(&adap->sge, us);
q->intr_params = QINTR_TIMER_IDX(us) | (cnt > 0 ? QINTR_CNT_EN : 0);
return 0;
}
/**
* set_rx_intr_params - set a net devices's RX interrupt holdoff paramete!
* @dev: the network device
* @us: the hold-off time in us, or 0 to disable timer
* @cnt: the hold-off packet count, or 0 to disable counter
*
* Set the RX interrupt hold-off parameters for a network device.
*/
static int set_rx_intr_params(struct net_device *dev,
unsigned int us, unsigned int cnt)
{
int i, err;
struct port_info *pi = netdev_priv(dev);
struct adapter *adap = pi->adapter;
struct sge_eth_rxq *q = &adap->sge.ethrxq[pi->first_qset];
for (i = 0; i < pi->nqsets; i++, q++) {
err = set_rspq_intr_params(&q->rspq, us, cnt);
if (err)
return err;
}
return 0;
}
static int set_coalesce(struct net_device *dev, struct ethtool_coalesce *c)
{
return set_rx_intr_params(dev, c->rx_coalesce_usecs,
c->rx_max_coalesced_frames);
}
static int get_coalesce(struct net_device *dev, struct ethtool_coalesce *c)
{
const struct port_info *pi = netdev_priv(dev);
const struct adapter *adap = pi->adapter;
const struct sge_rspq *rq = &adap->sge.ethrxq[pi->first_qset].rspq;
c->rx_coalesce_usecs = qtimer_val(adap, rq);
c->rx_max_coalesced_frames = (rq->intr_params & QINTR_CNT_EN) ?
adap->sge.counter_val[rq->pktcnt_idx] : 0;
return 0;
}
/**
* eeprom_ptov - translate a physical EEPROM address to virtual
* @phys_addr: the physical EEPROM address
* @fn: the PCI function number
* @sz: size of function-specific area
*
* Translate a physical EEPROM address to virtual. The first 1K is
* accessed through virtual addresses starting at 31K, the rest is
* accessed through virtual addresses starting at 0.
*
* The mapping is as follows:
* [0..1K) -> [31K..32K)
* [1K..1K+A) -> [31K-A..31K)
* [1K+A..ES) -> [0..ES-A-1K)
*
* where A = @fn * @sz, and ES = EEPROM size.
*/
static int eeprom_ptov(unsigned int phys_addr, unsigned int fn, unsigned int sz)
{
fn *= sz;
if (phys_addr < 1024)
return phys_addr + (31 << 10);
if (phys_addr < 1024 + fn)
return 31744 - fn + phys_addr - 1024;
if (phys_addr < EEPROMSIZE)
return phys_addr - 1024 - fn;
return -EINVAL;
}
/*
* The next two routines implement eeprom read/write from physical addresses.
*/
static int eeprom_rd_phys(struct adapter *adap, unsigned int phys_addr, u32 *v)
{
int vaddr = eeprom_ptov(phys_addr, adap->fn, EEPROMPFSIZE);
if (vaddr >= 0)
vaddr = pci_read_vpd(adap->pdev, vaddr, sizeof(u32), v);
return vaddr < 0 ? vaddr : 0;
}
static int eeprom_wr_phys(struct adapter *adap, unsigned int phys_addr, u32 v)
{
int vaddr = eeprom_ptov(phys_addr, adap->fn, EEPROMPFSIZE);
if (vaddr >= 0)
vaddr = pci_write_vpd(adap->pdev, vaddr, sizeof(u32), &v);
return vaddr < 0 ? vaddr : 0;
}
#define EEPROM_MAGIC 0x38E2F10C
static int get_eeprom(struct net_device *dev, struct ethtool_eeprom *e,
u8 *data)
{
int i, err = 0;
struct adapter *adapter = netdev2adap(dev);
u8 *buf = kmalloc(EEPROMSIZE, GFP_KERNEL);
if (!buf)
return -ENOMEM;
e->magic = EEPROM_MAGIC;
for (i = e->offset & ~3; !err && i < e->offset + e->len; i += 4)
err = eeprom_rd_phys(adapter, i, (u32 *)&buf[i]);
if (!err)
memcpy(data, buf + e->offset, e->len);
kfree(buf);
return err;
}
static int set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
u8 *data)
{
u8 *buf;
int err = 0;
u32 aligned_offset, aligned_len, *p;
struct adapter *adapter = netdev2adap(dev);
if (eeprom->magic != EEPROM_MAGIC)
return -EINVAL;
aligned_offset = eeprom->offset & ~3;
aligned_len = (eeprom->len + (eeprom->offset & 3) + 3) & ~3;
if (adapter->fn > 0) {
u32 start = 1024 + adapter->fn * EEPROMPFSIZE;
if (aligned_offset < start ||
aligned_offset + aligned_len > start + EEPROMPFSIZE)
return -EPERM;
}
if (aligned_offset != eeprom->offset || aligned_len != eeprom->len) {
/*
* RMW possibly needed for first or last words.
*/
buf = kmalloc(aligned_len, GFP_KERNEL);
if (!buf)
return -ENOMEM;
err = eeprom_rd_phys(adapter, aligned_offset, (u32 *)buf);
if (!err && aligned_len > 4)
err = eeprom_rd_phys(adapter,
aligned_offset + aligned_len - 4,
(u32 *)&buf[aligned_len - 4]);
if (err)
goto out;
memcpy(buf + (eeprom->offset & 3), data, eeprom->len);
} else
buf = data;
err = t4_seeprom_wp(adapter, false);
if (err)
goto out;
for (p = (u32 *)buf; !err && aligned_len; aligned_len -= 4, p++) {
err = eeprom_wr_phys(adapter, aligned_offset, *p);
aligned_offset += 4;
}
if (!err)
err = t4_seeprom_wp(adapter, true);
out:
if (buf != data)
kfree(buf);
return err;
}
static int set_flash(struct net_device *netdev, struct ethtool_flash *ef)
{
int ret;
const struct firmware *fw;
struct adapter *adap = netdev2adap(netdev);
ef->data[sizeof(ef->data) - 1] = '\0';
ret = request_firmware(&fw, ef->data, adap->pdev_dev);
if (ret < 0)
return ret;
ret = t4_load_fw(adap, fw->data, fw->size);
release_firmware(fw);
if (!ret)
dev_info(adap->pdev_dev, "loaded firmware %s\n", ef->data);
return ret;
}
#define WOL_SUPPORTED (WAKE_BCAST | WAKE_MAGIC)
#define BCAST_CRC 0xa0ccc1a6
static void get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
{
wol->supported = WAKE_BCAST | WAKE_MAGIC;
wol->wolopts = netdev2adap(dev)->wol;
memset(&wol->sopass, 0, sizeof(wol->sopass));
}
static int set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
{
int err = 0;
struct port_info *pi = netdev_priv(dev);
if (wol->wolopts & ~WOL_SUPPORTED)
return -EINVAL;
t4_wol_magic_enable(pi->adapter, pi->tx_chan,
(wol->wolopts & WAKE_MAGIC) ? dev->dev_addr : NULL);
if (wol->wolopts & WAKE_BCAST) {
err = t4_wol_pat_enable(pi->adapter, pi->tx_chan, 0xfe, ~0ULL,
~0ULL, 0, false);
if (!err)
err = t4_wol_pat_enable(pi->adapter, pi->tx_chan, 1,
~6ULL, ~0ULL, BCAST_CRC, true);
} else
t4_wol_pat_enable(pi->adapter, pi->tx_chan, 0, 0, 0, 0, false);
return err;
}
static int cxgb_set_features(struct net_device *dev, netdev_features_t features)
{
const struct port_info *pi = netdev_priv(dev);
netdev_features_t changed = dev->features ^ features;
int err;
if (!(changed & NETIF_F_HW_VLAN_CTAG_RX))
return 0;
err = t4_set_rxmode(pi->adapter, pi->adapter->fn, pi->viid, -1,
-1, -1, -1,
!!(features & NETIF_F_HW_VLAN_CTAG_RX), true);
if (unlikely(err))
dev->features = features ^ NETIF_F_HW_VLAN_CTAG_RX;
return err;
}
static u32 get_rss_table_size(struct net_device *dev)
{
const struct port_info *pi = netdev_priv(dev);
return pi->rss_size;
}
static int get_rss_table(struct net_device *dev, u32 *p, u8 *key)
{
const struct port_info *pi = netdev_priv(dev);
unsigned int n = pi->rss_size;
while (n--)
p[n] = pi->rss[n];
return 0;
}
static int set_rss_table(struct net_device *dev, const u32 *p, const u8 *key)
{
unsigned int i;
struct port_info *pi = netdev_priv(dev);
for (i = 0; i < pi->rss_size; i++)
pi->rss[i] = p[i];
if (pi->adapter->flags & FULL_INIT_DONE)
return write_rss(pi, pi->rss);
return 0;
}
static int get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info,
u32 *rules)
{
const struct port_info *pi = netdev_priv(dev);
switch (info->cmd) {
case ETHTOOL_GRXFH: {
unsigned int v = pi->rss_mode;
info->data = 0;
switch (info->flow_type) {
case TCP_V4_FLOW:
if (v & FW_RSS_VI_CONFIG_CMD_IP4FOURTUPEN)
info->data = RXH_IP_SRC | RXH_IP_DST |
RXH_L4_B_0_1 | RXH_L4_B_2_3;
else if (v & FW_RSS_VI_CONFIG_CMD_IP4TWOTUPEN)
info->data = RXH_IP_SRC | RXH_IP_DST;
break;
case UDP_V4_FLOW:
if ((v & FW_RSS_VI_CONFIG_CMD_IP4FOURTUPEN) &&
(v & FW_RSS_VI_CONFIG_CMD_UDPEN))
info->data = RXH_IP_SRC | RXH_IP_DST |
RXH_L4_B_0_1 | RXH_L4_B_2_3;
else if (v & FW_RSS_VI_CONFIG_CMD_IP4TWOTUPEN)
info->data = RXH_IP_SRC | RXH_IP_DST;
break;
case SCTP_V4_FLOW:
case AH_ESP_V4_FLOW:
case IPV4_FLOW:
if (v & FW_RSS_VI_CONFIG_CMD_IP4TWOTUPEN)
info->data = RXH_IP_SRC | RXH_IP_DST;
break;
case TCP_V6_FLOW:
if (v & FW_RSS_VI_CONFIG_CMD_IP6FOURTUPEN)
info->data = RXH_IP_SRC | RXH_IP_DST |
RXH_L4_B_0_1 | RXH_L4_B_2_3;
else if (v & FW_RSS_VI_CONFIG_CMD_IP6TWOTUPEN)
info->data = RXH_IP_SRC | RXH_IP_DST;
break;
case UDP_V6_FLOW:
if ((v & FW_RSS_VI_CONFIG_CMD_IP6FOURTUPEN) &&
(v & FW_RSS_VI_CONFIG_CMD_UDPEN))
info->data = RXH_IP_SRC | RXH_IP_DST |
RXH_L4_B_0_1 | RXH_L4_B_2_3;
else if (v & FW_RSS_VI_CONFIG_CMD_IP6TWOTUPEN)
info->data = RXH_IP_SRC | RXH_IP_DST;
break;
case SCTP_V6_FLOW:
case AH_ESP_V6_FLOW:
case IPV6_FLOW:
if (v & FW_RSS_VI_CONFIG_CMD_IP6TWOTUPEN)
info->data = RXH_IP_SRC | RXH_IP_DST;
break;
}
return 0;
}
case ETHTOOL_GRXRINGS:
info->data = pi->nqsets;
return 0;
}
return -EOPNOTSUPP;
}
static const struct ethtool_ops cxgb_ethtool_ops = {
.get_settings = get_settings,
.set_settings = set_settings,
.get_drvinfo = get_drvinfo,
.get_msglevel = get_msglevel,
.set_msglevel = set_msglevel,
.get_ringparam = get_sge_param,
.set_ringparam = set_sge_param,
.get_coalesce = get_coalesce,
.set_coalesce = set_coalesce,
.get_eeprom_len = get_eeprom_len,
.get_eeprom = get_eeprom,
.set_eeprom = set_eeprom,
.get_pauseparam = get_pauseparam,
.set_pauseparam = set_pauseparam,
.get_link = ethtool_op_get_link,
.get_strings = get_strings,
.set_phys_id = identify_port,
.nway_reset = restart_autoneg,
.get_sset_count = get_sset_count,
.get_ethtool_stats = get_stats,
.get_regs_len = get_regs_len,
.get_regs = get_regs,
.get_wol = get_wol,
.set_wol = set_wol,
.get_rxnfc = get_rxnfc,
.get_rxfh_indir_size = get_rss_table_size,
.get_rxfh = get_rss_table,
.set_rxfh = set_rss_table,
.flash_device = set_flash,
};
/*
* debugfs support
*/
static ssize_t mem_read(struct file *file, char __user *buf, size_t count,
loff_t *ppos)
{
loff_t pos = *ppos;
loff_t avail = file_inode(file)->i_size;
unsigned int mem = (uintptr_t)file->private_data & 3;
struct adapter *adap = file->private_data - mem;
__be32 *data;
int ret;
if (pos < 0)
return -EINVAL;
if (pos >= avail)
return 0;
if (count > avail - pos)
count = avail - pos;
data = t4_alloc_mem(count);
if (!data)
return -ENOMEM;
spin_lock(&adap->win0_lock);
ret = t4_memory_rw(adap, 0, mem, pos, count, data, T4_MEMORY_READ);
spin_unlock(&adap->win0_lock);
if (ret) {
t4_free_mem(data);
return ret;
}
ret = copy_to_user(buf, data, count);
t4_free_mem(data);
if (ret)
return -EFAULT;
*ppos = pos + count;
return count;
}
static const struct file_operations mem_debugfs_fops = {
.owner = THIS_MODULE,
.open = simple_open,
.read = mem_read,
.llseek = default_llseek,
};
static void add_debugfs_mem(struct adapter *adap, const char *name,
unsigned int idx, unsigned int size_mb)
{
struct dentry *de;
de = debugfs_create_file(name, S_IRUSR, adap->debugfs_root,
(void *)adap + idx, &mem_debugfs_fops);
if (de && de->d_inode)
de->d_inode->i_size = size_mb << 20;
}
static int setup_debugfs(struct adapter *adap)
{
int i;
u32 size;
if (IS_ERR_OR_NULL(adap->debugfs_root))
return -1;
i = t4_read_reg(adap, MA_TARGET_MEM_ENABLE);
if (i & EDRAM0_ENABLE) {
size = t4_read_reg(adap, MA_EDRAM0_BAR);
add_debugfs_mem(adap, "edc0", MEM_EDC0, EDRAM_SIZE_GET(size));
}
if (i & EDRAM1_ENABLE) {
size = t4_read_reg(adap, MA_EDRAM1_BAR);
add_debugfs_mem(adap, "edc1", MEM_EDC1, EDRAM_SIZE_GET(size));
}
if (is_t4(adap->params.chip)) {
size = t4_read_reg(adap, MA_EXT_MEMORY_BAR);
if (i & EXT_MEM_ENABLE)
add_debugfs_mem(adap, "mc", MEM_MC,
EXT_MEM_SIZE_GET(size));
} else {
if (i & EXT_MEM_ENABLE) {
size = t4_read_reg(adap, MA_EXT_MEMORY_BAR);
add_debugfs_mem(adap, "mc0", MEM_MC0,
EXT_MEM_SIZE_GET(size));
}
if (i & EXT_MEM1_ENABLE) {
size = t4_read_reg(adap, MA_EXT_MEMORY1_BAR);
add_debugfs_mem(adap, "mc1", MEM_MC1,
EXT_MEM_SIZE_GET(size));
}
}
if (adap->l2t)
debugfs_create_file("l2t", S_IRUSR, adap->debugfs_root, adap,
&t4_l2t_fops);
return 0;
}
/*
* upper-layer driver support
*/
/*
* Allocate an active-open TID and set it to the supplied value.
*/
int cxgb4_alloc_atid(struct tid_info *t, void *data)
{
int atid = -1;
spin_lock_bh(&t->atid_lock);
if (t->afree) {
union aopen_entry *p = t->afree;
atid = (p - t->atid_tab) + t->atid_base;
t->afree = p->next;
p->data = data;
t->atids_in_use++;
}
spin_unlock_bh(&t->atid_lock);
return atid;
}
EXPORT_SYMBOL(cxgb4_alloc_atid);
/*
* Release an active-open TID.
*/
void cxgb4_free_atid(struct tid_info *t, unsigned int atid)
{
union aopen_entry *p = &t->atid_tab[atid - t->atid_base];
spin_lock_bh(&t->atid_lock);
p->next = t->afree;
t->afree = p;
t->atids_in_use--;
spin_unlock_bh(&t->atid_lock);
}
EXPORT_SYMBOL(cxgb4_free_atid);
/*
* Allocate a server TID and set it to the supplied value.
*/
int cxgb4_alloc_stid(struct tid_info *t, int family, void *data)
{
int stid;
spin_lock_bh(&t->stid_lock);
if (family == PF_INET) {
stid = find_first_zero_bit(t->stid_bmap, t->nstids);
if (stid < t->nstids)
__set_bit(stid, t->stid_bmap);
else
stid = -1;
} else {
stid = bitmap_find_free_region(t->stid_bmap, t->nstids, 2);
if (stid < 0)
stid = -1;
}
if (stid >= 0) {
t->stid_tab[stid].data = data;
stid += t->stid_base;
/* IPv6 requires max of 520 bits or 16 cells in TCAM
* This is equivalent to 4 TIDs. With CLIP enabled it
* needs 2 TIDs.
*/
if (family == PF_INET)
t->stids_in_use++;
else
t->stids_in_use += 4;
}
spin_unlock_bh(&t->stid_lock);
return stid;
}
EXPORT_SYMBOL(cxgb4_alloc_stid);
/* Allocate a server filter TID and set it to the supplied value.
*/
int cxgb4_alloc_sftid(struct tid_info *t, int family, void *data)
{
int stid;
spin_lock_bh(&t->stid_lock);
if (family == PF_INET) {
stid = find_next_zero_bit(t->stid_bmap,
t->nstids + t->nsftids, t->nstids);
if (stid < (t->nstids + t->nsftids))
__set_bit(stid, t->stid_bmap);
else
stid = -1;
} else {
stid = -1;
}
if (stid >= 0) {
t->stid_tab[stid].data = data;
stid -= t->nstids;
stid += t->sftid_base;
t->stids_in_use++;
}
spin_unlock_bh(&t->stid_lock);
return stid;
}
EXPORT_SYMBOL(cxgb4_alloc_sftid);
/* Release a server TID.
*/
void cxgb4_free_stid(struct tid_info *t, unsigned int stid, int family)
{
/* Is it a server filter TID? */
if (t->nsftids && (stid >= t->sftid_base)) {
stid -= t->sftid_base;
stid += t->nstids;
} else {
stid -= t->stid_base;
}
spin_lock_bh(&t->stid_lock);
if (family == PF_INET)
__clear_bit(stid, t->stid_bmap);
else
bitmap_release_region(t->stid_bmap, stid, 2);
t->stid_tab[stid].data = NULL;
if (family == PF_INET)
t->stids_in_use--;
else
t->stids_in_use -= 4;
spin_unlock_bh(&t->stid_lock);
}
EXPORT_SYMBOL(cxgb4_free_stid);
/*
* Populate a TID_RELEASE WR. Caller must properly size the skb.
*/
static void mk_tid_release(struct sk_buff *skb, unsigned int chan,
unsigned int tid)
{
struct cpl_tid_release *req;
set_wr_txq(skb, CPL_PRIORITY_SETUP, chan);
req = (struct cpl_tid_release *)__skb_put(skb, sizeof(*req));
INIT_TP_WR(req, tid);
OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_TID_RELEASE, tid));
}
/*
* Queue a TID release request and if necessary schedule a work queue to
* process it.
*/
static void cxgb4_queue_tid_release(struct tid_info *t, unsigned int chan,
unsigned int tid)
{
void **p = &t->tid_tab[tid];
struct adapter *adap = container_of(t, struct adapter, tids);
spin_lock_bh(&adap->tid_release_lock);
*p = adap->tid_release_head;
/* Low 2 bits encode the Tx channel number */
adap->tid_release_head = (void **)((uintptr_t)p | chan);
if (!adap->tid_release_task_busy) {
adap->tid_release_task_busy = true;
queue_work(adap->workq, &adap->tid_release_task);
}
spin_unlock_bh(&adap->tid_release_lock);
}
/*
* Process the list of pending TID release requests.
*/
static void process_tid_release_list(struct work_struct *work)
{
struct sk_buff *skb;
struct adapter *adap;
adap = container_of(work, struct adapter, tid_release_task);
spin_lock_bh(&adap->tid_release_lock);
while (adap->tid_release_head) {
void **p = adap->tid_release_head;
unsigned int chan = (uintptr_t)p & 3;
p = (void *)p - chan;
adap->tid_release_head = *p;
*p = NULL;
spin_unlock_bh(&adap->tid_release_lock);
while (!(skb = alloc_skb(sizeof(struct cpl_tid_release),
GFP_KERNEL)))
schedule_timeout_uninterruptible(1);
mk_tid_release(skb, chan, p - adap->tids.tid_tab);
t4_ofld_send(adap, skb);
spin_lock_bh(&adap->tid_release_lock);
}
adap->tid_release_task_busy = false;
spin_unlock_bh(&adap->tid_release_lock);
}
/*
* Release a TID and inform HW. If we are unable to allocate the release
* message we defer to a work queue.
*/
void cxgb4_remove_tid(struct tid_info *t, unsigned int chan, unsigned int tid)
{
void *old;
struct sk_buff *skb;
struct adapter *adap = container_of(t, struct adapter, tids);
old = t->tid_tab[tid];
skb = alloc_skb(sizeof(struct cpl_tid_release), GFP_ATOMIC);
if (likely(skb)) {
t->tid_tab[tid] = NULL;
mk_tid_release(skb, chan, tid);
t4_ofld_send(adap, skb);
} else
cxgb4_queue_tid_release(t, chan, tid);
if (old)
atomic_dec(&t->tids_in_use);
}
EXPORT_SYMBOL(cxgb4_remove_tid);
/*
* Allocate and initialize the TID tables. Returns 0 on success.
*/
static int tid_init(struct tid_info *t)
{
size_t size;
unsigned int stid_bmap_size;
unsigned int natids = t->natids;
struct adapter *adap = container_of(t, struct adapter, tids);
stid_bmap_size = BITS_TO_LONGS(t->nstids + t->nsftids);
size = t->ntids * sizeof(*t->tid_tab) +
natids * sizeof(*t->atid_tab) +
t->nstids * sizeof(*t->stid_tab) +
t->nsftids * sizeof(*t->stid_tab) +
stid_bmap_size * sizeof(long) +
t->nftids * sizeof(*t->ftid_tab) +
t->nsftids * sizeof(*t->ftid_tab);
t->tid_tab = t4_alloc_mem(size);
if (!t->tid_tab)
return -ENOMEM;
t->atid_tab = (union aopen_entry *)&t->tid_tab[t->ntids];
t->stid_tab = (struct serv_entry *)&t->atid_tab[natids];
t->stid_bmap = (unsigned long *)&t->stid_tab[t->nstids + t->nsftids];
t->ftid_tab = (struct filter_entry *)&t->stid_bmap[stid_bmap_size];
spin_lock_init(&t->stid_lock);
spin_lock_init(&t->atid_lock);
t->stids_in_use = 0;
t->afree = NULL;
t->atids_in_use = 0;
atomic_set(&t->tids_in_use, 0);
/* Setup the free list for atid_tab and clear the stid bitmap. */
if (natids) {
while (--natids)
t->atid_tab[natids - 1].next = &t->atid_tab[natids];
t->afree = t->atid_tab;
}
bitmap_zero(t->stid_bmap, t->nstids + t->nsftids);
/* Reserve stid 0 for T4/T5 adapters */
if (!t->stid_base &&
(is_t4(adap->params.chip) || is_t5(adap->params.chip)))
__set_bit(0, t->stid_bmap);
return 0;
}
int cxgb4_clip_get(const struct net_device *dev,
const struct in6_addr *lip)
{
struct adapter *adap;
struct fw_clip_cmd c;
adap = netdev2adap(dev);
memset(&c, 0, sizeof(c));
c.op_to_write = htonl(FW_CMD_OP(FW_CLIP_CMD) |
FW_CMD_REQUEST | FW_CMD_WRITE);
c.alloc_to_len16 = htonl(F_FW_CLIP_CMD_ALLOC | FW_LEN16(c));
c.ip_hi = *(__be64 *)(lip->s6_addr);
c.ip_lo = *(__be64 *)(lip->s6_addr + 8);
return t4_wr_mbox_meat(adap, adap->mbox, &c, sizeof(c), &c, false);
}
EXPORT_SYMBOL(cxgb4_clip_get);
int cxgb4_clip_release(const struct net_device *dev,
const struct in6_addr *lip)
{
struct adapter *adap;
struct fw_clip_cmd c;
adap = netdev2adap(dev);
memset(&c, 0, sizeof(c));
c.op_to_write = htonl(FW_CMD_OP(FW_CLIP_CMD) |
FW_CMD_REQUEST | FW_CMD_READ);
c.alloc_to_len16 = htonl(F_FW_CLIP_CMD_FREE | FW_LEN16(c));
c.ip_hi = *(__be64 *)(lip->s6_addr);
c.ip_lo = *(__be64 *)(lip->s6_addr + 8);
return t4_wr_mbox_meat(adap, adap->mbox, &c, sizeof(c), &c, false);
}
EXPORT_SYMBOL(cxgb4_clip_release);
/**
* cxgb4_create_server - create an IP server
* @dev: the device
* @stid: the server TID
* @sip: local IP address to bind server to
* @sport: the server's TCP port
* @queue: queue to direct messages from this server to
*
* Create an IP server for the given port and address.
* Returns <0 on error and one of the %NET_XMIT_* values on success.
*/
int cxgb4_create_server(const struct net_device *dev, unsigned int stid,
__be32 sip, __be16 sport, __be16 vlan,
unsigned int queue)
{
unsigned int chan;
struct sk_buff *skb;
struct adapter *adap;
struct cpl_pass_open_req *req;
int ret;
skb = alloc_skb(sizeof(*req), GFP_KERNEL);
if (!skb)
return -ENOMEM;
adap = netdev2adap(dev);
req = (struct cpl_pass_open_req *)__skb_put(skb, sizeof(*req));
INIT_TP_WR(req, 0);
OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_PASS_OPEN_REQ, stid));
req->local_port = sport;
req->peer_port = htons(0);
req->local_ip = sip;
req->peer_ip = htonl(0);
chan = rxq_to_chan(&adap->sge, queue);
req->opt0 = cpu_to_be64(TX_CHAN(chan));
req->opt1 = cpu_to_be64(CONN_POLICY_ASK |
SYN_RSS_ENABLE | SYN_RSS_QUEUE(queue));
ret = t4_mgmt_tx(adap, skb);
return net_xmit_eval(ret);
}
EXPORT_SYMBOL(cxgb4_create_server);
/* cxgb4_create_server6 - create an IPv6 server
* @dev: the device
* @stid: the server TID
* @sip: local IPv6 address to bind server to
* @sport: the server's TCP port
* @queue: queue to direct messages from this server to
*
* Create an IPv6 server for the given port and address.
* Returns <0 on error and one of the %NET_XMIT_* values on success.
*/
int cxgb4_create_server6(const struct net_device *dev, unsigned int stid,
const struct in6_addr *sip, __be16 sport,
unsigned int queue)
{
unsigned int chan;
struct sk_buff *skb;
struct adapter *adap;
struct cpl_pass_open_req6 *req;
int ret;
skb = alloc_skb(sizeof(*req), GFP_KERNEL);
if (!skb)
return -ENOMEM;
adap = netdev2adap(dev);
req = (struct cpl_pass_open_req6 *)__skb_put(skb, sizeof(*req));
INIT_TP_WR(req, 0);
OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_PASS_OPEN_REQ6, stid));
req->local_port = sport;
req->peer_port = htons(0);
req->local_ip_hi = *(__be64 *)(sip->s6_addr);
req->local_ip_lo = *(__be64 *)(sip->s6_addr + 8);
req->peer_ip_hi = cpu_to_be64(0);
req->peer_ip_lo = cpu_to_be64(0);
chan = rxq_to_chan(&adap->sge, queue);
req->opt0 = cpu_to_be64(TX_CHAN(chan));
req->opt1 = cpu_to_be64(CONN_POLICY_ASK |
SYN_RSS_ENABLE | SYN_RSS_QUEUE(queue));
ret = t4_mgmt_tx(adap, skb);
return net_xmit_eval(ret);
}
EXPORT_SYMBOL(cxgb4_create_server6);
int cxgb4_remove_server(const struct net_device *dev, unsigned int stid,
unsigned int queue, bool ipv6)
{
struct sk_buff *skb;
struct adapter *adap;
struct cpl_close_listsvr_req *req;
int ret;
adap = netdev2adap(dev);
skb = alloc_skb(sizeof(*req), GFP_KERNEL);
if (!skb)
return -ENOMEM;
req = (struct cpl_close_listsvr_req *)__skb_put(skb, sizeof(*req));
INIT_TP_WR(req, 0);
OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_CLOSE_LISTSRV_REQ, stid));
req->reply_ctrl = htons(NO_REPLY(0) | (ipv6 ? LISTSVR_IPV6(1) :
LISTSVR_IPV6(0)) | QUEUENO(queue));
ret = t4_mgmt_tx(adap, skb);
return net_xmit_eval(ret);
}
EXPORT_SYMBOL(cxgb4_remove_server);
/**
* cxgb4_best_mtu - find the entry in the MTU table closest to an MTU
* @mtus: the HW MTU table
* @mtu: the target MTU
* @idx: index of selected entry in the MTU table
*
* Returns the index and the value in the HW MTU table that is closest to
* but does not exceed @mtu, unless @mtu is smaller than any value in the
* table, in which case that smallest available value is selected.
*/
unsigned int cxgb4_best_mtu(const unsigned short *mtus, unsigned short mtu,
unsigned int *idx)
{
unsigned int i = 0;
while (i < NMTUS - 1 && mtus[i + 1] <= mtu)
++i;
if (idx)
*idx = i;
return mtus[i];
}
EXPORT_SYMBOL(cxgb4_best_mtu);
/**
* cxgb4_best_aligned_mtu - find best MTU, [hopefully] data size aligned
* @mtus: the HW MTU table
* @header_size: Header Size
* @data_size_max: maximum Data Segment Size
* @data_size_align: desired Data Segment Size Alignment (2^N)
* @mtu_idxp: HW MTU Table Index return value pointer (possibly NULL)
*
* Similar to cxgb4_best_mtu() but instead of searching the Hardware
* MTU Table based solely on a Maximum MTU parameter, we break that
* parameter up into a Header Size and Maximum Data Segment Size, and
* provide a desired Data Segment Size Alignment. If we find an MTU in
* the Hardware MTU Table which will result in a Data Segment Size with
* the requested alignment _and_ that MTU isn't "too far" from the
* closest MTU, then we'll return that rather than the closest MTU.
*/
unsigned int cxgb4_best_aligned_mtu(const unsigned short *mtus,
unsigned short header_size,
unsigned short data_size_max,
unsigned short data_size_align,
unsigned int *mtu_idxp)
{
unsigned short max_mtu = header_size + data_size_max;
unsigned short data_size_align_mask = data_size_align - 1;
int mtu_idx, aligned_mtu_idx;
/* Scan the MTU Table till we find an MTU which is larger than our
* Maximum MTU or we reach the end of the table. Along the way,
* record the last MTU found, if any, which will result in a Data
* Segment Length matching the requested alignment.
*/
for (mtu_idx = 0, aligned_mtu_idx = -1; mtu_idx < NMTUS; mtu_idx++) {
unsigned short data_size = mtus[mtu_idx] - header_size;
/* If this MTU minus the Header Size would result in a
* Data Segment Size of the desired alignment, remember it.
*/
if ((data_size & data_size_align_mask) == 0)
aligned_mtu_idx = mtu_idx;
/* If we're not at the end of the Hardware MTU Table and the
* next element is larger than our Maximum MTU, drop out of
* the loop.
*/
if (mtu_idx+1 < NMTUS && mtus[mtu_idx+1] > max_mtu)
break;
}
/* If we fell out of the loop because we ran to the end of the table,
* then we just have to use the last [largest] entry.
*/
if (mtu_idx == NMTUS)
mtu_idx--;
/* If we found an MTU which resulted in the requested Data Segment
* Length alignment and that's "not far" from the largest MTU which is
* less than or equal to the maximum MTU, then use that.
*/
if (aligned_mtu_idx >= 0 &&
mtu_idx - aligned_mtu_idx <= 1)
mtu_idx = aligned_mtu_idx;
/* If the caller has passed in an MTU Index pointer, pass the
* MTU Index back. Return the MTU value.
*/
if (mtu_idxp)
*mtu_idxp = mtu_idx;
return mtus[mtu_idx];
}
EXPORT_SYMBOL(cxgb4_best_aligned_mtu);
/**
* cxgb4_port_chan - get the HW channel of a port
* @dev: the net device for the port
*
* Return the HW Tx channel of the given port.
*/
unsigned int cxgb4_port_chan(const struct net_device *dev)
{
return netdev2pinfo(dev)->tx_chan;
}
EXPORT_SYMBOL(cxgb4_port_chan);
unsigned int cxgb4_dbfifo_count(const struct net_device *dev, int lpfifo)
{
struct adapter *adap = netdev2adap(dev);
u32 v1, v2, lp_count, hp_count;
v1 = t4_read_reg(adap, A_SGE_DBFIFO_STATUS);
v2 = t4_read_reg(adap, SGE_DBFIFO_STATUS2);
if (is_t4(adap->params.chip)) {
lp_count = G_LP_COUNT(v1);
hp_count = G_HP_COUNT(v1);
} else {
lp_count = G_LP_COUNT_T5(v1);
hp_count = G_HP_COUNT_T5(v2);
}
return lpfifo ? lp_count : hp_count;
}
EXPORT_SYMBOL(cxgb4_dbfifo_count);
/**
* cxgb4_port_viid - get the VI id of a port
* @dev: the net device for the port
*
* Return the VI id of the given port.
*/
unsigned int cxgb4_port_viid(const struct net_device *dev)
{
return netdev2pinfo(dev)->viid;
}
EXPORT_SYMBOL(cxgb4_port_viid);
/**
* cxgb4_port_idx - get the index of a port
* @dev: the net device for the port
*
* Return the index of the given port.
*/
unsigned int cxgb4_port_idx(const struct net_device *dev)
{
return netdev2pinfo(dev)->port_id;
}
EXPORT_SYMBOL(cxgb4_port_idx);
void cxgb4_get_tcp_stats(struct pci_dev *pdev, struct tp_tcp_stats *v4,
struct tp_tcp_stats *v6)
{
struct adapter *adap = pci_get_drvdata(pdev);
spin_lock(&adap->stats_lock);
t4_tp_get_tcp_stats(adap, v4, v6);
spin_unlock(&adap->stats_lock);
}
EXPORT_SYMBOL(cxgb4_get_tcp_stats);
void cxgb4_iscsi_init(struct net_device *dev, unsigned int tag_mask,
const unsigned int *pgsz_order)
{
struct adapter *adap = netdev2adap(dev);
t4_write_reg(adap, ULP_RX_ISCSI_TAGMASK, tag_mask);
t4_write_reg(adap, ULP_RX_ISCSI_PSZ, HPZ0(pgsz_order[0]) |
HPZ1(pgsz_order[1]) | HPZ2(pgsz_order[2]) |
HPZ3(pgsz_order[3]));
}
EXPORT_SYMBOL(cxgb4_iscsi_init);
int cxgb4_flush_eq_cache(struct net_device *dev)
{
struct adapter *adap = netdev2adap(dev);
int ret;
ret = t4_fwaddrspace_write(adap, adap->mbox,
0xe1000000 + A_SGE_CTXT_CMD, 0x20000000);
return ret;
}
EXPORT_SYMBOL(cxgb4_flush_eq_cache);
static int read_eq_indices(struct adapter *adap, u16 qid, u16 *pidx, u16 *cidx)
{
u32 addr = t4_read_reg(adap, A_SGE_DBQ_CTXT_BADDR) + 24 * qid + 8;
__be64 indices;
int ret;
spin_lock(&adap->win0_lock);
ret = t4_memory_rw(adap, 0, MEM_EDC0, addr,
sizeof(indices), (__be32 *)&indices,
T4_MEMORY_READ);
spin_unlock(&adap->win0_lock);
if (!ret) {
*cidx = (be64_to_cpu(indices) >> 25) & 0xffff;
*pidx = (be64_to_cpu(indices) >> 9) & 0xffff;
}
return ret;
}
int cxgb4_sync_txq_pidx(struct net_device *dev, u16 qid, u16 pidx,
u16 size)
{
struct adapter *adap = netdev2adap(dev);
u16 hw_pidx, hw_cidx;
int ret;
ret = read_eq_indices(adap, qid, &hw_pidx, &hw_cidx);
if (ret)
goto out;
if (pidx != hw_pidx) {
u16 delta;
if (pidx >= hw_pidx)
delta = pidx - hw_pidx;
else
delta = size - hw_pidx + pidx;
wmb();
t4_write_reg(adap, MYPF_REG(SGE_PF_KDOORBELL),
QID(qid) | PIDX(delta));
}
out:
return ret;
}
EXPORT_SYMBOL(cxgb4_sync_txq_pidx);
void cxgb4_disable_db_coalescing(struct net_device *dev)
{
struct adapter *adap;
adap = netdev2adap(dev);
t4_set_reg_field(adap, A_SGE_DOORBELL_CONTROL, F_NOCOALESCE,
F_NOCOALESCE);
}
EXPORT_SYMBOL(cxgb4_disable_db_coalescing);
void cxgb4_enable_db_coalescing(struct net_device *dev)
{
struct adapter *adap;
adap = netdev2adap(dev);
t4_set_reg_field(adap, A_SGE_DOORBELL_CONTROL, F_NOCOALESCE, 0);
}
EXPORT_SYMBOL(cxgb4_enable_db_coalescing);
int cxgb4_read_tpte(struct net_device *dev, u32 stag, __be32 *tpte)
{
struct adapter *adap;
u32 offset, memtype, memaddr;
u32 edc0_size, edc1_size, mc0_size, mc1_size;
u32 edc0_end, edc1_end, mc0_end, mc1_end;
int ret;
adap = netdev2adap(dev);
offset = ((stag >> 8) * 32) + adap->vres.stag.start;
/* Figure out where the offset lands in the Memory Type/Address scheme.
* This code assumes that the memory is laid out starting at offset 0
* with no breaks as: EDC0, EDC1, MC0, MC1. All cards have both EDC0
* and EDC1. Some cards will have neither MC0 nor MC1, most cards have
* MC0, and some have both MC0 and MC1.
*/
edc0_size = EDRAM_SIZE_GET(t4_read_reg(adap, MA_EDRAM0_BAR)) << 20;
edc1_size = EDRAM_SIZE_GET(t4_read_reg(adap, MA_EDRAM1_BAR)) << 20;
mc0_size = EXT_MEM_SIZE_GET(t4_read_reg(adap, MA_EXT_MEMORY_BAR)) << 20;
edc0_end = edc0_size;
edc1_end = edc0_end + edc1_size;
mc0_end = edc1_end + mc0_size;
if (offset < edc0_end) {
memtype = MEM_EDC0;
memaddr = offset;
} else if (offset < edc1_end) {
memtype = MEM_EDC1;
memaddr = offset - edc0_end;
} else {
if (offset < mc0_end) {
memtype = MEM_MC0;
memaddr = offset - edc1_end;
} else if (is_t4(adap->params.chip)) {
/* T4 only has a single memory channel */
goto err;
} else {
mc1_size = EXT_MEM_SIZE_GET(
t4_read_reg(adap,
MA_EXT_MEMORY1_BAR)) << 20;
mc1_end = mc0_end + mc1_size;
if (offset < mc1_end) {
memtype = MEM_MC1;
memaddr = offset - mc0_end;
} else {
/* offset beyond the end of any memory */
goto err;
}
}
}
spin_lock(&adap->win0_lock);
ret = t4_memory_rw(adap, 0, memtype, memaddr, 32, tpte, T4_MEMORY_READ);
spin_unlock(&adap->win0_lock);
return ret;
err:
dev_err(adap->pdev_dev, "stag %#x, offset %#x out of range\n",
stag, offset);
return -EINVAL;
}
EXPORT_SYMBOL(cxgb4_read_tpte);
u64 cxgb4_read_sge_timestamp(struct net_device *dev)
{
u32 hi, lo;
struct adapter *adap;
adap = netdev2adap(dev);
lo = t4_read_reg(adap, SGE_TIMESTAMP_LO);
hi = GET_TSVAL(t4_read_reg(adap, SGE_TIMESTAMP_HI));
return ((u64)hi << 32) | (u64)lo;
}
EXPORT_SYMBOL(cxgb4_read_sge_timestamp);
static struct pci_driver cxgb4_driver;
static void check_neigh_update(struct neighbour *neigh)
{
const struct device *parent;
const struct net_device *netdev = neigh->dev;
if (netdev->priv_flags & IFF_802_1Q_VLAN)
netdev = vlan_dev_real_dev(netdev);
parent = netdev->dev.parent;
if (parent && parent->driver == &cxgb4_driver.driver)
t4_l2t_update(dev_get_drvdata(parent), neigh);
}
static int netevent_cb(struct notifier_block *nb, unsigned long event,
void *data)
{
switch (event) {
case NETEVENT_NEIGH_UPDATE:
check_neigh_update(data);
break;
case NETEVENT_REDIRECT:
default:
break;
}
return 0;
}
static bool netevent_registered;
static struct notifier_block cxgb4_netevent_nb = {
.notifier_call = netevent_cb
};
static void drain_db_fifo(struct adapter *adap, int usecs)
{
u32 v1, v2, lp_count, hp_count;
do {
v1 = t4_read_reg(adap, A_SGE_DBFIFO_STATUS);
v2 = t4_read_reg(adap, SGE_DBFIFO_STATUS2);
if (is_t4(adap->params.chip)) {
lp_count = G_LP_COUNT(v1);
hp_count = G_HP_COUNT(v1);
} else {
lp_count = G_LP_COUNT_T5(v1);
hp_count = G_HP_COUNT_T5(v2);
}
if (lp_count == 0 && hp_count == 0)
break;
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(usecs_to_jiffies(usecs));
} while (1);
}
static void disable_txq_db(struct sge_txq *q)
{
unsigned long flags;
spin_lock_irqsave(&q->db_lock, flags);
q->db_disabled = 1;
spin_unlock_irqrestore(&q->db_lock, flags);
}
static void enable_txq_db(struct adapter *adap, struct sge_txq *q)
{
spin_lock_irq(&q->db_lock);
if (q->db_pidx_inc) {
/* Make sure that all writes to the TX descriptors
* are committed before we tell HW about them.
*/
wmb();
t4_write_reg(adap, MYPF_REG(SGE_PF_KDOORBELL),
QID(q->cntxt_id) | PIDX(q->db_pidx_inc));
q->db_pidx_inc = 0;
}
q->db_disabled = 0;
spin_unlock_irq(&q->db_lock);
}
static void disable_dbs(struct adapter *adap)
{
int i;
for_each_ethrxq(&adap->sge, i)
disable_txq_db(&adap->sge.ethtxq[i].q);
for_each_ofldrxq(&adap->sge, i)
disable_txq_db(&adap->sge.ofldtxq[i].q);
for_each_port(adap, i)
disable_txq_db(&adap->sge.ctrlq[i].q);
}
static void enable_dbs(struct adapter *adap)
{
int i;
for_each_ethrxq(&adap->sge, i)
enable_txq_db(adap, &adap->sge.ethtxq[i].q);
for_each_ofldrxq(&adap->sge, i)
enable_txq_db(adap, &adap->sge.ofldtxq[i].q);
for_each_port(adap, i)
enable_txq_db(adap, &adap->sge.ctrlq[i].q);
}
static void notify_rdma_uld(struct adapter *adap, enum cxgb4_control cmd)
{
if (adap->uld_handle[CXGB4_ULD_RDMA])
ulds[CXGB4_ULD_RDMA].control(adap->uld_handle[CXGB4_ULD_RDMA],
cmd);
}
static void process_db_full(struct work_struct *work)
{
struct adapter *adap;
adap = container_of(work, struct adapter, db_full_task);
drain_db_fifo(adap, dbfifo_drain_delay);
enable_dbs(adap);
notify_rdma_uld(adap, CXGB4_CONTROL_DB_EMPTY);
t4_set_reg_field(adap, SGE_INT_ENABLE3,
DBFIFO_HP_INT | DBFIFO_LP_INT,
DBFIFO_HP_INT | DBFIFO_LP_INT);
}
static void sync_txq_pidx(struct adapter *adap, struct sge_txq *q)
{
u16 hw_pidx, hw_cidx;
int ret;
spin_lock_irq(&q->db_lock);
ret = read_eq_indices(adap, (u16)q->cntxt_id, &hw_pidx, &hw_cidx);
if (ret)
goto out;
if (q->db_pidx != hw_pidx) {
u16 delta;
if (q->db_pidx >= hw_pidx)
delta = q->db_pidx - hw_pidx;
else
delta = q->size - hw_pidx + q->db_pidx;
wmb();
t4_write_reg(adap, MYPF_REG(SGE_PF_KDOORBELL),
QID(q->cntxt_id) | PIDX(delta));
}
out:
q->db_disabled = 0;
q->db_pidx_inc = 0;
spin_unlock_irq(&q->db_lock);
if (ret)
CH_WARN(adap, "DB drop recovery failed.\n");
}
static void recover_all_queues(struct adapter *adap)
{
int i;
for_each_ethrxq(&adap->sge, i)
sync_txq_pidx(adap, &adap->sge.ethtxq[i].q);
for_each_ofldrxq(&adap->sge, i)
sync_txq_pidx(adap, &adap->sge.ofldtxq[i].q);
for_each_port(adap, i)
sync_txq_pidx(adap, &adap->sge.ctrlq[i].q);
}
static void process_db_drop(struct work_struct *work)
{
struct adapter *adap;
adap = container_of(work, struct adapter, db_drop_task);
if (is_t4(adap->params.chip)) {
drain_db_fifo(adap, dbfifo_drain_delay);
notify_rdma_uld(adap, CXGB4_CONTROL_DB_DROP);
drain_db_fifo(adap, dbfifo_drain_delay);
recover_all_queues(adap);
drain_db_fifo(adap, dbfifo_drain_delay);
enable_dbs(adap);
notify_rdma_uld(adap, CXGB4_CONTROL_DB_EMPTY);
} else {
u32 dropped_db = t4_read_reg(adap, 0x010ac);
u16 qid = (dropped_db >> 15) & 0x1ffff;
u16 pidx_inc = dropped_db & 0x1fff;
unsigned int s_qpp;
unsigned short udb_density;
unsigned long qpshift;
int page;
u32 udb;
dev_warn(adap->pdev_dev,
"Dropped DB 0x%x qid %d bar2 %d coalesce %d pidx %d\n",
dropped_db, qid,
(dropped_db >> 14) & 1,
(dropped_db >> 13) & 1,
pidx_inc);
drain_db_fifo(adap, 1);
s_qpp = QUEUESPERPAGEPF1 * adap->fn;
udb_density = 1 << QUEUESPERPAGEPF0_GET(t4_read_reg(adap,
SGE_EGRESS_QUEUES_PER_PAGE_PF) >> s_qpp);
qpshift = PAGE_SHIFT - ilog2(udb_density);
udb = qid << qpshift;
udb &= PAGE_MASK;
page = udb / PAGE_SIZE;
udb += (qid - (page * udb_density)) * 128;
writel(PIDX(pidx_inc), adap->bar2 + udb + 8);
/* Re-enable BAR2 WC */
t4_set_reg_field(adap, 0x10b0, 1<<15, 1<<15);
}
t4_set_reg_field(adap, A_SGE_DOORBELL_CONTROL, F_DROPPED_DB, 0);
}
void t4_db_full(struct adapter *adap)
{
if (is_t4(adap->params.chip)) {
disable_dbs(adap);
notify_rdma_uld(adap, CXGB4_CONTROL_DB_FULL);
t4_set_reg_field(adap, SGE_INT_ENABLE3,
DBFIFO_HP_INT | DBFIFO_LP_INT, 0);
queue_work(adap->workq, &adap->db_full_task);
}
}
void t4_db_dropped(struct adapter *adap)
{
if (is_t4(adap->params.chip)) {
disable_dbs(adap);
notify_rdma_uld(adap, CXGB4_CONTROL_DB_FULL);
}
queue_work(adap->workq, &adap->db_drop_task);
}
static void uld_attach(struct adapter *adap, unsigned int uld)
{
void *handle;
struct cxgb4_lld_info lli;
unsigned short i;
lli.pdev = adap->pdev;
lli.pf = adap->fn;
lli.l2t = adap->l2t;
lli.tids = &adap->tids;
lli.ports = adap->port;
lli.vr = &adap->vres;
lli.mtus = adap->params.mtus;
if (uld == CXGB4_ULD_RDMA) {
lli.rxq_ids = adap->sge.rdma_rxq;
lli.ciq_ids = adap->sge.rdma_ciq;
lli.nrxq = adap->sge.rdmaqs;
lli.nciq = adap->sge.rdmaciqs;
} else if (uld == CXGB4_ULD_ISCSI) {
lli.rxq_ids = adap->sge.ofld_rxq;
lli.nrxq = adap->sge.ofldqsets;
}
lli.ntxq = adap->sge.ofldqsets;
lli.nchan = adap->params.nports;
lli.nports = adap->params.nports;
lli.wr_cred = adap->params.ofldq_wr_cred;
lli.adapter_type = adap->params.chip;
lli.iscsi_iolen = MAXRXDATA_GET(t4_read_reg(adap, TP_PARA_REG2));
lli.cclk_ps = 1000000000 / adap->params.vpd.cclk;
lli.udb_density = 1 << QUEUESPERPAGEPF0_GET(
t4_read_reg(adap, SGE_EGRESS_QUEUES_PER_PAGE_PF) >>
(adap->fn * 4));
lli.ucq_density = 1 << QUEUESPERPAGEPF0_GET(
t4_read_reg(adap, SGE_INGRESS_QUEUES_PER_PAGE_PF) >>
(adap->fn * 4));
lli.filt_mode = adap->params.tp.vlan_pri_map;
/* MODQ_REQ_MAP sets queues 0-3 to chan 0-3 */
for (i = 0; i < NCHAN; i++)
lli.tx_modq[i] = i;
lli.gts_reg = adap->regs + MYPF_REG(SGE_PF_GTS);
lli.db_reg = adap->regs + MYPF_REG(SGE_PF_KDOORBELL);
lli.fw_vers = adap->params.fw_vers;
lli.dbfifo_int_thresh = dbfifo_int_thresh;
lli.sge_ingpadboundary = adap->sge.fl_align;
lli.sge_egrstatuspagesize = adap->sge.stat_len;
lli.sge_pktshift = adap->sge.pktshift;
lli.enable_fw_ofld_conn = adap->flags & FW_OFLD_CONN;
lli.max_ordird_qp = adap->params.max_ordird_qp;
lli.max_ird_adapter = adap->params.max_ird_adapter;
lli.ulptx_memwrite_dsgl = adap->params.ulptx_memwrite_dsgl;
handle = ulds[uld].add(&lli);
if (IS_ERR(handle)) {
dev_warn(adap->pdev_dev,
"could not attach to the %s driver, error %ld\n",
uld_str[uld], PTR_ERR(handle));
return;
}
adap->uld_handle[uld] = handle;
if (!netevent_registered) {
register_netevent_notifier(&cxgb4_netevent_nb);
netevent_registered = true;
}
if (adap->flags & FULL_INIT_DONE)
ulds[uld].state_change(handle, CXGB4_STATE_UP);
}
static void attach_ulds(struct adapter *adap)
{
unsigned int i;
spin_lock(&adap_rcu_lock);
list_add_tail_rcu(&adap->rcu_node, &adap_rcu_list);
spin_unlock(&adap_rcu_lock);
mutex_lock(&uld_mutex);
list_add_tail(&adap->list_node, &adapter_list);
for (i = 0; i < CXGB4_ULD_MAX; i++)
if (ulds[i].add)
uld_attach(adap, i);
mutex_unlock(&uld_mutex);
}
static void detach_ulds(struct adapter *adap)
{
unsigned int i;
mutex_lock(&uld_mutex);
list_del(&adap->list_node);
for (i = 0; i < CXGB4_ULD_MAX; i++)
if (adap->uld_handle[i]) {
ulds[i].state_change(adap->uld_handle[i],
CXGB4_STATE_DETACH);
adap->uld_handle[i] = NULL;
}
if (netevent_registered && list_empty(&adapter_list)) {
unregister_netevent_notifier(&cxgb4_netevent_nb);
netevent_registered = false;
}
mutex_unlock(&uld_mutex);
spin_lock(&adap_rcu_lock);
list_del_rcu(&adap->rcu_node);
spin_unlock(&adap_rcu_lock);
}
static void notify_ulds(struct adapter *adap, enum cxgb4_state new_state)
{
unsigned int i;
mutex_lock(&uld_mutex);
for (i = 0; i < CXGB4_ULD_MAX; i++)
if (adap->uld_handle[i])
ulds[i].state_change(adap->uld_handle[i], new_state);
mutex_unlock(&uld_mutex);
}
/**
* cxgb4_register_uld - register an upper-layer driver
* @type: the ULD type
* @p: the ULD methods
*
* Registers an upper-layer driver with this driver and notifies the ULD
* about any presently available devices that support its type. Returns
* %-EBUSY if a ULD of the same type is already registered.
*/
int cxgb4_register_uld(enum cxgb4_uld type, const struct cxgb4_uld_info *p)
{
int ret = 0;
struct adapter *adap;
if (type >= CXGB4_ULD_MAX)
return -EINVAL;
mutex_lock(&uld_mutex);
if (ulds[type].add) {
ret = -EBUSY;
goto out;
}
ulds[type] = *p;
list_for_each_entry(adap, &adapter_list, list_node)
uld_attach(adap, type);
out: mutex_unlock(&uld_mutex);
return ret;
}
EXPORT_SYMBOL(cxgb4_register_uld);
/**
* cxgb4_unregister_uld - unregister an upper-layer driver
* @type: the ULD type
*
* Unregisters an existing upper-layer driver.
*/
int cxgb4_unregister_uld(enum cxgb4_uld type)
{
struct adapter *adap;
if (type >= CXGB4_ULD_MAX)
return -EINVAL;
mutex_lock(&uld_mutex);
list_for_each_entry(adap, &adapter_list, list_node)
adap->uld_handle[type] = NULL;
ulds[type].add = NULL;
mutex_unlock(&uld_mutex);
return 0;
}
EXPORT_SYMBOL(cxgb4_unregister_uld);
/* Check if netdev on which event is occured belongs to us or not. Return
* success (true) if it belongs otherwise failure (false).
* Called with rcu_read_lock() held.
*/
static bool cxgb4_netdev(const struct net_device *netdev)
{
struct adapter *adap;
int i;
list_for_each_entry_rcu(adap, &adap_rcu_list, rcu_node)
for (i = 0; i < MAX_NPORTS; i++)
if (adap->port[i] == netdev)
return true;
return false;
}
static int clip_add(struct net_device *event_dev, struct inet6_ifaddr *ifa,
unsigned long event)
{
int ret = NOTIFY_DONE;
rcu_read_lock();
if (cxgb4_netdev(event_dev)) {
switch (event) {
case NETDEV_UP:
ret = cxgb4_clip_get(event_dev,
(const struct in6_addr *)ifa->addr.s6_addr);
if (ret < 0) {
rcu_read_unlock();
return ret;
}
ret = NOTIFY_OK;
break;
case NETDEV_DOWN:
cxgb4_clip_release(event_dev,
(const struct in6_addr *)ifa->addr.s6_addr);
ret = NOTIFY_OK;
break;
default:
break;
}
}
rcu_read_unlock();
return ret;
}
static int cxgb4_inet6addr_handler(struct notifier_block *this,
unsigned long event, void *data)
{
struct inet6_ifaddr *ifa = data;
struct net_device *event_dev;
int ret = NOTIFY_DONE;
struct bonding *bond = netdev_priv(ifa->idev->dev);
struct list_head *iter;
struct slave *slave;
struct pci_dev *first_pdev = NULL;
if (ifa->idev->dev->priv_flags & IFF_802_1Q_VLAN) {
event_dev = vlan_dev_real_dev(ifa->idev->dev);
ret = clip_add(event_dev, ifa, event);
} else if (ifa->idev->dev->flags & IFF_MASTER) {
/* It is possible that two different adapters are bonded in one
* bond. We need to find such different adapters and add clip
* in all of them only once.
*/
read_lock(&bond->lock);
bond_for_each_slave(bond, slave, iter) {
if (!first_pdev) {
ret = clip_add(slave->dev, ifa, event);
/* If clip_add is success then only initialize
* first_pdev since it means it is our device
*/
if (ret == NOTIFY_OK)
first_pdev = to_pci_dev(
slave->dev->dev.parent);
} else if (first_pdev !=
to_pci_dev(slave->dev->dev.parent))
ret = clip_add(slave->dev, ifa, event);
}
read_unlock(&bond->lock);
} else
ret = clip_add(ifa->idev->dev, ifa, event);
return ret;
}
static struct notifier_block cxgb4_inet6addr_notifier = {
.notifier_call = cxgb4_inet6addr_handler
};
/* Retrieves IPv6 addresses from a root device (bond, vlan) associated with
* a physical device.
* The physical device reference is needed to send the actul CLIP command.
*/
static int update_dev_clip(struct net_device *root_dev, struct net_device *dev)
{
struct inet6_dev *idev = NULL;
struct inet6_ifaddr *ifa;
int ret = 0;
idev = __in6_dev_get(root_dev);
if (!idev)
return ret;
read_lock_bh(&idev->lock);
list_for_each_entry(ifa, &idev->addr_list, if_list) {
ret = cxgb4_clip_get(dev,
(const struct in6_addr *)ifa->addr.s6_addr);
if (ret < 0)
break;
}
read_unlock_bh(&idev->lock);
return ret;
}
static int update_root_dev_clip(struct net_device *dev)
{
struct net_device *root_dev = NULL;
int i, ret = 0;
/* First populate the real net device's IPv6 addresses */
ret = update_dev_clip(dev, dev);
if (ret)
return ret;
/* Parse all bond and vlan devices layered on top of the physical dev */
for (i = 0; i < VLAN_N_VID; i++) {
root_dev = __vlan_find_dev_deep_rcu(dev, htons(ETH_P_8021Q), i);
if (!root_dev)
continue;
ret = update_dev_clip(root_dev, dev);
if (ret)
break;
}
return ret;
}
static void update_clip(const struct adapter *adap)
{
int i;
struct net_device *dev;
int ret;
rcu_read_lock();
for (i = 0; i < MAX_NPORTS; i++) {
dev = adap->port[i];
ret = 0;
if (dev)
ret = update_root_dev_clip(dev);
if (ret < 0)
break;
}
rcu_read_unlock();
}
/**
* cxgb_up - enable the adapter
* @adap: adapter being enabled
*
* Called when the first port is enabled, this function performs the
* actions necessary to make an adapter operational, such as completing
* the initialization of HW modules, and enabling interrupts.
*
* Must be called with the rtnl lock held.
*/
static int cxgb_up(struct adapter *adap)
{
int err;
err = setup_sge_queues(adap);
if (err)
goto out;
err = setup_rss(adap);
if (err)
goto freeq;
if (adap->flags & USING_MSIX) {
name_msix_vecs(adap);
err = request_irq(adap->msix_info[0].vec, t4_nondata_intr, 0,
adap->msix_info[0].desc, adap);
if (err)
goto irq_err;
err = request_msix_queue_irqs(adap);
if (err) {
free_irq(adap->msix_info[0].vec, adap);
goto irq_err;
}
} else {
err = request_irq(adap->pdev->irq, t4_intr_handler(adap),
(adap->flags & USING_MSI) ? 0 : IRQF_SHARED,
adap->port[0]->name, adap);
if (err)
goto irq_err;
}
enable_rx(adap);
t4_sge_start(adap);
t4_intr_enable(adap);
adap->flags |= FULL_INIT_DONE;
notify_ulds(adap, CXGB4_STATE_UP);
update_clip(adap);
out:
return err;
irq_err:
dev_err(adap->pdev_dev, "request_irq failed, err %d\n", err);
freeq:
t4_free_sge_resources(adap);
goto out;
}
static void cxgb_down(struct adapter *adapter)
{
t4_intr_disable(adapter);
cancel_work_sync(&adapter->tid_release_task);
cancel_work_sync(&adapter->db_full_task);
cancel_work_sync(&adapter->db_drop_task);
adapter->tid_release_task_busy = false;
adapter->tid_release_head = NULL;
if (adapter->flags & USING_MSIX) {
free_msix_queue_irqs(adapter);
free_irq(adapter->msix_info[0].vec, adapter);
} else
free_irq(adapter->pdev->irq, adapter);
quiesce_rx(adapter);
t4_sge_stop(adapter);
t4_free_sge_resources(adapter);
adapter->flags &= ~FULL_INIT_DONE;
}
/*
* net_device operations
*/
static int cxgb_open(struct net_device *dev)
{
int err;
struct port_info *pi = netdev_priv(dev);
struct adapter *adapter = pi->adapter;
netif_carrier_off(dev);
if (!(adapter->flags & FULL_INIT_DONE)) {
err = cxgb_up(adapter);
if (err < 0)
return err;
}
err = link_start(dev);
if (!err)
netif_tx_start_all_queues(dev);
return err;
}
static int cxgb_close(struct net_device *dev)
{
struct port_info *pi = netdev_priv(dev);
struct adapter *adapter = pi->adapter;
netif_tx_stop_all_queues(dev);
netif_carrier_off(dev);
return t4_enable_vi(adapter, adapter->fn, pi->viid, false, false);
}
/* Return an error number if the indicated filter isn't writable ...
*/
static int writable_filter(struct filter_entry *f)
{
if (f->locked)
return -EPERM;
if (f->pending)
return -EBUSY;
return 0;
}
/* Delete the filter at the specified index (if valid). The checks for all
* the common problems with doing this like the filter being locked, currently
* pending in another operation, etc.
*/
static int delete_filter(struct adapter *adapter, unsigned int fidx)
{
struct filter_entry *f;
int ret;
if (fidx >= adapter->tids.nftids + adapter->tids.nsftids)
return -EINVAL;
f = &adapter->tids.ftid_tab[fidx];
ret = writable_filter(f);
if (ret)
return ret;
if (f->valid)
return del_filter_wr(adapter, fidx);
return 0;
}
int cxgb4_create_server_filter(const struct net_device *dev, unsigned int stid,
__be32 sip, __be16 sport, __be16 vlan,
unsigned int queue, unsigned char port, unsigned char mask)
{
int ret;
struct filter_entry *f;
struct adapter *adap;
int i;
u8 *val;
adap = netdev2adap(dev);
/* Adjust stid to correct filter index */
stid -= adap->tids.sftid_base;
stid += adap->tids.nftids;
/* Check to make sure the filter requested is writable ...
*/
f = &adap->tids.ftid_tab[stid];
ret = writable_filter(f);
if (ret)
return ret;
/* Clear out any old resources being used by the filter before
* we start constructing the new filter.
*/
if (f->valid)
clear_filter(adap, f);
/* Clear out filter specifications */
memset(&f->fs, 0, sizeof(struct ch_filter_specification));
f->fs.val.lport = cpu_to_be16(sport);
f->fs.mask.lport = ~0;
val = (u8 *)&sip;
if ((val[0] | val[1] | val[2] | val[3]) != 0) {
for (i = 0; i < 4; i++) {
f->fs.val.lip[i] = val[i];
f->fs.mask.lip[i] = ~0;
}
if (adap->params.tp.vlan_pri_map & F_PORT) {
f->fs.val.iport = port;
f->fs.mask.iport = mask;
}
}
if (adap->params.tp.vlan_pri_map & F_PROTOCOL) {
f->fs.val.proto = IPPROTO_TCP;
f->fs.mask.proto = ~0;
}
f->fs.dirsteer = 1;
f->fs.iq = queue;
/* Mark filter as locked */
f->locked = 1;
f->fs.rpttid = 1;
ret = set_filter_wr(adap, stid);
if (ret) {
clear_filter(adap, f);
return ret;
}
return 0;
}
EXPORT_SYMBOL(cxgb4_create_server_filter);
int cxgb4_remove_server_filter(const struct net_device *dev, unsigned int stid,
unsigned int queue, bool ipv6)
{
int ret;
struct filter_entry *f;
struct adapter *adap;
adap = netdev2adap(dev);
/* Adjust stid to correct filter index */
stid -= adap->tids.sftid_base;
stid += adap->tids.nftids;
f = &adap->tids.ftid_tab[stid];
/* Unlock the filter */
f->locked = 0;
ret = delete_filter(adap, stid);
if (ret)
return ret;
return 0;
}
EXPORT_SYMBOL(cxgb4_remove_server_filter);
static struct rtnl_link_stats64 *cxgb_get_stats(struct net_device *dev,
struct rtnl_link_stats64 *ns)
{
struct port_stats stats;
struct port_info *p = netdev_priv(dev);
struct adapter *adapter = p->adapter;
/* Block retrieving statistics during EEH error
* recovery. Otherwise, the recovery might fail
* and the PCI device will be removed permanently
*/
spin_lock(&adapter->stats_lock);
if (!netif_device_present(dev)) {
spin_unlock(&adapter->stats_lock);
return ns;
}
t4_get_port_stats(adapter, p->tx_chan, &stats);
spin_unlock(&adapter->stats_lock);
ns->tx_bytes = stats.tx_octets;
ns->tx_packets = stats.tx_frames;
ns->rx_bytes = stats.rx_octets;
ns->rx_packets = stats.rx_frames;
ns->multicast = stats.rx_mcast_frames;
/* detailed rx_errors */
ns->rx_length_errors = stats.rx_jabber + stats.rx_too_long +
stats.rx_runt;
ns->rx_over_errors = 0;
ns->rx_crc_errors = stats.rx_fcs_err;
ns->rx_frame_errors = stats.rx_symbol_err;
ns->rx_fifo_errors = stats.rx_ovflow0 + stats.rx_ovflow1 +
stats.rx_ovflow2 + stats.rx_ovflow3 +
stats.rx_trunc0 + stats.rx_trunc1 +
stats.rx_trunc2 + stats.rx_trunc3;
ns->rx_missed_errors = 0;
/* detailed tx_errors */
ns->tx_aborted_errors = 0;
ns->tx_carrier_errors = 0;
ns->tx_fifo_errors = 0;
ns->tx_heartbeat_errors = 0;
ns->tx_window_errors = 0;
ns->tx_errors = stats.tx_error_frames;
ns->rx_errors = stats.rx_symbol_err + stats.rx_fcs_err +
ns->rx_length_errors + stats.rx_len_err + ns->rx_fifo_errors;
return ns;
}
static int cxgb_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
{
unsigned int mbox;
int ret = 0, prtad, devad;
struct port_info *pi = netdev_priv(dev);
struct mii_ioctl_data *data = (struct mii_ioctl_data *)&req->ifr_data;
switch (cmd) {
case SIOCGMIIPHY:
if (pi->mdio_addr < 0)
return -EOPNOTSUPP;
data->phy_id = pi->mdio_addr;
break;
case SIOCGMIIREG:
case SIOCSMIIREG:
if (mdio_phy_id_is_c45(data->phy_id)) {
prtad = mdio_phy_id_prtad(data->phy_id);
devad = mdio_phy_id_devad(data->phy_id);
} else if (data->phy_id < 32) {
prtad = data->phy_id;
devad = 0;
data->reg_num &= 0x1f;
} else
return -EINVAL;
mbox = pi->adapter->fn;
if (cmd == SIOCGMIIREG)
ret = t4_mdio_rd(pi->adapter, mbox, prtad, devad,
data->reg_num, &data->val_out);
else
ret = t4_mdio_wr(pi->adapter, mbox, prtad, devad,
data->reg_num, data->val_in);
break;
default:
return -EOPNOTSUPP;
}
return ret;
}
static void cxgb_set_rxmode(struct net_device *dev)
{
/* unfortunately we can't return errors to the stack */
set_rxmode(dev, -1, false);
}
static int cxgb_change_mtu(struct net_device *dev, int new_mtu)
{
int ret;
struct port_info *pi = netdev_priv(dev);
if (new_mtu < 81 || new_mtu > MAX_MTU) /* accommodate SACK */
return -EINVAL;
ret = t4_set_rxmode(pi->adapter, pi->adapter->fn, pi->viid, new_mtu, -1,
-1, -1, -1, true);
if (!ret)
dev->mtu = new_mtu;
return ret;
}
static int cxgb_set_mac_addr(struct net_device *dev, void *p)
{
int ret;
struct sockaddr *addr = p;
struct port_info *pi = netdev_priv(dev);
if (!is_valid_ether_addr(addr->sa_data))
return -EADDRNOTAVAIL;
ret = t4_change_mac(pi->adapter, pi->adapter->fn, pi->viid,
pi->xact_addr_filt, addr->sa_data, true, true);
if (ret < 0)
return ret;
memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
pi->xact_addr_filt = ret;
return 0;
}
#ifdef CONFIG_NET_POLL_CONTROLLER
static void cxgb_netpoll(struct net_device *dev)
{
struct port_info *pi = netdev_priv(dev);
struct adapter *adap = pi->adapter;
if (adap->flags & USING_MSIX) {
int i;
struct sge_eth_rxq *rx = &adap->sge.ethrxq[pi->first_qset];
for (i = pi->nqsets; i; i--, rx++)
t4_sge_intr_msix(0, &rx->rspq);
} else
t4_intr_handler(adap)(0, adap);
}
#endif
static const struct net_device_ops cxgb4_netdev_ops = {
.ndo_open = cxgb_open,
.ndo_stop = cxgb_close,
.ndo_start_xmit = t4_eth_xmit,
.ndo_select_queue = cxgb_select_queue,
.ndo_get_stats64 = cxgb_get_stats,
.ndo_set_rx_mode = cxgb_set_rxmode,
.ndo_set_mac_address = cxgb_set_mac_addr,
.ndo_set_features = cxgb_set_features,
.ndo_validate_addr = eth_validate_addr,
.ndo_do_ioctl = cxgb_ioctl,
.ndo_change_mtu = cxgb_change_mtu,
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = cxgb_netpoll,
#endif
};
void t4_fatal_err(struct adapter *adap)
{
t4_set_reg_field(adap, SGE_CONTROL, GLOBALENABLE, 0);
t4_intr_disable(adap);
dev_alert(adap->pdev_dev, "encountered fatal error, adapter stopped\n");
}
/* Return the specified PCI-E Configuration Space register from our Physical
* Function. We try first via a Firmware LDST Command since we prefer to let
* the firmware own all of these registers, but if that fails we go for it
* directly ourselves.
*/
static u32 t4_read_pcie_cfg4(struct adapter *adap, int reg)
{
struct fw_ldst_cmd ldst_cmd;
u32 val;
int ret;
/* Construct and send the Firmware LDST Command to retrieve the
* specified PCI-E Configuration Space register.
*/
memset(&ldst_cmd, 0, sizeof(ldst_cmd));
ldst_cmd.op_to_addrspace =
htonl(FW_CMD_OP(FW_LDST_CMD) |
FW_CMD_REQUEST |
FW_CMD_READ |
FW_LDST_CMD_ADDRSPACE(FW_LDST_ADDRSPC_FUNC_PCIE));
ldst_cmd.cycles_to_len16 = htonl(FW_LEN16(ldst_cmd));
ldst_cmd.u.pcie.select_naccess = FW_LDST_CMD_NACCESS(1);
ldst_cmd.u.pcie.ctrl_to_fn =
(FW_LDST_CMD_LC | FW_LDST_CMD_FN(adap->fn));
ldst_cmd.u.pcie.r = reg;
ret = t4_wr_mbox(adap, adap->mbox, &ldst_cmd, sizeof(ldst_cmd),
&ldst_cmd);
/* If the LDST Command suucceeded, exctract the returned register
* value. Otherwise read it directly ourself.
*/
if (ret == 0)
val = ntohl(ldst_cmd.u.pcie.data[0]);
else
t4_hw_pci_read_cfg4(adap, reg, &val);
return val;
}
static void setup_memwin(struct adapter *adap)
{
u32 mem_win0_base, mem_win1_base, mem_win2_base, mem_win2_aperture;
if (is_t4(adap->params.chip)) {
u32 bar0;
/* Truncation intentional: we only read the bottom 32-bits of
* the 64-bit BAR0/BAR1 ... We use the hardware backdoor
* mechanism to read BAR0 instead of using
* pci_resource_start() because we could be operating from
* within a Virtual Machine which is trapping our accesses to
* our Configuration Space and we need to set up the PCI-E
* Memory Window decoders with the actual addresses which will
* be coming across the PCI-E link.
*/
bar0 = t4_read_pcie_cfg4(adap, PCI_BASE_ADDRESS_0);
bar0 &= PCI_BASE_ADDRESS_MEM_MASK;
adap->t4_bar0 = bar0;
mem_win0_base = bar0 + MEMWIN0_BASE;
mem_win1_base = bar0 + MEMWIN1_BASE;
mem_win2_base = bar0 + MEMWIN2_BASE;
mem_win2_aperture = MEMWIN2_APERTURE;
} else {
/* For T5, only relative offset inside the PCIe BAR is passed */
mem_win0_base = MEMWIN0_BASE;
mem_win1_base = MEMWIN1_BASE;
mem_win2_base = MEMWIN2_BASE_T5;
mem_win2_aperture = MEMWIN2_APERTURE_T5;
}
t4_write_reg(adap, PCIE_MEM_ACCESS_REG(PCIE_MEM_ACCESS_BASE_WIN, 0),
mem_win0_base | BIR(0) |
WINDOW(ilog2(MEMWIN0_APERTURE) - 10));
t4_write_reg(adap, PCIE_MEM_ACCESS_REG(PCIE_MEM_ACCESS_BASE_WIN, 1),
mem_win1_base | BIR(0) |
WINDOW(ilog2(MEMWIN1_APERTURE) - 10));
t4_write_reg(adap, PCIE_MEM_ACCESS_REG(PCIE_MEM_ACCESS_BASE_WIN, 2),
mem_win2_base | BIR(0) |
WINDOW(ilog2(mem_win2_aperture) - 10));
t4_read_reg(adap, PCIE_MEM_ACCESS_REG(PCIE_MEM_ACCESS_BASE_WIN, 2));
}
static void setup_memwin_rdma(struct adapter *adap)
{
if (adap->vres.ocq.size) {
u32 start;
unsigned int sz_kb;
start = t4_read_pcie_cfg4(adap, PCI_BASE_ADDRESS_2);
start &= PCI_BASE_ADDRESS_MEM_MASK;
start += OCQ_WIN_OFFSET(adap->pdev, &adap->vres);
sz_kb = roundup_pow_of_two(adap->vres.ocq.size) >> 10;
t4_write_reg(adap,
PCIE_MEM_ACCESS_REG(PCIE_MEM_ACCESS_BASE_WIN, 3),
start | BIR(1) | WINDOW(ilog2(sz_kb)));
t4_write_reg(adap,
PCIE_MEM_ACCESS_REG(PCIE_MEM_ACCESS_OFFSET, 3),
adap->vres.ocq.start);
t4_read_reg(adap,
PCIE_MEM_ACCESS_REG(PCIE_MEM_ACCESS_OFFSET, 3));
}
}
static int adap_init1(struct adapter *adap, struct fw_caps_config_cmd *c)
{
u32 v;
int ret;
/* get device capabilities */
memset(c, 0, sizeof(*c));
c->op_to_write = htonl(FW_CMD_OP(FW_CAPS_CONFIG_CMD) |
FW_CMD_REQUEST | FW_CMD_READ);
c->cfvalid_to_len16 = htonl(FW_LEN16(*c));
ret = t4_wr_mbox(adap, adap->fn, c, sizeof(*c), c);
if (ret < 0)
return ret;
/* select capabilities we'll be using */
if (c->niccaps & htons(FW_CAPS_CONFIG_NIC_VM)) {
if (!vf_acls)
c->niccaps ^= htons(FW_CAPS_CONFIG_NIC_VM);
else
c->niccaps = htons(FW_CAPS_CONFIG_NIC_VM);
} else if (vf_acls) {
dev_err(adap->pdev_dev, "virtualization ACLs not supported");
return ret;
}
c->op_to_write = htonl(FW_CMD_OP(FW_CAPS_CONFIG_CMD) |
FW_CMD_REQUEST | FW_CMD_WRITE);
ret = t4_wr_mbox(adap, adap->fn, c, sizeof(*c), NULL);
if (ret < 0)
return ret;
ret = t4_config_glbl_rss(adap, adap->fn,
FW_RSS_GLB_CONFIG_CMD_MODE_BASICVIRTUAL,
FW_RSS_GLB_CONFIG_CMD_TNLMAPEN |
FW_RSS_GLB_CONFIG_CMD_TNLALLLKP);
if (ret < 0)
return ret;
ret = t4_cfg_pfvf(adap, adap->fn, adap->fn, 0, MAX_EGRQ, 64, MAX_INGQ,
0, 0, 4, 0xf, 0xf, 16, FW_CMD_CAP_PF, FW_CMD_CAP_PF);
if (ret < 0)
return ret;
t4_sge_init(adap);
/* tweak some settings */
t4_write_reg(adap, TP_SHIFT_CNT, 0x64f8849);
t4_write_reg(adap, ULP_RX_TDDP_PSZ, HPZ0(PAGE_SHIFT - 12));
t4_write_reg(adap, TP_PIO_ADDR, TP_INGRESS_CONFIG);
v = t4_read_reg(adap, TP_PIO_DATA);
t4_write_reg(adap, TP_PIO_DATA, v & ~CSUM_HAS_PSEUDO_HDR);
/* first 4 Tx modulation queues point to consecutive Tx channels */
adap->params.tp.tx_modq_map = 0xE4;
t4_write_reg(adap, A_TP_TX_MOD_QUEUE_REQ_MAP,
V_TX_MOD_QUEUE_REQ_MAP(adap->params.tp.tx_modq_map));
/* associate each Tx modulation queue with consecutive Tx channels */
v = 0x84218421;
t4_write_indirect(adap, TP_PIO_ADDR, TP_PIO_DATA,
&v, 1, A_TP_TX_SCHED_HDR);
t4_write_indirect(adap, TP_PIO_ADDR, TP_PIO_DATA,
&v, 1, A_TP_TX_SCHED_FIFO);
t4_write_indirect(adap, TP_PIO_ADDR, TP_PIO_DATA,
&v, 1, A_TP_TX_SCHED_PCMD);
#define T4_TX_MODQ_10G_WEIGHT_DEFAULT 16 /* in KB units */
if (is_offload(adap)) {
t4_write_reg(adap, A_TP_TX_MOD_QUEUE_WEIGHT0,
V_TX_MODQ_WEIGHT0(T4_TX_MODQ_10G_WEIGHT_DEFAULT) |
V_TX_MODQ_WEIGHT1(T4_TX_MODQ_10G_WEIGHT_DEFAULT) |
V_TX_MODQ_WEIGHT2(T4_TX_MODQ_10G_WEIGHT_DEFAULT) |
V_TX_MODQ_WEIGHT3(T4_TX_MODQ_10G_WEIGHT_DEFAULT));
t4_write_reg(adap, A_TP_TX_MOD_CHANNEL_WEIGHT,
V_TX_MODQ_WEIGHT0(T4_TX_MODQ_10G_WEIGHT_DEFAULT) |
V_TX_MODQ_WEIGHT1(T4_TX_MODQ_10G_WEIGHT_DEFAULT) |
V_TX_MODQ_WEIGHT2(T4_TX_MODQ_10G_WEIGHT_DEFAULT) |
V_TX_MODQ_WEIGHT3(T4_TX_MODQ_10G_WEIGHT_DEFAULT));
}
/* get basic stuff going */
return t4_early_init(adap, adap->fn);
}
/*
* Max # of ATIDs. The absolute HW max is 16K but we keep it lower.
*/
#define MAX_ATIDS 8192U
/*
* Phase 0 of initialization: contact FW, obtain config, perform basic init.
*
* If the firmware we're dealing with has Configuration File support, then
* we use that to perform all configuration
*/
/*
* Tweak configuration based on module parameters, etc. Most of these have
* defaults assigned to them by Firmware Configuration Files (if we're using
* them) but need to be explicitly set if we're using hard-coded
* initialization. But even in the case of using Firmware Configuration
* Files, we'd like to expose the ability to change these via module
* parameters so these are essentially common tweaks/settings for
* Configuration Files and hard-coded initialization ...
*/
static int adap_init0_tweaks(struct adapter *adapter)
{
/*
* Fix up various Host-Dependent Parameters like Page Size, Cache
* Line Size, etc. The firmware default is for a 4KB Page Size and
* 64B Cache Line Size ...
*/
t4_fixup_host_params(adapter, PAGE_SIZE, L1_CACHE_BYTES);
/*
* Process module parameters which affect early initialization.
*/
if (rx_dma_offset != 2 && rx_dma_offset != 0) {
dev_err(&adapter->pdev->dev,
"Ignoring illegal rx_dma_offset=%d, using 2\n",
rx_dma_offset);
rx_dma_offset = 2;
}
t4_set_reg_field(adapter, SGE_CONTROL,
PKTSHIFT_MASK,
PKTSHIFT(rx_dma_offset));
/*
* Don't include the "IP Pseudo Header" in CPL_RX_PKT checksums: Linux
* adds the pseudo header itself.
*/
t4_tp_wr_bits_indirect(adapter, TP_INGRESS_CONFIG,
CSUM_HAS_PSEUDO_HDR, 0);
return 0;
}
/*
* Attempt to initialize the adapter via a Firmware Configuration File.
*/
static int adap_init0_config(struct adapter *adapter, int reset)
{
struct fw_caps_config_cmd caps_cmd;
const struct firmware *cf;
unsigned long mtype = 0, maddr = 0;
u32 finiver, finicsum, cfcsum;
int ret;
int config_issued = 0;
char *fw_config_file, fw_config_file_path[256];
char *config_name = NULL;
/*
* Reset device if necessary.
*/
if (reset) {
ret = t4_fw_reset(adapter, adapter->mbox,
PIORSTMODE | PIORST);
if (ret < 0)
goto bye;
}
/*
* If we have a T4 configuration file under /lib/firmware/cxgb4/,
* then use that. Otherwise, use the configuration file stored
* in the adapter flash ...
*/
switch (CHELSIO_CHIP_VERSION(adapter->params.chip)) {
case CHELSIO_T4:
fw_config_file = FW4_CFNAME;
break;
case CHELSIO_T5:
fw_config_file = FW5_CFNAME;
break;
default:
dev_err(adapter->pdev_dev, "Device %d is not supported\n",
adapter->pdev->device);
ret = -EINVAL;
goto bye;
}
ret = request_firmware(&cf, fw_config_file, adapter->pdev_dev);
if (ret < 0) {
config_name = "On FLASH";
mtype = FW_MEMTYPE_CF_FLASH;
maddr = t4_flash_cfg_addr(adapter);
} else {
u32 params[7], val[7];
sprintf(fw_config_file_path,
"/lib/firmware/%s", fw_config_file);
config_name = fw_config_file_path;
if (cf->size >= FLASH_CFG_MAX_SIZE)
ret = -ENOMEM;
else {
params[0] = (FW_PARAMS_MNEM(FW_PARAMS_MNEM_DEV) |
FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DEV_CF));
ret = t4_query_params(adapter, adapter->mbox,
adapter->fn, 0, 1, params, val);
if (ret == 0) {
/*
* For t4_memory_rw() below addresses and
* sizes have to be in terms of multiples of 4
* bytes. So, if the Configuration File isn't
* a multiple of 4 bytes in length we'll have
* to write that out separately since we can't
* guarantee that the bytes following the
* residual byte in the buffer returned by
* request_firmware() are zeroed out ...
*/
size_t resid = cf->size & 0x3;
size_t size = cf->size & ~0x3;
__be32 *data = (__be32 *)cf->data;
mtype = FW_PARAMS_PARAM_Y_GET(val[0]);
maddr = FW_PARAMS_PARAM_Z_GET(val[0]) << 16;
spin_lock(&adapter->win0_lock);
ret = t4_memory_rw(adapter, 0, mtype, maddr,
size, data, T4_MEMORY_WRITE);
if (ret == 0 && resid != 0) {
union {
__be32 word;
char buf[4];
} last;
int i;
last.word = data[size >> 2];
for (i = resid; i < 4; i++)
last.buf[i] = 0;
ret = t4_memory_rw(adapter, 0, mtype,
maddr + size,
4, &last.word,
T4_MEMORY_WRITE);
}
spin_unlock(&adapter->win0_lock);
}
}
release_firmware(cf);
if (ret)
goto bye;
}
/*
* Issue a Capability Configuration command to the firmware to get it
* to parse the Configuration File. We don't use t4_fw_config_file()
* because we want the ability to modify various features after we've
* processed the configuration file ...
*/
memset(&caps_cmd, 0, sizeof(caps_cmd));
caps_cmd.op_to_write =
htonl(FW_CMD_OP(FW_CAPS_CONFIG_CMD) |
FW_CMD_REQUEST |
FW_CMD_READ);
caps_cmd.cfvalid_to_len16 =
htonl(FW_CAPS_CONFIG_CMD_CFVALID |
FW_CAPS_CONFIG_CMD_MEMTYPE_CF(mtype) |
FW_CAPS_CONFIG_CMD_MEMADDR64K_CF(maddr >> 16) |
FW_LEN16(caps_cmd));
ret = t4_wr_mbox(adapter, adapter->mbox, &caps_cmd, sizeof(caps_cmd),
&caps_cmd);
/* If the CAPS_CONFIG failed with an ENOENT (for a Firmware
* Configuration File in FLASH), our last gasp effort is to use the
* Firmware Configuration File which is embedded in the firmware. A
* very few early versions of the firmware didn't have one embedded
* but we can ignore those.
*/
if (ret == -ENOENT) {
memset(&caps_cmd, 0, sizeof(caps_cmd));
caps_cmd.op_to_write =
htonl(FW_CMD_OP(FW_CAPS_CONFIG_CMD) |
FW_CMD_REQUEST |
FW_CMD_READ);
caps_cmd.cfvalid_to_len16 = htonl(FW_LEN16(caps_cmd));
ret = t4_wr_mbox(adapter, adapter->mbox, &caps_cmd,
sizeof(caps_cmd), &caps_cmd);
config_name = "Firmware Default";
}
config_issued = 1;
if (ret < 0)
goto bye;
finiver = ntohl(caps_cmd.finiver);
finicsum = ntohl(caps_cmd.finicsum);
cfcsum = ntohl(caps_cmd.cfcsum);
if (finicsum != cfcsum)
dev_warn(adapter->pdev_dev, "Configuration File checksum "\
"mismatch: [fini] csum=%#x, computed csum=%#x\n",
finicsum, cfcsum);
/*
* And now tell the firmware to use the configuration we just loaded.
*/
caps_cmd.op_to_write =
htonl(FW_CMD_OP(FW_CAPS_CONFIG_CMD) |
FW_CMD_REQUEST |
FW_CMD_WRITE);
caps_cmd.cfvalid_to_len16 = htonl(FW_LEN16(caps_cmd));
ret = t4_wr_mbox(adapter, adapter->mbox, &caps_cmd, sizeof(caps_cmd),
NULL);
if (ret < 0)
goto bye;
/*
* Tweak configuration based on system architecture, module
* parameters, etc.
*/
ret = adap_init0_tweaks(adapter);
if (ret < 0)
goto bye;
/*
* And finally tell the firmware to initialize itself using the
* parameters from the Configuration File.
*/
ret = t4_fw_initialize(adapter, adapter->mbox);
if (ret < 0)
goto bye;
/*
* Return successfully and note that we're operating with parameters
* not supplied by the driver, rather than from hard-wired
* initialization constants burried in the driver.
*/
adapter->flags |= USING_SOFT_PARAMS;
dev_info(adapter->pdev_dev, "Successfully configured using Firmware "\
"Configuration File \"%s\", version %#x, computed checksum %#x\n",
config_name, finiver, cfcsum);
return 0;
/*
* Something bad happened. Return the error ... (If the "error"
* is that there's no Configuration File on the adapter we don't
* want to issue a warning since this is fairly common.)
*/
bye:
if (config_issued && ret != -ENOENT)
dev_warn(adapter->pdev_dev, "\"%s\" configuration file error %d\n",
config_name, -ret);
return ret;
}
/*
* Attempt to initialize the adapter via hard-coded, driver supplied
* parameters ...
*/
static int adap_init0_no_config(struct adapter *adapter, int reset)
{
struct sge *s = &adapter->sge;
struct fw_caps_config_cmd caps_cmd;
u32 v;
int i, ret;
/*
* Reset device if necessary
*/
if (reset) {
ret = t4_fw_reset(adapter, adapter->mbox,
PIORSTMODE | PIORST);
if (ret < 0)
goto bye;
}
/*
* Get device capabilities and select which we'll be using.
*/
memset(&caps_cmd, 0, sizeof(caps_cmd));
caps_cmd.op_to_write = htonl(FW_CMD_OP(FW_CAPS_CONFIG_CMD) |
FW_CMD_REQUEST | FW_CMD_READ);
caps_cmd.cfvalid_to_len16 = htonl(FW_LEN16(caps_cmd));
ret = t4_wr_mbox(adapter, adapter->mbox, &caps_cmd, sizeof(caps_cmd),
&caps_cmd);
if (ret < 0)
goto bye;
if (caps_cmd.niccaps & htons(FW_CAPS_CONFIG_NIC_VM)) {
if (!vf_acls)
caps_cmd.niccaps ^= htons(FW_CAPS_CONFIG_NIC_VM);
else
caps_cmd.niccaps = htons(FW_CAPS_CONFIG_NIC_VM);
} else if (vf_acls) {
dev_err(adapter->pdev_dev, "virtualization ACLs not supported");
goto bye;
}
caps_cmd.op_to_write = htonl(FW_CMD_OP(FW_CAPS_CONFIG_CMD) |
FW_CMD_REQUEST | FW_CMD_WRITE);
ret = t4_wr_mbox(adapter, adapter->mbox, &caps_cmd, sizeof(caps_cmd),
NULL);
if (ret < 0)
goto bye;
/*
* Tweak configuration based on system architecture, module
* parameters, etc.
*/
ret = adap_init0_tweaks(adapter);
if (ret < 0)
goto bye;
/*
* Select RSS Global Mode we want to use. We use "Basic Virtual"
* mode which maps each Virtual Interface to its own section of
* the RSS Table and we turn on all map and hash enables ...
*/
adapter->flags |= RSS_TNLALLLOOKUP;
ret = t4_config_glbl_rss(adapter, adapter->mbox,
FW_RSS_GLB_CONFIG_CMD_MODE_BASICVIRTUAL,
FW_RSS_GLB_CONFIG_CMD_TNLMAPEN |
FW_RSS_GLB_CONFIG_CMD_HASHTOEPLITZ |
((adapter->flags & RSS_TNLALLLOOKUP) ?
FW_RSS_GLB_CONFIG_CMD_TNLALLLKP : 0));
if (ret < 0)
goto bye;
/*
* Set up our own fundamental resource provisioning ...
*/
ret = t4_cfg_pfvf(adapter, adapter->mbox, adapter->fn, 0,
PFRES_NEQ, PFRES_NETHCTRL,
PFRES_NIQFLINT, PFRES_NIQ,
PFRES_TC, PFRES_NVI,
FW_PFVF_CMD_CMASK_MASK,
pfvfres_pmask(adapter, adapter->fn, 0),
PFRES_NEXACTF,
PFRES_R_CAPS, PFRES_WX_CAPS);
if (ret < 0)
goto bye;
/*
* Perform low level SGE initialization. We need to do this before we
* send the firmware the INITIALIZE command because that will cause
* any other PF Drivers which are waiting for the Master
* Initialization to proceed forward.
*/
for (i = 0; i < SGE_NTIMERS - 1; i++)
s->timer_val[i] = min(intr_holdoff[i], MAX_SGE_TIMERVAL);
s->timer_val[SGE_NTIMERS - 1] = MAX_SGE_TIMERVAL;
s->counter_val[0] = 1;
for (i = 1; i < SGE_NCOUNTERS; i++)
s->counter_val[i] = min(intr_cnt[i - 1],
THRESHOLD_0_GET(THRESHOLD_0_MASK));
t4_sge_init(adapter);
#ifdef CONFIG_PCI_IOV
/*
* Provision resource limits for Virtual Functions. We currently
* grant them all the same static resource limits except for the Port
* Access Rights Mask which we're assigning based on the PF. All of
* the static provisioning stuff for both the PF and VF really needs
* to be managed in a persistent manner for each device which the
* firmware controls.
*/
{
int pf, vf;
for (pf = 0; pf < ARRAY_SIZE(num_vf); pf++) {
if (num_vf[pf] <= 0)
continue;
/* VF numbering starts at 1! */
for (vf = 1; vf <= num_vf[pf]; vf++) {
ret = t4_cfg_pfvf(adapter, adapter->mbox,
pf, vf,
VFRES_NEQ, VFRES_NETHCTRL,
VFRES_NIQFLINT, VFRES_NIQ,
VFRES_TC, VFRES_NVI,
FW_PFVF_CMD_CMASK_MASK,
pfvfres_pmask(
adapter, pf, vf),
VFRES_NEXACTF,
VFRES_R_CAPS, VFRES_WX_CAPS);
if (ret < 0)
dev_warn(adapter->pdev_dev,
"failed to "\
"provision pf/vf=%d/%d; "
"err=%d\n", pf, vf, ret);
}
}
}
#endif
/*
* Set up the default filter mode. Later we'll want to implement this
* via a firmware command, etc. ... This needs to be done before the
* firmare initialization command ... If the selected set of fields
* isn't equal to the default value, we'll need to make sure that the
* field selections will fit in the 36-bit budget.
*/
if (tp_vlan_pri_map != TP_VLAN_PRI_MAP_DEFAULT) {
int j, bits = 0;
for (j = TP_VLAN_PRI_MAP_FIRST; j <= TP_VLAN_PRI_MAP_LAST; j++)
switch (tp_vlan_pri_map & (1 << j)) {
case 0:
/* compressed filter field not enabled */
break;
case FCOE_MASK:
bits += 1;
break;
case PORT_MASK:
bits += 3;
break;
case VNIC_ID_MASK:
bits += 17;
break;
case VLAN_MASK:
bits += 17;
break;
case TOS_MASK:
bits += 8;
break;
case PROTOCOL_MASK:
bits += 8;
break;
case ETHERTYPE_MASK:
bits += 16;
break;
case MACMATCH_MASK:
bits += 9;
break;
case MPSHITTYPE_MASK:
bits += 3;
break;
case FRAGMENTATION_MASK:
bits += 1;
break;
}
if (bits > 36) {
dev_err(adapter->pdev_dev,
"tp_vlan_pri_map=%#x needs %d bits > 36;"\
" using %#x\n", tp_vlan_pri_map, bits,
TP_VLAN_PRI_MAP_DEFAULT);
tp_vlan_pri_map = TP_VLAN_PRI_MAP_DEFAULT;
}
}
v = tp_vlan_pri_map;
t4_write_indirect(adapter, TP_PIO_ADDR, TP_PIO_DATA,
&v, 1, TP_VLAN_PRI_MAP);
/*
* We need Five Tuple Lookup mode to be set in TP_GLOBAL_CONFIG order
* to support any of the compressed filter fields above. Newer
* versions of the firmware do this automatically but it doesn't hurt
* to set it here. Meanwhile, we do _not_ need to set Lookup Every
* Packet in TP_INGRESS_CONFIG to support matching non-TCP packets
* since the firmware automatically turns this on and off when we have
* a non-zero number of filters active (since it does have a
* performance impact).
*/
if (tp_vlan_pri_map)
t4_set_reg_field(adapter, TP_GLOBAL_CONFIG,
FIVETUPLELOOKUP_MASK,
FIVETUPLELOOKUP_MASK);
/*
* Tweak some settings.
*/
t4_write_reg(adapter, TP_SHIFT_CNT, SYNSHIFTMAX(6) |
RXTSHIFTMAXR1(4) | RXTSHIFTMAXR2(15) |
PERSHIFTBACKOFFMAX(8) | PERSHIFTMAX(8) |
KEEPALIVEMAXR1(4) | KEEPALIVEMAXR2(9));
/*
* Get basic stuff going by issuing the Firmware Initialize command.
* Note that this _must_ be after all PFVF commands ...
*/
ret = t4_fw_initialize(adapter, adapter->mbox);
if (ret < 0)
goto bye;
/*
* Return successfully!
*/
dev_info(adapter->pdev_dev, "Successfully configured using built-in "\
"driver parameters\n");
return 0;
/*
* Something bad happened. Return the error ...
*/
bye:
return ret;
}
static struct fw_info fw_info_array[] = {
{
.chip = CHELSIO_T4,
.fs_name = FW4_CFNAME,
.fw_mod_name = FW4_FNAME,
.fw_hdr = {
.chip = FW_HDR_CHIP_T4,
.fw_ver = __cpu_to_be32(FW_VERSION(T4)),
.intfver_nic = FW_INTFVER(T4, NIC),
.intfver_vnic = FW_INTFVER(T4, VNIC),
.intfver_ri = FW_INTFVER(T4, RI),
.intfver_iscsi = FW_INTFVER(T4, ISCSI),
.intfver_fcoe = FW_INTFVER(T4, FCOE),
},
}, {
.chip = CHELSIO_T5,
.fs_name = FW5_CFNAME,
.fw_mod_name = FW5_FNAME,
.fw_hdr = {
.chip = FW_HDR_CHIP_T5,
.fw_ver = __cpu_to_be32(FW_VERSION(T5)),
.intfver_nic = FW_INTFVER(T5, NIC),
.intfver_vnic = FW_INTFVER(T5, VNIC),
.intfver_ri = FW_INTFVER(T5, RI),
.intfver_iscsi = FW_INTFVER(T5, ISCSI),
.intfver_fcoe = FW_INTFVER(T5, FCOE),
},
}
};
static struct fw_info *find_fw_info(int chip)
{
int i;
for (i = 0; i < ARRAY_SIZE(fw_info_array); i++) {
if (fw_info_array[i].chip == chip)
return &fw_info_array[i];
}
return NULL;
}
/*
* Phase 0 of initialization: contact FW, obtain config, perform basic init.
*/
static int adap_init0(struct adapter *adap)
{
int ret;
u32 v, port_vec;
enum dev_state state;
u32 params[7], val[7];
struct fw_caps_config_cmd caps_cmd;
int reset = 1;
/*
* Contact FW, advertising Master capability (and potentially forcing
* ourselves as the Master PF if our module parameter force_init is
* set).
*/
ret = t4_fw_hello(adap, adap->mbox, adap->fn,
force_init ? MASTER_MUST : MASTER_MAY,
&state);
if (ret < 0) {
dev_err(adap->pdev_dev, "could not connect to FW, error %d\n",
ret);
return ret;
}
if (ret == adap->mbox)
adap->flags |= MASTER_PF;
if (force_init && state == DEV_STATE_INIT)
state = DEV_STATE_UNINIT;
/*
* If we're the Master PF Driver and the device is uninitialized,
* then let's consider upgrading the firmware ... (We always want
* to check the firmware version number in order to A. get it for
* later reporting and B. to warn if the currently loaded firmware
* is excessively mismatched relative to the driver.)
*/
t4_get_fw_version(adap, &adap->params.fw_vers);
t4_get_tp_version(adap, &adap->params.tp_vers);
if ((adap->flags & MASTER_PF) && state != DEV_STATE_INIT) {
struct fw_info *fw_info;
struct fw_hdr *card_fw;
const struct firmware *fw;
const u8 *fw_data = NULL;
unsigned int fw_size = 0;
/* This is the firmware whose headers the driver was compiled
* against
*/
fw_info = find_fw_info(CHELSIO_CHIP_VERSION(adap->params.chip));
if (fw_info == NULL) {
dev_err(adap->pdev_dev,
"unable to get firmware info for chip %d.\n",
CHELSIO_CHIP_VERSION(adap->params.chip));
return -EINVAL;
}
/* allocate memory to read the header of the firmware on the
* card
*/
card_fw = t4_alloc_mem(sizeof(*card_fw));
/* Get FW from from /lib/firmware/ */
ret = request_firmware(&fw, fw_info->fw_mod_name,
adap->pdev_dev);
if (ret < 0) {
dev_err(adap->pdev_dev,
"unable to load firmware image %s, error %d\n",
fw_info->fw_mod_name, ret);
} else {
fw_data = fw->data;
fw_size = fw->size;
}
/* upgrade FW logic */
ret = t4_prep_fw(adap, fw_info, fw_data, fw_size, card_fw,
state, &reset);
/* Cleaning up */
if (fw != NULL)
release_firmware(fw);
t4_free_mem(card_fw);
if (ret < 0)
goto bye;
}
/*
* Grab VPD parameters. This should be done after we establish a
* connection to the firmware since some of the VPD parameters
* (notably the Core Clock frequency) are retrieved via requests to
* the firmware. On the other hand, we need these fairly early on
* so we do this right after getting ahold of the firmware.
*/
ret = get_vpd_params(adap, &adap->params.vpd);
if (ret < 0)
goto bye;
/*
* Find out what ports are available to us. Note that we need to do
* this before calling adap_init0_no_config() since it needs nports
* and portvec ...
*/
v =
FW_PARAMS_MNEM(FW_PARAMS_MNEM_DEV) |
FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DEV_PORTVEC);
ret = t4_query_params(adap, adap->mbox, adap->fn, 0, 1, &v, &port_vec);
if (ret < 0)
goto bye;
adap->params.nports = hweight32(port_vec);
adap->params.portvec = port_vec;
/*
* If the firmware is initialized already (and we're not forcing a
* master initialization), note that we're living with existing
* adapter parameters. Otherwise, it's time to try initializing the
* adapter ...
*/
if (state == DEV_STATE_INIT) {
dev_info(adap->pdev_dev, "Coming up as %s: "\
"Adapter already initialized\n",
adap->flags & MASTER_PF ? "MASTER" : "SLAVE");
adap->flags |= USING_SOFT_PARAMS;
} else {
dev_info(adap->pdev_dev, "Coming up as MASTER: "\
"Initializing adapter\n");
/*
* If the firmware doesn't support Configuration
* Files warn user and exit,
*/
if (ret < 0)
dev_warn(adap->pdev_dev, "Firmware doesn't support "
"configuration file.\n");
if (force_old_init)
ret = adap_init0_no_config(adap, reset);
else {
/*
* Find out whether we're dealing with a version of
* the firmware which has configuration file support.
*/
params[0] = (FW_PARAMS_MNEM(FW_PARAMS_MNEM_DEV) |
FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DEV_CF));
ret = t4_query_params(adap, adap->mbox, adap->fn, 0, 1,
params, val);
/*
* If the firmware doesn't support Configuration
* Files, use the old Driver-based, hard-wired
* initialization. Otherwise, try using the
* Configuration File support and fall back to the
* Driver-based initialization if there's no
* Configuration File found.
*/
if (ret < 0)
ret = adap_init0_no_config(adap, reset);
else {
/*
* The firmware provides us with a memory
* buffer where we can load a Configuration
* File from the host if we want to override
* the Configuration File in flash.
*/
ret = adap_init0_config(adap, reset);
if (ret == -ENOENT) {
dev_info(adap->pdev_dev,
"No Configuration File present "
"on adapter. Using hard-wired "
"configuration parameters.\n");
ret = adap_init0_no_config(adap, reset);
}
}
}
if (ret < 0) {
dev_err(adap->pdev_dev,
"could not initialize adapter, error %d\n",
-ret);
goto bye;
}
}
/*
* If we're living with non-hard-coded parameters (either from a
* Firmware Configuration File or values programmed by a different PF
* Driver), give the SGE code a chance to pull in anything that it
* needs ... Note that this must be called after we retrieve our VPD
* parameters in order to know how to convert core ticks to seconds.
*/
if (adap->flags & USING_SOFT_PARAMS) {
ret = t4_sge_init(adap);
if (ret < 0)
goto bye;
}
if (is_bypass_device(adap->pdev->device))
adap->params.bypass = 1;
/*
* Grab some of our basic fundamental operating parameters.
*/
#define FW_PARAM_DEV(param) \
(FW_PARAMS_MNEM(FW_PARAMS_MNEM_DEV) | \
FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DEV_##param))
#define FW_PARAM_PFVF(param) \
FW_PARAMS_MNEM(FW_PARAMS_MNEM_PFVF) | \
FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_PFVF_##param)| \
FW_PARAMS_PARAM_Y(0) | \
FW_PARAMS_PARAM_Z(0)
params[0] = FW_PARAM_PFVF(EQ_START);
params[1] = FW_PARAM_PFVF(L2T_START);
params[2] = FW_PARAM_PFVF(L2T_END);
params[3] = FW_PARAM_PFVF(FILTER_START);
params[4] = FW_PARAM_PFVF(FILTER_END);
params[5] = FW_PARAM_PFVF(IQFLINT_START);
ret = t4_query_params(adap, adap->mbox, adap->fn, 0, 6, params, val);
if (ret < 0)
goto bye;
adap->sge.egr_start = val[0];
adap->l2t_start = val[1];
adap->l2t_end = val[2];
adap->tids.ftid_base = val[3];
adap->tids.nftids = val[4] - val[3] + 1;
adap->sge.ingr_start = val[5];
/* query params related to active filter region */
params[0] = FW_PARAM_PFVF(ACTIVE_FILTER_START);
params[1] = FW_PARAM_PFVF(ACTIVE_FILTER_END);
ret = t4_query_params(adap, adap->mbox, adap->fn, 0, 2, params, val);
/* If Active filter size is set we enable establishing
* offload connection through firmware work request
*/
if ((val[0] != val[1]) && (ret >= 0)) {
adap->flags |= FW_OFLD_CONN;
adap->tids.aftid_base = val[0];
adap->tids.aftid_end = val[1];
}
/* If we're running on newer firmware, let it know that we're
* prepared to deal with encapsulated CPL messages. Older
* firmware won't understand this and we'll just get
* unencapsulated messages ...
*/
params[0] = FW_PARAM_PFVF(CPLFW4MSG_ENCAP);
val[0] = 1;
(void) t4_set_params(adap, adap->mbox, adap->fn, 0, 1, params, val);
/*
* Find out whether we're allowed to use the T5+ ULPTX MEMWRITE DSGL
* capability. Earlier versions of the firmware didn't have the
* ULPTX_MEMWRITE_DSGL so we'll interpret a query failure as no
* permission to use ULPTX MEMWRITE DSGL.
*/
if (is_t4(adap->params.chip)) {
adap->params.ulptx_memwrite_dsgl = false;
} else {
params[0] = FW_PARAM_DEV(ULPTX_MEMWRITE_DSGL);
ret = t4_query_params(adap, adap->mbox, adap->fn, 0,
1, params, val);
adap->params.ulptx_memwrite_dsgl = (ret == 0 && val[0] != 0);
}
/*
* Get device capabilities so we can determine what resources we need
* to manage.
*/
memset(&caps_cmd, 0, sizeof(caps_cmd));
caps_cmd.op_to_write = htonl(FW_CMD_OP(FW_CAPS_CONFIG_CMD) |
FW_CMD_REQUEST | FW_CMD_READ);
caps_cmd.cfvalid_to_len16 = htonl(FW_LEN16(caps_cmd));
ret = t4_wr_mbox(adap, adap->mbox, &caps_cmd, sizeof(caps_cmd),
&caps_cmd);
if (ret < 0)
goto bye;
if (caps_cmd.ofldcaps) {
/* query offload-related parameters */
params[0] = FW_PARAM_DEV(NTID);
params[1] = FW_PARAM_PFVF(SERVER_START);
params[2] = FW_PARAM_PFVF(SERVER_END);
params[3] = FW_PARAM_PFVF(TDDP_START);
params[4] = FW_PARAM_PFVF(TDDP_END);
params[5] = FW_PARAM_DEV(FLOWC_BUFFIFO_SZ);
ret = t4_query_params(adap, adap->mbox, adap->fn, 0, 6,
params, val);
if (ret < 0)
goto bye;
adap->tids.ntids = val[0];
adap->tids.natids = min(adap->tids.ntids / 2, MAX_ATIDS);
adap->tids.stid_base = val[1];
adap->tids.nstids = val[2] - val[1] + 1;
/*
* Setup server filter region. Divide the availble filter
* region into two parts. Regular filters get 1/3rd and server
* filters get 2/3rd part. This is only enabled if workarond
* path is enabled.
* 1. For regular filters.
* 2. Server filter: This are special filters which are used
* to redirect SYN packets to offload queue.
*/
if (adap->flags & FW_OFLD_CONN && !is_bypass(adap)) {
adap->tids.sftid_base = adap->tids.ftid_base +
DIV_ROUND_UP(adap->tids.nftids, 3);
adap->tids.nsftids = adap->tids.nftids -
DIV_ROUND_UP(adap->tids.nftids, 3);
adap->tids.nftids = adap->tids.sftid_base -
adap->tids.ftid_base;
}
adap->vres.ddp.start = val[3];
adap->vres.ddp.size = val[4] - val[3] + 1;
adap->params.ofldq_wr_cred = val[5];
adap->params.offload = 1;
}
if (caps_cmd.rdmacaps) {
params[0] = FW_PARAM_PFVF(STAG_START);
params[1] = FW_PARAM_PFVF(STAG_END);
params[2] = FW_PARAM_PFVF(RQ_START);
params[3] = FW_PARAM_PFVF(RQ_END);
params[4] = FW_PARAM_PFVF(PBL_START);
params[5] = FW_PARAM_PFVF(PBL_END);
ret = t4_query_params(adap, adap->mbox, adap->fn, 0, 6,
params, val);
if (ret < 0)
goto bye;
adap->vres.stag.start = val[0];
adap->vres.stag.size = val[1] - val[0] + 1;
adap->vres.rq.start = val[2];
adap->vres.rq.size = val[3] - val[2] + 1;
adap->vres.pbl.start = val[4];
adap->vres.pbl.size = val[5] - val[4] + 1;
params[0] = FW_PARAM_PFVF(SQRQ_START);
params[1] = FW_PARAM_PFVF(SQRQ_END);
params[2] = FW_PARAM_PFVF(CQ_START);
params[3] = FW_PARAM_PFVF(CQ_END);
params[4] = FW_PARAM_PFVF(OCQ_START);
params[5] = FW_PARAM_PFVF(OCQ_END);
ret = t4_query_params(adap, adap->mbox, adap->fn, 0, 6, params,
val);
if (ret < 0)
goto bye;
adap->vres.qp.start = val[0];
adap->vres.qp.size = val[1] - val[0] + 1;
adap->vres.cq.start = val[2];
adap->vres.cq.size = val[3] - val[2] + 1;
adap->vres.ocq.start = val[4];
adap->vres.ocq.size = val[5] - val[4] + 1;
params[0] = FW_PARAM_DEV(MAXORDIRD_QP);
params[1] = FW_PARAM_DEV(MAXIRD_ADAPTER);
ret = t4_query_params(adap, adap->mbox, adap->fn, 0, 2, params,
val);
if (ret < 0) {
adap->params.max_ordird_qp = 8;
adap->params.max_ird_adapter = 32 * adap->tids.ntids;
ret = 0;
} else {
adap->params.max_ordird_qp = val[0];
adap->params.max_ird_adapter = val[1];
}
dev_info(adap->pdev_dev,
"max_ordird_qp %d max_ird_adapter %d\n",
adap->params.max_ordird_qp,
adap->params.max_ird_adapter);
}
if (caps_cmd.iscsicaps) {
params[0] = FW_PARAM_PFVF(ISCSI_START);
params[1] = FW_PARAM_PFVF(ISCSI_END);
ret = t4_query_params(adap, adap->mbox, adap->fn, 0, 2,
params, val);
if (ret < 0)
goto bye;
adap->vres.iscsi.start = val[0];
adap->vres.iscsi.size = val[1] - val[0] + 1;
}
#undef FW_PARAM_PFVF
#undef FW_PARAM_DEV
/* The MTU/MSS Table is initialized by now, so load their values. If
* we're initializing the adapter, then we'll make any modifications
* we want to the MTU/MSS Table and also initialize the congestion
* parameters.
*/
t4_read_mtu_tbl(adap, adap->params.mtus, NULL);
if (state != DEV_STATE_INIT) {
int i;
/* The default MTU Table contains values 1492 and 1500.
* However, for TCP, it's better to have two values which are
* a multiple of 8 +/- 4 bytes apart near this popular MTU.
* This allows us to have a TCP Data Payload which is a
* multiple of 8 regardless of what combination of TCP Options
* are in use (always a multiple of 4 bytes) which is
* important for performance reasons. For instance, if no
* options are in use, then we have a 20-byte IP header and a
* 20-byte TCP header. In this case, a 1500-byte MSS would
* result in a TCP Data Payload of 1500 - 40 == 1460 bytes
* which is not a multiple of 8. So using an MSS of 1488 in
* this case results in a TCP Data Payload of 1448 bytes which
* is a multiple of 8. On the other hand, if 12-byte TCP Time
* Stamps have been negotiated, then an MTU of 1500 bytes
* results in a TCP Data Payload of 1448 bytes which, as
* above, is a multiple of 8 bytes ...
*/
for (i = 0; i < NMTUS; i++)
if (adap->params.mtus[i] == 1492) {
adap->params.mtus[i] = 1488;
break;
}
t4_load_mtus(adap, adap->params.mtus, adap->params.a_wnd,
adap->params.b_wnd);
}
t4_init_tp_params(adap);
adap->flags |= FW_OK;
return 0;
/*
* Something bad happened. If a command timed out or failed with EIO
* FW does not operate within its spec or something catastrophic
* happened to HW/FW, stop issuing commands.
*/
bye:
if (ret != -ETIMEDOUT && ret != -EIO)
t4_fw_bye(adap, adap->mbox);
return ret;
}
/* EEH callbacks */
static pci_ers_result_t eeh_err_detected(struct pci_dev *pdev,
pci_channel_state_t state)
{
int i;
struct adapter *adap = pci_get_drvdata(pdev);
if (!adap)
goto out;
rtnl_lock();
adap->flags &= ~FW_OK;
notify_ulds(adap, CXGB4_STATE_START_RECOVERY);
spin_lock(&adap->stats_lock);
for_each_port(adap, i) {
struct net_device *dev = adap->port[i];
netif_device_detach(dev);
netif_carrier_off(dev);
}
spin_unlock(&adap->stats_lock);
if (adap->flags & FULL_INIT_DONE)
cxgb_down(adap);
rtnl_unlock();
if ((adap->flags & DEV_ENABLED)) {
pci_disable_device(pdev);
adap->flags &= ~DEV_ENABLED;
}
out: return state == pci_channel_io_perm_failure ?
PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_NEED_RESET;
}
static pci_ers_result_t eeh_slot_reset(struct pci_dev *pdev)
{
int i, ret;
struct fw_caps_config_cmd c;
struct adapter *adap = pci_get_drvdata(pdev);
if (!adap) {
pci_restore_state(pdev);
pci_save_state(pdev);
return PCI_ERS_RESULT_RECOVERED;
}
if (!(adap->flags & DEV_ENABLED)) {
if (pci_enable_device(pdev)) {
dev_err(&pdev->dev, "Cannot reenable PCI "
"device after reset\n");
return PCI_ERS_RESULT_DISCONNECT;
}
adap->flags |= DEV_ENABLED;
}
pci_set_master(pdev);
pci_restore_state(pdev);
pci_save_state(pdev);
pci_cleanup_aer_uncorrect_error_status(pdev);
if (t4_wait_dev_ready(adap) < 0)
return PCI_ERS_RESULT_DISCONNECT;
if (t4_fw_hello(adap, adap->fn, adap->fn, MASTER_MUST, NULL) < 0)
return PCI_ERS_RESULT_DISCONNECT;
adap->flags |= FW_OK;
if (adap_init1(adap, &c))
return PCI_ERS_RESULT_DISCONNECT;
for_each_port(adap, i) {
struct port_info *p = adap2pinfo(adap, i);
ret = t4_alloc_vi(adap, adap->fn, p->tx_chan, adap->fn, 0, 1,
NULL, NULL);
if (ret < 0)
return PCI_ERS_RESULT_DISCONNECT;
p->viid = ret;
p->xact_addr_filt = -1;
}
t4_load_mtus(adap, adap->params.mtus, adap->params.a_wnd,
adap->params.b_wnd);
setup_memwin(adap);
if (cxgb_up(adap))
return PCI_ERS_RESULT_DISCONNECT;
return PCI_ERS_RESULT_RECOVERED;
}
static void eeh_resume(struct pci_dev *pdev)
{
int i;
struct adapter *adap = pci_get_drvdata(pdev);
if (!adap)
return;
rtnl_lock();
for_each_port(adap, i) {
struct net_device *dev = adap->port[i];
if (netif_running(dev)) {
link_start(dev);
cxgb_set_rxmode(dev);
}
netif_device_attach(dev);
}
rtnl_unlock();
}
static const struct pci_error_handlers cxgb4_eeh = {
.error_detected = eeh_err_detected,
.slot_reset = eeh_slot_reset,
.resume = eeh_resume,
};
static inline bool is_x_10g_port(const struct link_config *lc)
{
return (lc->supported & FW_PORT_CAP_SPEED_10G) != 0 ||
(lc->supported & FW_PORT_CAP_SPEED_40G) != 0;
}
static inline void init_rspq(struct adapter *adap, struct sge_rspq *q,
unsigned int us, unsigned int cnt,
unsigned int size, unsigned int iqe_size)
{
q->adap = adap;
set_rspq_intr_params(q, us, cnt);
q->iqe_len = iqe_size;
q->size = size;
}
/*
* Perform default configuration of DMA queues depending on the number and type
* of ports we found and the number of available CPUs. Most settings can be
* modified by the admin prior to actual use.
*/
static void cfg_queues(struct adapter *adap)
{
struct sge *s = &adap->sge;
int i, n10g = 0, qidx = 0;
#ifndef CONFIG_CHELSIO_T4_DCB
int q10g = 0;
#endif
int ciq_size;
for_each_port(adap, i)
n10g += is_x_10g_port(&adap2pinfo(adap, i)->link_cfg);
#ifdef CONFIG_CHELSIO_T4_DCB
/* For Data Center Bridging support we need to be able to support up
* to 8 Traffic Priorities; each of which will be assigned to its
* own TX Queue in order to prevent Head-Of-Line Blocking.
*/
if (adap->params.nports * 8 > MAX_ETH_QSETS) {
dev_err(adap->pdev_dev, "MAX_ETH_QSETS=%d < %d!\n",
MAX_ETH_QSETS, adap->params.nports * 8);
BUG_ON(1);
}
for_each_port(adap, i) {
struct port_info *pi = adap2pinfo(adap, i);
pi->first_qset = qidx;
pi->nqsets = 8;
qidx += pi->nqsets;
}
#else /* !CONFIG_CHELSIO_T4_DCB */
/*
* We default to 1 queue per non-10G port and up to # of cores queues
* per 10G port.
*/
if (n10g)
q10g = (MAX_ETH_QSETS - (adap->params.nports - n10g)) / n10g;
if (q10g > netif_get_num_default_rss_queues())
q10g = netif_get_num_default_rss_queues();
for_each_port(adap, i) {
struct port_info *pi = adap2pinfo(adap, i);
pi->first_qset = qidx;
pi->nqsets = is_x_10g_port(&pi->link_cfg) ? q10g : 1;
qidx += pi->nqsets;
}
#endif /* !CONFIG_CHELSIO_T4_DCB */
s->ethqsets = qidx;
s->max_ethqsets = qidx; /* MSI-X may lower it later */
if (is_offload(adap)) {
/*
* For offload we use 1 queue/channel if all ports are up to 1G,
* otherwise we divide all available queues amongst the channels
* capped by the number of available cores.
*/
if (n10g) {
i = min_t(int, ARRAY_SIZE(s->ofldrxq),
num_online_cpus());
s->ofldqsets = roundup(i, adap->params.nports);
} else
s->ofldqsets = adap->params.nports;
/* For RDMA one Rx queue per channel suffices */
s->rdmaqs = adap->params.nports;
s->rdmaciqs = adap->params.nports;
}
for (i = 0; i < ARRAY_SIZE(s->ethrxq); i++) {
struct sge_eth_rxq *r = &s->ethrxq[i];
init_rspq(adap, &r->rspq, 5, 10, 1024, 64);
r->fl.size = 72;
}
for (i = 0; i < ARRAY_SIZE(s->ethtxq); i++)
s->ethtxq[i].q.size = 1024;
for (i = 0; i < ARRAY_SIZE(s->ctrlq); i++)
s->ctrlq[i].q.size = 512;
for (i = 0; i < ARRAY_SIZE(s->ofldtxq); i++)
s->ofldtxq[i].q.size = 1024;
for (i = 0; i < ARRAY_SIZE(s->ofldrxq); i++) {
struct sge_ofld_rxq *r = &s->ofldrxq[i];
init_rspq(adap, &r->rspq, 5, 1, 1024, 64);
r->rspq.uld = CXGB4_ULD_ISCSI;
r->fl.size = 72;
}
for (i = 0; i < ARRAY_SIZE(s->rdmarxq); i++) {
struct sge_ofld_rxq *r = &s->rdmarxq[i];
init_rspq(adap, &r->rspq, 5, 1, 511, 64);
r->rspq.uld = CXGB4_ULD_RDMA;
r->fl.size = 72;
}
ciq_size = 64 + adap->vres.cq.size + adap->tids.nftids;
if (ciq_size > SGE_MAX_IQ_SIZE) {
CH_WARN(adap, "CIQ size too small for available IQs\n");
ciq_size = SGE_MAX_IQ_SIZE;
}
for (i = 0; i < ARRAY_SIZE(s->rdmaciq); i++) {
struct sge_ofld_rxq *r = &s->rdmaciq[i];
init_rspq(adap, &r->rspq, 5, 1, ciq_size, 64);
r->rspq.uld = CXGB4_ULD_RDMA;
}
init_rspq(adap, &s->fw_evtq, 0, 1, 1024, 64);
init_rspq(adap, &s->intrq, 0, 1, 2 * MAX_INGQ, 64);
}
/*
* Reduce the number of Ethernet queues across all ports to at most n.
* n provides at least one queue per port.
*/
static void reduce_ethqs(struct adapter *adap, int n)
{
int i;
struct port_info *pi;
while (n < adap->sge.ethqsets)
for_each_port(adap, i) {
pi = adap2pinfo(adap, i);
if (pi->nqsets > 1) {
pi->nqsets--;
adap->sge.ethqsets--;
if (adap->sge.ethqsets <= n)
break;
}
}
n = 0;
for_each_port(adap, i) {
pi = adap2pinfo(adap, i);
pi->first_qset = n;
n += pi->nqsets;
}
}
/* 2 MSI-X vectors needed for the FW queue and non-data interrupts */
#define EXTRA_VECS 2
static int enable_msix(struct adapter *adap)
{
int ofld_need = 0;
int i, want, need;
struct sge *s = &adap->sge;
unsigned int nchan = adap->params.nports;
struct msix_entry entries[MAX_INGQ + 1];
for (i = 0; i < ARRAY_SIZE(entries); ++i)
entries[i].entry = i;
want = s->max_ethqsets + EXTRA_VECS;
if (is_offload(adap)) {
want += s->rdmaqs + s->rdmaciqs + s->ofldqsets;
/* need nchan for each possible ULD */
ofld_need = 3 * nchan;
}
#ifdef CONFIG_CHELSIO_T4_DCB
/* For Data Center Bridging we need 8 Ethernet TX Priority Queues for
* each port.
*/
need = 8 * adap->params.nports + EXTRA_VECS + ofld_need;
#else
need = adap->params.nports + EXTRA_VECS + ofld_need;
#endif
want = pci_enable_msix_range(adap->pdev, entries, need, want);
if (want < 0)
return want;
/*
* Distribute available vectors to the various queue groups.
* Every group gets its minimum requirement and NIC gets top
* priority for leftovers.
*/
i = want - EXTRA_VECS - ofld_need;
if (i < s->max_ethqsets) {
s->max_ethqsets = i;
if (i < s->ethqsets)
reduce_ethqs(adap, i);
}
if (is_offload(adap)) {
i = want - EXTRA_VECS - s->max_ethqsets;
i -= ofld_need - nchan;
s->ofldqsets = (i / nchan) * nchan; /* round down */
}
for (i = 0; i < want; ++i)
adap->msix_info[i].vec = entries[i].vector;
return 0;
}
#undef EXTRA_VECS
static int init_rss(struct adapter *adap)
{
unsigned int i, j;
for_each_port(adap, i) {
struct port_info *pi = adap2pinfo(adap, i);
pi->rss = kcalloc(pi->rss_size, sizeof(u16), GFP_KERNEL);
if (!pi->rss)
return -ENOMEM;
for (j = 0; j < pi->rss_size; j++)
pi->rss[j] = ethtool_rxfh_indir_default(j, pi->nqsets);
}
return 0;
}
static void print_port_info(const struct net_device *dev)
{
char buf[80];
char *bufp = buf;
const char *spd = "";
const struct port_info *pi = netdev_priv(dev);
const struct adapter *adap = pi->adapter;
if (adap->params.pci.speed == PCI_EXP_LNKSTA_CLS_2_5GB)
spd = " 2.5 GT/s";
else if (adap->params.pci.speed == PCI_EXP_LNKSTA_CLS_5_0GB)
spd = " 5 GT/s";
else if (adap->params.pci.speed == PCI_EXP_LNKSTA_CLS_8_0GB)
spd = " 8 GT/s";
if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_100M)
bufp += sprintf(bufp, "100/");
if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_1G)
bufp += sprintf(bufp, "1000/");
if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_10G)
bufp += sprintf(bufp, "10G/");
if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_40G)
bufp += sprintf(bufp, "40G/");
if (bufp != buf)
--bufp;
sprintf(bufp, "BASE-%s", t4_get_port_type_description(pi->port_type));
netdev_info(dev, "Chelsio %s rev %d %s %sNIC PCIe x%d%s%s\n",
adap->params.vpd.id,
CHELSIO_CHIP_RELEASE(adap->params.chip), buf,
is_offload(adap) ? "R" : "", adap->params.pci.width, spd,
(adap->flags & USING_MSIX) ? " MSI-X" :
(adap->flags & USING_MSI) ? " MSI" : "");
netdev_info(dev, "S/N: %s, P/N: %s\n",
adap->params.vpd.sn, adap->params.vpd.pn);
}
static void enable_pcie_relaxed_ordering(struct pci_dev *dev)
{
pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_RELAX_EN);
}
/*
* Free the following resources:
* - memory used for tables
* - MSI/MSI-X
* - net devices
* - resources FW is holding for us
*/
static void free_some_resources(struct adapter *adapter)
{
unsigned int i;
t4_free_mem(adapter->l2t);
t4_free_mem(adapter->tids.tid_tab);
disable_msi(adapter);
for_each_port(adapter, i)
if (adapter->port[i]) {
kfree(adap2pinfo(adapter, i)->rss);
free_netdev(adapter->port[i]);
}
if (adapter->flags & FW_OK)
t4_fw_bye(adapter, adapter->fn);
}
#define TSO_FLAGS (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_TSO_ECN)
#define VLAN_FEAT (NETIF_F_SG | NETIF_F_IP_CSUM | TSO_FLAGS | \
NETIF_F_IPV6_CSUM | NETIF_F_HIGHDMA)
#define SEGMENT_SIZE 128
static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{
int func, i, err, s_qpp, qpp, num_seg;
struct port_info *pi;
bool highdma = false;
struct adapter *adapter = NULL;
void __iomem *regs;
printk_once(KERN_INFO "%s - version %s\n", DRV_DESC, DRV_VERSION);
err = pci_request_regions(pdev, KBUILD_MODNAME);
if (err) {
/* Just info, some other driver may have claimed the device. */
dev_info(&pdev->dev, "cannot obtain PCI resources\n");
return err;
}
err = pci_enable_device(pdev);
if (err) {
dev_err(&pdev->dev, "cannot enable PCI device\n");
goto out_release_regions;
}
regs = pci_ioremap_bar(pdev, 0);
if (!regs) {
dev_err(&pdev->dev, "cannot map device registers\n");
err = -ENOMEM;
goto out_disable_device;
}
/* We control everything through one PF */
func = SOURCEPF_GET(readl(regs + PL_WHOAMI));
if (func != ent->driver_data) {
iounmap(regs);
pci_disable_device(pdev);
pci_save_state(pdev); /* to restore SR-IOV later */
goto sriov;
}
if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) {
highdma = true;
err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
if (err) {
dev_err(&pdev->dev, "unable to obtain 64-bit DMA for "
"coherent allocations\n");
goto out_unmap_bar0;
}
} else {
err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
if (err) {
dev_err(&pdev->dev, "no usable DMA configuration\n");
goto out_unmap_bar0;
}
}
pci_enable_pcie_error_reporting(pdev);
enable_pcie_relaxed_ordering(pdev);
pci_set_master(pdev);
pci_save_state(pdev);
adapter = kzalloc(sizeof(*adapter), GFP_KERNEL);
if (!adapter) {
err = -ENOMEM;
goto out_unmap_bar0;
}
adapter->workq = create_singlethread_workqueue("cxgb4");
if (!adapter->workq) {
err = -ENOMEM;
goto out_free_adapter;
}
/* PCI device has been enabled */
adapter->flags |= DEV_ENABLED;
adapter->regs = regs;
adapter->pdev = pdev;
adapter->pdev_dev = &pdev->dev;
adapter->mbox = func;
adapter->fn = func;
adapter->msg_enable = dflt_msg_enable;
memset(adapter->chan_map, 0xff, sizeof(adapter->chan_map));
spin_lock_init(&adapter->stats_lock);
spin_lock_init(&adapter->tid_release_lock);
spin_lock_init(&adapter->win0_lock);
INIT_WORK(&adapter->tid_release_task, process_tid_release_list);
INIT_WORK(&adapter->db_full_task, process_db_full);
INIT_WORK(&adapter->db_drop_task, process_db_drop);
err = t4_prep_adapter(adapter);
if (err)
goto out_free_adapter;
if (!is_t4(adapter->params.chip)) {
s_qpp = QUEUESPERPAGEPF1 * adapter->fn;
qpp = 1 << QUEUESPERPAGEPF0_GET(t4_read_reg(adapter,
SGE_EGRESS_QUEUES_PER_PAGE_PF) >> s_qpp);
num_seg = PAGE_SIZE / SEGMENT_SIZE;
/* Each segment size is 128B. Write coalescing is enabled only
* when SGE_EGRESS_QUEUES_PER_PAGE_PF reg value for the
* queue is less no of segments that can be accommodated in
* a page size.
*/
if (qpp > num_seg) {
dev_err(&pdev->dev,
"Incorrect number of egress queues per page\n");
err = -EINVAL;
goto out_free_adapter;
}
adapter->bar2 = ioremap_wc(pci_resource_start(pdev, 2),
pci_resource_len(pdev, 2));
if (!adapter->bar2) {
dev_err(&pdev->dev, "cannot map device bar2 region\n");
err = -ENOMEM;
goto out_free_adapter;
}
}
setup_memwin(adapter);
err = adap_init0(adapter);
setup_memwin_rdma(adapter);
if (err)
goto out_unmap_bar;
for_each_port(adapter, i) {
struct net_device *netdev;
netdev = alloc_etherdev_mq(sizeof(struct port_info),
MAX_ETH_QSETS);
if (!netdev) {
err = -ENOMEM;
goto out_free_dev;
}
SET_NETDEV_DEV(netdev, &pdev->dev);
adapter->port[i] = netdev;
pi = netdev_priv(netdev);
pi->adapter = adapter;
pi->xact_addr_filt = -1;
pi->port_id = i;
netdev->irq = pdev->irq;
netdev->hw_features = NETIF_F_SG | TSO_FLAGS |
NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
NETIF_F_RXCSUM | NETIF_F_RXHASH |
NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX;
if (highdma)
netdev->hw_features |= NETIF_F_HIGHDMA;
netdev->features |= netdev->hw_features;
netdev->vlan_features = netdev->features & VLAN_FEAT;
netdev->priv_flags |= IFF_UNICAST_FLT;
netdev->netdev_ops = &cxgb4_netdev_ops;
#ifdef CONFIG_CHELSIO_T4_DCB
netdev->dcbnl_ops = &cxgb4_dcb_ops;
cxgb4_dcb_state_init(netdev);
#endif
netdev->ethtool_ops = &cxgb_ethtool_ops;
}
pci_set_drvdata(pdev, adapter);
if (adapter->flags & FW_OK) {
err = t4_port_init(adapter, func, func, 0);
if (err)
goto out_free_dev;
}
/*
* Configure queues and allocate tables now, they can be needed as
* soon as the first register_netdev completes.
*/
cfg_queues(adapter);
adapter->l2t = t4_init_l2t();
if (!adapter->l2t) {
/* We tolerate a lack of L2T, giving up some functionality */
dev_warn(&pdev->dev, "could not allocate L2T, continuing\n");
adapter->params.offload = 0;
}
if (is_offload(adapter) && tid_init(&adapter->tids) < 0) {
dev_warn(&pdev->dev, "could not allocate TID table, "
"continuing\n");
adapter->params.offload = 0;
}
/* See what interrupts we'll be using */
if (msi > 1 && enable_msix(adapter) == 0)
adapter->flags |= USING_MSIX;
else if (msi > 0 && pci_enable_msi(pdev) == 0)
adapter->flags |= USING_MSI;
err = init_rss(adapter);
if (err)
goto out_free_dev;
/*
* The card is now ready to go. If any errors occur during device
* registration we do not fail the whole card but rather proceed only
* with the ports we manage to register successfully. However we must
* register at least one net device.
*/
for_each_port(adapter, i) {
pi = adap2pinfo(adapter, i);
netif_set_real_num_tx_queues(adapter->port[i], pi->nqsets);
netif_set_real_num_rx_queues(adapter->port[i], pi->nqsets);
err = register_netdev(adapter->port[i]);
if (err)
break;
adapter->chan_map[pi->tx_chan] = i;
print_port_info(adapter->port[i]);
}
if (i == 0) {
dev_err(&pdev->dev, "could not register any net devices\n");
goto out_free_dev;
}
if (err) {
dev_warn(&pdev->dev, "only %d net devices registered\n", i);
err = 0;
}
if (cxgb4_debugfs_root) {
adapter->debugfs_root = debugfs_create_dir(pci_name(pdev),
cxgb4_debugfs_root);
setup_debugfs(adapter);
}
/* PCIe EEH recovery on powerpc platforms needs fundamental reset */
pdev->needs_freset = 1;
if (is_offload(adapter))
attach_ulds(adapter);
sriov:
#ifdef CONFIG_PCI_IOV
if (func < ARRAY_SIZE(num_vf) && num_vf[func] > 0)
if (pci_enable_sriov(pdev, num_vf[func]) == 0)
dev_info(&pdev->dev,
"instantiated %u virtual functions\n",
num_vf[func]);
#endif
return 0;
out_free_dev:
free_some_resources(adapter);
out_unmap_bar:
if (!is_t4(adapter->params.chip))
iounmap(adapter->bar2);
out_free_adapter:
if (adapter->workq)
destroy_workqueue(adapter->workq);
kfree(adapter);
out_unmap_bar0:
iounmap(regs);
out_disable_device:
pci_disable_pcie_error_reporting(pdev);
pci_disable_device(pdev);
out_release_regions:
pci_release_regions(pdev);
return err;
}
static void remove_one(struct pci_dev *pdev)
{
struct adapter *adapter = pci_get_drvdata(pdev);
#ifdef CONFIG_PCI_IOV
pci_disable_sriov(pdev);
#endif
if (adapter) {
int i;
/* Tear down per-adapter Work Queue first since it can contain
* references to our adapter data structure.
*/
destroy_workqueue(adapter->workq);
if (is_offload(adapter))
detach_ulds(adapter);
for_each_port(adapter, i)
if (adapter->port[i]->reg_state == NETREG_REGISTERED)
unregister_netdev(adapter->port[i]);
debugfs_remove_recursive(adapter->debugfs_root);
/* If we allocated filters, free up state associated with any
* valid filters ...
*/
if (adapter->tids.ftid_tab) {
struct filter_entry *f = &adapter->tids.ftid_tab[0];
for (i = 0; i < (adapter->tids.nftids +
adapter->tids.nsftids); i++, f++)
if (f->valid)
clear_filter(adapter, f);
}
if (adapter->flags & FULL_INIT_DONE)
cxgb_down(adapter);
free_some_resources(adapter);
iounmap(adapter->regs);
if (!is_t4(adapter->params.chip))
iounmap(adapter->bar2);
pci_disable_pcie_error_reporting(pdev);
if ((adapter->flags & DEV_ENABLED)) {
pci_disable_device(pdev);
adapter->flags &= ~DEV_ENABLED;
}
pci_release_regions(pdev);
synchronize_rcu();
kfree(adapter);
} else
pci_release_regions(pdev);
}
static struct pci_driver cxgb4_driver = {
.name = KBUILD_MODNAME,
.id_table = cxgb4_pci_tbl,
.probe = init_one,
.remove = remove_one,
.shutdown = remove_one,
.err_handler = &cxgb4_eeh,
};
static int __init cxgb4_init_module(void)
{
int ret;
/* Debugfs support is optional, just warn if this fails */
cxgb4_debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL);
if (!cxgb4_debugfs_root)
pr_warn("could not create debugfs entry, continuing\n");
ret = pci_register_driver(&cxgb4_driver);
if (ret < 0)
debugfs_remove(cxgb4_debugfs_root);
register_inet6addr_notifier(&cxgb4_inet6addr_notifier);
return ret;
}
static void __exit cxgb4_cleanup_module(void)
{
unregister_inet6addr_notifier(&cxgb4_inet6addr_notifier);
pci_unregister_driver(&cxgb4_driver);
debugfs_remove(cxgb4_debugfs_root); /* NULL ok */
}
module_init(cxgb4_init_module);
module_exit(cxgb4_cleanup_module);
| matyushov/vs311 | drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | C | gpl-2.0 | 184,169 |
/**********************************************************************
*
* Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful but, except
* as otherwise stated in writing, 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 St - Fifth Floor, Boston, MA 02110-1301 USA.
*
* The full GNU General Public License is included in this distribution in
* the file called "COPYING".
*
* Contact Information:
* Imagination Technologies Ltd. <gpl-support@imgtec.com>
* Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK
*
******************************************************************************/
#include "services_headers.h"
#include "pvr_pdump.h"
#include <linux/kernel.h>
#include <linux/mutex.h>
#include <linux/sched.h>
#include <linux/wait.h>
static IMG_BOOL gbInitServerRunning;
static IMG_BOOL gbInitServerRan;
static IMG_BOOL gbInitSuccessful;
static DEFINE_MUTEX(hPowerAndFreqLock);
enum PVRSRV_ERROR PVRSRVSetInitServerState(enum PVRSRV_INIT_SERVER_STATE
eInitServerState, IMG_BOOL bState)
{
switch (eInitServerState) {
case PVRSRV_INIT_SERVER_RUNNING:
gbInitServerRunning = bState;
break;
case PVRSRV_INIT_SERVER_RAN:
gbInitServerRan = bState;
break;
case PVRSRV_INIT_SERVER_SUCCESSFUL:
gbInitSuccessful = bState;
break;
default:
PVR_DPF(PVR_DBG_ERROR,
"PVRSRVSetInitServerState : Unknown state %lx",
eInitServerState);
return PVRSRV_ERROR_GENERIC;
}
return PVRSRV_OK;
}
IMG_BOOL PVRSRVGetInitServerState(
enum PVRSRV_INIT_SERVER_STATE eInitServerState)
{
IMG_BOOL bReturnVal;
switch (eInitServerState) {
case PVRSRV_INIT_SERVER_RUNNING:
bReturnVal = gbInitServerRunning;
break;
case PVRSRV_INIT_SERVER_RAN:
bReturnVal = gbInitServerRan;
break;
case PVRSRV_INIT_SERVER_SUCCESSFUL:
bReturnVal = gbInitSuccessful;
break;
default:
PVR_DPF(PVR_DBG_ERROR,
"PVRSRVGetInitServerState : Unknown state %lx",
eInitServerState);
bReturnVal = IMG_FALSE;
}
return bReturnVal;
}
static IMG_BOOL _IsSystemStatePowered(enum PVR_POWER_STATE eSystemPowerState)
{
return (IMG_BOOL)(eSystemPowerState < PVRSRV_POWER_STATE_D2);
}
static enum PVRSRV_ERROR PVRSRVDevicePrePowerStateKM(IMG_BOOL bAllDevices,
u32 ui32DeviceIndex,
enum PVR_POWER_STATE eNewPowerState)
{
enum PVRSRV_ERROR eError;
struct SYS_DATA *psSysData;
struct PVRSRV_POWER_DEV *psPowerDevice;
enum PVR_POWER_STATE eNewDevicePowerState;
eError = SysAcquireData(&psSysData);
if (eError != PVRSRV_OK)
return eError;
psPowerDevice = psSysData->psPowerDeviceList;
while (psPowerDevice) {
if (bAllDevices ||
(ui32DeviceIndex == psPowerDevice->ui32DeviceIndex)) {
eNewDevicePowerState =
(eNewPowerState == PVRSRV_POWER_Unspecified) ?
psPowerDevice->eDefaultPowerState :
eNewPowerState;
if (psPowerDevice->eCurrentPowerState !=
eNewDevicePowerState) {
if (psPowerDevice->pfnPrePower != NULL) {
eError =
psPowerDevice->
pfnPrePower(psPowerDevice->
hDevCookie,
eNewDevicePowerState,
psPowerDevice->
eCurrentPowerState);
if (eError != PVRSRV_OK) {
pr_err
("pfnPrePower failed (%u)\n",
eError);
return eError;
}
}
eError = SysDevicePrePowerState(
psPowerDevice->ui32DeviceIndex,
eNewDevicePowerState,
psPowerDevice->eCurrentPowerState);
if (eError != PVRSRV_OK) {
pr_err("SysDevicePrePowerState failed "
"(%u)\n", eError);
return eError;
}
}
}
psPowerDevice = psPowerDevice->psNext;
}
return PVRSRV_OK;
}
static enum PVRSRV_ERROR PVRSRVDevicePostPowerStateKM(IMG_BOOL bAllDevices,
u32 ui32DeviceIndex,
enum PVR_POWER_STATE eNewPowerState)
{
enum PVRSRV_ERROR eError;
struct SYS_DATA *psSysData;
struct PVRSRV_POWER_DEV *psPowerDevice;
enum PVR_POWER_STATE eNewDevicePowerState;
eError = SysAcquireData(&psSysData);
if (eError != PVRSRV_OK)
return eError;
psPowerDevice = psSysData->psPowerDeviceList;
while (psPowerDevice) {
if (bAllDevices ||
(ui32DeviceIndex == psPowerDevice->ui32DeviceIndex)) {
eNewDevicePowerState = (eNewPowerState ==
PVRSRV_POWER_Unspecified) ? psPowerDevice->
eDefaultPowerState : eNewPowerState;
if (psPowerDevice->eCurrentPowerState !=
eNewDevicePowerState) {
eError = SysDevicePostPowerState(
psPowerDevice->ui32DeviceIndex,
eNewDevicePowerState,
psPowerDevice->eCurrentPowerState);
if (eError != PVRSRV_OK) {
pr_err("SysDevicePostPowerState "
"failed (%u)\n", eError);
return eError;
}
if (psPowerDevice->pfnPostPower != NULL) {
eError =
psPowerDevice->
pfnPostPower(psPowerDevice->
hDevCookie,
eNewDevicePowerState,
psPowerDevice->
eCurrentPowerState);
if (eError != PVRSRV_OK) {
pr_err
("pfnPostPower failed "
"(%u)\n", eError);
return eError;
}
}
psPowerDevice->eCurrentPowerState =
eNewDevicePowerState;
}
}
psPowerDevice = psPowerDevice->psNext;
}
return PVRSRV_OK;
}
enum PVRSRV_ERROR PVRSRVSetDevicePowerStateKM(u32 ui32DeviceIndex,
enum PVR_POWER_STATE eNewPowerState)
{
enum PVRSRV_ERROR eError;
struct SYS_DATA *psSysData;
eError = SysAcquireData(&psSysData);
if (eError != PVRSRV_OK)
return eError;
#if defined(PDUMP)
if (eNewPowerState == PVRSRV_POWER_Unspecified) {
eError =
PVRSRVDevicePrePowerStateKM(IMG_FALSE, ui32DeviceIndex,
PVRSRV_POWER_STATE_D0);
if (eError != PVRSRV_OK)
goto Exit;
eError =
PVRSRVDevicePostPowerStateKM(IMG_FALSE, ui32DeviceIndex,
PVRSRV_POWER_STATE_D0);
if (eError != PVRSRV_OK)
goto Exit;
PDUMPSUSPEND();
}
#endif
eError = PVRSRVDevicePrePowerStateKM(IMG_FALSE, ui32DeviceIndex,
eNewPowerState);
if (eError != PVRSRV_OK) {
if (eNewPowerState == PVRSRV_POWER_Unspecified)
PDUMPRESUME();
goto Exit;
}
eError = PVRSRVDevicePostPowerStateKM(IMG_FALSE, ui32DeviceIndex,
eNewPowerState);
if (eNewPowerState == PVRSRV_POWER_Unspecified)
PDUMPRESUME();
Exit:
if (eError != PVRSRV_OK) {
PVR_DPF(PVR_DBG_ERROR, "PVRSRVSetDevicePowerStateKM : "
"Transition to %d FAILED 0x%x",
eNewPowerState, eError);
}
return eError;
}
enum PVRSRV_ERROR PVRSRVSystemPrePowerStateKM(
enum PVR_POWER_STATE eNewPowerState)
{
enum PVRSRV_ERROR eError;
struct SYS_DATA *psSysData;
enum PVR_POWER_STATE eNewDevicePowerState;
eError = SysAcquireData(&psSysData);
if (eError != PVRSRV_OK)
return eError;
if (_IsSystemStatePowered(eNewPowerState) !=
_IsSystemStatePowered(psSysData->eCurrentPowerState)) {
if (_IsSystemStatePowered(eNewPowerState))
eNewDevicePowerState = PVRSRV_POWER_Unspecified;
else
eNewDevicePowerState = PVRSRV_POWER_STATE_D3;
eError = PVRSRVDevicePrePowerStateKM(IMG_TRUE, 0,
eNewDevicePowerState);
if (eError != PVRSRV_OK)
goto ErrorExit;
}
if (eNewPowerState != psSysData->eCurrentPowerState) {
eError = SysSystemPrePowerState(eNewPowerState);
if (eError != PVRSRV_OK)
goto ErrorExit;
}
return eError;
ErrorExit:
PVR_DPF(PVR_DBG_ERROR, "PVRSRVSystemPrePowerStateKM: "
"Transition from %d to %d FAILED 0x%x",
psSysData->eCurrentPowerState, eNewPowerState, eError);
psSysData->eFailedPowerState = eNewPowerState;
return eError;
}
enum PVRSRV_ERROR PVRSRVSystemPostPowerStateKM(
enum PVR_POWER_STATE eNewPowerState)
{
enum PVRSRV_ERROR eError;
struct SYS_DATA *psSysData;
enum PVR_POWER_STATE eNewDevicePowerState;
eError = SysAcquireData(&psSysData);
if (eError != PVRSRV_OK)
goto Exit;
if (eNewPowerState != psSysData->eCurrentPowerState) {
eError = SysSystemPostPowerState(eNewPowerState);
if (eError != PVRSRV_OK)
goto Exit;
}
if (_IsSystemStatePowered(eNewPowerState) !=
_IsSystemStatePowered(psSysData->eCurrentPowerState)) {
if (_IsSystemStatePowered(eNewPowerState))
eNewDevicePowerState = PVRSRV_POWER_Unspecified;
else
eNewDevicePowerState = PVRSRV_POWER_STATE_D3;
eError =
PVRSRVDevicePostPowerStateKM(IMG_TRUE, 0,
eNewDevicePowerState);
if (eError != PVRSRV_OK)
goto Exit;
}
PVR_DPF(PVR_DBG_WARNING, "PVRSRVSystemPostPowerStateKM: "
"System Power Transition from %d to %d OK",
psSysData->eCurrentPowerState, eNewPowerState);
psSysData->eCurrentPowerState = eNewPowerState;
Exit:
if (_IsSystemStatePowered(eNewPowerState) &&
PVRSRVGetInitServerState(PVRSRV_INIT_SERVER_SUCCESSFUL))
PVRSRVCommandCompleteCallbacks();
return eError;
}
enum PVRSRV_ERROR PVRSRVSetPowerStateKM(enum PVR_POWER_STATE eNewPowerState)
{
enum PVRSRV_ERROR eError;
struct SYS_DATA *psSysData;
eError = SysAcquireData(&psSysData);
if (eError != PVRSRV_OK)
return eError;
eError = PVRSRVSystemPrePowerStateKM(eNewPowerState);
if (eError != PVRSRV_OK)
goto ErrorExit;
eError = PVRSRVSystemPostPowerStateKM(eNewPowerState);
if (eError != PVRSRV_OK)
goto ErrorExit;
psSysData->eFailedPowerState = PVRSRV_POWER_Unspecified;
return PVRSRV_OK;
ErrorExit:
PVR_DPF(PVR_DBG_ERROR, "PVRSRVSetPowerStateKM: "
"Transition from %d to %d FAILED 0x%x",
psSysData->eCurrentPowerState, eNewPowerState, eError);
psSysData->eFailedPowerState = eNewPowerState;
return eError;
}
enum PVRSRV_ERROR PVRSRVRegisterPowerDevice(u32 ui32DeviceIndex,
enum PVRSRV_ERROR (*pfnPrePower)(void *, enum PVR_POWER_STATE,
enum PVR_POWER_STATE),
enum PVRSRV_ERROR (*pfnPostPower)(void *, enum PVR_POWER_STATE,
enum PVR_POWER_STATE),
enum PVRSRV_ERROR (*pfnPreClockSpeedChange)(void *, IMG_BOOL,
enum PVR_POWER_STATE),
enum PVRSRV_ERROR (*pfnPostClockSpeedChange)(void *, IMG_BOOL,
enum PVR_POWER_STATE),
void *hDevCookie, enum PVR_POWER_STATE eCurrentPowerState,
enum PVR_POWER_STATE eDefaultPowerState)
{
enum PVRSRV_ERROR eError;
struct SYS_DATA *psSysData;
struct PVRSRV_POWER_DEV *psPowerDevice;
if (pfnPrePower == NULL && pfnPostPower == NULL)
return PVRSRVRemovePowerDevice(ui32DeviceIndex);
eError = SysAcquireData(&psSysData);
if (eError != PVRSRV_OK)
return eError;
eError = OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP,
sizeof(struct PVRSRV_POWER_DEV),
(void **) &psPowerDevice, NULL);
if (eError != PVRSRV_OK) {
PVR_DPF(PVR_DBG_ERROR, "PVRSRVRegisterPowerDevice: "
"Failed to alloc struct PVRSRV_POWER_DEV");
return eError;
}
psPowerDevice->pfnPrePower = pfnPrePower;
psPowerDevice->pfnPostPower = pfnPostPower;
psPowerDevice->pfnPreClockSpeedChange = pfnPreClockSpeedChange;
psPowerDevice->pfnPostClockSpeedChange = pfnPostClockSpeedChange;
psPowerDevice->hDevCookie = hDevCookie;
psPowerDevice->ui32DeviceIndex = ui32DeviceIndex;
psPowerDevice->eCurrentPowerState = eCurrentPowerState;
psPowerDevice->eDefaultPowerState = eDefaultPowerState;
psPowerDevice->psNext = psSysData->psPowerDeviceList;
psSysData->psPowerDeviceList = psPowerDevice;
return PVRSRV_OK;
}
enum PVRSRV_ERROR PVRSRVRemovePowerDevice(u32 ui32DeviceIndex)
{
enum PVRSRV_ERROR eError;
struct SYS_DATA *psSysData;
struct PVRSRV_POWER_DEV *psCurrent, *psPrevious;
eError = SysAcquireData(&psSysData);
if (eError != PVRSRV_OK)
return eError;
psCurrent = psSysData->psPowerDeviceList;
psPrevious = NULL;
while (psCurrent)
if (psCurrent->ui32DeviceIndex == ui32DeviceIndex) {
if (psPrevious)
psPrevious->psNext = psCurrent->psNext;
else
psSysData->psPowerDeviceList =
psCurrent->psNext;
OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP,
sizeof(struct PVRSRV_POWER_DEV), psCurrent,
NULL);
break;
} else {
psPrevious = psCurrent;
psCurrent = psCurrent->psNext;
}
return PVRSRV_OK;
}
IMG_BOOL PVRSRVIsDevicePowered(u32 ui32DeviceIndex)
{
enum PVRSRV_ERROR eError;
struct SYS_DATA *psSysData;
struct PVRSRV_POWER_DEV *psPowerDevice;
eError = SysAcquireData(&psSysData);
if (eError != PVRSRV_OK)
return IMG_FALSE;
psPowerDevice = psSysData->psPowerDeviceList;
while (psPowerDevice) {
if (psPowerDevice->ui32DeviceIndex == ui32DeviceIndex)
return (IMG_BOOL)(psPowerDevice->eCurrentPowerState ==
PVRSRV_POWER_STATE_D0);
psPowerDevice = psPowerDevice->psNext;
}
return IMG_FALSE;
}
enum PVRSRV_ERROR PVRSRVDevicePreClockSpeedChange(u32 ui32DeviceIndex,
IMG_BOOL bIdleDevice,
void *pvInfo)
{
enum PVRSRV_ERROR eError = PVRSRV_OK;
struct SYS_DATA *psSysData;
struct PVRSRV_POWER_DEV *psPowerDevice;
PVR_UNREFERENCED_PARAMETER(pvInfo);
eError = SysAcquireData(&psSysData);
if (eError != PVRSRV_OK)
return eError;
psPowerDevice = psSysData->psPowerDeviceList;
while (psPowerDevice) {
if (ui32DeviceIndex == psPowerDevice->ui32DeviceIndex)
if (psPowerDevice->pfnPreClockSpeedChange) {
eError =
psPowerDevice->
pfnPreClockSpeedChange(psPowerDevice->
hDevCookie,
bIdleDevice,
psPowerDevice->
eCurrentPowerState);
if (eError != PVRSRV_OK) {
pr_err
("pfnPreClockSpeedChange failed\n");
PVR_DPF(PVR_DBG_ERROR,
"PVRSRVDevicePreClockSpeedChange : "
"Device %lu failed, error:0x%lx",
ui32DeviceIndex, eError);
break;
}
}
psPowerDevice = psPowerDevice->psNext;
}
return eError;
}
void PVRSRVDevicePostClockSpeedChange(u32 ui32DeviceIndex, IMG_BOOL bIdleDevice,
void *pvInfo)
{
enum PVRSRV_ERROR eError;
struct SYS_DATA *psSysData;
struct PVRSRV_POWER_DEV *psPowerDevice;
PVR_UNREFERENCED_PARAMETER(pvInfo);
eError = SysAcquireData(&psSysData);
if (eError != PVRSRV_OK)
return;
psPowerDevice = psSysData->psPowerDeviceList;
while (psPowerDevice) {
if (ui32DeviceIndex == psPowerDevice->ui32DeviceIndex)
if (psPowerDevice->pfnPostClockSpeedChange) {
eError =
psPowerDevice->
pfnPostClockSpeedChange(psPowerDevice->
hDevCookie,
bIdleDevice,
psPowerDevice->
eCurrentPowerState);
if (eError != PVRSRV_OK) {
pr_err
("pfnPostClockSpeedChange "
"failed\n");
PVR_DPF(PVR_DBG_ERROR,
"PVRSRVDevicePostClockSpeedChange : "
"Device %lu failed, error:0x%lx",
ui32DeviceIndex, eError);
}
}
psPowerDevice = psPowerDevice->psNext;
}
}
| caio2k/kernel-n9 | drivers/gpu/pvr/power.c | C | gpl-2.0 | 14,857 |
/*
* ARM translation
*
* Copyright (c) 2003 Fabrice Bellard
* Copyright (c) 2005-2007 CodeSourcery
* Copyright (c) 2007 OpenedHand, Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include "cpu.h"
#include "disas.h"
#include "tcg-op.h"
#include "qemu-log.h"
#include "helper.h"
#define GEN_HELPER 1
#include "helper.h"
#define ENABLE_ARCH_4T arm_feature(env, ARM_FEATURE_V4T)
#define ENABLE_ARCH_5 arm_feature(env, ARM_FEATURE_V5)
/* currently all emulated v5 cores are also v5TE, so don't bother */
#define ENABLE_ARCH_5TE arm_feature(env, ARM_FEATURE_V5)
#define ENABLE_ARCH_5J 0
#define ENABLE_ARCH_6 arm_feature(env, ARM_FEATURE_V6)
#define ENABLE_ARCH_6K arm_feature(env, ARM_FEATURE_V6K)
#define ENABLE_ARCH_6T2 arm_feature(env, ARM_FEATURE_THUMB2)
#define ENABLE_ARCH_7 arm_feature(env, ARM_FEATURE_V7)
#define ARCH(x) do { if (!ENABLE_ARCH_##x) goto illegal_op; } while(0)
/* internal defines */
typedef struct DisasContext {
target_ulong pc;
int is_jmp;
/* Nonzero if this instruction has been conditionally skipped. */
int condjmp;
/* The label that will be jumped to when the instruction is skipped. */
int condlabel;
/* Thumb-2 condtional execution bits. */
int condexec_mask;
int condexec_cond;
struct TranslationBlock *tb;
int singlestep_enabled;
int thumb;
#if !defined(CONFIG_USER_ONLY)
int user;
#endif
int vfp_enabled;
int vec_len;
int vec_stride;
} DisasContext;
static uint32_t gen_opc_condexec_bits[OPC_BUF_SIZE];
#if defined(CONFIG_USER_ONLY)
#define IS_USER(s) 1
#else
#define IS_USER(s) (s->user)
#endif
/* These instructions trap after executing, so defer them until after the
conditional executions state has been updated. */
#define DISAS_WFI 4
#define DISAS_SWI 5
static TCGv_ptr cpu_env;
/* We reuse the same 64-bit temporaries for efficiency. */
static TCGv_i64 cpu_V0, cpu_V1, cpu_M0;
static TCGv_i32 cpu_R[16];
static TCGv_i32 cpu_exclusive_addr;
static TCGv_i32 cpu_exclusive_val;
static TCGv_i32 cpu_exclusive_high;
#ifdef CONFIG_USER_ONLY
static TCGv_i32 cpu_exclusive_test;
static TCGv_i32 cpu_exclusive_info;
#endif
/* FIXME: These should be removed. */
static TCGv cpu_F0s, cpu_F1s;
static TCGv_i64 cpu_F0d, cpu_F1d;
#include "gen-icount.h"
static const char *regnames[] =
{ "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "pc" };
/* initialize TCG globals. */
void arm_translate_init(void)
{
int i;
cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env");
for (i = 0; i < 16; i++) {
cpu_R[i] = tcg_global_mem_new_i32(TCG_AREG0,
offsetof(CPUState, regs[i]),
regnames[i]);
}
cpu_exclusive_addr = tcg_global_mem_new_i32(TCG_AREG0,
offsetof(CPUState, exclusive_addr), "exclusive_addr");
cpu_exclusive_val = tcg_global_mem_new_i32(TCG_AREG0,
offsetof(CPUState, exclusive_val), "exclusive_val");
cpu_exclusive_high = tcg_global_mem_new_i32(TCG_AREG0,
offsetof(CPUState, exclusive_high), "exclusive_high");
#ifdef CONFIG_USER_ONLY
cpu_exclusive_test = tcg_global_mem_new_i32(TCG_AREG0,
offsetof(CPUState, exclusive_test), "exclusive_test");
cpu_exclusive_info = tcg_global_mem_new_i32(TCG_AREG0,
offsetof(CPUState, exclusive_info), "exclusive_info");
#endif
#define GEN_HELPER 2
#include "helper.h"
}
static inline TCGv load_cpu_offset(int offset)
{
TCGv tmp = tcg_temp_new_i32();
tcg_gen_ld_i32(tmp, cpu_env, offset);
return tmp;
}
#define load_cpu_field(name) load_cpu_offset(offsetof(CPUState, name))
static inline void store_cpu_offset(TCGv var, int offset)
{
tcg_gen_st_i32(var, cpu_env, offset);
tcg_temp_free_i32(var);
}
#define store_cpu_field(var, name) \
store_cpu_offset(var, offsetof(CPUState, name))
/* Set a variable to the value of a CPU register. */
static void load_reg_var(DisasContext *s, TCGv var, int reg)
{
if (reg == 15) {
uint32_t addr;
/* normaly, since we updated PC, we need only to add one insn */
if (s->thumb)
addr = (long)s->pc + 2;
else
addr = (long)s->pc + 4;
tcg_gen_movi_i32(var, addr);
} else {
tcg_gen_mov_i32(var, cpu_R[reg]);
}
}
/* Create a new temporary and set it to the value of a CPU register. */
static inline TCGv load_reg(DisasContext *s, int reg)
{
TCGv tmp = tcg_temp_new_i32();
load_reg_var(s, tmp, reg);
return tmp;
}
/* Set a CPU register. The source must be a temporary and will be
marked as dead. */
static void store_reg(DisasContext *s, int reg, TCGv var)
{
if (reg == 15) {
tcg_gen_andi_i32(var, var, ~1);
s->is_jmp = DISAS_JUMP;
}
tcg_gen_mov_i32(cpu_R[reg], var);
tcg_temp_free_i32(var);
}
/* Value extensions. */
#define gen_uxtb(var) tcg_gen_ext8u_i32(var, var)
#define gen_uxth(var) tcg_gen_ext16u_i32(var, var)
#define gen_sxtb(var) tcg_gen_ext8s_i32(var, var)
#define gen_sxth(var) tcg_gen_ext16s_i32(var, var)
#define gen_sxtb16(var) gen_helper_sxtb16(var, var)
#define gen_uxtb16(var) gen_helper_uxtb16(var, var)
static inline void gen_set_cpsr(TCGv var, uint32_t mask)
{
TCGv tmp_mask = tcg_const_i32(mask);
gen_helper_cpsr_write(var, tmp_mask);
tcg_temp_free_i32(tmp_mask);
}
/* Set NZCV flags from the high 4 bits of var. */
#define gen_set_nzcv(var) gen_set_cpsr(var, CPSR_NZCV)
static void gen_exception(int excp)
{
TCGv tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, excp);
gen_helper_exception(tmp);
tcg_temp_free_i32(tmp);
}
static void gen_smul_dual(TCGv a, TCGv b)
{
TCGv tmp1 = tcg_temp_new_i32();
TCGv tmp2 = tcg_temp_new_i32();
tcg_gen_ext16s_i32(tmp1, a);
tcg_gen_ext16s_i32(tmp2, b);
tcg_gen_mul_i32(tmp1, tmp1, tmp2);
tcg_temp_free_i32(tmp2);
tcg_gen_sari_i32(a, a, 16);
tcg_gen_sari_i32(b, b, 16);
tcg_gen_mul_i32(b, b, a);
tcg_gen_mov_i32(a, tmp1);
tcg_temp_free_i32(tmp1);
}
/* Byteswap each halfword. */
static void gen_rev16(TCGv var)
{
TCGv tmp = tcg_temp_new_i32();
tcg_gen_shri_i32(tmp, var, 8);
tcg_gen_andi_i32(tmp, tmp, 0x00ff00ff);
tcg_gen_shli_i32(var, var, 8);
tcg_gen_andi_i32(var, var, 0xff00ff00);
tcg_gen_or_i32(var, var, tmp);
tcg_temp_free_i32(tmp);
}
/* Byteswap low halfword and sign extend. */
static void gen_revsh(TCGv var)
{
tcg_gen_ext16u_i32(var, var);
tcg_gen_bswap16_i32(var, var);
tcg_gen_ext16s_i32(var, var);
}
/* Unsigned bitfield extract. */
static void gen_ubfx(TCGv var, int shift, uint32_t mask)
{
if (shift)
tcg_gen_shri_i32(var, var, shift);
tcg_gen_andi_i32(var, var, mask);
}
/* Signed bitfield extract. */
static void gen_sbfx(TCGv var, int shift, int width)
{
uint32_t signbit;
if (shift)
tcg_gen_sari_i32(var, var, shift);
if (shift + width < 32) {
signbit = 1u << (width - 1);
tcg_gen_andi_i32(var, var, (1u << width) - 1);
tcg_gen_xori_i32(var, var, signbit);
tcg_gen_subi_i32(var, var, signbit);
}
}
/* Bitfield insertion. Insert val into base. Clobbers base and val. */
static void gen_bfi(TCGv dest, TCGv base, TCGv val, int shift, uint32_t mask)
{
tcg_gen_andi_i32(val, val, mask);
tcg_gen_shli_i32(val, val, shift);
tcg_gen_andi_i32(base, base, ~(mask << shift));
tcg_gen_or_i32(dest, base, val);
}
/* Return (b << 32) + a. Mark inputs as dead */
static TCGv_i64 gen_addq_msw(TCGv_i64 a, TCGv b)
{
TCGv_i64 tmp64 = tcg_temp_new_i64();
tcg_gen_extu_i32_i64(tmp64, b);
tcg_temp_free_i32(b);
tcg_gen_shli_i64(tmp64, tmp64, 32);
tcg_gen_add_i64(a, tmp64, a);
tcg_temp_free_i64(tmp64);
return a;
}
/* Return (b << 32) - a. Mark inputs as dead. */
static TCGv_i64 gen_subq_msw(TCGv_i64 a, TCGv b)
{
TCGv_i64 tmp64 = tcg_temp_new_i64();
tcg_gen_extu_i32_i64(tmp64, b);
tcg_temp_free_i32(b);
tcg_gen_shli_i64(tmp64, tmp64, 32);
tcg_gen_sub_i64(a, tmp64, a);
tcg_temp_free_i64(tmp64);
return a;
}
/* FIXME: Most targets have native widening multiplication.
It would be good to use that instead of a full wide multiply. */
/* 32x32->64 multiply. Marks inputs as dead. */
static TCGv_i64 gen_mulu_i64_i32(TCGv a, TCGv b)
{
TCGv_i64 tmp1 = tcg_temp_new_i64();
TCGv_i64 tmp2 = tcg_temp_new_i64();
tcg_gen_extu_i32_i64(tmp1, a);
tcg_temp_free_i32(a);
tcg_gen_extu_i32_i64(tmp2, b);
tcg_temp_free_i32(b);
tcg_gen_mul_i64(tmp1, tmp1, tmp2);
tcg_temp_free_i64(tmp2);
return tmp1;
}
static TCGv_i64 gen_muls_i64_i32(TCGv a, TCGv b)
{
TCGv_i64 tmp1 = tcg_temp_new_i64();
TCGv_i64 tmp2 = tcg_temp_new_i64();
tcg_gen_ext_i32_i64(tmp1, a);
tcg_temp_free_i32(a);
tcg_gen_ext_i32_i64(tmp2, b);
tcg_temp_free_i32(b);
tcg_gen_mul_i64(tmp1, tmp1, tmp2);
tcg_temp_free_i64(tmp2);
return tmp1;
}
/* Swap low and high halfwords. */
static void gen_swap_half(TCGv var)
{
TCGv tmp = tcg_temp_new_i32();
tcg_gen_shri_i32(tmp, var, 16);
tcg_gen_shli_i32(var, var, 16);
tcg_gen_or_i32(var, var, tmp);
tcg_temp_free_i32(tmp);
}
/* Dual 16-bit add. Result placed in t0 and t1 is marked as dead.
tmp = (t0 ^ t1) & 0x8000;
t0 &= ~0x8000;
t1 &= ~0x8000;
t0 = (t0 + t1) ^ tmp;
*/
static void gen_add16(TCGv t0, TCGv t1)
{
TCGv tmp = tcg_temp_new_i32();
tcg_gen_xor_i32(tmp, t0, t1);
tcg_gen_andi_i32(tmp, tmp, 0x8000);
tcg_gen_andi_i32(t0, t0, ~0x8000);
tcg_gen_andi_i32(t1, t1, ~0x8000);
tcg_gen_add_i32(t0, t0, t1);
tcg_gen_xor_i32(t0, t0, tmp);
tcg_temp_free_i32(tmp);
tcg_temp_free_i32(t1);
}
#define gen_set_CF(var) tcg_gen_st_i32(var, cpu_env, offsetof(CPUState, CF))
/* Set CF to the top bit of var. */
static void gen_set_CF_bit31(TCGv var)
{
TCGv tmp = tcg_temp_new_i32();
tcg_gen_shri_i32(tmp, var, 31);
gen_set_CF(tmp);
tcg_temp_free_i32(tmp);
}
/* Set N and Z flags from var. */
static inline void gen_logic_CC(TCGv var)
{
tcg_gen_st_i32(var, cpu_env, offsetof(CPUState, NF));
tcg_gen_st_i32(var, cpu_env, offsetof(CPUState, ZF));
}
/* T0 += T1 + CF. */
static void gen_adc(TCGv t0, TCGv t1)
{
TCGv tmp;
tcg_gen_add_i32(t0, t0, t1);
tmp = load_cpu_field(CF);
tcg_gen_add_i32(t0, t0, tmp);
tcg_temp_free_i32(tmp);
}
/* dest = T0 + T1 + CF. */
static void gen_add_carry(TCGv dest, TCGv t0, TCGv t1)
{
TCGv tmp;
tcg_gen_add_i32(dest, t0, t1);
tmp = load_cpu_field(CF);
tcg_gen_add_i32(dest, dest, tmp);
tcg_temp_free_i32(tmp);
}
/* dest = T0 - T1 + CF - 1. */
static void gen_sub_carry(TCGv dest, TCGv t0, TCGv t1)
{
TCGv tmp;
tcg_gen_sub_i32(dest, t0, t1);
tmp = load_cpu_field(CF);
tcg_gen_add_i32(dest, dest, tmp);
tcg_gen_subi_i32(dest, dest, 1);
tcg_temp_free_i32(tmp);
}
/* FIXME: Implement this natively. */
#define tcg_gen_abs_i32(t0, t1) gen_helper_abs(t0, t1)
static void shifter_out_im(TCGv var, int shift)
{
TCGv tmp = tcg_temp_new_i32();
if (shift == 0) {
tcg_gen_andi_i32(tmp, var, 1);
} else {
tcg_gen_shri_i32(tmp, var, shift);
if (shift != 31)
tcg_gen_andi_i32(tmp, tmp, 1);
}
gen_set_CF(tmp);
tcg_temp_free_i32(tmp);
}
/* Shift by immediate. Includes special handling for shift == 0. */
static inline void gen_arm_shift_im(TCGv var, int shiftop, int shift, int flags)
{
switch (shiftop) {
case 0: /* LSL */
if (shift != 0) {
if (flags)
shifter_out_im(var, 32 - shift);
tcg_gen_shli_i32(var, var, shift);
}
break;
case 1: /* LSR */
if (shift == 0) {
if (flags) {
tcg_gen_shri_i32(var, var, 31);
gen_set_CF(var);
}
tcg_gen_movi_i32(var, 0);
} else {
if (flags)
shifter_out_im(var, shift - 1);
tcg_gen_shri_i32(var, var, shift);
}
break;
case 2: /* ASR */
if (shift == 0)
shift = 32;
if (flags)
shifter_out_im(var, shift - 1);
if (shift == 32)
shift = 31;
tcg_gen_sari_i32(var, var, shift);
break;
case 3: /* ROR/RRX */
if (shift != 0) {
if (flags)
shifter_out_im(var, shift - 1);
tcg_gen_rotri_i32(var, var, shift); break;
} else {
TCGv tmp = load_cpu_field(CF);
if (flags)
shifter_out_im(var, 0);
tcg_gen_shri_i32(var, var, 1);
tcg_gen_shli_i32(tmp, tmp, 31);
tcg_gen_or_i32(var, var, tmp);
tcg_temp_free_i32(tmp);
}
}
};
static inline void gen_arm_shift_reg(TCGv var, int shiftop,
TCGv shift, int flags)
{
if (flags) {
switch (shiftop) {
case 0: gen_helper_shl_cc(var, var, shift); break;
case 1: gen_helper_shr_cc(var, var, shift); break;
case 2: gen_helper_sar_cc(var, var, shift); break;
case 3: gen_helper_ror_cc(var, var, shift); break;
}
} else {
switch (shiftop) {
case 0: gen_helper_shl(var, var, shift); break;
case 1: gen_helper_shr(var, var, shift); break;
case 2: gen_helper_sar(var, var, shift); break;
case 3: tcg_gen_andi_i32(shift, shift, 0x1f);
tcg_gen_rotr_i32(var, var, shift); break;
}
}
tcg_temp_free_i32(shift);
}
#define PAS_OP(pfx) \
switch (op2) { \
case 0: gen_pas_helper(glue(pfx,add16)); break; \
case 1: gen_pas_helper(glue(pfx,addsubx)); break; \
case 2: gen_pas_helper(glue(pfx,subaddx)); break; \
case 3: gen_pas_helper(glue(pfx,sub16)); break; \
case 4: gen_pas_helper(glue(pfx,add8)); break; \
case 7: gen_pas_helper(glue(pfx,sub8)); break; \
}
static void gen_arm_parallel_addsub(int op1, int op2, TCGv a, TCGv b)
{
TCGv_ptr tmp;
switch (op1) {
#define gen_pas_helper(name) glue(gen_helper_,name)(a, a, b, tmp)
case 1:
tmp = tcg_temp_new_ptr();
tcg_gen_addi_ptr(tmp, cpu_env, offsetof(CPUState, GE));
PAS_OP(s)
tcg_temp_free_ptr(tmp);
break;
case 5:
tmp = tcg_temp_new_ptr();
tcg_gen_addi_ptr(tmp, cpu_env, offsetof(CPUState, GE));
PAS_OP(u)
tcg_temp_free_ptr(tmp);
break;
#undef gen_pas_helper
#define gen_pas_helper(name) glue(gen_helper_,name)(a, a, b)
case 2:
PAS_OP(q);
break;
case 3:
PAS_OP(sh);
break;
case 6:
PAS_OP(uq);
break;
case 7:
PAS_OP(uh);
break;
#undef gen_pas_helper
}
}
#undef PAS_OP
/* For unknown reasons Arm and Thumb-2 use arbitrarily different encodings. */
#define PAS_OP(pfx) \
switch (op1) { \
case 0: gen_pas_helper(glue(pfx,add8)); break; \
case 1: gen_pas_helper(glue(pfx,add16)); break; \
case 2: gen_pas_helper(glue(pfx,addsubx)); break; \
case 4: gen_pas_helper(glue(pfx,sub8)); break; \
case 5: gen_pas_helper(glue(pfx,sub16)); break; \
case 6: gen_pas_helper(glue(pfx,subaddx)); break; \
}
static void gen_thumb2_parallel_addsub(int op1, int op2, TCGv a, TCGv b)
{
TCGv_ptr tmp;
switch (op2) {
#define gen_pas_helper(name) glue(gen_helper_,name)(a, a, b, tmp)
case 0:
tmp = tcg_temp_new_ptr();
tcg_gen_addi_ptr(tmp, cpu_env, offsetof(CPUState, GE));
PAS_OP(s)
tcg_temp_free_ptr(tmp);
break;
case 4:
tmp = tcg_temp_new_ptr();
tcg_gen_addi_ptr(tmp, cpu_env, offsetof(CPUState, GE));
PAS_OP(u)
tcg_temp_free_ptr(tmp);
break;
#undef gen_pas_helper
#define gen_pas_helper(name) glue(gen_helper_,name)(a, a, b)
case 1:
PAS_OP(q);
break;
case 2:
PAS_OP(sh);
break;
case 5:
PAS_OP(uq);
break;
case 6:
PAS_OP(uh);
break;
#undef gen_pas_helper
}
}
#undef PAS_OP
static void gen_test_cc(int cc, int label)
{
TCGv tmp;
TCGv tmp2;
int inv;
switch (cc) {
case 0: /* eq: Z */
tmp = load_cpu_field(ZF);
tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, label);
break;
case 1: /* ne: !Z */
tmp = load_cpu_field(ZF);
tcg_gen_brcondi_i32(TCG_COND_NE, tmp, 0, label);
break;
case 2: /* cs: C */
tmp = load_cpu_field(CF);
tcg_gen_brcondi_i32(TCG_COND_NE, tmp, 0, label);
break;
case 3: /* cc: !C */
tmp = load_cpu_field(CF);
tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, label);
break;
case 4: /* mi: N */
tmp = load_cpu_field(NF);
tcg_gen_brcondi_i32(TCG_COND_LT, tmp, 0, label);
break;
case 5: /* pl: !N */
tmp = load_cpu_field(NF);
tcg_gen_brcondi_i32(TCG_COND_GE, tmp, 0, label);
break;
case 6: /* vs: V */
tmp = load_cpu_field(VF);
tcg_gen_brcondi_i32(TCG_COND_LT, tmp, 0, label);
break;
case 7: /* vc: !V */
tmp = load_cpu_field(VF);
tcg_gen_brcondi_i32(TCG_COND_GE, tmp, 0, label);
break;
case 8: /* hi: C && !Z */
inv = gen_new_label();
tmp = load_cpu_field(CF);
tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, inv);
tcg_temp_free_i32(tmp);
tmp = load_cpu_field(ZF);
tcg_gen_brcondi_i32(TCG_COND_NE, tmp, 0, label);
gen_set_label(inv);
break;
case 9: /* ls: !C || Z */
tmp = load_cpu_field(CF);
tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, label);
tcg_temp_free_i32(tmp);
tmp = load_cpu_field(ZF);
tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, label);
break;
case 10: /* ge: N == V -> N ^ V == 0 */
tmp = load_cpu_field(VF);
tmp2 = load_cpu_field(NF);
tcg_gen_xor_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
tcg_gen_brcondi_i32(TCG_COND_GE, tmp, 0, label);
break;
case 11: /* lt: N != V -> N ^ V != 0 */
tmp = load_cpu_field(VF);
tmp2 = load_cpu_field(NF);
tcg_gen_xor_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
tcg_gen_brcondi_i32(TCG_COND_LT, tmp, 0, label);
break;
case 12: /* gt: !Z && N == V */
inv = gen_new_label();
tmp = load_cpu_field(ZF);
tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, inv);
tcg_temp_free_i32(tmp);
tmp = load_cpu_field(VF);
tmp2 = load_cpu_field(NF);
tcg_gen_xor_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
tcg_gen_brcondi_i32(TCG_COND_GE, tmp, 0, label);
gen_set_label(inv);
break;
case 13: /* le: Z || N != V */
tmp = load_cpu_field(ZF);
tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, label);
tcg_temp_free_i32(tmp);
tmp = load_cpu_field(VF);
tmp2 = load_cpu_field(NF);
tcg_gen_xor_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
tcg_gen_brcondi_i32(TCG_COND_LT, tmp, 0, label);
break;
default:
fprintf(stderr, "Bad condition code 0x%x\n", cc);
abort();
}
tcg_temp_free_i32(tmp);
}
static const uint8_t table_logic_cc[16] = {
1, /* and */
1, /* xor */
0, /* sub */
0, /* rsb */
0, /* add */
0, /* adc */
0, /* sbc */
0, /* rsc */
1, /* andl */
1, /* xorl */
0, /* cmp */
0, /* cmn */
1, /* orr */
1, /* mov */
1, /* bic */
1, /* mvn */
};
/* Set PC and Thumb state from an immediate address. */
static inline void gen_bx_im(DisasContext *s, uint32_t addr)
{
TCGv tmp;
s->is_jmp = DISAS_UPDATE;
if (s->thumb != (addr & 1)) {
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, addr & 1);
tcg_gen_st_i32(tmp, cpu_env, offsetof(CPUState, thumb));
tcg_temp_free_i32(tmp);
}
tcg_gen_movi_i32(cpu_R[15], addr & ~1);
}
/* Set PC and Thumb state from var. var is marked as dead. */
static inline void gen_bx(DisasContext *s, TCGv var)
{
s->is_jmp = DISAS_UPDATE;
tcg_gen_andi_i32(cpu_R[15], var, ~1);
tcg_gen_andi_i32(var, var, 1);
store_cpu_field(var, thumb);
}
/* Variant of store_reg which uses branch&exchange logic when storing
to r15 in ARM architecture v7 and above. The source must be a temporary
and will be marked as dead. */
static inline void store_reg_bx(CPUState *env, DisasContext *s,
int reg, TCGv var)
{
if (reg == 15 && ENABLE_ARCH_7) {
gen_bx(s, var);
} else {
store_reg(s, reg, var);
}
}
/* Variant of store_reg which uses branch&exchange logic when storing
* to r15 in ARM architecture v5T and above. This is used for storing
* the results of a LDR/LDM/POP into r15, and corresponds to the cases
* in the ARM ARM which use the LoadWritePC() pseudocode function. */
static inline void store_reg_from_load(CPUState *env, DisasContext *s,
int reg, TCGv var)
{
if (reg == 15 && ENABLE_ARCH_5) {
gen_bx(s, var);
} else {
store_reg(s, reg, var);
}
}
static inline TCGv gen_ld8s(TCGv addr, int index)
{
TCGv tmp = tcg_temp_new_i32();
tcg_gen_qemu_ld8s(tmp, addr, index);
return tmp;
}
static inline TCGv gen_ld8u(TCGv addr, int index)
{
TCGv tmp = tcg_temp_new_i32();
tcg_gen_qemu_ld8u(tmp, addr, index);
return tmp;
}
static inline TCGv gen_ld16s(TCGv addr, int index)
{
TCGv tmp = tcg_temp_new_i32();
tcg_gen_qemu_ld16s(tmp, addr, index);
return tmp;
}
static inline TCGv gen_ld16u(TCGv addr, int index)
{
TCGv tmp = tcg_temp_new_i32();
tcg_gen_qemu_ld16u(tmp, addr, index);
return tmp;
}
static inline TCGv gen_ld32(TCGv addr, int index)
{
TCGv tmp = tcg_temp_new_i32();
tcg_gen_qemu_ld32u(tmp, addr, index);
return tmp;
}
static inline TCGv_i64 gen_ld64(TCGv addr, int index)
{
TCGv_i64 tmp = tcg_temp_new_i64();
tcg_gen_qemu_ld64(tmp, addr, index);
return tmp;
}
static inline void gen_st8(TCGv val, TCGv addr, int index)
{
tcg_gen_qemu_st8(val, addr, index);
tcg_temp_free_i32(val);
}
static inline void gen_st16(TCGv val, TCGv addr, int index)
{
tcg_gen_qemu_st16(val, addr, index);
tcg_temp_free_i32(val);
}
static inline void gen_st32(TCGv val, TCGv addr, int index)
{
tcg_gen_qemu_st32(val, addr, index);
tcg_temp_free_i32(val);
}
static inline void gen_st64(TCGv_i64 val, TCGv addr, int index)
{
tcg_gen_qemu_st64(val, addr, index);
tcg_temp_free_i64(val);
}
static inline void gen_set_pc_im(uint32_t val)
{
tcg_gen_movi_i32(cpu_R[15], val);
}
/* Force a TB lookup after an instruction that changes the CPU state. */
static inline void gen_lookup_tb(DisasContext *s)
{
tcg_gen_movi_i32(cpu_R[15], s->pc & ~1);
s->is_jmp = DISAS_UPDATE;
}
static inline void gen_add_data_offset(DisasContext *s, unsigned int insn,
TCGv var)
{
int val, rm, shift, shiftop;
TCGv offset;
if (!(insn & (1 << 25))) {
/* immediate */
val = insn & 0xfff;
if (!(insn & (1 << 23)))
val = -val;
if (val != 0)
tcg_gen_addi_i32(var, var, val);
} else {
/* shift/register */
rm = (insn) & 0xf;
shift = (insn >> 7) & 0x1f;
shiftop = (insn >> 5) & 3;
offset = load_reg(s, rm);
gen_arm_shift_im(offset, shiftop, shift, 0);
if (!(insn & (1 << 23)))
tcg_gen_sub_i32(var, var, offset);
else
tcg_gen_add_i32(var, var, offset);
tcg_temp_free_i32(offset);
}
}
static inline void gen_add_datah_offset(DisasContext *s, unsigned int insn,
int extra, TCGv var)
{
int val, rm;
TCGv offset;
if (insn & (1 << 22)) {
/* immediate */
val = (insn & 0xf) | ((insn >> 4) & 0xf0);
if (!(insn & (1 << 23)))
val = -val;
val += extra;
if (val != 0)
tcg_gen_addi_i32(var, var, val);
} else {
/* register */
if (extra)
tcg_gen_addi_i32(var, var, extra);
rm = (insn) & 0xf;
offset = load_reg(s, rm);
if (!(insn & (1 << 23)))
tcg_gen_sub_i32(var, var, offset);
else
tcg_gen_add_i32(var, var, offset);
tcg_temp_free_i32(offset);
}
}
static TCGv_ptr get_fpstatus_ptr(int neon)
{
TCGv_ptr statusptr = tcg_temp_new_ptr();
int offset;
if (neon) {
offset = offsetof(CPUState, vfp.standard_fp_status);
} else {
offset = offsetof(CPUState, vfp.fp_status);
}
tcg_gen_addi_ptr(statusptr, cpu_env, offset);
return statusptr;
}
#define VFP_OP2(name) \
static inline void gen_vfp_##name(int dp) \
{ \
TCGv_ptr fpst = get_fpstatus_ptr(0); \
if (dp) { \
gen_helper_vfp_##name##d(cpu_F0d, cpu_F0d, cpu_F1d, fpst); \
} else { \
gen_helper_vfp_##name##s(cpu_F0s, cpu_F0s, cpu_F1s, fpst); \
} \
tcg_temp_free_ptr(fpst); \
}
VFP_OP2(add)
VFP_OP2(sub)
VFP_OP2(mul)
VFP_OP2(div)
#undef VFP_OP2
static inline void gen_vfp_F1_mul(int dp)
{
/* Like gen_vfp_mul() but put result in F1 */
TCGv_ptr fpst = get_fpstatus_ptr(0);
if (dp) {
gen_helper_vfp_muld(cpu_F1d, cpu_F0d, cpu_F1d, fpst);
} else {
gen_helper_vfp_muls(cpu_F1s, cpu_F0s, cpu_F1s, fpst);
}
tcg_temp_free_ptr(fpst);
}
static inline void gen_vfp_F1_neg(int dp)
{
/* Like gen_vfp_neg() but put result in F1 */
if (dp) {
gen_helper_vfp_negd(cpu_F1d, cpu_F0d);
} else {
gen_helper_vfp_negs(cpu_F1s, cpu_F0s);
}
}
static inline void gen_vfp_abs(int dp)
{
if (dp)
gen_helper_vfp_absd(cpu_F0d, cpu_F0d);
else
gen_helper_vfp_abss(cpu_F0s, cpu_F0s);
}
static inline void gen_vfp_neg(int dp)
{
if (dp)
gen_helper_vfp_negd(cpu_F0d, cpu_F0d);
else
gen_helper_vfp_negs(cpu_F0s, cpu_F0s);
}
static inline void gen_vfp_sqrt(int dp)
{
if (dp)
gen_helper_vfp_sqrtd(cpu_F0d, cpu_F0d, cpu_env);
else
gen_helper_vfp_sqrts(cpu_F0s, cpu_F0s, cpu_env);
}
static inline void gen_vfp_cmp(int dp)
{
if (dp)
gen_helper_vfp_cmpd(cpu_F0d, cpu_F1d, cpu_env);
else
gen_helper_vfp_cmps(cpu_F0s, cpu_F1s, cpu_env);
}
static inline void gen_vfp_cmpe(int dp)
{
if (dp)
gen_helper_vfp_cmped(cpu_F0d, cpu_F1d, cpu_env);
else
gen_helper_vfp_cmpes(cpu_F0s, cpu_F1s, cpu_env);
}
static inline void gen_vfp_F1_ld0(int dp)
{
if (dp)
tcg_gen_movi_i64(cpu_F1d, 0);
else
tcg_gen_movi_i32(cpu_F1s, 0);
}
#define VFP_GEN_ITOF(name) \
static inline void gen_vfp_##name(int dp, int neon) \
{ \
TCGv_ptr statusptr = get_fpstatus_ptr(neon); \
if (dp) { \
gen_helper_vfp_##name##d(cpu_F0d, cpu_F0s, statusptr); \
} else { \
gen_helper_vfp_##name##s(cpu_F0s, cpu_F0s, statusptr); \
} \
tcg_temp_free_ptr(statusptr); \
}
VFP_GEN_ITOF(uito)
VFP_GEN_ITOF(sito)
#undef VFP_GEN_ITOF
#define VFP_GEN_FTOI(name) \
static inline void gen_vfp_##name(int dp, int neon) \
{ \
TCGv_ptr statusptr = get_fpstatus_ptr(neon); \
if (dp) { \
gen_helper_vfp_##name##d(cpu_F0s, cpu_F0d, statusptr); \
} else { \
gen_helper_vfp_##name##s(cpu_F0s, cpu_F0s, statusptr); \
} \
tcg_temp_free_ptr(statusptr); \
}
VFP_GEN_FTOI(toui)
VFP_GEN_FTOI(touiz)
VFP_GEN_FTOI(tosi)
VFP_GEN_FTOI(tosiz)
#undef VFP_GEN_FTOI
#define VFP_GEN_FIX(name) \
static inline void gen_vfp_##name(int dp, int shift, int neon) \
{ \
TCGv tmp_shift = tcg_const_i32(shift); \
TCGv_ptr statusptr = get_fpstatus_ptr(neon); \
if (dp) { \
gen_helper_vfp_##name##d(cpu_F0d, cpu_F0d, tmp_shift, statusptr); \
} else { \
gen_helper_vfp_##name##s(cpu_F0s, cpu_F0s, tmp_shift, statusptr); \
} \
tcg_temp_free_i32(tmp_shift); \
tcg_temp_free_ptr(statusptr); \
}
VFP_GEN_FIX(tosh)
VFP_GEN_FIX(tosl)
VFP_GEN_FIX(touh)
VFP_GEN_FIX(toul)
VFP_GEN_FIX(shto)
VFP_GEN_FIX(slto)
VFP_GEN_FIX(uhto)
VFP_GEN_FIX(ulto)
#undef VFP_GEN_FIX
static inline void gen_vfp_ld(DisasContext *s, int dp, TCGv addr)
{
if (dp)
tcg_gen_qemu_ld64(cpu_F0d, addr, IS_USER(s));
else
tcg_gen_qemu_ld32u(cpu_F0s, addr, IS_USER(s));
}
static inline void gen_vfp_st(DisasContext *s, int dp, TCGv addr)
{
if (dp)
tcg_gen_qemu_st64(cpu_F0d, addr, IS_USER(s));
else
tcg_gen_qemu_st32(cpu_F0s, addr, IS_USER(s));
}
static inline long
vfp_reg_offset (int dp, int reg)
{
if (dp)
return offsetof(CPUARMState, vfp.regs[reg]);
else if (reg & 1) {
return offsetof(CPUARMState, vfp.regs[reg >> 1])
+ offsetof(CPU_DoubleU, l.upper);
} else {
return offsetof(CPUARMState, vfp.regs[reg >> 1])
+ offsetof(CPU_DoubleU, l.lower);
}
}
/* Return the offset of a 32-bit piece of a NEON register.
zero is the least significant end of the register. */
static inline long
neon_reg_offset (int reg, int n)
{
int sreg;
sreg = reg * 2 + n;
return vfp_reg_offset(0, sreg);
}
static TCGv neon_load_reg(int reg, int pass)
{
TCGv tmp = tcg_temp_new_i32();
tcg_gen_ld_i32(tmp, cpu_env, neon_reg_offset(reg, pass));
return tmp;
}
static void neon_store_reg(int reg, int pass, TCGv var)
{
tcg_gen_st_i32(var, cpu_env, neon_reg_offset(reg, pass));
tcg_temp_free_i32(var);
}
static inline void neon_load_reg64(TCGv_i64 var, int reg)
{
tcg_gen_ld_i64(var, cpu_env, vfp_reg_offset(1, reg));
}
static inline void neon_store_reg64(TCGv_i64 var, int reg)
{
tcg_gen_st_i64(var, cpu_env, vfp_reg_offset(1, reg));
}
#define tcg_gen_ld_f32 tcg_gen_ld_i32
#define tcg_gen_ld_f64 tcg_gen_ld_i64
#define tcg_gen_st_f32 tcg_gen_st_i32
#define tcg_gen_st_f64 tcg_gen_st_i64
static inline void gen_mov_F0_vreg(int dp, int reg)
{
if (dp)
tcg_gen_ld_f64(cpu_F0d, cpu_env, vfp_reg_offset(dp, reg));
else
tcg_gen_ld_f32(cpu_F0s, cpu_env, vfp_reg_offset(dp, reg));
}
static inline void gen_mov_F1_vreg(int dp, int reg)
{
if (dp)
tcg_gen_ld_f64(cpu_F1d, cpu_env, vfp_reg_offset(dp, reg));
else
tcg_gen_ld_f32(cpu_F1s, cpu_env, vfp_reg_offset(dp, reg));
}
static inline void gen_mov_vreg_F0(int dp, int reg)
{
if (dp)
tcg_gen_st_f64(cpu_F0d, cpu_env, vfp_reg_offset(dp, reg));
else
tcg_gen_st_f32(cpu_F0s, cpu_env, vfp_reg_offset(dp, reg));
}
#define ARM_CP_RW_BIT (1 << 20)
static inline void iwmmxt_load_reg(TCGv_i64 var, int reg)
{
tcg_gen_ld_i64(var, cpu_env, offsetof(CPUState, iwmmxt.regs[reg]));
}
static inline void iwmmxt_store_reg(TCGv_i64 var, int reg)
{
tcg_gen_st_i64(var, cpu_env, offsetof(CPUState, iwmmxt.regs[reg]));
}
static inline TCGv iwmmxt_load_creg(int reg)
{
TCGv var = tcg_temp_new_i32();
tcg_gen_ld_i32(var, cpu_env, offsetof(CPUState, iwmmxt.cregs[reg]));
return var;
}
static inline void iwmmxt_store_creg(int reg, TCGv var)
{
tcg_gen_st_i32(var, cpu_env, offsetof(CPUState, iwmmxt.cregs[reg]));
tcg_temp_free_i32(var);
}
static inline void gen_op_iwmmxt_movq_wRn_M0(int rn)
{
iwmmxt_store_reg(cpu_M0, rn);
}
static inline void gen_op_iwmmxt_movq_M0_wRn(int rn)
{
iwmmxt_load_reg(cpu_M0, rn);
}
static inline void gen_op_iwmmxt_orq_M0_wRn(int rn)
{
iwmmxt_load_reg(cpu_V1, rn);
tcg_gen_or_i64(cpu_M0, cpu_M0, cpu_V1);
}
static inline void gen_op_iwmmxt_andq_M0_wRn(int rn)
{
iwmmxt_load_reg(cpu_V1, rn);
tcg_gen_and_i64(cpu_M0, cpu_M0, cpu_V1);
}
static inline void gen_op_iwmmxt_xorq_M0_wRn(int rn)
{
iwmmxt_load_reg(cpu_V1, rn);
tcg_gen_xor_i64(cpu_M0, cpu_M0, cpu_V1);
}
#define IWMMXT_OP(name) \
static inline void gen_op_iwmmxt_##name##_M0_wRn(int rn) \
{ \
iwmmxt_load_reg(cpu_V1, rn); \
gen_helper_iwmmxt_##name(cpu_M0, cpu_M0, cpu_V1); \
}
#define IWMMXT_OP_ENV(name) \
static inline void gen_op_iwmmxt_##name##_M0_wRn(int rn) \
{ \
iwmmxt_load_reg(cpu_V1, rn); \
gen_helper_iwmmxt_##name(cpu_M0, cpu_env, cpu_M0, cpu_V1); \
}
#define IWMMXT_OP_ENV_SIZE(name) \
IWMMXT_OP_ENV(name##b) \
IWMMXT_OP_ENV(name##w) \
IWMMXT_OP_ENV(name##l)
#define IWMMXT_OP_ENV1(name) \
static inline void gen_op_iwmmxt_##name##_M0(void) \
{ \
gen_helper_iwmmxt_##name(cpu_M0, cpu_env, cpu_M0); \
}
IWMMXT_OP(maddsq)
IWMMXT_OP(madduq)
IWMMXT_OP(sadb)
IWMMXT_OP(sadw)
IWMMXT_OP(mulslw)
IWMMXT_OP(mulshw)
IWMMXT_OP(mululw)
IWMMXT_OP(muluhw)
IWMMXT_OP(macsw)
IWMMXT_OP(macuw)
IWMMXT_OP_ENV_SIZE(unpackl)
IWMMXT_OP_ENV_SIZE(unpackh)
IWMMXT_OP_ENV1(unpacklub)
IWMMXT_OP_ENV1(unpackluw)
IWMMXT_OP_ENV1(unpacklul)
IWMMXT_OP_ENV1(unpackhub)
IWMMXT_OP_ENV1(unpackhuw)
IWMMXT_OP_ENV1(unpackhul)
IWMMXT_OP_ENV1(unpacklsb)
IWMMXT_OP_ENV1(unpacklsw)
IWMMXT_OP_ENV1(unpacklsl)
IWMMXT_OP_ENV1(unpackhsb)
IWMMXT_OP_ENV1(unpackhsw)
IWMMXT_OP_ENV1(unpackhsl)
IWMMXT_OP_ENV_SIZE(cmpeq)
IWMMXT_OP_ENV_SIZE(cmpgtu)
IWMMXT_OP_ENV_SIZE(cmpgts)
IWMMXT_OP_ENV_SIZE(mins)
IWMMXT_OP_ENV_SIZE(minu)
IWMMXT_OP_ENV_SIZE(maxs)
IWMMXT_OP_ENV_SIZE(maxu)
IWMMXT_OP_ENV_SIZE(subn)
IWMMXT_OP_ENV_SIZE(addn)
IWMMXT_OP_ENV_SIZE(subu)
IWMMXT_OP_ENV_SIZE(addu)
IWMMXT_OP_ENV_SIZE(subs)
IWMMXT_OP_ENV_SIZE(adds)
IWMMXT_OP_ENV(avgb0)
IWMMXT_OP_ENV(avgb1)
IWMMXT_OP_ENV(avgw0)
IWMMXT_OP_ENV(avgw1)
IWMMXT_OP(msadb)
IWMMXT_OP_ENV(packuw)
IWMMXT_OP_ENV(packul)
IWMMXT_OP_ENV(packuq)
IWMMXT_OP_ENV(packsw)
IWMMXT_OP_ENV(packsl)
IWMMXT_OP_ENV(packsq)
static void gen_op_iwmmxt_set_mup(void)
{
TCGv tmp;
tmp = load_cpu_field(iwmmxt.cregs[ARM_IWMMXT_wCon]);
tcg_gen_ori_i32(tmp, tmp, 2);
store_cpu_field(tmp, iwmmxt.cregs[ARM_IWMMXT_wCon]);
}
static void gen_op_iwmmxt_set_cup(void)
{
TCGv tmp;
tmp = load_cpu_field(iwmmxt.cregs[ARM_IWMMXT_wCon]);
tcg_gen_ori_i32(tmp, tmp, 1);
store_cpu_field(tmp, iwmmxt.cregs[ARM_IWMMXT_wCon]);
}
static void gen_op_iwmmxt_setpsr_nz(void)
{
TCGv tmp = tcg_temp_new_i32();
gen_helper_iwmmxt_setpsr_nz(tmp, cpu_M0);
store_cpu_field(tmp, iwmmxt.cregs[ARM_IWMMXT_wCASF]);
}
static inline void gen_op_iwmmxt_addl_M0_wRn(int rn)
{
iwmmxt_load_reg(cpu_V1, rn);
tcg_gen_ext32u_i64(cpu_V1, cpu_V1);
tcg_gen_add_i64(cpu_M0, cpu_M0, cpu_V1);
}
static inline int gen_iwmmxt_address(DisasContext *s, uint32_t insn, TCGv dest)
{
int rd;
uint32_t offset;
TCGv tmp;
rd = (insn >> 16) & 0xf;
tmp = load_reg(s, rd);
offset = (insn & 0xff) << ((insn >> 7) & 2);
if (insn & (1 << 24)) {
/* Pre indexed */
if (insn & (1 << 23))
tcg_gen_addi_i32(tmp, tmp, offset);
else
tcg_gen_addi_i32(tmp, tmp, -offset);
tcg_gen_mov_i32(dest, tmp);
if (insn & (1 << 21))
store_reg(s, rd, tmp);
else
tcg_temp_free_i32(tmp);
} else if (insn & (1 << 21)) {
/* Post indexed */
tcg_gen_mov_i32(dest, tmp);
if (insn & (1 << 23))
tcg_gen_addi_i32(tmp, tmp, offset);
else
tcg_gen_addi_i32(tmp, tmp, -offset);
store_reg(s, rd, tmp);
} else if (!(insn & (1 << 23)))
return 1;
return 0;
}
static inline int gen_iwmmxt_shift(uint32_t insn, uint32_t mask, TCGv dest)
{
int rd = (insn >> 0) & 0xf;
TCGv tmp;
if (insn & (1 << 8)) {
if (rd < ARM_IWMMXT_wCGR0 || rd > ARM_IWMMXT_wCGR3) {
return 1;
} else {
tmp = iwmmxt_load_creg(rd);
}
} else {
tmp = tcg_temp_new_i32();
iwmmxt_load_reg(cpu_V0, rd);
tcg_gen_trunc_i64_i32(tmp, cpu_V0);
}
tcg_gen_andi_i32(tmp, tmp, mask);
tcg_gen_mov_i32(dest, tmp);
tcg_temp_free_i32(tmp);
return 0;
}
/* Disassemble an iwMMXt instruction. Returns nonzero if an error occurred
(ie. an undefined instruction). */
static int disas_iwmmxt_insn(CPUState *env, DisasContext *s, uint32_t insn)
{
int rd, wrd;
int rdhi, rdlo, rd0, rd1, i;
TCGv addr;
TCGv tmp, tmp2, tmp3;
if ((insn & 0x0e000e00) == 0x0c000000) {
if ((insn & 0x0fe00ff0) == 0x0c400000) {
wrd = insn & 0xf;
rdlo = (insn >> 12) & 0xf;
rdhi = (insn >> 16) & 0xf;
if (insn & ARM_CP_RW_BIT) { /* TMRRC */
iwmmxt_load_reg(cpu_V0, wrd);
tcg_gen_trunc_i64_i32(cpu_R[rdlo], cpu_V0);
tcg_gen_shri_i64(cpu_V0, cpu_V0, 32);
tcg_gen_trunc_i64_i32(cpu_R[rdhi], cpu_V0);
} else { /* TMCRR */
tcg_gen_concat_i32_i64(cpu_V0, cpu_R[rdlo], cpu_R[rdhi]);
iwmmxt_store_reg(cpu_V0, wrd);
gen_op_iwmmxt_set_mup();
}
return 0;
}
wrd = (insn >> 12) & 0xf;
addr = tcg_temp_new_i32();
if (gen_iwmmxt_address(s, insn, addr)) {
tcg_temp_free_i32(addr);
return 1;
}
if (insn & ARM_CP_RW_BIT) {
if ((insn >> 28) == 0xf) { /* WLDRW wCx */
tmp = tcg_temp_new_i32();
tcg_gen_qemu_ld32u(tmp, addr, IS_USER(s));
iwmmxt_store_creg(wrd, tmp);
} else {
i = 1;
if (insn & (1 << 8)) {
if (insn & (1 << 22)) { /* WLDRD */
tcg_gen_qemu_ld64(cpu_M0, addr, IS_USER(s));
i = 0;
} else { /* WLDRW wRd */
tmp = gen_ld32(addr, IS_USER(s));
}
} else {
if (insn & (1 << 22)) { /* WLDRH */
tmp = gen_ld16u(addr, IS_USER(s));
} else { /* WLDRB */
tmp = gen_ld8u(addr, IS_USER(s));
}
}
if (i) {
tcg_gen_extu_i32_i64(cpu_M0, tmp);
tcg_temp_free_i32(tmp);
}
gen_op_iwmmxt_movq_wRn_M0(wrd);
}
} else {
if ((insn >> 28) == 0xf) { /* WSTRW wCx */
tmp = iwmmxt_load_creg(wrd);
gen_st32(tmp, addr, IS_USER(s));
} else {
gen_op_iwmmxt_movq_M0_wRn(wrd);
tmp = tcg_temp_new_i32();
if (insn & (1 << 8)) {
if (insn & (1 << 22)) { /* WSTRD */
tcg_temp_free_i32(tmp);
tcg_gen_qemu_st64(cpu_M0, addr, IS_USER(s));
} else { /* WSTRW wRd */
tcg_gen_trunc_i64_i32(tmp, cpu_M0);
gen_st32(tmp, addr, IS_USER(s));
}
} else {
if (insn & (1 << 22)) { /* WSTRH */
tcg_gen_trunc_i64_i32(tmp, cpu_M0);
gen_st16(tmp, addr, IS_USER(s));
} else { /* WSTRB */
tcg_gen_trunc_i64_i32(tmp, cpu_M0);
gen_st8(tmp, addr, IS_USER(s));
}
}
}
}
tcg_temp_free_i32(addr);
return 0;
}
if ((insn & 0x0f000000) != 0x0e000000)
return 1;
switch (((insn >> 12) & 0xf00) | ((insn >> 4) & 0xff)) {
case 0x000: /* WOR */
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 0) & 0xf;
rd1 = (insn >> 16) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
gen_op_iwmmxt_orq_M0_wRn(rd1);
gen_op_iwmmxt_setpsr_nz();
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x011: /* TMCR */
if (insn & 0xf)
return 1;
rd = (insn >> 12) & 0xf;
wrd = (insn >> 16) & 0xf;
switch (wrd) {
case ARM_IWMMXT_wCID:
case ARM_IWMMXT_wCASF:
break;
case ARM_IWMMXT_wCon:
gen_op_iwmmxt_set_cup();
/* Fall through. */
case ARM_IWMMXT_wCSSF:
tmp = iwmmxt_load_creg(wrd);
tmp2 = load_reg(s, rd);
tcg_gen_andc_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
iwmmxt_store_creg(wrd, tmp);
break;
case ARM_IWMMXT_wCGR0:
case ARM_IWMMXT_wCGR1:
case ARM_IWMMXT_wCGR2:
case ARM_IWMMXT_wCGR3:
gen_op_iwmmxt_set_cup();
tmp = load_reg(s, rd);
iwmmxt_store_creg(wrd, tmp);
break;
default:
return 1;
}
break;
case 0x100: /* WXOR */
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 0) & 0xf;
rd1 = (insn >> 16) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
gen_op_iwmmxt_xorq_M0_wRn(rd1);
gen_op_iwmmxt_setpsr_nz();
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x111: /* TMRC */
if (insn & 0xf)
return 1;
rd = (insn >> 12) & 0xf;
wrd = (insn >> 16) & 0xf;
tmp = iwmmxt_load_creg(wrd);
store_reg(s, rd, tmp);
break;
case 0x300: /* WANDN */
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 0) & 0xf;
rd1 = (insn >> 16) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
tcg_gen_neg_i64(cpu_M0, cpu_M0);
gen_op_iwmmxt_andq_M0_wRn(rd1);
gen_op_iwmmxt_setpsr_nz();
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x200: /* WAND */
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 0) & 0xf;
rd1 = (insn >> 16) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
gen_op_iwmmxt_andq_M0_wRn(rd1);
gen_op_iwmmxt_setpsr_nz();
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x810: case 0xa10: /* WMADD */
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 0) & 0xf;
rd1 = (insn >> 16) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
if (insn & (1 << 21))
gen_op_iwmmxt_maddsq_M0_wRn(rd1);
else
gen_op_iwmmxt_madduq_M0_wRn(rd1);
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
break;
case 0x10e: case 0x50e: case 0x90e: case 0xd0e: /* WUNPCKIL */
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
rd1 = (insn >> 0) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
switch ((insn >> 22) & 3) {
case 0:
gen_op_iwmmxt_unpacklb_M0_wRn(rd1);
break;
case 1:
gen_op_iwmmxt_unpacklw_M0_wRn(rd1);
break;
case 2:
gen_op_iwmmxt_unpackll_M0_wRn(rd1);
break;
case 3:
return 1;
}
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x10c: case 0x50c: case 0x90c: case 0xd0c: /* WUNPCKIH */
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
rd1 = (insn >> 0) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
switch ((insn >> 22) & 3) {
case 0:
gen_op_iwmmxt_unpackhb_M0_wRn(rd1);
break;
case 1:
gen_op_iwmmxt_unpackhw_M0_wRn(rd1);
break;
case 2:
gen_op_iwmmxt_unpackhl_M0_wRn(rd1);
break;
case 3:
return 1;
}
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x012: case 0x112: case 0x412: case 0x512: /* WSAD */
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
rd1 = (insn >> 0) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
if (insn & (1 << 22))
gen_op_iwmmxt_sadw_M0_wRn(rd1);
else
gen_op_iwmmxt_sadb_M0_wRn(rd1);
if (!(insn & (1 << 20)))
gen_op_iwmmxt_addl_M0_wRn(wrd);
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
break;
case 0x010: case 0x110: case 0x210: case 0x310: /* WMUL */
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
rd1 = (insn >> 0) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
if (insn & (1 << 21)) {
if (insn & (1 << 20))
gen_op_iwmmxt_mulshw_M0_wRn(rd1);
else
gen_op_iwmmxt_mulslw_M0_wRn(rd1);
} else {
if (insn & (1 << 20))
gen_op_iwmmxt_muluhw_M0_wRn(rd1);
else
gen_op_iwmmxt_mululw_M0_wRn(rd1);
}
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
break;
case 0x410: case 0x510: case 0x610: case 0x710: /* WMAC */
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
rd1 = (insn >> 0) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
if (insn & (1 << 21))
gen_op_iwmmxt_macsw_M0_wRn(rd1);
else
gen_op_iwmmxt_macuw_M0_wRn(rd1);
if (!(insn & (1 << 20))) {
iwmmxt_load_reg(cpu_V1, wrd);
tcg_gen_add_i64(cpu_M0, cpu_M0, cpu_V1);
}
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
break;
case 0x006: case 0x406: case 0x806: case 0xc06: /* WCMPEQ */
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
rd1 = (insn >> 0) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
switch ((insn >> 22) & 3) {
case 0:
gen_op_iwmmxt_cmpeqb_M0_wRn(rd1);
break;
case 1:
gen_op_iwmmxt_cmpeqw_M0_wRn(rd1);
break;
case 2:
gen_op_iwmmxt_cmpeql_M0_wRn(rd1);
break;
case 3:
return 1;
}
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x800: case 0x900: case 0xc00: case 0xd00: /* WAVG2 */
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
rd1 = (insn >> 0) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
if (insn & (1 << 22)) {
if (insn & (1 << 20))
gen_op_iwmmxt_avgw1_M0_wRn(rd1);
else
gen_op_iwmmxt_avgw0_M0_wRn(rd1);
} else {
if (insn & (1 << 20))
gen_op_iwmmxt_avgb1_M0_wRn(rd1);
else
gen_op_iwmmxt_avgb0_M0_wRn(rd1);
}
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x802: case 0x902: case 0xa02: case 0xb02: /* WALIGNR */
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
rd1 = (insn >> 0) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
tmp = iwmmxt_load_creg(ARM_IWMMXT_wCGR0 + ((insn >> 20) & 3));
tcg_gen_andi_i32(tmp, tmp, 7);
iwmmxt_load_reg(cpu_V1, rd1);
gen_helper_iwmmxt_align(cpu_M0, cpu_M0, cpu_V1, tmp);
tcg_temp_free_i32(tmp);
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
break;
case 0x601: case 0x605: case 0x609: case 0x60d: /* TINSR */
if (((insn >> 6) & 3) == 3)
return 1;
rd = (insn >> 12) & 0xf;
wrd = (insn >> 16) & 0xf;
tmp = load_reg(s, rd);
gen_op_iwmmxt_movq_M0_wRn(wrd);
switch ((insn >> 6) & 3) {
case 0:
tmp2 = tcg_const_i32(0xff);
tmp3 = tcg_const_i32((insn & 7) << 3);
break;
case 1:
tmp2 = tcg_const_i32(0xffff);
tmp3 = tcg_const_i32((insn & 3) << 4);
break;
case 2:
tmp2 = tcg_const_i32(0xffffffff);
tmp3 = tcg_const_i32((insn & 1) << 5);
break;
default:
TCGV_UNUSED(tmp2);
TCGV_UNUSED(tmp3);
}
gen_helper_iwmmxt_insr(cpu_M0, cpu_M0, tmp, tmp2, tmp3);
tcg_temp_free(tmp3);
tcg_temp_free(tmp2);
tcg_temp_free_i32(tmp);
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
break;
case 0x107: case 0x507: case 0x907: case 0xd07: /* TEXTRM */
rd = (insn >> 12) & 0xf;
wrd = (insn >> 16) & 0xf;
if (rd == 15 || ((insn >> 22) & 3) == 3)
return 1;
gen_op_iwmmxt_movq_M0_wRn(wrd);
tmp = tcg_temp_new_i32();
switch ((insn >> 22) & 3) {
case 0:
tcg_gen_shri_i64(cpu_M0, cpu_M0, (insn & 7) << 3);
tcg_gen_trunc_i64_i32(tmp, cpu_M0);
if (insn & 8) {
tcg_gen_ext8s_i32(tmp, tmp);
} else {
tcg_gen_andi_i32(tmp, tmp, 0xff);
}
break;
case 1:
tcg_gen_shri_i64(cpu_M0, cpu_M0, (insn & 3) << 4);
tcg_gen_trunc_i64_i32(tmp, cpu_M0);
if (insn & 8) {
tcg_gen_ext16s_i32(tmp, tmp);
} else {
tcg_gen_andi_i32(tmp, tmp, 0xffff);
}
break;
case 2:
tcg_gen_shri_i64(cpu_M0, cpu_M0, (insn & 1) << 5);
tcg_gen_trunc_i64_i32(tmp, cpu_M0);
break;
}
store_reg(s, rd, tmp);
break;
case 0x117: case 0x517: case 0x917: case 0xd17: /* TEXTRC */
if ((insn & 0x000ff008) != 0x0003f000 || ((insn >> 22) & 3) == 3)
return 1;
tmp = iwmmxt_load_creg(ARM_IWMMXT_wCASF);
switch ((insn >> 22) & 3) {
case 0:
tcg_gen_shri_i32(tmp, tmp, ((insn & 7) << 2) + 0);
break;
case 1:
tcg_gen_shri_i32(tmp, tmp, ((insn & 3) << 3) + 4);
break;
case 2:
tcg_gen_shri_i32(tmp, tmp, ((insn & 1) << 4) + 12);
break;
}
tcg_gen_shli_i32(tmp, tmp, 28);
gen_set_nzcv(tmp);
tcg_temp_free_i32(tmp);
break;
case 0x401: case 0x405: case 0x409: case 0x40d: /* TBCST */
if (((insn >> 6) & 3) == 3)
return 1;
rd = (insn >> 12) & 0xf;
wrd = (insn >> 16) & 0xf;
tmp = load_reg(s, rd);
switch ((insn >> 6) & 3) {
case 0:
gen_helper_iwmmxt_bcstb(cpu_M0, tmp);
break;
case 1:
gen_helper_iwmmxt_bcstw(cpu_M0, tmp);
break;
case 2:
gen_helper_iwmmxt_bcstl(cpu_M0, tmp);
break;
}
tcg_temp_free_i32(tmp);
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
break;
case 0x113: case 0x513: case 0x913: case 0xd13: /* TANDC */
if ((insn & 0x000ff00f) != 0x0003f000 || ((insn >> 22) & 3) == 3)
return 1;
tmp = iwmmxt_load_creg(ARM_IWMMXT_wCASF);
tmp2 = tcg_temp_new_i32();
tcg_gen_mov_i32(tmp2, tmp);
switch ((insn >> 22) & 3) {
case 0:
for (i = 0; i < 7; i ++) {
tcg_gen_shli_i32(tmp2, tmp2, 4);
tcg_gen_and_i32(tmp, tmp, tmp2);
}
break;
case 1:
for (i = 0; i < 3; i ++) {
tcg_gen_shli_i32(tmp2, tmp2, 8);
tcg_gen_and_i32(tmp, tmp, tmp2);
}
break;
case 2:
tcg_gen_shli_i32(tmp2, tmp2, 16);
tcg_gen_and_i32(tmp, tmp, tmp2);
break;
}
gen_set_nzcv(tmp);
tcg_temp_free_i32(tmp2);
tcg_temp_free_i32(tmp);
break;
case 0x01c: case 0x41c: case 0x81c: case 0xc1c: /* WACC */
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
switch ((insn >> 22) & 3) {
case 0:
gen_helper_iwmmxt_addcb(cpu_M0, cpu_M0);
break;
case 1:
gen_helper_iwmmxt_addcw(cpu_M0, cpu_M0);
break;
case 2:
gen_helper_iwmmxt_addcl(cpu_M0, cpu_M0);
break;
case 3:
return 1;
}
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
break;
case 0x115: case 0x515: case 0x915: case 0xd15: /* TORC */
if ((insn & 0x000ff00f) != 0x0003f000 || ((insn >> 22) & 3) == 3)
return 1;
tmp = iwmmxt_load_creg(ARM_IWMMXT_wCASF);
tmp2 = tcg_temp_new_i32();
tcg_gen_mov_i32(tmp2, tmp);
switch ((insn >> 22) & 3) {
case 0:
for (i = 0; i < 7; i ++) {
tcg_gen_shli_i32(tmp2, tmp2, 4);
tcg_gen_or_i32(tmp, tmp, tmp2);
}
break;
case 1:
for (i = 0; i < 3; i ++) {
tcg_gen_shli_i32(tmp2, tmp2, 8);
tcg_gen_or_i32(tmp, tmp, tmp2);
}
break;
case 2:
tcg_gen_shli_i32(tmp2, tmp2, 16);
tcg_gen_or_i32(tmp, tmp, tmp2);
break;
}
gen_set_nzcv(tmp);
tcg_temp_free_i32(tmp2);
tcg_temp_free_i32(tmp);
break;
case 0x103: case 0x503: case 0x903: case 0xd03: /* TMOVMSK */
rd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
if ((insn & 0xf) != 0 || ((insn >> 22) & 3) == 3)
return 1;
gen_op_iwmmxt_movq_M0_wRn(rd0);
tmp = tcg_temp_new_i32();
switch ((insn >> 22) & 3) {
case 0:
gen_helper_iwmmxt_msbb(tmp, cpu_M0);
break;
case 1:
gen_helper_iwmmxt_msbw(tmp, cpu_M0);
break;
case 2:
gen_helper_iwmmxt_msbl(tmp, cpu_M0);
break;
}
store_reg(s, rd, tmp);
break;
case 0x106: case 0x306: case 0x506: case 0x706: /* WCMPGT */
case 0x906: case 0xb06: case 0xd06: case 0xf06:
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
rd1 = (insn >> 0) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
switch ((insn >> 22) & 3) {
case 0:
if (insn & (1 << 21))
gen_op_iwmmxt_cmpgtsb_M0_wRn(rd1);
else
gen_op_iwmmxt_cmpgtub_M0_wRn(rd1);
break;
case 1:
if (insn & (1 << 21))
gen_op_iwmmxt_cmpgtsw_M0_wRn(rd1);
else
gen_op_iwmmxt_cmpgtuw_M0_wRn(rd1);
break;
case 2:
if (insn & (1 << 21))
gen_op_iwmmxt_cmpgtsl_M0_wRn(rd1);
else
gen_op_iwmmxt_cmpgtul_M0_wRn(rd1);
break;
case 3:
return 1;
}
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x00e: case 0x20e: case 0x40e: case 0x60e: /* WUNPCKEL */
case 0x80e: case 0xa0e: case 0xc0e: case 0xe0e:
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
switch ((insn >> 22) & 3) {
case 0:
if (insn & (1 << 21))
gen_op_iwmmxt_unpacklsb_M0();
else
gen_op_iwmmxt_unpacklub_M0();
break;
case 1:
if (insn & (1 << 21))
gen_op_iwmmxt_unpacklsw_M0();
else
gen_op_iwmmxt_unpackluw_M0();
break;
case 2:
if (insn & (1 << 21))
gen_op_iwmmxt_unpacklsl_M0();
else
gen_op_iwmmxt_unpacklul_M0();
break;
case 3:
return 1;
}
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x00c: case 0x20c: case 0x40c: case 0x60c: /* WUNPCKEH */
case 0x80c: case 0xa0c: case 0xc0c: case 0xe0c:
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
switch ((insn >> 22) & 3) {
case 0:
if (insn & (1 << 21))
gen_op_iwmmxt_unpackhsb_M0();
else
gen_op_iwmmxt_unpackhub_M0();
break;
case 1:
if (insn & (1 << 21))
gen_op_iwmmxt_unpackhsw_M0();
else
gen_op_iwmmxt_unpackhuw_M0();
break;
case 2:
if (insn & (1 << 21))
gen_op_iwmmxt_unpackhsl_M0();
else
gen_op_iwmmxt_unpackhul_M0();
break;
case 3:
return 1;
}
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x204: case 0x604: case 0xa04: case 0xe04: /* WSRL */
case 0x214: case 0x614: case 0xa14: case 0xe14:
if (((insn >> 22) & 3) == 0)
return 1;
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
tmp = tcg_temp_new_i32();
if (gen_iwmmxt_shift(insn, 0xff, tmp)) {
tcg_temp_free_i32(tmp);
return 1;
}
switch ((insn >> 22) & 3) {
case 1:
gen_helper_iwmmxt_srlw(cpu_M0, cpu_env, cpu_M0, tmp);
break;
case 2:
gen_helper_iwmmxt_srll(cpu_M0, cpu_env, cpu_M0, tmp);
break;
case 3:
gen_helper_iwmmxt_srlq(cpu_M0, cpu_env, cpu_M0, tmp);
break;
}
tcg_temp_free_i32(tmp);
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x004: case 0x404: case 0x804: case 0xc04: /* WSRA */
case 0x014: case 0x414: case 0x814: case 0xc14:
if (((insn >> 22) & 3) == 0)
return 1;
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
tmp = tcg_temp_new_i32();
if (gen_iwmmxt_shift(insn, 0xff, tmp)) {
tcg_temp_free_i32(tmp);
return 1;
}
switch ((insn >> 22) & 3) {
case 1:
gen_helper_iwmmxt_sraw(cpu_M0, cpu_env, cpu_M0, tmp);
break;
case 2:
gen_helper_iwmmxt_sral(cpu_M0, cpu_env, cpu_M0, tmp);
break;
case 3:
gen_helper_iwmmxt_sraq(cpu_M0, cpu_env, cpu_M0, tmp);
break;
}
tcg_temp_free_i32(tmp);
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x104: case 0x504: case 0x904: case 0xd04: /* WSLL */
case 0x114: case 0x514: case 0x914: case 0xd14:
if (((insn >> 22) & 3) == 0)
return 1;
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
tmp = tcg_temp_new_i32();
if (gen_iwmmxt_shift(insn, 0xff, tmp)) {
tcg_temp_free_i32(tmp);
return 1;
}
switch ((insn >> 22) & 3) {
case 1:
gen_helper_iwmmxt_sllw(cpu_M0, cpu_env, cpu_M0, tmp);
break;
case 2:
gen_helper_iwmmxt_slll(cpu_M0, cpu_env, cpu_M0, tmp);
break;
case 3:
gen_helper_iwmmxt_sllq(cpu_M0, cpu_env, cpu_M0, tmp);
break;
}
tcg_temp_free_i32(tmp);
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x304: case 0x704: case 0xb04: case 0xf04: /* WROR */
case 0x314: case 0x714: case 0xb14: case 0xf14:
if (((insn >> 22) & 3) == 0)
return 1;
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
tmp = tcg_temp_new_i32();
switch ((insn >> 22) & 3) {
case 1:
if (gen_iwmmxt_shift(insn, 0xf, tmp)) {
tcg_temp_free_i32(tmp);
return 1;
}
gen_helper_iwmmxt_rorw(cpu_M0, cpu_env, cpu_M0, tmp);
break;
case 2:
if (gen_iwmmxt_shift(insn, 0x1f, tmp)) {
tcg_temp_free_i32(tmp);
return 1;
}
gen_helper_iwmmxt_rorl(cpu_M0, cpu_env, cpu_M0, tmp);
break;
case 3:
if (gen_iwmmxt_shift(insn, 0x3f, tmp)) {
tcg_temp_free_i32(tmp);
return 1;
}
gen_helper_iwmmxt_rorq(cpu_M0, cpu_env, cpu_M0, tmp);
break;
}
tcg_temp_free_i32(tmp);
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x116: case 0x316: case 0x516: case 0x716: /* WMIN */
case 0x916: case 0xb16: case 0xd16: case 0xf16:
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
rd1 = (insn >> 0) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
switch ((insn >> 22) & 3) {
case 0:
if (insn & (1 << 21))
gen_op_iwmmxt_minsb_M0_wRn(rd1);
else
gen_op_iwmmxt_minub_M0_wRn(rd1);
break;
case 1:
if (insn & (1 << 21))
gen_op_iwmmxt_minsw_M0_wRn(rd1);
else
gen_op_iwmmxt_minuw_M0_wRn(rd1);
break;
case 2:
if (insn & (1 << 21))
gen_op_iwmmxt_minsl_M0_wRn(rd1);
else
gen_op_iwmmxt_minul_M0_wRn(rd1);
break;
case 3:
return 1;
}
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
break;
case 0x016: case 0x216: case 0x416: case 0x616: /* WMAX */
case 0x816: case 0xa16: case 0xc16: case 0xe16:
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
rd1 = (insn >> 0) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
switch ((insn >> 22) & 3) {
case 0:
if (insn & (1 << 21))
gen_op_iwmmxt_maxsb_M0_wRn(rd1);
else
gen_op_iwmmxt_maxub_M0_wRn(rd1);
break;
case 1:
if (insn & (1 << 21))
gen_op_iwmmxt_maxsw_M0_wRn(rd1);
else
gen_op_iwmmxt_maxuw_M0_wRn(rd1);
break;
case 2:
if (insn & (1 << 21))
gen_op_iwmmxt_maxsl_M0_wRn(rd1);
else
gen_op_iwmmxt_maxul_M0_wRn(rd1);
break;
case 3:
return 1;
}
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
break;
case 0x002: case 0x102: case 0x202: case 0x302: /* WALIGNI */
case 0x402: case 0x502: case 0x602: case 0x702:
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
rd1 = (insn >> 0) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
tmp = tcg_const_i32((insn >> 20) & 3);
iwmmxt_load_reg(cpu_V1, rd1);
gen_helper_iwmmxt_align(cpu_M0, cpu_M0, cpu_V1, tmp);
tcg_temp_free(tmp);
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
break;
case 0x01a: case 0x11a: case 0x21a: case 0x31a: /* WSUB */
case 0x41a: case 0x51a: case 0x61a: case 0x71a:
case 0x81a: case 0x91a: case 0xa1a: case 0xb1a:
case 0xc1a: case 0xd1a: case 0xe1a: case 0xf1a:
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
rd1 = (insn >> 0) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
switch ((insn >> 20) & 0xf) {
case 0x0:
gen_op_iwmmxt_subnb_M0_wRn(rd1);
break;
case 0x1:
gen_op_iwmmxt_subub_M0_wRn(rd1);
break;
case 0x3:
gen_op_iwmmxt_subsb_M0_wRn(rd1);
break;
case 0x4:
gen_op_iwmmxt_subnw_M0_wRn(rd1);
break;
case 0x5:
gen_op_iwmmxt_subuw_M0_wRn(rd1);
break;
case 0x7:
gen_op_iwmmxt_subsw_M0_wRn(rd1);
break;
case 0x8:
gen_op_iwmmxt_subnl_M0_wRn(rd1);
break;
case 0x9:
gen_op_iwmmxt_subul_M0_wRn(rd1);
break;
case 0xb:
gen_op_iwmmxt_subsl_M0_wRn(rd1);
break;
default:
return 1;
}
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x01e: case 0x11e: case 0x21e: case 0x31e: /* WSHUFH */
case 0x41e: case 0x51e: case 0x61e: case 0x71e:
case 0x81e: case 0x91e: case 0xa1e: case 0xb1e:
case 0xc1e: case 0xd1e: case 0xe1e: case 0xf1e:
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
tmp = tcg_const_i32(((insn >> 16) & 0xf0) | (insn & 0x0f));
gen_helper_iwmmxt_shufh(cpu_M0, cpu_env, cpu_M0, tmp);
tcg_temp_free(tmp);
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x018: case 0x118: case 0x218: case 0x318: /* WADD */
case 0x418: case 0x518: case 0x618: case 0x718:
case 0x818: case 0x918: case 0xa18: case 0xb18:
case 0xc18: case 0xd18: case 0xe18: case 0xf18:
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
rd1 = (insn >> 0) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
switch ((insn >> 20) & 0xf) {
case 0x0:
gen_op_iwmmxt_addnb_M0_wRn(rd1);
break;
case 0x1:
gen_op_iwmmxt_addub_M0_wRn(rd1);
break;
case 0x3:
gen_op_iwmmxt_addsb_M0_wRn(rd1);
break;
case 0x4:
gen_op_iwmmxt_addnw_M0_wRn(rd1);
break;
case 0x5:
gen_op_iwmmxt_adduw_M0_wRn(rd1);
break;
case 0x7:
gen_op_iwmmxt_addsw_M0_wRn(rd1);
break;
case 0x8:
gen_op_iwmmxt_addnl_M0_wRn(rd1);
break;
case 0x9:
gen_op_iwmmxt_addul_M0_wRn(rd1);
break;
case 0xb:
gen_op_iwmmxt_addsl_M0_wRn(rd1);
break;
default:
return 1;
}
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x008: case 0x108: case 0x208: case 0x308: /* WPACK */
case 0x408: case 0x508: case 0x608: case 0x708:
case 0x808: case 0x908: case 0xa08: case 0xb08:
case 0xc08: case 0xd08: case 0xe08: case 0xf08:
if (!(insn & (1 << 20)) || ((insn >> 22) & 3) == 0)
return 1;
wrd = (insn >> 12) & 0xf;
rd0 = (insn >> 16) & 0xf;
rd1 = (insn >> 0) & 0xf;
gen_op_iwmmxt_movq_M0_wRn(rd0);
switch ((insn >> 22) & 3) {
case 1:
if (insn & (1 << 21))
gen_op_iwmmxt_packsw_M0_wRn(rd1);
else
gen_op_iwmmxt_packuw_M0_wRn(rd1);
break;
case 2:
if (insn & (1 << 21))
gen_op_iwmmxt_packsl_M0_wRn(rd1);
else
gen_op_iwmmxt_packul_M0_wRn(rd1);
break;
case 3:
if (insn & (1 << 21))
gen_op_iwmmxt_packsq_M0_wRn(rd1);
else
gen_op_iwmmxt_packuq_M0_wRn(rd1);
break;
}
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
gen_op_iwmmxt_set_cup();
break;
case 0x201: case 0x203: case 0x205: case 0x207:
case 0x209: case 0x20b: case 0x20d: case 0x20f:
case 0x211: case 0x213: case 0x215: case 0x217:
case 0x219: case 0x21b: case 0x21d: case 0x21f:
wrd = (insn >> 5) & 0xf;
rd0 = (insn >> 12) & 0xf;
rd1 = (insn >> 0) & 0xf;
if (rd0 == 0xf || rd1 == 0xf)
return 1;
gen_op_iwmmxt_movq_M0_wRn(wrd);
tmp = load_reg(s, rd0);
tmp2 = load_reg(s, rd1);
switch ((insn >> 16) & 0xf) {
case 0x0: /* TMIA */
gen_helper_iwmmxt_muladdsl(cpu_M0, cpu_M0, tmp, tmp2);
break;
case 0x8: /* TMIAPH */
gen_helper_iwmmxt_muladdsw(cpu_M0, cpu_M0, tmp, tmp2);
break;
case 0xc: case 0xd: case 0xe: case 0xf: /* TMIAxy */
if (insn & (1 << 16))
tcg_gen_shri_i32(tmp, tmp, 16);
if (insn & (1 << 17))
tcg_gen_shri_i32(tmp2, tmp2, 16);
gen_helper_iwmmxt_muladdswl(cpu_M0, cpu_M0, tmp, tmp2);
break;
default:
tcg_temp_free_i32(tmp2);
tcg_temp_free_i32(tmp);
return 1;
}
tcg_temp_free_i32(tmp2);
tcg_temp_free_i32(tmp);
gen_op_iwmmxt_movq_wRn_M0(wrd);
gen_op_iwmmxt_set_mup();
break;
default:
return 1;
}
return 0;
}
/* Disassemble an XScale DSP instruction. Returns nonzero if an error occurred
(ie. an undefined instruction). */
static int disas_dsp_insn(CPUState *env, DisasContext *s, uint32_t insn)
{
int acc, rd0, rd1, rdhi, rdlo;
TCGv tmp, tmp2;
if ((insn & 0x0ff00f10) == 0x0e200010) {
/* Multiply with Internal Accumulate Format */
rd0 = (insn >> 12) & 0xf;
rd1 = insn & 0xf;
acc = (insn >> 5) & 7;
if (acc != 0)
return 1;
tmp = load_reg(s, rd0);
tmp2 = load_reg(s, rd1);
switch ((insn >> 16) & 0xf) {
case 0x0: /* MIA */
gen_helper_iwmmxt_muladdsl(cpu_M0, cpu_M0, tmp, tmp2);
break;
case 0x8: /* MIAPH */
gen_helper_iwmmxt_muladdsw(cpu_M0, cpu_M0, tmp, tmp2);
break;
case 0xc: /* MIABB */
case 0xd: /* MIABT */
case 0xe: /* MIATB */
case 0xf: /* MIATT */
if (insn & (1 << 16))
tcg_gen_shri_i32(tmp, tmp, 16);
if (insn & (1 << 17))
tcg_gen_shri_i32(tmp2, tmp2, 16);
gen_helper_iwmmxt_muladdswl(cpu_M0, cpu_M0, tmp, tmp2);
break;
default:
return 1;
}
tcg_temp_free_i32(tmp2);
tcg_temp_free_i32(tmp);
gen_op_iwmmxt_movq_wRn_M0(acc);
return 0;
}
if ((insn & 0x0fe00ff8) == 0x0c400000) {
/* Internal Accumulator Access Format */
rdhi = (insn >> 16) & 0xf;
rdlo = (insn >> 12) & 0xf;
acc = insn & 7;
if (acc != 0)
return 1;
if (insn & ARM_CP_RW_BIT) { /* MRA */
iwmmxt_load_reg(cpu_V0, acc);
tcg_gen_trunc_i64_i32(cpu_R[rdlo], cpu_V0);
tcg_gen_shri_i64(cpu_V0, cpu_V0, 32);
tcg_gen_trunc_i64_i32(cpu_R[rdhi], cpu_V0);
tcg_gen_andi_i32(cpu_R[rdhi], cpu_R[rdhi], (1 << (40 - 32)) - 1);
} else { /* MAR */
tcg_gen_concat_i32_i64(cpu_V0, cpu_R[rdlo], cpu_R[rdhi]);
iwmmxt_store_reg(cpu_V0, acc);
}
return 0;
}
return 1;
}
/* Disassemble system coprocessor instruction. Return nonzero if
instruction is not defined. */
static int disas_cp_insn(CPUState *env, DisasContext *s, uint32_t insn)
{
TCGv tmp, tmp2;
uint32_t rd = (insn >> 12) & 0xf;
uint32_t cp = (insn >> 8) & 0xf;
if (IS_USER(s)) {
return 1;
}
if (insn & ARM_CP_RW_BIT) {
if (!env->cp[cp].cp_read)
return 1;
gen_set_pc_im(s->pc);
tmp = tcg_temp_new_i32();
tmp2 = tcg_const_i32(insn);
gen_helper_get_cp(tmp, cpu_env, tmp2);
tcg_temp_free(tmp2);
store_reg(s, rd, tmp);
} else {
if (!env->cp[cp].cp_write)
return 1;
gen_set_pc_im(s->pc);
tmp = load_reg(s, rd);
tmp2 = tcg_const_i32(insn);
gen_helper_set_cp(cpu_env, tmp2, tmp);
tcg_temp_free(tmp2);
tcg_temp_free_i32(tmp);
}
return 0;
}
static int cp15_user_ok(CPUState *env, uint32_t insn)
{
int cpn = (insn >> 16) & 0xf;
int cpm = insn & 0xf;
int op = ((insn >> 5) & 7) | ((insn >> 18) & 0x38);
if (arm_feature(env, ARM_FEATURE_V7) && cpn == 9) {
/* Performance monitor registers fall into three categories:
* (a) always UNDEF in usermode
* (b) UNDEF only if PMUSERENR.EN is 0
* (c) always read OK and UNDEF on write (PMUSERENR only)
*/
if ((cpm == 12 && (op < 6)) ||
(cpm == 13 && (op < 3))) {
return env->cp15.c9_pmuserenr;
} else if (cpm == 14 && op == 0 && (insn & ARM_CP_RW_BIT)) {
/* PMUSERENR, read only */
return 1;
}
return 0;
}
if (cpn == 13 && cpm == 0) {
/* TLS register. */
if (op == 2 || (op == 3 && (insn & ARM_CP_RW_BIT)))
return 1;
}
return 0;
}
static int cp15_tls_load_store(CPUState *env, DisasContext *s, uint32_t insn, uint32_t rd)
{
TCGv tmp;
int cpn = (insn >> 16) & 0xf;
int cpm = insn & 0xf;
int op = ((insn >> 5) & 7) | ((insn >> 18) & 0x38);
if (!arm_feature(env, ARM_FEATURE_V6K))
return 0;
if (!(cpn == 13 && cpm == 0))
return 0;
if (insn & ARM_CP_RW_BIT) {
switch (op) {
case 2:
tmp = load_cpu_field(cp15.c13_tls1);
break;
case 3:
tmp = load_cpu_field(cp15.c13_tls2);
break;
case 4:
tmp = load_cpu_field(cp15.c13_tls3);
break;
default:
return 0;
}
store_reg(s, rd, tmp);
} else {
tmp = load_reg(s, rd);
switch (op) {
case 2:
store_cpu_field(tmp, cp15.c13_tls1);
break;
case 3:
store_cpu_field(tmp, cp15.c13_tls2);
break;
case 4:
store_cpu_field(tmp, cp15.c13_tls3);
break;
default:
tcg_temp_free_i32(tmp);
return 0;
}
}
return 1;
}
/* Disassemble system coprocessor (cp15) instruction. Return nonzero if
instruction is not defined. */
static int disas_cp15_insn(CPUState *env, DisasContext *s, uint32_t insn)
{
uint32_t rd;
TCGv tmp, tmp2;
/* M profile cores use memory mapped registers instead of cp15. */
if (arm_feature(env, ARM_FEATURE_M))
return 1;
if ((insn & (1 << 25)) == 0) {
if (insn & (1 << 20)) {
/* mrrc */
return 1;
}
/* mcrr. Used for block cache operations, so implement as no-op. */
return 0;
}
if ((insn & (1 << 4)) == 0) {
/* cdp */
return 1;
}
/* We special case a number of cp15 instructions which were used
* for things which are real instructions in ARMv7. This allows
* them to work in linux-user mode which doesn't provide functional
* get_cp15/set_cp15 helpers, and is more efficient anyway.
*/
switch ((insn & 0x0fff0fff)) {
case 0x0e070f90:
/* 0,c7,c0,4: Standard v6 WFI (also used in some pre-v6 cores).
* In v7, this must NOP.
*/
if (IS_USER(s)) {
return 1;
}
if (!arm_feature(env, ARM_FEATURE_V7)) {
/* Wait for interrupt. */
gen_set_pc_im(s->pc);
s->is_jmp = DISAS_WFI;
}
return 0;
case 0x0e070f58:
/* 0,c7,c8,2: Not all pre-v6 cores implemented this WFI,
* so this is slightly over-broad.
*/
if (!IS_USER(s) && !arm_feature(env, ARM_FEATURE_V6)) {
/* Wait for interrupt. */
gen_set_pc_im(s->pc);
s->is_jmp = DISAS_WFI;
return 0;
}
/* Otherwise continue to handle via helper function.
* In particular, on v7 and some v6 cores this is one of
* the VA-PA registers.
*/
break;
case 0x0e070f3d:
/* 0,c7,c13,1: prefetch-by-MVA in v6, NOP in v7 */
if (arm_feature(env, ARM_FEATURE_V6)) {
return IS_USER(s) ? 1 : 0;
}
break;
case 0x0e070f95: /* 0,c7,c5,4 : ISB */
case 0x0e070f9a: /* 0,c7,c10,4: DSB */
case 0x0e070fba: /* 0,c7,c10,5: DMB */
/* Barriers in both v6 and v7 */
if (arm_feature(env, ARM_FEATURE_V6)) {
return 0;
}
break;
default:
break;
}
if (IS_USER(s) && !cp15_user_ok(env, insn)) {
return 1;
}
rd = (insn >> 12) & 0xf;
if (cp15_tls_load_store(env, s, insn, rd))
return 0;
tmp2 = tcg_const_i32(insn);
if (insn & ARM_CP_RW_BIT) {
tmp = tcg_temp_new_i32();
gen_helper_get_cp15(tmp, cpu_env, tmp2);
/* If the destination register is r15 then sets condition codes. */
if (rd != 15)
store_reg(s, rd, tmp);
else
tcg_temp_free_i32(tmp);
} else {
tmp = load_reg(s, rd);
gen_helper_set_cp15(cpu_env, tmp2, tmp);
tcg_temp_free_i32(tmp);
/* Normally we would always end the TB here, but Linux
* arch/arm/mach-pxa/sleep.S expects two instructions following
* an MMU enable to execute from cache. Imitate this behaviour. */
if (!arm_feature(env, ARM_FEATURE_XSCALE) ||
(insn & 0x0fff0fff) != 0x0e010f10)
gen_lookup_tb(s);
}
tcg_temp_free_i32(tmp2);
return 0;
}
#define VFP_REG_SHR(x, n) (((n) > 0) ? (x) >> (n) : (x) << -(n))
#define VFP_SREG(insn, bigbit, smallbit) \
((VFP_REG_SHR(insn, bigbit - 1) & 0x1e) | (((insn) >> (smallbit)) & 1))
#define VFP_DREG(reg, insn, bigbit, smallbit) do { \
if (arm_feature(env, ARM_FEATURE_VFP3)) { \
reg = (((insn) >> (bigbit)) & 0x0f) \
| (((insn) >> ((smallbit) - 4)) & 0x10); \
} else { \
if (insn & (1 << (smallbit))) \
return 1; \
reg = ((insn) >> (bigbit)) & 0x0f; \
}} while (0)
#define VFP_SREG_D(insn) VFP_SREG(insn, 12, 22)
#define VFP_DREG_D(reg, insn) VFP_DREG(reg, insn, 12, 22)
#define VFP_SREG_N(insn) VFP_SREG(insn, 16, 7)
#define VFP_DREG_N(reg, insn) VFP_DREG(reg, insn, 16, 7)
#define VFP_SREG_M(insn) VFP_SREG(insn, 0, 5)
#define VFP_DREG_M(reg, insn) VFP_DREG(reg, insn, 0, 5)
/* Move between integer and VFP cores. */
static TCGv gen_vfp_mrs(void)
{
TCGv tmp = tcg_temp_new_i32();
tcg_gen_mov_i32(tmp, cpu_F0s);
return tmp;
}
static void gen_vfp_msr(TCGv tmp)
{
tcg_gen_mov_i32(cpu_F0s, tmp);
tcg_temp_free_i32(tmp);
}
static void gen_neon_dup_u8(TCGv var, int shift)
{
TCGv tmp = tcg_temp_new_i32();
if (shift)
tcg_gen_shri_i32(var, var, shift);
tcg_gen_ext8u_i32(var, var);
tcg_gen_shli_i32(tmp, var, 8);
tcg_gen_or_i32(var, var, tmp);
tcg_gen_shli_i32(tmp, var, 16);
tcg_gen_or_i32(var, var, tmp);
tcg_temp_free_i32(tmp);
}
static void gen_neon_dup_low16(TCGv var)
{
TCGv tmp = tcg_temp_new_i32();
tcg_gen_ext16u_i32(var, var);
tcg_gen_shli_i32(tmp, var, 16);
tcg_gen_or_i32(var, var, tmp);
tcg_temp_free_i32(tmp);
}
static void gen_neon_dup_high16(TCGv var)
{
TCGv tmp = tcg_temp_new_i32();
tcg_gen_andi_i32(var, var, 0xffff0000);
tcg_gen_shri_i32(tmp, var, 16);
tcg_gen_or_i32(var, var, tmp);
tcg_temp_free_i32(tmp);
}
static TCGv gen_load_and_replicate(DisasContext *s, TCGv addr, int size)
{
/* Load a single Neon element and replicate into a 32 bit TCG reg */
TCGv tmp;
switch (size) {
case 0:
tmp = gen_ld8u(addr, IS_USER(s));
gen_neon_dup_u8(tmp, 0);
break;
case 1:
tmp = gen_ld16u(addr, IS_USER(s));
gen_neon_dup_low16(tmp);
break;
case 2:
tmp = gen_ld32(addr, IS_USER(s));
break;
default: /* Avoid compiler warnings. */
abort();
}
return tmp;
}
/* Disassemble a VFP instruction. Returns nonzero if an error occurred
(ie. an undefined instruction). */
static int disas_vfp_insn(CPUState * env, DisasContext *s, uint32_t insn)
{
uint32_t rd, rn, rm, op, i, n, offset, delta_d, delta_m, bank_mask;
int dp, veclen;
TCGv addr;
TCGv tmp;
TCGv tmp2;
if (!arm_feature(env, ARM_FEATURE_VFP))
return 1;
if (!s->vfp_enabled) {
/* VFP disabled. Only allow fmxr/fmrx to/from some control regs. */
if ((insn & 0x0fe00fff) != 0x0ee00a10)
return 1;
rn = (insn >> 16) & 0xf;
if (rn != ARM_VFP_FPSID && rn != ARM_VFP_FPEXC
&& rn != ARM_VFP_MVFR1 && rn != ARM_VFP_MVFR0)
return 1;
}
dp = ((insn & 0xf00) == 0xb00);
switch ((insn >> 24) & 0xf) {
case 0xe:
if (insn & (1 << 4)) {
/* single register transfer */
rd = (insn >> 12) & 0xf;
if (dp) {
int size;
int pass;
VFP_DREG_N(rn, insn);
if (insn & 0xf)
return 1;
if (insn & 0x00c00060
&& !arm_feature(env, ARM_FEATURE_NEON))
return 1;
pass = (insn >> 21) & 1;
if (insn & (1 << 22)) {
size = 0;
offset = ((insn >> 5) & 3) * 8;
} else if (insn & (1 << 5)) {
size = 1;
offset = (insn & (1 << 6)) ? 16 : 0;
} else {
size = 2;
offset = 0;
}
if (insn & ARM_CP_RW_BIT) {
/* vfp->arm */
tmp = neon_load_reg(rn, pass);
switch (size) {
case 0:
if (offset)
tcg_gen_shri_i32(tmp, tmp, offset);
if (insn & (1 << 23))
gen_uxtb(tmp);
else
gen_sxtb(tmp);
break;
case 1:
if (insn & (1 << 23)) {
if (offset) {
tcg_gen_shri_i32(tmp, tmp, 16);
} else {
gen_uxth(tmp);
}
} else {
if (offset) {
tcg_gen_sari_i32(tmp, tmp, 16);
} else {
gen_sxth(tmp);
}
}
break;
case 2:
break;
}
store_reg(s, rd, tmp);
} else {
/* arm->vfp */
tmp = load_reg(s, rd);
if (insn & (1 << 23)) {
/* VDUP */
if (size == 0) {
gen_neon_dup_u8(tmp, 0);
} else if (size == 1) {
gen_neon_dup_low16(tmp);
}
for (n = 0; n <= pass * 2; n++) {
tmp2 = tcg_temp_new_i32();
tcg_gen_mov_i32(tmp2, tmp);
neon_store_reg(rn, n, tmp2);
}
neon_store_reg(rn, n, tmp);
} else {
/* VMOV */
switch (size) {
case 0:
tmp2 = neon_load_reg(rn, pass);
gen_bfi(tmp, tmp2, tmp, offset, 0xff);
tcg_temp_free_i32(tmp2);
break;
case 1:
tmp2 = neon_load_reg(rn, pass);
gen_bfi(tmp, tmp2, tmp, offset, 0xffff);
tcg_temp_free_i32(tmp2);
break;
case 2:
break;
}
neon_store_reg(rn, pass, tmp);
}
}
} else { /* !dp */
if ((insn & 0x6f) != 0x00)
return 1;
rn = VFP_SREG_N(insn);
if (insn & ARM_CP_RW_BIT) {
/* vfp->arm */
if (insn & (1 << 21)) {
/* system register */
rn >>= 1;
switch (rn) {
case ARM_VFP_FPSID:
/* VFP2 allows access to FSID from userspace.
VFP3 restricts all id registers to privileged
accesses. */
if (IS_USER(s)
&& arm_feature(env, ARM_FEATURE_VFP3))
return 1;
tmp = load_cpu_field(vfp.xregs[rn]);
break;
case ARM_VFP_FPEXC:
if (IS_USER(s))
return 1;
tmp = load_cpu_field(vfp.xregs[rn]);
break;
case ARM_VFP_FPINST:
case ARM_VFP_FPINST2:
/* Not present in VFP3. */
if (IS_USER(s)
|| arm_feature(env, ARM_FEATURE_VFP3))
return 1;
tmp = load_cpu_field(vfp.xregs[rn]);
break;
case ARM_VFP_FPSCR:
if (rd == 15) {
tmp = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]);
tcg_gen_andi_i32(tmp, tmp, 0xf0000000);
} else {
tmp = tcg_temp_new_i32();
gen_helper_vfp_get_fpscr(tmp, cpu_env);
}
break;
case ARM_VFP_MVFR0:
case ARM_VFP_MVFR1:
if (IS_USER(s)
|| !arm_feature(env, ARM_FEATURE_VFP3))
return 1;
tmp = load_cpu_field(vfp.xregs[rn]);
break;
default:
return 1;
}
} else {
gen_mov_F0_vreg(0, rn);
tmp = gen_vfp_mrs();
}
if (rd == 15) {
/* Set the 4 flag bits in the CPSR. */
gen_set_nzcv(tmp);
tcg_temp_free_i32(tmp);
} else {
store_reg(s, rd, tmp);
}
} else {
/* arm->vfp */
tmp = load_reg(s, rd);
if (insn & (1 << 21)) {
rn >>= 1;
/* system register */
switch (rn) {
case ARM_VFP_FPSID:
case ARM_VFP_MVFR0:
case ARM_VFP_MVFR1:
/* Writes are ignored. */
break;
case ARM_VFP_FPSCR:
gen_helper_vfp_set_fpscr(cpu_env, tmp);
tcg_temp_free_i32(tmp);
gen_lookup_tb(s);
break;
case ARM_VFP_FPEXC:
if (IS_USER(s))
return 1;
/* TODO: VFP subarchitecture support.
* For now, keep the EN bit only */
tcg_gen_andi_i32(tmp, tmp, 1 << 30);
store_cpu_field(tmp, vfp.xregs[rn]);
gen_lookup_tb(s);
break;
case ARM_VFP_FPINST:
case ARM_VFP_FPINST2:
store_cpu_field(tmp, vfp.xregs[rn]);
break;
default:
return 1;
}
} else {
gen_vfp_msr(tmp);
gen_mov_vreg_F0(0, rn);
}
}
}
} else {
/* data processing */
/* The opcode is in bits 23, 21, 20 and 6. */
op = ((insn >> 20) & 8) | ((insn >> 19) & 6) | ((insn >> 6) & 1);
if (dp) {
if (op == 15) {
/* rn is opcode */
rn = ((insn >> 15) & 0x1e) | ((insn >> 7) & 1);
} else {
/* rn is register number */
VFP_DREG_N(rn, insn);
}
if (op == 15 && (rn == 15 || ((rn & 0x1c) == 0x18))) {
/* Integer or single precision destination. */
rd = VFP_SREG_D(insn);
} else {
VFP_DREG_D(rd, insn);
}
if (op == 15 &&
(((rn & 0x1c) == 0x10) || ((rn & 0x14) == 0x14))) {
/* VCVT from int is always from S reg regardless of dp bit.
* VCVT with immediate frac_bits has same format as SREG_M
*/
rm = VFP_SREG_M(insn);
} else {
VFP_DREG_M(rm, insn);
}
} else {
rn = VFP_SREG_N(insn);
if (op == 15 && rn == 15) {
/* Double precision destination. */
VFP_DREG_D(rd, insn);
} else {
rd = VFP_SREG_D(insn);
}
/* NB that we implicitly rely on the encoding for the frac_bits
* in VCVT of fixed to float being the same as that of an SREG_M
*/
rm = VFP_SREG_M(insn);
}
veclen = s->vec_len;
if (op == 15 && rn > 3)
veclen = 0;
/* Shut up compiler warnings. */
delta_m = 0;
delta_d = 0;
bank_mask = 0;
if (veclen > 0) {
if (dp)
bank_mask = 0xc;
else
bank_mask = 0x18;
/* Figure out what type of vector operation this is. */
if ((rd & bank_mask) == 0) {
/* scalar */
veclen = 0;
} else {
if (dp)
delta_d = (s->vec_stride >> 1) + 1;
else
delta_d = s->vec_stride + 1;
if ((rm & bank_mask) == 0) {
/* mixed scalar/vector */
delta_m = 0;
} else {
/* vector */
delta_m = delta_d;
}
}
}
/* Load the initial operands. */
if (op == 15) {
switch (rn) {
case 16:
case 17:
/* Integer source */
gen_mov_F0_vreg(0, rm);
break;
case 8:
case 9:
/* Compare */
gen_mov_F0_vreg(dp, rd);
gen_mov_F1_vreg(dp, rm);
break;
case 10:
case 11:
/* Compare with zero */
gen_mov_F0_vreg(dp, rd);
gen_vfp_F1_ld0(dp);
break;
case 20:
case 21:
case 22:
case 23:
case 28:
case 29:
case 30:
case 31:
/* Source and destination the same. */
gen_mov_F0_vreg(dp, rd);
break;
case 4:
case 5:
case 6:
case 7:
/* VCVTB, VCVTT: only present with the halfprec extension,
* UNPREDICTABLE if bit 8 is set (we choose to UNDEF)
*/
if (dp || !arm_feature(env, ARM_FEATURE_VFP_FP16)) {
return 1;
}
/* Otherwise fall through */
default:
/* One source operand. */
gen_mov_F0_vreg(dp, rm);
break;
}
} else {
/* Two source operands. */
gen_mov_F0_vreg(dp, rn);
gen_mov_F1_vreg(dp, rm);
}
for (;;) {
/* Perform the calculation. */
switch (op) {
case 0: /* VMLA: fd + (fn * fm) */
/* Note that order of inputs to the add matters for NaNs */
gen_vfp_F1_mul(dp);
gen_mov_F0_vreg(dp, rd);
gen_vfp_add(dp);
break;
case 1: /* VMLS: fd + -(fn * fm) */
gen_vfp_mul(dp);
gen_vfp_F1_neg(dp);
gen_mov_F0_vreg(dp, rd);
gen_vfp_add(dp);
break;
case 2: /* VNMLS: -fd + (fn * fm) */
/* Note that it isn't valid to replace (-A + B) with (B - A)
* or similar plausible looking simplifications
* because this will give wrong results for NaNs.
*/
gen_vfp_F1_mul(dp);
gen_mov_F0_vreg(dp, rd);
gen_vfp_neg(dp);
gen_vfp_add(dp);
break;
case 3: /* VNMLA: -fd + -(fn * fm) */
gen_vfp_mul(dp);
gen_vfp_F1_neg(dp);
gen_mov_F0_vreg(dp, rd);
gen_vfp_neg(dp);
gen_vfp_add(dp);
break;
case 4: /* mul: fn * fm */
gen_vfp_mul(dp);
break;
case 5: /* nmul: -(fn * fm) */
gen_vfp_mul(dp);
gen_vfp_neg(dp);
break;
case 6: /* add: fn + fm */
gen_vfp_add(dp);
break;
case 7: /* sub: fn - fm */
gen_vfp_sub(dp);
break;
case 8: /* div: fn / fm */
gen_vfp_div(dp);
break;
case 14: /* fconst */
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
n = (insn << 12) & 0x80000000;
i = ((insn >> 12) & 0x70) | (insn & 0xf);
if (dp) {
if (i & 0x40)
i |= 0x3f80;
else
i |= 0x4000;
n |= i << 16;
tcg_gen_movi_i64(cpu_F0d, ((uint64_t)n) << 32);
} else {
if (i & 0x40)
i |= 0x780;
else
i |= 0x800;
n |= i << 19;
tcg_gen_movi_i32(cpu_F0s, n);
}
break;
case 15: /* extension space */
switch (rn) {
case 0: /* cpy */
/* no-op */
break;
case 1: /* abs */
gen_vfp_abs(dp);
break;
case 2: /* neg */
gen_vfp_neg(dp);
break;
case 3: /* sqrt */
gen_vfp_sqrt(dp);
break;
case 4: /* vcvtb.f32.f16 */
tmp = gen_vfp_mrs();
tcg_gen_ext16u_i32(tmp, tmp);
gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp, cpu_env);
tcg_temp_free_i32(tmp);
break;
case 5: /* vcvtt.f32.f16 */
tmp = gen_vfp_mrs();
tcg_gen_shri_i32(tmp, tmp, 16);
gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp, cpu_env);
tcg_temp_free_i32(tmp);
break;
case 6: /* vcvtb.f16.f32 */
tmp = tcg_temp_new_i32();
gen_helper_vfp_fcvt_f32_to_f16(tmp, cpu_F0s, cpu_env);
gen_mov_F0_vreg(0, rd);
tmp2 = gen_vfp_mrs();
tcg_gen_andi_i32(tmp2, tmp2, 0xffff0000);
tcg_gen_or_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
gen_vfp_msr(tmp);
break;
case 7: /* vcvtt.f16.f32 */
tmp = tcg_temp_new_i32();
gen_helper_vfp_fcvt_f32_to_f16(tmp, cpu_F0s, cpu_env);
tcg_gen_shli_i32(tmp, tmp, 16);
gen_mov_F0_vreg(0, rd);
tmp2 = gen_vfp_mrs();
tcg_gen_ext16u_i32(tmp2, tmp2);
tcg_gen_or_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
gen_vfp_msr(tmp);
break;
case 8: /* cmp */
gen_vfp_cmp(dp);
break;
case 9: /* cmpe */
gen_vfp_cmpe(dp);
break;
case 10: /* cmpz */
gen_vfp_cmp(dp);
break;
case 11: /* cmpez */
gen_vfp_F1_ld0(dp);
gen_vfp_cmpe(dp);
break;
case 15: /* single<->double conversion */
if (dp)
gen_helper_vfp_fcvtsd(cpu_F0s, cpu_F0d, cpu_env);
else
gen_helper_vfp_fcvtds(cpu_F0d, cpu_F0s, cpu_env);
break;
case 16: /* fuito */
gen_vfp_uito(dp, 0);
break;
case 17: /* fsito */
gen_vfp_sito(dp, 0);
break;
case 20: /* fshto */
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_shto(dp, 16 - rm, 0);
break;
case 21: /* fslto */
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_slto(dp, 32 - rm, 0);
break;
case 22: /* fuhto */
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_uhto(dp, 16 - rm, 0);
break;
case 23: /* fulto */
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_ulto(dp, 32 - rm, 0);
break;
case 24: /* ftoui */
gen_vfp_toui(dp, 0);
break;
case 25: /* ftouiz */
gen_vfp_touiz(dp, 0);
break;
case 26: /* ftosi */
gen_vfp_tosi(dp, 0);
break;
case 27: /* ftosiz */
gen_vfp_tosiz(dp, 0);
break;
case 28: /* ftosh */
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_tosh(dp, 16 - rm, 0);
break;
case 29: /* ftosl */
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_tosl(dp, 32 - rm, 0);
break;
case 30: /* ftouh */
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_touh(dp, 16 - rm, 0);
break;
case 31: /* ftoul */
if (!arm_feature(env, ARM_FEATURE_VFP3))
return 1;
gen_vfp_toul(dp, 32 - rm, 0);
break;
default: /* undefined */
return 1;
}
break;
default: /* undefined */
return 1;
}
/* Write back the result. */
if (op == 15 && (rn >= 8 && rn <= 11))
; /* Comparison, do nothing. */
else if (op == 15 && dp && ((rn & 0x1c) == 0x18))
/* VCVT double to int: always integer result. */
gen_mov_vreg_F0(0, rd);
else if (op == 15 && rn == 15)
/* conversion */
gen_mov_vreg_F0(!dp, rd);
else
gen_mov_vreg_F0(dp, rd);
/* break out of the loop if we have finished */
if (veclen == 0)
break;
if (op == 15 && delta_m == 0) {
/* single source one-many */
while (veclen--) {
rd = ((rd + delta_d) & (bank_mask - 1))
| (rd & bank_mask);
gen_mov_vreg_F0(dp, rd);
}
break;
}
/* Setup the next operands. */
veclen--;
rd = ((rd + delta_d) & (bank_mask - 1))
| (rd & bank_mask);
if (op == 15) {
/* One source operand. */
rm = ((rm + delta_m) & (bank_mask - 1))
| (rm & bank_mask);
gen_mov_F0_vreg(dp, rm);
} else {
/* Two source operands. */
rn = ((rn + delta_d) & (bank_mask - 1))
| (rn & bank_mask);
gen_mov_F0_vreg(dp, rn);
if (delta_m) {
rm = ((rm + delta_m) & (bank_mask - 1))
| (rm & bank_mask);
gen_mov_F1_vreg(dp, rm);
}
}
}
}
break;
case 0xc:
case 0xd:
if ((insn & 0x03e00000) == 0x00400000) {
/* two-register transfer */
rn = (insn >> 16) & 0xf;
rd = (insn >> 12) & 0xf;
if (dp) {
VFP_DREG_M(rm, insn);
} else {
rm = VFP_SREG_M(insn);
}
if (insn & ARM_CP_RW_BIT) {
/* vfp->arm */
if (dp) {
gen_mov_F0_vreg(0, rm * 2);
tmp = gen_vfp_mrs();
store_reg(s, rd, tmp);
gen_mov_F0_vreg(0, rm * 2 + 1);
tmp = gen_vfp_mrs();
store_reg(s, rn, tmp);
} else {
gen_mov_F0_vreg(0, rm);
tmp = gen_vfp_mrs();
store_reg(s, rd, tmp);
gen_mov_F0_vreg(0, rm + 1);
tmp = gen_vfp_mrs();
store_reg(s, rn, tmp);
}
} else {
/* arm->vfp */
if (dp) {
tmp = load_reg(s, rd);
gen_vfp_msr(tmp);
gen_mov_vreg_F0(0, rm * 2);
tmp = load_reg(s, rn);
gen_vfp_msr(tmp);
gen_mov_vreg_F0(0, rm * 2 + 1);
} else {
tmp = load_reg(s, rd);
gen_vfp_msr(tmp);
gen_mov_vreg_F0(0, rm);
tmp = load_reg(s, rn);
gen_vfp_msr(tmp);
gen_mov_vreg_F0(0, rm + 1);
}
}
} else {
/* Load/store */
rn = (insn >> 16) & 0xf;
if (dp)
VFP_DREG_D(rd, insn);
else
rd = VFP_SREG_D(insn);
if ((insn & 0x01200000) == 0x01000000) {
/* Single load/store */
offset = (insn & 0xff) << 2;
if ((insn & (1 << 23)) == 0)
offset = -offset;
if (s->thumb && rn == 15) {
/* This is actually UNPREDICTABLE */
addr = tcg_temp_new_i32();
tcg_gen_movi_i32(addr, s->pc & ~2);
} else {
addr = load_reg(s, rn);
}
tcg_gen_addi_i32(addr, addr, offset);
if (insn & (1 << 20)) {
gen_vfp_ld(s, dp, addr);
gen_mov_vreg_F0(dp, rd);
} else {
gen_mov_F0_vreg(dp, rd);
gen_vfp_st(s, dp, addr);
}
tcg_temp_free_i32(addr);
} else {
/* load/store multiple */
int w = insn & (1 << 21);
if (dp)
n = (insn >> 1) & 0x7f;
else
n = insn & 0xff;
if (w && !(((insn >> 23) ^ (insn >> 24)) & 1)) {
/* P == U , W == 1 => UNDEF */
return 1;
}
if (n == 0 || (rd + n) > 32 || (dp && n > 16)) {
/* UNPREDICTABLE cases for bad immediates: we choose to
* UNDEF to avoid generating huge numbers of TCG ops
*/
return 1;
}
if (rn == 15 && w) {
/* writeback to PC is UNPREDICTABLE, we choose to UNDEF */
return 1;
}
if (s->thumb && rn == 15) {
/* This is actually UNPREDICTABLE */
addr = tcg_temp_new_i32();
tcg_gen_movi_i32(addr, s->pc & ~2);
} else {
addr = load_reg(s, rn);
}
if (insn & (1 << 24)) /* pre-decrement */
tcg_gen_addi_i32(addr, addr, -((insn & 0xff) << 2));
if (dp)
offset = 8;
else
offset = 4;
for (i = 0; i < n; i++) {
if (insn & ARM_CP_RW_BIT) {
/* load */
gen_vfp_ld(s, dp, addr);
gen_mov_vreg_F0(dp, rd + i);
} else {
/* store */
gen_mov_F0_vreg(dp, rd + i);
gen_vfp_st(s, dp, addr);
}
tcg_gen_addi_i32(addr, addr, offset);
}
if (w) {
/* writeback */
if (insn & (1 << 24))
offset = -offset * n;
else if (dp && (insn & 1))
offset = 4;
else
offset = 0;
if (offset != 0)
tcg_gen_addi_i32(addr, addr, offset);
store_reg(s, rn, addr);
} else {
tcg_temp_free_i32(addr);
}
}
}
break;
default:
/* Should never happen. */
return 1;
}
return 0;
}
static inline void gen_goto_tb(DisasContext *s, int n, uint32_t dest)
{
TranslationBlock *tb;
tb = s->tb;
if ((tb->pc & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK)) {
tcg_gen_goto_tb(n);
gen_set_pc_im(dest);
tcg_gen_exit_tb((tcg_target_long)tb + n);
} else {
gen_set_pc_im(dest);
tcg_gen_exit_tb(0);
}
}
static inline void gen_jmp (DisasContext *s, uint32_t dest)
{
if (unlikely(s->singlestep_enabled)) {
/* An indirect jump so that we still trigger the debug exception. */
if (s->thumb)
dest |= 1;
gen_bx_im(s, dest);
} else {
gen_goto_tb(s, 0, dest);
s->is_jmp = DISAS_TB_JUMP;
}
}
static inline void gen_mulxy(TCGv t0, TCGv t1, int x, int y)
{
if (x)
tcg_gen_sari_i32(t0, t0, 16);
else
gen_sxth(t0);
if (y)
tcg_gen_sari_i32(t1, t1, 16);
else
gen_sxth(t1);
tcg_gen_mul_i32(t0, t0, t1);
}
/* Return the mask of PSR bits set by a MSR instruction. */
static uint32_t msr_mask(CPUState *env, DisasContext *s, int flags, int spsr) {
uint32_t mask;
mask = 0;
if (flags & (1 << 0))
mask |= 0xff;
if (flags & (1 << 1))
mask |= 0xff00;
if (flags & (1 << 2))
mask |= 0xff0000;
if (flags & (1 << 3))
mask |= 0xff000000;
/* Mask out undefined bits. */
mask &= ~CPSR_RESERVED;
if (!arm_feature(env, ARM_FEATURE_V4T))
mask &= ~CPSR_T;
if (!arm_feature(env, ARM_FEATURE_V5))
mask &= ~CPSR_Q; /* V5TE in reality*/
if (!arm_feature(env, ARM_FEATURE_V6))
mask &= ~(CPSR_E | CPSR_GE);
if (!arm_feature(env, ARM_FEATURE_THUMB2))
mask &= ~CPSR_IT;
/* Mask out execution state bits. */
if (!spsr)
mask &= ~CPSR_EXEC;
/* Mask out privileged bits. */
if (IS_USER(s))
mask &= CPSR_USER;
return mask;
}
/* Returns nonzero if access to the PSR is not permitted. Marks t0 as dead. */
static int gen_set_psr(DisasContext *s, uint32_t mask, int spsr, TCGv t0)
{
TCGv tmp;
if (spsr) {
/* ??? This is also undefined in system mode. */
if (IS_USER(s))
return 1;
tmp = load_cpu_field(spsr);
tcg_gen_andi_i32(tmp, tmp, ~mask);
tcg_gen_andi_i32(t0, t0, mask);
tcg_gen_or_i32(tmp, tmp, t0);
store_cpu_field(tmp, spsr);
} else {
gen_set_cpsr(t0, mask);
}
tcg_temp_free_i32(t0);
gen_lookup_tb(s);
return 0;
}
/* Returns nonzero if access to the PSR is not permitted. */
static int gen_set_psr_im(DisasContext *s, uint32_t mask, int spsr, uint32_t val)
{
TCGv tmp;
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, val);
return gen_set_psr(s, mask, spsr, tmp);
}
/* Generate an old-style exception return. Marks pc as dead. */
static void gen_exception_return(DisasContext *s, TCGv pc)
{
TCGv tmp;
store_reg(s, 15, pc);
tmp = load_cpu_field(spsr);
gen_set_cpsr(tmp, 0xffffffff);
tcg_temp_free_i32(tmp);
s->is_jmp = DISAS_UPDATE;
}
/* Generate a v6 exception return. Marks both values as dead. */
static void gen_rfe(DisasContext *s, TCGv pc, TCGv cpsr)
{
gen_set_cpsr(cpsr, 0xffffffff);
tcg_temp_free_i32(cpsr);
store_reg(s, 15, pc);
s->is_jmp = DISAS_UPDATE;
}
static inline void
gen_set_condexec (DisasContext *s)
{
if (s->condexec_mask) {
uint32_t val = (s->condexec_cond << 4) | (s->condexec_mask >> 1);
TCGv tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, val);
store_cpu_field(tmp, condexec_bits);
}
}
static void gen_exception_insn(DisasContext *s, int offset, int excp)
{
gen_set_condexec(s);
gen_set_pc_im(s->pc - offset);
gen_exception(excp);
s->is_jmp = DISAS_JUMP;
}
static void gen_nop_hint(DisasContext *s, int val)
{
switch (val) {
case 3: /* wfi */
gen_set_pc_im(s->pc);
s->is_jmp = DISAS_WFI;
break;
case 2: /* wfe */
case 4: /* sev */
/* TODO: Implement SEV and WFE. May help SMP performance. */
default: /* nop */
break;
}
}
#define CPU_V001 cpu_V0, cpu_V0, cpu_V1
static inline void gen_neon_add(int size, TCGv t0, TCGv t1)
{
switch (size) {
case 0: gen_helper_neon_add_u8(t0, t0, t1); break;
case 1: gen_helper_neon_add_u16(t0, t0, t1); break;
case 2: tcg_gen_add_i32(t0, t0, t1); break;
default: abort();
}
}
static inline void gen_neon_rsb(int size, TCGv t0, TCGv t1)
{
switch (size) {
case 0: gen_helper_neon_sub_u8(t0, t1, t0); break;
case 1: gen_helper_neon_sub_u16(t0, t1, t0); break;
case 2: tcg_gen_sub_i32(t0, t1, t0); break;
default: return;
}
}
/* 32-bit pairwise ops end up the same as the elementwise versions. */
#define gen_helper_neon_pmax_s32 gen_helper_neon_max_s32
#define gen_helper_neon_pmax_u32 gen_helper_neon_max_u32
#define gen_helper_neon_pmin_s32 gen_helper_neon_min_s32
#define gen_helper_neon_pmin_u32 gen_helper_neon_min_u32
#define GEN_NEON_INTEGER_OP_ENV(name) do { \
switch ((size << 1) | u) { \
case 0: \
gen_helper_neon_##name##_s8(tmp, cpu_env, tmp, tmp2); \
break; \
case 1: \
gen_helper_neon_##name##_u8(tmp, cpu_env, tmp, tmp2); \
break; \
case 2: \
gen_helper_neon_##name##_s16(tmp, cpu_env, tmp, tmp2); \
break; \
case 3: \
gen_helper_neon_##name##_u16(tmp, cpu_env, tmp, tmp2); \
break; \
case 4: \
gen_helper_neon_##name##_s32(tmp, cpu_env, tmp, tmp2); \
break; \
case 5: \
gen_helper_neon_##name##_u32(tmp, cpu_env, tmp, tmp2); \
break; \
default: return 1; \
}} while (0)
#define GEN_NEON_INTEGER_OP(name) do { \
switch ((size << 1) | u) { \
case 0: \
gen_helper_neon_##name##_s8(tmp, tmp, tmp2); \
break; \
case 1: \
gen_helper_neon_##name##_u8(tmp, tmp, tmp2); \
break; \
case 2: \
gen_helper_neon_##name##_s16(tmp, tmp, tmp2); \
break; \
case 3: \
gen_helper_neon_##name##_u16(tmp, tmp, tmp2); \
break; \
case 4: \
gen_helper_neon_##name##_s32(tmp, tmp, tmp2); \
break; \
case 5: \
gen_helper_neon_##name##_u32(tmp, tmp, tmp2); \
break; \
default: return 1; \
}} while (0)
static TCGv neon_load_scratch(int scratch)
{
TCGv tmp = tcg_temp_new_i32();
tcg_gen_ld_i32(tmp, cpu_env, offsetof(CPUARMState, vfp.scratch[scratch]));
return tmp;
}
static void neon_store_scratch(int scratch, TCGv var)
{
tcg_gen_st_i32(var, cpu_env, offsetof(CPUARMState, vfp.scratch[scratch]));
tcg_temp_free_i32(var);
}
static inline TCGv neon_get_scalar(int size, int reg)
{
TCGv tmp;
if (size == 1) {
tmp = neon_load_reg(reg & 7, reg >> 4);
if (reg & 8) {
gen_neon_dup_high16(tmp);
} else {
gen_neon_dup_low16(tmp);
}
} else {
tmp = neon_load_reg(reg & 15, reg >> 4);
}
return tmp;
}
static int gen_neon_unzip(int rd, int rm, int size, int q)
{
TCGv tmp, tmp2;
if (!q && size == 2) {
return 1;
}
tmp = tcg_const_i32(rd);
tmp2 = tcg_const_i32(rm);
if (q) {
switch (size) {
case 0:
gen_helper_neon_qunzip8(cpu_env, tmp, tmp2);
break;
case 1:
gen_helper_neon_qunzip16(cpu_env, tmp, tmp2);
break;
case 2:
gen_helper_neon_qunzip32(cpu_env, tmp, tmp2);
break;
default:
abort();
}
} else {
switch (size) {
case 0:
gen_helper_neon_unzip8(cpu_env, tmp, tmp2);
break;
case 1:
gen_helper_neon_unzip16(cpu_env, tmp, tmp2);
break;
default:
abort();
}
}
tcg_temp_free_i32(tmp);
tcg_temp_free_i32(tmp2);
return 0;
}
static int gen_neon_zip(int rd, int rm, int size, int q)
{
TCGv tmp, tmp2;
if (!q && size == 2) {
return 1;
}
tmp = tcg_const_i32(rd);
tmp2 = tcg_const_i32(rm);
if (q) {
switch (size) {
case 0:
gen_helper_neon_qzip8(cpu_env, tmp, tmp2);
break;
case 1:
gen_helper_neon_qzip16(cpu_env, tmp, tmp2);
break;
case 2:
gen_helper_neon_qzip32(cpu_env, tmp, tmp2);
break;
default:
abort();
}
} else {
switch (size) {
case 0:
gen_helper_neon_zip8(cpu_env, tmp, tmp2);
break;
case 1:
gen_helper_neon_zip16(cpu_env, tmp, tmp2);
break;
default:
abort();
}
}
tcg_temp_free_i32(tmp);
tcg_temp_free_i32(tmp2);
return 0;
}
static void gen_neon_trn_u8(TCGv t0, TCGv t1)
{
TCGv rd, tmp;
rd = tcg_temp_new_i32();
tmp = tcg_temp_new_i32();
tcg_gen_shli_i32(rd, t0, 8);
tcg_gen_andi_i32(rd, rd, 0xff00ff00);
tcg_gen_andi_i32(tmp, t1, 0x00ff00ff);
tcg_gen_or_i32(rd, rd, tmp);
tcg_gen_shri_i32(t1, t1, 8);
tcg_gen_andi_i32(t1, t1, 0x00ff00ff);
tcg_gen_andi_i32(tmp, t0, 0xff00ff00);
tcg_gen_or_i32(t1, t1, tmp);
tcg_gen_mov_i32(t0, rd);
tcg_temp_free_i32(tmp);
tcg_temp_free_i32(rd);
}
static void gen_neon_trn_u16(TCGv t0, TCGv t1)
{
TCGv rd, tmp;
rd = tcg_temp_new_i32();
tmp = tcg_temp_new_i32();
tcg_gen_shli_i32(rd, t0, 16);
tcg_gen_andi_i32(tmp, t1, 0xffff);
tcg_gen_or_i32(rd, rd, tmp);
tcg_gen_shri_i32(t1, t1, 16);
tcg_gen_andi_i32(tmp, t0, 0xffff0000);
tcg_gen_or_i32(t1, t1, tmp);
tcg_gen_mov_i32(t0, rd);
tcg_temp_free_i32(tmp);
tcg_temp_free_i32(rd);
}
static struct {
int nregs;
int interleave;
int spacing;
} neon_ls_element_type[11] = {
{4, 4, 1},
{4, 4, 2},
{4, 1, 1},
{4, 2, 1},
{3, 3, 1},
{3, 3, 2},
{3, 1, 1},
{1, 1, 1},
{2, 2, 1},
{2, 2, 2},
{2, 1, 1}
};
/* Translate a NEON load/store element instruction. Return nonzero if the
instruction is invalid. */
static int disas_neon_ls_insn(CPUState * env, DisasContext *s, uint32_t insn)
{
int rd, rn, rm;
int op;
int nregs;
int interleave;
int spacing;
int stride;
int size;
int reg;
int pass;
int load;
int shift;
int n;
TCGv addr;
TCGv tmp;
TCGv tmp2;
TCGv_i64 tmp64;
if (!s->vfp_enabled)
return 1;
VFP_DREG_D(rd, insn);
rn = (insn >> 16) & 0xf;
rm = insn & 0xf;
load = (insn & (1 << 21)) != 0;
if ((insn & (1 << 23)) == 0) {
/* Load store all elements. */
op = (insn >> 8) & 0xf;
size = (insn >> 6) & 3;
if (op > 10)
return 1;
/* Catch UNDEF cases for bad values of align field */
switch (op & 0xc) {
case 4:
if (((insn >> 5) & 1) == 1) {
return 1;
}
break;
case 8:
if (((insn >> 4) & 3) == 3) {
return 1;
}
break;
default:
break;
}
nregs = neon_ls_element_type[op].nregs;
interleave = neon_ls_element_type[op].interleave;
spacing = neon_ls_element_type[op].spacing;
if (size == 3 && (interleave | spacing) != 1)
return 1;
addr = tcg_temp_new_i32();
load_reg_var(s, addr, rn);
stride = (1 << size) * interleave;
for (reg = 0; reg < nregs; reg++) {
if (interleave > 2 || (interleave == 2 && nregs == 2)) {
load_reg_var(s, addr, rn);
tcg_gen_addi_i32(addr, addr, (1 << size) * reg);
} else if (interleave == 2 && nregs == 4 && reg == 2) {
load_reg_var(s, addr, rn);
tcg_gen_addi_i32(addr, addr, 1 << size);
}
if (size == 3) {
if (load) {
tmp64 = gen_ld64(addr, IS_USER(s));
neon_store_reg64(tmp64, rd);
tcg_temp_free_i64(tmp64);
} else {
tmp64 = tcg_temp_new_i64();
neon_load_reg64(tmp64, rd);
gen_st64(tmp64, addr, IS_USER(s));
}
tcg_gen_addi_i32(addr, addr, stride);
} else {
for (pass = 0; pass < 2; pass++) {
if (size == 2) {
if (load) {
tmp = gen_ld32(addr, IS_USER(s));
neon_store_reg(rd, pass, tmp);
} else {
tmp = neon_load_reg(rd, pass);
gen_st32(tmp, addr, IS_USER(s));
}
tcg_gen_addi_i32(addr, addr, stride);
} else if (size == 1) {
if (load) {
tmp = gen_ld16u(addr, IS_USER(s));
tcg_gen_addi_i32(addr, addr, stride);
tmp2 = gen_ld16u(addr, IS_USER(s));
tcg_gen_addi_i32(addr, addr, stride);
tcg_gen_shli_i32(tmp2, tmp2, 16);
tcg_gen_or_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
neon_store_reg(rd, pass, tmp);
} else {
tmp = neon_load_reg(rd, pass);
tmp2 = tcg_temp_new_i32();
tcg_gen_shri_i32(tmp2, tmp, 16);
gen_st16(tmp, addr, IS_USER(s));
tcg_gen_addi_i32(addr, addr, stride);
gen_st16(tmp2, addr, IS_USER(s));
tcg_gen_addi_i32(addr, addr, stride);
}
} else /* size == 0 */ {
if (load) {
TCGV_UNUSED(tmp2);
for (n = 0; n < 4; n++) {
tmp = gen_ld8u(addr, IS_USER(s));
tcg_gen_addi_i32(addr, addr, stride);
if (n == 0) {
tmp2 = tmp;
} else {
tcg_gen_shli_i32(tmp, tmp, n * 8);
tcg_gen_or_i32(tmp2, tmp2, tmp);
tcg_temp_free_i32(tmp);
}
}
neon_store_reg(rd, pass, tmp2);
} else {
tmp2 = neon_load_reg(rd, pass);
for (n = 0; n < 4; n++) {
tmp = tcg_temp_new_i32();
if (n == 0) {
tcg_gen_mov_i32(tmp, tmp2);
} else {
tcg_gen_shri_i32(tmp, tmp2, n * 8);
}
gen_st8(tmp, addr, IS_USER(s));
tcg_gen_addi_i32(addr, addr, stride);
}
tcg_temp_free_i32(tmp2);
}
}
}
}
rd += spacing;
}
tcg_temp_free_i32(addr);
stride = nregs * 8;
} else {
size = (insn >> 10) & 3;
if (size == 3) {
/* Load single element to all lanes. */
int a = (insn >> 4) & 1;
if (!load) {
return 1;
}
size = (insn >> 6) & 3;
nregs = ((insn >> 8) & 3) + 1;
if (size == 3) {
if (nregs != 4 || a == 0) {
return 1;
}
/* For VLD4 size==3 a == 1 means 32 bits at 16 byte alignment */
size = 2;
}
if (nregs == 1 && a == 1 && size == 0) {
return 1;
}
if (nregs == 3 && a == 1) {
return 1;
}
addr = tcg_temp_new_i32();
load_reg_var(s, addr, rn);
if (nregs == 1) {
/* VLD1 to all lanes: bit 5 indicates how many Dregs to write */
tmp = gen_load_and_replicate(s, addr, size);
tcg_gen_st_i32(tmp, cpu_env, neon_reg_offset(rd, 0));
tcg_gen_st_i32(tmp, cpu_env, neon_reg_offset(rd, 1));
if (insn & (1 << 5)) {
tcg_gen_st_i32(tmp, cpu_env, neon_reg_offset(rd + 1, 0));
tcg_gen_st_i32(tmp, cpu_env, neon_reg_offset(rd + 1, 1));
}
tcg_temp_free_i32(tmp);
} else {
/* VLD2/3/4 to all lanes: bit 5 indicates register stride */
stride = (insn & (1 << 5)) ? 2 : 1;
for (reg = 0; reg < nregs; reg++) {
tmp = gen_load_and_replicate(s, addr, size);
tcg_gen_st_i32(tmp, cpu_env, neon_reg_offset(rd, 0));
tcg_gen_st_i32(tmp, cpu_env, neon_reg_offset(rd, 1));
tcg_temp_free_i32(tmp);
tcg_gen_addi_i32(addr, addr, 1 << size);
rd += stride;
}
}
tcg_temp_free_i32(addr);
stride = (1 << size) * nregs;
} else {
/* Single element. */
int idx = (insn >> 4) & 0xf;
pass = (insn >> 7) & 1;
switch (size) {
case 0:
shift = ((insn >> 5) & 3) * 8;
stride = 1;
break;
case 1:
shift = ((insn >> 6) & 1) * 16;
stride = (insn & (1 << 5)) ? 2 : 1;
break;
case 2:
shift = 0;
stride = (insn & (1 << 6)) ? 2 : 1;
break;
default:
abort();
}
nregs = ((insn >> 8) & 3) + 1;
/* Catch the UNDEF cases. This is unavoidably a bit messy. */
switch (nregs) {
case 1:
if (((idx & (1 << size)) != 0) ||
(size == 2 && ((idx & 3) == 1 || (idx & 3) == 2))) {
return 1;
}
break;
case 3:
if ((idx & 1) != 0) {
return 1;
}
/* fall through */
case 2:
if (size == 2 && (idx & 2) != 0) {
return 1;
}
break;
case 4:
if ((size == 2) && ((idx & 3) == 3)) {
return 1;
}
break;
default:
abort();
}
if ((rd + stride * (nregs - 1)) > 31) {
/* Attempts to write off the end of the register file
* are UNPREDICTABLE; we choose to UNDEF because otherwise
* the neon_load_reg() would write off the end of the array.
*/
return 1;
}
addr = tcg_temp_new_i32();
load_reg_var(s, addr, rn);
for (reg = 0; reg < nregs; reg++) {
if (load) {
switch (size) {
case 0:
tmp = gen_ld8u(addr, IS_USER(s));
break;
case 1:
tmp = gen_ld16u(addr, IS_USER(s));
break;
case 2:
tmp = gen_ld32(addr, IS_USER(s));
break;
default: /* Avoid compiler warnings. */
abort();
}
if (size != 2) {
tmp2 = neon_load_reg(rd, pass);
gen_bfi(tmp, tmp2, tmp, shift, size ? 0xffff : 0xff);
tcg_temp_free_i32(tmp2);
}
neon_store_reg(rd, pass, tmp);
} else { /* Store */
tmp = neon_load_reg(rd, pass);
if (shift)
tcg_gen_shri_i32(tmp, tmp, shift);
switch (size) {
case 0:
gen_st8(tmp, addr, IS_USER(s));
break;
case 1:
gen_st16(tmp, addr, IS_USER(s));
break;
case 2:
gen_st32(tmp, addr, IS_USER(s));
break;
}
}
rd += stride;
tcg_gen_addi_i32(addr, addr, 1 << size);
}
tcg_temp_free_i32(addr);
stride = nregs * (1 << size);
}
}
if (rm != 15) {
TCGv base;
base = load_reg(s, rn);
if (rm == 13) {
tcg_gen_addi_i32(base, base, stride);
} else {
TCGv index;
index = load_reg(s, rm);
tcg_gen_add_i32(base, base, index);
tcg_temp_free_i32(index);
}
store_reg(s, rn, base);
}
return 0;
}
/* Bitwise select. dest = c ? t : f. Clobbers T and F. */
static void gen_neon_bsl(TCGv dest, TCGv t, TCGv f, TCGv c)
{
tcg_gen_and_i32(t, t, c);
tcg_gen_andc_i32(f, f, c);
tcg_gen_or_i32(dest, t, f);
}
static inline void gen_neon_narrow(int size, TCGv dest, TCGv_i64 src)
{
switch (size) {
case 0: gen_helper_neon_narrow_u8(dest, src); break;
case 1: gen_helper_neon_narrow_u16(dest, src); break;
case 2: tcg_gen_trunc_i64_i32(dest, src); break;
default: abort();
}
}
static inline void gen_neon_narrow_sats(int size, TCGv dest, TCGv_i64 src)
{
switch (size) {
case 0: gen_helper_neon_narrow_sat_s8(dest, cpu_env, src); break;
case 1: gen_helper_neon_narrow_sat_s16(dest, cpu_env, src); break;
case 2: gen_helper_neon_narrow_sat_s32(dest, cpu_env, src); break;
default: abort();
}
}
static inline void gen_neon_narrow_satu(int size, TCGv dest, TCGv_i64 src)
{
switch (size) {
case 0: gen_helper_neon_narrow_sat_u8(dest, cpu_env, src); break;
case 1: gen_helper_neon_narrow_sat_u16(dest, cpu_env, src); break;
case 2: gen_helper_neon_narrow_sat_u32(dest, cpu_env, src); break;
default: abort();
}
}
static inline void gen_neon_unarrow_sats(int size, TCGv dest, TCGv_i64 src)
{
switch (size) {
case 0: gen_helper_neon_unarrow_sat8(dest, cpu_env, src); break;
case 1: gen_helper_neon_unarrow_sat16(dest, cpu_env, src); break;
case 2: gen_helper_neon_unarrow_sat32(dest, cpu_env, src); break;
default: abort();
}
}
static inline void gen_neon_shift_narrow(int size, TCGv var, TCGv shift,
int q, int u)
{
if (q) {
if (u) {
switch (size) {
case 1: gen_helper_neon_rshl_u16(var, var, shift); break;
case 2: gen_helper_neon_rshl_u32(var, var, shift); break;
default: abort();
}
} else {
switch (size) {
case 1: gen_helper_neon_rshl_s16(var, var, shift); break;
case 2: gen_helper_neon_rshl_s32(var, var, shift); break;
default: abort();
}
}
} else {
if (u) {
switch (size) {
case 1: gen_helper_neon_shl_u16(var, var, shift); break;
case 2: gen_helper_neon_shl_u32(var, var, shift); break;
default: abort();
}
} else {
switch (size) {
case 1: gen_helper_neon_shl_s16(var, var, shift); break;
case 2: gen_helper_neon_shl_s32(var, var, shift); break;
default: abort();
}
}
}
}
static inline void gen_neon_widen(TCGv_i64 dest, TCGv src, int size, int u)
{
if (u) {
switch (size) {
case 0: gen_helper_neon_widen_u8(dest, src); break;
case 1: gen_helper_neon_widen_u16(dest, src); break;
case 2: tcg_gen_extu_i32_i64(dest, src); break;
default: abort();
}
} else {
switch (size) {
case 0: gen_helper_neon_widen_s8(dest, src); break;
case 1: gen_helper_neon_widen_s16(dest, src); break;
case 2: tcg_gen_ext_i32_i64(dest, src); break;
default: abort();
}
}
tcg_temp_free_i32(src);
}
static inline void gen_neon_addl(int size)
{
switch (size) {
case 0: gen_helper_neon_addl_u16(CPU_V001); break;
case 1: gen_helper_neon_addl_u32(CPU_V001); break;
case 2: tcg_gen_add_i64(CPU_V001); break;
default: abort();
}
}
static inline void gen_neon_subl(int size)
{
switch (size) {
case 0: gen_helper_neon_subl_u16(CPU_V001); break;
case 1: gen_helper_neon_subl_u32(CPU_V001); break;
case 2: tcg_gen_sub_i64(CPU_V001); break;
default: abort();
}
}
static inline void gen_neon_negl(TCGv_i64 var, int size)
{
switch (size) {
case 0: gen_helper_neon_negl_u16(var, var); break;
case 1: gen_helper_neon_negl_u32(var, var); break;
case 2: gen_helper_neon_negl_u64(var, var); break;
default: abort();
}
}
static inline void gen_neon_addl_saturate(TCGv_i64 op0, TCGv_i64 op1, int size)
{
switch (size) {
case 1: gen_helper_neon_addl_saturate_s32(op0, cpu_env, op0, op1); break;
case 2: gen_helper_neon_addl_saturate_s64(op0, cpu_env, op0, op1); break;
default: abort();
}
}
static inline void gen_neon_mull(TCGv_i64 dest, TCGv a, TCGv b, int size, int u)
{
TCGv_i64 tmp;
switch ((size << 1) | u) {
case 0: gen_helper_neon_mull_s8(dest, a, b); break;
case 1: gen_helper_neon_mull_u8(dest, a, b); break;
case 2: gen_helper_neon_mull_s16(dest, a, b); break;
case 3: gen_helper_neon_mull_u16(dest, a, b); break;
case 4:
tmp = gen_muls_i64_i32(a, b);
tcg_gen_mov_i64(dest, tmp);
tcg_temp_free_i64(tmp);
break;
case 5:
tmp = gen_mulu_i64_i32(a, b);
tcg_gen_mov_i64(dest, tmp);
tcg_temp_free_i64(tmp);
break;
default: abort();
}
/* gen_helper_neon_mull_[su]{8|16} do not free their parameters.
Don't forget to clean them now. */
if (size < 2) {
tcg_temp_free_i32(a);
tcg_temp_free_i32(b);
}
}
static void gen_neon_narrow_op(int op, int u, int size, TCGv dest, TCGv_i64 src)
{
if (op) {
if (u) {
gen_neon_unarrow_sats(size, dest, src);
} else {
gen_neon_narrow(size, dest, src);
}
} else {
if (u) {
gen_neon_narrow_satu(size, dest, src);
} else {
gen_neon_narrow_sats(size, dest, src);
}
}
}
/* Symbolic constants for op fields for Neon 3-register same-length.
* The values correspond to bits [11:8,4]; see the ARM ARM DDI0406B
* table A7-9.
*/
#define NEON_3R_VHADD 0
#define NEON_3R_VQADD 1
#define NEON_3R_VRHADD 2
#define NEON_3R_LOGIC 3 /* VAND,VBIC,VORR,VMOV,VORN,VEOR,VBIF,VBIT,VBSL */
#define NEON_3R_VHSUB 4
#define NEON_3R_VQSUB 5
#define NEON_3R_VCGT 6
#define NEON_3R_VCGE 7
#define NEON_3R_VSHL 8
#define NEON_3R_VQSHL 9
#define NEON_3R_VRSHL 10
#define NEON_3R_VQRSHL 11
#define NEON_3R_VMAX 12
#define NEON_3R_VMIN 13
#define NEON_3R_VABD 14
#define NEON_3R_VABA 15
#define NEON_3R_VADD_VSUB 16
#define NEON_3R_VTST_VCEQ 17
#define NEON_3R_VML 18 /* VMLA, VMLAL, VMLS, VMLSL */
#define NEON_3R_VMUL 19
#define NEON_3R_VPMAX 20
#define NEON_3R_VPMIN 21
#define NEON_3R_VQDMULH_VQRDMULH 22
#define NEON_3R_VPADD 23
#define NEON_3R_FLOAT_ARITH 26 /* float VADD, VSUB, VPADD, VABD */
#define NEON_3R_FLOAT_MULTIPLY 27 /* float VMLA, VMLS, VMUL */
#define NEON_3R_FLOAT_CMP 28 /* float VCEQ, VCGE, VCGT */
#define NEON_3R_FLOAT_ACMP 29 /* float VACGE, VACGT, VACLE, VACLT */
#define NEON_3R_FLOAT_MINMAX 30 /* float VMIN, VMAX */
#define NEON_3R_VRECPS_VRSQRTS 31 /* float VRECPS, VRSQRTS */
static const uint8_t neon_3r_sizes[] = {
[NEON_3R_VHADD] = 0x7,
[NEON_3R_VQADD] = 0xf,
[NEON_3R_VRHADD] = 0x7,
[NEON_3R_LOGIC] = 0xf, /* size field encodes op type */
[NEON_3R_VHSUB] = 0x7,
[NEON_3R_VQSUB] = 0xf,
[NEON_3R_VCGT] = 0x7,
[NEON_3R_VCGE] = 0x7,
[NEON_3R_VSHL] = 0xf,
[NEON_3R_VQSHL] = 0xf,
[NEON_3R_VRSHL] = 0xf,
[NEON_3R_VQRSHL] = 0xf,
[NEON_3R_VMAX] = 0x7,
[NEON_3R_VMIN] = 0x7,
[NEON_3R_VABD] = 0x7,
[NEON_3R_VABA] = 0x7,
[NEON_3R_VADD_VSUB] = 0xf,
[NEON_3R_VTST_VCEQ] = 0x7,
[NEON_3R_VML] = 0x7,
[NEON_3R_VMUL] = 0x7,
[NEON_3R_VPMAX] = 0x7,
[NEON_3R_VPMIN] = 0x7,
[NEON_3R_VQDMULH_VQRDMULH] = 0x6,
[NEON_3R_VPADD] = 0x7,
[NEON_3R_FLOAT_ARITH] = 0x5, /* size bit 1 encodes op */
[NEON_3R_FLOAT_MULTIPLY] = 0x5, /* size bit 1 encodes op */
[NEON_3R_FLOAT_CMP] = 0x5, /* size bit 1 encodes op */
[NEON_3R_FLOAT_ACMP] = 0x5, /* size bit 1 encodes op */
[NEON_3R_FLOAT_MINMAX] = 0x5, /* size bit 1 encodes op */
[NEON_3R_VRECPS_VRSQRTS] = 0x5, /* size bit 1 encodes op */
};
/* Symbolic constants for op fields for Neon 2-register miscellaneous.
* The values correspond to bits [17:16,10:7]; see the ARM ARM DDI0406B
* table A7-13.
*/
#define NEON_2RM_VREV64 0
#define NEON_2RM_VREV32 1
#define NEON_2RM_VREV16 2
#define NEON_2RM_VPADDL 4
#define NEON_2RM_VPADDL_U 5
#define NEON_2RM_VCLS 8
#define NEON_2RM_VCLZ 9
#define NEON_2RM_VCNT 10
#define NEON_2RM_VMVN 11
#define NEON_2RM_VPADAL 12
#define NEON_2RM_VPADAL_U 13
#define NEON_2RM_VQABS 14
#define NEON_2RM_VQNEG 15
#define NEON_2RM_VCGT0 16
#define NEON_2RM_VCGE0 17
#define NEON_2RM_VCEQ0 18
#define NEON_2RM_VCLE0 19
#define NEON_2RM_VCLT0 20
#define NEON_2RM_VABS 22
#define NEON_2RM_VNEG 23
#define NEON_2RM_VCGT0_F 24
#define NEON_2RM_VCGE0_F 25
#define NEON_2RM_VCEQ0_F 26
#define NEON_2RM_VCLE0_F 27
#define NEON_2RM_VCLT0_F 28
#define NEON_2RM_VABS_F 30
#define NEON_2RM_VNEG_F 31
#define NEON_2RM_VSWP 32
#define NEON_2RM_VTRN 33
#define NEON_2RM_VUZP 34
#define NEON_2RM_VZIP 35
#define NEON_2RM_VMOVN 36 /* Includes VQMOVN, VQMOVUN */
#define NEON_2RM_VQMOVN 37 /* Includes VQMOVUN */
#define NEON_2RM_VSHLL 38
#define NEON_2RM_VCVT_F16_F32 44
#define NEON_2RM_VCVT_F32_F16 46
#define NEON_2RM_VRECPE 56
#define NEON_2RM_VRSQRTE 57
#define NEON_2RM_VRECPE_F 58
#define NEON_2RM_VRSQRTE_F 59
#define NEON_2RM_VCVT_FS 60
#define NEON_2RM_VCVT_FU 61
#define NEON_2RM_VCVT_SF 62
#define NEON_2RM_VCVT_UF 63
static int neon_2rm_is_float_op(int op)
{
/* Return true if this neon 2reg-misc op is float-to-float */
return (op == NEON_2RM_VABS_F || op == NEON_2RM_VNEG_F ||
op >= NEON_2RM_VRECPE_F);
}
/* Each entry in this array has bit n set if the insn allows
* size value n (otherwise it will UNDEF). Since unallocated
* op values will have no bits set they always UNDEF.
*/
static const uint8_t neon_2rm_sizes[] = {
[NEON_2RM_VREV64] = 0x7,
[NEON_2RM_VREV32] = 0x3,
[NEON_2RM_VREV16] = 0x1,
[NEON_2RM_VPADDL] = 0x7,
[NEON_2RM_VPADDL_U] = 0x7,
[NEON_2RM_VCLS] = 0x7,
[NEON_2RM_VCLZ] = 0x7,
[NEON_2RM_VCNT] = 0x1,
[NEON_2RM_VMVN] = 0x1,
[NEON_2RM_VPADAL] = 0x7,
[NEON_2RM_VPADAL_U] = 0x7,
[NEON_2RM_VQABS] = 0x7,
[NEON_2RM_VQNEG] = 0x7,
[NEON_2RM_VCGT0] = 0x7,
[NEON_2RM_VCGE0] = 0x7,
[NEON_2RM_VCEQ0] = 0x7,
[NEON_2RM_VCLE0] = 0x7,
[NEON_2RM_VCLT0] = 0x7,
[NEON_2RM_VABS] = 0x7,
[NEON_2RM_VNEG] = 0x7,
[NEON_2RM_VCGT0_F] = 0x4,
[NEON_2RM_VCGE0_F] = 0x4,
[NEON_2RM_VCEQ0_F] = 0x4,
[NEON_2RM_VCLE0_F] = 0x4,
[NEON_2RM_VCLT0_F] = 0x4,
[NEON_2RM_VABS_F] = 0x4,
[NEON_2RM_VNEG_F] = 0x4,
[NEON_2RM_VSWP] = 0x1,
[NEON_2RM_VTRN] = 0x7,
[NEON_2RM_VUZP] = 0x7,
[NEON_2RM_VZIP] = 0x7,
[NEON_2RM_VMOVN] = 0x7,
[NEON_2RM_VQMOVN] = 0x7,
[NEON_2RM_VSHLL] = 0x7,
[NEON_2RM_VCVT_F16_F32] = 0x2,
[NEON_2RM_VCVT_F32_F16] = 0x2,
[NEON_2RM_VRECPE] = 0x4,
[NEON_2RM_VRSQRTE] = 0x4,
[NEON_2RM_VRECPE_F] = 0x4,
[NEON_2RM_VRSQRTE_F] = 0x4,
[NEON_2RM_VCVT_FS] = 0x4,
[NEON_2RM_VCVT_FU] = 0x4,
[NEON_2RM_VCVT_SF] = 0x4,
[NEON_2RM_VCVT_UF] = 0x4,
};
/* Translate a NEON data processing instruction. Return nonzero if the
instruction is invalid.
We process data in a mixture of 32-bit and 64-bit chunks.
Mostly we use 32-bit chunks so we can use normal scalar instructions. */
static int disas_neon_data_insn(CPUState * env, DisasContext *s, uint32_t insn)
{
int op;
int q;
int rd, rn, rm;
int size;
int shift;
int pass;
int count;
int pairwise;
int u;
uint32_t imm, mask;
TCGv tmp, tmp2, tmp3, tmp4, tmp5;
TCGv_i64 tmp64;
if (!s->vfp_enabled)
return 1;
q = (insn & (1 << 6)) != 0;
u = (insn >> 24) & 1;
VFP_DREG_D(rd, insn);
VFP_DREG_N(rn, insn);
VFP_DREG_M(rm, insn);
size = (insn >> 20) & 3;
if ((insn & (1 << 23)) == 0) {
/* Three register same length. */
op = ((insn >> 7) & 0x1e) | ((insn >> 4) & 1);
/* Catch invalid op and bad size combinations: UNDEF */
if ((neon_3r_sizes[op] & (1 << size)) == 0) {
return 1;
}
/* All insns of this form UNDEF for either this condition or the
* superset of cases "Q==1"; we catch the latter later.
*/
if (q && ((rd | rn | rm) & 1)) {
return 1;
}
if (size == 3 && op != NEON_3R_LOGIC) {
/* 64-bit element instructions. */
for (pass = 0; pass < (q ? 2 : 1); pass++) {
neon_load_reg64(cpu_V0, rn + pass);
neon_load_reg64(cpu_V1, rm + pass);
switch (op) {
case NEON_3R_VQADD:
if (u) {
gen_helper_neon_qadd_u64(cpu_V0, cpu_env,
cpu_V0, cpu_V1);
} else {
gen_helper_neon_qadd_s64(cpu_V0, cpu_env,
cpu_V0, cpu_V1);
}
break;
case NEON_3R_VQSUB:
if (u) {
gen_helper_neon_qsub_u64(cpu_V0, cpu_env,
cpu_V0, cpu_V1);
} else {
gen_helper_neon_qsub_s64(cpu_V0, cpu_env,
cpu_V0, cpu_V1);
}
break;
case NEON_3R_VSHL:
if (u) {
gen_helper_neon_shl_u64(cpu_V0, cpu_V1, cpu_V0);
} else {
gen_helper_neon_shl_s64(cpu_V0, cpu_V1, cpu_V0);
}
break;
case NEON_3R_VQSHL:
if (u) {
gen_helper_neon_qshl_u64(cpu_V0, cpu_env,
cpu_V1, cpu_V0);
} else {
gen_helper_neon_qshl_s64(cpu_V0, cpu_env,
cpu_V1, cpu_V0);
}
break;
case NEON_3R_VRSHL:
if (u) {
gen_helper_neon_rshl_u64(cpu_V0, cpu_V1, cpu_V0);
} else {
gen_helper_neon_rshl_s64(cpu_V0, cpu_V1, cpu_V0);
}
break;
case NEON_3R_VQRSHL:
if (u) {
gen_helper_neon_qrshl_u64(cpu_V0, cpu_env,
cpu_V1, cpu_V0);
} else {
gen_helper_neon_qrshl_s64(cpu_V0, cpu_env,
cpu_V1, cpu_V0);
}
break;
case NEON_3R_VADD_VSUB:
if (u) {
tcg_gen_sub_i64(CPU_V001);
} else {
tcg_gen_add_i64(CPU_V001);
}
break;
default:
abort();
}
neon_store_reg64(cpu_V0, rd + pass);
}
return 0;
}
pairwise = 0;
switch (op) {
case NEON_3R_VSHL:
case NEON_3R_VQSHL:
case NEON_3R_VRSHL:
case NEON_3R_VQRSHL:
{
int rtmp;
/* Shift instruction operands are reversed. */
rtmp = rn;
rn = rm;
rm = rtmp;
}
break;
case NEON_3R_VPADD:
if (u) {
return 1;
}
/* Fall through */
case NEON_3R_VPMAX:
case NEON_3R_VPMIN:
pairwise = 1;
break;
case NEON_3R_FLOAT_ARITH:
pairwise = (u && size < 2); /* if VPADD (float) */
break;
case NEON_3R_FLOAT_MINMAX:
pairwise = u; /* if VPMIN/VPMAX (float) */
break;
case NEON_3R_FLOAT_CMP:
if (!u && size) {
/* no encoding for U=0 C=1x */
return 1;
}
break;
case NEON_3R_FLOAT_ACMP:
if (!u) {
return 1;
}
break;
case NEON_3R_VRECPS_VRSQRTS:
if (u) {
return 1;
}
break;
case NEON_3R_VMUL:
if (u && (size != 0)) {
/* UNDEF on invalid size for polynomial subcase */
return 1;
}
break;
default:
break;
}
if (pairwise && q) {
/* All the pairwise insns UNDEF if Q is set */
return 1;
}
for (pass = 0; pass < (q ? 4 : 2); pass++) {
if (pairwise) {
/* Pairwise. */
if (pass < 1) {
tmp = neon_load_reg(rn, 0);
tmp2 = neon_load_reg(rn, 1);
} else {
tmp = neon_load_reg(rm, 0);
tmp2 = neon_load_reg(rm, 1);
}
} else {
/* Elementwise. */
tmp = neon_load_reg(rn, pass);
tmp2 = neon_load_reg(rm, pass);
}
switch (op) {
case NEON_3R_VHADD:
GEN_NEON_INTEGER_OP(hadd);
break;
case NEON_3R_VQADD:
GEN_NEON_INTEGER_OP_ENV(qadd);
break;
case NEON_3R_VRHADD:
GEN_NEON_INTEGER_OP(rhadd);
break;
case NEON_3R_LOGIC: /* Logic ops. */
switch ((u << 2) | size) {
case 0: /* VAND */
tcg_gen_and_i32(tmp, tmp, tmp2);
break;
case 1: /* BIC */
tcg_gen_andc_i32(tmp, tmp, tmp2);
break;
case 2: /* VORR */
tcg_gen_or_i32(tmp, tmp, tmp2);
break;
case 3: /* VORN */
tcg_gen_orc_i32(tmp, tmp, tmp2);
break;
case 4: /* VEOR */
tcg_gen_xor_i32(tmp, tmp, tmp2);
break;
case 5: /* VBSL */
tmp3 = neon_load_reg(rd, pass);
gen_neon_bsl(tmp, tmp, tmp2, tmp3);
tcg_temp_free_i32(tmp3);
break;
case 6: /* VBIT */
tmp3 = neon_load_reg(rd, pass);
gen_neon_bsl(tmp, tmp, tmp3, tmp2);
tcg_temp_free_i32(tmp3);
break;
case 7: /* VBIF */
tmp3 = neon_load_reg(rd, pass);
gen_neon_bsl(tmp, tmp3, tmp, tmp2);
tcg_temp_free_i32(tmp3);
break;
}
break;
case NEON_3R_VHSUB:
GEN_NEON_INTEGER_OP(hsub);
break;
case NEON_3R_VQSUB:
GEN_NEON_INTEGER_OP_ENV(qsub);
break;
case NEON_3R_VCGT:
GEN_NEON_INTEGER_OP(cgt);
break;
case NEON_3R_VCGE:
GEN_NEON_INTEGER_OP(cge);
break;
case NEON_3R_VSHL:
GEN_NEON_INTEGER_OP(shl);
break;
case NEON_3R_VQSHL:
GEN_NEON_INTEGER_OP_ENV(qshl);
break;
case NEON_3R_VRSHL:
GEN_NEON_INTEGER_OP(rshl);
break;
case NEON_3R_VQRSHL:
GEN_NEON_INTEGER_OP_ENV(qrshl);
break;
case NEON_3R_VMAX:
GEN_NEON_INTEGER_OP(max);
break;
case NEON_3R_VMIN:
GEN_NEON_INTEGER_OP(min);
break;
case NEON_3R_VABD:
GEN_NEON_INTEGER_OP(abd);
break;
case NEON_3R_VABA:
GEN_NEON_INTEGER_OP(abd);
tcg_temp_free_i32(tmp2);
tmp2 = neon_load_reg(rd, pass);
gen_neon_add(size, tmp, tmp2);
break;
case NEON_3R_VADD_VSUB:
if (!u) { /* VADD */
gen_neon_add(size, tmp, tmp2);
} else { /* VSUB */
switch (size) {
case 0: gen_helper_neon_sub_u8(tmp, tmp, tmp2); break;
case 1: gen_helper_neon_sub_u16(tmp, tmp, tmp2); break;
case 2: tcg_gen_sub_i32(tmp, tmp, tmp2); break;
default: abort();
}
}
break;
case NEON_3R_VTST_VCEQ:
if (!u) { /* VTST */
switch (size) {
case 0: gen_helper_neon_tst_u8(tmp, tmp, tmp2); break;
case 1: gen_helper_neon_tst_u16(tmp, tmp, tmp2); break;
case 2: gen_helper_neon_tst_u32(tmp, tmp, tmp2); break;
default: abort();
}
} else { /* VCEQ */
switch (size) {
case 0: gen_helper_neon_ceq_u8(tmp, tmp, tmp2); break;
case 1: gen_helper_neon_ceq_u16(tmp, tmp, tmp2); break;
case 2: gen_helper_neon_ceq_u32(tmp, tmp, tmp2); break;
default: abort();
}
}
break;
case NEON_3R_VML: /* VMLA, VMLAL, VMLS,VMLSL */
switch (size) {
case 0: gen_helper_neon_mul_u8(tmp, tmp, tmp2); break;
case 1: gen_helper_neon_mul_u16(tmp, tmp, tmp2); break;
case 2: tcg_gen_mul_i32(tmp, tmp, tmp2); break;
default: abort();
}
tcg_temp_free_i32(tmp2);
tmp2 = neon_load_reg(rd, pass);
if (u) { /* VMLS */
gen_neon_rsb(size, tmp, tmp2);
} else { /* VMLA */
gen_neon_add(size, tmp, tmp2);
}
break;
case NEON_3R_VMUL:
if (u) { /* polynomial */
gen_helper_neon_mul_p8(tmp, tmp, tmp2);
} else { /* Integer */
switch (size) {
case 0: gen_helper_neon_mul_u8(tmp, tmp, tmp2); break;
case 1: gen_helper_neon_mul_u16(tmp, tmp, tmp2); break;
case 2: tcg_gen_mul_i32(tmp, tmp, tmp2); break;
default: abort();
}
}
break;
case NEON_3R_VPMAX:
GEN_NEON_INTEGER_OP(pmax);
break;
case NEON_3R_VPMIN:
GEN_NEON_INTEGER_OP(pmin);
break;
case NEON_3R_VQDMULH_VQRDMULH: /* Multiply high. */
if (!u) { /* VQDMULH */
switch (size) {
case 1:
gen_helper_neon_qdmulh_s16(tmp, cpu_env, tmp, tmp2);
break;
case 2:
gen_helper_neon_qdmulh_s32(tmp, cpu_env, tmp, tmp2);
break;
default: abort();
}
} else { /* VQRDMULH */
switch (size) {
case 1:
gen_helper_neon_qrdmulh_s16(tmp, cpu_env, tmp, tmp2);
break;
case 2:
gen_helper_neon_qrdmulh_s32(tmp, cpu_env, tmp, tmp2);
break;
default: abort();
}
}
break;
case NEON_3R_VPADD:
switch (size) {
case 0: gen_helper_neon_padd_u8(tmp, tmp, tmp2); break;
case 1: gen_helper_neon_padd_u16(tmp, tmp, tmp2); break;
case 2: tcg_gen_add_i32(tmp, tmp, tmp2); break;
default: abort();
}
break;
case NEON_3R_FLOAT_ARITH: /* Floating point arithmetic. */
{
TCGv_ptr fpstatus = get_fpstatus_ptr(1);
switch ((u << 2) | size) {
case 0: /* VADD */
case 4: /* VPADD */
gen_helper_vfp_adds(tmp, tmp, tmp2, fpstatus);
break;
case 2: /* VSUB */
gen_helper_vfp_subs(tmp, tmp, tmp2, fpstatus);
break;
case 6: /* VABD */
gen_helper_neon_abd_f32(tmp, tmp, tmp2, fpstatus);
break;
default:
abort();
}
tcg_temp_free_ptr(fpstatus);
break;
}
case NEON_3R_FLOAT_MULTIPLY:
{
TCGv_ptr fpstatus = get_fpstatus_ptr(1);
gen_helper_vfp_muls(tmp, tmp, tmp2, fpstatus);
if (!u) {
tcg_temp_free_i32(tmp2);
tmp2 = neon_load_reg(rd, pass);
if (size == 0) {
gen_helper_vfp_adds(tmp, tmp, tmp2, fpstatus);
} else {
gen_helper_vfp_subs(tmp, tmp2, tmp, fpstatus);
}
}
tcg_temp_free_ptr(fpstatus);
break;
}
case NEON_3R_FLOAT_CMP:
{
TCGv_ptr fpstatus = get_fpstatus_ptr(1);
if (!u) {
gen_helper_neon_ceq_f32(tmp, tmp, tmp2, fpstatus);
} else {
if (size == 0) {
gen_helper_neon_cge_f32(tmp, tmp, tmp2, fpstatus);
} else {
gen_helper_neon_cgt_f32(tmp, tmp, tmp2, fpstatus);
}
}
tcg_temp_free_ptr(fpstatus);
break;
}
case NEON_3R_FLOAT_ACMP:
{
TCGv_ptr fpstatus = get_fpstatus_ptr(1);
if (size == 0) {
gen_helper_neon_acge_f32(tmp, tmp, tmp2, fpstatus);
} else {
gen_helper_neon_acgt_f32(tmp, tmp, tmp2, fpstatus);
}
tcg_temp_free_ptr(fpstatus);
break;
}
case NEON_3R_FLOAT_MINMAX:
{
TCGv_ptr fpstatus = get_fpstatus_ptr(1);
if (size == 0) {
gen_helper_neon_max_f32(tmp, tmp, tmp2, fpstatus);
} else {
gen_helper_neon_min_f32(tmp, tmp, tmp2, fpstatus);
}
tcg_temp_free_ptr(fpstatus);
break;
}
case NEON_3R_VRECPS_VRSQRTS:
if (size == 0)
gen_helper_recps_f32(tmp, tmp, tmp2, cpu_env);
else
gen_helper_rsqrts_f32(tmp, tmp, tmp2, cpu_env);
break;
default:
abort();
}
tcg_temp_free_i32(tmp2);
/* Save the result. For elementwise operations we can put it
straight into the destination register. For pairwise operations
we have to be careful to avoid clobbering the source operands. */
if (pairwise && rd == rm) {
neon_store_scratch(pass, tmp);
} else {
neon_store_reg(rd, pass, tmp);
}
} /* for pass */
if (pairwise && rd == rm) {
for (pass = 0; pass < (q ? 4 : 2); pass++) {
tmp = neon_load_scratch(pass);
neon_store_reg(rd, pass, tmp);
}
}
/* End of 3 register same size operations. */
} else if (insn & (1 << 4)) {
if ((insn & 0x00380080) != 0) {
/* Two registers and shift. */
op = (insn >> 8) & 0xf;
if (insn & (1 << 7)) {
/* 64-bit shift. */
if (op > 7) {
return 1;
}
size = 3;
} else {
size = 2;
while ((insn & (1 << (size + 19))) == 0)
size--;
}
shift = (insn >> 16) & ((1 << (3 + size)) - 1);
/* To avoid excessive dumplication of ops we implement shift
by immediate using the variable shift operations. */
if (op < 8) {
/* Shift by immediate:
VSHR, VSRA, VRSHR, VRSRA, VSRI, VSHL, VQSHL, VQSHLU. */
if (q && ((rd | rm) & 1)) {
return 1;
}
if (!u && (op == 4 || op == 6)) {
return 1;
}
/* Right shifts are encoded as N - shift, where N is the
element size in bits. */
if (op <= 4)
shift = shift - (1 << (size + 3));
if (size == 3) {
count = q + 1;
} else {
count = q ? 4: 2;
}
switch (size) {
case 0:
imm = (uint8_t) shift;
imm |= imm << 8;
imm |= imm << 16;
break;
case 1:
imm = (uint16_t) shift;
imm |= imm << 16;
break;
case 2:
case 3:
imm = shift;
break;
default:
abort();
}
for (pass = 0; pass < count; pass++) {
if (size == 3) {
neon_load_reg64(cpu_V0, rm + pass);
tcg_gen_movi_i64(cpu_V1, imm);
switch (op) {
case 0: /* VSHR */
case 1: /* VSRA */
if (u)
gen_helper_neon_shl_u64(cpu_V0, cpu_V0, cpu_V1);
else
gen_helper_neon_shl_s64(cpu_V0, cpu_V0, cpu_V1);
break;
case 2: /* VRSHR */
case 3: /* VRSRA */
if (u)
gen_helper_neon_rshl_u64(cpu_V0, cpu_V0, cpu_V1);
else
gen_helper_neon_rshl_s64(cpu_V0, cpu_V0, cpu_V1);
break;
case 4: /* VSRI */
case 5: /* VSHL, VSLI */
gen_helper_neon_shl_u64(cpu_V0, cpu_V0, cpu_V1);
break;
case 6: /* VQSHLU */
gen_helper_neon_qshlu_s64(cpu_V0, cpu_env,
cpu_V0, cpu_V1);
break;
case 7: /* VQSHL */
if (u) {
gen_helper_neon_qshl_u64(cpu_V0, cpu_env,
cpu_V0, cpu_V1);
} else {
gen_helper_neon_qshl_s64(cpu_V0, cpu_env,
cpu_V0, cpu_V1);
}
break;
}
if (op == 1 || op == 3) {
/* Accumulate. */
neon_load_reg64(cpu_V1, rd + pass);
tcg_gen_add_i64(cpu_V0, cpu_V0, cpu_V1);
} else if (op == 4 || (op == 5 && u)) {
/* Insert */
neon_load_reg64(cpu_V1, rd + pass);
uint64_t mask;
if (shift < -63 || shift > 63) {
mask = 0;
} else {
if (op == 4) {
mask = 0xffffffffffffffffull >> -shift;
} else {
mask = 0xffffffffffffffffull << shift;
}
}
tcg_gen_andi_i64(cpu_V1, cpu_V1, ~mask);
tcg_gen_or_i64(cpu_V0, cpu_V0, cpu_V1);
}
neon_store_reg64(cpu_V0, rd + pass);
} else { /* size < 3 */
/* Operands in T0 and T1. */
tmp = neon_load_reg(rm, pass);
tmp2 = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp2, imm);
switch (op) {
case 0: /* VSHR */
case 1: /* VSRA */
GEN_NEON_INTEGER_OP(shl);
break;
case 2: /* VRSHR */
case 3: /* VRSRA */
GEN_NEON_INTEGER_OP(rshl);
break;
case 4: /* VSRI */
case 5: /* VSHL, VSLI */
switch (size) {
case 0: gen_helper_neon_shl_u8(tmp, tmp, tmp2); break;
case 1: gen_helper_neon_shl_u16(tmp, tmp, tmp2); break;
case 2: gen_helper_neon_shl_u32(tmp, tmp, tmp2); break;
default: abort();
}
break;
case 6: /* VQSHLU */
switch (size) {
case 0:
gen_helper_neon_qshlu_s8(tmp, cpu_env,
tmp, tmp2);
break;
case 1:
gen_helper_neon_qshlu_s16(tmp, cpu_env,
tmp, tmp2);
break;
case 2:
gen_helper_neon_qshlu_s32(tmp, cpu_env,
tmp, tmp2);
break;
default:
abort();
}
break;
case 7: /* VQSHL */
GEN_NEON_INTEGER_OP_ENV(qshl);
break;
}
tcg_temp_free_i32(tmp2);
if (op == 1 || op == 3) {
/* Accumulate. */
tmp2 = neon_load_reg(rd, pass);
gen_neon_add(size, tmp, tmp2);
tcg_temp_free_i32(tmp2);
} else if (op == 4 || (op == 5 && u)) {
/* Insert */
switch (size) {
case 0:
if (op == 4)
mask = 0xff >> -shift;
else
mask = (uint8_t)(0xff << shift);
mask |= mask << 8;
mask |= mask << 16;
break;
case 1:
if (op == 4)
mask = 0xffff >> -shift;
else
mask = (uint16_t)(0xffff << shift);
mask |= mask << 16;
break;
case 2:
if (shift < -31 || shift > 31) {
mask = 0;
} else {
if (op == 4)
mask = 0xffffffffu >> -shift;
else
mask = 0xffffffffu << shift;
}
break;
default:
abort();
}
tmp2 = neon_load_reg(rd, pass);
tcg_gen_andi_i32(tmp, tmp, mask);
tcg_gen_andi_i32(tmp2, tmp2, ~mask);
tcg_gen_or_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
}
neon_store_reg(rd, pass, tmp);
}
} /* for pass */
} else if (op < 10) {
/* Shift by immediate and narrow:
VSHRN, VRSHRN, VQSHRN, VQRSHRN. */
int input_unsigned = (op == 8) ? !u : u;
if (rm & 1) {
return 1;
}
shift = shift - (1 << (size + 3));
size++;
if (size == 3) {
tmp64 = tcg_const_i64(shift);
neon_load_reg64(cpu_V0, rm);
neon_load_reg64(cpu_V1, rm + 1);
for (pass = 0; pass < 2; pass++) {
TCGv_i64 in;
if (pass == 0) {
in = cpu_V0;
} else {
in = cpu_V1;
}
if (q) {
if (input_unsigned) {
gen_helper_neon_rshl_u64(cpu_V0, in, tmp64);
} else {
gen_helper_neon_rshl_s64(cpu_V0, in, tmp64);
}
} else {
if (input_unsigned) {
gen_helper_neon_shl_u64(cpu_V0, in, tmp64);
} else {
gen_helper_neon_shl_s64(cpu_V0, in, tmp64);
}
}
tmp = tcg_temp_new_i32();
gen_neon_narrow_op(op == 8, u, size - 1, tmp, cpu_V0);
neon_store_reg(rd, pass, tmp);
} /* for pass */
tcg_temp_free_i64(tmp64);
} else {
if (size == 1) {
imm = (uint16_t)shift;
imm |= imm << 16;
} else {
/* size == 2 */
imm = (uint32_t)shift;
}
tmp2 = tcg_const_i32(imm);
tmp4 = neon_load_reg(rm + 1, 0);
tmp5 = neon_load_reg(rm + 1, 1);
for (pass = 0; pass < 2; pass++) {
if (pass == 0) {
tmp = neon_load_reg(rm, 0);
} else {
tmp = tmp4;
}
gen_neon_shift_narrow(size, tmp, tmp2, q,
input_unsigned);
if (pass == 0) {
tmp3 = neon_load_reg(rm, 1);
} else {
tmp3 = tmp5;
}
gen_neon_shift_narrow(size, tmp3, tmp2, q,
input_unsigned);
tcg_gen_concat_i32_i64(cpu_V0, tmp, tmp3);
tcg_temp_free_i32(tmp);
tcg_temp_free_i32(tmp3);
tmp = tcg_temp_new_i32();
gen_neon_narrow_op(op == 8, u, size - 1, tmp, cpu_V0);
neon_store_reg(rd, pass, tmp);
} /* for pass */
tcg_temp_free_i32(tmp2);
}
} else if (op == 10) {
/* VSHLL, VMOVL */
if (q || (rd & 1)) {
return 1;
}
tmp = neon_load_reg(rm, 0);
tmp2 = neon_load_reg(rm, 1);
for (pass = 0; pass < 2; pass++) {
if (pass == 1)
tmp = tmp2;
gen_neon_widen(cpu_V0, tmp, size, u);
if (shift != 0) {
/* The shift is less than the width of the source
type, so we can just shift the whole register. */
tcg_gen_shli_i64(cpu_V0, cpu_V0, shift);
/* Widen the result of shift: we need to clear
* the potential overflow bits resulting from
* left bits of the narrow input appearing as
* right bits of left the neighbour narrow
* input. */
if (size < 2 || !u) {
uint64_t imm64;
if (size == 0) {
imm = (0xffu >> (8 - shift));
imm |= imm << 16;
} else if (size == 1) {
imm = 0xffff >> (16 - shift);
} else {
/* size == 2 */
imm = 0xffffffff >> (32 - shift);
}
if (size < 2) {
imm64 = imm | (((uint64_t)imm) << 32);
} else {
imm64 = imm;
}
tcg_gen_andi_i64(cpu_V0, cpu_V0, ~imm64);
}
}
neon_store_reg64(cpu_V0, rd + pass);
}
} else if (op >= 14) {
/* VCVT fixed-point. */
if (!(insn & (1 << 21)) || (q && ((rd | rm) & 1))) {
return 1;
}
/* We have already masked out the must-be-1 top bit of imm6,
* hence this 32-shift where the ARM ARM has 64-imm6.
*/
shift = 32 - shift;
for (pass = 0; pass < (q ? 4 : 2); pass++) {
tcg_gen_ld_f32(cpu_F0s, cpu_env, neon_reg_offset(rm, pass));
if (!(op & 1)) {
if (u)
gen_vfp_ulto(0, shift, 1);
else
gen_vfp_slto(0, shift, 1);
} else {
if (u)
gen_vfp_toul(0, shift, 1);
else
gen_vfp_tosl(0, shift, 1);
}
tcg_gen_st_f32(cpu_F0s, cpu_env, neon_reg_offset(rd, pass));
}
} else {
return 1;
}
} else { /* (insn & 0x00380080) == 0 */
int invert;
if (q && (rd & 1)) {
return 1;
}
op = (insn >> 8) & 0xf;
/* One register and immediate. */
imm = (u << 7) | ((insn >> 12) & 0x70) | (insn & 0xf);
invert = (insn & (1 << 5)) != 0;
/* Note that op = 2,3,4,5,6,7,10,11,12,13 imm=0 is UNPREDICTABLE.
* We choose to not special-case this and will behave as if a
* valid constant encoding of 0 had been given.
*/
switch (op) {
case 0: case 1:
/* no-op */
break;
case 2: case 3:
imm <<= 8;
break;
case 4: case 5:
imm <<= 16;
break;
case 6: case 7:
imm <<= 24;
break;
case 8: case 9:
imm |= imm << 16;
break;
case 10: case 11:
imm = (imm << 8) | (imm << 24);
break;
case 12:
imm = (imm << 8) | 0xff;
break;
case 13:
imm = (imm << 16) | 0xffff;
break;
case 14:
imm |= (imm << 8) | (imm << 16) | (imm << 24);
if (invert)
imm = ~imm;
break;
case 15:
if (invert) {
return 1;
}
imm = ((imm & 0x80) << 24) | ((imm & 0x3f) << 19)
| ((imm & 0x40) ? (0x1f << 25) : (1 << 30));
break;
}
if (invert)
imm = ~imm;
for (pass = 0; pass < (q ? 4 : 2); pass++) {
if (op & 1 && op < 12) {
tmp = neon_load_reg(rd, pass);
if (invert) {
/* The immediate value has already been inverted, so
BIC becomes AND. */
tcg_gen_andi_i32(tmp, tmp, imm);
} else {
tcg_gen_ori_i32(tmp, tmp, imm);
}
} else {
/* VMOV, VMVN. */
tmp = tcg_temp_new_i32();
if (op == 14 && invert) {
int n;
uint32_t val;
val = 0;
for (n = 0; n < 4; n++) {
if (imm & (1 << (n + (pass & 1) * 4)))
val |= 0xff << (n * 8);
}
tcg_gen_movi_i32(tmp, val);
} else {
tcg_gen_movi_i32(tmp, imm);
}
}
neon_store_reg(rd, pass, tmp);
}
}
} else { /* (insn & 0x00800010 == 0x00800000) */
if (size != 3) {
op = (insn >> 8) & 0xf;
if ((insn & (1 << 6)) == 0) {
/* Three registers of different lengths. */
int src1_wide;
int src2_wide;
int prewiden;
/* undefreq: bit 0 : UNDEF if size != 0
* bit 1 : UNDEF if size == 0
* bit 2 : UNDEF if U == 1
* Note that [1:0] set implies 'always UNDEF'
*/
int undefreq;
/* prewiden, src1_wide, src2_wide, undefreq */
static const int neon_3reg_wide[16][4] = {
{1, 0, 0, 0}, /* VADDL */
{1, 1, 0, 0}, /* VADDW */
{1, 0, 0, 0}, /* VSUBL */
{1, 1, 0, 0}, /* VSUBW */
{0, 1, 1, 0}, /* VADDHN */
{0, 0, 0, 0}, /* VABAL */
{0, 1, 1, 0}, /* VSUBHN */
{0, 0, 0, 0}, /* VABDL */
{0, 0, 0, 0}, /* VMLAL */
{0, 0, 0, 6}, /* VQDMLAL */
{0, 0, 0, 0}, /* VMLSL */
{0, 0, 0, 6}, /* VQDMLSL */
{0, 0, 0, 0}, /* Integer VMULL */
{0, 0, 0, 2}, /* VQDMULL */
{0, 0, 0, 5}, /* Polynomial VMULL */
{0, 0, 0, 3}, /* Reserved: always UNDEF */
};
prewiden = neon_3reg_wide[op][0];
src1_wide = neon_3reg_wide[op][1];
src2_wide = neon_3reg_wide[op][2];
undefreq = neon_3reg_wide[op][3];
if (((undefreq & 1) && (size != 0)) ||
((undefreq & 2) && (size == 0)) ||
((undefreq & 4) && u)) {
return 1;
}
if ((src1_wide && (rn & 1)) ||
(src2_wide && (rm & 1)) ||
(!src2_wide && (rd & 1))) {
return 1;
}
/* Avoid overlapping operands. Wide source operands are
always aligned so will never overlap with wide
destinations in problematic ways. */
if (rd == rm && !src2_wide) {
tmp = neon_load_reg(rm, 1);
neon_store_scratch(2, tmp);
} else if (rd == rn && !src1_wide) {
tmp = neon_load_reg(rn, 1);
neon_store_scratch(2, tmp);
}
TCGV_UNUSED(tmp3);
for (pass = 0; pass < 2; pass++) {
if (src1_wide) {
neon_load_reg64(cpu_V0, rn + pass);
TCGV_UNUSED(tmp);
} else {
if (pass == 1 && rd == rn) {
tmp = neon_load_scratch(2);
} else {
tmp = neon_load_reg(rn, pass);
}
if (prewiden) {
gen_neon_widen(cpu_V0, tmp, size, u);
}
}
if (src2_wide) {
neon_load_reg64(cpu_V1, rm + pass);
TCGV_UNUSED(tmp2);
} else {
if (pass == 1 && rd == rm) {
tmp2 = neon_load_scratch(2);
} else {
tmp2 = neon_load_reg(rm, pass);
}
if (prewiden) {
gen_neon_widen(cpu_V1, tmp2, size, u);
}
}
switch (op) {
case 0: case 1: case 4: /* VADDL, VADDW, VADDHN, VRADDHN */
gen_neon_addl(size);
break;
case 2: case 3: case 6: /* VSUBL, VSUBW, VSUBHN, VRSUBHN */
gen_neon_subl(size);
break;
case 5: case 7: /* VABAL, VABDL */
switch ((size << 1) | u) {
case 0:
gen_helper_neon_abdl_s16(cpu_V0, tmp, tmp2);
break;
case 1:
gen_helper_neon_abdl_u16(cpu_V0, tmp, tmp2);
break;
case 2:
gen_helper_neon_abdl_s32(cpu_V0, tmp, tmp2);
break;
case 3:
gen_helper_neon_abdl_u32(cpu_V0, tmp, tmp2);
break;
case 4:
gen_helper_neon_abdl_s64(cpu_V0, tmp, tmp2);
break;
case 5:
gen_helper_neon_abdl_u64(cpu_V0, tmp, tmp2);
break;
default: abort();
}
tcg_temp_free_i32(tmp2);
tcg_temp_free_i32(tmp);
break;
case 8: case 9: case 10: case 11: case 12: case 13:
/* VMLAL, VQDMLAL, VMLSL, VQDMLSL, VMULL, VQDMULL */
gen_neon_mull(cpu_V0, tmp, tmp2, size, u);
break;
case 14: /* Polynomial VMULL */
gen_helper_neon_mull_p8(cpu_V0, tmp, tmp2);
tcg_temp_free_i32(tmp2);
tcg_temp_free_i32(tmp);
break;
default: /* 15 is RESERVED: caught earlier */
abort();
}
if (op == 13) {
/* VQDMULL */
gen_neon_addl_saturate(cpu_V0, cpu_V0, size);
neon_store_reg64(cpu_V0, rd + pass);
} else if (op == 5 || (op >= 8 && op <= 11)) {
/* Accumulate. */
neon_load_reg64(cpu_V1, rd + pass);
switch (op) {
case 10: /* VMLSL */
gen_neon_negl(cpu_V0, size);
/* Fall through */
case 5: case 8: /* VABAL, VMLAL */
gen_neon_addl(size);
break;
case 9: case 11: /* VQDMLAL, VQDMLSL */
gen_neon_addl_saturate(cpu_V0, cpu_V0, size);
if (op == 11) {
gen_neon_negl(cpu_V0, size);
}
gen_neon_addl_saturate(cpu_V0, cpu_V1, size);
break;
default:
abort();
}
neon_store_reg64(cpu_V0, rd + pass);
} else if (op == 4 || op == 6) {
/* Narrowing operation. */
tmp = tcg_temp_new_i32();
if (!u) {
switch (size) {
case 0:
gen_helper_neon_narrow_high_u8(tmp, cpu_V0);
break;
case 1:
gen_helper_neon_narrow_high_u16(tmp, cpu_V0);
break;
case 2:
tcg_gen_shri_i64(cpu_V0, cpu_V0, 32);
tcg_gen_trunc_i64_i32(tmp, cpu_V0);
break;
default: abort();
}
} else {
switch (size) {
case 0:
gen_helper_neon_narrow_round_high_u8(tmp, cpu_V0);
break;
case 1:
gen_helper_neon_narrow_round_high_u16(tmp, cpu_V0);
break;
case 2:
tcg_gen_addi_i64(cpu_V0, cpu_V0, 1u << 31);
tcg_gen_shri_i64(cpu_V0, cpu_V0, 32);
tcg_gen_trunc_i64_i32(tmp, cpu_V0);
break;
default: abort();
}
}
if (pass == 0) {
tmp3 = tmp;
} else {
neon_store_reg(rd, 0, tmp3);
neon_store_reg(rd, 1, tmp);
}
} else {
/* Write back the result. */
neon_store_reg64(cpu_V0, rd + pass);
}
}
} else {
/* Two registers and a scalar. NB that for ops of this form
* the ARM ARM labels bit 24 as Q, but it is in our variable
* 'u', not 'q'.
*/
if (size == 0) {
return 1;
}
switch (op) {
case 1: /* Float VMLA scalar */
case 5: /* Floating point VMLS scalar */
case 9: /* Floating point VMUL scalar */
if (size == 1) {
return 1;
}
/* fall through */
case 0: /* Integer VMLA scalar */
case 4: /* Integer VMLS scalar */
case 8: /* Integer VMUL scalar */
case 12: /* VQDMULH scalar */
case 13: /* VQRDMULH scalar */
if (u && ((rd | rn) & 1)) {
return 1;
}
tmp = neon_get_scalar(size, rm);
neon_store_scratch(0, tmp);
for (pass = 0; pass < (u ? 4 : 2); pass++) {
tmp = neon_load_scratch(0);
tmp2 = neon_load_reg(rn, pass);
if (op == 12) {
if (size == 1) {
gen_helper_neon_qdmulh_s16(tmp, cpu_env, tmp, tmp2);
} else {
gen_helper_neon_qdmulh_s32(tmp, cpu_env, tmp, tmp2);
}
} else if (op == 13) {
if (size == 1) {
gen_helper_neon_qrdmulh_s16(tmp, cpu_env, tmp, tmp2);
} else {
gen_helper_neon_qrdmulh_s32(tmp, cpu_env, tmp, tmp2);
}
} else if (op & 1) {
TCGv_ptr fpstatus = get_fpstatus_ptr(1);
gen_helper_vfp_muls(tmp, tmp, tmp2, fpstatus);
tcg_temp_free_ptr(fpstatus);
} else {
switch (size) {
case 0: gen_helper_neon_mul_u8(tmp, tmp, tmp2); break;
case 1: gen_helper_neon_mul_u16(tmp, tmp, tmp2); break;
case 2: tcg_gen_mul_i32(tmp, tmp, tmp2); break;
default: abort();
}
}
tcg_temp_free_i32(tmp2);
if (op < 8) {
/* Accumulate. */
tmp2 = neon_load_reg(rd, pass);
switch (op) {
case 0:
gen_neon_add(size, tmp, tmp2);
break;
case 1:
{
TCGv_ptr fpstatus = get_fpstatus_ptr(1);
gen_helper_vfp_adds(tmp, tmp, tmp2, fpstatus);
tcg_temp_free_ptr(fpstatus);
break;
}
case 4:
gen_neon_rsb(size, tmp, tmp2);
break;
case 5:
{
TCGv_ptr fpstatus = get_fpstatus_ptr(1);
gen_helper_vfp_subs(tmp, tmp2, tmp, fpstatus);
tcg_temp_free_ptr(fpstatus);
break;
}
default:
abort();
}
tcg_temp_free_i32(tmp2);
}
neon_store_reg(rd, pass, tmp);
}
break;
case 3: /* VQDMLAL scalar */
case 7: /* VQDMLSL scalar */
case 11: /* VQDMULL scalar */
if (u == 1) {
return 1;
}
/* fall through */
case 2: /* VMLAL sclar */
case 6: /* VMLSL scalar */
case 10: /* VMULL scalar */
if (rd & 1) {
return 1;
}
tmp2 = neon_get_scalar(size, rm);
/* We need a copy of tmp2 because gen_neon_mull
* deletes it during pass 0. */
tmp4 = tcg_temp_new_i32();
tcg_gen_mov_i32(tmp4, tmp2);
tmp3 = neon_load_reg(rn, 1);
for (pass = 0; pass < 2; pass++) {
if (pass == 0) {
tmp = neon_load_reg(rn, 0);
} else {
tmp = tmp3;
tmp2 = tmp4;
}
gen_neon_mull(cpu_V0, tmp, tmp2, size, u);
if (op != 11) {
neon_load_reg64(cpu_V1, rd + pass);
}
switch (op) {
case 6:
gen_neon_negl(cpu_V0, size);
/* Fall through */
case 2:
gen_neon_addl(size);
break;
case 3: case 7:
gen_neon_addl_saturate(cpu_V0, cpu_V0, size);
if (op == 7) {
gen_neon_negl(cpu_V0, size);
}
gen_neon_addl_saturate(cpu_V0, cpu_V1, size);
break;
case 10:
/* no-op */
break;
case 11:
gen_neon_addl_saturate(cpu_V0, cpu_V0, size);
break;
default:
abort();
}
neon_store_reg64(cpu_V0, rd + pass);
}
break;
default: /* 14 and 15 are RESERVED */
return 1;
}
}
} else { /* size == 3 */
if (!u) {
/* Extract. */
imm = (insn >> 8) & 0xf;
if (imm > 7 && !q)
return 1;
if (q && ((rd | rn | rm) & 1)) {
return 1;
}
if (imm == 0) {
neon_load_reg64(cpu_V0, rn);
if (q) {
neon_load_reg64(cpu_V1, rn + 1);
}
} else if (imm == 8) {
neon_load_reg64(cpu_V0, rn + 1);
if (q) {
neon_load_reg64(cpu_V1, rm);
}
} else if (q) {
tmp64 = tcg_temp_new_i64();
if (imm < 8) {
neon_load_reg64(cpu_V0, rn);
neon_load_reg64(tmp64, rn + 1);
} else {
neon_load_reg64(cpu_V0, rn + 1);
neon_load_reg64(tmp64, rm);
}
tcg_gen_shri_i64(cpu_V0, cpu_V0, (imm & 7) * 8);
tcg_gen_shli_i64(cpu_V1, tmp64, 64 - ((imm & 7) * 8));
tcg_gen_or_i64(cpu_V0, cpu_V0, cpu_V1);
if (imm < 8) {
neon_load_reg64(cpu_V1, rm);
} else {
neon_load_reg64(cpu_V1, rm + 1);
imm -= 8;
}
tcg_gen_shli_i64(cpu_V1, cpu_V1, 64 - (imm * 8));
tcg_gen_shri_i64(tmp64, tmp64, imm * 8);
tcg_gen_or_i64(cpu_V1, cpu_V1, tmp64);
tcg_temp_free_i64(tmp64);
} else {
/* BUGFIX */
neon_load_reg64(cpu_V0, rn);
tcg_gen_shri_i64(cpu_V0, cpu_V0, imm * 8);
neon_load_reg64(cpu_V1, rm);
tcg_gen_shli_i64(cpu_V1, cpu_V1, 64 - (imm * 8));
tcg_gen_or_i64(cpu_V0, cpu_V0, cpu_V1);
}
neon_store_reg64(cpu_V0, rd);
if (q) {
neon_store_reg64(cpu_V1, rd + 1);
}
} else if ((insn & (1 << 11)) == 0) {
/* Two register misc. */
op = ((insn >> 12) & 0x30) | ((insn >> 7) & 0xf);
size = (insn >> 18) & 3;
/* UNDEF for unknown op values and bad op-size combinations */
if ((neon_2rm_sizes[op] & (1 << size)) == 0) {
return 1;
}
if ((op != NEON_2RM_VMOVN && op != NEON_2RM_VQMOVN) &&
q && ((rm | rd) & 1)) {
return 1;
}
switch (op) {
case NEON_2RM_VREV64:
for (pass = 0; pass < (q ? 2 : 1); pass++) {
tmp = neon_load_reg(rm, pass * 2);
tmp2 = neon_load_reg(rm, pass * 2 + 1);
switch (size) {
case 0: tcg_gen_bswap32_i32(tmp, tmp); break;
case 1: gen_swap_half(tmp); break;
case 2: /* no-op */ break;
default: abort();
}
neon_store_reg(rd, pass * 2 + 1, tmp);
if (size == 2) {
neon_store_reg(rd, pass * 2, tmp2);
} else {
switch (size) {
case 0: tcg_gen_bswap32_i32(tmp2, tmp2); break;
case 1: gen_swap_half(tmp2); break;
default: abort();
}
neon_store_reg(rd, pass * 2, tmp2);
}
}
break;
case NEON_2RM_VPADDL: case NEON_2RM_VPADDL_U:
case NEON_2RM_VPADAL: case NEON_2RM_VPADAL_U:
for (pass = 0; pass < q + 1; pass++) {
tmp = neon_load_reg(rm, pass * 2);
gen_neon_widen(cpu_V0, tmp, size, op & 1);
tmp = neon_load_reg(rm, pass * 2 + 1);
gen_neon_widen(cpu_V1, tmp, size, op & 1);
switch (size) {
case 0: gen_helper_neon_paddl_u16(CPU_V001); break;
case 1: gen_helper_neon_paddl_u32(CPU_V001); break;
case 2: tcg_gen_add_i64(CPU_V001); break;
default: abort();
}
if (op >= NEON_2RM_VPADAL) {
/* Accumulate. */
neon_load_reg64(cpu_V1, rd + pass);
gen_neon_addl(size);
}
neon_store_reg64(cpu_V0, rd + pass);
}
break;
case NEON_2RM_VTRN:
if (size == 2) {
int n;
for (n = 0; n < (q ? 4 : 2); n += 2) {
tmp = neon_load_reg(rm, n);
tmp2 = neon_load_reg(rd, n + 1);
neon_store_reg(rm, n, tmp2);
neon_store_reg(rd, n + 1, tmp);
}
} else {
goto elementwise;
}
break;
case NEON_2RM_VUZP:
if (gen_neon_unzip(rd, rm, size, q)) {
return 1;
}
break;
case NEON_2RM_VZIP:
if (gen_neon_zip(rd, rm, size, q)) {
return 1;
}
break;
case NEON_2RM_VMOVN: case NEON_2RM_VQMOVN:
/* also VQMOVUN; op field and mnemonics don't line up */
if (rm & 1) {
return 1;
}
TCGV_UNUSED(tmp2);
for (pass = 0; pass < 2; pass++) {
neon_load_reg64(cpu_V0, rm + pass);
tmp = tcg_temp_new_i32();
gen_neon_narrow_op(op == NEON_2RM_VMOVN, q, size,
tmp, cpu_V0);
if (pass == 0) {
tmp2 = tmp;
} else {
neon_store_reg(rd, 0, tmp2);
neon_store_reg(rd, 1, tmp);
}
}
break;
case NEON_2RM_VSHLL:
if (q || (rd & 1)) {
return 1;
}
tmp = neon_load_reg(rm, 0);
tmp2 = neon_load_reg(rm, 1);
for (pass = 0; pass < 2; pass++) {
if (pass == 1)
tmp = tmp2;
gen_neon_widen(cpu_V0, tmp, size, 1);
tcg_gen_shli_i64(cpu_V0, cpu_V0, 8 << size);
neon_store_reg64(cpu_V0, rd + pass);
}
break;
case NEON_2RM_VCVT_F16_F32:
if (!arm_feature(env, ARM_FEATURE_VFP_FP16) ||
q || (rm & 1)) {
return 1;
}
tmp = tcg_temp_new_i32();
tmp2 = tcg_temp_new_i32();
tcg_gen_ld_f32(cpu_F0s, cpu_env, neon_reg_offset(rm, 0));
gen_helper_neon_fcvt_f32_to_f16(tmp, cpu_F0s, cpu_env);
tcg_gen_ld_f32(cpu_F0s, cpu_env, neon_reg_offset(rm, 1));
gen_helper_neon_fcvt_f32_to_f16(tmp2, cpu_F0s, cpu_env);
tcg_gen_shli_i32(tmp2, tmp2, 16);
tcg_gen_or_i32(tmp2, tmp2, tmp);
tcg_gen_ld_f32(cpu_F0s, cpu_env, neon_reg_offset(rm, 2));
gen_helper_neon_fcvt_f32_to_f16(tmp, cpu_F0s, cpu_env);
tcg_gen_ld_f32(cpu_F0s, cpu_env, neon_reg_offset(rm, 3));
neon_store_reg(rd, 0, tmp2);
tmp2 = tcg_temp_new_i32();
gen_helper_neon_fcvt_f32_to_f16(tmp2, cpu_F0s, cpu_env);
tcg_gen_shli_i32(tmp2, tmp2, 16);
tcg_gen_or_i32(tmp2, tmp2, tmp);
neon_store_reg(rd, 1, tmp2);
tcg_temp_free_i32(tmp);
break;
case NEON_2RM_VCVT_F32_F16:
if (!arm_feature(env, ARM_FEATURE_VFP_FP16) ||
q || (rd & 1)) {
return 1;
}
tmp3 = tcg_temp_new_i32();
tmp = neon_load_reg(rm, 0);
tmp2 = neon_load_reg(rm, 1);
tcg_gen_ext16u_i32(tmp3, tmp);
gen_helper_neon_fcvt_f16_to_f32(cpu_F0s, tmp3, cpu_env);
tcg_gen_st_f32(cpu_F0s, cpu_env, neon_reg_offset(rd, 0));
tcg_gen_shri_i32(tmp3, tmp, 16);
gen_helper_neon_fcvt_f16_to_f32(cpu_F0s, tmp3, cpu_env);
tcg_gen_st_f32(cpu_F0s, cpu_env, neon_reg_offset(rd, 1));
tcg_temp_free_i32(tmp);
tcg_gen_ext16u_i32(tmp3, tmp2);
gen_helper_neon_fcvt_f16_to_f32(cpu_F0s, tmp3, cpu_env);
tcg_gen_st_f32(cpu_F0s, cpu_env, neon_reg_offset(rd, 2));
tcg_gen_shri_i32(tmp3, tmp2, 16);
gen_helper_neon_fcvt_f16_to_f32(cpu_F0s, tmp3, cpu_env);
tcg_gen_st_f32(cpu_F0s, cpu_env, neon_reg_offset(rd, 3));
tcg_temp_free_i32(tmp2);
tcg_temp_free_i32(tmp3);
break;
default:
elementwise:
for (pass = 0; pass < (q ? 4 : 2); pass++) {
if (neon_2rm_is_float_op(op)) {
tcg_gen_ld_f32(cpu_F0s, cpu_env,
neon_reg_offset(rm, pass));
TCGV_UNUSED(tmp);
} else {
tmp = neon_load_reg(rm, pass);
}
switch (op) {
case NEON_2RM_VREV32:
switch (size) {
case 0: tcg_gen_bswap32_i32(tmp, tmp); break;
case 1: gen_swap_half(tmp); break;
default: abort();
}
break;
case NEON_2RM_VREV16:
gen_rev16(tmp);
break;
case NEON_2RM_VCLS:
switch (size) {
case 0: gen_helper_neon_cls_s8(tmp, tmp); break;
case 1: gen_helper_neon_cls_s16(tmp, tmp); break;
case 2: gen_helper_neon_cls_s32(tmp, tmp); break;
default: abort();
}
break;
case NEON_2RM_VCLZ:
switch (size) {
case 0: gen_helper_neon_clz_u8(tmp, tmp); break;
case 1: gen_helper_neon_clz_u16(tmp, tmp); break;
case 2: gen_helper_clz(tmp, tmp); break;
default: abort();
}
break;
case NEON_2RM_VCNT:
gen_helper_neon_cnt_u8(tmp, tmp);
break;
case NEON_2RM_VMVN:
tcg_gen_not_i32(tmp, tmp);
break;
case NEON_2RM_VQABS:
switch (size) {
case 0:
gen_helper_neon_qabs_s8(tmp, cpu_env, tmp);
break;
case 1:
gen_helper_neon_qabs_s16(tmp, cpu_env, tmp);
break;
case 2:
gen_helper_neon_qabs_s32(tmp, cpu_env, tmp);
break;
default: abort();
}
break;
case NEON_2RM_VQNEG:
switch (size) {
case 0:
gen_helper_neon_qneg_s8(tmp, cpu_env, tmp);
break;
case 1:
gen_helper_neon_qneg_s16(tmp, cpu_env, tmp);
break;
case 2:
gen_helper_neon_qneg_s32(tmp, cpu_env, tmp);
break;
default: abort();
}
break;
case NEON_2RM_VCGT0: case NEON_2RM_VCLE0:
tmp2 = tcg_const_i32(0);
switch(size) {
case 0: gen_helper_neon_cgt_s8(tmp, tmp, tmp2); break;
case 1: gen_helper_neon_cgt_s16(tmp, tmp, tmp2); break;
case 2: gen_helper_neon_cgt_s32(tmp, tmp, tmp2); break;
default: abort();
}
tcg_temp_free(tmp2);
if (op == NEON_2RM_VCLE0) {
tcg_gen_not_i32(tmp, tmp);
}
break;
case NEON_2RM_VCGE0: case NEON_2RM_VCLT0:
tmp2 = tcg_const_i32(0);
switch(size) {
case 0: gen_helper_neon_cge_s8(tmp, tmp, tmp2); break;
case 1: gen_helper_neon_cge_s16(tmp, tmp, tmp2); break;
case 2: gen_helper_neon_cge_s32(tmp, tmp, tmp2); break;
default: abort();
}
tcg_temp_free(tmp2);
if (op == NEON_2RM_VCLT0) {
tcg_gen_not_i32(tmp, tmp);
}
break;
case NEON_2RM_VCEQ0:
tmp2 = tcg_const_i32(0);
switch(size) {
case 0: gen_helper_neon_ceq_u8(tmp, tmp, tmp2); break;
case 1: gen_helper_neon_ceq_u16(tmp, tmp, tmp2); break;
case 2: gen_helper_neon_ceq_u32(tmp, tmp, tmp2); break;
default: abort();
}
tcg_temp_free(tmp2);
break;
case NEON_2RM_VABS:
switch(size) {
case 0: gen_helper_neon_abs_s8(tmp, tmp); break;
case 1: gen_helper_neon_abs_s16(tmp, tmp); break;
case 2: tcg_gen_abs_i32(tmp, tmp); break;
default: abort();
}
break;
case NEON_2RM_VNEG:
tmp2 = tcg_const_i32(0);
gen_neon_rsb(size, tmp, tmp2);
tcg_temp_free(tmp2);
break;
case NEON_2RM_VCGT0_F:
{
TCGv_ptr fpstatus = get_fpstatus_ptr(1);
tmp2 = tcg_const_i32(0);
gen_helper_neon_cgt_f32(tmp, tmp, tmp2, fpstatus);
tcg_temp_free(tmp2);
tcg_temp_free_ptr(fpstatus);
break;
}
case NEON_2RM_VCGE0_F:
{
TCGv_ptr fpstatus = get_fpstatus_ptr(1);
tmp2 = tcg_const_i32(0);
gen_helper_neon_cge_f32(tmp, tmp, tmp2, fpstatus);
tcg_temp_free(tmp2);
tcg_temp_free_ptr(fpstatus);
break;
}
case NEON_2RM_VCEQ0_F:
{
TCGv_ptr fpstatus = get_fpstatus_ptr(1);
tmp2 = tcg_const_i32(0);
gen_helper_neon_ceq_f32(tmp, tmp, tmp2, fpstatus);
tcg_temp_free(tmp2);
tcg_temp_free_ptr(fpstatus);
break;
}
case NEON_2RM_VCLE0_F:
{
TCGv_ptr fpstatus = get_fpstatus_ptr(1);
tmp2 = tcg_const_i32(0);
gen_helper_neon_cge_f32(tmp, tmp2, tmp, fpstatus);
tcg_temp_free(tmp2);
tcg_temp_free_ptr(fpstatus);
break;
}
case NEON_2RM_VCLT0_F:
{
TCGv_ptr fpstatus = get_fpstatus_ptr(1);
tmp2 = tcg_const_i32(0);
gen_helper_neon_cgt_f32(tmp, tmp2, tmp, fpstatus);
tcg_temp_free(tmp2);
tcg_temp_free_ptr(fpstatus);
break;
}
case NEON_2RM_VABS_F:
gen_vfp_abs(0);
break;
case NEON_2RM_VNEG_F:
gen_vfp_neg(0);
break;
case NEON_2RM_VSWP:
tmp2 = neon_load_reg(rd, pass);
neon_store_reg(rm, pass, tmp2);
break;
case NEON_2RM_VTRN:
tmp2 = neon_load_reg(rd, pass);
switch (size) {
case 0: gen_neon_trn_u8(tmp, tmp2); break;
case 1: gen_neon_trn_u16(tmp, tmp2); break;
default: abort();
}
neon_store_reg(rm, pass, tmp2);
break;
case NEON_2RM_VRECPE:
gen_helper_recpe_u32(tmp, tmp, cpu_env);
break;
case NEON_2RM_VRSQRTE:
gen_helper_rsqrte_u32(tmp, tmp, cpu_env);
break;
case NEON_2RM_VRECPE_F:
gen_helper_recpe_f32(cpu_F0s, cpu_F0s, cpu_env);
break;
case NEON_2RM_VRSQRTE_F:
gen_helper_rsqrte_f32(cpu_F0s, cpu_F0s, cpu_env);
break;
case NEON_2RM_VCVT_FS: /* VCVT.F32.S32 */
gen_vfp_sito(0, 1);
break;
case NEON_2RM_VCVT_FU: /* VCVT.F32.U32 */
gen_vfp_uito(0, 1);
break;
case NEON_2RM_VCVT_SF: /* VCVT.S32.F32 */
gen_vfp_tosiz(0, 1);
break;
case NEON_2RM_VCVT_UF: /* VCVT.U32.F32 */
gen_vfp_touiz(0, 1);
break;
default:
/* Reserved op values were caught by the
* neon_2rm_sizes[] check earlier.
*/
abort();
}
if (neon_2rm_is_float_op(op)) {
tcg_gen_st_f32(cpu_F0s, cpu_env,
neon_reg_offset(rd, pass));
} else {
neon_store_reg(rd, pass, tmp);
}
}
break;
}
} else if ((insn & (1 << 10)) == 0) {
/* VTBL, VTBX. */
int n = ((insn >> 8) & 3) + 1;
if ((rn + n) > 32) {
/* This is UNPREDICTABLE; we choose to UNDEF to avoid the
* helper function running off the end of the register file.
*/
return 1;
}
n <<= 3;
if (insn & (1 << 6)) {
tmp = neon_load_reg(rd, 0);
} else {
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, 0);
}
tmp2 = neon_load_reg(rm, 0);
tmp4 = tcg_const_i32(rn);
tmp5 = tcg_const_i32(n);
gen_helper_neon_tbl(tmp2, tmp2, tmp, tmp4, tmp5);
tcg_temp_free_i32(tmp);
if (insn & (1 << 6)) {
tmp = neon_load_reg(rd, 1);
} else {
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, 0);
}
tmp3 = neon_load_reg(rm, 1);
gen_helper_neon_tbl(tmp3, tmp3, tmp, tmp4, tmp5);
tcg_temp_free_i32(tmp5);
tcg_temp_free_i32(tmp4);
neon_store_reg(rd, 0, tmp2);
neon_store_reg(rd, 1, tmp3);
tcg_temp_free_i32(tmp);
} else if ((insn & 0x380) == 0) {
/* VDUP */
if ((insn & (7 << 16)) == 0 || (q && (rd & 1))) {
return 1;
}
if (insn & (1 << 19)) {
tmp = neon_load_reg(rm, 1);
} else {
tmp = neon_load_reg(rm, 0);
}
if (insn & (1 << 16)) {
gen_neon_dup_u8(tmp, ((insn >> 17) & 3) * 8);
} else if (insn & (1 << 17)) {
if ((insn >> 18) & 1)
gen_neon_dup_high16(tmp);
else
gen_neon_dup_low16(tmp);
}
for (pass = 0; pass < (q ? 4 : 2); pass++) {
tmp2 = tcg_temp_new_i32();
tcg_gen_mov_i32(tmp2, tmp);
neon_store_reg(rd, pass, tmp2);
}
tcg_temp_free_i32(tmp);
} else {
return 1;
}
}
}
return 0;
}
static int disas_cp14_read(CPUState * env, DisasContext *s, uint32_t insn)
{
int crn = (insn >> 16) & 0xf;
int crm = insn & 0xf;
int op1 = (insn >> 21) & 7;
int op2 = (insn >> 5) & 7;
int rt = (insn >> 12) & 0xf;
TCGv tmp;
/* Minimal set of debug registers, since we don't support debug */
if (op1 == 0 && crn == 0 && op2 == 0) {
switch (crm) {
case 0:
/* DBGDIDR: just RAZ. In particular this means the
* "debug architecture version" bits will read as
* a reserved value, which should cause Linux to
* not try to use the debug hardware.
*/
tmp = tcg_const_i32(0);
store_reg(s, rt, tmp);
return 0;
case 1:
case 2:
/* DBGDRAR and DBGDSAR: v7 only. Always RAZ since we
* don't implement memory mapped debug components
*/
if (ENABLE_ARCH_7) {
tmp = tcg_const_i32(0);
store_reg(s, rt, tmp);
return 0;
}
break;
default:
break;
}
}
if (arm_feature(env, ARM_FEATURE_THUMB2EE)) {
if (op1 == 6 && crn == 0 && crm == 0 && op2 == 0) {
/* TEECR */
if (IS_USER(s))
return 1;
tmp = load_cpu_field(teecr);
store_reg(s, rt, tmp);
return 0;
}
if (op1 == 6 && crn == 1 && crm == 0 && op2 == 0) {
/* TEEHBR */
if (IS_USER(s) && (env->teecr & 1))
return 1;
tmp = load_cpu_field(teehbr);
store_reg(s, rt, tmp);
return 0;
}
}
return 1;
}
static int disas_cp14_write(CPUState * env, DisasContext *s, uint32_t insn)
{
int crn = (insn >> 16) & 0xf;
int crm = insn & 0xf;
int op1 = (insn >> 21) & 7;
int op2 = (insn >> 5) & 7;
int rt = (insn >> 12) & 0xf;
TCGv tmp;
if (arm_feature(env, ARM_FEATURE_THUMB2EE)) {
if (op1 == 6 && crn == 0 && crm == 0 && op2 == 0) {
/* TEECR */
if (IS_USER(s))
return 1;
tmp = load_reg(s, rt);
gen_helper_set_teecr(cpu_env, tmp);
tcg_temp_free_i32(tmp);
return 0;
}
if (op1 == 6 && crn == 1 && crm == 0 && op2 == 0) {
/* TEEHBR */
if (IS_USER(s) && (env->teecr & 1))
return 1;
tmp = load_reg(s, rt);
store_cpu_field(tmp, teehbr);
return 0;
}
}
return 1;
}
static int disas_coproc_insn(CPUState * env, DisasContext *s, uint32_t insn)
{
int cpnum;
cpnum = (insn >> 8) & 0xf;
if (arm_feature(env, ARM_FEATURE_XSCALE)
&& ((env->cp15.c15_cpar ^ 0x3fff) & (1 << cpnum)))
return 1;
switch (cpnum) {
case 0:
case 1:
if (arm_feature(env, ARM_FEATURE_IWMMXT)) {
return disas_iwmmxt_insn(env, s, insn);
} else if (arm_feature(env, ARM_FEATURE_XSCALE)) {
return disas_dsp_insn(env, s, insn);
}
return 1;
case 10:
case 11:
return disas_vfp_insn (env, s, insn);
case 14:
/* Coprocessors 7-15 are architecturally reserved by ARM.
Unfortunately Intel decided to ignore this. */
if (arm_feature(env, ARM_FEATURE_XSCALE))
goto board;
if (insn & (1 << 20))
return disas_cp14_read(env, s, insn);
else
return disas_cp14_write(env, s, insn);
case 15:
return disas_cp15_insn (env, s, insn);
default:
board:
/* Unknown coprocessor. See if the board has hooked it. */
return disas_cp_insn (env, s, insn);
}
}
/* Store a 64-bit value to a register pair. Clobbers val. */
static void gen_storeq_reg(DisasContext *s, int rlow, int rhigh, TCGv_i64 val)
{
TCGv tmp;
tmp = tcg_temp_new_i32();
tcg_gen_trunc_i64_i32(tmp, val);
store_reg(s, rlow, tmp);
tmp = tcg_temp_new_i32();
tcg_gen_shri_i64(val, val, 32);
tcg_gen_trunc_i64_i32(tmp, val);
store_reg(s, rhigh, tmp);
}
/* load a 32-bit value from a register and perform a 64-bit accumulate. */
static void gen_addq_lo(DisasContext *s, TCGv_i64 val, int rlow)
{
TCGv_i64 tmp;
TCGv tmp2;
/* Load value and extend to 64 bits. */
tmp = tcg_temp_new_i64();
tmp2 = load_reg(s, rlow);
tcg_gen_extu_i32_i64(tmp, tmp2);
tcg_temp_free_i32(tmp2);
tcg_gen_add_i64(val, val, tmp);
tcg_temp_free_i64(tmp);
}
/* load and add a 64-bit value from a register pair. */
static void gen_addq(DisasContext *s, TCGv_i64 val, int rlow, int rhigh)
{
TCGv_i64 tmp;
TCGv tmpl;
TCGv tmph;
/* Load 64-bit value rd:rn. */
tmpl = load_reg(s, rlow);
tmph = load_reg(s, rhigh);
tmp = tcg_temp_new_i64();
tcg_gen_concat_i32_i64(tmp, tmpl, tmph);
tcg_temp_free_i32(tmpl);
tcg_temp_free_i32(tmph);
tcg_gen_add_i64(val, val, tmp);
tcg_temp_free_i64(tmp);
}
/* Set N and Z flags from a 64-bit value. */
static void gen_logicq_cc(TCGv_i64 val)
{
TCGv tmp = tcg_temp_new_i32();
gen_helper_logicq_cc(tmp, val);
gen_logic_CC(tmp);
tcg_temp_free_i32(tmp);
}
/* Load/Store exclusive instructions are implemented by remembering
the value/address loaded, and seeing if these are the same
when the store is performed. This should be is sufficient to implement
the architecturally mandated semantics, and avoids having to monitor
regular stores.
In system emulation mode only one CPU will be running at once, so
this sequence is effectively atomic. In user emulation mode we
throw an exception and handle the atomic operation elsewhere. */
static void gen_load_exclusive(DisasContext *s, int rt, int rt2,
TCGv addr, int size)
{
TCGv tmp;
switch (size) {
case 0:
tmp = gen_ld8u(addr, IS_USER(s));
break;
case 1:
tmp = gen_ld16u(addr, IS_USER(s));
break;
case 2:
case 3:
tmp = gen_ld32(addr, IS_USER(s));
break;
default:
abort();
}
tcg_gen_mov_i32(cpu_exclusive_val, tmp);
store_reg(s, rt, tmp);
if (size == 3) {
TCGv tmp2 = tcg_temp_new_i32();
tcg_gen_addi_i32(tmp2, addr, 4);
tmp = gen_ld32(tmp2, IS_USER(s));
tcg_temp_free_i32(tmp2);
tcg_gen_mov_i32(cpu_exclusive_high, tmp);
store_reg(s, rt2, tmp);
}
tcg_gen_mov_i32(cpu_exclusive_addr, addr);
}
static void gen_clrex(DisasContext *s)
{
tcg_gen_movi_i32(cpu_exclusive_addr, -1);
}
#ifdef CONFIG_USER_ONLY
static void gen_store_exclusive(DisasContext *s, int rd, int rt, int rt2,
TCGv addr, int size)
{
tcg_gen_mov_i32(cpu_exclusive_test, addr);
tcg_gen_movi_i32(cpu_exclusive_info,
size | (rd << 4) | (rt << 8) | (rt2 << 12));
gen_exception_insn(s, 4, EXCP_STREX);
}
#else
static void gen_store_exclusive(DisasContext *s, int rd, int rt, int rt2,
TCGv addr, int size)
{
TCGv tmp;
int done_label;
int fail_label;
/* if (env->exclusive_addr == addr && env->exclusive_val == [addr]) {
[addr] = {Rt};
{Rd} = 0;
} else {
{Rd} = 1;
} */
fail_label = gen_new_label();
done_label = gen_new_label();
tcg_gen_brcond_i32(TCG_COND_NE, addr, cpu_exclusive_addr, fail_label);
switch (size) {
case 0:
tmp = gen_ld8u(addr, IS_USER(s));
break;
case 1:
tmp = gen_ld16u(addr, IS_USER(s));
break;
case 2:
case 3:
tmp = gen_ld32(addr, IS_USER(s));
break;
default:
abort();
}
tcg_gen_brcond_i32(TCG_COND_NE, tmp, cpu_exclusive_val, fail_label);
tcg_temp_free_i32(tmp);
if (size == 3) {
TCGv tmp2 = tcg_temp_new_i32();
tcg_gen_addi_i32(tmp2, addr, 4);
tmp = gen_ld32(tmp2, IS_USER(s));
tcg_temp_free_i32(tmp2);
tcg_gen_brcond_i32(TCG_COND_NE, tmp, cpu_exclusive_high, fail_label);
tcg_temp_free_i32(tmp);
}
tmp = load_reg(s, rt);
switch (size) {
case 0:
gen_st8(tmp, addr, IS_USER(s));
break;
case 1:
gen_st16(tmp, addr, IS_USER(s));
break;
case 2:
case 3:
gen_st32(tmp, addr, IS_USER(s));
break;
default:
abort();
}
if (size == 3) {
tcg_gen_addi_i32(addr, addr, 4);
tmp = load_reg(s, rt2);
gen_st32(tmp, addr, IS_USER(s));
}
tcg_gen_movi_i32(cpu_R[rd], 0);
tcg_gen_br(done_label);
gen_set_label(fail_label);
tcg_gen_movi_i32(cpu_R[rd], 1);
gen_set_label(done_label);
tcg_gen_movi_i32(cpu_exclusive_addr, -1);
}
#endif
static void disas_arm_insn(CPUState * env, DisasContext *s)
{
unsigned int cond, insn, val, op1, i, shift, rm, rs, rn, rd, sh;
TCGv tmp;
TCGv tmp2;
TCGv tmp3;
TCGv addr;
TCGv_i64 tmp64;
insn = ldl_code(s->pc);
s->pc += 4;
/* M variants do not implement ARM mode. */
if (IS_M(env))
goto illegal_op;
cond = insn >> 28;
if (cond == 0xf){
/* In ARMv3 and v4 the NV condition is UNPREDICTABLE; we
* choose to UNDEF. In ARMv5 and above the space is used
* for miscellaneous unconditional instructions.
*/
ARCH(5);
/* Unconditional instructions. */
if (((insn >> 25) & 7) == 1) {
/* NEON Data processing. */
if (!arm_feature(env, ARM_FEATURE_NEON))
goto illegal_op;
if (disas_neon_data_insn(env, s, insn))
goto illegal_op;
return;
}
if ((insn & 0x0f100000) == 0x04000000) {
/* NEON load/store. */
if (!arm_feature(env, ARM_FEATURE_NEON))
goto illegal_op;
if (disas_neon_ls_insn(env, s, insn))
goto illegal_op;
return;
}
if (((insn & 0x0f30f000) == 0x0510f000) ||
((insn & 0x0f30f010) == 0x0710f000)) {
if ((insn & (1 << 22)) == 0) {
/* PLDW; v7MP */
if (!arm_feature(env, ARM_FEATURE_V7MP)) {
goto illegal_op;
}
}
/* Otherwise PLD; v5TE+ */
ARCH(5TE);
return;
}
if (((insn & 0x0f70f000) == 0x0450f000) ||
((insn & 0x0f70f010) == 0x0650f000)) {
ARCH(7);
return; /* PLI; V7 */
}
if (((insn & 0x0f700000) == 0x04100000) ||
((insn & 0x0f700010) == 0x06100000)) {
if (!arm_feature(env, ARM_FEATURE_V7MP)) {
goto illegal_op;
}
return; /* v7MP: Unallocated memory hint: must NOP */
}
if ((insn & 0x0ffffdff) == 0x01010000) {
ARCH(6);
/* setend */
if (insn & (1 << 9)) {
/* BE8 mode not implemented. */
goto illegal_op;
}
return;
} else if ((insn & 0x0fffff00) == 0x057ff000) {
switch ((insn >> 4) & 0xf) {
case 1: /* clrex */
ARCH(6K);
gen_clrex(s);
return;
case 4: /* dsb */
case 5: /* dmb */
case 6: /* isb */
ARCH(7);
/* We don't emulate caches so these are a no-op. */
return;
default:
goto illegal_op;
}
} else if ((insn & 0x0e5fffe0) == 0x084d0500) {
/* srs */
int32_t offset;
if (IS_USER(s))
goto illegal_op;
ARCH(6);
op1 = (insn & 0x1f);
addr = tcg_temp_new_i32();
tmp = tcg_const_i32(op1);
gen_helper_get_r13_banked(addr, cpu_env, tmp);
tcg_temp_free_i32(tmp);
i = (insn >> 23) & 3;
switch (i) {
case 0: offset = -4; break; /* DA */
case 1: offset = 0; break; /* IA */
case 2: offset = -8; break; /* DB */
case 3: offset = 4; break; /* IB */
default: abort();
}
if (offset)
tcg_gen_addi_i32(addr, addr, offset);
tmp = load_reg(s, 14);
gen_st32(tmp, addr, 0);
tmp = load_cpu_field(spsr);
tcg_gen_addi_i32(addr, addr, 4);
gen_st32(tmp, addr, 0);
if (insn & (1 << 21)) {
/* Base writeback. */
switch (i) {
case 0: offset = -8; break;
case 1: offset = 4; break;
case 2: offset = -4; break;
case 3: offset = 0; break;
default: abort();
}
if (offset)
tcg_gen_addi_i32(addr, addr, offset);
tmp = tcg_const_i32(op1);
gen_helper_set_r13_banked(cpu_env, tmp, addr);
tcg_temp_free_i32(tmp);
tcg_temp_free_i32(addr);
} else {
tcg_temp_free_i32(addr);
}
return;
} else if ((insn & 0x0e50ffe0) == 0x08100a00) {
/* rfe */
int32_t offset;
if (IS_USER(s))
goto illegal_op;
ARCH(6);
rn = (insn >> 16) & 0xf;
addr = load_reg(s, rn);
i = (insn >> 23) & 3;
switch (i) {
case 0: offset = -4; break; /* DA */
case 1: offset = 0; break; /* IA */
case 2: offset = -8; break; /* DB */
case 3: offset = 4; break; /* IB */
default: abort();
}
if (offset)
tcg_gen_addi_i32(addr, addr, offset);
/* Load PC into tmp and CPSR into tmp2. */
tmp = gen_ld32(addr, 0);
tcg_gen_addi_i32(addr, addr, 4);
tmp2 = gen_ld32(addr, 0);
if (insn & (1 << 21)) {
/* Base writeback. */
switch (i) {
case 0: offset = -8; break;
case 1: offset = 4; break;
case 2: offset = -4; break;
case 3: offset = 0; break;
default: abort();
}
if (offset)
tcg_gen_addi_i32(addr, addr, offset);
store_reg(s, rn, addr);
} else {
tcg_temp_free_i32(addr);
}
gen_rfe(s, tmp, tmp2);
return;
} else if ((insn & 0x0e000000) == 0x0a000000) {
/* branch link and change to thumb (blx <offset>) */
int32_t offset;
val = (uint32_t)s->pc;
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, val);
store_reg(s, 14, tmp);
/* Sign-extend the 24-bit offset */
offset = (((int32_t)insn) << 8) >> 8;
/* offset * 4 + bit24 * 2 + (thumb bit) */
val += (offset << 2) | ((insn >> 23) & 2) | 1;
/* pipeline offset */
val += 4;
/* protected by ARCH(5); above, near the start of uncond block */
gen_bx_im(s, val);
return;
} else if ((insn & 0x0e000f00) == 0x0c000100) {
if (arm_feature(env, ARM_FEATURE_IWMMXT)) {
/* iWMMXt register transfer. */
if (env->cp15.c15_cpar & (1 << 1))
if (!disas_iwmmxt_insn(env, s, insn))
return;
}
} else if ((insn & 0x0fe00000) == 0x0c400000) {
/* Coprocessor double register transfer. */
ARCH(5TE);
} else if ((insn & 0x0f000010) == 0x0e000010) {
/* Additional coprocessor register transfer. */
} else if ((insn & 0x0ff10020) == 0x01000000) {
uint32_t mask;
uint32_t val;
/* cps (privileged) */
if (IS_USER(s))
return;
mask = val = 0;
if (insn & (1 << 19)) {
if (insn & (1 << 8))
mask |= CPSR_A;
if (insn & (1 << 7))
mask |= CPSR_I;
if (insn & (1 << 6))
mask |= CPSR_F;
if (insn & (1 << 18))
val |= mask;
}
if (insn & (1 << 17)) {
mask |= CPSR_M;
val |= (insn & 0x1f);
}
if (mask) {
gen_set_psr_im(s, mask, 0, val);
}
return;
}
goto illegal_op;
}
if (cond != 0xe) {
/* if not always execute, we generate a conditional jump to
next instruction */
s->condlabel = gen_new_label();
gen_test_cc(cond ^ 1, s->condlabel);
s->condjmp = 1;
}
if ((insn & 0x0f900000) == 0x03000000) {
if ((insn & (1 << 21)) == 0) {
ARCH(6T2);
rd = (insn >> 12) & 0xf;
val = ((insn >> 4) & 0xf000) | (insn & 0xfff);
if ((insn & (1 << 22)) == 0) {
/* MOVW */
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, val);
} else {
/* MOVT */
tmp = load_reg(s, rd);
tcg_gen_ext16u_i32(tmp, tmp);
tcg_gen_ori_i32(tmp, tmp, val << 16);
}
store_reg(s, rd, tmp);
} else {
if (((insn >> 12) & 0xf) != 0xf)
goto illegal_op;
if (((insn >> 16) & 0xf) == 0) {
gen_nop_hint(s, insn & 0xff);
} else {
/* CPSR = immediate */
val = insn & 0xff;
shift = ((insn >> 8) & 0xf) * 2;
if (shift)
val = (val >> shift) | (val << (32 - shift));
i = ((insn & (1 << 22)) != 0);
if (gen_set_psr_im(s, msr_mask(env, s, (insn >> 16) & 0xf, i), i, val))
goto illegal_op;
}
}
} else if ((insn & 0x0f900000) == 0x01000000
&& (insn & 0x00000090) != 0x00000090) {
/* miscellaneous instructions */
op1 = (insn >> 21) & 3;
sh = (insn >> 4) & 0xf;
rm = insn & 0xf;
switch (sh) {
case 0x0: /* move program status register */
if (op1 & 1) {
/* PSR = reg */
tmp = load_reg(s, rm);
i = ((op1 & 2) != 0);
if (gen_set_psr(s, msr_mask(env, s, (insn >> 16) & 0xf, i), i, tmp))
goto illegal_op;
} else {
/* reg = PSR */
rd = (insn >> 12) & 0xf;
if (op1 & 2) {
if (IS_USER(s))
goto illegal_op;
tmp = load_cpu_field(spsr);
} else {
tmp = tcg_temp_new_i32();
gen_helper_cpsr_read(tmp);
}
store_reg(s, rd, tmp);
}
break;
case 0x1:
if (op1 == 1) {
/* branch/exchange thumb (bx). */
ARCH(4T);
tmp = load_reg(s, rm);
gen_bx(s, tmp);
} else if (op1 == 3) {
/* clz */
ARCH(5);
rd = (insn >> 12) & 0xf;
tmp = load_reg(s, rm);
gen_helper_clz(tmp, tmp);
store_reg(s, rd, tmp);
} else {
goto illegal_op;
}
break;
case 0x2:
if (op1 == 1) {
ARCH(5J); /* bxj */
/* Trivial implementation equivalent to bx. */
tmp = load_reg(s, rm);
gen_bx(s, tmp);
} else {
goto illegal_op;
}
break;
case 0x3:
if (op1 != 1)
goto illegal_op;
ARCH(5);
/* branch link/exchange thumb (blx) */
tmp = load_reg(s, rm);
tmp2 = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp2, s->pc);
store_reg(s, 14, tmp2);
gen_bx(s, tmp);
break;
case 0x5: /* saturating add/subtract */
ARCH(5TE);
rd = (insn >> 12) & 0xf;
rn = (insn >> 16) & 0xf;
tmp = load_reg(s, rm);
tmp2 = load_reg(s, rn);
if (op1 & 2)
gen_helper_double_saturate(tmp2, tmp2);
if (op1 & 1)
gen_helper_sub_saturate(tmp, tmp, tmp2);
else
gen_helper_add_saturate(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
break;
case 7:
/* SMC instruction (op1 == 3)
and undefined instructions (op1 == 0 || op1 == 2)
will trap */
if (op1 != 1) {
goto illegal_op;
}
/* bkpt */
ARCH(5);
gen_exception_insn(s, 4, EXCP_BKPT);
break;
case 0x8: /* signed multiply */
case 0xa:
case 0xc:
case 0xe:
ARCH(5TE);
rs = (insn >> 8) & 0xf;
rn = (insn >> 12) & 0xf;
rd = (insn >> 16) & 0xf;
if (op1 == 1) {
/* (32 * 16) >> 16 */
tmp = load_reg(s, rm);
tmp2 = load_reg(s, rs);
if (sh & 4)
tcg_gen_sari_i32(tmp2, tmp2, 16);
else
gen_sxth(tmp2);
tmp64 = gen_muls_i64_i32(tmp, tmp2);
tcg_gen_shri_i64(tmp64, tmp64, 16);
tmp = tcg_temp_new_i32();
tcg_gen_trunc_i64_i32(tmp, tmp64);
tcg_temp_free_i64(tmp64);
if ((sh & 2) == 0) {
tmp2 = load_reg(s, rn);
gen_helper_add_setq(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
}
store_reg(s, rd, tmp);
} else {
/* 16 * 16 */
tmp = load_reg(s, rm);
tmp2 = load_reg(s, rs);
gen_mulxy(tmp, tmp2, sh & 2, sh & 4);
tcg_temp_free_i32(tmp2);
if (op1 == 2) {
tmp64 = tcg_temp_new_i64();
tcg_gen_ext_i32_i64(tmp64, tmp);
tcg_temp_free_i32(tmp);
gen_addq(s, tmp64, rn, rd);
gen_storeq_reg(s, rn, rd, tmp64);
tcg_temp_free_i64(tmp64);
} else {
if (op1 == 0) {
tmp2 = load_reg(s, rn);
gen_helper_add_setq(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
}
store_reg(s, rd, tmp);
}
}
break;
default:
goto illegal_op;
}
} else if (((insn & 0x0e000000) == 0 &&
(insn & 0x00000090) != 0x90) ||
((insn & 0x0e000000) == (1 << 25))) {
int set_cc, logic_cc, shiftop;
op1 = (insn >> 21) & 0xf;
set_cc = (insn >> 20) & 1;
logic_cc = table_logic_cc[op1] & set_cc;
/* data processing instruction */
if (insn & (1 << 25)) {
/* immediate operand */
val = insn & 0xff;
shift = ((insn >> 8) & 0xf) * 2;
if (shift) {
val = (val >> shift) | (val << (32 - shift));
}
tmp2 = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp2, val);
if (logic_cc && shift) {
gen_set_CF_bit31(tmp2);
}
} else {
/* register */
rm = (insn) & 0xf;
tmp2 = load_reg(s, rm);
shiftop = (insn >> 5) & 3;
if (!(insn & (1 << 4))) {
shift = (insn >> 7) & 0x1f;
gen_arm_shift_im(tmp2, shiftop, shift, logic_cc);
} else {
rs = (insn >> 8) & 0xf;
tmp = load_reg(s, rs);
gen_arm_shift_reg(tmp2, shiftop, tmp, logic_cc);
}
}
if (op1 != 0x0f && op1 != 0x0d) {
rn = (insn >> 16) & 0xf;
tmp = load_reg(s, rn);
} else {
TCGV_UNUSED(tmp);
}
rd = (insn >> 12) & 0xf;
switch(op1) {
case 0x00:
tcg_gen_and_i32(tmp, tmp, tmp2);
if (logic_cc) {
gen_logic_CC(tmp);
}
store_reg_bx(env, s, rd, tmp);
break;
case 0x01:
tcg_gen_xor_i32(tmp, tmp, tmp2);
if (logic_cc) {
gen_logic_CC(tmp);
}
store_reg_bx(env, s, rd, tmp);
break;
case 0x02:
if (set_cc && rd == 15) {
/* SUBS r15, ... is used for exception return. */
if (IS_USER(s)) {
goto illegal_op;
}
gen_helper_sub_cc(tmp, tmp, tmp2);
gen_exception_return(s, tmp);
} else {
if (set_cc) {
gen_helper_sub_cc(tmp, tmp, tmp2);
} else {
tcg_gen_sub_i32(tmp, tmp, tmp2);
}
store_reg_bx(env, s, rd, tmp);
}
break;
case 0x03:
if (set_cc) {
gen_helper_sub_cc(tmp, tmp2, tmp);
} else {
tcg_gen_sub_i32(tmp, tmp2, tmp);
}
store_reg_bx(env, s, rd, tmp);
break;
case 0x04:
if (set_cc) {
gen_helper_add_cc(tmp, tmp, tmp2);
} else {
tcg_gen_add_i32(tmp, tmp, tmp2);
}
store_reg_bx(env, s, rd, tmp);
break;
case 0x05:
if (set_cc) {
gen_helper_adc_cc(tmp, tmp, tmp2);
} else {
gen_add_carry(tmp, tmp, tmp2);
}
store_reg_bx(env, s, rd, tmp);
break;
case 0x06:
if (set_cc) {
gen_helper_sbc_cc(tmp, tmp, tmp2);
} else {
gen_sub_carry(tmp, tmp, tmp2);
}
store_reg_bx(env, s, rd, tmp);
break;
case 0x07:
if (set_cc) {
gen_helper_sbc_cc(tmp, tmp2, tmp);
} else {
gen_sub_carry(tmp, tmp2, tmp);
}
store_reg_bx(env, s, rd, tmp);
break;
case 0x08:
if (set_cc) {
tcg_gen_and_i32(tmp, tmp, tmp2);
gen_logic_CC(tmp);
}
tcg_temp_free_i32(tmp);
break;
case 0x09:
if (set_cc) {
tcg_gen_xor_i32(tmp, tmp, tmp2);
gen_logic_CC(tmp);
}
tcg_temp_free_i32(tmp);
break;
case 0x0a:
if (set_cc) {
gen_helper_sub_cc(tmp, tmp, tmp2);
}
tcg_temp_free_i32(tmp);
break;
case 0x0b:
if (set_cc) {
gen_helper_add_cc(tmp, tmp, tmp2);
}
tcg_temp_free_i32(tmp);
break;
case 0x0c:
tcg_gen_or_i32(tmp, tmp, tmp2);
if (logic_cc) {
gen_logic_CC(tmp);
}
store_reg_bx(env, s, rd, tmp);
break;
case 0x0d:
if (logic_cc && rd == 15) {
/* MOVS r15, ... is used for exception return. */
if (IS_USER(s)) {
goto illegal_op;
}
gen_exception_return(s, tmp2);
} else {
if (logic_cc) {
gen_logic_CC(tmp2);
}
store_reg_bx(env, s, rd, tmp2);
}
break;
case 0x0e:
tcg_gen_andc_i32(tmp, tmp, tmp2);
if (logic_cc) {
gen_logic_CC(tmp);
}
store_reg_bx(env, s, rd, tmp);
break;
default:
case 0x0f:
tcg_gen_not_i32(tmp2, tmp2);
if (logic_cc) {
gen_logic_CC(tmp2);
}
store_reg_bx(env, s, rd, tmp2);
break;
}
if (op1 != 0x0f && op1 != 0x0d) {
tcg_temp_free_i32(tmp2);
}
} else {
/* other instructions */
op1 = (insn >> 24) & 0xf;
switch(op1) {
case 0x0:
case 0x1:
/* multiplies, extra load/stores */
sh = (insn >> 5) & 3;
if (sh == 0) {
if (op1 == 0x0) {
rd = (insn >> 16) & 0xf;
rn = (insn >> 12) & 0xf;
rs = (insn >> 8) & 0xf;
rm = (insn) & 0xf;
op1 = (insn >> 20) & 0xf;
switch (op1) {
case 0: case 1: case 2: case 3: case 6:
/* 32 bit mul */
tmp = load_reg(s, rs);
tmp2 = load_reg(s, rm);
tcg_gen_mul_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
if (insn & (1 << 22)) {
/* Subtract (mls) */
ARCH(6T2);
tmp2 = load_reg(s, rn);
tcg_gen_sub_i32(tmp, tmp2, tmp);
tcg_temp_free_i32(tmp2);
} else if (insn & (1 << 21)) {
/* Add */
tmp2 = load_reg(s, rn);
tcg_gen_add_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
}
if (insn & (1 << 20))
gen_logic_CC(tmp);
store_reg(s, rd, tmp);
break;
case 4:
/* 64 bit mul double accumulate (UMAAL) */
ARCH(6);
tmp = load_reg(s, rs);
tmp2 = load_reg(s, rm);
tmp64 = gen_mulu_i64_i32(tmp, tmp2);
gen_addq_lo(s, tmp64, rn);
gen_addq_lo(s, tmp64, rd);
gen_storeq_reg(s, rn, rd, tmp64);
tcg_temp_free_i64(tmp64);
break;
case 8: case 9: case 10: case 11:
case 12: case 13: case 14: case 15:
/* 64 bit mul: UMULL, UMLAL, SMULL, SMLAL. */
tmp = load_reg(s, rs);
tmp2 = load_reg(s, rm);
if (insn & (1 << 22)) {
tmp64 = gen_muls_i64_i32(tmp, tmp2);
} else {
tmp64 = gen_mulu_i64_i32(tmp, tmp2);
}
if (insn & (1 << 21)) { /* mult accumulate */
gen_addq(s, tmp64, rn, rd);
}
if (insn & (1 << 20)) {
gen_logicq_cc(tmp64);
}
gen_storeq_reg(s, rn, rd, tmp64);
tcg_temp_free_i64(tmp64);
break;
default:
goto illegal_op;
}
} else {
rn = (insn >> 16) & 0xf;
rd = (insn >> 12) & 0xf;
if (insn & (1 << 23)) {
/* load/store exclusive */
op1 = (insn >> 21) & 0x3;
if (op1)
ARCH(6K);
else
ARCH(6);
addr = tcg_temp_local_new_i32();
load_reg_var(s, addr, rn);
if (insn & (1 << 20)) {
switch (op1) {
case 0: /* ldrex */
gen_load_exclusive(s, rd, 15, addr, 2);
break;
case 1: /* ldrexd */
gen_load_exclusive(s, rd, rd + 1, addr, 3);
break;
case 2: /* ldrexb */
gen_load_exclusive(s, rd, 15, addr, 0);
break;
case 3: /* ldrexh */
gen_load_exclusive(s, rd, 15, addr, 1);
break;
default:
abort();
}
} else {
rm = insn & 0xf;
switch (op1) {
case 0: /* strex */
gen_store_exclusive(s, rd, rm, 15, addr, 2);
break;
case 1: /* strexd */
gen_store_exclusive(s, rd, rm, rm + 1, addr, 3);
break;
case 2: /* strexb */
gen_store_exclusive(s, rd, rm, 15, addr, 0);
break;
case 3: /* strexh */
gen_store_exclusive(s, rd, rm, 15, addr, 1);
break;
default:
abort();
}
}
tcg_temp_free(addr);
} else {
/* SWP instruction */
rm = (insn) & 0xf;
/* ??? This is not really atomic. However we know
we never have multiple CPUs running in parallel,
so it is good enough. */
addr = load_reg(s, rn);
tmp = load_reg(s, rm);
if (insn & (1 << 22)) {
tmp2 = gen_ld8u(addr, IS_USER(s));
gen_st8(tmp, addr, IS_USER(s));
} else {
tmp2 = gen_ld32(addr, IS_USER(s));
gen_st32(tmp, addr, IS_USER(s));
}
tcg_temp_free_i32(addr);
store_reg(s, rd, tmp2);
}
}
} else {
int address_offset;
int load;
/* Misc load/store */
rn = (insn >> 16) & 0xf;
rd = (insn >> 12) & 0xf;
addr = load_reg(s, rn);
if (insn & (1 << 24))
gen_add_datah_offset(s, insn, 0, addr);
address_offset = 0;
if (insn & (1 << 20)) {
/* load */
switch(sh) {
case 1:
tmp = gen_ld16u(addr, IS_USER(s));
break;
case 2:
tmp = gen_ld8s(addr, IS_USER(s));
break;
default:
case 3:
tmp = gen_ld16s(addr, IS_USER(s));
break;
}
load = 1;
} else if (sh & 2) {
ARCH(5TE);
/* doubleword */
if (sh & 1) {
/* store */
tmp = load_reg(s, rd);
gen_st32(tmp, addr, IS_USER(s));
tcg_gen_addi_i32(addr, addr, 4);
tmp = load_reg(s, rd + 1);
gen_st32(tmp, addr, IS_USER(s));
load = 0;
} else {
/* load */
tmp = gen_ld32(addr, IS_USER(s));
store_reg(s, rd, tmp);
tcg_gen_addi_i32(addr, addr, 4);
tmp = gen_ld32(addr, IS_USER(s));
rd++;
load = 1;
}
address_offset = -4;
} else {
/* store */
tmp = load_reg(s, rd);
gen_st16(tmp, addr, IS_USER(s));
load = 0;
}
/* Perform base writeback before the loaded value to
ensure correct behavior with overlapping index registers.
ldrd with base writeback is is undefined if the
destination and index registers overlap. */
if (!(insn & (1 << 24))) {
gen_add_datah_offset(s, insn, address_offset, addr);
store_reg(s, rn, addr);
} else if (insn & (1 << 21)) {
if (address_offset)
tcg_gen_addi_i32(addr, addr, address_offset);
store_reg(s, rn, addr);
} else {
tcg_temp_free_i32(addr);
}
if (load) {
/* Complete the load. */
store_reg(s, rd, tmp);
}
}
break;
case 0x4:
case 0x5:
goto do_ldst;
case 0x6:
case 0x7:
if (insn & (1 << 4)) {
ARCH(6);
/* Armv6 Media instructions. */
rm = insn & 0xf;
rn = (insn >> 16) & 0xf;
rd = (insn >> 12) & 0xf;
rs = (insn >> 8) & 0xf;
switch ((insn >> 23) & 3) {
case 0: /* Parallel add/subtract. */
op1 = (insn >> 20) & 7;
tmp = load_reg(s, rn);
tmp2 = load_reg(s, rm);
sh = (insn >> 5) & 7;
if ((op1 & 3) == 0 || sh == 5 || sh == 6)
goto illegal_op;
gen_arm_parallel_addsub(op1, sh, tmp, tmp2);
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
break;
case 1:
if ((insn & 0x00700020) == 0) {
/* Halfword pack. */
tmp = load_reg(s, rn);
tmp2 = load_reg(s, rm);
shift = (insn >> 7) & 0x1f;
if (insn & (1 << 6)) {
/* pkhtb */
if (shift == 0)
shift = 31;
tcg_gen_sari_i32(tmp2, tmp2, shift);
tcg_gen_andi_i32(tmp, tmp, 0xffff0000);
tcg_gen_ext16u_i32(tmp2, tmp2);
} else {
/* pkhbt */
if (shift)
tcg_gen_shli_i32(tmp2, tmp2, shift);
tcg_gen_ext16u_i32(tmp, tmp);
tcg_gen_andi_i32(tmp2, tmp2, 0xffff0000);
}
tcg_gen_or_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
} else if ((insn & 0x00200020) == 0x00200000) {
/* [us]sat */
tmp = load_reg(s, rm);
shift = (insn >> 7) & 0x1f;
if (insn & (1 << 6)) {
if (shift == 0)
shift = 31;
tcg_gen_sari_i32(tmp, tmp, shift);
} else {
tcg_gen_shli_i32(tmp, tmp, shift);
}
sh = (insn >> 16) & 0x1f;
tmp2 = tcg_const_i32(sh);
if (insn & (1 << 22))
gen_helper_usat(tmp, tmp, tmp2);
else
gen_helper_ssat(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
} else if ((insn & 0x00300fe0) == 0x00200f20) {
/* [us]sat16 */
tmp = load_reg(s, rm);
sh = (insn >> 16) & 0x1f;
tmp2 = tcg_const_i32(sh);
if (insn & (1 << 22))
gen_helper_usat16(tmp, tmp, tmp2);
else
gen_helper_ssat16(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
} else if ((insn & 0x00700fe0) == 0x00000fa0) {
/* Select bytes. */
tmp = load_reg(s, rn);
tmp2 = load_reg(s, rm);
tmp3 = tcg_temp_new_i32();
tcg_gen_ld_i32(tmp3, cpu_env, offsetof(CPUState, GE));
gen_helper_sel_flags(tmp, tmp3, tmp, tmp2);
tcg_temp_free_i32(tmp3);
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
} else if ((insn & 0x000003e0) == 0x00000060) {
tmp = load_reg(s, rm);
shift = (insn >> 10) & 3;
/* ??? In many cases it's not necessary to do a
rotate, a shift is sufficient. */
if (shift != 0)
tcg_gen_rotri_i32(tmp, tmp, shift * 8);
op1 = (insn >> 20) & 7;
switch (op1) {
case 0: gen_sxtb16(tmp); break;
case 2: gen_sxtb(tmp); break;
case 3: gen_sxth(tmp); break;
case 4: gen_uxtb16(tmp); break;
case 6: gen_uxtb(tmp); break;
case 7: gen_uxth(tmp); break;
default: goto illegal_op;
}
if (rn != 15) {
tmp2 = load_reg(s, rn);
if ((op1 & 3) == 0) {
gen_add16(tmp, tmp2);
} else {
tcg_gen_add_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
}
}
store_reg(s, rd, tmp);
} else if ((insn & 0x003f0f60) == 0x003f0f20) {
/* rev */
tmp = load_reg(s, rm);
if (insn & (1 << 22)) {
if (insn & (1 << 7)) {
gen_revsh(tmp);
} else {
ARCH(6T2);
gen_helper_rbit(tmp, tmp);
}
} else {
if (insn & (1 << 7))
gen_rev16(tmp);
else
tcg_gen_bswap32_i32(tmp, tmp);
}
store_reg(s, rd, tmp);
} else {
goto illegal_op;
}
break;
case 2: /* Multiplies (Type 3). */
tmp = load_reg(s, rm);
tmp2 = load_reg(s, rs);
if (insn & (1 << 20)) {
/* Signed multiply most significant [accumulate].
(SMMUL, SMMLA, SMMLS) */
tmp64 = gen_muls_i64_i32(tmp, tmp2);
if (rd != 15) {
tmp = load_reg(s, rd);
if (insn & (1 << 6)) {
tmp64 = gen_subq_msw(tmp64, tmp);
} else {
tmp64 = gen_addq_msw(tmp64, tmp);
}
}
if (insn & (1 << 5)) {
tcg_gen_addi_i64(tmp64, tmp64, 0x80000000u);
}
tcg_gen_shri_i64(tmp64, tmp64, 32);
tmp = tcg_temp_new_i32();
tcg_gen_trunc_i64_i32(tmp, tmp64);
tcg_temp_free_i64(tmp64);
store_reg(s, rn, tmp);
} else {
if (insn & (1 << 5))
gen_swap_half(tmp2);
gen_smul_dual(tmp, tmp2);
if (insn & (1 << 6)) {
/* This subtraction cannot overflow. */
tcg_gen_sub_i32(tmp, tmp, tmp2);
} else {
/* This addition cannot overflow 32 bits;
* however it may overflow considered as a signed
* operation, in which case we must set the Q flag.
*/
gen_helper_add_setq(tmp, tmp, tmp2);
}
tcg_temp_free_i32(tmp2);
if (insn & (1 << 22)) {
/* smlald, smlsld */
tmp64 = tcg_temp_new_i64();
tcg_gen_ext_i32_i64(tmp64, tmp);
tcg_temp_free_i32(tmp);
gen_addq(s, tmp64, rd, rn);
gen_storeq_reg(s, rd, rn, tmp64);
tcg_temp_free_i64(tmp64);
} else {
/* smuad, smusd, smlad, smlsd */
if (rd != 15)
{
tmp2 = load_reg(s, rd);
gen_helper_add_setq(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
}
store_reg(s, rn, tmp);
}
}
break;
case 3:
op1 = ((insn >> 17) & 0x38) | ((insn >> 5) & 7);
switch (op1) {
case 0: /* Unsigned sum of absolute differences. */
ARCH(6);
tmp = load_reg(s, rm);
tmp2 = load_reg(s, rs);
gen_helper_usad8(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
if (rd != 15) {
tmp2 = load_reg(s, rd);
tcg_gen_add_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
}
store_reg(s, rn, tmp);
break;
case 0x20: case 0x24: case 0x28: case 0x2c:
/* Bitfield insert/clear. */
ARCH(6T2);
shift = (insn >> 7) & 0x1f;
i = (insn >> 16) & 0x1f;
i = i + 1 - shift;
if (rm == 15) {
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, 0);
} else {
tmp = load_reg(s, rm);
}
if (i != 32) {
tmp2 = load_reg(s, rd);
gen_bfi(tmp, tmp2, tmp, shift, (1u << i) - 1);
tcg_temp_free_i32(tmp2);
}
store_reg(s, rd, tmp);
break;
case 0x12: case 0x16: case 0x1a: case 0x1e: /* sbfx */
case 0x32: case 0x36: case 0x3a: case 0x3e: /* ubfx */
ARCH(6T2);
tmp = load_reg(s, rm);
shift = (insn >> 7) & 0x1f;
i = ((insn >> 16) & 0x1f) + 1;
if (shift + i > 32)
goto illegal_op;
if (i < 32) {
if (op1 & 0x20) {
gen_ubfx(tmp, shift, (1u << i) - 1);
} else {
gen_sbfx(tmp, shift, i);
}
}
store_reg(s, rd, tmp);
break;
default:
goto illegal_op;
}
break;
}
break;
}
do_ldst:
/* Check for undefined extension instructions
* per the ARM Bible IE:
* xxxx 0111 1111 xxxx xxxx xxxx 1111 xxxx
*/
sh = (0xf << 20) | (0xf << 4);
if (op1 == 0x7 && ((insn & sh) == sh))
{
goto illegal_op;
}
/* load/store byte/word */
rn = (insn >> 16) & 0xf;
rd = (insn >> 12) & 0xf;
tmp2 = load_reg(s, rn);
i = (IS_USER(s) || (insn & 0x01200000) == 0x00200000);
if (insn & (1 << 24))
gen_add_data_offset(s, insn, tmp2);
if (insn & (1 << 20)) {
/* load */
if (insn & (1 << 22)) {
tmp = gen_ld8u(tmp2, i);
} else {
tmp = gen_ld32(tmp2, i);
}
} else {
/* store */
tmp = load_reg(s, rd);
if (insn & (1 << 22))
gen_st8(tmp, tmp2, i);
else
gen_st32(tmp, tmp2, i);
}
if (!(insn & (1 << 24))) {
gen_add_data_offset(s, insn, tmp2);
store_reg(s, rn, tmp2);
} else if (insn & (1 << 21)) {
store_reg(s, rn, tmp2);
} else {
tcg_temp_free_i32(tmp2);
}
if (insn & (1 << 20)) {
/* Complete the load. */
store_reg_from_load(env, s, rd, tmp);
}
break;
case 0x08:
case 0x09:
{
int j, n, user, loaded_base;
TCGv loaded_var;
/* load/store multiple words */
/* XXX: store correct base if write back */
user = 0;
if (insn & (1 << 22)) {
if (IS_USER(s))
goto illegal_op; /* only usable in supervisor mode */
if ((insn & (1 << 15)) == 0)
user = 1;
}
rn = (insn >> 16) & 0xf;
addr = load_reg(s, rn);
/* compute total size */
loaded_base = 0;
TCGV_UNUSED(loaded_var);
n = 0;
for(i=0;i<16;i++) {
if (insn & (1 << i))
n++;
}
/* XXX: test invalid n == 0 case ? */
if (insn & (1 << 23)) {
if (insn & (1 << 24)) {
/* pre increment */
tcg_gen_addi_i32(addr, addr, 4);
} else {
/* post increment */
}
} else {
if (insn & (1 << 24)) {
/* pre decrement */
tcg_gen_addi_i32(addr, addr, -(n * 4));
} else {
/* post decrement */
if (n != 1)
tcg_gen_addi_i32(addr, addr, -((n - 1) * 4));
}
}
j = 0;
for(i=0;i<16;i++) {
if (insn & (1 << i)) {
if (insn & (1 << 20)) {
/* load */
tmp = gen_ld32(addr, IS_USER(s));
if (user) {
tmp2 = tcg_const_i32(i);
gen_helper_set_user_reg(tmp2, tmp);
tcg_temp_free_i32(tmp2);
tcg_temp_free_i32(tmp);
} else if (i == rn) {
loaded_var = tmp;
loaded_base = 1;
} else {
store_reg_from_load(env, s, i, tmp);
}
} else {
/* store */
if (i == 15) {
/* special case: r15 = PC + 8 */
val = (long)s->pc + 4;
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, val);
} else if (user) {
tmp = tcg_temp_new_i32();
tmp2 = tcg_const_i32(i);
gen_helper_get_user_reg(tmp, tmp2);
tcg_temp_free_i32(tmp2);
} else {
tmp = load_reg(s, i);
}
gen_st32(tmp, addr, IS_USER(s));
}
j++;
/* no need to add after the last transfer */
if (j != n)
tcg_gen_addi_i32(addr, addr, 4);
}
}
if (insn & (1 << 21)) {
/* write back */
if (insn & (1 << 23)) {
if (insn & (1 << 24)) {
/* pre increment */
} else {
/* post increment */
tcg_gen_addi_i32(addr, addr, 4);
}
} else {
if (insn & (1 << 24)) {
/* pre decrement */
if (n != 1)
tcg_gen_addi_i32(addr, addr, -((n - 1) * 4));
} else {
/* post decrement */
tcg_gen_addi_i32(addr, addr, -(n * 4));
}
}
store_reg(s, rn, addr);
} else {
tcg_temp_free_i32(addr);
}
if (loaded_base) {
store_reg(s, rn, loaded_var);
}
if ((insn & (1 << 22)) && !user) {
/* Restore CPSR from SPSR. */
tmp = load_cpu_field(spsr);
gen_set_cpsr(tmp, 0xffffffff);
tcg_temp_free_i32(tmp);
s->is_jmp = DISAS_UPDATE;
}
}
break;
case 0xa:
case 0xb:
{
int32_t offset;
/* branch (and link) */
val = (int32_t)s->pc;
if (insn & (1 << 24)) {
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, val);
store_reg(s, 14, tmp);
}
offset = (((int32_t)insn << 8) >> 8);
val += (offset << 2) + 4;
gen_jmp(s, val);
}
break;
case 0xc:
case 0xd:
case 0xe:
/* Coprocessor. */
if (disas_coproc_insn(env, s, insn))
goto illegal_op;
break;
case 0xf:
/* swi */
gen_set_pc_im(s->pc);
s->is_jmp = DISAS_SWI;
break;
default:
illegal_op:
gen_exception_insn(s, 4, EXCP_UDEF);
break;
}
}
}
/* Return true if this is a Thumb-2 logical op. */
static int
thumb2_logic_op(int op)
{
return (op < 8);
}
/* Generate code for a Thumb-2 data processing operation. If CONDS is nonzero
then set condition code flags based on the result of the operation.
If SHIFTER_OUT is nonzero then set the carry flag for logical operations
to the high bit of T1.
Returns zero if the opcode is valid. */
static int
gen_thumb2_data_op(DisasContext *s, int op, int conds, uint32_t shifter_out, TCGv t0, TCGv t1)
{
int logic_cc;
logic_cc = 0;
switch (op) {
case 0: /* and */
tcg_gen_and_i32(t0, t0, t1);
logic_cc = conds;
break;
case 1: /* bic */
tcg_gen_andc_i32(t0, t0, t1);
logic_cc = conds;
break;
case 2: /* orr */
tcg_gen_or_i32(t0, t0, t1);
logic_cc = conds;
break;
case 3: /* orn */
tcg_gen_orc_i32(t0, t0, t1);
logic_cc = conds;
break;
case 4: /* eor */
tcg_gen_xor_i32(t0, t0, t1);
logic_cc = conds;
break;
case 8: /* add */
if (conds)
gen_helper_add_cc(t0, t0, t1);
else
tcg_gen_add_i32(t0, t0, t1);
break;
case 10: /* adc */
if (conds)
gen_helper_adc_cc(t0, t0, t1);
else
gen_adc(t0, t1);
break;
case 11: /* sbc */
if (conds)
gen_helper_sbc_cc(t0, t0, t1);
else
gen_sub_carry(t0, t0, t1);
break;
case 13: /* sub */
if (conds)
gen_helper_sub_cc(t0, t0, t1);
else
tcg_gen_sub_i32(t0, t0, t1);
break;
case 14: /* rsb */
if (conds)
gen_helper_sub_cc(t0, t1, t0);
else
tcg_gen_sub_i32(t0, t1, t0);
break;
default: /* 5, 6, 7, 9, 12, 15. */
return 1;
}
if (logic_cc) {
gen_logic_CC(t0);
if (shifter_out)
gen_set_CF_bit31(t1);
}
return 0;
}
/* Translate a 32-bit thumb instruction. Returns nonzero if the instruction
is not legal. */
static int disas_thumb2_insn(CPUState *env, DisasContext *s, uint16_t insn_hw1)
{
uint32_t insn, imm, shift, offset;
uint32_t rd, rn, rm, rs;
TCGv tmp;
TCGv tmp2;
TCGv tmp3;
TCGv addr;
TCGv_i64 tmp64;
int op;
int shiftop;
int conds;
int logic_cc;
if (!(arm_feature(env, ARM_FEATURE_THUMB2)
|| arm_feature (env, ARM_FEATURE_M))) {
/* Thumb-1 cores may need to treat bl and blx as a pair of
16-bit instructions to get correct prefetch abort behavior. */
insn = insn_hw1;
if ((insn & (1 << 12)) == 0) {
ARCH(5);
/* Second half of blx. */
offset = ((insn & 0x7ff) << 1);
tmp = load_reg(s, 14);
tcg_gen_addi_i32(tmp, tmp, offset);
tcg_gen_andi_i32(tmp, tmp, 0xfffffffc);
tmp2 = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp2, s->pc | 1);
store_reg(s, 14, tmp2);
gen_bx(s, tmp);
return 0;
}
if (insn & (1 << 11)) {
/* Second half of bl. */
offset = ((insn & 0x7ff) << 1) | 1;
tmp = load_reg(s, 14);
tcg_gen_addi_i32(tmp, tmp, offset);
tmp2 = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp2, s->pc | 1);
store_reg(s, 14, tmp2);
gen_bx(s, tmp);
return 0;
}
if ((s->pc & ~TARGET_PAGE_MASK) == 0) {
/* Instruction spans a page boundary. Implement it as two
16-bit instructions in case the second half causes an
prefetch abort. */
offset = ((int32_t)insn << 21) >> 9;
tcg_gen_movi_i32(cpu_R[14], s->pc + 2 + offset);
return 0;
}
/* Fall through to 32-bit decode. */
}
insn = lduw_code(s->pc);
s->pc += 2;
insn |= (uint32_t)insn_hw1 << 16;
if ((insn & 0xf800e800) != 0xf000e800) {
ARCH(6T2);
}
rn = (insn >> 16) & 0xf;
rs = (insn >> 12) & 0xf;
rd = (insn >> 8) & 0xf;
rm = insn & 0xf;
switch ((insn >> 25) & 0xf) {
case 0: case 1: case 2: case 3:
/* 16-bit instructions. Should never happen. */
abort();
case 4:
if (insn & (1 << 22)) {
/* Other load/store, table branch. */
if (insn & 0x01200000) {
/* Load/store doubleword. */
if (rn == 15) {
addr = tcg_temp_new_i32();
tcg_gen_movi_i32(addr, s->pc & ~3);
} else {
addr = load_reg(s, rn);
}
offset = (insn & 0xff) * 4;
if ((insn & (1 << 23)) == 0)
offset = -offset;
if (insn & (1 << 24)) {
tcg_gen_addi_i32(addr, addr, offset);
offset = 0;
}
if (insn & (1 << 20)) {
/* ldrd */
tmp = gen_ld32(addr, IS_USER(s));
store_reg(s, rs, tmp);
tcg_gen_addi_i32(addr, addr, 4);
tmp = gen_ld32(addr, IS_USER(s));
store_reg(s, rd, tmp);
} else {
/* strd */
tmp = load_reg(s, rs);
gen_st32(tmp, addr, IS_USER(s));
tcg_gen_addi_i32(addr, addr, 4);
tmp = load_reg(s, rd);
gen_st32(tmp, addr, IS_USER(s));
}
if (insn & (1 << 21)) {
/* Base writeback. */
if (rn == 15)
goto illegal_op;
tcg_gen_addi_i32(addr, addr, offset - 4);
store_reg(s, rn, addr);
} else {
tcg_temp_free_i32(addr);
}
} else if ((insn & (1 << 23)) == 0) {
/* Load/store exclusive word. */
addr = tcg_temp_local_new();
load_reg_var(s, addr, rn);
tcg_gen_addi_i32(addr, addr, (insn & 0xff) << 2);
if (insn & (1 << 20)) {
gen_load_exclusive(s, rs, 15, addr, 2);
} else {
gen_store_exclusive(s, rd, rs, 15, addr, 2);
}
tcg_temp_free(addr);
} else if ((insn & (1 << 6)) == 0) {
/* Table Branch. */
if (rn == 15) {
addr = tcg_temp_new_i32();
tcg_gen_movi_i32(addr, s->pc);
} else {
addr = load_reg(s, rn);
}
tmp = load_reg(s, rm);
tcg_gen_add_i32(addr, addr, tmp);
if (insn & (1 << 4)) {
/* tbh */
tcg_gen_add_i32(addr, addr, tmp);
tcg_temp_free_i32(tmp);
tmp = gen_ld16u(addr, IS_USER(s));
} else { /* tbb */
tcg_temp_free_i32(tmp);
tmp = gen_ld8u(addr, IS_USER(s));
}
tcg_temp_free_i32(addr);
tcg_gen_shli_i32(tmp, tmp, 1);
tcg_gen_addi_i32(tmp, tmp, s->pc);
store_reg(s, 15, tmp);
} else {
/* Load/store exclusive byte/halfword/doubleword. */
ARCH(7);
op = (insn >> 4) & 0x3;
if (op == 2) {
goto illegal_op;
}
addr = tcg_temp_local_new();
load_reg_var(s, addr, rn);
if (insn & (1 << 20)) {
gen_load_exclusive(s, rs, rd, addr, op);
} else {
gen_store_exclusive(s, rm, rs, rd, addr, op);
}
tcg_temp_free(addr);
}
} else {
/* Load/store multiple, RFE, SRS. */
if (((insn >> 23) & 1) == ((insn >> 24) & 1)) {
/* Not available in user mode. */
if (IS_USER(s))
goto illegal_op;
if (insn & (1 << 20)) {
/* rfe */
addr = load_reg(s, rn);
if ((insn & (1 << 24)) == 0)
tcg_gen_addi_i32(addr, addr, -8);
/* Load PC into tmp and CPSR into tmp2. */
tmp = gen_ld32(addr, 0);
tcg_gen_addi_i32(addr, addr, 4);
tmp2 = gen_ld32(addr, 0);
if (insn & (1 << 21)) {
/* Base writeback. */
if (insn & (1 << 24)) {
tcg_gen_addi_i32(addr, addr, 4);
} else {
tcg_gen_addi_i32(addr, addr, -4);
}
store_reg(s, rn, addr);
} else {
tcg_temp_free_i32(addr);
}
gen_rfe(s, tmp, tmp2);
} else {
/* srs */
op = (insn & 0x1f);
addr = tcg_temp_new_i32();
tmp = tcg_const_i32(op);
gen_helper_get_r13_banked(addr, cpu_env, tmp);
tcg_temp_free_i32(tmp);
if ((insn & (1 << 24)) == 0) {
tcg_gen_addi_i32(addr, addr, -8);
}
tmp = load_reg(s, 14);
gen_st32(tmp, addr, 0);
tcg_gen_addi_i32(addr, addr, 4);
tmp = tcg_temp_new_i32();
gen_helper_cpsr_read(tmp);
gen_st32(tmp, addr, 0);
if (insn & (1 << 21)) {
if ((insn & (1 << 24)) == 0) {
tcg_gen_addi_i32(addr, addr, -4);
} else {
tcg_gen_addi_i32(addr, addr, 4);
}
tmp = tcg_const_i32(op);
gen_helper_set_r13_banked(cpu_env, tmp, addr);
tcg_temp_free_i32(tmp);
} else {
tcg_temp_free_i32(addr);
}
}
} else {
int i, loaded_base = 0;
TCGv loaded_var;
/* Load/store multiple. */
addr = load_reg(s, rn);
offset = 0;
for (i = 0; i < 16; i++) {
if (insn & (1 << i))
offset += 4;
}
if (insn & (1 << 24)) {
tcg_gen_addi_i32(addr, addr, -offset);
}
TCGV_UNUSED(loaded_var);
for (i = 0; i < 16; i++) {
if ((insn & (1 << i)) == 0)
continue;
if (insn & (1 << 20)) {
/* Load. */
tmp = gen_ld32(addr, IS_USER(s));
if (i == 15) {
gen_bx(s, tmp);
} else if (i == rn) {
loaded_var = tmp;
loaded_base = 1;
} else {
store_reg(s, i, tmp);
}
} else {
/* Store. */
tmp = load_reg(s, i);
gen_st32(tmp, addr, IS_USER(s));
}
tcg_gen_addi_i32(addr, addr, 4);
}
if (loaded_base) {
store_reg(s, rn, loaded_var);
}
if (insn & (1 << 21)) {
/* Base register writeback. */
if (insn & (1 << 24)) {
tcg_gen_addi_i32(addr, addr, -offset);
}
/* Fault if writeback register is in register list. */
if (insn & (1 << rn))
goto illegal_op;
store_reg(s, rn, addr);
} else {
tcg_temp_free_i32(addr);
}
}
}
break;
case 5:
op = (insn >> 21) & 0xf;
if (op == 6) {
/* Halfword pack. */
tmp = load_reg(s, rn);
tmp2 = load_reg(s, rm);
shift = ((insn >> 10) & 0x1c) | ((insn >> 6) & 0x3);
if (insn & (1 << 5)) {
/* pkhtb */
if (shift == 0)
shift = 31;
tcg_gen_sari_i32(tmp2, tmp2, shift);
tcg_gen_andi_i32(tmp, tmp, 0xffff0000);
tcg_gen_ext16u_i32(tmp2, tmp2);
} else {
/* pkhbt */
if (shift)
tcg_gen_shli_i32(tmp2, tmp2, shift);
tcg_gen_ext16u_i32(tmp, tmp);
tcg_gen_andi_i32(tmp2, tmp2, 0xffff0000);
}
tcg_gen_or_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
} else {
/* Data processing register constant shift. */
if (rn == 15) {
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, 0);
} else {
tmp = load_reg(s, rn);
}
tmp2 = load_reg(s, rm);
shiftop = (insn >> 4) & 3;
shift = ((insn >> 6) & 3) | ((insn >> 10) & 0x1c);
conds = (insn & (1 << 20)) != 0;
logic_cc = (conds && thumb2_logic_op(op));
gen_arm_shift_im(tmp2, shiftop, shift, logic_cc);
if (gen_thumb2_data_op(s, op, conds, 0, tmp, tmp2))
goto illegal_op;
tcg_temp_free_i32(tmp2);
if (rd != 15) {
store_reg(s, rd, tmp);
} else {
tcg_temp_free_i32(tmp);
}
}
break;
case 13: /* Misc data processing. */
op = ((insn >> 22) & 6) | ((insn >> 7) & 1);
if (op < 4 && (insn & 0xf000) != 0xf000)
goto illegal_op;
switch (op) {
case 0: /* Register controlled shift. */
tmp = load_reg(s, rn);
tmp2 = load_reg(s, rm);
if ((insn & 0x70) != 0)
goto illegal_op;
op = (insn >> 21) & 3;
logic_cc = (insn & (1 << 20)) != 0;
gen_arm_shift_reg(tmp, op, tmp2, logic_cc);
if (logic_cc)
gen_logic_CC(tmp);
store_reg_bx(env, s, rd, tmp);
break;
case 1: /* Sign/zero extend. */
tmp = load_reg(s, rm);
shift = (insn >> 4) & 3;
/* ??? In many cases it's not necessary to do a
rotate, a shift is sufficient. */
if (shift != 0)
tcg_gen_rotri_i32(tmp, tmp, shift * 8);
op = (insn >> 20) & 7;
switch (op) {
case 0: gen_sxth(tmp); break;
case 1: gen_uxth(tmp); break;
case 2: gen_sxtb16(tmp); break;
case 3: gen_uxtb16(tmp); break;
case 4: gen_sxtb(tmp); break;
case 5: gen_uxtb(tmp); break;
default: goto illegal_op;
}
if (rn != 15) {
tmp2 = load_reg(s, rn);
if ((op >> 1) == 1) {
gen_add16(tmp, tmp2);
} else {
tcg_gen_add_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
}
}
store_reg(s, rd, tmp);
break;
case 2: /* SIMD add/subtract. */
op = (insn >> 20) & 7;
shift = (insn >> 4) & 7;
if ((op & 3) == 3 || (shift & 3) == 3)
goto illegal_op;
tmp = load_reg(s, rn);
tmp2 = load_reg(s, rm);
gen_thumb2_parallel_addsub(op, shift, tmp, tmp2);
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
break;
case 3: /* Other data processing. */
op = ((insn >> 17) & 0x38) | ((insn >> 4) & 7);
if (op < 4) {
/* Saturating add/subtract. */
tmp = load_reg(s, rn);
tmp2 = load_reg(s, rm);
if (op & 1)
gen_helper_double_saturate(tmp, tmp);
if (op & 2)
gen_helper_sub_saturate(tmp, tmp2, tmp);
else
gen_helper_add_saturate(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
} else {
tmp = load_reg(s, rn);
switch (op) {
case 0x0a: /* rbit */
gen_helper_rbit(tmp, tmp);
break;
case 0x08: /* rev */
tcg_gen_bswap32_i32(tmp, tmp);
break;
case 0x09: /* rev16 */
gen_rev16(tmp);
break;
case 0x0b: /* revsh */
gen_revsh(tmp);
break;
case 0x10: /* sel */
tmp2 = load_reg(s, rm);
tmp3 = tcg_temp_new_i32();
tcg_gen_ld_i32(tmp3, cpu_env, offsetof(CPUState, GE));
gen_helper_sel_flags(tmp, tmp3, tmp, tmp2);
tcg_temp_free_i32(tmp3);
tcg_temp_free_i32(tmp2);
break;
case 0x18: /* clz */
gen_helper_clz(tmp, tmp);
break;
default:
goto illegal_op;
}
}
store_reg(s, rd, tmp);
break;
case 4: case 5: /* 32-bit multiply. Sum of absolute differences. */
op = (insn >> 4) & 0xf;
tmp = load_reg(s, rn);
tmp2 = load_reg(s, rm);
switch ((insn >> 20) & 7) {
case 0: /* 32 x 32 -> 32 */
tcg_gen_mul_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
if (rs != 15) {
tmp2 = load_reg(s, rs);
if (op)
tcg_gen_sub_i32(tmp, tmp2, tmp);
else
tcg_gen_add_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
}
break;
case 1: /* 16 x 16 -> 32 */
gen_mulxy(tmp, tmp2, op & 2, op & 1);
tcg_temp_free_i32(tmp2);
if (rs != 15) {
tmp2 = load_reg(s, rs);
gen_helper_add_setq(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
}
break;
case 2: /* Dual multiply add. */
case 4: /* Dual multiply subtract. */
if (op)
gen_swap_half(tmp2);
gen_smul_dual(tmp, tmp2);
if (insn & (1 << 22)) {
/* This subtraction cannot overflow. */
tcg_gen_sub_i32(tmp, tmp, tmp2);
} else {
/* This addition cannot overflow 32 bits;
* however it may overflow considered as a signed
* operation, in which case we must set the Q flag.
*/
gen_helper_add_setq(tmp, tmp, tmp2);
}
tcg_temp_free_i32(tmp2);
if (rs != 15)
{
tmp2 = load_reg(s, rs);
gen_helper_add_setq(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
}
break;
case 3: /* 32 * 16 -> 32msb */
if (op)
tcg_gen_sari_i32(tmp2, tmp2, 16);
else
gen_sxth(tmp2);
tmp64 = gen_muls_i64_i32(tmp, tmp2);
tcg_gen_shri_i64(tmp64, tmp64, 16);
tmp = tcg_temp_new_i32();
tcg_gen_trunc_i64_i32(tmp, tmp64);
tcg_temp_free_i64(tmp64);
if (rs != 15)
{
tmp2 = load_reg(s, rs);
gen_helper_add_setq(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
}
break;
case 5: case 6: /* 32 * 32 -> 32msb (SMMUL, SMMLA, SMMLS) */
tmp64 = gen_muls_i64_i32(tmp, tmp2);
if (rs != 15) {
tmp = load_reg(s, rs);
if (insn & (1 << 20)) {
tmp64 = gen_addq_msw(tmp64, tmp);
} else {
tmp64 = gen_subq_msw(tmp64, tmp);
}
}
if (insn & (1 << 4)) {
tcg_gen_addi_i64(tmp64, tmp64, 0x80000000u);
}
tcg_gen_shri_i64(tmp64, tmp64, 32);
tmp = tcg_temp_new_i32();
tcg_gen_trunc_i64_i32(tmp, tmp64);
tcg_temp_free_i64(tmp64);
break;
case 7: /* Unsigned sum of absolute differences. */
gen_helper_usad8(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
if (rs != 15) {
tmp2 = load_reg(s, rs);
tcg_gen_add_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
}
break;
}
store_reg(s, rd, tmp);
break;
case 6: case 7: /* 64-bit multiply, Divide. */
op = ((insn >> 4) & 0xf) | ((insn >> 16) & 0x70);
tmp = load_reg(s, rn);
tmp2 = load_reg(s, rm);
if ((op & 0x50) == 0x10) {
/* sdiv, udiv */
if (!arm_feature(env, ARM_FEATURE_DIV))
goto illegal_op;
if (op & 0x20)
gen_helper_udiv(tmp, tmp, tmp2);
else
gen_helper_sdiv(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
} else if ((op & 0xe) == 0xc) {
/* Dual multiply accumulate long. */
if (op & 1)
gen_swap_half(tmp2);
gen_smul_dual(tmp, tmp2);
if (op & 0x10) {
tcg_gen_sub_i32(tmp, tmp, tmp2);
} else {
tcg_gen_add_i32(tmp, tmp, tmp2);
}
tcg_temp_free_i32(tmp2);
/* BUGFIX */
tmp64 = tcg_temp_new_i64();
tcg_gen_ext_i32_i64(tmp64, tmp);
tcg_temp_free_i32(tmp);
gen_addq(s, tmp64, rs, rd);
gen_storeq_reg(s, rs, rd, tmp64);
tcg_temp_free_i64(tmp64);
} else {
if (op & 0x20) {
/* Unsigned 64-bit multiply */
tmp64 = gen_mulu_i64_i32(tmp, tmp2);
} else {
if (op & 8) {
/* smlalxy */
gen_mulxy(tmp, tmp2, op & 2, op & 1);
tcg_temp_free_i32(tmp2);
tmp64 = tcg_temp_new_i64();
tcg_gen_ext_i32_i64(tmp64, tmp);
tcg_temp_free_i32(tmp);
} else {
/* Signed 64-bit multiply */
tmp64 = gen_muls_i64_i32(tmp, tmp2);
}
}
if (op & 4) {
/* umaal */
gen_addq_lo(s, tmp64, rs);
gen_addq_lo(s, tmp64, rd);
} else if (op & 0x40) {
/* 64-bit accumulate. */
gen_addq(s, tmp64, rs, rd);
}
gen_storeq_reg(s, rs, rd, tmp64);
tcg_temp_free_i64(tmp64);
}
break;
}
break;
case 6: case 7: case 14: case 15:
/* Coprocessor. */
if (((insn >> 24) & 3) == 3) {
/* Translate into the equivalent ARM encoding. */
insn = (insn & 0xe2ffffff) | ((insn & (1 << 28)) >> 4) | (1 << 28);
if (disas_neon_data_insn(env, s, insn))
goto illegal_op;
} else {
if (insn & (1 << 28))
goto illegal_op;
if (disas_coproc_insn (env, s, insn))
goto illegal_op;
}
break;
case 8: case 9: case 10: case 11:
if (insn & (1 << 15)) {
/* Branches, misc control. */
if (insn & 0x5000) {
/* Unconditional branch. */
/* signextend(hw1[10:0]) -> offset[:12]. */
offset = ((int32_t)insn << 5) >> 9 & ~(int32_t)0xfff;
/* hw1[10:0] -> offset[11:1]. */
offset |= (insn & 0x7ff) << 1;
/* (~hw2[13, 11] ^ offset[24]) -> offset[23,22]
offset[24:22] already have the same value because of the
sign extension above. */
offset ^= ((~insn) & (1 << 13)) << 10;
offset ^= ((~insn) & (1 << 11)) << 11;
if (insn & (1 << 14)) {
/* Branch and link. */
tcg_gen_movi_i32(cpu_R[14], s->pc | 1);
}
offset += s->pc;
if (insn & (1 << 12)) {
/* b/bl */
gen_jmp(s, offset);
} else {
/* blx */
offset &= ~(uint32_t)2;
/* thumb2 bx, no need to check */
gen_bx_im(s, offset);
}
} else if (((insn >> 23) & 7) == 7) {
/* Misc control */
if (insn & (1 << 13))
goto illegal_op;
if (insn & (1 << 26)) {
/* Secure monitor call (v6Z) */
goto illegal_op; /* not implemented. */
} else {
op = (insn >> 20) & 7;
switch (op) {
case 0: /* msr cpsr. */
if (IS_M(env)) {
tmp = load_reg(s, rn);
addr = tcg_const_i32(insn & 0xff);
gen_helper_v7m_msr(cpu_env, addr, tmp);
tcg_temp_free_i32(addr);
tcg_temp_free_i32(tmp);
gen_lookup_tb(s);
break;
}
/* fall through */
case 1: /* msr spsr. */
if (IS_M(env))
goto illegal_op;
tmp = load_reg(s, rn);
if (gen_set_psr(s,
msr_mask(env, s, (insn >> 8) & 0xf, op == 1),
op == 1, tmp))
goto illegal_op;
break;
case 2: /* cps, nop-hint. */
if (((insn >> 8) & 7) == 0) {
gen_nop_hint(s, insn & 0xff);
}
/* Implemented as NOP in user mode. */
if (IS_USER(s))
break;
offset = 0;
imm = 0;
if (insn & (1 << 10)) {
if (insn & (1 << 7))
offset |= CPSR_A;
if (insn & (1 << 6))
offset |= CPSR_I;
if (insn & (1 << 5))
offset |= CPSR_F;
if (insn & (1 << 9))
imm = CPSR_A | CPSR_I | CPSR_F;
}
if (insn & (1 << 8)) {
offset |= 0x1f;
imm |= (insn & 0x1f);
}
if (offset) {
gen_set_psr_im(s, offset, 0, imm);
}
break;
case 3: /* Special control operations. */
ARCH(7);
op = (insn >> 4) & 0xf;
switch (op) {
case 2: /* clrex */
gen_clrex(s);
break;
case 4: /* dsb */
case 5: /* dmb */
case 6: /* isb */
/* These execute as NOPs. */
break;
default:
goto illegal_op;
}
break;
case 4: /* bxj */
/* Trivial implementation equivalent to bx. */
tmp = load_reg(s, rn);
gen_bx(s, tmp);
break;
case 5: /* Exception return. */
if (IS_USER(s)) {
goto illegal_op;
}
if (rn != 14 || rd != 15) {
goto illegal_op;
}
tmp = load_reg(s, rn);
tcg_gen_subi_i32(tmp, tmp, insn & 0xff);
gen_exception_return(s, tmp);
break;
case 6: /* mrs cpsr. */
tmp = tcg_temp_new_i32();
if (IS_M(env)) {
addr = tcg_const_i32(insn & 0xff);
gen_helper_v7m_mrs(tmp, cpu_env, addr);
tcg_temp_free_i32(addr);
} else {
gen_helper_cpsr_read(tmp);
}
store_reg(s, rd, tmp);
break;
case 7: /* mrs spsr. */
/* Not accessible in user mode. */
if (IS_USER(s) || IS_M(env))
goto illegal_op;
tmp = load_cpu_field(spsr);
store_reg(s, rd, tmp);
break;
}
}
} else {
/* Conditional branch. */
op = (insn >> 22) & 0xf;
/* Generate a conditional jump to next instruction. */
s->condlabel = gen_new_label();
gen_test_cc(op ^ 1, s->condlabel);
s->condjmp = 1;
/* offset[11:1] = insn[10:0] */
offset = (insn & 0x7ff) << 1;
/* offset[17:12] = insn[21:16]. */
offset |= (insn & 0x003f0000) >> 4;
/* offset[31:20] = insn[26]. */
offset |= ((int32_t)((insn << 5) & 0x80000000)) >> 11;
/* offset[18] = insn[13]. */
offset |= (insn & (1 << 13)) << 5;
/* offset[19] = insn[11]. */
offset |= (insn & (1 << 11)) << 8;
/* jump to the offset */
gen_jmp(s, s->pc + offset);
}
} else {
/* Data processing immediate. */
if (insn & (1 << 25)) {
if (insn & (1 << 24)) {
if (insn & (1 << 20))
goto illegal_op;
/* Bitfield/Saturate. */
op = (insn >> 21) & 7;
imm = insn & 0x1f;
shift = ((insn >> 6) & 3) | ((insn >> 10) & 0x1c);
if (rn == 15) {
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, 0);
} else {
tmp = load_reg(s, rn);
}
switch (op) {
case 2: /* Signed bitfield extract. */
imm++;
if (shift + imm > 32)
goto illegal_op;
if (imm < 32)
gen_sbfx(tmp, shift, imm);
break;
case 6: /* Unsigned bitfield extract. */
imm++;
if (shift + imm > 32)
goto illegal_op;
if (imm < 32)
gen_ubfx(tmp, shift, (1u << imm) - 1);
break;
case 3: /* Bitfield insert/clear. */
if (imm < shift)
goto illegal_op;
imm = imm + 1 - shift;
if (imm != 32) {
tmp2 = load_reg(s, rd);
gen_bfi(tmp, tmp2, tmp, shift, (1u << imm) - 1);
tcg_temp_free_i32(tmp2);
}
break;
case 7:
goto illegal_op;
default: /* Saturate. */
if (shift) {
if (op & 1)
tcg_gen_sari_i32(tmp, tmp, shift);
else
tcg_gen_shli_i32(tmp, tmp, shift);
}
tmp2 = tcg_const_i32(imm);
if (op & 4) {
/* Unsigned. */
if ((op & 1) && shift == 0)
gen_helper_usat16(tmp, tmp, tmp2);
else
gen_helper_usat(tmp, tmp, tmp2);
} else {
/* Signed. */
if ((op & 1) && shift == 0)
gen_helper_ssat16(tmp, tmp, tmp2);
else
gen_helper_ssat(tmp, tmp, tmp2);
}
tcg_temp_free_i32(tmp2);
break;
}
store_reg(s, rd, tmp);
} else {
imm = ((insn & 0x04000000) >> 15)
| ((insn & 0x7000) >> 4) | (insn & 0xff);
if (insn & (1 << 22)) {
/* 16-bit immediate. */
imm |= (insn >> 4) & 0xf000;
if (insn & (1 << 23)) {
/* movt */
tmp = load_reg(s, rd);
tcg_gen_ext16u_i32(tmp, tmp);
tcg_gen_ori_i32(tmp, tmp, imm << 16);
} else {
/* movw */
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, imm);
}
} else {
/* Add/sub 12-bit immediate. */
if (rn == 15) {
offset = s->pc & ~(uint32_t)3;
if (insn & (1 << 23))
offset -= imm;
else
offset += imm;
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, offset);
} else {
tmp = load_reg(s, rn);
if (insn & (1 << 23))
tcg_gen_subi_i32(tmp, tmp, imm);
else
tcg_gen_addi_i32(tmp, tmp, imm);
}
}
store_reg(s, rd, tmp);
}
} else {
int shifter_out = 0;
/* modified 12-bit immediate. */
shift = ((insn & 0x04000000) >> 23) | ((insn & 0x7000) >> 12);
imm = (insn & 0xff);
switch (shift) {
case 0: /* XY */
/* Nothing to do. */
break;
case 1: /* 00XY00XY */
imm |= imm << 16;
break;
case 2: /* XY00XY00 */
imm |= imm << 16;
imm <<= 8;
break;
case 3: /* XYXYXYXY */
imm |= imm << 16;
imm |= imm << 8;
break;
default: /* Rotated constant. */
shift = (shift << 1) | (imm >> 7);
imm |= 0x80;
imm = imm << (32 - shift);
shifter_out = 1;
break;
}
tmp2 = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp2, imm);
rn = (insn >> 16) & 0xf;
if (rn == 15) {
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, 0);
} else {
tmp = load_reg(s, rn);
}
op = (insn >> 21) & 0xf;
if (gen_thumb2_data_op(s, op, (insn & (1 << 20)) != 0,
shifter_out, tmp, tmp2))
goto illegal_op;
tcg_temp_free_i32(tmp2);
rd = (insn >> 8) & 0xf;
if (rd != 15) {
store_reg(s, rd, tmp);
} else {
tcg_temp_free_i32(tmp);
}
}
}
break;
case 12: /* Load/store single data item. */
{
int postinc = 0;
int writeback = 0;
int user;
if ((insn & 0x01100000) == 0x01000000) {
if (disas_neon_ls_insn(env, s, insn))
goto illegal_op;
break;
}
op = ((insn >> 21) & 3) | ((insn >> 22) & 4);
if (rs == 15) {
if (!(insn & (1 << 20))) {
goto illegal_op;
}
if (op != 2) {
/* Byte or halfword load space with dest == r15 : memory hints.
* Catch them early so we don't emit pointless addressing code.
* This space is a mix of:
* PLD/PLDW/PLI, which we implement as NOPs (note that unlike
* the ARM encodings, PLDW space doesn't UNDEF for non-v7MP
* cores)
* unallocated hints, which must be treated as NOPs
* UNPREDICTABLE space, which we NOP or UNDEF depending on
* which is easiest for the decoding logic
* Some space which must UNDEF
*/
int op1 = (insn >> 23) & 3;
int op2 = (insn >> 6) & 0x3f;
if (op & 2) {
goto illegal_op;
}
if (rn == 15) {
/* UNPREDICTABLE or unallocated hint */
return 0;
}
if (op1 & 1) {
return 0; /* PLD* or unallocated hint */
}
if ((op2 == 0) || ((op2 & 0x3c) == 0x30)) {
return 0; /* PLD* or unallocated hint */
}
/* UNDEF space, or an UNPREDICTABLE */
return 1;
}
}
user = IS_USER(s);
if (rn == 15) {
addr = tcg_temp_new_i32();
/* PC relative. */
/* s->pc has already been incremented by 4. */
imm = s->pc & 0xfffffffc;
if (insn & (1 << 23))
imm += insn & 0xfff;
else
imm -= insn & 0xfff;
tcg_gen_movi_i32(addr, imm);
} else {
addr = load_reg(s, rn);
if (insn & (1 << 23)) {
/* Positive offset. */
imm = insn & 0xfff;
tcg_gen_addi_i32(addr, addr, imm);
} else {
imm = insn & 0xff;
switch ((insn >> 8) & 0xf) {
case 0x0: /* Shifted Register. */
shift = (insn >> 4) & 0xf;
if (shift > 3) {
tcg_temp_free_i32(addr);
goto illegal_op;
}
tmp = load_reg(s, rm);
if (shift)
tcg_gen_shli_i32(tmp, tmp, shift);
tcg_gen_add_i32(addr, addr, tmp);
tcg_temp_free_i32(tmp);
break;
case 0xc: /* Negative offset. */
tcg_gen_addi_i32(addr, addr, -imm);
break;
case 0xe: /* User privilege. */
tcg_gen_addi_i32(addr, addr, imm);
user = 1;
break;
case 0x9: /* Post-decrement. */
imm = -imm;
/* Fall through. */
case 0xb: /* Post-increment. */
postinc = 1;
writeback = 1;
break;
case 0xd: /* Pre-decrement. */
imm = -imm;
/* Fall through. */
case 0xf: /* Pre-increment. */
tcg_gen_addi_i32(addr, addr, imm);
writeback = 1;
break;
default:
tcg_temp_free_i32(addr);
goto illegal_op;
}
}
}
if (insn & (1 << 20)) {
/* Load. */
switch (op) {
case 0: tmp = gen_ld8u(addr, user); break;
case 4: tmp = gen_ld8s(addr, user); break;
case 1: tmp = gen_ld16u(addr, user); break;
case 5: tmp = gen_ld16s(addr, user); break;
case 2: tmp = gen_ld32(addr, user); break;
default:
tcg_temp_free_i32(addr);
goto illegal_op;
}
if (rs == 15) {
gen_bx(s, tmp);
} else {
store_reg(s, rs, tmp);
}
} else {
/* Store. */
tmp = load_reg(s, rs);
switch (op) {
case 0: gen_st8(tmp, addr, user); break;
case 1: gen_st16(tmp, addr, user); break;
case 2: gen_st32(tmp, addr, user); break;
default:
tcg_temp_free_i32(addr);
goto illegal_op;
}
}
if (postinc)
tcg_gen_addi_i32(addr, addr, imm);
if (writeback) {
store_reg(s, rn, addr);
} else {
tcg_temp_free_i32(addr);
}
}
break;
default:
goto illegal_op;
}
return 0;
illegal_op:
return 1;
}
static void disas_thumb_insn(CPUState *env, DisasContext *s)
{
uint32_t val, insn, op, rm, rn, rd, shift, cond;
int32_t offset;
int i;
TCGv tmp;
TCGv tmp2;
TCGv addr;
if (s->condexec_mask) {
cond = s->condexec_cond;
if (cond != 0x0e) { /* Skip conditional when condition is AL. */
s->condlabel = gen_new_label();
gen_test_cc(cond ^ 1, s->condlabel);
s->condjmp = 1;
}
}
insn = lduw_code(s->pc);
s->pc += 2;
switch (insn >> 12) {
case 0: case 1:
rd = insn & 7;
op = (insn >> 11) & 3;
if (op == 3) {
/* add/subtract */
rn = (insn >> 3) & 7;
tmp = load_reg(s, rn);
if (insn & (1 << 10)) {
/* immediate */
tmp2 = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp2, (insn >> 6) & 7);
} else {
/* reg */
rm = (insn >> 6) & 7;
tmp2 = load_reg(s, rm);
}
if (insn & (1 << 9)) {
if (s->condexec_mask)
tcg_gen_sub_i32(tmp, tmp, tmp2);
else
gen_helper_sub_cc(tmp, tmp, tmp2);
} else {
if (s->condexec_mask)
tcg_gen_add_i32(tmp, tmp, tmp2);
else
gen_helper_add_cc(tmp, tmp, tmp2);
}
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
} else {
/* shift immediate */
rm = (insn >> 3) & 7;
shift = (insn >> 6) & 0x1f;
tmp = load_reg(s, rm);
gen_arm_shift_im(tmp, op, shift, s->condexec_mask == 0);
if (!s->condexec_mask)
gen_logic_CC(tmp);
store_reg(s, rd, tmp);
}
break;
case 2: case 3:
/* arithmetic large immediate */
op = (insn >> 11) & 3;
rd = (insn >> 8) & 0x7;
if (op == 0) { /* mov */
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, insn & 0xff);
if (!s->condexec_mask)
gen_logic_CC(tmp);
store_reg(s, rd, tmp);
} else {
tmp = load_reg(s, rd);
tmp2 = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp2, insn & 0xff);
switch (op) {
case 1: /* cmp */
gen_helper_sub_cc(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp);
tcg_temp_free_i32(tmp2);
break;
case 2: /* add */
if (s->condexec_mask)
tcg_gen_add_i32(tmp, tmp, tmp2);
else
gen_helper_add_cc(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
break;
case 3: /* sub */
if (s->condexec_mask)
tcg_gen_sub_i32(tmp, tmp, tmp2);
else
gen_helper_sub_cc(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
break;
}
}
break;
case 4:
if (insn & (1 << 11)) {
rd = (insn >> 8) & 7;
/* load pc-relative. Bit 1 of PC is ignored. */
val = s->pc + 2 + ((insn & 0xff) * 4);
val &= ~(uint32_t)2;
addr = tcg_temp_new_i32();
tcg_gen_movi_i32(addr, val);
tmp = gen_ld32(addr, IS_USER(s));
tcg_temp_free_i32(addr);
store_reg(s, rd, tmp);
break;
}
if (insn & (1 << 10)) {
/* data processing extended or blx */
rd = (insn & 7) | ((insn >> 4) & 8);
rm = (insn >> 3) & 0xf;
op = (insn >> 8) & 3;
switch (op) {
case 0: /* add */
tmp = load_reg(s, rd);
tmp2 = load_reg(s, rm);
tcg_gen_add_i32(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
store_reg(s, rd, tmp);
break;
case 1: /* cmp */
tmp = load_reg(s, rd);
tmp2 = load_reg(s, rm);
gen_helper_sub_cc(tmp, tmp, tmp2);
tcg_temp_free_i32(tmp2);
tcg_temp_free_i32(tmp);
break;
case 2: /* mov/cpy */
tmp = load_reg(s, rm);
store_reg(s, rd, tmp);
break;
case 3:/* branch [and link] exchange thumb register */
tmp = load_reg(s, rm);
if (insn & (1 << 7)) {
ARCH(5);
val = (uint32_t)s->pc | 1;
tmp2 = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp2, val);
store_reg(s, 14, tmp2);
}
/* already thumb, no need to check */
gen_bx(s, tmp);
break;
}
break;
}
/* data processing register */
rd = insn & 7;
rm = (insn >> 3) & 7;
op = (insn >> 6) & 0xf;
if (op == 2 || op == 3 || op == 4 || op == 7) {
/* the shift/rotate ops want the operands backwards */
val = rm;
rm = rd;
rd = val;
val = 1;
} else {
val = 0;
}
if (op == 9) { /* neg */
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, 0);
} else if (op != 0xf) { /* mvn doesn't read its first operand */
tmp = load_reg(s, rd);
} else {
TCGV_UNUSED(tmp);
}
tmp2 = load_reg(s, rm);
switch (op) {
case 0x0: /* and */
tcg_gen_and_i32(tmp, tmp, tmp2);
if (!s->condexec_mask)
gen_logic_CC(tmp);
break;
case 0x1: /* eor */
tcg_gen_xor_i32(tmp, tmp, tmp2);
if (!s->condexec_mask)
gen_logic_CC(tmp);
break;
case 0x2: /* lsl */
if (s->condexec_mask) {
gen_helper_shl(tmp2, tmp2, tmp);
} else {
gen_helper_shl_cc(tmp2, tmp2, tmp);
gen_logic_CC(tmp2);
}
break;
case 0x3: /* lsr */
if (s->condexec_mask) {
gen_helper_shr(tmp2, tmp2, tmp);
} else {
gen_helper_shr_cc(tmp2, tmp2, tmp);
gen_logic_CC(tmp2);
}
break;
case 0x4: /* asr */
if (s->condexec_mask) {
gen_helper_sar(tmp2, tmp2, tmp);
} else {
gen_helper_sar_cc(tmp2, tmp2, tmp);
gen_logic_CC(tmp2);
}
break;
case 0x5: /* adc */
if (s->condexec_mask)
gen_adc(tmp, tmp2);
else
gen_helper_adc_cc(tmp, tmp, tmp2);
break;
case 0x6: /* sbc */
if (s->condexec_mask)
gen_sub_carry(tmp, tmp, tmp2);
else
gen_helper_sbc_cc(tmp, tmp, tmp2);
break;
case 0x7: /* ror */
if (s->condexec_mask) {
tcg_gen_andi_i32(tmp, tmp, 0x1f);
tcg_gen_rotr_i32(tmp2, tmp2, tmp);
} else {
gen_helper_ror_cc(tmp2, tmp2, tmp);
gen_logic_CC(tmp2);
}
break;
case 0x8: /* tst */
tcg_gen_and_i32(tmp, tmp, tmp2);
gen_logic_CC(tmp);
rd = 16;
break;
case 0x9: /* neg */
if (s->condexec_mask)
tcg_gen_neg_i32(tmp, tmp2);
else
gen_helper_sub_cc(tmp, tmp, tmp2);
break;
case 0xa: /* cmp */
gen_helper_sub_cc(tmp, tmp, tmp2);
rd = 16;
break;
case 0xb: /* cmn */
gen_helper_add_cc(tmp, tmp, tmp2);
rd = 16;
break;
case 0xc: /* orr */
tcg_gen_or_i32(tmp, tmp, tmp2);
if (!s->condexec_mask)
gen_logic_CC(tmp);
break;
case 0xd: /* mul */
tcg_gen_mul_i32(tmp, tmp, tmp2);
if (!s->condexec_mask)
gen_logic_CC(tmp);
break;
case 0xe: /* bic */
tcg_gen_andc_i32(tmp, tmp, tmp2);
if (!s->condexec_mask)
gen_logic_CC(tmp);
break;
case 0xf: /* mvn */
tcg_gen_not_i32(tmp2, tmp2);
if (!s->condexec_mask)
gen_logic_CC(tmp2);
val = 1;
rm = rd;
break;
}
if (rd != 16) {
if (val) {
store_reg(s, rm, tmp2);
if (op != 0xf)
tcg_temp_free_i32(tmp);
} else {
store_reg(s, rd, tmp);
tcg_temp_free_i32(tmp2);
}
} else {
tcg_temp_free_i32(tmp);
tcg_temp_free_i32(tmp2);
}
break;
case 5:
/* load/store register offset. */
rd = insn & 7;
rn = (insn >> 3) & 7;
rm = (insn >> 6) & 7;
op = (insn >> 9) & 7;
addr = load_reg(s, rn);
tmp = load_reg(s, rm);
tcg_gen_add_i32(addr, addr, tmp);
tcg_temp_free_i32(tmp);
if (op < 3) /* store */
tmp = load_reg(s, rd);
switch (op) {
case 0: /* str */
gen_st32(tmp, addr, IS_USER(s));
break;
case 1: /* strh */
gen_st16(tmp, addr, IS_USER(s));
break;
case 2: /* strb */
gen_st8(tmp, addr, IS_USER(s));
break;
case 3: /* ldrsb */
tmp = gen_ld8s(addr, IS_USER(s));
break;
case 4: /* ldr */
tmp = gen_ld32(addr, IS_USER(s));
break;
case 5: /* ldrh */
tmp = gen_ld16u(addr, IS_USER(s));
break;
case 6: /* ldrb */
tmp = gen_ld8u(addr, IS_USER(s));
break;
case 7: /* ldrsh */
tmp = gen_ld16s(addr, IS_USER(s));
break;
}
if (op >= 3) /* load */
store_reg(s, rd, tmp);
tcg_temp_free_i32(addr);
break;
case 6:
/* load/store word immediate offset */
rd = insn & 7;
rn = (insn >> 3) & 7;
addr = load_reg(s, rn);
val = (insn >> 4) & 0x7c;
tcg_gen_addi_i32(addr, addr, val);
if (insn & (1 << 11)) {
/* load */
tmp = gen_ld32(addr, IS_USER(s));
store_reg(s, rd, tmp);
} else {
/* store */
tmp = load_reg(s, rd);
gen_st32(tmp, addr, IS_USER(s));
}
tcg_temp_free_i32(addr);
break;
case 7:
/* load/store byte immediate offset */
rd = insn & 7;
rn = (insn >> 3) & 7;
addr = load_reg(s, rn);
val = (insn >> 6) & 0x1f;
tcg_gen_addi_i32(addr, addr, val);
if (insn & (1 << 11)) {
/* load */
tmp = gen_ld8u(addr, IS_USER(s));
store_reg(s, rd, tmp);
} else {
/* store */
tmp = load_reg(s, rd);
gen_st8(tmp, addr, IS_USER(s));
}
tcg_temp_free_i32(addr);
break;
case 8:
/* load/store halfword immediate offset */
rd = insn & 7;
rn = (insn >> 3) & 7;
addr = load_reg(s, rn);
val = (insn >> 5) & 0x3e;
tcg_gen_addi_i32(addr, addr, val);
if (insn & (1 << 11)) {
/* load */
tmp = gen_ld16u(addr, IS_USER(s));
store_reg(s, rd, tmp);
} else {
/* store */
tmp = load_reg(s, rd);
gen_st16(tmp, addr, IS_USER(s));
}
tcg_temp_free_i32(addr);
break;
case 9:
/* load/store from stack */
rd = (insn >> 8) & 7;
addr = load_reg(s, 13);
val = (insn & 0xff) * 4;
tcg_gen_addi_i32(addr, addr, val);
if (insn & (1 << 11)) {
/* load */
tmp = gen_ld32(addr, IS_USER(s));
store_reg(s, rd, tmp);
} else {
/* store */
tmp = load_reg(s, rd);
gen_st32(tmp, addr, IS_USER(s));
}
tcg_temp_free_i32(addr);
break;
case 10:
/* add to high reg */
rd = (insn >> 8) & 7;
if (insn & (1 << 11)) {
/* SP */
tmp = load_reg(s, 13);
} else {
/* PC. bit 1 is ignored. */
tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, (s->pc + 2) & ~(uint32_t)2);
}
val = (insn & 0xff) * 4;
tcg_gen_addi_i32(tmp, tmp, val);
store_reg(s, rd, tmp);
break;
case 11:
/* misc */
op = (insn >> 8) & 0xf;
switch (op) {
case 0:
/* adjust stack pointer */
tmp = load_reg(s, 13);
val = (insn & 0x7f) * 4;
if (insn & (1 << 7))
val = -(int32_t)val;
tcg_gen_addi_i32(tmp, tmp, val);
store_reg(s, 13, tmp);
break;
case 2: /* sign/zero extend. */
ARCH(6);
rd = insn & 7;
rm = (insn >> 3) & 7;
tmp = load_reg(s, rm);
switch ((insn >> 6) & 3) {
case 0: gen_sxth(tmp); break;
case 1: gen_sxtb(tmp); break;
case 2: gen_uxth(tmp); break;
case 3: gen_uxtb(tmp); break;
}
store_reg(s, rd, tmp);
break;
case 4: case 5: case 0xc: case 0xd:
/* push/pop */
addr = load_reg(s, 13);
if (insn & (1 << 8))
offset = 4;
else
offset = 0;
for (i = 0; i < 8; i++) {
if (insn & (1 << i))
offset += 4;
}
if ((insn & (1 << 11)) == 0) {
tcg_gen_addi_i32(addr, addr, -offset);
}
for (i = 0; i < 8; i++) {
if (insn & (1 << i)) {
if (insn & (1 << 11)) {
/* pop */
tmp = gen_ld32(addr, IS_USER(s));
store_reg(s, i, tmp);
} else {
/* push */
tmp = load_reg(s, i);
gen_st32(tmp, addr, IS_USER(s));
}
/* advance to the next address. */
tcg_gen_addi_i32(addr, addr, 4);
}
}
TCGV_UNUSED(tmp);
if (insn & (1 << 8)) {
if (insn & (1 << 11)) {
/* pop pc */
tmp = gen_ld32(addr, IS_USER(s));
/* don't set the pc until the rest of the instruction
has completed */
} else {
/* push lr */
tmp = load_reg(s, 14);
gen_st32(tmp, addr, IS_USER(s));
}
tcg_gen_addi_i32(addr, addr, 4);
}
if ((insn & (1 << 11)) == 0) {
tcg_gen_addi_i32(addr, addr, -offset);
}
/* write back the new stack pointer */
store_reg(s, 13, addr);
/* set the new PC value */
if ((insn & 0x0900) == 0x0900) {
store_reg_from_load(env, s, 15, tmp);
}
break;
case 1: case 3: case 9: case 11: /* czb */
rm = insn & 7;
tmp = load_reg(s, rm);
s->condlabel = gen_new_label();
s->condjmp = 1;
if (insn & (1 << 11))
tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, s->condlabel);
else
tcg_gen_brcondi_i32(TCG_COND_NE, tmp, 0, s->condlabel);
tcg_temp_free_i32(tmp);
offset = ((insn & 0xf8) >> 2) | (insn & 0x200) >> 3;
val = (uint32_t)s->pc + 2;
val += offset;
gen_jmp(s, val);
break;
case 15: /* IT, nop-hint. */
if ((insn & 0xf) == 0) {
gen_nop_hint(s, (insn >> 4) & 0xf);
break;
}
/* If Then. */
s->condexec_cond = (insn >> 4) & 0xe;
s->condexec_mask = insn & 0x1f;
/* No actual code generated for this insn, just setup state. */
break;
case 0xe: /* bkpt */
ARCH(5);
gen_exception_insn(s, 2, EXCP_BKPT);
break;
case 0xa: /* rev */
ARCH(6);
rn = (insn >> 3) & 0x7;
rd = insn & 0x7;
tmp = load_reg(s, rn);
switch ((insn >> 6) & 3) {
case 0: tcg_gen_bswap32_i32(tmp, tmp); break;
case 1: gen_rev16(tmp); break;
case 3: gen_revsh(tmp); break;
default: goto illegal_op;
}
store_reg(s, rd, tmp);
break;
case 6: /* cps */
ARCH(6);
if (IS_USER(s))
break;
if (IS_M(env)) {
tmp = tcg_const_i32((insn & (1 << 4)) != 0);
/* PRIMASK */
if (insn & 1) {
addr = tcg_const_i32(16);
gen_helper_v7m_msr(cpu_env, addr, tmp);
tcg_temp_free_i32(addr);
}
/* FAULTMASK */
if (insn & 2) {
addr = tcg_const_i32(17);
gen_helper_v7m_msr(cpu_env, addr, tmp);
tcg_temp_free_i32(addr);
}
tcg_temp_free_i32(tmp);
gen_lookup_tb(s);
} else {
if (insn & (1 << 4))
shift = CPSR_A | CPSR_I | CPSR_F;
else
shift = 0;
gen_set_psr_im(s, ((insn & 7) << 6), 0, shift);
}
break;
default:
goto undef;
}
break;
case 12:
{
/* load/store multiple */
TCGv loaded_var;
TCGV_UNUSED(loaded_var);
rn = (insn >> 8) & 0x7;
addr = load_reg(s, rn);
for (i = 0; i < 8; i++) {
if (insn & (1 << i)) {
if (insn & (1 << 11)) {
/* load */
tmp = gen_ld32(addr, IS_USER(s));
if (i == rn) {
loaded_var = tmp;
} else {
store_reg(s, i, tmp);
}
} else {
/* store */
tmp = load_reg(s, i);
gen_st32(tmp, addr, IS_USER(s));
}
/* advance to the next address */
tcg_gen_addi_i32(addr, addr, 4);
}
}
if ((insn & (1 << rn)) == 0) {
/* base reg not in list: base register writeback */
store_reg(s, rn, addr);
} else {
/* base reg in list: if load, complete it now */
if (insn & (1 << 11)) {
store_reg(s, rn, loaded_var);
}
tcg_temp_free_i32(addr);
}
break;
}
case 13:
/* conditional branch or swi */
cond = (insn >> 8) & 0xf;
if (cond == 0xe)
goto undef;
if (cond == 0xf) {
/* swi */
gen_set_pc_im(s->pc);
s->is_jmp = DISAS_SWI;
break;
}
/* generate a conditional jump to next instruction */
s->condlabel = gen_new_label();
gen_test_cc(cond ^ 1, s->condlabel);
s->condjmp = 1;
/* jump to the offset */
val = (uint32_t)s->pc + 2;
offset = ((int32_t)insn << 24) >> 24;
val += offset << 1;
gen_jmp(s, val);
break;
case 14:
if (insn & (1 << 11)) {
if (disas_thumb2_insn(env, s, insn))
goto undef32;
break;
}
/* unconditional branch */
val = (uint32_t)s->pc;
offset = ((int32_t)insn << 21) >> 21;
val += (offset << 1) + 2;
gen_jmp(s, val);
break;
case 15:
if (disas_thumb2_insn(env, s, insn))
goto undef32;
break;
}
return;
undef32:
gen_exception_insn(s, 4, EXCP_UDEF);
return;
illegal_op:
undef:
gen_exception_insn(s, 2, EXCP_UDEF);
}
/* generate intermediate code in gen_opc_buf and gen_opparam_buf for
basic block 'tb'. If search_pc is TRUE, also generate PC
information for each intermediate instruction. */
static inline void gen_intermediate_code_internal(CPUState *env,
TranslationBlock *tb,
int search_pc)
{
DisasContext dc1, *dc = &dc1;
CPUBreakpoint *bp;
uint16_t *gen_opc_end;
int j, lj;
target_ulong pc_start;
uint32_t next_page_start;
int num_insns;
int max_insns;
/* generate intermediate code */
pc_start = tb->pc;
dc->tb = tb;
gen_opc_end = gen_opc_buf + OPC_MAX_SIZE;
dc->is_jmp = DISAS_NEXT;
dc->pc = pc_start;
dc->singlestep_enabled = env->singlestep_enabled;
dc->condjmp = 0;
dc->thumb = ARM_TBFLAG_THUMB(tb->flags);
dc->condexec_mask = (ARM_TBFLAG_CONDEXEC(tb->flags) & 0xf) << 1;
dc->condexec_cond = ARM_TBFLAG_CONDEXEC(tb->flags) >> 4;
#if !defined(CONFIG_USER_ONLY)
dc->user = (ARM_TBFLAG_PRIV(tb->flags) == 0);
#endif
dc->vfp_enabled = ARM_TBFLAG_VFPEN(tb->flags);
dc->vec_len = ARM_TBFLAG_VECLEN(tb->flags);
dc->vec_stride = ARM_TBFLAG_VECSTRIDE(tb->flags);
cpu_F0s = tcg_temp_new_i32();
cpu_F1s = tcg_temp_new_i32();
cpu_F0d = tcg_temp_new_i64();
cpu_F1d = tcg_temp_new_i64();
cpu_V0 = cpu_F0d;
cpu_V1 = cpu_F1d;
/* FIXME: cpu_M0 can probably be the same as cpu_V0. */
cpu_M0 = tcg_temp_new_i64();
next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;
lj = -1;
num_insns = 0;
max_insns = tb->cflags & CF_COUNT_MASK;
if (max_insns == 0)
max_insns = CF_COUNT_MASK;
gen_icount_start();
tcg_clear_temp_count();
/* A note on handling of the condexec (IT) bits:
*
* We want to avoid the overhead of having to write the updated condexec
* bits back to the CPUState for every instruction in an IT block. So:
* (1) if the condexec bits are not already zero then we write
* zero back into the CPUState now. This avoids complications trying
* to do it at the end of the block. (For example if we don't do this
* it's hard to identify whether we can safely skip writing condexec
* at the end of the TB, which we definitely want to do for the case
* where a TB doesn't do anything with the IT state at all.)
* (2) if we are going to leave the TB then we call gen_set_condexec()
* which will write the correct value into CPUState if zero is wrong.
* This is done both for leaving the TB at the end, and for leaving
* it because of an exception we know will happen, which is done in
* gen_exception_insn(). The latter is necessary because we need to
* leave the TB with the PC/IT state just prior to execution of the
* instruction which caused the exception.
* (3) if we leave the TB unexpectedly (eg a data abort on a load)
* then the CPUState will be wrong and we need to reset it.
* This is handled in the same way as restoration of the
* PC in these situations: we will be called again with search_pc=1
* and generate a mapping of the condexec bits for each PC in
* gen_opc_condexec_bits[]. restore_state_to_opc() then uses
* this to restore the condexec bits.
*
* Note that there are no instructions which can read the condexec
* bits, and none which can write non-static values to them, so
* we don't need to care about whether CPUState is correct in the
* middle of a TB.
*/
/* Reset the conditional execution bits immediately. This avoids
complications trying to do it at the end of the block. */
if (dc->condexec_mask || dc->condexec_cond)
{
TCGv tmp = tcg_temp_new_i32();
tcg_gen_movi_i32(tmp, 0);
store_cpu_field(tmp, condexec_bits);
}
do {
#ifdef CONFIG_USER_ONLY
/* Intercept jump to the magic kernel page. */
if (dc->pc >= 0xffff0000) {
/* We always get here via a jump, so know we are not in a
conditional execution block. */
gen_exception(EXCP_KERNEL_TRAP);
dc->is_jmp = DISAS_UPDATE;
break;
}
#else
if (dc->pc >= 0xfffffff0 && IS_M(env)) {
/* We always get here via a jump, so know we are not in a
conditional execution block. */
gen_exception(EXCP_EXCEPTION_EXIT);
dc->is_jmp = DISAS_UPDATE;
break;
}
#endif
if (unlikely(!QTAILQ_EMPTY(&env->breakpoints))) {
QTAILQ_FOREACH(bp, &env->breakpoints, entry) {
if (bp->pc == dc->pc) {
gen_exception_insn(dc, 0, EXCP_DEBUG);
/* Advance PC so that clearing the breakpoint will
invalidate this TB. */
dc->pc += 2;
goto done_generating;
break;
}
}
}
if (search_pc) {
j = gen_opc_ptr - gen_opc_buf;
if (lj < j) {
lj++;
while (lj < j)
gen_opc_instr_start[lj++] = 0;
}
gen_opc_pc[lj] = dc->pc;
gen_opc_condexec_bits[lj] = (dc->condexec_cond << 4) | (dc->condexec_mask >> 1);
gen_opc_instr_start[lj] = 1;
gen_opc_icount[lj] = num_insns;
}
if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO))
gen_io_start();
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP))) {
tcg_gen_debug_insn_start(dc->pc);
}
if (dc->thumb) {
disas_thumb_insn(env, dc);
if (dc->condexec_mask) {
dc->condexec_cond = (dc->condexec_cond & 0xe)
| ((dc->condexec_mask >> 4) & 1);
dc->condexec_mask = (dc->condexec_mask << 1) & 0x1f;
if (dc->condexec_mask == 0) {
dc->condexec_cond = 0;
}
}
} else {
disas_arm_insn(env, dc);
}
if (dc->condjmp && !dc->is_jmp) {
gen_set_label(dc->condlabel);
dc->condjmp = 0;
}
if (tcg_check_temp_count()) {
fprintf(stderr, "TCG temporary leak before %08x\n", dc->pc);
}
/* Translation stops when a conditional branch is encountered.
* Otherwise the subsequent code could get translated several times.
* Also stop translation when a page boundary is reached. This
* ensures prefetch aborts occur at the right place. */
num_insns ++;
} while (!dc->is_jmp && gen_opc_ptr < gen_opc_end &&
!env->singlestep_enabled &&
!singlestep &&
dc->pc < next_page_start &&
num_insns < max_insns);
if (tb->cflags & CF_LAST_IO) {
if (dc->condjmp) {
/* FIXME: This can theoretically happen with self-modifying
code. */
cpu_abort(env, "IO on conditional branch instruction");
}
gen_io_end();
}
/* At this stage dc->condjmp will only be set when the skipped
instruction was a conditional branch or trap, and the PC has
already been written. */
if (unlikely(env->singlestep_enabled)) {
/* Make sure the pc is updated, and raise a debug exception. */
if (dc->condjmp) {
gen_set_condexec(dc);
if (dc->is_jmp == DISAS_SWI) {
gen_exception(EXCP_SWI);
} else {
gen_exception(EXCP_DEBUG);
}
gen_set_label(dc->condlabel);
}
if (dc->condjmp || !dc->is_jmp) {
gen_set_pc_im(dc->pc);
dc->condjmp = 0;
}
gen_set_condexec(dc);
if (dc->is_jmp == DISAS_SWI && !dc->condjmp) {
gen_exception(EXCP_SWI);
} else {
/* FIXME: Single stepping a WFI insn will not halt
the CPU. */
gen_exception(EXCP_DEBUG);
}
} else {
/* While branches must always occur at the end of an IT block,
there are a few other things that can cause us to terminate
the TB in the middel of an IT block:
- Exception generating instructions (bkpt, swi, undefined).
- Page boundaries.
- Hardware watchpoints.
Hardware breakpoints have already been handled and skip this code.
*/
gen_set_condexec(dc);
switch(dc->is_jmp) {
case DISAS_NEXT:
gen_goto_tb(dc, 1, dc->pc);
break;
default:
case DISAS_JUMP:
case DISAS_UPDATE:
/* indicate that the hash table must be used to find the next TB */
tcg_gen_exit_tb(0);
break;
case DISAS_TB_JUMP:
/* nothing more to generate */
break;
case DISAS_WFI:
gen_helper_wfi();
break;
case DISAS_SWI:
gen_exception(EXCP_SWI);
break;
}
if (dc->condjmp) {
gen_set_label(dc->condlabel);
gen_set_condexec(dc);
gen_goto_tb(dc, 1, dc->pc);
dc->condjmp = 0;
}
}
done_generating:
gen_icount_end(tb, num_insns);
*gen_opc_ptr = INDEX_op_end;
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("----------------\n");
qemu_log("IN: %s\n", lookup_symbol(pc_start));
log_target_disas(pc_start, dc->pc - pc_start, dc->thumb);
qemu_log("\n");
}
#endif
if (search_pc) {
j = gen_opc_ptr - gen_opc_buf;
lj++;
while (lj <= j)
gen_opc_instr_start[lj++] = 0;
} else {
tb->size = dc->pc - pc_start;
tb->icount = num_insns;
}
}
void gen_intermediate_code(CPUState *env, TranslationBlock *tb)
{
gen_intermediate_code_internal(env, tb, 0);
}
void gen_intermediate_code_pc(CPUState *env, TranslationBlock *tb)
{
gen_intermediate_code_internal(env, tb, 1);
}
static const char *cpu_mode_names[16] = {
"usr", "fiq", "irq", "svc", "???", "???", "???", "abt",
"???", "???", "???", "und", "???", "???", "???", "sys"
};
void cpu_dump_state(CPUState *env, FILE *f, fprintf_function cpu_fprintf,
int flags)
{
int i;
#if 0
union {
uint32_t i;
float s;
} s0, s1;
CPU_DoubleU d;
/* ??? This assumes float64 and double have the same layout.
Oh well, it's only debug dumps. */
union {
float64 f64;
double d;
} d0;
#endif
uint32_t psr;
for(i=0;i<16;i++) {
cpu_fprintf(f, "R%02d=%08x", i, env->regs[i]);
if ((i % 4) == 3)
cpu_fprintf(f, "\n");
else
cpu_fprintf(f, " ");
}
psr = cpsr_read(env);
cpu_fprintf(f, "PSR=%08x %c%c%c%c %c %s%d\n",
psr,
psr & (1 << 31) ? 'N' : '-',
psr & (1 << 30) ? 'Z' : '-',
psr & (1 << 29) ? 'C' : '-',
psr & (1 << 28) ? 'V' : '-',
psr & CPSR_T ? 'T' : 'A',
cpu_mode_names[psr & 0xf], (psr & 0x10) ? 32 : 26);
#if 0
for (i = 0; i < 16; i++) {
d.d = env->vfp.regs[i];
s0.i = d.l.lower;
s1.i = d.l.upper;
d0.f64 = d.d;
cpu_fprintf(f, "s%02d=%08x(%8g) s%02d=%08x(%8g) d%02d=%08x%08x(%8g)\n",
i * 2, (int)s0.i, s0.s,
i * 2 + 1, (int)s1.i, s1.s,
i, (int)(uint32_t)d.l.upper, (int)(uint32_t)d.l.lower,
d0.d);
}
cpu_fprintf(f, "FPSCR: %08x\n", (int)env->vfp.xregs[ARM_VFP_FPSCR]);
#endif
}
void restore_state_to_opc(CPUState *env, TranslationBlock *tb, int pc_pos)
{
env->regs[15] = gen_opc_pc[pc_pos];
env->condexec_bits = gen_opc_condexec_bits[pc_pos];
}
| ceph/qemu-kvm | target-arm/translate.c | C | gpl-2.0 | 350,815 |
#! /bin/sh
$EXTRACTRC *.rc *.ui >> rc.cpp
$XGETTEXT *.cpp -o $podir/googledocs_plugin.pot
rm -f rc.cpp
| wyuka/calligra | plugins/staging/googledocs/Messages.sh | Shell | gpl-2.0 | 103 |
<?php
/**
* The transaction header loop.
*
* @since 1.4.0
* @version 1.0.0
* @package IT_Exchange
*
* WARNING: Do not edit this file directly. To use
* this template in a theme, simply copy over this
* file's content to the exchange/content-confirmation/loops/
* directory located in your theme.
*/
?>
<?php do_action( 'it_exchange_content_confirmation_before_header_loop' ); ?>
<?php do_action( 'it_exchange_content_confirmation_begin_header_loop' ); ?>
<?php foreach( it_exchange_get_template_part_loops( 'content_confirmation', 'header', array( 'message', 'menu' ) ) as $detail ) : ?>
<?php it_exchange_get_template_part( 'content-confirmation/elements/' . $detail ); ?>
<?php endforeach; ?>
<?php do_action( 'it_exchange_content_confirmation_end_header_loop' ); ?>
<?php do_action( 'it_exchange_content_confirmation_after_header_loop' ); ?>
| itaddy/permiekids | wp-content/themes/permiekids/exchange/content-confirmation/loops/header.php | PHP | gpl-2.0 | 865 |
/*
* Copyright (c) 1998-2012 Caucho Technology -- all rights reserved
*
* This file is part of Resin(R) Open Source
*
* Each copy or derived work must preserve the copyright notice and this
* notice unmodified.
*
* Resin Open Source 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.
*
* Resin Open Source 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, or any warranty
* of NON-INFRINGEMENT. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with Resin Open Source; if not, write to the
*
* Free Software Foundation, Inc.
* 59 Temple Place, Suite 330
* Boston, MA 02111-1307 USA
*
* @author Scott Ferguson
*/
package javax.jcr.observation;
import javax.jcr.RepositoryException;
public interface ObservationManager {
public void addEventListener(EventListener listener,
int eventTypes,
String absPath,
boolean isDeep,
String[] uuid,
String[] nodeTypeName,
boolean noLocal)
throws RepositoryException;
public void removeEventListener(EventListener listener)
throws RepositoryException;
public EventListenerIterator getRegisteredEventListeners()
throws RepositoryException;
}
| mdaniel/svn-caucho-com-resin | modules/jcr/src/javax/jcr/observation/ObservationManager.java | Java | gpl-2.0 | 1,710 |
# emacs: -*- mode: python; coding: utf-8; py-indent-offset: 4; indent-tabs-mode: t -*-
# vi: set ft=python sts=4 ts=4 sw=4 noet :
# This file is part of Fail2Ban.
#
# Fail2Ban 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.
#
# Fail2Ban 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 Fail2Ban; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# Author: Cyril Jaquier
#
__author__ = "Cyril Jaquier"
__copyright__ = "Copyright (c) 2004 Cyril Jaquier"
__license__ = "GPL"
import re
from abc import abstractmethod
from .strptime import reGroupDictStrptime, timeRE
from ..helpers import getLogger
logSys = getLogger(__name__)
class DateTemplate(object):
"""A template which searches for and returns a date from a log line.
This is an not functional abstract class which other templates should
inherit from.
Attributes
----------
name
regex
"""
def __init__(self):
self._name = ""
self._regex = ""
self._cRegex = None
self.hits = 0
@property
def name(self):
"""Name assigned to template.
"""
return self._name
@name.setter
def name(self, name):
self._name = name
def getRegex(self):
return self._regex
def setRegex(self, regex, wordBegin=True):
"""Sets regex to use for searching for date in log line.
Parameters
----------
regex : str
The regex the template will use for searching for a date.
wordBegin : bool
Defines whether the regex should be modified to search at
beginning of a word, by adding "\\b" to start of regex.
Default True.
Raises
------
re.error
If regular expression fails to compile
"""
regex = regex.strip()
if (wordBegin and not re.search(r'^\^', regex)):
regex = r'\b' + regex
self._regex = regex
self._cRegex = re.compile(regex, re.UNICODE | re.IGNORECASE)
regex = property(getRegex, setRegex, doc=
"""Regex used to search for date.
""")
def matchDate(self, line):
"""Check if regex for date matches on a log line.
"""
dateMatch = self._cRegex.search(line)
return dateMatch
@abstractmethod
def getDate(self, line):
"""Abstract method, which should return the date for a log line
This should return the date for a log line, typically taking the
date from the part of the line which matched the templates regex.
This requires abstraction, therefore just raises exception.
Parameters
----------
line : str
Log line, of which the date should be extracted from.
Raises
------
NotImplementedError
Abstract method, therefore always returns this.
"""
raise NotImplementedError("getDate() is abstract")
class DateEpoch(DateTemplate):
"""A date template which searches for Unix timestamps.
This includes Unix timestamps which appear at start of a line, optionally
within square braces (nsd), or on SELinux audit log lines.
Attributes
----------
name
regex
"""
def __init__(self):
DateTemplate.__init__(self)
self.regex = "(?:^|(?P<square>(?<=^\[))|(?P<selinux>(?<=audit\()))\d{10}(?:\.\d{3,6})?(?(selinux)(?=:\d+\))(?(square)(?=\])))"
def getDate(self, line):
"""Method to return the date for a log line.
Parameters
----------
line : str
Log line, of which the date should be extracted from.
Returns
-------
(float, str)
Tuple containing a Unix timestamp, and the string of the date
which was matched and in turned used to calculated the timestamp.
"""
dateMatch = self.matchDate(line)
if dateMatch:
# extract part of format which represents seconds since epoch
return (float(dateMatch.group()), dateMatch)
return None
class DatePatternRegex(DateTemplate):
"""Date template, with regex/pattern
Parameters
----------
pattern : str
Sets the date templates pattern.
Attributes
----------
name
regex
pattern
"""
_patternRE = r"%%(%%|[%s])" % "".join(timeRE.keys())
_patternName = {
'a': "DAY", 'A': "DAYNAME", 'b': "MON", 'B': "MONTH", 'd': "Day",
'H': "24hour", 'I': "12hour", 'j': "Yearday", 'm': "Month",
'M': "Minute", 'p': "AMPM", 'S': "Second", 'U': "Yearweek",
'w': "Weekday", 'W': "Yearweek", 'y': 'Year2', 'Y': "Year", '%': "%",
'z': "Zone offset", 'f': "Microseconds", 'Z': "Zone name"}
for _key in set(timeRE) - set(_patternName): # may not have them all...
_patternName[_key] = "%%%s" % _key
def __init__(self, pattern=None):
super(DatePatternRegex, self).__init__()
self._pattern = None
if pattern is not None:
self.pattern = pattern
@property
def pattern(self):
"""The pattern used for regex with strptime "%" time fields.
This should be a valid regular expression, of which matching string
will be extracted from the log line. strptime style "%" fields will
be replaced by appropriate regular expressions, or custom regex
groups with names as per the strptime fields can also be used
instead.
"""
return self._pattern
@pattern.setter
def pattern(self, pattern):
self._pattern = pattern
self._name = re.sub(
self._patternRE, r'%(\1)s', pattern) % self._patternName
super(DatePatternRegex, self).setRegex(
re.sub(self._patternRE, r'%(\1)s', pattern) % timeRE)
def setRegex(self, value):
raise NotImplementedError("Regex derived from pattern")
@DateTemplate.name.setter
def name(self, value):
raise NotImplementedError("Name derived from pattern")
def getDate(self, line):
"""Method to return the date for a log line.
This uses a custom version of strptime, using the named groups
from the instances `pattern` property.
Parameters
----------
line : str
Log line, of which the date should be extracted from.
Returns
-------
(float, str)
Tuple containing a Unix timestamp, and the string of the date
which was matched and in turned used to calculated the timestamp.
"""
dateMatch = self.matchDate(line)
if dateMatch:
groupdict = dict(
(key, value)
for key, value in dateMatch.groupdict().iteritems()
if value is not None)
return reGroupDictStrptime(groupdict), dateMatch
class DateTai64n(DateTemplate):
"""A date template which matches TAI64N formate timestamps.
Attributes
----------
name
regex
"""
def __init__(self):
DateTemplate.__init__(self)
# We already know the format for TAI64N
# yoh: we should not add an additional front anchor
self.setRegex("@[0-9a-f]{24}", wordBegin=False)
def getDate(self, line):
"""Method to return the date for a log line.
Parameters
----------
line : str
Log line, of which the date should be extracted from.
Returns
-------
(float, str)
Tuple containing a Unix timestamp, and the string of the date
which was matched and in turned used to calculated the timestamp.
"""
dateMatch = self.matchDate(line)
if dateMatch:
# extract part of format which represents seconds since epoch
value = dateMatch.group()
seconds_since_epoch = value[2:17]
# convert seconds from HEX into local time stamp
return (int(seconds_since_epoch, 16), dateMatch)
return None
| jakesyl/fail2ban | fail2ban/server/datetemplate.py | Python | gpl-2.0 | 7,428 |
/*
Copyright_License {
XCSoar Glide Computer - http://www.xcsoar.org/
Copyright (C) 2000-2015 The XCSoar Project
A detailed list of copyright holders can be found in the file "AUTHORS".
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 "Internal.hpp"
#include "NMEA/Checksum.hpp"
#include "NMEA/InputLine.hpp"
#include "NMEA/Info.hpp"
#include "Geo/SpeedVector.hpp"
#include "Units/System.hpp"
#include "Atmosphere/Temperature.hpp"
#include "Util/Macros.hpp"
static bool
ReadSpeedVector(NMEAInputLine &line, SpeedVector &value_r)
{
fixed bearing, norm;
bool bearing_valid = line.ReadChecked(bearing);
bool norm_valid = line.ReadChecked(norm);
if (bearing_valid && norm_valid) {
value_r.bearing = Angle::Degrees(bearing);
value_r.norm = Units::ToSysUnit(norm, Unit::KILOMETER_PER_HOUR);
return true;
} else
return false;
}
static bool
LXWP0(NMEAInputLine &line, NMEAInfo &info)
{
/*
$LXWP0,Y,222.3,1665.5,1.71,,,,,,239,174,10.1
0 loger_stored (Y/N)
1 IAS (kph) ----> Condor uses TAS!
2 baroaltitude (m)
3-8 vario (m/s) (last 6 measurements in last second)
9 heading of plane
10 windcourse (deg)
11 windspeed (kph)
*/
line.Skip();
fixed airspeed;
bool tas_available = line.ReadChecked(airspeed);
if (tas_available && (airspeed < fixed(-50) || airspeed > fixed(250)))
/* implausible */
return false;
fixed value;
if (line.ReadChecked(value))
/* a dump on a LX7007 has confirmed that the LX sends uncorrected
altitude above 1013.25hPa here */
info.ProvidePressureAltitude(value);
if (tas_available)
/*
* Call ProvideTrueAirspeed() after ProvidePressureAltitude() to use
* the provided altitude (if available)
*/
info.ProvideTrueAirspeed(Units::ToSysUnit(airspeed, Unit::KILOMETER_PER_HOUR));
if (line.ReadChecked(value))
info.ProvideTotalEnergyVario(value);
line.Skip(6);
SpeedVector wind;
if (ReadSpeedVector(line, wind))
info.ProvideExternalWind(wind);
return true;
}
template<size_t N>
static void
ReadString(NMEAInputLine &line, NarrowString<N> &value)
{
line.Read(value.buffer(), value.capacity());
}
static void
LXWP1(NMEAInputLine &line, DeviceInfo &device)
{
/*
* $LXWP1,
* instrument ID,
* serial number,
* software version,
* hardware version,
* license string
*/
ReadString(line, device.product);
ReadString(line, device.serial);
ReadString(line, device.software_version);
ReadString(line, device.hardware_version);
}
static bool
LXWP2(NMEAInputLine &line, NMEAInfo &info)
{
/*
* $LXWP2,
* maccready value, (m/s)
* ballast, (1.0 - 1.5)
* bugs, (0 - 100%)
* polar_a,
* polar_b,
* polar_c,
* audio volume
*/
fixed value;
// MacCready value
if (line.ReadChecked(value))
info.settings.ProvideMacCready(value, info.clock);
// Ballast
if (line.ReadChecked(value))
info.settings.ProvideBallastOverload(value, info.clock);
// Bugs
if (line.ReadChecked(value)) {
if (value <= fixed(1.5) && value >= fixed(1.0))
// LX160 (sw 3.04) reports bugs as 1.00, 1.05 or 1.10 (#2167)
info.settings.ProvideBugs(fixed(2) - value, info.clock);
else
// All other known LX devices report bugs as 0, 5, 10, 15, ...
info.settings.ProvideBugs((fixed(100) - value) / 100, info.clock);
}
line.Skip(3);
unsigned volume;
if (line.ReadChecked(volume))
info.settings.ProvideVolume(volume, info.clock);
return true;
}
static bool
LXWP3(NMEAInputLine &line, NMEAInfo &info)
{
/*
* $LXWP3,
* altioffset
* scmode
* variofil
* tefilter
* televel
* varioavg
* variorange
* sctab
* sclow
* scspeed
* SmartDiff
* glider name
* time offset
*/
fixed value;
// Altitude offset -> QNH
if (line.ReadChecked(value)) {
value = Units::ToSysUnit(-value, Unit::FEET);
auto qnh = AtmosphericPressure::PressureAltitudeToStaticPressure(value);
info.settings.ProvideQNH(qnh, info.clock);
}
return true;
}
/**
* Parse the $PLXV0 sentence (LXNav V7).
*/
static bool
PLXV0(NMEAInputLine &line, DeviceSettingsMap<std::string> &settings)
{
char name[64];
line.Read(name, ARRAY_SIZE(name));
if (StringIsEmpty(name))
return true;
char type[2];
line.Read(type, ARRAY_SIZE(type));
if (type[0] != 'W')
return true;
const auto value = line.Rest();
settings.Lock();
settings.Set(name, std::string(value.begin(), value.end()));
settings.Unlock();
return true;
}
static void
ParseNanoInfo(NMEAInputLine &line, DeviceInfo &device)
{
ReadString(line, device.product);
ReadString(line, device.software_version);
line.Skip(); /* ver.date, e.g. "May 12 2012 21:38:28" */
ReadString(line, device.hardware_version);
}
/**
* Parse the $PLXVC sentence (LXNAV Nano).
*
* $PLXVC,<key>,<type>,<values>*<checksum><cr><lf>
*/
static void
PLXVC(NMEAInputLine &line, DeviceInfo &device,
DeviceInfo &secondary_device,
DeviceSettingsMap<std::string> &settings)
{
char key[64];
line.Read(key, ARRAY_SIZE(key));
char type[2];
line.Read(type, ARRAY_SIZE(type));
if (StringIsEqual(key, "SET") && type[0] == 'A') {
char name[64];
line.Read(name, ARRAY_SIZE(name));
const auto value = line.Rest();
if (!StringIsEmpty(name)) {
settings.Lock();
settings.Set(name, std::string(value.begin(), value.end()));
settings.Unlock();
}
} else if (StringIsEqual(key, "INFO") && type[0] == 'A') {
ParseNanoInfo(line, device);
} else if (StringIsEqual(key, "GPSINFO") && type[0] == 'A') {
/* the LXNAV V7 (firmware >= 2.01) forwards the Nano's INFO
sentence with the "GPS" prefix */
char name[64];
line.Read(name, ARRAY_SIZE(name));
if (StringIsEqual(name, "LXWP1")) {
LXWP1(line, secondary_device);
} else if (StringIsEqual(name, "INFO")) {
line.Read(type, ARRAY_SIZE(type));
if (type[0] == 'A')
ParseNanoInfo(line, secondary_device);
}
}
}
/**
* Parse the $PLXVF sentence (LXNav V7).
*
* $PLXVF,time ,AccX,AccY,AccZ,Vario,IAS,PressAlt*CS<CR><LF>
*
* Example: $PLXVF,1.00,0.87,-0.12,-0.25,90.2,244.3,*CS<CR><LF>
*
* @see http://www.xcsoar.org/trac/raw-attachment/ticket/1666/V7%20dataport%20specification%201.97.pdf
*/
static bool
PLXVF(NMEAInputLine &line, NMEAInfo &info)
{
line.Skip(4);
fixed vario;
if (line.ReadChecked(vario))
info.ProvideNettoVario(vario);
fixed ias;
bool have_ias = line.ReadChecked(ias);
fixed altitude;
if (line.ReadChecked(altitude)) {
info.ProvidePressureAltitude(altitude);
if (have_ias)
info.ProvideIndicatedAirspeedWithAltitude(ias, altitude);
}
return true;
}
/**
* Parse the $PLXVS sentence (LXNav V7).
*
* $PLXVS,OAT,mode,voltage *CS<CR><LF>
*
* Example: $PLXVS,23.1,0,12.3,*CS<CR><LF>
*
* @see http://www.xcsoar.org/trac/raw-attachment/ticket/1666/V7%20dataport%20specification%201.97.pdf
*/
static bool
PLXVS(NMEAInputLine &line, NMEAInfo &info)
{
fixed temperature;
if (line.ReadChecked(temperature)) {
info.temperature = CelsiusToKelvin(temperature);
info.temperature_available = true;
}
int mode;
info.switch_state.flight_mode = SwitchState::FlightMode::UNKNOWN;
if (line.ReadChecked(mode)) {
if (mode == 0)
info.switch_state.flight_mode = SwitchState::FlightMode::CIRCLING;
else if (mode == 1)
info.switch_state.flight_mode = SwitchState::FlightMode::CRUISE;
}
fixed voltage;
if (line.ReadChecked(voltage)) {
info.voltage = voltage;
info.voltage_available.Update(info.clock);
}
return true;
}
bool
LXDevice::ParseNMEA(const char *String, NMEAInfo &info)
{
if (!VerifyNMEAChecksum(String))
return false;
NMEAInputLine line(String);
char type[16];
line.Read(type, 16);
if (StringIsEqual(type, "$LXWP0"))
return LXWP0(line, info);
if (StringIsEqual(type, "$LXWP1")) {
/* if in pass-through mode, assume that this line was sent by the
secondary device */
DeviceInfo &device_info = mode == Mode::PASS_THROUGH
? info.secondary_device
: info.device;
LXWP1(line, device_info);
const bool saw_v7 = device_info.product.equals("V7");
const bool saw_nano = device_info.product.equals("NANO");
const bool saw_lx16xx = device_info.product.equals("1606") ||
device_info.product.equals("1600");
if (mode == Mode::PASS_THROUGH) {
/* in pass-through mode, we should never clear the V7 flag,
because the V7 is still there, even though it's "hidden"
currently */
is_v7 |= saw_v7;
is_nano |= saw_nano;
is_lx16xx |= saw_lx16xx;
is_forwarded_nano = saw_nano;
} else {
is_v7 = saw_v7;
is_nano = saw_nano;
is_lx16xx = saw_lx16xx;
}
if (saw_v7 || saw_nano || saw_lx16xx)
is_colibri = false;
return true;
}
if (StringIsEqual(type, "$LXWP2"))
return LXWP2(line, info);
if (StringIsEqual(type, "$LXWP3"))
return LXWP3(line, info);
if (StringIsEqual(type, "$PLXV0")) {
is_v7 = true;
is_colibri = false;
return PLXV0(line, v7_settings);
}
if (StringIsEqual(type, "$PLXVC")) {
is_nano = true;
is_colibri = false;
PLXVC(line, info.device, info.secondary_device, nano_settings);
is_forwarded_nano = info.secondary_device.product.equals("NANO");
return true;
}
if (StringIsEqual(type, "$PLXVF")) {
is_v7 = true;
is_colibri = false;
return PLXVF(line, info);
}
if (StringIsEqual(type, "$PLXVS")) {
is_v7 = true;
is_colibri = false;
return PLXVS(line, info);
}
return false;
}
| TobiasLohner/XCSoar | src/Device/Driver/LX/Parser.cpp | C++ | gpl-2.0 | 10,296 |
/* arch/arm/mach-omap2/board-kona-input.c
*
* Based on mach-omap2/board-palau-input.c
*
* Copyright (C) 2012 Samsung Electronics, Inc.
*
* 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 <linux/platform_device.h>
#include <linux/errno.h>
#include <linux/input.h>
#include <linux/interrupt.h>
#include <linux/keyreset.h>
#include <linux/gpio_event.h>
#include <linux/gpio.h>
#include <linux/i2c.h>
#include <linux/power_supply.h>
#include <linux/regulator/consumer.h>
#include <linux/platform_data/sec_ts.h>
#include <linux/delay.h>
#include <linux/wacom_i2c.h>
#include <linux/slab.h>
#include <mach/cpufreq_limits.h>
#include <asm/mach-types.h>
#include <plat/omap4-keypad.h>
#include "board-kona.h"
#include "mux.h"
#include "omap_muxtbl.h"
#include "control.h" /* Used at tsp_set_power func. */
#include "sec_debug.h"
#define TOUCH_DVFS_FREQ 800000
#define TOUCH_MAX_SLOT 10
struct touch_dvfs_data {
struct work_struct dvfs_work;
bool mode;
bool enable;
};
static struct touch_dvfs_data dvfs_data;
static void touch_dvfs_work(struct work_struct *work)
{
if (dvfs_data.enable)
omap_cpufreq_min_limit(DVFS_LOCK_ID_TSP, TOUCH_DVFS_FREQ);
else
omap_cpufreq_min_limit_free(DVFS_LOCK_ID_TSP);
}
static void touch_dvfs_event(struct input_handle *handle,
unsigned int type, unsigned int code, int value)
{
static int slot;
static int cnt;
static bool state[TOUCH_MAX_SLOT];
static bool epen_state;
if (type == EV_ABS) {
switch (code) {
case ABS_MT_SLOT:
slot = value;
break;
case ABS_MT_POSITION_X:
case ABS_MT_POSITION_Y:
if (!state[slot]) {
state[slot] = true;
cnt++;
}
break;
case ABS_MT_TRACKING_ID:
if (value == -1 && state[slot]) {
state[slot] = false;
cnt--;
}
}
} else if (type == EV_KEY &&
(code == BTN_TOOL_PEN || code == BTN_TOOL_RUBBER))
epen_state = !!value;
if ((cnt || epen_state) && !dvfs_data.enable) {
dvfs_data.enable = true;
schedule_work(&dvfs_data.dvfs_work);
} else if (!cnt && !epen_state && dvfs_data.enable) {
dvfs_data.enable = false;
schedule_work(&dvfs_data.dvfs_work);
}
}
static bool touch_dvfs_match(struct input_handler *handler,
struct input_dev *dev)
{
if (test_bit(EV_ABS, dev->evbit) &&
test_bit(INPUT_PROP_DIRECT, dev->propbit))
return true;
else if (test_bit(EV_KEY, dev->evbit) && test_bit(EV_ABS, dev->evbit) &&
test_bit(BTN_TOOL_PEN, dev->keybit) &&
test_bit(BTN_TOOL_RUBBER, dev->keybit))
return true;
else
return false;
}
static int touch_dvfs_connect(struct input_handler *handler,
struct input_dev *dev, const struct input_device_id *id)
{
struct input_handle *handle;
int error;
handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL);
if (!handle)
return -ENOMEM;
handle->dev = dev;
handle->handler = handler;
handle->name = "touch_dvfs";
error = input_register_handle(handle);
if (error)
goto err_free_handle;
error = input_open_device(handle);
if (error)
goto err_unregister_handle;
return 0;
err_unregister_handle:
input_unregister_handle(handle);
err_free_handle:
kfree(handle);
return error;
}
static void touch_dvfs_disconnect(struct input_handle *handle)
{
input_close_device(handle);
input_unregister_handle(handle);
kfree(handle);
}
static const struct input_device_id touch_dvfs_ids[] = {
{
.flags = INPUT_DEVICE_ID_MATCH_EVBIT |
INPUT_DEVICE_ID_MATCH_ABSBIT,
.evbit = { BIT_MASK(EV_ABS) },
},
{ },
};
static struct input_handler touch_dvfs_handler = {
.event = touch_dvfs_event,
.match = touch_dvfs_match,
.connect = touch_dvfs_connect,
.disconnect = touch_dvfs_disconnect,
.name = "touch_dvfs",
.id_table = touch_dvfs_ids,
};
/* keypad setting */
enum {
GPIO_EXT_WAKEUP = 0,
GPIO_VOL_UP,
GPIO_VOL_DOWN,
};
static struct gpio keys_map_low_gpios[] __initdata = {
[GPIO_EXT_WAKEUP] = {
.label = "EXT_WAKEUP",
},
[GPIO_VOL_UP] = {
.label = "VOL_UP",
},
[GPIO_VOL_DOWN] = {
.label = "VOL_DOWN",
},
};
static struct gpio_event_direct_entry kona_gpio_keypad_keys_map_low[] = {
[GPIO_EXT_WAKEUP] = {
.code = KEY_POWER,
},
[GPIO_VOL_DOWN] = {
.code = KEY_VOLUMEDOWN,
},
[GPIO_VOL_UP] = {
.code = KEY_VOLUMEUP,
},
};
static struct gpio_event_input_info kona_gpio_keypad_keys_info_low = {
.info.func = gpio_event_input_func,
.info.no_suspend = true,
.type = EV_KEY,
.keymap = kona_gpio_keypad_keys_map_low,
.keymap_size = ARRAY_SIZE(kona_gpio_keypad_keys_map_low),
.debounce_time.tv64 = 2 * NSEC_PER_MSEC,
};
static struct gpio_event_info *kona_gpio_keypad_info[] = {
&kona_gpio_keypad_keys_info_low.info,
};
static struct gpio_event_platform_data kona_gpio_keypad_data = {
.name = "sec_key",
.info = kona_gpio_keypad_info,
.info_count = ARRAY_SIZE(kona_gpio_keypad_info)
};
static struct platform_device kona_gpio_keypad_device = {
.name = GPIO_EVENT_DEV_NAME,
.id = 0,
.dev = {
.platform_data = &kona_gpio_keypad_data,
},
};
ssize_t sec_key_pressed_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
unsigned int key_press_status = 0;
int i;
for (i = 0; i < ARRAY_SIZE(kona_gpio_keypad_keys_map_low); i++) {
if (unlikely(kona_gpio_keypad_keys_map_low[i].gpio == -EINVAL))
continue;
key_press_status |=
(!gpio_get_value(kona_gpio_keypad_keys_map_low[i].gpio))
<< i;
}
return sprintf(buf, "%u\n", key_press_status);
}
static DEVICE_ATTR(sec_key_pressed, S_IRUGO, sec_key_pressed_show, NULL);
static int kona_create_sec_key_dev(void)
{
struct device *sec_key;
sec_key = device_create(sec_class, NULL, 0, NULL, "sec_key");
if (!sec_key) {
pr_err("Failed to create sysfs(sec_key)!\n");
return -ENOMEM;
}
if (device_create_file(sec_key, &dev_attr_sec_key_pressed) < 0)
pr_err("Failed to create device file(%s)!\n",
dev_attr_sec_key_pressed.attr.name);
return 0;
}
static void __init kona_gpio_keypad_gpio_init(void)
{
int i;
for (i = 0; i < ARRAY_SIZE(keys_map_low_gpios); i++)
kona_gpio_keypad_keys_map_low[i].gpio =
omap_muxtbl_get_gpio_by_name(keys_map_low_gpios[i].label);
}
static void __init kona_input_keyboard_init(void)
{
kona_gpio_keypad_gpio_init();
kona_create_sec_key_dev();
if (unlikely(sec_debug_get_level()))
kona_gpio_keypad_keys_info_low.flags |= GPIOEDF_PRINT_KEYS;
platform_device_register(&kona_gpio_keypad_device);
}
/* touch device settings for synaptics rmi control program */
#if defined(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4)
#include <linux/rmi.h>
struct syna_gpio_data {
u16 gpio_number;
char *gpio_name;
};
static int SYNA_ts_power(bool on)
{
struct regulator *tsp_vdd, *tsp_pull_up;
tsp_vdd = regulator_get(NULL, "TSP_3.3V");
tsp_pull_up = regulator_get(NULL, "TSP_1.8V");
if (IS_ERR(tsp_vdd) || IS_ERR(tsp_pull_up)) {
pr_err("tsp: cannot get touch regulator.\n");
return 0;
}
if (on) {
pr_info("tsp: power on.\n");
regulator_enable(tsp_pull_up);
regulator_enable(tsp_vdd);
mdelay(300); /* for guarantee a boot time */
} else {
pr_info("tsp: power off.\n");
regulator_disable(tsp_vdd);
regulator_disable(tsp_pull_up);
}
return 0;
}
static int synaptics_touchpad_gpio_setup(void *gpio_data, bool configure)
{
int retval = 0;
struct syna_gpio_data *data = gpio_data;
pr_info("%s: RMI4 gpio configuration set to %d.\n",
__func__, configure);
if (configure) {
retval = gpio_request(data->gpio_number, "rmi4_attn");
if (retval) {
pr_err("%s: Failed to get attn gpio %d. Code: %d.",
__func__, data->gpio_number, retval);
return retval;
}
retval = gpio_direction_input(data->gpio_number);
if (retval) {
pr_err("%s: Failed to setup attn gpio %d. Code: %d.",
__func__, data->gpio_number, retval);
gpio_free(data->gpio_number);
}
} else {
pr_warn("%s: No way to deconfigure gpio %d.",
__func__, data->gpio_number);
}
return SYNA_ts_power(configure);
}
static struct syna_gpio_data SYNA_gpiodata = {
.gpio_name = "TOUCH_nINT",
};
static struct rmi_device_platform_data SYNA_platformdata = {
.driver_name = "rmi_generic",
.sensor_name = "kona",
.attn_polarity = RMI_ATTN_ACTIVE_LOW,
.level_triggered = true,
.gpio_data = &SYNA_gpiodata,
.gpio_config = synaptics_touchpad_gpio_setup,
.axis_align = { },
};
static struct i2c_board_info __initdata synaptics_i2c_devices[] = {
{
I2C_BOARD_INFO("rmi_i2c", 0x20),
.platform_data = &SYNA_platformdata,
},
};
static void __init kona_input_tsp_init(void)
{
SYNA_platformdata.attn_gpio = SYNA_gpiodata.gpio_number =
omap_muxtbl_get_gpio_by_name(SYNA_gpiodata.gpio_name);
i2c_register_board_info(3, synaptics_i2c_devices,
ARRAY_SIZE(synaptics_i2c_devices));
}
/* touch device settings for samsung synaptics driver */
#else
enum {
GPIO_TOUCH_nINT = 0,
GPIO_TOUCH_SCL,
GPIO_TOUCH_SDA,
};
static struct gpio tsp_gpios[] = {
[GPIO_TOUCH_nINT] = {
.flags = GPIOF_IN,
.label = "TOUCH_nINT",
},
[GPIO_TOUCH_SCL] = {
.label = "TSP_I2C_SCL",
},
[GPIO_TOUCH_SDA] = {
.label = "TSP_I2C_SDA",
},
};
static void tsp_set_power_regulator(bool on)
{
static struct regulator *tsp_vdd, *tsp_pull_up;
static bool boot_on;
if (unlikely(!tsp_vdd || !tsp_pull_up)) {
tsp_vdd = regulator_get(NULL, "TSP_3.3V");
tsp_pull_up = regulator_get(NULL, "TSP_1.8V");
if (IS_ERR(tsp_vdd) || IS_ERR(tsp_pull_up)) {
pr_err("tsp: cannot get touch regulator.\n");
return;
}
}
if (on) {
pr_info("tsp: power on.\n");
regulator_enable(tsp_pull_up);
regulator_enable(tsp_vdd);
if (likely(boot_on))
msleep(300); /* for guarantee a boot time */
else
boot_on = true;
} else {
pr_info("tsp: power off.\n");
regulator_disable(tsp_vdd);
regulator_disable(tsp_pull_up);
msleep(50);
}
return;
}
static struct sec_ts_platform_data kona_ts_pdata = {
.model_name = "N5100",
.fw_name = "synaptics/n5100.fw",
.ext_fw_name = "/mnt/sdcard/n5100.img",
.rx_channel_no = 41, /* Rx ch. */
.tx_channel_no = 26, /* Tx ch. */
.x_pixel_size = 799,
.y_pixel_size = 1279,
.pivot = false,
.ta_state = CABLE_NONE,
.set_power = tsp_set_power_regulator,
};
static struct i2c_board_info kona_i2c3_boardinfo[] __initdata = {
{
I2C_BOARD_INFO("synaptics_ts", 0x20),
.platform_data = &kona_ts_pdata,
},
};
static void __init kona_tsp_gpio_init(void)
{
int i, n = ARRAY_SIZE(tsp_gpios);
for (i = 0; i < n; i++)
tsp_gpios[i].gpio =
omap_muxtbl_get_gpio_by_name(tsp_gpios[i].label);
if (gpio_request_array(tsp_gpios, n) < 0)
pr_err("tsp: gpio_request failed.");
kona_i2c3_boardinfo[0].irq =
gpio_to_irq(tsp_gpios[GPIO_TOUCH_nINT].gpio);
kona_ts_pdata.gpio_irq = tsp_gpios[GPIO_TOUCH_nINT].gpio;
kona_ts_pdata.gpio_scl = tsp_gpios[GPIO_TOUCH_SCL].gpio;
kona_ts_pdata.gpio_sda = tsp_gpios[GPIO_TOUCH_SDA].gpio;
}
static void __init kona_input_tsp_init(void)
{
kona_tsp_gpio_init();
i2c_register_board_info(3, kona_i2c3_boardinfo,
ARRAY_SIZE(kona_i2c3_boardinfo));
}
void omap4_kona_tsp_ta_detect(int cable_type)
{
struct regulator *tsp_vdd;
tsp_vdd = regulator_get(NULL, "TSP_3.3V");
switch (cable_type) {
case POWER_SUPPLY_TYPE_MAINS:
kona_ts_pdata.ta_state = CABLE_TA;
break;
case POWER_SUPPLY_TYPE_USB:
kona_ts_pdata.ta_state = CABLE_USB;
break;
case POWER_SUPPLY_TYPE_BATTERY:
default:
kona_ts_pdata.ta_state = CABLE_NONE;
}
/* Conditions to prevent kernel panic */
if (kona_ts_pdata.set_ta_mode && regulator_is_enabled(tsp_vdd))
kona_ts_pdata.set_ta_mode(&kona_ts_pdata.ta_state);
return;
}
#endif
/* wacom device setting */
enum {
GPIO_PEN_LDO_EN = 0,
GPIO_PEN_IRQ,
GPIO_PEN_PDCT,
GPIO_PEN_DETECT,
GPIO_PEN_FWE1,
};
static struct gpio wacom_gpios[] = {
[GPIO_PEN_LDO_EN] = {
.flags = GPIOF_OUT_INIT_HIGH,
.label = "PEN_LDO_EN",
},
[GPIO_PEN_IRQ] = {
.flags = GPIOF_IN,
.label = "PEN_IRQ_1.8V",
},
[GPIO_PEN_PDCT] = {
.flags = GPIOF_IN,
.label = "PEN_PDCT_1.8V",
},
[GPIO_PEN_DETECT] = {
.flags = GPIOF_IN,
.label = "PEN_DETECT",
},
[GPIO_PEN_FWE1] = {
.flags = GPIOF_OUT_INIT_LOW,
.label = "PEN_FWE1_1.8V",
},
};
void wacom_power_on(bool on)
{
if (on != gpio_get_value(wacom_gpios[GPIO_PEN_LDO_EN].gpio))
gpio_set_value(wacom_gpios[GPIO_PEN_LDO_EN].gpio, on);
}
static struct wacom_platform_data wacom_pdata = {
.x_invert = false,
.y_invert = false,
.xy_switch = false,
.boot_on = true,
.boot_addr = 0x09,
.binary_fw_path = "wacom/n5100.fw",
.file_fw_path = "/sdcard/firmware/wacom_firm.bin",
.fw_version = 0x338,
.fw_checksum = {0x1F, 0xF9, 0xE6, 0x18, 0x6A},
.power = wacom_power_on,
};
static struct i2c_board_info kona_i2c10_boardinfo[] __initdata = {
{
I2C_BOARD_INFO(WACNAME, 0x56),
.platform_data = &wacom_pdata,
},
};
static void __init kona_wacom_gpio_init(void)
{
int i, n = ARRAY_SIZE(wacom_gpios);
for (i = 0; i < n; i++)
wacom_gpios[i].gpio =
omap_muxtbl_get_gpio_by_name(wacom_gpios[i].label);
if (system_rev < 5)
n--;
else if (system_rev < 4)
n -= 2;
if (gpio_request_array(wacom_gpios, n) < 0)
pr_err("wacom: gpio_request failed.");
kona_i2c10_boardinfo[0].irq =
gpio_to_irq(wacom_gpios[GPIO_PEN_IRQ].gpio);
wacom_pdata.gpio_pendct = wacom_gpios[GPIO_PEN_PDCT].gpio;
wacom_pdata.gpio_pen_insert = wacom_gpios[GPIO_PEN_DETECT].gpio;
wacom_pdata.gpio_pen_fwe1 = wacom_gpios[GPIO_PEN_FWE1].gpio;
}
static void __init kona_input_wacom_init(void)
{
kona_wacom_gpio_init();
i2c_register_board_info(10, kona_i2c10_boardinfo,
ARRAY_SIZE(kona_i2c10_boardinfo));
}
static void touch_dvfs_handler_init(void)
{
int ret;
INIT_WORK(&dvfs_data.dvfs_work, touch_dvfs_work);
ret = input_register_handler(&touch_dvfs_handler);
if (ret < 0)
pr_err("tsp: failed to register touch dvfs handler\n");
}
void __init omap4_kona_input_init(void)
{
unsigned int board_type;
kona_input_keyboard_init();
kona_input_tsp_init();
board_type = omap4_kona_get_board_type();
if (board_type == SEC_MACHINE_KONA_WACOM
|| board_type == SEC_MACHINE_KONA_WACOM_WIFI)
kona_input_wacom_init();
touch_dvfs_handler_init();
}
| CyanogenMod/android_kernel_samsung_espresso10 | arch/arm/mach-omap2/board-kona-input.c | C | gpl-2.0 | 14,375 |
#!/bin/bash
rm -rf _public
node_modules/.bin/brunch build -o
| Lucafp/panemcoin | scripts/production.sh | Shell | gpl-2.0 | 62 |
// Aseprite
// Copyright (C) 2001-2015 David Capello
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
#ifndef APP_UI_PALETTE_POPUP_H_INCLUDED
#define APP_UI_PALETTE_POPUP_H_INCLUDED
#pragma once
#include "app/ui/palettes_listbox.h"
#include "ui/popup_window.h"
namespace ui {
class Button;
class View;
}
namespace app {
namespace gen {
class PalettePopup;
}
class PalettePopup : public ui::PopupWindow {
public:
PalettePopup();
void showPopup(const gfx::Rect& bounds);
protected:
void onPalChange(doc::Palette* palette);
void onLoadPal();
void onOpenFolder();
private:
gen::PalettePopup* m_popup;
PalettesListBox m_paletteListBox;
};
} // namespace app
#endif
| Fojar/aseprite | src/app/ui/palette_popup.h | C | gpl-2.0 | 863 |
///////////////////////////////////////////////////////////////////////
// File: genericvector.h
// Description: Generic vector class
// Author: Daria Antonova
// Created: Mon Jun 23 11:26:43 PDT 2008
//
// (C) Copyright 2007, Google Inc.
// Licensed 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.
//
///////////////////////////////////////////////////////////////////////
//
#ifndef TESSERACT_CCUTIL_GENERICVECTOR_H_
#define TESSERACT_CCUTIL_GENERICVECTOR_H_
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include "tesscallback.h"
#include "errcode.h"
#include "helpers.h"
#include "ndminx.h"
#include "serialis.h"
#include "strngs.h"
// Use PointerVector<T> below in preference to GenericVector<T*>, as that
// provides automatic deletion of pointers, [De]Serialize that works, and
// sort that works.
template <typename T>
class GenericVector {
public:
GenericVector() {
init(kDefaultVectorSize);
}
GenericVector(int size, T init_val) {
init(size);
init_to_size(size, init_val);
}
// Copy
GenericVector(const GenericVector& other) {
this->init(other.size());
this->operator+=(other);
}
GenericVector<T> &operator+=(const GenericVector& other);
GenericVector<T> &operator=(const GenericVector& other);
~GenericVector();
// Reserve some memory.
void reserve(int size);
// Double the size of the internal array.
void double_the_size();
// Resizes to size and sets all values to t.
void init_to_size(int size, T t);
// Resizes to size without any initialization.
void resize_no_init(int size) {
reserve(size);
size_used_ = size;
}
// Return the size used.
int size() const {
return size_used_;
}
int size_reserved() const {
return size_reserved_;
}
int length() const {
return size_used_;
}
// Return true if empty.
bool empty() const {
return size_used_ == 0;
}
// Return the object from an index.
T &get(int index) const;
T &back() const;
T &operator[](int index) const;
// Returns the last object and removes it.
T pop_back();
// Return the index of the T object.
// This method NEEDS a compare_callback to be passed to
// set_compare_callback.
int get_index(T object) const;
// Return true if T is in the array
bool contains(T object) const;
// Return true if the index is valid
T contains_index(int index) const;
// Push an element in the end of the array
int push_back(T object);
void operator+=(T t);
// Push an element in the end of the array if the same
// element is not already contained in the array.
int push_back_new(T object);
// Push an element in the front of the array
// Note: This function is O(n)
int push_front(T object);
// Set the value at the given index
void set(T t, int index);
// Insert t at the given index, push other elements to the right.
void insert(T t, int index);
// Removes an element at the given index and
// shifts the remaining elements to the left.
void remove(int index);
// Truncates the array to the given size by removing the end.
// If the current size is less, the array is not expanded.
void truncate(int size) {
if (size < size_used_)
size_used_ = size;
}
// Add a callback to be called to delete the elements when the array took
// their ownership.
void set_clear_callback(TessCallback1<T>* cb);
// Add a callback to be called to compare the elements when needed (contains,
// get_id, ...)
void set_compare_callback(TessResultCallback2<bool, T const &, T const &>* cb);
// Clear the array, calling the clear callback function if any.
// All the owned callbacks are also deleted.
// If you don't want the callbacks to be deleted, before calling clear, set
// the callback to NULL.
void clear();
// Delete objects pointed to by data_[i]
void delete_data_pointers();
// This method clears the current object, then, does a shallow copy of
// its argument, and finally invalidates its argument.
// Callbacks are moved to the current object;
void move(GenericVector<T>* from);
// Read/Write the array to a file. This does _NOT_ read/write the callbacks.
// The callback given must be permanent since they will be called more than
// once. The given callback will be deleted at the end.
// If the callbacks are NULL, then the data is simply read/written using
// fread (and swapping)/fwrite.
// Returns false on error or if the callback returns false.
// DEPRECATED. Use [De]Serialize[Classes] instead.
bool write(FILE* f, TessResultCallback2<bool, FILE*, T const &>* cb) const;
bool read(FILE* f, TessResultCallback3<bool, FILE*, T*, bool>* cb, bool swap);
// Writes a vector of simple types to the given file. Assumes that bitwise
// read/write of T will work. Returns false in case of error.
// TODO(rays) Change all callers to use TFile and remove deprecated methods.
bool Serialize(FILE* fp) const;
bool Serialize(tesseract::TFile* fp) const;
// Reads a vector of simple types from the given file. Assumes that bitwise
// read/write will work with ReverseN according to sizeof(T).
// Returns false in case of error.
// If swap is true, assumes a big/little-endian swap is needed.
bool DeSerialize(bool swap, FILE* fp);
bool DeSerialize(bool swap, tesseract::TFile* fp);
// Writes a vector of classes to the given file. Assumes the existence of
// bool T::Serialize(FILE* fp) const that returns false in case of error.
// Returns false in case of error.
bool SerializeClasses(FILE* fp) const;
bool SerializeClasses(tesseract::TFile* fp) const;
// Reads a vector of classes from the given file. Assumes the existence of
// bool T::Deserialize(bool swap, FILE* fp) that returns false in case of
// error. Also needs T::T() and T::T(constT&), as init_to_size is used in
// this function. Returns false in case of error.
// If swap is true, assumes a big/little-endian swap is needed.
bool DeSerializeClasses(bool swap, FILE* fp);
bool DeSerializeClasses(bool swap, tesseract::TFile* fp);
// Allocates a new array of double the current_size, copies over the
// information from data to the new location, deletes data and returns
// the pointed to the new larger array.
// This function uses memcpy to copy the data, instead of invoking
// operator=() for each element like double_the_size() does.
static T *double_the_size_memcpy(int current_size, T *data) {
T *data_new = new T[current_size * 2];
memcpy(data_new, data, sizeof(T) * current_size);
delete[] data;
return data_new;
}
// Reverses the elements of the vector.
void reverse() {
for (int i = 0; i < size_used_ / 2; ++i)
Swap(&data_[i], &data_[size_used_ - 1 - i]);
}
// Sorts the members of this vector using the less than comparator (cmp_lt),
// which compares the values. Useful for GenericVectors to primitive types.
// Will not work so great for pointers (unless you just want to sort some
// pointers). You need to provide a specialization to sort_cmp to use
// your type.
void sort();
// Sort the array into the order defined by the qsort function comparator.
// The comparator function is as defined by qsort, ie. it receives pointers
// to two Ts and returns negative if the first element is to appear earlier
// in the result and positive if it is to appear later, with 0 for equal.
void sort(int (*comparator)(const void*, const void*)) {
qsort(data_, size_used_, sizeof(*data_), comparator);
}
// Searches the array (assuming sorted in ascending order, using sort()) for
// an element equal to target and returns true if it is present.
// Use binary_search to get the index of target, or its nearest candidate.
bool bool_binary_search(const T& target) const {
int index = binary_search(target);
if (index >= size_used_)
return false;
return data_[index] == target;
}
// Searches the array (assuming sorted in ascending order, using sort()) for
// an element equal to target and returns the index of the best candidate.
// The return value is conceptually the largest index i such that
// data_[i] <= target or 0 if target < the whole vector.
// NOTE that this function uses operator> so really the return value is
// the largest index i such that data_[i] > target is false.
int binary_search(const T& target) const {
int bottom = 0;
int top = size_used_;
do {
int middle = (bottom + top) / 2;
if (data_[middle] > target)
top = middle;
else
bottom = middle;
}
while (top - bottom > 1);
return bottom;
}
// Compact the vector by deleting elements using operator!= on basic types.
// The vector must be sorted.
void compact_sorted() {
if (size_used_ == 0)
return;
// First element is in no matter what, hence the i = 1.
int last_write = 0;
for (int i = 1; i < size_used_; ++i) {
// Finds next unique item and writes it.
if (data_[last_write] != data_[i])
data_[++last_write] = data_[i];
}
// last_write is the index of a valid data cell, so add 1.
size_used_ = last_write + 1;
}
// Compact the vector by deleting elements for which delete_cb returns
// true. delete_cb is a permanent callback and will be deleted.
void compact(TessResultCallback1<bool, int>* delete_cb) {
int new_size = 0;
int old_index = 0;
// Until the callback returns true, the elements stay the same.
while (old_index < size_used_ && !delete_cb->Run(old_index++))
++new_size;
// Now just copy anything else that gets false from delete_cb.
for (; old_index < size_used_; ++old_index) {
if (!delete_cb->Run(old_index)) {
data_[new_size++] = data_[old_index];
}
}
size_used_ = new_size;
delete delete_cb;
}
T dot_product(const GenericVector<T>& other) const {
T result = static_cast<T>(0);
for (int i = MIN(size_used_, other.size_used_) - 1; i >= 0; --i)
result += data_[i] * other.data_[i];
return result;
}
// Returns the index of what would be the target_index_th item in the array
// if the members were sorted, without actually sorting. Members are
// shuffled around, but it takes O(n) time.
// NOTE: uses operator< and operator== on the members.
int choose_nth_item(int target_index) {
// Make sure target_index is legal.
if (target_index < 0)
target_index = 0; // ensure legal
else if (target_index >= size_used_)
target_index = size_used_ - 1;
unsigned int seed = 1;
return choose_nth_item(target_index, 0, size_used_, &seed);
}
// Swaps the elements with the given indices.
void swap(int index1, int index2) {
if (index1 != index2) {
T tmp = data_[index1];
data_[index1] = data_[index2];
data_[index2] = tmp;
}
}
// Returns true if all elements of *this are within the given range.
// Only uses operator<
bool WithinBounds(const T& rangemin, const T& rangemax) const {
for (int i = 0; i < size_used_; ++i) {
if (data_[i] < rangemin || rangemax < data_[i])
return false;
}
return true;
}
protected:
// Internal recursive version of choose_nth_item.
int choose_nth_item(int target_index, int start, int end, unsigned int* seed);
// Init the object, allocating size memory.
void init(int size);
// We are assuming that the object generally placed in thie
// vector are small enough that for efficiency it makes sense
// to start with a larger initial size.
static const int kDefaultVectorSize = 4;
inT32 size_used_;
inT32 size_reserved_;
T* data_;
TessCallback1<T>* clear_cb_;
// Mutable because Run method is not const
mutable TessResultCallback2<bool, T const &, T const &>* compare_cb_;
};
namespace tesseract {
// Function to read a GenericVector<char> from a whole file.
// Returns false on failure.
typedef bool (*FileReader)(const STRING& filename, GenericVector<char>* data);
// Function to write a GenericVector<char> to a whole file.
// Returns false on failure.
typedef bool (*FileWriter)(const GenericVector<char>& data,
const STRING& filename);
// The default FileReader loads the whole file into the vector of char,
// returning false on error.
inline bool LoadDataFromFile(const STRING& filename,
GenericVector<char>* data) {
FILE* fp = fopen(filename.string(), "rb");
if (fp == NULL) return false;
fseek(fp, 0, SEEK_END);
size_t size = ftell(fp);
fseek(fp, 0, SEEK_SET);
// Pad with a 0, just in case we treat the result as a string.
data->init_to_size((int)size + 1, 0);
bool result = fread(&(*data)[0], 1, size, fp) == size;
fclose(fp);
return result;
}
// The default FileWriter writes the vector of char to the filename file,
// returning false on error.
inline bool SaveDataToFile(const GenericVector<char>& data,
const STRING& filename) {
FILE* fp = fopen(filename.string(), "wb");
if (fp == NULL) return false;
bool result =
static_cast<int>(fwrite(&data[0], 1, data.size(), fp)) == data.size();
fclose(fp);
return result;
}
template <typename T>
bool cmp_eq(T const & t1, T const & t2) {
return t1 == t2;
}
// Used by sort()
// return < 0 if t1 < t2
// return 0 if t1 == t2
// return > 0 if t1 > t2
template <typename T>
int sort_cmp(const void* t1, const void* t2) {
const T* a = static_cast<const T *> (t1);
const T* b = static_cast<const T *> (t2);
if (*a < *b) {
return -1;
} else if (*b < *a) {
return 1;
} else {
return 0;
}
}
// Used by PointerVector::sort()
// return < 0 if t1 < t2
// return 0 if t1 == t2
// return > 0 if t1 > t2
template <typename T>
int sort_ptr_cmp(const void* t1, const void* t2) {
const T* a = *reinterpret_cast<T * const *>(t1);
const T* b = *reinterpret_cast<T * const *>(t2);
if (*a < *b) {
return -1;
} else if (*b < *a) {
return 1;
} else {
return 0;
}
}
// Subclass for a vector of pointers. Use in preference to GenericVector<T*>
// as it provides automatic deletion and correct serialization, with the
// corollary that all copy operations are deep copies of the pointed-to objects.
template<typename T>
class PointerVector : public GenericVector<T*> {
public:
PointerVector() : GenericVector<T*>() { }
explicit PointerVector(int size) : GenericVector<T*>(size) { }
~PointerVector() {
// Clear must be called here, even though it is called again by the base,
// as the base will call the wrong clear.
clear();
}
// Copy must be deep, as the pointers will be automatically deleted on
// destruction.
PointerVector(const PointerVector& other) : GenericVector<T*>(other) {
this->init(other.size());
this->operator+=(other);
}
PointerVector<T>& operator+=(const PointerVector& other) {
this->reserve(this->size_used_ + other.size_used_);
for (int i = 0; i < other.size(); ++i) {
this->push_back(new T(*other.data_[i]));
}
return *this;
}
PointerVector<T>& operator=(const PointerVector& other) {
if (&other != this) {
this->truncate(0);
this->operator+=(other);
}
return *this;
}
// Removes an element at the given index and
// shifts the remaining elements to the left.
void remove(int index) {
delete GenericVector<T*>::data_[index];
GenericVector<T*>::remove(index);
}
// Truncates the array to the given size by removing the end.
// If the current size is less, the array is not expanded.
void truncate(int size) {
for (int i = size; i < GenericVector<T*>::size_used_; ++i)
delete GenericVector<T*>::data_[i];
GenericVector<T*>::truncate(size);
}
// Compact the vector by deleting elements for which delete_cb returns
// true. delete_cb is a permanent callback and will be deleted.
void compact(TessResultCallback1<bool, const T*>* delete_cb) {
int new_size = 0;
int old_index = 0;
// Until the callback returns true, the elements stay the same.
while (old_index < GenericVector<T*>::size_used_ &&
!delete_cb->Run(GenericVector<T*>::data_[old_index++]))
++new_size;
// Now just copy anything else that gets false from delete_cb.
for (; old_index < GenericVector<T*>::size_used_; ++old_index) {
if (!delete_cb->Run(GenericVector<T*>::data_[old_index])) {
GenericVector<T*>::data_[new_size++] =
GenericVector<T*>::data_[old_index];
} else {
delete GenericVector<T*>::data_[old_index];
}
}
GenericVector<T*>::size_used_ = new_size;
delete delete_cb;
}
// Clear the array, calling the clear callback function if any.
// All the owned callbacks are also deleted.
// If you don't want the callbacks to be deleted, before calling clear, set
// the callback to NULL.
void clear() {
GenericVector<T*>::delete_data_pointers();
GenericVector<T*>::clear();
}
// Writes a vector of (pointers to) classes to the given file. Assumes the
// existence of bool T::Serialize(FILE*) const that returns false in case of
// error. There is no Serialize for simple types, as you would have a
// normal GenericVector of those.
// Returns false in case of error.
bool Serialize(FILE* fp) const {
inT32 used = GenericVector<T*>::size_used_;
if (fwrite(&used, sizeof(used), 1, fp) != 1) return false;
for (int i = 0; i < used; ++i) {
inT8 non_null = GenericVector<T*>::data_[i] != NULL;
if (fwrite(&non_null, sizeof(non_null), 1, fp) != 1) return false;
if (non_null && !GenericVector<T*>::data_[i]->Serialize(fp)) return false;
}
return true;
}
bool Serialize(TFile* fp) const {
inT32 used = GenericVector<T*>::size_used_;
if (fp->FWrite(&used, sizeof(used), 1) != 1) return false;
for (int i = 0; i < used; ++i) {
inT8 non_null = GenericVector<T*>::data_[i] != NULL;
if (fp->FWrite(&non_null, sizeof(non_null), 1) != 1) return false;
if (non_null && !GenericVector<T*>::data_[i]->Serialize(fp)) return false;
}
return true;
}
// Reads a vector of (pointers to) classes to the given file. Assumes the
// existence of bool T::DeSerialize(bool, Tfile*) const that returns false in
// case of error. There is no Serialize for simple types, as you would have a
// normal GenericVector of those.
// If swap is true, assumes a big/little-endian swap is needed.
// Also needs T::T(), as new T is used in this function.
// Returns false in case of error.
bool DeSerialize(bool swap, FILE* fp) {
inT32 reserved;
if (fread(&reserved, sizeof(reserved), 1, fp) != 1) return false;
if (swap) Reverse32(&reserved);
GenericVector<T*>::reserve(reserved);
truncate(0);
for (int i = 0; i < reserved; ++i) {
inT8 non_null;
if (fread(&non_null, sizeof(non_null), 1, fp) != 1) return false;
T* item = NULL;
if (non_null) {
item = new T;
if (!item->DeSerialize(swap, fp)) {
delete item;
return false;
}
this->push_back(item);
} else {
// Null elements should keep their place in the vector.
this->push_back(NULL);
}
}
return true;
}
bool DeSerialize(bool swap, TFile* fp) {
inT32 reserved;
if (fp->FRead(&reserved, sizeof(reserved), 1) != 1) return false;
if (swap) Reverse32(&reserved);
GenericVector<T*>::reserve(reserved);
truncate(0);
for (int i = 0; i < reserved; ++i) {
inT8 non_null;
if (fp->FRead(&non_null, sizeof(non_null), 1) != 1) return false;
T* item = NULL;
if (non_null) {
item = new T;
if (!item->DeSerialize(swap, fp)) {
delete item;
return false;
}
this->push_back(item);
} else {
// Null elements should keep their place in the vector.
this->push_back(NULL);
}
}
return true;
}
// Sorts the items pointed to by the members of this vector using
// t::operator<().
void sort() {
sort(&sort_ptr_cmp<T>);
}
};
} // namespace tesseract
// A useful vector that uses operator== to do comparisons.
template <typename T>
class GenericVectorEqEq : public GenericVector<T> {
public:
GenericVectorEqEq() {
GenericVector<T>::set_compare_callback(
NewPermanentTessCallback(tesseract::cmp_eq<T>));
}
GenericVectorEqEq(int size) : GenericVector<T>(size) {
GenericVector<T>::set_compare_callback(
NewPermanentTessCallback(tesseract::cmp_eq<T>));
}
};
template <typename T>
void GenericVector<T>::init(int size) {
size_used_ = 0;
size_reserved_ = 0;
data_ = 0;
clear_cb_ = 0;
compare_cb_ = 0;
reserve(size);
}
template <typename T>
GenericVector<T>::~GenericVector() {
clear();
}
// Reserve some memory. If the internal array contains elements, they are
// copied.
template <typename T>
void GenericVector<T>::reserve(int size) {
if (size_reserved_ >= size || size <= 0)
return;
T* new_array = new T[size];
for (int i = 0; i < size_used_; ++i)
new_array[i] = data_[i];
if (data_ != NULL) delete[] data_;
data_ = new_array;
size_reserved_ = size;
}
template <typename T>
void GenericVector<T>::double_the_size() {
if (size_reserved_ == 0) {
reserve(kDefaultVectorSize);
}
else {
reserve(2 * size_reserved_);
}
}
// Resizes to size and sets all values to t.
template <typename T>
void GenericVector<T>::init_to_size(int size, T t) {
reserve(size);
size_used_ = size;
for (int i = 0; i < size; ++i)
data_[i] = t;
}
// Return the object from an index.
template <typename T>
T &GenericVector<T>::get(int index) const {
ASSERT_HOST(index >= 0 && index < size_used_);
return data_[index];
}
template <typename T>
T &GenericVector<T>::operator[](int index) const {
assert(index >= 0 && index < size_used_);
return data_[index];
}
template <typename T>
T &GenericVector<T>::back() const {
ASSERT_HOST(size_used_ > 0);
return data_[size_used_ - 1];
}
// Returns the last object and removes it.
template <typename T>
T GenericVector<T>::pop_back() {
ASSERT_HOST(size_used_ > 0);
return data_[--size_used_];
}
// Return the object from an index.
template <typename T>
void GenericVector<T>::set(T t, int index) {
ASSERT_HOST(index >= 0 && index < size_used_);
data_[index] = t;
}
// Shifts the rest of the elements to the right to make
// space for the new elements and inserts the given element
// at the specified index.
template <typename T>
void GenericVector<T>::insert(T t, int index) {
ASSERT_HOST(index >= 0 && index <= size_used_);
if (size_reserved_ == size_used_)
double_the_size();
for (int i = size_used_; i > index; --i) {
data_[i] = data_[i-1];
}
data_[index] = t;
size_used_++;
}
// Removes an element at the given index and
// shifts the remaining elements to the left.
template <typename T>
void GenericVector<T>::remove(int index) {
ASSERT_HOST(index >= 0 && index < size_used_);
for (int i = index; i < size_used_ - 1; ++i) {
data_[i] = data_[i+1];
}
size_used_--;
}
// Return true if the index is valindex
template <typename T>
T GenericVector<T>::contains_index(int index) const {
return index >= 0 && index < size_used_;
}
// Return the index of the T object.
template <typename T>
int GenericVector<T>::get_index(T object) const {
for (int i = 0; i < size_used_; ++i) {
ASSERT_HOST(compare_cb_ != NULL);
if (compare_cb_->Run(object, data_[i]))
return i;
}
return -1;
}
// Return true if T is in the array
template <typename T>
bool GenericVector<T>::contains(T object) const {
return get_index(object) != -1;
}
// Add an element in the array
template <typename T>
int GenericVector<T>::push_back(T object) {
int index = 0;
if (size_used_ == size_reserved_)
double_the_size();
index = size_used_++;
data_[index] = object;
return index;
}
template <typename T>
int GenericVector<T>::push_back_new(T object) {
int index = get_index(object);
if (index >= 0)
return index;
return push_back(object);
}
// Add an element in the array (front)
template <typename T>
int GenericVector<T>::push_front(T object) {
if (size_used_ == size_reserved_)
double_the_size();
for (int i = size_used_; i > 0; --i)
data_[i] = data_[i-1];
data_[0] = object;
++size_used_;
return 0;
}
template <typename T>
void GenericVector<T>::operator+=(T t) {
push_back(t);
}
template <typename T>
GenericVector<T> &GenericVector<T>::operator+=(const GenericVector& other) {
this->reserve(size_used_ + other.size_used_);
for (int i = 0; i < other.size(); ++i) {
this->operator+=(other.data_[i]);
}
return *this;
}
template <typename T>
GenericVector<T> &GenericVector<T>::operator=(const GenericVector& other) {
if (&other != this) {
this->truncate(0);
this->operator+=(other);
}
return *this;
}
// Add a callback to be called to delete the elements when the array took
// their ownership.
template <typename T>
void GenericVector<T>::set_clear_callback(TessCallback1<T>* cb) {
clear_cb_ = cb;
}
// Add a callback to be called to delete the elements when the array took
// their ownership.
template <typename T>
void GenericVector<T>::set_compare_callback(
TessResultCallback2<bool, T const &, T const &>* cb) {
compare_cb_ = cb;
}
// Clear the array, calling the callback function if any.
template <typename T>
void GenericVector<T>::clear() {
if (size_reserved_ > 0) {
if (clear_cb_ != NULL)
for (int i = 0; i < size_used_; ++i)
clear_cb_->Run(data_[i]);
delete[] data_;
data_ = NULL;
size_used_ = 0;
size_reserved_ = 0;
}
if (clear_cb_ != NULL) {
delete clear_cb_;
clear_cb_ = NULL;
}
if (compare_cb_ != NULL) {
delete compare_cb_;
compare_cb_ = NULL;
}
}
template <typename T>
void GenericVector<T>::delete_data_pointers() {
for (int i = 0; i < size_used_; ++i)
if (data_[i]) {
delete data_[i];
}
}
template <typename T>
bool GenericVector<T>::write(
FILE* f, TessResultCallback2<bool, FILE*, T const &>* cb) const {
if (fwrite(&size_reserved_, sizeof(size_reserved_), 1, f) != 1) return false;
if (fwrite(&size_used_, sizeof(size_used_), 1, f) != 1) return false;
if (cb != NULL) {
for (int i = 0; i < size_used_; ++i) {
if (!cb->Run(f, data_[i])) {
delete cb;
return false;
}
}
delete cb;
} else {
if (fwrite(data_, sizeof(T), size_used_, f) != size_used_) return false;
}
return true;
}
template <typename T>
bool GenericVector<T>::read(FILE* f,
TessResultCallback3<bool, FILE*, T*, bool>* cb,
bool swap) {
inT32 reserved;
if (fread(&reserved, sizeof(reserved), 1, f) != 1) return false;
if (swap) Reverse32(&reserved);
reserve(reserved);
if (fread(&size_used_, sizeof(size_used_), 1, f) != 1) return false;
if (swap) Reverse32(&size_used_);
if (cb != NULL) {
for (int i = 0; i < size_used_; ++i) {
if (!cb->Run(f, data_ + i, swap)) {
delete cb;
return false;
}
}
delete cb;
} else {
if (fread(data_, sizeof(T), size_used_, f) != size_used_) return false;
if (swap) {
for (int i = 0; i < size_used_; ++i)
ReverseN(&data_[i], sizeof(T));
}
}
return true;
}
// Writes a vector of simple types to the given file. Assumes that bitwise
// read/write of T will work. Returns false in case of error.
template <typename T>
bool GenericVector<T>::Serialize(FILE* fp) const {
if (fwrite(&size_used_, sizeof(size_used_), 1, fp) != 1) return false;
if (fwrite(data_, sizeof(*data_), size_used_, fp) != size_used_) return false;
return true;
}
template <typename T>
bool GenericVector<T>::Serialize(tesseract::TFile* fp) const {
if (fp->FWrite(&size_used_, sizeof(size_used_), 1) != 1) return false;
if (fp->FWrite(data_, sizeof(*data_), size_used_) != size_used_) return false;
return true;
}
// Reads a vector of simple types from the given file. Assumes that bitwise
// read/write will work with ReverseN according to sizeof(T).
// Returns false in case of error.
// If swap is true, assumes a big/little-endian swap is needed.
template <typename T>
bool GenericVector<T>::DeSerialize(bool swap, FILE* fp) {
inT32 reserved;
if (fread(&reserved, sizeof(reserved), 1, fp) != 1) return false;
if (swap) Reverse32(&reserved);
reserve(reserved);
size_used_ = reserved;
if (fread(data_, sizeof(T), size_used_, fp) != size_used_) return false;
if (swap) {
for (int i = 0; i < size_used_; ++i)
ReverseN(&data_[i], sizeof(data_[i]));
}
return true;
}
template <typename T>
bool GenericVector<T>::DeSerialize(bool swap, tesseract::TFile* fp) {
inT32 reserved;
if (fp->FRead(&reserved, sizeof(reserved), 1) != 1) return false;
if (swap) Reverse32(&reserved);
reserve(reserved);
size_used_ = reserved;
if (fp->FRead(data_, sizeof(T), size_used_) != size_used_) return false;
if (swap) {
for (int i = 0; i < size_used_; ++i)
ReverseN(&data_[i], sizeof(data_[i]));
}
return true;
}
// Writes a vector of classes to the given file. Assumes the existence of
// bool T::Serialize(FILE* fp) const that returns false in case of error.
// Returns false in case of error.
template <typename T>
bool GenericVector<T>::SerializeClasses(FILE* fp) const {
if (fwrite(&size_used_, sizeof(size_used_), 1, fp) != 1) return false;
for (int i = 0; i < size_used_; ++i) {
if (!data_[i].Serialize(fp)) return false;
}
return true;
}
template <typename T>
bool GenericVector<T>::SerializeClasses(tesseract::TFile* fp) const {
if (fp->FWrite(&size_used_, sizeof(size_used_), 1) != 1) return false;
for (int i = 0; i < size_used_; ++i) {
if (!data_[i].Serialize(fp)) return false;
}
return true;
}
// Reads a vector of classes from the given file. Assumes the existence of
// bool T::Deserialize(bool swap, FILE* fp) that returns false in case of
// error. Also needs T::T() and T::T(constT&), as init_to_size is used in
// this function. Returns false in case of error.
// If swap is true, assumes a big/little-endian swap is needed.
template <typename T>
bool GenericVector<T>::DeSerializeClasses(bool swap, FILE* fp) {
uinT32 reserved;
if (fread(&reserved, sizeof(reserved), 1, fp) != 1) return false;
if (swap) Reverse32(&reserved);
T empty;
init_to_size(reserved, empty);
for (int i = 0; i < reserved; ++i) {
if (!data_[i].DeSerialize(swap, fp)) return false;
}
return true;
}
template <typename T>
bool GenericVector<T>::DeSerializeClasses(bool swap, tesseract::TFile* fp) {
uinT32 reserved;
if (fp->FRead(&reserved, sizeof(reserved), 1) != 1) return false;
if (swap) Reverse32(&reserved);
T empty;
init_to_size(reserved, empty);
for (int i = 0; i < reserved; ++i) {
if (!data_[i].DeSerialize(swap, fp)) return false;
}
return true;
}
// This method clear the current object, then, does a shallow copy of
// its argument, and finally invalidates its argument.
template <typename T>
void GenericVector<T>::move(GenericVector<T>* from) {
this->clear();
this->data_ = from->data_;
this->size_reserved_ = from->size_reserved_;
this->size_used_ = from->size_used_;
this->compare_cb_ = from->compare_cb_;
this->clear_cb_ = from->clear_cb_;
from->data_ = NULL;
from->clear_cb_ = NULL;
from->compare_cb_ = NULL;
from->size_used_ = 0;
from->size_reserved_ = 0;
}
template <typename T>
void GenericVector<T>::sort() {
sort(&tesseract::sort_cmp<T>);
}
// Internal recursive version of choose_nth_item.
// The algorithm used comes from "Algorithms" by Sedgewick:
// http://books.google.com/books/about/Algorithms.html?id=idUdqdDXqnAC
// The principle is to choose a random pivot, and move everything less than
// the pivot to its left, and everything greater than the pivot to the end
// of the array, then recurse on the part that contains the desired index, or
// just return the answer if it is in the equal section in the middle.
// The random pivot guarantees average linear time for the same reason that
// n times vector::push_back takes linear time on average.
// target_index, start and and end are all indices into the full array.
// Seed is a seed for rand_r for thread safety purposes. Its value is
// unimportant as the random numbers do not affect the result except
// between equal answers.
template <typename T>
int GenericVector<T>::choose_nth_item(int target_index, int start, int end,
unsigned int* seed) {
// Number of elements to process.
int num_elements = end - start;
// Trivial cases.
if (num_elements <= 1)
return start;
if (num_elements == 2) {
if (data_[start] < data_[start + 1]) {
return target_index > start ? start + 1 : start;
} else {
return target_index > start ? start : start + 1;
}
}
// Place the pivot at start.
#ifndef rand_r // _MSC_VER, ANDROID
srand(*seed);
#define rand_r(seed) rand()
#endif // _MSC_VER
int pivot = rand_r(seed) % num_elements + start;
swap(pivot, start);
// The invariant condition here is that items [start, next_lesser) are less
// than the pivot (which is at index next_lesser) and items
// [prev_greater, end) are greater than the pivot, with items
// [next_lesser, prev_greater) being equal to the pivot.
int next_lesser = start;
int prev_greater = end;
for (int next_sample = start + 1; next_sample < prev_greater;) {
if (data_[next_sample] < data_[next_lesser]) {
swap(next_lesser++, next_sample++);
} else if (data_[next_sample] == data_[next_lesser]) {
++next_sample;
} else {
swap(--prev_greater, next_sample);
}
}
// Now the invariant is set up, we recurse on just the section that contains
// the desired index.
if (target_index < next_lesser)
return choose_nth_item(target_index, start, next_lesser, seed);
else if (target_index < prev_greater)
return next_lesser; // In equal bracket.
else
return choose_nth_item(target_index, prev_greater, end, seed);
}
#endif // TESSERACT_CCUTIL_GENERICVECTOR_H_
| kazuyaujihara/osra_vs | tesseract/ccutil/genericvector.h | C | gpl-2.0 | 34,679 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html" charset="UTF-8">
<title>Uses of Class org.apache.commons.math3.geometry.spherical.oned.SubLimitAngle (Apache Commons Math 3.3 API)</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.commons.math3.geometry.spherical.oned.SubLimitAngle (Apache Commons Math 3.3 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><a href="../../../../../../../../org/apache/commons/math3/geometry/spherical/oned/SubLimitAngle.html" title="class in org.apache.commons.math3.geometry.spherical.oned">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 class="aboutLanguage"><em><script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script></em></div>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="../../../../../../../../index.html?org/apache/commons/math3/geometry/spherical/oned/class-use/SubLimitAngle.html" target="_top">Frames</a></li>
<li><a href="SubLimitAngle.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.commons.math3.geometry.spherical.oned.SubLimitAngle" class="title">Uses of Class<br>org.apache.commons.math3.geometry.spherical.oned.SubLimitAngle</h2>
</div>
<div class="classUseContainer">
<ul class="blockList">
<li class="blockList">
<table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing packages, and an explanation">
<caption><span>Packages that use <a href="../../../../../../../../org/apache/commons/math3/geometry/spherical/oned/SubLimitAngle.html" title="class in org.apache.commons.math3.geometry.spherical.oned">SubLimitAngle</a></span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Package</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="#org.apache.commons.math3.geometry.spherical.oned">org.apache.commons.math3.geometry.spherical.oned</a></td>
<td class="colLast">
<div class="block">
This package provides basic geometry components on the 1-sphere.</div>
</td>
</tr>
</tbody>
</table>
</li>
<li class="blockList">
<ul class="blockList">
<li class="blockList"><a name="org.apache.commons.math3.geometry.spherical.oned">
<!-- -->
</a>
<h3>Uses of <a href="../../../../../../../../org/apache/commons/math3/geometry/spherical/oned/SubLimitAngle.html" title="class in org.apache.commons.math3.geometry.spherical.oned">SubLimitAngle</a> in <a href="../../../../../../../../org/apache/commons/math3/geometry/spherical/oned/package-summary.html">org.apache.commons.math3.geometry.spherical.oned</a></h3>
<table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing methods, and an explanation">
<caption><span>Methods in <a href="../../../../../../../../org/apache/commons/math3/geometry/spherical/oned/package-summary.html">org.apache.commons.math3.geometry.spherical.oned</a> that return <a href="../../../../../../../../org/apache/commons/math3/geometry/spherical/oned/SubLimitAngle.html" title="class in org.apache.commons.math3.geometry.spherical.oned">SubLimitAngle</a></span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><code><a href="../../../../../../../../org/apache/commons/math3/geometry/spherical/oned/SubLimitAngle.html" title="class in org.apache.commons.math3.geometry.spherical.oned">SubLimitAngle</a></code></td>
<td class="colLast"><span class="strong">LimitAngle.</span><code><strong><a href="../../../../../../../../org/apache/commons/math3/geometry/spherical/oned/LimitAngle.html#wholeHyperplane()">wholeHyperplane</a></strong>()</code>
<div class="block">Build a region covering the whole hyperplane.</div>
</td>
</tr>
</tbody>
</table>
</li>
</ul>
</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><a href="../../../../../../../../org/apache/commons/math3/geometry/spherical/oned/SubLimitAngle.html" title="class in org.apache.commons.math3.geometry.spherical.oned">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 class="aboutLanguage"><em><script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script></em></div>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="../../../../../../../../index.html?org/apache/commons/math3/geometry/spherical/oned/class-use/SubLimitAngle.html" target="_top">Frames</a></li>
<li><a href="SubLimitAngle.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>Copyright © 2003–2014 <a href="http://www.apache.org/">The Apache Software Foundation</a>. All rights reserved.</small></p>
</body>
</html>
| aryantaheri/openstack-benchmarking | lib/commons-math3-3.3/docs/apidocs/org/apache/commons/math3/geometry/spherical/oned/class-use/SubLimitAngle.html | HTML | gpl-2.0 | 7,606 |
/*
* parrot_neuron.cpp
*
* This file is part of NEST.
*
* Copyright (C) 2004 The NEST Initiative
*
* NEST 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.
*
* NEST 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 NEST. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "exceptions.h"
#include "parrot_neuron.h"
#include "network.h"
#include "dict.h"
#include "integerdatum.h"
#include "doubledatum.h"
#include "dictutils.h"
#include "numerics.h"
#include <limits>
namespace nest
{
parrot_neuron::parrot_neuron()
: Archiving_Node()
{
}
void
parrot_neuron::init_buffers_()
{
B_.n_spikes_.clear(); // includes resize
Archiving_Node::clear_history();
}
void
parrot_neuron::update( Time const& origin, const long_t from, const long_t to )
{
assert( to >= 0 && ( delay ) from < Scheduler::get_min_delay() );
assert( from < to );
for ( long_t lag = from; lag < to; ++lag )
{
const ulong_t current_spikes_n = static_cast< ulong_t >( B_.n_spikes_.get_value( lag ) );
if ( current_spikes_n > 0 )
{
// create a new SpikeEvent, set its multiplicity and send it
SpikeEvent se;
se.set_multiplicity( current_spikes_n );
network()->send( *this, se, lag );
// set the spike times, respecting the multiplicity
for ( ulong_t i = 0; i < current_spikes_n; i++ )
{
set_spiketime( Time::step( origin.get_steps() + lag + 1 ) );
}
}
}
}
void
parrot_neuron::get_status( DictionaryDatum& d ) const
{
def< double >( d, names::t_spike, get_spiketime_ms() );
Archiving_Node::get_status( d );
}
void
parrot_neuron::set_status( const DictionaryDatum& d )
{
Archiving_Node::set_status( d );
}
void
parrot_neuron::handle( SpikeEvent& e )
{
// Repeat only spikes incoming on port 0, port 1 will be ignored
if ( 0 == e.get_rport() )
{
B_.n_spikes_.add_value( e.get_rel_delivery_steps( network()->get_slice_origin() ),
static_cast< double_t >( e.get_multiplicity() ) );
}
}
} // namespace
| magnastrazh/NEUCOGAR | nest/serotonin/research/C/nest-2.10.0/models/parrot_neuron.cpp | C++ | gpl-2.0 | 2,462 |
#text_font {
width: 250px;
}
#text_size {
width: 70px;
}
.mceAddSelectValue {
background-color: #DDDDDD;
}
select, #block_text_indent, #box_width, #box_height, #box_padding_top, #box_padding_right, #box_padding_bottom, #box_padding_left {
width: 70px;
}
#box_margin_top, #box_margin_right, #box_margin_bottom, #box_margin_left, #positioning_width, #positioning_height, #positioning_zindex {
width: 70px;
}
#positioning_placement_top, #positioning_placement_right, #positioning_placement_bottom, #positioning_placement_left {
width: 70px;
}
#positioning_clip_top, #positioning_clip_right, #positioning_clip_bottom, #positioning_clip_left {
width: 70px;
}
.panel_wrapper div.current {
padding-top: 10px;
height: 230px;
}
.delim {
b2ackground-color: #DDDDDD;
border-left: 1px solid gray;
}
.tdelim {
border-bottom: 1px solid gray;
}
#block_display {
width: 145px;
}
#list_type {
width: 115px;
}
.disabled {
background-color: #EEEEEE;
}
#apply {
font-weight: bold;
width: 78px;
height: 21px;
border: 0;
background-image: url('../images/apply_button_bg.gif');
cursor: pointer;
}
| tectronics/fcc | tiny_mce/plugins/style/css/props.css | CSS | gpl-2.0 | 1,173 |
/* Copyright (c) 2002-2012 Croteam Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License 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.
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. */
#if !defined(AFX_WNDDISPLAYTEXTURE_H__4B489BC1_FAD9_11D1_82EA_000000000000__INCLUDED_)
#define AFX_WNDDISPLAYTEXTURE_H__4B489BC1_FAD9_11D1_82EA_000000000000__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// WndDisplayTexture.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CWndDisplayTexture window
class CWndDisplayTexture : public CWnd
{
// Construction
public:
CWndDisplayTexture();
// function that is called when lmb is clicked
inline void SetLeftMouseButtonClicked( void(*pLeftMouseButtonClicked)( PIX pixX, PIX pixY))
{m_pLeftMouseButtonClicked=pLeftMouseButtonClicked;};
// function that is called when lmb is released
inline void SetLeftMouseButtonReleased( void(*pLeftMouseButtonReleased)( PIX pixX, PIX pixY))
{m_pLeftMouseButtonReleased=pLeftMouseButtonReleased;};
// function that is called when rmb is clicked
inline void SetRightMouseButtonClicked( void(*pRightMouseButtonClicked)( PIX pixX, PIX pixY))
{m_pRightMouseButtonClicked=pRightMouseButtonClicked;};
// function that is called when rmb is moved
inline void SetRightMouseButtonMoved( void(*pRightMouseButtonMoved)( PIX pixX, PIX pixY))
{m_pRightMouseButtonMoved=pRightMouseButtonMoved;};
void (*m_pLeftMouseButtonClicked)( PIX pixX, PIX pixY);
void (*m_pLeftMouseButtonReleased)( PIX pixX, PIX pixY);
void (*m_pRightMouseButtonClicked)( PIX pixX, PIX pixY);
void (*m_pRightMouseButtonMoved)( PIX pixX, PIX pixY);
CTextureObject m_toTexture;
CDrawPort *m_pDrawPort;
CViewPort *m_pViewPort;
int m_iTimerID;
BOOL m_bChequeredAlpha;
BOOL m_bForce32;
FLOAT m_fWndTexRatio;
PIX m_pixWinWidth;
PIX m_pixWinHeight;
PIX m_pixWinOffsetU;
PIX m_pixWinOffsetV;
public:
BOOL m_bDrawLine;
PIX m_pixLineStartU;
PIX m_pixLineStartV;
PIX m_pixLineStopU;
PIX m_pixLineStopV;
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CWndDisplayTexture)
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CWndDisplayTexture();
// Generated message map functions
protected:
//{{AFX_MSG(CWndDisplayTexture)
afx_msg void OnDestroy();
afx_msg void OnPaint();
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_WNDDISPLAYTEXTURE_H__4B489BC1_FAD9_11D1_82EA_000000000000__INCLUDED_)
| stevenc99/Serious-Engine | Sources/EngineGui/WndDisplayTexture.h | C | gpl-2.0 | 3,490 |
<?php
/**
* ILS driver test
*
* PHP version 7
*
* Copyright (C) Villanova University 2011.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License 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.
*
* 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
*
* @category VuFind
* @package Tests
* @author Demian Katz <demian.katz@villanova.edu>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org Main Page
*/
namespace VuFindTest\ILS\Driver;
use VuFind\ILS\Driver\Voyager;
/**
* ILS driver test
*
* @category VuFind
* @package Tests
* @author Demian Katz <demian.katz@villanova.edu>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org Main Page
*/
class VoyagerTest extends \VuFindTest\Unit\ILSDriverTestCase
{
/**
* Standard setup method.
*
* @return void
*/
public function setUp()
{
$this->driver = new Voyager(new \VuFind\Date\Converter());
}
}
| samueloph/vufind | module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/VoyagerTest.php | PHP | gpl-2.0 | 1,535 |
<?php
/*
* Author: National Research Council Canada
* Website: http://www.nrc-cnrc.gc.ca/eng/rd/ict/
*
* License: Creative Commons Attribution 3.0 Unported License
* Copyright: Her Majesty the Queen in Right of Canada, 2015
*/
$input_org_abbr = elgg_view('input/text', array(
'name' => 'target_org_abbr',
'value' => $node->abbr,
'id' => 'merge-node-organization-abbreviation-text-input'
));
$hidden_guid = elgg_view('input/hidden', array(
'name' => 'hidden_subject_guid',
'value' => $vars['node_guid']
));
?>
<div>
<?php echo $hidden_guid; ?>
</div>
<div class="form-group">
<label class="col-sm-3" for="merge-node-organization-abbreviation-text-input" style="text-align:right;">
<?php echo elgg_echo('missions_organization:abbreviation_of_the_target_node') . ': '; ?>
</label>
<div class="col-sm-5" style="display:inline-block;">
<?php echo $input_org_abbr; ?>
</div>
</div>
<div>
<?php
echo elgg_view('input/submit', array(
'value' => elgg_echo('missions_organization:merge'),
'class' => 'elgg-button btn btn-primary elgg-button-action',
'style' => 'float:right;'
));
?>
</div> | pscrevs/gcconnex | mod/missions_organization/views/default/forms/missions_organization/merge-node-form.php | PHP | gpl-2.0 | 1,125 |
/**
* Structures and functions for separating a character buffer into lexemes --
* groups of characters. The lexer reads through a buffer of characters
* (themselves typically read from standard input), strips whitespace, and
* breaks them up into logical atoms of character strings which, in turn, may be
* passed on to later processes (such as a tokenizer).
*
* \file lexer.h
*
* \author Justin J. Meza
*
* \date 2010-2012
*/
#ifndef __LEXER_H__
#define __LEXER_H__
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "error.h"
#undef DEBUG
/**
* Stores a lexeme. A lexeme is a group of contiguous characters, stripped of
* surrounding whitespace or other lexemes.
*/
typedef struct {
char *image; /**< The string that identifies the lexeme. */
const char *fname; /**< The name of the file containing the lexeme. */
unsigned int line; /**< The line number the lexeme occurred on. */
} Lexeme;
/**
* Stores a list of lexemes.
*/
typedef struct {
unsigned int num; /**< The number of lexemes stored. */
Lexeme **lexemes; /**< The array of stored lexemes. */
} LexemeList;
/**
* \name Lexeme modifiers
*
* Functions for performing helper tasks.
*/
/**@{*/
Lexeme *createLexeme(char *, const char *, unsigned int);
void deleteLexeme(Lexeme *);
LexemeList *createLexemeList(void);
Lexeme *addLexeme(LexemeList *, Lexeme*);
void deleteLexemeList(LexemeList *);
/**@}*/
/**
* \name Buffer lexer
*
* Generates lexemes from a character buffer.
*/
/**@{*/
LexemeList *scanBuffer(const char *, unsigned int, const char *);
/**@}*/
#endif /* __LEXER_H__ */
| abhishekgahlot/lci | lexer.h | C | gpl-3.0 | 1,632 |
###############################################################################
#cyn.in is an open source Collaborative Knowledge Management Appliance that
#enables teams to seamlessly work together on files, documents and content in
#a secure central environment.
#
#cyn.in v2 an open source appliance is distributed under the GPL v3 license
#along with commercial support options.
#
#cyn.in is a Cynapse Invention.
#
#Copyright (C) 2008 Cynapse India Pvt. Ltd.
#
#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 3 of the License, or any later version and observe
#the Additional Terms applicable to this program and must display appropriate
#legal notices. In accordance with Section 7(b) of the GNU General Public
#License version 3, these Appropriate Legal Notices must retain the display of
#the "Powered by cyn.in" AND "A Cynapse Invention" logos. You should have
#received a copy of the detailed Additional Terms License with this program.
#
#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/>.
#
#You can contact Cynapse at support@cynapse.com with any problems with cyn.in.
#For any queries regarding the licensing, please send your mails to
# legal@cynapse.com
#
#You can also contact Cynapse at:
#802, Building No. 1,
#Dheeraj Sagar, Malad(W)
#Mumbai-400064, India
###############################################################################
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from plone.app.layout.viewlets.common import ViewletBase
from zope.component import getMultiAdapter
class SpaceIconViewlet(ViewletBase):
render = ViewPageTemplateFile('space_icon.pt')
def update(self):
portal_state = getMultiAdapter((self.context, self.request),
name=u'plone_portal_state')
cportal_url = portal_state.portal_url()
current_object = self.context.aq_inner
self.has_space_icon = False
self.space_icon = ""
self.space_url = ""
parentslist = current_object.aq_chain
new_object = None
found = 0
try:
for type in parentslist:
if type.portal_type == 'Space' and type.meta_type == 'Space':
new_object = type
found = 1
if found == 1:
break
except AttributeError:
a = self.space_icon
if new_object <> None:
#implement code here for binding space icon
if new_object.space_icon <> "":
self.space_icon = cportal_url + "/" + new_object.space_icon
else:
self.space_icon = default_space_icon
self.space_url = new_object.absolute_url()
self.has_space_icon = True
else:
self.site_icon = portal_state.portal_url() + "/logo.jpg"
self.site_url = portal_state.portal_url()
self.render = ViewPageTemplateFile('site_logo.pt')
| collective/cyn.in | src/ubify.viewlets/ubify/viewlets/browser/spaceicon.py | Python | gpl-3.0 | 3,414 |
package net.minecraftforge.event.terraingen;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraft.world.gen.layer.GenLayer;
import net.minecraft.world.WorldType;
/**
* WorldTypeEvent is fired when an event involving the world occurs.<br>
* If a method utilizes this {@link Event} as its parameter, the method will
* receive every child event of this class.<br>
* <br>
* {@link #worldType} contains the WorldType of the world this event is occurring in.<br>
* <br>
* All children of this event are fired on the {@link MinecraftForge#TERRAIN_GEN_BUS}.<br>
**/
public class WorldTypeEvent extends Event
{
public final WorldType worldType;
public WorldTypeEvent(WorldType worldType)
{
this.worldType = worldType;
}
/**
* BiomeSize is fired when vanilla Minecraft attempts to generate biomes.<br>
* This event is fired during biome generation in
* GenLayer#initializeAllBiomeGenerators(long, WorldType). <br>
* <br>
* {@link #originalSize} the original size of the Biome. <br>
* {@link #newSize} the new size of the biome. Initially set to the {@link #originalSize}. <br>
* If {@link #newSize} is set to a new value, that value will be used for the Biome size. <br>
* <br>
* This event is not {@link Cancelable}.<br>
* <br>
* This event does not have a result. {@link HasResult} <br>
* <br>
* This event is fired on the {@link MinecraftForge#TERRAIN_GEN_BUS}.<br>
**/
public static class BiomeSize extends WorldTypeEvent
{
public final byte originalSize;
public byte newSize;
public BiomeSize(WorldType worldType, byte original)
{
super(worldType);
originalSize = original;
newSize = original;
}
}
/**
* InitBiomeGens is fired when vanilla Minecraft attempts to initialize the biome generators.<br>
* This event is fired just during biome generator initialization in
* WorldChunkManager#WorldChunkManager(long, WorldType). <br>
* <br>
* {@link #seed} the seed of the world. <br>
* {@link #originalBiomeGens} the array of GenLayers original intended for this Biome generation. <br>
* {@link #newBiomeGens} the array of GenLayers that will now be used for this Biome generation. <br>
* If {@link #newBiomeGens} is set to a new value, that value will be used for the Biome generator. <br>
* <br>
* This event is not {@link Cancelable}.<br>
* <br>
* This event does not have a result. {@link HasResult} <br>
* <br>
* This event is fired on the {@link MinecraftForge#TERRAIN_GEN_BUS}.<br>
**/
public static class InitBiomeGens extends WorldTypeEvent
{
public final long seed;
public final GenLayer[] originalBiomeGens;
public GenLayer[] newBiomeGens;
public InitBiomeGens(WorldType worldType, long seed, GenLayer[] original)
{
super(worldType);
this.seed = seed;
originalBiomeGens = original;
newBiomeGens = original.clone();
}
}
} | Scrik/Cauldron-1 | eclipse/cauldron/src/main/java/net/minecraftforge/event/terraingen/WorldTypeEvent.java | Java | gpl-3.0 | 3,141 |
<?php
/** ---------------------------------------------------------------------
* app/lib/ca/Service/OAIPMHService.php
* ----------------------------------------------------------------------
* CollectiveAccess
* Open-source collections management software
* ----------------------------------------------------------------------
*
* Software by Whirl-i-Gig (http://www.whirl-i-gig.com)
* Copyright 2011-2013 Whirl-i-Gig
*
* For more information visit http://www.CollectiveAccess.org
*
* This program is free software; you may redistribute it and/or modify it under
* the terms of the provided license as published by Whirl-i-Gig
*
* CollectiveAccess is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTIES whatsoever, including any implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* This source code is free and modifiable under the terms of
* GNU General Public License. (http://www.gnu.org/copyleft/gpl.html). See
* the "license.txt" file for details, or visit the CollectiveAccess web site at
* http://www.CollectiveAccess.org
*
* Portions of this code were inspired by and/or based upon the Omeka
* OaiPmhRepository plugin by John Flatness and Yu-Hsun Lin available at
* http://www.omeka.org and licensed under the GNU Public License version 3
*
* @package CollectiveAccess
* @subpackage WebServices
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License version 3
*
* ----------------------------------------------------------------------
*/
/**
*
*/
require_once(__CA_LIB_DIR__."/ca/Service/BaseService.php");
require_once(__CA_LIB_DIR__."/ca/Export/OAIPMH/OaiIdentifier.php");
require_once(__CA_APP_DIR__."/helpers/utilityHelpers.php");
require_once(__CA_APP_DIR__."/helpers/searchHelpers.php");
require_once(__CA_APP_DIR__."/helpers/browseHelpers.php");
require_once(__CA_APP_DIR__."/helpers/accessHelpers.php");
require_once(__CA_MODELS_DIR__."/ca_data_exporters.php");
class OAIPMHService extends BaseService {
const OAI_PMH_NAMESPACE_URI = 'http://www.openarchives.org/OAI/2.0/';
const OAI_PMH_SCHEMA_URI = 'http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd';
const OAI_PMH_PROTOCOL_VERSION = '2.0';
// XML namespace URI for XML schema
const XML_SCHEMA_NAMESPACE_URI = 'http://www.w3.org/2001/XMLSchema-instance';
// =========================
// Error codes
// =========================
const OAI_ERR_BAD_ARGUMENT = 'badArgument';
const OAI_ERR_BAD_RESUMPTION_TOKEN = 'badResumptionToken';
const OAI_ERR_BAD_VERB = 'badVerb';
const OAI_ERR_CANNOT_DISSEMINATE_FORMAT = 'cannotDisseminateFormat';
const OAI_ERR_ID_DOES_NOT_EXIST = 'idDoesNotExist';
const OAI_ERR_NO_RECORDS_MATCH = 'noRecordsMatch';
const OAI_ERR_NO_METADATA_FORMATS = 'noMetadataFormats';
const OAI_ERR_NO_SET_HIERARCHY = 'noSetHierarchy';
// =========================
// Date/time constants
// =========================
/**
* PHP date() format string to produce the required date format.
* Must be used with gmdate() to conform to spec.
*/
const OAI_DATE_FORMAT = 'Y-m-d\TH:i:s\Z';
const DB_DATE_FORMAT = 'Y-m-d H:i:s';
const OAI_DATE_PCRE = "/^\\d{4}\\-\\d{2}\\-\\d{2}$/";
const OAI_DATETIME_PCRE = "/^\\d{4}\\-\\d{2}\\-\\d{2}T\\d{2}\\:\\d{2}\\:\\d{2}Z$/";
const OAI_GRANULARITY_STRING = 'YYYY-MM-DDThh:mm:ssZ';
const OAI_GRANULARITY_DATE = 1;
const OAI_GRANULARITY_DATETIME = 2;
/**
* OAI XML document for output
*/
private $oaiData;
/**
* OAI_provider.conf configuration file instance
*/
private $config;
/**
* Maximum number of items to return is a single list response
*/
private $_listLimit;
/**
* Error flag. Will be true if error occurs.
*/
private $error = false;
/**
* Base url of the provider
*/
private $_baseUrl;
/**
* ca_data_exporters object representing the selected mapping (as soon as it's been selected, i.e. on request)
*/
private $exporter;
/**
* 'target' table name for the current request
*/
private $table;
# -------------------------------------------------------
/**
* Set up OAI service
*
* @param RequestHTTP $po_request The current request
* @param string $ps_provider The identifier for the provider configuration to use when servicing this request
*/
public function __construct($po_request, $ps_provider) {
parent::__construct($this->opo_request);
$this->oaiData = new DomDocument('1.0', 'UTF-8');
$this->oaiData->preserveWhiteSpace = false;
$this->oaiData->formatOutput = true;
$this->oaiData->xmlStandalone = true;
$o_root_node = $this->oaiData->createElementNS(self::OAI_PMH_NAMESPACE_URI, 'OAI-PMH');
$this->oaiData->appendChild($o_root_node);
$o_root_node->setAttributeNS(self::XML_SCHEMA_NAMESPACE_URI, 'xsi:schemaLocation', self::OAI_PMH_NAMESPACE_URI.' '.self::OAI_PMH_SCHEMA_URI);
$responseDate = $this->oaiData->createElement('responseDate', self::unixToUtc(time()));
$o_root_node->appendChild($responseDate);
$this->opo_request = $po_request;
// Get provider configuration info
$this->config = Configuration::load($this->opo_request->config->get('oai_provider_config'));
$this->ops_provider = $ps_provider;
$this->opa_provider_list = $this->config->getAssoc('providers');
if(!is_array($this->opa_provider_info = $this->opa_provider_list[$ps_provider])) {
$this->throwError(self::OAI_ERR_BAD_ARGUMENT, _t("Invalid provider '%1'.", $ps_provider));
}
if (!($vn_limit = (int)$this->opa_provider_info['maxRecordsPerRequest'])) {
if (!($vn_limit = (int)$this->config->get('maxRecordsPerRequest'))) {
$vn_limit = 50;
}
}
$this->_listLimit = $vn_limit;
$this->_baseUrl = $this->config->get('site_host').$this->config->get('ca_url_root').'/service.php/OAI/'.$this->ops_provider;
OaiIdentifier::initializeNamespace($this->opa_provider_info['identiferNamespace']);
}
# -------------------------------------------------------
/**
* OAI request dispatcher
*/
public function dispatch(){
if ($this->error) { // error on __construct
return $this->oaiData;
}
if (!(bool)$this->config->get('enabled')) {
$this->throwError(self::OAI_ERR_CANNOT_DISSEMINATE_FORMAT, _t("OAI provider is not enabled."));
return $this->oaiData;
}
$request = $this->oaiData->createElement('request', $this->_baseUrl);
$this->oaiData->documentElement->appendChild($request);
$va_optional_parameters = $va_required_parameters = array();
if (!($vs_verb = $this->opo_request->getParameter("verb", pString))) {
$this->throwError(self::OAI_ERR_BAD_VERB, _t('No verb specified.'));
return $this->oaiData;
}
if ($vs_resumption_tok = $this->opo_request->getParameter("resumptionToken", pString)) {
$va_required_parameters = array("resumptionToken");
} else {
switch($vs_verb) {
case "Identify":
// no parameters
break;
case "GetRecord":
$va_required_parameters = array("identifier", "metadataPrefix");
break;
case "ListRecords":
$va_required_parameters = array("metadataPrefix");
$va_optional_parameters = array("from", "until", "set");
break;
case "ListIdentifiers":
$va_required_parameters = array("metadataPrefix");
$va_optional_parameters = array("from", "until", "set");
break;
case "ListSets":
// no parameters
break;
case "ListMetadataFormats":
$va_optional_parameters = array("identifier");
break;
default:
$this->throwError(self::OAI_ERR_BAD_VERB, _t('Invalid verb specified.'));
return $this->oaiData;
break;
}
}
if ($this->checkParameters($va_required_parameters, $va_optional_parameters)) {
switch($vs_verb) {
case "Identify":
$this->identify($this->oaiData);
break;
case "GetRecord":
$this->getRecord($this->oaiData);
break;
case "ListRecords":
case "ListIdentifiers":
if ($vs_resumption_tok) {
$this->resumeListResponse($this->oaiData, $vs_resumption_tok);
} else {
$this->initListResponse($this->oaiData);
}
break;
case "ListSets":
$this->listSets($this->oaiData);
break;
case "ListMetadataFormats":
$this->listMetadataFormats($this->oaiData);
break;
default:
// Won't ever get here but you never know :-)
die("invalid verb {$vs_verb}");
break;
}
foreach($_REQUEST as $vs_key => $vs_value) {
$request->setAttribute($vs_key, $vs_value);
}
}
return $this->oaiData;
}
# -------------------------------------------------------
/**
* Responds to Identify OAI verb
*/
private function identify($oaiData) {
if($this->error) {
return;
}
$t_change_log = new ApplicationChangeLog();
// according to the schema, this order of elements
// is required for the response to validate
$elements = array(
'repositoryName' => $this->opa_provider_info['name'],
'baseURL' => $this->_baseUrl,
'protocolVersion' => self::OAI_PMH_PROTOCOL_VERSION,
'adminEmail' => $this->opa_provider_info['admin_email'],
'earliestDatestamp' => self::unixToUtc($t_change_log->getEarliestTimestampForIDs($this->table, null)),
'deletedRecord' => 'transient',
'granularity' => self::OAI_GRANULARITY_STRING
);
$identify = $this->createElementWithChildren($oaiData,$oaiData->documentElement, 'Identify', $elements);
if(extension_loaded('zlib') && ini_get('zlib.output_compression')) {
$gzip = $oaiData->createElement('compression', 'gzip');
$deflate = $oaiData->createElement('compression', 'deflate');
$identify->appendChild($gzip);
$identify->appendChild($deflate);
}
$description = $oaiData->createElement('description');
$identify->appendChild($description);
OaiIdentifier::describeIdentifier($description);
$toolkitDescription = $oaiData->createElement('description');
$identify->appendChild($toolkitDescription);
$this->describeToolkit($oaiData, $toolkitDescription);
}
# -------------------------------------------------------
/**
* Responds to ListMetadataFormats OAI verb
*/
private function listMetadataFormats($oaiData) {
if($ps_identifier = $this->opo_request->getParameter('identifier', pString)) {
if(!$vs_item_id = OaiIdentifier::oaiIdToItem($ps_identifier)) {
$this->throwError(self::OAI_ERR_ID_DOES_NOT_EXIST);
return false;
}
}
$listMetadataFormats = $oaiData->createElement('ListMetadataFormats');
$oaiData->documentElement->appendChild($listMetadataFormats);
foreach($this->opa_provider_info['formats'] as $vs_format => $va_format) {
$elements = array(
'metadataPrefix' => $vs_format,
'schema' => $va_format['schema'],
'metadataNamespace' => $va_format['metadataNamespace'],
);
$this->createElementWithChildren($oaiData, $listMetadataFormats, 'metadataFormat', $elements);
}
}
# -------------------------------------------------------
/**
* Responds to GetRecord OAI verb
*/
private function getRecord($oaiData) {
if($ps_identifier = $this->opo_request->getParameter('identifier', pString)) {
if(!($vs_item_id = OaiIdentifier::oaiIdToItem($ps_identifier))) {
$this->throwError(self::OAI_ERR_ID_DOES_NOT_EXIST, _t('Identifier is empty'));
return false;
}
}
$getRecord = $oaiData->createElement('GetRecord');
$oaiData->documentElement->appendChild($getRecord);
$o_dm = Datamodel::load();
$t_item = $o_dm->getInstanceByTableName($this->table,true);
if (!($t_item->load($vs_item_id))) {
// error - identifier invalid
$this->throwError(self::OAI_ERR_ID_DOES_NOT_EXIST, _t('Identifier is invalid'));
return;
}
$vs_export = ca_data_exporters::exportRecord($this->getMappingCode(),$t_item->getPrimaryKey());
$headerData = array(
'identifier' => OaiIdentifier::itemToOaiId($ps_identifier),
'datestamp' => self::unixToUtc(time()),
);
$exportFragment = $oaiData->createDocumentFragment();
$exportFragment->appendXML($vs_export);
$recordElement = $getRecord->appendChild($oaiData->createElement('record'));
$this->createElementWithChildren($oaiData, $recordElement, 'header', $headerData);
$metadataElement = $oaiData->createElement('metadata');
$metadataElement->appendChild($exportFragment);
$recordElement->appendChild($metadataElement);
}
# -------------------------------------------------------
/**
* Responds to ListSets OAI verb
*/
private function listSets($oaiData) {
$va_access_values = caGetUserAccessValues($this->opo_request, $this->opa_provider_info);
$vb_show_deleted = (bool)$this->opa_provider_info['show_deleted'];
$vb_dont_enforce_access_settings = (bool)$this->opa_provider_info['dont_enforce_access_settings'];
$listSets = $oaiData->createElement('ListSets');
$oaiData->documentElement->appendChild($listSets);
if ($vs_facet_name = $this->opa_provider_info['setFacet']) {
$o_browse = caGetBrowseInstance($this->table);
if (($vs_query = $this->opa_provider_info['query']) && ($vs_query != "*")) {
$o_browse->addCriteria("_search", $vs_query);
}
$o_browse->execute();
$va_facet = $o_browse->getFacet($vs_facet_name,array('checkAccess' => ($vb_dont_enforce_access_settings ? null : $va_access_values)));
foreach($va_facet as $vn_id => $va_info) {
$elements = array(
'setSpec' => $va_info['id'],
'setName' => caEscapeForXml($va_info['label'])
);
$this->createElementWithChildren($this->oaiData, $listSets, 'set', $elements);
}
}
}
# -------------------------------------------------------
/**
* Responds to the ListIdentifiers and ListRecords verbs.
*
* Only called for the initial request in the case of multiple incomplete
* list responses
*
* @uses listResponse()
*/
private function initListResponse($oaiData) {
$from = $this->opo_request->getParameter('from', pString);
$until = $this->opo_request->getParameter('until', pString);
if ($from) { $fromDate = self::utcToDb($from); }
if ($until) { $untilDate = self::utcToDb($until); }
$this->listResponse(
$oaiData,
$this->opo_request->getParameter('verb', pString),
$this->opo_request->getParameter('metadataPrefix', pString),
0,
$this->opo_request->getParameter('set', pString),
$fromDate,
$untilDate
);
}
# -------------------------------------------------------
/**
* Returns the next incomplete list response based on the given resumption
* token.
*
* @param string $token Resumption token
* @uses listResponse()
*/
private function resumeListResponse($oaiData, $token) {
$va_token_info = ExternalCache::fetch($token, 'OAIPMHService');
if(!$va_token_info || ($va_token_info['verb'] != $this->opo_request->getParameter('verb', pString))) {
$this->throwError(self::OAI_ERR_BAD_RESUMPTION_TOKEN);
} else {
$this->listResponse($oaiData,
$va_token_info['verb'],
$va_token_info['metadata_prefix'],
$va_token_info['cursor'],
$va_token_info['set'],
$va_token_info['from'],
$va_token_info['until']);
}
}
# -------------------------------------------------------
/**
* Responds to the two main List verbs, includes resumption and limiting.
*
* @param string $verb OAI-PMH verb for the request
* @param string $metadataPrefix Metadata prefix
* @param int $cursor Offset in response to begin output at
* @param mixed $set Optional set argument
* @param string $from Optional from date argument
* @param string $until Optional until date argument
* @uses createResumptionToken()
*/
private function listResponse($oaiData, $verb, $metadataPrefix, $cursor, $set, $from, $until) {
$listLimit = $this->_listLimit;
$o_dm = Datamodel::load();
// by this point, the mapping code was checked to be valid
$t_instance = $o_dm->getInstanceByTableName($this->table, true);
$vs_pk = $t_instance->primaryKey();
$va_access_values = caGetUserAccessValues($this->opo_request, $this->opa_provider_info);
$vb_show_deleted = (bool)$this->opa_provider_info['show_deleted'];
$vb_dont_enforce_access_settings = (bool)$this->opa_provider_info['dont_enforce_access_settings'];
$vb_dont_cache = (bool)$this->opa_provider_info['dont_cache'];
$vs_table = $t_instance->tableName();
if(!($o_search = caGetSearchInstance($vs_table))) {
$this->throwError(self::OAI_ERR_BAD_ARGUMENT);
return;
}
// Construct date range for from/until if defined
$o_tep = new TimeExpressionParser();
$o_lang_settings = $o_tep->getLanguageSettings();
$vs_conj = array_shift($o_lang_settings->getList("rangeConjunctions"));
$vs_range = ($from && $until) ? "{$from} {$vs_conj} {$until}" : '';
if ($set && $this->opa_provider_info['setFacet']) {
$o_browse = caGetBrowseInstance($this->table);
if (($vs_query = $this->opa_provider_info['query']) && ($vs_query != "*")) {
$o_browse->addCriteria("_search", $vs_query);
}
$o_browse->addCriteria($this->opa_provider_info['setFacet'], $set);
$o_browse->execute(array('showDeleted' => $vb_show_deleted, 'no_cache' => $vb_dont_cache, 'limitToModifiedOn' => $vs_range, 'checkAccess' => $vb_dont_enforce_access_settings ? null : $va_access_values));
$qr_res = $o_browse->getResults();
} else {
$qr_res = $o_search->search(strlen($this->opa_provider_info['query']) ? $this->opa_provider_info['query'] : "*", array('no_cache' => $vb_dont_cache, 'limitToModifiedOn' => $vs_range, 'showDeleted' => $vb_show_deleted, 'checkAccess' => $vb_show_deleted ? null : $va_access_values));
}
if (!$qr_res) {
$this->throwError(self::OAI_ERR_NO_RECORDS_MATCH, _t('Query failed'));
return;
}
$rows = $qr_res->numHits();
if(count($qr_res->numHits()) == 0) {
$this->throwError(self::OAI_ERR_NO_RECORDS_MATCH, _t('No records match the given criteria'));
} else {
$verbElement = $oaiData->createElement($verb);
$oaiData->documentElement->appendChild($verbElement);
$t_change_log = new ApplicationChangeLog();
if ($vb_show_deleted) {
// get list of deleted records
$va_deleted_items = array();
$qr_res->seek($cursor);
$vn_c = 0;
$va_get_deleted_timestamps_for = array();
while($qr_res->nextHit()) {
if ((bool)$qr_res->get("{$vs_table}.deleted")) {
$va_deleted_items[$vs_pk_val = (int)$qr_res->get("{$vs_table}.{$vs_pk}")] = true;
$va_get_deleted_timestamps_for[$vs_pk_val] = true;
} else {
$vn_access = (int)$qr_res->get("{$vs_table}.access");
if (!in_array($vn_access, $va_access_values)) {
$va_deleted_items[(int)$qr_res->get("{$vs_table}.{$vs_pk}")] = true;
}
}
$vn_c++;
if ($vn_c >= $listLimit) { break; }
}
$qr_res->seek(0);
$va_deleted_timestamps = $t_change_log->getDeleteOnTimestampsForIDs($vs_table, array_keys($va_get_deleted_timestamps_for));
}
// Export data using metadata mapping
$va_items = ca_data_exporters::exportRecordsFromSearchResultToArray($this->getMappingCode(),$qr_res,array('start' => $cursor, 'limit' => $listLimit));
if (is_array($va_items) && sizeof($va_items)) {
$va_timestamps = $t_change_log->getLastChangeTimestampsForIDs($vs_table, array_keys($va_items));
foreach($va_items as $vn_id => $vs_item_xml) {
if ($vb_show_deleted && $va_deleted_items[$vn_id]) {
$headerData = array(
'identifier' => OaiIdentifier::itemToOaiId($vn_id),
// TODO: how do we efficiently fish out the date the "access" field was changed to private?
// For now, timestamps for records that are private (as opposed to actually deleted) are just the last modification date
'datestamp' => self::unixToUtc($va_deleted_timestamps[$vn_id]['timestamp'] ? $va_deleted_timestamps[$vn_id]['timestamp'] : $va_timestamps[$vn_id]['timestamp'])
);
if ($verb == 'ListIdentifiers') {
$header = $this->createElementWithChildren($oaiData, $verbElement, 'header', $headerData);
$header->setAttribute("status", "deleted");
} else {
$recordElement = $verbElement->appendChild($oaiData->createElement('record'));
$header = $this->createElementWithChildren($oaiData, $recordElement, 'header', $headerData);
$header->setAttribute("status", "deleted");
}
} else {
$headerData = array(
'identifier' => OaiIdentifier::itemToOaiId($vn_id),
'datestamp' => self::unixToUtc($va_timestamps[$vn_id]['timestamp'])
);
if ($verb == 'ListIdentifiers') {
$this->createElementWithChildren($oaiData, $verbElement, 'header', $headerData);
} else {
$recordElement = $verbElement->appendChild($oaiData->createElement('record'));
$this->createElementWithChildren($oaiData, $recordElement, 'header', $headerData);
$metadataElement = $oaiData->createElement('metadata');
$o_doc_src = DomDocument::loadXML($vs_item_xml);
if($o_doc_src) { // just in case the xml fails to load through DomDocument for some reason (e.g. a bad mapping or very weird characters)
$metadataElement->appendChild($oaiData->importNode($o_doc_src->documentElement, true));
}
$recordElement->appendChild($metadataElement);
}
}
}
}
if($rows > ($cursor + $listLimit)) {
$token = $this->createResumptionToken(
$verb,
$metadataPrefix,
$cursor + $listLimit,
$set,
$from,
$until
);
$tokenElement = $oaiData->createElement('resumptionToken', $token['key']);
$tokenElement->setAttribute('expirationDate',self::unixToUtc($token['expiration']));
$tokenElement->setAttribute('completeListSize', $rows);
$tokenElement->setAttribute('cursor', $cursor);
$verbElement->appendChild($tokenElement);
} else if($cursor != 0) {
$tokenElement = $this->oaiData->createElement('resumptionToken');
$verbElement->appendChild($tokenElement);
}
}
}
# -------------------------------------------------------
/**
* Stores a new resumption token record in the database
*
* @param string $verb OAI-PMH verb for the request
* @param string $metadataPrefix Metadata prefix
* @param int $cursor Offset in response to begin output at
* @param mixed $set Optional set argument
* @param string $from Optional from date argument
* @param string $until Optional until date argument
* @return array resumption token info
*/
private function createResumptionToken($verb, $metadataPrefix, $cursor, $set, $from, $until) {
$va_token_info = array(
'verb' => $verb,
'metadata_prefix' => $metadataPrefix,
'cursor' => $cursor,
'set' => ($set) ? $set : null,
'from' => ($from) ? $from : null,
'until' => ($until) ? $until : null,
'expiration' => time() + ($this->_tokenExpirationTime * 60 )
);
$vs_key = md5(print_r($va_token_info, true).'/'.time().'/'.rand(0, 1000000));
$va_token_info['key'] = $vs_key;
ExternalCache::save($vs_key, $va_token_info, 'OAIPMHService');
return $va_token_info;
}
# -------------------------------------------------------
/**
* Describes OAI provider
*
* @return bool Always returns true
*/
private function describeToolkit($pa_oai_data, $po_parent_element){
$vs_toolkit_namespace = 'http://oai.dlib.vt.edu/OAI/metadata/toolkit';
$vs_toolkit_schema = 'http://oai.dlib.vt.edu/OAI/metadata/toolkit.xsd';
$va_elements = array(
'title' => _t('CollectiveAccess OAI-PMH Service'),
'author' => array(
'name' => 'CollectiveAccess',
'email' => 'info@collectiveaccess.org'
),
'version' => __CollectiveAccess__,
'URL' => 'http://collectiveaccess.org'
);
$o_toolkit = $this->createElementWithChildren($pa_oai_data, $po_parent_element, 'toolkit', $va_elements);
$o_toolkit->setAttribute('xsi:schemaLocation', "$vs_toolkit_namespace $vs_toolkit_schema");
$o_toolkit->setAttribute('xmlns', $vs_toolkit_namespace);
return true;
}
# -------------------------------------------------------
/**
* Creates a new XML element with the specified children
*
* Creates a parent element with the given name, with children with names
* and values as given. Adds the resulting element as a child of the given
* element
*
* @param DomElement $parent Existing parent of all the new nodes.
* @param string $name Name of the new parent element.
* @param array $children Child names and values, as name => value.
* @return DomElement The new tree of elements.
*/
protected function createElementWithChildren($oaiData, $parent, $name, $children) {
$document = $oaiData;
$newElement = $document->createElement($name);
foreach($children as $tag => $value)
{
if (is_array($value)) {
$this->createElementWithChildren($oaiData, $newElement, $tag, $value);
} else {
$newElement->appendChild($document->createElement($tag, $value));
}
}
$parent->appendChild($newElement);
return $newElement;
}
# -------------------------------------------------------
/**
* Creates a parent element with the given name, with text as given.
*
* Adds the resulting element as a child of the given parent node.
*
* @param DomElement $parent Existing parent of all the new nodes.
* @param string $name Name of the new parent element.
* @param string $text Text of the new element.
* @return DomElement The new element.
*/
protected function appendNewElement($parent, $name, $text = null) {
$document = $this->oaiData;
$newElement = $document->createElement($name);
// Use a TextNode, causes escaping of input text
if($text) {
$text = $document->createTextNode($text);
$newElement->appendChild($text);
}
$parent->appendChild($newElement);
return $newElement;
}
# -------------------------------------------------------
/**
* Checks validity of request parameters
*
* @return boolean True if parameters are valid, fase if not.
*/
private function checkParameters($pa_required_parameters, $pa_optional_parameters) {
$pa_required_parameters[] = 'verb';
// Check for duplicate parameters
if($_SERVER['REQUEST_METHOD'] == 'GET' && (urldecode($_SERVER['QUERY_STRING']) != urldecode(http_build_query($_REQUEST)))) {
$this->throwError(self::OAI_ERR_BAD_ARGUMENT, _t("Duplicate parameters in request"));
}
if((!($vs_metadata_prefix = $this->opo_request->getParameter('metadataPrefix', pString))) && ((in_array('metadataPrefix', $pa_required_parameters)) || (in_array('metadataPrefix', $pa_optional_parameters))) && $this->opa_provider_info['default_format']) {
$_REQUEST['metadataPrefix'] = $vs_metadata_prefix = $this->opa_provider_info['default_format'];
$this->opo_request->setParameter('metadataPrefix', $vs_metadata_prefix, 'REQUEST');
}
$va_keys = array_keys($_REQUEST);
foreach(array_diff($pa_required_parameters, $va_keys) as $vs_arg) {
$this->throwError(self::OAI_ERR_BAD_ARGUMENT, _t("Missing required parameter %1", $vs_arg));
}
foreach(array_diff($va_keys, $pa_required_parameters, $pa_optional_parameters) as $vs_arg) {
$this->throwError(self::OAI_ERR_BAD_ARGUMENT, _t("Unknown parameter %1", $vs_arg));
}
$vs_from = $this->opo_request->getParameter('from', pString);
$vs_until = $this->opo_request->getParameter('until', pString);
$vs_from_gran = self::getGranularity($vs_from);
$vs_until_gran = self::getGranularity($vs_until);
if($vs_from && !$vs_from_gran) {
$this->throwError(self::OAI_ERR_BAD_ARGUMENT, _t("Invalid date/time parameter"));
}
if($vs_until && !$vs_until_gran) {
$this->throwError(self::OAI_ERR_BAD_ARGUMENT, _t("Invalid date/time parameter"));
}
if($vs_from && $vs_until && $vs_from_gran != $vs_until_gran) {
$this->throwError(self::OAI_ERR_BAD_ARGUMENT, _t("Date/time parameter of differing granularity"));
}
if(!is_array($this->opa_provider_info['formats'])){
$this->throwError(self::OAI_ERR_CANNOT_DISSEMINATE_FORMAT, _t("Invalid format configuration"));
}
if ($vs_metadata_prefix) {
if(!in_array($vs_metadata_prefix, array_keys($this->opa_provider_info['formats']))){
$this->throwError(self::OAI_ERR_CANNOT_DISSEMINATE_FORMAT, _t("Unknown format %1",$vs_metadata_prefix));
}
}
if($vs_mapping = $this->getMappingCode()){
if($this->exporter = ca_data_exporters::loadExporterByCode($this->getMappingCode())){
if($this->exporter->getSetting('exporter_format') != "XML"){
$this->throwError(self::OAI_ERR_BAD_ARGUMENT, _t("Selected mapping %1 is invalid",$this->getMappingCode()));
}
$this->table = $this->exporter->getAppDatamodel()->getTableName($this->exporter->get('table_num'));
} else {
$this->throwError(self::OAI_ERR_CANNOT_DISSEMINATE_FORMAT, _t("Exporter with code %1 does not exist",$this->getMappingCode()));
}
} else {
$this->throwError(self::OAI_ERR_CANNOT_DISSEMINATE_FORMAT, _t("metadataPrefix or default_format is invalid",$this->getMappingCode()));
}
return !$this->error;
}
# -------------------------------------------------------
/**
* Returns the granularity of the given utcDateTime string. Returns zero
* if the given string is not in utcDateTime format.
*
* @param string $dateTime Time string
* @return int OAI_GRANULARITY_DATE, OAI_GRANULARITY_DATETIME, or zero
*/
static function getGranularity($ps_datetime) {
if(preg_match(self::OAI_DATE_PCRE, $ps_datetime)) {
return self::OAI_GRANULARITY_DATE;
} else if(preg_match(self::OAI_DATETIME_PCRE, $ps_datetime)) {
return self::OAI_GRANULARITY_DATETIME;
} else {
return false;
}
}
# -------------------------------------------------------
/**
* Converts the given Unix timestamp to OAI-PMH's specified ISO 8601 format.
*
* @param int $ps_timestamp Unix timestamp
* @return string Time in ISO 8601 format
*/
static function unixToUtc($ps_timestamp) {
return gmdate(self::OAI_DATE_FORMAT, $ps_timestamp);
}
# -------------------------------------------------------
/**
* Converts the given Unix timestamp to the Omeka DB's datetime format.
*
* @param int $ps_timestamp Unix timestamp
* @return string Time in Omeka DB format
*/
static function unixToDb($ps_timestamp) {
return date(self::DB_DATE_FORMAT, $ps_timestamp);
}
# -------------------------------------------------------
/**
* Converts the given time string to MySQL database format
*
* @param string $databaseTime Database time string
* @return string Time in MySQL DB format
* @uses unixToDb()
*/
static function utcToDb($ps_utc_datetime) {
return self::unixToDb(strtotime($ps_utc_datetime));
}
# -------------------------------------------------------
/**
* Throws an OAI-PMH error on the given response.
*
* @param string $error OAI-PMH error code.
* @param string $message Optional human-readable error message.
*/
public function throwError($error, $message = null) {
$this->error = true;
$errorElement = $this->oaiData->createElement('error', $message);
$this->oaiData->documentElement->appendChild($errorElement);
$errorElement->setAttribute('code', $error);
}
# -------------------------------------------------------
/**
* Responds to GetRecord OAI verb
*/
public function getMappingCode() {
$ps_metadata_prefix = $this->opo_request->getParameter('metadataPrefix', pString);
if(!$ps_metadata_prefix && isset($this->opa_provider_info['default_format'])) {
$ps_metadata_prefix = $this->opa_provider_info['default_format'];
}
if(is_array($this->opa_provider_info['formats'][$ps_metadata_prefix])){
if(isset($this->opa_provider_info['formats'][$ps_metadata_prefix]['mapping'])){
return $this->opa_provider_info['formats'][$ps_metadata_prefix]['mapping'];
}
}
return false;
}
# -------------------------------------------------------
}
?> | MatsWillemsen/pawtucket2 | app/lib/ca/Service/OAIPMHService.php | PHP | gpl-3.0 | 31,780 |
<!--
This file demonstrates how the dojox.wire code can be used to do declarative
wiring of events. Specifically, it shows how you can chain actions together
in a sequence. In this case the setting of a value on one textbox triggers a
copy over to another textbox. That in turn triggers yet another copy to another
text box.
-->
<html>
<head>
<title>Sample Action Chaining</title>
<style type="text/css">
@import "../../../../dijit/themes/tundra/tundra.css";
@import "../../../../dojo/resources/dojo.css";
@import "../../../../dijit/tests/css/dijitTests.css";
@import "../TableContainer.css";
.splitView {
width: 90%;
height: 90%;
border: 1px solid #bfbfbf;
border-collapse: separate;
}
</style>
<script type="text/javascript" src="../../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
<script type="text/javascript">
dojo.require("dojo.parser");
dojo.require("dojox.wire");
dojo.require("dojox.wire.ml.Invocation");
dojo.require("dojox.wire.ml.DataStore");
dojo.require("dojox.wire.ml.Transfer");
dojo.require("dojox.wire.ml.Data");
dojo.require("dijit.form.TextBox");
</script>
</head>
<body class="tundra">
<!-- Layout -->
<font size="3"><b>Demo of Chaining Actions:</b></font><br/><br/>
This demo shows how you can chain actions together to fire in a sequence.
Such as the completion of setting one value on a widget triggers the setting of another value on the widget
<br/>
<br/>
<table>
<tr>
<td>
<div dojoType="dijit.form.TextBox" id="inputField" value="" size="50" intermediateChanges="true"></div>
</td>
</tr>
<tr>
<td>
<div dojoType="dijit.form.TextBox" id="targetField1" value="" disabled="true" size="50"></div>
</td>
</tr>
<tr>
<td>
<div dojoType="dijit.form.TextBox" id="targetField2" value="" disabled="true" size="50"></div>
</td>
</tr>
</table>
<!-------------------------------- Using dojox.wire, declaratively wire up the widgets. --------------------------->
<!--
This is an example of using the declarative data value definition.
These are effectively declarative variables to act as placeholders
for data values.
-->
<div dojoType="dojox.wire.ml.Data"
id="data">
<div dojoType="dojox.wire.ml.DataProperty"
name="tempData"
value="">
</div>
</div>
<!--
Whenever a key is entered into the textbox, copy the value somewhere, then invoke a method on another widget, in this case
on just another text box.
-->
<div dojoType="dojox.wire.ml.Action"
id="action1"
trigger="inputField"
triggerEvent="onChange">
<div dojoType="dojox.wire.ml.Invocation" object="inputField" method="getValue" result="data.tempData"></div>
<div dojoType="dojox.wire.ml.Invocation" id="targetCopy" object="targetField1" method="setValue" parameters="data.tempData"></div>
</div>
<!--
Whenever the primary cloning invocation completes, invoke a secondary cloning action.
-->
<div dojoType="dojox.wire.ml.Action"
id="action2"
trigger="targetCopy"
triggerEvent="onComplete">
<!--
Note that this uses the basic 'property' form of copying the property over and setting it. The Wire
code supports both getX and setX functions of setting a property as well as direct access. It first looks
for the getX/setX functions and if present, uses them. If missing, it will just do direct access. Because
of the standard getValue/setValue API of dijit form widgets, these transfers work really well and are very compact.
-->
<div dojoType="dojox.wire.ml.Transfer" source="targetField1.value" target="targetField2.value"></div>
</div>
</body>
</html>
| bigswitch/snac-nox | src/nox/apps/coreui/base_www/dojo-release-1.2.1/dojox/wire/demos/markup/demo_ActionChaining.html | HTML | gpl-3.0 | 3,657 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MissionPlanner.Maps
{
using System;
using GMap.NET.Projections;
using System.Globalization;
using GMap.NET.MapProviders;
using GMap.NET;
using System.Reflection;
/// <summary>
/// EarthBuilder Custom
/// </summary>
public class MapBox : GMapProvider
{
public static readonly MapBox Instance;
MapBox()
{
}
static MapBox()
{
Instance = new MapBox();
Type mytype = typeof (GMapProviders);
FieldInfo field = mytype.GetField("DbHash", BindingFlags.Static | BindingFlags.NonPublic);
Dictionary<int, GMapProvider> list = (Dictionary<int, GMapProvider>) field.GetValue(Instance);
list.Add(Instance.DbId, Instance);
}
#region GMapProvider Members
readonly Guid id = new Guid("22d6e496-842b-4549-bd6d-8f019e6c019f");
public override Guid Id
{
get { return id; }
}
readonly string name = "MapBox Satellite";
public override string Name
{
get { return name; }
}
GMapProvider[] overlays;
public override GMapProvider[] Overlays
{
get
{
if (overlays == null)
{
overlays = new GMapProvider[] {this};
}
return overlays;
}
}
public override PureProjection Projection
{
get { return MercatorProjection.Instance; }
}
public override PureImage GetTileImage(GPoint pos, int zoom)
{
string url = MakeTileImageUrl(pos, zoom, LanguageStr);
return GetTileImageUsingHttp(url);
}
#endregion
string MakeTileImageUrl(GPoint pos, int zoom, string language)
{
string ret;
ret = string.Format(CultureInfo.InvariantCulture, CustomURL, pos.X, pos.Y, zoom, mapsource, mapkey);
return ret;
}
public static string CustomURL = "http://a.tiles.mapbox.com/v4/{3}/{2}/{0}/{1}.png?access_token={4}";
public object mapsource = "mapbox.satellite";//"digitalglobe.nmghof7o";
public object mapkey = "pk.eyJ1IjoibWVlZSIsImEiOiJoeHpwNzJFIn0.BHJ74PT22hTY4ivnpPZEQA";
//"pk.eyJ1IjoiZGlnaXRhbGdsb2JlIiwiYSI6ImNpampsZ3JtbTAyejV0aG01bW5temdvYmIifQ.Q8pQPkSL9r_f7sOuAnkIBA";
}
} | ArduPilot/MissionPlanner | ExtLibs/Xamarin/Xamarin/Maps/Mapbox.cs | C# | gpl-3.0 | 2,547 |
/* EINA - EFL data type library
* Copyright (C) 2008-2010 Enlightenment Developers:
* Albin "Lutin" Tonnerre <albin.tonnerre@gmail.com>
* Alexandre "diaxen" Becoulet <diaxen@free.fr>
* Andre Dieb <andre.dieb@gmail.com>
* Arnaud de Turckheim "quarium" <quarium@gmail.com>
* Carsten Haitzler <raster@rasterman.com>
* Cedric Bail <cedric.bail@free.fr>
* Corey "atmos" Donohoe <atmos@atmos.org>
* Fabiano Fidêncio <fidencio@profusion.mobi>
* Gustavo Chaves <glima@profusion.mobi>
* Gustavo Sverzut Barbieri <barbieri@gmail.com>
* Jorge Luis "turran" Zapata <jorgeluis.zapata@gmail.com>
* Peter "pfritz" Wehrfritz <peter.wehrfritz@web.de>
* Raphael Kubo da Costa <kubo@profusion.mobi>
* Tilman Sauerbeck <tilman@code-monkey.de>
* Vincent "caro" Torri <vtorri at univ-evry dot fr>
* Tom Hacohen <tom@stosb.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library;
* if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef EINA_H_
#define EINA_H_
/**
* @mainpage Eina
*
* @author Albin "Lutin" Tonnerre <albin.tonnerre@@gmail.com>
* @author Alexandre "diaxen" Becoulet <diaxen@@free.fr>
* @author Andre Dieb <andre.dieb@@gmail.com>
* @author Arnaud de Turckheim "quarium" <quarium@@gmail.com>
* @author Carsten Haitzler <raster@@rasterman.com>
* @author Cedric Bail <cedric.bail@@free.fr>
* @author Corey "atmos" Donohoe <atmos@@atmos.org>
* @author Fabiano Fidêncio <fidencio@@profusion.mobi>
* @author Gustavo Chaves <glima@@profusion.mobi>
* @author Gustavo Sverzut Barbieri <barbieri@@profusion.mobi>
* @author Jorge Luis "turran" Zapata <jorgeluis.zapata@@gmail.com>
* @author Peter "pfritz" Wehrfritz <peter.wehrfritz@@web.de>
* @author Raphael Kubo da Costa <kubo@@profusion.mobi>
* @author Tilman Sauerbeck <tilman@@code-monkey.de>
* @author Vincent "caro" Torri <vtorri at univ-evry dot fr>
* @author Tom Hacohen <tom@@stosb.com>
* @date 2008-2010
*
* @section eina_intro_sec Introduction
*
* The Eina library is a library that implements an API for data types
* in an efficient way. It also provides some useful tools like
* openin shared libraries, errors management, type conversion,
* time accounting and memory pool.
*
* This library is cross-platform and can be compiled and used on
* Linux, BSD, Opensolaris and Windows (XP and CE).
*
* The data types that are available are (see @ref Eina_Data_Types_Group):
* @li @ref Eina_Array_Group standard array of @c void* data.
* @li @ref Eina_Hash_Group standard hash of @c void* data.
* @li @ref Eina_Inline_List_Group list with nodes inlined into user type.
* @li @ref Eina_List_Group standard list of @c void* data.
* @li @ref Eina_Matrixsparse_Group sparse matrix of @c void* data.
* @li @ref Eina_Rbtree_Group red-black tree with nodes inlined into user type.
* @li @ref Eina_String_Buffer_Group mutable string to prepend, insert or append strings to a buffer.
* @li @ref Eina_Stringshare_Group saves memory by sharing read-only string references.
* @li @ref Eina_Tiler_Group split, merge and navigates into 2D tiled regions.
* @li @ref Eina_Trash_Group container of unused but allocated data.
*
* The tools that are available are (see @ref Eina_Tools_Group):
* @li @ref Eina_Benchmark_Group helper to write benchmarks.
* @li @ref Eina_Convert_Group faster conversion from strings to integers, double, etc.
* @li @ref Eina_Counter_Group measures number of calls and their time.
* @li @ref Eina_Error_Group error identifiers.
* @li @ref Eina_File_Group simple file list and path split.
* @li @ref Eina_Lalloc_Group simple lazy allocator.
* @li @ref Eina_Log_Group full-featured logging system.
* @li @ref Eina_Magic_Group provides runtime type checking.
* @li @ref Eina_Memory_Pool_Group abstraction for various memory allocators.
* @li @ref Eina_Module_Group lists, loads and share modules using Eina_Module standard.
* @li @ref Eina_Rectangle_Group rectangle structure and standard manipulation methods.
* @li @ref Eina_Safety_Checks_Group extra checks that will report unexpected conditions and can be disabled at compile time.
* @li @ref Eina_String_Group a set of functions that manages C strings.
*
* @defgroup Eina_Data_Types_Group Data types.
*
* Eina provide easy to use and optimized data types and structures.
*
*
* @defgroup Eina_Containers_Group Containers
*
* Containers are data types that hold data and allow iteration over
* their elements with an @ref Eina_Iterator_Group, or eventually an
* @ref Eina_Accessor_Group.
*
*
* @defgroup Eina_Tools_Group Tools
*
* Eina tools aims to help application development, providing ways to
* make it safer, log errors, manage memory more efficiently and more.
*/
#include <dirent.h>
#ifdef _WIN32
# include <Evil.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#include "eina_config.h"
#include "eina_types.h"
#include "eina_main.h"
#include "eina_fp.h"
#include "eina_rectangle.h"
#include "eina_inlist.h"
#include "eina_file.h"
#include "eina_list.h"
#include "eina_hash.h"
#include "eina_trash.h"
#include "eina_lalloc.h"
#include "eina_module.h"
#include "eina_mempool.h"
#include "eina_error.h"
#include "eina_log.h"
#include "eina_array.h"
#include "eina_binshare.h"
#include "eina_stringshare.h"
#include "eina_ustringshare.h"
#include "eina_magic.h"
#include "eina_counter.h"
#include "eina_rbtree.h"
#include "eina_accessor.h"
#include "eina_iterator.h"
#include "eina_benchmark.h"
#include "eina_convert.h"
#include "eina_cpu.h"
#include "eina_sched.h"
#include "eina_tiler.h"
#include "eina_hamster.h"
#include "eina_matrixsparse.h"
#include "eina_str.h"
#include "eina_strbuf.h"
#include "eina_ustrbuf.h"
#include "eina_unicode.h"
#include "eina_quadtree.h"
#ifdef __cplusplus
}
#endif
#endif /* EINA_H */
| philippe-goetz/gnutls | tests/suite/ecore/src/include/Eina.h | C | gpl-3.0 | 6,469 |
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "sampledPatch.H"
#include "dictionary.H"
#include "polyMesh.H"
#include "polyPatch.H"
#include "volFields.H"
#include "surfaceFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(sampledPatch, 0);
addNamedToRunTimeSelectionTable(sampledSurface, sampledPatch, word, patch);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sampledPatch::sampledPatch
(
const word& name,
const polyMesh& mesh,
const wordReList& patchNames,
const bool triangulate
)
:
sampledSurface(name, mesh),
patchNames_(patchNames),
triangulate_(triangulate),
needsUpdate_(true)
{}
Foam::sampledPatch::sampledPatch
(
const word& name,
const polyMesh& mesh,
const dictionary& dict
)
:
sampledSurface(name, mesh, dict),
patchNames_(dict.lookup("patches")),
triangulate_(dict.lookupOrDefault("triangulate", false)),
needsUpdate_(true)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::sampledPatch::~sampledPatch()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::labelList& Foam::sampledPatch::patchIDs() const
{
if (patchIDs_.empty())
{
patchIDs_ = mesh().boundaryMesh().patchSet
(
patchNames_,
false
).sortedToc();
}
return patchIDs_;
}
bool Foam::sampledPatch::needsUpdate() const
{
return needsUpdate_;
}
bool Foam::sampledPatch::expire()
{
// already marked as expired
if (needsUpdate_)
{
return false;
}
sampledSurface::clearGeom();
MeshStorage::clear();
patchIDs_.clear();
patchIndex_.clear();
patchFaceLabels_.clear();
patchStart_.clear();
needsUpdate_ = true;
return true;
}
bool Foam::sampledPatch::update()
{
if (!needsUpdate_)
{
return false;
}
label sz = 0;
forAll(patchIDs(), i)
{
label patchi = patchIDs()[i];
const polyPatch& pp = mesh().boundaryMesh()[patchi];
if (isA<emptyPolyPatch>(pp))
{
FatalErrorInFunction
<< "Cannot sample an empty patch. Patch " << pp.name()
<< exit(FatalError);
}
sz += pp.size();
}
// For every face (or triangle) the originating patch and local face in the
// patch.
patchIndex_.setSize(sz);
patchFaceLabels_.setSize(sz);
patchStart_.setSize(patchIDs().size());
labelList meshFaceLabels(sz);
sz = 0;
forAll(patchIDs(), i)
{
label patchi = patchIDs()[i];
patchStart_[i] = sz;
const polyPatch& pp = mesh().boundaryMesh()[patchi];
forAll(pp, j)
{
patchIndex_[sz] = i;
patchFaceLabels_[sz] = j;
meshFaceLabels[sz] = pp.start()+j;
sz++;
}
}
indirectPrimitivePatch allPatches
(
IndirectList<face>(mesh().faces(), meshFaceLabels),
mesh().points()
);
this->storedPoints() = allPatches.localPoints();
this->storedFaces() = allPatches.localFaces();
// triangulate uses remapFaces()
// - this is somewhat less efficient since it recopies the faces
// that we just created, but we probably don't want to do this
// too often anyhow.
if (triangulate_)
{
MeshStorage::triangulate();
}
if (debug)
{
print(Pout);
Pout<< endl;
}
needsUpdate_ = false;
return true;
}
// remap action on triangulation
void Foam::sampledPatch::remapFaces(const labelUList& faceMap)
{
// recalculate the cells cut
if (notNull(faceMap) && faceMap.size())
{
MeshStorage::remapFaces(faceMap);
patchFaceLabels_ = labelList
(
UIndirectList<label>(patchFaceLabels_, faceMap)
);
patchIndex_ = labelList
(
UIndirectList<label>(patchIndex_, faceMap)
);
// Redo patchStart.
if (patchIndex_.size() > 0)
{
patchStart_[patchIndex_[0]] = 0;
for (label i = 1; i < patchIndex_.size(); i++)
{
if (patchIndex_[i] != patchIndex_[i-1])
{
patchStart_[patchIndex_[i]] = i;
}
}
}
}
}
Foam::tmp<Foam::scalarField> Foam::sampledPatch::sample
(
const volScalarField& vField
) const
{
return sampleField(vField);
}
Foam::tmp<Foam::vectorField> Foam::sampledPatch::sample
(
const volVectorField& vField
) const
{
return sampleField(vField);
}
Foam::tmp<Foam::sphericalTensorField> Foam::sampledPatch::sample
(
const volSphericalTensorField& vField
) const
{
return sampleField(vField);
}
Foam::tmp<Foam::symmTensorField> Foam::sampledPatch::sample
(
const volSymmTensorField& vField
) const
{
return sampleField(vField);
}
Foam::tmp<Foam::tensorField> Foam::sampledPatch::sample
(
const volTensorField& vField
) const
{
return sampleField(vField);
}
Foam::tmp<Foam::scalarField> Foam::sampledPatch::sample
(
const surfaceScalarField& sField
) const
{
return sampleField(sField);
}
Foam::tmp<Foam::vectorField> Foam::sampledPatch::sample
(
const surfaceVectorField& sField
) const
{
return sampleField(sField);
}
Foam::tmp<Foam::sphericalTensorField> Foam::sampledPatch::sample
(
const surfaceSphericalTensorField& sField
) const
{
return sampleField(sField);
}
Foam::tmp<Foam::symmTensorField> Foam::sampledPatch::sample
(
const surfaceSymmTensorField& sField
) const
{
return sampleField(sField);
}
Foam::tmp<Foam::tensorField> Foam::sampledPatch::sample
(
const surfaceTensorField& sField
) const
{
return sampleField(sField);
}
Foam::tmp<Foam::scalarField> Foam::sampledPatch::interpolate
(
const interpolation<scalar>& interpolator
) const
{
return interpolateField(interpolator);
}
Foam::tmp<Foam::vectorField> Foam::sampledPatch::interpolate
(
const interpolation<vector>& interpolator
) const
{
return interpolateField(interpolator);
}
Foam::tmp<Foam::sphericalTensorField> Foam::sampledPatch::interpolate
(
const interpolation<sphericalTensor>& interpolator
) const
{
return interpolateField(interpolator);
}
Foam::tmp<Foam::symmTensorField> Foam::sampledPatch::interpolate
(
const interpolation<symmTensor>& interpolator
) const
{
return interpolateField(interpolator);
}
Foam::tmp<Foam::tensorField> Foam::sampledPatch::interpolate
(
const interpolation<tensor>& interpolator
) const
{
return interpolateField(interpolator);
}
void Foam::sampledPatch::print(Ostream& os) const
{
os << "sampledPatch: " << name() << " :"
<< " patches:" << patchNames()
<< " faces:" << faces().size()
<< " points:" << points().size();
}
// ************************************************************************* //
| OpenFOAM/OpenFOAM-4.x | src/sampling/sampledSurface/sampledPatch/sampledPatch.C | C++ | gpl-3.0 | 8,197 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>CheckBox Widget Demo</title>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../css/dijitTests.css";
label { margin-right: 0.80em; }
</style>
<!-- required: the default dijit theme: -->
<link id="themeStyles" rel="stylesheet" href="../../../dijit/themes/tundra/tundra.css">
<!-- required: dojo.js -->
<script type="text/javascript" src="../../../dojo/dojo.js"
djConfig="isDebug: true, parseOnLoad: true"></script>
<!-- only needed for alternate theme testing: -->
<script type="text/javascript" src="../_testCommon.js"></script>
<script type="text/javascript">
dojo.require("dijit.dijit"); // optimize: load dijit layer
dojo.require("dijit.form.CheckBox");
dojo.require("dojo.parser"); // find widgets
function outputValues(form){
var str = "";
for(var i=0;i<form.elements.length;i++){
var e = form.elements[i];
if(e.type=="submit"){ break; }
if(e.checked){
str += "submit: name="+e.name+" id="+e.id+" value="+e.value+ "<br>";
}
}
dojo.byId("result").innerHTML = str;
return false;
}
function reportChecked(checked) {
dojo.byId("oncheckedoutput").innerHTML = checked;
}
function reportValueChanged(value) {
dojo.byId("onvaluechangedoutput").innerHTML = value;
}
dojo.addOnLoad(function(){
var params = {id: "cb6", name: "cb6"};
var widget = new dijit.form.CheckBox(params, dojo.byId("checkboxContainer"));
widget.attr('checked', true);
});
</script>
</head>
<body class="tundra">
<h1 class="testTitle">Dijit CheckBox Test</h1>
<p>
Here are some checkboxes. Try clicking, and hovering, tabbing, and using the space bar to select:
</p>
<!-- <form onSubmit="return outputValues(this);"> -->
<!-- to test form submission, you'll need to create an action handler similar to
http://www.utexas.edu/teamweb/cgi-bin/generic.cgi -->
<form>
<input type="checkbox" name="cb0" id="cb0" />
<label for="cb0">cb0: Vanilla (non-dojo) checkbox (for comparison purposes)</label>
<br>
<input name="cb1" id="cb1" value="foo" dojoType="dijit.form.CheckBox" onClick="console.log('clicked cb1')">
<label for="cb1">cb1: normal checkbox, with value=foo, clicking generates console log messages</label>
<button type=button onclick="alert(dijit.byId('cb1').attr('value'));">attr('value')</button>
<br>
<input onChange="reportChecked" name="cb2" id="cb2" dojoType="dijit.form.CheckBox" checked="checked"/>
<label for="cb2">cb2: normal checkbox, with default value, initially turned on.</label>
<span>"onChange" handler updates: [<span id="oncheckedoutput"></span>]</span>
<button type=button onclick="alert(dijit.byId('cb2').attr('value'));">attr('value')</button>
<br>
<input name="cb3" id="cb3" dojoType="dijit.form.CheckBox" disabled="disabled">
<label for="cb3">cb3: disabled checkbox</label>
<br>
<input name="cb4" id="cb4" dojoType="dijit.form.CheckBox" disabled="disabled" checked="checked"/>
<label for="cb4">cb4: disabled checkbox, turned on</label>
<br>
<input name="cb5" id="cb5" type="checkbox" value="" dojoType="dijit.form.CheckBox" onClick="console.log('clicked cb5')">
<label for="cb5">cb5: normal checkbox, with specified value="", clicking generates console log messages</label>
<button type=button onclick="alert(dijit.byId('cb5').attr('value'));">attr('value')</button>
<br>
<div id="checkboxContainer"></div>
<label for="cb6">cb6: instantiated from script</label>
<br>
<input onChange="reportValueChanged" name="cb7" id="cb7" dojoType="dijit.form.CheckBox">
<label for="cb7">cb7: normal checkbox.</label>
<input type="button" onclick='dijit.byId("cb7").attr("disabled",true);' value="disable" />
<input type="button" onclick='dijit.byId("cb7").attr("disabled",false);' value="enable" />
<input type="button" onclick='dijit.byId("cb7").attr("value", "fish");' value='set value to "fish"' />
<input type="button" onclick='dijit.byId("cb7").reset();' value='Reset value+checked' />
<span>"onChange" handler updates: [<span id="onvaluechangedoutput"></span>]</span>
<br>
<p>
Here are some radio buttons. Try clicking, and hovering, tabbing, and arrowing
</p>
<p>
<span>Radio group #1:</span>
<input type="radio" name="g1" id="g1rb1" value="news" dojoType="dijit.form.RadioButton">
<label for="g1rb1">news</label>
<input type="radio" name="g1" id="g1rb2" value="talk" dojoType="dijit.form.RadioButton" checked="checked"/>
<label for="g1rb2">talk</label>
<input type="radio" name="g1" id="g1rb3" value="weather" dojoType="dijit.form.RadioButton" disabled="disabled"/>
<label for="g1rb3">weather</label>
</p>
<p>
<span>Radio group #2: (no default value, and has breaks)</span><br>
<input type="radio" name="g2" id="g2rb1" value="top40" dojoType="dijit.form.RadioButton"/>
<label for="g2rb1">top 40</label><br>
<input type="radio" name="g2" id="g2rb2" value="oldies" dojoType="dijit.form.RadioButton"/>
<label for="g2rb2">oldies</label><br>
<input type="radio" name="g2" id="g2rb3" value="country" dojoType="dijit.form.RadioButton"/>
<label for="g2rb3">country</label><br>
(Note if using keyboard: tab to navigate, and use arrow or space to select)
</p>
<p>
<span>Radio group #3 (native radio buttons):</span>
<input type="radio" name="g3" id="g3rb1" value="rock"/>
<label for="g3rb1">rock</label>
<input type="radio" name="g3" id="g3rb2" value="jazz" disabled="disabled"/>
<label for="g3rb2">jazz</label>
<input type="radio" name="g3" id="g3rb3" value="classical" checked="checked"/>
<label for="g3rb3">classical</label>
</p>
<input type="submit" />
</form>
<div style='border:1px solid gray;'>
These 6 radio buttons have the name but are in separate forms so they can be selected independently.
<form>
1:
<input dojoType="dijit.form.RadioButton" type=radio name='a1' id='b1' value="1"/>b1
<input dojoType="dijit.form.RadioButton" type=radio name='a1' id='b2' value="2"/>b2
</form>
<form>
2:
<input dojoType="dijit.form.RadioButton" type=radio name='a1' id='c1' value="1"/>c1
<input dojoType="dijit.form.RadioButton" type=radio name='a1' id='c2' value="2"/>c2
</form>
<div>
3:
<input dojoType="dijit.form.RadioButton" type=radio name='a1' id='d1' value="1"/>d1
<input dojoType="dijit.form.RadioButton" type=radio name='a1' id='d2' value="2"/>d2
</div>
</div>
<!-- <p>Submitted data:</p>
<div id="result"></div>
-->
</body>
</html>
| emogames-gbr/syndicates | src/public/php/dojo/dijit/tests/form/test_CheckBox.html | HTML | gpl-3.0 | 6,578 |
#region Copyright & License Information
/*
* Copyright 2007-2016 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using System;
using System.Drawing;
using OpenRA.Graphics;
using OpenRA.Widgets;
namespace OpenRA.Mods.Common.Widgets
{
public class CheckboxWidget : ButtonWidget
{
public string CheckType = "checked";
public Func<string> GetCheckType;
public Func<bool> IsChecked = () => false;
public int CheckOffset = 2;
public bool HasPressedState = ChromeMetrics.Get<bool>("CheckboxPressedState");
[ObjectCreator.UseCtor]
public CheckboxWidget(ModData modData)
: base(modData)
{
GetCheckType = () => CheckType;
}
protected CheckboxWidget(CheckboxWidget other)
: base(other)
{
CheckType = other.CheckType;
GetCheckType = other.GetCheckType;
IsChecked = other.IsChecked;
CheckOffset = other.CheckOffset;
HasPressedState = other.HasPressedState;
}
public override void Draw()
{
var disabled = IsDisabled();
var highlighted = IsHighlighted();
var font = Game.Renderer.Fonts[Font];
var color = GetColor();
var colordisabled = GetColorDisabled();
var bgDark = GetContrastColorDark();
var bgLight = GetContrastColorLight();
var rect = RenderBounds;
var text = GetText();
var textSize = font.Measure(text);
var check = new Rectangle(rect.Location, new Size(Bounds.Height, Bounds.Height));
var state = disabled ? "checkbox-disabled" :
highlighted ? "checkbox-highlighted" :
Depressed && HasPressedState ? "checkbox-pressed" :
Ui.MouseOverWidget == this ? "checkbox-hover" :
"checkbox";
WidgetUtils.DrawPanel(state, check);
var position = new float2(rect.Left + rect.Height * 1.5f, RenderOrigin.Y - BaseLine + (Bounds.Height - textSize.Y) / 2);
if (Contrast)
font.DrawTextWithContrast(text, position,
disabled ? colordisabled : color, bgDark, bgLight, 2);
else
font.DrawText(text, position,
disabled ? colordisabled : color);
if (IsChecked() || (Depressed && HasPressedState && !disabled))
{
var checkType = GetCheckType();
if (HasPressedState && (Depressed || disabled))
checkType += "-disabled";
var offset = new float2(rect.Left + CheckOffset, rect.Top + CheckOffset);
WidgetUtils.DrawRGBA(ChromeProvider.GetImage("checkbox-bits", checkType), offset);
}
}
public override Widget Clone() { return new CheckboxWidget(this); }
}
}
| cyanskies/OpenRA | OpenRA.Mods.Common/Widgets/CheckboxWidget.cs | C# | gpl-3.0 | 2,714 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<TITLE>
WMLHelper (POI API Documentation)
</TITLE>
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../stylesheet.css" TITLE="Style">
<SCRIPT type="text/javascript">
function windowTitle()
{
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="WMLHelper (POI API Documentation)";
}
}
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>
</HEAD>
<BODY BGCOLOR="white" onload="windowTitle();">
<HR>
<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/WMLHelper.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
PREV CLASS
<A HREF="../../../../../org/apache/poi/xwpf/model/XMLParagraph.html" title="class in org.apache.poi.xwpf.model"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../../index.html?org/apache/poi/xwpf/model/WMLHelper.html" target="_top"><B>FRAMES</B></A>
<A HREF="WMLHelper.html" target="_top"><B>NO FRAMES</B></A>
<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY: NESTED | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->
<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
org.apache.poi.xwpf.model</FONT>
<BR>
Class WMLHelper</H2>
<PRE>
java.lang.Object
<IMG SRC="../../../../../resources/inherit.gif" ALT="extended by "><B>org.apache.poi.xwpf.model.WMLHelper</B>
</PRE>
<HR>
<DL>
<DT><PRE>public final class <B>WMLHelper</B><DT>extends java.lang.Object</DL>
</PRE>
<P>
<HR>
<P>
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<A NAME="constructor_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Constructor Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../../../../org/apache/poi/xwpf/model/WMLHelper.html#WMLHelper()">WMLHelper</A></B>()</CODE>
<BR>
</TD>
</TR>
</TABLE>
<!-- ========== METHOD SUMMARY =========== -->
<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Method Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static org.openxmlformats.schemas.wordprocessingml.x2006.main.STOnOff.Enum</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/poi/xwpf/model/WMLHelper.html#convertBooleanToSTOnOff(boolean)">convertBooleanToSTOnOff</A></B>(boolean value)</CODE>
<BR>
</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/poi/xwpf/model/WMLHelper.html#convertSTOnOffToBoolean(org.openxmlformats.schemas.wordprocessingml.x2006.main.STOnOff.Enum)">convertSTOnOffToBoolean</A></B>(org.openxmlformats.schemas.wordprocessingml.x2006.main.STOnOff.Enum value)</CODE>
<BR>
</TD>
</TR>
</TABLE>
<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TH ALIGN="left"><B>Methods inherited from class java.lang.Object</B></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</CODE></TD>
</TR>
</TABLE>
<P>
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<A NAME="constructor_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Constructor Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="WMLHelper()"><!-- --></A><H3>
WMLHelper</H3>
<PRE>
public <B>WMLHelper</B>()</PRE>
<DL>
</DL>
<!-- ============ METHOD DETAIL ========== -->
<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Method Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="convertSTOnOffToBoolean(org.openxmlformats.schemas.wordprocessingml.x2006.main.STOnOff.Enum)"><!-- --></A><H3>
convertSTOnOffToBoolean</H3>
<PRE>
public static boolean <B>convertSTOnOffToBoolean</B>(org.openxmlformats.schemas.wordprocessingml.x2006.main.STOnOff.Enum value)</PRE>
<DL>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="convertBooleanToSTOnOff(boolean)"><!-- --></A><H3>
convertBooleanToSTOnOff</H3>
<PRE>
public static org.openxmlformats.schemas.wordprocessingml.x2006.main.STOnOff.Enum <B>convertBooleanToSTOnOff</B>(boolean value)</PRE>
<DL>
<DD><DL>
</DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A>
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/WMLHelper.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
PREV CLASS
<A HREF="../../../../../org/apache/poi/xwpf/model/XMLParagraph.html" title="class in org.apache.poi.xwpf.model"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../../index.html?org/apache/poi/xwpf/model/WMLHelper.html" target="_top"><B>FRAMES</B></A>
<A HREF="WMLHelper.html" target="_top"><B>NO FRAMES</B></A>
<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY: NESTED | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<HR>
<i>Copyright 2017 The Apache Software Foundation or
its licensors, as applicable.</i>
</BODY>
</HTML>
| TonyClark/ESL | lib/poi-3.17/docs/apidocs/org/apache/poi/xwpf/model/WMLHelper.html | HTML | gpl-3.0 | 10,679 |
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "net/base/file_stream_context.h"
#include <utility>
#include "base/debug/alias.h"
#include "base/files/file_path.h"
#include "base/location.h"
#include "base/profiler/scoped_tracker.h"
#include "base/task_runner.h"
#include "base/task_runner_util.h"
#include "base/threading/thread_restrictions.h"
#include "base/values.h"
#include "net/base/net_errors.h"
#if defined(OS_ANDROID)
#include "base/android/content_uri_utils.h"
#endif
namespace net {
namespace {
void CallInt64ToInt(const CompletionCallback& callback, int64_t result) {
callback.Run(static_cast<int>(result));
}
} // namespace
FileStream::Context::IOResult::IOResult()
: result(OK),
os_error(0) {
}
FileStream::Context::IOResult::IOResult(int64_t result,
logging::SystemErrorCode os_error)
: result(result), os_error(os_error) {
}
// static
FileStream::Context::IOResult FileStream::Context::IOResult::FromOSError(
logging::SystemErrorCode os_error) {
return IOResult(MapSystemError(os_error), os_error);
}
// ---------------------------------------------------------------------
FileStream::Context::OpenResult::OpenResult() {
}
FileStream::Context::OpenResult::OpenResult(base::File file,
IOResult error_code)
: file(std::move(file)), error_code(error_code) {}
FileStream::Context::OpenResult::OpenResult(OpenResult&& other)
: file(std::move(other.file)), error_code(other.error_code) {}
FileStream::Context::OpenResult& FileStream::Context::OpenResult::operator=(
OpenResult&& other) {
file = std::move(other.file);
error_code = other.error_code;
return *this;
}
// ---------------------------------------------------------------------
void FileStream::Context::Orphan() {
DCHECK(!orphaned_);
orphaned_ = true;
if (!async_in_progress_) {
CloseAndDelete();
} else if (file_.IsValid()) {
#if defined(OS_WIN)
CancelIo(file_.GetPlatformFile());
#endif
}
}
void FileStream::Context::Open(const base::FilePath& path,
int open_flags,
const CompletionCallback& callback) {
CheckNoAsyncInProgress();
bool posted = base::PostTaskAndReplyWithResult(
task_runner_.get(),
FROM_HERE,
base::Bind(
&Context::OpenFileImpl, base::Unretained(this), path, open_flags),
base::Bind(&Context::OnOpenCompleted, base::Unretained(this), callback));
DCHECK(posted);
last_operation_ = OPEN;
async_in_progress_ = true;
}
void FileStream::Context::Close(const CompletionCallback& callback) {
CheckNoAsyncInProgress();
bool posted = base::PostTaskAndReplyWithResult(
task_runner_.get(),
FROM_HERE,
base::Bind(&Context::CloseFileImpl, base::Unretained(this)),
base::Bind(&Context::OnAsyncCompleted,
base::Unretained(this),
IntToInt64(callback)));
DCHECK(posted);
last_operation_ = CLOSE;
async_in_progress_ = true;
}
void FileStream::Context::Seek(int64_t offset,
const Int64CompletionCallback& callback) {
CheckNoAsyncInProgress();
bool posted = base::PostTaskAndReplyWithResult(
task_runner_.get(), FROM_HERE,
base::Bind(&Context::SeekFileImpl, base::Unretained(this), offset),
base::Bind(&Context::OnAsyncCompleted, base::Unretained(this), callback));
DCHECK(posted);
last_operation_ = SEEK;
async_in_progress_ = true;
}
void FileStream::Context::Flush(const CompletionCallback& callback) {
CheckNoAsyncInProgress();
bool posted = base::PostTaskAndReplyWithResult(
task_runner_.get(),
FROM_HERE,
base::Bind(&Context::FlushFileImpl, base::Unretained(this)),
base::Bind(&Context::OnAsyncCompleted,
base::Unretained(this),
IntToInt64(callback)));
DCHECK(posted);
last_operation_ = FLUSH;
async_in_progress_ = true;
}
bool FileStream::Context::IsOpen() const {
return file_.IsValid();
}
void FileStream::Context::CheckNoAsyncInProgress() const {
if (!async_in_progress_)
return;
LastOperation state = last_operation_;
base::debug::Alias(&state);
// TODO(xunjieli): Once https://crbug.com/487732 is fixed, use
// DCHECK(!async_in_progress_) directly at call places.
CHECK(!async_in_progress_);
}
FileStream::Context::OpenResult FileStream::Context::OpenFileImpl(
const base::FilePath& path, int open_flags) {
#if defined(OS_POSIX)
// Always use blocking IO.
open_flags &= ~base::File::FLAG_ASYNC;
#endif
base::File file;
#if defined(OS_ANDROID)
if (path.IsContentUri()) {
// Check that only Read flags are set.
DCHECK_EQ(open_flags & ~base::File::FLAG_ASYNC,
base::File::FLAG_OPEN | base::File::FLAG_READ);
file = base::OpenContentUriForRead(path);
} else {
#endif // defined(OS_ANDROID)
// FileStream::Context actually closes the file asynchronously,
// independently from FileStream's destructor. It can cause problems for
// users wanting to delete the file right after FileStream deletion. Thus
// we are always adding SHARE_DELETE flag to accommodate such use case.
// TODO(rvargas): This sounds like a bug, as deleting the file would
// presumably happen on the wrong thread. There should be an async delete.
open_flags |= base::File::FLAG_SHARE_DELETE;
file.Initialize(path, open_flags);
#if defined(OS_ANDROID)
}
#endif // defined(OS_ANDROID)
if (!file.IsValid())
return OpenResult(base::File(),
IOResult::FromOSError(logging::GetLastSystemErrorCode()));
return OpenResult(std::move(file), IOResult(OK, 0));
}
FileStream::Context::IOResult FileStream::Context::CloseFileImpl() {
file_.Close();
return IOResult(OK, 0);
}
FileStream::Context::IOResult FileStream::Context::FlushFileImpl() {
if (file_.Flush())
return IOResult(OK, 0);
return IOResult::FromOSError(logging::GetLastSystemErrorCode());
}
void FileStream::Context::OnOpenCompleted(const CompletionCallback& callback,
OpenResult open_result) {
file_ = std::move(open_result.file);
if (file_.IsValid() && !orphaned_)
OnFileOpened();
OnAsyncCompleted(IntToInt64(callback), open_result.error_code);
}
void FileStream::Context::CloseAndDelete() {
// TODO(ananta)
// Replace this CHECK with a DCHECK once we figure out the root cause of
// http://crbug.com/455066
CheckNoAsyncInProgress();
if (file_.IsValid()) {
bool posted = task_runner_.get()->PostTask(
FROM_HERE, base::Bind(base::IgnoreResult(&Context::CloseFileImpl),
base::Owned(this)));
DCHECK(posted);
} else {
delete this;
}
}
Int64CompletionCallback FileStream::Context::IntToInt64(
const CompletionCallback& callback) {
return base::Bind(&CallInt64ToInt, callback);
}
void FileStream::Context::OnAsyncCompleted(
const Int64CompletionCallback& callback,
const IOResult& result) {
// TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed.
tracked_objects::ScopedTracker tracking_profile(
FROM_HERE_WITH_EXPLICIT_FUNCTION(
"477117 FileStream::Context::OnAsyncCompleted"));
// Reset this before Run() as Run() may issue a new async operation. Also it
// should be reset before Close() because it shouldn't run if any async
// operation is in progress.
async_in_progress_ = false;
last_operation_ = NONE;
if (orphaned_)
CloseAndDelete();
else
callback.Run(result.result);
}
} // namespace net
| geminy/aidear | oss/qt/qt-everywhere-opensource-src-5.9.0/qtwebengine/src/3rdparty/chromium/net/base/file_stream_context.cc | C++ | gpl-3.0 | 7,740 |
<!DOCTYPE html>
<meta charset="UTF-8">
<style>
.target {
height: 10px;
background: black;
}
.filler {
height: 10px;
-webkit-flex: 1 1 50%;
flex: 1 1 50%;
}
.replica {
background: green;
}
.container {
display: -webkit-flex;
display: flex;
}
</style>
<body>
<template id="target-template"><div class="container">
<div class="target"></div>
<div class="filler"></div>
</div></template>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/interpolation-test.js"></script>
<script>
assertInterpolation({
property: 'flex',
from: '1 1 0%',
to: '2 2 100%'
}, [
{at: -5, is: '0 0 0%'},
{at: -0.3, is: '0.7 0.7 0%'},
{at: 0, is: '1 1 0%'},
{at: 0.3, is: '1.3 1.3 30%'},
{at: 0.6, is: '1.6 1.6 60%'},
{at: 1, is: '2 2 100%'},
{at: 1.5, is: '2.5 2.5 150%'}
]);
assertInterpolation({
property: 'flex',
from: '0 0 100%',
to: '1 1 100%'
}, [
{at: -0.3, is: '0 0 100%'},
{at: 0, is: '0 0 100%'},
{at: 0.4, is: '0 0 100%'},
{at: 0.6, is: '1 1 100%'},
{at: 1, is: '1 1 100%'},
{at: 1.5, is: '1 1 100%'}
]);
</script>
</body>
| shdevops/JAF-Dice-Roller | www/assets/js/web-animations-js-master/test/blink/interpolation/flex-interpolation.html | HTML | gpl-3.0 | 1,139 |
/*
* Ghost - A honeypot for USB malware
* Copyright (C) 2011-2012 Sebastian Poeplau (sebastian.poeplau@gmail.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 3 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/>.
*
* Additional permission under GNU GPL version 3 section 7
*
* If you modify this Program, or any covered work, by linking or combining
* it with the Windows Driver Frameworks (or a modified version of that library),
* containing parts covered by the terms of the Microsoft Software License Terms -
* Microsoft Windows Driver Kit, the licensors of this Program grant you additional
* permission to convey the resulting work.
*
*/
#ifndef DEVICELIST_H
#define DEVICELIST_H
#include <windows.h>
#include <ghostbus.h>
#include "ghostlib.h"
typedef struct _GHOST_INCIDENT {
int IncidentID;
PGHOST_DRIVE_WRITER_INFO_RESPONSE WriterInfo;
struct _GHOST_INCIDENT *Next;
} GHOST_INCIDENT, *PGHOST_INCIDENT;
typedef struct _GHOST_DEVICE {
int DeviceID;
GhostIncidentCallback Callback;
void *Context;
HANDLE StopEvent;
HANDLE InfoThread;
PGHOST_INCIDENT Incidents;
struct _GHOST_DEVICE *Next;
} GHOST_DEVICE, *PGHOST_DEVICE;
void DeviceListInit();
void DeviceListDestroy();
PGHOST_DEVICE DeviceListCreateDevice(int DeviceID);
void DeviceListAdd(PGHOST_DEVICE Device);
PGHOST_DEVICE DeviceListGet(int DeviceID);
void DeviceListRemove(int DeviceID);
#endif
| voroojax/ghost-usb-honeypot | winxp/GhostLib/devicelist.h | C | gpl-3.0 | 1,945 |
/*
* Cantata
*
* Copyright (c) 2011-2014 Craig Drummond <craig.p.drummond@gmail.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; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "contextwidget.h"
#include "artistview.h"
#include "albumview.h"
#include "songview.h"
#ifdef ENABLE_ONLINE_SERVICES
#include "onlineview.h"
#endif
#include "mpd-interface/song.h"
#include "support/utils.h"
#include "gui/covers.h"
#include "network/networkaccessmanager.h"
#include "gui/settings.h"
#include "wikipediaengine.h"
#include "support/localize.h"
#include "backdropcreator.h"
#include "support/gtkstyle.h"
#include "widgets/playqueueview.h"
#include "widgets/treeview.h"
#include "widgets/thinsplitterhandle.h"
#include <QHBoxLayout>
#include <QGridLayout>
#include <QSpacerItem>
#include <QStylePainter>
#if QT_VERSION >= 0x050000
#include <QUrlQuery>
#include <QJsonDocument>
#else
#include "qjson/parser.h"
#endif
#include <QXmlStreamReader>
#include <QFile>
#include <QWheelEvent>
#include <QApplication>
#ifndef SCALE_CONTEXT_BGND
#include <QDesktopWidget>
#endif
#include <QStackedWidget>
#include <QAction>
#include <QPair>
#include <QImage>
#include <QToolButton>
#include <QButtonGroup>
#include <QWheelEvent>
#include <qglobal.h>
// Exported by QtGui
void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius, bool quality, bool alphaOnly, int transposed = 0);
#include <QDebug>
static bool debugEnabled=false;
#define DBUG if (debugEnabled) qWarning() << metaObject()->className() << __FUNCTION__
void ContextWidget::enableDebug()
{
debugEnabled=true;
}
const QLatin1String ContextWidget::constBackdropFileName("backdrop");
//const QLatin1String ContextWidget::constHtbApiKey(0); // API key required
const QLatin1String ContextWidget::constFanArtApiKey("ee86404cb429fa27ac32a1a3c117b006");
const QLatin1String ContextWidget::constCacheDir("backdrops/");
static QString cacheFileName(const QString &artist, bool createDir)
{
return Utils::cacheDir(ContextWidget::constCacheDir, createDir)+Covers::encodeName(artist)+".jpg";
}
class ViewSelectorButton : public QToolButton
{
public:
ViewSelectorButton(QWidget *p) : QToolButton(p) { }
void paintEvent(QPaintEvent *ev)
{
Q_UNUSED(ev)
QPainter painter(this);
QString txt=text();
txt.replace("&", "");
QFont f(font());
if (isChecked()) {
f.setBold(true);
}
QFontMetrics fm(f);
if (fm.width(txt)>rect().width()) {
txt=fm.elidedText(txt, isRightToLeft() ? Qt::ElideLeft : Qt::ElideRight, rect().width());
}
painter.setFont(f);
painter.setPen(palette().color(!isChecked() && underMouse() ? QPalette::Highlight : QPalette::Text));
painter.drawText(rect(), Qt::AlignCenter, txt);
}
};
static const char *constDataProp="view-data";
ViewSelector::ViewSelector(QWidget *p)
: QWidget(p)
{
group=new QButtonGroup(this);
}
void ViewSelector::addItem(const QString &label, const QVariant &data)
{
QHBoxLayout *l;
if (buttons.isEmpty()) {
l = new QHBoxLayout(this);
l->setMargin(0);
l->setSpacing(0);
} else {
l=static_cast<QHBoxLayout *>(layout());
}
QToolButton *button=new ViewSelectorButton(this);
button->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
button->setAutoRaise(true);
button->setText(label);
button->setCheckable(true);
button->setProperty(constDataProp, data);
connect(button, SIGNAL(toggled(bool)), this, SLOT(buttonActivated()));
buttons.append(button);
group->addButton(button);
l->addWidget(button);
}
void ViewSelector::buttonActivated()
{
QToolButton *button=qobject_cast<QToolButton *>(sender());
if (button && button->isChecked()) {
emit activated(buttons.indexOf(button));
}
}
QVariant ViewSelector::itemData(int index) const
{
return index>=0 && index<buttons.count() ? buttons.at(index)->property(constDataProp) : QVariant();
}
int ViewSelector::currentIndex() const
{
for (int i=0; i<buttons.count(); ++i) {
if (buttons.at(i)->isChecked()) {
return i;
}
}
return -1;
}
void ViewSelector::setCurrentIndex(int index)
{
QFont f(font());
for (int i=0; i<buttons.count(); ++i) {
QToolButton *btn=buttons.at(i);
bool wasChecked=btn->isChecked();
btn->setChecked(i==index);
if (i==index) {
emit activated(i);
} else if (wasChecked) {
btn->setFont(f);
}
}
}
void ViewSelector::wheelEvent(QWheelEvent *ev)
{
int numDegrees = ev->delta() / 8;
int numSteps = numDegrees / 15;
if (numSteps > 0) {
for (int i = 0; i < numSteps; ++i) {
int index=currentIndex();
setCurrentIndex(index==count()-1 ? 0 : index+1);
}
} else {
for (int i = 0; i > numSteps; --i) {
int index=currentIndex();
setCurrentIndex(index==0 ? count()-1 : index-1);
}
}
}
void ViewSelector::paintEvent(QPaintEvent *ev)
{
Q_UNUSED(ev)
}
ThinSplitter::ThinSplitter(QWidget *parent)
: QSplitter(parent)
{
setChildrenCollapsible(true);
setOrientation(Qt::Horizontal);
resetAct=new QAction(i18n("Reset Spacing"), this);
connect(resetAct, SIGNAL(triggered()), this, SLOT(reset()));
setHandleWidth(0);
}
QSplitterHandle * ThinSplitter::createHandle()
{
ThinSplitterHandle *handle=new ThinSplitterHandle(orientation(), this);
handle->addAction(resetAct);
handle->setContextMenuPolicy(Qt::ActionsContextMenu);
handle->setHighlightUnderMouse();
return handle;
}
void ThinSplitter::reset()
{
int totalSize=0;
foreach (int s, sizes()) {
totalSize+=s;
}
QList<int> newSizes;
int size=totalSize/count();
for (int i=0; i<count()-1; ++i) {
newSizes.append(size);
}
newSizes.append(totalSize-(size*newSizes.count()));
setSizes(newSizes);
}
ContextWidget::ContextWidget(QWidget *parent)
: QWidget(parent)
, job(0)
, alwaysCollapsed(false)
, backdropType(PlayQueueView::BI_Cover)
, darkBackground(false)
, useFanArt(0!=constFanArtApiKey.latin1())
, albumCoverBackdrop(false)
, oldIsAlbumCoverBackdrop(false)
, fadeValue(1.0)
, isWide(false)
, stack(0)
#ifdef ENABLE_ONLINE_SERVICES
, onlineContext(0)
#endif
, splitter(0)
, viewSelector(0)
, creator(0)
{
QHBoxLayout *layout=new QHBoxLayout(this);
mainStack=new QStackedWidget(this);
standardContext=new QWidget(mainStack);
mainStack->addWidget(standardContext);
layout->setMargin(0);
layout->addWidget(mainStack);
animator.setPropertyName("fade");
animator.setTargetObject(this);
appLinkColor=QApplication::palette().color(QPalette::Link);
artist = new ArtistView(standardContext);
album = new AlbumView(standardContext);
song = new SongView(standardContext);
minWidth=album->picSize().width()*2.5;
artist->addEventFilter(this);
album->addEventFilter(this);
song->addEventFilter(this);
connect(artist, SIGNAL(findArtist(QString)), this, SIGNAL(findArtist(QString)));
connect(artist, SIGNAL(findAlbum(QString,QString)), this, SIGNAL(findAlbum(QString,QString)));
connect(album, SIGNAL(playSong(QString)), this, SIGNAL(playSong(QString)));
readConfig();
setZoom();
setWide(true);
#ifndef SCALE_CONTEXT_BGND
QDesktopWidget *dw=QApplication::desktop();
if (dw) {
QSize geo=dw->availableGeometry(this).size()-QSize(32, 64);
minBackdropSize=geo;
minBackdropSize.setWidth(((int)(minBackdropSize.width()/32))*32);
minBackdropSize.setHeight(((int)(minBackdropSize.height()/32))*32);
maxBackdropSize=QSize(geo.width()*1.25, geo.height()*1.25);
} else {
minBackdropSize=QSize(Utils::scaleForDpi(1024*3), Utils::scaleForDpi(768*3);
maxBackdropSize=QSize(minBackdropSize.width()*2, minBackdropSize.height()*2);
}
#endif
}
void ContextWidget::setZoom()
{
int zoom=Settings::self()->contextZoom();
if (zoom) {
artist->setZoom(zoom);
album->setZoom(zoom);
song->setZoom(zoom);
}
}
void ContextWidget::setWide(bool w)
{
if (w==isWide) {
return;
}
isWide=w;
if (w) {
if (standardContext->layout()) {
delete standardContext->layout();
}
QHBoxLayout *l=new QHBoxLayout(standardContext);
standardContext->setLayout(l);
int m=l->margin()/2;
l->setMargin(0);
if (stack) {
stack->setVisible(false);
viewSelector->setVisible(false);
stack->removeWidget(artist);
stack->removeWidget(album);
stack->removeWidget(song);
artist->setVisible(true);
album->setVisible(true);
song->setVisible(true);
}
l->addItem(new QSpacerItem(m, m, QSizePolicy::Fixed, QSizePolicy::Fixed));
QByteArray state;
bool resetSplitter=splitter;
if (!splitter) {
splitter=new ThinSplitter(standardContext);
state=Settings::self()->contextSplitterState();
}
l->addWidget(splitter);
artist->setParent(splitter);
album->setParent(splitter);
song->setParent(splitter);
splitter->addWidget(artist);
splitter->addWidget(album);
splitter->setVisible(true);
splitter->addWidget(song);
if (resetSplitter) {
splitter->reset();
} else if (!state.isEmpty()) {
splitter->restoreState(state);
}
} else {
if (standardContext->layout()) {
delete standardContext->layout();
}
QGridLayout *l=new QGridLayout(standardContext);
standardContext->setLayout(l);
int m=l->margin()/2;
l->setMargin(0);
l->setSpacing(0);
if (!stack) {
stack=new QStackedWidget(standardContext);
}
if (!viewSelector) {
viewSelector=new ViewSelector(standardContext);
viewSelector->addItem(i18n("&Artist"), "artist");
viewSelector->addItem(i18n("Al&bum"), "album");
viewSelector->addItem(i18n("&Track"), "song");
viewSelector->setPalette(palette());
connect(viewSelector, SIGNAL(activated(int)), stack, SLOT(setCurrentIndex(int)));
}
if (splitter) {
splitter->setVisible(false);
}
stack->setVisible(true);
viewSelector->setVisible(true);
artist->setParent(stack);
album->setParent(stack);
song->setParent(stack);
stack->addWidget(artist);
stack->addWidget(album);
stack->addWidget(song);
l->addItem(new QSpacerItem(m, m, QSizePolicy::Fixed, QSizePolicy::Fixed), 0, 0, 1, 1);
l->addWidget(stack, 0, 1, 1, 1);
l->addWidget(viewSelector, 1, 0, 1, 2);
QString lastSaved=Settings::self()->contextSlimPage();
if (!lastSaved.isEmpty()) {
for (int i=0; i<viewSelector->count(); ++i) {
if (viewSelector->itemData(i).toString()==lastSaved) {
viewSelector->setCurrentIndex(i);
stack->setCurrentIndex(i);
break;
}
}
}
}
}
void ContextWidget::resizeEvent(QResizeEvent *e)
{
if (isVisible()) {
setWide(width()>minWidth && !alwaysCollapsed);
}
#ifdef SCALE_CONTEXT_BGND
resizeBackdrop();
#endif
QWidget::resizeEvent(e);
}
void ContextWidget::readConfig()
{
int origOpacity=backdropOpacity;
int origBlur=backdropBlur;
QString origCustomBackdropFile=customBackdropFile;
int origType=backdropType;
backdropType=Settings::self()->contextBackdrop();
backdropOpacity=Settings::self()->contextBackdropOpacity();
backdropBlur=Settings::self()->contextBackdropBlur();
customBackdropFile=Settings::self()->contextBackdropFile();
switch (backdropType) {
case PlayQueueView::BI_None:
if (origType!=backdropType && isVisible() && !currentArtist.isEmpty()) {
updateBackdrop(true);
QWidget::update();
}
break;
case PlayQueueView::BI_Cover:
if (origType!=backdropType || backdropOpacity!=origOpacity || backdropBlur!=origBlur) {
if (isVisible() && !currentArtist.isEmpty()) {
updateBackdrop(true);
QWidget::update();
}
}
break;
case PlayQueueView::BI_Custom:
if (origType!=backdropType || backdropOpacity!=origOpacity || backdropBlur!=origBlur || origCustomBackdropFile!=customBackdropFile) {
updateImage(QImage(customBackdropFile), false);
artistsCreatedBackdropsFor.clear();
}
break;
}
useDarkBackground(Settings::self()->contextDarkBackground());
WikipediaEngine::setIntroOnly(Settings::self()->wikipediaIntroOnly());
bool wasCollpased=stack && stack->isVisible();
alwaysCollapsed=Settings::self()->contextAlwaysCollapsed();
if (alwaysCollapsed && !wasCollpased) {
setWide(false);
}
}
void ContextWidget::saveConfig()
{
Settings::self()->saveContextZoom(artist->getZoom());
if (viewSelector) {
Settings::self()->saveContextSlimPage(viewSelector->itemData(viewSelector->currentIndex()).toString());
}
if (splitter) {
Settings::self()->saveContextSplitterState(splitter->saveState());
}
song->saveConfig();
}
void ContextWidget::useDarkBackground(bool u)
{
if (u!=darkBackground) {
darkBackground=u;
QPalette pal=darkBackground ? palette() : parentWidget()->palette();
QColor prevLinkColor;
QColor linkCol;
if (darkBackground) {
QColor dark(32, 32, 32);
QColor light(240, 240, 240);
QColor linkVisited(164, 164, 164);
pal.setColor(QPalette::Window, dark);
pal.setColor(QPalette::Base, dark);
// Dont globally change window/button text - because this can mess up scrollbar buttons
// with some styles (e.g. plastique)
// pal.setColor(QPalette::WindowText, light);
// pal.setColor(QPalette::ButtonText, light);
pal.setColor(QPalette::Text, light);
pal.setColor(QPalette::Link, light);
pal.setColor(QPalette::LinkVisited, linkVisited);
prevLinkColor=appLinkColor;
linkCol=pal.color(QPalette::Link);
} else {
linkCol=appLinkColor;
prevLinkColor=QColor(240, 240, 240);
}
setPalette(pal);
artist->setPal(pal, linkCol, prevLinkColor);
album->setPal(pal, linkCol, prevLinkColor);
song->setPal(pal, linkCol, prevLinkColor);
if (viewSelector) {
viewSelector->setPalette(pal);
}
QWidget::update();
}
}
void ContextWidget::showEvent(QShowEvent *e)
{
setWide(width()>minWidth && !alwaysCollapsed);
if (backdropType) {
updateBackdrop();
}
QWidget::showEvent(e);
}
void ContextWidget::paintEvent(QPaintEvent *e)
{
QPainter p(this);
QRect r(rect());
if (darkBackground) {
p.fillRect(r, palette().background().color());
}
if (backdropType) {
if (!oldBackdrop.isNull()) {
if (!qFuzzyCompare(fadeValue, qreal(0.0))) {
p.setOpacity(1.0-fadeValue);
}
#ifdef SCALE_CONTEXT_BGND
if (!oldIsAlbumCoverBackdrop && oldBackdrop.height()<height()) {
p.drawPixmap(0, (height()-oldBackdrop.height())/2, oldBackdrop);
} else
#endif
p.fillRect(r, QBrush(oldBackdrop));
}
if (!currentBackdrop.isNull()) {
p.setOpacity(fadeValue);
#ifdef SCALE_CONTEXT_BGND
if (!albumCoverBackdrop && currentBackdrop.height()<height()) {
p.drawPixmap(0, (height()-currentBackdrop.height())/2, currentBackdrop);
} else
#endif
p.fillRect(r, QBrush(currentBackdrop));
}
}
if (!darkBackground) {
QWidget::paintEvent(e);
}
}
void ContextWidget::setFade(float value)
{
if (fadeValue!=value) {
fadeValue = value;
if (qFuzzyCompare(fadeValue, qreal(1.0))) {
oldBackdrop=QPixmap();
oldIsAlbumCoverBackdrop=false;
}
QWidget::update();
}
}
void ContextWidget::updateImage(QImage img, bool created)
{
DBUG << img.isNull() << currentBackdrop.isNull();
oldBackdrop=currentBackdrop;
oldIsAlbumCoverBackdrop=albumCoverBackdrop;
currentBackdrop=QPixmap();
animator.stop();
if (img.isNull()) {
backdropAlbums.clear();
}
if (img.isNull() && oldBackdrop.isNull()) {
return;
}
if (!img.isNull()) {
if (backdropOpacity<100) {
img=TreeView::setOpacity(img, (backdropOpacity*1.0)/100.0);
}
if (backdropBlur>0) {
QImage blurred(img.size(), QImage::Format_ARGB32_Premultiplied);
blurred.fill(Qt::transparent);
QPainter painter(&blurred);
qt_blurImage(&painter, img, backdropBlur, true, false);
painter.end();
img = blurred;
}
#ifdef SCALE_CONTEXT_BGND
currentImage=img;
#else
currentBackdrop=QPixmap::fromImage(img);
#endif
}
albumCoverBackdrop=created;
resizeBackdrop();
animator.stop();
if (PlayQueueView::BI_Custom==backdropType || !isVisible()) {
setFade(1.0);
} else {
fadeValue=0.0;
animator.setDuration(250);
animator.setEndValue(1.0);
animator.start();
}
}
void ContextWidget::search()
{
if (song->isVisible()) {
song->search();
}
}
void ContextWidget::update(const Song &s)
{
Song sng=s;
if (sng.isVariousArtists()) {
sng.revertVariousArtists();
}
if (sng.isStandardStream() && sng.artist.isEmpty() && sng.albumartist.isEmpty() && sng.album.isEmpty()) {
int pos=sng.title.indexOf(QLatin1String(" - "));
if (pos>3) {
sng.artist=sng.title.left(pos);
sng.title=sng.title.mid(pos+3);
}
}
if (s.albumArtist()!=currentSong.albumArtist()) {
cancel();
}
#ifdef ENABLE_ONLINE_SERVICES
if (Song::OnlineSvrTrack==sng.type) {
if (!onlineContext) {
QWidget *onlinePage=new QWidget(mainStack);
QHBoxLayout *onlineLayout=new QHBoxLayout(onlinePage);
int m=onlineLayout->margin()/2;
onlineLayout->setMargin(0);
onlineLayout->addItem(new QSpacerItem(m, m, QSizePolicy::Fixed, QSizePolicy::Fixed));
onlineContext=new OnlineView(onlinePage);
onlineLayout->addWidget(onlineContext);
mainStack->addWidget(onlinePage);
}
onlineContext->update(sng);
mainStack->setCurrentIndex(1);
updateArtist=QString();
if (isVisible() && PlayQueueView::BI_Cover==backdropType) {
updateBackdrop();
}
return;
}
mainStack->setCurrentIndex(0);
#endif
artist->update(sng);
album->update(sng);
song->update(sng);
currentSong=s;
updateArtist=Covers::fixArtist(sng.basicArtist());
if (isVisible() && PlayQueueView::BI_Cover==backdropType) {
updateBackdrop();
}
}
bool ContextWidget::eventFilter(QObject *o, QEvent *e)
{
if (QEvent::Wheel==e->type()) {
QWheelEvent *we=static_cast<QWheelEvent *>(e);
if (Qt::ControlModifier==we->modifiers()) {
int numDegrees = static_cast<QWheelEvent *>(e)->delta() / 8;
int numSteps = numDegrees / 15;
artist->setZoom(numSteps);
album->setZoom(numSteps);
song->setZoom(numSteps);
return true;
}
}
return QObject::eventFilter(o, e);
}
void ContextWidget::cancel()
{
if (job) {
job->cancelAndDelete();
job=0;
}
}
void ContextWidget::updateBackdrop(bool force)
{
DBUG << updateArtist << currentArtist << currentSong.file << force;
if (!force && updateArtist==currentArtist) {
return;
}
currentArtist=updateArtist;
backdropAlbums.clear();
if (currentArtist.isEmpty()) {
updateImage(QImage());
QWidget::update();
return;
}
QString encoded=Covers::encodeName(currentArtist);
QStringList names=QStringList() << encoded+"-"+constBackdropFileName+".jpg" << encoded+"-"+constBackdropFileName+".png"
<< constBackdropFileName+".jpg" << constBackdropFileName+".png";
if (!currentSong.isStream()) {
bool localNonMpd=currentSong.file.startsWith(Utils::constDirSep);
QString dirName=localNonMpd ? QString() : MPDConnection::self()->getDetails().dir;
if (localNonMpd || (!dirName.isEmpty() && !dirName.startsWith(QLatin1String("http:/")) && MPDConnection::self()->getDetails().dirReadable)) {
dirName+=Utils::getDir(currentSong.file);
for (int level=0; level<2; ++level) {
foreach (const QString &fileName, names) {
DBUG << "Checking file(1)" << QString(dirName+fileName);
if (QFile::exists(dirName+fileName)) {
QImage img(dirName+fileName);
if (!img.isNull()) {
DBUG << "Got backdrop from" << QString(dirName+fileName);
updateImage(img);
QWidget::update();
return;
}
}
}
QDir d(dirName);
d.cdUp();
dirName=Utils::fixPath(d.absolutePath());
}
}
}
// For various artists tracks, or for non-MPD files, see if we have a matching backdrop in MPD.
// e.g. artist=Wibble, look for $mpdDir/Wibble/backdrop.png
if (currentSong.isVariousArtists() || currentSong.isNonMPD()) {
QString dirName=MPDConnection::self()->getDetails().dirReadable ? MPDConnection::self()->getDetails().dir : QString();
if (!dirName.isEmpty() && !dirName.startsWith(QLatin1String("http:/"))) {
dirName+=currentArtist+Utils::constDirSep;
foreach (const QString &fileName, names) {
DBUG << "Checking file(2)" << QString(dirName+fileName);
if (QFile::exists(dirName+fileName)) {
QImage img(dirName+fileName);
if (!img.isNull()) {
DBUG << "Got backdrop from" << QString(dirName+fileName);
updateImage(img);
QWidget::update();
return;
}
}
}
}
}
QString cacheName=cacheFileName(currentArtist, false);
QImage img(cacheName);
if (img.isNull()) {
getBackdrop();
} else {
DBUG << "Use cache file:" << cacheName;
updateImage(img);
QWidget::update();
}
}
static QString fixArtist(const QString &artist)
{
QString fixed(artist.trimmed());
fixed.remove(QChar('?'));
return fixed;
}
void ContextWidget::getBackdrop()
{
cancel();
if (artistsCreatedBackdropsFor.contains(currentArtist)) {
createBackdrop();
} else if (useFanArt) {
getFanArtBackdrop();
} else {
getDiscoGsImage();
}
}
void ContextWidget::getFanArtBackdrop()
{
// First we need to query musicbrainz to get id
getMusicbrainzId(fixArtist(currentArtist));
}
static const char * constArtistProp="artist-name";
void ContextWidget::getMusicbrainzId(const QString &artist)
{
QUrl url("http://www.musicbrainz.org/ws/2/artist/");
#if QT_VERSION < 0x050000
QUrl &query=url;
#else
QUrlQuery query;
#endif
query.addQueryItem("query", "artist:"+artist);
#if QT_VERSION >= 0x050000
url.setQuery(query);
#endif
job = NetworkAccessManager::self()->get(url);
DBUG << url.toString();
job->setProperty(constArtistProp, artist);
connect(job, SIGNAL(finished()), this, SLOT(musicbrainzResponse()));
}
void ContextWidget::getDiscoGsImage()
{
cancel();
QUrl url;
#if QT_VERSION < 0x050000
QUrl &query=url;
#else
QUrlQuery query;
#endif
url.setScheme("http");
url.setHost("api.discogs.com");
url.setPath("/search");
query.addQueryItem("per_page", QString::number(5));
query.addQueryItem("type", "artist");
query.addQueryItem("q", fixArtist(currentArtist));
query.addQueryItem("f", "json");
#if QT_VERSION >= 0x050000
url.setQuery(query);
#endif
job=NetworkAccessManager::self()->get(url, 5000);
DBUG << url.toString();
connect(job, SIGNAL(finished()), this, SLOT(discoGsResponse()));
}
void ContextWidget::musicbrainzResponse()
{
NetworkJob *reply = getReply(sender());
if (!reply) {
return;
}
DBUG << "status" << reply->error() << reply->errorString();
QString id;
if (reply->ok()) {
bool inSection=false;
QXmlStreamReader doc(reply->actualJob());
while (!doc.atEnd()) {
doc.readNext();
if (doc.isStartElement()) {
if (!inSection && QLatin1String("artist-list")==doc.name()) {
inSection=true;
} if (inSection && QLatin1String("artist")==doc.name()) {
id=doc.attributes().value("id").toString();
break;
}
} else if (doc.isEndElement() && inSection && QLatin1String("artist")==doc.name()) {
break;
}
}
}
if (id.isEmpty()) {
QString artist=reply->property(constArtistProp).toString();
// MusicBrainz does not seem to like AC/DC, but AC DC works - so if we fail with an artist
// containing /, then try with space...
if (!artist.isEmpty() && artist.contains("/")) {
artist=artist.replace("/", " ");
getMusicbrainzId(artist);
} else {
getDiscoGsImage();
}
} else {
QUrl url("http://api.fanart.tv/webservice/artist/"+constFanArtApiKey+"/"+id+"/json/artistbackground/1");
job=NetworkAccessManager::self()->get(url);
DBUG << url.toString();
connect(job, SIGNAL(finished()), this, SLOT(fanArtResponse()));
}
}
void ContextWidget::fanArtResponse()
{
NetworkJob *reply = getReply(sender());
if (!reply) {
return;
}
DBUG << "status" << reply->error() << reply->errorString();
QString url;
if (reply->ok()) {
#if QT_VERSION >= 0x050000
QJsonParseError jsonParseError;
QVariantMap parsed=QJsonDocument::fromJson(reply->readAll(), &jsonParseError).toVariant().toMap();
bool ok=QJsonParseError::NoError==jsonParseError.error;
#else
bool ok=false;
QVariantMap parsed = QJson::Parser().parse(reply->readAll(), &ok).toMap();
#endif
if (ok && !parsed.isEmpty()) {
QVariantMap artist=parsed[parsed.keys().first()].toMap();
if (artist.contains("artistbackground")) {
QVariantList artistbackgrounds=artist["artistbackground"].toList();
if (!artistbackgrounds.isEmpty()) {
QVariantMap artistbackground=artistbackgrounds.first().toMap();
if (artistbackground.contains("url")) {
url=artistbackground["url"].toString();
}
}
}
}
}
if (url.isEmpty()) {
getDiscoGsImage();
} else {
job=NetworkAccessManager::self()->get(QUrl(url));
DBUG << url;
connect(job, SIGNAL(finished()), this, SLOT(downloadResponse()));
}
}
static bool matchesArtist(const QString &titleOrig, const QString &artistOrig)
{
QString title=titleOrig.toLower();
QString artist=artistOrig.toLower();
if (title==artist) {
return true;
}
if (artist.startsWith(QLatin1String("the ")) && title.endsWith(QLatin1String(", the"))) {
QString theArtist=artist.mid(4)+QLatin1String(", the");
if (title==theArtist) {
return true;
}
}
typedef QPair<QChar, QChar> ChPair;
QList<ChPair> replacements = QList<ChPair>() << ChPair('-', '/') << ChPair('.', 0)
<< ChPair(QChar(0x00ff /* ÿ */), 'y');
foreach (const ChPair &r, replacements) {
QString a=artist;
QString t=title;
if (r.second.isNull()) {
a=a.replace(QString()+r.first, "");
t=t.replace(QString()+r.first, "");
} else {
a=a.replace(r.first, r.second);
t=t.replace(r.first, r.second);
}
if (t==a) {
return true;
}
}
return false;
}
void ContextWidget::discoGsResponse()
{
NetworkJob *reply = getReply(sender());
if (!reply) {
return;
}
DBUG << "status" << reply->error() << reply->errorString();
QString url;
if (reply->ok()) {
#if QT_VERSION >= 0x050000
QJsonParseError jsonParseError;
QVariantMap parsed=QJsonDocument::fromJson(reply->readAll(), &jsonParseError).toVariant().toMap();
bool ok=QJsonParseError::NoError==jsonParseError.error;
#else
bool ok=false;
QVariantMap parsed = QJson::Parser().parse(reply->readAll(), &ok).toMap();
#endif
if (ok && parsed.contains("resp")) {
QVariantMap response=parsed["resp"].toMap();
if (response.contains("search")) {
QVariantMap search=response["search"].toMap();
if (search.contains("exactresults")) {
QVariantList results=search["exactresults"].toList();
foreach (const QVariant &r, results) {
QVariantMap rm=r.toMap();
if (rm.contains("thumb") && rm.contains("title")) {
QString thumbUrl=rm["thumb"].toString();
QString title=rm["title"].toString();
if (thumbUrl.contains("/image/A-150-") && matchesArtist(title, currentArtist)) {
url=thumbUrl.replace("image/A-150-", "/image/A-");
break;
}
}
}
}
}
}
}
if (url.isEmpty()) {
createBackdrop();
} else {
job=NetworkAccessManager::self()->get(QUrl(url));
DBUG << url;
connect(job, SIGNAL(finished()), this, SLOT(downloadResponse()));
}
}
void ContextWidget::downloadResponse()
{
NetworkJob *reply = getReply(sender());
if (!reply) {
return;
}
DBUG << "status" << reply->error() << reply->errorString();
QImage img;
QByteArray data;
if (reply->ok()) {
data=reply->readAll();
img=QImage::fromData(data);
}
if (img.isNull()) {
createBackdrop();
} else {
updateImage(img);
bool saved=false;
if (Settings::self()->storeBackdropsInMpdDir() && !currentSong.isVariousArtists() &&
!currentSong.isNonMPD() && MPDConnection::self()->getDetails().dirReadable) {
QString mpdDir=MPDConnection::self()->getDetails().dir;
QString songDir=Utils::getDir(currentSong.file);
if (!mpdDir.isEmpty() && 2==songDir.split(Utils::constDirSep, QString::SkipEmptyParts).count()) {
QDir d(mpdDir+songDir);
d.cdUp();
QString fileName=Utils::fixPath(d.absolutePath())+constBackdropFileName+".jpg";
QFile f(fileName);
if (f.open(QIODevice::WriteOnly)) {
f.write(data);
f.close();
DBUG << "Saved backdrop to" << fileName << "for artist" << currentArtist << ", current song" << currentSong.file;
saved=true;
}
} else {
DBUG << "Not saving to mpd folder, mpd dir:" << mpdDir
<< "num parts:" << songDir.split(Utils::constDirSep, QString::SkipEmptyParts).count();
}
} else {
DBUG << "Not saving to mpd folder - set to save in mpd?" << Settings::self()->storeBackdropsInMpdDir()
<< "isVa:" << currentSong.isVariousArtists() << "isNonMPD:" << currentSong.isNonMPD()
<< "mpd readable:" << MPDConnection::self()->getDetails().dirReadable;
}
if (!saved) {
QString cacheName=cacheFileName(currentArtist, true);
QFile f(cacheName);
if (f.open(QIODevice::WriteOnly)) {
DBUG << "Saved backdrop to (cache)" << cacheName << "for artist" << currentArtist << ", current song" << currentSong.file;
f.write(data);
f.close();
}
}
QWidget::update();
}
}
void ContextWidget::createBackdrop()
{
DBUG << currentArtist;
if (!creator) {
creator = new BackdropCreator();
connect(creator, SIGNAL(created(QString,QImage)), SLOT(backdropCreated(QString,QImage)));
connect(this, SIGNAL(createBackdrop(QString,QList<Song>)), creator, SLOT(create(QString,QList<Song>)));
}
QList<Song> artistAlbumsFirstTracks=artist->getArtistAlbumsFirstTracks();
QSet<QString> albumNames;
foreach (const Song &s, artistAlbumsFirstTracks) {
albumNames.insert(s.albumArtist()+" - "+s.album);
}
if (backdropAlbums!=albumNames) {
backdropAlbums=albumNames;
emit createBackdrop(currentArtist, artistAlbumsFirstTracks);
}
}
void ContextWidget::resizeBackdrop()
{
#ifdef SCALE_CONTEXT_BGND
if (!albumCoverBackdrop && !currentImage.isNull() &&( currentBackdrop.isNull() || (!currentBackdrop.isNull() && currentBackdrop.width()!=width()))) {
QSize sz(width(), width()*currentImage.height()/currentImage.width());
currentBackdrop = QPixmap::fromImage(currentImage.scaled(sz, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation));
}
#else
if (!currentBackdrop.isNull() && !albumCoverBackdrop) {
if (currentBackdrop.width()<minBackdropSize.width() && currentBackdrop.height()<minBackdropSize.height()) {
QSize size(minBackdropSize);
if (currentBackdrop.width()<minBackdropSize.width()/4 && currentBackdrop.height()<minBackdropSize.height()/4) {
size=QSize(minBackdropSize.width()/2, minBackdropSize.height()/2);
}
currentBackdrop=currentBackdrop.scaled(size, Qt::KeepAspectRatio, Qt::SmoothTransformation);
} else if (maxBackdropSize.width()>1024 && maxBackdropSize.height()>768 &&
(currentBackdrop.width()>maxBackdropSize.width() || currentBackdrop.height()>maxBackdropSize.height())) {
currentBackdrop=currentBackdrop.scaled(maxBackdropSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
}
}
#endif
}
void ContextWidget::backdropCreated(const QString &artist, const QImage &img)
{
DBUG << artist << img.isNull() << currentArtist;
if (artist==currentArtist) {
artistsCreatedBackdropsFor.removeAll(artist);
artistsCreatedBackdropsFor.append(artist);
if (artistsCreatedBackdropsFor.count()>20) {
artistsCreatedBackdropsFor.removeFirst();
}
updateImage(img, true);
QWidget::update();
}
}
NetworkJob * ContextWidget::getReply(QObject *obj)
{
NetworkJob *reply = qobject_cast<NetworkJob*>(obj);
if (!reply) {
return 0;
}
reply->deleteLater();
if (reply!=job) {
return 0;
}
job=0;
return reply;
}
| Nikoli/cantata | context/contextwidget.cpp | C++ | gpl-3.0 | 36,837 |
<?php
/**
* This file is part of GameQ.
*
* GameQ 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 3 of the License, or
* (at your option) any later version.
*
* GameQ 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/>.
*
* $Id: gamespy.php,v 1.3 2007/10/13 08:55:39 tombuskens Exp $
*/
require_once GAMEQ_BASE . 'Protocol.php';
/**
* Gamespy Protocol
*
* @author Tom Buskens <t.buskens@deviation.nl>
* @version $Revision: 1.3 $
*/
class GameQ_Protocol_gamespy extends GameQ_Protocol
{
public function status()
{
// Header
$this->header();
while ($this->p->getLength()) {
// Check for final keyword
$key = $this->p->readString('\\');
if ($key == 'final') break;
$suffix = strrpos($key, '_');
// Normal variable
if ($suffix === false or !is_numeric(substr($key, $suffix + 1))) {
$this->r->add($key, $this->p->readString('\\'));
}
// Player (<variable>_<count>) variable
else {
$this->r->addPlayer(substr($key, 0, $suffix), $this->p->readString('\\'));
}
}
}
public function players()
{
$this->status();
}
public function basic()
{
$this->status();
}
public function info()
{
$this->status();
}
public function preprocess($packets)
{
if (count($packets) == 1) return $packets[0];
// Order packets by queryid
$newpackets = array();
foreach ($packets as $packet) {
preg_match("#^(.*)\\\\queryid\\\\([^\\\\]+)(\\\\|$)#", $packet, $matches);
if (!isset($matches[1]) or !isset($matches[2])) {
throw new GameQ_ParsingException();
}
$newpackets[$matches[2]] = $matches[1];
}
// Sort the array
ksort($newpackets);
// Remove the keys
$newpackets = array_values($newpackets);
return implode('', $newpackets);
}
private function header()
{
if ($this->p->read() !== '\\') {
throw new GameQ_ParsingException($this->p);
}
}
}
?>
| nedwidek/BF2NameHackBuster | php/trunk/GameQ/Protocol/gamespy.php | PHP | gpl-3.0 | 2,801 |
/* gpgkeys_curl.c - fetch a key via libcurl
* Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
* GnuPG 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 3 of the License, or
* (at your option) any later version.
*
* GnuPG 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/>.
*
* In addition, as a special exception, the Free Software Foundation
* gives permission to link the code of the keyserver helper tools:
* gpgkeys_ldap, gpgkeys_curl and gpgkeys_hkp with the OpenSSL
* project's "OpenSSL" library (or with modified versions of it that
* use the same license as the "OpenSSL" library), and distribute the
* linked executables. You must obey the GNU General Public License
* in all respects for all of the code used other than "OpenSSL". If
* you modify this file, you may extend this exception to your version
* of the file, but you are not obligated to do so. If you do not
* wish to do so, delete this exception statement from your version.
*/
#include <config.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
#ifdef HAVE_LIBCURL
#include <curl/curl.h>
#else
#include "curl-shim.h"
#endif
#include "compat.h"
#include "keyserver.h"
#include "ksutil.h"
extern char *optarg;
extern int optind;
static FILE *input,*output,*console;
static CURL *curl;
static struct ks_options *opt;
static int
get_key(char *getkey)
{
CURLcode res;
char errorbuffer[CURL_ERROR_SIZE];
char request[MAX_URL];
struct curl_writer_ctx ctx;
memset(&ctx,0,sizeof(ctx));
if(strncmp(getkey,"0x",2)==0)
getkey+=2;
fprintf(output,"KEY 0x%s BEGIN\n",getkey);
sprintf(request,"%s://%s%s%s%s",opt->scheme,opt->host,
opt->port?":":"",opt->port?opt->port:"",opt->path?opt->path:"/");
curl_easy_setopt(curl,CURLOPT_URL,request);
curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,curl_writer);
ctx.stream=output;
curl_easy_setopt(curl,CURLOPT_FILE,&ctx);
curl_easy_setopt(curl,CURLOPT_ERRORBUFFER,errorbuffer);
res=curl_easy_perform(curl);
if(res!=CURLE_OK)
{
fprintf(console,"gpgkeys: %s fetch error %d: %s\n",opt->scheme,
res,errorbuffer);
fprintf(output,"\nKEY 0x%s FAILED %d\n",getkey,curl_err_to_gpg_err(res));
}
else
{
curl_writer_finalize(&ctx);
if(!ctx.flags.done)
{
fprintf(console,"gpgkeys: no key data found for %s\n",request);
fprintf(output,"\nKEY 0x%s FAILED %d\n",
getkey,KEYSERVER_KEY_NOT_FOUND);
}
else
fprintf(output,"\nKEY 0x%s END\n",getkey);
}
return curl_err_to_gpg_err(res);
}
static void
show_help (FILE *fp)
{
fprintf (fp,"-h, --help\thelp\n");
fprintf (fp,"-V\t\tmachine readable version\n");
fprintf (fp,"--version\thuman readable version\n");
fprintf (fp,"-o\t\toutput to this file\n");
}
int
main(int argc,char *argv[])
{
int arg,ret=KEYSERVER_INTERNAL_ERROR,i;
char line[MAX_LINE];
char *thekey=NULL;
long follow_redirects=5;
char *proxy=NULL;
curl_version_info_data *curldata;
struct curl_slist *headers=NULL;
console=stderr;
/* Kludge to implement standard GNU options. */
if (argc > 1 && !strcmp (argv[1], "--version"))
{
printf ("gpgkeys_curl (GnuPG) %s\n", VERSION);
printf ("Uses: %s\n", curl_version());
return 0;
}
else if (argc > 1 && !strcmp (argv[1], "--help"))
{
show_help (stdout);
return 0;
}
while((arg=getopt(argc,argv,"hVo:"))!=-1)
switch(arg)
{
default:
case 'h':
show_help (console);
return KEYSERVER_OK;
case 'V':
fprintf(stdout,"%d\n%s\n",KEYSERVER_PROTO_VERSION,VERSION);
return KEYSERVER_OK;
case 'o':
output=fopen(optarg,"wb");
if(output==NULL)
{
fprintf(console,"gpgkeys: Cannot open output file `%s': %s\n",
optarg,strerror(errno));
return KEYSERVER_INTERNAL_ERROR;
}
break;
}
if(argc>optind)
{
input=fopen(argv[optind],"r");
if(input==NULL)
{
fprintf(console,"gpgkeys: Cannot open input file `%s': %s\n",
argv[optind],strerror(errno));
return KEYSERVER_INTERNAL_ERROR;
}
}
if(input==NULL)
input=stdin;
if(output==NULL)
output=stdout;
opt=init_ks_options();
if(!opt)
return KEYSERVER_NO_MEMORY;
/* Get the command and info block */
while(fgets(line,MAX_LINE,input)!=NULL)
{
int err;
char option[MAX_OPTION+1];
if(line[0]=='\n')
break;
err=parse_ks_options(line,opt);
if(err>0)
{
ret=err;
goto fail;
}
else if(err==0)
continue;
if(sscanf(line,"OPTION %" MKSTRING(MAX_OPTION) "s\n",option)==1)
{
int no=0;
char *start=&option[0];
option[MAX_OPTION]='\0';
if(ascii_strncasecmp(option,"no-",3)==0)
{
no=1;
start=&option[3];
}
if(ascii_strncasecmp(start,"http-proxy",10)==0)
{
/* Safe to not check the return code of strdup() here.
If it fails, we simply won't use a proxy. */
if(no)
{
free(proxy);
proxy=strdup("");
}
else if(start[10]=='=')
{
if(strlen(&start[11])<MAX_PROXY)
{
free(proxy);
proxy=strdup(&start[11]);
}
}
}
else if(ascii_strncasecmp(start,"follow-redirects",16)==0)
{
if(no)
follow_redirects=0;
else if(start[16]=='=')
follow_redirects=atoi(&start[17]);
else if(start[16]=='\0')
follow_redirects=-1;
}
continue;
}
}
if(!opt->scheme)
{
fprintf(console,"gpgkeys: no scheme supplied!\n");
ret=KEYSERVER_SCHEME_NOT_FOUND;
goto fail;
}
if(!opt->host)
{
fprintf(console,"gpgkeys: no keyserver host provided\n");
goto fail;
}
if(opt->timeout && register_timeout()==-1)
{
fprintf(console,"gpgkeys: unable to register timeout handler\n");
return KEYSERVER_INTERNAL_ERROR;
}
curl_global_init(CURL_GLOBAL_DEFAULT);
curl=curl_easy_init();
if(!curl)
{
fprintf(console,"gpgkeys: unable to initialize curl\n");
ret=KEYSERVER_INTERNAL_ERROR;
goto fail;
}
/* Make sure we have the protocol the user is asking for so we can
print a nicer error message. */
curldata=curl_version_info(CURLVERSION_NOW);
for(i=0;curldata->protocols[i];i++)
if(ascii_strcasecmp(curldata->protocols[i],opt->scheme)==0)
break;
if(curldata->protocols[i]==NULL)
{
fprintf(console,"gpgkeys: protocol `%s' not supported\n",opt->scheme);
ret=KEYSERVER_SCHEME_NOT_FOUND;
goto fail;
}
if(follow_redirects)
{
curl_easy_setopt(curl,CURLOPT_FOLLOWLOCATION,1L);
if(follow_redirects>0)
curl_easy_setopt(curl,CURLOPT_MAXREDIRS,follow_redirects);
}
if(opt->auth)
curl_easy_setopt(curl,CURLOPT_USERPWD,opt->auth);
if(opt->debug)
{
fprintf(console,"gpgkeys: curl version = %s\n",curl_version());
curl_easy_setopt(curl,CURLOPT_STDERR,console);
curl_easy_setopt(curl,CURLOPT_VERBOSE,1L);
}
curl_easy_setopt(curl,CURLOPT_SSL_VERIFYPEER,(long)opt->flags.check_cert);
curl_easy_setopt(curl,CURLOPT_CAINFO,opt->ca_cert_file);
/* Avoid caches to get the most recent copy of the key. This is bug
#1061. In pre-curl versions of the code, we didn't do it. Then
we did do it (as a curl default) until curl changed the default.
Now we're doing it again, but in such a way that changing
defaults in the future won't impact us. We set both the Pragma
and Cache-Control versions of the header, so we're good with both
HTTP 1.0 and 1.1. */
headers=curl_slist_append(headers,"Pragma: no-cache");
if(headers)
headers=curl_slist_append(headers,"Cache-Control: no-cache");
if(!headers)
{
fprintf(console,"gpgkeys: out of memory when building HTTP headers\n");
ret=KEYSERVER_NO_MEMORY;
goto fail;
}
curl_easy_setopt(curl,CURLOPT_HTTPHEADER,headers);
if(proxy)
curl_easy_setopt(curl,CURLOPT_PROXY,proxy);
/* If it's a GET or a SEARCH, the next thing to come in is the
keyids. If it's a SEND, then there are no keyids. */
if(opt->action==KS_GET)
{
/* Eat the rest of the file */
for(;;)
{
if(fgets(line,MAX_LINE,input)==NULL)
break;
else
{
if(line[0]=='\n' || line[0]=='\0')
break;
if(!thekey)
{
thekey=strdup(line);
if(!thekey)
{
fprintf(console,"gpgkeys: out of memory while "
"building key list\n");
ret=KEYSERVER_NO_MEMORY;
goto fail;
}
/* Trim the trailing \n */
thekey[strlen(line)-1]='\0';
}
}
}
}
else
{
fprintf(console,
"gpgkeys: this keyserver type only supports key retrieval\n");
goto fail;
}
if(!thekey)
{
fprintf(console,"gpgkeys: invalid keyserver instructions\n");
goto fail;
}
/* Send the response */
fprintf(output,"VERSION %d\n",KEYSERVER_PROTO_VERSION);
fprintf(output,"PROGRAM %s\n\n",VERSION);
if(opt->verbose)
{
fprintf(console,"Scheme:\t\t%s\n",opt->scheme);
fprintf(console,"Host:\t\t%s\n",opt->host);
if(opt->port)
fprintf(console,"Port:\t\t%s\n",opt->port);
if(opt->path)
fprintf(console,"Path:\t\t%s\n",opt->path);
fprintf(console,"Command:\tGET\n");
}
set_timeout(opt->timeout);
ret=get_key(thekey);
fail:
free(thekey);
if(input!=stdin)
fclose(input);
if(output!=stdout)
fclose(output);
free_ks_options(opt);
curl_slist_free_all(headers);
if(curl)
curl_easy_cleanup(curl);
free(proxy);
curl_global_cleanup();
return ret;
}
| alexforsale/aosp_platform_external_gpg | keyserver/gpgkeys_curl.c | C | gpl-3.0 | 10,109 |
using System.IO;
using System.Text.RegularExpressions;
// This is a neat little idea I found of how to deal with the problem of non-incrementing file version on StackOverflow
// It has the advantage of not relying on a particular build system and being completely optional.
namespace BumpBuildNumber
{
class BumpBuildNumber
{
public static void Main(string[] args)
{
try {
string FILE = @"SharedAssemblyInfo.cs";
string text = File.ReadAllText(FILE);
var regex = new Regex(@"(?<STATIC>\[assembly: AssemblyFileVersion\(""\d+\.\d+\.\d+\.)(?<BUILD>\d+)(?<TRAILER>""\)\])");
var match = regex.Match(text);
int buildNumber = int.Parse(match.Groups["BUILD"].Value) + 1;
string newText = regex.Replace(text, "${STATIC}" + buildNumber + "${TRAILER}", 1);
File.WriteAllText(FILE, newText);
} catch {
}
}
}
}
| exoatmorobotics/kspMods | RasterPropMonitor-0.22.2/BumpBuildNumber/BumpBuildNumber.cs | C# | gpl-3.0 | 850 |
if (runTime.outputTime())
{
// Displacement gradient
tetPointTensorField gradU = tetFec::grad(U);
// Stress tensor
tetPointSymmTensorField sigma =
rho*(2.0*mu*symm(gradU) + lambda*I*tr(gradU));
// Create pointMesh for field post-processing
const pointMesh& pMesh = pointMesh::New(mesh);
// U
pointVectorField Up
(
IOobject
(
"Up",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
pMesh,
U.dimensions()
);
Up.internalField() = vectorField::subField
(
U.internalField(),
pMesh.size()
);
// sigmaEq
pointScalarField sigmaEq
(
IOobject
(
"sigmaEq",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
pMesh,
sigma.dimensions()
);
sigmaEq.internalField() = scalarField::subField
(
sqrt((3.0/2.0)*magSqr(dev(sigma.internalField())))(),
pMesh.size()
);
// sigmaXX
pointScalarField sigmaXX
(
IOobject
(
"sigmaXX",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
pMesh,
sigma.dimensions()
);
sigmaXX.internalField() = scalarField::subField
(
sigma.component(symmTensor::XX)().internalField(),
pMesh.size()
);
// sigmaYY
pointScalarField sigmaYY
(
IOobject
(
"sigmaYY",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
pMesh,
sigma.dimensions()
);
sigmaYY.internalField() = scalarField::subField
(
sigma.component(symmTensor::YY)().internalField(),
pMesh.size()
);
// sigmaXY
pointScalarField sigmaXY
(
IOobject
(
"sigmaXY",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
pMesh,
sigma.dimensions()
);
sigmaXY.internalField() = scalarField::subField
(
sigma.component(symmTensor::XY)().internalField(),
pMesh.size()
);
runTime.write();
}
| Unofficial-Extend-Project-Mirror/openfoam-extend-foam-extend-3.1 | applications/solvers/solidMechanics/stressFemFoam/calculateStress.H | C++ | gpl-3.0 | 2,821 |
<?php
class TransactionTest_55 extends SimpleTest {
function test_1_transactions() {
DB::$nested_transactions = true;
$depth = DB::startTransaction();
$this->assert($depth === 1);
DB::query("UPDATE accounts SET age=%i WHERE username=%s", 700, 'Abe');
$depth = DB::startTransaction();
$this->assert($depth === 2);
DB::query("UPDATE accounts SET age=%i WHERE username=%s", 800, 'Abe');
$depth = DB::startTransaction();
$this->assert($depth === 3);
$this->assert(DB::transactionDepth() === 3);
DB::query("UPDATE accounts SET age=%i WHERE username=%s", 500, 'Abe');
$depth = DB::commit();
$this->assert($depth === 2);
$age = DB::queryFirstField("SELECT age FROM accounts WHERE username=%s", 'Abe');
$this->assert($age == 500);
$depth = DB::rollback();
$this->assert($depth === 1);
$age = DB::queryFirstField("SELECT age FROM accounts WHERE username=%s", 'Abe');
$this->assert($age == 700);
$depth = DB::commit();
$this->assert($depth === 0);
$age = DB::queryFirstField("SELECT age FROM accounts WHERE username=%s", 'Abe');
$this->assert($age == 700);
DB::$nested_transactions = false;
}
function test_2_transactions() {
DB::$nested_transactions = true;
DB::query("UPDATE accounts SET age=%i WHERE username=%s", 600, 'Abe');
DB::startTransaction();
DB::query("UPDATE accounts SET age=%i WHERE username=%s", 700, 'Abe');
DB::startTransaction();
DB::query("UPDATE accounts SET age=%i WHERE username=%s", 800, 'Abe');
DB::rollback();
$age = DB::queryFirstField("SELECT age FROM accounts WHERE username=%s", 'Abe');
$this->assert($age == 700);
DB::rollback();
$age = DB::queryFirstField("SELECT age FROM accounts WHERE username=%s", 'Abe');
$this->assert($age == 600);
DB::$nested_transactions = false;
}
function test_3_transaction_rollback_all() {
DB::$nested_transactions = true;
DB::query("UPDATE accounts SET age=%i WHERE username=%s", 200, 'Abe');
$depth = DB::startTransaction();
$this->assert($depth === 1);
DB::query("UPDATE accounts SET age=%i WHERE username=%s", 300, 'Abe');
$depth = DB::startTransaction();
$this->assert($depth === 2);
DB::query("UPDATE accounts SET age=%i WHERE username=%s", 400, 'Abe');
$depth = DB::rollback(true);
$this->assert($depth === 0);
$age = DB::queryFirstField("SELECT age FROM accounts WHERE username=%s", 'Abe');
$this->assert($age == 200);
DB::$nested_transactions = false;
}
}
?>
| OkoWsc/Accessin-Command | vendor/sergeytsalkov/meekrodb/simpletest/TransactionTest_55.php | PHP | gpl-3.0 | 2,730 |
/**********************************************************************
require( 'require' )
-----------------------------------------------------------------------
@example
var Path = require("node://path"); // Only in NodeJS/NW.js environment.
var Button = require("tfw.button");
**********************************************************************/
var require = function() {
var modules = {};
var definitions = {};
var nodejs_require = typeof window.require === 'function' ? window.require : null;
var f = function(id, body) {
if( id.substr( 0, 7 ) == 'node://' ) {
// Calling for a NodeJS module.
if( !nodejs_require ) {
throw Error( "[require] NodeJS is not available to load module `" + id + "`!" );
}
return nodejs_require( id.substr( 7 ) );
}
if( typeof body === 'function' ) {
definitions[id] = body;
return;
}
var mod;
body = definitions[id];
if (typeof body === 'undefined') {
var err = new Error("Required module is missing: " + id);
console.error(err.stack);
throw err;
}
mod = modules[id];
if (typeof mod === 'undefined') {
mod = {exports: {}};
var exports = mod.exports;
body(exports, mod);
modules[id] = mod.exports;
mod = mod.exports;
//console.log("Module initialized: " + id);
}
return mod;
};
return f;
}();
| tolokoban/hackathon-2016 | spec/mod/@require.js | JavaScript | gpl-3.0 | 1,562 |
require 'factory_girl'
FactoryGirl.define do
# requires order
factory :group_order do
ordergroup { create(:user, groups: [FactoryGirl.create(:ordergroup)]).ordergroup }
end
end
| BanzaiMan/foodsoft | spec/factories/group_order.rb | Ruby | gpl-3.0 | 190 |
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.compiler;
import java.io.*;
import java.util.StringTokenizer;
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.codegen.*;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.impl.Constant;
import org.eclipse.jdt.internal.compiler.impl.StringConstant;
import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
import org.eclipse.jdt.internal.compiler.util.Util;
/**
* Represents a class file wrapper on bytes, it is aware of its actual
* type name.
*
* Public APIs are listed below:
*
* byte[] getBytes();
* Answer the actual bytes of the class file
*
* char[][] getCompoundName();
* Answer the compound name of the class file.
* For example, {{java}, {util}, {Hashtable}}.
*
* byte[] getReducedBytes();
* Answer a smaller byte format, which is only contains some structural
* information. Those bytes are decodable with a regular class file reader,
* such as DietClassFileReader
*/
public class ClassFile
implements AttributeNamesConstants, CompilerModifiers, TypeConstants, TypeIds {
public SourceTypeBinding referenceBinding;
public ConstantPool constantPool;
public ClassFile enclosingClassFile;
// used to generate private access methods
public int produceDebugAttributes;
public ReferenceBinding[] innerClassesBindings;
public int numberOfInnerClasses;
public byte[] header;
// the header contains all the bytes till the end of the constant pool
public byte[] contents;
// that collection contains all the remaining bytes of the .class file
public int headerOffset;
public int contentsOffset;
public int constantPoolOffset;
public int methodCountOffset;
public int methodCount;
protected boolean creatingProblemType;
public static final int INITIAL_CONTENTS_SIZE = 400;
public static final int INITIAL_HEADER_SIZE = 1500;
public boolean ownSharedArrays = false; // flag set when header/contents are set to shared arrays
public static final int INNER_CLASSES_SIZE = 5;
public CodeStream codeStream;
public long targetJDK;
/**
* INTERNAL USE-ONLY
* This methods creates a new instance of the receiver.
*/
public ClassFile() {
// default constructor for subclasses
}
/**
* INTERNAL USE-ONLY
* This methods creates a new instance of the receiver.
*
* @param aType org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding
* @param enclosingClassFile org.eclipse.jdt.internal.compiler.ClassFile
* @param creatingProblemType <CODE>boolean</CODE>
*/
public ClassFile(
SourceTypeBinding aType,
ClassFile enclosingClassFile,
boolean creatingProblemType) {
this.referenceBinding = aType;
initByteArrays();
// generate the magic numbers inside the header
header[headerOffset++] = (byte) (0xCAFEBABEL >> 24);
header[headerOffset++] = (byte) (0xCAFEBABEL >> 16);
header[headerOffset++] = (byte) (0xCAFEBABEL >> 8);
header[headerOffset++] = (byte) (0xCAFEBABEL >> 0);
final CompilerOptions options = aType.scope.environment().options;
this.targetJDK = options.targetJDK;
header[headerOffset++] = (byte) (this.targetJDK >> 8); // minor high
header[headerOffset++] = (byte) (this.targetJDK >> 0); // minor low
header[headerOffset++] = (byte) (this.targetJDK >> 24); // major high
header[headerOffset++] = (byte) (this.targetJDK >> 16); // major low
constantPoolOffset = headerOffset;
headerOffset += 2;
constantPool = new ConstantPool(this);
// Modifier manipulations for classfile
int accessFlags = aType.getAccessFlags();
if (aType.isPrivate()) { // rewrite private to non-public
accessFlags &= ~AccPublic;
}
if (aType.isProtected()) { // rewrite protected into public
accessFlags |= AccPublic;
}
// clear all bits that are illegal for a class or an interface
accessFlags
&= ~(
AccStrictfp
| AccProtected
| AccPrivate
| AccStatic
| AccSynchronized
| AccNative);
// set the AccSuper flag (has to be done after clearing AccSynchronized - since same value)
if (aType.isClass()) {
accessFlags |= AccSuper;
}
this.enclosingClassFile = enclosingClassFile;
// innerclasses get their names computed at code gen time
// now we continue to generate the bytes inside the contents array
contents[contentsOffset++] = (byte) (accessFlags >> 8);
contents[contentsOffset++] = (byte) accessFlags;
int classNameIndex = constantPool.literalIndex(aType);
contents[contentsOffset++] = (byte) (classNameIndex >> 8);
contents[contentsOffset++] = (byte) classNameIndex;
int superclassNameIndex;
if (aType.isInterface()) {
superclassNameIndex = constantPool.literalIndexForJavaLangObject();
} else {
superclassNameIndex =
(aType.superclass == null ? 0 : constantPool.literalIndex(aType.superclass));
}
contents[contentsOffset++] = (byte) (superclassNameIndex >> 8);
contents[contentsOffset++] = (byte) superclassNameIndex;
ReferenceBinding[] superInterfacesBinding = aType.superInterfaces();
int interfacesCount = superInterfacesBinding.length;
contents[contentsOffset++] = (byte) (interfacesCount >> 8);
contents[contentsOffset++] = (byte) interfacesCount;
for (int i = 0; i < interfacesCount; i++) {
int interfaceIndex = constantPool.literalIndex(superInterfacesBinding[i]);
contents[contentsOffset++] = (byte) (interfaceIndex >> 8);
contents[contentsOffset++] = (byte) interfaceIndex;
}
produceDebugAttributes = options.produceDebugAttributes;
innerClassesBindings = new ReferenceBinding[INNER_CLASSES_SIZE];
this.creatingProblemType = creatingProblemType;
codeStream = new CodeStream(this, this.targetJDK);
// retrieve the enclosing one guaranteed to be the one matching the propagated flow info
// 1FF9ZBU: LFCOM:ALL - Local variable attributes busted (Sanity check)
ClassFile outermostClassFile = this.outerMostEnclosingClassFile();
if (this == outermostClassFile) {
codeStream.maxFieldCount = aType.scope.referenceType().maxFieldCount;
} else {
codeStream.maxFieldCount = outermostClassFile.codeStream.maxFieldCount;
}
}
/**
* INTERNAL USE-ONLY
* Generate the byte for a problem method info that correspond to a boggus method.
*
* @param method org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration
* @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.MethodBinding
*/
public void addAbstractMethod(
AbstractMethodDeclaration method,
MethodBinding methodBinding) {
// force the modifiers to be public and abstract
methodBinding.modifiers = AccPublic | AccAbstract;
this.generateMethodInfoHeader(methodBinding);
int methodAttributeOffset = this.contentsOffset;
int attributeNumber = this.generateMethodInfoAttribute(methodBinding);
this.completeMethodInfo(methodAttributeOffset, attributeNumber);
}
/**
* INTERNAL USE-ONLY
* This methods generate all the attributes for the receiver.
* For a class they could be:
* - source file attribute
* - inner classes attribute
* - deprecated attribute
*/
public void addAttributes() {
// update the method count
contents[methodCountOffset++] = (byte) (methodCount >> 8);
contents[methodCountOffset] = (byte) methodCount;
int attributeNumber = 0;
// leave two bytes for the number of attributes and store the current offset
int attributeOffset = contentsOffset;
contentsOffset += 2;
// source attribute
if ((produceDebugAttributes & CompilerOptions.Source) != 0) {
String fullFileName =
new String(referenceBinding.scope.referenceCompilationUnit().getFileName());
fullFileName = fullFileName.replace('\\', '/');
int lastIndex = fullFileName.lastIndexOf('/');
if (lastIndex != -1) {
fullFileName = fullFileName.substring(lastIndex + 1, fullFileName.length());
}
// check that there is enough space to write all the bytes for the field info corresponding
// to the @fieldBinding
if (contentsOffset + 8 >= contents.length) {
resizeContents(8);
}
int sourceAttributeNameIndex =
constantPool.literalIndex(AttributeNamesConstants.SourceName);
contents[contentsOffset++] = (byte) (sourceAttributeNameIndex >> 8);
contents[contentsOffset++] = (byte) sourceAttributeNameIndex;
// The length of a source file attribute is 2. This is a fixed-length
// attribute
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 2;
// write the source file name
int fileNameIndex = constantPool.literalIndex(fullFileName.toCharArray());
contents[contentsOffset++] = (byte) (fileNameIndex >> 8);
contents[contentsOffset++] = (byte) fileNameIndex;
attributeNumber++;
}
// Deprecated attribute
if (referenceBinding.isDeprecated()) {
// check that there is enough space to write all the bytes for the field info corresponding
// to the @fieldBinding
if (contentsOffset + 6 >= contents.length) {
resizeContents(6);
}
int deprecatedAttributeNameIndex =
constantPool.literalIndex(AttributeNamesConstants.DeprecatedName);
contents[contentsOffset++] = (byte) (deprecatedAttributeNameIndex >> 8);
contents[contentsOffset++] = (byte) deprecatedAttributeNameIndex;
// the length of a deprecated attribute is equals to 0
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
attributeNumber++;
}
// Inner class attribute
if (numberOfInnerClasses != 0) {
// Generate the inner class attribute
int exSize = 8 * numberOfInnerClasses + 8;
if (exSize + contentsOffset >= this.contents.length) {
resizeContents(exSize);
}
// Now we now the size of the attribute and the number of entries
// attribute name
int attributeNameIndex =
constantPool.literalIndex(AttributeNamesConstants.InnerClassName);
contents[contentsOffset++] = (byte) (attributeNameIndex >> 8);
contents[contentsOffset++] = (byte) attributeNameIndex;
int value = (numberOfInnerClasses << 3) + 2;
contents[contentsOffset++] = (byte) (value >> 24);
contents[contentsOffset++] = (byte) (value >> 16);
contents[contentsOffset++] = (byte) (value >> 8);
contents[contentsOffset++] = (byte) value;
contents[contentsOffset++] = (byte) (numberOfInnerClasses >> 8);
contents[contentsOffset++] = (byte) numberOfInnerClasses;
for (int i = 0; i < numberOfInnerClasses; i++) {
ReferenceBinding innerClass = innerClassesBindings[i];
int accessFlags = innerClass.getAccessFlags();
int innerClassIndex = constantPool.literalIndex(innerClass);
// inner class index
contents[contentsOffset++] = (byte) (innerClassIndex >> 8);
contents[contentsOffset++] = (byte) innerClassIndex;
// outer class index: anonymous and local have no outer class index
if (innerClass.isMemberType()) {
// member or member of local
int outerClassIndex = constantPool.literalIndex(innerClass.enclosingType());
contents[contentsOffset++] = (byte) (outerClassIndex >> 8);
contents[contentsOffset++] = (byte) outerClassIndex;
} else {
// equals to 0 if the innerClass is not a member type
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
}
// name index
if (!innerClass.isAnonymousType()) {
int nameIndex = constantPool.literalIndex(innerClass.sourceName());
contents[contentsOffset++] = (byte) (nameIndex >> 8);
contents[contentsOffset++] = (byte) nameIndex;
} else {
// equals to 0 if the innerClass is an anonymous type
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
}
// access flag
if (innerClass.isAnonymousType()) {
accessFlags |= AccPrivate;
} else
if (innerClass.isLocalType() && !innerClass.isMemberType()) {
accessFlags |= AccPrivate;
}
contents[contentsOffset++] = (byte) (accessFlags >> 8);
contents[contentsOffset++] = (byte) accessFlags;
}
attributeNumber++;
}
// add signature attribute
char[] genericSignature = referenceBinding.genericSignature();
if (genericSignature != null) {
// check that there is enough space to write all the bytes for the field info corresponding
// to the @fieldBinding
if (contentsOffset + 8 >= contents.length) {
resizeContents(8);
}
int signatureAttributeNameIndex =
constantPool.literalIndex(AttributeNamesConstants.SignatureName);
contents[contentsOffset++] = (byte) (signatureAttributeNameIndex >> 8);
contents[contentsOffset++] = (byte) signatureAttributeNameIndex;
// the length of a signature attribute is equals to 2
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 2;
int signatureIndex =
constantPool.literalIndex(genericSignature);
contents[contentsOffset++] = (byte) (signatureIndex >> 8);
contents[contentsOffset++] = (byte) signatureIndex;
attributeNumber++;
}
// update the number of attributes
if (attributeOffset + 2 >= this.contents.length) {
resizeContents(2);
}
contents[attributeOffset++] = (byte) (attributeNumber >> 8);
contents[attributeOffset] = (byte) attributeNumber;
// resynchronize all offsets of the classfile
header = constantPool.poolContent;
headerOffset = constantPool.currentOffset;
int constantPoolCount = constantPool.currentIndex;
header[constantPoolOffset++] = (byte) (constantPoolCount >> 8);
header[constantPoolOffset] = (byte) constantPoolCount;
}
/**
* INTERNAL USE-ONLY
* This methods generate all the default abstract method infos that correpond to
* the abstract methods inherited from superinterfaces.
*/
public void addDefaultAbstractMethods() { // default abstract methods
MethodBinding[] defaultAbstractMethods =
referenceBinding.getDefaultAbstractMethods();
for (int i = 0, max = defaultAbstractMethods.length; i < max; i++) {
generateMethodInfoHeader(defaultAbstractMethods[i]);
int methodAttributeOffset = contentsOffset;
int attributeNumber = generateMethodInfoAttribute(defaultAbstractMethods[i]);
completeMethodInfo(methodAttributeOffset, attributeNumber);
}
}
/**
* INTERNAL USE-ONLY
* This methods generates the bytes for the field binding passed like a parameter
* @param fieldBinding org.eclipse.jdt.internal.compiler.lookup.FieldBinding
*/
public void addFieldInfo(FieldBinding fieldBinding) {
int attributeNumber = 0;
// check that there is enough space to write all the bytes for the field info corresponding
// to the @fieldBinding
if (contentsOffset + 30 >= contents.length) {
resizeContents(30);
}
// Now we can generate all entries into the byte array
// First the accessFlags
int accessFlags = fieldBinding.getAccessFlags();
if (targetJDK < ClassFileConstants.JDK1_5) {
// pre 1.5, synthetic was an attribute, not a modifier
accessFlags &= ~AccSynthetic;
}
contents[contentsOffset++] = (byte) (accessFlags >> 8);
contents[contentsOffset++] = (byte) accessFlags;
// Then the nameIndex
int nameIndex = constantPool.literalIndex(fieldBinding.name);
contents[contentsOffset++] = (byte) (nameIndex >> 8);
contents[contentsOffset++] = (byte) nameIndex;
// Then the descriptorIndex
int descriptorIndex = constantPool.literalIndex(fieldBinding.type.signature());
contents[contentsOffset++] = (byte) (descriptorIndex >> 8);
contents[contentsOffset++] = (byte) descriptorIndex;
// leave some space for the number of attributes
int fieldAttributeOffset = contentsOffset;
contentsOffset += 2;
// 4.7.2 only static constant fields get a ConstantAttribute
// Generate the constantValueAttribute
if (fieldBinding.isConstantValue()){
if (contentsOffset + 8 >= contents.length) {
resizeContents(8);
}
// Now we generate the constant attribute corresponding to the fieldBinding
int constantValueNameIndex =
constantPool.literalIndex(AttributeNamesConstants.ConstantValueName);
contents[contentsOffset++] = (byte) (constantValueNameIndex >> 8);
contents[contentsOffset++] = (byte) constantValueNameIndex;
// The attribute length = 2 in case of a constantValue attribute
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 2;
attributeNumber++;
// Need to add the constant_value_index
Constant fieldConstant = fieldBinding.constant();
switch (fieldConstant.typeID()) {
case T_boolean :
int booleanValueIndex =
constantPool.literalIndex(fieldConstant.booleanValue() ? 1 : 0);
contents[contentsOffset++] = (byte) (booleanValueIndex >> 8);
contents[contentsOffset++] = (byte) booleanValueIndex;
break;
case T_byte :
case T_char :
case T_int :
case T_short :
int integerValueIndex =
constantPool.literalIndex(fieldConstant.intValue());
contents[contentsOffset++] = (byte) (integerValueIndex >> 8);
contents[contentsOffset++] = (byte) integerValueIndex;
break;
case T_float :
int floatValueIndex =
constantPool.literalIndex(fieldConstant.floatValue());
contents[contentsOffset++] = (byte) (floatValueIndex >> 8);
contents[contentsOffset++] = (byte) floatValueIndex;
break;
case T_double :
int doubleValueIndex =
constantPool.literalIndex(fieldConstant.doubleValue());
contents[contentsOffset++] = (byte) (doubleValueIndex >> 8);
contents[contentsOffset++] = (byte) doubleValueIndex;
break;
case T_long :
int longValueIndex =
constantPool.literalIndex(fieldConstant.longValue());
contents[contentsOffset++] = (byte) (longValueIndex >> 8);
contents[contentsOffset++] = (byte) longValueIndex;
break;
case T_String :
int stringValueIndex =
constantPool.literalIndex(
((StringConstant) fieldConstant).stringValue());
if (stringValueIndex == -1) {
if (!creatingProblemType) {
// report an error and abort: will lead to a problem type classfile creation
TypeDeclaration typeDeclaration = referenceBinding.scope.referenceContext;
FieldDeclaration[] fieldDecls = typeDeclaration.fields;
for (int i = 0, max = fieldDecls.length; i < max; i++) {
if (fieldDecls[i].binding == fieldBinding) {
// problem should abort
typeDeclaration.scope.problemReporter().stringConstantIsExceedingUtf8Limit(
fieldDecls[i]);
}
}
} else {
// already inside a problem type creation : no constant for this field
contentsOffset = fieldAttributeOffset + 2;
// +2 is necessary to keep the two byte space for the attribute number
attributeNumber--;
}
} else {
contents[contentsOffset++] = (byte) (stringValueIndex >> 8);
contents[contentsOffset++] = (byte) stringValueIndex;
}
}
}
if (this.targetJDK < ClassFileConstants.JDK1_5 && fieldBinding.isSynthetic()) {
if (contentsOffset + 6 >= contents.length) {
resizeContents(6);
}
int syntheticAttributeNameIndex =
constantPool.literalIndex(AttributeNamesConstants.SyntheticName);
contents[contentsOffset++] = (byte) (syntheticAttributeNameIndex >> 8);
contents[contentsOffset++] = (byte) syntheticAttributeNameIndex;
// the length of a synthetic attribute is equals to 0
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
attributeNumber++;
}
if (fieldBinding.isDeprecated()) {
if (contentsOffset + 6 >= contents.length) {
resizeContents(6);
}
int deprecatedAttributeNameIndex =
constantPool.literalIndex(AttributeNamesConstants.DeprecatedName);
contents[contentsOffset++] = (byte) (deprecatedAttributeNameIndex >> 8);
contents[contentsOffset++] = (byte) deprecatedAttributeNameIndex;
// the length of a deprecated attribute is equals to 0
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
attributeNumber++;
}
// add signature attribute
char[] genericSignature = fieldBinding.genericSignature();
if (genericSignature != null) {
// check that there is enough space to write all the bytes for the field info corresponding
// to the @fieldBinding
if (contentsOffset + 8 >= contents.length) {
resizeContents(8);
}
int signatureAttributeNameIndex =
constantPool.literalIndex(AttributeNamesConstants.SignatureName);
contents[contentsOffset++] = (byte) (signatureAttributeNameIndex >> 8);
contents[contentsOffset++] = (byte) signatureAttributeNameIndex;
// the length of a signature attribute is equals to 2
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 2;
int signatureIndex =
constantPool.literalIndex(genericSignature);
contents[contentsOffset++] = (byte) (signatureIndex >> 8);
contents[contentsOffset++] = (byte) signatureIndex;
attributeNumber++;
}
contents[fieldAttributeOffset++] = (byte) (attributeNumber >> 8);
contents[fieldAttributeOffset] = (byte) attributeNumber;
}
/**
* INTERNAL USE-ONLY
* This methods generate all the fields infos for the receiver.
* This includes:
* - a field info for each defined field of that class
* - a field info for each synthetic field (e.g. this$0)
*/
public void addFieldInfos() {
SourceTypeBinding currentBinding = referenceBinding;
FieldBinding[] syntheticFields = currentBinding.syntheticFields();
int fieldCount =
currentBinding.fieldCount()
+ (syntheticFields == null ? 0 : syntheticFields.length);
// write the number of fields
if (fieldCount > 0xFFFF) {
referenceBinding.scope.problemReporter().tooManyFields(referenceBinding.scope.referenceType());
}
contents[contentsOffset++] = (byte) (fieldCount >> 8);
contents[contentsOffset++] = (byte) fieldCount;
FieldBinding[] fieldBindings = currentBinding.fields();
for (int i = 0, max = fieldBindings.length; i < max; i++) {
addFieldInfo(fieldBindings[i]);
}
if (syntheticFields != null) {
for (int i = 0, max = syntheticFields.length; i < max; i++) {
addFieldInfo(syntheticFields[i]);
}
}
}
/**
* INTERNAL USE-ONLY
* This methods stores the bindings for each inner class. They will be used to know which entries
* have to be generated for the inner classes attributes.
* @param refBinding org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding
*/
public void addInnerClasses(ReferenceBinding refBinding) {
// check first if that reference binding is there
for (int i = 0; i < numberOfInnerClasses; i++) {
if (innerClassesBindings[i] == refBinding)
return;
}
int length = innerClassesBindings.length;
if (numberOfInnerClasses == length) {
System.arraycopy(
innerClassesBindings,
0,
innerClassesBindings = new ReferenceBinding[length * 2],
0,
length);
}
innerClassesBindings[numberOfInnerClasses++] = refBinding;
}
/**
* INTERNAL USE-ONLY
* Generate the byte for a problem clinit method info that correspond to a boggus method.
*
* @param problems org.eclipse.jdt.internal.compiler.problem.Problem[]
*/
public void addProblemClinit(IProblem[] problems) {
generateMethodInfoHeaderForClinit();
// leave two spaces for the number of attributes
contentsOffset -= 2;
int attributeOffset = contentsOffset;
contentsOffset += 2;
int attributeNumber = 0;
int codeAttributeOffset = contentsOffset;
generateCodeAttributeHeader();
codeStream.resetForProblemClinit(this);
String problemString = "" ; //$NON-NLS-1$
int problemLine = 0;
if (problems != null) {
int max = problems.length;
StringBuffer buffer = new StringBuffer(25);
int count = 0;
for (int i = 0; i < max; i++) {
IProblem problem = problems[i];
if ((problem != null) && (problem.isError())) {
buffer.append("\t" +problem.getMessage() + "\n" ); //$NON-NLS-1$ //$NON-NLS-2$
count++;
if (problemLine == 0) {
problemLine = problem.getSourceLineNumber();
}
problems[i] = null;
}
} // insert the top line afterwards, once knowing how many problems we have to consider
if (count > 1) {
buffer.insert(0, Util.bind("compilation.unresolvedProblems" )); //$NON-NLS-1$
} else {
buffer.insert(0, Util.bind("compilation.unresolvedProblem" )); //$NON-NLS-1$
}
problemString = buffer.toString();
}
// return codeStream.generateCodeAttributeForProblemMethod(comp.options.runtimeExceptionNameForCompileError, "")
codeStream.generateCodeAttributeForProblemMethod(problemString);
attributeNumber++; // code attribute
completeCodeAttributeForClinit(
codeAttributeOffset,
referenceBinding
.scope
.referenceCompilationUnit()
.compilationResult
.lineSeparatorPositions,
problemLine);
contents[attributeOffset++] = (byte) (attributeNumber >> 8);
contents[attributeOffset] = (byte) attributeNumber;
}
/**
* INTERNAL USE-ONLY
* Generate the byte for a problem method info that correspond to a boggus constructor.
*
* @param method org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration
* @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.MethodBinding
* @param problems org.eclipse.jdt.internal.compiler.problem.Problem[]
*/
public void addProblemConstructor(
AbstractMethodDeclaration method,
MethodBinding methodBinding,
IProblem[] problems) {
// always clear the strictfp/native/abstract bit for a problem method
generateMethodInfoHeader(methodBinding, methodBinding.modifiers & ~(AccStrictfp | AccNative | AccAbstract));
int methodAttributeOffset = contentsOffset;
int attributeNumber = generateMethodInfoAttribute(methodBinding);
// Code attribute
attributeNumber++;
int codeAttributeOffset = contentsOffset;
generateCodeAttributeHeader();
codeStream.reset(method, this);
String problemString = "" ; //$NON-NLS-1$
int problemLine = 0;
if (problems != null) {
int max = problems.length;
StringBuffer buffer = new StringBuffer(25);
int count = 0;
for (int i = 0; i < max; i++) {
IProblem problem = problems[i];
if ((problem != null) && (problem.isError())) {
buffer.append("\t" +problem.getMessage() + "\n" ); //$NON-NLS-1$ //$NON-NLS-2$
count++;
if (problemLine == 0) {
problemLine = problem.getSourceLineNumber();
}
}
} // insert the top line afterwards, once knowing how many problems we have to consider
if (count > 1) {
buffer.insert(0, Util.bind("compilation.unresolvedProblems" )); //$NON-NLS-1$
} else {
buffer.insert(0, Util.bind("compilation.unresolvedProblem" )); //$NON-NLS-1$
}
problemString = buffer.toString();
}
// return codeStream.generateCodeAttributeForProblemMethod(comp.options.runtimeExceptionNameForCompileError, "")
codeStream.generateCodeAttributeForProblemMethod(problemString);
completeCodeAttributeForProblemMethod(
method,
methodBinding,
codeAttributeOffset,
((SourceTypeBinding) methodBinding.declaringClass)
.scope
.referenceCompilationUnit()
.compilationResult
.lineSeparatorPositions,
problemLine);
completeMethodInfo(methodAttributeOffset, attributeNumber);
}
/**
* INTERNAL USE-ONLY
* Generate the byte for a problem method info that correspond to a boggus constructor.
* Reset the position inside the contents byte array to the savedOffset.
*
* @param method org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration
* @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.MethodBinding
* @param problems org.eclipse.jdt.internal.compiler.problem.Problem[]
* @param savedOffset <CODE>int</CODE>
*/
public void addProblemConstructor(
AbstractMethodDeclaration method,
MethodBinding methodBinding,
IProblem[] problems,
int savedOffset) {
// we need to move back the contentsOffset to the value at the beginning of the method
contentsOffset = savedOffset;
methodCount--; // we need to remove the method that causes the problem
addProblemConstructor(method, methodBinding, problems);
}
/**
* INTERNAL USE-ONLY
* Generate the byte for a problem method info that correspond to a boggus method.
*
* @param method org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration
* @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.MethodBinding
* @param problems org.eclipse.jdt.internal.compiler.problem.Problem[]
*/
public void addProblemMethod(
AbstractMethodDeclaration method,
MethodBinding methodBinding,
IProblem[] problems) {
if (methodBinding.isAbstract() && methodBinding.declaringClass.isInterface()) {
method.abort(ProblemSeverities.AbortType, null);
}
// always clear the strictfp/native/abstract bit for a problem method
generateMethodInfoHeader(methodBinding, methodBinding.modifiers & ~(AccStrictfp | AccNative | AccAbstract));
int methodAttributeOffset = contentsOffset;
int attributeNumber = generateMethodInfoAttribute(methodBinding);
// Code attribute
attributeNumber++;
int codeAttributeOffset = contentsOffset;
generateCodeAttributeHeader();
codeStream.reset(method, this);
String problemString = "" ; //$NON-NLS-1$
int problemLine = 0;
if (problems != null) {
int max = problems.length;
StringBuffer buffer = new StringBuffer(25);
int count = 0;
for (int i = 0; i < max; i++) {
IProblem problem = problems[i];
if ((problem != null)
&& (problem.isError())
&& (problem.getSourceStart() >= method.declarationSourceStart)
&& (problem.getSourceEnd() <= method.declarationSourceEnd)) {
buffer.append("\t" +problem.getMessage() + "\n" ); //$NON-NLS-1$ //$NON-NLS-2$
count++;
if (problemLine == 0) {
problemLine = problem.getSourceLineNumber();
}
problems[i] = null;
}
} // insert the top line afterwards, once knowing how many problems we have to consider
if (count > 1) {
buffer.insert(0, Util.bind("compilation.unresolvedProblems" )); //$NON-NLS-1$
} else {
buffer.insert(0, Util.bind("compilation.unresolvedProblem" )); //$NON-NLS-1$
}
problemString = buffer.toString();
}
// return codeStream.generateCodeAttributeForProblemMethod(comp.options.runtimeExceptionNameForCompileError, "")
codeStream.generateCodeAttributeForProblemMethod(problemString);
completeCodeAttributeForProblemMethod(
method,
methodBinding,
codeAttributeOffset,
((SourceTypeBinding) methodBinding.declaringClass)
.scope
.referenceCompilationUnit()
.compilationResult
.lineSeparatorPositions,
problemLine);
completeMethodInfo(methodAttributeOffset, attributeNumber);
}
/**
* INTERNAL USE-ONLY
* Generate the byte for a problem method info that correspond to a boggus method.
* Reset the position inside the contents byte array to the savedOffset.
*
* @param method org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration
* @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.MethodBinding
* @param problems org.eclipse.jdt.internal.compiler.problem.Problem[]
* @param savedOffset <CODE>int</CODE>
*/
public void addProblemMethod(
AbstractMethodDeclaration method,
MethodBinding methodBinding,
IProblem[] problems,
int savedOffset) {
// we need to move back the contentsOffset to the value at the beginning of the method
contentsOffset = savedOffset;
methodCount--; // we need to remove the method that causes the problem
addProblemMethod(method, methodBinding, problems);
}
/**
* INTERNAL USE-ONLY
* Generate the byte for all the special method infos.
* They are:
* - synthetic access methods
* - default abstract methods
*/
public void addSpecialMethods() {
// add all methods (default abstract methods and synthetic)
// default abstract methods
generateMissingAbstractMethods(referenceBinding.scope.referenceType().missingAbstractMethods, referenceBinding.scope.referenceCompilationUnit().compilationResult);
MethodBinding[] defaultAbstractMethods = this.referenceBinding.getDefaultAbstractMethods();
for (int i = 0, max = defaultAbstractMethods.length; i < max; i++) {
generateMethodInfoHeader(defaultAbstractMethods[i]);
int methodAttributeOffset = contentsOffset;
int attributeNumber = generateMethodInfoAttribute(defaultAbstractMethods[i]);
completeMethodInfo(methodAttributeOffset, attributeNumber);
}
// add synthetic methods infos
SyntheticAccessMethodBinding[] syntheticAccessMethods = this.referenceBinding.syntheticAccessMethods();
if (syntheticAccessMethods != null) {
for (int i = 0, max = syntheticAccessMethods.length; i < max; i++) {
SyntheticAccessMethodBinding accessMethodBinding = syntheticAccessMethods[i];
switch (accessMethodBinding.accessType) {
case SyntheticAccessMethodBinding.FieldReadAccess :
// generate a method info to emulate an reading access to
// a non-accessible field
addSyntheticFieldReadAccessMethod(accessMethodBinding);
break;
case SyntheticAccessMethodBinding.FieldWriteAccess :
// generate a method info to emulate an writing access to
// a non-accessible field
addSyntheticFieldWriteAccessMethod(accessMethodBinding);
break;
case SyntheticAccessMethodBinding.MethodAccess :
case SyntheticAccessMethodBinding.SuperMethodAccess :
case SyntheticAccessMethodBinding.BridgeMethodAccess :
// generate a method info to emulate an access to a non-accessible method / super-method or bridge method
addSyntheticMethodAccessMethod(accessMethodBinding);
break;
case SyntheticAccessMethodBinding.ConstructorAccess :
// generate a method info to emulate an access to a non-accessible constructor
addSyntheticConstructorAccessMethod(accessMethodBinding);
break;
}
}
}
}
/**
* INTERNAL USE-ONLY
* Generate the byte for problem method infos that correspond to missing abstract methods.
* http://dev.eclipse.org/bugs/show_bug.cgi?id=3179
*
* @param methodDeclarations Array of all missing abstract methods
*/
public void generateMissingAbstractMethods(MethodDeclaration[] methodDeclarations, CompilationResult compilationResult) {
if (methodDeclarations != null) {
for (int i = 0, max = methodDeclarations.length; i < max; i++) {
MethodDeclaration methodDeclaration = methodDeclarations[i];
MethodBinding methodBinding = methodDeclaration.binding;
String readableName = new String(methodBinding.readableName());
IProblem[] problems = compilationResult.problems;
int problemsCount = compilationResult.problemCount;
for (int j = 0; j < problemsCount; j++) {
IProblem problem = problems[j];
if (problem != null
&& problem.getID() == IProblem.AbstractMethodMustBeImplemented
&& problem.getMessage().indexOf(readableName) != -1) {
// we found a match
addMissingAbstractProblemMethod(methodDeclaration, methodBinding, problem, compilationResult);
}
}
}
}
}
private void addMissingAbstractProblemMethod(MethodDeclaration methodDeclaration, MethodBinding methodBinding, IProblem problem, CompilationResult compilationResult) {
// always clear the strictfp/native/abstract bit for a problem method
generateMethodInfoHeader(methodBinding, methodBinding.modifiers & ~(AccStrictfp | AccNative | AccAbstract));
int methodAttributeOffset = contentsOffset;
int attributeNumber = generateMethodInfoAttribute(methodBinding);
// Code attribute
attributeNumber++;
int codeAttributeOffset = contentsOffset;
generateCodeAttributeHeader();
StringBuffer buffer = new StringBuffer(25);
buffer.append("\t" + problem.getMessage() + "\n" ); //$NON-NLS-1$ //$NON-NLS-2$
buffer.insert(0, Util.bind("compilation.unresolvedProblem" )); //$NON-NLS-1$
String problemString = buffer.toString();
codeStream.init(this);
codeStream.preserveUnusedLocals = true;
codeStream.initializeMaxLocals(methodBinding);
// return codeStream.generateCodeAttributeForProblemMethod(comp.options.runtimeExceptionNameForCompileError, "")
codeStream.generateCodeAttributeForProblemMethod(problemString);
completeCodeAttributeForMissingAbstractProblemMethod(
methodBinding,
codeAttributeOffset,
compilationResult.lineSeparatorPositions,
problem.getSourceLineNumber());
completeMethodInfo(methodAttributeOffset, attributeNumber);
}
/**
*
*/
public void completeCodeAttributeForMissingAbstractProblemMethod(
MethodBinding binding,
int codeAttributeOffset,
int[] startLineIndexes,
int problemLine) {
// reinitialize the localContents with the byte modified by the code stream
this.contents = codeStream.bCodeStream;
int localContentsOffset = codeStream.classFileOffset;
// codeAttributeOffset is the position inside localContents byte array before we started to write// any information about the codeAttribute// That means that to write the attribute_length you need to offset by 2 the value of codeAttributeOffset// to get the right position, 6 for the max_stack etc...
int max_stack = codeStream.stackMax;
this.contents[codeAttributeOffset + 6] = (byte) (max_stack >> 8);
this.contents[codeAttributeOffset + 7] = (byte) max_stack;
int max_locals = codeStream.maxLocals;
this.contents[codeAttributeOffset + 8] = (byte) (max_locals >> 8);
this.contents[codeAttributeOffset + 9] = (byte) max_locals;
int code_length = codeStream.position;
this.contents[codeAttributeOffset + 10] = (byte) (code_length >> 24);
this.contents[codeAttributeOffset + 11] = (byte) (code_length >> 16);
this.contents[codeAttributeOffset + 12] = (byte) (code_length >> 8);
this.contents[codeAttributeOffset + 13] = (byte) code_length;
// write the exception table
if (localContentsOffset + 50 >= this.contents.length) {
resizeContents(50);
}
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = 0;
// debug attributes
int codeAttributeAttributeOffset = localContentsOffset;
int attributeNumber = 0; // leave two bytes for the attribute_length
localContentsOffset += 2; // first we handle the linenumber attribute
if (codeStream.generateLineNumberAttributes) {
/* Create and add the line number attribute (used for debugging)
* Build the pairs of:
* (bytecodePC lineNumber)
* according to the table of start line indexes and the pcToSourceMap table
* contained into the codestream
*/
int lineNumberNameIndex =
constantPool.literalIndex(AttributeNamesConstants.LineNumberTableName);
this.contents[localContentsOffset++] = (byte) (lineNumberNameIndex >> 8);
this.contents[localContentsOffset++] = (byte) lineNumberNameIndex;
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = 6;
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = 1;
if (problemLine == 0) {
problemLine = searchLineNumber(startLineIndexes, binding.sourceStart());
}
// first entry at pc = 0
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = (byte) (problemLine >> 8);
this.contents[localContentsOffset++] = (byte) problemLine;
// now we change the size of the line number attribute
attributeNumber++;
}
// then we do the local variable attribute
// update the number of attributes// ensure first that there is enough space available inside the localContents array
if (codeAttributeAttributeOffset + 2 >= this.contents.length) {
resizeContents(2);
}
this.contents[codeAttributeAttributeOffset++] = (byte) (attributeNumber >> 8);
this.contents[codeAttributeAttributeOffset] = (byte) attributeNumber;
// update the attribute length
int codeAttributeLength = localContentsOffset - (codeAttributeOffset + 6);
this.contents[codeAttributeOffset + 2] = (byte) (codeAttributeLength >> 24);
this.contents[codeAttributeOffset + 3] = (byte) (codeAttributeLength >> 16);
this.contents[codeAttributeOffset + 4] = (byte) (codeAttributeLength >> 8);
this.contents[codeAttributeOffset + 5] = (byte) codeAttributeLength;
contentsOffset = localContentsOffset;
}
/**
* INTERNAL USE-ONLY
* Generate the byte for a problem method info that correspond to a synthetic method that
* generate an access to a private constructor.
*
* @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.SyntheticAccessMethodBinding
*/
public void addSyntheticConstructorAccessMethod(SyntheticAccessMethodBinding methodBinding) {
generateMethodInfoHeader(methodBinding);
// We know that we won't get more than 2 attribute: the code attribute + synthetic attribute
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 2;
// Code attribute
int codeAttributeOffset = contentsOffset;
generateCodeAttributeHeader();
codeStream.init(this);
codeStream.generateSyntheticBodyForConstructorAccess(methodBinding);
completeCodeAttributeForSyntheticAccessMethod(
methodBinding,
codeAttributeOffset,
((SourceTypeBinding) methodBinding.declaringClass)
.scope
.referenceCompilationUnit()
.compilationResult
.lineSeparatorPositions);
// add the synthetic attribute
int syntheticAttributeNameIndex =
constantPool.literalIndex(AttributeNamesConstants.SyntheticName);
contents[contentsOffset++] = (byte) (syntheticAttributeNameIndex >> 8);
contents[contentsOffset++] = (byte) syntheticAttributeNameIndex;
// the length of a synthetic attribute is equals to 0
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
}
/**
* INTERNAL USE-ONLY
* Generate the byte for a problem method info that correspond to a synthetic method that
* generate an read access to a private field.
*
* @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.SyntheticAccessMethodBinding
*/
public void addSyntheticFieldReadAccessMethod(SyntheticAccessMethodBinding methodBinding) {
generateMethodInfoHeader(methodBinding);
// We know that we won't get more than 2 attribute: the code attribute + synthetic attribute
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 2;
// Code attribute
int codeAttributeOffset = contentsOffset;
generateCodeAttributeHeader();
codeStream.init(this);
codeStream.generateSyntheticBodyForFieldReadAccess(methodBinding);
completeCodeAttributeForSyntheticAccessMethod(
methodBinding,
codeAttributeOffset,
((SourceTypeBinding) methodBinding.declaringClass)
.scope
.referenceCompilationUnit()
.compilationResult
.lineSeparatorPositions);
// add the synthetic attribute
int syntheticAttributeNameIndex =
constantPool.literalIndex(AttributeNamesConstants.SyntheticName);
contents[contentsOffset++] = (byte) (syntheticAttributeNameIndex >> 8);
contents[contentsOffset++] = (byte) syntheticAttributeNameIndex;
// the length of a synthetic attribute is equals to 0
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
}
/**
* INTERNAL USE-ONLY
* Generate the byte for a problem method info that correspond to a synthetic method that
* generate an write access to a private field.
*
* @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.SyntheticAccessMethodBinding
*/
public void addSyntheticFieldWriteAccessMethod(SyntheticAccessMethodBinding methodBinding) {
generateMethodInfoHeader(methodBinding);
// We know that we won't get more than 2 attribute: the code attribute + synthetic attribute
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 2;
// Code attribute
int codeAttributeOffset = contentsOffset;
generateCodeAttributeHeader();
codeStream.init(this);
codeStream.generateSyntheticBodyForFieldWriteAccess(methodBinding);
completeCodeAttributeForSyntheticAccessMethod(
methodBinding,
codeAttributeOffset,
((SourceTypeBinding) methodBinding.declaringClass)
.scope
.referenceCompilationUnit()
.compilationResult
.lineSeparatorPositions);
// add the synthetic attribute
int syntheticAttributeNameIndex =
constantPool.literalIndex(AttributeNamesConstants.SyntheticName);
contents[contentsOffset++] = (byte) (syntheticAttributeNameIndex >> 8);
contents[contentsOffset++] = (byte) syntheticAttributeNameIndex;
// the length of a synthetic attribute is equals to 0
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
}
/**
* INTERNAL USE-ONLY
* Generate the byte for a problem method info that correspond to a synthetic method that
* generate an access to a private method.
*
* @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.SyntheticAccessMethodBinding
*/
public void addSyntheticMethodAccessMethod(SyntheticAccessMethodBinding methodBinding) {
generateMethodInfoHeader(methodBinding);
// We know that we won't get more than 2 attribute: the code attribute + synthetic attribute
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 2;
// Code attribute
int codeAttributeOffset = contentsOffset;
generateCodeAttributeHeader();
codeStream.init(this);
codeStream.generateSyntheticBodyForMethodAccess(methodBinding);
completeCodeAttributeForSyntheticAccessMethod(
methodBinding,
codeAttributeOffset,
((SourceTypeBinding) methodBinding.declaringClass)
.scope
.referenceCompilationUnit()
.compilationResult
.lineSeparatorPositions);
// add the synthetic attribute
int syntheticAttributeNameIndex =
constantPool.literalIndex(AttributeNamesConstants.SyntheticName);
contents[contentsOffset++] = (byte) (syntheticAttributeNameIndex >> 8);
contents[contentsOffset++] = (byte) syntheticAttributeNameIndex;
// the length of a synthetic attribute is equals to 0
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
}
/**
* INTERNAL USE-ONLY
* Build all the directories and subdirectories corresponding to the packages names
* into the directory specified in parameters.
*
* outputPath is formed like:
* c:\temp\ the last character is a file separator
* relativeFileName is formed like:
* java\lang\String.class *
*
* @param outputPath java.lang.String
* @param relativeFileName java.lang.String
* @return java.lang.String
*/
public static String buildAllDirectoriesInto(
String outputPath,
String relativeFileName)
throws IOException {
char fileSeparatorChar = File.separatorChar;
String fileSeparator = File.separator;
File f;
// First we ensure that the outputPath exists
outputPath = outputPath.replace('/', fileSeparatorChar);
// To be able to pass the mkdirs() method we need to remove the extra file separator at the end of the outDir name
if (outputPath.endsWith(fileSeparator)) {
outputPath = outputPath.substring(0, outputPath.length() - 1);
}
f = new File(outputPath);
if (f.exists()) {
if (!f.isDirectory()) {
System.out.println(Util.bind("output.isFile" , f.getAbsolutePath())); //$NON-NLS-1$
throw new IOException(Util.bind("output.isFileNotDirectory" )); //$NON-NLS-1$
}
} else {
// we have to create that directory
if (!f.mkdirs()) {
System.out.println(Util.bind("output.dirName" , f.getAbsolutePath())); //$NON-NLS-1$
throw new IOException(Util.bind("output.notValidAll" )); //$NON-NLS-1$
}
}
StringBuffer outDir = new StringBuffer(outputPath);
outDir.append(fileSeparator);
StringTokenizer tokenizer =
new StringTokenizer(relativeFileName, fileSeparator);
String token = tokenizer.nextToken();
while (tokenizer.hasMoreTokens()) {
f = new File(outDir.append(token).append(fileSeparator).toString());
if (f.exists()) {
// The outDir already exists, so we proceed the next entry
// System.out.println("outDir: " + outDir + " already exists.");
} else {
// Need to add the outDir
if (!f.mkdir()) {
System.out.println(Util.bind("output.fileName" , f.getName())); //$NON-NLS-1$
throw new IOException(Util.bind("output.notValid" )); //$NON-NLS-1$
}
}
token = tokenizer.nextToken();
}
// token contains the last one
return outDir.append(token).toString();
}
/**
* INTERNAL USE-ONLY
* That method completes the creation of the code attribute by setting
* - the attribute_length
* - max_stack
* - max_locals
* - code_length
* - exception table
* - and debug attributes if necessary.
*
* @param codeAttributeOffset <CODE>int</CODE>
*/
public void completeCodeAttribute(int codeAttributeOffset) {
// reinitialize the localContents with the byte modified by the code stream
this.contents = codeStream.bCodeStream;
int localContentsOffset = codeStream.classFileOffset;
// codeAttributeOffset is the position inside localContents byte array before we started to write
// any information about the codeAttribute
// That means that to write the attribute_length you need to offset by 2 the value of codeAttributeOffset
// to get the right position, 6 for the max_stack etc...
int code_length = codeStream.position;
if (code_length > 65535) {
codeStream.methodDeclaration.scope.problemReporter().bytecodeExceeds64KLimit(
codeStream.methodDeclaration);
}
if (localContentsOffset + 20 >= this.contents.length) {
resizeContents(20);
}
int max_stack = codeStream.stackMax;
this.contents[codeAttributeOffset + 6] = (byte) (max_stack >> 8);
this.contents[codeAttributeOffset + 7] = (byte) max_stack;
int max_locals = codeStream.maxLocals;
this.contents[codeAttributeOffset + 8] = (byte) (max_locals >> 8);
this.contents[codeAttributeOffset + 9] = (byte) max_locals;
this.contents[codeAttributeOffset + 10] = (byte) (code_length >> 24);
this.contents[codeAttributeOffset + 11] = (byte) (code_length >> 16);
this.contents[codeAttributeOffset + 12] = (byte) (code_length >> 8);
this.contents[codeAttributeOffset + 13] = (byte) code_length;
// write the exception table
int exceptionHandlersNumber = codeStream.exceptionHandlersCounter;
ExceptionLabel[] exceptionHandlers = codeStream.exceptionHandlers;
int exSize = exceptionHandlersNumber * 8 + 2;
if (exSize + localContentsOffset >= this.contents.length) {
resizeContents(exSize);
}
// there is no exception table, so we need to offset by 2 the current offset and move
// on the attribute generation
this.contents[localContentsOffset++] = (byte) (exceptionHandlersNumber >> 8);
this.contents[localContentsOffset++] = (byte) exceptionHandlersNumber;
for (int i = 0, max = codeStream.exceptionHandlersIndex; i < max; i++) {
ExceptionLabel exceptionHandler = exceptionHandlers[i];
if (exceptionHandler != null) {
int start = exceptionHandler.start;
this.contents[localContentsOffset++] = (byte) (start >> 8);
this.contents[localContentsOffset++] = (byte) start;
int end = exceptionHandler.end;
this.contents[localContentsOffset++] = (byte) (end >> 8);
this.contents[localContentsOffset++] = (byte) end;
int handlerPC = exceptionHandler.position;
this.contents[localContentsOffset++] = (byte) (handlerPC >> 8);
this.contents[localContentsOffset++] = (byte) handlerPC;
if (exceptionHandler.exceptionType == null) {
// any exception handler
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = 0;
} else {
int nameIndex;
if (exceptionHandler.exceptionType == BaseTypes.NullBinding) {
/* represents ClassNotFoundException, see class literal access*/
nameIndex = constantPool.literalIndexForJavaLangClassNotFoundException();
} else {
nameIndex = constantPool.literalIndex(exceptionHandler.exceptionType);
}
this.contents[localContentsOffset++] = (byte) (nameIndex >> 8);
this.contents[localContentsOffset++] = (byte) nameIndex;
}
}
}
// debug attributes
int codeAttributeAttributeOffset = localContentsOffset;
int attributeNumber = 0;
// leave two bytes for the attribute_length
localContentsOffset += 2;
// first we handle the linenumber attribute
if (codeStream.generateLineNumberAttributes) {
/* Create and add the line number attribute (used for debugging)
* Build the pairs of:
* (bytecodePC lineNumber)
* according to the table of start line indexes and the pcToSourceMap table
* contained into the codestream
*/
int[] pcToSourceMapTable;
if (((pcToSourceMapTable = codeStream.pcToSourceMap) != null)
&& (codeStream.pcToSourceMapSize != 0)) {
int lineNumberNameIndex =
constantPool.literalIndex(AttributeNamesConstants.LineNumberTableName);
if (localContentsOffset + 8 >= this.contents.length) {
resizeContents(8);
}
this.contents[localContentsOffset++] = (byte) (lineNumberNameIndex >> 8);
this.contents[localContentsOffset++] = (byte) lineNumberNameIndex;
int lineNumberTableOffset = localContentsOffset;
localContentsOffset += 6;
// leave space for attribute_length and line_number_table_length
int numberOfEntries = 0;
int length = codeStream.pcToSourceMapSize;
for (int i = 0; i < length;) {
// write the entry
if (localContentsOffset + 4 >= this.contents.length) {
resizeContents(4);
}
int pc = pcToSourceMapTable[i++];
this.contents[localContentsOffset++] = (byte) (pc >> 8);
this.contents[localContentsOffset++] = (byte) pc;
int lineNumber = pcToSourceMapTable[i++];
this.contents[localContentsOffset++] = (byte) (lineNumber >> 8);
this.contents[localContentsOffset++] = (byte) lineNumber;
numberOfEntries++;
}
// now we change the size of the line number attribute
int lineNumberAttr_length = numberOfEntries * 4 + 2;
this.contents[lineNumberTableOffset++] = (byte) (lineNumberAttr_length >> 24);
this.contents[lineNumberTableOffset++] = (byte) (lineNumberAttr_length >> 16);
this.contents[lineNumberTableOffset++] = (byte) (lineNumberAttr_length >> 8);
this.contents[lineNumberTableOffset++] = (byte) lineNumberAttr_length;
this.contents[lineNumberTableOffset++] = (byte) (numberOfEntries >> 8);
this.contents[lineNumberTableOffset++] = (byte) numberOfEntries;
attributeNumber++;
}
}
// then we do the local variable attribute
if (codeStream.generateLocalVariableTableAttributes) {
int localVariableTableOffset = localContentsOffset;
int numberOfEntries = 0;
int localVariableNameIndex =
constantPool.literalIndex(AttributeNamesConstants.LocalVariableTableName);
final boolean methodDeclarationIsStatic = codeStream.methodDeclaration.isStatic();
int maxOfEntries = 8 + 10 * (methodDeclarationIsStatic ? 0 : 1);
for (int i = 0; i < codeStream.allLocalsCounter; i++) {
maxOfEntries += 10 * codeStream.locals[i].initializationCount;
}
// reserve enough space
if (localContentsOffset + maxOfEntries >= this.contents.length) {
resizeContents(maxOfEntries);
}
this.contents[localContentsOffset++] = (byte) (localVariableNameIndex >> 8);
this.contents[localContentsOffset++] = (byte) localVariableNameIndex;
localContentsOffset += 6;
// leave space for attribute_length and local_variable_table_length
int nameIndex;
int descriptorIndex;
SourceTypeBinding declaringClassBinding = null;
if (!methodDeclarationIsStatic) {
numberOfEntries++;
this.contents[localContentsOffset++] = 0; // the startPC for this is always 0
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = (byte) (code_length >> 8);
this.contents[localContentsOffset++] = (byte) code_length;
nameIndex = constantPool.literalIndex(QualifiedNamesConstants.This);
this.contents[localContentsOffset++] = (byte) (nameIndex >> 8);
this.contents[localContentsOffset++] = (byte) nameIndex;
declaringClassBinding = (SourceTypeBinding) codeStream.methodDeclaration.binding.declaringClass;
descriptorIndex =
constantPool.literalIndex(
declaringClassBinding.signature());
this.contents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
this.contents[localContentsOffset++] = (byte) descriptorIndex;
this.contents[localContentsOffset++] = 0;// the resolved position for this is always 0
this.contents[localContentsOffset++] = 0;
}
// used to remember the local variable with a generic type
int genericLocalVariablesCounter = 0;
LocalVariableBinding[] genericLocalVariables = null;
int numberOfGenericEntries = 0;
for (int i = 0, max = codeStream.allLocalsCounter; i < max; i++) {
LocalVariableBinding localVariable = codeStream.locals[i];
final TypeBinding localVariableTypeBinding = localVariable.type;
boolean isParameterizedType = localVariableTypeBinding.isParameterizedType() || localVariableTypeBinding.isTypeVariable();
if (localVariable.initializationCount != 0 && isParameterizedType) {
if (genericLocalVariables == null) {
// we cannot have more than max locals
genericLocalVariables = new LocalVariableBinding[max];
}
genericLocalVariables[genericLocalVariablesCounter++] = localVariable;
}
for (int j = 0; j < localVariable.initializationCount; j++) {
int startPC = localVariable.initializationPCs[j << 1];
int endPC = localVariable.initializationPCs[(j << 1) + 1];
if (startPC != endPC) { // only entries for non zero length
if (endPC == -1) {
localVariable.declaringScope.problemReporter().abortDueToInternalError(
Util.bind("abort.invalidAttribute" , new String(localVariable.name)), //$NON-NLS-1$
(ASTNode) localVariable.declaringScope.methodScope().referenceContext);
}
if (isParameterizedType) {
numberOfGenericEntries++;
}
// now we can safely add the local entry
numberOfEntries++;
this.contents[localContentsOffset++] = (byte) (startPC >> 8);
this.contents[localContentsOffset++] = (byte) startPC;
int length = endPC - startPC;
this.contents[localContentsOffset++] = (byte) (length >> 8);
this.contents[localContentsOffset++] = (byte) length;
nameIndex = constantPool.literalIndex(localVariable.name);
this.contents[localContentsOffset++] = (byte) (nameIndex >> 8);
this.contents[localContentsOffset++] = (byte) nameIndex;
descriptorIndex = constantPool.literalIndex(localVariableTypeBinding.signature());
this.contents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
this.contents[localContentsOffset++] = (byte) descriptorIndex;
int resolvedPosition = localVariable.resolvedPosition;
this.contents[localContentsOffset++] = (byte) (resolvedPosition >> 8);
this.contents[localContentsOffset++] = (byte) resolvedPosition;
}
}
}
int value = numberOfEntries * 10 + 2;
localVariableTableOffset += 2;
this.contents[localVariableTableOffset++] = (byte) (value >> 24);
this.contents[localVariableTableOffset++] = (byte) (value >> 16);
this.contents[localVariableTableOffset++] = (byte) (value >> 8);
this.contents[localVariableTableOffset++] = (byte) value;
this.contents[localVariableTableOffset++] = (byte) (numberOfEntries >> 8);
this.contents[localVariableTableOffset] = (byte) numberOfEntries;
attributeNumber++;
final boolean currentInstanceIsGeneric =
!methodDeclarationIsStatic
&& declaringClassBinding != null
&& declaringClassBinding.typeVariables != NoTypeVariables;
if (genericLocalVariablesCounter != 0 || currentInstanceIsGeneric) {
// add the local variable type table attribute
numberOfGenericEntries += (currentInstanceIsGeneric ? 1 : 0);
maxOfEntries = 8 + numberOfGenericEntries * 10;
// reserve enough space
if (localContentsOffset + maxOfEntries >= this.contents.length) {
resizeContents(maxOfEntries);
}
int localVariableTypeNameIndex =
constantPool.literalIndex(AttributeNamesConstants.LocalVariableTypeTableName);
this.contents[localContentsOffset++] = (byte) (localVariableTypeNameIndex >> 8);
this.contents[localContentsOffset++] = (byte) localVariableTypeNameIndex;
value = numberOfGenericEntries * 10 + 2;
this.contents[localContentsOffset++] = (byte) (value >> 24);
this.contents[localContentsOffset++] = (byte) (value >> 16);
this.contents[localContentsOffset++] = (byte) (value >> 8);
this.contents[localContentsOffset++] = (byte) value;
this.contents[localContentsOffset++] = (byte) (numberOfGenericEntries >> 8);
this.contents[localContentsOffset++] = (byte) numberOfGenericEntries;
if (currentInstanceIsGeneric) {
this.contents[localContentsOffset++] = 0; // the startPC for this is always 0
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = (byte) (code_length >> 8);
this.contents[localContentsOffset++] = (byte) code_length;
nameIndex = constantPool.literalIndex(QualifiedNamesConstants.This);
this.contents[localContentsOffset++] = (byte) (nameIndex >> 8);
this.contents[localContentsOffset++] = (byte) nameIndex;
descriptorIndex = constantPool.literalIndex(declaringClassBinding.genericTypeSignature());
this.contents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
this.contents[localContentsOffset++] = (byte) descriptorIndex;
this.contents[localContentsOffset++] = 0;// the resolved position for this is always 0
this.contents[localContentsOffset++] = 0;
}
for (int i = 0; i < genericLocalVariablesCounter; i++) {
LocalVariableBinding localVariable = genericLocalVariables[i];
for (int j = 0; j < localVariable.initializationCount; j++) {
int startPC = localVariable.initializationPCs[j << 1];
int endPC = localVariable.initializationPCs[(j << 1) + 1];
if (startPC != endPC) {
// only entries for non zero length
// now we can safely add the local entry
this.contents[localContentsOffset++] = (byte) (startPC >> 8);
this.contents[localContentsOffset++] = (byte) startPC;
int length = endPC - startPC;
this.contents[localContentsOffset++] = (byte) (length >> 8);
this.contents[localContentsOffset++] = (byte) length;
nameIndex = constantPool.literalIndex(localVariable.name);
this.contents[localContentsOffset++] = (byte) (nameIndex >> 8);
this.contents[localContentsOffset++] = (byte) nameIndex;
descriptorIndex = constantPool.literalIndex(localVariable.type.genericTypeSignature());
this.contents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
this.contents[localContentsOffset++] = (byte) descriptorIndex;
int resolvedPosition = localVariable.resolvedPosition;
this.contents[localContentsOffset++] = (byte) (resolvedPosition >> 8);
this.contents[localContentsOffset++] = (byte) resolvedPosition;
}
}
}
attributeNumber++;
}
}
// update the number of attributes
// ensure first that there is enough space available inside the localContents array
if (codeAttributeAttributeOffset + 2 >= this.contents.length) {
resizeContents(2);
}
this.contents[codeAttributeAttributeOffset++] = (byte) (attributeNumber >> 8);
this.contents[codeAttributeAttributeOffset] = (byte) attributeNumber;
// update the attribute length
int codeAttributeLength = localContentsOffset - (codeAttributeOffset + 6);
this.contents[codeAttributeOffset + 2] = (byte) (codeAttributeLength >> 24);
this.contents[codeAttributeOffset + 3] = (byte) (codeAttributeLength >> 16);
this.contents[codeAttributeOffset + 4] = (byte) (codeAttributeLength >> 8);
this.contents[codeAttributeOffset + 5] = (byte) codeAttributeLength;
contentsOffset = localContentsOffset;
}
/**
* INTERNAL USE-ONLY
* That method completes the creation of the code attribute by setting
* - the attribute_length
* - max_stack
* - max_locals
* - code_length
* - exception table
* - and debug attributes if necessary.
*
* @param codeAttributeOffset <CODE>int</CODE>
*/
public void completeCodeAttributeForClinit(int codeAttributeOffset) {
// reinitialize the contents with the byte modified by the code stream
this.contents = codeStream.bCodeStream;
int localContentsOffset = codeStream.classFileOffset;
// codeAttributeOffset is the position inside contents byte array before we started to write
// any information about the codeAttribute
// That means that to write the attribute_length you need to offset by 2 the value of codeAttributeOffset
// to get the right position, 6 for the max_stack etc...
int code_length = codeStream.position;
if (code_length > 65535) {
codeStream.methodDeclaration.scope.problemReporter().bytecodeExceeds64KLimit(
codeStream.methodDeclaration.scope.referenceType());
}
if (localContentsOffset + 20 >= this.contents.length) {
resizeContents(20);
}
int max_stack = codeStream.stackMax;
this.contents[codeAttributeOffset + 6] = (byte) (max_stack >> 8);
this.contents[codeAttributeOffset + 7] = (byte) max_stack;
int max_locals = codeStream.maxLocals;
this.contents[codeAttributeOffset + 8] = (byte) (max_locals >> 8);
this.contents[codeAttributeOffset + 9] = (byte) max_locals;
this.contents[codeAttributeOffset + 10] = (byte) (code_length >> 24);
this.contents[codeAttributeOffset + 11] = (byte) (code_length >> 16);
this.contents[codeAttributeOffset + 12] = (byte) (code_length >> 8);
this.contents[codeAttributeOffset + 13] = (byte) code_length;
// write the exception table
int exceptionHandlersNumber = codeStream.exceptionHandlersCounter;
ExceptionLabel[] exceptionHandlers = codeStream.exceptionHandlers;
int exSize = exceptionHandlersNumber * 8 + 2;
if (exSize + localContentsOffset >= this.contents.length) {
resizeContents(exSize);
}
// there is no exception table, so we need to offset by 2 the current offset and move
// on the attribute generation
this.contents[localContentsOffset++] = (byte) (exceptionHandlersNumber >> 8);
this.contents[localContentsOffset++] = (byte) exceptionHandlersNumber;
for (int i = 0, max = codeStream.exceptionHandlersIndex; i < max; i++) {
ExceptionLabel exceptionHandler = exceptionHandlers[i];
if (exceptionHandler != null) {
int start = exceptionHandler.start;
this.contents[localContentsOffset++] = (byte) (start >> 8);
this.contents[localContentsOffset++] = (byte) start;
int end = exceptionHandler.end;
this.contents[localContentsOffset++] = (byte) (end >> 8);
this.contents[localContentsOffset++] = (byte) end;
int handlerPC = exceptionHandler.position;
this.contents[localContentsOffset++] = (byte) (handlerPC >> 8);
this.contents[localContentsOffset++] = (byte) handlerPC;
if (exceptionHandler.exceptionType == null) {
// any exception handler
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = 0;
} else {
int nameIndex;
if (exceptionHandler.exceptionType == BaseTypes.NullBinding) {
/* represents denote ClassNotFoundException, see class literal access*/
nameIndex = constantPool.literalIndexForJavaLangClassNotFoundException();
} else {
nameIndex = constantPool.literalIndex(exceptionHandler.exceptionType);
}
this.contents[localContentsOffset++] = (byte) (nameIndex >> 8);
this.contents[localContentsOffset++] = (byte) nameIndex;
}
}
}
// debug attributes
int codeAttributeAttributeOffset = localContentsOffset;
int attributeNumber = 0;
// leave two bytes for the attribute_length
localContentsOffset += 2;
// first we handle the linenumber attribute
if (codeStream.generateLineNumberAttributes) {
/* Create and add the line number attribute (used for debugging)
* Build the pairs of:
* (bytecodePC lineNumber)
* according to the table of start line indexes and the pcToSourceMap table
* contained into the codestream
*/
int[] pcToSourceMapTable;
if (((pcToSourceMapTable = codeStream.pcToSourceMap) != null)
&& (codeStream.pcToSourceMapSize != 0)) {
int lineNumberNameIndex =
constantPool.literalIndex(AttributeNamesConstants.LineNumberTableName);
if (localContentsOffset + 8 >= this.contents.length) {
resizeContents(8);
}
this.contents[localContentsOffset++] = (byte) (lineNumberNameIndex >> 8);
this.contents[localContentsOffset++] = (byte) lineNumberNameIndex;
int lineNumberTableOffset = localContentsOffset;
localContentsOffset += 6;
// leave space for attribute_length and line_number_table_length
int numberOfEntries = 0;
int length = codeStream.pcToSourceMapSize;
for (int i = 0; i < length;) {
// write the entry
if (localContentsOffset + 4 >= this.contents.length) {
resizeContents(4);
}
int pc = pcToSourceMapTable[i++];
this.contents[localContentsOffset++] = (byte) (pc >> 8);
this.contents[localContentsOffset++] = (byte) pc;
int lineNumber = pcToSourceMapTable[i++];
this.contents[localContentsOffset++] = (byte) (lineNumber >> 8);
this.contents[localContentsOffset++] = (byte) lineNumber;
numberOfEntries++;
}
// now we change the size of the line number attribute
int lineNumberAttr_length = numberOfEntries * 4 + 2;
this.contents[lineNumberTableOffset++] = (byte) (lineNumberAttr_length >> 24);
this.contents[lineNumberTableOffset++] = (byte) (lineNumberAttr_length >> 16);
this.contents[lineNumberTableOffset++] = (byte) (lineNumberAttr_length >> 8);
this.contents[lineNumberTableOffset++] = (byte) lineNumberAttr_length;
this.contents[lineNumberTableOffset++] = (byte) (numberOfEntries >> 8);
this.contents[lineNumberTableOffset++] = (byte) numberOfEntries;
attributeNumber++;
}
}
// then we do the local variable attribute
if (codeStream.generateLocalVariableTableAttributes) {
int localVariableTableOffset = localContentsOffset;
int numberOfEntries = 0;
// codeAttribute.addLocalVariableTableAttribute(this);
if ((codeStream.pcToSourceMap != null)
&& (codeStream.pcToSourceMapSize != 0)) {
int localVariableNameIndex =
constantPool.literalIndex(AttributeNamesConstants.LocalVariableTableName);
if (localContentsOffset + 8 >= this.contents.length) {
resizeContents(8);
}
this.contents[localContentsOffset++] = (byte) (localVariableNameIndex >> 8);
this.contents[localContentsOffset++] = (byte) localVariableNameIndex;
localContentsOffset += 6;
// leave space for attribute_length and local_variable_table_length
int nameIndex;
int descriptorIndex;
// used to remember the local variable with a generic type
int genericLocalVariablesCounter = 0;
LocalVariableBinding[] genericLocalVariables = null;
int numberOfGenericEntries = 0;
for (int i = 0, max = codeStream.allLocalsCounter; i < max; i++) {
LocalVariableBinding localVariable = codeStream.locals[i];
final TypeBinding localVariableTypeBinding = localVariable.type;
boolean isParameterizedType = localVariableTypeBinding.isParameterizedType() || localVariableTypeBinding.isTypeVariable();
if (localVariable.initializationCount != 0 && isParameterizedType) {
if (genericLocalVariables == null) {
// we cannot have more than max locals
genericLocalVariables = new LocalVariableBinding[max];
}
genericLocalVariables[genericLocalVariablesCounter++] = localVariable;
}
for (int j = 0; j < localVariable.initializationCount; j++) {
int startPC = localVariable.initializationPCs[j << 1];
int endPC = localVariable.initializationPCs[(j << 1) + 1];
if (startPC != endPC) { // only entries for non zero length
if (endPC == -1) {
localVariable.declaringScope.problemReporter().abortDueToInternalError(
Util.bind("abort.invalidAttribute" , new String(localVariable.name)), //$NON-NLS-1$
(ASTNode) localVariable.declaringScope.methodScope().referenceContext);
}
if (localContentsOffset + 10 >= this.contents.length) {
resizeContents(10);
}
// now we can safely add the local entry
numberOfEntries++;
if (isParameterizedType) {
numberOfGenericEntries++;
}
this.contents[localContentsOffset++] = (byte) (startPC >> 8);
this.contents[localContentsOffset++] = (byte) startPC;
int length = endPC - startPC;
this.contents[localContentsOffset++] = (byte) (length >> 8);
this.contents[localContentsOffset++] = (byte) length;
nameIndex = constantPool.literalIndex(localVariable.name);
this.contents[localContentsOffset++] = (byte) (nameIndex >> 8);
this.contents[localContentsOffset++] = (byte) nameIndex;
descriptorIndex = constantPool.literalIndex(localVariableTypeBinding.signature());
this.contents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
this.contents[localContentsOffset++] = (byte) descriptorIndex;
int resolvedPosition = localVariable.resolvedPosition;
this.contents[localContentsOffset++] = (byte) (resolvedPosition >> 8);
this.contents[localContentsOffset++] = (byte) resolvedPosition;
}
}
}
int value = numberOfEntries * 10 + 2;
localVariableTableOffset += 2;
this.contents[localVariableTableOffset++] = (byte) (value >> 24);
this.contents[localVariableTableOffset++] = (byte) (value >> 16);
this.contents[localVariableTableOffset++] = (byte) (value >> 8);
this.contents[localVariableTableOffset++] = (byte) value;
this.contents[localVariableTableOffset++] = (byte) (numberOfEntries >> 8);
this.contents[localVariableTableOffset] = (byte) numberOfEntries;
attributeNumber++;
if (genericLocalVariablesCounter != 0) {
// add the local variable type table attribute
// reserve enough space
int maxOfEntries = 8 + numberOfGenericEntries * 10;
if (localContentsOffset + maxOfEntries >= this.contents.length) {
resizeContents(maxOfEntries);
}
int localVariableTypeNameIndex =
constantPool.literalIndex(AttributeNamesConstants.LocalVariableTypeTableName);
this.contents[localContentsOffset++] = (byte) (localVariableTypeNameIndex >> 8);
this.contents[localContentsOffset++] = (byte) localVariableTypeNameIndex;
value = numberOfGenericEntries * 10 + 2;
this.contents[localContentsOffset++] = (byte) (value >> 24);
this.contents[localContentsOffset++] = (byte) (value >> 16);
this.contents[localContentsOffset++] = (byte) (value >> 8);
this.contents[localContentsOffset++] = (byte) value;
this.contents[localContentsOffset++] = (byte) (numberOfGenericEntries >> 8);
this.contents[localContentsOffset++] = (byte) numberOfGenericEntries;
for (int i = 0; i < genericLocalVariablesCounter; i++) {
LocalVariableBinding localVariable = genericLocalVariables[i];
for (int j = 0; j < localVariable.initializationCount; j++) {
int startPC = localVariable.initializationPCs[j << 1];
int endPC = localVariable.initializationPCs[(j << 1) + 1];
if (startPC != endPC) { // only entries for non zero length
// now we can safely add the local entry
this.contents[localContentsOffset++] = (byte) (startPC >> 8);
this.contents[localContentsOffset++] = (byte) startPC;
int length = endPC - startPC;
this.contents[localContentsOffset++] = (byte) (length >> 8);
this.contents[localContentsOffset++] = (byte) length;
nameIndex = constantPool.literalIndex(localVariable.name);
this.contents[localContentsOffset++] = (byte) (nameIndex >> 8);
this.contents[localContentsOffset++] = (byte) nameIndex;
descriptorIndex = constantPool.literalIndex(localVariable.type.genericTypeSignature());
this.contents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
this.contents[localContentsOffset++] = (byte) descriptorIndex;
int resolvedPosition = localVariable.resolvedPosition;
this.contents[localContentsOffset++] = (byte) (resolvedPosition >> 8);
this.contents[localContentsOffset++] = (byte) resolvedPosition;
}
}
}
attributeNumber++;
}
}
}
// update the number of attributes
// ensure first that there is enough space available inside the contents array
if (codeAttributeAttributeOffset + 2 >= this.contents.length) {
resizeContents(2);
}
this.contents[codeAttributeAttributeOffset++] = (byte) (attributeNumber >> 8);
this.contents[codeAttributeAttributeOffset] = (byte) attributeNumber;
// update the attribute length
int codeAttributeLength = localContentsOffset - (codeAttributeOffset + 6);
this.contents[codeAttributeOffset + 2] = (byte) (codeAttributeLength >> 24);
this.contents[codeAttributeOffset + 3] = (byte) (codeAttributeLength >> 16);
this.contents[codeAttributeOffset + 4] = (byte) (codeAttributeLength >> 8);
this.contents[codeAttributeOffset + 5] = (byte) codeAttributeLength;
contentsOffset = localContentsOffset;
}
/**
* INTERNAL USE-ONLY
* That method completes the creation of the code attribute by setting
* - the attribute_length
* - max_stack
* - max_locals
* - code_length
* - exception table
* - and debug attributes if necessary.
*
* @param codeAttributeOffset <CODE>int</CODE>
* @param startLineIndexes int[]
*/
public void completeCodeAttributeForClinit(
int codeAttributeOffset,
int[] startLineIndexes,
int problemLine) {
// reinitialize the contents with the byte modified by the code stream
this.contents = codeStream.bCodeStream;
int localContentsOffset = codeStream.classFileOffset;
// codeAttributeOffset is the position inside contents byte array before we started to write
// any information about the codeAttribute
// That means that to write the attribute_length you need to offset by 2 the value of codeAttributeOffset
// to get the right position, 6 for the max_stack etc...
int code_length = codeStream.position;
if (code_length > 65535) {
codeStream.methodDeclaration.scope.problemReporter().bytecodeExceeds64KLimit(
codeStream.methodDeclaration.scope.referenceType());
}
if (localContentsOffset + 20 >= this.contents.length) {
resizeContents(20);
}
int max_stack = codeStream.stackMax;
this.contents[codeAttributeOffset + 6] = (byte) (max_stack >> 8);
this.contents[codeAttributeOffset + 7] = (byte) max_stack;
int max_locals = codeStream.maxLocals;
this.contents[codeAttributeOffset + 8] = (byte) (max_locals >> 8);
this.contents[codeAttributeOffset + 9] = (byte) max_locals;
this.contents[codeAttributeOffset + 10] = (byte) (code_length >> 24);
this.contents[codeAttributeOffset + 11] = (byte) (code_length >> 16);
this.contents[codeAttributeOffset + 12] = (byte) (code_length >> 8);
this.contents[codeAttributeOffset + 13] = (byte) code_length;
// write the exception table
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = 0;
// debug attributes
int codeAttributeAttributeOffset = localContentsOffset;
int attributeNumber = 0; // leave two bytes for the attribute_length
localContentsOffset += 2; // first we handle the linenumber attribute
// first we handle the linenumber attribute
if (codeStream.generateLineNumberAttributes) {
if (localContentsOffset + 20 >= this.contents.length) {
resizeContents(20);
}
/* Create and add the line number attribute (used for debugging)
* Build the pairs of:
* (bytecodePC lineNumber)
* according to the table of start line indexes and the pcToSourceMap table
* contained into the codestream
*/
int lineNumberNameIndex =
constantPool.literalIndex(AttributeNamesConstants.LineNumberTableName);
this.contents[localContentsOffset++] = (byte) (lineNumberNameIndex >> 8);
this.contents[localContentsOffset++] = (byte) lineNumberNameIndex;
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = 6;
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = 1;
// first entry at pc = 0
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = (byte) (problemLine >> 8);
this.contents[localContentsOffset++] = (byte) problemLine;
// now we change the size of the line number attribute
attributeNumber++;
}
// then we do the local variable attribute
if (codeStream.generateLocalVariableTableAttributes) {
int localVariableNameIndex =
constantPool.literalIndex(AttributeNamesConstants.LocalVariableTableName);
if (localContentsOffset + 8 >= this.contents.length) {
resizeContents(8);
}
this.contents[localContentsOffset++] = (byte) (localVariableNameIndex >> 8);
this.contents[localContentsOffset++] = (byte) localVariableNameIndex;
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = 2;
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = 0;
attributeNumber++;
}
// update the number of attributes
// ensure first that there is enough space available inside the contents array
if (codeAttributeAttributeOffset + 2 >= this.contents.length) {
resizeContents(2);
}
this.contents[codeAttributeAttributeOffset++] = (byte) (attributeNumber >> 8);
this.contents[codeAttributeAttributeOffset] = (byte) attributeNumber;
// update the attribute length
int codeAttributeLength = localContentsOffset - (codeAttributeOffset + 6);
this.contents[codeAttributeOffset + 2] = (byte) (codeAttributeLength >> 24);
this.contents[codeAttributeOffset + 3] = (byte) (codeAttributeLength >> 16);
this.contents[codeAttributeOffset + 4] = (byte) (codeAttributeLength >> 8);
this.contents[codeAttributeOffset + 5] = (byte) codeAttributeLength;
contentsOffset = localContentsOffset;
}
/**
* INTERNAL USE-ONLY
* That method completes the creation of the code attribute by setting
* - the attribute_length
* - max_stack
* - max_locals
* - code_length
* - exception table
* - and debug attributes if necessary.
*
* @param codeAttributeOffset <CODE>int</CODE>
*/
public void completeCodeAttributeForProblemMethod(
AbstractMethodDeclaration method,
MethodBinding binding,
int codeAttributeOffset,
int[] startLineIndexes,
int problemLine) {
// reinitialize the localContents with the byte modified by the code stream
this.contents = codeStream.bCodeStream;
int localContentsOffset = codeStream.classFileOffset;
// codeAttributeOffset is the position inside localContents byte array before we started to write// any information about the codeAttribute// That means that to write the attribute_length you need to offset by 2 the value of codeAttributeOffset// to get the right position, 6 for the max_stack etc...
int max_stack = codeStream.stackMax;
this.contents[codeAttributeOffset + 6] = (byte) (max_stack >> 8);
this.contents[codeAttributeOffset + 7] = (byte) max_stack;
int max_locals = codeStream.maxLocals;
this.contents[codeAttributeOffset + 8] = (byte) (max_locals >> 8);
this.contents[codeAttributeOffset + 9] = (byte) max_locals;
int code_length = codeStream.position;
this.contents[codeAttributeOffset + 10] = (byte) (code_length >> 24);
this.contents[codeAttributeOffset + 11] = (byte) (code_length >> 16);
this.contents[codeAttributeOffset + 12] = (byte) (code_length >> 8);
this.contents[codeAttributeOffset + 13] = (byte) code_length;
// write the exception table
if (localContentsOffset + 50 >= this.contents.length) {
resizeContents(50);
}
// write the exception table
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = 0;
// debug attributes
int codeAttributeAttributeOffset = localContentsOffset;
int attributeNumber = 0; // leave two bytes for the attribute_length
localContentsOffset += 2; // first we handle the linenumber attribute
if (codeStream.generateLineNumberAttributes) {
if (localContentsOffset + 20 >= this.contents.length) {
resizeContents(20);
}
/* Create and add the line number attribute (used for debugging)
* Build the pairs of:
* (bytecodePC lineNumber)
* according to the table of start line indexes and the pcToSourceMap table
* contained into the codestream
*/
int lineNumberNameIndex =
constantPool.literalIndex(AttributeNamesConstants.LineNumberTableName);
this.contents[localContentsOffset++] = (byte) (lineNumberNameIndex >> 8);
this.contents[localContentsOffset++] = (byte) lineNumberNameIndex;
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = 6;
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = 1;
if (problemLine == 0) {
problemLine = searchLineNumber(startLineIndexes, binding.sourceStart());
}
// first entry at pc = 0
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = (byte) (problemLine >> 8);
this.contents[localContentsOffset++] = (byte) problemLine;
// now we change the size of the line number attribute
attributeNumber++;
}
// then we do the local variable attribute
if (codeStream.generateLocalVariableTableAttributes) {
// compute the resolved position for the arguments of the method
int argSize;
int localVariableTableOffset = localContentsOffset;
int numberOfEntries = 0;
// codeAttribute.addLocalVariableTableAttribute(this);
int localVariableNameIndex =
constantPool.literalIndex(AttributeNamesConstants.LocalVariableTableName);
if (localContentsOffset + 8 >= this.contents.length) {
resizeContents(8);
}
this.contents[localContentsOffset++] = (byte) (localVariableNameIndex >> 8);
this.contents[localContentsOffset++] = (byte) localVariableNameIndex;
localContentsOffset += 6;
// leave space for attribute_length and local_variable_table_length
int descriptorIndex;
int nameIndex;
SourceTypeBinding declaringClassBinding = null;
final boolean methodDeclarationIsStatic = codeStream.methodDeclaration.isStatic();
if (!methodDeclarationIsStatic) {
numberOfEntries++;
if (localContentsOffset + 10 >= this.contents.length) {
resizeContents(10);
}
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = (byte) (code_length >> 8);
this.contents[localContentsOffset++] = (byte) code_length;
nameIndex = constantPool.literalIndex(QualifiedNamesConstants.This);
this.contents[localContentsOffset++] = (byte) (nameIndex >> 8);
this.contents[localContentsOffset++] = (byte) nameIndex;
declaringClassBinding = (SourceTypeBinding) codeStream.methodDeclaration.binding.declaringClass;
descriptorIndex =
constantPool.literalIndex(declaringClassBinding.signature());
this.contents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
this.contents[localContentsOffset++] = (byte) descriptorIndex;
// the resolved position for this is always 0
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = 0;
}
// used to remember the local variable with a generic type
int genericLocalVariablesCounter = 0;
LocalVariableBinding[] genericLocalVariables = null;
int numberOfGenericEntries = 0;
if (binding.isConstructor()) {
ReferenceBinding declaringClass = binding.declaringClass;
if (declaringClass.isNestedType()) {
NestedTypeBinding methodDeclaringClass = (NestedTypeBinding) declaringClass;
argSize = methodDeclaringClass.enclosingInstancesSlotSize;
SyntheticArgumentBinding[] syntheticArguments;
if ((syntheticArguments = methodDeclaringClass.syntheticEnclosingInstances()) != null) {
for (int i = 0, max = syntheticArguments.length; i < max; i++) {
LocalVariableBinding localVariable = syntheticArguments[i];
final TypeBinding localVariableTypeBinding = localVariable.type;
if (localVariableTypeBinding.isParameterizedType() || localVariableTypeBinding.isTypeVariable()) {
if (genericLocalVariables == null) {
// we cannot have more than max locals
genericLocalVariables = new LocalVariableBinding[max];
}
genericLocalVariables[genericLocalVariablesCounter++] = localVariable;
numberOfGenericEntries++;
}
if (localContentsOffset + 10 >= this.contents.length) {
resizeContents(10);
}
// now we can safely add the local entry
numberOfEntries++;
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = (byte) (code_length >> 8);
this.contents[localContentsOffset++] = (byte) code_length;
nameIndex = constantPool.literalIndex(localVariable.name);
this.contents[localContentsOffset++] = (byte) (nameIndex >> 8);
this.contents[localContentsOffset++] = (byte) nameIndex;
descriptorIndex = constantPool.literalIndex(localVariableTypeBinding.signature());
this.contents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
this.contents[localContentsOffset++] = (byte) descriptorIndex;
int resolvedPosition = localVariable.resolvedPosition;
this.contents[localContentsOffset++] = (byte) (resolvedPosition >> 8);
this.contents[localContentsOffset++] = (byte) resolvedPosition;
}
}
} else {
argSize = 1;
}
} else {
argSize = binding.isStatic() ? 0 : 1;
}
int genericArgumentsCounter = 0;
int[] genericArgumentsNameIndexes = null;
int[] genericArgumentsResolvedPositions = null;
TypeBinding[] genericArgumentsTypeBindings = null;
if (method.binding != null) {
TypeBinding[] parameters = method.binding.parameters;
Argument[] arguments = method.arguments;
if ((parameters != null) && (arguments != null)) {
for (int i = 0, max = parameters.length; i < max; i++) {
TypeBinding argumentBinding = parameters[i];
if (localContentsOffset + 10 >= this.contents.length) {
resizeContents(10);
}
// now we can safely add the local entry
numberOfEntries++;
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = (byte) (code_length >> 8);
this.contents[localContentsOffset++] = (byte) code_length;
nameIndex = constantPool.literalIndex(arguments[i].name);
this.contents[localContentsOffset++] = (byte) (nameIndex >> 8);
this.contents[localContentsOffset++] = (byte) nameIndex;
int resolvedPosition = argSize;
if (argumentBinding.isParameterizedType() || argumentBinding.isTypeVariable()) {
if (genericArgumentsCounter == 0) {
// we cannot have more than max locals
genericArgumentsNameIndexes = new int[max];
genericArgumentsResolvedPositions = new int[max];
genericArgumentsTypeBindings = new TypeBinding[max];
}
genericArgumentsNameIndexes[genericArgumentsCounter] = nameIndex;
genericArgumentsResolvedPositions[genericArgumentsCounter] = resolvedPosition;
genericArgumentsTypeBindings[genericArgumentsCounter++] = argumentBinding;
}
descriptorIndex = constantPool.literalIndex(argumentBinding.signature());
this.contents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
this.contents[localContentsOffset++] = (byte) descriptorIndex;
if ((argumentBinding == BaseTypes.LongBinding)
|| (argumentBinding == BaseTypes.DoubleBinding))
argSize += 2;
else
argSize++;
this.contents[localContentsOffset++] = (byte) (resolvedPosition >> 8);
this.contents[localContentsOffset++] = (byte) resolvedPosition;
}
}
}
int value = numberOfEntries * 10 + 2;
localVariableTableOffset += 2;
this.contents[localVariableTableOffset++] = (byte) (value >> 24);
this.contents[localVariableTableOffset++] = (byte) (value >> 16);
this.contents[localVariableTableOffset++] = (byte) (value >> 8);
this.contents[localVariableTableOffset++] = (byte) value;
this.contents[localVariableTableOffset++] = (byte) (numberOfEntries >> 8);
this.contents[localVariableTableOffset] = (byte) numberOfEntries;
attributeNumber++;
final boolean currentInstanceIsGeneric =
!methodDeclarationIsStatic
&& declaringClassBinding != null
&& declaringClassBinding.typeVariables != NoTypeVariables;
if (genericLocalVariablesCounter != 0 || genericArgumentsCounter != 0 || currentInstanceIsGeneric) {
// add the local variable type table attribute
numberOfEntries = numberOfGenericEntries + genericArgumentsCounter + (currentInstanceIsGeneric ? 1 : 0);
// reserve enough space
int maxOfEntries = 8 + numberOfEntries * 10;
if (localContentsOffset + maxOfEntries >= this.contents.length) {
resizeContents(maxOfEntries);
}
int localVariableTypeNameIndex =
constantPool.literalIndex(AttributeNamesConstants.LocalVariableTypeTableName);
this.contents[localContentsOffset++] = (byte) (localVariableTypeNameIndex >> 8);
this.contents[localContentsOffset++] = (byte) localVariableTypeNameIndex;
value = numberOfEntries * 10 + 2;
this.contents[localContentsOffset++] = (byte) (value >> 24);
this.contents[localContentsOffset++] = (byte) (value >> 16);
this.contents[localContentsOffset++] = (byte) (value >> 8);
this.contents[localContentsOffset++] = (byte) value;
this.contents[localContentsOffset++] = (byte) (numberOfEntries >> 8);
this.contents[localContentsOffset++] = (byte) numberOfEntries;
if (currentInstanceIsGeneric) {
numberOfEntries++;
this.contents[localContentsOffset++] = 0; // the startPC for this is always 0
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = (byte) (code_length >> 8);
this.contents[localContentsOffset++] = (byte) code_length;
nameIndex = constantPool.literalIndex(QualifiedNamesConstants.This);
this.contents[localContentsOffset++] = (byte) (nameIndex >> 8);
this.contents[localContentsOffset++] = (byte) nameIndex;
descriptorIndex = constantPool.literalIndex(declaringClassBinding.genericTypeSignature());
this.contents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
this.contents[localContentsOffset++] = (byte) descriptorIndex;
this.contents[localContentsOffset++] = 0;// the resolved position for this is always 0
this.contents[localContentsOffset++] = 0;
}
for (int i = 0; i < genericLocalVariablesCounter; i++) {
LocalVariableBinding localVariable = genericLocalVariables[i];
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = (byte) (code_length >> 8);
this.contents[localContentsOffset++] = (byte) code_length;
nameIndex = constantPool.literalIndex(localVariable.name);
this.contents[localContentsOffset++] = (byte) (nameIndex >> 8);
this.contents[localContentsOffset++] = (byte) nameIndex;
descriptorIndex = constantPool.literalIndex(localVariable.type.genericTypeSignature());
this.contents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
this.contents[localContentsOffset++] = (byte) descriptorIndex;
int resolvedPosition = localVariable.resolvedPosition;
this.contents[localContentsOffset++] = (byte) (resolvedPosition >> 8);
this.contents[localContentsOffset++] = (byte) resolvedPosition;
}
for (int i = 0; i < genericArgumentsCounter; i++) {
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = (byte) (code_length >> 8);
this.contents[localContentsOffset++] = (byte) code_length;
nameIndex = genericArgumentsNameIndexes[i];
this.contents[localContentsOffset++] = (byte) (nameIndex >> 8);
this.contents[localContentsOffset++] = (byte) nameIndex;
descriptorIndex = constantPool.literalIndex(genericArgumentsTypeBindings[i].genericTypeSignature());
this.contents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
this.contents[localContentsOffset++] = (byte) descriptorIndex;
int resolvedPosition = genericArgumentsResolvedPositions[i];
this.contents[localContentsOffset++] = (byte) (resolvedPosition >> 8);
this.contents[localContentsOffset++] = (byte) resolvedPosition;
}
attributeNumber++;
}
}
// update the number of attributes// ensure first that there is enough space available inside the localContents array
if (codeAttributeAttributeOffset + 2 >= this.contents.length) {
resizeContents(2);
}
this.contents[codeAttributeAttributeOffset++] = (byte) (attributeNumber >> 8);
this.contents[codeAttributeAttributeOffset] = (byte) attributeNumber;
// update the attribute length
int codeAttributeLength = localContentsOffset - (codeAttributeOffset + 6);
this.contents[codeAttributeOffset + 2] = (byte) (codeAttributeLength >> 24);
this.contents[codeAttributeOffset + 3] = (byte) (codeAttributeLength >> 16);
this.contents[codeAttributeOffset + 4] = (byte) (codeAttributeLength >> 8);
this.contents[codeAttributeOffset + 5] = (byte) codeAttributeLength;
contentsOffset = localContentsOffset;
}
/**
* INTERNAL USE-ONLY
* That method completes the creation of the code attribute by setting
* - the attribute_length
* - max_stack
* - max_locals
* - code_length
* - exception table
* - and debug attributes if necessary.
*
* @param binding org.eclipse.jdt.internal.compiler.lookup.SyntheticAccessMethodBinding
* @param codeAttributeOffset <CODE>int</CODE>
*/
public void completeCodeAttributeForSyntheticAccessMethod(
SyntheticAccessMethodBinding binding,
int codeAttributeOffset,
int[] startLineIndexes) {
// reinitialize the contents with the byte modified by the code stream
this.contents = codeStream.bCodeStream;
int localContentsOffset = codeStream.classFileOffset;
// codeAttributeOffset is the position inside contents byte array before we started to write
// any information about the codeAttribute
// That means that to write the attribute_length you need to offset by 2 the value of codeAttributeOffset
// to get the right position, 6 for the max_stack etc...
int max_stack = codeStream.stackMax;
contents[codeAttributeOffset + 6] = (byte) (max_stack >> 8);
contents[codeAttributeOffset + 7] = (byte) max_stack;
int max_locals = codeStream.maxLocals;
contents[codeAttributeOffset + 8] = (byte) (max_locals >> 8);
contents[codeAttributeOffset + 9] = (byte) max_locals;
int code_length = codeStream.position;
contents[codeAttributeOffset + 10] = (byte) (code_length >> 24);
contents[codeAttributeOffset + 11] = (byte) (code_length >> 16);
contents[codeAttributeOffset + 12] = (byte) (code_length >> 8);
contents[codeAttributeOffset + 13] = (byte) code_length;
if ((localContentsOffset + 40) >= this.contents.length) {
resizeContents(40);
}
// there is no exception table, so we need to offset by 2 the current offset and move
// on the attribute generation
contents[localContentsOffset++] = 0;
contents[localContentsOffset++] = 0;
// debug attributes
int codeAttributeAttributeOffset = localContentsOffset;
int attributeNumber = 0;
// leave two bytes for the attribute_length
localContentsOffset += 2;
// first we handle the linenumber attribute
if (codeStream.generateLineNumberAttributes) {
int index = 0;
int lineNumberNameIndex =
constantPool.literalIndex(AttributeNamesConstants.LineNumberTableName);
contents[localContentsOffset++] = (byte) (lineNumberNameIndex >> 8);
contents[localContentsOffset++] = (byte) lineNumberNameIndex;
int lineNumberTableOffset = localContentsOffset;
localContentsOffset += 6;
// leave space for attribute_length and line_number_table_length
// Seems like do would be better, but this preserves the existing behavior.
index = searchLineNumber(startLineIndexes, binding.sourceStart);
contents[localContentsOffset++] = 0;
contents[localContentsOffset++] = 0;
contents[localContentsOffset++] = (byte) (index >> 8);
contents[localContentsOffset++] = (byte) index;
// now we change the size of the line number attribute
contents[lineNumberTableOffset++] = 0;
contents[lineNumberTableOffset++] = 0;
contents[lineNumberTableOffset++] = 0;
contents[lineNumberTableOffset++] = 6;
contents[lineNumberTableOffset++] = 0;
contents[lineNumberTableOffset++] = 1;
attributeNumber++;
}
// then we do the local variable attribute
if (codeStream.generateLocalVariableTableAttributes) {
int localVariableTableOffset = localContentsOffset;
int numberOfEntries = 0;
int localVariableNameIndex =
constantPool.literalIndex(AttributeNamesConstants.LocalVariableTableName);
if (localContentsOffset + 8 > this.contents.length) {
resizeContents(8);
}
contents[localContentsOffset++] = (byte) (localVariableNameIndex >> 8);
contents[localContentsOffset++] = (byte) localVariableNameIndex;
localContentsOffset += 6;
// leave space for attribute_length and local_variable_table_length
int nameIndex;
int descriptorIndex;
// used to remember the local variable with a generic type
int genericLocalVariablesCounter = 0;
LocalVariableBinding[] genericLocalVariables = null;
int numberOfGenericEntries = 0;
for (int i = 0, max = codeStream.allLocalsCounter; i < max; i++) {
LocalVariableBinding localVariable = codeStream.locals[i];
final TypeBinding localVariableTypeBinding = localVariable.type;
boolean isParameterizedType = localVariableTypeBinding.isParameterizedType() || localVariableTypeBinding.isTypeVariable();
if (localVariable.initializationCount != 0 && isParameterizedType) {
if (genericLocalVariables == null) {
// we cannot have more than max locals
genericLocalVariables = new LocalVariableBinding[max];
}
genericLocalVariables[genericLocalVariablesCounter++] = localVariable;
}
for (int j = 0; j < localVariable.initializationCount; j++) {
int startPC = localVariable.initializationPCs[j << 1];
int endPC = localVariable.initializationPCs[(j << 1) + 1];
if (startPC != endPC) { // only entries for non zero length
if (endPC == -1) {
localVariable.declaringScope.problemReporter().abortDueToInternalError(
Util.bind("abort.invalidAttribute" , new String(localVariable.name)), //$NON-NLS-1$
(ASTNode) localVariable.declaringScope.methodScope().referenceContext);
}
if (localContentsOffset + 10 > this.contents.length) {
resizeContents(10);
}
// now we can safely add the local entry
numberOfEntries++;
if (isParameterizedType) {
numberOfGenericEntries++;
}
contents[localContentsOffset++] = (byte) (startPC >> 8);
contents[localContentsOffset++] = (byte) startPC;
int length = endPC - startPC;
contents[localContentsOffset++] = (byte) (length >> 8);
contents[localContentsOffset++] = (byte) length;
nameIndex = constantPool.literalIndex(localVariable.name);
contents[localContentsOffset++] = (byte) (nameIndex >> 8);
contents[localContentsOffset++] = (byte) nameIndex;
descriptorIndex = constantPool.literalIndex(localVariableTypeBinding.signature());
contents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
contents[localContentsOffset++] = (byte) descriptorIndex;
int resolvedPosition = localVariable.resolvedPosition;
contents[localContentsOffset++] = (byte) (resolvedPosition >> 8);
contents[localContentsOffset++] = (byte) resolvedPosition;
}
}
}
int value = numberOfEntries * 10 + 2;
localVariableTableOffset += 2;
contents[localVariableTableOffset++] = (byte) (value >> 24);
contents[localVariableTableOffset++] = (byte) (value >> 16);
contents[localVariableTableOffset++] = (byte) (value >> 8);
contents[localVariableTableOffset++] = (byte) value;
contents[localVariableTableOffset++] = (byte) (numberOfEntries >> 8);
contents[localVariableTableOffset] = (byte) numberOfEntries;
attributeNumber++;
if (genericLocalVariablesCounter != 0) {
// add the local variable type table attribute
int maxOfEntries = 8 + numberOfGenericEntries * 10;
// reserve enough space
if (localContentsOffset + maxOfEntries >= this.contents.length) {
resizeContents(maxOfEntries);
}
int localVariableTypeNameIndex =
constantPool.literalIndex(AttributeNamesConstants.LocalVariableTypeTableName);
contents[localContentsOffset++] = (byte) (localVariableTypeNameIndex >> 8);
contents[localContentsOffset++] = (byte) localVariableTypeNameIndex;
value = numberOfGenericEntries * 10 + 2;
contents[localContentsOffset++] = (byte) (value >> 24);
contents[localContentsOffset++] = (byte) (value >> 16);
contents[localContentsOffset++] = (byte) (value >> 8);
contents[localContentsOffset++] = (byte) value;
contents[localContentsOffset++] = (byte) (numberOfGenericEntries >> 8);
contents[localContentsOffset++] = (byte) numberOfGenericEntries;
for (int i = 0; i < genericLocalVariablesCounter; i++) {
LocalVariableBinding localVariable = genericLocalVariables[i];
for (int j = 0; j < localVariable.initializationCount; j++) {
int startPC = localVariable.initializationPCs[j << 1];
int endPC = localVariable.initializationPCs[(j << 1) + 1];
if (startPC != endPC) { // only entries for non zero length
// now we can safely add the local entry
contents[localContentsOffset++] = (byte) (startPC >> 8);
contents[localContentsOffset++] = (byte) startPC;
int length = endPC - startPC;
contents[localContentsOffset++] = (byte) (length >> 8);
contents[localContentsOffset++] = (byte) length;
nameIndex = constantPool.literalIndex(localVariable.name);
contents[localContentsOffset++] = (byte) (nameIndex >> 8);
contents[localContentsOffset++] = (byte) nameIndex;
descriptorIndex = constantPool.literalIndex(localVariable.type.genericTypeSignature());
contents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
contents[localContentsOffset++] = (byte) descriptorIndex;
int resolvedPosition = localVariable.resolvedPosition;
contents[localContentsOffset++] = (byte) (resolvedPosition >> 8);
contents[localContentsOffset++] = (byte) resolvedPosition;
}
}
}
attributeNumber++;
}
}
// update the number of attributes
// ensure first that there is enough space available inside the contents array
if (codeAttributeAttributeOffset + 2 >= this.contents.length) {
resizeContents(2);
}
contents[codeAttributeAttributeOffset++] = (byte) (attributeNumber >> 8);
contents[codeAttributeAttributeOffset] = (byte) attributeNumber;
// update the attribute length
int codeAttributeLength = localContentsOffset - (codeAttributeOffset + 6);
contents[codeAttributeOffset + 2] = (byte) (codeAttributeLength >> 24);
contents[codeAttributeOffset + 3] = (byte) (codeAttributeLength >> 16);
contents[codeAttributeOffset + 4] = (byte) (codeAttributeLength >> 8);
contents[codeAttributeOffset + 5] = (byte) codeAttributeLength;
contentsOffset = localContentsOffset;
}
/**
* INTERNAL USE-ONLY
* Complete the creation of a method info by setting up the number of attributes at the right offset.
*
* @param methodAttributeOffset <CODE>int</CODE>
* @param attributeNumber <CODE>int</CODE>
*/
public void completeMethodInfo(
int methodAttributeOffset,
int attributeNumber) {
// update the number of attributes
contents[methodAttributeOffset++] = (byte) (attributeNumber >> 8);
contents[methodAttributeOffset] = (byte) attributeNumber;
}
/**
* INTERNAL USE-ONLY
* Request the creation of a ClassFile compatible representation of a problematic type
*
* @param typeDeclaration org.eclipse.jdt.internal.compiler.ast.TypeDeclaration
* @param unitResult org.eclipse.jdt.internal.compiler.CompilationUnitResult
*/
public static void createProblemType(
TypeDeclaration typeDeclaration,
CompilationResult unitResult) {
SourceTypeBinding typeBinding = typeDeclaration.binding;
ClassFile classFile = new ClassFile(typeBinding, null, true);
// TODO (olivier) handle cases where a field cannot be generated (name too long)
// TODO (olivier) handle too many methods
// inner attributes
if (typeBinding.isMemberType())
classFile.recordEnclosingTypeAttributes(typeBinding);
// add its fields
FieldBinding[] fields = typeBinding.fields;
if ((fields != null) && (fields != NoFields)) {
for (int i = 0, max = fields.length; i < max; i++) {
if (fields[i].constant() == null) {
FieldReference.getConstantFor(fields[i], null, false, null);
}
}
classFile.addFieldInfos();
} else {
// we have to set the number of fields to be equals to 0
classFile.contents[classFile.contentsOffset++] = 0;
classFile.contents[classFile.contentsOffset++] = 0;
}
// leave some space for the methodCount
classFile.setForMethodInfos();
// add its user defined methods
MethodBinding[] methods = typeBinding.methods;
AbstractMethodDeclaration[] methodDeclarations = typeDeclaration.methods;
int maxMethodDecl = methodDeclarations == null ? 0 : methodDeclarations.length;
int problemsLength;
IProblem[] problems = unitResult.getErrors();
if (problems == null) {
problems = new IProblem[0];
}
IProblem[] problemsCopy = new IProblem[problemsLength = problems.length];
System.arraycopy(problems, 0, problemsCopy, 0, problemsLength);
if (methods != null) {
if (typeBinding.isInterface()) {
// we cannot create problem methods for an interface. So we have to generate a clinit
// which should contain all the problem
classFile.addProblemClinit(problemsCopy);
for (int i = 0, max = methods.length; i < max; i++) {
MethodBinding methodBinding;
if ((methodBinding = methods[i]) != null) {
// find the corresponding method declaration
for (int j = 0; j < maxMethodDecl; j++) {
if ((methodDeclarations[j] != null)
&& (methodDeclarations[j].binding == methods[i])) {
if (!methodBinding.isConstructor()) {
classFile.addAbstractMethod(methodDeclarations[j], methodBinding);
}
break;
}
}
}
}
} else {
for (int i = 0, max = methods.length; i < max; i++) {
MethodBinding methodBinding;
if ((methodBinding = methods[i]) != null) {
// find the corresponding method declaration
for (int j = 0; j < maxMethodDecl; j++) {
if ((methodDeclarations[j] != null)
&& (methodDeclarations[j].binding == methods[i])) {
AbstractMethodDeclaration methodDecl;
if ((methodDecl = methodDeclarations[j]).isConstructor()) {
classFile.addProblemConstructor(methodDecl, methodBinding, problemsCopy);
} else {
classFile.addProblemMethod(methodDecl, methodBinding, problemsCopy);
}
break;
}
}
}
}
}
// add abstract methods
classFile.addDefaultAbstractMethods();
}
// propagate generation of (problem) member types
if (typeDeclaration.memberTypes != null) {
for (int i = 0, max = typeDeclaration.memberTypes.length; i < max; i++) {
TypeDeclaration memberType = typeDeclaration.memberTypes[i];
if (memberType.binding != null) {
classFile.recordNestedMemberAttribute(memberType.binding);
ClassFile.createProblemType(memberType, unitResult);
}
}
}
classFile.addAttributes();
unitResult.record(typeBinding.constantPoolName(), classFile);
}
/**
* INTERNAL USE-ONLY
* This methods returns a char[] representing the file name of the receiver
*
* @return char[]
*/
public char[] fileName() {
return constantPool.UTF8Cache.returnKeyFor(1);
}
/**
* INTERNAL USE-ONLY
* That method generates the header of a code attribute.
* - the index inside the constant pool for the attribute name ("Code")
* - leave some space for attribute_length(4), max_stack(2), max_locals(2), code_length(4).
*/
public void generateCodeAttributeHeader() {
if (contentsOffset + 20 >= this.contents.length) {
resizeContents(20);
}
int constantValueNameIndex =
constantPool.literalIndex(AttributeNamesConstants.CodeName);
contents[contentsOffset++] = (byte) (constantValueNameIndex >> 8);
contents[contentsOffset++] = (byte) constantValueNameIndex;
// leave space for attribute_length(4), max_stack(2), max_locals(2), code_length(4)
contentsOffset += 12;
}
/**
* INTERNAL USE-ONLY
* That method generates the attributes of a code attribute.
* They could be:
* - an exception attribute for each try/catch found inside the method
* - a deprecated attribute
* - a synthetic attribute for synthetic access methods
*
* It returns the number of attributes created for the code attribute.
*
* @param methodBinding org.eclipse.jdt.internal.compiler.lookup.MethodBinding
* @return <CODE>int</CODE>
*/
public int generateMethodInfoAttribute(MethodBinding methodBinding) {
// leave two bytes for the attribute_number
contentsOffset += 2;
// now we can handle all the attribute for that method info:
// it could be:
// - a CodeAttribute
// - a ExceptionAttribute
// - a DeprecatedAttribute
// - a SyntheticAttribute
// Exception attribute
ReferenceBinding[] thrownsExceptions;
int attributeNumber = 0;
if ((thrownsExceptions = methodBinding.thrownExceptions) != NoExceptions) {
// The method has a throw clause. So we need to add an exception attribute
// check that there is enough space to write all the bytes for the exception attribute
int length = thrownsExceptions.length;
int exSize = 8 + length * 2;
if (exSize + contentsOffset >= this.contents.length) {
resizeContents(exSize);
}
int exceptionNameIndex =
constantPool.literalIndex(AttributeNamesConstants.ExceptionsName);
contents[contentsOffset++] = (byte) (exceptionNameIndex >> 8);
contents[contentsOffset++] = (byte) exceptionNameIndex;
// The attribute length = length * 2 + 2 in case of a exception attribute
int attributeLength = length * 2 + 2;
contents[contentsOffset++] = (byte) (attributeLength >> 24);
contents[contentsOffset++] = (byte) (attributeLength >> 16);
contents[contentsOffset++] = (byte) (attributeLength >> 8);
contents[contentsOffset++] = (byte) attributeLength;
contents[contentsOffset++] = (byte) (length >> 8);
contents[contentsOffset++] = (byte) length;
for (int i = 0; i < length; i++) {
int exceptionIndex = constantPool.literalIndex(thrownsExceptions[i]);
contents[contentsOffset++] = (byte) (exceptionIndex >> 8);
contents[contentsOffset++] = (byte) exceptionIndex;
}
attributeNumber++;
}
if (methodBinding.isDeprecated()) {
// Deprecated attribute
// Check that there is enough space to write the deprecated attribute
if (contentsOffset + 6 >= this.contents.length) {
resizeContents(6);
}
int deprecatedAttributeNameIndex =
constantPool.literalIndex(AttributeNamesConstants.DeprecatedName);
contents[contentsOffset++] = (byte) (deprecatedAttributeNameIndex >> 8);
contents[contentsOffset++] = (byte) deprecatedAttributeNameIndex;
// the length of a deprecated attribute is equals to 0
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
attributeNumber++;
}
if (this.targetJDK < ClassFileConstants.JDK1_5 && methodBinding.isSynthetic()) {
// Synthetic attribute
// Check that there is enough space to write the deprecated attribute
if (contentsOffset + 6 >= this.contents.length) {
resizeContents(6);
}
int syntheticAttributeNameIndex =
constantPool.literalIndex(AttributeNamesConstants.SyntheticName);
contents[contentsOffset++] = (byte) (syntheticAttributeNameIndex >> 8);
contents[contentsOffset++] = (byte) syntheticAttributeNameIndex;
// the length of a synthetic attribute is equals to 0
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
attributeNumber++;
}
// add signature attribute
char[] genericSignature = methodBinding.genericSignature();
if (genericSignature != null) {
// check that there is enough space to write all the bytes for the field info corresponding
// to the @fieldBinding
if (contentsOffset + 8 >= this.contents.length) {
resizeContents(8);
}
int signatureAttributeNameIndex =
constantPool.literalIndex(AttributeNamesConstants.SignatureName);
contents[contentsOffset++] = (byte) (signatureAttributeNameIndex >> 8);
contents[contentsOffset++] = (byte) signatureAttributeNameIndex;
// the length of a signature attribute is equals to 2
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 2;
int signatureIndex =
constantPool.literalIndex(genericSignature);
contents[contentsOffset++] = (byte) (signatureIndex >> 8);
contents[contentsOffset++] = (byte) signatureIndex;
attributeNumber++;
}
return attributeNumber;
}
/**
* INTERNAL USE-ONLY
* That method generates the header of a method info:
* The header consists in:
* - the access flags
* - the name index of the method name inside the constant pool
* - the descriptor index of the signature of the method inside the constant pool.
*
* @param methodBinding org.eclipse.jdt.internal.compiler.lookup.MethodBinding
*/
public void generateMethodInfoHeader(MethodBinding methodBinding) {
generateMethodInfoHeader(methodBinding, methodBinding.modifiers);
}
/**
* INTERNAL USE-ONLY
* That method generates the header of a method info:
* The header consists in:
* - the access flags
* - the name index of the method name inside the constant pool
* - the descriptor index of the signature of the method inside the constant pool.
*
* @param methodBinding org.eclipse.jdt.internal.compiler.lookup.MethodBinding
* @param accessFlags the access flags
*/
public void generateMethodInfoHeader(MethodBinding methodBinding, int accessFlags) {
// check that there is enough space to write all the bytes for the method info corresponding
// to the @methodBinding
methodCount++; // add one more method
if (contentsOffset + 10 >= this.contents.length) {
resizeContents(10);
}
if (targetJDK < ClassFileConstants.JDK1_5) {
// pre 1.5, synthetic was an attribute, not a modifier
accessFlags &= ~AccSynthetic;
}
if (methodBinding.isRequiredToClearPrivateModifier()) {
accessFlags &= ~AccPrivate;
}
contents[contentsOffset++] = (byte) (accessFlags >> 8);
contents[contentsOffset++] = (byte) accessFlags;
int nameIndex = constantPool.literalIndex(methodBinding.selector);
contents[contentsOffset++] = (byte) (nameIndex >> 8);
contents[contentsOffset++] = (byte) nameIndex;
int descriptorIndex = constantPool.literalIndex(methodBinding.signature());
contents[contentsOffset++] = (byte) (descriptorIndex >> 8);
contents[contentsOffset++] = (byte) descriptorIndex;
}
/**
* INTERNAL USE-ONLY
* That method generates the method info header of a clinit:
* The header consists in:
* - the access flags (always default access + static)
* - the name index of the method name (always <clinit>) inside the constant pool
* - the descriptor index of the signature (always ()V) of the method inside the constant pool.
*/
public void generateMethodInfoHeaderForClinit() {
// check that there is enough space to write all the bytes for the method info corresponding
// to the @methodBinding
methodCount++; // add one more method
if (contentsOffset + 10 >= this.contents.length) {
resizeContents(10);
}
contents[contentsOffset++] = (byte) ((AccDefault | AccStatic) >> 8);
contents[contentsOffset++] = (byte) (AccDefault | AccStatic);
int nameIndex = constantPool.literalIndex(QualifiedNamesConstants.Clinit);
contents[contentsOffset++] = (byte) (nameIndex >> 8);
contents[contentsOffset++] = (byte) nameIndex;
int descriptorIndex =
constantPool.literalIndex(QualifiedNamesConstants.ClinitSignature);
contents[contentsOffset++] = (byte) (descriptorIndex >> 8);
contents[contentsOffset++] = (byte) descriptorIndex;
// We know that we won't get more than 1 attribute: the code attribute
contents[contentsOffset++] = 0;
contents[contentsOffset++] = 1;
}
/**
* EXTERNAL API
* Answer the actual bytes of the class file
*
* This method encodes the receiver structure into a byte array which is the content of the classfile.
* Returns the byte array that represents the encoded structure of the receiver.
*
* @return byte[]
*/
public byte[] getBytes() {
byte[] fullContents = new byte[headerOffset + contentsOffset];
System.arraycopy(header, 0, fullContents, 0, headerOffset);
System.arraycopy(contents, 0, fullContents, headerOffset, contentsOffset);
return fullContents;
}
/**
* EXTERNAL API
* Answer the compound name of the class file.
* @return char[][]
* e.g. {{java}, {util}, {Hashtable}}.
*/
public char[][] getCompoundName() {
return CharOperation.splitOn('/', fileName());
}
protected void initByteArrays() {
LookupEnvironment env = this.referenceBinding.scope.environment();
synchronized (env) {
if (env.sharedArraysUsed) {
this.ownSharedArrays = false;
int members = referenceBinding.methods().length + referenceBinding.fields().length;
this.header = new byte[INITIAL_HEADER_SIZE];
this.contents = new byte[members < 15 ? INITIAL_CONTENTS_SIZE : INITIAL_HEADER_SIZE];
} else {
this.ownSharedArrays = env.sharedArraysUsed = true;
this.header = env.sharedClassFileHeader;
this.contents = env.sharedClassFileContents;
}
}
}
/**
* INTERNAL USE-ONLY
* Returns the most enclosing classfile of the receiver. This is used know to store the constant pool name
* for all inner types of the receiver.
* @return org.eclipse.jdt.internal.compiler.codegen.ClassFile
*/
public ClassFile outerMostEnclosingClassFile() {
ClassFile current = this;
while (current.enclosingClassFile != null)
current = current.enclosingClassFile;
return current;
}
/**
* INTERNAL USE-ONLY
* This is used to store a new inner class. It checks that the binding @binding doesn't already exist inside the
* collection of inner classes. Add all the necessary classes in the right order to fit to the specifications.
*
* @param binding org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding
*/
public void recordEnclosingTypeAttributes(ReferenceBinding binding) {
// add all the enclosing types
ReferenceBinding enclosingType = referenceBinding.enclosingType();
int depth = 0;
while (enclosingType != null) {
depth++;
enclosingType = enclosingType.enclosingType();
}
enclosingType = referenceBinding;
ReferenceBinding enclosingTypes[];
if (depth >= 2) {
enclosingTypes = new ReferenceBinding[depth];
for (int i = depth - 1; i >= 0; i--) {
enclosingTypes[i] = enclosingType;
enclosingType = enclosingType.enclosingType();
}
for (int i = 0; i < depth; i++) {
addInnerClasses(enclosingTypes[i]);
}
} else {
addInnerClasses(referenceBinding);
}
}
/**
* INTERNAL USE-ONLY
* This is used to store a new inner class. It checks that the binding @binding doesn't already exist inside the
* collection of inner classes. Add all the necessary classes in the right order to fit to the specifications.
*
* @param binding org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding
*/
public void recordNestedLocalAttribute(ReferenceBinding binding) {
// add all the enclosing types
ReferenceBinding enclosingType = referenceBinding.enclosingType();
int depth = 0;
while (enclosingType != null) {
depth++;
enclosingType = enclosingType.enclosingType();
}
enclosingType = referenceBinding;
ReferenceBinding enclosingTypes[];
if (depth >= 2) {
enclosingTypes = new ReferenceBinding[depth];
for (int i = depth - 1; i >= 0; i--) {
enclosingTypes[i] = enclosingType;
enclosingType = enclosingType.enclosingType();
}
for (int i = 0; i < depth; i++)
addInnerClasses(enclosingTypes[i]);
} else {
addInnerClasses(binding);
}
}
/**
* INTERNAL USE-ONLY
* This is used to store a new inner class. It checks that the binding @binding doesn't already exist inside the
* collection of inner classes. Add all the necessary classes in the right order to fit to the specifications.
*
* @param binding org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding
*/
public void recordNestedMemberAttribute(ReferenceBinding binding) {
addInnerClasses(binding);
}
/**
* Resize the pool contents
*/
private final void resizeContents(int minimalSize) {
int length = this.contents.length;
int toAdd = length;
if (toAdd < minimalSize)
toAdd = minimalSize;
System.arraycopy(this.contents, 0, this.contents = new byte[length + toAdd], 0, length);
}
/**
* INTERNAL USE-ONLY
* Search the line number corresponding to a specific position
*/
public static final int searchLineNumber(
int[] startLineIndexes,
int position) {
// this code is completely useless, but it is the same implementation than
// org.eclipse.jdt.internal.compiler.problem.ProblemHandler.searchLineNumber(int[], int)
// if (startLineIndexes == null)
// return 1;
int length = startLineIndexes.length;
if (length == 0)
return 1;
int g = 0, d = length - 1;
int m = 0;
while (g <= d) {
m = (g + d) / 2;
if (position < startLineIndexes[m]) {
d = m - 1;
} else
if (position > startLineIndexes[m]) {
g = m + 1;
} else {
return m + 1;
}
}
if (position < startLineIndexes[m]) {
return m + 1;
}
return m + 2;
}
/**
* INTERNAL USE-ONLY
* This methods leaves the space for method counts recording.
*/
public void setForMethodInfos() {
// leave some space for the methodCount
methodCountOffset = contentsOffset;
contentsOffset += 2;
}
/**
* INTERNAL USE-ONLY
* outputPath is formed like:
* c:\temp\ the last character is a file separator
* relativeFileName is formed like:
* java\lang\String.class
* @param generatePackagesStructure a flag to know if the packages structure has to be generated.
* @param outputPath the output directory
* @param relativeFileName java.lang.String
* @param contents byte[]
*
*/
public static void writeToDisk(
boolean generatePackagesStructure,
String outputPath,
String relativeFileName,
byte[] contents)
throws IOException {
BufferedOutputStream output = null;
if (generatePackagesStructure) {
output = new BufferedOutputStream(
new FileOutputStream(
new File(buildAllDirectoriesInto(outputPath, relativeFileName))));
} else {
String fileName = null;
char fileSeparatorChar = File.separatorChar;
String fileSeparator = File.separator;
// First we ensure that the outputPath exists
outputPath = outputPath.replace('/', fileSeparatorChar);
// To be able to pass the mkdirs() method we need to remove the extra file separator at the end of the outDir name
int indexOfPackageSeparator = relativeFileName.lastIndexOf(fileSeparatorChar);
if (indexOfPackageSeparator == -1) {
if (outputPath.endsWith(fileSeparator)) {
fileName = outputPath + relativeFileName;
} else {
fileName = outputPath + fileSeparator + relativeFileName;
}
} else {
int length = relativeFileName.length();
if (outputPath.endsWith(fileSeparator)) {
fileName = outputPath + relativeFileName.substring(indexOfPackageSeparator + 1, length);
} else {
fileName = outputPath + fileSeparator + relativeFileName.substring(indexOfPackageSeparator + 1, length);
}
}
output = new BufferedOutputStream(
new FileOutputStream(
new File(fileName)));
}
try {
output.write(contents);
} finally {
output.flush();
output.close();
}
}
}
| Niky4000/UsefulUtils | projects/others/eclipse-platform-parent/eclipse.jdt.core-master/org.eclipse.jdt.core.tests.model/workspace/Compiler/src/org/eclipse/jdt/internal/compiler/ClassFile.java | Java | gpl-3.0 | 130,298 |
/*
* Copyright (c) 2012, Mathieu Malaterre
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE 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 COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <assert.h>
#include <string.h>
#include <stdio.h>
#include "opj_config.h"
#include "openjpeg.h"
#define J2K_CFMT 0
void error_callback(const char *msg, void *v);
void warning_callback(const char *msg, void *v);
void info_callback(const char *msg, void *v);
void error_callback(const char *msg, void *v) {
(void)msg;
(void)v;
puts(msg);
}
void warning_callback(const char *msg, void *v) {
(void)msg;
(void)v;
puts(msg);
}
void info_callback(const char *msg, void *v) {
(void)msg;
(void)v;
puts(msg);
}
int main(int argc, char *argv[])
{
const char * v = opj_version();
const OPJ_COLOR_SPACE color_space = OPJ_CLRSPC_GRAY;
unsigned int numcomps = 1;
unsigned int i;
unsigned int image_width = 256;
unsigned int image_height = 256;
opj_cparameters_t parameters;
unsigned int subsampling_dx = 0;
unsigned int subsampling_dy = 0;
opj_image_cmptparm_t cmptparm;
opj_image_t *image;
opj_codec_t* l_codec = 00;
OPJ_BOOL bSuccess;
opj_stream_t *l_stream = 00;
(void)argc;
(void)argv;
opj_set_default_encoder_parameters(¶meters);
parameters.cod_format = J2K_CFMT;
puts(v);
cmptparm.prec = 8;
cmptparm.bpp = 8;
cmptparm.sgnd = 0;
cmptparm.dx = subsampling_dx;
cmptparm.dy = subsampling_dy;
cmptparm.w = image_width;
cmptparm.h = image_height;
image = opj_image_create(numcomps, &cmptparm, color_space);
assert( image );
for (i = 0; i < image_width * image_height; i++)
{
unsigned int compno;
for(compno = 0; compno < numcomps; compno++)
{
image->comps[compno].data[i] = 0;
}
}
/* catch events using our callbacks and give a local context */
opj_set_info_handler(l_codec, info_callback,00);
opj_set_warning_handler(l_codec, warning_callback,00);
opj_set_error_handler(l_codec, error_callback,00);
l_codec = opj_create_compress(OPJ_CODEC_J2K);
opj_set_info_handler(l_codec, info_callback,00);
opj_set_warning_handler(l_codec, warning_callback,00);
opj_set_error_handler(l_codec, error_callback,00);
opj_setup_encoder(l_codec, ¶meters, image);
l_stream = opj_stream_create_default_file_stream("testempty1.j2k",OPJ_FALSE);
assert(l_stream);
bSuccess = opj_start_compress(l_codec,image,l_stream);
if( !bSuccess )
{
opj_stream_destroy(l_stream);
opj_destroy_codec(l_codec);
opj_image_destroy(image);
return 0;
}
assert( bSuccess );
bSuccess = opj_encode(l_codec, l_stream);
assert( bSuccess );
bSuccess = opj_end_compress(l_codec, l_stream);
assert( bSuccess );
opj_stream_destroy(l_stream);
opj_destroy_codec(l_codec);
opj_image_destroy(image);
puts( "end" );
return 0;
}
| AlienCowEatCake/ImageViewer | src/ThirdParty/OpenJPEG/openjpeg-2.4.0/tests/unit/testempty1.c | C | gpl-3.0 | 4,031 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.6.0_35) on Sat Oct 06 21:59:20 CEST 2012 -->
<TITLE>
SmartPrinter (Mockito 1.9.5 API)
</TITLE>
<META NAME="date" CONTENT="2012-10-06">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style">
<SCRIPT type="text/javascript">
function windowTitle()
{
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="SmartPrinter (Mockito 1.9.5 API)";
}
}
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>
</HEAD>
<BODY BGCOLOR="white" onload="windowTitle();">
<HR>
<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/SmartPrinter.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<!-- Note there is a weird javadoc task bug if using the double quote char \" that causes an 'illegal package name' error -->
<!-- using the beautify plugin for jQuery from https://bitbucket.org/larscorneliussen/beautyofcode/ -->
<script type="text/javascript">
var shBaseURL = '../../../../js/sh-2.1.382/';
</script>
<script type="text/javascript" src="../../../../js/jquery-1.7.min.js"></script>
<script type="text/javascript" src="../../../../js/jquery.beautyOfCode-min.js"></script>
<script type="text/javascript">
/* Apply beautification of code */
var usingOldIE = false;
if($.browser.msie && parseInt($.browser.version) < 9) usingOldIE = true;
if(!usingOldIE) {
$.beautyOfCode.init({
theme : 'Eclipse',
brushes: ['Java']
});
/* Add name & version to header */
$(function() {
$('td.NavBarCell1[colspan=2]').each(function(index, element) {
var jqueryTD = $(element);
jqueryTD.after(
$('<td><em><strong>Mockito 1.9.5 API</strong></em></td>').attr('class','NavBarCell1').attr('id','mockito-version-header')
);
jqueryTD.removeAttr('colspan');
})
})
}
</script>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../org/mockito/internal/reporting/PrintSettings.html" title="class in org.mockito.internal.reporting"><B>PREV CLASS</B></A>
NEXT CLASS</FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../index.html?org/mockito/internal/reporting/SmartPrinter.html" target="_top"><B>FRAMES</B></A>
<A HREF="SmartPrinter.html" target="_top"><B>NO FRAMES</B></A>
<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY: NESTED | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->
<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
org.mockito.internal.reporting</FONT>
<BR>
Class SmartPrinter</H2>
<PRE>
java.lang.Object
<IMG SRC="../../../../resources/inherit.gif" ALT="extended by "><B>org.mockito.internal.reporting.SmartPrinter</B>
</PRE>
<HR>
<DL>
<DT><PRE>public class <B>SmartPrinter</B><DT>extends java.lang.Object</DL>
</PRE>
<P>
Makes sure both wanted and actual are printed consistently (single line or multiline)
<p>
Makes arguments printed with types if necessary
<P>
<P>
<HR>
<P>
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<A NAME="constructor_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Constructor Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../../../org/mockito/internal/reporting/SmartPrinter.html#SmartPrinter(org.mockito.internal.invocation.InvocationMatcher, org.mockito.invocation.Invocation, java.lang.Integer...)">SmartPrinter</A></B>(<A HREF="../../../../org/mockito/internal/invocation/InvocationMatcher.html" title="class in org.mockito.internal.invocation">InvocationMatcher</A> wanted,
<A HREF="../../../../org/mockito/invocation/Invocation.html" title="interface in org.mockito.invocation">Invocation</A> actual,
java.lang.Integer... indexesOfMatchersToBeDescribedWithExtraTypeInfo)</CODE>
<BR>
</TD>
</TR>
</TABLE>
<!-- ========== METHOD SUMMARY =========== -->
<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Method Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/mockito/internal/reporting/SmartPrinter.html#getActual()">getActual</A></B>()</CODE>
<BR>
</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/mockito/internal/reporting/SmartPrinter.html#getWanted()">getWanted</A></B>()</CODE>
<BR>
</TD>
</TR>
</TABLE>
<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TH ALIGN="left"><B>Methods inherited from class java.lang.Object</B></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</CODE></TD>
</TR>
</TABLE>
<P>
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<A NAME="constructor_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Constructor Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="SmartPrinter(org.mockito.internal.invocation.InvocationMatcher, org.mockito.invocation.Invocation, java.lang.Integer...)"><!-- --></A><H3>
SmartPrinter</H3>
<PRE>
public <B>SmartPrinter</B>(<A HREF="../../../../org/mockito/internal/invocation/InvocationMatcher.html" title="class in org.mockito.internal.invocation">InvocationMatcher</A> wanted,
<A HREF="../../../../org/mockito/invocation/Invocation.html" title="interface in org.mockito.invocation">Invocation</A> actual,
java.lang.Integer... indexesOfMatchersToBeDescribedWithExtraTypeInfo)</PRE>
<DL>
</DL>
<!-- ============ METHOD DETAIL ========== -->
<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Method Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="getWanted()"><!-- --></A><H3>
getWanted</H3>
<PRE>
public java.lang.String <B>getWanted</B>()</PRE>
<DL>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="getActual()"><!-- --></A><H3>
getActual</H3>
<PRE>
public java.lang.String <B>getActual</B>()</PRE>
<DL>
<DD><DL>
</DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A>
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/SmartPrinter.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<!-- Note there is a weird javadoc task bug if using the double quote char \" that causes an 'illegal package name' error -->
<!-- using the beautify plugin for jQuery from https://bitbucket.org/larscorneliussen/beautyofcode/ -->
<script type="text/javascript">
var shBaseURL = '../../../../js/sh-2.1.382/';
</script>
<script type="text/javascript" src="../../../../js/jquery-1.7.min.js"></script>
<script type="text/javascript" src="../../../../js/jquery.beautyOfCode-min.js"></script>
<script type="text/javascript">
/* Apply beautification of code */
var usingOldIE = false;
if($.browser.msie && parseInt($.browser.version) < 9) usingOldIE = true;
if(!usingOldIE) {
$.beautyOfCode.init({
theme : 'Eclipse',
brushes: ['Java']
});
/* Add name & version to header */
$(function() {
$('td.NavBarCell1[colspan=2]').each(function(index, element) {
var jqueryTD = $(element);
jqueryTD.after(
$('<td><em><strong>Mockito 1.9.5 API</strong></em></td>').attr('class','NavBarCell1').attr('id','mockito-version-header')
);
jqueryTD.removeAttr('colspan');
})
})
}
</script>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../org/mockito/internal/reporting/PrintSettings.html" title="class in org.mockito.internal.reporting"><B>PREV CLASS</B></A>
NEXT CLASS</FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../index.html?org/mockito/internal/reporting/SmartPrinter.html" target="_top"><B>FRAMES</B></A>
<A HREF="SmartPrinter.html" target="_top"><B>NO FRAMES</B></A>
<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY: NESTED | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<HR>
</BODY>
</HTML>
| robertsmieja/Gw2InfoViewer | lib/mockito-1.9.5/javadoc/org/mockito/internal/reporting/SmartPrinter.html | HTML | gpl-3.0 | 14,360 |
/*******************************************************************************
* Trace Recorder Library for Tracealyzer v3.0.2
* Percepio AB, www.percepio.com
*
* trcKernelPort.c
*
* The kernel-specific code for integration with FreeRTOS.
*
* Terms of Use
* This software (the "Tracealyzer Recorder Library") is the intellectual
* property of Percepio AB and may not be sold or in other ways commercially
* redistributed without explicit written permission by Percepio AB.
*
* Separate conditions applies for the SEGGER branded source code included.
*
* The recorder library is free for use together with Percepio products.
* You may distribute the recorder library in its original form, but public
* distribution of modified versions require approval by Percepio AB.
*
* Disclaimer
* The trace tool and recorder library is being delivered to you AS IS and
* Percepio AB makes no warranty as to its use or performance. Percepio AB does
* not and cannot warrant the performance or results you may obtain by using the
* software or documentation. Percepio AB make no warranties, express or
* implied, as to noninfringement of third party rights, merchantability, or
* fitness for any particular purpose. In no event will Percepio AB, its
* technology partners, or distributors be liable to you for any consequential,
* incidental or special damages, including any lost profits or lost savings,
* even if a representative of Percepio AB has been advised of the possibility
* of such damages, or for any claim by any third party. Some jurisdictions do
* not allow the exclusion or limitation of incidental, consequential or special
* damages, or the exclusion of implied warranties or limitations on how long an
* implied warranty may last, so the above limitations may not apply to you.
*
* Tabs are used for indent in this file (1 tab = 4 spaces)
*
* Copyright Percepio AB, 2015.
* www.percepio.com
******************************************************************************/
#include "trcKernelPort.h"
#if (USE_TRACEALYZER_RECORDER == 1)
#include <stdint.h>
#include "trcRecorder.h"
#include "trcStreamPort.h"
#include "task.h"
/* TzCtrl task TCB */
static xTaskHandle HandleTzCtrl;
/* Called by TzCtrl task periodically (every 100 ms) */
static void CheckRecorderStatus(void);
/* The TzCtrl task - receives commands from Tracealyzer (start/stop) */
static portTASK_FUNCTION( TzCtrl, pvParameters );
/* Monitored by TzCtrl task, that give warnings as User Events */
extern volatile uint32_t NoRoomForSymbol;
extern volatile uint32_t NoRoomForObjectData;
extern volatile uint32_t LongestSymbolName;
extern volatile uint32_t MaxBytesTruncated;
#define TRC_PORT_MALLOC(size) pvPortMalloc(size)
#if ((TRC_STREAM_PORT_BLOCKING_TRANSFER == 1) && (TRC_MEASURE_BLOCKING_TIME == 1))
/*** Used in blocking transfer mode, if enabled TRC_MEASURE_BLOCKING_TIME **************/
/* The highest number of cycles used by SEGGER_RTT_Write. */
static volatile int32_t blockingCyclesMax;
/* The number of times SEGGER_RTT_Write has blocked due to a full buffer. */
static volatile uint32_t blockingCount;
/* User Event Channel for giving warnings regarding blocking */
static char* trcDiagnosticsChannel;
#endif /*((TRC_STREAM_PORT_BLOCKING_TRANSFER==1) && (TRC_MEASURE_BLOCKING_TIME))*/
TRC_STREAM_PORT_ALLOCATE_FIELDS()
/* User Event Channel for giving warnings regarding NoRoomForSymbol etc. */
char* trcWarningChannel;
/* Keeps track of previous values, to only react on changes. */
static uint32_t NoRoomForSymbol_last = 0;
static uint32_t NoRoomForObjectData_last = 0;
static uint32_t LongestSymbolName_last = 0;
static uint32_t MaxBytesTruncated_last = 0;
/*******************************************************************************
* prvTraceGetCurrentTaskHandle
*
* Function that returns the handle to the currently executing task.
*
******************************************************************************/
void* prvTraceGetCurrentTaskHandle(void)
{
return xTaskGetCurrentTaskHandle();
}
/*******************************************************************************
* prvIsNewTCB
*
* Function that returns the handle to the currently executing task.
*
******************************************************************************/
static void* pCurrentTCB = NULL;
uint32_t prvIsNewTCB(void* pNewTCB)
{
if (pCurrentTCB != pNewTCB)
{
pCurrentTCB = pNewTCB;
return 1;
}
return 0;
}
/*******************************************************************************
* CheckRecorderStatus
*
* Called by TzCtrl task periodically (every 100 ms - seems reasonable).
* Checks a number of diagnostic variables and give warnings as user events,
* in most cases including a suggested solution.
******************************************************************************/
static void CheckRecorderStatus(void)
{
if (NoRoomForSymbol > NoRoomForSymbol_last)
{
vTracePrintF(trcWarningChannel, "TRC_SYMBOL_TABLE_SLOTS too small. Add %d slots.",
NoRoomForSymbol);
NoRoomForSymbol_last = NoRoomForSymbol;
}
if (NoRoomForObjectData > NoRoomForObjectData_last)
{
vTracePrintF(trcWarningChannel, "TRC_OBJECT_DATA_SLOTS too small. Add %d slots.",
NoRoomForObjectData);
NoRoomForObjectData_last = NoRoomForObjectData;
}
if (LongestSymbolName > LongestSymbolName_last)
{
if (LongestSymbolName > TRC_SYMBOL_MAX_LENGTH)
{
vTracePrintF(trcWarningChannel, "TRC_SYMBOL_MAX_LENGTH too small. Add %d chars.",
LongestSymbolName);
}
LongestSymbolName_last = LongestSymbolName;
}
if (MaxBytesTruncated > MaxBytesTruncated_last)
{
/* Some string event generated a too long string that was truncated.
This may happen for the following functions:
- vTracePrintF
- vTracePrintF
- vTraceStoreKernelObjectName
- vTraceStoreUserEventChannelName
- vTraceSetISRProperties
A PSF event may store maximum 60 bytes payload, including data arguments
and string characters. For User Events, also the User Event Channel ptr
must be squeezed in, if a channel is specified. */
vTracePrintF(trcWarningChannel, "String event too long, up to %d bytes truncated.",
MaxBytesTruncated);
MaxBytesTruncated_last = MaxBytesTruncated;
}
#if ((TRC_STREAM_PORT_BLOCKING_TRANSFER==1) && (TRC_MEASURE_BLOCKING_TIME))
if (blockingCount > 0)
{
/* At least one case of blocking since the last check and this is
the longest case. */
vTracePrintF(trcDiagnosticsChannel, "Longest since last: %d us",
(uint32_t)blockingCyclesMax/(TRACE_CPU_CLOCK_HZ/1000000));
blockingCyclesMax = 0;
}
#endif
}
/*******************************************************************************
* vTraceOnTraceBegin
*
* Called on trace begin.
******************************************************************************/
void vTraceOnTraceBegin(void)
{
TRC_STREAM_PORT_ON_TRACE_BEGIN();
}
/*******************************************************************************
* vTraceOnTraceEnd
*
* Called on trace end.
******************************************************************************/
void vTraceOnTraceEnd(void)
{
TRC_STREAM_PORT_ON_TRACE_END();
}
/*******************************************************************************
* TzCtrl
*
* Task for receiving commands from Tracealyzer and for recorder diagnostics.
*
******************************************************************************/
static portTASK_FUNCTION( TzCtrl, pvParameters )
{
TracealyzerCommandType msg;
int bytes = 0;
while (1)
{
bytes = 0;
TRC_STREAM_PORT_READ_DATA(&msg, sizeof(TracealyzerCommandType), &bytes);
if (bytes != 0)
{
if (bytes == sizeof(TracealyzerCommandType))
{
if (isValidCommand(&msg))
{
processCommand(&msg); /* Start or Stop currently... */
}
}
}
do
{
bytes = 0;
TRC_STREAM_PORT_PERIODIC_SEND_DATA(&bytes);
}
while (bytes != 0);
CheckRecorderStatus();
vTaskDelay(TRC_CTRL_TASK_DELAY); /* 10ms */
}
}
/*******************************************************************************
* Trace_Init
*
* The main initialization routine for the trace recorder. Configures the stream
* and activates the TzCtrl task.
* Also sets up the diagnostic User Event channels used by TzCtrl task.
*
******************************************************************************/
void Trace_Init(void)
{
TRC_STREAM_PORT_INIT();
trcWarningChannel = vTraceStoreUserEventChannelName("Warnings from Recorder");
#if ((TRC_STREAM_PORT_BLOCKING_TRANSFER==1) && (TRC_MEASURE_BLOCKING_TIME))
trcDiagnosticsChannel = vTraceStoreUserEventChannelName("Blocking on trace buffer");
#endif
/* Creates the TzCtrl task - receives trace commands (start, stop, ...) */
xTaskCreate( TzCtrl, "TzCtrl", configMINIMAL_STACK_SIZE, NULL, TRC_CTRL_TASK_PRIORITY, &HandleTzCtrl );
}
#endif
| RobsonRojas/frertos-udemy | Keil-FreeRTOS-Sample-Project/Keil-FreeRTOS/FreeRTOSv9.0.0/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace(streaming)/trcKernelPort.c | C | gpl-3.0 | 8,840 |
# zxcvbn-c
This is a C/C++ implementation of the zxcvbn password strength estimation.
The code is intended to be included as part of the source of a C/C++ program. Like the
original this code is for character sets which use single byte characters primarily in the
code range 0x20 to 0x7E.
The original coffee script version is available at
https://github.com/lowe/zxcvbn
An article on the reasons for zxcvbn is at
https://tech.dropox.com/2012/04/zxcvbn-realistic-password-strength-estimation
##Building
The makefile will build several test programs to test the code. It shows the steps needed
to use the code in C and C++ programs, using the dictionary data read from file or included
within the program executable.
The makefile has only been tried on Linux using GCC version 4.8.4, but should be faily
portable to other systems.
When dictionary data is included in your program's executable, the files `zxcvbn.c` ,
`zxcvbn.h` , `dict-src.h` are used in your program.
When dictionary data is read from file, the files `zxcvbn.c` , `zxcvbn.h` , `dict-crc.h`
and `zxcvbn.dict` are used in your program, compiled with `#define USE_DICT_FILE`. The CRC
of the dictionary data file is written to `dict-crc.h` so your executable can detect
corruption of the data.
Rename `zxcvbn.c` to `zxcvbn.cpp` (or whatever your compiler uses) to compile as C++.
The `dict*.h` and `zxcvbn.dict` files are generated by the dictgen program compiled from
dict-generate.cpp (see makefile for details).
##Using
Initially call `ZxcvbnInit()` with the pathname of the `zxcvbn.dict` file. This can be
omitted when dictionary data is included in the executable.
Call `ZxcvbnMatch()` with the password and optional user dictionary to get the entropy
estimation and optional information on the password parts (which will need freeing with
`ZxcvbnFreeInfo()` after use). Do this for each password to be tested, or as each character
of it is entered into your program. The optional user dictionary can change between each
call.
Finally call `ZxcvbnUninit()` to free the dictionary data from read from file. This can be
omitted when dictionary data is included in the executable.
Review the test program in `test.c` for an example.
## Differences from the original version.
The entropy calculated will sometimes differ from the original because of
* The UK keyboard layout is also included, so there are additional spacial sequences, e.g.
**;'#** is a spacial sequence.
* The different character classes in a password are taken into account when calculating the
strength of brute-force matches.
* Dijktra's path searching algorithm is used to combine parts of the entered password. This
can result in the found parts of the password being combined differently than the
original coffee script. E.g. the password **passwordassword**
is combined by the original coffee script as **p** (3.5 bits) + **asswordassword** (12.6
bits) + multiple part allowance (1.0bit) to give total entropy of 17.1 bits. This
implementation combines it as **password** (1.0 bit) + **assword** (11.6 bits) + multiple
part allowance (1.0bit) to give 13.6 bits.
* For multi part passwords the original coffee script version multiplies the number of
guesses needed by the factorial of the number of parts. This is not possible in this
version as Dijktra's algorithm is used. Instead one bit entropy is added for the part at the
end of the password, 1.7 bits for each part in the middle of a password and nothing
for the part at the beginning. This gives similar results compared to the coffee script
version when there are 4 or less parts, but will differ significantly when there are many
parts (which is likely to be a rare occurrence).
##References
The original coffee-script version is available at
https://github.com/lowe/zxcvbn
The dictionary words are taken from the original coffee script version.
Dictionary trie encoding (used for by the word lookup code) based on idea from the Caroline
Word Graph from
http://www.pathcom.com/~vadco/cwg.html
| mooltipass/moolticute | src/zxcvbn-c/README.md | Markdown | gpl-3.0 | 4,021 |
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Basic BOT handling.
//
// $Workfile: $
// $Date: $
//
//-----------------------------------------------------------------------------
// $Log: $
//
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include "player.h"
#include "sdk_player.h"
#include "in_buttons.h"
#include "movehelper_server.h"
#include "gameinterface.h"
class CSDKBot;
void Bot_Think( CSDKBot *pBot );
ConVar bot_forcefireweapon( "bot_forcefireweapon", "", 0, "Force bots with the specified weapon to fire." );
ConVar bot_forceattack2( "bot_forceattack2", "0", 0, "When firing, use attack2." );
ConVar bot_forceattackon( "bot_forceattackon", "0", 0, "When firing, don't tap fire, hold it down." );
ConVar bot_flipout( "bot_flipout", "0", 0, "When on, all bots fire their guns." );
ConVar bot_changeclass( "bot_changeclass", "0", 0, "Force all bots to change to the specified class." );
static ConVar bot_mimic( "bot_mimic", "0", 0, "Bot uses usercmd of player by index." );
static ConVar bot_mimic_yaw_offset( "bot_mimic_yaw_offset", "0", 0, "Offsets the bot yaw." );
ConVar bot_sendcmd( "bot_sendcmd", "", 0, "Forces bots to send the specified command." );
ConVar bot_crouch( "bot_crouch", "0", 0, "Bot crouches" );
static int g_CurBotNumber = 1;
// This is our bot class.
class CSDKBot : public CSDKPlayer
{
public:
bool m_bBackwards;
float m_flNextTurnTime;
bool m_bLastTurnToRight;
float m_flNextStrafeTime;
float m_flSideMove;
QAngle m_ForwardAngle;
QAngle m_LastAngles;
};
LINK_ENTITY_TO_CLASS( sdk_bot, CSDKBot );
class CBotManager
{
public:
static CBasePlayer* ClientPutInServerOverride_Bot( edict_t *pEdict, const char *playername )
{
// This tells it which edict to use rather than creating a new one.
CBasePlayer::s_PlayerEdict = pEdict;
CSDKBot *pPlayer = static_cast<CSDKBot *>( CreateEntityByName( "sdk_bot" ) );
if ( pPlayer )
{
pPlayer->SetPlayerName( playername );
}
return pPlayer;
}
};
//-----------------------------------------------------------------------------
// Purpose: Create a new Bot and put it in the game.
// Output : Pointer to the new Bot, or NULL if there's no free clients.
//-----------------------------------------------------------------------------
CBasePlayer *BotPutInServer( bool bFrozen )
{
char botname[ 64 ];
Q_snprintf( botname, sizeof( botname ), "Bot%02i", g_CurBotNumber );
// This trick lets us create a CSDKBot for this client instead of the CSDKPlayer
// that we would normally get when ClientPutInServer is called.
ClientPutInServerOverride( &CBotManager::ClientPutInServerOverride_Bot );
edict_t *pEdict = engine->CreateFakeClient( botname );
ClientPutInServerOverride( NULL );
if (!pEdict)
{
Msg( "Failed to create Bot.\n");
return NULL;
}
// Allocate a player entity for the bot, and call spawn
CSDKBot *pPlayer = ((CSDKBot*)CBaseEntity::Instance( pEdict ));
pPlayer->ClearFlags();
pPlayer->AddFlag( FL_CLIENT | FL_FAKECLIENT );
if ( bFrozen )
pPlayer->AddEFlags( EFL_BOT_FROZEN );
pPlayer->ChangeTeam( TEAM_UNASSIGNED );
pPlayer->RemoveAllItems( true );
pPlayer->Spawn();
g_CurBotNumber++;
return pPlayer;
}
// Handler for the "bot" command.
CON_COMMAND_F( "bot_add", "Add a bot.", FCVAR_CHEAT )
{
// Look at -count.
int count = args.FindArgInt( "-count", 1 );
count = clamp( count, 1, 16 );
// Look at -frozen.
bool bFrozen = !!args.FindArg( "-frozen" );
// Ok, spawn all the bots.
while ( --count >= 0 )
{
BotPutInServer( bFrozen );
}
}
//-----------------------------------------------------------------------------
// Purpose: Run through all the Bots in the game and let them think.
//-----------------------------------------------------------------------------
void Bot_RunAll( void )
{
for ( int i = 1; i <= gpGlobals->maxClients; i++ )
{
CSDKPlayer *pPlayer = ToSDKPlayer( UTIL_PlayerByIndex( i ) );
if ( pPlayer && (pPlayer->GetFlags() & FL_FAKECLIENT) )
{
CSDKBot *pBot = dynamic_cast< CSDKBot* >( pPlayer );
if ( pBot )
Bot_Think( pBot );
}
}
}
bool Bot_RunMimicCommand( CUserCmd& cmd )
{
if ( bot_mimic.GetInt() <= 0 )
return false;
if ( bot_mimic.GetInt() > gpGlobals->maxClients )
return false;
CBasePlayer *pPlayer = UTIL_PlayerByIndex( bot_mimic.GetInt() );
if ( !pPlayer )
return false;
if ( !pPlayer->GetLastUserCommand() )
return false;
cmd = *pPlayer->GetLastUserCommand();
cmd.viewangles[YAW] += bot_mimic_yaw_offset.GetFloat();
if( bot_crouch.GetInt() )
cmd.buttons |= IN_DUCK;
return true;
}
//-----------------------------------------------------------------------------
// Purpose: Simulates a single frame of movement for a player
// Input : *fakeclient -
// *viewangles -
// forwardmove -
// m_flSideMove -
// upmove -
// buttons -
// impulse -
// msec -
// Output : virtual void
//-----------------------------------------------------------------------------
static void RunPlayerMove( CSDKPlayer *fakeclient, CUserCmd &cmd, float frametime )
{
if ( !fakeclient )
return;
// Store off the globals.. they're gonna get whacked
float flOldFrametime = gpGlobals->frametime;
float flOldCurtime = gpGlobals->curtime;
float flTimeBase = gpGlobals->curtime + gpGlobals->frametime - frametime;
fakeclient->SetTimeBase( flTimeBase );
MoveHelperServer()->SetHost( fakeclient );
fakeclient->PlayerRunCommand( &cmd, MoveHelperServer() );
// save off the last good usercmd
fakeclient->SetLastUserCommand( cmd );
// Clear out any fixangle that has been set
fakeclient->pl.fixangle = FIXANGLE_NONE;
// Restore the globals..
gpGlobals->frametime = flOldFrametime;
gpGlobals->curtime = flOldCurtime;
}
void Bot_UpdateStrafing( CSDKBot *pBot, CUserCmd &cmd )
{
if ( gpGlobals->curtime >= pBot->m_flNextStrafeTime )
{
pBot->m_flNextStrafeTime = gpGlobals->curtime + 1.0f;
if ( random->RandomInt( 0, 5 ) == 0 )
{
pBot->m_flSideMove = -600.0f + 1200.0f * random->RandomFloat( 0, 2 );
}
else
{
pBot->m_flSideMove = 0;
}
cmd.sidemove = pBot->m_flSideMove;
if ( random->RandomInt( 0, 20 ) == 0 )
{
pBot->m_bBackwards = true;
}
else
{
pBot->m_bBackwards = false;
}
}
}
void Bot_UpdateDirection( CSDKBot *pBot )
{
float angledelta = 15.0;
QAngle angle;
int maxtries = (int)360.0/angledelta;
if ( pBot->m_bLastTurnToRight )
{
angledelta = -angledelta;
}
angle = pBot->GetLocalAngles();
trace_t trace;
Vector vecSrc, vecEnd, forward;
while ( --maxtries >= 0 )
{
AngleVectors( angle, &forward );
vecSrc = pBot->GetLocalOrigin() + Vector( 0, 0, 36 );
vecEnd = vecSrc + forward * 10;
UTIL_TraceHull( vecSrc, vecEnd, VEC_HULL_MIN_SCALED( pBot ), VEC_HULL_MAX_SCALED( pBot ),
MASK_PLAYERSOLID, pBot, COLLISION_GROUP_NONE, &trace );
if ( trace.fraction == 1.0 )
{
if ( gpGlobals->curtime < pBot->m_flNextTurnTime )
{
break;
}
}
angle.y += angledelta;
if ( angle.y > 180 )
angle.y -= 360;
else if ( angle.y < -180 )
angle.y += 360;
pBot->m_flNextTurnTime = gpGlobals->curtime + 2.0;
pBot->m_bLastTurnToRight = random->RandomInt( 0, 1 ) == 0 ? true : false;
pBot->m_ForwardAngle = angle;
pBot->m_LastAngles = angle;
}
pBot->SetLocalAngles( angle );
}
void Bot_FlipOut( CSDKBot *pBot, CUserCmd &cmd )
{
if ( bot_flipout.GetInt() > 0 && pBot->IsAlive() )
{
if ( bot_forceattackon.GetBool() || (RandomFloat(0.0,1.0) > 0.5) )
{
cmd.buttons |= bot_forceattack2.GetBool() ? IN_ATTACK2 : IN_ATTACK;
}
if ( bot_flipout.GetInt() >= 2 )
{
QAngle angOffset = RandomAngle( -1, 1 );
pBot->m_LastAngles += angOffset;
for ( int i = 0 ; i < 2; i++ )
{
if ( fabs( pBot->m_LastAngles[ i ] - pBot->m_ForwardAngle[ i ] ) > 15.0f )
{
if ( pBot->m_LastAngles[ i ] > pBot->m_ForwardAngle[ i ] )
{
pBot->m_LastAngles[ i ] = pBot->m_ForwardAngle[ i ] + 15;
}
else
{
pBot->m_LastAngles[ i ] = pBot->m_ForwardAngle[ i ] - 15;
}
}
}
pBot->m_LastAngles[ 2 ] = 0;
pBot->SetLocalAngles( pBot->m_LastAngles );
}
}
}
void Bot_HandleSendCmd( CSDKBot *pBot )
{
if ( strlen( bot_sendcmd.GetString() ) > 0 )
{
//send the cmd from this bot
pBot->ClientCommand( bot_sendcmd.GetString() );
bot_sendcmd.SetValue("");
}
}
// If bots are being forced to fire a weapon, see if I have it
void Bot_ForceFireWeapon( CSDKBot *pBot, CUserCmd &cmd )
{
if ( bot_forcefireweapon.GetString() )
{
CBaseCombatWeapon *pWeapon = pBot->Weapon_OwnsThisType( bot_forcefireweapon.GetString() );
if ( pWeapon )
{
// Switch to it if we don't have it out
CBaseCombatWeapon *pActiveWeapon = pBot->GetActiveWeapon();
// Switch?
if ( pActiveWeapon != pWeapon )
{
pBot->Weapon_Switch( pWeapon );
}
else
{
// Start firing
// Some weapons require releases, so randomise firing
if ( bot_forceattackon.GetBool() || (RandomFloat(0.0,1.0) > 0.5) )
{
cmd.buttons |= bot_forceattack2.GetBool() ? IN_ATTACK2 : IN_ATTACK;
}
}
}
}
}
void Bot_SetForwardMovement( CSDKBot *pBot, CUserCmd &cmd )
{
if ( !pBot->IsEFlagSet(EFL_BOT_FROZEN) )
{
if ( pBot->m_iHealth == 100 )
{
cmd.forwardmove = 600 * ( pBot->m_bBackwards ? -1 : 1 );
if ( pBot->m_flSideMove != 0.0f )
{
cmd.forwardmove *= random->RandomFloat( 0.1, 1.0f );
}
}
else
{
// Stop when shot
cmd.forwardmove = 0;
}
}
}
void Bot_HandleRespawn( CSDKBot *pBot, CUserCmd &cmd )
{
// Wait for Reinforcement wave
if ( !pBot->IsAlive() )
{
// Try hitting my buttons occasionally
if ( random->RandomInt( 0, 100 ) > 80 )
{
// Respawn the bot
if ( random->RandomInt( 0, 1 ) == 0 )
{
cmd.buttons |= IN_JUMP;
}
else
{
cmd.buttons = 0;
}
}
}
}
//-----------------------------------------------------------------------------
// Run this Bot's AI for one frame.
//-----------------------------------------------------------------------------
void Bot_Think( CSDKBot *pBot )
{
// Make sure we stay being a bot
pBot->AddFlag( FL_FAKECLIENT );
CUserCmd cmd;
Q_memset( &cmd, 0, sizeof( cmd ) );
// Finally, override all this stuff if the bot is being forced to mimic a player.
if ( !Bot_RunMimicCommand( cmd ) )
{
cmd.sidemove = pBot->m_flSideMove;
if ( pBot->IsAlive() && (pBot->GetSolid() == SOLID_BBOX) )
{
Bot_SetForwardMovement( pBot, cmd );
// Only turn if I haven't been hurt
if ( !pBot->IsEFlagSet(EFL_BOT_FROZEN) && pBot->m_iHealth == 100 )
{
Bot_UpdateDirection( pBot );
Bot_UpdateStrafing( pBot, cmd );
}
// Handle console settings.
Bot_ForceFireWeapon( pBot, cmd );
Bot_HandleSendCmd( pBot );
}
else
{
Bot_HandleRespawn( pBot, cmd );
}
Bot_FlipOut( pBot, cmd );
cmd.viewangles = pBot->GetLocalAngles();
cmd.upmove = 0;
cmd.impulse = 0;
}
float frametime = gpGlobals->frametime;
RunPlayerMove( pBot, cmd, frametime );
}
| OnePointSeven/onepointseven | src/game/server/sdk/sdk_bot_temp.cpp | C++ | gpl-3.0 | 11,070 |
/*
** $Id: sjisunimap.c 12463 2010-01-15 02:14:24Z houhuihua $
**
** sjisunimap.c: Shift-JIS to UNICODE map.
**
** Copyright (C) 2003 ~ 2008 Feynman Software.
**
** All rights reserved by Feynman Software.
**
** Create date: 2003/02/14
*/
#include "common.h"
#ifdef _MGCHARSET_SHIFTJIS
#ifdef _MGCHARSET_UNICODE
const unsigned short __mg_jisx0208_1_unicode_map[] = {
0x3000, 0x3001, 0x3002,
0xff0c, 0xff0e, 0x30fb,
0xff1a, 0xff1b, 0xff1f,
0xff01, 0x309b, 0x309c,
0x00b4, 0xff40, 0x00a8,
0xff3e, 0xffe3, 0xff3f,
0x30fd, 0x30fe, 0x309d,
0x309e, 0x3003, 0x4edd,
0x3005, 0x3006, 0x3007,
0x30fc, 0x2015, 0x2010,
0xff0f, 0x005c, 0x301c,
0x2016, 0xff5c, 0x2026,
0x2025, 0x2018, 0x2019,
0x201c, 0x201d, 0xff08,
0xff09, 0x3014, 0x3015,
0xff3b, 0xff3d, 0xff5b,
0xff5d, 0x3008, 0x3009,
0x300a, 0x300b, 0x300c,
0x300d, 0x300e, 0x300f,
0x3010, 0x3011, 0xff0b,
0x2212, 0x00b1, 0x00d7,
0x00f7, 0xff1d, 0x2260,
0xff1c, 0xff1e, 0x2266,
0x2267, 0x221e, 0x2234,
0x2642, 0x2640, 0x00b0,
0x2032, 0x2033, 0x2103,
0xffe5, 0xff04, 0x00a2,
0x00a3, 0xff05, 0xff03,
0xff06, 0xff0a, 0xff20,
0x00a7, 0x2606, 0x2605,
0x25cb, 0x25cf, 0x25ce,
0x25c7, 0x25c6, 0x25a1,
0x25a0, 0x25b3, 0x25b2,
0x25bd, 0x25bc, 0x203b,
0x3012, 0x2192, 0x2190,
0x2191, 0x2193, 0x3013,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x2208,
0x220b, 0x2286, 0x2287,
0x2282, 0x2283, 0x222a,
0x2229, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x2227, 0x2228, 0x00ac,
0x21d2, 0x21d4, 0x2200,
0x2203, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x2220, 0x22a5, 0x2312,
0x2202, 0x2207, 0x2261,
0x2252, 0x226a, 0x226b,
0x221a, 0x223d, 0x221d,
0x2235, 0x222b, 0x222c,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x212b, 0x2030,
0x266f, 0x266d, 0x266a,
0x2020, 0x2021, 0x00b6,
0x0000, 0x0000, 0x0000,
0x0000, 0x25ef, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0xff10,
0xff11, 0xff12, 0xff13,
0xff14, 0xff15, 0xff16,
0xff17, 0xff18, 0xff19,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0xff21, 0xff22,
0xff23, 0xff24, 0xff25,
0xff26, 0xff27, 0xff28,
0xff29, 0xff2a, 0xff2b,
0xff2c, 0xff2d, 0xff2e,
0xff2f, 0xff30, 0xff31,
0xff32, 0xff33, 0xff34,
0xff35, 0xff36, 0xff37,
0xff38, 0xff39, 0xff3a,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0xff41, 0xff42, 0xff43,
0xff44, 0xff45, 0xff46,
0xff47, 0xff48, 0xff49,
0xff4a, 0xff4b, 0xff4c,
0xff4d, 0xff4e, 0xff4f,
0xff50, 0xff51, 0xff52,
0xff53, 0xff54, 0xff55,
0xff56, 0xff57, 0xff58,
0xff59, 0xff5a, 0x0000,
0x0000, 0x0000, 0x0000,
0x3041, 0x3042, 0x3043,
0x3044, 0x3045, 0x3046,
0x3047, 0x3048, 0x3049,
0x304a, 0x304b, 0x304c,
0x304d, 0x304e, 0x304f,
0x3050, 0x3051, 0x3052,
0x3053, 0x3054, 0x3055,
0x3056, 0x3057, 0x3058,
0x3059, 0x305a, 0x305b,
0x305c, 0x305d, 0x305e,
0x305f, 0x3060, 0x3061,
0x3062, 0x3063, 0x3064,
0x3065, 0x3066, 0x3067,
0x3068, 0x3069, 0x306a,
0x306b, 0x306c, 0x306d,
0x306e, 0x306f, 0x3070,
0x3071, 0x3072, 0x3073,
0x3074, 0x3075, 0x3076,
0x3077, 0x3078, 0x3079,
0x307a, 0x307b, 0x307c,
0x307d, 0x307e, 0x307f,
0x3080, 0x3081, 0x3082,
0x3083, 0x3084, 0x3085,
0x3086, 0x3087, 0x3088,
0x3089, 0x308a, 0x308b,
0x308c, 0x308d, 0x308e,
0x308f, 0x3090, 0x3091,
0x3092, 0x3093, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x30a1, 0x30a2,
0x30a3, 0x30a4, 0x30a5,
0x30a6, 0x30a7, 0x30a8,
0x30a9, 0x30aa, 0x30ab,
0x30ac, 0x30ad, 0x30ae,
0x30af, 0x30b0, 0x30b1,
0x30b2, 0x30b3, 0x30b4,
0x30b5, 0x30b6, 0x30b7,
0x30b8, 0x30b9, 0x30ba,
0x30bb, 0x30bc, 0x30bd,
0x30be, 0x30bf, 0x30c0,
0x30c1, 0x30c2, 0x30c3,
0x30c4, 0x30c5, 0x30c6,
0x30c7, 0x30c8, 0x30c9,
0x30ca, 0x30cb, 0x30cc,
0x30cd, 0x30ce, 0x30cf,
0x30d0, 0x30d1, 0x30d2,
0x30d3, 0x30d4, 0x30d5,
0x30d6, 0x30d7, 0x30d8,
0x30d9, 0x30da, 0x30db,
0x30dc, 0x30dd, 0x30de,
0x30df, 0x30e0, 0x30e1,
0x30e2, 0x30e3, 0x30e4,
0x30e5, 0x30e6, 0x30e7,
0x30e8, 0x30e9, 0x30ea,
0x30eb, 0x30ec, 0x30ed,
0x30ee, 0x30ef, 0x30f0,
0x30f1, 0x30f2, 0x30f3,
0x30f4, 0x30f5, 0x30f6,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0391,
0x0392, 0x0393, 0x0394,
0x0395, 0x0396, 0x0397,
0x0398, 0x0399, 0x039a,
0x039b, 0x039c, 0x039d,
0x039e, 0x039f, 0x03a0,
0x03a1, 0x03a3, 0x03a4,
0x03a5, 0x03a6, 0x03a7,
0x03a8, 0x03a9, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x03b1, 0x03b2,
0x03b3, 0x03b4, 0x03b5,
0x03b6, 0x03b7, 0x03b8,
0x03b9, 0x03ba, 0x03bb,
0x03bc, 0x03bd, 0x03be,
0x03bf, 0x03c0, 0x03c1,
0x03c3, 0x03c4, 0x03c5,
0x03c6, 0x03c7, 0x03c8,
0x03c9, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0410, 0x0411, 0x0412,
0x0413, 0x0414, 0x0415,
0x0401, 0x0416, 0x0417,
0x0418, 0x0419, 0x041a,
0x041b, 0x041c, 0x041d,
0x041e, 0x041f, 0x0420,
0x0421, 0x0422, 0x0423,
0x0424, 0x0425, 0x0426,
0x0427, 0x0428, 0x0429,
0x042a, 0x042b, 0x042c,
0x042d, 0x042e, 0x042f,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0430, 0x0431, 0x0432,
0x0433, 0x0434, 0x0435,
0x0451, 0x0436, 0x0437,
0x0438, 0x0439, 0x043a,
0x043b, 0x043c, 0x043d,
0x043e, 0x043f, 0x0440,
0x0441, 0x0442, 0x0443,
0x0444, 0x0445, 0x0446,
0x0447, 0x0448, 0x0449,
0x044a, 0x044b, 0x044c,
0x044d, 0x044e, 0x044f,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x2500, 0x2502,
0x250c, 0x2510, 0x2518,
0x2514, 0x251c, 0x252c,
0x2524, 0x2534, 0x253c,
0x2501, 0x2503, 0x250f,
0x2513, 0x251b, 0x2517,
0x2523, 0x2533, 0x252b,
0x253b, 0x254b, 0x2520,
0x252f, 0x2528, 0x2537,
0x253f, 0x251d, 0x2530,
0x2525, 0x2538, 0x2542,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x4e9c, 0x5516, 0x5a03,
0x963f, 0x54c0, 0x611b,
0x6328, 0x59f6, 0x9022,
0x8475, 0x831c, 0x7a50,
0x60aa, 0x63e1, 0x6e25,
0x65ed, 0x8466, 0x82a6,
0x9bf5, 0x6893, 0x5727,
0x65a1, 0x6271, 0x5b9b,
0x59d0, 0x867b, 0x98f4,
0x7d62, 0x7dbe, 0x9b8e,
0x6216, 0x7c9f, 0x88b7,
0x5b89, 0x5eb5, 0x6309,
0x6697, 0x6848, 0x95c7,
0x978d, 0x674f, 0x4ee5,
0x4f0a, 0x4f4d, 0x4f9d,
0x5049, 0x56f2, 0x5937,
0x59d4, 0x5a01, 0x5c09,
0x60df, 0x610f, 0x6170,
0x6613, 0x6905, 0x70ba,
0x754f, 0x7570, 0x79fb,
0x7dad, 0x7def, 0x80c3,
0x840e, 0x8863, 0x8b02,
0x9055, 0x907a, 0x533b,
0x4e95, 0x4ea5, 0x57df,
0x80b2, 0x90c1, 0x78ef,
0x4e00, 0x58f1, 0x6ea2,
0x9038, 0x7a32, 0x8328,
0x828b, 0x9c2f, 0x5141,
0x5370, 0x54bd, 0x54e1,
0x56e0, 0x59fb, 0x5f15,
0x98f2, 0x6deb, 0x80e4,
0x852d, 0x9662, 0x9670,
0x96a0, 0x97fb, 0x540b,
0x53f3, 0x5b87, 0x70cf,
0x7fbd, 0x8fc2, 0x96e8,
0x536f, 0x9d5c, 0x7aba,
0x4e11, 0x7893, 0x81fc,
0x6e26, 0x5618, 0x5504,
0x6b1d, 0x851a, 0x9c3b,
0x59e5, 0x53a9, 0x6d66,
0x74dc, 0x958f, 0x5642,
0x4e91, 0x904b, 0x96f2,
0x834f, 0x990c, 0x53e1,
0x55b6, 0x5b30, 0x5f71,
0x6620, 0x66f3, 0x6804,
0x6c38, 0x6cf3, 0x6d29,
0x745b, 0x76c8, 0x7a4e,
0x9834, 0x82f1, 0x885b,
0x8a60, 0x92ed, 0x6db2,
0x75ab, 0x76ca, 0x99c5,
0x60a6, 0x8b01, 0x8d8a,
0x95b2, 0x698e, 0x53ad,
0x5186, 0x5712, 0x5830,
0x5944, 0x5bb4, 0x5ef6,
0x6028, 0x63a9, 0x63f4,
0x6cbf, 0x6f14, 0x708e,
0x7114, 0x7159, 0x71d5,
0x733f, 0x7e01, 0x8276,
0x82d1, 0x8597, 0x9060,
0x925b, 0x9d1b, 0x5869,
0x65bc, 0x6c5a, 0x7525,
0x51f9, 0x592e, 0x5965,
0x5f80, 0x5fdc, 0x62bc,
0x65fa, 0x6a2a, 0x6b27,
0x6bb4, 0x738b, 0x7fc1,
0x8956, 0x9d2c, 0x9d0e,
0x9ec4, 0x5ca1, 0x6c96,
0x837b, 0x5104, 0x5c4b,
0x61b6, 0x81c6, 0x6876,
0x7261, 0x4e59, 0x4ffa,
0x5378, 0x6069, 0x6e29,
0x7a4f, 0x97f3, 0x4e0b,
0x5316, 0x4eee, 0x4f55,
0x4f3d, 0x4fa1, 0x4f73,
0x52a0, 0x53ef, 0x5609,
0x590f, 0x5ac1, 0x5bb6,
0x5be1, 0x79d1, 0x6687,
0x679c, 0x67b6, 0x6b4c,
0x6cb3, 0x706b, 0x73c2,
0x798d, 0x79be, 0x7a3c,
0x7b87, 0x82b1, 0x82db,
0x8304, 0x8377, 0x83ef,
0x83d3, 0x8766, 0x8ab2,
0x5629, 0x8ca8, 0x8fe6,
0x904e, 0x971e, 0x868a,
0x4fc4, 0x5ce8, 0x6211,
0x7259, 0x753b, 0x81e5,
0x82bd, 0x86fe, 0x8cc0,
0x96c5, 0x9913, 0x99d5,
0x4ecb, 0x4f1a, 0x89e3,
0x56de, 0x584a, 0x58ca,
0x5efb, 0x5feb, 0x602a,
0x6094, 0x6062, 0x61d0,
0x6212, 0x62d0, 0x6539,
0x9b41, 0x6666, 0x68b0,
0x6d77, 0x7070, 0x754c,
0x7686, 0x7d75, 0x82a5,
0x87f9, 0x958b, 0x968e,
0x8c9d, 0x51f1, 0x52be,
0x5916, 0x54b3, 0x5bb3,
0x5d16, 0x6168, 0x6982,
0x6daf, 0x788d, 0x84cb,
0x8857, 0x8a72, 0x93a7,
0x9ab8, 0x6d6c, 0x99a8,
0x86d9, 0x57a3, 0x67ff,
0x86ce, 0x920e, 0x5283,
0x5687, 0x5404, 0x5ed3,
0x62e1, 0x64b9, 0x683c,
0x6838, 0x6bbb, 0x7372,
0x78ba, 0x7a6b, 0x899a,
0x89d2, 0x8d6b, 0x8f03,
0x90ed, 0x95a3, 0x9694,
0x9769, 0x5b66, 0x5cb3,
0x697d, 0x984d, 0x984e,
0x639b, 0x7b20, 0x6a2b,
0x6a7f, 0x68b6, 0x9c0d,
0x6f5f, 0x5272, 0x559d,
0x6070, 0x62ec, 0x6d3b,
0x6e07, 0x6ed1, 0x845b,
0x8910, 0x8f44, 0x4e14,
0x9c39, 0x53f6, 0x691b,
0x6a3a, 0x9784, 0x682a,
0x515c, 0x7ac3, 0x84b2,
0x91dc, 0x938c, 0x565b,
0x9d28, 0x6822, 0x8305,
0x8431, 0x7ca5, 0x5208,
0x82c5, 0x74e6, 0x4e7e,
0x4f83, 0x51a0, 0x5bd2,
0x520a, 0x52d8, 0x52e7,
0x5dfb, 0x559a, 0x582a,
0x59e6, 0x5b8c, 0x5b98,
0x5bdb, 0x5e72, 0x5e79,
0x60a3, 0x611f, 0x6163,
0x61be, 0x63db, 0x6562,
0x67d1, 0x6853, 0x68fa,
0x6b3e, 0x6b53, 0x6c57,
0x6f22, 0x6f97, 0x6f45,
0x74b0, 0x7518, 0x76e3,
0x770b, 0x7aff, 0x7ba1,
0x7c21, 0x7de9, 0x7f36,
0x7ff0, 0x809d, 0x8266,
0x839e, 0x89b3, 0x8acc,
0x8cab, 0x9084, 0x9451,
0x9593, 0x9591, 0x95a2,
0x9665, 0x97d3, 0x9928,
0x8218, 0x4e38, 0x542b,
0x5cb8, 0x5dcc, 0x73a9,
0x764c, 0x773c, 0x5ca9,
0x7feb, 0x8d0b, 0x96c1,
0x9811, 0x9854, 0x9858,
0x4f01, 0x4f0e, 0x5371,
0x559c, 0x5668, 0x57fa,
0x5947, 0x5b09, 0x5bc4,
0x5c90, 0x5e0c, 0x5e7e,
0x5fcc, 0x63ee, 0x673a,
0x65d7, 0x65e2, 0x671f,
0x68cb, 0x68c4, 0x6a5f,
0x5e30, 0x6bc5, 0x6c17,
0x6c7d, 0x757f, 0x7948,
0x5b63, 0x7a00, 0x7d00,
0x5fbd, 0x898f, 0x8a18,
0x8cb4, 0x8d77, 0x8ecc,
0x8f1d, 0x98e2, 0x9a0e,
0x9b3c, 0x4e80, 0x507d,
0x5100, 0x5993, 0x5b9c,
0x622f, 0x6280, 0x64ec,
0x6b3a, 0x72a0, 0x7591,
0x7947, 0x7fa9, 0x87fb,
0x8abc, 0x8b70, 0x63ac,
0x83ca, 0x97a0, 0x5409,
0x5403, 0x55ab, 0x6854,
0x6a58, 0x8a70, 0x7827,
0x6775, 0x9ecd, 0x5374,
0x5ba2, 0x811a, 0x8650,
0x9006, 0x4e18, 0x4e45,
0x4ec7, 0x4f11, 0x53ca,
0x5438, 0x5bae, 0x5f13,
0x6025, 0x6551, 0x673d,
0x6c42, 0x6c72, 0x6ce3,
0x7078, 0x7403, 0x7a76,
0x7aae, 0x7b08, 0x7d1a,
0x7cfe, 0x7d66, 0x65e7,
0x725b, 0x53bb, 0x5c45,
0x5de8, 0x62d2, 0x62e0,
0x6319, 0x6e20, 0x865a,
0x8a31, 0x8ddd, 0x92f8,
0x6f01, 0x79a6, 0x9b5a,
0x4ea8, 0x4eab, 0x4eac,
0x4f9b, 0x4fa0, 0x50d1,
0x5147, 0x7af6, 0x5171,
0x51f6, 0x5354, 0x5321,
0x537f, 0x53eb, 0x55ac,
0x5883, 0x5ce1, 0x5f37,
0x5f4a, 0x602f, 0x6050,
0x606d, 0x631f, 0x6559,
0x6a4b, 0x6cc1, 0x72c2,
0x72ed, 0x77ef, 0x80f8,
0x8105, 0x8208, 0x854e,
0x90f7, 0x93e1, 0x97ff,
0x9957, 0x9a5a, 0x4ef0,
0x51dd, 0x5c2d, 0x6681,
0x696d, 0x5c40, 0x66f2,
0x6975, 0x7389, 0x6850,
0x7c81, 0x50c5, 0x52e4,
0x5747, 0x5dfe, 0x9326,
0x65a4, 0x6b23, 0x6b3d,
0x7434, 0x7981, 0x79bd,
0x7b4b, 0x7dca, 0x82b9,
0x83cc, 0x887f, 0x895f,
0x8b39, 0x8fd1, 0x91d1,
0x541f, 0x9280, 0x4e5d,
0x5036, 0x53e5, 0x533a,
0x72d7, 0x7396, 0x77e9,
0x82e6, 0x8eaf, 0x99c6,
0x99c8, 0x99d2, 0x5177,
0x611a, 0x865e, 0x55b0,
0x7a7a, 0x5076, 0x5bd3,
0x9047, 0x9685, 0x4e32,
0x6adb, 0x91e7, 0x5c51,
0x5c48, 0x6398, 0x7a9f,
0x6c93, 0x9774, 0x8f61,
0x7aaa, 0x718a, 0x9688,
0x7c82, 0x6817, 0x7e70,
0x6851, 0x936c, 0x52f2,
0x541b, 0x85ab, 0x8a13,
0x7fa4, 0x8ecd, 0x90e1,
0x5366, 0x8888, 0x7941,
0x4fc2, 0x50be, 0x5211,
0x5144, 0x5553, 0x572d,
0x73ea, 0x578b, 0x5951,
0x5f62, 0x5f84, 0x6075,
0x6176, 0x6167, 0x61a9,
0x63b2, 0x643a, 0x656c,
0x666f, 0x6842, 0x6e13,
0x7566, 0x7a3d, 0x7cfb,
0x7d4c, 0x7d99, 0x7e4b,
0x7f6b, 0x830e, 0x834a,
0x86cd, 0x8a08, 0x8a63,
0x8b66, 0x8efd, 0x981a,
0x9d8f, 0x82b8, 0x8fce,
0x9be8, 0x5287, 0x621f,
0x6483, 0x6fc0, 0x9699,
0x6841, 0x5091, 0x6b20,
0x6c7a, 0x6f54, 0x7a74,
0x7d50, 0x8840, 0x8a23,
0x6708, 0x4ef6, 0x5039,
0x5026, 0x5065, 0x517c,
0x5238, 0x5263, 0x55a7,
0x570f, 0x5805, 0x5acc,
0x5efa, 0x61b2, 0x61f8,
0x62f3, 0x6372, 0x691c,
0x6a29, 0x727d, 0x72ac,
0x732e, 0x7814, 0x786f,
0x7d79, 0x770c, 0x80a9,
0x898b, 0x8b19, 0x8ce2,
0x8ed2, 0x9063, 0x9375,
0x967a, 0x9855, 0x9a13,
0x9e78, 0x5143, 0x539f,
0x53b3, 0x5e7b, 0x5f26,
0x6e1b, 0x6e90, 0x7384,
0x73fe, 0x7d43, 0x8237,
0x8a00, 0x8afa, 0x9650,
0x4e4e, 0x500b, 0x53e4,
0x547c, 0x56fa, 0x59d1,
0x5b64, 0x5df1, 0x5eab,
0x5f27, 0x6238, 0x6545,
0x67af, 0x6e56, 0x72d0,
0x7cca, 0x88b4, 0x80a1,
0x80e1, 0x83f0, 0x864e,
0x8a87, 0x8de8, 0x9237,
0x96c7, 0x9867, 0x9f13,
0x4e94, 0x4e92, 0x4f0d,
0x5348, 0x5449, 0x543e,
0x5a2f, 0x5f8c, 0x5fa1,
0x609f, 0x68a7, 0x6a8e,
0x745a, 0x7881, 0x8a9e,
0x8aa4, 0x8b77, 0x9190,
0x4e5e, 0x9bc9, 0x4ea4,
0x4f7c, 0x4faf, 0x5019,
0x5016, 0x5149, 0x516c,
0x529f, 0x52b9, 0x52fe,
0x539a, 0x53e3, 0x5411,
0x540e, 0x5589, 0x5751,
0x57a2, 0x597d, 0x5b54,
0x5b5d, 0x5b8f, 0x5de5,
0x5de7, 0x5df7, 0x5e78,
0x5e83, 0x5e9a, 0x5eb7,
0x5f18, 0x6052, 0x614c,
0x6297, 0x62d8, 0x63a7,
0x653b, 0x6602, 0x6643,
0x66f4, 0x676d, 0x6821,
0x6897, 0x69cb, 0x6c5f,
0x6d2a, 0x6d69, 0x6e2f,
0x6e9d, 0x7532, 0x7687,
0x786c, 0x7a3f, 0x7ce0,
0x7d05, 0x7d18, 0x7d5e,
0x7db1, 0x8015, 0x8003,
0x80af, 0x80b1, 0x8154,
0x818f, 0x822a, 0x8352,
0x884c, 0x8861, 0x8b1b,
0x8ca2, 0x8cfc, 0x90ca,
0x9175, 0x9271, 0x783f,
0x92fc, 0x95a4, 0x964d,
0x9805, 0x9999, 0x9ad8,
0x9d3b, 0x525b, 0x52ab,
0x53f7, 0x5408, 0x58d5,
0x62f7, 0x6fe0, 0x8c6a,
0x8f5f, 0x9eb9, 0x514b,
0x523b, 0x544a, 0x56fd,
0x7a40, 0x9177, 0x9d60,
0x9ed2, 0x7344, 0x6f09,
0x8170, 0x7511, 0x5ffd,
0x60da, 0x9aa8, 0x72db,
0x8fbc, 0x6b64, 0x9803,
0x4eca, 0x56f0, 0x5764,
0x58be, 0x5a5a, 0x6068,
0x61c7, 0x660f, 0x6606,
0x6839, 0x68b1, 0x6df7,
0x75d5, 0x7d3a, 0x826e,
0x9b42, 0x4e9b, 0x4f50,
0x53c9, 0x5506, 0x5d6f,
0x5de6, 0x5dee, 0x67fb,
0x6c99, 0x7473, 0x7802,
0x8a50, 0x9396, 0x88df,
0x5750, 0x5ea7, 0x632b,
0x50b5, 0x50ac, 0x518d,
0x6700, 0x54c9, 0x585e,
0x59bb, 0x5bb0, 0x5f69,
0x624d, 0x63a1, 0x683d,
0x6b73, 0x6e08, 0x707d,
0x91c7, 0x7280, 0x7815,
0x7826, 0x796d, 0x658e,
0x7d30, 0x83dc, 0x88c1,
0x8f09, 0x969b, 0x5264,
0x5728, 0x6750, 0x7f6a,
0x8ca1, 0x51b4, 0x5742,
0x962a, 0x583a, 0x698a,
0x80b4, 0x54b2, 0x5d0e,
0x57fc, 0x7895, 0x9dfa,
0x4f5c, 0x524a, 0x548b,
0x643e, 0x6628, 0x6714,
0x67f5, 0x7a84, 0x7b56,
0x7d22, 0x932f, 0x685c,
0x9bad, 0x7b39, 0x5319,
0x518a, 0x5237, 0x5bdf,
0x62f6, 0x64ae, 0x64e6,
0x672d, 0x6bba, 0x85a9,
0x96d1, 0x7690, 0x9bd6,
0x634c, 0x9306, 0x9bab,
0x76bf, 0x6652, 0x4e09,
0x5098, 0x53c2, 0x5c71,
0x60e8, 0x6492, 0x6563,
0x685f, 0x71e6, 0x73ca,
0x7523, 0x7b97, 0x7e82,
0x8695, 0x8b83, 0x8cdb,
0x9178, 0x9910, 0x65ac,
0x66ab, 0x6b8b, 0x4ed5,
0x4ed4, 0x4f3a, 0x4f7f,
0x523a, 0x53f8, 0x53f2,
0x55e3, 0x56db, 0x58eb,
0x59cb, 0x59c9, 0x59ff,
0x5b50, 0x5c4d, 0x5e02,
0x5e2b, 0x5fd7, 0x601d,
0x6307, 0x652f, 0x5b5c,
0x65af, 0x65bd, 0x65e8,
0x679d, 0x6b62, 0x6b7b,
0x6c0f, 0x7345, 0x7949,
0x79c1, 0x7cf8, 0x7d19,
0x7d2b, 0x80a2, 0x8102,
0x81f3, 0x8996, 0x8a5e,
0x8a69, 0x8a66, 0x8a8c,
0x8aee, 0x8cc7, 0x8cdc,
0x96cc, 0x98fc, 0x6b6f,
0x4e8b, 0x4f3c, 0x4f8d,
0x5150, 0x5b57, 0x5bfa,
0x6148, 0x6301, 0x6642,
0x6b21, 0x6ecb, 0x6cbb,
0x723e, 0x74bd, 0x75d4,
0x78c1, 0x793a, 0x800c,
0x8033, 0x81ea, 0x8494,
0x8f9e, 0x6c50, 0x9e7f,
0x5f0f, 0x8b58, 0x9d2b,
0x7afa, 0x8ef8, 0x5b8d,
0x96eb, 0x4e03, 0x53f1,
0x57f7, 0x5931, 0x5ac9,
0x5ba4, 0x6089, 0x6e7f,
0x6f06, 0x75be, 0x8cea,
0x5b9f, 0x8500, 0x7be0,
0x5072, 0x67f4, 0x829d,
0x5c61, 0x854a, 0x7e1e,
0x820e, 0x5199, 0x5c04,
0x6368, 0x8d66, 0x659c,
0x716e, 0x793e, 0x7d17,
0x8005, 0x8b1d, 0x8eca,
0x906e, 0x86c7, 0x90aa,
0x501f, 0x52fa, 0x5c3a,
0x6753, 0x707c, 0x7235,
0x914c, 0x91c8, 0x932b,
0x82e5, 0x5bc2, 0x5f31,
0x60f9, 0x4e3b, 0x53d6,
0x5b88, 0x624b, 0x6731,
0x6b8a, 0x72e9, 0x73e0,
0x7a2e, 0x816b, 0x8da3,
0x9152, 0x9996, 0x5112,
0x53d7, 0x546a, 0x5bff,
0x6388, 0x6a39, 0x7dac,
0x9700, 0x56da, 0x53ce,
0x5468, 0x5b97, 0x5c31,
0x5dde, 0x4fee, 0x6101,
0x62fe, 0x6d32, 0x79c0,
0x79cb, 0x7d42, 0x7e4d,
0x7fd2, 0x81ed, 0x821f,
0x8490, 0x8846, 0x8972,
0x8b90, 0x8e74, 0x8f2f,
0x9031, 0x914b, 0x916c,
0x96c6, 0x919c, 0x4ec0,
0x4f4f, 0x5145, 0x5341,
0x5f93, 0x620e, 0x67d4,
0x6c41, 0x6e0b, 0x7363,
0x7e26, 0x91cd, 0x9283,
0x53d4, 0x5919, 0x5bbf,
0x6dd1, 0x795d, 0x7e2e,
0x7c9b, 0x587e, 0x719f,
0x51fa, 0x8853, 0x8ff0,
0x4fca, 0x5cfb, 0x6625,
0x77ac, 0x7ae3, 0x821c,
0x99ff, 0x51c6, 0x5faa,
0x65ec, 0x696f, 0x6b89,
0x6df3, 0x6e96, 0x6f64,
0x76fe, 0x7d14, 0x5de1,
0x9075, 0x9187, 0x9806,
0x51e6, 0x521d, 0x6240,
0x6691, 0x66d9, 0x6e1a,
0x5eb6, 0x7dd2, 0x7f72,
0x66f8, 0x85af, 0x85f7,
0x8af8, 0x52a9, 0x53d9,
0x5973, 0x5e8f, 0x5f90,
0x6055, 0x92e4, 0x9664,
0x50b7, 0x511f, 0x52dd,
0x5320, 0x5347, 0x53ec,
0x54e8, 0x5546, 0x5531,
0x5617, 0x5968, 0x59be,
0x5a3c, 0x5bb5, 0x5c06,
0x5c0f, 0x5c11, 0x5c1a,
0x5e84, 0x5e8a, 0x5ee0,
0x5f70, 0x627f, 0x6284,
0x62db, 0x638c, 0x6377,
0x6607, 0x660c, 0x662d,
0x6676, 0x677e, 0x68a2,
0x6a1f, 0x6a35, 0x6cbc,
0x6d88, 0x6e09, 0x6e58,
0x713c, 0x7126, 0x7167,
0x75c7, 0x7701, 0x785d,
0x7901, 0x7965, 0x79f0,
0x7ae0, 0x7b11, 0x7ca7,
0x7d39, 0x8096, 0x83d6,
0x848b, 0x8549, 0x885d,
0x88f3, 0x8a1f, 0x8a3c,
0x8a54, 0x8a73, 0x8c61,
0x8cde, 0x91a4, 0x9266,
0x937e, 0x9418, 0x969c,
0x9798, 0x4e0a, 0x4e08,
0x4e1e, 0x4e57, 0x5197,
0x5270, 0x57ce, 0x5834,
0x58cc, 0x5b22, 0x5e38,
0x60c5, 0x64fe, 0x6761,
0x6756, 0x6d44, 0x72b6,
0x7573, 0x7a63, 0x84b8,
0x8b72, 0x91b8, 0x9320,
0x5631, 0x57f4, 0x98fe,
0x62ed, 0x690d, 0x6b96,
0x71ed, 0x7e54, 0x8077,
0x8272, 0x89e6, 0x98df,
0x8755, 0x8fb1, 0x5c3b,
0x4f38, 0x4fe1, 0x4fb5,
0x5507, 0x5a20, 0x5bdd,
0x5be9, 0x5fc3, 0x614e,
0x632f, 0x65b0, 0x664b,
0x68ee, 0x699b, 0x6d78,
0x6df1, 0x7533, 0x75b9,
0x771f, 0x795e, 0x79e6,
0x7d33, 0x81e3, 0x82af,
0x85aa, 0x89aa, 0x8a3a,
0x8eab, 0x8f9b, 0x9032,
0x91dd, 0x9707, 0x4eba,
0x4ec1, 0x5203, 0x5875,
0x58ec, 0x5c0b, 0x751a,
0x5c3d, 0x814e, 0x8a0a,
0x8fc5, 0x9663, 0x976d,
0x7b25, 0x8acf, 0x9808,
0x9162, 0x56f3, 0x53a8,
0x9017, 0x5439, 0x5782,
0x5e25, 0x63a8, 0x6c34,
0x708a, 0x7761, 0x7c8b,
0x7fe0, 0x8870, 0x9042,
0x9154, 0x9310, 0x9318,
0x968f, 0x745e, 0x9ac4,
0x5d07, 0x5d69, 0x6570,
0x67a2, 0x8da8, 0x96db,
0x636e, 0x6749, 0x6919,
0x83c5, 0x9817, 0x96c0,
0x88fe, 0x6f84, 0x647a,
0x5bf8, 0x4e16, 0x702c,
0x755d, 0x662f, 0x51c4,
0x5236, 0x52e2, 0x59d3,
0x5f81, 0x6027, 0x6210,
0x653f, 0x6574, 0x661f,
0x6674, 0x68f2, 0x6816,
0x6b63, 0x6e05, 0x7272,
0x751f, 0x76db, 0x7cbe,
0x8056, 0x58f0, 0x88fd,
0x897f, 0x8aa0, 0x8a93,
0x8acb, 0x901d, 0x9192,
0x9752, 0x9759, 0x6589,
0x7a0e, 0x8106, 0x96bb,
0x5e2d, 0x60dc, 0x621a,
0x65a5, 0x6614, 0x6790,
0x77f3, 0x7a4d, 0x7c4d,
0x7e3e, 0x810a, 0x8cac,
0x8d64, 0x8de1, 0x8e5f,
0x78a9, 0x5207, 0x62d9,
0x63a5, 0x6442, 0x6298,
0x8a2d, 0x7a83, 0x7bc0,
0x8aac, 0x96ea, 0x7d76,
0x820c, 0x8749, 0x4ed9,
0x5148, 0x5343, 0x5360,
0x5ba3, 0x5c02, 0x5c16,
0x5ddd, 0x6226, 0x6247,
0x64b0, 0x6813, 0x6834,
0x6cc9, 0x6d45, 0x6d17,
0x67d3, 0x6f5c, 0x714e,
0x717d, 0x65cb, 0x7a7f,
0x7bad, 0x7dda, 0x7e4a,
0x7fa8, 0x817a, 0x821b,
0x8239, 0x85a6, 0x8a6e,
0x8cce, 0x8df5, 0x9078,
0x9077, 0x92ad, 0x9291,
0x9583, 0x9bae, 0x524d,
0x5584, 0x6f38, 0x7136,
0x5168, 0x7985, 0x7e55,
0x81b3, 0x7cce, 0x564c,
0x5851, 0x5ca8, 0x63aa,
0x66fe, 0x66fd, 0x695a,
0x72d9, 0x758f, 0x758e,
0x790e, 0x7956, 0x79df,
0x7c97, 0x7d20, 0x7d44,
0x8607, 0x8a34, 0x963b,
0x9061, 0x9f20, 0x50e7,
0x5275, 0x53cc, 0x53e2,
0x5009, 0x55aa, 0x58ee,
0x594f, 0x723d, 0x5b8b,
0x5c64, 0x531d, 0x60e3,
0x60f3, 0x635c, 0x6383,
0x633f, 0x63bb, 0x64cd,
0x65e9, 0x66f9, 0x5de3,
0x69cd, 0x69fd, 0x6f15,
0x71e5, 0x4e89, 0x75e9,
0x76f8, 0x7a93, 0x7cdf,
0x7dcf, 0x7d9c, 0x8061,
0x8349, 0x8358, 0x846c,
0x84bc, 0x85fb, 0x88c5,
0x8d70, 0x9001, 0x906d,
0x9397, 0x971c, 0x9a12,
0x50cf, 0x5897, 0x618e,
0x81d3, 0x8535, 0x8d08,
0x9020, 0x4fc3, 0x5074,
0x5247, 0x5373, 0x606f,
0x6349, 0x675f, 0x6e2c,
0x8db3, 0x901f, 0x4fd7,
0x5c5e, 0x8cca, 0x65cf,
0x7d9a, 0x5352, 0x8896,
0x5176, 0x63c3, 0x5b58,
0x5b6b, 0x5c0a, 0x640d,
0x6751, 0x905c, 0x4ed6,
0x591a, 0x592a, 0x6c70,
0x8a51, 0x553e, 0x5815,
0x59a5, 0x60f0, 0x6253,
0x67c1, 0x8235, 0x6955,
0x9640, 0x99c4, 0x9a28,
0x4f53, 0x5806, 0x5bfe,
0x8010, 0x5cb1, 0x5e2f,
0x5f85, 0x6020, 0x614b,
0x6234, 0x66ff, 0x6cf0,
0x6ede, 0x80ce, 0x817f,
0x82d4, 0x888b, 0x8cb8,
0x9000, 0x902e, 0x968a,
0x9edb, 0x9bdb, 0x4ee3,
0x53f0, 0x5927, 0x7b2c,
0x918d, 0x984c, 0x9df9,
0x6edd, 0x7027, 0x5353,
0x5544, 0x5b85, 0x6258,
0x629e, 0x62d3, 0x6ca2,
0x6fef, 0x7422, 0x8a17,
0x9438, 0x6fc1, 0x8afe,
0x8338, 0x51e7, 0x86f8,
0x53ea, 0x53e9, 0x4f46,
0x9054, 0x8fb0, 0x596a,
0x8131, 0x5dfd, 0x7aea,
0x8fbf, 0x68da, 0x8c37,
0x72f8, 0x9c48, 0x6a3d,
0x8ab0, 0x4e39, 0x5358,
0x5606, 0x5766, 0x62c5,
0x63a2, 0x65e6, 0x6b4e,
0x6de1, 0x6e5b, 0x70ad,
0x77ed, 0x7aef, 0x7baa,
0x7dbb, 0x803d, 0x80c6,
0x86cb, 0x8a95, 0x935b,
0x56e3, 0x58c7, 0x5f3e,
0x65ad, 0x6696, 0x6a80,
0x6bb5, 0x7537, 0x8ac7,
0x5024, 0x77e5, 0x5730,
0x5f1b, 0x6065, 0x667a,
0x6c60, 0x75f4, 0x7a1a,
0x7f6e, 0x81f4, 0x8718,
0x9045, 0x99b3, 0x7bc9,
0x755c, 0x7af9, 0x7b51,
0x84c4, 0x9010, 0x79e9,
0x7a92, 0x8336, 0x5ae1,
0x7740, 0x4e2d, 0x4ef2,
0x5b99, 0x5fe0, 0x62bd,
0x663c, 0x67f1, 0x6ce8,
0x866b, 0x8877, 0x8a3b,
0x914e, 0x92f3, 0x99d0,
0x6a17, 0x7026, 0x732a,
0x82e7, 0x8457, 0x8caf,
0x4e01, 0x5146, 0x51cb,
0x558b, 0x5bf5, 0x5e16,
0x5e33, 0x5e81, 0x5f14,
0x5f35, 0x5f6b, 0x5fb4,
0x61f2, 0x6311, 0x66a2,
0x671d, 0x6f6e, 0x7252,
0x753a, 0x773a, 0x8074,
0x8139, 0x8178, 0x8776,
0x8abf, 0x8adc, 0x8d85,
0x8df3, 0x929a, 0x9577,
0x9802, 0x9ce5, 0x52c5,
0x6357, 0x76f4, 0x6715,
0x6c88, 0x73cd, 0x8cc3,
0x93ae, 0x9673, 0x6d25,
0x589c, 0x690e, 0x69cc,
0x8ffd, 0x939a, 0x75db,
0x901a, 0x585a, 0x6802,
0x63b4, 0x69fb, 0x4f43,
0x6f2c, 0x67d8, 0x8fbb,
0x8526, 0x7db4, 0x9354,
0x693f, 0x6f70, 0x576a,
0x58f7, 0x5b2c, 0x7d2c,
0x722a, 0x540a, 0x91e3,
0x9db4, 0x4ead, 0x4f4e,
0x505c, 0x5075, 0x5243,
0x8c9e, 0x5448, 0x5824,
0x5b9a, 0x5e1d, 0x5e95,
0x5ead, 0x5ef7, 0x5f1f,
0x608c, 0x62b5, 0x633a,
0x63d0, 0x68af, 0x6c40,
0x7887, 0x798e, 0x7a0b,
0x7de0, 0x8247, 0x8a02,
0x8ae6, 0x8e44, 0x9013,
0x90b8, 0x912d, 0x91d8,
0x9f0e, 0x6ce5, 0x6458,
0x64e2, 0x6575, 0x6ef4,
0x7684, 0x7b1b, 0x9069,
0x93d1, 0x6eba, 0x54f2,
0x5fb9, 0x64a4, 0x8f4d,
0x8fed, 0x9244, 0x5178,
0x586b, 0x5929, 0x5c55,
0x5e97, 0x6dfb, 0x7e8f,
0x751c, 0x8cbc, 0x8ee2,
0x985b, 0x70b9, 0x4f1d,
0x6bbf, 0x6fb1, 0x7530,
0x96fb, 0x514e, 0x5410,
0x5835, 0x5857, 0x59ac,
0x5c60, 0x5f92, 0x6597,
0x675c, 0x6e21, 0x767b,
0x83df, 0x8ced, 0x9014,
0x90fd, 0x934d, 0x7825,
0x783a, 0x52aa, 0x5ea6,
0x571f, 0x5974, 0x6012,
0x5012, 0x515a, 0x51ac,
0x51cd, 0x5200, 0x5510,
0x5854, 0x5858, 0x5957,
0x5b95, 0x5cf6, 0x5d8b,
0x60bc, 0x6295, 0x642d,
0x6771, 0x6843, 0x68bc,
0x68df, 0x76d7, 0x6dd8,
0x6e6f, 0x6d9b, 0x706f,
0x71c8, 0x5f53, 0x75d8,
0x7977, 0x7b49, 0x7b54,
0x7b52, 0x7cd6, 0x7d71,
0x5230, 0x8463, 0x8569,
0x85e4, 0x8a0e, 0x8b04,
0x8c46, 0x8e0f, 0x9003,
0x900f, 0x9419, 0x9676,
0x982d, 0x9a30, 0x95d8,
0x50cd, 0x52d5, 0x540c,
0x5802, 0x5c0e, 0x61a7,
0x649e, 0x6d1e, 0x77b3,
0x7ae5, 0x80f4, 0x8404,
0x9053, 0x9285, 0x5ce0,
0x9d07, 0x533f, 0x5f97,
0x5fb3, 0x6d9c, 0x7279,
0x7763, 0x79bf, 0x7be4,
0x6bd2, 0x72ec, 0x8aad,
0x6803, 0x6a61, 0x51f8,
0x7a81, 0x6934, 0x5c4a,
0x9cf6, 0x82eb, 0x5bc5,
0x9149, 0x701e, 0x5678,
0x5c6f, 0x60c7, 0x6566,
0x6c8c, 0x8c5a, 0x9041,
0x9813, 0x5451, 0x66c7,
0x920d, 0x5948, 0x90a3,
0x5185, 0x4e4d, 0x51ea,
0x8599, 0x8b0e, 0x7058,
0x637a, 0x934b, 0x6962,
0x99b4, 0x7e04, 0x7577,
0x5357, 0x6960, 0x8edf,
0x96e3, 0x6c5d, 0x4e8c,
0x5c3c, 0x5f10, 0x8fe9,
0x5302, 0x8cd1, 0x8089,
0x8679, 0x5eff, 0x65e5,
0x4e73, 0x5165, 0x5982,
0x5c3f, 0x97ee, 0x4efb,
0x598a, 0x5fcd, 0x8a8d,
0x6fe1, 0x79b0, 0x7962,
0x5be7, 0x8471, 0x732b,
0x71b1, 0x5e74, 0x5ff5,
0x637b, 0x649a, 0x71c3,
0x7c98, 0x4e43, 0x5efc,
0x4e4b, 0x57dc, 0x56a2,
0x60a9, 0x6fc3, 0x7d0d,
0x80fd, 0x8133, 0x81bf,
0x8fb2, 0x8997, 0x86a4,
0x5df4, 0x628a, 0x64ad,
0x8987, 0x6777, 0x6ce2,
0x6d3e, 0x7436, 0x7834,
0x5a46, 0x7f75, 0x82ad,
0x99ac, 0x4ff3, 0x5ec3,
0x62dd, 0x6392, 0x6557,
0x676f, 0x76c3, 0x724c,
0x80cc, 0x80ba, 0x8f29,
0x914d, 0x500d, 0x57f9,
0x5a92, 0x6885, 0x6973,
0x7164, 0x72fd, 0x8cb7,
0x58f2, 0x8ce0, 0x966a,
0x9019, 0x877f, 0x79e4,
0x77e7, 0x8429, 0x4f2f,
0x5265, 0x535a, 0x62cd,
0x67cf, 0x6cca, 0x767d,
0x7b94, 0x7c95, 0x8236,
0x8584, 0x8feb, 0x66dd,
0x6f20, 0x7206, 0x7e1b,
0x83ab, 0x99c1, 0x9ea6,
0x51fd, 0x7bb1, 0x7872,
0x7bb8, 0x8087, 0x7b48,
0x6ae8, 0x5e61, 0x808c,
0x7551, 0x7560, 0x516b,
0x9262, 0x6e8c, 0x767a,
0x9197, 0x9aea, 0x4f10,
0x7f70, 0x629c, 0x7b4f,
0x95a5, 0x9ce9, 0x567a,
0x5859, 0x86e4, 0x96bc,
0x4f34, 0x5224, 0x534a,
0x53cd, 0x53db, 0x5e06,
0x642c, 0x6591, 0x677f,
0x6c3e, 0x6c4e, 0x7248,
0x72af, 0x73ed, 0x7554,
0x7e41, 0x822c, 0x85e9,
0x8ca9, 0x7bc4, 0x91c6,
0x7169, 0x9812, 0x98ef,
0x633d, 0x6669, 0x756a,
0x76e4, 0x78d0, 0x8543,
0x86ee, 0x532a, 0x5351,
0x5426, 0x5983, 0x5e87,
0x5f7c, 0x60b2, 0x6249,
0x6279, 0x62ab, 0x6590,
0x6bd4, 0x6ccc, 0x75b2,
0x76ae, 0x7891, 0x79d8,
0x7dcb, 0x7f77, 0x80a5,
0x88ab, 0x8ab9, 0x8cbb,
0x907f, 0x975e, 0x98db,
0x6a0b, 0x7c38, 0x5099,
0x5c3e, 0x5fae, 0x6787,
0x6bd8, 0x7435, 0x7709,
0x7f8e, 0x9f3b, 0x67ca,
0x7a17, 0x5339, 0x758b,
0x9aed, 0x5f66, 0x819d,
0x83f1, 0x8098, 0x5f3c,
0x5fc5, 0x7562, 0x7b46,
0x903c, 0x6867, 0x59eb,
0x5a9b, 0x7d10, 0x767e,
0x8b2c, 0x4ff5, 0x5f6a,
0x6a19, 0x6c37, 0x6f02,
0x74e2, 0x7968, 0x8868,
0x8a55, 0x8c79, 0x5edf,
0x63cf, 0x75c5, 0x79d2,
0x82d7, 0x9328, 0x92f2,
0x849c, 0x86ed, 0x9c2d,
0x54c1, 0x5f6c, 0x658c,
0x6d5c, 0x7015, 0x8ca7,
0x8cd3, 0x983b, 0x654f,
0x74f6, 0x4e0d, 0x4ed8,
0x57e0, 0x592b, 0x5a66,
0x5bcc, 0x51a8, 0x5e03,
0x5e9c, 0x6016, 0x6276,
0x6577, 0x65a7, 0x666e,
0x6d6e, 0x7236, 0x7b26,
0x8150, 0x819a, 0x8299,
0x8b5c, 0x8ca0, 0x8ce6,
0x8d74, 0x961c, 0x9644,
0x4fae, 0x64ab, 0x6b66,
0x821e, 0x8461, 0x856a,
0x90e8, 0x5c01, 0x6953,
0x98a8, 0x847a, 0x8557,
0x4f0f, 0x526f, 0x5fa9,
0x5e45, 0x670d, 0x798f,
0x8179, 0x8907, 0x8986,
0x6df5, 0x5f17, 0x6255,
0x6cb8, 0x4ecf, 0x7269,
0x9b92, 0x5206, 0x543b,
0x5674, 0x58b3, 0x61a4,
0x626e, 0x711a, 0x596e,
0x7c89, 0x7cde, 0x7d1b,
0x96f0, 0x6587, 0x805e,
0x4e19, 0x4f75, 0x5175,
0x5840, 0x5e63, 0x5e73,
0x5f0a, 0x67c4, 0x4e26,
0x853d, 0x9589, 0x965b,
0x7c73, 0x9801, 0x50fb,
0x58c1, 0x7656, 0x78a7,
0x5225, 0x77a5, 0x8511,
0x7b86, 0x504f, 0x5909,
0x7247, 0x7bc7, 0x7de8,
0x8fba, 0x8fd4, 0x904d,
0x4fbf, 0x52c9, 0x5a29,
0x5f01, 0x97ad, 0x4fdd,
0x8217, 0x92ea, 0x5703,
0x6355, 0x6b69, 0x752b,
0x88dc, 0x8f14, 0x7a42,
0x52df, 0x5893, 0x6155,
0x620a, 0x66ae, 0x6bcd,
0x7c3f, 0x83e9, 0x5023,
0x4ff8, 0x5305, 0x5446,
0x5831, 0x5949, 0x5b9d,
0x5cf0, 0x5cef, 0x5d29,
0x5e96, 0x62b1, 0x6367,
0x653e, 0x65b9, 0x670b,
0x6cd5, 0x6ce1, 0x70f9,
0x7832, 0x7e2b, 0x80de,
0x82b3, 0x840c, 0x84ec,
0x8702, 0x8912, 0x8a2a,
0x8c4a, 0x90a6, 0x92d2,
0x98fd, 0x9cf3, 0x9d6c,
0x4e4f, 0x4ea1, 0x508d,
0x5256, 0x574a, 0x59a8,
0x5e3d, 0x5fd8, 0x5fd9,
0x623f, 0x66b4, 0x671b,
0x67d0, 0x68d2, 0x5192,
0x7d21, 0x80aa, 0x81a8,
0x8b00, 0x8c8c, 0x8cbf,
0x927e, 0x9632, 0x5420,
0x982c, 0x5317, 0x50d5,
0x535c, 0x58a8, 0x64b2,
0x6734, 0x7267, 0x7766,
0x7a46, 0x91e6, 0x52c3,
0x6ca1, 0x6b86, 0x5800,
0x5e4c, 0x5954, 0x672c,
0x7ffb, 0x51e1, 0x76c6,
0x6469, 0x78e8, 0x9b54,
0x9ebb, 0x57cb, 0x59b9,
0x6627, 0x679a, 0x6bce,
0x54e9, 0x69d9, 0x5e55,
0x819c, 0x6795, 0x9baa,
0x67fe, 0x9c52, 0x685d,
0x4ea6, 0x4fe3, 0x53c8,
0x62b9, 0x672b, 0x6cab,
0x8fc4, 0x4fad, 0x7e6d,
0x9ebf, 0x4e07, 0x6162,
0x6e80, 0x6f2b, 0x8513,
0x5473, 0x672a, 0x9b45,
0x5df3, 0x7b95, 0x5cac,
0x5bc6, 0x871c, 0x6e4a,
0x84d1, 0x7a14, 0x8108,
0x5999, 0x7c8d, 0x6c11,
0x7720, 0x52d9, 0x5922,
0x7121, 0x725f, 0x77db,
0x9727, 0x9d61, 0x690b,
0x5a7f, 0x5a18, 0x51a5,
0x540d, 0x547d, 0x660e,
0x76df, 0x8ff7, 0x9298,
0x9cf4, 0x59ea, 0x725d,
0x6ec5, 0x514d, 0x68c9,
0x7dbf, 0x7dec, 0x9762,
0x9eba, 0x6478, 0x6a21,
0x8302, 0x5984, 0x5b5f,
0x6bdb, 0x731b, 0x76f2,
0x7db2, 0x8017, 0x8499,
0x5132, 0x6728, 0x9ed9,
0x76ee, 0x6762, 0x52ff,
0x9905, 0x5c24, 0x623b,
0x7c7e, 0x8cb0, 0x554f,
0x60b6, 0x7d0b, 0x9580,
0x5301, 0x4e5f, 0x51b6,
0x591c, 0x723a, 0x8036,
0x91ce, 0x5f25, 0x77e2,
0x5384, 0x5f79, 0x7d04,
0x85ac, 0x8a33, 0x8e8d,
0x9756, 0x67f3, 0x85ae,
0x9453, 0x6109, 0x6108,
0x6cb9, 0x7652, 0x8aed,
0x8f38, 0x552f, 0x4f51,
0x512a, 0x52c7, 0x53cb,
0x5ba5, 0x5e7d, 0x60a0,
0x6182, 0x63d6, 0x6709,
0x67da, 0x6e67, 0x6d8c,
0x7336, 0x7337, 0x7531,
0x7950, 0x88d5, 0x8a98,
0x904a, 0x9091, 0x90f5,
0x96c4, 0x878d, 0x5915,
0x4e88, 0x4f59, 0x4e0e,
0x8a89, 0x8f3f, 0x9810,
0x50ad, 0x5e7c, 0x5996,
0x5bb9, 0x5eb8, 0x63da,
0x63fa, 0x64c1, 0x66dc,
0x694a, 0x69d8, 0x6d0b,
0x6eb6, 0x7194, 0x7528,
0x7aaf, 0x7f8a, 0x8000,
0x8449, 0x84c9, 0x8981,
0x8b21, 0x8e0a, 0x9065,
0x967d, 0x990a, 0x617e,
0x6291, 0x6b32, 0x6c83,
0x6d74, 0x7fcc, 0x7ffc,
0x6dc0, 0x7f85, 0x87ba,
0x88f8, 0x6765, 0x83b1,
0x983c, 0x96f7, 0x6d1b,
0x7d61, 0x843d, 0x916a,
0x4e71, 0x5375, 0x5d50,
0x6b04, 0x6feb, 0x85cd,
0x862d, 0x89a7, 0x5229,
0x540f, 0x5c65, 0x674e,
0x68a8, 0x7406, 0x7483,
0x75e2, 0x88cf, 0x88e1,
0x91cc, 0x96e2, 0x9678,
0x5f8b, 0x7387, 0x7acb,
0x844e, 0x63a0, 0x7565,
0x5289, 0x6d41, 0x6e9c,
0x7409, 0x7559, 0x786b,
0x7c92, 0x9686, 0x7adc,
0x9f8d, 0x4fb6, 0x616e,
0x65c5, 0x865c, 0x4e86,
0x4eae, 0x50da, 0x4e21,
0x51cc, 0x5bee, 0x6599,
0x6881, 0x6dbc, 0x731f,
0x7642, 0x77ad, 0x7a1c,
0x7ce7, 0x826f, 0x8ad2,
0x907c, 0x91cf, 0x9675,
0x9818, 0x529b, 0x7dd1,
0x502b, 0x5398, 0x6797,
0x6dcb, 0x71d0, 0x7433,
0x81e8, 0x8f2a, 0x96a3,
0x9c57, 0x9e9f, 0x7460,
0x5841, 0x6d99, 0x7d2f,
0x985e, 0x4ee4, 0x4f36,
0x4f8b, 0x51b7, 0x52b1,
0x5dba, 0x601c, 0x73b2,
0x793c, 0x82d3, 0x9234,
0x96b7, 0x96f6, 0x970a,
0x9e97, 0x9f62, 0x66a6,
0x6b74, 0x5217, 0x52a3,
0x70c8, 0x88c2, 0x5ec9,
0x604b, 0x6190, 0x6f23,
0x7149, 0x7c3e, 0x7df4,
0x806f, 0x84ee, 0x9023,
0x932c, 0x5442, 0x9b6f,
0x6ad3, 0x7089, 0x8cc2,
0x8def, 0x9732, 0x52b4,
0x5a41, 0x5eca, 0x5f04,
0x6717, 0x697c, 0x6994,
0x6d6a, 0x6f0f, 0x7262,
0x72fc, 0x7bed, 0x8001,
0x807e, 0x874b, 0x90ce,
0x516d, 0x9e93, 0x7984,
0x808b, 0x9332, 0x8ad6,
0x502d, 0x548c, 0x8a71,
0x6b6a, 0x8cc4, 0x8107,
0x60d1, 0x67a0, 0x9df2,
0x4e99, 0x4e98, 0x9c10,
0x8a6b, 0x85c1, 0x8568,
0x6900, 0x6e7e, 0x7897,
0x8155, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x5f0c,
0x4e10, 0x4e15, 0x4e2a,
0x4e31, 0x4e36, 0x4e3c,
0x4e3f, 0x4e42, 0x4e56,
0x4e58, 0x4e82, 0x4e85,
0x8c6b, 0x4e8a, 0x8212,
0x5f0d, 0x4e8e, 0x4e9e,
0x4e9f, 0x4ea0, 0x4ea2,
0x4eb0, 0x4eb3, 0x4eb6,
0x4ece, 0x4ecd, 0x4ec4,
0x4ec6, 0x4ec2, 0x4ed7,
0x4ede, 0x4eed, 0x4edf,
0x4ef7, 0x4f09, 0x4f5a,
0x4f30, 0x4f5b, 0x4f5d,
0x4f57, 0x4f47, 0x4f76,
0x4f88, 0x4f8f, 0x4f98,
0x4f7b, 0x4f69, 0x4f70,
0x4f91, 0x4f6f, 0x4f86,
0x4f96, 0x5118, 0x4fd4,
0x4fdf, 0x4fce, 0x4fd8,
0x4fdb, 0x4fd1, 0x4fda,
0x4fd0, 0x4fe4, 0x4fe5,
0x501a, 0x5028, 0x5014,
0x502a, 0x5025, 0x5005,
0x4f1c, 0x4ff6, 0x5021,
0x5029, 0x502c, 0x4ffe,
0x4fef, 0x5011, 0x5006,
0x5043, 0x5047, 0x6703,
0x5055, 0x5050, 0x5048,
0x505a, 0x5056, 0x506c,
0x5078, 0x5080, 0x509a,
0x5085, 0x50b4, 0x50b2,
0x50c9, 0x50ca, 0x50b3,
0x50c2, 0x50d6, 0x50de,
0x50e5, 0x50ed, 0x50e3,
0x50ee, 0x50f9, 0x50f5,
0x5109, 0x5101, 0x5102,
0x5116, 0x5115, 0x5114,
0x511a, 0x5121, 0x513a,
0x5137, 0x513c, 0x513b,
0x513f, 0x5140, 0x5152,
0x514c, 0x5154, 0x5162,
0x7af8, 0x5169, 0x516a,
0x516e, 0x5180, 0x5182,
0x56d8, 0x518c, 0x5189,
0x518f, 0x5191, 0x5193,
0x5195, 0x5196, 0x51a4,
0x51a6, 0x51a2, 0x51a9,
0x51aa, 0x51ab, 0x51b3,
0x51b1, 0x51b2, 0x51b0,
0x51b5, 0x51bd, 0x51c5,
0x51c9, 0x51db, 0x51e0,
0x8655, 0x51e9, 0x51ed,
0x51f0, 0x51f5, 0x51fe,
0x5204, 0x520b, 0x5214,
0x520e, 0x5227, 0x522a,
0x522e, 0x5233, 0x5239,
0x524f, 0x5244, 0x524b,
0x524c, 0x525e, 0x5254,
0x526a, 0x5274, 0x5269,
0x5273, 0x527f, 0x527d,
0x528d, 0x5294, 0x5292,
0x5271, 0x5288, 0x5291,
0x8fa8, 0x8fa7, 0x52ac,
0x52ad, 0x52bc, 0x52b5,
0x52c1, 0x52cd, 0x52d7,
0x52de, 0x52e3, 0x52e6,
0x98ed, 0x52e0, 0x52f3,
0x52f5, 0x52f8, 0x52f9,
0x5306, 0x5308, 0x7538,
0x530d, 0x5310, 0x530f,
0x5315, 0x531a, 0x5323,
0x532f, 0x5331, 0x5333,
0x5338, 0x5340, 0x5346,
0x5345, 0x4e17, 0x5349,
0x534d, 0x51d6, 0x535e,
0x5369, 0x536e, 0x5918,
0x537b, 0x5377, 0x5382,
0x5396, 0x53a0, 0x53a6,
0x53a5, 0x53ae, 0x53b0,
0x53b6, 0x53c3, 0x7c12,
0x96d9, 0x53df, 0x66fc,
0x71ee, 0x53ee, 0x53e8,
0x53ed, 0x53fa, 0x5401,
0x543d, 0x5440, 0x542c,
0x542d, 0x543c, 0x542e,
0x5436, 0x5429, 0x541d,
0x544e, 0x548f, 0x5475,
0x548e, 0x545f, 0x5471,
0x5477, 0x5470, 0x5492,
0x547b, 0x5480, 0x5476,
0x5484, 0x5490, 0x5486,
0x54c7, 0x54a2, 0x54b8,
0x54a5, 0x54ac, 0x54c4,
0x54c8, 0x54a8, 0x54ab,
0x54c2, 0x54a4, 0x54be,
0x54bc, 0x54d8, 0x54e5,
0x54e6, 0x550f, 0x5514,
0x54fd, 0x54ee, 0x54ed,
0x54fa, 0x54e2, 0x5539,
0x5540, 0x5563, 0x554c,
0x552e, 0x555c, 0x5545,
0x5556, 0x5557, 0x5538,
0x5533, 0x555d, 0x5599,
0x5580, 0x54af, 0x558a,
0x559f, 0x557b, 0x557e,
0x5598, 0x559e, 0x55ae,
0x557c, 0x5583, 0x55a9,
0x5587, 0x55a8, 0x55da,
0x55c5, 0x55df, 0x55c4,
0x55dc, 0x55e4, 0x55d4,
0x5614, 0x55f7, 0x5616,
0x55fe, 0x55fd, 0x561b,
0x55f9, 0x564e, 0x5650,
0x71df, 0x5634, 0x5636,
0x5632, 0x5638, 0x566b,
0x5664, 0x562f, 0x566c,
0x566a, 0x5686, 0x5680,
0x568a, 0x56a0, 0x5694,
0x568f, 0x56a5, 0x56ae,
0x56b6, 0x56b4, 0x56c2,
0x56bc, 0x56c1, 0x56c3,
0x56c0, 0x56c8, 0x56ce,
0x56d1, 0x56d3, 0x56d7,
0x56ee, 0x56f9, 0x5700,
0x56ff, 0x5704, 0x5709,
0x5708, 0x570b, 0x570d,
0x5713, 0x5718, 0x5716,
0x55c7, 0x571c, 0x5726,
0x5737, 0x5738, 0x574e,
0x573b, 0x5740, 0x574f,
0x5769, 0x57c0, 0x5788,
0x5761, 0x577f, 0x5789,
0x5793, 0x57a0, 0x57b3,
0x57a4, 0x57aa, 0x57b0,
0x57c3, 0x57c6, 0x57d4,
0x57d2, 0x57d3, 0x580a,
0x57d6, 0x57e3, 0x580b,
0x5819, 0x581d, 0x5872,
0x5821, 0x5862, 0x584b,
0x5870, 0x6bc0, 0x5852,
0x583d, 0x5879, 0x5885,
0x58b9, 0x589f, 0x58ab,
0x58ba, 0x58de, 0x58bb,
0x58b8, 0x58ae, 0x58c5,
0x58d3, 0x58d1, 0x58d7,
0x58d9, 0x58d8, 0x58e5,
0x58dc, 0x58e4, 0x58df,
0x58ef, 0x58fa, 0x58f9,
0x58fb, 0x58fc, 0x58fd,
0x5902, 0x590a, 0x5910,
0x591b, 0x68a6, 0x5925,
0x592c, 0x592d, 0x5932,
0x5938, 0x593e, 0x7ad2,
0x5955, 0x5950, 0x594e,
0x595a, 0x5958, 0x5962,
0x5960, 0x5967, 0x596c,
0x5969, 0x5978, 0x5981,
0x599d, 0x4f5e, 0x4fab,
0x59a3, 0x59b2, 0x59c6,
0x59e8, 0x59dc, 0x598d,
0x59d9, 0x59da, 0x5a25,
0x5a1f, 0x5a11, 0x5a1c,
0x5a09, 0x5a1a, 0x5a40,
0x5a6c, 0x5a49, 0x5a35,
0x5a36, 0x5a62, 0x5a6a,
0x5a9a, 0x5abc, 0x5abe,
0x5acb, 0x5ac2, 0x5abd,
0x5ae3, 0x5ad7, 0x5ae6,
0x5ae9, 0x5ad6, 0x5afa,
0x5afb, 0x5b0c, 0x5b0b,
0x5b16, 0x5b32, 0x5ad0,
0x5b2a, 0x5b36, 0x5b3e,
0x5b43, 0x5b45, 0x5b40,
0x5b51, 0x5b55, 0x5b5a,
0x5b5b, 0x5b65, 0x5b69,
0x5b70, 0x5b73, 0x5b75,
0x5b78, 0x6588, 0x5b7a,
0x5b80, 0x5b83, 0x5ba6,
0x5bb8, 0x5bc3, 0x5bc7,
0x5bc9, 0x5bd4, 0x5bd0,
0x5be4, 0x5be6, 0x5be2,
0x5bde, 0x5be5, 0x5beb,
0x5bf0, 0x5bf6, 0x5bf3,
0x5c05, 0x5c07, 0x5c08,
0x5c0d, 0x5c13, 0x5c20,
0x5c22, 0x5c28, 0x5c38,
0x5c39, 0x5c41, 0x5c46,
0x5c4e, 0x5c53, 0x5c50,
0x5c4f, 0x5b71, 0x5c6c,
0x5c6e, 0x4e62, 0x5c76,
0x5c79, 0x5c8c, 0x5c91,
0x5c94, 0x599b, 0x5cab,
0x5cbb, 0x5cb6, 0x5cbc,
0x5cb7, 0x5cc5, 0x5cbe,
0x5cc7, 0x5cd9, 0x5ce9,
0x5cfd, 0x5cfa, 0x5ced,
0x5d8c, 0x5cea, 0x5d0b,
0x5d15, 0x5d17, 0x5d5c,
0x5d1f, 0x5d1b, 0x5d11,
0x5d14, 0x5d22, 0x5d1a,
0x5d19, 0x5d18, 0x5d4c,
0x5d52, 0x5d4e, 0x5d4b,
0x5d6c, 0x5d73, 0x5d76,
0x5d87, 0x5d84, 0x5d82,
0x5da2, 0x5d9d, 0x5dac,
0x5dae, 0x5dbd, 0x5d90,
0x5db7, 0x5dbc, 0x5dc9,
0x5dcd, 0x5dd3, 0x5dd2,
0x5dd6, 0x5ddb, 0x5deb,
0x5df2, 0x5df5, 0x5e0b,
0x5e1a, 0x5e19, 0x5e11,
0x5e1b, 0x5e36, 0x5e37,
0x5e44, 0x5e43, 0x5e40,
0x5e4e, 0x5e57, 0x5e54,
0x5e5f, 0x5e62, 0x5e64,
0x5e47, 0x5e75, 0x5e76,
0x5e7a, 0x9ebc, 0x5e7f,
0x5ea0, 0x5ec1, 0x5ec2,
0x5ec8, 0x5ed0, 0x5ecf,
0x5ed6, 0x5ee3, 0x5edd,
0x5eda, 0x5edb, 0x5ee2,
0x5ee1, 0x5ee8, 0x5ee9,
0x5eec, 0x5ef1, 0x5ef3,
0x5ef0, 0x5ef4, 0x5ef8,
0x5efe, 0x5f03, 0x5f09,
0x5f5d, 0x5f5c, 0x5f0b,
0x5f11, 0x5f16, 0x5f29,
0x5f2d, 0x5f38, 0x5f41,
0x5f48, 0x5f4c, 0x5f4e,
0x5f2f, 0x5f51, 0x5f56,
0x5f57, 0x5f59, 0x5f61,
0x5f6d, 0x5f73, 0x5f77,
0x5f83, 0x5f82, 0x5f7f,
0x5f8a, 0x5f88, 0x5f91,
0x5f87, 0x5f9e, 0x5f99,
0x5f98, 0x5fa0, 0x5fa8,
0x5fad, 0x5fbc, 0x5fd6,
0x5ffb, 0x5fe4, 0x5ff8,
0x5ff1, 0x5fdd, 0x60b3,
0x5fff, 0x6021, 0x6060,
0x6019, 0x6010, 0x6029,
0x600e, 0x6031, 0x601b,
0x6015, 0x602b, 0x6026,
0x600f, 0x603a, 0x605a,
0x6041, 0x606a, 0x6077,
0x605f, 0x604a, 0x6046,
0x604d, 0x6063, 0x6043,
0x6064, 0x6042, 0x606c,
0x606b, 0x6059, 0x6081,
0x608d, 0x60e7, 0x6083,
0x609a, 0x6084, 0x609b,
0x6096, 0x6097, 0x6092,
0x60a7, 0x608b, 0x60e1,
0x60b8, 0x60e0, 0x60d3,
0x60b4, 0x5ff0, 0x60bd,
0x60c6, 0x60b5, 0x60d8,
0x614d, 0x6115, 0x6106,
0x60f6, 0x60f7, 0x6100,
0x60f4, 0x60fa, 0x6103,
0x6121, 0x60fb, 0x60f1,
0x610d, 0x610e, 0x6147,
0x613e, 0x6128, 0x6127,
0x614a, 0x613f, 0x613c,
0x612c, 0x6134, 0x613d,
0x6142, 0x6144, 0x6173,
0x6177, 0x6158, 0x6159,
0x615a, 0x616b, 0x6174,
0x616f, 0x6165, 0x6171,
0x615f, 0x615d, 0x6153,
0x6175, 0x6199, 0x6196,
0x6187, 0x61ac, 0x6194,
0x619a, 0x618a, 0x6191,
0x61ab, 0x61ae, 0x61cc,
0x61ca, 0x61c9, 0x61f7,
0x61c8, 0x61c3, 0x61c6,
0x61ba, 0x61cb, 0x7f79,
0x61cd, 0x61e6, 0x61e3,
0x61f6, 0x61fa, 0x61f4,
0x61ff, 0x61fd, 0x61fc,
0x61fe, 0x6200, 0x6208,
0x6209, 0x620d, 0x620c,
0x6214, 0x621b, 0x621e,
0x6221, 0x622a, 0x622e,
0x6230, 0x6232, 0x6233,
0x6241, 0x624e, 0x625e,
0x6263, 0x625b, 0x6260,
0x6268, 0x627c, 0x6282,
0x6289, 0x627e, 0x6292,
0x6293, 0x6296, 0x62d4,
0x6283, 0x6294, 0x62d7,
0x62d1, 0x62bb, 0x62cf,
0x62ff, 0x62c6, 0x64d4,
0x62c8, 0x62dc, 0x62cc,
0x62ca, 0x62c2, 0x62c7,
0x629b, 0x62c9, 0x630c,
0x62ee, 0x62f1, 0x6327,
0x6302, 0x6308, 0x62ef,
0x62f5, 0x6350, 0x633e,
0x634d, 0x641c, 0x634f,
0x6396, 0x638e, 0x6380,
0x63ab, 0x6376, 0x63a3,
0x638f, 0x6389, 0x639f,
0x63b5, 0x636b, 0x6369,
0x63be, 0x63e9, 0x63c0,
0x63c6, 0x63e3, 0x63c9,
0x63d2, 0x63f6, 0x63c4,
0x6416, 0x6434, 0x6406,
0x6413, 0x6426, 0x6436,
0x651d, 0x6417, 0x6428,
0x640f, 0x6467, 0x646f,
0x6476, 0x644e, 0x652a,
0x6495, 0x6493, 0x64a5,
0x64a9, 0x6488, 0x64bc,
0x64da, 0x64d2, 0x64c5,
0x64c7, 0x64bb, 0x64d8,
0x64c2, 0x64f1, 0x64e7,
0x8209, 0x64e0, 0x64e1,
0x62ac, 0x64e3, 0x64ef,
0x652c, 0x64f6, 0x64f4,
0x64f2, 0x64fa, 0x6500,
0x64fd, 0x6518, 0x651c,
0x6505, 0x6524, 0x6523,
0x652b, 0x6534, 0x6535,
0x6537, 0x6536, 0x6538,
0x754b, 0x6548, 0x6556,
0x6555, 0x654d, 0x6558,
0x655e, 0x655d, 0x6572,
0x6578, 0x6582, 0x6583,
0x8b8a, 0x659b, 0x659f,
0x65ab, 0x65b7, 0x65c3,
0x65c6, 0x65c1, 0x65c4,
0x65cc, 0x65d2, 0x65db,
0x65d9, 0x65e0, 0x65e1,
0x65f1, 0x6772, 0x660a,
0x6603, 0x65fb, 0x6773,
0x6635, 0x6636, 0x6634,
0x661c, 0x664f, 0x6644,
0x6649, 0x6641, 0x665e,
0x665d, 0x6664, 0x6667,
0x6668, 0x665f, 0x6662,
0x6670, 0x6683, 0x6688,
0x668e, 0x6689, 0x6684,
0x6698, 0x669d, 0x66c1,
0x66b9, 0x66c9, 0x66be,
0x66bc, 0x66c4, 0x66b8,
0x66d6, 0x66da, 0x66e0,
0x663f, 0x66e6, 0x66e9,
0x66f0, 0x66f5, 0x66f7,
0x670f, 0x6716, 0x671e,
0x6726, 0x6727, 0x9738,
0x672e, 0x673f, 0x6736,
0x6741, 0x6738, 0x6737,
0x6746, 0x675e, 0x6760,
0x6759, 0x6763, 0x6764,
0x6789, 0x6770, 0x67a9,
0x677c, 0x676a, 0x678c,
0x678b, 0x67a6, 0x67a1,
0x6785, 0x67b7, 0x67ef,
0x67b4, 0x67ec, 0x67b3,
0x67e9, 0x67b8, 0x67e4,
0x67de, 0x67dd, 0x67e2,
0x67ee, 0x67b9, 0x67ce,
0x67c6, 0x67e7, 0x6a9c,
0x681e, 0x6846, 0x6829,
0x6840, 0x684d, 0x6832,
0x684e, 0x68b3, 0x682b,
0x6859, 0x6863, 0x6877,
0x687f, 0x689f, 0x688f,
0x68ad, 0x6894, 0x689d,
0x689b, 0x6883, 0x6aae,
0x68b9, 0x6874, 0x68b5,
0x68a0, 0x68ba, 0x690f,
0x688d, 0x687e, 0x6901,
0x68ca, 0x6908, 0x68d8,
0x6922, 0x6926, 0x68e1,
0x690c, 0x68cd, 0x68d4,
0x68e7, 0x68d5, 0x6936,
0x6912, 0x6904, 0x68d7,
0x68e3, 0x6925, 0x68f9,
0x68e0, 0x68ef, 0x6928,
0x692a, 0x691a, 0x6923,
0x6921, 0x68c6, 0x6979,
0x6977, 0x695c, 0x6978,
0x696b, 0x6954, 0x697e,
0x696e, 0x6939, 0x6974,
0x693d, 0x6959, 0x6930,
0x6961, 0x695e, 0x695d,
0x6981, 0x696a, 0x69b2,
0x69ae, 0x69d0, 0x69bf,
0x69c1, 0x69d3, 0x69be,
0x69ce, 0x5be8, 0x69ca,
0x69dd, 0x69bb, 0x69c3,
0x69a7, 0x6a2e, 0x6991,
0x69a0, 0x699c, 0x6995,
0x69b4, 0x69de, 0x69e8,
0x6a02, 0x6a1b, 0x69ff,
0x6b0a, 0x69f9, 0x69f2,
0x69e7, 0x6a05, 0x69b1,
0x6a1e, 0x69ed, 0x6a14,
0x69eb, 0x6a0a, 0x6a12,
0x6ac1, 0x6a23, 0x6a13,
0x6a44, 0x6a0c, 0x6a72,
0x6a36, 0x6a78, 0x6a47,
0x6a62, 0x6a59, 0x6a66,
0x6a48, 0x6a38, 0x6a22,
0x6a90, 0x6a8d, 0x6aa0,
0x6a84, 0x6aa2, 0x6aa3,
0x6a97, 0x8617, 0x6abb,
0x6ac3, 0x6ac2, 0x6ab8,
0x6ab3, 0x6aac, 0x6ade,
0x6ad1, 0x6adf, 0x6aaa,
0x6ada, 0x6aea, 0x6afb,
0x6b05, 0x8616, 0x6afa,
0x6b12, 0x6b16, 0x9b31,
0x6b1f, 0x6b38, 0x6b37,
0x76dc, 0x6b39, 0x98ee,
0x6b47, 0x6b43, 0x6b49,
0x6b50, 0x6b59, 0x6b54,
0x6b5b, 0x6b5f, 0x6b61,
0x6b78, 0x6b79, 0x6b7f,
0x6b80, 0x6b84, 0x6b83,
0x6b8d, 0x6b98, 0x6b95,
0x6b9e, 0x6ba4, 0x6baa,
0x6bab, 0x6baf, 0x6bb2,
0x6bb1, 0x6bb3, 0x6bb7,
0x6bbc, 0x6bc6, 0x6bcb,
0x6bd3, 0x6bdf, 0x6bec,
0x6beb, 0x6bf3, 0x6bef,
0x9ebe, 0x6c08, 0x6c13,
0x6c14, 0x6c1b, 0x6c24,
0x6c23, 0x6c5e, 0x6c55,
0x6c62, 0x6c6a, 0x6c82,
0x6c8d, 0x6c9a, 0x6c81,
0x6c9b, 0x6c7e, 0x6c68,
0x6c73, 0x6c92, 0x6c90,
0x6cc4, 0x6cf1, 0x6cd3,
0x6cbd, 0x6cd7, 0x6cc5,
0x6cdd, 0x6cae, 0x6cb1,
0x6cbe, 0x6cba, 0x6cdb,
0x6cef, 0x6cd9, 0x6cea,
0x6d1f, 0x884d, 0x6d36,
0x6d2b, 0x6d3d, 0x6d38,
0x6d19, 0x6d35, 0x6d33,
0x6d12, 0x6d0c, 0x6d63,
0x6d93, 0x6d64, 0x6d5a,
0x6d79, 0x6d59, 0x6d8e,
0x6d95, 0x6fe4, 0x6d85,
0x6df9, 0x6e15, 0x6e0a,
0x6db5, 0x6dc7, 0x6de6,
0x6db8, 0x6dc6, 0x6dec,
0x6dde, 0x6dcc, 0x6de8,
0x6dd2, 0x6dc5, 0x6dfa,
0x6dd9, 0x6de4, 0x6dd5,
0x6dea, 0x6dee, 0x6e2d,
0x6e6e, 0x6e2e, 0x6e19,
0x6e72, 0x6e5f, 0x6e3e,
0x6e23, 0x6e6b, 0x6e2b,
0x6e76, 0x6e4d, 0x6e1f,
0x6e43, 0x6e3a, 0x6e4e,
0x6e24, 0x6eff, 0x6e1d,
0x6e38, 0x6e82, 0x6eaa,
0x6e98, 0x6ec9, 0x6eb7,
0x6ed3, 0x6ebd, 0x6eaf,
0x6ec4, 0x6eb2, 0x6ed4,
0x6ed5, 0x6e8f, 0x6ea5,
0x6ec2, 0x6e9f, 0x6f41,
0x6f11, 0x704c, 0x6eec,
0x6ef8, 0x6efe, 0x6f3f,
0x6ef2, 0x6f31, 0x6eef,
0x6f32, 0x6ecc, 0x6f3e,
0x6f13, 0x6ef7, 0x6f86,
0x6f7a, 0x6f78, 0x6f81,
0x6f80, 0x6f6f, 0x6f5b,
0x6ff3, 0x6f6d, 0x6f82,
0x6f7c, 0x6f58, 0x6f8e,
0x6f91, 0x6fc2, 0x6f66,
0x6fb3, 0x6fa3, 0x6fa1,
0x6fa4, 0x6fb9, 0x6fc6,
0x6faa, 0x6fdf, 0x6fd5,
0x6fec, 0x6fd4, 0x6fd8,
0x6ff1, 0x6fee, 0x6fdb,
0x7009, 0x700b, 0x6ffa,
0x7011, 0x7001, 0x700f,
0x6ffe, 0x701b, 0x701a,
0x6f74, 0x701d, 0x7018,
0x701f, 0x7030, 0x703e,
0x7032, 0x7051, 0x7063,
0x7099, 0x7092, 0x70af,
0x70f1, 0x70ac, 0x70b8,
0x70b3, 0x70ae, 0x70df,
0x70cb, 0x70dd, 0x70d9,
0x7109, 0x70fd, 0x711c,
0x7119, 0x7165, 0x7155,
0x7188, 0x7166, 0x7162,
0x714c, 0x7156, 0x716c,
0x718f, 0x71fb, 0x7184,
0x7195, 0x71a8, 0x71ac,
0x71d7, 0x71b9, 0x71be,
0x71d2, 0x71c9, 0x71d4,
0x71ce, 0x71e0, 0x71ec,
0x71e7, 0x71f5, 0x71fc,
0x71f9, 0x71ff, 0x720d,
0x7210, 0x721b, 0x7228,
0x722d, 0x722c, 0x7230,
0x7232, 0x723b, 0x723c,
0x723f, 0x7240, 0x7246,
0x724b, 0x7258, 0x7274,
0x727e, 0x7282, 0x7281,
0x7287, 0x7292, 0x7296,
0x72a2, 0x72a7, 0x72b9,
0x72b2, 0x72c3, 0x72c6,
0x72c4, 0x72ce, 0x72d2,
0x72e2, 0x72e0, 0x72e1,
0x72f9, 0x72f7, 0x500f,
0x7317, 0x730a, 0x731c,
0x7316, 0x731d, 0x7334,
0x732f, 0x7329, 0x7325,
0x733e, 0x734e, 0x734f,
0x9ed8, 0x7357, 0x736a,
0x7368, 0x7370, 0x7378,
0x7375, 0x737b, 0x737a,
0x73c8, 0x73b3, 0x73ce,
0x73bb, 0x73c0, 0x73e5,
0x73ee, 0x73de, 0x74a2,
0x7405, 0x746f, 0x7425,
0x73f8, 0x7432, 0x743a,
0x7455, 0x743f, 0x745f,
0x7459, 0x7441, 0x745c,
0x7469, 0x7470, 0x7463,
0x746a, 0x7476, 0x747e,
0x748b, 0x749e, 0x74a7,
0x74ca, 0x74cf, 0x74d4,
0x73f1, 0x74e0, 0x74e3,
0x74e7, 0x74e9, 0x74ee,
0x74f2, 0x74f0, 0x74f1,
0x74f8, 0x74f7, 0x7504,
0x7503, 0x7505, 0x750c,
0x750e, 0x750d, 0x7515,
0x7513, 0x751e, 0x7526,
0x752c, 0x753c, 0x7544,
0x754d, 0x754a, 0x7549,
0x755b, 0x7546, 0x755a,
0x7569, 0x7564, 0x7567,
0x756b, 0x756d, 0x7578,
0x7576, 0x7586, 0x7587,
0x7574, 0x758a, 0x7589,
0x7582, 0x7594, 0x759a,
0x759d, 0x75a5, 0x75a3,
0x75c2, 0x75b3, 0x75c3,
0x75b5, 0x75bd, 0x75b8,
0x75bc, 0x75b1, 0x75cd,
0x75ca, 0x75d2, 0x75d9,
0x75e3, 0x75de, 0x75fe,
0x75ff, 0x75fc, 0x7601,
0x75f0, 0x75fa, 0x75f2,
0x75f3, 0x760b, 0x760d,
0x7609, 0x761f, 0x7627,
0x7620, 0x7621, 0x7622,
0x7624, 0x7634, 0x7630,
0x763b, 0x7647, 0x7648,
0x7646, 0x765c, 0x7658,
0x7661, 0x7662, 0x7668,
0x7669, 0x766a, 0x7667,
0x766c, 0x7670, 0x7672,
0x7676, 0x7678, 0x767c,
0x7680, 0x7683, 0x7688,
0x768b, 0x768e, 0x7696,
0x7693, 0x7699, 0x769a,
0x76b0, 0x76b4, 0x76b8,
0x76b9, 0x76ba, 0x76c2,
0x76cd, 0x76d6, 0x76d2,
0x76de, 0x76e1, 0x76e5,
0x76e7, 0x76ea, 0x862f,
0x76fb, 0x7708, 0x7707,
0x7704, 0x7729, 0x7724,
0x771e, 0x7725, 0x7726,
0x771b, 0x7737, 0x7738,
0x7747, 0x775a, 0x7768,
0x776b, 0x775b, 0x7765,
0x777f, 0x777e, 0x7779,
0x778e, 0x778b, 0x7791,
0x77a0, 0x779e, 0x77b0,
0x77b6, 0x77b9, 0x77bf,
0x77bc, 0x77bd, 0x77bb,
0x77c7, 0x77cd, 0x77d7,
0x77da, 0x77dc, 0x77e3,
0x77ee, 0x77fc, 0x780c,
0x7812, 0x7926, 0x7820,
0x792a, 0x7845, 0x788e,
0x7874, 0x7886, 0x787c,
0x789a, 0x788c, 0x78a3,
0x78b5, 0x78aa, 0x78af,
0x78d1, 0x78c6, 0x78cb,
0x78d4, 0x78be, 0x78bc,
0x78c5, 0x78ca, 0x78ec,
0x78e7, 0x78da, 0x78fd,
0x78f4, 0x7907, 0x7912,
0x7911, 0x7919, 0x792c,
0x792b, 0x7940, 0x7960,
0x7957, 0x795f, 0x795a,
0x7955, 0x7953, 0x797a,
0x797f, 0x798a, 0x799d,
0x79a7, 0x9f4b, 0x79aa,
0x79ae, 0x79b3, 0x79b9,
0x79ba, 0x79c9, 0x79d5,
0x79e7, 0x79ec, 0x79e1,
0x79e3, 0x7a08, 0x7a0d,
0x7a18, 0x7a19, 0x7a20,
0x7a1f, 0x7980, 0x7a31,
0x7a3b, 0x7a3e, 0x7a37,
0x7a43, 0x7a57, 0x7a49,
0x7a61, 0x7a62, 0x7a69,
0x9f9d, 0x7a70, 0x7a79,
0x7a7d, 0x7a88, 0x7a97,
0x7a95, 0x7a98, 0x7a96,
0x7aa9, 0x7ac8, 0x7ab0,
0x7ab6, 0x7ac5, 0x7ac4,
0x7abf, 0x9083, 0x7ac7,
0x7aca, 0x7acd, 0x7acf,
0x7ad5, 0x7ad3, 0x7ad9,
0x7ada, 0x7add, 0x7ae1,
0x7ae2, 0x7ae6, 0x7aed,
0x7af0, 0x7b02, 0x7b0f,
0x7b0a, 0x7b06, 0x7b33,
0x7b18, 0x7b19, 0x7b1e,
0x7b35, 0x7b28, 0x7b36,
0x7b50, 0x7b7a, 0x7b04,
0x7b4d, 0x7b0b, 0x7b4c,
0x7b45, 0x7b75, 0x7b65,
0x7b74, 0x7b67, 0x7b70,
0x7b71, 0x7b6c, 0x7b6e,
0x7b9d, 0x7b98, 0x7b9f,
0x7b8d, 0x7b9c, 0x7b9a,
0x7b8b, 0x7b92, 0x7b8f,
0x7b5d, 0x7b99, 0x7bcb,
0x7bc1, 0x7bcc, 0x7bcf,
0x7bb4, 0x7bc6, 0x7bdd,
0x7be9, 0x7c11, 0x7c14,
0x7be6, 0x7be5, 0x7c60,
0x7c00, 0x7c07, 0x7c13,
0x7bf3, 0x7bf7, 0x7c17,
0x7c0d, 0x7bf6, 0x7c23,
0x7c27, 0x7c2a, 0x7c1f,
0x7c37, 0x7c2b, 0x7c3d,
0x7c4c, 0x7c43, 0x7c54,
0x7c4f, 0x7c40, 0x7c50,
0x7c58, 0x7c5f, 0x7c64,
0x7c56, 0x7c65, 0x7c6c,
0x7c75, 0x7c83, 0x7c90,
0x7ca4, 0x7cad, 0x7ca2,
0x7cab, 0x7ca1, 0x7ca8,
0x7cb3, 0x7cb2, 0x7cb1,
0x7cae, 0x7cb9, 0x7cbd,
0x7cc0, 0x7cc5, 0x7cc2,
0x7cd8, 0x7cd2, 0x7cdc,
0x7ce2, 0x9b3b, 0x7cef,
0x7cf2, 0x7cf4, 0x7cf6,
0x7cfa, 0x7d06, 0x7d02,
0x7d1c, 0x7d15, 0x7d0a,
0x7d45, 0x7d4b, 0x7d2e,
0x7d32, 0x7d3f, 0x7d35,
0x7d46, 0x7d73, 0x7d56,
0x7d4e, 0x7d72, 0x7d68,
0x7d6e, 0x7d4f, 0x7d63,
0x7d93, 0x7d89, 0x7d5b,
0x7d8f, 0x7d7d, 0x7d9b,
0x7dba, 0x7dae, 0x7da3,
0x7db5, 0x7dc7, 0x7dbd,
0x7dab, 0x7e3d, 0x7da2,
0x7daf, 0x7ddc, 0x7db8,
0x7d9f, 0x7db0, 0x7dd8,
0x7ddd, 0x7de4, 0x7dde,
0x7dfb, 0x7df2, 0x7de1,
0x7e05, 0x7e0a, 0x7e23,
0x7e21, 0x7e12, 0x7e31,
0x7e1f, 0x7e09, 0x7e0b,
0x7e22, 0x7e46, 0x7e66,
0x7e3b, 0x7e35, 0x7e39,
0x7e43, 0x7e37, 0x7e32,
0x7e3a, 0x7e67, 0x7e5d,
0x7e56, 0x7e5e, 0x7e59,
0x7e5a, 0x7e79, 0x7e6a,
0x7e69, 0x7e7c, 0x7e7b,
0x7e83, 0x7dd5, 0x7e7d,
0x8fae, 0x7e7f, 0x7e88,
0x7e89, 0x7e8c, 0x7e92,
0x7e90, 0x7e93, 0x7e94,
0x7e96, 0x7e8e, 0x7e9b,
0x7e9c, 0x7f38, 0x7f3a,
0x7f45, 0x7f4c, 0x7f4d,
0x7f4e, 0x7f50, 0x7f51,
0x7f55, 0x7f54, 0x7f58,
0x7f5f, 0x7f60, 0x7f68,
0x7f69, 0x7f67, 0x7f78,
0x7f82, 0x7f86, 0x7f83,
0x7f88, 0x7f87, 0x7f8c,
0x7f94, 0x7f9e, 0x7f9d,
0x7f9a, 0x7fa3, 0x7faf,
0x7fb2, 0x7fb9, 0x7fae,
0x7fb6, 0x7fb8, 0x8b71,
0x7fc5, 0x7fc6, 0x7fca,
0x7fd5, 0x7fd4, 0x7fe1,
0x7fe6, 0x7fe9, 0x7ff3,
0x7ff9, 0x98dc, 0x8006,
0x8004, 0x800b, 0x8012,
0x8018, 0x8019, 0x801c,
0x8021, 0x8028, 0x803f,
0x803b, 0x804a, 0x8046,
0x8052, 0x8058, 0x805a,
0x805f, 0x8062, 0x8068,
0x8073, 0x8072, 0x8070,
0x8076, 0x8079, 0x807d,
0x807f, 0x8084, 0x8086,
0x8085, 0x809b, 0x8093,
0x809a, 0x80ad, 0x5190,
0x80ac, 0x80db, 0x80e5,
0x80d9, 0x80dd, 0x80c4,
0x80da, 0x80d6, 0x8109,
0x80ef, 0x80f1, 0x811b,
0x8129, 0x8123, 0x812f,
0x814b, 0x968b, 0x8146,
0x813e, 0x8153, 0x8151,
0x80fc, 0x8171, 0x816e,
0x8165, 0x8166, 0x8174,
0x8183, 0x8188, 0x818a,
0x8180, 0x8182, 0x81a0,
0x8195, 0x81a4, 0x81a3,
0x815f, 0x8193, 0x81a9,
0x81b0, 0x81b5, 0x81be,
0x81b8, 0x81bd, 0x81c0,
0x81c2, 0x81ba, 0x81c9,
0x81cd, 0x81d1, 0x81d9,
0x81d8, 0x81c8, 0x81da,
0x81df, 0x81e0, 0x81e7,
0x81fa, 0x81fb, 0x81fe,
0x8201, 0x8202, 0x8205,
0x8207, 0x820a, 0x820d,
0x8210, 0x8216, 0x8229,
0x822b, 0x8238, 0x8233,
0x8240, 0x8259, 0x8258,
0x825d, 0x825a, 0x825f,
0x8264, 0x8262, 0x8268,
0x826a, 0x826b, 0x822e,
0x8271, 0x8277, 0x8278,
0x827e, 0x828d, 0x8292,
0x82ab, 0x829f, 0x82bb,
0x82ac, 0x82e1, 0x82e3,
0x82df, 0x82d2, 0x82f4,
0x82f3, 0x82fa, 0x8393,
0x8303, 0x82fb, 0x82f9,
0x82de, 0x8306, 0x82dc,
0x8309, 0x82d9, 0x8335,
0x8334, 0x8316, 0x8332,
0x8331, 0x8340, 0x8339,
0x8350, 0x8345, 0x832f,
0x832b, 0x8317, 0x8318,
0x8385, 0x839a, 0x83aa,
0x839f, 0x83a2, 0x8396,
0x8323, 0x838e, 0x8387,
0x838a, 0x837c, 0x83b5,
0x8373, 0x8375, 0x83a0,
0x8389, 0x83a8, 0x83f4,
0x8413, 0x83eb, 0x83ce,
0x83fd, 0x8403, 0x83d8,
0x840b, 0x83c1, 0x83f7,
0x8407, 0x83e0, 0x83f2,
0x840d, 0x8422, 0x8420,
0x83bd, 0x8438, 0x8506,
0x83fb, 0x846d, 0x842a,
0x843c, 0x855a, 0x8484,
0x8477, 0x846b, 0x84ad,
0x846e, 0x8482, 0x8469,
0x8446, 0x842c, 0x846f,
0x8479, 0x8435, 0x84ca,
0x8462, 0x84b9, 0x84bf,
0x849f, 0x84d9, 0x84cd,
0x84bb, 0x84da, 0x84d0,
0x84c1, 0x84c6, 0x84d6,
0x84a1, 0x8521, 0x84ff,
0x84f4, 0x8517, 0x8518,
0x852c, 0x851f, 0x8515,
0x8514, 0x84fc, 0x8540,
0x8563, 0x8558, 0x8548,
0x8541, 0x8602, 0x854b,
0x8555, 0x8580, 0x85a4,
0x8588, 0x8591, 0x858a,
0x85a8, 0x856d, 0x8594,
0x859b, 0x85ea, 0x8587,
0x859c, 0x8577, 0x857e,
0x8590, 0x85c9, 0x85ba,
0x85cf, 0x85b9, 0x85d0,
0x85d5, 0x85dd, 0x85e5,
0x85dc, 0x85f9, 0x860a,
0x8613, 0x860b, 0x85fe,
0x85fa, 0x8606, 0x8622,
0x861a, 0x8630, 0x863f,
0x864d, 0x4e55, 0x8654,
0x865f, 0x8667, 0x8671,
0x8693, 0x86a3, 0x86a9,
0x86aa, 0x868b, 0x868c,
0x86b6, 0x86af, 0x86c4,
0x86c6, 0x86b0, 0x86c9,
0x8823, 0x86ab, 0x86d4,
0x86de, 0x86e9, 0x86ec,
0x86df, 0x86db, 0x86ef,
0x8712, 0x8706, 0x8708,
0x8700, 0x8703, 0x86fb,
0x8711, 0x8709, 0x870d,
0x86f9, 0x870a, 0x8734,
0x873f, 0x8737, 0x873b,
0x8725, 0x8729, 0x871a,
0x8760, 0x875f, 0x8778,
0x874c, 0x874e, 0x8774,
0x8757, 0x8768, 0x876e,
0x8759, 0x8753, 0x8763,
0x876a, 0x8805, 0x87a2,
0x879f, 0x8782, 0x87af,
0x87cb, 0x87bd, 0x87c0,
0x87d0, 0x96d6, 0x87ab,
0x87c4, 0x87b3, 0x87c7,
0x87c6, 0x87bb, 0x87ef,
0x87f2, 0x87e0, 0x880f,
0x880d, 0x87fe, 0x87f6,
0x87f7, 0x880e, 0x87d2,
0x8811, 0x8816, 0x8815,
0x8822, 0x8821, 0x8831,
0x8836, 0x8839, 0x8827,
0x883b, 0x8844, 0x8842,
0x8852, 0x8859, 0x885e,
0x8862, 0x886b, 0x8881,
0x887e, 0x889e, 0x8875,
0x887d, 0x88b5, 0x8872,
0x8882, 0x8897, 0x8892,
0x88ae, 0x8899, 0x88a2,
0x888d, 0x88a4, 0x88b0,
0x88bf, 0x88b1, 0x88c3,
0x88c4, 0x88d4, 0x88d8,
0x88d9, 0x88dd, 0x88f9,
0x8902, 0x88fc, 0x88f4,
0x88e8, 0x88f2, 0x8904,
0x890c, 0x890a, 0x8913,
0x8943, 0x891e, 0x8925,
0x892a, 0x892b, 0x8941,
0x8944, 0x893b, 0x8936,
0x8938, 0x894c, 0x891d,
0x8960, 0x895e, 0x8966,
0x8964, 0x896d, 0x896a,
0x896f, 0x8974, 0x8977,
0x897e, 0x8983, 0x8988,
0x898a, 0x8993, 0x8998,
0x89a1, 0x89a9, 0x89a6,
0x89ac, 0x89af, 0x89b2,
0x89ba, 0x89bd, 0x89bf,
0x89c0, 0x89da, 0x89dc,
0x89dd, 0x89e7, 0x89f4,
0x89f8, 0x8a03, 0x8a16,
0x8a10, 0x8a0c, 0x8a1b,
0x8a1d, 0x8a25, 0x8a36,
0x8a41, 0x8a5b, 0x8a52,
0x8a46, 0x8a48, 0x8a7c,
0x8a6d, 0x8a6c, 0x8a62,
0x8a85, 0x8a82, 0x8a84,
0x8aa8, 0x8aa1, 0x8a91,
0x8aa5, 0x8aa6, 0x8a9a,
0x8aa3, 0x8ac4, 0x8acd,
0x8ac2, 0x8ada, 0x8aeb,
0x8af3, 0x8ae7, 0x8ae4,
0x8af1, 0x8b14, 0x8ae0,
0x8ae2, 0x8af7, 0x8ade,
0x8adb, 0x8b0c, 0x8b07,
0x8b1a, 0x8ae1, 0x8b16,
0x8b10, 0x8b17, 0x8b20,
0x8b33, 0x97ab, 0x8b26,
0x8b2b, 0x8b3e, 0x8b28,
0x8b41, 0x8b4c, 0x8b4f,
0x8b4e, 0x8b49, 0x8b56,
0x8b5b, 0x8b5a, 0x8b6b,
0x8b5f, 0x8b6c, 0x8b6f,
0x8b74, 0x8b7d, 0x8b80,
0x8b8c, 0x8b8e, 0x8b92,
0x8b93, 0x8b96, 0x8b99,
0x8b9a, 0x8c3a, 0x8c41,
0x8c3f, 0x8c48, 0x8c4c,
0x8c4e, 0x8c50, 0x8c55,
0x8c62, 0x8c6c, 0x8c78,
0x8c7a, 0x8c82, 0x8c89,
0x8c85, 0x8c8a, 0x8c8d,
0x8c8e, 0x8c94, 0x8c7c,
0x8c98, 0x621d, 0x8cad,
0x8caa, 0x8cbd, 0x8cb2,
0x8cb3, 0x8cae, 0x8cb6,
0x8cc8, 0x8cc1, 0x8ce4,
0x8ce3, 0x8cda, 0x8cfd,
0x8cfa, 0x8cfb, 0x8d04,
0x8d05, 0x8d0a, 0x8d07,
0x8d0f, 0x8d0d, 0x8d10,
0x9f4e, 0x8d13, 0x8ccd,
0x8d14, 0x8d16, 0x8d67,
0x8d6d, 0x8d71, 0x8d73,
0x8d81, 0x8d99, 0x8dc2,
0x8dbe, 0x8dba, 0x8dcf,
0x8dda, 0x8dd6, 0x8dcc,
0x8ddb, 0x8dcb, 0x8dea,
0x8deb, 0x8ddf, 0x8de3,
0x8dfc, 0x8e08, 0x8e09,
0x8dff, 0x8e1d, 0x8e1e,
0x8e10, 0x8e1f, 0x8e42,
0x8e35, 0x8e30, 0x8e34,
0x8e4a, 0x8e47, 0x8e49,
0x8e4c, 0x8e50, 0x8e48,
0x8e59, 0x8e64, 0x8e60,
0x8e2a, 0x8e63, 0x8e55,
0x8e76, 0x8e72, 0x8e7c,
0x8e81, 0x8e87, 0x8e85,
0x8e84, 0x8e8b, 0x8e8a,
0x8e93, 0x8e91, 0x8e94,
0x8e99, 0x8eaa, 0x8ea1,
0x8eac, 0x8eb0, 0x8ec6,
0x8eb1, 0x8ebe, 0x8ec5,
0x8ec8, 0x8ecb, 0x8edb,
0x8ee3, 0x8efc, 0x8efb,
0x8eeb, 0x8efe, 0x8f0a,
0x8f05, 0x8f15, 0x8f12,
0x8f19, 0x8f13, 0x8f1c,
0x8f1f, 0x8f1b, 0x8f0c,
0x8f26, 0x8f33, 0x8f3b,
0x8f39, 0x8f45, 0x8f42,
0x8f3e, 0x8f4c, 0x8f49,
0x8f46, 0x8f4e, 0x8f57,
0x8f5c, 0x8f62, 0x8f63,
0x8f64, 0x8f9c, 0x8f9f,
0x8fa3, 0x8fad, 0x8faf,
0x8fb7, 0x8fda, 0x8fe5,
0x8fe2, 0x8fea, 0x8fef,
0x9087, 0x8ff4, 0x9005,
0x8ff9, 0x8ffa, 0x9011,
0x9015, 0x9021, 0x900d,
0x901e, 0x9016, 0x900b,
0x9027, 0x9036, 0x9035,
0x9039, 0x8ff8, 0x904f,
0x9050, 0x9051, 0x9052,
0x900e, 0x9049, 0x903e,
0x9056, 0x9058, 0x905e,
0x9068, 0x906f, 0x9076,
0x96a8, 0x9072, 0x9082,
0x907d, 0x9081, 0x9080,
0x908a, 0x9089, 0x908f,
0x90a8, 0x90af, 0x90b1,
0x90b5, 0x90e2, 0x90e4,
0x6248, 0x90db, 0x9102,
0x9112, 0x9119, 0x9132,
0x9130, 0x914a, 0x9156,
0x9158, 0x9163, 0x9165,
0x9169, 0x9173, 0x9172,
0x918b, 0x9189, 0x9182,
0x91a2, 0x91ab, 0x91af,
0x91aa, 0x91b5, 0x91b4,
0x91ba, 0x91c0, 0x91c1,
0x91c9, 0x91cb, 0x91d0,
0x91d6, 0x91df, 0x91e1,
0x91db, 0x91fc, 0x91f5,
0x91f6, 0x921e, 0x91ff,
0x9214, 0x922c, 0x9215,
0x9211, 0x925e, 0x9257,
0x9245, 0x9249, 0x9264,
0x9248, 0x9295, 0x923f,
0x924b, 0x9250, 0x929c,
0x9296, 0x9293, 0x929b,
0x925a, 0x92cf, 0x92b9,
0x92b7, 0x92e9, 0x930f,
0x92fa, 0x9344, 0x932e,
0x9319, 0x9322, 0x931a,
0x9323, 0x933a, 0x9335,
0x933b, 0x935c, 0x9360,
0x937c, 0x936e, 0x9356,
0x93b0, 0x93ac, 0x93ad,
0x9394, 0x93b9, 0x93d6,
0x93d7, 0x93e8, 0x93e5,
0x93d8, 0x93c3, 0x93dd,
0x93d0, 0x93c8, 0x93e4,
0x941a, 0x9414, 0x9413,
0x9403, 0x9407, 0x9410,
0x9436, 0x942b, 0x9435,
0x9421, 0x943a, 0x9441,
0x9452, 0x9444, 0x945b,
0x9460, 0x9462, 0x945e,
0x946a, 0x9229, 0x9470,
0x9475, 0x9477, 0x947d,
0x945a, 0x947c, 0x947e,
0x9481, 0x947f, 0x9582,
0x9587, 0x958a, 0x9594,
0x9596, 0x9598, 0x9599,
0x95a0, 0x95a8, 0x95a7,
0x95ad, 0x95bc, 0x95bb,
0x95b9, 0x95be, 0x95ca,
0x6ff6, 0x95c3, 0x95cd,
0x95cc, 0x95d5, 0x95d4,
0x95d6, 0x95dc, 0x95e1,
0x95e5, 0x95e2, 0x9621,
0x9628, 0x962e, 0x962f,
0x9642, 0x964c, 0x964f,
0x964b, 0x9677, 0x965c,
0x965e, 0x965d, 0x965f,
0x9666, 0x9672, 0x966c,
0x968d, 0x9698, 0x9695,
0x9697, 0x96aa, 0x96a7,
0x96b1, 0x96b2, 0x96b0,
0x96b4, 0x96b6, 0x96b8,
0x96b9, 0x96ce, 0x96cb,
0x96c9, 0x96cd, 0x894d,
0x96dc, 0x970d, 0x96d5,
0x96f9, 0x9704, 0x9706,
0x9708, 0x9713, 0x970e,
0x9711, 0x970f, 0x9716,
0x9719, 0x9724, 0x972a,
0x9730, 0x9739, 0x973d,
0x973e, 0x9744, 0x9746,
0x9748, 0x9742, 0x9749,
0x975c, 0x9760, 0x9764,
0x9766, 0x9768, 0x52d2,
0x976b, 0x9771, 0x9779,
0x9785, 0x977c, 0x9781,
0x977a, 0x9786, 0x978b,
0x978f, 0x9790, 0x979c,
0x97a8, 0x97a6, 0x97a3,
0x97b3, 0x97b4, 0x97c3,
0x97c6, 0x97c8, 0x97cb,
0x97dc, 0x97ed, 0x9f4f,
0x97f2, 0x7adf, 0x97f6,
0x97f5, 0x980f, 0x980c,
0x9838, 0x9824, 0x9821,
0x9837, 0x983d, 0x9846,
0x984f, 0x984b, 0x986b,
0x986f, 0x9870, 0x9871,
0x9874, 0x9873, 0x98aa,
0x98af, 0x98b1, 0x98b6,
0x98c4, 0x98c3, 0x98c6,
0x98e9, 0x98eb, 0x9903,
0x9909, 0x9912, 0x9914,
0x9918, 0x9921, 0x991d,
0x991e, 0x9924, 0x9920,
0x992c, 0x992e, 0x993d,
0x993e, 0x9942, 0x9949,
0x9945, 0x9950, 0x994b,
0x9951, 0x9952, 0x994c,
0x9955, 0x9997, 0x9998,
0x99a5, 0x99ad, 0x99ae,
0x99bc, 0x99df, 0x99db,
0x99dd, 0x99d8, 0x99d1,
0x99ed, 0x99ee, 0x99f1,
0x99f2, 0x99fb, 0x99f8,
0x9a01, 0x9a0f, 0x9a05,
0x99e2, 0x9a19, 0x9a2b,
0x9a37, 0x9a45, 0x9a42,
0x9a40, 0x9a43, 0x9a3e,
0x9a55, 0x9a4d, 0x9a5b,
0x9a57, 0x9a5f, 0x9a62,
0x9a65, 0x9a64, 0x9a69,
0x9a6b, 0x9a6a, 0x9aad,
0x9ab0, 0x9abc, 0x9ac0,
0x9acf, 0x9ad1, 0x9ad3,
0x9ad4, 0x9ade, 0x9adf,
0x9ae2, 0x9ae3, 0x9ae6,
0x9aef, 0x9aeb, 0x9aee,
0x9af4, 0x9af1, 0x9af7,
0x9afb, 0x9b06, 0x9b18,
0x9b1a, 0x9b1f, 0x9b22,
0x9b23, 0x9b25, 0x9b27,
0x9b28, 0x9b29, 0x9b2a,
0x9b2e, 0x9b2f, 0x9b32,
0x9b44, 0x9b43, 0x9b4f,
0x9b4d, 0x9b4e, 0x9b51,
0x9b58, 0x9b74, 0x9b93,
0x9b83, 0x9b91, 0x9b96,
0x9b97, 0x9b9f, 0x9ba0,
0x9ba8, 0x9bb4, 0x9bc0,
0x9bca, 0x9bb9, 0x9bc6,
0x9bcf, 0x9bd1, 0x9bd2,
0x9be3, 0x9be2, 0x9be4,
0x9bd4, 0x9be1, 0x9c3a,
0x9bf2, 0x9bf1, 0x9bf0,
0x9c15, 0x9c14, 0x9c09,
0x9c13, 0x9c0c, 0x9c06,
0x9c08, 0x9c12, 0x9c0a,
0x9c04, 0x9c2e, 0x9c1b,
0x9c25, 0x9c24, 0x9c21,
0x9c30, 0x9c47, 0x9c32,
0x9c46, 0x9c3e, 0x9c5a,
0x9c60, 0x9c67, 0x9c76,
0x9c78, 0x9ce7, 0x9cec,
0x9cf0, 0x9d09, 0x9d08,
0x9ceb, 0x9d03, 0x9d06,
0x9d2a, 0x9d26, 0x9daf,
0x9d23, 0x9d1f, 0x9d44,
0x9d15, 0x9d12, 0x9d41,
0x9d3f, 0x9d3e, 0x9d46,
0x9d48, 0x9d5d, 0x9d5e,
0x9d64, 0x9d51, 0x9d50,
0x9d59, 0x9d72, 0x9d89,
0x9d87, 0x9dab, 0x9d6f,
0x9d7a, 0x9d9a, 0x9da4,
0x9da9, 0x9db2, 0x9dc4,
0x9dc1, 0x9dbb, 0x9db8,
0x9dba, 0x9dc6, 0x9dcf,
0x9dc2, 0x9dd9, 0x9dd3,
0x9df8, 0x9de6, 0x9ded,
0x9def, 0x9dfd, 0x9e1a,
0x9e1b, 0x9e1e, 0x9e75,
0x9e79, 0x9e7d, 0x9e81,
0x9e88, 0x9e8b, 0x9e8c,
0x9e92, 0x9e95, 0x9e91,
0x9e9d, 0x9ea5, 0x9ea9,
0x9eb8, 0x9eaa, 0x9ead,
0x9761, 0x9ecc, 0x9ece,
0x9ecf, 0x9ed0, 0x9ed4,
0x9edc, 0x9ede, 0x9edd,
0x9ee0, 0x9ee5, 0x9ee8,
0x9eef, 0x9ef4, 0x9ef6,
0x9ef7, 0x9ef9, 0x9efb,
0x9efc, 0x9efd, 0x9f07,
0x9f08, 0x76b7, 0x9f15,
0x9f21, 0x9f2c, 0x9f3e,
0x9f4a, 0x9f52, 0x9f54,
0x9f63, 0x9f5f, 0x9f60,
0x9f61, 0x9f66, 0x9f67,
0x9f6c, 0x9f6a, 0x9f77,
0x9f72, 0x9f76, 0x9f95,
0x9f9c, 0x9fa0, 0x582f,
0x69c7, 0x9059, 0x7464,
0x51dc
};
#endif /* _MGCHARSET_UNICODE */
#endif /* _SHIFTJIS_SUPPORT */
| shuntianxia/libminigui-gpl-3.0.12 | src/font/sjisunimap.c | C | gpl-3.0 | 65,498 |
/**************************************************************************/
/*!
@file mcp4725.h
@author K. Townsend (microBuilder.eu)
@section LICENSE
Software License Agreement (BSD License)
Copyright (c) 2010, microBuilder SARL
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders 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 ''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 COPYRIGHT HOLDER 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.
*/
/**************************************************************************/
#ifndef _MCP4725_H_
#define _MCP4725_H_
#include "projectconfig.h"
#define MCP4725_ADDRESS (0xC0) // 1100000x - Assumes A0 is GND and A2,A1 are 0 (MCP4725A0T-E/CH)
#define MCP4725_READ (0x01)
#define MCP4726_CMD_WRITEDAC (0x40) // Writes data to the DAC
#define MCP4726_CMD_WRITEDACEEPROM (0x60) // Writes data to the DAC and the EEPROM (persisting the assigned value after reset)
int mcp4725Init();
void mcp4725SetVoltage( uint16_t output, bool writeEEPROM );
void mcp472ReadConfig( uint8_t *status, uint16_t *value );
#endif | jhnphm/xbs_xbd | platforms/lpc1114-evb/microbuilder_sdk/drivers/dac/mcp4725/mcp4725.h | C | gpl-3.0 | 2,429 |
/*
* 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.commons.math3.transform;
import java.io.Serializable;
import java.lang.reflect.Array;
import org.apache.commons.math3.analysis.FunctionUtils;
import org.apache.commons.math3.analysis.UnivariateFunction;
import org.apache.commons.math3.complex.Complex;
import org.apache.commons.math3.exception.DimensionMismatchException;
import org.apache.commons.math3.exception.MathIllegalArgumentException;
import org.apache.commons.math3.exception.MathIllegalStateException;
import org.apache.commons.math3.exception.util.LocalizedFormats;
import org.apache.commons.math3.util.ArithmeticUtils;
import org.apache.commons.math3.util.FastMath;
import org.apache.commons.math3.util.MathArrays;
/**
* Implements the Fast Fourier Transform for transformation of one-dimensional
* real or complex data sets. For reference, see <em>Applied Numerical Linear
* Algebra</em>, ISBN 0898713897, chapter 6.
* <p>
* There are several variants of the discrete Fourier transform, with various
* normalization conventions, which are specified by the parameter
* {@link DftNormalization}.
* <p>
* The current implementation of the discrete Fourier transform as a fast
* Fourier transform requires the length of the data set to be a power of 2.
* This greatly simplifies and speeds up the code. Users can pad the data with
* zeros to meet this requirement. There are other flavors of FFT, for
* reference, see S. Winograd,
* <i>On computing the discrete Fourier transform</i>, Mathematics of
* Computation, 32 (1978), 175 - 199.
*
* @see DftNormalization
* @since 1.2
*/
public class FastFourierTransformer implements Serializable {
/** Serializable version identifier. */
static final long serialVersionUID = 20120210L;
/**
* {@code W_SUB_N_R[i]} is the real part of
* {@code exp(- 2 * i * pi / n)}:
* {@code W_SUB_N_R[i] = cos(2 * pi/ n)}, where {@code n = 2^i}.
*/
private static final double[] W_SUB_N_R =
{ 0x1.0p0, -0x1.0p0, 0x1.1a62633145c07p-54, 0x1.6a09e667f3bcdp-1
, 0x1.d906bcf328d46p-1, 0x1.f6297cff75cbp-1, 0x1.fd88da3d12526p-1, 0x1.ff621e3796d7ep-1
, 0x1.ffd886084cd0dp-1, 0x1.fff62169b92dbp-1, 0x1.fffd8858e8a92p-1, 0x1.ffff621621d02p-1
, 0x1.ffffd88586ee6p-1, 0x1.fffff62161a34p-1, 0x1.fffffd8858675p-1, 0x1.ffffff621619cp-1
, 0x1.ffffffd885867p-1, 0x1.fffffff62161ap-1, 0x1.fffffffd88586p-1, 0x1.ffffffff62162p-1
, 0x1.ffffffffd8858p-1, 0x1.fffffffff6216p-1, 0x1.fffffffffd886p-1, 0x1.ffffffffff621p-1
, 0x1.ffffffffffd88p-1, 0x1.fffffffffff62p-1, 0x1.fffffffffffd9p-1, 0x1.ffffffffffff6p-1
, 0x1.ffffffffffffep-1, 0x1.fffffffffffffp-1, 0x1.0p0, 0x1.0p0
, 0x1.0p0, 0x1.0p0, 0x1.0p0, 0x1.0p0
, 0x1.0p0, 0x1.0p0, 0x1.0p0, 0x1.0p0
, 0x1.0p0, 0x1.0p0, 0x1.0p0, 0x1.0p0
, 0x1.0p0, 0x1.0p0, 0x1.0p0, 0x1.0p0
, 0x1.0p0, 0x1.0p0, 0x1.0p0, 0x1.0p0
, 0x1.0p0, 0x1.0p0, 0x1.0p0, 0x1.0p0
, 0x1.0p0, 0x1.0p0, 0x1.0p0, 0x1.0p0
, 0x1.0p0, 0x1.0p0, 0x1.0p0 };
/**
* {@code W_SUB_N_I[i]} is the imaginary part of
* {@code exp(- 2 * i * pi / n)}:
* {@code W_SUB_N_I[i] = -sin(2 * pi/ n)}, where {@code n = 2^i}.
*/
private static final double[] W_SUB_N_I =
{ 0x1.1a62633145c07p-52, -0x1.1a62633145c07p-53, -0x1.0p0, -0x1.6a09e667f3bccp-1
, -0x1.87de2a6aea963p-2, -0x1.8f8b83c69a60ap-3, -0x1.917a6bc29b42cp-4, -0x1.91f65f10dd814p-5
, -0x1.92155f7a3667ep-6, -0x1.921d1fcdec784p-7, -0x1.921f0fe670071p-8, -0x1.921f8becca4bap-9
, -0x1.921faaee6472dp-10, -0x1.921fb2aecb36p-11, -0x1.921fb49ee4ea6p-12, -0x1.921fb51aeb57bp-13
, -0x1.921fb539ecf31p-14, -0x1.921fb541ad59ep-15, -0x1.921fb5439d73ap-16, -0x1.921fb544197ap-17
, -0x1.921fb544387bap-18, -0x1.921fb544403c1p-19, -0x1.921fb544422c2p-20, -0x1.921fb54442a83p-21
, -0x1.921fb54442c73p-22, -0x1.921fb54442cefp-23, -0x1.921fb54442d0ep-24, -0x1.921fb54442d15p-25
, -0x1.921fb54442d17p-26, -0x1.921fb54442d18p-27, -0x1.921fb54442d18p-28, -0x1.921fb54442d18p-29
, -0x1.921fb54442d18p-30, -0x1.921fb54442d18p-31, -0x1.921fb54442d18p-32, -0x1.921fb54442d18p-33
, -0x1.921fb54442d18p-34, -0x1.921fb54442d18p-35, -0x1.921fb54442d18p-36, -0x1.921fb54442d18p-37
, -0x1.921fb54442d18p-38, -0x1.921fb54442d18p-39, -0x1.921fb54442d18p-40, -0x1.921fb54442d18p-41
, -0x1.921fb54442d18p-42, -0x1.921fb54442d18p-43, -0x1.921fb54442d18p-44, -0x1.921fb54442d18p-45
, -0x1.921fb54442d18p-46, -0x1.921fb54442d18p-47, -0x1.921fb54442d18p-48, -0x1.921fb54442d18p-49
, -0x1.921fb54442d18p-50, -0x1.921fb54442d18p-51, -0x1.921fb54442d18p-52, -0x1.921fb54442d18p-53
, -0x1.921fb54442d18p-54, -0x1.921fb54442d18p-55, -0x1.921fb54442d18p-56, -0x1.921fb54442d18p-57
, -0x1.921fb54442d18p-58, -0x1.921fb54442d18p-59, -0x1.921fb54442d18p-60 };
/** The type of DFT to be performed. */
private final DftNormalization normalization;
/**
* Creates a new instance of this class, with various normalization
* conventions.
*
* @param normalization the type of normalization to be applied to the
* transformed data
*/
public FastFourierTransformer(final DftNormalization normalization) {
this.normalization = normalization;
}
/**
* Performs identical index bit reversal shuffles on two arrays of identical
* size. Each element in the array is swapped with another element based on
* the bit-reversal of the index. For example, in an array with length 16,
* item at binary index 0011 (decimal 3) would be swapped with the item at
* binary index 1100 (decimal 12).
*
* @param a the first array to be shuffled
* @param b the second array to be shuffled
*/
private static void bitReversalShuffle2(double[] a, double[] b) {
final int n = a.length;
assert b.length == n;
final int halfOfN = n >> 1;
int j = 0;
for (int i = 0; i < n; i++) {
if (i < j) {
// swap indices i & j
double temp = a[i];
a[i] = a[j];
a[j] = temp;
temp = b[i];
b[i] = b[j];
b[j] = temp;
}
int k = halfOfN;
while (k <= j && k > 0) {
j -= k;
k >>= 1;
}
j += k;
}
}
/**
* Applies the proper normalization to the specified transformed data.
*
* @param dataRI the unscaled transformed data
* @param normalization the normalization to be applied
* @param type the type of transform (forward, inverse) which resulted in the specified data
*/
private static void normalizeTransformedData(final double[][] dataRI,
final DftNormalization normalization, final TransformType type) {
final double[] dataR = dataRI[0];
final double[] dataI = dataRI[1];
final int n = dataR.length;
assert dataI.length == n;
switch (normalization) {
case STANDARD:
if (type == TransformType.INVERSE) {
final double scaleFactor = 1.0 / ((double) n);
for (int i = 0; i < n; i++) {
dataR[i] *= scaleFactor;
dataI[i] *= scaleFactor;
}
}
break;
case UNITARY:
final double scaleFactor = 1.0 / FastMath.sqrt(n);
for (int i = 0; i < n; i++) {
dataR[i] *= scaleFactor;
dataI[i] *= scaleFactor;
}
break;
default:
/*
* This should never occur in normal conditions. However this
* clause has been added as a safeguard if other types of
* normalizations are ever implemented, and the corresponding
* test is forgotten in the present switch.
*/
throw new MathIllegalStateException();
}
}
/**
* Computes the standard transform of the specified complex data. The
* computation is done in place. The input data is laid out as follows
* <ul>
* <li>{@code dataRI[0][i]} is the real part of the {@code i}-th data point,</li>
* <li>{@code dataRI[1][i]} is the imaginary part of the {@code i}-th data point.</li>
* </ul>
*
* @param dataRI the two dimensional array of real and imaginary parts of the data
* @param normalization the normalization to be applied to the transformed data
* @param type the type of transform (forward, inverse) to be performed
* @throws DimensionMismatchException if the number of rows of the specified
* array is not two, or the array is not rectangular
* @throws MathIllegalArgumentException if the number of data points is not
* a power of two
*/
public static void transformInPlace(final double[][] dataRI,
final DftNormalization normalization, final TransformType type) {
if (dataRI.length != 2) {
throw new DimensionMismatchException(dataRI.length, 2);
}
final double[] dataR = dataRI[0];
final double[] dataI = dataRI[1];
if (dataR.length != dataI.length) {
throw new DimensionMismatchException(dataI.length, dataR.length);
}
final int n = dataR.length;
if (!ArithmeticUtils.isPowerOfTwo(n)) {
throw new MathIllegalArgumentException(
LocalizedFormats.NOT_POWER_OF_TWO_CONSIDER_PADDING,
Integer.valueOf(n));
}
if (n == 1) {
return;
} else if (n == 2) {
final double srcR0 = dataR[0];
final double srcI0 = dataI[0];
final double srcR1 = dataR[1];
final double srcI1 = dataI[1];
// X_0 = x_0 + x_1
dataR[0] = srcR0 + srcR1;
dataI[0] = srcI0 + srcI1;
// X_1 = x_0 - x_1
dataR[1] = srcR0 - srcR1;
dataI[1] = srcI0 - srcI1;
normalizeTransformedData(dataRI, normalization, type);
return;
}
bitReversalShuffle2(dataR, dataI);
// Do 4-term DFT.
if (type == TransformType.INVERSE) {
for (int i0 = 0; i0 < n; i0 += 4) {
final int i1 = i0 + 1;
final int i2 = i0 + 2;
final int i3 = i0 + 3;
final double srcR0 = dataR[i0];
final double srcI0 = dataI[i0];
final double srcR1 = dataR[i2];
final double srcI1 = dataI[i2];
final double srcR2 = dataR[i1];
final double srcI2 = dataI[i1];
final double srcR3 = dataR[i3];
final double srcI3 = dataI[i3];
// 4-term DFT
// X_0 = x_0 + x_1 + x_2 + x_3
dataR[i0] = srcR0 + srcR1 + srcR2 + srcR3;
dataI[i0] = srcI0 + srcI1 + srcI2 + srcI3;
// X_1 = x_0 - x_2 + j * (x_3 - x_1)
dataR[i1] = srcR0 - srcR2 + (srcI3 - srcI1);
dataI[i1] = srcI0 - srcI2 + (srcR1 - srcR3);
// X_2 = x_0 - x_1 + x_2 - x_3
dataR[i2] = srcR0 - srcR1 + srcR2 - srcR3;
dataI[i2] = srcI0 - srcI1 + srcI2 - srcI3;
// X_3 = x_0 - x_2 + j * (x_1 - x_3)
dataR[i3] = srcR0 - srcR2 + (srcI1 - srcI3);
dataI[i3] = srcI0 - srcI2 + (srcR3 - srcR1);
}
} else {
for (int i0 = 0; i0 < n; i0 += 4) {
final int i1 = i0 + 1;
final int i2 = i0 + 2;
final int i3 = i0 + 3;
final double srcR0 = dataR[i0];
final double srcI0 = dataI[i0];
final double srcR1 = dataR[i2];
final double srcI1 = dataI[i2];
final double srcR2 = dataR[i1];
final double srcI2 = dataI[i1];
final double srcR3 = dataR[i3];
final double srcI3 = dataI[i3];
// 4-term DFT
// X_0 = x_0 + x_1 + x_2 + x_3
dataR[i0] = srcR0 + srcR1 + srcR2 + srcR3;
dataI[i0] = srcI0 + srcI1 + srcI2 + srcI3;
// X_1 = x_0 - x_2 + j * (x_3 - x_1)
dataR[i1] = srcR0 - srcR2 + (srcI1 - srcI3);
dataI[i1] = srcI0 - srcI2 + (srcR3 - srcR1);
// X_2 = x_0 - x_1 + x_2 - x_3
dataR[i2] = srcR0 - srcR1 + srcR2 - srcR3;
dataI[i2] = srcI0 - srcI1 + srcI2 - srcI3;
// X_3 = x_0 - x_2 + j * (x_1 - x_3)
dataR[i3] = srcR0 - srcR2 + (srcI3 - srcI1);
dataI[i3] = srcI0 - srcI2 + (srcR1 - srcR3);
}
}
int lastN0 = 4;
int lastLogN0 = 2;
while (lastN0 < n) {
int n0 = lastN0 << 1;
int logN0 = lastLogN0 + 1;
double wSubN0R = W_SUB_N_R[logN0];
double wSubN0I = W_SUB_N_I[logN0];
if (type == TransformType.INVERSE) {
wSubN0I = -wSubN0I;
}
// Combine even/odd transforms of size lastN0 into a transform of size N0 (lastN0 * 2).
for (int destEvenStartIndex = 0; destEvenStartIndex < n; destEvenStartIndex += n0) {
int destOddStartIndex = destEvenStartIndex + lastN0;
double wSubN0ToRR = 1;
double wSubN0ToRI = 0;
for (int r = 0; r < lastN0; r++) {
double grR = dataR[destEvenStartIndex + r];
double grI = dataI[destEvenStartIndex + r];
double hrR = dataR[destOddStartIndex + r];
double hrI = dataI[destOddStartIndex + r];
// dest[destEvenStartIndex + r] = Gr + WsubN0ToR * Hr
dataR[destEvenStartIndex + r] = grR + wSubN0ToRR * hrR - wSubN0ToRI * hrI;
dataI[destEvenStartIndex + r] = grI + wSubN0ToRR * hrI + wSubN0ToRI * hrR;
// dest[destOddStartIndex + r] = Gr - WsubN0ToR * Hr
dataR[destOddStartIndex + r] = grR - (wSubN0ToRR * hrR - wSubN0ToRI * hrI);
dataI[destOddStartIndex + r] = grI - (wSubN0ToRR * hrI + wSubN0ToRI * hrR);
// WsubN0ToR *= WsubN0R
double nextWsubN0ToRR = wSubN0ToRR * wSubN0R - wSubN0ToRI * wSubN0I;
double nextWsubN0ToRI = wSubN0ToRR * wSubN0I + wSubN0ToRI * wSubN0R;
wSubN0ToRR = nextWsubN0ToRR;
wSubN0ToRI = nextWsubN0ToRI;
}
}
lastN0 = n0;
lastLogN0 = logN0;
}
normalizeTransformedData(dataRI, normalization, type);
}
/**
* Returns the (forward, inverse) transform of the specified real data set.
*
* @param f the real data array to be transformed
* @param type the type of transform (forward, inverse) to be performed
* @return the complex transformed array
* @throws MathIllegalArgumentException if the length of the data array is not a power of two
*/
public Complex[] transform(final double[] f, final TransformType type) {
final double[][] dataRI = new double[][] {
MathArrays.copyOf(f, f.length), new double[f.length]
};
transformInPlace(dataRI, normalization, type);
return TransformUtils.createComplexArray(dataRI);
}
/**
* Returns the (forward, inverse) transform of the specified real function,
* sampled on the specified interval.
*
* @param f the function to be sampled and transformed
* @param min the (inclusive) lower bound for the interval
* @param max the (exclusive) upper bound for the interval
* @param n the number of sample points
* @param type the type of transform (forward, inverse) to be performed
* @return the complex transformed array
* @throws org.apache.commons.math3.exception.NumberIsTooLargeException
* if the lower bound is greater than, or equal to the upper bound
* @throws org.apache.commons.math3.exception.NotStrictlyPositiveException
* if the number of sample points {@code n} is negative
* @throws MathIllegalArgumentException if the number of sample points
* {@code n} is not a power of two
*/
public Complex[] transform(final UnivariateFunction f,
final double min, final double max, final int n,
final TransformType type) {
final double[] data = FunctionUtils.sample(f, min, max, n);
return transform(data, type);
}
/**
* Returns the (forward, inverse) transform of the specified complex data set.
*
* @param f the complex data array to be transformed
* @param type the type of transform (forward, inverse) to be performed
* @return the complex transformed array
* @throws MathIllegalArgumentException if the length of the data array is not a power of two
*/
public Complex[] transform(final Complex[] f, final TransformType type) {
final double[][] dataRI = TransformUtils.createRealImaginaryArray(f);
transformInPlace(dataRI, normalization, type);
return TransformUtils.createComplexArray(dataRI);
}
/**
* Performs a multi-dimensional Fourier transform on a given array. Use
* {@link #transform(Complex[], TransformType)} in a row-column
* implementation in any number of dimensions with
* O(N×log(N)) complexity with
* N = n<sub>1</sub> × n<sub>2</sub> ×n<sub>3</sub> × ...
* × n<sub>d</sub>, where n<sub>k</sub> is the number of elements in
* dimension k, and d is the total number of dimensions.
*
* @param mdca Multi-Dimensional Complex Array, i.e. {@code Complex[][][][]}
* @param type the type of transform (forward, inverse) to be performed
* @return transform of {@code mdca} as a Multi-Dimensional Complex Array, i.e. {@code Complex[][][][]}
* @throws IllegalArgumentException if any dimension is not a power of two
* @deprecated see MATH-736
*/
@Deprecated
public Object mdfft(Object mdca, TransformType type) {
MultiDimensionalComplexMatrix mdcm = (MultiDimensionalComplexMatrix)
new MultiDimensionalComplexMatrix(mdca).clone();
int[] dimensionSize = mdcm.getDimensionSizes();
//cycle through each dimension
for (int i = 0; i < dimensionSize.length; i++) {
mdfft(mdcm, type, i, new int[0]);
}
return mdcm.getArray();
}
/**
* Performs one dimension of a multi-dimensional Fourier transform.
*
* @param mdcm input matrix
* @param type the type of transform (forward, inverse) to be performed
* @param d index of the dimension to process
* @param subVector recursion subvector
* @throws IllegalArgumentException if any dimension is not a power of two
* @deprecated see MATH-736
*/
@Deprecated
private void mdfft(MultiDimensionalComplexMatrix mdcm,
TransformType type, int d, int[] subVector) {
int[] dimensionSize = mdcm.getDimensionSizes();
//if done
if (subVector.length == dimensionSize.length) {
Complex[] temp = new Complex[dimensionSize[d]];
for (int i = 0; i < dimensionSize[d]; i++) {
//fft along dimension d
subVector[d] = i;
temp[i] = mdcm.get(subVector);
}
temp = transform(temp, type);
for (int i = 0; i < dimensionSize[d]; i++) {
subVector[d] = i;
mdcm.set(temp[i], subVector);
}
} else {
int[] vector = new int[subVector.length + 1];
System.arraycopy(subVector, 0, vector, 0, subVector.length);
if (subVector.length == d) {
//value is not important once the recursion is done.
//then an fft will be applied along the dimension d.
vector[d] = 0;
mdfft(mdcm, type, d, vector);
} else {
for (int i = 0; i < dimensionSize[subVector.length]; i++) {
vector[subVector.length] = i;
//further split along the next dimension
mdfft(mdcm, type, d, vector);
}
}
}
}
/**
* Complex matrix implementation. Not designed for synchronized access may
* eventually be replaced by jsr-83 of the java community process
* http://jcp.org/en/jsr/detail?id=83
* may require additional exception throws for other basic requirements.
*
* @deprecated see MATH-736
*/
@Deprecated
private static class MultiDimensionalComplexMatrix
implements Cloneable {
/** Size in all dimensions. */
protected int[] dimensionSize;
/** Storage array. */
protected Object multiDimensionalComplexArray;
/**
* Simple constructor.
*
* @param multiDimensionalComplexArray array containing the matrix
* elements
*/
MultiDimensionalComplexMatrix(Object multiDimensionalComplexArray) {
this.multiDimensionalComplexArray = multiDimensionalComplexArray;
// count dimensions
int numOfDimensions = 0;
for (Object lastDimension = multiDimensionalComplexArray;
lastDimension instanceof Object[];) {
final Object[] array = (Object[]) lastDimension;
numOfDimensions++;
lastDimension = array[0];
}
// allocate array with exact count
dimensionSize = new int[numOfDimensions];
// fill array
numOfDimensions = 0;
for (Object lastDimension = multiDimensionalComplexArray;
lastDimension instanceof Object[];) {
final Object[] array = (Object[]) lastDimension;
dimensionSize[numOfDimensions++] = array.length;
lastDimension = array[0];
}
}
/**
* Get a matrix element.
*
* @param vector indices of the element
* @return matrix element
* @exception DimensionMismatchException if dimensions do not match
*/
public Complex get(int... vector)
throws DimensionMismatchException {
if (vector == null) {
if (dimensionSize.length > 0) {
throw new DimensionMismatchException(
0,
dimensionSize.length);
}
return null;
}
if (vector.length != dimensionSize.length) {
throw new DimensionMismatchException(
vector.length,
dimensionSize.length);
}
Object lastDimension = multiDimensionalComplexArray;
for (int i = 0; i < dimensionSize.length; i++) {
lastDimension = ((Object[]) lastDimension)[vector[i]];
}
return (Complex) lastDimension;
}
/**
* Set a matrix element.
*
* @param magnitude magnitude of the element
* @param vector indices of the element
* @return the previous value
* @exception DimensionMismatchException if dimensions do not match
*/
public Complex set(Complex magnitude, int... vector)
throws DimensionMismatchException {
if (vector == null) {
if (dimensionSize.length > 0) {
throw new DimensionMismatchException(
0,
dimensionSize.length);
}
return null;
}
if (vector.length != dimensionSize.length) {
throw new DimensionMismatchException(
vector.length,
dimensionSize.length);
}
Object[] lastDimension = (Object[]) multiDimensionalComplexArray;
for (int i = 0; i < dimensionSize.length - 1; i++) {
lastDimension = (Object[]) lastDimension[vector[i]];
}
Complex lastValue = (Complex) lastDimension[vector[dimensionSize.length - 1]];
lastDimension[vector[dimensionSize.length - 1]] = magnitude;
return lastValue;
}
/**
* Get the size in all dimensions.
*
* @return size in all dimensions
*/
public int[] getDimensionSizes() {
return dimensionSize.clone();
}
/**
* Get the underlying storage array.
*
* @return underlying storage array
*/
public Object getArray() {
return multiDimensionalComplexArray;
}
/** {@inheritDoc} */
@Override
public Object clone() {
MultiDimensionalComplexMatrix mdcm =
new MultiDimensionalComplexMatrix(Array.newInstance(
Complex.class, dimensionSize));
clone(mdcm);
return mdcm;
}
/**
* Copy contents of current array into mdcm.
*
* @param mdcm array where to copy data
*/
private void clone(MultiDimensionalComplexMatrix mdcm) {
int[] vector = new int[dimensionSize.length];
int size = 1;
for (int i = 0; i < dimensionSize.length; i++) {
size *= dimensionSize[i];
}
int[][] vectorList = new int[size][dimensionSize.length];
for (int[] nextVector : vectorList) {
System.arraycopy(vector, 0, nextVector, 0,
dimensionSize.length);
for (int i = 0; i < dimensionSize.length; i++) {
vector[i]++;
if (vector[i] < dimensionSize[i]) {
break;
} else {
vector[i] = 0;
}
}
}
for (int[] nextVector : vectorList) {
mdcm.set(get(nextVector), nextVector);
}
}
}
}
| happyjack27/autoredistrict | src/org/apache/commons/math3/transform/FastFourierTransformer.java | Java | gpl-3.0 | 27,654 |
package net.minecraft.item;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemSimpleFoiled extends Item
{
/**
* Returns true if this item has an enchantment glint. By default, this returns
* <code>stack.isItemEnchanted()</code>, but other items can override it (for instance, written books always return
* true).
*
* Note that if you override this method, you generally want to also call the super version (on {@link Item}) to get
* the glint for enchanted items. Of course, that is unnecessary if the overwritten version always returns true.
*/
@SideOnly(Side.CLIENT)
public boolean hasEffect(ItemStack stack)
{
return true;
}
} | Severed-Infinity/technium | build/tmp/recompileMc/sources/net/minecraft/item/ItemSimpleFoiled.java | Java | gpl-3.0 | 761 |
/* grain.h */
/*
This file is part of the AVR-Crypto-Lib.
Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
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 3 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/>.
*/
/** \file grain.h
* \author Daniel Otte
* \email daniel.otte@rub.de
* \license GPLv3 or later
* \brief implementation of the Grain streamcipher
*/
#ifndef GRAIN_H_
#define GRAIN_H_
#include <stdint.h>
typedef struct gain_ctx_st{
uint8_t lfsr[10];
uint8_t nfsr[10];
} grain_ctx_t;
uint8_t grain_getbyte(grain_ctx_t* ctx);
uint8_t grain_enc(grain_ctx_t* ctx);
void grain_init(const void* key, const void* iv, grain_ctx_t* ctx);
#endif /*GRAIN_H_*/
| efDidymos/LightweightCryptography | StreamCiphers/Grain-sha256/src/grain/grain.h | C | gpl-3.0 | 1,238 |
package command
import (
"io/ioutil"
"os"
"path/filepath"
"strings"
"testing"
"github.com/hashicorp/terraform/terraform"
"github.com/mitchellh/cli"
)
func TestOutput(t *testing.T) {
originalState := &terraform.State{
Modules: []*terraform.ModuleState{
&terraform.ModuleState{
Path: []string{"root"},
Outputs: map[string]string{
"foo": "bar",
},
},
},
}
statePath := testStateFile(t, originalState)
ui := new(cli.MockUi)
c := &OutputCommand{
Meta: Meta{
ContextOpts: testCtxConfig(testProvider()),
Ui: ui,
},
}
args := []string{
"-state", statePath,
"foo",
}
if code := c.Run(args); code != 0 {
t.Fatalf("bad: \n%s", ui.ErrorWriter.String())
}
actual := strings.TrimSpace(ui.OutputWriter.String())
if actual != "bar" {
t.Fatalf("bad: %#v", actual)
}
}
func TestOutput_badVar(t *testing.T) {
originalState := &terraform.State{
Modules: []*terraform.ModuleState{
&terraform.ModuleState{
Path: []string{"root"},
Outputs: map[string]string{
"foo": "bar",
},
},
},
}
statePath := testStateFile(t, originalState)
ui := new(cli.MockUi)
c := &OutputCommand{
Meta: Meta{
ContextOpts: testCtxConfig(testProvider()),
Ui: ui,
},
}
args := []string{
"-state", statePath,
"bar",
}
if code := c.Run(args); code != 1 {
t.Fatalf("bad: \n%s", ui.ErrorWriter.String())
}
}
func TestOutput_blank(t *testing.T) {
originalState := &terraform.State{
Modules: []*terraform.ModuleState{
&terraform.ModuleState{
Path: []string{"root"},
Outputs: map[string]string{
"foo": "bar",
},
},
},
}
statePath := testStateFile(t, originalState)
ui := new(cli.MockUi)
c := &OutputCommand{
Meta: Meta{
ContextOpts: testCtxConfig(testProvider()),
Ui: ui,
},
}
args := []string{
"-state", statePath,
"",
}
if code := c.Run(args); code != 1 {
t.Fatalf("bad: \n%s", ui.ErrorWriter.String())
}
}
func TestOutput_manyArgs(t *testing.T) {
ui := new(cli.MockUi)
c := &OutputCommand{
Meta: Meta{
ContextOpts: testCtxConfig(testProvider()),
Ui: ui,
},
}
args := []string{
"bad",
"bad",
}
if code := c.Run(args); code != 1 {
t.Fatalf("bad: \n%s", ui.OutputWriter.String())
}
}
func TestOutput_noArgs(t *testing.T) {
ui := new(cli.MockUi)
c := &OutputCommand{
Meta: Meta{
ContextOpts: testCtxConfig(testProvider()),
Ui: ui,
},
}
args := []string{}
if code := c.Run(args); code != 1 {
t.Fatalf("bad: \n%s", ui.OutputWriter.String())
}
}
func TestOutput_noVars(t *testing.T) {
originalState := &terraform.State{
Modules: []*terraform.ModuleState{
&terraform.ModuleState{
Path: []string{"root"},
Outputs: map[string]string{},
},
},
}
statePath := testStateFile(t, originalState)
ui := new(cli.MockUi)
c := &OutputCommand{
Meta: Meta{
ContextOpts: testCtxConfig(testProvider()),
Ui: ui,
},
}
args := []string{
"-state", statePath,
"bar",
}
if code := c.Run(args); code != 1 {
t.Fatalf("bad: \n%s", ui.ErrorWriter.String())
}
}
func TestOutput_stateDefault(t *testing.T) {
originalState := &terraform.State{
Modules: []*terraform.ModuleState{
&terraform.ModuleState{
Path: []string{"root"},
Outputs: map[string]string{
"foo": "bar",
},
},
},
}
// Write the state file in a temporary directory with the
// default filename.
td, err := ioutil.TempDir("", "tf")
if err != nil {
t.Fatalf("err: %s", err)
}
statePath := filepath.Join(td, DefaultStateFilename)
f, err := os.Create(statePath)
if err != nil {
t.Fatalf("err: %s", err)
}
err = terraform.WriteState(originalState, f)
f.Close()
if err != nil {
t.Fatalf("err: %s", err)
}
// Change to that directory
cwd, err := os.Getwd()
if err != nil {
t.Fatalf("err: %s", err)
}
if err := os.Chdir(filepath.Dir(statePath)); err != nil {
t.Fatalf("err: %s", err)
}
defer os.Chdir(cwd)
ui := new(cli.MockUi)
c := &OutputCommand{
Meta: Meta{
ContextOpts: testCtxConfig(testProvider()),
Ui: ui,
},
}
args := []string{
"foo",
}
if code := c.Run(args); code != 0 {
t.Fatalf("bad: \n%s", ui.ErrorWriter.String())
}
actual := strings.TrimSpace(ui.OutputWriter.String())
if actual != "bar" {
t.Fatalf("bad: %#v", actual)
}
}
| svend/terraform | command/output_test.go | GO | mpl-2.0 | 4,338 |
## Tests
#### Mocha, React Test Utils and Karma
We are using React Test Utils to test our components and using Karma for our test runner to run Mocha tests.
To run the test simply run:
```
$> npm test
```
#### Selenium
```
$> npm run test:selenium
``` | mozilla/donate.mozilla.org | docs/Tests.md | Markdown | mpl-2.0 | 257 |
<?php
/**
* @package jelix
* @subpackage auth
* @author Laurent Jouanneau
* @contributor Frédéric Guillot, Antoine Detante, Julien Issler
* @copyright 2005-2008 Laurent Jouanneau, 2007 Frédéric Guillot, 2007 Antoine Detante
* @copyright 2007 Julien Issler
*
*/
/**
* interface for auth drivers
* @package jelix
* @subpackage auth
* @static
*/
interface jIAuthDriver {
/**
* constructor
* @param array $params driver parameters, written in the ini file of the auth plugin
*/
function __construct($params);
/**
* creates a new user object, with some first data..
* Careful : it doesn't create a user in a database for example. Just an object.
* @param string $login the user login
* @param string $password the user password
* @return object the returned object depends on the driver
*/
public function createUserObject($login, $password);
/**
* store a new user.
*
* It create the user in a database for example
* should be call after a call of createUser and after setting some of its properties...
* @param object $user the user data container
*/
public function saveNewUser($user);
/**
* Erase user data of the user $login
* @param string $login the login of the user to remove
*/
public function removeUser($login);
/**
* save updated data of a user
* warning : should not save the password !
* @param object $user the user data container
*/
public function updateUser($user);
/**
* return user data corresponding to the given login
* @param string $login the login of the user
* @return object the user data container
*/
public function getUser($login);
/**
* construct the user list
* @param string $pattern '' for all users
* @return array array of user object
*/
public function getUserList($pattern);
/**
* change a user password
*
* @param string $login the login of the user
* @param string $newpassword
*/
public function changePassword($login, $newpassword);
/**
* verify that the password correspond to the login
* @param string $login the login of the user
* @param string $password the password to test
* @return object|false
*/
public function verifyPassword($login, $password);
}
| aeag/lizmap-web-client | lib/jelix/auth/jIAuthDriver.iface.php | PHP | mpl-2.0 | 2,391 |
<!-- GENERATED FILE, DO NOT EDIT -->
<!DOCTYPE HTML>
<html>
<head>
<meta charset='utf-8'/>
<title>
Mochitest wrapper for WebGL Conformance Test Suite tests
</title>
<link rel='stylesheet' type='text/css' href='../iframe-passthrough.css'/>
<script src='/tests/SimpleTest/SimpleTest.js'></script>
<link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
</head>
<body>
<iframe src='../mochi-single.html?checkout/conformance/more/functions/texImage2DBadArgs.html?webglVersion=2'></iframe>
</body>
</html>
| Yukarumya/Yukarum-Redfoxes | dom/canvas/test/webgl-conf/generated/test_2_conformance__more__functions__texImage2DBadArgs.html | HTML | mpl-2.0 | 563 |
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>HTML Test: dir=auto, start with dir, then L</title>
<link rel="reference" href="dir_auto-contained-dir-L-ref.html" />
<link rel="author" title="Matitiahu Allouche" href="mailto:matitiahu.allouche@google.com" />
<link rel="author" title="Oren Roth" href="mailto:oren.roth@gmail.com" />
<link rel="author" title="Simon Montagu" href="mailto:smontagu@smontagu.org" />
<link rel="author" title="HTML5 bidi test WG" href="mailto:html5bidi@googlegroups.com" />
<link rel="help" href="http://dev.w3.org/html5/spec/Overview.html#the-dir-attribute" />
<meta name="assert" content="
When dir='auto', the direction is set according to the first strong character
of the text while ignoring contained elements with an explicit dir of their own.
In this test, it is the Hebrew letter Dalet, thus the direction must be
resolved as RTL.
This is a variation of the original dir_auto-contained-dir-L.html in which
the explicit dir is unset by script after loading the page" />
<style>
input, textarea {
font-size:1em;
}
body {
font-size:2em;
}
.test, .ref {
border: medium solid gray;
width: 400px;
margin: 20px;
}
.comments {
display: none;
}
</style>
</head>
<body>
<div class="instructions"><p>Test passes if the two boxes below look exactly the same.</p></div>
<div class="comments">
Key to entities used below:
א - The Hebrew letter Alef (strongly RTL).
ב - The Hebrew letter Bet (strongly RTL).
ג - The Hebrew letter Gimel (strongly RTL).
ד - The Hebrew letter Dalet (strongly RTL).
ה - The Hebrew letter He (strongly RTL).
ו - The Hebrew letter Vav (strongly RTL).
</div>
<div class="test">
<div dir="ltr">
<div dir="rtl"><p id="p1" dir="rtl">דהו</p>ABCאבג.</div>
</div>
<div dir="rtl">
<div dir="rtl"><p id="p2" dir="rtl">דהו</p>ABCאבג.</div>
</div>
</div>
<div class="ref">
<div dir="ltr">
<div dir="rtl"><p dir="rtl">דהו</p>ABCאבג.</div>
</div>
<div dir="rtl">
<div dir="rtl"><p dir="rtl">דהו</p>ABCאבג.</div>
</div>
</div>
</body>
</html>
| Yukarumya/Yukarum-Redfoxes | layout/reftests/bidi/dirAuto/dir_auto-unset-contained-dir-R-ref.html | HTML | mpl-2.0 | 2,538 |
<!-- GENERATED FILE, DO NOT EDIT -->
<!DOCTYPE HTML>
<html>
<head>
<meta charset='utf-8'/>
<title>
Mochitest wrapper for WebGL Conformance Test Suite tests
</title>
<link rel='stylesheet' type='text/css' href='../iframe-passthrough.css'/>
<script src='/tests/SimpleTest/SimpleTest.js'></script>
<link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css'/>
</head>
<body>
<iframe src='../mochi-single.html?checkout/conformance/glsl/functions/glsl-function.html?webglVersion=2'></iframe>
</body>
</html>
| Yukarumya/Yukarum-Redfoxes | dom/canvas/test/webgl-conf/generated/test_2_conformance__glsl__functions__glsl-function.html | HTML | mpl-2.0 | 559 |
using System;
using System.IO;
using System.Threading.Tasks;
using Windows.ApplicationModel;
using Windows.Storage;
using Newtonsoft.Json;
namespace AlFanous.Model
{
public class DataService : IDataService
{
public async Task<FanousQueryResponse> GetData()
{
return null;
}
}
} | keelhaule/alfanous | interfaces/smart_phones/WindowsStore/AlFanous/Model/DataService.cs | C# | agpl-3.0 | 330 |
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>boost::cnv::is_range</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../index.html" title="Chapter 1. Boost.Convert 2.0">
<link rel="up" href="../supporting_tools.html" title="Supporting Tools">
<link rel="prev" href="boost__cnv__range.html" title="boost::cnv::range">
<link rel="next" href="boost__cnv__is_cnv.html" title="boost::cnv::is_cnv">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="boost__cnv__range.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../supporting_tools.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost__cnv__is_cnv.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="boost_convert.supporting_tools.boost__cnv__is_range"></a><a class="link" href="boost__cnv__is_range.html" title="boost::cnv::is_range">boost::cnv::is_range</a>
</h3></div></div></div>
<p>
TODO
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2009-2016 Vladimir Batov<p>
Distributed under the Boost Software License, Version 1.0. See copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>.
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="boost__cnv__range.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../supporting_tools.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost__cnv__is_cnv.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
| ntonjeta/iidea-Docker | examples/sobel/src/boost_1_63_0/libs/convert/doc/html/boost_convert/supporting_tools/boost__cnv__is_range.html | HTML | agpl-3.0 | 2,966 |
"""A module that is accepted by Python but rejected by tokenize.
The problem is the trailing line continuation at the end of the line,
which produces a TokenError."""
""\
| GbalsaC/bitnamiP | venv/lib/python2.7/site-packages/pylint/test/input/func_tokenize_error.py | Python | agpl-3.0 | 173 |
<?php
/**
* Class xmlformTemplate
*
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @package gulliver.system
* @access public
*/
class xmlformTemplate extends Smarty
{
public $template;
public $templateFile;
/**
* Function xmlformTemplate
*
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public
* @param string form
* @param string templateFile
* @return string
*/
public function xmlformTemplate (&$form, $templateFile)
{
$this->template_dir = PATH_XMLFORM;
$this->compile_dir = PATH_SMARTY_C;
$this->cache_dir = PATH_SMARTY_CACHE;
$this->config_dir = PATH_THIRDPARTY . 'smarty/configs';
$this->caching = false;
// register the resource name "db"
$this->templateFile = $templateFile;
}
/**
* Function printTemplate
*
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public
* @param string form
* @param string target
* @return string
*/
public function printTemplate (&$form, $target = 'smarty')
{
if (strcasecmp( $target, 'smarty' ) === 0) {
$varPrefix = '$';
}
if (strcasecmp( $target, 'templatePower' ) === 0) {
$varPrefix = '';
}
$ft = new StdClass();
foreach ($form as $name => $value) {
if (($name !== 'fields') && ($value !== '')) {
$ft->{$name} = '{$form_' . $name . '}';
}
if ($name === 'cols') {
$ft->{$name} = $value;
}
if ($name === 'owner') {
$ft->owner = & $form->owner;
}
if ($name === 'deleteRow') {
$ft->deleteRow = $form->deleteRow;
}
if ($name === 'addRow') {
$ft->addRow = $form->addRow;
}
if ($name === 'editRow') {
$ft->editRow = $form->editRow;
}
}
if (! isset( $ft->action )) {
$ft->action = '{$form_action}';
}
$hasRequiredFields = false;
foreach ($form->fields as $k => $v) {
$ft->fields[$k] = $v->cloneObject();
$ft->fields[$k]->label = '{' . $varPrefix . $k . '}';
if ($form->type === 'grid') {
if (strcasecmp( $target, 'smarty' ) === 0) {
$ft->fields[$k]->field = '{' . $varPrefix . 'form.' . $k . '[row]}';
}
if (strcasecmp( $target, 'templatePower' ) === 0) {
$ft->fields[$k]->field = '{' . $varPrefix . 'form[' . $k . '][row]}';
}
} else {
if (strcasecmp( $target, 'smarty' ) === 0) {
$ft->fields[$k]->field = '{' . $varPrefix . 'form.' . $k . '}';
}
if (strcasecmp( $target, 'templatePower' ) === 0) {
$ft->fields[$k]->field = '{' . $varPrefix . 'form[' . $k . ']}';
}
}
$hasRequiredFields = $hasRequiredFields | (isset( $v->required ) && ($v->required == '1') && ($v->mode == 'edit'));
if ($v->type == 'xmlmenu') {
$menu = $v;
}
}
if (isset( $menu )) {
if (isset( $menu->owner->values['__DYNAFORM_OPTIONS']['PREVIOUS_STEP'] )) {
$prevStep_url = $menu->owner->values['__DYNAFORM_OPTIONS']['PREVIOUS_STEP'];
$this->assign( 'prevStep_url', $prevStep_url );
$this->assign( 'prevStep_label', G::loadTranslation( 'ID_BACK' ) );
}
}
$this->assign( 'hasRequiredFields', $hasRequiredFields );
$this->assign( 'form', $ft );
$this->assign( 'printTemplate', true );
$this->assign( 'printJSFile', false );
$this->assign( 'printJavaScript', false );
//$this->assign ( 'dynaformSetFocus', "try {literal}{{/literal} dynaformSetFocus();}catch(e){literal}{{/literal}}" );
return $this->fetch( $this->templateFile );
}
/**
* Function printJavaScript
*
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public
* @param string form
* @return string
*/
public function printJavaScript (&$form)
{
$this->assign( 'form', $form );
$this->assign( 'printTemplate', false );
$this->assign( 'printJSFile', false );
$this->assign( 'printJavaScript', true );
return $this->fetch( $this->templateFile );
}
/**
* Function printJSFile
*
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public
* @param string form
* @return string
*/
public function printJSFile (&$form)
{
//JS designer>preview
if (isset($_SERVER["HTTP_REFERER"]) && !empty($_SERVER["HTTP_REFERER"]) && preg_match("/^.*dynaforms_Editor\?.*PRO_UID=.*DYN_UID=.*$/", $_SERVER["HTTP_REFERER"]) && preg_match("/^.*dynaforms\/dynaforms_Ajax.*$/", $_SERVER["REQUEST_URI"])) {
$js = null;
foreach ($form->fields as $index => $value) {
$field = $value;
if ($field->type == "javascript" && !empty($field->code)) {
$js = $js . " " . $field->code;
}
}
if ($js != null) {
$form->jsDesignerPreview = "
//JS designer>preview
$js
loadForm_" . $form->id . "(\"../gulliver/defaultAjaxDynaform\");
if (typeof(dynaformOnload) != \"undefined\") {
dynaformOnload();
}
";
}
}
$this->assign( 'form', $form );
$this->assign( 'printTemplate', false );
$this->assign( 'printJSFile', true );
$this->assign( 'printJavaScript', false );
return $this->fetch( $this->templateFile );
}
/**
* Function getFields
*
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public
* @param string form
* @return string
*/
public function getFields (&$form, $therow = -1)
{
$result = array ();
foreach ($form->fields as $k => $v) {
$field = $v;
if ($form->mode != '') {
#@ last modification: erik
$field->mode = $form->mode; #@
} #@
//if (isset($form->fields[$k]->sql)) $form->fields[$k]->executeSQL( $form );
$value = (isset( $form->values[$k] )) ? $form->values[$k] : null;
$result[$k] = G::replaceDataField( $form->fields[$k]->label, $form->values );
if ($form->type == 'xmlform') {
if (in_array($field->type, array("text", "currency", "percentage", "password", "suggest", "textarea", "dropdown", "yesno", "listbox", "checkbox", "date", "link", "file"))) {
$result[$k] = '<label for="form[' . $k . ']">' . $result[$k] . '</label>';
}
}
if (! is_array( $value )) {
if ($form->type == 'grid') {
$aAux = array ();
if (!isset($form->values[$form->name])) {
$form->values[$form->name] = array();
}
if ($therow == - 1) {
for ($i = 0; $i < count( $form->values[$form->name] ); $i ++) {
$aAux[] = '';
}
} else {
for ($i = 0; $i < $therow; $i ++) {
$aAux[] = '';
}
}
switch ($field->type) {
case "link":
$result["form"][$k] = $form->fields[$k]->renderGrid($aAux, array(), $form);
break;
default:
$result["form"][$k] = $form->fields[$k]->renderGrid($aAux, $form);
break;
}
} else {
switch ($field->type) {
case "link":
$result["form"][$k] = $form->fields[$k]->render(
$value,
(isset($form->values[$k . "_label"]))? $form->values[$k . "_label"] : null,
$form
);
break;
default:
$result["form"][$k] = $form->fields[$k]->render($value, $form);
break;
}
}
} else {
/*if (isset ( $form->owner )) {
if (count ( $value ) < count ( $form->owner->values [$form->name] )) {
$i = count ( $value );
$j = count ( $form->owner->values [$form->name] );
for($i; $i < $j; $i ++) {
$value [] = '';
}
}
}*/
if ($field->type == "grid") {
// Fix data for grids
if (is_array($form->fields[$k]->fields)) {
foreach ($form->fields[$k]->fields as $gridFieldName => $gridField) {
$valueLength = count($value);
for ($i = 1; $i <= $valueLength; $i++) {
if (!isset($value[$i][$gridFieldName])) {
switch ($gridField->type) {
case 'checkbox':
$defaultAttribute = 'falseValue';
break;
default:
$defaultAttribute = 'defaultValue';
break;
}
$value[$i][$gridFieldName] = isset($gridField->$defaultAttribute) ? $gridField->$defaultAttribute : '';
}
}
}
}
$form->fields[$k]->setScrollStyle( $form );
$result["form"][$k] = $form->fields[$k]->renderGrid( $value, $form, $therow );
} else {
switch ($field->type) {
case "dropdown":
$result["form"][$k] = $form->fields[$k]->renderGrid( $value, $form, false, $therow );
break;
case "file":
$result["form"][$k] = $form->fields[$k]->renderGrid( $value, $form, $therow );
break;
case "link":
$result["form"][$k] = $form->fields[$k]->renderGrid(
$value,
(isset($form->values[$k . "_label"]))? $form->values[$k . "_label"] : array(),
$form
);
break;
default:
$result["form"][$k] = $form->fields[$k]->renderGrid( $value, $form );
break;
}
}
}
}
foreach ($form as $name => $value) {
if ($name !== 'fields') {
$result['form_' . $name] = $value;
}
}
return $result;
}
/**
* Function printObject
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public
* @param string form
* @return string
*/
public function printObject(&$form, $therow = -1)
{
//to do: generate the template for templatePower.
//DONE: The template was generated in printTemplate, to use it
// is necesary to load the file with templatePower and send the array
//result
$this->register_resource ( 'mem', array (array (&$this, '_get_template' ), array ($this, '_get_timestamp' ), array ($this, '_get_secure' ), array ($this, '_get_trusted' ) ) );
$result = $this->getFields ( $form, $therow );
$this->assign ( array ('PATH_TPL' => PATH_TPL ) );
$this->assign ( $result );
if ( defined('SYS_LANG_DIRECTION') && SYS_LANG_DIRECTION == 'R' ) {
switch( $form->type ){
case 'toolbar':
$form->align = 'right';
break;
}
}
$this->assign ( array ('_form' => $form ) );
//'mem:defaultTemplate'.$form->name obtains the template generated for the
//current "form" object, then this resource y saved by Smarty in the
//cache_dir. To avoiding troubles when two forms with the same id are being
//drawed in a same page with different templates, add an . rand(1,1000)
//to the resource name. This is because the process of creating templates
//(with the method "printTemplate") and painting takes less than 1 second
//so the new template resource generally will had the same timestamp.
$output = $this->fetch ( 'mem:defaultTemplate' . $form->name );
return $output;
}
/**
* Smarty plugin
* -------------------------------------------------------------
* Type: resource
* Name: mem
* Purpose: Fetches templates from this object
* -------------------------------------------------------------
*/
public function _get_template($tpl_name, &$tpl_source, &$smarty_obj)
{
$tpl_source = $this->template;
return true;
}
/**
* Function _get_timestamp
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public
* @param string tpl_name
* @param string tpl_timestamp
* @param string smarty_obj
* @return string
*/
public function _get_timestamp($tpl_name, &$tpl_timestamp, &$smarty_obj)
{
//NOTE: +1 prevents to load the smarty cache instead of this resource
$tpl_timestamp = time () + 1;
return true;
}
/**
* Function _get_secure
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public
* @param string tpl_name
* @param string smarty_obj
* @return string
*/
public function _get_secure($tpl_name, &$smarty_obj)
{
// assume all templates are secure
return true;
}
/**
* Function _get_trusted
* @author David S. Callizaya S. <davidsantos@colosa.com>
* @access public
* @param string tpl_name
* @param string smarty_obj
* @return string
*/
public function _get_trusted($tpl_name, &$smarty_obj)
{
// not used for templates
}
} | BathnesDevelopment/processmaker-3.1.2.b2-community | gulliver/system/class.xmlformTemplate.php | PHP | agpl-3.0 | 15,101 |
#!/usr/bin/perl
# --
# bin/fcgi-bin/public.pl - the global FastCGI handle file for OTRS
# Copyright (C) 2001-2015 OTRS AG, http://otrs.com/
# --
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU AFFERO General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# 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 Affero General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# or see http://www.gnu.org/licenses/agpl.txt.
# --
use strict;
use warnings;
# use ../../ as lib location
use FindBin qw($Bin);
use lib "$Bin/../..";
use lib "$Bin/../../Kernel/cpan-lib";
use lib "$Bin/../../Custom";
# Imports the library; required line
use CGI::Fast;
# load agent web interface
use Kernel::System::Web::InterfacePublic();
use Kernel::System::ObjectManager;
# 0=off;1=on;
my $Debug = 0;
#my $Cnt = 0;
# Response loop
while ( my $WebRequest = new CGI::Fast ) {
local $Kernel::OM = Kernel::System::ObjectManager->new();
my $Interface = Kernel::System::Web::InterfacePublic->new(
Debug => $Debug,
WebRequest => $WebRequest,
);
$Interface->Run();
# $Cnt++;
# print STDERR "This is connection number $Cnt\n";
}
| oiami/otrs | bin/fcgi-bin/public.pl | Perl | agpl-3.0 | 1,626 |
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
{
'name': 'Gengo Translator',
'category': 'Website/Website',
'summary': 'Translate website in one-click',
'description': """
This module allows to send website content to Gengo translation service in a single click. Gengo then gives back the translated terms in the destination language.
""",
'depends': [
'website',
'base_gengo'
],
'data': [
'views/website_gengo_templates.xml',
]
}
| ddico/odoo | addons/website_gengo/__manifest__.py | Python | agpl-3.0 | 544 |
<?php
/*
* This file is part of the ONGR package.
*
* (c) NFQ Technologies UAB <info@nfq.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace ONGR\ElasticsearchDSL\Tests\Unit\DSL\Aggregation;
use ONGR\ElasticsearchDSL\Aggregation\ChildrenAggregation;
/**
* Unit test for children aggregation.
*/
class ChildrenAggregationTest extends \PHPUnit_Framework_TestCase
{
/**
* Tests if ChildrenAggregation#getArray throws exception when expected.
*
* @expectedException \LogicException
*/
public function testGetArrayException()
{
$aggregation = new ChildrenAggregation('foo');
$aggregation->getArray();
}
/**
* Tests getType method.
*/
public function testChildrenAggregationGetType()
{
$aggregation = new ChildrenAggregation('foo');
$result = $aggregation->getType();
$this->assertEquals('children', $result);
}
/**
* Tests getArray method.
*/
public function testChildrenAggregationGetArray()
{
$mock = $this->getMockBuilder('ONGR\ElasticsearchDSL\Aggregation\AbstractAggregation')
->disableOriginalConstructor()
->getMockForAbstractClass();
$aggregation = new ChildrenAggregation('foo');
$aggregation->addAggregation($mock);
$aggregation->setChildren('question');
$result = $aggregation->getArray();
$expected = ['type' => 'question'];
$this->assertEquals($expected, $result);
}
}
| GerDner/luck-docker | vendor/ongr/elasticsearch-dsl/tests/Aggregation/ChildrenAggregationTest.php | PHP | agpl-3.0 | 1,593 |
<?php
class WSLiveReportInputPager extends WSBaseObject
{
function getKalturaObject() {
return null;
}
/**
* @var int
**/
public $pageSize;
/**
* @var int
**/
public $pageIndex;
public function WSLiveReportInputPager($pageSize, $pageIndex) {
$this->pageSize = $pageSize;
$this->pageIndex = $pageIndex;
}
}
| ivesbai/server | api_v3/lib/types/liveReports/soap/WSLiveReportInputPager.class.php | PHP | agpl-3.0 | 343 |
<?php
/**
* HtmlHelperTest file
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2011, Cake Software Foundation, Inc.
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc.
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @package Cake.Test.Case.View.Helper
* @since CakePHP(tm) v 1.2.0.4206
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('Controller', 'Controller');
App::uses('Helper', 'View');
App::uses('AppHelper', 'View/Helper');
App::uses('HtmlHelper', 'View/Helper');
App::uses('FormHelper', 'View/Helper');
App::uses('ClassRegistry', 'Utility');
App::uses('Folder', 'Utility');
if (!defined('FULL_BASE_URL')) {
define('FULL_BASE_URL', 'http://cakephp.org');
}
/**
* TheHtmlTestController class
*
* @package Cake.Test.Case.View.Helper
*/
class TheHtmlTestController extends Controller {
/**
* name property
*
* @var string 'TheTest'
*/
public $name = 'TheTest';
/**
* uses property
*
* @var mixed null
*/
public $uses = null;
}
class TestHtmlHelper extends HtmlHelper {
/**
* expose a method as public
*
* @param string $options
* @param string $exclude
* @param string $insertBefore
* @param string $insertAfter
* @return void
*/
public function parseAttributes($options, $exclude = null, $insertBefore = ' ', $insertAfter = null) {
return $this->_parseAttributes($options, $exclude, $insertBefore, $insertAfter);
}
/**
* Get a protected attribute value
*
* @param string $attribute
* @return mixed
*/
public function getAttribute($attribute) {
if (!isset($this->{$attribute})) {
return null;
}
return $this->{$attribute};
}
}
/**
* Html5TestHelper class
*
* @package Cake.Test.Case.View.Helper
*/
class Html5TestHelper extends TestHtmlHelper {
/**
* Minimized
*
* @var array
*/
protected $_minimizedAttributes = array('require', 'checked');
/**
* Allow compact use in HTML
*
* @var string
*/
protected $_minimizedAttributeFormat = '%s';
/**
* Test to attribute format
*
* @var string
*/
protected $_attributeFormat = 'data-%s="%s"';
}
/**
* HtmlHelperTest class
*
* @package Cake.Test.Case.View.Helper
*/
class HtmlHelperTest extends CakeTestCase {
/**
* Regexp for CDATA start block
*
* @var string
*/
public $cDataStart = 'preg:/^\/\/<!\[CDATA\[[\n\r]*/';
/**
* Regexp for CDATA end block
*
* @var string
*/
public $cDataEnd = 'preg:/[^\]]*\]\]\>[\s\r\n]*/';
/**
* html property
*
* @var object
*/
public $Html = null;
/**
* setUp method
*
* @return void
*/
public function setUp() {
parent::setUp();
$this->View = $this->getMock('View', array('addScript'), array(new TheHtmlTestController()));
$this->Html = new TestHtmlHelper($this->View);
$this->Html->request = new CakeRequest(null, false);
$this->Html->request->webroot = '';
Configure::write('Asset.timestamp', false);
}
/**
* tearDown method
*
* @return void
*/
public function tearDown() {
parent::tearDown();
unset($this->Html, $this->View);
}
/**
* testDocType method
*
* @return void
*/
public function testDocType() {
$result = $this->Html->docType();
$expected = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
$this->assertEquals($expected, $result);
$result = $this->Html->docType('html4-strict');
$expected = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">';
$this->assertEquals($expected, $result);
$this->assertNull($this->Html->docType('non-existing-doctype'));
}
/**
* testLink method
*
* @return void
*/
public function testLink() {
Router::connect('/:controller/:action/*');
$this->Html->request->webroot = '';
$result = $this->Html->link('/home');
$expected = array('a' => array('href' => '/home'), 'preg:/\/home/', '/a');
$this->assertTags($result, $expected);
$result = $this->Html->link(array('action' => 'login', '<[You]>'));
$expected = array(
'a' => array('href' => '/login/%3C%5BYou%5D%3E'),
'preg:/\/login\/<\[You\]>/',
'/a'
);
$this->assertTags($result, $expected);
Router::reload();
$result = $this->Html->link('Posts', array('controller' => 'posts', 'action' => 'index', 'full_base' => true));
$expected = array('a' => array('href' => FULL_BASE_URL . '/posts'), 'Posts', '/a');
$this->assertTags($result, $expected);
$result = $this->Html->link('Home', '/home', array('confirm' => 'Are you sure you want to do this?'));
$expected = array(
'a' => array('href' => '/home', 'onclick' => 'return confirm('Are you sure you want to do this?');'),
'Home',
'/a'
);
$this->assertTags($result, $expected);
$result = $this->Html->link('Home', '/home', array('default' => false));
$expected = array(
'a' => array('href' => '/home', 'onclick' => 'event.returnValue = false; return false;'),
'Home',
'/a'
);
$this->assertTags($result, $expected);
$result = $this->Html->link('Home', '/home', array('default' => false, 'onclick' => 'someFunction();'));
$expected = array(
'a' => array('href' => '/home', 'onclick' => 'someFunction(); event.returnValue = false; return false;'),
'Home',
'/a'
);
$this->assertTags($result, $expected);
$result = $this->Html->link('Next >', '#');
$expected = array(
'a' => array('href' => '#'),
'Next >',
'/a'
);
$this->assertTags($result, $expected);
$result = $this->Html->link('Next >', '#', array('escape' => true));
$expected = array(
'a' => array('href' => '#'),
'Next >',
'/a'
);
$this->assertTags($result, $expected);
$result = $this->Html->link('Next >', '#', array('escape' => 'utf-8'));
$expected = array(
'a' => array('href' => '#'),
'Next >',
'/a'
);
$this->assertTags($result, $expected);
$result = $this->Html->link('Next >', '#', array('escape' => false));
$expected = array(
'a' => array('href' => '#'),
'Next >',
'/a'
);
$this->assertTags($result, $expected);
$result = $this->Html->link('Next >', '#', array(
'title' => 'to escape … or not escape?',
'escape' => false
));
$expected = array(
'a' => array('href' => '#', 'title' => 'to escape … or not escape?'),
'Next >',
'/a'
);
$this->assertTags($result, $expected);
$result = $this->Html->link('Next >', '#', array(
'title' => 'to escape … or not escape?',
'escape' => true
));
$expected = array(
'a' => array('href' => '#', 'title' => 'to escape &#8230; or not escape?'),
'Next >',
'/a'
);
$this->assertTags($result, $expected);
$result = $this->Html->link('Original size', array(
'controller' => 'images', 'action' => 'view', 3, '?' => array('height' => 100, 'width' => 200)
));
$expected = array(
'a' => array('href' => '/images/view/3?height=100&width=200'),
'Original size',
'/a'
);
$this->assertTags($result, $expected);
Configure::write('Asset.timestamp', false);
$result = $this->Html->link($this->Html->image('test.gif'), '#', array('escape' => false));
$expected = array(
'a' => array('href' => '#'),
'img' => array('src' => 'img/test.gif', 'alt' => ''),
'/a'
);
$this->assertTags($result, $expected);
$result = $this->Html->image('test.gif', array('url' => '#'));
$expected = array(
'a' => array('href' => '#'),
'img' => array('src' => 'img/test.gif', 'alt' => ''),
'/a'
);
$this->assertTags($result, $expected);
Configure::write('Asset.timestamp', 'force');
$result = $this->Html->link($this->Html->image('../favicon.ico'), '#', array('escape' => false));
$expected = array(
'a' => array('href' => '#'),
'img' => array('src' => 'preg:/img\/..\/favicon\.ico\?\d*/', 'alt' => ''),
'/a'
);
$this->assertTags($result, $expected);
$result = $this->Html->image('../favicon.ico', array('url' => '#'));
$expected = array(
'a' => array('href' => '#'),
'img' => array('src' => 'preg:/img\/..\/favicon\.ico\?\d*/', 'alt' => ''),
'/a'
);
$this->assertTags($result, $expected);
}
/**
* testImageTag method
*
* @return void
*/
public function testImageTag() {
$this->Html->request->webroot = '';
$result = $this->Html->image('test.gif');
$this->assertTags($result, array('img' => array('src' => 'img/test.gif', 'alt' => '')));
$result = $this->Html->image('http://google.com/logo.gif');
$this->assertTags($result, array('img' => array('src' => 'http://google.com/logo.gif', 'alt' => '')));
$result = $this->Html->image(array('controller' => 'test', 'action' => 'view', 1, 'ext' => 'gif'));
$this->assertTags($result, array('img' => array('src' => '/test/view/1.gif', 'alt' => '')));
$result = $this->Html->image('/test/view/1.gif');
$this->assertTags($result, array('img' => array('src' => '/test/view/1.gif', 'alt' => '')));
}
/**
* test image() with Asset.timestamp
*
* @return void
*/
public function testImageWithTimestampping() {
Configure::write('Asset.timestamp', 'force');
$this->Html->request->webroot = '/';
$result = $this->Html->image('cake.icon.png');
$this->assertTags($result, array('img' => array('src' => 'preg:/\/img\/cake\.icon\.png\?\d+/', 'alt' => '')));
Configure::write('debug', 0);
Configure::write('Asset.timestamp', 'force');
$result = $this->Html->image('cake.icon.png');
$this->assertTags($result, array('img' => array('src' => 'preg:/\/img\/cake\.icon\.png\?\d+/', 'alt' => '')));
$this->Html->request->webroot = '/testing/longer/';
$result = $this->Html->image('cake.icon.png');
$expected = array(
'img' => array('src' => 'preg:/\/testing\/longer\/img\/cake\.icon\.png\?[0-9]+/', 'alt' => '')
);
$this->assertTags($result, $expected);
}
/**
* Tests creation of an image tag using a theme and asset timestamping
*
* @return void
*/
public function testImageTagWithTheme() {
$this->skipIf(!is_writable(WWW_ROOT), 'Cannot write to webroot.');
$themeExists = is_dir(WWW_ROOT . 'theme');
App::uses('File', 'Utility');
$testfile = WWW_ROOT . 'theme' . DS . 'test_theme' . DS . 'img' . DS . '__cake_test_image.gif';
$File = new File($testfile, true);
App::build(array(
'views' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
));
Configure::write('Asset.timestamp', true);
Configure::write('debug', 1);
$this->Html->request->webroot = '/';
$this->Html->theme = 'test_theme';
$result = $this->Html->image('__cake_test_image.gif');
$this->assertTags($result, array(
'img' => array(
'src' => 'preg:/\/theme\/test_theme\/img\/__cake_test_image\.gif\?\d+/',
'alt' => ''
)));
$this->Html->request->webroot = '/testing/';
$result = $this->Html->image('__cake_test_image.gif');
$this->assertTags($result, array(
'img' => array(
'src' => 'preg:/\/testing\/theme\/test_theme\/img\/__cake_test_image\.gif\?\d+/',
'alt' => ''
)));
$dir = new Folder(WWW_ROOT . 'theme' . DS . 'test_theme');
$dir->delete();
if (!$themeExists) {
$dir = new Folder(WWW_ROOT . 'theme');
$dir->delete();
}
}
/**
* test theme assets in main webroot path
*
* @return void
*/
public function testThemeAssetsInMainWebrootPath() {
App::build(array(
'views' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
));
$webRoot = Configure::read('App.www_root');
Configure::write('App.www_root', CAKE . 'Test' . DS . 'test_app' . DS . 'webroot' . DS);
$this->Html->theme = 'test_theme';
$result = $this->Html->css('webroot_test');
$expected = array(
'link' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => 'preg:/.*theme\/test_theme\/css\/webroot_test\.css/')
);
$this->assertTags($result, $expected);
$this->Html->theme = 'test_theme';
$result = $this->Html->css('theme_webroot');
$expected = array(
'link' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => 'preg:/.*theme\/test_theme\/css\/theme_webroot\.css/')
);
$this->assertTags($result, $expected);
Configure::write('App.www_root', $webRoot);
}
/**
* testStyle method
*
* @return void
*/
public function testStyle() {
$result = $this->Html->style('display: none;');
$this->assertEquals($result, 'display: none;');
$result = $this->Html->style(array('display' => 'none', 'margin' => '10px'));
$expected = 'display:none; margin:10px;';
$this->assertRegExp('/^display\s*:\s*none\s*;\s*margin\s*:\s*10px\s*;?$/', $expected);
$result = $this->Html->style(array('display' => 'none', 'margin' => '10px'), false);
$lines = explode("\n", $result);
$this->assertRegExp('/^\s*display\s*:\s*none\s*;\s*$/', $lines[0]);
$this->assertRegExp('/^\s*margin\s*:\s*10px\s*;?$/', $lines[1]);
}
/**
* testCssLink method
*
* @return void
*/
public function testCssLink() {
Configure::write('Asset.filter.css', false);
$result = $this->Html->css('screen');
$expected = array(
'link' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => 'preg:/.*css\/screen\.css/')
);
$this->assertTags($result, $expected);
$result = $this->Html->css('screen.css');
$this->assertTags($result, $expected);
$result = $this->Html->css('my.css.library');
$expected['link']['href'] = 'preg:/.*css\/my\.css\.library\.css/';
$this->assertTags($result, $expected);
$result = $this->Html->css('screen.css?1234');
$expected['link']['href'] = 'preg:/.*css\/screen\.css\?1234/';
$this->assertTags($result, $expected);
$result = $this->Html->css('http://whatever.com/screen.css?1234');
$expected['link']['href'] = 'preg:/http:\/\/.*\/screen\.css\?1234/';
$this->assertTags($result, $expected);
Configure::write('Asset.filter.css', 'css.php');
$result = $this->Html->css('cake.generic');
$expected['link']['href'] = 'preg:/.*ccss\/cake\.generic\.css/';
$this->assertTags($result, $expected);
$result = $this->Html->css('//example.com/css/cake.generic.css');
$expected['link']['href'] = 'preg:/.*example\.com\/css\/cake\.generic\.css/';
$this->assertTags($result, $expected);
Configure::write('Asset.filter.css', false);
$result = explode("\n", trim($this->Html->css(array('cake.generic', 'vendor.generic'))));
$expected['link']['href'] = 'preg:/.*css\/cake\.generic\.css/';
$this->assertTags($result[0], $expected);
$expected['link']['href'] = 'preg:/.*css\/vendor\.generic\.css/';
$this->assertTags($result[1], $expected);
$this->assertEquals(count($result), 2);
$this->View->expects($this->at(0))->method('addScript')
->with($this->matchesRegularExpression('/css_in_head.css/'));
$this->View->expects($this->at(1))
->method('addScript')
->with($this->matchesRegularExpression('/more_css_in_head.css/'));
$result = $this->Html->css('css_in_head', null, array('inline' => false));
$this->assertNull($result);
$result = $this->Html->css('more_css_in_head', null, array('inline' => false));
$this->assertNull($result);
}
/**
* test use of css() and timestamping
*
* @return void
*/
public function testCssTimestamping() {
Configure::write('debug', 2);
Configure::write('Asset.timestamp', true);
$expected = array(
'link' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => '')
);
$result = $this->Html->css('cake.generic');
$expected['link']['href'] = 'preg:/.*css\/cake\.generic\.css\?[0-9]+/';
$this->assertTags($result, $expected);
Configure::write('debug', 0);
$result = $this->Html->css('cake.generic');
$expected['link']['href'] = 'preg:/.*css\/cake\.generic\.css/';
$this->assertTags($result, $expected);
Configure::write('Asset.timestamp', 'force');
$result = $this->Html->css('cake.generic');
$expected['link']['href'] = 'preg:/.*css\/cake\.generic\.css\?[0-9]+/';
$this->assertTags($result, $expected);
$this->Html->request->webroot = '/testing/';
$result = $this->Html->css('cake.generic');
$expected['link']['href'] = 'preg:/\/testing\/css\/cake\.generic\.css\?[0-9]+/';
$this->assertTags($result, $expected);
$this->Html->request->webroot = '/testing/longer/';
$result = $this->Html->css('cake.generic');
$expected['link']['href'] = 'preg:/\/testing\/longer\/css\/cake\.generic\.css\?[0-9]+/';
$this->assertTags($result, $expected);
}
/**
* test timestamp enforcement for script tags.
*
* @return void
*/
public function testScriptTimestamping() {
$this->skipIf(!is_writable(JS), 'webroot/js is not Writable, timestamp testing has been skipped.');
Configure::write('debug', 2);
Configure::write('Asset.timestamp', true);
touch(WWW_ROOT . 'js' . DS . '__cake_js_test.js');
$timestamp = substr(strtotime('now'), 0, 8);
$result = $this->Html->script('__cake_js_test', array('inline' => true, 'once' => false));
$this->assertRegExp('/__cake_js_test.js\?' . $timestamp . '[0-9]{2}"/', $result, 'Timestamp value not found %s');
Configure::write('debug', 0);
Configure::write('Asset.timestamp', 'force');
$result = $this->Html->script('__cake_js_test', array('inline' => true, 'once' => false));
$this->assertRegExp('/__cake_js_test.js\?' . $timestamp . '[0-9]{2}"/', $result, 'Timestamp value not found %s');
unlink(WWW_ROOT . 'js' . DS . '__cake_js_test.js');
Configure::write('Asset.timestamp', false);
}
/**
* test that scripts added with uses() are only ever included once.
* test script tag generation
*
* @return void
*/
public function testScript() {
$result = $this->Html->script('foo');
$expected = array(
'script' => array('type' => 'text/javascript', 'src' => 'js/foo.js')
);
$this->assertTags($result, $expected);
$result = $this->Html->script(array('foobar', 'bar'));
$expected = array(
array('script' => array('type' => 'text/javascript', 'src' => 'js/foobar.js')),
'/script',
array('script' => array('type' => 'text/javascript', 'src' => 'js/bar.js')),
'/script',
);
$this->assertTags($result, $expected);
$result = $this->Html->script('jquery-1.3');
$expected = array(
'script' => array('type' => 'text/javascript', 'src' => 'js/jquery-1.3.js')
);
$this->assertTags($result, $expected);
$result = $this->Html->script('test.json');
$expected = array(
'script' => array('type' => 'text/javascript', 'src' => 'js/test.json.js')
);
$this->assertTags($result, $expected);
$result = $this->Html->script('http://example.com/test.json');
$expected = array(
'script' => array('type' => 'text/javascript', 'src' => 'http://example.com/test.json')
);
$this->assertTags($result, $expected);
$result = $this->Html->script('/plugin/js/jquery-1.3.2.js?someparam=foo');
$expected = array(
'script' => array('type' => 'text/javascript', 'src' => '/plugin/js/jquery-1.3.2.js?someparam=foo')
);
$this->assertTags($result, $expected);
$result = $this->Html->script('test.json.js?foo=bar');
$expected = array(
'script' => array('type' => 'text/javascript', 'src' => 'js/test.json.js?foo=bar')
);
$this->assertTags($result, $expected);
$result = $this->Html->script('foo');
$this->assertNull($result, 'Script returned upon duplicate inclusion %s');
$result = $this->Html->script(array('foo', 'bar', 'baz'));
$this->assertNotRegExp('/foo.js/', $result);
$result = $this->Html->script('foo', array('inline' => true, 'once' => false));
$this->assertNotNull($result);
$result = $this->Html->script('jquery-1.3.2', array('defer' => true, 'encoding' => 'utf-8'));
$expected = array(
'script' => array('type' => 'text/javascript', 'src' => 'js/jquery-1.3.2.js', 'defer' => 'defer', 'encoding' => 'utf-8')
);
$this->assertTags($result, $expected);
$this->View->expects($this->any())->method('addScript')
->with($this->matchesRegularExpression('/script_in_head.js/'));
$result = $this->Html->script('script_in_head', array('inline' => false));
$this->assertNull($result);
}
/**
* Test that Asset.filter.js works.
*
* @return void
*/
function testScriptAssetFilter() {
Configure::write('Asset.filter.js', 'js.php');
$result = $this->Html->script('jquery-1.3');
$expected = array(
'script' => array('type' => 'text/javascript', 'src' => 'cjs/jquery-1.3.js')
);
$this->assertTags($result, $expected);
$result = $this->Html->script('//example.com/js/jquery-1.3.js');
$expected = array(
'script' => array('type' => 'text/javascript', 'src' => '//example.com/js/jquery-1.3.js')
);
$this->assertTags($result, $expected);
}
/**
* test a script file in the webroot/theme dir.
*
* @return void
*/
public function testScriptInTheme() {
$this->skipIf(!is_writable(WWW_ROOT), 'Cannot write to webroot.');
$themeExists = is_dir(WWW_ROOT . 'theme');
App::uses('File', 'Utility');
$testfile = WWW_ROOT . 'theme' . DS . 'test_theme' . DS . 'js' . DS . '__test_js.js';
$File = new File($testfile, true);
App::build(array(
'views' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
));
$this->Html->webroot = '/';
$this->Html->theme = 'test_theme';
$result = $this->Html->script('__test_js.js');
$expected = array(
'script' => array('src' => '/theme/test_theme/js/__test_js.js', 'type' => 'text/javascript')
);
$this->assertTags($result, $expected);
$Folder = new Folder(WWW_ROOT . 'theme' . DS . 'test_theme');
$Folder->delete();
if (!$themeExists) {
$dir = new Folder(WWW_ROOT . 'theme');
$dir->delete();
}
}
/**
* test Script block generation
*
* @return void
*/
public function testScriptBlock() {
$result = $this->Html->scriptBlock('window.foo = 2;');
$expected = array(
'script' => array('type' => 'text/javascript'),
$this->cDataStart,
'window.foo = 2;',
$this->cDataEnd,
'/script',
);
$this->assertTags($result, $expected);
$result = $this->Html->scriptBlock('window.foo = 2;', array('safe' => false));
$expected = array(
'script' => array('type' => 'text/javascript'),
'window.foo = 2;',
'/script',
);
$this->assertTags($result, $expected);
$result = $this->Html->scriptBlock('window.foo = 2;', array('safe' => true));
$expected = array(
'script' => array('type' => 'text/javascript'),
$this->cDataStart,
'window.foo = 2;',
$this->cDataEnd,
'/script',
);
$this->assertTags($result, $expected);
$this->View->expects($this->any())->method('addScript')
->with($this->matchesRegularExpression('/window\.foo\s\=\s2;/'));
$result = $this->Html->scriptBlock('window.foo = 2;', array('inline' => false));
$this->assertNull($result);
$result = $this->Html->scriptBlock('window.foo = 2;', array('safe' => false, 'encoding' => 'utf-8'));
$expected = array(
'script' => array('type' => 'text/javascript', 'encoding' => 'utf-8'),
'window.foo = 2;',
'/script',
);
$this->assertTags($result, $expected);
}
/**
* test script tag output buffering when using scriptStart() and scriptEnd();
*
* @return void
*/
public function testScriptStartAndScriptEnd() {
$result = $this->Html->scriptStart(array('safe' => true));
$this->assertNull($result);
echo 'this is some javascript';
$result = $this->Html->scriptEnd();
$expected = array(
'script' => array('type' => 'text/javascript'),
$this->cDataStart,
'this is some javascript',
$this->cDataEnd,
'/script'
);
$this->assertTags($result, $expected);
$result = $this->Html->scriptStart(array('safe' => false));
$this->assertNull($result);
echo 'this is some javascript';
$result = $this->Html->scriptEnd();
$expected = array(
'script' => array('type' => 'text/javascript'),
'this is some javascript',
'/script'
);
$this->assertTags($result, $expected);
$this->View->expects($this->once())->method('addScript');
$result = $this->Html->scriptStart(array('safe' => false, 'inline' => false));
$this->assertNull($result);
echo 'this is some javascript';
$result = $this->Html->scriptEnd();
$this->assertNull($result);
}
/**
* testCharsetTag method
*
* @return void
*/
public function testCharsetTag() {
Configure::write('App.encoding', null);
$result = $this->Html->charset();
$this->assertTags($result, array('meta' => array('http-equiv' => 'Content-Type', 'content' => 'text/html; charset=utf-8')));
Configure::write('App.encoding', 'ISO-8859-1');
$result = $this->Html->charset();
$this->assertTags($result, array('meta' => array('http-equiv' => 'Content-Type', 'content' => 'text/html; charset=iso-8859-1')));
$result = $this->Html->charset('UTF-7');
$this->assertTags($result, array('meta' => array('http-equiv' => 'Content-Type', 'content' => 'text/html; charset=UTF-7')));
}
/**
* testBreadcrumb method
*
* @return void
*/
public function testBreadcrumb() {
$this->assertNull($this->Html->getCrumbs());
$this->Html->addCrumb('First', '#first');
$this->Html->addCrumb('Second', '#second');
$this->Html->addCrumb('Third', '#third');
$result = $this->Html->getCrumbs();
$expected = array(
array('a' => array('href' => '#first')),
'First',
'/a',
'»',
array('a' => array('href' => '#second')),
'Second',
'/a',
'»',
array('a' => array('href' => '#third')),
'Third',
'/a',
);
$this->assertTags($result, $expected);
$result = $this->Html->getCrumbs(' > ');
$expected = array(
array('a' => array('href' => '#first')),
'First',
'/a',
' > ',
array('a' => array('href' => '#second')),
'Second',
'/a',
' > ',
array('a' => array('href' => '#third')),
'Third',
'/a',
);
$this->assertTags($result, $expected);
$this->assertRegExp('/^<a[^<>]+>First<\/a> > <a[^<>]+>Second<\/a> > <a[^<>]+>Third<\/a>$/', $result);
$this->assertRegExp('/<a\s+href=["\']+\#first["\']+[^<>]*>First<\/a>/', $result);
$this->assertRegExp('/<a\s+href=["\']+\#second["\']+[^<>]*>Second<\/a>/', $result);
$this->assertRegExp('/<a\s+href=["\']+\#third["\']+[^<>]*>Third<\/a>/', $result);
$this->assertNotRegExp('/<a[^<>]+[^href]=[^<>]*>/', $result);
$this->Html->addCrumb('Fourth', null);
$result = $this->Html->getCrumbs();
$expected = array(
array('a' => array('href' => '#first')),
'First',
'/a',
'»',
array('a' => array('href' => '#second')),
'Second',
'/a',
'»',
array('a' => array('href' => '#third')),
'Third',
'/a',
'»',
'Fourth'
);
$this->assertTags($result, $expected);
$result = $this->Html->getCrumbs('-', 'Start');
$expected = array(
array('a' => array('href' => '/')),
'Start',
'/a',
'-',
array('a' => array('href' => '#first')),
'First',
'/a',
'-',
array('a' => array('href' => '#second')),
'Second',
'/a',
'-',
array('a' => array('href' => '#third')),
'Third',
'/a',
'-',
'Fourth'
);
$this->assertTags($result, $expected);
}
/**
* testNestedList method
*
* @return void
*/
public function testNestedList() {
$list = array(
'Item 1',
'Item 2' => array(
'Item 2.1'
),
'Item 3',
'Item 4' => array(
'Item 4.1',
'Item 4.2',
'Item 4.3' => array(
'Item 4.3.1',
'Item 4.3.2'
)
),
'Item 5' => array(
'Item 5.1',
'Item 5.2'
)
);
$result = $this->Html->nestedList($list);
$expected = array(
'<ul',
'<li', 'Item 1', '/li',
'<li', 'Item 2',
'<ul', '<li', 'Item 2.1', '/li', '/ul',
'/li',
'<li', 'Item 3', '/li',
'<li', 'Item 4',
'<ul',
'<li', 'Item 4.1', '/li',
'<li', 'Item 4.2', '/li',
'<li', 'Item 4.3',
'<ul',
'<li', 'Item 4.3.1', '/li',
'<li', 'Item 4.3.2', '/li',
'/ul',
'/li',
'/ul',
'/li',
'<li', 'Item 5',
'<ul',
'<li', 'Item 5.1', '/li',
'<li', 'Item 5.2', '/li',
'/ul',
'/li',
'/ul'
);
$this->assertTags($result, $expected);
$result = $this->Html->nestedList($list, null);
$expected = array(
'<ul',
'<li', 'Item 1', '/li',
'<li', 'Item 2',
'<ul', '<li', 'Item 2.1', '/li', '/ul',
'/li',
'<li', 'Item 3', '/li',
'<li', 'Item 4',
'<ul',
'<li', 'Item 4.1', '/li',
'<li', 'Item 4.2', '/li',
'<li', 'Item 4.3',
'<ul',
'<li', 'Item 4.3.1', '/li',
'<li', 'Item 4.3.2', '/li',
'/ul',
'/li',
'/ul',
'/li',
'<li', 'Item 5',
'<ul',
'<li', 'Item 5.1', '/li',
'<li', 'Item 5.2', '/li',
'/ul',
'/li',
'/ul'
);
$this->assertTags($result, $expected);
$result = $this->Html->nestedList($list, array(), array(), 'ol');
$expected = array(
'<ol',
'<li', 'Item 1', '/li',
'<li', 'Item 2',
'<ol', '<li', 'Item 2.1', '/li', '/ol',
'/li',
'<li', 'Item 3', '/li',
'<li', 'Item 4',
'<ol',
'<li', 'Item 4.1', '/li',
'<li', 'Item 4.2', '/li',
'<li', 'Item 4.3',
'<ol',
'<li', 'Item 4.3.1', '/li',
'<li', 'Item 4.3.2', '/li',
'/ol',
'/li',
'/ol',
'/li',
'<li', 'Item 5',
'<ol',
'<li', 'Item 5.1', '/li',
'<li', 'Item 5.2', '/li',
'/ol',
'/li',
'/ol'
);
$this->assertTags($result, $expected);
$result = $this->Html->nestedList($list, 'ol');
$expected = array(
'<ol',
'<li', 'Item 1', '/li',
'<li', 'Item 2',
'<ol', '<li', 'Item 2.1', '/li', '/ol',
'/li',
'<li', 'Item 3', '/li',
'<li', 'Item 4',
'<ol',
'<li', 'Item 4.1', '/li',
'<li', 'Item 4.2', '/li',
'<li', 'Item 4.3',
'<ol',
'<li', 'Item 4.3.1', '/li',
'<li', 'Item 4.3.2', '/li',
'/ol',
'/li',
'/ol',
'/li',
'<li', 'Item 5',
'<ol',
'<li', 'Item 5.1', '/li',
'<li', 'Item 5.2', '/li',
'/ol',
'/li',
'/ol'
);
$this->assertTags($result, $expected);
$result = $this->Html->nestedList($list, array('class' => 'list'));
$expected = array(
array('ul' => array('class' => 'list')),
'<li', 'Item 1', '/li',
'<li', 'Item 2',
array('ul' => array('class' => 'list')), '<li', 'Item 2.1', '/li', '/ul',
'/li',
'<li', 'Item 3', '/li',
'<li', 'Item 4',
array('ul' => array('class' => 'list')),
'<li', 'Item 4.1', '/li',
'<li', 'Item 4.2', '/li',
'<li', 'Item 4.3',
array('ul' => array('class' => 'list')),
'<li', 'Item 4.3.1', '/li',
'<li', 'Item 4.3.2', '/li',
'/ul',
'/li',
'/ul',
'/li',
'<li', 'Item 5',
array('ul' => array('class' => 'list')),
'<li', 'Item 5.1', '/li',
'<li', 'Item 5.2', '/li',
'/ul',
'/li',
'/ul'
);
$this->assertTags($result, $expected);
$result = $this->Html->nestedList($list, array(), array('class' => 'item'));
$expected = array(
'<ul',
array('li' => array('class' => 'item')), 'Item 1', '/li',
array('li' => array('class' => 'item')), 'Item 2',
'<ul', array('li' => array('class' => 'item')), 'Item 2.1', '/li', '/ul',
'/li',
array('li' => array('class' => 'item')), 'Item 3', '/li',
array('li' => array('class' => 'item')), 'Item 4',
'<ul',
array('li' => array('class' => 'item')), 'Item 4.1', '/li',
array('li' => array('class' => 'item')), 'Item 4.2', '/li',
array('li' => array('class' => 'item')), 'Item 4.3',
'<ul',
array('li' => array('class' => 'item')), 'Item 4.3.1', '/li',
array('li' => array('class' => 'item')), 'Item 4.3.2', '/li',
'/ul',
'/li',
'/ul',
'/li',
array('li' => array('class' => 'item')), 'Item 5',
'<ul',
array('li' => array('class' => 'item')), 'Item 5.1', '/li',
array('li' => array('class' => 'item')), 'Item 5.2', '/li',
'/ul',
'/li',
'/ul'
);
$this->assertTags($result, $expected);
$result = $this->Html->nestedList($list, array(), array('even' => 'even', 'odd' => 'odd'));
$expected = array(
'<ul',
array('li' => array('class' => 'odd')), 'Item 1', '/li',
array('li' => array('class' => 'even')), 'Item 2',
'<ul', array('li' => array('class' => 'odd')), 'Item 2.1', '/li', '/ul',
'/li',
array('li' => array('class' => 'odd')), 'Item 3', '/li',
array('li' => array('class' => 'even')), 'Item 4',
'<ul',
array('li' => array('class' => 'odd')), 'Item 4.1', '/li',
array('li' => array('class' => 'even')), 'Item 4.2', '/li',
array('li' => array('class' => 'odd')), 'Item 4.3',
'<ul',
array('li' => array('class' => 'odd')), 'Item 4.3.1', '/li',
array('li' => array('class' => 'even')), 'Item 4.3.2', '/li',
'/ul',
'/li',
'/ul',
'/li',
array('li' => array('class' => 'odd')), 'Item 5',
'<ul',
array('li' => array('class' => 'odd')), 'Item 5.1', '/li',
array('li' => array('class' => 'even')), 'Item 5.2', '/li',
'/ul',
'/li',
'/ul'
);
$this->assertTags($result, $expected);
$result = $this->Html->nestedList($list, array('class' => 'list'), array('class' => 'item'));
$expected = array(
array('ul' => array('class' => 'list')),
array('li' => array('class' => 'item')), 'Item 1', '/li',
array('li' => array('class' => 'item')), 'Item 2',
array('ul' => array('class' => 'list')), array('li' => array('class' => 'item')), 'Item 2.1', '/li', '/ul',
'/li',
array('li' => array('class' => 'item')), 'Item 3', '/li',
array('li' => array('class' => 'item')), 'Item 4',
array('ul' => array('class' => 'list')),
array('li' => array('class' => 'item')), 'Item 4.1', '/li',
array('li' => array('class' => 'item')), 'Item 4.2', '/li',
array('li' => array('class' => 'item')), 'Item 4.3',
array('ul' => array('class' => 'list')),
array('li' => array('class' => 'item')), 'Item 4.3.1', '/li',
array('li' => array('class' => 'item')), 'Item 4.3.2', '/li',
'/ul',
'/li',
'/ul',
'/li',
array('li' => array('class' => 'item')), 'Item 5',
array('ul' => array('class' => 'list')),
array('li' => array('class' => 'item')), 'Item 5.1', '/li',
array('li' => array('class' => 'item')), 'Item 5.2', '/li',
'/ul',
'/li',
'/ul'
);
$this->assertTags($result, $expected);
}
/**
* testMeta method
*
* @return void
*/
public function testMeta() {
$result = $this->Html->meta('this is an rss feed', array('controller' => 'posts', 'ext' => 'rss'));
$this->assertTags($result, array('link' => array('href' => 'preg:/.*\/posts\.rss/', 'type' => 'application/rss+xml', 'rel' => 'alternate', 'title' => 'this is an rss feed')));
$result = $this->Html->meta('rss', array('controller' => 'posts', 'ext' => 'rss'), array('title' => 'this is an rss feed'));
$this->assertTags($result, array('link' => array('href' => 'preg:/.*\/posts\.rss/', 'type' => 'application/rss+xml', 'rel' => 'alternate', 'title' => 'this is an rss feed')));
$result = $this->Html->meta('atom', array('controller' => 'posts', 'ext' => 'xml'));
$this->assertTags($result, array('link' => array('href' => 'preg:/.*\/posts\.xml/', 'type' => 'application/atom+xml', 'title' => 'atom')));
$result = $this->Html->meta('non-existing');
$this->assertTags($result, array('<meta'));
$result = $this->Html->meta('non-existing', '/posts.xpp');
$this->assertTags($result, array('link' => array('href' => 'preg:/.*\/posts\.xpp/', 'type' => 'application/rss+xml', 'rel' => 'alternate', 'title' => 'non-existing')));
$result = $this->Html->meta('non-existing', '/posts.xpp', array('type' => 'atom'));
$this->assertTags($result, array('link' => array('href' => 'preg:/.*\/posts\.xpp/', 'type' => 'application/atom+xml', 'title' => 'non-existing')));
$result = $this->Html->meta('atom', array('controller' => 'posts', 'ext' => 'xml'), array('link' => '/articles.rss'));
$this->assertTags($result, array('link' => array('href' => 'preg:/.*\/articles\.rss/', 'type' => 'application/atom+xml', 'title' => 'atom')));
$result = $this->Html->meta(array('link' => 'favicon.ico', 'rel' => 'icon'));
$expected = array(
'link' => array('href' => 'preg:/.*favicon\.ico/', 'rel' => 'icon'),
array('link' => array('href' => 'preg:/.*favicon\.ico/', 'rel' => 'shortcut icon'))
);
$this->assertTags($result, $expected);
$result = $this->Html->meta('icon', 'favicon.ico');
$expected = array(
'link' => array('href' => 'preg:/.*favicon\.ico/', 'type' => 'image/x-icon', 'rel' => 'icon'),
array('link' => array('href' => 'preg:/.*favicon\.ico/', 'type' => 'image/x-icon', 'rel' => 'shortcut icon'))
);
$this->assertTags($result, $expected);
$result = $this->Html->meta('icon');
$expected = array(
'link' => array('href' => 'preg:/.*favicon\.ico/', 'type' => 'image/x-icon', 'rel' => 'icon'),
array('link' => array('href' => 'preg:/.*favicon\.ico/', 'type' => 'image/x-icon', 'rel' => 'shortcut icon'))
);
$this->assertTags($result, $expected);
$result = $this->Html->meta('keywords', 'these, are, some, meta, keywords');
$this->assertTags($result, array('meta' => array('name' => 'keywords', 'content' => 'these, are, some, meta, keywords')));
$this->assertRegExp('/\s+\/>$/', $result);
$result = $this->Html->meta('description', 'this is the meta description');
$this->assertTags($result, array('meta' => array('name' => 'description', 'content' => 'this is the meta description')));
$result = $this->Html->meta(array('name' => 'ROBOTS', 'content' => 'ALL'));
$this->assertTags($result, array('meta' => array('name' => 'ROBOTS', 'content' => 'ALL')));
$this->View->expects($this->any())->method('addScript')
->with($this->matchesRegularExpression('/^<meta/'));
$result = $this->Html->meta(array('name' => 'ROBOTS', 'content' => 'ALL'), null, array('inline' => false));
$this->assertNull($result);
}
/**
* testTableHeaders method
*
* @return void
*/
public function testTableHeaders() {
$result = $this->Html->tableHeaders(array('ID', 'Name', 'Date'));
$expected = array('<tr', '<th', 'ID', '/th', '<th', 'Name', '/th', '<th', 'Date', '/th', '/tr');
$this->assertTags($result, $expected);
}
/**
* testTableCells method
*
* @return void
*/
public function testTableCells() {
$tr = array(
'td content 1',
array('td content 2', array("width" => "100px")),
array('td content 3', "width=100px")
);
$result = $this->Html->tableCells($tr);
$expected = array(
'<tr',
'<td', 'td content 1', '/td',
array('td' => array('width' => '100px')), 'td content 2', '/td',
array('td' => array('width' => 'preg:/100px/')), 'td content 3', '/td',
'/tr'
);
$this->assertTags($result, $expected);
$tr = array('td content 1', 'td content 2', 'td content 3');
$result = $this->Html->tableCells($tr, null, null, true);
$expected = array(
'<tr',
array('td' => array('class' => 'column-1')), 'td content 1', '/td',
array('td' => array('class' => 'column-2')), 'td content 2', '/td',
array('td' => array('class' => 'column-3')), 'td content 3', '/td',
'/tr'
);
$this->assertTags($result, $expected);
$tr = array('td content 1', 'td content 2', 'td content 3');
$result = $this->Html->tableCells($tr, true);
$expected = array(
'<tr',
array('td' => array('class' => 'column-1')), 'td content 1', '/td',
array('td' => array('class' => 'column-2')), 'td content 2', '/td',
array('td' => array('class' => 'column-3')), 'td content 3', '/td',
'/tr'
);
$this->assertTags($result, $expected);
$tr = array(
array('td content 1', 'td content 2', 'td content 3'),
array('td content 1', 'td content 2', 'td content 3'),
array('td content 1', 'td content 2', 'td content 3')
);
$result = $this->Html->tableCells($tr, array('class' => 'odd'), array('class' => 'even'));
$expected = "<tr class=\"even\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"odd\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"even\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>";
$this->assertEquals($expected, $result);
$tr = array(
array('td content 1', 'td content 2', 'td content 3'),
array('td content 1', 'td content 2', 'td content 3'),
array('td content 1', 'td content 2', 'td content 3'),
array('td content 1', 'td content 2', 'td content 3')
);
$result = $this->Html->tableCells($tr, array('class' => 'odd'), array('class' => 'even'));
$expected = "<tr class=\"odd\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"even\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"odd\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"even\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>";
$this->assertEquals($expected, $result);
$tr = array(
array('td content 1', 'td content 2', 'td content 3'),
array('td content 1', 'td content 2', 'td content 3'),
array('td content 1', 'td content 2', 'td content 3')
);
$this->Html->tableCells($tr, array('class' => 'odd'), array('class' => 'even'));
$result = $this->Html->tableCells($tr, array('class' => 'odd'), array('class' => 'even'), false, false);
$expected = "<tr class=\"odd\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"even\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"odd\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>";
$this->assertEquals($expected, $result);
}
/**
* testTag method
*
* @return void
*/
public function testTag() {
$result = $this->Html->tag('div');
$this->assertTags($result, '<div');
$result = $this->Html->tag('div', 'text');
$this->assertTags($result, '<div', 'text', '/div');
$result = $this->Html->tag('div', '<text>', 'class-name');
$this->assertTags($result, array('div' => array('class' => 'class-name'), 'preg:/<text>/', '/div'));
$result = $this->Html->tag('div', '<text>', array('class' => 'class-name', 'escape' => true));
$this->assertTags($result, array('div' => array('class' => 'class-name'), '<text>', '/div'));
}
/**
* testUseTag method
*
* @return void
*/
public function testUseTag() {
$result = $this->Html->useTag('unknowntag');
$this->assertEquals($result, '');
$result = $this->Html->useTag('formend');
$this->assertTags($result, '/form');
$result = $this->Html->useTag('form', 'url', ' test');
$this->assertEquals($result, '<form action="url" test>');
$result = $this->Html->useTag('form', 'example.com', array('test' => 'ok'));
$this->assertTags($result, array('form' => array('test' => 'ok', 'action' => 'example.com')));
}
/**
* testDiv method
*
* @return void
*/
public function testDiv() {
$result = $this->Html->div('class-name');
$this->assertTags($result, array('div' => array('class' => 'class-name')));
$result = $this->Html->div('class-name', 'text');
$this->assertTags($result, array('div' => array('class' => 'class-name'), 'text', '/div'));
$result = $this->Html->div('class-name', '<text>', array('escape' => true));
$this->assertTags($result, array('div' => array('class' => 'class-name'), '<text>', '/div'));
}
/**
* testPara method
*
* @return void
*/
public function testPara() {
$result = $this->Html->para('class-name', '');
$this->assertTags($result, array('p' => array('class' => 'class-name')));
$result = $this->Html->para('class-name', 'text');
$this->assertTags($result, array('p' => array('class' => 'class-name'), 'text', '/p'));
$result = $this->Html->para('class-name', '<text>', array('escape' => true));
$this->assertTags($result, array('p' => array('class' => 'class-name'), '<text>', '/p'));
}
/**
* testCrumbList method
*
*
* @return void
*/
public function testCrumbList() {
$this->assertNull($this->Html->getCrumbList());
$this->Html->addCrumb('Home', '/', array('class' => 'home'));
$this->Html->addCrumb('Some page', '/some_page');
$this->Html->addCrumb('Another page');
$result = $this->Html->getCrumbList(
array('class' => 'breadcrumbs')
);
$this->assertTags(
$result,
array(
array('ul' => array('class' => 'breadcrumbs')),
array('li' => array('class' => 'first')),
array('a' => array('class' => 'home', 'href' => '/')), 'Home', '/a',
'/li',
'<li',
array('a' => array('href' => '/some_page')), 'Some page', '/a',
'/li',
array('li' => array('class' => 'last')),
'Another page',
'/li',
'/ul'
)
);
}
/**
* testLoadConfig method
*
* @return void
*/
public function testLoadConfig() {
$path = CAKE . 'Test' . DS . 'test_app' . DS . 'Config'. DS;
$result = $this->Html->loadConfig('htmlhelper_tags', $path);
$expected = array(
'tags' => array(
'form' => 'start form',
'formend' => 'finish form'
)
);
$this->assertEquals($expected, $result);
$tags = $this->Html->getAttribute('_tags');
$this->assertEquals($tags['form'], 'start form');
$this->assertEquals($tags['formend'], 'finish form');
$this->assertEquals($tags['selectend'], '</select>');
$result = $this->Html->loadConfig(array('htmlhelper_minimized.ini', 'ini'), $path);
$expected = array(
'minimizedAttributeFormat' => 'format'
);
$this->assertEquals($expected, $result);
$this->assertEquals($this->Html->getAttribute('_minimizedAttributeFormat'), 'format');
}
/**
* testLoadConfigWrongFile method
*
* @return void
* @expectedException ConfigureException
*/
public function testLoadConfigWrongFile() {
$result = $this->Html->loadConfig('wrong_file');
}
/**
* testLoadConfigWrongReader method
*
* @return void
* @expectedException ConfigureException
*/
public function testLoadConfigWrongReader() {
$path = CAKE . 'Test' . DS . 'test_app' . DS . 'Config'. DS;
$result = $this->Html->loadConfig(array('htmlhelper_tags', 'wrong_reader'), $path);
}
/**
* test parsing attributes.
*
* @return void
*/
public function testParseAttributeCompact() {
$helper = new TestHtmlHelper($this->View);
$compact = array('compact', 'checked', 'declare', 'readonly', 'disabled',
'selected', 'defer', 'ismap', 'nohref', 'noshade', 'nowrap', 'multiple', 'noresize');
foreach ($compact as $attribute) {
foreach (array('true', true, 1, '1', $attribute) as $value) {
$attrs = array($attribute => $value);
$expected = ' ' . $attribute . '="' . $attribute . '"';
$this->assertEquals($helper->parseAttributes($attrs), $expected, '%s Failed on ' . $value);
}
}
$this->assertEquals($helper->parseAttributes(array('compact')), ' compact="compact"');
$attrs = array('class' => array('foo', 'bar'));
$expected = ' class="foo bar"';
$this->assertEquals(' class="foo bar"', $helper->parseAttributes($attrs));
$helper = new Html5TestHelper($this->View);
$expected = ' require';
$this->assertEquals($helper->parseAttributes(array('require')), $expected);
$this->assertEquals($helper->parseAttributes(array('require' => true)), $expected);
$this->assertEquals($helper->parseAttributes(array('require' => false)), '');
}
}
| parkr/HEC-87-Database-Admin | lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php | PHP | agpl-3.0 | 46,763 |
Hide Top Grades Navigation
======
Use this Javascript to hide the grades navigation at the top of Canvas.
Support
======
This is an unsupported, community-created project. Keep that in
mind. Instructure won't be able to help you fix or debug this.
That said, the community will hopefully help support and keep
both the script and this documentation up-to-date.
Good luck!
| kajigga/canvas-contrib | Branding/JavaScript/hide_grades_top_nav/README.md | Markdown | agpl-3.0 | 376 |
/*
* Kuali Coeus, a comprehensive research administration system for higher education.
*
* Copyright 2005-2015 Kuali, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.kuali.kra.meeting;
import org.kuali.coeus.common.committee.impl.meeting.CommitteeScheduleAttendanceBase;
import org.kuali.coeus.common.committee.impl.meeting.OtherPresentBeanBase;
/**
*
* This class is form data for other present.
*/
public class OtherPresentBean extends OtherPresentBeanBase {
private static final long serialVersionUID = -2827619336606027054L;
@Override
protected CommitteeScheduleAttendanceBase getNewCommitteeScheduleAttendanceInstanceHook() {
return new CommitteeScheduleAttendance();
}
}
| sanjupolus/KC6.oLatest | coeus-impl/src/main/java/org/kuali/kra/meeting/OtherPresentBean.java | Java | agpl-3.0 | 1,361 |
package tc.oc.pgm.loot;
import org.bukkit.inventory.ItemStack;
import tc.oc.commons.core.inject.HybridManifest;
import tc.oc.pgm.compose.ComposableManifest;
import tc.oc.pgm.features.FeatureBinder;
import tc.oc.pgm.match.MatchScope;
import tc.oc.pgm.match.inject.MatchBinders;
import tc.oc.pgm.match.inject.MatchScoped;
import tc.oc.pgm.xml.parser.ParserBinders;
public class LootManifest extends HybridManifest implements MatchBinders, ParserBinders {
@Override
protected void configure() {
final FeatureBinder<Loot> loot = new FeatureBinder<>(binder(), Loot.class);
loot.installReflectiveParser();
loot.installRootParser();
final FeatureBinder<Filler> fill = new FeatureBinder<>(binder(), Filler.class);
fill.installReflectiveParser();
fill.installRootParser();
final FeatureBinder<Cache> cache = new FeatureBinder<>(binder(), Cache.class);
cache.installReflectiveParser();
cache.installRootParser();
install(new ComposableManifest<ItemStack>(){}); // Parser<Composition<ItemStack>>
bind(FillListener.class).in(MatchScoped.class);
matchListener(FillListener.class, MatchScope.LOADED);
}
}
| cswhite2000/ProjectAres | PGM/src/main/java/tc/oc/pgm/loot/LootManifest.java | Java | agpl-3.0 | 1,206 |
--[[
Illarion Server
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU Affero General Public License as published by the Free
Software Foundation, either version 3 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 Affero General Public License for more
details.
You should have received a copy of the GNU Affero General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
]]
local spellProjectile = require("monster.base.spells.projectile")
local function _isTable(value)
return type(value) == "table"
end
return function(params)
if params == nil then
params = {}
end
if not _isTable(params) then
error("The parameters for the fireball spell aren't a table.")
end
if params.gfxId == nil then params.gfxId = 8 end
if params.sfxId == nil then params.sfxId = 5 end
if params.trailGfxId == nil then params.trailGfxId = 1 end
return spellProjectile(params)
end | vilarion/Illarion-Content | monster/base/spells/poisonball.lua | Lua | agpl-3.0 | 1,194 |
CREATE OR REPLACE FUNCTION
issues_update_open_all (
new_open boolean,
course_id bigint,
authn_user_id bigint
) RETURNS void
AS $$
DECLARE
old_open boolean;
BEGIN
WITH updated_issues AS (
UPDATE issues AS e
SET open = new_open
WHERE
e.course_id = issues_update_open_all.course_id
AND e.course_caused
AND e.open IS DISTINCT FROM new_open
RETURNING e.id, e.open
)
INSERT INTO audit_logs
(authn_user_id, course_id,
table_name, column_name, row_id, action,
parameters, new_state)
SELECT
authn_user_id, course_id,
'issues', 'open', e.id, 'update',
jsonb_build_object('course_id', course_id),
jsonb_build_object('open', e.open)
FROM updated_issues AS e;
END;
$$ LANGUAGE plpgsql VOLATILE;
| jakebailey/PrairieLearn | sprocs/issues_update_open_all.sql | SQL | agpl-3.0 | 863 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.